1 /*---------------------------------------------------------------------------*
2 Project: TwlSDK - OS - include
3 File: cache.h
4
5 Copyright 2003-2008 Nintendo. All rights reserved.
6
7 These coded instructions, statements, and computer programs contain
8 proprietary information of Nintendo of America Inc. and/or Nintendo
9 Company Ltd., and are protected by Federal copyright law. They may
10 not be disclosed to third parties or copied or duplicated in any form,
11 in whole or in part, without the prior written consent of Nintendo.
12
13 $Date:: 2008-09-18#$
14 $Rev: 8573 $
15 $Author: okubata_ryoma $
16
17 *---------------------------------------------------------------------------*/
18
19 #ifndef NITRO_OS_CACHE_H_
20 #define NITRO_OS_CACHE_H_
21
22 #ifdef __cplusplus
23 extern "C" {
24 #endif
25
26 #include <nitro/misc.h>
27 #include <nitro/types.h>
28
29 //===========================================================================
30 // DATA CACHE CONTROL
31 //===========================================================================
32 /*---------------------------------------------------------------------------*
33 Name: DC_Enable
34
35 Description: enable data cache
36
37 Arguments: None
38
39 Returns: previous state
40 *---------------------------------------------------------------------------*/
41 BOOL DC_Enable();
42
43 /*---------------------------------------------------------------------------*
44 Name: DC_Disable
45
46 Description: disable data cache
47
48 Arguments: None
49
50 Returns: previous stats
51 *---------------------------------------------------------------------------*/
52 BOOL DC_Disable();
53
54 /*---------------------------------------------------------------------------*
55 Name: DC_Restore
56
57 Description: set state of data cache
58
59 Arguments: data cache state to be set
60
61 Returns: previous state
62 *---------------------------------------------------------------------------*/
63 BOOL DC_Restore(BOOL enable);
64
65
66 //===========================================================================
67 // DATA CACHE (for all range)
68 //===========================================================================
69 /*---------------------------------------------------------------------------*
70 Name: DC_InvalidateAll
71
72 Description: invalidate all data cache
73
74 Arguments: None.
75
76 Returns: None.
77 *---------------------------------------------------------------------------*/
78 void DC_InvalidateAll(void);
79
80 /*---------------------------------------------------------------------------*
81 Name: DC_StoreAll
82
83 Description: clean all data cache
84 (write cache data to memory)
85
86 Arguments: None.
87
88 Returns: None.
89 *---------------------------------------------------------------------------*/
90 void DC_StoreAll(void);
91
92 /*---------------------------------------------------------------------------*
93 Name: DC_FlushAll
94
95 Description: clean and invalidate all data cache
96 (write cache data to memory, and invalidate cache)
97
98 Arguments: None.
99
100 Returns: None.
101 *---------------------------------------------------------------------------*/
102 void DC_FlushAll(void);
103
104
105 //===========================================================================
106 // DATA CACHE (for specified range)
107 //===========================================================================
108 /*---------------------------------------------------------------------------*
109 Name: DC_InvalidateRange
110
111 Description: invalidate data cache in specified range
112
113 Arguments: startAddr start address
114 nBytes size (in byte)
115
116 Returns: None.
117 *---------------------------------------------------------------------------*/
118 void DC_InvalidateRange(void *startAddr, u32 nBytes);
119
120 /*---------------------------------------------------------------------------*
121 Name: DC_StoreRange
122
123 Description: clean data cache in specified range
124 (write cache data to memory)
125
126 Arguments: startAddr start address
127 nBytes size (in byte)
128
129 Returns: None.
130 *---------------------------------------------------------------------------*/
131 void DC_StoreRange(const void *startAddr, u32 nBytes);
132
133 /*---------------------------------------------------------------------------*
134 Name: DC_FlushRange
135
136 Description: clean and invalidate data cache in specified range
137 (write cache data to memory, and invalidate cache)
138
139 Arguments: startAddr start address
140 nBytes size (in byte)
141
142 Returns: None.
143 *---------------------------------------------------------------------------*/
144 void DC_FlushRange(const void *startAddr, u32 nBytes);
145
146
147 //===========================================================================
148 // DATA CACHE (for specified range)
149 //===========================================================================
150 /*---------------------------------------------------------------------------*
151 Name: DC_TouchRange
152
153 Description: include specified area to data cache in advance
154
155 Arguments: startAddr start address
156 nBytes size (in byte)
157
158 Returns: None.
159 *---------------------------------------------------------------------------*/
160 void DC_TouchRange(const void *startAddr, u32 nBytes);
161
162 /*---------------------------------------------------------------------------*
163 Name: DC_LockdownRange
164
165 Description: lock specified area to prevent not to release data cache
166
167 Arguments: startAddr start address
168 nBytes size (in byte)
169
170 Returns: None.
171 *---------------------------------------------------------------------------*/
172 void DC_LockdownRange(const void *startAddr, u32 nBytes);
173
174 /*---------------------------------------------------------------------------*
175 Name: DC_UnlockdownAll
176
177 Description: unlock all data cache to enable to release
178
179 Arguments: none.
180
181 Returns: None.
182 *---------------------------------------------------------------------------*/
183 void DC_UnlockdownAll(void);
184
185 /*---------------------------------------------------------------------------*
186 Name: DC_Unlockdown
187
188 Description: unlock any data cache to enable to release
189
190 Arguments: num - specify number of datablock to unlock.
191
192 Returns: None.
193 *---------------------------------------------------------------------------*/
194 void DC_Unlockdown(u32 num);
195
196 /*---------------------------------------------------------------------------*
197 Name: DC_WaitWriteBufferEmpty
198
199 Description: wait till write buffer becomes to be empty
200
201 Arguments: None.
202
203 Returns: None.
204 *---------------------------------------------------------------------------*/
205 void DC_WaitWriteBufferEmpty(void);
206
207
208 //===========================================================================
209 // ALIAS OF DC function
210 //===========================================================================
211 /*---------------------------------------------------------------------------*
212 Name: DC_CleanAll
213
214 Description: alias for DC_StoreAll
215
216 Arguments: None.
217
218 Returns: None.
219 *---------------------------------------------------------------------------*/
DC_CleanAll(void)220 static inline void DC_CleanAll(void)
221 {
222 DC_StoreAll();
223 }
224
225 /*---------------------------------------------------------------------------*
226 Name: DC_CleanAndInvalidateAll
227
228 Description: alias for DC_FlushAll
229
230 Arguments: None.
231
232 Returns: None.
233 *---------------------------------------------------------------------------*/
DC_CleanAndInvalidateAll(void)234 static inline void DC_CleanAndInvalidateAll(void)
235 {
236 DC_FlushAll();
237 }
238
239 /*---------------------------------------------------------------------------*
240 Name: DC_CleanRange
241
242 Description: alias for DC_StoreRange
243
244 Arguments: startAddr start address
245 nBytes size (in byte)
246
247 Returns: None.
248 *---------------------------------------------------------------------------*/
DC_CleanRange(const void * startAddr,u32 nBytes)249 static inline void DC_CleanRange(const void *startAddr, u32 nBytes)
250 {
251 DC_StoreRange(startAddr, nBytes);
252 }
253
254 /*---------------------------------------------------------------------------*
255 Name: DC_CleanAndInvalidateRange
256
257 Description: alias for DC_FlushRange
258
259 Arguments: startAddr start address
260 nBytes size (in byte)
261
262 Returns: None.
263 *---------------------------------------------------------------------------*/
DC_CleanAndInvalidateRange(const void * startAddr,u32 nBytes)264 static inline void DC_CleanAndInvalidateRange(const void *startAddr, u32 nBytes)
265 {
266 DC_FlushRange(startAddr, nBytes);
267 }
268
269 //===========================================================================
270 // INSTRUCTION CACHE CONTROL
271 //===========================================================================
272 /*---------------------------------------------------------------------------*
273 Name: IC_Enable
274
275 Description: enable instruction cache
276
277 Arguments: None
278
279 Returns: previous state
280 *---------------------------------------------------------------------------*/
281 BOOL IC_Enable();
282
283 /*---------------------------------------------------------------------------*
284 Name: IC_Disable
285
286 Description: disable instruction cache
287
288 Arguments: None
289
290 Returns: previous stats
291 *---------------------------------------------------------------------------*/
292 BOOL IC_Disable();
293
294 /*---------------------------------------------------------------------------*
295 Name: IC_Restore
296
297 Description: set state of instruction cache
298
299 Arguments: instruction cache state to be set
300
301 Returns: previous stats
302 *---------------------------------------------------------------------------*/
303 BOOL IC_Restore(BOOL enable);
304
305
306 //===========================================================================
307 // INSTRUCTION CACHE
308 //===========================================================================
309 /*---------------------------------------------------------------------------*
310 Name: IC_InvalidateAll
311
312 Description: invalidate all instruction cache
313
314 Arguments: None.
315
316 Returns: None.
317 *---------------------------------------------------------------------------*/
318 void IC_InvalidateAll(void);
319
320 /*---------------------------------------------------------------------------*
321 Name: IC_InvalidateRange
322
323 Description: invalidate instruction cache in specified range
324
325 Arguments: startAddr start address
326 nBytes size (in byte)
327
328 Returns: None.
329 *---------------------------------------------------------------------------*/
330 void IC_InvalidateRange(void *startAddr, u32 nBytes);
331
332 /*---------------------------------------------------------------------------*
333 Name: IC_PrefetchRange
334
335 Description: include specified area to instruction cache in advance
336
337 Arguments: startAddr start address
338 nBytes size (in byte)
339
340 Returns: None.
341 *---------------------------------------------------------------------------*/
342 void IC_PrefetchRange(const void *startAddr, u32 nBytes);
343
344 /*---------------------------------------------------------------------------*
345 Name: IC_LockdownRange
346
347 Description: lock specified area to prevent not to release instruction cache
348
349 Arguments: startAddr start address
350 nBytes size (in byte)
351
352 Returns: None.
353 *---------------------------------------------------------------------------*/
354 void IC_LockdownRange(const void *startAddr, u32 nBytes);
355
356 /*---------------------------------------------------------------------------*
357 Name: IC_Unlockdown
358
359 Description: unlock any instruction cache to enable to release
360
361 Arguments: num - specify number of datablock to unlock.
362
363 Returns: None.
364 *---------------------------------------------------------------------------*/
365 void IC_Unlockdown(u32 num);
366
367 /*---------------------------------------------------------------------------*
368 Name: IC_UnlockdownAll
369
370 Description: unlock all instruction cache to enable to release
371
372 Arguments: None.
373
374 Returns: None.
375 *---------------------------------------------------------------------------*/
376 void IC_UnlockdownAll(void);
377
378
379 #ifdef __cplusplus
380 } /* extern "C" */
381 #endif
382
383 /* NITRO_OS_CACHE_H_ */
384 #endif
385