3 * Copyright (c) 2011-2015, ARM Limited. All rights reserved.
5 * This program and the accompanying materials
6 * are licensed and made available under the terms and conditions of the BSD License
7 * which accompanies this distribution. The full text of the license may be found at
8 * http://opensource.org/licenses/bsd-license.php
10 * THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
15 #ifndef _BDSINTERNAL_H_
16 #define _BDSINTERNAL_H_
19 #include <Library/BaseMemoryLib.h>
20 #include <Library/BdsLib.h>
21 #include <Library/DebugLib.h>
22 #include <Library/DevicePathLib.h>
23 #include <Library/UefiLib.h>
24 #include <Library/PrintLib.h>
25 #include <Library/PcdLib.h>
26 #include <Library/MemoryAllocationLib.h>
27 #include <Library/UefiBootServicesTableLib.h>
28 #include <Library/UefiRuntimeServicesTableLib.h>
30 #include <Protocol/DevicePathFromText.h>
31 #include <Protocol/DevicePathToText.h>
33 #include <Guid/GlobalVariable.h>
36 #define BOOT_DEVICE_DESCRIPTION_MAX 100
37 #define BOOT_DEVICE_FILEPATH_MAX 100
38 #define BOOT_DEVICE_OPTION_MAX 300
39 #define BOOT_DEVICE_ADDRESS_MAX (sizeof(L"0x0000000000000000"))
41 #define UPDATE_BOOT_ENTRY L"Update entry: "
42 #define DELETE_BOOT_ENTRY L"Delete entry: "
43 #define MOVE_BOOT_ENTRY L"Move entry: "
47 BDS_LOAD_OPTION
* BdsLoadOption
;
48 } BDS_LOAD_OPTION_ENTRY
;
51 BDS_DEVICE_FILESYSTEM
= 0,
56 } BDS_SUPPORTED_DEVICE_TYPE
;
60 CHAR16 Description
[BOOT_DEVICE_DESCRIPTION_MAX
];
61 EFI_DEVICE_PATH_PROTOCOL
* DevicePathProtocol
;
62 struct _BDS_LOAD_OPTION_SUPPORT
* Support
;
63 } BDS_SUPPORTED_DEVICE
;
65 #define SUPPORTED_BOOT_DEVICE_FROM_LINK(a) BASE_CR(a, BDS_SUPPORTED_DEVICE, Link)
67 typedef struct _BDS_LOAD_OPTION_SUPPORT
{
68 BDS_SUPPORTED_DEVICE_TYPE Type
;
69 EFI_STATUS (*ListDevices
)(IN OUT LIST_ENTRY
* BdsLoadOptionList
);
70 BOOLEAN (*IsSupported
)(IN EFI_DEVICE_PATH
*DevicePath
);
71 EFI_STATUS (*CreateDevicePathNode
)(IN CHAR16
* FileName
, OUT EFI_DEVICE_PATH_PROTOCOL
**DevicePathNodes
);
72 EFI_STATUS (*UpdateDevicePathNode
)(IN EFI_DEVICE_PATH
*OldDevicePath
, IN CHAR16
* FileName
, OUT EFI_DEVICE_PATH_PROTOCOL
** NewDevicePath
);
74 /// Define if the boot menu should request if the file is a EFI binary or a Linux kernel
75 /// Example: PXE boot always deliver a UEFI application.
76 BOOLEAN RequestBootType
;
77 } BDS_LOAD_OPTION_SUPPORT
;
79 #define LOAD_OPTION_ENTRY_FROM_LINK(a) BASE_CR(a, BDS_LOAD_OPTION_ENTRY, Link)
80 #define LOAD_OPTION_FROM_LINK(a) ((BDS_LOAD_OPTION_ENTRY*)BASE_CR(a, BDS_LOAD_OPTION_ENTRY, Link))->BdsLoadOption
82 // GUID of the EFI Linux Loader
83 extern CONST EFI_GUID mLinuxLoaderAppGuid
;
85 // Device path of the EFI Linux Loader in the Firmware Volume
86 extern EFI_DEVICE_PATH
* mLinuxLoaderDevicePath
;
89 BootDeviceListSupportedInit (
90 IN OUT LIST_ENTRY
*SupportedDeviceList
94 BootDeviceListSupportedFree (
95 IN LIST_ENTRY
*SupportedDeviceList
,
96 IN BDS_SUPPORTED_DEVICE
*Except
100 BootDeviceGetDeviceSupport (
101 IN EFI_DEVICE_PATH
*DevicePath
,
102 OUT BDS_LOAD_OPTION_SUPPORT
**DeviceSupport
107 IN OUT CHAR16
*CmdLine
,
113 IN OUT CHAR16
*CmdLine
,
119 IN OUT CHAR8
*CmdLine
,
125 IN OUT CHAR8
*CmdLine
,
131 IN OUT UINTN
*Integer
136 OUT EFI_IP_ADDRESS
*Ip
141 IN EFI_IP_ADDRESS
*InIpAddr
,
142 OUT EFI_IP_ADDRESS
*OutIpAddr
151 GetLastDevicePathNode (
152 IN EFI_DEVICE_PATH
* DevicePath
157 IN CHAR16
* BootOption
161 GetUnalignedDevicePathSize (
162 IN EFI_DEVICE_PATH
* DevicePath
166 GetAlignedDevicePath (
167 IN EFI_DEVICE_PATH
* DevicePath
171 GenerateDeviceDescriptionName (
172 IN EFI_HANDLE Handle
,
173 IN OUT CHAR16
* Description
178 IN OUT LIST_ENTRY
*BootOptionList
182 BootOptionParseLoadOption (
183 IN EFI_LOAD_OPTION EfiLoadOption
,
184 IN UINTN EfiLoadOptionSize
,
185 OUT BDS_LOAD_OPTION
**BdsLoadOption
190 IN BDS_LOAD_OPTION
*BootOption
195 IN UINT32 Attributes
,
196 IN CHAR16
* BootDescription
,
197 IN EFI_DEVICE_PATH_PROTOCOL
* DevicePath
,
198 IN UINT8
* OptionalData
,
199 IN UINTN OptionalDataSize
,
200 OUT BDS_LOAD_OPTION
** BdsLoadOption
205 IN BDS_LOAD_OPTION
* BdsLoadOption
,
206 IN UINT32 Attributes
,
207 IN CHAR16
* BootDescription
,
208 IN EFI_DEVICE_PATH_PROTOCOL
* DevicePath
,
209 IN UINT8
* OptionalData
,
210 IN UINTN OptionalDataSize
215 IN BDS_LOAD_OPTION
*BootOption
229 * Try to detect if the given string is an ASCII or Unicode string
231 * There are actually few limitation to this function but it is mainly to give
232 * a user friendly output.
235 * - it only supports unicode string that use ASCII character (< 0x100)
236 * - single character ASCII strings are interpreted as Unicode string
237 * - string cannot be longer than 2 x BOOT_DEVICE_OPTION_MAX (600 bytes)
239 * @param String Buffer that might contain a Unicode or Ascii string
240 * @param IsUnicode If not NULL this boolean value returns if the string is an
241 * ASCII or Unicode string.
246 OUT BOOLEAN
*IsUnicode
250 An empty function to pass error checking of CreateEventEx ().
252 @param Event Event whose notification function is being invoked.
253 @param Context Pointer to the notification function's context,
254 which is implementation-dependent.
259 EmptyCallbackFunction (
265 * This function check if the DevicePath defines an EFI binary
267 * This function is used when the BDS support Linux loader to
268 * detect if the binary is an EFI application or potentially a
273 IN EFI_DEVICE_PATH
* DevicePath
,
274 OUT BOOLEAN
*EfiBinary
277 #endif /* _BDSINTERNAL_H_ */