]> git.proxmox.com Git - mirror_edk2.git/blob - Vlv2TbltDevicePkg/Library/PlatformBdsLib/BdsPlatform.h
MdeModulePkg: use 64 KB granularity for runtime allocations on AArch64
[mirror_edk2.git] / Vlv2TbltDevicePkg / Library / PlatformBdsLib / BdsPlatform.h
1 /*++
2
3 Copyright (c) 2004 - 2014, Intel Corporation. All rights reserved.<BR>
4
5 This program and the accompanying materials are licensed and made available under
6 the terms and conditions of the BSD License that accompanies this distribution.
7 The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php.
9
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
12
13
14
15 Module Name:
16
17 BdsPlatform.h
18
19 Abstract:
20
21 Head file for BDS Platform specific code
22
23 --*/
24
25 #ifndef _BDS_PLATFORM_H
26 #define _BDS_PLATFORM_H
27
28 #include <FrameworkDxe.h>
29
30 #include <Protocol/FirmwareVolume2.h>
31 #include <Protocol/DevicePath.h>
32 #include <Protocol/SimpleNetwork.h>
33 #include <Protocol/PciRootBridgeIo.h>
34 #include <Protocol/LoadFile.h>
35 #include <Protocol/LegacyBios.h>
36 #include <Protocol/PciIo.h>
37 #include <Protocol/SmmAccess2.h>
38 #include <Protocol/DxeSmmReadyToLock.h>
39 #include <Protocol/UserManager.h>
40 #include <Protocol/DeferredImageLoad.h>
41 #include <Protocol/AcpiS3Save.h>
42 #include <Protocol/ExitPmAuth.h>
43 #include <Protocol/MmioDevice.h>
44 #include <Protocol/I2cBusMcg.h>
45 #include <Protocol/I2cHostMcg.h>
46 #include <Guid/CapsuleVendor.h>
47 #include <Guid/MemoryTypeInformation.h>
48 #include <Guid/GlobalVariable.h>
49
50
51 #include <Library/DebugLib.h>
52 #include <Library/BaseMemoryLib.h>
53 #include <Library/UefiBootServicesTableLib.h>
54 #include <Library/UefiRuntimeServicesTableLib.h>
55 #include <Library/MemoryAllocationLib.h>
56 #include <Library/BaseLib.h>
57 #include <Library/PcdLib.h>
58 #include <Library/IoLib.h>
59 #include <Library/GenericBdsLib.h>
60 #include <Library/PlatformBdsLib.h>
61 #include <Library/DevicePathLib.h>
62 #include <Library/UefiLib.h>
63 #include <Library/HobLib.h>
64 #include <Library/PrintLib.h>
65 #include <Library/PerformanceLib.h>
66 #include <Library/ReportStatusCodeLib.h>
67
68 #include <IndustryStandard/Pci.h>
69
70 extern EFI_DEVICE_PATH_PROTOCOL *gPlatformRootBridges [];
71 extern BDS_CONSOLE_CONNECT_ENTRY gPlatformConsole [];
72 extern EFI_DEVICE_PATH_PROTOCOL *gPlatformAllPossiblePciVgaConsole [];
73 extern EFI_DEVICE_PATH_PROTOCOL *gPlatformConnectSequence [];
74 extern EFI_DEVICE_PATH_PROTOCOL *gPlatformDriverOption [];
75 extern EFI_DEVICE_PATH_PROTOCOL *gPlatformBootOption [];
76 extern EFI_DEVICE_PATH_PROTOCOL *gUserAuthenticationDevice[];
77 extern BDS_CONSOLE_CONNECT_ENTRY gPlatformSimpleConsole [];
78 extern EFI_DEVICE_PATH_PROTOCOL *gPlatformSimpleBootOption [];
79
80 //
81 // the short form device path for Usb keyboard
82 //
83 #define CLASS_HID 3
84 #define SUBCLASS_BOOT 1
85 #define PROTOCOL_KEYBOARD 1
86
87 #define PCI_DEVICE_PATH_NODE(Func, Dev) \
88 { \
89 HARDWARE_DEVICE_PATH, \
90 HW_PCI_DP, \
91 { \
92 (UINT8) (sizeof (PCI_DEVICE_PATH)), \
93 (UINT8) ((sizeof (PCI_DEVICE_PATH)) >> 8) \
94 }, \
95 (Func), \
96 (Dev) \
97 }
98
99 #define PNPID_DEVICE_PATH_NODE(PnpId) \
100 { \
101 { \
102 ACPI_DEVICE_PATH, \
103 ACPI_DP, \
104 { \
105 (UINT8) (sizeof (ACPI_HID_DEVICE_PATH)), \
106 (UINT8) ((sizeof (ACPI_HID_DEVICE_PATH)) >> 8) \
107 } \
108 }, \
109 EISA_PNP_ID((PnpId)), \
110 0 \
111 }
112
113 #define gUart(BaudRate, DataBits, Parity, StopBits) \
114 { \
115 { \
116 MESSAGING_DEVICE_PATH, \
117 MSG_UART_DP, \
118 { \
119 (UINT8) (sizeof (UART_DEVICE_PATH)), \
120 (UINT8) ((sizeof (UART_DEVICE_PATH)) >> 8) \
121 } \
122 }, \
123 0, \
124 (BaudRate), \
125 (DataBits), \
126 (Parity), \
127 (StopBits) \
128 }
129
130 #define gPcAnsiTerminal \
131 { \
132 { \
133 MESSAGING_DEVICE_PATH, \
134 MSG_VENDOR_DP, \
135 { \
136 (UINT8) (sizeof (VENDOR_DEVICE_PATH)), \
137 (UINT8) ((sizeof (VENDOR_DEVICE_PATH)) >> 8) \
138 } \
139 }, \
140 DEVICE_PATH_MESSAGING_PC_ANSI \
141 }
142
143 #define gUsbKeyboardMouse \
144 { \
145 { \
146 MESSAGING_DEVICE_PATH, \
147 MSG_USB_CLASS_DP, \
148 (UINT8) (sizeof (USB_CLASS_DEVICE_PATH)), \
149 (UINT8) ((sizeof (USB_CLASS_DEVICE_PATH)) >> 8) \
150 }, \
151 0xffff, \
152 0xffff, \
153 CLASS_HID, \
154 SUBCLASS_BOOT, \
155 PROTOCOL_KEYBOARD \
156 }
157
158 #define gEndEntire \
159 { \
160 END_DEVICE_PATH_TYPE, \
161 END_ENTIRE_DEVICE_PATH_SUBTYPE, \
162 { \
163 END_DEVICE_PATH_LENGTH, \
164 0 \
165 } \
166 }
167
168 #define gPciRootBridge \
169 PNPID_DEVICE_PATH_NODE(0x0A03)
170
171 #define gPnpPs2Keyboard \
172 PNPID_DEVICE_PATH_NODE(0x0303)
173
174 #define gPnp16550ComPort \
175 PNPID_DEVICE_PATH_NODE(0x0501)
176
177 #define gPciePort0Bridge \
178 PCI_DEVICE_PATH_NODE(0, 0x1C)
179
180 #define gPciePort1Bridge \
181 PCI_DEVICE_PATH_NODE(1, 0x1C)
182
183 #define gPciePort2Bridge \
184 PCI_DEVICE_PATH_NODE(2, 0x1C)
185
186 #define gPciePort3Bridge \
187 PCI_DEVICE_PATH_NODE(3, 0x1C)
188
189 #define gPciIsaBridge \
190 PCI_DEVICE_PATH_NODE(0, 0x1f)
191
192 //
193 // Platform Root Bridge
194 //
195 typedef struct {
196 ACPI_HID_DEVICE_PATH PciRootBridge;
197 EFI_DEVICE_PATH_PROTOCOL End;
198 } PLATFORM_ROOT_BRIDGE_DEVICE_PATH;
199
200 //
201 // Below is the platform console device path
202 //
203 typedef struct {
204 ACPI_HID_DEVICE_PATH PciRootBridge;
205 PCI_DEVICE_PATH IsaBridge;
206 ACPI_HID_DEVICE_PATH Keyboard;
207 EFI_DEVICE_PATH_PROTOCOL End;
208 } PLATFORM_ISA_KEYBOARD_DEVICE_PATH;
209
210 typedef struct {
211 VENDOR_DEVICE_PATH VendorDevicePath;
212 EFI_DEVICE_PATH_PROTOCOL End;
213 } HII_VENDOR_DEVICE_PATH;
214
215 typedef struct {
216 USB_CLASS_DEVICE_PATH UsbClass;
217 EFI_DEVICE_PATH_PROTOCOL End;
218 } USB_CLASS_FORMAT_DEVICE_PATH;
219
220 typedef struct {
221 ACPI_HID_DEVICE_PATH PciRootBridge;
222 PCI_DEVICE_PATH OnboardVga;
223 EFI_DEVICE_PATH_PROTOCOL End;
224 } PLATFORM_ONBOARD_VGA_DEVICE_PATH;
225
226 typedef struct {
227 ACPI_HID_DEVICE_PATH PciRootBridge;
228 PCI_DEVICE_PATH AgpBridge;
229 PCI_DEVICE_PATH AgpDevice;
230 EFI_DEVICE_PATH_PROTOCOL End;
231 } PLATFORM_OFFBOARD_VGA_DEVICE_PATH;
232
233 typedef struct {
234 ACPI_HID_DEVICE_PATH PciRootBridge;
235 PCI_DEVICE_PATH IsaBridge;
236 ACPI_HID_DEVICE_PATH IsaSerial;
237 UART_DEVICE_PATH Uart;
238 VENDOR_DEVICE_PATH TerminalType;
239 EFI_DEVICE_PATH_PROTOCOL End;
240 } PLATFORM_ISA_SERIAL_DEVICE_PATH;
241
242 //
243 // Below is the boot option device path
244 //
245 typedef struct {
246 BBS_BBS_DEVICE_PATH LegacyHD;
247 EFI_DEVICE_PATH_PROTOCOL End;
248 } LEGACY_HD_DEVICE_PATH;
249
250 //
251 // Below is the platform IDE device path
252 //
253 typedef struct {
254 ACPI_HID_DEVICE_PATH PciRootBridge;
255 PCI_DEVICE_PATH IsaBridge;
256 ATAPI_DEVICE_PATH Ide;
257 EFI_DEVICE_PATH_PROTOCOL End;
258 } PLATFORM_IDE_DEVICE_PATH;
259
260 //
261 // Floppy device path definition
262 //
263 typedef struct {
264 ACPI_HID_DEVICE_PATH PciRootBridge;
265 PCI_DEVICE_PATH IsaBridge;
266 ACPI_HID_DEVICE_PATH Floppy;
267 EFI_DEVICE_PATH_PROTOCOL End;
268 } PLATFORM_FLOPPY_DEVICE_PATH;
269
270 //
271 // Below is the platform USB controller device path for
272 // USB disk as user authentication device.
273 //
274 typedef struct {
275 ACPI_HID_DEVICE_PATH PciRootBridge;
276 PCI_DEVICE_PATH PciDevice;
277 EFI_DEVICE_PATH_PROTOCOL End;
278 } PLATFORM_USB_DEVICE_PATH;
279
280 //
281 // Below is the platform PCI device path
282 //
283 typedef struct {
284 ACPI_HID_DEVICE_PATH PciRootBridge;
285 PCI_DEVICE_PATH PciDevice;
286 EFI_DEVICE_PATH_PROTOCOL End;
287 } PLATFORM_PCI_DEVICE_PATH;
288
289 typedef enum {
290 PMIC_Equal = 0, // = 0
291 PMIC_Greater_Than, // > 1
292 PMIC_Smaller_Than, // < 2
293 PMIC_Greater_Equal, // >= 3
294 PMIC_Smaller_Equal, // <= 4
295 PMIC_Any // don't care 5
296 } PMIC_Condition_list;
297
298 typedef enum {
299 PMIC_White_List = 0, //White list
300 PMIC_Black_List = 1 //Black list
301 } PMIC_Compliance_mode;
302
303 typedef struct {
304 UINT8 Cond_Choice; // PMIC_Condition_list
305 UINT8 Cond_Number; // the number
306 }PMIC_Condition_Item;
307
308 typedef struct {
309 PMIC_Condition_Item PMIC_BoardID;
310 PMIC_Condition_Item PMIC_FabID;
311 PMIC_Condition_Item Soc_Stepping;//define PMIC type, 1:Dialog , 2:Rohm
312 PMIC_Condition_Item PMIC_VendID;
313 PMIC_Condition_Item PMIC_RevID;
314 PMIC_Compliance_mode mode; //if 1, blacklist; if 0, white list.
315 } PMIC_Compliance_Item;
316
317 //
318 // Platform BDS Functions
319 //
320 VOID
321 PlatformBdsGetDriverOption (
322 IN LIST_ENTRY *BdsDriverLists
323 );
324
325 VOID
326 PlatformBdsPredictBootOption (
327 IN LIST_ENTRY *BdsBootOptionList
328 );
329
330 EFI_STATUS
331 PlatformBdsShowProgress (
332 EFI_GRAPHICS_OUTPUT_BLT_PIXEL TitleForeground,
333 EFI_GRAPHICS_OUTPUT_BLT_PIXEL TitleBackground,
334 CHAR16 *Title,
335 EFI_GRAPHICS_OUTPUT_BLT_PIXEL ProgressColor,
336 UINTN Progress,
337 UINTN PreviousValue
338 );
339
340 VOID
341 PlatformBdsConnectSequence (
342 VOID
343 );
344
345 EFI_STATUS
346 PlatformBdsConnectConsole (
347 IN BDS_CONSOLE_CONNECT_ENTRY *PlatformConsole
348 );
349
350 EFI_STATUS
351 PlatformBdsNoConsoleAction (
352 VOID
353 );
354
355 VOID
356 PlatformBdsEnterFrontPage (
357 IN UINT16 TimeoutDefault,
358 IN BOOLEAN ConnectAllHappened
359 );
360
361 VOID
362 EFIAPI
363 PlatformBdsUserIdentify (
364 OUT EFI_USER_PROFILE_HANDLE *User,
365 OUT BOOLEAN *DeferredImage
366 );
367
368 VOID
369 EFIAPI
370 PlatformBdsConnectAuthDevice (
371 VOID
372 );
373
374 VOID
375 PlatformBdsEnterFrontPageWithHotKey (
376 IN UINT16 TimeoutDefault,
377 IN BOOLEAN ConnectAllHappened
378 );
379
380 EFI_STATUS
381 ShowProgress (
382 IN UINT16 TimeoutDefault
383 );
384
385 EFI_STATUS
386 InitializeFrontPage (
387 IN BOOLEAN InitializeHiiData
388 );
389
390 VOID
391 UpdateFrontPageStrings (
392 VOID
393 );
394
395
396 EFI_STATUS
397 InitBMPackage (
398 VOID
399 );
400
401
402 VOID
403 FreeBMPackage (
404 VOID
405 );
406
407
408 EFI_STATUS
409 CallFrontPage (
410 VOID
411 );
412
413
414 VOID
415 CallBootManager (
416 VOID
417 );
418
419 VOID
420 CallDeviceManager (
421 VOID
422 );
423
424 VOID
425 BdsStartBootMaint (
426 VOID
427 );
428
429 CHAR16 *
430 GetStringById (
431 IN EFI_STRING_ID Id
432 );
433
434 EFI_STATUS
435 WaitForSingleEvent (
436 IN EFI_EVENT Event,
437 IN UINT64 Timeout OPTIONAL
438 );
439
440
441 #define ONE_SECOND 10000000
442 #define FRONT_PAGE_KEY_CONTINUE 0x1000
443 #define FRONT_PAGE_KEY_LANGUAGE 0x1234
444 #define FRONT_PAGE_KEY_BOOT_MANAGER 0x1064
445 #define FRONT_PAGE_KEY_DEVICE_MANAGER 0x8567
446 #define FRONT_PAGE_KEY_BOOT_MAINTAIN 0x9876
447
448 #define PORT_A_DVO 0 // ; DVO A
449 #define PORT_B_DVO 1 // ; DVO B
450 #define PORT_C_DVO 2 // ; DVO C
451 #define PORT_D_DVO 3 // ; DVO D
452 #define PORT_LVDS 4 // ; Integrated LVDS port
453 #define PORT_ANALOG_TV 5 // ; Integrated TV port
454 #define PORT_CRT 6 // ; integrated Analog port
455 #define PORT_B_DP 7 // ; DisplayPort B
456 #define PORT_C_DP 8 // ; DisplayPort C
457 #define PORT_D_DP 9 // ; DisplayPort D
458 #define PORT_A_DP 10 // ; DisplayPort A (for eDP on ILK)
459 #define PORT_B_HDMI 11 // ; HDMI B
460 #define PORT_C_HDMI 12 // ; HDMI C
461 #define PORT_D_HDMI 13 // ; HDMI D
462 #define PORT_B_DVI 14 // ; DVI B
463 #define PORT_C_DVI 15 // ; DVI C
464 #define PORT_D_DVI 16 // ; DVI D
465 #define PORT_MIPI_A 21 // ; MIPI
466 #define PORT_MIPI_B 22
467 #define PORT_MIPI_C 23
468
469
470 extern BOOLEAN gConnectAllHappened;
471 extern UINTN gCallbackKey;
472
473 VOID
474 BdsBootDeviceSelect (
475 VOID
476 );
477 VOID FastBoot(VOID);
478
479 extern BOOLEAN mModeInitialized;
480
481 //
482 // Boot video resolution and text mode.
483 //
484 extern UINT32 mBootHorizontalResolution ;
485 extern UINT32 mBootVerticalResolution ;
486 extern UINT32 mBootTextModeColumn ;
487 extern UINT32 mBootTextModeRow ;
488
489 //
490 // BIOS setup video resolution and text mode.
491 //
492 extern UINT32 mSetupTextModeColumn ;
493 extern UINT32 mSetupTextModeRow ;
494 extern UINT32 mSetupHorizontalResolution ;
495 extern UINT32 mSetupVerticalResolution ;
496 extern EFI_STATUS BdsSetConsoleMode (BOOLEAN);
497 #endif // _BDS_PLATFORM_H