Home | History | Annotate | Line # | Download | only in mba
hp.c revision 1.37.12.1
      1  1.37.12.1      yamt /*	$NetBSD: hp.c,v 1.37.12.1 2006/06/21 14:57:33 yamt 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.35     lukem 
     44       1.35     lukem #include <sys/cdefs.h>
     45  1.37.12.1      yamt __KERNEL_RCSID(0, "$NetBSD: hp.c,v 1.37.12.1 2006/06/21 14:57:33 yamt Exp $");
     46       1.35     lukem 
     47        1.2   mycroft #include <sys/param.h>
     48        1.8     ragge #include <sys/systm.h>
     49        1.4     ragge #include <sys/device.h>
     50        1.4     ragge #include <sys/disklabel.h>
     51        1.4     ragge #include <sys/disk.h>
     52        1.4     ragge #include <sys/dkio.h>
     53        1.4     ragge #include <sys/buf.h>
     54       1.37      yamt #include <sys/bufq.h>
     55        1.4     ragge #include <sys/stat.h>
     56        1.4     ragge #include <sys/ioccom.h>
     57        1.2   mycroft #include <sys/fcntl.h>
     58        1.2   mycroft #include <sys/syslog.h>
     59       1.14     ragge #include <sys/reboot.h>
     60       1.24     ragge #include <sys/conf.h>
     61       1.30  jdolecek #include <sys/event.h>
     62        1.3   mycroft 
     63       1.24     ragge #include <machine/bus.h>
     64        1.4     ragge #include <machine/trap.h>
     65        1.4     ragge #include <machine/pte.h>
     66        1.4     ragge #include <machine/mtpr.h>
     67        1.8     ragge #include <machine/cpu.h>
     68        1.4     ragge 
     69        1.4     ragge #include <vax/mba/mbavar.h>
     70        1.2   mycroft #include <vax/mba/mbareg.h>
     71        1.4     ragge #include <vax/mba/hpreg.h>
     72        1.3   mycroft 
     73       1.24     ragge #include "ioconf.h"
     74       1.16       jtk #include "locators.h"
     75       1.16       jtk 
     76        1.4     ragge struct	hp_softc {
     77        1.4     ragge 	struct	device	sc_dev;
     78        1.4     ragge 	struct	disk sc_disk;
     79       1.24     ragge 	bus_space_tag_t sc_iot;
     80       1.24     ragge 	bus_space_handle_t sc_ioh;
     81        1.4     ragge 	struct	mba_device sc_md;	/* Common struct used by mbaqueue. */
     82        1.6     ragge 	int	sc_wlabel;		/* Disklabel area is writable */
     83        1.4     ragge };
     84        1.1     ragge 
     85       1.24     ragge int     hpmatch(struct device *, struct cfdata *, void *);
     86       1.24     ragge void    hpattach(struct device *, struct device *, void *);
     87       1.24     ragge void	hpstart(struct mba_device *);
     88       1.24     ragge int	hpattn(struct mba_device *);
     89       1.24     ragge enum	xfer_action hpfinish(struct mba_device *, int, int *);
     90        1.1     ragge 
     91       1.28   thorpej CFATTACH_DECL(hp, sizeof(struct hp_softc),
     92       1.29   thorpej     hpmatch, hpattach, NULL, NULL);
     93       1.17   thorpej 
     94       1.26   gehenna dev_type_open(hpopen);
     95       1.26   gehenna dev_type_close(hpclose);
     96       1.26   gehenna dev_type_read(hpread);
     97       1.26   gehenna dev_type_write(hpwrite);
     98       1.26   gehenna dev_type_ioctl(hpioctl);
     99       1.26   gehenna dev_type_strategy(hpstrategy);
    100       1.26   gehenna dev_type_size(hpsize);
    101       1.26   gehenna 
    102       1.26   gehenna const struct bdevsw hp_bdevsw = {
    103       1.26   gehenna 	hpopen, hpclose, hpstrategy, hpioctl, nulldump, hpsize, D_DISK
    104       1.26   gehenna };
    105       1.26   gehenna 
    106       1.26   gehenna const struct cdevsw hp_cdevsw = {
    107       1.26   gehenna 	hpopen, hpclose, hpread, hpwrite, hpioctl,
    108       1.30  jdolecek 	nostop, notty, nopoll, nommap, nokqfilter, D_DISK
    109       1.26   gehenna };
    110       1.26   gehenna 
    111       1.24     ragge #define HP_WCSR(reg, val) \
    112       1.24     ragge 	bus_space_write_4(sc->sc_iot, sc->sc_ioh, (reg), (val))
    113       1.24     ragge #define HP_RCSR(reg) \
    114       1.24     ragge 	bus_space_read_4(sc->sc_iot, sc->sc_ioh, (reg))
    115       1.24     ragge 
    116        1.1     ragge 
    117        1.4     ragge /*
    118        1.4     ragge  * Check if this is a disk drive; done by checking type from mbaattach.
    119        1.4     ragge  */
    120        1.4     ragge int
    121       1.24     ragge hpmatch(struct device *parent, struct cfdata *cf, void *aux)
    122        1.4     ragge {
    123        1.4     ragge 	struct	mba_attach_args *ma = aux;
    124        1.1     ragge 
    125       1.16       jtk 	if (cf->cf_loc[MBACF_DRIVE] != MBACF_DRIVE_DEFAULT &&
    126       1.24     ragge 	    cf->cf_loc[MBACF_DRIVE] != ma->ma_unit)
    127        1.4     ragge 		return 0;
    128        1.1     ragge 
    129       1.24     ragge 	if (ma->ma_devtyp != MB_RP)
    130        1.4     ragge 		return 0;
    131        1.1     ragge 
    132        1.4     ragge 	return 1;
    133        1.1     ragge }
    134        1.1     ragge 
    135        1.4     ragge /*
    136        1.4     ragge  * Disk drive found; fake a disklabel and try to read the real one.
    137        1.4     ragge  * If the on-disk label can't be read; we lose.
    138        1.4     ragge  */
    139        1.4     ragge void
    140       1.24     ragge hpattach(struct device *parent, struct device *self, void *aux)
    141        1.4     ragge {
    142        1.4     ragge 	struct	hp_softc *sc = (void *)self;
    143        1.4     ragge 	struct	mba_softc *ms = (void *)parent;
    144        1.4     ragge 	struct	disklabel *dl;
    145        1.4     ragge 	struct  mba_attach_args *ma = aux;
    146       1.33       dsl 	const char	*msg;
    147        1.4     ragge 
    148       1.24     ragge 	sc->sc_iot = ma->ma_iot;
    149       1.24     ragge 	sc->sc_ioh = ma->ma_ioh;
    150        1.4     ragge 	/*
    151        1.4     ragge 	 * Init the common struct for both the adapter and its slaves.
    152        1.4     ragge 	 */
    153  1.37.12.1      yamt 	bufq_alloc(&sc->sc_md.md_q, "disksort", BUFQ_SORT_CYLINDER);
    154        1.4     ragge 	sc->sc_md.md_softc = (void *)sc;	/* Pointer to this softc */
    155        1.4     ragge 	sc->sc_md.md_mba = (void *)parent;	/* Pointer to parent softc */
    156        1.4     ragge 	sc->sc_md.md_start = hpstart;		/* Disk start routine */
    157        1.4     ragge 	sc->sc_md.md_attn = hpattn;		/* Disk attention routine */
    158        1.4     ragge 	sc->sc_md.md_finish = hpfinish;		/* Disk xfer finish routine */
    159        1.4     ragge 
    160       1.24     ragge 	ms->sc_md[ma->ma_unit] = &sc->sc_md;	/* Per-unit backpointer */
    161        1.1     ragge 
    162        1.4     ragge 	/*
    163        1.4     ragge 	 * Init and attach the disk structure.
    164        1.4     ragge 	 */
    165        1.4     ragge 	sc->sc_disk.dk_name = sc->sc_dev.dv_xname;
    166        1.4     ragge 	disk_attach(&sc->sc_disk);
    167        1.1     ragge 
    168        1.4     ragge 	/*
    169        1.4     ragge 	 * Fake a disklabel to be able to read in the real label.
    170        1.4     ragge 	 */
    171        1.4     ragge 	dl = sc->sc_disk.dk_label;
    172        1.1     ragge 
    173        1.4     ragge 	dl->d_secsize = DEV_BSIZE;
    174        1.4     ragge 	dl->d_ntracks = 1;
    175        1.4     ragge 	dl->d_nsectors = 32;
    176        1.4     ragge 	dl->d_secpercyl = 32;
    177        1.1     ragge 
    178        1.4     ragge 	/*
    179        1.4     ragge 	 * Read in label.
    180        1.4     ragge 	 */
    181  1.37.12.1      yamt 	if ((msg = readdisklabel(makedev(0, device_unit(self) * 8), hpstrategy,
    182        1.4     ragge 	    dl, NULL)) != NULL)
    183       1.12  christos 		printf(": %s", msg);
    184       1.12  christos 	printf(": %s, size = %d sectors\n", dl->d_typename, dl->d_secperunit);
    185        1.4     ragge }
    186        1.4     ragge 
    187        1.4     ragge 
    188        1.4     ragge void
    189       1.24     ragge hpstrategy(struct buf *bp)
    190        1.1     ragge {
    191        1.4     ragge 	struct	hp_softc *sc;
    192        1.4     ragge 	struct	buf *gp;
    193       1.19     ragge 	int	unit, s, err;
    194       1.21   thorpej 	struct disklabel *lp;
    195        1.4     ragge 
    196        1.4     ragge 	unit = DISKUNIT(bp->b_dev);
    197        1.7     ragge 	sc = hp_cd.cd_devs[unit];
    198       1.21   thorpej 	lp = sc->sc_disk.dk_label;
    199        1.4     ragge 
    200       1.34   thorpej 	err = bounds_check_with_label(&sc->sc_disk, bp, sc->sc_wlabel);
    201       1.32    bouyer 	if (err <= 0)
    202        1.4     ragge 		goto done;
    203       1.21   thorpej 
    204       1.21   thorpej 	bp->b_rawblkno =
    205       1.21   thorpej 	    bp->b_blkno + lp->d_partitions[DISKPART(bp->b_dev)].p_offset;
    206       1.21   thorpej 	bp->b_cylinder = bp->b_rawblkno / lp->d_secpercyl;
    207       1.21   thorpej 
    208        1.4     ragge 	s = splbio();
    209        1.4     ragge 
    210  1.37.12.1      yamt 	gp = BUFQ_PEEK(sc->sc_md.md_q);
    211  1.37.12.1      yamt 	BUFQ_PUT(sc->sc_md.md_q, bp);
    212        1.4     ragge 	if (gp == 0)
    213        1.4     ragge 		mbaqueue(&sc->sc_md);
    214        1.4     ragge 
    215        1.4     ragge 	splx(s);
    216        1.4     ragge 	return;
    217        1.4     ragge 
    218        1.4     ragge done:
    219        1.4     ragge 	bp->b_resid = bp->b_bcount;
    220        1.4     ragge 	biodone(bp);
    221        1.4     ragge }
    222        1.1     ragge 
    223        1.1     ragge /*
    224        1.4     ragge  * Start transfer on given disk. Called from mbastart().
    225        1.1     ragge  */
    226        1.4     ragge void
    227       1.24     ragge hpstart(struct	mba_device *md)
    228        1.4     ragge {
    229        1.4     ragge 	struct	hp_softc *sc = md->md_softc;
    230        1.4     ragge 	struct	disklabel *lp = sc->sc_disk.dk_label;
    231  1.37.12.1      yamt 	struct	buf *bp = BUFQ_PEEK(md->md_q);
    232        1.4     ragge 	unsigned bn, cn, sn, tn;
    233        1.4     ragge 
    234        1.4     ragge 	/*
    235        1.4     ragge 	 * Collect statistics.
    236        1.4     ragge 	 */
    237        1.4     ragge 	disk_busy(&sc->sc_disk);
    238  1.37.12.1      yamt 	iostat_seek(sc->sc_disk.dk_stats);
    239        1.4     ragge 
    240       1.21   thorpej 	bn = bp->b_rawblkno;
    241        1.4     ragge 	if (bn) {
    242        1.4     ragge 		cn = bn / lp->d_secpercyl;
    243        1.4     ragge 		sn = bn % lp->d_secpercyl;
    244        1.4     ragge 		tn = sn / lp->d_nsectors;
    245        1.4     ragge 		sn = sn % lp->d_nsectors;
    246        1.4     ragge 	} else
    247        1.4     ragge 		cn = sn = tn = 0;
    248        1.4     ragge 
    249       1.24     ragge 	HP_WCSR(HP_DC, cn);
    250       1.24     ragge 	HP_WCSR(HP_DA, (tn << 8) | sn);
    251        1.4     ragge 	if (bp->b_flags & B_READ)
    252       1.24     ragge 		HP_WCSR(HP_CS1, HPCS_READ);
    253        1.4     ragge 	else
    254       1.24     ragge 		HP_WCSR(HP_CS1, HPCS_WRITE);
    255        1.4     ragge }
    256        1.4     ragge 
    257        1.4     ragge int
    258  1.37.12.1      yamt hpopen(dev_t dev, int flag, int fmt, struct lwp *l)
    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.37.12.1      yamt hpclose(dev_t dev, int flag, int fmt, struct lwp *l)
    292        1.4     ragge {
    293        1.4     ragge 	struct	hp_softc *sc;
    294        1.4     ragge 	int	unit, part;
    295        1.4     ragge 
    296        1.4     ragge 	unit = DISKUNIT(dev);
    297        1.7     ragge 	sc = hp_cd.cd_devs[unit];
    298        1.4     ragge 
    299        1.4     ragge 	part = DISKPART(dev);
    300        1.4     ragge 
    301        1.4     ragge 	switch (fmt) {
    302        1.4     ragge 	case 	S_IFCHR:
    303        1.4     ragge 		sc->sc_disk.dk_copenmask &= ~(1 << part);
    304        1.4     ragge 		break;
    305        1.4     ragge 
    306        1.4     ragge 	case	S_IFBLK:
    307        1.4     ragge 		sc->sc_disk.dk_bopenmask &= ~(1 << part);
    308        1.4     ragge 		break;
    309        1.1     ragge 	}
    310        1.4     ragge 	sc->sc_disk.dk_openmask =
    311        1.4     ragge 	    sc->sc_disk.dk_copenmask | sc->sc_disk.dk_bopenmask;
    312        1.4     ragge 
    313        1.4     ragge 	return 0;
    314        1.4     ragge }
    315        1.1     ragge 
    316        1.4     ragge int
    317  1.37.12.1      yamt hpioctl(dev_t dev, u_long cmd, caddr_t addr, int flag, struct lwp *l)
    318        1.4     ragge {
    319        1.7     ragge 	struct	hp_softc *sc = hp_cd.cd_devs[DISKUNIT(dev)];
    320        1.4     ragge 	struct	disklabel *lp = sc->sc_disk.dk_label;
    321        1.5     ragge 	int	error;
    322        1.1     ragge 
    323        1.4     ragge 	switch (cmd) {
    324        1.4     ragge 	case	DIOCGDINFO:
    325        1.4     ragge 		bcopy(lp, addr, sizeof (struct disklabel));
    326        1.4     ragge 		return 0;
    327        1.4     ragge 
    328        1.4     ragge 	case	DIOCGPART:
    329        1.4     ragge 		((struct partinfo *)addr)->disklab = lp;
    330        1.4     ragge 		((struct partinfo *)addr)->part =
    331        1.4     ragge 		    &lp->d_partitions[DISKPART(dev)];
    332        1.4     ragge 		break;
    333        1.4     ragge 
    334        1.4     ragge 	case	DIOCSDINFO:
    335        1.4     ragge 		if ((flag & FWRITE) == 0)
    336        1.4     ragge 			return EBADF;
    337        1.4     ragge 
    338        1.4     ragge 		return setdisklabel(lp, (struct disklabel *)addr, 0, 0);
    339        1.4     ragge 
    340        1.4     ragge 	case	DIOCWDINFO:
    341        1.4     ragge 		if ((flag & FWRITE) == 0)
    342        1.5     ragge 			error = EBADF;
    343        1.5     ragge 		else {
    344        1.5     ragge 			sc->sc_wlabel = 1;
    345        1.5     ragge 			error = writedisklabel(dev, hpstrategy, lp, 0);
    346        1.5     ragge 			sc->sc_wlabel = 0;
    347        1.5     ragge 		}
    348        1.5     ragge 		return error;
    349        1.6     ragge 	case	DIOCWLABEL:
    350        1.6     ragge 		if ((flag & FWRITE) == 0)
    351        1.6     ragge 			return EBADF;
    352        1.6     ragge 		sc->sc_wlabel = 1;
    353        1.6     ragge 		break;
    354        1.4     ragge 
    355        1.4     ragge 	default:
    356        1.4     ragge 		return ENOTTY;
    357        1.4     ragge 	}
    358        1.6     ragge 	return 0;
    359        1.1     ragge }
    360        1.1     ragge 
    361        1.1     ragge /*
    362        1.4     ragge  * Called when a transfer is finished. Check if transfer went OK,
    363        1.4     ragge  * Return info about what-to-do-now.
    364        1.1     ragge  */
    365        1.4     ragge enum xfer_action
    366       1.24     ragge hpfinish(struct mba_device *md, int mbasr, int *attn)
    367        1.1     ragge {
    368        1.4     ragge 	struct	hp_softc *sc = md->md_softc;
    369  1.37.12.1      yamt 	struct	buf *bp = BUFQ_PEEK(md->md_q);
    370       1.24     ragge 	int er1, er2, bc;
    371        1.4     ragge 	unsigned byte;
    372        1.4     ragge 
    373       1.24     ragge 	er1 = HP_RCSR(HP_ER1);
    374       1.24     ragge 	er2 = HP_RCSR(HP_ER2);
    375       1.24     ragge 	HP_WCSR(HP_ER1, 0);
    376       1.24     ragge 	HP_WCSR(HP_ER2, 0);
    377       1.24     ragge 
    378        1.4     ragge hper1:
    379        1.4     ragge 	switch (ffs(er1) - 1) {
    380        1.4     ragge 	case -1:
    381       1.24     ragge 		HP_WCSR(HP_ER1, 0);
    382        1.4     ragge 		goto hper2;
    383        1.4     ragge 
    384        1.4     ragge 	case HPER1_DCK: /* Corrected? data read. Just notice. */
    385       1.24     ragge 		bc = bus_space_read_4(md->md_mba->sc_iot,
    386       1.24     ragge 		    md->md_mba->sc_ioh, MBA_BC);
    387        1.4     ragge 		byte = ~(bc >> 16);
    388       1.36        pk 		diskerr(bp, hp_cd.cd_name, "soft ecc", LOG_PRINTF,
    389        1.4     ragge 		    btodb(bp->b_bcount - byte), sc->sc_disk.dk_label);
    390        1.4     ragge 		er1 &= ~(1<<HPER1_DCK);
    391        1.4     ragge 		break;
    392        1.4     ragge 
    393        1.4     ragge 	default:
    394       1.12  christos 		printf("drive error :%s er1 %x er2 %x\n",
    395        1.4     ragge 		    sc->sc_dev.dv_xname, er1, er2);
    396       1.24     ragge 		HP_WCSR(HP_ER1, 0);
    397       1.24     ragge 		HP_WCSR(HP_ER2, 0);
    398        1.4     ragge 		goto hper2;
    399        1.4     ragge 	}
    400        1.4     ragge 	goto hper1;
    401        1.1     ragge 
    402        1.4     ragge hper2:
    403        1.4     ragge 	mbasr &= ~(MBASR_DTBUSY|MBASR_DTCMP|MBASR_ATTN);
    404        1.4     ragge 	if (mbasr)
    405       1.12  christos 		printf("massbuss error :%s %x\n",
    406        1.4     ragge 		    sc->sc_dev.dv_xname, mbasr);
    407        1.4     ragge 
    408  1.37.12.1      yamt 	BUFQ_PEEK(md->md_q)->b_resid = 0;
    409  1.37.12.1      yamt 	disk_unbusy(&sc->sc_disk, BUFQ_PEEK(md->md_q)->b_bcount,
    410       1.31       mrg 	    (bp->b_flags & B_READ));
    411        1.4     ragge 	return XFER_FINISH;
    412        1.1     ragge }
    413        1.1     ragge 
    414        1.1     ragge /*
    415        1.4     ragge  * Non-data transfer interrupt; like volume change.
    416        1.1     ragge  */
    417        1.4     ragge int
    418       1.24     ragge hpattn(struct mba_device *md)
    419        1.4     ragge {
    420        1.4     ragge 	struct	hp_softc *sc = md->md_softc;
    421        1.4     ragge 	int	er1, er2;
    422        1.4     ragge 
    423       1.24     ragge         er1 = HP_RCSR(HP_ER1);
    424       1.24     ragge         er2 = HP_RCSR(HP_ER2);
    425        1.4     ragge 
    426       1.12  christos 	printf("%s: Attention! er1 %x er2 %x\n",
    427        1.4     ragge 		sc->sc_dev.dv_xname, er1, er2);
    428        1.4     ragge 	return 0;
    429        1.4     ragge }
    430        1.4     ragge 
    431        1.4     ragge 
    432        1.4     ragge int
    433       1.24     ragge hpsize(dev_t dev)
    434        1.1     ragge {
    435        1.4     ragge 	int	size, unit = DISKUNIT(dev);
    436        1.4     ragge 	struct  hp_softc *sc;
    437        1.4     ragge 
    438        1.7     ragge 	if (unit >= hp_cd.cd_ndevs || hp_cd.cd_devs[unit] == 0)
    439        1.4     ragge 		return -1;
    440        1.4     ragge 
    441        1.7     ragge 	sc = hp_cd.cd_devs[unit];
    442       1.15   thorpej 	size = sc->sc_disk.dk_label->d_partitions[DISKPART(dev)].p_size *
    443       1.15   thorpej 	    (sc->sc_disk.dk_label->d_secsize / DEV_BSIZE);
    444        1.1     ragge 
    445        1.4     ragge 	return size;
    446        1.4     ragge }
    447        1.1     ragge 
    448        1.4     ragge int
    449       1.24     ragge hpread(dev_t dev, struct uio *uio, int ioflag)
    450        1.4     ragge {
    451        1.4     ragge 	return (physio(hpstrategy, NULL, dev, B_READ, minphys, uio));
    452        1.1     ragge }
    453        1.1     ragge 
    454        1.4     ragge int
    455       1.24     ragge hpwrite(dev_t dev, struct uio *uio, int ioflag)
    456        1.1     ragge {
    457        1.4     ragge 	return (physio(hpstrategy, NULL, dev, B_WRITE, minphys, uio));
    458        1.1     ragge }
    459