]> git.ipfire.org Git - thirdparty/u-boot.git/blame - cmd/source.c
Revert "Merge patch series "arm: dts: am62-beagleplay: Fix Beagleplay Ethernet""
[thirdparty/u-boot.git] / cmd / source.c
CommitLineData
83d290c5 1// SPDX-License-Identifier: GPL-2.0+
d0dd1077
WD
2/*
3 * (C) Copyright 2001
4 * Kyle Harris, kharris@nexus-tech.net
d0dd1077
WD
5 */
6
7/*
74de7aef
WD
8 * The "source" command allows to define "script images", i. e. files
9 * that contain command sequences that can be executed by the command
10 * interpreter. It returns the exit status of the last command
11 * executed from the script. This is very similar to running a shell
12 * script in a UNIX shell, hence the name for the command.
d0dd1077
WD
13 */
14
15/* #define DEBUG */
16
d678a59d 17#include <common.h>
d0dd1077 18#include <command.h>
6bf6dbee 19#include <env.h>
d0dd1077 20#include <image.h>
f7ae49fc 21#include <log.h>
d0dd1077 22#include <malloc.h>
0eb25b61 23#include <mapmem.h>
d0dd1077 24#include <asm/byteorder.h>
4ca30d60 25#include <asm/io.h>
d0dd1077 26
09140113
SG
27static int do_source(struct cmd_tbl *cmdtp, int flag, int argc,
28 char *const argv[])
d0dd1077
WD
29{
30 ulong addr;
31 int rcode;
bcc85b96 32 const char *fit_uname = NULL, *confname = NULL;
d0dd1077 33
424c4abd 34 /* Find script image */
d0dd1077 35 if (argc < 2) {
6d0f6bcf 36 addr = CONFIG_SYS_LOAD_ADDR;
3c7dded8 37 debug("* source: default load address = 0x%08lx\n", addr);
424c4abd 38#if defined(CONFIG_FIT)
bb872dd9
SG
39 } else if (fit_parse_subimage(argv[1], image_load_addr, &addr,
40 &fit_uname)) {
3c7dded8
SG
41 debug("* source: subimage '%s' from FIT image at 0x%08lx\n",
42 fit_uname, addr);
bcc85b96
SA
43 } else if (fit_parse_conf(argv[1], image_load_addr, &addr, &confname)) {
44 debug("* source: config '%s' from FIT image at 0x%08lx\n",
45 confname, addr);
424c4abd 46#endif
d0dd1077 47 } else {
7e5f460e 48 addr = hextoul(argv[1], NULL);
3c7dded8 49 debug("* source: cmdline image address = 0x%08lx\n", addr);
d0dd1077
WD
50 }
51
424c4abd 52 printf ("## Executing script at %08lx\n", addr);
30f3333d 53 rcode = cmd_source_script(addr, fit_uname, confname);
d0dd1077
WD
54 return rcode;
55}
8bde7f77 56
3616218b 57U_BOOT_LONGHELP(source,
424c4abd 58#if defined(CONFIG_FIT)
bcc85b96
SA
59 "[<addr>][:[<image>]|#[<config>]]\n"
60 "\t- Run script starting at addr\n"
61 "\t- A FIT config name or subimage name may be specified with : or #\n"
62 "\t (like bootm). If the image or config name is omitted, the\n"
3616218b 63 "\t default is used."
bcc85b96
SA
64#else
65 "[<addr>]\n"
3616218b 66 "\t- Run script starting at addr"
088f1b19 67#endif
3616218b 68 );
088f1b19
KP
69
70U_BOOT_CMD(
71 source, 2, 0, do_source,
72 "run script from memory", source_help_text
424c4abd 73);