proc-v7.S 6.2 KB

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