cacheops_60.h revision 1.6 1 1.6 perry /* $NetBSD: cacheops_60.h,v 1.6 2005/12/24 20:07:15 perry Exp $ */
2 1.1 leo
3 1.1 leo /*-
4 1.1 leo * Copyright (c) 1997 The NetBSD Foundation, Inc.
5 1.1 leo * All rights reserved.
6 1.1 leo *
7 1.1 leo * This code is derived from software contributed to The NetBSD Foundation
8 1.1 leo * by Leo Weppelman
9 1.1 leo *
10 1.1 leo * Redistribution and use in source and binary forms, with or without
11 1.1 leo * modification, are permitted provided that the following conditions
12 1.1 leo * are met:
13 1.1 leo * 1. Redistributions of source code must retain the above copyright
14 1.1 leo * notice, this list of conditions and the following disclaimer.
15 1.1 leo * 2. Redistributions in binary form must reproduce the above copyright
16 1.1 leo * notice, this list of conditions and the following disclaimer in the
17 1.1 leo * documentation and/or other materials provided with the distribution.
18 1.1 leo * 3. All advertising materials mentioning features or use of this software
19 1.1 leo * must display the following acknowledgement:
20 1.1 leo * This product includes software developed by the NetBSD
21 1.1 leo * Foundation, Inc. and its contributors.
22 1.1 leo * 4. Neither the name of The NetBSD Foundation nor the names of its
23 1.1 leo * contributors may be used to endorse or promote products derived
24 1.1 leo * from this software without specific prior written permission.
25 1.1 leo *
26 1.1 leo * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
27 1.1 leo * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
28 1.1 leo * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 1.1 leo * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
30 1.1 leo * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31 1.1 leo * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32 1.1 leo * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33 1.1 leo * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34 1.1 leo * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35 1.1 leo * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36 1.1 leo * POSSIBILITY OF SUCH DAMAGE.
37 1.1 leo */
38 1.1 leo
39 1.1 leo /*
40 1.1 leo * Invalidate entire TLB.
41 1.1 leo */
42 1.6 perry static inline void __attribute__((__unused__))
43 1.5 chs TBIA_60(void)
44 1.1 leo {
45 1.6 perry __asm volatile (" .word 0xf518" ); /* pflusha */
46 1.1 leo }
47 1.1 leo
48 1.1 leo /*
49 1.1 leo * Invalidate any TLB entry for given VA (TB Invalidate Single)
50 1.1 leo */
51 1.6 perry static inline void __attribute__((__unused__))
52 1.5 chs TBIS_60(vaddr_t va)
53 1.1 leo {
54 1.4 thorpej register vaddr_t r_va __asm("%a0") = va;
55 1.1 leo int tmp;
56 1.1 leo
57 1.6 perry __asm volatile (" movc %1, %%dfc;" /* select supervisor */
58 1.4 thorpej " .word 0xf508;" /* pflush %a0@ */
59 1.1 leo " moveq %3, %1;" /* select user */
60 1.4 thorpej " movc %1, %%dfc;"
61 1.4 thorpej " .word 0xf508;" /* pflush %a0@ */
62 1.4 thorpej " movc %%cacr,%1;"
63 1.1 leo " orl %4,%1;"
64 1.4 thorpej " movc %1,%%cacr" : "=d" (tmp) :
65 1.1 leo "0" (FC_SUPERD), "a" (r_va), "i" (FC_USERD),
66 1.1 leo "i" (IC60_CABC));
67 1.1 leo }
68 1.1 leo
69 1.1 leo /*
70 1.1 leo * Invalidate supervisor side of TLB
71 1.1 leo */
72 1.6 perry static inline void __attribute__((__unused__))
73 1.5 chs TBIAS_60(void)
74 1.1 leo {
75 1.1 leo int tmp;
76 1.5 chs
77 1.1 leo /*
78 1.1 leo * Cannot specify supervisor/user on pflusha, so we flush all
79 1.1 leo */
80 1.6 perry __asm volatile (" .word 0xf518;"
81 1.4 thorpej " movc %%cacr,%0;"
82 1.1 leo " orl %1,%0;"
83 1.4 thorpej " movc %0,%%cacr" /* clear all branch cache
84 1.4 thorpej entries */
85 1.1 leo : "=d" (tmp) : "i" (IC60_CABC) );
86 1.1 leo }
87 1.1 leo
88 1.1 leo /*
89 1.1 leo * Invalidate user side of TLB
90 1.1 leo */
91 1.6 perry static inline void __attribute__((__unused__))
92 1.5 chs TBIAU_60(void)
93 1.1 leo {
94 1.1 leo int tmp;
95 1.5 chs
96 1.1 leo /*
97 1.1 leo * Cannot specify supervisor/user on pflusha, so we flush all
98 1.1 leo */
99 1.6 perry __asm volatile (" .word 0xf518;"
100 1.4 thorpej " movc %%cacr,%0;"
101 1.1 leo " orl %1,%0;"
102 1.4 thorpej " movc %0,%%cacr" /* clear all branch cache
103 1.4 thorpej entries */
104 1.1 leo : "=d" (tmp) : "i" (IC60_CUBC) );
105 1.1 leo }
106 1.1 leo
107 1.1 leo /*
108 1.1 leo * Invalidate instruction cache
109 1.1 leo */
110 1.6 perry static inline void __attribute__((__unused__))
111 1.5 chs ICIA_60(void)
112 1.1 leo {
113 1.1 leo /* inva ic (also clears branch cache) */
114 1.6 perry __asm volatile (" .word 0xf498;");
115 1.1 leo }
116 1.1 leo
117 1.6 perry static inline void __attribute__((__unused__))
118 1.5 chs ICPA_60(void)
119 1.1 leo {
120 1.1 leo /* inva ic (also clears branch cache) */
121 1.6 perry __asm volatile (" .word 0xf498;");
122 1.1 leo }
123 1.1 leo
124 1.1 leo /*
125 1.1 leo * Invalidate data cache.
126 1.1 leo */
127 1.6 perry static inline void __attribute__((__unused__))
128 1.5 chs DCIA_60(void)
129 1.1 leo {
130 1.6 perry __asm volatile (" .word 0xf478;"); /* cpusha dc */
131 1.1 leo }
132 1.1 leo
133 1.6 perry static inline void __attribute__((__unused__))
134 1.5 chs DCIS_60(void)
135 1.1 leo {
136 1.6 perry __asm volatile (" .word 0xf478;"); /* cpusha dc */
137 1.1 leo }
138 1.1 leo
139 1.6 perry static inline void __attribute__((__unused__))
140 1.5 chs DCIU_60(void)
141 1.1 leo {
142 1.6 perry __asm volatile (" .word 0xf478;"); /* cpusha dc */
143 1.1 leo }
144 1.1 leo
145 1.6 perry static inline void __attribute__((__unused__))
146 1.5 chs DCIAS_60(paddr_t pa)
147 1.1 leo {
148 1.4 thorpej register paddr_t r_pa __asm("%a0") = pa;
149 1.1 leo
150 1.6 perry __asm volatile (" .word 0xf468;" : : "a" (r_pa)); /* cpushl dc,%a0@ */
151 1.1 leo }
152 1.1 leo
153 1.6 perry static inline void __attribute__((__unused__))
154 1.5 chs PCIA_60(void)
155 1.1 leo {
156 1.6 perry __asm volatile (" .word 0xf478;"); /* cpusha dc */
157 1.1 leo }
158 1.1 leo
159 1.6 perry static inline void __attribute__((__unused__))
160 1.5 chs DCFA_60(void)
161 1.1 leo {
162 1.6 perry __asm volatile (" .word 0xf478;"); /* cpusha dc */
163 1.1 leo }
164 1.1 leo
165 1.1 leo /* invalidate instruction physical cache line */
166 1.6 perry static inline void __attribute__((__unused__))
167 1.5 chs ICPL_60(paddr_t pa)
168 1.1 leo {
169 1.4 thorpej register paddr_t r_pa __asm("%a0") = pa;
170 1.1 leo
171 1.6 perry __asm volatile (" .word 0xf488;" : : "a" (r_pa)); /* cinvl ic,%a0@ */
172 1.1 leo }
173 1.1 leo
174 1.1 leo /* invalidate instruction physical cache page */
175 1.6 perry static inline void __attribute__((__unused__))
176 1.5 chs ICPP_60(paddr_t pa)
177 1.1 leo {
178 1.4 thorpej register paddr_t r_pa __asm("%a0") = pa;
179 1.1 leo
180 1.6 perry __asm volatile (" .word 0xf490;" : : "a" (r_pa)); /* cinvp ic,%a0@ */
181 1.1 leo }
182 1.1 leo
183 1.1 leo /* invalidate data physical cache line */
184 1.6 perry static inline void __attribute__((__unused__))
185 1.5 chs DCPL_60(paddr_t pa)
186 1.1 leo {
187 1.4 thorpej register paddr_t r_pa __asm("%a0") = pa;
188 1.1 leo
189 1.6 perry __asm volatile (" .word 0xf448;" : : "a" (r_pa)); /* cinvl dc,%a0@ */
190 1.1 leo }
191 1.1 leo
192 1.1 leo /* invalidate data physical cache page */
193 1.6 perry static inline void __attribute__((__unused__))
194 1.5 chs DCPP_60(paddr_t pa)
195 1.1 leo {
196 1.4 thorpej register paddr_t r_pa __asm("%a0") = pa;
197 1.1 leo
198 1.6 perry __asm volatile (" .word 0xf450;" : : "a" (r_pa)); /* cinvp dc,%a0@ */
199 1.1 leo }
200 1.1 leo
201 1.1 leo /* invalidate data physical all */
202 1.6 perry static inline void __attribute__((__unused__))
203 1.5 chs DCPA_60(void)
204 1.1 leo {
205 1.6 perry __asm volatile (" .word 0xf458;"); /* cinva dc */
206 1.1 leo }
207 1.1 leo
208 1.1 leo /* data cache flush line */
209 1.6 perry static inline void __attribute__((__unused__))
210 1.5 chs DCFL_60(paddr_t pa)
211 1.1 leo {
212 1.4 thorpej register paddr_t r_pa __asm("%a0") = pa;
213 1.1 leo
214 1.6 perry __asm volatile (" .word 0xf468;" : : "a" (r_pa)); /* cpushl dc,%a0@ */
215 1.1 leo }
216 1.1 leo
217 1.1 leo /* data cache flush page */
218 1.6 perry static inline void __attribute__((__unused__))
219 1.5 chs DCFP_60(paddr_t pa)
220 1.1 leo {
221 1.4 thorpej register paddr_t r_pa __asm("%a0") = pa;
222 1.1 leo
223 1.6 perry __asm volatile (" .word 0xf470;" : : "a" (r_pa)); /* cpushp dc,%a0@ */
224 1.1 leo }
225