On Tue, Apr 21, 2020 at 7:29 AM <mho...@freebsd.org> wrote: > > From: Mitchell Horne <mho...@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 <mho...@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
At some time we need turn all these macros to Kconfig options in this file. > +#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 */ Reviewed-by: Bin Meng <bmeng...@gmail.com>