Add function hw_trace() and macro HW_TRACE - provides trace support
authorAndrew Cagney <cagney@redhat.com>
Sun, 22 Mar 1998 05:33:41 +0000 (05:33 +0000)
committerAndrew Cagney <cagney@redhat.com>
Sun, 22 Mar 1998 05:33:41 +0000 (05:33 +0000)
for HW devices.

sim/common/ChangeLog
sim/common/dv-core.c
sim/common/dv-pal.c
sim/common/hw-base.c
sim/common/hw-device.c
sim/common/hw-device.h

index e760208..9ecbe04 100644 (file)
@@ -1,3 +1,16 @@
+Sun Mar 22 16:21:15 1998  Andrew Cagney  <cagney@b1.cygnus.com>
+
+       * 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  <cagney@b1.cygnus.com>
 
        * hw-device.h (HW_ZALLOC, HW_MALLOC): New macros.
index bdb612c..e84f70d 100644 (file)
@@ -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; ... */
index f15f5c9..2e00c3b 100644 (file)
@@ -41,8 +41,6 @@
 #include <stdlib.h>
 #endif
 
-#define DTRACE(x,y)
-
 /* DEVICE
 
    
    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;
index 495f96d..ad17df4 100644 (file)
@@ -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);
index 3f57190..55968d8 100644 (file)
@@ -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);
+    }
+}
+
 \f
 /* The event queue abstraction (for devices) */
 
index 4abe207..b1ef09c 100644 (file)
@@ -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 */