Home | History | Annotate | Line # | Download | only in gpib
      1 /*	$NetBSD: cs80busvar.h,v 1.6 2012/10/27 17:18:16 chs 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  *
     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.
     30  */
     31 
     32 #define CS80BUS_NSLAVES		8	/* number of slaves on a bus */
     33 #define CS80BUS_NPUNITS		2	/* number of punits per slave */
     34 
     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 */
     40 };
     41 
     42 struct cs80bus_softc {
     43 	device_t sc_dev;		/* generic device glue */
     44 	gpib_chipset_tag_t sc_ic;
     45 	u_int8_t	sc_rmap[CS80BUS_NSLAVES][CS80BUS_NPUNITS];
     46 };
     47 
     48 
     49 /*
     50  * CS80/SS80 primary commands
     51  */
     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 */
     56 
     57 /*
     58  * CS80/SS80 secondary commands
     59  *
     60  * The arguments in < > indicate the number of parameters and number of
     61  * bits per parameter used in the command.
     62  */
     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 */
     79 
     80 struct cs80_describecmd {		/* describe command */
     81 	u_int8_t c_unit;
     82 	u_int8_t c_vol;
     83 	u_int8_t c_cmd;
     84 } __packed;
     85 
     86 struct	cs80_clearcmd {			/* clear device command */
     87 	u_int8_t	c_unit;
     88 	u_int8_t	c_cmd;
     89 } __packed;
     90 
     91 struct	cs80_srcmd {			/* s? release */
     92 	u_int8_t	c_unit;
     93 	u_int8_t	c_nop;
     94 	u_int8_t	c_cmd;
     95 	u_int8_t	c_param;
     96 } __packed;
     97 
     98 struct	cs80_statuscmd {		/* status command */
     99 	u_int8_t	c_unit;
    100 	u_int8_t	c_sram;
    101 	u_int8_t	c_param;
    102 	u_int8_t	c_cmd;
    103 } __packed;
    104 
    105 struct	cs80_ssmcmd {			/* status mask */
    106 	u_int8_t	c_unit;
    107 	u_int8_t	c_cmd;
    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 */
    112 #define	REF_MASK	0x0
    113 #define	FEF_MASK	0x0
    114 #define	AEF_MASK	0x0
    115 #define	IEF_MASK	0xF970
    116 } __packed;
    117 
    118 struct cs80_soptcmd {			/* set options */
    119 	u_int8_t	c_unit;
    120 	u_int8_t	c_nop;
    121 	u_int8_t	c_opt;
    122 	u_int8_t	c_param;
    123 #define C_CC		0x01		/* character count option */
    124 #define C_SKSPAR	0x02
    125 #define C_SPAR		0x04
    126 #define C_IMRPT		0x08
    127 } __packed;
    128 
    129 
    130 
    131 
    132 /*
    133  * Structures returned by functions.
    134  */
    135 
    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 */
    157 } __packed;
    158 
    159 struct	cs80_stat {		/* device status */
    160 	u_int8_t	c_vu;	/* volume/unit */
    161 	u_int8_t	c_pend;
    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 */
    201 	union {
    202 		u_int8_t cu_raw[10];
    203 		struct {
    204 			u_int16_t	cu_msw;
    205 			u_int32_t	cu_lsl;
    206 		} cu_sva;
    207 		struct {
    208 			u_int32_t	cu_cyhd;
    209 			u_int16_t	cu_sect;
    210 		} cu_tva;
    211 	} c_pf;
    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
    215 } __packed;
    216 
    217 
    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);
    223