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