Stephen Warren | eefbc3f | 2012-10-22 06:43:51 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2012, NVIDIA CORPORATION. All rights reserved. |
| 3 | * |
| 4 | * Inspired by cmd_ext_common.c, cmd_fat.c. |
| 5 | * |
Tom Rini | e237880 | 2016-01-14 22:05:13 -0500 | [diff] [blame] | 6 | * SPDX-License-Identifier: GPL-2.0 |
Stephen Warren | eefbc3f | 2012-10-22 06:43:51 +0000 | [diff] [blame] | 7 | */ |
| 8 | |
| 9 | #include <common.h> |
| 10 | #include <command.h> |
| 11 | #include <fs.h> |
Alexander Graf | 8f19f26 | 2016-03-04 01:10:14 +0100 | [diff] [blame] | 12 | #include <efi_loader.h> |
Stephen Warren | eefbc3f | 2012-10-22 06:43:51 +0000 | [diff] [blame] | 13 | |
Stephen Warren | 3eb58f5 | 2014-06-11 12:47:26 -0600 | [diff] [blame] | 14 | static int do_size_wrapper(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) |
| 15 | { |
| 16 | return do_size(cmdtp, flag, argc, argv, FS_TYPE_ANY); |
| 17 | } |
| 18 | |
| 19 | U_BOOT_CMD( |
| 20 | size, 4, 0, do_size_wrapper, |
| 21 | "determine a file's size", |
| 22 | "<interface> <dev[:part]> <filename>\n" |
| 23 | " - Find file 'filename' from 'dev' on 'interface'\n" |
| 24 | " and determine its size." |
| 25 | ); |
| 26 | |
Jeroen Hofstee | f384fbf | 2014-06-23 00:22:08 +0200 | [diff] [blame] | 27 | static int do_load_wrapper(cmd_tbl_t *cmdtp, int flag, int argc, |
| 28 | char * const argv[]) |
Stephen Warren | eefbc3f | 2012-10-22 06:43:51 +0000 | [diff] [blame] | 29 | { |
Alexander Graf | c49a1b8 | 2016-04-11 16:16:19 +0200 | [diff] [blame] | 30 | efi_set_bootdev(argv[1], (argc > 2) ? argv[2] : "", |
| 31 | (argc > 4) ? argv[4] : ""); |
Wolfgang Denk | a10c7a5 | 2013-10-05 21:07:25 +0200 | [diff] [blame] | 32 | return do_load(cmdtp, flag, argc, argv, FS_TYPE_ANY); |
Stephen Warren | eefbc3f | 2012-10-22 06:43:51 +0000 | [diff] [blame] | 33 | } |
| 34 | |
| 35 | U_BOOT_CMD( |
Stephen Warren | 128d3d9 | 2012-10-31 11:05:07 +0000 | [diff] [blame] | 36 | load, 7, 0, do_load_wrapper, |
Stephen Warren | eefbc3f | 2012-10-22 06:43:51 +0000 | [diff] [blame] | 37 | "load binary file from a filesystem", |
| 38 | "<interface> [<dev[:part]> [<addr> [<filename> [bytes [pos]]]]]\n" |
| 39 | " - Load binary file 'filename' from partition 'part' on device\n" |
| 40 | " type 'interface' instance 'dev' to address 'addr' in memory.\n" |
| 41 | " 'bytes' gives the size to load in bytes.\n" |
| 42 | " If 'bytes' is 0 or omitted, the file is read until the end.\n" |
| 43 | " 'pos' gives the file byte position to start reading from.\n" |
Wolfgang Denk | a10c7a5 | 2013-10-05 21:07:25 +0200 | [diff] [blame] | 44 | " If 'pos' is 0 or omitted, the file is read from the start." |
Jeroen Hofstee | f384fbf | 2014-06-23 00:22:08 +0200 | [diff] [blame] | 45 | ) |
Stephen Warren | eefbc3f | 2012-10-22 06:43:51 +0000 | [diff] [blame] | 46 | |
Suriyan Ramasami | 96171fb | 2014-11-17 14:39:38 -0800 | [diff] [blame] | 47 | static int do_save_wrapper(cmd_tbl_t *cmdtp, int flag, int argc, |
| 48 | char * const argv[]) |
| 49 | { |
| 50 | return do_save(cmdtp, flag, argc, argv, FS_TYPE_ANY); |
| 51 | } |
| 52 | |
| 53 | U_BOOT_CMD( |
| 54 | save, 7, 0, do_save_wrapper, |
| 55 | "save file to a filesystem", |
| 56 | "<interface> <dev[:part]> <addr> <filename> bytes [pos]\n" |
| 57 | " - Save binary file 'filename' to partition 'part' on device\n" |
| 58 | " type 'interface' instance 'dev' from addr 'addr' in memory.\n" |
| 59 | " 'bytes' gives the size to save in bytes and is mandatory.\n" |
| 60 | " 'pos' gives the file byte position to start writing to.\n" |
| 61 | " If 'pos' is 0 or omitted, the file is written from the start." |
| 62 | ) |
| 63 | |
Jeroen Hofstee | f384fbf | 2014-06-23 00:22:08 +0200 | [diff] [blame] | 64 | static int do_ls_wrapper(cmd_tbl_t *cmdtp, int flag, int argc, |
| 65 | char * const argv[]) |
Stephen Warren | eefbc3f | 2012-10-22 06:43:51 +0000 | [diff] [blame] | 66 | { |
| 67 | return do_ls(cmdtp, flag, argc, argv, FS_TYPE_ANY); |
| 68 | } |
| 69 | |
| 70 | U_BOOT_CMD( |
| 71 | ls, 4, 1, do_ls_wrapper, |
| 72 | "list files in a directory (default /)", |
| 73 | "<interface> [<dev[:part]> [directory]]\n" |
| 74 | " - List files in directory 'directory' of partition 'part' on\n" |
| 75 | " device type 'interface' instance 'dev'." |
Jeroen Hofstee | f384fbf | 2014-06-23 00:22:08 +0200 | [diff] [blame] | 76 | ) |
Sjoerd Simons | 7d9faf6 | 2015-01-05 18:13:36 +0100 | [diff] [blame] | 77 | |
| 78 | static int do_fstype_wrapper(cmd_tbl_t *cmdtp, int flag, int argc, |
| 79 | char * const argv[]) |
| 80 | { |
| 81 | return do_fs_type(cmdtp, flag, argc, argv); |
| 82 | } |
| 83 | |
| 84 | U_BOOT_CMD( |
| 85 | fstype, 4, 1, do_fstype_wrapper, |
| 86 | "Look up a filesystem type", |
| 87 | "<interface> <dev>:<part>\n" |
| 88 | "- print filesystem type\n" |
| 89 | "fstype <interface> <dev>:<part> <varname>\n" |
| 90 | "- set environment variable to filesystem type\n" |
| 91 | ); |