aboutsummaryrefslogtreecommitdiff
path: root/sim
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2022-12-25 00:53:25 -0500
committerMike Frysinger <vapier@gentoo.org>2022-12-25 02:10:46 -0500
commit883be197745c9a9ea626cf0671e8bb0109d21a36 (patch)
tree0c19d5fa5fb39952a439f495c29c32e5ea777738 /sim
parentsim: msp430: add basic SMP cpu init (diff)
downloadbinutils-gdb-883be197745c9a9ea626cf0671e8bb0109d21a36.tar.gz
binutils-gdb-883be197745c9a9ea626cf0671e8bb0109d21a36.tar.bz2
binutils-gdb-883be197745c9a9ea626cf0671e8bb0109d21a36.zip
sim: cpu: change default init to handle all cpus
All the runtimes were only initializing a single CPU. When SMP is enabled, things quickly crash as none of the other CPU structs are setup. Change the default from 0 to the compile time value.
Diffstat (limited to 'sim')
-rw-r--r--sim/aarch64/interp.c2
-rw-r--r--sim/arm/wrapper.c2
-rw-r--r--sim/avr/interp.c2
-rw-r--r--sim/bfin/interp.c2
-rw-r--r--sim/bpf/sim-if.c2
-rw-r--r--sim/common/sim-cpu.c5
-rw-r--r--sim/cr16/interp.c2
-rw-r--r--sim/cris/sim-if.c2
-rw-r--r--sim/d10v/interp.c2
-rw-r--r--sim/example-synacor/interp.c2
-rw-r--r--sim/frv/sim-if.c2
-rw-r--r--sim/ft32/interp.c2
-rw-r--r--sim/h8300/compile.c2
-rw-r--r--sim/iq2000/sim-if.c2
-rw-r--r--sim/lm32/sim-if.c2
-rw-r--r--sim/m32r/sim-if.c2
-rw-r--r--sim/m68hc11/interp.c2
-rw-r--r--sim/mcore/interp.c2
-rw-r--r--sim/microblaze/interp.c2
-rw-r--r--sim/mips/interp.c2
-rw-r--r--sim/mn10300/interp.c2
-rw-r--r--sim/moxie/interp.c2
-rw-r--r--sim/msp430/msp430-sim.c2
-rw-r--r--sim/or1k/sim-if.c2
-rw-r--r--sim/pru/interp.c2
-rw-r--r--sim/riscv/interp.c2
-rw-r--r--sim/sh/interp.c2
-rw-r--r--sim/v850/interp.c2
28 files changed, 32 insertions, 27 deletions
diff --git a/sim/aarch64/interp.c b/sim/aarch64/interp.c
index 234d978a768..03efb42e6b5 100644
--- a/sim/aarch64/interp.c
+++ b/sim/aarch64/interp.c
@@ -348,7 +348,7 @@ sim_open (SIM_OPEN_KIND kind,
current_alignment = NONSTRICT_ALIGNMENT;
/* Perform the initialization steps one by one. */
- if (sim_cpu_alloc_all_extra (sd, 1, sizeof (struct aarch64_sim_cpu))
+ if (sim_cpu_alloc_all_extra (sd, 0, sizeof (struct aarch64_sim_cpu))
!= SIM_RC_OK
|| sim_pre_argv_init (sd, argv[0]) != SIM_RC_OK
|| sim_parse_args (sd, argv) != SIM_RC_OK
diff --git a/sim/arm/wrapper.c b/sim/arm/wrapper.c
index 5eb61df1437..4e800780454 100644
--- a/sim/arm/wrapper.c
+++ b/sim/arm/wrapper.c
@@ -822,7 +822,7 @@ sim_open (SIM_OPEN_KIND kind,
current_alignment = STRICT_ALIGNMENT;
/* The cpu data is kept in a separately allocated chunk of memory. */
- if (sim_cpu_alloc_all (sd, 1) != SIM_RC_OK)
+ if (sim_cpu_alloc_all (sd, 0) != SIM_RC_OK)
{
free_state (sd);
return 0;
diff --git a/sim/avr/interp.c b/sim/avr/interp.c
index ddd9e1ff1ea..27834f15dbc 100644
--- a/sim/avr/interp.c
+++ b/sim/avr/interp.c
@@ -1703,7 +1703,7 @@ sim_open (SIM_OPEN_KIND kind, host_callback *cb,
current_target_byte_order = BFD_ENDIAN_LITTLE;
/* The cpu data is kept in a separately allocated chunk of memory. */
- if (sim_cpu_alloc_all_extra (sd, 1, sizeof (struct avr_sim_cpu))
+ if (sim_cpu_alloc_all_extra (sd, 0, sizeof (struct avr_sim_cpu))
!= SIM_RC_OK)
{
free_state (sd);
diff --git a/sim/bfin/interp.c b/sim/bfin/interp.c
index 04c1773eaf4..e904506bf22 100644
--- a/sim/bfin/interp.c
+++ b/sim/bfin/interp.c
@@ -675,7 +675,7 @@ sim_open (SIM_OPEN_KIND kind, host_callback *callback,
current_target_byte_order = BFD_ENDIAN_LITTLE;
/* The cpu data is kept in a separately allocated chunk of memory. */
- if (sim_cpu_alloc_all_extra (sd, 1, sizeof (struct bfin_cpu_state))
+ if (sim_cpu_alloc_all_extra (sd, 0, sizeof (struct bfin_cpu_state))
!= SIM_RC_OK)
{
free_state (sd);
diff --git a/sim/bpf/sim-if.c b/sim/bpf/sim-if.c
index b29300f0328..4c9aa83232a 100644
--- a/sim/bpf/sim-if.c
+++ b/sim/bpf/sim-if.c
@@ -132,7 +132,7 @@ sim_open (SIM_OPEN_KIND kind,
STATE_MACHS (sd) = bpf_sim_machs;
STATE_MODEL_NAME (sd) = "bpf-def";
- if (sim_cpu_alloc_all_extra (sd, 1, sizeof (struct bpf_sim_cpu)) != SIM_RC_OK)
+ if (sim_cpu_alloc_all_extra (sd, 0, sizeof (struct bpf_sim_cpu)) != SIM_RC_OK)
goto error;
if (sim_pre_argv_init (sd, argv[0]) != SIM_RC_OK)
diff --git a/sim/common/sim-cpu.c b/sim/common/sim-cpu.c
index 024bd050ab3..9f64d9d06e8 100644
--- a/sim/common/sim-cpu.c
+++ b/sim/common/sim-cpu.c
@@ -35,8 +35,13 @@ sim_cpu_alloc_all_extra (SIM_DESC sd, int ncpus, size_t extra_bytes)
{
int c;
+ /* TODO: This should be a command line option for users to control. */
+ if (ncpus == 0)
+ ncpus = MAX_NR_PROCESSORS;
+
for (c = 0; c < ncpus; ++c)
STATE_CPU (sd, c) = sim_cpu_alloc_extra (sd, extra_bytes);
+
return SIM_RC_OK;
}
diff --git a/sim/cr16/interp.c b/sim/cr16/interp.c
index 1830e348a06..fe1e24bed68 100644
--- a/sim/cr16/interp.c
+++ b/sim/cr16/interp.c
@@ -407,7 +407,7 @@ sim_open (SIM_OPEN_KIND kind, struct host_callback_struct *cb,
cb->syscall_map = cb_cr16_syscall_map;
/* The cpu data is kept in a separately allocated chunk of memory. */
- if (sim_cpu_alloc_all (sd, 1) != SIM_RC_OK)
+ if (sim_cpu_alloc_all (sd, 0) != SIM_RC_OK)
{
free_state (sd);
return 0;
diff --git a/sim/cris/sim-if.c b/sim/cris/sim-if.c
index 47862edf4f5..d939854e32d 100644
--- a/sim/cris/sim-if.c
+++ b/sim/cris/sim-if.c
@@ -670,7 +670,7 @@ sim_open (SIM_OPEN_KIND kind, host_callback *callback, struct bfd *abfd,
current_target_byte_order = BFD_ENDIAN_LITTLE;
/* The cpu data is kept in a separately allocated chunk of memory. */
- if (sim_cpu_alloc_all_extra (sd, 1, sizeof (struct cris_sim_cpu))
+ if (sim_cpu_alloc_all_extra (sd, 0, sizeof (struct cris_sim_cpu))
!= SIM_RC_OK)
{
free_state (sd);
diff --git a/sim/d10v/interp.c b/sim/d10v/interp.c
index 9beedf8f445..aebd98ab6ac 100644
--- a/sim/d10v/interp.c
+++ b/sim/d10v/interp.c
@@ -765,7 +765,7 @@ sim_open (SIM_OPEN_KIND kind, host_callback *cb,
cb->syscall_map = cb_d10v_syscall_map;
/* The cpu data is kept in a separately allocated chunk of memory. */
- if (sim_cpu_alloc_all (sd, 1) != SIM_RC_OK)
+ if (sim_cpu_alloc_all (sd, 0) != SIM_RC_OK)
{
free_state (sd);
return 0;
diff --git a/sim/example-synacor/interp.c b/sim/example-synacor/interp.c
index 20ae057d43a..25e519d9f2a 100644
--- a/sim/example-synacor/interp.c
+++ b/sim/example-synacor/interp.c
@@ -90,7 +90,7 @@ sim_open (SIM_OPEN_KIND kind, host_callback *callback,
current_target_byte_order = BFD_ENDIAN_LITTLE;
/* The cpu data is kept in a separately allocated chunk of memory. */
- if (sim_cpu_alloc_all_extra (sd, 1, sizeof (struct example_sim_cpu))
+ if (sim_cpu_alloc_all_extra (sd, 0, sizeof (struct example_sim_cpu))
!= SIM_RC_OK)
{
free_state (sd);
diff --git a/sim/frv/sim-if.c b/sim/frv/sim-if.c
index 6e0f1bbaba6..ad94423f40b 100644
--- a/sim/frv/sim-if.c
+++ b/sim/frv/sim-if.c
@@ -65,7 +65,7 @@ sim_open (SIM_OPEN_KIND kind, host_callback *callback, bfd *abfd,
current_target_byte_order = BFD_ENDIAN_BIG;
/* The cpu data is kept in a separately allocated chunk of memory. */
- if (sim_cpu_alloc_all_extra (sd, 1, sizeof (struct frv_sim_cpu)) != SIM_RC_OK)
+ if (sim_cpu_alloc_all_extra (sd, 0, sizeof (struct frv_sim_cpu)) != SIM_RC_OK)
{
free_state (sd);
return 0;
diff --git a/sim/ft32/interp.c b/sim/ft32/interp.c
index dfea4720c22..1eda9a7a286 100644
--- a/sim/ft32/interp.c
+++ b/sim/ft32/interp.c
@@ -823,7 +823,7 @@ sim_open (SIM_OPEN_KIND kind,
current_target_byte_order = BFD_ENDIAN_LITTLE;
/* The cpu data is kept in a separately allocated chunk of memory. */
- if (sim_cpu_alloc_all_extra (sd, 1, sizeof (struct ft32_cpu_state))
+ if (sim_cpu_alloc_all_extra (sd, 0, sizeof (struct ft32_cpu_state))
!= SIM_RC_OK)
{
free_state (sd);
diff --git a/sim/h8300/compile.c b/sim/h8300/compile.c
index cc8b52c5d65..467eeafde61 100644
--- a/sim/h8300/compile.c
+++ b/sim/h8300/compile.c
@@ -4631,7 +4631,7 @@ sim_open (SIM_OPEN_KIND kind,
current_target_byte_order = BFD_ENDIAN_BIG;
/* The cpu data is kept in a separately allocated chunk of memory. */
- if (sim_cpu_alloc_all_extra (sd, 1, sizeof (struct h8300_sim_cpu))
+ if (sim_cpu_alloc_all_extra (sd, 0, sizeof (struct h8300_sim_cpu))
!= SIM_RC_OK)
{
free_state (sd);
diff --git a/sim/iq2000/sim-if.c b/sim/iq2000/sim-if.c
index e9b66b6a7ef..e02a413103e 100644
--- a/sim/iq2000/sim-if.c
+++ b/sim/iq2000/sim-if.c
@@ -70,7 +70,7 @@ sim_open (SIM_OPEN_KIND kind, host_callback *callback, struct bfd *abfd,
current_target_byte_order = BFD_ENDIAN_BIG;
/* The cpu data is kept in a separately allocated chunk of memory. */
- if (sim_cpu_alloc_all_extra (sd, 1, sizeof (struct iq2000_sim_cpu))
+ if (sim_cpu_alloc_all_extra (sd, 0, sizeof (struct iq2000_sim_cpu))
!= SIM_RC_OK)
{
free_state (sd);
diff --git a/sim/lm32/sim-if.c b/sim/lm32/sim-if.c
index 82f2e117671..b5102805512 100644
--- a/sim/lm32/sim-if.c
+++ b/sim/lm32/sim-if.c
@@ -101,7 +101,7 @@ sim_open (SIM_OPEN_KIND kind, host_callback *callback, struct bfd *abfd,
current_target_byte_order = BFD_ENDIAN_BIG;
/* The cpu data is kept in a separately allocated chunk of memory. */
- if (sim_cpu_alloc_all_extra (sd, 1, sizeof (struct lm32_sim_cpu))
+ if (sim_cpu_alloc_all_extra (sd, 0, sizeof (struct lm32_sim_cpu))
!= SIM_RC_OK)
{
free_state (sd);
diff --git a/sim/m32r/sim-if.c b/sim/m32r/sim-if.c
index 7fe6b42801e..1305ea6d102 100644
--- a/sim/m32r/sim-if.c
+++ b/sim/m32r/sim-if.c
@@ -68,7 +68,7 @@ sim_open (SIM_OPEN_KIND kind, host_callback *callback, struct bfd *abfd,
current_target_byte_order = BFD_ENDIAN_BIG;
/* The cpu data is kept in a separately allocated chunk of memory. */
- if (sim_cpu_alloc_all_extra (sd, 1, sizeof (struct m32r_sim_cpu))
+ if (sim_cpu_alloc_all_extra (sd, 0, sizeof (struct m32r_sim_cpu))
!= SIM_RC_OK)
{
free_state (sd);
diff --git a/sim/m68hc11/interp.c b/sim/m68hc11/interp.c
index b80f5cb82bb..82155213330 100644
--- a/sim/m68hc11/interp.c
+++ b/sim/m68hc11/interp.c
@@ -422,7 +422,7 @@ sim_open (SIM_OPEN_KIND kind, host_callback *callback,
current_target_byte_order = BFD_ENDIAN_BIG;
/* The cpu data is kept in a separately allocated chunk of memory. */
- if (sim_cpu_alloc_all_extra (sd, 1, sizeof (struct m68hc11_sim_cpu))
+ if (sim_cpu_alloc_all_extra (sd, 0, sizeof (struct m68hc11_sim_cpu))
!= SIM_RC_OK)
{
free_state (sd);
diff --git a/sim/mcore/interp.c b/sim/mcore/interp.c
index 84b243f0705..ae554c77d31 100644
--- a/sim/mcore/interp.c
+++ b/sim/mcore/interp.c
@@ -1370,7 +1370,7 @@ sim_open (SIM_OPEN_KIND kind, host_callback *cb,
cb->syscall_map = cb_mcore_syscall_map;
/* The cpu data is kept in a separately allocated chunk of memory. */
- if (sim_cpu_alloc_all_extra (sd, 1, sizeof (struct mcore_sim_cpu))
+ if (sim_cpu_alloc_all_extra (sd, 0, sizeof (struct mcore_sim_cpu))
!= SIM_RC_OK)
{
free_state (sd);
diff --git a/sim/microblaze/interp.c b/sim/microblaze/interp.c
index 8a8cb9f2b83..df7f41fcff5 100644
--- a/sim/microblaze/interp.c
+++ b/sim/microblaze/interp.c
@@ -410,7 +410,7 @@ sim_open (SIM_OPEN_KIND kind, host_callback *cb,
SIM_ASSERT (STATE_MAGIC (sd) == SIM_MAGIC_NUMBER);
/* The cpu data is kept in a separately allocated chunk of memory. */
- if (sim_cpu_alloc_all_extra (sd, 1, sizeof (struct microblaze_regset))
+ if (sim_cpu_alloc_all_extra (sd, 0, sizeof (struct microblaze_regset))
!= SIM_RC_OK)
{
free_state (sd);
diff --git a/sim/mips/interp.c b/sim/mips/interp.c
index fa192d36f2e..d44c474ae1d 100644
--- a/sim/mips/interp.c
+++ b/sim/mips/interp.c
@@ -351,7 +351,7 @@ sim_open (SIM_OPEN_KIND kind, host_callback *cb,
SIM_ASSERT (STATE_MAGIC (sd) == SIM_MAGIC_NUMBER);
/* The cpu data is kept in a separately allocated chunk of memory. */
- if (sim_cpu_alloc_all_extra (sd, 1, sizeof (struct mips_sim_cpu))
+ if (sim_cpu_alloc_all_extra (sd, 0, sizeof (struct mips_sim_cpu))
!= SIM_RC_OK)
return 0;
diff --git a/sim/mn10300/interp.c b/sim/mn10300/interp.c
index 8467070addb..2915551253f 100644
--- a/sim/mn10300/interp.c
+++ b/sim/mn10300/interp.c
@@ -97,7 +97,7 @@ sim_open (SIM_OPEN_KIND kind,
current_target_byte_order = BFD_ENDIAN_LITTLE;
/* The cpu data is kept in a separately allocated chunk of memory. */
- if (sim_cpu_alloc_all (sd, 1) != SIM_RC_OK)
+ if (sim_cpu_alloc_all (sd, 0) != SIM_RC_OK)
return 0;
/* for compatibility */
diff --git a/sim/moxie/interp.c b/sim/moxie/interp.c
index 144d83cbe8e..2bc241db6f5 100644
--- a/sim/moxie/interp.c
+++ b/sim/moxie/interp.c
@@ -1202,7 +1202,7 @@ sim_open (SIM_OPEN_KIND kind, host_callback *cb,
current_target_byte_order = BFD_ENDIAN_BIG;
/* The cpu data is kept in a separately allocated chunk of memory. */
- if (sim_cpu_alloc_all_extra (sd, 1, sizeof (struct moxie_sim_cpu))
+ if (sim_cpu_alloc_all_extra (sd, 0, sizeof (struct moxie_sim_cpu))
!= SIM_RC_OK)
{
free_state (sd);
diff --git a/sim/msp430/msp430-sim.c b/sim/msp430/msp430-sim.c
index e7b58bab134..c02e7ca4b6f 100644
--- a/sim/msp430/msp430-sim.c
+++ b/sim/msp430/msp430-sim.c
@@ -123,7 +123,7 @@ sim_open (SIM_OPEN_KIND kind,
/* Set default options before parsing user options. */
current_target_byte_order = BFD_ENDIAN_LITTLE;
- if (sim_cpu_alloc_all_extra (sd, 1, sizeof (struct msp430_cpu_state))
+ if (sim_cpu_alloc_all_extra (sd, 0, sizeof (struct msp430_cpu_state))
!= SIM_RC_OK)
{
sim_state_free (sd);
diff --git a/sim/or1k/sim-if.c b/sim/or1k/sim-if.c
index 799812bb741..3bbf4f05738 100644
--- a/sim/or1k/sim-if.c
+++ b/sim/or1k/sim-if.c
@@ -168,7 +168,7 @@ sim_open (SIM_OPEN_KIND kind, host_callback *callback, struct bfd *abfd,
current_target_byte_order = BFD_ENDIAN_BIG;
/* The cpu data is kept in a separately allocated chunk of memory. */
- if (sim_cpu_alloc_all_extra (sd, 1, sizeof (struct or1k_sim_cpu))
+ if (sim_cpu_alloc_all_extra (sd, 0, sizeof (struct or1k_sim_cpu))
!= SIM_RC_OK)
{
free_state (sd);
diff --git a/sim/pru/interp.c b/sim/pru/interp.c
index 250a32a889a..0e1874c1180 100644
--- a/sim/pru/interp.c
+++ b/sim/pru/interp.c
@@ -774,7 +774,7 @@ sim_open (SIM_OPEN_KIND kind, host_callback *cb,
current_target_byte_order = BFD_ENDIAN_LITTLE;
/* The cpu data is kept in a separately allocated chunk of memory. */
- if (sim_cpu_alloc_all_extra (sd, 1, sizeof (struct pru_regset)) != SIM_RC_OK)
+ if (sim_cpu_alloc_all_extra (sd, 0, sizeof (struct pru_regset)) != SIM_RC_OK)
{
free_state (sd);
return 0;
diff --git a/sim/riscv/interp.c b/sim/riscv/interp.c
index a49ad0476c4..601753e0291 100644
--- a/sim/riscv/interp.c
+++ b/sim/riscv/interp.c
@@ -77,7 +77,7 @@ sim_open (SIM_OPEN_KIND kind, host_callback *callback,
callback->syscall_map = cb_riscv_syscall_map;
/* The cpu data is kept in a separately allocated chunk of memory. */
- if (sim_cpu_alloc_all_extra (sd, 1, sizeof (struct riscv_sim_cpu))
+ if (sim_cpu_alloc_all_extra (sd, 0, sizeof (struct riscv_sim_cpu))
!= SIM_RC_OK)
{
free_state (sd);
diff --git a/sim/sh/interp.c b/sim/sh/interp.c
index b2d30e386c1..5a90cd2cf74 100644
--- a/sim/sh/interp.c
+++ b/sim/sh/interp.c
@@ -2350,7 +2350,7 @@ sim_open (SIM_OPEN_KIND kind, host_callback *cb,
cb->syscall_map = cb_sh_syscall_map;
/* The cpu data is kept in a separately allocated chunk of memory. */
- if (sim_cpu_alloc_all (sd, 1) != SIM_RC_OK)
+ if (sim_cpu_alloc_all (sd, 0) != SIM_RC_OK)
{
free_state (sd);
return 0;
diff --git a/sim/v850/interp.c b/sim/v850/interp.c
index efe35c606ff..948b7245c3f 100644
--- a/sim/v850/interp.c
+++ b/sim/v850/interp.c
@@ -206,7 +206,7 @@ sim_open (SIM_OPEN_KIND kind,
cb->syscall_map = cb_v850_syscall_map;
/* The cpu data is kept in a separately allocated chunk of memory. */
- if (sim_cpu_alloc_all_extra (sd, 1, sizeof (struct v850_sim_cpu))
+ if (sim_cpu_alloc_all_extra (sd, 0, sizeof (struct v850_sim_cpu))
!= SIM_RC_OK)
return 0;