AKASHI Takahiro | 7e0badb | 2018-12-30 15:16:55 +0100 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
| 2 | /* |
| 3 | * EFI setup code |
| 4 | * |
| 5 | * Copyright (c) 2016-2018 Alexander Graf et al. |
| 6 | */ |
| 7 | |
Heinrich Schuchardt | a306a12 | 2021-06-29 13:33:09 +0200 | [diff] [blame] | 8 | #define LOG_CATEGORY LOGC_EFI |
| 9 | |
AKASHI Takahiro | 7e0badb | 2018-12-30 15:16:55 +0100 | [diff] [blame] | 10 | #include <common.h> |
| 11 | #include <efi_loader.h> |
Heinrich Schuchardt | ee3565f | 2020-06-24 19:38:29 +0200 | [diff] [blame] | 12 | #include <efi_variable.h> |
Heinrich Schuchardt | a306a12 | 2021-06-29 13:33:09 +0200 | [diff] [blame] | 13 | #include <log.h> |
Heinrich Schuchardt | bf53ea7 | 2023-02-10 09:02:56 +0100 | [diff] [blame] | 14 | #include <asm-generic/unaligned.h> |
AKASHI Takahiro | 7e0badb | 2018-12-30 15:16:55 +0100 | [diff] [blame] | 15 | |
| 16 | #define OBJ_LIST_NOT_INITIALIZED 1 |
| 17 | |
Heinrich Schuchardt | de9bdc6 | 2020-03-19 18:21:58 +0000 | [diff] [blame] | 18 | efi_status_t efi_obj_list_initialized = OBJ_LIST_NOT_INITIALIZED; |
AKASHI Takahiro | 7e0badb | 2018-12-30 15:16:55 +0100 | [diff] [blame] | 19 | |
Heinrich Schuchardt | aea03d6 | 2019-05-04 11:47:48 +0200 | [diff] [blame] | 20 | /* |
| 21 | * Allow unaligned memory access. |
| 22 | * |
| 23 | * This routine is overridden by architectures providing this feature. |
| 24 | */ |
| 25 | void __weak allow_unaligned(void) |
| 26 | { |
| 27 | } |
| 28 | |
Heinrich Schuchardt | 3700d57 | 2019-04-11 07:34:24 +0200 | [diff] [blame] | 29 | /** |
| 30 | * efi_init_platform_lang() - define supported languages |
| 31 | * |
| 32 | * Set the PlatformLangCodes and PlatformLang variables. |
| 33 | * |
| 34 | * Return: status code |
| 35 | */ |
| 36 | static efi_status_t efi_init_platform_lang(void) |
AKASHI Takahiro | 7e0badb | 2018-12-30 15:16:55 +0100 | [diff] [blame] | 37 | { |
Heinrich Schuchardt | 3700d57 | 2019-04-11 07:34:24 +0200 | [diff] [blame] | 38 | efi_status_t ret; |
| 39 | efi_uintn_t data_size = 0; |
| 40 | char *lang = CONFIG_EFI_PLATFORM_LANG_CODES; |
| 41 | char *pos; |
AKASHI Takahiro | 7e0badb | 2018-12-30 15:16:55 +0100 | [diff] [blame] | 42 | |
| 43 | /* |
Heinrich Schuchardt | 3700d57 | 2019-04-11 07:34:24 +0200 | [diff] [blame] | 44 | * Variable PlatformLangCodes defines the language codes that the |
| 45 | * machine can support. |
Heinrich Schuchardt | f7fe45b | 2019-04-05 02:45:21 +0200 | [diff] [blame] | 46 | */ |
Simon Glass | 9097537 | 2022-01-23 12:55:12 -0700 | [diff] [blame] | 47 | ret = efi_set_variable_int(u"PlatformLangCodes", |
Heinrich Schuchardt | ee3565f | 2020-06-24 19:38:29 +0200 | [diff] [blame] | 48 | &efi_global_variable_guid, |
| 49 | EFI_VARIABLE_BOOTSERVICE_ACCESS | |
| 50 | EFI_VARIABLE_RUNTIME_ACCESS | |
| 51 | EFI_VARIABLE_READ_ONLY, |
| 52 | sizeof(CONFIG_EFI_PLATFORM_LANG_CODES), |
| 53 | CONFIG_EFI_PLATFORM_LANG_CODES, false); |
Heinrich Schuchardt | f7fe45b | 2019-04-05 02:45:21 +0200 | [diff] [blame] | 54 | if (ret != EFI_SUCCESS) |
| 55 | goto out; |
| 56 | |
| 57 | /* |
Heinrich Schuchardt | 3700d57 | 2019-04-11 07:34:24 +0200 | [diff] [blame] | 58 | * Variable PlatformLang defines the language that the machine has been |
| 59 | * configured for. |
Heinrich Schuchardt | f7fe45b | 2019-04-05 02:45:21 +0200 | [diff] [blame] | 60 | */ |
Simon Glass | 9097537 | 2022-01-23 12:55:12 -0700 | [diff] [blame] | 61 | ret = efi_get_variable_int(u"PlatformLang", |
Heinrich Schuchardt | ee3565f | 2020-06-24 19:38:29 +0200 | [diff] [blame] | 62 | &efi_global_variable_guid, |
| 63 | NULL, &data_size, &pos, NULL); |
Heinrich Schuchardt | 3700d57 | 2019-04-11 07:34:24 +0200 | [diff] [blame] | 64 | if (ret == EFI_BUFFER_TOO_SMALL) { |
| 65 | /* The variable is already set. Do not change it. */ |
| 66 | ret = EFI_SUCCESS; |
| 67 | goto out; |
| 68 | } |
| 69 | |
| 70 | /* |
| 71 | * The list of supported languages is semicolon separated. Use the first |
| 72 | * language to initialize PlatformLang. |
| 73 | */ |
| 74 | pos = strchr(lang, ';'); |
| 75 | if (pos) |
| 76 | *pos = 0; |
| 77 | |
Simon Glass | 9097537 | 2022-01-23 12:55:12 -0700 | [diff] [blame] | 78 | ret = efi_set_variable_int(u"PlatformLang", |
Heinrich Schuchardt | ee3565f | 2020-06-24 19:38:29 +0200 | [diff] [blame] | 79 | &efi_global_variable_guid, |
| 80 | EFI_VARIABLE_NON_VOLATILE | |
| 81 | EFI_VARIABLE_BOOTSERVICE_ACCESS | |
| 82 | EFI_VARIABLE_RUNTIME_ACCESS, |
| 83 | 1 + strlen(lang), lang, false); |
Heinrich Schuchardt | 3700d57 | 2019-04-11 07:34:24 +0200 | [diff] [blame] | 84 | out: |
Heinrich Schuchardt | f7fe45b | 2019-04-05 02:45:21 +0200 | [diff] [blame] | 85 | if (ret != EFI_SUCCESS) |
Heinrich Schuchardt | 3700d57 | 2019-04-11 07:34:24 +0200 | [diff] [blame] | 86 | printf("EFI: cannot initialize platform language settings\n"); |
| 87 | return ret; |
| 88 | } |
| 89 | |
AKASHI Takahiro | 8d494f6 | 2020-04-14 11:51:45 +0900 | [diff] [blame] | 90 | #ifdef CONFIG_EFI_SECURE_BOOT |
| 91 | /** |
| 92 | * efi_init_secure_boot - initialize secure boot state |
| 93 | * |
Heinrich Schuchardt | e2c43da | 2020-05-03 16:29:00 +0200 | [diff] [blame] | 94 | * Return: status code |
AKASHI Takahiro | 8d494f6 | 2020-04-14 11:51:45 +0900 | [diff] [blame] | 95 | */ |
| 96 | static efi_status_t efi_init_secure_boot(void) |
| 97 | { |
| 98 | efi_guid_t signature_types[] = { |
| 99 | EFI_CERT_SHA256_GUID, |
| 100 | EFI_CERT_X509_GUID, |
| 101 | }; |
| 102 | efi_status_t ret; |
| 103 | |
Simon Glass | 9097537 | 2022-01-23 12:55:12 -0700 | [diff] [blame] | 104 | ret = efi_set_variable_int(u"SignatureSupport", |
Heinrich Schuchardt | ee3565f | 2020-06-24 19:38:29 +0200 | [diff] [blame] | 105 | &efi_global_variable_guid, |
AKASHI Takahiro | 473d9b3 | 2020-11-17 09:27:55 +0900 | [diff] [blame] | 106 | EFI_VARIABLE_READ_ONLY | |
Heinrich Schuchardt | ee3565f | 2020-06-24 19:38:29 +0200 | [diff] [blame] | 107 | EFI_VARIABLE_BOOTSERVICE_ACCESS | |
AKASHI Takahiro | 473d9b3 | 2020-11-17 09:27:55 +0900 | [diff] [blame] | 108 | EFI_VARIABLE_RUNTIME_ACCESS, |
Heinrich Schuchardt | ee3565f | 2020-06-24 19:38:29 +0200 | [diff] [blame] | 109 | sizeof(signature_types), |
| 110 | &signature_types, false); |
AKASHI Takahiro | 8d494f6 | 2020-04-14 11:51:45 +0900 | [diff] [blame] | 111 | if (ret != EFI_SUCCESS) |
| 112 | printf("EFI: cannot initialize SignatureSupport variable\n"); |
| 113 | |
| 114 | return ret; |
| 115 | } |
| 116 | #else |
| 117 | static efi_status_t efi_init_secure_boot(void) |
| 118 | { |
| 119 | return EFI_SUCCESS; |
| 120 | } |
| 121 | #endif /* CONFIG_EFI_SECURE_BOOT */ |
| 122 | |
Heinrich Schuchardt | 3700d57 | 2019-04-11 07:34:24 +0200 | [diff] [blame] | 123 | /** |
AKASHI Takahiro | 473d9b3 | 2020-11-17 09:27:55 +0900 | [diff] [blame] | 124 | * efi_init_capsule - initialize capsule update state |
| 125 | * |
| 126 | * Return: status code |
| 127 | */ |
| 128 | static efi_status_t efi_init_capsule(void) |
| 129 | { |
| 130 | efi_status_t ret = EFI_SUCCESS; |
| 131 | |
Ilias Apalodimas | 21bd5ac | 2023-01-20 13:58:48 +0200 | [diff] [blame] | 132 | if (IS_ENABLED(CONFIG_EFI_HAVE_CAPSULE_SUPPORT)) { |
Etienne Carriere | 6326e91 | 2023-02-16 18:21:41 +0100 | [diff] [blame] | 133 | u16 var_name16[12]; |
| 134 | |
| 135 | efi_create_indexed_name(var_name16, sizeof(var_name16), |
| 136 | "Capsule", CONFIG_EFI_CAPSULE_MAX); |
| 137 | |
Simon Glass | 9097537 | 2022-01-23 12:55:12 -0700 | [diff] [blame] | 138 | ret = efi_set_variable_int(u"CapsuleMax", |
AKASHI Takahiro | 473d9b3 | 2020-11-17 09:27:55 +0900 | [diff] [blame] | 139 | &efi_guid_capsule_report, |
| 140 | EFI_VARIABLE_READ_ONLY | |
| 141 | EFI_VARIABLE_BOOTSERVICE_ACCESS | |
| 142 | EFI_VARIABLE_RUNTIME_ACCESS, |
Etienne Carriere | 6326e91 | 2023-02-16 18:21:41 +0100 | [diff] [blame] | 143 | 22, var_name16, false); |
AKASHI Takahiro | 473d9b3 | 2020-11-17 09:27:55 +0900 | [diff] [blame] | 144 | if (ret != EFI_SUCCESS) |
| 145 | printf("EFI: cannot initialize CapsuleMax variable\n"); |
| 146 | } |
| 147 | |
| 148 | return ret; |
| 149 | } |
| 150 | |
| 151 | /** |
| 152 | * efi_init_os_indications() - indicate supported features for OS requests |
| 153 | * |
| 154 | * Set the OsIndicationsSupported variable. |
| 155 | * |
| 156 | * Return: status code |
| 157 | */ |
| 158 | static efi_status_t efi_init_os_indications(void) |
| 159 | { |
| 160 | u64 os_indications_supported = 0; |
| 161 | |
| 162 | if (IS_ENABLED(CONFIG_EFI_HAVE_CAPSULE_SUPPORT)) |
| 163 | os_indications_supported |= |
| 164 | EFI_OS_INDICATIONS_CAPSULE_RESULT_VAR_SUPPORTED; |
| 165 | |
AKASHI Takahiro | 45b81954 | 2020-11-17 09:27:56 +0900 | [diff] [blame] | 166 | if (IS_ENABLED(CONFIG_EFI_CAPSULE_ON_DISK)) |
| 167 | os_indications_supported |= |
| 168 | EFI_OS_INDICATIONS_FILE_CAPSULE_DELIVERY_SUPPORTED; |
| 169 | |
AKASHI Takahiro | 0d96378 | 2020-11-30 18:12:11 +0900 | [diff] [blame] | 170 | if (IS_ENABLED(CONFIG_EFI_CAPSULE_FIRMWARE_MANAGEMENT)) |
| 171 | os_indications_supported |= |
| 172 | EFI_OS_INDICATIONS_FMP_CAPSULE_SUPPORTED; |
| 173 | |
Simon Glass | 9097537 | 2022-01-23 12:55:12 -0700 | [diff] [blame] | 174 | return efi_set_variable_int(u"OsIndicationsSupported", |
AKASHI Takahiro | 473d9b3 | 2020-11-17 09:27:55 +0900 | [diff] [blame] | 175 | &efi_global_variable_guid, |
| 176 | EFI_VARIABLE_BOOTSERVICE_ACCESS | |
| 177 | EFI_VARIABLE_RUNTIME_ACCESS | |
| 178 | EFI_VARIABLE_READ_ONLY, |
| 179 | sizeof(os_indications_supported), |
| 180 | &os_indications_supported, false); |
| 181 | } |
| 182 | |
Heinrich Schuchardt | a306a12 | 2021-06-29 13:33:09 +0200 | [diff] [blame] | 183 | /** |
AKASHI Takahiro | 9a84e07 | 2022-10-21 12:01:57 +0900 | [diff] [blame] | 184 | * efi_init_early() - handle initialization at early stage |
AKASHI Takahiro | a36dc25 | 2022-04-19 10:05:11 +0900 | [diff] [blame] | 185 | * |
AKASHI Takahiro | 9a84e07 | 2022-10-21 12:01:57 +0900 | [diff] [blame] | 186 | * expected to be called in board_init_r(). |
Heinrich Schuchardt | 3700d57 | 2019-04-11 07:34:24 +0200 | [diff] [blame] | 187 | * |
| 188 | * Return: status code |
| 189 | */ |
AKASHI Takahiro | 9a84e07 | 2022-10-21 12:01:57 +0900 | [diff] [blame] | 190 | int efi_init_early(void) |
Heinrich Schuchardt | 3700d57 | 2019-04-11 07:34:24 +0200 | [diff] [blame] | 191 | { |
AKASHI Takahiro | 9a84e07 | 2022-10-21 12:01:57 +0900 | [diff] [blame] | 192 | efi_status_t ret; |
Heinrich Schuchardt | f7fe45b | 2019-04-05 02:45:21 +0200 | [diff] [blame] | 193 | |
Heinrich Schuchardt | aea03d6 | 2019-05-04 11:47:48 +0200 | [diff] [blame] | 194 | /* Allow unaligned memory access */ |
| 195 | allow_unaligned(); |
| 196 | |
Heinrich Schuchardt | f667a18 | 2020-05-20 21:27:29 +0200 | [diff] [blame] | 197 | /* Initialize root node */ |
| 198 | ret = efi_root_node_register(); |
| 199 | if (ret != EFI_SUCCESS) |
| 200 | goto out; |
| 201 | |
AKASHI Takahiro | 9b31c63 | 2020-06-09 14:09:31 +0900 | [diff] [blame] | 202 | ret = efi_console_register(); |
| 203 | if (ret != EFI_SUCCESS) |
| 204 | goto out; |
| 205 | |
Heinrich Schuchardt | 6c5fd21 | 2022-10-05 11:28:47 +0200 | [diff] [blame] | 206 | /* Initialize EFI driver uclass */ |
| 207 | ret = efi_driver_init(); |
AKASHI Takahiro | 9a84e07 | 2022-10-21 12:01:57 +0900 | [diff] [blame] | 208 | if (ret != EFI_SUCCESS) |
| 209 | goto out; |
AKASHI Takahiro | a36dc25 | 2022-04-19 10:05:11 +0900 | [diff] [blame] | 210 | |
AKASHI Takahiro | a36dc25 | 2022-04-19 10:05:11 +0900 | [diff] [blame] | 211 | return 0; |
AKASHI Takahiro | 9a84e07 | 2022-10-21 12:01:57 +0900 | [diff] [blame] | 212 | out: |
| 213 | /* never re-init UEFI subsystem */ |
| 214 | efi_obj_list_initialized = ret; |
| 215 | |
| 216 | return -1; |
AKASHI Takahiro | a36dc25 | 2022-04-19 10:05:11 +0900 | [diff] [blame] | 217 | } |
| 218 | |
| 219 | /** |
| 220 | * efi_init_obj_list() - Initialize and populate EFI object list |
| 221 | * |
| 222 | * Return: status code |
| 223 | */ |
| 224 | efi_status_t efi_init_obj_list(void) |
| 225 | { |
| 226 | efi_status_t ret = EFI_SUCCESS; |
| 227 | |
| 228 | /* Initialize once only */ |
| 229 | if (efi_obj_list_initialized != OBJ_LIST_NOT_INITIALIZED) |
| 230 | return efi_obj_list_initialized; |
| 231 | |
Heinrich Schuchardt | 761908e | 2022-06-14 08:02:03 +0200 | [diff] [blame] | 232 | /* Set up console modes */ |
| 233 | efi_setup_console_size(); |
| 234 | |
Heinrich Schuchardt | a02228f | 2022-08-31 16:37:35 +0200 | [diff] [blame] | 235 | /* |
| 236 | * Probe block devices to find the ESP. |
| 237 | * efi_disks_register() must be called before efi_init_variables(). |
| 238 | */ |
| 239 | ret = efi_disks_register(); |
| 240 | if (ret != EFI_SUCCESS) |
| 241 | goto out; |
| 242 | |
Heinrich Schuchardt | cf3b118 | 2019-06-20 13:52:16 +0200 | [diff] [blame] | 243 | /* Initialize variable services */ |
| 244 | ret = efi_init_variables(); |
| 245 | if (ret != EFI_SUCCESS) |
| 246 | goto out; |
| 247 | |
Heinrich Schuchardt | 3700d57 | 2019-04-11 07:34:24 +0200 | [diff] [blame] | 248 | /* Define supported languages */ |
| 249 | ret = efi_init_platform_lang(); |
| 250 | if (ret != EFI_SUCCESS) |
| 251 | goto out; |
| 252 | |
AKASHI Takahiro | 3a48925 | 2019-04-24 15:30:38 +0900 | [diff] [blame] | 253 | /* Indicate supported features */ |
AKASHI Takahiro | 473d9b3 | 2020-11-17 09:27:55 +0900 | [diff] [blame] | 254 | ret = efi_init_os_indications(); |
AKASHI Takahiro | 3a48925 | 2019-04-24 15:30:38 +0900 | [diff] [blame] | 255 | if (ret != EFI_SUCCESS) |
| 256 | goto out; |
| 257 | |
Heinrich Schuchardt | 956eff3 | 2020-02-19 20:48:49 +0100 | [diff] [blame] | 258 | /* Initialize system table */ |
| 259 | ret = efi_initialize_system_table(); |
AKASHI Takahiro | 3240184 | 2019-06-05 13:21:38 +0900 | [diff] [blame] | 260 | if (ret != EFI_SUCCESS) |
| 261 | goto out; |
| 262 | |
Jose Marinho | ff72cb3 | 2021-12-23 14:51:07 +0000 | [diff] [blame] | 263 | if (IS_ENABLED(CONFIG_EFI_ECPT)) { |
| 264 | ret = efi_ecpt_register(); |
| 265 | if (ret != EFI_SUCCESS) |
| 266 | goto out; |
| 267 | } |
| 268 | |
Jose Marinho | ebb61ee | 2021-03-02 17:26:38 +0000 | [diff] [blame] | 269 | if (IS_ENABLED(CONFIG_EFI_ESRT)) { |
| 270 | ret = efi_esrt_register(); |
| 271 | if (ret != EFI_SUCCESS) |
| 272 | goto out; |
| 273 | } |
| 274 | |
Ilias Apalodimas | 967650d | 2020-11-30 11:47:40 +0200 | [diff] [blame] | 275 | if (IS_ENABLED(CONFIG_EFI_TCG2_PROTOCOL)) { |
| 276 | ret = efi_tcg2_register(); |
| 277 | if (ret != EFI_SUCCESS) |
| 278 | goto out; |
Masahisa Kojima | 0fd4379 | 2021-12-07 14:15:31 +0900 | [diff] [blame] | 279 | |
| 280 | ret = efi_tcg2_do_initial_measurement(); |
| 281 | if (ret == EFI_SECURITY_VIOLATION) |
| 282 | goto out; |
Ilias Apalodimas | 967650d | 2020-11-30 11:47:40 +0200 | [diff] [blame] | 283 | } |
| 284 | |
Ilias Apalodimas | 369b926 | 2022-07-22 21:32:03 +0530 | [diff] [blame] | 285 | /* Install EFI_RNG_PROTOCOL */ |
| 286 | if (IS_ENABLED(CONFIG_EFI_RNG_PROTOCOL)) { |
| 287 | ret = efi_rng_register(); |
| 288 | if (ret != EFI_SUCCESS) |
| 289 | goto out; |
| 290 | } |
| 291 | |
Sunil V L | 279d1c8 | 2022-01-28 20:48:44 +0530 | [diff] [blame] | 292 | if (IS_ENABLED(CONFIG_EFI_RISCV_BOOT_PROTOCOL)) { |
| 293 | ret = efi_riscv_register(); |
| 294 | if (ret != EFI_SUCCESS) |
| 295 | goto out; |
| 296 | } |
| 297 | |
AKASHI Takahiro | 8d494f6 | 2020-04-14 11:51:45 +0900 | [diff] [blame] | 298 | /* Secure boot */ |
| 299 | ret = efi_init_secure_boot(); |
| 300 | if (ret != EFI_SUCCESS) |
| 301 | goto out; |
| 302 | |
Heinrich Schuchardt | 956eff3 | 2020-02-19 20:48:49 +0100 | [diff] [blame] | 303 | /* Indicate supported runtime services */ |
| 304 | ret = efi_init_runtime_supported(); |
AKASHI Takahiro | 7e0badb | 2018-12-30 15:16:55 +0100 | [diff] [blame] | 305 | if (ret != EFI_SUCCESS) |
| 306 | goto out; |
| 307 | |
Ilias Apalodimas | fac773e | 2021-06-22 17:38:53 +0300 | [diff] [blame] | 308 | if (IS_ENABLED(CONFIG_EFI_HAVE_CAPSULE_SUPPORT)) { |
| 309 | ret = efi_load_capsule_drivers(); |
| 310 | if (ret != EFI_SUCCESS) |
| 311 | goto out; |
| 312 | } |
| 313 | |
Simon Glass | 52cb504 | 2022-10-18 07:46:31 -0600 | [diff] [blame] | 314 | if (IS_ENABLED(CONFIG_VIDEO)) { |
Simon Glass | 26a6af2 | 2022-10-16 15:58:34 -0600 | [diff] [blame] | 315 | ret = efi_gop_register(); |
| 316 | if (ret != EFI_SUCCESS) |
| 317 | goto out; |
| 318 | } |
Jan Kiszka | f138982 | 2022-10-14 18:10:06 +0200 | [diff] [blame] | 319 | #ifdef CONFIG_NETDEVICES |
AKASHI Takahiro | 7e0badb | 2018-12-30 15:16:55 +0100 | [diff] [blame] | 320 | ret = efi_net_register(); |
| 321 | if (ret != EFI_SUCCESS) |
| 322 | goto out; |
| 323 | #endif |
Simon Glass | b0a8544 | 2023-09-19 21:00:12 -0600 | [diff] [blame] | 324 | if (IS_ENABLED(CONFIG_ACPI)) { |
| 325 | ret = efi_acpi_register(); |
| 326 | if (ret != EFI_SUCCESS) |
| 327 | goto out; |
| 328 | } |
Simon Glass | aadec12 | 2023-09-20 07:29:51 -0600 | [diff] [blame^] | 329 | if (IS_ENABLED(CONFIG_SMBIOS)) { |
| 330 | ret = efi_smbios_register(); |
| 331 | if (ret != EFI_SUCCESS) |
| 332 | goto out; |
| 333 | } |
AKASHI Takahiro | 7e0badb | 2018-12-30 15:16:55 +0100 | [diff] [blame] | 334 | ret = efi_watchdog_register(); |
| 335 | if (ret != EFI_SUCCESS) |
| 336 | goto out; |
| 337 | |
AKASHI Takahiro | 473d9b3 | 2020-11-17 09:27:55 +0900 | [diff] [blame] | 338 | ret = efi_init_capsule(); |
| 339 | if (ret != EFI_SUCCESS) |
| 340 | goto out; |
| 341 | |
AKASHI Takahiro | 7e0badb | 2018-12-30 15:16:55 +0100 | [diff] [blame] | 342 | /* Initialize EFI runtime services */ |
| 343 | ret = efi_reset_system_init(); |
| 344 | if (ret != EFI_SUCCESS) |
| 345 | goto out; |
| 346 | |
AKASHI Takahiro | 45b81954 | 2020-11-17 09:27:56 +0900 | [diff] [blame] | 347 | /* Execute capsules after reboot */ |
| 348 | if (IS_ENABLED(CONFIG_EFI_CAPSULE_ON_DISK) && |
| 349 | !IS_ENABLED(CONFIG_EFI_CAPSULE_ON_DISK_EARLY)) |
| 350 | ret = efi_launch_capsules(); |
AKASHI Takahiro | 7e0badb | 2018-12-30 15:16:55 +0100 | [diff] [blame] | 351 | out: |
AKASHI Takahiro | 7e0badb | 2018-12-30 15:16:55 +0100 | [diff] [blame] | 352 | efi_obj_list_initialized = ret; |
| 353 | return ret; |
| 354 | } |