proc-arm6_7.S 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423
  1. /*
  2. * linux/arch/arm/mm/proc-arm6,7.S
  3. *
  4. * Copyright (C) 1997-2000 Russell King
  5. * hacked for non-paged-MM by Hyok S. Choi, 2003.
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License version 2 as
  9. * published by the Free Software Foundation.
  10. *
  11. * These are the low level assembler for performing cache and TLB
  12. * functions on the ARM610 & ARM710.
  13. */
  14. #include <linux/linkage.h>
  15. #include <linux/init.h>
  16. #include <asm/assembler.h>
  17. #include <asm/asm-offsets.h>
  18. #include <asm/hwcap.h>
  19. #include <asm/pgtable-hwdef.h>
  20. #include <asm/pgtable.h>
  21. #include <asm/ptrace.h>
  22. #include "proc-macros.S"
  23. ENTRY(cpu_arm6_dcache_clean_area)
  24. ENTRY(cpu_arm7_dcache_clean_area)
  25. mov pc, lr
  26. /*
  27. * Function: arm6_7_data_abort ()
  28. *
  29. * Params : r2 = address of aborted instruction
  30. * : sp = pointer to registers
  31. *
  32. * Purpose : obtain information about current aborted instruction
  33. *
  34. * Returns : r0 = address of abort
  35. * : r1 = FSR
  36. */
  37. ENTRY(cpu_arm7_data_abort)
  38. mrc p15, 0, r1, c5, c0, 0 @ get FSR
  39. mrc p15, 0, r0, c6, c0, 0 @ get FAR
  40. ldr r8, [r0] @ read arm instruction
  41. tst r8, #1 << 20 @ L = 0 -> write?
  42. orreq r1, r1, #1 << 11 @ yes.
  43. and r7, r8, #15 << 24
  44. add pc, pc, r7, lsr #22 @ Now branch to the relevant processing routine
  45. nop
  46. /* 0 */ b .data_unknown
  47. /* 1 */ mov pc, lr @ swp
  48. /* 2 */ b .data_unknown
  49. /* 3 */ b .data_unknown
  50. /* 4 */ b .data_arm_lateldrpostconst @ ldr rd, [rn], #m
  51. /* 5 */ b .data_arm_lateldrpreconst @ ldr rd, [rn, #m]
  52. /* 6 */ b .data_arm_lateldrpostreg @ ldr rd, [rn], rm
  53. /* 7 */ b .data_arm_lateldrprereg @ ldr rd, [rn, rm]
  54. /* 8 */ b .data_arm_ldmstm @ ldm*a rn, <rlist>
  55. /* 9 */ b .data_arm_ldmstm @ ldm*b rn, <rlist>
  56. /* a */ b .data_unknown
  57. /* b */ b .data_unknown
  58. /* c */ mov pc, lr @ ldc rd, [rn], #m @ Same as ldr rd, [rn], #m
  59. /* d */ mov pc, lr @ ldc rd, [rn, #m]
  60. /* e */ b .data_unknown
  61. /* f */
  62. .data_unknown: @ Part of jumptable
  63. mov r0, r2
  64. mov r1, r8
  65. mov r2, sp
  66. bl baddataabort
  67. b ret_from_exception
  68. ENTRY(cpu_arm6_data_abort)
  69. mrc p15, 0, r1, c5, c0, 0 @ get FSR
  70. mrc p15, 0, r0, c6, c0, 0 @ get FAR
  71. ldr r8, [r2] @ read arm instruction
  72. tst r8, #1 << 20 @ L = 0 -> write?
  73. orreq r1, r1, #1 << 11 @ yes.
  74. and r7, r8, #14 << 24
  75. teq r7, #8 << 24 @ was it ldm/stm
  76. movne pc, lr
  77. .data_arm_ldmstm:
  78. tst r8, #1 << 21 @ check writeback bit
  79. moveq pc, lr @ no writeback -> no fixup
  80. mov r7, #0x11
  81. orr r7, r7, #0x1100
  82. and r6, r8, r7
  83. and r2, r8, r7, lsl #1
  84. add r6, r6, r2, lsr #1
  85. and r2, r8, r7, lsl #2
  86. add r6, r6, r2, lsr #2
  87. and r2, r8, r7, lsl #3
  88. add r6, r6, r2, lsr #3
  89. add r6, r6, r6, lsr #8
  90. add r6, r6, r6, lsr #4
  91. and r6, r6, #15 @ r6 = no. of registers to transfer.
  92. and r5, r8, #15 << 16 @ Extract 'n' from instruction
  93. ldr r7, [sp, r5, lsr #14] @ Get register 'Rn'
  94. tst r8, #1 << 23 @ Check U bit
  95. subne r7, r7, r6, lsl #2 @ Undo increment
  96. addeq r7, r7, r6, lsl #2 @ Undo decrement
  97. str r7, [sp, r5, lsr #14] @ Put register 'Rn'
  98. mov pc, lr
  99. .data_arm_apply_r6_and_rn:
  100. and r5, r8, #15 << 16 @ Extract 'n' from instruction
  101. ldr r7, [sp, r5, lsr #14] @ Get register 'Rn'
  102. tst r8, #1 << 23 @ Check U bit
  103. subne r7, r7, r6 @ Undo incrmenet
  104. addeq r7, r7, r6 @ Undo decrement
  105. str r7, [sp, r5, lsr #14] @ Put register 'Rn'
  106. mov pc, lr
  107. .data_arm_lateldrpreconst:
  108. tst r8, #1 << 21 @ check writeback bit
  109. moveq pc, lr @ no writeback -> no fixup
  110. .data_arm_lateldrpostconst:
  111. movs r2, r8, lsl #20 @ Get offset
  112. moveq pc, lr @ zero -> no fixup
  113. and r5, r8, #15 << 16 @ Extract 'n' from instruction
  114. ldr r7, [sp, r5, lsr #14] @ Get register 'Rn'
  115. tst r8, #1 << 23 @ Check U bit
  116. subne r7, r7, r2, lsr #20 @ Undo increment
  117. addeq r7, r7, r2, lsr #20 @ Undo decrement
  118. str r7, [sp, r5, lsr #14] @ Put register 'Rn'
  119. mov pc, lr
  120. .data_arm_lateldrprereg:
  121. tst r8, #1 << 21 @ check writeback bit
  122. moveq pc, lr @ no writeback -> no fixup
  123. .data_arm_lateldrpostreg:
  124. and r7, r8, #15 @ Extract 'm' from instruction
  125. ldr r6, [sp, r7, lsl #2] @ Get register 'Rm'
  126. mov r5, r8, lsr #7 @ get shift count
  127. ands r5, r5, #31
  128. and r7, r8, #0x70 @ get shift type
  129. orreq r7, r7, #8 @ shift count = 0
  130. add pc, pc, r7
  131. nop
  132. mov r6, r6, lsl r5 @ 0: LSL #!0
  133. b .data_arm_apply_r6_and_rn
  134. b .data_arm_apply_r6_and_rn @ 1: LSL #0
  135. nop
  136. b .data_unknown @ 2: MUL?
  137. nop
  138. b .data_unknown @ 3: MUL?
  139. nop
  140. mov r6, r6, lsr r5 @ 4: LSR #!0
  141. b .data_arm_apply_r6_and_rn
  142. mov r6, r6, lsr #32 @ 5: LSR #32
  143. b .data_arm_apply_r6_and_rn
  144. b .data_unknown @ 6: MUL?
  145. nop
  146. b .data_unknown @ 7: MUL?
  147. nop
  148. mov r6, r6, asr r5 @ 8: ASR #!0
  149. b .data_arm_apply_r6_and_rn
  150. mov r6, r6, asr #32 @ 9: ASR #32
  151. b .data_arm_apply_r6_and_rn
  152. b .data_unknown @ A: MUL?
  153. nop
  154. b .data_unknown @ B: MUL?
  155. nop
  156. mov r6, r6, ror r5 @ C: ROR #!0
  157. b .data_arm_apply_r6_and_rn
  158. mov r6, r6, rrx @ D: RRX
  159. b .data_arm_apply_r6_and_rn
  160. b .data_unknown @ E: MUL?
  161. nop
  162. b .data_unknown @ F: MUL?
  163. /*
  164. * Function: arm6_7_proc_init (void)
  165. * : arm6_7_proc_fin (void)
  166. *
  167. * Notes : This processor does not require these
  168. */
  169. ENTRY(cpu_arm6_proc_init)
  170. ENTRY(cpu_arm7_proc_init)
  171. mov pc, lr
  172. ENTRY(cpu_arm6_proc_fin)
  173. ENTRY(cpu_arm7_proc_fin)
  174. mov r0, #PSR_F_BIT | PSR_I_BIT | SVC_MODE
  175. msr cpsr_c, r0
  176. mov r0, #0x31 @ ....S..DP...M
  177. mcr p15, 0, r0, c1, c0, 0 @ disable caches
  178. mov pc, lr
  179. ENTRY(cpu_arm6_do_idle)
  180. ENTRY(cpu_arm7_do_idle)
  181. mov pc, lr
  182. /*
  183. * Function: arm6_7_switch_mm(unsigned long pgd_phys)
  184. * Params : pgd_phys Physical address of page table
  185. * Purpose : Perform a task switch, saving the old processes state, and restoring
  186. * the new.
  187. */
  188. ENTRY(cpu_arm6_switch_mm)
  189. ENTRY(cpu_arm7_switch_mm)
  190. #ifdef CONFIG_MMU
  191. mov r1, #0
  192. mcr p15, 0, r1, c7, c0, 0 @ flush cache
  193. mcr p15, 0, r0, c2, c0, 0 @ update page table ptr
  194. mcr p15, 0, r1, c5, c0, 0 @ flush TLBs
  195. #endif
  196. mov pc, lr
  197. /*
  198. * Function: arm6_7_set_pte_ext(pte_t *ptep, pte_t pte, unsigned int ext)
  199. * Params : r0 = Address to set
  200. * : r1 = value to set
  201. * Purpose : Set a PTE and flush it out of any WB cache
  202. */
  203. .align 5
  204. ENTRY(cpu_arm6_set_pte_ext)
  205. ENTRY(cpu_arm7_set_pte_ext)
  206. #ifdef CONFIG_MMU
  207. armv3_set_pte_ext wc_disable=0
  208. #endif /* CONFIG_MMU */
  209. mov pc, lr
  210. /*
  211. * Function: _arm6_7_reset
  212. * Params : r0 = address to jump to
  213. * Notes : This sets up everything for a reset
  214. */
  215. ENTRY(cpu_arm6_reset)
  216. ENTRY(cpu_arm7_reset)
  217. mov r1, #0
  218. mcr p15, 0, r1, c7, c0, 0 @ flush cache
  219. #ifdef CONFIG_MMU
  220. mcr p15, 0, r1, c5, c0, 0 @ flush TLB
  221. #endif
  222. mov r1, #0x30
  223. mcr p15, 0, r1, c1, c0, 0 @ turn off MMU etc
  224. mov pc, r0
  225. __INIT
  226. .type __arm6_setup, #function
  227. __arm6_setup: mov r0, #0
  228. mcr p15, 0, r0, c7, c0 @ flush caches on v3
  229. #ifdef CONFIG_MMU
  230. mcr p15, 0, r0, c5, c0 @ flush TLBs on v3
  231. mov r0, #0x3d @ . ..RS BLDP WCAM
  232. orr r0, r0, #0x100 @ . ..01 0011 1101
  233. #else
  234. mov r0, #0x3c @ . ..RS BLDP WCA.
  235. #endif
  236. mov pc, lr
  237. .size __arm6_setup, . - __arm6_setup
  238. .type __arm7_setup, #function
  239. __arm7_setup: mov r0, #0
  240. mcr p15, 0, r0, c7, c0 @ flush caches on v3
  241. #ifdef CONFIG_MMU
  242. mcr p15, 0, r0, c5, c0 @ flush TLBs on v3
  243. mcr p15, 0, r0, c3, c0 @ load domain access register
  244. mov r0, #0x7d @ . ..RS BLDP WCAM
  245. orr r0, r0, #0x100 @ . ..01 0111 1101
  246. #else
  247. mov r0, #0x7c @ . ..RS BLDP WCA.
  248. #endif
  249. mov pc, lr
  250. .size __arm7_setup, . - __arm7_setup
  251. __INITDATA
  252. /*
  253. * Purpose : Function pointers used to access above functions - all calls
  254. * come through these
  255. */
  256. .type arm6_processor_functions, #object
  257. ENTRY(arm6_processor_functions)
  258. .word cpu_arm6_data_abort
  259. .word pabort_noifar
  260. .word cpu_arm6_proc_init
  261. .word cpu_arm6_proc_fin
  262. .word cpu_arm6_reset
  263. .word cpu_arm6_do_idle
  264. .word cpu_arm6_dcache_clean_area
  265. .word cpu_arm6_switch_mm
  266. .word cpu_arm6_set_pte_ext
  267. .size arm6_processor_functions, . - arm6_processor_functions
  268. /*
  269. * Purpose : Function pointers used to access above functions - all calls
  270. * come through these
  271. */
  272. .type arm7_processor_functions, #object
  273. ENTRY(arm7_processor_functions)
  274. .word cpu_arm7_data_abort
  275. .word pabort_noifar
  276. .word cpu_arm7_proc_init
  277. .word cpu_arm7_proc_fin
  278. .word cpu_arm7_reset
  279. .word cpu_arm7_do_idle
  280. .word cpu_arm7_dcache_clean_area
  281. .word cpu_arm7_switch_mm
  282. .word cpu_arm7_set_pte_ext
  283. .size arm7_processor_functions, . - arm7_processor_functions
  284. .section ".rodata"
  285. .type cpu_arch_name, #object
  286. cpu_arch_name: .asciz "armv3"
  287. .size cpu_arch_name, . - cpu_arch_name
  288. .type cpu_elf_name, #object
  289. cpu_elf_name: .asciz "v3"
  290. .size cpu_elf_name, . - cpu_elf_name
  291. .type cpu_arm6_name, #object
  292. cpu_arm6_name: .asciz "ARM6"
  293. .size cpu_arm6_name, . - cpu_arm6_name
  294. .type cpu_arm610_name, #object
  295. cpu_arm610_name:
  296. .asciz "ARM610"
  297. .size cpu_arm610_name, . - cpu_arm610_name
  298. .type cpu_arm7_name, #object
  299. cpu_arm7_name: .asciz "ARM7"
  300. .size cpu_arm7_name, . - cpu_arm7_name
  301. .type cpu_arm710_name, #object
  302. cpu_arm710_name:
  303. .asciz "ARM710"
  304. .size cpu_arm710_name, . - cpu_arm710_name
  305. .align
  306. .section ".proc.info.init", #alloc, #execinstr
  307. .type __arm6_proc_info, #object
  308. __arm6_proc_info:
  309. .long 0x41560600
  310. .long 0xfffffff0
  311. .long 0x00000c1e
  312. .long PMD_TYPE_SECT | \
  313. PMD_BIT4 | \
  314. PMD_SECT_AP_WRITE | \
  315. PMD_SECT_AP_READ
  316. b __arm6_setup
  317. .long cpu_arch_name
  318. .long cpu_elf_name
  319. .long HWCAP_SWP | HWCAP_26BIT
  320. .long cpu_arm6_name
  321. .long arm6_processor_functions
  322. .long v3_tlb_fns
  323. .long v3_user_fns
  324. .long v3_cache_fns
  325. .size __arm6_proc_info, . - __arm6_proc_info
  326. .type __arm610_proc_info, #object
  327. __arm610_proc_info:
  328. .long 0x41560610
  329. .long 0xfffffff0
  330. .long 0x00000c1e
  331. .long PMD_TYPE_SECT | \
  332. PMD_BIT4 | \
  333. PMD_SECT_AP_WRITE | \
  334. PMD_SECT_AP_READ
  335. b __arm6_setup
  336. .long cpu_arch_name
  337. .long cpu_elf_name
  338. .long HWCAP_SWP | HWCAP_26BIT
  339. .long cpu_arm610_name
  340. .long arm6_processor_functions
  341. .long v3_tlb_fns
  342. .long v3_user_fns
  343. .long v3_cache_fns
  344. .size __arm610_proc_info, . - __arm610_proc_info
  345. .type __arm7_proc_info, #object
  346. __arm7_proc_info:
  347. .long 0x41007000
  348. .long 0xffffff00
  349. .long 0x00000c1e
  350. .long PMD_TYPE_SECT | \
  351. PMD_BIT4 | \
  352. PMD_SECT_AP_WRITE | \
  353. PMD_SECT_AP_READ
  354. b __arm7_setup
  355. .long cpu_arch_name
  356. .long cpu_elf_name
  357. .long HWCAP_SWP | HWCAP_26BIT
  358. .long cpu_arm7_name
  359. .long arm7_processor_functions
  360. .long v3_tlb_fns
  361. .long v3_user_fns
  362. .long v3_cache_fns
  363. .size __arm7_proc_info, . - __arm7_proc_info
  364. .type __arm710_proc_info, #object
  365. __arm710_proc_info:
  366. .long 0x41007100
  367. .long 0xfff8ff00
  368. .long PMD_TYPE_SECT | \
  369. PMD_SECT_BUFFERABLE | \
  370. PMD_SECT_CACHEABLE | \
  371. PMD_BIT4 | \
  372. PMD_SECT_AP_WRITE | \
  373. PMD_SECT_AP_READ
  374. .long PMD_TYPE_SECT | \
  375. PMD_BIT4 | \
  376. PMD_SECT_AP_WRITE | \
  377. PMD_SECT_AP_READ
  378. b __arm7_setup
  379. .long cpu_arch_name
  380. .long cpu_elf_name
  381. .long HWCAP_SWP | HWCAP_26BIT
  382. .long cpu_arm710_name
  383. .long arm7_processor_functions
  384. .long v3_tlb_fns
  385. .long v3_user_fns
  386. .long v3_cache_fns
  387. .size __arm710_proc_info, . - __arm710_proc_info