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