|
Message
From: =?unknown-8bit?Q?Gy=F6rgy?= 'nog' Jeney<nog@s...>
Date: Sun May 8 16:37:08 CEST 2005
Subject: [openrisc] [or1ksim #84] Use {eval,set}_direct* functions
Hi,This patch removes all wrong uses of {set,eval}sim_* and replaces them with the correct {eval,set}_direct* functions. The breakpoint argument to the _direct* functions should be removed, it is used nowere nor does it get touched in those functions but that is the focus of another patch.
ChangeLog: * Use the {set,eval}_direct* functions where they are supposed to be used.
nog. -------------- next part -------------- diff -upr --unidirectional-new-file ./cpu/common/parse.c /home/nog/or1ksim-ac/cpu/common/parse.c --- ./cpu/common/parse.c 2005-02-10 09:56:14.000000000 +0100 +++ /home/nog/or1ksim-ac/cpu/common/parse.c 2005-04-30 10:24:41.000000000 +0200 @@ -94,6 +94,7 @@ char *strstrip (char *dst, const char *s static oraddr_t translate(oraddr_t laddr,int* breakpoint) { int i; + int brkp; /* No translation (i.e. when loading kernel into simulator) */ /* PRINTF("transl_table=%x laddr=%x\n", transl_table, laddr); @@ -103,26 +104,35 @@ static oraddr_t translate(oraddr_t laddr /* Try to find our translation in the table. */ for(i = 0; i < (MEMORY_LEN / PAGE_SIZE) * 16; i += 16) - if ((laddr & ~(PAGE_SIZE - 1)) == evalsim_mem32(transl_table + i)) { - setsim_mem32(transl_table + i + 8, -2); /* Page modified */ + if ((laddr & ~(PAGE_SIZE - 1)) == eval_direct32(transl_table + i, + &brkp, 0, 0)) { + /* Page modified */ + set_direct32(transl_table + i + 8, -2, &brkp, 0, 0); PRINTF("found paddr=%"PRIx32"\n", - evalsim_mem32(transl_table + i + 4) | (laddr & (PAGE_SIZE - 1))); - return (oraddr_t)evalsim_mem32(transl_table + i + 4) | (laddr & (oraddr_t)(PAGE_SIZE - 1)); + eval_direct32(transl_table + i + 4, &brkp, 0, 0) | + (laddr & (PAGE_SIZE - 1))); + return (oraddr_t)eval_direct32(transl_table + i + 4, &brkp, 0, 0) | + (laddr & (oraddr_t)(PAGE_SIZE - 1)); } /* Allocate new phy page for us. */ for(i = 0; i < (MEMORY_LEN / PAGE_SIZE) * 16; i += 16) - if (evalsim_mem32(transl_table + i + 8) == 0) { - setsim_mem32(transl_table + i, laddr & ~(PAGE_SIZE - 1)); /* VPN */ - setsim_mem32(transl_table + i + 4, (i/16) * PAGE_SIZE); /* PPN */ - setsim_mem32(transl_table + i + 8, -2); /* Page modified */ + if (eval_direct32(transl_table + i + 8, &brkp, 0, 0) == 0) { + /* VPN */ + set_direct32(transl_table + i, laddr & ~(PAGE_SIZE - 1), &brkp, 0, 0); + /* PPN */ + set_direct32(transl_table + i + 4, (i/16) * PAGE_SIZE, &brkp, 0, 0); + /* Page modified */ + set_direct32(transl_table + i + 8, -2, &brkp, 0, 0); PRINTF("newly allocated ppn=%"PRIx32"\n", - evalsim_mem32(transl_table + i + 4)); + eval_direct32(transl_table + i + 4, &brkp, 0, 0)); PRINTF("newly allocated .ppn=%"PRIxADDR"\n", transl_table + i + 4); PRINTF("newly allocated ofs=%"PRIxADDR"\n", (laddr & (PAGE_SIZE - 1))); PRINTF("newly allocated paddr=%"PRIx32"\n", - evalsim_mem32(transl_table + i + 4) | (laddr & (PAGE_SIZE - 1))); - return (oraddr_t)evalsim_mem32(transl_table + i + 4) | (laddr & (oraddr_t)(PAGE_SIZE - 1)); + eval_direct32(transl_table + i + 4, &brkp, 0, 0) | + (laddr & (PAGE_SIZE - 1))); + return (oraddr_t)eval_direct32(transl_table + i + 4, &brkp, 0, 0) | + (laddr & (oraddr_t)(PAGE_SIZE - 1)); } /* If we come this far then all phy memory is used and we can't find our page nor allocate new page. */ diff -upr --unidirectional-new-file ./cpu/or32/execute.c /home/nog/or1ksim-ac/cpu/or32/execute.c --- ./cpu/or32/execute.c 2005-04-27 19:39:32.000000000 +0200 +++ /home/nog/or1ksim-ac/cpu/or32/execute.c 2005-05-06 07:24:22.000000000 +0200 @@ -437,11 +437,12 @@ static inline void sbuf_load () { } /* Outputs dissasembled instruction */ -void dump_exe_log () +void dump_exe_log (void) { oraddr_t insn_addr = cpu_state.iqueue.insn_addr; unsigned int i, j; uorreg_t operand; + int breakpoint; if (insn_addr == 0xffffffff) return; if ((config.sim.exe_log_start <= runtime.cpu.instructions) && @@ -455,11 +456,12 @@ void dump_exe_log () case EXE_LOG_HARDWARE: fprintf (runtime.sim.fexe_log, "\nEXECUTED(%11llu): %"PRIxADDR": ", runtime.cpu.instructions, insn_addr); - fprintf (runtime.sim.fexe_log, "%.2x%.2x", evalsim_mem8_void(insn_addr), - evalsim_mem8_void(insn_addr + 1)); fprintf (runtime.sim.fexe_log, "%.2x%.2x", - evalsim_mem8_void(insn_addr + 2), - evalsim_mem8_void(insn_addr + 3)); + eval_direct8(insn_addr, &breakpoint, 0, 0), + eval_direct8(insn_addr + 1, &breakpoint, 0, 0)); + fprintf (runtime.sim.fexe_log, "%.2x%.2x", + eval_direct8(insn_addr + 2, &breakpoint, 0, 0), + eval_direct8(insn_addr + 3, &breakpoint, 0 ,0)); for(i = 0; i < MAX_GPRS; i++) { if (i % 4 == 0)
fprintf(runtime.sim.fexe_log, "\n");
diff -upr --unidirectional-new-file ./cuc/cuc.c /home/nog/or1ksim-ac/cuc/cuc.c
--- ./cuc/cuc.c 2005-02-25 16:56:06.000000000 +0100
+++ /home/nog/or1ksim-ac/cuc/cuc.c 2005-04-29 20:33:17.000000000 +0200
@@ -482,7 +482,8 @@ unsigned long extract_function (char *ou
assert (fo = fopen (out_fn, "wt+"));
do {
- unsigned long d = evalsim_mem32 (a);
+ int breakpoint;
+ unsigned long d = eval_direct32 (a, &breakpoint, 0, 0);
int index = insn_decode (d);
assert (index >= 0);
if (x) x++;
diff -upr --unidirectional-new-file ./peripheral/fb.c /home/nog/or1ksim-ac/peripheral/fb.c
--- ./peripheral/fb.c 2005-03-31 16:39:44.000000000 +0200
+++ /home/nog/or1ksim-ac/peripheral/fb.c 2005-05-07 19:53:17.000000000 +0200
@@ -186,10 +182,11 @@ static int fb_dump_image8 (struct fb_sta
int align = (4 - sx) % 4;
int zero = CNV32(0);
int add;
+ int breakpoint;
while (align < 0) align += 4;
for (x = 0; x < sx; x++) {
add = (fb->addr & ~(FB_WRAP - 1)) | ((fb->addr + y * sx + x) & (FB_WRAP - 1));
- fputc (evalsim_mem8 (add), fo);
+ fputc (eval_direct8 (add, &breakpoint, 0, 0), fo);
}
if (align && !fwrite (&zero, align, 1, fo)) return 1;
}
@@ -209,6 +206,8 @@ static int fb_dump_image24 (struct fb_st
unsigned short int u16;
unsigned long int u32;
+
+ int breakpoint;
if (config.sim.verbose) PRINTF ("Creating %s...", filename);
fo = fopen (filename, "wb+");
@@ -251,13 +250,13 @@ static int fb_dump_image24 (struct fb_st
for (x = 0; x < sx; x++)
if (y >= fb->cameray && x >= fb->camerax && y < fb->cameray + CAM_SIZEY && x < fb->camerax + CAM_SIZEX) {
int add = (fb->cam_addr + (x - fb->camerax + (y - fb->cameray) * CAM_SIZEX) * 2) ^ 2;
- unsigned short d = evalsim_mem16 (add);
+ unsigned short d = eval_direct16 (add, &breakpoint, 0, 0);
line[x][0] = ((d >> 0) & 0x1f) << 3; /* Blue */
line[x][1] = ((d >> 5) & 0x3f) << 2; /* Green */
line[x][2] = ((d >> 11) & 0x1f) << 3; /* Red */
} else {
int add = (fb->addr & ~(FB_WRAP - 1)) | ((fb->addr + y * sx + x) & (FB_WRAP - 1));
- unsigned short d = fb->pal[evalsim_mem8 (add)];
+ unsigned short d = fb->pal[eval_direct8 (add, &breakpoint, 0, 0)];
line[x][0] = ((d >> 0) & 0x1f) << 3; /* Blue */
line[x][1] = ((d >> 5) & 0x3f) << 2; /* Green */
line[x][2] = ((d >> 11) & 0x1f) << 3; /* Red */
diff -upr --unidirectional-new-file ./peripheral/vga.c /home/nog/or1ksim-ac/peripheral/vga.c
--- ./peripheral/vga.c 2005-04-27 19:39:34.000000000 +0200
+++ /home/nog/or1ksim-ac/peripheral/vga.c 2005-05-08 07:11:11.000000000 +0200
@@ -190,7 +186,8 @@ static int vga_dump_image (char *filenam
int align = 4 - ((bpp + 1) * sx) % 4;
int zero = 0;
for (x = 0; x < sx; x++) {
- unsigned long pixel = evalsim_mem32 (vga->vbar[vga->vbindex] + (y * sx + x) * (bpp + 1));
+ int breakpoint;
+ unsigned long pixel = eval_direct32 (vga->vbar[vga->vbindex] + (y * sx + x) * (bpp + 1), &breakpoint, 0, 0);
if (!fwrite (&pixel, sizeof (pixel), 1, fo)) return 1;
}
if (!fwrite (&zero, align, 1, fo)) return 1;
diff -upr --unidirectional-new-file ./sim-cmd.c /home/nog/or1ksim-ac/sim-cmd.c
--- ./sim-cmd.c 2005-04-27 19:39:30.000000000 +0200
+++ /home/nog/or1ksim-ac/sim-cmd.c 2005-04-29 20:24:25.000000000 +0200
@@ -93,6 +93,7 @@ extern char *disassembled;
static void debugmem( oraddr_t from, oraddr_t to )
{
int i;
+ int breakpoint;
PRINTF("starting to dump mem...\n");
for(i=from; i<to; ) {
struct label_entry *entry;
@@ -102,7 +103,7 @@ static void debugmem( oraddr_t from, ora
if (verify_memoryarea(i) && (entry = get_label(i)))
PRINTF("label: %s |", entry->name);
- insn = evalsim_mem32(i);
+ insn = eval_direct32(i, &breakpoint, 0, 0);
disassemble_insn (insn);
PRINTF("%08x %s\n", insn, disassembled);
i += 4;
@@ -263,6 +264,7 @@ static int sim_cmd_cm(int argc, char **a
{
static oraddr_t from = 0, to = 0;
static unsigned int size = 0;
+ int breakpoint;
int i;
if(argc >= 2) {
@@ -287,7 +289,8 @@ static int sim_cmd_cm(int argc, char **a
}
for(i = 0; i < size; i += 4)
- setsim_mem32(to + i, evalsim_mem32(from + i));
+ set_direct32(to + i, eval_direct32(from + i, &breakpoint, 0, 0),
+ &breakpoint, 0, 0);
return 0;
}
diff -upr --unidirectional-new-file ./support/dumpverilog.c /home/nog/or1ksim-ac/support/dumpverilog.c
--- ./support/dumpverilog.c 2005-03-31 16:39:44.000000000 +0200
+++ /home/nog/or1ksim-ac/support/dumpverilog.c 2005-04-30 10:03:52.000000000 +0200
@@ -52,12 +52,13 @@ void dumpverilog(char *verilog_modname,
unsigned int i, done = 0;
struct label_entry *tmp;
char dis[DISWIDTH + 100];
+ int breakpoint;
PRINTF("// This file was generated by or1ksim %s\n", rcsrev);
PRINTF(OR1K_MEM_VERILOG_HEADER(verilog_modname, from/DWQ, to/DWQ, (DISWIDTH*8)));
for(i = from; i < to; i++)
{
- unsigned int _insn = evalsim_mem32 (i);
+ unsigned int _insn = eval_direct32 (i, &breakpoint, 0, 0);
int index = insn_decode(_insn);
if (index >= 0)
{
@@ -65,7 +66,8 @@ void dumpverilog(char *verilog_modname,
if (tmp)
PRINTF("\n//\t%s%s", tmp->name, LABELEND_CHAR);
- PRINTF("\n\tmem['h%x] = %d'h%.8"PRIx32";", i/DWQ, DW, evalsim_mem32(i));
+ PRINTF("\n\tmem['h%x] = %d'h%.8"PRIx32";", i/DWQ, DW,
+ eval_direct32(i, &breakpoint, 0, 0));
disassemble_insn (_insn);
strcpy (dis, disassembled);
@@ -80,7 +82,8 @@ void dumpverilog(char *verilog_modname,
if (i % 64 == 0)
PRINTF("\n");
- PRINTF("\n\tmem['h%x] = 'h%.2x;", i/DWQ, evalsim_mem8(i));
+ PRINTF("\n\tmem['h%x] = 'h%.2x;", i/DWQ,
+ eval_direct8(i, &breakpoint, 0, 0));
}
done = 1;
}
@@ -99,10 +102,11 @@ void dumpverilog(char *verilog_modname,
PRINTF("\n%.8x: ", i);
/* don't print ascii chars below 0x20. */
- if (evalsim_mem32(i) < 0x20)
- PRINTF("0x%.2x ", (unsigned char)evalsim_mem32(i));
+ if (eval_direct32(i, &breakpoint, 0, 0) < 0x20)
+ PRINTF("0x%.2x ", (uint8_t)eval_direct32(i, &breakpoint, 0, 0));
else
- PRINTF("0x%.2x'%c' ", (unsigned char)evalsim_mem32(i), (unsigned char)evalsim_mem32(i));
+ PRINTF("0x%.2x'%c' ", (uint8_t)eval_direct32(i, &breakpoint, 0, 0),
+ (char)eval_direct32(i, &breakpoint, 0, 0));
}
PRINTF(OR1K_MEM_VERILOG_FOOTER);
}
@@ -110,17 +114,18 @@ void dumpverilog(char *verilog_modname,
void dumphex(unsigned int from, unsigned int to)
{
unsigned int i;
+ int breakpoint;
for(i = from; i < to; i++) {
- unsigned int _insn = evalsim_mem32 (i);
+ unsigned int _insn = eval_direct32 (i, &breakpoint, 0, 0);
int index = insn_decode(_insn);
if (index >= 0)
{
- PRINTF("%.8"PRIx32"\n", evalsim_mem32(i));
+ PRINTF("%.8"PRIx32"\n", eval_direct32(i, &breakpoint, 0, 0));
i += insn_len(index) - 1;
}
else
- PRINTF("%.2x\n", evalsim_mem8(i));
+ PRINTF("%.2x\n", eval_direct8(i, &breakpoint, 0, 0));
}
}
--- cpu/common/abstract.c 2005-03-31 16:39:39.000000000 +0200
+++ cpu/common/abstract.c 2005-05-08 14:22:07.000000000 +0200
@@ -336,35 +336,6 @@
/* Returns 32-bit values from mem array. Big endian version.
*
- * this function is only used in dumpmemory() below, so it's
- * safe to asume it's for simulator purposes access only,
- * hence the use of eval_mem32_void()
- *
- * STATISTICS OK.
- */
-static uint32_t read_mem(oraddr_t memaddr, int* breakpoint)
-{
- uint32_t temp;
-
- cur_vadd = memaddr;
- if (config.debug.enabled)
- *breakpoint += CheckDebugUnit(DebugLoadAddress,memaddr); /* 28/05/01 CZ */
- temp = evalsim_mem32_void(memaddr);
- if (!cur_area) {
- PRINTF("EXCEPTION: read out of memory (32-bit access to %"PRIxADDR")\n",
- memaddr);
- except_handle(EXCEPT_BUSERR, cur_vadd);
- temp = 0;
- } else if (cur_area->log)
- fprintf (cur_area->log, "[%"PRIxADDR"] -> read %08"PRIx32"\n", memaddr, temp);
-
- if (config.debug.enabled)
- *breakpoint += CheckDebugUnit(DebugLoadData,temp); /* MM170901 */
- return temp;
-}
-
-/* Returns 32-bit values from mem array. Big endian version.
- *
* STATISTICS OK (only used for cpu_access, that is architectural access)
*/
uint32_t eval_mem32(oraddr_t memaddr,int* breakpoint)
@@ -1008,6 +979,7 @@
oraddr_t i, j;
struct label_entry *tmp;
int ilen = disasm ? 4 : 16;
+ int breakpoint;
for(i = from; i < to; i += ilen) {
PRINTF("%"PRIxADDR": ", i);
@@ -1019,12 +991,11 @@
entry = get_label(i + j);
if (entry)
PRINTF("(%s)", entry->name);
- PRINTF("%02"PRIx8" ", evalsim_mem8(i + j));
+ PRINTF("%02"PRIx8" ", eval_direct8(i + j, &breakpoint, 0, 0));
} else PRINTF("XX ");
j++;
} else {
- int breakpoint;
- uint32_t _insn = read_mem(i, &breakpoint);
+ uint32_t _insn = eval_direct32(i, &breakpoint, 0, 0);
int index = insn_decode (_insn);
int len = insn_len (index);
|
 |