aboutsummaryrefslogtreecommitdiff
path: root/sim
diff options
context:
space:
mode:
authorAndrew Cagney <cagney@redhat.com>1998-05-25 06:44:39 +0000
committerAndrew Cagney <cagney@redhat.com>1998-05-25 06:44:39 +0000
commitf67574471894a2e1ebfc9ba7a5b154b9735da2e9 (patch)
treece1b02af72d684fb3ad7c30bcb54b9bba5571237 /sim
parent1e1dcdf0d9200a09d86010e4ce0ea03ef72bf13c (diff)
downloadgdb-f67574471894a2e1ebfc9ba7a5b154b9735da2e9.zip
gdb-f67574471894a2e1ebfc9ba7a5b154b9735da2e9.tar.gz
gdb-f67574471894a2e1ebfc9ba7a5b154b9735da2e9.tar.bz2
* hw-device.c (hw_ioctl), hw-device.h (hw_ioctl_callback): Drop
PROCESSOR and CIA arguments.
Diffstat (limited to 'sim')
-rw-r--r--sim/common/ChangeLog5
-rw-r--r--sim/common/hw-device.c132
-rw-r--r--sim/common/hw-device.h43
3 files changed, 51 insertions, 129 deletions
diff --git a/sim/common/ChangeLog b/sim/common/ChangeLog
index ca63e97..9f0aa26 100644
--- a/sim/common/ChangeLog
+++ b/sim/common/ChangeLog
@@ -1,3 +1,8 @@
+Mon May 25 16:42:48 1998 Andrew Cagney <cagney@b1.cygnus.com>
+
+ * hw-device.c (hw_ioctl), hw-device.h (hw_ioctl_callback): Drop
+ PROCESSOR and CIA arguments.
+
Fri May 22 12:16:27 1998 Andrew Cagney <cagney@b1.cygnus.com>
* aclocal.m4 (SIM_AC_OPTION_HW): Add enable / disable argument.
diff --git a/sim/common/hw-device.c b/sim/common/hw-device.c
index 55968d8..f47ae86 100644
--- a/sim/common/hw-device.c
+++ b/sim/common/hw-device.c
@@ -43,124 +43,17 @@ hw_unit_address (struct hw *me)
int
hw_ioctl (struct hw *me,
- sim_cpu *processor,
- sim_cia cia,
hw_ioctl_request request,
...)
{
int status;
va_list ap;
va_start(ap, request);
- status = me->to_ioctl (me, processor, cia, request, ap);
+ status = me->to_ioctl (me, request, ap);
va_end(ap);
return status;
}
-/* I/O */
-
-void volatile
-hw_abort (struct hw *me,
- const char *fmt,
- ...)
-{
- SIM_DESC sd;
- const char *name;
- va_list ap;
- va_start(ap, fmt);
- /* find a system to abort through */
- if (me == NULL || hw_system (me) == NULL)
- sd = NULL;
- else
- sd = hw_system (me);
- /* find an identity */
- if (me != NULL && hw_path (me) != NULL && hw_path (me) [0] != '\0')
- name = hw_path (me);
- else if (me != NULL && hw_name (me) != NULL && hw_name (me)[0] != '\0')
- name = hw_name (me);
- else if (me != NULL && hw_family (me) != NULL && hw_family (me)[0] != '\0')
- name = hw_family (me);
- else
- name = "device";
- /* report the problem */
- sim_io_eprintf (sd, "%s: ", name);
- sim_io_evprintf (sd, fmt, ap);
- sim_io_error (sd, "%s", "");
-}
-
-void
-hw_trace (struct hw *me,
- const char *fmt,
- ...)
-{
- if (hw_trace_p (me)) /* to be sure, to be sure */
- {
- va_list ap;
- va_start (ap, fmt);
- sim_io_eprintf (hw_system (me), "%s: ", hw_path (me));
- sim_io_evprintf (hw_system (me), fmt, ap);
- sim_io_eprintf (hw_system (me), "\n");
- va_end (ap);
- }
-}
-
-
-/* The event queue abstraction (for devices) */
-
-
-struct _hw_event {
- void *data;
- struct hw *me;
- hw_event_handler *handler;
- sim_event *real;
-};
-
-/* Pass the H/W event onto the real handler */
-
-static void
-bounce_hw_event (SIM_DESC sd,
- void *data)
-{
- hw_event event = * (hw_event*) data;
- zfree (data);
- event.handler (event.me, event.data);
-}
-
-
-/* Map onto the event functions */
-
-hw_event *
-hw_event_queue_schedule (struct hw *me,
- signed64 delta_time,
- hw_event_handler *handler,
- void *data)
-{
- hw_event *event = ZALLOC (hw_event);
- event->data = data;
- event->handler = handler;
- event->me = me;
- event->real = sim_events_schedule (hw_system (me),
- delta_time,
- bounce_hw_event,
- event);
- return event;
-}
-
-void
-hw_event_queue_deschedule (struct hw *me,
- hw_event *event_to_remove)
-{
- sim_events_deschedule (hw_system (me),
- event_to_remove->real);
- zfree (event_to_remove);
-}
-
-signed64
-hw_event_queue_time (struct hw *me)
-{
- return sim_events_time (hw_system (me));
-}
-
-
/* Mechanism for associating allocated memory regions to a device.
When a device is deleted any remaining memory regions are also
reclaimed.
@@ -174,7 +67,7 @@ struct hw_alloc_data {
struct hw_alloc_data *next;
};
-extern void *
+void *
hw_zalloc (struct hw *me, unsigned long size)
{
struct hw_alloc_data *memory = ZALLOC (struct hw_alloc_data);
@@ -185,7 +78,7 @@ hw_zalloc (struct hw *me, unsigned long size)
return memory->alloc;
}
-extern void *
+void *
hw_malloc (struct hw *me, unsigned long size)
{
struct hw_alloc_data *memory = ZALLOC (struct hw_alloc_data);
@@ -196,7 +89,7 @@ hw_malloc (struct hw *me, unsigned long size)
return memory->alloc;
}
-extern void
+void
hw_free (struct hw *me,
void *alloc)
{
@@ -220,7 +113,7 @@ hw_free (struct hw *me,
hw_abort (me, "free of memory not belonging to a device");
}
-extern void
+void
hw_free_all (struct hw *me)
{
while (me->alloc_of_hw != NULL)
@@ -228,3 +121,18 @@ hw_free_all (struct hw *me)
hw_free (me, me->alloc_of_hw->alloc);
}
}
+
+char *
+hw_strdup (struct hw *me, const char *str)
+{
+ if (str != NULL)
+ {
+ char *dup = hw_zalloc (me, strlen (str) + 1);
+ strcpy (dup, str);
+ return dup;
+ }
+ else
+ {
+ return NULL;
+ }
+}
diff --git a/sim/common/hw-device.h b/sim/common/hw-device.h
index b1ef09c..bb46bea 100644
--- a/sim/common/hw-device.h
+++ b/sim/common/hw-device.h
@@ -139,7 +139,12 @@
/* Short cut back to the simulator object */
-#define hw_system(hw) ((hw)->system_of_hw + 0)
+#define hw_system(hw) ((hw)->system_of_hw)
+
+/* For requests initiated by a CPU the cpu that initiated the request */
+
+struct _sim_cpu *hw_system_cpu (struct hw *hw);
+
/* Device private data */
@@ -213,24 +218,20 @@ typedef unsigned (hw_io_read_buffer_callback)
void *dest,
int space,
unsigned_word addr,
- unsigned nr_bytes,
- sim_cpu *processor,
- sim_cia cia);
+ unsigned nr_bytes);
-#define hw_io_read_buffer(hw, dest, space, addr, nr_bytes, processor, cia) \
-((hw)->to_io_read_buffer (hw, dest, space, addr, nr_bytes, processor, cia))
+#define hw_io_read_buffer(hw, dest, space, addr, nr_bytes) \
+((hw)->to_io_read_buffer (hw, dest, space, addr, nr_bytes))
typedef unsigned (hw_io_write_buffer_callback)
(struct hw *me,
const void *source,
int space,
unsigned_word addr,
- unsigned nr_bytes,
- sim_cpu *processor,
- sim_cia cia);
+ unsigned nr_bytes);
-#define hw_io_write_buffer(hw, src, space, addr, nr_bytes, processor, cia) \
-((hw)->to_io_write_buffer (hw, src, space, addr, nr_bytes, processor, cia))
+#define hw_io_write_buffer(hw, src, space, addr, nr_bytes) \
+((hw)->to_io_write_buffer (hw, src, space, addr, nr_bytes))
@@ -367,6 +368,7 @@ extern void *hw_malloc (struct hw *me, unsigned long size);
extern void hw_free (struct hw *me, void *);
extern void hw_free_all (struct hw *me);
+extern char *hw_strdup (struct hw *me, const char *str);
/* Utilities:
@@ -393,15 +395,11 @@ typedef enum {
typedef int (hw_ioctl_callback)
(struct hw *me,
- sim_cpu *processor,
- sim_cia cia,
hw_ioctl_request request,
va_list ap);
int hw_ioctl
(struct hw *me,
- sim_cpu *processor,
- sim_cia cia,
hw_ioctl_request request,
...);
@@ -440,11 +438,22 @@ signed64 hw_event_queue_time
*/
-void volatile NORETURN hw_abort
+void hw_abort
(struct hw *me,
const char *fmt,
...) __attribute__ ((format (printf, 2, 3)));
+void hw_vabort
+(struct hw *me,
+ const char *fmt,
+ va_list ap);
+
+void hw_halt
+(struct hw *me,
+ int reason,
+ int status);
+
+
#define hw_trace_p(hw) ((hw)->trace_of_hw_p + 0)
void hw_trace
@@ -489,7 +498,7 @@ struct hw {
/* hot links */
struct hw *root_of_hw;
- SIM_DESC system_of_hw;
+ struct sim_state *system_of_hw;
/* identifying data */
hw_unit unit_address_of_hw;