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