MAX_POOL_SIZE was hardcoded to 0xFFFFFF00. MAX_POOL_SIZE was replaced with MAX_ADDRES...
[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 // This data structure is the part of BDS_CONNECT_ENTRY that we can hard code.
64 //
65 #define BDS_LOAD_OPTION_SIGNATURE EFI_SIGNATURE_32 ('B', 'd', 'C', 'O')
66
67 typedef struct {
68
69 UINTN Signature;
70 LIST_ENTRY Link;
71
72 EFI_DEVICE_PATH_PROTOCOL *DevicePath;
73
74 CHAR16 *OptionName;
75 UINTN OptionNumber;
76 UINT16 BootCurrent;
77 UINT32 Attribute;
78 CHAR16 *Description;
79 VOID *LoadOptions;
80 UINT32 LoadOptionsSize;
81
82 } BDS_COMMON_OPTION;
83
84 typedef struct {
85 EFI_DEVICE_PATH_PROTOCOL *DevicePath;
86 UINTN ConnectType;
87 } BDS_CONSOLE_CONNECT_ENTRY;
88
89 //
90 // Lib Functions
91 //
92
93 //
94 // Bds boot relate lib functions
95 //
96 EFI_STATUS
97 BdsLibUpdateBootOrderList (
98 IN LIST_ENTRY *BdsOptionList,
99 IN CHAR16 *VariableName
100 );
101
102 VOID
103 BdsLibBootNext (
104 VOID
105 );
106
107 EFI_STATUS
108 BdsLibBootViaBootOption (
109 IN BDS_COMMON_OPTION * Option,
110 IN EFI_DEVICE_PATH_PROTOCOL * DevicePath,
111 OUT UINTN *ExitDataSize,
112 OUT CHAR16 **ExitData OPTIONAL
113 );
114
115 EFI_STATUS
116 BdsLibEnumerateAllBootOption (
117 IN OUT LIST_ENTRY *BdsBootOptionList
118 );
119
120 VOID
121 BdsLibBuildOptionFromHandle (
122 IN EFI_HANDLE Handle,
123 IN LIST_ENTRY *BdsBootOptionList
124 );
125
126 VOID
127 BdsLibBuildOptionFromShell (
128 IN EFI_HANDLE Handle,
129 IN LIST_ENTRY *BdsBootOptionList
130 );
131
132 //
133 // Bds misc lib functions
134 //
135 UINT16
136 BdsLibGetTimeout (
137 VOID
138 );
139
140 EFI_STATUS
141 BdsLibGetBootMode (
142 OUT EFI_BOOT_MODE *BootMode
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 BOOLEAN
245 BdsLibMatchDevicePaths (
246 IN EFI_DEVICE_PATH_PROTOCOL *Multi,
247 IN EFI_DEVICE_PATH_PROTOCOL *Single
248 );
249
250 CHAR16 *
251 DevicePathToStr (
252 EFI_DEVICE_PATH_PROTOCOL *DevPath
253 );
254
255 VOID *
256 EfiLibGetVariable (
257 IN CHAR16 *Name,
258 IN EFI_GUID *VendorGuid
259 );
260
261 //
262 // Internal definitions
263 //
264 typedef struct {
265 CHAR16 *str;
266 UINTN len;
267 UINTN maxlen;
268 } POOL_PRINT;
269
270 typedef struct {
271 UINT8 Type;
272 UINT8 SubType;
273 VOID (*Function) (POOL_PRINT *, VOID *);
274 } DEVICE_PATH_STRING_TABLE;
275
276 //
277 // Internal functions
278 //
279 EFI_STATUS
280 BdsBootByDiskSignatureAndPartition (
281 IN BDS_COMMON_OPTION * Option,
282 IN HARDDRIVE_DEVICE_PATH * HardDriveDevicePath,
283 IN UINT32 LoadOptionsSize,
284 IN VOID *LoadOptions,
285 OUT UINTN *ExitDataSize,
286 OUT CHAR16 **ExitData OPTIONAL
287 );
288
289 //
290 // Notes: EFI 64 shadow all option rom
291 //
292 #ifdef EFI64
293 #define EFI64_SHADOW_ALL_LEGACY_ROM() ShadowAllOptionRom ();
294 VOID
295 ShadowAllOptionRom();
296 #else
297 #define EFI64_SHADOW_ALL_LEGACY_ROM()
298 #endif
299
300 //
301 // BBS support macros and functions
302 //
303 #ifdef EFI32
304 #define REFRESH_LEGACY_BOOT_OPTIONS \
305 BdsDeleteAllInvalidLegacyBootOptions ();\
306 BdsAddNonExistingLegacyBootOptions (); \
307 BdsUpdateLegacyDevOrder ()
308 #else
309 #define REFRESH_LEGACY_BOOT_OPTIONS
310 #endif
311
312 EFI_STATUS
313 BdsDeleteAllInvalidLegacyBootOptions (
314 VOID
315 );
316
317 EFI_STATUS
318 BdsAddNonExistingLegacyBootOptions (
319 VOID
320 );
321
322 EFI_STATUS
323 BdsUpdateLegacyDevOrder (
324 VOID
325 );
326
327 EFI_STATUS
328 BdsRefreshBbsTableForBoot (
329 IN BDS_COMMON_OPTION *Entry
330 );
331
332 #endif // _BDS_LIB_H_