]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Library/UefiBootManagerLib/InternalBm.h
MdeModulePkg: Make the BmFindLoadOption function public
[mirror_edk2.git] / MdeModulePkg / Library / UefiBootManagerLib / InternalBm.h
CommitLineData
067ed98a
RN
1/** @file\r
2 BDS library definition, include the file and data structure\r
3\r
4Copyright (c) 2004 - 2015, Intel Corporation. All rights reserved.<BR>\r
5d3a9896 5(C) Copyright 2015 Hewlett Packard Enterprise Development LP<BR>\r
067ed98a
RN
6This program and the accompanying materials\r
7are licensed and made available under the terms and conditions of the BSD License\r
8which accompanies this distribution. The full text of the license may be found at\r
9http://opensource.org/licenses/bsd-license.php\r
10\r
11THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
12WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
13\r
14**/\r
15\r
16#ifndef _INTERNAL_BM_H_\r
17#define _INTERNAL_BM_H_\r
18\r
19#include <PiDxe.h>\r
20\r
21#include <IndustryStandard/Pci.h>\r
22#include <IndustryStandard/PeImage.h>\r
23#include <IndustryStandard/Atapi.h>\r
24#include <IndustryStandard/Scsi.h>\r
25\r
26#include <Protocol/PciRootBridgeIo.h>\r
27#include <Protocol/BlockIo.h>\r
28#include <Protocol/LoadedImage.h>\r
29#include <Protocol/SimpleFileSystem.h>\r
30#include <Protocol/LoadFile.h>\r
31#include <Protocol/DevicePath.h>\r
32#include <Protocol/SimpleTextIn.h>\r
33#include <Protocol/SimpleTextInEx.h>\r
34#include <Protocol/SimpleTextOut.h>\r
35#include <Protocol/SimpleNetwork.h>\r
36#include <Protocol/FirmwareVolume2.h>\r
37#include <Protocol/PciIo.h>\r
38#include <Protocol/GraphicsOutput.h>\r
39#include <Protocol/UsbIo.h>\r
40#include <Protocol/DiskInfo.h>\r
41#include <Protocol/IdeControllerInit.h>\r
42#include <Protocol/BootLogo.h>\r
43#include <Protocol/DriverHealth.h>\r
44#include <Protocol/FormBrowser2.h>\r
45\r
46#include <Guid/ZeroGuid.h>\r
47#include <Guid/MemoryTypeInformation.h>\r
48#include <Guid/FileInfo.h>\r
49#include <Guid/GlobalVariable.h>\r
50#include <Guid/Performance.h>\r
51#include <Guid/StatusCodeDataTypeVariable.h>\r
52\r
53#include <Library/PrintLib.h>\r
54#include <Library/DebugLib.h>\r
55#include <Library/BaseMemoryLib.h>\r
56#include <Library/UefiBootServicesTableLib.h>\r
57#include <Library/UefiRuntimeServicesTableLib.h>\r
58#include <Library/UefiLib.h>\r
59#include <Library/MemoryAllocationLib.h>\r
60#include <Library/DxeServicesTableLib.h>\r
61#include <Library/HobLib.h>\r
62#include <Library/BaseLib.h>\r
63#include <Library/DevicePathLib.h>\r
64#include <Library/PerformanceLib.h>\r
65#include <Library/PcdLib.h>\r
66#include <Library/PeCoffGetEntryPointLib.h>\r
67#include <Library/UefiBootManagerLib.h>\r
68#include <Library/TimerLib.h>\r
69#include <Library/DxeServicesLib.h>\r
70#include <Library/ReportStatusCodeLib.h>\r
71#include <Library/CapsuleLib.h>\r
72#include <Library/PerformanceLib.h>\r
73#include <Library/HiiLib.h>\r
74\r
75#if !defined (EFI_REMOVABLE_MEDIA_FILE_NAME)\r
76 #if defined (MDE_CPU_EBC)\r
77 //\r
78 // Uefi specification only defines the default boot file name for IA32, X64\r
79 // and IPF processor, so need define boot file name for EBC architecture here.\r
80 //\r
81 #define EFI_REMOVABLE_MEDIA_FILE_NAME L"\\EFI\\BOOT\\BOOTEBC.EFI"\r
82 #else\r
83 #error "Can not determine the default boot file name for unknown processor type!"\r
84 #endif\r
85#endif\r
86\r
87typedef enum {\r
88 BmAcpiFloppyBoot,\r
89 BmHardwareDeviceBoot,\r
90 BmMessageAtapiBoot,\r
91 BmMessageSataBoot,\r
92 BmMessageUsbBoot,\r
93 BmMessageScsiBoot,\r
94 BmMessageNetworkBoot,\r
ebf735f1 95 BmMessageHttpBoot,\r
067ed98a
RN
96 BmMiscBoot\r
97} BM_BOOT_TYPE;\r
98\r
99typedef\r
100CHAR16 *\r
101(* BM_GET_BOOT_DESCRIPTION) (\r
102 IN EFI_HANDLE Handle\r
103 );\r
104\r
105#define BM_OPTION_NAME_LEN sizeof ("SysPrep####")\r
106extern CHAR16 *mBmLoadOptionName[];\r
107\r
108typedef\r
109VOID\r
110(*VARIABLE_VISITOR) (\r
111 CHAR16 *Name,\r
112 EFI_GUID *Guid,\r
113 VOID *Context\r
114 );\r
115\r
116/**\r
117 Call Visitor function for each variable in variable storage.\r
118\r
119 @param Visitor Visitor function.\r
120 @param Context The context passed to Visitor function.\r
121**/\r
122VOID\r
123ForEachVariable (\r
124 VARIABLE_VISITOR Visitor,\r
125 VOID *Context\r
126 );\r
127\r
f41c71d2
RN
128#define BM_BOOT_DESCRIPTION_ENTRY_SIGNATURE SIGNATURE_32 ('b', 'm', 'd', 'h')\r
129typedef struct {\r
130 UINT32 Signature;\r
131 LIST_ENTRY Link;\r
132 EFI_BOOT_MANAGER_BOOT_DESCRIPTION_HANDLER Handler;\r
133} BM_BOOT_DESCRIPTION_ENTRY;\r
134\r
067ed98a
RN
135/**\r
136 Repair all the controllers according to the Driver Health status queried.\r
137**/\r
138VOID\r
139BmRepairAllControllers (\r
140 VOID\r
141 );\r
142\r
143#define BM_HOTKEY_SIGNATURE SIGNATURE_32 ('b', 'm', 'h', 'k')\r
144typedef struct {\r
145 UINT32 Signature;\r
146 LIST_ENTRY Link;\r
147\r
148 BOOLEAN IsContinue;\r
149 UINT16 BootOption;\r
150 UINT8 CodeCount;\r
151 UINT8 WaitingKey;\r
152 EFI_KEY_DATA KeyData[3];\r
153} BM_HOTKEY;\r
154\r
155#define BM_HOTKEY_FROM_LINK(a) CR (a, BM_HOTKEY, Link, BM_HOTKEY_SIGNATURE)\r
156\r
157/**\r
158 Get the image file buffer data and buffer size by its device path. \r
159\r
160 @param FilePath On input, a pointer to an allocated buffer containing the device\r
161 path of the file.\r
162 On output the pointer could be NULL when the function fails to\r
163 load the boot option, or could point to an allocated buffer containing\r
164 the device path of the file.\r
165 It could be updated by either short-form device path expanding,\r
166 or default boot file path appending.\r
167 Caller is responsible to free it when it's non-NULL.\r
168 @param FileSize A pointer to the size of the file buffer.\r
169\r
170 @retval NULL File is NULL, or FileSize is NULL. Or, the file can't be found.\r
171 @retval other The file buffer. The caller is responsible to free the memory.\r
172**/\r
173VOID *\r
174BmLoadEfiBootOption (\r
175 IN OUT EFI_DEVICE_PATH_PROTOCOL **FilePath,\r
176 OUT UINTN *FileSize\r
177 );\r
178\r
179/**\r
180 Get the Option Number that wasn't used.\r
181\r
182 @param LoadOptionType Load option type.\r
183 @param FreeOptionNumber To receive the minimal free option number.\r
184\r
185 @retval EFI_SUCCESS The option number is found\r
186 @retval EFI_OUT_OF_RESOURCES There is no free option number that can be used.\r
187 @retval EFI_INVALID_PARAMETER FreeOptionNumber is NULL\r
188\r
189**/\r
190EFI_STATUS\r
191BmGetFreeOptionNumber (\r
192 IN EFI_BOOT_MANAGER_LOAD_OPTION_TYPE LoadOptionType,\r
193 OUT UINT16 *FreeOptionNumber\r
194 );\r
195\r
196/**\r
197\r
198 Writes performance data of booting into the allocated memory.\r
199 OS can process these records.\r
200\r
201 @param Event The triggered event.\r
202 @param Context Context for this event.\r
203\r
204**/\r
205VOID\r
206EFIAPI\r
207BmWriteBootToOsPerformanceData (\r
208 IN EFI_EVENT Event,\r
209 IN VOID *Context\r
210 );\r
211\r
212\r
213/**\r
214 Get the headers (dos, image, optional header) from an image\r
215\r
216 @param Device SimpleFileSystem device handle\r
217 @param FileName File name for the image\r
218 @param DosHeader Pointer to dos header\r
219 @param Hdr The buffer in which to return the PE32, PE32+, or TE header.\r
220\r
221 @retval EFI_SUCCESS Successfully get the machine type.\r
222 @retval EFI_NOT_FOUND The file is not found.\r
223 @retval EFI_LOAD_ERROR File is not a valid image file.\r
224\r
225**/\r
226EFI_STATUS\r
227BmGetImageHeader (\r
228 IN EFI_HANDLE Device,\r
229 IN CHAR16 *FileName,\r
230 OUT EFI_IMAGE_DOS_HEADER *DosHeader,\r
231 OUT EFI_IMAGE_OPTIONAL_HEADER_PTR_UNION Hdr\r
232 );\r
233\r
234/**\r
235 This routine adjust the memory information for different memory type and \r
236 save them into the variables for next boot.\r
237**/\r
238VOID\r
239BmSetMemoryTypeInformationVariable (\r
240 VOID\r
241 );\r
242\r
243/**\r
244 Check whether there is a instance in BlockIoDevicePath, which contain multi device path\r
245 instances, has the same partition node with HardDriveDevicePath device path\r
246\r
247 @param BlockIoDevicePath Multi device path instances which need to check\r
248 @param HardDriveDevicePath A device path which starts with a hard drive media\r
249 device path.\r
250\r
251 @retval TRUE There is a matched device path instance.\r
252 @retval FALSE There is no matched device path instance.\r
253\r
254**/\r
255BOOLEAN\r
256BmMatchPartitionDevicePathNode (\r
257 IN EFI_DEVICE_PATH_PROTOCOL *BlockIoDevicePath,\r
258 IN HARDDRIVE_DEVICE_PATH *HardDriveDevicePath\r
259 );\r
260\r
261/**\r
262 Connect the specific Usb device which match the short form device path.\r
263\r
264 @param DevicePath A short-form device path that starts with the first\r
265 element being a USB WWID or a USB Class device\r
266 path\r
267\r
268 @return EFI_INVALID_PARAMETER DevicePath is NULL pointer.\r
269 DevicePath is not a USB device path.\r
270\r
271 @return EFI_SUCCESS Success to connect USB device\r
272 @return EFI_NOT_FOUND Fail to find handle for USB controller to connect.\r
273\r
274**/\r
275EFI_STATUS\r
276BmConnectUsbShortFormDevicePath (\r
277 IN EFI_DEVICE_PATH_PROTOCOL *DevicePath\r
278 );\r
279\r
280/**\r
281 Stop the hotkey processing.\r
282 \r
283 @param Event Event pointer related to hotkey service. \r
284 @param Context Context pass to this function. \r
285**/\r
286VOID\r
287EFIAPI\r
288BmStopHotkeyService (\r
289 IN EFI_EVENT Event,\r
290 IN VOID *Context\r
291 );\r
292\r
293/**\r
294 Set the variable and report the error through status code upon failure.\r
295\r
296 @param VariableName A Null-terminated string that is the name of the vendor's variable.\r
297 Each VariableName is unique for each VendorGuid. VariableName must\r
298 contain 1 or more characters. If VariableName is an empty string,\r
299 then EFI_INVALID_PARAMETER is returned.\r
300 @param VendorGuid A unique identifier for the vendor.\r
301 @param Attributes Attributes bitmask to set for the variable.\r
302 @param DataSize The size in bytes of the Data buffer. Unless the EFI_VARIABLE_APPEND_WRITE, \r
303 EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS, or \r
304 EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS attribute is set, a size of zero \r
305 causes the variable to be deleted. When the EFI_VARIABLE_APPEND_WRITE attribute is \r
306 set, then a SetVariable() call with a DataSize of zero will not cause any change to \r
307 the variable value (the timestamp associated with the variable may be updated however \r
308 even if no new data value is provided,see the description of the \r
309 EFI_VARIABLE_AUTHENTICATION_2 descriptor below. In this case the DataSize will not \r
310 be zero since the EFI_VARIABLE_AUTHENTICATION_2 descriptor will be populated). \r
311 @param Data The contents for the variable.\r
312\r
313 @retval EFI_SUCCESS The firmware has successfully stored the variable and its data as\r
314 defined by the Attributes.\r
315 @retval EFI_INVALID_PARAMETER An invalid combination of attribute bits, name, and GUID was supplied, or the\r
316 DataSize exceeds the maximum allowed.\r
317 @retval EFI_INVALID_PARAMETER VariableName is an empty string.\r
318 @retval EFI_OUT_OF_RESOURCES Not enough storage is available to hold the variable and its data.\r
319 @retval EFI_DEVICE_ERROR The variable could not be retrieved due to a hardware error.\r
320 @retval EFI_WRITE_PROTECTED The variable in question is read-only.\r
321 @retval EFI_WRITE_PROTECTED The variable in question cannot be deleted.\r
322 @retval EFI_SECURITY_VIOLATION The variable could not be written due to EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS \r
323 or EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACESS being set, but the AuthInfo \r
324 does NOT pass the validation check carried out by the firmware.\r
325\r
326 @retval EFI_NOT_FOUND The variable trying to be updated or deleted was not found.\r
327**/\r
328EFI_STATUS\r
329BmSetVariableAndReportStatusCodeOnError (\r
330 IN CHAR16 *VariableName,\r
331 IN EFI_GUID *VendorGuid,\r
332 IN UINT32 Attributes,\r
333 IN UINTN DataSize,\r
334 IN VOID *Data\r
335 );\r
336\r
337/**\r
338 Get the load option by its device path.\r
339\r
340 @param FilePath The device path pointing to a load option.\r
341 It could be a short-form device path.\r
342 @param FullPath Return the full device path of the load option after\r
343 short-form device path expanding.\r
344 Caller is responsible to free it.\r
345 @param FileSize Return the load option size.\r
346\r
347 @return The load option buffer. Caller is responsible to free the memory.\r
348**/\r
349VOID *\r
350BmGetLoadOptionBuffer (\r
351 IN EFI_DEVICE_PATH_PROTOCOL *FilePath,\r
352 OUT EFI_DEVICE_PATH_PROTOCOL **FullPath,\r
353 OUT UINTN *FileSize\r
354 );\r
355\r
356/**\r
357 Return whether the PE header of the load option is valid or not.\r
358\r
359 @param[in] Type The load option type.\r
360 @param[in] FileBuffer The PE file buffer of the load option.\r
361 @param[in] FileSize The size of the load option file.\r
362\r
363 @retval TRUE The PE header of the load option is valid.\r
364 @retval FALSE The PE header of the load option is not valid.\r
365**/\r
366BOOLEAN\r
367BmIsLoadOptionPeHeaderValid (\r
368 IN EFI_BOOT_MANAGER_LOAD_OPTION_TYPE Type,\r
369 IN VOID *FileBuffer,\r
370 IN UINTN FileSize\r
371 );\r
372\r
373/**\r
374 Function compares a device path data structure to that of all the nodes of a\r
375 second device path instance.\r
376\r
377 @param Multi A pointer to a multi-instance device path data\r
378 structure.\r
379 @param Single A pointer to a single-instance device path data\r
380 structure.\r
381\r
382 @retval TRUE If the Single device path is contained within Multi device path.\r
383 @retval FALSE The Single device path is not match within Multi device path.\r
384\r
385**/\r
386BOOLEAN\r
387BmMatchDevicePaths (\r
388 IN EFI_DEVICE_PATH_PROTOCOL *Multi,\r
389 IN EFI_DEVICE_PATH_PROTOCOL *Single\r
390 );\r
391\r
392/**\r
393 Delete the instance in Multi which matches partly with Single instance\r
394\r
395 @param Multi A pointer to a multi-instance device path data\r
396 structure.\r
397 @param Single A pointer to a single-instance device path data\r
398 structure.\r
399\r
400 @return This function will remove the device path instances in Multi which partly\r
401 match with the Single, and return the result device path. If there is no\r
402 remaining device path as a result, this function will return NULL.\r
403\r
404**/\r
405EFI_DEVICE_PATH_PROTOCOL *\r
406BmDelPartMatchInstance (\r
407 IN EFI_DEVICE_PATH_PROTOCOL *Multi,\r
408 IN EFI_DEVICE_PATH_PROTOCOL *Single\r
409 );\r
410\r
067ed98a
RN
411/**\r
412 Repair all the controllers according to the Driver Health status queried.\r
413**/\r
414VOID\r
415BmRepairAllControllers (\r
416 VOID\r
417 );\r
418\r
419/**\r
420 Print the device path info.\r
421\r
422 @param DevicePath The device path need to print.\r
423**/\r
424VOID\r
425BmPrintDp (\r
426 EFI_DEVICE_PATH_PROTOCOL *DevicePath\r
427 );\r
428\r
429#endif // _INTERNAL_BM_H_\r