]> git.proxmox.com Git - mirror_edk2.git/blob - ArmPlatformPkg/Bds/BdsInternal.h
ArmPlatformPkg/Bds: Remove Linux specific boot path
[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 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 EFI_STATUS
83 BootDeviceListSupportedInit (
84 IN OUT LIST_ENTRY *SupportedDeviceList
85 );
86
87 EFI_STATUS
88 BootDeviceListSupportedFree (
89 IN LIST_ENTRY *SupportedDeviceList,
90 IN BDS_SUPPORTED_DEVICE *Except
91 );
92
93 EFI_STATUS
94 BootDeviceGetDeviceSupport (
95 IN EFI_DEVICE_PATH *DevicePath,
96 OUT BDS_LOAD_OPTION_SUPPORT **DeviceSupport
97 );
98
99 EFI_STATUS
100 GetHIInputStr (
101 IN OUT CHAR16 *CmdLine,
102 IN UINTN MaxCmdLine
103 );
104
105 EFI_STATUS
106 EditHIInputStr (
107 IN OUT CHAR16 *CmdLine,
108 IN UINTN MaxCmdLine
109 );
110
111 EFI_STATUS
112 GetHIInputAscii (
113 IN OUT CHAR8 *CmdLine,
114 IN UINTN MaxCmdLine
115 );
116
117 EFI_STATUS
118 EditHIInputAscii (
119 IN OUT CHAR8 *CmdLine,
120 IN UINTN MaxCmdLine
121 );
122
123 EFI_STATUS
124 GetHIInputInteger (
125 IN OUT UINTN *Integer
126 );
127
128 EFI_STATUS
129 GetHIInputIP (
130 OUT EFI_IP_ADDRESS *Ip
131 );
132
133 EFI_STATUS
134 EditHIInputIP (
135 IN EFI_IP_ADDRESS *InIpAddr,
136 OUT EFI_IP_ADDRESS *OutIpAddr
137 );
138
139 EFI_STATUS
140 GetHIInputBoolean (
141 OUT BOOLEAN *Value
142 );
143
144 BOOLEAN
145 HasFilePathEfiExtension (
146 IN CHAR16* FilePath
147 );
148
149 EFI_DEVICE_PATH*
150 GetLastDevicePathNode (
151 IN EFI_DEVICE_PATH* DevicePath
152 );
153
154 EFI_STATUS
155 BdsStartBootOption (
156 IN CHAR16* BootOption
157 );
158
159 UINTN
160 GetUnalignedDevicePathSize (
161 IN EFI_DEVICE_PATH* DevicePath
162 );
163
164 EFI_DEVICE_PATH*
165 GetAlignedDevicePath (
166 IN EFI_DEVICE_PATH* DevicePath
167 );
168
169 EFI_STATUS
170 GenerateDeviceDescriptionName (
171 IN EFI_HANDLE Handle,
172 IN OUT CHAR16* Description
173 );
174
175 EFI_STATUS
176 BootOptionList (
177 IN OUT LIST_ENTRY *BootOptionList
178 );
179
180 EFI_STATUS
181 BootOptionParseLoadOption (
182 IN EFI_LOAD_OPTION EfiLoadOption,
183 IN UINTN EfiLoadOptionSize,
184 OUT BDS_LOAD_OPTION **BdsLoadOption
185 );
186
187 EFI_STATUS
188 BootOptionStart (
189 IN BDS_LOAD_OPTION *BootOption
190 );
191
192 EFI_STATUS
193 BootOptionCreate (
194 IN UINT32 Attributes,
195 IN CHAR16* BootDescription,
196 IN EFI_DEVICE_PATH_PROTOCOL* DevicePath,
197 IN UINT8* OptionalData,
198 IN UINTN OptionalDataSize,
199 OUT BDS_LOAD_OPTION** BdsLoadOption
200 );
201
202 EFI_STATUS
203 BootOptionUpdate (
204 IN BDS_LOAD_OPTION* BdsLoadOption,
205 IN UINT32 Attributes,
206 IN CHAR16* BootDescription,
207 IN EFI_DEVICE_PATH_PROTOCOL* DevicePath,
208 IN UINT8* OptionalData,
209 IN UINTN OptionalDataSize
210 );
211
212 EFI_STATUS
213 BootOptionDelete (
214 IN BDS_LOAD_OPTION *BootOption
215 );
216
217 EFI_STATUS
218 BootMenuMain (
219 VOID
220 );
221
222 BOOLEAN
223 IsUnicodeString (
224 IN VOID* String
225 );
226
227 /*
228 * Try to detect if the given string is an ASCII or Unicode string
229 *
230 * There are actually few limitation to this function but it is mainly to give
231 * a user friendly output.
232 *
233 * Some limitations:
234 * - it only supports unicode string that use ASCII character (< 0x100)
235 * - single character ASCII strings are interpreted as Unicode string
236 * - string cannot be longer than 2 x BOOT_DEVICE_OPTION_MAX (600 bytes)
237 *
238 * @param String Buffer that might contain a Unicode or Ascii string
239 * @param IsUnicode If not NULL this boolean value returns if the string is an
240 * ASCII or Unicode string.
241 */
242 BOOLEAN
243 IsPrintableString (
244 IN VOID* String,
245 OUT BOOLEAN *IsUnicode
246 );
247
248 /**
249 An empty function to pass error checking of CreateEventEx ().
250
251 @param Event Event whose notification function is being invoked.
252 @param Context Pointer to the notification function's context,
253 which is implementation-dependent.
254
255 **/
256 VOID
257 EFIAPI
258 EmptyCallbackFunction (
259 IN EFI_EVENT Event,
260 IN VOID *Context
261 );
262
263 #endif /* _BDSINTERNAL_H_ */