summaryrefslogtreecommitdiffstats
path: root/sys
diff options
context:
space:
mode:
authorsos <sos@FreeBSD.org>2003-11-30 16:27:59 +0000
committersos <sos@FreeBSD.org>2003-11-30 16:27:59 +0000
commit396e8abc850f4833591004d40a59d10c56696041 (patch)
tree81fa70e4700e34a0683ab5886703210bccaf3796 /sys
parent55c4b326afcb154451ecff37c6d76c6089fa33ac (diff)
downloadFreeBSD-src-396e8abc850f4833591004d40a59d10c56696041.zip
FreeBSD-src-396e8abc850f4833591004d40a59d10c56696041.tar.gz
Fix ata-card.
The altio resource magic no longer worked probably due to other changes in the kernel. Redo that part so it also fits better into ATAng. Fix detach so it doesn't panic the system when a pccard device is yanked. Approved by: re@
Diffstat (limited to 'sys')
-rw-r--r--sys/dev/ata/ata-all.c2
-rw-r--r--sys/dev/ata/ata-card.c64
2 files changed, 28 insertions, 38 deletions
diff --git a/sys/dev/ata/ata-all.c b/sys/dev/ata/ata-all.c
index c5f1b44..88bfc56 100644
--- a/sys/dev/ata/ata-all.c
+++ b/sys/dev/ata/ata-all.c
@@ -74,12 +74,12 @@ static void bpack(int8_t *, int8_t *, int);
static void ata_init(void);
/* global vars */
+MALLOC_DEFINE(M_ATA, "ATA generic", "ATA driver generic layer");
struct intr_config_hook *ata_delayed_attach = NULL;
devclass_t ata_devclass;
int ata_wc = 1;
/* local vars */
-static MALLOC_DEFINE(M_ATA, "ATA generic", "ATA driver generic layer");
static int ata_dma = 1;
static int atapi_dma = 0;
diff --git a/sys/dev/ata/ata-card.c b/sys/dev/ata/ata-card.c
index 8bb99b2..220c5d0 100644
--- a/sys/dev/ata/ata-card.c
+++ b/sys/dev/ata/ata-card.c
@@ -58,6 +58,8 @@ static const struct pccard_product ata_pccard_products[] = {
{NULL}
};
+MALLOC_DECLARE(M_ATA);
+
static int
ata_pccard_match(device_t dev)
{
@@ -99,8 +101,7 @@ ata_pccard_probe(device_t dev)
{
struct ata_channel *ch = device_get_softc(dev);
struct resource *io, *altio;
- int i, rid, len, start, end;
- u_long tmp;
+ int i, rid, len;
/* allocate the io range to get start and length */
rid = ATA_IOADDR_RID;
@@ -110,52 +111,39 @@ ata_pccard_probe(device_t dev)
if (!io)
return ENXIO;
- /* reallocate the io address to only cover the io ports */
- start = rman_get_start(io);
- end = start + ATA_IOSIZE - 1;
- bus_release_resource(dev, SYS_RES_IOPORT, rid, io);
- io = bus_alloc_resource(dev, SYS_RES_IOPORT, &rid,
- start, end, ATA_IOSIZE, RF_ACTIVE);
-
- /*
- * if we got more than the default ATA_IOSIZE ports, this is likely
- * a pccard system where the altio ports are located at offset 14
- * otherwise its the normal altio offset
- */
- if (bus_get_resource(dev, SYS_RES_IOPORT, ATA_ALTADDR_RID, &tmp, &tmp)) {
- if (len > ATA_IOSIZE) {
- bus_set_resource(dev, SYS_RES_IOPORT, ATA_ALTADDR_RID,
- start + ATA_PCCARD_ALTOFFSET, ATA_ALTIOSIZE);
- }
- else {
- bus_set_resource(dev, SYS_RES_IOPORT, ATA_ALTADDR_RID,
- start + ATA_ALTOFFSET, ATA_ALTIOSIZE);
- }
- }
-
- /* allocate the altport range */
- rid = ATA_ALTADDR_RID;
- altio = bus_alloc_resource(dev, SYS_RES_IOPORT, &rid, 0, ~0,
- ATA_ALTIOSIZE, RF_ACTIVE);
- if (!altio) {
- bus_release_resource(dev, SYS_RES_IOPORT, ATA_IOADDR_RID, io);
- return ENXIO;
- }
-
/* setup the resource vectors */
for (i = ATA_DATA; i <= ATA_STATUS; i++) {
ch->r_io[i].res = io;
ch->r_io[i].offset = i;
}
- ch->r_io[ATA_ALTSTAT].res = altio;
- ch->r_io[ATA_ALTSTAT].offset = 0;
+
+ /*
+ * if we got more than the default ATA_IOSIZE ports, this is a device
+ * where altio is located at offset 14 into "normal" io space.
+ */
+ if (len > ATA_IOSIZE) {
+ ch->r_io[ATA_ALTSTAT].res = io;
+ ch->r_io[ATA_ALTSTAT].offset = 14;
+ }
+ else {
+ rid = ATA_ALTADDR_RID;
+ altio = bus_alloc_resource(dev, SYS_RES_IOPORT, &rid, 0, ~0,
+ ATA_ALTIOSIZE, RF_ACTIVE);
+ if (!altio) {
+ bus_release_resource(dev, SYS_RES_IOPORT, ATA_IOADDR_RID, io);
+ for (i = ATA_DATA; i < ATA_MAX_RES; i++)
+ ch->r_io[i].res = NULL;
+ return ENXIO;
+ }
+ ch->r_io[ATA_ALTSTAT].res = altio;
+ ch->r_io[ATA_ALTSTAT].offset = 0;
+ }
/* initialize softc for this channel */
ch->unit = 0;
ch->flags |= (ATA_USE_16BIT | ATA_NO_SLAVE);
ch->locking = ata_pccard_locknoop;
ch->device[MASTER].setmode = ata_pccard_setmode;
- ch->device[SLAVE].setmode = ata_pccard_setmode;
return ata_probe(dev);
}
@@ -165,6 +153,8 @@ ata_pccard_detach(device_t dev)
struct ata_channel *ch = device_get_softc(dev);
int i;
+ free(ch->device[MASTER].param, M_ATA);
+ ch->device[MASTER].param = NULL;
ata_detach(dev);
bus_release_resource(dev, SYS_RES_IOPORT,
ATA_ALTADDR_RID, ch->r_io[ATA_ALTSTAT].res);
OpenPOWER on IntegriCloud