aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2016-01-21 22:46:34 -0500
committerMike Frysinger <vapier@gentoo.org>2021-05-17 01:01:08 -0400
commit2ad10cb22246b16fdebece06646db288dbea1fdb (patch)
tree22d99c218a7685a319099c0b5b5ba50fe353007a
parent8ea7241cf3f46e9164c5ef75611bb2442350c934 (diff)
downloadgdb-2ad10cb22246b16fdebece06646db288dbea1fdb.zip
gdb-2ad10cb22246b16fdebece06646db288dbea1fdb.tar.gz
gdb-2ad10cb22246b16fdebece06646db288dbea1fdb.tar.bz2
sim: h8300: invert sim_state storage
-rw-r--r--sim/h8300/ChangeLog16
-rw-r--r--sim/h8300/compile.c19
-rw-r--r--sim/h8300/sim-main.h8
3 files changed, 32 insertions, 11 deletions
diff --git a/sim/h8300/ChangeLog b/sim/h8300/ChangeLog
index dfbaecb..8ddbb54 100644
--- a/sim/h8300/ChangeLog
+++ b/sim/h8300/ChangeLog
@@ -1,3 +1,19 @@
+2021-05-17 Mike Frysinger <vapier@gentoo.org>
+
+ * compile.c (h8_get_state): Change sd to H8300_SIM_STATE.
+ (h8_set_state): Likewise.
+ (h8_get_stats): Likewise.
+ (h8_increment_stats): Likewise.
+ (init_pointers): Likewise.
+ (step_once): Likewise.
+ (sim_info): Likewise.
+ (sim_open): Likewise.
+ (sim_load): Likewise.
+ * sim-main.h (SIM_HAVE_COMMON_SIM_STATE): Define.
+ (struct sim_state): Delete.
+ (struct h8300_sim_state): New struct.
+ (H8300_SIM_STATE): Define.
+
2021-05-16 Mike Frysinger <vapier@gentoo.org>
* compile.c: Replace config.h include with defs.h.
diff --git a/sim/h8300/compile.c b/sim/h8300/compile.c
index 2ac6dd0..a45a676 100644
--- a/sim/h8300/compile.c
+++ b/sim/h8300/compile.c
@@ -139,13 +139,13 @@ h8_set_exception (SIM_DESC sd, int val)
static enum h8300_sim_state
h8_get_state (SIM_DESC sd)
{
- return sd -> state;
+ return H8300_SIM_STATE (sd)->state;
}
static void
h8_set_state (SIM_DESC sd, enum h8300_sim_state val)
{
- sd -> state = val;
+ H8300_SIM_STATE (sd)->state = val;
}
#endif
static unsigned int
@@ -230,13 +230,13 @@ h8_set_reg (SIM_DESC sd, int regnum, int val)
static int
h8_get_stats (SIM_DESC sd, int idx)
{
- return sd -> stats[idx];
+ return H8300_SIM_STATE (sd)->stats[idx];
}
static void
h8_increment_stats (SIM_DESC sd, int idx)
{
- sd -> stats[idx] ++;
+ H8300_SIM_STATE (sd)->stats[idx] ++;
}
#endif /* ADEBUG */
@@ -1612,6 +1612,8 @@ static int init_pointers_needed = 1;
static void
init_pointers (SIM_DESC sd)
{
+ struct h8300_sim_state *state = H8300_SIM_STATE (sd);
+
if (init_pointers_needed)
{
int i;
@@ -1637,7 +1639,7 @@ init_pointers (SIM_DESC sd)
h8_set_memory_buf (sd, (unsigned char *)
calloc (sizeof (char), memory_size));
- sd->memory_size = memory_size;
+ state->memory_size = memory_size;
h8_set_mask (sd, memory_size - 1);
@@ -1723,6 +1725,7 @@ step_once (SIM_DESC sd, SIM_CPU *cpu)
int trace = 0;
int intMask = 0;
int oldmask;
+ const struct h8300_sim_state *state = H8300_SIM_STATE (sd);
host_callback *sim_callback = STATE_CALLBACK (sd);
init_pointers (sd);
@@ -4529,6 +4532,7 @@ h8300_reg_fetch (SIM_CPU *cpu, int rn, unsigned char *buf, int length)
void
sim_info (SIM_DESC sd, int verbose)
{
+ const struct h8300_sim_state *state = H8300_SIM_STATE (sd);
double timetaken = (double) h8_get_ticks (sd) / (double) now_persec ();
double virttime = h8_get_cycles (sd) / 10.0e6;
@@ -4661,7 +4665,7 @@ sim_open (SIM_OPEN_KIND kind,
SIM_DESC sd;
sim_cpu *cpu;
- sd = sim_state_alloc (kind, callback);
+ sd = sim_state_alloc_extra (kind, callback, sizeof (struct h8300_sim_state));
/* The cpu data is kept in a separately allocated chunk of memory. */
if (sim_cpu_alloc_all (sd, 1) != SIM_RC_OK)
@@ -4745,6 +4749,7 @@ sim_open (SIM_OPEN_KIND kind,
SIM_RC
sim_load (SIM_DESC sd, const char *prog, bfd *abfd, int from_tty)
{
+ struct h8300_sim_state *state = H8300_SIM_STATE (sd);
bfd *prog_bfd;
/* FIXME: The code below that sets a specific variant of the H8/300
@@ -4794,7 +4799,7 @@ sim_load (SIM_DESC sd, const char *prog, bfd *abfd, int from_tty)
h8_set_memory_buf (sd, (unsigned char *)
calloc (sizeof (char), memory_size));
- sd->memory_size = memory_size;
+ state->memory_size = memory_size;
/* `msize' must be a power of two. */
if ((memory_size & (memory_size - 1)) != 0)
diff --git a/sim/h8300/sim-main.h b/sim/h8300/sim-main.h
index 68e44ae..57ff307 100644
--- a/sim/h8300/sim-main.h
+++ b/sim/h8300/sim-main.h
@@ -5,6 +5,8 @@
#ifndef SIM_MAIN_H
#define SIM_MAIN_H
+#define SIM_HAVE_COMMON_SIM_STATE
+
#define DEBUG
/* These define the size of main memory for the simulator.
@@ -130,15 +132,13 @@ struct _sim_cpu {
sim_cpu_base base;
};
-/* The sim_state struct. */
-struct sim_state {
- sim_cpu *cpu[MAX_NR_PROCESSORS];
+struct h8300_sim_state {
unsigned long memory_size;
#ifdef ADEBUG
int stats[O_LAST];
#endif
- sim_state_base base;
};
+#define H8300_SIM_STATE(sd) ((struct h8300_sim_state *) STATE_ARCH_DATA (sd))
/* The current state of the processor; registers, memory, etc. */