Line 38... |
Line 38... |
#include "stats.h"
|
#include "stats.h"
|
#include "except.h"
|
#include "except.h"
|
#include "debug_unit.h"
|
#include "debug_unit.h"
|
#include "opcode/or32.h"
|
#include "opcode/or32.h"
|
#include "support/profile.h"
|
#include "support/profile.h"
|
|
#include "dmmu.h"
|
|
#include "dcache_model.h"
|
|
#include "icache_model.h"
|
|
#include "debug.h"
|
|
|
extern unsigned long reg[];
|
extern unsigned long reg[];
|
extern char *disassembled;
|
extern char *disassembled;
|
|
|
/* This is an abstract+physical memory array rather than only physical
|
/* This is an abstract+physical memory array rather than only physical
|
Line 91... |
Line 95... |
for(pptmp = &dev_list; *pptmp; pptmp = &(*pptmp)->next)
|
for(pptmp = &dev_list; *pptmp; pptmp = &(*pptmp)->next)
|
if ((addr_compare >= (*pptmp)->addr_compare) && (addr_compare < (*pptmp)->addr_compare + (*pptmp)->size)
|
if ((addr_compare >= (*pptmp)->addr_compare) && (addr_compare < (*pptmp)->addr_compare + (*pptmp)->size)
|
|| (addr_compare + size > (*pptmp)->addr_compare) && (addr_compare < (*pptmp)->addr_compare + (*pptmp)->size)) {
|
|| (addr_compare + size > (*pptmp)->addr_compare) && (addr_compare < (*pptmp)->addr_compare + (*pptmp)->size)) {
|
if (!found_error) {
|
if (!found_error) {
|
fprintf (stderr, "ERROR: Overlapping memory area(s):\n");
|
fprintf (stderr, "ERROR: Overlapping memory area(s):\n");
|
fprintf (stderr, "\taddr & %08x == %08x to %08x, size %08x, gran %iB\n", addr_mask, addr_compare, addr_compare | bit_mask (size), size, granularity);
|
fprintf (stderr, "\taddr & %08lx == %08lx to %08lx, size %08lx, gran %iB\n",
|
|
addr_mask, addr_compare, addr_compare | bit_mask (size), size,
|
|
granularity);
|
}
|
}
|
found_error = 1;
|
found_error = 1;
|
fprintf (stderr, "and\taddr & %08x == %08x to %08x, size %08x, gran %iB\n", (*pptmp)->addr_mask, (*pptmp)->addr_compare,
|
fprintf (stderr, "and\taddr & %08lx == %08lx to %08lx, size %08lx, gran %liB\n",
|
(*pptmp)->addr_compare | (*pptmp)->size_mask, (*pptmp)->size, (*pptmp)->granularity);
|
(*pptmp)->addr_mask, (*pptmp)->addr_compare,
|
|
(*pptmp)->addr_compare | (*pptmp)->size_mask,
|
|
(*pptmp)->size, (*pptmp)->granularity);
|
}
|
}
|
|
|
if (found_error)
|
if (found_error)
|
exit (-1);
|
exit (-1);
|
|
|
Line 261... |
Line 269... |
|
|
/* Returns 32-bit values from mem array. Big endian version. */
|
/* Returns 32-bit values from mem array. Big endian version. */
|
unsigned long read_mem(unsigned long memaddr,int* breakpoint)
|
unsigned long read_mem(unsigned long memaddr,int* breakpoint)
|
{
|
{
|
unsigned long temp;
|
unsigned long temp;
|
struct dev_memarea *dev;
|
|
|
|
cur_vadd = memaddr;
|
cur_vadd = 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 */
|
temp = evalsim_mem32(memaddr);
|
temp = evalsim_mem32(memaddr);
|
Line 274... |
Line 281... |
except_handle(EXCEPT_BUSERR, cur_vadd);
|
except_handle(EXCEPT_BUSERR, cur_vadd);
|
temp = 0;
|
temp = 0;
|
}
|
}
|
|
|
if (!pending.valid && cur_area->log)
|
if (!pending.valid && cur_area->log)
|
fprintf (cur_area->log, "[%08x] -> read %08x\n", memaddr, temp);
|
fprintf (cur_area->log, "[%08lx] -> read %08lx\n", memaddr, temp);
|
if (config.debug.enabled)
|
if (config.debug.enabled)
|
*breakpoint += CheckDebugUnit(DebugLoadData,temp); /* MM170901 */
|
*breakpoint += CheckDebugUnit(DebugLoadData,temp); /* MM170901 */
|
return temp;
|
return temp;
|
}
|
}
|
|
|
/* Returns 32-bit values from mem array. Big endian version. */
|
/* Returns 32-bit values from mem array. Big endian version. */
|
unsigned long eval_mem32(unsigned long memaddr,int* breakpoint)
|
unsigned long eval_mem32(unsigned long memaddr,int* breakpoint)
|
{
|
{
|
|
|
unsigned long temp;
|
unsigned long temp;
|
struct dev_memarea *dev;
|
|
|
|
if (config.sim.mprofile)
|
if (config.sim.mprofile)
|
mprofile (memaddr, MPROF_32 | MPROF_READ);
|
mprofile (memaddr, MPROF_32 | MPROF_READ);
|
|
|
if (memaddr & 3) {
|
if (memaddr & 3) {
|
Line 354... |
Line 360... |
|
|
/* Returns 32-bit values from mem array. Big endian version. */
|
/* Returns 32-bit values from mem array. Big endian version. */
|
unsigned long eval_insn(unsigned long memaddr,int* breakpoint)
|
unsigned long eval_insn(unsigned long memaddr,int* breakpoint)
|
{
|
{
|
unsigned long temp;
|
unsigned long temp;
|
struct dev_memarea *dev;
|
|
|
|
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;
|
Line 513... |
Line 518... |
PRINTF("EXCEPTION: read out of memory (8-bit access to %.8lx) in eval_direct8()\n", memaddr);
|
PRINTF("EXCEPTION: read out of memory (8-bit access to %.8lx) in eval_direct8()\n", memaddr);
|
except_handle(EXCEPT_BUSERR, cur_vadd);
|
except_handle(EXCEPT_BUSERR, cur_vadd);
|
temp = 0;
|
temp = 0;
|
}
|
}
|
}
|
}
|
|
return temp;
|
}
|
}
|
|
|
|
|
void setsim_mem32(unsigned long memaddr, unsigned long value)
|
void setsim_mem32(unsigned long memaddr, unsigned long value)
|
{
|
{
|
struct dev_memarea *dev;
|
|
|
|
if (verify_memoryarea(memaddr)) {
|
if (verify_memoryarea(memaddr)) {
|
switch(cur_area->granularity) {
|
switch(cur_area->granularity) {
|
case 4:
|
case 4:
|
cur_area->writefunc(memaddr, value);
|
cur_area->writefunc(memaddr, value);
|
runtime.sim.mem_cycles += cur_area->delayw;
|
runtime.sim.mem_cycles += cur_area->delayw;
|
Line 626... |
Line 630... |
}
|
}
|
|
|
dc_simulate_write(memaddr, value, 4);
|
dc_simulate_write(memaddr, value, 4);
|
|
|
if (cur_area && cur_area->log)
|
if (cur_area && cur_area->log)
|
fprintf (cur_area->log, "[%08x] -> write %08x\n", memaddr, value);
|
fprintf (cur_area->log, "[%08lx] -> write %08lx\n", memaddr, value);
|
}
|
}
|
|
|
void set_direct32(unsigned long memaddr, unsigned long value,int* breakpoint,
|
void set_direct32(unsigned long memaddr, unsigned long value,int* breakpoint,
|
int through_mmu, int through_dc)
|
int through_mmu, int through_dc)
|
{
|
{
|
Line 654... |
Line 658... |
* just fine anyway
|
* just fine anyway
|
*/
|
*/
|
dc_simulate_write(memaddr, value, 4);
|
dc_simulate_write(memaddr, value, 4);
|
|
|
if (cur_area && cur_area->log)
|
if (cur_area && cur_area->log)
|
fprintf (cur_area->log, "[%08x] -> write %08x\n", memaddr, value);
|
fprintf (cur_area->log, "[%08lx] -> write %08lx\n", memaddr, value);
|
}
|
}
|
|
|
|
|
/* Set mem, 16-bit. Big endian version. */
|
/* Set mem, 16-bit. Big endian version. */
|
|
|
Line 684... |
Line 688... |
}
|
}
|
|
|
dc_simulate_write(memaddr, (unsigned long)value, 2);
|
dc_simulate_write(memaddr, (unsigned long)value, 2);
|
|
|
if (cur_area && cur_area->log)
|
if (cur_area && cur_area->log)
|
fprintf (cur_area->log, "[%08x] -> write %08x\n", memaddr, value);
|
fprintf (cur_area->log, "[%08lx] -> write %08x\n", memaddr, value);
|
}
|
}
|
|
|
void set_direct16(unsigned long memaddr, unsigned short value, int* breakpoint,
|
void set_direct16(unsigned long memaddr, unsigned short value, int* breakpoint,
|
int through_mmu, int through_dc)
|
int through_mmu, int through_dc)
|
{
|
{
|
Line 711... |
Line 715... |
* just fine anyway
|
* just fine anyway
|
*/
|
*/
|
dc_simulate_write(memaddr, value, 2);
|
dc_simulate_write(memaddr, value, 2);
|
|
|
if (cur_area && cur_area->log)
|
if (cur_area && cur_area->log)
|
fprintf (cur_area->log, "[%08x] -> write %08x\n", memaddr, value);
|
fprintf (cur_area->log, "[%08lx] -> write %08x\n", memaddr, value);
|
}
|
}
|
|
|
/* 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)
|
Line 734... |
Line 738... |
}
|
}
|
|
|
dc_simulate_write(memaddr, (unsigned long)value, 1);
|
dc_simulate_write(memaddr, (unsigned long)value, 1);
|
|
|
if (cur_area && cur_area->log)
|
if (cur_area && cur_area->log)
|
fprintf (cur_area->log, "[%08x] -> write %08x\n", memaddr, value);
|
fprintf (cur_area->log, "[%08lx] -> write %08x\n", memaddr, value);
|
}
|
}
|
|
|
void set_direct8(unsigned long memaddr, unsigned char value, int* breakpoint,
|
void set_direct8(unsigned long memaddr, unsigned char value, int* breakpoint,
|
int through_mmu, int through_dc)
|
int through_mmu, int through_dc)
|
{
|
{
|
Line 770... |
Line 774... |
|
|
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;
|
struct label_entry *tmp;
|
struct label_entry *tmp;
|
int breakpoint = 0;
|
|
int ilen = disasm ? 4 : 16;
|
int ilen = disasm ? 4 : 16;
|
|
|
for(i = from; i < to; i += ilen) {
|
for(i = from; i < to; i += ilen) {
|
PRINTF("%.8x: ", i);
|
PRINTF("%.8x: ", i);
|
for (j = 0; j < ilen;) {
|
for (j = 0; j < ilen;) {
|
Line 800... |
Line 803... |
struct label_entry *entry;
|
struct label_entry *entry;
|
entry = get_label(i + j);
|
entry = get_label(i + j);
|
if (entry)
|
if (entry)
|
PRINTF("(%s)", entry->name);
|
PRINTF("(%s)", entry->name);
|
|
|
PRINTF(": %08x ", (unsigned long)_insn);
|
PRINTF(": %08lx ", (unsigned long)_insn);
|
if (index >= 0) {
|
if (index >= 0) {
|
disassemble_insn (_insn);
|
disassemble_insn (_insn);
|
PRINTF(" %s", disassembled);
|
PRINTF(" %s", disassembled);
|
} else
|
} else
|
PRINTF("<invalid>");
|
PRINTF("<invalid>");
|
Line 831... |
Line 834... |
return 0;
|
return 0;
|
}
|
}
|
|
|
void simmem_write_null(unsigned long addr, unsigned long value) {
|
void simmem_write_null(unsigned long addr, unsigned long value) {
|
if (config.sim.verbose)
|
if (config.sim.verbose)
|
fprintf (stderr, "WARNING: memory write to 0x%08x, non-write memory area (value 0x%08x).\n", addr, value);
|
fprintf (stderr, "WARNING: memory write to 0x%08lx, non-write memory area (value 0x%08lx).\n", addr, value);
|
}
|
}
|
|
|
/* Initialize memory table from a config struct */
|
/* Initialize memory table from a config struct */
|
|
|
void init_memory_table ()
|
void init_memory_table ()
|
Line 930... |
Line 933... |
{
|
{
|
struct dev_memarea *ptmp;
|
struct dev_memarea *ptmp;
|
|
|
/* Check list of registered devices. */
|
/* Check list of registered devices. */
|
for(ptmp = dev_list; ptmp; ptmp = ptmp->next) {
|
for(ptmp = dev_list; ptmp; ptmp = ptmp->next) {
|
PRINTF ("addr & %08x == %08x to %08x, size %08x, gran %iB\n",
|
PRINTF ("addr & %08lx == %08lx to %08lx, size %08lx, gran %liB\n",
|
ptmp->addr_mask, ptmp->addr_compare, ptmp->addr_compare | bit_mask (ptmp->size),
|
ptmp->addr_mask, ptmp->addr_compare, ptmp->addr_compare | bit_mask (ptmp->size),
|
ptmp->size, ptmp->granularity);
|
ptmp->size, ptmp->granularity);
|
PRINTF ("\t");
|
PRINTF ("\t");
|
if (ptmp->delayr >= 0)
|
if (ptmp->delayr >= 0)
|
PRINTF ("read delay = %i cycles, ", ptmp->delayr);
|
PRINTF ("read delay = %i cycles, ", ptmp->delayr);
|
Line 962... |
Line 965... |
while ((time_ps % 1000) == 0) {
|
while ((time_ps % 1000) == 0) {
|
time_ps /= 1000;
|
time_ps /= 1000;
|
exp3++;
|
exp3++;
|
}
|
}
|
}
|
}
|
sprintf (dest, "%i%cs", time_ps, "pnum"[exp3]);
|
sprintf (dest, "%li%cs", time_ps, "pnum"[exp3]);
|
return dest;
|
return dest;
|
}
|
}
|
|
|
No newline at end of file
|
No newline at end of file
|