blob: f38cc56598caebaf4568c066c1767d9c7a8a101f [file] [log] [blame]
Tuomas Tynkkynen78e12902018-10-15 02:21:12 -07001// 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>
Simon Glasse6f6f9e2020-05-10 11:39:58 -06008#include <blk.h>
Tuomas Tynkkynen78e12902018-10-15 02:21:12 -07009#include <command.h>
10#include <dm.h>
11#include <virtio_types.h>
12#include <virtio.h>
13
14static int virtio_curr_dev;
15
16static int do_virtio(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
17{
18 if (argc == 2 && !strcmp(argv[1], "scan")) {
19 /* make sure all virtio devices are enumerated */
20 virtio_init();
21
22 return CMD_RET_SUCCESS;
23 }
24
25 return blk_common_cmd(argc, argv, IF_TYPE_VIRTIO, &virtio_curr_dev);
26}
27
28U_BOOT_CMD(
29 virtio, 8, 1, do_virtio,
30 "virtio block devices sub-system",
31 "scan - initialize virtio bus\n"
32 "virtio info - show all available virtio block devices\n"
33 "virtio device [dev] - show or set current virtio block device\n"
34 "virtio part [dev] - print partition table of one or all virtio block devices\n"
35 "virtio read addr blk# cnt - read `cnt' blocks starting at block\n"
36 " `blk#' to memory address `addr'\n"
37 "virtio write addr blk# cnt - write `cnt' blocks starting at block\n"
38 " `blk#' from memory address `addr'"
39);