Heinrich Schuchardt | adaea9c | 2020-11-12 00:29:57 +0100 | [diff] [blame] | 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 | |
Heinrich Schuchardt | adaea9c | 2020-11-12 00:29:57 +0100 | [diff] [blame] | 8 | #include <command.h> |
| 9 | |
| 10 | static 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 | |
| 19 | static int do_undefined(struct cmd_tbl *cmdtp, int flag, int argc, |
| 20 | char *const argv[]) |
| 21 | { |
WHR | 63548fb | 2024-05-01 00:55:10 +0800 | [diff] [blame] | 22 | #ifdef __powerpc__ |
| 23 | asm volatile (".long 0xffffffff\n"); |
| 24 | #else |
Heinrich Schuchardt | adaea9c | 2020-11-12 00:29:57 +0100 | [diff] [blame] | 25 | asm volatile (".word 0xffff\n"); |
WHR | 63548fb | 2024-05-01 00:55:10 +0800 | [diff] [blame] | 26 | #endif |
Heinrich Schuchardt | adaea9c | 2020-11-12 00:29:57 +0100 | [diff] [blame] | 27 | return CMD_RET_FAILURE; |
| 28 | } |
| 29 | |
| 30 | static struct cmd_tbl cmd_sub[] = { |
| 31 | U_BOOT_CMD_MKENT(sigsegv, CONFIG_SYS_MAXARGS, 1, do_sigsegv, |
| 32 | "", ""), |
| 33 | U_BOOT_CMD_MKENT(undefined, CONFIG_SYS_MAXARGS, 1, do_undefined, |
| 34 | "", ""), |
| 35 | }; |
| 36 | |
Tom Rini | 03f146c | 2023-10-07 15:13:08 -0400 | [diff] [blame] | 37 | U_BOOT_LONGHELP(exception, |
Heinrich Schuchardt | adaea9c | 2020-11-12 00:29:57 +0100 | [diff] [blame] | 38 | "<ex>\n" |
| 39 | " The following exceptions are available:\n" |
| 40 | " undefined - undefined instruction\n" |
Tom Rini | 03f146c | 2023-10-07 15:13:08 -0400 | [diff] [blame] | 41 | " sigsegv - illegal memory access\n"); |
Heinrich Schuchardt | adaea9c | 2020-11-12 00:29:57 +0100 | [diff] [blame] | 42 | |
| 43 | #include <exception.h> |