2005-06-13 H.J. Lu <hongjiu.lu@intel.com>
[deliverable/binutils-gdb.git] / gdb / dve3900-rom.c
index 34707bb9b05ef2360d9aba15a70d8e461be89451..ae8ea13c2297abad1a58d07c43c64fb6b0c7c62f 100644 (file)
@@ -1,6 +1,6 @@
 /* Remote debugging interface for Densan DVE-R3900 ROM monitor for
    GDB, the GNU debugger.
-   Copyright 1997 Free Software Foundation, Inc.
+   Copyright 1997, 1998, 2000, 2001 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
 #include "command.h"
 #include "gdb_string.h"
 #include <time.h>
+#include "regcache.h"
+#include "mips-tdep.h"
 
 /* Type of function passed to bfd_map_over_sections.  */
 
-typedef void (*section_map_func) (bfd * abfd, asection * sect, PTR obj);
+typedef void (*section_map_func) (bfd * abfd, asection * sect, void *obj);
 
 /* Packet escape character used by Densan monitor.  */
 
@@ -112,7 +114,7 @@ static int ethernet = 0;
    different names than GDB does, and don't support all the registers
    either.  */
 
-static char *r3900_regnames[NUM_REGS] =
+static char *r3900_regnames[] =
 {
   "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7",
   "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15",
@@ -120,11 +122,11 @@ static char *r3900_regnames[NUM_REGS] =
   "r24", "r25", "r26", "r27", "r28", "r29", "r30", "r31",
 
   "S",                         /* PS_REGNUM */
-  "l",                         /* LO_REGNUM */
-  "h",                         /* HI_REGNUM */
-  "B",                         /* BADVADDR_REGNUM */
-  "Pcause",                    /* CAUSE_REGNUM */
-  "p"                          /* PC_REGNUM */
+  "l",                         /* MIPS_EMBED_LO_REGNUM */
+  "h",                         /* MIPS_EMBED_HI_REGNUM */
+  "B",                         /* MIPS_EMBED_BADVADDR_REGNUM */
+  "Pcause",                    /* MIPS_EMBED_CAUSE_REGNUM */
+  "p"                          /* MIPS_EMBED_PC_REGNUM */
 };
 
 
@@ -266,19 +268,19 @@ reg_table[] =
   }
   ,
   {
-    "HI", HI_REGNUM
+    "HI", MIPS_EMBED_HI_REGNUM
   }
   ,
   {
-    "LO", LO_REGNUM
+    "LO", MIPS_EMBED_LO_REGNUM
   }
   ,
   {
-    "PC", PC_REGNUM
+    "PC", MIPS_EMBED_PC_REGNUM
   }
   ,
   {
-    "BadV", BADVADDR_REGNUM
+    "BadV", MIPS_EMBED_BADVADDR_REGNUM
   }
   ,
   {
@@ -419,7 +421,7 @@ fetch_bad_vaddr (void)
   monitor_printf ("xB\r");
   monitor_expect ("BadV=", NULL, 0);
   monitor_expect_prompt (buf, sizeof (buf));
-  monitor_supply_register (BADVADDR_REGNUM, buf);
+  monitor_supply_register (mips_regnum (current_gdbarch)->badvaddr, buf);
 }
 
 
@@ -454,17 +456,24 @@ static void
 fetch_bitmapped_register (int regno, struct bit_field *bf)
 {
   unsigned long val;
-  unsigned char regbuf[MAX_REGISTER_RAW_SIZE];
+  unsigned char regbuf[MAX_REGISTER_SIZE];
+  char *regname = NULL;
 
-  monitor_printf ("x%s\r", r3900_regnames[regno]);
+  if (regno >= sizeof (r3900_regnames) / sizeof (r3900_regnames[0]))
+    internal_error (__FILE__, __LINE__,
+                    _("fetch_bitmapped_register: regno out of bounds"));
+  else
+    regname = r3900_regnames[regno];
+
+  monitor_printf ("x%s\r", regname);
   val = fetch_fields (bf);
   monitor_printf (".\r");
   monitor_expect_prompt (NULL, 0);
 
   /* supply register stores in target byte order, so swap here */
 
-  store_unsigned_integer (regbuf, REGISTER_RAW_SIZE (regno), val);
-  supply_register (regno, regbuf);
+  store_unsigned_integer (regbuf, register_size (current_gdbarch, regno), val);
+  regcache_raw_supply (current_regcache, regno, regbuf);
 
 }
 
@@ -477,20 +486,15 @@ fetch_bitmapped_register (int regno, struct bit_field *bf)
 static void
 r3900_fetch_registers (int regno)
 {
-  switch (regno)
-    {
-    case BADVADDR_REGNUM:
-      fetch_bad_vaddr ();
-      return;
-    case PS_REGNUM:
-      fetch_bitmapped_register (PS_REGNUM, status_fields);
-      return;
-    case CAUSE_REGNUM:
-      fetch_bitmapped_register (CAUSE_REGNUM, cause_fields);
-      return;
-    default:
-      orig_monitor_fetch_registers (regno);
-    }
+  if (regno == mips_regnum (current_gdbarch)->badvaddr)
+    fetch_bad_vaddr ();
+  else if (regno == PS_REGNUM)
+    fetch_bitmapped_register (PS_REGNUM, status_fields);
+  else if (regno == mips_regnum (current_gdbarch)->cause)
+    fetch_bitmapped_register (mips_regnum (current_gdbarch)->cause,
+                             cause_fields);
+  else
+    orig_monitor_fetch_registers (regno);
 }
 
 
@@ -500,9 +504,16 @@ static void
 store_bitmapped_register (int regno, struct bit_field *bf)
 {
   unsigned long oldval, newval;
+  char *regname = NULL;
+
+  if (regno >= sizeof (r3900_regnames) / sizeof (r3900_regnames[0]))
+    internal_error (__FILE__, __LINE__,
+                    _("fetch_bitmapped_register: regno out of bounds"));
+  else
+    regname = r3900_regnames[regno];
 
   /* Fetch the current value of the register.  */
-  monitor_printf ("x%s\r", r3900_regnames[regno]);
+  monitor_printf ("x%s\r", regname);
   oldval = fetch_fields (bf);
   newval = read_register (regno);
 
@@ -529,17 +540,13 @@ store_bitmapped_register (int regno, struct bit_field *bf)
 static void
 r3900_store_registers (int regno)
 {
-  switch (regno)
-    {
-    case PS_REGNUM:
-      store_bitmapped_register (PS_REGNUM, status_fields);
-      return;
-    case CAUSE_REGNUM:
-      store_bitmapped_register (CAUSE_REGNUM, cause_fields);
-      return;
-    default:
-      orig_monitor_store_registers (regno);
-    }
+  if (regno == PS_REGNUM)
+    store_bitmapped_register (PS_REGNUM, status_fields);
+  else if (regno == mips_regnum (current_gdbarch)->cause)
+    store_bitmapped_register (mips_regnum (current_gdbarch)->cause,
+                             cause_fields);
+  else
+    orig_monitor_store_registers (regno);
 }
 
 
@@ -633,7 +640,7 @@ debug_write (unsigned char *buf, int buflen)
 static void
 ignore_packet (void)
 {
-  int c;
+  int c = -1;
   int len;
 
   /* Ignore lots of trash (messages about section addresses, for example)
@@ -645,7 +652,7 @@ ignore_packet (void)
        break;
     }
   if (len == 8)
-    error ("Packet header byte not found; %02x seen instead.", c);
+    error (_("Packet header byte not found; %02x seen instead."), c);
 
   /* Read the packet type and length.  */
   c = debug_readchar (1);      /* type */
@@ -819,7 +826,7 @@ load_section (bfd *abfd, asection *s, unsigned int *data_count)
       /* Print some fluff about the section being loaded.  */
       printf_filtered ("Loading section %s, size 0x%lx lma ",
                       bfd_section_name (abfd, s), (long) section_size);
-      print_address_numeric (section_base, 1, gdb_stdout);
+      deprecated_print_address_numeric (section_base, 1, gdb_stdout);
       printf_filtered ("\n");
       gdb_flush (gdb_stdout);
 
@@ -833,7 +840,7 @@ load_section (bfd *abfd, asection *s, unsigned int *data_count)
       buffer = (unsigned char *) xmalloc (section_size);
       bfd_get_section_contents (abfd, s, buffer, 0, section_size);
       process_read_request (buffer, section_size);
-      free (buffer);
+      xfree (buffer);
     }
 }
 
@@ -878,9 +885,9 @@ r3900_load (char *filename, int from_tty)
     filename = get_exec_file (1);
   abfd = bfd_openr (filename, 0);
   if (!abfd)
-    error ("Unable to open file %s\n", filename);
+    error (_("Unable to open file %s."), filename);
   if (bfd_check_format (abfd, bfd_object) == 0)
-    error ("File is not an object file\n");
+    error (_("File is not an object file."));
 
   /* Output the "vconsi" command to get the monitor in the communication
      state where it will accept a load command.  This will cause
@@ -926,7 +933,7 @@ r3900_load (char *filename, int from_tty)
   if (exec_bfd)
     write_pc (bfd_get_start_address (exec_bfd));
 
-  inferior_pid = 0;            /* No process now */
+  inferior_ptid = null_ptid;           /* No process now */
 
   /* This is necessary because many things were based on the PC at the
      time that we attached to the monitor, which is no longer valid
This page took 0.026567 seconds and 4 git commands to generate.