aboutsummaryrefslogtreecommitdiff
path: root/pc-bios/s390-ccw/virtio-scsi.h
diff options
context:
space:
mode:
authorPeter Maydell <peter.maydell@linaro.org>2016-03-24 16:24:02 +0000
committerPeter Maydell <peter.maydell@linaro.org>2016-03-24 16:24:02 +0000
commitb68a80139e37e806f004237e55311ebc42151434 (patch)
tree66f14ec7ad073233859ce30b2563b38e72f9a71f /pc-bios/s390-ccw/virtio-scsi.h
parentf18f2e7cfcdc31d7f82af15947aae60c4b16e131 (diff)
parentce11b0622268dc8133bb4954c1e3fae0c23b6609 (diff)
Merge remote-tracking branch 'remotes/cohuck/tags/s390x-20160324' into staging
Support for booting from virtio-scsi devices in the s390-ccw bios. # gpg: Signature made Thu 24 Mar 2016 08:14:21 GMT using RSA key ID C6F02FAF # gpg: Good signature from "Cornelia Huck <huckc@linux.vnet.ibm.com>" # gpg: aka "Cornelia Huck <cornelia.huck@de.ibm.com>" * remotes/cohuck/tags/s390x-20160324: s390-ccw.img: rebuild image pc-bios/s390-ccw: disambiguation of "No zIPL magic" message pc-bios/s390-ccw: enhance bootmap detection pc-bios/s390-ccw: enable virtio-scsi pc-bios/s390-ccw: add virtio-scsi implementation pc-bios/s390-ccw: add scsi definitions pc-bios/s390-ccw: add simplified virtio call pc-bios/s390-ccw: make provisions for different backends pc-bios/s390-ccw: add vdev object to store all device details pc-bios/s390-ccw: update virtio implementation to allow up to 3 vrings pc-bios/s390-ccw: qemuize types pc-bios/s390-ccw: add utility functions and "export" some others pc-bios/s390-ccw: virtio_panic -> panic pc-bios/s390-ccw: add more disk layout checks Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'pc-bios/s390-ccw/virtio-scsi.h')
-rw-r--r--pc-bios/s390-ccw/virtio-scsi.h72
1 files changed, 72 insertions, 0 deletions
diff --git a/pc-bios/s390-ccw/virtio-scsi.h b/pc-bios/s390-ccw/virtio-scsi.h
new file mode 100644
index 0000000000..f50b38b18b
--- /dev/null
+++ b/pc-bios/s390-ccw/virtio-scsi.h
@@ -0,0 +1,72 @@
+/*
+ * Virtio-SCSI definitions for s390 machine loader for qemu
+ *
+ * Copyright 2015 IBM Corp.
+ * Author: Eugene "jno" Dvurechenski <jno@linux.vnet.ibm.com>
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or (at
+ * your option) any later version. See the COPYING file in the top-level
+ * directory.
+ */
+
+#ifndef VIRTIO_SCSI_H
+#define VIRTIO_SCSI_H
+
+#include "s390-ccw.h"
+#include "virtio.h"
+#include "scsi.h"
+
+#define VIRTIO_SCSI_CDB_SIZE SCSI_DEFAULT_CDB_SIZE
+#define VIRTIO_SCSI_SENSE_SIZE SCSI_DEFAULT_SENSE_SIZE
+
+/* command-specific response values */
+#define VIRTIO_SCSI_S_OK 0x00
+#define VIRTIO_SCSI_S_BAD_TARGET 0x03
+
+#define QEMU_CDROM_SIGNATURE "QEMU CD-ROM "
+
+enum virtio_scsi_vq_id {
+ VR_CONTROL = 0,
+ VR_EVENT = 1,
+ VR_REQUEST = 2,
+};
+
+struct VirtioScsiCmdReq {
+ ScsiLun lun;
+ uint64_t id;
+ uint8_t task_attr; /* = 0 = VIRTIO_SCSI_S_SIMPLE */
+ uint8_t prio;
+ uint8_t crn; /* = 0 */
+ uint8_t cdb[VIRTIO_SCSI_CDB_SIZE];
+} __attribute__((packed));
+typedef struct VirtioScsiCmdReq VirtioScsiCmdReq;
+
+struct VirtioScsiCmdResp {
+ uint32_t sense_len;
+ uint32_t residual;
+ uint16_t status_qualifier;
+ uint8_t status; /* first check for .response */
+ uint8_t response; /* then for .status */
+ uint8_t sense[VIRTIO_SCSI_SENSE_SIZE];
+} __attribute__((packed));
+typedef struct VirtioScsiCmdResp VirtioScsiCmdResp;
+
+static inline const char *virtio_scsi_response_msg(const VirtioScsiCmdResp *r)
+{
+ static char err_msg[] = "VS RESP=XX";
+ uint8_t v = r->response;
+
+ fill_hex_val(err_msg + 8, &v, 1);
+ return err_msg;
+}
+
+static inline bool virtio_scsi_response_ok(const VirtioScsiCmdResp *r)
+{
+ return r->response == VIRTIO_SCSI_S_OK && r->status == CDB_STATUS_GOOD;
+}
+
+void virtio_scsi_setup(VDev *vdev);
+int virtio_scsi_read_many(VDev *vdev,
+ ulong sector, void *load_addr, int sec_num);
+
+#endif /* VIRTIO_SCSI_H */