Heinrich Schuchardt | cafccfd | 2019-08-27 08:16:08 +0200 | [diff] [blame] | 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 | |
| 10 | #include <common.h> |
| 11 | #include <efi_api.h> |
Heinrich Schuchardt | 04598e5 | 2022-09-02 02:46:37 +0200 | [diff] [blame] | 12 | #include <host_arch.h> |
Heinrich Schuchardt | cafccfd | 2019-08-27 08:16:08 +0200 | [diff] [blame] | 13 | |
| 14 | /* |
| 15 | * Entry point of the EFI application. |
| 16 | * |
| 17 | * @handle handle of the loaded image |
| 18 | * @systable system table |
Heinrich Schuchardt | 47b4c02 | 2022-01-19 18:05:50 +0100 | [diff] [blame] | 19 | * Return: status code |
Heinrich Schuchardt | cafccfd | 2019-08-27 08:16:08 +0200 | [diff] [blame] | 20 | */ |
| 21 | efi_status_t EFIAPI efi_main(efi_handle_t handle, |
| 22 | struct efi_system_table *systable) |
| 23 | { |
| 24 | struct efi_simple_text_output_protocol *con_out = systable->con_out; |
| 25 | |
| 26 | con_out->output_string(con_out, |
Simon Glass | 9097537 | 2022-01-23 12:55:12 -0700 | [diff] [blame] | 27 | u"EFI application triggers exception.\n"); |
Heinrich Schuchardt | cafccfd | 2019-08-27 08:16:08 +0200 | [diff] [blame] | 28 | |
| 29 | #if defined(CONFIG_ARM) |
| 30 | /* |
| 31 | * 0xe7f...f. is undefined in ARM mode |
| 32 | * 0xde.. is undefined in Thumb mode |
| 33 | */ |
| 34 | asm volatile (".word 0xe7f7defb\n"); |
| 35 | #elif defined(CONFIG_RISCV) |
| 36 | asm volatile (".word 0xffffffff\n"); |
Heinrich Schuchardt | 04598e5 | 2022-09-02 02:46:37 +0200 | [diff] [blame] | 37 | #elif defined(CONFIG_X86) |
| 38 | asm volatile (".word 0xffff\n"); |
Heinrich Schuchardt | a8466ad | 2020-11-12 00:29:58 +0100 | [diff] [blame] | 39 | #elif defined(CONFIG_SANDBOX) |
Heinrich Schuchardt | 04598e5 | 2022-09-02 02:46:37 +0200 | [diff] [blame] | 40 | #if (HOST_ARCH == HOST_ARCH_ARM || HOST_ARCH == HOST_ARCH_AARCH64) |
| 41 | asm volatile (".word 0xe7f7defb\n"); |
| 42 | #elif (HOST_ARCH == HOST_ARCH_RISCV32 || HOST_ARCH == HOST_ARCH_RISCV64) |
Heinrich Schuchardt | a8466ad | 2020-11-12 00:29:58 +0100 | [diff] [blame] | 43 | asm volatile (".word 0xffffffff\n"); |
Heinrich Schuchardt | 04598e5 | 2022-09-02 02:46:37 +0200 | [diff] [blame] | 44 | #elif (HOST_ARCH == HOST_ARCH_X86 || HOST_ARCH == HOST_ARCH_X86_64) |
Heinrich Schuchardt | cafccfd | 2019-08-27 08:16:08 +0200 | [diff] [blame] | 45 | asm volatile (".word 0xffff\n"); |
| 46 | #endif |
Heinrich Schuchardt | 04598e5 | 2022-09-02 02:46:37 +0200 | [diff] [blame] | 47 | #endif |
Simon Glass | 9097537 | 2022-01-23 12:55:12 -0700 | [diff] [blame] | 48 | con_out->output_string(con_out, u"Exception not triggered.\n"); |
Heinrich Schuchardt | cafccfd | 2019-08-27 08:16:08 +0200 | [diff] [blame] | 49 | return EFI_ABORTED; |
| 50 | } |