Tuomas Tynkkynen | 78e1290 | 2018-10-15 02:21:12 -0700 | [diff] [blame] | 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> |
Simon Glass | e6f6f9e | 2020-05-10 11:39:58 -0600 | [diff] [blame^] | 8 | #include <blk.h> |
Tuomas Tynkkynen | 78e1290 | 2018-10-15 02:21:12 -0700 | [diff] [blame] | 9 | #include <command.h> |
| 10 | #include <dm.h> |
| 11 | #include <virtio_types.h> |
| 12 | #include <virtio.h> |
| 13 | |
| 14 | static int virtio_curr_dev; |
| 15 | |
| 16 | static 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 | |
| 28 | U_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 | ); |