2 |
- |
1 |
#pragma src "/sys/src/libdisk"
|
|
|
2 |
#pragma lib "libdisk.a"
|
|
|
3 |
|
|
|
4 |
/* SCSI interface */
|
|
|
5 |
typedef struct Scsi Scsi;
|
|
|
6 |
struct Scsi {
|
|
|
7 |
QLock;
|
|
|
8 |
char* inquire;
|
|
|
9 |
int rawfd;
|
|
|
10 |
int nchange;
|
|
|
11 |
ulong changetime;
|
|
|
12 |
};
|
|
|
13 |
|
|
|
14 |
enum {
|
|
|
15 |
Sread = 0,
|
|
|
16 |
Swrite,
|
|
|
17 |
Snone,
|
|
|
18 |
};
|
|
|
19 |
|
|
|
20 |
char* scsierror(int, int);
|
|
|
21 |
int scsicmd(Scsi*, uchar*, int, void*, int, int);
|
|
|
22 |
int scsi(Scsi*, uchar*, int, void*, int, int);
|
|
|
23 |
Scsi* openscsi(char*);
|
|
|
24 |
void closescsi(Scsi*);
|
|
|
25 |
int scsiready(Scsi*);
|
|
|
26 |
|
|
|
27 |
extern int scsiverbose;
|
|
|
28 |
|
|
|
29 |
/* disk partition interface */
|
|
|
30 |
typedef struct Disk Disk;
|
|
|
31 |
struct Disk {
|
|
|
32 |
char *prefix;
|
|
|
33 |
char *part;
|
|
|
34 |
int fd;
|
|
|
35 |
int wfd;
|
|
|
36 |
int ctlfd;
|
|
|
37 |
int rdonly;
|
|
|
38 |
int type;
|
|
|
39 |
|
|
|
40 |
vlong secs;
|
|
|
41 |
vlong secsize;
|
|
|
42 |
vlong size;
|
|
|
43 |
vlong offset; /* within larger disk, perhaps */
|
|
|
44 |
int width; /* of disk size in bytes as decimal string */
|
|
|
45 |
int c;
|
|
|
46 |
int h;
|
|
|
47 |
int s;
|
|
|
48 |
int chssrc;
|
|
|
49 |
};
|
|
|
50 |
|
|
|
51 |
Disk* opendisk(char*, int, int);
|
|
|
52 |
|
|
|
53 |
enum {
|
|
|
54 |
Tfile = 0,
|
|
|
55 |
Tsd,
|
|
|
56 |
Tfloppy,
|
|
|
57 |
|
|
|
58 |
Gpart = 0, /* partition info source */
|
|
|
59 |
Gdisk,
|
|
|
60 |
Gguess,
|
|
|
61 |
};
|
|
|
62 |
enum { /* SCSI command codes */
|
|
|
63 |
ScmdTur = 0x00, /* test unit ready */
|
|
|
64 |
ScmdRewind = 0x01, /* rezero/rewind */
|
|
|
65 |
ScmdRsense = 0x03, /* request sense */
|
|
|
66 |
ScmdFormat = 0x04, /* format unit */
|
|
|
67 |
ScmdRblimits = 0x05, /* read block limits */
|
|
|
68 |
ScmdRead = 0x08, /* read */
|
|
|
69 |
ScmdWrite = 0x0A, /* write */
|
|
|
70 |
ScmdSeek = 0x0B, /* seek */
|
|
|
71 |
ScmdFmark = 0x10, /* write filemarks */
|
|
|
72 |
ScmdSpace = 0x11, /* space forward/backward */
|
|
|
73 |
ScmdInq = 0x12, /* inquiry */
|
|
|
74 |
ScmdMselect6 = 0x15, /* mode select */
|
|
|
75 |
ScmdMselect10 = 0x55, /* mode select */
|
|
|
76 |
ScmdMsense6 = 0x1A, /* mode sense */
|
|
|
77 |
ScmdMsense10 = 0x5A, /* mode sense */
|
|
|
78 |
ScmdStart = 0x1B, /* start/stop unit */
|
|
|
79 |
ScmdRcapacity = 0x25, /* read capacity */
|
|
|
80 |
ScmdRcapacity16 = 0x9e, /* long read capacity */
|
|
|
81 |
ScmdRformatcap = 0x23, /* read format capacity */
|
|
|
82 |
ScmdExtread = 0x28, /* extended read (10 bytes) */
|
|
|
83 |
ScmdRead16 = 0x88, /* long read (16 bytes) */
|
|
|
84 |
ScmdExtwrite = 0x2A, /* extended write (10 bytes) */
|
|
|
85 |
ScmdExtwritever = 0x2E, /* extended write and verify (10) */
|
|
|
86 |
ScmdWrite16 = 0x8A, /* long write (16 bytes) */
|
|
|
87 |
ScmdExtseek = 0x2B, /* extended seek */
|
|
|
88 |
|
|
|
89 |
ScmdSynccache = 0x35, /* flush cache */
|
|
|
90 |
ScmdRTOC = 0x43, /* read TOC data */
|
|
|
91 |
ScmdRdiscinfo = 0x51, /* read disc information */
|
|
|
92 |
ScmdRtrackinfo = 0x52, /* read track information */
|
|
|
93 |
ScmdReserve = 0x53, /* reserve track */
|
|
|
94 |
ScmdBlank = 0xA1, /* blank *-RW media */
|
|
|
95 |
|
|
|
96 |
ScmdCDpause = 0x4B, /* pause/resume */
|
|
|
97 |
ScmdCDstop = 0x4E, /* stop play/scan */
|
|
|
98 |
ScmdCDplay = 0xA5, /* play audio */
|
|
|
99 |
ScmdCDload = 0xA6, /* load/unload */
|
|
|
100 |
ScmdCDscan = 0xBA, /* fast forward/reverse */
|
|
|
101 |
ScmdCDstatus = 0xBD, /* mechanism status */
|
|
|
102 |
Scmdgetconf = 0x46, /* get configuration */
|
|
|
103 |
|
|
|
104 |
ScmdEInitialise = 0x07, /* initialise element status */
|
|
|
105 |
ScmdMMove = 0xA5, /* move medium */
|
|
|
106 |
ScmdEStatus = 0xB8, /* read element status */
|
|
|
107 |
ScmdMExchange = 0xA6, /* exchange medium */
|
|
|
108 |
ScmdEposition = 0x2B, /* position to element */
|
|
|
109 |
|
|
|
110 |
ScmdReadDVD = 0xAD, /* read dvd structure */
|
|
|
111 |
ScmdReportKey = 0xA4, /* read dvd key */
|
|
|
112 |
ScmdSendKey = 0xA3, /* write dvd key */
|
|
|
113 |
|
|
|
114 |
ScmdClosetracksess= 0x5B,
|
|
|
115 |
ScmdRead12 = 0xA8,
|
|
|
116 |
ScmdSetcdspeed = 0xBB,
|
|
|
117 |
ScmdReadcd = 0xBE,
|
|
|
118 |
|
|
|
119 |
/* vendor-specific */
|
|
|
120 |
ScmdFwaddr = 0xE2, /* first writeable address */
|
|
|
121 |
ScmdTreserve = 0xE4, /* reserve track */
|
|
|
122 |
ScmdTinfo = 0xE5, /* read track info */
|
|
|
123 |
ScmdTwrite = 0xE6, /* write track */
|
|
|
124 |
ScmdMload = 0xE7, /* medium load/unload */
|
|
|
125 |
ScmdFixation = 0xE9, /* fixation */
|
|
|
126 |
};
|
|
|
127 |
|
|
|
128 |
/* proto file parsing */
|
|
|
129 |
typedef void Protoenum(char *new, char *old, Dir *d, void *a);
|
|
|
130 |
typedef void Protowarn(char *msg, void *a);
|
|
|
131 |
int rdproto(char*, char*, Protoenum*, Protowarn*, void*);
|