diff mbox series

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

Message ID 20180102212714.58450-1-manu@freebsd.org
State Changes Requested
Delegated to: Tom Rini
Headers show
Series [U-Boot,1/2] cmd: go: Make do_go available to outside boot.c | expand

Commit Message

Emmanuel Vadot Jan. 2, 2018, 9:27 p.m. UTC
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(-)

Comments

Simon Glass Jan. 8, 2018, 4:38 a.m. UTC | #1
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
Emmanuel Vadot Jan. 8, 2018, 10 a.m. UTC | #2
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
Simon Glass Jan. 8, 2018, 10:11 p.m. UTC | #3
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
diff mbox series

Patch

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[]);