]>
Commit | Line | Data |
---|---|---|
ea46ebbe | 1 | /** @file\r |
2 | *\r | |
abc0e107 | 3 | * Copyright (c) 2011-2014, 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 |
2ccfb71e | 41 | #define ARM_BDS_OPTIONAL_DATA_SIGNATURE SIGNATURE_32('a', 'b', 'o', 'd')\r |
42 | \r | |
734b6c33 OM |
43 | #define IS_ARM_BDS_BOOTENTRY(ptr) \\r |
44 | (((ptr)->OptionalData != NULL) && \\r | |
45 | (ReadUnaligned32 ((CONST UINT32*)&((ARM_BDS_LOADER_OPTIONAL_DATA*)((ptr)->OptionalData))->Header.Signature) \\r | |
46 | == ARM_BDS_OPTIONAL_DATA_SIGNATURE))\r | |
2ccfb71e | 47 | \r |
11c20f4e | 48 | #define UPDATE_BOOT_ENTRY L"Update entry: "\r |
49 | #define DELETE_BOOT_ENTRY L"Delete entry: "\r | |
019680b3 | 50 | #define MOVE_BOOT_ENTRY L"Move entry: "\r |
11c20f4e | 51 | \r |
ea46ebbe | 52 | typedef enum {\r |
53 | BDS_LOADER_EFI_APPLICATION = 0,\r | |
54 | BDS_LOADER_KERNEL_LINUX_ATAG,\r | |
55 | BDS_LOADER_KERNEL_LINUX_FDT,\r | |
2ccfb71e | 56 | } ARM_BDS_LOADER_TYPE;\r |
ea46ebbe | 57 | \r |
2ccfb71e | 58 | typedef struct {\r |
59 | UINT16 CmdLineSize;\r | |
60 | UINT16 InitrdSize;\r | |
c0b2e477 | 61 | \r |
2ccfb71e | 62 | // These following fields have variable length and are packed:\r |
63 | //CHAR8 *CmdLine;\r | |
64 | //EFI_DEVICE_PATH_PROTOCOL *InitrdPathList;\r | |
65 | } ARM_BDS_LINUX_ARGUMENTS;\r | |
656416bc | 66 | \r |
67 | typedef union {\r | |
2ccfb71e | 68 | ARM_BDS_LINUX_ARGUMENTS LinuxArguments;\r |
69 | } ARM_BDS_LOADER_ARGUMENTS;\r | |
656416bc | 70 | \r |
ea46ebbe | 71 | typedef struct {\r |
2ccfb71e | 72 | UINT32 Signature;\r |
73 | ARM_BDS_LOADER_TYPE LoaderType;\r | |
74 | } ARM_BDS_LOADER_OPTIONAL_DATA_HEADER;\r | |
75 | \r | |
76 | typedef struct {\r | |
77 | ARM_BDS_LOADER_OPTIONAL_DATA_HEADER Header;\r | |
78 | ARM_BDS_LOADER_ARGUMENTS Arguments;\r | |
79 | } ARM_BDS_LOADER_OPTIONAL_DATA;\r | |
ea46ebbe | 80 | \r |
a6e97d28 | 81 | typedef struct {\r |
82 | LIST_ENTRY Link;\r | |
83 | BDS_LOAD_OPTION* BdsLoadOption;\r | |
84 | } BDS_LOAD_OPTION_ENTRY;\r | |
85 | \r | |
ea46ebbe | 86 | typedef enum {\r |
87 | BDS_DEVICE_FILESYSTEM = 0,\r | |
88 | BDS_DEVICE_MEMMAP,\r | |
89 | BDS_DEVICE_PXE,\r | |
90 | BDS_DEVICE_TFTP,\r | |
91 | BDS_DEVICE_MAX\r | |
92 | } BDS_SUPPORTED_DEVICE_TYPE;\r | |
93 | \r | |
94 | typedef struct {\r | |
793275a8 | 95 | LIST_ENTRY Link;\r |
96 | CHAR16 Description[BOOT_DEVICE_DESCRIPTION_MAX];\r | |
97 | EFI_DEVICE_PATH_PROTOCOL* DevicePathProtocol;\r | |
ea46ebbe | 98 | struct _BDS_LOAD_OPTION_SUPPORT* Support;\r |
99 | } BDS_SUPPORTED_DEVICE;\r | |
100 | \r | |
101 | #define SUPPORTED_BOOT_DEVICE_FROM_LINK(a) BASE_CR(a, BDS_SUPPORTED_DEVICE, Link)\r | |
102 | \r | |
ea46ebbe | 103 | typedef struct _BDS_LOAD_OPTION_SUPPORT {\r |
104 | BDS_SUPPORTED_DEVICE_TYPE Type;\r | |
105 | EFI_STATUS (*ListDevices)(IN OUT LIST_ENTRY* BdsLoadOptionList);\r | |
22a262c8 | 106 | BOOLEAN (*IsSupported)(IN EFI_DEVICE_PATH *DevicePath);\r |
889ac6a8 RC |
107 | EFI_STATUS (*CreateDevicePathNode)(IN CHAR16* FileName, OUT EFI_DEVICE_PATH_PROTOCOL **DevicePathNodes);\r |
108 | EFI_STATUS (*UpdateDevicePathNode)(IN EFI_DEVICE_PATH *OldDevicePath, IN CHAR16* FileName, OUT EFI_DEVICE_PATH_PROTOCOL** NewDevicePath);\r | |
109 | \r | |
110 | /// Define if the boot menu should request if the file is a EFI binary or a Linux kernel\r | |
111 | /// Example: PXE boot always deliver a UEFI application.\r | |
112 | BOOLEAN RequestBootType;\r | |
ea46ebbe | 113 | } BDS_LOAD_OPTION_SUPPORT;\r |
114 | \r | |
a6e97d28 | 115 | #define LOAD_OPTION_ENTRY_FROM_LINK(a) BASE_CR(a, BDS_LOAD_OPTION_ENTRY, Link)\r |
116 | #define LOAD_OPTION_FROM_LINK(a) ((BDS_LOAD_OPTION_ENTRY*)BASE_CR(a, BDS_LOAD_OPTION_ENTRY, Link))->BdsLoadOption\r | |
ea46ebbe | 117 | \r |
ea46ebbe | 118 | EFI_STATUS\r |
119 | BootDeviceListSupportedInit (\r | |
120 | IN OUT LIST_ENTRY *SupportedDeviceList\r | |
121 | );\r | |
122 | \r | |
123 | EFI_STATUS\r | |
124 | BootDeviceListSupportedFree (\r | |
656416bc | 125 | IN LIST_ENTRY *SupportedDeviceList,\r |
126 | IN BDS_SUPPORTED_DEVICE *Except\r | |
ea46ebbe | 127 | );\r |
128 | \r | |
129 | EFI_STATUS\r | |
130 | BootDeviceGetDeviceSupport (\r | |
22a262c8 | 131 | IN EFI_DEVICE_PATH *DevicePath,\r |
132 | OUT BDS_LOAD_OPTION_SUPPORT **DeviceSupport\r | |
ea46ebbe | 133 | );\r |
134 | \r | |
74b96132 | 135 | EFI_STATUS\r |
136 | GetHIInputStr (\r | |
137 | IN OUT CHAR16 *CmdLine,\r | |
138 | IN UINTN MaxCmdLine\r | |
139 | );\r | |
140 | \r | |
141 | EFI_STATUS\r | |
142 | EditHIInputStr (\r | |
143 | IN OUT CHAR16 *CmdLine,\r | |
144 | IN UINTN MaxCmdLine\r | |
145 | );\r | |
146 | \r | |
ea46ebbe | 147 | EFI_STATUS\r |
148 | GetHIInputAscii (\r | |
149 | IN OUT CHAR8 *CmdLine,\r | |
150 | IN UINTN MaxCmdLine\r | |
151 | );\r | |
152 | \r | |
153 | EFI_STATUS\r | |
154 | EditHIInputAscii (\r | |
155 | IN OUT CHAR8 *CmdLine,\r | |
156 | IN UINTN MaxCmdLine\r | |
157 | );\r | |
158 | \r | |
159 | EFI_STATUS\r | |
160 | GetHIInputInteger (\r | |
161 | IN OUT UINTN *Integer\r | |
162 | );\r | |
163 | \r | |
164 | EFI_STATUS\r | |
165 | GetHIInputIP (\r | |
166 | OUT EFI_IP_ADDRESS *Ip\r | |
167 | );\r | |
168 | \r | |
8bf4ad44 RC |
169 | EFI_STATUS\r |
170 | EditHIInputIP (\r | |
171 | IN EFI_IP_ADDRESS *InIpAddr,\r | |
172 | OUT EFI_IP_ADDRESS *OutIpAddr\r | |
173 | );\r | |
174 | \r | |
ea46ebbe | 175 | EFI_STATUS\r |
176 | GetHIInputBoolean (\r | |
177 | OUT BOOLEAN *Value\r | |
178 | );\r | |
179 | \r | |
180 | BOOLEAN\r | |
181 | HasFilePathEfiExtension (\r | |
182 | IN CHAR16* FilePath\r | |
183 | );\r | |
184 | \r | |
185 | EFI_DEVICE_PATH*\r | |
186 | GetLastDevicePathNode (\r | |
187 | IN EFI_DEVICE_PATH* DevicePath\r | |
188 | );\r | |
189 | \r | |
190 | EFI_STATUS\r | |
191 | BdsStartBootOption (\r | |
192 | IN CHAR16* BootOption\r | |
193 | );\r | |
194 | \r | |
2ccfb71e | 195 | UINTN\r |
196 | GetUnalignedDevicePathSize (\r | |
197 | IN EFI_DEVICE_PATH* DevicePath\r | |
198 | );\r | |
199 | \r | |
200 | EFI_DEVICE_PATH*\r | |
201 | GetAlignedDevicePath (\r | |
202 | IN EFI_DEVICE_PATH* DevicePath\r | |
203 | );\r | |
204 | \r | |
ea46ebbe | 205 | EFI_STATUS\r |
206 | GenerateDeviceDescriptionName (\r | |
207 | IN EFI_HANDLE Handle,\r | |
208 | IN OUT CHAR16* Description\r | |
209 | );\r | |
210 | \r | |
211 | EFI_STATUS\r | |
212 | BootOptionList (\r | |
213 | IN OUT LIST_ENTRY *BootOptionList\r | |
214 | );\r | |
215 | \r | |
216 | EFI_STATUS\r | |
217 | BootOptionParseLoadOption (\r | |
218 | IN EFI_LOAD_OPTION EfiLoadOption,\r | |
219 | IN UINTN EfiLoadOptionSize,\r | |
220 | OUT BDS_LOAD_OPTION **BdsLoadOption\r | |
221 | );\r | |
222 | \r | |
223 | EFI_STATUS\r | |
224 | BootOptionStart (\r | |
225 | IN BDS_LOAD_OPTION *BootOption\r | |
226 | );\r | |
227 | \r | |
228 | EFI_STATUS\r | |
229 | BootOptionCreate (\r | |
2ccfb71e | 230 | IN UINT32 Attributes,\r |
231 | IN CHAR16* BootDescription,\r | |
ea46ebbe | 232 | IN EFI_DEVICE_PATH_PROTOCOL* DevicePath,\r |
2ccfb71e | 233 | IN ARM_BDS_LOADER_TYPE BootType,\r |
90a44ec4 OM |
234 | IN UINT8* OptionalData,\r |
235 | IN UINTN OptionalDataSize,\r | |
2ccfb71e | 236 | OUT BDS_LOAD_OPTION** BdsLoadOption\r |
ea46ebbe | 237 | );\r |
238 | \r | |
239 | EFI_STATUS\r | |
240 | BootOptionUpdate (\r | |
2ccfb71e | 241 | IN BDS_LOAD_OPTION* BdsLoadOption,\r |
242 | IN UINT32 Attributes,\r | |
243 | IN CHAR16* BootDescription,\r | |
ea46ebbe | 244 | IN EFI_DEVICE_PATH_PROTOCOL* DevicePath,\r |
2ccfb71e | 245 | IN ARM_BDS_LOADER_TYPE BootType,\r |
90a44ec4 OM |
246 | IN UINT8* OptionalData,\r |
247 | IN UINTN OptionalDataSize\r | |
ea46ebbe | 248 | );\r |
249 | \r | |
250 | EFI_STATUS\r | |
251 | BootOptionDelete (\r | |
252 | IN BDS_LOAD_OPTION *BootOption\r | |
253 | );\r | |
254 | \r | |
55a9f75d OM |
255 | EFI_STATUS\r |
256 | BootDeviceGetType (\r | |
257 | IN EFI_DEVICE_PATH* DevicePath,\r | |
258 | OUT ARM_BDS_LOADER_TYPE *BootType,\r | |
259 | OUT UINT32 *Attributes\r | |
260 | );\r | |
261 | \r | |
ea46ebbe | 262 | EFI_STATUS\r |
263 | BootMenuMain (\r | |
264 | VOID\r | |
265 | );\r | |
266 | \r | |
9fc9aa46 OM |
267 | BOOLEAN\r |
268 | IsUnicodeString (\r | |
269 | IN VOID* String\r | |
270 | );\r | |
271 | \r | |
135b09a2 OM |
272 | /*\r |
273 | * Try to detect if the given string is an ASCII or Unicode string\r | |
274 | *\r | |
275 | * There are actually few limitation to this function but it is mainly to give\r | |
276 | * a user friendly output.\r | |
277 | *\r | |
278 | * Some limitations:\r | |
279 | * - it only supports unicode string that use ASCII character (< 0x100)\r | |
280 | * - single character ASCII strings are interpreted as Unicode string\r | |
281 | * - string cannot be longer than 2 x BOOT_DEVICE_OPTION_MAX (600 bytes)\r | |
282 | *\r | |
283 | * @param String Buffer that might contain a Unicode or Ascii string\r | |
284 | * @param IsUnicode If not NULL this boolean value returns if the string is an\r | |
285 | * ASCII or Unicode string.\r | |
286 | */\r | |
287 | BOOLEAN\r | |
288 | IsPrintableString (\r | |
289 | IN VOID* String,\r | |
290 | OUT BOOLEAN *IsUnicode\r | |
291 | );\r | |
292 | \r | |
5c2d456b OM |
293 | /**\r |
294 | An empty function to pass error checking of CreateEventEx ().\r | |
295 | \r | |
296 | @param Event Event whose notification function is being invoked.\r | |
297 | @param Context Pointer to the notification function's context,\r | |
298 | which is implementation-dependent.\r | |
299 | \r | |
300 | **/\r | |
301 | VOID\r | |
302 | EFIAPI\r | |
303 | EmptyCallbackFunction (\r | |
304 | IN EFI_EVENT Event,\r | |
305 | IN VOID *Context\r | |
306 | );\r | |
307 | \r | |
ea46ebbe | 308 | #endif /* _BDSINTERNAL_H_ */\r |