Heinrich Schuchardt | f6a95c1 | 2020-08-20 12:16:54 +0200 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
| 2 | /* |
| 3 | * efi_selftest_reset |
| 4 | * |
| 5 | * Copyright (c) 2020 Heinrich Schuchardt <xypron.glpk@gmx.de> |
| 6 | * |
| 7 | * This test checks the following service at boot time or runtime: |
| 8 | * ResetSystem() |
| 9 | */ |
| 10 | |
| 11 | #include <efi_selftest.h> |
| 12 | |
| 13 | static struct efi_runtime_services *runtime; |
| 14 | |
| 15 | /* |
| 16 | * Setup unit test. |
| 17 | * |
| 18 | * @handle: handle of the loaded image |
| 19 | * @systable: system table |
Heinrich Schuchardt | fbe9021 | 2022-01-20 19:48:20 +0100 | [diff] [blame^] | 20 | * Return: EFI_ST_SUCCESS for success |
Heinrich Schuchardt | f6a95c1 | 2020-08-20 12:16:54 +0200 | [diff] [blame] | 21 | */ |
| 22 | static int setup(const efi_handle_t handle, |
| 23 | const struct efi_system_table *systable) |
| 24 | { |
| 25 | runtime = systable->runtime; |
| 26 | return EFI_ST_SUCCESS; |
| 27 | } |
| 28 | |
| 29 | /* |
| 30 | * Execute unit test. |
| 31 | * |
Heinrich Schuchardt | fbe9021 | 2022-01-20 19:48:20 +0100 | [diff] [blame^] | 32 | * Return: EFI_ST_SUCCESS for success |
Heinrich Schuchardt | f6a95c1 | 2020-08-20 12:16:54 +0200 | [diff] [blame] | 33 | */ |
| 34 | static int execute(void) |
| 35 | { |
| 36 | u16 reset_data[] = L"Reset by selftest"; |
| 37 | |
| 38 | runtime->reset_system(EFI_RESET_COLD, EFI_SUCCESS, |
| 39 | sizeof(reset_data), reset_data); |
| 40 | efi_st_error("Reset failed.\n"); |
| 41 | return EFI_ST_FAILURE; |
| 42 | } |
| 43 | |
| 44 | EFI_UNIT_TEST(reset) = { |
| 45 | .name = "reset system", |
| 46 | .phase = EFI_EXECUTE_BEFORE_BOOTTIME_EXIT, |
| 47 | .setup = setup, |
| 48 | .execute = execute, |
| 49 | .on_request = true, |
| 50 | }; |
| 51 | |
| 52 | EFI_UNIT_TEST(resetrt) = { |
| 53 | .name = "reset system runtime", |
| 54 | .phase = EFI_SETUP_BEFORE_BOOTTIME_EXIT, |
| 55 | .setup = setup, |
| 56 | .execute = execute, |
| 57 | .on_request = true, |
| 58 | }; |