[PATCH 7/7] api: enumerate virtio-blk devices
mhorne at FreeBSD.org
mhorne at FreeBSD.org
Tue Apr 21 00:34:18 CEST 2020
From: Mitchell Horne <mhorne at FreeBSD.org>
API clients can make a syscall requesting the enumeration of network and
storage devices. However, this does not check for virtio-blk storage
devices, which API consumers may wish to use. Add the support to
enumerate these devices as well.
Signed-off-by: Mitchell Horne <mhorne at FreeBSD.org>
---
api/api_storage.c | 14 +++++++++++++-
include/api_public.h | 1 +
2 files changed, 14 insertions(+), 1 deletion(-)
diff --git a/api/api_storage.c b/api/api_storage.c
index 7ae03ac230..866c82d7ec 100644
--- a/api/api_storage.c
+++ b/api/api_storage.c
@@ -30,7 +30,8 @@
#define ENUM_SCSI 2
#define ENUM_MMC 3
#define ENUM_SATA 4
-#define ENUM_MAX 5
+#define ENUM_VIRTIO 5
+#define ENUM_MAX 6
struct stor_spec {
int max_dev;
@@ -46,6 +47,10 @@ static struct stor_spec specs[ENUM_MAX] = { { 0, 0, 0, 0, NULL }, };
#define CONFIG_SYS_MMC_MAX_DEVICE 1
#endif
+#ifndef CONFIG_SYS_VIRTIO_BLK_MAX_DEVICE
+#define CONFIG_SYS_VIRTIO_BLK_MAX_DEVICE 1
+#endif
+
void dev_stor_init(void)
{
#if defined(CONFIG_IDE)
@@ -83,6 +88,13 @@ void dev_stor_init(void)
specs[ENUM_USB].type = DEV_TYP_STOR | DT_STOR_USB;
specs[ENUM_USB].name = "usb";
#endif
+#if defined(CONFIG_VIRTIO_BLK)
+ specs[ENUM_VIRTIO].max_dev = CONFIG_SYS_VIRTIO_BLK_MAX_DEVICE;
+ specs[ENUM_VIRTIO].enum_started = 0;
+ specs[ENUM_VIRTIO].enum_ended = 0;
+ specs[ENUM_VIRTIO].type = DEV_TYP_STOR | DT_STOR_VIRTIO;
+ specs[ENUM_VIRTIO].name = "virtio";
+#endif
}
/*
diff --git a/include/api_public.h b/include/api_public.h
index def103ce22..1f9ff49b0b 100644
--- a/include/api_public.h
+++ b/include/api_public.h
@@ -87,6 +87,7 @@ typedef unsigned long lbastart_t;
#define DT_STOR_USB 0x0040
#define DT_STOR_MMC 0x0080
#define DT_STOR_SATA 0x0100
+#define DT_STOR_VIRTIO 0x0200
#define DEV_STA_CLOSED 0x0000 /* invalid, closed */
#define DEV_STA_OPEN 0x0001 /* open i.e. active */
--
2.26.1
More information about the U-Boot
mailing list