cps-vec.S 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. /*
  2. * Copyright (C) 2013 Imagination Technologies
  3. * Author: Paul Burton <paul.burton@imgtec.com>
  4. *
  5. * This program is free software; you can redistribute it and/or modify it
  6. * under the terms of the GNU General Public License as published by the
  7. * Free Software Foundation; either version 2 of the License, or (at your
  8. * option) any later version.
  9. */
  10. #include <asm/addrspace.h>
  11. #include <asm/asm.h>
  12. #include <asm/asm-offsets.h>
  13. #include <asm/asmmacro.h>
  14. #include <asm/cacheops.h>
  15. #include <asm/mipsregs.h>
  16. #define GCR_CL_COHERENCE_OFS 0x2008
  17. .section .text.cps-vec
  18. .balign 0x1000
  19. .set noreorder
  20. LEAF(mips_cps_core_entry)
  21. /*
  22. * These first 8 bytes will be patched by cps_smp_setup to load the
  23. * base address of the CM GCRs into register v1.
  24. */
  25. .quad 0
  26. /* Check whether we're here due to an NMI */
  27. mfc0 k0, CP0_STATUS
  28. and k0, k0, ST0_NMI
  29. beqz k0, not_nmi
  30. nop
  31. /* This is an NMI */
  32. la k0, nmi_handler
  33. jr k0
  34. nop
  35. not_nmi:
  36. /* Setup Cause */
  37. li t0, CAUSEF_IV
  38. mtc0 t0, CP0_CAUSE
  39. /* Setup Status */
  40. li t0, ST0_CU1 | ST0_CU0
  41. mtc0 t0, CP0_STATUS
  42. /*
  43. * Clear the bits used to index the caches. Note that the architecture
  44. * dictates that writing to any of TagLo or TagHi selects 0 or 2 should
  45. * be valid for all MIPS32 CPUs, even those for which said writes are
  46. * unnecessary.
  47. */
  48. mtc0 zero, CP0_TAGLO, 0
  49. mtc0 zero, CP0_TAGHI, 0
  50. mtc0 zero, CP0_TAGLO, 2
  51. mtc0 zero, CP0_TAGHI, 2
  52. ehb
  53. /* Primary cache configuration is indicated by Config1 */
  54. mfc0 v0, CP0_CONFIG, 1
  55. /* Detect I-cache line size */
  56. _EXT t0, v0, MIPS_CONF1_IL_SHF, MIPS_CONF1_IL_SZ
  57. beqz t0, icache_done
  58. li t1, 2
  59. sllv t0, t1, t0
  60. /* Detect I-cache size */
  61. _EXT t1, v0, MIPS_CONF1_IS_SHF, MIPS_CONF1_IS_SZ
  62. xori t2, t1, 0x7
  63. beqz t2, 1f
  64. li t3, 32
  65. addi t1, t1, 1
  66. sllv t1, t3, t1
  67. 1: /* At this point t1 == I-cache sets per way */
  68. _EXT t2, v0, MIPS_CONF1_IA_SHF, MIPS_CONF1_IA_SZ
  69. addi t2, t2, 1
  70. mul t1, t1, t0
  71. mul t1, t1, t2
  72. li a0, KSEG0
  73. add a1, a0, t1
  74. 1: cache Index_Store_Tag_I, 0(a0)
  75. add a0, a0, t0
  76. bne a0, a1, 1b
  77. nop
  78. icache_done:
  79. /* Detect D-cache line size */
  80. _EXT t0, v0, MIPS_CONF1_DL_SHF, MIPS_CONF1_DL_SZ
  81. beqz t0, dcache_done
  82. li t1, 2
  83. sllv t0, t1, t0
  84. /* Detect D-cache size */
  85. _EXT t1, v0, MIPS_CONF1_DS_SHF, MIPS_CONF1_DS_SZ
  86. xori t2, t1, 0x7
  87. beqz t2, 1f
  88. li t3, 32
  89. addi t1, t1, 1
  90. sllv t1, t3, t1
  91. 1: /* At this point t1 == D-cache sets per way */
  92. _EXT t2, v0, MIPS_CONF1_DA_SHF, MIPS_CONF1_DA_SZ
  93. addi t2, t2, 1
  94. mul t1, t1, t0
  95. mul t1, t1, t2
  96. li a0, KSEG0
  97. addu a1, a0, t1
  98. subu a1, a1, t0
  99. 1: cache Index_Store_Tag_D, 0(a0)
  100. bne a0, a1, 1b
  101. add a0, a0, t0
  102. dcache_done:
  103. /* Set Kseg0 cacheable, coherent, write-back, write-allocate */
  104. mfc0 t0, CP0_CONFIG
  105. ori t0, 0x7
  106. xori t0, 0x2
  107. mtc0 t0, CP0_CONFIG
  108. ehb
  109. /* Enter the coherent domain */
  110. li t0, 0xff
  111. sw t0, GCR_CL_COHERENCE_OFS(v1)
  112. ehb
  113. /* Jump to kseg0 */
  114. la t0, 1f
  115. jr t0
  116. nop
  117. 1: /* We're up, cached & coherent */
  118. /*
  119. * TODO: We should check the VPE number we intended to boot here, and
  120. * if non-zero we should start that VPE and stop this one. For
  121. * the moment this doesn't matter since CPUs are brought up
  122. * sequentially and in order, but once hotplug is implemented
  123. * this will need revisiting.
  124. */
  125. /* Off we go! */
  126. la t0, mips_cps_bootcfg
  127. lw t1, BOOTCFG_PC(t0)
  128. lw gp, BOOTCFG_GP(t0)
  129. lw sp, BOOTCFG_SP(t0)
  130. jr t1
  131. nop
  132. END(mips_cps_core_entry)
  133. .org 0x200
  134. LEAF(excep_tlbfill)
  135. b .
  136. nop
  137. END(excep_tlbfill)
  138. .org 0x280
  139. LEAF(excep_xtlbfill)
  140. b .
  141. nop
  142. END(excep_xtlbfill)
  143. .org 0x300
  144. LEAF(excep_cache)
  145. b .
  146. nop
  147. END(excep_cache)
  148. .org 0x380
  149. LEAF(excep_genex)
  150. b .
  151. nop
  152. END(excep_genex)
  153. .org 0x400
  154. LEAF(excep_intex)
  155. b .
  156. nop
  157. END(excep_intex)
  158. .org 0x480
  159. LEAF(excep_ejtag)
  160. la k0, ejtag_debug_handler
  161. jr k0
  162. nop
  163. END(excep_ejtag)