exception.c 929 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  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. #include <common.h>
  8. #include <command.h>
  9. static int do_sigsegv(struct cmd_tbl *cmdtp, int flag, int argc,
  10. char *const argv[])
  11. {
  12. u8 *ptr = NULL;
  13. *ptr = 0;
  14. return CMD_RET_FAILURE;
  15. }
  16. static int do_undefined(struct cmd_tbl *cmdtp, int flag, int argc,
  17. char *const argv[])
  18. {
  19. asm volatile (".word 0xffff\n");
  20. return CMD_RET_FAILURE;
  21. }
  22. static struct cmd_tbl cmd_sub[] = {
  23. U_BOOT_CMD_MKENT(sigsegv, CONFIG_SYS_MAXARGS, 1, do_sigsegv,
  24. "", ""),
  25. U_BOOT_CMD_MKENT(undefined, CONFIG_SYS_MAXARGS, 1, do_undefined,
  26. "", ""),
  27. };
  28. static char exception_help_text[] =
  29. "<ex>\n"
  30. " The following exceptions are available:\n"
  31. " undefined - undefined instruction\n"
  32. " sigsegv - illegal memory access\n"
  33. ;
  34. #include <exception.h>