1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47 typedef unsigned char bcd_t;
48 #define M_msf(msf) msf[0]
49 #define S_msf(msf) msf[1]
50 #define F_msf(msf) msf[2]
51
52 #define MCD_COMMAND 0
53 #define MCD_STATUS 0
54 #define MCD_RDATA 0
55 #define MCD_RESET 1
56 #define MCD_XFER 1
57 #define MCD_CTL2 2
58 #define MCD_CONFIG 3
59 #define MCD_NPORT 4
60
61 #define MCD_MASK_DMA 0x07
62 #define MCD_MASK_IRQ 0x70
63
64
65
66
67
68
69
70 #define MCD_ST_DOOROPEN 0x80
71 #define MCD_ST_DSKIN 0x40
72 #define MCD_ST_DSKCHNG 0x20
73 #define MCD_ST_SPINNING 0x10
74 #define MCD_ST_AUDIODISK 0x08
75 #define MCD_ST_READERR 0x04
76 #define MCD_ST_AUDIOBSY 0x02
77 #define MCD_ST_CMDCHECK 0x01
78
79
80 #define MCD_XF_STATUSUNAVAIL 0x04
81 #define MCD_XF_DATAUNAVAIL 0x02
82
83
84 #define MCD_MD_TESTMODE 0x80
85 #define MCD_MD_DATALENGTH 0x40
86 #define MCD_MD_ECCMODE 0x20
87 #define MCD_MD_SPINDOWN 0x08
88 #define MCD_MD_READTOC 0x04
89 #define MCD_MD_PLAYAUDIO 0x01
90
91 #define MCD_MD_RAW (MCD_MD_PLAYAUDIO|MCD_MD_ECCMODE|MCD_MD_DATALENGTH)
92 #define MCD_MD_COOKED (MCD_MD_PLAYAUDIO)
93 #define MCD_MD_TOC (MCD_MD_PLAYAUDIO|MCD_MD_READTOC)
94 #define MCD_MD_SLEEP (MCD_MD_PLAYAUDIO|MCD_MD_SPINDOWN)
95
96 #define MCD_BLKSIZE_RAW sizeof(struct mcd_rawsector)
97 #define MCD_BLKSIZE_COOKED 2048
98
99
100 #define MCD_LK_UNLOCK 0x00
101 #define MCD_LK_LOCK 0x01
102 #define MCD_LK_TEST 0x02
103
104
105 #define MCD_CF_IRQENABLE 0x10
106 #define MCD_CF_DMATIMEOUT 0x08
107 #define MCD_CF_READUPC 0x04
108 #define MCD_CF_DMAENABLE 0x02
109 #define MCD_CF_BLOCKSIZE 0x01
110
111
112 #define MCD_UPC_DISABLE 0x00
113 #define MCD_UPC_ENABLE 0x01
114
115
116 #define MCD_CMDRESET 0x00
117 #define MCD_CMDGETVOLINFO 0x10
118 #define MCD_CMDGETDISKINFO 0x11
119 #define MCD_CMDGETQCHN 0x20
120 #define MCD_CMDGETSENSE 0x30
121 #define MCD_CMDGETSTAT 0x40
122 #define MCD_CMDSETMODE 0x50
123 #define MCD_CMDSTOPAUDIO 0x70
124 #define MCD_CMDSTOPAUDIOTIME 0x80
125 #define MCD_CMDGETVOLUME 0x8E
126 #define MCD_CMDCONFIGDRIVE 0x90
127 #define MCD_CMDSETDRIVEMODE 0xa0
128 #define MCD_CMDSETVOLUME 0xae
129 #define MCD_CMDREAD1 0xb0
130 #define MCD_CMDREADSINGLESPEED 0xc0
131 #define MCD_CMDREADDOUBLESPEED 0xc1
132 #define MCD_CMDGETDRIVEMODE 0xc2
133 #define MCD_CMDREAD3 0xc3
134 #define MCD_CMDSETINTERLEAVE 0xc8
135 #define MCD_CMDCONTINFO 0xdc
136 #define MCD_CMDSTOP 0xf0
137 #define MCD_CMDEJECTDISK 0xf6
138 #define MCD_CMDCLOSETRAY 0xf8
139 #define MCD_CMDSETLOCK 0xfe
140
141 union mcd_qchninfo {
142 struct {
143 u_char control:4;
144 u_char addr_type:4;
145 u_char trk_no;
146 u_char idx_no;
147 bcd_t track_size[3];
148 u_char :8;
149 bcd_t absolute_pos[3];
150 } toc;
151 struct {
152 u_char control:4;
153 u_char addr_type:4;
154 u_char trk_no;
155 u_char idx_no;
156 bcd_t relative_pos[3];
157 u_char :8;
158 bcd_t absolute_pos[3];
159 } current;
160 struct {
161 u_char control:4;
162 u_char addr_type:4;
163 u_char upccode[7];
164 u_char junk[2];
165 } upc;
166 } __packed;
167
168 struct mcd_volinfo {
169 bcd_t trk_low;
170 bcd_t trk_high;
171 bcd_t vol_msf[3];
172 bcd_t trk1_msf[3];
173 } __packed;
174
175 struct mcd_result {
176 u_char length;
177 union {
178 struct {
179 u_char data[1];
180 } raw;
181 struct {
182 u_char code;
183 u_char version;
184 } continfo;
185 union mcd_qchninfo qchninfo;
186 struct mcd_volinfo volinfo;
187 } data;
188 } __packed;
189
190 struct mcd_command {
191 u_char opcode;
192 u_char length;
193 union {
194 struct {
195 u_char data[1];
196 } raw;
197 struct {
198 bcd_t start_msf[3];
199 bcd_t reserved[3];
200 } seek;
201 struct {
202 bcd_t start_msf[3];
203 bcd_t length[3];
204 } read;
205 struct {
206 bcd_t start_msf[3];
207 bcd_t end_msf[3];
208 } play;
209 struct {
210 u_char mode;
211 } datamode;
212 struct {
213 u_char time;
214 } hold;
215 struct {
216 u_char mode;
217 } drivemode;
218 struct {
219 u_char mode;
220 } lockmode;
221 struct {
222 u_char subcommand;
223 u_char data1, data2;
224 } config;
225 } data;
226 } __packed;
227
228 struct mcd_mbox {
229 struct mcd_command cmd;
230 struct mcd_result res;
231 } __packed;
232
233 struct mcd_volume {
234 u_char v0l;
235 u_char v0rs;
236 u_char v0r;
237 u_char v0ls;
238 } __packed;
239
240 struct mcd_rawsector {
241 u_char sync1[12];
242 u_char header[4];
243 u_char subheader1[4];
244 u_char subheader2[4];
245 u_char data[MCD_BLKSIZE_COOKED];
246 u_char ecc_bits[280];
247 } __packed;