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