3 * Copyright (c) 2011-2014, 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
83 BootDeviceListSupportedInit (
84 IN OUT LIST_ENTRY
*SupportedDeviceList
88 BootDeviceListSupportedFree (
89 IN LIST_ENTRY
*SupportedDeviceList
,
90 IN BDS_SUPPORTED_DEVICE
*Except
94 BootDeviceGetDeviceSupport (
95 IN EFI_DEVICE_PATH
*DevicePath
,
96 OUT BDS_LOAD_OPTION_SUPPORT
**DeviceSupport
101 IN OUT CHAR16
*CmdLine
,
107 IN OUT CHAR16
*CmdLine
,
113 IN OUT CHAR8
*CmdLine
,
119 IN OUT CHAR8
*CmdLine
,
125 IN OUT UINTN
*Integer
130 OUT EFI_IP_ADDRESS
*Ip
135 IN EFI_IP_ADDRESS
*InIpAddr
,
136 OUT EFI_IP_ADDRESS
*OutIpAddr
145 HasFilePathEfiExtension (
150 GetLastDevicePathNode (
151 IN EFI_DEVICE_PATH
* DevicePath
156 IN CHAR16
* BootOption
160 GetUnalignedDevicePathSize (
161 IN EFI_DEVICE_PATH
* DevicePath
165 GetAlignedDevicePath (
166 IN EFI_DEVICE_PATH
* DevicePath
170 GenerateDeviceDescriptionName (
171 IN EFI_HANDLE Handle
,
172 IN OUT CHAR16
* Description
177 IN OUT LIST_ENTRY
*BootOptionList
181 BootOptionParseLoadOption (
182 IN EFI_LOAD_OPTION EfiLoadOption
,
183 IN UINTN EfiLoadOptionSize
,
184 OUT BDS_LOAD_OPTION
**BdsLoadOption
189 IN BDS_LOAD_OPTION
*BootOption
194 IN UINT32 Attributes
,
195 IN CHAR16
* BootDescription
,
196 IN EFI_DEVICE_PATH_PROTOCOL
* DevicePath
,
197 IN UINT8
* OptionalData
,
198 IN UINTN OptionalDataSize
,
199 OUT BDS_LOAD_OPTION
** BdsLoadOption
204 IN BDS_LOAD_OPTION
* BdsLoadOption
,
205 IN UINT32 Attributes
,
206 IN CHAR16
* BootDescription
,
207 IN EFI_DEVICE_PATH_PROTOCOL
* DevicePath
,
208 IN UINT8
* OptionalData
,
209 IN UINTN OptionalDataSize
214 IN BDS_LOAD_OPTION
*BootOption
228 * Try to detect if the given string is an ASCII or Unicode string
230 * There are actually few limitation to this function but it is mainly to give
231 * a user friendly output.
234 * - it only supports unicode string that use ASCII character (< 0x100)
235 * - single character ASCII strings are interpreted as Unicode string
236 * - string cannot be longer than 2 x BOOT_DEVICE_OPTION_MAX (600 bytes)
238 * @param String Buffer that might contain a Unicode or Ascii string
239 * @param IsUnicode If not NULL this boolean value returns if the string is an
240 * ASCII or Unicode string.
245 OUT BOOLEAN
*IsUnicode
249 An empty function to pass error checking of CreateEventEx ().
251 @param Event Event whose notification function is being invoked.
252 @param Context Pointer to the notification function's context,
253 which is implementation-dependent.
258 EmptyCallbackFunction (
263 #endif /* _BDSINTERNAL_H_ */