1 /*========================================================================
2 Debug routines for nsp_cs
3 By: YOKOTA Hiroshi <yokota@netlab.is.tsukuba.ac.jp>
5 This software may be used and distributed according to the terms of
6 the GNU General Public License.
7 =========================================================================*/
9 /* $Id: nsp_debug.c,v 1.3 2003/07/26 14:21:09 elca Exp $ */
12 * Show the command data of a command
14 static const char unknown[] = "UNKNOWN";
16 static const char * group_0_commands[] = {
17 /* 00-03 */ "Test Unit Ready", "Rezero Unit", unknown, "Request Sense",
18 /* 04-07 */ "Format Unit", "Read Block Limits", unknown, "Reasssign Blocks",
19 /* 08-0d */ "Read (6)", unknown, "Write (6)", "Seek (6)", unknown, unknown,
20 /* 0e-12 */ unknown, "Read Reverse", "Write Filemarks", "Space", "Inquiry",
21 /* 13-16 */ unknown, "Recover Buffered Data", "Mode Select", "Reserve",
22 /* 17-1b */ "Release", "Copy", "Erase", "Mode Sense", "Start/Stop Unit",
23 /* 1c-1d */ "Receive Diagnostic", "Send Diagnostic",
24 /* 1e-1f */ "Prevent/Allow Medium Removal", unknown,
28 static const char *group_1_commands[] = {
29 /* 20-22 */ unknown, unknown, unknown,
30 /* 23-28 */ unknown, unknown, "Read Capacity", unknown, unknown, "Read (10)",
31 /* 29-2d */ unknown, "Write (10)", "Seek (10)", unknown, unknown,
32 /* 2e-31 */ "Write Verify","Verify", "Search High", "Search Equal",
33 /* 32-34 */ "Search Low", "Set Limits", "Prefetch or Read Position",
34 /* 35-37 */ "Synchronize Cache","Lock/Unlock Cache", "Read Defect Data",
35 /* 38-3c */ "Medium Scan", "Compare","Copy Verify", "Write Buffer", "Read Buffer",
36 /* 3d-3f */ "Update Block", "Read Long", "Write Long",
40 static const char *group_2_commands[] = {
41 /* 40-41 */ "Change Definition", "Write Same",
42 /* 42-48 */ "Read Sub-Ch(cd)", "Read TOC", "Read Header(cd)", "Play Audio(cd)", unknown, "Play Audio MSF(cd)", "Play Audio Track/Index(cd)",
43 /* 49-4f */ "Play Track Relative(10)(cd)", unknown, "Pause/Resume(cd)", "Log Select", "Log Sense", unknown, unknown,
44 /* 50-55 */ unknown, unknown, unknown, unknown, unknown, "Mode Select (10)",
45 /* 56-5b */ unknown, unknown, unknown, unknown, "Mode Sense (10)", unknown,
46 /* 5c-5f */ unknown, unknown, unknown,
49 #define group(opcode) (((opcode) >> 5) & 7)
51 #define RESERVED_GROUP 0
52 #define VENDOR_GROUP 1
53 #define NOTEXT_GROUP 2
55 static const char **commands[] = {
56 group_0_commands, group_1_commands, group_2_commands,
57 (const char **) RESERVED_GROUP, (const char **) RESERVED_GROUP,
58 (const char **) NOTEXT_GROUP, (const char **) VENDOR_GROUP,
59 (const char **) VENDOR_GROUP
62 static const char reserved[] = "RESERVED";
63 static const char vendor[] = "VENDOR SPECIFIC";
65 static void print_opcodek(unsigned char opcode)
67 const char **table = commands[ group(opcode) ];
69 switch ((unsigned long) table) {
71 printk("%s[%02x] ", reserved, opcode);
74 printk("%s(notext)[%02x] ", unknown, opcode);
77 printk("%s[%02x] ", vendor, opcode);
80 if (table[opcode & 0x1f] != unknown)
81 printk("%s[%02x] ", table[opcode & 0x1f], opcode);
83 printk("%s[%02x] ", unknown, opcode);
88 static void print_commandk (unsigned char *command)
92 print_opcodek(command[0]);
93 /*printk(KERN_DEBUG "%s ", __FUNCTION__);*/
94 if ((command[0] >> 5) == 6 ||
95 (command[0] >> 5) == 7 ) {
96 s = 12; /* vender specific */
98 s = COMMAND_SIZE(command[0]);
100 for ( i = 1; i < s; ++i) {
101 printk("%02x ", command[i]);
106 printk("LBA=%d len=%d",
107 (((unsigned int)command[1] & 0x0f) << 16) |
108 ( (unsigned int)command[2] << 8) |
109 ( (unsigned int)command[3] ),
110 (unsigned int)command[4]
114 printk("LBA=%d len=%d",
115 ((unsigned int)command[2] << 24) |
116 ((unsigned int)command[3] << 16) |
117 ((unsigned int)command[4] << 8) |
118 ((unsigned int)command[5] ),
119 ((unsigned int)command[7] << 8) |
120 ((unsigned int)command[8] )
124 printk("LBA=%d len=%d",
125 ((unsigned int)command[2] << 24) |
126 ((unsigned int)command[3] << 16) |
127 ((unsigned int)command[4] << 8) |
128 ((unsigned int)command[5] ),
129 ((unsigned int)command[6] << 24) |
130 ((unsigned int)command[7] << 16) |
131 ((unsigned int)command[8] << 8) |
132 ((unsigned int)command[9] )
141 static void show_command(Scsi_Cmnd *SCpnt)
143 print_commandk(SCpnt->cmnd);
146 static void show_phase(Scsi_Cmnd *SCpnt)
148 int i = SCpnt->SCp.phase;
164 if ( i < PH_UNDETERMINED || i > PH_RESELECT ) {
165 printk(KERN_DEBUG "scsi phase: unknown(%d)\n", i);
169 printk(KERN_DEBUG "scsi phase: %s\n", ph[i]);
174 static void show_busphase(unsigned char stat)
177 case BUSPHASE_COMMAND:
178 printk(KERN_DEBUG "BUSPHASE_COMMAND\n");
180 case BUSPHASE_MESSAGE_IN:
181 printk(KERN_DEBUG "BUSPHASE_MESSAGE_IN\n");
183 case BUSPHASE_MESSAGE_OUT:
184 printk(KERN_DEBUG "BUSPHASE_MESSAGE_OUT\n");
186 case BUSPHASE_DATA_IN:
187 printk(KERN_DEBUG "BUSPHASE_DATA_IN\n");
189 case BUSPHASE_DATA_OUT:
190 printk(KERN_DEBUG "BUSPHASE_DATA_OUT\n");
192 case BUSPHASE_STATUS:
193 printk(KERN_DEBUG "BUSPHASE_STATUS\n");
195 case BUSPHASE_SELECT:
196 printk(KERN_DEBUG "BUSPHASE_SELECT\n");
199 printk(KERN_DEBUG "BUSPHASE_other\n");
204 static void show_message(nsp_hw_data *data)
208 printk(KERN_DEBUG "msg:");
209 for(i=0; i < data->MsgLen; i++) {
210 printk(" %02x", data->MsgBuffer[i]);