[SeaBIOS] [PATCH v3] pvscsi boot support
Signed-off-by: Evgeny Budilovsky evgeny.budilov...@ravellosystems.com --- Makefile |2 +- src/Kconfig | 12 ++ src/block.c |1 + src/block.h |1 + src/hw/blockcmd.c |3 + src/hw/pci_ids.h |3 + src/hw/pvscsi.c | 365 + src/hw/pvscsi.h |8 ++ src/post.c|2 + 9 files changed, 396 insertions(+), 1 deletion(-) create mode 100644 src/hw/pvscsi.c create mode 100644 src/hw/pvscsi.h diff --git a/Makefile b/Makefile index 3218970..6c6302e 100644 --- a/Makefile +++ b/Makefile @@ -34,7 +34,7 @@ SRCBOTH=misc.c stacks.c output.c string.c x86.c block.c cdrom.c mouse.c kbd.c \ hw/usb-hid.c hw/usb-msc.c hw/usb-uas.c \ hw/blockcmd.c hw/floppy.c hw/ata.c hw/ahci.c hw/ramdisk.c \ hw/virtio-ring.c hw/virtio-pci.c hw/virtio-blk.c hw/virtio-scsi.c \ -hw/lsi-scsi.c hw/esp-scsi.c hw/megasas.c +hw/lsi-scsi.c hw/esp-scsi.c hw/megasas.c hw/pvscsi.c SRC16=$(SRCBOTH) system.c disk.c font.c SRC32FLAT=$(SRCBOTH) post.c memmap.c malloc.c pmm.c romfile.c optionroms.c \ boot.c bootsplash.c jpeg.c bmp.c \ diff --git a/src/Kconfig b/src/Kconfig index c40cc61..6e6814e 100644 --- a/src/Kconfig +++ b/src/Kconfig @@ -161,6 +161,18 @@ menu Hardware support default y help Support boot from virtio-scsi storage. +config PVSCSI +depends on DRIVES QEMU_HARDWARE +bool pvscsi controllers +default y +help +Support boot from Paravirtualized SCSI storage. This kind of storage +is mainly supported by VMware ESX hypervisor. It is commonly used +to allow fast storage access by communicating directly with the +underlying hypervisor. Enabling this type of boot will allow +booting directly from images that were imported from ESX platform, +without the need to use slower emulation of storage controllers +such as IDE. config ESP_SCSI depends on DRIVES QEMU_HARDWARE bool AMD PCscsi controllers diff --git a/src/block.c b/src/block.c index cbcf9e1..2d01f6a 100644 --- a/src/block.c +++ b/src/block.c @@ -373,6 +373,7 @@ process_op(struct disk_op_s *op) case DTYPE_LSI_SCSI: case DTYPE_ESP_SCSI: case DTYPE_MEGASAS: +case DTYPE_PVSCSI: return process_scsi_op(op); default: op-count = 0; diff --git a/src/block.h b/src/block.h index 3492806..aea6a71 100644 --- a/src/block.h +++ b/src/block.h @@ -83,6 +83,7 @@ struct drive_s { #define DTYPE_LSI_SCSI 0x0c #define DTYPE_ESP_SCSI 0x0d #define DTYPE_MEGASAS 0x0e +#define DTYPE_PVSCSI 0x0f #define MAXDESCSIZE 80 diff --git a/src/hw/blockcmd.c b/src/hw/blockcmd.c index 7bdcf38..39d3caa 100644 --- a/src/hw/blockcmd.c +++ b/src/hw/blockcmd.c @@ -14,6 +14,7 @@ #include esp-scsi.h // esp_scsi_cmd_data #include lsi-scsi.h // lsi_scsi_cmd_data #include megasas.h // megasas_cmd_data +#include pvscsi.h // pvscsi_cmd_data #include output.h // dprintf #include std/disk.h // DISK_RET_EPARAM #include string.h // memset @@ -44,6 +45,8 @@ cdb_cmd_data(struct disk_op_s *op, void *cdbcmd, u16 blocksize) return esp_scsi_cmd_data(op, cdbcmd, blocksize); case DTYPE_MEGASAS: return megasas_cmd_data(op, cdbcmd, blocksize); +case DTYPE_PVSCSI: +return pvscsi_cmd_data(op, cdbcmd, blocksize); default: op-count = 0; return DISK_RET_EPARAM; diff --git a/src/hw/pci_ids.h b/src/hw/pci_ids.h index 322d156..1cd4f72 100644 --- a/src/hw/pci_ids.h +++ b/src/hw/pci_ids.h @@ -2618,3 +2618,6 @@ #define PCI_VENDOR_ID_REDHAT_QUMRANET 0x1af4 #define PCI_DEVICE_ID_VIRTIO_BLK 0x1001 #define PCI_DEVICE_ID_VIRTIO_SCSI 0x1004 + +#define PCI_VENDOR_ID_VMWARE0x15ad +#define PCI_DEVICE_ID_VMWARE_PVSCSI 0x07C0 diff --git a/src/hw/pvscsi.c b/src/hw/pvscsi.c new file mode 100644 index 000..df5faeb --- /dev/null +++ b/src/hw/pvscsi.c @@ -0,0 +1,365 @@ +// QEMU VMWARE Paravirtualized SCSI boot support. +// +// Copyright (c) 2013 Ravello Systems LTD (http://ravellosystems.com) +// +// Authors: +// Evgeny Budilovsky evgeny.budilov...@ravellosystems.com +// +// This file may be distributed under the terms of the GNU LGPLv3 license. + +#include biosvar.h // GET_GLOBAL +#include block.h // struct drive_s +#include blockcmd.h // scsi_drive_setup +#include config.h // CONFIG_* +#include malloc.h // free +#include output.h // dprintf +#include pci.h // foreachpci +#include pci_ids.h // PCI_DEVICE_ID_VMWARE_PVSCSI +#include pci_regs.h // PCI_VENDOR_ID +#include std/disk.h // DISK_RET_SUCCESS +#include string.h // memset +#include util.h // usleep +#include pvscsi.h +#include virtio-ring.h // PAGE_SHIFT, virt_to_phys + +#define MASK(n) ((1 (n)) - 1) + +#define SIMPLE_QUEUE_TAG 0x20 + +#define PVSCSI_INTR_CMPL_0 (1 0) +#define PVSCSI_INTR_CMPL_1 (1 1) +#define
Re: [SeaBIOS] [PATCH v3] pvscsi boot support
Dear Evgeny, thank you for the patch iterations! A minor nitpick, I prefer having a verb in the commit summary. Add pvscsi boot support Also you could add your reply (the things you tested on) to the commit message. Am Sonntag, den 13.10.2013, 20:07 +0300 schrieb Evgeny Budilovsky: Signed-off-by: Evgeny Budilovsky evgeny.budilov...@ravellosystems.com --- Makefile |2 +- src/Kconfig | 12 ++ src/block.c |1 + src/block.h |1 + src/hw/blockcmd.c |3 + src/hw/pci_ids.h |3 + src/hw/pvscsi.c | 365 + src/hw/pvscsi.h |8 ++ src/post.c|2 + 9 files changed, 396 insertions(+), 1 deletion(-) create mode 100644 src/hw/pvscsi.c create mode 100644 src/hw/pvscsi.h diff --git a/Makefile b/Makefile index 3218970..6c6302e 100644 --- a/Makefile +++ b/Makefile @@ -34,7 +34,7 @@ SRCBOTH=misc.c stacks.c output.c string.c x86.c block.c cdrom.c mouse.c kbd.c \ hw/usb-hid.c hw/usb-msc.c hw/usb-uas.c \ hw/blockcmd.c hw/floppy.c hw/ata.c hw/ahci.c hw/ramdisk.c \ hw/virtio-ring.c hw/virtio-pci.c hw/virtio-blk.c hw/virtio-scsi.c \ -hw/lsi-scsi.c hw/esp-scsi.c hw/megasas.c +hw/lsi-scsi.c hw/esp-scsi.c hw/megasas.c hw/pvscsi.c SRC16=$(SRCBOTH) system.c disk.c font.c SRC32FLAT=$(SRCBOTH) post.c memmap.c malloc.c pmm.c romfile.c optionroms.c \ boot.c bootsplash.c jpeg.c bmp.c \ diff --git a/src/Kconfig b/src/Kconfig index c40cc61..6e6814e 100644 --- a/src/Kconfig +++ b/src/Kconfig @@ -161,6 +161,18 @@ menu Hardware support default y help Support boot from virtio-scsi storage. +config PVSCSI +depends on DRIVES QEMU_HARDWARE +bool pvscsi controllers Should it be capitalizied? +default y +help +Support boot from Paravirtualized SCSI storage. This kind of storage +is mainly supported by VMware ESX hypervisor. It is commonly used +to allow fast storage access by communicating directly with the +underlying hypervisor. Enabling this type of boot will allow +booting directly from images that were imported from ESX platform, »ESX platform*s*« or »from an ESX platform«? (I am no native speaker though.) To make it shorter remove the »that were«: … imported from images imported from … (as above). +without the need to use slower emulation of storage controllers +such as IDE. […] diff --git a/src/hw/pvscsi.c b/src/hw/pvscsi.c new file mode 100644 index 000..df5faeb --- /dev/null +++ b/src/hw/pvscsi.c @@ -0,0 +1,365 @@ +// QEMU VMWARE Paravirtualized SCSI boot support. +// +// Copyright (c) 2013 Ravello Systems LTD (http://ravellosystems.com) +// +// Authors: +// Evgeny Budilovsky evgeny.budilov...@ravellosystems.com +// +// This file may be distributed under the terms of the GNU LGPLv3 license. + +#include biosvar.h // GET_GLOBAL +#include block.h // struct drive_s +#include blockcmd.h // scsi_drive_setup +#include config.h // CONFIG_* +#include malloc.h // free +#include output.h // dprintf +#include pci.h // foreachpci +#include pci_ids.h // PCI_DEVICE_ID_VMWARE_PVSCSI +#include pci_regs.h // PCI_VENDOR_ID +#include std/disk.h // DISK_RET_SUCCESS +#include string.h // memset +#include util.h // usleep +#include pvscsi.h +#include virtio-ring.h // PAGE_SHIFT, virt_to_phys + +#define MASK(n) ((1 (n)) - 1) + +#define SIMPLE_QUEUE_TAG 0x20 + +#define PVSCSI_INTR_CMPL_0 (1 0) +#define PVSCSI_INTR_CMPL_1 (1 1) +#define PVSCSI_INTR_CMPL_MASK MASK(2) + +#define PVSCSI_INTR_MSG_0 (1 2) +#define PVSCSI_INTR_MSG_1 (1 3) +#define PVSCSI_INTR_MSG_MASK (MASK(2) 2) +#define PVSCSI_INTR_ALL_SUPPORTED MASK(4) + +#define PVSCSI_FLAG_CMD_WITH_SG_LIST (1 0) +#define PVSCSI_FLAG_CMD_OUT_OF_BAND_CDB(1 1) +#define PVSCSI_FLAG_CMD_DIR_NONE (1 2) +#define PVSCSI_FLAG_CMD_DIR_TOHOST (1 3) +#define PVSCSI_FLAG_CMD_DIR_TODEVICE (1 4) + +enum PVSCSIRegOffset { +PVSCSI_REG_OFFSET_COMMAND=0x0, +PVSCSI_REG_OFFSET_COMMAND_DATA =0x4, +PVSCSI_REG_OFFSET_COMMAND_STATUS =0x8, +PVSCSI_REG_OFFSET_LAST_STS_0 = 0x100, +PVSCSI_REG_OFFSET_LAST_STS_1 = 0x104, +PVSCSI_REG_OFFSET_LAST_STS_2 = 0x108, +PVSCSI_REG_OFFSET_LAST_STS_3 = 0x10c, +PVSCSI_REG_OFFSET_INTR_STATUS= 0x100c, +PVSCSI_REG_OFFSET_INTR_MASK = 0x2010, +PVSCSI_REG_OFFSET_KICK_NON_RW_IO = 0x3014, +PVSCSI_REG_OFFSET_DEBUG = 0x3018, +PVSCSI_REG_OFFSET_KICK_RW_IO = 0x4018, +}; + +enum PVSCSICommands { +PVSCSI_CMD_FIRST = 0, +PVSCSI_CMD_ADAPTER_RESET = 1, +PVSCSI_CMD_ISSUE_SCSI= 2, +