Update copyright year range in all GDB files
[external/binutils.git] / sim / ppc / device.c
index 7d69c3f..d5093bb 100644 (file)
@@ -1,10 +1,10 @@
 /*  This file is part of the program psim.
 
-    Copyright (C) 1994-1996, Andrew Cagney <cagney@highland.com.au>
+    Copyright (C) 1994-1997, Andrew Cagney <cagney@highland.com.au>
 
     This program is free software; you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
-    the Free Software Foundation; either version 2 of the License, or
+    the Free Software Foundation; either version 3 of the License, or
     (at your option) any later version.
 
     This program is distributed in the hope that it will be useful,
@@ -13,8 +13,7 @@
     GNU General Public License for more details.
  
     You should have received a copy of the GNU General Public License
-    along with this program; if not, write to the Free Software
-    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+    along with this program; if not, see <http://www.gnu.org/licenses/>.
  
     */
 
@@ -101,7 +100,7 @@ detach_device_interrupt_edge(device *me,
       if (old_edge->disposition == permenant_object)
        device_error(me, "attempt to delete permenant interrupt");
       *list = old_edge->next;
-      zfree(old_edge);
+      free(old_edge);
       return;
     }
   }
@@ -120,7 +119,7 @@ clean_device_interrupt_edges(device_interrupt_edge **list)
       break;
     case tempoary_object:
       *list = old_edge->next;
-      zfree(old_edge);
+      free(old_edge);
       break;
     }
   }
@@ -590,9 +589,9 @@ device_instance_delete(device_instance *instance)
     device_error(me, "no delete method");
   instance->callback->delete(instance);
   if (instance->args != NULL)
-    zfree(instance->args);
+    free(instance->args);
   if (instance->path != NULL)
-    zfree(instance->path);
+    free(instance->path);
   if (instance->child == NULL) {
     /* only remove leaf nodes */
     device_instance **curr = &me->instances;
@@ -614,7 +613,7 @@ device_instance_delete(device_instance *instance)
     instance->child->parent = NULL;
   }
   cap_remove(me->ihandles, instance);
-  zfree(instance);
+  free(instance);
 }
 
 INLINE_DEVICE\
@@ -768,7 +767,6 @@ device_add_property(device *me,
     new_entry->sizeof_init_array = sizeof_init_array;
   }
   new_entry->value = new_value;
-
 }
 
 
@@ -792,7 +790,7 @@ device_set_property(device *me,
       device_error(me, "conflict between type of new and old value for property %s", property);
     /* replace its value */
     if (value->array != NULL)
-      zfree((void*)value->array);
+      free((void*)value->array);
     new_array = (sizeof_array > 0
                 ? zalloc(sizeof_array)
                 : (void*)0);
@@ -823,7 +821,7 @@ clean_device_properties(device *me)
       /* zap the current value, will be initialized later */
       ASSERT(current->init_array != NULL);
       if (current->value->array != NULL) {
-       zfree((void*)current->value->array);
+       free((void*)current->value->array);
        current->value->array = NULL;
       }
       delete_point = &(*delete_point)->next;
@@ -833,9 +831,9 @@ clean_device_properties(device *me)
       ASSERT(current->init_array == NULL);
       *delete_point = current->next;
       if (current->value->array != NULL)
-       zfree((void*)current->value->array);
-      zfree(current->value);
-      zfree(current);
+       free((void*)current->value->array);
+      free(current->value);
+      free(current);
       break;
     }
   }
@@ -894,9 +892,7 @@ device_init_runtime_properties(device *me,
          ASSERT(property->init_array != NULL);
          ASSERT(property->value->array == NULL);
          device_find_ihandle_runtime_property(me, property->value->name, &spec);
-         ihandle = device_create_instance(spec.phandle, 
-                                          spec.full_path,
-                                          spec.args);
+         ihandle = tree_instance(me, spec.full_path);
          device_set_ihandle_property(me, property->value->name, ihandle);
          break;
        }
@@ -1034,37 +1030,9 @@ device_add_ihandle_runtime_property(device *me,
                                    const char *property,
                                    const ihandle_runtime_property_spec *ihandle)
 {
-  unsigned_cell *cells;
-  char *chp;
-  unsigned sizeof_cells = (sizeof(unsigned_cell) * 3
-                          + (strlen(ihandle->full_path) + 1)
-                          + (ihandle->args != NULL
-                             ? (strlen(ihandle->args) + 1)
-                             : 0));
-
-  /* the basics */
-  cells = zalloc(sizeof_cells);
-  cells[0] = H2BE_cell(device_to_external(ihandle->phandle));
-  cells[1] = (ihandle->full_path == NULL ? 0 : -1);
-  cells[2] = (ihandle->args == NULL ? 0 : -1);
-  chp = (char*)&cells[3];
-
-  /* the full path (if present) */
-  if (ihandle->full_path != NULL) {
-    strcpy(chp, ihandle->full_path);
-    chp += strlen(ihandle->full_path) + 1;
-  }
-
-  /* the args (if present) */
-  if (ihandle->args != NULL) {
-    strcpy(chp, ihandle->args);
-    chp += strlen(ihandle->args) + 1;
-  }
-
-  /* add it */
-  ASSERT(sizeof_cells == (chp - (char*)cells));
+  /* enter the full path as the init array */
   device_add_property(me, property, ihandle_property,
-                     cells, sizeof_cells,
+                     ihandle->full_path, strlen(ihandle->full_path) + 1,
                      NULL, 0,
                      NULL, permenant_object);
 }
@@ -1075,8 +1043,6 @@ device_find_ihandle_runtime_property(device *me,
                                     const char *property,
                                     ihandle_runtime_property_spec *ihandle)
 {
-  const unsigned_cell *cells;
-  const char *chp;
   device_property_entry *entry = find_property_entry(me, property);
   TRACE(trace_devices,
        ("device_find_ihandle_runtime_property(me=0x%lx, property=%s)\n",
@@ -1085,29 +1051,9 @@ device_find_ihandle_runtime_property(device *me,
       || entry->value->type != ihandle_property
       || entry->value->disposition != permenant_object)
     device_error(me, "property %s not found or of wrong type", property);
-  cells = entry->init_array;
-  chp = (char*)&cells[3];
   ASSERT(entry->init_array != NULL);
-  /* the device to be opened */
-  ihandle->phandle = external_to_device(me, BE2H_cell(cells[0]));
   /* the full path */
-  if (cells[1] != 0) {
-    ihandle->full_path = chp;
-    chp += strlen(ihandle->full_path) + 1;
-  }
-  else
-    ihandle->full_path = NULL;
-  /* the args */
-  if (cells[2] != 0) {
-    ihandle->args = chp;
-    chp += strlen(ihandle->args) + 1;
-  }
-  else
-    ihandle->args = NULL;
-  /* reached the end? */
-  ASSERT(entry->sizeof_init_array
-        == (chp - (char*)cells));
-  return;
+  ihandle->full_path = entry->init_array;
 }
 
 
@@ -1292,7 +1238,7 @@ device_add_range_array_property(device *me,
                      cells, sizeof_cells,
                      NULL, permenant_object);
 
-  zfree(cells);
+  free(cells);
 }
 
 INLINE_DEVICE\
@@ -1383,7 +1329,7 @@ device_add_reg_array_property(device *me,
                      cells, sizeof_cells,
                      NULL, permenant_object);
 
-  zfree(cells);
+  free(cells);
 }
 
 INLINE_DEVICE\
@@ -1869,7 +1815,7 @@ device_ioctl(device *me,
 /* I/O */
 
 EXTERN_DEVICE\
-(void volatile)
+(void)
 device_error(device *me,
             const char *fmt,
             ...)