proc-v6.S 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273
  1. /*
  2. * linux/arch/arm/mm/proc-v6.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 ARMv6 processor support.
  11. */
  12. #include <linux/linkage.h>
  13. #include <asm/assembler.h>
  14. #include <asm/asm-offsets.h>
  15. #include <asm/procinfo.h>
  16. #include <asm/pgtable.h>
  17. #include "proc-macros.S"
  18. #define D_CACHE_LINE_SIZE 32
  19. .macro cpsie, flags
  20. .ifc \flags, f
  21. .long 0xf1080040
  22. .exitm
  23. .endif
  24. .ifc \flags, i
  25. .long 0xf1080080
  26. .exitm
  27. .endif
  28. .ifc \flags, if
  29. .long 0xf10800c0
  30. .exitm
  31. .endif
  32. .err
  33. .endm
  34. .macro cpsid, flags
  35. .ifc \flags, f
  36. .long 0xf10c0040
  37. .exitm
  38. .endif
  39. .ifc \flags, i
  40. .long 0xf10c0080
  41. .exitm
  42. .endif
  43. .ifc \flags, if
  44. .long 0xf10c00c0
  45. .exitm
  46. .endif
  47. .err
  48. .endm
  49. ENTRY(cpu_v6_proc_init)
  50. mov pc, lr
  51. ENTRY(cpu_v6_proc_fin)
  52. stmfd sp!, {lr}
  53. cpsid if @ disable interrupts
  54. bl v6_flush_kern_cache_all
  55. mrc p15, 0, r0, c1, c0, 0 @ ctrl register
  56. bic r0, r0, #0x1000 @ ...i............
  57. bic r0, r0, #0x0006 @ .............ca.
  58. mcr p15, 0, r0, c1, c0, 0 @ disable caches
  59. ldmfd sp!, {pc}
  60. /*
  61. * cpu_v6_reset(loc)
  62. *
  63. * Perform a soft reset of the system. Put the CPU into the
  64. * same state as it would be if it had been reset, and branch
  65. * to what would be the reset vector.
  66. *
  67. * - loc - location to jump to for soft reset
  68. *
  69. * It is assumed that:
  70. */
  71. .align 5
  72. ENTRY(cpu_v6_reset)
  73. mov pc, r0
  74. /*
  75. * cpu_v6_do_idle()
  76. *
  77. * Idle the processor (eg, wait for interrupt).
  78. *
  79. * IRQs are already disabled.
  80. */
  81. ENTRY(cpu_v6_do_idle)
  82. mcr p15, 0, r1, c7, c0, 4 @ wait for interrupt
  83. mov pc, lr
  84. ENTRY(cpu_v6_dcache_clean_area)
  85. #ifndef TLB_CAN_READ_FROM_L1_CACHE
  86. 1: mcr p15, 0, r0, c7, c10, 1 @ clean D entry
  87. add r0, r0, #D_CACHE_LINE_SIZE
  88. subs r1, r1, #D_CACHE_LINE_SIZE
  89. bhi 1b
  90. #endif
  91. mov pc, lr
  92. /*
  93. * cpu_arm926_switch_mm(pgd_phys, tsk)
  94. *
  95. * Set the translation table base pointer to be pgd_phys
  96. *
  97. * - pgd_phys - physical address of new TTB
  98. *
  99. * It is assumed that:
  100. * - we are not using split page tables
  101. */
  102. ENTRY(cpu_v6_switch_mm)
  103. mov r2, #0
  104. ldr r1, [r1, #MM_CONTEXT_ID] @ get mm->context.id
  105. mcr p15, 0, r2, c7, c5, 6 @ flush BTAC/BTB
  106. mcr p15, 0, r2, c7, c10, 4 @ drain write buffer
  107. mcr p15, 0, r0, c2, c0, 0 @ set TTB 0
  108. mcr p15, 0, r1, c13, c0, 1 @ set context ID
  109. mov pc, lr
  110. /*
  111. * cpu_v6_set_pte(ptep, pte)
  112. *
  113. * Set a level 2 translation table entry.
  114. *
  115. * - ptep - pointer to level 2 translation table entry
  116. * (hardware version is stored at -1024 bytes)
  117. * - pte - PTE value to store
  118. *
  119. * Permissions:
  120. * YUWD APX AP1 AP0 SVC User
  121. * 0xxx 0 0 0 no acc no acc
  122. * 100x 1 0 1 r/o no acc
  123. * 10x0 1 0 1 r/o no acc
  124. * 1011 0 0 1 r/w no acc
  125. * 110x 0 1 0 r/w r/o
  126. * 11x0 0 1 0 r/w r/o
  127. * 1111 0 1 1 r/w r/w
  128. */
  129. ENTRY(cpu_v6_set_pte)
  130. str r1, [r0], #-2048 @ linux version
  131. bic r2, r1, #0x000007f0
  132. bic r2, r2, #0x00000003
  133. orr r2, r2, #PTE_EXT_AP0 | 2
  134. tst r1, #L_PTE_WRITE
  135. tstne r1, #L_PTE_DIRTY
  136. orreq r2, r2, #PTE_EXT_APX
  137. tst r1, #L_PTE_USER
  138. orrne r2, r2, #PTE_EXT_AP1
  139. tstne r2, #PTE_EXT_APX
  140. bicne r2, r2, #PTE_EXT_APX | PTE_EXT_AP0
  141. tst r1, #L_PTE_YOUNG
  142. biceq r2, r2, #PTE_EXT_APX | PTE_EXT_AP_MASK
  143. @ tst r1, #L_PTE_EXEC
  144. @ orreq r2, r2, #PTE_EXT_XN
  145. tst r1, #L_PTE_PRESENT
  146. moveq r2, #0
  147. str r2, [r0]
  148. mcr p15, 0, r0, c7, c10, 1 @ flush_pte
  149. mov pc, lr
  150. cpu_v6_name:
  151. .asciz "Some Random V6 Processor"
  152. .align
  153. .section ".text.init", #alloc, #execinstr
  154. /*
  155. * __v6_setup
  156. *
  157. * Initialise TLB, Caches, and MMU state ready to switch the MMU
  158. * on. Return in r0 the new CP15 C1 control register setting.
  159. *
  160. * We automatically detect if we have a Harvard cache, and use the
  161. * Harvard cache control instructions insead of the unified cache
  162. * control instructions.
  163. *
  164. * This should be able to cover all ARMv6 cores.
  165. *
  166. * It is assumed that:
  167. * - cache type register is implemented
  168. */
  169. __v6_setup:
  170. mov r0, #0
  171. mcr p15, 0, r0, c7, c14, 0 @ clean+invalidate D cache
  172. mcr p15, 0, r0, c7, c5, 0 @ invalidate I cache
  173. mcr p15, 0, r0, c7, c15, 0 @ clean+invalidate cache
  174. mcr p15, 0, r0, c7, c10, 4 @ drain write buffer
  175. mcr p15, 0, r0, c8, c7, 0 @ invalidate I + D TLBs
  176. mcr p15, 0, r0, c2, c0, 2 @ TTB control register
  177. mcr p15, 0, r4, c2, c0, 1 @ load TTB1
  178. #ifdef CONFIG_VFP
  179. mrc p15, 0, r0, c1, c0, 2
  180. orr r0, r0, #(0xf << 20)
  181. mcr p15, 0, r0, c1, c0, 2 @ Enable full access to VFP
  182. #endif
  183. mrc p15, 0, r0, c1, c0, 0 @ read control register
  184. ldr r5, v6_cr1_clear @ get mask for bits to clear
  185. bic r0, r0, r5 @ clear bits them
  186. ldr r5, v6_cr1_set @ get mask for bits to set
  187. orr r0, r0, r5 @ set them
  188. mov pc, lr @ return to head.S:__ret
  189. /*
  190. * V X F I D LR
  191. * .... ...E PUI. .T.T 4RVI ZFRS BLDP WCAM
  192. * rrrr rrrx xxx0 0101 xxxx xxxx x111 xxxx < forced
  193. * 0 110 0011 1.00 .111 1101 < we want
  194. */
  195. .type v6_cr1_clear, #object
  196. .type v6_cr1_set, #object
  197. v6_cr1_clear:
  198. .word 0x01e0fb7f
  199. v6_cr1_set:
  200. .word 0x00c0387d
  201. .type v6_processor_functions, #object
  202. ENTRY(v6_processor_functions)
  203. .word v6_early_abort
  204. .word cpu_v6_proc_init
  205. .word cpu_v6_proc_fin
  206. .word cpu_v6_reset
  207. .word cpu_v6_do_idle
  208. .word cpu_v6_dcache_clean_area
  209. .word cpu_v6_switch_mm
  210. .word cpu_v6_set_pte
  211. .size v6_processor_functions, . - v6_processor_functions
  212. .type cpu_arch_name, #object
  213. cpu_arch_name:
  214. .asciz "armv6"
  215. .size cpu_arch_name, . - cpu_arch_name
  216. .type cpu_elf_name, #object
  217. cpu_elf_name:
  218. .asciz "v6"
  219. .size cpu_elf_name, . - cpu_elf_name
  220. .align
  221. .section ".proc.info.init", #alloc, #execinstr
  222. /*
  223. * Match any ARMv6 processor core.
  224. */
  225. .type __v6_proc_info, #object
  226. __v6_proc_info:
  227. .long 0x0007b000
  228. .long 0x0007f000
  229. .long PMD_TYPE_SECT | \
  230. PMD_SECT_BUFFERABLE | \
  231. PMD_SECT_CACHEABLE | \
  232. PMD_SECT_AP_WRITE | \
  233. PMD_SECT_AP_READ
  234. b __v6_setup
  235. .long cpu_arch_name
  236. .long cpu_elf_name
  237. .long HWCAP_SWP|HWCAP_HALF|HWCAP_THUMB|HWCAP_FAST_MULT|HWCAP_VFP|HWCAP_EDSP|HWCAP_JAVA
  238. .long cpu_v6_name
  239. .long v6_processor_functions
  240. .long v6wbi_tlb_fns
  241. .long v6_user_fns
  242. .long v6_cache_fns
  243. .size __v6_proc_info, . - __v6_proc_info