constants.c
上传用户:lgb322
上传日期:2013-02-24
资源大小:30529k
文件大小:45k
源码类别:

嵌入式Linux

开发平台:

Unix_Linux

  1. /* 
  2.  * ASCII values for a number of symbolic constants, printing functions,
  3.  * etc.
  4.  * Additions for SCSI 2 and Linux 2.2.x by D. Gilbert (990422)
  5.  *
  6.  */
  7. #define __NO_VERSION__
  8. #include <linux/module.h>
  9. #include <linux/config.h>
  10. #include <linux/blk.h>
  11. #include <linux/kernel.h>
  12. #include "scsi.h"
  13. #include "hosts.h"
  14. #define CONST_COMMAND   0x01
  15. #define CONST_STATUS    0x02
  16. #define CONST_SENSE     0x04
  17. #define CONST_XSENSE    0x08
  18. #define CONST_CMND      0x10
  19. #define CONST_MSG       0x20
  20. #define CONST_HOST 0x40
  21. #define CONST_DRIVER 0x80
  22. static const char unknown[] = "UNKNOWN";
  23. #ifdef CONFIG_SCSI_CONSTANTS
  24. #ifdef CONSTANTS
  25. #undef CONSTANTS
  26. #endif
  27. #define CONSTANTS (CONST_COMMAND | CONST_STATUS | CONST_SENSE | CONST_XSENSE 
  28.    | CONST_CMND | CONST_MSG | CONST_HOST | CONST_DRIVER)
  29. #endif
  30. #if (CONSTANTS & CONST_COMMAND)
  31. static const char * group_0_commands[] = {
  32. /* 00-03 */ "Test Unit Ready", "Rezero Unit", unknown, "Request Sense",
  33. /* 04-07 */ "Format Unit", "Read Block Limits", unknown, "Reasssign Blocks",
  34. /* 08-0d */ "Read (6)", unknown, "Write (6)", "Seek (6)", unknown, unknown,
  35. /* 0e-12 */ unknown, "Read Reverse", "Write Filemarks", "Space", "Inquiry",  
  36. /* 13-16 */ "Verify", "Recover Buffered Data", "Mode Select", "Reserve",
  37. /* 17-1b */ "Release", "Copy", "Erase", "Mode Sense", "Start/Stop Unit",
  38. /* 1c-1d */ "Receive Diagnostic", "Send Diagnostic", 
  39. /* 1e-1f */ "Prevent/Allow Medium Removal", unknown,
  40. };
  41. static const char *group_1_commands[] = {
  42. /* 20-22 */  unknown, unknown, unknown,
  43. /* 23-28 */ unknown, "Define window parameters", "Read Capacity", 
  44.             unknown, unknown, "Read (10)", 
  45. /* 29-2d */ "Read Generation", "Write (10)", "Seek (10)", "Erase", 
  46.             "Read updated block", 
  47. /* 2e-31 */ "Write Verify","Verify", "Search High", "Search Equal", 
  48. /* 32-34 */ "Search Low", "Set Limits", "Prefetch or Read Position", 
  49. /* 35-37 */ "Synchronize Cache","Lock/Unlock Cache", "Read Defect Data", 
  50. /* 38-3c */ "Medium Scan", "Compare", "Copy Verify", "Write Buffer", 
  51.             "Read Buffer", 
  52. /* 3d-3f */ "Update Block", "Read Long",  "Write Long",
  53. };
  54. static const char *group_2_commands[] = {
  55. /* 40-41 */ "Change Definition", "Write Same", 
  56. /* 42-48 */ "Read sub-channel", "Read TOC", "Read header", 
  57.             "Play audio (10)", unknown, "Play audio msf",
  58.             "Play audio track/index", 
  59. /* 49-4f */ "Play track relative (10)", unknown, "Pause/resume", 
  60.             "Log Select", "Log Sense", unknown, unknown,
  61. /* 50-55 */ unknown, unknown, unknown, unknown, unknown, "Mode Select (10)",
  62. /* 56-5b */ unknown, unknown, unknown, unknown, "Mode Sense (10)", unknown,
  63. /* 5c-5f */ unknown, unknown, unknown,
  64. };
  65. /* The following are 16 byte commands in group 4 */
  66. static const char *group_4_commands[] = {
  67. /* 80-84 */ unknown, unknown, unknown, unknown, unknown,
  68. /* 85-89 */ "Memory Export In (16)", unknown, unknown, unknown,
  69.             "Memory Export Out (16)",
  70. /* 8a-8f */ unknown, unknown, unknown, unknown, unknown, unknown,
  71. /* 90-94 */ unknown, unknown, unknown, unknown, unknown,
  72. /* 95-99 */ unknown, unknown, unknown, unknown, unknown,
  73. /* 9a-9f */ unknown, unknown, unknown, unknown, unknown, unknown,
  74. };
  75. /* The following are 12 byte commands in group 5 */
  76. static const char *group_5_commands[] = {
  77. /* a0-a5 */ unknown, unknown, unknown, unknown, unknown,
  78.             "Move medium/play audio(12)",
  79. /* a6-a9 */ "Exchange medium", unknown, "Read(12)", "Play track relative(12)", 
  80. /* aa-ae */ "Write(12)", unknown, "Erase(12)", unknown, 
  81.             "Write and verify(12)", 
  82. /* af-b1 */ "Verify(12)", "Search data high(12)", "Search data equal(12)",
  83. /* b2-b4 */ "Search data low(12)", "Set limits(12)", unknown,
  84. /* b5-b6 */ "Request volume element address", "Send volume tag",
  85. /* b7-b9 */ "Read defect data(12)", "Read element status", unknown,
  86. /* ba-bf */ unknown, unknown, unknown, unknown, unknown, unknown,
  87. };
  88. #define group(opcode) (((opcode) >> 5) & 7)
  89. #define RESERVED_GROUP  0
  90. #define VENDOR_GROUP    1
  91. static const char **commands[] = {
  92.     group_0_commands, group_1_commands, group_2_commands, 
  93.     (const char **) RESERVED_GROUP, group_4_commands, 
  94.     group_5_commands, (const char **) VENDOR_GROUP, 
  95.     (const char **) VENDOR_GROUP
  96. };
  97. static const char reserved[] = "RESERVED";
  98. static const char vendor[] = "VENDOR SPECIFIC";
  99. static void print_opcode(int opcode) {
  100.     const char **table = commands[ group(opcode) ];
  101.     switch ((unsigned long) table) {
  102.     case RESERVED_GROUP:
  103. printk("%s(0x%02x) ", reserved, opcode); 
  104. break;
  105.     case VENDOR_GROUP:
  106. printk("%s(0x%02x) ", vendor, opcode); 
  107. break;
  108.     default:
  109. if (table[opcode & 0x1f] != unknown)
  110.     printk("%s ",table[opcode & 0x1f]);
  111. else
  112.     printk("%s(0x%02x) ", unknown, opcode);
  113. break;
  114.     }
  115. }
  116. #else /* CONST & CONST_COMMAND */
  117. static void print_opcode(int opcode) {
  118.     printk("0x%02x ", opcode);
  119. }
  120. #endif  
  121. void print_command (unsigned char *command) {
  122.     int i,s;
  123.     print_opcode(command[0]);
  124.     for ( i = 1, s = COMMAND_SIZE(command[0]); i < s; ++i) 
  125. printk("%02x ", command[i]);
  126.     printk("n");
  127. }
  128. #if (CONSTANTS & CONST_STATUS)
  129. static const char * statuses[] = {
  130. /* 0-4 */ "Good", "Check Condition", "Condition Met", unknown, "Busy", 
  131. /* 5-9 */ unknown, unknown, unknown, "Intermediate", unknown, 
  132. /* a-c */ "Intermediate-Condition Met", unknown, "Reservation Conflict",
  133. /* d-10 */ unknown, unknown, unknown, unknown,
  134. /* 11-14 */ "Command Terminated", unknown, unknown, "Queue Full",
  135. /* 15-1a */ unknown, unknown, unknown, unknown, unknown, unknown,
  136. /* 1b-1f */ unknown, unknown, unknown, unknown, unknown,
  137. };
  138. #endif
  139. void print_status (int status) {
  140.     status = (status >> 1) & 0x1f;
  141. #if (CONSTANTS & CONST_STATUS)
  142.     printk("%s ",statuses[status]);
  143. #else
  144.     printk("0x%0x ", status); 
  145. #endif 
  146. }
  147. #if (CONSTANTS & CONST_XSENSE)
  148. #define D 0x0001  /* DIRECT ACCESS DEVICE (disk) */
  149. #define T 0x0002  /* SEQUENTIAL ACCESS DEVICE (tape) */
  150. #define L 0x0004  /* PRINTER DEVICE */
  151. #define P 0x0008  /* PROCESSOR DEVICE */
  152. #define W 0x0010  /* WRITE ONCE READ MULTIPLE DEVICE */
  153. #define R 0x0020  /* READ ONLY (CD-ROM) DEVICE */
  154. #define S 0x0040  /* SCANNER DEVICE */
  155. #define O 0x0080  /* OPTICAL MEMORY DEVICE */
  156. #define M 0x0100  /* MEDIA CHANGER DEVICE */
  157. #define C 0x0200  /* COMMUNICATION DEVICE */
  158. #define A 0x0400  /* ARRAY STORAGE */
  159. #define E 0x0800  /* ENCLOSURE SERVICES DEVICE */
  160. #define B 0x1000  /* SIMPLIFIED DIRECT ACCESS DEVICE */
  161. #define K 0x2000  /* OPTICAL CARD READER/WRITER DEVICE */
  162. struct error_info{
  163.     unsigned char code1, code2;
  164.     unsigned short int devices;
  165.     const char * text;
  166. };
  167. struct error_info2{
  168.     unsigned char code1, code2_min, code2_max;
  169.     unsigned short int devices;
  170.     const char * text;
  171. };
  172. static struct error_info2 additional2[] =
  173. {
  174.   {0x40,0x00,0x7f,D,"Ram failure (%x)"},
  175.   {0x40,0x80,0xff,D|T|L|P|W|R|S|O|M|C,"Diagnostic failure on component (%x)"},
  176.   {0x41,0x00,0xff,D,"Data path failure (%x)"},
  177.   {0x42,0x00,0xff,D,"Power-on or self-test failure (%x)"},
  178.   {0, 0, 0, 0, NULL}
  179. };
  180. static struct error_info additional[] =
  181. {
  182.   {0x00,0x00,D|T|L|P|W|R|S|O|M|C|A|E|B|K,"No additional sense information"},
  183.   {0x00,0x01,T,"Filemark detected"},
  184.   {0x00,0x02,T|S,"End-of-partition/medium detected"},
  185.   {0x00,0x03,T,"Setmark detected"},
  186.   {0x00,0x04,T|S,"Beginning-of-partition/medium detected"},
  187.   {0x00,0x05,T|L|S,"End-of-data detected"},
  188.   {0x00,0x06,D|T|L|P|W|R|S|O|M|C|A|E|B|K,"I/O process terminated"},
  189.   {0x00,0x11,R,"Audio play operation in progress"},
  190.   {0x00,0x12,R,"Audio play operation paused"},
  191.   {0x00,0x13,R,"Audio play operation successfully completed"},
  192.   {0x00,0x14,R,"Audio play operation stopped due to error"},
  193.   {0x00,0x15,R,"No current audio status to return"},
  194.   {0x00,0x16,D|T|L|P|W|R|S|O|M|C|A|E|B|K,"Operation in progress"},
  195.   {0x00,0x17,D|T|L|W|R|S|O|M|A|E|B|K,"Cleaning requested"},
  196.   {0x01,0x00,D|W|O|B|K,"No index/sector signal"},
  197.   {0x02,0x00,D|W|R|O|M|B|K,"No seek complete"},
  198.   {0x03,0x00,D|T|L|W|S|O|B|K,"Peripheral device write fault"},
  199.   {0x03,0x01,T,"No write current"},
  200.   {0x03,0x02,T,"Excessive write errors"},
  201.   {0x04,0x00,D|T|L|P|W|R|S|O|M|C|A|E|B|K,"Logical unit not ready,cause not reportable"},
  202.   {0x04,0x01,D|T|L|P|W|R|S|O|M|C|A|E|B|K,"Logical unit is in process of becoming ready"},
  203.   {0x04,0x02,D|T|L|P|W|R|S|O|M|C|A|E|B|K,"Logical unit not ready,initializing cmd. required"},
  204.   {0x04,0x03,D|T|L|P|W|R|S|O|M|C|A|E|B|K,"Logical unit not ready,manual intervention required"},
  205.   {0x04,0x04,D|T|L|R|O|B,"Logical unit not ready,format in progress"},
  206.   {0x04,0x05,D|T|W|O|M|C|A|B|K,"Logical unit not ready,rebuild in progress"},
  207.   {0x04,0x06,D|T|W|O|M|C|A|B|K,"Logical unit not ready,recalculation in progress"},
  208.   {0x04,0x07,D|T|L|P|W|R|S|O|M|C|A|E|B|K,"Logical unit not ready,operation in progress"},
  209.   {0x04,0x08,R,"Logical unit not ready,long write in progress"},
  210.   {0x04,0x09,D|T|L|P|W|R|S|O|M|C|A|E|B|K,"Logical unit not ready,self-test in progress"},
  211.   {0x05,0x00,D|T|L|W|R|S|O|M|C|A|E|B|K,"Logical unit does not respond to selection"},
  212.   {0x06,0x00,D|W|R|O|M|B|K,"No reference position found"},
  213.   {0x07,0x00,D|T|L|W|R|S|O|M|B|K,"Multiple peripheral devices selected"},
  214.   {0x08,0x00,D|T|L|W|R|S|O|M|C|A|E|B|K,"Logical unit communication failure"},
  215.   {0x08,0x01,D|T|L|W|R|S|O|M|C|A|E|B|K,"Logical unit communication time-out"},
  216.   {0x08,0x02,D|T|L|W|R|S|O|M|C|A|E|B|K,"Logical unit communication parity error"},
  217.   {0x08,0x03,D|T|R|O|M|B|K,"Logical unit communication CRC error (Ultra-DMA/32)"},
  218.   {0x08,0x04,D|T|L|P|W|R|S|O|C|K,"Unreachable copy target"},
  219.   {0x09,0x00,D|T|W|R|O|B,"Track following error"},
  220.   {0x09,0x01,W|R|O|K,"Tracking servo failure"},
  221.   {0x09,0x02,W|R|O|K,"Focus servo failure"},
  222.   {0x09,0x03,W|R|O,"Spindle servo failure"},
  223.   {0x09,0x04,D|T|W|R|O|B,"Head select fault"},
  224.   {0x0A,0x00,D|T|L|P|W|R|S|O|M|C|A|E|B|K,"Error log overflow"},
  225.   {0x0B,0x00,D|T|L|P|W|R|S|O|M|C|A|E|B|K,"Warning"},
  226.   {0x0B,0x01,D|T|L|P|W|R|S|O|M|C|A|E|B|K,"Warning - specified temperature exceeded"},
  227.   {0x0B,0x02,D|T|L|P|W|R|S|O|M|C|A|E|B|K,"Warning - enclosure degraded"},
  228.   {0x0C,0x00,T|R|S,"Write error"},
  229.   {0x0C,0x01,K,"Write error - recovered with auto reallocation"},
  230.   {0x0C,0x02,D|W|O|B|K,"Write error - auto reallocation failed"},
  231.   {0x0C,0x03,D|W|O|B|K,"Write error - recommend reassignment"},
  232.   {0x0C,0x04,D|T|W|O|B,"Compression check miscompare error"},
  233.   {0x0C,0x05,D|T|W|O|B,"Data expansion occurred during compression"},
  234.   {0x0C,0x06,D|T|W|O|B,"Block not compressible"},
  235.   {0x0C,0x07,R,"Write error - recovery needed"},
  236.   {0x0C,0x08,R,"Write error - recovery failed"},
  237.   {0x0C,0x09,R,"Write error - loss of streaming"},
  238.   {0x0C,0x0A,R,"Write error - padding blocks added"},
  239.   {0x10,0x00,D|W|O|B|K,"Id CRC or ECC error"},
  240.   {0x11,0x00,D|T|W|R|S|O|B|K,"Unrecovered read error"},
  241.   {0x11,0x01,D|T|W|R|S|O|B|K,"Read retries exhausted"},
  242.   {0x11,0x02,D|T|W|R|S|O|B|K,"Error too long to correct"},
  243.   {0x11,0x03,D|T|W|S|O|B|K,"Multiple read errors"},
  244.   {0x11,0x04,D|W|O|B|K,"Unrecovered read error - auto reallocate failed"},
  245.   {0x11,0x05,W|R|O|B,"L-EC uncorrectable error"},
  246.   {0x11,0x06,W|R|O|B,"CIRC unrecovered error"},
  247.   {0x11,0x07,W|O|B,"Data re-synchronization error"},
  248.   {0x11,0x08,T,"Incomplete block read"},
  249.   {0x11,0x09,T,"No gap found"},
  250.   {0x11,0x0A,D|T|O|B|K,"Miscorrected error"},
  251.   {0x11,0x0B,D|W|O|B|K,"Unrecovered read error - recommend reassignment"},
  252.   {0x11,0x0C,D|W|O|B|K,"Unrecovered read error - recommend rewrite the data"},
  253.   {0x11,0x0D,D|T|W|R|O|B,"De-compression CRC error"},
  254.   {0x11,0x0E,D|T|W|R|O|B,"Cannot decompress using declared algorithm"},
  255.   {0x11,0x0F,R,"Error reading UPC/EAN number"},
  256.   {0x11,0x10,R,"Error reading ISRC number"},
  257.   {0x11,0x11,R,"Read error - loss of streaming"},
  258.   {0x12,0x00,D|W|O|B|K,"Address mark not found for id field"},
  259.   {0x13,0x00,D|W|O|B|K,"Address mark not found for data field"},
  260.   {0x14,0x00,D|T|L|W|R|S|O|B|K,"Recorded entity not found"},
  261.   {0x14,0x01,D|T|W|R|O|B|K,"Record not found"},
  262.   {0x14,0x02,T,"Filemark or setmark not found"},
  263.   {0x14,0x03,T,"End-of-data not found"},
  264.   {0x14,0x04,T,"Block sequence error"},
  265.   {0x14,0x05,D|T|W|O|B|K,"Record not found - recommend reassignment"},
  266.   {0x14,0x06,D|T|W|O|B|K,"Record not found - data auto-reallocated"},
  267.   {0x15,0x00,D|T|L|W|R|S|O|M|B|K,"Random positioning error"},
  268.   {0x15,0x01,D|T|L|W|R|S|O|M|B|K,"Mechanical positioning error"},
  269.   {0x15,0x02,D|T|W|R|O|B|K,"Positioning error detected by read of medium"},
  270.   {0x16,0x00,D|W|O|B|K,"Data synchronization mark error"},
  271.   {0x16,0x01,D|W|O|B|K,"Data sync error - data rewritten"},
  272.   {0x16,0x02,D|W|O|B|K,"Data sync error - recommend rewrite"},
  273.   {0x16,0x03,D|W|O|B|K,"Data sync error - data auto-reallocated"},
  274.   {0x16,0x04,D|W|O|B|K,"Data sync error - recommend reassignment"},
  275.   {0x17,0x00,D|T|W|R|S|O|B|K,"Recovered data with no error correction applied"},
  276.   {0x17,0x01,D|T|W|R|S|O|B|K,"Recovered data with retries"},
  277.   {0x17,0x02,D|T|W|R|O|B|K,"Recovered data with positive head offset"},
  278.   {0x17,0x03,D|T|W|R|O|B|K,"Recovered data with negative head offset"},
  279.   {0x17,0x04,W|R|O|B,"Recovered data with retries and/or circ applied"},
  280.   {0x17,0x05,D|W|R|O|B|K,"Recovered data using previous sector id"},
  281.   {0x17,0x06,D|W|O|B|K,"Recovered data without ecc - data auto-reallocated"},
  282.   {0x17,0x07,D|W|R|O|B|K,"Recovered data without ecc - recommend reassignment"},
  283.   {0x17,0x08,D|W|R|O|B|K,"Recovered data without ecc - recommend rewrite"},
  284.   {0x17,0x09,D|W|R|O|B|K,"Recovered data without ecc - data rewritten"},
  285.   {0x18,0x00,D|T|W|R|O|B|K,"Recovered data with error correction applied"},
  286.   {0x18,0x01,D|W|R|O|B|K,"Recovered data with error corr. & retries applied"},
  287.   {0x18,0x02,D|W|R|O|B|K,"Recovered data - data auto-reallocated"},
  288.   {0x18,0x03,R,"Recovered data with CIRC"},
  289.   {0x18,0x04,R,"Recovered data with L-EC"},
  290.   {0x18,0x05,D|W|R|O|B|K,"Recovered data - recommend reassignment"},
  291.   {0x18,0x06,D|W|R|O|B|K,"Recovered data - recommend rewrite"},
  292.   {0x18,0x07,D|W|O|B|K,"Recovered data with ecc - data rewritten"},
  293.   {0x19,0x00,D|O|K,"Defect list error"},
  294.   {0x19,0x01,D|O|K,"Defect list not available"},
  295.   {0x19,0x02,D|O|K,"Defect list error in primary list"},
  296.   {0x19,0x03,D|O|K,"Defect list error in grown list"},
  297.   {0x1A,0x00,D|T|L|P|W|R|S|O|M|C|A|E|B|K,"Parameter list length error"},
  298.   {0x1B,0x00,D|T|L|P|W|R|S|O|M|C|A|E|B|K,"Synchronous data transfer error"},
  299.   {0x1C,0x00,D|O|B|K,"Defect list not found"},
  300.   {0x1C,0x01,D|O|B|K,"Primary defect list not found"},
  301.   {0x1C,0x02,D|O|B|K,"Grown defect list not found"},
  302.   {0x1D,0x00,D|T|W|R|O|B|K,"Miscompare during verify operation"},
  303.   {0x1E,0x00,D|W|O|B|K,"Recovered id with ecc correction"},
  304.   {0x1F,0x00,D|O|K,"Partial defect list transfer"},
  305.   {0x20,0x00,D|T|L|P|W|R|S|O|M|C|A|E|B|K,"Invalid command operation code"},
  306.   {0x21,0x00,D|T|W|R|O|M|B|K,"Logical block address out of range"},
  307.   {0x21,0x01,D|T|W|R|O|M|B|K,"Invalid element address"},
  308.   {0x22,0x00,D,"Illegal function (use 20 00,24 00,or 26 00)"},
  309.   {0x24,0x00,D|T|L|P|W|R|S|O|M|C|A|E|B|K,"Invalid field in cdb"},
  310.   {0x24,0x01,D|T|L|P|W|R|S|O|M|C|A|E|B|K,"CDB decryption error"},
  311.   {0x25,0x00,D|T|L|P|W|R|S|O|M|C|A|E|B|K,"Logical unit not supported"},
  312.   {0x26,0x00,D|T|L|P|W|R|S|O|M|C|A|E|B|K,"Invalid field in parameter list"},
  313.   {0x26,0x01,D|T|L|P|W|R|S|O|M|C|A|E|B|K,"Parameter not supported"},
  314.   {0x26,0x02,D|T|L|P|W|R|S|O|M|C|A|E|B|K,"Parameter value invalid"},
  315.   {0x26,0x03,D|T|L|P|W|R|S|O|M|C|A|E|K,"Threshold parameters not supported"},
  316.   {0x26,0x04,D|T|L|P|W|R|S|O|M|C|A|E|B|K,"Invalid release of persistent reservation"},
  317.   {0x26,0x05,D|T|L|P|W|R|S|O|M|C|A|B|K,"Data decryption error"},
  318.   {0x26,0x06,D|T|L|P|W|R|S|O|C|K,"Too many target descriptors"},
  319.   {0x26,0x07,D|T|L|P|W|R|S|O|C|K,"Unsupported target descriptor type code"},
  320.   {0x26,0x08,D|T|L|P|W|R|S|O|C|K,"Too many segment descriptors"},
  321.   {0x26,0x09,D|T|L|P|W|R|S|O|C|K,"Unsupported segment descriptor type code"},
  322.   {0x26,0x0A,D|T|L|P|W|R|S|O|C|K,"Unexpected inexact segment"},
  323.   {0x26,0x0B,D|T|L|P|W|R|S|O|C|K,"Inline data length exceeded"},
  324.   {0x26,0x0C,D|T|L|P|W|R|S|O|C|K,"Invalid operation for copy source or destination"},
  325.   {0x26,0x0D,D|T|L|P|W|R|S|O|C|K,"Copy segment granularity violation"},
  326.   {0x27,0x00,D|T|W|R|O|B|K,"Write protected"},
  327.   {0x27,0x01,D|T|W|R|O|B|K,"Hardware write protected"},
  328.   {0x27,0x02,D|T|W|R|O|B|K,"Logical unit software write protected"},
  329.   {0x27,0x03,T|R,"Associated write protect"},
  330.   {0x27,0x04,T|R,"Persistent write protect"},
  331.   {0x27,0x05,T|R,"Permanent write protect"},
  332.   {0x28,0x00,D|T|L|P|W|R|S|O|M|C|A|E|B|K,"Not ready to ready change,medium may have changed"},
  333.   {0x28,0x01,D|T|W|R|O|M|B,"Import or export element accessed"},
  334.   {0x29,0x00,D|T|L|P|W|R|S|O|M|C|A|E|B|K,"Power on,reset,or bus device reset occurred"},
  335.   {0x29,0x01,D|T|L|P|W|R|S|O|M|C|A|E|B|K,"Power on occurred"},
  336.   {0x29,0x02,D|T|L|P|W|R|S|O|M|C|A|E|B|K,"Scsi bus reset occurred"},
  337.   {0x29,0x03,D|T|L|P|W|R|S|O|M|C|A|E|B|K,"Bus device reset function occurred"},
  338.   {0x29,0x04,D|T|L|P|W|R|S|O|M|C|A|E|B|K,"Device internal reset"},
  339.   {0x29,0x05,D|T|L|P|W|R|S|O|M|C|A|E|B|K,"Transceiver mode changed to single-ended"},
  340.   {0x29,0x06,D|T|L|P|W|R|S|O|M|C|A|E|B|K,"Transceiver mode changed to lvd"},
  341.   {0x2A,0x00,D|T|L|W|R|S|O|M|C|A|E|B|K,"Parameters changed"},
  342.   {0x2A,0x01,D|T|L|W|R|S|O|M|C|A|E|B|K,"Mode parameters changed"},
  343.   {0x2A,0x02,D|T|L|W|R|S|O|M|C|A|E|K,"Log parameters changed"},
  344.   {0x2A,0x03,D|T|L|P|W|R|S|O|M|C|A|E|K,"Reservations preempted"},
  345.   {0x2A,0x04,D|T|L|P|W|R|S|O|M|C|A|E,"Reservations released"},
  346.   {0x2A,0x05,D|T|L|P|W|R|S|O|M|C|A|E,"Registrations preempted"},
  347.   {0x2B,0x00,D|T|L|P|W|R|S|O|C|K,"Copy cannot execute since host cannot disconnect"},
  348.   {0x2C,0x00,D|T|L|P|W|R|S|O|M|C|A|E|B|K,"Command sequence error"},
  349.   {0x2C,0x01,S,"Too many windows specified"},
  350.   {0x2C,0x02,S,"Invalid combination of windows specified"},
  351.   {0x2C,0x03,R,"Current program area is not empty"},
  352.   {0x2C,0x04,R,"Current program area is empty"},
  353.   {0x2C,0x05,B,"Illegal power condition request"},
  354.   {0x2D,0x00,T,"Overwrite error on update in place"},
  355.   {0x2F,0x00,D|T|L|P|W|R|S|O|M|C|A|E|B|K,"Commands cleared by another initiator"},
  356.   {0x30,0x00,D|T|W|R|O|M|B|K,"Incompatible medium installed"},
  357.   {0x30,0x01,D|T|W|R|O|B|K,"Cannot read medium - unknown format"},
  358.   {0x30,0x02,D|T|W|R|O|B|K,"Cannot read medium - incompatible format"},
  359.   {0x30,0x03,D|T|R|K,"Cleaning cartridge installed"},
  360.   {0x30,0x04,D|T|W|R|O|B|K,"Cannot write medium - unknown format"},
  361.   {0x30,0x05,D|T|W|R|O|B|K,"Cannot write medium - incompatible format"},
  362.   {0x30,0x06,D|T|W|R|O|B,"Cannot format medium - incompatible medium"},
  363.   {0x30,0x07,D|T|L|W|R|S|O|M|A|E|B|K,"Cleaning failure"},
  364.   {0x30,0x08,R,"Cannot write - application code mismatch"},
  365.   {0x30,0x09,R,"Current session not fixated for append"},
  366.   {0x31,0x00,D|T|W|R|O|B|K,"Medium format corrupted"},
  367.   {0x31,0x01,D|L|R|O|B,"Format command failed"},
  368.   {0x32,0x00,D|W|O|B|K,"No defect spare location available"},
  369.   {0x32,0x01,D|W|O|B|K,"Defect list update failure"},
  370.   {0x33,0x00,T,"Tape length error"},
  371.   {0x34,0x00,D|T|L|P|W|R|S|O|M|C|A|E|B|K,"Enclosure failure"},
  372.   {0x35,0x00,D|T|L|P|W|R|S|O|M|C|A|E|B|K,"Enclosure services failure"},
  373.   {0x35,0x01,D|T|L|P|W|R|S|O|M|C|A|E|B|K,"Unsupported enclosure function"},
  374.   {0x35,0x02,D|T|L|P|W|R|S|O|M|C|A|E|B|K,"Enclosure services unavailable"},
  375.   {0x35,0x03,D|T|L|P|W|R|S|O|M|C|A|E|B|K,"Enclosure services transfer failure"},
  376.   {0x35,0x04,D|T|L|P|W|R|S|O|M|C|A|E|B|K,"Enclosure services transfer refused"},
  377.   {0x36,0x00,L,"Ribbon,ink,or toner failure"},
  378.   {0x37,0x00,D|T|L|W|R|S|O|M|C|A|E|B|K,"Rounded parameter"},
  379.   {0x38,0x00,B,"Event status notification"},
  380.   {0x38,0x02,B,"Esn - power management class event"},
  381.   {0x38,0x04,B,"Esn - media class event"},
  382.   {0x38,0x06,B,"Esn - device busy class event"},
  383.   {0x39,0x00,D|T|L|W|R|S|O|M|C|A|E|K,"Saving parameters not supported"},
  384.   {0x3A,0x00,D|T|L|W|R|S|O|M|B|K,"Medium not present"},
  385.   {0x3A,0x01,D|T|W|R|O|M|B|K,"Medium not present - tray closed"},
  386.   {0x3A,0x02,D|T|W|R|O|M|B|K,"Medium not present - tray open"},
  387.   {0x3A,0x03,D|T|W|R|O|M|B,"Medium not present - loadable"},
  388.   {0x3A,0x04,D|T|W|R|O|M|B,"Medium not present - medium auxiliary memory accessible"},
  389.   {0x3B,0x00,T|L,"Sequential positioning error"},
  390.   {0x3B,0x01,T,"Tape position error at beginning-of-medium"},
  391.   {0x3B,0x02,T,"Tape position error at end-of-medium"},
  392.   {0x3B,0x03,L,"Tape or electronic vertical forms unit not ready"},
  393.   {0x3B,0x04,L,"Slew failure"},
  394.   {0x3B,0x05,L,"Paper jam"},
  395.   {0x3B,0x06,L,"Failed to sense top-of-form"},
  396.   {0x3B,0x07,L,"Failed to sense bottom-of-form"},
  397.   {0x3B,0x08,T,"Reposition error"},
  398.   {0x3B,0x09,S,"Read past end of medium"},
  399.   {0x3B,0x0A,S,"Read past beginning of medium"},
  400.   {0x3B,0x0B,S,"Position past end of medium"},
  401.   {0x3B,0x0C,T|S,"Position past beginning of medium"},
  402.   {0x3B,0x0D,D|T|W|R|O|M|B|K,"Medium destination element full"},
  403.   {0x3B,0x0E,D|T|W|R|O|M|B|K,"Medium source element empty"},
  404.   {0x3B,0x0F,R,"End of medium reached"},
  405.   {0x3B,0x11,D|T|W|R|O|M|B|K,"Medium magazine not accessible"},
  406.   {0x3B,0x12,D|T|W|R|O|M|B|K,"Medium magazine removed"},
  407.   {0x3B,0x13,D|T|W|R|O|M|B|K,"Medium magazine inserted"},
  408.   {0x3B,0x14,D|T|W|R|O|M|B|K,"Medium magazine locked"},
  409.   {0x3B,0x15,D|T|W|R|O|M|B|K,"Medium magazine unlocked"},
  410.   {0x3B,0x16,R,"Mechanical positioning or changer error"},
  411.   {0x3D,0x00,D|T|L|P|W|R|S|O|M|C|A|E|K,"Invalid bits in identify message"},
  412.   {0x3E,0x00,D|T|L|P|W|R|S|O|M|C|A|E|B|K,"Logical unit has not self-configured yet"},
  413.   {0x3E,0x01,D|T|L|P|W|R|S|O|M|C|A|E|B|K,"Logical unit failure"},
  414.   {0x3E,0x02,D|T|L|P|W|R|S|O|M|C|A|E|B|K,"Timeout on logical unit"},
  415.   {0x3E,0x03,D|T|L|P|W|R|S|O|M|C|A|E|B|K,"Logical unit failed self-test"},
  416.   {0x3E,0x04,D|T|L|P|W|R|S|O|M|C|A|E|B|K,"Logical unit unable to update self-test log"},
  417.   {0x3F,0x00,D|T|L|P|W|R|S|O|M|C|A|E|B|K,"Target operating conditions have changed"},
  418.   {0x3F,0x01,D|T|L|P|W|R|S|O|M|C|A|E|B|K,"Microcode has been changed"},
  419.   {0x3F,0x02,D|T|L|P|W|R|S|O|M|C|B|K,"Changed operating definition"},
  420.   {0x3F,0x03,D|T|L|P|W|R|S|O|M|C|A|E|B|K,"Inquiry data has changed"},
  421.   {0x3F,0x04,D|T|W|R|O|M|C|A|E|B|K,"Component device attached"},
  422.   {0x3F,0x05,D|T|W|R|O|M|C|A|E|B|K,"Device identifier changed"},
  423.   {0x3F,0x06,D|T|W|R|O|M|C|A|E|B,"Redundancy group created or modified"},
  424.   {0x3F,0x07,D|T|W|R|O|M|C|A|E|B,"Redundancy group deleted"},
  425.   {0x3F,0x08,D|T|W|R|O|M|C|A|E|B,"Spare created or modified"},
  426.   {0x3F,0x09,D|T|W|R|O|M|C|A|E|B,"Spare deleted"},
  427.   {0x3F,0x0A,D|T|W|R|O|M|C|A|E|B|K,"Volume set created or modified"},
  428.   {0x3F,0x0B,D|T|W|R|O|M|C|A|E|B|K,"Volume set deleted"},
  429.   {0x3F,0x0C,D|T|W|R|O|M|C|A|E|B|K,"Volume set deassigned"},
  430.   {0x3F,0x0D,D|T|W|R|O|M|C|A|E|B|K,"Volume set reassigned"},
  431.   {0x3F,0x0E,D|T|L|P|W|R|S|O|M|C|A|E,"Reported luns data has changed"},
  432.   {0x3F,0x10,D|T|W|R|O|M|B,"Medium loadable"},
  433.   {0x3F,0x11,D|T|W|R|O|M|B,"Medium auxiliary memory accessible"},
  434.   {0x40,0x00,D,"Ram failure (should use 40 nn)"},
  435.   /*
  436.    * FIXME(eric) - need a way to represent wildcards here.
  437.    */
  438.   {0x40,0x00,D|T|L|P|W|R|S|O|M|C|A|E|B|K,"Diagnostic failure on component nn (80h-ffh)"},
  439.   {0x41,0x00,D,"Data path failure (should use 40 nn)"},
  440.   {0x42,0x00,D,"Power-on or self-test failure (should use 40 nn)"},
  441.   {0x43,0x00,D|T|L|P|W|R|S|O|M|C|A|E|B|K,"Message error"},
  442.   {0x44,0x00,D|T|L|P|W|R|S|O|M|C|A|E|B|K,"Internal target failure"},
  443.   {0x45,0x00,D|T|L|P|W|R|S|O|M|C|A|E|B|K,"Select or reselect failure"},
  444.   {0x46,0x00,D|T|L|P|W|R|S|O|M|C|B|K,"Unsuccessful soft reset"},
  445.   {0x47,0x00,D|T|L|P|W|R|S|O|M|C|A|E|B|K,"Scsi parity error"},
  446.   {0x47,0x01,D|T|L|P|W|R|S|O|M|C|A|E|B|K,"Data phase CRC error detected"},
  447.   {0x47,0x02,D|T|L|P|W|R|S|O|M|C|A|E|B|K,"Scsi parity error detected during st data phase"},
  448.   {0x47,0x03,D|T|L|P|W|R|S|O|M|C|A|E|B|K,"Information unit CRC error detected"},
  449.   {0x47,0x04,D|T|L|P|W|R|S|O|M|C|A|E|B|K,"Asynchronous information protection error detected"},
  450.   {0x48,0x00,D|T|L|P|W|R|S|O|M|C|A|E|B|K,"Initiator detected error message received"},
  451.   {0x49,0x00,D|T|L|P|W|R|S|O|M|C|A|E|B|K,"Invalid message error"},
  452.   {0x4A,0x00,D|T|L|P|W|R|S|O|M|C|A|E|B|K,"Command phase error"},
  453.   {0x4B,0x00,D|T|L|P|W|R|S|O|M|C|A|E|B|K,"Data phase error"},
  454.   {0x4C,0x00,D|T|L|P|W|R|S|O|M|C|A|E|B|K,"Logical unit failed self-configuration"},
  455.   /*
  456.    * FIXME(eric) - need a way to represent wildcards here.
  457.    */
  458.   {0x4D,0x00,D|T|L|P|W|R|S|O|M|C|A|E|B|K,"Tagged overlapped commands (nn = queue tag)"},
  459.   {0x4E,0x00,D|T|L|P|W|R|S|O|M|C|A|E|B|K,"Overlapped commands attempted"},
  460.   {0x50,0x00,T,"Write append error"},
  461.   {0x50,0x01,T,"Write append position error"},
  462.   {0x50,0x02,T,"Position error related to timing"},
  463.   {0x51,0x00,T|R|O,"Erase failure"},
  464.   {0x52,0x00,T,"Cartridge fault"},
  465.   {0x53,0x00,D|T|L|W|R|S|O|M|B|K,"Media load or eject failed"},
  466.   {0x53,0x01,T,"Unload tape failure"},
  467.   {0x53,0x02,D|T|W|R|O|M|B|K,"Medium removal prevented"},
  468.   {0x54,0x00,P,"Scsi to host system interface failure"},
  469.   {0x55,0x00,P,"System resource failure"},
  470.   {0x55,0x01,D|O|B|K,"System buffer full"},
  471.   {0x55,0x02,D|T|L|P|W|R|S|O|M|A|E|K,"Insufficient reservation resources"},
  472.   {0x55,0x03,D|T|L|P|W|R|S|O|M|C|A|E,"Insufficient resources"},
  473.   {0x55,0x04,D|T|L|P|W|R|S|O|M|A|E,"Insufficient registration resources"},
  474.   {0x57,0x00,R,"Unable to recover table-of-contents"},
  475.   {0x58,0x00,O,"Generation does not exist"},
  476.   {0x59,0x00,O,"Updated block read"},
  477.   {0x5A,0x00,D|T|L|P|W|R|S|O|M|B|K,"Operator request or state change input"},
  478.   {0x5A,0x01,D|T|W|R|O|M|B|K,"Operator medium removal request"},
  479.   {0x5A,0x02,D|T|W|R|O|A|B|K,"Operator selected write protect"},
  480.   {0x5A,0x03,D|T|W|R|O|A|B|K,"Operator selected write permit"},
  481.   {0x5B,0x00,D|T|L|P|W|R|S|O|M|K,"Log exception"},
  482.   {0x5B,0x01,D|T|L|P|W|R|S|O|M|K,"Threshold condition met"},
  483.   {0x5B,0x02,D|T|L|P|W|R|S|O|M|K,"Log counter at maximum"},
  484.   {0x5B,0x03,D|T|L|P|W|R|S|O|M|K,"Log list codes exhausted"},
  485.   {0x5C,0x00,D|O,"Rpl status change"},
  486.   {0x5C,0x01,D|O,"Spindles synchronized"},
  487.   {0x5C,0x02,D|O,"Spindles not synchronized"},
  488.   {0x5D,0x00,D|T|L|P|W|R|S|O|M|C|A|E|B|K,"Failure prediction threshold exceeded"},
  489.   {0x5D,0x01,R|B,"Media failure prediction threshold exceeded"},
  490.   {0x5D,0x02,R,"Logical unit failure prediction threshold exceeded"},
  491.   {0x5D,0x10,D|B,"Hardware impending failure general hard drive failure"},
  492.   {0x5D,0x11,D|B,"Hardware impending failure drive error rate too high"},
  493.   {0x5D,0x12,D|B,"Hardware impending failure data error rate too high"},
  494.   {0x5D,0x13,D|B,"Hardware impending failure seek error rate too high"},
  495.   {0x5D,0x14,D|B,"Hardware impending failure too many block reassigns"},
  496.   {0x5D,0x15,D|B,"Hardware impending failure access times too high"},
  497.   {0x5D,0x16,D|B,"Hardware impending failure start unit times too high"},
  498.   {0x5D,0x17,D|B,"Hardware impending failure channel parametrics"},
  499.   {0x5D,0x18,D|B,"Hardware impending failure controller detected"},
  500.   {0x5D,0x19,D|B,"Hardware impending failure throughput performance"},
  501.   {0x5D,0x1A,D|B,"Hardware impending failure seek time performance"},
  502.   {0x5D,0x1B,D|B,"Hardware impending failure spin-up retry count"},
  503.   {0x5D,0x1C,D|B,"Hardware impending failure drive calibration retry count"},
  504.   {0x5D,0x20,D|B,"Controller impending failure general hard drive failure"},
  505.   {0x5D,0x21,D|B,"Controller impending failure drive error rate too high"},
  506.   {0x5D,0x22,D|B,"Controller impending failure data error rate too high"},
  507.   {0x5D,0x23,D|B,"Controller impending failure seek error rate too high"},
  508.   {0x5D,0x24,D|B,"Controller impending failure too many block reassigns"},
  509.   {0x5D,0x25,D|B,"Controller impending failure access times too high"},
  510.   {0x5D,0x26,D|B,"Controller impending failure start unit times too high"},
  511.   {0x5D,0x27,D|B,"Controller impending failure channel parametrics"},
  512.   {0x5D,0x28,D|B,"Controller impending failure controller detected"},
  513.   {0x5D,0x29,D|B,"Controller impending failure throughput performance"},
  514.   {0x5D,0x2A,D|B,"Controller impending failure seek time performance"},
  515.   {0x5D,0x2B,D|B,"Controller impending failure spin-up retry count"},
  516.   {0x5D,0x2C,D|B,"Controller impending failure drive calibration retry count"},
  517.   {0x5D,0x30,D|B,"Data channel impending failure general hard drive failure"},
  518.   {0x5D,0x31,D|B,"Data channel impending failure drive error rate too high"},
  519.   {0x5D,0x32,D|B,"Data channel impending failure data error rate too high"},
  520.   {0x5D,0x33,D|B,"Data channel impending failure seek error rate too high"},
  521.   {0x5D,0x34,D|B,"Data channel impending failure too many block reassigns"},
  522.   {0x5D,0x35,D|B,"Data channel impending failure access times too high"},
  523.   {0x5D,0x36,D|B,"Data channel impending failure start unit times too high"},
  524.   {0x5D,0x37,D|B,"Data channel impending failure channel parametrics"},
  525.   {0x5D,0x38,D|B,"Data channel impending failure controller detected"},
  526.   {0x5D,0x39,D|B,"Data channel impending failure throughput performance"},
  527.   {0x5D,0x3A,D|B,"Data channel impending failure seek time performance"},
  528.   {0x5D,0x3B,D|B,"Data channel impending failure spin-up retry count"},
  529.   {0x5D,0x3C,D|B,"Data channel impending failure drive calibration retry count"},
  530.   {0x5D,0x40,D|B,"Servo impending failure general hard drive failure"},
  531.   {0x5D,0x41,D|B,"Servo impending failure drive error rate too high"},
  532.   {0x5D,0x42,D|B,"Servo impending failure data error rate too high"},
  533.   {0x5D,0x43,D|B,"Servo impending failure seek error rate too high"},
  534.   {0x5D,0x44,D|B,"Servo impending failure too many block reassigns"},
  535.   {0x5D,0x45,D|B,"Servo impending failure access times too high"},
  536.   {0x5D,0x46,D|B,"Servo impending failure start unit times too high"},
  537.   {0x5D,0x47,D|B,"Servo impending failure channel parametrics"},
  538.   {0x5D,0x48,D|B,"Servo impending failure controller detected"},
  539.   {0x5D,0x49,D|B,"Servo impending failure throughput performance"},
  540.   {0x5D,0x4A,D|B,"Servo impending failure seek time performance"},
  541.   {0x5D,0x4B,D|B,"Servo impending failure spin-up retry count"},
  542.   {0x5D,0x4C,D|B,"Servo impending failure drive calibration retry count"},
  543.   {0x5D,0x50,D|B,"Spindle impending failure general hard drive failure"},
  544.   {0x5D,0x51,D|B,"Spindle impending failure drive error rate too high"},
  545.   {0x5D,0x52,D|B,"Spindle impending failure data error rate too high"},
  546.   {0x5D,0x53,D|B,"Spindle impending failure seek error rate too high"},
  547.   {0x5D,0x54,D|B,"Spindle impending failure too many block reassigns"},
  548.   {0x5D,0x55,D|B,"Spindle impending failure access times too high"},
  549.   {0x5D,0x56,D|B,"Spindle impending failure start unit times too high"},
  550.   {0x5D,0x57,D|B,"Spindle impending failure channel parametrics"},
  551.   {0x5D,0x58,D|B,"Spindle impending failure controller detected"},
  552.   {0x5D,0x59,D|B,"Spindle impending failure throughput performance"},
  553.   {0x5D,0x5A,D|B,"Spindle impending failure seek time performance"},
  554.   {0x5D,0x5B,D|B,"Spindle impending failure spin-up retry count"},
  555.   {0x5D,0x5C,D|B,"Spindle impending failure drive calibration retry count"},
  556.   {0x5D,0x60,D|B,"Firmware impending failure general hard drive failure"},
  557.   {0x5D,0x61,D|B,"Firmware impending failure drive error rate too high"},
  558.   {0x5D,0x62,D|B,"Firmware impending failure data error rate too high"},
  559.   {0x5D,0x63,D|B,"Firmware impending failure seek error rate too high"},
  560.   {0x5D,0x64,D|B,"Firmware impending failure too many block reassigns"},
  561.   {0x5D,0x65,D|B,"Firmware impending failure access times too high"},
  562.   {0x5D,0x66,D|B,"Firmware impending failure start unit times too high"},
  563.   {0x5D,0x67,D|B,"Firmware impending failure channel parametrics"},
  564.   {0x5D,0x68,D|B,"Firmware impending failure controller detected"},
  565.   {0x5D,0x69,D|B,"Firmware impending failure throughput performance"},
  566.   {0x5D,0x6A,D|B,"Firmware impending failure seek time performance"},
  567.   {0x5D,0x6B,D|B,"Firmware impending failure spin-up retry count"},
  568.   {0x5D,0x6C,D|B,"Firmware impending failure drive calibration retry count"},
  569.   {0x5D,0xFF,D|T|L|P|W|R|S|O|M|C|A|E|B|K,"Failure prediction threshold exceeded (false)"},
  570.   {0x5E,0x00,D|T|L|P|W|R|S|O|C|A|K,"Low power condition on"},
  571.   {0x5E,0x01,D|T|L|P|W|R|S|O|C|A|K,"Idle condition activated by timer"},
  572.   {0x5E,0x02,D|T|L|P|W|R|S|O|C|A|K,"Standby condition activated by timer"},
  573.   {0x5E,0x03,D|T|L|P|W|R|S|O|C|A|K,"Idle condition activated by command"},
  574.   {0x5E,0x04,D|T|L|P|W|R|S|O|C|A|K,"Standby condition activated by command"},
  575.   {0x5E,0x41,B,"Power state change to active"},
  576.   {0x5E,0x42,B,"Power state change to idle"},
  577.   {0x5E,0x43,B,"Power state change to standby"},
  578.   {0x5E,0x45,B,"Power state change to sleep"},
  579.   {0x5E,0x47,B|K,"Power state change to device control"},
  580.   {0x60,0x00,S,"Lamp failure"},
  581.   {0x61,0x00,S,"Video acquisition error"},
  582.   {0x61,0x01,S,"Unable to acquire video"},
  583.   {0x61,0x02,S,"Out of focus"},
  584.   {0x62,0x00,S,"Scan head positioning error"},
  585.   {0x63,0x00,R,"End of user area encountered on this track"},
  586.   {0x63,0x01,R,"Packet does not fit in available space"},
  587.   {0x64,0x00,R,"Illegal mode for this track"},
  588.   {0x64,0x01,R,"Invalid packet size"},
  589.   {0x65,0x00,D|T|L|P|W|R|S|O|M|C|A|E|B|K,"Voltage fault"},
  590.   {0x66,0x00,S,"Automatic document feeder cover up"},
  591.   {0x66,0x01,S,"Automatic document feeder lift up"},
  592.   {0x66,0x02,S,"Document jam in automatic document feeder"},
  593.   {0x66,0x03,S,"Document miss feed automatic in document feeder"},
  594.   {0x67,0x00,A,"Configuration failure"},
  595.   {0x67,0x01,A,"Configuration of incapable logical units failed"},
  596.   {0x67,0x02,A,"Add logical unit failed"},
  597.   {0x67,0x03,A,"Modification of logical unit failed"},
  598.   {0x67,0x04,A,"Exchange of logical unit failed"},
  599.   {0x67,0x05,A,"Remove of logical unit failed"},
  600.   {0x67,0x06,A,"Attachment of logical unit failed"},
  601.   {0x67,0x07,A,"Creation of logical unit failed"},
  602.   {0x67,0x08,A,"Assign failure occurred"},
  603.   {0x67,0x09,A,"Multiply assigned logical unit"},
  604.   {0x68,0x00,A,"Logical unit not configured"},
  605.   {0x69,0x00,A,"Data loss on logical unit"},
  606.   {0x69,0x01,A,"Multiple logical unit failures"},
  607.   {0x69,0x02,A,"Parity/data mismatch"},
  608.   {0x6A,0x00,A,"Informational,refer to log"},
  609.   {0x6B,0x00,A,"State change has occurred"},
  610.   {0x6B,0x01,A,"Redundancy level got better"},
  611.   {0x6B,0x02,A,"Redundancy level got worse"},
  612.   {0x6C,0x00,A,"Rebuild failure occurred"},
  613.   {0x6D,0x00,A,"Recalculate failure occurred"},
  614.   {0x6E,0x00,A,"Command to logical unit failed"},
  615.   {0x6F,0x00,R,"Copy protection key exchange failure - authentication failure"},
  616.   {0x6F,0x01,R,"Copy protection key exchange failure - key not present"},
  617.   {0x6F,0x02,R,"Copy protection key exchange failure - key not established"},
  618.   {0x6F,0x03,R,"Read of scrambled sector without authentication"},
  619.   {0x6F,0x04,R,"Media region code is mismatched to logical unit region"},
  620.   {0x6F,0x05,R,"Drive region must be permanent/region reset count error"},
  621.   /*
  622.    * FIXME(eric) - need a way to represent wildcards here.
  623.    */
  624.   {0x70,0x00,T,"Decompression exception short algorithm id of nn"},
  625.   {0x71,0x00,T,"Decompression exception long algorithm id"},
  626.   {0x72,0x00,R,"Session fixation error"},
  627.   {0x72,0x01,R,"Session fixation error writing lead-in"},
  628.   {0x72,0x02,R,"Session fixation error writing lead-out"},
  629.   {0x72,0x03,R,"Session fixation error - incomplete track in session"},
  630.   {0x72,0x04,R,"Empty or partially written reserved track"},
  631.   {0x72,0x05,R,"No more track reservations allowed"},
  632.   {0x73,0x00,R,"Cd control error"},
  633.   {0x73,0x01,R,"Power calibration area almost full"},
  634.   {0x73,0x02,R,"Power calibration area is full"},
  635.   {0x73,0x03,R,"Power calibration area error"},
  636.   {0x73,0x04,R,"Program memory area update failure"},
  637.   {0x73,0x05,R,"Program memory area is full"},
  638.   {0x73,0x06,R,"RMA/PMA is full"},
  639.   {0, 0, 0, NULL}
  640. };
  641. #endif
  642. #if (CONSTANTS & CONST_SENSE)
  643. static const char *snstext[] = {
  644.     "None",                     /* There is no sense information */
  645.     "Recovered Error",          /* The last command completed successfully
  646.                                    but used error correction */
  647.     "Not Ready",                /* The addressed target is not ready */
  648.     "Medium Error",             /* Data error detected on the medium */
  649.     "Hardware Error",           /* Controller or device failure */
  650.     "Illegal Request",
  651.     "Unit Attention",           /* Removable medium was changed, or
  652.                                    the target has been reset */
  653.     "Data Protect",             /* Access to the data is blocked */
  654.     "Blank Check",              /* Reached unexpected written or unwritten
  655.                                    region of the medium */
  656.     "Key=9",                    /* Vendor specific */
  657.     "Copy Aborted",             /* COPY or COMPARE was aborted */
  658.     "Aborted Command",          /* The target aborted the command */
  659.     "Equal",                    /* A SEARCH DATA command found data equal */
  660.     "Volume Overflow",          /* Medium full with still data to be written */
  661.     "Miscompare",               /* Source data and data on the medium
  662.                                    do not agree */
  663.     "Key=15"                    /* Reserved */
  664. };
  665. #endif
  666. /* Print sense information */
  667. static 
  668. void print_sense_internal(const char * devclass, 
  669.   const unsigned char * sense_buffer,
  670.   kdev_t dev)
  671. {
  672.     int i, s;
  673.     int sense_class, valid, code, info;
  674.     const char * error = NULL;
  675.     
  676.     sense_class = (sense_buffer[0] >> 4) & 0x07;
  677.     code = sense_buffer[0] & 0xf;
  678.     valid = sense_buffer[0] & 0x80;
  679.     
  680.     if (sense_class == 7) { /* extended sense data */
  681. s = sense_buffer[7] + 8;
  682. if(s > SCSI_SENSE_BUFFERSIZE)
  683.    s = SCSI_SENSE_BUFFERSIZE;
  684. info = ((sense_buffer[3] << 24) | (sense_buffer[4] << 16) |
  685. (sense_buffer[5] << 8) | sense_buffer[6]);
  686. if (info || valid) {
  687. printk("Info fld=0x%x", info);
  688. if (!valid) /* info data not according to standard */
  689. printk(" (nonstd)");
  690. printk(", ");
  691. }
  692. if (sense_buffer[2] & 0x80)
  693.            printk( "FMK "); /* current command has read a filemark */
  694. if (sense_buffer[2] & 0x40)
  695.            printk( "EOM "); /* end-of-medium condition exists */
  696. if (sense_buffer[2] & 0x20)
  697.            printk( "ILI "); /* incorrect block length requested */
  698. switch (code) {
  699. case 0x0:
  700.     error = "Current"; /* error concerns current command */
  701.     break;
  702. case 0x1:
  703.     error = "Deferred"; /* error concerns some earlier command */
  704.              /* e.g., an earlier write to disk cache succeeded, but
  705.                    now the disk discovers that it cannot write the data */
  706.     break;
  707. default:
  708.     error = "Invalid";
  709. }
  710. printk("%s ", error);
  711. #if (CONSTANTS & CONST_SENSE)
  712. printk( "%s%s: sense key %sn", devclass,
  713.        kdevname(dev), snstext[sense_buffer[2] & 0x0f]);
  714. #else
  715. printk("%s%s: sns = %2x %2xn", devclass,
  716.        kdevname(dev), sense_buffer[0], sense_buffer[2]);
  717. #endif
  718. /* Check to see if additional sense information is available */
  719. if(sense_buffer[7] + 7 < 13 ||
  720.    (sense_buffer[12] == 0  && sense_buffer[13] ==  0)) goto done;
  721. #if (CONSTANTS & CONST_XSENSE)
  722. for(i=0; additional[i].text; i++)
  723.     if(additional[i].code1 == sense_buffer[12] &&
  724.        additional[i].code2 == sense_buffer[13])
  725. printk("Additional sense indicates %sn", additional[i].text);
  726. for(i=0; additional2[i].text; i++)
  727.     if(additional2[i].code1 == sense_buffer[12] &&
  728.        additional2[i].code2_min >= sense_buffer[13]  &&
  729.        additional2[i].code2_max <= sense_buffer[13]) {
  730. printk("Additional sense indicates ");
  731. printk(additional2[i].text, sense_buffer[13]);
  732. printk("n");
  733.     };
  734. #else
  735. printk("ASC=%2x ASCQ=%2xn", sense_buffer[12], sense_buffer[13]);
  736. #endif
  737.     } else { /* non-extended sense data */
  738.          /*
  739.           * Standard says:
  740.           *    sense_buffer[0] & 0200 : address valid
  741.           *    sense_buffer[0] & 0177 : vendor-specific error code
  742.           *    sense_buffer[1] & 0340 : vendor-specific
  743.           *    sense_buffer[1..3] : 21-bit logical block address
  744.           */
  745. #if (CONSTANTS & CONST_SENSE)
  746. if (sense_buffer[0] < 15)
  747.     printk("%s%s: old sense key %sn", devclass,
  748.       kdevname(dev), snstext[sense_buffer[0] & 0x0f]);
  749. else
  750. #endif
  751.     printk("%s%s: sns = %2x %2xn", devclass,
  752.       kdevname(dev), sense_buffer[0], sense_buffer[2]);
  753. printk("Non-extended sense class %d code 0x%0xn", sense_class, code);
  754. s = 4;
  755.     }
  756.     
  757.  done:
  758. #if !(CONSTANTS & CONST_SENSE)
  759.     printk("Raw sense data:");
  760.     for (i = 0; i < s; ++i) 
  761. printk("0x%02x ", sense_buffer[i]);
  762.     printk("n");
  763. #endif
  764.     return;
  765. }
  766. void print_sense(const char * devclass, Scsi_Cmnd * SCpnt)
  767. {
  768. print_sense_internal(devclass, SCpnt->sense_buffer,
  769.      SCpnt->request.rq_dev);
  770. }
  771. void print_req_sense(const char * devclass, Scsi_Request * SRpnt)
  772. {
  773. print_sense_internal(devclass, SRpnt->sr_sense_buffer,
  774.      SRpnt->sr_request.rq_dev);
  775. }
  776. #if (CONSTANTS & CONST_MSG) 
  777. static const char *one_byte_msgs[] = {
  778. /* 0x00 */ "Command Complete", NULL, "Save Pointers",
  779. /* 0x03 */ "Restore Pointers", "Disconnect", "Initiator Error", 
  780. /* 0x06 */ "Abort", "Message Reject", "Nop", "Message Parity Error",
  781. /* 0x0a */ "Linked Command Complete", "Linked Command Complete w/flag",
  782. /* 0x0c */ "Bus device reset", "Abort Tag", "Clear Queue", 
  783. /* 0x0f */ "Initiate Recovery", "Release Recovery"
  784. };
  785. #define NO_ONE_BYTE_MSGS (sizeof(one_byte_msgs)  / sizeof (const char *))
  786. static const char *two_byte_msgs[] = {
  787. /* 0x20 */ "Simple Queue Tag", "Head of Queue Tag", "Ordered Queue Tag"
  788. /* 0x23 */ "Ignore Wide Residue"
  789. };
  790. #define NO_TWO_BYTE_MSGS (sizeof(two_byte_msgs)  / sizeof (const char *))
  791. static const char *extended_msgs[] = {
  792. /* 0x00 */ "Modify Data Pointer", "Synchronous Data Transfer Request",
  793. /* 0x02 */ "SCSI-I Extended Identify", "Wide Data Transfer Request"
  794. };
  795. #define NO_EXTENDED_MSGS (sizeof(two_byte_msgs)  / sizeof (const char *))
  796. #endif /* (CONSTANTS & CONST_MSG) */
  797. int print_msg (const unsigned char *msg) {
  798.     int len = 0, i;
  799.     if (msg[0] == EXTENDED_MESSAGE) {
  800. len = 3 + msg[1];
  801. #if (CONSTANTS & CONST_MSG)
  802. if (msg[2] < NO_EXTENDED_MSGS)
  803.     printk ("%s ", extended_msgs[msg[2]]); 
  804. else 
  805.     printk ("Extended Message, reserved code (0x%02x) ", (int) msg[2]);
  806. switch (msg[2]) {
  807. case EXTENDED_MODIFY_DATA_POINTER:
  808.     printk("pointer = %d", (int) (msg[3] << 24) | (msg[4] << 16) | 
  809.    (msg[5] << 8) | msg[6]);
  810.     break;
  811. case EXTENDED_SDTR:
  812.     printk("period = %d ns, offset = %d", (int) msg[3] * 4, (int) 
  813.    msg[4]);
  814.     break;
  815. case EXTENDED_WDTR:
  816.     printk("width = 2^%d bytes", msg[3]);
  817.     break;
  818. default:
  819.     for (i = 2; i < len; ++i) 
  820. printk("%02x ", msg[i]);
  821. }
  822. #else
  823. for (i = 0; i < len; ++i)
  824.     printk("%02x ", msg[i]);
  825. #endif
  826. /* Identify */
  827.     } else if (msg[0] & 0x80) {
  828. #if (CONSTANTS & CONST_MSG)
  829. printk("Identify disconnect %sallowed %s %d ",
  830.        (msg[0] & 0x40) ? "" : "not ",
  831.        (msg[0] & 0x20) ? "target routine" : "lun",
  832.        msg[0] & 0x7);
  833. #else
  834. printk("%02x ", msg[0]);
  835. #endif
  836. len = 1;
  837. /* Normal One byte */
  838.     } else if (msg[0] < 0x1f) {
  839. #if (CONSTANTS & CONST_MSG)
  840. if (msg[0] < NO_ONE_BYTE_MSGS)
  841.     printk(one_byte_msgs[msg[0]]);
  842. else
  843.     printk("reserved (%02x) ", msg[0]);
  844. #else
  845. printk("%02x ", msg[0]);
  846. #endif
  847. len = 1;
  848. /* Two byte */
  849.     } else if (msg[0] <= 0x2f) {
  850. #if (CONSTANTS & CONST_MSG)
  851. if ((msg[0] - 0x20) < NO_TWO_BYTE_MSGS)
  852.     printk("%s %02x ", two_byte_msgs[msg[0] - 0x20], 
  853.    msg[1]);
  854. else 
  855.     printk("reserved two byte (%02x %02x) ", 
  856.    msg[0], msg[1]);
  857. #else
  858. printk("%02x %02x", msg[0], msg[1]);
  859. #endif
  860. len = 2;
  861.     } else 
  862. #if (CONSTANTS & CONST_MSG)
  863. printk(reserved);
  864. #else
  865.     printk("%02x ", msg[0]);
  866. #endif
  867.     return len;
  868. }
  869. void print_Scsi_Cmnd (Scsi_Cmnd *cmd) {
  870.     printk("scsi%d : destination target %d, lun %dn", 
  871.    cmd->host->host_no, 
  872.    cmd->target, 
  873.    cmd->lun);
  874.     printk("        command = ");
  875.     print_command (cmd->cmnd);
  876. }
  877. #if (CONSTANTS & CONST_HOST)
  878. static const char * hostbyte_table[]={
  879. "DID_OK", "DID_NO_CONNECT", "DID_BUS_BUSY", "DID_TIME_OUT", "DID_BAD_TARGET", 
  880. "DID_ABORT", "DID_PARITY", "DID_ERROR", "DID_RESET", "DID_BAD_INTR",
  881. "DID_PASSTHROUGH", "DID_SOFT_ERROR", NULL};
  882. void print_hostbyte(int scsiresult)
  883. {   static int maxcode=0;
  884.     int i;
  885.    
  886.     if(!maxcode) {
  887. for(i=0;hostbyte_table[i];i++) ;
  888. maxcode=i-1;
  889.     }
  890.     printk("Hostbyte=0x%02x",host_byte(scsiresult));
  891.     if(host_byte(scsiresult)>maxcode) {
  892. printk("is invalid "); 
  893. return;
  894.     }
  895.     printk("(%s) ",hostbyte_table[host_byte(scsiresult)]);
  896. }
  897. #else
  898. void print_hostbyte(int scsiresult)
  899. {   printk("Hostbyte=0x%02x ",host_byte(scsiresult));
  900. }
  901. #endif
  902. #if (CONSTANTS & CONST_DRIVER)
  903. static const char * driverbyte_table[]={
  904. "DRIVER_OK", "DRIVER_BUSY", "DRIVER_SOFT",  "DRIVER_MEDIA", "DRIVER_ERROR", 
  905. "DRIVER_INVALID", "DRIVER_TIMEOUT", "DRIVER_HARD",NULL };
  906. static const char * driversuggest_table[]={"SUGGEST_OK",
  907. "SUGGEST_RETRY", "SUGGEST_ABORT", "SUGGEST_REMAP", "SUGGEST_DIE",
  908. unknown,unknown,unknown, "SUGGEST_SENSE",NULL};
  909. void print_driverbyte(int scsiresult)
  910. {   static int driver_max=0,suggest_max=0;
  911.     int i,dr=driver_byte(scsiresult)&DRIVER_MASK, 
  912. su=(driver_byte(scsiresult)&SUGGEST_MASK)>>4;
  913.     if(!driver_max) {
  914.         for(i=0;driverbyte_table[i];i++) ;
  915.         driver_max=i;
  916. for(i=0;driversuggest_table[i];i++) ;
  917. suggest_max=i;
  918.     }
  919.     printk("Driverbyte=0x%02x",driver_byte(scsiresult));
  920.     printk("(%s,%s) ",
  921. dr<driver_max  ? driverbyte_table[dr]:"invalid",
  922. su<suggest_max ? driversuggest_table[su]:"invalid");
  923. }
  924. #else
  925. void print_driverbyte(int scsiresult)
  926. {   printk("Driverbyte=0x%02x ",driver_byte(scsiresult));
  927. }
  928. #endif
  929. /*
  930.  * Overrides for Emacs so that we almost follow Linus's tabbing style.
  931.  * Emacs will notice this stuff at the end of the file and automatically
  932.  * adjust the settings for this buffer only.  This must remain at the end
  933.  * of the file.
  934.  * ---------------------------------------------------------------------------
  935.  * Local variables:
  936.  * c-indent-level: 4
  937.  * c-brace-imaginary-offset: 0
  938.  * c-brace-offset: -4
  939.  * c-argdecl-indent: 4
  940.  * c-label-offset: -4
  941.  * c-continued-statement-offset: 4
  942.  * c-continued-brace-offset: 0
  943.  * indent-tabs-mode: nil
  944.  * tab-width: 8
  945.  * End:
  946.  */