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