proc-v7.S 5.9 KB

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