Home | History | Annotate | Line # | Download | only in mba
hp.c revision 1.21
      1  1.21   thorpej /*	$NetBSD: hp.c,v 1.21 2000/02/07 20:16:54 thorpej Exp $ */
      2   1.1     ragge /*
      3   1.4     ragge  * Copyright (c) 1996 Ludd, University of Lule}, Sweden.
      4   1.1     ragge  * All rights reserved.
      5   1.1     ragge  *
      6   1.1     ragge  * Redistribution and use in source and binary forms, with or without
      7   1.1     ragge  * modification, are permitted provided that the following conditions
      8   1.1     ragge  * are met:
      9   1.1     ragge  * 1. Redistributions of source code must retain the above copyright
     10   1.1     ragge  *    notice, this list of conditions and the following disclaimer.
     11   1.1     ragge  * 2. Redistributions in binary form must reproduce the above copyright
     12   1.1     ragge  *    notice, this list of conditions and the following disclaimer in the
     13   1.1     ragge  *    documentation and/or other materials provided with the distribution.
     14   1.1     ragge  * 3. All advertising materials mentioning features or use of this software
     15   1.1     ragge  *    must display the following acknowledgement:
     16   1.4     ragge  *      This product includes software developed at Ludd, University of
     17   1.4     ragge  *      Lule}, Sweden and its contributors.
     18   1.1     ragge  * 4. The name of the author may not be used to endorse or promote products
     19   1.1     ragge  *    derived from this software without specific prior written permission
     20   1.1     ragge  *
     21   1.1     ragge  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     22   1.1     ragge  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     23   1.1     ragge  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     24   1.1     ragge  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     25   1.1     ragge  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     26   1.1     ragge  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     27   1.1     ragge  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     28   1.1     ragge  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     29   1.1     ragge  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     30   1.1     ragge  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     31   1.1     ragge  */
     32   1.1     ragge 
     33   1.4     ragge /*
     34   1.4     ragge  * Simple device driver routine for massbuss disks.
     35   1.4     ragge  * TODO:
     36   1.4     ragge  *  Fix support for Standard DEC BAD144 bad block forwarding.
     37   1.4     ragge  *  Be able to to handle soft/hard transfer errors.
     38   1.4     ragge  *  Handle non-data transfer interrupts.
     39   1.4     ragge  *  Autoconfiguration of disk drives 'on the fly'.
     40   1.4     ragge  *  Handle disk media changes.
     41   1.4     ragge  *  Dual-port operations should be supported.
     42   1.4     ragge  */
     43   1.2   mycroft #include <sys/param.h>
     44   1.8     ragge #include <sys/systm.h>
     45   1.4     ragge #include <sys/device.h>
     46   1.4     ragge #include <sys/disklabel.h>
     47   1.4     ragge #include <sys/disk.h>
     48   1.4     ragge #include <sys/dkio.h>
     49   1.4     ragge #include <sys/buf.h>
     50   1.4     ragge #include <sys/stat.h>
     51   1.4     ragge #include <sys/ioccom.h>
     52   1.2   mycroft #include <sys/fcntl.h>
     53   1.2   mycroft #include <sys/syslog.h>
     54  1.14     ragge #include <sys/reboot.h>
     55   1.3   mycroft 
     56   1.4     ragge #include <machine/trap.h>
     57   1.4     ragge #include <machine/pte.h>
     58   1.4     ragge #include <machine/mtpr.h>
     59   1.8     ragge #include <machine/cpu.h>
     60  1.14     ragge #include <machine/rpb.h>
     61   1.4     ragge 
     62   1.4     ragge #include <vax/mba/mbavar.h>
     63   1.2   mycroft #include <vax/mba/mbareg.h>
     64   1.4     ragge #include <vax/mba/hpreg.h>
     65   1.3   mycroft 
     66  1.16       jtk #include "locators.h"
     67  1.16       jtk 
     68   1.4     ragge #define	HPMASK 0xffff
     69   1.1     ragge 
     70   1.4     ragge struct	hp_softc {
     71   1.4     ragge 	struct	device	sc_dev;
     72   1.4     ragge 	struct	disk sc_disk;
     73   1.4     ragge 	struct	mba_device sc_md;	/* Common struct used by mbaqueue. */
     74   1.6     ragge 	int	sc_wlabel;		/* Disklabel area is writable */
     75   1.6     ragge 	int	sc_physnr;		/* Physical disk number */
     76   1.4     ragge };
     77   1.1     ragge 
     78  1.18     ragge int     hpmatch __P((struct device *, struct cfdata *, void *));
     79   1.4     ragge void    hpattach __P((struct device *, struct device *, void *));
     80   1.4     ragge void	hpstrategy __P((struct buf *));
     81   1.4     ragge void	hpstart __P((struct mba_device *));
     82   1.4     ragge int	hpattn __P((struct mba_device *));
     83   1.4     ragge enum	xfer_action hpfinish __P((struct mba_device *, int, int *));
     84   1.4     ragge int	hpopen __P((dev_t, int, int));
     85   1.4     ragge int	hpclose __P((dev_t, int, int));
     86   1.4     ragge int	hpioctl __P((dev_t, u_long, caddr_t, int, struct proc *));
     87   1.4     ragge int	hpdump __P((dev_t, caddr_t, caddr_t, size_t));
     88   1.4     ragge int	hpread __P((dev_t, struct uio *));
     89   1.4     ragge int	hpwrite __P((dev_t, struct uio *));
     90   1.4     ragge int	hpsize __P((dev_t));
     91   1.1     ragge 
     92   1.7     ragge struct	cfattach hp_ca = {
     93   1.7     ragge 	sizeof(struct hp_softc), hpmatch, hpattach
     94   1.1     ragge };
     95  1.17   thorpej 
     96  1.17   thorpej extern struct cfdriver hp_cd;
     97   1.1     ragge 
     98   1.4     ragge /*
     99   1.4     ragge  * Check if this is a disk drive; done by checking type from mbaattach.
    100   1.4     ragge  */
    101   1.4     ragge int
    102  1.18     ragge hpmatch(parent, cf, aux)
    103   1.4     ragge 	struct	device *parent;
    104  1.18     ragge 	struct	cfdata *cf;
    105  1.18     ragge 	void	*aux;
    106   1.4     ragge {
    107   1.4     ragge 	struct	mba_attach_args *ma = aux;
    108   1.1     ragge 
    109  1.16       jtk 	if (cf->cf_loc[MBACF_DRIVE] != MBACF_DRIVE_DEFAULT &&
    110  1.16       jtk 	    cf->cf_loc[MBACF_DRIVE] != ma->unit)
    111   1.4     ragge 		return 0;
    112   1.1     ragge 
    113   1.4     ragge 	if (ma->devtyp != MB_RP)
    114   1.4     ragge 		return 0;
    115   1.1     ragge 
    116   1.4     ragge 	return 1;
    117   1.1     ragge }
    118   1.1     ragge 
    119   1.4     ragge /*
    120   1.4     ragge  * Disk drive found; fake a disklabel and try to read the real one.
    121   1.4     ragge  * If the on-disk label can't be read; we lose.
    122   1.4     ragge  */
    123   1.4     ragge void
    124   1.4     ragge hpattach(parent, self, aux)
    125   1.4     ragge 	struct	device *parent, *self;
    126   1.4     ragge 	void	*aux;
    127   1.4     ragge {
    128   1.4     ragge 	struct	hp_softc *sc = (void *)self;
    129   1.4     ragge 	struct	mba_softc *ms = (void *)parent;
    130   1.4     ragge 	struct	disklabel *dl;
    131   1.4     ragge 	struct  mba_attach_args *ma = aux;
    132   1.4     ragge 	char	*msg;
    133   1.4     ragge 
    134   1.4     ragge 	/*
    135   1.4     ragge 	 * Init the common struct for both the adapter and its slaves.
    136   1.4     ragge 	 */
    137  1.20   thorpej 	BUFQ_INIT(&sc->sc_md.md_q);
    138   1.4     ragge 	sc->sc_md.md_softc = (void *)sc;	/* Pointer to this softc */
    139   1.4     ragge 	sc->sc_md.md_mba = (void *)parent;	/* Pointer to parent softc */
    140   1.4     ragge 	sc->sc_md.md_start = hpstart;		/* Disk start routine */
    141   1.4     ragge 	sc->sc_md.md_attn = hpattn;		/* Disk attention routine */
    142   1.4     ragge 	sc->sc_md.md_finish = hpfinish;		/* Disk xfer finish routine */
    143   1.4     ragge 
    144   1.4     ragge 	ms->sc_md[ma->unit] = &sc->sc_md;	/* Per-unit backpointer */
    145   1.1     ragge 
    146   1.6     ragge 	sc->sc_physnr = ma->unit;
    147   1.4     ragge 	/*
    148   1.4     ragge 	 * Init and attach the disk structure.
    149   1.4     ragge 	 */
    150   1.4     ragge 	sc->sc_disk.dk_name = sc->sc_dev.dv_xname;
    151   1.4     ragge 	disk_attach(&sc->sc_disk);
    152   1.1     ragge 
    153   1.4     ragge 	/*
    154   1.4     ragge 	 * Fake a disklabel to be able to read in the real label.
    155   1.4     ragge 	 */
    156   1.4     ragge 	dl = sc->sc_disk.dk_label;
    157   1.1     ragge 
    158   1.4     ragge 	dl->d_secsize = DEV_BSIZE;
    159   1.4     ragge 	dl->d_ntracks = 1;
    160   1.4     ragge 	dl->d_nsectors = 32;
    161   1.4     ragge 	dl->d_secpercyl = 32;
    162   1.1     ragge 
    163   1.4     ragge 	/*
    164   1.4     ragge 	 * Read in label.
    165   1.4     ragge 	 */
    166   1.4     ragge 	if ((msg = readdisklabel(makedev(0, self->dv_unit * 8), hpstrategy,
    167   1.4     ragge 	    dl, NULL)) != NULL)
    168  1.12  christos 		printf(": %s", msg);
    169  1.12  christos 	printf(": %s, size = %d sectors\n", dl->d_typename, dl->d_secperunit);
    170  1.14     ragge 	/*
    171  1.14     ragge 	 * check if this was what we booted from.
    172  1.14     ragge 	 */
    173  1.14     ragge 	if ((B_TYPE(bootdev) == BDEV_HP) && (ma->unit == B_UNIT(bootdev)) &&
    174  1.14     ragge 	    (ms->sc_physnr == B_ADAPTOR(bootdev)))
    175  1.14     ragge 		booted_from = self;
    176   1.4     ragge }
    177   1.4     ragge 
    178   1.4     ragge 
    179   1.4     ragge void
    180   1.4     ragge hpstrategy(bp)
    181   1.4     ragge 	struct buf *bp;
    182   1.1     ragge {
    183   1.4     ragge 	struct	hp_softc *sc;
    184   1.4     ragge 	struct	buf *gp;
    185  1.19     ragge 	int	unit, s, err;
    186  1.21   thorpej 	struct disklabel *lp;
    187   1.4     ragge 
    188   1.4     ragge 	unit = DISKUNIT(bp->b_dev);
    189   1.7     ragge 	sc = hp_cd.cd_devs[unit];
    190  1.21   thorpej 	lp = sc->sc_disk.dk_label;
    191   1.4     ragge 
    192  1.21   thorpej 	err = bounds_check_with_label(bp, lp, sc->sc_wlabel);
    193  1.19     ragge 	if (err < 0)
    194   1.4     ragge 		goto done;
    195  1.21   thorpej 
    196  1.21   thorpej 	bp->b_rawblkno =
    197  1.21   thorpej 	    bp->b_blkno + lp->d_partitions[DISKPART(bp->b_dev)].p_offset;
    198  1.21   thorpej 	bp->b_cylinder = bp->b_rawblkno / lp->d_secpercyl;
    199  1.21   thorpej 
    200   1.4     ragge 	s = splbio();
    201   1.4     ragge 
    202  1.20   thorpej 	gp = BUFQ_FIRST(&sc->sc_md.md_q);
    203  1.21   thorpej 	disksort_cylinder(&sc->sc_md.md_q, bp);
    204   1.4     ragge 	if (gp == 0)
    205   1.4     ragge 		mbaqueue(&sc->sc_md);
    206   1.4     ragge 
    207   1.4     ragge 	splx(s);
    208   1.4     ragge 	return;
    209   1.4     ragge 
    210   1.4     ragge done:
    211   1.4     ragge 	bp->b_resid = bp->b_bcount;
    212   1.4     ragge 	biodone(bp);
    213   1.4     ragge }
    214   1.1     ragge 
    215   1.1     ragge /*
    216   1.4     ragge  * Start transfer on given disk. Called from mbastart().
    217   1.1     ragge  */
    218   1.4     ragge void
    219   1.4     ragge hpstart(md)
    220   1.4     ragge 	struct	mba_device *md;
    221   1.4     ragge {
    222   1.4     ragge 	struct	hp_softc *sc = md->md_softc;
    223   1.4     ragge 	struct	mba_regs *mr = md->md_mba->sc_mbareg;
    224   1.4     ragge 	volatile struct	hp_regs *hr;
    225   1.4     ragge 	struct	disklabel *lp = sc->sc_disk.dk_label;
    226  1.20   thorpej 	struct	buf *bp = BUFQ_FIRST(&md->md_q);
    227   1.4     ragge 	unsigned bn, cn, sn, tn;
    228   1.4     ragge 	int	part = DISKPART(bp->b_dev);
    229   1.4     ragge 
    230   1.4     ragge 	/*
    231   1.4     ragge 	 * Collect statistics.
    232   1.4     ragge 	 */
    233   1.4     ragge 	disk_busy(&sc->sc_disk);
    234   1.4     ragge 	sc->sc_disk.dk_seek++;
    235   1.4     ragge 
    236   1.4     ragge 	hr = (void *)&mr->mba_md[DISKUNIT(bp->b_dev)];
    237   1.4     ragge 
    238  1.21   thorpej 	bn = bp->b_rawblkno;
    239   1.4     ragge 	if (bn) {
    240   1.4     ragge 		cn = bn / lp->d_secpercyl;
    241   1.4     ragge 		sn = bn % lp->d_secpercyl;
    242   1.4     ragge 		tn = sn / lp->d_nsectors;
    243   1.4     ragge 		sn = sn % lp->d_nsectors;
    244   1.4     ragge 	} else
    245   1.4     ragge 		cn = sn = tn = 0;
    246   1.4     ragge 
    247   1.4     ragge 	hr->hp_dc = cn;
    248   1.4     ragge 	hr->hp_da = (tn << 8) | sn;
    249   1.4     ragge 	if (bp->b_flags & B_READ)
    250   1.4     ragge 		hr->hp_cs1 = HPCS_READ;		/* GO */
    251   1.4     ragge 	else
    252   1.4     ragge 		hr->hp_cs1 = HPCS_WRITE;
    253   1.4     ragge }
    254   1.4     ragge 
    255   1.4     ragge int
    256   1.4     ragge hpopen(dev, flag, fmt)
    257   1.4     ragge 	dev_t	dev;
    258   1.4     ragge 	int	flag, fmt;
    259   1.4     ragge {
    260   1.4     ragge 	struct	hp_softc *sc;
    261   1.4     ragge 	int	unit, part;
    262   1.4     ragge 
    263   1.4     ragge 	unit = DISKUNIT(dev);
    264   1.7     ragge 	if (unit >= hp_cd.cd_ndevs)
    265   1.4     ragge 		return ENXIO;
    266   1.7     ragge 	sc = hp_cd.cd_devs[unit];
    267   1.4     ragge 	if (sc == 0)
    268   1.4     ragge 		return ENXIO;
    269   1.4     ragge 
    270   1.4     ragge 	part = DISKPART(dev);
    271   1.4     ragge 
    272   1.5     ragge 	if (part >= sc->sc_disk.dk_label->d_npartitions)
    273   1.4     ragge 		return ENXIO;
    274   1.4     ragge 
    275   1.4     ragge 	switch (fmt) {
    276   1.4     ragge 	case 	S_IFCHR:
    277   1.4     ragge 		sc->sc_disk.dk_copenmask |= (1 << part);
    278   1.4     ragge 		break;
    279   1.4     ragge 
    280   1.4     ragge 	case	S_IFBLK:
    281   1.4     ragge 		sc->sc_disk.dk_bopenmask |= (1 << part);
    282   1.4     ragge 		break;
    283   1.1     ragge 	}
    284   1.4     ragge 	sc->sc_disk.dk_openmask =
    285   1.4     ragge 	    sc->sc_disk.dk_copenmask | sc->sc_disk.dk_bopenmask;
    286   1.4     ragge 
    287   1.4     ragge 	return 0;
    288   1.4     ragge }
    289   1.4     ragge 
    290   1.4     ragge int
    291   1.4     ragge hpclose(dev, flag, fmt)
    292   1.4     ragge 	dev_t	dev;
    293   1.4     ragge 	int	flag, fmt;
    294   1.4     ragge {
    295   1.4     ragge 	struct	hp_softc *sc;
    296   1.4     ragge 	int	unit, part;
    297   1.4     ragge 
    298   1.4     ragge 	unit = DISKUNIT(dev);
    299   1.7     ragge 	sc = hp_cd.cd_devs[unit];
    300   1.4     ragge 
    301   1.4     ragge 	part = DISKPART(dev);
    302   1.4     ragge 
    303   1.4     ragge 	switch (fmt) {
    304   1.4     ragge 	case 	S_IFCHR:
    305   1.4     ragge 		sc->sc_disk.dk_copenmask &= ~(1 << part);
    306   1.4     ragge 		break;
    307   1.4     ragge 
    308   1.4     ragge 	case	S_IFBLK:
    309   1.4     ragge 		sc->sc_disk.dk_bopenmask &= ~(1 << part);
    310   1.4     ragge 		break;
    311   1.1     ragge 	}
    312   1.4     ragge 	sc->sc_disk.dk_openmask =
    313   1.4     ragge 	    sc->sc_disk.dk_copenmask | sc->sc_disk.dk_bopenmask;
    314   1.4     ragge 
    315   1.4     ragge 	return 0;
    316   1.4     ragge }
    317   1.1     ragge 
    318   1.4     ragge int
    319   1.4     ragge hpioctl(dev, cmd, addr, flag, p)
    320   1.4     ragge 	dev_t	dev;
    321   1.4     ragge 	u_long	cmd;
    322   1.4     ragge 	caddr_t	addr;
    323   1.4     ragge 	int	flag;
    324   1.4     ragge 	struct	proc *p;
    325   1.4     ragge {
    326   1.7     ragge 	struct	hp_softc *sc = hp_cd.cd_devs[DISKUNIT(dev)];
    327   1.4     ragge 	struct	disklabel *lp = sc->sc_disk.dk_label;
    328   1.5     ragge 	int	error;
    329   1.1     ragge 
    330   1.4     ragge 	switch (cmd) {
    331   1.4     ragge 	case	DIOCGDINFO:
    332   1.4     ragge 		bcopy(lp, addr, sizeof (struct disklabel));
    333   1.4     ragge 		return 0;
    334   1.4     ragge 
    335   1.4     ragge 	case	DIOCGPART:
    336   1.4     ragge 		((struct partinfo *)addr)->disklab = lp;
    337   1.4     ragge 		((struct partinfo *)addr)->part =
    338   1.4     ragge 		    &lp->d_partitions[DISKPART(dev)];
    339   1.4     ragge 		break;
    340   1.4     ragge 
    341   1.4     ragge 	case	DIOCSDINFO:
    342   1.4     ragge 		if ((flag & FWRITE) == 0)
    343   1.4     ragge 			return EBADF;
    344   1.4     ragge 
    345   1.4     ragge 		return setdisklabel(lp, (struct disklabel *)addr, 0, 0);
    346   1.4     ragge 
    347   1.4     ragge 	case	DIOCWDINFO:
    348   1.4     ragge 		if ((flag & FWRITE) == 0)
    349   1.5     ragge 			error = EBADF;
    350   1.5     ragge 		else {
    351   1.5     ragge 			sc->sc_wlabel = 1;
    352   1.5     ragge 			error = writedisklabel(dev, hpstrategy, lp, 0);
    353   1.5     ragge 			sc->sc_wlabel = 0;
    354   1.5     ragge 		}
    355   1.5     ragge 		return error;
    356   1.6     ragge 	case	DIOCWLABEL:
    357   1.6     ragge 		if ((flag & FWRITE) == 0)
    358   1.6     ragge 			return EBADF;
    359   1.6     ragge 		sc->sc_wlabel = 1;
    360   1.6     ragge 		break;
    361   1.4     ragge 
    362   1.4     ragge 	default:
    363  1.12  christos 		printf("hpioctl: command %x\n", (unsigned int)cmd);
    364   1.4     ragge 		return ENOTTY;
    365   1.4     ragge 	}
    366   1.6     ragge 	return 0;
    367   1.1     ragge }
    368   1.1     ragge 
    369   1.1     ragge /*
    370   1.4     ragge  * Called when a transfer is finished. Check if transfer went OK,
    371   1.4     ragge  * Return info about what-to-do-now.
    372   1.1     ragge  */
    373   1.4     ragge enum xfer_action
    374   1.4     ragge hpfinish(md, mbasr, attn)
    375   1.4     ragge 	struct	mba_device *md;
    376   1.4     ragge 	int	mbasr, *attn;
    377   1.1     ragge {
    378   1.4     ragge 	struct	hp_softc *sc = md->md_softc;
    379  1.20   thorpej 	struct	buf *bp = BUFQ_FIRST(&md->md_q);
    380   1.4     ragge 	volatile struct  mba_regs *mr = md->md_mba->sc_mbareg;
    381   1.4     ragge 	volatile struct	hp_regs *hr = (void *)&mr->mba_md[DISKUNIT(bp->b_dev)];
    382   1.4     ragge 	int	er1, er2;
    383   1.4     ragge 	volatile int bc; /* to get GCC read whole longword */
    384   1.4     ragge 	unsigned byte;
    385   1.4     ragge 
    386   1.4     ragge 	er1 = hr->hp_er1 & HPMASK;
    387   1.4     ragge 	er2 = hr->hp_er2 & HPMASK;
    388   1.4     ragge 	hr->hp_er1 = hr->hp_er2 = 0;
    389   1.4     ragge hper1:
    390   1.4     ragge 	switch (ffs(er1) - 1) {
    391   1.4     ragge 	case -1:
    392   1.4     ragge 		hr->hp_er1 = 0;
    393   1.4     ragge 		goto hper2;
    394   1.4     ragge 
    395   1.4     ragge 	case HPER1_DCK: /* Corrected? data read. Just notice. */
    396   1.4     ragge 		bc = mr->mba_bc;
    397   1.4     ragge 		byte = ~(bc >> 16);
    398   1.7     ragge 		diskerr(buf, hp_cd.cd_name, "soft ecc", LOG_PRINTF,
    399   1.4     ragge 		    btodb(bp->b_bcount - byte), sc->sc_disk.dk_label);
    400   1.4     ragge 		er1 &= ~(1<<HPER1_DCK);
    401   1.4     ragge 		er1 &= HPMASK;
    402   1.4     ragge 		break;
    403   1.4     ragge 
    404   1.4     ragge 	default:
    405  1.12  christos 		printf("drive error :%s er1 %x er2 %x\n",
    406   1.4     ragge 		    sc->sc_dev.dv_xname, er1, er2);
    407   1.4     ragge 		hr->hp_er1 = hr->hp_er2 = 0;
    408   1.4     ragge 		goto hper2;
    409   1.4     ragge 	}
    410   1.4     ragge 	goto hper1;
    411   1.1     ragge 
    412   1.4     ragge hper2:
    413   1.4     ragge 	mbasr &= ~(MBASR_DTBUSY|MBASR_DTCMP|MBASR_ATTN);
    414   1.4     ragge 	if (mbasr)
    415  1.12  christos 		printf("massbuss error :%s %x\n",
    416   1.4     ragge 		    sc->sc_dev.dv_xname, mbasr);
    417   1.4     ragge 
    418  1.20   thorpej 	BUFQ_FIRST(&md->md_q)->b_resid = 0;
    419  1.20   thorpej 	disk_unbusy(&sc->sc_disk, BUFQ_FIRST(&md->md_q)->b_bcount);
    420   1.4     ragge 	return XFER_FINISH;
    421   1.1     ragge }
    422   1.1     ragge 
    423   1.1     ragge /*
    424   1.4     ragge  * Non-data transfer interrupt; like volume change.
    425   1.1     ragge  */
    426   1.4     ragge int
    427   1.4     ragge hpattn(md)
    428   1.4     ragge 	struct	mba_device *md;
    429   1.4     ragge {
    430   1.4     ragge 	struct	hp_softc *sc = md->md_softc;
    431   1.4     ragge 	struct	mba_softc *ms = (void *)sc->sc_dev.dv_parent;
    432   1.4     ragge 	struct  mba_regs *mr = ms->sc_mbareg;
    433   1.4     ragge 	struct  hp_regs *hr = (void *)&mr->mba_md[sc->sc_dev.dv_unit];
    434   1.4     ragge 	int	er1, er2;
    435   1.4     ragge 
    436   1.4     ragge         er1 = hr->hp_er1 & HPMASK;
    437   1.4     ragge         er2 = hr->hp_er2 & HPMASK;
    438   1.4     ragge 
    439  1.12  christos 	printf("%s: Attention! er1 %x er2 %x\n",
    440   1.4     ragge 		sc->sc_dev.dv_xname, er1, er2);
    441   1.4     ragge 	return 0;
    442   1.4     ragge }
    443   1.4     ragge 
    444   1.4     ragge 
    445   1.4     ragge int
    446   1.4     ragge hpsize(dev)
    447   1.4     ragge 	dev_t	dev;
    448   1.1     ragge {
    449   1.4     ragge 	int	size, unit = DISKUNIT(dev);
    450   1.4     ragge 	struct  hp_softc *sc;
    451   1.4     ragge 
    452   1.7     ragge 	if (unit >= hp_cd.cd_ndevs || hp_cd.cd_devs[unit] == 0)
    453   1.4     ragge 		return -1;
    454   1.4     ragge 
    455   1.7     ragge 	sc = hp_cd.cd_devs[unit];
    456  1.15   thorpej 	size = sc->sc_disk.dk_label->d_partitions[DISKPART(dev)].p_size *
    457  1.15   thorpej 	    (sc->sc_disk.dk_label->d_secsize / DEV_BSIZE);
    458   1.1     ragge 
    459   1.4     ragge 	return size;
    460   1.4     ragge }
    461   1.1     ragge 
    462   1.4     ragge int
    463   1.4     ragge hpdump(dev, a1, a2, size)
    464   1.4     ragge 	dev_t	dev;
    465   1.4     ragge 	caddr_t	a1, a2;
    466   1.4     ragge 	size_t	size;
    467   1.4     ragge {
    468  1.12  christos 	printf("hpdump: Not implemented yet.\n");
    469   1.8     ragge 	return 0;
    470   1.4     ragge }
    471   1.1     ragge 
    472   1.4     ragge int
    473   1.4     ragge hpread(dev, uio)
    474   1.4     ragge 	dev_t dev;
    475   1.4     ragge 	struct uio *uio;
    476   1.4     ragge {
    477   1.4     ragge 	return (physio(hpstrategy, NULL, dev, B_READ, minphys, uio));
    478   1.1     ragge }
    479   1.1     ragge 
    480   1.4     ragge int
    481   1.4     ragge hpwrite(dev, uio)
    482   1.4     ragge 	dev_t dev;
    483   1.4     ragge 	struct uio *uio;
    484   1.1     ragge {
    485   1.4     ragge 	return (physio(hpstrategy, NULL, dev, B_WRITE, minphys, uio));
    486   1.1     ragge }
    487