proc-arm6_7.S 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421
  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, [r2] @ 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, #0x31 @ ....S..DP...M
  175. mcr p15, 0, r0, c1, c0, 0 @ disable caches
  176. mov pc, lr
  177. ENTRY(cpu_arm6_do_idle)
  178. ENTRY(cpu_arm7_do_idle)
  179. mov pc, lr
  180. /*
  181. * Function: arm6_7_switch_mm(unsigned long pgd_phys)
  182. * Params : pgd_phys Physical address of page table
  183. * Purpose : Perform a task switch, saving the old processes state, and restoring
  184. * the new.
  185. */
  186. ENTRY(cpu_arm6_switch_mm)
  187. ENTRY(cpu_arm7_switch_mm)
  188. #ifdef CONFIG_MMU
  189. mov r1, #0
  190. mcr p15, 0, r1, c7, c0, 0 @ flush cache
  191. mcr p15, 0, r0, c2, c0, 0 @ update page table ptr
  192. mcr p15, 0, r1, c5, c0, 0 @ flush TLBs
  193. #endif
  194. mov pc, lr
  195. /*
  196. * Function: arm6_7_set_pte_ext(pte_t *ptep, pte_t pte, unsigned int ext)
  197. * Params : r0 = Address to set
  198. * : r1 = value to set
  199. * Purpose : Set a PTE and flush it out of any WB cache
  200. */
  201. .align 5
  202. ENTRY(cpu_arm6_set_pte_ext)
  203. ENTRY(cpu_arm7_set_pte_ext)
  204. #ifdef CONFIG_MMU
  205. armv3_set_pte_ext wc_disable=0
  206. #endif /* CONFIG_MMU */
  207. mov pc, lr
  208. /*
  209. * Function: _arm6_7_reset
  210. * Params : r0 = address to jump to
  211. * Notes : This sets up everything for a reset
  212. */
  213. ENTRY(cpu_arm6_reset)
  214. ENTRY(cpu_arm7_reset)
  215. mov r1, #0
  216. mcr p15, 0, r1, c7, c0, 0 @ flush cache
  217. #ifdef CONFIG_MMU
  218. mcr p15, 0, r1, c5, c0, 0 @ flush TLB
  219. #endif
  220. mov r1, #0x30
  221. mcr p15, 0, r1, c1, c0, 0 @ turn off MMU etc
  222. mov pc, r0
  223. __INIT
  224. .type __arm6_setup, #function
  225. __arm6_setup: mov r0, #0
  226. mcr p15, 0, r0, c7, c0 @ flush caches on v3
  227. #ifdef CONFIG_MMU
  228. mcr p15, 0, r0, c5, c0 @ flush TLBs on v3
  229. mov r0, #0x3d @ . ..RS BLDP WCAM
  230. orr r0, r0, #0x100 @ . ..01 0011 1101
  231. #else
  232. mov r0, #0x3c @ . ..RS BLDP WCA.
  233. #endif
  234. mov pc, lr
  235. .size __arm6_setup, . - __arm6_setup
  236. .type __arm7_setup, #function
  237. __arm7_setup: mov r0, #0
  238. mcr p15, 0, r0, c7, c0 @ flush caches on v3
  239. #ifdef CONFIG_MMU
  240. mcr p15, 0, r0, c5, c0 @ flush TLBs on v3
  241. mcr p15, 0, r0, c3, c0 @ load domain access register
  242. mov r0, #0x7d @ . ..RS BLDP WCAM
  243. orr r0, r0, #0x100 @ . ..01 0111 1101
  244. #else
  245. mov r0, #0x7c @ . ..RS BLDP WCA.
  246. #endif
  247. mov pc, lr
  248. .size __arm7_setup, . - __arm7_setup
  249. __INITDATA
  250. /*
  251. * Purpose : Function pointers used to access above functions - all calls
  252. * come through these
  253. */
  254. .type arm6_processor_functions, #object
  255. ENTRY(arm6_processor_functions)
  256. .word cpu_arm6_data_abort
  257. .word legacy_pabort
  258. .word cpu_arm6_proc_init
  259. .word cpu_arm6_proc_fin
  260. .word cpu_arm6_reset
  261. .word cpu_arm6_do_idle
  262. .word cpu_arm6_dcache_clean_area
  263. .word cpu_arm6_switch_mm
  264. .word cpu_arm6_set_pte_ext
  265. .size arm6_processor_functions, . - arm6_processor_functions
  266. /*
  267. * Purpose : Function pointers used to access above functions - all calls
  268. * come through these
  269. */
  270. .type arm7_processor_functions, #object
  271. ENTRY(arm7_processor_functions)
  272. .word cpu_arm7_data_abort
  273. .word legacy_pabort
  274. .word cpu_arm7_proc_init
  275. .word cpu_arm7_proc_fin
  276. .word cpu_arm7_reset
  277. .word cpu_arm7_do_idle
  278. .word cpu_arm7_dcache_clean_area
  279. .word cpu_arm7_switch_mm
  280. .word cpu_arm7_set_pte_ext
  281. .size arm7_processor_functions, . - arm7_processor_functions
  282. .section ".rodata"
  283. .type cpu_arch_name, #object
  284. cpu_arch_name: .asciz "armv3"
  285. .size cpu_arch_name, . - cpu_arch_name
  286. .type cpu_elf_name, #object
  287. cpu_elf_name: .asciz "v3"
  288. .size cpu_elf_name, . - cpu_elf_name
  289. .type cpu_arm6_name, #object
  290. cpu_arm6_name: .asciz "ARM6"
  291. .size cpu_arm6_name, . - cpu_arm6_name
  292. .type cpu_arm610_name, #object
  293. cpu_arm610_name:
  294. .asciz "ARM610"
  295. .size cpu_arm610_name, . - cpu_arm610_name
  296. .type cpu_arm7_name, #object
  297. cpu_arm7_name: .asciz "ARM7"
  298. .size cpu_arm7_name, . - cpu_arm7_name
  299. .type cpu_arm710_name, #object
  300. cpu_arm710_name:
  301. .asciz "ARM710"
  302. .size cpu_arm710_name, . - cpu_arm710_name
  303. .align
  304. .section ".proc.info.init", #alloc, #execinstr
  305. .type __arm6_proc_info, #object
  306. __arm6_proc_info:
  307. .long 0x41560600
  308. .long 0xfffffff0
  309. .long 0x00000c1e
  310. .long PMD_TYPE_SECT | \
  311. PMD_BIT4 | \
  312. PMD_SECT_AP_WRITE | \
  313. PMD_SECT_AP_READ
  314. b __arm6_setup
  315. .long cpu_arch_name
  316. .long cpu_elf_name
  317. .long HWCAP_SWP | HWCAP_26BIT
  318. .long cpu_arm6_name
  319. .long arm6_processor_functions
  320. .long v3_tlb_fns
  321. .long v3_user_fns
  322. .long v3_cache_fns
  323. .size __arm6_proc_info, . - __arm6_proc_info
  324. .type __arm610_proc_info, #object
  325. __arm610_proc_info:
  326. .long 0x41560610
  327. .long 0xfffffff0
  328. .long 0x00000c1e
  329. .long PMD_TYPE_SECT | \
  330. PMD_BIT4 | \
  331. PMD_SECT_AP_WRITE | \
  332. PMD_SECT_AP_READ
  333. b __arm6_setup
  334. .long cpu_arch_name
  335. .long cpu_elf_name
  336. .long HWCAP_SWP | HWCAP_26BIT
  337. .long cpu_arm610_name
  338. .long arm6_processor_functions
  339. .long v3_tlb_fns
  340. .long v3_user_fns
  341. .long v3_cache_fns
  342. .size __arm610_proc_info, . - __arm610_proc_info
  343. .type __arm7_proc_info, #object
  344. __arm7_proc_info:
  345. .long 0x41007000
  346. .long 0xffffff00
  347. .long 0x00000c1e
  348. .long PMD_TYPE_SECT | \
  349. PMD_BIT4 | \
  350. PMD_SECT_AP_WRITE | \
  351. PMD_SECT_AP_READ
  352. b __arm7_setup
  353. .long cpu_arch_name
  354. .long cpu_elf_name
  355. .long HWCAP_SWP | HWCAP_26BIT
  356. .long cpu_arm7_name
  357. .long arm7_processor_functions
  358. .long v3_tlb_fns
  359. .long v3_user_fns
  360. .long v3_cache_fns
  361. .size __arm7_proc_info, . - __arm7_proc_info
  362. .type __arm710_proc_info, #object
  363. __arm710_proc_info:
  364. .long 0x41007100
  365. .long 0xfff8ff00
  366. .long PMD_TYPE_SECT | \
  367. PMD_SECT_BUFFERABLE | \
  368. PMD_SECT_CACHEABLE | \
  369. PMD_BIT4 | \
  370. PMD_SECT_AP_WRITE | \
  371. PMD_SECT_AP_READ
  372. .long PMD_TYPE_SECT | \
  373. PMD_BIT4 | \
  374. PMD_SECT_AP_WRITE | \
  375. PMD_SECT_AP_READ
  376. b __arm7_setup
  377. .long cpu_arch_name
  378. .long cpu_elf_name
  379. .long HWCAP_SWP | HWCAP_26BIT
  380. .long cpu_arm710_name
  381. .long arm7_processor_functions
  382. .long v3_tlb_fns
  383. .long v3_user_fns
  384. .long v3_cache_fns
  385. .size __arm710_proc_info, . - __arm710_proc_info