Add initial infrastructure for Xen para-virtualized block device.
This includes compile-time configuration and the skeleton for
the future driver implementation.
Add new class UCLASS_PVBLOCK which is going to be a parent for
virtual block devices.
Add new interface type IF_TYPE_PVBLOCK.
Implement basic driver setup by reading XenStore configuration.
Signed-off-by: Andrii Anisov <andrii_anisov@epam.com>
Signed-off-by: Anastasiia Lukianenko <anastasiia_lukianenko@epam.com>
Signed-off-by: Oleksandr Andrushchenko <oleksandr_andrushchenko@epam.com>
help
USB mass storage support
+config CMD_PVBLOCK
+ bool "Xen para-virtualized block device"
+ depends on XEN
+ select PVBLOCK
+ help
+ Xen para-virtualized block device support
+
config CMD_VIRTIO
bool "virtio"
depends on VIRTIO
obj-$(CONFIG_CMD_GPT) += gpt.o
obj-$(CONFIG_CMD_ETHSW) += ethsw.o
obj-$(CONFIG_CMD_AXI) += axi.o
+obj-$(CONFIG_CMD_PVBLOCK) += pvblock.o
# Power
obj-$(CONFIG_CMD_PMIC) += pmic.o
--- /dev/null
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * (C) Copyright 2020 EPAM Systems Inc.
+ *
+ * XEN para-virtualized block device support
+ */
+
+#include <blk.h>
+#include <common.h>
+#include <command.h>
+
+/* Current I/O Device */
+static int pvblock_curr_device;
+
+int do_pvblock(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
+{
+ return blk_common_cmd(argc, argv, IF_TYPE_PVBLOCK,
+ &pvblock_curr_device);
+}
+
+U_BOOT_CMD(pvblock, 5, 1, do_pvblock,
+ "Xen para-virtualized block device",
+ "info - show available block devices\n"
+ "pvblock device [dev] - show or set current device\n"
+ "pvblock part [dev] - print partition table of one or all devices\n"
+ "pvblock read addr blk# cnt\n"
+ "pvblock write addr blk# cnt - read/write `cnt'"
+ " blocks starting at block `blk#'\n"
+ " to/from memory address `addr'");
+
#include <nand.h>
#include <of_live.h>
#include <onenand_uboot.h>
+#include <pvblock.h>
#include <scsi.h>
#include <serial.h>
#include <status_led.h>
return 0;
}
#endif
+
+#ifdef CONFIG_PVBLOCK
+static int initr_pvblock(void)
+{
+ puts("PVBLOCK: ");
+ pvblock_init();
+ return 0;
+}
+#endif
+
/*
* Tell if it's OK to load the environment early in boot.
*
#endif
#ifdef CONFIG_XEN
initr_xen,
+#endif
+#ifdef CONFIG_PVBLOCK
+ initr_pvblock,
#endif
initr_env,
#ifdef CONFIG_SYS_BOOTPARAMS_LEN
CONFIG_CMD_BOOTEFI=n
CONFIG_CMD_BOOTEFI_HELLO_COMPILE=n
CONFIG_CMD_ELF=n
+CONFIG_CMD_EXT4=y
+CONFIG_CMD_FAT=y
CONFIG_CMD_GO=n
CONFIG_CMD_RUN=n
CONFIG_CMD_IMI=n
CONFIG_CMD_SAVEENV=n
CONFIG_CMD_UMS=n
+CONFIG_CMD_PVBLOCK=y
+
#CONFIG_USB=n
# CONFIG_ISO_PARTITION is not set
case IF_TYPE_MMC:
case IF_TYPE_USB:
case IF_TYPE_NVME:
+ case IF_TYPE_PVBLOCK:
printf ("Vendor: %s Rev: %s Prod: %s\n",
dev_desc->vendor,
dev_desc->revision,
case IF_TYPE_NVME:
puts ("NVMe");
break;
+ case IF_TYPE_PVBLOCK:
+ puts("PV BLOCK");
+ break;
case IF_TYPE_VIRTIO:
puts("VirtIO");
break;
source "drivers/watchdog/Kconfig"
+source "drivers/xen/Kconfig"
+
config PHYS_TO_BUS
bool "Custom physical to bus address mapping"
help
[IF_TYPE_NVME] = "nvme",
[IF_TYPE_EFI] = "efi",
[IF_TYPE_VIRTIO] = "virtio",
+ [IF_TYPE_PVBLOCK] = "pvblock",
};
static enum uclass_id if_type_uclass_id[IF_TYPE_COUNT] = {
[IF_TYPE_NVME] = UCLASS_NVME,
[IF_TYPE_EFI] = UCLASS_EFI,
[IF_TYPE_VIRTIO] = UCLASS_VIRTIO,
+ [IF_TYPE_PVBLOCK] = UCLASS_PVBLOCK,
};
static enum if_type if_typename_to_iftype(const char *if_typename)
--- /dev/null
+config PVBLOCK
+ bool "Xen para-virtualized block device"
+ depends on DM
+ select BLK
+ select HAVE_BLOCK_DEVICE
+ help
+ This driver implements the front-end of the Xen virtual
+ block device driver. It communicates with a back-end driver
+ in another domain which drives the actual block device.
+
obj-y += events.o
obj-y += xenbus.o
obj-y += gnttab.o
+
+obj-$(CONFIG_PVBLOCK) += pvblock.o
--- /dev/null
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * (C) Copyright 2020 EPAM Systems Inc.
+ */
+#include <blk.h>
+#include <common.h>
+#include <dm.h>
+#include <dm/device-internal.h>
+
+#define DRV_NAME "pvblock"
+#define DRV_NAME_BLK "pvblock_blk"
+
+struct blkfront_dev {
+ char dummy;
+};
+
+static int init_blkfront(unsigned int devid, struct blkfront_dev *dev)
+{
+ return 0;
+}
+
+static void shutdown_blkfront(struct blkfront_dev *dev)
+{
+}
+
+ulong pvblock_blk_read(struct udevice *udev, lbaint_t blknr, lbaint_t blkcnt,
+ void *buffer)
+{
+ return 0;
+}
+
+ulong pvblock_blk_write(struct udevice *udev, lbaint_t blknr, lbaint_t blkcnt,
+ const void *buffer)
+{
+ return 0;
+}
+
+static int pvblock_blk_bind(struct udevice *udev)
+{
+ return 0;
+}
+
+static int pvblock_blk_probe(struct udevice *udev)
+{
+ struct blkfront_dev *blk_dev = dev_get_priv(udev);
+ int ret;
+
+ ret = init_blkfront(0, blk_dev);
+ if (ret < 0)
+ return ret;
+ return 0;
+}
+
+static int pvblock_blk_remove(struct udevice *udev)
+{
+ struct blkfront_dev *blk_dev = dev_get_priv(udev);
+
+ shutdown_blkfront(blk_dev);
+ return 0;
+}
+
+static const struct blk_ops pvblock_blk_ops = {
+ .read = pvblock_blk_read,
+ .write = pvblock_blk_write,
+};
+
+U_BOOT_DRIVER(pvblock_blk) = {
+ .name = DRV_NAME_BLK,
+ .id = UCLASS_BLK,
+ .ops = &pvblock_blk_ops,
+ .bind = pvblock_blk_bind,
+ .probe = pvblock_blk_probe,
+ .remove = pvblock_blk_remove,
+ .priv_auto_alloc_size = sizeof(struct blkfront_dev),
+ .flags = DM_FLAG_OS_PREPARE,
+};
+
+/*******************************************************************************
+ * Para-virtual block device class
+ *******************************************************************************/
+
+void pvblock_init(void)
+{
+ struct driver_info info;
+ struct udevice *udev;
+ struct uclass *uc;
+ int ret;
+
+ /*
+ * At this point Xen drivers have already initialized,
+ * so we can instantiate the class driver and enumerate
+ * virtual block devices.
+ */
+ info.name = DRV_NAME;
+ ret = device_bind_by_name(gd->dm_root, false, &info, &udev);
+ if (ret < 0)
+ printf("Failed to bind " DRV_NAME ", ret: %d\n", ret);
+
+ /* Bootstrap virtual block devices class driver */
+ ret = uclass_get(UCLASS_PVBLOCK, &uc);
+ if (ret)
+ return;
+ uclass_foreach_dev_probe(UCLASS_PVBLOCK, udev);
+}
+
+static int pvblock_probe(struct udevice *udev)
+{
+ return 0;
+}
+
+U_BOOT_DRIVER(pvblock_drv) = {
+ .name = DRV_NAME,
+ .id = UCLASS_PVBLOCK,
+ .probe = pvblock_probe,
+};
+
+UCLASS_DRIVER(pvblock) = {
+ .name = DRV_NAME,
+ .id = UCLASS_PVBLOCK,
+};
IF_TYPE_HOST,
IF_TYPE_NVME,
IF_TYPE_EFI,
+ IF_TYPE_PVBLOCK,
IF_TYPE_VIRTIO,
IF_TYPE_COUNT, /* Number of interface types */
#define CONFIG_CMDLINE_TAG 1
#define CONFIG_INITRD_TAG 1
+#define CONFIG_CMD_RUN
+
+#undef CONFIG_EXTRA_ENV_SETTINGS
+#define CONFIG_EXTRA_ENV_SETTINGS \
+ "loadimage=ext4load pvblock 0 0x90000000 /boot/Image;\0" \
+ "pvblockboot=run loadimage;" \
+ "booti 0x90000000 - 0x88000000;\0"
+
#endif /* __XENGUEST_ARM64_H */
UCLASS_W1, /* Dallas 1-Wire bus */
UCLASS_W1_EEPROM, /* one-wire EEPROMs */
UCLASS_WDT, /* Watchdog Timer driver */
+ UCLASS_PVBLOCK, /* Xen virtual block device */
UCLASS_COUNT,
UCLASS_INVALID = -1,
--- /dev/null
+/* SPDX-License-Identifier: GPL-2.0+
+ *
+ * (C) 2020 EPAM Systems Inc.
+ */
+
+#ifndef _PVBLOCK_H
+#define _PVBLOCK_H
+
+/**
+ * pvblock_init() - Initialize para-virtual block device class driver
+ *
+ * Bind PV block to UCLASS_ROOT device and probe all UCLASS_PVBLOCK
+ * virtual block devices.
+ */
+void pvblock_init(void);
+
+#endif /* _PVBLOCK_H */