diff options
Diffstat (limited to 'sys/arch/vax/mba')
-rw-r--r-- | sys/arch/vax/mba/hp.c | 81 | ||||
-rw-r--r-- | sys/arch/vax/mba/mba.c | 47 | ||||
-rw-r--r-- | sys/arch/vax/mba/mbavar.h | 6 |
3 files changed, 57 insertions, 77 deletions
diff --git a/sys/arch/vax/mba/hp.c b/sys/arch/vax/mba/hp.c index 633d6a04aa5..962b2c689ee 100644 --- a/sys/arch/vax/mba/hp.c +++ b/sys/arch/vax/mba/hp.c @@ -1,5 +1,5 @@ -/* $OpenBSD: hp.c,v 1.9 1998/10/03 21:18:59 millert Exp $ */ -/* $NetBSD: hp.c,v 1.15 1997/06/24 01:09:37 thorpej Exp $ */ +/* $OpenBSD: hp.c,v 1.10 2000/04/27 03:14:44 bjc Exp $ */ +/* $NetBSD: hp.c,v 1.22 2000/02/12 16:09:33 ragge Exp $ */ /* * Copyright (c) 1996 Ludd, University of Lule}, Sweden. * All rights reserved. @@ -74,7 +74,7 @@ struct hp_softc { int sc_physnr; /* Physical disk number */ }; -int hpmatch __P((struct device *, void *, void *)); +int hpmatch __P((struct device *, struct cfdata *, void *)); void hpattach __P((struct device *, struct device *, void *)); void hpstrategy __P((struct buf *)); void hpstart __P((struct mba_device *)); @@ -88,26 +88,25 @@ int hpread __P((dev_t, struct uio *)); int hpwrite __P((dev_t, struct uio *)); int hpsize __P((dev_t)); -struct cfdriver hp_cd = { - NULL, "hp", DV_DISK -}; - struct cfattach hp_ca = { sizeof(struct hp_softc), hpmatch, hpattach }; +extern struct cfdriver hp_cd; + /* * Check if this is a disk drive; done by checking type from mbaattach. */ int -hpmatch(parent, match, aux) +hpmatch(parent, cf, aux) struct device *parent; - void *match, *aux; + struct cfdata *cf; + void *aux; { - struct cfdata *cf = match; struct mba_attach_args *ma = aux; - if (cf->cf_loc[0] != -1 && cf->cf_loc[0] != ma->unit) + if (cf->cf_loc[MBACF_DRIVE] != MBACF_DRIVE_DEFAULT && + cf->cf_loc[MBACF_DRIVE] != ma->unit) return 0; if (ma->devtyp != MB_RP) @@ -134,6 +133,7 @@ hpattach(parent, self, aux) /* * Init the common struct for both the adapter and its slaves. */ + BUFQ_INIT(&sc->sc_md.md_q); sc->sc_md.md_softc = (void *)sc; /* Pointer to this softc */ sc->sc_md.md_mba = (void *)parent; /* Pointer to parent softc */ sc->sc_md.md_start = hpstart; /* Disk start routine */ @@ -163,7 +163,7 @@ hpattach(parent, self, aux) * Read in label. */ if ((msg = readdisklabel(makedev(0, self->dv_unit * 8), hpstrategy, - dl, NULL, 0)) != NULL) + dl, NULL)) != NULL) printf(": %s", msg); printf(": %s, size = %d sectors\n", dl->d_typename, dl->d_secperunit); /* @@ -181,18 +181,25 @@ hpstrategy(bp) { struct hp_softc *sc; struct buf *gp; - int unit, s; + int unit, s, err; + struct disklabel *lp; unit = DISKUNIT(bp->b_dev); sc = hp_cd.cd_devs[unit]; + lp = sc->sc_disk.dk_label; - if (bounds_check_with_label(bp, sc->sc_disk.dk_label, - sc->sc_disk.dk_cpulabel, sc->sc_wlabel) <= 0) + err = bounds_check_with_label(bp, lp, sc->sc_wlabel); + if (err < 0) goto done; + + bp->b_rawblkno = + bp->b_blkno + lp->d_partitions[DISKPART(bp->b_dev)].p_offset; + bp->b_cylinder = bp->b_rawblkno / lp->d_secpercyl; + s = splbio(); - gp = sc->sc_md.md_q.b_actf; - disksort(&sc->sc_md.md_q, bp); + gp = BUFQ_FIRST(&sc->sc_md.md_q); + disksort_cylinder(&sc->sc_md.md_q, bp); if (gp == 0) mbaqueue(&sc->sc_md); @@ -215,9 +222,8 @@ hpstart(md) struct mba_regs *mr = md->md_mba->sc_mbareg; volatile struct hp_regs *hr; struct disklabel *lp = sc->sc_disk.dk_label; - struct buf *bp = md->md_q.b_actf; + struct buf *bp = BUFQ_FIRST(&md->md_q); unsigned bn, cn, sn, tn; - int part = DISKPART(bp->b_dev); /* * Collect statistics. @@ -227,7 +233,7 @@ hpstart(md) hr = (void *)&mr->mba_md[DISKUNIT(bp->b_dev)]; - bn = bp->b_blkno + lp->d_partitions[part].p_offset; + bn = bp->b_rawblkno; if (bn) { cn = bn / lp->d_secpercyl; sn = bn % lp->d_secpercyl; @@ -368,7 +374,7 @@ hpfinish(md, mbasr, attn) int mbasr, *attn; { struct hp_softc *sc = md->md_softc; - struct buf *bp = md->md_q.b_actf; + struct buf *bp = BUFQ_FIRST(&md->md_q); volatile struct mba_regs *mr = md->md_mba->sc_mbareg; volatile struct hp_regs *hr = (void *)&mr->mba_md[DISKUNIT(bp->b_dev)]; int er1, er2; @@ -407,8 +413,8 @@ hper2: printf("massbuss error :%s %x\n", sc->sc_dev.dv_xname, mbasr); - md->md_q.b_actf->b_resid = 0; - disk_unbusy(&sc->sc_disk, md->md_q.b_actf->b_bcount); + BUFQ_FIRST(&md->md_q)->b_resid = 0; + disk_unbusy(&sc->sc_disk, BUFQ_FIRST(&md->md_q)->b_bcount); return XFER_FINISH; } @@ -445,7 +451,8 @@ hpsize(dev) return -1; sc = hp_cd.cd_devs[unit]; - size = sc->sc_disk.dk_label->d_partitions[DISKPART(dev)].p_size; + size = sc->sc_disk.dk_label->d_partitions[DISKPART(dev)].p_size * + (sc->sc_disk.dk_label->d_secsize / DEV_BSIZE); return size; } @@ -475,29 +482,3 @@ hpwrite(dev, uio) { return (physio(hpstrategy, NULL, dev, B_WRITE, minphys, uio)); } - -/* - * Convert physical adapternr and unit to the unit number used by kernel. - */ -int -hp_getdev(mbanr, unit, uname) - int mbanr, unit; - char **uname; -{ - struct mba_softc *ms; - struct hp_softc *sc; - int i; - - for (i = 0; i < hp_cd.cd_ndevs; i++) { - if (hp_cd.cd_devs[i] == 0) - continue; - - sc = hp_cd.cd_devs[i]; - ms = (void *)sc->sc_dev.dv_parent; - if (ms->sc_physnr == mbanr && sc->sc_physnr == unit) { - *uname = sc->sc_dev.dv_xname; - return i; - } - } - return -1; -} diff --git a/sys/arch/vax/mba/mba.c b/sys/arch/vax/mba/mba.c index 88e269579e9..d11ce0caaa5 100644 --- a/sys/arch/vax/mba/mba.c +++ b/sys/arch/vax/mba/mba.c @@ -1,5 +1,5 @@ -/* $OpenBSD: mba.c,v 1.5 1997/05/29 00:04:59 niklas Exp $ */ -/* $NetBSD: mba.c,v 1.10 1996/10/13 03:35:00 christos Exp $ */ +/* $OpenBSD: mba.c,v 1.6 2000/04/27 03:14:45 bjc Exp $ */ +/* $NetBSD: mba.c,v 1.18 2000/01/24 02:40:36 matt Exp $ */ /* * Copyright (c) 1994, 1996 Ludd, University of Lule}, Sweden. * All rights reserved. @@ -54,6 +54,7 @@ #include <machine/pte.h> #include <machine/pcb.h> #include <machine/sid.h> +#include <machine/cpu.h> #include <vax/mba/mbareg.h> #include <vax/mba/mbavar.h> @@ -70,18 +71,14 @@ struct mbaunit mbaunit[] = { {0, 0, 0} }; -int mbamatch __P((struct device *, void *, void *)); +int mbamatch __P((struct device *, struct cfdata *, void *)); void mbaattach __P((struct device *, struct device *, void *)); -void mbaintr __P((int)); +void mbaintr __P((void *)); int mbaprint __P((void *, const char *)); void mbaqueue __P((struct mba_device *)); void mbastart __P((struct mba_softc *)); void mbamapregs __P((struct mba_softc *)); -struct cfdriver mba_cd = { - NULL, "mba", DV_DULL -}; - struct cfattach mba_cmi_ca = { sizeof(struct mba_softc), mbamatch, mbaattach }; @@ -90,16 +87,18 @@ struct cfattach mba_sbi_ca = { sizeof(struct mba_softc), mbamatch, mbaattach }; +extern struct cfdriver mba_cd; + /* * Look if this is a massbuss adapter. */ int -mbamatch(parent, match, aux) +mbamatch(parent, cf, aux) struct device *parent; - void *match, *aux; + struct cfdata *cf; + void *aux; { struct sbi_attach_args *sa = (struct sbi_attach_args *)aux; - struct cfdata *cf = match; if ((cf->cf_loc[0] != sa->nexnum) && (cf->cf_loc[0] > -1 )) return 0; @@ -123,22 +122,21 @@ mbaattach(parent, self, aux) struct sbi_attach_args *sa = (struct sbi_attach_args *)aux; volatile struct mba_regs *mbar = (struct mba_regs *)sa->nexaddr; struct mba_attach_args ma; - extern struct ivec_dsp idsptch; int i, j; printf("\n"); /* * Set up interrupt vectors for this MBA. */ - bcopy(&idsptch, &sc->sc_dsp, sizeof(struct ivec_dsp)); + sc->sc_dsp = idsptch; + sc->sc_dsp.pushlarg = sc; + sc->sc_dsp.hoppaddr = mbaintr; scb->scb_nexvec[0][sa->nexnum] = scb->scb_nexvec[1][sa->nexnum] = scb->scb_nexvec[2][sa->nexnum] = scb->scb_nexvec[3][sa->nexnum] = &sc->sc_dsp; - sc->sc_dsp.pushlarg = sc->sc_dev.dv_unit; - sc->sc_dsp.hoppaddr = mbaintr; sc->sc_physnr = sa->nexnum - 8; /* MBA's have TR between 8 - 11... */ -#ifdef VAX750 +#if VAX750 if (vax_cputype == VAX_750) sc->sc_physnr += 4; /* ...but not on 11/750 */ #endif @@ -171,9 +169,9 @@ mbaattach(parent, self, aux) */ void mbaintr(mba) - int mba; + void *mba; { - struct mba_softc *sc = mba_cd.cd_devs[mba]; + struct mba_softc *sc = mba; volatile struct mba_regs *mr = sc->sc_mbareg; struct mba_device *md; struct buf *bp; @@ -189,7 +187,7 @@ mbaintr(mba) return; /* During autoconfig */ md = sc->sc_first; - bp = md->md_q.b_actf; + bp = BUFQ_FIRST(&md->md_q); /* * A data-transfer interrupt. Current operation is finished, * call that device's finish routine to see what to do next. @@ -206,13 +204,13 @@ mbaintr(mba) * If more to transfer, start the adapter again * by calling mbastart(). */ - md->md_q.b_actf = bp->b_actf; + BUFQ_REMOVE(&md->md_q, bp); sc->sc_first = md->md_back; md->md_back = 0; if (sc->sc_first == 0) sc->sc_last = (void *)&sc->sc_first; - if (md->md_q.b_actf) { + if (BUFQ_FIRST(&md->md_q) != NULL) { sc->sc_last->md_back = md; sc->sc_last = md; } @@ -287,12 +285,13 @@ mbastart(sc) { struct mba_device *md = sc->sc_first; volatile struct mba_regs *mr = sc->sc_mbareg; - struct buf *bp = md->md_q.b_actf; + struct buf *bp = BUFQ_FIRST(&md->md_q); - disk_reallymapin(md->md_q.b_actf, sc->sc_mbareg->mba_map, 0, PG_V); + disk_reallymapin(BUFQ_FIRST(&md->md_q), sc->sc_mbareg->mba_map, + 0, PG_V); sc->sc_state = SC_ACTIVE; - mr->mba_var = ((u_int)bp->b_un.b_addr & PGOFSET); + mr->mba_var = ((u_int)bp->b_un.b_addr & VAX_PGOFSET); mr->mba_bc = (~bp->b_bcount) + 1; (*md->md_start)(md); /* machine-dependent start */ } diff --git a/sys/arch/vax/mba/mbavar.h b/sys/arch/vax/mba/mbavar.h index e2960d67880..cc1c59a5706 100644 --- a/sys/arch/vax/mba/mbavar.h +++ b/sys/arch/vax/mba/mbavar.h @@ -1,5 +1,5 @@ -/* $OpenBSD: mbavar.h,v 1.3 1997/05/29 00:05:00 niklas Exp $ */ -/* $NetBSD: mbavar.h,v 1.4 1996/04/08 18:39:01 ragge Exp $ */ +/* $OpenBSD: mbavar.h,v 1.4 2000/04/27 03:14:45 bjc Exp $ */ +/* $NetBSD: mbavar.h,v 1.5 2000/01/21 23:39:56 thorpej Exp $ */ /* * Copyright (c) 1994 Ludd, University of Lule}, Sweden * All rights reserved. @@ -98,7 +98,7 @@ struct mba_device { enum xfer_action (*md_finish) __P((struct mba_device *, int, int *)); void *md_softc; /* Backpointer to this units softc. */ struct mba_softc *md_mba; - struct buf md_q; /* Buffer head for transfers */ + struct buf_queue md_q; /* queue of I/O requests */ }; struct mba_softc { |