* elf32-sh.c (sh_elf_set_mach_from_flags): Make it static.
[deliverable/binutils-gdb.git] / gdb / dcache.c
index 5f09ca886866d5cb37d35457021fb261720d2fa3..4081c920ceb2b39e3c46587e1fa589a21b66d9c9 100644 (file)
@@ -149,24 +149,21 @@ struct dcache_struct
     int cache_has_stuff;
   };
 
-static int dcache_poke_byte PARAMS ((DCACHE * dcache, CORE_ADDR addr,
-                                    char *ptr));
+static int dcache_poke_byte (DCACHE * dcache, CORE_ADDR addr, char *ptr);
 
-static int dcache_peek_byte PARAMS ((DCACHE * dcache, CORE_ADDR addr,
-                                    char *ptr));
+static int dcache_peek_byte (DCACHE * dcache, CORE_ADDR addr, char *ptr);
 
-static struct dcache_block *dcache_hit PARAMS ((DCACHE * dcache,
-                                               CORE_ADDR addr));
+static struct dcache_block *dcache_hit (DCACHE * dcache, CORE_ADDR addr);
 
-static int dcache_write_line PARAMS ((DCACHE * dcache, struct dcache_block * db));
+static int dcache_write_line (DCACHE * dcache, struct dcache_block *db);
 
-static struct dcache_block *dcache_alloc PARAMS ((DCACHE * dcache));
+static struct dcache_block *dcache_alloc (DCACHE * dcache, CORE_ADDR addr);
 
-static int dcache_writeback PARAMS ((DCACHE * dcache));
+static int dcache_writeback (DCACHE * dcache);
 
-static void dcache_info PARAMS ((char *exp, int tty));
+static void dcache_info (char *exp, int tty);
 
-void _initialize_dcache PARAMS ((void));
+void _initialize_dcache (void);
 
 static int dcache_enabled_p = 0;
 
@@ -176,8 +173,7 @@ DCACHE *last_cache;         /* Used by info dcache */
 /* Free all the data cache blocks, thus discarding all cached data.  */
 
 void
-dcache_flush (dcache)
-     DCACHE *dcache;
+dcache_flush (DCACHE *dcache)
 {
   int i;
   dcache->valid_head = 0;
@@ -207,9 +203,7 @@ dcache_flush (dcache)
    containing it. */
 
 static struct dcache_block *
-dcache_hit (dcache, addr)
-     DCACHE *dcache;
-     CORE_ADDR addr;
+dcache_hit (DCACHE *dcache, CORE_ADDR addr)
 {
   register struct dcache_block *db;
 
@@ -233,9 +227,7 @@ dcache_hit (dcache, addr)
    be written is. */
 
 static int
-dcache_write_line (dcache, db)
-     DCACHE *dcache;
-     register struct dcache_block *db;
+dcache_write_line (DCACHE *dcache, register struct dcache_block *db)
 {
   int s;
   int e;
@@ -275,16 +267,10 @@ dcache_write_line (dcache, db)
 
 
 /* Get a free cache block, put or keep it on the valid list,
-   and return its address.  The caller should store into the block
-   the address and data that it describes, then remque it from the
-   free list and insert it into the valid list.  This procedure
-   prevents errors from creeping in if a memory retrieval is
-   interrupted (which used to put garbage blocks in the valid
-   list...).  */
+   and return its address.  */
 
 static struct dcache_block *
-dcache_alloc (dcache)
-     DCACHE *dcache;
+dcache_alloc (DCACHE *dcache, CORE_ADDR addr)
 {
   register struct dcache_block *db;
 
@@ -306,6 +292,11 @@ dcache_alloc (dcache)
       dcache_write_line (dcache, db);
     }
 
+  db->addr = MASK(addr);
+  db->refs = 0;
+  db->anydirty = 0;
+  memset (db->state, ENTRY_BAD, sizeof (db->data));
+
   /* append this line to end of valid list */
   if (!dcache->valid_head)
     dcache->valid_head = db;
@@ -323,10 +314,7 @@ dcache_alloc (dcache)
    Returns 0 on error. */
 
 static int
-dcache_peek_byte (dcache, addr, ptr)
-     DCACHE *dcache;
-     CORE_ADDR addr;
-     char *ptr;
+dcache_peek_byte (DCACHE *dcache, CORE_ADDR addr, char *ptr)
 {
   register struct dcache_block *db = dcache_hit (dcache, addr);
   int ok = 1;
@@ -339,9 +327,9 @@ dcache_peek_byte (dcache, addr, ptr)
          dcache_write_line (dcache, db);
        }
       else
-       db = dcache_alloc (dcache);
+       db = dcache_alloc (dcache, addr);
+
       immediate_quit++;
-      db->addr = MASK (addr);
       while (done < LINE_SIZE)
        {
          int try =
@@ -364,8 +352,7 @@ dcache_peek_byte (dcache, addr, ptr)
 
 /* Writeback any dirty lines to the remote. */
 static int
-dcache_writeback (dcache)
-     DCACHE *dcache;
+dcache_writeback (DCACHE *dcache)
 {
   struct dcache_block *db;
 
@@ -381,39 +368,18 @@ dcache_writeback (dcache)
 }
 
 
-/* Using the data cache DCACHE return the contents of the word at
-   address ADDR in the remote machine.  */
-int
-dcache_fetch (dcache, addr)
-     DCACHE *dcache;
-     CORE_ADDR addr;
-{
-  int res;
-
-  if (dcache_xfer_memory (dcache, addr, (char *) &res, sizeof res, 0) != sizeof res)
-    memory_error (EIO, addr);
-
-  return res;
-}
-
-
 /* Write the byte at PTR into ADDR in the data cache.
    Return zero on write error.
  */
 
 static int
-dcache_poke_byte (dcache, addr, ptr)
-     DCACHE *dcache;
-     CORE_ADDR addr;
-     char *ptr;
+dcache_poke_byte (DCACHE *dcache, CORE_ADDR addr, char *ptr)
 {
   register struct dcache_block *db = dcache_hit (dcache, addr);
 
   if (!db)
     {
-      db = dcache_alloc (dcache);
-      db->addr = MASK (addr);
-      memset (db->state, ENTRY_BAD, sizeof (db->data));
+      db = dcache_alloc (dcache, addr);
     }
 
   db->data[XFORM (addr)] = *ptr;
@@ -422,28 +388,9 @@ dcache_poke_byte (dcache, addr, ptr)
   return 1;
 }
 
-/* Write the word at ADDR both in the data cache and in the remote machine.  
-   Return zero on write error.
- */
-
-int
-dcache_poke (dcache, addr, data)
-     DCACHE *dcache;
-     CORE_ADDR addr;
-     int data;
-{
-  if (dcache_xfer_memory (dcache, addr, (char *) &data, sizeof data, 1) != sizeof data)
-    return 0;
-
-  return dcache_writeback (dcache);
-}
-
-
 /* Initialize the data cache.  */
 DCACHE *
-dcache_init (reading, writing)
-     memxferfunc reading;
-     memxferfunc writing;
+dcache_init (memxferfunc reading, memxferfunc writing)
 {
   int csize = sizeof (struct dcache_block) * DCACHE_SIZE;
   DCACHE *dcache;
@@ -470,18 +417,14 @@ dcache_init (reading, writing)
    This routine is indended to be called by remote_xfer_ functions. */
 
 int
-dcache_xfer_memory (dcache, memaddr, myaddr, len, should_write)
-     DCACHE *dcache;
-     CORE_ADDR memaddr;
-     char *myaddr;
-     int len;
-     int should_write;
+dcache_xfer_memory (DCACHE *dcache, CORE_ADDR memaddr, char *myaddr, int len,
+                   int should_write)
 {
   int i;
 
   if (dcache_enabled_p)
     {
-      int (*xfunc) PARAMS ((DCACHE * dcache, CORE_ADDR addr, char *ptr));
+      int (*xfunc) (DCACHE * dcache, CORE_ADDR addr, char *ptr);
       xfunc = should_write ? dcache_poke_byte : dcache_peek_byte;
 
       for (i = 0; i < len; i++)
@@ -506,9 +449,7 @@ dcache_xfer_memory (dcache, memaddr, myaddr, len, should_write)
 }
 
 static void
-dcache_info (exp, tty)
-     char *exp;
-     int tty;
+dcache_info (char *exp, int tty)
 {
   struct dcache_block *p;
 
@@ -538,8 +479,15 @@ dcache_info (exp, tty)
     }
 }
 
+/* Turn dcache on or off. */
+void
+set_dcache_state (int what)
+{
+  dcache_enabled_p = !!what;
+}
+
 void
-_initialize_dcache ()
+_initialize_dcache (void)
 {
   add_show_from_set
     (add_set_cmd ("remotecache", class_support, var_boolean,
This page took 0.027057 seconds and 4 git commands to generate.