URL
https://opencores.org/ocsvn/altor32/altor32/trunk
[/] [altor32/] [trunk/] [sw/] [common/] [cache.c] - Blame information for rev 42
Details |
Compare with Previous |
View Log
Line No. |
Rev |
Author |
Line |
1 |
42 |
ultra_embe |
#include "cache.h"
|
2 |
|
|
|
3 |
|
|
//-----------------------------------------------------------------
|
4 |
|
|
// Defines:
|
5 |
|
|
//-----------------------------------------------------------------
|
6 |
|
|
// SR Register
|
7 |
|
|
#define SPR_SR (17)
|
8 |
|
|
#define SPR_SR_ICACHE_FLUSH (1 << 17)
|
9 |
|
|
#define SPR_SR_DCACHE_FLUSH (1 << 18)
|
10 |
|
|
|
11 |
|
|
//-----------------------------------------------------------------
|
12 |
|
|
// mfspr: Read from SPR
|
13 |
|
|
//-----------------------------------------------------------------
|
14 |
|
|
static inline unsigned long mfspr(unsigned long spr)
|
15 |
|
|
{
|
16 |
|
|
unsigned long value;
|
17 |
|
|
asm volatile ("l.mfspr\t\t%0,%1,0" : "=r" (value) : "r" (spr));
|
18 |
|
|
return value;
|
19 |
|
|
}
|
20 |
|
|
//-----------------------------------------------------------------
|
21 |
|
|
// mtspr: Write to SPR
|
22 |
|
|
//-----------------------------------------------------------------
|
23 |
|
|
static inline void mtspr(unsigned long spr, unsigned long value)
|
24 |
|
|
{
|
25 |
|
|
asm volatile ("l.mtspr\t\t%0,%1,0": : "r" (spr), "r" (value));
|
26 |
|
|
}
|
27 |
|
|
//-----------------------------------------------------------------
|
28 |
|
|
// cache_dflush:
|
29 |
|
|
//-----------------------------------------------------------------
|
30 |
|
|
void cache_dflush(void)
|
31 |
|
|
{
|
32 |
|
|
unsigned long sr = mfspr(SPR_SR);
|
33 |
|
|
mtspr(SPR_SR, sr | SPR_SR_DCACHE_FLUSH);
|
34 |
|
|
}
|
35 |
|
|
//-----------------------------------------------------------------
|
36 |
|
|
// cache_iflush:
|
37 |
|
|
//-----------------------------------------------------------------
|
38 |
|
|
void cache_iflush(void)
|
39 |
|
|
{
|
40 |
|
|
unsigned long sr = mfspr(SPR_SR);
|
41 |
|
|
mtspr(SPR_SR, sr | SPR_SR_ICACHE_FLUSH);
|
42 |
|
|
}
|
43 |
|
|
//-----------------------------------------------------------------
|
44 |
|
|
// cache_flush:
|
45 |
|
|
//-----------------------------------------------------------------
|
46 |
|
|
void cache_flush(void)
|
47 |
|
|
{
|
48 |
|
|
unsigned long sr = mfspr(SPR_SR);
|
49 |
|
|
mtspr(SPR_SR, sr | SPR_SR_ICACHE_FLUSH | SPR_SR_DCACHE_FLUSH);
|
50 |
|
|
}
|
© copyright 1999-2025
OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.