From: "Sascha Hauer" <s.hauer@pengutronix.de>
To: "Ahmad Fatoum" <a.fatoum@pengutronix.de>
Cc: barebox@lists.infradead.org, "Ahmad Fatoum" <a.fatoum@pengutronix.de>
Subject: Re: [PATCH] semihosting: add semihosting_exit() and an smhexit command
Date: Wed, 23 Sep 2026 06:25:43 +0000 [thread overview]
Message-ID: <6551e95c-71cf-44df-a327-e5e24bdb3a76@pengutronix.de> (raw)
In-Reply-To: <20260921101948.1007488-1-a.fatoum@pengutronix.de>
On 2026-09-21 12:18, Ahmad Fatoum wrote:
> +
> +static int do_smhexit(int argc, char *argv[])
> +{
> + bool extended_flag = true, shutdown_flag = true;
> + int opt, status = 0;
> +
> + while ((opt = getopt(argc, argv, "pf")) > 0) {
> + switch (opt) {
> + case 'p':
> + extended_flag = false;
> + break;
> + case 'f':
> + shutdown_flag = false;
> + break;
> + default:
> + return COMMAND_ERROR_USAGE;
> + }
> + }
> +
> + argc -= optind;
> + argv += optind;
> +
> + if (argc > 1)
> + return COMMAND_ERROR_USAGE;
> +
> + if (argc == 1 && kstrtoint(argv[0], 0, &status))
> + return COMMAND_ERROR_USAGE;
> +
> + if (shutdown_flag)
> + shutdown_barebox();
> +
> + console_flush();
> + semihosting_exit(status, extended_flag);
> +
> + /* Unreachable */
unreachable();
> + return 1;
> +}
> +
> +BAREBOX_CMD_HELP_START(smhexit)
> +BAREBOX_CMD_HELP_TEXT("Tell the debugger or emulator barebox runs under that the session")
> +BAREBOX_CMD_HELP_TEXT("is over and hand it STATUS (0 if none is given) as the exit status.")
> +BAREBOX_CMD_HELP_TEXT("QEMU exits with it, so a boot driven from the outside can report")
> +BAREBOX_CMD_HELP_TEXT("its outcome without anything having to read the console.")
> +BAREBOX_CMD_HELP_TEXT("")
> +BAREBOX_CMD_HELP_TEXT("Options:")
> +BAREBOX_CMD_HELP_OPT("-p", "use the plain SYS_EXIT call for a host that has no")
> +BAREBOX_CMD_HELP_OPT("", "SYS_EXIT_EXTENDED. On 32-bit, this loses STATUS.")
-f option is not documented.
> +BAREBOX_CMD_HELP_TEXT("")
> +BAREBOX_CMD_HELP_TEXT("Without a host listening the trap instruction is undefined and the")
> +BAREBOX_CMD_HELP_TEXT("machine stops instead.")
> +BAREBOX_CMD_HELP_END
> +
Sascha
--
Pengutronix e.K. | |
Steuerwalder Str. 21 | http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
prev parent reply other threads:[~2026-09-23 6:27 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-21 10:18 Ahmad Fatoum
2026-09-23 6:25 ` Sascha Hauer [this message]
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=6551e95c-71cf-44df-a327-e5e24bdb3a76@pengutronix.de \
--to=s.hauer@pengutronix.de \
--cc=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