aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTuomas Tynkkynen2018-10-15 04:21:12 -0500
committerSimon Glass2018-11-14 11:16:27 -0600
commit78e12901f3fc8d228bd050f35594e1994f6a7d35 (patch)
treec2640b7f9fe4ca591608c06552c0489666377e45
parentf4802209e59da759b2d1bfcf136d6855984a5d05 (diff)
downloadu-boot-78e12901f3fc8d228bd050f35594e1994f6a7d35.tar.gz
u-boot-78e12901f3fc8d228bd050f35594e1994f6a7d35.tar.xz
u-boot-78e12901f3fc8d228bd050f35594e1994f6a7d35.zip
virtio: cmd: Add virtio command for virtio devices
Add 'virtio' command in U-Boot command line. Signed-off-by: Tuomas Tynkkynen <tuomas.tynkkynen@iki.fi> Signed-off-by: Bin Meng <bmeng.cn@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org>
-rw-r--r--cmd/Kconfig7
-rw-r--r--cmd/Makefile1
-rw-r--r--cmd/virtio.c38
3 files changed, 46 insertions, 0 deletions
diff --git a/cmd/Kconfig b/cmd/Kconfig
index ad14c9ce71..d609f9d1c9 100644
--- a/cmd/Kconfig
+++ b/cmd/Kconfig
@@ -1065,6 +1065,13 @@ config CMD_USB_MASS_STORAGE
1065 help 1065 help
1066 USB mass storage support 1066 USB mass storage support
1067 1067
1068config CMD_VIRTIO
1069 bool "virtio"
1070 depends on VIRTIO
1071 default y if VIRTIO
1072 help
1073 VirtIO block device support
1074
1068config CMD_AXI 1075config CMD_AXI
1069 bool "axi" 1076 bool "axi"
1070 depends on AXI 1077 depends on AXI
diff --git a/cmd/Makefile b/cmd/Makefile
index ac4830a692..12a1330b06 100644
--- a/cmd/Makefile
+++ b/cmd/Makefile
@@ -135,6 +135,7 @@ obj-$(CONFIG_CMD_UBI) += ubi.o
135obj-$(CONFIG_CMD_UBIFS) += ubifs.o 135obj-$(CONFIG_CMD_UBIFS) += ubifs.o
136obj-$(CONFIG_CMD_UNIVERSE) += universe.o 136obj-$(CONFIG_CMD_UNIVERSE) += universe.o
137obj-$(CONFIG_CMD_UNZIP) += unzip.o 137obj-$(CONFIG_CMD_UNZIP) += unzip.o
138obj-$(CONFIG_CMD_VIRTIO) += virtio.o
138obj-$(CONFIG_CMD_LZMADEC) += lzmadec.o 139obj-$(CONFIG_CMD_LZMADEC) += lzmadec.o
139 140
140obj-$(CONFIG_CMD_USB) += usb.o disk.o 141obj-$(CONFIG_CMD_USB) += usb.o disk.o
diff --git a/cmd/virtio.c b/cmd/virtio.c
new file mode 100644
index 0000000000..b7082bc63a
--- /dev/null
+++ b/cmd/virtio.c
@@ -0,0 +1,38 @@
1// SPDX-License-Identifier: GPL-2.0+
2/*
3 * Copyright (C) 2018, Tuomas Tynkkynen <tuomas.tynkkynen@iki.fi>
4 * Copyright (C) 2018, Bin Meng <bmeng.cn@gmail.com>
5 */
6
7#include <common.h>
8#include <command.h>
9#include <dm.h>
10#include <virtio_types.h>
11#include <virtio.h>
12
13static int virtio_curr_dev;
14
15static int do_virtio(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
16{
17 if (argc == 2 && !strcmp(argv[1], "scan")) {
18 /* make sure all virtio devices are enumerated */
19 virtio_init();
20
21 return CMD_RET_SUCCESS;
22 }
23
24 return blk_common_cmd(argc, argv, IF_TYPE_VIRTIO, &virtio_curr_dev);
25}
26
27U_BOOT_CMD(
28 virtio, 8, 1, do_virtio,
29 "virtio block devices sub-system",
30 "scan - initialize virtio bus\n"
31 "virtio info - show all available virtio block devices\n"
32 "virtio device [dev] - show or set current virtio block device\n"
33 "virtio part [dev] - print partition table of one or all virtio block devices\n"
34 "virtio read addr blk# cnt - read `cnt' blocks starting at block\n"
35 " `blk#' to memory address `addr'\n"
36 "virtio write addr blk# cnt - write `cnt' blocks starting at block\n"
37 " `blk#' from memory address `addr'"
38);