* hw-device.c (hw_ioctl), hw-device.h (hw_ioctl_callback): Drop
PROCESSOR and CIA arguments.
This commit is contained in:
parent
1e1dcdf0d9
commit
f675744718
|
@ -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>
|
Fri May 22 12:16:27 1998 Andrew Cagney <cagney@b1.cygnus.com>
|
||||||
|
|
||||||
* aclocal.m4 (SIM_AC_OPTION_HW): Add enable / disable argument.
|
* aclocal.m4 (SIM_AC_OPTION_HW): Add enable / disable argument.
|
||||||
|
|
|
@ -43,124 +43,17 @@ hw_unit_address (struct hw *me)
|
||||||
|
|
||||||
int
|
int
|
||||||
hw_ioctl (struct hw *me,
|
hw_ioctl (struct hw *me,
|
||||||
sim_cpu *processor,
|
|
||||||
sim_cia cia,
|
|
||||||
hw_ioctl_request request,
|
hw_ioctl_request request,
|
||||||
...)
|
...)
|
||||||
{
|
{
|
||||||
int status;
|
int status;
|
||||||
va_list ap;
|
va_list ap;
|
||||||
va_start(ap, request);
|
va_start(ap, request);
|
||||||
status = me->to_ioctl (me, processor, cia, request, ap);
|
status = me->to_ioctl (me, request, ap);
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
return status;
|
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.
|
/* Mechanism for associating allocated memory regions to a device.
|
||||||
When a device is deleted any remaining memory regions are also
|
When a device is deleted any remaining memory regions are also
|
||||||
reclaimed.
|
reclaimed.
|
||||||
|
@ -174,7 +67,7 @@ struct hw_alloc_data {
|
||||||
struct hw_alloc_data *next;
|
struct hw_alloc_data *next;
|
||||||
};
|
};
|
||||||
|
|
||||||
extern void *
|
void *
|
||||||
hw_zalloc (struct hw *me, unsigned long size)
|
hw_zalloc (struct hw *me, unsigned long size)
|
||||||
{
|
{
|
||||||
struct hw_alloc_data *memory = ZALLOC (struct hw_alloc_data);
|
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;
|
return memory->alloc;
|
||||||
}
|
}
|
||||||
|
|
||||||
extern void *
|
void *
|
||||||
hw_malloc (struct hw *me, unsigned long size)
|
hw_malloc (struct hw *me, unsigned long size)
|
||||||
{
|
{
|
||||||
struct hw_alloc_data *memory = ZALLOC (struct hw_alloc_data);
|
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;
|
return memory->alloc;
|
||||||
}
|
}
|
||||||
|
|
||||||
extern void
|
void
|
||||||
hw_free (struct hw *me,
|
hw_free (struct hw *me,
|
||||||
void *alloc)
|
void *alloc)
|
||||||
{
|
{
|
||||||
|
@ -220,7 +113,7 @@ hw_free (struct hw *me,
|
||||||
hw_abort (me, "free of memory not belonging to a device");
|
hw_abort (me, "free of memory not belonging to a device");
|
||||||
}
|
}
|
||||||
|
|
||||||
extern void
|
void
|
||||||
hw_free_all (struct hw *me)
|
hw_free_all (struct hw *me)
|
||||||
{
|
{
|
||||||
while (me->alloc_of_hw != NULL)
|
while (me->alloc_of_hw != NULL)
|
||||||
|
@ -228,3 +121,18 @@ hw_free_all (struct hw *me)
|
||||||
hw_free (me, me->alloc_of_hw->alloc);
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -139,7 +139,12 @@
|
||||||
|
|
||||||
/* Short cut back to the simulator object */
|
/* 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 */
|
/* Device private data */
|
||||||
|
|
||||||
|
@ -213,24 +218,20 @@ typedef unsigned (hw_io_read_buffer_callback)
|
||||||
void *dest,
|
void *dest,
|
||||||
int space,
|
int space,
|
||||||
unsigned_word addr,
|
unsigned_word addr,
|
||||||
unsigned nr_bytes,
|
unsigned nr_bytes);
|
||||||
sim_cpu *processor,
|
|
||||||
sim_cia cia);
|
|
||||||
|
|
||||||
#define hw_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, processor, cia))
|
((hw)->to_io_read_buffer (hw, dest, space, addr, nr_bytes))
|
||||||
|
|
||||||
typedef unsigned (hw_io_write_buffer_callback)
|
typedef unsigned (hw_io_write_buffer_callback)
|
||||||
(struct hw *me,
|
(struct hw *me,
|
||||||
const void *source,
|
const void *source,
|
||||||
int space,
|
int space,
|
||||||
unsigned_word addr,
|
unsigned_word addr,
|
||||||
unsigned nr_bytes,
|
unsigned nr_bytes);
|
||||||
sim_cpu *processor,
|
|
||||||
sim_cia cia);
|
|
||||||
|
|
||||||
#define hw_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, processor, cia))
|
((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 (struct hw *me, void *);
|
||||||
extern void hw_free_all (struct hw *me);
|
extern void hw_free_all (struct hw *me);
|
||||||
|
|
||||||
|
extern char *hw_strdup (struct hw *me, const char *str);
|
||||||
|
|
||||||
|
|
||||||
/* Utilities:
|
/* Utilities:
|
||||||
|
@ -393,15 +395,11 @@ typedef enum {
|
||||||
|
|
||||||
typedef int (hw_ioctl_callback)
|
typedef int (hw_ioctl_callback)
|
||||||
(struct hw *me,
|
(struct hw *me,
|
||||||
sim_cpu *processor,
|
|
||||||
sim_cia cia,
|
|
||||||
hw_ioctl_request request,
|
hw_ioctl_request request,
|
||||||
va_list ap);
|
va_list ap);
|
||||||
|
|
||||||
int hw_ioctl
|
int hw_ioctl
|
||||||
(struct hw *me,
|
(struct hw *me,
|
||||||
sim_cpu *processor,
|
|
||||||
sim_cia cia,
|
|
||||||
hw_ioctl_request request,
|
hw_ioctl_request request,
|
||||||
...);
|
...);
|
||||||
|
|
||||||
|
@ -440,11 +438,22 @@ signed64 hw_event_queue_time
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void volatile NORETURN hw_abort
|
void hw_abort
|
||||||
(struct hw *me,
|
(struct hw *me,
|
||||||
const char *fmt,
|
const char *fmt,
|
||||||
...) __attribute__ ((format (printf, 2, 3)));
|
...) __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)
|
#define hw_trace_p(hw) ((hw)->trace_of_hw_p + 0)
|
||||||
|
|
||||||
void hw_trace
|
void hw_trace
|
||||||
|
@ -489,7 +498,7 @@ struct hw {
|
||||||
|
|
||||||
/* hot links */
|
/* hot links */
|
||||||
struct hw *root_of_hw;
|
struct hw *root_of_hw;
|
||||||
SIM_DESC system_of_hw;
|
struct sim_state *system_of_hw;
|
||||||
|
|
||||||
/* identifying data */
|
/* identifying data */
|
||||||
hw_unit unit_address_of_hw;
|
hw_unit unit_address_of_hw;
|
||||||
|
|
Loading…
Reference in New Issue