scsi-bus: Add SCSI scanner support

Add support for missing scanner specific SCSI commands and their xfer
lenghts as per ANSI spec section 15.

Signed-off-by: Jarkko Lavinen <jarkko.lavinen@iki.fi>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
Jarkko Lavinen 2016-06-28 21:51:52 +03:00 committed by Paolo Bonzini
parent a91a4e7d8c
commit 297b044a7f
2 changed files with 37 additions and 0 deletions

View File

@ -1132,6 +1132,29 @@ static int scsi_req_medium_changer_xfer(SCSICommand *cmd, SCSIDevice *dev, uint8
return 0;
}
static int scsi_req_scanner_length(SCSICommand *cmd, SCSIDevice *dev, uint8_t *buf)
{
switch (buf[0]) {
/* Scanner commands */
case OBJECT_POSITION:
cmd->xfer = 0;
break;
case SCAN:
cmd->xfer = buf[4];
break;
case READ_10:
case SEND:
case GET_WINDOW:
case SET_WINDOW:
cmd->xfer = buf[8] | (buf[7] << 8) | (buf[6] << 16);
break;
default:
/* GET_DATA_BUFFER_STATUS xfer handled by scsi_req_xfer */
return scsi_req_xfer(cmd, dev, buf);
}
return 0;
}
static void scsi_cmd_xfer_mode(SCSICommand *cmd)
{
@ -1178,6 +1201,11 @@ static void scsi_cmd_xfer_mode(SCSICommand *cmd)
case SEND_DVD_STRUCTURE:
case PERSISTENT_RESERVE_OUT:
case MAINTENANCE_OUT:
case SET_WINDOW:
case SCAN:
/* SCAN conflicts with START_STOP. START_STOP has cmd->xfer set to 0 for
* non-scanner devices, so we only get here for SCAN and not for START_STOP.
*/
cmd->mode = SCSI_XFER_TO_DEV;
break;
case ATA_PASSTHROUGH_12:
@ -1258,6 +1286,9 @@ int scsi_req_parse_cdb(SCSIDevice *dev, SCSICommand *cmd, uint8_t *buf)
case TYPE_MEDIUM_CHANGER:
rc = scsi_req_medium_changer_xfer(cmd, dev, buf);
break;
case TYPE_SCANNER:
rc = scsi_req_scanner_length(cmd, dev, buf);
break;
default:
rc = scsi_req_xfer(cmd, dev, buf);
break;

View File

@ -48,13 +48,17 @@
#define ERASE 0x19
#define MODE_SENSE 0x1a
#define LOAD_UNLOAD 0x1b
#define SCAN 0x1b
#define START_STOP 0x1b
#define RECEIVE_DIAGNOSTIC 0x1c
#define SEND_DIAGNOSTIC 0x1d
#define ALLOW_MEDIUM_REMOVAL 0x1e
#define SET_WINDOW 0x24
#define READ_CAPACITY_10 0x25
#define GET_WINDOW 0x25
#define READ_10 0x28
#define WRITE_10 0x2a
#define SEND 0x2a
#define SEEK_10 0x2b
#define LOCATE_10 0x2b
#define POSITION_TO_ELEMENT 0x2b
@ -62,10 +66,12 @@
#define VERIFY_10 0x2f
#define SEARCH_HIGH 0x30
#define SEARCH_EQUAL 0x31
#define OBJECT_POSITION 0x31
#define SEARCH_LOW 0x32
#define SET_LIMITS 0x33
#define PRE_FETCH 0x34
#define READ_POSITION 0x34
#define GET_DATA_BUFFER_STATUS 0x34
#define SYNCHRONIZE_CACHE 0x35
#define LOCK_UNLOCK_CACHE 0x36
#define INITIALIZE_ELEMENT_STATUS_WITH_RANGE 0x37