efi_selftest_miniapp_exception.c 972 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * efi_selftest_miniapp_return
  4. *
  5. * Copyright (c) 2019 Heinrich Schuchardt
  6. *
  7. * This EFI application triggers an exception.
  8. */
  9. #include <common.h>
  10. #include <efi_api.h>
  11. /*
  12. * Entry point of the EFI application.
  13. *
  14. * @handle handle of the loaded image
  15. * @systable system table
  16. * @return status code
  17. */
  18. efi_status_t EFIAPI efi_main(efi_handle_t handle,
  19. struct efi_system_table *systable)
  20. {
  21. struct efi_simple_text_output_protocol *con_out = systable->con_out;
  22. con_out->output_string(con_out,
  23. L"EFI application triggers exception.\n");
  24. #if defined(CONFIG_ARM)
  25. /*
  26. * 0xe7f...f. is undefined in ARM mode
  27. * 0xde.. is undefined in Thumb mode
  28. */
  29. asm volatile (".word 0xe7f7defb\n");
  30. #elif defined(CONFIG_RISCV)
  31. asm volatile (".word 0xffffffff\n");
  32. #elif defined(CONFIG_X86)
  33. asm volatile (".word 0xffff\n");
  34. #endif
  35. con_out->output_string(con_out, L"Exception not triggered.\n");
  36. return EFI_ABORTED;
  37. }