-/* This file is part of the program psim.
+/* The common simulator framework for GDB, the GNU Debugger.
- Copyright (C) 1994-1996, 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.
+ 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 "sim-main.h"
-#include "hw-base.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"
-/* LATER: #include "hwconfig.h" */
-extern const struct hw_device_descriptor dv_core_descriptor[];
-extern const struct hw_device_descriptor dv_pal_descriptor[];
-const struct hw_device_descriptor *hw_descriptors[] = {
- dv_core_descriptor,
- dv_pal_descriptor,
- NULL,
-};
#ifdef HAVE_STRING_H
#include <string.h>
#include <ctype.h>
+#include "hw-config.h"
+
struct hw_base_data {
int finished_p;
- const struct hw_device_descriptor *descriptor;
+ const struct hw_descriptor *descriptor;
hw_delete_callback *to_delete;
};
void *dest,
int space,
unsigned_word addr,
- unsigned nr_bytes,
- sim_cpu *processor,
- sim_cia cia)
+ unsigned nr_bytes)
{
hw_abort (me, "no io-read method");
return 0;
const void *source,
int space,
unsigned_word addr,
- unsigned nr_bytes,
- sim_cpu *processor,
- sim_cia cia)
+ unsigned nr_bytes)
{
hw_abort (me, "no io-write method");
return 0;
violate_read_only_section);
}
-const struct hw_port_descriptor empty_hw_ports[] = {
- { NULL, },
-};
-
-static void
-panic_hw_port_event (struct hw *me,
- int my_port,
- struct hw *source,
- int source_port,
- int level,
- sim_cpu *processor,
- sim_cia cia)
-{
- hw_abort (me, "no port method");
-}
-
static void
ignore_hw_delete (struct hw *me)
{
/* return it usefully */
if (buf == full_name)
- buf = (char *) strdup (full_name);
+ buf = hw_strdup (leaf, full_name);
return buf;
}
struct hw *
-hw_create (SIM_DESC sd,
+hw_create (struct sim_state *sd,
struct hw *parent,
const char *family,
const char *name,
struct hw *hw = ZALLOC (struct hw);
/* our identity */
- hw->family_of_hw = family;
- hw->name_of_hw = name;
- hw->args_of_hw = args;
+ hw->family_of_hw = hw_strdup (hw, family);
+ hw->name_of_hw = hw_strdup (hw, name);
+ hw->args_of_hw = hw_strdup (hw, args);
/* a hook into the system */
if (sd != NULL)
/* locate a descriptor */
{
- const struct hw_device_descriptor **table;
+ const struct hw_descriptor **table;
for (table = hw_descriptors;
*table != NULL;
table++)
{
- const struct hw_device_descriptor *entry;
+ const struct hw_descriptor *entry;
for (entry = *table;
entry->family != NULL;
entry++)
if (strcmp (family, entry->family) == 0)
{
hw->base_of_hw->descriptor = entry;
+ break;
}
}
}
}
/* Attach dummy ports */
- set_hw_ports (hw, empty_hw_ports);
- set_hw_port_event (hw, panic_hw_port_event);
+ create_hw_alloc_data (hw);
+ create_hw_property_data (hw);
+ create_hw_port_data (hw);
+ create_hw_event_data (hw);
+ create_hw_handle_data (hw);
+ create_hw_instance_data (hw);
return hw;
}
/* Fill in the (hopefully) defined trace variable */
if (hw_find_property (me, "trace?") != NULL)
me->trace_of_hw_p = hw_find_boolean_property (me, "trace?");
+ /* allow global variable to define default tracing */
+ else if (! hw_trace_p (me)
+ && hw_find_property (hw_root (me), "global-trace?") != NULL
+ && hw_find_boolean_property (hw_root (me), "global-trace?"))
+ me->trace_of_hw_p = 1;
+
/* Allow the real device to override any methods */
me->base_of_hw->descriptor->to_finish (me);
/* give the object a chance to tidy up */
me->base_of_hw->to_delete (me);
+ delete_hw_instance_data (me);
+ delete_hw_handle_data (me);
+ delete_hw_event_data (me);
+ delete_hw_port_data (me);
+ delete_hw_property_data (me);
+
/* now unlink us from the tree */
if (hw_parent (me))
{
}
/* blow away all memory belonging to the device */
- hw_free_all (me);
+ delete_hw_alloc_data (me);
/* finally */
- zfree (me->base_of_hw);
zfree (me);
}
+void
+set_hw_delete (struct hw *hw, hw_delete_callback method)
+{
+ hw->base_of_hw->to_delete = method;
+}
+
/* Go through the devices various reg properties for those that
specify attach addresses */