2 |
- |
1 |
/*
|
|
|
2 |
* This is /sys/src/cmd/scuzz/scsireq.h
|
|
|
3 |
* changed to add more debug support, and to keep
|
|
|
4 |
* disk compiling without a scuzz that includes these changes.
|
|
|
5 |
*
|
|
|
6 |
* scsireq.h is also included by usb/disk and cdfs.
|
|
|
7 |
*/
|
|
|
8 |
typedef struct Umsc Umsc;
|
|
|
9 |
#pragma incomplete Umsc
|
|
|
10 |
|
|
|
11 |
enum { /* fundamental constants/defaults */
|
|
|
12 |
MaxDirData = 255, /* max. direct data returned */
|
|
|
13 |
/*
|
|
|
14 |
* Because we are accessed via devmnt, we can never get i/o counts
|
|
|
15 |
* larger than 8216 (Msgsize and devmnt's offered iounit) - 24
|
|
|
16 |
* (IOHDRSZ) = 8K.
|
|
|
17 |
*/
|
|
|
18 |
Maxiosize = 8216 - IOHDRSZ, /* max. I/O transfer size */
|
|
|
19 |
};
|
|
|
20 |
|
|
|
21 |
typedef struct {
|
|
|
22 |
uchar *p;
|
|
|
23 |
long count;
|
|
|
24 |
uchar write;
|
|
|
25 |
} ScsiPtr;
|
|
|
26 |
|
|
|
27 |
typedef struct {
|
|
|
28 |
int flags;
|
|
|
29 |
char *unit; /* unit directory */
|
|
|
30 |
int lun;
|
|
|
31 |
ulong lbsize;
|
|
|
32 |
uvlong offset; /* in blocks of lbsize bytes */
|
|
|
33 |
int fd;
|
|
|
34 |
Umsc *umsc; /* lun */
|
|
|
35 |
ScsiPtr cmd;
|
|
|
36 |
ScsiPtr data;
|
|
|
37 |
int status; /* returned status */
|
|
|
38 |
uchar sense[MaxDirData]; /* returned sense data */
|
|
|
39 |
uchar inquiry[MaxDirData]; /* returned inquiry data */
|
|
|
40 |
int readblock; /* flag: read a block since open */
|
|
|
41 |
} ScsiReq;
|
|
|
42 |
|
|
|
43 |
enum { /* software flags */
|
|
|
44 |
Fopen = 0x0001, /* open */
|
|
|
45 |
Fseqdev = 0x0002, /* sequential-access device */
|
|
|
46 |
Fwritten = 0x0004, /* device written */
|
|
|
47 |
Fronly = 0x0008, /* device is read-only */
|
|
|
48 |
Fwormdev = 0x0010, /* write-once read-multiple device */
|
|
|
49 |
Fprintdev = 0x0020, /* printer */
|
|
|
50 |
Fbfixed = 0x0040, /* fixed block size */
|
|
|
51 |
Fchanger = 0x0080, /* medium-changer device */
|
|
|
52 |
Finqok = 0x0100, /* inquiry data is OK */
|
|
|
53 |
Fmode6 = 0x0200, /* use 6-byte modeselect */
|
|
|
54 |
Frw10 = 0x0400, /* use 10-byte read/write */
|
|
|
55 |
Fusb = 0x0800, /* USB transparent scsi */
|
|
|
56 |
};
|
|
|
57 |
|
|
|
58 |
enum {
|
|
|
59 |
STnomem =-4, /* buffer allocation failed */
|
|
|
60 |
STharderr =-3, /* controller error of some kind */
|
|
|
61 |
STtimeout =-2, /* bus timeout */
|
|
|
62 |
STok = 0, /* good */
|
|
|
63 |
STcheck = 0x02, /* check condition */
|
|
|
64 |
STcondmet = 0x04, /* condition met/good */
|
|
|
65 |
STbusy = 0x08, /* busy */
|
|
|
66 |
STintok = 0x10, /* intermediate/good */
|
|
|
67 |
STintcondmet = 0x14, /* intermediate/condition met/good */
|
|
|
68 |
STresconf = 0x18, /* reservation conflict */
|
|
|
69 |
STterminated = 0x22, /* command terminated */
|
|
|
70 |
STqfull = 0x28, /* queue full */
|
|
|
71 |
};
|
|
|
72 |
|
|
|
73 |
enum { /* status */
|
|
|
74 |
Status_SD = 0x80, /* sense-data available */
|
|
|
75 |
Status_SW = 0x83, /* internal software error */
|
|
|
76 |
Status_BADARG = 0x84, /* bad argument to request */
|
|
|
77 |
Status_RO = 0x85, /* device is read-only */
|
|
|
78 |
};
|
|
|
79 |
|
|
|
80 |
enum {
|
|
|
81 |
/* sense data byte 0 */
|
|
|
82 |
Sd0valid = 0x80, /* valid sense data present */
|
|
|
83 |
|
|
|
84 |
/* sense data byte 2 */
|
|
|
85 |
/* incorrect-length indicator, difference in bytes 3—6 */
|
|
|
86 |
Sd2ili = 0x20,
|
|
|
87 |
Sd2eom = 0x40, /* end of medium (tape) */
|
|
|
88 |
Sd2filemark = 0x80, /* at a filemark (tape) */
|
|
|
89 |
|
|
|
90 |
/* command byte 1 */
|
|
|
91 |
Cmd1fixed = 1, /* use fixed-length blocks */
|
|
|
92 |
Cmd1sili = 2, /* don't set Sd2ili */
|
|
|
93 |
|
|
|
94 |
/* limit of block #s in 24-bit ccbs */
|
|
|
95 |
Max24off = (1<<21) - 1, /* 2ⁱ - 1 */
|
|
|
96 |
|
|
|
97 |
/* mode pages */
|
|
|
98 |
Allmodepages = 0x3F,
|
|
|
99 |
};
|
|
|
100 |
|
|
|
101 |
/* scsi device types, from the scsi standards */
|
|
|
102 |
enum {
|
|
|
103 |
Devdir, /* usually disk */
|
|
|
104 |
Devseq, /* usually tape */
|
|
|
105 |
Devprint,
|
|
|
106 |
Dev3,
|
|
|
107 |
Devworm, /* also direct, but special */
|
|
|
108 |
Devcd, /* also direct */
|
|
|
109 |
Dev6,
|
|
|
110 |
Devmo, /* also direct */
|
|
|
111 |
Devjuke,
|
|
|
112 |
};
|
|
|
113 |
|
|
|
114 |
/* p arguments should be of type uchar* */
|
|
|
115 |
#define GETBELONG(p) ((ulong)(p)[0]<<24 | (ulong)(p)[1]<<16 | (p)[2]<<8 | (p)[3])
|
|
|
116 |
#define PUTBELONG(p, ul) ((p)[0] = (ul)>>24, (p)[1] = (ul)>>16, \
|
|
|
117 |
(p)[2] = (ul)>>8, (p)[3] = (ul))
|
|
|
118 |
#define GETBE24(p) ((ulong)(p)[0]<<16 | (p)[1]<<8 | (p)[2])
|
|
|
119 |
#define PUTBE24(p, ul) ((p)[0] = (ul)>>16, (p)[1] = (ul)>>8, (p)[2] = (ul))
|
|
|
120 |
|
|
|
121 |
long SRready(ScsiReq*);
|
|
|
122 |
long SRrewind(ScsiReq*);
|
|
|
123 |
long SRreqsense(ScsiReq*);
|
|
|
124 |
long SRformat(ScsiReq*);
|
|
|
125 |
long SRrblimits(ScsiReq*, uchar*);
|
|
|
126 |
long SRread(ScsiReq*, void*, long);
|
|
|
127 |
long SRwrite(ScsiReq*, void*, long);
|
|
|
128 |
long SRseek(ScsiReq*, long, int);
|
|
|
129 |
long SRfilemark(ScsiReq*, ulong);
|
|
|
130 |
long SRspace(ScsiReq*, uchar, long);
|
|
|
131 |
long SRinquiry(ScsiReq*);
|
|
|
132 |
long SRmodeselect6(ScsiReq*, uchar*, long);
|
|
|
133 |
long SRmodeselect10(ScsiReq*, uchar*, long);
|
|
|
134 |
long SRmodesense6(ScsiReq*, uchar, uchar*, long);
|
|
|
135 |
long SRmodesense10(ScsiReq*, uchar, uchar*, long);
|
|
|
136 |
long SRstart(ScsiReq*, uchar);
|
|
|
137 |
long SRrcapacity(ScsiReq*, uchar*);
|
|
|
138 |
long SRrcapacity16(ScsiReq*, uchar*);
|
|
|
139 |
|
|
|
140 |
long SRblank(ScsiReq*, uchar, uchar); /* MMC CD-R/CD-RW commands */
|
|
|
141 |
long SRsynccache(ScsiReq*);
|
|
|
142 |
long SRTOC(ScsiReq*, void*, int, uchar, uchar);
|
|
|
143 |
long SRrdiscinfo(ScsiReq*, void*, int);
|
|
|
144 |
long SRrtrackinfo(ScsiReq*, void*, int, int);
|
|
|
145 |
|
|
|
146 |
long SRcdpause(ScsiReq*, int); /* MMC CD audio commands */
|
|
|
147 |
long SRcdstop(ScsiReq*);
|
|
|
148 |
long SRcdload(ScsiReq*, int, int);
|
|
|
149 |
long SRcdplay(ScsiReq*, int, long, long);
|
|
|
150 |
long SRcdstatus(ScsiReq*, uchar*, int);
|
|
|
151 |
long SRgetconf(ScsiReq*, uchar*, int);
|
|
|
152 |
|
|
|
153 |
/* old CD-R/CD-RW commands */
|
|
|
154 |
long SRfwaddr(ScsiReq*, uchar, uchar, uchar, uchar*);
|
|
|
155 |
long SRtreserve(ScsiReq*, long);
|
|
|
156 |
long SRtinfo(ScsiReq*, uchar, uchar*);
|
|
|
157 |
long SRwtrack(ScsiReq*, void*, long, uchar, uchar);
|
|
|
158 |
long SRmload(ScsiReq*, uchar);
|
|
|
159 |
long SRfixation(ScsiReq*, uchar);
|
|
|
160 |
|
|
|
161 |
long SReinitialise(ScsiReq*); /* CHANGER commands */
|
|
|
162 |
long SRestatus(ScsiReq*, uchar, uchar*, int);
|
|
|
163 |
long SRmmove(ScsiReq*, int, int, int, int);
|
|
|
164 |
|
|
|
165 |
long SRrequest(ScsiReq*);
|
|
|
166 |
int SRclose(ScsiReq*);
|
|
|
167 |
int SRopenraw(ScsiReq*, char*);
|
|
|
168 |
int SRopen(ScsiReq*, char*);
|
|
|
169 |
|
|
|
170 |
void makesense(ScsiReq*);
|
|
|
171 |
|
|
|
172 |
long umsrequest(struct Umsc*, ScsiPtr*, ScsiPtr*, int*);
|
|
|
173 |
|
|
|
174 |
void scsidebug(int);
|
|
|
175 |
|
|
|
176 |
char* scsierrmsg(int n);
|