]>
Commit | Line | Data |
---|---|---|
ea46ebbe | 1 | /** @file\r |
2 | *\r | |
5d9e9d1a | 3 | * Copyright (c) 2011-2015, ARM Limited. All rights reserved.\r |
ea46ebbe | 4 | *\r |
5 | * This program and the accompanying materials\r | |
6 | * are licensed and made available under the terms and conditions of the BSD License\r | |
7 | * which accompanies this distribution. The full text of the license may be found at\r | |
8 | * http://opensource.org/licenses/bsd-license.php\r | |
9 | *\r | |
10 | * THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
11 | * WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
12 | *\r | |
13 | **/\r | |
14 | \r | |
15 | #ifndef _BDSINTERNAL_H_\r | |
16 | #define _BDSINTERNAL_H_\r | |
17 | \r | |
18 | #include <PiDxe.h>\r | |
19 | #include <Library/BaseMemoryLib.h>\r | |
20 | #include <Library/BdsLib.h>\r | |
ea46ebbe | 21 | #include <Library/DebugLib.h>\r |
22 | #include <Library/DevicePathLib.h>\r | |
23 | #include <Library/UefiLib.h>\r | |
24 | #include <Library/PrintLib.h>\r | |
25 | #include <Library/PcdLib.h>\r | |
26 | #include <Library/MemoryAllocationLib.h>\r | |
27 | #include <Library/UefiBootServicesTableLib.h>\r | |
28 | #include <Library/UefiRuntimeServicesTableLib.h>\r | |
29 | \r | |
30 | #include <Protocol/DevicePathFromText.h>\r | |
31 | #include <Protocol/DevicePathToText.h>\r | |
32 | \r | |
33 | #include <Guid/GlobalVariable.h>\r | |
0ae6a518 | 34 | #include <Guid/Fdt.h>\r |
ea46ebbe | 35 | \r |
36 | #define BOOT_DEVICE_DESCRIPTION_MAX 100\r | |
37 | #define BOOT_DEVICE_FILEPATH_MAX 100\r | |
656416bc | 38 | #define BOOT_DEVICE_OPTION_MAX 300\r |
e34114ea | 39 | #define BOOT_DEVICE_ADDRESS_MAX (sizeof(L"0x0000000000000000"))\r |
ea46ebbe | 40 | \r |
11c20f4e | 41 | #define UPDATE_BOOT_ENTRY L"Update entry: "\r |
42 | #define DELETE_BOOT_ENTRY L"Delete entry: "\r | |
019680b3 | 43 | #define MOVE_BOOT_ENTRY L"Move entry: "\r |
11c20f4e | 44 | \r |
a6e97d28 | 45 | typedef struct {\r |
46 | LIST_ENTRY Link;\r | |
47 | BDS_LOAD_OPTION* BdsLoadOption;\r | |
48 | } BDS_LOAD_OPTION_ENTRY;\r | |
49 | \r | |
ea46ebbe | 50 | typedef enum {\r |
51 | BDS_DEVICE_FILESYSTEM = 0,\r | |
52 | BDS_DEVICE_MEMMAP,\r | |
53 | BDS_DEVICE_PXE,\r | |
54 | BDS_DEVICE_TFTP,\r | |
55 | BDS_DEVICE_MAX\r | |
56 | } BDS_SUPPORTED_DEVICE_TYPE;\r | |
57 | \r | |
58 | typedef struct {\r | |
793275a8 | 59 | LIST_ENTRY Link;\r |
60 | CHAR16 Description[BOOT_DEVICE_DESCRIPTION_MAX];\r | |
61 | EFI_DEVICE_PATH_PROTOCOL* DevicePathProtocol;\r | |
ea46ebbe | 62 | struct _BDS_LOAD_OPTION_SUPPORT* Support;\r |
63 | } BDS_SUPPORTED_DEVICE;\r | |
64 | \r | |
65 | #define SUPPORTED_BOOT_DEVICE_FROM_LINK(a) BASE_CR(a, BDS_SUPPORTED_DEVICE, Link)\r | |
66 | \r | |
ea46ebbe | 67 | typedef struct _BDS_LOAD_OPTION_SUPPORT {\r |
68 | BDS_SUPPORTED_DEVICE_TYPE Type;\r | |
69 | EFI_STATUS (*ListDevices)(IN OUT LIST_ENTRY* BdsLoadOptionList);\r | |
22a262c8 | 70 | BOOLEAN (*IsSupported)(IN EFI_DEVICE_PATH *DevicePath);\r |
889ac6a8 RC |
71 | EFI_STATUS (*CreateDevicePathNode)(IN CHAR16* FileName, OUT EFI_DEVICE_PATH_PROTOCOL **DevicePathNodes);\r |
72 | EFI_STATUS (*UpdateDevicePathNode)(IN EFI_DEVICE_PATH *OldDevicePath, IN CHAR16* FileName, OUT EFI_DEVICE_PATH_PROTOCOL** NewDevicePath);\r | |
73 | \r | |
74 | /// Define if the boot menu should request if the file is a EFI binary or a Linux kernel\r | |
75 | /// Example: PXE boot always deliver a UEFI application.\r | |
76 | BOOLEAN RequestBootType;\r | |
ea46ebbe | 77 | } BDS_LOAD_OPTION_SUPPORT;\r |
78 | \r | |
a6e97d28 | 79 | #define LOAD_OPTION_ENTRY_FROM_LINK(a) BASE_CR(a, BDS_LOAD_OPTION_ENTRY, Link)\r |
80 | #define LOAD_OPTION_FROM_LINK(a) ((BDS_LOAD_OPTION_ENTRY*)BASE_CR(a, BDS_LOAD_OPTION_ENTRY, Link))->BdsLoadOption\r | |
ea46ebbe | 81 | \r |
5d9e9d1a OM |
82 | // GUID of the EFI Linux Loader\r |
83 | extern CONST EFI_GUID mLinuxLoaderAppGuid;\r | |
84 | \r | |
85 | // Device path of the EFI Linux Loader in the Firmware Volume\r | |
86 | extern EFI_DEVICE_PATH* mLinuxLoaderDevicePath;\r | |
87 | \r | |
ea46ebbe | 88 | EFI_STATUS\r |
89 | BootDeviceListSupportedInit (\r | |
90 | IN OUT LIST_ENTRY *SupportedDeviceList\r | |
91 | );\r | |
92 | \r | |
93 | EFI_STATUS\r | |
94 | BootDeviceListSupportedFree (\r | |
656416bc | 95 | IN LIST_ENTRY *SupportedDeviceList,\r |
96 | IN BDS_SUPPORTED_DEVICE *Except\r | |
ea46ebbe | 97 | );\r |
98 | \r | |
99 | EFI_STATUS\r | |
100 | BootDeviceGetDeviceSupport (\r | |
22a262c8 | 101 | IN EFI_DEVICE_PATH *DevicePath,\r |
102 | OUT BDS_LOAD_OPTION_SUPPORT **DeviceSupport\r | |
ea46ebbe | 103 | );\r |
104 | \r | |
74b96132 | 105 | EFI_STATUS\r |
106 | GetHIInputStr (\r | |
107 | IN OUT CHAR16 *CmdLine,\r | |
108 | IN UINTN MaxCmdLine\r | |
109 | );\r | |
110 | \r | |
111 | EFI_STATUS\r | |
112 | EditHIInputStr (\r | |
113 | IN OUT CHAR16 *CmdLine,\r | |
114 | IN UINTN MaxCmdLine\r | |
115 | );\r | |
116 | \r | |
ea46ebbe | 117 | EFI_STATUS\r |
118 | GetHIInputAscii (\r | |
119 | IN OUT CHAR8 *CmdLine,\r | |
120 | IN UINTN MaxCmdLine\r | |
121 | );\r | |
122 | \r | |
123 | EFI_STATUS\r | |
124 | EditHIInputAscii (\r | |
125 | IN OUT CHAR8 *CmdLine,\r | |
126 | IN UINTN MaxCmdLine\r | |
127 | );\r | |
128 | \r | |
129 | EFI_STATUS\r | |
130 | GetHIInputInteger (\r | |
131 | IN OUT UINTN *Integer\r | |
132 | );\r | |
133 | \r | |
134 | EFI_STATUS\r | |
135 | GetHIInputIP (\r | |
136 | OUT EFI_IP_ADDRESS *Ip\r | |
137 | );\r | |
138 | \r | |
8bf4ad44 RC |
139 | EFI_STATUS\r |
140 | EditHIInputIP (\r | |
141 | IN EFI_IP_ADDRESS *InIpAddr,\r | |
142 | OUT EFI_IP_ADDRESS *OutIpAddr\r | |
143 | );\r | |
144 | \r | |
ea46ebbe | 145 | EFI_STATUS\r |
146 | GetHIInputBoolean (\r | |
147 | OUT BOOLEAN *Value\r | |
148 | );\r | |
149 | \r | |
ea46ebbe | 150 | EFI_DEVICE_PATH*\r |
151 | GetLastDevicePathNode (\r | |
152 | IN EFI_DEVICE_PATH* DevicePath\r | |
153 | );\r | |
154 | \r | |
155 | EFI_STATUS\r | |
156 | BdsStartBootOption (\r | |
157 | IN CHAR16* BootOption\r | |
158 | );\r | |
159 | \r | |
2ccfb71e | 160 | UINTN\r |
161 | GetUnalignedDevicePathSize (\r | |
162 | IN EFI_DEVICE_PATH* DevicePath\r | |
163 | );\r | |
164 | \r | |
165 | EFI_DEVICE_PATH*\r | |
166 | GetAlignedDevicePath (\r | |
167 | IN EFI_DEVICE_PATH* DevicePath\r | |
168 | );\r | |
169 | \r | |
ea46ebbe | 170 | EFI_STATUS\r |
171 | GenerateDeviceDescriptionName (\r | |
172 | IN EFI_HANDLE Handle,\r | |
173 | IN OUT CHAR16* Description\r | |
174 | );\r | |
175 | \r | |
176 | EFI_STATUS\r | |
177 | BootOptionList (\r | |
178 | IN OUT LIST_ENTRY *BootOptionList\r | |
179 | );\r | |
180 | \r | |
181 | EFI_STATUS\r | |
182 | BootOptionParseLoadOption (\r | |
183 | IN EFI_LOAD_OPTION EfiLoadOption,\r | |
184 | IN UINTN EfiLoadOptionSize,\r | |
185 | OUT BDS_LOAD_OPTION **BdsLoadOption\r | |
186 | );\r | |
187 | \r | |
188 | EFI_STATUS\r | |
189 | BootOptionStart (\r | |
190 | IN BDS_LOAD_OPTION *BootOption\r | |
191 | );\r | |
192 | \r | |
193 | EFI_STATUS\r | |
194 | BootOptionCreate (\r | |
2ccfb71e | 195 | IN UINT32 Attributes,\r |
196 | IN CHAR16* BootDescription,\r | |
ea46ebbe | 197 | IN EFI_DEVICE_PATH_PROTOCOL* DevicePath,\r |
90a44ec4 OM |
198 | IN UINT8* OptionalData,\r |
199 | IN UINTN OptionalDataSize,\r | |
2ccfb71e | 200 | OUT BDS_LOAD_OPTION** BdsLoadOption\r |
ea46ebbe | 201 | );\r |
202 | \r | |
203 | EFI_STATUS\r | |
204 | BootOptionUpdate (\r | |
2ccfb71e | 205 | IN BDS_LOAD_OPTION* BdsLoadOption,\r |
206 | IN UINT32 Attributes,\r | |
207 | IN CHAR16* BootDescription,\r | |
ea46ebbe | 208 | IN EFI_DEVICE_PATH_PROTOCOL* DevicePath,\r |
90a44ec4 OM |
209 | IN UINT8* OptionalData,\r |
210 | IN UINTN OptionalDataSize\r | |
ea46ebbe | 211 | );\r |
212 | \r | |
213 | EFI_STATUS\r | |
214 | BootOptionDelete (\r | |
215 | IN BDS_LOAD_OPTION *BootOption\r | |
216 | );\r | |
217 | \r | |
218 | EFI_STATUS\r | |
219 | BootMenuMain (\r | |
220 | VOID\r | |
221 | );\r | |
222 | \r | |
9fc9aa46 OM |
223 | BOOLEAN\r |
224 | IsUnicodeString (\r | |
225 | IN VOID* String\r | |
226 | );\r | |
227 | \r | |
135b09a2 OM |
228 | /*\r |
229 | * Try to detect if the given string is an ASCII or Unicode string\r | |
230 | *\r | |
231 | * There are actually few limitation to this function but it is mainly to give\r | |
232 | * a user friendly output.\r | |
233 | *\r | |
234 | * Some limitations:\r | |
235 | * - it only supports unicode string that use ASCII character (< 0x100)\r | |
236 | * - single character ASCII strings are interpreted as Unicode string\r | |
237 | * - string cannot be longer than 2 x BOOT_DEVICE_OPTION_MAX (600 bytes)\r | |
238 | *\r | |
239 | * @param String Buffer that might contain a Unicode or Ascii string\r | |
240 | * @param IsUnicode If not NULL this boolean value returns if the string is an\r | |
241 | * ASCII or Unicode string.\r | |
242 | */\r | |
243 | BOOLEAN\r | |
244 | IsPrintableString (\r | |
245 | IN VOID* String,\r | |
246 | OUT BOOLEAN *IsUnicode\r | |
247 | );\r | |
248 | \r | |
5c2d456b OM |
249 | /**\r |
250 | An empty function to pass error checking of CreateEventEx ().\r | |
251 | \r | |
252 | @param Event Event whose notification function is being invoked.\r | |
253 | @param Context Pointer to the notification function's context,\r | |
254 | which is implementation-dependent.\r | |
255 | \r | |
256 | **/\r | |
257 | VOID\r | |
258 | EFIAPI\r | |
259 | EmptyCallbackFunction (\r | |
260 | IN EFI_EVENT Event,\r | |
261 | IN VOID *Context\r | |
262 | );\r | |
263 | \r | |
5d9e9d1a OM |
264 | /**\r |
265 | * This function check if the DevicePath defines an EFI binary\r | |
266 | *\r | |
267 | * This function is used when the BDS support Linux loader to\r | |
268 | * detect if the binary is an EFI application or potentially a\r | |
269 | * Linux kernel.\r | |
270 | */\r | |
271 | EFI_STATUS\r | |
272 | IsEfiBinary (\r | |
273 | IN EFI_DEVICE_PATH* DevicePath,\r | |
274 | OUT BOOLEAN *EfiBinary\r | |
275 | );\r | |
276 | \r | |
ea46ebbe | 277 | #endif /* _BDSINTERNAL_H_ */\r |