Changeset View
Changeset View
Standalone View
Standalone View
sys/dev/ata/ata-isa.c
Show First 20 Lines • Show All 42 Lines • ▼ Show 20 Lines | |||||
{0x8006d041, "Standard bus mastering IDE hard disk controller"}, | {0x8006d041, "Standard bus mastering IDE hard disk controller"}, | ||||
{0} | {0} | ||||
}; | }; | ||||
static int | static int | ||||
ata_isa_probe(device_t dev) | ata_isa_probe(device_t dev) | ||||
{ | { | ||||
struct resource *io = NULL, *ctlio = NULL; | struct resource *io = NULL, *ctlio = NULL; | ||||
u_long tmp; | rman_res_t tmp; | ||||
rman_res_t tcount; | |||||
int rid; | int rid; | ||||
/* check isapnp ids */ | /* check isapnp ids */ | ||||
if (ISA_PNP_PROBE(device_get_parent(dev), dev, ata_ids) == ENXIO) | if (ISA_PNP_PROBE(device_get_parent(dev), dev, ata_ids) == ENXIO) | ||||
return ENXIO; | return ENXIO; | ||||
/* allocate the io port range */ | /* allocate the io port range */ | ||||
rid = ATA_IOADDR_RID; | rid = ATA_IOADDR_RID; | ||||
if (!(io = bus_alloc_resource(dev, SYS_RES_IOPORT, &rid, 0, ~0, | if (!(io = bus_alloc_resource(dev, SYS_RES_IOPORT, &rid, 0, ~0, | ||||
ATA_IOSIZE, RF_ACTIVE))) | ATA_IOSIZE, RF_ACTIVE))) | ||||
return ENXIO; | return ENXIO; | ||||
/* set the altport range */ | /* set the altport range */ | ||||
if (bus_get_resource(dev, SYS_RES_IOPORT, ATA_CTLADDR_RID, &tmp, &tmp)) { | if (bus_get_resource(dev, SYS_RES_IOPORT, ATA_CTLADDR_RID, &tmp, &tcount)) { | ||||
bus_set_resource(dev, SYS_RES_IOPORT, ATA_CTLADDR_RID, | bus_set_resource(dev, SYS_RES_IOPORT, ATA_CTLADDR_RID, | ||||
rman_get_start(io) + ATA_CTLOFFSET, ATA_CTLIOSIZE); | rman_get_start(io) + ATA_CTLOFFSET, ATA_CTLIOSIZE); | ||||
} | } | ||||
/* allocate the altport range */ | /* allocate the altport range */ | ||||
rid = ATA_CTLADDR_RID; | rid = ATA_CTLADDR_RID; | ||||
if (!(ctlio = bus_alloc_resource(dev, SYS_RES_IOPORT, &rid, 0, ~0, | if (!(ctlio = bus_alloc_resource(dev, SYS_RES_IOPORT, &rid, 0, ~0, | ||||
jhb: Why RM_MAX_END here instead of ~0? | |||||
ATA_CTLIOSIZE, RF_ACTIVE))) { | ATA_CTLIOSIZE, RF_ACTIVE))) { | ||||
bus_release_resource(dev, SYS_RES_IOPORT, ATA_IOADDR_RID, io); | bus_release_resource(dev, SYS_RES_IOPORT, ATA_IOADDR_RID, io); | ||||
return ENXIO; | return ENXIO; | ||||
} | } | ||||
/* Release resources to reallocate on attach. */ | /* Release resources to reallocate on attach. */ | ||||
bus_release_resource(dev, SYS_RES_IOPORT, ATA_CTLADDR_RID, ctlio); | bus_release_resource(dev, SYS_RES_IOPORT, ATA_CTLADDR_RID, ctlio); | ||||
bus_release_resource(dev, SYS_RES_IOPORT, ATA_IOADDR_RID, io); | bus_release_resource(dev, SYS_RES_IOPORT, ATA_IOADDR_RID, io); | ||||
device_set_desc(dev, "ATA channel"); | device_set_desc(dev, "ATA channel"); | ||||
return (ata_probe(dev)); | return (ata_probe(dev)); | ||||
} | } | ||||
static int | static int | ||||
ata_isa_attach(device_t dev) | ata_isa_attach(device_t dev) | ||||
{ | { | ||||
struct ata_channel *ch = device_get_softc(dev); | struct ata_channel *ch = device_get_softc(dev); | ||||
struct resource *io = NULL, *ctlio = NULL; | struct resource *io = NULL, *ctlio = NULL; | ||||
u_long tmp; | rman_res_t tmp; | ||||
rman_res_t tcount; | |||||
int i, rid; | int i, rid; | ||||
if (ch->attached) | if (ch->attached) | ||||
return (0); | return (0); | ||||
ch->attached = 1; | ch->attached = 1; | ||||
/* allocate the io port range */ | /* allocate the io port range */ | ||||
rid = ATA_IOADDR_RID; | rid = ATA_IOADDR_RID; | ||||
if (!(io = bus_alloc_resource(dev, SYS_RES_IOPORT, &rid, 0, ~0, | if (!(io = bus_alloc_resource(dev, SYS_RES_IOPORT, &rid, 0, ~0, | ||||
ATA_IOSIZE, RF_ACTIVE))) | ATA_IOSIZE, RF_ACTIVE))) | ||||
return ENXIO; | return ENXIO; | ||||
/* set the altport range */ | /* set the altport range */ | ||||
if (bus_get_resource(dev, SYS_RES_IOPORT, ATA_CTLADDR_RID, &tmp, &tmp)) { | if (bus_get_resource(dev, SYS_RES_IOPORT, ATA_CTLADDR_RID, &tmp, &tcount)) { | ||||
bus_set_resource(dev, SYS_RES_IOPORT, ATA_CTLADDR_RID, | bus_set_resource(dev, SYS_RES_IOPORT, ATA_CTLADDR_RID, | ||||
rman_get_start(io) + ATA_CTLOFFSET, ATA_CTLIOSIZE); | rman_get_start(io) + ATA_CTLOFFSET, ATA_CTLIOSIZE); | ||||
} | } | ||||
/* allocate the altport range */ | /* allocate the altport range */ | ||||
rid = ATA_CTLADDR_RID; | rid = ATA_CTLADDR_RID; | ||||
if (!(ctlio = bus_alloc_resource(dev, SYS_RES_IOPORT, &rid, 0, ~0, | if (!(ctlio = bus_alloc_resource(dev, SYS_RES_IOPORT, &rid, 0, ~0, | ||||
ATA_CTLIOSIZE, RF_ACTIVE))) { | ATA_CTLIOSIZE, RF_ACTIVE))) { | ||||
▲ Show 20 Lines • Show All 42 Lines • Show Last 20 Lines |
Why RM_MAX_END here instead of ~0?