Support quad & max speeds in wormcontrol.

A bit more general cleanup.
This commit is contained in:
sos 1999-09-22 12:04:51 +00:00
parent 5add57d3e7
commit 804f068c6a
12 changed files with 51 additions and 98 deletions

View File

@ -48,10 +48,10 @@ trlld.o optional oltr \
contrib/dev/oltr/trlldbm.c optional oltr
contrib/dev/oltr/trlldhm.c optional oltr
contrib/dev/oltr/trlldmac.c optional oltr
dev/ata/ata-all.c optional ata
dev/ata/ata-all.c optional ata atadisk atapicd atapifd atapist
dev/ata/ata-dma.c optional ata atadisk atapicd atapifd atapist
dev/ata/atapi-all.c optional atapicd atapifd atapist
dev/ata/ata-disk.c optional atadisk
dev/ata/ata-dma.c optional ata
dev/ata/atapi-all.c optional ata
dev/ata/atapi-cd.c optional atapicd
dev/ata/atapi-fd.c optional atapifd
dev/ata/atapi-tape.c optional atapist

View File

@ -30,9 +30,6 @@
#include "ata.h"
#include "apm.h"
#if NATA > 0
#include "isa.h"
#include "pci.h"
#include "atadisk.h"
@ -870,4 +867,3 @@ bpack(int8_t *src, int8_t *dst, int32_t len)
}
dst[j] = 0x00;
}
#endif /* NATA > 0 */

View File

@ -28,12 +28,7 @@
* $FreeBSD$
*/
#include "ata.h"
#include "atadisk.h"
#include "apm.h"
#if NATA > 0 && NATADISK > 0
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/kernel.h>
@ -282,6 +277,7 @@ adopen(dev_t dev, int32_t flags, int32_t fmt, struct proc *p)
printf("adopen: lun=%d adnlun=%d\n", adp->lun, adnlun);
#endif
dev->si_iosize_max = 256 * DEV_BSIZE;
dl = &adp->disk.d_label;
bzero(dl, sizeof *dl);
dl->d_secsize = DEV_BSIZE;
@ -660,8 +656,6 @@ ad_version(u_int16_t version)
static void
ad_drvinit(void)
{
if (!ad_cdevsw.d_maxio)
ad_cdevsw.d_maxio = 256 * DEV_BSIZE;
fakewd_cdevsw = ad_cdevsw;
fakewd_cdevsw.d_maj = 3;
fakewd_cdevsw.d_bmaj = 0;
@ -684,4 +678,3 @@ ad_drvinit(void)
}
SYSINIT(addev, SI_SUB_DRIVERS, SI_ORDER_SECOND, ad_drvinit, NULL)
#endif /* NATA && NATADISK */

View File

@ -28,12 +28,8 @@
* $FreeBSD$
*/
#include "ata.h"
#include "pci.h"
#include "apm.h"
#if NATA > 0
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/kernel.h>
@ -282,7 +278,13 @@ ata_dmainit(struct ata_softc *scp, int32_t device,
}
break;
default: /* well, we have no support for this, but try anyways */
default: /* unknown controller chip */
/* better not try generic DMA on ATAPI devices it almost never works */
if ((device == ATA_MASTER && scp->devices & ATA_ATAPI_MASTER) ||
(device == ATA_SLAVE && scp->devices & ATA_ATAPI_SLAVE))
break;
/* well, we have no support for this, but try anyways */
if (((wdmamode >= 2 && apiomode >= 4) || udmamode >= 2) &&
(inb(scp->bmaddr + ATA_BMSTAT_PORT) &
((device == ATA_MASTER) ?
@ -426,4 +428,3 @@ ata_dmastatus(struct ata_softc *scp, int32_t device)
}
#endif /* NPCI > 0 */
#endif /* NATA > 0 */

View File

@ -28,14 +28,10 @@
* $FreeBSD$
*/
#include "ata.h"
#include "apm.h"
#include "atapicd.h"
#include "atapist.h"
#include "atapifd.h"
#include "apm.h"
#if NATA > 0 && (NATAPICD > 0 || NATAPIFD > 0 || NATAPIST > 0)
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/kernel.h>
@ -780,4 +776,3 @@ atapi_init(void)
}
SYSINIT(atconf, SI_SUB_CONFIGURE, SI_ORDER_SECOND, atapi_init, NULL)
#endif /* NATA > 0 && (NATAPICD > 0 || NATAPIFD > 0 || NATAPIST > 0) */

View File

@ -101,6 +101,7 @@
#define ATAPI_PLAY_BIG 0xa5 /* play by lba */
#define ATAPI_LOAD_UNLOAD 0xa6 /* changer control command */
#define ATAPI_PLAY_CD 0xb4 /* universal play command */
#define ATAPI_SET_SPEED 0xbb /* set drive speed */
#define ATAPI_MECH_STATUS 0xbd /* get changer status */
#define ATAPI_READ_CD 0xbe /* read data */

View File

@ -28,12 +28,7 @@
* $FreeBSD$
*/
#include "ata.h"
#include "atapicd.h"
#include "apm.h"
#if NATA > 0 && NATAPICD > 0
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/kernel.h>
@ -87,7 +82,7 @@ static struct cdevsw acd_cdevsw = {
/* prototypes */
int32_t acdattach(struct atapi_softc *);
static struct acd_softc *acd_init_lun(struct atapi_softc *, int, struct devstat *);
static struct acd_softc *acd_init_lun(struct atapi_softc *, int32_t, struct devstat *);
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);
@ -96,19 +91,19 @@ static void acd_done(struct atapi_request *);
static int32_t acd_read_toc(struct acd_softc *);
static int32_t acd_setchan(struct acd_softc *, u_int8_t, u_int8_t, u_int8_t, u_int8_t);
static void acd_select_slot(struct acd_softc *);
static int32_t acd_open_disk(struct acd_softc *, int);
static int32_t acd_open_disk(struct acd_softc *, int32_t);
static int32_t acd_open_track(struct acd_softc *, struct wormio_prepare_track *);
static int32_t acd_close_track(struct acd_softc *);
static int32_t acd_close_disk(struct acd_softc *);
static int32_t acd_read_track_info(struct acd_softc *, int, struct acd_track_info*);
static int32_t acd_eject(struct acd_softc *, int);
static int32_t acd_read_track_info(struct acd_softc *, int32_t, struct acd_track_info*);
static int32_t acd_eject(struct acd_softc *, int32_t);
static int32_t acd_blank(struct acd_softc *);
static int32_t acd_prevent_allow(struct acd_softc *, int32_t);
static int32_t acd_start_stop(struct acd_softc *, int32_t);
static int32_t acd_pause_resume(struct acd_softc *, int32_t);
static int32_t acd_mode_sense(struct acd_softc *, u_int8_t, void *, int32_t);
static int32_t acd_mode_select(struct acd_softc *, void *, int32_t);
static void acd_drvinit(void *);
static int32_t acd_set_speed(struct acd_softc *cdp, int32_t);
/* internal vars */
static int32_t acdnlun = 0; /* number of configured drives */
@ -119,7 +114,12 @@ acdattach(struct atapi_softc *atp)
struct acd_softc *cdp;
struct changer *chp;
int32_t error, count;
static int once;
if (!once) {
cdevsw_add(&acd_cdevsw);
once++;
}
if (acdnlun >= NUNIT) {
printf("acd: too many units\n");
return -1;
@ -439,11 +439,12 @@ acdopen(dev_t dev, int32_t flags, int32_t fmt, struct proc *p)
}
dev->si_bsize_phys = 2048; /* XXX SOS */
dev->si_iosize_max = 254 * DEV_BSIZE;
if (!(cdp->flags & F_BOPEN) && !cdp->refcnt) {
acd_prevent_allow(cdp, 1); /* prevent user eject */
acd_prevent_allow(cdp, 1);
cdp->flags |= F_LOCKED;
if (!(flags & O_NONBLOCK) && acd_read_toc(cdp) && !(flags & FWRITE))
printf("acd%d: read_toc failed\n", cdp->lun);
if (!(flags & O_NONBLOCK) && !(flags & FWRITE))
acd_read_toc(cdp);
}
if (fmt == S_IFBLK)
cdp->flags |= F_BOPEN;
@ -938,8 +939,9 @@ acdioctl(dev_t dev, u_long cmd, caddr_t addr, int32_t flag, struct proc *p)
if (error == 0) {
cdp->flags |= F_DISK_PREPED;
cdp->dummy = w->dummy;
cdp->speed = w->speed;
}
/* set speed in KB/s (approximate) */
acd_set_speed(cdp, w->speed * 173);
}
break;
}
@ -1407,9 +1409,7 @@ acd_eject(struct acd_softc *cdp, int32_t close)
int32_t error;
acd_select_slot(cdp);
error = acd_start_stop(cdp, 0);
if (((cdp->atp->controller->error&ATAPI_SK_MASK)==ATAPI_SK_NOT_READY) ||
((cdp->atp->controller->error&ATAPI_SK_MASK)==ATAPI_SK_UNIT_ATTENTION)){
if ((error = acd_start_stop(cdp, 0)) == EBUSY) {
if (!close)
return 0;
if ((error = acd_start_stop(cdp, 3)))
@ -1423,9 +1423,6 @@ acd_eject(struct acd_softc *cdp, int32_t close)
return error;
if (close)
return 0;
tsleep((caddr_t) &lbolt, PRIBIO, "acdej1", 0);
tsleep((caddr_t) &lbolt, PRIBIO, "acdej2", 0);
acd_prevent_allow(cdp, 0);
cdp->flags &= ~F_LOCKED;
cdp->flags &= ~(F_WRITTEN|F_TRACK_PREP|F_TRACK_PREPED);
@ -1502,18 +1499,12 @@ acd_mode_select(struct acd_softc *cdp, void *pagebuf, int32_t pagesize)
pagebuf, pagesize, 0, 30));
}
static void
acd_drvinit(void *unused)
static int32_t
acd_set_speed(struct acd_softc *cdp, int32_t speed)
{
static int32_t acd_devsw_installed = 0;
int8_t ccb[16] = { ATAPI_SET_SPEED, 0, 0xff, 0xff, speed>>8, speed,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
if (!acd_devsw_installed) {
if (!acd_cdevsw.d_maxio)
acd_cdevsw.d_maxio = 254 * DEV_BSIZE;
cdevsw_add(&acd_cdevsw);
acd_devsw_installed = 1;
}
return atapi_error(cdp->atp, atapi_immed_cmd(cdp->atp, ccb, NULL, 0, 0,30));
}
SYSINIT(acddev, SI_SUB_DRIVERS, SI_ORDER_MIDDLE, acd_drvinit, NULL)
#endif /* NATA && NATAPICD */

View File

@ -344,7 +344,6 @@ struct acd_softc {
int32_t slot; /* this lun's slot number */
u_int32_t block_size; /* blocksize currently used */
u_int8_t dummy; /* use dummy writes */
u_int8_t speed; /* select drive speed */
u_int32_t next_writeable_addr; /* next writable address */
struct wormio_prepare_track preptrack; /* scratch region */
struct devstat *stats; /* devstat entry */

View File

@ -28,12 +28,7 @@
* $FreeBSD$
*/
#include "ata.h"
#include "atapifd.h"
#include "apm.h"
#if NATA > 0 && NATAPIFD > 0
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/kernel.h>
@ -103,9 +98,6 @@ afdattach(struct atapi_softc *atp)
struct afd_softc *fdp;
dev_t dev;
if (!afd_cdevsw.d_maxio)
afd_cdevsw.d_maxio = 254 * DEV_BSIZE;
fdp = malloc(sizeof(struct afd_softc), M_TEMP, M_NOWAIT);
if (!fdp) {
printf("afd: out of memory\n");
@ -219,6 +211,8 @@ afdopen(dev_t dev, int32_t flags, int32_t fmt, struct proc *p)
struct afd_softc *fdp = dev->si_drv1;
struct disklabel *label;
dev->si_iosize_max = 254 * DEV_BSIZE;
fdp->atp->flags &= ~ATAPI_F_MEDIA_CHANGED;
afd_prevent_allow(fdp, 1);
if (afd_sense(fdp))
@ -377,9 +371,7 @@ afd_eject(struct afd_softc *fdp, int32_t close)
{
int32_t error;
error = afd_start_stop(fdp, 0);
if (((fdp->atp->controller->error&ATAPI_SK_MASK)==ATAPI_SK_NOT_READY) ||
((fdp->atp->controller->error&ATAPI_SK_MASK)==ATAPI_SK_UNIT_ATTENTION)){
if ((error = afd_start_stop(fdp, 0)) == EBUSY) {
if (!close)
return 0;
if ((error = afd_start_stop(fdp, 3)))
@ -390,8 +382,6 @@ afd_eject(struct afd_softc *fdp, int32_t close)
return error;
if (close)
return 0;
tsleep((caddr_t) &lbolt, PRIBIO, "afdej1", 0);
tsleep((caddr_t) &lbolt, PRIBIO, "afdej2", 0);
if ((error = afd_prevent_allow(fdp, 0)))
return error;
fdp->atp->flags |= ATAPI_F_MEDIA_CHANGED;
@ -419,4 +409,3 @@ afd_prevent_allow(struct afd_softc *fdp, int32_t lock)
return atapi_error(fdp->atp, atapi_immed_cmd(fdp->atp, ccb, NULL, 0, 0,30));
}
#endif /* NATA & NATAPIFD */

View File

@ -28,12 +28,7 @@
* $FreeBSD$
*/
#include "ata.h"
#include "atapist.h"
#include "apm.h"
#if NATA > 0 && NATAPIST > 0
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/kernel.h>
@ -98,10 +93,10 @@ static int32_t ast_prevent_allow(struct ast_softc *stp, int32_t lock);
static int32_t ast_load_unload(struct ast_softc *, u_int8_t);
static int32_t ast_rewind(struct ast_softc *);
static int32_t ast_erase(struct ast_softc *);
static void ast_drvinit(void *);
/* internal vars */
static int32_t astnlun = 0; /* number of config'd drives */
static int ast_cdev_done = 0;
static u_int64_t ast_total = 0;
static int32_t ast_buffermode = 0;
@ -112,6 +107,10 @@ astattach(struct atapi_softc *atp)
struct ast_readposition position;
dev_t dev;
if (!ast_cdev_done) {
cdevsw_add(&ast_cdevsw);
ast_cdev_done = 1;
}
if (astnlun >= NUNIT) {
printf("ast: too many units\n");
return -1;
@ -247,6 +246,7 @@ astopen(dev_t dev, int32_t flags, int32_t fmt, struct proc *p)
if (ast_sense(stp))
printf("ast%d: sense media type failed\n", stp->lun);
dev->si_iosize_max = 254 * DEV_BSIZE;
stp->flags &= ~(F_DATA_WRITTEN | F_FM_WRITTEN);
stp->flags |= F_OPEN;
stp->atp->flags &= ~ATAPI_F_MEDIA_CHANGED;
@ -653,19 +653,3 @@ ast_erase(struct ast_softc *stp)
return atapi_error(stp->atp,
atapi_immed_cmd(stp->atp, ccb, NULL, 0, 0, 60*60));
}
static void
ast_drvinit(void *unused)
{
static int32_t ast_devsw_installed = 0;
if (!ast_devsw_installed) {
if (!ast_cdevsw.d_maxio)
ast_cdevsw.d_maxio = 254 * DEV_BSIZE;
cdevsw_add(&ast_cdevsw);
ast_devsw_installed = 1;
}
}
SYSINIT(astdev, SI_SUB_DRIVERS, SI_ORDER_MIDDLE, ast_drvinit, NULL)
#endif /* NATA & NATAPIST */

View File

@ -48,10 +48,10 @@ trlld.o optional oltr \
contrib/dev/oltr/trlldbm.c optional oltr
contrib/dev/oltr/trlldhm.c optional oltr
contrib/dev/oltr/trlldmac.c optional oltr
dev/ata/ata-all.c optional ata
dev/ata/ata-all.c optional ata atadisk atapicd atapifd atapist
dev/ata/ata-dma.c optional ata atadisk atapicd atapifd atapist
dev/ata/atapi-all.c optional atapicd atapifd atapist
dev/ata/ata-disk.c optional atadisk
dev/ata/ata-dma.c optional ata
dev/ata/atapi-all.c optional ata
dev/ata/atapi-cd.c optional atapicd
dev/ata/atapi-fd.c optional atapifd
dev/ata/atapi-tape.c optional atapist

View File

@ -96,6 +96,10 @@ main(int argc, char **argv)
d.speed = 1;
else if (eq(argv[i], "double"))
d.speed = 2;
else if (eq(argv[i], "quad"))
d.speed = 4;
else if (eq(argv[i], "max"))
d.speed = 99;
else
errx(EX_USAGE,
"wrong param for \"prepdisk\": %s",