Skip to contentSkip to conversation

cmd: go: Make do_go available to outside boot.c

PATCH New Emmanuel Vadot 3 participants 8 messages Jan 2, 2018 – Jan 8, 2018

lore
Share & tools
lore
#0 lore raw

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.

---
 cmd/boot.c        | 2 +-
 include/command.h | 4 ++++
 2 files changed, 5 insertions(+), 1 deletion(-)
cmd/boot.c +1 -1
index 72f2cf362d..5691c5f883 100644
@@ -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;
include/command.h +4 -0
index 767cabb3df..377e2eadd4 100644
@@ -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[]);
 
Signature · 1 line
2.15.1
#1 lore raw

PATCH 2/2 sysboot: Call bootm booti bootz then go on label_boot

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.

---
 cmd/pxe.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)
cmd/pxe.c +7 -5
index 7043ad11fd..0ca6a964bc 100644
@@ -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;
Signature · 1 line
2.15.1
#2 lore raw

PATCH 2/2 sysboot: Call bootm booti bootz then go on label_boot

Hi Emmanuel,

Quoted 3 lines · Emmanuel Vadot

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.

Quoted 31 lines
---
 cmd/pxe.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)
cmd/pxe.c +7 -6
index 7043ad11fd..0ca6a964bc 100644
@@ -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;
--
Quoted 2 lines

2.15.1

Regards,
Simon

#3 lore raw

PATCH 2/2 sysboot: Call bootm booti bootz then go on label_boot

Quoted 8 lines · On Sun, 7 Jan 2018 21:39:01 -0700 Simon Glass <[email protected]> wrote:

Hi Emmanuel,

Quoted 3 lines · Emmanuel Vadot

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 ?

Quoted 1 line

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 ?

Quoted 36 lines
Quoted 31 lines
---
 cmd/pxe.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)
cmd/pxe.c +7 -6
index 7043ad11fd..0ca6a964bc 100644
@@ -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;
--
Quoted 2 lines

2.15.1

Regards,
Simon

Signature · 1 line
Emmanuel Vadot <[email protected]> <[email protected]>
#4 lore raw

PATCH 2/2 sysboot: Call bootm booti bootz then go on label_boot

Hi Emmanuel,

Quoted 10 lines · Emmanuel Vadot
Quoted 7 lines · On Sun, 7 Jan 2018 21:39:01 -0700 Simon Glass <[email protected]> wrote:

Hi Emmanuel,

Quoted 3 lines · Emmanuel Vadot

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.

Quoted 8 lines
Quoted 1 line

Do we not know which type of binary it is?

For which case ?

Quoted 1 line

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?

Quoted 25 lines
Quoted 25 lines
Quoted 25 lines
---
 cmd/pxe.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)
cmd/pxe.c +4 -5
index 7043ad11fd..0ca6a964bc 100644
@@ -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);
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
cmd/pxe.c +3 -1
+#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

#5 lore raw

PATCH 1/2 cmd: go: Make do_go available to outside boot.c

In reply to Emmanuel Vadot

Hi Emmanuel,

Quoted 9 lines · Emmanuel Vadot

Some commands (like sysboot) might want to call go as they can encounter a raw binary.
Make do_go callable for everyone.

---
 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()?

Quoted 30 lines
cmd/boot.c +1 -1
index 72f2cf362d..5691c5f883 100644
@@ -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;
include/command.h +4 -1
index 767cabb3df..377e2eadd4 100644
@@ -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[]);
 
--
Quoted 2 lines

2.15.1

Regards,
Simon

#6 lore raw

PATCH 1/2 cmd: go: Make do_go available to outside boot.c

Hello Simon,

Quoted 7 lines · On Sun, 7 Jan 2018 21:38:29 -0700 Simon Glass <[email protected]> wrote:

Hi Emmanuel,

Quoted 4 lines · Emmanuel Vadot

Some commands (like sysboot) might want to call go as they can encounter a raw binary.
Make do_go callable for everyone.

Quoted 8 lines
Quoted 5 lines
---
 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.

Quoted 35 lines
Quoted 30 lines
cmd/boot.c +1 -1
index 72f2cf362d..5691c5f883 100644
@@ -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;
include/command.h +4 -1
index 767cabb3df..377e2eadd4 100644
@@ -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[]);
 
--
Quoted 2 lines

2.15.1

Regards,
Simon

Signature · 1 line
Emmanuel Vadot <[email protected]> <[email protected]>
#7 lore raw

PATCH 1/2 cmd: go: Make do_go available to outside boot.c

Hi Emmanuel,

Quoted 20 lines · Emmanuel Vadot

Hello Simon,

Quoted 13 lines · On Sun, 7 Jan 2018 21:38:29 -0700 Simon Glass <[email protected]> wrote:

Hi Emmanuel,

Quoted 9 lines · Emmanuel Vadot

Some commands (like sysboot) might want to call go as they can encounter a raw binary.
Make do_go callable for everyone.

---
 cmd/boot.c        | 2 +-
 include/command.h | 4 ++++
 2 files changed, 5 insertions(+), 1 deletion(-)
Quoted 4 lines
Quoted 2 lines

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