xref: /netbsd-src/sys/dev/scsipi/scsiconf.h (revision cda4f8f6ee55684e8d311b86c99ea59191e6b74f)
1 /*
2  * Written by Julian Elischer (julian@tfs.com)
3  * for TRW Financial Systems for use under the MACH(2.5) operating system.
4  * Hacked by Theo de Raadt <deraadt@fsa.ca>
5  *
6  * TRW Financial Systems, in accordance with their agreement with Carnegie
7  * Mellon University, makes this software available to CMU to distribute
8  * or use in any manner that they see fit as long as this message is kept with
9  * the software. For this reason TFS also grants any other persons or
10  * organisations permission to use or modify this software.
11  *
12  * TFS supplies this software to be publicly redistributed
13  * on the understanding that TFS is not responsible for the correct
14  * functioning of this software in any circumstances.
15  *
16  *	$Id: scsiconf.h,v 1.4 1993/05/20 03:46:39 cgd Exp $
17  */
18 
19 /*
20  * these calls are called by the high-end
21  * drivers to get services from whatever low-end
22  * drivers they are attached to
23  */
24 struct scsi_switch {
25 	char *name;
26 	int (*scsi_cmd)();
27 	void (*scsi_minphys)();
28 	int (*open_target_lu)();
29 	int (*close_target_lu)();
30 	long int (*adapter_info)(); /* see definitions below */
31 	u_long	spare[3];
32 	u_char	empty[8], used[8], printed[8];
33 };
34 #define	AD_INF_MAX_CMDS		0x000000FF /* maximum number of entries
35 						queuable to a device by
36 						the adapter */
37 /* 24 bits of other adapter charcteristics go here */
38 
39 /***********************************************\
40 * The scsi debug control bits			*
41 \***********************************************/
42 extern	int	scsi_debug;
43 #define PRINTROUTINES	0x01
44 #define	TRACEOPENS	0x02
45 #define	TRACEINTERRUPTS	0x04
46 #define	SHOWREQUESTS	0x08
47 #define	SHOWSCATGATH	0x10
48 #define	SHOWINQUIRY	0x20
49 #define	SHOWCOMMANDS	0x40
50 
51 
52 /********************************/
53 /* return values for scsi_cmd() */
54 /********************************/
55 #define SUCCESSFULLY_QUEUED	0
56 #define TRY_AGAIN_LATER		1
57 #define	COMPLETE		2
58 #define	HAD_ERROR		3
59 
60 struct scsi_xfer
61 {
62 	struct	scsi_xfer *next;	/* when free */
63 	int	flags;
64 	u_char	adapter;
65 	u_char	targ;
66 	u_char	lu;
67 	u_char	retries;	/* the number of times to retry */
68 	long	int	timeout;	/* in miliseconds */
69 	struct	scsi_generic *cmd;
70 	int	cmdlen;
71 	u_char	*data;		/* either the dma address OR a uio address */
72 	int	datalen;	/* data len (blank if uio)    */
73 	int	resid;
74 	int	(*when_done)();
75 	int	done_arg;
76 	int	done_arg2;
77 	int	error;
78 	struct	buf *bp;
79 	struct	scsi_sense_data	sense;
80 };
81 /********************************/
82 /* Flag values			*/
83 /********************************/
84 #define	SCSI_NOSLEEP	0x01	/* Not a user... don't sleep		*/
85 #define	SCSI_NOMASK	0x02	/* dont allow interrupts.. booting	*/
86 #define	SCSI_NOSTART	0x04	/* left over from ancient history	*/
87 #define	ITSDONE		0x10	/* the transfer is as done as it gets	*/
88 #define	INUSE		0x20	/* The scsi_xfer block is in use	*/
89 #define	SCSI_SILENT	0x40	/* Don't report errors to console	*/
90 #define SCSI_ERR_OK	0x80	/* An error on this operation is OK.	*/
91 #define	SCSI_RESET	0x100	/* Reset the device in question		*/
92 #define	SCSI_DATA_UIO	0x200	/* The data address refers to a UIO	*/
93 #define	SCSI_DATA_IN	0x400	/* expect data to come INTO memory	*/
94 #define	SCSI_DATA_OUT	0x800	/* expect data to flow OUT of memory	*/
95 #define	SCSI_TARGET	0x1000	/* This defines a TARGET mode op.	*/
96 /********************************/
97 /* Error values			*/
98 /********************************/
99 #define XS_NOERROR	0x0	/* there is no error, (sense is invalid)  */
100 #define XS_SENSE	0x1	/* Check the returned sense for the error */
101 #define	XS_DRIVER_STUFFUP 0x2	/* Driver failed to perform operation	  */
102 #define XS_TIMEOUT	0x03	/* The device timed out.. turned off?	  */
103 #define XS_SWTIMEOUT	0x04	/* The Timeout reported was caught by SW  */
104 #define XS_BUSY		0x08	/* The device busy, try again later?	  */
105 
106 /*
107  * The structure of known drivers for autoconfiguration
108  */
109 #define SC_TSD	0
110 #define SC_TST	1
111 #define SC_TCD	2
112 
113 #define SC_SHOWME	0x01
114 #define	SC_ONE_LU	0x00
115 #define	SC_MORE_LUS	0x02
116 struct scsidevs {
117 	int type, dtype, removable;
118 	char *manufacturer, *model, *version;
119 	int (*attach_rtn)();
120 	char *devname, flags;
121 };
122 
123 int scsi_inquire(int, int, int,	struct scsi_switch *, u_char *, int);
124 int scsi_ready(int, int, int, struct scsi_switch *, int);
125 int scsi_attach(int, int, struct scsi_switch *, int *, int *, int);
126 void scsi_warn(int, int, struct scsi_switch *);
127 struct scsidevs *scsi_probe(int, struct scsi_switch *, int, int, int);
128 struct scsidevs *selectdev(int, int, int, struct scsi_switch *,
129 	int, int, int, char *, char *, char *, int);
130 u_long _3btol(u_char *);
131 void lto3b(u_long, u_char *);
132 
133