2 * Virtio-SCSI definitions for s390 machine loader for qemu
4 * Copyright 2015 IBM Corp.
5 * Author: Eugene "jno" Dvurechenski <jno@linux.vnet.ibm.com>
7 * This work is licensed under the terms of the GNU GPL, version 2 or (at
8 * your option) any later version. See the COPYING file in the top-level
19 #define VIRTIO_SCSI_CDB_SIZE SCSI_DEFAULT_CDB_SIZE
20 #define VIRTIO_SCSI_SENSE_SIZE SCSI_DEFAULT_SENSE_SIZE
22 /* command-specific response values */
23 #define VIRTIO_SCSI_S_OK 0x00
24 #define VIRTIO_SCSI_S_BAD_TARGET 0x03
26 #define QEMU_CDROM_SIGNATURE "QEMU CD-ROM "
28 enum virtio_scsi_vq_id {
34 struct VirtioScsiCmdReq {
37 uint8_t task_attr; /* = 0 = VIRTIO_SCSI_S_SIMPLE */
39 uint8_t crn; /* = 0 */
40 uint8_t cdb[VIRTIO_SCSI_CDB_SIZE];
41 } __attribute__((packed));
42 typedef struct VirtioScsiCmdReq VirtioScsiCmdReq;
44 struct VirtioScsiCmdResp {
47 uint16_t status_qualifier;
48 uint8_t status; /* first check for .response */
49 uint8_t response; /* then for .status */
50 uint8_t sense[VIRTIO_SCSI_SENSE_SIZE];
51 } __attribute__((packed));
52 typedef struct VirtioScsiCmdResp VirtioScsiCmdResp;
54 static inline const char *virtio_scsi_response_msg(const VirtioScsiCmdResp *r)
56 static char err_msg[] = "VS RESP=XX";
57 uint8_t v = r->response;
59 fill_hex_val(err_msg + 8, &v, 1);
63 static inline bool virtio_scsi_response_ok(const VirtioScsiCmdResp *r)
65 return r->response == VIRTIO_SCSI_S_OK && r->status == CDB_STATUS_GOOD;
68 void virtio_scsi_setup(VDev *vdev);
69 int virtio_scsi_read_many(VDev *vdev,
70 ulong sector, void *load_addr, int sec_num);
72 #endif /* VIRTIO_SCSI_H */