Merge tag 'u-boot-at91-fixes-2023.10-b' of https://source.denx.de/u-boot/custodians...
[platform/kernel/u-boot.git] / common / command.c
index 068cb55..846e16e 100644 (file)
 #include <command.h>
 #include <console.h>
 #include <env.h>
+#include <image.h>
 #include <log.h>
+#include <mapmem.h>
+#include <asm/global_data.h>
 #include <linux/ctype.h>
 
+DECLARE_GLOBAL_DATA_PTR;
+
 /*
  * Use puts() instead of printf() to avoid printf buffer overflow
  * for long help messages
@@ -63,7 +68,7 @@ int _do_help(struct cmd_tbl *cmd_start, int cmd_items, struct cmd_tbl *cmdtp,
                                return 1;
                        if (usage == NULL)
                                continue;
-                       printf("%-*s- %s\n", CONFIG_SYS_HELP_CMD_WIDTH,
+                       printf("%-*s- %s\n", CFG_SYS_HELP_CMD_WIDTH,
                               cmd_array[i]->name, usage);
                }
                return 0;
@@ -488,9 +493,6 @@ int cmd_get_data_size(char* arg, int default_size)
 }
 #endif
 
-#if defined(CONFIG_NEEDS_MANUAL_RELOC)
-DECLARE_GLOBAL_DATA_PTR;
-
 void fixup_cmdtable(struct cmd_tbl *cmdtp, int size)
 {
        int     i;
@@ -535,7 +537,6 @@ void fixup_cmdtable(struct cmd_tbl *cmdtp, int size)
                cmdtp++;
        }
 }
-#endif
 
 int cmd_always_repeatable(struct cmd_tbl *cmdtp, int flag, int argc,
                          char *const argv[], int *repeatable)
@@ -571,7 +572,7 @@ int cmd_discard_repeatable(struct cmd_tbl *cmdtp, int flag, int argc,
  * @param argc         Number of arguments (arg 0 must be the command text)
  * @param argv         Arguments
  * @param repeatable   Can the command be repeated
- * @return 0 if command succeeded, else non-zero (CMD_RET_...)
+ * Return: 0 if command succeeded, else non-zero (CMD_RET_...)
  */
 static int cmd_call(struct cmd_tbl *cmdtp, int flag, int argc,
                    char *const argv[], int *repeatable)
@@ -655,3 +656,20 @@ int cmd_process_error(struct cmd_tbl *cmdtp, int err)
 
        return CMD_RET_SUCCESS;
 }
+
+int cmd_source_script(ulong addr, const char *fit_uname, const char *confname)
+{
+       char *data;
+       void *buf;
+       uint len;
+       int ret;
+
+       buf = map_sysmem(addr, 0);
+       ret = image_locate_script(buf, 0, fit_uname, confname, &data, &len);
+       unmap_sysmem(buf);
+       if (ret)
+               return CMD_RET_FAILURE;
+
+       debug("** Script length: %d\n", len);
+       return run_command_list(data, len, 0);
+}