summaryrefslogtreecommitdiffstats
path: root/sys/sys/bus_private.h
diff options
context:
space:
mode:
authordfr <dfr@FreeBSD.org>1998-06-14 13:46:10 +0000
committerdfr <dfr@FreeBSD.org>1998-06-14 13:46:10 +0000
commitdc295ed278eb0235154462b23615e89213bc591c (patch)
tree0734d180ccb27bfdde5cd04d1961394e2e0ac94f /sys/sys/bus_private.h
parenta7d3dec6df55d42bcb12806631798932380ce34b (diff)
downloadFreeBSD-src-dc295ed278eb0235154462b23615e89213bc591c.zip
FreeBSD-src-dc295ed278eb0235154462b23615e89213bc591c.tar.gz
Major changes to the generic device framework for FreeBSD/alpha:
* Eliminate bus_t and make it possible for all devices to have attached children. * Support dynamically extendable interfaces for drivers to replace both the function pointers in driver_t and bus_ops_t (which has been removed entirely. Two system defined interfaces have been defined, 'device' which is mandatory for all devices and 'bus' which is recommended for all devices which support attached children. * In addition, the alpha port defines two simple interfaces 'clock' for attaching various real time clocks to the system and 'mcclock' for the many different variations of mc146818 clocks which can be attached to different alpha platforms. This eliminates two more function pointer tables in favour of the generic method dispatch system provided by the device framework. Future device interfaces may include: * cdev and bdev interfaces for devfs to use in replacement for specfs and the fixed interfaces bdevsw and cdevsw. * scsi interface to replace struct scsi_adapter (not sure how this works in CAM but I imagine there is something similar there). * various tailored interfaces for different bus types such as pci, isa, pccard etc.
Diffstat (limited to 'sys/sys/bus_private.h')
-rw-r--r--sys/sys/bus_private.h43
1 files changed, 38 insertions, 5 deletions
diff --git a/sys/sys/bus_private.h b/sys/sys/bus_private.h
index 5a9fba9..15d7620 100644
--- a/sys/sys/bus_private.h
+++ b/sys/sys/bus_private.h
@@ -1,5 +1,5 @@
/*-
- * Copyright (c) 1997 Doug Rabson
+ * Copyright (c) 1997,1998 Doug Rabson
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id$
+ * $Id: bus_private.h,v 1.1 1998/06/10 10:57:23 dfr Exp $
*/
#ifndef _SYS_BUS_PRIVATE_H_
@@ -36,6 +36,7 @@
*/
typedef TAILQ_HEAD(devclass_list, devclass) devclass_list_t;
typedef TAILQ_HEAD(driver_list, driver) driver_list_t;
+typedef TAILQ_HEAD(device_list, device) device_list_t;
struct devclass {
TAILQ_ENTRY(devclass) link;
@@ -47,11 +48,40 @@ struct devclass {
};
/*
+ * Compiled device methods.
+ */
+struct device_ops {
+ int maxoffset;
+ devop_t methods[1];
+};
+
+/*
+ * Helpers for device method wrappers.
+ */
+#define DEVOPDESC(OP) (&OP##_##desc)
+
+#define DEVOPOFF(DEV, OP) \
+ ((DEVOPDESC(OP)->offset >= DEV->ops->maxoffset \
+ || !DEV->ops->methods[DEVOPDESC(OP)->offset]) \
+ ? 0 : DEVOPDESC(OP)->offset)
+
+#define DEVOPMETH(DEV, OP) (DEV->ops->methods[DEVOPOFF(DEV, OP)])
+
+/*
* Implementation of device.
*/
struct device {
- TAILQ_ENTRY(device) link; /* list of devices on a bus */
- bus_t parent;
+ /*
+ * Device hierarchy.
+ */
+ TAILQ_ENTRY(device) link; /* list of devices in parent */
+ device_t parent;
+ device_list_t children; /* list of subordinate devices */
+
+ /*
+ * Details of this device.
+ */
+ device_ops_t ops;
driver_t *driver;
devclass_t devclass; /* device class which we are in */
int unit;
@@ -66,6 +96,9 @@ struct device {
void *softc;
};
-
+struct device_op_desc {
+ unsigned int offset; /* offset in driver ops */
+ const char* name; /* unique name (for registration) */
+};
#endif /* !_SYS_BUS_PRIVATE_H_ */
OpenPOWER on IntegriCloud