"Das U-Boot" Source Tree
at master 59 lines 1.5 kB view raw
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 8#include <command.h> 9 10static int do_unaligned(struct cmd_tbl *cmdtp, int flag, int argc, 11 char *const argv[]) 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 25static int do_breakpoint(struct cmd_tbl *cmdtp, int flag, int argc, 26 char *const argv[]) 27{ 28 asm volatile ("BKPT #123\n"); 29 return CMD_RET_FAILURE; 30} 31 32static int do_undefined(struct cmd_tbl *cmdtp, int flag, int argc, 33 char *const argv[]) 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 43static struct cmd_tbl cmd_sub[] = { 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 52U_BOOT_LONGHELP(exception, 53 "<ex>\n" 54 " The following exceptions are available:\n" 55 " breakpoint - prefetch abort\n" 56 " unaligned - data abort\n" 57 " undefined - undefined instruction\n"); 58 59#include <exception.h>