From patchwork Mon Apr 13 06:15:12 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Frysinger X-Patchwork-Id: 6171 Received: (qmail 86557 invoked by alias); 13 Apr 2015 06:15:24 -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 86441 invoked by uid 89); 13 Apr 2015 06:15:18 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=0.0 required=5.0 tests=AWL, BAYES_00, KAM_ASCII_DIVIDERS, SPF_PASS, T_RP_MATCHES_RCVD, UNWANTED_LANGUAGE_BODY autolearn=no 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; Mon, 13 Apr 2015 06:15:17 +0000 Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.gentoo.org (Postfix) with ESMTP id 0A0B23406B5 for ; Mon, 13 Apr 2015 06:15:15 +0000 (UTC) From: Mike Frysinger To: gdb-patches@sourceware.org Subject: [PATCH 2/4] sim: mips: convert to sim-cpu Date: Mon, 13 Apr 2015 02:15:12 -0400 Message-Id: <1428905714-12268-2-git-send-email-vapier@gentoo.org> In-Reply-To: <1428905714-12268-1-git-send-email-vapier@gentoo.org> References: <1428905714-12268-1-git-send-email-vapier@gentoo.org> X-IsSubscribed: yes Make cpu allocation fully dynamic so we can leverage the common sim-cpu and its APIs. Committed. --- sim/mips/ChangeLog | 11 +++++++++++ sim/mips/Makefile.in | 1 + sim/mips/interp.c | 34 +++++++++++++++++++++++++++------- sim/mips/sim-main.h | 9 +++++---- 4 files changed, 44 insertions(+), 11 deletions(-) diff --git a/sim/mips/ChangeLog b/sim/mips/ChangeLog index cd655eb..a962f84 100644 --- a/sim/mips/ChangeLog +++ b/sim/mips/ChangeLog @@ -1,5 +1,16 @@ 2015-04-13 Mike Frysinger + * Makefile.in (SIM_OBJS): Add sim-cpu.o. + * interp.c (mips_pc_get, mips_pc_set): New functions. + (sim_open): Declare new local var i. Call sim_cpu_alloc_all. + Call CPU_PC_FETCH & CPU_PC_STORE for all cpus. + (sim_pc_get): Delete. + * sim-main.h (SIM_CPU): Define. + (struct sim_state): Change cpu to an array of pointers. + (STATE_CPU): Drop &. + +2015-04-13 Mike Frysinger + * interp.c (mips_option_handler, open_trace, sim_close, sim_write, sim_read, sim_store_register, sim_fetch_register, sim_create_inferior, pr_addr, pr_uword64): Convert old style diff --git a/sim/mips/Makefile.in b/sim/mips/Makefile.in index 17eeab6..96131ae 100644 --- a/sim/mips/Makefile.in +++ b/sim/mips/Makefile.in @@ -46,6 +46,7 @@ SIM_OBJS = \ cp1.o \ mdmx.o \ dsp.o \ + sim-cpu.o \ sim-main.o \ sim-hload.o \ sim-stop.o \ diff --git a/sim/mips/interp.c b/sim/mips/interp.c index dabd9e0..d6136ab 100644 --- a/sim/mips/interp.c +++ b/sim/mips/interp.c @@ -336,14 +336,33 @@ static void device_init(SIM_DESC sd) { /*-- GDB simulator interface ------------------------------------------------*/ /*---------------------------------------------------------------------------*/ +static sim_cia +mips_pc_get (sim_cpu *cpu) +{ + return PC; +} + +static void +mips_pc_set (sim_cpu *cpu, sim_cia pc) +{ + PC = pc; +} + SIM_DESC sim_open (SIM_OPEN_KIND kind, host_callback *cb, struct bfd *abfd, char **argv) { + int i; SIM_DESC sd = sim_state_alloc (kind, cb); - sim_cpu *cpu = STATE_CPU (sd, 0); /* FIXME */ + sim_cpu *cpu; 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 (sd, 1, /*cgen_cpu_max_extra_bytes ()*/0) != SIM_RC_OK) + return 0; + + cpu = STATE_CPU (sd, 0); /* FIXME */ + /* FIXME: watchpoints code shouldn't need this */ STATE_WATCHPOINTS (sd)->pc = &(PC); STATE_WATCHPOINTS (sd)->sizeof_pc = sizeof (PC); @@ -790,7 +809,14 @@ sim_open (SIM_OPEN_KIND kind, host_callback *cb, struct bfd *abfd, char **argv) } } + /* CPU specific initialization. */ + for (i = 0; i < MAX_NR_PROCESSORS; ++i) + { + SIM_CPU *cpu = STATE_CPU (sd, i); + CPU_PC_FETCH (cpu) = mips_pc_get; + CPU_PC_STORE (cpu) = mips_pc_set; + } return sd; } @@ -1066,12 +1092,6 @@ sim_fetch_register (SIM_DESC sd, int rn, unsigned char *memory, int length) return 0; } -sim_cia -sim_pc_get (sim_cpu *cpu) -{ - return PC; -} - SIM_RC sim_create_inferior (SIM_DESC sd, struct bfd *abfd, char **argv, char **env) { diff --git a/sim/mips/sim-main.h b/sim/mips/sim-main.h index 3c0e9bb..e27636c 100644 --- a/sim/mips/sim-main.h +++ b/sim/mips/sim-main.h @@ -36,6 +36,8 @@ mips_core_signal ((SD), (CPU), (CIA), (MAP), (NR_BYTES), (ADDR), (TRANSFER), (ER typedef address_word sim_cia; +typedef struct _sim_cpu SIM_CPU; + #include "sim-base.h" #include "bfd.h" @@ -486,14 +488,13 @@ struct sim_state { struct swatch watch; - sim_cpu cpu[MAX_NR_PROCESSORS]; + sim_cpu *cpu[MAX_NR_PROCESSORS]; #if (WITH_SMP) -#define STATE_CPU(sd,n) (&(sd)->cpu[n]) +#define STATE_CPU(sd,n) ((sd)->cpu[n]) #else -#define STATE_CPU(sd,n) (&(sd)->cpu[0]) +#define STATE_CPU(sd,n) ((sd)->cpu[0]) #endif - sim_state_base base; };