]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Library/UefiBootManagerLib/InternalBm.h
MdeModulePkg: Fix EOL to be DOS format.
[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
94 BmMiscBoot\r
95} BM_BOOT_TYPE;\r
96\r
97typedef\r
98CHAR16 *\r
99(* BM_GET_BOOT_DESCRIPTION) (\r
100 IN EFI_HANDLE Handle\r
101 );\r
102\r
103#define BM_OPTION_NAME_LEN sizeof ("SysPrep####")\r
104extern CHAR16 *mBmLoadOptionName[];\r
105\r
106typedef\r
107VOID\r
108(*VARIABLE_VISITOR) (\r
109 CHAR16 *Name,\r
110 EFI_GUID *Guid,\r
111 VOID *Context\r
112 );\r
113\r
114/**\r
115 Call Visitor function for each variable in variable storage.\r
116\r
117 @param Visitor Visitor function.\r
118 @param Context The context passed to Visitor function.\r
119**/\r
120VOID\r
121ForEachVariable (\r
122 VARIABLE_VISITOR Visitor,\r
123 VOID *Context\r
124 );\r
125\r
126/**\r
127 Repair all the controllers according to the Driver Health status queried.\r
128**/\r
129VOID\r
130BmRepairAllControllers (\r
131 VOID\r
132 );\r
133\r
134#define BM_HOTKEY_SIGNATURE SIGNATURE_32 ('b', 'm', 'h', 'k')\r
135typedef struct {\r
136 UINT32 Signature;\r
137 LIST_ENTRY Link;\r
138\r
139 BOOLEAN IsContinue;\r
140 UINT16 BootOption;\r
141 UINT8 CodeCount;\r
142 UINT8 WaitingKey;\r
143 EFI_KEY_DATA KeyData[3];\r
144} BM_HOTKEY;\r
145\r
146#define BM_HOTKEY_FROM_LINK(a) CR (a, BM_HOTKEY, Link, BM_HOTKEY_SIGNATURE)\r
147\r
148/**\r
149 Get the image file buffer data and buffer size by its device path. \r
150\r
151 @param FilePath On input, a pointer to an allocated buffer containing the device\r
152 path of the file.\r
153 On output the pointer could be NULL when the function fails to\r
154 load the boot option, or could point to an allocated buffer containing\r
155 the device path of the file.\r
156 It could be updated by either short-form device path expanding,\r
157 or default boot file path appending.\r
158 Caller is responsible to free it when it's non-NULL.\r
159 @param FileSize A pointer to the size of the file buffer.\r
160\r
161 @retval NULL File is NULL, or FileSize is NULL. Or, the file can't be found.\r
162 @retval other The file buffer. The caller is responsible to free the memory.\r
163**/\r
164VOID *\r
165BmLoadEfiBootOption (\r
166 IN OUT EFI_DEVICE_PATH_PROTOCOL **FilePath,\r
167 OUT UINTN *FileSize\r
168 );\r
169\r
170/**\r
171 Get the Option Number that wasn't used.\r
172\r
173 @param LoadOptionType Load option type.\r
174 @param FreeOptionNumber To receive the minimal free option number.\r
175\r
176 @retval EFI_SUCCESS The option number is found\r
177 @retval EFI_OUT_OF_RESOURCES There is no free option number that can be used.\r
178 @retval EFI_INVALID_PARAMETER FreeOptionNumber is NULL\r
179\r
180**/\r
181EFI_STATUS\r
182BmGetFreeOptionNumber (\r
183 IN EFI_BOOT_MANAGER_LOAD_OPTION_TYPE LoadOptionType,\r
184 OUT UINT16 *FreeOptionNumber\r
185 );\r
186\r
187/**\r
188\r
189 Writes performance data of booting into the allocated memory.\r
190 OS can process these records.\r
191\r
192 @param Event The triggered event.\r
193 @param Context Context for this event.\r
194\r
195**/\r
196VOID\r
197EFIAPI\r
198BmWriteBootToOsPerformanceData (\r
199 IN EFI_EVENT Event,\r
200 IN VOID *Context\r
201 );\r
202\r
203\r
204/**\r
205 Get the headers (dos, image, optional header) from an image\r
206\r
207 @param Device SimpleFileSystem device handle\r
208 @param FileName File name for the image\r
209 @param DosHeader Pointer to dos header\r
210 @param Hdr The buffer in which to return the PE32, PE32+, or TE header.\r
211\r
212 @retval EFI_SUCCESS Successfully get the machine type.\r
213 @retval EFI_NOT_FOUND The file is not found.\r
214 @retval EFI_LOAD_ERROR File is not a valid image file.\r
215\r
216**/\r
217EFI_STATUS\r
218BmGetImageHeader (\r
219 IN EFI_HANDLE Device,\r
220 IN CHAR16 *FileName,\r
221 OUT EFI_IMAGE_DOS_HEADER *DosHeader,\r
222 OUT EFI_IMAGE_OPTIONAL_HEADER_PTR_UNION Hdr\r
223 );\r
224\r
225/**\r
226 This routine adjust the memory information for different memory type and \r
227 save them into the variables for next boot.\r
228**/\r
229VOID\r
230BmSetMemoryTypeInformationVariable (\r
231 VOID\r
232 );\r
233\r
234/**\r
235 Check whether there is a instance in BlockIoDevicePath, which contain multi device path\r
236 instances, has the same partition node with HardDriveDevicePath device path\r
237\r
238 @param BlockIoDevicePath Multi device path instances which need to check\r
239 @param HardDriveDevicePath A device path which starts with a hard drive media\r
240 device path.\r
241\r
242 @retval TRUE There is a matched device path instance.\r
243 @retval FALSE There is no matched device path instance.\r
244\r
245**/\r
246BOOLEAN\r
247BmMatchPartitionDevicePathNode (\r
248 IN EFI_DEVICE_PATH_PROTOCOL *BlockIoDevicePath,\r
249 IN HARDDRIVE_DEVICE_PATH *HardDriveDevicePath\r
250 );\r
251\r
252/**\r
253 Connect the specific Usb device which match the short form device path.\r
254\r
255 @param DevicePath A short-form device path that starts with the first\r
256 element being a USB WWID or a USB Class device\r
257 path\r
258\r
259 @return EFI_INVALID_PARAMETER DevicePath is NULL pointer.\r
260 DevicePath is not a USB device path.\r
261\r
262 @return EFI_SUCCESS Success to connect USB device\r
263 @return EFI_NOT_FOUND Fail to find handle for USB controller to connect.\r
264\r
265**/\r
266EFI_STATUS\r
267BmConnectUsbShortFormDevicePath (\r
268 IN EFI_DEVICE_PATH_PROTOCOL *DevicePath\r
269 );\r
270\r
271/**\r
272 Stop the hotkey processing.\r
273 \r
274 @param Event Event pointer related to hotkey service. \r
275 @param Context Context pass to this function. \r
276**/\r
277VOID\r
278EFIAPI\r
279BmStopHotkeyService (\r
280 IN EFI_EVENT Event,\r
281 IN VOID *Context\r
282 );\r
283\r
284/**\r
285 Set the variable and report the error through status code upon failure.\r
286\r
287 @param VariableName A Null-terminated string that is the name of the vendor's variable.\r
288 Each VariableName is unique for each VendorGuid. VariableName must\r
289 contain 1 or more characters. If VariableName is an empty string,\r
290 then EFI_INVALID_PARAMETER is returned.\r
291 @param VendorGuid A unique identifier for the vendor.\r
292 @param Attributes Attributes bitmask to set for the variable.\r
293 @param DataSize The size in bytes of the Data buffer. Unless the EFI_VARIABLE_APPEND_WRITE, \r
294 EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS, or \r
295 EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS attribute is set, a size of zero \r
296 causes the variable to be deleted. When the EFI_VARIABLE_APPEND_WRITE attribute is \r
297 set, then a SetVariable() call with a DataSize of zero will not cause any change to \r
298 the variable value (the timestamp associated with the variable may be updated however \r
299 even if no new data value is provided,see the description of the \r
300 EFI_VARIABLE_AUTHENTICATION_2 descriptor below. In this case the DataSize will not \r
301 be zero since the EFI_VARIABLE_AUTHENTICATION_2 descriptor will be populated). \r
302 @param Data The contents for the variable.\r
303\r
304 @retval EFI_SUCCESS The firmware has successfully stored the variable and its data as\r
305 defined by the Attributes.\r
306 @retval EFI_INVALID_PARAMETER An invalid combination of attribute bits, name, and GUID was supplied, or the\r
307 DataSize exceeds the maximum allowed.\r
308 @retval EFI_INVALID_PARAMETER VariableName is an empty string.\r
309 @retval EFI_OUT_OF_RESOURCES Not enough storage is available to hold the variable and its data.\r
310 @retval EFI_DEVICE_ERROR The variable could not be retrieved due to a hardware error.\r
311 @retval EFI_WRITE_PROTECTED The variable in question is read-only.\r
312 @retval EFI_WRITE_PROTECTED The variable in question cannot be deleted.\r
313 @retval EFI_SECURITY_VIOLATION The variable could not be written due to EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS \r
314 or EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACESS being set, but the AuthInfo \r
315 does NOT pass the validation check carried out by the firmware.\r
316\r
317 @retval EFI_NOT_FOUND The variable trying to be updated or deleted was not found.\r
318**/\r
319EFI_STATUS\r
320BmSetVariableAndReportStatusCodeOnError (\r
321 IN CHAR16 *VariableName,\r
322 IN EFI_GUID *VendorGuid,\r
323 IN UINT32 Attributes,\r
324 IN UINTN DataSize,\r
325 IN VOID *Data\r
326 );\r
327\r
328/**\r
329 Get the load option by its device path.\r
330\r
331 @param FilePath The device path pointing to a load option.\r
332 It could be a short-form device path.\r
333 @param FullPath Return the full device path of the load option after\r
334 short-form device path expanding.\r
335 Caller is responsible to free it.\r
336 @param FileSize Return the load option size.\r
337\r
338 @return The load option buffer. Caller is responsible to free the memory.\r
339**/\r
340VOID *\r
341BmGetLoadOptionBuffer (\r
342 IN EFI_DEVICE_PATH_PROTOCOL *FilePath,\r
343 OUT EFI_DEVICE_PATH_PROTOCOL **FullPath,\r
344 OUT UINTN *FileSize\r
345 );\r
346\r
347/**\r
348 Return whether the PE header of the load option is valid or not.\r
349\r
350 @param[in] Type The load option type.\r
351 @param[in] FileBuffer The PE file buffer of the load option.\r
352 @param[in] FileSize The size of the load option file.\r
353\r
354 @retval TRUE The PE header of the load option is valid.\r
355 @retval FALSE The PE header of the load option is not valid.\r
356**/\r
357BOOLEAN\r
358BmIsLoadOptionPeHeaderValid (\r
359 IN EFI_BOOT_MANAGER_LOAD_OPTION_TYPE Type,\r
360 IN VOID *FileBuffer,\r
361 IN UINTN FileSize\r
362 );\r
363\r
364/**\r
365 Function compares a device path data structure to that of all the nodes of a\r
366 second device path instance.\r
367\r
368 @param Multi A pointer to a multi-instance device path data\r
369 structure.\r
370 @param Single A pointer to a single-instance device path data\r
371 structure.\r
372\r
373 @retval TRUE If the Single device path is contained within Multi device path.\r
374 @retval FALSE The Single device path is not match within Multi device path.\r
375\r
376**/\r
377BOOLEAN\r
378BmMatchDevicePaths (\r
379 IN EFI_DEVICE_PATH_PROTOCOL *Multi,\r
380 IN EFI_DEVICE_PATH_PROTOCOL *Single\r
381 );\r
382\r
383/**\r
384 Delete the instance in Multi which matches partly with Single instance\r
385\r
386 @param Multi A pointer to a multi-instance device path data\r
387 structure.\r
388 @param Single A pointer to a single-instance device path data\r
389 structure.\r
390\r
391 @return This function will remove the device path instances in Multi which partly\r
392 match with the Single, and return the result device path. If there is no\r
393 remaining device path as a result, this function will return NULL.\r
394\r
395**/\r
396EFI_DEVICE_PATH_PROTOCOL *\r
397BmDelPartMatchInstance (\r
398 IN EFI_DEVICE_PATH_PROTOCOL *Multi,\r
399 IN EFI_DEVICE_PATH_PROTOCOL *Single\r
400 );\r
401\r
402\r
403/**\r
404 Return the index of the load option in the load option array.\r
405\r
406 The function consider two load options are equal when the \r
407 OptionType, Attributes, Description, FilePath and OptionalData are equal.\r
408\r
409 @param Key Pointer to the load option to be found.\r
410 @param Array Pointer to the array of load options to be found.\r
411 @param Count Number of entries in the Array.\r
412\r
413 @retval -1 Key wasn't found in the Array.\r
414 @retval 0 ~ Count-1 The index of the Key in the Array.\r
415**/\r
416INTN\r
417BmFindLoadOption (\r
418 IN CONST EFI_BOOT_MANAGER_LOAD_OPTION *Key,\r
419 IN CONST EFI_BOOT_MANAGER_LOAD_OPTION *Array,\r
420 IN UINTN Count\r
421 );\r
422\r
423/**\r
424 Repair all the controllers according to the Driver Health status queried.\r
425**/\r
426VOID\r
427BmRepairAllControllers (\r
428 VOID\r
429 );\r
430\r
431/**\r
432 Print the device path info.\r
433\r
434 @param DevicePath The device path need to print.\r
435**/\r
436VOID\r
437BmPrintDp (\r
438 EFI_DEVICE_PATH_PROTOCOL *DevicePath\r
439 );\r
440\r
441#endif // _INTERNAL_BM_H_\r