constants.c
来自「Linux Kernel 2.6.9 for OMAP1710」· C语言 代码 · 共 1,197 行 · 第 1/3 页
C
1,197 行
/* * ASCII values for a number of symbolic constants, printing functions, * etc. * Additions for SCSI 2 and Linux 2.2.x by D. Gilbert (990422) * Additions for SCSI 3+ (SPC-3 T10/1416-D Rev 07 3 May 2002) * by D. Gilbert and aeb (20020609) */#include <linux/config.h>#include <linux/blkdev.h>#include <linux/module.h>#include <linux/kernel.h>#include <scsi/scsi.h>#include <scsi/scsi_device.h>#include <scsi/scsi_host.h>#include <scsi/scsi_request.h>#define CONST_COMMAND 0x01#define CONST_STATUS 0x02#define CONST_SENSE 0x04#define CONST_XSENSE 0x08#define CONST_CMND 0x10#define CONST_MSG 0x20#define CONST_HOST 0x40#define CONST_DRIVER 0x80static const char unknown[] = "UNKNOWN";#ifdef CONFIG_SCSI_CONSTANTS#ifdef CONSTANTS#undef CONSTANTS#endif#define CONSTANTS (CONST_COMMAND | CONST_STATUS | CONST_SENSE | CONST_XSENSE \ | CONST_CMND | CONST_MSG | CONST_HOST | CONST_DRIVER)#else#define CONSTANTS 0#endif#if (CONSTANTS & CONST_COMMAND)static const char * group_0_commands[] = {/* 00-03 */ "Test Unit Ready", "Rezero Unit", unknown, "Request Sense",/* 04-07 */ "Format Unit", "Read Block Limits", unknown, "Reasssign Blocks",/* 08-0d */ "Read (6)", unknown, "Write (6)", "Seek (6)", unknown, unknown,/* 0e-12 */ unknown, "Read Reverse", "Write Filemarks", "Space", "Inquiry", /* 13-16 */ "Verify", "Recover Buffered Data", "Mode Select", "Reserve",/* 17-1b */ "Release", "Copy", "Erase", "Mode Sense", "Start/Stop Unit",/* 1c-1d */ "Receive Diagnostic", "Send Diagnostic", /* 1e-1f */ "Prevent/Allow Medium Removal", unknown,};static const char *group_1_commands[] = {/* 20-22 */ unknown, unknown, unknown,/* 23-28 */ unknown, "Define window parameters", "Read Capacity", unknown, unknown, "Read (10)", /* 29-2d */ "Read Generation", "Write (10)", "Seek (10)", "Erase", "Read updated block", /* 2e-31 */ "Write Verify","Verify", "Search High", "Search Equal", /* 32-34 */ "Search Low", "Set Limits", "Prefetch or Read Position", /* 35-37 */ "Synchronize Cache","Lock/Unlock Cache", "Read Defect Data", /* 38-3c */ "Medium Scan", "Compare", "Copy Verify", "Write Buffer", "Read Buffer", /* 3d-3f */ "Update Block", "Read Long", "Write Long",};static const char *group_2_commands[] = {/* 40-41 */ "Change Definition", "Write Same",/* 42-48 */ "Read sub-channel", "Read TOC", "Read header", "Play audio (10)", "Get configuration", "Play audio msf", "Play audio track/index",/* 49-4f */ "Play track relative (10)", "Get event status notification", "Pause/resume", "Log Select", "Log Sense", "Stop play/scan", unknown,/* 50-55 */ "Xdwrite", "Xpwrite, Read disk info", "Xdread, Read track info", "Reserve track", "Send OPC onfo", "Mode Select (10)",/* 56-5b */ "Reserve (10)", "Release (10)", "Repair track", "Read master cue", "Mode Sense (10)", "Close track/session",/* 5c-5f */ "Read buffer capacity", "Send cue sheet", "Persistent reserve in", "Persistent reserve out",};/* The following are 16 byte commands in group 4 */static const char *group_4_commands[] = {/* 80-84 */ "Xdwrite (16)", "Rebuild (16)", "Regenerate (16)", "Extended copy", "Receive copy results",/* 85-89 */ "Memory Export In (16)", "Access control in", "Access control out", "Read (16)", "Memory Export Out (16)",/* 8a-8f */ "Write (16)", unknown, "Read attributes", "Write attributes", "Write and verify (16)", "Verify (16)",/* 90-94 */ "Pre-fetch (16)", "Synchronize cache (16)", "Lock/unlock cache (16)", "Write same (16)", unknown,/* 95-99 */ unknown, unknown, unknown, unknown, unknown,/* 9a-9f */ unknown, unknown, unknown, unknown, "Service action in", "Service action out",};/* The following are 12 byte commands in group 5 */static const char *group_5_commands[] = {/* a0-a5 */ "Report luns", "Blank", "Send event", "Maintenance (in)", "Maintenance (out)", "Move medium/play audio(12)",/* a6-a9 */ "Exchange medium", "Move medium attached", "Read(12)", "Play track relative(12)",/* aa-ae */ "Write(12)", unknown, "Erase(12), Get Performance", "Read DVD structure", "Write and verify(12)",/* af-b1 */ "Verify(12)", "Search data high(12)", "Search data equal(12)",/* b2-b4 */ "Search data low(12)", "Set limits(12)", "Read element status attached",/* b5-b6 */ "Request volume element address", "Send volume tag, set streaming",/* b7-b9 */ "Read defect data(12)", "Read element status", "Read CD msf",/* ba-bc */ "Redundancy group (in), Scan", "Redundancy group (out), Set cd-rom speed", "Spare (in), Play cd",/* bd-bf */ "Spare (out), Mechanism status", "Volume set (in), Read cd", "Volume set (out), Send DVD structure",};#define group(opcode) (((opcode) >> 5) & 7)#define RESERVED_GROUP 0#define VENDOR_GROUP 1static const char **commands[] = { group_0_commands, group_1_commands, group_2_commands, (const char **) RESERVED_GROUP, group_4_commands, group_5_commands, (const char **) VENDOR_GROUP, (const char **) VENDOR_GROUP};static const char reserved[] = "RESERVED";static const char vendor[] = "VENDOR SPECIFIC";static void print_opcode(int opcode) { const char **table = commands[ group(opcode) ]; switch ((unsigned long) table) { case RESERVED_GROUP: printk("%s(0x%02x) ", reserved, opcode); break; case VENDOR_GROUP: printk("%s(0x%02x) ", vendor, opcode); break; default: if (table[opcode & 0x1f] != unknown) printk("%s ",table[opcode & 0x1f]); else printk("%s(0x%02x) ", unknown, opcode); break; }}#else /* CONST & CONST_COMMAND */static void print_opcode(int opcode) { printk("0x%02x ", opcode);}#endif void __scsi_print_command (unsigned char *command) { int i,s; print_opcode(command[0]); for ( i = 1, s = COMMAND_SIZE(command[0]); i < s; ++i) printk("%02x ", command[i]); printk("\n");}/** * * print_status - print scsi status description * @scsi_status: scsi status value * * If the status is recognized, the description is printed. * Otherwise "Unknown status" is output. No trailing space. * If CONFIG_SCSI_CONSTANTS is not set, then print status in hex * (e.g. "0x2" for Check Condition). **/voidscsi_print_status(unsigned char scsi_status) {#if (CONSTANTS & CONST_STATUS) const char * ccp; switch (scsi_status) { case 0: ccp = "Good"; break; case 0x2: ccp = "Check Condition"; break; case 0x4: ccp = "Condition Met"; break; case 0x8: ccp = "Busy"; break; case 0x10: ccp = "Intermediate"; break; case 0x14: ccp = "Intermediate-Condition Met"; break; case 0x18: ccp = "Reservation Conflict"; break; case 0x22: ccp = "Command Terminated"; break; /* obsolete */ case 0x28: ccp = "Task set Full"; break; /* was: Queue Full */ case 0x30: ccp = "ACA Active"; break; case 0x40: ccp = "Task Aborted"; break; default: ccp = "Unknown status"; } printk("%s", ccp);#else printk("0x%0x", scsi_status);#endif}#if (CONSTANTS & CONST_XSENSE)struct error_info { unsigned short code12; /* 0x0302 looks better than 0x03,0x02 */ const char * text;};static struct error_info additional[] ={ {0x0000, "No additional sense information"}, {0x0001, "Filemark detected"}, {0x0002, "End-of-partition/medium detected"}, {0x0003, "Setmark detected"}, {0x0004, "Beginning-of-partition/medium detected"}, {0x0005, "End-of-data detected"}, {0x0006, "I/O process terminated"}, {0x0011, "Audio play operation in progress"}, {0x0012, "Audio play operation paused"}, {0x0013, "Audio play operation successfully completed"}, {0x0014, "Audio play operation stopped due to error"}, {0x0015, "No current audio status to return"}, {0x0016, "Operation in progress"}, {0x0017, "Cleaning requested"}, {0x0018, "Erase operation in progress"}, {0x0019, "Locate operation in progress"}, {0x001A, "Rewind operation in progress"}, {0x001B, "Set capacity operation in progress"}, {0x001C, "Verify operation in progress"}, {0x0100, "No index/sector signal"}, {0x0200, "No seek complete"}, {0x0300, "Peripheral device write fault"}, {0x0301, "No write current"}, {0x0302, "Excessive write errors"}, {0x0400, "Logical unit not ready, cause not reportable"}, {0x0401, "Logical unit is in process of becoming ready"}, {0x0402, "Logical unit not ready, initializing cmd. required"}, {0x0403, "Logical unit not ready, manual intervention required"}, {0x0404, "Logical unit not ready, format in progress"}, {0x0405, "Logical unit not ready, rebuild in progress"}, {0x0406, "Logical unit not ready, recalculation in progress"}, {0x0407, "Logical unit not ready, operation in progress"}, {0x0408, "Logical unit not ready, long write in progress"}, {0x0409, "Logical unit not ready, self-test in progress"}, {0x040A, "Logical unit not accessible, asymmetric access state " "transition"}, {0x040B, "Logical unit not accessible, target port in standby state"}, {0x040C, "Logical unit not accessible, target port in unavailable " "state"}, {0x0410, "Logical unit not ready, auxiliary memory not accessible"}, {0x0500, "Logical unit does not respond to selection"}, {0x0600, "No reference position found"}, {0x0700, "Multiple peripheral devices selected"}, {0x0800, "Logical unit communication failure"}, {0x0801, "Logical unit communication time-out"}, {0x0802, "Logical unit communication parity error"}, {0x0803, "Logical unit communication CRC error (Ultra-DMA/32)"}, {0x0804, "Unreachable copy target"}, {0x0900, "Track following error"}, {0x0901, "Tracking servo failure"}, {0x0902, "Focus servo failure"}, {0x0903, "Spindle servo failure"}, {0x0904, "Head select fault"}, {0x0A00, "Error log overflow"}, {0x0B00, "Warning"}, {0x0B01, "Warning - specified temperature exceeded"}, {0x0B02, "Warning - enclosure degraded"}, {0x0C00, "Write error"}, {0x0C01, "Write error - recovered with auto reallocation"}, {0x0C02, "Write error - auto reallocation failed"}, {0x0C03, "Write error - recommend reassignment"}, {0x0C04, "Compression check miscompare error"}, {0x0C05, "Data expansion occurred during compression"}, {0x0C06, "Block not compressible"}, {0x0C07, "Write error - recovery needed"}, {0x0C08, "Write error - recovery failed"}, {0x0C09, "Write error - loss of streaming"}, {0x0C0A, "Write error - padding blocks added"}, {0x0C0B, "Auxiliary memory write error"}, {0x0C0C, "Write error - unexpected unsolicited data"}, {0x0C0D, "Write error - not enough unsolicited data"}, {0x0D00, "Error detected by third party temporary initiator"}, {0x0D01, "Third party device failure"}, {0x0D02, "Copy target device not reachable"}, {0x0D03, "Incorrect copy target device type"}, {0x0D04, "Copy target device data underrun"}, {0x0D05, "Copy target device data overrun"}, {0x1000, "Id CRC or ECC error"}, {0x1100, "Unrecovered read error"}, {0x1101, "Read retries exhausted"}, {0x1102, "Error too long to correct"}, {0x1103, "Multiple read errors"}, {0x1104, "Unrecovered read error - auto reallocate failed"}, {0x1105, "L-EC uncorrectable error"}, {0x1106, "CIRC unrecovered error"}, {0x1107, "Data re-synchronization error"}, {0x1108, "Incomplete block read"}, {0x1109, "No gap found"}, {0x110A, "Miscorrected error"}, {0x110B, "Unrecovered read error - recommend reassignment"}, {0x110C, "Unrecovered read error - recommend rewrite the data"}, {0x110D, "De-compression CRC error"}, {0x110E, "Cannot decompress using declared algorithm"}, {0x110F, "Error reading UPC/EAN number"}, {0x1110, "Error reading ISRC number"}, {0x1111, "Read error - loss of streaming"}, {0x1112, "Auxiliary memory read error"}, {0x1113, "Read error - failed retransmission request"}, {0x1200, "Address mark not found for id field"}, {0x1300, "Address mark not found for data field"}, {0x1400, "Recorded entity not found"}, {0x1401, "Record not found"}, {0x1402, "Filemark or setmark not found"}, {0x1403, "End-of-data not found"}, {0x1404, "Block sequence error"}, {0x1405, "Record not found - recommend reassignment"}, {0x1406, "Record not found - data auto-reallocated"}, {0x1407, "Locate operation failure"}, {0x1500, "Random positioning error"}, {0x1501, "Mechanical positioning error"}, {0x1502, "Positioning error detected by read of medium"}, {0x1600, "Data synchronization mark error"}, {0x1601, "Data sync error - data rewritten"}, {0x1602, "Data sync error - recommend rewrite"}, {0x1603, "Data sync error - data auto-reallocated"}, {0x1604, "Data sync error - recommend reassignment"}, {0x1700, "Recovered data with no error correction applied"}, {0x1701, "Recovered data with retries"}, {0x1702, "Recovered data with positive head offset"}, {0x1703, "Recovered data with negative head offset"}, {0x1704, "Recovered data with retries and/or circ applied"}, {0x1705, "Recovered data using previous sector id"}, {0x1706, "Recovered data without ECC - data auto-reallocated"}, {0x1707, "Recovered data without ECC - recommend reassignment"}, {0x1708, "Recovered data without ECC - recommend rewrite"}, {0x1709, "Recovered data without ECC - data rewritten"}, {0x1800, "Recovered data with error correction applied"}, {0x1801, "Recovered data with error corr. & retries applied"}, {0x1802, "Recovered data - data auto-reallocated"}, {0x1803, "Recovered data with CIRC"}, {0x1804, "Recovered data with L-EC"}, {0x1805, "Recovered data - recommend reassignment"}, {0x1806, "Recovered data - recommend rewrite"}, {0x1807, "Recovered data with ECC - data rewritten"}, {0x1808, "Recovered data with linking"}, {0x1900, "Defect list error"}, {0x1901, "Defect list not available"}, {0x1902, "Defect list error in primary list"}, {0x1903, "Defect list error in grown list"}, {0x1A00, "Parameter list length error"}, {0x1B00, "Synchronous data transfer error"}, {0x1C00, "Defect list not found"}, {0x1C01, "Primary defect list not found"}, {0x1C02, "Grown defect list not found"}, {0x1D00, "Miscompare during verify operation"}, {0x1E00, "Recovered id with ECC correction"}, {0x1F00, "Partial defect list transfer"}, {0x2000, "Invalid command operation code"}, {0x2001, "Access denied - initiator pending-enrolled"}, {0x2002, "Access denied - no access rights"}, {0x2003, "Access denied - invalid mgmt id key"}, {0x2004, "Illegal command while in write capable state"}, {0x2005, "Obsolete"}, {0x2006, "Illegal command while in explicit address mode"}, {0x2007, "Illegal command while in implicit address mode"}, {0x2008, "Access denied - enrollment conflict"}, {0x2009, "Access denied - invalid LU identifier"}, {0x200A, "Access denied - invalid proxy token"},
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?