xref: /csrg-svn/sys/vax/stand/up.c (revision 33408)
123248Smckusick /*
232196Skarels  * Copyright (c) 1982 Regents of the University of California.
323248Smckusick  * All rights reserved.  The Berkeley software License Agreement
423248Smckusick  * specifies the terms and conditions for redistribution.
523248Smckusick  *
6*33408Skarels  *	@(#)up.c	7.3 (Berkeley) 01/28/88
723248Smckusick  */
89974Ssam 
910023Ssam /*
1010023Ssam  * UNIBUS peripheral standalone driver
1110023Ssam  * with ECC correction and bad block forwarding.
1210023Ssam  * Also supports header operation and write
1310023Ssam  * check for data and/or header.
1410023Ssam  */
1532196Skarels #include "param.h"
1632196Skarels #include "inode.h"
1732196Skarels #include "fs.h"
1832196Skarels #include "dkbad.h"
1932196Skarels #include "vmmac.h"
209974Ssam 
21*33408Skarels #include "../vax/pte.h"
229974Ssam 
23*33408Skarels #include "../vaxuba/upreg.h"
24*33408Skarels #include "../vaxuba/ubareg.h"
25*33408Skarels 
2610023Ssam #include "saio.h"
279974Ssam #include "savax.h"
289974Ssam 
2925443Skarels #define RETRIES		27
3025443Skarels 
3110352Shelge #define MAXBADDESC	126	/* max number of bad sectors recorded */
3210352Shelge #define SECTSIZ		512	/* sector size in bytes */
3310352Shelge #define HDRSIZ		4	/* number of bytes in sector header */
3411365Ssam 
3510023Ssam u_short	ubastd[] = { 0776700 };
369974Ssam 
3711143Ssam extern	struct st upst[];
3810023Ssam 
3932196Skarels #ifndef SMALL
4011365Ssam struct  dkbad upbad[MAXNUBA*8];		/* bad sector table */
4132196Skarels #endif
4211365Ssam int 	sectsiz;			/* real sector size */
4311365Ssam 
4425443Skarels struct	up_softc {
4525443Skarels 	char	gottype;
4625443Skarels 	char	type;
4725443Skarels 	char	debug;
4825443Skarels #	define	UPF_BSEDEBUG	01	/* debugging bad sector forwarding */
4925443Skarels #	define	UPF_ECCDEBUG	02	/* debugging ecc correction */
5025443Skarels 	int	retries;
5125443Skarels 	int	ecclim;
5225443Skarels } up_softc[MAXNUBA * 8];
5325443Skarels 
549974Ssam u_char	up_offset[16] = {
559974Ssam 	UPOF_P400, UPOF_M400, UPOF_P400, UPOF_M400,
569974Ssam 	UPOF_P800, UPOF_M800, UPOF_P800, UPOF_M800,
579974Ssam 	UPOF_P1200, UPOF_M1200, UPOF_P1200, UPOF_M1200,
589974Ssam 	0, 0, 0, 0
599974Ssam };
609974Ssam 
619974Ssam upopen(io)
629974Ssam 	register struct iob *io;
639974Ssam {
6410352Shelge 	register unit = io->i_unit;
6510023Ssam 	register struct updevice *upaddr;
6625443Skarels 	register struct up_softc *sc = &up_softc[unit];
6711118Ssam 	register struct st *st;
689974Ssam 
6911143Ssam 	if (io->i_boff < 0 || io->i_boff > 7)
7010023Ssam 		_stop("up bad unit");
7110352Shelge 	upaddr = (struct updevice *)ubamem(unit, ubastd[0]);
7215067Skarels 	upaddr->upcs2 = unit % 8;
7311085Ssam 	while ((upaddr->upcs1 & UP_DVA) == 0)
749974Ssam 		;
7525443Skarels 	if (sc->gottype == 0) {
7610023Ssam 		register int i;
7710023Ssam 		struct iob tio;
7810023Ssam 
7925443Skarels 		sc->retries = RETRIES;
8025443Skarels 		sc->ecclim = 11;
8125443Skarels 		sc->debug = 0;
8225443Skarels 		sc->type = upmaptype(unit, upaddr);
8325443Skarels 		if (sc->type < 0)
8410023Ssam 			_stop("unknown drive type");
8525443Skarels 		st = &upst[sc->type];
8611143Ssam 		if (st->off[io->i_boff] == -1)
8711143Ssam 			_stop("up bad unit");
8832196Skarels #ifndef SMALL
8910023Ssam 		/*
9011365Ssam 		 * Read in the bad sector table.
9110023Ssam 		 */
9210023Ssam 		tio = *io;
9310023Ssam 		tio.i_bn = st->nspc * st->ncyl - st->nsect;
949974Ssam 		tio.i_ma = (char *)&upbad[tio.i_unit];
9510638Shelge 		tio.i_cc = sizeof (struct dkbad);
9610023Ssam 		tio.i_flgs |= F_RDDATA;
9710023Ssam 		for (i = 0; i < 5; i++) {
9810638Shelge 			if (upstrategy(&tio, READ) == sizeof (struct dkbad))
9910023Ssam 				break;
1009974Ssam 			tio.i_bn += 2;
1019974Ssam 		}
1029974Ssam 		if (i == 5) {
10310023Ssam 			printf("Unable to read bad sector table\n");
10410352Shelge 			for (i = 0; i < MAXBADDESC; i++) {
10510352Shelge 				upbad[unit].bt_bad[i].bt_cyl = -1;
10610352Shelge 				upbad[unit].bt_bad[i].bt_trksec = -1;
1079974Ssam 			}
1089974Ssam 		}
10932196Skarels #endif
11025443Skarels 		sc->gottype = 1;
1119974Ssam 	}
11225443Skarels 	st = &upst[sc->type];
1139974Ssam 	io->i_boff = st->off[io->i_boff] * st->nspc;
11410023Ssam 	io->i_flgs &= ~F_TYPEMASK;
115*33408Skarels 	return (0);
1169974Ssam }
1179974Ssam 
1189974Ssam upstrategy(io, func)
1199974Ssam 	register struct iob *io;
1209974Ssam {
12111317Ssam 	int cn, tn, sn, o;
12210352Shelge 	register unit = io->i_unit;
123*33408Skarels 	register daddr_t bn;
1249974Ssam 	int recal, info, waitdry;
1259974Ssam 	register struct updevice *upaddr =
12610352Shelge 	    (struct updevice *)ubamem(unit, ubastd[0]);
12725443Skarels 	struct up_softc *sc = &up_softc[unit];
12825443Skarels 	register struct st *st = &upst[sc->type];
129*33408Skarels 	int error, rv = io->i_cc;
130*33408Skarels #ifndef SMALL
131*33408Skarels 	int doprintf = 0;
132*33408Skarels #endif
1339974Ssam 
13410352Shelge 	sectsiz = SECTSIZ;
13511085Ssam 	if (io->i_flgs & (F_HDR|F_HCHECK))
13610352Shelge 		sectsiz += HDRSIZ;
13711365Ssam 	upaddr->upcs2 = unit % 8;
1389974Ssam 	if ((upaddr->upds & UPDS_VV) == 0) {
1399974Ssam 		upaddr->upcs1 = UP_DCLR|UP_GO;
1409974Ssam 		upaddr->upcs1 = UP_PRESET|UP_GO;
1419974Ssam 		upaddr->upof = UPOF_FMT22;
1429974Ssam 	}
14325443Skarels 	if ((upaddr->upds & UPDS_DREADY) == 0) {
14425443Skarels 		printf("up%d not ready", unit);
14525443Skarels 		return (-1);
14625443Skarels 	}
1479974Ssam 	info = ubasetup(io, 1);
1489974Ssam 	upaddr->upwc = -io->i_cc / sizeof (short);
14911085Ssam 	recal = 0;
15011085Ssam 	io->i_errcnt = 0;
15111085Ssam 
15210638Shelge restart:
15325443Skarels 	error = 0;
15411317Ssam 	o = io->i_cc + (upaddr->upwc * sizeof (short));
15511317Ssam 	upaddr->upba = info + o;
15611317Ssam 	bn = io->i_bn + o / sectsiz;
157*33408Skarels #ifndef SMALL
15825443Skarels 	if (doprintf && sc->debug & (UPF_ECCDEBUG|UPF_BSEDEBUG))
15911386Ssam 		printf("wc=%d o=%d i_bn=%d bn=%d\n",
16011365Ssam 			upaddr->upwc, o, io->i_bn, bn);
161*33408Skarels #endif
16210023Ssam 	while((upaddr->upds & UPDS_DRY) == 0)
16310023Ssam 		;
16410352Shelge 	if (upstart(io, bn) != 0) {
16525443Skarels 		rv = -1;
16625443Skarels 		goto done;
16710352Shelge 	}
1689974Ssam 	do {
1699974Ssam 		DELAY(25);
1709974Ssam 	} while ((upaddr->upcs1 & UP_RDY) == 0);
17111085Ssam 	/*
17211085Ssam 	 * If transfer has completed, free UNIBUS
17311085Ssam 	 * resources and return transfer size.
17411085Ssam 	 */
17515067Skarels 	if ((upaddr->upds&UPDS_ERR) == 0 && (upaddr->upcs1&UP_TRE) == 0)
17615067Skarels 		goto done;
17725443Skarels 	bn = io->i_bn +
17825443Skarels 		(io->i_cc + upaddr->upwc * sizeof (short)) / sectsiz;
17925443Skarels 	if (upaddr->uper1 & (UPER1_DCK|UPER1_ECH))
18025443Skarels 		bn--;
18125443Skarels 	cn = bn/st->nspc;
18225443Skarels 	sn = bn%st->nspc;
18325443Skarels 	tn = sn/st->nsect;
18425443Skarels 	sn = sn%st->nsect;
18532196Skarels #ifndef SMALL
18625443Skarels 	if (sc->debug & (UPF_ECCDEBUG|UPF_BSEDEBUG)) {
18725443Skarels 		printf("up error: sn%d (cyl,trk,sec)=(%d,%d,%d) ",
18825443Skarels 		   bn, cn, tn, sn);
18911386Ssam 		printf("cs2=%b er1=%b er2=%b wc=%d\n",
19011365Ssam 	    	  upaddr->upcs2, UPCS2_BITS, upaddr->uper1,
19111386Ssam 		  UPER1_BITS, upaddr->uper2, UPER2_BITS, upaddr->upwc);
19211365Ssam 	}
19332196Skarels #endif
1949974Ssam 	waitdry = 0;
19511386Ssam 	while ((upaddr->upds&UPDS_DRY) == 0 && ++waitdry < sectsiz)
19610023Ssam 		DELAY(5);
19732196Skarels #ifndef SMALL
19811085Ssam 	if (upaddr->uper1&UPER1_WLE) {
19911085Ssam 		/*
20011085Ssam 		 * Give up on write locked devices immediately.
20111085Ssam 		 */
20211085Ssam 		printf("up%d: write locked\n", unit);
20325443Skarels 		rv = -1;
20425443Skarels 		goto done;
20511085Ssam 	}
20625443Skarels 	if (upaddr->uper2 & UPER2_BSE) {
20725443Skarels 		if ((io->i_flgs&F_NBSF) == 0 && upecc(io, BSE) == 0)
20825443Skarels 			goto success;
20925443Skarels 		error = EBSE;
21025443Skarels 		goto hard;
21125443Skarels 	}
21225443Skarels 	/*
21325443Skarels 	 * ECC error. If a soft error, correct it;
21425443Skarels 	 * if correction is too large, no more retries.
21525443Skarels 	 */
21625443Skarels 	if ((upaddr->uper1 & (UPER1_DCK|UPER1_ECH|UPER1_HCRC)) == UPER1_DCK) {
21725443Skarels 		if (upecc(io, ECC) == 0)
21825443Skarels 			goto success;
21925443Skarels 		error = EECC;
22025443Skarels 		goto hard;
22125443Skarels 	}
22225443Skarels 	/*
22325443Skarels 	 * If the error is a header CRC,
22425443Skarels 	 * check if a replacement sector exists in
22525443Skarels 	 * the bad sector table.
22625443Skarels 	 */
22725443Skarels 	if ((upaddr->uper1&UPER1_HCRC) && (io->i_flgs&F_NBSF) == 0 &&
22825443Skarels 	     upecc(io, BSE) == 0)
22925443Skarels 		goto success;
23032196Skarels #endif
23125443Skarels 	if (++io->i_errcnt > sc->retries) {
2329974Ssam 		/*
2339974Ssam 		 * After 28 retries (16 without offset, and
2349974Ssam 		 * 12 with offset positioning) give up.
2359974Ssam 		 */
23610352Shelge hard:
23725443Skarels 		if (error == 0) {
23825443Skarels 			error = EHER;
23925443Skarels 			if (upaddr->upcs2 & UPCS2_WCE)
24025443Skarels 				error = EWCK;
24125443Skarels 		}
24225443Skarels 		printf("up error: sn%d (cyl,trk,sec)=(%d,%d,%d) ",
24325443Skarels 		   bn, cn, tn, sn);
24425443Skarels 		printf("cs2=%b er1=%b er2=%b\n",
24511085Ssam 		   upaddr->upcs2, UPCS2_BITS, upaddr->uper1,
24611085Ssam 		   UPER1_BITS, upaddr->uper2, UPER2_BITS);
2479974Ssam 		upaddr->upcs1 = UP_TRE|UP_DCLR|UP_GO;
24810352Shelge 		io->i_errblk = bn;
24915067Skarels 		if (io->i_errcnt >= 16) {
25015067Skarels 			upaddr->upof = UPOF_FMT22;
25115067Skarels 			upaddr->upcs1 = UP_RTC|UP_GO;
25215067Skarels 			while ((upaddr->upds&UPDS_DRY) == 0)
25315067Skarels 				DELAY(25);
25415067Skarels 		}
25525443Skarels 		rv = -1;
25625443Skarels 		goto done;
25711085Ssam 	}
25811085Ssam 	/*
2599974Ssam 	 * Clear drive error and, every eight attempts,
2609974Ssam 	 * (starting with the fourth)
2619974Ssam 	 * recalibrate to clear the slate.
2629974Ssam 	 */
2639974Ssam 	upaddr->upcs1 = UP_TRE|UP_DCLR|UP_GO;
26410638Shelge 	if ((io->i_errcnt&07) == 4 ) {
2659974Ssam 		upaddr->upcs1 = UP_RECAL|UP_GO;
26615067Skarels 		while ((upaddr->upds&UPDS_DRY) == 0)
26715067Skarels 			DELAY(25);
2689974Ssam 		upaddr->updc = cn;
2699974Ssam 		upaddr->upcs1 = UP_SEEK|UP_GO;
27015067Skarels 		while ((upaddr->upds&UPDS_DRY) == 0)
27115067Skarels 			DELAY(25);
27215067Skarels 	}
27315067Skarels 	if (io->i_errcnt >= 16 && (func & READ)) {
2749974Ssam 		upaddr->upof = up_offset[io->i_errcnt & 017] | UPOF_FMT22;
2759974Ssam 		upaddr->upcs1 = UP_OFFSET|UP_GO;
27610638Shelge 		while ((upaddr->upds&UPDS_DRY) == 0)
27710638Shelge 			DELAY(25);
2789974Ssam 	}
27910638Shelge 	goto restart;
28011085Ssam 
2819974Ssam success:
28211386Ssam #define	rounddown(x, y)	(((x) / (y)) * (y))
28311386Ssam 	upaddr->upwc = rounddown(upaddr->upwc, sectsiz / sizeof (short));
28411386Ssam 	if (upaddr->upwc) {
285*33408Skarels #ifndef SMALL
28611317Ssam 		doprintf++;
287*33408Skarels #endif
28810638Shelge 		goto restart;
28911317Ssam 	}
29015067Skarels done:
2919974Ssam 	/*
29211365Ssam 	 * Release UNIBUS
2939974Ssam 	 */
2949974Ssam 	ubafree(io, info);
29515067Skarels 	/*
29615067Skarels 	 * If we were offset positioning,
29715067Skarels 	 * return to centerline.
29815067Skarels 	 */
29915067Skarels 	if (io->i_errcnt >= 16) {
30015067Skarels 		upaddr->upof = UPOF_FMT22;
30115067Skarels 		upaddr->upcs1 = UP_RTC|UP_GO;
30215067Skarels 		while ((upaddr->upds&UPDS_DRY) == 0)
30315067Skarels 			DELAY(25);
30415067Skarels 	}
30525443Skarels 	return (rv);
3069974Ssam }
3079974Ssam 
30832196Skarels #ifndef SMALL
3099974Ssam /*
31011143Ssam  * Correct an ECC error, and restart the
31111143Ssam  * i/o to complete the transfer (if necessary).
31211143Ssam  * This is quite complicated because the transfer
31311143Ssam  * may be going to an odd memory address base and/or
3149974Ssam  * across a page boundary.
3159974Ssam  */
31610023Ssam upecc(io, flag)
3179974Ssam 	register struct iob *io;
3189974Ssam 	int flag;
3199974Ssam {
32011365Ssam 	register i, unit = io->i_unit;
32125443Skarels 	register struct up_softc *sc = &up_softc[unit];
3229974Ssam 	register struct updevice *up =
32311365Ssam 		(struct updevice *)ubamem(unit, ubastd[0]);
32410352Shelge 	register struct st *st;
3259974Ssam 	caddr_t addr;
32610410Shelge 	int bn, twc, npf, mask, cn, tn, sn;
32710352Shelge 	daddr_t bbn;
3289974Ssam 
3299974Ssam 	/*
33011143Ssam 	 * Npf is the number of sectors transferred
33111143Ssam 	 * before the sector containing the ECC error;
33211143Ssam 	 * bn is the current block number.
3339974Ssam 	 */
33410352Shelge 	twc = up->upwc;
33511143Ssam 	npf = ((twc * sizeof(short)) + io->i_cc) / sectsiz;
33615067Skarels 	if (flag == ECC)
33715067Skarels 		npf--;
33825443Skarels 	if (sc->debug & UPF_ECCDEBUG)
33911386Ssam 		printf("npf=%d mask=0x%x ec1=%d wc=%d\n",
34011386Ssam 			npf, up->upec2, up->upec1, twc);
34111317Ssam 	bn = io->i_bn + npf;
34225443Skarels 	st = &upst[sc->type];
34310410Shelge 	cn = bn/st->nspc;
34410410Shelge 	sn = bn%st->nspc;
34510410Shelge 	tn = sn/st->nsect;
34610410Shelge 	sn = sn%st->nsect;
34711143Ssam 
3489974Ssam 	/*
34911143Ssam 	 * ECC correction.
3509974Ssam 	 */
3519974Ssam 	if (flag == ECC) {
35225443Skarels 		int bit, o;
35311085Ssam 
3549974Ssam 		mask = up->upec2;
35511365Ssam 		printf("up%d: soft ecc sn%d\n", unit, bn);
35625443Skarels 		for (i = mask, bit = 0; i; i >>= 1)
35725443Skarels 			if (i & 1)
35825443Skarels 				bit++;
35925443Skarels 		if (bit > sc->ecclim) {
36025443Skarels 			printf("%d-bit error\n", bit);
36125443Skarels 			return (1);
36225443Skarels 		}
3639974Ssam 		/*
36411317Ssam 		 * Compute the byte and bit position of
36511317Ssam 		 * the error.  o is the byte offset in
36611317Ssam 		 * the transfer at which the correction
36711317Ssam 		 * applied.
3689974Ssam 		 */
3699974Ssam 		i = up->upec1 - 1;		/* -1 makes 0 origin */
37011386Ssam 		bit = i & 07;
37111386Ssam 		o = (i & ~07) >> 3;
3729974Ssam 		up->upcs1 = UP_TRE|UP_DCLR|UP_GO;
3739974Ssam 		/*
37411143Ssam 		 * Correct while possible bits remain of mask.
37511143Ssam 		 * Since mask contains 11 bits, we continue while
37611143Ssam 		 * the bit offset is > -11.  Also watch out for
37711143Ssam 		 * end of this block and the end of the transfer.
3789974Ssam 		 */
37911317Ssam 		while (o < sectsiz && (npf*sectsiz)+o < io->i_cc && bit > -11) {
3809974Ssam 			/*
38111143Ssam 			 * addr =
38211317Ssam 			 *  (base address of transfer) +
38311143Ssam 			 *  (# sectors transferred before the error) *
38411143Ssam 			 *    (sector size) +
38511317Ssam 			 *  (byte offset to incorrect data)
3869974Ssam 			 */
38711317Ssam 			addr = io->i_ma + (npf * sectsiz) + o;
38811317Ssam 			/*
38911317Ssam 			 * No data transfer occurs with a write check,
39011317Ssam 			 * so don't correct the resident copy of data.
39111317Ssam 			 */
39211365Ssam 			if ((io->i_flgs & (F_CHECK|F_HCHECK)) == 0) {
39325443Skarels 				if (sc->debug & UPF_ECCDEBUG)
39411365Ssam 					printf("addr=0x%x old=0x%x ", addr,
39511365Ssam 						(*addr&0xff));
39610352Shelge 				*addr ^= (mask << bit);
39725443Skarels 				if (sc->debug & UPF_ECCDEBUG)
39811365Ssam 					printf("new=0x%x\n", (*addr&0xff));
39911365Ssam 			}
40011317Ssam 			o++, bit -= 8;
4019974Ssam 		}
40211085Ssam 		return (0);
40311085Ssam 	}
40411143Ssam 
40511143Ssam 	/*
40611143Ssam 	 * Bad sector forwarding.
40711143Ssam 	 */
40811085Ssam 	if (flag == BSE) {
4099974Ssam 		/*
41011143Ssam 		 * If not in bad sector table,
41111143Ssam 		 * indicate a hard error to caller.
4129974Ssam 		 */
41310352Shelge 		up->upcs1 = UP_TRE|UP_DCLR|UP_GO;
41411365Ssam 		if ((bbn = isbad(&upbad[unit], cn, tn, sn)) < 0)
41511085Ssam 			return (1);
41611386Ssam 		bbn = (st->ncyl * st->nspc) - st->nsect - 1 - bbn;
41710352Shelge 		twc = up->upwc + sectsiz;
41811085Ssam 		up->upwc = - (sectsiz / sizeof (short));
41925443Skarels 		if (sc->debug & UPF_BSEDEBUG)
42011365Ssam 			printf("revector sn %d to %d\n", sn, bbn);
4219974Ssam 		/*
42211143Ssam 	 	 * Clear the drive & read the replacement
42311143Ssam 		 * sector.  If this is in the middle of a
42411143Ssam 		 * transfer, then set up the controller
42511143Ssam 		 * registers in a normal fashion.
42611143Ssam 	 	 * The UNIBUS address need not be changed.
42711143Ssam 	 	 */
42811386Ssam 		while ((up->upcs1 & UP_RDY) == 0)
4299974Ssam 			;
43011386Ssam 		if (upstart(io, bbn))
43110352Shelge 			return (1);		/* error */
43210352Shelge 		io->i_errcnt = 0;		/* success */
4339974Ssam 		do {
4349974Ssam 			DELAY(25);
43511386Ssam 		} while ((up->upcs1 & UP_RDY) == 0) ;
43611386Ssam 		if ((up->upds & UPDS_ERR) || (up->upcs1 & UP_TRE)) {
43711386Ssam 			up->upwc = twc - sectsiz;
43810352Shelge 			return (1);
4399974Ssam 		}
4409974Ssam 	}
44110638Shelge 	if (twc)
4429974Ssam 		up->upwc = twc;
44310352Shelge 	return (0);
4449974Ssam }
44532196Skarels #endif
4469974Ssam 
4479974Ssam upstart(io, bn)
44810023Ssam 	register struct iob *io;
44910023Ssam 	daddr_t bn;
4509974Ssam {
4519974Ssam 	register struct updevice *upaddr =
45210023Ssam 		(struct updevice *)ubamem(io->i_unit, ubastd[0]);
45325443Skarels 	register struct up_softc *sc = &up_softc[io->i_unit];
45425443Skarels 	register struct st *st = &upst[sc->type];
4559974Ssam 	int sn, tn;
4569974Ssam 
4579974Ssam 	sn = bn%st->nspc;
4589974Ssam 	tn = sn/st->nsect;
4599974Ssam 	sn %= st->nsect;
4609974Ssam 	upaddr->updc = bn/st->nspc;
4619974Ssam 	upaddr->upda = (tn << 8) + sn;
46210352Shelge 	switch (io->i_flgs & F_TYPEMASK) {
46310023Ssam 
46410023Ssam 	case F_RDDATA:
46510023Ssam 		upaddr->upcs1 = UP_RCOM|UP_GO;
4669974Ssam 		break;
46710023Ssam 
46810023Ssam 	case F_WRDATA:
46910023Ssam 		upaddr->upcs1 = UP_WCOM|UP_GO;
4709974Ssam 		break;
47110023Ssam 
47232196Skarels #ifndef SMALL
47310023Ssam 	case F_HDR|F_RDDATA:
47410023Ssam 		upaddr->upcs1 = UP_RHDR|UP_GO;
47510023Ssam 		break;
47610023Ssam 
47710023Ssam 	case F_HDR|F_WRDATA:
47810023Ssam 		upaddr->upcs1 = UP_WHDR|UP_GO;
47910023Ssam 		break;
48010023Ssam 
48110023Ssam 	case F_CHECK|F_WRDATA:
48210023Ssam 	case F_CHECK|F_RDDATA:
4839974Ssam 		upaddr->upcs1 = UP_WCDATA|UP_GO;
4849974Ssam 		break;
48510023Ssam 
48610023Ssam 	case F_HCHECK|F_WRDATA:
48710023Ssam 	case F_HCHECK|F_RDDATA:
4889974Ssam 		upaddr->upcs1 = UP_WCHDR|UP_GO;
4899974Ssam 		break;
49032196Skarels #endif
49110023Ssam 
4929974Ssam 	default:
49310023Ssam 		io->i_error = ECMD;
49410023Ssam 		io->i_flgs &= ~F_TYPEMASK;
49510023Ssam 		return (1);
4969974Ssam 	}
49710023Ssam 	return (0);
4989974Ssam }
4999974Ssam 
50010023Ssam /*ARGSUSED*/
50110023Ssam upioctl(io, cmd, arg)
50210023Ssam 	struct iob *io;
50310023Ssam 	int cmd;
50410023Ssam 	caddr_t arg;
50510023Ssam {
50632196Skarels #ifndef SMALL
50725443Skarels 	int unit = io->i_unit;
50825443Skarels 	register struct up_softc *sc = &up_softc[unit];
50925443Skarels 	struct st *st = &upst[sc->type];
51010352Shelge 
51110352Shelge 	switch(cmd) {
51210352Shelge 
51311365Ssam 	case SAIODEBUG:
51425443Skarels 		sc->debug = (int)arg;
51525443Skarels 		break;
51611365Ssam 
51710352Shelge 	case SAIODEVDATA:
51825443Skarels 		*(struct st *)arg = *st;
51925443Skarels 		break;
52025443Skarels 
52125443Skarels 	case SAIOGBADINFO:
52225443Skarels 		*(struct dkbad *)arg = upbad[unit];
52325443Skarels 		break;
52425443Skarels 
52525443Skarels 	case SAIOECCLIM:
52625443Skarels 		sc->ecclim = (int)arg;
52725443Skarels 		break;
52825443Skarels 
52925443Skarels 	case SAIORETRIES:
53025443Skarels 		sc->retries = (int)arg;
53125443Skarels 		break;
53225443Skarels 
53325443Skarels 	default:
53425443Skarels 		return (ECMD);
53510352Shelge 	}
53625443Skarels 	return (0);
53732196Skarels #else SMALL
53832196Skarels 	return (ECMD);
53932196Skarels #endif
54010023Ssam }
541