daily update
[deliverable/binutils-gdb.git] / sim / common / hw-properties.c
index a42c0c9188e29a7a9f8c538109f02eda5dd4d3fd..06312c8729a38952ec00150f4d074aae30ce08a3 100644 (file)
@@ -1,28 +1,28 @@
-/*  This file is part of the program psim.
+/* The common simulator framework for GDB, the GNU Debugger.
 
-    Copyright (C) 1994-1998, Andrew Cagney <cagney@highland.com.au>
+   Copyright 2002, 2007, 2008 Free Software Foundation, Inc.
 
-    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
-    (at your option) any later version.
+   Contributed by Andrew Cagney and Red Hat.
 
-    This program is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-    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.
-    */
+   This file is part of GDB.
 
-#include "sim-main.h"
+   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 3 of the License, or
+   (at your option) any later version.
 
-#include "hw-device.h"
-#include "hw-properties.h"
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   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, see <http://www.gnu.org/licenses/>.  */
+
+#include "hw-main.h"
+#include "hw-base.h"
+
+#include "sim-io.h"
 #include "sim-assert.h"
 
 #ifdef HAVE_STRING_H
@@ -44,6 +44,17 @@ struct hw_property_data {
   unsigned sizeof_init_array;
 };
 
+void
+create_hw_property_data (struct hw *me)
+{
+}
+
+void
+delete_hw_property_data (struct hw *me)
+{
+}
+
+
 /* Device Properties: */
 
 static struct hw_property_data *
@@ -347,9 +358,10 @@ hw_find_array_property (struct hw *me,
 {
   const struct hw_property *node;
   node = hw_find_property (me, property);
-  if (node == NULL
-      || node->type != array_property)
-    hw_abort(me, "property %s not found or of wrong type", property);
+  if (node == NULL)
+    hw_abort (me, "property \"%s\" not found", property);
+  if (node->type != array_property)
+    hw_abort (me, "property \"%s\" of wrong type (array)", property);
   return node;
 }
 
@@ -374,8 +386,10 @@ hw_find_boolean_property (struct hw *me,
   const struct hw_property *node;
   unsigned_cell boolean;
   node = hw_find_property (me, property);
-  if (node == NULL || node->type != boolean_property)
-    hw_abort (me, "property %s not found or of wrong type", property);
+  if (node == NULL)
+    hw_abort (me, "property \"%s\" not found", property);
+  if (node->type != boolean_property)
+    hw_abort (me, "property \"%s\" of wrong type (boolean)", property);
   ASSERT (sizeof (boolean) == node->sizeof_array);
   memcpy (&boolean, node->array, sizeof (boolean));
   return boolean;
@@ -407,10 +421,11 @@ hw_find_ihandle_runtime_property (struct hw *me,
   TRACE (trace_devices,
         ("hw_find_ihandle_runtime_property(me=0x%lx, property=%s)\n",
          (long)me, property));
-  if (entry == NULL
-      || entry->property->type != ihandle_property
+  if (entry == NULL)
+    hw_abort (me, "property \"%s\" not found", property);
+  if (entry->property->type != ihandle_property
       || entry->property->disposition != permenant_object)
-    hw_abort (me, "property %s not found or of wrong type", property);
+    hw_abort (me, "property \"%s\" of wrong type", property);
   ASSERT (entry->init_array != NULL);
   /* the full path */
   ihandle->full_path = entry->init_array;
@@ -443,10 +458,12 @@ hw_find_ihandle_property (struct hw *me,
   hw_instance *instance;
 
   node = hw_find_property (me, property);
-  if (node == NULL || node->type != ihandle_property)
-    hw_abort(me, "property %s not found or of wrong type", property);
+  if (node == NULL)
+    hw_abort (me, "property \"%s\" not found", property);
+  if (node->type != ihandle_property)
+    hw_abort(me, "property \"%s\" of wrong type (ihandle)", property);
   if (node->array == NULL)
-    hw_abort(me, "runtime property %s not yet initialized", property);
+    hw_abort(me, "runtime property \"%s\" not yet initialized", property);
 
   ASSERT (sizeof(ihandle) == node->sizeof_array);
   memcpy (&ihandle, node->array, sizeof(ihandle));
@@ -479,8 +496,10 @@ hw_find_integer_property (struct hw *me,
         ("hw_find_integer(me=0x%lx, property=%s)\n",
          (long)me, property));
   node = hw_find_property (me, property);
-  if (node == NULL || node->type != integer_property)
-    hw_abort (me, "property %s not found or of wrong type", property);
+  if (node == NULL)
+    hw_abort (me, "property \"%s\" not found", property);
+  if (node->type != integer_property)
+    hw_abort (me, "property \"%s\" of wrong type (integer)", property);
   ASSERT (sizeof(integer) == node->sizeof_array);
   memcpy (&integer, node->array, sizeof (integer));
   return BE2H_cell (integer);
@@ -501,12 +520,13 @@ hw_find_integer_array_property (struct hw *me,
   
   /* check things sane */
   node = hw_find_property (me, property);
-  if (node == NULL
-      || (node->type != integer_property
-         && node->type != array_property))
-    hw_abort (me, "property %s not found or of wrong type", property);
+  if (node == NULL)
+    hw_abort (me, "property \"%s\" not found", property);
+  if (node->type != integer_property
+      && node->type != array_property)
+    hw_abort (me, "property \"%s\" of wrong type (integer or array)", property);
   if ((node->sizeof_array % sizeof_integer) != 0)
-    hw_abort (me, "property %s contains an incomplete number of cells", property);
+    hw_abort (me, "property \"%s\" contains an incomplete number of cells", property);
   if (node->sizeof_array <= sizeof_integer * index)
     return 0;
   
@@ -612,12 +632,14 @@ hw_find_range_array_property (struct hw *me,
   
   /* locate the property */
   node = hw_find_property (me, property);
-  if (node == NULL || node->type != range_array_property)
-    hw_abort (me, "property %s not found or of wrong type", property);
+  if (node == NULL)
+    hw_abort (me, "property \"%s\" not found", property);
+  if (node->type != range_array_property)
+    hw_abort (me, "property \"%s\" of wrong type (range array)", property);
   
   /* aligned ? */
   if ((node->sizeof_array % sizeof_entry) != 0)
-    hw_abort (me, "property %s contains an incomplete number of entries",
+    hw_abort (me, "property \"%s\" contains an incomplete number of entries",
              property);
   
   /* within bounds? */
@@ -700,12 +722,14 @@ hw_find_reg_array_property (struct hw *me,
   
   /* locate the property */
   node = hw_find_property (me, property);
-  if (node == NULL || node->type != reg_array_property)
-    hw_abort (me, "property %s not found or of wrong type", property);
+  if (node == NULL)
+    hw_abort (me, "property \"%s\" not found", property);
+  if (node->type != reg_array_property)
+    hw_abort (me, "property \"%s\" of wrong type (reg array)", property);
   
   /* aligned ? */
   if ((node->sizeof_array % sizeof_entry) != 0)
-    hw_abort (me, "property %s contains an incomplete number of entries",
+    hw_abort (me, "property \"%s\" contains an incomplete number of entries",
              property);
   
   /* within bounds? */
@@ -745,8 +769,10 @@ hw_find_string_property (struct hw *me,
   const struct hw_property *node;
   const char *string;
   node = hw_find_property (me, property);
-  if (node == NULL || node->type != string_property)
-    hw_abort (me, "property %s not found or of wrong type", property);
+  if (node == NULL)
+    hw_abort (me, "property \"%s\" not found", property);
+  if (node->type != string_property)
+    hw_abort (me, "property \"%s\" of wrong type (string)", property);
   string = node->array;
   ASSERT (strlen(string) + 1 == node->sizeof_array);
   return string;
@@ -763,7 +789,7 @@ hw_add_string_array_property (struct hw *me,
   char *array;
   char *chp;
   if (nr_strings == 0)
-    hw_abort (me, "property %s must be non-null", property);
+    hw_abort (me, "property \"%s\" must be non-null", property);
   /* total up the size of the needed array */
   for (sizeof_array = 0, string_nr = 0;
        string_nr < nr_strings;
@@ -798,11 +824,11 @@ hw_find_string_array_property (struct hw *me,
   const struct hw_property *node;
   node = hw_find_property (me, property);
   if (node == NULL)
-    hw_abort (me, "property %s not found", property);
+    hw_abort (me, "property \"%s\" not found", property);
   switch (node->type)
     {
     default:
-      hw_abort (me, "property %s of wrong type", property);
+      hw_abort (me, "property \"%s\" of wrong type", property);
       break;
     case string_property:
       if (index == 0)
@@ -815,7 +841,7 @@ hw_find_string_array_property (struct hw *me,
     case array_property:
       if (node->sizeof_array == 0
          || ((char*)node->array)[node->sizeof_array - 1] != '\0')
-       hw_abort (me, "property %s invalid for string array", property);
+       hw_abort (me, "property \"%s\" invalid for string array", property);
       /* FALL THROUGH */
     case string_array_property:
       ASSERT (node->sizeof_array > 0);
This page took 0.026104 seconds and 4 git commands to generate.