proc-arm920.S 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473
  1. /*
  2. * linux/arch/arm/mm/proc-arm920.S: MMU functions for ARM920
  3. *
  4. * Copyright (C) 1999,2000 ARM Limited
  5. * Copyright (C) 2000 Deep Blue Solutions Ltd.
  6. * hacked for non-paged-MM by Hyok S. Choi, 2003.
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation; either version 2 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, write to the Free Software
  20. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  21. *
  22. *
  23. * These are the low level assembler for performing cache and TLB
  24. * functions on the arm920.
  25. *
  26. * CONFIG_CPU_ARM920_CPU_IDLE -> nohlt
  27. */
  28. #include <linux/linkage.h>
  29. #include <linux/init.h>
  30. #include <asm/assembler.h>
  31. #include <asm/hwcap.h>
  32. #include <asm/pgtable-hwdef.h>
  33. #include <asm/pgtable.h>
  34. #include <asm/page.h>
  35. #include <asm/ptrace.h>
  36. #include "proc-macros.S"
  37. /*
  38. * The size of one data cache line.
  39. */
  40. #define CACHE_DLINESIZE 32
  41. /*
  42. * The number of data cache segments.
  43. */
  44. #define CACHE_DSEGMENTS 8
  45. /*
  46. * The number of lines in a cache segment.
  47. */
  48. #define CACHE_DENTRIES 64
  49. /*
  50. * This is the size at which it becomes more efficient to
  51. * clean the whole cache, rather than using the individual
  52. * cache line maintainence instructions.
  53. */
  54. #define CACHE_DLIMIT 65536
  55. .text
  56. /*
  57. * cpu_arm920_proc_init()
  58. */
  59. ENTRY(cpu_arm920_proc_init)
  60. mov pc, lr
  61. /*
  62. * cpu_arm920_proc_fin()
  63. */
  64. ENTRY(cpu_arm920_proc_fin)
  65. mrc p15, 0, r0, c1, c0, 0 @ ctrl register
  66. bic r0, r0, #0x1000 @ ...i............
  67. bic r0, r0, #0x000e @ ............wca.
  68. mcr p15, 0, r0, c1, c0, 0 @ disable caches
  69. mov pc, lr
  70. /*
  71. * cpu_arm920_reset(loc)
  72. *
  73. * Perform a soft reset of the system. Put the CPU into the
  74. * same state as it would be if it had been reset, and branch
  75. * to what would be the reset vector.
  76. *
  77. * loc: location to jump to for soft reset
  78. */
  79. .align 5
  80. ENTRY(cpu_arm920_reset)
  81. mov ip, #0
  82. mcr p15, 0, ip, c7, c7, 0 @ invalidate I,D caches
  83. mcr p15, 0, ip, c7, c10, 4 @ drain WB
  84. #ifdef CONFIG_MMU
  85. mcr p15, 0, ip, c8, c7, 0 @ invalidate I & D TLBs
  86. #endif
  87. mrc p15, 0, ip, c1, c0, 0 @ ctrl register
  88. bic ip, ip, #0x000f @ ............wcam
  89. bic ip, ip, #0x1100 @ ...i...s........
  90. mcr p15, 0, ip, c1, c0, 0 @ ctrl register
  91. mov pc, r0
  92. /*
  93. * cpu_arm920_do_idle()
  94. */
  95. .align 5
  96. ENTRY(cpu_arm920_do_idle)
  97. mcr p15, 0, r0, c7, c0, 4 @ Wait for interrupt
  98. mov pc, lr
  99. #ifndef CONFIG_CPU_DCACHE_WRITETHROUGH
  100. /*
  101. * flush_user_cache_all()
  102. *
  103. * Invalidate all cache entries in a particular address
  104. * space.
  105. */
  106. ENTRY(arm920_flush_user_cache_all)
  107. /* FALLTHROUGH */
  108. /*
  109. * flush_kern_cache_all()
  110. *
  111. * Clean and invalidate the entire cache.
  112. */
  113. ENTRY(arm920_flush_kern_cache_all)
  114. mov r2, #VM_EXEC
  115. mov ip, #0
  116. __flush_whole_cache:
  117. mov r1, #(CACHE_DSEGMENTS - 1) << 5 @ 8 segments
  118. 1: orr r3, r1, #(CACHE_DENTRIES - 1) << 26 @ 64 entries
  119. 2: mcr p15, 0, r3, c7, c14, 2 @ clean+invalidate D index
  120. subs r3, r3, #1 << 26
  121. bcs 2b @ entries 63 to 0
  122. subs r1, r1, #1 << 5
  123. bcs 1b @ segments 7 to 0
  124. tst r2, #VM_EXEC
  125. mcrne p15, 0, ip, c7, c5, 0 @ invalidate I cache
  126. mcrne p15, 0, ip, c7, c10, 4 @ drain WB
  127. mov pc, lr
  128. /*
  129. * flush_user_cache_range(start, end, flags)
  130. *
  131. * Invalidate a range of cache entries in the specified
  132. * address space.
  133. *
  134. * - start - start address (inclusive)
  135. * - end - end address (exclusive)
  136. * - flags - vm_flags for address space
  137. */
  138. ENTRY(arm920_flush_user_cache_range)
  139. mov ip, #0
  140. sub r3, r1, r0 @ calculate total size
  141. cmp r3, #CACHE_DLIMIT
  142. bhs __flush_whole_cache
  143. 1: mcr p15, 0, r0, c7, c14, 1 @ clean+invalidate D entry
  144. tst r2, #VM_EXEC
  145. mcrne p15, 0, r0, c7, c5, 1 @ invalidate I entry
  146. add r0, r0, #CACHE_DLINESIZE
  147. cmp r0, r1
  148. blo 1b
  149. tst r2, #VM_EXEC
  150. mcrne p15, 0, ip, c7, c10, 4 @ drain WB
  151. mov pc, lr
  152. /*
  153. * coherent_kern_range(start, end)
  154. *
  155. * Ensure coherency between the Icache and the Dcache in the
  156. * region described by start, end. If you have non-snooping
  157. * Harvard caches, you need to implement this function.
  158. *
  159. * - start - virtual start address
  160. * - end - virtual end address
  161. */
  162. ENTRY(arm920_coherent_kern_range)
  163. /* FALLTHROUGH */
  164. /*
  165. * coherent_user_range(start, end)
  166. *
  167. * Ensure coherency between the Icache and the Dcache in the
  168. * region described by start, end. If you have non-snooping
  169. * Harvard caches, you need to implement this function.
  170. *
  171. * - start - virtual start address
  172. * - end - virtual end address
  173. */
  174. ENTRY(arm920_coherent_user_range)
  175. bic r0, r0, #CACHE_DLINESIZE - 1
  176. 1: mcr p15, 0, r0, c7, c10, 1 @ clean D entry
  177. mcr p15, 0, r0, c7, c5, 1 @ invalidate I entry
  178. add r0, r0, #CACHE_DLINESIZE
  179. cmp r0, r1
  180. blo 1b
  181. mcr p15, 0, r0, c7, c10, 4 @ drain WB
  182. mov pc, lr
  183. /*
  184. * flush_kern_dcache_area(void *addr, size_t size)
  185. *
  186. * Ensure no D cache aliasing occurs, either with itself or
  187. * the I cache
  188. *
  189. * - addr - kernel address
  190. * - size - region size
  191. */
  192. ENTRY(arm920_flush_kern_dcache_area)
  193. add r1, r0, r1
  194. 1: mcr p15, 0, r0, c7, c14, 1 @ clean+invalidate D entry
  195. add r0, r0, #CACHE_DLINESIZE
  196. cmp r0, r1
  197. blo 1b
  198. mov r0, #0
  199. mcr p15, 0, r0, c7, c5, 0 @ invalidate I cache
  200. mcr p15, 0, r0, c7, c10, 4 @ drain WB
  201. mov pc, lr
  202. /*
  203. * dma_inv_range(start, end)
  204. *
  205. * Invalidate (discard) the specified virtual address range.
  206. * May not write back any entries. If 'start' or 'end'
  207. * are not cache line aligned, those lines must be written
  208. * back.
  209. *
  210. * - start - virtual start address
  211. * - end - virtual end address
  212. *
  213. * (same as v4wb)
  214. */
  215. arm920_dma_inv_range:
  216. tst r0, #CACHE_DLINESIZE - 1
  217. bic r0, r0, #CACHE_DLINESIZE - 1
  218. mcrne p15, 0, r0, c7, c10, 1 @ clean D entry
  219. tst r1, #CACHE_DLINESIZE - 1
  220. mcrne p15, 0, r1, c7, c10, 1 @ clean D entry
  221. 1: mcr p15, 0, r0, c7, c6, 1 @ invalidate D entry
  222. add r0, r0, #CACHE_DLINESIZE
  223. cmp r0, r1
  224. blo 1b
  225. mcr p15, 0, r0, c7, c10, 4 @ drain WB
  226. mov pc, lr
  227. /*
  228. * dma_clean_range(start, end)
  229. *
  230. * Clean the specified virtual address range.
  231. *
  232. * - start - virtual start address
  233. * - end - virtual end address
  234. *
  235. * (same as v4wb)
  236. */
  237. arm920_dma_clean_range:
  238. bic r0, r0, #CACHE_DLINESIZE - 1
  239. 1: mcr p15, 0, r0, c7, c10, 1 @ clean D entry
  240. add r0, r0, #CACHE_DLINESIZE
  241. cmp r0, r1
  242. blo 1b
  243. mcr p15, 0, r0, c7, c10, 4 @ drain WB
  244. mov pc, lr
  245. /*
  246. * dma_flush_range(start, end)
  247. *
  248. * Clean and invalidate the specified virtual address range.
  249. *
  250. * - start - virtual start address
  251. * - end - virtual end address
  252. */
  253. ENTRY(arm920_dma_flush_range)
  254. bic r0, r0, #CACHE_DLINESIZE - 1
  255. 1: mcr p15, 0, r0, c7, c14, 1 @ clean+invalidate D entry
  256. add r0, r0, #CACHE_DLINESIZE
  257. cmp r0, r1
  258. blo 1b
  259. mcr p15, 0, r0, c7, c10, 4 @ drain WB
  260. mov pc, lr
  261. /*
  262. * dma_map_area(start, size, dir)
  263. * - start - kernel virtual start address
  264. * - size - size of region
  265. * - dir - DMA direction
  266. */
  267. ENTRY(arm920_dma_map_area)
  268. add r1, r1, r0
  269. cmp r2, #DMA_TO_DEVICE
  270. beq arm920_dma_clean_range
  271. bcs arm920_dma_inv_range
  272. b arm920_dma_flush_range
  273. ENDPROC(arm920_dma_map_area)
  274. /*
  275. * dma_unmap_area(start, size, dir)
  276. * - start - kernel virtual start address
  277. * - size - size of region
  278. * - dir - DMA direction
  279. */
  280. ENTRY(arm920_dma_unmap_area)
  281. mov pc, lr
  282. ENDPROC(arm920_dma_unmap_area)
  283. ENTRY(arm920_cache_fns)
  284. .long arm920_flush_kern_cache_all
  285. .long arm920_flush_user_cache_all
  286. .long arm920_flush_user_cache_range
  287. .long arm920_coherent_kern_range
  288. .long arm920_coherent_user_range
  289. .long arm920_flush_kern_dcache_area
  290. .long arm920_dma_map_area
  291. .long arm920_dma_unmap_area
  292. .long arm920_dma_flush_range
  293. #endif
  294. ENTRY(cpu_arm920_dcache_clean_area)
  295. 1: mcr p15, 0, r0, c7, c10, 1 @ clean D entry
  296. add r0, r0, #CACHE_DLINESIZE
  297. subs r1, r1, #CACHE_DLINESIZE
  298. bhi 1b
  299. mov pc, lr
  300. /* =============================== PageTable ============================== */
  301. /*
  302. * cpu_arm920_switch_mm(pgd)
  303. *
  304. * Set the translation base pointer to be as described by pgd.
  305. *
  306. * pgd: new page tables
  307. */
  308. .align 5
  309. ENTRY(cpu_arm920_switch_mm)
  310. #ifdef CONFIG_MMU
  311. mov ip, #0
  312. #ifdef CONFIG_CPU_DCACHE_WRITETHROUGH
  313. mcr p15, 0, ip, c7, c6, 0 @ invalidate D cache
  314. #else
  315. @ && 'Clean & Invalidate whole DCache'
  316. @ && Re-written to use Index Ops.
  317. @ && Uses registers r1, r3 and ip
  318. mov r1, #(CACHE_DSEGMENTS - 1) << 5 @ 8 segments
  319. 1: orr r3, r1, #(CACHE_DENTRIES - 1) << 26 @ 64 entries
  320. 2: mcr p15, 0, r3, c7, c14, 2 @ clean & invalidate D index
  321. subs r3, r3, #1 << 26
  322. bcs 2b @ entries 63 to 0
  323. subs r1, r1, #1 << 5
  324. bcs 1b @ segments 7 to 0
  325. #endif
  326. mcr p15, 0, ip, c7, c5, 0 @ invalidate I cache
  327. mcr p15, 0, ip, c7, c10, 4 @ drain WB
  328. mcr p15, 0, r0, c2, c0, 0 @ load page table pointer
  329. mcr p15, 0, ip, c8, c7, 0 @ invalidate I & D TLBs
  330. #endif
  331. mov pc, lr
  332. /*
  333. * cpu_arm920_set_pte(ptep, pte, ext)
  334. *
  335. * Set a PTE and flush it out
  336. */
  337. .align 5
  338. ENTRY(cpu_arm920_set_pte_ext)
  339. #ifdef CONFIG_MMU
  340. armv3_set_pte_ext
  341. mov r0, r0
  342. mcr p15, 0, r0, c7, c10, 1 @ clean D entry
  343. mcr p15, 0, r0, c7, c10, 4 @ drain WB
  344. #endif
  345. mov pc, lr
  346. __INIT
  347. .type __arm920_setup, #function
  348. __arm920_setup:
  349. mov r0, #0
  350. mcr p15, 0, r0, c7, c7 @ invalidate I,D caches on v4
  351. mcr p15, 0, r0, c7, c10, 4 @ drain write buffer on v4
  352. #ifdef CONFIG_MMU
  353. mcr p15, 0, r0, c8, c7 @ invalidate I,D TLBs on v4
  354. #endif
  355. adr r5, arm920_crval
  356. ldmia r5, {r5, r6}
  357. mrc p15, 0, r0, c1, c0 @ get control register v4
  358. bic r0, r0, r5
  359. orr r0, r0, r6
  360. mov pc, lr
  361. .size __arm920_setup, . - __arm920_setup
  362. /*
  363. * R
  364. * .RVI ZFRS BLDP WCAM
  365. * ..11 0001 ..11 0101
  366. *
  367. */
  368. .type arm920_crval, #object
  369. arm920_crval:
  370. crval clear=0x00003f3f, mmuset=0x00003135, ucset=0x00001130
  371. __INITDATA
  372. /*
  373. * Purpose : Function pointers used to access above functions - all calls
  374. * come through these
  375. */
  376. .type arm920_processor_functions, #object
  377. arm920_processor_functions:
  378. .word v4t_early_abort
  379. .word legacy_pabort
  380. .word cpu_arm920_proc_init
  381. .word cpu_arm920_proc_fin
  382. .word cpu_arm920_reset
  383. .word cpu_arm920_do_idle
  384. .word cpu_arm920_dcache_clean_area
  385. .word cpu_arm920_switch_mm
  386. .word cpu_arm920_set_pte_ext
  387. .size arm920_processor_functions, . - arm920_processor_functions
  388. .section ".rodata"
  389. .type cpu_arch_name, #object
  390. cpu_arch_name:
  391. .asciz "armv4t"
  392. .size cpu_arch_name, . - cpu_arch_name
  393. .type cpu_elf_name, #object
  394. cpu_elf_name:
  395. .asciz "v4"
  396. .size cpu_elf_name, . - cpu_elf_name
  397. .type cpu_arm920_name, #object
  398. cpu_arm920_name:
  399. .asciz "ARM920T"
  400. .size cpu_arm920_name, . - cpu_arm920_name
  401. .align
  402. .section ".proc.info.init", #alloc, #execinstr
  403. .type __arm920_proc_info,#object
  404. __arm920_proc_info:
  405. .long 0x41009200
  406. .long 0xff00fff0
  407. .long PMD_TYPE_SECT | \
  408. PMD_SECT_BUFFERABLE | \
  409. PMD_SECT_CACHEABLE | \
  410. PMD_BIT4 | \
  411. PMD_SECT_AP_WRITE | \
  412. PMD_SECT_AP_READ
  413. .long PMD_TYPE_SECT | \
  414. PMD_BIT4 | \
  415. PMD_SECT_AP_WRITE | \
  416. PMD_SECT_AP_READ
  417. b __arm920_setup
  418. .long cpu_arch_name
  419. .long cpu_elf_name
  420. .long HWCAP_SWP | HWCAP_HALF | HWCAP_THUMB
  421. .long cpu_arm920_name
  422. .long arm920_processor_functions
  423. .long v4wbi_tlb_fns
  424. .long v4wb_user_fns
  425. #ifndef CONFIG_CPU_DCACHE_WRITETHROUGH
  426. .long arm920_cache_fns
  427. #else
  428. .long v4wt_cache_fns
  429. #endif
  430. .size __arm920_proc_info, . - __arm920_proc_info