|
|
1.1 root 1: /*
2: * scsi.h Copyright (C) 1992 Drew Eckhardt
3: * generic SCSI package header file by
4: * Drew Eckhardt
5: *
6: * <[email protected]>
7: */
8:
9: #ifndef _SCSI_H
10: #define _SCSI_H
11: /*
12: $Header: /usr/src/linux/kernel/blk_drv/scsi/RCS/scsi.h,v 1.1 1992/04/24 18:01:50 root Exp root $
13:
14: For documentation on the OPCODES, MESSAGES, and SENSE values,
15: please consult the SCSI standard.
16:
17: */
18:
19: /*
20: SCSI opcodes
21: */
22:
23: #define TEST_UNIT_READY 0x00
24: #define REZERO_UNIT 0x01
25: #define REQUEST_SENSE 0x03
26: #define FORMAT_UNIT 0x04
27: #define REASSIGN_BLOCKS 0x07
28: #define READ_6 0x08
29: #define WRITE_6 0x0a
30: #define SEEK_6 0x0b
31: #define INQUIRY 0x12
32: #define MODE_SELECT 0x15
33: #define RESERVE 0x16
34: #define RELEASE 0x17
35: #define COPY 0x18
36: #define MODE_SENSE 0x1a
37: #define START_STOP 0x1b
38: #define RECIEVE_DAIGNOSTIC 0x1c
39: #define SEND_DIAGNOSTIC 0x1d
40: #define ALLOW_MEDIUM_REMOVAL 0x1e
41:
42: #define READ_CAPACITY 0x25
43: #define READ_10 0x28
44: #define WRITE_10 0x2a
45: #define SEEK_10 0x2b
46: #define WRITE_VERIFY 0x2e
47: #define VERIFY 0x2f
48: #define SEARCH_HIGH 0x30
49: #define SEARCH_EQUAL 0x31
50: #define SEARCH_LOW 0x32
51: #define SET_LIMITS 0x33
52: #define COMPARE 0x39
53: #define COPY_VERIFY 0x3a
54:
55: #define COMMAND_SIZE(opcode) ((opcode) ? ((opcode) > 0x20 ? 10 : 6) : 0)
56:
57: /*
58: MESSAGE CODES
59: */
60:
61: #define COMMAND_COMPLETE 0x00
62: #define EXTENDED_MESSAGE 0x01
63: #define SAVE_POINTERS 0x02
64: #define RESTORE_POINTERS 0x03
65: #define DISCONNECT 0x04
66: #define INITIATOR_ERROR 0x05
67: #define ABORT 0x06
68: #define MESSAGE_REJECT 0x07
69: #define NOP 0x08
70: #define MSG_PARITY_ERROR 0x09
71: #define LINKED_CMD_COMPLETE 0x0a
72: #define LINKED_FLG_CMD_COMPLETE 0x0b
73: #define BUS_DEVICE_RESET 0x0c
74: #define IDENTIFY 0x80
75: /*
76: Status codes
77: */
78:
79: #define GOOD 0x00
80: #define CHECK_CONDITION 0x01
81: #define CONDITION_GOOD 0x02
82: #define BUSY 0x04
83: #define INTERMEDIATE_GOOD 0x08
84: #define INTERMEDIATE_C_GOOD 0x0a
85: #define RESERVATION_CONFLICT 0x0c
86:
87: #define STATUS_MASK 0x1e
88:
89: /*
90: the return of the status word will be in the following format :
91: The low byte is the status returned by the SCSI command,
92: with vendor specific bits masked.
93:
94: The next byte is the message which followed the SCSI status.
95: This allows a stos to be used, since the Intel is a little
96: endian machine.
97:
98: The final byte is a host return code, which is one of the following.
99:
100: IE
101: lsb msb
102: status msg host code
103:
104: Our errors returned by OUR driver, NOT SCSI message. Orr'd with
105: SCSI message passed back to driver <IF any>.
106: */
107:
108: /* NO error */
109: #define DID_OK 0x00
110: /* Couldn't connect before timeout period */
111: #define DID_NO_CONNECT 0x01
112: /* BUS stayed busy through time out period */
113: #define DID_BUS_BUSY 0x02
114: /* TIMED OUT for other reason */
115: #define DID_TIME_OUT 0x03
116: /* BAD target. */
117: #define DID_BAD_TARGET 0x04
118: /* Told to abort for some other reason */
119: #define DID_ABORT 0x05
120: /*
121: Parity error
122: */
123: #define DID_PARITY 0x06
124: /*
125: Internal error
126: */
127: #define DID_ERROR 0x07
128: /*
129: Reset by somebody.
130: */
131: #define DID_RESET 0x08
132:
133: /*
134: Driver status
135: */
136: #define DRIVER_OK 0x00
137:
138: /*
139: These indicate the error that occured, and what is available.
140: */
141:
142: #define DRIVER_BUSY 0x01
143: #define DRIVER_SOFT 0x02
144: #define DRIVER_MEDIA 0x03
145: #define DRIVER_ERROR 0x04
146:
147: #define DRIVER_INVALID 0x05
148: #define DRIVER_TIMEOUT 0x06
149: #define DRIVER_HARD 0x07
150:
151: #define SUGGEST_RETRY 0x08
152: #define SUGGEST_ABORT 0x09
153: #define SUGGEST_REMAP 0x0a
154: #define SUGGEST_DIE 0x0b
155:
156: #define DRIVER_SENSE 0x10
157:
158: #define DRIVER_MASK 0x0f
159: #define SUGGEST_MASK 0xf0
160:
161: /*
162:
163: SENSE KEYS
164: */
165:
166: #define NO_SENSE 0x00
167: #define RECOVERED_ERROR 0x01
168: #define NOT_READY 0x02
169: #define MEDIUM_ERROR 0x03
170: #define HARDWARE_ERROR 0x04
171: #define ILLEGAL_REQUEST 0x05
172: #define UNIT_ATTENTION 0x06
173: #define DATA_PROTECT 0x07
174: #define BLANK_CHECK 0x08
175: #define COPY_ABORTED 0x0a
176: #define ABORTED_COMMAND 0x0b
177: #define VOLUME_OVERFLOW 0x0d
178: #define MISCOMPARE 0x0e
179:
180:
181: /*
182: DEVICE TYPES
183:
184: */
185:
186: #define TYPE_DISK 0x00
187: #define TYPE_TAPE 0x01
188: #define TYPE_WORM 0x04 /* Treated as ROM by our system */
189: #define TYPE_ROM 0x05
190: #define TYPE_NO_LUN 0x7f
191: /*
192: Every SCSI command starts with a one byte OP-code.
193: The next byte's high three bits are the LUN of the
194: device. Any multi-byte quantities are stored high byte
195: first, and may have a 5 bit MSB in the same byte
196: as the LUN.
197: */
198:
199:
200: /*
201: The scsi_device struct contains what we know about each given scsi
202: device.
203: */
204:
205: typedef struct scsi_device {
206: unsigned char host_no, id, lun;
207: unsigned writeable:1;
208: unsigned removable:1;
209: unsigned random:1;
210: } Scsi_Device;
211: /*
212: Use these to separate status msg and our bytes
213: */
214:
215: #define status_byte(result) (((result) >> 1) & 0xf)
216: #define msg_byte(result) (((result) >> 8) & 0xff)
217: #define host_byte(result) (((result) >> 16) & 0xff)
218: #define driver_byte(result) (((result) >> 24) & 0xff)
219: #define sugestion(result) (driver_byte(result) & SUGGEST_MASK)
220:
221: #define sense_class(sense) (((sense) >> 4) & 0x7)
222: #define sense_error(sense) ((sense) & 0xf)
223: #define sense_valid(sense) ((sense) & 0x80);
224:
225: /*
226: These are the SCSI devices available on the system.
227: */
228:
229: #define MAX_SCSI_DEVICE 2
230: extern int NR_SCSI_DEVICES;
231: extern Scsi_Device scsi_devices[MAX_SCSI_DEVICE];
232: /*
233: scsi_abort aborts the current command that is executing on host host.
234: The error code, if non zero is returned in the host byte, otherwise
235: DID_ABORT is returned in the hostbyte.
236: */
237:
238: extern int scsi_abort (int host, int code);
239:
240: /*
241: Initializes all SCSI devices. This scans all scsi busses.
242: */
243:
244: extern void scsi_dev_init (void);
245:
246: /*
247: You guesed it. This sends a command to the selected SCSI host
248: */
249:
250:
251:
252: extern void scsi_do_cmd (int host, unsigned char target, const void *cmnd ,
253: void *buffer, unsigned bufflen, void (*done)(int,int),
254: int timeout, unsigned char *sense_buffer, int retries);
255:
256: int scsi_reset (int host);
257: #endif
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.