Tom Rini | f739fcd | 2018-05-07 17:02:21 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Rob Clark | 9975fe9 | 2017-09-13 18:05:38 -0400 | [diff] [blame] | 2 | /* |
Heinrich Schuchardt | e1fec15 | 2018-10-18 21:51:38 +0200 | [diff] [blame] | 3 | * EFI boot manager |
Rob Clark | 9975fe9 | 2017-09-13 18:05:38 -0400 | [diff] [blame] | 4 | * |
| 5 | * Copyright (c) 2017 Rob Clark |
Rob Clark | 9975fe9 | 2017-09-13 18:05:38 -0400 | [diff] [blame] | 6 | */ |
| 7 | |
Heinrich Schuchardt | 7a373e5 | 2020-05-31 10:07:31 +0200 | [diff] [blame] | 8 | #define LOG_CATEGORY LOGC_EFI |
| 9 | |
Rob Clark | 9975fe9 | 2017-09-13 18:05:38 -0400 | [diff] [blame] | 10 | #include <common.h> |
| 11 | #include <charset.h> |
Simon Glass | f7ae49f | 2020-05-10 11:40:05 -0600 | [diff] [blame] | 12 | #include <log.h> |
Rob Clark | 9975fe9 | 2017-09-13 18:05:38 -0400 | [diff] [blame] | 13 | #include <malloc.h> |
AKASHI Takahiro | 4e65ca0 | 2022-04-28 17:09:39 +0900 | [diff] [blame] | 14 | #include <efi_default_filename.h> |
Rob Clark | 9975fe9 | 2017-09-13 18:05:38 -0400 | [diff] [blame] | 15 | #include <efi_loader.h> |
Heinrich Schuchardt | dda8c71 | 2020-06-24 19:09:18 +0200 | [diff] [blame] | 16 | #include <efi_variable.h> |
AKASHI Takahiro | 1a82b34 | 2018-11-05 18:06:41 +0900 | [diff] [blame] | 17 | #include <asm/unaligned.h> |
Rob Clark | 9975fe9 | 2017-09-13 18:05:38 -0400 | [diff] [blame] | 18 | |
| 19 | static const struct efi_boot_services *bs; |
| 20 | static const struct efi_runtime_services *rs; |
| 21 | |
Rob Clark | 9975fe9 | 2017-09-13 18:05:38 -0400 | [diff] [blame] | 22 | /* |
| 23 | * bootmgr implements the logic of trying to find a payload to boot |
| 24 | * based on the BootOrder + BootXXXX variables, and then loading it. |
| 25 | * |
| 26 | * TODO detecting a special key held (f9?) and displaying a boot menu |
| 27 | * like you would get on a PC would be clever. |
| 28 | * |
| 29 | * TODO if we had a way to write and persist variables after the OS |
| 30 | * has started, we'd also want to check OsIndications to see if we |
| 31 | * should do normal or recovery boot. |
| 32 | */ |
| 33 | |
Heinrich Schuchardt | 1064d04 | 2020-08-07 17:47:13 +0200 | [diff] [blame] | 34 | /** |
AKASHI Takahiro | 4e65ca0 | 2022-04-28 17:09:39 +0900 | [diff] [blame] | 35 | * expand_media_path() - expand a device path for default file name |
| 36 | * @device_path: device path to check against |
| 37 | * |
| 38 | * If @device_path is a media or disk partition which houses a file |
| 39 | * system, this function returns a full device path which contains |
| 40 | * an architecture-specific default file name for removable media. |
| 41 | * |
| 42 | * Return: a newly allocated device path |
| 43 | */ |
| 44 | static |
| 45 | struct efi_device_path *expand_media_path(struct efi_device_path *device_path) |
| 46 | { |
| 47 | struct efi_device_path *dp, *full_path; |
| 48 | efi_handle_t handle; |
| 49 | efi_status_t ret; |
| 50 | |
| 51 | if (!device_path) |
| 52 | return NULL; |
| 53 | |
| 54 | /* |
| 55 | * If device_path is a (removable) media or partition which provides |
| 56 | * simple file system protocol, append a default file name to support |
| 57 | * booting from removable media. |
| 58 | */ |
| 59 | dp = device_path; |
| 60 | ret = EFI_CALL(efi_locate_device_path( |
| 61 | &efi_simple_file_system_protocol_guid, |
| 62 | &dp, &handle)); |
| 63 | if (ret == EFI_SUCCESS) { |
| 64 | if (dp->type == DEVICE_PATH_TYPE_END) { |
| 65 | dp = efi_dp_from_file(NULL, 0, |
| 66 | "/EFI/BOOT/" BOOTEFI_NAME); |
| 67 | full_path = efi_dp_append(device_path, dp); |
| 68 | efi_free_pool(dp); |
| 69 | } else { |
| 70 | full_path = efi_dp_dup(device_path); |
| 71 | } |
| 72 | } else { |
| 73 | full_path = efi_dp_dup(device_path); |
| 74 | } |
| 75 | |
| 76 | return full_path; |
| 77 | } |
| 78 | |
| 79 | /** |
AKASHI Takahiro | 57ad624 | 2022-05-12 11:29:02 +0900 | [diff] [blame] | 80 | * try_load_from_file_path() - try to load a file |
| 81 | * |
| 82 | * Given a file media path iterate through a list of handles and try to |
| 83 | * to load the file from each of them until the first success. |
| 84 | * |
| 85 | * @fs_handles: array of handles with the simple file protocol |
| 86 | * @num: number of handles in fs_handles |
| 87 | * @fp: file path to open |
| 88 | * @handle: on return pointer to handle for loaded image |
| 89 | * @removable: if true only consider removable media, else only non-removable |
| 90 | */ |
| 91 | static efi_status_t try_load_from_file_path(efi_handle_t *fs_handles, |
| 92 | efi_uintn_t num, |
| 93 | struct efi_device_path *fp, |
| 94 | efi_handle_t *handle, |
| 95 | bool removable) |
| 96 | { |
| 97 | struct efi_handler *handler; |
| 98 | struct efi_device_path *dp; |
| 99 | int i; |
| 100 | efi_status_t ret; |
| 101 | |
| 102 | for (i = 0; i < num; i++) { |
| 103 | if (removable != efi_disk_is_removable(fs_handles[i])) |
| 104 | continue; |
| 105 | |
| 106 | ret = efi_search_protocol(fs_handles[i], &efi_guid_device_path, |
| 107 | &handler); |
| 108 | if (ret != EFI_SUCCESS) |
| 109 | continue; |
| 110 | |
| 111 | dp = handler->protocol_interface; |
| 112 | if (!dp) |
| 113 | continue; |
| 114 | |
| 115 | dp = efi_dp_append(dp, fp); |
| 116 | if (!dp) |
| 117 | continue; |
| 118 | |
| 119 | ret = EFI_CALL(efi_load_image(true, efi_root, dp, NULL, 0, |
| 120 | handle)); |
| 121 | efi_free_pool(dp); |
| 122 | if (ret == EFI_SUCCESS) |
| 123 | return ret; |
| 124 | } |
| 125 | |
| 126 | return EFI_NOT_FOUND; |
| 127 | } |
| 128 | |
| 129 | /** |
| 130 | * try_load_from_short_path |
| 131 | * @fp: file path |
| 132 | * @handle: pointer to handle for newly installed image |
| 133 | * |
| 134 | * Enumerate all the devices which support file system operations, |
| 135 | * prepend its media device path to the file path, @fp, and |
| 136 | * try to load the file. |
| 137 | * This function should be called when handling a short-form path |
| 138 | * which is starting with a file device path. |
| 139 | * |
| 140 | * Return: status code |
| 141 | */ |
| 142 | static efi_status_t try_load_from_short_path(struct efi_device_path *fp, |
| 143 | efi_handle_t *handle) |
| 144 | { |
| 145 | efi_handle_t *fs_handles; |
| 146 | efi_uintn_t num; |
| 147 | efi_status_t ret; |
| 148 | |
| 149 | ret = EFI_CALL(efi_locate_handle_buffer( |
| 150 | BY_PROTOCOL, |
| 151 | &efi_simple_file_system_protocol_guid, |
| 152 | NULL, |
| 153 | &num, &fs_handles)); |
| 154 | if (ret != EFI_SUCCESS) |
| 155 | return ret; |
| 156 | if (!num) |
| 157 | return EFI_NOT_FOUND; |
| 158 | |
| 159 | /* removable media first */ |
| 160 | ret = try_load_from_file_path(fs_handles, num, fp, handle, true); |
| 161 | if (ret == EFI_SUCCESS) |
| 162 | goto out; |
| 163 | |
| 164 | /* fixed media */ |
| 165 | ret = try_load_from_file_path(fs_handles, num, fp, handle, false); |
| 166 | if (ret == EFI_SUCCESS) |
| 167 | goto out; |
| 168 | |
| 169 | out: |
| 170 | return ret; |
| 171 | } |
| 172 | |
| 173 | /** |
Heinrich Schuchardt | 15621aa | 2019-07-14 13:20:28 +0200 | [diff] [blame] | 174 | * try_load_entry() - try to load image for boot option |
| 175 | * |
Rob Clark | 9975fe9 | 2017-09-13 18:05:38 -0400 | [diff] [blame] | 176 | * Attempt to load load-option number 'n', returning device_path and file_path |
Heinrich Schuchardt | 15621aa | 2019-07-14 13:20:28 +0200 | [diff] [blame] | 177 | * if successful. This checks that the EFI_LOAD_OPTION is active (enabled) |
Rob Clark | 9975fe9 | 2017-09-13 18:05:38 -0400 | [diff] [blame] | 178 | * and that the specified file to boot exists. |
Heinrich Schuchardt | 15621aa | 2019-07-14 13:20:28 +0200 | [diff] [blame] | 179 | * |
Heinrich Schuchardt | 0ad6400 | 2020-08-07 17:49:39 +0200 | [diff] [blame] | 180 | * @n: number of the boot option, e.g. 0x0a13 for Boot0A13 |
| 181 | * @handle: on return handle for the newly installed image |
| 182 | * @load_options: load options set on the loaded image protocol |
| 183 | * Return: status code |
Rob Clark | 9975fe9 | 2017-09-13 18:05:38 -0400 | [diff] [blame] | 184 | */ |
Heinrich Schuchardt | 0ad6400 | 2020-08-07 17:49:39 +0200 | [diff] [blame] | 185 | static efi_status_t try_load_entry(u16 n, efi_handle_t *handle, |
| 186 | void **load_options) |
Rob Clark | 9975fe9 | 2017-09-13 18:05:38 -0400 | [diff] [blame] | 187 | { |
AKASHI Takahiro | 1a82b34 | 2018-11-05 18:06:41 +0900 | [diff] [blame] | 188 | struct efi_load_option lo; |
Heinrich Schuchardt | 4f41996 | 2022-04-25 23:35:01 +0200 | [diff] [blame] | 189 | u16 varname[9]; |
AKASHI Takahiro | 6b95b38 | 2019-04-19 12:22:35 +0900 | [diff] [blame] | 190 | void *load_option; |
Heinrich Schuchardt | 45c66f9 | 2018-05-17 07:57:05 +0200 | [diff] [blame] | 191 | efi_uintn_t size; |
AKASHI Takahiro | 6b95b38 | 2019-04-19 12:22:35 +0900 | [diff] [blame] | 192 | efi_status_t ret; |
Rob Clark | 9975fe9 | 2017-09-13 18:05:38 -0400 | [diff] [blame] | 193 | |
Heinrich Schuchardt | 4f41996 | 2022-04-25 23:35:01 +0200 | [diff] [blame] | 194 | efi_create_indexed_name(varname, sizeof(varname), "Boot", n); |
Rob Clark | 9975fe9 | 2017-09-13 18:05:38 -0400 | [diff] [blame] | 195 | |
Ilias Apalodimas | f4dc1bc | 2021-03-27 10:56:07 +0200 | [diff] [blame] | 196 | load_option = efi_get_var(varname, &efi_global_variable_guid, &size); |
Rob Clark | 9975fe9 | 2017-09-13 18:05:38 -0400 | [diff] [blame] | 197 | if (!load_option) |
AKASHI Takahiro | 6b95b38 | 2019-04-19 12:22:35 +0900 | [diff] [blame] | 198 | return EFI_LOAD_ERROR; |
Rob Clark | 9975fe9 | 2017-09-13 18:05:38 -0400 | [diff] [blame] | 199 | |
Heinrich Schuchardt | 0e69bcf | 2020-05-31 22:46:09 +0200 | [diff] [blame] | 200 | ret = efi_deserialize_load_option(&lo, load_option, &size); |
| 201 | if (ret != EFI_SUCCESS) { |
| 202 | log_warning("Invalid load option for %ls\n", varname); |
| 203 | goto error; |
| 204 | } |
Rob Clark | 9975fe9 | 2017-09-13 18:05:38 -0400 | [diff] [blame] | 205 | |
| 206 | if (lo.attributes & LOAD_OPTION_ACTIVE) { |
AKASHI Takahiro | 4e65ca0 | 2022-04-28 17:09:39 +0900 | [diff] [blame] | 207 | struct efi_device_path *file_path; |
AKASHI Takahiro | 37279ad | 2019-03-20 09:07:55 +0900 | [diff] [blame] | 208 | u32 attributes; |
Rob Clark | 9975fe9 | 2017-09-13 18:05:38 -0400 | [diff] [blame] | 209 | |
Heinrich Schuchardt | 7ea79e5 | 2022-04-29 07:15:04 +0200 | [diff] [blame] | 210 | log_debug("trying to load \"%ls\" from %pD\n", lo.label, |
| 211 | lo.file_path); |
Rob Clark | 9975fe9 | 2017-09-13 18:05:38 -0400 | [diff] [blame] | 212 | |
AKASHI Takahiro | 57ad624 | 2022-05-12 11:29:02 +0900 | [diff] [blame] | 213 | if (EFI_DP_TYPE(lo.file_path, MEDIA_DEVICE, FILE_PATH)) { |
| 214 | /* file_path doesn't contain a device path */ |
| 215 | ret = try_load_from_short_path(lo.file_path, handle); |
| 216 | } else { |
| 217 | file_path = expand_media_path(lo.file_path); |
| 218 | ret = EFI_CALL(efi_load_image(true, efi_root, file_path, |
| 219 | NULL, 0, handle)); |
| 220 | efi_free_pool(file_path); |
| 221 | } |
AKASHI Takahiro | 94e6e55 | 2019-05-29 20:54:25 +0200 | [diff] [blame] | 222 | if (ret != EFI_SUCCESS) { |
Heinrich Schuchardt | 7a373e5 | 2020-05-31 10:07:31 +0200 | [diff] [blame] | 223 | log_warning("Loading %ls '%ls' failed\n", |
| 224 | varname, lo.label); |
Rob Clark | 9975fe9 | 2017-09-13 18:05:38 -0400 | [diff] [blame] | 225 | goto error; |
AKASHI Takahiro | 94e6e55 | 2019-05-29 20:54:25 +0200 | [diff] [blame] | 226 | } |
Rob Clark | 9975fe9 | 2017-09-13 18:05:38 -0400 | [diff] [blame] | 227 | |
AKASHI Takahiro | 37279ad | 2019-03-20 09:07:55 +0900 | [diff] [blame] | 228 | attributes = EFI_VARIABLE_BOOTSERVICE_ACCESS | |
| 229 | EFI_VARIABLE_RUNTIME_ACCESS; |
Simon Glass | 156ccbc | 2022-01-23 12:55:12 -0700 | [diff] [blame] | 230 | ret = efi_set_variable_int(u"BootCurrent", |
Heinrich Schuchardt | dda8c71 | 2020-06-24 19:09:18 +0200 | [diff] [blame] | 231 | &efi_global_variable_guid, |
Heinrich Schuchardt | 0ad6400 | 2020-08-07 17:49:39 +0200 | [diff] [blame] | 232 | attributes, sizeof(n), &n, false); |
Ilias Apalodimas | 53f6a5a | 2021-03-17 21:55:00 +0200 | [diff] [blame] | 233 | if (ret != EFI_SUCCESS) |
| 234 | goto unload; |
| 235 | /* try to register load file2 for initrd's */ |
| 236 | if (IS_ENABLED(CONFIG_EFI_LOAD_FILE2_INITRD)) { |
| 237 | ret = efi_initrd_register(); |
| 238 | if (ret != EFI_SUCCESS) |
| 239 | goto unload; |
AKASHI Takahiro | 6b95b38 | 2019-04-19 12:22:35 +0900 | [diff] [blame] | 240 | } |
AKASHI Takahiro | 37279ad | 2019-03-20 09:07:55 +0900 | [diff] [blame] | 241 | |
Heinrich Schuchardt | 7a373e5 | 2020-05-31 10:07:31 +0200 | [diff] [blame] | 242 | log_info("Booting: %ls\n", lo.label); |
AKASHI Takahiro | 6b95b38 | 2019-04-19 12:22:35 +0900 | [diff] [blame] | 243 | } else { |
| 244 | ret = EFI_LOAD_ERROR; |
Rob Clark | 9975fe9 | 2017-09-13 18:05:38 -0400 | [diff] [blame] | 245 | } |
| 246 | |
Heinrich Schuchardt | 0ad6400 | 2020-08-07 17:49:39 +0200 | [diff] [blame] | 247 | /* Set load options */ |
| 248 | if (size) { |
| 249 | *load_options = malloc(size); |
| 250 | if (!*load_options) { |
| 251 | ret = EFI_OUT_OF_RESOURCES; |
| 252 | goto error; |
| 253 | } |
| 254 | memcpy(*load_options, lo.optional_data, size); |
| 255 | ret = efi_set_load_options(*handle, size, *load_options); |
| 256 | } else { |
Heinrich Schuchardt | e434311 | 2020-12-27 15:46:00 +0100 | [diff] [blame] | 257 | *load_options = NULL; |
Heinrich Schuchardt | 0ad6400 | 2020-08-07 17:49:39 +0200 | [diff] [blame] | 258 | } |
| 259 | |
Rob Clark | 9975fe9 | 2017-09-13 18:05:38 -0400 | [diff] [blame] | 260 | error: |
| 261 | free(load_option); |
| 262 | |
AKASHI Takahiro | 6b95b38 | 2019-04-19 12:22:35 +0900 | [diff] [blame] | 263 | return ret; |
Ilias Apalodimas | 53f6a5a | 2021-03-17 21:55:00 +0200 | [diff] [blame] | 264 | |
| 265 | unload: |
| 266 | if (EFI_CALL(efi_unload_image(*handle)) != EFI_SUCCESS) |
| 267 | log_err("Unloading image failed\n"); |
| 268 | free(load_option); |
| 269 | |
| 270 | return ret; |
Rob Clark | 9975fe9 | 2017-09-13 18:05:38 -0400 | [diff] [blame] | 271 | } |
| 272 | |
Heinrich Schuchardt | 15621aa | 2019-07-14 13:20:28 +0200 | [diff] [blame] | 273 | /** |
| 274 | * efi_bootmgr_load() - try to load from BootNext or BootOrder |
| 275 | * |
AKASHI Takahiro | 37279ad | 2019-03-20 09:07:55 +0900 | [diff] [blame] | 276 | * Attempt to load from BootNext or in the order specified by BootOrder |
| 277 | * EFI variable, the available load-options, finding and returning |
| 278 | * the first one that can be loaded successfully. |
Heinrich Schuchardt | 15621aa | 2019-07-14 13:20:28 +0200 | [diff] [blame] | 279 | * |
Heinrich Schuchardt | 0ad6400 | 2020-08-07 17:49:39 +0200 | [diff] [blame] | 280 | * @handle: on return handle for the newly installed image |
| 281 | * @load_options: load options set on the loaded image protocol |
| 282 | * Return: status code |
Rob Clark | 9975fe9 | 2017-09-13 18:05:38 -0400 | [diff] [blame] | 283 | */ |
Heinrich Schuchardt | 0ad6400 | 2020-08-07 17:49:39 +0200 | [diff] [blame] | 284 | efi_status_t efi_bootmgr_load(efi_handle_t *handle, void **load_options) |
Rob Clark | 9975fe9 | 2017-09-13 18:05:38 -0400 | [diff] [blame] | 285 | { |
AKASHI Takahiro | 37279ad | 2019-03-20 09:07:55 +0900 | [diff] [blame] | 286 | u16 bootnext, *bootorder; |
Heinrich Schuchardt | 45c66f9 | 2018-05-17 07:57:05 +0200 | [diff] [blame] | 287 | efi_uintn_t size; |
Rob Clark | 9975fe9 | 2017-09-13 18:05:38 -0400 | [diff] [blame] | 288 | int i, num; |
AKASHI Takahiro | 37279ad | 2019-03-20 09:07:55 +0900 | [diff] [blame] | 289 | efi_status_t ret; |
Rob Clark | 9975fe9 | 2017-09-13 18:05:38 -0400 | [diff] [blame] | 290 | |
Rob Clark | 9975fe9 | 2017-09-13 18:05:38 -0400 | [diff] [blame] | 291 | bs = systab.boottime; |
| 292 | rs = systab.runtime; |
| 293 | |
AKASHI Takahiro | 37279ad | 2019-03-20 09:07:55 +0900 | [diff] [blame] | 294 | /* BootNext */ |
AKASHI Takahiro | 37279ad | 2019-03-20 09:07:55 +0900 | [diff] [blame] | 295 | size = sizeof(bootnext); |
Simon Glass | 156ccbc | 2022-01-23 12:55:12 -0700 | [diff] [blame] | 296 | ret = efi_get_variable_int(u"BootNext", |
Heinrich Schuchardt | dda8c71 | 2020-06-24 19:09:18 +0200 | [diff] [blame] | 297 | &efi_global_variable_guid, |
| 298 | NULL, &size, &bootnext, NULL); |
AKASHI Takahiro | 37279ad | 2019-03-20 09:07:55 +0900 | [diff] [blame] | 299 | if (ret == EFI_SUCCESS || ret == EFI_BUFFER_TOO_SMALL) { |
| 300 | /* BootNext does exist here */ |
| 301 | if (ret == EFI_BUFFER_TOO_SMALL || size != sizeof(u16)) |
Heinrich Schuchardt | 7a373e5 | 2020-05-31 10:07:31 +0200 | [diff] [blame] | 302 | log_err("BootNext must be 16-bit integer\n"); |
AKASHI Takahiro | 37279ad | 2019-03-20 09:07:55 +0900 | [diff] [blame] | 303 | |
| 304 | /* delete BootNext */ |
Simon Glass | 156ccbc | 2022-01-23 12:55:12 -0700 | [diff] [blame] | 305 | ret = efi_set_variable_int(u"BootNext", |
Heinrich Schuchardt | dda8c71 | 2020-06-24 19:09:18 +0200 | [diff] [blame] | 306 | &efi_global_variable_guid, |
| 307 | 0, 0, NULL, false); |
AKASHI Takahiro | 37279ad | 2019-03-20 09:07:55 +0900 | [diff] [blame] | 308 | |
| 309 | /* load BootNext */ |
| 310 | if (ret == EFI_SUCCESS) { |
| 311 | if (size == sizeof(u16)) { |
Heinrich Schuchardt | 0ad6400 | 2020-08-07 17:49:39 +0200 | [diff] [blame] | 312 | ret = try_load_entry(bootnext, handle, |
| 313 | load_options); |
AKASHI Takahiro | 6b95b38 | 2019-04-19 12:22:35 +0900 | [diff] [blame] | 314 | if (ret == EFI_SUCCESS) |
| 315 | return ret; |
Heinrich Schuchardt | 7a373e5 | 2020-05-31 10:07:31 +0200 | [diff] [blame] | 316 | log_warning( |
| 317 | "Loading from BootNext failed, falling back to BootOrder\n"); |
AKASHI Takahiro | 37279ad | 2019-03-20 09:07:55 +0900 | [diff] [blame] | 318 | } |
| 319 | } else { |
Heinrich Schuchardt | 7a373e5 | 2020-05-31 10:07:31 +0200 | [diff] [blame] | 320 | log_err("Deleting BootNext failed\n"); |
AKASHI Takahiro | 37279ad | 2019-03-20 09:07:55 +0900 | [diff] [blame] | 321 | } |
| 322 | } |
| 323 | |
| 324 | /* BootOrder */ |
Simon Glass | 156ccbc | 2022-01-23 12:55:12 -0700 | [diff] [blame] | 325 | bootorder = efi_get_var(u"BootOrder", &efi_global_variable_guid, &size); |
Heinrich Schuchardt | 33e4497 | 2019-02-24 04:44:48 +0100 | [diff] [blame] | 326 | if (!bootorder) { |
Heinrich Schuchardt | 7a373e5 | 2020-05-31 10:07:31 +0200 | [diff] [blame] | 327 | log_info("BootOrder not defined\n"); |
AKASHI Takahiro | 6b95b38 | 2019-04-19 12:22:35 +0900 | [diff] [blame] | 328 | ret = EFI_NOT_FOUND; |
Rob Clark | 9975fe9 | 2017-09-13 18:05:38 -0400 | [diff] [blame] | 329 | goto error; |
Heinrich Schuchardt | 33e4497 | 2019-02-24 04:44:48 +0100 | [diff] [blame] | 330 | } |
Rob Clark | 9975fe9 | 2017-09-13 18:05:38 -0400 | [diff] [blame] | 331 | |
| 332 | num = size / sizeof(uint16_t); |
| 333 | for (i = 0; i < num; i++) { |
Heinrich Schuchardt | 7ea79e5 | 2022-04-29 07:15:04 +0200 | [diff] [blame] | 334 | log_debug("trying to load Boot%04X\n", bootorder[i]); |
Heinrich Schuchardt | 0ad6400 | 2020-08-07 17:49:39 +0200 | [diff] [blame] | 335 | ret = try_load_entry(bootorder[i], handle, load_options); |
AKASHI Takahiro | 6b95b38 | 2019-04-19 12:22:35 +0900 | [diff] [blame] | 336 | if (ret == EFI_SUCCESS) |
Rob Clark | 9975fe9 | 2017-09-13 18:05:38 -0400 | [diff] [blame] | 337 | break; |
| 338 | } |
| 339 | |
| 340 | free(bootorder); |
| 341 | |
| 342 | error: |
AKASHI Takahiro | 6b95b38 | 2019-04-19 12:22:35 +0900 | [diff] [blame] | 343 | return ret; |
Rob Clark | 9975fe9 | 2017-09-13 18:05:38 -0400 | [diff] [blame] | 344 | } |