* Add struct resource_list* argument to resource_list_alloc and
resource_list_release. This removes the dependancy on the layout of ivars. * Move set_resource, get_resource and delete_resource from isa_if.m to bus_if.m. * Simplify driver code by providing wrappers to those methods: bus_set_resource(dev, type, rid, start, count); bus_get_resource(dev, type, rid, startp, countp); bus_get_resource_start(dev, type, rid); bus_get_resource_count(dev, type, rid); bus_delete_resource(dev, type, rid); * Delete isa_get_rsrc and use bus_get_resource_start instead. * Fix a stupid typo in isa_alloc_resource reported by Takahashi Yoshihiro <nyan@FreeBSD.org>. * Print a diagnostic message if we can't assign resources to a PnP device. * Change device_print_prettyname() so that it doesn't print "(no driver assigned)-1" for anonymous devices.
This commit is contained in:
parent
b203e98b2b
commit
229cdb9144
@ -164,30 +164,42 @@ isa_alloc_resource(device_t bus, device_t child, int type, int *rid,
|
||||
*/
|
||||
int passthrough = (device_get_parent(child) != bus);
|
||||
int isdefault = (start == 0UL && end == ~0UL);
|
||||
struct resource_list *rl;
|
||||
struct isa_device* idev = DEVTOISA(child);
|
||||
struct resource_list *rl = &idev->id_resources;
|
||||
struct resource_list_entry *rle;
|
||||
struct resource *res;
|
||||
|
||||
if (!passthrough && !isdefault) {
|
||||
rl = device_get_ivars(child);
|
||||
rle = resource_list_find(rl, type, *rid);
|
||||
if (!rle) {
|
||||
if (*rid < 0)
|
||||
return 0;
|
||||
if (type == SYS_RES_IRQ && *rid > 1)
|
||||
return 0;
|
||||
if (type == SYS_RES_DRQ && *rid > 1)
|
||||
return 0;
|
||||
if (type != SYS_RES_MEMORY && *rid > 3)
|
||||
return 0;
|
||||
if (type == SYS_RES_IOPORT && *rid > 7)
|
||||
switch (type) {
|
||||
case SYS_RES_IRQ:
|
||||
if (*rid >= ISA_NIRQ)
|
||||
return 0;
|
||||
break;
|
||||
case SYS_RES_DRQ:
|
||||
if (*rid >= ISA_NDRQ)
|
||||
return 0;
|
||||
break;
|
||||
case SYS_RES_MEMORY:
|
||||
if (*rid >= ISA_NMEM)
|
||||
return 0;
|
||||
break;
|
||||
case SYS_RES_IOPORT:
|
||||
if (*rid >= ISA_NPORT)
|
||||
return 0;
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
resource_list_add(rl, type, *rid, start, end, count);
|
||||
}
|
||||
}
|
||||
|
||||
if (type != SYS_RES_IRQ && type != SYS_RES_DRQ)
|
||||
return resource_list_alloc(bus, child, type, rid,
|
||||
return resource_list_alloc(rl, bus, child, type, rid,
|
||||
start, end, count, flags);
|
||||
|
||||
if (!passthrough) {
|
||||
@ -211,7 +223,6 @@ isa_alloc_resource(device_t bus, device_t child, int type, int *rid,
|
||||
0, child);
|
||||
|
||||
if (res && !passthrough) {
|
||||
rl = device_get_ivars(child);
|
||||
rle = resource_list_find(rl, type, *rid);
|
||||
rle->start = rman_get_start(res);
|
||||
rle->end = rman_get_end(res);
|
||||
@ -227,17 +238,17 @@ isa_release_resource(device_t bus, device_t child, int type, int rid,
|
||||
struct resource *res)
|
||||
{
|
||||
int passthrough = (device_get_parent(child) != bus);
|
||||
struct resource_list *rl;
|
||||
struct isa_device* idev = DEVTOISA(child);
|
||||
struct resource_list *rl = &idev->id_resources;
|
||||
struct resource_list_entry *rle;
|
||||
int error;
|
||||
|
||||
if (type != SYS_RES_IRQ)
|
||||
return resource_list_release(bus, child, type, rid, res);
|
||||
return resource_list_release(rl, bus, child, type, rid, res);
|
||||
|
||||
error = rman_release_resource(res);
|
||||
|
||||
if (!passthrough && !error) {
|
||||
rl = device_get_ivars(child);
|
||||
rle = resource_list_find(rl, SYS_RES_IRQ, rid);
|
||||
if (rle)
|
||||
rle->res = NULL;
|
||||
|
@ -91,28 +91,40 @@ isa_alloc_resource(device_t bus, device_t child, int type, int *rid,
|
||||
*/
|
||||
int passthrough = (device_get_parent(child) != bus);
|
||||
int isdefault = (start == 0UL && end == ~0UL);
|
||||
struct resource_list *rl;
|
||||
struct isa_device* idev = DEVTOISA(child);
|
||||
struct resource_list *rl = &idev->id_resources;
|
||||
struct resource_list_entry *rle;
|
||||
|
||||
if (!passthrough && !isdefault) {
|
||||
rl = device_get_ivars(child);
|
||||
rle = resource_list_find(rl, type, *rid);
|
||||
if (!rle) {
|
||||
if (*rid < 0)
|
||||
return 0;
|
||||
if (type == SYS_RES_IRQ && *rid >= ISA_NIRQ)
|
||||
return 0;
|
||||
if (type == SYS_RES_DRQ && *rid >= ISA_NDRQ)
|
||||
return 0;
|
||||
if (type != SYS_RES_MEMORY && *rid >= ISA_NMEM)
|
||||
return 0;
|
||||
if (type == SYS_RES_IOPORT && *rid >= ISA_NPORT)
|
||||
switch (type) {
|
||||
case SYS_RES_IRQ:
|
||||
if (*rid >= ISA_NIRQ)
|
||||
return 0;
|
||||
break;
|
||||
case SYS_RES_DRQ:
|
||||
if (*rid >= ISA_NDRQ)
|
||||
return 0;
|
||||
break;
|
||||
case SYS_RES_MEMORY:
|
||||
if (*rid >= ISA_NMEM)
|
||||
return 0;
|
||||
break;
|
||||
case SYS_RES_IOPORT:
|
||||
if (*rid >= ISA_NPORT)
|
||||
return 0;
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
resource_list_add(rl, type, *rid, start, end, count);
|
||||
}
|
||||
}
|
||||
|
||||
return resource_list_alloc(bus, child, type, rid,
|
||||
return resource_list_alloc(rl, bus, child, type, rid,
|
||||
start, end, count, flags);
|
||||
}
|
||||
|
||||
@ -120,7 +132,9 @@ int
|
||||
isa_release_resource(device_t bus, device_t child, int type, int rid,
|
||||
struct resource *r)
|
||||
{
|
||||
return resource_list_release(bus, child, type, rid, r);
|
||||
struct isa_device* idev = DEVTOISA(child);
|
||||
struct resource_list *rl = &idev->id_resources;
|
||||
return resource_list_release(rl, bus, child, type, rid, r);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -260,7 +260,6 @@ flaprobe (device_t dev)
|
||||
{
|
||||
int unit;
|
||||
struct fla_s *sc;
|
||||
device_t bus;
|
||||
int i;
|
||||
|
||||
unit = device_get_unit(dev);
|
||||
@ -275,8 +274,7 @@ flaprobe (device_t dev)
|
||||
if (i)
|
||||
return (ENXIO);
|
||||
|
||||
bus = device_get_parent(dev);
|
||||
ISA_SET_RESOURCE(bus, dev, SYS_RES_MEMORY, 0,
|
||||
bus_set_resource(dev, SYS_RES_MEMORY, 0,
|
||||
sc->ds.window - KERNBASE, 8192);
|
||||
|
||||
return (0);
|
||||
|
@ -83,8 +83,8 @@ aha_isa_probe(device_t dev)
|
||||
if (ISA_PNP_PROBE(device_get_parent(dev), dev, aha_ids) == ENXIO)
|
||||
return (ENXIO);
|
||||
|
||||
error = ISA_GET_RESOURCE(device_get_parent(dev), dev, SYS_RES_IOPORT,
|
||||
0, &port_start, &port_count);
|
||||
error = bus_get_resource(dev, SYS_RES_IOPORT, 0,
|
||||
&port_start, &port_count);
|
||||
if (error != 0)
|
||||
port_start = 0;
|
||||
|
||||
@ -111,8 +111,8 @@ aha_isa_probe(device_t dev)
|
||||
*/
|
||||
if (aha_check_probed_iop(ioport) != 0)
|
||||
continue;
|
||||
error = ISA_SET_RESOURCE(device_get_parent(dev), dev,
|
||||
SYS_RES_IOPORT, 0, ioport, AHA_NREGS);
|
||||
error = bus_set_resource(dev, SYS_RES_IOPORT, 0,
|
||||
ioport, AHA_NREGS);
|
||||
if (error)
|
||||
return error;
|
||||
|
||||
@ -179,14 +179,12 @@ aha_isa_probe(device_t dev)
|
||||
"Failing probe\n", ioport);
|
||||
return (ENXIO);
|
||||
}
|
||||
error = ISA_SET_RESOURCE(device_get_parent(dev), dev,
|
||||
SYS_RES_DRQ, 0, drq, 1);
|
||||
error = bus_set_resource(dev, SYS_RES_DRQ, 0, drq, 1);
|
||||
if (error)
|
||||
return error;
|
||||
|
||||
irq = ffs(config_data.irq) + 8;
|
||||
error = ISA_SET_RESOURCE(device_get_parent(dev), dev,
|
||||
SYS_RES_IRQ, 0, irq, 1);
|
||||
error = bus_set_resource(dev, SYS_RES_IRQ, 0, irq, 1);
|
||||
if (error)
|
||||
return error;
|
||||
|
||||
|
@ -172,10 +172,8 @@ bt_isa_probe(device_t dev)
|
||||
|
||||
bt_isa_release_resources(dev);
|
||||
|
||||
ISA_SET_RESOURCE(device_get_parent(dev), dev,
|
||||
SYS_RES_DRQ, 0, info.drq, 1);
|
||||
ISA_SET_RESOURCE(device_get_parent(dev), dev,
|
||||
SYS_RES_IRQ, 0, info.irq, 1);
|
||||
bus_set_resource(dev, SYS_RES_DRQ, 0, info.drq, 1);
|
||||
bus_set_resource(dev, SYS_RES_IRQ, 0, info.irq, 1);
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
@ -555,8 +555,7 @@ ed_probe_WD80x3(dev)
|
||||
memsize = 8192;
|
||||
}
|
||||
|
||||
error = ISA_GET_RESOURCE(device_get_parent(dev), dev,
|
||||
SYS_RES_MEMORY, 0,
|
||||
error = bus_get_resource(dev, SYS_RES_MEMORY, 0,
|
||||
&conf_maddr, &conf_msize);
|
||||
if (error)
|
||||
return (error);
|
||||
@ -606,12 +605,10 @@ ed_probe_WD80x3(dev)
|
||||
/*
|
||||
* If no interrupt specified (or "?"), use what the board tells us.
|
||||
*/
|
||||
error = ISA_GET_RESOURCE(device_get_parent(dev), dev,
|
||||
SYS_RES_IRQ, 0,
|
||||
error = bus_get_resource(dev, SYS_RES_IRQ, 0,
|
||||
&irq, &junk);
|
||||
if (error) {
|
||||
ISA_SET_RESOURCE(device_get_parent(dev), dev,
|
||||
SYS_RES_IRQ, 0,
|
||||
bus_set_resource(dev, SYS_RES_IRQ, 0,
|
||||
ed_intr_val[iptr], 1);
|
||||
}
|
||||
|
||||
@ -633,12 +630,10 @@ ed_probe_WD80x3(dev)
|
||||
/*
|
||||
* If no interrupt specified (or "?"), use what the board tells us.
|
||||
*/
|
||||
error = ISA_GET_RESOURCE(device_get_parent(dev), dev,
|
||||
SYS_RES_IRQ, 0,
|
||||
error = bus_get_resource(dev, SYS_RES_IRQ, 0,
|
||||
&irq, &junk);
|
||||
if (error) {
|
||||
ISA_SET_RESOURCE(device_get_parent(dev), dev,
|
||||
SYS_RES_IRQ, 0,
|
||||
bus_set_resource(dev, SYS_RES_IRQ, 0,
|
||||
ed_790_intr_val[iptr], 1);
|
||||
}
|
||||
|
||||
@ -648,8 +643,7 @@ ed_probe_WD80x3(dev)
|
||||
outb(sc->asic_addr + ED_WD790_ICR,
|
||||
inb(sc->asic_addr + ED_WD790_ICR) | ED_WD790_ICR_EIL);
|
||||
}
|
||||
error = ISA_GET_RESOURCE(device_get_parent(dev), dev,
|
||||
SYS_RES_IRQ, 0,
|
||||
error = bus_get_resource(dev, SYS_RES_IRQ, 0,
|
||||
&irq, &junk);
|
||||
if (error) {
|
||||
device_printf(dev, "%s cards don't support auto-detected/assigned interrupts.\n",
|
||||
@ -850,8 +844,7 @@ ed_probe_3Com(dev)
|
||||
return (ENXIO);
|
||||
}
|
||||
|
||||
error = ISA_GET_RESOURCE(device_get_parent(dev), dev,
|
||||
SYS_RES_MEMORY, 0,
|
||||
error = bus_get_resource(dev, SYS_RES_MEMORY, 0,
|
||||
&conf_maddr, &conf_msize);
|
||||
if (error)
|
||||
return (error);
|
||||
@ -1019,8 +1012,7 @@ ed_probe_3Com(dev)
|
||||
/*
|
||||
* Set IRQ. 3c503 only allows a choice of irq 2-5.
|
||||
*/
|
||||
error = ISA_GET_RESOURCE(device_get_parent(dev), dev,
|
||||
SYS_RES_IRQ, 0,
|
||||
error = bus_get_resource(dev, SYS_RES_IRQ, 0,
|
||||
&irq, &junk);
|
||||
if (error)
|
||||
return (error);
|
||||
@ -1464,12 +1456,10 @@ ed_probe_HP_pclanp(dev)
|
||||
* of the IRQ. If the kernel IRQ was explicitly specified, it
|
||||
* should match that of the hardware.
|
||||
*/
|
||||
error = ISA_GET_RESOURCE(device_get_parent(dev), dev,
|
||||
SYS_RES_IRQ, 0,
|
||||
error = bus_get_resource(dev, SYS_RES_IRQ, 0,
|
||||
&conf_irq, &junk);
|
||||
if (error) {
|
||||
ISA_SET_RESOURCE(device_get_parent(dev), dev,
|
||||
SYS_RES_IRQ, 0,
|
||||
bus_set_resource(dev, SYS_RES_IRQ, 0,
|
||||
ed_hpp_intr_val[irq], 1);
|
||||
} else {
|
||||
if (conf_irq != ed_hpp_intr_val[irq])
|
||||
@ -1515,8 +1505,7 @@ ed_probe_HP_pclanp(dev)
|
||||
* Check that the kernel specified start of memory and
|
||||
* hardware's idea of it match.
|
||||
*/
|
||||
error = ISA_GET_RESOURCE(device_get_parent(dev), dev,
|
||||
SYS_RES_MEMORY, 0,
|
||||
error = bus_get_resource(dev, SYS_RES_MEMORY, 0,
|
||||
&conf_maddr, &conf_msize);
|
||||
if (error)
|
||||
return (error);
|
||||
|
@ -449,7 +449,7 @@ mss_probe(device_t dev)
|
||||
mss->io_rid = 0;
|
||||
/* XXX verify this */
|
||||
setres = 1;
|
||||
ISA_SET_RESOURCE(device_get_parent(dev), dev, SYS_RES_IOPORT, mss->io_rid,
|
||||
bus_set_resource(dev, SYS_RES_IOPORT, mss->io_rid,
|
||||
0x530, 8);
|
||||
mss->io_base = bus_alloc_resource(dev, SYS_RES_IOPORT, &mss->io_rid,
|
||||
0, ~0, 8, RF_ACTIVE);
|
||||
@ -866,7 +866,7 @@ mss_attach(device_t dev)
|
||||
mss->drq1_rid = 0;
|
||||
mss->drq2_rid = -1;
|
||||
if (flags & DV_F_DUAL_DMA) {
|
||||
ISA_SET_RESOURCE(device_get_parent(dev), dev, SYS_RES_DRQ, 1,
|
||||
bus_set_resource(dev, SYS_RES_DRQ, 1,
|
||||
flags & DV_F_DRQ_MASK, 1);
|
||||
mss->drq2_rid = 1;
|
||||
}
|
||||
|
@ -573,8 +573,7 @@ sb_probe(device_t dev)
|
||||
no:
|
||||
i = sb->io_rid;
|
||||
sb_release_resources(sb, dev);
|
||||
if (allocated) ISA_DELETE_RESOURCE(device_get_parent(dev), dev,
|
||||
SYS_RES_IOPORT, i);
|
||||
if (allocated) bus_delete_resource(dev, SYS_RES_IOPORT, i);
|
||||
return error;
|
||||
}
|
||||
|
||||
@ -647,8 +646,8 @@ sb_attach(device_t dev)
|
||||
int flags = device_get_flags(dev);
|
||||
|
||||
if (flags & DV_F_DUAL_DMA) {
|
||||
ISA_SET_RESOURCE(device_get_parent(dev), dev, SYS_RES_DRQ, 1,
|
||||
flags & DV_F_DRQ_MASK, 1);
|
||||
bus_set_resource(dev, SYS_RES_DRQ, 1,
|
||||
flags & DV_F_DRQ_MASK, 1);
|
||||
}
|
||||
sb = (struct sb_info *)malloc(sizeof *sb, M_DEVBUF, M_NOWAIT);
|
||||
if (!sb) return ENXIO;
|
||||
|
@ -449,7 +449,7 @@ mss_probe(device_t dev)
|
||||
mss->io_rid = 0;
|
||||
/* XXX verify this */
|
||||
setres = 1;
|
||||
ISA_SET_RESOURCE(device_get_parent(dev), dev, SYS_RES_IOPORT, mss->io_rid,
|
||||
bus_set_resource(dev, SYS_RES_IOPORT, mss->io_rid,
|
||||
0x530, 8);
|
||||
mss->io_base = bus_alloc_resource(dev, SYS_RES_IOPORT, &mss->io_rid,
|
||||
0, ~0, 8, RF_ACTIVE);
|
||||
@ -866,7 +866,7 @@ mss_attach(device_t dev)
|
||||
mss->drq1_rid = 0;
|
||||
mss->drq2_rid = -1;
|
||||
if (flags & DV_F_DUAL_DMA) {
|
||||
ISA_SET_RESOURCE(device_get_parent(dev), dev, SYS_RES_DRQ, 1,
|
||||
bus_set_resource(dev, SYS_RES_DRQ, 1,
|
||||
flags & DV_F_DRQ_MASK, 1);
|
||||
mss->drq2_rid = 1;
|
||||
}
|
||||
|
@ -573,8 +573,7 @@ sb_probe(device_t dev)
|
||||
no:
|
||||
i = sb->io_rid;
|
||||
sb_release_resources(sb, dev);
|
||||
if (allocated) ISA_DELETE_RESOURCE(device_get_parent(dev), dev,
|
||||
SYS_RES_IOPORT, i);
|
||||
if (allocated) bus_delete_resource(dev, SYS_RES_IOPORT, i);
|
||||
return error;
|
||||
}
|
||||
|
||||
@ -647,8 +646,8 @@ sb_attach(device_t dev)
|
||||
int flags = device_get_flags(dev);
|
||||
|
||||
if (flags & DV_F_DUAL_DMA) {
|
||||
ISA_SET_RESOURCE(device_get_parent(dev), dev, SYS_RES_DRQ, 1,
|
||||
flags & DV_F_DRQ_MASK, 1);
|
||||
bus_set_resource(dev, SYS_RES_DRQ, 1,
|
||||
flags & DV_F_DRQ_MASK, 1);
|
||||
}
|
||||
sb = (struct sb_info *)malloc(sizeof *sb, M_DEVBUF, M_NOWAIT);
|
||||
if (!sb) return ENXIO;
|
||||
|
@ -573,8 +573,7 @@ sb_probe(device_t dev)
|
||||
no:
|
||||
i = sb->io_rid;
|
||||
sb_release_resources(sb, dev);
|
||||
if (allocated) ISA_DELETE_RESOURCE(device_get_parent(dev), dev,
|
||||
SYS_RES_IOPORT, i);
|
||||
if (allocated) bus_delete_resource(dev, SYS_RES_IOPORT, i);
|
||||
return error;
|
||||
}
|
||||
|
||||
@ -647,8 +646,8 @@ sb_attach(device_t dev)
|
||||
int flags = device_get_flags(dev);
|
||||
|
||||
if (flags & DV_F_DUAL_DMA) {
|
||||
ISA_SET_RESOURCE(device_get_parent(dev), dev, SYS_RES_DRQ, 1,
|
||||
flags & DV_F_DRQ_MASK, 1);
|
||||
bus_set_resource(dev, SYS_RES_DRQ, 1,
|
||||
flags & DV_F_DRQ_MASK, 1);
|
||||
}
|
||||
sb = (struct sb_info *)malloc(sizeof *sb, M_DEVBUF, M_NOWAIT);
|
||||
if (!sb) return ENXIO;
|
||||
|
@ -573,8 +573,7 @@ sb_probe(device_t dev)
|
||||
no:
|
||||
i = sb->io_rid;
|
||||
sb_release_resources(sb, dev);
|
||||
if (allocated) ISA_DELETE_RESOURCE(device_get_parent(dev), dev,
|
||||
SYS_RES_IOPORT, i);
|
||||
if (allocated) bus_delete_resource(dev, SYS_RES_IOPORT, i);
|
||||
return error;
|
||||
}
|
||||
|
||||
@ -647,8 +646,8 @@ sb_attach(device_t dev)
|
||||
int flags = device_get_flags(dev);
|
||||
|
||||
if (flags & DV_F_DUAL_DMA) {
|
||||
ISA_SET_RESOURCE(device_get_parent(dev), dev, SYS_RES_DRQ, 1,
|
||||
flags & DV_F_DRQ_MASK, 1);
|
||||
bus_set_resource(dev, SYS_RES_DRQ, 1,
|
||||
flags & DV_F_DRQ_MASK, 1);
|
||||
}
|
||||
sb = (struct sb_info *)malloc(sizeof *sb, M_DEVBUF, M_NOWAIT);
|
||||
if (!sb) return ENXIO;
|
||||
|
@ -91,28 +91,40 @@ isa_alloc_resource(device_t bus, device_t child, int type, int *rid,
|
||||
*/
|
||||
int passthrough = (device_get_parent(child) != bus);
|
||||
int isdefault = (start == 0UL && end == ~0UL);
|
||||
struct resource_list *rl;
|
||||
struct isa_device* idev = DEVTOISA(child);
|
||||
struct resource_list *rl = &idev->id_resources;
|
||||
struct resource_list_entry *rle;
|
||||
|
||||
if (!passthrough && !isdefault) {
|
||||
rl = device_get_ivars(child);
|
||||
rle = resource_list_find(rl, type, *rid);
|
||||
if (!rle) {
|
||||
if (*rid < 0)
|
||||
return 0;
|
||||
if (type == SYS_RES_IRQ && *rid >= ISA_NIRQ)
|
||||
return 0;
|
||||
if (type == SYS_RES_DRQ && *rid >= ISA_NDRQ)
|
||||
return 0;
|
||||
if (type != SYS_RES_MEMORY && *rid >= ISA_NMEM)
|
||||
return 0;
|
||||
if (type == SYS_RES_IOPORT && *rid >= ISA_NPORT)
|
||||
switch (type) {
|
||||
case SYS_RES_IRQ:
|
||||
if (*rid >= ISA_NIRQ)
|
||||
return 0;
|
||||
break;
|
||||
case SYS_RES_DRQ:
|
||||
if (*rid >= ISA_NDRQ)
|
||||
return 0;
|
||||
break;
|
||||
case SYS_RES_MEMORY:
|
||||
if (*rid >= ISA_NMEM)
|
||||
return 0;
|
||||
break;
|
||||
case SYS_RES_IOPORT:
|
||||
if (*rid >= ISA_NPORT)
|
||||
return 0;
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
resource_list_add(rl, type, *rid, start, end, count);
|
||||
}
|
||||
}
|
||||
|
||||
return resource_list_alloc(bus, child, type, rid,
|
||||
return resource_list_alloc(rl, bus, child, type, rid,
|
||||
start, end, count, flags);
|
||||
}
|
||||
|
||||
@ -120,7 +132,9 @@ int
|
||||
isa_release_resource(device_t bus, device_t child, int type, int rid,
|
||||
struct resource *r)
|
||||
{
|
||||
return resource_list_release(bus, child, type, rid, r);
|
||||
struct isa_device* idev = DEVTOISA(child);
|
||||
struct resource_list *rl = &idev->id_resources;
|
||||
return resource_list_release(rl, bus, child, type, rid, r);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -64,11 +64,10 @@ isa_compat_nextid(void)
|
||||
static void
|
||||
isa_compat_alloc_resources(device_t dev, struct isa_compat_resources *res)
|
||||
{
|
||||
device_t parent = device_get_parent(dev);
|
||||
int rid;
|
||||
u_long start, count;
|
||||
|
||||
if (ISA_GET_RESOURCE(parent, dev, SYS_RES_IOPORT, 0,
|
||||
if (bus_get_resource(dev, SYS_RES_IOPORT, 0,
|
||||
&start, &count) == 0) {
|
||||
rid = 0;
|
||||
res->ports = bus_alloc_resource(dev, SYS_RES_IOPORT,
|
||||
@ -80,7 +79,7 @@ isa_compat_alloc_resources(device_t dev, struct isa_compat_resources *res)
|
||||
} else
|
||||
res->ports = 0;
|
||||
|
||||
if (ISA_GET_RESOURCE(parent, dev, SYS_RES_MEMORY, 0,
|
||||
if (bus_get_resource(dev, SYS_RES_MEMORY, 0,
|
||||
&start, &count) == 0
|
||||
&& start != 0) {
|
||||
rid = 0;
|
||||
@ -93,7 +92,7 @@ isa_compat_alloc_resources(device_t dev, struct isa_compat_resources *res)
|
||||
} else
|
||||
res->memory = 0;
|
||||
|
||||
if (ISA_GET_RESOURCE(parent, dev, SYS_RES_DRQ, 0,
|
||||
if (bus_get_resource(dev, SYS_RES_DRQ, 0,
|
||||
&start, &count) == 0) {
|
||||
rid = 0;
|
||||
res->drq = bus_alloc_resource(dev, SYS_RES_DRQ,
|
||||
@ -105,7 +104,7 @@ isa_compat_alloc_resources(device_t dev, struct isa_compat_resources *res)
|
||||
} else
|
||||
res->drq = 0;
|
||||
|
||||
if (ISA_GET_RESOURCE(parent, dev, SYS_RES_IRQ, 0,
|
||||
if (bus_get_resource(dev, SYS_RES_IRQ, 0,
|
||||
&start, &count) == 0) {
|
||||
rid = 0;
|
||||
res->irq = bus_alloc_resource(dev, SYS_RES_IRQ,
|
||||
@ -144,7 +143,6 @@ isa_compat_release_resources(device_t dev, struct isa_compat_resources *res)
|
||||
static int
|
||||
isa_compat_probe(device_t dev)
|
||||
{
|
||||
device_t parent = device_get_parent(dev);
|
||||
struct isa_device *dvp = device_get_softc(dev);
|
||||
struct isa_compat_resources res;
|
||||
struct old_isa_driver *op;
|
||||
@ -161,22 +159,22 @@ isa_compat_probe(device_t dev)
|
||||
op = device_get_driver(dev)->priv;
|
||||
dvp->id_id = isa_compat_nextid();
|
||||
dvp->id_driver = op->driver;
|
||||
if (ISA_GET_RESOURCE(parent, dev, SYS_RES_IOPORT, 0,
|
||||
if (bus_get_resource(dev, SYS_RES_IOPORT, 0,
|
||||
&start, &count) == 0)
|
||||
dvp->id_iobase = start;
|
||||
else
|
||||
dvp->id_iobase = -1;
|
||||
if (ISA_GET_RESOURCE(parent, dev, SYS_RES_IRQ, 0,
|
||||
if (bus_get_resource(dev, SYS_RES_IRQ, 0,
|
||||
&start, &count) == 0)
|
||||
dvp->id_irq = irqmask(start);
|
||||
else
|
||||
dvp->id_irq = 0;
|
||||
if (ISA_GET_RESOURCE(parent, dev, SYS_RES_DRQ, 0,
|
||||
if (bus_get_resource(dev, SYS_RES_DRQ, 0,
|
||||
&start, &count) == 0)
|
||||
dvp->id_drq = start;
|
||||
else
|
||||
dvp->id_drq = -1;
|
||||
if (ISA_GET_RESOURCE(parent, dev, SYS_RES_MEMORY,
|
||||
if (bus_get_resource(dev, SYS_RES_MEMORY,
|
||||
0, &start, &count) == 0) {
|
||||
dvp->id_maddr = (void *)(uintptr_t)start;
|
||||
dvp->id_msize = count;
|
||||
@ -208,25 +206,25 @@ isa_compat_probe(device_t dev)
|
||||
isa_compat_release_resources(dev, &res);
|
||||
if (portsize != 0) {
|
||||
if (portsize > 0 || dvp->id_iobase != old.id_iobase)
|
||||
ISA_SET_RESOURCE(parent, dev, SYS_RES_IOPORT,
|
||||
bus_set_resource(dev, SYS_RES_IOPORT,
|
||||
0, dvp->id_iobase, portsize);
|
||||
if (dvp->id_irq != old.id_irq)
|
||||
ISA_SET_RESOURCE(parent, dev, SYS_RES_IRQ, 0,
|
||||
bus_set_resource(dev, SYS_RES_IRQ, 0,
|
||||
ffs(dvp->id_irq) - 1, 1);
|
||||
if (dvp->id_drq != old.id_drq)
|
||||
ISA_SET_RESOURCE(parent, dev, SYS_RES_DRQ, 0,
|
||||
bus_set_resource(dev, SYS_RES_DRQ, 0,
|
||||
dvp->id_drq, 1);
|
||||
if (dvp->id_maddr != old.id_maddr
|
||||
|| dvp->id_msize != old.id_msize) {
|
||||
maddr = dvp->id_maddr;
|
||||
if (maddr != NULL)
|
||||
ISA_SET_RESOURCE(parent, dev,
|
||||
bus_set_resource(dev,
|
||||
SYS_RES_MEMORY,
|
||||
0,
|
||||
kvtop(maddr),
|
||||
dvp->id_msize);
|
||||
else
|
||||
ISA_DELETE_RESOURCE(parent, dev,
|
||||
bus_delete_resource(dev,
|
||||
SYS_RES_MEMORY,
|
||||
0);
|
||||
}
|
||||
|
@ -115,7 +115,6 @@ isa_find_memory(device_t child,
|
||||
struct isa_config *config,
|
||||
struct isa_config *result)
|
||||
{
|
||||
device_t dev = device_get_parent(child);
|
||||
int success, i;
|
||||
struct resource *res[ISA_NMEM];
|
||||
|
||||
@ -123,7 +122,7 @@ isa_find_memory(device_t child,
|
||||
* First clear out any existing resource definitions.
|
||||
*/
|
||||
for (i = 0; i < ISA_NMEM; i++) {
|
||||
ISA_DELETE_RESOURCE(dev, child, SYS_RES_MEMORY, i);
|
||||
bus_delete_resource(child, SYS_RES_MEMORY, i);
|
||||
res[i] = NULL;
|
||||
}
|
||||
|
||||
@ -137,7 +136,7 @@ isa_find_memory(device_t child,
|
||||
align = config->ic_mem[i].ir_align;
|
||||
start + size - 1 <= end;
|
||||
start += align) {
|
||||
ISA_SET_RESOURCE(dev, child, SYS_RES_MEMORY, i,
|
||||
bus_set_resource(child, SYS_RES_MEMORY, i,
|
||||
start, size);
|
||||
res[i] = bus_alloc_resource(child,
|
||||
SYS_RES_MEMORY, &i,
|
||||
@ -180,7 +179,6 @@ isa_find_port(device_t child,
|
||||
struct isa_config *config,
|
||||
struct isa_config *result)
|
||||
{
|
||||
device_t dev = device_get_parent(child);
|
||||
int success, i;
|
||||
struct resource *res[ISA_NPORT];
|
||||
|
||||
@ -188,7 +186,7 @@ isa_find_port(device_t child,
|
||||
* First clear out any existing resource definitions.
|
||||
*/
|
||||
for (i = 0; i < ISA_NPORT; i++) {
|
||||
ISA_DELETE_RESOURCE(dev, child, SYS_RES_IOPORT, i);
|
||||
bus_delete_resource(child, SYS_RES_IOPORT, i);
|
||||
res[i] = NULL;
|
||||
}
|
||||
|
||||
@ -202,7 +200,7 @@ isa_find_port(device_t child,
|
||||
align = config->ic_port[i].ir_align;
|
||||
start + size - 1 <= end;
|
||||
start += align) {
|
||||
ISA_SET_RESOURCE(dev, child, SYS_RES_IOPORT, i,
|
||||
bus_set_resource(child, SYS_RES_IOPORT, i,
|
||||
start, size);
|
||||
res[i] = bus_alloc_resource(child,
|
||||
SYS_RES_IOPORT, &i,
|
||||
@ -268,7 +266,6 @@ isa_find_irq(device_t child,
|
||||
struct isa_config *config,
|
||||
struct isa_config *result)
|
||||
{
|
||||
device_t dev = device_get_parent(child);
|
||||
int success, i;
|
||||
struct resource *res[ISA_NIRQ];
|
||||
|
||||
@ -276,7 +273,7 @@ isa_find_irq(device_t child,
|
||||
* First clear out any existing resource definitions.
|
||||
*/
|
||||
for (i = 0; i < ISA_NIRQ; i++) {
|
||||
ISA_DELETE_RESOURCE(dev, child, SYS_RES_IRQ, i);
|
||||
bus_delete_resource(child, SYS_RES_IRQ, i);
|
||||
res[i] = NULL;
|
||||
}
|
||||
|
||||
@ -288,7 +285,7 @@ isa_find_irq(device_t child,
|
||||
for (irq = find_first_bit(mask);
|
||||
irq != -1;
|
||||
irq = find_next_bit(mask, irq)) {
|
||||
ISA_SET_RESOURCE(dev, child, SYS_RES_IRQ, i,
|
||||
bus_set_resource(child, SYS_RES_IRQ, i,
|
||||
irq, 1);
|
||||
res[i] = bus_alloc_resource(child,
|
||||
SYS_RES_IRQ, &i,
|
||||
@ -328,7 +325,6 @@ isa_find_drq(device_t child,
|
||||
struct isa_config *config,
|
||||
struct isa_config *result)
|
||||
{
|
||||
device_t dev = device_get_parent(child);
|
||||
int success, i;
|
||||
struct resource *res[ISA_NDRQ];
|
||||
|
||||
@ -336,7 +332,7 @@ isa_find_drq(device_t child,
|
||||
* First clear out any existing resource definitions.
|
||||
*/
|
||||
for (i = 0; i < ISA_NDRQ; i++) {
|
||||
ISA_DELETE_RESOURCE(dev, child, SYS_RES_DRQ, i);
|
||||
bus_delete_resource(child, SYS_RES_DRQ, i);
|
||||
res[i] = NULL;
|
||||
}
|
||||
|
||||
@ -348,7 +344,7 @@ isa_find_drq(device_t child,
|
||||
for (drq = find_first_bit(mask);
|
||||
drq != -1;
|
||||
drq = find_next_bit(mask, drq)) {
|
||||
ISA_SET_RESOURCE(dev, child, SYS_RES_DRQ, i,
|
||||
bus_set_resource(child, SYS_RES_DRQ, i,
|
||||
drq, 1);
|
||||
res[i] = bus_alloc_resource(child,
|
||||
SYS_RES_DRQ, &i,
|
||||
@ -414,6 +410,11 @@ isa_assign_resources(device_t child)
|
||||
/*
|
||||
* Disable the device.
|
||||
*/
|
||||
if (device_get_desc(child))
|
||||
device_printf(child, "<%s> can't assign resources\n",
|
||||
device_get_desc(child));
|
||||
else
|
||||
device_printf(child, "can't assign resources\n");
|
||||
bzero(&config, sizeof config);
|
||||
if (idev->id_config_cb)
|
||||
idev->id_config_cb(idev->id_config_arg, &config, 0);
|
||||
@ -473,6 +474,7 @@ isa_probe_children(device_t dev)
|
||||
continue;
|
||||
|
||||
if (isa_assign_resources(child)) {
|
||||
struct resource_list *rl = &idev->id_resources;
|
||||
struct resource_list_entry *rle;
|
||||
|
||||
device_probe_and_attach(child);
|
||||
@ -481,10 +483,10 @@ isa_probe_children(device_t dev)
|
||||
* Claim any unallocated resources to keep other
|
||||
* devices from using them.
|
||||
*/
|
||||
SLIST_FOREACH(rle, &idev->id_resources, link) {
|
||||
SLIST_FOREACH(rle, rl, link) {
|
||||
if (!rle->res) {
|
||||
int rid = rle->rid;
|
||||
resource_list_alloc(dev, child,
|
||||
resource_list_alloc(rl, dev, child,
|
||||
rle->type,
|
||||
&rid,
|
||||
0, ~0, 1,
|
||||
@ -518,14 +520,14 @@ isa_add_child(device_t dev, int order, const char *name, int unit)
|
||||
|
||||
static void
|
||||
isa_print_resources(struct resource_list *rl, const char *name, int type,
|
||||
const char *format)
|
||||
int count, const char *format)
|
||||
{
|
||||
struct resource_list_entry *rle;
|
||||
int printed;
|
||||
int i;
|
||||
|
||||
printed = 0;
|
||||
for (i = 0; i < 16; i++) {
|
||||
for (i = 0; i < count; i++) {
|
||||
rle = resource_list_find(rl, type, i);
|
||||
if (rle) {
|
||||
if (printed == 0)
|
||||
@ -557,10 +559,10 @@ isa_print_child(device_t bus, device_t dev)
|
||||
if (SLIST_FIRST(rl) || device_get_flags(dev))
|
||||
retval += printf(" at");
|
||||
|
||||
isa_print_resources(rl, "port", SYS_RES_IOPORT, "%#lx");
|
||||
isa_print_resources(rl, "iomem", SYS_RES_MEMORY, "%#lx");
|
||||
isa_print_resources(rl, "irq", SYS_RES_IRQ, "%ld");
|
||||
isa_print_resources(rl, "drq", SYS_RES_DRQ, "%ld");
|
||||
isa_print_resources(rl, "port", SYS_RES_IOPORT, ISA_NPORT, "%#lx");
|
||||
isa_print_resources(rl, "iomem", SYS_RES_MEMORY, ISA_NMEM, "%#lx");
|
||||
isa_print_resources(rl, "irq", SYS_RES_IRQ, ISA_NIRQ, "%ld");
|
||||
isa_print_resources(rl, "drq", SYS_RES_DRQ, ISA_NDRQ, "%ld");
|
||||
if (device_get_flags(dev))
|
||||
retval += printf(" flags %#x", device_get_flags(dev));
|
||||
|
||||
@ -748,11 +750,12 @@ static void
|
||||
isa_child_detached(device_t dev, device_t child)
|
||||
{
|
||||
struct isa_device* idev = DEVTOISA(child);
|
||||
struct resource_list *rl = &idev->id_resources;
|
||||
struct resource_list_entry *rle;
|
||||
|
||||
SLIST_FOREACH(rle, &idev->id_resources, link) {
|
||||
if (rle->res)
|
||||
resource_list_release(dev, child,
|
||||
resource_list_release(rl, dev, child,
|
||||
rle->type,
|
||||
rle->rid,
|
||||
rle->res);
|
||||
@ -892,11 +895,11 @@ static device_method_t isa_methods[] = {
|
||||
DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource),
|
||||
DEVMETHOD(bus_setup_intr, isa_setup_intr),
|
||||
DEVMETHOD(bus_teardown_intr, isa_teardown_intr),
|
||||
DEVMETHOD(bus_set_resource, isa_set_resource),
|
||||
DEVMETHOD(bus_get_resource, isa_get_resource),
|
||||
DEVMETHOD(bus_delete_resource, isa_delete_resource),
|
||||
|
||||
/* ISA interface */
|
||||
DEVMETHOD(isa_set_resource, isa_set_resource),
|
||||
DEVMETHOD(isa_get_resource, isa_get_resource),
|
||||
DEVMETHOD(isa_delete_resource, isa_delete_resource),
|
||||
DEVMETHOD(isa_add_config, isa_add_config),
|
||||
DEVMETHOD(isa_set_config_callback, isa_set_config_callback),
|
||||
DEVMETHOD(isa_pnp_probe, isa_pnp_probe),
|
||||
|
@ -32,42 +32,6 @@ CODE {
|
||||
|
||||
INTERFACE isa;
|
||||
|
||||
#
|
||||
# Set the range used for a particular resource. Return EINVAL if
|
||||
# the type or rid are out of range.
|
||||
#
|
||||
METHOD int set_resource {
|
||||
device_t dev;
|
||||
device_t child;
|
||||
int type;
|
||||
int rid;
|
||||
u_long start;
|
||||
u_long count;
|
||||
};
|
||||
|
||||
#
|
||||
# Get the range for a resource. Return ENOENT if the type or rid are
|
||||
# out of range or have not been set.
|
||||
#
|
||||
METHOD int get_resource {
|
||||
device_t dev;
|
||||
device_t child;
|
||||
int type;
|
||||
int rid;
|
||||
u_long *startp;
|
||||
u_long *countp;
|
||||
};
|
||||
|
||||
#
|
||||
# Delete a resource.
|
||||
#
|
||||
METHOD void delete_resource {
|
||||
device_t dev;
|
||||
device_t child;
|
||||
int type;
|
||||
int rid;
|
||||
};
|
||||
|
||||
#
|
||||
# Add a Plug-and-play configuration to the device. Configurations with
|
||||
# a lower priority are preferred.
|
||||
|
@ -59,21 +59,19 @@ isahint_add_device(device_t parent, const char *name, int unit)
|
||||
count = 0;
|
||||
if ((resource_int_value(name, unit, "port", &start) == 0 && start > 0)
|
||||
|| (resource_int_value(name, unit, "portsize", &count) == 0 && count > 0))
|
||||
ISA_SET_RESOURCE(parent, child, SYS_RES_IOPORT, 0,
|
||||
start, count);
|
||||
bus_set_resource(child, SYS_RES_IOPORT, 0, start, count);
|
||||
|
||||
start = 0;
|
||||
count = 0;
|
||||
if ((resource_int_value(name, unit, "maddr", &start) == 0 && start > 0)
|
||||
|| (resource_int_value(name, unit, "msize", &count) == 0 && count > 0))
|
||||
ISA_SET_RESOURCE(parent, child, SYS_RES_MEMORY, 0,
|
||||
start, count);
|
||||
bus_set_resource(child, SYS_RES_MEMORY, 0, start, count);
|
||||
|
||||
if (resource_int_value(name, unit, "irq", &start) == 0 && start > 0)
|
||||
ISA_SET_RESOURCE(parent, child, SYS_RES_IRQ, 0, start, 1);
|
||||
bus_set_resource(child, SYS_RES_IRQ, 0, start, 1);
|
||||
|
||||
if (resource_int_value(name, unit, "drq", &start) == 0 && start > 0)
|
||||
ISA_SET_RESOURCE(parent, child, SYS_RES_DRQ, 0, start, 1);
|
||||
bus_set_resource(child, SYS_RES_DRQ, 0, start, 1);
|
||||
|
||||
if (resource_int_value(name, unit, "flags", &t) == 0)
|
||||
device_set_flags(child, t);
|
||||
|
@ -49,8 +49,8 @@ typedef void isa_config_cb(void *arg, struct isa_config *config, int enable);
|
||||
#define ISA_ORDER_SPECULATIVE 1 /* legacy non-sensitive hardware */
|
||||
#define ISA_ORDER_PNP 2 /* plug-and-play hardware */
|
||||
|
||||
#define ISA_NPORT 8
|
||||
#define ISA_NMEM 4
|
||||
#define ISA_NPORT 32
|
||||
#define ISA_NMEM 8
|
||||
#define ISA_NIRQ 2
|
||||
#define ISA_NDRQ 2
|
||||
|
||||
|
@ -124,9 +124,9 @@ isavga_probe(device_t dev)
|
||||
error = vga_probe_unit(device_get_unit(dev), &adp, device_get_flags(dev));
|
||||
if (error == 0) {
|
||||
bus = device_get_parent(dev);
|
||||
ISA_SET_RESOURCE(bus, dev, SYS_RES_IOPORT, 0,
|
||||
bus_set_resource(dev, SYS_RES_IOPORT, 0,
|
||||
adp.va_io_base, adp.va_io_size);
|
||||
ISA_SET_RESOURCE(bus, dev, SYS_RES_MEMORY, 0,
|
||||
bus_set_resource(dev, SYS_RES_MEMORY, 0,
|
||||
adp.va_mem_base, adp.va_mem_size);
|
||||
#if 0
|
||||
isa_set_port(dev, adp.va_io_base);
|
||||
|
@ -198,3 +198,39 @@ METHOD int teardown_intr {
|
||||
struct resource *irq;
|
||||
void *cookie;
|
||||
};
|
||||
|
||||
#
|
||||
# Set the range used for a particular resource. Return EINVAL if
|
||||
# the type or rid are out of range.
|
||||
#
|
||||
METHOD int set_resource {
|
||||
device_t dev;
|
||||
device_t child;
|
||||
int type;
|
||||
int rid;
|
||||
u_long start;
|
||||
u_long count;
|
||||
};
|
||||
|
||||
#
|
||||
# Get the range for a resource. Return ENOENT if the type or rid are
|
||||
# out of range or have not been set.
|
||||
#
|
||||
METHOD int get_resource {
|
||||
device_t dev;
|
||||
device_t child;
|
||||
int type;
|
||||
int rid;
|
||||
u_long *startp;
|
||||
u_long *countp;
|
||||
};
|
||||
|
||||
#
|
||||
# Delete a resource.
|
||||
#
|
||||
METHOD void delete_resource {
|
||||
device_t dev;
|
||||
device_t child;
|
||||
int type;
|
||||
int rid;
|
||||
};
|
||||
|
@ -906,24 +906,25 @@ device_get_flags(device_t dev)
|
||||
int
|
||||
device_print_prettyname(device_t dev)
|
||||
{
|
||||
const char *name = device_get_name(dev);
|
||||
const char *name = device_get_name(dev);
|
||||
|
||||
if (name == 0)
|
||||
name = "(no driver assigned)";
|
||||
return(printf("%s%d: ", name, device_get_unit(dev)));
|
||||
if (name == 0)
|
||||
return printf("unknown: ");
|
||||
else
|
||||
return printf("%s%d: ", name, device_get_unit(dev));
|
||||
}
|
||||
|
||||
int
|
||||
device_printf(device_t dev, const char * fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
int retval;
|
||||
va_list ap;
|
||||
int retval;
|
||||
|
||||
retval = device_print_prettyname(dev);
|
||||
va_start(ap, fmt);
|
||||
retval += vprintf(fmt, ap);
|
||||
va_end(ap);
|
||||
return retval;
|
||||
retval = device_print_prettyname(dev);
|
||||
va_start(ap, fmt);
|
||||
retval += vprintf(fmt, ap);
|
||||
va_end(ap);
|
||||
return retval;
|
||||
}
|
||||
|
||||
static void
|
||||
@ -1710,12 +1711,12 @@ resource_list_delete(struct resource_list *rl,
|
||||
}
|
||||
|
||||
struct resource *
|
||||
resource_list_alloc(device_t bus, device_t child,
|
||||
resource_list_alloc(struct resource_list *rl,
|
||||
device_t bus, device_t child,
|
||||
int type, int *rid,
|
||||
u_long start, u_long end,
|
||||
u_long count, u_int flags)
|
||||
{
|
||||
struct resource_list *rl;
|
||||
struct resource_list_entry *rle = 0;
|
||||
int passthrough = (device_get_parent(child) != bus);
|
||||
int isdefault = (start == 0UL && end == ~0UL);
|
||||
@ -1726,7 +1727,6 @@ resource_list_alloc(device_t bus, device_t child,
|
||||
start, end, count, flags);
|
||||
}
|
||||
|
||||
rl = device_get_ivars(child);
|
||||
rle = resource_list_find(rl, type, *rid);
|
||||
|
||||
if (!rle)
|
||||
@ -1756,10 +1756,10 @@ resource_list_alloc(device_t bus, device_t child,
|
||||
}
|
||||
|
||||
int
|
||||
resource_list_release(device_t bus, device_t child,
|
||||
resource_list_release(struct resource_list *rl,
|
||||
device_t bus, device_t child,
|
||||
int type, int rid, struct resource *res)
|
||||
{
|
||||
struct resource_list *rl;
|
||||
struct resource_list_entry *rle = 0;
|
||||
int passthrough = (device_get_parent(child) != bus);
|
||||
int error;
|
||||
@ -1769,7 +1769,6 @@ resource_list_release(device_t bus, device_t child,
|
||||
type, rid, res);
|
||||
}
|
||||
|
||||
rl = device_get_ivars(child);
|
||||
rle = resource_list_find(rl, type, rid);
|
||||
|
||||
if (!rle)
|
||||
@ -2065,6 +2064,54 @@ bus_teardown_intr(device_t dev, struct resource *r, void *cookie)
|
||||
return (BUS_TEARDOWN_INTR(dev->parent, dev, r, cookie));
|
||||
}
|
||||
|
||||
int
|
||||
bus_set_resource(device_t dev, int type, int rid,
|
||||
u_long start, u_long count)
|
||||
{
|
||||
return BUS_SET_RESOURCE(device_get_parent(dev), dev, type, rid,
|
||||
start, count);
|
||||
}
|
||||
|
||||
int
|
||||
bus_get_resource(device_t dev, int type, int rid,
|
||||
u_long *startp, u_long *countp)
|
||||
{
|
||||
return BUS_GET_RESOURCE(device_get_parent(dev), dev, type, rid,
|
||||
startp, countp);
|
||||
}
|
||||
|
||||
u_long
|
||||
bus_get_resource_start(device_t dev, int type, int rid)
|
||||
{
|
||||
u_long start, count;
|
||||
int error;
|
||||
|
||||
error = BUS_GET_RESOURCE(device_get_parent(dev), dev, type, rid,
|
||||
&start, &count);
|
||||
if (error)
|
||||
return 0;
|
||||
return start;
|
||||
}
|
||||
|
||||
u_long
|
||||
bus_get_resource_count(device_t dev, int type, int rid)
|
||||
{
|
||||
u_long start, count;
|
||||
int error;
|
||||
|
||||
error = BUS_GET_RESOURCE(device_get_parent(dev), dev, type, rid,
|
||||
&start, &count);
|
||||
if (error)
|
||||
return 0;
|
||||
return count;
|
||||
}
|
||||
|
||||
void
|
||||
bus_delete_resource(device_t dev, int type, int rid)
|
||||
{
|
||||
BUS_DELETE_RESOURCE(device_get_parent(dev), dev, type, rid);
|
||||
}
|
||||
|
||||
static int
|
||||
root_print_child(device_t dev, device_t child)
|
||||
{
|
||||
|
@ -64,11 +64,10 @@ isa_compat_nextid(void)
|
||||
static void
|
||||
isa_compat_alloc_resources(device_t dev, struct isa_compat_resources *res)
|
||||
{
|
||||
device_t parent = device_get_parent(dev);
|
||||
int rid;
|
||||
u_long start, count;
|
||||
|
||||
if (ISA_GET_RESOURCE(parent, dev, SYS_RES_IOPORT, 0,
|
||||
if (bus_get_resource(dev, SYS_RES_IOPORT, 0,
|
||||
&start, &count) == 0) {
|
||||
rid = 0;
|
||||
res->ports = bus_alloc_resource(dev, SYS_RES_IOPORT,
|
||||
@ -80,7 +79,7 @@ isa_compat_alloc_resources(device_t dev, struct isa_compat_resources *res)
|
||||
} else
|
||||
res->ports = 0;
|
||||
|
||||
if (ISA_GET_RESOURCE(parent, dev, SYS_RES_MEMORY, 0,
|
||||
if (bus_get_resource(dev, SYS_RES_MEMORY, 0,
|
||||
&start, &count) == 0
|
||||
&& start != 0) {
|
||||
rid = 0;
|
||||
@ -93,7 +92,7 @@ isa_compat_alloc_resources(device_t dev, struct isa_compat_resources *res)
|
||||
} else
|
||||
res->memory = 0;
|
||||
|
||||
if (ISA_GET_RESOURCE(parent, dev, SYS_RES_DRQ, 0,
|
||||
if (bus_get_resource(dev, SYS_RES_DRQ, 0,
|
||||
&start, &count) == 0) {
|
||||
rid = 0;
|
||||
res->drq = bus_alloc_resource(dev, SYS_RES_DRQ,
|
||||
@ -105,7 +104,7 @@ isa_compat_alloc_resources(device_t dev, struct isa_compat_resources *res)
|
||||
} else
|
||||
res->drq = 0;
|
||||
|
||||
if (ISA_GET_RESOURCE(parent, dev, SYS_RES_IRQ, 0,
|
||||
if (bus_get_resource(dev, SYS_RES_IRQ, 0,
|
||||
&start, &count) == 0) {
|
||||
rid = 0;
|
||||
res->irq = bus_alloc_resource(dev, SYS_RES_IRQ,
|
||||
@ -144,7 +143,6 @@ isa_compat_release_resources(device_t dev, struct isa_compat_resources *res)
|
||||
static int
|
||||
isa_compat_probe(device_t dev)
|
||||
{
|
||||
device_t parent = device_get_parent(dev);
|
||||
struct isa_device *dvp = device_get_softc(dev);
|
||||
struct isa_compat_resources res;
|
||||
struct old_isa_driver *op;
|
||||
@ -161,22 +159,22 @@ isa_compat_probe(device_t dev)
|
||||
op = device_get_driver(dev)->priv;
|
||||
dvp->id_id = isa_compat_nextid();
|
||||
dvp->id_driver = op->driver;
|
||||
if (ISA_GET_RESOURCE(parent, dev, SYS_RES_IOPORT, 0,
|
||||
if (bus_get_resource(dev, SYS_RES_IOPORT, 0,
|
||||
&start, &count) == 0)
|
||||
dvp->id_iobase = start;
|
||||
else
|
||||
dvp->id_iobase = -1;
|
||||
if (ISA_GET_RESOURCE(parent, dev, SYS_RES_IRQ, 0,
|
||||
if (bus_get_resource(dev, SYS_RES_IRQ, 0,
|
||||
&start, &count) == 0)
|
||||
dvp->id_irq = irqmask(start);
|
||||
else
|
||||
dvp->id_irq = 0;
|
||||
if (ISA_GET_RESOURCE(parent, dev, SYS_RES_DRQ, 0,
|
||||
if (bus_get_resource(dev, SYS_RES_DRQ, 0,
|
||||
&start, &count) == 0)
|
||||
dvp->id_drq = start;
|
||||
else
|
||||
dvp->id_drq = -1;
|
||||
if (ISA_GET_RESOURCE(parent, dev, SYS_RES_MEMORY,
|
||||
if (bus_get_resource(dev, SYS_RES_MEMORY,
|
||||
0, &start, &count) == 0) {
|
||||
dvp->id_maddr = (void *)(uintptr_t)start;
|
||||
dvp->id_msize = count;
|
||||
@ -208,25 +206,25 @@ isa_compat_probe(device_t dev)
|
||||
isa_compat_release_resources(dev, &res);
|
||||
if (portsize != 0) {
|
||||
if (portsize > 0 || dvp->id_iobase != old.id_iobase)
|
||||
ISA_SET_RESOURCE(parent, dev, SYS_RES_IOPORT,
|
||||
bus_set_resource(dev, SYS_RES_IOPORT,
|
||||
0, dvp->id_iobase, portsize);
|
||||
if (dvp->id_irq != old.id_irq)
|
||||
ISA_SET_RESOURCE(parent, dev, SYS_RES_IRQ, 0,
|
||||
bus_set_resource(dev, SYS_RES_IRQ, 0,
|
||||
ffs(dvp->id_irq) - 1, 1);
|
||||
if (dvp->id_drq != old.id_drq)
|
||||
ISA_SET_RESOURCE(parent, dev, SYS_RES_DRQ, 0,
|
||||
bus_set_resource(dev, SYS_RES_DRQ, 0,
|
||||
dvp->id_drq, 1);
|
||||
if (dvp->id_maddr != old.id_maddr
|
||||
|| dvp->id_msize != old.id_msize) {
|
||||
maddr = dvp->id_maddr;
|
||||
if (maddr != NULL)
|
||||
ISA_SET_RESOURCE(parent, dev,
|
||||
bus_set_resource(dev,
|
||||
SYS_RES_MEMORY,
|
||||
0,
|
||||
kvtop(maddr),
|
||||
dvp->id_msize);
|
||||
else
|
||||
ISA_DELETE_RESOURCE(parent, dev,
|
||||
bus_delete_resource(dev,
|
||||
SYS_RES_MEMORY,
|
||||
0);
|
||||
}
|
||||
|
@ -141,7 +141,8 @@ void resource_list_delete(struct resource_list *rl,
|
||||
* the parent of bus.
|
||||
*/
|
||||
struct resource *
|
||||
resource_list_alloc(device_t bus, device_t child,
|
||||
resource_list_alloc(struct resource_list *rl,
|
||||
device_t bus, device_t child,
|
||||
int type, int *rid,
|
||||
u_long start, u_long end,
|
||||
u_long count, u_int flags);
|
||||
@ -149,7 +150,8 @@ struct resource *
|
||||
/*
|
||||
* Implement BUS_RELEASE_RESOURCE.
|
||||
*/
|
||||
int resource_list_release(device_t bus, device_t child,
|
||||
int resource_list_release(struct resource_list *rl,
|
||||
device_t bus, device_t child,
|
||||
int type, int rid, struct resource *res);
|
||||
|
||||
/*
|
||||
@ -209,6 +211,13 @@ int bus_release_resource(device_t dev, int type, int rid,
|
||||
int bus_setup_intr(device_t dev, struct resource *r, int flags,
|
||||
driver_intr_t handler, void *arg, void **cookiep);
|
||||
int bus_teardown_intr(device_t dev, struct resource *r, void *cookie);
|
||||
int bus_set_resource(device_t dev, int type, int rid,
|
||||
u_long start, u_long count);
|
||||
int bus_get_resource(device_t dev, int type, int rid,
|
||||
u_long *startp, u_long *countp);
|
||||
u_long bus_get_resource_start(device_t dev, int type, int rid);
|
||||
u_long bus_get_resource_count(device_t dev, int type, int rid);
|
||||
void bus_delete_resource(device_t dev, int type, int rid);
|
||||
|
||||
/*
|
||||
* Access functions for device.
|
||||
|
Loading…
Reference in New Issue
Block a user