Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Heinrich Schuchardt | d33ae3e | 2017-09-15 10:06:11 +0200 | [diff] [blame] | 2 | /* |
| 3 | * EFI efi_selftest |
| 4 | * |
| 5 | * Copyright (c) 2017 Heinrich Schuchardt <xypron.glpk@gmx.de> |
Heinrich Schuchardt | d33ae3e | 2017-09-15 10:06:11 +0200 | [diff] [blame] | 6 | */ |
| 7 | |
Heinrich Schuchardt | d5e8571 | 2020-08-22 09:14:56 +0200 | [diff] [blame] | 8 | #include <command.h> |
Heinrich Schuchardt | d33ae3e | 2017-09-15 10:06:11 +0200 | [diff] [blame] | 9 | #include <efi_selftest.h> |
| 10 | #include <vsprintf.h> |
| 11 | |
Simon Glass | 0b9680f | 2018-06-18 08:08:21 -0600 | [diff] [blame] | 12 | /* Constants for test step bitmap */ |
Heinrich Schuchardt | 2eb1558 | 2017-10-18 18:13:12 +0200 | [diff] [blame] | 13 | #define EFI_ST_SETUP 1 |
| 14 | #define EFI_ST_EXECUTE 2 |
| 15 | #define EFI_ST_TEARDOWN 4 |
| 16 | |
Heinrich Schuchardt | d33ae3e | 2017-09-15 10:06:11 +0200 | [diff] [blame] | 17 | static const struct efi_system_table *systable; |
| 18 | static const struct efi_boot_services *boottime; |
| 19 | static const struct efi_runtime_services *runtime; |
| 20 | static efi_handle_t handle; |
| 21 | static u16 reset_message[] = L"Selftest completed"; |
Heinrich Schuchardt | 7281933 | 2018-10-22 23:15:10 +0200 | [diff] [blame] | 22 | static int *setup_status; |
Heinrich Schuchardt | d33ae3e | 2017-09-15 10:06:11 +0200 | [diff] [blame] | 23 | |
| 24 | /* |
| 25 | * Exit the boot services. |
| 26 | * |
| 27 | * The size of the memory map is determined. |
| 28 | * Pool memory is allocated to copy the memory map. |
Simon Glass | 0b9680f | 2018-06-18 08:08:21 -0600 | [diff] [blame] | 29 | * The memory map is copied and the map key is obtained. |
Heinrich Schuchardt | d33ae3e | 2017-09-15 10:06:11 +0200 | [diff] [blame] | 30 | * The map key is used to exit the boot services. |
| 31 | */ |
| 32 | void efi_st_exit_boot_services(void) |
| 33 | { |
Heinrich Schuchardt | 798a441 | 2017-11-06 21:17:48 +0100 | [diff] [blame] | 34 | efi_uintn_t map_size = 0; |
| 35 | efi_uintn_t map_key; |
| 36 | efi_uintn_t desc_size; |
Heinrich Schuchardt | d33ae3e | 2017-09-15 10:06:11 +0200 | [diff] [blame] | 37 | u32 desc_version; |
| 38 | efi_status_t ret; |
| 39 | struct efi_mem_desc *memory_map; |
| 40 | |
| 41 | ret = boottime->get_memory_map(&map_size, NULL, &map_key, &desc_size, |
| 42 | &desc_version); |
| 43 | if (ret != EFI_BUFFER_TOO_SMALL) { |
Heinrich Schuchardt | cbfdf81 | 2017-10-04 12:37:02 +0200 | [diff] [blame] | 44 | efi_st_error( |
| 45 | "GetMemoryMap did not return EFI_BUFFER_TOO_SMALL\n"); |
Heinrich Schuchardt | d33ae3e | 2017-09-15 10:06:11 +0200 | [diff] [blame] | 46 | return; |
| 47 | } |
| 48 | /* Allocate extra space for newly allocated memory */ |
| 49 | map_size += sizeof(struct efi_mem_desc); |
| 50 | ret = boottime->allocate_pool(EFI_BOOT_SERVICES_DATA, map_size, |
| 51 | (void **)&memory_map); |
| 52 | if (ret != EFI_SUCCESS) { |
Heinrich Schuchardt | cbfdf81 | 2017-10-04 12:37:02 +0200 | [diff] [blame] | 53 | efi_st_error("AllocatePool did not return EFI_SUCCESS\n"); |
Heinrich Schuchardt | d33ae3e | 2017-09-15 10:06:11 +0200 | [diff] [blame] | 54 | return; |
| 55 | } |
| 56 | ret = boottime->get_memory_map(&map_size, memory_map, &map_key, |
| 57 | &desc_size, &desc_version); |
| 58 | if (ret != EFI_SUCCESS) { |
Heinrich Schuchardt | cbfdf81 | 2017-10-04 12:37:02 +0200 | [diff] [blame] | 59 | efi_st_error("GetMemoryMap did not return EFI_SUCCESS\n"); |
Heinrich Schuchardt | d33ae3e | 2017-09-15 10:06:11 +0200 | [diff] [blame] | 60 | return; |
| 61 | } |
| 62 | ret = boottime->exit_boot_services(handle, map_key); |
| 63 | if (ret != EFI_SUCCESS) { |
Heinrich Schuchardt | cbfdf81 | 2017-10-04 12:37:02 +0200 | [diff] [blame] | 64 | efi_st_error("ExitBootServices did not return EFI_SUCCESS\n"); |
Heinrich Schuchardt | d33ae3e | 2017-09-15 10:06:11 +0200 | [diff] [blame] | 65 | return; |
| 66 | } |
Heinrich Schuchardt | 9137df8 | 2018-01-11 08:15:54 +0100 | [diff] [blame] | 67 | efi_st_printc(EFI_WHITE, "\nBoot services terminated\n"); |
Heinrich Schuchardt | d33ae3e | 2017-09-15 10:06:11 +0200 | [diff] [blame] | 68 | } |
| 69 | |
| 70 | /* |
| 71 | * Set up a test. |
| 72 | * |
| 73 | * @test the test to be executed |
| 74 | * @failures counter that will be incremented if a failure occurs |
Heinrich Schuchardt | 1afe5f7 | 2017-10-04 15:31:26 +0200 | [diff] [blame] | 75 | * @return EFI_ST_SUCCESS for success |
Heinrich Schuchardt | d33ae3e | 2017-09-15 10:06:11 +0200 | [diff] [blame] | 76 | */ |
| 77 | static int setup(struct efi_unit_test *test, unsigned int *failures) |
| 78 | { |
Heinrich Schuchardt | 0e77ca9 | 2018-10-19 07:51:26 +0200 | [diff] [blame] | 79 | int ret; |
| 80 | |
| 81 | if (!test->setup) |
Heinrich Schuchardt | 1afe5f7 | 2017-10-04 15:31:26 +0200 | [diff] [blame] | 82 | return EFI_ST_SUCCESS; |
Heinrich Schuchardt | 9137df8 | 2018-01-11 08:15:54 +0100 | [diff] [blame] | 83 | efi_st_printc(EFI_LIGHTBLUE, "\nSetting up '%s'\n", test->name); |
Heinrich Schuchardt | 0e77ca9 | 2018-10-19 07:51:26 +0200 | [diff] [blame] | 84 | ret = test->setup(handle, systable); |
| 85 | if (ret != EFI_ST_SUCCESS) { |
Heinrich Schuchardt | cbfdf81 | 2017-10-04 12:37:02 +0200 | [diff] [blame] | 86 | efi_st_error("Setting up '%s' failed\n", test->name); |
Heinrich Schuchardt | d33ae3e | 2017-09-15 10:06:11 +0200 | [diff] [blame] | 87 | ++*failures; |
| 88 | } else { |
Heinrich Schuchardt | 9137df8 | 2018-01-11 08:15:54 +0100 | [diff] [blame] | 89 | efi_st_printc(EFI_LIGHTGREEN, |
| 90 | "Setting up '%s' succeeded\n", test->name); |
Heinrich Schuchardt | d33ae3e | 2017-09-15 10:06:11 +0200 | [diff] [blame] | 91 | } |
Heinrich Schuchardt | 0e77ca9 | 2018-10-19 07:51:26 +0200 | [diff] [blame] | 92 | return ret; |
Heinrich Schuchardt | d33ae3e | 2017-09-15 10:06:11 +0200 | [diff] [blame] | 93 | } |
| 94 | |
| 95 | /* |
| 96 | * Execute a test. |
| 97 | * |
| 98 | * @test the test to be executed |
| 99 | * @failures counter that will be incremented if a failure occurs |
Heinrich Schuchardt | 1afe5f7 | 2017-10-04 15:31:26 +0200 | [diff] [blame] | 100 | * @return EFI_ST_SUCCESS for success |
Heinrich Schuchardt | d33ae3e | 2017-09-15 10:06:11 +0200 | [diff] [blame] | 101 | */ |
| 102 | static int execute(struct efi_unit_test *test, unsigned int *failures) |
| 103 | { |
| 104 | int ret; |
| 105 | |
| 106 | if (!test->execute) |
Heinrich Schuchardt | 1afe5f7 | 2017-10-04 15:31:26 +0200 | [diff] [blame] | 107 | return EFI_ST_SUCCESS; |
Heinrich Schuchardt | 9137df8 | 2018-01-11 08:15:54 +0100 | [diff] [blame] | 108 | efi_st_printc(EFI_LIGHTBLUE, "\nExecuting '%s'\n", test->name); |
Heinrich Schuchardt | d33ae3e | 2017-09-15 10:06:11 +0200 | [diff] [blame] | 109 | ret = test->execute(); |
Heinrich Schuchardt | 1afe5f7 | 2017-10-04 15:31:26 +0200 | [diff] [blame] | 110 | if (ret != EFI_ST_SUCCESS) { |
Heinrich Schuchardt | cbfdf81 | 2017-10-04 12:37:02 +0200 | [diff] [blame] | 111 | efi_st_error("Executing '%s' failed\n", test->name); |
Heinrich Schuchardt | d33ae3e | 2017-09-15 10:06:11 +0200 | [diff] [blame] | 112 | ++*failures; |
| 113 | } else { |
Heinrich Schuchardt | 9137df8 | 2018-01-11 08:15:54 +0100 | [diff] [blame] | 114 | efi_st_printc(EFI_LIGHTGREEN, |
| 115 | "Executing '%s' succeeded\n", test->name); |
Heinrich Schuchardt | d33ae3e | 2017-09-15 10:06:11 +0200 | [diff] [blame] | 116 | } |
| 117 | return ret; |
| 118 | } |
| 119 | |
| 120 | /* |
| 121 | * Tear down a test. |
| 122 | * |
| 123 | * @test the test to be torn down |
| 124 | * @failures counter that will be incremented if a failure occurs |
Heinrich Schuchardt | 1afe5f7 | 2017-10-04 15:31:26 +0200 | [diff] [blame] | 125 | * @return EFI_ST_SUCCESS for success |
Heinrich Schuchardt | d33ae3e | 2017-09-15 10:06:11 +0200 | [diff] [blame] | 126 | */ |
| 127 | static int teardown(struct efi_unit_test *test, unsigned int *failures) |
| 128 | { |
| 129 | int ret; |
| 130 | |
| 131 | if (!test->teardown) |
Heinrich Schuchardt | 1afe5f7 | 2017-10-04 15:31:26 +0200 | [diff] [blame] | 132 | return EFI_ST_SUCCESS; |
Heinrich Schuchardt | 9137df8 | 2018-01-11 08:15:54 +0100 | [diff] [blame] | 133 | efi_st_printc(EFI_LIGHTBLUE, "\nTearing down '%s'\n", test->name); |
Heinrich Schuchardt | d33ae3e | 2017-09-15 10:06:11 +0200 | [diff] [blame] | 134 | ret = test->teardown(); |
Heinrich Schuchardt | 1afe5f7 | 2017-10-04 15:31:26 +0200 | [diff] [blame] | 135 | if (ret != EFI_ST_SUCCESS) { |
Heinrich Schuchardt | cbfdf81 | 2017-10-04 12:37:02 +0200 | [diff] [blame] | 136 | efi_st_error("Tearing down '%s' failed\n", test->name); |
Heinrich Schuchardt | d33ae3e | 2017-09-15 10:06:11 +0200 | [diff] [blame] | 137 | ++*failures; |
| 138 | } else { |
Heinrich Schuchardt | 9137df8 | 2018-01-11 08:15:54 +0100 | [diff] [blame] | 139 | efi_st_printc(EFI_LIGHTGREEN, |
| 140 | "Tearing down '%s' succeeded\n", test->name); |
Heinrich Schuchardt | d33ae3e | 2017-09-15 10:06:11 +0200 | [diff] [blame] | 141 | } |
| 142 | return ret; |
| 143 | } |
| 144 | |
| 145 | /* |
Heinrich Schuchardt | 02efd5d | 2017-10-18 18:13:13 +0200 | [diff] [blame] | 146 | * Check that a test exists. |
| 147 | * |
| 148 | * @testname: name of the test |
Simon Glass | 0b9680f | 2018-06-18 08:08:21 -0600 | [diff] [blame] | 149 | * @return: test, or NULL if not found |
Heinrich Schuchardt | 02efd5d | 2017-10-18 18:13:13 +0200 | [diff] [blame] | 150 | */ |
| 151 | static struct efi_unit_test *find_test(const u16 *testname) |
| 152 | { |
| 153 | struct efi_unit_test *test; |
| 154 | |
| 155 | for (test = ll_entry_start(struct efi_unit_test, efi_unit_test); |
| 156 | test < ll_entry_end(struct efi_unit_test, efi_unit_test); ++test) { |
| 157 | if (!efi_st_strcmp_16_8(testname, test->name)) |
| 158 | return test; |
| 159 | } |
| 160 | efi_st_printf("\nTest '%ps' not found\n", testname); |
| 161 | return NULL; |
| 162 | } |
| 163 | |
| 164 | /* |
| 165 | * List all available tests. |
| 166 | */ |
| 167 | static void list_all_tests(void) |
| 168 | { |
| 169 | struct efi_unit_test *test; |
| 170 | |
| 171 | /* List all tests */ |
| 172 | efi_st_printf("\nAvailable tests:\n"); |
| 173 | for (test = ll_entry_start(struct efi_unit_test, efi_unit_test); |
| 174 | test < ll_entry_end(struct efi_unit_test, efi_unit_test); ++test) { |
| 175 | efi_st_printf("'%s'%s\n", test->name, |
| 176 | test->on_request ? " - on request" : ""); |
| 177 | } |
| 178 | } |
| 179 | |
| 180 | /* |
Heinrich Schuchardt | 2eb1558 | 2017-10-18 18:13:12 +0200 | [diff] [blame] | 181 | * Execute test steps of one phase. |
| 182 | * |
Heinrich Schuchardt | 02efd5d | 2017-10-18 18:13:13 +0200 | [diff] [blame] | 183 | * @testname name of a single selected test or NULL |
Heinrich Schuchardt | 2eb1558 | 2017-10-18 18:13:12 +0200 | [diff] [blame] | 184 | * @phase test phase |
Simon Glass | 0b9680f | 2018-06-18 08:08:21 -0600 | [diff] [blame] | 185 | * @steps steps to execute (mask with bits from EFI_ST_...) |
Heinrich Schuchardt | 2eb1558 | 2017-10-18 18:13:12 +0200 | [diff] [blame] | 186 | * failures returns EFI_ST_SUCCESS if all test steps succeeded |
| 187 | */ |
Heinrich Schuchardt | 02efd5d | 2017-10-18 18:13:13 +0200 | [diff] [blame] | 188 | void efi_st_do_tests(const u16 *testname, unsigned int phase, |
| 189 | unsigned int steps, unsigned int *failures) |
Heinrich Schuchardt | 2eb1558 | 2017-10-18 18:13:12 +0200 | [diff] [blame] | 190 | { |
Heinrich Schuchardt | 0e77ca9 | 2018-10-19 07:51:26 +0200 | [diff] [blame] | 191 | int i = 0; |
Heinrich Schuchardt | 2eb1558 | 2017-10-18 18:13:12 +0200 | [diff] [blame] | 192 | struct efi_unit_test *test; |
| 193 | |
| 194 | for (test = ll_entry_start(struct efi_unit_test, efi_unit_test); |
Heinrich Schuchardt | 0e77ca9 | 2018-10-19 07:51:26 +0200 | [diff] [blame] | 195 | test < ll_entry_end(struct efi_unit_test, efi_unit_test); |
| 196 | ++test, ++i) { |
Heinrich Schuchardt | 02efd5d | 2017-10-18 18:13:13 +0200 | [diff] [blame] | 197 | if (testname ? |
| 198 | efi_st_strcmp_16_8(testname, test->name) : test->on_request) |
| 199 | continue; |
Heinrich Schuchardt | 2eb1558 | 2017-10-18 18:13:12 +0200 | [diff] [blame] | 200 | if (test->phase != phase) |
| 201 | continue; |
| 202 | if (steps & EFI_ST_SETUP) |
Heinrich Schuchardt | 7281933 | 2018-10-22 23:15:10 +0200 | [diff] [blame] | 203 | setup_status[i] = setup(test, failures); |
| 204 | if (steps & EFI_ST_EXECUTE && setup_status[i] == EFI_ST_SUCCESS) |
Heinrich Schuchardt | 2eb1558 | 2017-10-18 18:13:12 +0200 | [diff] [blame] | 205 | execute(test, failures); |
| 206 | if (steps & EFI_ST_TEARDOWN) |
| 207 | teardown(test, failures); |
| 208 | } |
| 209 | } |
| 210 | |
| 211 | /* |
Heinrich Schuchardt | d33ae3e | 2017-09-15 10:06:11 +0200 | [diff] [blame] | 212 | * Execute selftest of the EFI API |
| 213 | * |
| 214 | * This is the main entry point of the EFI selftest application. |
| 215 | * |
| 216 | * All tests use a driver model and are run in three phases: |
| 217 | * setup, execute, teardown. |
| 218 | * |
| 219 | * A test may be setup and executed at boottime, |
| 220 | * it may be setup at boottime and executed at runtime, |
| 221 | * or it may be setup and executed at runtime. |
| 222 | * |
| 223 | * After executing all tests the system is reset. |
| 224 | * |
| 225 | * @image_handle: handle of the loaded EFI image |
| 226 | * @systab: EFI system table |
| 227 | */ |
| 228 | efi_status_t EFIAPI efi_selftest(efi_handle_t image_handle, |
| 229 | struct efi_system_table *systab) |
| 230 | { |
Heinrich Schuchardt | d33ae3e | 2017-09-15 10:06:11 +0200 | [diff] [blame] | 231 | unsigned int failures = 0; |
Heinrich Schuchardt | 02efd5d | 2017-10-18 18:13:13 +0200 | [diff] [blame] | 232 | const u16 *testname = NULL; |
| 233 | struct efi_loaded_image *loaded_image; |
| 234 | efi_status_t ret; |
Heinrich Schuchardt | d33ae3e | 2017-09-15 10:06:11 +0200 | [diff] [blame] | 235 | |
| 236 | systable = systab; |
| 237 | boottime = systable->boottime; |
| 238 | runtime = systable->runtime; |
| 239 | handle = image_handle; |
| 240 | con_out = systable->con_out; |
| 241 | con_in = systable->con_in; |
| 242 | |
Heinrich Schuchardt | 02efd5d | 2017-10-18 18:13:13 +0200 | [diff] [blame] | 243 | ret = boottime->handle_protocol(image_handle, &efi_guid_loaded_image, |
| 244 | (void **)&loaded_image); |
| 245 | if (ret != EFI_SUCCESS) { |
Heinrich Schuchardt | bf7ea1d | 2017-11-26 14:05:19 +0100 | [diff] [blame] | 246 | efi_st_error("Cannot open loaded image protocol\n"); |
Heinrich Schuchardt | 02efd5d | 2017-10-18 18:13:13 +0200 | [diff] [blame] | 247 | return ret; |
| 248 | } |
| 249 | |
| 250 | if (loaded_image->load_options) |
| 251 | testname = (u16 *)loaded_image->load_options; |
| 252 | |
| 253 | if (testname) { |
| 254 | if (!efi_st_strcmp_16_8(testname, "list") || |
| 255 | !find_test(testname)) { |
| 256 | list_all_tests(); |
| 257 | /* |
| 258 | * TODO: |
| 259 | * Once the Exit boottime service is correctly |
| 260 | * implemented we should call |
| 261 | * boottime->exit(image_handle, EFI_SUCCESS, 0, NULL); |
| 262 | * here, cf. |
| 263 | * https://lists.denx.de/pipermail/u-boot/2017-October/308720.html |
| 264 | */ |
| 265 | return EFI_SUCCESS; |
| 266 | } |
| 267 | } |
| 268 | |
Heinrich Schuchardt | 9137df8 | 2018-01-11 08:15:54 +0100 | [diff] [blame] | 269 | efi_st_printc(EFI_WHITE, "\nTesting EFI API implementation\n"); |
Heinrich Schuchardt | d33ae3e | 2017-09-15 10:06:11 +0200 | [diff] [blame] | 270 | |
Heinrich Schuchardt | 02efd5d | 2017-10-18 18:13:13 +0200 | [diff] [blame] | 271 | if (testname) |
Heinrich Schuchardt | 9137df8 | 2018-01-11 08:15:54 +0100 | [diff] [blame] | 272 | efi_st_printc(EFI_WHITE, "\nSelected test: '%ps'\n", testname); |
Heinrich Schuchardt | 02efd5d | 2017-10-18 18:13:13 +0200 | [diff] [blame] | 273 | else |
Heinrich Schuchardt | 9137df8 | 2018-01-11 08:15:54 +0100 | [diff] [blame] | 274 | efi_st_printc(EFI_WHITE, "\nNumber of tests to execute: %u\n", |
Heinrich Schuchardt | 02efd5d | 2017-10-18 18:13:13 +0200 | [diff] [blame] | 275 | ll_entry_count(struct efi_unit_test, |
| 276 | efi_unit_test)); |
Heinrich Schuchardt | d33ae3e | 2017-09-15 10:06:11 +0200 | [diff] [blame] | 277 | |
Heinrich Schuchardt | 0e77ca9 | 2018-10-19 07:51:26 +0200 | [diff] [blame] | 278 | /* Allocate buffer for setup results */ |
| 279 | ret = boottime->allocate_pool(EFI_RUNTIME_SERVICES_DATA, sizeof(int) * |
| 280 | ll_entry_count(struct efi_unit_test, |
| 281 | efi_unit_test), |
Heinrich Schuchardt | 7281933 | 2018-10-22 23:15:10 +0200 | [diff] [blame] | 282 | (void **)&setup_status); |
Heinrich Schuchardt | 0e77ca9 | 2018-10-19 07:51:26 +0200 | [diff] [blame] | 283 | if (ret != EFI_SUCCESS) { |
| 284 | efi_st_error("Allocate pool failed\n"); |
| 285 | return ret; |
| 286 | } |
| 287 | |
Heinrich Schuchardt | d33ae3e | 2017-09-15 10:06:11 +0200 | [diff] [blame] | 288 | /* Execute boottime tests */ |
Heinrich Schuchardt | 02efd5d | 2017-10-18 18:13:13 +0200 | [diff] [blame] | 289 | efi_st_do_tests(testname, EFI_EXECUTE_BEFORE_BOOTTIME_EXIT, |
Heinrich Schuchardt | 2eb1558 | 2017-10-18 18:13:12 +0200 | [diff] [blame] | 290 | EFI_ST_SETUP | EFI_ST_EXECUTE | EFI_ST_TEARDOWN, |
| 291 | &failures); |
Heinrich Schuchardt | d33ae3e | 2017-09-15 10:06:11 +0200 | [diff] [blame] | 292 | |
| 293 | /* Execute mixed tests */ |
Heinrich Schuchardt | 02efd5d | 2017-10-18 18:13:13 +0200 | [diff] [blame] | 294 | efi_st_do_tests(testname, EFI_SETUP_BEFORE_BOOTTIME_EXIT, |
Heinrich Schuchardt | 2eb1558 | 2017-10-18 18:13:12 +0200 | [diff] [blame] | 295 | EFI_ST_SETUP, &failures); |
Heinrich Schuchardt | d33ae3e | 2017-09-15 10:06:11 +0200 | [diff] [blame] | 296 | |
| 297 | efi_st_exit_boot_services(); |
| 298 | |
Heinrich Schuchardt | 02efd5d | 2017-10-18 18:13:13 +0200 | [diff] [blame] | 299 | efi_st_do_tests(testname, EFI_SETUP_BEFORE_BOOTTIME_EXIT, |
Heinrich Schuchardt | 2eb1558 | 2017-10-18 18:13:12 +0200 | [diff] [blame] | 300 | EFI_ST_EXECUTE | EFI_ST_TEARDOWN, &failures); |
Heinrich Schuchardt | d33ae3e | 2017-09-15 10:06:11 +0200 | [diff] [blame] | 301 | |
| 302 | /* Execute runtime tests */ |
Heinrich Schuchardt | 02efd5d | 2017-10-18 18:13:13 +0200 | [diff] [blame] | 303 | efi_st_do_tests(testname, EFI_SETUP_AFTER_BOOTTIME_EXIT, |
Heinrich Schuchardt | 2eb1558 | 2017-10-18 18:13:12 +0200 | [diff] [blame] | 304 | EFI_ST_SETUP | EFI_ST_EXECUTE | EFI_ST_TEARDOWN, |
| 305 | &failures); |
Heinrich Schuchardt | d33ae3e | 2017-09-15 10:06:11 +0200 | [diff] [blame] | 306 | |
| 307 | /* Give feedback */ |
Heinrich Schuchardt | 9137df8 | 2018-01-11 08:15:54 +0100 | [diff] [blame] | 308 | efi_st_printc(EFI_WHITE, "\nSummary: %u failures\n\n", failures); |
Heinrich Schuchardt | d33ae3e | 2017-09-15 10:06:11 +0200 | [diff] [blame] | 309 | |
| 310 | /* Reset system */ |
Simon Glass | 0b9680f | 2018-06-18 08:08:21 -0600 | [diff] [blame] | 311 | efi_st_printf("Preparing for reset. Press any key...\n"); |
Heinrich Schuchardt | d33ae3e | 2017-09-15 10:06:11 +0200 | [diff] [blame] | 312 | efi_st_get_key(); |
Heinrich Schuchardt | d5e8571 | 2020-08-22 09:14:56 +0200 | [diff] [blame] | 313 | |
Heinrich Schuchardt | c450db5 | 2020-09-10 07:47:58 +0200 | [diff] [blame] | 314 | if (IS_ENABLED(CONFIG_EFI_HAVE_RUNTIME_RESET)) { |
Heinrich Schuchardt | d5e8571 | 2020-08-22 09:14:56 +0200 | [diff] [blame] | 315 | runtime->reset_system(EFI_RESET_WARM, EFI_NOT_READY, |
| 316 | sizeof(reset_message), reset_message); |
Heinrich Schuchardt | c450db5 | 2020-09-10 07:47:58 +0200 | [diff] [blame] | 317 | } else { |
| 318 | efi_restore_gd(); |
Heinrich Schuchardt | d5e8571 | 2020-08-22 09:14:56 +0200 | [diff] [blame] | 319 | do_reset(NULL, 0, 0, NULL); |
Heinrich Schuchardt | c450db5 | 2020-09-10 07:47:58 +0200 | [diff] [blame] | 320 | } |
Heinrich Schuchardt | d5e8571 | 2020-08-22 09:14:56 +0200 | [diff] [blame] | 321 | |
Heinrich Schuchardt | cbfdf81 | 2017-10-04 12:37:02 +0200 | [diff] [blame] | 322 | efi_st_printf("\n"); |
Simon Glass | 0b9680f | 2018-06-18 08:08:21 -0600 | [diff] [blame] | 323 | efi_st_error("Reset failed\n"); |
Heinrich Schuchardt | d33ae3e | 2017-09-15 10:06:11 +0200 | [diff] [blame] | 324 | |
| 325 | return EFI_UNSUPPORTED; |
| 326 | } |