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