Line 35... |
Line 35... |
#include "stats.h"
|
#include "stats.h"
|
#include "sprs.h"
|
#include "sprs.h"
|
#include "except.h"
|
#include "except.h"
|
#include "sim-config.h"
|
#include "sim-config.h"
|
#include "debug.h"
|
#include "debug.h"
|
|
#include "misc.h"
|
|
|
DEFAULT_DEBUG_CHANNEL(dmmu);
|
DEFAULT_DEBUG_CHANNEL(dmmu);
|
|
|
/* Data MMU */
|
/* Data MMU */
|
|
|
/* Precalculates some values for use during address translation */
|
/* Precalculates some values for use during address translation */
|
void init_dmmu(void)
|
void init_dmmu(void)
|
{
|
{
|
config.dmmu.pagesize_log2 = log2(config.dmmu.pagesize);
|
config.dmmu.pagesize_log2 = log2_int(config.dmmu.pagesize);
|
config.dmmu.page_offset_mask = config.dmmu.pagesize - 1;
|
config.dmmu.page_offset_mask = config.dmmu.pagesize - 1;
|
config.dmmu.page_mask = ~config.dmmu.page_offset_mask;
|
config.dmmu.page_mask = ~config.dmmu.page_offset_mask;
|
config.dmmu.vpn_mask = ~((config.dmmu.pagesize * config.dmmu.nsets) - 1);
|
config.dmmu.vpn_mask = ~((config.dmmu.pagesize * config.dmmu.nsets) - 1);
|
config.dmmu.set_mask = config.dmmu.nsets - 1;
|
config.dmmu.set_mask = config.dmmu.nsets - 1;
|
config.dmmu.lru_reload = (config.dmmu.set_mask << 6) & SPR_DTLBMR_LRU;
|
config.dmmu.lru_reload = (config.dmmu.set_mask << 6) & SPR_DTLBMR_LRU;
|
Line 309... |
Line 310... |
void dmmu_nsets(union param_val val, void *dat)
|
void dmmu_nsets(union param_val val, void *dat)
|
{
|
{
|
if (is_power2(val.int_val) && val.int_val <= 256) {
|
if (is_power2(val.int_val) && val.int_val <= 256) {
|
config.dmmu.nsets = val.int_val;
|
config.dmmu.nsets = val.int_val;
|
cpu_state.sprs[SPR_DMMUCFGR] &= ~SPR_DMMUCFGR_NTS;
|
cpu_state.sprs[SPR_DMMUCFGR] &= ~SPR_DMMUCFGR_NTS;
|
cpu_state.sprs[SPR_DMMUCFGR] |= log2(val.int_val) << 3;
|
cpu_state.sprs[SPR_DMMUCFGR] |= log2_int(val.int_val) << 3;
|
} else
|
} else
|
CONFIG_ERROR("value of power of two and lower or equal than 256 expected.");
|
CONFIG_ERROR("value of power of two and lower or equal than 256 expected.");
|
}
|
}
|
|
|
void dmmu_nways(union param_val val, void *dat)
|
void dmmu_nways(union param_val val, void *dat)
|