BSD 4_4 release
[unix-history] / usr / src / sys / tahoe / vba / cyreg.h
CommitLineData
bf9edb82
KB
1/*
2 * Copyright (c) 1988 The Regents of the University of California.
3 * All rights reserved.
4 *
5 * This code is derived from software contributed to Berkeley by
6 * Computer Consoles Inc.
7 *
ad787160
C
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. All advertising materials mentioning features or use of this software
17 * must display the following acknowledgement:
18 * This product includes software developed by the University of
19 * California, Berkeley and its contributors.
20 * 4. Neither the name of the University nor the names of its contributors
21 * may be used to endorse or promote products derived from this software
22 * without specific prior written permission.
bf9edb82 23 *
ad787160
C
24 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * SUCH DAMAGE.
bf9edb82 35 *
1c15e888 36 * @(#)cyreg.h 7.8 (Berkeley) 6/28/90
bf9edb82 37 */
d62077b1
SL
38
39/*
40 * Tapemaster controller definitions.
41 */
42
7aefbaf7
MK
43/*
44 * With 20-bit addressing, the intermediate buffer
45 * must be allocated early in startup().
46 */
29a6143e 47#define CYMAXIO (64*1024) /* max i/o size + 1 */
7aefbaf7
MK
48char *cybuf;
49
d62077b1 50/* for byte swapping Multibus values */
0995dc78 51#define htoms(x) (u_short)((((x)>>8)&0xff) | (((x)<<8)&0xff00))
d62077b1
SL
52
53#define b_repcnt b_bcount
54#define b_command b_resid
55
82bc5dc5
MK
56/*
57 * System configuration pointer.
58 * Memory address is jumpered on controller.
59 */
60struct cyscp {
61 char csp_buswidth; /* system bus width */
62#define CSP_16BITS 1 /* 16-bit system bus */
63#define CSP_8BITS 0 /* 8-bit system bus */
64 char csp_unused;
65 u_char csp_scb[4]; /* point to system config block */
66};
67
68/*
69 * System configuration block
70 */
71struct cyscb {
72 char csb_fixed; /* fixed value code (must be 3) */
73 char csb_unused; /* unused */
74 u_char csb_ccb[4]; /* pointer to channel control block */
75};
76
77#define CSB_FIXED 0x3
78
d62077b1
SL
79/*
80 * Channel control block definitions
81 */
82struct cyccb {
83 char cbcw; /* channel control word */
84 char cbgate; /* tpb access gate */
82bc5dc5 85 u_char cbtpb[4]; /* first tape parameter block */
d62077b1
SL
86};
87
88#define GATE_OPEN (char)(0x00)
89#define GATE_CLOSED (char)(0xff)
90
91#define CY_GO(addr) movob((addr), 0xff) /* channel attention */
92#define CY_RESET(addr) movob((addr)+1, 0xff) /* software controller reset */
93
94#define CBCW_IE 0x11 /* interrupt on cmd completion */
95#define CBCW_CLRINT 0x09 /* clear active interrupt */
96
97/*
98 * Tape parameter block definitions
99 */
100struct cytpb {
29a6143e
MK
101 u_long tpcmd; /* command, see below */
102 u_short tpcontrol; /* control word */
103 u_short tpcount; /* return count */
104 u_short tpsize; /* buffer size */
105 u_short tprec; /* records/overrun */
82bc5dc5 106 u_char tpdata[4]; /* pointer to source/dest */
29a6143e 107 u_short tpstatus; /* status */
82bc5dc5 108 u_char tplink[4]; /* pointer to next parameter block */
d62077b1
SL
109};
110
111/* control field bit definitions */
112#define CYCW_UNIT (0x000c<<8) /* unit select mask, 2 bit field */
113#define CYCW_IE (0x0020<<8) /* interrupt enable */
114#define CYCW_LOCK (0x0080<<8) /* bus lock flag */
115#define CYCW_REV (0x0400>>8) /* reverse flag */
116#define CYCW_SPEED (0x0800>>8) /* speed/density */
117#define CYCW_25IPS 0
118#define CYCW_100IPS (0x0800>>8)
119#define CYCW_WIDTH (0x8000>>8) /* width */
120#define CYCW_8BITS 0
121#define CYCW_16BITS (0x8000>>8)
122
123#define CYCW_BITS "\20\3REV\005100IPS\00716BITS\16IE\20LOCK"
124
125/*
126 * Controller commands
127 */
128
129/* control status/commands */
130#define CY_CONFIG (0x00<<24) /* configure */
131#define CY_NOP (0x20<<24) /* no operation */
82bc5dc5 132#define CY_SETPAGE (0x08<<24) /* set page (addr bits 20-23) */
d62077b1
SL
133#define CY_SENSE (0x28<<24) /* drive status */
134#define CY_CLRINT (0x9c<<24) /* clear Multibus interrupt */
135
136/* tape position commands */
137#define CY_REW (0x34<<24) /* rewind tape */
138#define CY_OFFL (0x38<<24) /* off_line and unload */
139#define CY_WEOF (0x40<<24) /* write end-of-file mark */
140#define CY_SFORW (0x70<<24) /* space record forward */
82bc5dc5
MK
141#define CY_SREV (CY_SFORW|CYCW_REV) /* space record backwards */
142#define CY_FSF (0x44<<24) /* space file forward */
143#define CY_BSF (CY_FSF|CYCW_REV) /* space file backwards */
d62077b1
SL
144#define CY_ERASE (0x4c<<24) /* erase record */
145
146/* data transfer commands */
147#define CY_BRCOM (0x10<<24) /* read buffered */
148#define CY_BWCOM (0x14<<24) /* write buffered */
149#define CY_RCOM (0x2c<<24) /* read tape unbuffered */
150#define CY_WCOM (0x30<<24) /* write tape unbuffered */
151
152/* status field bit definitions */
153#define CYS_WP (0x0002<<8) /* write protected, no write ring */
154#define CYS_BSY (0x0004<<8) /* formatter busy */
155#define CYS_RDY (0x0008<<8) /* drive ready */
156#define CYS_EOT (0x0010<<8) /* end of tape detected */
157#define CYS_BOT (0x0020<<8) /* tape is at load point */
158#define CYS_OL (0x0040<<8) /* drive on_line */
159#define CYS_FM (0x0080<<8) /* filemark detected */
160#define CYS_ERR (0x1f00>>8) /* error value mask */
161#define CYS_CR (0x2000>>8) /* controller executed retries */
162#define CYS_CC (0x4000>>8) /* command completed successfully */
163#define CYS_CE (0x8000>>8) /* command execution has begun */
164
165#define CYS_BITS "\20\6CR\7CC\10CE\12WP\13BSY\14RDY\15EOT/BOT\16BOT\17OL\20FM"
166
167/* error codes for CYS_ERR */
168#define CYER_TIMOUT 0x01 /* timed out data busy false */
169#define CYER_TIMOUT1 0x02 /* data busy false,formatter,ready */
170#define CYER_TIMOUT2 0x03 /* time out ready busy false */
171#define CYER_TIMOUT3 0x04 /* time out ready busy true */
172#define CYER_TIMOUT4 0x05 /* time out data busy true */
173#define CYER_NXM 0x06 /* time out memory */
174#define CYER_BLANK 0x07 /* blank tape */
175#define CYER_DIAG 0x08 /* micro-diagnostic */
176#define CYER_EOT 0x09 /* EOT forward, BOT rev. */
177#define CYER_BOT 0x09 /* EOT forward, BOT rev. */
178#define CYER_HERR 0x0a /* retry unsuccessful */
179#define CYER_FIFO 0x0b /* FIFO over/under flow */
180#define CYER_PARITY 0x0d /* drive to tapemaster parity error */
181#define CYER_CKSUM 0x0e /* prom checksum */
182#define CYER_STROBE 0x0f /* time out tape strobe */
183#define CYER_NOTRDY 0x10 /* tape not ready */
184#define CYER_PROT 0x11 /* write, no enable ring */
185#define CYER_JUMPER 0x13 /* missing diagnostic jumper */
186#define CYER_LINK 0x14 /* bad link, link inappropriate */
187#define CYER_FM 0x15 /* unexpected filemark */
188#define CYER_PARAM 0x16 /* bad parameter, byte count ? */
189#define CYER_HDWERR 0x18 /* unidentified hardware error */
190#define CYER_NOSTRM 0x19 /* streaming terminated */
191
192#ifdef CYERROR
193char *cyerror[] = {
82bc5dc5 194 "no error",
d62077b1
SL
195 "timeout",
196 "timeout1",
197 "timeout2",
198 "timeout3",
199 "timeout4",
82bc5dc5 200 "non-existent memory",
d62077b1
SL
201 "blank tape",
202 "micro-diagnostic",
203 "eot/bot detected",
204 "retry unsuccessful",
205 "fifo over/under-flow",
82bc5dc5 206 "#0xc",
d62077b1
SL
207 "drive to controller parity error",
208 "prom checksum",
209 "time out tape strobe (record length error)",
210 "tape not ready",
211 "write protected",
82bc5dc5 212 "#0x12",
d62077b1
SL
213 "missing diagnostic jumper",
214 "invalid link pointer",
215 "unexpected file mark",
82bc5dc5
MK
216 "invalid byte count/parameter",
217 "#0x17",
d62077b1
SL
218 "unidentified hardware error",
219 "streaming terminated"
220};
221#define NCYERROR (sizeof (cyerror) / sizeof (cyerror[0]))
222#endif
223
224/*
225 * Masks defining hard and soft errors (must check against 1<<CYER_code).
226 */
0995dc78 227#define CYMASK(e) (1 << (e))
bf9edb82
KB
228#define CYER_HARD (CYMASK(CYER_TIMOUT)|CYMASK(CYER_TIMOUT1)|\
229 CYMASK(CYER_TIMOUT2)|CYMASK(CYER_TIMOUT3)|CYMASK(CYER_TIMOUT4)|\
230 CYMASK(CYER_NXM)|CYMASK(CYER_DIAG)|CYMASK(CYER_JUMPER)|\
231 CYMASK(CYER_STROBE)|CYMASK(CYER_PROT)|CYMASK(CYER_CKSUM)|\
232 CYMASK(CYER_HERR)|CYMASK(CYER_BLANK))
233#define CYER_RSOFT (CYMASK(CYER_FIFO)|CYMASK(CYER_NOTRDY)|\
234 CYMASK(CYER_PARITY))
235#define CYER_WSOFT (CYMASK(CYER_HERR)|CYMASK(CYER_FIFO)|\
236 CYMASK(CYER_NOTRDY)|CYMASK(CYER_PARITY))