blob: f668cdac4ab2de0259374722958f0178d8693fd6 [file] [log] [blame]
Heinrich Schuchardtcafccfd2019-08-27 08:16:08 +02001// 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
Heinrich Schuchardtcafccfd2019-08-27 08:16:08 +020010#include <efi_api.h>
Heinrich Schuchardt04598e52022-09-02 02:46:37 +020011#include <host_arch.h>
Heinrich Schuchardtcafccfd2019-08-27 08:16:08 +020012
13/*
14 * Entry point of the EFI application.
15 *
16 * @handle handle of the loaded image
17 * @systable system table
Heinrich Schuchardt47b4c022022-01-19 18:05:50 +010018 * Return: status code
Heinrich Schuchardtcafccfd2019-08-27 08:16:08 +020019 */
20efi_status_t EFIAPI efi_main(efi_handle_t handle,
21 struct efi_system_table *systable)
22{
23 struct efi_simple_text_output_protocol *con_out = systable->con_out;
24
25 con_out->output_string(con_out,
Simon Glass90975372022-01-23 12:55:12 -070026 u"EFI application triggers exception.\n");
Heinrich Schuchardtcafccfd2019-08-27 08:16:08 +020027
28#if defined(CONFIG_ARM)
29 /*
30 * 0xe7f...f. is undefined in ARM mode
31 * 0xde.. is undefined in Thumb mode
32 */
33 asm volatile (".word 0xe7f7defb\n");
34#elif defined(CONFIG_RISCV)
35 asm volatile (".word 0xffffffff\n");
Heinrich Schuchardt04598e52022-09-02 02:46:37 +020036#elif defined(CONFIG_X86)
37 asm volatile (".word 0xffff\n");
Heinrich Schuchardta8466ad2020-11-12 00:29:58 +010038#elif defined(CONFIG_SANDBOX)
Heinrich Schuchardt04598e52022-09-02 02:46:37 +020039#if (HOST_ARCH == HOST_ARCH_ARM || HOST_ARCH == HOST_ARCH_AARCH64)
40 asm volatile (".word 0xe7f7defb\n");
41#elif (HOST_ARCH == HOST_ARCH_RISCV32 || HOST_ARCH == HOST_ARCH_RISCV64)
Heinrich Schuchardta8466ad2020-11-12 00:29:58 +010042 asm volatile (".word 0xffffffff\n");
Heinrich Schuchardt04598e52022-09-02 02:46:37 +020043#elif (HOST_ARCH == HOST_ARCH_X86 || HOST_ARCH == HOST_ARCH_X86_64)
Heinrich Schuchardtcafccfd2019-08-27 08:16:08 +020044 asm volatile (".word 0xffff\n");
45#endif
Heinrich Schuchardt04598e52022-09-02 02:46:37 +020046#endif
Simon Glass90975372022-01-23 12:55:12 -070047 con_out->output_string(con_out, u"Exception not triggered.\n");
Heinrich Schuchardtcafccfd2019-08-27 08:16:08 +020048 return EFI_ABORTED;
49}