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