* Change device_add_child_after() to device_add_child_ordered() which is

easier to use and more flexible.
* Change BUS_ADD_CHILD to take an order argument instead of a place.
* Define a partial ordering for isa devices so that sensitive devices are
  probed before non-sensitive ones.
This commit is contained in:
dfr 1999-05-28 09:25:16 +00:00
parent 0e927447e3
commit c10ae458eb
7 changed files with 59 additions and 45 deletions

View File

@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id$
* $Id: isa_common.c,v 1.1 1999/05/22 15:18:23 dfr Exp $
*/
/*
* Modifications for Intel architecture by Garrett A. Wollman.
@ -109,7 +109,7 @@ isa_attach(device_t dev)
* Add a new child with default ivars.
*/
static device_t
isa_add_child(device_t dev, device_t place, const char *name, int unit)
isa_add_child(device_t dev, int order, const char *name, int unit)
{
struct isa_device *idev;
@ -121,10 +121,7 @@ isa_add_child(device_t dev, device_t place, const char *name, int unit)
resource_list_init(&idev->id_resources);
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);
return device_add_child_ordered(dev, order, name, unit, idev);
}
static void

View File

@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: isahint.c,v 1.1 1999/05/14 11:22:33 dfr Exp $
* $Id: isahint.c,v 1.2 1999/05/22 15:18:26 dfr Exp $
*/
#include <sys/param.h>
@ -39,7 +39,7 @@ isahint_add_device(device_t parent, const char *name, int unit)
{
device_t child;
int sensitive, start, count, t;
static device_t last_sensitive;
int order;
/* device-specific flag overrides any wildcard */
sensitive = 0;
@ -47,13 +47,13 @@ isahint_add_device(device_t parent, const char *name, int unit)
resource_int_value(name, -1, "sensitive", &sensitive);
if (sensitive)
child = BUS_ADD_CHILD(parent, last_sensitive, name, unit);
order = ISA_ORDER_SENSITIVE;
else
child = BUS_ADD_CHILD(parent, 0, name, unit);
order = ISA_ORDER_SPECULATIVE;
child = BUS_ADD_CHILD(parent, order, name, unit);
if (child == 0)
return;
else if (sensitive)
last_sensitive = child;
start = 0;
count = 0;

View File

@ -23,11 +23,22 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: isavar.h,v 1.6 1999/05/14 11:22:35 dfr Exp $
* $Id: isavar.h,v 1.7 1999/05/22 15:18:28 dfr Exp $
*/
#include "isa_if.h"
/*
* ISA devices are partially ordered to ensure that devices which are
* sensitive to other driver probe routines are probed first. Plug and
* Play devices are added after devices with speculative probes so that
* the legacy hardware can claim resources allowing the Plug and Play
* hardware to choose different resources.
*/
#define ISA_ORDER_SENSITIVE 0 /* legacy sensitive hardware */
#define ISA_ORDER_SPECULATIVE 1 /* legacy non-sensitive hardware */
#define ISA_ORDER_PNP 2 /* plug-and-play hardware */
#define ISA_NPORT_IVARS 2
#define ISA_NMEM_IVARS 2
#define ISA_NIRQ_IVARS 2

View File

@ -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.9 1999/05/10 17:06:12 dfr Exp $
# $Id: bus_if.m,v 1.10 1999/05/14 11:22:39 dfr Exp $
#
INTERFACE bus;
@ -107,11 +107,11 @@ 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.
# added after the last existing child with the same order.
#
METHOD device_t add_child {
device_t dev;
device_t place;
int order;
const char *name;
int unit;
};

View File

@ -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.26 1999/05/22 14:57:15 dfr Exp $
* $Id: subr_bus.c,v 1.27 1999/05/27 07:18:41 dfr Exp $
*/
#include <sys/param.h>
@ -604,6 +604,7 @@ make_device(device_t parent, const char *name,
dev->desc = NULL;
dev->busy = 0;
dev->flags = DF_ENABLED;
dev->order = 0;
if (unit == -1)
dev->flags |= DF_WILDCARD;
if (name) {
@ -634,38 +635,40 @@ device_print_child(device_t dev, device_t child)
device_t
device_add_child(device_t dev, const char *name, int unit, void *ivars)
{
device_t child;
PDEBUG(("%s at %s as unit %d with%s ivars",
name, DEVICENAME(dev), unit, (ivars? "":"out")));
child = make_device(dev, name, unit, ivars);
if (child)
TAILQ_INSERT_TAIL(&dev->children, child, link);
else
PDEBUG(("%s failed", name));
return child;
return device_add_child_ordered(dev, 0, name, unit, ivars);
}
device_t
device_add_child_after(device_t dev, device_t place, const char *name,
int unit, void *ivars)
device_add_child_ordered(device_t dev, int order,
const char *name, int unit, void *ivars)
{
device_t child;
device_t place;
PDEBUG(("%s at %s after %s as unit %d with%s ivars",
name, DEVICENAME(dev), DEVICENAME(place), unit, (ivars? "":"out")));
PDEBUG(("%s at %s with order %d as unit %d with%s ivars",
name, DEVICENAME(dev), order, unit, (ivars? "":"out")));
child = make_device(dev, name, unit, ivars);
if (child == NULL)
return child;
child->order = order;
TAILQ_FOREACH(place, &dev->children, link)
if (place->order > order)
break;
if (place) {
TAILQ_INSERT_AFTER(&dev->children, place, child, link);
/*
* The device 'place' is the first device whose order is
* greater than the new child.
*/
TAILQ_INSERT_BEFORE(place, child, link);
} else {
TAILQ_INSERT_HEAD(&dev->children, child, link);
/*
* The new child's order is greater or equal to the order of
* any existing device. Add the child to the tail of the list.
*/
TAILQ_INSERT_TAIL(&dev->children, child, link);
}
return child;

View File

@ -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.16 1999/05/14 11:22:47 dfr Exp $
* $Id: bus.h,v 1.17 1999/05/22 14:57:13 dfr Exp $
*/
#ifndef _SYS_BUS_H_
@ -213,8 +213,9 @@ int bus_teardown_intr(device_t dev, struct resource *r, void *cookie);
*/
device_t device_add_child(device_t dev, const char *name, int unit,
void *ivp);
device_t device_add_child_after(device_t dev, device_t place,
const char *name, int unit, void *ivp);
device_t device_add_child_ordered(device_t dev, int order,
const char *name, int unit,
void *ivp);
void device_busy(device_t dev);
int device_delete_child(device_t dev, device_t child);
int device_detach(device_t dev);

View File

@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: bus_private.h,v 1.7 1999/05/10 17:06:11 dfr Exp $
* $Id: bus_private.h,v 1.8 1999/05/14 09:13:39 dfr Exp $
*/
#ifndef _SYS_BUS_PRIVATE_H_
@ -127,16 +127,18 @@ struct device {
char* desc; /* driver specific description */
int busy; /* count of calls to device_busy() */
device_state_t state;
int flags;
#ifdef DEVICE_SYSCTLS
struct sysctl_oid oid[4];
struct sysctl_oid_list oidlist[1];
#endif
u_short flags;
#define DF_ENABLED 1 /* device should be probed/attached */
#define DF_FIXEDCLASS 2 /* devclass specified at create time */
#define DF_WILDCARD 4 /* unit was originally wildcard */
#define DF_DESCMALLOCED 8 /* description was malloced */
#define DF_QUIET 16 /* don't print verbose attach message */
u_char order; /* order from device_add_child_ordered() */
u_char pad;
#ifdef DEVICE_SYSCTLS
struct sysctl_oid oid[4];
struct sysctl_oid_list oidlist[1];
#endif
void *ivars;
void *softc;
};