1 | /** @file
|
---|
2 | Provide Boot Manager related library APIs.
|
---|
3 |
|
---|
4 | Copyright (c) 2011 - 2019, Intel Corporation. All rights reserved.<BR>
|
---|
5 | (C) Copyright 2015-2016 Hewlett Packard Enterprise Development LP<BR>
|
---|
6 | SPDX-License-Identifier: BSD-2-Clause-Patent
|
---|
7 |
|
---|
8 | **/
|
---|
9 |
|
---|
10 |
|
---|
11 | #ifndef _UEFI_BOOT_MANAGER_LIB_H_
|
---|
12 | #define _UEFI_BOOT_MANAGER_LIB_H_
|
---|
13 |
|
---|
14 | #include <Protocol/DriverHealth.h>
|
---|
15 | #include <Library/SortLib.h>
|
---|
16 |
|
---|
17 | //
|
---|
18 | // Boot Manager load option library functions.
|
---|
19 | //
|
---|
20 |
|
---|
21 | //
|
---|
22 | // Load Option Type
|
---|
23 | //
|
---|
24 | typedef enum {
|
---|
25 | LoadOptionTypeDriver,
|
---|
26 | LoadOptionTypeSysPrep,
|
---|
27 | LoadOptionTypeBoot,
|
---|
28 | LoadOptionTypePlatformRecovery,
|
---|
29 | LoadOptionTypeMax
|
---|
30 | } EFI_BOOT_MANAGER_LOAD_OPTION_TYPE;
|
---|
31 |
|
---|
32 | typedef enum {
|
---|
33 | LoadOptionNumberMax = 0x10000,
|
---|
34 | LoadOptionNumberUnassigned = LoadOptionNumberMax
|
---|
35 | } EFI_BOOT_MANAGER_LOAD_OPTION_NUMBER;
|
---|
36 |
|
---|
37 | //
|
---|
38 | // Common structure definition for DriverOption and BootOption
|
---|
39 | //
|
---|
40 | typedef struct {
|
---|
41 | //
|
---|
42 | // Data read from UEFI NV variables
|
---|
43 | //
|
---|
44 | UINTN OptionNumber; // #### numerical value, could be LoadOptionNumberUnassigned
|
---|
45 | EFI_BOOT_MANAGER_LOAD_OPTION_TYPE OptionType; // LoadOptionTypeBoot or LoadOptionTypeDriver
|
---|
46 | UINT32 Attributes; // Load Option Attributes
|
---|
47 | CHAR16 *Description; // Load Option Description
|
---|
48 | EFI_DEVICE_PATH_PROTOCOL *FilePath; // Load Option Device Path
|
---|
49 | UINT8 *OptionalData; // Load Option optional data to pass into image
|
---|
50 | UINT32 OptionalDataSize; // Load Option size of OptionalData
|
---|
51 | EFI_GUID VendorGuid;
|
---|
52 |
|
---|
53 | //
|
---|
54 | // Used at runtime
|
---|
55 | //
|
---|
56 | EFI_STATUS Status; // Status returned from boot attempt gBS->StartImage ()
|
---|
57 | CHAR16 *ExitData; // Exit data returned from gBS->StartImage ()
|
---|
58 | UINTN ExitDataSize; // Size of ExitData
|
---|
59 | } EFI_BOOT_MANAGER_LOAD_OPTION;
|
---|
60 |
|
---|
61 | /**
|
---|
62 | Returns an array of load options based on the EFI variable
|
---|
63 | L"BootOrder"/L"DriverOrder" and the L"Boot####"/L"Driver####" variables impled by it.
|
---|
64 | #### is the hex value of the UINT16 in each BootOrder/DriverOrder entry.
|
---|
65 |
|
---|
66 | @param LoadOptionCount Returns number of entries in the array.
|
---|
67 | @param LoadOptionType The type of the load option.
|
---|
68 |
|
---|
69 | @retval NULL No load options exist.
|
---|
70 | @retval !NULL Array of load option entries.
|
---|
71 |
|
---|
72 | **/
|
---|
73 | EFI_BOOT_MANAGER_LOAD_OPTION *
|
---|
74 | EFIAPI
|
---|
75 | EfiBootManagerGetLoadOptions (
|
---|
76 | OUT UINTN *LoadOptionCount,
|
---|
77 | IN EFI_BOOT_MANAGER_LOAD_OPTION_TYPE LoadOptionType
|
---|
78 | );
|
---|
79 |
|
---|
80 | /**
|
---|
81 | Free an array of load options returned from EfiBootManagerGetLoadOptions().
|
---|
82 |
|
---|
83 | @param LoadOptions Pointer to the array of load options to free.
|
---|
84 | @param LoadOptionCount Number of array entries in LoadOptions.
|
---|
85 |
|
---|
86 | @return EFI_SUCCESS LoadOptions was freed.
|
---|
87 | @return EFI_INVALID_PARAMETER LoadOptions is NULL.
|
---|
88 | **/
|
---|
89 | EFI_STATUS
|
---|
90 | EFIAPI
|
---|
91 | EfiBootManagerFreeLoadOptions (
|
---|
92 | IN EFI_BOOT_MANAGER_LOAD_OPTION *LoadOptions,
|
---|
93 | IN UINTN LoadOptionCount
|
---|
94 | );
|
---|
95 |
|
---|
96 | /**
|
---|
97 | Initialize a load option.
|
---|
98 |
|
---|
99 | @param Option Pointer to the load option to be initialized.
|
---|
100 | @param OptionNumber Option number of the load option.
|
---|
101 | @param OptionType Type of the load option.
|
---|
102 | @param Attributes Attributes of the load option.
|
---|
103 | @param Description Description of the load option.
|
---|
104 | @param FilePath Device path of the load option.
|
---|
105 | @param OptionalData Optional data of the load option.
|
---|
106 | @param OptionalDataSize Size of the optional data of the load option.
|
---|
107 |
|
---|
108 | @retval EFI_SUCCESS The load option was initialized successfully.
|
---|
109 | @retval EFI_INVALID_PARAMETER Option, Description or FilePath is NULL.
|
---|
110 | **/
|
---|
111 | EFI_STATUS
|
---|
112 | EFIAPI
|
---|
113 | EfiBootManagerInitializeLoadOption (
|
---|
114 | IN OUT EFI_BOOT_MANAGER_LOAD_OPTION *Option,
|
---|
115 | IN UINTN OptionNumber,
|
---|
116 | IN EFI_BOOT_MANAGER_LOAD_OPTION_TYPE OptionType,
|
---|
117 | IN UINT32 Attributes,
|
---|
118 | IN CHAR16 *Description,
|
---|
119 | IN EFI_DEVICE_PATH_PROTOCOL *FilePath,
|
---|
120 | IN UINT8 *OptionalData,
|
---|
121 | IN UINT32 OptionalDataSize
|
---|
122 | );
|
---|
123 |
|
---|
124 | /**
|
---|
125 | Free a load option created by EfiBootManagerInitializeLoadOption()
|
---|
126 | or EfiBootManagerVariableToLoadOption().
|
---|
127 |
|
---|
128 | @param LoadOption Pointer to the load option to free.
|
---|
129 | CONCERN: Check Boot#### instead of BootOrder, optimize, spec clarify
|
---|
130 | @return EFI_SUCCESS LoadOption was freed.
|
---|
131 | @return EFI_INVALID_PARAMETER LoadOption is NULL.
|
---|
132 |
|
---|
133 | **/
|
---|
134 | EFI_STATUS
|
---|
135 | EFIAPI
|
---|
136 | EfiBootManagerFreeLoadOption (
|
---|
137 | IN EFI_BOOT_MANAGER_LOAD_OPTION *LoadOption
|
---|
138 | );
|
---|
139 |
|
---|
140 | /**
|
---|
141 | Initialize the load option from the VariableName.
|
---|
142 |
|
---|
143 | @param VariableName EFI Variable name which could be Boot#### or
|
---|
144 | Driver####
|
---|
145 | @param LoadOption Pointer to the load option to be initialized
|
---|
146 |
|
---|
147 | @retval EFI_SUCCESS The option was created
|
---|
148 | @retval EFI_INVALID_PARAMETER VariableName or LoadOption is NULL.
|
---|
149 | @retval EFI_NOT_FOUND The variable specified by VariableName cannot be found.
|
---|
150 | **/
|
---|
151 | EFI_STATUS
|
---|
152 | EFIAPI
|
---|
153 | EfiBootManagerVariableToLoadOption (
|
---|
154 | IN CHAR16 *VariableName,
|
---|
155 | IN OUT EFI_BOOT_MANAGER_LOAD_OPTION *LoadOption
|
---|
156 | );
|
---|
157 |
|
---|
158 | /**
|
---|
159 | Create the Boot#### or Driver#### variable from the load option.
|
---|
160 |
|
---|
161 | @param LoadOption Pointer to the load option.
|
---|
162 |
|
---|
163 | @retval EFI_SUCCESS The variable was created.
|
---|
164 | @retval Others Error status returned by RT->SetVariable.
|
---|
165 | **/
|
---|
166 | EFI_STATUS
|
---|
167 | EFIAPI
|
---|
168 | EfiBootManagerLoadOptionToVariable (
|
---|
169 | IN CONST EFI_BOOT_MANAGER_LOAD_OPTION *LoadOption
|
---|
170 | );
|
---|
171 |
|
---|
172 | /**
|
---|
173 | This function will register the new Boot####, Driver#### or SysPrep#### option.
|
---|
174 | After the *#### is updated, the *Order will also be updated.
|
---|
175 |
|
---|
176 | @param Option Pointer to load option to add. If on input
|
---|
177 | Option->OptionNumber is LoadOptionNumberUnassigned,
|
---|
178 | then on output Option->OptionNumber is updated to
|
---|
179 | the number of the new Boot####,
|
---|
180 | Driver#### or SysPrep#### option.
|
---|
181 | @param Position Position of the new load option to put in the ****Order variable.
|
---|
182 |
|
---|
183 | @retval EFI_SUCCESS The *#### have been successfully registered.
|
---|
184 | @retval EFI_INVALID_PARAMETER The option number exceeds 0xFFFF.
|
---|
185 | @retval EFI_ALREADY_STARTED The option number of Option is being used already.
|
---|
186 | Note: this API only adds new load option, no replacement support.
|
---|
187 | @retval EFI_OUT_OF_RESOURCES There is no free option number that can be used when the
|
---|
188 | option number specified in the Option is LoadOptionNumberUnassigned.
|
---|
189 | @return Status codes of gRT->SetVariable ().
|
---|
190 |
|
---|
191 | **/
|
---|
192 | EFI_STATUS
|
---|
193 | EFIAPI
|
---|
194 | EfiBootManagerAddLoadOptionVariable (
|
---|
195 | IN OUT EFI_BOOT_MANAGER_LOAD_OPTION *Option,
|
---|
196 | IN UINTN Position
|
---|
197 | );
|
---|
198 |
|
---|
199 | /**
|
---|
200 | Delete the load option according to the OptionNumber and OptionType.
|
---|
201 |
|
---|
202 | Only the BootOrder/DriverOrder is updated to remove the reference of the OptionNumber.
|
---|
203 |
|
---|
204 | @param OptionNumber Option number of the load option.
|
---|
205 | @param OptionType Type of the load option.
|
---|
206 |
|
---|
207 | @retval EFI_NOT_FOUND The load option cannot be found.
|
---|
208 | @retval EFI_SUCCESS The load option was deleted.
|
---|
209 | **/
|
---|
210 | EFI_STATUS
|
---|
211 | EFIAPI
|
---|
212 | EfiBootManagerDeleteLoadOptionVariable (
|
---|
213 | IN UINTN OptionNumber,
|
---|
214 | IN EFI_BOOT_MANAGER_LOAD_OPTION_TYPE OptionType
|
---|
215 | );
|
---|
216 |
|
---|
217 | /**
|
---|
218 | Sort the load options. The DriverOrder/BootOrder variables will be re-created to
|
---|
219 | reflect the new order.
|
---|
220 |
|
---|
221 | @param OptionType The type of the load option.
|
---|
222 | @param CompareFunction The comparator function pointer.
|
---|
223 | **/
|
---|
224 | VOID
|
---|
225 | EFIAPI
|
---|
226 | EfiBootManagerSortLoadOptionVariable (
|
---|
227 | IN EFI_BOOT_MANAGER_LOAD_OPTION_TYPE OptionType,
|
---|
228 | IN SORT_COMPARE CompareFunction
|
---|
229 | );
|
---|
230 |
|
---|
231 | /**
|
---|
232 | Return the index of the load option in the load option array.
|
---|
233 |
|
---|
234 | The function consider two load options are equal when the
|
---|
235 | OptionType, Attributes, Description, FilePath and OptionalData are equal.
|
---|
236 |
|
---|
237 | @param Key Pointer to the load option to be found.
|
---|
238 | @param Array Pointer to the array of load options to be found.
|
---|
239 | @param Count Number of entries in the Array.
|
---|
240 |
|
---|
241 | @retval -1 Key wasn't found in the Array.
|
---|
242 | @retval 0 ~ Count-1 The index of the Key in the Array.
|
---|
243 | **/
|
---|
244 | INTN
|
---|
245 | EFIAPI
|
---|
246 | EfiBootManagerFindLoadOption (
|
---|
247 | IN CONST EFI_BOOT_MANAGER_LOAD_OPTION *Key,
|
---|
248 | IN CONST EFI_BOOT_MANAGER_LOAD_OPTION *Array,
|
---|
249 | IN UINTN Count
|
---|
250 | );
|
---|
251 |
|
---|
252 | //
|
---|
253 | // Boot Manager hot key library functions.
|
---|
254 | //
|
---|
255 |
|
---|
256 | #pragma pack(1)
|
---|
257 | ///
|
---|
258 | /// EFI Key Option.
|
---|
259 | ///
|
---|
260 | typedef struct {
|
---|
261 | ///
|
---|
262 | /// Specifies options about how the key will be processed.
|
---|
263 | ///
|
---|
264 | EFI_BOOT_KEY_DATA KeyData;
|
---|
265 | ///
|
---|
266 | /// The CRC-32 which should match the CRC-32 of the entire EFI_LOAD_OPTION to
|
---|
267 | /// which BootOption refers. If the CRC-32s do not match this value, then this key
|
---|
268 | /// option is ignored.
|
---|
269 | ///
|
---|
270 | UINT32 BootOptionCrc;
|
---|
271 | ///
|
---|
272 | /// The Boot#### option which will be invoked if this key is pressed and the boot option
|
---|
273 | /// is active (LOAD_OPTION_ACTIVE is set).
|
---|
274 | ///
|
---|
275 | UINT16 BootOption;
|
---|
276 | ///
|
---|
277 | /// The key codes to compare against those returned by the
|
---|
278 | /// EFI_SIMPLE_TEXT_INPUT and EFI_SIMPLE_TEXT_INPUT_EX protocols.
|
---|
279 | /// The number of key codes (0-3) is specified by the EFI_KEY_CODE_COUNT field in KeyOptions.
|
---|
280 | ///
|
---|
281 | EFI_INPUT_KEY Keys[3];
|
---|
282 | UINT16 OptionNumber;
|
---|
283 | } EFI_BOOT_MANAGER_KEY_OPTION;
|
---|
284 | #pragma pack()
|
---|
285 |
|
---|
286 | /**
|
---|
287 | Start the hot key service so that the key press can trigger the boot option.
|
---|
288 |
|
---|
289 | @param HotkeyTriggered Return the waitable event and it will be signaled
|
---|
290 | when a valid hot key is pressed.
|
---|
291 |
|
---|
292 | @retval EFI_SUCCESS The hot key service is started.
|
---|
293 | **/
|
---|
294 | EFI_STATUS
|
---|
295 | EFIAPI
|
---|
296 | EfiBootManagerStartHotkeyService (
|
---|
297 | IN EFI_EVENT *HotkeyTriggered
|
---|
298 | );
|
---|
299 |
|
---|
300 | //
|
---|
301 | // Modifier for EfiBootManagerAddKeyOptionVariable and EfiBootManagerDeleteKeyOptionVariable
|
---|
302 | //
|
---|
303 | #define EFI_BOOT_MANAGER_SHIFT_PRESSED 0x00000001
|
---|
304 | #define EFI_BOOT_MANAGER_CONTROL_PRESSED 0x00000002
|
---|
305 | #define EFI_BOOT_MANAGER_ALT_PRESSED 0x00000004
|
---|
306 | #define EFI_BOOT_MANAGER_LOGO_PRESSED 0x00000008
|
---|
307 | #define EFI_BOOT_MANAGER_MENU_KEY_PRESSED 0x00000010
|
---|
308 | #define EFI_BOOT_MANAGER_SYS_REQ_PRESSED 0x00000020
|
---|
309 |
|
---|
310 | /**
|
---|
311 | Add the key option.
|
---|
312 | It adds the key option variable and the key option takes affect immediately.
|
---|
313 |
|
---|
314 | @param AddedOption Return the added key option.
|
---|
315 | @param BootOptionNumber The boot option number for the key option.
|
---|
316 | @param Modifier Key shift state.
|
---|
317 | @param ... Parameter list of pointer of EFI_INPUT_KEY.
|
---|
318 |
|
---|
319 | @retval EFI_SUCCESS The key option is added.
|
---|
320 | @retval EFI_ALREADY_STARTED The hot key is already used by certain key option.
|
---|
321 | **/
|
---|
322 | EFI_STATUS
|
---|
323 | EFIAPI
|
---|
324 | EfiBootManagerAddKeyOptionVariable (
|
---|
325 | OUT EFI_BOOT_MANAGER_KEY_OPTION *AddedOption, OPTIONAL
|
---|
326 | IN UINT16 BootOptionNumber,
|
---|
327 | IN UINT32 Modifier,
|
---|
328 | ...
|
---|
329 | );
|
---|
330 |
|
---|
331 | /**
|
---|
332 | Delete the Key Option variable and unregister the hot key
|
---|
333 |
|
---|
334 | @param DeletedOption Return the deleted key options.
|
---|
335 | @param Modifier Key shift state.
|
---|
336 | @param ... Parameter list of pointer of EFI_INPUT_KEY.
|
---|
337 |
|
---|
338 | @retval EFI_SUCCESS The key option is deleted.
|
---|
339 | @retval EFI_NOT_FOUND The key option cannot be found.
|
---|
340 | **/
|
---|
341 | EFI_STATUS
|
---|
342 | EFIAPI
|
---|
343 | EfiBootManagerDeleteKeyOptionVariable (
|
---|
344 | IN EFI_BOOT_MANAGER_KEY_OPTION *DeletedOption, OPTIONAL
|
---|
345 | IN UINT32 Modifier,
|
---|
346 | ...
|
---|
347 | );
|
---|
348 |
|
---|
349 | /**
|
---|
350 | Register the key option to exit the waiting of the Boot Manager timeout.
|
---|
351 | Platform should ensure that the continue key option isn't conflict with
|
---|
352 | other boot key options.
|
---|
353 |
|
---|
354 | @param Modifier Key shift state.
|
---|
355 | @param ... Parameter list of pointer of EFI_INPUT_KEY.
|
---|
356 |
|
---|
357 | @retval EFI_SUCCESS Successfully register the continue key option.
|
---|
358 | @retval EFI_ALREADY_STARTED The continue key option is already registered.
|
---|
359 | **/
|
---|
360 | EFI_STATUS
|
---|
361 | EFIAPI
|
---|
362 | EfiBootManagerRegisterContinueKeyOption (
|
---|
363 | IN UINT32 Modifier,
|
---|
364 | ...
|
---|
365 | );
|
---|
366 |
|
---|
367 | /**
|
---|
368 | Try to boot the boot option triggered by hot key.
|
---|
369 | **/
|
---|
370 | VOID
|
---|
371 | EFIAPI
|
---|
372 | EfiBootManagerHotkeyBoot (
|
---|
373 | VOID
|
---|
374 | );
|
---|
375 | //
|
---|
376 | // Boot Manager boot library functions.
|
---|
377 | //
|
---|
378 |
|
---|
379 | /**
|
---|
380 | The function creates boot options for all possible bootable medias in the following order:
|
---|
381 | 1. Removable BlockIo - The boot option only points to the removable media
|
---|
382 | device, like USB key, DVD, Floppy etc.
|
---|
383 | 2. Fixed BlockIo - The boot option only points to a Fixed blockIo device,
|
---|
384 | like HardDisk.
|
---|
385 | 3. Non-BlockIo SimpleFileSystem - The boot option points to a device supporting
|
---|
386 | SimpleFileSystem Protocol, but not supporting BlockIo
|
---|
387 | protocol.
|
---|
388 | 4. LoadFile - The boot option points to the media supporting
|
---|
389 | LoadFile protocol.
|
---|
390 | Reference: UEFI Spec chapter 3.3 Boot Option Variables Default Boot Behavior
|
---|
391 |
|
---|
392 | The function won't delete the boot option not added by itself.
|
---|
393 | **/
|
---|
394 | VOID
|
---|
395 | EFIAPI
|
---|
396 | EfiBootManagerRefreshAllBootOption (
|
---|
397 | VOID
|
---|
398 | );
|
---|
399 |
|
---|
400 | /**
|
---|
401 | Attempt to boot the EFI boot option. This routine sets L"BootCurent" and
|
---|
402 | signals the EFI ready to boot event. If the device path for the option starts
|
---|
403 | with a BBS device path a legacy boot is attempted. Short form device paths are
|
---|
404 | also supported via this rountine. A device path starting with
|
---|
405 | MEDIA_HARDDRIVE_DP, MSG_USB_WWID_DP, MSG_USB_CLASS_DP gets expaned out
|
---|
406 | to find the first device that matches. If the BootOption Device Path
|
---|
407 | fails the removable media boot algorithm is attempted (\EFI\BOOTIA32.EFI,
|
---|
408 | \EFI\BOOTX64.EFI,... only one file type is tried per processor type)
|
---|
409 |
|
---|
410 | @param BootOption Boot Option to try and boot.
|
---|
411 | On return, BootOption->Status contains the boot status:
|
---|
412 | EFI_SUCCESS BootOption was booted
|
---|
413 | EFI_UNSUPPORTED BootOption isn't supported.
|
---|
414 | EFI_NOT_FOUND The BootOption was not found on the system
|
---|
415 | Others BootOption failed with this error status
|
---|
416 |
|
---|
417 | **/
|
---|
418 | VOID
|
---|
419 | EFIAPI
|
---|
420 | EfiBootManagerBoot (
|
---|
421 | IN EFI_BOOT_MANAGER_LOAD_OPTION *BootOption
|
---|
422 | );
|
---|
423 |
|
---|
424 | /**
|
---|
425 | Return the boot option corresponding to the Boot Manager Menu.
|
---|
426 | It may automatically create one if the boot option hasn't been created yet.
|
---|
427 |
|
---|
428 | @param BootOption Return the Boot Manager Menu.
|
---|
429 |
|
---|
430 | @retval EFI_SUCCESS The Boot Manager Menu is successfully returned.
|
---|
431 | @retval EFI_NOT_FOUND The Boot Manager Menu cannot be found.
|
---|
432 | @retval others Return status of gRT->SetVariable (). BootOption still points
|
---|
433 | to the Boot Manager Menu even the Status is not EFI_SUCCESS
|
---|
434 | and EFI_NOT_FOUND.
|
---|
435 | **/
|
---|
436 | EFI_STATUS
|
---|
437 | EFIAPI
|
---|
438 | EfiBootManagerGetBootManagerMenu (
|
---|
439 | EFI_BOOT_MANAGER_LOAD_OPTION *BootOption
|
---|
440 | );
|
---|
441 |
|
---|
442 | /**
|
---|
443 | Get the next possible full path pointing to the load option.
|
---|
444 | The routine doesn't guarantee the returned full path points to an existing
|
---|
445 | file, and it also doesn't guarantee the existing file is a valid load option.
|
---|
446 | BmGetNextLoadOptionBuffer() guarantees.
|
---|
447 |
|
---|
448 | @param FilePath The device path pointing to a load option.
|
---|
449 | It could be a short-form device path.
|
---|
450 | @param FullPath The full path returned by the routine in last call.
|
---|
451 | Set to NULL in first call.
|
---|
452 |
|
---|
453 | @return The next possible full path pointing to the load option.
|
---|
454 | Caller is responsible to free the memory.
|
---|
455 | **/
|
---|
456 | EFI_DEVICE_PATH_PROTOCOL *
|
---|
457 | EFIAPI
|
---|
458 | EfiBootManagerGetNextLoadOptionDevicePath (
|
---|
459 | IN EFI_DEVICE_PATH_PROTOCOL *FilePath,
|
---|
460 | IN EFI_DEVICE_PATH_PROTOCOL *FullPath
|
---|
461 | );
|
---|
462 |
|
---|
463 | /**
|
---|
464 | Get the load option by its device path.
|
---|
465 |
|
---|
466 | @param FilePath The device path pointing to a load option.
|
---|
467 | It could be a short-form device path.
|
---|
468 | @param FullPath Return the full device path of the load option after
|
---|
469 | short-form device path expanding.
|
---|
470 | Caller is responsible to free it.
|
---|
471 | @param FileSize Return the load option size.
|
---|
472 |
|
---|
473 | @return The load option buffer. Caller is responsible to free the memory.
|
---|
474 | **/
|
---|
475 | VOID *
|
---|
476 | EFIAPI
|
---|
477 | EfiBootManagerGetLoadOptionBuffer (
|
---|
478 | IN EFI_DEVICE_PATH_PROTOCOL *FilePath,
|
---|
479 | OUT EFI_DEVICE_PATH_PROTOCOL **FullPath,
|
---|
480 | OUT UINTN *FileSize
|
---|
481 | );
|
---|
482 |
|
---|
483 | /**
|
---|
484 | The function enumerates all the legacy boot options, creates them and
|
---|
485 | registers them in the BootOrder variable.
|
---|
486 | **/
|
---|
487 | typedef
|
---|
488 | VOID
|
---|
489 | (EFIAPI *EFI_BOOT_MANAGER_REFRESH_LEGACY_BOOT_OPTION) (
|
---|
490 | VOID
|
---|
491 | );
|
---|
492 |
|
---|
493 | /**
|
---|
494 | The function boots a legacy boot option.
|
---|
495 | **/
|
---|
496 | typedef
|
---|
497 | VOID
|
---|
498 | (EFIAPI *EFI_BOOT_MANAGER_LEGACY_BOOT) (
|
---|
499 | IN EFI_BOOT_MANAGER_LOAD_OPTION *BootOption
|
---|
500 | );
|
---|
501 |
|
---|
502 | /**
|
---|
503 | The function registers the legacy boot support capabilities.
|
---|
504 |
|
---|
505 | @param RefreshLegacyBootOption The function pointer to create all the legacy boot options.
|
---|
506 | @param LegacyBoot The function pointer to boot the legacy boot option.
|
---|
507 | **/
|
---|
508 | VOID
|
---|
509 | EFIAPI
|
---|
510 | EfiBootManagerRegisterLegacyBootSupport (
|
---|
511 | EFI_BOOT_MANAGER_REFRESH_LEGACY_BOOT_OPTION RefreshLegacyBootOption,
|
---|
512 | EFI_BOOT_MANAGER_LEGACY_BOOT LegacyBoot
|
---|
513 | );
|
---|
514 |
|
---|
515 | /**
|
---|
516 | Return the platform provided boot option description for the controller.
|
---|
517 |
|
---|
518 | @param Handle Controller handle.
|
---|
519 | @param DefaultDescription Default boot description provided by core.
|
---|
520 |
|
---|
521 | @return The callee allocated description string
|
---|
522 | or NULL if the handler wants to use DefaultDescription.
|
---|
523 | **/
|
---|
524 | typedef
|
---|
525 | CHAR16 *
|
---|
526 | (EFIAPI *EFI_BOOT_MANAGER_BOOT_DESCRIPTION_HANDLER) (
|
---|
527 | IN EFI_HANDLE Handle,
|
---|
528 | IN CONST CHAR16 *DefaultDescription
|
---|
529 | );
|
---|
530 |
|
---|
531 | /**
|
---|
532 | Register the platform provided boot description handler.
|
---|
533 |
|
---|
534 | @param Handler The platform provided boot description handler
|
---|
535 |
|
---|
536 | @retval EFI_SUCCESS The handler was registered successfully.
|
---|
537 | @retval EFI_ALREADY_STARTED The handler was already registered.
|
---|
538 | @retval EFI_OUT_OF_RESOURCES There is not enough resource to perform the registration.
|
---|
539 | **/
|
---|
540 | EFI_STATUS
|
---|
541 | EFIAPI
|
---|
542 | EfiBootManagerRegisterBootDescriptionHandler (
|
---|
543 | IN EFI_BOOT_MANAGER_BOOT_DESCRIPTION_HANDLER Handler
|
---|
544 | );
|
---|
545 |
|
---|
546 | //
|
---|
547 | // Boot Manager connect and disconnect library functions
|
---|
548 | //
|
---|
549 |
|
---|
550 | /**
|
---|
551 | This function will connect all the system driver to controller
|
---|
552 | first, and then special connect the default console, this make
|
---|
553 | sure all the system controller available and the platform default
|
---|
554 | console connected.
|
---|
555 | **/
|
---|
556 | VOID
|
---|
557 | EFIAPI
|
---|
558 | EfiBootManagerConnectAll (
|
---|
559 | VOID
|
---|
560 | );
|
---|
561 |
|
---|
562 | /**
|
---|
563 | This function will create all handles associate with every device
|
---|
564 | path node. If the handle associate with one device path node can not
|
---|
565 | be created successfully, then still give chance to do the dispatch,
|
---|
566 | which load the missing drivers if possible.
|
---|
567 |
|
---|
568 | @param DevicePathToConnect The device path which will be connected, it can be
|
---|
569 | a multi-instance device path
|
---|
570 | @param MatchingHandle Return the controller handle closest to the DevicePathToConnect
|
---|
571 |
|
---|
572 | @retval EFI_SUCCESS All handles associate with every device path node
|
---|
573 | have been created.
|
---|
574 | @retval EFI_OUT_OF_RESOURCES There is no resource to create new handles.
|
---|
575 | @retval EFI_NOT_FOUND Create the handle associate with one device path
|
---|
576 | node failed.
|
---|
577 | @retval EFI_SECURITY_VIOLATION The user has no permission to start UEFI device
|
---|
578 | drivers on the DevicePath.
|
---|
579 | **/
|
---|
580 | EFI_STATUS
|
---|
581 | EFIAPI
|
---|
582 | EfiBootManagerConnectDevicePath (
|
---|
583 | IN EFI_DEVICE_PATH_PROTOCOL *DevicePathToConnect,
|
---|
584 | OUT EFI_HANDLE *MatchingHandle OPTIONAL
|
---|
585 | );
|
---|
586 |
|
---|
587 | /**
|
---|
588 | This function will disconnect all current system handles.
|
---|
589 |
|
---|
590 | gBS->DisconnectController() is invoked for each handle exists in system handle buffer.
|
---|
591 | If handle is a bus type handle, all childrens also are disconnected recursively by
|
---|
592 | gBS->DisconnectController().
|
---|
593 | **/
|
---|
594 | VOID
|
---|
595 | EFIAPI
|
---|
596 | EfiBootManagerDisconnectAll (
|
---|
597 | VOID
|
---|
598 | );
|
---|
599 |
|
---|
600 |
|
---|
601 | //
|
---|
602 | // Boot Manager console library functions
|
---|
603 | //
|
---|
604 |
|
---|
605 | typedef enum {
|
---|
606 | ConIn,
|
---|
607 | ConOut,
|
---|
608 | ErrOut,
|
---|
609 | ConInDev,
|
---|
610 | ConOutDev,
|
---|
611 | ErrOutDev,
|
---|
612 | ConsoleTypeMax
|
---|
613 | } CONSOLE_TYPE;
|
---|
614 |
|
---|
615 | /**
|
---|
616 | This function will connect all the console devices base on the console
|
---|
617 | device variable ConIn, ConOut and ErrOut.
|
---|
618 |
|
---|
619 | @retval EFI_DEVICE_ERROR All the consoles were not connected due to an error.
|
---|
620 | @retval EFI_SUCCESS Success connect any one instance of the console
|
---|
621 | device path base on the variable ConVarName.
|
---|
622 | **/
|
---|
623 | EFI_STATUS
|
---|
624 | EFIAPI
|
---|
625 | EfiBootManagerConnectAllDefaultConsoles (
|
---|
626 | VOID
|
---|
627 | );
|
---|
628 |
|
---|
629 | /**
|
---|
630 | This function updates the console variable based on ConVarName. It can
|
---|
631 | add or remove one specific console device path from the variable
|
---|
632 |
|
---|
633 | @param ConsoleType ConIn, ConOut, ErrOut, ConInDev, ConOutDev or ErrOutDev.
|
---|
634 | @param CustomizedConDevicePath The console device path to be added to
|
---|
635 | the console variable. Cannot be multi-instance.
|
---|
636 | @param ExclusiveDevicePath The console device path to be removed
|
---|
637 | from the console variable. Cannot be multi-instance.
|
---|
638 |
|
---|
639 | @retval EFI_UNSUPPORTED The added device path is the same as a removed one.
|
---|
640 | @retval EFI_SUCCESS Successfully added or removed the device path from the
|
---|
641 | console variable.
|
---|
642 |
|
---|
643 | **/
|
---|
644 | EFI_STATUS
|
---|
645 | EFIAPI
|
---|
646 | EfiBootManagerUpdateConsoleVariable (
|
---|
647 | IN CONSOLE_TYPE ConsoleType,
|
---|
648 | IN EFI_DEVICE_PATH_PROTOCOL *CustomizedConDevicePath,
|
---|
649 | IN EFI_DEVICE_PATH_PROTOCOL *ExclusiveDevicePath
|
---|
650 | );
|
---|
651 |
|
---|
652 | /**
|
---|
653 | Connect the console device base on the variable ConVarName, if
|
---|
654 | device path of the ConVarName is multi-instance device path, if
|
---|
655 | anyone of the instances is connected success, then this function
|
---|
656 | will return success.
|
---|
657 |
|
---|
658 | @param ConsoleType ConIn, ConOut or ErrOut.
|
---|
659 |
|
---|
660 | @retval EFI_NOT_FOUND There is not any console devices connected
|
---|
661 | success
|
---|
662 | @retval EFI_SUCCESS Success connect any one instance of the console
|
---|
663 | device path base on the variable ConVarName.
|
---|
664 |
|
---|
665 | **/
|
---|
666 | EFI_STATUS
|
---|
667 | EFIAPI
|
---|
668 | EfiBootManagerConnectConsoleVariable (
|
---|
669 | IN CONSOLE_TYPE ConsoleType
|
---|
670 | );
|
---|
671 |
|
---|
672 | /**
|
---|
673 | Query all the children of VideoController and return the device paths of all the
|
---|
674 | children that support GraphicsOutput protocol.
|
---|
675 |
|
---|
676 | @param VideoController PCI handle of video controller.
|
---|
677 |
|
---|
678 | @return Device paths of all the children that support GraphicsOutput protocol.
|
---|
679 | **/
|
---|
680 | EFI_DEVICE_PATH_PROTOCOL *
|
---|
681 | EFIAPI
|
---|
682 | EfiBootManagerGetGopDevicePath (
|
---|
683 | IN EFI_HANDLE VideoController
|
---|
684 | );
|
---|
685 |
|
---|
686 | /**
|
---|
687 | Connect the platform active active video controller.
|
---|
688 |
|
---|
689 | @param VideoController PCI handle of video controller.
|
---|
690 |
|
---|
691 | @retval EFI_NOT_FOUND There is no active video controller.
|
---|
692 | @retval EFI_SUCCESS The video controller is connected.
|
---|
693 | **/
|
---|
694 | EFI_STATUS
|
---|
695 | EFIAPI
|
---|
696 | EfiBootManagerConnectVideoController (
|
---|
697 | EFI_HANDLE VideoController OPTIONAL
|
---|
698 | );
|
---|
699 |
|
---|
700 | //
|
---|
701 | // Boot Manager driver health library functions.
|
---|
702 | //
|
---|
703 |
|
---|
704 | typedef struct {
|
---|
705 | EFI_DRIVER_HEALTH_PROTOCOL *DriverHealth;
|
---|
706 |
|
---|
707 | ///
|
---|
708 | /// Driver relative handles
|
---|
709 | ///
|
---|
710 | EFI_HANDLE DriverHealthHandle;
|
---|
711 | EFI_HANDLE ControllerHandle;
|
---|
712 | EFI_HANDLE ChildHandle;
|
---|
713 |
|
---|
714 | ///
|
---|
715 | /// Driver health messages of the specify Driver
|
---|
716 | ///
|
---|
717 | EFI_DRIVER_HEALTH_HII_MESSAGE *MessageList;
|
---|
718 |
|
---|
719 | ///
|
---|
720 | /// HII relative handles
|
---|
721 | ///
|
---|
722 | EFI_HII_HANDLE HiiHandle;
|
---|
723 |
|
---|
724 | ///
|
---|
725 | /// Driver Health status
|
---|
726 | ///
|
---|
727 | EFI_DRIVER_HEALTH_STATUS HealthStatus;
|
---|
728 | } EFI_BOOT_MANAGER_DRIVER_HEALTH_INFO;
|
---|
729 |
|
---|
730 | /**
|
---|
731 | Return all the Driver Health information.
|
---|
732 |
|
---|
733 | When the cumulative health status of all the controllers managed by the
|
---|
734 | driver who produces the EFI_DRIVER_HEALTH_PROTOCOL is healthy, only one
|
---|
735 | EFI_BOOT_MANAGER_DRIVER_HEALTH_INFO entry is created for such
|
---|
736 | EFI_DRIVER_HEALTH_PROTOCOL instance.
|
---|
737 | Otherwise, every controller creates one EFI_BOOT_MANAGER_DRIVER_HEALTH_INFO
|
---|
738 | entry. Additionally every child controller creates one
|
---|
739 | EFI_BOOT_MANAGER_DRIVER_HEALTH_INFO entry if the driver is a bus driver.
|
---|
740 |
|
---|
741 | @param Count Return the count of the Driver Health information.
|
---|
742 |
|
---|
743 | @retval NULL No Driver Health information is returned.
|
---|
744 | @retval !NULL Pointer to the Driver Health information array.
|
---|
745 | **/
|
---|
746 | EFI_BOOT_MANAGER_DRIVER_HEALTH_INFO *
|
---|
747 | EFIAPI
|
---|
748 | EfiBootManagerGetDriverHealthInfo (
|
---|
749 | UINTN *Count
|
---|
750 | );
|
---|
751 |
|
---|
752 | /**
|
---|
753 | Free the Driver Health information array.
|
---|
754 |
|
---|
755 | @param DriverHealthInfo Pointer to array of the Driver Health information.
|
---|
756 | @param Count Count of the array.
|
---|
757 |
|
---|
758 | @retval EFI_SUCCESS The array is freed.
|
---|
759 | @retval EFI_INVALID_PARAMETER The array is NULL.
|
---|
760 | **/
|
---|
761 | EFI_STATUS
|
---|
762 | EFIAPI
|
---|
763 | EfiBootManagerFreeDriverHealthInfo (
|
---|
764 | EFI_BOOT_MANAGER_DRIVER_HEALTH_INFO *DriverHealthInfo,
|
---|
765 | UINTN Count
|
---|
766 | );
|
---|
767 |
|
---|
768 | /**
|
---|
769 | Process (load and execute) the load option.
|
---|
770 |
|
---|
771 | @param LoadOption Pointer to the load option.
|
---|
772 |
|
---|
773 | @retval EFI_INVALID_PARAMETER The load option type is invalid,
|
---|
774 | or the load option file path doesn't point to a valid file.
|
---|
775 | @retval EFI_UNSUPPORTED The load option type is of LoadOptionTypeBoot.
|
---|
776 | @retval EFI_SUCCESS The load option is inactive, or successfully loaded and executed.
|
---|
777 | **/
|
---|
778 | EFI_STATUS
|
---|
779 | EFIAPI
|
---|
780 | EfiBootManagerProcessLoadOption (
|
---|
781 | EFI_BOOT_MANAGER_LOAD_OPTION *LoadOption
|
---|
782 | );
|
---|
783 |
|
---|
784 | /**
|
---|
785 | Check whether the VariableName is a valid load option variable name
|
---|
786 | and return the load option type and option number.
|
---|
787 |
|
---|
788 | @param VariableName The name of the load option variable.
|
---|
789 | @param OptionType Return the load option type.
|
---|
790 | @param OptionNumber Return the load option number.
|
---|
791 |
|
---|
792 | @retval TRUE The variable name is valid; The load option type and
|
---|
793 | load option number are returned.
|
---|
794 | @retval FALSE The variable name is NOT valid.
|
---|
795 | **/
|
---|
796 | BOOLEAN
|
---|
797 | EFIAPI
|
---|
798 | EfiBootManagerIsValidLoadOptionVariableName (
|
---|
799 | IN CHAR16 *VariableName,
|
---|
800 | OUT EFI_BOOT_MANAGER_LOAD_OPTION_TYPE *OptionType OPTIONAL,
|
---|
801 | OUT UINT16 *OptionNumber OPTIONAL
|
---|
802 | );
|
---|
803 |
|
---|
804 |
|
---|
805 | /**
|
---|
806 | Dispatch the deferred images that are returned from all DeferredImageLoad instances.
|
---|
807 |
|
---|
808 | @retval EFI_SUCCESS At least one deferred image is loaded successfully and started.
|
---|
809 | @retval EFI_NOT_FOUND There is no deferred image.
|
---|
810 | @retval EFI_ACCESS_DENIED There are deferred images but all of them are failed to load.
|
---|
811 | **/
|
---|
812 | EFI_STATUS
|
---|
813 | EFIAPI
|
---|
814 | EfiBootManagerDispatchDeferredImages (
|
---|
815 | VOID
|
---|
816 | );
|
---|
817 | #endif
|
---|