Revision a1f0cce2 hw/scsi-bus.c
b/hw/scsi-bus.c | ||
---|---|---|
154 | 154 |
QTAILQ_INSERT_TAIL(&req->dev->requests, req, next); |
155 | 155 |
} |
156 | 156 |
|
157 |
void scsi_req_dequeue(SCSIRequest *req) |
|
157 |
static void scsi_req_dequeue(SCSIRequest *req)
|
|
158 | 158 |
{ |
159 | 159 |
trace_scsi_req_dequeue(req->dev->id, req->lun, req->tag); |
160 | 160 |
if (req->enqueued) { |
... | ... | |
391 | 391 |
return 0; |
392 | 392 |
} |
393 | 393 |
|
394 |
/* |
|
395 |
* Predefined sense codes |
|
396 |
*/ |
|
397 |
|
|
398 |
/* No sense data available */ |
|
399 |
const struct SCSISense sense_code_NO_SENSE = { |
|
400 |
.key = NO_SENSE , .asc = 0x00 , .ascq = 0x00 |
|
401 |
}; |
|
402 |
|
|
403 |
/* LUN not ready, Manual intervention required */ |
|
404 |
const struct SCSISense sense_code_LUN_NOT_READY = { |
|
405 |
.key = NOT_READY, .asc = 0x04, .ascq = 0x03 |
|
406 |
}; |
|
407 |
|
|
408 |
/* LUN not ready, Medium not present */ |
|
409 |
const struct SCSISense sense_code_NO_MEDIUM = { |
|
410 |
.key = NOT_READY, .asc = 0x3a, .ascq = 0x00 |
|
411 |
}; |
|
412 |
|
|
413 |
/* Hardware error, internal target failure */ |
|
414 |
const struct SCSISense sense_code_TARGET_FAILURE = { |
|
415 |
.key = HARDWARE_ERROR, .asc = 0x44, .ascq = 0x00 |
|
416 |
}; |
|
417 |
|
|
418 |
/* Illegal request, invalid command operation code */ |
|
419 |
const struct SCSISense sense_code_INVALID_OPCODE = { |
|
420 |
.key = ILLEGAL_REQUEST, .asc = 0x20, .ascq = 0x00 |
|
421 |
}; |
|
422 |
|
|
423 |
/* Illegal request, LBA out of range */ |
|
424 |
const struct SCSISense sense_code_LBA_OUT_OF_RANGE = { |
|
425 |
.key = ILLEGAL_REQUEST, .asc = 0x21, .ascq = 0x00 |
|
426 |
}; |
|
427 |
|
|
428 |
/* Illegal request, Invalid field in CDB */ |
|
429 |
const struct SCSISense sense_code_INVALID_FIELD = { |
|
430 |
.key = ILLEGAL_REQUEST, .asc = 0x24, .ascq = 0x00 |
|
431 |
}; |
|
432 |
|
|
433 |
/* Illegal request, LUN not supported */ |
|
434 |
const struct SCSISense sense_code_LUN_NOT_SUPPORTED = { |
|
435 |
.key = ILLEGAL_REQUEST, .asc = 0x25, .ascq = 0x00 |
|
436 |
}; |
|
437 |
|
|
438 |
/* Command aborted, I/O process terminated */ |
|
439 |
const struct SCSISense sense_code_IO_ERROR = { |
|
440 |
.key = ABORTED_COMMAND, .asc = 0x00, .ascq = 0x06 |
|
441 |
}; |
|
442 |
|
|
443 |
/* Command aborted, I_T Nexus loss occurred */ |
|
444 |
const struct SCSISense sense_code_I_T_NEXUS_LOSS = { |
|
445 |
.key = ABORTED_COMMAND, .asc = 0x29, .ascq = 0x07 |
|
446 |
}; |
|
447 |
|
|
448 |
/* Command aborted, Logical Unit failure */ |
|
449 |
const struct SCSISense sense_code_LUN_FAILURE = { |
|
450 |
.key = ABORTED_COMMAND, .asc = 0x3e, .ascq = 0x01 |
|
451 |
}; |
|
452 |
|
|
453 |
/* |
|
454 |
* scsi_build_sense |
|
455 |
* |
|
456 |
* Build a sense buffer |
|
457 |
*/ |
|
458 |
int scsi_build_sense(SCSISense sense, uint8_t *buf, int len, int fixed) |
|
459 |
{ |
|
460 |
if (!fixed && len < 8) { |
|
461 |
return 0; |
|
462 |
} |
|
463 |
|
|
464 |
memset(buf, 0, len); |
|
465 |
if (fixed) { |
|
466 |
/* Return fixed format sense buffer */ |
|
467 |
buf[0] = 0xf0; |
|
468 |
buf[2] = sense.key; |
|
469 |
buf[7] = 7; |
|
470 |
buf[12] = sense.asc; |
|
471 |
buf[13] = sense.ascq; |
|
472 |
return MIN(len, 18); |
|
473 |
} else { |
|
474 |
/* Return descriptor format sense buffer */ |
|
475 |
buf[0] = 0x72; |
|
476 |
buf[1] = sense.key; |
|
477 |
buf[2] = sense.asc; |
|
478 |
buf[3] = sense.ascq; |
|
479 |
return 8; |
|
480 |
} |
|
481 |
} |
|
482 |
|
|
394 | 483 |
static const char *scsi_command_name(uint8_t cmd) |
395 | 484 |
{ |
396 | 485 |
static const char *names[] = { |
Also available in: Unified diff