blob: c082401ce6b34feb2b598b2060ae2264698823b6 [file] [log] [blame]
Heinrich Schuchardt3a5ec032020-11-12 00:29:57 +01001// SPDX-License-Identifier: GPL-2.0+
2/*
3 * The 'exception' command can be used for testing exception handling.
4 *
5 * Copyright (c) 2020, Heinrich Schuchardt <xypron.glpk@gmx.de>
6 */
7
8#include <common.h>
9#include <command.h>
10
11static int do_sigsegv(struct cmd_tbl *cmdtp, int flag, int argc,
12 char *const argv[])
13{
14 u8 *ptr = NULL;
15
16 *ptr = 0;
17 return CMD_RET_FAILURE;
18}
19
20static int do_undefined(struct cmd_tbl *cmdtp, int flag, int argc,
21 char *const argv[])
22{
23 asm volatile (".word 0xffff\n");
24 return CMD_RET_FAILURE;
25}
26
27static struct cmd_tbl cmd_sub[] = {
28 U_BOOT_CMD_MKENT(sigsegv, CONFIG_SYS_MAXARGS, 1, do_sigsegv,
29 "", ""),
30 U_BOOT_CMD_MKENT(undefined, CONFIG_SYS_MAXARGS, 1, do_undefined,
31 "", ""),
32};
33
Tom Rini36162182023-10-07 15:13:08 -040034U_BOOT_LONGHELP(exception,
Heinrich Schuchardt3a5ec032020-11-12 00:29:57 +010035 "<ex>\n"
36 " The following exceptions are available:\n"
37 " undefined - undefined instruction\n"
Tom Rini36162182023-10-07 15:13:08 -040038 " sigsegv - illegal memory access\n");
Heinrich Schuchardt3a5ec032020-11-12 00:29:57 +010039
40#include <exception.h>