]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
sandbox: Add a new 'sb' command
authorSimon Glass <sjg@chromium.org>
Fri, 16 Nov 2018 01:44:03 +0000 (18:44 -0700)
committerTom Rini <trini@konsulko.com>
Mon, 26 Nov 2018 13:25:36 +0000 (08:25 -0500)
The old 'sb' command was deprecated in 2015 and replaced with 'host'. It
is useful to be able to access some internal sandbox state, particularly
for testing.

Resurrect the old command and provide a way to print some basic state
information (currently just the arguments to sandbox).

Signed-off-by: Simon Glass <sjg@chromium.org>
arch/sandbox/cpu/start.c
arch/sandbox/include/asm/state.h
cmd/Makefile
cmd/sb.c [new file with mode: 0644]

index 28ca35392c946d924d31eb2b45c4460d5f14197e..b1566a8143571ad63776cbb79b15a15666b3af80 100644 (file)
@@ -305,6 +305,16 @@ static void setup_ram_buf(struct sandbox_state *state)
        gd->ram_size = state->ram_size;
 }
 
+void state_show(struct sandbox_state *state)
+{
+       char **p;
+
+       printf("Arguments:\n");
+       for (p = state->argv; *p; p++)
+               printf("%s ", *p);
+       printf("\n");
+}
+
 int main(int argc, char *argv[])
 {
        struct sandbox_state *state;
index 0a2e3c41ae30417a46d82b212fb6dcca7add80da..8fabe70a86d8ee84d4965d1c0fbf3b4624e386c4 100644 (file)
@@ -242,6 +242,13 @@ bool state_get_skip_delays(void);
  */
 void state_reset_for_test(struct sandbox_state *state);
 
+/**
+ * state_show() - Show information about the sandbox state
+ *
+ * @param state                Sandbox state to show
+ */
+void state_show(struct sandbox_state *state);
+
 /**
  * Initialize the test system state
  */
index 0534ddc67975d40afcccd2c148b87858ac94ec59..5ec2f9e8ebfdf42533b9079470bd73b47d0f0f4e 100644 (file)
@@ -115,6 +115,7 @@ obj-$(CONFIG_CMD_ROCKUSB) += rockusb.o
 obj-$(CONFIG_SANDBOX) += host.o
 obj-$(CONFIG_CMD_SATA) += sata.o
 obj-$(CONFIG_CMD_NVME) += nvme.o
+obj-$(CONFIG_SANDBOX) += sb.o
 obj-$(CONFIG_CMD_SF) += sf.o
 obj-$(CONFIG_CMD_SCSI) += scsi.o disk.o
 obj-$(CONFIG_CMD_SHA1SUM) += sha1sum.o
diff --git a/cmd/sb.c b/cmd/sb.c
new file mode 100644 (file)
index 0000000..6ca3361
--- /dev/null
+++ b/cmd/sb.c
@@ -0,0 +1,46 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright 2018, Google Inc.
+ * Written by Simon Glass <sjg@chromium.org>
+ */
+
+#include <common.h>
+#include <dm.h>
+#include <spl.h>
+#include <asm/state.h>
+
+static int do_sb_state(cmd_tbl_t *cmdtp, int flag, int argc,
+                      char * const argv[])
+{
+       struct sandbox_state *state;
+
+       state = state_get_current();
+       state_show(state);
+
+       return 0;
+}
+
+static cmd_tbl_t cmd_sb_sub[] = {
+       U_BOOT_CMD_MKENT(state, 1, 0, do_sb_state, "", ""),
+};
+
+static int do_sb(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+{
+       cmd_tbl_t *c;
+
+       /* Skip past 'sb' */
+       argc--;
+       argv++;
+
+       c = find_cmd_tbl(argv[0], cmd_sb_sub, ARRAY_SIZE(cmd_sb_sub));
+       if (c)
+               return c->cmd(cmdtp, flag, argc, argv);
+       else
+               return CMD_RET_USAGE;
+}
+
+U_BOOT_CMD(
+       sb,     8,      1,      do_sb,
+       "Sandbox status commands",
+       "state       - Show sandbox state"
+);