From patchwork Wed Apr 15 05:24:55 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Frysinger X-Patchwork-Id: 6222 Received: (qmail 93886 invoked by alias); 15 Apr 2015 05:25:27 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 93864 invoked by uid 89); 15 Apr 2015 05:25:23 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.8 required=5.0 tests=AWL, BAYES_00, SPF_PASS, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: smtp.gentoo.org Received: from smtp.gentoo.org (HELO smtp.gentoo.org) (140.211.166.183) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Wed, 15 Apr 2015 05:25:21 +0000 Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.gentoo.org (Postfix) with ESMTP id A7399340BCB for ; Wed, 15 Apr 2015 05:25:19 +0000 (UTC) From: Mike Frysinger To: gdb-patches@sourceware.org Subject: [PATCH] sim: cris/frv/h8300/iq2000/lm32/m32r/sh64: standardize cpu state Date: Wed, 15 Apr 2015 01:24:55 -0400 Message-Id: <1429075495-28703-1-git-send-email-vapier@gentoo.org> X-IsSubscribed: yes This sets up the sim_state structure and the cpu member to match what we do in most other sims, and what the common code suggests. This is a step to unifying on the sim-cpu.o object. Committed. --- sim/cris/ChangeLog | 5 +++++ sim/cris/sim-main.h | 8 ++++++-- sim/frv/ChangeLog | 5 +++++ sim/frv/sim-main.h | 8 ++++++-- sim/h8300/ChangeLog | 7 +++++++ sim/h8300/compile.c | 10 +++++++++- sim/h8300/sim-main.h | 8 ++++++-- sim/iq2000/ChangeLog | 5 +++++ sim/iq2000/sim-main.h | 8 ++++++-- sim/lm32/ChangeLog | 5 +++++ sim/lm32/sim-main.h | 8 ++++++-- sim/m32r/ChangeLog | 5 +++++ sim/m32r/sim-main.h | 8 ++++++-- sim/sh64/ChangeLog | 5 +++++ sim/sh64/sim-main.h | 8 ++++++-- 15 files changed, 88 insertions(+), 15 deletions(-) diff --git a/sim/cris/ChangeLog b/sim/cris/ChangeLog index b69e20f..b1ac591 100644 --- a/sim/cris/ChangeLog +++ b/sim/cris/ChangeLog @@ -1,3 +1,8 @@ +2015-04-15 Mike Frysinger + + * sim-main.h (struct sim_state): Change cpu to an array of pointers. + (STATE_CPU): Handle WITH_SMP. + 2015-04-13 Mike Frysinger * configure: Regenerate. diff --git a/sim/cris/sim-main.h b/sim/cris/sim-main.h index 18c536f..5ae292e 100644 --- a/sim/cris/sim-main.h +++ b/sim/cris/sim-main.h @@ -225,8 +225,12 @@ struct _sim_cpu { /* The sim_state struct. */ struct sim_state { - sim_cpu *cpu; -#define STATE_CPU(sd, n) (/*&*/ (sd)->cpu) + sim_cpu *cpu[MAX_NR_PROCESSORS]; +#if (WITH_SMP) +#define STATE_CPU(sd,n) ((sd)->cpu[n]) +#else +#define STATE_CPU(sd,n) ((sd)->cpu[0]) +#endif CGEN_STATE cgen_state; diff --git a/sim/frv/ChangeLog b/sim/frv/ChangeLog index 9580c56..8e7e995 100644 --- a/sim/frv/ChangeLog +++ b/sim/frv/ChangeLog @@ -1,3 +1,8 @@ +2015-04-15 Mike Frysinger + + * sim-main.h (struct sim_state): Change cpu to an array of pointers. + (STATE_CPU): Handle WITH_SMP. + 2015-04-13 Mike Frysinger * configure: Regenerate. diff --git a/sim/frv/sim-main.h b/sim/frv/sim-main.h index 7528f6a..e7dc1a2 100644 --- a/sim/frv/sim-main.h +++ b/sim/frv/sim-main.h @@ -118,8 +118,12 @@ struct _sim_cpu { /* The sim_state struct. */ struct sim_state { - sim_cpu *cpu; -#define STATE_CPU(sd, n) (/*&*/ (sd)->cpu) + sim_cpu *cpu[MAX_NR_PROCESSORS]; +#if (WITH_SMP) +#define STATE_CPU(sd,n) ((sd)->cpu[n]) +#else +#define STATE_CPU(sd,n) ((sd)->cpu[0]) +#endif CGEN_STATE cgen_state; diff --git a/sim/h8300/ChangeLog b/sim/h8300/ChangeLog index 215a182..1740b3d 100644 --- a/sim/h8300/ChangeLog +++ b/sim/h8300/ChangeLog @@ -1,3 +1,10 @@ +2015-04-15 Mike Frysinger + + * compile.c: Include sim-options.h. + (sim_open): Call sim_cpu_alloc_all instead of sim_cpu_alloc. + * sim-main.h (struct sim_state): Change cpu to an array of pointers. + (STATE_CPU): Handle WITH_SMP. + 2015-04-13 Mike Frysinger * configure: Regenerate. diff --git a/sim/h8300/compile.c b/sim/h8300/compile.c index 2574168..e14c3ab 100644 --- a/sim/h8300/compile.c +++ b/sim/h8300/compile.c @@ -34,6 +34,7 @@ #include "gdb/sim-h8300.h" #include "sys/stat.h" #include "sys/types.h" +#include "sim-options.h" #ifndef SIGTRAP # define SIGTRAP 5 @@ -4886,7 +4887,14 @@ sim_open (SIM_OPEN_KIND kind, sim_cpu *cpu; sd = sim_state_alloc (kind, callback); - sd->cpu = sim_cpu_alloc (sd, 0); + + /* The cpu data is kept in a separately allocated chunk of memory. */ + if (sim_cpu_alloc_all (sd, 1, /*cgen_cpu_max_extra_bytes ()*/0) != SIM_RC_OK) + { + free_state (sd); + return 0; + } + cpu = STATE_CPU (sd, 0); SIM_ASSERT (STATE_MAGIC (sd) == SIM_MAGIC_NUMBER); sim_state_initialize (sd, cpu); diff --git a/sim/h8300/sim-main.h b/sim/h8300/sim-main.h index 964388a..7126fa3 100644 --- a/sim/h8300/sim-main.h +++ b/sim/h8300/sim-main.h @@ -138,7 +138,7 @@ struct _sim_cpu { /* The sim_state struct. */ struct sim_state { - struct _sim_cpu *cpu; + sim_cpu *cpu[MAX_NR_PROCESSORS]; unsigned int sim_cache_size; decoded_inst *sim_cache; unsigned short *cache_idx; @@ -155,7 +155,11 @@ struct sim_state { #define CIA_GET(CPU) (cpu_get_pc (CPU)) #define CIA_SET(CPU, VAL) (cpu_set_pc ((CPU), (VAL))) -#define STATE_CPU(SD, N) ((SD)->cpu) /* Single Processor. */ +#if (WITH_SMP) +#define STATE_CPU(sd,n) ((sd)->cpu[n]) +#else +#define STATE_CPU(sd,n) ((sd)->cpu[0]) +#endif #define cpu_set_pc(CPU, VAL) (((CPU)->pc) = (VAL)) #define cpu_get_pc(CPU) (((CPU)->pc)) diff --git a/sim/iq2000/ChangeLog b/sim/iq2000/ChangeLog index 9da17e5..b590cb0 100644 --- a/sim/iq2000/ChangeLog +++ b/sim/iq2000/ChangeLog @@ -1,3 +1,8 @@ +2015-04-15 Mike Frysinger + + * sim-main.h (struct sim_state): Change cpu to an array of pointers. + (STATE_CPU): Handle WITH_SMP. + 2015-04-13 Mike Frysinger * configure: Regenerate. diff --git a/sim/iq2000/sim-main.h b/sim/iq2000/sim-main.h index d6cb782..623c0a6 100644 --- a/sim/iq2000/sim-main.h +++ b/sim/iq2000/sim-main.h @@ -57,8 +57,12 @@ struct _sim_cpu { /* The sim_state struct. */ struct sim_state { - sim_cpu *cpu; -#define STATE_CPU(sd, n) (/*&*/ (sd)->cpu) + sim_cpu *cpu[MAX_NR_PROCESSORS]; +#if (WITH_SMP) +#define STATE_CPU(sd,n) ((sd)->cpu[n]) +#else +#define STATE_CPU(sd,n) ((sd)->cpu[0]) +#endif CGEN_STATE cgen_state; diff --git a/sim/lm32/ChangeLog b/sim/lm32/ChangeLog index fdb204b..94a1ccd 100644 --- a/sim/lm32/ChangeLog +++ b/sim/lm32/ChangeLog @@ -1,3 +1,8 @@ +2015-04-15 Mike Frysinger + + * sim-main.h (struct sim_state): Change cpu to an array of pointers. + (STATE_CPU): Handle WITH_SMP. + 2015-04-13 Mike Frysinger * configure: Regenerate. diff --git a/sim/lm32/sim-main.h b/sim/lm32/sim-main.h index a4e4423..d985607 100644 --- a/sim/lm32/sim-main.h +++ b/sim/lm32/sim-main.h @@ -83,8 +83,12 @@ struct _sim_cpu struct sim_state { - sim_cpu *cpu; -#define STATE_CPU(sd, n) (/*&*/ (sd)->cpu) + sim_cpu *cpu[MAX_NR_PROCESSORS]; +#if (WITH_SMP) +#define STATE_CPU(sd,n) ((sd)->cpu[n]) +#else +#define STATE_CPU(sd,n) ((sd)->cpu[0]) +#endif CGEN_STATE cgen_state; diff --git a/sim/m32r/ChangeLog b/sim/m32r/ChangeLog index 2dcd3a0..c8a285c 100644 --- a/sim/m32r/ChangeLog +++ b/sim/m32r/ChangeLog @@ -1,3 +1,8 @@ +2015-04-15 Mike Frysinger + + * sim-main.h (struct sim_state): Change cpu to an array of pointers. + (STATE_CPU): Handle WITH_SMP. + 2015-04-13 Mike Frysinger * configure: Regenerate. diff --git a/sim/m32r/sim-main.h b/sim/m32r/sim-main.h index 2cbb40b..96c1ec1 100644 --- a/sim/m32r/sim-main.h +++ b/sim/m32r/sim-main.h @@ -68,8 +68,12 @@ struct _sim_cpu { /* The sim_state struct. */ struct sim_state { - sim_cpu *cpu; -#define STATE_CPU(sd, n) (/*&*/ (sd)->cpu) + sim_cpu *cpu[MAX_NR_PROCESSORS]; +#if (WITH_SMP) +#define STATE_CPU(sd,n) ((sd)->cpu[n]) +#else +#define STATE_CPU(sd,n) ((sd)->cpu[0]) +#endif CGEN_STATE cgen_state; diff --git a/sim/sh64/ChangeLog b/sim/sh64/ChangeLog index 574fbb1..5bbc7a3 100644 --- a/sim/sh64/ChangeLog +++ b/sim/sh64/ChangeLog @@ -1,3 +1,8 @@ +2015-04-15 Mike Frysinger + + * sim-main.h (struct sim_state): Change cpu to an array of pointers. + (STATE_CPU): Handle WITH_SMP. + 2015-04-13 Mike Frysinger * configure: Regenerate. diff --git a/sim/sh64/sim-main.h b/sim/sh64/sim-main.h index e7cbe99..5ae4309 100644 --- a/sim/sh64/sim-main.h +++ b/sim/sh64/sim-main.h @@ -53,8 +53,12 @@ struct _sim_cpu { /* The sim_state struct. */ struct sim_state { - sim_cpu *cpu; -#define STATE_CPU(sd, n) (/*&*/ (sd)->cpu) + sim_cpu *cpu[MAX_NR_PROCESSORS]; +#if (WITH_SMP) +#define STATE_CPU(sd,n) ((sd)->cpu[n]) +#else +#define STATE_CPU(sd,n) ((sd)->cpu[0]) +#endif CGEN_STATE cgen_state;