Sony PlayStation2 Study
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

138 lines
2.9 KiB

4 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. /*
  2. * Copyright (c) 2003 Wolfgang Denk <wd@denx.de>
  3. * Copyright (c) 2014 Juergen Urban
  4. *
  5. * SPDX-License-Identifier: GPL-2.0+
  6. */
  7. #include <common.h>
  8. #include <command.h>
  9. #include <netdev.h>
  10. #include <asm/mipsregs.h>
  11. #include <asm/cacheops.h>
  12. #include <asm/reboot.h>
  13. #define dcache_op(op,addr) \
  14. __asm__ __volatile__( \
  15. " .set push \n" \
  16. " .set noreorder \n" \
  17. " .set mips3\n\t \n" \
  18. " sync.l \n" \
  19. " cache %0, %1 \n" \
  20. " sync.l \n" \
  21. " .set pop \n" \
  22. : \
  23. : "i" (op), "R" (*(unsigned char *)(addr)))
  24. #define icache_op(op,addr) \
  25. __asm__ __volatile__( \
  26. " .set push \n" \
  27. " .set noreorder \n" \
  28. " .set mips3\n\t \n" \
  29. " sync.p \n" \
  30. " cache %0, %1 \n" \
  31. " sync.p \n" \
  32. " .set pop \n" \
  33. : \
  34. : "i" (op), "R" (*(unsigned char *)(addr)))
  35. void __attribute__((weak)) _machine_restart(void)
  36. {
  37. }
  38. int do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
  39. {
  40. _machine_restart();
  41. fprintf(stderr, "*** reset failed ***\n");
  42. return 0;
  43. }
  44. #ifdef CONFIG_SYS_CACHELINE_SIZE
  45. static inline unsigned long icache_line_size(void)
  46. {
  47. return CONFIG_SYS_CACHELINE_SIZE;
  48. }
  49. static inline unsigned long dcache_line_size(void)
  50. {
  51. return CONFIG_SYS_CACHELINE_SIZE;
  52. }
  53. #endif /* CONFIG_SYS_CACHELINE_SIZE */
  54. void flush_cache(ulong start_addr, ulong size)
  55. {
  56. unsigned long ilsize = icache_line_size();
  57. unsigned long dlsize = dcache_line_size();
  58. unsigned long addr, aend;
  59. /* aend will be miscalculated when size is zero, so we return here */
  60. if (size == 0)
  61. return;
  62. addr = start_addr & ~(dlsize - 1);
  63. aend = (start_addr + size - 1) & ~(dlsize - 1);
  64. if (ilsize == dlsize) {
  65. /* flush I-cache & D-cache simultaneously */
  66. while (1) {
  67. dcache_op(R5900_HIT_WRITEBACK_INV_D, addr);
  68. icache_op(R5900_HIT_INVALIDATE_I, addr);
  69. if (addr == aend)
  70. break;
  71. addr += dlsize;
  72. }
  73. return;
  74. }
  75. /* flush D-cache */
  76. while (1) {
  77. dcache_op(R5900_HIT_WRITEBACK_INV_D, addr);
  78. if (addr == aend)
  79. break;
  80. addr += dlsize;
  81. }
  82. /* flush I-cache */
  83. addr = start_addr & ~(ilsize - 1);
  84. aend = (start_addr + size - 1) & ~(ilsize - 1);
  85. while (1) {
  86. icache_op(R5900_HIT_INVALIDATE_I, addr);
  87. if (addr == aend)
  88. break;
  89. addr += ilsize;
  90. }
  91. }
  92. void flush_dcache_range(ulong start_addr, ulong stop)
  93. {
  94. unsigned long lsize = dcache_line_size();
  95. unsigned long addr = start_addr & ~(lsize - 1);
  96. unsigned long aend = (stop - 1) & ~(lsize - 1);
  97. while (1) {
  98. dcache_op(R5900_HIT_WRITEBACK_INV_D, addr);
  99. if (addr == aend)
  100. break;
  101. addr += lsize;
  102. }
  103. }
  104. void invalidate_dcache_range(ulong start_addr, ulong stop)
  105. {
  106. unsigned long lsize = dcache_line_size();
  107. unsigned long addr = start_addr & ~(lsize - 1);
  108. unsigned long aend = (stop - 1) & ~(lsize - 1);
  109. while (1) {
  110. dcache_op(R5900_HIT_INVALIDATE_D, addr);
  111. if (addr == aend)
  112. break;
  113. addr += lsize;
  114. }
  115. }
  116. int cpu_eth_init(bd_t *bis)
  117. {
  118. return 0;
  119. }