blob: 1aa1d673aed426e6c1cc95e0f0db9c7e5166f382 [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
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
34static 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>