--- //depot/vendor/freebsd/src/sys/dev/acpica/acpi.c 2010-11-08 19:55:16.000000000 0000 +++ //depot/user/jhb/acpipci/dev/acpica/acpi.c 2010-11-19 13:41:12.000000000 0000 @@ -116,7 +116,10 @@ static int acpi_write_ivar(device_t dev, device_t child, int index, uintptr_t value); static struct resource_list *acpi_get_rlist(device_t dev, device_t child); +static void acpi_reserve_resources(device_t dev); static int acpi_sysres_alloc(device_t dev); +static int acpi_set_resource(device_t dev, device_t child, int type, + int rid, u_long start, u_long count); static struct resource *acpi_alloc_resource(device_t bus, device_t child, int type, int *rid, u_long start, u_long end, u_long count, u_int flags); @@ -187,7 +190,7 @@ DEVMETHOD(bus_read_ivar, acpi_read_ivar), DEVMETHOD(bus_write_ivar, acpi_write_ivar), DEVMETHOD(bus_get_resource_list, acpi_get_rlist), - DEVMETHOD(bus_set_resource, bus_generic_rl_set_resource), + DEVMETHOD(bus_set_resource, acpi_set_resource), DEVMETHOD(bus_get_resource, bus_generic_rl_get_resource), DEVMETHOD(bus_alloc_resource, acpi_alloc_resource), DEVMETHOD(bus_release_resource, acpi_release_resource), @@ -1103,73 +1102,144 @@ return (0); } -static struct resource * -acpi_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 char *pcilink_ids[] = { "PNP0C0F", NULL }; +static char *sysres_ids[] = { "PNP0C01", "PNP0C02", NULL }; + +/* + * Reserve declared resources for devices found during attach once system + * resources have been allocated. + */ +static void +acpi_reserve_resources(device_t dev) +{ + struct resource_list_entry *rle; + struct resource_list *rl; + struct acpi_device *ad; + struct acpi_softc *sc; + device_t *children; + int child_count, i; + + sc = device_get_softc(dev); + if (device_get_children(dev, &children, &child_count) != 0) + return; + for (i = 0; i < child_count; i++) { + ad = device_get_ivars(children[i]); + rl = &ad->ad_rl; + + /* Don't reserve system resources. */ + if (ACPI_ID_PROBE(dev, children[i], sysres_ids) != NULL) + continue; + + STAILQ_FOREACH(rle, rl, link) { + /* + * Don't reserve IRQ resources. There are many sticky things + * to get right otherwise (e.g. IRQs for psm, atkbd, and HPET + * when using legacy routing). + */ + if (rle->type == SYS_RES_IRQ) + continue; + + /* + * Try to reserve the resource from our parent. If this + * fails because the resource is a system resource, just + * let it be. The resource range is already reserved so + * that other devices will not use it. If the driver + * needs to allocate the resource, then + * acpi_alloc_resource() will sub-alloc from the system + * resource. + */ + resource_list_reserve(rl, dev, children[i], rle->type, &rle->rid, + rle->start, rle->end, rle->count, 0); + } + } + free(children, M_TEMP); + sc->acpi_resources_reserved = 1; +} + +static int +acpi_set_resource(device_t dev, device_t child, int type, int rid, + u_long start, u_long count) { - ACPI_RESOURCE ares; + struct acpi_softc *sc = device_get_softc(dev); struct acpi_device *ad = device_get_ivars(child); struct resource_list *rl = &ad->ad_rl; - struct resource_list_entry *rle; - struct resource *res; - struct rman *rm; + u_long end; + + /* Ignore IRQ resources for PCI link devices. */ + if (type == SYS_RES_IRQ && ACPI_ID_PROBE(dev, child, pcilink_ids) != NULL) + return (0); + + /* If the resource is already allocated, fail. */ + if (resource_list_busy(rl, type, rid)) + return (EBUSY); + + /* If the resource is already reserved, release it. */ + if (resource_list_reserved(rl, type, rid)) + resource_list_unreserve(rl, dev, child, type, rid); + + /* Add the resource. */ + end = (start + count - 1); + resource_list_add(rl, type, rid, start, end, count); - res = NULL; + /* Don't reserve resources until the system resources are allocated. */ + if (!sc->acpi_resources_reserved) + return (0); - /* We only handle memory and IO resources through rman. */ - switch (type) { - case SYS_RES_IOPORT: - rm = &acpi_rman_io; - break; - case SYS_RES_MEMORY: - rm = &acpi_rman_mem; - break; - default: - rm = NULL; - } - - ACPI_SERIAL_BEGIN(acpi); + /* Don't reserve system resources. */ + if (ACPI_ID_PROBE(dev, child, sysres_ids) != NULL) + return (0); /* - * If this is an allocation of the "default" range for a given RID, and - * we know what the resources for this device are (i.e., they're on the - * child's resource list), use those start/end values. + * Don't reserve IRQ resources. There are many sticky things to + * get right otherwise (e.g. IRQs for psm, atkbd, and HPET when + * using legacy routing). */ - if (bus == device_get_parent(child) && start == 0UL && end == ~0UL) { - rle = resource_list_find(rl, type, *rid); - if (rle == NULL) - goto out; - start = rle->start; - end = rle->end; - count = rle->count; - } + if (type == SYS_RES_IRQ) + return (0); /* - * If this is an allocation of a specific range, see if we can satisfy - * the request from our system resource regions. If we can't, pass the - * request up to the parent. + * Reserve the resource. + * + * XXX: Ignores failure for now. Failure here is probably a + * BIOS/firmware bug? */ - if (start + count - 1 == end && rm != NULL) - res = rman_reserve_resource(rm, start, end, count, flags & ~RF_ACTIVE, - child); - if (res == NULL) { - res = BUS_ALLOC_RESOURCE(device_get_parent(bus), child, type, rid, - start, end, count, flags); - } else { - rman_set_rid(res, *rid); + resource_list_reserve(rl, dev, child, type, &rid, start, end, count, 0); + return (0); +} + +static struct resource * +acpi_alloc_resource(device_t bus, device_t child, int type, int *rid, + u_long start, u_long end, u_long count, u_int flags) +{ + ACPI_RESOURCE ares; + struct acpi_device *ad; + struct resource_list_entry *rle; + struct resource_list *rl; + struct resource *res; + struct rman *rm; + int isdefault = (start == 0UL && end == ~0UL); - /* If requested, activate the resource using the parent's method. */ - if (flags & RF_ACTIVE) - if (bus_activate_resource(child, type, *rid, res) != 0) { - rman_release_resource(res); - res = NULL; - goto out; - } - } + /* + * First attempt at allocating the resource. For direct children, + * use resource_list_alloc() to handle reserved resources. For + * other dveices, pass the request up to our parent. + */ + if (bus == device_get_parent(child)) { + ad = device_get_ivars(child); + rl = &ad->ad_rl; - if (res != NULL && device_get_parent(child) == bus) - switch (type) { - case SYS_RES_IRQ: + /* + * Simulate the behavior of the ISA bus for direct children + * devices. That is, if a non-default range is specified for + * a resource that doesn't exist, use bus_set_resource() to + * add the resource before allocating it. Note that these + * resources will not be reserved. + */ + if (!isdefault && resource_list_find(rl, type, *rid) == NULL) + resource_list_add(rl, type, *rid, start, end, count); + res = resource_list_alloc(rl, bus, child, type, rid, start, end, count, + flags); + if (res != NULL && type == SYS_RES_IRQ) { /* * Since bus_config_intr() takes immediate effect, we cannot * configure the interrupt associated with a device when we @@ -1180,11 +1250,59 @@ */ if (ACPI_SUCCESS(acpi_lookup_irq_resource(child, *rid, res, &ares))) acpi_config_intr(child, &ares); - break; + } + + /* + * If this is an allocation of the "default" range for a given + * RID, fetch the exact bounds for this resource from the + * resource list entry to try to allocate the range from the + * system resource regions. + */ + if (res == NULL && isdefault) { + rle = resource_list_find(rl, type, *rid); + if (rle != NULL) { + start = rle->start; + end = rle->end; + count = rle->count; + } + } + } else + res = BUS_ALLOC_RESOURCE(device_get_parent(bus), child, type, rid, + start, end, count, flags); + if (res != NULL || start + count - 1 != end) + return (res); + + /* + * If the first attempt failed and this is an allocation of a + * specific range, try to satisfy the request via a suballocation + * from our system resource regions. Note that we only handle + * memory and I/O port system resources. + */ + switch (type) { + case SYS_RES_IOPORT: + rm = &acpi_rman_io; + break; + case SYS_RES_MEMORY: + rm = &acpi_rman_mem; + break; + default: + return (NULL); + } + + res = rman_reserve_resource(rm, start, end, count, flags & ~RF_ACTIVE, + child); + if (res == NULL) + return (NULL); + + rman_set_rid(res, *rid); + + /* If requested, activate the resource using the parent's method. */ + if (flags & RF_ACTIVE) + if (bus_activate_resource(child, type, *rid, res) != 0) { + rman_release_resource(res); + return (NULL); } -out: - ACPI_SERIAL_END(acpi); return (res); } @@ -1207,26 +1325,20 @@ rm = NULL; } - ACPI_SERIAL_BEGIN(acpi); - /* * If this resource belongs to one of our internal managers, - * deactivate it and release it to the local pool. If it doesn't, - * pass this request up to the parent. + * deactivate it and release it to the local pool. */ if (rm != NULL && rman_is_region_manager(r, rm)) { if (rman_get_flags(r) & RF_ACTIVE) { ret = bus_deactivate_resource(child, type, rid, r); if (ret != 0) - goto out; + return (ret); } - ret = rman_release_resource(r); - } else - ret = BUS_RELEASE_RESOURCE(device_get_parent(bus), child, type, rid, r); + return (rman_release_resource(r)); + } -out: - ACPI_SERIAL_END(acpi); - return (ret); + return (bus_generic_rl_release_resource(bus, child, type, rid, r)); } static void @@ -1235,6 +1347,12 @@ struct resource_list *rl; rl = acpi_get_rlist(bus, child); + if (resource_list_busy(rl, type, rid)) { + device_printf(bus, "delete_resource: Resource still owned by child" + " (type=%d, rid=%d)\n", type, rid); + return; + } + resource_list_unreserve(rl, bus, child, type, rid); resource_list_delete(rl, type, rid); } @@ -1623,11 +1741,14 @@ /* Pre-allocate resources for our rman from any sysresource devices. */ acpi_sysres_alloc(bus); + /* Reserve resources already allocated to children. */ + acpi_reserve_resources(bus); + /* Create any static children by calling device identify methods. */ ACPI_DEBUG_PRINT((ACPI_DB_OBJECTS, "device identify routines\n")); bus_generic_probe(bus); - /* Probe/attach all children, created staticly and from the namespace. */ + /* Probe/attach all children, created statically and from the namespace. */ ACPI_DEBUG_PRINT((ACPI_DB_OBJECTS, "acpi bus_generic_attach\n")); bus_generic_attach(bus); --- //depot/vendor/freebsd/src/sys/dev/acpica/acpi_hpet.c 2010-12-07 18:50:17.000000000 0000 +++ //depot/user/jhb/acpipci/dev/acpica/acpi_hpet.c 2010-12-07 19:29:57.000000000 0000 @@ -558,16 +558,15 @@ } if (t->irq >= 0) { t->intr_rid = hpet_find_irq_rid(dev, t->irq, t->irq); - if (!(t->intr_res = - bus_alloc_resource(dev, SYS_RES_IRQ, &t->intr_rid, - t->irq, t->irq, 1, RF_ACTIVE))) { + t->intr_res = bus_alloc_resource(dev, SYS_RES_IRQ, + &t->intr_rid, t->irq, t->irq, 1, RF_ACTIVE); + if (t->intr_res == NULL) { t->irq = -1; device_printf(dev, "Can't map interrupt for t%d.\n", i); - } else if ((bus_setup_intr(dev, t->intr_res, - INTR_MPSAFE | INTR_TYPE_CLK, - (driver_filter_t *)hpet_intr_single, NULL, - t, &t->intr_handle))) { + } else if (bus_setup_intr(dev, t->intr_res, + INTR_TYPE_CLK, hpet_intr_single, NULL, t, + &t->intr_handle) != 0) { t->irq = -1; device_printf(dev, "Can't setup interrupt for t%d.\n", i); @@ -614,13 +613,12 @@ while (j > 0 && (cvectors & (1 << (j - 1))) != 0) j--; sc->intr_rid = hpet_find_irq_rid(dev, j, i); - if (!(sc->intr_res = bus_alloc_resource(dev, SYS_RES_IRQ, - &sc->intr_rid, j, i, 1, RF_SHAREABLE | RF_ACTIVE))) - device_printf(dev,"Can't map interrupt.\n"); - else if ((bus_setup_intr(dev, sc->intr_res, - INTR_MPSAFE | INTR_TYPE_CLK, - (driver_filter_t *)hpet_intr, NULL, - sc, &sc->intr_handle))) { + sc->intr_res = bus_alloc_resource(dev, SYS_RES_IRQ, + &sc->intr_rid, j, i, 1, RF_SHAREABLE | RF_ACTIVE); + if (sc->intr_res == NULL) + device_printf(dev, "Can't map interrupt.\n"); + else if (bus_setup_intr(dev, sc->intr_res, INTR_TYPE_CLK, + hpet_intr, NULL, sc, &sc->intr_handle) != 0) { device_printf(dev, "Can't setup interrupt.\n"); } else { sc->irq = rman_get_start(sc->intr_res); --- //depot/vendor/freebsd/src/sys/dev/acpica/acpivar.h 2010-11-10 18:55:16.000000000 0000 +++ //depot/user/jhb/acpipci/dev/acpica/acpivar.h 2010-11-14 14:40:47.000000000 0000 @@ -58,6 +58,7 @@ int acpi_enabled; int acpi_sstate; int acpi_sleep_disabled; + int acpi_resources_reserved; struct sysctl_ctx_list acpi_sysctl_ctx; struct sysctl_oid *acpi_sysctl_tree; --- //depot/vendor/freebsd/src/sys/dev/atkbdc/atkbd_atkbdc.c 2007-12-29 22:00:26.000000000 0000 +++ //depot/user/jhb/acpipci/dev/atkbdc/atkbd_atkbdc.c 2010-11-18 13:16:49.000000000 0000 @@ -94,8 +94,7 @@ /* see if IRQ is available */ rid = KBDC_RID_KBD; - res = bus_alloc_resource_any(dev, SYS_RES_IRQ, &rid, - RF_SHAREABLE | RF_ACTIVE); + res = bus_alloc_resource_any(dev, SYS_RES_IRQ, &rid, RF_ACTIVE); if (res == NULL) { if (bootverbose) device_printf(dev, "unable to allocate IRQ\n"); @@ -132,8 +131,7 @@ return error; /* declare our interrupt handler */ - sc->intr = bus_alloc_resource_any(dev, SYS_RES_IRQ, &rid, - RF_SHAREABLE | RF_ACTIVE); + sc->intr = bus_alloc_resource_any(dev, SYS_RES_IRQ, &rid, RF_ACTIVE); if (sc->intr == NULL) return ENXIO; error = bus_setup_intr(dev, sc->intr, INTR_TYPE_TTY, NULL, atkbdintr, --- //depot/vendor/freebsd/src/sys/dev/atkbdc/atkbdc_isa.c 2010-09-10 11:20:16.000000000 0000 +++ //depot/user/jhb/acpipci/dev/atkbdc/atkbdc_isa.c 2010-11-16 20:25:59.000000000 0000 @@ -49,6 +49,11 @@ static int atkbdc_isa_attach(device_t dev); static device_t atkbdc_isa_add_child(device_t bus, u_int order, const char *name, int unit); +static struct resource *atkbdc_isa_alloc_resource(device_t dev, device_t child, + int type, int *rid, u_long start, u_long end, + u_long count, u_int flags); +static int atkbdc_isa_release_resource(device_t dev, device_t child, + int type, int rid, struct resource *r); static device_method_t atkbdc_isa_methods[] = { DEVMETHOD(device_probe, atkbdc_isa_probe), @@ -61,8 +66,8 @@ DEVMETHOD(bus_read_ivar, atkbdc_read_ivar), DEVMETHOD(bus_write_ivar, atkbdc_write_ivar), DEVMETHOD(bus_get_resource_list,atkbdc_get_resource_list), - DEVMETHOD(bus_alloc_resource, bus_generic_rl_alloc_resource), - DEVMETHOD(bus_release_resource, bus_generic_rl_release_resource), + DEVMETHOD(bus_alloc_resource, atkbdc_isa_alloc_resource), + DEVMETHOD(bus_release_resource, atkbdc_isa_release_resource), DEVMETHOD(bus_activate_resource, bus_generic_activate_resource), DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource), DEVMETHOD(bus_get_resource, bus_generic_rl_get_resource), @@ -170,8 +175,6 @@ device_verbose(dev); error = atkbdc_probe_unit(device_get_unit(dev), port0, port1); - if (error == 0) - bus_generic_probe(dev); bus_release_resource(dev, SYS_RES_IOPORT, 0, port0); bus_release_resource(dev, SYS_RES_IOPORT, 1, port1); @@ -216,14 +219,25 @@ return ENXIO; } + /* + * If the device is not created by the PnP BIOS or ACPI, then + * the hint for the IRQ is on the child atkbd device, not the + * keyboard controller, so this can fail. + */ + rid = 0; + sc->irq = bus_alloc_resource_any(dev, SYS_RES_IRQ, &rid, RF_ACTIVE); + error = atkbdc_attach_unit(unit, sc, sc->port0, sc->port1); if (error) { bus_release_resource(dev, SYS_RES_IOPORT, 0, sc->port0); bus_release_resource(dev, SYS_RES_IOPORT, 1, sc->port1); + if (sc->irq != NULL) + bus_release_resource(dev, SYS_RES_IRQ, 0, sc->irq); return error; } *(atkbdc_softc_t **)device_get_softc(dev) = sc; + bus_generic_probe(dev); bus_generic_attach(dev); return 0; @@ -233,9 +247,11 @@ atkbdc_isa_add_child(device_t bus, u_int order, const char *name, int unit) { atkbdc_device_t *ivar; + atkbdc_softc_t *sc; device_t child; int t; + sc = *(atkbdc_softc_t **)device_get_softc(bus); ivar = malloc(sizeof(struct atkbdc_device), M_ATKBDDEV, M_NOWAIT | M_ZERO); if (!ivar) @@ -251,15 +267,16 @@ ivar->rid = order; /* - * If the device is not created by the PnP BIOS or ACPI, - * refer to device hints for IRQ. + * If the device is not created by the PnP BIOS or ACPI, refer + * to device hints for IRQ. We always populate the resource + * list entry so we can use a standard bus_get_resource() + * method. */ - if (ISA_PNP_PROBE(device_get_parent(bus), bus, atkbdc_ids) != 0) { + if (sc->irq == NULL) { if (resource_int_value(name, unit, "irq", &t) != 0) t = -1; - } else { - t = bus_get_resource_start(bus, SYS_RES_IRQ, ivar->rid); - } + } else + t = rman_get_start(sc->irq); if (t > 0) resource_list_add(&ivar->resources, SYS_RES_IRQ, ivar->rid, t, t, 1); @@ -272,5 +289,30 @@ return child; } +struct resource * +atkbdc_isa_alloc_resource(device_t dev, device_t child, int type, int *rid, + u_long start, u_long end, u_long count, u_int flags) +{ + atkbdc_softc_t *sc; + + sc = *(atkbdc_softc_t **)device_get_softc(dev); + if (type == SYS_RES_IRQ && *rid == KBDC_RID_KBD && sc->irq != NULL) + return (sc->irq); + return (bus_generic_rl_alloc_resource(dev, child, type, rid, start, + end, count, flags)); +} + +static int +atkbdc_isa_release_resource(device_t dev, device_t child, int type, int rid, + struct resource *r) +{ + atkbdc_softc_t *sc; + + sc = *(atkbdc_softc_t **)device_get_softc(dev); + if (type == SYS_RES_IRQ && rid == KBDC_RID_KBD && r == sc->irq) + return (0); + return (bus_generic_rl_release_resource(dev, child, type, rid, r)); +} + DRIVER_MODULE(atkbdc, isa, atkbdc_isa_driver, atkbdc_devclass, 0, 0); DRIVER_MODULE(atkbdc, acpi, atkbdc_isa_driver, atkbdc_devclass, 0, 0); --- //depot/vendor/freebsd/src/sys/dev/atkbdc/atkbdcreg.h 2010-04-29 06:20:13.000000000 0000 +++ //depot/user/jhb/acpipci/dev/atkbdc/atkbdcreg.h 2010-11-16 20:25:59.000000000 0000 @@ -192,6 +192,7 @@ typedef struct atkbdc_softc { struct resource *port0; /* data port */ struct resource *port1; /* status port */ + struct resource *irq; bus_space_tag_t iot; bus_space_handle_t ioh0; bus_space_handle_t ioh1; --- //depot/vendor/freebsd/src/sys/dev/atkbdc/psm.c 2010-11-18 22:20:18.000000000 0000 +++ //depot/user/jhb/acpipci/dev/atkbdc/psm.c 2010-11-19 17:19:02.000000000 0000 @@ -1105,6 +1105,7 @@ irq = bus_get_resource_start(psmc, SYS_RES_IRQ, 0); if (irq <= 0) return; + bus_delete_resource(psmc, SYS_RES_IRQ, 0); bus_set_resource(psm, SYS_RES_IRQ, KBDC_RID_AUX, irq, 1); } @@ -1133,8 +1134,7 @@ /* see if IRQ is available */ rid = KBDC_RID_AUX; - sc->intr = bus_alloc_resource_any(dev, SYS_RES_IRQ, &rid, - RF_SHAREABLE | RF_ACTIVE); + sc->intr = bus_alloc_resource_any(dev, SYS_RES_IRQ, &rid, RF_ACTIVE); if (sc->intr == NULL) { if (bootverbose) device_printf(dev, "unable to allocate IRQ\n"); @@ -1438,8 +1438,7 @@ /* Setup our interrupt handler */ rid = KBDC_RID_AUX; - sc->intr = bus_alloc_resource_any(dev, SYS_RES_IRQ, &rid, - RF_SHAREABLE | RF_ACTIVE); + sc->intr = bus_alloc_resource_any(dev, SYS_RES_IRQ, &rid, RF_ACTIVE); if (sc->intr == NULL) return (ENXIO); error = bus_setup_intr(dev, sc->intr, INTR_TYPE_TTY, NULL, psmintr, sc, @@ -4628,6 +4627,7 @@ /* move our resource to the found device */ irq = bus_get_resource_start(me, SYS_RES_IRQ, 0); + bus_delete_resource(me, SYS_RES_IRQ, 0); bus_set_resource(psm, SYS_RES_IRQ, KBDC_RID_AUX, irq, 1); /* ...then probe and attach it */ @@ -4661,7 +4661,7 @@ "assuming irq %ld\n", irq); bus_set_resource(dev, SYS_RES_IRQ, rid, irq, 1); } - res = bus_alloc_resource_any(dev, SYS_RES_IRQ, &rid, RF_SHAREABLE); + res = bus_alloc_resource_any(dev, SYS_RES_IRQ, &rid, 0); bus_release_resource(dev, SYS_RES_IRQ, rid, res); /* keep quiet */ @@ -4675,22 +4675,12 @@ psmcpnp_attach(device_t dev) { device_t atkbdc; - int rid; /* find the keyboard controller, which may be on acpi* or isa* bus */ atkbdc = devclass_get_device(devclass_find(ATKBDC_DRIVER_NAME), device_get_unit(dev)); if ((atkbdc != NULL) && (device_get_state(atkbdc) == DS_ATTACHED)) create_a_copy(atkbdc, dev); - else { - /* - * If we don't have the AT keyboard controller yet, - * just reserve the IRQ for later use... - * (See psmidentify() above.) - */ - rid = 0; - bus_alloc_resource_any(dev, SYS_RES_IRQ, &rid, RF_SHAREABLE); - } return (0); } --- //depot/vendor/freebsd/src/sys/kern/subr_bus.c 2010-12-02 04:30:19.000000000 0000 +++ //depot/user/jhb/acpipci/kern/subr_bus.c 2010-12-07 19:29:57.000000000 0000 @@ -3078,6 +3078,9 @@ if (rle->flags & RLE_RESERVED) { if (rle->flags & RLE_ALLOCATED) return (NULL); + if (start > rle->start || end < rle->end) + panic( + "resource_list_alloc: invalid allocation range"); if ((flags & RF_ACTIVE) && bus_activate_resource(child, type, *rid, rle->res) != 0) --- //depot/vendor/freebsd/src/sys/x86/isa/atrtc.c 2010-10-16 10:50:21.000000000 0000 +++ //depot/user/jhb/acpipci/x86/isa/atrtc.c 2010-11-19 13:41:12.000000000 0000 @@ -245,9 +245,10 @@ int i; sc = device_get_softc(dev); - if (!(sc->port_res = bus_alloc_resource(dev, SYS_RES_IOPORT, - &sc->port_rid, IO_RTC, IO_RTC + 1, 2, RF_ACTIVE))) - device_printf(dev,"Warning: Couldn't map I/O.\n"); + sc->port_res = bus_alloc_resource(dev, SYS_RES_IOPORT, &sc->port_rid, + IO_RTC, IO_RTC + 1, 2, RF_ACTIVE); + if (sc->port_res == NULL) + device_printf(dev, "Warning: Couldn't map I/O.\n"); atrtc_start(); clock_register(dev, 1000000); bzero(&sc->et, sizeof(struct eventtimer)); @@ -258,9 +259,10 @@ while (bus_get_resource(dev, SYS_RES_IRQ, sc->intr_rid, &s, NULL) == 0 && s != 8) sc->intr_rid++; - if (!(sc->intr_res = bus_alloc_resource(dev, SYS_RES_IRQ, - &sc->intr_rid, 8, 8, 1, RF_ACTIVE))) { - device_printf(dev,"Can't map interrupt.\n"); + sc->intr_res = bus_alloc_resource(dev, SYS_RES_IRQ, + &sc->intr_rid, 8, 8, 1, RF_ACTIVE); + if (sc->intr_res == NULL) { + device_printf(dev, "Can't map interrupt.\n"); return (0); } else if ((bus_setup_intr(dev, sc->intr_res, INTR_MPSAFE | INTR_TYPE_CLK,