BSD 4_4 release
[unix-history] / usr / src / sys / pmax / dev / scsi.h
CommitLineData
12d43ee5 1/*
ad787160
C
2 * Copyright (c) 1992, 1993
3 * The Regents of the University of California. All rights reserved.
12d43ee5
KM
4 *
5 * This code is derived from software contributed to Berkeley by
6 * Ralph Campbell.
7 *
ad787160
C
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. All advertising materials mentioning features or use of this software
17 * must display the following acknowledgement:
18 * This product includes software developed by the University of
19 * California, Berkeley and its contributors.
20 * 4. Neither the name of the University nor the names of its contributors
21 * may be used to endorse or promote products derived from this software
22 * without specific prior written permission.
12d43ee5 23 *
ad787160
C
24 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * SUCH DAMAGE.
35 *
36 * @(#)scsi.h 8.1 (Berkeley) 6/10/93
12d43ee5
KM
37 *
38 * scsi.h --
39 *
40 * Common declarations for SCSI command formaters. This file only covers
41 * definitions pertaining to the SCSI common command set that are
42 * common to all SCSI device types (ie disk, tapes, WORM, printers, etc).
43 * Some of the references from the proceedings of the
44 * 1984 Mini/Micro Northeast conference might help in understanding SCSI.
45 *
46 * from: $Header: /sprite/src/kernel/dev/RCS/scsi.h,
47 * v 9.1 90/02/13 23:11:24 jhh Exp $ SPRITE (Berkeley)
48 */
49
50#ifndef _SCSI_H
51#define _SCSI_H
52
53/*
54 * "Standard" SCSI Commands.
55 * SCSI commands are divided into 8 groups as follows:
56 * Group0 (0x00 - 0x1f). Basic commands. 6 bytes long
57 * Group1 (0x20 - 0x3f). Extended command. 10 bytes.
58 * Group2 (0x40 - 0x5f). Reserved.
59 * Group2 (0x60 - 0x7f). Reserved.
60 * Group2 (0x80 - 0x9f). Reserved.
61 * Group2 (0xa0 - 0xbf). Reserved.
62 * Group6 (0xc0 - 0xdf). Vendor Unique
63 * Group7 (0xe0 - 0xff). Vendor Unique
64 */
65
66/*
67 * Scsi Group0 commands all are 6 bytes and have a format according to
68 * struct ScsiGroup0Cmd.
69 */
70#define SCSI_TEST_UNIT_READY 0x00
71#define SCSI_REZERO_UNIT 0x01
72#define SCSI_REWIND 0x01
73#define SCSI_REQUEST_SENSE 0x03
74#define SCSI_FORMAT_UNIT 0x04
75#define SCSI_READ_BLOCK_LIMITS 0x05
76#define SCSI_REASSIGN_BLOCKS 0x07
77#define SCSI_READ 0x08
78#define SCSI_WRITE 0x0a
79#define SCSI_SEEK 0x0b
80#define SCSI_TRACK_SELECT 0x0b
81#define SCSI_READ_REVERSE 0x0f
82#define SCSI_WRITE_EOF 0x10
83#define SCSI_SPACE 0x11
84#define SCSI_INQUIRY 0x12
85#define SCSI_VERIFY 0x13
86#define SCSI_READ_BUFFER 0x14
87#define SCSI_MODE_SELECT 0x15
88#define SCSI_RESERVE_UNIT 0x16
89#define SCSI_RELEASE_UNIT 0x17
90#define SCSI_COPY 0x18
91#define SCSI_ERASE_TAPE 0x19
92#define SCSI_MODE_SENSE 0x1a
93#define SCSI_START_STOP 0x1b
94#define SCSI_LOAD_UNLOAD 0x1b
95#define SCSI_RECV_DIAG_RESULTS 0x1c
96#define SCSI_SEND_DIAGNOSTIC 0x1d
97#define SCSI_PREVENT_ALLOW 0x1e
98
99/*
100 * Group1 commands are all 10 bytes and have a format according to
101 * struct ScsiGroup1Cmd.
102 */
103#define SCSI_READ_CAPACITY 0x25
104#define SCSI_READ_EXT 0x28
105#define SCSI_WRITE_EXT 0x2a
106#define SCSI_SEEK_EXT 0x2b
107#define SCSI_WRITE_VERIFY 0x2e
108#define SCSI_VERIFY_EXT 0x2f
109#define SCSI_SEARCH_HIGH 0x30
110#define SCSI_SEARCH_EQUAL 0x31
111#define SCSI_SEARCH_LOW 0x32
112#define SCSI_SET_LIMITS 0x33
113#define SCSI_COMPARE 0x39
114#define SCSI_COPY_VERIFY 0x3a
115
116/*
117 * Control byte flags for Group0 and Group1 commands.
118 *
119 * SCSI_CTRL_LINK - This is used to prevent a bus free phase between commands.
120 * If the command terminates successfully, a SCSI_LINKED_CMD_COMPLETE
121 * message is returned instead of the normal SCSI_COMMAND_COMPLETE message. * The last command in a chain should not have this bit set
122 * (and consequently gets a normal SCSI_COMMAND_COMPLETE message).
123 * SCSI_CTRL_LINK_FLAG - This bit should only set when SCSI_CTRL_LINK is set and
124 * causes a SCSI_LINKED_FLAGED_CMD_COMPLETE to be returned instead of
125 * a SCSI_LINKED_CMD_COMPLETE.
126 */
127#define SCSI_CTRL_LINK 0x01 /* Link commands (no bus free phase) */
128#define SCSI_CTRL_LINK_INTR 0x02 /* Interrupt after linked command */
129
130/*
131 * The standard group0 6-byte SCSI control block. Note that the
132 * fields between highAddr and blockCount inclusive are command dependent.
133 * The definitions Addr and BlockCount cover most of the commands we will
134 * use.
135 */
136typedef struct ScsiGroup0Cmd {
137 u_char command; /* command code, defined below. The
138 * upper three bits of this are zero
139 * to indicate the control block is
140 * only 6 bytes long */
141#if BYTE_ORDER == BIG_ENDIAN
142 u_char unitNumber :3; /* Logical Unit (LUN) to which to
143 * pass the command. The device
144 * has already been selected using
145 * the "targetID" bit. */
146 u_char highAddr :5; /* High bits of address */
147#else
148 u_char highAddr :5; /* High bits of address */
149 u_char unitNumber :3; /* Logical Unit (LUN) to which to
150 * pass the command. The device
151 * has already been selected using
152 * the "targetID" bit. */
153#endif
154 u_char midAddr; /* Middle bits of address */
155 u_char lowAddr; /* Low bits of address */
156 u_char blockCount; /* Blocks to transfer */
157 u_char control; /* See flags for common bits */
158} ScsiGroup0Cmd;
159
160/*
161 * Format of a SCSI_START_STOP command. This is a group 0 command, but
162 * the command contents are different.
163 */
164typedef struct ScsiStartStopCmd {
165#if BYTE_ORDER == BIG_ENDIAN
166 u_char command; /* command code, defined below. The
167 * upper three bits of this are zero
168 * to indicate the control block is
169 * only 6 bytes long */
170 u_char unitNumber :3; /* Logical Unit (LUN) to which to
171 * pass the command. The device
172 * has already been selected using
173 * the "targetID" bit. */
174 u_char pad1 :4; /* Reserved */
175 u_char immed :1; /* Immediate status bit */
176 u_char pad2; /* Reserved */
177 u_char pad3; /* Reserved */
178 u_char pad4 :6; /* Reserved */
179 u_char loadEject :1; /* Load or eject medium */
180 u_char start :1; /* Start or stop medium */
181 u_char control; /* See flags for common bits */
182#else
183 u_char command; /* command code, defined below. The
184 * upper three bits of this are zero
185 * to indicate the control block is
186 * only 6 bytes long */
187 u_char immed :1; /* Immediate status bit */
188 u_char pad1 :4; /* Reserved */
189 u_char unitNumber :3; /* Logical Unit (LUN) to which to
190 * pass the command. The device
191 * has already been selected using
192 * the "targetID" bit. */
193 u_char pad2; /* Reserved */
194 u_char pad3; /* Reserved */
195 u_char start :1; /* Start or stop medium */
196 u_char loadEject :1; /* Load or eject medium */
197 u_char pad4 :6; /* Reserved */
198 u_char control; /* See flags for common bits */
199#endif
200} ScsiStartStopCmd;
201
202/*
203 * The standard group1 10-byte SCSI control block. Note that the
204 * fields between highAddr and blockCount inclusive are command dependent.
205 * The definitions Addr and BlockCount cover most of the commands we will
206 * use.
207 */
208typedef struct ScsiGroup1Cmd {
209 u_char command; /* command code, defined below. The
210 * upper three bits of this are zero
211 * to indicate the control block is
212 * only 6 bytes long */
213#if BYTE_ORDER == BIG_ENDIAN
214 u_char unitNumber :3; /* Logical Unit (LUN) to which to
215 * pass the command. The device
216 * has already been selected using
217 * the "targetID" bit. */
218 u_char pad1 :5; /* Reserved */
219#else
220 u_char pad1 :5; /* Reserved */
221 u_char unitNumber :3; /* Logical Unit (LUN) to which to
222 * pass the command. The device
223 * has already been selected using
224 * the "targetID" bit. */
225#endif
226 u_char highAddr; /* High bits of address */
227 u_char midHighAddr; /* Middle high bits of address */
228 u_char midLowAddr; /* Middle low bits of address */
229 u_char lowAddr; /* Low bits of address */
230 u_char pad2; /* Reserved */
231 u_char highBlockCount; /* High bits of blocks to transfer */
232 u_char lowBlockCount; /* Low bits of blocks to transfer */
233 u_char control; /* See flags for common bits */
234} ScsiGroup1Cmd;
235
236/*
237 * SCSI status completion information.
238 * This is returned by the device when a command completes.
239 */
240#define SCSI_STATUS_CHECKCOND 0x02 /* Check Condition (ie., read sense) */
241#define SCSI_STATUS_CONDMET 0x04 /* Condition Met (ie., search worked) */
242#define SCSI_STATUS_BUSY 0x08
243#define SCSI_STATUS_INTERMED 0x10 /* Intermediate status sent */
244#define SCSI_STATUS_EXT 0x80 /* Extended status valid */
245
246/*
247 * Sense information provided after some errors. This is divided into
248 * two kinds, classes 0-6, and class 7. This is 30 bytes big to allow
249 * for the drive specific sense bytes that follow the standard 4 byte header.
250 *
251 * For extended sense, this buffer may be cast into another type. Also
252 * The actual size of the sense data returned is used to detect what
253 * kind of tape drive is out there. Kludgy, but true.
254 */
255typedef struct ScsiClass0Sense {
256#if BYTE_ORDER == BIG_ENDIAN
257 u_char valid :1; /* Sense data is valid */
258 u_char error :7; /* 3 bits class and 4 bits code */
259#else
260 u_char error :7; /* 3 bits class and 4 bits code */
261 u_char valid :1; /* Sense data is valid */
262#endif
263 u_char highAddr; /* High byte of block address */
264 u_char midAddr; /* Middle byte of block address */
265 u_char lowAddr; /* Low byte of block address */
266 u_char sense[26]; /* Target specific sense data */
267} ScsiClass0Sense;
268
269/*
270 * Definitions for errors in the sense data. The error field is specified
271 * as a 3 bit class and 4 bit code, but it is easier to treat it as a
272 * single 7 bit field.
273 */
274#define SCSI_NO_SENSE_DATA 0x00
275#define SCSI_NOT_READY 0x04
276#define SCSI_NOT_LOADED 0x09
277#define SCSI_INSUF_CAPACITY 0x0a
278#define SCSI_HARD_DATA_ERROR 0x11
279#define SCSI_WRITE_PROTECT 0x17
280#define SCSI_CORRECTABLE_ERROR 0x18
281#define SCSI_FILE_MARK 0x1c
282#define SCSI_INVALID_COMMAND 0x20
283#define SCSI_UNIT_ATTENTION 0x30
284#define SCSI_END_OF_MEDIA 0x34
285
286/*
287 * The standard "extended" sense data returned by SCSI devices. This
288 * has an error field of 0x70, for a "class 7" error.
289 */
290typedef struct ScsiClass7Sense {
291#if BYTE_ORDER == BIG_ENDIAN
292 u_char valid :1; /* Sense data is valid */
293 u_char error7 :7; /* == 0x70 */
294 u_char pad1; /* Also "segment number" for copy */
295 u_char fileMark :1; /* File mark on device */
296 u_char endOfMedia :1; /* End of media reached */
297 u_char badBlockLen :1; /* Block length mis-match (Exabyte) */
298 u_char pad2 :1;
299 u_char key :4; /* Sense keys defined below */
300 u_char info1; /* Information byte 1 */
301 u_char info2; /* Information byte 2 */
302 u_char info3; /* Information byte 3 */
303 u_char info4; /* Information byte 4 */
304 u_char length; /* Number of additional info bytes */
305#else
306 u_char error7 :7; /* == 0x70 */
307 u_char valid :1; /* Sense data is valid */
308 u_char pad1; /* Also "segment number" for copy */
309 u_char key :4; /* Sense keys defined below */
310 u_char pad2 :1;
311 u_char badBlockLen :1; /* Block length mis-match (Exabyte) */
312 u_char endOfMedia :1; /* End of media reached */
313 u_char fileMark :1; /* File mark on device */
314 u_char info1; /* Information byte 1 */
315 u_char info2; /* Information byte 2 */
316 u_char info3; /* Information byte 3 */
317 u_char info4; /* Information byte 4 */
318 u_char length; /* Number of additional info bytes */
319#endif
320} ScsiClass7Sense; /* 8 Bytes */
321
322/*
323 * Key values for standardized sense class 7.
324 */
325#define SCSI_CLASS7_NO_SENSE 0
326#define SCSI_CLASS7_RECOVERABLE 1
327#define SCSI_CLASS7_NOT_READY 2
328#define SCSI_CLASS7_MEDIA_ERROR 3
329#define SCSI_CLASS7_HARDWARE_ERROR 4
330#define SCSI_CLASS7_ILLEGAL_REQUEST 5
331
332/*
333 * These seem to have different meanings to different vendors....
334 */
335#define SCSI_CLASS7_MEDIA_CHANGE 6
336#define SCSI_CLASS7_UNIT_ATTN 6
337
338#define SCSI_CLASS7_WRITE_PROTECT 7
339#define SCSI_CLASS7_BLANK_CHECK 8
340#define SCSI_CLASS7_VENDOR 9
341#define SCSI_CLASS7_POWER_UP_FAILURE 10
342#define SCSI_CLASS7_ABORT 11
343#define SCSI_CLASS7_EQUAL 12
344#define SCSI_CLASS7_OVERFLOW 13
345#define SCSI_CLASS7_RESERVED_14 14
346#define SCSI_CLASS7_RESERVED_15 15
347
348/*
349 * Data return by the SCSI inquiry command.
350 */
351typedef struct ScsiInquiryData {
352#if BYTE_ORDER == BIG_ENDIAN
353 u_char type; /* Peripheral Device type. See below. */
354 u_char rmb:1; /* Removable Medium bit. */
355 u_char qualifier:7; /* Device type qualifier. */
356 u_char version; /* Version info. */
357 u_char reserved:4; /* reserved. */
358 u_char format:4; /* Response format. */
359 u_char length; /* length of data returned. */
360 u_char reserved2[2]; /* Reserved */
361 u_char flags; /* SCSI II flags (see below) */
362 u_char vendorID[8]; /* Vendor ID (ASCII) */
363 u_char productID[16]; /* Product ID (ASCII) */
364 u_char revLevel[4]; /* Revision level (ASCII) */
365 u_char revData[8]; /* Revision data (ASCII) */
366#else
367 u_char type; /* Peripheral Device type. See below. */
368 u_char qualifier:7; /* Device type qualifier. */
369 u_char rmb:1; /* Removable Medium bit. */
370 u_char version; /* Version info. */
371 u_char format:4; /* Response format. */
372 u_char reserved:4; /* reserved. */
373 u_char length; /* length of data returned. */
374 u_char reserved2[2]; /* Reserved */
375 u_char flags; /* SCSI II flags (see below) */
376 u_char vendorID[8]; /* Vendor ID (ASCII) */
377 u_char productID[16]; /* Product ID (ASCII) */
378 u_char revLevel[4]; /* Revision level (ASCII) */
379 u_char revData[8]; /* Revision data (ASCII) */
380#endif
381} ScsiInquiryData;
382
383/*
384 * The SCSI Peripheral type ID codes as return by the SCSI_INQUIRY command.
385 *
386 * SCSI_DISK_TYPE - Direct Access Device.
387 * SCSI_TAPE_TYPE - Sequential Access Device.
388 * SCSI_PRINTER_TYPE - Printer Device.
389 * SCSI_HOST_TYPE - Processor Device.
390 * SCSI_WORM_TYPE - Write-Once Read-Multiple Device.
391 * SCSI_ROM_TYPE - Read-Only Direct Access Device.
392 * SCSI_SCANNER_TYPE - Scanner device.
393 * SCSI_OPTICAL_MEM_TYPE - Optical memory device.
394 * SCSI_MEDIUM_CHANGER_TYPE - Medium changer device.
395 * SCSI_COMMUNICATIONS_TYPE - Communications device.
396 * SCSI_NODEVICE_TYPE - Logical Unit not present or implemented.
397 *
398 * Note that codes 0xa-0x7e are reserved and 0x80-0xff are vendor unique.
399 */
400#define SCSI_DISK_TYPE 0
401#define SCSI_TAPE_TYPE 1
402#define SCSI_PRINTER_TYPE 2
403#define SCSI_HOST_TYPE 3
404#define SCSI_WORM_TYPE 4
405#define SCSI_ROM_TYPE 5
406#define SCSI_SCANNER_TYPE 6
407#define SCSI_OPTICAL_MEM_TYPE 7
408#define SCSI_MEDIUM_CHANGER_TYPE 8
409#define SCSI_COMMUNICATIONS_TYPE 9
410#define SCSI_NODEVICE_TYPE 0x7f
411
412/*
413 * The SCSI I & II inquiry flags.
414 *
415 * SCSI_REL_ADR - Relative addressing supported.
416 * SCSI_WIDE_32 - 32 bit wide SCSI bus transfers supported.
417 * SCSI_WIDE_16 - 16 bit wide SCSI bus transfers supported.
418 * SCSI_SYNC - Synchronous data transfers supported.
419 * SCSI_LINKED - Linked commands supported.
420 * SCSI_CMD_QUEUE - Tagged command queuing supported.
421 * SCSI_SOFT_RESET - Soft RESET alternative suported.
422 */
423#define SCSI_REL_ADR 0x80
424#define SCSI_WIDE_32 0x40
425#define SCSI_WIDE_16 0x20
426#define SCSI_SYNC 0x10
427#define SCSI_LINKED 0x08
428#define SCSI_CMD_QUEUE 0x02
429#define SCSI_SOFT_RESET 0x01
430
431/*
5ddac841 432 * Standard header for SCSI_MODE_SENSE and SCSI_MODE_SELECT commands for tapes.
12d43ee5
KM
433 */
434typedef struct ScsiTapeModeSelectHdr {
5ddac841
RC
435 u_char len; /* length */
436 u_char media; /* media type */
12d43ee5 437#if BYTE_ORDER == BIG_ENDIAN
5ddac841 438 u_char writeprot:1; /* Write protected media */
12d43ee5
KM
439 u_char bufferedMode:3; /* Type of buffer to be done. */
440 u_char speed:4; /* Drive speed. */
12d43ee5 441#else
12d43ee5
KM
442 u_char speed:4; /* Drive speed. */
443 u_char bufferedMode:3; /* Type of buffer to be done. */
5ddac841 444 u_char writeprot:1; /* Write protected media */
12d43ee5 445#endif
5ddac841
RC
446 u_char length; /* Block descriptor length. */
447 u_char density; /* tape density code */
448 u_char blocks_2; /* number of blocks (MSB) */
449 u_char blocks_1; /* number of blocks */
450 u_char blocks_0; /* number of blocks (LSB) */
451 u_char reserved; /* */
452 u_char block_size2; /* Tape block size (MSB) */
453 u_char block_size1; /* Tape block size */
454 u_char block_size0; /* Tape block size (LSB) */
455 u_char vendor[6]; /* vendor specific data */
12d43ee5
KM
456} ScsiTapeModeSelectHdr;
457
458/*
459 * Definitions of SCSI messages.
460 *
461 * SCSI_COMMAND_COMPLETE - After a command has completed, successfully
462 * or not, this is returned to the host from the target.
463 *
464 * SCSI_EXTENDED_MSG - Indicates that a multi-byte message is being sent.
465 *
466 * The following messages are used with connect/disconnect:
467 * SCSI_SAVE_DATA_POINTER - Sent from target to host to request saving
468 * of current DMA address and count. Indicates a pending dis-connect.
469 * SCSI_RESTORE_POINTER - Sent from the target to the host to request
470 * restoring pointers saved before a disconnect
471 * SCSI_DISCONNECT - Sent from the target to the host to disconnect.
472 * SCSI_ABORT - Sent from the host to the target to abort current request.
473 * SCSI_MESSAGE_REJECT - Indicates receipt, by either host or target, of
474 * an unimplemented message.
475 * SCSI_NO_OP - Sent from host to target if it has no real message to send.
476 * SCSI_MESSAGE_PARITY_ERROR - Sent from host to target on message parity error
477 * SCSI_BUS_RESET - Sent from host to target to reset all current I/O
478 *
479 * SCSI_IDENTIFY - The low order two bits of this message type indicate
480 * the Logical Unit of the Target which is requesting a reconnect.
481 * SCSI_DIS_REC_IDENTIFY - Sent from the host to a target to indicate
482 * is supports connect/dis-connect
483 *
484 */
485#define SCSI_COMMAND_COMPLETE 0x00
486#define SCSI_EXTENDED_MSG 0x01
487#define SCSI_SAVE_DATA_POINTER 0x02
488#define SCSI_RESTORE_POINTERS 0x03
489#define SCSI_DISCONNECT 0x04
490#define SCSI_ABORT 0x06
491#define SCSI_MESSAGE_REJECT 0x07
492#define SCSI_NO_OP 0x08
493#define SCSI_MESSAGE_PARITY_ERROR 0x09
494#define SCSI_LINKED_CMD_COMPLETE 0x0A
495#define SCSI_LINKED_FLAGED_CMD_COMPLETE 0x0B
496#define SCSI_BUS_RESET 0x0C
497
498#define SCSI_IDENTIFY 0x80
499#define SCSI_DIS_REC_IDENTIFY 0xc0
500
501/*
502 * Extended message types (2nd byte of SCSI_EXTENDED_MSG).
503 */
504#define SCSI_MODIFY_DATA_PTR 0x00
505#define SCSI_SYNCHRONOUS_XFER 0x01
506#define SCSI_EXTENDED_IDENTIFY 0x02 /* only in SCSI I */
507#define SCSI_WIDE_XFER 0x03
508
509/*
510 * Driver ioctl's for various scsi operations.
511 */
512#ifndef _IOCTL_
38a01dbe 513#include <sys/ioctl.h>
12d43ee5
KM
514#endif
515
516/*
517 * Control for SCSI "format" mode.
518 *
519 * "Format" mode allows a privileged process to issue direct SCSI
520 * commands to a drive (it is intended primarily to allow on-line
521 * formatting). SDIOCSFORMAT with a non-zero arg will put the drive
522 * into format mode; a zero arg will take it out. When in format
523 * mode, only the process that issued the SDIOCFORMAT can read or
524 * write the drive.
525 *
526 * In format mode, process is expected to
527 * - do SDIOCSCSICOMMAND to supply cdb for next SCSI op
528 * - do read or write as appropriate for cdb
529 * - if i/o error, optionally do SDIOCSENSE to get completion
530 * status and sense data from last scsi operation.
531 */
532
533struct scsi_fmt_cdb {
534 int len; /* cdb length (in bytes) */
535 u_char cdb[28]; /* cdb to use on next read/write */
536};
537
538struct scsi_fmt_sense {
539 u_int status; /* completion status of last op */
540 u_char sense[32]; /* sense data (if any) from last op */
541};
542
543#define SDIOCSFORMAT _IOW('S', 0x1, int)
544#define SDIOCGFORMAT _IOR('S', 0x2, int)
545#define SDIOCSCSICOMMAND _IOW('S', 0x3, struct scsi_fmt_cdb)
546#define SDIOCSENSE _IOR('S', 0x4, struct scsi_fmt_sense)
547
548#ifdef KERNEL
549/*
550 * Routines.
551 */
552extern void scsiGroup0Cmd();
553extern void scsiGroup1Cmd();
c872e6d9 554#endif /* KERNEL */
12d43ee5
KM
555
556#endif /* _SCSI_H */