Make hw-main.h the main header file for H/W devices. Like sim-main.h
authorAndrew Cagney <cagney@redhat.com>
Mon, 25 May 1998 11:06:29 +0000 (11:06 +0000)
committerAndrew Cagney <cagney@redhat.com>
Mon, 25 May 1998 11:06:29 +0000 (11:06 +0000)
Update dv-*.c
Replace *_callback with more correct. *_method. Update dv-*.c

sim/common/.Sanitize
sim/common/ChangeLog
sim/common/Make-common.in
sim/common/hw-base.c
sim/common/hw-base.h
sim/common/hw-device.h
sim/common/hw-main.h [new file with mode: 0644]

index 5a612e2b5368f2e0da810256d3e4a495198d9e70..240f3d3bd7e3d2a9b753ac70e537632a1c826f39 100644 (file)
@@ -65,6 +65,7 @@ hw-device.c
 hw-device.h
 hw-events.c
 hw-events.h
+hw-main.h
 hw-ports.c
 hw-ports.h
 hw-properties.c
@@ -100,6 +101,8 @@ sim-fpu.c
 sim-fpu.h
 sim-hload.c
 sim-hrw.c
+sim-hw.c
+sim-hw.h
 sim-info.c
 sim-inline.c
 sim-inline.h
index 69aebccfca42e6f6915e3dde1fae636d07cd88f6..f60a1c800c7a571c0417a6dc0175feed3c8a42ec 100644 (file)
@@ -1,3 +1,31 @@
+Mon May 25 18:55:35 1998  Andrew Cagney  <cagney@b1.cygnus.com>
+
+       * dv-core.c: Include hw-main.h and sim-main.h.
+       * dv-pal.c: Include hw-main.h and sim-io.h.
+       * dv-glue.c: Include hw-main.h.
+
+       * hw-main.h: New file.  Move list of includes to here.
+       * hw-base.h: From here.
+       * Make-common.in (hw_base_headers): Rename to hw_main_headers.
+       (hw-*.o, dv-*.o): Update.
+       * hw-tree.c, hw-base.c, hw-properties.c, hw-ports.c, hw-device.c,
+       hw-events.c, hw-alloc.c, sim-hw.c: Include hw-main.h instead of
+       sim-main.h.
+
+       * hw-base.h (do_hw_attach_regs, do_hw_poll_read_method,
+       do_hw_poll_read): Move declarations from here.
+       * hw-main.h: To here.
+       
+       * hw-base.h (struct hw_device_descriptor, hw_finish_callback):
+       Move from here.
+       * hw-main.h (struct hw_descriptor, hw_finish_method): To here,
+       rename.
+       * Make-common.in (hw-config.h): Update
+       * hw-base.c, dv-pal.c, dv-glue.c: Update
+
+       * dv-glue.c, hw-device.h, hw-base.h, hw-ports.c: Rename
+       `*_callback' to `*_method.
+
 Mon May 25 18:41:18 1998  Andrew Cagney  <cagney@b1.cygnus.com>
 
        * hw-base.h (set_*): Move set method macros from here.
index dcc8c7a7383d3a7514f064bc070638329be67e90..b92486ccc33ea794070e85a67b725d86c6e74183 100644 (file)
@@ -325,7 +325,8 @@ hw-ports_h = $(srccom)/hw-ports.h
 hw-properties_h = $(srccom)/hw-properties.h
 hw-tree_h = $(srccom)/hw-tree.h
 
-hw_base_headers = \
+hw_main_headers = \
+       $(srccom)/hw-main.h \
        $(hw-alloc_h) \
        $(hw-base_h) \
        $(hw-device_h) \
@@ -465,9 +466,9 @@ hw-config.h: Makefile.in $(srccom)/Make-common.in config.status Makefile
        rm -f tmp-hw.h
        echo "/* generated by Makefile */" > tmp-hw.h
        for hw in $(SIM_HW) ; do \
-         echo "extern const struct hw_device_descriptor dv_$${hw}_descriptor[];" ; \
+         echo "extern const struct hw_descriptor dv_$${hw}_descriptor[];" ; \
        done >> tmp-hw.h
-       echo "const struct hw_device_descriptor *hw_descriptors[] = {" >> tmp-hw.h
+       echo "const struct hw_descriptor *hw_descriptors[] = {" >> tmp-hw.h
        for hw in $(SIM_HW) ; do \
          echo "  dv_$${hw}_descriptor," ; \
        done >> tmp-hw.h
@@ -475,53 +476,41 @@ hw-config.h: Makefile.in $(srccom)/Make-common.in config.status Makefile
        echo "};" >> tmp-hw.h
        mv tmp-hw.h hw-config.h
 
-hw-alloc.o: $(srccom)/hw-alloc.c $(sim_main_headers) \
-         $(hw-alloc_h)
+hw-alloc.o: $(srccom)/hw-alloc.c $(hw_main_headers)
        $(CC) -c $(srccom)/hw-alloc.c $(ALL_CFLAGS)
 
-hw-base.o: $(srccom)/hw-base.c $(sim_main_headers) \
-         $(hw_base_headers) hw-config.h
+hw-base.o: $(srccom)/hw-base.c $(hw_main_headers) hw-config.h
        $(CC) -c $(srccom)/hw-base.c $(ALL_CFLAGS)
 
-hw-device.o: $(srccom)/hw-device.c $(sim_main_headers) \
-         $(hw-device_h)
+hw-device.o: $(srccom)/hw-device.c $(hw_main_headers)
        $(CC) -c $(srccom)/hw-device.c $(ALL_CFLAGS)
 
-hw-events.o: $(srccom)/hw-events.c $(sim_main_headers) \
-         $(hw-events_h)
+hw-events.o: $(srccom)/hw-events.c $(hw_main_headers) $(sim_main_headers)
        $(CC) -c $(srccom)/hw-events.c $(ALL_CFLAGS)
 
-hw-instances.o: $(srccom)/hw-instances.c $(sim_main_headers) \
-         $(hw_base_headers)
+hw-instances.o: $(srccom)/hw-instances.c $(hw_main_headers)
        $(CC) -c $(srccom)/hw-instances.c $(ALL_CFLAGS)
 
-hw-handles.o: $(srccom)/hw-handles.c $(sim_main_headers) \
-         $(hw_base_headers)
+hw-handles.o: $(srccom)/hw-handles.c $(hw_main_headers)
        $(CC) -c $(srccom)/hw-handles.c $(ALL_CFLAGS)
 
-hw-ports.o: $(srccom)/hw-ports.c $(sim_main_headers) \
-         $(hw-ports_h)
+hw-ports.o: $(srccom)/hw-ports.c $(hw_main_headers)
        $(CC) -c $(srccom)/hw-ports.c $(ALL_CFLAGS)
 
-hw-properties.o: $(srccom)/hw-properties.c $(sim_main_headers) \
-         $(hw-properties_h)
+hw-properties.o: $(srccom)/hw-properties.c $(hw_main_headers)
        $(CC) -c $(srccom)/hw-properties.c $(ALL_CFLAGS)
 
-hw-tree.o: $(srccom)/hw-tree.c $(sim_main_headers) \
-         $(hw-tree_h) $(hw_base_headers)
+hw-tree.o: $(srccom)/hw-tree.c $(hw_main_headers) $(hw-tree_h)
        $(CC) -c $(srccom)/hw-tree.c $(ALL_CFLAGS)
 
 
-dv-core.o: $(srccom)/dv-core.c $(sim_main_headers) \
-         $(sim-main_h) $(hw_base_headers)
+dv-core.o: $(srccom)/dv-core.c $(hw_main_headers) $(sim_main_headers)
        $(CC) -c $(srccom)/dv-core.c $(ALL_CFLAGS)
 
-dv-glue.o: $(srccom)/dv-glue.c $(sim_main_headers) \
-         $(sim-main_h) $(hw_base_headers)
+dv-glue.o: $(srccom)/dv-glue.c $(hw_main_headers) $(sim_main_headers)
        $(CC) -c $(srccom)/dv-glue.c $(ALL_CFLAGS)
 
-dv-pal.o: $(srccom)/dv-pal.c $(sim_main_headers) \
-         $(sim-main_h) $(hw_base_headers)
+dv-pal.o: $(srccom)/dv-pal.c $(hw_main_headers) $(sim_main_headers)
        $(CC) -c $(srccom)/dv-pal.c $(ALL_CFLAGS)
 
 
index 3adef18dfa88e69c2b35202b5f98e83fd6c715e3..05255b06eacf21e100671d6dd513c657d9311f41 100644 (file)
@@ -19,7 +19,7 @@
     */
 
 
-#include "sim-main.h"
+#include "hw-main.h"
 #include "hw-base.h"
 
 
@@ -41,7 +41,7 @@
 
 struct hw_base_data {
   int finished_p;
-  const struct hw_device_descriptor *descriptor;
+  const struct hw_descriptor *descriptor;
   hw_delete_callback *to_delete;
 };
 
@@ -393,12 +393,12 @@ hw_create (struct sim_state *sd,
 
   /* locate a descriptor */
   {
-    const struct hw_device_descriptor **table;
+    const struct hw_descriptor **table;
     for (table = hw_descriptors;
         *table != NULL;
         table++)
       {
-       const struct hw_device_descriptor *entry;
+       const struct hw_descriptor *entry;
        for (entry = *table;
             entry->family != NULL;
             entry++)
index da379866fa5661df9cae495b8c28d15abda072ff..4cb574b9847923f88ba9c1b1785e937710405300 100644 (file)
     */
 
 
-#ifndef HW_ROOT
-#define HW_ROOT
-
-/* A root device from which dv-* devices can be built */
-
-#include "hw-device.h"
-
-#include "hw-properties.h"
-#include "hw-events.h"
-#include "hw-alloc.h"
-/* #include "hw-instances.h" */
-/* #include "hw-handles.h" */
-#include "hw-ports.h"
-
-typedef void (hw_finish_callback)
-     (struct hw *me);
-
-struct hw_device_descriptor {
-  const char *family;
-  hw_finish_callback *to_finish;
-};
+#ifndef HW_BASE
+#define HW_BASE
 
 /* Create a primative device */
 
@@ -77,32 +58,6 @@ typedef void (hw_delete_callback)
 ((hw)->base_of_hw->to_delete = (method))
 
 
-/* Helper functions to make the implementation of a device easier */
-
-/* Go through the devices reg properties and look for those specifying
-   an address to attach various registers to */
-
-void do_hw_attach_regs (struct hw *me);
-
-/* Perform a polling read on FD returning either the number of bytes
-   or a hw_io status code that indicates the reason for the read
-   failure */
-
-enum {
-  HW_IO_EOF = -1, HW_IO_NOT_READY = -2, /* See: IEEE 1275 */
-};
-
-typedef int (do_hw_poll_read_method)
-     (SIM_DESC sd, int, char *, int);
-
-int do_hw_poll_read
-(struct hw *me,
- do_hw_poll_read_method *read,
- int sim_io_fd,
- void *buf,
- unsigned size_of_buf);
-
-
 /* ALLOC */
 
 extern void create_hw_alloc_data
index 44c0709fc8f1a43638f188036b19a5d2a2a28f44..3d459dab975103955ffb67c70a5c3824bf2fdcf7 100644 (file)
@@ -157,7 +157,7 @@ struct _sim_cpu *hw_system_cpu (struct hw *hw);
 \f
 /* Perform a soft reset of the device */
 
-typedef unsigned (hw_reset_callback)
+typedef unsigned (hw_reset_method)
      (struct hw *me);
 
 #define hw_reset(hw) ((hw)->to_reset (hw))
@@ -190,7 +190,7 @@ typedef unsigned (hw_reset_callback)
    The SPACE:ADDR pair specify an address on the common bus that
    connects the parent and child devices. */
 
-typedef void (hw_attach_address_callback)
+typedef void (hw_attach_address_method)
      (struct hw *me,
       int level,
       int space,
@@ -204,7 +204,7 @@ typedef void (hw_attach_address_callback)
 #define set_hw_attach_address(hw, method) \
 ((hw)->to_attach_address = (method))
 
-typedef void (hw_detach_address_callback)
+typedef void (hw_detach_address_method)
      (struct hw *me,
       int level,
       int space,
@@ -224,7 +224,7 @@ typedef void (hw_detach_address_callback)
    The SPACE:ADDR pair specify an address on the bus shared between
    the parent and child devices. */
 
-typedef unsigned (hw_io_read_buffer_callback)
+typedef unsigned (hw_io_read_buffer_method)
      (struct hw *me,
       void *dest,
       int space,
@@ -237,7 +237,7 @@ typedef unsigned (hw_io_read_buffer_callback)
 #define set_hw_io_read_buffer(hw, method) \
 ((hw)->to_io_read_buffer = (method))
 
-typedef unsigned (hw_io_write_buffer_callback)
+typedef unsigned (hw_io_write_buffer_method)
      (struct hw *me,
       const void *source,
       int space,
@@ -260,7 +260,7 @@ typedef unsigned (hw_io_write_buffer_callback)
    The SPACE:ADDR pair specify an address on the common bus connecting
    the parent and child devices. */
 
-typedef unsigned (hw_dma_read_buffer_callback)
+typedef unsigned (hw_dma_read_buffer_method)
      (struct hw *bus,
       void *dest,
       int space,
@@ -273,7 +273,7 @@ typedef unsigned (hw_dma_read_buffer_callback)
 #define set_hw_dma_read_buffer(me, method) \
 ((me)->to_dma_read_buffer = (method))
 
-typedef unsigned (hw_dma_write_buffer_callback)
+typedef unsigned (hw_dma_write_buffer_method)
      (struct hw *bus,
       const void *source,
       int space,
@@ -324,7 +324,7 @@ const hw_unit *hw_unit_address
    textual representation.  This is because the textual address of a
    device is specified using the parent busses notation. */
 
-typedef int (hw_unit_decode_callback)
+typedef int (hw_unit_decode_method)
      (struct hw *bus,
       const char *encoded,
       hw_unit *unit);
@@ -335,7 +335,7 @@ typedef int (hw_unit_decode_callback)
 #define set_hw_unit_decode(hw, method) \
 ((hw)->to_unit_decode = (method))
 
-typedef int (hw_unit_encode_callback)
+typedef int (hw_unit_encode_method)
      (struct hw *bus,
       const hw_unit *unit,
       char *encoded,
@@ -355,7 +355,7 @@ typedef int (hw_unit_encode_callback)
    Return a zero result if the address should be ignored when looking
    for attach addresses. */
 
-typedef int (hw_unit_address_to_attach_address_callback)
+typedef int (hw_unit_address_to_attach_address_method)
      (struct hw *bus,
       const hw_unit *unit_addr,
       int *attach_space,
@@ -368,7 +368,7 @@ typedef int (hw_unit_address_to_attach_address_callback)
 #define set_hw_unit_address_to_attach_address(hw, method) \
 ((hw)->to_unit_address_to_attach_address = (method))
 
-typedef int (hw_unit_size_to_attach_size_callback)
+typedef int (hw_unit_size_to_attach_size_method)
      (struct hw *bus,
       const hw_unit *unit_size,
       unsigned *attach_size,
@@ -406,7 +406,7 @@ typedef enum {
   nr_hw_ioctl_requests,
 } hw_ioctl_request;
 
-typedef int (hw_ioctl_callback)
+typedef int (hw_ioctl_method)
      (struct hw *me,
       hw_ioctl_request request,
       va_list ap);
@@ -498,25 +498,25 @@ struct hw {
   int nr_size_cells_of_hw_unit;
 
   /* Soft reset */
-  hw_reset_callback *to_reset;
+  hw_reset_method *to_reset;
 
   /* Basic callbacks */
-  hw_io_read_buffer_callback *to_io_read_buffer;
-  hw_io_write_buffer_callback *to_io_write_buffer;
-  hw_dma_read_buffer_callback *to_dma_read_buffer;
-  hw_dma_write_buffer_callback *to_dma_write_buffer;
-  hw_attach_address_callback *to_attach_address;
-  hw_detach_address_callback *to_detach_address;
+  hw_io_read_buffer_method *to_io_read_buffer;
+  hw_io_write_buffer_method *to_io_write_buffer;
+  hw_dma_read_buffer_method *to_dma_read_buffer;
+  hw_dma_write_buffer_method *to_dma_write_buffer;
+  hw_attach_address_method *to_attach_address;
+  hw_detach_address_method *to_detach_address;
 
   /* More complicated callbacks */
-  hw_ioctl_callback *to_ioctl;
+  hw_ioctl_method *to_ioctl;
   int trace_of_hw_p;
 
   /* address callbacks */
-  hw_unit_decode_callback *to_unit_decode;
-  hw_unit_encode_callback *to_unit_encode;
-  hw_unit_address_to_attach_address_callback *to_unit_address_to_attach_address;
-  hw_unit_size_to_attach_size_callback *to_unit_size_to_attach_size;
+  hw_unit_decode_method *to_unit_decode;
+  hw_unit_encode_method *to_unit_encode;
+  hw_unit_address_to_attach_address_method *to_unit_address_to_attach_address;
+  hw_unit_size_to_attach_size_method *to_unit_size_to_attach_size;
 
   /* related data */
   struct hw_property_data *properties_of_hw;
diff --git a/sim/common/hw-main.h b/sim/common/hw-main.h
new file mode 100644 (file)
index 0000000..96b404c
--- /dev/null
@@ -0,0 +1,73 @@
+/* Common hardware header file.
+   Copyright (C) 1998 Free Software Foundation, Inc.
+   Contributed by Andrew Cagney and 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_MAIN
+#define HW_MAIN
+
+/* establish a type system */
+#include "sim-basics.h"
+
+/* construct a hw device */
+#include "hw-device.h"
+#include "hw-properties.h"
+#include "hw-events.h"
+#include "hw-alloc.h"
+/* #include "hw-instances.h" */
+/* #include "hw-handles.h" */
+#include "hw-ports.h"
+
+/* Description of a hardware device */
+
+typedef void (hw_finish_method)
+     (struct hw *me);
+
+struct hw_descriptor {
+  const char *family;
+  hw_finish_method *to_finish;
+};
+
+/* Helper functions to make the implementation of a device easier */
+
+/* Go through the devices reg properties and look for those specifying
+   an address to attach various registers to */
+
+void do_hw_attach_regs (struct hw *me);
+
+/* Perform a polling read on FD returning either the number of bytes
+   or a hw_io status code that indicates the reason for the read
+   failure */
+
+enum {
+  HW_IO_EOF = -1, HW_IO_NOT_READY = -2, /* See: IEEE 1275 */
+};
+
+typedef int (do_hw_poll_read_method)
+     (SIM_DESC sd, int, char *, int);
+
+int do_hw_poll_read
+(struct hw *me,
+ do_hw_poll_read_method *read,
+ int sim_io_fd,
+ void *buf,
+ unsigned size_of_buf);
+
+
+#endif