scsi: move sense to SCSIDevice, create SCSISense struct.
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
This commit is contained in:
parent
97a0643567
commit
37659e5104
@ -113,6 +113,16 @@ void scsi_bus_legacy_handle_cmdline(SCSIBus *bus)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void scsi_dev_clear_sense(SCSIDevice *dev)
|
||||||
|
{
|
||||||
|
memset(&dev->sense, 0, sizeof(dev->sense));
|
||||||
|
}
|
||||||
|
|
||||||
|
void scsi_dev_set_sense(SCSIDevice *dev, uint8_t key)
|
||||||
|
{
|
||||||
|
dev->sense.key = key;
|
||||||
|
}
|
||||||
|
|
||||||
SCSIRequest *scsi_req_alloc(size_t size, SCSIDevice *d, uint32_t tag, uint32_t lun)
|
SCSIRequest *scsi_req_alloc(size_t size, SCSIDevice *d, uint32_t tag, uint32_t lun)
|
||||||
{
|
{
|
||||||
SCSIRequest *req;
|
SCSIRequest *req;
|
||||||
|
@ -59,7 +59,6 @@ struct SCSIDiskState
|
|||||||
This is the number of 512 byte blocks in a single scsi sector. */
|
This is the number of 512 byte blocks in a single scsi sector. */
|
||||||
int cluster_size;
|
int cluster_size;
|
||||||
uint64_t max_lba;
|
uint64_t max_lba;
|
||||||
int sense;
|
|
||||||
char drive_serial_str[21];
|
char drive_serial_str[21];
|
||||||
QEMUBH *bh;
|
QEMUBH *bh;
|
||||||
};
|
};
|
||||||
@ -93,7 +92,7 @@ static void scsi_command_complete(SCSIDiskReq *r, int status, int sense)
|
|||||||
uint32_t tag;
|
uint32_t tag;
|
||||||
DPRINTF("Command complete tag=0x%x status=%d sense=%d\n",
|
DPRINTF("Command complete tag=0x%x status=%d sense=%d\n",
|
||||||
r->req.tag, status, sense);
|
r->req.tag, status, sense);
|
||||||
s->sense = sense;
|
scsi_dev_set_sense(&s->qdev, sense);
|
||||||
tag = r->req.tag;
|
tag = r->req.tag;
|
||||||
r->req.bus->complete(r->req.bus, SCSI_REASON_DONE, tag, status);
|
r->req.bus->complete(r->req.bus, SCSI_REASON_DONE, tag, status);
|
||||||
scsi_remove_request(r);
|
scsi_remove_request(r);
|
||||||
@ -394,7 +393,7 @@ static int32_t scsi_send_command(SCSIDevice *d, uint32_t tag,
|
|||||||
goto fail;
|
goto fail;
|
||||||
memset(outbuf, 0, 4);
|
memset(outbuf, 0, 4);
|
||||||
r->iov.iov_len = 4;
|
r->iov.iov_len = 4;
|
||||||
if (s->sense == NOT_READY && len >= 18) {
|
if (s->qdev.sense.key == NOT_READY && len >= 18) {
|
||||||
memset(outbuf, 0, 18);
|
memset(outbuf, 0, 18);
|
||||||
r->iov.iov_len = 18;
|
r->iov.iov_len = 18;
|
||||||
outbuf[7] = 10;
|
outbuf[7] = 10;
|
||||||
@ -404,7 +403,8 @@ static int32_t scsi_send_command(SCSIDevice *d, uint32_t tag,
|
|||||||
}
|
}
|
||||||
outbuf[0] = 0xf0;
|
outbuf[0] = 0xf0;
|
||||||
outbuf[1] = 0;
|
outbuf[1] = 0;
|
||||||
outbuf[2] = s->sense;
|
outbuf[2] = s->qdev.sense.key;
|
||||||
|
scsi_dev_clear_sense(&s->qdev);
|
||||||
break;
|
break;
|
||||||
case INQUIRY:
|
case INQUIRY:
|
||||||
DPRINTF("Inquiry (len %d)\n", len);
|
DPRINTF("Inquiry (len %d)\n", len);
|
||||||
|
@ -24,6 +24,10 @@ enum SCSIXferMode {
|
|||||||
SCSI_XFER_TO_DEV, /* WRITE, MODE_SELECT, ... */
|
SCSI_XFER_TO_DEV, /* WRITE, MODE_SELECT, ... */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
typedef struct SCSISense {
|
||||||
|
uint8_t key;
|
||||||
|
} SCSISense;
|
||||||
|
|
||||||
typedef struct SCSIRequest {
|
typedef struct SCSIRequest {
|
||||||
SCSIBus *bus;
|
SCSIBus *bus;
|
||||||
SCSIDevice *dev;
|
SCSIDevice *dev;
|
||||||
@ -48,6 +52,7 @@ struct SCSIDevice
|
|||||||
QTAILQ_HEAD(, SCSIRequest) requests;
|
QTAILQ_HEAD(, SCSIRequest) requests;
|
||||||
int blocksize;
|
int blocksize;
|
||||||
int type;
|
int type;
|
||||||
|
struct SCSISense sense;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* cdrom.c */
|
/* cdrom.c */
|
||||||
@ -92,9 +97,13 @@ static inline SCSIBus *scsi_bus_from_device(SCSIDevice *d)
|
|||||||
SCSIDevice *scsi_bus_legacy_add_drive(SCSIBus *bus, DriveInfo *dinfo, int unit);
|
SCSIDevice *scsi_bus_legacy_add_drive(SCSIBus *bus, DriveInfo *dinfo, int unit);
|
||||||
void scsi_bus_legacy_handle_cmdline(SCSIBus *bus);
|
void scsi_bus_legacy_handle_cmdline(SCSIBus *bus);
|
||||||
|
|
||||||
|
void scsi_dev_clear_sense(SCSIDevice *dev);
|
||||||
|
void scsi_dev_set_sense(SCSIDevice *dev, uint8_t key);
|
||||||
|
|
||||||
SCSIRequest *scsi_req_alloc(size_t size, SCSIDevice *d, uint32_t tag, uint32_t lun);
|
SCSIRequest *scsi_req_alloc(size_t size, SCSIDevice *d, uint32_t tag, uint32_t lun);
|
||||||
SCSIRequest *scsi_req_find(SCSIDevice *d, uint32_t tag);
|
SCSIRequest *scsi_req_find(SCSIDevice *d, uint32_t tag);
|
||||||
void scsi_req_free(SCSIRequest *req);
|
void scsi_req_free(SCSIRequest *req);
|
||||||
|
|
||||||
int scsi_req_parse(SCSIRequest *req, uint8_t *buf);
|
int scsi_req_parse(SCSIRequest *req, uint8_t *buf);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user