| NUC472_NUC442_BSP V3.03.003 The Board Support Package for NUC472/NUC442

UmasDebug.c
Go to the documentation of this file.
1/* Driver for USB Mass Storage compliant devices
2 * Debugging Functions Source Code File
3 *
4 * $Id: debug.c,v 1.4 2000/09/04 02:12:47 groovyjava Exp $
5 *
6 * Current development and maintenance by:
7 * (c) 1999, 2000 Matthew Dharm (mdharm-usb@one-eyed-alien.net)
8 *
9 * Initial work by:
10 * (c) 1999 Michael Gee (michael@linuxspecific.com)
11 *
12 * This driver is based on the 'USB Mass Storage Class' document. This
13 * describes in detail the protocol used to communicate with such
14 * devices. Clearly, the designers had SCSI and ATAPI commands in
15 * mind when they created this document. The commands are all very
16 * similar to commands in the SCSI-II and ATAPI specifications.
17 *
18 * It is important to note that in a number of cases this class
19 * exhibits class-specific exemptions from the USB specification.
20 * Notably the usage of NAK, STALL and ACK differs from the norm, in
21 * that they are used to communicate wait, failed and OK on commands.
22 *
23 * Also, for certain devices, the interrupt endpoint is used to convey
24 * status of a command.
25 *
26 * Please see http://www.one-eyed-alien.net/~mdharm/linux-usb for more
27 * information about this driver.
28 *
29 * This program is free software; you can redistribute it and/or modify it
30 * under the terms of the GNU General Public License as published by the
31 * Free Software Foundation; either version 2, or (at your option) any
32 * later version.
33 *
34 * This program is distributed in the hope that it will be useful, but
35 * WITHOUT ANY WARRANTY; without even the implied warranty of
36 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
37 * General Public License for more details.
38 *
39 * You should have received a copy of the GNU General Public License along
40 * with this program; if not, write to the Free Software Foundation, Inc.,
41 * 675 Mass Ave, Cambridge, MA 02139, USA.
42 */
43
44/**************************************************************************/
54#include <stdio.h>
55#include <string.h>
56#include "NUC472_442.h"
57#include "usbh_core.h"
58#include "Umas.h"
59
61
62 void UMAS_DEBUG_ShowCommand(SCSI_CMD_T *srb)
63{
64#ifdef DEBUG
65 int i;
66 char *what = NULL;
67
68 switch (srb->cmnd[0])
69 {
70 case TEST_UNIT_READY:
71
72 what = "TEST_UNIT_READY";
73 break;
74 case REZERO_UNIT:
75
76 what = "REZERO_UNIT";
77 break;
78
79 case REQUEST_SENSE:
80 what = "REQUEST_SENSE";
81 break;
82
83 case FORMAT_UNIT:
84 what = "FORMAT_UNIT";
85 break;
86
87 case READ_BLOCK_LIMITS:
88 what = "READ_BLOCK_LIMITS";
89 break;
90
91 case REASSIGN_BLOCKS:
92 what = "REASSIGN_BLOCKS";
93 break;
94
95 case READ_6:
96 what = "READ_6";
97 break;
98
99 case WRITE_6:
100 what = "WRITE_6";
101 break;
102
103 case SEEK_6:
104 what = "SEEK_6";
105 break;
106
107 case READ_REVERSE:
108 what = "READ_REVERSE";
109 break;
110
111 case WRITE_FILEMARKS:
112 what = "WRITE_FILEMARKS";
113 break;
114
115 case SPACE:
116 what = "SPACE";
117 break;
118
119 case INQUIRY:
120 what = "INQUIRY";
121 break;
122
123 case RECOVER_BUFFERED_DATA:
124 what = "RECOVER_BUFFERED_DATA";
125 break;
126
127 case MODE_SELECT:
128 what = "MODE_SELECT";
129 break;
130
131 case RESERVE:
132 what = "RESERVE";
133 break;
134
135 case RELEASE:
136 what = "RELEASE";
137 break;
138
139 case COPY:
140 what = "COPY";
141 break;
142
143 case ERASE:
144 what = "ERASE";
145 break;
146
147 case MODE_SENSE:
148 what = "MODE_SENSE";
149 break;
150 case START_STOP:
151 what = "START_STOP";
152 break;
153
154 case RECEIVE_DIAGNOSTIC:
155 what = "RECEIVE_DIAGNOSTIC";
156 break;
157
158 case SEND_DIAGNOSTIC:
159 what = "SEND_DIAGNOSTIC";
160 break;
161
162 case ALLOW_MEDIUM_REMOVAL:
163 what = "ALLOW_MEDIUM_REMOVAL";
164 break;
165
166 case SET_WINDOW:
167 what = "SET_WINDOW";
168 break;
169
170 case READ_CAPACITY:
171 what = "READ_CAPACITY";
172 break;
173
174 case READ_10:
175 what = "READ_10";
176 break;
177
178 case WRITE_10:
179 what = "WRITE_10";
180 break;
181
182 case SEEK_10:
183 what = "SEEK_10";
184 break;
185
186 case WRITE_VERIFY:
187 what = "WRITE_VERIFY";
188 break;
189
190 case VERIFY:
191 what = "VERIFY";
192 break;
193
194 case SEARCH_HIGH:
195 what = "SEARCH_HIGH";
196 break;
197
198 case SEARCH_EQUAL:
199 what = "SEARCH_EQUAL";
200 break;
201
202 case SEARCH_LOW:
203 what = "SEARCH_LOW";
204 break;
205
206 case SET_LIMITS:
207 what = "SET_LIMITS";
208 break;
209
210 case READ_POSITION:
211 what = "READ_POSITION";
212 break;
213
214 case SYNCHRONIZE_CACHE:
215 what = "SYNCHRONIZE_CACHE";
216 break;
217
218 case LOCK_UNLOCK_CACHE:
219 what = "LOCK_UNLOCK_CACHE";
220 break;
221
222 case READ_DEFECT_DATA:
223 what = "READ_DEFECT_DATA";
224 break;
225
226 case MEDIUM_SCAN:
227 what = "MEDIUM_SCAN";
228 break;
229
230 case COMPARE:
231 what = "COMPARE";
232 break;
233
234 case COPY_VERIFY:
235 what = "COPY_VERIFY";
236 break;
237
238 case WRITE_BUFFER:
239 what = "WRITE_BUFFER";
240 break;
241
242 case READ_BUFFER:
243 what = "READ_BUFFER";
244 break;
245
246 case UPDATE_BLOCK:
247 what = "UPDATE_BLOCK";
248 break;
249
250 case READ_LONG:
251 what = "READ_LONG";
252 break;
253
254 case WRITE_LONG:
255 what = "WRITE_LONG";
256 break;
257
258 case CHANGE_DEFINITION:
259 what = "CHANGE_DEFINITION";
260 break;
261
262 case WRITE_SAME:
263 what = "WRITE_SAME";
264 break;
265
266 //case GPCMD_READ_SUBCHANNEL:
267 // what = "READ SUBCHANNEL";
268 // break;
269
270 case READ_TOC:
271 what = "READ_TOC";
272 break;
273 /*
274 case GPCMD_READ_HEADER:
275 what = "READ HEADER";
276 break;
277
278 case GPCMD_PLAY_AUDIO_10:
279 what = "PLAY AUDIO (10)";
280 break;
281
282 case GPCMD_PLAY_AUDIO_MSF:
283 what = "PLAY AUDIO MSF";
284 break;
285
286 case GPCMD_GET_EVENT_STATUS_NOTIFICATION:
287 what = "GET EVENT/STATUS NOTIFICATION";
288 break;
289
290 case GPCMD_PAUSE_RESUME:
291 what = "PAUSE/RESUME";
292 break;
293 */
294 case LOG_SELECT:
295 what = "LOG_SELECT";
296 break;
297
298 case LOG_SENSE:
299 what = "LOG_SENSE";
300 break;
301 /*
302 case GPCMD_STOP_PLAY_SCAN:
303 what = "STOP PLAY/SCAN";
304 break;
305
306 case GPCMD_READ_DISC_INFO:
307 what = "READ DISC INFORMATION";
308 break;
309
310 case GPCMD_READ_TRACK_RZONE_INFO:
311 what = "READ TRACK INFORMATION";
312 break;
313
314 case GPCMD_RESERVE_RZONE_TRACK:
315 what = "RESERVE TRACK";
316 break;
317
318 case GPCMD_SEND_OPC:
319 what = "SEND OPC";
320 break;
321 */
322 case MODE_SELECT_10:
323 what = "MODE_SELECT_10";
324 break;
325 /*
326 case GPCMD_REPAIR_RZONE_TRACK:
327 what = "REPAIR TRACK";
328 break;
329 */
330 case 0x59:
331 what = "READ MASTER CUE";
332 break;
333
334 case MODE_SENSE_10:
335 what = "MODE_SENSE_10";
336 break;
337 /*
338 case GPCMD_CLOSE_TRACK:
339 what = "CLOSE TRACK/SESSION";
340 break;
341 */
342 case 0x5C:
343 what = "READ BUFFER CAPACITY";
344 break;
345
346 case 0x5D:
347 what = "SEND CUE SHEET";
348 break;
349 /*
350 case GPCMD_BLANK:
351 what = "BLANK";
352 break;
353 */
354 case MOVE_MEDIUM:
355 what = "MOVE_MEDIUM or PLAY AUDIO (12)";
356 break;
357
358 case READ_12:
359 what = "READ_12";
360 break;
361
362 case WRITE_12:
363 what = "WRITE_12";
364 break;
365
366 case WRITE_VERIFY_12:
367 what = "WRITE_VERIFY_12";
368 break;
369
370 case SEARCH_HIGH_12:
371 what = "SEARCH_HIGH_12";
372 break;
373
374 case SEARCH_EQUAL_12:
375 what = "SEARCH_EQUAL_12";
376 break;
377
378 case SEARCH_LOW_12:
379 what = "SEARCH_LOW_12";
380 break;
381
382 case SEND_VOLUME_TAG:
383 what = "SEND_VOLUME_TAG";
384 break;
385
386 case READ_ELEMENT_STATUS:
387 what = "READ_ELEMENT_STATUS";
388 break;
389 /*
390 case GPCMD_READ_CD_MSF:
391 what = "READ CD MSF";
392 break;
393
394 case GPCMD_SCAN:
395 what = "SCAN";
396 break;
397
398 case GPCMD_SET_SPEED:
399 what = "SET CD SPEED";
400 break;
401
402 case GPCMD_MECHANISM_STATUS:
403 what = "MECHANISM STATUS";
404 break;
405
406 case GPCMD_READ_CD:
407 what = "READ CD";
408 break;
409 */
410 case 0xE1:
411 what = "WRITE CONTINUE";
412 break;
413
414 case WRITE_LONG_2:
415 what = "WRITE_LONG_2";
416 break;
417
418 default:
419 what = "(unknown command)";
420 break;
421 }
422 UMAS_DEBUG("Command:[%s], (%d bytes)\n", what, srb->cmd_len);
423 for (i = 0; i < srb->cmd_len; i++)
424 UMAS_DEBUG("%02x ", srb->cmnd[i]);
425 UMAS_DEBUG("\n");
426#endif
427}
428
429
430
431 void UMAS_DEBUG_PrintScsiCommand(SCSI_CMD_T *cmd)
432{
433#ifdef DEBUG
434 int i = 0, bufferSize = cmd->request_bufflen;
435 uint8_t *buffer = cmd->request_buff;
436 SCATTER_LIST_T *sg = (SCATTER_LIST_T *)cmd->request_buff;
437
438 UMAS_DEBUG("Dumping information about %p.\n", cmd );
439 UMAS_DEBUG("cmd->cmnd[0] value is %d.\n", cmd->cmnd[0] );
440 UMAS_DEBUG("(MODE_SENSE is %d and MODE_SENSE_10 is %d)\n",
441 MODE_SENSE, MODE_SENSE_10 );
442
443 UMAS_DEBUG("buffer is %p with length %d.\n", buffer, bufferSize );
444 for (i = 0; i < bufferSize; i += 16)
445 {
446 UMAS_DEBUG("%02x %02x %02x %02x %02x %02x %02x %02x\n",
447 buffer[i], buffer[i+1], buffer[i+2], buffer[i+3],
448 buffer[i+4], buffer[i+5], buffer[i+6], buffer[i+7]);
449 UMAS_DEBUG("%02x %02x %02x %02x %02x %02x %02x %02x\n",
450 buffer[i+8], buffer[i+9], buffer[i+10], buffer[i+11],
451 buffer[i+12], buffer[i+13], buffer[i+14], buffer[i+15]);
452 }
453
454 UMAS_DEBUG("Buffer has %d scatterlists.\n", cmd->use_sg );
455 for (i = 0; i < cmd->use_sg; i++ )
456 {
457 UMAS_DEBUG("Length of scatterlist %d is %d.\n",i,sg[i].length);
458 UMAS_DEBUG("%02x %02x %02x %02x %02x %02x %02x %02x\n",
459 sg[i].address[0], sg[i].address[1], sg[i].address[2], sg[i].address[3],
460 sg[i].address[4], sg[i].address[5], sg[i].address[6], sg[i].address[7]);
461 UMAS_DEBUG("%02x %02x %02x %02x %02x %02x %02x %02x\n",
462 sg[i].address[8], sg[i].address[9], sg[i].address[10], sg[i].address[11],
463 sg[i].address[12], sg[i].address[13], sg[i].address[14], sg[i].address[15]);
464 }
465#endif
466}
467
NUC472_442.h
NUC472/NUC442 peripheral access layer header file. This file contains all the peripheral register's d...
Umas.h
NULL
#define NULL
NULL pointer.
Definition: NUC472_442.h:29018
usbh_core.h
USB Host core driver header file.