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 |


Reply via email to