From 937a4bdc12d90b400da5b5f5e1e3770c6e4b39ea Mon Sep 17 00:00:00 2001 From: Andrew Cagney Date: Sun, 22 Mar 1998 05:33:41 +0000 Subject: Add function hw_trace() and macro HW_TRACE - provides trace support for HW devices. --- sim/common/ChangeLog | 13 +++++++++++++ sim/common/dv-core.c | 2 ++ sim/common/dv-pal.c | 33 ++++++++++++++++++++------------- sim/common/hw-base.c | 4 ++++ sim/common/hw-device.c | 16 ++++++++++++++++ sim/common/hw-device.h | 12 ++++++++++++ 6 files changed, 67 insertions(+), 13 deletions(-) diff --git a/sim/common/ChangeLog b/sim/common/ChangeLog index e760208..9ecbe04 100644 --- a/sim/common/ChangeLog +++ b/sim/common/ChangeLog @@ -1,3 +1,16 @@ +Sun Mar 22 16:21:15 1998 Andrew Cagney + + * hw-device.h (HW_TRACE): Define. + (hw_trace): Declare. + * hw-device.c (hw_trace): Implement function. + + * hw-base.c (hw_create): Set hw trace level from "trace?" + property. + + * dv-core.c (dv_core_attach_address_callback): Add trace. + + * dv-pal.c: Replace DTRACE with HW_TRACE. + Sun Mar 22 15:23:35 1998 Andrew Cagney * hw-device.h (HW_ZALLOC, HW_MALLOC): New macros. diff --git a/sim/common/dv-core.c b/sim/common/dv-core.c index bdb612c..e84f70d 100644 --- a/sim/common/dv-core.c +++ b/sim/common/dv-core.c @@ -52,6 +52,8 @@ dv_core_attach_address_callback (struct hw *me, address_word nr_bytes, struct hw *client) { + HW_TRACE ((me, "attach (level=%d, space=%d, addr=0x%lx, nr_bytes=%ld, client=0x%lx)", + level, space, (unsigned long) addr, (unsigned long) nr_bytes, (unsigned long) client)); /* NOTE: At preset the space is assumed to be zero. Perhaphs the space should be mapped onto something for instance: space0 - unified memory; space1 - IO memory; ... */ diff --git a/sim/common/dv-pal.c b/sim/common/dv-pal.c index f15f5c9..2e00c3b 100644 --- a/sim/common/dv-pal.c +++ b/sim/common/dv-pal.c @@ -41,8 +41,6 @@ #include #endif -#define DTRACE(x,y) - /* DEVICE @@ -107,6 +105,15 @@ live. + PORTS + + + int[0..NR_PROCESSORS] (output) + + Driven as a result of a write to the interrupt-port / + interrupt-level register pair. + + */ @@ -191,32 +198,32 @@ hw_pal_io_read_buffer (struct hw *me, #else val = 0; #endif - DTRACE (pal, ("read - cpu-nr %d\n", val)); + HW_TRACE ((me, "read - cpu-nr %d\n", val)); break; case hw_pal_nr_cpu_register: val = hw_tree_find_integer_property (me, "/openprom/options/smp"); - DTRACE (pal, ("read - nr-cpu %d\n", val)); + HW_TRACE ((me, "read - nr-cpu %d\n", val)); break; case hw_pal_read_fifo: val = hw_pal->input.buffer; - DTRACE (pal, ("read - input-fifo %d\n", val)); + HW_TRACE ((me, "read - input-fifo %d\n", val)); break; case hw_pal_read_status: scan_hw_pal (me); val = hw_pal->input.status; - DTRACE (pal, ("read - input-status %d\n", val)); + HW_TRACE ((me, "read - input-status %d\n", val)); break; case hw_pal_write_fifo: val = hw_pal->output.buffer; - DTRACE (pal, ("read - output-fifo %d\n", val)); + HW_TRACE ((me, "read - output-fifo %d\n", val)); break; case hw_pal_write_status: val = hw_pal->output.status; - DTRACE (pal, ("read - output-status %d\n", val)); + HW_TRACE ((me, "read - output-status %d\n", val)); break; default: val = 0; - DTRACE (pal, ("read - ???\n")); + HW_TRACE ((me, "read - ???\n")); } memset (dest, 0, nr_bytes); *(unsigned_1*)dest = val; @@ -249,19 +256,19 @@ hw_pal_io_write_buffer (struct hw *me, break; case hw_pal_read_fifo: hw_pal->input.buffer = byte[0]; - DTRACE (pal, ("write - input-fifo %d\n", byte[0])); + HW_TRACE ((me, "write - input-fifo %d\n", byte[0])); break; case hw_pal_read_status: hw_pal->input.status = byte[0]; - DTRACE (pal, ("write - input-status %d\n", byte[0])); + HW_TRACE ((me, "write - input-status %d\n", byte[0])); break; case hw_pal_write_fifo: write_hw_pal (me, byte[0]); - DTRACE (pal, ("write - output-fifo %d\n", byte[0])); + HW_TRACE ((me, "write - output-fifo %d\n", byte[0])); break; case hw_pal_write_status: hw_pal->output.status = byte[0]; - DTRACE (pal, ("write - output-status %d\n", byte[0])); + HW_TRACE ((me, "write - output-status %d\n", byte[0])); break; } return nr_bytes; diff --git a/sim/common/hw-base.c b/sim/common/hw-base.c index 495f96d..ad17df4 100644 --- a/sim/common/hw-base.c +++ b/sim/common/hw-base.c @@ -442,6 +442,10 @@ hw_create (SIM_DESC sd, } } + /* Fill in the (hopefully) defined trace variable */ + if (hw_find_property (hw, "trace?") != NULL) + hw->trace_of_hw_p = hw_find_boolean_property (hw, "trace?"); + /* Attach dummy ports */ set_hw_ports (hw, empty_hw_ports); set_hw_port_event (hw, panic_hw_port_event); diff --git a/sim/common/hw-device.c b/sim/common/hw-device.c index 3f57190..55968d8 100644 --- a/sim/common/hw-device.c +++ b/sim/common/hw-device.c @@ -87,6 +87,22 @@ hw_abort (struct hw *me, 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) */ diff --git a/sim/common/hw-device.h b/sim/common/hw-device.h index 4abe207..b1ef09c 100644 --- a/sim/common/hw-device.h +++ b/sim/common/hw-device.h @@ -447,6 +447,18 @@ void volatile NORETURN hw_abort #define hw_trace_p(hw) ((hw)->trace_of_hw_p + 0) +void hw_trace +(struct hw *me, + const char *fmt, + ...) __attribute__ ((format (printf, 2, 3))); + +#define HW_TRACE(ARGS) \ +do { \ + if (hw_trace_p (me)) \ + { \ + hw_trace ARGS; \ + } \ +} while (0) /* Some of the related functions require specific types */ -- cgit v1.1