aboutsummaryrefslogtreecommitdiff
path: root/sim/common/sim-cpu.h
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2016-08-12 23:43:27 +0800
committerMike Frysinger <vapier@gentoo.org>2022-12-20 23:57:38 -0500
commitffeb72b44c8c5060465005178dd3a4a304117a58 (patch)
treeb44abd51ce73b4207664c3570fb0a834668aff65 /sim/common/sim-cpu.h
parentd026e67ed41a249ec758847008d8a19257bf45fc (diff)
downloadgdb-ffeb72b44c8c5060465005178dd3a4a304117a58.zip
gdb-ffeb72b44c8c5060465005178dd3a4a304117a58.tar.gz
gdb-ffeb72b44c8c5060465005178dd3a4a304117a58.tar.bz2
sim: sim_cpu: invert sim_cpu storage
Currently all ports have to declare sim_cpu themselves in their sim-main.h and then embed the common sim_cpu_base in it. This dynamic makes it impossible to share common object code among multiple ports because the core data structure is always different. Let's invert this relationship: common code declares sim_cpu, and the port uses the new arch_data field for its per-cpu state. This is the first in a series of changes: it adds a define to select between the old & new layouts, then converts all the ports that don't need custom state over to the new layout. This includes mn10300 that, while it defines custom fields in its cpu struct, never uses them.
Diffstat (limited to 'sim/common/sim-cpu.h')
-rw-r--r--sim/common/sim-cpu.h18
1 files changed, 16 insertions, 2 deletions
diff --git a/sim/common/sim-cpu.h b/sim/common/sim-cpu.h
index 4f5972b..ab41508 100644
--- a/sim/common/sim-cpu.h
+++ b/sim/common/sim-cpu.h
@@ -122,10 +122,24 @@ typedef struct {
} sim_cpu_base;
+#ifdef SIM_HAVE_COMMON_SIM_CPU
+struct _sim_cpu {
+ /* All the common state. */
+ sim_cpu_base base;
+
+ /* Pointer for sim target to store arbitrary cpu data. Normally the
+ target should define a struct and use it here. */
+ void *arch_data;
+#define CPU_ARCH_DATA(cpu) ((cpu)->arch_data)
+};
+#endif
+
/* Create all cpus. */
-extern SIM_RC sim_cpu_alloc_all (SIM_DESC, int);
+extern SIM_RC sim_cpu_alloc_all_extra (SIM_DESC, int, size_t);
+#define sim_cpu_alloc_all(state, ncpus) sim_cpu_alloc_all_extra (state, ncpus, 0)
/* Create a cpu. */
-extern sim_cpu *sim_cpu_alloc (SIM_DESC);
+extern sim_cpu *sim_cpu_alloc_extra (SIM_DESC, size_t);
+#define sim_cpu_alloc(sd) sim_cpu_alloc_extra (sd, 0)
/* Release resources held by all cpus. */
extern void sim_cpu_free_all (SIM_DESC);
/* Release resources held by a cpu. */