BDS code calls Hii->FindHandles() with hardcoded length.
[mirror_edk2.git] / EdkUnixPkg / Include / Library / EdkGenericBdsLib.h
CommitLineData
c9093a06 1/*++\r
2\r
3Copyright (c) 2006, Intel Corporation \r
4All rights reserved. This program and the accompanying materials \r
5are licensed and made available under the terms and conditions of the BSD License \r
6which accompanies this distribution. The full text of the license may be found at \r
7http://opensource.org/licenses/bsd-license.php \r
8 \r
9THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r
10WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r
11\r
12Module Name:\r
13\r
14 BdsLib.h\r
15\r
16Abstract:\r
17\r
18 BDS library definition, include the file and data structure\r
19\r
20--*/\r
21\r
22#ifndef _BDS_LIB_H_\r
23#define _BDS_LIB_H_\r
24\r
25extern EFI_HANDLE mBdsImageHandle;\r
26\r
27//\r
28// Constants which are variable names used to access variables\r
29//\r
30#define VarLegacyDevOrder L"LegacyDevOrder"\r
31\r
32//\r
33// Data structures and defines\r
34//\r
35#define FRONT_PAGE_QUESTION_ID 0x0000\r
36#define FRONT_PAGE_DATA_WIDTH 0x01\r
37\r
38//\r
39// ConnectType\r
40//\r
41#define CONSOLE_OUT 0x00000001\r
42#define STD_ERROR 0x00000002\r
43#define CONSOLE_IN 0x00000004\r
44#define CONSOLE_ALL (CONSOLE_OUT | CONSOLE_IN | STD_ERROR)\r
45\r
46//\r
47// Load Option Attributes defined in EFI Specification\r
48//\r
49#define LOAD_OPTION_ACTIVE 0x00000001\r
50#define LOAD_OPTION_FORCE_RECONNECT 0x00000002\r
51#define IS_LOAD_OPTION_TYPE(_c, _Mask) (BOOLEAN) (((_c) & (_Mask)) != 0)\r
52\r
53//\r
54// Define Maxmim characters that will be accepted\r
55//\r
56#define MAX_CHAR 480\r
57#define MAX_CHAR_SIZE (MAX_CHAR * 2)\r
58\r
59#define MIN_ALIGNMENT_SIZE 4\r
60#define ALIGN_SIZE(a) ((a % MIN_ALIGNMENT_SIZE) ? MIN_ALIGNMENT_SIZE - (a % MIN_ALIGNMENT_SIZE) : 0)\r
61\r
62//\r
63// Define maximum characters for boot option variable "BootXXXX"\r
64//\r
65#define BOOT_OPTION_MAX_CHAR 10\r
66\r
67//\r
68// This data structure is the part of BDS_CONNECT_ENTRY that we can hard code.\r
69//\r
70#define BDS_LOAD_OPTION_SIGNATURE EFI_SIGNATURE_32 ('B', 'd', 'C', 'O')\r
71\r
72typedef struct {\r
73\r
74 UINTN Signature;\r
75 LIST_ENTRY Link;\r
76\r
77 EFI_DEVICE_PATH_PROTOCOL *DevicePath;\r
78\r
79 CHAR16 *OptionName;\r
80 UINTN OptionNumber;\r
81 UINT16 BootCurrent;\r
82 UINT32 Attribute;\r
83 CHAR16 *Description;\r
84 VOID *LoadOptions;\r
85 UINT32 LoadOptionsSize;\r
86\r
87} BDS_COMMON_OPTION;\r
88\r
89typedef struct {\r
90 EFI_DEVICE_PATH_PROTOCOL *DevicePath;\r
91 UINTN ConnectType;\r
92} BDS_CONSOLE_CONNECT_ENTRY;\r
93\r
94//\r
95// Lib Functions\r
96//\r
97\r
98//\r
99// Bds boot relate lib functions\r
100//\r
101EFI_STATUS\r
102BdsLibUpdateBootOrderList (\r
103 IN LIST_ENTRY *BdsOptionList,\r
104 IN CHAR16 *VariableName\r
105 );\r
106\r
107VOID\r
108BdsLibBootNext (\r
109 VOID\r
110 );\r
111\r
112EFI_STATUS\r
113BdsLibBootViaBootOption (\r
114 IN BDS_COMMON_OPTION * Option,\r
115 IN EFI_DEVICE_PATH_PROTOCOL * DevicePath,\r
116 OUT UINTN *ExitDataSize,\r
117 OUT CHAR16 **ExitData OPTIONAL\r
118 );\r
119\r
120EFI_STATUS\r
121BdsLibEnumerateAllBootOption (\r
122 IN OUT LIST_ENTRY *BdsBootOptionList\r
123 );\r
124\r
125VOID\r
126BdsLibBuildOptionFromHandle (\r
127 IN EFI_HANDLE Handle,\r
128 IN LIST_ENTRY *BdsBootOptionList\r
129 );\r
130\r
131VOID\r
132BdsLibBuildOptionFromShell (\r
133 IN EFI_HANDLE Handle,\r
134 IN LIST_ENTRY *BdsBootOptionList\r
135 );\r
136\r
137//\r
138// Bds misc lib functions\r
139//\r
140UINT16\r
141BdsLibGetTimeout (\r
142 VOID\r
143 );\r
144\r
145EFI_STATUS\r
146BdsLibGetBootMode (\r
147 OUT EFI_BOOT_MODE *BootMode\r
148 );\r
149\r
150VOID\r
151BdsLibLoadDrivers (\r
152 IN LIST_ENTRY *BdsDriverLists\r
153 );\r
154\r
155EFI_STATUS\r
156BdsLibBuildOptionFromVar (\r
157 IN LIST_ENTRY *BdsCommonOptionList,\r
158 IN CHAR16 *VariableName\r
159 );\r
160\r
161VOID *\r
162BdsLibGetVariableAndSize (\r
163 IN CHAR16 *Name,\r
164 IN EFI_GUID *VendorGuid,\r
165 OUT UINTN *VariableSize\r
166 );\r
167\r
168EFI_STATUS\r
169BdsLibOutputStrings (\r
170 IN EFI_SIMPLE_TEXT_OUT_PROTOCOL *ConOut,\r
171 ...\r
172 );\r
173\r
174BDS_COMMON_OPTION *\r
175BdsLibVariableToOption (\r
176 IN OUT LIST_ENTRY *BdsCommonOptionList,\r
177 IN CHAR16 *VariableName\r
178 );\r
179\r
180EFI_STATUS\r
181BdsLibRegisterNewOption (\r
182 IN LIST_ENTRY *BdsOptionList,\r
183 IN EFI_DEVICE_PATH_PROTOCOL *DevicePath,\r
184 IN CHAR16 *String,\r
185 IN CHAR16 *VariableName\r
186 );\r
187\r
188//\r
189// Bds connect or disconnect driver lib funcion\r
190//\r
191VOID\r
192BdsLibConnectAllDriversToAllControllers (\r
193 VOID\r
194 );\r
195\r
196VOID\r
197BdsLibConnectAll (\r
198 VOID\r
199 );\r
200\r
201EFI_STATUS\r
202BdsLibConnectDevicePath (\r
203 IN EFI_DEVICE_PATH_PROTOCOL *DevicePathToConnect\r
204 );\r
205\r
206EFI_STATUS\r
207BdsLibConnectAllEfi (\r
208 VOID\r
209 );\r
210\r
211EFI_STATUS\r
212BdsLibDisconnectAllEfi (\r
213 VOID\r
214 );\r
215\r
216//\r
217// Bds console relate lib functions\r
218//\r
219VOID\r
220BdsLibConnectAllConsoles (\r
221 VOID\r
222 );\r
223\r
224EFI_STATUS\r
225BdsLibConnectAllDefaultConsoles (\r
226 VOID\r
227 );\r
228\r
229EFI_STATUS\r
230BdsLibUpdateConsoleVariable (\r
231 IN CHAR16 *ConVarName,\r
232 IN EFI_DEVICE_PATH_PROTOCOL *CustomizedConDevicePath,\r
233 IN EFI_DEVICE_PATH_PROTOCOL *ExclusiveDevicePath\r
234 );\r
235\r
236EFI_STATUS\r
237BdsLibConnectConsoleVariable (\r
238 IN CHAR16 *ConVarName\r
239 );\r
240\r
241//\r
242// Bds device path relate lib functions\r
243//\r
244EFI_DEVICE_PATH_PROTOCOL *\r
245BdsLibUnpackDevicePath (\r
246 IN EFI_DEVICE_PATH_PROTOCOL *DevPath\r
247 );\r
248\r
249BOOLEAN\r
250BdsLibMatchDevicePaths (\r
251 IN EFI_DEVICE_PATH_PROTOCOL *Multi,\r
252 IN EFI_DEVICE_PATH_PROTOCOL *Single\r
253 );\r
254\r
255CHAR16 *\r
256DevicePathToStr (\r
257 EFI_DEVICE_PATH_PROTOCOL *DevPath\r
258 );\r
259\r
260VOID *\r
261EfiLibGetVariable (\r
262 IN CHAR16 *Name,\r
263 IN EFI_GUID *VendorGuid\r
264 );\r
265\r
266//\r
267// Internal definitions\r
268//\r
269typedef struct {\r
270 CHAR16 *str;\r
271 UINTN len;\r
272 UINTN maxlen;\r
273} POOL_PRINT;\r
274\r
275typedef struct {\r
276 UINT8 Type;\r
277 UINT8 SubType;\r
278 VOID (*Function) (POOL_PRINT *, VOID *);\r
279} DEVICE_PATH_STRING_TABLE;\r
280\r
281//\r
282// Internal functions\r
283//\r
284EFI_STATUS\r
285BdsBootByDiskSignatureAndPartition (\r
286 IN BDS_COMMON_OPTION * Option,\r
287 IN HARDDRIVE_DEVICE_PATH * HardDriveDevicePath,\r
288 IN UINT32 LoadOptionsSize,\r
289 IN VOID *LoadOptions,\r
290 OUT UINTN *ExitDataSize,\r
291 OUT CHAR16 **ExitData OPTIONAL\r
292 );\r
293\r
294//\r
295// Notes: EFI 64 shadow all option rom\r
296//\r
297#ifdef EFI64\r
298#define EFI64_SHADOW_ALL_LEGACY_ROM() ShadowAllOptionRom ();\r
299VOID\r
300ShadowAllOptionRom();\r
301#else\r
302#define EFI64_SHADOW_ALL_LEGACY_ROM()\r
303#endif\r
304\r
305//\r
306// BBS support macros and functions\r
307//\r
308#ifdef EFI32\r
309#define REFRESH_LEGACY_BOOT_OPTIONS \\r
310 BdsDeleteAllInvalidLegacyBootOptions ();\\r
311 BdsAddNonExistingLegacyBootOptions (); \\r
312 BdsUpdateLegacyDevOrder ()\r
313#else\r
314#define REFRESH_LEGACY_BOOT_OPTIONS\r
315#endif\r
316\r
317EFI_STATUS\r
318BdsDeleteAllInvalidLegacyBootOptions (\r
319 VOID\r
320 );\r
321\r
322EFI_STATUS\r
323BdsAddNonExistingLegacyBootOptions (\r
324 VOID\r
325 );\r
326\r
327EFI_STATUS\r
328BdsUpdateLegacyDevOrder (\r
329 VOID\r
330 );\r
331\r
332EFI_STATUS\r
333BdsRefreshBbsTableForBoot (\r
334 IN BDS_COMMON_OPTION *Entry\r
335 );\r
336\r
337EFI_STATUS\r
338BdsDeleteBootOption (\r
339 IN UINTN OptionNumber,\r
340 IN OUT UINT16 *BootOrder,\r
341 IN OUT UINTN *BootOrderSize\r
342 );\r
343\r
344//\r
345//The interface functions relate with Setup Browser Reset Reminder feature\r
346//\r
347VOID\r
348EnableResetReminderFeature (\r
349 VOID\r
350 );\r
351\r
352VOID\r
353DisableResetReminderFeature (\r
354 VOID\r
355 );\r
356\r
357VOID\r
358EnableResetRequired (\r
359 VOID\r
360 );\r
361\r
362VOID\r
363DisableResetRequired (\r
364 VOID\r
365 );\r
366\r
367BOOLEAN\r
368IsResetReminderFeatureEnable (\r
369 VOID\r
370 );\r
371\r
372BOOLEAN\r
373IsResetRequired (\r
374 VOID\r
375 );\r
376\r
377VOID\r
378SetupResetReminder (\r
379 VOID\r
380 );\r
381 \r
0e7bfce8 382EFI_STATUS\r
383BdsLibGetHiiHandles (\r
384 IN EFI_HII_PROTOCOL *Hii,\r
385 IN OUT UINT16 *HandleBufferLength,\r
386 OUT EFI_HII_HANDLE **HiiHandles\r
387 );\r
388\r
c9093a06 389#endif // _BDS_LIB_H_\r