blob: 9687cec8120fa83bb81ad93df93f51a419d7ded3 [file] [log] [blame]
Heinrich Schuchardtf7d6b072018-12-26 17:20:35 +01001// 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 <common.h>
9#include <command.h>
10
Heinrich Schuchardt5dfa8832020-08-06 12:34:59 +020011static int do_unaligned(struct cmd_tbl *cmdtp, int flag, int argc,
12 char *const argv[])
13{
14 asm volatile (
15 "auipc a1, 0\n"
16 "ori a1, a1, 3\n"
17 "lw a2, (0)(a1)\n"
18 );
19 printf("The system supports unaligned access.\n");
20 return CMD_RET_SUCCESS;
21}
22
Simon Glassed38aef2020-05-10 11:40:03 -060023static int do_undefined(struct cmd_tbl *cmdtp, int flag, int argc,
24 char *const argv[])
Heinrich Schuchardtf7d6b072018-12-26 17:20:35 +010025{
26 asm volatile (".word 0xffffffff\n");
27 return CMD_RET_FAILURE;
28}
29
Simon Glassed38aef2020-05-10 11:40:03 -060030static struct cmd_tbl cmd_sub[] = {
Heinrich Schuchardt5dfa8832020-08-06 12:34:59 +020031 U_BOOT_CMD_MKENT(unaligned, CONFIG_SYS_MAXARGS, 1, do_unaligned,
32 "", ""),
Heinrich Schuchardtf7d6b072018-12-26 17:20:35 +010033 U_BOOT_CMD_MKENT(undefined, CONFIG_SYS_MAXARGS, 1, do_undefined,
34 "", ""),
35};
36
37static char exception_help_text[] =
38 "<ex>\n"
39 " The following exceptions are available:\n"
Heinrich Schuchardt5dfa8832020-08-06 12:34:59 +020040 " undefined - illegal instruction\n"
41 " unaligned - load address misaligned\n"
Heinrich Schuchardtf7d6b072018-12-26 17:20:35 +010042 ;
43
44#include <exception.h>