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 * Invalidate DCache for this range
33 * void invalidate_dcache_range(const void *base, unsigned int size)
35 .section .text, "ax", %progbits
37 .global invalidate_dcache_range
38 .type invalidate_dcache_range, %function
39 @ MVA format: 31:5 = Modified virtual address, 4:0 = Ignored
40 invalidate_dcache_range:
41 add r1, r0, r1 @ size -> end
42 cmp r1, r0 @ end <= start?
43 subhi r1, r1, #1 @ round it down
45 mcrrhi p15, 0, r1, r0, c14 @ Clean and invalidate DCache range
46 mcrhi p15, 0, r2, c7, c10, 4 @ Data synchronization barrier
48 .size invalidate_dcache_range, .-invalidate_dcache_range
50 #endif /* unused function */
53 * clean DCache for this range
54 * forces DCache writeback for the specified range
55 * void clean_dcache_range(const void *base, unsigned int size);
57 .section .text, "ax", %progbits
59 .global clean_dcache_range
60 .type clean_dcache_range, %function
61 @ MVA format: 31:5 = Modified virtual address, 4:0 = Ignored
63 add r1, r0, r1 @ size -> end
64 cmp r1, r0 @ end <= start?
65 subhi r1, r1, #1 @ round it down
67 mcrrhi p15, 0, r1, r0, c12 @ Clean DCache range
68 mcrhi p15, 0, r2, c7, c10, 4 @ Data synchronization barrier
70 .size clean_dcache_range, .-clean_dcache_range
73 * Dump DCache for this range
74 * will *NOT* do write back except for buffer edges not on a line boundary
75 * void dump_dcache_range(const void *base, unsigned int size);
77 .section .text, "ax", %progbits
79 .global dump_dcache_range
80 .type dump_dcache_range, %function
81 @ MVA format (mcr): 31:5 = Modified virtual address, 4:0 = SBZ
82 @ MVA format (mcrr): 31:5 = Modified virtual address, 4:0 = Ignored
84 add r1, r0, r1 @ size -> end
85 cmp r1, r0 @ end <= start?
87 tst r0, #31 @ Check first line for bits set
88 bicne r0, r0, #31 @ Clear low five bits (down)
89 mcrne p15, 0, r0, c7, c14, 1 @ Clean and invalidate line by MVA
90 @ if not cache aligned
91 addne r0, r0, #32 @ Move to the next cache line
93 tst r1, #31 @ Check last line for bits set
94 bicne r1, r1, #31 @ Clear low five bits (down)
95 mcrne p15, 0, r1, c7, c14, 1 @ Clean and invalidate line by MVA
96 @ if not cache aligned
97 sub r1, r1, #32 @ Move to the previous cache line
98 cmp r1, r0 @ end < start now?
99 mcrrhs p15, 0, r1, r0, c6 @ Invalidate DCache range
101 mcr p15, 0, r0, c7, c10, 4 @ Data synchronization barrier
103 .size dump_dcache_range, .-dump_dcache_range
107 * Cleans entire DCache
108 * void clean_dcache(void);
110 .section .text, "ax", %progbits
113 .type clean_dcache, %function
114 .global cpucache_flush @ Alias
118 mcr p15, 0, r0, c7, c10, 0 @ Clean entire DCache
119 mcr p15, 0, r0, c7, c10, 4 @ Data synchronization barrier
121 .size clean_dcache, .-clean_dcache
124 * Invalidate entire DCache
126 * void invalidate_dcache(void);
128 .section .text, "ax", %progbits
130 .global invalidate_dcache
131 .type invalidate_dcache, %function
134 mcr p15, 0, r0, c7, c14, 0 @ Clean and invalidate entire DCache
135 mcr p15, 0, r0, c7, c10, 4 @ Data synchronization barrier
137 .size invalidate_dcache, .-invalidate_dcache
140 * Invalidate entire ICache and DCache
142 * void invalidate_idcache(void);
144 .section .icode, "ax", %progbits
146 .global invalidate_idcache
147 .type invalidate_idcache, %function
148 .global cpucache_invalidate @ Alias
152 mcr p15, 0, r0, c7, c14, 0 @ Clean and invalidate entire DCache
153 mcr p15, 0, r0, c7, c5, 0 @ Invalidate entire ICache
154 @ Also flushes the branch target cache
155 mcr p15, 0, r0, c7, c10, 4 @ Data synchronization barrier
156 mcr p15, 0, r0, c7, c5, 4 @ Flush prefetch buffer (IMB)
158 .size invalidate_idcache, .-invalidate_idcache