Add some definitions in Framework FV 0.9 spec but not in PI 1.0.
[mirror_edk2.git] / EdkNt32Pkg / Include / Library / EdkGenericBdsLib.h
1 /*++
2
3 Copyright (c) 2006 - 2007, 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 VOID
146 BdsLibLoadDrivers (
147 IN LIST_ENTRY *BdsDriverLists
148 );
149
150 EFI_STATUS
151 BdsLibBuildOptionFromVar (
152 IN LIST_ENTRY *BdsCommonOptionList,
153 IN CHAR16 *VariableName
154 );
155
156 VOID *
157 BdsLibGetVariableAndSize (
158 IN CHAR16 *Name,
159 IN EFI_GUID *VendorGuid,
160 OUT UINTN *VariableSize
161 );
162
163 EFI_STATUS
164 BdsLibOutputStrings (
165 IN EFI_SIMPLE_TEXT_OUT_PROTOCOL *ConOut,
166 ...
167 );
168
169 BDS_COMMON_OPTION *
170 BdsLibVariableToOption (
171 IN OUT LIST_ENTRY *BdsCommonOptionList,
172 IN CHAR16 *VariableName
173 );
174
175 EFI_STATUS
176 BdsLibRegisterNewOption (
177 IN LIST_ENTRY *BdsOptionList,
178 IN EFI_DEVICE_PATH_PROTOCOL *DevicePath,
179 IN CHAR16 *String,
180 IN CHAR16 *VariableName
181 );
182
183 //
184 // Bds connect or disconnect driver lib funcion
185 //
186 VOID
187 BdsLibConnectAllDriversToAllControllers (
188 VOID
189 );
190
191 VOID
192 BdsLibConnectAll (
193 VOID
194 );
195
196 EFI_STATUS
197 BdsLibConnectDevicePath (
198 IN EFI_DEVICE_PATH_PROTOCOL *DevicePathToConnect
199 );
200
201 EFI_STATUS
202 BdsLibConnectAllEfi (
203 VOID
204 );
205
206 EFI_STATUS
207 BdsLibDisconnectAllEfi (
208 VOID
209 );
210
211 //
212 // Bds console relate lib functions
213 //
214 VOID
215 BdsLibConnectAllConsoles (
216 VOID
217 );
218
219 EFI_STATUS
220 BdsLibConnectAllDefaultConsoles (
221 VOID
222 );
223
224 EFI_STATUS
225 BdsLibUpdateConsoleVariable (
226 IN CHAR16 *ConVarName,
227 IN EFI_DEVICE_PATH_PROTOCOL *CustomizedConDevicePath,
228 IN EFI_DEVICE_PATH_PROTOCOL *ExclusiveDevicePath
229 );
230
231 EFI_STATUS
232 BdsLibConnectConsoleVariable (
233 IN CHAR16 *ConVarName
234 );
235
236 //
237 // Bds device path relate lib functions
238 //
239 EFI_DEVICE_PATH_PROTOCOL *
240 BdsLibUnpackDevicePath (
241 IN EFI_DEVICE_PATH_PROTOCOL *DevPath
242 );
243
244 VOID
245 BdsLibSafeFreePool (
246 IN VOID *Buffer
247 );
248
249 EFI_DEVICE_PATH_PROTOCOL *
250 BdsLibDelPartMatchInstance (
251 IN EFI_DEVICE_PATH_PROTOCOL *Multi,
252 IN EFI_DEVICE_PATH_PROTOCOL *Single
253 );
254
255 BOOLEAN
256 BdsLibMatchDevicePaths (
257 IN EFI_DEVICE_PATH_PROTOCOL *Multi,
258 IN EFI_DEVICE_PATH_PROTOCOL *Single
259 );
260
261 CHAR16 *
262 DevicePathToStr (
263 EFI_DEVICE_PATH_PROTOCOL *DevPath
264 );
265
266 VOID *
267 EfiLibGetVariable (
268 IN CHAR16 *Name,
269 IN EFI_GUID *VendorGuid
270 );
271
272 //
273 // Internal definitions
274 //
275 typedef struct {
276 CHAR16 *str;
277 UINTN len;
278 UINTN maxlen;
279 } POOL_PRINT;
280
281 typedef struct {
282 UINT8 Type;
283 UINT8 SubType;
284 VOID (*Function) (POOL_PRINT *, VOID *);
285 } DEVICE_PATH_STRING_TABLE;
286
287 //
288 // Internal functions
289 //
290 EFI_STATUS
291 BdsBootByDiskSignatureAndPartition (
292 IN BDS_COMMON_OPTION * Option,
293 IN HARDDRIVE_DEVICE_PATH * HardDriveDevicePath,
294 IN UINT32 LoadOptionsSize,
295 IN VOID *LoadOptions,
296 OUT UINTN *ExitDataSize,
297 OUT CHAR16 **ExitData OPTIONAL
298 );
299
300 //
301 // Notes: EFI 64 shadow all option rom
302 //
303 #if defined (MDE_CPU_IPF)
304 #define EFI64_SHADOW_ALL_LEGACY_ROM() ShadowAllOptionRom ();
305 VOID
306 ShadowAllOptionRom();
307 #else
308 #define EFI64_SHADOW_ALL_LEGACY_ROM()
309 #endif
310
311 //
312 // BBS support macros and functions
313 //
314 #if defined (MDE_CPU_IA32)
315 #define REFRESH_LEGACY_BOOT_OPTIONS \
316 BdsDeleteAllInvalidLegacyBootOptions ();\
317 BdsAddNonExistingLegacyBootOptions (); \
318 BdsUpdateLegacyDevOrder ()
319 #else
320 #define REFRESH_LEGACY_BOOT_OPTIONS
321 #endif
322
323 EFI_STATUS
324 BdsDeleteAllInvalidLegacyBootOptions (
325 VOID
326 );
327
328 EFI_STATUS
329 BdsAddNonExistingLegacyBootOptions (
330 VOID
331 );
332
333 EFI_STATUS
334 BdsUpdateLegacyDevOrder (
335 VOID
336 );
337
338 EFI_STATUS
339 BdsRefreshBbsTableForBoot (
340 IN BDS_COMMON_OPTION *Entry
341 );
342
343 EFI_STATUS
344 BdsDeleteBootOption (
345 IN UINTN OptionNumber,
346 IN OUT UINT16 *BootOrder,
347 IN OUT UINTN *BootOrderSize
348 );
349
350 //
351 //The interface functions relate with Setup Browser Reset Reminder feature
352 //
353 VOID
354 EnableResetReminderFeature (
355 VOID
356 );
357
358 VOID
359 DisableResetReminderFeature (
360 VOID
361 );
362
363 VOID
364 EnableResetRequired (
365 VOID
366 );
367
368 VOID
369 DisableResetRequired (
370 VOID
371 );
372
373 BOOLEAN
374 IsResetReminderFeatureEnable (
375 VOID
376 );
377
378 BOOLEAN
379 IsResetRequired (
380 VOID
381 );
382
383 VOID
384 SetupResetReminder (
385 VOID
386 );
387
388 EFI_STATUS
389 BdsLibGetHiiHandles (
390 IN EFI_HII_PROTOCOL *Hii,
391 IN OUT UINT16 *HandleBufferLength,
392 OUT EFI_HII_HANDLE **HiiHandles
393 );
394
395 #endif // _BDS_LIB_H_