proc-v7.S 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259
  1. /*
  2. * linux/arch/arm/mm/proc-v7.S
  3. *
  4. * Copyright (C) 2001 Deep Blue Solutions Ltd.
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License version 2 as
  8. * published by the Free Software Foundation.
  9. *
  10. * This is the "shell" of the ARMv7 processor support.
  11. */
  12. #include <linux/linkage.h>
  13. #include <asm/assembler.h>
  14. #include <asm/asm-offsets.h>
  15. #include <asm/hwcap.h>
  16. #include <asm/pgtable-hwdef.h>
  17. #include <asm/pgtable.h>
  18. #include "proc-macros.S"
  19. #define TTB_C (1 << 0)
  20. #define TTB_S (1 << 1)
  21. #define TTB_RGN_OC_WT (2 << 3)
  22. #define TTB_RGN_OC_WB (3 << 3)
  23. ENTRY(cpu_v7_proc_init)
  24. mov pc, lr
  25. ENDPROC(cpu_v7_proc_init)
  26. ENTRY(cpu_v7_proc_fin)
  27. mov pc, lr
  28. ENDPROC(cpu_v7_proc_fin)
  29. /*
  30. * cpu_v7_reset(loc)
  31. *
  32. * Perform a soft reset of the system. Put the CPU into the
  33. * same state as it would be if it had been reset, and branch
  34. * to what would be the reset vector.
  35. *
  36. * - loc - location to jump to for soft reset
  37. *
  38. * It is assumed that:
  39. */
  40. .align 5
  41. ENTRY(cpu_v7_reset)
  42. mov pc, r0
  43. ENDPROC(cpu_v7_reset)
  44. /*
  45. * cpu_v7_do_idle()
  46. *
  47. * Idle the processor (eg, wait for interrupt).
  48. *
  49. * IRQs are already disabled.
  50. */
  51. ENTRY(cpu_v7_do_idle)
  52. wfi
  53. mov pc, lr
  54. ENDPROC(cpu_v7_do_idle)
  55. ENTRY(cpu_v7_dcache_clean_area)
  56. #ifndef TLB_CAN_READ_FROM_L1_CACHE
  57. dcache_line_size r2, r3
  58. 1: mcr p15, 0, r0, c7, c10, 1 @ clean D entry
  59. add r0, r0, r2
  60. subs r1, r1, r2
  61. bhi 1b
  62. dsb
  63. #endif
  64. mov pc, lr
  65. ENDPROC(cpu_v7_dcache_clean_area)
  66. /*
  67. * cpu_v7_switch_mm(pgd_phys, tsk)
  68. *
  69. * Set the translation table base pointer to be pgd_phys
  70. *
  71. * - pgd_phys - physical address of new TTB
  72. *
  73. * It is assumed that:
  74. * - we are not using split page tables
  75. */
  76. ENTRY(cpu_v7_switch_mm)
  77. #ifdef CONFIG_MMU
  78. mov r2, #0
  79. ldr r1, [r1, #MM_CONTEXT_ID] @ get mm->context.id
  80. orr r0, r0, #TTB_RGN_OC_WB @ mark PTWs outer cacheable, WB
  81. mcr p15, 0, r2, c13, c0, 1 @ set reserved context ID
  82. isb
  83. 1: mcr p15, 0, r0, c2, c0, 0 @ set TTB 0
  84. isb
  85. mcr p15, 0, r1, c13, c0, 1 @ set context ID
  86. isb
  87. #endif
  88. mov pc, lr
  89. ENDPROC(cpu_v7_switch_mm)
  90. /*
  91. * cpu_v7_set_pte_ext(ptep, pte)
  92. *
  93. * Set a level 2 translation table entry.
  94. *
  95. * - ptep - pointer to level 2 translation table entry
  96. * (hardware version is stored at -1024 bytes)
  97. * - pte - PTE value to store
  98. * - ext - value for extended PTE bits
  99. */
  100. ENTRY(cpu_v7_set_pte_ext)
  101. #ifdef CONFIG_MMU
  102. str r1, [r0], #-2048 @ linux version
  103. bic r3, r1, #0x000003f0
  104. bic r3, r3, #PTE_TYPE_MASK
  105. orr r3, r3, r2
  106. orr r3, r3, #PTE_EXT_AP0 | 2
  107. tst r2, #1 << 4
  108. orrne r3, r3, #PTE_EXT_TEX(1)
  109. tst r1, #L_PTE_WRITE
  110. tstne r1, #L_PTE_DIRTY
  111. orreq r3, r3, #PTE_EXT_APX
  112. tst r1, #L_PTE_USER
  113. orrne r3, r3, #PTE_EXT_AP1
  114. tstne r3, #PTE_EXT_APX
  115. bicne r3, r3, #PTE_EXT_APX | PTE_EXT_AP0
  116. tst r1, #L_PTE_EXEC
  117. orreq r3, r3, #PTE_EXT_XN
  118. tst r1, #L_PTE_YOUNG
  119. tstne r1, #L_PTE_PRESENT
  120. moveq r3, #0
  121. str r3, [r0]
  122. mcr p15, 0, r0, c7, c10, 1 @ flush_pte
  123. #endif
  124. mov pc, lr
  125. ENDPROC(cpu_v7_set_pte_ext)
  126. cpu_v7_name:
  127. .ascii "ARMv7 Processor"
  128. .align
  129. .section ".text.init", #alloc, #execinstr
  130. /*
  131. * __v7_setup
  132. *
  133. * Initialise TLB, Caches, and MMU state ready to switch the MMU
  134. * on. Return in r0 the new CP15 C1 control register setting.
  135. *
  136. * We automatically detect if we have a Harvard cache, and use the
  137. * Harvard cache control instructions insead of the unified cache
  138. * control instructions.
  139. *
  140. * This should be able to cover all ARMv7 cores.
  141. *
  142. * It is assumed that:
  143. * - cache type register is implemented
  144. */
  145. __v7_setup:
  146. adr r12, __v7_setup_stack @ the local stack
  147. stmia r12, {r0-r5, r7, r9, r11, lr}
  148. bl v7_flush_dcache_all
  149. ldmia r12, {r0-r5, r7, r9, r11, lr}
  150. mov r10, #0
  151. #ifdef HARVARD_CACHE
  152. mcr p15, 0, r10, c7, c5, 0 @ I+BTB cache invalidate
  153. #endif
  154. dsb
  155. #ifdef CONFIG_MMU
  156. mcr p15, 0, r10, c8, c7, 0 @ invalidate I + D TLBs
  157. mcr p15, 0, r10, c2, c0, 2 @ TTB control register
  158. orr r4, r4, #TTB_RGN_OC_WB @ mark PTWs outer cacheable, WB
  159. mcr p15, 0, r4, c2, c0, 0 @ load TTB0
  160. mcr p15, 0, r4, c2, c0, 1 @ load TTB1
  161. mov r10, #0x1f @ domains 0, 1 = manager
  162. mcr p15, 0, r10, c3, c0, 0 @ load domain access register
  163. #endif
  164. ldr r5, =0x40e040e0
  165. ldr r6, =0xff0aa1a8
  166. mcr p15, 0, r5, c10, c2, 0 @ write PRRR
  167. mcr p15, 0, r6, c10, c2, 1 @ write NMRR
  168. adr r5, v7_crval
  169. ldmia r5, {r5, r6}
  170. mrc p15, 0, r0, c1, c0, 0 @ read control register
  171. bic r0, r0, r5 @ clear bits them
  172. orr r0, r0, r6 @ set them
  173. mov pc, lr @ return to head.S:__ret
  174. ENDPROC(__v7_setup)
  175. /*
  176. * V X F I D LR
  177. * .... ...E PUI. .T.T 4RVI ZFRS BLDP WCAM
  178. * rrrr rrrx xxx0 0101 xxxx xxxx x111 xxxx < forced
  179. * 0 110 0011 1.00 .111 1101 < we want
  180. */
  181. .type v7_crval, #object
  182. v7_crval:
  183. crval clear=0x0120c302, mmuset=0x10c0387d, ucset=0x00c0187c
  184. __v7_setup_stack:
  185. .space 4 * 11 @ 11 registers
  186. .type v7_processor_functions, #object
  187. ENTRY(v7_processor_functions)
  188. .word v7_early_abort
  189. .word pabort_ifar
  190. .word cpu_v7_proc_init
  191. .word cpu_v7_proc_fin
  192. .word cpu_v7_reset
  193. .word cpu_v7_do_idle
  194. .word cpu_v7_dcache_clean_area
  195. .word cpu_v7_switch_mm
  196. .word cpu_v7_set_pte_ext
  197. .size v7_processor_functions, . - v7_processor_functions
  198. .type cpu_arch_name, #object
  199. cpu_arch_name:
  200. .asciz "armv7"
  201. .size cpu_arch_name, . - cpu_arch_name
  202. .type cpu_elf_name, #object
  203. cpu_elf_name:
  204. .asciz "v7"
  205. .size cpu_elf_name, . - cpu_elf_name
  206. .align
  207. .section ".proc.info.init", #alloc, #execinstr
  208. /*
  209. * Match any ARMv7 processor core.
  210. */
  211. .type __v7_proc_info, #object
  212. __v7_proc_info:
  213. .long 0x000f0000 @ Required ID value
  214. .long 0x000f0000 @ Mask for ID
  215. .long PMD_TYPE_SECT | \
  216. PMD_SECT_BUFFERABLE | \
  217. PMD_SECT_CACHEABLE | \
  218. PMD_SECT_AP_WRITE | \
  219. PMD_SECT_AP_READ
  220. .long PMD_TYPE_SECT | \
  221. PMD_SECT_XN | \
  222. PMD_SECT_AP_WRITE | \
  223. PMD_SECT_AP_READ
  224. b __v7_setup
  225. .long cpu_arch_name
  226. .long cpu_elf_name
  227. .long HWCAP_SWP|HWCAP_HALF|HWCAP_THUMB|HWCAP_FAST_MULT|HWCAP_EDSP
  228. .long cpu_v7_name
  229. .long v7_processor_functions
  230. .long v7wbi_tlb_fns
  231. .long v6_user_fns
  232. .long v7_cache_fns
  233. .size __v7_proc_info, . - __v7_proc_info