proc-v7.S 6.2 KB

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