Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0 |
Stephen Warren | eefbc3f | 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 | eefbc3f | 2012-10-22 06:43:51 +0000 | [diff] [blame] | 6 | */ |
| 7 | |
| 8 | #include <common.h> |
| 9 | #include <command.h> |
| 10 | #include <fs.h> |
| 11 | |
Simon Glass | ed38aef | 2020-05-10 11:40:03 -0600 | [diff] [blame] | 12 | static int do_size_wrapper(struct cmd_tbl *cmdtp, int flag, int argc, |
| 13 | char *const argv[]) |
Stephen Warren | 3eb58f5 | 2014-06-11 12:47:26 -0600 | [diff] [blame] | 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" |
Baruch Siach | 5c7d204 | 2023-05-07 13:48:06 +0300 | [diff] [blame] | 23 | " determine its size, and store in the 'filesize' variable." |
Stephen Warren | 3eb58f5 | 2014-06-11 12:47:26 -0600 | [diff] [blame] | 24 | ); |
| 25 | |
Simon Glass | ed38aef | 2020-05-10 11:40:03 -0600 | [diff] [blame] | 26 | static int do_load_wrapper(struct cmd_tbl *cmdtp, int flag, int argc, |
| 27 | char *const argv[]) |
Stephen Warren | eefbc3f | 2012-10-22 06:43:51 +0000 | [diff] [blame] | 28 | { |
Wolfgang Denk | a10c7a5 | 2013-10-05 21:07:25 +0200 | [diff] [blame] | 29 | return do_load(cmdtp, flag, argc, argv, FS_TYPE_ANY); |
Stephen Warren | eefbc3f | 2012-10-22 06:43:51 +0000 | [diff] [blame] | 30 | } |
| 31 | |
| 32 | U_BOOT_CMD( |
Stephen Warren | 128d3d9 | 2012-10-31 11:05:07 +0000 | [diff] [blame] | 33 | load, 7, 0, do_load_wrapper, |
Stephen Warren | eefbc3f | 2012-10-22 06:43:51 +0000 | [diff] [blame] | 34 | "load binary file from a filesystem", |
| 35 | "<interface> [<dev[:part]> [<addr> [<filename> [bytes [pos]]]]]\n" |
| 36 | " - Load binary file 'filename' from partition 'part' on device\n" |
| 37 | " type 'interface' instance 'dev' to address 'addr' in memory.\n" |
| 38 | " 'bytes' gives the size to load in bytes.\n" |
| 39 | " If 'bytes' is 0 or omitted, the file is read until the end.\n" |
| 40 | " 'pos' gives the file byte position to start reading from.\n" |
Wolfgang Denk | a10c7a5 | 2013-10-05 21:07:25 +0200 | [diff] [blame] | 41 | " If 'pos' is 0 or omitted, the file is read from the start." |
Simon Glass | 761d602 | 2023-11-18 14:04:52 -0700 | [diff] [blame] | 42 | ); |
Stephen Warren | eefbc3f | 2012-10-22 06:43:51 +0000 | [diff] [blame] | 43 | |
Simon Glass | ed38aef | 2020-05-10 11:40:03 -0600 | [diff] [blame] | 44 | static int do_save_wrapper(struct cmd_tbl *cmdtp, int flag, int argc, |
| 45 | char *const argv[]) |
Suriyan Ramasami | 96171fb | 2014-11-17 14:39:38 -0800 | [diff] [blame] | 46 | { |
| 47 | return do_save(cmdtp, flag, argc, argv, FS_TYPE_ANY); |
| 48 | } |
| 49 | |
| 50 | U_BOOT_CMD( |
| 51 | save, 7, 0, do_save_wrapper, |
| 52 | "save file to a filesystem", |
| 53 | "<interface> <dev[:part]> <addr> <filename> bytes [pos]\n" |
| 54 | " - Save binary file 'filename' to partition 'part' on device\n" |
| 55 | " type 'interface' instance 'dev' from addr 'addr' in memory.\n" |
| 56 | " 'bytes' gives the size to save in bytes and is mandatory.\n" |
| 57 | " 'pos' gives the file byte position to start writing to.\n" |
| 58 | " If 'pos' is 0 or omitted, the file is written from the start." |
Simon Glass | 761d602 | 2023-11-18 14:04:52 -0700 | [diff] [blame] | 59 | ); |
Suriyan Ramasami | 96171fb | 2014-11-17 14:39:38 -0800 | [diff] [blame] | 60 | |
Simon Glass | ed38aef | 2020-05-10 11:40:03 -0600 | [diff] [blame] | 61 | static int do_ls_wrapper(struct cmd_tbl *cmdtp, int flag, int argc, |
| 62 | char *const argv[]) |
Stephen Warren | eefbc3f | 2012-10-22 06:43:51 +0000 | [diff] [blame] | 63 | { |
| 64 | return do_ls(cmdtp, flag, argc, argv, FS_TYPE_ANY); |
| 65 | } |
| 66 | |
| 67 | U_BOOT_CMD( |
| 68 | ls, 4, 1, do_ls_wrapper, |
| 69 | "list files in a directory (default /)", |
| 70 | "<interface> [<dev[:part]> [directory]]\n" |
| 71 | " - List files in directory 'directory' of partition 'part' on\n" |
| 72 | " device type 'interface' instance 'dev'." |
Simon Glass | 761d602 | 2023-11-18 14:04:52 -0700 | [diff] [blame] | 73 | ); |
Sjoerd Simons | 7d9faf6 | 2015-01-05 18:13:36 +0100 | [diff] [blame] | 74 | |
Simon Glass | ed38aef | 2020-05-10 11:40:03 -0600 | [diff] [blame] | 75 | static int do_ln_wrapper(struct cmd_tbl *cmdtp, int flag, int argc, |
| 76 | char *const argv[]) |
Jean-Jacques Hiblot | bc23748 | 2019-02-13 12:15:26 +0100 | [diff] [blame] | 77 | { |
| 78 | return do_ln(cmdtp, flag, argc, argv, FS_TYPE_ANY); |
| 79 | } |
| 80 | |
| 81 | U_BOOT_CMD( |
| 82 | ln, 5, 1, do_ln_wrapper, |
| 83 | "Create a symbolic link", |
| 84 | "<interface> <dev[:part]> target linkname\n" |
| 85 | " - create a symbolic link to 'target' with the name 'linkname' on\n" |
| 86 | " device type 'interface' instance 'dev'." |
Simon Glass | 761d602 | 2023-11-18 14:04:52 -0700 | [diff] [blame] | 87 | ); |
Jean-Jacques Hiblot | bc23748 | 2019-02-13 12:15:26 +0100 | [diff] [blame] | 88 | |
Simon Glass | ed38aef | 2020-05-10 11:40:03 -0600 | [diff] [blame] | 89 | static int do_fstype_wrapper(struct cmd_tbl *cmdtp, int flag, int argc, |
| 90 | char *const argv[]) |
Sjoerd Simons | 7d9faf6 | 2015-01-05 18:13:36 +0100 | [diff] [blame] | 91 | { |
| 92 | return do_fs_type(cmdtp, flag, argc, argv); |
| 93 | } |
| 94 | |
| 95 | U_BOOT_CMD( |
| 96 | fstype, 4, 1, do_fstype_wrapper, |
| 97 | "Look up a filesystem type", |
| 98 | "<interface> <dev>:<part>\n" |
| 99 | "- print filesystem type\n" |
| 100 | "fstype <interface> <dev>:<part> <varname>\n" |
| 101 | "- set environment variable to filesystem type\n" |
| 102 | ); |
Niel Fourie | 9252d70 | 2020-03-24 16:17:04 +0100 | [diff] [blame] | 103 | |
| 104 | static int do_fstypes_wrapper(struct cmd_tbl *cmdtp, int flag, int argc, |
| 105 | char * const argv[]) |
| 106 | { |
| 107 | return do_fs_types(cmdtp, flag, argc, argv); |
| 108 | } |
| 109 | |
| 110 | U_BOOT_CMD( |
| 111 | fstypes, 1, 1, do_fstypes_wrapper, |
| 112 | "List supported filesystem types", "" |
| 113 | ); |