From df91bf49f0979d8418358821772a374bbab0f6e1 Mon Sep 17 00:00:00 2001 From: tanimura Date: Tue, 5 Feb 2002 06:52:56 +0000 Subject: - Do not hang if the resource allocation fails. - Add another quirk entry of SB AWE64. PR: kern/32530 Submitted by: Magnus Backstrom --- sys/dev/sound/isa/emu8000.c | 47 +++++++++++++++++++++++++++------------------ sys/isa/pnp.c | 2 ++ 2 files changed, 30 insertions(+), 19 deletions(-) (limited to 'sys') diff --git a/sys/dev/sound/isa/emu8000.c b/sys/dev/sound/isa/emu8000.c index d17ca3c..73ac39f 100644 --- a/sys/dev/sound/isa/emu8000.c +++ b/sys/dev/sound/isa/emu8000.c @@ -1910,30 +1910,39 @@ emu_status(sc_p scp, int reg, int chn) static int emu_allocres(sc_p scp, device_t dev) { - int iobase; + int i; - if (scp->io[0] == NULL) { - scp->io_rid[0] = 0; - scp->io[0] = bus_alloc_resource(dev, SYS_RES_IOPORT, &scp->io_rid[0], 0, ~0, 4, RF_ACTIVE); - } - if (scp->io[0] == NULL) - return (1); - iobase = rman_get_start(scp->io[0]); - if (scp->io[1] == NULL) { - scp->io_rid[1] = 1; - scp->io[1] = bus_alloc_resource(dev, SYS_RES_IOPORT, &scp->io_rid[1], iobase + 0x400, iobase + 0x400 + 3, 4, RF_ACTIVE); - } - if (scp->io[2] == NULL) { - scp->io_rid[2] = 2; - scp->io[2] = bus_alloc_resource(dev, SYS_RES_IOPORT, &scp->io_rid[2], iobase + 0x800, iobase + 0x800 + 3, 4, RF_ACTIVE); + /* + * Attempt to allocate the EMU8000's three I/O port ranges. + */ + for (i = 0; i < 3; i++) + { + if (scp->io[i] == NULL) + { + scp->io_rid[i] = i; + scp->io[i] = bus_alloc_resource(dev, SYS_RES_IOPORT, + &(scp->io_rid[i]), + 0, ~0, 4, RF_ACTIVE); + } } - if (scp->io[0] == NULL || scp->io[1] == NULL || scp->io[2] == NULL) { - printf("emu_allocres: failed.\n"); - return (1); + /* + * Fail if any of the I/O ranges failed (I.e. weren't identified and + * configured by PNP, which can happen if the ID of the card isn't + * known by the PNP quirk-handling logic) + */ + if (scp->io[0] == NULL || scp->io[1] == NULL || scp->io[2] == NULL) + { + printf("emu%d: Resource alloc failed, pnp_quirks " + "may need { 0x%08x, 0x%08x }\n", + device_get_unit(dev), + isa_get_vendorid(dev), + isa_get_logicalid(dev)); + + return 1; } - return (0); + return 0; } /* Releases resources. */ diff --git a/sys/isa/pnp.c b/sys/isa/pnp.c index bf7ca97..6eff917 100644 --- a/sys/isa/pnp.c +++ b/sys/isa/pnp.c @@ -83,6 +83,8 @@ struct pnp_quirk pnp_quirks[] = { PNP_QUIRK_EXTRA_IO, 0x400, 0x800 }, { 0xc1008c0e /* SB64(CTL00c1) */, 0x22008c0e, PNP_QUIRK_EXTRA_IO, 0x400, 0x800 }, + { 0xc5008c0e /* SB64(CTL00c5) */, 0x22008c0e, + PNP_QUIRK_EXTRA_IO, 0x400, 0x800 }, { 0xe4008c0e /* SB64(CTL00e4) */, 0x22008c0e, PNP_QUIRK_EXTRA_IO, 0x400, 0x800 }, -- cgit v1.1