From patchwork Thu Apr 16 06:15:47 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Frysinger X-Patchwork-Id: 6251 Received: (qmail 36029 invoked by alias); 16 Apr 2015 06:15:52 -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 36010 invoked by uid 89); 16 Apr 2015 06:15:52 -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; Thu, 16 Apr 2015 06:15:50 +0000 Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.gentoo.org (Postfix) with ESMTP id 78365340A0E for ; Thu, 16 Apr 2015 06:15:48 +0000 (UTC) From: Mike Frysinger To: gdb-patches@sourceware.org Subject: [PATCH] sim: avr/mcore/moxie: fill out sim-cpu pc fetch/store helpers Date: Thu, 16 Apr 2015 02:15:47 -0400 Message-Id: <1429164947-10850-1-git-send-email-vapier@gentoo.org> X-IsSubscribed: yes This makes the common sim-cpu logic work. Committed. --- sim/avr/ChangeLog | 6 ++++++ sim/avr/interp.c | 22 ++++++++++++++++++++++ sim/mcore/ChangeLog | 5 +++++ sim/mcore/interp.c | 16 ++++++++++++++++ sim/moxie/ChangeLog | 7 +++++++ sim/moxie/interp.c | 23 ++++++++++++++++++++++- sim/moxie/sim-main.h | 2 ++ 7 files changed, 80 insertions(+), 1 deletion(-) diff --git a/sim/avr/ChangeLog b/sim/avr/ChangeLog index 0dd4faf..2d8ddf2 100644 --- a/sim/avr/ChangeLog +++ b/sim/avr/ChangeLog @@ -1,3 +1,9 @@ +2015-04-16 Mike Frysinger + + * interp.c (avr_pc_get, avr_pc_set): New functions. + (sim_open): Declare new local var i. Call CPU_PC_FETCH & + CPU_PC_STORE for all cpus. + 2015-04-15 Mike Frysinger * Makefile.in (SIM_OBJS): Delete sim-cpu.o. diff --git a/sim/avr/interp.c b/sim/avr/interp.c index d169935..a6588d3 100644 --- a/sim/avr/interp.c +++ b/sim/avr/interp.c @@ -1663,6 +1663,18 @@ sim_fetch_register (SIM_DESC sd, int rn, unsigned char *memory, int length) return 0; } +static sim_cia +avr_pc_get (sim_cpu *cpu) +{ + return pc; +} + +static void +avr_pc_set (sim_cpu *cpu, sim_cia _pc) +{ + pc = _pc; +} + static void free_state (SIM_DESC sd) { @@ -1675,6 +1687,7 @@ free_state (SIM_DESC sd) 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_ASSERT (STATE_MAGIC (sd) == SIM_MAGIC_NUMBER); @@ -1729,6 +1742,15 @@ sim_open (SIM_OPEN_KIND kind, host_callback *cb, struct bfd *abfd, char **argv) return 0; } + /* CPU specific initialization. */ + for (i = 0; i < MAX_NR_PROCESSORS; ++i) + { + SIM_CPU *cpu = STATE_CPU (sd, i); + + CPU_PC_FETCH (cpu) = avr_pc_get; + CPU_PC_STORE (cpu) = avr_pc_set; + } + /* Clear all the memory. */ memset (sram, 0, sizeof (sram)); memset (flash, 0, sizeof (flash)); diff --git a/sim/mcore/ChangeLog b/sim/mcore/ChangeLog index 152864e..a00954c 100644 --- a/sim/mcore/ChangeLog +++ b/sim/mcore/ChangeLog @@ -1,3 +1,8 @@ +2015-04-16 Mike Frysinger + + * interp.c (mcore_pc_get, mcore_pc_set): New functions. + (sim_open): Call CPU_PC_FETCH & CPU_PC_STORE for all cpus. + 2015-04-15 Mike Frysinger * Makefile.in (SIM_OBJS): Delete sim-cpu.o. diff --git a/sim/mcore/interp.c b/sim/mcore/interp.c index b99988c..fc1131b 100644 --- a/sim/mcore/interp.c +++ b/sim/mcore/interp.c @@ -1779,6 +1779,18 @@ sim_info (SIM_DESC sd, int verbose) #endif } +static sim_cia +mcore_pc_get (sim_cpu *cpu) +{ + return cpu->pc; +} + +static void +mcore_pc_set (sim_cpu *cpu, sim_cia pc) +{ + cpu->pc = pc; +} + static void free_state (SIM_DESC sd) { @@ -1856,6 +1868,10 @@ sim_open (SIM_OPEN_KIND kind, host_callback *cb, struct bfd *abfd, char **argv) for (i = 0; i < MAX_NR_PROCESSORS; ++i) { SIM_CPU *cpu = STATE_CPU (sd, i); + + CPU_PC_FETCH (cpu) = mcore_pc_get; + CPU_PC_STORE (cpu) = mcore_pc_set; + set_initial_gprs (cpu); /* Reset the GPR registers. */ } diff --git a/sim/moxie/ChangeLog b/sim/moxie/ChangeLog index b2cf6f6..6f7e55b 100644 --- a/sim/moxie/ChangeLog +++ b/sim/moxie/ChangeLog @@ -1,3 +1,10 @@ +2015-04-16 Mike Frysinger + + * interp.c (moxie_pc_get, moxie_pc_set): New functions. + (sim_open): Declare new local var i. Call CPU_PC_FETCH & + CPU_PC_STORE for all cpus. + * sim-main.h (SIM_CPU): New typedef. + 2015-04-15 Mike Frysinger * Makefile.in (SIM_OBJS): Delete sim-cpu.o. diff --git a/sim/moxie/interp.c b/sim/moxie/interp.c index 428a9d5..fce6d81 100644 --- a/sim/moxie/interp.c +++ b/sim/moxie/interp.c @@ -1145,6 +1145,18 @@ sim_fetch_register (SIM_DESC sd, int rn, unsigned char *memory, int length) return 0; } +static sim_cia +moxie_pc_get (sim_cpu *cpu) +{ + return cpu->registers[PCIDX]; +} + +static void +moxie_pc_set (sim_cpu *cpu, sim_cia pc) +{ + cpu->registers[PCIDX] = pc; +} + static void free_state (SIM_DESC sd) { @@ -1157,6 +1169,7 @@ free_state (SIM_DESC sd) 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_ASSERT (STATE_MAGIC (sd) == SIM_MAGIC_NUMBER); @@ -1215,7 +1228,15 @@ sim_open (SIM_OPEN_KIND kind, host_callback *cb, struct bfd *abfd, char **argv) } /* CPU specific initialization. */ - set_initial_gprs (); + for (i = 0; i < MAX_NR_PROCESSORS; ++i) + { + SIM_CPU *cpu = STATE_CPU (sd, i); + + CPU_PC_FETCH (cpu) = moxie_pc_get; + CPU_PC_STORE (cpu) = moxie_pc_set; + + set_initial_gprs (); /* Reset the GPR registers. */ + } return sd; } diff --git a/sim/moxie/sim-main.h b/sim/moxie/sim-main.h index 5a9f7c7..6a2174b 100644 --- a/sim/moxie/sim-main.h +++ b/sim/moxie/sim-main.h @@ -24,6 +24,8 @@ along with this program. If not, see . */ typedef address_word sim_cia; +typedef struct _sim_cpu SIM_CPU; + #include "sim-base.h" #include "bfd.h"