rockchip: config: tiner-rk3288: extend CONFIG_SYS_MONITOR_LEN to 600KB
[project/bcm63xx/u-boot.git] / include / exception.h
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 static int do_exception(cmd_tbl_t *cmdtp, int flag, int argc,
9 char * const argv[])
10 {
11 cmd_tbl_t *cp;
12
13 if (argc != 2)
14 return CMD_RET_USAGE;
15
16 /* drop sub-command parameter */
17 argc--;
18 argv++;
19
20 cp = find_cmd_tbl(argv[0], cmd_sub, ARRAY_SIZE(cmd_sub));
21
22 if (cp)
23 return cp->cmd(cmdtp, flag, argc, argv);
24
25 return CMD_RET_USAGE;
26 }
27
28 static int exception_complete(int argc, char * const argv[], char last_char,
29 int maxv, char *cmdv[])
30 {
31 int len = 0;
32 int i = 0;
33 cmd_tbl_t *cmdtp;
34
35 switch (argc) {
36 case 1:
37 break;
38 case 2:
39 len = strlen(argv[1]);
40 break;
41 default:
42 return 0;
43 }
44 for (cmdtp = cmd_sub; cmdtp != cmd_sub + ARRAY_SIZE(cmd_sub); cmdtp++) {
45 if (i >= maxv - 1)
46 return i;
47 if (!strncmp(argv[1], cmdtp->name, len))
48 cmdv[i++] = cmdtp->name;
49 }
50 cmdv[i] = NULL;
51 return i;
52 }
53
54 U_BOOT_CMD_COMPLETE(
55 exception, 2, 0, do_exception,
56 "Forces an exception to occur",
57 exception_help_text, exception_complete
58 );