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