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