1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Copyright (C) 2006,2007 by Greg White
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
20 ****************************************************************************/
24 /* TTB routines not used */
26 /** Cache coherency **/
31 * Write DCache back to RAM for the given range and remove cache lines
32 * from DCache afterwards
33 * void commit_discard_dcache_range(const void *base, unsigned int size);
35 .section .text, "ax", %progbits
37 .global commit_discard_dcache_range
38 .type commit_discard_dcache_range, %function
39 .global invalidate_dcache_range @ Alias, deprecated
41 @ MVA format: 31:5 = Modified virtual address, 4:0 = SBZ
42 commit_discard_dcache_range:
43 invalidate_dcache_range:
44 add r1, r0, r1 @ size -> end
45 cmp r1, r0 @ end <= start?
46 subhi r1, r1, #1 @ round it down
48 mcrrhi p15, 0, r1, r0, c14 @ Clean and invalidate DCache range
49 mcrhi p15, 0, r2, c7, c10, 4 @ Data synchronization barrier
51 .size commit_discard_dcache_range, .-commit_discard_dcache_range
53 #endif /* unused function */
56 * Write DCache back to RAM for the given range
57 * void commit_dcache_range(const void *base, unsigned int size);
59 .section .text, "ax", %progbits
61 .global commit_dcache_range
62 .type commit_dcache_range, %function
63 .global clean_dcache_range @ Alias, deprecated
65 @ MVA format: 31:5 = Modified virtual address, 4:0 = SBZ
68 add r1, r0, r1 @ size -> end
69 cmp r1, r0 @ end <= start?
70 subhi r1, r1, #1 @ round it down
72 mcrrhi p15, 0, r1, r0, c12 @ Clean DCache range
73 mcrhi p15, 0, r2, c7, c10, 4 @ Data synchronization barrier
75 .size commit_dcache_range, .-commit_dcache_range
78 * Remove cache lines for the given range from DCache
79 * will *NOT* do write back except for buffer edges not on a line boundary
80 * void discard_dcache_range(const void *base, unsigned int size);
82 .section .text, "ax", %progbits
84 .global discard_dcache_range
85 .type discard_dcache_range, %function
86 .global dump_dcache_range @ Alias, deprecated
88 @ MVA format: 31:5 = Modified virtual address, 4:0 = SBZ
91 add r1, r0, r1 @ size -> end
92 cmp r1, r0 @ end <= start?
94 tst r0, #31 @ Check first line for bits set
95 bicne r0, r0, #31 @ Clear low five bits (down)
96 mcrne p15, 0, r0, c7, c14, 1 @ Clean and invalidate line by MVA
97 @ if not cache aligned
98 addne r0, r0, #32 @ Move to the next cache line
100 tst r1, #31 @ Check last line for bits set
101 bicne r1, r1, #31 @ Clear low five bits (down)
102 mcrne p15, 0, r1, c7, c14, 1 @ Clean and invalidate line by MVA
103 @ if not cache aligned
104 sub r1, r1, #32 @ Move to the previous cache line
105 cmp r1, r0 @ end < start now?
106 mcrrhs p15, 0, r1, r0, c6 @ Invalidate DCache range
108 mcr p15, 0, r0, c7, c10, 4 @ Data synchronization barrier
110 .size discard_dcache_range, .-discard_dcache_range
114 * Write entire DCache back to RAM
115 * void commit_dcache(void);
117 .section .text, "ax", %progbits
119 .global commit_dcache
120 .type commit_dcache, %function
121 .global cpucache_commit @ Alias
122 .global clean_dcache @ Alias, deprecated
123 .global cpucache_flush @ Alias, deprecated
130 mcr p15, 0, r0, c7, c10, 0 @ Clean entire DCache
131 mcr p15, 0, r0, c7, c10, 4 @ Data synchronization barrier
133 .size commit_dcache, .-commit_dcache
136 * Clean and invalidate entire DCache, will do writeback
137 * void commit_discard_dcache(void);
139 .section .icode, "ax", %progbits
141 .global commit_discard_dcache
142 .type commit_discard_dcache, %function
143 .global invalidate_dcache @ Alias, deprecated
145 commit_discard_dcache:
148 mcr p15, 0, r0, c7, c14, 0 @ Clean and invalidate entire DCache
149 mcr p15, 0, r0, c7, c10, 4 @ Data synchronization barrier
151 .size commit_discard_dcache, .-commit_discard_dcache
155 * Discards the entire ICache, and commit+discards the entire DCache
156 * void cpucache_commit_discard(void);
158 .section .icode, "ax", %progbits
160 .global cpucache_commit_discard
161 .type cpucache_commit_discard, %function
162 .global commit_discard_idcache @ Alias
163 .global invalidate_idcache @ Alias, deprecated
164 .global cpucache_invalidate @ Alias, deprecated
166 cpucache_commit_discard:
167 commit_discard_idcache:
171 mcr p15, 0, r0, c7, c14, 0 @ Clean and invalidate entire DCache
172 mcr p15, 0, r0, c7, c5, 0 @ Invalidate entire ICache
173 @ Also flushes the branch target cache
174 mcr p15, 0, r0, c7, c10, 4 @ Data synchronization barrier
175 mcr p15, 0, r0, c7, c5, 4 @ Flush prefetch buffer (IMB)
177 .size commit_discard_idcache, .-commit_discard_idcache