xref: /netbsd-src/sys/dev/gpib/cs80busvar.h (revision 23c8222edbfb0f0932d88a8351d3a0cf817dfb9e)
1 /*	$NetBSD: cs80busvar.h,v 1.2 2004/04/19 12:44:10 wiz Exp $	*/
2 
3 /*-
4  * Copyright (c) 2003 The NetBSD Foundation, Inc.
5  * All rights reserved.
6  *
7  * This code is derived from software contributed to The NetBSD Foundation
8  * by Gregory McGarry.
9  *
10  * Redistribution and use in source and binary forms, with or without
11  * modification, are permitted provided that the following conditions
12  * are met:
13  * 1. Redistributions of source code must retain the above copyright
14  *    notice, this list of conditions and the following disclaimer.
15  * 2. Redistributions in binary form must reproduce the above copyright
16  *    notice, this list of conditions and the following disclaimer in the
17  *    documentation and/or other materials provided with the distribution.
18  * 3. All advertising materials mentioning features or use of this software
19  *    must display the following acknowledgement:
20  *        This product includes software developed by the NetBSD
21  *        Foundation, Inc. and its contributors.
22  * 4. Neither the name of The NetBSD Foundation nor the names of its
23  *    contributors may be used to endorse or promote products derived
24  *    from this software without specific prior written permission.
25  *
26  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
27  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
28  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
30  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36  * POSSIBILITY OF SUCH DAMAGE.
37  */
38 
39 #define CS80BUS_NSLAVES		8	/* number of slaves on a bus */
40 #define CS80BUS_NPUNITS		2	/* number of punits per slave */
41 
42 struct cs80bus_attach_args {
43 	gpib_chipset_tag_t ca_ic;
44 	u_int16_t ca_id;		/* device id */
45 	int	ca_slave;		/* GPIB bus slave */
46 	int	ca_punit;		/* physical unit on slave */
47 };
48 
49 struct cs80bus_softc {
50 	struct device sc_dev;		/* generic device glue */
51 	gpib_chipset_tag_t sc_ic;
52 	u_int8_t	sc_rmap[CS80BUS_NSLAVES][CS80BUS_NPUNITS];
53 };
54 
55 
56 /*
57  * CS80/SS80 primary commands
58  */
59 #define	CS80CMD_SCMD		0x05	/* secondary command to follow */
60 #define	CS80CMD_EXEC		0x0e	/* return requested data */
61 #define	CS80CMD_QSTAT		0x10	/* query status of device */
62 #define	CS80CMD_TCMD		0x12	/* transparent message */
63 
64 /*
65  * CS80/SS80 secondary commands
66  *
67  * The arguments in < > indicate the number of parameters and number of
68  * bits per parameter used in the command.
69  */
70 #define	CS80CMD_READ		0x00	/* read sector */
71 #define	CS80CMD_WRITE		0x02	/* write sector */
72 #define	CS80CMD_CLEAR		0x08	/* clear device */
73 #define	CS80CMD_STATUS		0x0d	/* request status */
74 #define	CS80CMD_SADDR		0x10	/* set block number <16,32>*/
75 #define	CS80CMD_SLEN		0x18	/* set block length <8> */
76 #define	CS80CMD_SUNIT(x)	(0x20|(x))	/* set unit */
77 #define	CS80CMD_NOP		0x34	/* no-op */
78 #define CS80CMD_DESC		0x35	/* request device description */
79 #define	CS80CMD_SOPT		0x38	/* set options <8> */
80 #define	CS80CMD_SREL		0x3b	/* set release ? <8> */
81 #define	CS80CMD_SSM		0x3e	/* set status mask <16,16,16,16> */
82 #define CS80CMD_SVOL(x)		(0x40|(x))	/* set volume */
83 #define	CS80CMD_SRAM		0x48	/* set description format <8> */
84 #define	CS80CMD_WFM		0x49	/* write end-of-file record */
85 #define	CS80CMD_UNLOAD		0x4a	/* unload media */
86 
87 struct cs80_describecmd {		/* describe command */
88 	u_int8_t c_unit;
89 	u_int8_t c_vol;
90 	u_int8_t c_cmd;
91 } __attribute__((__packed__));
92 
93 struct	cs80_clearcmd {			/* clear device command */
94 	u_int8_t	c_unit;
95 	u_int8_t	c_cmd;
96 } __attribute__((__packed__));
97 
98 struct	cs80_srcmd {			/* s? release */
99 	u_int8_t	c_unit;
100 	u_int8_t	c_nop;
101 	u_int8_t	c_cmd;
102 	u_int8_t	c_param;
103 } __attribute__((__packed__));
104 
105 struct	cs80_statuscmd {		/* status command */
106 	u_int8_t	c_unit;
107 	u_int8_t	c_sram;
108 	u_int8_t	c_param;
109 	u_int8_t	c_cmd;
110 } __attribute__((__packed__));
111 
112 struct	cs80_ssmcmd {			/* status mask */
113 	u_int8_t	c_unit;
114 	u_int8_t	c_cmd;
115 	u_int16_t	c_refm;		/* "request error" mask */
116 	u_int16_t	c_fefm;		/* "fault error" mask */
117 	u_int16_t	c_aefm;		/* "access error" mask */
118 	u_int16_t	c_iefm;		/* "info error" mask */
119 #define	REF_MASK	0x0
120 #define	FEF_MASK	0x0
121 #define	AEF_MASK	0x0
122 #define	IEF_MASK	0xF970
123 } __attribute__((__packed__));
124 
125 struct cs80_soptcmd {			/* set options */
126 	u_int8_t	c_unit;
127 	u_int8_t	c_nop;
128 	u_int8_t	c_opt;
129 	u_int8_t	c_param;
130 #define C_CC		0x01		/* character count option */
131 #define C_SKSPAR	0x02
132 #define C_SPAR		0x04
133 #define C_IMRPT		0x08
134 } __attribute__((__packed__));
135 
136 
137 
138 
139 /*
140  * Structures returned by functions.
141  */
142 
143 struct cs80_description {
144 	u_int16_t	d_iuw;		/* ctlr: installed unit word */
145 	u_int16_t	d_cmaxxfr;	/* ctlr: max transfer rate (KB) */
146 	u_int8_t	d_ctype;	/* ctlr: controller type */
147 	u_int8_t	d_utype;	/* unit: unit type */
148 	u_int8_t	d_name[3];	/* unit: name (6 BCD digits) */
149 	u_int16_t	d_sectsize;	/* unit: # of bytes per block */
150 	u_int8_t	d_blkbuf;	/* unit: # of blocks can be buffered */
151 	u_int8_t	d_burstsize;	/* unit: recommended burst size */
152 	u_int16_t	d_blocktime;	/* unit: block time (u-sec) */
153 	u_int16_t	d_uavexfr;	/* unit: average transfer rate (Kb) */
154 	u_int16_t	d_retry;	/* unit: retry time (1/100-sec) */
155 	u_int16_t	d_access;	/* unit: access time (1/100-sec) */
156 	u_int8_t	d_maxint;	/* unit: max interleave */
157 	u_int8_t	d_fvbyte;	/* unit: fixed volume byte */
158 	u_int8_t	d_rvbyte;	/* unit: removable volume byte */
159 	u_int32_t	d_maxcylhead;	/* volume: max cylinder/head */
160 	u_int16_t	d_maxsect;	/* volume: max sector on track */
161 	u_int16_t	d_maxvsecth;	/* volume: max volume block (MSW) */
162 	u_int32_t	d_maxvsectl;	/* volume: max volume block (LSWs) */
163 	u_int8_t	d_interleave;	/* volume: current interleave */
164 } __attribute__((__packed__));
165 
166 struct	cs80_stat {		/* device status */
167 	u_int8_t	c_vu;	/* volume/unit */
168 	u_int8_t	c_pend;
169 	u_int16_t	c_ref;	/* reject error */
170 #define REF_bit3	0x0008		/* message length */
171 #define REF_bit5	0x0020		/* message sequence */
172 #define REF_bit6	0x0040		/* illegal parameter */
173 #define REF_bit7	0x0080		/* parameter bounds */
174 #define REF_bit8	0x0100		/* address bounds */
175 #define REF_bit9	0x0200		/* module addressing */
176 #define REF_bit10	0x0400		/* illegal opcode */
177 #define REF_bit13	0x2000		/* channel parity error */
178 	u_int16_t	c_fef;	/* fault error */
179 #define	FEF_REXMT	0x0001		/* retransmit */
180 #define	FEF_PF		0x0002		/* power fail */
181 #define FEF_IMR		0x0008		/* internal maintenance release */
182 #define FEF_bit4	0x0010		/* diagnostic release request */
183 #define FEF_bit5	0x0020		/* operator release request */
184 #define FEF_DR		0x0080		/* diagnostic result */
185 #define FEF_bit9	0x0200		/* unit fault */
186 #define FEF_bit12	0x1000		/* controller fault */
187 #define FEF_CU		0x4000		/* cross-unit */
188 	u_int16_t	c_aef;	/* access error */
189 #define	AEF_EOV		0x0008		/* end of volume */
190 #define	AEF_EOF		0x0010		/* end of file */
191 #define AEF_UD		0x0040		/* unrecoverable data */
192 #define AEF_bit7	0x0080		/* unrecoverable data overflow */
193 #define AEF_bit10	0x0400		/* no data found */
194 #define AEF_bit11	0x0800		/* write protect */
195 #define AEF_bit12	0x1000		/* not ready */
196 #define AEF_bit13	0x2000		/* no spares available */
197 #define AEF_bit14	0x4000		/* uninitialized media */
198 #define AEF_bit15	0x8000		/* illegal parallel operation */
199 	u_int16_t	c_ief;	/* info error */
200 #define IEF_bit2	0x0004		/* maintenance track overflow */
201 #define IEF_RD		0x0010		/* recoverable data */
202 #define IEF_MD		0x0020		/* marginal data */
203 #define IEF_bit6	0x0040		/* recoverable data overflow */
204 #define IEF_bit8	0x0100		/* auto-sparing invoked */
205 #define IEF_bit9	0x0800		/* latency induced */
206 #define IEF_bit10	0x1000		/* media wear */
207 #define IEF_RRMASK	0xe000		/* request release bits */
208 	union {
209 		u_int8_t cu_raw[10];
210 		struct {
211 			u_int16_t	cu_msw;
212 			u_int32_t	cu_lsl;
213 		} cu_sva;
214 		struct {
215 			u_int32_t	cu_cyhd;
216 			u_int16_t	cu_sect;
217 		} cu_tva;
218 	} c_pf;
219 #define c_raw	c_pf.cu_raw
220 #define c_blk	c_pf.cu_sva.cu_lsl
221 #define c_tva	c_pf.cu_tva
222 } __attribute__((__packed__));
223 
224 
225 int cs80describe(void *, int, int, struct cs80_description *);
226 int cs80reset(void *, int, int);
227 int cs80status(void *, int, int, struct cs80_stat *);
228 int cs80setoptions(void *, int, int, u_int8_t);
229 int cs80send(void *, int, int, int, void *, int);
230