public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Mike Frysinger <vapier@gentoo.org>
To: James Bowman <james.bowman@ftdichip.com>,
	"gdb-patches@sourceware.org" <gdb-patches@sourceware.org>
Subject: Re: [PATCH, FT32] gdb and sim support
Date: Fri, 20 Mar 2015 05:19:00 -0000	[thread overview]
Message-ID: <20150320051909.GE11803@vapier> (raw)
In-Reply-To: <20150320051809.GD11803@vapier>


[-- Attachment #1.1: Type: text/plain, Size: 148 bytes --]

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

[-- Attachment #1.2: ft32-sim.patch --]
[-- Type: text/x-diff, Size: 3768 bytes --]

--- 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);
 }

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

  reply	other threads:[~2015-03-20  5:19 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-03  4:06 James Bowman
2015-02-10  6:27 ` James Bowman
2015-02-17 10:21   ` Mike Frysinger
2015-02-19  7:06 ` Mike Frysinger
     [not found] ` <ORIGINAL-RELEASE-1424557036-20150219070610.GI544@vapier>
2015-02-23 10:40   ` James Bowman
2015-02-24  4:52     ` Mike Frysinger
2015-03-10 16:56       ` James Bowman
2015-03-16  8:25         ` Mike Frysinger
2015-03-19 15:26           ` James Bowman
2015-03-19 18:52             ` Mike Frysinger
2015-03-20  2:57               ` James Bowman
2015-03-20  5:18                 ` Mike Frysinger
2015-03-20  5:19                   ` Mike Frysinger [this message]
2015-03-23 19:21                     ` James Bowman
2015-03-26  7:10                       ` Mike Frysinger
2015-03-26 19:05                         ` James Bowman
2015-03-16 16:38         ` Mike Frysinger
2015-03-17 17:36         ` Joel Brobecker
2015-03-19 15:21           ` James Bowman
2015-03-19 18:54             ` Mike Frysinger
2015-03-20  3:01               ` James Bowman
2015-03-20  3:47                 ` Mike Frysinger
2015-03-20 12:46                 ` Joel Brobecker
2015-03-20 15:47                   ` Mike Frysinger
2015-03-20 15:50                     ` Joel Brobecker
2015-03-22 22:33                       ` Mike Frysinger
2015-03-23 12:36                         ` Joel Brobecker
2015-03-23 19:15                           ` James Bowman
2015-03-23 23:04                             ` Joel Brobecker
2015-03-28  6:21 ` Mike Frysinger

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20150320051909.GE11803@vapier \
    --to=vapier@gentoo.org \
    --cc=gdb-patches@sourceware.org \
    --cc=james.bowman@ftdichip.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).