From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH 2/2] sandbox: add cpuinfo command
Date: Wed, 16 Oct 2024 10:55:43 +0200 [thread overview]
Message-ID: <20241016085543.3961965-2-a.fatoum@pengutronix.de> (raw)
In-Reply-To: <20241016085543.3961965-1-a.fatoum@pengutronix.de>
We have stack dump support in sandbox via AddressSanitizer, if it's
compiled in. To make it easier to test proper operation, let's a cpuinfo
command like we already do on ARM and give it the same -s option.
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
arch/sandbox/Kconfig | 7 +++++++
arch/sandbox/board/Makefile | 1 +
arch/sandbox/board/cpuinfo.c | 40 ++++++++++++++++++++++++++++++++++++
3 files changed, 48 insertions(+)
create mode 100644 arch/sandbox/board/cpuinfo.c
diff --git a/arch/sandbox/Kconfig b/arch/sandbox/Kconfig
index 52915490ca98..caff3a138fea 100644
--- a/arch/sandbox/Kconfig
+++ b/arch/sandbox/Kconfig
@@ -58,6 +58,13 @@ config SANDBOX_REEXEC
The normal reset handler hangs barebox. On Linux, barebox
instead can exec itself to simulate a reset.
+config CMD_SANDBOX_CPUINFO
+ bool "cpuinfo command"
+ depends on COMMAND_SUPPORT
+ default y
+ help
+ Say yes here to get a dummy cpuinfo command.
+
config SDL
bool
diff --git a/arch/sandbox/board/Makefile b/arch/sandbox/board/Makefile
index 8e6e1d2d8843..029bfe7ff163 100644
--- a/arch/sandbox/board/Makefile
+++ b/arch/sandbox/board/Makefile
@@ -10,6 +10,7 @@ obj-y += dtb.o
obj-y += power.o
obj-y += dev-random.o
obj-y += watchdog.o
+obj-$(CONFIG_CMD_SANDBOX_CPUINFO) += cpuinfo.o
obj-$(CONFIG_LED) += led.o
extra-y += barebox.lds
diff --git a/arch/sandbox/board/cpuinfo.c b/arch/sandbox/board/cpuinfo.c
new file mode 100644
index 000000000000..ce2762e607fd
--- /dev/null
+++ b/arch/sandbox/board/cpuinfo.c
@@ -0,0 +1,40 @@
+// SPDX-License-Identifier: GPL-2.0-only
+
+#include <common.h>
+#include <getopt.h>
+#include <command.h>
+#include <complete.h>
+
+static int do_cpuinfo(int argc, char *argv[])
+{
+ int opt;
+
+ while ((opt = getopt(argc, argv, "s")) > 0) {
+ switch (opt) {
+ case 's':
+ if (!IS_ENABLED(CONFIG_ARCH_HAS_STACK_DUMP))
+ return -ENOSYS;
+
+ dump_stack();
+ return 0;
+ default:
+ return COMMAND_ERROR_USAGE;
+ }
+ }
+
+ return 0;
+}
+
+BAREBOX_CMD_HELP_START(cpuinfo)
+BAREBOX_CMD_HELP_TEXT("Shows misc info about CPU")
+BAREBOX_CMD_HELP_OPT ("-s", "print call stack info (if supported)")
+BAREBOX_CMD_HELP_END
+
+BAREBOX_CMD_START(cpuinfo)
+ .cmd = do_cpuinfo,
+ BAREBOX_CMD_DESC("show info about CPU")
+ BAREBOX_CMD_OPTS("[-s]")
+ BAREBOX_CMD_GROUP(CMD_GRP_INFO)
+ BAREBOX_CMD_COMPLETE(empty_complete)
+ BAREBOX_CMD_HELP(cmd_cpuinfo_help)
+BAREBOX_CMD_END
--
2.39.5
next prev parent reply other threads:[~2024-10-16 8:57 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-16 8:55 [PATCH 1/2] sandbox: add --command line support Ahmad Fatoum
2024-10-16 8:55 ` Ahmad Fatoum [this message]
2024-10-16 9:32 ` [PATCH 2/2] sandbox: add cpuinfo command Yann Sionneau
2024-10-18 9:06 ` Sascha Hauer
2024-10-21 7:35 ` Ahmad Fatoum
2024-10-16 9:54 ` [PATCH 1/2] sandbox: add --command line support Yann Sionneau
2024-10-16 9:56 ` Ahmad Fatoum
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20241016085543.3961965-2-a.fatoum@pengutronix.de \
--to=a.fatoum@pengutronix.de \
--cc=barebox@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox