Heinrich Schuchardt | f7d6b07 | 2018-12-26 17:20:35 +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) 2018, Heinrich Schuchardt <xypron.glpk@gmx.de> |
| 6 | */ |
| 7 | |
Heinrich Schuchardt | f7d6b07 | 2018-12-26 17:20:35 +0100 | [diff] [blame] | 8 | #include <command.h> |
| 9 | |
Simon Glass | ed38aef | 2020-05-10 11:40:03 -0600 | [diff] [blame] | 10 | static int do_unaligned(struct cmd_tbl *cmdtp, int flag, int argc, |
| 11 | char *const argv[]) |
Heinrich Schuchardt | f7d6b07 | 2018-12-26 17:20:35 +0100 | [diff] [blame] | 12 | { |
| 13 | /* |
| 14 | * The LDRD instruction requires the data source to be four byte aligned |
| 15 | * even if strict alignment fault checking is disabled in the system |
| 16 | * control register. |
| 17 | */ |
| 18 | asm volatile ( |
| 19 | "MOV r5, sp\n" |
| 20 | "ADD r5, #1\n" |
| 21 | "LDRD r6, r7, [r5]\n"); |
| 22 | return CMD_RET_FAILURE; |
| 23 | } |
| 24 | |
Simon Glass | ed38aef | 2020-05-10 11:40:03 -0600 | [diff] [blame] | 25 | static int do_breakpoint(struct cmd_tbl *cmdtp, int flag, int argc, |
| 26 | char *const argv[]) |
Heinrich Schuchardt | f7d6b07 | 2018-12-26 17:20:35 +0100 | [diff] [blame] | 27 | { |
| 28 | asm volatile ("BKPT #123\n"); |
| 29 | return CMD_RET_FAILURE; |
| 30 | } |
| 31 | |
Simon Glass | ed38aef | 2020-05-10 11:40:03 -0600 | [diff] [blame] | 32 | static int do_undefined(struct cmd_tbl *cmdtp, int flag, int argc, |
| 33 | char *const argv[]) |
Heinrich Schuchardt | f7d6b07 | 2018-12-26 17:20:35 +0100 | [diff] [blame] | 34 | { |
| 35 | /* |
| 36 | * 0xe7f...f. is undefined in ARM mode |
| 37 | * 0xde.. is undefined in Thumb mode |
| 38 | */ |
| 39 | asm volatile (".word 0xe7f7defb\n"); |
| 40 | return CMD_RET_FAILURE; |
| 41 | } |
| 42 | |
Simon Glass | ed38aef | 2020-05-10 11:40:03 -0600 | [diff] [blame] | 43 | static struct cmd_tbl cmd_sub[] = { |
Heinrich Schuchardt | f7d6b07 | 2018-12-26 17:20:35 +0100 | [diff] [blame] | 44 | U_BOOT_CMD_MKENT(breakpoint, CONFIG_SYS_MAXARGS, 1, do_breakpoint, |
| 45 | "", ""), |
| 46 | U_BOOT_CMD_MKENT(unaligned, CONFIG_SYS_MAXARGS, 1, do_unaligned, |
| 47 | "", ""), |
| 48 | U_BOOT_CMD_MKENT(undefined, CONFIG_SYS_MAXARGS, 1, do_undefined, |
| 49 | "", ""), |
| 50 | }; |
| 51 | |
Tom Rini | 4c1ca0d | 2024-06-19 10:09:44 -0600 | [diff] [blame] | 52 | U_BOOT_LONGHELP(exception, |
Heinrich Schuchardt | f7d6b07 | 2018-12-26 17:20:35 +0100 | [diff] [blame] | 53 | "<ex>\n" |
| 54 | " The following exceptions are available:\n" |
| 55 | " breakpoint - prefetch abort\n" |
| 56 | " unaligned - data abort\n" |
Tom Rini | 4c1ca0d | 2024-06-19 10:09:44 -0600 | [diff] [blame] | 57 | " undefined - undefined instruction\n"); |
Heinrich Schuchardt | f7d6b07 | 2018-12-26 17:20:35 +0100 | [diff] [blame] | 58 | |
| 59 | #include <exception.h> |