From 7e9a7073ef377ae41f09b4dfb21c34a4a6b3a12c Mon Sep 17 00:00:00 2001 From: imp Date: Fri, 18 Mar 2005 05:19:50 +0000 Subject: [PATCH] Use STAILQ in preference to SLIST for the resources. Insert new resources last in the list rather than first. This makes the resouces print in the 4.x order rather than the 5.x order (eg fdc0 at 0x3f0-0x3f5,0x3f7 is 4.x, but 0x3f7,0x3f0-0x3f5 is 5.x). This also means that the pci code will once again print the resources in BAR ascending order. --- sys/dev/cardbus/cardbus.c | 8 ++++---- sys/dev/pccard/pccard.c | 2 +- sys/dev/pci/pci.c | 2 +- sys/i386/i386/nexus.c | 2 +- sys/isa/isa_common.c | 10 +++++----- sys/kern/subr_bus.c | 14 +++++++------- sys/sys/bus.h | 4 ++-- 7 files changed, 21 insertions(+), 21 deletions(-) diff --git a/sys/dev/cardbus/cardbus.c b/sys/dev/cardbus/cardbus.c index 6514396a7a93..be90c8889af4 100644 --- a/sys/dev/cardbus/cardbus.c +++ b/sys/dev/cardbus/cardbus.c @@ -107,7 +107,7 @@ cardbus_add_map(device_t cbdev, device_t child, int reg) uint32_t testval; int type; - SLIST_FOREACH(rle, &dinfo->pci.resources, link) { + STAILQ_FOREACH(rle, &dinfo->pci.resources, link) { if (rle->rid == reg) return; } @@ -179,7 +179,7 @@ cardbus_alloc_resources(device_t cbdev, device_t child) int rid, flags; count = 0; - SLIST_FOREACH(rle, &dinfo->pci.resources, link) { + STAILQ_FOREACH(rle, &dinfo->pci.resources, link) { count++; } if (count == 0) @@ -187,7 +187,7 @@ cardbus_alloc_resources(device_t cbdev, device_t child) barlist = malloc(sizeof(struct resource_list_entry*) * count, M_DEVBUF, M_WAITOK); count = 0; - SLIST_FOREACH(rle, &dinfo->pci.resources, link) { + STAILQ_FOREACH(rle, &dinfo->pci.resources, link) { barlist[count] = rle; if (rle->type == SYS_RES_IOPORT) { io_size += rle->count; @@ -561,7 +561,7 @@ cardbus_release_all_resources(device_t cbdev, struct cardbus_devinfo *dinfo) struct resource_list_entry *rle; /* Free all allocated resources */ - SLIST_FOREACH(rle, &dinfo->pci.resources, link) { + STAILQ_FOREACH(rle, &dinfo->pci.resources, link) { if (rle->res) { if (rman_get_device(rle->res) != cbdev) device_printf(cbdev, "release_all_resource: " diff --git a/sys/dev/pccard/pccard.c b/sys/dev/pccard/pccard.c index d92435820523..167ab8ef8f51 100644 --- a/sys/dev/pccard/pccard.c +++ b/sys/dev/pccard/pccard.c @@ -534,7 +534,7 @@ pccard_function_free(struct pccard_function *pf) return; } - SLIST_FOREACH(rle, &devi->resources, link) { + STAILQ_FOREACH(rle, &devi->resources, link) { if (rle->res) { if (rman_get_device(rle->res) != pf->sc->dev) device_printf(pf->sc->dev, diff --git a/sys/dev/pci/pci.c b/sys/dev/pci/pci.c index 445b32b6a1d4..8303c3b82c0e 100644 --- a/sys/dev/pci/pci.c +++ b/sys/dev/pci/pci.c @@ -1000,6 +1000,7 @@ pci_add_child(device_t bus, struct pci_devinfo *dinfo) pcib = device_get_parent(bus); dinfo->cfg.dev = device_add_child(bus, NULL, -1); device_set_ivars(dinfo->cfg.dev, dinfo); + resource_list_init(&dinfo->resources); pci_cfg_save(dinfo->cfg.dev, dinfo, 0); pci_cfg_restore(dinfo->cfg.dev, dinfo); pci_add_resources(pcib, bus, dinfo->cfg.dev); @@ -1153,7 +1154,6 @@ pci_driver_added(device_t dev, driver_t *driver) continue; dinfo = device_get_ivars(child); pci_print_verbose(dinfo); -/*XXX???*/ /* resource_list_init(&dinfo->cfg.resources); */ if (bootverbose) printf("pci%d:%d:%d: reprobing on driver added\n", dinfo->cfg.bus, dinfo->cfg.slot, dinfo->cfg.func); diff --git a/sys/i386/i386/nexus.c b/sys/i386/i386/nexus.c index 75fe064850aa..e8d1406d29ee 100644 --- a/sys/i386/i386/nexus.c +++ b/sys/i386/i386/nexus.c @@ -249,7 +249,7 @@ nexus_print_all_resources(device_t dev) struct resource_list *rl = &ndev->nx_resources; int retval = 0; - if (SLIST_FIRST(rl)) + if (STAILQ_FIRST(rl)) retval += printf(" at"); retval += resource_list_print_type(rl, "port", SYS_RES_IOPORT, "%#lx"); diff --git a/sys/isa/isa_common.c b/sys/isa/isa_common.c index 9948955365c8..36f3d79061d5 100644 --- a/sys/isa/isa_common.c +++ b/sys/isa/isa_common.c @@ -597,7 +597,7 @@ isa_probe_children(device_t dev) * Claim any unallocated resources to keep other * devices from using them. */ - SLIST_FOREACH(rle, rl, link) { + STAILQ_FOREACH(rle, rl, link) { if (!rle->res) { int rid = rle->rid; resource_list_alloc(rl, dev, child, @@ -646,7 +646,7 @@ isa_print_all_resources(device_t dev) struct resource_list *rl = &idev->id_resources; int retval = 0; - if (SLIST_FIRST(rl) || device_get_flags(dev)) + if (STAILQ_FIRST(rl) || device_get_flags(dev)) retval += printf(" at"); retval += resource_list_print_type(rl, "port", SYS_RES_IOPORT, "%#lx"); @@ -878,7 +878,7 @@ isa_child_detached(device_t dev, device_t child) * Claim any unallocated resources to keep other * devices from using them. */ - SLIST_FOREACH(rle, rl, link) { + STAILQ_FOREACH(rle, rl, link) { if (!rle->res) { int rid = rle->rid; resource_list_alloc(rl, dev, child, @@ -923,7 +923,7 @@ isa_driver_added(device_t dev, driver_t *driver) * Free resources which we were holding on behalf of * the device. */ - SLIST_FOREACH(rle, &idev->id_resources, link) { + STAILQ_FOREACH(rle, &idev->id_resources, link) { if (rle->res) resource_list_release(rl, dev, child, rle->type, @@ -942,7 +942,7 @@ isa_driver_added(device_t dev, driver_t *driver) * Claim any unallocated resources to keep other * devices from using them. */ - SLIST_FOREACH(rle, rl, link) { + STAILQ_FOREACH(rle, rl, link) { if (!rle->res) { int rid = rle->rid; resource_list_alloc(rl, dev, child, diff --git a/sys/kern/subr_bus.c b/sys/kern/subr_bus.c index 15312ca7c3dc..570eca769130 100644 --- a/sys/kern/subr_bus.c +++ b/sys/kern/subr_bus.c @@ -2462,7 +2462,7 @@ device_set_unit(device_t dev, int unit) void resource_list_init(struct resource_list *rl) { - SLIST_INIT(rl); + STAILQ_INIT(rl); } /** @@ -2478,10 +2478,10 @@ resource_list_free(struct resource_list *rl) { struct resource_list_entry *rle; - while ((rle = SLIST_FIRST(rl)) != NULL) { + while ((rle = STAILQ_FIRST(rl)) != NULL) { if (rle->res) panic("resource_list_free: resource entry is busy"); - SLIST_REMOVE_HEAD(rl, link); + STAILQ_REMOVE_HEAD(rl, link); free(rle, M_BUS); } } @@ -2539,7 +2539,7 @@ resource_list_add(struct resource_list *rl, int type, int rid, M_NOWAIT); if (!rle) panic("resource_list_add: can't record entry"); - SLIST_INSERT_HEAD(rl, rle, link); + STAILQ_INSERT_TAIL(rl, rle, link); rle->type = type; rle->rid = rid; rle->res = NULL; @@ -2568,7 +2568,7 @@ resource_list_find(struct resource_list *rl, int type, int rid) { struct resource_list_entry *rle; - SLIST_FOREACH(rle, rl, link) { + STAILQ_FOREACH(rle, rl, link) { if (rle->type == type && rle->rid == rid) return (rle); } @@ -2590,7 +2590,7 @@ resource_list_delete(struct resource_list *rl, int type, int rid) if (rle) { if (rle->res != NULL) panic("resource_list_delete: resource has not been released"); - SLIST_REMOVE(rl, rle, resource_list_entry, link); + STAILQ_REMOVE(rl, rle, resource_list_entry, link); free(rle, M_BUS); } } @@ -2741,7 +2741,7 @@ resource_list_print_type(struct resource_list *rl, const char *name, int type, printed = 0; retval = 0; /* Yes, this is kinda cheating */ - SLIST_FOREACH(rle, rl, link) { + STAILQ_FOREACH(rle, rl, link) { if (rle->type == type) { if (printed == 0) retval += printf(" %s ", name); diff --git a/sys/sys/bus.h b/sys/sys/bus.h index ddeda99334e2..2fbf07478bf7 100644 --- a/sys/sys/bus.h +++ b/sys/sys/bus.h @@ -194,7 +194,7 @@ struct resource; * @brief An entry for a single resource in a resource list. */ struct resource_list_entry { - SLIST_ENTRY(resource_list_entry) link; + STAILQ_ENTRY(resource_list_entry) link; int type; /**< @brief type argument to alloc_resource */ int rid; /**< @brief resource identifier */ struct resource *res; /**< @brief the real resource when allocated */ @@ -202,7 +202,7 @@ struct resource_list_entry { u_long end; /**< @brief end of resource range */ u_long count; /**< @brief count within range */ }; -SLIST_HEAD(resource_list, resource_list_entry); +STAILQ_HEAD(resource_list, resource_list_entry); void resource_list_init(struct resource_list *rl); void resource_list_free(struct resource_list *rl);