proc-arm1020e.S 12 KB

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