This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH, FT32] gdb and sim support


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

Attachment: signature.asc
Description: Digital signature


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]