diff options
Diffstat (limited to 'sim')
-rw-r--r-- | sim/common/.Sanitize | 15 | ||||
-rw-r--r-- | sim/common/ChangeLog | 18 | ||||
-rw-r--r-- | sim/common/Make-common.in | 7 | ||||
-rw-r--r-- | sim/common/dv-pal.c | 52 | ||||
-rw-r--r-- | sim/common/hw-base.c | 2 | ||||
-rw-r--r-- | sim/common/hw-base.h | 10 | ||||
-rw-r--r-- | sim/common/hw-device.h | 24 | ||||
-rw-r--r-- | sim/common/hw-events.c | 140 | ||||
-rw-r--r-- | sim/common/hw-events.h | 44 | ||||
-rw-r--r-- | sim/common/hw-ports.c | 2 | ||||
-rw-r--r-- | sim/common/hw-ports.h | 2 | ||||
-rw-r--r-- | sim/common/sim-hw.c | 59 | ||||
-rw-r--r-- | sim/mn10300/ChangeLog | 7 | ||||
-rw-r--r-- | sim/mn10300/dv-mn103cpu.c | 2 |
14 files changed, 276 insertions, 108 deletions
diff --git a/sim/common/.Sanitize b/sim/common/.Sanitize index c765b7f..c969031 100644 --- a/sim/common/.Sanitize +++ b/sim/common/.Sanitize @@ -47,6 +47,9 @@ cgen-utils.c config.in configure.in configure +dv-core.c +dv-glue.c +dv-pal.c dv-sockser.c dv-sockser.h gdbinit.in @@ -54,6 +57,18 @@ genmloop.sh gennltvals.sh gentmap.c gentvals.sh +hw-base.c +hw-base.h +hw-device.c +hw-device.h +hw-events.c +hw-events.h +hw-ports.c +hw-ports.h +hw-properties.c +hw-properties.h +hw-tree.c +hw-tree.h nltvals.def nrun.c run.c diff --git a/sim/common/ChangeLog b/sim/common/ChangeLog index d8e1cea..1e32237 100644 --- a/sim/common/ChangeLog +++ b/sim/common/ChangeLog @@ -1,3 +1,21 @@ +Mon May 25 17:14:27 1998 Andrew Cagney <cagney@b1.cygnus.com> + + * dv-pal.c: Update. + + * hw-events.h, hw-events.c: New files. Move event code to here. + * sim-hw.c: From here. + * hw-base.h: Include "hw-events.h". + + * hw-device.h (struct hw): Add struct hw_event_data events_of_hw. + * hw-events.h (struct hw_event): Replace typedef hw_event. + + * hw-base.h (create_hw_event_data, delete_hw_event_data): Declare. + * hw-base.c (hw_create, hw_delete): Call. + * hw-events.c (create_hw_event_data, delete_hw_event_data): Define. + + * Make-common.in (SIM_NEW_COMMON_OBJS): Add hw-events.o. + (hw-events.o): New target. + Mon May 25 16:55:16 1998 Andrew Cagney <cagney@b1.cygnus.com> * hw-base.c (panic_hw_port_event, empty_hw_ports): Move from here. diff --git a/sim/common/Make-common.in b/sim/common/Make-common.in index aab6708..23763e1 100644 --- a/sim/common/Make-common.in +++ b/sim/common/Make-common.in @@ -143,6 +143,7 @@ SIM_EXTRA_CLEAN = SIM_COMMON_HW_OBJS = \ hw-device.o \ + hw-events.o \ hw-ports.o \ hw-properties.o \ hw-base.o \ @@ -315,6 +316,7 @@ sim-signal_h = $(srccom)/sim-signal.h hw-base_h = $(srccom)/hw-base.h hw-device_h = $(srccom)/hw-device.h +hw-events_h = $(srccom)/hw-events.h hw-handles_h = #$(srccom)/hw-handles.h hw-instances_h = #$(srccom)/hw-instances.h hw-ports_h = $(srccom)/hw-ports.h @@ -324,6 +326,7 @@ hw-tree_h = $(srccom)/hw-tree.h hw_base_headers = \ $(hw-base_h) \ $(hw-device_h) \ + $(hw-events_h) \ $(hw-instances_h) \ $(hw-handles_h) \ $(hw-ports_h) \ @@ -477,6 +480,10 @@ hw-device.o: $(srccom)/hw-device.c $(sim_main_headers) \ $(hw-device_h) $(CC) -c $(srccom)/hw-device.c $(ALL_CFLAGS) +hw-events.o: $(srccom)/hw-events.c $(sim_main_headers) \ + $(hw-events_h) + $(CC) -c $(srccom)/hw-events.c $(ALL_CFLAGS) + hw-instances.o: $(srccom)/hw-instances.c $(sim_main_headers) \ $(hw_base_headers) $(CC) -c $(srccom)/hw-instances.c $(ALL_CFLAGS) diff --git a/sim/common/dv-pal.c b/sim/common/dv-pal.c index 4f19ff3..a696d39 100644 --- a/sim/common/dv-pal.c +++ b/sim/common/dv-pal.c @@ -128,6 +128,11 @@ Specify the address (within the parent bus) that this device is to be located. + poll? = <boolean> + + If present and true, indicates that the device should poll its + input. + PORTS @@ -170,7 +175,7 @@ enum { hw_pal_countdown_value = 0x24, hw_pal_timer = 0x28, hw_pal_timer_value = 0x2c, - hw_pal_address_mask = 0x2f, + hw_pal_address_mask = 0x3f, }; @@ -180,7 +185,7 @@ typedef struct _hw_pal_console_buffer { } hw_pal_console_buffer; typedef struct _hw_pal_counter { - hw_event *handler; + struct hw_event *handler; signed64 start; unsigned32 delta; int periodic_p; @@ -193,6 +198,7 @@ typedef struct _hw_pal_device { hw_pal_counter countdown; hw_pal_counter timer; struct hw *disk; + do_hw_poll_read_method *reader; } hw_pal_device; enum { @@ -220,14 +226,14 @@ do_counter_event (struct hw *me, { HW_TRACE ((me, "timer expired")); counter->start = hw_event_queue_time (me); - hw_port_event (me, TIMER_PORT, 1, NULL, NULL_CIA); + hw_port_event (me, TIMER_PORT, 1); hw_event_queue_schedule (me, counter->delta, do_counter_event, counter); } else { HW_TRACE ((me, "countdown expired")); counter->delta = 0; - hw_port_event (me, COUNTDOWN_PORT, 1, NULL, NULL_CIA); + hw_port_event (me, COUNTDOWN_PORT, 1); } } @@ -296,17 +302,14 @@ do_counter_write (struct hw *me, static void scan_hw_pal (struct hw *me) { -#if 0 - hw_pal_struct hw *hw_pal = (hw_pal_struct hw *) hw_data (me); -#endif + hw_pal_device *hw_pal = (hw_pal_device *)hw_data (me); char c; int count; - count = sim_io_read_stdin (hw_system (me), &c, sizeof(c)); -#if 0 + count = do_hw_poll_read (me, hw_pal->reader, 0/*STDIN*/, &c, sizeof(c)); switch (count) { - case sim_io_not_ready: - case sim_io_eof: + case HW_IO_NOT_READY: + case HW_IO_EOF: hw_pal->input.buffer = 0; hw_pal->input.status = 0; break; @@ -314,7 +317,6 @@ scan_hw_pal (struct hw *me) hw_pal->input.buffer = c; hw_pal->input.status = 1; } -#endif } /* write the character to the hw_pal */ @@ -337,9 +339,7 @@ hw_pal_io_read_buffer (struct hw *me, void *dest, int space, unsigned_word addr, - unsigned nr_bytes, - sim_cpu *cpu, - sim_cia cia) + unsigned nr_bytes) { hw_pal_device *hw_pal = (hw_pal_device *) hw_data (me); unsigned_1 *byte = (unsigned_1 *) dest; @@ -349,7 +349,7 @@ hw_pal_io_read_buffer (struct hw *me, case hw_pal_cpu_nr_register: #ifdef CPU_INDEX - *byte = CPU_INDEX (cpu); + *byte = CPU_INDEX (hw_system_cpu (me)); #else *byte = 0; #endif @@ -424,9 +424,7 @@ hw_pal_io_write_buffer (struct hw *me, const void *source, int space, unsigned_word addr, - unsigned nr_bytes, - sim_cpu *cpu, - sim_cia cia) + unsigned nr_bytes) { hw_pal_device *hw_pal = (hw_pal_device*) hw_data (me); unsigned_1 *byte = (unsigned_1 *) source; @@ -435,14 +433,13 @@ hw_pal_io_write_buffer (struct hw *me, { case hw_pal_reset_register: - sim_engine_halt (hw_system (me), cpu, NULL, cia, sim_exited, byte[0]); + hw_halt (me, sim_exited, byte[0]); break; case hw_pal_int_register: hw_port_event (me, INT_PORT + byte[0], /*port*/ - (nr_bytes > 1 ? byte[1] : 0), /* val */ - cpu, cia); + (nr_bytes > 1 ? byte[1] : 0)); /* val */ break; case hw_pal_read_fifo: @@ -587,7 +584,16 @@ hw_pal_finish (struct hw *hw) set_hw_ports (hw, hw_pal_ports); /* attach ourselves */ do_hw_attach_regs (hw); - + /* If so configured, enable polled input */ + if (hw_find_property (hw, "poll?") != NULL + && hw_find_boolean_property (hw, "poll?")) + { + hw_pal->reader = sim_io_poll_read; + } + else + { + hw_pal->reader = sim_io_read; + } /* tag the periodic timer */ hw_pal->timer.periodic_p = 1; } diff --git a/sim/common/hw-base.c b/sim/common/hw-base.c index e8c09f0..25b5c23 100644 --- a/sim/common/hw-base.c +++ b/sim/common/hw-base.c @@ -418,6 +418,7 @@ hw_create (struct sim_state *sd, /* Attach dummy ports */ create_hw_port_data (hw); + create_hw_event_data (hw); return hw; } @@ -469,6 +470,7 @@ hw_delete (struct hw *me) /* give the object a chance to tidy up */ me->base_of_hw->to_delete (me); + delete_hw_event_data (me); delete_hw_port_data (me); /* now unlink us from the tree */ diff --git a/sim/common/hw-base.h b/sim/common/hw-base.h index 27702c8..99d68ac 100644 --- a/sim/common/hw-base.h +++ b/sim/common/hw-base.h @@ -27,6 +27,7 @@ #include "hw-device.h" #include "hw-properties.h" +#include "hw-events.h" /* #include "hw-instances.h" */ /* #include "hw-handles.h" */ #include "hw-ports.h" @@ -140,4 +141,13 @@ extern void delete_hw_port_data (struct hw *hw); +/* EVENTS */ + +extern void create_hw_event_data +(struct hw *hw); +extern void delete_hw_event_data +(struct hw *hw); + + + #endif diff --git a/sim/common/hw-device.h b/sim/common/hw-device.h index bb46bea..558c41d 100644 --- a/sim/common/hw-device.h +++ b/sim/common/hw-device.h @@ -404,28 +404,6 @@ int hw_ioctl ...); -/* Event queue: - - Device specific versions of certain event handlers */ - -typedef struct _hw_event hw_event; -typedef void (hw_event_handler) (struct hw *me, void *data); - -hw_event *hw_event_queue_schedule -(struct hw *me, - signed64 delta_time, - hw_event_handler *handler, - void *data); - -void hw_event_queue_deschedule -(struct hw *me, - hw_event *event_to_remove); - -signed64 hw_event_queue_time -(struct hw *me); - - - /* Error reporting:: So that errors originating from devices appear in a consistent @@ -476,6 +454,7 @@ struct hw_property_data; struct hw_port_data; struct hw_base_data; struct hw_alloc_data; +struct hw_event_data; /* Finally the hardware device - keep your grubby little mits off of these internals! :-) */ @@ -531,6 +510,7 @@ struct hw { struct hw_port_data *ports_of_hw; struct hw_base_data *base_of_hw; struct hw_alloc_data *alloc_of_hw; + struct hw_event_data *events_of_hw; }; diff --git a/sim/common/hw-events.c b/sim/common/hw-events.c new file mode 100644 index 0000000..ca6d441 --- /dev/null +++ b/sim/common/hw-events.c @@ -0,0 +1,140 @@ +/* Hardware event manager. + Copyright (C) 1998 Free Software Foundation, Inc. + Contributed by Cygnus Support. + +This file is part of GDB, the GNU debugger. + +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, or (at your option) +any later version. + +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. */ + + +#include "sim-main.h" +#include "hw-base.h" + +#include "sim-events.h" + + +/* The hw-events object is implemented using sim-events */ + +struct hw_event { + void *data; + struct hw *me; + hw_event_callback *callback; + sim_event *real; + struct hw_event_data *entry; +}; + +struct hw_event_data { + struct hw_event event; + struct hw_event_data *next; + struct hw_event_data **prev; +}; + +void +create_hw_event_data (struct hw *me) +{ + /* NOP */ +} + +void +delete_hw_event_data (struct hw *me) +{ + if (me->events_of_hw != NULL) + hw_abort (me, "stray events"); +} + + +static void +delete_hw_event (struct hw *me, + struct hw_event **event) +{ + struct hw_event_data *entry = (*event)->entry; + *(entry->prev) = entry->next; + entry->next->prev = entry->prev; + (*event) = NULL; +} + + +static void +create_hw_event (struct hw *me, + struct hw_event **event) +{ + struct hw_event_data *entry = HW_ZALLOC (me, struct hw_event_data); + entry->next = me->events_of_hw; + entry->prev = &me->events_of_hw; + me->events_of_hw->prev = &entry->next; + me->events_of_hw = entry; + (*event) = &entry->event; +} + + + +/* Pass the H/W event onto the real callback */ + +static void +bounce_hw_event (SIM_DESC sd, + void *data) +{ + /* save the data */ + struct hw_event *event = (struct hw_event*)data; + struct hw *me = event->me; + void *event_data = event->data; + hw_event_callback *callback = event->callback; + hw_free (me, data); + event = NULL; + callback (me, event_data); +} + + + +/* Map onto the event functions */ + +struct hw_event * +hw_event_queue_schedule (struct hw *me, + signed64 delta_time, + hw_event_callback *callback, + void *data) +{ + struct hw_event *event; + create_hw_event (me, &event); + /* fill it in */ + event->data = data; + event->callback = callback; + 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, + struct hw_event *event_to_remove) +{ + /* remove it from the event queue */ + sim_events_deschedule (hw_system (me), + event_to_remove->real); + delete_hw_event (me, &event_to_remove); +} + + +signed64 +hw_event_queue_time (struct hw *me) +{ + return sim_events_time (hw_system (me)); +} + + diff --git a/sim/common/hw-events.h b/sim/common/hw-events.h new file mode 100644 index 0000000..2356222 --- /dev/null +++ b/sim/common/hw-events.h @@ -0,0 +1,44 @@ +/* Hardware event manager. + Copyright (C) 1998 Free Software Foundation, Inc. + Contributed by Cygnus Support. + +This file is part of GDB, the GNU debugger. + +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, or (at your option) +any later version. + +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. */ + +#ifndef HW_EVENTS_H +#define HW_EVENTS_H + +/* Event manager customized for hardware models. + + This interface is discussed further in sim-events.h. */ + +struct hw_event; +typedef void (hw_event_callback) (struct hw *me, void *data); + +struct hw_event *hw_event_queue_schedule +(struct hw *me, + signed64 delta_time, + hw_event_callback *handler, + void *data); + +void hw_event_queue_deschedule +(struct hw *me, + struct hw_event *event_to_remove); + +signed64 hw_event_queue_time +(struct hw *me); + +#endif diff --git a/sim/common/hw-ports.c b/sim/common/hw-ports.c index 4144bc7..fc28033 100644 --- a/sim/common/hw-ports.c +++ b/sim/common/hw-ports.c @@ -1,4 +1,4 @@ -/* Common hardware. +/* Hardware ports. Copyright (C) 1998 Free Software Foundation, Inc. Contributed by Andrew Cagney and Cygnus Solutions. diff --git a/sim/common/hw-ports.h b/sim/common/hw-ports.h index 79357c4..c214578 100644 --- a/sim/common/hw-ports.h +++ b/sim/common/hw-ports.h @@ -1,4 +1,4 @@ -/* Common hardware. +/* Hardware ports. Copyright (C) 1998 Free Software Foundation, Inc. Contributed by Andrew Cagney and Cygnus Solutions. diff --git a/sim/common/sim-hw.c b/sim/common/sim-hw.c index 51b7b0f..fa3ca8f 100644 --- a/sim/common/sim-hw.c +++ b/sim/common/sim-hw.c @@ -503,62 +503,3 @@ do_hw_poll_read (struct hw *me, #endif } } - - -/* 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); - /* if we are delivering an event, we don't have a CPU. */ - STATE_HW (sd)->cpu = NULL; - 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)); -} diff --git a/sim/mn10300/ChangeLog b/sim/mn10300/ChangeLog index e3e59b1..7360a73 100644 --- a/sim/mn10300/ChangeLog +++ b/sim/mn10300/ChangeLog @@ -1,8 +1,13 @@ +start-sanitize-am30 +Mon May 25 17:33:33 1998 Andrew Cagney <cagney@b1.cygnus.com> + + * dv-mn103cpu.c (struct mn103cpu): Change type of pending_handler + to struct hw_event. + Fri May 22 12:17:41 1998 Andrew Cagney <cagney@b1.cygnus.com> * configure.in (SIM_AC_OPTION_HARDWARE): Add argument "yes". -start-sanitize-am30 Wed May 6 13:29:06 1998 Andrew Cagney <cagney@b1.cygnus.com> * interp.c (sim_open): Create a polling PAL device. diff --git a/sim/mn10300/dv-mn103cpu.c b/sim/mn10300/dv-mn103cpu.c index f85ea34..cce89f4 100644 --- a/sim/mn10300/dv-mn103cpu.c +++ b/sim/mn10300/dv-mn103cpu.c @@ -107,7 +107,7 @@ struct mn103cpu_block { struct mn103cpu { struct mn103cpu_block block; - hw_event *pending_handler; + struct hw_event *pending_handler; int pending_level; int pending_nmi; int pending_reset; |