diff options
author | Frank Ch. Eigler <fche@redhat.com> | 1998-12-30 12:09:13 +0000 |
---|---|---|
committer | Frank Ch. Eigler <fche@redhat.com> | 1998-12-30 12:09:13 +0000 |
commit | 617ca17ed2a92af9e9b8cc0ed5ac8cf04fc99f43 (patch) | |
tree | 09ad8c106b0b8d13747ea63ac1075877827e01e9 /sim/common | |
parent | d846c99ee4c5906a6b6bb7fdc56485fec4a1cece (diff) | |
download | ppe42-binutils-617ca17ed2a92af9e9b8cc0ed5ac8cf04fc99f43.tar.gz ppe42-binutils-617ca17ed2a92af9e9b8cc0ed5ac8cf04fc99f43.zip |
* eCos->devo merge
1998-12-24 Frank Ch. Eigler <fche@cygnus.com>
* dv-sockser.c (DEFAULT_TIMEOUT): Increase to 1 ms.
* nrun.c (main): Remain in simulation loop for traps and
exceptions when in operating environment mode.
(ui_loop_hook): New stub hook for standalone use.
* sim-events.c (sim_events_process): Call ui_loop_hook
periodically on CYGWIN host.
* sim-reason.c (sim_stop_reason): Return host signal numbers
to gdb on sim_stopped and sim_signalled cases.
* sim-engine.c (sim_engine_halt): Call SIM_CPU_EXCEPTION_SUSPEND
hook just before longjmp.
* sim-resume.c (sim_resume): Call SIM_CPU_EXCEPTION_RESUME
hook just before sim_engine_run.
* sim-n-core.h (sim_core_trace_M): Allay const warning.
* sim-trace.h (trace_generic): Ditto.
* sim-trace.c (trace_generic): Ditto.
Diffstat (limited to 'sim/common')
-rw-r--r-- | sim/common/ChangeLog | 32 | ||||
-rw-r--r-- | sim/common/sim-events.c | 199 |
2 files changed, 179 insertions, 52 deletions
diff --git a/sim/common/ChangeLog b/sim/common/ChangeLog index bbe82ca9aa..38917cc8cc 100644 --- a/sim/common/ChangeLog +++ b/sim/common/ChangeLog @@ -1,3 +1,33 @@ +1998-12-24 Frank Ch. Eigler <fche@cygnus.com> + + * dv-sockser.c (DEFAULT_TIMEOUT): Increase to 1 ms. + + * nrun.c (main): Remain in simulation loop for traps and + exceptions when in operating environment mode. + (ui_loop_hook): New stub hook for standalone use. + * sim-events.c (sim_events_process): Call ui_loop_hook + periodically on CYGWIN host. + * sim-engine.c (sim_engine_halt): Call SIM_CPU_EXCEPTION_SUSPEND + hook just before longjmp. + * sim-resume.c (sim_resume): Call SIM_CPU_EXCEPTION_RESUME + hook just before sim_engine_run. + + * sim-n-core.h (sim_core_trace_M): Allay const warning. + * sim-trace.h (trace_generic): Ditto. + * sim-trace.c (trace_generic): Ditto. + + * sim-reason.c (sim_stop_reason): Return host signal numbers + to gdb on sim_stopped and sim_signalled cases. + +1998-12-14 Doug Evans <devans@casey.cygnus.com> + + * Make-common.in (SIM_MAIN_DEPS): New var. + (CGEN_MAIN_CPU_DEPS): New var. + * aclocal.m4: Add --enable-cgen-maint option. + * cgen-mem.h (GETMEM*): New arg `pc'. Pass to sim_core routine. + (SETMEM*): Ditto. + (GETIMEM*): Pass pc value to sim_core routine. + Fri Dec 11 16:58:36 1998 Andrew Cagney <cagney@b1.cygnus.com> * hw-handles.c (hw_handle_add_ihandle, hw_handle_add_phandle): @@ -3871,5 +3901,3 @@ Tue Oct 10 12:03:13 1995 J.T. Conklin <jtc@rtl.cygnus.com> Thu Sep 28 15:40:36 1995 steve chamberlain <sac@slash.cygnus.com> * run.c, run.1: From sh directory. - - diff --git a/sim/common/sim-events.c b/sim/common/sim-events.c index c70fc34946..000ba6db7c 100644 --- a/sim/common/sim-events.c +++ b/sim/common/sim-events.c @@ -33,8 +33,20 @@ #endif #endif -#include <signal.h> +#ifdef HAVE_STDLIB_H +#include <stdlib.h> +#endif + +#include <signal.h> /* For SIGPROCMASK et.al. */ + +#if __CYGWIN32__ +/* The ui_loop_hook is called to keep the GUI alive while the simulator + is running. The counter is to make sure we do not wake it too often. +*/ +extern void (*ui_loop_hook) PARAMS ((int)); +static unsigned int ui_loop_hook_counter = 0; +#endif typedef enum { watch_invalid, @@ -89,7 +101,7 @@ struct _sim_event { unsigned wallclock; /* watch core address */ address_word core_addr; - sim_core_maps core_map; + unsigned core_map; /* watch sim addr */ void *host_addr; /* watch core/sim range */ @@ -98,6 +110,8 @@ struct _sim_event { unsigned lb; unsigned64 ub64; unsigned64 lb64; + /* trace info (if any) */ + char *trace; /* list */ sim_event *next; }; @@ -134,19 +148,22 @@ struct _sim_event { #define _ETRACE sd, NULL +#undef ETRACE_P +#define ETRACE_P (WITH_TRACE && STATE_EVENTS (sd)->trace) + #undef ETRACE #define ETRACE(ARGS) \ do \ { \ - if (WITH_TRACE) \ + if (ETRACE_P) \ { \ - if (STATE_EVENTS (sd)->trace) \ - { \ - const char *file; \ - SIM_FILTER_PATH (file, __FILE__); \ - trace_printf (sd, NULL, "%s:%d: ", file, __LINE__); \ - trace_printf ARGS; \ - } \ + if (STRACE_DEBUG_P (sd)) \ + { \ + const char *file; \ + SIM_FILTER_PATH (file, __FILE__); \ + trace_printf (sd, NULL, "%s:%d: ", file, __LINE__); \ + } \ + trace_printf ARGS; \ } \ } \ while (0) @@ -154,8 +171,8 @@ while (0) /* event queue iterator - don't iterate over the held queue. */ -STATIC_INLINE_SIM_EVENTS\ -(sim_event **) +#if EXTERN_SIM_EVENTS_P +static sim_event ** next_event_queue (SIM_DESC sd, sim_event **queue) { @@ -171,6 +188,7 @@ next_event_queue (SIM_DESC sd, sim_io_error (sd, "next_event_queue - bad queue"); return NULL; } +#endif STATIC_INLINE_SIM_EVENTS\ @@ -188,13 +206,15 @@ sim_events_poll (SIM_DESC sd, This is called via sim_module_install to install the "events" subsystem into the simulator. */ +#if EXTERN_SIM_EVENTS_P STATIC_SIM_EVENTS (MODULE_UNINSTALL_FN) sim_events_uninstall; STATIC_SIM_EVENTS (MODULE_INIT_FN) sim_events_init; STATIC_SIM_EVENTS (MODULE_RESUME_FN) sim_events_resume; STATIC_SIM_EVENTS (MODULE_SUSPEND_FN) sim_events_suspend; +#endif -EXTERN_SIM_EVENTS\ -(SIM_RC) +#if EXTERN_SIM_EVENTS_P +SIM_RC sim_events_install (SIM_DESC sd) { SIM_ASSERT (STATE_MAGIC (sd) == SIM_MAGIC_NUMBER); @@ -204,13 +224,14 @@ sim_events_install (SIM_DESC sd) sim_module_add_suspend_fn (sd, sim_events_suspend); return SIM_RC_OK; } +#endif /* Suspend/resume the event queue manager when the simulator is not running */ -STATIC_SIM_EVENTS\ -(SIM_RC) +#if EXTERN_SIM_EVENTS_P +static SIM_RC sim_events_resume (SIM_DESC sd) { sim_events *events = STATE_EVENTS (sd); @@ -219,9 +240,10 @@ sim_events_resume (SIM_DESC sd) events->resume_wallclock = sim_elapsed_time_get (); return SIM_RC_OK; } +#endif -STATIC_SIM_EVENTS\ -(SIM_RC) +#if EXTERN_SIM_EVENTS_P +static SIM_RC sim_events_suspend (SIM_DESC sd) { sim_events *events = STATE_EVENTS (sd); @@ -231,23 +253,25 @@ sim_events_suspend (SIM_DESC sd) events->resume_wallclock = 0; return SIM_RC_OK; } +#endif /* Uninstall the "events" subsystem from the simulator. */ -STATIC_SIM_EVENTS\ -(void) +#if EXTERN_SIM_EVENTS_P +static void sim_events_uninstall (SIM_DESC sd) { SIM_ASSERT (STATE_MAGIC (sd) == SIM_MAGIC_NUMBER); /* FIXME: free buffers, etc. */ } +#endif /* malloc/free */ -STATIC_INLINE_SIM_EVENTS\ -(sim_event *) +#if EXTERN_SIM_EVENTS_P +static sim_event * sim_events_zalloc (SIM_DESC sd) { sim_events *events = STATE_EVENTS (sd); @@ -274,6 +298,7 @@ sim_events_zalloc (SIM_DESC sd) } return new; } +#endif STATIC_INLINE_SIM_EVENTS\ (void) @@ -283,13 +308,18 @@ sim_events_free (SIM_DESC sd, sim_events *events = STATE_EVENTS (sd); dead->next = events->free_list; events->free_list = dead; + if (dead->trace != NULL) + { + free (dead->trace); /* NB: asprintf returns a `free' buf */ + dead->trace = NULL; + } } /* Initialize the simulator event manager */ -EXTERN_SIM_EVENTS\ -(SIM_RC) +#if EXTERN_SIM_EVENTS_P +SIM_RC sim_events_init (SIM_DESC sd) { sim_events *events = STATE_EVENTS (sd); @@ -297,7 +327,7 @@ sim_events_init (SIM_DESC sd) /* drain the interrupt queue */ events->nr_held = 0; if (events->held == NULL) - events->held = zalloc (sizeof (sim_event) * MAX_NR_SIGNAL_SIM_EVENTS); + events->held = NZALLOC (sim_event, MAX_NR_SIGNAL_SIM_EVENTS); /* drain the normal queues */ { @@ -331,6 +361,7 @@ sim_events_init (SIM_DESC sd) return SIM_RC_OK; } +#endif INLINE_SIM_EVENTS\ @@ -346,8 +377,14 @@ INLINE_SIM_EVENTS\ (unsigned long) sim_events_elapsed_time (SIM_DESC sd) { - return (sim_elapsed_time_since (STATE_EVENTS (sd)->resume_wallclock) - + STATE_EVENTS (sd)->elapsed_wallclock); + unsigned long elapsed = STATE_EVENTS (sd)->elapsed_wallclock; + + /* Are we being called inside sim_resume? + (Is there a simulation in progress?) */ + if (STATE_EVENTS (sd)->resume_wallclock != 0) + elapsed += sim_elapsed_time_since (STATE_EVENTS (sd)->resume_wallclock); + + return elapsed; } @@ -371,8 +408,8 @@ update_time_from_event (SIM_DESC sd) } -STATIC_INLINE_SIM_EVENTS\ -(void) +#if EXTERN_SIM_EVENTS_P +static void insert_sim_event (SIM_DESC sd, sim_event *new_event, signed64 delta) @@ -408,33 +445,72 @@ insert_sim_event (SIM_DESC sd, /* adjust the time until the first event */ update_time_from_event (sd); } +#endif -EXTERN_SIM_EVENTS\ -(sim_event *) +#if EXTERN_SIM_EVENTS_P +sim_event * sim_events_schedule (SIM_DESC sd, signed64 delta_time, sim_event_handler *handler, void *data) { + return sim_events_schedule_vtracef (sd, delta_time, handler, data, NULL, 0); +} +#endif + + +#if EXTERN_SIM_EVENTS_P +sim_event * +sim_events_schedule_tracef (SIM_DESC sd, + signed64 delta_time, + sim_event_handler *handler, + void *data, + const char *fmt, + ...) +{ + sim_event *new_event; + va_list ap; + va_start (ap, fmt); + new_event = sim_events_schedule_vtracef (sd, delta_time, handler, data, fmt, ap); + va_end (ap); + return new_event; +} +#endif + + +#if EXTERN_SIM_EVENTS_P +sim_event * +sim_events_schedule_vtracef (SIM_DESC sd, + signed64 delta_time, + sim_event_handler *handler, + void *data, + const char *fmt, + va_list ap) +{ sim_event *new_event = sim_events_zalloc (sd); new_event->data = data; new_event->handler = handler; new_event->watching = watch_timer; + if (fmt == NULL || !ETRACE_P || vasprintf (&new_event->trace, fmt, ap) < 0) + new_event->trace = NULL; insert_sim_event(sd, new_event, delta_time); ETRACE((_ETRACE, - "event scheduled at %ld - tag 0x%lx - time %ld, handler 0x%lx, data 0x%lx\n", + "event scheduled at %ld - tag 0x%lx - time %ld, handler 0x%lx, data 0x%lx%s%s\n", (long)sim_events_time(sd), (long)new_event, (long)new_event->time_of_event, (long)new_event->handler, - (long)new_event->data)); + (long)new_event->data, + (new_event->trace != NULL) ? ", " : "", + (new_event->trace != NULL) ? new_event->trace : "")); return new_event; } +#endif -EXTERN_SIM_EVENTS\ -(void) +#if EXTERN_SIM_EVENTS_P +void sim_events_schedule_after_signal (SIM_DESC sd, signed64 delta_time, sim_event_handler *handler, @@ -479,10 +555,11 @@ sim_events_schedule_after_signal (SIM_DESC sd, (long)new_event->handler, (long)new_event->data)); } +#endif -EXTERN_SIM_EVENTS\ -(sim_event *) +#if EXTERN_SIM_EVENTS_P +sim_event * sim_events_watch_clock (SIM_DESC sd, unsigned delta_ms_time, sim_event_handler *handler, @@ -515,10 +592,11 @@ sim_events_watch_clock (SIM_DESC sd, (long)new_event->data)); return new_event; } +#endif -EXTERN_SIM_EVENTS\ -(sim_event *) +#if EXTERN_SIM_EVENTS_P +sim_event * sim_events_watch_sim (SIM_DESC sd, void *host_addr, int nr_bytes, @@ -592,13 +670,14 @@ sim_events_watch_sim (SIM_DESC sd, (long)new_event->data)); return new_event; } +#endif -EXTERN_SIM_EVENTS\ -(sim_event *) +#if EXTERN_SIM_EVENTS_P +sim_event * sim_events_watch_core (SIM_DESC sd, address_word core_addr, - sim_core_maps core_map, + unsigned core_map, int nr_bytes, int byte_order, int is_within, @@ -671,10 +750,11 @@ sim_events_watch_core (SIM_DESC sd, (long)new_event->data)); return new_event; } +#endif -EXTERN_SIM_EVENTS\ -(void) +#if EXTERN_SIM_EVENTS_P +void sim_events_deschedule (SIM_DESC sd, sim_event *event_to_remove) { @@ -694,12 +774,14 @@ sim_events_deschedule (SIM_DESC sd, sim_event *dead = *ptr_to_current; *ptr_to_current = dead->next; ETRACE ((_ETRACE, - "event/watch descheduled at %ld - tag 0x%lx - time %ld, handler 0x%lx, data 0x%lx\n", + "event/watch descheduled at %ld - tag 0x%lx - time %ld, handler 0x%lx, data 0x%lx%s%s\n", (long) sim_events_time (sd), (long) event_to_remove, (long) dead->time_of_event, (long) dead->handler, - (long) dead->data)); + (long) dead->data, + (dead->trace != NULL) ? ", " : "", + (dead->trace != NULL) ? dead->trace : "")); sim_events_free (sd, dead); update_time_from_event (sd); SIM_ASSERT ((events->time_from_event >= 0) == (events->queue != NULL)); @@ -712,6 +794,7 @@ sim_events_deschedule (SIM_DESC sd, (long) sim_events_time (sd), (long) event_to_remove)); } +#endif STATIC_INLINE_SIM_EVENTS\ @@ -1034,11 +1117,13 @@ sim_events_process (SIM_DESC sd) sim_event_handler *handler = to_do->handler; void *data = to_do->data; ETRACE((_ETRACE, - "event issued at %ld - tag 0x%lx - handler 0x%lx, data 0x%lx\n", + "event issued at %ld - tag 0x%lx - handler 0x%lx, data 0x%lx%s%s\n", (long) event_time, (long) to_do, (long) handler, - (long) data)); + (long) data, + (to_do->trace != NULL) ? ", " : "", + (to_do->trace != NULL) ? to_do->trace : "")); sim_events_free (sd, to_do); handler (sd, data); } @@ -1060,11 +1145,13 @@ sim_events_process (SIM_DESC sd) events->queue = to_do->next; update_time_from_event (sd); ETRACE((_ETRACE, - "event issued at %ld - tag 0x%lx - handler 0x%lx, data 0x%lx\n", + "event issued at %ld - tag 0x%lx - handler 0x%lx, data 0x%lx%s%s\n", (long) event_time, (long) to_do, (long) handler, - (long) data)); + (long) data, + (to_do->trace != NULL) ? ", " : "", + (to_do->trace != NULL) ? to_do->trace : "")); sim_events_free (sd, to_do); handler (sd, data); } @@ -1082,6 +1169,18 @@ sim_events_process (SIM_DESC sd) /* this round of processing complete */ events->nr_ticks_to_process = 0; + +#if __CYGWIN32__ + /* Now call the ui_loop_hook to give the gui a chance to + process events. */ + + if (ui_loop_hook != NULL) + { + /* attempt to limit calls to 1-10 per second */ + if (! (ui_loop_hook_counter++ & 0xf)) + (*ui_loop_hook) (-2); /* magic */ + } +#endif } #endif |