summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChen, Pai-chingX <pai-chingx.chen@intel.com>2017-11-01 14:26:00 +0800
committerJiewen Yao <jiewen.yao@intel.com>2017-11-01 15:29:50 +0800
commit661da8820b3afeff4fc9b32e0412f67d554c52a0 (patch)
treed98c8d4e304a47ca33fa83f66c4a0bbfde511ece
parentb0489b8f3f276932db8aa7af3680b41574bb09f3 (diff)
downloadedk2-platforms-661da8820b3afeff4fc9b32e0412f67d554c52a0.tar.xz
Decouple Graphics Console Selection from MinPlatformPkg
Cc: Michael A Kubacki <michael.a.kubacki@intel.com> Cc: Amy Chan <amy.chan@intel.com> Cc: Chasel Chiu <chasel.chiu@intel.com> Cc: Rangasai V Chaganty <rangasai.v.chaganty@intel.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Pai-chingX Chen <pai-chingx.chen@intel.com> Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
-rw-r--r--Platform/Intel/MinPlatformPkg/Bds/Library/DxePlatformBootManagerLib/BdsPlatform.c139
-rw-r--r--Platform/Intel/MinPlatformPkg/Bds/Library/DxePlatformBootManagerLib/DxePlatformBootManagerLib.inf10
-rw-r--r--Platform/Intel/MinPlatformPkg/MinPlatformPkg.dec5
3 files changed, 108 insertions, 46 deletions
diff --git a/Platform/Intel/MinPlatformPkg/Bds/Library/DxePlatformBootManagerLib/BdsPlatform.c b/Platform/Intel/MinPlatformPkg/Bds/Library/DxePlatformBootManagerLib/BdsPlatform.c
index 74c0d2d9a6..ef0bf0bb89 100644
--- a/Platform/Intel/MinPlatformPkg/Bds/Library/DxePlatformBootManagerLib/BdsPlatform.c
+++ b/Platform/Intel/MinPlatformPkg/Bds/Library/DxePlatformBootManagerLib/BdsPlatform.c
@@ -19,6 +19,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include <Protocol/PciRootBridgeIo.h>
#include <Protocol/BlockIo.h>
+#include <Protocol/PciIo.h>
#include <Library/IoLib.h>
#include <Library/PciLib.h>
#include <Guid/EventGroup.h>
@@ -792,6 +793,66 @@ OnReadyToBootCallBack (
}
/**
+ Get Graphics Controller Handle.
+
+ @retval GraphicsController Successfully located
+ @retval NULL Failed to locate
+**/
+EFI_HANDLE
+EFIAPI
+GetGraphicsController (
+ VOID
+ )
+{
+ EFI_STATUS Status;
+ UINTN Index;
+ EFI_HANDLE *PciHandles;
+ UINTN PciHandlesSize;
+ EFI_PCI_IO_PROTOCOL *PciIo;
+ EFI_HANDLE GraphicsController;
+ UINTN GraphicsPciSeg;
+ UINTN GraphicsPciBus;
+ UINTN GraphicsPciDev;
+ UINTN GraphicsPciFun;
+
+ GraphicsController = NULL;
+
+ Status = gBS->LocateHandleBuffer (
+ ByProtocol,
+ &gEfiPciIoProtocolGuid,
+ NULL,
+ &PciHandlesSize,
+ &PciHandles
+ );
+ if (!RETURN_ERROR (Status)) {
+ for (Index = 0; Index < PciHandlesSize; Index++) {
+ gBS->HandleProtocol (
+ PciHandles[Index],
+ &gEfiPciIoProtocolGuid,
+ (VOID **) &PciIo
+ );
+ Status = PciIo->GetLocation (
+ PciIo,
+ &GraphicsPciSeg,
+ &GraphicsPciBus,
+ &GraphicsPciDev,
+ &GraphicsPciFun
+ );
+ if (!RETURN_ERROR (Status) &&
+ (UINT16) GraphicsPciSeg == PcdGet16 (PcdGraphicsPciSeg) &&
+ (UINT8) GraphicsPciBus == PcdGet8 (PcdGraphicsPciBus) &&
+ (UINT8) GraphicsPciDev == PcdGet8 (PcdGraphicsPciDev) &&
+ (UINT8) GraphicsPciFun == PcdGet8 (PcdGraphicsPciFun)) {
+ GraphicsController = PciHandles[Index];
+ Index = PciHandlesSize;
+ }
+ }
+ }
+
+ return GraphicsController;
+}
+
+/**
Platform Bds init. Incude the platform firmware vendor, revision
and so crc check.
**/
@@ -805,13 +866,12 @@ PlatformBootManagerBeforeConsole (
UINTN Index;
EFI_DEVICE_PATH_PROTOCOL *VarConOut;
EFI_DEVICE_PATH_PROTOCOL *VarConIn;
- EFI_DEVICE_PATH_PROTOCOL *TempDevicePath;
- EFI_DEVICE_PATH_PROTOCOL *ConsoleOut;
- EFI_DEVICE_PATH_PROTOCOL *Temp;
+ EFI_DEVICE_PATH_PROTOCOL *GopDevicePath;
+ EFI_DEVICE_PATH_PROTOCOL *ConOutDevicePath;
+ EFI_DEVICE_PATH_PROTOCOL *UpdatedConOutDevicePath;
EFI_DEVICE_PATH_PROTOCOL *Instance;
EFI_DEVICE_PATH_PROTOCOL *Next;
- EFI_HANDLE VideoHandle;
- BOOLEAN IsIgd;
+ EFI_HANDLE GraphicsControllerHandle;
EFI_EVENT Event;
UINTN InstanceSize;
@@ -852,44 +912,6 @@ PlatformBootManagerBeforeConsole (
ConnectRootBridge (FALSE);
//
- // Update ConOut variable according to the PrimaryDisplay setting
- //
- GetEfiGlobalVariable2 (L"ConOut", &ConsoleOut, NULL);
- //
- // Add IGD to ConOut
- //
- IsIgd = TRUE;
- TempDevicePath = (EFI_DEVICE_PATH_PROTOCOL *) &gPlatformIGDDevice;
- Status = gBS->LocateDevicePath (&gEfiPciIoProtocolGuid, &TempDevicePath, &VideoHandle);
-
- if ((VideoHandle != NULL) && (IsIgd == TRUE)) {
- //
- // Connect the GOP driver
- //
- gBS->ConnectController (VideoHandle, NULL, NULL, TRUE);
-
- //
- // Get the GOP device path
- // NOTE: We may get a device path that contains Controller node in it.
- //
- TempDevicePath = EfiBootManagerGetGopDevicePath (VideoHandle);
- if (TempDevicePath != NULL) {
- Temp = ConsoleOut;
- ConsoleOut = UpdateDevicePath (ConsoleOut, TempDevicePath);
- if (Temp != NULL) {
- FreePool (Temp);
- }
- FreePool (TempDevicePath);
- Status = gRT->SetVariable (
- L"ConOut",
- &gEfiGlobalVariableGuid,
- EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_BOOTSERVICE_ACCESS,
- GetDevicePathSize (ConsoleOut),
- ConsoleOut
- );
- }
- }
- //
// Fill ConIn/ConOut in Full Configuration boot mode
//
DEBUG ((DEBUG_INFO, "PlatformBootManagerInit - %x\n", gBootMode));
@@ -988,6 +1010,37 @@ PlatformBootManagerBeforeConsole (
//
EfiBootManagerDispatchDeferredImages ();
+ //
+ // Update ConOut variable
+ //
+ GraphicsControllerHandle = GetGraphicsController ();
+ if (GraphicsControllerHandle != NULL) {
+ //
+ // Connect the GOP driver
+ //
+ gBS->ConnectController (GraphicsControllerHandle, NULL, NULL, TRUE);
+
+ //
+ // Get the GOP device path
+ // NOTE: We may get a device path that contains Controller node in it.
+ //
+ GopDevicePath = EfiBootManagerGetGopDevicePath (GraphicsControllerHandle);
+ if (GopDevicePath != NULL) {
+ GetEfiGlobalVariable2 (L"ConOut", &ConOutDevicePath, NULL);
+ UpdatedConOutDevicePath = UpdateDevicePath (ConOutDevicePath, GopDevicePath);
+ if (ConOutDevicePath != NULL) {
+ FreePool (ConOutDevicePath);
+ }
+ FreePool (GopDevicePath);
+ Status = gRT->SetVariable (
+ L"ConOut",
+ &gEfiGlobalVariableGuid,
+ EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_BOOTSERVICE_ACCESS,
+ GetDevicePathSize (UpdatedConOutDevicePath),
+ UpdatedConOutDevicePath
+ );
+ }
+ }
}
diff --git a/Platform/Intel/MinPlatformPkg/Bds/Library/DxePlatformBootManagerLib/DxePlatformBootManagerLib.inf b/Platform/Intel/MinPlatformPkg/Bds/Library/DxePlatformBootManagerLib/DxePlatformBootManagerLib.inf
index 19d3b1acca..fb4435203e 100644
--- a/Platform/Intel/MinPlatformPkg/Bds/Library/DxePlatformBootManagerLib/DxePlatformBootManagerLib.inf
+++ b/Platform/Intel/MinPlatformPkg/Bds/Library/DxePlatformBootManagerLib/DxePlatformBootManagerLib.inf
@@ -54,7 +54,7 @@
MinPlatformPkg/MinPlatformPkg.dec
[Pcd]
- gMinPlatformModuleTokenSpaceGuid.PcdTpm2Enable ## CONSUMES
+ gMinPlatformModuleTokenSpaceGuid.PcdTpm2Enable ## CONSUMES
gEfiMdePkgTokenSpaceGuid.PcdPlatformBootTimeOut ## PRODUCES
gEfiMdeModulePkgTokenSpaceGuid.PcdVideoHorizontalResolution ## PRODUCES
gEfiMdeModulePkgTokenSpaceGuid.PcdVideoVerticalResolution ## PRODUCES
@@ -65,8 +65,12 @@
gEfiMdeModulePkgTokenSpaceGuid.PcdSetupVideoHorizontalResolution ## CONSUMES
gEfiMdeModulePkgTokenSpaceGuid.PcdSetupVideoVerticalResolution ## CONSUMES
gEfiMdeModulePkgTokenSpaceGuid.PcdConInConnectOnDemand ## PRODUCES
- gMinPlatformModuleTokenSpaceGuid.PcdPlatformMemoryCheckLevel ## CONSUMES
- gMinPlatformModuleTokenSpaceGuid.PcdBootToShellOnly
+ gMinPlatformModuleTokenSpaceGuid.PcdPlatformMemoryCheckLevel ## CONSUMES
+ gMinPlatformModuleTokenSpaceGuid.PcdBootToShellOnly ## CONSUMES
+ gMinPlatformModuleTokenSpaceGuid.PcdGraphicsPciSeg ## CONSUMES
+ gMinPlatformModuleTokenSpaceGuid.PcdGraphicsPciBus ## CONSUMES
+ gMinPlatformModuleTokenSpaceGuid.PcdGraphicsPciDev ## CONSUMES
+ gMinPlatformModuleTokenSpaceGuid.PcdGraphicsPciFun ## CONSUMES
[Sources]
BdsPlatform.c
diff --git a/Platform/Intel/MinPlatformPkg/MinPlatformPkg.dec b/Platform/Intel/MinPlatformPkg/MinPlatformPkg.dec
index 05bdf234c5..71a2afcb93 100644
--- a/Platform/Intel/MinPlatformPkg/MinPlatformPkg.dec
+++ b/Platform/Intel/MinPlatformPkg/MinPlatformPkg.dec
@@ -174,6 +174,11 @@ gMinPlatformModuleTokenSpaceGuid.PcdTestPointIbvPlatformFeature|{0x01, 0x7F, 0x3
[PcdsDynamic]
[PcdsFixedAtBuild, PcdsPatchableInModule, PcdsDynamic, PcdsDynamicEx]
+
+ gMinPlatformModuleTokenSpaceGuid.PcdGraphicsPciSeg|0x0|UINT16|0x00020000
+ gMinPlatformModuleTokenSpaceGuid.PcdGraphicsPciBus|0x0|UINT8|0x00020001
+ gMinPlatformModuleTokenSpaceGuid.PcdGraphicsPciDev|0x2|UINT8|0x00020002
+ gMinPlatformModuleTokenSpaceGuid.PcdGraphicsPciFun|0x0|UINT8|0x00020003
##
## Allocate 56 KB [0x2000..0xFFFF] of I/O space for Pci Devices