]>
Commit | Line | Data |
---|---|---|
1da177e4 LT |
1 | /* |
2 | * linux/drivers/ide/ide_cd.h | |
3 | * | |
4 | * Copyright (C) 1996-98 Erik Andersen | |
5 | * Copyright (C) 1998-2000 Jens Axboe | |
6 | */ | |
7 | #ifndef _IDE_CD_H | |
8 | #define _IDE_CD_H | |
9 | ||
10 | #include <linux/cdrom.h> | |
11 | #include <asm/byteorder.h> | |
12 | ||
13 | /* Turn this on to have the driver print out the meanings of the | |
14 | ATAPI error codes. This will use up additional kernel-space | |
15 | memory, though. */ | |
16 | ||
17 | #ifndef VERBOSE_IDE_CD_ERRORS | |
18 | #define VERBOSE_IDE_CD_ERRORS 1 | |
19 | #endif | |
20 | ||
21 | ||
22 | /* Turning this on will remove code to work around various nonstandard | |
23 | ATAPI implementations. If you know your drive follows the standard, | |
24 | this will give you a slightly smaller kernel. */ | |
25 | ||
26 | #ifndef STANDARD_ATAPI | |
27 | #define STANDARD_ATAPI 0 | |
28 | #endif | |
29 | ||
30 | ||
31 | /* Turning this on will disable the door-locking functionality. | |
32 | This is apparently needed for supermount. */ | |
33 | ||
34 | #ifndef NO_DOOR_LOCKING | |
35 | #define NO_DOOR_LOCKING 0 | |
36 | #endif | |
37 | ||
38 | /* | |
39 | * typical timeout for packet command | |
40 | */ | |
41 | #define ATAPI_WAIT_PC (60 * HZ) | |
42 | #define ATAPI_WAIT_WRITE_BUSY (10 * HZ) | |
43 | ||
44 | /************************************************************************/ | |
45 | ||
46 | #define SECTOR_BITS 9 | |
47 | #ifndef SECTOR_SIZE | |
48 | #define SECTOR_SIZE (1 << SECTOR_BITS) | |
49 | #endif | |
50 | #define SECTORS_PER_FRAME (CD_FRAMESIZE >> SECTOR_BITS) | |
51 | #define SECTOR_BUFFER_SIZE (CD_FRAMESIZE * 32) | |
1da177e4 | 52 | |
455d80a9 BZ |
53 | /* Capabilities Page size including 8 bytes of Mode Page Header */ |
54 | #define ATAPI_CAPABILITIES_PAGE_SIZE (8 + 20) | |
55 | #define ATAPI_CAPABILITIES_PAGE_PAD_SIZE 4 | |
56 | ||
1da177e4 LT |
57 | /* Configuration flags. These describe the capabilities of the drive. |
58 | They generally do not change after initialization, unless we learn | |
59 | more about the drive from stuff failing. */ | |
60 | struct ide_cd_config_flags { | |
61 | __u8 drq_interrupt : 1; /* Device sends an interrupt when ready | |
62 | for a packet command. */ | |
63 | __u8 no_doorlock : 1; /* Drive cannot lock the door. */ | |
64 | __u8 no_eject : 1; /* Drive cannot eject the disc. */ | |
65 | __u8 nec260 : 1; /* Drive is a pre-1.2 NEC 260 drive. */ | |
1da177e4 LT |
66 | __u8 tocaddr_as_bcd : 1; /* TOC addresses are in BCD. */ |
67 | __u8 toctracks_as_bcd : 1; /* TOC track numbers are in BCD. */ | |
1da177e4 LT |
68 | __u8 limit_nframes : 1; /* Drive does not provide data in |
69 | multiples of SECTOR_SIZE when more | |
70 | than one interrupt is needed. */ | |
71 | __u8 seeking : 1; /* Seeking in progress */ | |
3cbd814e | 72 | __u8 no_speed_select : 1; /* SET_CD_SPEED command is unsupported. */ |
1da177e4 LT |
73 | byte max_speed; /* Max speed of the drive */ |
74 | }; | |
1da177e4 | 75 | |
1da177e4 LT |
76 | /* State flags. These give information about the current state of the |
77 | drive, and will change during normal operation. */ | |
78 | struct ide_cd_state_flags { | |
79 | __u8 media_changed : 1; /* Driver has noticed a media change. */ | |
80 | __u8 toc_valid : 1; /* Saved TOC information is current. */ | |
81 | __u8 door_locked : 1; /* We think that the drive door is locked. */ | |
82 | __u8 writing : 1; /* the drive is currently writing */ | |
83 | __u8 reserved : 4; | |
84 | byte current_speed; /* Current speed of the drive */ | |
85 | }; | |
86 | ||
1da177e4 LT |
87 | /* Structure of a MSF cdrom address. */ |
88 | struct atapi_msf { | |
89 | byte reserved; | |
90 | byte minute; | |
91 | byte second; | |
92 | byte frame; | |
93 | }; | |
94 | ||
95 | /* Space to hold the disk TOC. */ | |
96 | #define MAX_TRACKS 99 | |
97 | struct atapi_toc_header { | |
98 | unsigned short toc_length; | |
99 | byte first_track; | |
100 | byte last_track; | |
101 | }; | |
102 | ||
103 | struct atapi_toc_entry { | |
104 | byte reserved1; | |
105 | #if defined(__BIG_ENDIAN_BITFIELD) | |
106 | __u8 adr : 4; | |
107 | __u8 control : 4; | |
108 | #elif defined(__LITTLE_ENDIAN_BITFIELD) | |
109 | __u8 control : 4; | |
110 | __u8 adr : 4; | |
111 | #else | |
112 | #error "Please fix <asm/byteorder.h>" | |
113 | #endif | |
114 | byte track; | |
115 | byte reserved2; | |
116 | union { | |
117 | unsigned lba; | |
118 | struct atapi_msf msf; | |
119 | } addr; | |
120 | }; | |
121 | ||
122 | struct atapi_toc { | |
123 | int last_session_lba; | |
124 | int xa_flag; | |
125 | unsigned long capacity; | |
126 | struct atapi_toc_header hdr; | |
127 | struct atapi_toc_entry ent[MAX_TRACKS+1]; | |
128 | /* One extra for the leadout. */ | |
129 | }; | |
130 | ||
1da177e4 LT |
131 | /* Extra per-device info for cdrom drives. */ |
132 | struct cdrom_info { | |
133 | ide_drive_t *drive; | |
134 | ide_driver_t *driver; | |
135 | struct gendisk *disk; | |
136 | struct kref kref; | |
137 | ||
138 | /* Buffer for table of contents. NULL if we haven't allocated | |
139 | a TOC buffer for this device yet. */ | |
140 | ||
141 | struct atapi_toc *toc; | |
142 | ||
143 | unsigned long sector_buffered; | |
144 | unsigned long nsectors_buffered; | |
145 | unsigned char *buffer; | |
146 | ||
147 | /* The result of the last successful request sense command | |
148 | on this device. */ | |
149 | struct request_sense sense_data; | |
150 | ||
151 | struct request request_sense_request; | |
152 | int dma; | |
1da177e4 LT |
153 | unsigned long last_block; |
154 | unsigned long start_seek; | |
1da177e4 LT |
155 | |
156 | struct ide_cd_config_flags config_flags; | |
157 | struct ide_cd_state_flags state_flags; | |
158 | ||
159 | /* Per-device info needed by cdrom.c generic driver. */ | |
160 | struct cdrom_device_info devinfo; | |
161 | ||
162 | unsigned long write_timeout; | |
163 | }; | |
164 | ||
165 | /**************************************************************************** | |
166 | * Descriptions of ATAPI error codes. | |
167 | */ | |
168 | ||
1da177e4 LT |
169 | /* This stuff should be in cdrom.h, since it is now generic... */ |
170 | ||
171 | /* ATAPI sense keys (from table 140 of ATAPI 2.6) */ | |
172 | #define NO_SENSE 0x00 | |
173 | #define RECOVERED_ERROR 0x01 | |
174 | #define NOT_READY 0x02 | |
175 | #define MEDIUM_ERROR 0x03 | |
176 | #define HARDWARE_ERROR 0x04 | |
177 | #define ILLEGAL_REQUEST 0x05 | |
178 | #define UNIT_ATTENTION 0x06 | |
179 | #define DATA_PROTECT 0x07 | |
180 | #define BLANK_CHECK 0x08 | |
181 | #define ABORTED_COMMAND 0x0b | |
182 | #define MISCOMPARE 0x0e | |
183 | ||
184 | ||
185 | ||
186 | /* This stuff should be in cdrom.h, since it is now generic... */ | |
187 | #if VERBOSE_IDE_CD_ERRORS | |
188 | ||
189 | /* The generic packet command opcodes for CD/DVD Logical Units, | |
190 | * From Table 57 of the SFF8090 Ver. 3 (Mt. Fuji) draft standard. */ | |
191 | static const struct { | |
192 | unsigned short packet_command; | |
193 | const char * const text; | |
194 | } packet_command_texts[] = { | |
195 | { GPCMD_TEST_UNIT_READY, "Test Unit Ready" }, | |
196 | { GPCMD_REQUEST_SENSE, "Request Sense" }, | |
197 | { GPCMD_FORMAT_UNIT, "Format Unit" }, | |
198 | { GPCMD_INQUIRY, "Inquiry" }, | |
199 | { GPCMD_START_STOP_UNIT, "Start/Stop Unit" }, | |
200 | { GPCMD_PREVENT_ALLOW_MEDIUM_REMOVAL, "Prevent/Allow Medium Removal" }, | |
201 | { GPCMD_READ_FORMAT_CAPACITIES, "Read Format Capacities" }, | |
202 | { GPCMD_READ_CDVD_CAPACITY, "Read Cd/Dvd Capacity" }, | |
203 | { GPCMD_READ_10, "Read 10" }, | |
204 | { GPCMD_WRITE_10, "Write 10" }, | |
205 | { GPCMD_SEEK, "Seek" }, | |
206 | { GPCMD_WRITE_AND_VERIFY_10, "Write and Verify 10" }, | |
207 | { GPCMD_VERIFY_10, "Verify 10" }, | |
208 | { GPCMD_FLUSH_CACHE, "Flush Cache" }, | |
209 | { GPCMD_READ_SUBCHANNEL, "Read Subchannel" }, | |
210 | { GPCMD_READ_TOC_PMA_ATIP, "Read Table of Contents" }, | |
211 | { GPCMD_READ_HEADER, "Read Header" }, | |
212 | { GPCMD_PLAY_AUDIO_10, "Play Audio 10" }, | |
213 | { GPCMD_GET_CONFIGURATION, "Get Configuration" }, | |
214 | { GPCMD_PLAY_AUDIO_MSF, "Play Audio MSF" }, | |
215 | { GPCMD_PLAYAUDIO_TI, "Play Audio TrackIndex" }, | |
216 | { GPCMD_GET_EVENT_STATUS_NOTIFICATION, "Get Event Status Notification" }, | |
217 | { GPCMD_PAUSE_RESUME, "Pause/Resume" }, | |
218 | { GPCMD_STOP_PLAY_SCAN, "Stop Play/Scan" }, | |
219 | { GPCMD_READ_DISC_INFO, "Read Disc Info" }, | |
220 | { GPCMD_READ_TRACK_RZONE_INFO, "Read Track Rzone Info" }, | |
221 | { GPCMD_RESERVE_RZONE_TRACK, "Reserve Rzone Track" }, | |
222 | { GPCMD_SEND_OPC, "Send OPC" }, | |
223 | { GPCMD_MODE_SELECT_10, "Mode Select 10" }, | |
224 | { GPCMD_REPAIR_RZONE_TRACK, "Repair Rzone Track" }, | |
225 | { GPCMD_MODE_SENSE_10, "Mode Sense 10" }, | |
226 | { GPCMD_CLOSE_TRACK, "Close Track" }, | |
227 | { GPCMD_BLANK, "Blank" }, | |
228 | { GPCMD_SEND_EVENT, "Send Event" }, | |
229 | { GPCMD_SEND_KEY, "Send Key" }, | |
230 | { GPCMD_REPORT_KEY, "Report Key" }, | |
231 | { GPCMD_LOAD_UNLOAD, "Load/Unload" }, | |
232 | { GPCMD_SET_READ_AHEAD, "Set Read-ahead" }, | |
233 | { GPCMD_READ_12, "Read 12" }, | |
234 | { GPCMD_GET_PERFORMANCE, "Get Performance" }, | |
235 | { GPCMD_SEND_DVD_STRUCTURE, "Send DVD Structure" }, | |
236 | { GPCMD_READ_DVD_STRUCTURE, "Read DVD Structure" }, | |
237 | { GPCMD_SET_STREAMING, "Set Streaming" }, | |
238 | { GPCMD_READ_CD_MSF, "Read CD MSF" }, | |
239 | { GPCMD_SCAN, "Scan" }, | |
240 | { GPCMD_SET_SPEED, "Set Speed" }, | |
241 | { GPCMD_PLAY_CD, "Play CD" }, | |
242 | { GPCMD_MECHANISM_STATUS, "Mechanism Status" }, | |
243 | { GPCMD_READ_CD, "Read CD" }, | |
244 | }; | |
245 | ||
246 | ||
247 | ||
248 | /* From Table 303 of the SFF8090 Ver. 3 (Mt. Fuji) draft standard. */ | |
249 | static const char * const sense_key_texts[16] = { | |
250 | "No sense data", | |
251 | "Recovered error", | |
252 | "Not ready", | |
253 | "Medium error", | |
254 | "Hardware error", | |
255 | "Illegal request", | |
256 | "Unit attention", | |
257 | "Data protect", | |
258 | "Blank check", | |
259 | "(reserved)", | |
260 | "(reserved)", | |
261 | "Aborted command", | |
262 | "(reserved)", | |
263 | "(reserved)", | |
264 | "Miscompare", | |
265 | "(reserved)", | |
266 | }; | |
267 | ||
268 | /* From Table 304 of the SFF8090 Ver. 3 (Mt. Fuji) draft standard. */ | |
269 | static const struct { | |
270 | unsigned long asc_ascq; | |
271 | const char * const text; | |
272 | } sense_data_texts[] = { | |
273 | { 0x000000, "No additional sense information" }, | |
274 | { 0x000011, "Play operation in progress" }, | |
275 | { 0x000012, "Play operation paused" }, | |
276 | { 0x000013, "Play operation successfully completed" }, | |
277 | { 0x000014, "Play operation stopped due to error" }, | |
278 | { 0x000015, "No current audio status to return" }, | |
279 | { 0x010c0a, "Write error - padding blocks added" }, | |
280 | { 0x011700, "Recovered data with no error correction applied" }, | |
281 | { 0x011701, "Recovered data with retries" }, | |
282 | { 0x011702, "Recovered data with positive head offset" }, | |
283 | { 0x011703, "Recovered data with negative head offset" }, | |
284 | { 0x011704, "Recovered data with retries and/or CIRC applied" }, | |
285 | { 0x011705, "Recovered data using previous sector ID" }, | |
286 | { 0x011800, "Recovered data with error correction applied" }, | |
287 | { 0x011801, "Recovered data with error correction and retries applied"}, | |
288 | { 0x011802, "Recovered data - the data was auto-reallocated" }, | |
289 | { 0x011803, "Recovered data with CIRC" }, | |
290 | { 0x011804, "Recovered data with L-EC" }, | |
291 | { 0x015d00, | |
292 | "Failure prediction threshold exceeded - Predicted logical unit failure" }, | |
293 | { 0x015d01, | |
294 | "Failure prediction threshold exceeded - Predicted media failure" }, | |
295 | { 0x015dff, "Failure prediction threshold exceeded - False" }, | |
296 | { 0x017301, "Power calibration area almost full" }, | |
297 | { 0x020400, "Logical unit not ready - cause not reportable" }, | |
298 | /* Following is misspelled in ATAPI 2.6, _and_ in Mt. Fuji */ | |
299 | { 0x020401, | |
300 | "Logical unit not ready - in progress [sic] of becoming ready" }, | |
301 | { 0x020402, "Logical unit not ready - initializing command required" }, | |
302 | { 0x020403, "Logical unit not ready - manual intervention required" }, | |
303 | { 0x020404, "Logical unit not ready - format in progress" }, | |
304 | { 0x020407, "Logical unit not ready - operation in progress" }, | |
305 | { 0x020408, "Logical unit not ready - long write in progress" }, | |
306 | { 0x020600, "No reference position found (media may be upside down)" }, | |
307 | { 0x023000, "Incompatible medium installed" }, | |
308 | { 0x023a00, "Medium not present" }, | |
309 | { 0x025300, "Media load or eject failed" }, | |
310 | { 0x025700, "Unable to recover table of contents" }, | |
311 | { 0x030300, "Peripheral device write fault" }, | |
312 | { 0x030301, "No write current" }, | |
313 | { 0x030302, "Excessive write errors" }, | |
314 | { 0x030c00, "Write error" }, | |
315 | { 0x030c01, "Write error - Recovered with auto reallocation" }, | |
316 | { 0x030c02, "Write error - auto reallocation failed" }, | |
317 | { 0x030c03, "Write error - recommend reassignment" }, | |
318 | { 0x030c04, "Compression check miscompare error" }, | |
319 | { 0x030c05, "Data expansion occurred during compress" }, | |
320 | { 0x030c06, "Block not compressible" }, | |
321 | { 0x030c07, "Write error - recovery needed" }, | |
322 | { 0x030c08, "Write error - recovery failed" }, | |
323 | { 0x030c09, "Write error - loss of streaming" }, | |
324 | { 0x031100, "Unrecovered read error" }, | |
325 | { 0x031106, "CIRC unrecovered error" }, | |
326 | { 0x033101, "Format command failed" }, | |
327 | { 0x033200, "No defect spare location available" }, | |
328 | { 0x033201, "Defect list update failure" }, | |
329 | { 0x035100, "Erase failure" }, | |
330 | { 0x037200, "Session fixation error" }, | |
331 | { 0x037201, "Session fixation error writin lead-in" }, | |
332 | { 0x037202, "Session fixation error writin lead-out" }, | |
333 | { 0x037300, "CD control error" }, | |
334 | { 0x037302, "Power calibration area is full" }, | |
335 | { 0x037303, "Power calibration area error" }, | |
336 | { 0x037304, "Program memory area / RMA update failure" }, | |
337 | { 0x037305, "Program memory area / RMA is full" }, | |
338 | { 0x037306, "Program memory area / RMA is (almost) full" }, | |
339 | ||
340 | { 0x040200, "No seek complete" }, | |
341 | { 0x040300, "Write fault" }, | |
342 | { 0x040900, "Track following error" }, | |
343 | { 0x040901, "Tracking servo failure" }, | |
344 | { 0x040902, "Focus servo failure" }, | |
345 | { 0x040903, "Spindle servo failure" }, | |
346 | { 0x041500, "Random positioning error" }, | |
347 | { 0x041501, "Mechanical positioning or changer error" }, | |
348 | { 0x041502, "Positioning error detected by read of medium" }, | |
349 | { 0x043c00, "Mechanical positioning or changer error" }, | |
350 | { 0x044000, "Diagnostic failure on component (ASCQ)" }, | |
351 | { 0x044400, "Internal CD/DVD logical unit failure" }, | |
352 | { 0x04b600, "Media load mechanism failed" }, | |
353 | { 0x051a00, "Parameter list length error" }, | |
354 | { 0x052000, "Invalid command operation code" }, | |
355 | { 0x052100, "Logical block address out of range" }, | |
356 | { 0x052102, "Invalid address for write" }, | |
357 | { 0x052400, "Invalid field in command packet" }, | |
358 | { 0x052600, "Invalid field in parameter list" }, | |
359 | { 0x052601, "Parameter not supported" }, | |
360 | { 0x052602, "Parameter value invalid" }, | |
361 | { 0x052700, "Write protected media" }, | |
362 | { 0x052c00, "Command sequence error" }, | |
363 | { 0x052c03, "Current program area is not empty" }, | |
364 | { 0x052c04, "Current program area is empty" }, | |
365 | { 0x053001, "Cannot read medium - unknown format" }, | |
366 | { 0x053002, "Cannot read medium - incompatible format" }, | |
367 | { 0x053900, "Saving parameters not supported" }, | |
368 | { 0x054e00, "Overlapped commands attempted" }, | |
369 | { 0x055302, "Medium removal prevented" }, | |
370 | { 0x055500, "System resource failure" }, | |
371 | { 0x056300, "End of user area encountered on this track" }, | |
372 | { 0x056400, "Illegal mode for this track or incompatible medium" }, | |
373 | { 0x056f00, "Copy protection key exchange failure - Authentication failure" }, | |
374 | { 0x056f01, "Copy protection key exchange failure - Key not present" }, | |
375 | { 0x056f02, "Copy protection key exchange failure - Key not established" }, | |
376 | { 0x056f03, "Read of scrambled sector without authentication" }, | |
377 | { 0x056f04, "Media region code is mismatched to logical unit" }, | |
378 | { 0x056f05, "Drive region must be permanent / region reset count error" }, | |
379 | { 0x057203, "Session fixation error - incomplete track in session" }, | |
380 | { 0x057204, "Empty or partially written reserved track" }, | |
381 | { 0x057205, "No more RZONE reservations are allowed" }, | |
382 | { 0x05bf00, "Loss of streaming" }, | |
383 | { 0x062800, "Not ready to ready transition, medium may have changed" }, | |
384 | { 0x062900, "Power on, reset or hardware reset occurred" }, | |
385 | { 0x062a00, "Parameters changed" }, | |
386 | { 0x062a01, "Mode parameters changed" }, | |
387 | { 0x062e00, "Insufficient time for operation" }, | |
388 | { 0x063f00, "Logical unit operating conditions have changed" }, | |
389 | { 0x063f01, "Microcode has been changed" }, | |
390 | { 0x065a00, "Operator request or state change input (unspecified)" }, | |
391 | { 0x065a01, "Operator medium removal request" }, | |
392 | { 0x0bb900, "Play operation aborted" }, | |
393 | ||
394 | /* Here we use 0xff for the key (not a valid key) to signify | |
395 | * that these can have _any_ key value associated with them... */ | |
396 | { 0xff0401, "Logical unit is in process of becoming ready" }, | |
397 | { 0xff0400, "Logical unit not ready, cause not reportable" }, | |
398 | { 0xff0402, "Logical unit not ready, initializing command required" }, | |
399 | { 0xff0403, "Logical unit not ready, manual intervention required" }, | |
400 | { 0xff0500, "Logical unit does not respond to selection" }, | |
401 | { 0xff0800, "Logical unit communication failure" }, | |
402 | { 0xff0802, "Logical unit communication parity error" }, | |
403 | { 0xff0801, "Logical unit communication time-out" }, | |
404 | { 0xff2500, "Logical unit not supported" }, | |
405 | { 0xff4c00, "Logical unit failed self-configuration" }, | |
406 | { 0xff3e00, "Logical unit has not self-configured yet" }, | |
407 | }; | |
408 | #endif | |
409 | ||
410 | ||
411 | #endif /* _IDE_CD_H */ |