2 * linux/arch/unicore32/mm/cache-ucv2.S
4 * Code specific to PKUnity SoC and UniCore ISA
6 * Copyright (C) 2001-2010 GUAN Xue-tao
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
12 * This is the "shell" of the UniCore-v2 processor support.
14 #include <linux/linkage.h>
15 #include <linux/init.h>
16 #include <asm/assembler.h>
19 #include "proc-macros.S"
22 * __cpuc_flush_icache_all()
23 * __cpuc_flush_kern_all()
24 * __cpuc_flush_user_all()
26 * Flush the entire cache.
28 ENTRY(__cpuc_flush_icache_all)
30 ENTRY(__cpuc_flush_kern_all)
32 ENTRY(__cpuc_flush_user_all)
34 movc p0.c5, r0, #14 @ Dcache flush all
38 movc p0.c5, r0, #20 @ Icache invalidate all
44 * __cpuc_flush_user_range(start, end, flags)
46 * Flush a range of TLB entries in the specified address space.
48 * - start - start address (may not be aligned)
49 * - end - end address (exclusive, may not be aligned)
50 * - flags - vm_area_struct flags describing address space
52 ENTRY(__cpuc_flush_user_range)
54 beq __cpuc_dma_flush_range
56 #ifndef CONFIG_CPU_DCACHE_LINE_DISABLE
57 andn r0, r0, #CACHE_LINESIZE - 1 @ Safety check
59 csub.a r1, #MAX_AREA_SIZE
62 andn r1, r1, #CACHE_LINESIZE - 1
63 add r1, r1, #CACHE_LINESIZE
65 101: dcacheline_flush r0, r11, r12
67 add r0, r0, #CACHE_LINESIZE
68 sub.a r1, r1, #CACHE_LINESIZE
73 movc p0.c5, ip, #14 @ Dcache flush all
77 movc p0.c5, ip, #20 @ Icache invalidate all
83 * __cpuc_coherent_kern_range(start,end)
84 * __cpuc_coherent_user_range(start,end)
86 * Ensure that the I and D caches are coherent within specified
87 * region. This is typically used when code has been written to
88 * a memory region, and will be executed.
90 * - start - virtual start address of region
91 * - end - virtual end address of region
93 ENTRY(__cpuc_coherent_kern_range)
95 ENTRY(__cpuc_coherent_user_range)
96 #ifndef CONFIG_CPU_DCACHE_LINE_DISABLE
97 andn r0, r0, #CACHE_LINESIZE - 1 @ Safety check
99 csub.a r1, #MAX_AREA_SIZE
102 andn r1, r1, #CACHE_LINESIZE - 1
103 add r1, r1, #CACHE_LINESIZE
107 sub r9, r9, #1 @ PAGE_MASK
108 101: va2pa r0, r10, r11, r12, r13, 2f @ r10 is PA
113 103: movc p0.c5, r10, #11 @ Dcache clean line of R10
116 add r0, r0, #CACHE_LINESIZE
117 add r10, r10, #CACHE_LINESIZE
118 sub.a r1, r1, #CACHE_LINESIZE
123 movc p0.c5, ip, #10 @ Dcache clean all
127 movc p0.c5, ip, #20 @ Icache invalidate all
133 * __cpuc_flush_kern_dcache_area(void *addr, size_t size)
135 * - addr - kernel address
136 * - size - region size
138 ENTRY(__cpuc_flush_kern_dcache_area)
140 movc p0.c5, ip, #14 @ Dcache flush all
145 * __cpuc_dma_clean_range(start,end)
146 * - start - virtual start address of region
147 * - end - virtual end address of region
149 ENTRY(__cpuc_dma_clean_range)
150 #ifndef CONFIG_CPU_DCACHE_LINE_DISABLE
151 andn r0, r0, #CACHE_LINESIZE - 1
153 andn r1, r1, #CACHE_LINESIZE - 1
154 add r1, r1, #CACHE_LINESIZE
156 csub.a r1, #MAX_AREA_SIZE
161 sub r9, r9, #1 @ PAGE_MASK
162 101: va2pa r0, r10, r11, r12, r13, 2f @ r10 is PA
167 1: movc p0.c5, r10, #11 @ Dcache clean line of R10
169 add r0, r0, #CACHE_LINESIZE
170 add r10, r10, #CACHE_LINESIZE
171 sub.a r1, r1, #CACHE_LINESIZE
176 movc p0.c5, ip, #10 @ Dcache clean all
182 * __cpuc_dma_inv_range(start,end)
183 * __cpuc_dma_flush_range(start,end)
184 * - start - virtual start address of region
185 * - end - virtual end address of region
187 __cpuc_dma_inv_range:
189 ENTRY(__cpuc_dma_flush_range)
190 #ifndef CONFIG_CPU_DCACHE_LINE_DISABLE
191 andn r0, r0, #CACHE_LINESIZE - 1
193 andn r1, r1, #CACHE_LINESIZE - 1
194 add r1, r1, #CACHE_LINESIZE
196 csub.a r1, #MAX_AREA_SIZE
200 101: dcacheline_flush r0, r11, r12
202 add r0, r0, #CACHE_LINESIZE
203 sub.a r1, r1, #CACHE_LINESIZE
208 movc p0.c5, ip, #14 @ Dcache flush all