[U-Boot] [PATCH 1/2] cmd: go: Make do_go available to outside boot.c

Some commands (like sysboot) might want to call go as they can encounter a raw binary. Make do_go callable for everyone.
Signed-off-by: Emmanuel Vadot manu@freebsd.org --- cmd/boot.c | 2 +- include/command.h | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-)
diff --git a/cmd/boot.c b/cmd/boot.c index 72f2cf362d..5691c5f883 100644 --- a/cmd/boot.c +++ b/cmd/boot.c @@ -22,7 +22,7 @@ unsigned long do_go_exec(ulong (*entry)(int, char * const []), int argc, return entry (argc, argv); }
-static int do_go(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) +int do_go(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) { ulong addr, rc; int rcode = 0; diff --git a/include/command.h b/include/command.h index 767cabb3df..377e2eadd4 100644 --- a/include/command.h +++ b/include/command.h @@ -105,6 +105,10 @@ extern int do_bootz(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]);
extern int do_booti(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]);
+#ifdef CONFIG_CMD_GO +extern int do_go(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]); +#endif + extern int common_diskboot(cmd_tbl_t *cmdtp, const char *intf, int argc, char *const argv[]);

As do_bootm/do_booti/do_bootz will not return if the boot succeded, always call them if enable by the config. Also add a fallback to go if the binary is a raw one.
Signed-off-by: Emmanuel Vadot manu@freebsd.org --- cmd/pxe.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/cmd/pxe.c b/cmd/pxe.c index 7043ad11fd..0ca6a964bc 100644 --- a/cmd/pxe.c +++ b/cmd/pxe.c @@ -796,12 +796,14 @@ static int label_boot(cmd_tbl_t *cmdtp, struct pxe_label *label) do_bootm(cmdtp, 0, bootm_argc, bootm_argv); #ifdef CONFIG_CMD_BOOTI /* Try booting an AArch64 Linux kernel image */ - else - do_booti(cmdtp, 0, bootm_argc, bootm_argv); -#elif defined(CONFIG_CMD_BOOTZ) + do_booti(cmdtp, 0, bootm_argc, bootm_argv); +#endif +#if defined(CONFIG_CMD_BOOTZ) /* Try booting a Image */ - else - do_bootz(cmdtp, 0, bootm_argc, bootm_argv); + do_bootz(cmdtp, 0, bootm_argc, bootm_argv); +#endif +#if defined(CONFIG_CMD_GO) + do_go(cmdtp, 0, bootm_argc, bootm_argv); #endif unmap_sysmem(buf); return 1;

Hi Emmanuel,
On 2 January 2018 at 14:27, Emmanuel Vadot manu@freebsd.org wrote:
As do_bootm/do_booti/do_bootz will not return if the boot succeded, always call them if enable by the config. Also add a fallback to go if the binary is a raw one.
Do we not know which type of binary it is? It seems like we should have some error checking here.
Signed-off-by: Emmanuel Vadot manu@freebsd.org
cmd/pxe.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/cmd/pxe.c b/cmd/pxe.c index 7043ad11fd..0ca6a964bc 100644 --- a/cmd/pxe.c +++ b/cmd/pxe.c @@ -796,12 +796,14 @@ static int label_boot(cmd_tbl_t *cmdtp, struct pxe_label *label) do_bootm(cmdtp, 0, bootm_argc, bootm_argv); #ifdef CONFIG_CMD_BOOTI /* Try booting an AArch64 Linux kernel image */
else
do_booti(cmdtp, 0, bootm_argc, bootm_argv);
-#elif defined(CONFIG_CMD_BOOTZ)
do_booti(cmdtp, 0, bootm_argc, bootm_argv);
+#endif +#if defined(CONFIG_CMD_BOOTZ) /* Try booting a Image */
else
do_bootz(cmdtp, 0, bootm_argc, bootm_argv);
do_bootz(cmdtp, 0, bootm_argc, bootm_argv);
+#endif +#if defined(CONFIG_CMD_GO)
do_go(cmdtp, 0, bootm_argc, bootm_argv);
#endif unmap_sysmem(buf); return 1; -- 2.15.1
Regards, Simon

On Sun, 7 Jan 2018 21:39:01 -0700 Simon Glass sjg@chromium.org wrote:
Hi Emmanuel,
On 2 January 2018 at 14:27, Emmanuel Vadot manu@freebsd.org wrote:
As do_bootm/do_booti/do_bootz will not return if the boot succeded, always call them if enable by the config. Also add a fallback to go if the binary is a raw one.
Do we not know which type of binary it is?
For which case ?
It seems like we should have some error checking here.
Each bootX function check the header/magic/etc ... What kind of error checking do you want to add ?
Signed-off-by: Emmanuel Vadot manu@freebsd.org
cmd/pxe.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/cmd/pxe.c b/cmd/pxe.c index 7043ad11fd..0ca6a964bc 100644 --- a/cmd/pxe.c +++ b/cmd/pxe.c @@ -796,12 +796,14 @@ static int label_boot(cmd_tbl_t *cmdtp, struct pxe_label *label) do_bootm(cmdtp, 0, bootm_argc, bootm_argv); #ifdef CONFIG_CMD_BOOTI /* Try booting an AArch64 Linux kernel image */
else
do_booti(cmdtp, 0, bootm_argc, bootm_argv);
-#elif defined(CONFIG_CMD_BOOTZ)
do_booti(cmdtp, 0, bootm_argc, bootm_argv);
+#endif +#if defined(CONFIG_CMD_BOOTZ) /* Try booting a Image */
else
do_bootz(cmdtp, 0, bootm_argc, bootm_argv);
do_bootz(cmdtp, 0, bootm_argc, bootm_argv);
+#endif +#if defined(CONFIG_CMD_GO)
do_go(cmdtp, 0, bootm_argc, bootm_argv);
#endif unmap_sysmem(buf); return 1; -- 2.15.1
Regards, Simon

Hi Emmanuel,
On 8 January 2018 at 03:05, Emmanuel Vadot manu@bidouilliste.com wrote:
On Sun, 7 Jan 2018 21:39:01 -0700 Simon Glass sjg@chromium.org wrote:
Hi Emmanuel,
On 2 January 2018 at 14:27, Emmanuel Vadot manu@freebsd.org wrote:
As do_bootm/do_booti/do_bootz will not return if the boot succeded, always call them if enable by the config. Also add a fallback to go if the binary is a raw one.
Do we not know which type of binary it is?
For which case ?
It seems like we should have some error checking here.
Each bootX function check the header/magic/etc ... What kind of error checking do you want to add ?
Well, it looks like you have a fallback so that if the image does not pass any of the header/magic checks you just jump to it,. Won't that crash if (e.g.) someone uses a valid image but one for which support is turned off in the U-Boot build?
I'm not sure of the solution, but perhaps we should have a CONFIG option to enable this fallback?
Signed-off-by: Emmanuel Vadot manu@freebsd.org
cmd/pxe.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/cmd/pxe.c b/cmd/pxe.c index 7043ad11fd..0ca6a964bc 100644 --- a/cmd/pxe.c +++ b/cmd/pxe.c @@ -796,12 +796,14 @@ static int label_boot(cmd_tbl_t *cmdtp, struct pxe_label *label) do_bootm(cmdtp, 0, bootm_argc, bootm_argv); #ifdef CONFIG_CMD_BOOTI /* Try booting an AArch64 Linux kernel image */
else
do_booti(cmdtp, 0, bootm_argc, bootm_argv);
-#elif defined(CONFIG_CMD_BOOTZ)
do_booti(cmdtp, 0, bootm_argc, bootm_argv);
+#endif +#if defined(CONFIG_CMD_BOOTZ) /* Try booting a Image */
else
do_bootz(cmdtp, 0, bootm_argc, bootm_argv);
do_bootz(cmdtp, 0, bootm_argc, bootm_argv);
+#endif +#if defined(CONFIG_CMD_GO)
do_go(cmdtp, 0, bootm_argc, bootm_argv);
#endif unmap_sysmem(buf); return 1; -- 2.15.1
Regards, Simon

Hi Emmanuel,
On 2 January 2018 at 14:27, Emmanuel Vadot manu@freebsd.org wrote:
Some commands (like sysboot) might want to call go as they can encounter a raw binary. Make do_go callable for everyone.
Signed-off-by: Emmanuel Vadot manu@freebsd.org
cmd/boot.c | 2 +- include/command.h | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-)
Can we instead move the code out of do_go() into another function which accepts C arguments, and then call that from do_go()?
diff --git a/cmd/boot.c b/cmd/boot.c index 72f2cf362d..5691c5f883 100644 --- a/cmd/boot.c +++ b/cmd/boot.c @@ -22,7 +22,7 @@ unsigned long do_go_exec(ulong (*entry)(int, char * const []), int argc, return entry (argc, argv); }
-static int do_go(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) +int do_go(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) { ulong addr, rc; int rcode = 0; diff --git a/include/command.h b/include/command.h index 767cabb3df..377e2eadd4 100644 --- a/include/command.h +++ b/include/command.h @@ -105,6 +105,10 @@ extern int do_bootz(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]);
extern int do_booti(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]);
+#ifdef CONFIG_CMD_GO +extern int do_go(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]); +#endif
extern int common_diskboot(cmd_tbl_t *cmdtp, const char *intf, int argc, char *const argv[]);
-- 2.15.1
Regards, Simon

Hello Simon,
On Sun, 7 Jan 2018 21:38:29 -0700 Simon Glass sjg@chromium.org wrote:
Hi Emmanuel,
On 2 January 2018 at 14:27, Emmanuel Vadot manu@freebsd.org wrote:
Some commands (like sysboot) might want to call go as they can encounter a raw binary. Make do_go callable for everyone.
Signed-off-by: Emmanuel Vadot manu@freebsd.org
cmd/boot.c | 2 +- include/command.h | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-)
Can we instead move the code out of do_go() into another function which accepts C arguments, and then call that from do_go()?
Sorry I do not understand what you mean.
diff --git a/cmd/boot.c b/cmd/boot.c index 72f2cf362d..5691c5f883 100644 --- a/cmd/boot.c +++ b/cmd/boot.c @@ -22,7 +22,7 @@ unsigned long do_go_exec(ulong (*entry)(int, char * const []), int argc, return entry (argc, argv); }
-static int do_go(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) +int do_go(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) { ulong addr, rc; int rcode = 0; diff --git a/include/command.h b/include/command.h index 767cabb3df..377e2eadd4 100644 --- a/include/command.h +++ b/include/command.h @@ -105,6 +105,10 @@ extern int do_bootz(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]);
extern int do_booti(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]);
+#ifdef CONFIG_CMD_GO +extern int do_go(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]); +#endif
extern int common_diskboot(cmd_tbl_t *cmdtp, const char *intf, int argc, char *const argv[]);
-- 2.15.1
Regards, Simon

Hi Emmanuel,
On 8 January 2018 at 03:00, Emmanuel Vadot manu@bidouilliste.com wrote:
Hello Simon,
On Sun, 7 Jan 2018 21:38:29 -0700 Simon Glass sjg@chromium.org wrote:
Hi Emmanuel,
On 2 January 2018 at 14:27, Emmanuel Vadot manu@freebsd.org wrote:
Some commands (like sysboot) might want to call go as they can encounter a raw binary. Make do_go callable for everyone.
Signed-off-by: Emmanuel Vadot manu@freebsd.org
cmd/boot.c | 2 +- include/command.h | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-)
Can we instead move the code out of do_go() into another function which accepts C arguments, and then call that from do_go()?
Sorry I do not understand what you mean.
int go_exec(ulong addr) { existing code to jump to addr }
do_go() { existing code to parse args....
go_exec(addr)l }
Then you can call go_eec() from cmd/boot.c
Regards, Simon
participants (3)
-
Emmanuel Vadot
-
Emmanuel Vadot
-
Simon Glass