1 /*-------------------------------------------------------------
3 cache.c -- Cache interface
6 Michael Wiedenbauer (shagkur)
7 Dave Murphy (WinterMute)
9 This software is provided 'as-is', without any express or implied
10 warranty. In no event will the authors be held liable for any
11 damages arising from the use of this software.
13 Permission is granted to anyone to use this software for any
14 purpose, including commercial applications, and to alter it and
15 redistribute it freely, subject to the following restrictions:
17 1. The origin of this software must not be misrepresented; you
18 must not claim that you wrote the original software. If you use
19 this software in a product, an acknowledgment in the product
20 documentation would be appreciated but is not required.
22 2. Altered source versions must be plainly marked as such, and
23 must not be misrepresented as being the original software.
25 3. This notice may not be removed or altered from any source
28 -------------------------------------------------------------*/
32 #include <processor.h>
35 #define _SHIFTL(v, s, w) \
36 ((u32) (((u32)(v) & ((0x01 << (w)) - 1)) << (s)))
37 #define _SHIFTR(v, s, w) \
38 ((u32)(((u32)(v) >> (s)) & ((0x01 << (w)) - 1)))
40 extern void __LCEnable();
46 _CPU_ISR_Disable(level
);
48 _CPU_ISR_Restore(level
);
51 u32
LCLoadData(void *dstAddr
,void *srcAddr
,u32 nCount
)
55 if((s32
)nCount
<=0) return 0;
58 blocks
= (cnt
+127)>>7;
61 LCLoadBlocks(dstAddr
,srcAddr
,cnt
);
65 LCLoadBlocks(dstAddr
,srcAddr
,0);
73 u32
LCStoreData(void *dstAddr
,void *srcAddr
,u32 nCount
)
77 if((s32
)nCount
<=0) return 0;
80 blocks
= (cnt
+127)>>7;
83 LCStoreBlocks(dstAddr
,srcAddr
,cnt
);
87 LCStoreBlocks(dstAddr
,srcAddr
,0);
97 u32 hid2
= mfspr(920);
98 return _SHIFTR(hid2
,4,4);
101 u32
LCQueueWait(u32 len
)
104 while(_SHIFTR(mfspr(920),4,4)>=len
);
115 void LCAlloc(void *addr
,u32 bytes
)
121 if(!(hid2
&0x10000000)) {
122 _CPU_ISR_Disable(level
);
124 _CPU_ISR_Restore(level
);
126 LCAllocTags(TRUE
,addr
,cnt
);
129 void LCAllocNoInvalidate(void *addr
,u32 bytes
)
135 if(!(hid2
&0x10000000)) {
136 _CPU_ISR_Disable(level
);
138 _CPU_ISR_Restore(level
);
140 LCAllocTags(FALSE
,addr
,cnt
);