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]

[m32c sim] minor patches


This should make the sim buildable, and fix the few bugs I'd
discovered since Jim contributed it.

2006-03-13  DJ Delorie  <dj@redhat.com>

	* mem.c (mem_put_byte): Hook simulated UART to stdout.
	(mem_put_hi): Hook in simulated trace port.
	(mem_get_byte): Hook in simulated uart control port.
	* opc2c: Be more picky about matching special comments.
	* r8c.opc (shift_op): Limit shift counts to -16..16.
	(BMcnd): Map conditional codes.
	* reg.c (condition_true): Mask condition code to 4 bits.
	* syscalls.c: Include local syscall.h.
	* syscall.h: New, copied from libgloss.

Index: mem.c
===================================================================
RCS file: /cvs/src/src/sim/m32c/mem.c,v
retrieving revision 1.1
diff -p -U3 -r1.1 mem.c
--- mem.c	23 Jan 2006 22:10:41 -0000	1.1
+++ mem.c	14 Mar 2006 03:32:38 -0000
@@ -202,6 +202,23 @@ mem_put_byte (int address, unsigned char
       }
       break;
 
+    case 0x3aa: /* uart1tx */
+      {
+	static int pending_exit = 0;
+	if (value == 0)
+	  {
+	    if (pending_exit)
+	      {
+		step_result = M32C_MAKE_EXITED(value);
+		return;
+	      }
+	    pending_exit = 1;
+	  }
+	else
+	  putchar(value);
+      }
+      break;
+
     case 0x400:
       m32c_syscall (value);
       break;
@@ -232,6 +249,11 @@ mem_put_qi (int address, unsigned char v
 void
 mem_put_hi (int address, unsigned short value)
 {
+  if (address == 0x402)
+    {
+      printf ("SimTrace: %06lx %04x\n", regs.r_pc, value);
+      return;
+    }
   S ("<=");
   mem_put_byte (address, value & 0xff);
   mem_put_byte (address + 1, value >> 8);
@@ -288,16 +310,16 @@ mem_get_byte (int address)
   address &= membus_mask;
   S ("=>");
   m = mem_ptr (address);
-  if (trace)
+  switch (address)
     {
-      if (tpr)
+    case 0x3ad: /* uart1c1 */
+      E();
+      return 2; /* transmitter empty */
+      break;
+    default: 
+      if (trace)
 	printf (" %02x", *m);
-      else
-	{
-	  S ("=>");
-	  printf (" %02x", *m);
-	  E ();
-	}
+      break;
     }
   E ();
   return *m;
Index: r8c.opc
===================================================================
RCS file: /cvs/src/src/sim/m32c/r8c.opc,v
retrieving revision 1.1
diff -p -U3 -r1.1 r8c.opc
--- r8c.opc	23 Jan 2006 22:10:41 -0000	1.1
+++ r8c.opc	14 Mar 2006 03:32:38 -0000
@@ -240,6 +240,15 @@ shift_op (srcdest sd, int arith, int cou
     {
       mask = 0xffffffffU;
       msb = 0x80000000U;
+      if (count > 16 || count < -16)
+	{
+	  fprintf(stderr, "Error: SI shift of %d undefined\n", count);
+	  exit(1);
+	}
+      if (count > 16)
+	count = (count - 1) % 16 + 1;
+      if (count < -16)
+	count = -((-count - 1) % 16 + 1);
     }
 
   tprintf("%s %x by %d\n", arith ? "sha" : "shl", v, count);
@@ -292,6 +301,12 @@ shift_op (srcdest sd, int arith, int cou
   tprintf ("b=%d, carry=%d, %s = %d\n", b, carry, #expr, v); \
   set_c (v);
 
+/* The "BMcnd dest" opcode uses a different encoding for the */
+/* condition than other opcodes.  */
+static int bmcnd_cond_map[] = {
+  0, 1, 2, 3, 8, 9, 10, 11, 4, 5, 6, 7, 12, 13, 14, 15
+};
+
 int
 decode_r8c()
 {
@@ -448,7 +463,7 @@ decode_r8c()
   /** 0111 1110 0010 dest  BMcnd dest  */
 
   dc = decode_bit (dest);
-  if (condition_true (IMM (0)))
+  if (condition_true (bmcnd_cond_map [IMM (0) & 15]))
     put_bit (dc, 1);
   else
     put_bit (dc, 0);
Index: reg.c
===================================================================
RCS file: /cvs/src/src/sim/m32c/reg.c,v
retrieving revision 1.1
diff -p -U3 -r1.1 reg.c
--- reg.c	23 Jan 2006 22:10:41 -0000	1.1
+++ reg.c	14 Mar 2006 03:32:39 -0000
@@ -347,7 +347,7 @@ condition_true (int cond_id)
 	"(S^O)|Z", "O", "!(S^O)", "unk",
 	"!((S^O)|Z)", "!O", "S^O", "unk"
       };
-      switch (cond_id)
+      switch (cond_id & 15)
 	{
 	case 0:
 	  f = FLAG_C;
@@ -409,7 +409,7 @@ condition_true (int cond_id)
 	"C", "GTU", "Z", "N",
 	"O", "LE", "LT", "!?"
       };
-      switch (cond_id)
+      switch (cond_id & 15)
 	{
 	case 0:
 	  f = !FLAG_C;
Index: syscalls.c
===================================================================
RCS file: /cvs/src/src/sim/m32c/syscalls.c,v
retrieving revision 1.1
diff -p -U3 -r1.1 syscalls.c
--- syscalls.c	23 Jan 2006 22:10:41 -0000	1.1
+++ syscalls.c	14 Mar 2006 03:32:39 -0000
@@ -33,7 +33,7 @@ Foundation, Inc., 51 Franklin Street, Fi
 #include "mem.h"
 #include "syscalls.h"
 
-#include "../../libgloss/syscall.h"
+#include "syscall.h"
 
 /* The current syscall callbacks we're using.  */
 static struct host_callback_struct *callbacks;


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