1 // 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
do_sigsegv(struct cmd_tbl * cmdtp,int flag,int argc,char * const argv[])11 static 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
do_undefined(struct cmd_tbl * cmdtp,int flag,int argc,char * const argv[])20 static 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
27 static 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
34 static char exception_help_text[] =
35 "<ex>\n"
36 " The following exceptions are available:\n"
37 " undefined - undefined instruction\n"
38 " sigsegv - illegal memory access\n"
39 ;
40
41 #include <exception.h>
42