proc-arm1020e.S 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513
  1. /*
  2. * linux/arch/arm/mm/proc-arm1020e.S: MMU functions for ARM1020
  3. *
  4. * Copyright (C) 2000 ARM Limited
  5. * Copyright (C) 2000 Deep Blue Solutions Ltd.
  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 as published by
  9. * the Free Software Foundation; either version 2 of the License, or
  10. * (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, write to the Free Software
  19. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  20. *
  21. *
  22. * These are the low level assembler for performing cache and TLB
  23. * functions on the arm1020e.
  24. *
  25. * CONFIG_CPU_ARM1020_CPU_IDLE -> nohlt
  26. */
  27. #include <linux/linkage.h>
  28. #include <linux/config.h>
  29. #include <linux/init.h>
  30. #include <asm/assembler.h>
  31. #include <asm/constants.h>
  32. #include <asm/pgtable.h>
  33. #include <asm/procinfo.h>
  34. #include <asm/ptrace.h>
  35. #include <asm/hardware.h>
  36. /*
  37. * This is the maximum size of an area which will be invalidated
  38. * using the single invalidate entry instructions. Anything larger
  39. * than this, and we go for the whole cache.
  40. *
  41. * This value should be chosen such that we choose the cheapest
  42. * alternative.
  43. */
  44. #define MAX_AREA_SIZE 32768
  45. /*
  46. * The size of one data cache line.
  47. */
  48. #define CACHE_DLINESIZE 32
  49. /*
  50. * The number of data cache segments.
  51. */
  52. #define CACHE_DSEGMENTS 16
  53. /*
  54. * The number of lines in a cache segment.
  55. */
  56. #define CACHE_DENTRIES 64
  57. /*
  58. * This is the size at which it becomes more efficient to
  59. * clean the whole cache, rather than using the individual
  60. * cache line maintainence instructions.
  61. */
  62. #define CACHE_DLIMIT 32768
  63. .text
  64. /*
  65. * cpu_arm1020e_proc_init()
  66. */
  67. ENTRY(cpu_arm1020e_proc_init)
  68. mov pc, lr
  69. /*
  70. * cpu_arm1020e_proc_fin()
  71. */
  72. ENTRY(cpu_arm1020e_proc_fin)
  73. stmfd sp!, {lr}
  74. mov ip, #PSR_F_BIT | PSR_I_BIT | SVC_MODE
  75. msr cpsr_c, ip
  76. bl arm1020e_flush_kern_cache_all
  77. mrc p15, 0, r0, c1, c0, 0 @ ctrl register
  78. bic r0, r0, #0x1000 @ ...i............
  79. bic r0, r0, #0x000e @ ............wca.
  80. mcr p15, 0, r0, c1, c0, 0 @ disable caches
  81. ldmfd sp!, {pc}
  82. /*
  83. * cpu_arm1020e_reset(loc)
  84. *
  85. * Perform a soft reset of the system. Put the CPU into the
  86. * same state as it would be if it had been reset, and branch
  87. * to what would be the reset vector.
  88. *
  89. * loc: location to jump to for soft reset
  90. */
  91. .align 5
  92. ENTRY(cpu_arm1020e_reset)
  93. mov ip, #0
  94. mcr p15, 0, ip, c7, c7, 0 @ invalidate I,D caches
  95. mcr p15, 0, ip, c7, c10, 4 @ drain WB
  96. mcr p15, 0, ip, c8, c7, 0 @ invalidate I & D TLBs
  97. mrc p15, 0, ip, c1, c0, 0 @ ctrl register
  98. bic ip, ip, #0x000f @ ............wcam
  99. bic ip, ip, #0x1100 @ ...i...s........
  100. mcr p15, 0, ip, c1, c0, 0 @ ctrl register
  101. mov pc, r0
  102. /*
  103. * cpu_arm1020e_do_idle()
  104. */
  105. .align 5
  106. ENTRY(cpu_arm1020e_do_idle)
  107. mcr p15, 0, r0, c7, c0, 4 @ Wait for interrupt
  108. mov pc, lr
  109. /* ================================= CACHE ================================ */
  110. .align 5
  111. /*
  112. * flush_user_cache_all()
  113. *
  114. * Invalidate all cache entries in a particular address
  115. * space.
  116. */
  117. ENTRY(arm1020e_flush_user_cache_all)
  118. /* FALLTHROUGH */
  119. /*
  120. * flush_kern_cache_all()
  121. *
  122. * Clean and invalidate the entire cache.
  123. */
  124. ENTRY(arm1020e_flush_kern_cache_all)
  125. mov r2, #VM_EXEC
  126. mov ip, #0
  127. __flush_whole_cache:
  128. #ifndef CONFIG_CPU_DCACHE_DISABLE
  129. mcr p15, 0, ip, c7, c10, 4 @ drain WB
  130. mov r1, #(CACHE_DSEGMENTS - 1) << 5 @ 16 segments
  131. 1: orr r3, r1, #(CACHE_DENTRIES - 1) << 26 @ 64 entries
  132. 2: mcr p15, 0, r3, c7, c14, 2 @ clean+invalidate D index
  133. subs r3, r3, #1 << 26
  134. bcs 2b @ entries 63 to 0
  135. subs r1, r1, #1 << 5
  136. bcs 1b @ segments 15 to 0
  137. #endif
  138. tst r2, #VM_EXEC
  139. #ifndef CONFIG_CPU_ICACHE_DISABLE
  140. mcrne p15, 0, ip, c7, c5, 0 @ invalidate I cache
  141. #endif
  142. mcrne p15, 0, ip, c7, c10, 4 @ drain WB
  143. mov pc, lr
  144. /*
  145. * flush_user_cache_range(start, end, flags)
  146. *
  147. * Invalidate a range of cache entries in the specified
  148. * address space.
  149. *
  150. * - start - start address (inclusive)
  151. * - end - end address (exclusive)
  152. * - flags - vm_flags for this space
  153. */
  154. ENTRY(arm1020e_flush_user_cache_range)
  155. mov ip, #0
  156. sub r3, r1, r0 @ calculate total size
  157. cmp r3, #CACHE_DLIMIT
  158. bhs __flush_whole_cache
  159. #ifndef CONFIG_CPU_DCACHE_DISABLE
  160. 1: mcr p15, 0, r0, c7, c14, 1 @ clean+invalidate D entry
  161. add r0, r0, #CACHE_DLINESIZE
  162. cmp r0, r1
  163. blo 1b
  164. #endif
  165. tst r2, #VM_EXEC
  166. #ifndef CONFIG_CPU_ICACHE_DISABLE
  167. mcrne p15, 0, ip, c7, c5, 0 @ invalidate I cache
  168. #endif
  169. mcrne p15, 0, ip, c7, c10, 4 @ drain WB
  170. mov pc, lr
  171. /*
  172. * coherent_kern_range(start, end)
  173. *
  174. * Ensure coherency between the Icache and the Dcache in the
  175. * region described by start. If you have non-snooping
  176. * Harvard caches, you need to implement this function.
  177. *
  178. * - start - virtual start address
  179. * - end - virtual end address
  180. */
  181. ENTRY(arm1020e_coherent_kern_range)
  182. /* FALLTHROUGH */
  183. /*
  184. * coherent_user_range(start, end)
  185. *
  186. * Ensure coherency between the Icache and the Dcache in the
  187. * region described by start. If you have non-snooping
  188. * Harvard caches, you need to implement this function.
  189. *
  190. * - start - virtual start address
  191. * - end - virtual end address
  192. */
  193. ENTRY(arm1020e_coherent_user_range)
  194. mov ip, #0
  195. bic r0, r0, #CACHE_DLINESIZE - 1
  196. 1:
  197. #ifndef CONFIG_CPU_DCACHE_DISABLE
  198. mcr p15, 0, r0, c7, c10, 1 @ clean D entry
  199. #endif
  200. #ifndef CONFIG_CPU_ICACHE_DISABLE
  201. mcr p15, 0, r0, c7, c5, 1 @ invalidate I entry
  202. #endif
  203. add r0, r0, #CACHE_DLINESIZE
  204. cmp r0, r1
  205. blo 1b
  206. mcr p15, 0, ip, c7, c10, 4 @ drain WB
  207. mov pc, lr
  208. /*
  209. * flush_kern_dcache_page(void *page)
  210. *
  211. * Ensure no D cache aliasing occurs, either with itself or
  212. * the I cache
  213. *
  214. * - page - page aligned address
  215. */
  216. ENTRY(arm1020e_flush_kern_dcache_page)
  217. mov ip, #0
  218. #ifndef CONFIG_CPU_DCACHE_DISABLE
  219. add r1, r0, #PAGE_SZ
  220. 1: mcr p15, 0, r0, c7, c14, 1 @ clean+invalidate D entry
  221. add r0, r0, #CACHE_DLINESIZE
  222. cmp r0, r1
  223. blo 1b
  224. #endif
  225. mcr p15, 0, ip, c7, c10, 4 @ drain WB
  226. mov pc, lr
  227. /*
  228. * dma_inv_range(start, end)
  229. *
  230. * Invalidate (discard) the specified virtual address range.
  231. * May not write back any entries. If 'start' or 'end'
  232. * are not cache line aligned, those lines must be written
  233. * back.
  234. *
  235. * - start - virtual start address
  236. * - end - virtual end address
  237. *
  238. * (same as v4wb)
  239. */
  240. ENTRY(arm1020e_dma_inv_range)
  241. mov ip, #0
  242. #ifndef CONFIG_CPU_DCACHE_DISABLE
  243. tst r0, #CACHE_DLINESIZE - 1
  244. bic r0, r0, #CACHE_DLINESIZE - 1
  245. mcrne p15, 0, r0, c7, c10, 1 @ clean D entry
  246. tst r1, #CACHE_DLINESIZE - 1
  247. mcrne p15, 0, r1, c7, c10, 1 @ clean D entry
  248. 1: mcr p15, 0, r0, c7, c6, 1 @ invalidate D entry
  249. add r0, r0, #CACHE_DLINESIZE
  250. cmp r0, r1
  251. blo 1b
  252. #endif
  253. mcr p15, 0, ip, c7, c10, 4 @ drain WB
  254. mov pc, lr
  255. /*
  256. * dma_clean_range(start, end)
  257. *
  258. * Clean the specified virtual address range.
  259. *
  260. * - start - virtual start address
  261. * - end - virtual end address
  262. *
  263. * (same as v4wb)
  264. */
  265. ENTRY(arm1020e_dma_clean_range)
  266. mov ip, #0
  267. #ifndef CONFIG_CPU_DCACHE_DISABLE
  268. bic r0, r0, #CACHE_DLINESIZE - 1
  269. 1: mcr p15, 0, r0, c7, c10, 1 @ clean D entry
  270. add r0, r0, #CACHE_DLINESIZE
  271. cmp r0, r1
  272. blo 1b
  273. #endif
  274. mcr p15, 0, ip, c7, c10, 4 @ drain WB
  275. mov pc, lr
  276. /*
  277. * dma_flush_range(start, end)
  278. *
  279. * Clean and invalidate the specified virtual address range.
  280. *
  281. * - start - virtual start address
  282. * - end - virtual end address
  283. */
  284. ENTRY(arm1020e_dma_flush_range)
  285. mov ip, #0
  286. #ifndef CONFIG_CPU_DCACHE_DISABLE
  287. bic r0, r0, #CACHE_DLINESIZE - 1
  288. 1: mcr p15, 0, r0, c7, c14, 1 @ clean+invalidate D entry
  289. add r0, r0, #CACHE_DLINESIZE
  290. cmp r0, r1
  291. blo 1b
  292. #endif
  293. mcr p15, 0, ip, c7, c10, 4 @ drain WB
  294. mov pc, lr
  295. ENTRY(arm1020e_cache_fns)
  296. .long arm1020e_flush_kern_cache_all
  297. .long arm1020e_flush_user_cache_all
  298. .long arm1020e_flush_user_cache_range
  299. .long arm1020e_coherent_kern_range
  300. .long arm1020e_coherent_user_range
  301. .long arm1020e_flush_kern_dcache_page
  302. .long arm1020e_dma_inv_range
  303. .long arm1020e_dma_clean_range
  304. .long arm1020e_dma_flush_range
  305. .align 5
  306. ENTRY(cpu_arm1020e_dcache_clean_area)
  307. #ifndef CONFIG_CPU_DCACHE_DISABLE
  308. mov ip, #0
  309. 1: mcr p15, 0, r0, c7, c10, 1 @ clean D entry
  310. add r0, r0, #CACHE_DLINESIZE
  311. subs r1, r1, #CACHE_DLINESIZE
  312. bhi 1b
  313. #endif
  314. mov pc, lr
  315. /* =============================== PageTable ============================== */
  316. /*
  317. * cpu_arm1020e_switch_mm(pgd)
  318. *
  319. * Set the translation base pointer to be as described by pgd.
  320. *
  321. * pgd: new page tables
  322. */
  323. .align 5
  324. ENTRY(cpu_arm1020e_switch_mm)
  325. #ifndef CONFIG_CPU_DCACHE_DISABLE
  326. mcr p15, 0, r3, c7, c10, 4
  327. mov r1, #0xF @ 16 segments
  328. 1: mov r3, #0x3F @ 64 entries
  329. 2: mov ip, r3, LSL #26 @ shift up entry
  330. orr ip, ip, r1, LSL #5 @ shift in/up index
  331. mcr p15, 0, ip, c7, c14, 2 @ Clean & Inval DCache entry
  332. mov ip, #0
  333. subs r3, r3, #1
  334. cmp r3, #0
  335. bge 2b @ entries 3F to 0
  336. subs r1, r1, #1
  337. cmp r1, #0
  338. bge 1b @ segments 15 to 0
  339. #endif
  340. mov r1, #0
  341. #ifndef CONFIG_CPU_ICACHE_DISABLE
  342. mcr p15, 0, r1, c7, c5, 0 @ invalidate I cache
  343. #endif
  344. mcr p15, 0, r1, c7, c10, 4 @ drain WB
  345. mcr p15, 0, r0, c2, c0, 0 @ load page table pointer
  346. mcr p15, 0, r1, c8, c7, 0 @ invalidate I & D TLBs
  347. mov pc, lr
  348. /*
  349. * cpu_arm1020e_set_pte(ptep, pte)
  350. *
  351. * Set a PTE and flush it out
  352. */
  353. .align 5
  354. ENTRY(cpu_arm1020e_set_pte)
  355. str r1, [r0], #-2048 @ linux version
  356. eor r1, r1, #L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_WRITE | L_PTE_DIRTY
  357. bic r2, r1, #PTE_SMALL_AP_MASK
  358. bic r2, r2, #PTE_TYPE_MASK
  359. orr r2, r2, #PTE_TYPE_SMALL
  360. tst r1, #L_PTE_USER @ User?
  361. orrne r2, r2, #PTE_SMALL_AP_URO_SRW
  362. tst r1, #L_PTE_WRITE | L_PTE_DIRTY @ Write and Dirty?
  363. orreq r2, r2, #PTE_SMALL_AP_UNO_SRW
  364. tst r1, #L_PTE_PRESENT | L_PTE_YOUNG @ Present and Young?
  365. movne r2, #0
  366. #ifdef CONFIG_CPU_DCACHE_WRITETHROUGH
  367. eor r3, r1, #0x0a @ C & small page?
  368. tst r3, #0x0b
  369. biceq r2, r2, #4
  370. #endif
  371. str r2, [r0] @ hardware version
  372. mov r0, r0
  373. #ifndef CONFIG_CPU_DCACHE_DISABLE
  374. mcr p15, 0, r0, c7, c10, 1 @ clean D entry
  375. #endif
  376. mov pc, lr
  377. __INIT
  378. .type __arm1020e_setup, #function
  379. __arm1020e_setup:
  380. mov r0, #0
  381. mcr p15, 0, r0, c7, c7 @ invalidate I,D caches on v4
  382. mcr p15, 0, r0, c7, c10, 4 @ drain write buffer on v4
  383. mcr p15, 0, r0, c8, c7 @ invalidate I,D TLBs on v4
  384. mrc p15, 0, r0, c1, c0 @ get control register v4
  385. ldr r5, arm1020e_cr1_clear
  386. bic r0, r0, r5
  387. ldr r5, arm1020e_cr1_set
  388. orr r0, r0, r5
  389. #ifdef CONFIG_CPU_CACHE_ROUND_ROBIN
  390. orr r0, r0, #0x4000 @ .R.. .... .... ....
  391. #endif
  392. mov pc, lr
  393. .size __arm1020e_setup, . - __arm1020e_setup
  394. /*
  395. * R
  396. * .RVI ZFRS BLDP WCAM
  397. * .011 1001 ..11 0101
  398. */
  399. .type arm1020e_cr1_clear, #object
  400. .type arm1020e_cr1_set, #object
  401. arm1020e_cr1_clear:
  402. .word 0x5f3f
  403. arm1020e_cr1_set:
  404. .word 0x3935
  405. __INITDATA
  406. /*
  407. * Purpose : Function pointers used to access above functions - all calls
  408. * come through these
  409. */
  410. .type arm1020e_processor_functions, #object
  411. arm1020e_processor_functions:
  412. .word v4t_early_abort
  413. .word cpu_arm1020e_proc_init
  414. .word cpu_arm1020e_proc_fin
  415. .word cpu_arm1020e_reset
  416. .word cpu_arm1020e_do_idle
  417. .word cpu_arm1020e_dcache_clean_area
  418. .word cpu_arm1020e_switch_mm
  419. .word cpu_arm1020e_set_pte
  420. .size arm1020e_processor_functions, . - arm1020e_processor_functions
  421. .section ".rodata"
  422. .type cpu_arch_name, #object
  423. cpu_arch_name:
  424. .asciz "armv5te"
  425. .size cpu_arch_name, . - cpu_arch_name
  426. .type cpu_elf_name, #object
  427. cpu_elf_name:
  428. .asciz "v5"
  429. .size cpu_elf_name, . - cpu_elf_name
  430. .type cpu_arm1020e_name, #object
  431. cpu_arm1020e_name:
  432. .ascii "ARM1020E"
  433. #ifndef CONFIG_CPU_ICACHE_DISABLE
  434. .ascii "i"
  435. #endif
  436. #ifndef CONFIG_CPU_DCACHE_DISABLE
  437. .ascii "d"
  438. #ifdef CONFIG_CPU_DCACHE_WRITETHROUGH
  439. .ascii "(wt)"
  440. #else
  441. .ascii "(wb)"
  442. #endif
  443. #endif
  444. #ifndef CONFIG_CPU_BPREDICT_DISABLE
  445. .ascii "B"
  446. #endif
  447. #ifdef CONFIG_CPU_CACHE_ROUND_ROBIN
  448. .ascii "RR"
  449. #endif
  450. .ascii "\0"
  451. .size cpu_arm1020e_name, . - cpu_arm1020e_name
  452. .align
  453. .section ".proc.info", #alloc, #execinstr
  454. .type __arm1020e_proc_info,#object
  455. __arm1020e_proc_info:
  456. .long 0x4105a200 @ ARM 1020TE (Architecture v5TE)
  457. .long 0xff0ffff0
  458. .long PMD_TYPE_SECT | \
  459. PMD_BIT4 | \
  460. PMD_SECT_AP_WRITE | \
  461. PMD_SECT_AP_READ
  462. b __arm1020e_setup
  463. .long cpu_arch_name
  464. .long cpu_elf_name
  465. .long HWCAP_SWP | HWCAP_HALF | HWCAP_THUMB | HWCAP_EDSP
  466. .long cpu_arm1020e_name
  467. .long arm1020e_processor_functions
  468. .long v4wbi_tlb_fns
  469. .long v4wb_user_fns
  470. .long arm1020e_cache_fns
  471. .size __arm1020e_proc_info, . - __arm1020e_proc_info