OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [tags/] [stable_0_2_0_rc3/] [or1ksim/] [mmu/] [immu.c] - Diff between revs 1538 and 1555

Go to most recent revision | Show entire file | Details | Blame | View Log

Rev 1538 Rev 1555
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(immu);
DEFAULT_DEBUG_CHANNEL(immu);
 
 
/* Insn MMU */
/* Insn MMU */
 
 
/* Precalculates some values for use during address translation */
/* Precalculates some values for use during address translation */
void init_immu(void)
void init_immu(void)
{
{
  config.immu.pagesize_log2 = log2(config.immu.pagesize);
  config.immu.pagesize_log2 = log2_int(config.immu.pagesize);
  config.immu.page_offset_mask = config.immu.pagesize - 1;
  config.immu.page_offset_mask = config.immu.pagesize - 1;
  config.immu.page_mask = ~config.immu.page_offset_mask;
  config.immu.page_mask = ~config.immu.page_offset_mask;
  config.immu.vpn_mask = ~((config.immu.pagesize * config.immu.nsets) - 1);
  config.immu.vpn_mask = ~((config.immu.pagesize * config.immu.nsets) - 1);
  config.immu.set_mask = config.immu.nsets - 1;
  config.immu.set_mask = config.immu.nsets - 1;
  config.immu.lru_reload = (config.immu.set_mask << 6) & SPR_ITLBMR_LRU;
  config.immu.lru_reload = (config.immu.set_mask << 6) & SPR_ITLBMR_LRU;
Line 284... Line 285...
void immu_nsets(union param_val val, void *dat)
void immu_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.immu.nsets = val.int_val;
    config.immu.nsets = val.int_val;
    cpu_state.sprs[SPR_IMMUCFGR] &= ~SPR_IMMUCFGR_NTS;
    cpu_state.sprs[SPR_IMMUCFGR] &= ~SPR_IMMUCFGR_NTS;
    cpu_state.sprs[SPR_IMMUCFGR] |= log2(val.int_val) << 3;
    cpu_state.sprs[SPR_IMMUCFGR] |= 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.");
}
}
 
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.