proc-v7.S 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264
  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/elf.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. .long 0xe320f003 @ ARM V7 WFI instruction
  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. * Permissions:
  101. * YUWD APX AP1 AP0 SVC User
  102. * 0xxx 0 0 0 no acc no acc
  103. * 100x 1 0 1 r/o no acc
  104. * 10x0 1 0 1 r/o no acc
  105. * 1011 0 0 1 r/w no acc
  106. * 110x 0 1 0 r/w r/o
  107. * 11x0 0 1 0 r/w r/o
  108. * 1111 0 1 1 r/w r/w
  109. */
  110. ENTRY(cpu_v7_set_pte_ext)
  111. #ifdef CONFIG_MMU
  112. str r1, [r0], #-2048 @ linux version
  113. bic r3, r1, #0x000003f0
  114. bic r3, r3, #0x00000003
  115. orr r3, r3, r2
  116. orr r3, r3, #PTE_EXT_AP0 | 2
  117. tst r1, #L_PTE_WRITE
  118. tstne r1, #L_PTE_DIRTY
  119. orreq r3, r3, #PTE_EXT_APX
  120. tst r1, #L_PTE_USER
  121. orrne r3, r3, #PTE_EXT_AP1
  122. tstne r3, #PTE_EXT_APX
  123. bicne r3, r3, #PTE_EXT_APX | PTE_EXT_AP0
  124. tst r1, #L_PTE_YOUNG
  125. biceq r3, r3, #PTE_EXT_APX | PTE_EXT_AP_MASK
  126. tst r1, #L_PTE_EXEC
  127. orreq r3, r3, #PTE_EXT_XN
  128. tst r1, #L_PTE_PRESENT
  129. moveq r3, #0
  130. str r3, [r0]
  131. mcr p15, 0, r0, c7, c10, 1 @ flush_pte
  132. #endif
  133. mov pc, lr
  134. ENDPROC(cpu_v7_set_pte_ext)
  135. cpu_v7_name:
  136. .ascii "ARMv7 Processor"
  137. .align
  138. .section ".text.init", #alloc, #execinstr
  139. /*
  140. * __v7_setup
  141. *
  142. * Initialise TLB, Caches, and MMU state ready to switch the MMU
  143. * on. Return in r0 the new CP15 C1 control register setting.
  144. *
  145. * We automatically detect if we have a Harvard cache, and use the
  146. * Harvard cache control instructions insead of the unified cache
  147. * control instructions.
  148. *
  149. * This should be able to cover all ARMv7 cores.
  150. *
  151. * It is assumed that:
  152. * - cache type register is implemented
  153. */
  154. __v7_setup:
  155. adr r12, __v7_setup_stack @ the local stack
  156. stmia r12, {r0-r5, r7, r9, r11, lr}
  157. bl v7_flush_dcache_all
  158. ldmia r12, {r0-r5, r7, r9, r11, lr}
  159. mov r10, #0
  160. #ifdef HARVARD_CACHE
  161. mcr p15, 0, r10, c7, c5, 0 @ I+BTB cache invalidate
  162. #endif
  163. dsb
  164. #ifdef CONFIG_MMU
  165. mcr p15, 0, r10, c8, c7, 0 @ invalidate I + D TLBs
  166. mcr p15, 0, r10, c2, c0, 2 @ TTB control register
  167. orr r4, r4, #TTB_RGN_OC_WB @ mark PTWs outer cacheable, WB
  168. mcr p15, 0, r4, c2, c0, 0 @ load TTB0
  169. mcr p15, 0, r4, c2, c0, 1 @ load TTB1
  170. mov r10, #0x1f @ domains 0, 1 = manager
  171. mcr p15, 0, r10, c3, c0, 0 @ load domain access register
  172. #endif
  173. adr r5, v7_crval
  174. ldmia r5, {r5, r6}
  175. mrc p15, 0, r0, c1, c0, 0 @ read control register
  176. bic r0, r0, r5 @ clear bits them
  177. orr r0, r0, r6 @ set them
  178. mov pc, lr @ return to head.S:__ret
  179. ENDPROC(__v7_setup)
  180. /*
  181. * V X F I D LR
  182. * .... ...E PUI. .T.T 4RVI ZFRS BLDP WCAM
  183. * rrrr rrrx xxx0 0101 xxxx xxxx x111 xxxx < forced
  184. * 0 110 0011 1.00 .111 1101 < we want
  185. */
  186. .type v7_crval, #object
  187. v7_crval:
  188. crval clear=0x0120c302, mmuset=0x00c0387d, ucset=0x00c0187c
  189. __v7_setup_stack:
  190. .space 4 * 11 @ 11 registers
  191. .type v7_processor_functions, #object
  192. ENTRY(v7_processor_functions)
  193. .word v7_early_abort
  194. .word pabort_ifar
  195. .word cpu_v7_proc_init
  196. .word cpu_v7_proc_fin
  197. .word cpu_v7_reset
  198. .word cpu_v7_do_idle
  199. .word cpu_v7_dcache_clean_area
  200. .word cpu_v7_switch_mm
  201. .word cpu_v7_set_pte_ext
  202. .size v7_processor_functions, . - v7_processor_functions
  203. .type cpu_arch_name, #object
  204. cpu_arch_name:
  205. .asciz "armv7"
  206. .size cpu_arch_name, . - cpu_arch_name
  207. .type cpu_elf_name, #object
  208. cpu_elf_name:
  209. .asciz "v7"
  210. .size cpu_elf_name, . - cpu_elf_name
  211. .align
  212. .section ".proc.info.init", #alloc, #execinstr
  213. /*
  214. * Match any ARMv7 processor core.
  215. */
  216. .type __v7_proc_info, #object
  217. __v7_proc_info:
  218. .long 0x000f0000 @ Required ID value
  219. .long 0x000f0000 @ Mask for ID
  220. .long PMD_TYPE_SECT | \
  221. PMD_SECT_BUFFERABLE | \
  222. PMD_SECT_CACHEABLE | \
  223. PMD_SECT_AP_WRITE | \
  224. PMD_SECT_AP_READ
  225. .long PMD_TYPE_SECT | \
  226. PMD_SECT_XN | \
  227. PMD_SECT_AP_WRITE | \
  228. PMD_SECT_AP_READ
  229. b __v7_setup
  230. .long cpu_arch_name
  231. .long cpu_elf_name
  232. .long HWCAP_SWP|HWCAP_HALF|HWCAP_THUMB|HWCAP_FAST_MULT|HWCAP_EDSP
  233. .long cpu_v7_name
  234. .long v7_processor_functions
  235. .long v7wbi_tlb_fns
  236. .long v6_user_fns
  237. .long v7_cache_fns
  238. .size __v7_proc_info, . - __v7_proc_info