cpupower: fix Makefile typo
[linux-2.6.git] / drivers / scsi / pcmcia / nsp_debug.c
blob6aa7d269d3b3b7170eb929b0e8212e33a3f1c31a
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, "Reassign 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) {
70 case RESERVED_GROUP:
71 printk("%s[%02x] ", reserved, opcode);
72 break;
73 case NOTEXT_GROUP:
74 printk("%s(notext)[%02x] ", unknown, opcode);
75 break;
76 case VENDOR_GROUP:
77 printk("%s[%02x] ", vendor, opcode);
78 break;
79 default:
80 if (table[opcode & 0x1f] != unknown)
81 printk("%s[%02x] ", table[opcode & 0x1f], opcode);
82 else
83 printk("%s[%02x] ", unknown, opcode);
84 break;
88 static void print_commandk (unsigned char *command)
90 int i, s;
91 printk(KERN_DEBUG);
92 print_opcodek(command[0]);
93 /*printk(KERN_DEBUG "%s ", __func__);*/
94 if ((command[0] >> 5) == 6 ||
95 (command[0] >> 5) == 7 ) {
96 s = 12; /* vender specific */
97 } else {
98 s = COMMAND_SIZE(command[0]);
100 for ( i = 1; i < s; ++i) {
101 printk("%02x ", command[i]);
104 switch (s) {
105 case 6:
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]
112 break;
113 case 10:
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] )
122 break;
123 case 12:
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] )
134 break;
135 default:
136 break;
138 printk("\n");
141 static void show_command(struct scsi_cmnd *SCpnt)
143 print_commandk(SCpnt->cmnd);
146 static void show_phase(struct scsi_cmnd *SCpnt)
148 int i = SCpnt->SCp.phase;
150 char *ph[] = {
151 "PH_UNDETERMINED",
152 "PH_ARBSTART",
153 "PH_SELSTART",
154 "PH_SELECTED",
155 "PH_COMMAND",
156 "PH_DATA",
157 "PH_STATUS",
158 "PH_MSG_IN",
159 "PH_MSG_OUT",
160 "PH_DISCONNECT",
161 "PH_RESELECT"
164 if ( i < PH_UNDETERMINED || i > PH_RESELECT ) {
165 printk(KERN_DEBUG "scsi phase: unknown(%d)\n", i);
166 return;
169 printk(KERN_DEBUG "scsi phase: %s\n", ph[i]);
171 return;
174 static void show_busphase(unsigned char stat)
176 switch(stat) {
177 case BUSPHASE_COMMAND:
178 printk(KERN_DEBUG "BUSPHASE_COMMAND\n");
179 break;
180 case BUSPHASE_MESSAGE_IN:
181 printk(KERN_DEBUG "BUSPHASE_MESSAGE_IN\n");
182 break;
183 case BUSPHASE_MESSAGE_OUT:
184 printk(KERN_DEBUG "BUSPHASE_MESSAGE_OUT\n");
185 break;
186 case BUSPHASE_DATA_IN:
187 printk(KERN_DEBUG "BUSPHASE_DATA_IN\n");
188 break;
189 case BUSPHASE_DATA_OUT:
190 printk(KERN_DEBUG "BUSPHASE_DATA_OUT\n");
191 break;
192 case BUSPHASE_STATUS:
193 printk(KERN_DEBUG "BUSPHASE_STATUS\n");
194 break;
195 case BUSPHASE_SELECT:
196 printk(KERN_DEBUG "BUSPHASE_SELECT\n");
197 break;
198 default:
199 printk(KERN_DEBUG "BUSPHASE_other\n");
200 break;
204 static void show_message(nsp_hw_data *data)
206 int i;
208 printk(KERN_DEBUG "msg:");
209 for(i=0; i < data->MsgLen; i++) {
210 printk(" %02x", data->MsgBuffer[i]);
212 printk("\n");
215 /* end */