]> git.proxmox.com Git - mirror_edk2.git/blob - ArmPlatformPkg/Bds/BdsInternal.h
PcAtChipsetPkg: PciHostBridgeDxe: rewrap IoFifo source files to 79 columns
[mirror_edk2.git] / ArmPlatformPkg / Bds / BdsInternal.h
1 /** @file
2 *
3 * Copyright (c) 2011-2014, ARM Limited. All rights reserved.
4 *
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
9 *
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.
12 *
13 **/
14
15 #ifndef _BDSINTERNAL_H_
16 #define _BDSINTERNAL_H_
17
18 #include <PiDxe.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>
29
30 #include <Protocol/DevicePathFromText.h>
31 #include <Protocol/DevicePathToText.h>
32
33 #include <Guid/GlobalVariable.h>
34 #include <Guid/Fdt.h>
35
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"))
40
41 #define ARM_BDS_OPTIONAL_DATA_SIGNATURE SIGNATURE_32('a', 'b', 'o', 'd')
42
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))
47
48 #define UPDATE_BOOT_ENTRY L"Update entry: "
49 #define DELETE_BOOT_ENTRY L"Delete entry: "
50 #define MOVE_BOOT_ENTRY L"Move entry: "
51
52 typedef enum {
53 BDS_LOADER_EFI_APPLICATION = 0,
54 BDS_LOADER_KERNEL_LINUX_ATAG,
55 BDS_LOADER_KERNEL_LINUX_FDT,
56 } ARM_BDS_LOADER_TYPE;
57
58 typedef struct {
59 UINT16 CmdLineSize;
60 UINT16 InitrdSize;
61
62 // These following fields have variable length and are packed:
63 //CHAR8 *CmdLine;
64 //EFI_DEVICE_PATH_PROTOCOL *InitrdPathList;
65 } ARM_BDS_LINUX_ARGUMENTS;
66
67 typedef union {
68 ARM_BDS_LINUX_ARGUMENTS LinuxArguments;
69 } ARM_BDS_LOADER_ARGUMENTS;
70
71 typedef struct {
72 UINT32 Signature;
73 ARM_BDS_LOADER_TYPE LoaderType;
74 } ARM_BDS_LOADER_OPTIONAL_DATA_HEADER;
75
76 typedef struct {
77 ARM_BDS_LOADER_OPTIONAL_DATA_HEADER Header;
78 ARM_BDS_LOADER_ARGUMENTS Arguments;
79 } ARM_BDS_LOADER_OPTIONAL_DATA;
80
81 typedef struct {
82 LIST_ENTRY Link;
83 BDS_LOAD_OPTION* BdsLoadOption;
84 } BDS_LOAD_OPTION_ENTRY;
85
86 typedef enum {
87 BDS_DEVICE_FILESYSTEM = 0,
88 BDS_DEVICE_MEMMAP,
89 BDS_DEVICE_PXE,
90 BDS_DEVICE_TFTP,
91 BDS_DEVICE_MAX
92 } BDS_SUPPORTED_DEVICE_TYPE;
93
94 typedef struct {
95 LIST_ENTRY Link;
96 CHAR16 Description[BOOT_DEVICE_DESCRIPTION_MAX];
97 EFI_DEVICE_PATH_PROTOCOL* DevicePathProtocol;
98 struct _BDS_LOAD_OPTION_SUPPORT* Support;
99 } BDS_SUPPORTED_DEVICE;
100
101 #define SUPPORTED_BOOT_DEVICE_FROM_LINK(a) BASE_CR(a, BDS_SUPPORTED_DEVICE, Link)
102
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);
109
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;
114
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
117
118 EFI_STATUS
119 BootDeviceListSupportedInit (
120 IN OUT LIST_ENTRY *SupportedDeviceList
121 );
122
123 EFI_STATUS
124 BootDeviceListSupportedFree (
125 IN LIST_ENTRY *SupportedDeviceList,
126 IN BDS_SUPPORTED_DEVICE *Except
127 );
128
129 EFI_STATUS
130 BootDeviceGetDeviceSupport (
131 IN EFI_DEVICE_PATH *DevicePath,
132 OUT BDS_LOAD_OPTION_SUPPORT **DeviceSupport
133 );
134
135 EFI_STATUS
136 GetHIInputStr (
137 IN OUT CHAR16 *CmdLine,
138 IN UINTN MaxCmdLine
139 );
140
141 EFI_STATUS
142 EditHIInputStr (
143 IN OUT CHAR16 *CmdLine,
144 IN UINTN MaxCmdLine
145 );
146
147 EFI_STATUS
148 GetHIInputAscii (
149 IN OUT CHAR8 *CmdLine,
150 IN UINTN MaxCmdLine
151 );
152
153 EFI_STATUS
154 EditHIInputAscii (
155 IN OUT CHAR8 *CmdLine,
156 IN UINTN MaxCmdLine
157 );
158
159 EFI_STATUS
160 GetHIInputInteger (
161 IN OUT UINTN *Integer
162 );
163
164 EFI_STATUS
165 GetHIInputIP (
166 OUT EFI_IP_ADDRESS *Ip
167 );
168
169 EFI_STATUS
170 EditHIInputIP (
171 IN EFI_IP_ADDRESS *InIpAddr,
172 OUT EFI_IP_ADDRESS *OutIpAddr
173 );
174
175 EFI_STATUS
176 GetHIInputBoolean (
177 OUT BOOLEAN *Value
178 );
179
180 BOOLEAN
181 HasFilePathEfiExtension (
182 IN CHAR16* FilePath
183 );
184
185 EFI_DEVICE_PATH*
186 GetLastDevicePathNode (
187 IN EFI_DEVICE_PATH* DevicePath
188 );
189
190 EFI_STATUS
191 BdsStartBootOption (
192 IN CHAR16* BootOption
193 );
194
195 UINTN
196 GetUnalignedDevicePathSize (
197 IN EFI_DEVICE_PATH* DevicePath
198 );
199
200 EFI_DEVICE_PATH*
201 GetAlignedDevicePath (
202 IN EFI_DEVICE_PATH* DevicePath
203 );
204
205 EFI_STATUS
206 GenerateDeviceDescriptionName (
207 IN EFI_HANDLE Handle,
208 IN OUT CHAR16* Description
209 );
210
211 EFI_STATUS
212 BootOptionList (
213 IN OUT LIST_ENTRY *BootOptionList
214 );
215
216 EFI_STATUS
217 BootOptionParseLoadOption (
218 IN EFI_LOAD_OPTION EfiLoadOption,
219 IN UINTN EfiLoadOptionSize,
220 OUT BDS_LOAD_OPTION **BdsLoadOption
221 );
222
223 EFI_STATUS
224 BootOptionStart (
225 IN BDS_LOAD_OPTION *BootOption
226 );
227
228 EFI_STATUS
229 BootOptionCreate (
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
237 );
238
239 EFI_STATUS
240 BootOptionUpdate (
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
248 );
249
250 EFI_STATUS
251 BootOptionDelete (
252 IN BDS_LOAD_OPTION *BootOption
253 );
254
255 EFI_STATUS
256 BootDeviceGetType (
257 IN EFI_DEVICE_PATH* DevicePath,
258 OUT ARM_BDS_LOADER_TYPE *BootType,
259 OUT UINT32 *Attributes
260 );
261
262 EFI_STATUS
263 BootMenuMain (
264 VOID
265 );
266
267 BOOLEAN
268 IsUnicodeString (
269 IN VOID* String
270 );
271
272 /*
273 * Try to detect if the given string is an ASCII or Unicode string
274 *
275 * There are actually few limitation to this function but it is mainly to give
276 * a user friendly output.
277 *
278 * Some limitations:
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)
282 *
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.
286 */
287 BOOLEAN
288 IsPrintableString (
289 IN VOID* String,
290 OUT BOOLEAN *IsUnicode
291 );
292
293 /**
294 An empty function to pass error checking of CreateEventEx ().
295
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.
299
300 **/
301 VOID
302 EFIAPI
303 EmptyCallbackFunction (
304 IN EFI_EVENT Event,
305 IN VOID *Context
306 );
307
308 #endif /* _BDSINTERNAL_H_ */