xref: /csrg-svn/sys/tahoe/vba/cyreg.h (revision 30372)
1 /*	cyreg.h	7.3	87/01/11	*/
2 
3 /*
4  * Tapemaster controller definitions.
5  */
6 
7 /* for byte swapping Multibus values */
8 #define	htoms(x) (short)((((x)>>8)&0xff) | (((x)<<8)&0xff00))
9 
10 #define	b_repcnt  b_bcount
11 #define	b_command b_resid
12 
13 /*
14  * System configuration pointer.
15  * Memory address is jumpered on controller.
16  */
17 struct	cyscp {
18 	char	csp_buswidth;	/* system bus width */
19 #define	CSP_16BITS	1	/* 16-bit system bus */
20 #define	CSP_8BITS	0	/* 8-bit system bus */
21 	char	csp_unused;
22 	u_char	csp_scb[4];	/* point to system config block */
23 };
24 
25 /*
26  * System configuration block
27  */
28 struct	cyscb {
29 	char	csb_fixed;	/* fixed value code (must be 3) */
30 	char	csb_unused;	/* unused */
31 	u_char	csb_ccb[4];	/* pointer to channel control block */
32 };
33 
34 #define	CSB_FIXED	0x3
35 
36 /*
37  * Channel control block definitions
38  */
39 struct	cyccb {
40 	char	cbcw;		/* channel control word */
41 	char	cbgate;		/* tpb access gate */
42 	u_char	cbtpb[4];	/* first tape parameter block */
43 };
44 
45 #define	GATE_OPEN	(char)(0x00)
46 #define	GATE_CLOSED	(char)(0xff)
47 
48 #define	CY_GO(addr)	movob((addr), 0xff)	/* channel attention */
49 #define	CY_RESET(addr)  movob((addr)+1, 0xff) 	/* software controller reset */
50 
51 #define	CBCW_IE		0x11		/* interrupt on cmd completion */
52 #define	CBCW_CLRINT	0x09		/* clear active interrupt */
53 
54 /*
55  * Tape parameter block definitions
56  */
57 struct	cytpb {
58 	long	tpcmd;		/* command, see below */
59 	short	tpcontrol;	/* control word */
60 	short	tpcount;	/* return count */
61 	short	tpsize;		/* buffer size */
62 	short	tprec;		/* records/overrun */
63 	u_char	tpdata[4];	/* pointer to source/dest */
64 	short	tpstatus;	/* status */
65 	u_char	tplink[4];	/* pointer to next parameter block */
66 };
67 
68 /* control field bit definitions */
69 #define	CYCW_UNIT	(0x000c<<8) 	/* unit select mask, 2 bit field */
70 #define	CYCW_IE		(0x0020<<8)	/* interrupt enable */
71 #define	CYCW_LOCK	(0x0080<<8)	/* bus lock flag */
72 #define	CYCW_REV	(0x0400>>8)	/* reverse flag */
73 #define	CYCW_SPEED	(0x0800>>8)	/* speed/density */
74 #define	    CYCW_25IPS	0
75 #define	    CYCW_100IPS	(0x0800>>8)
76 #define	CYCW_WIDTH  	(0x8000>>8)	/* width */
77 #define	    CYCW_8BITS	0
78 #define	    CYCW_16BITS	(0x8000>>8)
79 
80 #define	CYCW_BITS	"\20\3REV\005100IPS\00716BITS\16IE\20LOCK"
81 
82 /*
83  * Controller commands
84  */
85 
86 /* control status/commands */
87 #define	CY_CONFIG	(0x00<<24)	/* configure */
88 #define	CY_NOP		(0x20<<24)	/* no operation */
89 #define	CY_SETPAGE	(0x08<<24)	/* set page (addr bits 20-23) */
90 #define	CY_SENSE	(0x28<<24)	/* drive status */
91 #define	CY_CLRINT	(0x9c<<24)	/* clear Multibus interrupt */
92 
93 /* tape position commands */
94 #define	CY_REW		(0x34<<24)	/* rewind tape */
95 #define	CY_OFFL		(0x38<<24)	/* off_line and unload */
96 #define	CY_WEOF		(0x40<<24)	/* write end-of-file mark */
97 #define	CY_SFORW	(0x70<<24)	/* space record forward */
98 #define	CY_SREV		(CY_SFORW|CYCW_REV) /* space record backwards */
99 #define	CY_FSF		(0x44<<24)	/* space file forward */
100 #define	CY_BSF		(CY_FSF|CYCW_REV) /* space file backwards */
101 #define	CY_ERASE	(0x4c<<24)	/* erase record */
102 
103 /* data transfer commands */
104 #define	CY_BRCOM	(0x10<<24)	/* read buffered */
105 #define	CY_BWCOM	(0x14<<24)	/* write buffered */
106 #define	CY_RCOM		(0x2c<<24)	/* read tape unbuffered */
107 #define	CY_WCOM		(0x30<<24)	/* write tape unbuffered */
108 
109 /* status field bit definitions */
110 #define	CYS_WP		(0x0002<<8)	/* write protected, no write ring */
111 #define	CYS_BSY		(0x0004<<8)	/* formatter busy */
112 #define	CYS_RDY		(0x0008<<8)	/* drive ready */
113 #define	CYS_EOT		(0x0010<<8)	/* end of tape detected */
114 #define	CYS_BOT		(0x0020<<8)	/* tape is at load point */
115 #define	CYS_OL		(0x0040<<8)	/* drive on_line */
116 #define	CYS_FM		(0x0080<<8)	/* filemark detected */
117 #define	CYS_ERR		(0x1f00>>8)	/* error value mask */
118 #define	CYS_CR		(0x2000>>8)	/* controller executed retries */
119 #define	CYS_CC		(0x4000>>8)	/* command completed successfully */
120 #define	CYS_CE		(0x8000>>8)	/* command execution has begun */
121 
122 #define	CYS_BITS "\20\6CR\7CC\10CE\12WP\13BSY\14RDY\15EOT/BOT\16BOT\17OL\20FM"
123 
124 /* error codes for CYS_ERR */
125 #define	CYER_TIMOUT	0x01	/* timed out data busy false */
126 #define	CYER_TIMOUT1	0x02	/* data busy false,formatter,ready */
127 #define	CYER_TIMOUT2	0x03	/* time out ready busy false */
128 #define	CYER_TIMOUT3	0x04	/* time out ready busy true */
129 #define	CYER_TIMOUT4	0x05	/* time out data busy true */
130 #define	CYER_NXM	0x06	/* time out memory */
131 #define	CYER_BLANK	0x07	/* blank tape */
132 #define	CYER_DIAG	0x08	/* micro-diagnostic */
133 #define	CYER_EOT	0x09	/* EOT forward, BOT rev. */
134 #define	CYER_BOT	0x09	/* EOT forward, BOT rev. */
135 #define	CYER_HERR	0x0a	/* retry unsuccessful */
136 #define	CYER_FIFO	0x0b	/* FIFO over/under flow */
137 #define	CYER_PARITY	0x0d	/* drive to tapemaster parity error */
138 #define	CYER_CKSUM	0x0e	/* prom checksum */
139 #define	CYER_STROBE	0x0f	/* time out tape strobe */
140 #define	CYER_NOTRDY	0x10	/* tape not ready */
141 #define	CYER_PROT	0x11	/* write, no enable ring */
142 #define	CYER_JUMPER	0x13	/* missing diagnostic jumper */
143 #define	CYER_LINK	0x14	/* bad link, link inappropriate */
144 #define	CYER_FM		0x15	/* unexpected filemark */
145 #define	CYER_PARAM	0x16	/* bad parameter, byte count ? */
146 #define	CYER_HDWERR	0x18	/* unidentified hardware error */
147 #define	CYER_NOSTRM	0x19	/* streaming terminated */
148 
149 #ifdef CYERROR
150 char	*cyerror[] = {
151 	"no error",
152 	"timeout",
153 	"timeout1",
154 	"timeout2",
155 	"timeout3",
156 	"timeout4",
157 	"non-existent memory",
158 	"blank tape",
159 	"micro-diagnostic",
160 	"eot/bot detected",
161 	"retry unsuccessful",
162 	"fifo over/under-flow",
163 	"#0xc",
164 	"drive to controller parity error",
165 	"prom checksum",
166 	"time out tape strobe (record length error)",
167 	"tape not ready",
168 	"write protected",
169 	"#0x12",
170 	"missing diagnostic jumper",
171 	"invalid link pointer",
172 	"unexpected file mark",
173 	"invalid byte count/parameter",
174 	"#0x17",
175 	"unidentified hardware error",
176 	"streaming terminated"
177 };
178 #define	NCYERROR	(sizeof (cyerror) / sizeof (cyerror[0]))
179 #endif
180 
181 /*
182  * Masks defining hard and soft errors (must check against 1<<CYER_code).
183  */
184 #define	CYMASK(e)	(1<<(CYER_/**/e))
185 #define	CYER_HARD	(CYMASK(TIMOUT)|CYMASK(TIMOUT1)|CYMASK(TIMOUT2)|\
186     CYMASK(TIMOUT3)|CYMASK(TIMOUT4)|CYMASK(NXM)|CYMASK(DIAG)|CYMASK(JUMPER)|\
187     CYMASK(STROBE)|CYMASK(PROT)|CYMASK(CKSUM)|CYMASK(HERR)|CYMASK(BLANK))
188 #define	CYER_SOFT	(CYMASK(FIFO)|CYMASK(NOTRDY)|CYMASK(PARITY))
189