-/* $NetBSD: disksubr.c,v 1.3 1995/04/22 12:43:22 cgd Exp $ */
+/* $NetBSD: disksubr.c,v 1.4 1996/01/07 22:01:38 thorpej Exp $ */
/*
* Copyright (c) 1994, 1995 Carnegie-Mellon University.
/* was this the boot device ? */
int
dk_establish(dk, dev)
- struct dkdevice *dk;
+ struct disk *dk;
struct device *dev;
{
#ifdef NOTDEF
-/* $NetBSD: disksubr.c,v 1.20 1995/09/29 13:51:33 chopps Exp $ */
+/* $NetBSD: disksubr.c,v 1.21 1996/01/07 22:01:44 thorpej Exp $ */
/*
* Copyright (c) 1994 Christian E. Hopps
/* XXX unknown function but needed for /sys/scsi to link */
int
dk_establish(dk, dev)
- struct dkdevice *dk;
+ struct disk *dk;
struct device *dev;
{
return(-1);
-/* $NetBSD: swapgeneric.c,v 1.19 1995/04/19 13:02:57 chopps Exp $ */
+/* $NetBSD: swapgeneric.c,v 1.20 1996/01/07 22:01:46 thorpej Exp $ */
/*
* Copyright (c) 1982, 1986 Regents of the University of California.
setconf()
{
- struct dkdevice *dkp;
+ struct disk *dkp;
+ struct device **devpp;
struct partition *pp;
struct genericconf *gc;
struct bdevsw *bdp;
unit &= 0x7;
goto found;
}
+
for (gc = genericconf; gc->gc_driver; gc++) {
for (unit = gc->gc_driver->cd_ndevs - 1; unit >= 0; unit--) {
if (gc->gc_driver->cd_devs[unit] == NULL)
continue;
+
/*
- * this is a hack these drivers should use
- * dk_dev and not another instance directly above.
+ * Find the disk corresponding to the current
+ * device.
*/
- dkp = (struct dkdevice *)
- ((struct device *)gc->gc_driver->cd_devs[unit] + 1);
+ devpp = (struct device **)gc->gc_driver->cd_devs;
+ if ((dkp = disk_find(devpp[unit]->dv_xname)) == NULL)
+ continue;
+
if (dkp->dk_driver == NULL ||
dkp->dk_driver->d_strategy == NULL)
continue;
continue;
bdp->d_close(MAKEDISKDEV(major(gc->gc_root), unit,
0), FREAD | FNONBLOCK, 0, curproc);
- pp = &dkp->dk_label.d_partitions[0];
+ pp = &dkp->dk_label->d_partitions[0];
if (pp->p_size == 0 || pp->p_fstype != FS_BSDFFS)
continue;
goto found;
-/* $NetBSD: fd.c,v 1.21 1995/08/12 20:30:45 mycroft Exp $ */
+/* $NetBSD: fd.c,v 1.22 1996/01/07 22:01:50 thorpej Exp $ */
/*
* Copyright (c) 1994 Christian E. Hopps
* floppy disk device data
*/
struct fd_softc {
- struct dkdevice dkdev;
+ struct device sc_dv; /* generic device info; must come first */
+ struct disk dkdev; /* generic disk info */
struct buf bufq; /* queue of buf's */
struct fdtype *type;
void *cachep; /* cached track data (write through) */
sc->hwunit = ap->unit;
sc->unitmask = 1 << (3 + ap->unit);
sc->retries = FDRETRIES;
- sc->dkdev.dk_driver = &fddkdriver;
sc->stepdelay = FDSTEPDELAY;
printf(": %s %d cyl, %d head, %d sec [%d sec], 512 bytes/sec\n",
sc->type->desc, sc->type->ncylinders, FDNHEADS,
sc->type->amiga_nsectors, sc->type->msdos_nsectors);
+ /*
+ * Initialize and attach the disk structure.
+ */
+ sc->dkdev.dk_name = sc->sc_dv.dv_xname;
+ sc->dkdev.dk_driver = &fddkdriver;
+ disk_attach(&sc->dkdev);
+
/*
* calibrate the drive
*/
case DIOCSSTEP:
if (*(int *)addr < FDSTEPDELAY)
return(EINVAL);
- sc->dkdev.dk_label.d_trkseek = sc->stepdelay = *(int *)addr;
+ sc->dkdev.dk_label->d_trkseek = sc->stepdelay = *(int *)addr;
return(0);
case DIOCGDINFO:
- *(struct disklabel *)addr = sc->dkdev.dk_label;
+ *(struct disklabel *)addr = *(sc->dkdev.dk_label);
return(0);
case DIOCGPART:
- ((struct partinfo *)addr)->disklab = &sc->dkdev.dk_label;
+ ((struct partinfo *)addr)->disklab = sc->dkdev.dk_label;
((struct partinfo *)addr)->part =
- &sc->dkdev.dk_label.d_partitions[FDPART(dev)];
+ &sc->dkdev.dk_label->d_partitions[FDPART(dev)];
return(0);
case DIOCSDINFO:
if ((flag & FWRITE) == 0)
/*
* check for valid partition and bounds
*/
- lp = &sc->dkdev.dk_label;
+ lp = sc->dkdev.dk_label;
if ((sc->flags & FDF_HAVELABEL) == 0) {
bp->b_error = EIO;
goto bad;
printf("fdgetdisklabel()\n");
#endif
part = FDPART(dev);
- lp = &sc->dkdev.dk_label;
- clp = &sc->dkdev.dk_cpulabel;
+ lp = sc->dkdev.dk_label;
+ clp = sc->dkdev.dk_cpulabel;
bzero(lp, sizeof(struct disklabel));
bzero(clp, sizeof(struct cpu_disklabel));
*/
if ((sc->flags & FDF_HAVELABEL) == 0)
return(EINVAL);
- clp = &sc->dkdev.dk_label;
+ clp = sc->dkdev.dk_label;
/*
* make sure things check out and we only have one valid
* partition
/*
* get buf and read in sector 0
*/
- lp = &sc->dkdev.dk_label;
+ lp = sc->dkdev.dk_label;
bp = (void *)geteblk((int)lp->d_secsize);
bp->b_dev = FDMAKEDEV(major(dev), FDUNIT(dev), RAW_PART);
bp->b_blkno = 0;
*/
trk = bp->b_blkno / sc->nsectors;
+ /* Instrumentation. */
+ disk_busy(&sc->dkdev);
+
/*
* check to see if same as currently cached track
* if so we need to do no dma read.
sc->flags &= ~FDF_DIRTY;
if (timeo)
printf("%s: write of track cache timed out.\n",
- sc->dkdev.dk_dev.dv_xname);
+ sc->dv.dv_xname);
if (sc->flags & FDF_JUSTFLUSH) {
sc->flags &= ~FDF_JUSTFLUSH;
/*
#ifdef FDDEBUG
if (timeo)
printf("%s: fddmadone: cache load timed out.\n",
- sc->dkdev.dk_dev.dv_xname);
+ sc->sc_dv.dv_xname);
#endif
if (sc->retried >= sc->retries) {
sc->retried = 0;
* remove from queue.
*/
dp->b_actf = bp->b_actf;
+
+ disk_unbusy(&sc->dkdev, (bp->b_bcount - bp->b_resid));
+
biodone(bp);
nobuf:
- fdfindwork(sc->dkdev.dk_dev.dv_unit);
+ fdfindwork(sc->sc_dv.dv_unit);
}
void
if (doagain == 0 || (rp = srp = fdfindsync(srp, erp)) == NULL) {
#ifdef DIAGNOSTIC
printf("%s: corrupted track (%d) data.\n",
- sc->dkdev.dk_dev.dv_xname, sc->cachetrk);
+ sc->sc_dv.dv_xname, sc->cachetrk);
#endif
return(-1);
}
if (((info >> 16) & 0xff) != sc->cachetrk) {
#ifdef DEBUG
printf("%s: incorrect track found: 0x%0x %d\n",
- sc->dkdev.dk_dev.dv_xname, info, sc->cachetrk);
+ sc->sc_dv.dv_xname, info, sc->cachetrk);
#endif
goto again;
}
-/* $NetBSD: idesc.c,v 1.14 1995/10/05 12:41:22 chopps Exp $ */
+/* $NetBSD: idesc.c,v 1.15 1996/01/07 22:01:53 thorpej Exp $ */
/*
* Copyright (c) 1994 Michael L. Hitch
panic("ide_scsidone");
#endif
#if 1
+ /*
+ * XXX Support old-style instrumentation for now.
+ * IS THIS REALLY THE RIGHT PLACE FOR THIS? --thorpej
+ */
if (xs->sc_link && xs->sc_link->device_softc &&
((struct device *)(xs->sc_link->device_softc))->dv_unit < dk_ndrive)
++dk_xfer[((struct device *)(xs->sc_link->device_softc))->dv_unit];
-/* $NetBSD: sbic.c,v 1.19.2.1 1995/11/24 07:51:17 chopps Exp $ */
+/* $NetBSD: sbic.c,v 1.21 1996/01/07 22:01:54 thorpej Exp $ */
/*
* Copyright (c) 1994 Christian E. Hopps
return;
}
#endif
+ /*
+ * XXX Support old-style instrumentation for now.
+ * IS THIS REALLY THE RIGHT PLACE FOR THIS? --thorpej
+ */
if (slp->device_softc &&
((struct device *)(slp->device_softc))->dv_unit < dk_ndrive)
++dk_xfer[((struct device *)(slp->device_softc))->dv_unit];
-/* $NetBSD: sci.c,v 1.14 1995/09/29 13:52:02 chopps Exp $ */
+/* $NetBSD: sci.c,v 1.15 1996/01/07 22:01:56 thorpej Exp $ */
/*
* Copyright (c) 1994 Michael L. Hitch
if (xs == NULL)
panic("sci_scsidone");
#endif
+ /*
+ * XXX Support old-style instrumentation for now.
+ * IS THIS REALLY THE RIGHT PLACE FOR THIS? --thorpej
+ */
if (xs->sc_link->device_softc &&
((struct device *)(xs->sc_link->device_softc))->dv_unit < dk_ndrive)
++dk_xfer[((struct device *)(xs->sc_link->device_softc))->dv_unit];
-/* $NetBSD: siop.c,v 1.25.2.1 1995/11/24 07:51:23 chopps Exp $ */
+/* $NetBSD: siop.c,v 1.27 1996/01/07 22:01:58 thorpej Exp $ */
/*
* Copyright (c) 1994 Michael L. Hitch
if (acb == NULL || xs == NULL)
panic("siop_scsidone");
#endif
- if (slp->device_softc &&
+ /*
+ * XXX Support old-style instrumentation for now.
+ * IS THIS REALLY THE RIGHT PLACE FOR THIS? --thorpej
+ */
+ if (slp->device_softc &&
((struct device *)(slp->device_softc))->dv_unit < dk_ndrive)
++dk_xfer[((struct device *)(slp->device_softc))->dv_unit];
/*
-/* $NetBSD: swapgeneric.c,v 1.2 1995/11/30 21:55:01 leo Exp $ */
+/* $NetBSD: swapgeneric.c,v 1.3 1996/01/07 22:02:02 thorpej Exp $ */
/*
* Copyright (c) 1995 Leo Weppelman
{
struct genericconf *gc;
struct partition *pp;
- struct dkdevice *dkp;
+ struct disk *dkp;
+ struct device **devpp;
struct bdevsw *bdp;
int unit;
for (unit = 0; unit < gc->gc_driver->cd_ndevs; unit++) {
if (gc->gc_driver->cd_devs[unit] == NULL)
continue;
+
/*
- * this is a hack these drivers should use
- * dk_dev and not another instance directly above.
+ * Find the disk corresponding to the current
+ * device.
*/
- dkp = (struct dkdevice *)
- ((struct device *)gc->gc_driver->cd_devs[unit] + 1);
- if (dkp->dk_driver==NULL || dkp->dk_driver->d_strategy==NULL)
+ devpp = (struct device **)gc->gc_driver->cd_devs;
+ if ((dkp = disk_find(devpp[unit]->dv_xname)) == NULL)
+ continue;
+
+ if ((dkp->dk_driver == NULL) ||
+ (dkp->dk_driver->d_strategy == NULL))
continue;
for (bdp = bdevsw; bdp < (bdevsw + nblkdev); bdp++)
if (bdp->d_strategy == dkp->dk_driver->d_strategy)
bdp->d_close(MAKEDISKDEV(major(gc->gc_root), unit, 3),
FREAD | FNONBLOCK, 0, curproc);
if (search_root) {
- pp = &dkp->dk_label.d_partitions[0];
+ pp = &dkp->dk_label->d_partitions[0];
if (pp->p_size == 0 || pp->p_fstype != FS_BSDFFS)
continue;
}
else { /* must be swap */
- pp = &dkp->dk_label.d_partitions[1];
+ pp = &dkp->dk_label->d_partitions[1];
if (pp->p_size == 0 || pp->p_fstype != FS_SWAP)
continue;
}
-/* $NetBSD: fd.c,v 1.12 1995/12/10 14:25:12 leo Exp $ */
+/* $NetBSD: fd.c,v 1.13 1996/01/07 22:02:05 thorpej Exp $ */
/*
* Copyright (c) 1995 Leo Weppelman.
* Private per device data
*/
struct fd_softc {
- struct dkdevice dkdev;
+ struct device sc_dv; /* generic device info */
+ struct disk dkdev; /* generic disk info */
struct buf bufq; /* queue of buf's */
int unit; /* unit for atari controlling hw*/
int nheads; /* number of heads in use */
printf("\n");
+ /*
+ * Initialize and attach the disk structure.
+ */
+ sc->dkdev.dk_name = sc->sc_dv.dv_xname;
sc->dkdev.dk_driver = &fddkdriver;
+ disk_attach(&sc->dkdev);
}
fdioctl(dev, cmd, addr, flag, p)
case DIOCSBAD:
return(EINVAL);
case DIOCGDINFO:
- *(struct disklabel *)addr = sc->dkdev.dk_label;
+ *(struct disklabel *)addr = *(sc->dkdev.dk_label);
return(0);
case DIOCGPART:
((struct partinfo *)addr)->disklab =
- &sc->dkdev.dk_label;
+ sc->dkdev.dk_label;
((struct partinfo *)addr)->part =
- &sc->dkdev.dk_label.d_partitions[DISKPART(dev)];
+ &sc->dkdev.dk_label->d_partitions[DISKPART(dev)];
return(0);
#ifdef notyet /* XXX LWP */
case DIOCSRETRIES:
/*
* check for valid partition and bounds
*/
- lp = &sc->dkdev.dk_label;
+ lp = sc->dkdev.dk_label;
if ((sc->flags & FLPF_HAVELAB) == 0) {
bp->b_error = EIO;
goto bad;
sc->errcnt = 0; /* No errors yet */
fd_state = FLP_XFER; /* Yes, we're going to transfer */
+ /* Instrumentation. */
+ disk_busy(&sc->dkdev);
+
fd_xfer(sc);
}
sc->io_bytes);
#endif
bp->b_resid = sc->io_bytes;
+
+ disk_unbusy(&sc->dkdev, (bp->b_bcount - bp->b_resid));
+
biodone(bp);
}
fd_state = FLP_MON;
#endif
part = DISKPART(dev);
- lp = &sc->dkdev.dk_label;
+ lp = sc->dkdev.dk_label;
bzero(lp, sizeof(struct disklabel));
lp->d_secsize = SECTOR_SIZE;
-/* $NetBSD: ramd.c,v 1.5 1995/08/12 20:31:02 mycroft Exp $ */
+/* $NetBSD: ramd.c,v 1.6 1996/01/07 22:02:06 thorpej Exp $ */
/*
* Copyright (c) 1995 Leo Weppelman.
void (*strat)(); /* strategy function for read */
};
+static struct disk ramd_disks[RAMD_NDEV]; /* XXX Ick. */
+
/*
* Autoconfig stuff....
*/
NULL, "rd", (cfmatch_t)ramdmatch, ramdattach, DV_DULL,
sizeof(struct device), NULL, 0 };
+void rdstrategy __P((struct buf *));
+
+struct dkdriver ramddkdriver = { rdstrategy };
+
static int
ramdmatch(pdp, cfp, auxp)
struct device *pdp;
void *auxp;
{
int i;
+ struct disk *diskp;
+
+ /*
+ * XXX It's not really clear to me _exactly_ what's going
+ * on here, so this might need to be adjusted. --thorpej
+ */
+
+ for(i = 0; i < RAMD_NDEV; i++) {
+ /*
+ * Initialize and attach the disk structure.
+ */
+ diskp = &ramd_disks[i];
+ bzero(diskp, sizeof(struct disk));
+ if ((diskp->dk_name = malloc(8, M_DEVBUF, M_NOWAIT)) == NULL)
+ panic("ramdattach: can't allocate space for name");
+ bzero(diskp->dk_name, 8);
+ sprintf(diskp->dk_name, "rd%d", i);
+ diskp->dk_driver = &ramddkdriver;
+ disk_attach(diskp);
- for(i = 0; i < RAMD_NDEV; i++)
config_found(dp, (void*)i, ramdprint);
+ }
}
static int
-/* $NetBSD: rd.c,v 1.16 1995/12/09 07:31:07 thorpej Exp $ */
+/* $NetBSD: rd.c,v 1.17 1996/01/07 22:02:12 thorpej Exp $ */
/*
* Copyright (c) 1988 University of Utah.
#include <sys/systm.h>
#include <sys/buf.h>
#include <sys/stat.h>
-#include <sys/dkstat.h>
+#include <sys/dkstat.h> /* XXX */
#include <sys/disklabel.h>
+#include <sys/disk.h>
#include <sys/ioctl.h>
#include <sys/fcntl.h>
rs->sc_punit = rdpunit(hd->hp_flags);
rs->sc_type = rdident(rs, hd, 0);
if (rs->sc_type < 0)
+ return(0);
+
+ /* XXX set up the external name */
+ bzero(rs->sc_xname, sizeof(rs->sc_xname));
+ sprintf(rs->sc_xname, "rd%d", hd->hp_unit);
+
+ /*
+ * Initialize and attach the disk structure.
+ */
+ bzero(&rs->sc_dkdev, sizeof(rs->sc_dkdev));
+ rs->sc_dkdev.dk_name = rs->sc_xname;
+ disk_attach(&rs->sc_dkdev);
+
return (0);
return (1);
{
int unit = rdunit(dev);
register struct rd_softc *rs = &rd_softc[unit];
- register struct disklabel *lp = &rs->sc_info.ri_label;
+ register struct disklabel *lp = rs->sc_dkdev.dk_label;
register struct partition *pi;
char *msg, *readdisklabel();
* We may block reading the label, so be careful
* to stop any other opens.
*/
- if (rs->sc_info.ri_open == 0) {
+ if (rs->sc_dkdev.dk_openmask == 0) {
rs->sc_flags |= RDF_OPENING;
error = rdgetinfo(dev);
rs->sc_flags &= ~RDF_OPENING;
if (rs->sc_hd->hp_dk >= 0) {
/* guess at xfer rate based on 3600 rpm (60 rps) */
if (rs->sc_wpms == 0)
- rs->sc_wpms = 60 * rs->sc_info.ri_label.d_nsectors
+ rs->sc_wpms = 60 * rs->sc_dkdev.dk_label->d_nsectors
* DEV_BSIZE / 2;
+
+ /* XXX Support old-style instrumentation for now. */
dk_wpms[rs->sc_hd->hp_dk] = rs->sc_wpms;
}
mask = 1 << rdpart(dev);
if (mode == S_IFCHR)
- rs->sc_info.ri_copen |= mask;
+ rs->sc_dkdev.dk_copenmask |= mask;
else
- rs->sc_info.ri_bopen |= mask;
- rs->sc_info.ri_open |= mask;
+ rs->sc_dkdev.dk_bopenmask |= mask;
+ rs->sc_dkdev.dk_openmask |= mask;
return(0);
}
{
int unit = rdunit(dev);
register struct rd_softc *rs = &rd_softc[unit];
- register struct rdinfo *ri = &rs->sc_info;
+ register struct disk *dk = &rs->sc_dkdev;
int mask, s;
mask = 1 << rdpart(dev);
if (mode == S_IFCHR)
- ri->ri_copen &= ~mask;
+ dk->dk_copenmask &= ~mask;
else
- ri->ri_bopen &= ~mask;
- ri->ri_open = ri->ri_bopen | ri->ri_copen;
+ dk->dk_bopenmask &= ~mask;
+ dk->dk_openmask = dk->dk_copenmask | dk->dk_bopenmask;
/*
* On last close, we wait for all activity to cease since
* the label/parition info will become invalid. Since we
* Note we don't have to about other closes since we know
* we are the last one.
*/
- if (ri->ri_open == 0) {
+ if (dk->dk_openmask == 0) {
rs->sc_flags |= RDF_CLOSING;
s = splbio();
while (rdtab[unit].b_active) {
#endif
bn = bp->b_blkno;
sz = howmany(bp->b_bcount, DEV_BSIZE);
- pinfo = &rs->sc_info.ri_label.d_partitions[rdpart(bp->b_dev)];
+ pinfo = &rs->sc_dkdev.dk_label->d_partitions[rdpart(bp->b_dev)];
if (bn < 0 || bn + sz > pinfo->p_size) {
sz = pinfo->p_size - bn;
if (sz == 0) {
#endif
if (hpibsend(hp->hp_ctlr, hp->hp_slave, C_CMD, &rs->sc_ioc.c_unit,
sizeof(rs->sc_ioc)-2) == sizeof(rs->sc_ioc)-2) {
+
+ /* XXX Support old-style instrumentation for now. */
if (hp->hp_dk >= 0) {
- dk_busy |= 1 << hp->hp_dk;
- dk_seek[hp->hp_dk]++;
+ dk_busy |= 1 << hp->hp_dk;
+ dk_seek[hp->hp_dk]++;
}
+
+ /* Instrumentation. */
+ disk_busy(&rs->sc_dkdev);
+ rs->sc_dkdev.dk_seek++;
+
#ifdef DEBUG
if (rddebug & RDB_IO)
printf("rdstart: hpibawait(%x)\n", hp->hp_ctlr);
rw = bp->b_flags & B_READ;
+ /* XXX Support old-style instrumentation for now. */
if (hp->hp_dk >= 0) {
dk_busy |= 1 << hp->hp_dk;
dk_xfer[hp->hp_dk]++;
dk_wds[hp->hp_dk] += rs->sc_resid >> 6;
}
+
+ /* Instrumentation. */
+ disk_busy(&rs->sc_dkdev);
+
#ifdef USELEDS
if (inledcontrol == 0)
ledcontrol(0, 0, LED_DISK);
return;
}
#endif
+ /* XXX Support old-style instrumentation for now. */
if (hp->hp_dk >= 0)
dk_busy &= ~(1 << hp->hp_dk);
+
+ disk_unbusy(&rs->sc_dkdev, (bp->b_bcount - bp->b_resid));
+
if (rs->sc_flags & RDF_SEEK) {
rs->sc_flags &= ~RDF_SEEK;
if (hpibustart(hp->hp_ctlr))
#ifdef DEBUG
rdstats[unit].rdpollwaits++;
#endif
+
+ /* XXX Support old-style instrumentation for now. */
if (hp->hp_dk >= 0)
dk_busy |= 1 << hp->hp_dk;
+
+ /* Instrumentation. */
+ disk_busy(&rs->sc_dkdev);
rs->sc_flags |= RDF_SWAIT;
hpibawait(hp->hp_ctlr);
return;
* we just use b_blkno.
*/
bp = rdtab[unit].b_actf;
- pbn = rs->sc_info.ri_label.d_partitions[rdpart(bp->b_dev)].p_offset;
+ pbn = rs->sc_dkdev.dk_label->d_partitions[rdpart(bp->b_dev)].p_offset;
if ((sp->c_fef & FEF_CU) || (sp->c_fef & FEF_DR) ||
(sp->c_ief & IEF_RRMASK)) {
hwbn = RDBTOS(pbn + bp->b_blkno);
{
int unit = rdunit(dev);
register struct rd_softc *sc = &rd_softc[unit];
- register struct disklabel *lp = &sc->sc_info.ri_label;
+ register struct disklabel *lp = sc->sc_dkdev.dk_label;
int error, flags;
switch (cmd) {
return (EBADF);
return (setdisklabel(lp, (struct disklabel *)data,
(sc->sc_flags & RDF_WLABEL) ? 0
- : sc->sc_info.ri_open,
+ : sc->sc_dkdev.dk_openmask,
(struct cpu_disklabel *)0));
case DIOCWDINFO:
return (EBADF);
error = setdisklabel(lp, (struct disklabel *)data,
(sc->sc_flags & RDF_WLABEL) ? 0
- : sc->sc_info.ri_open,
+ : sc->sc_dkdev.dk_openmask,
(struct cpu_disklabel *)0);
if (error)
return (error);
* without the device being open so we may need
* to handle it here.
*/
- if (rs->sc_info.ri_open == 0) {
+ if (rs->sc_dkdev.dk_openmask == 0) {
if (rdopen(dev, FREAD|FWRITE, S_IFBLK, NULL))
return(-1);
didopen = 1;
}
- psize = rs->sc_info.ri_label.d_partitions[rdpart(dev)].p_size;
+ psize = rs->sc_dkdev.dk_label->d_partitions[rdpart(dev)].p_size;
if (didopen)
(void) rdclose(dev, FREAD|FWRITE, S_IFBLK, NULL);
return (psize);
/* is drive ok? */
if (unit >= NRD || (rs->sc_flags & RDF_ALIVE) == 0)
return (ENXIO);
- pinfo = &rs->sc_info.ri_label.d_partitions[part];
+ pinfo = &rs->sc_dkdev.dk_label->d_partitions[part];
/* dump parameters in range? */
if (dumplo < 0 || dumplo >= pinfo->p_size ||
pinfo->p_fstype != FS_SWAP)
-/* $NetBSD: rd_compat.c,v 1.4 1995/11/19 19:07:20 thorpej Exp $ */
+/* $NetBSD: rd_compat.c,v 1.5 1996/01/07 22:02:14 thorpej Exp $ */
/*
* Copyright (c) 1988 University of Utah.
#include <sys/param.h>
#include <sys/disklabel.h>
+#include <sys/disk.h>
#include <hp300/dev/device.h>
#include <hp300/dev/rdreg.h>
#include <hp300/dev/rdvar.h>
-/* $NetBSD: rdvar.h,v 1.3 1995/11/19 19:07:21 thorpej Exp $ */
+/* $NetBSD: rdvar.h,v 1.4 1996/01/07 22:02:16 thorpej Exp $ */
/*
* Copyright (c) 1988 University of Utah.
int ri_nblocks; /* DEV_BSIZE blocks on disk */
};
-struct rdinfo {
- struct disklabel ri_label; /* label */
- int ri_bopen; /* mask of open block devs */
- int ri_copen; /* mask of open char devs */
- int ri_open; /* composite mask of open devs */
-};
-
struct rd_softc {
struct hp_device *sc_hd;
+ struct disk sc_dkdev;
+ char sc_xname[8];
int sc_flags;
short sc_type;
short sc_punit;
char *sc_addr;
int sc_resid;
u_int sc_wpms;
- struct rdinfo sc_info;
struct rd_describe sc_rddesc;
struct devqueue sc_dq;
struct rd_iocmd sc_ioc;
-/* $NetBSD: sd.c,v 1.20 1995/12/09 07:31:03 thorpej Exp $ */
+/* $NetBSD: sd.c,v 1.21 1996/01/07 22:02:18 thorpej Exp $ */
/*
* Copyright (c) 1990, 1993
#include <sys/systm.h>
#include <sys/buf.h>
#include <sys/stat.h>
-#include <sys/dkstat.h>
+#include <sys/dkstat.h> /* XXX */
#include <sys/disklabel.h>
+#include <sys/disk.h>
#include <sys/malloc.h>
#include <sys/proc.h>
#include <sys/ioctl.h>
{
register struct sd_softc *sc = &sd_softc[hd->hp_unit];
+ /* XXX set up external name */
+ bzero(sc->sc_xname, sizeof(sc->sc_xname));
+ sprintf(sc->sc_xname, "sd%d", hd->hp_unit);
+
+ /* Initialize the disk structure. */
+ bzero(&sc->sc_dkdev, sizeof(sc->sc_dkdev));
+ sc->sc_dkdev.dk_name = sc->sc_xname;
+
sc->sc_hd = hd;
sc->sc_flags = 0;
/*
sc->sc_dq.dq_slave = hd->hp_slave;
sc->sc_dq.dq_driver = &sddriver;
+ /* Attach the disk. */
+ disk_attach(&sc->sc_dkdev);
+
sc->sc_flags |= SDF_ALIVE;
}
{
int unit = sdunit(dev);
register struct sd_softc *sc = &sd_softc[unit];
- register struct disklabel *lp = &sc->sc_info.si_label;
+ register struct disklabel *lp = sc->sc_dkdev.dk_label;
register struct partition *pi;
char *msg, *readdisklabel();
#ifdef COMPAT_NOLABEL
* We may block reading the label, so be careful
* to stop any other opens.
*/
- if (sc->sc_info.si_open == 0) {
+ if (sc->sc_dkdev.dk_openmask == 0) {
sc->sc_flags |= SDF_OPENING;
error = sdgetinfo(dev);
sc->sc_flags &= ~SDF_OPENING;
if (error)
return(error);
}
+
+ /* XXX Support old-style instrumentation for now. */
if (sc->sc_hd->hp_dk >= 0)
dk_wpms[sc->sc_hd->hp_dk] = sc->sc_wpms;
mask = 1 << sdpart(dev);
if (mode == S_IFCHR)
- sc->sc_info.si_copen |= mask;
+ sc->sc_dkdev.dk_copenmask |= mask;
else
- sc->sc_info.si_bopen |= mask;
- sc->sc_info.si_open |= mask;
+ sc->sc_dkdev.dk_bopenmask |= mask;
+ sc->sc_dkdev.dk_openmask |= mask;
return(0);
}
{
int unit = sdunit(dev);
register struct sd_softc *sc = &sd_softc[unit];
- register struct sdinfo *si = &sc->sc_info;
+ register struct disk *dk = &sc->sc_dkdev;
int mask, s;
mask = 1 << sdpart(dev);
if (mode == S_IFCHR)
- si->si_copen &= ~mask;
+ dk->dk_copenmask &= ~mask;
else
- si->si_bopen &= ~mask;
- si->si_open = si->si_bopen | si->si_copen;
+ dk->dk_bopenmask &= ~mask;
+ dk->dk_openmask = dk->dk_copenmask | dk->dk_bopenmask;
/*
* On last close, we wait for all activity to cease since
* the label/parition info will become invalid. Since we
* Note we don't have to about other closes since we know
* we are the last one.
*/
- if (si->si_open == 0) {
+ if (dk->dk_openmask == 0) {
sc->sc_flags |= SDF_CLOSING;
s = splbio();
while (sdtab[unit].b_active) {
}
bn = bp->b_blkno;
sz = howmany(bp->b_bcount, DEV_BSIZE);
- pinfo = &sc->sc_info.si_label.d_partitions[sdpart(bp->b_dev)];
+ pinfo = &sc->sc_dkdev.dk_label->d_partitions[sdpart(bp->b_dev)];
if (bn < 0 || bn + sz > pinfo->p_size) {
sz = pinfo->p_size - bn;
if (sz == 0) {
if (inledcontrol == 0)
ledcontrol(0, 0, LED_DISK);
#endif
- if (scsigo(hp->hp_ctlr, hp->hp_slave, sc->sc_punit, bp, cmd, pad) == 0) {
+ if (scsigo(hp->hp_ctlr, hp->hp_slave, sc->sc_punit,
+ bp, cmd, pad) == 0) {
+ /* XXX Support old-style instrumentation for now. */
if (hp->hp_dk >= 0) {
dk_busy |= 1 << hp->hp_dk;
++dk_seek[hp->hp_dk];
++dk_xfer[hp->hp_dk];
dk_wds[hp->hp_dk] += bp->b_bcount >> 6;
}
+
+ /* Instrumentation. */
+ disk_busy(&sc->sc_dkdev);
+ sc->sc_dkdev.dk_seek++; /* XXX */
return;
}
#ifdef DEBUG
printf("%s: bp == NULL\n", sc->sc_hd->hp_xname);
return;
}
+
+ /* XXX Support old-style instrumentation for now. */
if (hp->hp_dk >= 0)
dk_busy &=~ (1 << hp->hp_dk);
+
+ disk_unbusy(&sc->sc_dkdev, (bp->b_bcount - bp->b_resid));
+
if (stat) {
#ifdef DEBUG
if (sddebug & SDB_ERROR)
{
int unit = sdunit(dev);
register struct sd_softc *sc = &sd_softc[unit];
- register struct disklabel *lp = &sc->sc_info.si_label;
+ register struct disklabel *lp = sc->sc_dkdev.dk_label;
int error, flags;
switch (cmd) {
return (EBADF);
error = setdisklabel(lp, (struct disklabel *)data,
(sc->sc_flags & SDF_WLABEL) ? 0
- : sc->sc_info.si_open,
+ : sc->sc_dkdev.dk_openmask,
(struct cpu_disklabel *)0);
return (error);
return (EBADF);
error = setdisklabel(lp, (struct disklabel *)data,
(sc->sc_flags & SDF_WLABEL) ? 0
- : sc->sc_info.si_open,
+ : sc->sc_dkdev.dk_openmask,
(struct cpu_disklabel *)0);
if (error)
return (error);
* without the device being open so we may need
* to handle it here.
*/
- if (sc->sc_info.si_open == 0) {
+ if (sc->sc_dkdev.dk_openmask == 0) {
if (sdopen(dev, FREAD|FWRITE, S_IFBLK, NULL))
return(-1);
didopen = 1;
}
- psize = sc->sc_info.si_label.d_partitions[sdpart(dev)].p_size;
+ psize = sc->sc_dkdev.dk_label->d_partitions[sdpart(dev)].p_size;
if (didopen)
(void) sdclose(dev, FREAD|FWRITE, S_IFBLK, NULL);
return (psize);
/* is drive ok? */
if (unit >= NSD || (sc->sc_flags & SDF_ALIVE) == 0)
return (ENXIO);
- pinfo = &sc->sc_info.si_label.d_partitions[part];
+ pinfo = &sc->sc_dkdev.dk_label->d_partitions[part];
/* dump parameters in range? */
if (dumplo < 0 || dumplo >= pinfo->p_size ||
pinfo->p_fstype != FS_SWAP)
-/* $NetBSD: sd_compat.c,v 1.3 1994/10/26 07:25:08 cgd Exp $ */
+/* $NetBSD: sd_compat.c,v 1.4 1996/01/07 22:02:20 thorpej Exp $ */
/*
* Copyright (c) 1990, 1993
#include <sys/param.h>
#include <sys/disklabel.h>
+#include <sys/disk.h>
#include <hp300/dev/device.h>
#include <hp300/dev/sdvar.h>
-/* $NetBSD: sdvar.h,v 1.3 1995/10/15 10:03:20 thorpej Exp $ */
+/* $NetBSD: sdvar.h,v 1.4 1996/01/07 22:02:21 thorpej Exp $ */
/*
* Copyright (c) 1990, 1993
* @(#)sdvar.h 8.1 (Berkeley) 6/10/93
*/
-struct sdinfo {
- struct disklabel si_label; /* label */
- int si_bopen; /* mask of open block devs */
- int si_copen; /* mask of open char devs */
- int si_open; /* composite mask of open devs */
-};
-
struct sd_softc {
struct hp_device *sc_hd;
+ struct disk sc_dkdev;
+ char sc_xname[8];
struct devqueue sc_dq;
int sc_format_pid; /* process using "format" mode */
short sc_flags;
u_int sc_heads; /* number of heads (tracks) */
u_int sc_cyls; /* number of cylinders */
u_int sc_wpms; /* average xfer rate in 16 bit wds/sec. */
- struct sdinfo sc_info; /* disklabel and related info */
};
/* sc_flags values */
-/* $NetBSD: fd.c,v 1.79 1995/08/21 06:56:14 mycroft Exp $ */
+/* $NetBSD: fd.c,v 1.82 1996/01/07 22:02:28 thorpej Exp $ */
/*-
* Copyright (c) 1993, 1994, 1995 Charles Hannum.
/* software state, per disk (with up to 4 disks per ctlr) */
struct fd_softc {
struct device sc_dev;
- struct dkdevice sc_dk;
+ struct disk sc_dk;
struct fd_type *sc_deftype; /* default type descriptor */
struct fd_type *sc_type; /* current type descriptor */
fd->sc_drive = drive;
fd->sc_deftype = type;
fdc->sc_fd[drive] = fd;
+
+ /*
+ * Initialize and attach the disk structure.
+ */
+ fd->sc_dk.dk_name = fd->sc_dev.dv_xname;
fd->sc_dk.dk_driver = &fddkdriver;
+ disk_attach(&fd->sc_dk);
+
#ifdef NEWCONFIG
/* XXX Need to do some more fiddling with sc_dk. */
dk_establish(&fd->sc_dk, &fd->sc_dev);
fd->sc_q.b_active = 1;
TAILQ_INSERT_TAIL(&fdc->sc_drives, fd, sc_drivechain);
+ /* Instrumentation. */
+ disk_busy(&fd->sc_dk);
+
/* If controller not already active, start it. */
if (!active)
fdcstart(fdc);
bp->b_resid = fd->sc_bcount;
fd->sc_skip = 0;
fd->sc_q.b_actf = bp->b_actf;
+
+ disk_unbusy(&fd->sc_dk, (bp->b_bcount - bp->b_resid));
+
biodone(bp);
/* turn off motor 5s from now */
timeout(fd_motor_off, fd, 5 * hz);
-/* $NetBSD: ncr5380.c,v 1.14 1995/12/04 02:10:44 briggs Exp $ */
+/* $NetBSD: ncr5380.c,v 1.17 1996/01/06 15:56:12 briggs Exp $ */
/*
* Copyright (c) 1995 Leo Weppelman.
# define DBG_INFPRINT(a,b,c)
#endif
#ifdef DBG_PID
- static char *last_hit = NULL, *olast_hit = NULL;
-# define PID(a) olast_hit = last_hit; last_hit = a;
+ /* static char *last_hit = NULL, *olast_hit = NULL; */
+ static char *last_hit[DBG_PID];
+# define PID(a) \
+ { int i; \
+ for (i=0; i< DBG_PID-1; i++) \
+ last_hit[i] = last_hit[i+1]; \
+ last_hit[DBG_PID-1] = a; } \
+ /* olast_hit = last_hit; last_hit = a; */
#else
# define PID(a)
#endif
phase = PH_MSGOUT;
SET_5380_REG(NCR5380_ICOM, SC_A_ATN);
- transfer_pio(&phase, &msg, &len, 0);
+ if (transfer_pio(&phase, &msg, &len, 0) || len)
+ scsi_reset(sc);
}
else {
connected = tmp;
*/
if (!is_edma && !(dmstat & (SC_END_DMA|SC_BSY_ERR))
&& (dmstat & SC_PHS_MTCH) ) {
- ncr_tprint(reqp, "dma_ready: spurious call"
+ ncr_tprint(reqp, "dma_ready: spurious call "
"(dm:%x,last_hit: %s)\n",
#ifdef DBG_PID
- dmstat, last_hit);
+ dmstat, last_hit[DBG_PID-1]);
#else
- dmstat, "unknown");
+ dmstat, "unknown");
#endif
return (0);
}
if (reqp->dr_flag & DRIVER_LINKCHK) {
if (linked)
ncr_will_link |= 1<<reqp->targ_id;
+ else ncr_tprint(reqp, "Does not support linked commands\n");
return (0);
}
/*
printf("REQ-%s: %d %x[%d] cmd[0]=%x S=%x M=%x R=%x resid=%d dr_flag=%x %s\n",
qtxt, reqp->targ_id, reqp->xdata_ptr, reqp->xdata_len,
reqp->xcmd.opcode, reqp->status, reqp->message,
- reqp->dr_flag,
- reqp->xs->error, reqp->xs->resid, reqp->link ? "L":"");
+ reqp->xs->error, reqp->xs->resid, reqp->dr_flag,
+ reqp->link ? "L":"");
if (reqp->status == SCSCHKC)
show_data_sense(reqp->xs);
}
SC_REQ *tmp;
int sps = splhigh();
u_char idstat, dmstat;
-
-#ifndef DBG_PID
- #define last_hit ""
- #define olast_hit ""
-#endif
+ int i;
for (tmp = issue_q; tmp; tmp = tmp->next)
show_request(tmp, "ISSUED");
show_signals(dmstat, idstat);
if (connected)
printf("phase = %d, ", connected->phase);
- printf("busy:%x, last_hit:%s, olast_hit:%s spl:%04x\n", busy,
- last_hit, olast_hit, sps);
+ printf("busy:%x, spl:%04x\n", busy, sps);
+#ifdef DBG_PID
+ for (i=0; i<DBG_PID; i++)
+ printf("\t%d\t%s\n", i, last_hit[i]);
+#endif
splx(sps);
}
-/* $NetBSD: autoconf.c,v 1.20 1995/11/01 04:59:31 briggs Exp $ */
+/* $NetBSD: autoconf.c,v 1.21 1996/01/07 22:02:39 thorpej Exp $ */
/*
* Copyright (c) 1988 University of Utah.
/* swiped from sparc/sparc/autoconf.c */
static int
-findblkmajor(register struct dkdevice *dv)
+findblkmajor(register struct disk *dv)
{
register int i;
findbootdev()
{
register struct device *dv;
+ register struct disk *diskp;
register int unit;
int major;
unit = target_to_unit(-1, unit, 0);
bootdev |= (unit << B_UNITSHIFT);
+ if (disk_count <= 0)
+ return;
+
for (dv = alldevs ; dv ; dv = dv->dv_next) {
- if ( (dv->dv_class == DV_DISK)
- && (unit == dv->dv_unit)
- && (major == findblkmajor((struct dkdevice *) (dv+1)))) {
- bootdv = dv;
- return;
+ if ((dv->dv_class == DV_DISK) && (unit == dv->dv_unit)) {
+ /*
+ * Find the disk corresponding to the current
+ * device.
+ */
+ if ((diskp = disk_find(dv->dv_xname)) == NULL)
+ continue;
+
+ if (major == findblkmajor(diskp)) {
+ bootdv = dv;
+ return;
+ }
}
}
}
#include <sys/buf.h>
#define DKTYPENAMES
#include <sys/disklabel.h>
+#include <sys/disk.h>
#define b_cylin b_resid
#endif
int
-dk_establish()
+dk_establish(dk, dev)
+ struct disk *dk;
+ struct device *dev;
{
return(-1);
}
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
- * $Id: rd.c,v 1.1.1.1 1995/10/18 08:51:18 deraadt Exp $
+ * $Id: rd.c,v 1.2 1996/01/12 20:20:38 deraadt Exp $
*/
#include <sys/param.h>
#include <sys/buf.h>
#include <sys/device.h>
#include <sys/conf.h>
+#include <sys/disk.h>
static int rdmatch(struct device *parent, void *cf, void *aux);
static void rdattach(struct device *parent, struct device *self, void *aux);
+struct rdsoftc {
+ struct device sc_dev; /* generic device glue */
+ struct disk sc_dkdev; /* generic disk glue */
+};
+
struct cfdriver rdcd = {
NULL,
"rd",
rdmatch,
rdattach,
DV_DISK,
- sizeof(struct device),
+ sizeof(struct rdsoftc),
NULL,
0
};
+void rdstrategy __P((struct buf *));
+
+struct dkdriver rddkdriver = { rdstrategy };
+
#if !defined(RD_SIZE)
# define RD_SIZE 0x200000
#endif
struct device *parent, *self;
void *aux;
{
+ struct rdsoftc *sc = (struct rdsoftc *)self;
+
printf(" addr 0x%x, size 0x%x\n", ram_disk, RD_SIZE);
+
+ /*
+ * Initialize and attach the disk structure.
+ */
+ bzero(&sc->sc_dkdev, sizeof(sc->sc_dkdev));
+ sc->sc_dkdev.dk_driver = &rddkdriver;
+ sc->sc_dkdev.dk_name = sc->sc_dev.dv_xname;
+ disk_attach(&sc->sc_dkdev);
}
-/* $NetBSD: rz.c,v 1.12 1995/09/13 19:35:56 jonathan Exp $ */
+/* $NetBSD: rz.c,v 1.13 1996/01/07 22:02:52 thorpej Exp $ */
/*
* Copyright (c) 1992, 1993
#include <sys/errno.h>
#include <sys/fcntl.h>
#include <sys/ioctl.h>
-#include <sys/dkstat.h>
+#include <sys/dkstat.h> /* XXX */
#include <sys/disklabel.h>
+#include <sys/disk.h>
#include <sys/malloc.h>
#include <sys/proc.h>
#include <sys/uio.h>
struct rz_softc {
struct pmax_scsi_device *sc_sd; /* physical unit info */
pid_t sc_format_pid; /* process using "format" mode */
- u_long sc_openpart; /* partitions open */
- u_long sc_bopenpart; /* block partitions open */
- u_long sc_copenpart; /* character partitions open */
short sc_flags; /* see below */
short sc_type; /* drive type from INQUIRY cmd */
u_int sc_blks; /* number of blocks on device */
int sc_blksize; /* device block size in bytes */
- int sc_bshift; /* convert device blocks to DEV_BSIZE */
+ struct disk sc_dkdev; /* generic disk device info */
+#define sc_label sc_dkdev.dk_label /* XXX compat */
+#define sc_openpart sc_dkdev.dk_openmask /* XXX compat */
+#define sc_bopenpart sc_dkdev.dk_bopenmask /* XXX compat */
+#define sc_copenpart sc_dkdev.dk_copenmask /* XXX compat */
+#define sc_bshift sc_dkdev.dk_blkshift /* XXX compat */
+ char sc_xname[8]; /* XXX external name */
u_int sc_wpms; /* average xfer rate in 16bit wds/sec */
- struct disklabel sc_label; /* disk label for this disk */
struct rzstats sc_stats; /* statisic counts */
struct buf sc_tab; /* queue of pending operations */
struct buf sc_buf; /* buf for doing I/O */
else
sc->sc_cmd.flags = 0;
+ disk_busy(&sc->sc_dkdev); /* XXX */
(*sc->sc_sd->sd_cdriver->d_start)(&sc->sc_cmd);
if (!biowait(&sc->sc_buf))
break;
sc->sc_cmd.unit = sd->sd_unit;
sc->sc_rwcmd.unitNumber = sd->sd_slave;
+ /* XXX set up the external name */
+ bzero(sc->sc_xname, sizeof(sc->sc_xname)); /* XXX */
+ sprintf(sc->sc_xname, "rz%d", sd->sd_unit); /* XXX */
+
+ /* Initialize the disk structure. */
+ bzero(&sc->sc_dkdev, sizeof(sc->sc_dkdev));
+ sc->sc_dkdev.dk_name = sc->sc_xname;
+
/* try to find out what type of device this is */
sc->sc_format_pid = 1; /* force use of sc_cdb */
sc->sc_flags = RZF_NOERR; /* don't print SCSI errors */
goto bad;
}
}
- sc->sc_wpms = 32 * (60 * DEV_BSIZE / 2); /* XXX */
+
+ /* XXX Support old-style instrumentation for now. */
+ sc->sc_wpms = 32 * (60 * DEV_BSIZE / 2);
+
+ /* Attach the disk. */
+ disk_attach(&sc->sc_dkdev);
+
sc->sc_format_pid = 0;
sc->sc_flags |= RZF_ALIVE;
if (inqbuf.rmb)
register int unit = rzunit(bp->b_dev);
register int part = rzpart(bp->b_dev);
register struct rz_softc *sc = &rz_softc[unit];
- register struct partition *pp = &sc->sc_label.d_partitions[part];
+ register struct partition *pp = &sc->sc_label->d_partitions[part];
register daddr_t bn;
register long sz, s;
unit, bp->b_bcount);
#endif
sc->sc_stats.rztransfers++;
+
+ /* XXX Support old-style instrumentation for now. */
if ((n = sc->sc_sd->sd_dk) >= 0) {
dk_busy |= 1 << n;
++dk_seek[n];
}
}
+
+ /* Instrumentation. */
+ disk_busy(&sc->sc_dkdev);
+ sc->sc_dkdev.dk_seek++; /* XXX */
+
/* tell controller to start this command */
(*sc->sc_sd->sd_cdriver->d_start)(&sc->sc_cmd);
}
printf("rz%d: bp == NULL\n", unit);
return;
}
+
+ /* XXX Support old-style instrumentation for now. */
if (sd->sd_dk >= 0)
dk_busy &= ~(1 << sd->sd_dk);
+
+ disk_unbusy(&sc->sc_dkdev, (bp->b_bcount - bp->b_resid));
+
if (sc->sc_flags & RZF_SENSEINPROGRESS) {
sc->sc_flags &= ~RZF_SENSEINPROGRESS;
sc->sc_tab.b_actf = bp = bp->b_actf; /* remove sc_errbuf */
{
register int unit = rzunit(dev);
register struct rz_softc *sc = &rz_softc[unit];
- register struct disklabel *lp = &sc->sc_label;
+ register struct disklabel *lp = sc->sc_label;
register int i;
char *msg;
int part;
register struct disklabel *lp;
register int i;
int part;
- u_long mask;
+ int mask;
if (unit >= NRZ || !(sc->sc_flags & RZF_ALIVE))
return (ENXIO);
if (!(sc->sc_flags & RZF_HAVELABEL))
rzgetinfo(dev);
- lp = &sc->sc_label;
+ lp = sc->sc_label;
if (part >= lp->d_npartitions || lp->d_partitions[part].p_size == 0)
{
printf("rzopen: ENXIO on rz%d%c unit %d part %d\n",
break;
}
sc->sc_openpart |= mask;
+
+ /* XXX Support old-style instrumentation for now. */
if (sc->sc_sd->sd_dk >= 0)
dk_wpms[sc->sc_sd->sd_dk] = sc->sc_wpms;
+
return (0);
}
int flags, mode;
{
register struct rz_softc *sc = &rz_softc[rzunit(dev)];
- u_long mask = (1 << rzpart(dev));
+ int mask = (1 << rzpart(dev));
int s;
switch (mode) {
case DIOCGDINFO:
/* get the current disk label */
- *(struct disklabel *)data = sc->sc_label;
+ *(struct disklabel *)data = *(sc->sc_label);
return (0);
case DIOCSDINFO:
/* set the current disk label */
if (!(flag & FWRITE))
return (EBADF);
- error = setdisklabel(&sc->sc_label,
+ error = setdisklabel(sc->sc_label,
(struct disklabel *)data,
(sc->sc_flags & RZF_WLABEL) ? 0 :
sc->sc_openpart, &cd);
case DIOCGPART:
/* return the disk partition data */
- ((struct partinfo *)data)->disklab = &sc->sc_label;
+ ((struct partinfo *)data)->disklab = sc->sc_label;
((struct partinfo *)data)->part =
- &sc->sc_label.d_partitions[rzpart(dev)];
+ &sc->sc_label->d_partitions[rzpart(dev)];
return (0);
case DIOCWLABEL:
/* write the disk label to disk */
if (!(flag & FWRITE))
return (EBADF);
- error = setdisklabel(&sc->sc_label,
+ error = setdisklabel(sc->sc_label,
(struct disklabel *)data,
(sc->sc_flags & RZF_WLABEL) ? 0 :
sc->sc_openpart,
/* simulate opening partition 0 so write succeeds */
flags = sc->sc_flags;
sc->sc_flags = RZF_ALIVE | RZF_WLABEL;
- error = writedisklabel(dev, rzstrategy, &sc->sc_label, &cd);
+ error = writedisklabel(dev, rzstrategy, sc->sc_label, &cd);
sc->sc_flags = flags;
return (error);
}
if (!(sc->sc_flags & RZF_HAVELABEL))
rzgetinfo(dev);
- if (part >= sc->sc_label.d_npartitions)
+ if (part >= sc->sc_label->d_npartitions)
return (-1);
- return (sc->sc_label.d_partitions[part].p_size);
+ return (sc->sc_label->d_partitions[part].p_size);
}
/*
if (unit >= NRZ || (sc->sc_flags & RZF_ALIVE) == 0)
return (ENXIO);
/* dump parameters in range? */
- if (dumplo < 0 || dumplo >= sc->sc_label.d_partitions[part].p_size)
+ if (dumplo < 0 || dumplo >= sc->sc_label->d_partitions[part].p_size)
return (EINVAL);
- if (dumplo + ctod(pages) > sc->sc_label.d_partitions[part].p_size)
- pages = dtoc(sc->sc_label.d_partitions[part].p_size - dumplo);
+ if (dumplo + ctod(pages) > sc->sc_label->d_partitions[part].p_size)
+ pages = dtoc(sc->sc_label->d_partitions[part].p_size - dumplo);
maddr = lowram;
- baddr = dumplo + sc->sc_label.d_partitions[part].p_offset;
+ baddr = dumplo + sc->sc_label->d_partitions[part].p_offset;
#ifdef notdef /*XXX -- bogus code, from Mach perhaps? */
/* scsi bus idle? */
-/* $NetBSD: disksubr.c,v 1.6 1995/08/04 02:34:24 jonathan Exp $ */
+/* $NetBSD: disksubr.c,v 1.7 1996/01/07 22:02:55 thorpej Exp $ */
/*
* Copyright (c) 1982, 1986, 1988 Regents of the University of California.
*/
int
dk_establish(dk, dev)
- struct dkdevice *dk;
+ struct disk *dk;
struct device *dev;
{
/* see also arch/alpha/alpha/disksubr.c */
/* software state, per disk (with up to 4 disks per ctlr) */
struct fd_softc {
- struct dkdevice sc_dk;
+ struct device sc_dv; /* generic device info */
+ struct disk sc_dk; /* generic disk info */
struct fd_type *sc_deftype; /* default type descriptor */
struct fd_type *sc_type; /* current type descriptor */
fa.fa_deftype = &fd_types[0]; /* XXX */
(void)config_found(self, (void *)&fa, fdprint);
}
+
+ bootpath_store(1, NULL);
}
int
fd->sc_drive = drive;
fd->sc_deftype = type;
fdc->sc_fd[drive] = fd;
+
+ /*
+ * Initialize and attach the disk structure.
+ */
+ fd->sc_dk.dk_name = fd->sc_dv.dv_xname;
fd->sc_dk.dk_driver = &fddkdriver;
+ disk_attach(&fd->sc_dk);
/*
* We're told if we're the boot device in fdcattach().
*/
if (fa->fa_bootdev)
- bootdv = &fd->sc_dk.dk_dev;
+ bootdv = &fd->sc_dv;
/* XXX Need to do some more fiddling with sc_dk. */
- dk_establish(&fd->sc_dk, &fd->sc_dk.dk_dev);
+ dk_establish(&fd->sc_dk, &fd->sc_dv);
}
inline struct fd_type *
fdstart(fd);
#ifdef DIAGNOSTIC
else {
- struct fdc_softc *fdc = (void *)fd->sc_dk.dk_dev.dv_parent;
+ struct fdc_softc *fdc = (void *)fd->sc_dv.dv_parent;
if (fdc->sc_state == DEVIDLE) {
printf("fdstrategy: controller inactive\n");
fdcstart(fdc);
fdstart(fd)
struct fd_softc *fd;
{
- struct fdc_softc *fdc = (void *)fd->sc_dk.dk_dev.dv_parent;
+ struct fdc_softc *fdc = (void *)fd->sc_dv.dv_parent;
int active = fdc->sc_drives.tqh_first != 0;
/* Link into controller queue. */
fd->sc_q.b_active = 1;
TAILQ_INSERT_TAIL(&fdc->sc_drives, fd, sc_drivechain);
+ /* Instrumentation. */
+ disk_busy(&fd->sc_dk);
+
/* If controller not already active, start it. */
if (!active)
fdcstart(fdc);
struct fd_softc *fd;
struct buf *bp;
{
- struct fdc_softc *fdc = (void *)fd->sc_dk.dk_dev.dv_parent;
+ struct fdc_softc *fdc = (void *)fd->sc_dv.dv_parent;
/*
* Move this drive to the end of the queue to give others a `fair'
bp->b_resid = fd->sc_bcount;
fd->sc_skip = 0;
fd->sc_q.b_actf = bp->b_actf;
+
+ disk_unbusy(&fd->sc_dk, (bp->b_bcount - bp->b_resid));
+
biodone(bp);
/* turn off motor 5s from now */
timeout(fd_motor_off, fd, 5 * hz);
s = splbio();
fd->sc_flags &= ~(FD_MOTOR | FD_MOTOR_WAIT);
- fd_set_motor((struct fdc_softc *)fd->sc_dk.dk_dev.dv_parent);
+ fd_set_motor((struct fdc_softc *)fd->sc_dv.dv_parent);
splx(s);
}
void *arg;
{
struct fd_softc *fd = arg;
- struct fdc_softc *fdc = (void *)fd->sc_dk.dk_dev.dv_parent;
+ struct fdc_softc *fdc = (void *)fd->sc_dv.dv_parent;
int s;
s = splbio();
int s;
s = splbio();
- fdcstatus(&fd->sc_dk.dk_dev, 0, "timeout");
+ fdcstatus(&fd->sc_dv, 0, "timeout");
if (fd->sc_q.b_actf)
fdc->sc_state++;
cyl != bp->b_cylin * fd->sc_type->step) {
#ifdef FD_DEBUG
if (fdc_debug)
- fdcstatus(&fd->sc_dk.dk_dev, 2, "seek failed");
+ fdcstatus(&fd->sc_dv, 2, "seek failed");
#endif
fdcretry(fdc);
goto loop;
if (fdc->sc_nstat != 7 || (st0 & 0xf8) != 0 || st1 != 0) {
#ifdef FD_DEBUG
if (fdc_debug) {
- fdcstatus(&fd->sc_dk.dk_dev, 7,
+ fdcstatus(&fd->sc_dv, 7,
bp->b_flags & B_READ
? "read failed" : "write failed");
printf("blkno %d nblks %d tc %d\n",
if (fdc->sc_nstat != 2 || (st0 & 0xf8) != 0x20 || cyl != 0) {
#ifdef FD_DEBUG
if (fdc_debug)
- fdcstatus(&fd->sc_dk.dk_dev, 2, "recalibrate failed");
+ fdcstatus(&fd->sc_dv, 2, "recalibrate failed");
#endif
fdcretry(fdc);
goto loop;
goto doseek;
default:
- fdcstatus(&fd->sc_dk.dk_dev, 0, "stray interrupt");
+ fdcstatus(&fd->sc_dv, 0, "stray interrupt");
return 1;
}
#ifdef DIAGNOSTIC
switch (cmd) {
case DIOCGDINFO:
- bzero(&fd->sc_dk.dk_label, sizeof(struct disklabel));
+ bzero(fd->sc_dk.dk_label, sizeof(struct disklabel));
- fd->sc_dk.dk_label.d_secpercyl = fd->sc_type->seccyl;
- fd->sc_dk.dk_label.d_type = DTYPE_FLOPPY;
- fd->sc_dk.dk_label.d_secsize = FDC_BSIZE;
+ fd->sc_dk.dk_label->d_secpercyl = fd->sc_type->seccyl;
+ fd->sc_dk.dk_label->d_type = DTYPE_FLOPPY;
+ fd->sc_dk.dk_label->d_secsize = FDC_BSIZE;
if (readdisklabel(dev, fdstrategy,
- &fd->sc_dk.dk_label,
- &fd->sc_dk.dk_cpulabel) != NULL)
+ fd->sc_dk.dk_label,
+ fd->sc_dk.dk_cpulabel) != NULL)
return EINVAL;
- *(struct disklabel *)addr = fd->sc_dk.dk_label;
+ *(struct disklabel *)addr = *(fd->sc_dk.dk_label);
return 0;
case DIOCWLABEL:
if ((flag & FWRITE) == 0)
return EBADF;
- error = setdisklabel(&fd->sc_dk.dk_label,
+ error = setdisklabel(fd->sc_dk.dk_label,
(struct disklabel *)addr, 0,
- &fd->sc_dk.dk_cpulabel);
+ fd->sc_dk.dk_cpulabel);
if (error)
return error;
error = writedisklabel(dev, fdstrategy,
- &fd->sc_dk.dk_label,
- &fd->sc_dk.dk_cpulabel);
+ fd->sc_dk.dk_label,
+ fd->sc_dk.dk_cpulabel);
return error;
case MTIOCTOP:
{
int i;
struct fdc_softc *fdc = (struct fdc_softc *)
- fd->sc_dk.dk_dev.dv_parent;
+ fd->sc_dv.dv_parent;
out_fdc(fdc, NE7CMD_DUMPREG);
fdcresult(fdc);
return 0;
case _IOW('f', 101, int):
- ((struct fdc_softc *)fd->sc_dk.dk_dev.dv_parent)->sc_cfg &=
+ ((struct fdc_softc *)fd->sc_dv.dv_parent)->sc_cfg &=
~CFG_THRHLD_MASK;
- ((struct fdc_softc *)fd->sc_dk.dk_dev.dv_parent)->sc_cfg |=
+ ((struct fdc_softc *)fd->sc_dv.dv_parent)->sc_cfg |=
(*(int *)addr & CFG_THRHLD_MASK);
- fdconf(fd->sc_dk.dk_dev.dv_parent);
+ fdconf(fd->sc_dv.dv_parent);
return 0;
case _IO('f', 102):
{
int i;
struct fdc_softc *fdc = (struct fdc_softc *)
- fd->sc_dk.dk_dev.dv_parent;
+ fd->sc_dv.dv_parent;
out_fdc(fdc, NE7CMD_SENSEI);
fdcresult(fdc);
printf("sensei(%d regs): <", fdc->sc_nstat);
int i;
/* Pull in the options flags. */
- sc->sc_options =
- ((ncr_sc->sc_dev.dv_cfdata->cf_flags | si_options) & SI_OPTIONS_MASK);
-
+ if (ca->ca_bustype == BUS_OBIO) {
/*
* XXX Interrupts and reselect don't work on the "sw".
- * I don't know why (yet). -- thorpej
+ * I don't know why (yet). Disable DMA by default, too.
+ * It's still a little dangerous.
*/
- if (ca->ca_bustype == BUS_OBIO)
- sc->sc_options &= ~(SI_DMA_INTR|SI_DO_RESELECT);
+ sc->sc_options = ncr_sc->sc_dev.dv_cfdata->cf_flags &
+ SI_OPTIONS_MASK;
+ } else
+ sc->sc_options =
+ ((ncr_sc->sc_dev.dv_cfdata->cf_flags | si_options) & SI_OPTIONS_MASK);
/* Map the controller registers. */
regs = (struct si_regs *)mapiodev(ra->ra_reg, 0,
-/* $NetBSD: xd.c,v 1.10 1995/12/11 12:40:20 pk Exp $ */
+/* $NetBSD: xd.c,v 1.11 1996/01/07 22:03:02 thorpej Exp $ */
/*
*
* x d . c x y l o g i c s 7 5 3 / 7 0 5 3 v m e / s m d d r i v e r
*
* author: Chuck Cranor <chuck@ccrc.wustl.edu>
- * id: $Id: xd.c,v 1.2 1995/12/15 13:56:27 deraadt Exp $
+ * id: $Id: xd.c,v 1.3 1996/01/12 20:20:51 deraadt Exp $
* started: 27-Feb-95
* references: [1] Xylogics Model 753 User's Manual
* part number: 166-753-001, Revision B, May 21, 1988.
xd_labeldata = b;
/* Required parameter for readdisklabel() */
- xd->sc_dk.dk_label.d_secsize = XDFM_BPS;
+ xd->sc_dk.dk_label->d_secsize = XDFM_BPS;
err = readdisklabel(MAKEDISKDEV(0, xd->sc_dev.dv_unit, RAW_PART),
xddummystrat,
- &xd->sc_dk.dk_label, &xd->sc_dk.dk_cpulabel);
+ xd->sc_dk.dk_label, xd->sc_dk.dk_cpulabel);
if (err) {
printf("%s: %s\n", xd->sc_dev.dv_xname, err);
return(XD_ERR_FAIL);
}
/* Ok, we have the label; fill in `pcyl' if there's SunOS magic */
- sdl = (struct sun_disklabel *)xd->sc_dk.dk_cpulabel.cd_block;
+ sdl = (struct sun_disklabel *)xd->sc_dk.dk_cpulabel->cd_block;
if (sdl->sl_magic == SUN_DKMAGIC)
xd->pcyl = sdl->sl_pcylinders;
else {
printf("%s: WARNING: no `pcyl' in disk label.\n",
xd->sc_dev.dv_xname);
- xd->pcyl = xd->sc_dk.dk_label.d_ncylinders +
- xd->sc_dk.dk_label.d_acylinders;
+ xd->pcyl = xd->sc_dk.dk_label->d_ncylinders +
+ xd->sc_dk.dk_label->d_acylinders;
printf("%s: WARNING: guessing pcyl=%d (ncyl+acyl)\n",
xd->sc_dev.dv_xname, xd->pcyl);
}
- xd->ncyl = xd->sc_dk.dk_label.d_ncylinders;
- xd->acyl = xd->sc_dk.dk_label.d_acylinders;
- xd->nhead = xd->sc_dk.dk_label.d_ntracks;
- xd->nsect = xd->sc_dk.dk_label.d_nsectors;
+ xd->ncyl = xd->sc_dk.dk_label->d_ncylinders;
+ xd->acyl = xd->sc_dk.dk_label->d_acylinders;
+ xd->nhead = xd->sc_dk.dk_label->d_ntracks;
+ xd->nsect = xd->sc_dk.dk_label->d_nsectors;
xd->sectpercyl = xd->nhead * xd->nsect;
- xd->sc_dk.dk_label.d_secsize = XDFM_BPS; /* not handled by
+ xd->sc_dk.dk_label->d_secsize = XDFM_BPS; /* not handled by
* sun->bsd */
return(XD_ERR_AOK);
}
struct dkbad *dkb;
struct bootpath *bp;
+ /*
+ * Always re-initialize the disk structure. We want statistics
+ * to start with a clean slate.
+ */
+ bzero(&xd->sc_dk, sizeof(xd->sc_dk));
+ xd->sc_dk.dk_driver = &xddkdriver;
+ xd->sc_dk.dk_name = xd->sc_dev.dv_xname;
+
/* if booting, init the xd_softc */
if (xa->booting) {
}
if (xa->booting) {
- xd->sc_dk.dk_driver = &xddkdriver; /* link in dkdriver */
-
/* restore bootpath! (do this via attach_args again?)*/
bp = bootpath_store(0, NULL);
if (bp && strcmp("xd", bp->name) == 0 &&
bootdv = &xd->sc_dev;
}
- dk_establish(&xd->sc_dk, &xd->sc_dev);
+ /* Attach the disk. */
+ disk_attach(&xd->sc_dk);
+
+ dk_establish(&xd->sc_dk, &xd->sc_dev); /* XXX */
done:
xd->state = newstate;
return 0;
case DIOCGDINFO: /* get disk label */
- bcopy(&xd->sc_dk.dk_label, addr, sizeof(struct disklabel));
+ bcopy(xd->sc_dk.dk_label, addr, sizeof(struct disklabel));
return 0;
case DIOCGPART: /* get partition info */
- ((struct partinfo *) addr)->disklab = &xd->sc_dk.dk_label;
+ ((struct partinfo *) addr)->disklab = xd->sc_dk.dk_label;
((struct partinfo *) addr)->part =
- &xd->sc_dk.dk_label.d_partitions[DISKPART(dev)];
+ &xd->sc_dk.dk_label->d_partitions[DISKPART(dev)];
return 0;
case DIOCSDINFO: /* set disk label */
if ((flag & FWRITE) == 0)
return EBADF;
- error = setdisklabel(&xd->sc_dk.dk_label,
+ error = setdisklabel(xd->sc_dk.dk_label,
(struct disklabel *) addr, /* xd->sc_dk.dk_openmask : */ 0,
- &xd->sc_dk.dk_cpulabel);
+ xd->sc_dk.dk_cpulabel);
if (error == 0) {
if (xd->state == XD_DRIVE_NOLABEL)
xd->state = XD_DRIVE_ONLINE;
case DIOCWDINFO: /* write disk label */
if ((flag & FWRITE) == 0)
return EBADF;
- error = setdisklabel(&xd->sc_dk.dk_label,
+ error = setdisklabel(xd->sc_dk.dk_label,
(struct disklabel *) addr, /* xd->sc_dk.dk_openmask : */ 0,
- &xd->sc_dk.dk_cpulabel);
+ xd->sc_dk.dk_cpulabel);
if (error == 0) {
if (xd->state == XD_DRIVE_NOLABEL)
xd->state = XD_DRIVE_ONLINE;
/* Simulate opening partition 0 so write succeeds. */
xd->sc_dk.dk_openmask |= (1 << 0);
error = writedisklabel(MAKEDISKDEV(major(dev), DISKUNIT(dev), RAW_PART),
- xdstrategy, &xd->sc_dk.dk_label,
- &xd->sc_dk.dk_cpulabel);
+ xdstrategy, xd->sc_dk.dk_label,
+ xd->sc_dk.dk_cpulabel);
xd->sc_dk.dk_openmask =
xd->sc_dk.dk_copenmask | xd->sc_dk.dk_bopenmask;
}
/* check for partition */
if (part != RAW_PART &&
- (part >= xd->sc_dk.dk_label.d_npartitions ||
- xd->sc_dk.dk_label.d_partitions[part].p_fstype == FS_UNUSED)) {
+ (part >= xd->sc_dk.dk_label->d_npartitions ||
+ xd->sc_dk.dk_label->d_partitions[part].p_fstype == FS_UNUSED)) {
return (ENXIO);
}
/* set open masks */
xdsc = xdcd.cd_devs[DISKUNIT(dev)];
part = DISKPART(dev);
- if (xdsc->sc_dk.dk_label.d_partitions[part].p_fstype != FS_SWAP)
+ if (xdsc->sc_dk.dk_label->d_partitions[part].p_fstype != FS_SWAP)
size = -1; /* only give valid size for swap partitions */
else
- size = xdsc->sc_dk.dk_label.d_partitions[part].p_size;
+ size = xdsc->sc_dk.dk_label->d_partitions[part].p_size;
if (xdclose(dev, 0, S_IFBLK) != 0)
return -1;
return size;
if (unit >= xdcd.cd_ndevs || (xd = xdcd.cd_devs[unit]) == 0 ||
bp->b_blkno < 0 ||
- (bp->b_bcount % xd->sc_dk.dk_label.d_secsize) != 0) {
+ (bp->b_bcount % xd->sc_dk.dk_label->d_secsize) != 0) {
bp->b_error = EINVAL;
goto bad;
}
* partition. Adjust transfer if needed, and signal errors or early
* completion. */
- if (bounds_check_with_label(bp, &xd->sc_dk.dk_label,
+ if (bounds_check_with_label(bp, xd->sc_dk.dk_label,
(xd->flags & XD_WLABEL) != 0) <= 0)
goto done;
if (xdc_startbuf(parent, xd, bp) != XD_ERR_AOK) {
return;
}
+
+ /* Instrumentation. */
+ disk_busy(&xd->sc_dk);
+
/* done! */
splx(s);
*/
block = bp->b_blkno + ((partno == RAW_PART) ? 0 :
- xdsc->sc_dk.dk_label.d_partitions[partno].p_offset);
+ xdsc->sc_dk.dk_label->d_partitions[partno].p_offset);
dbuf = kdvma_mapin(bp->b_data, bp->b_bcount, 0);
if (dbuf == NULL) { /* out of DVMA space */
(vm_offset_t)iorq->dbufbase,
(vm_offset_t)iorq->buf->b_un.b_addr,
iorq->buf->b_bcount);
+ disk_unbusy(&xdcsc->reqs[lcv].xd->sc_dk,
+ (xdcsc->reqs[lcv].buf->b_bcount -
+ xdcsc->reqs[lcv].buf->b_resid));
biodone(iorq->buf);
XDC_FREE(xdcsc, lcv); /* add to free list */
break;
(vm_offset_t) bp->b_un.b_addr,
bp->b_bcount);
XDC_FREE(xdcsc, rqno);
+ disk_unbusy(&iorq->xd->sc_dk,
+ (bp->b_bcount - bp->b_resid));
biodone(bp);
break;
case XD_SUB_WAIT:
-/* $NetBSD: xdvar.h,v 1.1 1995/06/26 23:07:19 pk Exp $ */
+/* $NetBSD: xdvar.h,v 1.2 1996/01/07 22:03:04 thorpej Exp $ */
/*
*
struct xd_softc {
struct device sc_dev; /* device struct, reqd by autoconf */
- struct dkdevice sc_dk; /* dkdevice: hook for iostat */
+ struct disk sc_dk; /* generic disk info */
struct xdc_softc *parent; /* parent */
u_short flags; /* flags */
u_short state; /* device state */
-/* $NetBSD: xy.c,v 1.2 1995/12/11 12:40:25 pk Exp $ */
+/* $NetBSD: xy.c,v 1.3 1996/01/07 22:03:05 thorpej Exp $ */
/*
*
* x y . c x y l o g i c s 4 5 0 / 4 5 1 s m d d r i v e r
*
* author: Chuck Cranor <chuck@ccrc.wustl.edu>
- * id: $Id: xy.c,v 1.2 1995/12/15 13:56:29 deraadt Exp $
+ * id: $Id: xy.c,v 1.3 1996/01/12 20:20:53 deraadt Exp $
* started: 14-Sep-95
* references: [1] Xylogics Model 753 User's Manual
* part number: 166-753-001, Revision B, May 21, 1988.
xy_labeldata = b;
/* Required parameter for readdisklabel() */
- xy->sc_dk.dk_label.d_secsize = XYFM_BPS;
+ xy->sc_dk.dk_label->d_secsize = XYFM_BPS;
err = readdisklabel(MAKEDISKDEV(0, xy->sc_dev.dv_unit, RAW_PART),
xydummystrat,
- &xy->sc_dk.dk_label, &xy->sc_dk.dk_cpulabel);
+ xy->sc_dk.dk_label, xy->sc_dk.dk_cpulabel);
if (err) {
printf("%s: %s\n", xy->sc_dev.dv_xname, err);
return(XY_ERR_FAIL);
}
/* Ok, we have the label; fill in `pcyl' if there's SunOS magic */
- sdl = (struct sun_disklabel *)xy->sc_dk.dk_cpulabel.cd_block;
+ sdl = (struct sun_disklabel *)xy->sc_dk.dk_cpulabel->cd_block;
if (sdl->sl_magic == SUN_DKMAGIC)
xy->pcyl = sdl->sl_pcylinders;
else {
printf("%s: WARNING: no `pcyl' in disk label.\n",
xy->sc_dev.dv_xname);
- xy->pcyl = xy->sc_dk.dk_label.d_ncylinders +
- xy->sc_dk.dk_label.d_acylinders;
+ xy->pcyl = xy->sc_dk.dk_label->d_ncylinders +
+ xy->sc_dk.dk_label->d_acylinders;
printf("%s: WARNING: guessing pcyl=%d (ncyl+acyl)\n",
xy->sc_dev.dv_xname, xy->pcyl);
}
- xy->ncyl = xy->sc_dk.dk_label.d_ncylinders;
- xy->acyl = xy->sc_dk.dk_label.d_acylinders;
- xy->nhead = xy->sc_dk.dk_label.d_ntracks;
- xy->nsect = xy->sc_dk.dk_label.d_nsectors;
+ xy->ncyl = xy->sc_dk.dk_label->d_ncylinders;
+ xy->acyl = xy->sc_dk.dk_label->d_acylinders;
+ xy->nhead = xy->sc_dk.dk_label->d_ntracks;
+ xy->nsect = xy->sc_dk.dk_label->d_nsectors;
xy->sectpercyl = xy->nhead * xy->nsect;
- xy->sc_dk.dk_label.d_secsize = XYFM_BPS; /* not handled by
+ xy->sc_dk.dk_label->d_secsize = XYFM_BPS; /* not handled by
* sun->bsd */
return(XY_ERR_AOK);
}
struct dkbad *dkb;
struct bootpath *bp;
+ /*
+ * Always re-initialize the disk structure. We want statistics
+ * to start with a clean slate.
+ */
+ bzero(&xy->sc_dk, sizeof(xy->sc_dk));
+ xy->sc_dk.dk_driver = &xydkdriver;
+ xy->sc_dk.dk_name = xy->sc_dev.dv_xname;
+
/* if booting, init the xy_softc */
if (xa->booting) {
}
if (xa->booting) {
- xy->sc_dk.dk_driver = &xydkdriver; /* link in dkdriver */
-
/* restore bootpath! (do this via attach_args again?)*/
bp = bootpath_store(0, NULL);
if (bp && strcmp("xy", bp->name) == 0 &&
bootdv = &xy->sc_dev;
}
- dk_establish(&xy->sc_dk, &xy->sc_dev);
+ /* Attach the disk. */
+ disk_attach(&xy->sc_dk);
+
+ dk_establish(&xy->sc_dk, &xy->sc_dev); /* XXX */
done:
xy->state = newstate;
return 0;
case DIOCGDINFO: /* get disk label */
- bcopy(&xy->sc_dk.dk_label, addr, sizeof(struct disklabel));
+ bcopy(xy->sc_dk.dk_label, addr, sizeof(struct disklabel));
return 0;
case DIOCGPART: /* get partition info */
- ((struct partinfo *) addr)->disklab = &xy->sc_dk.dk_label;
+ ((struct partinfo *) addr)->disklab = xy->sc_dk.dk_label;
((struct partinfo *) addr)->part =
- &xy->sc_dk.dk_label.d_partitions[DISKPART(dev)];
+ &xy->sc_dk.dk_label->d_partitions[DISKPART(dev)];
return 0;
case DIOCSDINFO: /* set disk label */
if ((flag & FWRITE) == 0)
return EBADF;
- error = setdisklabel(&xy->sc_dk.dk_label,
+ error = setdisklabel(xy->sc_dk.dk_label,
(struct disklabel *) addr, /* xy->sc_dk.dk_openmask : */ 0,
- &xy->sc_dk.dk_cpulabel);
+ xy->sc_dk.dk_cpulabel);
if (error == 0) {
if (xy->state == XY_DRIVE_NOLABEL)
xy->state = XY_DRIVE_ONLINE;
case DIOCWDINFO: /* write disk label */
if ((flag & FWRITE) == 0)
return EBADF;
- error = setdisklabel(&xy->sc_dk.dk_label,
+ error = setdisklabel(xy->sc_dk.dk_label,
(struct disklabel *) addr, /* xy->sc_dk.dk_openmask : */ 0,
- &xy->sc_dk.dk_cpulabel);
+ xy->sc_dk.dk_cpulabel);
if (error == 0) {
if (xy->state == XY_DRIVE_NOLABEL)
xy->state = XY_DRIVE_ONLINE;
/* Simulate opening partition 0 so write succeeds. */
xy->sc_dk.dk_openmask |= (1 << 0);
error = writedisklabel(MAKEDISKDEV(major(dev), DISKUNIT(dev), RAW_PART),
- xystrategy, &xy->sc_dk.dk_label,
- &xy->sc_dk.dk_cpulabel);
+ xystrategy, xy->sc_dk.dk_label,
+ xy->sc_dk.dk_cpulabel);
xy->sc_dk.dk_openmask =
xy->sc_dk.dk_copenmask | xy->sc_dk.dk_bopenmask;
}
/* check for partition */
if (part != RAW_PART &&
- (part >= xy->sc_dk.dk_label.d_npartitions ||
- xy->sc_dk.dk_label.d_partitions[part].p_fstype == FS_UNUSED)) {
+ (part >= xy->sc_dk.dk_label->d_npartitions ||
+ xy->sc_dk.dk_label->d_partitions[part].p_fstype == FS_UNUSED)) {
return (ENXIO);
}
/* set open masks */
xysc = xycd.cd_devs[DISKUNIT(dev)];
part = DISKPART(dev);
- if (xysc->sc_dk.dk_label.d_partitions[part].p_fstype != FS_SWAP)
+ if (xysc->sc_dk.dk_label->d_partitions[part].p_fstype != FS_SWAP)
size = -1; /* only give valid size for swap partitions */
else
- size = xysc->sc_dk.dk_label.d_partitions[part].p_size;
+ size = xysc->sc_dk.dk_label->d_partitions[part].p_size;
if (xyclose(dev, 0, S_IFBLK) != 0)
return -1;
return size;
if (unit >= xycd.cd_ndevs || (xy = xycd.cd_devs[unit]) == 0 ||
bp->b_blkno < 0 ||
- (bp->b_bcount % xy->sc_dk.dk_label.d_secsize) != 0) {
+ (bp->b_bcount % xy->sc_dk.dk_label->d_secsize) != 0) {
bp->b_error = EINVAL;
goto bad;
}
* partition. Adjust transfer if needed, and signal errors or early
* completion. */
- if (bounds_check_with_label(bp, &xy->sc_dk.dk_label,
+ if (bounds_check_with_label(bp, xy->sc_dk.dk_label,
(xy->flags & XY_WLABEL) != 0) <= 0)
goto done;
xyc_start(xy->parent, NULL);
+ /* Instrumentation. */
+ disk_busy(&xy->sc_dk);
+
/* done! */
splx(s);
*/
block = bp->b_blkno + ((partno == RAW_PART) ? 0 :
- xysc->sc_dk.dk_label.d_partitions[partno].p_offset);
+ xysc->sc_dk.dk_label->d_partitions[partno].p_offset);
dbuf = kdvma_mapin(bp->b_data, bp->b_bcount, 0);
if (dbuf == NULL) { /* out of DVMA space */
(vm_offset_t)iorq->buf->b_un.b_addr,
iorq->buf->b_bcount);
iorq->xy->xyq.b_actf = iorq->buf->b_actf;
+ disk_unbusy(&xycsc->reqs[lcv].xy->sc_dk,
+ (xycsc->reqs[lcv].buf->b_bcount -
+ xycsc->reqs[lcv].buf->b_resid));
biodone(iorq->buf);
iorq->mode = XY_SUB_FREE;
break;
bp->b_bcount);
iorq->mode = XY_SUB_FREE;
iorq->xy->xyq.b_actf = bp->b_actf;
+ disk_unbusy(&iorq->xy->sc_dk,
+ (bp->b_bcount - bp->b_resid));
biodone(bp);
break;
case XY_SUB_WAIT:
-/* $NetBSD: xyvar.h,v 1.1 1995/09/25 20:35:17 chuck Exp $ */
+/* $NetBSD: xyvar.h,v 1.2 1996/01/07 22:03:06 thorpej Exp $ */
/*
*
struct xy_softc {
struct device sc_dev; /* device struct, reqd by autoconf */
- struct dkdevice sc_dk; /* dkdevice: hook for iostat */
+ struct disk sc_dk; /* generic disk info */
struct xyc_softc *parent; /* parent */
u_short flags; /* flags */
u_short state; /* device state */
-/* $NetBSD: sun_disklabel.h,v 1.4 1995/03/28 18:20:12 jtc Exp $ */
+/* $NetBSD: sun_disklabel.h,v 1.6 1996/01/07 22:03:09 thorpej Exp $ */
/*
* Copyright (c) 1992, 1993
#define SUN_LABELOFFSET 128
#ifdef _KERNEL
-int sunos_dkioctl __P((struct dkdevice *, u_long, caddr_t, int));
+/* reads sun label in sector at [cp..cp+511] and sets *lp to BSD label */
+int sunos_disklabel __P((caddr_t, struct disklabel *)); /* true on success */
+
+/* compatability dk ioctl's */
+int sunos_dkioctl __P((struct disk *, u_long, caddr_t, int));
#endif
-/* $NetBSD: disksubr.c,v 1.9 1995/09/01 17:19:50 pk Exp $ */
+/* $NetBSD: disksubr.c,v 1.11 1996/01/07 22:03:12 thorpej Exp $ */
/*
* Copyright (c) 1994, 1995 Gordon W. Ross
int
dk_establish(dk, dev)
- struct dkdevice *dk;
+ struct disk *dk;
struct device *dev;
{
struct bootpath *bp = bootpath_store(0, NULL); /* restore bootpath! */
/* move this to compat/sunos */
int
-sun_dkioctl(dk, cmd, data, partition)
- struct dkdevice *dk;
+sunos_dkioctl(dk, cmd, data, partition)
+ struct disk *dk;
u_long cmd;
caddr_t data;
int partition;
case SUNOS_DKIOCGGEOM:
#define geom ((struct sun_dkgeom *)data)
bzero(data, sizeof(*geom));
- geom->sdkc_ncylinders = dk->dk_label.d_ncylinders;
- geom->sdkc_acylinders = dk->dk_label.d_acylinders;
- geom->sdkc_ntracks = dk->dk_label.d_ntracks;
- geom->sdkc_nsectors = dk->dk_label.d_nsectors;
- geom->sdkc_interleave = dk->dk_label.d_interleave;
- geom->sdkc_sparespercyl = dk->dk_label.d_sparespercyl;
- geom->sdkc_rpm = dk->dk_label.d_rpm;
+ geom->sdkc_ncylinders = dk->dk_label->d_ncylinders;
+ geom->sdkc_acylinders = dk->dk_label->d_acylinders;
+ geom->sdkc_ntracks = dk->dk_label->d_ntracks;
+ geom->sdkc_nsectors = dk->dk_label->d_nsectors;
+ geom->sdkc_interleave = dk->dk_label->d_interleave;
+ geom->sdkc_sparespercyl = dk->dk_label->d_sparespercyl;
+ geom->sdkc_rpm = dk->dk_label->d_rpm;
geom->sdkc_pcylinders =
- dk->dk_label.d_ncylinders + dk->dk_label.d_acylinders;
+ dk->dk_label->d_ncylinders + dk->dk_label->d_acylinders;
#undef geom
break;
case SUNOS_DKIOCINFO:
bzero(data, sizeof(struct sun_dkctlr));
break;
case SUNOS_DKIOCGPART:
- if (dk->dk_label.d_secpercyl == 0)
+ if (dk->dk_label->d_secpercyl == 0)
return (ERANGE); /* XXX */
- p = &dk->dk_label.d_partitions[partition];
- if (p->p_offset % dk->dk_label.d_secpercyl != 0)
+ p = &dk->dk_label->d_partitions[partition];
+ if (p->p_offset % dk->dk_label->d_secpercyl != 0)
return (ERANGE); /* XXX */
#define part ((struct sun_dkpart *)data)
- part->sdkp_cyloffset = p->p_offset / dk->dk_label.d_secpercyl;
+ part->sdkp_cyloffset = p->p_offset / dk->dk_label->d_secpercyl;
part->sdkp_nsectors = p->p_size;
#undef part
break;
-/* $NetBSD: xd.c,v 1.1 1995/10/30 20:58:17 gwr Exp $ */
+/* $NetBSD: xd.c,v 1.2 1996/01/07 22:03:17 thorpej Exp $ */
/*
*
* x d . c x y l o g i c s 7 5 3 / 7 0 5 3 v m e / s m d d r i v e r
*
* author: Chuck Cranor <chuck@ccrc.wustl.edu>
- * id: $Id: xd.c,v 1.1 1995/11/01 17:24:22 deraadt Exp $
+ * id: $Id: xd.c,v 1.2 1996/01/12 20:21:04 deraadt Exp $
* started: 27-Feb-95
* references: [1] Xylogics Model 753 User's Manual
* part number: 166-753-001, Revision B, May 21, 1988.
xd_labeldata = b;
/* Required parameter for readdisklabel() */
- xd->sc_dk.dk_label.d_secsize = XDFM_BPS;
+ xd->sc_dk.dk_label->d_secsize = XDFM_BPS;
err = readdisklabel(MAKEDISKDEV(0, xd->sc_dev.dv_unit, RAW_PART),
xddummystrat,
- &xd->sc_dk.dk_label, &xd->sc_dk.dk_cpulabel);
+ xd->sc_dk.dk_label, xd->sc_dk.dk_cpulabel);
if (err) {
printf("%s: %s\n", xd->sc_dev.dv_xname, err);
return(XD_ERR_FAIL);
}
/* Ok, we have the label; fill in `pcyl' if there's SunOS magic */
- sdl = (struct sun_disklabel *)xd->sc_dk.dk_cpulabel.cd_block;
+ sdl = (struct sun_disklabel *)xd->sc_dk.dk_cpulabel->cd_block;
if (sdl->sl_magic == SUN_DKMAGIC)
xd->pcyl = sdl->sl_pcyl;
else {
printf("%s: WARNING: no `pcyl' in disk label.\n",
xd->sc_dev.dv_xname);
- xd->pcyl = xd->sc_dk.dk_label.d_ncylinders +
- xd->sc_dk.dk_label.d_acylinders;
+ xd->pcyl = xd->sc_dk.dk_label->d_ncylinders +
+ xd->sc_dk.dk_label->d_acylinders;
printf("%s: WARNING: guessing pcyl=%d (ncyl+acyl)\n",
xd->sc_dev.dv_xname, xd->pcyl);
}
- xd->ncyl = xd->sc_dk.dk_label.d_ncylinders;
- xd->acyl = xd->sc_dk.dk_label.d_acylinders;
- xd->nhead = xd->sc_dk.dk_label.d_ntracks;
- xd->nsect = xd->sc_dk.dk_label.d_nsectors;
+ xd->ncyl = xd->sc_dk.dk_label->d_ncylinders;
+ xd->acyl = xd->sc_dk.dk_label->d_acylinders;
+ xd->nhead = xd->sc_dk.dk_label->d_ntracks;
+ xd->nsect = xd->sc_dk.dk_label->d_nsectors;
xd->sectpercyl = xd->nhead * xd->nsect;
- xd->sc_dk.dk_label.d_secsize = XDFM_BPS; /* not handled by
+ xd->sc_dk.dk_label->d_secsize = XDFM_BPS; /* not handled by
* sun->bsd */
return(XD_ERR_AOK);
}
struct dkbad *dkb;
struct bootpath *bp;
+ /*
+ * Always re-initialize the disk structure. We want statistics
+ * to start with a clean slate.
+ */
+ bzero(&xd->sc_dk, sizeof(xd->sc_dk));
+ xd->sc_dk.dk_driver = &xddkdriver;
+ xd->sc_dk.dk_name = xd->sc_dev.dv_xname;
+
/* if booting, init the xd_softc */
if (xa->booting) {
bcopy(xa->dvmabuf, &xd->dkb, XDFM_BPS);
}
- if (xa->booting) {
- xd->sc_dk.dk_driver = &xddkdriver; /* link in dkdriver */
- }
+ /* Attach the disk. */
+ disk_attach(&xd->sc_dk);
/* XXX - Where is this and what does it do? -gwr */
dk_establish(&xd->sc_dk, &xd->sc_dev);
return 0;
case DIOCGDINFO: /* get disk label */
- bcopy(&xd->sc_dk.dk_label, addr, sizeof(struct disklabel));
+ bcopy(xd->sc_dk.dk_label, addr, sizeof(struct disklabel));
return 0;
case DIOCGPART: /* get partition info */
- ((struct partinfo *) addr)->disklab = &xd->sc_dk.dk_label;
+ ((struct partinfo *) addr)->disklab = xd->sc_dk.dk_label;
((struct partinfo *) addr)->part =
- &xd->sc_dk.dk_label.d_partitions[DISKPART(dev)];
+ &xd->sc_dk.dk_label->d_partitions[DISKPART(dev)];
return 0;
case DIOCSDINFO: /* set disk label */
if ((flag & FWRITE) == 0)
return EBADF;
- error = setdisklabel(&xd->sc_dk.dk_label,
+ error = setdisklabel(xd->sc_dk.dk_label,
(struct disklabel *) addr, /* xd->sc_dk.dk_openmask : */ 0,
- &xd->sc_dk.dk_cpulabel);
+ xd->sc_dk.dk_cpulabel);
if (error == 0) {
if (xd->state == XD_DRIVE_NOLABEL)
xd->state = XD_DRIVE_ONLINE;
case DIOCWDINFO: /* write disk label */
if ((flag & FWRITE) == 0)
return EBADF;
- error = setdisklabel(&xd->sc_dk.dk_label,
+ error = setdisklabel(xd->sc_dk.dk_label,
(struct disklabel *) addr, /* xd->sc_dk.dk_openmask : */ 0,
- &xd->sc_dk.dk_cpulabel);
+ xd->sc_dk.dk_cpulabel);
if (error == 0) {
if (xd->state == XD_DRIVE_NOLABEL)
xd->state = XD_DRIVE_ONLINE;
/* Simulate opening partition 0 so write succeeds. */
xd->sc_dk.dk_openmask |= (1 << 0);
error = writedisklabel(MAKEDISKDEV(major(dev), DISKUNIT(dev), RAW_PART),
- xdstrategy, &xd->sc_dk.dk_label,
- &xd->sc_dk.dk_cpulabel);
+ xdstrategy, xd->sc_dk.dk_label,
+ xd->sc_dk.dk_cpulabel);
xd->sc_dk.dk_openmask =
xd->sc_dk.dk_copenmask | xd->sc_dk.dk_bopenmask;
}
/* check for partition */
if (part != RAW_PART &&
- (part >= xd->sc_dk.dk_label.d_npartitions ||
- xd->sc_dk.dk_label.d_partitions[part].p_fstype == FS_UNUSED)) {
+ (part >= xd->sc_dk.dk_label->d_npartitions ||
+ xd->sc_dk.dk_label->d_partitions[part].p_fstype == FS_UNUSED)) {
return (ENXIO);
}
/* set open masks */
xdsc = xdcd.cd_devs[DISKUNIT(dev)];
part = DISKPART(dev);
- if (xdsc->sc_dk.dk_label.d_partitions[part].p_fstype != FS_SWAP)
+ if (xdsc->sc_dk.dk_label->d_partitions[part].p_fstype != FS_SWAP)
size = -1; /* only give valid size for swap partitions */
else
- size = xdsc->sc_dk.dk_label.d_partitions[part].p_size;
+ size = xdsc->sc_dk.dk_label->d_partitions[part].p_size;
if (xdclose(dev, 0, S_IFBLK) != 0)
return -1;
return size;
if (unit >= xdcd.cd_ndevs || (xd = xdcd.cd_devs[unit]) == 0 ||
bp->b_blkno < 0 ||
- (bp->b_bcount % xd->sc_dk.dk_label.d_secsize) != 0) {
+ (bp->b_bcount % xd->sc_dk.dk_label->d_secsize) != 0) {
bp->b_error = EINVAL;
goto bad;
}
* partition. Adjust transfer if needed, and signal errors or early
* completion. */
- if (bounds_check_with_label(bp, &xd->sc_dk.dk_label,
+ if (bounds_check_with_label(bp, xd->sc_dk.dk_label,
(xd->flags & XD_WLABEL) != 0) <= 0)
goto done;
if (xdc_startbuf(parent, xd, bp) != XD_ERR_AOK) {
return;
}
+
+ /* Instrumentation. */
+ disk_busy(&xd->sc_dk);
+
/* done! */
splx(s);
*/
block = bp->b_blkno + ((partno == RAW_PART) ? 0 :
- xdsc->sc_dk.dk_label.d_partitions[partno].p_offset);
+ xdsc->sc_dk.dk_label->d_partitions[partno].p_offset);
dbuf = dvma_mapin(bp->b_data, bp->b_bcount);
if (dbuf == NULL) { /* out of DVMA space */
/* Sun3: map/unmap regardless of B_PHYS */
dvma_mapout(iorq->dbufbase,
iorq->buf->b_bcount);
+ disk_unbusy(&iorq->xd->sc_dk,
+ (iorq->buf->b_bcount - iorq->buf->b_resid));
biodone(iorq->buf);
XDC_FREE(xdcsc, lcv); /* add to free list */
break;
dvma_mapout(iorq->dbufbase,
iorq->buf->b_bcount);
XDC_FREE(xdcsc, rqno);
+ disk_unbusy(&iorq->xd->sc_dk,
+ (bp->b_bcount - bp->b_resid));
biodone(bp);
break;
case XD_SUB_WAIT:
-/* $NetBSD: xdvar.h,v 1.1 1995/10/30 20:58:19 gwr Exp $ */
+/* $NetBSD: xdvar.h,v 1.2 1996/01/07 22:03:18 thorpej Exp $ */
/*
*
struct xd_softc {
struct device sc_dev; /* device struct, reqd by autoconf */
- struct dkdevice sc_dk; /* dkdevice: hook for iostat */
+ struct disk sc_dk; /* generic disk info */
struct xdc_softc *parent; /* parent */
u_short flags; /* flags */
u_short state; /* device state */
-/* $NetBSD: xy.c,v 1.1 1995/10/30 20:58:21 gwr Exp $ */
+/* $NetBSD: xy.c,v 1.2 1996/01/07 22:03:20 thorpej Exp $ */
/*
*
* x y . c x y l o g i c s 4 5 0 / 4 5 1 s m d d r i v e r
*
* author: Chuck Cranor <chuck@ccrc.wustl.edu>
- * id: $Id: xy.c,v 1.1 1995/11/01 17:24:25 deraadt Exp $
+ * id: $Id: xy.c,v 1.2 1996/01/12 20:21:06 deraadt Exp $
* started: 14-Sep-95
* references: [1] Xylogics Model 753 User's Manual
* part number: 166-753-001, Revision B, May 21, 1988.
xy_labeldata = b;
/* Required parameter for readdisklabel() */
- xy->sc_dk.dk_label.d_secsize = XYFM_BPS;
+ xy->sc_dk.dk_label->d_secsize = XYFM_BPS;
err = readdisklabel(MAKEDISKDEV(0, xy->sc_dev.dv_unit, RAW_PART),
xydummystrat,
- &xy->sc_dk.dk_label, &xy->sc_dk.dk_cpulabel);
+ xy->sc_dk.dk_label, xy->sc_dk.dk_cpulabel);
if (err) {
printf("%s: %s\n", xy->sc_dev.dv_xname, err);
return(XY_ERR_FAIL);
}
/* Ok, we have the label; fill in `pcyl' if there's SunOS magic */
- sdl = (struct sun_disklabel *)xy->sc_dk.dk_cpulabel.cd_block;
+ sdl = (struct sun_disklabel *)xy->sc_dk.dk_cpulabel->cd_block;
if (sdl->sl_magic == SUN_DKMAGIC)
xy->pcyl = sdl->sl_pcyl;
else {
printf("%s: WARNING: no `pcyl' in disk label.\n",
xy->sc_dev.dv_xname);
- xy->pcyl = xy->sc_dk.dk_label.d_ncylinders +
- xy->sc_dk.dk_label.d_acylinders;
+ xy->pcyl = xy->sc_dk.dk_label->d_ncylinders +
+ xy->sc_dk.dk_label->d_acylinders;
printf("%s: WARNING: guessing pcyl=%d (ncyl+acyl)\n",
xy->sc_dev.dv_xname, xy->pcyl);
}
- xy->ncyl = xy->sc_dk.dk_label.d_ncylinders;
- xy->acyl = xy->sc_dk.dk_label.d_acylinders;
- xy->nhead = xy->sc_dk.dk_label.d_ntracks;
- xy->nsect = xy->sc_dk.dk_label.d_nsectors;
+ xy->ncyl = xy->sc_dk.dk_label->d_ncylinders;
+ xy->acyl = xy->sc_dk.dk_label->d_acylinders;
+ xy->nhead = xy->sc_dk.dk_label->d_ntracks;
+ xy->nsect = xy->sc_dk.dk_label->d_nsectors;
xy->sectpercyl = xy->nhead * xy->nsect;
- xy->sc_dk.dk_label.d_secsize = XYFM_BPS; /* not handled by
+ xy->sc_dk.dk_label->d_secsize = XYFM_BPS; /* not handled by
* sun->bsd */
return(XY_ERR_AOK);
}
struct dkbad *dkb;
struct bootpath *bp;
+ /*
+ * Always re-initialize the disk structure. We want statistics
+ * to start with a clean slate.
+ */
+ bzero(&xy->sc_dk, sizeof(xy->sc_dk));
+ xy->sc_dk.dk_driver = &xydkdriver;
+ xy->sc_dk.dk_name = xy->sc_dev.dv_xname;
+
/* if booting, init the xy_softc */
if (xa->booting) {
bcopy(xa->dvmabuf, &xy->dkb, XYFM_BPS);
}
- if (xa->booting) {
- xy->sc_dk.dk_driver = &xydkdriver; /* link in dkdriver */
- }
+ /* Attach the disk. */
+ disk_attach(&xy->sc_dk);
- dk_establish(&xy->sc_dk, &xy->sc_dev);
+ dk_establish(&xy->sc_dk, &xy->sc_dev); /* XXX */
done:
xy->state = newstate;
return 0;
case DIOCGDINFO: /* get disk label */
- bcopy(&xy->sc_dk.dk_label, addr, sizeof(struct disklabel));
+ bcopy(xy->sc_dk.dk_label, addr, sizeof(struct disklabel));
return 0;
case DIOCGPART: /* get partition info */
- ((struct partinfo *) addr)->disklab = &xy->sc_dk.dk_label;
+ ((struct partinfo *) addr)->disklab = xy->sc_dk.dk_label;
((struct partinfo *) addr)->part =
- &xy->sc_dk.dk_label.d_partitions[DISKPART(dev)];
+ &xy->sc_dk.dk_label->d_partitions[DISKPART(dev)];
return 0;
case DIOCSDINFO: /* set disk label */
if ((flag & FWRITE) == 0)
return EBADF;
- error = setdisklabel(&xy->sc_dk.dk_label,
+ error = setdisklabel(xy->sc_dk.dk_label,
(struct disklabel *) addr, /* xy->sc_dk.dk_openmask : */ 0,
- &xy->sc_dk.dk_cpulabel);
+ xy->sc_dk.dk_cpulabel);
if (error == 0) {
if (xy->state == XY_DRIVE_NOLABEL)
xy->state = XY_DRIVE_ONLINE;
case DIOCWDINFO: /* write disk label */
if ((flag & FWRITE) == 0)
return EBADF;
- error = setdisklabel(&xy->sc_dk.dk_label,
+ error = setdisklabel(xy->sc_dk.dk_label,
(struct disklabel *) addr, /* xy->sc_dk.dk_openmask : */ 0,
- &xy->sc_dk.dk_cpulabel);
+ xy->sc_dk.dk_cpulabel);
if (error == 0) {
if (xy->state == XY_DRIVE_NOLABEL)
xy->state = XY_DRIVE_ONLINE;
/* Simulate opening partition 0 so write succeeds. */
xy->sc_dk.dk_openmask |= (1 << 0);
error = writedisklabel(MAKEDISKDEV(major(dev), DISKUNIT(dev), RAW_PART),
- xystrategy, &xy->sc_dk.dk_label,
- &xy->sc_dk.dk_cpulabel);
+ xystrategy, xy->sc_dk.dk_label,
+ xy->sc_dk.dk_cpulabel);
xy->sc_dk.dk_openmask =
xy->sc_dk.dk_copenmask | xy->sc_dk.dk_bopenmask;
}
/* check for partition */
if (part != RAW_PART &&
- (part >= xy->sc_dk.dk_label.d_npartitions ||
- xy->sc_dk.dk_label.d_partitions[part].p_fstype == FS_UNUSED)) {
+ (part >= xy->sc_dk.dk_label->d_npartitions ||
+ xy->sc_dk.dk_label->d_partitions[part].p_fstype == FS_UNUSED)) {
return (ENXIO);
}
/* set open masks */
xysc = xycd.cd_devs[DISKUNIT(dev)];
part = DISKPART(dev);
- if (xysc->sc_dk.dk_label.d_partitions[part].p_fstype != FS_SWAP)
+ if (xysc->sc_dk.dk_label->d_partitions[part].p_fstype != FS_SWAP)
size = -1; /* only give valid size for swap partitions */
else
- size = xysc->sc_dk.dk_label.d_partitions[part].p_size;
+ size = xysc->sc_dk.dk_label->d_partitions[part].p_size;
if (xyclose(dev, 0, S_IFBLK) != 0)
return -1;
return size;
if (unit >= xycd.cd_ndevs || (xy = xycd.cd_devs[unit]) == 0 ||
bp->b_blkno < 0 ||
- (bp->b_bcount % xy->sc_dk.dk_label.d_secsize) != 0) {
+ (bp->b_bcount % xy->sc_dk.dk_label->d_secsize) != 0) {
bp->b_error = EINVAL;
goto bad;
}
* partition. Adjust transfer if needed, and signal errors or early
* completion. */
- if (bounds_check_with_label(bp, &xy->sc_dk.dk_label,
+ if (bounds_check_with_label(bp, xy->sc_dk.dk_label,
(xy->flags & XY_WLABEL) != 0) <= 0)
goto done;
xyc_start(xy->parent, NULL);
+ /* Instrumentation. */
+ disk_busy(&xy->sc_dk);
+
/* done! */
splx(s);
*/
block = bp->b_blkno + ((partno == RAW_PART) ? 0 :
- xysc->sc_dk.dk_label.d_partitions[partno].p_offset);
+ xysc->sc_dk.dk_label->d_partitions[partno].p_offset);
dbuf = dvma_mapin(bp->b_data, bp->b_bcount);
if (dbuf == NULL) { /* out of DVMA space */
iorq->buf->b_bcount);
iorq->xy->xyq.b_actf =
iorq->buf->b_actf;
+ disk_unbusy(&iorq->xy->sc_dk,
+ (iorq->buf->b_bcount - iorq->buf->b_resid));
biodone(iorq->buf);
iorq->mode = XY_SUB_FREE;
break;
iorq->buf->b_bcount);
iorq->mode = XY_SUB_FREE;
iorq->xy->xyq.b_actf = bp->b_actf;
+ disk_unbusy(&iorq->xy->sc_dk,
+ (bp->b_bcount - bp->b_resid));
biodone(bp);
break;
case XY_SUB_WAIT:
-/* $NetBSD: xyvar.h,v 1.1 1995/10/30 20:58:23 gwr Exp $ */
+/* $NetBSD: xyvar.h,v 1.2 1996/01/07 22:03:22 thorpej Exp $ */
/*
*
struct xy_softc {
struct device sc_dev; /* device struct, reqd by autoconf */
- struct dkdevice sc_dk; /* dkdevice: hook for iostat */
+ struct disk sc_dk; /* generic disk info */
struct xyc_softc *parent; /* parent */
u_short flags; /* flags */
u_short state; /* device state */
-/* $NetBSD: ccd.c,v 1.22 1995/12/08 19:13:26 thorpej Exp $ */
+/* $NetBSD: ccd.c,v 1.23 1996/01/07 22:03:28 thorpej Exp $ */
/*
* Copyright (c) 1995 Jason R. Thorpe.
#include <sys/systm.h>
#include <sys/proc.h>
#include <sys/errno.h>
-#include <sys/dkstat.h>
#include <sys/buf.h>
#include <sys/malloc.h>
#include <sys/namei.h>
numccd = num;
bzero(ccd_softc, num * sizeof(struct ccd_softc));
bzero(ccddevs, num * sizeof(struct ccddevice));
-
- /* XXX: is this necessary? */
- for (i = 0; i < numccd; ++i)
- ccddevs[i].ccd_dk = -1;
}
static int
printf("ccdinit: unit %d\n", ccd->ccd_unit);
#endif
-#ifdef WORKING_DISK_STATISTICS /* XXX !! */
- cs->sc_dk = ccd->ccd_dk;
-#endif
cs->sc_size = 0;
cs->sc_ileave = ccd->ccd_interleave;
cs->sc_nccdisks = ccd->ccd_ndev;
+ sprintf(cs->sc_xname, "ccd%d", ccd->ccd_unit); /* XXX */
/* Allocate space for the component info. */
cs->sc_cinfo = malloc(cs->sc_nccdisks * sizeof(struct ccdcinfo),
MAXPATHLEN, &ci->ci_pathlen)) {
#ifdef DEBUG
if (ccddebug & (CCDB_FOLLOW|CCDB_INIT))
- printf("ccd%d: can't copy path, error = %d\n",
- ccd->ccd_unit, error);
+ printf("%s: can't copy path, error = %d\n",
+ cs->sc_xname, error);
#endif
free(cs->sc_cinfo, M_DEVBUF);
return (error);
if (error = VOP_GETATTR(vp, &va, p->p_ucred, p)) {
#ifdef DEBUG
if (ccddebug & (CCDB_FOLLOW|CCDB_INIT))
- printf("ccd%d: %s: getattr failed %s = %d\n",
- ccd->ccd_unit, ci->ci_path,
+ printf("%s: %s: getattr failed %s = %d\n",
+ cs->sc_xname, ci->ci_path,
"error", error);
#endif
free(ci->ci_path, M_DEVBUF);
FREAD, p->p_ucred, p)) {
#ifdef DEBUG
if (ccddebug & (CCDB_FOLLOW|CCDB_INIT))
- printf("ccd%d: %s: ioctl failed, error = %d\n",
- ccd->ccd_unit, ci->ci_path, error);
+ printf("%s: %s: ioctl failed, error = %d\n",
+ cs->sc_xname, ci->ci_path, error);
#endif
free(ci->ci_path, M_DEVBUF);
free(cs->sc_cinfo, M_DEVBUF);
} else {
#ifdef DEBUG
if (ccddebug & (CCDB_FOLLOW|CCDB_INIT))
- printf("ccd%d: %s: incorrect partition type\n",
- ccd->ccd_unit, ci->ci_path);
+ printf("%s: %s: incorrect partition type\n",
+ cs->sc_xname, ci->ci_path);
#endif
free(ci->ci_path, M_DEVBUF);
free(cs->sc_cinfo, M_DEVBUF);
if (size == 0) {
#ifdef DEBUG
if (ccddebug & (CCDB_FOLLOW|CCDB_INIT))
- printf("ccd%d: %s: size == 0\n",
- ccd->ccd_unit, ci->ci_path);
+ printf("%s: %s: size == 0\n",
+ cs->sc_xname, ci->ci_path);
#endif
free(ci->ci_path, M_DEVBUF);
free(cs->sc_cinfo, M_DEVBUF);
(cs->sc_ileave < (maxsecsize / DEV_BSIZE))) {
#ifdef DEBUG
if (ccddebug & (CCDB_FOLLOW|CCDB_INIT))
- printf("ccd%d: interleave must be at least %d\n",
- ccd->ccd_unit, (maxsecsize / DEV_BSIZE));
+ printf("%s: interleave must be at least %d\n",
+ cs->sc_xname, (maxsecsize / DEV_BSIZE));
#endif
free(ci->ci_path, M_DEVBUF);
free(cs->sc_cinfo, M_DEVBUF);
ccg->ccg_nsectors = 1024 * (1024 / ccg->ccg_secsize);
ccg->ccg_ncylinders = cs->sc_size / ccg->ccg_nsectors;
-#ifdef WORKING_DISK_STATISTICS /* XXX !! */
- if (ccd->ccd_dk >= 0)
- dk_wpms[ccd->ccd_dk] = 32 * (60 * DEV_BSIZE / 2); /* XXX */
-#endif
-
cs->sc_flags |= CCDF_INITED;
cs->sc_cflags = ccd->ccd_flags; /* So we can find out later... */
cs->sc_unit = ccd->ccd_unit;
+
return (0);
}
if (error = ccdlock(cs))
return (error);
- lp = &cs->sc_dkdev.dk_label;
+ lp = cs->sc_dkdev.dk_label;
part = DISKPART(dev);
pmask = (1 << part);
if (bp->b_bcount == 0)
goto done;
- lp = &cs->sc_dkdev.dk_label;
+ lp = cs->sc_dkdev.dk_label;
/*
* Do bounds checking and adjust transfer. If there's an
printf("ccdstart(%x, %x)\n", cs, bp);
#endif
-#ifdef WORKING_DISK_STATISTICS /* XXX !! */
- /*
- * Instrumentation (not very meaningful)
- */
- cs->sc_nactive++;
- if (cs->sc_dk >= 0) {
- dk_busy |= 1 << cs->sc_dk;
- dk_xfer[cs->sc_dk]++;
- dk_wds[cs->sc_dk] += bp->b_bcount >> 6;
- }
-#endif
+ /* Instrumentation. */
+ disk_busy(&cs->sc_dkdev);
/*
* Translate the partition-relative block number to an absolute.
*/
bn = bp->b_blkno;
if (DISKPART(bp->b_dev) != RAW_PART) {
- pp = &cs->sc_dkdev.dk_label.d_partitions[DISKPART(bp->b_dev)];
+ pp = &cs->sc_dkdev.dk_label->d_partitions[DISKPART(bp->b_dev)];
bn += pp->p_offset;
}
/*
* Request is done for better or worse, wakeup the top half.
*/
-#ifdef WORKING_DISK_STATISTICS /* XXX !! */
- --cs->sc_nactive;
-#ifdef DIAGNOSTIC
- if (cs->sc_nactive < 0)
- panic("ccdintr: ccd%d: sc_nactive < 0", cs->sc_unit);
-#endif
-
- if (cs->sc_nactive == 0 && cs->sc_dk >= 0)
- dk_busy &= ~(1 << cs->sc_dk);
-#endif
if (bp->b_flags & B_ERROR)
bp->b_resid = bp->b_bcount;
+ disk_unbusy(&cs->sc_dkdev, (bp->b_bcount - bp->b_resid));
biodone(bp);
}
{
register struct buf *bp = cbp->cb_obp;
register int unit = cbp->cb_unit;
+ struct ccd_softc *cs = &ccd_softc[unit];
int count, s;
s = splbio();
bp->b_flags |= B_ERROR;
bp->b_error = cbp->cb_buf.b_error ? cbp->cb_buf.b_error : EIO;
#ifdef DEBUG
- printf("ccd%d: error %d on component %d\n",
- unit, bp->b_error, cbp->cb_comp);
+ printf("%s: error %d on component %d\n",
+ cs->sc_xname, bp->b_error, cbp->cb_comp);
#endif
}
count = cbp->cb_buf.b_bcount;
struct ccddevice ccd;
char **cpp;
struct vnode **vpp;
-#ifdef WORKING_DISK_STATISTICS /* XXX !! */
- extern int dkn;
-#endif
if (unit >= numccd)
return (ENXIO);
ccd.ccd_vpp = vpp;
ccd.ccd_ndev = ccio->ccio_ndisks;
-#ifdef WORKING_DISK_STATISTICS /* XXX !! */
- /*
- * Assign disk index first so that init routine
- * can use it (saves having the driver drag around
- * the ccddevice pointer just to set up the dk_*
- * info in the open routine).
- */
- if (dkn < DK_NDRIVE)
- ccd.ccd_dk = dkn++;
- else
- ccd.ccd_dk = -1;
-#endif
-
/*
* Initialize the ccd. Fills in the softc for us.
*/
if (error = ccdinit(&ccd, cpp, p)) {
-#ifdef WORKING_DISK_STATISTICS /* XXX !! */
- if (ccd.ccd_dk >= 0)
- --dkn;
-#endif
for (j = 0; j < lookedup; ++j)
(void)vn_close(vpp[j], FREAD|FWRITE,
p->p_ucred, p);
/*
* The ccd has been successfully initialized, so
- * we can place it into the array and read the disklabel.
+ * we can place it into the array. Don't try to
+ * read the disklabel until the disk has been attached,
+ * because space for the disklabel is allocated
+ * in disk_attach();
*/
bcopy(&ccd, &ccddevs[unit], sizeof(ccd));
ccio->ccio_unit = unit;
ccio->ccio_size = cs->sc_size;
+
+ /* Attach the disk. */
+ cs->sc_dkdev.dk_name = cs->sc_xname;
+ disk_attach(&cs->sc_dkdev);
+
+ /* Try and read the disklabel. */
ccdgetdisklabel(dev);
ccdunlock(cs);
*/
free(ccddevs[unit].ccd_cpp, M_DEVBUF);
free(ccddevs[unit].ccd_vpp, M_DEVBUF);
- ccd.ccd_dk = -1;
bcopy(&ccd, &ccddevs[unit], sizeof(ccd));
+ /* Detatch the disk. */
+ disk_detatch(&cs->sc_dkdev);
+
/* This must be atomic. */
s = splhigh();
ccdunlock(cs);
if ((cs->sc_flags & CCDF_INITED) == 0)
return (ENXIO);
- *(struct disklabel *)data = cs->sc_dkdev.dk_label;
+ *(struct disklabel *)data = *(cs->sc_dkdev.dk_label);
break;
case DIOCGPART:
if ((cs->sc_flags & CCDF_INITED) == 0)
return (ENXIO);
- ((struct partinfo *)data)->disklab = &cs->sc_dkdev.dk_label;
+ ((struct partinfo *)data)->disklab = cs->sc_dkdev.dk_label;
((struct partinfo *)data)->part =
- &cs->sc_dkdev.dk_label.d_partitions[DISKPART(dev)];
+ &cs->sc_dkdev.dk_label->d_partitions[DISKPART(dev)];
break;
case DIOCWDINFO:
cs->sc_flags |= CCDF_LABELLING;
- error = setdisklabel(&cs->sc_dkdev.dk_label,
- (struct disklabel *)data, 0, &cs->sc_dkdev.dk_cpulabel);
+ error = setdisklabel(cs->sc_dkdev.dk_label,
+ (struct disklabel *)data, 0, cs->sc_dkdev.dk_cpulabel);
if (error == 0) {
if (cmd == DIOCWDINFO)
error = writedisklabel(CCDLABELDEV(dev),
- ccdstrategy, &cs->sc_dkdev.dk_label,
- &cs->sc_dkdev.dk_cpulabel);
+ ccdstrategy, cs->sc_dkdev.dk_label,
+ cs->sc_dkdev.dk_cpulabel);
}
cs->sc_flags &= ~CCDF_LABELLING;
if ((cs->sc_flags & CCDF_INITED) == 0)
return (-1);
- if (cs->sc_dkdev.dk_label.d_partitions[part].p_fstype != FS_SWAP)
+ if (cs->sc_dkdev.dk_label->d_partitions[part].p_fstype != FS_SWAP)
size = -1;
else
- size = cs->sc_dkdev.dk_label.d_partitions[part].p_size;
+ size = cs->sc_dkdev.dk_label->d_partitions[part].p_size;
if (ccdclose(dev, 0, S_IFBLK, curproc))
return (-1);
int unit = ccdunit(dev);
struct ccd_softc *cs = &ccd_softc[unit];
char *errstring;
- struct disklabel *lp = &cs->sc_dkdev.dk_label;
- struct cpu_disklabel *clp = &cs->sc_dkdev.dk_cpulabel;
+ struct disklabel *lp = cs->sc_dkdev.dk_label;
+ struct cpu_disklabel *clp = cs->sc_dkdev.dk_cpulabel;
struct ccdgeom *ccg = &cs->sc_geom;
bzero(lp, sizeof(*lp));
lp->d_magic = DISKMAGIC;
lp->d_magic2 = DISKMAGIC;
- lp->d_checksum = dkcksum(&cs->sc_dkdev.dk_label);
+ lp->d_checksum = dkcksum(cs->sc_dkdev.dk_label);
/*
* Call the generic disklabel extraction routine.
*/
if (errstring = readdisklabel(CCDLABELDEV(dev), ccdstrategy,
- &cs->sc_dkdev.dk_label, &cs->sc_dkdev.dk_cpulabel))
+ cs->sc_dkdev.dk_label, cs->sc_dkdev.dk_cpulabel))
ccdmakedisklabel(cs);
#ifdef DEBUG
/* It's actually extremely common to have unlabeled ccds. */
if (ccddebug & CCDB_LABEL)
if (errstring != NULL)
- printf("ccd%d: %s\n", unit, errstring);
+ printf("%s: %s\n", cs->sc_xname, errstring);
#endif
}
ccdmakedisklabel(cs)
struct ccd_softc *cs;
{
- struct disklabel *lp = &cs->sc_dkdev.dk_label;
+ struct disklabel *lp = cs->sc_dkdev.dk_label;
/*
* For historical reasons, if there's no disklabel present
-/* $NetBSD: ccdvar.h,v 1.7.2.1 1995/10/12 21:30:18 thorpej Exp $ */
+/* $NetBSD: ccdvar.h,v 1.9 1996/01/07 22:03:30 thorpej Exp $ */
/*
* Copyright (c) 1995 Jason R. Thorpe.
int ccd_unit; /* logical unit of this ccd */
int ccd_interleave; /* interleave (DEV_BSIZE blocks) */
int ccd_flags; /* misc. information */
- int ccd_dk; /* disk number */
struct vnode **ccd_vpp; /* array of component vnodes */
char **ccd_cpp; /* array of component pathnames */
int ccd_ndev; /* number of component devices */
int sc_nccdisks; /* number of components */
struct ccdcinfo *sc_cinfo; /* component info */
struct ccdiinfo *sc_itable; /* interleave table */
- int sc_nactive; /* number of requests active */
- int sc_dk; /* disk index */
struct ccdgeom sc_geom; /* pseudo geometry info */
- struct dkdevice sc_dkdev; /* generic disk device info */
+ char sc_xname[8]; /* XXX external name */
+ struct disk sc_dkdev; /* generic disk device info */
};
/* sc_flags */
-/* $NetBSD: fd.c,v 1.79 1995/08/21 06:56:14 mycroft Exp $ */
+/* $NetBSD: fd.c,v 1.82 1996/01/07 22:02:28 thorpej Exp $ */
/*-
* Copyright (c) 1993, 1994, 1995 Charles Hannum.
/* software state, per disk (with up to 4 disks per ctlr) */
struct fd_softc {
struct device sc_dev;
- struct dkdevice sc_dk;
+ struct disk sc_dk;
struct fd_type *sc_deftype; /* default type descriptor */
struct fd_type *sc_type; /* current type descriptor */
fd->sc_drive = drive;
fd->sc_deftype = type;
fdc->sc_fd[drive] = fd;
+
+ /*
+ * Initialize and attach the disk structure.
+ */
+ fd->sc_dk.dk_name = fd->sc_dev.dv_xname;
fd->sc_dk.dk_driver = &fddkdriver;
+ disk_attach(&fd->sc_dk);
+
#ifdef NEWCONFIG
/* XXX Need to do some more fiddling with sc_dk. */
dk_establish(&fd->sc_dk, &fd->sc_dev);
fd->sc_q.b_active = 1;
TAILQ_INSERT_TAIL(&fdc->sc_drives, fd, sc_drivechain);
+ /* Instrumentation. */
+ disk_busy(&fd->sc_dk);
+
/* If controller not already active, start it. */
if (!active)
fdcstart(fdc);
bp->b_resid = fd->sc_bcount;
fd->sc_skip = 0;
fd->sc_q.b_actf = bp->b_actf;
+
+ disk_unbusy(&fd->sc_dk, (bp->b_bcount - bp->b_resid));
+
biodone(bp);
/* turn off motor 5s from now */
timeout(fd_motor_off, fd, 5 * hz);
-/* $NetBSD: mcd.c,v 1.42 1995/08/05 23:47:52 mycroft Exp $ */
+/* $NetBSD: mcd.c,v 1.44 1996/01/07 22:03:37 thorpej Exp $ */
/*
* Copyright (c) 1993, 1994, 1995 Charles M. Hannum. All rights reserved.
struct mcd_softc {
struct device sc_dev;
- struct dkdevice sc_dk;
+ struct disk sc_dk;
void *sc_ih;
int iobase;
struct isa_attach_args *ia = aux;
struct mcd_mbox mbx;
+ /*
+ * Initialize and attach the disk structure.
+ */
+ sc->sc_dk.dk_driver = &mcddkdriver;
+ sc->sc_dk.dk_name = sc->sc_dev.dv_xname;
+ disk_attach(&sc->sc_dk);
+
printf(": model %s\n", sc->type != 0 ? sc->type : "unknown");
(void) mcd_setlock(sc, MCD_LK_UNLOCK);
mcd_soft_reset(sc);
- sc->sc_dk.dk_driver = &mcddkdriver;
-
sc->sc_ih = isa_intr_establish(ia->ia_irq, IST_EDGE, IPL_BIO, mcdintr,
sc);
}
/* Check that the partition exists. */
if (part != RAW_PART &&
- (part >= sc->sc_dk.dk_label.d_npartitions ||
- sc->sc_dk.dk_label.d_partitions[part].p_fstype == FS_UNUSED)) {
+ (part >= sc->sc_dk.dk_label->d_npartitions ||
+ sc->sc_dk.dk_label->d_partitions[part].p_fstype == FS_UNUSED)) {
error = ENXIO;
goto bad;
}
* If end of partition, just return.
*/
if (MCDPART(bp->b_dev) != RAW_PART &&
- bounds_check_with_label(bp, &sc->sc_dk.dk_label,
+ bounds_check_with_label(bp, sc->sc_dk.dk_label,
(sc->flags & (MCDF_WLABEL|MCDF_LABELLING)) != 0) <= 0)
goto done;
dp->b_active = 1;
+ /* Instrumentation. */
+ s = splbio();
+ disk_busy(&sc->sc_dk);
+ splx(s);
+
sc->mbx.retry = MCD_RDRETRIES;
sc->mbx.bp = bp;
sc->mbx.blkno = bp->b_blkno / (sc->blksize / DEV_BSIZE);
if (MCDPART(bp->b_dev) != RAW_PART) {
struct partition *p;
- p = &sc->sc_dk.dk_label.d_partitions[MCDPART(bp->b_dev)];
+ p = &sc->sc_dk.dk_label->d_partitions[MCDPART(bp->b_dev)];
sc->mbx.blkno += p->p_offset;
}
sc->mbx.nblk = bp->b_bcount / sc->blksize;
switch (cmd) {
case DIOCGDINFO:
- *(struct disklabel *)addr = sc->sc_dk.dk_label;
+ *(struct disklabel *)addr = *(sc->sc_dk.dk_label);
return 0;
case DIOCGPART:
- ((struct partinfo *)addr)->disklab = &sc->sc_dk.dk_label;
+ ((struct partinfo *)addr)->disklab = sc->sc_dk.dk_label;
((struct partinfo *)addr)->part =
- &sc->sc_dk.dk_label.d_partitions[MCDPART(dev)];
+ &sc->sc_dk.dk_label->d_partitions[MCDPART(dev)];
return 0;
case DIOCWDINFO:
return error;
sc->flags |= MCDF_LABELLING;
- error = setdisklabel(&sc->sc_dk.dk_label,
+ error = setdisklabel(sc->sc_dk.dk_label,
(struct disklabel *)addr, /*sc->sc_dk.dk_openmask : */0,
- &sc->sc_dk.dk_cpulabel);
+ sc->sc_dk.dk_cpulabel);
if (error == 0) {
}
mcdgetdisklabel(sc)
struct mcd_softc *sc;
{
- struct disklabel *lp = &sc->sc_dk.dk_label;
+ struct disklabel *lp = sc->sc_dk.dk_label;
bzero(lp, sizeof(struct disklabel));
- bzero(&sc->sc_dk.dk_cpulabel, sizeof(struct cpu_disklabel));
+ bzero(sc->sc_dk.dk_cpulabel, sizeof(struct cpu_disklabel));
lp->d_secsize = sc->blksize;
lp->d_ntracks = 1;
/* Return buffer. */
bp->b_resid = 0;
+ disk_unbusy(&sc->sc_dk, bp->b_bcount);
biodone(bp);
mcdstart(sc);
/* Invalidate the buffer. */
bp->b_flags |= B_ERROR;
bp->b_resid = bp->b_bcount - mbx->skip;
+ disk_unbusy(&sc->sc_dk, (bp->b_bcount - bp->b_resid));
biodone(bp);
mcdstart(sc);
-/* $NetBSD: wd.c,v 1.142 1995/08/05 23:50:23 mycroft Exp $ */
+/* $NetBSD: wd.c,v 1.145 1996/01/08 21:21:56 mycroft Exp $ */
/*
* Copyright (c) 1994, 1995 Charles M. Hannum. All rights reserved.
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#define INSTRUMENT /* instrumentation stuff by Brad Parker */
-
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/kernel.h>
struct wd_softc {
struct device sc_dev;
- struct dkdevice sc_dk;
+ struct disk sc_dk;
/* Information about the current transfer: */
daddr_t sc_blkno; /* starting block number */
wd->sc_drive = wa->wa_drive;
+ /*
+ * Initialize and attach the disk structure.
+ */
+ wd->sc_dk.dk_driver = &wddkdriver;
+ wd->sc_dk.dk_name = wd->sc_dev.dv_xname;
+ disk_attach(&wd->sc_dk);
+
wd_get_parms(wd);
for (blank = 0, p = wd->sc_params.wdp_model, q = buf, i = 0;
i < sizeof(wd->sc_params.wdp_model); i++) {
printf(" lba addressing\n");
else
printf(" chs addressing\n");
-
- wd->sc_dk.dk_driver = &wddkdriver;
}
/*
/* Valid request? */
if (bp->b_blkno < 0 ||
- (bp->b_bcount % wd->sc_dk.dk_label.d_secsize) != 0 ||
- (bp->b_bcount / wd->sc_dk.dk_label.d_secsize) >= (1 << NBBY)) {
+ (bp->b_bcount % wd->sc_dk.dk_label->d_secsize) != 0 ||
+ (bp->b_bcount / wd->sc_dk.dk_label->d_secsize) >= (1 << NBBY)) {
bp->b_error = EINVAL;
goto bad;
}
* If end of partition, just return.
*/
if (WDPART(bp->b_dev) != RAW_PART &&
- bounds_check_with_label(bp, &wd->sc_dk.dk_label,
+ bounds_check_with_label(bp, wd->sc_dk.dk_label,
(wd->sc_flags & (WDF_WLABEL|WDF_LABELLING)) != 0) <= 0)
goto done;
wd->sc_q.b_active = 1;
TAILQ_INSERT_TAIL(&wdc->sc_drives, wd, sc_drivechain);
+ disk_busy(&wd->sc_dk);
+
/* If controller not already active, start it. */
if (!active)
wdcstart(wdc);
bp->b_resid = wd->sc_bcount;
wd->sc_skip = 0;
wd->sc_q.b_actf = bp->b_actf;
+
+ disk_unbusy(&wd->sc_dk, (bp->b_bcount - bp->b_resid));
+
+ if (!wd->sc_q.b_actf) {
+ TAILQ_REMOVE(&wdc->sc_drives, wd, sc_drivechain);
+ wd->sc_q.b_active = 0;
+ } else
+ disk_busy(&wd->sc_dk);
+
biodone(bp);
}
/* Is there a transfer to this drive? If not, deactivate drive. */
bp = wd->sc_q.b_actf;
- if (bp == NULL) {
- TAILQ_REMOVE(&wdc->sc_drives, wd, sc_drivechain);
- wd->sc_q.b_active = 0;
- goto loop;
- }
if (wdc->sc_errors >= WDIORETRIES) {
wderror(wd, bp, "hard error");
}
}
- lp = &wd->sc_dk.dk_label;
+ lp = wd->sc_dk.dk_label;
/* When starting a transfer... */
if (wd->sc_skip == 0) {
/* Check that the partition exists. */
if (part != RAW_PART &&
- (part >= wd->sc_dk.dk_label.d_npartitions ||
- wd->sc_dk.dk_label.d_partitions[part].p_fstype == FS_UNUSED)) {
+ (part >= wd->sc_dk.dk_label->d_npartitions ||
+ wd->sc_dk.dk_label->d_partitions[part].p_fstype == FS_UNUSED)) {
error = ENXIO;
goto bad;
}
wdgetdisklabel(wd)
struct wd_softc *wd;
{
- struct disklabel *lp = &wd->sc_dk.dk_label;
+ struct disklabel *lp = wd->sc_dk.dk_label;
char *errstring;
bzero(lp, sizeof(struct disklabel));
- bzero(&wd->sc_dk.dk_cpulabel, sizeof(struct cpu_disklabel));
+ bzero(wd->sc_dk.dk_cpulabel, sizeof(struct cpu_disklabel));
lp->d_secsize = DEV_BSIZE;
lp->d_ntracks = wd->sc_params.wdp_heads;
if (wd->sc_state > RECAL)
wd->sc_state = RECAL;
errstring = readdisklabel(MAKEWDDEV(0, wd->sc_dev.dv_unit, RAW_PART),
- wdstrategy, lp, &wd->sc_dk.dk_cpulabel);
+ wdstrategy, lp, wd->sc_dk.dk_cpulabel);
if (errstring) {
/*
* This probably happened because the drive's default
if (wd->sc_state > GEOMETRY)
wd->sc_state = GEOMETRY;
errstring = readdisklabel(MAKEWDDEV(0, wd->sc_dev.dv_unit, RAW_PART),
- wdstrategy, lp, &wd->sc_dk.dk_cpulabel);
+ wdstrategy, lp, wd->sc_dk.dk_cpulabel);
}
if (errstring) {
printf("%s: %s\n", wd->sc_dev.dv_xname, errstring);
return -1;
/* Load parameters. */
- if (wd->sc_dk.dk_label.d_type == DTYPE_ST506)
- outb(iobase+wd_precomp, wd->sc_dk.dk_label.d_precompcyl / 4);
+ if (wd->sc_dk.dk_label->d_type == DTYPE_ST506)
+ outb(iobase+wd_precomp, wd->sc_dk.dk_label->d_precompcyl / 4);
else
outb(iobase+wd_features, 0);
outb(iobase+wd_cyl_lo, cylin);
#ifdef WDDEBUG
printf("wd(%d,%d) C%dH%dS%d\n", wd->sc_dev.dv_unit, wd->sc_drive,
- wd->sc_dk.dk_label.d_ncylinders, wd->sc_dk.dk_label.d_ntracks,
- wd->sc_dk.dk_label.d_nsectors);
+ wd->sc_dk.dk_label->d_ncylinders, wd->sc_dk.dk_label->d_ntracks,
+ wd->sc_dk.dk_label->d_nsectors);
#endif
- if (wdcommand(wd, WDCC_IDP, wd->sc_dk.dk_label.d_ncylinders,
- wd->sc_dk.dk_label.d_ntracks - 1, 0, wd->sc_dk.dk_label.d_nsectors)
- != 0) {
+ if (wdcommand(wd, WDCC_IDP, wd->sc_dk.dk_label->d_ncylinders,
+ wd->sc_dk.dk_label->d_ntracks - 1, 0,
+ wd->sc_dk.dk_label->d_nsectors) != 0) {
wderror(wd, NULL, "wdsetctlr: geometry upload failed");
return -1;
}
* This geometry is only used to read the MBR and print a
* (false) attach message.
*/
- strncpy(wd->sc_dk.dk_label.d_typename, "ST506",
- sizeof wd->sc_dk.dk_label.d_typename);
- wd->sc_dk.dk_label.d_type = DTYPE_ST506;
+ strncpy(wd->sc_dk.dk_label->d_typename, "ST506",
+ sizeof wd->sc_dk.dk_label->d_typename);
+ wd->sc_dk.dk_label->d_type = DTYPE_ST506;
strncpy(wd->sc_params.wdp_model, "unknown",
sizeof wd->sc_params.wdp_model);
wd->sc_params.wdp_usedmovsd = 0;
wd->sc_params.wdp_capabilities = 0;
} else {
- strncpy(wd->sc_dk.dk_label.d_typename, "ESDI/IDE",
- sizeof wd->sc_dk.dk_label.d_typename);
- wd->sc_dk.dk_label.d_type = DTYPE_ESDI;
+ strncpy(wd->sc_dk.dk_label->d_typename, "ESDI/IDE",
+ sizeof wd->sc_dk.dk_label->d_typename);
+ wd->sc_dk.dk_label->d_type = DTYPE_ESDI;
/* Read in parameter block. */
insw(wdc->sc_iobase+wd_data, tb, sizeof(tb) / sizeof(short));
case DIOCSBAD:
if ((flag & FWRITE) == 0)
return EBADF;
- wd->sc_dk.dk_cpulabel.bad = *(struct dkbad *)addr;
- wd->sc_dk.dk_label.d_flags |= D_BADSECT;
+ wd->sc_dk.dk_cpulabel->bad = *(struct dkbad *)addr;
+ wd->sc_dk.dk_label->d_flags |= D_BADSECT;
bad144intern(wd);
return 0;
case DIOCGDINFO:
- *(struct disklabel *)addr = wd->sc_dk.dk_label;
+ *(struct disklabel *)addr = *(wd->sc_dk.dk_label);
return 0;
case DIOCGPART:
- ((struct partinfo *)addr)->disklab = &wd->sc_dk.dk_label;
+ ((struct partinfo *)addr)->disklab = wd->sc_dk.dk_label;
((struct partinfo *)addr)->part =
- &wd->sc_dk.dk_label.d_partitions[WDPART(dev)];
+ &wd->sc_dk.dk_label->d_partitions[WDPART(dev)];
return 0;
case DIOCWDINFO:
return error;
wd->sc_flags |= WDF_LABELLING;
- error = setdisklabel(&wd->sc_dk.dk_label,
+ error = setdisklabel(wd->sc_dk.dk_label,
(struct disklabel *)addr, /*wd->sc_dk.dk_openmask : */0,
- &wd->sc_dk.dk_cpulabel);
+ wd->sc_dk.dk_cpulabel);
if (error == 0) {
if (wd->sc_state > GEOMETRY)
wd->sc_state = GEOMETRY;
if (cmd == DIOCWDINFO)
error = writedisklabel(WDLABELDEV(dev),
- wdstrategy, &wd->sc_dk.dk_label,
- &wd->sc_dk.dk_cpulabel);
+ wdstrategy, wd->sc_dk.dk_label,
+ wd->sc_dk.dk_cpulabel);
}
wd->sc_flags &= ~WDF_LABELLING;
auio.uio_resid = fop->df_count;
auio.uio_segflg = 0;
auio.uio_offset =
- fop->df_startblk * wd->sc_dk.dk_label.d_secsize;
+ fop->df_startblk * wd->sc_dk.dk_label->d_secsize;
auio.uio_procp = p;
error = physio(wdformat, NULL, dev, B_WRITE, minphys,
&auio);
return -1;
wd = wdcd.cd_devs[WDUNIT(dev)];
part = WDPART(dev);
- if (wd->sc_dk.dk_label.d_partitions[part].p_fstype != FS_SWAP)
+ if (wd->sc_dk.dk_label->d_partitions[part].p_fstype != FS_SWAP)
size = -1;
else
- size = wd->sc_dk.dk_label.d_partitions[part].p_size;
+ size = wd->sc_dk.dk_label->d_partitions[part].p_size;
if (wdclose(dev, 0, S_IFBLK) != 0)
return -1;
return size;
wdc = (void *)wd->sc_dev.dv_parent;
/* Convert to disk sectors. Request must be a multiple of size. */
- lp = &wd->sc_dk.dk_label;
+ lp = wd->sc_dk.dk_label;
if ((size % lp->d_secsize) != 0)
return EFAULT;
nblks = size / lp->d_secsize;
bad144intern(wd)
struct wd_softc *wd;
{
- struct dkbad *bt = &wd->sc_dk.dk_cpulabel.bad;
- struct disklabel *lp = &wd->sc_dk.dk_label;
+ struct dkbad *bt = &wd->sc_dk.dk_cpulabel->bad;
+ struct disklabel *lp = wd->sc_dk.dk_label;
int i = 0;
for (; i < 126; i++) {
s = splbio();
if ((wdc->sc_flags & WDCF_ACTIVE) != 0) {
+ struct wd_softc *wd = wdc->sc_drives.tqh_first;
+ struct buf *bp = wd->sc_q.b_actf;
+
wdc->sc_flags &= ~WDCF_ACTIVE;
wderror(wdc, NULL, "lost interrupt");
+ printf("%s: lost interrupt: %sing %d@%s:%d\n",
+ wdc->sc_dev.dv_xname,
+ (bp->b_flags & B_READ) ? "read" : "writ",
+ wd->sc_nblks, wd->sc_dev.dv_xname, wd->sc_blkno);
wdcunwedge(wdc);
} else
wderror(wdc, NULL, "missing untimeout");
if (bp) {
diskerr(bp, "wd", msg, LOG_PRINTF, wd->sc_skip / DEV_BSIZE,
- &wd->sc_dk.dk_label);
+ wd->sc_dk.dk_label);
printf("\n");
} else
printf("%s: %s: status %b error %b\n", wdc->sc_dev.dv_xname,
-/* $NetBSD: ramdisk.c,v 1.1.2.1 1995/11/17 23:34:25 gwr Exp $ */
+/* $NetBSD: ramdisk.c,v 1.4 1996/01/07 22:03:31 thorpej Exp $ */
/*
* Copyright (c) 1995 Gordon W. Ross, Leo Weppelman.
#include <sys/systm.h>
#include <sys/buf.h>
#include <sys/device.h>
+#include <sys/disk.h>
#include <vm/vm.h>
#include <vm/vm_kern.h>
struct rd_softc {
struct device sc_dev; /* REQUIRED first entry */
+ struct disk sc_dkdev; /* hook for generic disk handling */
struct rd_conf sc_rd;
struct buf *sc_buflist;
int sc_flags;
NULL, "rd", rd_match, rd_attach,
DV_DULL, sizeof(struct rd_softc), NULL, 0 };
+void rdstrategy __P((struct buf *bp));
+
+struct dkdriver rddkdriver = { rdstrategy };
+
static int
rd_match(parent, self, aux)
struct device *parent;
rd_attach_hook(sc->sc_dev.dv_unit, &sc->sc_rd);
#endif
printf("\n");
+
+ /*
+ * Initialize and attach the disk structure.
+ */
+ bzero(&sc->sc_dkdev, sizeof(sc->sc_dkdev));
+ sc->sc_dkdev.dk_driver = &rddkdriver;
+ sc->sc_dkdev.dk_name = sc->sc_dev.dv_xname;
+ disk_attach(&sc->sc_dkdev);
}
/*
* ioctl, dump, size
*/
-void rdstrategy __P((struct buf *bp));
-
#if RAMDISK_SERVER
static int rd_server_loop __P((struct rd_softc *sc));
static int rd_ioctl_server __P((struct rd_softc *sc,
-/* $NetBSD: vnd.c,v 1.22 1995/11/06 20:28:09 thorpej Exp $ */
+/* $NetBSD: vnd.c,v 1.23 1996/01/07 22:03:33 thorpej Exp $ */
/*
* Copyright (c) 1988 University of Utah.
#include <sys/namei.h>
#include <sys/proc.h>
#include <sys/errno.h>
-#include <sys/dkstat.h>
#include <sys/buf.h>
#include <sys/malloc.h>
#include <sys/ioctl.h>
struct ucred *sc_cred; /* credentials */
int sc_maxactive; /* max # of active requests */
struct buf sc_tab; /* transfer queue */
- struct dkdevice sc_dkdev; /* generic disk device info */
+ char sc_xname[8]; /* XXX external name */
+ struct disk sc_dkdev; /* generic disk device info */
};
/* sc_flags */
vnd-vnd_softc, bp, bp->b_vp, bp->b_blkno, bp->b_data,
bp->b_bcount);
#endif
+
+ /* Instrumentation. */
+ disk_busy(&vnd->sc_dkdev);
+
if ((bp->b_flags & B_READ) == 0)
bp->b_vp->v_numoutput++;
VOP_STRATEGY(bp);
vnd-vnd_softc, vbp, vbp->vb_buf.b_vp, vbp->vb_buf.b_blkno,
vbp->vb_buf.b_data, vbp->vb_buf.b_bcount);
#endif
+
if (vbp->vb_buf.b_error) {
#ifdef DEBUG
if (vnddebug & VDB_IO)
}
pbp->b_resid -= vbp->vb_buf.b_bcount;
putvndbuf(vbp);
+ disk_unbusy(&vnd->sc_dkdev, (pbp->b_bcount - pbp->b_resid));
if (pbp->b_resid == 0) {
#ifdef DEBUG
if (vnddebug & VDB_IO)
vnd->sc_vp, vnd->sc_size);
#endif
+ /* Attach the disk. */
+ bzero(vnd->sc_xname, sizeof(vnd->sc_xname)); /* XXX */
+ sprintf(vnd->sc_xname, "vnd%d", unit); /* XXX */
+ vnd->sc_dkdev.dk_name = vnd->sc_xname;
+ disk_attach(&vnd->sc_dkdev);
+
vndunlock(vnd);
break;
printf("vndioctl: CLRed\n");
#endif
+ /* Detatch the disk. */
+ disk_detatch(&vnd->sc_dkdev);
+
/* This must be atomic. */
s = splhigh();
vndunlock(vnd);
-/* $NetBSD: init_main.c,v 1.79 1995/12/09 04:07:41 mycroft Exp $ */
+/* $NetBSD: init_main.c,v 1.80 1996/01/07 22:03:47 thorpej Exp $ */
/*
* Copyright (c) 1995 Christopher G. Demetriou. All rights reserved.
extern struct pdevinit pdevinit[];
extern void roundrobin __P((void *));
extern void schedcpu __P((void *));
+ extern void disk_init __P((void));
/*
* Initialize the current process pointer (curproc) before
vm_mem_init();
kmeminit();
+ disk_init(); /* must come before autoconfiguration */
cpu_startup();
/*
-/* $NetBSD: subr_disk.c,v 1.14 1995/12/28 19:16:39 thorpej Exp $ */
+/* $NetBSD: subr_disk.c,v 1.15 1996/01/07 22:03:49 thorpej Exp $ */
/*
+ * Copyright (c) 1995 Jason R. Thorpe. All rights reserved.
* Copyright (c) 1982, 1986, 1988, 1993
* The Regents of the University of California. All rights reserved.
* (c) UNIX System Laboratories, Inc.
#include <sys/param.h>
#include <sys/systm.h>
+#include <sys/kernel.h>
+#include <sys/malloc.h>
#include <sys/buf.h>
-#include <sys/disklabel.h>
#include <sys/syslog.h>
+#include <sys/time.h>
+#include <sys/disklabel.h>
+#include <sys/disk.h>
#include <sys/dkstat.h> /* XXX */
+/*
+ * A global list of all disks attached to the system. May grow or
+ * shrink over time.
+ */
+struct disklist_head disklist; /* TAILQ_HEAD */
+int disk_count; /* number of drives in global disklist */
+
/*
* Old-style disk instrumentation structures. These will go away
* someday.
long dk_wpms[DK_NDRIVE];
long dk_xfer[DK_NDRIVE];
int dk_busy;
-int dk_ndrive = DK_NDRIVE;
+int dk_ndrive;
int dkn; /* number of slots filled so far */
/*
(*pr)(" tn %d sn %d)", sn / lp->d_nsectors, sn % lp->d_nsectors);
}
}
+
+/*
+ * Initialize the disklist. Called by main() before autoconfiguration.
+ */
+void
+disk_init()
+{
+
+ TAILQ_INIT(&disklist);
+ disk_count = 0;
+ dk_ndrive = DK_NDRIVE; /* XXX */
+}
+
+/*
+ * Searches the disklist for the disk corresponding to the
+ * name provided.
+ */
+struct disk *
+disk_find(name)
+ char *name;
+{
+ struct disk *diskp;
+
+ if ((name == NULL) || (disk_count <= 0))
+ return (NULL);
+
+ for (diskp = disklist.tqh_first; diskp != NULL;
+ diskp = diskp->dk_link.tqe_next)
+ if (strcmp(diskp->dk_name, name) == 0)
+ return (diskp);
+
+ return (NULL);
+}
+
+/*
+ * Attach a disk.
+ */
+void
+disk_attach(diskp)
+ struct disk *diskp;
+{
+ int s;
+
+ /*
+ * Allocate and initialize the disklabel structures. Note that
+ * it's not safe to sleep here, since we're probably going to be
+ * called during autoconfiguration.
+ */
+ diskp->dk_label = malloc(sizeof(struct disklabel), M_DEVBUF, M_NOWAIT);
+ diskp->dk_cpulabel = malloc(sizeof(struct cpu_disklabel), M_DEVBUF,
+ M_NOWAIT);
+ if ((diskp->dk_label == NULL) || (diskp->dk_cpulabel == NULL))
+ panic("disk_attach: can't allocate storage for disklabel");
+
+ bzero(diskp->dk_label, sizeof(struct disklabel));
+ bzero(diskp->dk_cpulabel, sizeof(struct cpu_disklabel));
+
+ /*
+ * Set the attached timestamp.
+ */
+ s = splclock();
+ diskp->dk_attachtime = mono_time;
+ splx(s);
+
+ /*
+ * Link into the disklist.
+ */
+ TAILQ_INSERT_TAIL(&disklist, diskp, dk_link);
+ ++disk_count;
+}
+
+/*
+ * Detatch a disk.
+ */
+void
+disk_detatch(diskp)
+ struct disk *diskp;
+{
+
+ /*
+ * Free the space used by the disklabel structures.
+ */
+ free(diskp->dk_label, M_DEVBUF);
+ free(diskp->dk_cpulabel, M_DEVBUF);
+
+ /*
+ * Remove from the disklist.
+ */
+ TAILQ_REMOVE(&disklist, diskp, dk_link);
+ if (--disk_count < 0)
+ panic("disk_detatch: disk_count < 0");
+}
+
+/*
+ * Increment a disk's busy counter. If the counter is going from
+ * 0 to 1, set the timestamp.
+ */
+void
+disk_busy(diskp)
+ struct disk *diskp;
+{
+ int s;
+
+ /*
+ * XXX We'd like to use something as accurate as microtime(),
+ * but that doesn't depend on the system TOD clock.
+ */
+ if (diskp->dk_busy++ == 0) {
+ s = splclock();
+ diskp->dk_timestamp = mono_time;
+ splx(s);
+ }
+}
+
+/*
+ * Decrement a disk's busy counter, increment the byte count, total busy
+ * time, and reset the timestamp.
+ */
+void
+disk_unbusy(diskp, bcount)
+ struct disk *diskp;
+ long bcount;
+{
+ int s;
+ struct timeval dv_time, diff_time;
+
+ if (diskp->dk_busy-- == 0)
+ panic("disk_unbusy: %s: dk_busy < 0", diskp->dk_name);
+
+ s = splclock();
+ dv_time = mono_time;
+ splx(s);
+
+ timersub(&dv_time, &diskp->dk_timestamp, &diff_time);
+ timeradd(&diskp->dk_time, &diff_time, &diskp->dk_time);
+
+ diskp->dk_timestamp = dv_time;
+ if (bcount > 0) {
+ diskp->dk_bytes += bcount;
+ diskp->dk_xfer++;
+ }
+}
+
+/*
+ * Reset the metrics counters on the given disk. Note that we cannot
+ * reset the busy counter, as it may case a panic in disk_unbusy().
+ * We also must avoid playing with the timestamp information, as it
+ * may skew any pending transfer results.
+ */
+void
+disk_resetstat(diskp)
+ struct disk *diskp;
+{
+ int s = splbio(), t;
+
+ diskp->dk_xfer = 0;
+ diskp->dk_bytes = 0;
+
+ t = splclock();
+ diskp->dk_attachtime = mono_time;
+ splx(t);
+
+ timerclear(&diskp->dk_time);
+
+ splx(s);
+}
-/* $NetBSD: cd.c,v 1.78 1995/12/07 19:11:32 thorpej Exp $ */
+/* $NetBSD: cd.c,v 1.79 1996/01/07 22:03:58 thorpej Exp $ */
/*
* Copyright (c) 1994, 1995 Charles M. Hannum. All rights reserved.
#include <sys/file.h>
#include <sys/stat.h>
#include <sys/ioctl.h>
-#include <sys/mtio.h>
#include <sys/buf.h>
#include <sys/uio.h>
#include <sys/malloc.h>
struct cd_softc {
struct device sc_dev;
- struct dkdevice sc_dk;
+ struct disk sc_dk;
int flags;
#define CDF_LOCKED 0x01
int cd_get_parms __P((struct cd_softc *, int));
void cdstrategy __P((struct buf *));
void cdstart __P((struct cd_softc *));
+int cddone __P((struct scsi_xfer *));
struct dkdriver cddkdriver = { cdstrategy };
NULL, /* use default error handler */
cdstart, /* we have a queue, which is started by this */
NULL, /* we do not have an async handler */
- NULL, /* use default 'done' routine */
+ cddone, /* deal with stats at interrupt time */
};
struct scsi_inquiry_pattern cd_patterns[] = {
if (sc_link->openings > CDOUTSTANDING)
sc_link->openings = CDOUTSTANDING;
+ /*
+ * Initialize and attach the disk structure.
+ */
cd->sc_dk.dk_driver = &cddkdriver;
+ cd->sc_dk.dk_name = cd->sc_dev.dv_xname;
+ disk_attach(&cd->sc_dk);
+
#if !defined(i386) || defined(NEWCONFIG)
- dk_establish(&cd->sc_dk, &cd->sc_dev);
+ dk_establish(&cd->sc_dk, &cd->sc_dev); /* XXX */
#endif
printf("\n");
} else {
/* Check that it is still responding and ok. */
if (error = scsi_test_unit_ready(sc_link,
- SCSI_IGNORE_ILLEGAL_REQUEST | SCSI_IGNORE_MEDIA_CHANGE |
- SCSI_IGNORE_NOT_READY))
+ SCSI_IGNORE_ILLEGAL_REQUEST | SCSI_IGNORE_MEDIA_CHANGE | SCSI_IGNORE_NOT_READY))
goto bad3;
/* Start the pack spinning if necessary. */
if (error = scsi_start(sc_link, SSS_START,
- SCSI_IGNORE_ILLEGAL_REQUEST | SCSI_IGNORE_MEDIA_CHANGE |
- SCSI_SILENT))
+ SCSI_IGNORE_ILLEGAL_REQUEST | SCSI_IGNORE_MEDIA_CHANGE | SCSI_SILENT))
goto bad3;
sc_link->flags |= SDEV_OPEN;
/* Check that the partition exists. */
if (part != RAW_PART &&
- (part >= cd->sc_dk.dk_label.d_npartitions ||
- cd->sc_dk.dk_label.d_partitions[part].p_fstype == FS_UNUSED)) {
+ (part >= cd->sc_dk.dk_label->d_npartitions ||
+ cd->sc_dk.dk_label->d_partitions[part].p_fstype == FS_UNUSED)) {
error = ENXIO;
goto bad;
}
/*
* The transfer must be a whole number of blocks.
*/
- if ((bp->b_bcount % cd->sc_dk.dk_label.d_secsize) != 0) {
+ if ((bp->b_bcount % cd->sc_dk.dk_label->d_secsize) != 0) {
bp->b_error = EINVAL;
goto bad;
}
* If end of partition, just return.
*/
if (CDPART(bp->b_dev) != RAW_PART &&
- bounds_check_with_label(bp, &cd->sc_dk.dk_label,
+ bounds_check_with_label(bp, cd->sc_dk.dk_label,
(cd->flags & (CDF_WLABEL|CDF_LABELLING)) != 0) <= 0)
goto done;
* of the logical blocksize of the device.
*/
blkno =
- bp->b_blkno / (cd->sc_dk.dk_label.d_secsize / DEV_BSIZE);
+ bp->b_blkno / (cd->sc_dk.dk_label->d_secsize / DEV_BSIZE);
if (CDPART(bp->b_dev) != RAW_PART) {
- p = &cd->sc_dk.dk_label.d_partitions[CDPART(bp->b_dev)];
- blkno += p->p_offset;
+ p = &cd->sc_dk.dk_label->d_partitions[CDPART(bp->b_dev)];
+ blkno += p->p_offset;
}
- nblks = howmany(bp->b_bcount, cd->sc_dk.dk_label.d_secsize);
+ nblks = howmany(bp->b_bcount, cd->sc_dk.dk_label->d_secsize);
/*
* Fill out the scsi command. If the transfer will
cmdp = (struct scsi_generic *)&cmd_big;
}
+ /* Instrumentation. */
+ disk_busy(&cd->sc_dk);
+
/*
* Call the routine that chats with the adapter.
* Note: we cannot sleep as we may be an interrupt
}
}
+int
+cddone(xs)
+ struct scsi_xfer *xs;
+{
+ struct cd_softc *cd = xs->sc_link->device_softc;
+
+ if (xs->bp != NULL)
+ disk_unbusy(&cd->sc_dk, (xs->bp->b_bcount - xs->bp->b_resid));
+
+ return (0);
+}
+
int
cdread(dev, uio)
dev_t dev;
switch (cmd) {
case DIOCGDINFO:
- *(struct disklabel *)addr = cd->sc_dk.dk_label;
+ *(struct disklabel *)addr = *(cd->sc_dk.dk_label);
return 0;
case DIOCGPART:
- ((struct partinfo *)addr)->disklab = &cd->sc_dk.dk_label;
+ ((struct partinfo *)addr)->disklab = cd->sc_dk.dk_label;
((struct partinfo *)addr)->part =
- &cd->sc_dk.dk_label.d_partitions[CDPART(dev)];
+ &cd->sc_dk.dk_label->d_partitions[CDPART(dev)];
return 0;
case DIOCWDINFO:
return error;
cd->flags |= CDF_LABELLING;
- error = setdisklabel(&cd->sc_dk.dk_label,
+ error = setdisklabel(cd->sc_dk.dk_label,
(struct disklabel *)addr, /*cd->sc_dk.dk_openmask : */0,
- &cd->sc_dk.dk_cpulabel);
+ cd->sc_dk.dk_cpulabel);
if (error == 0) {
}
return scsi_start(cd->sc_link, SSS_START, 0);
case CDIOCSTOP:
return scsi_start(cd->sc_link, SSS_STOP, 0);
- case MTIOCTOP:
- if (((struct mtop *)addr)->mt_op != MTOFFL)
- return EIO;
case CDIOCEJECT:
return scsi_start(cd->sc_link, SSS_STOP|SSS_LOEJ, 0);
case CDIOCALLOW:
cdgetdisklabel(cd)
struct cd_softc *cd;
{
- struct disklabel *lp = &cd->sc_dk.dk_label;
+ struct disklabel *lp = cd->sc_dk.dk_label;
bzero(lp, sizeof(struct disklabel));
- bzero(&cd->sc_dk.dk_cpulabel, sizeof(struct cpu_disklabel));
+ bzero(cd->sc_dk.dk_cpulabel, sizeof(struct cpu_disklabel));
lp->d_secsize = cd->params.blksize;
lp->d_ntracks = 1;
-/* $NetBSD: sd.c,v 1.83 1995/12/07 21:54:24 thorpej Exp $ */
+/* $NetBSD: sd.c,v 1.84 1996/01/07 22:04:02 thorpej Exp $ */
/*
* Copyright (c) 1994, 1995 Charles M. Hannum. All rights reserved.
struct sd_softc {
struct device sc_dev;
- struct dkdevice sc_dk;
+ struct disk sc_dk;
int flags;
#define SDF_LOCKED 0x01
int sd_get_parms __P((struct sd_softc *, int));
void sdstrategy __P((struct buf *));
void sdstart __P((struct sd_softc *));
+int sddone __P((struct scsi_xfer *));
void sdminphys __P((struct buf *));
struct dkdriver sddkdriver = { sdstrategy };
NULL, /* Use default error handler */
sdstart, /* have a queue, served by this */
NULL, /* have no async handler */
- NULL, /* Use default 'done' routine */
+ sddone, /* deal with stats at interrupt time */
};
struct scsi_inquiry_pattern sd_patterns[] = {
sc_link->openings = SDOUTSTANDING;
/*
- * Note if this device is ancient. This is used in sdminphys().
+ * Initialize and attach the disk structure.
*/
- if ((sa->sa_inqbuf->version & SID_ANSII) == 0)
- sd->flags |= SDF_ANCIENT;
+ sd->sc_dk.dk_driver = &sddkdriver;
+ sd->sc_dk.dk_name = sd->sc_dev.dv_xname;
+ disk_attach(&sd->sc_dk);
sd->sc_dk.dk_driver = &sddkdriver;
#if !defined(i386) || defined(NEWCONFIG)
- dk_establish(&sd->sc_dk, &sd->sc_dev);
+ dk_establish(&sd->sc_dk, &sd->sc_dev); /* XXX */
#endif
+ /*
+ * Note if this device is ancient. This is used in sdminphys().
+ */
+ if ((sa->sa_inqbuf->version & SID_ANSII) == 0)
+ sd->flags |= SDF_ANCIENT;
+
/*
* Use the subdriver to request information regarding
* the drive. We cannot use interrupts yet, so the
/* Check that the partition exists. */
if (part != RAW_PART &&
- (part >= sd->sc_dk.dk_label.d_npartitions ||
- sd->sc_dk.dk_label.d_partitions[part].p_fstype == FS_UNUSED)) {
+ (part >= sd->sc_dk.dk_label->d_npartitions ||
+ sd->sc_dk.dk_label->d_partitions[part].p_fstype == FS_UNUSED)) {
error = ENXIO;
goto bad;
}
/*
* The transfer must be a whole number of blocks.
*/
- if ((bp->b_bcount % sd->sc_dk.dk_label.d_secsize) != 0) {
+ if ((bp->b_bcount % sd->sc_dk.dk_label->d_secsize) != 0) {
bp->b_error = EINVAL;
goto bad;
}
* If end of partition, just return.
*/
if (SDPART(bp->b_dev) != RAW_PART &&
- bounds_check_with_label(bp, &sd->sc_dk.dk_label,
+ bounds_check_with_label(bp, sd->sc_dk.dk_label,
(sd->flags & (SDF_WLABEL|SDF_LABELLING)) != 0) <= 0)
goto done;
* of the logical blocksize of the device.
*/
blkno =
- bp->b_blkno / (sd->sc_dk.dk_label.d_secsize / DEV_BSIZE);
+ bp->b_blkno / (sd->sc_dk.dk_label->d_secsize / DEV_BSIZE);
if (SDPART(bp->b_dev) != RAW_PART) {
- p = &sd->sc_dk.dk_label.d_partitions[SDPART(bp->b_dev)];
- blkno += p->p_offset;
+ p = &sd->sc_dk.dk_label->d_partitions[SDPART(bp->b_dev)];
+ blkno += p->p_offset;
}
- nblks = howmany(bp->b_bcount, sd->sc_dk.dk_label.d_secsize);
+ nblks = howmany(bp->b_bcount, sd->sc_dk.dk_label->d_secsize);
/*
* Fill out the scsi command. If the transfer will
cmdp = (struct scsi_generic *)&cmd_big;
}
+ /* Instrumentation. */
+ disk_busy(&sd->sc_dk);
+
/*
* Call the routine that chats with the adapter.
* Note: we cannot sleep as we may be an interrupt
}
}
+int
+sddone(xs)
+ struct scsi_xfer *xs;
+{
+ struct sd_softc *sd = xs->sc_link->device_softc;
+
+ if (xs->bp != NULL)
+ disk_unbusy(&sd->sc_dk, (xs->bp->b_bcount - xs->bp->b_resid));
+
+ return (0);
+}
+
void
sdminphys(bp)
struct buf *bp;
* in a 10-byte read/write actually means 0 blocks.
*/
if (sd->flags & SDF_ANCIENT) {
- max = sd->sc_dk.dk_label.d_secsize * 0xff;
+ max = sd->sc_dk.dk_label->d_secsize * 0xff;
if (bp->b_bcount > max)
bp->b_bcount = max;
switch (cmd) {
case DIOCGDINFO:
- *(struct disklabel *)addr = sd->sc_dk.dk_label;
+ *(struct disklabel *)addr = *(sd->sc_dk.dk_label);
return 0;
case DIOCGPART:
- ((struct partinfo *)addr)->disklab = &sd->sc_dk.dk_label;
+ ((struct partinfo *)addr)->disklab = sd->sc_dk.dk_label;
((struct partinfo *)addr)->part =
- &sd->sc_dk.dk_label.d_partitions[SDPART(dev)];
+ &sd->sc_dk.dk_label->d_partitions[SDPART(dev)];
return 0;
case DIOCWDINFO:
return error;
sd->flags |= SDF_LABELLING;
- error = setdisklabel(&sd->sc_dk.dk_label,
+ error = setdisklabel(sd->sc_dk.dk_label,
(struct disklabel *)addr, /*sd->sc_dk.dk_openmask : */0,
- &sd->sc_dk.dk_cpulabel);
+ sd->sc_dk.dk_cpulabel);
if (error == 0) {
if (cmd == DIOCWDINFO)
error = writedisklabel(SDLABELDEV(dev),
- sdstrategy, &sd->sc_dk.dk_label,
- &sd->sc_dk.dk_cpulabel);
+ sdstrategy, sd->sc_dk.dk_label,
+ sd->sc_dk.dk_cpulabel);
}
sd->flags &= ~SDF_LABELLING;
sdgetdisklabel(sd)
struct sd_softc *sd;
{
- struct disklabel *lp = &sd->sc_dk.dk_label;
+ struct disklabel *lp = sd->sc_dk.dk_label;
char *errstring;
bzero(lp, sizeof(struct disklabel));
- bzero(&sd->sc_dk.dk_cpulabel, sizeof(struct cpu_disklabel));
+ bzero(sd->sc_dk.dk_cpulabel, sizeof(struct cpu_disklabel));
lp->d_secsize = sd->params.blksize;
lp->d_ntracks = sd->params.heads;
* Call the generic disklabel extraction routine
*/
if (errstring = readdisklabel(MAKESDDEV(0, sd->sc_dev.dv_unit,
- RAW_PART), sdstrategy, lp, &sd->sc_dk.dk_cpulabel)) {
+ RAW_PART), sdstrategy, lp, sd->sc_dk.dk_cpulabel)) {
printf("%s: %s\n", sd->sc_dev.dv_xname, errstring);
return;
}
return -1;
sd = sdcd.cd_devs[SDUNIT(dev)];
part = SDPART(dev);
- if (sd->sc_dk.dk_label.d_partitions[part].p_fstype != FS_SWAP)
+ if (sd->sc_dk.dk_label->d_partitions[part].p_fstype != FS_SWAP)
size = -1;
else
- size = sd->sc_dk.dk_label.d_partitions[part].p_size;
+ size = sd->sc_dk.dk_label->d_partitions[part].p_size;
if (sdclose(dev, 0, S_IFBLK) != 0)
return -1;
return size;
return ENXIO;
/* Convert to disk sectors. Request must be a multiple of size. */
- lp = &sd->sc_dk.dk_label;
+ lp = sd->sc_dk.dk_label;
sectorsize = lp->d_secsize;
if ((size % sectorsize) != 0)
return EFAULT;
-/* $NetBSD: disk.h,v 1.8 1994/10/30 21:49:49 cgd Exp $ */
+/* $NetBSD: disk.h,v 1.9 1996/01/07 22:04:07 thorpej Exp $ */
/*
+ * Copyright (c) 1995 Jason R. Thorpe. All rights reserved.
* Copyright (c) 1992, 1993
* The Regents of the University of California. All rights reserved.
*
/*
* Disk device structures.
- *
- * Note that this is only a preliminary outline. The final disk structures
- * may be somewhat different.
*/
+
+#include <sys/time.h>
+#include <sys/queue.h>
+
struct buf;
+struct disklabel;
+struct cpu_disklabel;
+
+struct disk {
+ TAILQ_ENTRY(disk) dk_link; /* link in global disklist */
+ char *dk_name; /* disk name */
+ int dk_bopenmask; /* block devices open */
+ int dk_copenmask; /* character devices open */
+ int dk_openmask; /* composite (bopen|copen) */
+ int dk_state; /* label state ### */
+ int dk_blkshift; /* shift to convert DEV_BSIZE to blks */
+ int dk_byteshift; /* shift to convert bytes to blks */
+
+ /*
+ * Metrics data; note that some metrics may have no meaning
+ * on certain types of disks.
+ */
+ int dk_busy; /* busy counter */
+ u_int64_t dk_xfer; /* total number of transfers */
+ u_int64_t dk_seek; /* total independent seek operations */
+ u_int64_t dk_bytes; /* total bytes transfered */
+ struct timeval dk_attachtime; /* time disk was attached */
+ struct timeval dk_timestamp; /* timestamp of last unbusy */
+ struct timeval dk_time; /* total time spent busy */
-struct dkdevice {
- struct device dk_dev; /* base device */
- struct dkdevice *dk_next; /* list of disks; not yet used */
- int dk_bps; /* xfer rate: bytes per second */
- int dk_bopenmask; /* block devices open */
- int dk_copenmask; /* character devices open */
- int dk_openmask; /* composite (bopen|copen) */
- int dk_state; /* label state ### */
- int dk_blkshift; /* shift to convert DEV_BSIZE to blks */
- int dk_byteshift; /* shift to convert bytes to blks */
struct dkdriver *dk_driver; /* pointer to driver */
- daddr_t dk_labelsector; /* sector containing label */
- struct disklabel dk_label; /* label */
- struct cpu_disklabel dk_cpulabel;
+
+ /*
+ * Disk label information. Storage for the in-core disk label
+ * must be dynamically allocated, otherwise the size of this
+ * structure becomes machine-dependent.
+ */
+ daddr_t dk_labelsector; /* sector containing label */
+ struct disklabel *dk_label; /* label */
+ struct cpu_disklabel *dk_cpulabel;
};
struct dkdriver {
struct proc *));
int (*d_dump) __P((dev_t));
void (*d_start) __P((struct buf *, daddr_t));
- int (*d_mklabel) __P((struct dkdevice *));
+ int (*d_mklabel) __P((struct disk *));
#endif
};
long ds_endsecond; /* # insertions at end of 2nd list */
};
#endif
+
+/*
+ * disklist_head is defined here so that user-land has access to it.
+ */
+TAILQ_HEAD(disklist_head, disk); /* the disklist is a TAILQ */
+
+#ifdef _KERNEL
+extern int disk_count; /* number of disks in global disklist */
+
+void disk_init __P((void));
+void disk_attach __P((struct disk *));
+void disk_detach __P((struct disk *));
+void disk_busy __P((struct disk *));
+void disk_unbusy __P((struct disk *, long));
+void disk_resetstat __P((struct disk *));
+struct disk *disk_find __P((char *));
+#endif