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