diff options
author | Hugh Graham <hugh@cvs.openbsd.org> | 2001-12-05 03:04:39 +0000 |
---|---|---|
committer | Hugh Graham <hugh@cvs.openbsd.org> | 2001-12-05 03:04:39 +0000 |
commit | 719b1227da3fb8ad66c32e1076be223f79471780 (patch) | |
tree | 6512afd4b0c2a5f901697cba857f5ade400c1e96 | |
parent | 8495122eab9d3b759a87512bb36cc1a457f3012e (diff) |
sync with netbsd. untested.
-rw-r--r-- | sys/arch/vax/mscp/mscp.c | 19 | ||||
-rw-r--r-- | sys/arch/vax/mscp/mscp_disk.c | 141 | ||||
-rw-r--r-- | sys/arch/vax/mscp/mscp_subr.c | 27 | ||||
-rw-r--r-- | sys/arch/vax/mscp/mscp_tape.c | 32 |
4 files changed, 120 insertions, 99 deletions
diff --git a/sys/arch/vax/mscp/mscp.c b/sys/arch/vax/mscp/mscp.c index 2e1ecf8e349..bcee44f0463 100644 --- a/sys/arch/vax/mscp/mscp.c +++ b/sys/arch/vax/mscp/mscp.c @@ -1,5 +1,5 @@ -/* $OpenBSD: mscp.c,v 1.5 2001/06/25 00:43:18 mickey Exp $ */ -/* $NetBSD: mscp.c,v 1.11 1999/06/06 19:16:18 ragge Exp $ */ +/* $OpenBSD: mscp.c,v 1.6 2001/12/05 03:04:38 hugh Exp $ */ +/* $NetBSD: mscp.c,v 1.16 2001/11/13 07:38:28 lukem Exp $ */ /* * Copyright (c) 1996 Ludd, University of Lule}, Sweden. @@ -44,6 +44,8 @@ * MSCP generic driver routines */ +#include <sys/cdefs.h> + #include <sys/param.h> #include <sys/buf.h> #include <sys/malloc.h> @@ -66,12 +68,12 @@ */ struct mscp * mscp_getcp(mi, canwait) - register struct mscp_softc *mi; + struct mscp_softc *mi; int canwait; { #define mri (&mi->mi_cmd) - register struct mscp *mp; - register int i; + struct mscp *mp; + int i; int s = splimp(); again: @@ -85,7 +87,7 @@ again: return (NULL); } mi->mi_wantcredits = 1; - sleep((caddr_t) &mi->mi_wantcredits, PCMD); + (void) tsleep(&mi->mi_wantcredits, PCMD, "mscpwcrd", 0); goto again; } i = mri->mri_next; @@ -95,7 +97,7 @@ again: return (NULL); } mi->mi_wantcmd = 1; - sleep((caddr_t) &mi->mi_wantcmd, PCMD); + (void) tsleep(&mi->mi_wantcmd, PCMD, "mscpwcmd", 0); goto again; } mi->mi_credits--; @@ -130,7 +132,7 @@ int mscp_aeb_xor = 0x8000bb80; */ void mscp_dorsp(mi) - register struct mscp_softc *mi; + struct mscp_softc *mi; { struct device *drive; struct mscp_device *me = mi->mi_me; @@ -140,6 +142,7 @@ mscp_dorsp(mi) struct mscp_xi *mxi; int nextrsp; int st, error; + extern int cold; extern struct mscp slavereply; nextrsp = mi->mi_rsp.mri_next; diff --git a/sys/arch/vax/mscp/mscp_disk.c b/sys/arch/vax/mscp/mscp_disk.c index ae0b4eb2a44..6d7ab2c5729 100644 --- a/sys/arch/vax/mscp/mscp_disk.c +++ b/sys/arch/vax/mscp/mscp_disk.c @@ -1,5 +1,5 @@ -/* $OpenBSD: mscp_disk.c,v 1.8 2001/07/04 05:12:57 csapuntz Exp $ */ -/* $NetBSD: mscp_disk.c,v 1.21 1999/06/06 19:16:18 ragge Exp $ */ +/* $OpenBSD: mscp_disk.c,v 1.9 2001/12/05 03:04:38 hugh Exp $ */ +/* $NetBSD: mscp_disk.c,v 1.30 2001/11/13 07:38:28 lukem Exp $ */ /* * Copyright (c) 1996 Ludd, University of Lule}, Sweden. * Copyright (c) 1988 Regents of the University of California. @@ -49,6 +49,8 @@ * write bad block forwarding code */ +#include <sys/cdefs.h> + #include <sys/param.h> #include <sys/buf.h> #include <sys/device.h> @@ -66,7 +68,6 @@ #include <machine/bus.h> #include <machine/cpu.h> -#include <machine/rpb.h> #include <arch/vax/mscp/mscp.h> #include <arch/vax/mscp/mscpreg.h> @@ -118,7 +119,7 @@ int rasize __P((dev_t)); int ra_putonline __P((struct ra_softc *)); struct cfattach ra_ca = { - sizeof(struct ra_softc), (cfmatch_t)ramatch, raattach + sizeof(struct ra_softc), (cfmatch_t)ramatch, rxattach }; /* @@ -137,7 +138,7 @@ ramatch(parent, cf, aux) if ((da->da_typ & MSCPBUS_DISK) == 0) return 0; if (cf->cf_loc[0] != -1 && cf->cf_loc[0] != mp->mscp_unit) - return 0; + return 0; /* * Check if this disk is a floppy; then don't configure it. * Seems to be a safe way to test it per Chris Torek. @@ -147,29 +148,6 @@ ramatch(parent, cf, aux) return 1; } -/* - * The attach routine only checks and prints drive type. - * Bringing the disk online is done when the disk is accessed - * the first time. - */ -void -raattach(parent, self, aux) - struct device *parent, *self; - void *aux; -{ - struct ra_softc *ra = (void *)self; - struct mscp_softc *mi = (void *)parent; - - rxattach(parent, self, aux); - /* - * Find out if we booted from this disk. - */ - if ((B_TYPE(bootdev) == BDEV_UDA) && (ra->ra_hwunit == B_UNIT(bootdev)) - && (mi->mi_ctlrnr == B_CONTROLLER(bootdev)) - && (mi->mi_adapnr == B_ADAPTOR(bootdev))) - booted_from = self; -} - /* * (Try to) put the drive online. This is done the first time the * drive is opened, or if it har fallen offline. @@ -211,7 +189,7 @@ raopen(dev, flag, fmt, p) int flag, fmt; struct proc *p; { - register struct ra_softc *ra; + struct ra_softc *ra; int part, unit, mask; /* * Make sure this is a reasonable open request. @@ -272,8 +250,8 @@ raclose(dev, flags, fmt, p) int flags, fmt; struct proc *p; { - register int unit = DISKUNIT(dev); - register struct ra_softc *ra = ra_cd.cd_devs[unit]; + int unit = DISKUNIT(dev); + struct ra_softc *ra = ra_cd.cd_devs[unit]; int mask = (1 << DISKPART(dev)); switch (fmt) { @@ -293,9 +271,10 @@ raclose(dev, flags, fmt, p) */ #if notyet if (ra->ra_openpart == 0) { - s = splimp(); - while (udautab[unit].b_actf) - sleep((caddr_t)&udautab[unit], PZERO - 1); + s = spluba(); + while (BUFQ_FIRST(&udautab[unit]) != NULL) + (void) tsleep(&udautab[unit], PZERO - 1, + "raclose", 0); splx(s); ra->ra_state = CLOSED; ra->ra_wlabel = 0; @@ -309,15 +288,15 @@ raclose(dev, flags, fmt, p) */ void rastrategy(bp) - register struct buf *bp; + struct buf *bp; { - register int unit; - register struct ra_softc *ra; + int unit; + struct ra_softc *ra; /* * Make sure this is a reasonable drive to use. */ unit = DISKUNIT(bp->b_dev); - if (unit >= ra_cd.cd_ndevs || (ra = ra_cd.cd_devs[unit]) == NULL) { + if (unit > ra_cd.cd_ndevs || (ra = ra_cd.cd_devs[unit]) == NULL) { bp->b_error = ENXIO; bp->b_flags |= B_ERROR; goto done; @@ -385,10 +364,13 @@ raioctl(dev, cmd, data, flag, p) int flag; struct proc *p; { - register int unit = DISKUNIT(dev); - register struct disklabel *lp, *tp; - register struct ra_softc *ra = ra_cd.cd_devs[unit]; + int unit = DISKUNIT(dev); + struct disklabel *lp, *tp; + struct ra_softc *ra = ra_cd.cd_devs[unit]; int error = 0; +#ifdef __HAVE_OLD_DISKLABEL + struct disklabel newlabel; +#endif lp = ra->ra_disk.dk_label; @@ -397,6 +379,14 @@ raioctl(dev, cmd, data, flag, p) case DIOCGDINFO: bcopy(lp, data, sizeof (struct disklabel)); break; +#ifdef __HAVE_OLD_DISKLABEL + case ODIOCGDINFO: + bcopy(lp, &newlabel, sizeof disklabel); + if (newlabel.d_npartitions > OLDMAXPARTITIONS) + return ENOTTY; + bcopy(&newlabel, data, sizeof (struct olddisklabel)); + break; +#endif case DIOCGPART: ((struct partinfo *)data)->disklab = lp; @@ -406,11 +396,27 @@ raioctl(dev, cmd, data, flag, p) case DIOCWDINFO: case DIOCSDINFO: +#ifdef __HAVE_OLD_DISKLABEL + case ODIOCWDINFO: + case ODIOCSDINFO: + if (cmd == ODIOCSDINFO || xfer == ODIOCWDINFO) { + memset(&newlabel, 0, sizeof newlabel); + memcpy(&newlabel, data, sizeof (struct olddisklabel)); + tp = &newlabel; + } else +#endif + tp = (struct disklabel *)data; + if ((flag & FWRITE) == 0) error = EBADF; else { - error = setdisklabel(lp, (struct disklabel *)data,0,0); - if ((error == 0) && (cmd == DIOCWDINFO)) { + error = setdisklabel(lp, tp, 0, 0); + if ((error == 0) && (cmd == DIOCWDINFO +#ifdef __HAVE_OLD_DISKLABEL + || cmd == ODIOCWDINFO +#else + )) { +#endif ra->ra_wlabel = 1; error = writedisklabel(dev, rastrategy, lp,0); ra->ra_wlabel = 0; @@ -427,8 +433,15 @@ raioctl(dev, cmd, data, flag, p) #ifdef __NetBSD__ case DIOCGDEFLABEL: +#ifdef __HAVE_OLD_DISKLABEL + case ODIOCGDEFLABEL: + if (cmd == ODIOCGDEFLABEL) + tp = &newlabel; + else +#else tp = (struct disklabel *)data; - bzero(data, sizeof(struct disklabel)); +#endif + bzero(tp, sizeof(struct disklabel)); tp->d_secsize = lp->d_secsize; tp->d_nsectors = lp->d_nsectors; tp->d_ntracks = lp->d_ntracks; @@ -438,8 +451,15 @@ raioctl(dev, cmd, data, flag, p) tp->d_type = DTYPE_MSCP; tp->d_rpm = 3600; rrmakelabel(tp, ra->ra_mediaid); - break; +#ifdef __HAVE_OLD_DISKLABEL + if (cmd == ODIOCGDEFLABEL) { + if (tp->d_npartitions > OLDMAXPARTITIONS) + return ENOTTY; + memcpy(data, tp, sizeof (struct olddisklabel)); + } #endif + break; +#endif /* __NetBSD__ */ default: error = ENOTTY; @@ -466,7 +486,7 @@ int rasize(dev) dev_t dev; { - register int unit = DISKUNIT(dev); + int unit = DISKUNIT(dev); struct ra_softc *ra; if (unit >= ra_cd.cd_ndevs || ra_cd.cd_devs[unit] == 0) @@ -482,8 +502,7 @@ rasize(dev) (ra->ra_disk.dk_label->d_secsize / DEV_BSIZE); } -int -ra_getdev(adaptor, controller, unit, uname) +int ra_getdev(adaptor, controller, unit, uname) int adaptor, controller, unit; char **uname; { @@ -539,7 +558,7 @@ rxmatch(parent, cf, aux) if ((da->da_typ & MSCPBUS_DISK) == 0) return 0; if (cf->cf_loc[0] != -1 && cf->cf_loc[0] != mp->mscp_unit) - return 0; + return 0; /* * Check if this disk is a floppy; then configure it. * Seems to be a safe way to test it per Chris Torek. @@ -633,7 +652,7 @@ rxopen(dev, flag, fmt, p) int flag, fmt; struct proc *p; { - register struct rx_softc *rx; + struct rx_softc *rx; int unit; /* @@ -676,16 +695,16 @@ rxclose(dev, flags, fmt, p) */ void rxstrategy(bp) - register struct buf *bp; + struct buf *bp; { - register int unit; - register struct rx_softc *rx; + int unit; + struct rx_softc *rx; /* * Make sure this is a reasonable drive to use. */ unit = DISKUNIT(bp->b_dev); - if (unit >= rx_cd.cd_ndevs || (rx = rx_cd.cd_devs[unit]) == NULL) { + if (unit > rx_cd.cd_ndevs || (rx = rx_cd.cd_devs[unit]) == NULL) { bp->b_error = ENXIO; bp->b_flags |= B_ERROR; goto done; @@ -747,9 +766,9 @@ rxioctl(dev, cmd, data, flag, p) int flag; struct proc *p; { - register int unit = DISKUNIT(dev); - register struct disklabel *lp; - register struct rx_softc *rx = rx_cd.cd_devs[unit]; + int unit = DISKUNIT(dev); + struct disklabel *lp; + struct rx_softc *rx = rx_cd.cd_devs[unit]; int error = 0; lp = rx->ra_disk.dk_label; @@ -932,8 +951,8 @@ rrmakelabel(dl, type) */ int rrgotstatus(usc, mp) - register struct device *usc; - register struct mscp *mp; + struct device *usc; + struct mscp *mp; { if ((mp->mscp_status & M_ST_MASK) != M_ST_SUCCESS) { printf("%s: attempt to get status failed: ", usc->dv_xname); @@ -967,8 +986,8 @@ rrreplace(usc, mp) /*ARGSUSED*/ int rrioerror(usc, mp, bp) - register struct device *usc; - register struct mscp *mp; + struct device *usc; + struct mscp *mp; struct buf *bp; { struct ra_softc *ra = (void *)usc; diff --git a/sys/arch/vax/mscp/mscp_subr.c b/sys/arch/vax/mscp/mscp_subr.c index c94d5919563..15f8a4a9d22 100644 --- a/sys/arch/vax/mscp/mscp_subr.c +++ b/sys/arch/vax/mscp/mscp_subr.c @@ -1,5 +1,5 @@ -/* $OpenBSD: mscp_subr.c,v 1.3 2000/04/27 03:14:46 bjc Exp $ */ -/* $NetBSD: mscp_subr.c,v 1.12 1999/06/06 19:16:18 ragge Exp $ */ +/* $OpenBSD: mscp_subr.c,v 1.4 2001/12/05 03:04:38 hugh Exp $ */ +/* $NetBSD: mscp_subr.c,v 1.18 2001/11/13 07:38:28 lukem Exp $ */ /* * Copyright (c) 1996 Ludd, University of Lule}, Sweden. * Copyright (c) 1988 Regents of the University of California. @@ -43,6 +43,8 @@ * MSCP generic driver routines */ +#include <sys/cdefs.h> + #include <sys/param.h> #include <sys/device.h> #include <sys/buf.h> @@ -61,10 +63,6 @@ #define b_forw b_hash.le_next -#ifndef offsetof -#define offsetof(type, member) ((size_t)(&((type *)0)->member)) -#endif - int mscp_match __P((struct device *, struct cfdata *, void *)); void mscp_attach __P((struct device *, struct device *, void *)); void mscp_start __P((struct mscp_softc *)); @@ -76,7 +74,7 @@ struct cfattach mscpbus_ca = { sizeof(struct mscp_softc), (cfmatch_t)mscp_match, mscp_attach }; -struct cfdriver mscpbus_cd = { +struct cfdriver mscpbus_cd = { NULL, "mscpbus", DV_DULL }; @@ -178,7 +176,7 @@ mscp_attach(parent, self, aux) } for (i = 0; i < NCMD; i++) { mi->mi_mxiuse |= (1 << i); - if (bus_dmamap_create(mi->mi_dmat, (64*1024), 1, (64*1024), + if (bus_dmamap_create(mi->mi_dmat, (64*1024), 16, (64*1024), 0, BUS_DMA_NOWAIT, &mi->mi_xi[i].mxi_dmam)) { printf("Couldn't alloc dmamap %d\n", i); return; @@ -350,7 +348,6 @@ mscp_init(mi) } /* step3 */ - WRITE_SW((mi->mi_dmam->dm_segs[0].ds_addr >> 16)); status = mscp_waitstep(mi, STEP3MASK, STEP3GOOD); if (status == 0) { @@ -577,10 +574,10 @@ mscp_dgo(mi, mxi) */ void mscp_hexdump(mp) - register struct mscp *mp; + struct mscp *mp; { - register long *p = (long *) mp; - register int i = mp->mscp_msglen; + long *p = (long *) mp; + int i = mp->mscp_msglen; if (i > 256) /* sanity */ i = 256; @@ -772,8 +769,8 @@ void mscp_printevent(mp) struct mscp *mp; { - register int event = mp->mscp_event; - register struct code_decode *cdc; + int event = mp->mscp_event; + struct code_decode *cdc; int c, sc; char *cm, *scm; @@ -813,7 +810,7 @@ static char *codemsg[16] = { int mscp_decodeerror(name, mp, mi) char *name; - register struct mscp *mp; + struct mscp *mp; struct mscp_softc *mi; { int issoft; diff --git a/sys/arch/vax/mscp/mscp_tape.c b/sys/arch/vax/mscp/mscp_tape.c index d08d21495ff..bdc5bf58a1d 100644 --- a/sys/arch/vax/mscp/mscp_tape.c +++ b/sys/arch/vax/mscp/mscp_tape.c @@ -1,5 +1,5 @@ -/* $OpenBSD: mscp_tape.c,v 1.5 2001/07/04 05:12:58 csapuntz Exp $ */ -/* $NetBSD: mscp_tape.c,v 1.14 1999/06/06 19:16:18 ragge Exp $ */ +/* $OpenBSD: mscp_tape.c,v 1.6 2001/12/05 03:04:38 hugh Exp $ */ +/* $NetBSD: mscp_tape.c,v 1.16 2001/11/13 07:38:28 lukem Exp $ */ /* * Copyright (c) 1996 Ludd, University of Lule}, Sweden. * All rights reserved. @@ -41,6 +41,8 @@ * Write status handling code. */ +#include <sys/cdefs.h> + #include <sys/param.h> #include <sys/device.h> #include <sys/kernel.h> @@ -115,7 +117,7 @@ struct cfattach mt_ca = { sizeof(struct mt_softc), (cfmatch_t)mtmatch, mtattach }; -struct cfdriver mt_cd = { +struct cfdriver mt_cd = { NULL, "mt", DV_TAPE }; @@ -197,7 +199,7 @@ mtopen(dev, flag, fmt, p) int flag, fmt; struct proc *p; { - register struct mt_softc *mt; + struct mt_softc *mt; int unit; /* @@ -251,16 +253,16 @@ mtclose(dev, flags, fmt, p) void mtstrategy(bp) - register struct buf *bp; + struct buf *bp; { - register int unit; - register struct mt_softc *mt; + int unit; + struct mt_softc *mt; /* * Make sure this is a reasonable drive to use. */ unit = mtunit(bp->b_dev); - if (unit >= mt_cd.cd_ndevs || (mt = mt_cd.cd_devs[unit]) == NULL) { + if (unit > mt_cd.cd_ndevs || (mt = mt_cd.cd_devs[unit]) == NULL) { bp->b_error = ENXIO; goto bad; } @@ -344,7 +346,7 @@ mtonline(usc, mp) struct device *usc; struct mscp *mp; { - register struct mt_softc *mt = (void *)usc; + struct mt_softc *mt = (void *)usc; wakeup((caddr_t)&mt->mt_state); if ((mp->mscp_status & M_ST_MASK) == M_ST_SUCCESS) @@ -358,8 +360,8 @@ mtonline(usc, mp) */ int mtgotstatus(usc, mp) - register struct device *usc; - register struct mscp *mp; + struct device *usc; + struct mscp *mp; { return (MSCP_DONE); } @@ -390,8 +392,8 @@ static char *mt_ioerrs[] = { /*ARGSUSED*/ int mtioerror(usc, mp, bp) - register struct device *usc; - register struct mscp *mp; + struct device *usc; + struct mscp *mp; struct buf *bp; { struct mt_softc *mt = (void *)usc; @@ -425,8 +427,8 @@ mtioctl(dev, cmd, data, flag, p) int flag; struct proc *p; { - register int unit = mtunit(dev); - register struct mt_softc *mt = mt_cd.cd_devs[unit]; + int unit = mtunit(dev); + struct mt_softc *mt = mt_cd.cd_devs[unit]; struct mtop *mtop; struct mtget *mtget; int error = 0, count; |