public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Guo Dong" <guo.dong@intel.com>
To: "devel@edk2.groups.io" <devel@edk2.groups.io>,
	"Rhodes, Sean" <sean@starlabs.systems>
Cc: 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: Re: [edk2-devel] [PATCH] UefiPayloadPkg: Add PlatformGopPolicy
Date: Mon, 14 Feb 2022 21:59:54 +0000	[thread overview]
Message-ID: <BYAPR11MB3622D2947F828F83662074A79E339@BYAPR11MB3622.namprd11.prod.outlook.com> (raw)
In-Reply-To: <61b8da797bacd4d2fa4708e042765c8d157b1e71.1644531852.git.sean@starlabs.systems>


+  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]
-=-=-=-=-=-=



  reply	other threads:[~2022-02-14 21:59 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-10 22:24 [PATCH] UefiPayloadPkg: Add PlatformGopPolicy Sean Rhodes
2022-02-14 21:59 ` Guo Dong [this message]
2022-02-16  6:47 ` [edk2-devel] " Ni, Ray
2022-02-27 21:46   ` Sean Rhodes
2022-02-28  8:08     ` Patrick Rudolph

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=BYAPR11MB3622D2947F828F83662074A79E339@BYAPR11MB3622.namprd11.prod.outlook.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox