blob: cfa153da26028e8455402e126de590ed7e2c174c [file] [log] [blame]
Heinrich Schuchardtadaea9c2020-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
Heinrich Schuchardtadaea9c2020-11-12 00:29:57 +01008#include <command.h>
9
10static int do_sigsegv(struct cmd_tbl *cmdtp, int flag, int argc,
11 char *const argv[])
12{
13 u8 *ptr = NULL;
14
15 *ptr = 0;
16 return CMD_RET_FAILURE;
17}
18
19static int do_undefined(struct cmd_tbl *cmdtp, int flag, int argc,
20 char *const argv[])
21{
22 asm volatile (".word 0xffff\n");
23 return CMD_RET_FAILURE;
24}
25
26static struct cmd_tbl cmd_sub[] = {
27 U_BOOT_CMD_MKENT(sigsegv, CONFIG_SYS_MAXARGS, 1, do_sigsegv,
28 "", ""),
29 U_BOOT_CMD_MKENT(undefined, CONFIG_SYS_MAXARGS, 1, do_undefined,
30 "", ""),
31};
32
Tom Rini03f146c2023-10-07 15:13:08 -040033U_BOOT_LONGHELP(exception,
Heinrich Schuchardtadaea9c2020-11-12 00:29:57 +010034 "<ex>\n"
35 " The following exceptions are available:\n"
36 " undefined - undefined instruction\n"
Tom Rini03f146c2023-10-07 15:13:08 -040037 " sigsegv - illegal memory access\n");
Heinrich Schuchardtadaea9c2020-11-12 00:29:57 +010038
39#include <exception.h>