From patchwork Fri Mar 20 05:19:09 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Frysinger X-Patchwork-Id: 5714 Received: (qmail 23900 invoked by alias); 20 Mar 2015 05:19:12 -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 23855 invoked by uid 89); 20 Mar 2015 05:19:11 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 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; Fri, 20 Mar 2015 05:19:11 +0000 Received: from vapier (localhost [127.0.0.1]) by smtp.gentoo.org (Postfix) with SMTP id DE1B0340C22; Fri, 20 Mar 2015 05:19:08 +0000 (UTC) Date: Fri, 20 Mar 2015 01:19:09 -0400 From: Mike Frysinger To: James Bowman , "gdb-patches@sourceware.org" Subject: Re: [PATCH, FT32] gdb and sim support Message-ID: <20150320051909.GE11803@vapier> Mail-Followup-To: James Bowman , "gdb-patches@sourceware.org" References: <20150224045154.GE13523@vapier> <20150316082548.GC12926@vapier> <20150319185217.GC4128@vapier> <20150320051809.GD11803@vapier> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20150320051809.GD11803@vapier> X-IsSubscribed: yes On 20 Mar 2015 01:18, Mike Frysinger wrote: > it mostly looks good. i made some fixes you should apply (see attached). forgot to attach ... -mike --- a/sim/ft32/interp.c +++ b/sim/ft32/interp.c @@ -30,16 +30,11 @@ #include "gdb/remote-sim.h" #include "sim-main.h" -#include "sim-base.h" #include "opcode/ft32.h" #define RAM_BIAS 0x800000 /* Bias added to RAM addresses. */ -/* Forward declarations. */ -int ft32_reg_store (SIM_CPU *cpu, int rn, unsigned char *memory, int length); -int ft32_reg_fetch (SIM_CPU *cpu, int rn, unsigned char *memory, int length); - static unsigned long ft32_extract_unsigned_integer (unsigned char *addr, int len) { @@ -139,7 +134,7 @@ static uint32_t cpu_mem_read (SIM_DESC sd, uint32_t dw, uint32_t ea) uint8_t byte[4]; ea &= 0x1ffff; - if ((ea & ~0xffff)) + if (ea & ~0xffff) { switch (ea) { @@ -147,10 +142,8 @@ static uint32_t cpu_mem_read (SIM_DESC sd, uint32_t dw, uint32_t ea) /* Read the simulator cycle timer. */ return cpu->state.cycles / 100; default: - sim_io_eprintf (sd, - "Illegal IO read address %08x, pc %#x\n", - ea, - insnpc); + sim_io_eprintf (sd, "Illegal IO read address %08x, pc %#x\n", + ea, insnpc); ILLEGAL (); } } @@ -281,8 +274,8 @@ static uint32_t flip (uint32_t x, uint32_t b) return x; } -static -void step_once (SIM_DESC sd) +static void +step_once (SIM_DESC sd) { sim_cpu *cpu = STATE_CPU (sd, 0); address_word cia = CIA_GET (cpu); @@ -366,9 +359,7 @@ void step_once (SIM_DESC sd) else cpu->state.pc = cpu->state.regs[r_2]; if (cpu->state.pc == 0x8) - { goto escape; - } } } break; @@ -680,10 +671,8 @@ sim_read (SIM_DESC sd, } static uint32_t * -ft32_lookup_register (SIM_CPU *current_cpu, int nr) +ft32_lookup_register (SIM_CPU *cpu, int nr) { - sim_cpu *cpu = current_cpu; - /* Handle the register number translation here. * Sim registers are 0-31. * Other tools (gcc, gdb) use: @@ -694,29 +683,28 @@ ft32_lookup_register (SIM_CPU *current_cpu, int nr) */ if ((nr < 0) || (nr > 31)) - abort (); + { + sim_io_eprintf (CPU_STATE (cpu), "unknown register %i\n", nr); + abort (); + } switch (nr) { case 0: return &cpu->state.regs[FT32_FP_REGNUM]; - break; case 1: return &cpu->state.regs[FT32_SP_REGNUM]; - break; case 31: return &cpu->state.regs[FT32_CC_REGNUM]; - break; case 32: return &cpu->state.pc; - break; default: return &cpu->state.regs[nr - 2]; } } -int -ft32_reg_store (SIM_CPU *current_cpu, +static int +ft32_reg_store (SIM_CPU *cpu, int rn, unsigned char *memory, int length) @@ -724,7 +712,7 @@ ft32_reg_store (SIM_CPU *current_cpu, if (0 <= rn && rn <= 32) { if (length == 4) - *ft32_lookup_register (current_cpu, rn) = ft32_extract_unsigned_integer (memory, 4); + *ft32_lookup_register (cpu, rn) = ft32_extract_unsigned_integer (memory, 4); return 4; } @@ -732,8 +720,8 @@ ft32_reg_store (SIM_CPU *current_cpu, return 0; } -int -ft32_reg_fetch (SIM_CPU *current_cpu, +static int +ft32_reg_fetch (SIM_CPU *cpu, int rn, unsigned char *memory, int length) @@ -741,7 +729,7 @@ ft32_reg_fetch (SIM_CPU *current_cpu, if (0 <= rn && rn <= 32) { if (length == 4) - ft32_store_unsigned_integer (memory, 4, *ft32_lookup_register (current_cpu, rn)); + ft32_store_unsigned_integer (memory, 4, *ft32_lookup_register (cpu, rn)); return 4; } @@ -837,8 +825,7 @@ sim_open (SIM_OPEN_KIND kind, } void -sim_close (SIM_DESC sd, - int quitting) +sim_close (SIM_DESC sd, int quitting) { sim_module_uninstall (sd); }