xref: /csrg-svn/sys/tahoe/vba/cyreg.h (revision 44534)
135478Sbostic /*
235478Sbostic  * Copyright (c) 1988 The Regents of the University of California.
335478Sbostic  * All rights reserved.
435478Sbostic  *
535478Sbostic  * This code is derived from software contributed to Berkeley by
635478Sbostic  * Computer Consoles Inc.
735478Sbostic  *
8*44534Sbostic  * %sccs.include.redist.c%
935478Sbostic  *
10*44534Sbostic  *	@(#)cyreg.h	7.8 (Berkeley) 06/28/90
1135478Sbostic  */
1225676Ssam 
1325979Ssam /*
1425979Ssam  * Tapemaster controller definitions.
1525979Ssam  */
1625676Ssam 
1730719Skarels /*
1830719Skarels  * With 20-bit addressing, the intermediate buffer
1930719Skarels  * must be allocated early in startup().
2030719Skarels  */
2130869Skarels #define	CYMAXIO	(64*1024)		/* max i/o size + 1 */
2230719Skarels char	*cybuf;
2330719Skarels 
2425979Ssam /* for byte swapping Multibus values */
2535477Sbostic #define	htoms(x) (u_short)((((x)>>8)&0xff) | (((x)<<8)&0xff00))
2625676Ssam 
2725979Ssam #define	b_repcnt  b_bcount
2825979Ssam #define	b_command b_resid
2925676Ssam 
3025979Ssam /*
3130372Skarels  * System configuration pointer.
3230372Skarels  * Memory address is jumpered on controller.
3330372Skarels  */
3430372Skarels struct	cyscp {
3530372Skarels 	char	csp_buswidth;	/* system bus width */
3630372Skarels #define	CSP_16BITS	1	/* 16-bit system bus */
3730372Skarels #define	CSP_8BITS	0	/* 8-bit system bus */
3830372Skarels 	char	csp_unused;
3930372Skarels 	u_char	csp_scb[4];	/* point to system config block */
4030372Skarels };
4130372Skarels 
4230372Skarels /*
4330372Skarels  * System configuration block
4430372Skarels  */
4530372Skarels struct	cyscb {
4630372Skarels 	char	csb_fixed;	/* fixed value code (must be 3) */
4730372Skarels 	char	csb_unused;	/* unused */
4830372Skarels 	u_char	csb_ccb[4];	/* pointer to channel control block */
4930372Skarels };
5030372Skarels 
5130372Skarels #define	CSB_FIXED	0x3
5230372Skarels 
5330372Skarels /*
5425979Ssam  * Channel control block definitions
5525979Ssam  */
5625979Ssam struct	cyccb {
5725979Ssam 	char	cbcw;		/* channel control word */
5825979Ssam 	char	cbgate;		/* tpb access gate */
5930372Skarels 	u_char	cbtpb[4];	/* first tape parameter block */
6025979Ssam };
6125676Ssam 
6225979Ssam #define	GATE_OPEN	(char)(0x00)
6325979Ssam #define	GATE_CLOSED	(char)(0xff)
6425676Ssam 
6525979Ssam #define	CY_GO(addr)	movob((addr), 0xff)	/* channel attention */
6625979Ssam #define	CY_RESET(addr)  movob((addr)+1, 0xff) 	/* software controller reset */
6725676Ssam 
6825979Ssam #define	CBCW_IE		0x11		/* interrupt on cmd completion */
6925979Ssam #define	CBCW_CLRINT	0x09		/* clear active interrupt */
7025676Ssam 
7125979Ssam /*
7225979Ssam  * Tape parameter block definitions
7325979Ssam  */
7425979Ssam struct	cytpb {
7530869Skarels 	u_long	tpcmd;		/* command, see below */
7630869Skarels 	u_short	tpcontrol;	/* control word */
7730869Skarels 	u_short	tpcount;	/* return count */
7830869Skarels 	u_short	tpsize;		/* buffer size */
7930869Skarels 	u_short	tprec;		/* records/overrun */
8030372Skarels 	u_char	tpdata[4];	/* pointer to source/dest */
8130869Skarels 	u_short	tpstatus;	/* status */
8230372Skarels 	u_char	tplink[4];	/* pointer to next parameter block */
8325979Ssam };
8425676Ssam 
8525979Ssam /* control field bit definitions */
8625979Ssam #define	CYCW_UNIT	(0x000c<<8) 	/* unit select mask, 2 bit field */
8725979Ssam #define	CYCW_IE		(0x0020<<8)	/* interrupt enable */
8825979Ssam #define	CYCW_LOCK	(0x0080<<8)	/* bus lock flag */
8925979Ssam #define	CYCW_REV	(0x0400>>8)	/* reverse flag */
9025979Ssam #define	CYCW_SPEED	(0x0800>>8)	/* speed/density */
9125979Ssam #define	    CYCW_25IPS	0
9225979Ssam #define	    CYCW_100IPS	(0x0800>>8)
9325979Ssam #define	CYCW_WIDTH  	(0x8000>>8)	/* width */
9425979Ssam #define	    CYCW_8BITS	0
9525979Ssam #define	    CYCW_16BITS	(0x8000>>8)
9625676Ssam 
9725979Ssam #define	CYCW_BITS	"\20\3REV\005100IPS\00716BITS\16IE\20LOCK"
9825676Ssam 
9925979Ssam /*
10025979Ssam  * Controller commands
10125979Ssam  */
10225676Ssam 
10325979Ssam /* control status/commands */
10425979Ssam #define	CY_CONFIG	(0x00<<24)	/* configure */
10525979Ssam #define	CY_NOP		(0x20<<24)	/* no operation */
10630372Skarels #define	CY_SETPAGE	(0x08<<24)	/* set page (addr bits 20-23) */
10725979Ssam #define	CY_SENSE	(0x28<<24)	/* drive status */
10825979Ssam #define	CY_CLRINT	(0x9c<<24)	/* clear Multibus interrupt */
10925676Ssam 
11025979Ssam /* tape position commands */
11125979Ssam #define	CY_REW		(0x34<<24)	/* rewind tape */
11225979Ssam #define	CY_OFFL		(0x38<<24)	/* off_line and unload */
11325979Ssam #define	CY_WEOF		(0x40<<24)	/* write end-of-file mark */
11425979Ssam #define	CY_SFORW	(0x70<<24)	/* space record forward */
11530372Skarels #define	CY_SREV		(CY_SFORW|CYCW_REV) /* space record backwards */
11630372Skarels #define	CY_FSF		(0x44<<24)	/* space file forward */
11730372Skarels #define	CY_BSF		(CY_FSF|CYCW_REV) /* space file backwards */
11825979Ssam #define	CY_ERASE	(0x4c<<24)	/* erase record */
11925676Ssam 
12025979Ssam /* data transfer commands */
12125979Ssam #define	CY_BRCOM	(0x10<<24)	/* read buffered */
12225979Ssam #define	CY_BWCOM	(0x14<<24)	/* write buffered */
12325979Ssam #define	CY_RCOM		(0x2c<<24)	/* read tape unbuffered */
12425979Ssam #define	CY_WCOM		(0x30<<24)	/* write tape unbuffered */
12525676Ssam 
12625979Ssam /* status field bit definitions */
12725979Ssam #define	CYS_WP		(0x0002<<8)	/* write protected, no write ring */
12825979Ssam #define	CYS_BSY		(0x0004<<8)	/* formatter busy */
12925979Ssam #define	CYS_RDY		(0x0008<<8)	/* drive ready */
13025979Ssam #define	CYS_EOT		(0x0010<<8)	/* end of tape detected */
13125979Ssam #define	CYS_BOT		(0x0020<<8)	/* tape is at load point */
13225979Ssam #define	CYS_OL		(0x0040<<8)	/* drive on_line */
13325979Ssam #define	CYS_FM		(0x0080<<8)	/* filemark detected */
13425979Ssam #define	CYS_ERR		(0x1f00>>8)	/* error value mask */
13525979Ssam #define	CYS_CR		(0x2000>>8)	/* controller executed retries */
13625979Ssam #define	CYS_CC		(0x4000>>8)	/* command completed successfully */
13725979Ssam #define	CYS_CE		(0x8000>>8)	/* command execution has begun */
13825676Ssam 
13925979Ssam #define	CYS_BITS "\20\6CR\7CC\10CE\12WP\13BSY\14RDY\15EOT/BOT\16BOT\17OL\20FM"
14025676Ssam 
14125979Ssam /* error codes for CYS_ERR */
14225979Ssam #define	CYER_TIMOUT	0x01	/* timed out data busy false */
14325979Ssam #define	CYER_TIMOUT1	0x02	/* data busy false,formatter,ready */
14425979Ssam #define	CYER_TIMOUT2	0x03	/* time out ready busy false */
14525979Ssam #define	CYER_TIMOUT3	0x04	/* time out ready busy true */
14625979Ssam #define	CYER_TIMOUT4	0x05	/* time out data busy true */
14725979Ssam #define	CYER_NXM	0x06	/* time out memory */
14825979Ssam #define	CYER_BLANK	0x07	/* blank tape */
14925979Ssam #define	CYER_DIAG	0x08	/* micro-diagnostic */
15025979Ssam #define	CYER_EOT	0x09	/* EOT forward, BOT rev. */
15125979Ssam #define	CYER_BOT	0x09	/* EOT forward, BOT rev. */
15225979Ssam #define	CYER_HERR	0x0a	/* retry unsuccessful */
15325979Ssam #define	CYER_FIFO	0x0b	/* FIFO over/under flow */
15425979Ssam #define	CYER_PARITY	0x0d	/* drive to tapemaster parity error */
15525979Ssam #define	CYER_CKSUM	0x0e	/* prom checksum */
15625979Ssam #define	CYER_STROBE	0x0f	/* time out tape strobe */
15725979Ssam #define	CYER_NOTRDY	0x10	/* tape not ready */
15825979Ssam #define	CYER_PROT	0x11	/* write, no enable ring */
15925979Ssam #define	CYER_JUMPER	0x13	/* missing diagnostic jumper */
16025979Ssam #define	CYER_LINK	0x14	/* bad link, link inappropriate */
16125979Ssam #define	CYER_FM		0x15	/* unexpected filemark */
16225979Ssam #define	CYER_PARAM	0x16	/* bad parameter, byte count ? */
16325979Ssam #define	CYER_HDWERR	0x18	/* unidentified hardware error */
16425979Ssam #define	CYER_NOSTRM	0x19	/* streaming terminated */
16525676Ssam 
16625979Ssam #ifdef CYERROR
16725979Ssam char	*cyerror[] = {
16830372Skarels 	"no error",
16925979Ssam 	"timeout",
17025979Ssam 	"timeout1",
17125979Ssam 	"timeout2",
17225979Ssam 	"timeout3",
17325979Ssam 	"timeout4",
17430372Skarels 	"non-existent memory",
17525979Ssam 	"blank tape",
17625979Ssam 	"micro-diagnostic",
17725979Ssam 	"eot/bot detected",
17825979Ssam 	"retry unsuccessful",
17925979Ssam 	"fifo over/under-flow",
18030372Skarels 	"#0xc",
18125979Ssam 	"drive to controller parity error",
18225979Ssam 	"prom checksum",
18325979Ssam 	"time out tape strobe (record length error)",
18425979Ssam 	"tape not ready",
18525979Ssam 	"write protected",
18630372Skarels 	"#0x12",
18725979Ssam 	"missing diagnostic jumper",
18825979Ssam 	"invalid link pointer",
18925979Ssam 	"unexpected file mark",
19030372Skarels 	"invalid byte count/parameter",
19130372Skarels 	"#0x17",
19225979Ssam 	"unidentified hardware error",
19325979Ssam 	"streaming terminated"
19425979Ssam };
19525979Ssam #define	NCYERROR	(sizeof (cyerror) / sizeof (cyerror[0]))
19625979Ssam #endif
19725676Ssam 
19825979Ssam /*
19925979Ssam  * Masks defining hard and soft errors (must check against 1<<CYER_code).
20025979Ssam  */
20135477Sbostic #define	CYMASK(e)	(1 << (e))
20235478Sbostic #define	CYER_HARD	(CYMASK(CYER_TIMOUT)|CYMASK(CYER_TIMOUT1)|\
20335478Sbostic 	CYMASK(CYER_TIMOUT2)|CYMASK(CYER_TIMOUT3)|CYMASK(CYER_TIMOUT4)|\
20435478Sbostic 	CYMASK(CYER_NXM)|CYMASK(CYER_DIAG)|CYMASK(CYER_JUMPER)|\
20535478Sbostic 	CYMASK(CYER_STROBE)|CYMASK(CYER_PROT)|CYMASK(CYER_CKSUM)|\
20635478Sbostic 	CYMASK(CYER_HERR)|CYMASK(CYER_BLANK))
20735478Sbostic #define	CYER_RSOFT	(CYMASK(CYER_FIFO)|CYMASK(CYER_NOTRDY)|\
20835478Sbostic 	CYMASK(CYER_PARITY))
20935478Sbostic #define	CYER_WSOFT	(CYMASK(CYER_HERR)|CYMASK(CYER_FIFO)|\
21035478Sbostic 	CYMASK(CYER_NOTRDY)|CYMASK(CYER_PARITY))
211