Home | History | Annotate | Line # | Download | only in scsipi
scsiconf.h revision 1.4.3.2
      1      1.1      cgd /*
      2      1.1      cgd  * Written by Julian Elischer (julian (at) tfs.com)
      3      1.3  deraadt  * for TRW Financial Systems for use under the MACH(2.5) operating system.
      4      1.1      cgd  *
      5      1.1      cgd  * TRW Financial Systems, in accordance with their agreement with Carnegie
      6      1.1      cgd  * Mellon University, makes this software available to CMU to distribute
      7      1.1      cgd  * or use in any manner that they see fit as long as this message is kept with
      8      1.1      cgd  * the software. For this reason TFS also grants any other persons or
      9      1.1      cgd  * organisations permission to use or modify this software.
     10      1.1      cgd  *
     11      1.1      cgd  * TFS supplies this software to be publicly redistributed
     12      1.1      cgd  * on the understanding that TFS is not responsible for the correct
     13      1.1      cgd  * functioning of this software in any circumstances.
     14      1.4      cgd  *
     15  1.4.3.1  mycroft  * Ported to run under 386BSD by Julian Elischer (julian (at) tfs.com) Sept 1992
     16  1.4.3.1  mycroft  *
     17  1.4.3.2  mycroft  *	$Id: scsiconf.h,v 1.4.3.2 1993/11/24 09:45:12 mycroft Exp $
     18  1.4.3.1  mycroft  */
     19  1.4.3.1  mycroft #ifndef	SCSI_SCSICONF_H
     20  1.4.3.1  mycroft #define SCSI_SCSICONF_H 1
     21  1.4.3.1  mycroft typedef	int			boolean;
     22  1.4.3.1  mycroft typedef	long int		int32;
     23  1.4.3.1  mycroft typedef	short int		int16;
     24  1.4.3.1  mycroft typedef	char 			int8;
     25  1.4.3.1  mycroft typedef	unsigned long int	u_int32;
     26  1.4.3.1  mycroft typedef	unsigned short int	u_int16;
     27  1.4.3.1  mycroft typedef	unsigned char 		u_int8;
     28  1.4.3.1  mycroft 
     29  1.4.3.1  mycroft #ifdef	__NetBSD__
     30  1.4.3.1  mycroft #define DELAY delay
     31  1.4.3.1  mycroft #endif
     32  1.4.3.1  mycroft 
     33  1.4.3.1  mycroft #include <machine/cpu.h>
     34  1.4.3.1  mycroft #include <scsi/scsi_debug.h>
     35  1.4.3.1  mycroft 
     36  1.4.3.1  mycroft /*
     37  1.4.3.1  mycroft  * The following documentation tries to describe the relationship between the
     38  1.4.3.1  mycroft  * various structures defined in this file:
     39  1.4.3.1  mycroft  *
     40  1.4.3.1  mycroft  * each adapter type has a scsi_adapter struct. This describes the adapter and
     41  1.4.3.1  mycroft  *    identifies routines that can be called to use the adapter.
     42  1.4.3.1  mycroft  * each device type has a scsi_device struct. This describes the device and
     43  1.4.3.1  mycroft  *    identifies routines that can be called to use the device.
     44  1.4.3.1  mycroft  * each existing device position (scsibus + target + lun)
     45  1.4.3.1  mycroft  *    can be described by a scsi_link struct.
     46  1.4.3.1  mycroft  *    Only scsi positions that actually have devices, have a scsi_link
     47  1.4.3.1  mycroft  *    structure assigned. so in effect each device has scsi_link struct.
     48  1.4.3.1  mycroft  *    The scsi_link structure contains information identifying both the
     49  1.4.3.1  mycroft  *    device driver and the adapter driver for that position on that scsi bus,
     50  1.4.3.1  mycroft  *    and can be said to 'link' the two.
     51  1.4.3.1  mycroft  * each individual scsi bus has an array that points to all the scsi_link
     52  1.4.3.1  mycroft  *    structs associated with that scsi bus. Slots with no device have
     53  1.4.3.1  mycroft  *    a NULL pointer.
     54  1.4.3.1  mycroft  * each individual device also knows the address of it's own scsi_link
     55  1.4.3.1  mycroft  *    structure.
     56  1.4.3.1  mycroft  *
     57  1.4.3.1  mycroft  *				-------------
     58  1.4.3.1  mycroft  *
     59  1.4.3.1  mycroft  * The key to all this is the scsi_link structure which associates all the
     60  1.4.3.1  mycroft  * other structures with each other in the correct configuration.  The
     61  1.4.3.1  mycroft  * scsi_link is the connecting information that allows each part of the
     62  1.4.3.1  mycroft  * scsi system to find the associated other parts.
     63      1.1      cgd  */
     64      1.1      cgd 
     65  1.4.3.1  mycroft 
     66      1.1      cgd /*
     67  1.4.3.1  mycroft  * These entrypoints are called by the high-end drivers to get services from
     68  1.4.3.1  mycroft  * whatever low-end drivers they are attached to each adapter type has one of
     69  1.4.3.1  mycroft  * these statically allocated.
     70  1.4.3.1  mycroft  */
     71  1.4.3.1  mycroft struct scsi_adapter
     72  1.4.3.1  mycroft {
     73  1.4.3.1  mycroft /* 4*/	int32		(*scsi_cmd)();
     74  1.4.3.1  mycroft /* 8*/	void		(*scsi_minphys)();
     75  1.4.3.1  mycroft /*12*/	int32		(*open_target_lu)();
     76  1.4.3.1  mycroft /*16*/	int32		(*close_target_lu)();
     77  1.4.3.1  mycroft /*20*/	u_int32		(*adapter_info)(); /* see definitions below */
     78  1.4.3.1  mycroft /*24*/	char		*name; /* name of scsi bus controller */
     79  1.4.3.1  mycroft /*32*/	u_long	spare[2];
     80      1.1      cgd };
     81  1.4.3.1  mycroft 
     82  1.4.3.1  mycroft /*
     83  1.4.3.1  mycroft  * return values for scsi_cmd()
     84  1.4.3.1  mycroft  */
     85      1.1      cgd #define SUCCESSFULLY_QUEUED	0
     86      1.1      cgd #define TRY_AGAIN_LATER		1
     87      1.1      cgd #define	COMPLETE		2
     88  1.4.3.1  mycroft #define	HAD_ERROR		3 /* do not use this, use COMPLETE */
     89  1.4.3.1  mycroft #define	ESCAPE_NOT_SUPPORTED	4
     90  1.4.3.1  mycroft 
     91  1.4.3.1  mycroft /*
     92  1.4.3.1  mycroft  * Format of adapter_info() response data
     93  1.4.3.1  mycroft  * e.g. maximum number of entries queuable to a device by the adapter
     94  1.4.3.1  mycroft  */
     95  1.4.3.1  mycroft #define	AD_INF_MAX_CMDS		0x000000FF
     96  1.4.3.1  mycroft /* 24 bits of other adapter characteristics go here */
     97  1.4.3.1  mycroft 
     98  1.4.3.1  mycroft /*
     99  1.4.3.1  mycroft  * These entry points are called by the low-end drivers to get services from
    100  1.4.3.1  mycroft  * whatever high-end drivers they are attached to.  Each device type has one
    101  1.4.3.1  mycroft  * of these statically allocated.
    102  1.4.3.1  mycroft  */
    103  1.4.3.1  mycroft struct scsi_device
    104  1.4.3.1  mycroft {
    105  1.4.3.2  mycroft /*  4*/	int	(*err_handler)(); /* returns -1 to say err processing complete */
    106  1.4.3.1  mycroft /*  8*/	void	(*start)();
    107  1.4.3.1  mycroft /* 12*/	int32	(*async)();
    108  1.4.3.1  mycroft /* 16*/	int32	(*done)();	/* returns -1 to say done processing complete */
    109  1.4.3.1  mycroft /* 20*/	char	*name;		/* name of device type */
    110  1.4.3.1  mycroft /* 24*/	u_int32 flags;		/* device type dependent flags */
    111  1.4.3.1  mycroft /* 32*/	int32	spare[2];
    112  1.4.3.1  mycroft };
    113  1.4.3.1  mycroft 
    114  1.4.3.1  mycroft /*
    115  1.4.3.1  mycroft  * This structure describes the connection between an adapter driver and
    116  1.4.3.1  mycroft  * a device driver, and is used by each to call services provided by
    117  1.4.3.1  mycroft  * the other, and to allow generic scsi glue code to call these services
    118  1.4.3.1  mycroft  * as well.
    119  1.4.3.1  mycroft  */
    120  1.4.3.1  mycroft struct scsi_link
    121  1.4.3.1  mycroft {
    122  1.4.3.1  mycroft /*  1*/	u_int8	scsibus;		/* the Nth scsibus */
    123  1.4.3.1  mycroft /*  2*/	u_int8	target;			/* targ of this dev */
    124  1.4.3.1  mycroft /*  3*/	u_int8	lun;			/* lun of this dev */
    125  1.4.3.1  mycroft /*  4*/	u_int8	adapter_targ;		/* what are we on the scsi bus */
    126  1.4.3.1  mycroft /*  5*/	u_int8	dev_unit;		/* e.g. the 0 in sd0 */
    127  1.4.3.1  mycroft /*  6*/	u_int8	opennings;		/* available operations */
    128  1.4.3.1  mycroft /*  7*/	u_int8	active;			/* operations in progress */
    129  1.4.3.1  mycroft /*  8*/ u_int8	sparea[1];
    130  1.4.3.1  mycroft /* 10*/	u_int16	flags;			/* flags that all devices have */
    131  1.4.3.1  mycroft /* 12*/	u_int8	spareb[2];
    132  1.4.3.1  mycroft /* 16*/	struct	scsi_adapter *adapter;	/* adapter entry points etc. */
    133  1.4.3.1  mycroft /* 20*/	struct	scsi_device *device;	/* device entry points etc. */
    134  1.4.3.1  mycroft /* 24*/	struct	scsi_xfer *active_xs;	/* operations under way */
    135  1.4.3.1  mycroft /*  4*/	void	*adapter_softc;		/* e.g. the 0 in aha0 */
    136  1.4.3.1  mycroft /* 28*/	void	*fordriver;		/* for private use by the driver */
    137  1.4.3.1  mycroft };
    138  1.4.3.1  mycroft #define	SDEV_MEDIA_LOADED 	0x01	/* device figures are still valid */
    139  1.4.3.1  mycroft #define	SDEV_WAITING	 	0x02	/* a process is waiting for this */
    140  1.4.3.1  mycroft #define	SDEV_OPEN	 	0x04	/* at least 1 open session */
    141  1.4.3.1  mycroft #define	SDEV_DBX		0xF0	/* debuging flags (scsi_debug.h) */
    142  1.4.3.1  mycroft 
    143  1.4.3.1  mycroft /*
    144  1.4.3.1  mycroft  * One of these is allocated and filled in for each scsi bus.
    145  1.4.3.1  mycroft  * it holds pointers to allow the scsi bus to get to the driver
    146  1.4.3.1  mycroft  * That is running each LUN on the bus
    147  1.4.3.1  mycroft  * it also has a template entry which is the prototype struct
    148  1.4.3.1  mycroft  * supplied by the adapter driver, this is used to initialise
    149  1.4.3.1  mycroft  * the others, before they have the rest of the fields filled in
    150  1.4.3.1  mycroft  */
    151  1.4.3.1  mycroft struct scsibus_data {
    152  1.4.3.1  mycroft 	struct device sc_dev;
    153  1.4.3.1  mycroft 	struct scsi_link *adapter_link;		/* prototype supplied by adapter */
    154  1.4.3.1  mycroft 	struct scsi_link *sc_link[8][8];
    155  1.4.3.1  mycroft };
    156      1.1      cgd 
    157  1.4.3.1  mycroft /*
    158  1.4.3.1  mycroft  * Each scsi transaction is fully described by one of these structures
    159  1.4.3.1  mycroft  * It includes information about the source of the command and also the
    160  1.4.3.1  mycroft  * device and adapter for which the command is destined.
    161  1.4.3.1  mycroft  * (via the scsi_link structure)
    162  1.4.3.1  mycroft  */
    163      1.1      cgd struct scsi_xfer
    164      1.1      cgd {
    165  1.4.3.1  mycroft /* 4*/	struct	scsi_xfer *next;	/* when free */
    166  1.4.3.1  mycroft /* 8*/	u_int32	flags;
    167  1.4.3.1  mycroft /*12*/	struct	scsi_link *sc_link;	/* all about our device and adapter */
    168  1.4.3.1  mycroft /*13*/	u_int8	retries;		/* the number of times to retry */
    169  1.4.3.1  mycroft /*16*/	u_int8	spare[3];
    170  1.4.3.1  mycroft /*20*/	int32	timeout;		/* in milliseconds */
    171  1.4.3.1  mycroft /*24*/	struct	scsi_generic *cmd;	/* The scsi command to execute */
    172  1.4.3.1  mycroft /*28*/	int32	cmdlen;			/* how long it is */
    173  1.4.3.1  mycroft /*32*/	u_char	*data;			/* dma address OR a uio address */
    174  1.4.3.1  mycroft /*36*/	int32	datalen;		/* data len (blank if uio)    */
    175  1.4.3.1  mycroft /*40*/	int32	resid;			/* how much buffer was not touched */
    176  1.4.3.1  mycroft /*44*/	int32	error;			/* an error value	*/
    177  1.4.3.1  mycroft /*48*/	struct	buf *bp;		/* If we need to associate with a buf */
    178  1.4.3.1  mycroft /*80*/	struct	scsi_sense_data	sense; /* 32 bytes*/
    179  1.4.3.1  mycroft 	/*
    180  1.4.3.1  mycroft 	 * Believe it or not, Some targets fall on the ground with
    181  1.4.3.1  mycroft 	 * anything but a certain sense length.
    182  1.4.3.1  mycroft 	 */
    183  1.4.3.1  mycroft /*84*/	int32 req_sense_length;		/* Explicit request sense length */
    184  1.4.3.1  mycroft /*88*/	int32 status;			/* SCSI status */
    185  1.4.3.1  mycroft /*100*/	struct	scsi_generic cmdstore;	/* stash the command in here */
    186      1.1      cgd };
    187  1.4.3.1  mycroft 
    188  1.4.3.1  mycroft /*
    189  1.4.3.1  mycroft  * Per-request Flag values
    190  1.4.3.1  mycroft  */
    191      1.1      cgd #define	SCSI_NOSLEEP	0x01	/* Not a user... don't sleep		*/
    192      1.1      cgd #define	SCSI_NOMASK	0x02	/* dont allow interrupts.. booting	*/
    193      1.1      cgd #define	SCSI_NOSTART	0x04	/* left over from ancient history	*/
    194  1.4.3.1  mycroft #define	SCSI_USER	0x08	/* Is a user cmd, call scsi_user_done	*/
    195      1.1      cgd #define	ITSDONE		0x10	/* the transfer is as done as it gets	*/
    196      1.1      cgd #define	INUSE		0x20	/* The scsi_xfer block is in use	*/
    197      1.1      cgd #define	SCSI_SILENT	0x40	/* Don't report errors to console	*/
    198      1.1      cgd #define SCSI_ERR_OK	0x80	/* An error on this operation is OK.	*/
    199      1.1      cgd #define	SCSI_RESET	0x100	/* Reset the device in question		*/
    200      1.1      cgd #define	SCSI_DATA_UIO	0x200	/* The data address refers to a UIO	*/
    201      1.1      cgd #define	SCSI_DATA_IN	0x400	/* expect data to come INTO memory	*/
    202      1.1      cgd #define	SCSI_DATA_OUT	0x800	/* expect data to flow OUT of memory	*/
    203      1.1      cgd #define	SCSI_TARGET	0x1000	/* This defines a TARGET mode op.	*/
    204  1.4.3.1  mycroft #define	SCSI_ESCAPE	0x2000	/* Escape operation			*/
    205  1.4.3.1  mycroft 
    206  1.4.3.1  mycroft /*
    207  1.4.3.1  mycroft  * Escape op codes.  This provides an extensible setup for operations
    208  1.4.3.1  mycroft  * that are not scsi commands.  They are intended for modal operations.
    209  1.4.3.1  mycroft  */
    210  1.4.3.1  mycroft 
    211  1.4.3.1  mycroft #define SCSI_OP_TARGET	0x0001
    212  1.4.3.1  mycroft #define	SCSI_OP_RESET	0x0002
    213  1.4.3.1  mycroft #define	SCSI_OP_BDINFO	0x0003
    214  1.4.3.1  mycroft 
    215  1.4.3.1  mycroft /*
    216  1.4.3.1  mycroft  * Error values an adapter driver may return
    217  1.4.3.1  mycroft  */
    218      1.1      cgd #define XS_NOERROR	0x0	/* there is no error, (sense is invalid)  */
    219      1.1      cgd #define XS_SENSE	0x1	/* Check the returned sense for the error */
    220      1.1      cgd #define	XS_DRIVER_STUFFUP 0x2	/* Driver failed to perform operation	  */
    221      1.1      cgd #define XS_TIMEOUT	0x03	/* The device timed out.. turned off?	  */
    222      1.1      cgd #define XS_SWTIMEOUT	0x04	/* The Timeout reported was caught by SW  */
    223      1.1      cgd #define XS_BUSY		0x08	/* The device busy, try again later?	  */
    224      1.1      cgd 
    225  1.4.3.2  mycroft struct scsi_xfer *get_xs __P((struct scsi_link *, u_int32));
    226  1.4.3.2  mycroft void free_xs __P((struct scsi_xfer *, struct scsi_link *, u_int32));
    227  1.4.3.2  mycroft u_int32 scsi_size __P((struct scsi_link *, u_int32));
    228  1.4.3.2  mycroft int scsi_test_unit_ready __P((struct scsi_link *, u_int32));
    229  1.4.3.2  mycroft int scsi_change_def __P((struct scsi_link *, u_int32));
    230  1.4.3.2  mycroft int scsi_inquire __P((struct scsi_link *, struct scsi_inquiry_data *, u_int32));
    231  1.4.3.2  mycroft int scsi_prevent __P((struct scsi_link *, u_int32, u_int32));
    232  1.4.3.2  mycroft int scsi_start_unit __P((struct scsi_link *, u_int32));
    233  1.4.3.2  mycroft void scsi_done __P((struct scsi_xfer *));
    234  1.4.3.2  mycroft int scsi_scsi_cmd __P((struct scsi_link *, struct scsi_generic *,
    235  1.4.3.1  mycroft 			u_int32 cmdlen, u_char *data_addr,
    236  1.4.3.1  mycroft 			u_int32 datalen, u_int32 retries,
    237  1.4.3.1  mycroft 			u_int32 timeout, struct buf *bp,
    238  1.4.3.2  mycroft 			u_int32 flags));
    239  1.4.3.2  mycroft int scsi_do_ioctl __P((struct scsi_link *, int, caddr_t, int));
    240  1.4.3.1  mycroft 
    241  1.4.3.2  mycroft void show_scsi_xs __P((struct scsi_xfer *));
    242  1.4.3.2  mycroft void show_scsi_cmd __P((struct scsi_xfer *));
    243  1.4.3.2  mycroft void show_mem __P((unsigned char *, u_int32));
    244      1.2  deraadt 
    245  1.4.3.1  mycroft void	lto3b __P((int val, u_char *bytes));
    246  1.4.3.1  mycroft int	_3btol __P((u_char *bytes));
    247      1.2  deraadt 
    248  1.4.3.1  mycroft #endif /*SCSI_SCSICONF_H*/
    249  1.4.3.1  mycroft /* END OF FILE */
    250