fs.c 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. // SPDX-License-Identifier: GPL-2.0
  2. /*
  3. * Copyright (c) 2012, NVIDIA CORPORATION. All rights reserved.
  4. *
  5. * Inspired by cmd_ext_common.c, cmd_fat.c.
  6. */
  7. #include <common.h>
  8. #include <command.h>
  9. #include <fs.h>
  10. #include <efi_loader.h>
  11. static int do_size_wrapper(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
  12. {
  13. return do_size(cmdtp, flag, argc, argv, FS_TYPE_ANY);
  14. }
  15. U_BOOT_CMD(
  16. size, 4, 0, do_size_wrapper,
  17. "determine a file's size",
  18. "<interface> <dev[:part]> <filename>\n"
  19. " - Find file 'filename' from 'dev' on 'interface'\n"
  20. " and determine its size."
  21. );
  22. static int do_load_wrapper(cmd_tbl_t *cmdtp, int flag, int argc,
  23. char * const argv[])
  24. {
  25. efi_set_bootdev(argv[1], (argc > 2) ? argv[2] : "",
  26. (argc > 4) ? argv[4] : "");
  27. return do_load(cmdtp, flag, argc, argv, FS_TYPE_ANY);
  28. }
  29. U_BOOT_CMD(
  30. load, 7, 0, do_load_wrapper,
  31. "load binary file from a filesystem",
  32. "<interface> [<dev[:part]> [<addr> [<filename> [bytes [pos]]]]]\n"
  33. " - Load binary file 'filename' from partition 'part' on device\n"
  34. " type 'interface' instance 'dev' to address 'addr' in memory.\n"
  35. " 'bytes' gives the size to load in bytes.\n"
  36. " If 'bytes' is 0 or omitted, the file is read until the end.\n"
  37. " 'pos' gives the file byte position to start reading from.\n"
  38. " If 'pos' is 0 or omitted, the file is read from the start."
  39. )
  40. static int do_save_wrapper(cmd_tbl_t *cmdtp, int flag, int argc,
  41. char * const argv[])
  42. {
  43. return do_save(cmdtp, flag, argc, argv, FS_TYPE_ANY);
  44. }
  45. U_BOOT_CMD(
  46. save, 7, 0, do_save_wrapper,
  47. "save file to a filesystem",
  48. "<interface> <dev[:part]> <addr> <filename> bytes [pos]\n"
  49. " - Save binary file 'filename' to partition 'part' on device\n"
  50. " type 'interface' instance 'dev' from addr 'addr' in memory.\n"
  51. " 'bytes' gives the size to save in bytes and is mandatory.\n"
  52. " 'pos' gives the file byte position to start writing to.\n"
  53. " If 'pos' is 0 or omitted, the file is written from the start."
  54. )
  55. static int do_ls_wrapper(cmd_tbl_t *cmdtp, int flag, int argc,
  56. char * const argv[])
  57. {
  58. return do_ls(cmdtp, flag, argc, argv, FS_TYPE_ANY);
  59. }
  60. U_BOOT_CMD(
  61. ls, 4, 1, do_ls_wrapper,
  62. "list files in a directory (default /)",
  63. "<interface> [<dev[:part]> [directory]]\n"
  64. " - List files in directory 'directory' of partition 'part' on\n"
  65. " device type 'interface' instance 'dev'."
  66. )
  67. static int do_fstype_wrapper(cmd_tbl_t *cmdtp, int flag, int argc,
  68. char * const argv[])
  69. {
  70. return do_fs_type(cmdtp, flag, argc, argv);
  71. }
  72. U_BOOT_CMD(
  73. fstype, 4, 1, do_fstype_wrapper,
  74. "Look up a filesystem type",
  75. "<interface> <dev>:<part>\n"
  76. "- print filesystem type\n"
  77. "fstype <interface> <dev>:<part> <varname>\n"
  78. "- set environment variable to filesystem type\n"
  79. );