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