summaryrefslogtreecommitdiff
path: root/sim
diff options
context:
space:
mode:
authorAndrew Cagney <cagney@redhat.com>1998-05-25 11:06:29 +0000
committerAndrew Cagney <cagney@redhat.com>1998-05-25 11:06:29 +0000
commit48f83b1a2e0a034c1b28a72c41c85a27a3a01266 (patch)
tree9bdce36ba1f7f3df9cbe2081f66aa979ee3f7696 /sim
parentc14db36dbbcef966978f8d8aee0b3670d3243bb0 (diff)
downloadbinutils-gdb-48f83b1a2e0a034c1b28a72c41c85a27a3a01266.tar.gz
Make hw-main.h the main header file for H/W devices. Like sim-main.h
Update dv-*.c Replace *_callback with more correct. *_method. Update dv-*.c
Diffstat (limited to 'sim')
-rw-r--r--sim/common/.Sanitize3
-rw-r--r--sim/common/ChangeLog28
-rw-r--r--sim/common/Make-common.in43
-rw-r--r--sim/common/hw-base.c8
-rw-r--r--sim/common/hw-base.h49
-rw-r--r--sim/common/hw-device.h48
-rw-r--r--sim/common/hw-main.h73
7 files changed, 150 insertions, 102 deletions
diff --git a/sim/common/.Sanitize b/sim/common/.Sanitize
index 5a612e2b536..240f3d3bd7e 100644
--- a/sim/common/.Sanitize
+++ b/sim/common/.Sanitize
@@ -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
diff --git a/sim/common/ChangeLog b/sim/common/ChangeLog
index 69aebccfca4..f60a1c800c7 100644
--- a/sim/common/ChangeLog
+++ b/sim/common/ChangeLog
@@ -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.
diff --git a/sim/common/Make-common.in b/sim/common/Make-common.in
index dcc8c7a7383..b92486ccc33 100644
--- a/sim/common/Make-common.in
+++ b/sim/common/Make-common.in
@@ -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)
diff --git a/sim/common/hw-base.c b/sim/common/hw-base.c
index 3adef18dfa8..05255b06eac 100644
--- a/sim/common/hw-base.c
+++ b/sim/common/hw-base.c
@@ -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++)
diff --git a/sim/common/hw-base.h b/sim/common/hw-base.h
index da379866fa5..4cb574b9847 100644
--- a/sim/common/hw-base.h
+++ b/sim/common/hw-base.h
@@ -19,27 +19,8 @@
*/
-#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
diff --git a/sim/common/hw-device.h b/sim/common/hw-device.h
index 44c0709fc8f..3d459dab975 100644
--- a/sim/common/hw-device.h
+++ b/sim/common/hw-device.h
@@ -157,7 +157,7 @@ struct _sim_cpu *hw_system_cpu (struct hw *hw);
/* 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
index 00000000000..96b404c48c2
--- /dev/null
+++ b/sim/common/hw-main.h
@@ -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