[edk2-devel] [PATCH] UefiPayloadPkg: Add PlatformGopPolicy

Sean Rhodes posted 1 patch 2 years, 2 months ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/edk2 tags/patchew/61b8da797bacd4d2fa4708e042765c8d157b1e71.1644531852.git.sean@starlabs.systems
.../PlatformGopPolicy/PlatformGopPolicy.c     | 161 ++++++++++++++++++
.../PlatformGopPolicy/PlatformGopPolicy.h     |  62 +++++++
.../PlatformGopPolicy/PlatformGopPolicy.inf   |  47 +++++
UefiPayloadPkg/UefiPayloadPkg.dsc             |   5 +
UefiPayloadPkg/UefiPayloadPkg.fdf             |  14 ++
5 files changed, 289 insertions(+)
create mode 100644 UefiPayloadPkg/PlatformGopPolicy/PlatformGopPolicy.c
create mode 100644 UefiPayloadPkg/PlatformGopPolicy/PlatformGopPolicy.h
create mode 100644 UefiPayloadPkg/PlatformGopPolicy/PlatformGopPolicy.inf
[edk2-devel] [PATCH] UefiPayloadPkg: Add PlatformGopPolicy
Posted by Sean Rhodes 2 years, 2 months ago
From: Matt DeVillier <matt.devillier@gmail.com>

Add PlatformGopPolicy to use external GOP driver

Cc: Guo Dong <guo.dong@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Maurice Ma <maurice.ma@intel.com>
Cc: Benjamin You <benjamin.you@intel.com>
Signed-off-by: Matt DeVillier <matt.devillier@gmail.com>
---
 .../PlatformGopPolicy/PlatformGopPolicy.c     | 161 ++++++++++++++++++
 .../PlatformGopPolicy/PlatformGopPolicy.h     |  62 +++++++
 .../PlatformGopPolicy/PlatformGopPolicy.inf   |  47 +++++
 UefiPayloadPkg/UefiPayloadPkg.dsc             |   5 +
 UefiPayloadPkg/UefiPayloadPkg.fdf             |  14 ++
 5 files changed, 289 insertions(+)
 create mode 100644 UefiPayloadPkg/PlatformGopPolicy/PlatformGopPolicy.c
 create mode 100644 UefiPayloadPkg/PlatformGopPolicy/PlatformGopPolicy.h
 create mode 100644 UefiPayloadPkg/PlatformGopPolicy/PlatformGopPolicy.inf

diff --git a/UefiPayloadPkg/PlatformGopPolicy/PlatformGopPolicy.c b/UefiPayloadPkg/PlatformGopPolicy/PlatformGopPolicy.c
new file mode 100644
index 0000000000..31c61d967e
--- /dev/null
+++ b/UefiPayloadPkg/PlatformGopPolicy/PlatformGopPolicy.c
@@ -0,0 +1,161 @@
+/** @file
+
+  Copyright (c) 2021, Intel Corporation. All rights reserved.<BR>
+
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include <Library/BaseMemoryLib.h>
+#include <Library/DebugLib.h>
+#include <Protocol/FirmwareVolume2.h>
+#include "PlatformGopPolicy.h"
+
+#include <Library/UefiBootServicesTableLib.h>
+#include <Library/UefiRuntimeServicesTableLib.h>
+
+PLATFORM_GOP_POLICY_PROTOCOL  mPlatformGOPPolicy;
+
+/**
+  The function will execute with as the platform policy, and gives
+  the Platform Lid Status. IBV/OEM can customize this code for their specific
+  policy action.
+
+  @param  CurrentLidStatus  Gives the current LID Status
+
+  @retval EFI_SUCCESS.
+**/
+EFI_STATUS
+EFIAPI
+GetPlatformLidStatus (
+  OUT LID_STATUS  *CurrentLidStatus
+  )
+{
+  *CurrentLidStatus = LidOpen;
+
+  return EFI_SUCCESS;
+}
+
+/**
+  The function will execute and gives the Video Bios Table Size and Address.
+
+  @param  VbtAddress  Gives the Physical Address of Video BIOS Table
+
+  @param  VbtSize     Gives the Size of Video BIOS Table
+
+  @retval EFI_STATUS.
+**/
+EFI_STATUS
+EFIAPI
+GetVbtData (
+  OUT EFI_PHYSICAL_ADDRESS  *VbtAddress,
+  OUT UINT32                *VbtSize
+  )
+{
+  EFI_STATUS                     Status;
+  UINTN                          FvProtocolCount;
+  EFI_HANDLE                     *FvHandles;
+  EFI_FIRMWARE_VOLUME2_PROTOCOL  *Fv;
+  UINTN                          Index;
+  UINT32                         AuthenticationStatus;
+
+  UINT8  *Buffer;
+  UINTN  VbtBufferSize;
+
+  Buffer    = 0;
+  FvHandles = NULL;
+
+  if ((VbtAddress == NULL) || (VbtSize == NULL)) {
+    return EFI_INVALID_PARAMETER;
+  }
+
+  Status = gBS->LocateHandleBuffer (
+                  ByProtocol,
+                  &gEfiFirmwareVolume2ProtocolGuid,
+                  NULL,
+                  &FvProtocolCount,
+                  &FvHandles
+                  );
+
+  if (!EFI_ERROR (Status)) {
+    for (Index = 0; Index < FvProtocolCount; Index++) {
+      Status = gBS->HandleProtocol (
+                      FvHandles[Index],
+                      &gEfiFirmwareVolume2ProtocolGuid,
+                      (VOID **)&Fv
+                      );
+      VbtBufferSize = 0;
+      Status        = Fv->ReadSection (
+                            Fv,
+                            &gBmpImageGuid,
+                            EFI_SECTION_RAW,
+                            0,
+                            (void **)&Buffer,
+                            &VbtBufferSize,
+                            &AuthenticationStatus
+                            );
+
+      if (!EFI_ERROR (Status)) {
+        *VbtAddress = (EFI_PHYSICAL_ADDRESS)(UINTN)Buffer;
+        *VbtSize    = (UINT32)VbtBufferSize;
+        Status      = EFI_SUCCESS;
+        break;
+      }
+    }
+  } else {
+    Status = EFI_NOT_FOUND;
+  }
+
+  if (FvHandles != NULL) {
+    gBS->FreePool (FvHandles);
+    FvHandles = NULL;
+  }
+
+  return Status;
+}
+
+/**
+  Entry point for the Platform GOP Policy Driver.
+
+  @param ImageHandle       Image handle of this driver.
+  @param SystemTable       Global system service table.
+
+  @retval EFI_SUCCESS           Initialization complete.
+  @retval EFI_OUT_OF_RESOURCES  Do not have enough resources to initialize the driver.
+**/
+EFI_STATUS
+EFIAPI
+PlatformGOPPolicyEntryPoint (
+  IN EFI_HANDLE        ImageHandle,
+  IN EFI_SYSTEM_TABLE  *SystemTable
+  )
+
+{
+  EFI_STATUS  Status;
+
+  Status = EFI_SUCCESS;
+
+  gBS = SystemTable->BootServices;
+
+  gBS->SetMem (
+         &mPlatformGOPPolicy,
+         sizeof (PLATFORM_GOP_POLICY_PROTOCOL),
+         0
+         );
+
+  mPlatformGOPPolicy.Revision             = PLATFORM_GOP_POLICY_PROTOCOL_REVISION_01;
+  mPlatformGOPPolicy.GetPlatformLidStatus = GetPlatformLidStatus;
+  mPlatformGOPPolicy.GetVbtData           = GetVbtData;
+
+  //
+  // Install protocol to allow access to this Policy.
+  //
+  Status = gBS->InstallMultipleProtocolInterfaces (
+                  &ImageHandle,
+                  &gPlatformGOPPolicyGuid,
+                  &mPlatformGOPPolicy,
+                  NULL
+                  );
+
+  return Status;
+}
diff --git a/UefiPayloadPkg/PlatformGopPolicy/PlatformGopPolicy.h b/UefiPayloadPkg/PlatformGopPolicy/PlatformGopPolicy.h
new file mode 100644
index 0000000000..a8ac0be1b8
--- /dev/null
+++ b/UefiPayloadPkg/PlatformGopPolicy/PlatformGopPolicy.h
@@ -0,0 +1,62 @@
+/** @file
+  The header file for Platform GPO.
+
+Copyright (c) 2021, Intel Corporation. All rights reserved.<BR>
+SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef PLATFORM_GOP_POLICY_PROTOCOL_H_
+#define PLATFORM_GOP_POLICY_PROTOCOL_H_
+
+#define EFI_PLATFORM_GOP_POLICY_PROTOCOL_GUID \
+  { 0xec2e931b, 0x3281, 0x48a5, 0x81, 0x7, 0xdf, 0x8a, 0x8b, 0xed, 0x3c, 0x5d }
+
+#define EFI_BMP_IMAGE_GUID \
+  { 0x878AC2CC, 0x5343, 0x46F2, 0xB5, 0x63, 0x51, 0xF8, 0x9D, 0xAF, 0x56, 0xBA }
+
+#define PLATFORM_GOP_POLICY_PROTOCOL_REVISION_01 0x01
+#define PLATFORM_GOP_POLICY_PROTOCOL_REVISION_02 x0222
+
+#pragma pack(1)
+
+typedef enum {
+  LidClosed,
+  LidOpen,
+  LidStatusMax
+} LID_STATUS;
+
+typedef enum {
+  Docked,
+  UnDocked,
+  DockStatusMax
+} DOCK_STATUS;
+
+typedef EFI_STATUS \
+(EFIAPI *GET_PLATFORM_LID_STATUS) (
+  OUT LID_STATUS  *CurrentLidStatus
+  );
+
+typedef EFI_STATUS \
+(EFIAPI *GET_VBT_DATA) (
+   OUT EFI_PHYSICAL_ADDRESS  *VbtAddress,
+   OUT UINT32                *VbtSize
+   );
+
+#pragma pack()
+
+typedef struct _PLATFORM_GOP_POLICY_PROTOCOL {
+  UINT32                   Revision;
+  GET_PLATFORM_LID_STATUS  GetPlatformLidStatus;
+  GET_VBT_DATA             GetVbtData;
+} PLATFORM_GOP_POLICY_PROTOCOL;
+
+//
+// Extern the GUID for protocol users.
+//
+extern EFI_GUID  gPlatformGOPPolicyGuid;
+
+extern EFI_GUID  gBmpImageGuid;
+
+#endif
+
diff --git a/UefiPayloadPkg/PlatformGopPolicy/PlatformGopPolicy.inf b/UefiPayloadPkg/PlatformGopPolicy/PlatformGopPolicy.inf
new file mode 100644
index 0000000000..cdcdc86e2e
--- /dev/null
+++ b/UefiPayloadPkg/PlatformGopPolicy/PlatformGopPolicy.inf
@@ -0,0 +1,47 @@
+## @file
+#  Module for using VBT for GOP.
+#
+# Copyright (c) 2021, Intel Corporation. All rights reserved.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[Defines]
+  INF_VERSION                    = 0x00010005
+  BASE_NAME                      = PlatformGOPPolicy
+  FILE_GUID                      = 9737D7CA-D869-45e5-A5EF-75D9438688DE
+  MODULE_TYPE                    = DXE_DRIVER
+  VERSION_STRING                 = 1.0
+  ENTRY_POINT                    = PlatformGOPPolicyEntryPoint
+
+#
+# The following information is for reference only and not required by the build tools.
+#
+#  VALID_ARCHITECTURES           = X64
+#
+
+[Sources.common]
+  PlatformGopPolicy.h
+  PlatformGopPolicy.c
+
+[Packages]
+  MdePkg/MdePkg.dec
+  UefiPayloadPkg/UefiPayloadPkg.dec
+
+[LibraryClasses]
+  BaseLib
+  DebugLib
+  UefiDriverEntryPoint
+  UefiRuntimeServicesTableLib
+
+[Guids]
+  gBmpImageGuid
+
+[Protocols]
+  gEfiFirmwareVolume2ProtocolGuid
+  gPlatformGOPPolicyGuid
+
+[Depex]
+  gEfiVariableArchProtocolGuid
+
diff --git a/UefiPayloadPkg/UefiPayloadPkg.dsc b/UefiPayloadPkg/UefiPayloadPkg.dsc
index 1ce96a51c1..cb050b7269 100644
--- a/UefiPayloadPkg/UefiPayloadPkg.dsc
+++ b/UefiPayloadPkg/UefiPayloadPkg.dsc
@@ -33,6 +33,7 @@
   DEFINE UNIVERSAL_PAYLOAD            = FALSE
   DEFINE SECURITY_STUB_ENABLE         = TRUE
   DEFINE SMM_SUPPORT                  = FALSE
+  DEFINE USE_PLATFORM_GOP             = FALSE
   #
   # SBL:      UEFI payload for Slim Bootloader
   # COREBOOT: UEFI payload for coreboot
@@ -666,7 +667,11 @@
 !if $(DISABLE_SERIAL_TERMINAL) == FALSE
   MdeModulePkg/Universal/Console/TerminalDxe/TerminalDxe.inf
 !endif
+!if $(USE_PLATFORM_GOP) == TRUE
+  UefiPayloadPkg/PlatformGopPolicy/PlatformGopPolicy.inf
+!else
   UefiPayloadPkg/GraphicsOutputDxe/GraphicsOutputDxe.inf
+!endif
 !if $(PERFORMANCE_MEASUREMENT_ENABLE)
   MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableDxe/FirmwarePerformanceDxe.inf
 !endif
diff --git a/UefiPayloadPkg/UefiPayloadPkg.fdf b/UefiPayloadPkg/UefiPayloadPkg.fdf
index c7b04978ad..ca3196256e 100644
--- a/UefiPayloadPkg/UefiPayloadPkg.fdf
+++ b/UefiPayloadPkg/UefiPayloadPkg.fdf
@@ -187,7 +187,21 @@ INF MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsoleDxe.inf
 !if $(DISABLE_SERIAL_TERMINAL) == FALSE
 INF MdeModulePkg/Universal/Console/TerminalDxe/TerminalDxe.inf
 !endif
+!if $(USE_PLATFORM_GOP) == TRUE
+INF UefiPayloadPkg/PlatformGopPolicy/PlatformGopPolicy.inf
+FILE DRIVER = FF0C8745-3270-4439-B74F-3E45F8C77064 {
+  SECTION DXE_DEPEX_EXP = {gPlatformGOPPolicyGuid}
+  SECTION PE32 = UefiPayloadPkg/IntelGopDriver.efi
+  SECTION UI = "IntelGopDriver"
+}
+
+FILE FREEFORM = 878AC2CC-5343-46F2-B563-51F89DAF56BA {
+  SECTION RAW = UefiPayloadPkg/vbt.bin
+  SECTION UI = "IntelGopVbt"
+}
+!else
 INF UefiPayloadPkg/GraphicsOutputDxe/GraphicsOutputDxe.inf
+!endif
 
 #
 # SCSI/ATA/IDE/DISK Support
-- 
2.32.0



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#86594): https://edk2.groups.io/g/devel/message/86594
Mute This Topic: https://groups.io/mt/89057277/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-


Re: [edk2-devel] [PATCH] UefiPayloadPkg: Add PlatformGopPolicy
Posted by Guo Dong 2 years, 2 months ago
+  SECTION PE32 = UefiPayloadPkg/IntelGopDriver.efi

I didn't see file IntelGopDriver.efi in this patch while this file is added into FDF file.
Is this a generic GOP driver that could work on different platform?

Thanks,
Guo

-----Original Message-----
From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Sean Rhodes
Sent: Thursday, February 10, 2022 3:24 PM
To: devel@edk2.groups.io
Cc: Dong, Guo <guo.dong@intel.com>; Matt DeVillier <matt.devillier@gmail.com>; Ni, Ray <ray.ni@intel.com>; Ma, Maurice <maurice.ma@intel.com>; You, Benjamin <benjamin.you@intel.com>
Subject: [edk2-devel] [PATCH] UefiPayloadPkg: Add PlatformGopPolicy

From: Matt DeVillier <matt.devillier@gmail.com>

Add PlatformGopPolicy to use external GOP driver

Cc: Guo Dong <guo.dong@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Maurice Ma <maurice.ma@intel.com>
Cc: Benjamin You <benjamin.you@intel.com>
Signed-off-by: Matt DeVillier <matt.devillier@gmail.com>
---
 .../PlatformGopPolicy/PlatformGopPolicy.c     | 161 ++++++++++++++++++
 .../PlatformGopPolicy/PlatformGopPolicy.h     |  62 +++++++
 .../PlatformGopPolicy/PlatformGopPolicy.inf   |  47 +++++
 UefiPayloadPkg/UefiPayloadPkg.dsc             |   5 +
 UefiPayloadPkg/UefiPayloadPkg.fdf             |  14 ++
 5 files changed, 289 insertions(+)
 create mode 100644 UefiPayloadPkg/PlatformGopPolicy/PlatformGopPolicy.c
 create mode 100644 UefiPayloadPkg/PlatformGopPolicy/PlatformGopPolicy.h
 create mode 100644 UefiPayloadPkg/PlatformGopPolicy/PlatformGopPolicy.inf

diff --git a/UefiPayloadPkg/PlatformGopPolicy/PlatformGopPolicy.c b/UefiPayloadPkg/PlatformGopPolicy/PlatformGopPolicy.c
new file mode 100644
index 0000000000..31c61d967e
--- /dev/null
+++ b/UefiPayloadPkg/PlatformGopPolicy/PlatformGopPolicy.c
@@ -0,0 +1,161 @@
+/** @file

+

+  Copyright (c) 2021, Intel Corporation. All rights reserved.<BR>

+

+  SPDX-License-Identifier: BSD-2-Clause-Patent

+

+**/

+

+#include <Library/BaseMemoryLib.h>

+#include <Library/DebugLib.h>

+#include <Protocol/FirmwareVolume2.h>

+#include "PlatformGopPolicy.h"

+

+#include <Library/UefiBootServicesTableLib.h>

+#include <Library/UefiRuntimeServicesTableLib.h>

+

+PLATFORM_GOP_POLICY_PROTOCOL  mPlatformGOPPolicy;

+

+/**

+  The function will execute with as the platform policy, and gives

+  the Platform Lid Status. IBV/OEM can customize this code for their specific

+  policy action.

+

+  @param  CurrentLidStatus  Gives the current LID Status

+

+  @retval EFI_SUCCESS.

+**/

+EFI_STATUS

+EFIAPI

+GetPlatformLidStatus (

+  OUT LID_STATUS  *CurrentLidStatus

+  )

+{

+  *CurrentLidStatus = LidOpen;

+

+  return EFI_SUCCESS;

+}

+

+/**

+  The function will execute and gives the Video Bios Table Size and Address.

+

+  @param  VbtAddress  Gives the Physical Address of Video BIOS Table

+

+  @param  VbtSize     Gives the Size of Video BIOS Table

+

+  @retval EFI_STATUS.

+**/

+EFI_STATUS

+EFIAPI

+GetVbtData (

+  OUT EFI_PHYSICAL_ADDRESS  *VbtAddress,

+  OUT UINT32                *VbtSize

+  )

+{

+  EFI_STATUS                     Status;

+  UINTN                          FvProtocolCount;

+  EFI_HANDLE                     *FvHandles;

+  EFI_FIRMWARE_VOLUME2_PROTOCOL  *Fv;

+  UINTN                          Index;

+  UINT32                         AuthenticationStatus;

+

+  UINT8  *Buffer;

+  UINTN  VbtBufferSize;

+

+  Buffer    = 0;

+  FvHandles = NULL;

+

+  if ((VbtAddress == NULL) || (VbtSize == NULL)) {

+    return EFI_INVALID_PARAMETER;

+  }

+

+  Status = gBS->LocateHandleBuffer (

+                  ByProtocol,

+                  &gEfiFirmwareVolume2ProtocolGuid,

+                  NULL,

+                  &FvProtocolCount,

+                  &FvHandles

+                  );

+

+  if (!EFI_ERROR (Status)) {

+    for (Index = 0; Index < FvProtocolCount; Index++) {

+      Status = gBS->HandleProtocol (

+                      FvHandles[Index],

+                      &gEfiFirmwareVolume2ProtocolGuid,

+                      (VOID **)&Fv

+                      );

+      VbtBufferSize = 0;

+      Status        = Fv->ReadSection (

+                            Fv,

+                            &gBmpImageGuid,

+                            EFI_SECTION_RAW,

+                            0,

+                            (void **)&Buffer,

+                            &VbtBufferSize,

+                            &AuthenticationStatus

+                            );

+

+      if (!EFI_ERROR (Status)) {

+        *VbtAddress = (EFI_PHYSICAL_ADDRESS)(UINTN)Buffer;

+        *VbtSize    = (UINT32)VbtBufferSize;

+        Status      = EFI_SUCCESS;

+        break;

+      }

+    }

+  } else {

+    Status = EFI_NOT_FOUND;

+  }

+

+  if (FvHandles != NULL) {

+    gBS->FreePool (FvHandles);

+    FvHandles = NULL;

+  }

+

+  return Status;

+}

+

+/**

+  Entry point for the Platform GOP Policy Driver.

+

+  @param ImageHandle       Image handle of this driver.

+  @param SystemTable       Global system service table.

+

+  @retval EFI_SUCCESS           Initialization complete.

+  @retval EFI_OUT_OF_RESOURCES  Do not have enough resources to initialize the driver.

+**/

+EFI_STATUS

+EFIAPI

+PlatformGOPPolicyEntryPoint (

+  IN EFI_HANDLE        ImageHandle,

+  IN EFI_SYSTEM_TABLE  *SystemTable

+  )

+

+{

+  EFI_STATUS  Status;

+

+  Status = EFI_SUCCESS;

+

+  gBS = SystemTable->BootServices;

+

+  gBS->SetMem (

+         &mPlatformGOPPolicy,

+         sizeof (PLATFORM_GOP_POLICY_PROTOCOL),

+         0

+         );

+

+  mPlatformGOPPolicy.Revision             = PLATFORM_GOP_POLICY_PROTOCOL_REVISION_01;

+  mPlatformGOPPolicy.GetPlatformLidStatus = GetPlatformLidStatus;

+  mPlatformGOPPolicy.GetVbtData           = GetVbtData;

+

+  //

+  // Install protocol to allow access to this Policy.

+  //

+  Status = gBS->InstallMultipleProtocolInterfaces (

+                  &ImageHandle,

+                  &gPlatformGOPPolicyGuid,

+                  &mPlatformGOPPolicy,

+                  NULL

+                  );

+

+  return Status;

+}

diff --git a/UefiPayloadPkg/PlatformGopPolicy/PlatformGopPolicy.h b/UefiPayloadPkg/PlatformGopPolicy/PlatformGopPolicy.h
new file mode 100644
index 0000000000..a8ac0be1b8
--- /dev/null
+++ b/UefiPayloadPkg/PlatformGopPolicy/PlatformGopPolicy.h
@@ -0,0 +1,62 @@
+/** @file

+  The header file for Platform GPO.

+

+Copyright (c) 2021, Intel Corporation. All rights reserved.<BR>

+SPDX-License-Identifier: BSD-2-Clause-Patent

+

+**/

+

+#ifndef PLATFORM_GOP_POLICY_PROTOCOL_H_

+#define PLATFORM_GOP_POLICY_PROTOCOL_H_

+

+#define EFI_PLATFORM_GOP_POLICY_PROTOCOL_GUID \

+  { 0xec2e931b, 0x3281, 0x48a5, 0x81, 0x7, 0xdf, 0x8a, 0x8b, 0xed, 0x3c, 0x5d }

+

+#define EFI_BMP_IMAGE_GUID \

+  { 0x878AC2CC, 0x5343, 0x46F2, 0xB5, 0x63, 0x51, 0xF8, 0x9D, 0xAF, 0x56, 0xBA }

+

+#define PLATFORM_GOP_POLICY_PROTOCOL_REVISION_01 0x01

+#define PLATFORM_GOP_POLICY_PROTOCOL_REVISION_02 x0222

+

+#pragma pack(1)

+

+typedef enum {

+  LidClosed,

+  LidOpen,

+  LidStatusMax

+} LID_STATUS;

+

+typedef enum {

+  Docked,

+  UnDocked,

+  DockStatusMax

+} DOCK_STATUS;

+

+typedef EFI_STATUS \

+(EFIAPI *GET_PLATFORM_LID_STATUS) (

+  OUT LID_STATUS  *CurrentLidStatus

+  );

+

+typedef EFI_STATUS \

+(EFIAPI *GET_VBT_DATA) (

+   OUT EFI_PHYSICAL_ADDRESS  *VbtAddress,

+   OUT UINT32                *VbtSize

+   );

+

+#pragma pack()

+

+typedef struct _PLATFORM_GOP_POLICY_PROTOCOL {

+  UINT32                   Revision;

+  GET_PLATFORM_LID_STATUS  GetPlatformLidStatus;

+  GET_VBT_DATA             GetVbtData;

+} PLATFORM_GOP_POLICY_PROTOCOL;

+

+//

+// Extern the GUID for protocol users.

+//

+extern EFI_GUID  gPlatformGOPPolicyGuid;

+

+extern EFI_GUID  gBmpImageGuid;

+

+#endif

+

diff --git a/UefiPayloadPkg/PlatformGopPolicy/PlatformGopPolicy.inf b/UefiPayloadPkg/PlatformGopPolicy/PlatformGopPolicy.inf
new file mode 100644
index 0000000000..cdcdc86e2e
--- /dev/null
+++ b/UefiPayloadPkg/PlatformGopPolicy/PlatformGopPolicy.inf
@@ -0,0 +1,47 @@
+## @file

+#  Module for using VBT for GOP.

+#

+# Copyright (c) 2021, Intel Corporation. All rights reserved.<BR>

+#

+# SPDX-License-Identifier: BSD-2-Clause-Patent

+#

+##

+

+[Defines]

+  INF_VERSION                    = 0x00010005

+  BASE_NAME                      = PlatformGOPPolicy

+  FILE_GUID                      = 9737D7CA-D869-45e5-A5EF-75D9438688DE

+  MODULE_TYPE                    = DXE_DRIVER

+  VERSION_STRING                 = 1.0

+  ENTRY_POINT                    = PlatformGOPPolicyEntryPoint

+

+#

+# The following information is for reference only and not required by the build tools.

+#

+#  VALID_ARCHITECTURES           = X64

+#

+

+[Sources.common]

+  PlatformGopPolicy.h

+  PlatformGopPolicy.c

+

+[Packages]

+  MdePkg/MdePkg.dec

+  UefiPayloadPkg/UefiPayloadPkg.dec

+

+[LibraryClasses]

+  BaseLib

+  DebugLib

+  UefiDriverEntryPoint

+  UefiRuntimeServicesTableLib

+

+[Guids]

+  gBmpImageGuid

+

+[Protocols]

+  gEfiFirmwareVolume2ProtocolGuid

+  gPlatformGOPPolicyGuid

+

+[Depex]

+  gEfiVariableArchProtocolGuid

+

diff --git a/UefiPayloadPkg/UefiPayloadPkg.dsc b/UefiPayloadPkg/UefiPayloadPkg.dsc
index 1ce96a51c1..cb050b7269 100644
--- a/UefiPayloadPkg/UefiPayloadPkg.dsc
+++ b/UefiPayloadPkg/UefiPayloadPkg.dsc
@@ -33,6 +33,7 @@
   DEFINE UNIVERSAL_PAYLOAD            = FALSE

   DEFINE SECURITY_STUB_ENABLE         = TRUE

   DEFINE SMM_SUPPORT                  = FALSE

+  DEFINE USE_PLATFORM_GOP             = FALSE

   #

   # SBL:      UEFI payload for Slim Bootloader

   # COREBOOT: UEFI payload for coreboot

@@ -666,7 +667,11 @@
 !if $(DISABLE_SERIAL_TERMINAL) == FALSE

   MdeModulePkg/Universal/Console/TerminalDxe/TerminalDxe.inf

 !endif

+!if $(USE_PLATFORM_GOP) == TRUE

+  UefiPayloadPkg/PlatformGopPolicy/PlatformGopPolicy.inf

+!else

   UefiPayloadPkg/GraphicsOutputDxe/GraphicsOutputDxe.inf

+!endif

 !if $(PERFORMANCE_MEASUREMENT_ENABLE)

   MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableDxe/FirmwarePerformanceDxe.inf

 !endif

diff --git a/UefiPayloadPkg/UefiPayloadPkg.fdf b/UefiPayloadPkg/UefiPayloadPkg.fdf
index c7b04978ad..ca3196256e 100644
--- a/UefiPayloadPkg/UefiPayloadPkg.fdf
+++ b/UefiPayloadPkg/UefiPayloadPkg.fdf
@@ -187,7 +187,21 @@ INF MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsoleDxe.inf
 !if $(DISABLE_SERIAL_TERMINAL) == FALSE

 INF MdeModulePkg/Universal/Console/TerminalDxe/TerminalDxe.inf

 !endif

+!if $(USE_PLATFORM_GOP) == TRUE

+INF UefiPayloadPkg/PlatformGopPolicy/PlatformGopPolicy.inf

+FILE DRIVER = FF0C8745-3270-4439-B74F-3E45F8C77064 {

+  SECTION DXE_DEPEX_EXP = {gPlatformGOPPolicyGuid}

+  SECTION PE32 = UefiPayloadPkg/IntelGopDriver.efi

+  SECTION UI = "IntelGopDriver"

+}

+

+FILE FREEFORM = 878AC2CC-5343-46F2-B563-51F89DAF56BA {

+  SECTION RAW = UefiPayloadPkg/vbt.bin

+  SECTION UI = "IntelGopVbt"

+}

+!else

 INF UefiPayloadPkg/GraphicsOutputDxe/GraphicsOutputDxe.inf

+!endif

 

 #

 # SCSI/ATA/IDE/DISK Support

-- 
2.32.0



-=-=-=-=-=-=
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#86594): https://edk2.groups.io/g/devel/message/86594
Mute This Topic: https://groups.io/mt/89057277/1781375
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [guo.dong@intel.com]
-=-=-=-=-=-=




-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#86663): https://edk2.groups.io/g/devel/message/86663
Mute This Topic: https://groups.io/mt/89057277/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-


Re: [edk2-devel] [PATCH] UefiPayloadPkg: Add PlatformGopPolicy
Posted by Ni, Ray 2 years, 2 months ago
gPlatformGOPPolicyGuid is installed by this driver. Then who is producing GOP?

Thanks,
Ray

-----Original Message-----
From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Sean Rhodes
Sent: Friday, February 11, 2022 6:24 AM
To: devel@edk2.groups.io
Cc: Dong, Guo <guo.dong@intel.com>; Matt DeVillier <matt.devillier@gmail.com>; Ni, Ray <ray.ni@intel.com>; Ma, Maurice <maurice.ma@intel.com>; You, Benjamin <benjamin.you@intel.com>
Subject: [edk2-devel] [PATCH] UefiPayloadPkg: Add PlatformGopPolicy

From: Matt DeVillier <matt.devillier@gmail.com>

Add PlatformGopPolicy to use external GOP driver

Cc: Guo Dong <guo.dong@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Maurice Ma <maurice.ma@intel.com>
Cc: Benjamin You <benjamin.you@intel.com>
Signed-off-by: Matt DeVillier <matt.devillier@gmail.com>
---
 .../PlatformGopPolicy/PlatformGopPolicy.c     | 161 ++++++++++++++++++
 .../PlatformGopPolicy/PlatformGopPolicy.h     |  62 +++++++
 .../PlatformGopPolicy/PlatformGopPolicy.inf   |  47 +++++
 UefiPayloadPkg/UefiPayloadPkg.dsc             |   5 +
 UefiPayloadPkg/UefiPayloadPkg.fdf             |  14 ++
 5 files changed, 289 insertions(+)
 create mode 100644 UefiPayloadPkg/PlatformGopPolicy/PlatformGopPolicy.c
 create mode 100644 UefiPayloadPkg/PlatformGopPolicy/PlatformGopPolicy.h
 create mode 100644 UefiPayloadPkg/PlatformGopPolicy/PlatformGopPolicy.inf

diff --git a/UefiPayloadPkg/PlatformGopPolicy/PlatformGopPolicy.c b/UefiPayloadPkg/PlatformGopPolicy/PlatformGopPolicy.c
new file mode 100644
index 0000000000..31c61d967e
--- /dev/null
+++ b/UefiPayloadPkg/PlatformGopPolicy/PlatformGopPolicy.c
@@ -0,0 +1,161 @@
+/** @file

+

+  Copyright (c) 2021, Intel Corporation. All rights reserved.<BR>

+

+  SPDX-License-Identifier: BSD-2-Clause-Patent

+

+**/

+

+#include <Library/BaseMemoryLib.h>

+#include <Library/DebugLib.h>

+#include <Protocol/FirmwareVolume2.h>

+#include "PlatformGopPolicy.h"

+

+#include <Library/UefiBootServicesTableLib.h>

+#include <Library/UefiRuntimeServicesTableLib.h>

+

+PLATFORM_GOP_POLICY_PROTOCOL  mPlatformGOPPolicy;

+

+/**

+  The function will execute with as the platform policy, and gives

+  the Platform Lid Status. IBV/OEM can customize this code for their specific

+  policy action.

+

+  @param  CurrentLidStatus  Gives the current LID Status

+

+  @retval EFI_SUCCESS.

+**/

+EFI_STATUS

+EFIAPI

+GetPlatformLidStatus (

+  OUT LID_STATUS  *CurrentLidStatus

+  )

+{

+  *CurrentLidStatus = LidOpen;

+

+  return EFI_SUCCESS;

+}

+

+/**

+  The function will execute and gives the Video Bios Table Size and Address.

+

+  @param  VbtAddress  Gives the Physical Address of Video BIOS Table

+

+  @param  VbtSize     Gives the Size of Video BIOS Table

+

+  @retval EFI_STATUS.

+**/

+EFI_STATUS

+EFIAPI

+GetVbtData (

+  OUT EFI_PHYSICAL_ADDRESS  *VbtAddress,

+  OUT UINT32                *VbtSize

+  )

+{

+  EFI_STATUS                     Status;

+  UINTN                          FvProtocolCount;

+  EFI_HANDLE                     *FvHandles;

+  EFI_FIRMWARE_VOLUME2_PROTOCOL  *Fv;

+  UINTN                          Index;

+  UINT32                         AuthenticationStatus;

+

+  UINT8  *Buffer;

+  UINTN  VbtBufferSize;

+

+  Buffer    = 0;

+  FvHandles = NULL;

+

+  if ((VbtAddress == NULL) || (VbtSize == NULL)) {

+    return EFI_INVALID_PARAMETER;

+  }

+

+  Status = gBS->LocateHandleBuffer (

+                  ByProtocol,

+                  &gEfiFirmwareVolume2ProtocolGuid,

+                  NULL,

+                  &FvProtocolCount,

+                  &FvHandles

+                  );

+

+  if (!EFI_ERROR (Status)) {

+    for (Index = 0; Index < FvProtocolCount; Index++) {

+      Status = gBS->HandleProtocol (

+                      FvHandles[Index],

+                      &gEfiFirmwareVolume2ProtocolGuid,

+                      (VOID **)&Fv

+                      );

+      VbtBufferSize = 0;

+      Status        = Fv->ReadSection (

+                            Fv,

+                            &gBmpImageGuid,

+                            EFI_SECTION_RAW,

+                            0,

+                            (void **)&Buffer,

+                            &VbtBufferSize,

+                            &AuthenticationStatus

+                            );

+

+      if (!EFI_ERROR (Status)) {

+        *VbtAddress = (EFI_PHYSICAL_ADDRESS)(UINTN)Buffer;

+        *VbtSize    = (UINT32)VbtBufferSize;

+        Status      = EFI_SUCCESS;

+        break;

+      }

+    }

+  } else {

+    Status = EFI_NOT_FOUND;

+  }

+

+  if (FvHandles != NULL) {

+    gBS->FreePool (FvHandles);

+    FvHandles = NULL;

+  }

+

+  return Status;

+}

+

+/**

+  Entry point for the Platform GOP Policy Driver.

+

+  @param ImageHandle       Image handle of this driver.

+  @param SystemTable       Global system service table.

+

+  @retval EFI_SUCCESS           Initialization complete.

+  @retval EFI_OUT_OF_RESOURCES  Do not have enough resources to initialize the driver.

+**/

+EFI_STATUS

+EFIAPI

+PlatformGOPPolicyEntryPoint (

+  IN EFI_HANDLE        ImageHandle,

+  IN EFI_SYSTEM_TABLE  *SystemTable

+  )

+

+{

+  EFI_STATUS  Status;

+

+  Status = EFI_SUCCESS;

+

+  gBS = SystemTable->BootServices;

+

+  gBS->SetMem (

+         &mPlatformGOPPolicy,

+         sizeof (PLATFORM_GOP_POLICY_PROTOCOL),

+         0

+         );

+

+  mPlatformGOPPolicy.Revision             = PLATFORM_GOP_POLICY_PROTOCOL_REVISION_01;

+  mPlatformGOPPolicy.GetPlatformLidStatus = GetPlatformLidStatus;

+  mPlatformGOPPolicy.GetVbtData           = GetVbtData;

+

+  //

+  // Install protocol to allow access to this Policy.

+  //

+  Status = gBS->InstallMultipleProtocolInterfaces (

+                  &ImageHandle,

+                  &gPlatformGOPPolicyGuid,

+                  &mPlatformGOPPolicy,

+                  NULL

+                  );

+

+  return Status;

+}

diff --git a/UefiPayloadPkg/PlatformGopPolicy/PlatformGopPolicy.h b/UefiPayloadPkg/PlatformGopPolicy/PlatformGopPolicy.h
new file mode 100644
index 0000000000..a8ac0be1b8
--- /dev/null
+++ b/UefiPayloadPkg/PlatformGopPolicy/PlatformGopPolicy.h
@@ -0,0 +1,62 @@
+/** @file

+  The header file for Platform GPO.

+

+Copyright (c) 2021, Intel Corporation. All rights reserved.<BR>

+SPDX-License-Identifier: BSD-2-Clause-Patent

+

+**/

+

+#ifndef PLATFORM_GOP_POLICY_PROTOCOL_H_

+#define PLATFORM_GOP_POLICY_PROTOCOL_H_

+

+#define EFI_PLATFORM_GOP_POLICY_PROTOCOL_GUID \

+  { 0xec2e931b, 0x3281, 0x48a5, 0x81, 0x7, 0xdf, 0x8a, 0x8b, 0xed, 0x3c, 0x5d }

+

+#define EFI_BMP_IMAGE_GUID \

+  { 0x878AC2CC, 0x5343, 0x46F2, 0xB5, 0x63, 0x51, 0xF8, 0x9D, 0xAF, 0x56, 0xBA }

+

+#define PLATFORM_GOP_POLICY_PROTOCOL_REVISION_01 0x01

+#define PLATFORM_GOP_POLICY_PROTOCOL_REVISION_02 x0222

+

+#pragma pack(1)

+

+typedef enum {

+  LidClosed,

+  LidOpen,

+  LidStatusMax

+} LID_STATUS;

+

+typedef enum {

+  Docked,

+  UnDocked,

+  DockStatusMax

+} DOCK_STATUS;

+

+typedef EFI_STATUS \

+(EFIAPI *GET_PLATFORM_LID_STATUS) (

+  OUT LID_STATUS  *CurrentLidStatus

+  );

+

+typedef EFI_STATUS \

+(EFIAPI *GET_VBT_DATA) (

+   OUT EFI_PHYSICAL_ADDRESS  *VbtAddress,

+   OUT UINT32                *VbtSize

+   );

+

+#pragma pack()

+

+typedef struct _PLATFORM_GOP_POLICY_PROTOCOL {

+  UINT32                   Revision;

+  GET_PLATFORM_LID_STATUS  GetPlatformLidStatus;

+  GET_VBT_DATA             GetVbtData;

+} PLATFORM_GOP_POLICY_PROTOCOL;

+

+//

+// Extern the GUID for protocol users.

+//

+extern EFI_GUID  gPlatformGOPPolicyGuid;

+

+extern EFI_GUID  gBmpImageGuid;

+

+#endif

+

diff --git a/UefiPayloadPkg/PlatformGopPolicy/PlatformGopPolicy.inf b/UefiPayloadPkg/PlatformGopPolicy/PlatformGopPolicy.inf
new file mode 100644
index 0000000000..cdcdc86e2e
--- /dev/null
+++ b/UefiPayloadPkg/PlatformGopPolicy/PlatformGopPolicy.inf
@@ -0,0 +1,47 @@
+## @file

+#  Module for using VBT for GOP.

+#

+# Copyright (c) 2021, Intel Corporation. All rights reserved.<BR>

+#

+# SPDX-License-Identifier: BSD-2-Clause-Patent

+#

+##

+

+[Defines]

+  INF_VERSION                    = 0x00010005

+  BASE_NAME                      = PlatformGOPPolicy

+  FILE_GUID                      = 9737D7CA-D869-45e5-A5EF-75D9438688DE

+  MODULE_TYPE                    = DXE_DRIVER

+  VERSION_STRING                 = 1.0

+  ENTRY_POINT                    = PlatformGOPPolicyEntryPoint

+

+#

+# The following information is for reference only and not required by the build tools.

+#

+#  VALID_ARCHITECTURES           = X64

+#

+

+[Sources.common]

+  PlatformGopPolicy.h

+  PlatformGopPolicy.c

+

+[Packages]

+  MdePkg/MdePkg.dec

+  UefiPayloadPkg/UefiPayloadPkg.dec

+

+[LibraryClasses]

+  BaseLib

+  DebugLib

+  UefiDriverEntryPoint

+  UefiRuntimeServicesTableLib

+

+[Guids]

+  gBmpImageGuid

+

+[Protocols]

+  gEfiFirmwareVolume2ProtocolGuid

+  gPlatformGOPPolicyGuid

+

+[Depex]

+  gEfiVariableArchProtocolGuid

+

diff --git a/UefiPayloadPkg/UefiPayloadPkg.dsc b/UefiPayloadPkg/UefiPayloadPkg.dsc
index 1ce96a51c1..cb050b7269 100644
--- a/UefiPayloadPkg/UefiPayloadPkg.dsc
+++ b/UefiPayloadPkg/UefiPayloadPkg.dsc
@@ -33,6 +33,7 @@
   DEFINE UNIVERSAL_PAYLOAD            = FALSE

   DEFINE SECURITY_STUB_ENABLE         = TRUE

   DEFINE SMM_SUPPORT                  = FALSE

+  DEFINE USE_PLATFORM_GOP             = FALSE

   #

   # SBL:      UEFI payload for Slim Bootloader

   # COREBOOT: UEFI payload for coreboot

@@ -666,7 +667,11 @@
 !if $(DISABLE_SERIAL_TERMINAL) == FALSE

   MdeModulePkg/Universal/Console/TerminalDxe/TerminalDxe.inf

 !endif

+!if $(USE_PLATFORM_GOP) == TRUE

+  UefiPayloadPkg/PlatformGopPolicy/PlatformGopPolicy.inf

+!else

   UefiPayloadPkg/GraphicsOutputDxe/GraphicsOutputDxe.inf

+!endif

 !if $(PERFORMANCE_MEASUREMENT_ENABLE)

   MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableDxe/FirmwarePerformanceDxe.inf

 !endif

diff --git a/UefiPayloadPkg/UefiPayloadPkg.fdf b/UefiPayloadPkg/UefiPayloadPkg.fdf
index c7b04978ad..ca3196256e 100644
--- a/UefiPayloadPkg/UefiPayloadPkg.fdf
+++ b/UefiPayloadPkg/UefiPayloadPkg.fdf
@@ -187,7 +187,21 @@ INF MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsoleDxe.inf
 !if $(DISABLE_SERIAL_TERMINAL) == FALSE

 INF MdeModulePkg/Universal/Console/TerminalDxe/TerminalDxe.inf

 !endif

+!if $(USE_PLATFORM_GOP) == TRUE

+INF UefiPayloadPkg/PlatformGopPolicy/PlatformGopPolicy.inf

+FILE DRIVER = FF0C8745-3270-4439-B74F-3E45F8C77064 {

+  SECTION DXE_DEPEX_EXP = {gPlatformGOPPolicyGuid}

+  SECTION PE32 = UefiPayloadPkg/IntelGopDriver.efi

+  SECTION UI = "IntelGopDriver"

+}

+

+FILE FREEFORM = 878AC2CC-5343-46F2-B563-51F89DAF56BA {

+  SECTION RAW = UefiPayloadPkg/vbt.bin

+  SECTION UI = "IntelGopVbt"

+}

+!else

 INF UefiPayloadPkg/GraphicsOutputDxe/GraphicsOutputDxe.inf

+!endif

 

 #

 # SCSI/ATA/IDE/DISK Support

-- 
2.32.0



-=-=-=-=-=-=
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#86594): https://edk2.groups.io/g/devel/message/86594
Mute This Topic: https://groups.io/mt/89057277/1712937
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [ray.ni@intel.com]
-=-=-=-=-=-=




-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#86696): https://edk2.groups.io/g/devel/message/86696
Mute This Topic: https://groups.io/mt/89057277/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-