Update video card preference policy, together with some memory leaks in Generic BDS...
[mirror_edk2.git] / EdkNt32Pkg / Include / Library / EdkGenericBdsLib.h
CommitLineData
878ddf1f 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
9e0e49fc 62//\r
63// Define maximum characters for boot option variable "BootXXXX"\r
64//\r
65#define BOOT_OPTION_MAX_CHAR 10\r
66\r
878ddf1f 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
d02ea958 249VOID\r
250BdsLibSafeFreePool (\r
251 IN VOID *Buffer\r
252 );\r
253\r
254EFI_DEVICE_PATH_PROTOCOL *\r
255BdsLibDelPartMatchInstance (\r
256 IN EFI_DEVICE_PATH_PROTOCOL *Multi,\r
257 IN EFI_DEVICE_PATH_PROTOCOL *Single\r
258 );\r
259\r
878ddf1f 260BOOLEAN\r
261BdsLibMatchDevicePaths (\r
262 IN EFI_DEVICE_PATH_PROTOCOL *Multi,\r
263 IN EFI_DEVICE_PATH_PROTOCOL *Single\r
264 );\r
265\r
266CHAR16 *\r
267DevicePathToStr (\r
268 EFI_DEVICE_PATH_PROTOCOL *DevPath\r
269 );\r
270\r
271VOID *\r
272EfiLibGetVariable (\r
273 IN CHAR16 *Name,\r
274 IN EFI_GUID *VendorGuid\r
275 );\r
276\r
277//\r
278// Internal definitions\r
279//\r
280typedef struct {\r
281 CHAR16 *str;\r
282 UINTN len;\r
283 UINTN maxlen;\r
284} POOL_PRINT;\r
285\r
286typedef struct {\r
287 UINT8 Type;\r
288 UINT8 SubType;\r
289 VOID (*Function) (POOL_PRINT *, VOID *);\r
290} DEVICE_PATH_STRING_TABLE;\r
291\r
292//\r
293// Internal functions\r
294//\r
295EFI_STATUS\r
296BdsBootByDiskSignatureAndPartition (\r
297 IN BDS_COMMON_OPTION * Option,\r
298 IN HARDDRIVE_DEVICE_PATH * HardDriveDevicePath,\r
299 IN UINT32 LoadOptionsSize,\r
300 IN VOID *LoadOptions,\r
301 OUT UINTN *ExitDataSize,\r
302 OUT CHAR16 **ExitData OPTIONAL\r
303 );\r
304\r
305//\r
306// Notes: EFI 64 shadow all option rom\r
307//\r
308#ifdef EFI64\r
309#define EFI64_SHADOW_ALL_LEGACY_ROM() ShadowAllOptionRom ();\r
310VOID\r
311ShadowAllOptionRom();\r
312#else\r
313#define EFI64_SHADOW_ALL_LEGACY_ROM()\r
314#endif\r
315\r
316//\r
317// BBS support macros and functions\r
318//\r
319#ifdef EFI32\r
320#define REFRESH_LEGACY_BOOT_OPTIONS \\r
321 BdsDeleteAllInvalidLegacyBootOptions ();\\r
322 BdsAddNonExistingLegacyBootOptions (); \\r
323 BdsUpdateLegacyDevOrder ()\r
324#else\r
325#define REFRESH_LEGACY_BOOT_OPTIONS\r
326#endif\r
327\r
328EFI_STATUS\r
329BdsDeleteAllInvalidLegacyBootOptions (\r
330 VOID\r
331 );\r
332\r
333EFI_STATUS\r
334BdsAddNonExistingLegacyBootOptions (\r
335 VOID\r
336 );\r
337\r
338EFI_STATUS\r
339BdsUpdateLegacyDevOrder (\r
340 VOID\r
341 );\r
342\r
343EFI_STATUS\r
344BdsRefreshBbsTableForBoot (\r
345 IN BDS_COMMON_OPTION *Entry\r
346 );\r
347\r
9e0e49fc 348EFI_STATUS\r
349BdsDeleteBootOption (\r
350 IN UINTN OptionNumber,\r
351 IN OUT UINT16 *BootOrder,\r
352 IN OUT UINTN *BootOrderSize\r
353 );\r
354\r
355//\r
356//The interface functions relate with Setup Browser Reset Reminder feature\r
357//\r
358VOID\r
359EnableResetReminderFeature (\r
360 VOID\r
361 );\r
362\r
363VOID\r
364DisableResetReminderFeature (\r
365 VOID\r
366 );\r
367\r
368VOID\r
369EnableResetRequired (\r
370 VOID\r
371 );\r
372\r
373VOID\r
374DisableResetRequired (\r
375 VOID\r
376 );\r
377\r
378BOOLEAN\r
379IsResetReminderFeatureEnable (\r
380 VOID\r
381 );\r
382\r
383BOOLEAN\r
384IsResetRequired (\r
385 VOID\r
386 );\r
387\r
388VOID\r
389SetupResetReminder (\r
390 VOID\r
391 );\r
392 \r
0e7bfce8 393EFI_STATUS\r
394BdsLibGetHiiHandles (\r
395 IN EFI_HII_PROTOCOL *Hii,\r
396 IN OUT UINT16 *HandleBufferLength,\r
397 OUT EFI_HII_HANDLE **HiiHandles\r
398 );\r
399\r
878ddf1f 400#endif // _BDS_LIB_H_\r