Rename cache coherency functions.
[maemo-rb.git] / firmware / target / arm / mmu-armv6.S
blob38eefece812db2ce6419fc09dc48207cc2496a66
1 /***************************************************************************
2  *             __________               __   ___.
3  *   Open      \______   \ ____   ____ |  | _\_ |__   _______  ___
4  *   Source     |       _//  _ \_/ ___\|  |/ /| __ \ /  _ \  \/  /
5  *   Jukebox    |    |   (  <_> )  \___|    < | \_\ (  <_> > <  <
6  *   Firmware   |____|_  /\____/ \___  >__|_ \|___  /\____/__/\_ \
7  *                     \/            \/     \/    \/            \/
8  * $Id$
9  *
10  * Copyright (C) 2006,2007 by Greg White
11  *
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.
16  *
17  * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18  * KIND, either express or implied.
19  *
20  ****************************************************************************/
21 #include "config.h"
22 #include "cpu.h"
24 /* TTB routines not used */
26 /** Cache coherency **/
28 #if 0 /* unused */
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);
34  */
35     .section   .text, "ax", %progbits
36     .align      2
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
47     movhi   r2, #0                  @
48     mcrrhi  p15, 0, r1, r0, c14     @ Clean and invalidate DCache range
49     mcrhi   p15, 0, r2, c7, c10, 4  @ Data synchronization barrier
50     bx      lr                      @
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);
58  */
59     .section   .text, "ax", %progbits
60     .align      2
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
66 commit_dcache_range:
67 clean_dcache_range:
68     add     r1, r0, r1              @ size -> end
69     cmp     r1, r0                  @ end <= start?
70     subhi   r1, r1, #1              @ round it down
71     movhi   r2, #0                  @
72     mcrrhi  p15, 0, r1, r0, c12     @ Clean DCache range
73     mcrhi   p15, 0, r2, c7, c10, 4  @ Data synchronization barrier
74     bx      lr                      @
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);
81  */
82     .section   .text, "ax", %progbits
83     .align      2
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
89 discard_dcache_range:
90 dump_dcache_range:
91     add     r1, r0, r1              @ size -> end
92     cmp     r1, r0                  @ end <= start?
93     bxls    lr                      @ 
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
99                                     @
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
107     mov     r0, #0                  @
108     mcr     p15, 0, r0, c7, c10, 4  @ Data synchronization barrier
109     bx      lr                      @
110     .size   discard_dcache_range, .-discard_dcache_range
114  * Write entire DCache back to RAM
115  * void commit_dcache(void);
116  */
117     .section   .text, "ax", %progbits
118     .align      2
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
125 commit_dcache:
126 cpucache_commit:
127 clean_dcache:
128 cpucache_flush:
129     mov     r0, #0                  @
130     mcr     p15, 0, r0, c7, c10, 0  @ Clean entire DCache
131     mcr     p15, 0, r0, c7, c10, 4  @ Data synchronization barrier
132     bx      lr                      @
133     .size   commit_dcache, .-commit_dcache
136  * Clean and invalidate entire DCache, will do writeback
137  * void commit_discard_dcache(void);
138  */
139     .section   .icode, "ax", %progbits
140     .align      2
141     .global     commit_discard_dcache
142     .type       commit_discard_dcache, %function
143     .global     invalidate_dcache   @ Alias, deprecated
145 commit_discard_dcache:
146 invalidate_dcache:
147     mov     r0, #0                  @
148     mcr     p15, 0, r0, c7, c14, 0  @ Clean and invalidate entire DCache
149     mcr     p15, 0, r0, c7, c10, 4  @ Data synchronization barrier
150     bx      lr                      @
151     .size   commit_discard_dcache, .-commit_discard_dcache
152     
155  * Discards the entire ICache, and commit+discards the entire DCache
156  * void commit_discard_idcache(void);
157  */
158     .section   .icode, "ax", %progbits
159     .align      2
160     .global     commit_discard_idcache
161     .type       commit_discard_idcache, %function
162     .global     cpucache_commit_discard @ Alias
163     .global     invalidate_idcache      @ Alias, deprecated
164     .global     cpucache_invalidate     @ Alias, deprecated
166 commit_discard_idcache:
167 invalidate_idcache:
168 cpucache_invalidate:
169     mov     r0, #0                  @
170     mcr     p15, 0, r0, c7, c14, 0  @ Clean and invalidate entire DCache
171     mcr     p15, 0, r0, c7, c5, 0   @ Invalidate entire ICache
172                                     @ Also flushes the branch target cache
173     mcr     p15, 0, r0, c7, c10, 4  @ Data synchronization barrier
174     mcr     p15, 0, r0, c7, c5, 4   @ Flush prefetch buffer (IMB)
175     bx      lr                      @
176     .size   commit_discard_idcache, .-commit_discard_idcache