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