proc-v7.S 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252
  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. mrc p15, 0, r0, c1, c0, 0 @ read control register
  161. ldr r10, cr1_clear @ get mask for bits to clear
  162. bic r0, r0, r10 @ clear bits them
  163. ldr r10, cr1_set @ get mask for bits to set
  164. orr r0, r0, r10 @ set them
  165. mov pc, lr @ return to head.S:__ret
  166. /*
  167. * V X F I D LR
  168. * .... ...E PUI. .T.T 4RVI ZFRS BLDP WCAM
  169. * rrrr rrrx xxx0 0101 xxxx xxxx x111 xxxx < forced
  170. * 0 110 0011 1.00 .111 1101 < we want
  171. */
  172. .type cr1_clear, #object
  173. .type cr1_set, #object
  174. cr1_clear:
  175. .word 0x0120c302
  176. cr1_set:
  177. .word 0x00c0387d
  178. __v7_setup_stack:
  179. .space 4 * 11 @ 11 registers
  180. .type v7_processor_functions, #object
  181. ENTRY(v7_processor_functions)
  182. .word v7_early_abort
  183. .word cpu_v7_proc_init
  184. .word cpu_v7_proc_fin
  185. .word cpu_v7_reset
  186. .word cpu_v7_do_idle
  187. .word cpu_v7_dcache_clean_area
  188. .word cpu_v7_switch_mm
  189. .word cpu_v7_set_pte_ext
  190. .size v7_processor_functions, . - v7_processor_functions
  191. .type cpu_arch_name, #object
  192. cpu_arch_name:
  193. .asciz "armv7"
  194. .size cpu_arch_name, . - cpu_arch_name
  195. .type cpu_elf_name, #object
  196. cpu_elf_name:
  197. .asciz "v7"
  198. .size cpu_elf_name, . - cpu_elf_name
  199. .align
  200. .section ".proc.info.init", #alloc, #execinstr
  201. /*
  202. * Match any ARMv7 processor core.
  203. */
  204. .type __v7_proc_info, #object
  205. __v7_proc_info:
  206. .long 0x000f0000 @ Required ID value
  207. .long 0x000f0000 @ Mask for ID
  208. .long PMD_TYPE_SECT | \
  209. PMD_SECT_BUFFERABLE | \
  210. PMD_SECT_CACHEABLE | \
  211. PMD_SECT_AP_WRITE | \
  212. PMD_SECT_AP_READ
  213. .long PMD_TYPE_SECT | \
  214. PMD_SECT_XN | \
  215. PMD_SECT_AP_WRITE | \
  216. PMD_SECT_AP_READ
  217. b __v7_setup
  218. .long cpu_arch_name
  219. .long cpu_elf_name
  220. .long HWCAP_SWP|HWCAP_HALF|HWCAP_THUMB|HWCAP_FAST_MULT|HWCAP_EDSP
  221. .long cpu_v7_name
  222. .long v7_processor_functions
  223. .long v7wbi_tlb_fns
  224. .long v6_user_fns
  225. .long v7_cache_fns
  226. .size __v7_proc_info, . - __v7_proc_info