int     del = 0, lcv, poll = -1, retval = XD_ERR_AOK;
int     del = 0, lcv, retval = XD_ERR_AOK;
xdc_reset(xdcsc, quiet, blastmode, error, xdsc)	struct xdc_softc *xdcsc;	int     quiet, blastmode, error;	struct xd_softc *xdsc;{	int     del = 0, lcv, poll = -1, retval = XD_ERR_AOK;	int     oldfree = xdcsc->nfree;	struct xd_iorq *iorq;	/* soft reset hardware */	if (!quiet)		printf("%s: soft reset\n", xdcsc->sc_dev.dv_xname);	xdcsc->xdc->xdc_csr = XDC_RESET;	XDC_WAIT(xdcsc->xdc, del, XDC_RESETUSEC, XDC_RESET);	if (del <= 0) {		blastmode = XD_RSET_ALL;	/* dead, flush all requests */		retval = XD_ERR_FAIL;	}	if (xdsc)		xdc_xdreset(xdcsc, xdsc);	/* fix queues based on "blast-mode" */	for (lcv = 0; lcv < XDC_MAXIOPB; lcv++) {		iorq = &xdcsc->reqs[lcv];		if (XD_STATE(iorq->mode) != XD_SUB_POLL &&		    XD_STATE(iorq->mode) != XD_SUB_WAIT &&		    XD_STATE(iorq->mode) != XD_SUB_NORM)			/* is it active? */			continue;		xdcsc->nrun--;	/* it isn't running any more */		if (blastmode == XD_RSET_ALL || blastmode != lcv) {			/* failed */			iorq->errno = error;			xdcsc->iopbase[lcv].done = xdcsc->iopbase[lcv].errs = 1;			switch (XD_STATE(iorq->mode)) {			case XD_SUB_NORM:			    iorq->buf->b_error = EIO;			    iorq->buf->b_flags |= B_ERROR;			    iorq->buf->b_resid =			       iorq->sectcnt * XDFM_BPS;				/* 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;			case XD_SUB_WAIT:			    wakeup(iorq);			case XD_SUB_POLL:			    xdcsc->ndone++;			    iorq->mode = XD_NEWSTATE(iorq->mode, XD_SUB_DONE);			    break;			}		} else {			/* resubmit, put at front of wait queue */			XDC_HWAIT(xdcsc, lcv);		}	}	/*	 * now, if stuff is waiting, start it.	 * since we just reset it should go	 */	xdc_start(xdcsc, XDC_MAXIOPB);	/* ok, we did it */	if (oldfree == 0 && xdcsc->nfree)		wakeup(&xdcsc->nfree);#ifdef XDC_DIAG	del = xdcsc->nwait + xdcsc->nrun + xdcsc->nfree + xdcsc->ndone;	if (del != XDC_MAXIOPB)		printf("%s: diag: xdc_reset miscount (%d should be %d)!\n",		    xdcsc->sc_dev.dv_xname, del, XDC_MAXIOPB);	else		if (xdcsc->ndone > XDC_MAXIOPB - XDC_SUBWAITLIM)			printf("%s: diag: lots of done jobs (%d)\n",			    xdcsc->sc_dev.dv_xname, xdcsc->ndone);#endif	printf("RESET DONE\n");	return (retval);}