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