]> git.proxmox.com Git - mirror_edk2.git/blob - ArmPlatformPkg/Bds/BdsInternal.h
ArmPlatformPkg: Print arguments for EFI Application
[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
35 #define BOOT_DEVICE_DESCRIPTION_MAX 100
36 #define BOOT_DEVICE_FILEPATH_MAX 100
37 #define BOOT_DEVICE_OPTION_MAX 300
38 #define BOOT_DEVICE_ADDRESS_MAX (sizeof(L"0x0000000000000000"))
39
40 #define ARM_BDS_OPTIONAL_DATA_SIGNATURE SIGNATURE_32('a', 'b', 'o', 'd')
41
42 #define IS_ARM_BDS_BOOTENTRY(ptr) \
43 (((ptr)->OptionalData != NULL) && \
44 (ReadUnaligned32 ((CONST UINT32*)&((ARM_BDS_LOADER_OPTIONAL_DATA*)((ptr)->OptionalData))->Header.Signature) \
45 == ARM_BDS_OPTIONAL_DATA_SIGNATURE))
46
47 #define UPDATE_BOOT_ENTRY L"Update entry: "
48 #define DELETE_BOOT_ENTRY L"Delete entry: "
49
50 typedef enum {
51 BDS_LOADER_EFI_APPLICATION = 0,
52 BDS_LOADER_KERNEL_LINUX_ATAG,
53 BDS_LOADER_KERNEL_LINUX_FDT,
54 } ARM_BDS_LOADER_TYPE;
55
56 typedef struct {
57 UINT16 CmdLineSize;
58 UINT16 InitrdSize;
59
60 // These following fields have variable length and are packed:
61 //CHAR8 *CmdLine;
62 //EFI_DEVICE_PATH_PROTOCOL *InitrdPathList;
63 } ARM_BDS_LINUX_ARGUMENTS;
64
65 typedef union {
66 ARM_BDS_LINUX_ARGUMENTS LinuxArguments;
67 } ARM_BDS_LOADER_ARGUMENTS;
68
69 typedef struct {
70 UINT32 Signature;
71 ARM_BDS_LOADER_TYPE LoaderType;
72 } ARM_BDS_LOADER_OPTIONAL_DATA_HEADER;
73
74 typedef struct {
75 ARM_BDS_LOADER_OPTIONAL_DATA_HEADER Header;
76 ARM_BDS_LOADER_ARGUMENTS Arguments;
77 } ARM_BDS_LOADER_OPTIONAL_DATA;
78
79 typedef struct {
80 LIST_ENTRY Link;
81 BDS_LOAD_OPTION* BdsLoadOption;
82 } BDS_LOAD_OPTION_ENTRY;
83
84 typedef enum {
85 BDS_DEVICE_FILESYSTEM = 0,
86 BDS_DEVICE_MEMMAP,
87 BDS_DEVICE_PXE,
88 BDS_DEVICE_TFTP,
89 BDS_DEVICE_MAX
90 } BDS_SUPPORTED_DEVICE_TYPE;
91
92 typedef struct {
93 LIST_ENTRY Link;
94 CHAR16 Description[BOOT_DEVICE_DESCRIPTION_MAX];
95 EFI_DEVICE_PATH_PROTOCOL* DevicePathProtocol;
96 struct _BDS_LOAD_OPTION_SUPPORT* Support;
97 } BDS_SUPPORTED_DEVICE;
98
99 #define SUPPORTED_BOOT_DEVICE_FROM_LINK(a) BASE_CR(a, BDS_SUPPORTED_DEVICE, Link)
100
101 typedef struct _BDS_LOAD_OPTION_SUPPORT {
102 BDS_SUPPORTED_DEVICE_TYPE Type;
103 EFI_STATUS (*ListDevices)(IN OUT LIST_ENTRY* BdsLoadOptionList);
104 BOOLEAN (*IsSupported)(IN EFI_DEVICE_PATH *DevicePath);
105 EFI_STATUS (*CreateDevicePathNode)(IN CHAR16* FileName, OUT EFI_DEVICE_PATH_PROTOCOL **DevicePathNodes, OUT BOOLEAN *RequestBootType);
106 EFI_STATUS (*UpdateDevicePathNode)(IN EFI_DEVICE_PATH *OldDevicePath, IN CHAR16* FileName, OUT EFI_DEVICE_PATH_PROTOCOL** NewDevicePath, OUT BOOLEAN *RequestBootType);
107 } BDS_LOAD_OPTION_SUPPORT;
108
109 #define LOAD_OPTION_ENTRY_FROM_LINK(a) BASE_CR(a, BDS_LOAD_OPTION_ENTRY, Link)
110 #define LOAD_OPTION_FROM_LINK(a) ((BDS_LOAD_OPTION_ENTRY*)BASE_CR(a, BDS_LOAD_OPTION_ENTRY, Link))->BdsLoadOption
111
112 EFI_STATUS
113 BootDeviceListSupportedInit (
114 IN OUT LIST_ENTRY *SupportedDeviceList
115 );
116
117 EFI_STATUS
118 BootDeviceListSupportedFree (
119 IN LIST_ENTRY *SupportedDeviceList,
120 IN BDS_SUPPORTED_DEVICE *Except
121 );
122
123 EFI_STATUS
124 BootDeviceGetDeviceSupport (
125 IN EFI_DEVICE_PATH *DevicePath,
126 OUT BDS_LOAD_OPTION_SUPPORT **DeviceSupport
127 );
128
129 EFI_STATUS
130 GetHIInputStr (
131 IN OUT CHAR16 *CmdLine,
132 IN UINTN MaxCmdLine
133 );
134
135 EFI_STATUS
136 EditHIInputStr (
137 IN OUT CHAR16 *CmdLine,
138 IN UINTN MaxCmdLine
139 );
140
141 EFI_STATUS
142 GetHIInputAscii (
143 IN OUT CHAR8 *CmdLine,
144 IN UINTN MaxCmdLine
145 );
146
147 EFI_STATUS
148 EditHIInputAscii (
149 IN OUT CHAR8 *CmdLine,
150 IN UINTN MaxCmdLine
151 );
152
153 EFI_STATUS
154 GetHIInputInteger (
155 IN OUT UINTN *Integer
156 );
157
158 EFI_STATUS
159 GetHIInputIP (
160 OUT EFI_IP_ADDRESS *Ip
161 );
162
163 EFI_STATUS
164 GetHIInputBoolean (
165 OUT BOOLEAN *Value
166 );
167
168 BOOLEAN
169 HasFilePathEfiExtension (
170 IN CHAR16* FilePath
171 );
172
173 EFI_DEVICE_PATH*
174 GetLastDevicePathNode (
175 IN EFI_DEVICE_PATH* DevicePath
176 );
177
178 EFI_STATUS
179 BdsStartBootOption (
180 IN CHAR16* BootOption
181 );
182
183 UINTN
184 GetUnalignedDevicePathSize (
185 IN EFI_DEVICE_PATH* DevicePath
186 );
187
188 EFI_DEVICE_PATH*
189 GetAlignedDevicePath (
190 IN EFI_DEVICE_PATH* DevicePath
191 );
192
193 EFI_STATUS
194 GenerateDeviceDescriptionName (
195 IN EFI_HANDLE Handle,
196 IN OUT CHAR16* Description
197 );
198
199 EFI_STATUS
200 BootOptionList (
201 IN OUT LIST_ENTRY *BootOptionList
202 );
203
204 EFI_STATUS
205 BootOptionParseLoadOption (
206 IN EFI_LOAD_OPTION EfiLoadOption,
207 IN UINTN EfiLoadOptionSize,
208 OUT BDS_LOAD_OPTION **BdsLoadOption
209 );
210
211 EFI_STATUS
212 BootOptionStart (
213 IN BDS_LOAD_OPTION *BootOption
214 );
215
216 EFI_STATUS
217 BootOptionCreate (
218 IN UINT32 Attributes,
219 IN CHAR16* BootDescription,
220 IN EFI_DEVICE_PATH_PROTOCOL* DevicePath,
221 IN ARM_BDS_LOADER_TYPE BootType,
222 IN UINT8* OptionalData,
223 IN UINTN OptionalDataSize,
224 OUT BDS_LOAD_OPTION** BdsLoadOption
225 );
226
227 EFI_STATUS
228 BootOptionUpdate (
229 IN BDS_LOAD_OPTION* BdsLoadOption,
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 );
237
238 EFI_STATUS
239 BootOptionDelete (
240 IN BDS_LOAD_OPTION *BootOption
241 );
242
243 EFI_STATUS
244 BootDeviceGetType (
245 IN EFI_DEVICE_PATH* DevicePath,
246 OUT ARM_BDS_LOADER_TYPE *BootType,
247 OUT UINT32 *Attributes
248 );
249
250 EFI_STATUS
251 BootMenuMain (
252 VOID
253 );
254
255 BOOLEAN
256 IsUnicodeString (
257 IN VOID* String
258 );
259
260 /*
261 * Try to detect if the given string is an ASCII or Unicode string
262 *
263 * There are actually few limitation to this function but it is mainly to give
264 * a user friendly output.
265 *
266 * Some limitations:
267 * - it only supports unicode string that use ASCII character (< 0x100)
268 * - single character ASCII strings are interpreted as Unicode string
269 * - string cannot be longer than 2 x BOOT_DEVICE_OPTION_MAX (600 bytes)
270 *
271 * @param String Buffer that might contain a Unicode or Ascii string
272 * @param IsUnicode If not NULL this boolean value returns if the string is an
273 * ASCII or Unicode string.
274 */
275 BOOLEAN
276 IsPrintableString (
277 IN VOID* String,
278 OUT BOOLEAN *IsUnicode
279 );
280
281 #endif /* _BDSINTERNAL_H_ */