VirtualBox

source: vbox/trunk/src/VBox/Devices/EFI/FirmwareNew/MdeModulePkg/Library/UefiBootManagerLib/InternalBm.h@ 85716

最後變更 在這個檔案從85716是 82509,由 vboxsync 提交於 5 年 前

EFI/Firmware/UefiBootManagerLib: Use the gVBoxFsBlessedFileInfoGuid information type to query the blessed file on HFS+ volumes instead of having the path hard coded

  • 屬性 svn:eol-style 設為 native
檔案大小: 15.5 KB
 
1/** @file
2 BDS library definition, include the file and data structure
3
4Copyright (c) 2004 - 2018, Intel Corporation. All rights reserved.<BR>
5(C) Copyright 2015 Hewlett Packard Enterprise Development LP<BR>
6SPDX-License-Identifier: BSD-2-Clause-Patent
7
8**/
9
10#ifndef _INTERNAL_BM_H_
11#define _INTERNAL_BM_H_
12
13#include <PiDxe.h>
14
15#include <IndustryStandard/Pci.h>
16#include <IndustryStandard/PeImage.h>
17#include <IndustryStandard/Atapi.h>
18#include <IndustryStandard/Scsi.h>
19#include <IndustryStandard/Nvme.h>
20
21#include <Protocol/PciRootBridgeIo.h>
22#include <Protocol/BlockIo.h>
23#include <Protocol/LoadedImage.h>
24#include <Protocol/SimpleFileSystem.h>
25#include <Protocol/LoadFile.h>
26#include <Protocol/DevicePath.h>
27#include <Protocol/SimpleTextIn.h>
28#include <Protocol/SimpleTextInEx.h>
29#include <Protocol/SimpleTextOut.h>
30#include <Protocol/SimpleNetwork.h>
31#include <Protocol/FirmwareVolume2.h>
32#include <Protocol/PciIo.h>
33#include <Protocol/GraphicsOutput.h>
34#include <Protocol/UsbIo.h>
35#include <Protocol/DiskInfo.h>
36#include <Protocol/NvmExpressPassthru.h>
37#include <Protocol/IdeControllerInit.h>
38#include <Protocol/BootLogo.h>
39#include <Protocol/DriverHealth.h>
40#include <Protocol/FormBrowser2.h>
41#include <Protocol/VariableLock.h>
42#include <Protocol/RamDisk.h>
43#include <Protocol/DeferredImageLoad.h>
44
45#include <Guid/MemoryTypeInformation.h>
46#include <Guid/FileInfo.h>
47#include <Guid/GlobalVariable.h>
48#include <Guid/StatusCodeDataTypeId.h>
49#include <Guid/StatusCodeDataTypeVariable.h>
50#ifdef VBOX
51#include <Guid/VBoxFsBlessedFileInfo.h>
52#endif
53
54#include <Library/PrintLib.h>
55#include <Library/DebugLib.h>
56#include <Library/BaseMemoryLib.h>
57#include <Library/UefiBootServicesTableLib.h>
58#include <Library/UefiRuntimeServicesTableLib.h>
59#include <Library/UefiLib.h>
60#include <Library/MemoryAllocationLib.h>
61#include <Library/DxeServicesTableLib.h>
62#include <Library/HobLib.h>
63#include <Library/BaseLib.h>
64#include <Library/DevicePathLib.h>
65#include <Library/PerformanceLib.h>
66#include <Library/PcdLib.h>
67#include <Library/PeCoffGetEntryPointLib.h>
68#include <Library/UefiBootManagerLib.h>
69#include <Library/DxeServicesLib.h>
70#include <Library/ReportStatusCodeLib.h>
71#include <Library/CapsuleLib.h>
72#include <Library/PerformanceLib.h>
73#include <Library/HiiLib.h>
74
75#if !defined (EFI_REMOVABLE_MEDIA_FILE_NAME)
76 #if defined (MDE_CPU_EBC)
77 //
78 // Uefi specification only defines the default boot file name for IA32, X64
79 // and IPF processor, so need define boot file name for EBC architecture here.
80 //
81 #define EFI_REMOVABLE_MEDIA_FILE_NAME L"\\EFI\\BOOT\\BOOTEBC.EFI"
82 #else
83 #error "Can not determine the default boot file name for unknown processor type!"
84 #endif
85#endif
86
87typedef enum {
88 BmAcpiFloppyBoot,
89 BmHardwareDeviceBoot,
90 BmMessageAtapiBoot,
91 BmMessageSataBoot,
92 BmMessageUsbBoot,
93 BmMessageScsiBoot,
94 BmMiscBoot
95} BM_BOOT_TYPE;
96
97typedef
98CHAR16 *
99(* BM_GET_BOOT_DESCRIPTION) (
100 IN EFI_HANDLE Handle
101 );
102
103//
104// PlatformRecovery#### is the load option with the longest name
105//
106#define BM_OPTION_NAME_LEN sizeof ("PlatformRecovery####")
107extern CHAR16 *mBmLoadOptionName[];
108
109//
110// Maximum number of reconnect retry to repair controller; it is to limit the
111// number of recursive call of BmRepairAllControllers.
112//
113#define MAX_RECONNECT_REPAIR 10
114
115/**
116 Visitor function to be called by BmForEachVariable for each variable
117 in variable storage.
118
119 @param Name Variable name.
120 @param Guid Variable GUID.
121 @param Context The same context passed to BmForEachVariable.
122**/
123typedef
124VOID
125(*BM_VARIABLE_VISITOR) (
126 CHAR16 *Name,
127 EFI_GUID *Guid,
128 VOID *Context
129 );
130
131/**
132 Call Visitor function for each variable in variable storage.
133
134 @param Visitor Visitor function.
135 @param Context The context passed to Visitor function.
136**/
137VOID
138BmForEachVariable (
139 BM_VARIABLE_VISITOR Visitor,
140 VOID *Context
141 );
142
143#define BM_BOOT_DESCRIPTION_ENTRY_SIGNATURE SIGNATURE_32 ('b', 'm', 'd', 'h')
144typedef struct {
145 UINT32 Signature;
146 LIST_ENTRY Link;
147 EFI_BOOT_MANAGER_BOOT_DESCRIPTION_HANDLER Handler;
148} BM_BOOT_DESCRIPTION_ENTRY;
149
150/**
151 Repair all the controllers according to the Driver Health status queried.
152
153 @param ReconnectRepairCount To record the number of recursive call of
154 this function itself.
155**/
156VOID
157BmRepairAllControllers (
158 UINTN ReconnectRepairCount
159 );
160
161#define BM_HOTKEY_SIGNATURE SIGNATURE_32 ('b', 'm', 'h', 'k')
162typedef struct {
163 UINT32 Signature;
164 LIST_ENTRY Link;
165
166 BOOLEAN IsContinue;
167 UINT16 BootOption;
168 UINT8 CodeCount;
169 UINT8 WaitingKey;
170 EFI_KEY_DATA KeyData[3];
171} BM_HOTKEY;
172
173#define BM_HOTKEY_FROM_LINK(a) CR (a, BM_HOTKEY, Link, BM_HOTKEY_SIGNATURE)
174
175/**
176 Get the Option Number that wasn't used.
177
178 @param LoadOptionType Load option type.
179 @param FreeOptionNumber To receive the minimal free option number.
180
181 @retval EFI_SUCCESS The option number is found
182 @retval EFI_OUT_OF_RESOURCES There is no free option number that can be used.
183 @retval EFI_INVALID_PARAMETER FreeOptionNumber is NULL
184
185**/
186EFI_STATUS
187BmGetFreeOptionNumber (
188 IN EFI_BOOT_MANAGER_LOAD_OPTION_TYPE LoadOptionType,
189 OUT UINT16 *FreeOptionNumber
190 );
191
192/**
193 This routine adjust the memory information for different memory type and
194 save them into the variables for next boot. It resets the system when
195 memory information is updated and the current boot option belongs to
196 boot category instead of application category. It doesn't count the
197 reserved memory occupied by RAM Disk.
198
199 @param Boot TRUE if current boot option belongs to boot
200 category instead of application category.
201**/
202VOID
203BmSetMemoryTypeInformationVariable (
204 IN BOOLEAN Boot
205 );
206
207/**
208 Check whether there is a instance in BlockIoDevicePath, which contain multi device path
209 instances, has the same partition node with HardDriveDevicePath device path
210
211 @param BlockIoDevicePath Multi device path instances which need to check
212 @param HardDriveDevicePath A device path which starts with a hard drive media
213 device path.
214
215 @retval TRUE There is a matched device path instance.
216 @retval FALSE There is no matched device path instance.
217
218**/
219BOOLEAN
220BmMatchPartitionDevicePathNode (
221 IN EFI_DEVICE_PATH_PROTOCOL *BlockIoDevicePath,
222 IN HARDDRIVE_DEVICE_PATH *HardDriveDevicePath
223 );
224
225/**
226 Connect the specific Usb device which match the short form device path.
227
228 @param DevicePath A short-form device path that starts with the first
229 element being a USB WWID or a USB Class device
230 path
231
232 @return EFI_INVALID_PARAMETER DevicePath is NULL pointer.
233 DevicePath is not a USB device path.
234
235 @return EFI_SUCCESS Success to connect USB device
236 @return EFI_NOT_FOUND Fail to find handle for USB controller to connect.
237
238**/
239EFI_STATUS
240BmConnectUsbShortFormDevicePath (
241 IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
242 );
243
244/**
245 Stop the hotkey processing.
246
247 @param Event Event pointer related to hotkey service.
248 @param Context Context pass to this function.
249**/
250VOID
251EFIAPI
252BmStopHotkeyService (
253 IN EFI_EVENT Event,
254 IN VOID *Context
255 );
256
257/**
258 Set the variable and report the error through status code upon failure.
259
260 @param VariableName A Null-terminated string that is the name of the vendor's variable.
261 Each VariableName is unique for each VendorGuid. VariableName must
262 contain 1 or more characters. If VariableName is an empty string,
263 then EFI_INVALID_PARAMETER is returned.
264 @param VendorGuid A unique identifier for the vendor.
265 @param Attributes Attributes bitmask to set for the variable.
266 @param DataSize The size in bytes of the Data buffer. Unless the EFI_VARIABLE_APPEND_WRITE,
267 or EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS attribute is set, a size of zero
268 causes the variable to be deleted. When the EFI_VARIABLE_APPEND_WRITE attribute is
269 set, then a SetVariable() call with a DataSize of zero will not cause any change to
270 the variable value (the timestamp associated with the variable may be updated however
271 even if no new data value is provided,see the description of the
272 EFI_VARIABLE_AUTHENTICATION_2 descriptor below. In this case the DataSize will not
273 be zero since the EFI_VARIABLE_AUTHENTICATION_2 descriptor will be populated).
274 @param Data The contents for the variable.
275
276 @retval EFI_SUCCESS The firmware has successfully stored the variable and its data as
277 defined by the Attributes.
278 @retval EFI_INVALID_PARAMETER An invalid combination of attribute bits, name, and GUID was supplied, or the
279 DataSize exceeds the maximum allowed.
280 @retval EFI_INVALID_PARAMETER VariableName is an empty string.
281 @retval EFI_OUT_OF_RESOURCES Not enough storage is available to hold the variable and its data.
282 @retval EFI_DEVICE_ERROR The variable could not be retrieved due to a hardware error.
283 @retval EFI_WRITE_PROTECTED The variable in question is read-only.
284 @retval EFI_WRITE_PROTECTED The variable in question cannot be deleted.
285 @retval EFI_SECURITY_VIOLATION The variable could not be written due to EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACESS
286 being set, but the AuthInfo does NOT pass the validation check carried out by the firmware.
287
288 @retval EFI_NOT_FOUND The variable trying to be updated or deleted was not found.
289**/
290EFI_STATUS
291BmSetVariableAndReportStatusCodeOnError (
292 IN CHAR16 *VariableName,
293 IN EFI_GUID *VendorGuid,
294 IN UINT32 Attributes,
295 IN UINTN DataSize,
296 IN VOID *Data
297 );
298
299/**
300 Function compares a device path data structure to that of all the nodes of a
301 second device path instance.
302
303 @param Multi A pointer to a multi-instance device path data
304 structure.
305 @param Single A pointer to a single-instance device path data
306 structure.
307
308 @retval TRUE If the Single device path is contained within Multi device path.
309 @retval FALSE The Single device path is not match within Multi device path.
310
311**/
312BOOLEAN
313BmMatchDevicePaths (
314 IN EFI_DEVICE_PATH_PROTOCOL *Multi,
315 IN EFI_DEVICE_PATH_PROTOCOL *Single
316 );
317
318/**
319 Delete the instance in Multi which matches partly with Single instance
320
321 @param Multi A pointer to a multi-instance device path data
322 structure.
323 @param Single A pointer to a single-instance device path data
324 structure.
325
326 @return This function will remove the device path instances in Multi which partly
327 match with the Single, and return the result device path. If there is no
328 remaining device path as a result, this function will return NULL.
329
330**/
331EFI_DEVICE_PATH_PROTOCOL *
332BmDelPartMatchInstance (
333 IN EFI_DEVICE_PATH_PROTOCOL *Multi,
334 IN EFI_DEVICE_PATH_PROTOCOL *Single
335 );
336
337/**
338 Print the device path info.
339
340 @param DevicePath The device path need to print.
341**/
342VOID
343BmPrintDp (
344 EFI_DEVICE_PATH_PROTOCOL *DevicePath
345 );
346
347/**
348 Convert a single character to number.
349 It assumes the input Char is in the scope of L'0' ~ L'9' and L'A' ~ L'F'
350
351 @param Char The input char which need to convert to int.
352
353 @return The converted 8-bit number or (UINTN) -1 if conversion failed.
354**/
355UINTN
356BmCharToUint (
357 IN CHAR16 Char
358 );
359
360/**
361 Return the boot description for the controller.
362
363 @param Handle Controller handle.
364
365 @return The description string.
366**/
367CHAR16 *
368BmGetBootDescription (
369 IN EFI_HANDLE Handle
370 );
371
372/**
373 Enumerate all boot option descriptions and append " 2"/" 3"/... to make
374 unique description.
375
376 @param BootOptions Array of boot options.
377 @param BootOptionCount Count of boot options.
378**/
379VOID
380BmMakeBootOptionDescriptionUnique (
381 EFI_BOOT_MANAGER_LOAD_OPTION *BootOptions,
382 UINTN BootOptionCount
383 );
384
385/**
386 Get the file buffer from the specified Load File instance.
387
388 @param LoadFileHandle The specified Load File instance.
389 @param FilePath The file path which will pass to LoadFile().
390
391 @return The full device path pointing to the load option buffer.
392**/
393EFI_DEVICE_PATH_PROTOCOL *
394BmExpandLoadFile (
395 IN EFI_HANDLE LoadFileHandle,
396 IN EFI_DEVICE_PATH_PROTOCOL *FilePath
397 );
398
399/**
400 Return the RAM Disk device path created by LoadFile.
401
402 @param FilePath The source file path.
403
404 @return Callee-to-free RAM Disk device path
405**/
406EFI_DEVICE_PATH_PROTOCOL *
407BmGetRamDiskDevicePath (
408 IN EFI_DEVICE_PATH_PROTOCOL *FilePath
409 );
410
411/**
412 Destroy the RAM Disk.
413
414 The destroy operation includes to call RamDisk.Unregister to
415 unregister the RAM DISK from RAM DISK driver, free the memory
416 allocated for the RAM Disk.
417
418 @param RamDiskDevicePath RAM Disk device path.
419**/
420VOID
421BmDestroyRamDisk (
422 IN EFI_DEVICE_PATH_PROTOCOL *RamDiskDevicePath
423 );
424
425/**
426 Get the next possible full path pointing to the load option.
427
428 @param FilePath The device path pointing to a load option.
429 It could be a short-form device path.
430 @param FullPath The full path returned by the routine in last call.
431 Set to NULL in first call.
432
433 @return The next possible full path pointing to the load option.
434 Caller is responsible to free the memory.
435**/
436EFI_DEVICE_PATH_PROTOCOL *
437BmGetNextLoadOptionDevicePath (
438 IN EFI_DEVICE_PATH_PROTOCOL *FilePath,
439 IN EFI_DEVICE_PATH_PROTOCOL *FullPath
440 );
441
442/**
443 Return the next matched load option buffer.
444 The routine keeps calling BmGetNextLoadOptionDevicePath() until a valid
445 load option is read.
446
447 @param Type The load option type.
448 It's used to check whether the load option is valid.
449 When it's LoadOptionTypeMax, the routine only guarantees
450 the load option is a valid PE image but doesn't guarantee
451 the PE's subsystem type is valid.
452 @param FilePath The device path pointing to a load option.
453 It could be a short-form device path.
454 @param FullPath Return the next full device path of the load option after
455 short-form device path expanding.
456 Caller is responsible to free it.
457 NULL to return the first matched full device path.
458 @param FileSize Return the load option size.
459
460 @return The load option buffer. Caller is responsible to free the memory.
461**/
462VOID *
463BmGetNextLoadOptionBuffer (
464 IN EFI_BOOT_MANAGER_LOAD_OPTION_TYPE Type,
465 IN EFI_DEVICE_PATH_PROTOCOL *FilePath,
466 OUT EFI_DEVICE_PATH_PROTOCOL **FullPath,
467 OUT UINTN *FileSize
468 );
469#endif // _INTERNAL_BM_H_
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette