aboutsummaryrefslogtreecommitdiff
path: root/sim/common
diff options
context:
space:
mode:
authorAndrew Cagney <cagney@redhat.com>1997-05-02 08:41:15 +0000
committerAndrew Cagney <cagney@redhat.com>1997-05-02 08:41:15 +0000
commit1fe052808af59da1d2c4718efe8678cb5eabea0a (patch)
treec18c827b6be9e43f2e56c4bfd0c7a8c94cf0948d /sim/common
parent949fccf66b273ceff1a2d21b3558f24aca17f60d (diff)
downloadbinutils-1fe052808af59da1d2c4718efe8678cb5eabea0a.zip
binutils-1fe052808af59da1d2c4718efe8678cb5eabea0a.tar.gz
binutils-1fe052808af59da1d2c4718efe8678cb5eabea0a.tar.bz2
Update devo version of m32r sim to build with recent sim/common changes.
Diffstat (limited to 'sim/common')
-rw-r--r--sim/common/ChangeLog71
-rw-r--r--sim/common/cgen-utils.c7
-rw-r--r--sim/common/sim-core.c32
-rw-r--r--sim/common/sim-n-core.h96
4 files changed, 159 insertions, 47 deletions
diff --git a/sim/common/ChangeLog b/sim/common/ChangeLog
index 925db91..6ffc2b2 100644
--- a/sim/common/ChangeLog
+++ b/sim/common/ChangeLog
@@ -1,3 +1,74 @@
+Fri May 2 17:59:42 1997 Andrew Cagney <cagney@b1.cygnus.com>
+
+ * sim-core.c (sim_core_map_to_str): New function ascii equivalent
+ to map type.
+
+ * sim-n-core.h (sim_core_read_N, sim_core_write_N): Use in trace
+ statement.
+
+Fri May 2 17:28:02 1997 Andrew Cagney <cagney@b2.cygnus.com>
+
+ * cgen-trace.c: Prepend additional trace_printf argument.
+
+ * cgen-utils.c (sim_disassemble_insn): Add additional core
+ arguments.
+
+Fri May 2 11:40:23 1997 Andrew Cagney <cagney@b1.cygnus.com>
+
+ * nrun.c (main): Catch/report errorenous simulator states.
+
+ * sim-module.c: #include "libiberty.h" so that xmalloc is defined.
+ * sim-trace.c: #include string.h/strings.h so that memset is
+ defined.
+ * sim-utils.c: Ditto.
+ * sim-profile.c: Ditto. And stdlib.h.
+ (print_bar): Only define when used by instruction or memory profiler.
+
+ * sim-options.c (standard_option_handler): Make ul more local.
+
+ * sim-load.c (sim_load_file): Make the name constant.
+ (sim_load_file): Passify gcc.
+
+ * sim-utils.h: New file, pre-declare utilites in corresponding .c
+ file.
+ * sim-utils.c, sim-load.c: Include sim-utils.h.
+
+ * sim-base.h (sim_cpu): Pre define here so available to all.
+
+ * sim-core.h (DECLARE_SIM_CORE_WRITE_N, DECLARE_SIM_CORE_READ_N):
+ Restore the sim_cpu and instruction_address arguments so that full
+ information is available to the abort function.
+ * sim-core.c (sim_core_find_mapping, sim_core_write_buffer): Ditto.
+ * sim-n-core.h (sim_core_write_N, sim_core_read_N): Update.
+
+ * sim-trace.h, sim-trace.c (trace_option_handler): Add interim
+ tracing support for sim-events and sim-core.
+ (trace_option_handler): Convert #if to if where possible so always
+ compiled/checked by C compiler.
+ * sim-n-core.h (sim_core_write_N, sim_core_read_N): Update.
+
+ * sim-base.h: Adjust comment documenting how to define the cpu
+ structure.
+ (sim_state_base): Add sim_core and sim_events to simulator base
+ object.
+
+ * sim-trace.h, sim-trace.c (trace_printf): Add SIM_DESC argument.
+ * sim-core.c (sim_core_init, sim_core_attach,
+ sim_core_find_mapping): Update.
+ * sim-events.c (ETRACE, sim_events_init, sim_events_time,
+ update_time_from_event, insert_sim_event,
+ sim_events_schedule_after_signal, sim_events_deschedule,
+ sim_events_tick): Ditto.
+
+ * sim-basics.h (sim-module.h, sim-trace.h, sim-profile.h,
+ sim-model.h): Move #includes from here.
+ * sim-base.h: To here.
+ (sim-core.h, sim-events.h, sim-io.h): Include also
+
+Wed Apr 30 15:37:54 1997 Andrew Cagney <cagney@b1.cygnus.com>
+
+ * callback.c (default_callback): Missing initialisers.
+
Thu May 1 10:40:47 1997 Doug Evans <dje@canuck.cygnus.com>
* sim-utils.c (sim_add_commas): New function.
diff --git a/sim/common/cgen-utils.c b/sim/common/cgen-utils.c
index d8e57bf..6aa9107 100644
--- a/sim/common/cgen-utils.c
+++ b/sim/common/cgen-utils.c
@@ -19,6 +19,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#include "sim-main.h"
+#include <signal.h>
#include "dis-asm.h"
#include "cpu-opc.h"
#include "decode.h"
@@ -237,13 +238,13 @@ sim_disassemble_insn (SIM_CPU *cpu, const struct cgen_insn *insn,
switch (abuf->length)
{
case 1 :
- insn_value = sim_core_read_1 (CPU_STATE (cpu), sim_core_read_map, pc);
+ insn_value = sim_core_read_1 (CPU_STATE (cpu), sim_core_read_map, pc, NULL, NULL_CIA);
break;
case 2 :
- insn_value = sim_core_read_2 (CPU_STATE (cpu), sim_core_read_map, pc);
+ insn_value = sim_core_read_2 (CPU_STATE (cpu), sim_core_read_map, pc, NULL, NULL_CIA);
break;
case 4 :
- insn_value = sim_core_read_4 (CPU_STATE (cpu), sim_core_read_map, pc);
+ insn_value = sim_core_read_4 (CPU_STATE (cpu), sim_core_read_map, pc, NULL, NULL_CIA);
break;
default:
abort ();
diff --git a/sim/common/sim-core.c b/sim/common/sim-core.c
index 7e41bd9..0268131 100644
--- a/sim/common/sim-core.c
+++ b/sim/common/sim-core.c
@@ -54,7 +54,7 @@ EXTERN_SIM_CORE\
(SIM_RC)
sim_core_init (SIM_DESC sd)
{
- sim_core *memory = &sd->core;
+ sim_core *memory = STATE_CORE(sd);
sim_core_maps map;
for (map = 0;
map < nr_sim_core_maps;
@@ -78,6 +78,20 @@ sim_core_init (SIM_DESC sd)
STATIC_INLINE_SIM_CORE\
+(const char *)
+sim_core_map_to_str (sim_core_maps map)
+{
+ switch (map)
+ {
+ case sim_core_read_map: return "read";
+ case sim_core_write_map: return "write";
+ case sim_core_execute_map: return "exec";
+ default: return "(invalid-map)";
+ }
+}
+
+
+STATIC_INLINE_SIM_CORE\
(sim_core_mapping *)
new_sim_core_mapping(SIM_DESC sd,
attach_type attach,
@@ -186,7 +200,7 @@ sim_core_attach(SIM_DESC sd,
device *client,
void *optional_buffer)
{
- sim_core *memory = &sd->core;
+ sim_core *memory = STATE_CORE(sd);
sim_core_maps map;
void *buffer;
int buffer_freed;
@@ -265,9 +279,11 @@ sim_core_find_mapping(SIM_DESC sd,
sim_core_maps map,
unsigned_word addr,
unsigned nr_bytes,
- int abort) /*either 0 or 1 - helps inline */
+ int abort, /*either 0 or 1 - helps inline */
+ sim_cpu *cpu,
+ sim_cia cia)
{
- sim_core_mapping *mapping = sd->core.map[map].first;
+ sim_core_mapping *mapping = STATE_CORE (sd)->map[map].first;
SIM_ASSERT((addr & (nr_bytes - 1)) == 0); /* must be aligned */
SIM_ASSERT((addr + (nr_bytes - 1)) >= addr); /* must not wrap */
while (mapping != NULL) {
@@ -277,8 +293,8 @@ sim_core_find_mapping(SIM_DESC sd,
mapping = mapping->next;
}
if (abort)
- sim_io_error (sd, "access to unmaped address 0x%x (%d bytes)\n",
- addr, nr_bytes);
+ sim_io_error (sd, "access to unmaped address 0x%lx (%d bytes)\n",
+ (unsigned long) addr, nr_bytes);
return NULL;
}
@@ -306,7 +322,7 @@ sim_core_read_buffer(SIM_DESC sd,
sim_core_mapping *mapping =
sim_core_find_mapping(sd, map,
raddr, 1,
- 0); /*dont-abort*/
+ 0, NULL, NULL_CIA); /*dont-abort*/
if (mapping == NULL)
break;
#if (WITH_DEVICES)
@@ -347,7 +363,7 @@ sim_core_write_buffer(SIM_DESC sd,
unsigned_word raddr = addr + count;
sim_core_mapping *mapping = sim_core_find_mapping(sd, map,
raddr, 1,
- 0); /*dont-abort*/
+ 0, NULL, NULL_CIA); /*dont-abort*/
if (mapping == NULL)
break;
#if (WITH_DEVICES)
diff --git a/sim/common/sim-n-core.h b/sim/common/sim-n-core.h
index 1bcb722..35e6e72 100644
--- a/sim/common/sim-n-core.h
+++ b/sim/common/sim-n-core.h
@@ -23,67 +23,91 @@
#error "N must be #defined"
#endif
+#include "sim-xcat.h"
+
/* NOTE: see end of file for #undef of these macros */
#define unsigned_N XCONCAT2(unsigned_,N)
#define T2H_N XCONCAT2(T2H_,N)
#define H2T_N XCONCAT2(H2T_,N)
-#define core_map_read_N XCONCAT2(core_map_read_,N)
-#define core_map_write_N XCONCAT2(core_map_write_,N)
+#define sim_core_read_N XCONCAT2(sim_core_read_,N)
+#define sim_core_write_N XCONCAT2(sim_core_write_,N)
INLINE_SIM_CORE(unsigned_N)
-core_map_read_N(engine *system,
- core_maps map,
- unsigned_word addr)
+sim_core_read_N(SIM_DESC sd,
+ sim_core_maps map,
+ unsigned_word addr,
+ sim_cpu *cpu,
+ sim_cia cia)
{
- core_mapping *mapping = core_map_find_mapping(system, map,
- addr,
- sizeof(unsigned_N),
- 1); /*abort*/
+ unsigned_N val;
+ sim_core_mapping *mapping = sim_core_find_mapping (sd, map,
+ addr,
+ sizeof (unsigned_N),
+ 1,
+ cpu, cia); /*abort*/
#if (WITH_DEVICES)
if (WITH_CALLBACK_MEMORY && mapping->device != NULL) {
unsigned_N data;
- if (device_io_read_buffer(mapping->device,
- &data,
- mapping->space,
- addr,
- sizeof(unsigned_N)) != sizeof(unsigned_N))
- device_error(mapping->device, "internal error - core_read_N() - io_read_buffer should not fail");
- return T2H_N(data);
+ if (device_io_read_buffer (mapping->device,
+ &data,
+ mapping->space,
+ addr,
+ sizeof (unsigned_N)) != sizeof (unsigned_N))
+ device_error (mapping->device, "internal error - sim_core_read_N() - io_read_buffer should not fail");
+ val = T2H_N (data);
}
else
#endif
- return T2H_N(*(unsigned_N*)core_translate(mapping, addr));
+ val = T2H_N (*(unsigned_N*) sim_core_translate (mapping, addr));
+ if (STATE_CORE (sd)->trace)
+ trace_printf (sd, cpu, "sim-n-core.c:%d: read-%d %s:0x%08lx -> 0x%lx\n",
+ __LINE__,
+ sizeof (unsigned_N),
+ sim_core_map_to_str (map),
+ (unsigned long) addr,
+ (unsigned long) val);
+ return val;
}
INLINE_SIM_CORE(void)
-core_map_write_N(engine *system,
- core_maps map,
+sim_core_write_N(SIM_DESC sd,
+ sim_core_maps map,
unsigned_word addr,
- unsigned_N val)
+ unsigned_N val,
+ sim_cpu *cpu,
+ sim_cia cia)
{
- core_mapping *mapping = core_map_find_mapping(system, map,
- addr,
- sizeof(unsigned_N),
- 1); /*abort*/
+ sim_core_mapping *mapping = sim_core_find_mapping(sd, map,
+ addr,
+ sizeof (unsigned_N),
+ 1,
+ cpu, cia); /*abort*/
#if (WITH_DEVICES)
if (WITH_CALLBACK_MEMORY && mapping->device != NULL) {
- unsigned_N data = H2T_N(val);
- if (device_io_write_buffer(mapping->device,
- &data,
- mapping->space,
- addr,
- sizeof(unsigned_N), /* nr_bytes */
- processor,
- cia) != sizeof(unsigned_N))
- device_error(mapping->device, "internal error - core_write_N() - io_write_buffer should not fail");
+ unsigned_N data = H2T_N (val);
+ if (device_io_write_buffer (mapping->device,
+ &data,
+ mapping->space,
+ addr,
+ sizeof (unsigned_N), /* nr_bytes */
+ cpu,
+ cia) != sizeof (unsigned_N))
+ device_error (mapping->device, "internal error - sim_core_write_N() - io_write_buffer should not fail");
}
else
#endif
- *(unsigned_N*)core_translate(mapping, addr) = H2T_N(val);
+ *(unsigned_N*) sim_core_translate (mapping, addr) = H2T_N (val);
+ if (STATE_CORE (sd)->trace)
+ trace_printf (sd, cpu, "sim-n-core.c:%d: write-%d %s:0x%08lx <- 0x%lx\n",
+ __LINE__,
+ sizeof (unsigned_N),
+ sim_core_map_to_str (map),
+ (unsigned long) addr,
+ (unsigned long) val);
}
@@ -91,5 +115,5 @@ core_map_write_N(engine *system,
#undef unsigned_N
#undef T2H_N
#undef H2T_N
-#undef core_map_read_N
-#undef core_map_write_N
+#undef sim_core_read_N
+#undef sim_core_write_N