+
+static int do_smhload(struct cmd_tbl *cmdtp, int flag, int argc,
+ char *const argv[])
+{
+ if (argc == 3 || argc == 4) {
+ ulong load_addr;
+ ulong end_addr = 0;
+ int ret;
+ char end_str[64];
+
+ load_addr = simple_strtoul(argv[2], NULL, 16);
+ if (!load_addr)
+ return -1;
+
+ ret = smh_load_file(argv[1], load_addr, &end_addr);
+ if (ret < 0)
+ return CMD_RET_FAILURE;
+
+ /* Optionally save returned end to the environment */
+ if (argc == 4) {
+ sprintf(end_str, "0x%08lx", end_addr);
+ env_set(argv[3], end_str);
+ }
+ } else {
+ return CMD_RET_USAGE;
+ }
+ return 0;
+}
+
+U_BOOT_CMD(smhload, 4, 0, do_smhload, "load a file using semihosting",
+ "<file> 0x<address> [end var]\n"
+ " - load a semihosted file to the address specified\n"
+ " if the optional [end var] is specified, the end\n"
+ " address of the file will be stored in this environment\n"
+ " variable.\n");