blob: df3b423713b9f77904d0043d4f0bcc7a3bdec081 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * linux/arch/arm/mm/cache-v4.S
3 *
4 * Copyright (C) 1997-2002 Russell king
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 */
10#include <linux/linkage.h>
11#include <linux/init.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070012#include <asm/page.h>
13#include "proc-macros.S"
14
15/*
16 * flush_user_cache_all()
17 *
18 * Invalidate all cache entries in a particular address
19 * space.
20 *
21 * - mm - mm_struct describing address space
22 */
23ENTRY(v4_flush_user_cache_all)
24 /* FALLTHROUGH */
25/*
26 * flush_kern_cache_all()
27 *
28 * Clean and invalidate the entire cache.
29 */
30ENTRY(v4_flush_kern_cache_all)
Anders Grafströme4d2a592008-10-16 17:37:24 +010031#ifdef CONFIG_CPU_CP15
Linus Torvalds1da177e2005-04-16 15:20:36 -070032 mov r0, #0
33 mcr p15, 0, r0, c7, c7, 0 @ flush ID cache
34 mov pc, lr
Hyok S. Choif12d0d72006-09-26 17:36:37 +090035#else
36 /* FALLTHROUGH */
37#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -070038
39/*
40 * flush_user_cache_range(start, end, flags)
41 *
42 * Invalidate a range of cache entries in the specified
43 * address space.
44 *
45 * - start - start address (may not be aligned)
46 * - end - end address (exclusive, may not be aligned)
47 * - flags - vma_area_struct flags describing address space
48 */
49ENTRY(v4_flush_user_cache_range)
Anders Grafströme4d2a592008-10-16 17:37:24 +010050#ifdef CONFIG_CPU_CP15
Linus Torvalds1da177e2005-04-16 15:20:36 -070051 mov ip, #0
52 mcreq p15, 0, ip, c7, c7, 0 @ flush ID cache
53 mov pc, lr
Hyok S. Choif12d0d72006-09-26 17:36:37 +090054#else
55 /* FALLTHROUGH */
56#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -070057
58/*
59 * coherent_kern_range(start, end)
60 *
61 * Ensure coherency between the Icache and the Dcache in the
62 * region described by start. If you have non-snooping
63 * Harvard caches, you need to implement this function.
64 *
65 * - start - virtual start address
66 * - end - virtual end address
67 */
68ENTRY(v4_coherent_kern_range)
69 /* FALLTHROUGH */
70
71/*
72 * coherent_user_range(start, end)
73 *
74 * Ensure coherency between the Icache and the Dcache in the
75 * region described by start. If you have non-snooping
76 * Harvard caches, you need to implement this function.
77 *
78 * - start - virtual start address
79 * - end - virtual end address
80 */
81ENTRY(v4_coherent_user_range)
82 mov pc, lr
83
84/*
Russell King2c9b9c82009-11-26 12:56:21 +000085 * flush_kern_dcache_area(void *addr, size_t size)
Linus Torvalds1da177e2005-04-16 15:20:36 -070086 *
87 * Ensure no D cache aliasing occurs, either with itself or
88 * the I cache
89 *
Russell King2c9b9c82009-11-26 12:56:21 +000090 * - addr - kernel address
91 * - size - region size
Linus Torvalds1da177e2005-04-16 15:20:36 -070092 */
Russell King2c9b9c82009-11-26 12:56:21 +000093ENTRY(v4_flush_kern_dcache_area)
Linus Torvalds1da177e2005-04-16 15:20:36 -070094 /* FALLTHROUGH */
95
96/*
97 * dma_inv_range(start, end)
98 *
99 * Invalidate (discard) the specified virtual address range.
100 * May not write back any entries. If 'start' or 'end'
101 * are not cache line aligned, those lines must be written
102 * back.
103 *
104 * - start - virtual start address
105 * - end - virtual end address
106 */
107ENTRY(v4_dma_inv_range)
108 /* FALLTHROUGH */
109
110/*
111 * dma_flush_range(start, end)
112 *
113 * Clean and invalidate the specified virtual address range.
114 *
115 * - start - virtual start address
116 * - end - virtual end address
117 */
118ENTRY(v4_dma_flush_range)
Anders Grafströme4d2a592008-10-16 17:37:24 +0100119#ifdef CONFIG_CPU_CP15
Linus Torvalds1da177e2005-04-16 15:20:36 -0700120 mov r0, #0
121 mcr p15, 0, r0, c7, c7, 0 @ flush ID cache
Hyok S. Choif12d0d72006-09-26 17:36:37 +0900122#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700123 /* FALLTHROUGH */
124
125/*
126 * dma_clean_range(start, end)
127 *
128 * Clean (write back) the specified virtual address range.
129 *
130 * - start - virtual start address
131 * - end - virtual end address
132 */
133ENTRY(v4_dma_clean_range)
134 mov pc, lr
135
Russell Kinga9c91472009-11-26 16:19:58 +0000136/*
137 * dma_unmap_area(start, size, dir)
138 * - start - kernel virtual start address
139 * - size - size of region
140 * - dir - DMA direction
141 */
142ENTRY(v4_dma_unmap_area)
143 teq r2, #DMA_TO_DEVICE
144 bne v4_dma_inv_range
145 /* FALLTHROUGH */
146
147/*
148 * dma_map_area(start, size, dir)
149 * - start - kernel virtual start address
150 * - size - size of region
151 * - dir - DMA direction
152 */
153ENTRY(v4_dma_map_area)
154 mov pc, lr
155ENDPROC(v4_dma_unmap_area)
156ENDPROC(v4_dma_map_area)
157
Linus Torvalds1da177e2005-04-16 15:20:36 -0700158 __INITDATA
159
160 .type v4_cache_fns, #object
161ENTRY(v4_cache_fns)
162 .long v4_flush_kern_cache_all
163 .long v4_flush_user_cache_all
164 .long v4_flush_user_cache_range
165 .long v4_coherent_kern_range
166 .long v4_coherent_user_range
Russell King2c9b9c82009-11-26 12:56:21 +0000167 .long v4_flush_kern_dcache_area
Russell Kinga9c91472009-11-26 16:19:58 +0000168 .long v4_dma_map_area
169 .long v4_dma_unmap_area
Linus Torvalds1da177e2005-04-16 15:20:36 -0700170 .long v4_dma_inv_range
171 .long v4_dma_clean_range
172 .long v4_dma_flush_range
173 .size v4_cache_fns, . - v4_cache_fns