* 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.
This commit is contained in:
parent
d45204676e
commit
6c2e3dde8c
@ -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);
|
||||
|
@ -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),
|
||||
|
@ -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
|
||||
|
@ -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),
|
||||
|
131
sys/isa/isahint.c
Normal file
131
sys/isa/isahint.c
Normal file
@ -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);
|
@ -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)
|
||||
|
||||
|
@ -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;
|
||||
@ -103,6 +103,19 @@ METHOD void driver_added {
|
||||
driver_t *driver;
|
||||
}
|
||||
|
||||
#
|
||||
# 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
|
||||
|
@ -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;
|
||||
@ -74,6 +74,14 @@ METHOD int probe {
|
||||
device_t dev;
|
||||
};
|
||||
|
||||
#
|
||||
# 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
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user