Line 59... |
Line 59... |
unsigned long cur_vadd;
|
unsigned long cur_vadd;
|
|
|
/* Temporary variable, which specifies how many cycles did the memory acces require */
|
/* Temporary variable, which specifies how many cycles did the memory acces require */
|
extern int mem_cycles;
|
extern int mem_cycles;
|
|
|
/* It returns physical address. */
|
|
inline unsigned long translate_vrt_to_phy_add(unsigned long virtaddr, int write_access)
|
|
{
|
|
if (config.ic.tagtype == CT_NONE)
|
|
return immu_translate(virtaddr, write_access);
|
|
else
|
|
if (config.ic.tagtype == CT_VIRTUAL) {
|
|
return immu_translate(virtaddr, write_access);
|
|
}
|
|
else if (config.dc.tagtype == CT_PHYSICAL) {
|
|
unsigned long phyaddr = immu_translate(virtaddr, write_access);
|
|
return phyaddr;
|
|
}
|
|
else {
|
|
printf("INTERNAL ERROR: Unknown insn cache type.\n");
|
|
cont_run = 0;
|
|
}
|
|
|
|
return -1;
|
|
}
|
|
|
|
/* Calls IMMU translation routines before simulating insn
|
|
cache for virtually indexed insn cache or after simulating insn cache
|
|
for physically indexed insn cache. It returns physical address. */
|
|
|
|
static inline unsigned long simulate_ic_mmu_fetch(unsigned long virtaddr)
|
|
{
|
|
|
|
unsigned long phyaddr;
|
|
|
|
if ((phyaddr = translate_vrt_to_phy_add(virtaddr, 0)) != -1) {
|
|
ic_simulate_fetch(phyaddr);
|
|
return phyaddr;
|
|
}
|
|
else {
|
|
printf("INTERNAL ERROR: Unknown insn cache type.\n");
|
|
cont_run = 0;
|
|
}
|
|
return -1;
|
|
}
|
|
|
|
/* Calls DMMU translation routines (load cycles) before simulating data
|
|
cache for virtually indexed data cache or after simulating data cache
|
|
for physically indexed data cache. It returns physical address. */
|
|
|
|
static inline unsigned long simulate_dc_mmu_load(unsigned long virtaddr)
|
|
{
|
|
if (config.dc.tagtype == CT_NONE)
|
|
return dmmu_translate(virtaddr, 0);
|
|
else
|
|
if (config.dc.tagtype == CT_VIRTUAL) {
|
|
dc_simulate_read(virtaddr);
|
|
return dmmu_translate(virtaddr, 0);
|
|
}
|
|
else if (config.dc.tagtype == CT_PHYSICAL) {
|
|
unsigned long phyaddr = dmmu_translate(virtaddr, 0);
|
|
dc_simulate_read(phyaddr);
|
|
return phyaddr;
|
|
}
|
|
else {
|
|
printf("INTERNAL ERROR: Unknown data cache type.\n");
|
|
cont_run = 0;
|
|
}
|
|
|
|
return -1;
|
|
}
|
|
|
|
/* Calls DMMU translation routines (store cycles) before simulating data
|
|
cache for virtually indexed data cache or after simulating data cache
|
|
for physically indexed data cache. It returns physical address. */
|
|
|
|
static inline unsigned long simulate_dc_mmu_store(unsigned long virtaddr)
|
|
{
|
|
if (config.dc.tagtype == CT_NONE)
|
|
return dmmu_translate(virtaddr, 0);
|
|
else
|
|
if (config.dc.tagtype == CT_VIRTUAL) {
|
|
dc_simulate_write(virtaddr);
|
|
return dmmu_translate(virtaddr, 1);
|
|
}
|
|
else if (config.dc.tagtype == CT_PHYSICAL) {
|
|
unsigned long phyaddr = dmmu_translate(virtaddr, 1);
|
|
dc_simulate_write(phyaddr);
|
|
return phyaddr;
|
|
}
|
|
else {
|
|
printf("INTERNAL ERROR: Unknown data cache type.\n");
|
|
cont_run = 0;
|
|
}
|
|
|
|
return -1;
|
|
}
|
|
|
|
/* Calculates bit mask to fit the data */
|
/* Calculates bit mask to fit the data */
|
unsigned long bit_mask (unsigned long data) {
|
unsigned long bit_mask (unsigned long data) {
|
int i = 0;
|
int i = 0;
|
data--;
|
data--;
|
while (data >> i)
|
while (data >> i)
|
Line 363... |
Line 270... |
if (memaddr & 3) {
|
if (memaddr & 3) {
|
except_handle (EXCEPT_ALIGN, memaddr);
|
except_handle (EXCEPT_ALIGN, memaddr);
|
return 0;
|
return 0;
|
}
|
}
|
|
|
|
if (config.debug.enabled)
|
|
*breakpoint += CheckDebugUnit(DebugLoadAddress,memaddr); /* 28/05/01 CZ */
|
|
|
cur_vadd = memaddr;
|
cur_vadd = memaddr;
|
memaddr = simulate_dc_mmu_load(memaddr);
|
|
|
memaddr = dmmu_translate(memaddr, 0);
|
if (pending.valid)
|
if (pending.valid)
|
return 0;
|
return 0;
|
|
|
if (config.debug.enabled)
|
temp = dc_simulate_read(memaddr, 4);
|
*breakpoint += CheckDebugUnit(DebugLoadAddress,memaddr); /* 28/05/01 CZ */
|
|
temp = evalsim_mem32(memaddr);
|
|
if (!cur_area) {
|
if (!cur_area) {
|
printf("EXCEPTION: read out of memory (32-bit access to %.8lx)\n", memaddr);
|
printf("EXCEPTION: read out of memory (32-bit access to %.8lx)\n", memaddr);
|
except_handle(EXCEPT_BUSERR, cur_vadd);
|
except_handle(EXCEPT_BUSERR, cur_vadd);
|
temp = 0;
|
temp = 0;
|
}
|
}
|
Line 394... |
Line 303... |
|
|
if (config.sim.mprofile)
|
if (config.sim.mprofile)
|
mprofile (memaddr, MPROF_32 | MPROF_FETCH);
|
mprofile (memaddr, MPROF_32 | MPROF_FETCH);
|
// memaddr = simulate_ic_mmu_fetch(memaddr);
|
// memaddr = simulate_ic_mmu_fetch(memaddr);
|
cur_vadd = pc;
|
cur_vadd = pc;
|
IFF (config.ic.enabled) ic_simulate_fetch(memaddr);
|
|
if (config.debug.enabled)
|
if (config.debug.enabled)
|
*breakpoint += CheckDebugUnit(DebugLoadAddress,memaddr); /* 28/05/01 CZ */
|
*breakpoint += CheckDebugUnit(DebugLoadAddress,memaddr); /* 28/05/01 CZ */
|
|
if (config.ic.enabled)
|
|
temp = ic_simulate_fetch(memaddr);
|
|
else
|
temp = evalsim_mem32(memaddr);
|
temp = evalsim_mem32(memaddr);
|
if (!cur_area) {
|
if (!cur_area) {
|
printf("EXCEPTION: read out of memory (32-bit access to %.8lx)\n", memaddr);
|
printf("EXCEPTION: read out of memory (32-bit access to %.8lx)\n", memaddr);
|
except_handle(EXCEPT_BUSERR, cur_vadd);
|
except_handle(EXCEPT_BUSERR, cur_vadd);
|
temp = 0;
|
temp = 0;
|
Line 425... |
Line 336... |
if (memaddr & 1) {
|
if (memaddr & 1) {
|
except_handle (EXCEPT_ALIGN, memaddr);
|
except_handle (EXCEPT_ALIGN, memaddr);
|
return 0;
|
return 0;
|
}
|
}
|
|
|
|
if (config.debug.enabled)
|
|
*breakpoint += CheckDebugUnit(DebugLoadAddress,memaddr); /* 28/05/01 CZ */
|
|
|
cur_vadd = memaddr;
|
cur_vadd = memaddr;
|
memaddr = simulate_dc_mmu_load(memaddr);
|
|
|
memaddr = dmmu_translate(memaddr, 0);
|
if (pending.valid)
|
if (pending.valid)
|
return 0;
|
return 0;
|
|
|
if (config.debug.enabled)
|
temp = (unsigned short)dc_simulate_read(memaddr, 2);
|
*breakpoint += CheckDebugUnit(DebugLoadAddress,memaddr); /* 28/05/01 CZ */
|
|
|
|
temp = evalsim_mem16(memaddr);
|
|
if (!cur_area) {
|
if (!cur_area) {
|
printf("EXCEPTION: read out of memory (16-bit access to %.8lx)\n", memaddr);
|
printf("EXCEPTION: read out of memory (16-bit access to %.8lx)\n", memaddr);
|
except_handle(EXCEPT_BUSERR, cur_vadd);
|
except_handle(EXCEPT_BUSERR, cur_vadd);
|
temp = 0;
|
temp = 0;
|
}
|
}
|
Line 451... |
Line 363... |
|
|
/* Returns 8-bit values from mem array. */
|
/* Returns 8-bit values from mem array. */
|
|
|
unsigned char eval_mem8(unsigned long memaddr,int* breakpoint)
|
unsigned char eval_mem8(unsigned long memaddr,int* breakpoint)
|
{
|
{
|
unsigned long temp;
|
unsigned char temp;
|
|
|
if (config.sim.mprofile)
|
if (config.sim.mprofile)
|
mprofile (memaddr, MPROF_8 | MPROF_READ);
|
mprofile (memaddr, MPROF_8 | MPROF_READ);
|
|
|
|
if (config.debug.enabled)
|
|
*breakpoint += CheckDebugUnit(DebugLoadAddress,memaddr); /* 28/05/01 CZ */
|
|
|
cur_vadd = memaddr;
|
cur_vadd = memaddr;
|
memaddr = simulate_dc_mmu_load(memaddr);
|
|
|
memaddr = dmmu_translate(memaddr, 0);
|
if (pending.valid)
|
if (pending.valid)
|
return 0;
|
return 0;
|
|
|
if (config.debug.enabled)
|
temp = (unsigned char)dc_simulate_read(memaddr, 1);
|
*breakpoint += CheckDebugUnit(DebugLoadAddress,memaddr); /* 28/05/01 CZ */
|
|
|
|
temp = evalsim_mem8(memaddr);
|
|
if (!cur_area) {
|
if (!cur_area) {
|
printf("EXCEPTION: read out of memory (8-bit access to %.8lx)\n", memaddr);
|
printf("EXCEPTION: read out of memory (8-bit access to %.8lx)\n", memaddr);
|
except_handle(EXCEPT_BUSERR, cur_vadd);
|
except_handle(EXCEPT_BUSERR, cur_vadd);
|
temp = 0;
|
temp = 0;
|
}
|
}
|
Line 575... |
Line 488... |
except_handle (EXCEPT_ALIGN, memaddr);
|
except_handle (EXCEPT_ALIGN, memaddr);
|
return;
|
return;
|
}
|
}
|
|
|
cur_vadd = memaddr;
|
cur_vadd = memaddr;
|
memaddr = simulate_dc_mmu_store(memaddr);
|
memaddr = dmmu_translate(memaddr, 1);;
|
/* If we produced exception don't set anything */
|
/* If we produced exception don't set anything */
|
if (pending.valid)
|
if (pending.valid)
|
return;
|
return;
|
|
|
if (config.debug.enabled) {
|
if (config.debug.enabled) {
|
Line 588... |
Line 501... |
}
|
}
|
|
|
if (cur_area->log)
|
if (cur_area->log)
|
fprintf (cur_area->log, "[%08x] -> write %08x\n", memaddr, value);
|
fprintf (cur_area->log, "[%08x] -> write %08x\n", memaddr, value);
|
|
|
setsim_mem32(memaddr, value);
|
dc_simulate_write(memaddr, value, 4);
|
}
|
}
|
|
|
/* Set mem, 16-bit. Big endian version. */
|
/* Set mem, 16-bit. Big endian version. */
|
|
|
void set_mem16(unsigned long memaddr, unsigned short value,int* breakpoint)
|
void set_mem16(unsigned long memaddr, unsigned short value,int* breakpoint)
|
Line 604... |
Line 517... |
except_handle (EXCEPT_ALIGN, memaddr);
|
except_handle (EXCEPT_ALIGN, memaddr);
|
return;
|
return;
|
}
|
}
|
|
|
cur_vadd = memaddr;
|
cur_vadd = memaddr;
|
memaddr = simulate_dc_mmu_store(memaddr);
|
memaddr = dmmu_translate(memaddr, 1);;
|
/* If we produced exception don't set anything */
|
/* If we produced exception don't set anything */
|
if (pending.valid)
|
if (pending.valid)
|
return;
|
return;
|
|
|
if (config.debug.enabled) {
|
if (config.debug.enabled) {
|
Line 617... |
Line 530... |
}
|
}
|
|
|
if (cur_area->log)
|
if (cur_area->log)
|
fprintf (cur_area->log, "[%08x] -> write %08x\n", memaddr, value);
|
fprintf (cur_area->log, "[%08x] -> write %08x\n", memaddr, value);
|
|
|
setsim_mem16(memaddr, value);
|
dc_simulate_write(memaddr, (unsigned long)value, 2);
|
}
|
}
|
|
|
/* Set mem, 8-bit. */
|
/* Set mem, 8-bit. */
|
|
|
void set_mem8(unsigned long memaddr, unsigned char value,int* breakpoint)
|
void set_mem8(unsigned long memaddr, unsigned char value,int* breakpoint)
|
{
|
{
|
if (config.sim.mprofile)
|
if (config.sim.mprofile)
|
mprofile (memaddr, MPROF_8 | MPROF_WRITE);
|
mprofile (memaddr, MPROF_8 | MPROF_WRITE);
|
|
|
cur_vadd = memaddr;
|
cur_vadd = memaddr;
|
memaddr = simulate_dc_mmu_store(memaddr);
|
memaddr = dmmu_translate(memaddr, 1);;
|
/* If we produced exception don't set anything */
|
/* If we produced exception don't set anything */
|
if (pending.valid) return;
|
if (pending.valid) return;
|
|
|
if (config.debug.enabled) {
|
if (config.debug.enabled) {
|
*breakpoint += CheckDebugUnit(DebugStoreAddress,memaddr); /* 28/05/01 CZ */
|
*breakpoint += CheckDebugUnit(DebugStoreAddress,memaddr); /* 28/05/01 CZ */
|
Line 640... |
Line 553... |
}
|
}
|
|
|
if (cur_area->log)
|
if (cur_area->log)
|
fprintf (cur_area->log, "[%08x] -> write %08x\n", memaddr, value);
|
fprintf (cur_area->log, "[%08x] -> write %08x\n", memaddr, value);
|
|
|
setsim_mem8(memaddr, value);
|
dc_simulate_write(memaddr, (unsigned long)value, 1);
|
}
|
}
|
|
|
void dumpmemory(unsigned int from, unsigned int to, int disasm, int nl)
|
void dumpmemory(unsigned int from, unsigned int to, int disasm, int nl)
|
{
|
{
|
unsigned int i, j;
|
unsigned int i, j;
|