#include <sys/param.h>
#include <sys/systm.h>
#include <sh/cache.h>
#include <sh/cache_sh3.h>
#include <sh/cache_sh4.h>
static void __cache_flush(void);
struct sh_cache_ops sh_cache_ops = {
._icache_sync_all = (void (*)(void))__cache_flush,
._icache_sync_range = (void (*)(vaddr_t, vsize_t))__cache_flush,
._icache_sync_range_index = (void (*)(vaddr_t, vsize_t))__cache_flush,
._dcache_wbinv_all = (void (*)(void))__cache_flush,
._dcache_wbinv_range = (void (*)(vaddr_t, vsize_t))__cache_flush,
._dcache_wbinv_range_index = (void (*)(vaddr_t, vsize_t))__cache_flush,
._dcache_inv_range = (void (*)(vaddr_t, vsize_t))__cache_flush,
._dcache_wb_range = (void (*)(vaddr_t, vsize_t))__cache_flush
};
int sh_cache_enable_icache;
int sh_cache_enable_dcache;
int sh_cache_write_through;
int sh_cache_write_through_p0_u0_p3;
int sh_cache_write_through_p1;
int sh_cache_unified;
int sh_cache_ways;
int sh_cache_size_icache;
int sh_cache_size_dcache;
int sh_cache_line_size;
int sh_cache_ram_mode;
int sh_cache_index_mode_icache;
int sh_cache_index_mode_dcache;
int sh_cache_prefer_mask;
void
sh_cache_init(void)
{
#ifdef CACHE_DEBUG
return;
#endif
#ifdef SH3
if (CPU_IS_SH3)
sh3_cache_config();
#endif
#ifdef SH4
if (CPU_IS_SH4)
sh4_cache_config();
#endif
}
void
sh_cache_information(void)
{
#ifdef CACHE_DEBUG
printf("*** USE CPU INDEPENDENT CACHE OPS. ***\n");
return;
#endif
printf("cpu0: %dKB/%dB",
sh_cache_size_icache >> 10, sh_cache_line_size);
if (sh_cache_ways > 1)
printf(" %d-way associative", sh_cache_ways);
else
printf(" direct");
if (sh_cache_unified)
printf(" I/D-");
else
printf(" I-");
printf("cache");
if (!sh_cache_enable_icache)
printf(" DISABLED");
if (sh_cache_unified && sh_cache_ram_mode)
printf(" RAM-mode");
if (sh_cache_index_mode_icache)
printf(" INDEX-mode");
if (!sh_cache_unified) {
printf(", %dKB/%dB", sh_cache_size_dcache >> 10,
sh_cache_line_size);
if (sh_cache_ways > 1)
printf(" %d-way associative", sh_cache_ways);
else
printf(" direct");
printf(" D-cache");
if (!sh_cache_enable_dcache)
printf(" DISABLED");
if (sh_cache_ram_mode)
printf(" RAM-mode");
if (sh_cache_index_mode_dcache)
printf(" INDEX-mode");
}
printf("\n");
#ifdef CACHE_DEBUG
printf("cpu0: P0, U0, P3 write-%s; P1 write-%s\n",
sh_cache_write_through_p0_u0_p3 ? "through" : "back",
sh_cache_write_through_p1 ? "through" : "back");
#endif
}
void
__cache_flush(void)
{
volatile int *p = (int *)SH3_PHYS_TO_P1SEG(IOM_RAM_BEGIN);
int i;
int d;
for (i = 0; i < 256 * 4; i++) {
d = *p;
p += 4;
}
}