From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smarthost01a.sbp.mail.zen.net.uk (smarthost01a.sbp.mail.zen.net.uk [212.23.1.1]) by mx.groups.io with SMTP id smtpd.web09.2757.1644531863004179183 for ; Thu, 10 Feb 2022 14:24:23 -0800 Authentication-Results: mx.groups.io; dkim=missing; spf=permerror, err=parse error for token &{10 18 sdn.klaviyomail.com}: permanent DNS error (domain: starlabs.systems, ip: 212.23.1.1, mailfrom: sean@starlabs.systems) Received: from [217.155.46.38] (helo=sean-StarBook.lan) by smarthost01a.sbp.mail.zen.net.uk with esmtp (Exim 4.90_1) (envelope-from ) id 1nIHrO-0002Ff-59; Thu, 10 Feb 2022 22:24:18 +0000 From: "Sean Rhodes" To: devel@edk2.groups.io Cc: guo.dong@intel.com, Matt DeVillier , Ray Ni , Maurice Ma , Benjamin You Subject: [PATCH] UefiPayloadPkg: Add PlatformGopPolicy Date: Thu, 10 Feb 2022 22:24:12 +0000 Message-Id: <61b8da797bacd4d2fa4708e042765c8d157b1e71.1644531852.git.sean@starlabs.systems> X-Mailer: git-send-email 2.32.0 MIME-Version: 1.0 X-Originating-smarthost01a-IP: [217.155.46.38] Feedback-ID: 217.155.46.38 Content-Transfer-Encoding: quoted-printable From: Matt DeVillier Add PlatformGopPolicy to use external GOP driver Cc: Guo Dong Cc: Ray Ni Cc: Maurice Ma Cc: Benjamin You Signed-off-by: Matt DeVillier --- .../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/UefiPay= loadPkg/PlatformGopPolicy/PlatformGopPolicy.c new file mode 100644 index 0000000000..31c61d967e --- /dev/null +++ b/UefiPayloadPkg/PlatformGopPolicy/PlatformGopPolicy.c @@ -0,0 +1,161 @@ +/** @file=0D +=0D + Copyright (c) 2021, Intel Corporation. All rights reserved.
=0D +=0D + SPDX-License-Identifier: BSD-2-Clause-Patent=0D +=0D +**/=0D +=0D +#include =0D +#include =0D +#include =0D +#include "PlatformGopPolicy.h"=0D +=0D +#include =0D +#include =0D +=0D +PLATFORM_GOP_POLICY_PROTOCOL mPlatformGOPPolicy;=0D +=0D +/**=0D + The function will execute with as the platform policy, and gives=0D + the Platform Lid Status. IBV/OEM can customize this code for their speci= fic=0D + policy action.=0D +=0D + @param CurrentLidStatus Gives the current LID Status=0D +=0D + @retval EFI_SUCCESS.=0D +**/=0D +EFI_STATUS=0D +EFIAPI=0D +GetPlatformLidStatus (=0D + OUT LID_STATUS *CurrentLidStatus=0D + )=0D +{=0D + *CurrentLidStatus =3D LidOpen;=0D +=0D + return EFI_SUCCESS;=0D +}=0D +=0D +/**=0D + The function will execute and gives the Video Bios Table Size and Addres= s.=0D +=0D + @param VbtAddress Gives the Physical Address of Video BIOS Table=0D +=0D + @param VbtSize Gives the Size of Video BIOS Table=0D +=0D + @retval EFI_STATUS.=0D +**/=0D +EFI_STATUS=0D +EFIAPI=0D +GetVbtData (=0D + OUT EFI_PHYSICAL_ADDRESS *VbtAddress,=0D + OUT UINT32 *VbtSize=0D + )=0D +{=0D + EFI_STATUS Status;=0D + UINTN FvProtocolCount;=0D + EFI_HANDLE *FvHandles;=0D + EFI_FIRMWARE_VOLUME2_PROTOCOL *Fv;=0D + UINTN Index;=0D + UINT32 AuthenticationStatus;=0D +=0D + UINT8 *Buffer;=0D + UINTN VbtBufferSize;=0D +=0D + Buffer =3D 0;=0D + FvHandles =3D NULL;=0D +=0D + if ((VbtAddress =3D=3D NULL) || (VbtSize =3D=3D NULL)) {=0D + return EFI_INVALID_PARAMETER;=0D + }=0D +=0D + Status =3D gBS->LocateHandleBuffer (=0D + ByProtocol,=0D + &gEfiFirmwareVolume2ProtocolGuid,=0D + NULL,=0D + &FvProtocolCount,=0D + &FvHandles=0D + );=0D +=0D + if (!EFI_ERROR (Status)) {=0D + for (Index =3D 0; Index < FvProtocolCount; Index++) {=0D + Status =3D gBS->HandleProtocol (=0D + FvHandles[Index],=0D + &gEfiFirmwareVolume2ProtocolGuid,=0D + (VOID **)&Fv=0D + );=0D + VbtBufferSize =3D 0;=0D + Status =3D Fv->ReadSection (=0D + Fv,=0D + &gBmpImageGuid,=0D + EFI_SECTION_RAW,=0D + 0,=0D + (void **)&Buffer,=0D + &VbtBufferSize,=0D + &AuthenticationStatus=0D + );=0D +=0D + if (!EFI_ERROR (Status)) {=0D + *VbtAddress =3D (EFI_PHYSICAL_ADDRESS)(UINTN)Buffer;=0D + *VbtSize =3D (UINT32)VbtBufferSize;=0D + Status =3D EFI_SUCCESS;=0D + break;=0D + }=0D + }=0D + } else {=0D + Status =3D EFI_NOT_FOUND;=0D + }=0D +=0D + if (FvHandles !=3D NULL) {=0D + gBS->FreePool (FvHandles);=0D + FvHandles =3D NULL;=0D + }=0D +=0D + return Status;=0D +}=0D +=0D +/**=0D + Entry point for the Platform GOP Policy Driver.=0D +=0D + @param ImageHandle Image handle of this driver.=0D + @param SystemTable Global system service table.=0D +=0D + @retval EFI_SUCCESS Initialization complete.=0D + @retval EFI_OUT_OF_RESOURCES Do not have enough resources to initialize= the driver.=0D +**/=0D +EFI_STATUS=0D +EFIAPI=0D +PlatformGOPPolicyEntryPoint (=0D + IN EFI_HANDLE ImageHandle,=0D + IN EFI_SYSTEM_TABLE *SystemTable=0D + )=0D +=0D +{=0D + EFI_STATUS Status;=0D +=0D + Status =3D EFI_SUCCESS;=0D +=0D + gBS =3D SystemTable->BootServices;=0D +=0D + gBS->SetMem (=0D + &mPlatformGOPPolicy,=0D + sizeof (PLATFORM_GOP_POLICY_PROTOCOL),=0D + 0=0D + );=0D +=0D + mPlatformGOPPolicy.Revision =3D PLATFORM_GOP_POLICY_PROTOCOL= _REVISION_01;=0D + mPlatformGOPPolicy.GetPlatformLidStatus =3D GetPlatformLidStatus;=0D + mPlatformGOPPolicy.GetVbtData =3D GetVbtData;=0D +=0D + //=0D + // Install protocol to allow access to this Policy.=0D + //=0D + Status =3D gBS->InstallMultipleProtocolInterfaces (=0D + &ImageHandle,=0D + &gPlatformGOPPolicyGuid,=0D + &mPlatformGOPPolicy,=0D + NULL=0D + );=0D +=0D + return Status;=0D +}=0D diff --git a/UefiPayloadPkg/PlatformGopPolicy/PlatformGopPolicy.h b/UefiPay= loadPkg/PlatformGopPolicy/PlatformGopPolicy.h new file mode 100644 index 0000000000..a8ac0be1b8 --- /dev/null +++ b/UefiPayloadPkg/PlatformGopPolicy/PlatformGopPolicy.h @@ -0,0 +1,62 @@ +/** @file=0D + The header file for Platform GPO.=0D +=0D +Copyright (c) 2021, Intel Corporation. All rights reserved.
=0D +SPDX-License-Identifier: BSD-2-Clause-Patent=0D +=0D +**/=0D +=0D +#ifndef PLATFORM_GOP_POLICY_PROTOCOL_H_=0D +#define PLATFORM_GOP_POLICY_PROTOCOL_H_=0D +=0D +#define EFI_PLATFORM_GOP_POLICY_PROTOCOL_GUID \=0D + { 0xec2e931b, 0x3281, 0x48a5, 0x81, 0x7, 0xdf, 0x8a, 0x8b, 0xed, 0x3c, 0= x5d }=0D +=0D +#define EFI_BMP_IMAGE_GUID \=0D + { 0x878AC2CC, 0x5343, 0x46F2, 0xB5, 0x63, 0x51, 0xF8, 0x9D, 0xAF, 0x56, = 0xBA }=0D +=0D +#define PLATFORM_GOP_POLICY_PROTOCOL_REVISION_01 0x01=0D +#define PLATFORM_GOP_POLICY_PROTOCOL_REVISION_02 x0222=0D +=0D +#pragma pack(1)=0D +=0D +typedef enum {=0D + LidClosed,=0D + LidOpen,=0D + LidStatusMax=0D +} LID_STATUS;=0D +=0D +typedef enum {=0D + Docked,=0D + UnDocked,=0D + DockStatusMax=0D +} DOCK_STATUS;=0D +=0D +typedef EFI_STATUS \=0D +(EFIAPI *GET_PLATFORM_LID_STATUS) (=0D + OUT LID_STATUS *CurrentLidStatus=0D + );=0D +=0D +typedef EFI_STATUS \=0D +(EFIAPI *GET_VBT_DATA) (=0D + OUT EFI_PHYSICAL_ADDRESS *VbtAddress,=0D + OUT UINT32 *VbtSize=0D + );=0D +=0D +#pragma pack()=0D +=0D +typedef struct _PLATFORM_GOP_POLICY_PROTOCOL {=0D + UINT32 Revision;=0D + GET_PLATFORM_LID_STATUS GetPlatformLidStatus;=0D + GET_VBT_DATA GetVbtData;=0D +} PLATFORM_GOP_POLICY_PROTOCOL;=0D +=0D +//=0D +// Extern the GUID for protocol users.=0D +//=0D +extern EFI_GUID gPlatformGOPPolicyGuid;=0D +=0D +extern EFI_GUID gBmpImageGuid;=0D +=0D +#endif=0D +=0D diff --git a/UefiPayloadPkg/PlatformGopPolicy/PlatformGopPolicy.inf b/UefiP= ayloadPkg/PlatformGopPolicy/PlatformGopPolicy.inf new file mode 100644 index 0000000000..cdcdc86e2e --- /dev/null +++ b/UefiPayloadPkg/PlatformGopPolicy/PlatformGopPolicy.inf @@ -0,0 +1,47 @@ +## @file=0D +# Module for using VBT for GOP.=0D +#=0D +# Copyright (c) 2021, Intel Corporation. All rights reserved.
=0D +#=0D +# SPDX-License-Identifier: BSD-2-Clause-Patent=0D +#=0D +##=0D +=0D +[Defines]=0D + INF_VERSION =3D 0x00010005=0D + BASE_NAME =3D PlatformGOPPolicy=0D + FILE_GUID =3D 9737D7CA-D869-45e5-A5EF-75D9438688DE= =0D + MODULE_TYPE =3D DXE_DRIVER=0D + VERSION_STRING =3D 1.0=0D + ENTRY_POINT =3D PlatformGOPPolicyEntryPoint=0D +=0D +#=0D +# The following information is for reference only and not required by the = build tools.=0D +#=0D +# VALID_ARCHITECTURES =3D X64=0D +#=0D +=0D +[Sources.common]=0D + PlatformGopPolicy.h=0D + PlatformGopPolicy.c=0D +=0D +[Packages]=0D + MdePkg/MdePkg.dec=0D + UefiPayloadPkg/UefiPayloadPkg.dec=0D +=0D +[LibraryClasses]=0D + BaseLib=0D + DebugLib=0D + UefiDriverEntryPoint=0D + UefiRuntimeServicesTableLib=0D +=0D +[Guids]=0D + gBmpImageGuid=0D +=0D +[Protocols]=0D + gEfiFirmwareVolume2ProtocolGuid=0D + gPlatformGOPPolicyGuid=0D +=0D +[Depex]=0D + gEfiVariableArchProtocolGuid=0D +=0D diff --git a/UefiPayloadPkg/UefiPayloadPkg.dsc b/UefiPayloadPkg/UefiPayload= Pkg.dsc index 1ce96a51c1..cb050b7269 100644 --- a/UefiPayloadPkg/UefiPayloadPkg.dsc +++ b/UefiPayloadPkg/UefiPayloadPkg.dsc @@ -33,6 +33,7 @@ DEFINE UNIVERSAL_PAYLOAD =3D FALSE=0D DEFINE SECURITY_STUB_ENABLE =3D TRUE=0D DEFINE SMM_SUPPORT =3D FALSE=0D + DEFINE USE_PLATFORM_GOP =3D FALSE=0D #=0D # SBL: UEFI payload for Slim Bootloader=0D # COREBOOT: UEFI payload for coreboot=0D @@ -666,7 +667,11 @@ !if $(DISABLE_SERIAL_TERMINAL) =3D=3D FALSE=0D MdeModulePkg/Universal/Console/TerminalDxe/TerminalDxe.inf=0D !endif=0D +!if $(USE_PLATFORM_GOP) =3D=3D TRUE=0D + UefiPayloadPkg/PlatformGopPolicy/PlatformGopPolicy.inf=0D +!else=0D UefiPayloadPkg/GraphicsOutputDxe/GraphicsOutputDxe.inf=0D +!endif=0D !if $(PERFORMANCE_MEASUREMENT_ENABLE)=0D MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableDxe/FirmwarePerf= ormanceDxe.inf=0D !endif=0D diff --git a/UefiPayloadPkg/UefiPayloadPkg.fdf b/UefiPayloadPkg/UefiPayload= Pkg.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) =3D=3D FALSE=0D INF MdeModulePkg/Universal/Console/TerminalDxe/TerminalDxe.inf=0D !endif=0D +!if $(USE_PLATFORM_GOP) =3D=3D TRUE=0D +INF UefiPayloadPkg/PlatformGopPolicy/PlatformGopPolicy.inf=0D +FILE DRIVER =3D FF0C8745-3270-4439-B74F-3E45F8C77064 {=0D + SECTION DXE_DEPEX_EXP =3D {gPlatformGOPPolicyGuid}=0D + SECTION PE32 =3D UefiPayloadPkg/IntelGopDriver.efi=0D + SECTION UI =3D "IntelGopDriver"=0D +}=0D +=0D +FILE FREEFORM =3D 878AC2CC-5343-46F2-B563-51F89DAF56BA {=0D + SECTION RAW =3D UefiPayloadPkg/vbt.bin=0D + SECTION UI =3D "IntelGopVbt"=0D +}=0D +!else=0D INF UefiPayloadPkg/GraphicsOutputDxe/GraphicsOutputDxe.inf=0D +!endif=0D =0D #=0D # SCSI/ATA/IDE/DISK Support=0D --=20 2.32.0