MIPS/resources/soft/perf_func/lib/cache.c
Paul Pan 7b33e4213a a big update
1. add test soft
2. modify verilator (TODO: crossbar need to replace)
3. fix CP0: now CU0 is always 1
4. Controller: cacheop
5. Controller: fix TEN
6. mycpu_top fix CP0_i
7. fix AXI.sv
8. fix AXIReader.sv
9. fix AXIWriter.sv: getting the correct data and length
10. MU: fix cache writeback, fix mem data mux, fix writer address, fix read request
2022-07-29 18:25:58 +08:00

50 lines
1.1 KiB
C

#include <asm/r4kcache.h>
int dcache_size = 0x4000;
int icache_size = 0x4000;
#define cpu_dcache_line_size() 32
void dma_cache_wback_inv(unsigned long addr, unsigned long size)
{
/*
* Either no secondary cache or the available caches don't have the
* subset property so we have to flush the primary caches
* explicitly
*/
if (size >= dcache_size) {
blast_dcache32();
} else {
blast_dcache_range(addr, addr + size);
}
}
void dma_cache_inv(unsigned long addr, unsigned long size)
{
if (size >= dcache_size) {
blast_dcache32();
} else {
unsigned long lsize = cpu_dcache_line_size();
unsigned long almask = ~(lsize - 1);
cache_op(Hit_Writeback_Inv_D, addr & almask);
cache_op(Hit_Writeback_Inv_D, (addr + size - 1) & almask);
blast_inv_dcache_range(addr, addr + size);
}
}
void flush_icache_range(unsigned long start, unsigned long end)
{
if (end - start >= dcache_size) {
blast_dcache32();
} else {
protected_blast_dcache_range(start, end);
}
if (end - start > icache_size)
blast_icache32();
else
protected_blast_icache_range(start, end);
}