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 ARM_BDS_OPTIONAL_DATA_SIGNATURE SIGNATURE_32('a', 'b', 'o', 'd')
43 #define IS_ARM_BDS_BOOTENTRY(ptr) \
44 (((ptr)->OptionalData != NULL) && \
45 (ReadUnaligned32 ((CONST UINT32*)&((ARM_BDS_LOADER_OPTIONAL_DATA*)((ptr)->OptionalData))->Header.Signature) \
46 == ARM_BDS_OPTIONAL_DATA_SIGNATURE))
48 #define UPDATE_BOOT_ENTRY L"Update entry: "
49 #define DELETE_BOOT_ENTRY L"Delete entry: "
50 #define MOVE_BOOT_ENTRY L"Move entry: "
53 BDS_LOADER_EFI_APPLICATION
= 0,
54 BDS_LOADER_KERNEL_LINUX_ATAG
,
55 BDS_LOADER_KERNEL_LINUX_FDT
,
56 } ARM_BDS_LOADER_TYPE
;
62 // These following fields have variable length and are packed:
64 //EFI_DEVICE_PATH_PROTOCOL *InitrdPathList;
65 } ARM_BDS_LINUX_ARGUMENTS
;
68 ARM_BDS_LINUX_ARGUMENTS LinuxArguments
;
69 } ARM_BDS_LOADER_ARGUMENTS
;
73 ARM_BDS_LOADER_TYPE LoaderType
;
74 } ARM_BDS_LOADER_OPTIONAL_DATA_HEADER
;
77 ARM_BDS_LOADER_OPTIONAL_DATA_HEADER Header
;
78 ARM_BDS_LOADER_ARGUMENTS Arguments
;
79 } ARM_BDS_LOADER_OPTIONAL_DATA
;
83 BDS_LOAD_OPTION
* BdsLoadOption
;
84 } BDS_LOAD_OPTION_ENTRY
;
87 BDS_DEVICE_FILESYSTEM
= 0,
92 } BDS_SUPPORTED_DEVICE_TYPE
;
96 CHAR16 Description
[BOOT_DEVICE_DESCRIPTION_MAX
];
97 EFI_DEVICE_PATH_PROTOCOL
* DevicePathProtocol
;
98 struct _BDS_LOAD_OPTION_SUPPORT
* Support
;
99 } BDS_SUPPORTED_DEVICE
;
101 #define SUPPORTED_BOOT_DEVICE_FROM_LINK(a) BASE_CR(a, BDS_SUPPORTED_DEVICE, Link)
103 typedef struct _BDS_LOAD_OPTION_SUPPORT
{
104 BDS_SUPPORTED_DEVICE_TYPE Type
;
105 EFI_STATUS (*ListDevices
)(IN OUT LIST_ENTRY
* BdsLoadOptionList
);
106 BOOLEAN (*IsSupported
)(IN EFI_DEVICE_PATH
*DevicePath
);
107 EFI_STATUS (*CreateDevicePathNode
)(IN CHAR16
* FileName
, OUT EFI_DEVICE_PATH_PROTOCOL
**DevicePathNodes
);
108 EFI_STATUS (*UpdateDevicePathNode
)(IN EFI_DEVICE_PATH
*OldDevicePath
, IN CHAR16
* FileName
, OUT EFI_DEVICE_PATH_PROTOCOL
** NewDevicePath
);
110 /// Define if the boot menu should request if the file is a EFI binary or a Linux kernel
111 /// Example: PXE boot always deliver a UEFI application.
112 BOOLEAN RequestBootType
;
113 } BDS_LOAD_OPTION_SUPPORT
;
115 #define LOAD_OPTION_ENTRY_FROM_LINK(a) BASE_CR(a, BDS_LOAD_OPTION_ENTRY, Link)
116 #define LOAD_OPTION_FROM_LINK(a) ((BDS_LOAD_OPTION_ENTRY*)BASE_CR(a, BDS_LOAD_OPTION_ENTRY, Link))->BdsLoadOption
119 BootDeviceListSupportedInit (
120 IN OUT LIST_ENTRY
*SupportedDeviceList
124 BootDeviceListSupportedFree (
125 IN LIST_ENTRY
*SupportedDeviceList
,
126 IN BDS_SUPPORTED_DEVICE
*Except
130 BootDeviceGetDeviceSupport (
131 IN EFI_DEVICE_PATH
*DevicePath
,
132 OUT BDS_LOAD_OPTION_SUPPORT
**DeviceSupport
137 IN OUT CHAR16
*CmdLine
,
143 IN OUT CHAR16
*CmdLine
,
149 IN OUT CHAR8
*CmdLine
,
155 IN OUT CHAR8
*CmdLine
,
161 IN OUT UINTN
*Integer
166 OUT EFI_IP_ADDRESS
*Ip
171 IN EFI_IP_ADDRESS
*InIpAddr
,
172 OUT EFI_IP_ADDRESS
*OutIpAddr
181 HasFilePathEfiExtension (
186 GetLastDevicePathNode (
187 IN EFI_DEVICE_PATH
* DevicePath
192 IN CHAR16
* BootOption
196 GetUnalignedDevicePathSize (
197 IN EFI_DEVICE_PATH
* DevicePath
201 GetAlignedDevicePath (
202 IN EFI_DEVICE_PATH
* DevicePath
206 GenerateDeviceDescriptionName (
207 IN EFI_HANDLE Handle
,
208 IN OUT CHAR16
* Description
213 IN OUT LIST_ENTRY
*BootOptionList
217 BootOptionParseLoadOption (
218 IN EFI_LOAD_OPTION EfiLoadOption
,
219 IN UINTN EfiLoadOptionSize
,
220 OUT BDS_LOAD_OPTION
**BdsLoadOption
225 IN BDS_LOAD_OPTION
*BootOption
230 IN UINT32 Attributes
,
231 IN CHAR16
* BootDescription
,
232 IN EFI_DEVICE_PATH_PROTOCOL
* DevicePath
,
233 IN ARM_BDS_LOADER_TYPE BootType
,
234 IN UINT8
* OptionalData
,
235 IN UINTN OptionalDataSize
,
236 OUT BDS_LOAD_OPTION
** BdsLoadOption
241 IN BDS_LOAD_OPTION
* BdsLoadOption
,
242 IN UINT32 Attributes
,
243 IN CHAR16
* BootDescription
,
244 IN EFI_DEVICE_PATH_PROTOCOL
* DevicePath
,
245 IN ARM_BDS_LOADER_TYPE BootType
,
246 IN UINT8
* OptionalData
,
247 IN UINTN OptionalDataSize
252 IN BDS_LOAD_OPTION
*BootOption
257 IN EFI_DEVICE_PATH
* DevicePath
,
258 OUT ARM_BDS_LOADER_TYPE
*BootType
,
259 OUT UINT32
*Attributes
273 * Try to detect if the given string is an ASCII or Unicode string
275 * There are actually few limitation to this function but it is mainly to give
276 * a user friendly output.
279 * - it only supports unicode string that use ASCII character (< 0x100)
280 * - single character ASCII strings are interpreted as Unicode string
281 * - string cannot be longer than 2 x BOOT_DEVICE_OPTION_MAX (600 bytes)
283 * @param String Buffer that might contain a Unicode or Ascii string
284 * @param IsUnicode If not NULL this boolean value returns if the string is an
285 * ASCII or Unicode string.
290 OUT BOOLEAN
*IsUnicode
294 An empty function to pass error checking of CreateEventEx ().
296 @param Event Event whose notification function is being invoked.
297 @param Context Pointer to the notification function's context,
298 which is implementation-dependent.
303 EmptyCallbackFunction (
308 #endif /* _BDSINTERNAL_H_ */