3 * Copyright (c) 2011, 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/BdsUnixLib.h>
22 #include <Library/DebugLib.h>
23 #include <Library/DevicePathLib.h>
24 #include <Library/UefiLib.h>
25 #include <Library/PrintLib.h>
26 #include <Library/PcdLib.h>
27 #include <Library/MemoryAllocationLib.h>
28 #include <Library/UefiBootServicesTableLib.h>
29 #include <Library/UefiRuntimeServicesTableLib.h>
31 #include <Protocol/DevicePathFromText.h>
32 #include <Protocol/DevicePathToText.h>
34 #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 20
42 BDS_LOADER_EFI_APPLICATION
= 0,
43 BDS_LOADER_KERNEL_LINUX_ATAG
,
44 BDS_LOADER_KERNEL_LINUX_FDT
,
48 UINT16 InitrdPathListLength
;
49 EFI_DEVICE_PATH_PROTOCOL
*InitrdPathList
;
50 CHAR8 CmdLine
[BOOT_DEVICE_OPTION_MAX
+ 1];
51 } BDS_LINUX_ATAG_ARGUMENTS
;
54 BDS_LINUX_ATAG_ARGUMENTS LinuxAtagArguments
;
55 } BDS_LOADER_ARGUMENTS
;
58 BDS_LOADER_TYPE LoaderType
;
59 BDS_LOADER_ARGUMENTS Arguments
;
60 } BDS_LOADER_OPTIONAL_DATA
;
63 BDS_DEVICE_FILESYSTEM
= 0,
68 } BDS_SUPPORTED_DEVICE_TYPE
;
72 CHAR16 Description
[BOOT_DEVICE_DESCRIPTION_MAX
];
73 EFI_DEVICE_PATH_PROTOCOL
* DevicePathProtocol
;
74 struct _BDS_LOAD_OPTION_SUPPORT
* Support
;
75 } BDS_SUPPORTED_DEVICE
;
77 #define SUPPORTED_BOOT_DEVICE_FROM_LINK(a) BASE_CR(a, BDS_SUPPORTED_DEVICE, Link)
79 typedef UINT8
* EFI_LOAD_OPTION
;
81 /* This is defined by the UEFI specs, don't change it */
85 UINT16 LoadOptionIndex
;
86 EFI_LOAD_OPTION LoadOption
;
90 UINT16 FilePathListLength
;
92 EFI_DEVICE_PATH_PROTOCOL
*FilePathList
;
93 BDS_LOADER_OPTIONAL_DATA
*OptionalData
;
96 typedef struct _BDS_LOAD_OPTION_SUPPORT
{
97 BDS_SUPPORTED_DEVICE_TYPE Type
;
98 EFI_STATUS (*ListDevices
)(IN OUT LIST_ENTRY
* BdsLoadOptionList
);
99 BOOLEAN (*IsSupported
)(IN BDS_LOAD_OPTION
* BdsLoadOption
);
100 EFI_STATUS (*CreateDevicePathNode
)(IN BDS_SUPPORTED_DEVICE
* BdsLoadOption
, OUT EFI_DEVICE_PATH_PROTOCOL
**DevicePathNode
, OUT BDS_LOADER_TYPE
*BootType
, OUT UINT32
*Attributes
);
101 EFI_STATUS (*UpdateDevicePathNode
)(IN EFI_DEVICE_PATH
*OldDevicePath
, OUT EFI_DEVICE_PATH_PROTOCOL
** NewDevicePath
, OUT BDS_LOADER_TYPE
*BootType
, OUT UINT32
*Attributes
);
102 } BDS_LOAD_OPTION_SUPPORT
;
104 #define LOAD_OPTION_FROM_LINK(a) BASE_CR(a, BDS_LOAD_OPTION, Link)
107 GetEnvironmentVariable (
108 IN CONST CHAR16
* VariableName
,
109 IN VOID
* DefaultValue
,
115 BootDeviceListSupportedInit (
116 IN OUT LIST_ENTRY
*SupportedDeviceList
120 BootDeviceListSupportedFree (
121 IN LIST_ENTRY
*SupportedDeviceList
,
122 IN BDS_SUPPORTED_DEVICE
*Except
126 BootDeviceGetDeviceSupport (
127 IN BDS_LOAD_OPTION
*BootOption
,
128 OUT BDS_LOAD_OPTION_SUPPORT
** DeviceSupport
133 IN OUT CHAR8
*CmdLine
,
139 IN OUT CHAR8
*CmdLine
,
145 IN OUT UINTN
*Integer
150 OUT EFI_IP_ADDRESS
*Ip
159 HasFilePathEfiExtension (
164 GetLastDevicePathNode (
165 IN EFI_DEVICE_PATH
* DevicePath
170 IN CHAR16
* BootOption
174 GenerateDeviceDescriptionName (
175 IN EFI_HANDLE Handle
,
176 IN OUT CHAR16
* Description
181 IN OUT LIST_ENTRY
*BootOptionList
185 BootOptionParseLoadOption (
186 IN EFI_LOAD_OPTION EfiLoadOption
,
187 IN UINTN EfiLoadOptionSize
,
188 OUT BDS_LOAD_OPTION
**BdsLoadOption
193 IN BDS_LOAD_OPTION
*BootOption
198 IN UINT32 Attributes
,
199 IN CHAR16
* BootDescription
,
200 IN EFI_DEVICE_PATH_PROTOCOL
* DevicePath
,
201 IN BDS_LOADER_TYPE BootType
,
202 IN BDS_LOADER_ARGUMENTS
*BootArguments
,
203 OUT BDS_LOAD_OPTION
**BdsLoadOption
208 IN BDS_LOAD_OPTION
*BdsLoadOption
,
209 IN UINT32 Attributes
,
210 IN CHAR16
* BootDescription
,
211 IN EFI_DEVICE_PATH_PROTOCOL
* DevicePath
,
212 IN BDS_LOADER_TYPE BootType
,
213 IN BDS_LOADER_ARGUMENTS
*BootArguments
218 IN BDS_LOAD_OPTION
*BootOption
226 #endif /* _BDSINTERNAL_H_ */