cmd_sandbox.c 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /*
  2. * Copyright (c) 2012, Google Inc.
  3. *
  4. * This program is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU General Public License as
  6. * published by the Free Software Foundation; either version 2 of
  7. * the License, or (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program; if not, write to the Free Software
  16. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  17. * MA 02111-1307 USA
  18. */
  19. #include <common.h>
  20. #include <fs.h>
  21. static int do_sandbox_load(cmd_tbl_t *cmdtp, int flag, int argc,
  22. char * const argv[])
  23. {
  24. return do_load(cmdtp, flag, argc, argv, FS_TYPE_SANDBOX, 16);
  25. }
  26. static int do_sandbox_ls(cmd_tbl_t *cmdtp, int flag, int argc,
  27. char * const argv[])
  28. {
  29. return do_ls(cmdtp, flag, argc, argv, FS_TYPE_SANDBOX);
  30. }
  31. static int do_sandbox_save(cmd_tbl_t *cmdtp, int flag, int argc,
  32. char * const argv[])
  33. {
  34. return do_save(cmdtp, flag, argc, argv, FS_TYPE_SANDBOX, 16);
  35. }
  36. static cmd_tbl_t cmd_sandbox_sub[] = {
  37. U_BOOT_CMD_MKENT(load, 7, 0, do_sandbox_load, "", ""),
  38. U_BOOT_CMD_MKENT(ls, 3, 0, do_sandbox_ls, "", ""),
  39. U_BOOT_CMD_MKENT(save, 6, 0, do_sandbox_save, "", ""),
  40. };
  41. static int do_sandbox(cmd_tbl_t *cmdtp, int flag, int argc,
  42. char * const argv[])
  43. {
  44. cmd_tbl_t *c;
  45. /* Skip past 'sandbox' */
  46. argc--;
  47. argv++;
  48. c = find_cmd_tbl(argv[0], cmd_sandbox_sub,
  49. ARRAY_SIZE(cmd_sandbox_sub));
  50. if (c)
  51. return c->cmd(cmdtp, flag, argc, argv);
  52. else
  53. return CMD_RET_USAGE;
  54. }
  55. U_BOOT_CMD(
  56. sb, 8, 1, do_sandbox,
  57. "Miscellaneous sandbox commands",
  58. "load host <dev> <addr> <filename> [<bytes> <offset>] - "
  59. "load a file from host\n"
  60. "sb ls host <filename> - list files on host\n"
  61. "sb save host <dev> <filename> <addr> <bytes> [<offset>] - "
  62. "save a file to host\n"
  63. );