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