2 * include/asm-xtensa/cacheasm.h
4 * This file is subject to the terms and conditions of the GNU General Public
5 * License. See the file "COPYING" in the main directory of this archive
8 * Copyright (C) 2006 Tensilica Inc.
11 #include <asm/cache.h>
12 #include <asm/asmmacro.h>
13 #include <linux/stringify.h>
16 * Define cache functions as macros here so that they can be used
17 * by the kernel and boot loader. We should consider moving them to a
18 * library that can be linked by both.
22 * ___unlock_dcache_all
23 * ___unlock_icache_all
25 * Flush and invaldating
27 * ___flush_invalidate_dcache_{all|range|page}
28 * ___flush_dcache_{all|range|page}
29 * ___invalidate_dcache_{all|range|page}
30 * ___invalidate_icache_{all|range|page}
35 .macro __loop_cache_unroll ar at insn size line_width max_immed
37 .if (1 << (\line_width)) > (\max_immed)
39 .elseif (2 << (\line_width)) > (\max_immed)
45 __loopi \ar, \at, \size, (_reps << (\line_width))
48 \insn \ar, _index << (\line_width)
49 .set _index, _index + 1
51 __endla \ar, \at, _reps << (\line_width)
56 .macro __loop_cache_all ar at insn size line_width max_immed
59 __loop_cache_unroll \ar, \at, \insn, \size, \line_width, \max_immed
64 .macro __loop_cache_range ar as at insn line_width
66 extui \at, \ar, 0, \line_width
69 __loops \ar, \as, \at, \line_width
71 __endla \ar, \at, (1 << (\line_width))
76 .macro __loop_cache_page ar at insn line_width max_immed
78 __loop_cache_unroll \ar, \at, \insn, PAGE_SIZE, \line_width, \max_immed
83 .macro ___unlock_dcache_all ar at
85 #if XCHAL_DCACHE_LINE_LOCKABLE && XCHAL_DCACHE_SIZE
86 __loop_cache_all \ar \at diu XCHAL_DCACHE_SIZE \
87 XCHAL_DCACHE_LINEWIDTH 240
93 .macro ___unlock_icache_all ar at
95 #if XCHAL_ICACHE_LINE_LOCKABLE && XCHAL_ICACHE_SIZE
96 __loop_cache_all \ar \at iiu XCHAL_ICACHE_SIZE \
97 XCHAL_ICACHE_LINEWIDTH 240
103 .macro ___flush_invalidate_dcache_all ar at
105 #if XCHAL_DCACHE_SIZE
106 __loop_cache_all \ar \at diwbi XCHAL_DCACHE_SIZE \
107 XCHAL_DCACHE_LINEWIDTH 240
113 .macro ___flush_dcache_all ar at
115 #if XCHAL_DCACHE_SIZE
116 __loop_cache_all \ar \at diwb XCHAL_DCACHE_SIZE \
117 XCHAL_DCACHE_LINEWIDTH 240
123 .macro ___invalidate_dcache_all ar at
125 #if XCHAL_DCACHE_SIZE
126 __loop_cache_all \ar \at dii XCHAL_DCACHE_SIZE \
127 XCHAL_DCACHE_LINEWIDTH 1020
133 .macro ___invalidate_icache_all ar at
135 #if XCHAL_ICACHE_SIZE
136 __loop_cache_all \ar \at iii XCHAL_ICACHE_SIZE \
137 XCHAL_ICACHE_LINEWIDTH 1020
144 .macro ___flush_invalidate_dcache_range ar as at
146 #if XCHAL_DCACHE_SIZE
147 __loop_cache_range \ar \as \at dhwbi XCHAL_DCACHE_LINEWIDTH
153 .macro ___flush_dcache_range ar as at
155 #if XCHAL_DCACHE_SIZE
156 __loop_cache_range \ar \as \at dhwb XCHAL_DCACHE_LINEWIDTH
162 .macro ___invalidate_dcache_range ar as at
164 #if XCHAL_DCACHE_SIZE
165 __loop_cache_range \ar \as \at dhi XCHAL_DCACHE_LINEWIDTH
171 .macro ___invalidate_icache_range ar as at
173 #if XCHAL_ICACHE_SIZE
174 __loop_cache_range \ar \as \at ihi XCHAL_ICACHE_LINEWIDTH
181 .macro ___flush_invalidate_dcache_page ar as
183 #if XCHAL_DCACHE_SIZE
184 __loop_cache_page \ar \as dhwbi XCHAL_DCACHE_LINEWIDTH 1020
190 .macro ___flush_dcache_page ar as
192 #if XCHAL_DCACHE_SIZE
193 __loop_cache_page \ar \as dhwb XCHAL_DCACHE_LINEWIDTH 1020
199 .macro ___invalidate_dcache_page ar as
201 #if XCHAL_DCACHE_SIZE
202 __loop_cache_page \ar \as dhi XCHAL_DCACHE_LINEWIDTH 1020
208 .macro ___invalidate_icache_page ar as
210 #if XCHAL_ICACHE_SIZE
211 __loop_cache_page \ar \as ihi XCHAL_ICACHE_LINEWIDTH 1020