diff options
author | imp <imp@FreeBSD.org> | 2002-07-21 03:28:43 +0000 |
---|---|---|
committer | imp <imp@FreeBSD.org> | 2002-07-21 03:28:43 +0000 |
commit | 30ec4e72722c97aebb1484546143c06ce494b330 (patch) | |
tree | e901a3d2cd9d0f23ff50c0caafc7d8f4c7b106ce /sys | |
parent | 4a190d70152293c089b8a53c82687bd958d61e6f (diff) | |
download | FreeBSD-src-30ec4e72722c97aebb1484546143c06ce494b330.zip FreeBSD-src-30ec4e72722c97aebb1484546143c06ce494b330.tar.gz |
Add bus_child_present and the child_present method to bus_if.m
Diffstat (limited to 'sys')
-rw-r--r-- | sys/kern/bus_if.m | 15 | ||||
-rw-r--r-- | sys/kern/subr_bus.c | 26 | ||||
-rw-r--r-- | sys/sys/bus.h | 2 |
3 files changed, 39 insertions, 4 deletions
diff --git a/sys/kern/bus_if.m b/sys/kern/bus_if.m index bf8d4ac..c5350be 100644 --- a/sys/kern/bus_if.m +++ b/sys/kern/bus_if.m @@ -36,11 +36,10 @@ INTERFACE bus; CODE { static struct resource * null_alloc_resource(device_t dev, device_t child, - int type, int *rid, - u_long start, u_long end, - u_long count, u_int flags) + int type, int *rid, u_long start, u_long end, + u_long count, u_int flags) { - return 0; + return (0); } }; @@ -244,3 +243,11 @@ METHOD struct resource_list * get_resource_list { device_t _dev; device_t _child; } DEFAULT bus_generic_get_resource_list; + +# +# Is the hardware described by _child still attached to the system? +# +METHOD int child_present { + device_t _dev; + device_t _child; +} DEFAULT bus_generic_child_present; diff --git a/sys/kern/subr_bus.c b/sys/kern/subr_bus.c index 7281051..7e7df14 100644 --- a/sys/kern/subr_bus.c +++ b/sys/kern/subr_bus.c @@ -1594,6 +1594,12 @@ bus_generic_rl_alloc_resource (device_t dev, device_t child, int type, start, end, count, flags)); } +int +bus_generic_child_present(device_t bus, device_t child) +{ + return (BUS_CHILD_PRESENT(device_get_parent(bus), bus)); +} + /* * Some convenience functions to make it easier for drivers to use the * resource-management functions. All these really do is hide the @@ -1701,6 +1707,12 @@ bus_delete_resource(device_t dev, int type, int rid) BUS_DELETE_RESOURCE(device_get_parent(dev), dev, type, rid); } +int +bus_child_present(device_t dev) +{ + return (BUS_CHILD_PRESENT(device_get_parent(dev), dev)); +} + static int root_print_child(device_t dev, device_t child) { @@ -1722,6 +1734,19 @@ root_setup_intr(device_t dev, device_t child, driver_intr_t *intr, void *arg, panic("root_setup_intr"); } +/* + * If we get here, assume that the device is permanant and really is + * present in the system. Removable bus drivers are expected to intercept + * this call long before it gets here. We return -1 so that drivers that + * really care can check vs -1 or some ERRNO returned higher in the food + * chain. + */ +static int +root_child_present(device_t dev, device_t child) +{ + return (-1); +} + static kobj_method_t root_methods[] = { /* Device interface */ KOBJMETHOD(device_shutdown, bus_generic_shutdown), @@ -1733,6 +1758,7 @@ static kobj_method_t root_methods[] = { KOBJMETHOD(bus_read_ivar, bus_generic_read_ivar), KOBJMETHOD(bus_write_ivar, bus_generic_write_ivar), KOBJMETHOD(bus_setup_intr, root_setup_intr), + KOBJMETHOD(bus_child_present, root_child_present), { 0, 0 } }; diff --git a/sys/sys/bus.h b/sys/sys/bus.h index 47bea4c..1559c41 100644 --- a/sys/sys/bus.h +++ b/sys/sys/bus.h @@ -209,6 +209,7 @@ struct resource * int *rid, u_long start, u_long end, u_long count, u_int flags); int bus_generic_attach(device_t dev); +int bus_generic_child_present(device_t dev, device_t child); int bus_generic_deactivate_resource(device_t dev, device_t child, int type, int rid, struct resource *r); int bus_generic_detach(device_t dev); @@ -269,6 +270,7 @@ int bus_get_resource(device_t dev, int type, int rid, u_long bus_get_resource_start(device_t dev, int type, int rid); u_long bus_get_resource_count(device_t dev, int type, int rid); void bus_delete_resource(device_t dev, int type, int rid); +int bus_child_present(device_t dev); /* * Access functions for device. |