blob: 8064a1c84dfae81088225f2f7473709009aa6070 [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0
Stephen Warreneefbc3f2012-10-22 06:43:51 +00002/*
3 * Copyright (c) 2012, NVIDIA CORPORATION. All rights reserved.
4 *
5 * Inspired by cmd_ext_common.c, cmd_fat.c.
Stephen Warreneefbc3f2012-10-22 06:43:51 +00006 */
7
8#include <common.h>
9#include <command.h>
10#include <fs.h>
Alexander Graf8f19f262016-03-04 01:10:14 +010011#include <efi_loader.h>
Stephen Warreneefbc3f2012-10-22 06:43:51 +000012
Stephen Warren3eb58f52014-06-11 12:47:26 -060013static 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
18U_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 Hofsteef384fbf2014-06-23 00:22:08 +020026static int do_load_wrapper(cmd_tbl_t *cmdtp, int flag, int argc,
27 char * const argv[])
Stephen Warreneefbc3f2012-10-22 06:43:51 +000028{
Alexander Grafc49a1b82016-04-11 16:16:19 +020029 efi_set_bootdev(argv[1], (argc > 2) ? argv[2] : "",
30 (argc > 4) ? argv[4] : "");
Wolfgang Denka10c7a52013-10-05 21:07:25 +020031 return do_load(cmdtp, flag, argc, argv, FS_TYPE_ANY);
Stephen Warreneefbc3f2012-10-22 06:43:51 +000032}
33
34U_BOOT_CMD(
Stephen Warren128d3d92012-10-31 11:05:07 +000035 load, 7, 0, do_load_wrapper,
Stephen Warreneefbc3f2012-10-22 06:43:51 +000036 "load binary file from a filesystem",
37 "<interface> [<dev[:part]> [<addr> [<filename> [bytes [pos]]]]]\n"
38 " - Load binary file 'filename' from partition 'part' on device\n"
39 " type 'interface' instance 'dev' to address 'addr' in memory.\n"
40 " 'bytes' gives the size to load in bytes.\n"
41 " If 'bytes' is 0 or omitted, the file is read until the end.\n"
42 " 'pos' gives the file byte position to start reading from.\n"
Wolfgang Denka10c7a52013-10-05 21:07:25 +020043 " If 'pos' is 0 or omitted, the file is read from the start."
Jeroen Hofsteef384fbf2014-06-23 00:22:08 +020044)
Stephen Warreneefbc3f2012-10-22 06:43:51 +000045
Suriyan Ramasami96171fb2014-11-17 14:39:38 -080046static int do_save_wrapper(cmd_tbl_t *cmdtp, int flag, int argc,
47 char * const argv[])
48{
49 return do_save(cmdtp, flag, argc, argv, FS_TYPE_ANY);
50}
51
52U_BOOT_CMD(
53 save, 7, 0, do_save_wrapper,
54 "save file to a filesystem",
55 "<interface> <dev[:part]> <addr> <filename> bytes [pos]\n"
56 " - Save binary file 'filename' to partition 'part' on device\n"
57 " type 'interface' instance 'dev' from addr 'addr' in memory.\n"
58 " 'bytes' gives the size to save in bytes and is mandatory.\n"
59 " 'pos' gives the file byte position to start writing to.\n"
60 " If 'pos' is 0 or omitted, the file is written from the start."
61)
62
Jeroen Hofsteef384fbf2014-06-23 00:22:08 +020063static int do_ls_wrapper(cmd_tbl_t *cmdtp, int flag, int argc,
64 char * const argv[])
Stephen Warreneefbc3f2012-10-22 06:43:51 +000065{
66 return do_ls(cmdtp, flag, argc, argv, FS_TYPE_ANY);
67}
68
69U_BOOT_CMD(
70 ls, 4, 1, do_ls_wrapper,
71 "list files in a directory (default /)",
72 "<interface> [<dev[:part]> [directory]]\n"
73 " - List files in directory 'directory' of partition 'part' on\n"
74 " device type 'interface' instance 'dev'."
Jeroen Hofsteef384fbf2014-06-23 00:22:08 +020075)
Sjoerd Simons7d9faf62015-01-05 18:13:36 +010076
77static int do_fstype_wrapper(cmd_tbl_t *cmdtp, int flag, int argc,
78 char * const argv[])
79{
80 return do_fs_type(cmdtp, flag, argc, argv);
81}
82
83U_BOOT_CMD(
84 fstype, 4, 1, do_fstype_wrapper,
85 "Look up a filesystem type",
86 "<interface> <dev>:<part>\n"
87 "- print filesystem type\n"
88 "fstype <interface> <dev>:<part> <varname>\n"
89 "- set environment variable to filesystem type\n"
90);