diff mbox

[U-Boot] sandbox: Don't try distro_bootcmd by default

Message ID 1430080316-826-1-git-send-email-sjoerd.simons@collabora.co.uk
State Superseded
Delegated to: Simon Glass
Headers show

Commit Message

Sjoerd Simons April 26, 2015, 8:31 p.m. UTC
For the distro_bootcmds to succeed on the sandbox a bit of setup is
required (e.g. network configured or host image bound), so running them
by default isn't that useful.

Add a -b/--boot command to the sandbox binary, which triggers the
distro_bootcmds to run after the other command-line commands.

Signed-off-by: Sjoerd Simons <sjoerd.simons@collabora.co.uk>
---
Patch is against the u-boot-x86/sandbox branch

 arch/sandbox/cpu/start.c         | 20 +++++++++++++++++---
 arch/sandbox/include/asm/state.h |  1 +
 include/configs/sandbox.h        |  2 ++
 3 files changed, 20 insertions(+), 3 deletions(-)

Comments

Simon Glass April 27, 2015, 8:56 p.m. UTC | #1
Hi Sjoerd,

On 26 April 2015 at 14:31, Sjoerd Simons <sjoerd.simons@collabora.co.uk> wrote:
> For the distro_bootcmds to succeed on the sandbox a bit of setup is
> required (e.g. network configured or host image bound), so running them
> by default isn't that useful.
>
> Add a -b/--boot command to the sandbox binary, which triggers the
> distro_bootcmds to run after the other command-line commands.
>
> Signed-off-by: Sjoerd Simons <sjoerd.simons@collabora.co.uk>
> ---
> Patch is against the u-boot-x86/sandbox branch
>
>  arch/sandbox/cpu/start.c         | 20 +++++++++++++++++---
>  arch/sandbox/include/asm/state.h |  1 +
>  include/configs/sandbox.h        |  2 ++
>  3 files changed, 20 insertions(+), 3 deletions(-)
>
> diff --git a/arch/sandbox/cpu/start.c b/arch/sandbox/cpu/start.c
> index ec01040..ed2c569 100644
> --- a/arch/sandbox/cpu/start.c
> +++ b/arch/sandbox/cpu/start.c
> @@ -77,12 +77,18 @@ int sandbox_main_loop_init(void)
>         struct sandbox_state *state = state_get_current();
>
>         /* Execute command if required */
> -       if (state->cmd) {
> -               int retval;
> +       if (state->cmd || state->boot) {
> +               int retval = 0;
>
>                 cli_init();
>
> -               retval = run_command_list(state->cmd, -1, 0);
> +               if (state->cmd)
> +                       retval = run_command_list(state->cmd, -1, 0);
> +
> +               if (state->boot)
> +                       retval = cli_simple_run_command("run distro_bootcmd",
> +                                                       0);
> +
>                 if (!state->interactive)
>                         os_exit(retval);
>         }
> @@ -90,6 +96,14 @@ int sandbox_main_loop_init(void)
>         return 0;
>  }
>
> +static int sandbox_cmdline_cb_boot(struct sandbox_state *state,
> +                                     const char *arg)
> +{
> +       state->boot = true;
> +       return 0;
> +}
> +SANDBOX_CMDLINE_OPT_SHORT(boot, 'b', 0, "Run distro boot commands");
> +
>  static int sandbox_cmdline_cb_command(struct sandbox_state *state,
>                                       const char *arg)
>  {
> diff --git a/arch/sandbox/include/asm/state.h b/arch/sandbox/include/asm/state.h
> index a0c24ba..02d9f0f 100644
> --- a/arch/sandbox/include/asm/state.h
> +++ b/arch/sandbox/include/asm/state.h
> @@ -42,6 +42,7 @@ struct sandbox_spi_info {
>  struct sandbox_state {
>         const char *cmd;                /* Command to execute */
>         bool interactive;               /* Enable cmdline after execute */
> +       bool boot;              /* Automatically run distro bootcommands */

Can you rename this to something a bit more meaningful? Perhaps
'run_distro_boot' or something similar?

>         const char *fdt_fname;          /* Filename of FDT binary */
>         const char *parse_err;          /* Error to report from parsing */
>         int argc;                       /* Program arguments */
> diff --git a/include/configs/sandbox.h b/include/configs/sandbox.h
> index 9394dd3..9d67afc 100644
> --- a/include/configs/sandbox.h
> +++ b/include/configs/sandbox.h
> @@ -127,6 +127,8 @@
>         func(HOST, host, 1) \
>         func(HOST, host, 0)
>
> +#define CONFIG_BOOTCOMMAND ""
> +
>  #include <config_distro_bootcmd.h>
>
>  #define CONFIG_KEEP_SERVERADDR
> --
> 2.1.4
>

Regards,
Simon
diff mbox

Patch

diff --git a/arch/sandbox/cpu/start.c b/arch/sandbox/cpu/start.c
index ec01040..ed2c569 100644
--- a/arch/sandbox/cpu/start.c
+++ b/arch/sandbox/cpu/start.c
@@ -77,12 +77,18 @@  int sandbox_main_loop_init(void)
 	struct sandbox_state *state = state_get_current();
 
 	/* Execute command if required */
-	if (state->cmd) {
-		int retval;
+	if (state->cmd || state->boot) {
+		int retval = 0;
 
 		cli_init();
 
-		retval = run_command_list(state->cmd, -1, 0);
+		if (state->cmd)
+			retval = run_command_list(state->cmd, -1, 0);
+
+		if (state->boot)
+			retval = cli_simple_run_command("run distro_bootcmd",
+							0);
+
 		if (!state->interactive)
 			os_exit(retval);
 	}
@@ -90,6 +96,14 @@  int sandbox_main_loop_init(void)
 	return 0;
 }
 
+static int sandbox_cmdline_cb_boot(struct sandbox_state *state,
+				      const char *arg)
+{
+	state->boot = true;
+	return 0;
+}
+SANDBOX_CMDLINE_OPT_SHORT(boot, 'b', 0, "Run distro boot commands");
+
 static int sandbox_cmdline_cb_command(struct sandbox_state *state,
 				      const char *arg)
 {
diff --git a/arch/sandbox/include/asm/state.h b/arch/sandbox/include/asm/state.h
index a0c24ba..02d9f0f 100644
--- a/arch/sandbox/include/asm/state.h
+++ b/arch/sandbox/include/asm/state.h
@@ -42,6 +42,7 @@  struct sandbox_spi_info {
 struct sandbox_state {
 	const char *cmd;		/* Command to execute */
 	bool interactive;		/* Enable cmdline after execute */
+	bool boot;		/* Automatically run distro bootcommands */
 	const char *fdt_fname;		/* Filename of FDT binary */
 	const char *parse_err;		/* Error to report from parsing */
 	int argc;			/* Program arguments */
diff --git a/include/configs/sandbox.h b/include/configs/sandbox.h
index 9394dd3..9d67afc 100644
--- a/include/configs/sandbox.h
+++ b/include/configs/sandbox.h
@@ -127,6 +127,8 @@ 
 	func(HOST, host, 1) \
 	func(HOST, host, 0)
 
+#define CONFIG_BOOTCOMMAND ""
+
 #include <config_distro_bootcmd.h>
 
 #define CONFIG_KEEP_SERVERADDR