183d290c5STom Rini // SPDX-License-Identifier: GPL-2.0 22e192b24SSimon Glass /* 32e192b24SSimon Glass * Copyright (c) 2012, NVIDIA CORPORATION. All rights reserved. 42e192b24SSimon Glass * 52e192b24SSimon Glass * Inspired by cmd_ext_common.c, cmd_fat.c. 62e192b24SSimon Glass */ 72e192b24SSimon Glass 82e192b24SSimon Glass #include <common.h> 92e192b24SSimon Glass #include <command.h> 102e192b24SSimon Glass #include <fs.h> 110f4060ebSAlexander Graf #include <efi_loader.h> 122e192b24SSimon Glass 132e192b24SSimon Glass static int do_size_wrapper(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) 142e192b24SSimon Glass { 152e192b24SSimon Glass return do_size(cmdtp, flag, argc, argv, FS_TYPE_ANY); 162e192b24SSimon Glass } 172e192b24SSimon Glass 182e192b24SSimon Glass U_BOOT_CMD( 192e192b24SSimon Glass size, 4, 0, do_size_wrapper, 202e192b24SSimon Glass "determine a file's size", 212e192b24SSimon Glass "<interface> <dev[:part]> <filename>\n" 222e192b24SSimon Glass " - Find file 'filename' from 'dev' on 'interface'\n" 232e192b24SSimon Glass " and determine its size." 242e192b24SSimon Glass ); 252e192b24SSimon Glass 262e192b24SSimon Glass static int do_load_wrapper(cmd_tbl_t *cmdtp, int flag, int argc, 272e192b24SSimon Glass char * const argv[]) 282e192b24SSimon Glass { 29*84c7a139SGervais, Francois #ifdef CONFIG_CMD_BOOTEFI 30c07ad7c0SAlexander Graf efi_set_bootdev(argv[1], (argc > 2) ? argv[2] : "", 31c07ad7c0SAlexander Graf (argc > 4) ? argv[4] : ""); 32*84c7a139SGervais, Francois #endif 332e192b24SSimon Glass return do_load(cmdtp, flag, argc, argv, FS_TYPE_ANY); 342e192b24SSimon Glass } 352e192b24SSimon Glass 362e192b24SSimon Glass U_BOOT_CMD( 372e192b24SSimon Glass load, 7, 0, do_load_wrapper, 382e192b24SSimon Glass "load binary file from a filesystem", 392e192b24SSimon Glass "<interface> [<dev[:part]> [<addr> [<filename> [bytes [pos]]]]]\n" 402e192b24SSimon Glass " - Load binary file 'filename' from partition 'part' on device\n" 412e192b24SSimon Glass " type 'interface' instance 'dev' to address 'addr' in memory.\n" 422e192b24SSimon Glass " 'bytes' gives the size to load in bytes.\n" 432e192b24SSimon Glass " If 'bytes' is 0 or omitted, the file is read until the end.\n" 442e192b24SSimon Glass " 'pos' gives the file byte position to start reading from.\n" 452e192b24SSimon Glass " If 'pos' is 0 or omitted, the file is read from the start." 462e192b24SSimon Glass ) 472e192b24SSimon Glass 482e192b24SSimon Glass static int do_save_wrapper(cmd_tbl_t *cmdtp, int flag, int argc, 492e192b24SSimon Glass char * const argv[]) 502e192b24SSimon Glass { 512e192b24SSimon Glass return do_save(cmdtp, flag, argc, argv, FS_TYPE_ANY); 522e192b24SSimon Glass } 532e192b24SSimon Glass 542e192b24SSimon Glass U_BOOT_CMD( 552e192b24SSimon Glass save, 7, 0, do_save_wrapper, 562e192b24SSimon Glass "save file to a filesystem", 572e192b24SSimon Glass "<interface> <dev[:part]> <addr> <filename> bytes [pos]\n" 582e192b24SSimon Glass " - Save binary file 'filename' to partition 'part' on device\n" 592e192b24SSimon Glass " type 'interface' instance 'dev' from addr 'addr' in memory.\n" 602e192b24SSimon Glass " 'bytes' gives the size to save in bytes and is mandatory.\n" 612e192b24SSimon Glass " 'pos' gives the file byte position to start writing to.\n" 622e192b24SSimon Glass " If 'pos' is 0 or omitted, the file is written from the start." 632e192b24SSimon Glass ) 642e192b24SSimon Glass 652e192b24SSimon Glass static int do_ls_wrapper(cmd_tbl_t *cmdtp, int flag, int argc, 662e192b24SSimon Glass char * const argv[]) 672e192b24SSimon Glass { 682e192b24SSimon Glass return do_ls(cmdtp, flag, argc, argv, FS_TYPE_ANY); 692e192b24SSimon Glass } 702e192b24SSimon Glass 712e192b24SSimon Glass U_BOOT_CMD( 722e192b24SSimon Glass ls, 4, 1, do_ls_wrapper, 732e192b24SSimon Glass "list files in a directory (default /)", 742e192b24SSimon Glass "<interface> [<dev[:part]> [directory]]\n" 752e192b24SSimon Glass " - List files in directory 'directory' of partition 'part' on\n" 762e192b24SSimon Glass " device type 'interface' instance 'dev'." 772e192b24SSimon Glass ) 782e192b24SSimon Glass 792e192b24SSimon Glass static int do_fstype_wrapper(cmd_tbl_t *cmdtp, int flag, int argc, 802e192b24SSimon Glass char * const argv[]) 812e192b24SSimon Glass { 822e192b24SSimon Glass return do_fs_type(cmdtp, flag, argc, argv); 832e192b24SSimon Glass } 842e192b24SSimon Glass 852e192b24SSimon Glass U_BOOT_CMD( 862e192b24SSimon Glass fstype, 4, 1, do_fstype_wrapper, 872e192b24SSimon Glass "Look up a filesystem type", 882e192b24SSimon Glass "<interface> <dev>:<part>\n" 892e192b24SSimon Glass "- print filesystem type\n" 902e192b24SSimon Glass "fstype <interface> <dev>:<part> <varname>\n" 912e192b24SSimon Glass "- set environment variable to filesystem type\n" 922e192b24SSimon Glass ); 93