]> git.proxmox.com Git - mirror_edk2.git/blob - ArmPlatformPkg/Bds/BdsInternal.h
ddf5308e8b234d7ff5a75a5c8b823f5bd66a4358
[mirror_edk2.git] / ArmPlatformPkg / Bds / BdsInternal.h
1 /** @file
2 *
3 * Copyright (c) 2011-2015, 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 UPDATE_BOOT_ENTRY L"Update entry: "
42 #define DELETE_BOOT_ENTRY L"Delete entry: "
43 #define MOVE_BOOT_ENTRY L"Move entry: "
44
45 typedef struct {
46 LIST_ENTRY Link;
47 BDS_LOAD_OPTION* BdsLoadOption;
48 } BDS_LOAD_OPTION_ENTRY;
49
50 typedef enum {
51 BDS_DEVICE_FILESYSTEM = 0,
52 BDS_DEVICE_MEMMAP,
53 BDS_DEVICE_PXE,
54 BDS_DEVICE_TFTP,
55 BDS_DEVICE_MAX
56 } BDS_SUPPORTED_DEVICE_TYPE;
57
58 typedef struct {
59 LIST_ENTRY Link;
60 CHAR16 Description[BOOT_DEVICE_DESCRIPTION_MAX];
61 EFI_DEVICE_PATH_PROTOCOL* DevicePathProtocol;
62 struct _BDS_LOAD_OPTION_SUPPORT* Support;
63 } BDS_SUPPORTED_DEVICE;
64
65 #define SUPPORTED_BOOT_DEVICE_FROM_LINK(a) BASE_CR(a, BDS_SUPPORTED_DEVICE, Link)
66
67 typedef struct _BDS_LOAD_OPTION_SUPPORT {
68 BDS_SUPPORTED_DEVICE_TYPE Type;
69 EFI_STATUS (*ListDevices)(IN OUT LIST_ENTRY* BdsLoadOptionList);
70 BOOLEAN (*IsSupported)(IN EFI_DEVICE_PATH *DevicePath);
71 EFI_STATUS (*CreateDevicePathNode)(IN CHAR16* FileName, OUT EFI_DEVICE_PATH_PROTOCOL **DevicePathNodes);
72 EFI_STATUS (*UpdateDevicePathNode)(IN EFI_DEVICE_PATH *OldDevicePath, IN CHAR16* FileName, OUT EFI_DEVICE_PATH_PROTOCOL** NewDevicePath);
73
74 /// Define if the boot menu should request if the file is a EFI binary or a Linux kernel
75 /// Example: PXE boot always deliver a UEFI application.
76 BOOLEAN RequestBootType;
77 } BDS_LOAD_OPTION_SUPPORT;
78
79 #define LOAD_OPTION_ENTRY_FROM_LINK(a) BASE_CR(a, BDS_LOAD_OPTION_ENTRY, Link)
80 #define LOAD_OPTION_FROM_LINK(a) ((BDS_LOAD_OPTION_ENTRY*)BASE_CR(a, BDS_LOAD_OPTION_ENTRY, Link))->BdsLoadOption
81
82 // GUID of the EFI Linux Loader
83 extern CONST EFI_GUID mLinuxLoaderAppGuid;
84
85 // Device path of the EFI Linux Loader in the Firmware Volume
86 extern EFI_DEVICE_PATH* mLinuxLoaderDevicePath;
87
88 EFI_STATUS
89 BootDeviceListSupportedInit (
90 IN OUT LIST_ENTRY *SupportedDeviceList
91 );
92
93 EFI_STATUS
94 BootDeviceListSupportedFree (
95 IN LIST_ENTRY *SupportedDeviceList,
96 IN BDS_SUPPORTED_DEVICE *Except
97 );
98
99 EFI_STATUS
100 BootDeviceGetDeviceSupport (
101 IN EFI_DEVICE_PATH *DevicePath,
102 OUT BDS_LOAD_OPTION_SUPPORT **DeviceSupport
103 );
104
105 EFI_STATUS
106 GetHIInputStr (
107 IN OUT CHAR16 *CmdLine,
108 IN UINTN MaxCmdLine
109 );
110
111 EFI_STATUS
112 EditHIInputStr (
113 IN OUT CHAR16 *CmdLine,
114 IN UINTN MaxCmdLine
115 );
116
117 EFI_STATUS
118 GetHIInputAscii (
119 IN OUT CHAR8 *CmdLine,
120 IN UINTN MaxCmdLine
121 );
122
123 EFI_STATUS
124 EditHIInputAscii (
125 IN OUT CHAR8 *CmdLine,
126 IN UINTN MaxCmdLine
127 );
128
129 EFI_STATUS
130 GetHIInputInteger (
131 IN OUT UINTN *Integer
132 );
133
134 EFI_STATUS
135 GetHIInputIP (
136 OUT EFI_IP_ADDRESS *Ip
137 );
138
139 EFI_STATUS
140 EditHIInputIP (
141 IN EFI_IP_ADDRESS *InIpAddr,
142 OUT EFI_IP_ADDRESS *OutIpAddr
143 );
144
145 EFI_STATUS
146 GetHIInputBoolean (
147 OUT BOOLEAN *Value
148 );
149
150 EFI_DEVICE_PATH*
151 GetLastDevicePathNode (
152 IN EFI_DEVICE_PATH* DevicePath
153 );
154
155 EFI_STATUS
156 BdsStartBootOption (
157 IN CHAR16* BootOption
158 );
159
160 UINTN
161 GetUnalignedDevicePathSize (
162 IN EFI_DEVICE_PATH* DevicePath
163 );
164
165 EFI_DEVICE_PATH*
166 GetAlignedDevicePath (
167 IN EFI_DEVICE_PATH* DevicePath
168 );
169
170 EFI_STATUS
171 GenerateDeviceDescriptionName (
172 IN EFI_HANDLE Handle,
173 IN OUT CHAR16* Description
174 );
175
176 EFI_STATUS
177 BootOptionList (
178 IN OUT LIST_ENTRY *BootOptionList
179 );
180
181 EFI_STATUS
182 BootOptionParseLoadOption (
183 IN EFI_LOAD_OPTION EfiLoadOption,
184 IN UINTN EfiLoadOptionSize,
185 OUT BDS_LOAD_OPTION **BdsLoadOption
186 );
187
188 EFI_STATUS
189 BootOptionStart (
190 IN BDS_LOAD_OPTION *BootOption
191 );
192
193 EFI_STATUS
194 BootOptionCreate (
195 IN UINT32 Attributes,
196 IN CHAR16* BootDescription,
197 IN EFI_DEVICE_PATH_PROTOCOL* DevicePath,
198 IN UINT8* OptionalData,
199 IN UINTN OptionalDataSize,
200 OUT BDS_LOAD_OPTION** BdsLoadOption
201 );
202
203 EFI_STATUS
204 BootOptionUpdate (
205 IN BDS_LOAD_OPTION* BdsLoadOption,
206 IN UINT32 Attributes,
207 IN CHAR16* BootDescription,
208 IN EFI_DEVICE_PATH_PROTOCOL* DevicePath,
209 IN UINT8* OptionalData,
210 IN UINTN OptionalDataSize
211 );
212
213 EFI_STATUS
214 BootOptionDelete (
215 IN BDS_LOAD_OPTION *BootOption
216 );
217
218 EFI_STATUS
219 BootMenuMain (
220 VOID
221 );
222
223 BOOLEAN
224 IsUnicodeString (
225 IN VOID* String
226 );
227
228 /*
229 * Try to detect if the given string is an ASCII or Unicode string
230 *
231 * There are actually few limitation to this function but it is mainly to give
232 * a user friendly output.
233 *
234 * Some limitations:
235 * - it only supports unicode string that use ASCII character (< 0x100)
236 * - single character ASCII strings are interpreted as Unicode string
237 * - string cannot be longer than 2 x BOOT_DEVICE_OPTION_MAX (600 bytes)
238 *
239 * @param String Buffer that might contain a Unicode or Ascii string
240 * @param IsUnicode If not NULL this boolean value returns if the string is an
241 * ASCII or Unicode string.
242 */
243 BOOLEAN
244 IsPrintableString (
245 IN VOID* String,
246 OUT BOOLEAN *IsUnicode
247 );
248
249 /**
250 An empty function to pass error checking of CreateEventEx ().
251
252 @param Event Event whose notification function is being invoked.
253 @param Context Pointer to the notification function's context,
254 which is implementation-dependent.
255
256 **/
257 VOID
258 EFIAPI
259 EmptyCallbackFunction (
260 IN EFI_EVENT Event,
261 IN VOID *Context
262 );
263
264 /**
265 * This function check if the DevicePath defines an EFI binary
266 *
267 * This function is used when the BDS support Linux loader to
268 * detect if the binary is an EFI application or potentially a
269 * Linux kernel.
270 */
271 EFI_STATUS
272 IsEfiBinary (
273 IN EFI_DEVICE_PATH* DevicePath,
274 OUT BOOLEAN *EfiBinary
275 );
276
277 #endif /* _BDSINTERNAL_H_ */