ide-cd.h 14 KB

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