]> Git Repo - J-u-boot.git/blame - cmd/virtio.c
Merge tag 'dm-pull-21sep22' of https://source.denx.de/u-boot/custodians/u-boot-dm
[J-u-boot.git] / cmd / virtio.c
CommitLineData
78e12901
TT
1// SPDX-License-Identifier: GPL-2.0+
2/*
3 * Copyright (C) 2018, Tuomas Tynkkynen <[email protected]>
4 * Copyright (C) 2018, Bin Meng <[email protected]>
5 */
6
7#include <common.h>
e6f6f9e6 8#include <blk.h>
78e12901
TT
9#include <command.h>
10#include <dm.h>
11#include <virtio_types.h>
12#include <virtio.h>
13
14static int virtio_curr_dev;
15
09140113
SG
16static int do_virtio(struct cmd_tbl *cmdtp, int flag, int argc,
17 char *const argv[])
78e12901
TT
18{
19 if (argc == 2 && !strcmp(argv[1], "scan")) {
75a9d750
AT
20 /*
21 * make sure all virtio devices are enumerated.
22 * Do the same as virtio_init(), but also call
23 * device_probe() for children (i.e. virtio devices)
24 */
25 struct udevice *bus, *child;
26 int ret;
27
28 ret = uclass_first_device(UCLASS_VIRTIO, &bus);
29 if (ret)
30 return CMD_RET_FAILURE;
31
32 while (bus) {
33 device_foreach_child_probe(child, bus)
34 ;
35 ret = uclass_next_device(&bus);
36 if (ret)
37 break;
38 }
78e12901
TT
39
40 return CMD_RET_SUCCESS;
41 }
42
43 return blk_common_cmd(argc, argv, IF_TYPE_VIRTIO, &virtio_curr_dev);
44}
45
46U_BOOT_CMD(
47 virtio, 8, 1, do_virtio,
48 "virtio block devices sub-system",
49 "scan - initialize virtio bus\n"
50 "virtio info - show all available virtio block devices\n"
51 "virtio device [dev] - show or set current virtio block device\n"
52 "virtio part [dev] - print partition table of one or all virtio block devices\n"
53 "virtio read addr blk# cnt - read `cnt' blocks starting at block\n"
54 " `blk#' to memory address `addr'\n"
55 "virtio write addr blk# cnt - write `cnt' blocks starting at block\n"
56 " `blk#' from memory address `addr'"
57);
This page took 0.121239 seconds and 4 git commands to generate.