summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSøren Schmidt <sos@FreeBSD.org>2000-03-14 20:25:13 +0000
committerSøren Schmidt <sos@FreeBSD.org>2000-03-14 20:25:13 +0000
commitd281aade56d59271978d284cabf9daa78cf59049 (patch)
tree17493d5dd2f635c97bdd4f256ad346c293cf2920
parent3bc3e3e7a0616d2157f77f56d0434fbbddc8ea5e (diff)
Notes
-rw-r--r--sys/dev/ata/ata-all.c22
-rw-r--r--sys/dev/ata/ata-disk.c15
-rw-r--r--sys/dev/ata/ata-disk.h3
-rw-r--r--sys/dev/ata/atapi-all.c44
-rw-r--r--sys/dev/ata/atapi-all.h15
-rw-r--r--sys/dev/ata/atapi-cd.c78
-rw-r--r--sys/dev/ata/atapi-fd.c23
-rw-r--r--sys/dev/ata/atapi-tape.c37
8 files changed, 121 insertions, 116 deletions
diff --git a/sys/dev/ata/ata-all.c b/sys/dev/ata/ata-all.c
index b8527f01733ca..63ace7c6a8c0a 100644
--- a/sys/dev/ata/ata-all.c
+++ b/sys/dev/ata/ata-all.c
@@ -921,15 +921,15 @@ ata_detach(device_t dev)
#if NATADISK > 0
if (scp->devices & ATA_ATA_MASTER)
- ad_detach(scp, ATA_MASTER);
+ ad_detach(scp->dev_softc[0]);
if (scp->devices & ATA_ATA_SLAVE)
- ad_detach(scp, ATA_SLAVE);
+ ad_detach(scp->dev_softc[1]);
#endif
#if NATAPICD > 0 || NATAPIFD > 0 || NATAPIST > 0
if (scp->devices & ATA_ATAPI_MASTER)
- atapi_detach(scp, ATA_MASTER);
+ atapi_detach(scp->dev_softc[0]);
if (scp->devices & ATA_ATAPI_SLAVE)
- atapi_detach(scp, ATA_SLAVE);
+ atapi_detach(scp->dev_softc[1]);
#endif
if (scp->dev_param[ATA_DEV(ATA_MASTER)]) {
free(scp->dev_param[ATA_DEV(ATA_MASTER)], M_ATA);
@@ -939,6 +939,8 @@ ata_detach(device_t dev)
free(scp->dev_param[ATA_DEV(ATA_SLAVE)], M_ATA);
scp->dev_param[ATA_DEV(ATA_SLAVE)] = NULL;
}
+ scp->dev_softc[ATA_DEV(ATA_MASTER)] = NULL;
+ scp->dev_softc[ATA_DEV(ATA_SLAVE)] = NULL;
scp->mode[ATA_DEV(ATA_MASTER)] = ATA_PIO;
scp->mode[ATA_DEV(ATA_SLAVE)] = ATA_PIO;
bus_teardown_intr(dev, scp->r_irq, scp->ih);
@@ -1171,6 +1173,12 @@ ata_start(struct ata_softc *scp)
#if NATADISK > 0
/* find & call the responsible driver if anything on the ATA queue */
+ if (TAILQ_EMPTY(&scp->ata_queue)) {
+ if (scp->devices & (ATA_ATA_MASTER) && scp->dev_softc[0])
+ ad_start((struct ad_softc *)scp->dev_softc[0]);
+ if (scp->devices & (ATA_ATA_SLAVE) && scp->dev_softc[1])
+ ad_start((struct ad_softc *)scp->dev_softc[1]);
+ }
if ((ad_request = TAILQ_FIRST(&scp->ata_queue))) {
TAILQ_REMOVE(&scp->ata_queue, ad_request, chain);
scp->active = ATA_ACTIVE_ATA;
@@ -1187,6 +1195,12 @@ ata_start(struct ata_softc *scp)
* if the other device is an ATA disk it already had its chance above.
* if no request can be served, timeout a call to ata_start.
*/
+ if (TAILQ_EMPTY(&scp->atapi_queue)) {
+ if (scp->devices & (ATA_ATAPI_MASTER) && scp->dev_softc[0])
+ atapi_start((struct atapi_softc *)scp->dev_softc[0]);
+ if (scp->devices & (ATA_ATAPI_SLAVE) && scp->dev_softc[1])
+ atapi_start((struct atapi_softc *)scp->dev_softc[1]);
+ }
if ((atapi_request = TAILQ_FIRST(&scp->atapi_queue))) {
struct atapi_softc *atp = atapi_request->device;
static int32_t interval = 1;
diff --git a/sys/dev/ata/ata-disk.c b/sys/dev/ata/ata-disk.c
index 46915a71c0d4d..802a783bb6e7f 100644
--- a/sys/dev/ata/ata-disk.c
+++ b/sys/dev/ata/ata-disk.c
@@ -91,7 +91,6 @@ static struct cdevsw fakewd_cdevsw = {
static struct cdevsw fakewddisk_cdevsw;
/* prototypes */
-static void ad_start(struct ad_softc *);
static void ad_timeout(struct ad_request *);
static int32_t ad_version(u_int16_t);
@@ -207,17 +206,14 @@ ad_attach(struct ata_softc *scp, int32_t device)
}
void
-ad_detach(struct ata_softc *scp, int32_t device)
+ad_detach(struct ad_softc *adp)
{
- struct ad_softc *adp = scp->dev_softc[ATA_DEV(device)];
-
disk_invalidate(&adp->disk);
disk_destroy(adp->dev1);
disk_destroy(adp->dev2);
devstat_remove_entry(&adp->stats);
ata_free_lun(&adp_lun_map, adp->lun);
free(adp, M_AD);
- scp->dev_softc[ATA_DEV(device)] = NULL;
}
static int
@@ -252,7 +248,7 @@ adstrategy(struct buf *bp)
s = splbio();
bufqdisksort(&adp->queue, bp);
- ad_start(adp);
+ ata_start(adp->controller);
splx(s);
}
@@ -320,7 +316,7 @@ addump(dev_t dev)
return 0;
}
-static void
+void
ad_start(struct ad_softc *adp)
{
struct buf *bp = bufq_first(&adp->queue);
@@ -348,10 +344,6 @@ ad_start(struct ad_softc *adp)
/* link onto controller queue */
TAILQ_INSERT_TAIL(&adp->controller->ata_queue, request, chain);
-
- /* try to start controller */
- if (adp->controller->active == ATA_IDLE)
- ata_start(adp->controller);
}
void
@@ -566,7 +558,6 @@ oops:
untimeout((timeout_t *)ad_timeout, request, request->timeout_handle);
free(request, M_AD);
- ad_start(adp);
return ATA_OP_FINISHED;
}
diff --git a/sys/dev/ata/ata-disk.h b/sys/dev/ata/ata-disk.h
index 52eaeb26c165f..91e9fad92177e 100644
--- a/sys/dev/ata/ata-disk.h
+++ b/sys/dev/ata/ata-disk.h
@@ -71,7 +71,8 @@ struct ad_request {
};
void ad_attach(struct ata_softc *, int32_t);
-void ad_detach(struct ata_softc *, int32_t);
+void ad_detach(struct ad_softc *);
+void ad_start(struct ad_softc *);
void ad_transfer(struct ad_request *);
int32_t ad_interrupt(struct ad_request *);
void ad_reinit(struct ad_softc *);
diff --git a/sys/dev/ata/atapi-all.c b/sys/dev/ata/atapi-all.c
index 6167e78344457..56103cf77d395 100644
--- a/sys/dev/ata/atapi-all.c
+++ b/sys/dev/ata/atapi-all.c
@@ -51,14 +51,6 @@ static int8_t *atapi_type(int32_t);
static int8_t *atapi_cmd2str(u_int8_t);
static int8_t *atapi_skey2str(u_int8_t);
-/* extern references */
-int32_t acdattach(struct atapi_softc *);
-int32_t afdattach(struct atapi_softc *);
-int32_t astattach(struct atapi_softc *);
-void acddetach(struct atapi_softc *);
-void afddetach(struct atapi_softc *);
-void astdetach(struct atapi_softc *);
-
/* internal vars */
MALLOC_DEFINE(M_ATAPI, "ATAPI generic", "ATAPI driver generic layer");
@@ -131,10 +123,8 @@ notfound:
}
void
-atapi_detach(struct ata_softc *scp, int32_t device)
+atapi_detach(struct atapi_softc *atp)
{
- struct atapi_softc *atp = scp->dev_softc[ATA_DEV(device)];
-
switch (ATP_PARAM->device_type) {
#if NATAPICD > 0
case ATAPI_TYPE_CDROM:
@@ -155,13 +145,12 @@ atapi_detach(struct ata_softc *scp, int32_t device)
return;
}
free(atp, M_ATAPI);
- scp->dev_softc[ATA_DEV(device)] = NULL;
}
int32_t
atapi_queue_cmd(struct atapi_softc *atp, int8_t *ccb, void *data,
int32_t count, int32_t flags, int32_t timeout,
- atapi_callback_t callback, void *unused, struct buf *bp)
+ atapi_callback_t callback, struct buf *bp)
{
struct atapi_request *request;
int32_t error, s;
@@ -190,8 +179,7 @@ atapi_queue_cmd(struct atapi_softc *atp, int8_t *ccb, void *data,
/* append onto controller queue and try to start controller */
TAILQ_INSERT_TAIL(&atp->controller->atapi_queue, request, chain);
- if (atp->controller->active == ATA_IDLE)
- ata_start(atp->controller);
+ ata_start(atp->controller);
/* if callback used, then just return, gets called from interrupt context */
if (callback) {
@@ -208,6 +196,30 @@ atapi_queue_cmd(struct atapi_softc *atp, int8_t *ccb, void *data,
}
void
+atapi_start(struct atapi_softc *atp)
+{
+ switch (ATP_PARAM->device_type) {
+#if NATAPICD > 0
+ case ATAPI_TYPE_CDROM:
+ acd_start(atp);
+ break;
+#endif
+#if NATAPIFD > 0
+ case ATAPI_TYPE_DIRECT:
+ afd_start(atp);
+ break;
+#endif
+#if NATAPIST > 0
+ case ATAPI_TYPE_TAPE:
+ ast_start(atp);
+ break;
+#endif
+ default:
+ return;
+ }
+}
+
+void
atapi_transfer(struct atapi_request *request)
{
struct atapi_softc *atp = request->device;
@@ -451,7 +463,7 @@ atapi_test_ready(struct atapi_softc *atp)
int8_t ccb[16] = { ATAPI_TEST_UNIT_READY, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
- return atapi_queue_cmd(atp, ccb, NULL, 0, 0, 30, NULL, NULL, NULL);
+ return atapi_queue_cmd(atp, ccb, NULL, 0, 0, 30, NULL, NULL);
}
int32_t
diff --git a/sys/dev/ata/atapi-all.h b/sys/dev/ata/atapi-all.h
index 0c97536d12993..6e5bc5a7a9d5b 100644
--- a/sys/dev/ata/atapi-all.h
+++ b/sys/dev/ata/atapi-all.h
@@ -178,13 +178,22 @@ struct atapi_request {
};
void atapi_attach(struct ata_softc *, int32_t);
-void atapi_detach(struct ata_softc *, int32_t);
+void atapi_detach(struct atapi_softc *);
+void atapi_start(struct atapi_softc *);
void atapi_transfer(struct atapi_request *);
int32_t atapi_interrupt(struct atapi_request *);
-int32_t atapi_queue_cmd(struct atapi_softc *, int8_t [], void *, int32_t, int32_t, int32_t, atapi_callback_t, void *, struct buf *);
+int32_t atapi_queue_cmd(struct atapi_softc *, int8_t [], void *, int32_t, int32_t, int32_t, atapi_callback_t, struct buf *);
void atapi_reinit(struct atapi_softc *);
int32_t atapi_test_ready(struct atapi_softc *);
int32_t atapi_wait_ready(struct atapi_softc *, int32_t);
void atapi_request_sense(struct atapi_softc *, struct atapi_reqsense *);
void atapi_dump(int8_t *, void *, int32_t);
-
+int32_t acdattach(struct atapi_softc *);
+void acddetach(struct atapi_softc *);
+void acd_start(struct atapi_softc *);
+int32_t afdattach(struct atapi_softc *);
+void afddetach(struct atapi_softc *);
+void afd_start(struct atapi_softc *);
+int32_t astattach(struct atapi_softc *);
+void astdetach(struct atapi_softc *);
+void ast_start(struct atapi_softc *);
diff --git a/sys/dev/ata/atapi-cd.c b/sys/dev/ata/atapi-cd.c
index 37b707b3aae7b..4c9da0dfa6823 100644
--- a/sys/dev/ata/atapi-cd.c
+++ b/sys/dev/ata/atapi-cd.c
@@ -70,14 +70,11 @@ static struct cdevsw acd_cdevsw = {
};
/* prototypes */
-int32_t acdattach(struct atapi_softc *);
-void acddetach(struct atapi_softc *);
static struct acd_softc *acd_init_lun(struct atapi_softc *, struct devstat *);
static void acd_make_dev(struct acd_softc *);
static void acd_describe(struct acd_softc *);
static void lba2msf(int32_t, u_int8_t *, u_int8_t *, u_int8_t *);
static int32_t msf2lba(u_int8_t, u_int8_t, u_int8_t);
-static void acd_start(struct acd_softc *);
static int32_t acd_done(struct atapi_request *);
static int32_t acd_read_toc(struct acd_softc *);
static void acd_construct_label(struct acd_softc *);
@@ -152,7 +149,7 @@ acdattach(struct atapi_softc *atp)
}
bzero(chp, sizeof(struct changer));
error = atapi_queue_cmd(cdp->atp, ccb, chp, sizeof(struct changer),
- ATPR_F_READ, 60, NULL, NULL, NULL);
+ ATPR_F_READ, 60, NULL, NULL);
if (!error) {
struct acd_softc *tmpcdp = cdp;
@@ -703,7 +700,7 @@ acdioctl(dev_t dev, u_long cmd, caddr_t addr, int32_t flags, struct proc *p)
if ((error = atapi_queue_cmd(cdp->atp, ccb, &cdp->subchan,
sizeof(cdp->subchan), ATPR_F_READ, 10,
- NULL, NULL, NULL))) {
+ NULL, NULL))) {
break;
}
abslba = cdp->subchan.abslba;
@@ -738,8 +735,7 @@ acdioctl(dev_t dev, u_long cmd, caddr_t addr, int32_t flags, struct proc *p)
args->end_m, args->end_s, args->end_f,
0, 0, 0, 0, 0, 0, 0 };
- error = atapi_queue_cmd(cdp->atp, ccb, NULL, 0, 0, 10,
- NULL, NULL, NULL);
+ error = atapi_queue_cmd(cdp->atp, ccb, NULL, 0, 0, 10, NULL, NULL);
break;
}
@@ -752,8 +748,7 @@ acdioctl(dev_t dev, u_long cmd, caddr_t addr, int32_t flags, struct proc *p)
args->len>>8, args->len,
0, 0, 0, 0, 0, 0 };
- error = atapi_queue_cmd(cdp->atp, ccb, NULL, 0, 0, 10,
- NULL, NULL, NULL);
+ error = atapi_queue_cmd(cdp->atp, ccb, NULL, 0, 0, 10, NULL, NULL);
break;
}
@@ -793,8 +788,7 @@ acdioctl(dev_t dev, u_long cmd, caddr_t addr, int32_t flags, struct proc *p)
ccb[8] = len>>8;
ccb[9] = len;
- error = atapi_queue_cmd(cdp->atp, ccb, NULL, 0, 0, 10,
- NULL, NULL, NULL);
+ error = atapi_queue_cmd(cdp->atp, ccb, NULL, 0, 0, 10, NULL, NULL);
break;
}
@@ -850,7 +844,7 @@ acdioctl(dev_t dev, u_long cmd, caddr_t addr, int32_t flags, struct proc *p)
ccb[8] = blocks;
ccb[9] = 0xf0;
if ((error = atapi_queue_cmd(cdp->atp, ccb, buffer, size,
- ATPR_F_READ, 30, NULL, NULL,NULL)))
+ ATPR_F_READ, 30, NULL,NULL)))
break;
if ((error = copyout(buffer, ubuf, size)))
@@ -1087,13 +1081,14 @@ acdstrategy(struct buf *bp)
s = splbio();
bufqdisksort(&cdp->buf_queue, bp);
- acd_start(cdp);
+ ata_start(cdp->atp->controller);
splx(s);
}
-static void
-acd_start(struct acd_softc *cdp)
+void
+acd_start(struct atapi_softc *atp)
{
+ struct acd_softc *cdp = atp->driver;
struct buf *bp = bufq_first(&cdp->buf_queue);
u_int32_t lba, count;
int8_t ccb[16];
@@ -1112,16 +1107,7 @@ acd_start(struct acd_softc *cdp)
}
acd_select_slot(cdp);
-#ifdef NO_DVD_RAM_SUPPORT
- if (!(bp->b_flags & B_READ) &&
- (!(cdp->flags & F_DISK_OPEN) || !(cdp->flags & F_TRACK_OPEN))) {
- printf("acd%d: sequence error (no open)\n", cdp->lun);
- bp->b_error = EIO;
- bp->b_flags |= B_ERROR;
- biodone(bp);
- return;
- }
-#endif
+
bzero(ccb, sizeof(ccb));
count = (bp->b_bcount + (cdp->block_size - 1)) / cdp->block_size;
if (bp->b_flags & B_PHYS)
@@ -1143,7 +1129,7 @@ acd_start(struct acd_softc *cdp)
ccb[0] = ATAPI_READ_BIG;
else {
ccb[0] = ATAPI_READ_CD;
- ccb[9] = 0x10;
+ ccb[9] = 0xf8;
}
}
else
@@ -1160,7 +1146,7 @@ acd_start(struct acd_softc *cdp)
devstat_start_transaction(cdp->stats);
atapi_queue_cmd(cdp->atp, ccb, bp->b_data, count * cdp->block_size,
- bp->b_flags&B_READ ? ATPR_F_READ : 0, 30, acd_done, cdp,bp);
+ bp->b_flags&B_READ ? ATPR_F_READ : 0, 30, acd_done, bp);
}
static int32_t
@@ -1180,7 +1166,6 @@ acd_done(struct atapi_request *request)
}
devstat_end_transaction_buf(cdp->stats, bp);
biodone(bp);
- acd_start(cdp);
return 0;
}
@@ -1207,7 +1192,7 @@ acd_read_toc(struct acd_softc *cdp)
ccb[7] = len>>8;
ccb[8] = len;
if (atapi_queue_cmd(cdp->atp, ccb, &cdp->toc, len, ATPR_F_READ, 30,
- NULL, NULL, NULL)) {
+ NULL, NULL)) {
bzero(&cdp->toc, sizeof(cdp->toc));
return 0;
}
@@ -1223,7 +1208,7 @@ acd_read_toc(struct acd_softc *cdp)
ccb[7] = len>>8;
ccb[8] = len;
if (atapi_queue_cmd(cdp->atp, ccb, &cdp->toc, len, ATPR_F_READ, 30,
- NULL, NULL, NULL)) {
+ NULL, NULL)) {
bzero(&cdp->toc, sizeof(cdp->toc));
return 0;
}
@@ -1233,7 +1218,7 @@ acd_read_toc(struct acd_softc *cdp)
bzero(ccb, sizeof(ccb));
ccb[0] = ATAPI_READ_CAPACITY;
if (atapi_queue_cmd(cdp->atp, ccb, &cdp->info, sizeof(cdp->info),
- ATPR_F_READ, 30, NULL, NULL, NULL))
+ ATPR_F_READ, 30, NULL, NULL))
bzero(&cdp->info, sizeof(cdp->info));
cdp->info.volsize = ntohl(cdp->info.volsize);
@@ -1320,7 +1305,7 @@ acd_select_slot(struct acd_softc *cdp)
ccb[0] = ATAPI_LOAD_UNLOAD;
ccb[4] = 2;
ccb[8] = cdp->changer_info->current_slot;
- atapi_queue_cmd(cdp->atp, ccb, NULL, 0, 0, 30, NULL, NULL, NULL);
+ atapi_queue_cmd(cdp->atp, ccb, NULL, 0, 0, 30, NULL, NULL);
/* load the wanted slot */
bzero(ccb, sizeof(ccb));
@@ -1328,7 +1313,7 @@ acd_select_slot(struct acd_softc *cdp)
ccb[1] = 0x01;
ccb[4] = 3;
ccb[8] = cdp->slot;
- atapi_queue_cmd(cdp->atp, ccb, NULL, 0, 0, 10, NULL, NULL, NULL);
+ atapi_queue_cmd(cdp->atp, ccb, NULL, 0, 0, 10, NULL, NULL);
atapi_wait_ready(cdp->atp, 30);
cdp->changer_info->current_slot = cdp->slot;
@@ -1345,7 +1330,7 @@ acd_close_disk(struct acd_softc *cdp)
0, 0, 0, 0, 0, 0, 0, 0 };
int32_t error;
- error = atapi_queue_cmd(cdp->atp, ccb, NULL, 0, 0, 10, NULL, NULL, NULL);
+ error = atapi_queue_cmd(cdp->atp, ccb, NULL, 0, 0, 10, NULL, NULL);
if (error)
return error;
return atapi_wait_ready(cdp->atp, 10*60);
@@ -1438,7 +1423,7 @@ acd_close_track(struct acd_softc *cdp)
0, 0, 0, 0, 0, 0, 0, 0 };
int32_t error;
- error = atapi_queue_cmd(cdp->atp, ccb1, NULL, 0, 0, 10, NULL, NULL, NULL);
+ error = atapi_queue_cmd(cdp->atp, ccb1, NULL, 0, 0, 10, NULL, NULL);
if (error)
return error;
return atapi_wait_ready(cdp->atp, 5*60);
@@ -1456,7 +1441,7 @@ acd_read_track_info(struct acd_softc *cdp,
int32_t error;
if ((error = atapi_queue_cmd(cdp->atp, ccb, info, sizeof(*info),
- ATPR_F_READ, 30, NULL, NULL, NULL)))
+ ATPR_F_READ, 30, NULL, NULL)))
return error;
info->track_start_addr = ntohl(info->track_start_addr);
info->next_writeable_addr = ntohl(info->next_writeable_addr);
@@ -1515,7 +1500,7 @@ acd_report_key(struct acd_softc *cdp, struct dvd_authinfo *ai)
d.length = htons(length - 2);
error = atapi_queue_cmd(cdp->atp, ccb, &d, length,
ai->format == DVD_INVALIDATE_AGID ? 0 : ATPR_F_READ,
- 10, NULL, NULL, NULL);
+ 10, NULL, NULL);
if (error)
return error;
@@ -1596,7 +1581,7 @@ acd_send_key(struct acd_softc *cdp, struct dvd_authinfo *ai)
ccb[9] = length & 0xff;
ccb[10] = (ai->agid << 6) | ai->format;
d.length = htons(length - 2);
- return atapi_queue_cmd(cdp->atp, ccb, &d, length, 0, 10, NULL, NULL, NULL);
+ return atapi_queue_cmd(cdp->atp, ccb, &d, length, 0, 10, NULL, NULL);
}
static int
@@ -1657,7 +1642,7 @@ acd_read_structure(struct acd_softc *cdp, struct dvd_struct *s)
ccb[10] = s->agid << 6;
d.length = htons(length - 2);
error = atapi_queue_cmd(cdp->atp, ccb, &d, length, ATPR_F_READ, 30,
- NULL, NULL, NULL);
+ NULL, NULL);
if (error)
return error;
@@ -1740,7 +1725,7 @@ acd_blank(struct acd_softc *cdp)
0, 0, 0, 0, 0, 0, 0, 0 };
int32_t error;
- error = atapi_queue_cmd(cdp->atp, ccb, NULL, 0, 0, 60*60, NULL, NULL, NULL);
+ error = atapi_queue_cmd(cdp->atp, ccb, NULL, 0, 0, 60*60, NULL, NULL);
cdp->flags &= ~(F_WRITTEN | F_DISK_OPEN | F_TRACK_OPEN);
cdp->atp->flags |= ATAPI_F_MEDIA_CHANGED;
return error;
@@ -1752,7 +1737,7 @@ acd_prevent_allow(struct acd_softc *cdp, int32_t lock)
int8_t ccb[16] = { ATAPI_PREVENT_ALLOW, 0, 0, 0, lock,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
- return atapi_queue_cmd(cdp->atp, ccb, NULL, 0, 0, 30, NULL, NULL, NULL);
+ return atapi_queue_cmd(cdp->atp, ccb, NULL, 0, 0, 30, NULL, NULL);
}
static int32_t
@@ -1761,7 +1746,7 @@ acd_start_stop(struct acd_softc *cdp, int32_t start)
int8_t ccb[16] = { ATAPI_START_STOP, 0, 0, 0, start,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
- return atapi_queue_cmd(cdp->atp, ccb, NULL, 0, 0, 30, NULL, NULL, NULL);
+ return atapi_queue_cmd(cdp->atp, ccb, NULL, 0, 0, 30, NULL, NULL);
}
static int32_t
@@ -1770,7 +1755,7 @@ acd_pause_resume(struct acd_softc *cdp, int32_t pause)
int8_t ccb[16] = { ATAPI_PAUSE, 0, 0, 0, 0, 0, 0, 0, pause,
0, 0, 0, 0, 0, 0, 0 };
- return atapi_queue_cmd(cdp->atp, ccb, NULL, 0, 0, 30, NULL, NULL, NULL);
+ return atapi_queue_cmd(cdp->atp, ccb, NULL, 0, 0, 30, NULL, NULL);
}
static int32_t
@@ -1782,7 +1767,7 @@ acd_mode_sense(struct acd_softc *cdp, u_int8_t page,
int32_t error;
error = atapi_queue_cmd(cdp->atp, ccb, pagebuf, pagesize, ATPR_F_READ, 10,
- NULL, NULL, NULL);
+ NULL, NULL);
#ifdef ACD_DEBUG
atapi_dump("acd: mode sense ", pagebuf, pagesize);
#endif
@@ -1799,8 +1784,7 @@ acd_mode_select(struct acd_softc *cdp, void *pagebuf, int32_t pagesize)
printf("acd: modeselect pagesize=%d\n", pagesize);
atapi_dump("acd: mode select ", pagebuf, pagesize);
#endif
- return atapi_queue_cmd(cdp->atp, ccb, pagebuf, pagesize, 0, 30,
- NULL, NULL, NULL);
+ return atapi_queue_cmd(cdp->atp, ccb, pagebuf, pagesize, 0, 30, NULL, NULL);
}
static int32_t
@@ -1809,5 +1793,5 @@ acd_set_speed(struct acd_softc *cdp, int32_t speed)
int8_t ccb[16] = { ATAPI_SET_SPEED, 0, 0xff, 0xff, speed>>8, speed,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
- return atapi_queue_cmd(cdp->atp, ccb, NULL, 0, 0, 30, NULL, NULL, NULL);
+ return atapi_queue_cmd(cdp->atp, ccb, NULL, 0, 0, 30, NULL, NULL);
}
diff --git a/sys/dev/ata/atapi-fd.c b/sys/dev/ata/atapi-fd.c
index 3683854335020..a27147b78b0d2 100644
--- a/sys/dev/ata/atapi-fd.c
+++ b/sys/dev/ata/atapi-fd.c
@@ -67,11 +67,8 @@ static struct cdevsw afd_cdevsw = {
static struct cdevsw afddisk_cdevsw;
/* prototypes */
-int32_t afdattach(struct atapi_softc *);
-void afddetach(struct atapi_softc *);
static int32_t afd_sense(struct afd_softc *);
static void afd_describe(struct afd_softc *);
-static void afd_start(struct afd_softc *);
static int32_t afd_partial_done(struct atapi_request *);
static int32_t afd_done(struct atapi_request *);
static int32_t afd_eject(struct afd_softc *, int32_t);
@@ -149,7 +146,7 @@ afd_sense(struct afd_softc *fdp)
/* get drive capabilities, some drives needs this repeated */
for (count = 0 ; count < 5 ; count++) {
if (!(error = atapi_queue_cmd(fdp->atp, ccb, buffer, sizeof(buffer),
- ATPR_F_READ, 30, NULL, NULL, NULL)))
+ ATPR_F_READ, 30, NULL, NULL)))
break;
}
if (error)
@@ -290,14 +287,15 @@ afdstrategy(struct buf *bp)
}
s = splbio();
- bufq_insert_tail(&fdp->buf_queue, bp);
- afd_start(fdp);
+ bufqdisksort(&fdp->buf_queue, bp);
+ ata_start(fdp->atp->controller);
splx(s);
}
-static void
-afd_start(struct afd_softc *fdp)
+void
+afd_start(struct atapi_softc *atp)
{
+ struct afd_softc *fdp = atp->driver;
struct buf *bp = bufq_first(&fdp->buf_queue);
u_int32_t lba, count;
int8_t ccb[16];
@@ -341,7 +339,7 @@ afd_start(struct afd_softc *fdp)
atapi_queue_cmd(fdp->atp, ccb, data_ptr,
fdp->transfersize * fdp->cap.sector_size,
(bp->b_flags & B_READ) ? ATPR_F_READ : 0, 30,
- afd_partial_done, fdp, bp);
+ afd_partial_done, bp);
count -= fdp->transfersize;
lba += fdp->transfersize;
@@ -356,7 +354,7 @@ afd_start(struct afd_softc *fdp)
ccb[8] = count;
atapi_queue_cmd(fdp->atp, ccb, data_ptr, count * fdp->cap.sector_size,
- bp->b_flags&B_READ ? ATPR_F_READ : 0, 30, afd_done, fdp,bp);
+ bp->b_flags&B_READ ? ATPR_F_READ : 0, 30, afd_done, bp);
}
static int32_t
@@ -386,7 +384,6 @@ afd_done(struct atapi_request *request)
bp->b_resid += (bp->b_bcount - request->donecount);
devstat_end_transaction_buf(&fdp->stats, bp);
biodone(bp);
- afd_start(fdp);
return 0;
}
@@ -419,7 +416,7 @@ afd_start_stop(struct afd_softc *fdp, int32_t start)
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
int32_t error;
- error = atapi_queue_cmd(fdp->atp, ccb, NULL, 0, 0, 10, NULL, NULL, NULL);
+ error = atapi_queue_cmd(fdp->atp, ccb, NULL, 0, 0, 10, NULL, NULL);
if (error)
return error;
return atapi_wait_ready(fdp->atp, 30);
@@ -431,5 +428,5 @@ afd_prevent_allow(struct afd_softc *fdp, int32_t lock)
int8_t ccb[16] = { ATAPI_PREVENT_ALLOW, 0, 0, 0, lock,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
- return atapi_queue_cmd(fdp->atp, ccb, NULL, 0, 0,30, NULL, NULL, NULL);
+ return atapi_queue_cmd(fdp->atp, ccb, NULL, 0, 0,30, NULL, NULL);
}
diff --git a/sys/dev/ata/atapi-tape.c b/sys/dev/ata/atapi-tape.c
index e3abcf0e2cdad..53b546e4f26ba 100644
--- a/sys/dev/ata/atapi-tape.c
+++ b/sys/dev/ata/atapi-tape.c
@@ -65,11 +65,8 @@ static struct cdevsw ast_cdevsw = {
};
/* prototypes */
-int32_t astattach(struct atapi_softc *);
-void astdetach(struct atapi_softc *);
static int32_t ast_sense(struct ast_softc *);
static void ast_describe(struct ast_softc *);
-static void ast_start(struct ast_softc *);
static int32_t ast_done(struct atapi_request *);
static int32_t ast_mode_sense(struct ast_softc *, u_int8_t, void *, int32_t);
static int32_t ast_mode_select(struct ast_softc *, void *, int32_t);
@@ -452,13 +449,14 @@ aststrategy(struct buf *bp)
s = splbio();
bufq_insert_tail(&stp->buf_queue, bp);
- ast_start(stp);
+ ata_start(stp->atp->controller);
splx(s);
}
-static void
-ast_start(struct ast_softc *stp)
+void
+ast_start(struct atapi_softc *atp)
{
+ struct ast_softc *stp = atp->driver;
struct buf *bp = bufq_first(&stp->buf_queue);
u_int32_t blkcount;
int8_t ccb[16];
@@ -471,12 +469,12 @@ ast_start(struct ast_softc *stp)
if (bp->b_flags & B_READ) {
ccb[0] = ATAPI_READ;
if (!(stp->flags & ATAPI_F_DSC_USED))
- atapi_queue_cmd(stp->atp, ccb, NULL, 0, 0, 2*60, NULL, NULL, NULL);
+ atapi_queue_cmd(stp->atp, ccb, NULL, 0, 0, 2*60, NULL, NULL);
}
else {
ccb[0] = ATAPI_WRITE;
if (!(stp->flags & ATAPI_F_DSC_USED))
- atapi_queue_cmd(stp->atp, ccb, NULL, 0, 0, 2*60, NULL, NULL, NULL);
+ atapi_queue_cmd(stp->atp, ccb, NULL, 0, 0, 2*60, NULL, NULL);
}
bufq_remove(&stp->buf_queue, bp);
@@ -490,7 +488,7 @@ ast_start(struct ast_softc *stp)
devstat_start_transaction(&stp->stats);
atapi_queue_cmd(stp->atp, ccb, bp->b_data, blkcount * stp->blksize,
- bp->b_flags&B_READ ? ATPR_F_READ : 0, 60, ast_done, stp,bp);
+ bp->b_flags&B_READ ? ATPR_F_READ : 0, 60, ast_done, bp);
}
static int32_t
@@ -511,7 +509,6 @@ ast_done(struct atapi_request *request)
}
devstat_end_transaction_buf(&stp->stats, bp);
biodone(bp);
- ast_start(stp);
return 0;
}
@@ -524,7 +521,7 @@ ast_mode_sense(struct ast_softc *stp, u_int8_t page,
int32_t error;
error = atapi_queue_cmd(stp->atp, ccb, pagebuf, pagesize, ATPR_F_READ, 10,
- NULL, NULL, NULL);
+ NULL, NULL);
#ifdef AST_DEBUG
atapi_dump("ast: mode sense ", pagebuf, pagesize);
#endif
@@ -542,7 +539,7 @@ ast_mode_select(struct ast_softc *stp, void *pagebuf, int32_t pagesize)
atapi_dump("ast: mode select ", pagebuf, pagesize);
#endif
return atapi_queue_cmd(stp->atp, ccb, pagebuf, pagesize, 0, 10,
- NULL, NULL, NULL);
+ NULL, NULL);
}
static int32_t
@@ -562,7 +559,7 @@ ast_write_filemark(struct ast_softc *stp, u_int8_t function)
stp->flags |= F_FM_WRITTEN;
}
}
- error = atapi_queue_cmd(stp->atp, ccb, NULL, 0, 0, 10, NULL, NULL, NULL);
+ error = atapi_queue_cmd(stp->atp, ccb, NULL, 0, 0, 10, NULL, NULL);
if (error)
return error;
return atapi_wait_ready(stp->atp, 10*60);
@@ -578,7 +575,7 @@ ast_read_position(struct ast_softc *stp, int32_t hard,
error = atapi_queue_cmd(stp->atp, ccb, position,
sizeof(struct ast_readposition), ATPR_F_READ, 10,
- NULL, NULL, NULL);
+ NULL, NULL);
position->tape = ntohl(position->tape);
position->host = ntohl(position->host);
return error;
@@ -590,7 +587,7 @@ ast_space(struct ast_softc *stp, u_int8_t function, u_int32_t count)
int8_t ccb[16] = { ATAPI_SPACE, function, count>>16, count>>8, count,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
- return atapi_queue_cmd(stp->atp, ccb, NULL, 0, 0, 60*60, NULL, NULL, NULL);
+ return atapi_queue_cmd(stp->atp, ccb, NULL, 0, 0, 60*60, NULL, NULL);
}
static int32_t
@@ -601,7 +598,7 @@ ast_locate(struct ast_softc *stp, int32_t hard, int32_t pos)
0, 0, 0, 0, 0, 0, 0, 0, 0 };
int32_t error;
- error = atapi_queue_cmd(stp->atp, ccb, NULL, 0, 0, 10, NULL, NULL, NULL);
+ error = atapi_queue_cmd(stp->atp, ccb, NULL, 0, 0, 10, NULL, NULL);
if (error)
return error;
return atapi_wait_ready(stp->atp, 60*60);
@@ -613,7 +610,7 @@ ast_prevent_allow(struct ast_softc *stp, int32_t lock)
int8_t ccb[16] = { ATAPI_PREVENT_ALLOW, 0, 0, 0, lock,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
- return atapi_queue_cmd(stp->atp, ccb, NULL, 0, 0,30, NULL, NULL, NULL);
+ return atapi_queue_cmd(stp->atp, ccb, NULL, 0, 0,30, NULL, NULL);
}
static int32_t
@@ -625,7 +622,7 @@ ast_load_unload(struct ast_softc *stp, u_int8_t function)
if ((function & SS_EJECT) && !stp->cap.eject)
return 0;
- error = atapi_queue_cmd(stp->atp, ccb, NULL, 0, 0, 10, NULL, NULL, NULL);
+ error = atapi_queue_cmd(stp->atp, ccb, NULL, 0, 0, 10, NULL, NULL);
if (error)
return error;
tsleep((caddr_t)&error, PRIBIO, "astlu", 1 * hz);
@@ -641,7 +638,7 @@ ast_rewind(struct ast_softc *stp)
0, 0, 0, 0, 0, 0, 0, 0 };
int32_t error;
- error = atapi_queue_cmd(stp->atp, ccb, NULL, 0, 0, 10, NULL, NULL, NULL);
+ error = atapi_queue_cmd(stp->atp, ccb, NULL, 0, 0, 10, NULL, NULL);
if (error)
return error;
return atapi_wait_ready(stp->atp, 60*60);
@@ -657,5 +654,5 @@ ast_erase(struct ast_softc *stp)
if ((error = ast_rewind(stp)))
return error;
- return atapi_queue_cmd(stp->atp, ccb, NULL, 0, 0, 60*60, NULL, NULL, NULL);
+ return atapi_queue_cmd(stp->atp, ccb, NULL, 0, 0, 60*60, NULL, NULL);
}