diff options
author | dfr <dfr@FreeBSD.org> | 1999-05-14 11:22:47 +0000 |
---|---|---|
committer | dfr <dfr@FreeBSD.org> | 1999-05-14 11:22:47 +0000 |
commit | 8a8a702dc2ad6a84232f0efd1ecb484effb273a1 (patch) | |
tree | 22d0abf17160893d226dcecdfe26c0bd265601db | |
parent | 29cc5794964b10b5c333e8d03f21ca3506b79cad (diff) | |
download | FreeBSD-src-8a8a702dc2ad6a84232f0efd1ecb484effb273a1.zip FreeBSD-src-8a8a702dc2ad6a84232f0efd1ecb484effb273a1.tar.gz |
* Define a new static method DEVICE_IDENTIFY which is called to add device
instances to a parent bus.
* Define a new method BUS_ADD_CHILD which can be called from DEVICE_IDENTIFY
to add new instances.
* Add a generic implementation of DEVICE_PROBE which calls DEVICE_IDENTIFY
for each driver attached to the parent's devclass.
* Move the hint-based isa probe from the isa driver to a new isahint driver
which can be shared between i386 and alpha.
-rw-r--r-- | sys/alpha/isa/isa.c | 202 | ||||
-rw-r--r-- | sys/amd64/isa/isa.c | 142 | ||||
-rw-r--r-- | sys/conf/files | 1 | ||||
-rw-r--r-- | sys/i386/isa/isa.c | 142 | ||||
-rw-r--r-- | sys/isa/isahint.c | 131 | ||||
-rw-r--r-- | sys/isa/isavar.h | 4 | ||||
-rw-r--r-- | sys/kern/bus_if.m | 15 | ||||
-rw-r--r-- | sys/kern/device_if.m | 10 | ||||
-rw-r--r-- | sys/kern/subr_bus.c | 18 | ||||
-rw-r--r-- | sys/sys/bus.h | 3 |
10 files changed, 311 insertions, 357 deletions
diff --git a/sys/alpha/isa/isa.c b/sys/alpha/isa/isa.c index 6e01cec..b81961c 100644 --- a/sys/alpha/isa/isa.c +++ b/sys/alpha/isa/isa.c @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: isa.c,v 1.11 1999/04/21 07:26:23 peter Exp $ + * $Id: isa.c,v 1.12 1999/05/08 21:58:37 dfr Exp $ */ #include <sys/param.h> @@ -66,119 +66,6 @@ struct isa_device { static devclass_t isa_devclass; static struct rman isa_irq_rman; -/* - * Device methods - */ -static int isa_probe(device_t dev); -static int isa_attach(device_t dev); -static void isa_print_child(device_t dev, device_t child); -static int isa_read_ivar(device_t dev, device_t child, int which, u_long *result); -static int isa_write_ivar(device_t dev, device_t child, int which, u_long result); -static struct resource *isa_alloc_resource(device_t bus, device_t child, - int type, int *rid, - u_long start, u_long end, - u_long count, u_int flags); -static int isa_release_resource(device_t bus, device_t child, - int type, int rid, struct resource *r); - -static device_method_t isa_methods[] = { - /* Device interface */ - DEVMETHOD(device_probe, isa_probe), - DEVMETHOD(device_attach, isa_attach), - DEVMETHOD(device_detach, bus_generic_detach), - DEVMETHOD(device_shutdown, bus_generic_shutdown), - - /* Bus interface */ - DEVMETHOD(bus_print_child, isa_print_child), - DEVMETHOD(bus_read_ivar, isa_read_ivar), - DEVMETHOD(bus_write_ivar, isa_write_ivar), - DEVMETHOD(bus_alloc_resource, isa_alloc_resource), - DEVMETHOD(bus_release_resource, isa_release_resource), - DEVMETHOD(bus_activate_resource, bus_generic_activate_resource), - DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource), - DEVMETHOD(bus_setup_intr, isa_setup_intr), - DEVMETHOD(bus_teardown_intr, isa_teardown_intr), - - { 0, 0 } -}; - -static driver_t isa_driver = { - "isa", - isa_methods, - 1, /* no softc */ -}; - -static void -isa_add_device(device_t dev, const char *name, int unit) -{ - struct isa_device *idev; - device_t child; - int sensitive, t; - static device_t last_sensitive; - - if (resource_int_value(name, unit, "sensitive", &sensitive) != 0) - sensitive = 0; - - idev = malloc(sizeof(struct isa_device), M_ISADEV, M_NOWAIT); - if (!idev) - return; - bzero(idev, sizeof *idev); - - if (resource_int_value(name, unit, "port", &t) == 0) - idev->id_port[0] = t; - else - idev->id_port[0] = 0; - idev->id_port[1] = 0; - - if (resource_int_value(name, unit, "portsize", &t) == 0) - idev->id_portsize[0] = t; - else - idev->id_portsize[0] = 0; - idev->id_portsize[1] = 0; - - if (resource_int_value(name, unit, "maddr", &t) == 0) - idev->id_maddr[0] = t; - else - idev->id_maddr[0] = 0; - idev->id_maddr[1] = 0; - - if (resource_int_value(name, unit, "msize", &t) == 0) - idev->id_msize[0] = t; - else - idev->id_msize[0] = 0; - idev->id_msize[1] = 0; - - if (resource_int_value(name, unit, "flags", &t) == 0) - idev->id_flags = t; - else - idev->id_flags = 0; - - if (resource_int_value(name, unit, "irq", &t) == 0) - idev->id_irq[0] = t; - else - idev->id_irq[0] = -1; - idev->id_irq[1] = -1; - - if (resource_int_value(name, unit, "drq", &t) == 0) - idev->id_drq[0] = t; - else - idev->id_drq[0] = -1; - idev->id_drq[1] = -1; - - if (sensitive) - child = device_add_child_after(dev, last_sensitive, name, - unit, idev); - else - child = device_add_child(dev, name, unit, idev); - if (child == 0) - return; - else if (sensitive) - last_sensitive = child; - - if (resource_int_value(name, unit, "disabled", &t) == 0 && t != 0) - device_disable(child); -} - static void isa_intr_enable(int irq) { @@ -231,33 +118,9 @@ isa_irq_mask(void) static int isa_probe(device_t dev) { - int i; - device_set_desc(dev, "ISA bus"); - - /* - * Add all devices configured to be attached to isa0. - */ - for (i = resource_query_string(-1, "at", "isa0"); - i != -1; - i = resource_query_string(i, "at", "isa0")) { - isa_add_device(dev, resource_query_name(i), - resource_query_unit(i)); - } - - /* - * and isa? - */ - for (i = resource_query_string(-1, "at", "isa"); - i != -1; - i = resource_query_string(i, "at", "isa")) { - isa_add_device(dev, resource_query_name(i), - resource_query_unit(i)); - } - isa_init_intr(); - - return 0; + return bus_generic_probe(dev); } extern device_t isa_bus_device; @@ -275,6 +138,39 @@ isa_attach(device_t dev) return 0; } +/* + * Add a new child with default ivars. + */ +static device_t +isa_add_child(device_t dev, device_t place, const char *name, int unit) +{ + struct isa_device *idev; + + idev = malloc(sizeof(struct isa_device), M_ISADEV, M_NOWAIT); + if (!idev) + return 0; + bzero(idev, sizeof *idev); + + idev->id_port[0] = -1; + idev->id_port[1] = -1; + idev->id_portsize[0] = 0; + idev->id_portsize[1] = 0; + idev->id_maddr[0] = 0; + idev->id_maddr[1] = 0; + idev->id_msize[0] = 0; + idev->id_msize[1] = 0; + idev->id_irq[0] = -1; + idev->id_irq[1] = -1; + idev->id_drq[0] = -1; + idev->id_drq[1] = -1; + idev->id_flags = 0; + + if (place) + return device_add_child_after(dev, place, name, unit, idev); + else + return device_add_child(dev, name, unit, idev); +} + static void isa_print_child(device_t bus, device_t dev) { @@ -726,4 +622,32 @@ isa_teardown_intr(device_t dev, device_t child, return 0; } +static device_method_t isa_methods[] = { + /* Device interface */ + DEVMETHOD(device_probe, isa_probe), + DEVMETHOD(device_attach, isa_attach), + DEVMETHOD(device_detach, bus_generic_detach), + DEVMETHOD(device_shutdown, bus_generic_shutdown), + + /* Bus interface */ + DEVMETHOD(bus_add_child, isa_add_child), + DEVMETHOD(bus_print_child, isa_print_child), + DEVMETHOD(bus_read_ivar, isa_read_ivar), + DEVMETHOD(bus_write_ivar, isa_write_ivar), + DEVMETHOD(bus_alloc_resource, isa_alloc_resource), + DEVMETHOD(bus_release_resource, isa_release_resource), + DEVMETHOD(bus_activate_resource, bus_generic_activate_resource), + DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource), + DEVMETHOD(bus_setup_intr, isa_setup_intr), + DEVMETHOD(bus_teardown_intr, isa_teardown_intr), + + { 0, 0 } +}; + +static driver_t isa_driver = { + "isa", + isa_methods, + 1, /* no softc */ +}; + DRIVER_MODULE(isa, isab, isa_driver, isa_devclass, 0, 0); diff --git a/sys/amd64/isa/isa.c b/sys/amd64/isa/isa.c index 512be7a..9078b5b 100644 --- a/sys/amd64/isa/isa.c +++ b/sys/amd64/isa/isa.c @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: isa.c,v 1.124 1999/05/08 21:28:39 peter Exp $ + * $Id: isa.c,v 1.125 1999/05/08 21:59:25 dfr Exp $ */ /* @@ -92,79 +92,6 @@ struct isa_device { static devclass_t isa_devclass; -static void -isa_add_device(device_t dev, const char *name, int unit) -{ - struct isa_device *idev; - device_t child; - int sensitive, t; - static device_t last_sensitive; - - /* device-specific flag overrides any wildcard */ - sensitive = 0; - if (resource_int_value(name, unit, "sensitive", &sensitive) != 0) - resource_int_value(name, -1, "sensitive", &sensitive); - - idev = malloc(sizeof(struct isa_device), M_ISADEV, M_NOWAIT); - if (!idev) - return; - bzero(idev, sizeof *idev); - - if (resource_int_value(name, unit, "port", &t) == 0) - idev->id_port[0] = t; - else - idev->id_port[0] = -1; - idev->id_port[1] = 0; - - if (resource_int_value(name, unit, "portsize", &t) == 0) - idev->id_portsize[0] = t; - else - idev->id_portsize[0] = 0; - idev->id_portsize[1] = 0; - - if (resource_int_value(name, unit, "maddr", &t) == 0) - idev->id_maddr[0] = t; - else - idev->id_maddr[0] = 0; - idev->id_maddr[1] = 0; - - if (resource_int_value(name, unit, "msize", &t) == 0) - idev->id_msize[0] = t; - else - idev->id_msize[0] = 0; - idev->id_msize[1] = 0; - - if (resource_int_value(name, unit, "flags", &t) == 0) - idev->id_flags = t; - else - idev->id_flags = 0; - - if (resource_int_value(name, unit, "irq", &t) == 0) - idev->id_irq[0] = t; - else - idev->id_irq[0] = -1; - idev->id_irq[1] = -1; - - if (resource_int_value(name, unit, "drq", &t) == 0) - idev->id_drq[0] = t; - else - idev->id_drq[0] = -1; - idev->id_drq[1] = -1; - - if (sensitive) - child = device_add_child_after(dev, last_sensitive, name, - unit, idev); - else - child = device_add_child(dev, name, unit, idev); - if (child == 0) - return; - else if (sensitive) - last_sensitive = child; - - if (resource_int_value(name, unit, "disabled", &t) == 0 && t != 0) - device_disable(child); -} - /* * At 'probe' time, we add all the devices which we know about to the * bus. The generic attach routine will probe and attach them if they @@ -173,39 +100,8 @@ isa_add_device(device_t dev, const char *name, int unit) static int isa_probe(device_t dev) { - int i; - static char buf[] = "isaXXX"; - - device_set_desc(dev, "ISA bus"); - - /* - * Add all devices configured to be attached to isa0. - */ - sprintf(buf, "isa%d", device_get_unit(dev)); - for (i = resource_query_string(-1, "at", buf); - i != -1; - i = resource_query_string(i, "at", buf)) { - if (strcmp(resource_query_name(i), "atkbd") == 0) - continue; /* old GENERIC kludge */ - isa_add_device(dev, resource_query_name(i), - resource_query_unit(i)); - } - - /* - * and isa? - */ - for (i = resource_query_string(-1, "at", "isa"); - i != -1; - i = resource_query_string(i, "at", "isa")) { - if (strcmp(resource_query_name(i), "atkbd") == 0) - continue; /* old GENERIC kludge */ - isa_add_device(dev, resource_query_name(i), - resource_query_unit(i)); - } - isa_wrap_old_drivers(); - - return 0; + return bus_generic_probe(dev); } extern device_t isa_bus_device; @@ -220,6 +116,39 @@ isa_attach(device_t dev) return 0; } +/* + * Add a new child with default ivars. + */ +static device_t +isa_add_child(device_t dev, device_t place, const char *name, int unit) +{ + struct isa_device *idev; + + idev = malloc(sizeof(struct isa_device), M_ISADEV, M_NOWAIT); + if (!idev) + return 0; + bzero(idev, sizeof *idev); + + idev->id_port[0] = -1; + idev->id_port[1] = -1; + idev->id_portsize[0] = 0; + idev->id_portsize[1] = 0; + idev->id_maddr[0] = 0; + idev->id_maddr[1] = 0; + idev->id_msize[0] = 0; + idev->id_msize[1] = 0; + idev->id_irq[0] = -1; + idev->id_irq[1] = -1; + idev->id_drq[0] = -1; + idev->id_drq[1] = -1; + idev->id_flags = 0; + + if (place) + return device_add_child_after(dev, place, name, unit, idev); + else + return device_add_child(dev, name, unit, idev); +} + static void isa_print_child(device_t bus, device_t dev) { @@ -588,6 +517,7 @@ static device_method_t isa_methods[] = { DEVMETHOD(device_resume, bus_generic_resume), /* Bus interface */ + DEVMETHOD(bus_add_child, isa_add_child), DEVMETHOD(bus_print_child, isa_print_child), DEVMETHOD(bus_read_ivar, isa_read_ivar), DEVMETHOD(bus_write_ivar, isa_write_ivar), diff --git a/sys/conf/files b/sys/conf/files index fb36829..70db9c6 100644 --- a/sys/conf/files +++ b/sys/conf/files @@ -714,3 +714,4 @@ dev/usb/ulpt.c optional ulpt device-driver dev/usb/ukbd.c optional ukbd device-driver dev/usb/umass.c optional umass device-driver dev/usb/uhub.c optional usb device-driver +isa/isahint.c optional isa device-driver diff --git a/sys/i386/isa/isa.c b/sys/i386/isa/isa.c index 512be7a..9078b5b 100644 --- a/sys/i386/isa/isa.c +++ b/sys/i386/isa/isa.c @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: isa.c,v 1.124 1999/05/08 21:28:39 peter Exp $ + * $Id: isa.c,v 1.125 1999/05/08 21:59:25 dfr Exp $ */ /* @@ -92,79 +92,6 @@ struct isa_device { static devclass_t isa_devclass; -static void -isa_add_device(device_t dev, const char *name, int unit) -{ - struct isa_device *idev; - device_t child; - int sensitive, t; - static device_t last_sensitive; - - /* device-specific flag overrides any wildcard */ - sensitive = 0; - if (resource_int_value(name, unit, "sensitive", &sensitive) != 0) - resource_int_value(name, -1, "sensitive", &sensitive); - - idev = malloc(sizeof(struct isa_device), M_ISADEV, M_NOWAIT); - if (!idev) - return; - bzero(idev, sizeof *idev); - - if (resource_int_value(name, unit, "port", &t) == 0) - idev->id_port[0] = t; - else - idev->id_port[0] = -1; - idev->id_port[1] = 0; - - if (resource_int_value(name, unit, "portsize", &t) == 0) - idev->id_portsize[0] = t; - else - idev->id_portsize[0] = 0; - idev->id_portsize[1] = 0; - - if (resource_int_value(name, unit, "maddr", &t) == 0) - idev->id_maddr[0] = t; - else - idev->id_maddr[0] = 0; - idev->id_maddr[1] = 0; - - if (resource_int_value(name, unit, "msize", &t) == 0) - idev->id_msize[0] = t; - else - idev->id_msize[0] = 0; - idev->id_msize[1] = 0; - - if (resource_int_value(name, unit, "flags", &t) == 0) - idev->id_flags = t; - else - idev->id_flags = 0; - - if (resource_int_value(name, unit, "irq", &t) == 0) - idev->id_irq[0] = t; - else - idev->id_irq[0] = -1; - idev->id_irq[1] = -1; - - if (resource_int_value(name, unit, "drq", &t) == 0) - idev->id_drq[0] = t; - else - idev->id_drq[0] = -1; - idev->id_drq[1] = -1; - - if (sensitive) - child = device_add_child_after(dev, last_sensitive, name, - unit, idev); - else - child = device_add_child(dev, name, unit, idev); - if (child == 0) - return; - else if (sensitive) - last_sensitive = child; - - if (resource_int_value(name, unit, "disabled", &t) == 0 && t != 0) - device_disable(child); -} - /* * At 'probe' time, we add all the devices which we know about to the * bus. The generic attach routine will probe and attach them if they @@ -173,39 +100,8 @@ isa_add_device(device_t dev, const char *name, int unit) static int isa_probe(device_t dev) { - int i; - static char buf[] = "isaXXX"; - - device_set_desc(dev, "ISA bus"); - - /* - * Add all devices configured to be attached to isa0. - */ - sprintf(buf, "isa%d", device_get_unit(dev)); - for (i = resource_query_string(-1, "at", buf); - i != -1; - i = resource_query_string(i, "at", buf)) { - if (strcmp(resource_query_name(i), "atkbd") == 0) - continue; /* old GENERIC kludge */ - isa_add_device(dev, resource_query_name(i), - resource_query_unit(i)); - } - - /* - * and isa? - */ - for (i = resource_query_string(-1, "at", "isa"); - i != -1; - i = resource_query_string(i, "at", "isa")) { - if (strcmp(resource_query_name(i), "atkbd") == 0) - continue; /* old GENERIC kludge */ - isa_add_device(dev, resource_query_name(i), - resource_query_unit(i)); - } - isa_wrap_old_drivers(); - - return 0; + return bus_generic_probe(dev); } extern device_t isa_bus_device; @@ -220,6 +116,39 @@ isa_attach(device_t dev) return 0; } +/* + * Add a new child with default ivars. + */ +static device_t +isa_add_child(device_t dev, device_t place, const char *name, int unit) +{ + struct isa_device *idev; + + idev = malloc(sizeof(struct isa_device), M_ISADEV, M_NOWAIT); + if (!idev) + return 0; + bzero(idev, sizeof *idev); + + idev->id_port[0] = -1; + idev->id_port[1] = -1; + idev->id_portsize[0] = 0; + idev->id_portsize[1] = 0; + idev->id_maddr[0] = 0; + idev->id_maddr[1] = 0; + idev->id_msize[0] = 0; + idev->id_msize[1] = 0; + idev->id_irq[0] = -1; + idev->id_irq[1] = -1; + idev->id_drq[0] = -1; + idev->id_drq[1] = -1; + idev->id_flags = 0; + + if (place) + return device_add_child_after(dev, place, name, unit, idev); + else + return device_add_child(dev, name, unit, idev); +} + static void isa_print_child(device_t bus, device_t dev) { @@ -588,6 +517,7 @@ static device_method_t isa_methods[] = { DEVMETHOD(device_resume, bus_generic_resume), /* Bus interface */ + DEVMETHOD(bus_add_child, isa_add_child), DEVMETHOD(bus_print_child, isa_print_child), DEVMETHOD(bus_read_ivar, isa_read_ivar), DEVMETHOD(bus_write_ivar, isa_write_ivar), diff --git a/sys/isa/isahint.c b/sys/isa/isahint.c new file mode 100644 index 0000000..8010195 --- /dev/null +++ b/sys/isa/isahint.c @@ -0,0 +1,131 @@ +/*- + * Copyright (c) 1999 Doug Rabson + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $Id$ + */ + +#include <sys/param.h> +#include <sys/systm.h> +#include <sys/kernel.h> +#include <sys/bus.h> +#include <sys/module.h> +#include <isa/isavar.h> + +static void +isahint_add_device(device_t parent, const char *name, int unit) +{ + device_t child; + int sensitive, t; + static device_t last_sensitive; + + /* device-specific flag overrides any wildcard */ + sensitive = 0; + if (resource_int_value(name, unit, "sensitive", &sensitive) != 0) + resource_int_value(name, -1, "sensitive", &sensitive); + + if (sensitive) + child = BUS_ADD_CHILD(parent, last_sensitive, name, unit); + else + child = BUS_ADD_CHILD(parent, 0, name, unit); + if (child == 0) + return; + else if (sensitive) + last_sensitive = child; + + if (resource_int_value(name, unit, "port", &t) == 0) + isa_set_port(child, t); + + if (resource_int_value(name, unit, "portsize", &t) == 0) + isa_set_portsize(child, t); + + if (resource_int_value(name, unit, "maddr", &t) == 0) + isa_set_maddr(child, t); + + if (resource_int_value(name, unit, "msize", &t) == 0) + isa_set_msize(child, t); + + if (resource_int_value(name, unit, "flags", &t) == 0) + isa_set_flags(child, t); + + if (resource_int_value(name, unit, "irq", &t) == 0) + isa_set_irq(child, t); + + if (resource_int_value(name, unit, "drq", &t) == 0) + isa_set_drq(child, t); + + if (resource_int_value(name, unit, "disabled", &t) == 0 && t != 0) + device_disable(child); +} + +static void +isahint_identify(driver_t *driver, device_t parent) +{ + int i; + static char buf[] = "isaXXX"; + + /* + * Add all devices configured to be attached to parent. + */ + sprintf(buf, "isa%d", device_get_unit(parent)); + for (i = resource_query_string(-1, "at", buf); + i != -1; + i = resource_query_string(i, "at", buf)) { + if (strcmp(resource_query_name(i), "atkbd") == 0) + continue; /* old GENERIC kludge */ + isahint_add_device(parent, + resource_query_name(i), + resource_query_unit(i)); + } + + /* + * and isa? + */ + for (i = resource_query_string(-1, "at", "isa"); + i != -1; + i = resource_query_string(i, "at", "isa")) { + if (strcmp(resource_query_name(i), "atkbd") == 0) + continue; /* old GENERIC kludge */ + isahint_add_device(parent, + resource_query_name(i), + resource_query_unit(i)); + } +} + +static device_method_t isahint_methods[] = { + /* Device interface */ + DEVMETHOD(device_identify, isahint_identify), + + { 0, 0 } +}; + +static driver_t isahint_driver = { + "hint", + isahint_methods, + 1, /* no softc */ +}; + +static devclass_t hint_devclass; + +DRIVER_MODULE(isahint, isa, isahint_driver, hint_devclass, 0, 0); diff --git a/sys/isa/isavar.h b/sys/isa/isavar.h index dd50a60..a20f66d 100644 --- a/sys/isa/isavar.h +++ b/sys/isa/isavar.h @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: isavar.h,v 1.4 1999/04/21 07:26:28 peter Exp $ + * $Id: isavar.h,v 1.5 1999/05/08 18:11:04 peter Exp $ */ #define ISA_NPORT_IVARS 2 @@ -79,9 +79,9 @@ static __inline void isa_set_ ## A(device_t dev, T t) \ ISA_ACCESSOR(port, PORT, int) ISA_ACCESSOR(portsize, PORTSIZE, int) -ISA_ACCESSOR(flags, FLAGS, int) ISA_ACCESSOR(irq, IRQ, int) ISA_ACCESSOR(drq, DRQ, int) ISA_ACCESSOR(maddr, MADDR, int) ISA_ACCESSOR(msize, MSIZE, int) +ISA_ACCESSOR(flags, FLAGS, int) diff --git a/sys/kern/bus_if.m b/sys/kern/bus_if.m index 33383ff..1a142a1 100644 --- a/sys/kern/bus_if.m +++ b/sys/kern/bus_if.m @@ -23,7 +23,7 @@ # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # -# $Id: bus_if.m,v 1.8 1999/05/08 21:59:34 dfr Exp $ +# $Id: bus_if.m,v 1.9 1999/05/10 17:06:12 dfr Exp $ # INTERFACE bus; @@ -104,6 +104,19 @@ METHOD void driver_added { } # +# For busses which use use drivers supporting DEVICE_IDENTIFY to +# enumerate their devices, these methods are used to create new +# device instances. If place is non-NULL, the new device will be +# added after place in the list of devices. +# +METHOD device_t add_child { + device_t dev; + device_t place; + const char *name; + int unit; +}; + +# # Allocate a system resource attached to `dev' on behalf of `child'. # The types are defined in <machine/resource.h>; the meaning of the # resource-ID field varies from bus to bus (but *rid == 0 is always diff --git a/sys/kern/device_if.m b/sys/kern/device_if.m index 0d8e8f4..c927e02 100644 --- a/sys/kern/device_if.m +++ b/sys/kern/device_if.m @@ -23,7 +23,7 @@ # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # -# $Id: device_if.m,v 1.3 1998/11/14 21:58:51 wollman Exp $ +# $Id: device_if.m,v 1.4 1999/05/10 17:06:13 dfr Exp $ # INTERFACE device; @@ -75,6 +75,14 @@ METHOD int probe { }; # +# Called by a parent bus to add new devices to the bus. +# +STATICMETHOD void identify { + driver_t *driver; + device_t parent; +}; + +# # Attach a device to the system. The probe method will have been # called and will have indicated that the device exists. This routine # should initialise the hardware and allocate other system resources diff --git a/sys/kern/subr_bus.c b/sys/kern/subr_bus.c index bdfead6..1e70ff1 100644 --- a/sys/kern/subr_bus.c +++ b/sys/kern/subr_bus.c @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: subr_bus.c,v 1.21 1999/05/10 17:06:14 dfr Exp $ + * $Id: subr_bus.c,v 1.22 1999/05/14 09:13:43 dfr Exp $ */ #include <sys/param.h> @@ -1604,6 +1604,22 @@ SYSINIT(cfgload, SI_SUB_KMEM, SI_ORDER_ANY + 50, resource_cfgload, 0) /* * Some useful method implementations to make life easier for bus drivers. */ + +/* + * Call DEVICE_IDENTIFY for each driver. + */ +int +bus_generic_probe(device_t dev) +{ + devclass_t dc = dev->devclass; + driverlink_t dl; + + for (dl = TAILQ_FIRST(&dc->drivers); dl; dl = TAILQ_NEXT(dl, link)) + DEVICE_IDENTIFY(dl->driver, dev); + + return 0; +} + int bus_generic_attach(device_t dev) { diff --git a/sys/sys/bus.h b/sys/sys/bus.h index 8446884..7ee1530 100644 --- a/sys/sys/bus.h +++ b/sys/sys/bus.h @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: bus.h,v 1.14 1999/05/08 21:59:43 dfr Exp $ + * $Id: bus.h,v 1.15 1999/05/09 13:00:49 phk Exp $ */ #ifndef _SYS_BUS_H_ @@ -108,6 +108,7 @@ int bus_generic_deactivate_resource(device_t dev, device_t child, int type, int bus_generic_detach(device_t dev); void bus_generic_driver_added(device_t dev, driver_t *driver); void bus_generic_print_child(device_t dev, device_t child); +int bus_generic_probe(device_t dev); int bus_generic_read_ivar(device_t dev, device_t child, int which, uintptr_t *result); int bus_generic_release_resource(device_t bus, device_t child, |