From nobody Fri May 17 05:26:20 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+86594+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+86594+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1644531865; cv=none; d=zohomail.com; s=zohoarc; b=bjdayBA3PFsigmzei+cO4SbsjkPVps4AvHph+fOPa90Ep7HSe2Nx2kLboa2KGvHg+/l2zNBvEf7yKbp5bPWeTcPR3z31Ck7YLjh07o+0m2tq3EY1KOcg7N+wcNDOZpHt2hkYjO6fa+lN21XN711qYtCCu6Y7cdhbL9Dkb/uLuEs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1644531865; h=Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Sender:Subject:To; bh=Bbb+qqKq67bB0209QByuOxUK47HF4foq+rB8m7O9edk=; b=Q9SO4fSwPxsEzGM0kRR49AVBaXOPgOSbcb/aH+v6IutA0z9S343mzoNEcfM05vd/HqbMiYL1M92KRHfxTaMz4RF+g4ajDkktPJYt5TOBpaV2KrxRuF2C+2So5S0aBRxpricvlYziFTBt73o+NF0bIe/k6CBOdki2jOYIFpZ0Rjg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+86594+1787277+3901457@groups.io Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1644531865088242.3550899245139; Thu, 10 Feb 2022 14:24:25 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id EAN9YY1788612xoQBB4jLcF5; Thu, 10 Feb 2022 14:24:24 -0800 X-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 X-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: [edk2-devel] [PATCH] UefiPayloadPkg: Add PlatformGopPolicy Date: Thu, 10 Feb 2022 22:24:12 +0000 Message-Id: <61b8da797bacd4d2fa4708e042765c8d157b1e71.1644531852.git.sean@starlabs.systems> MIME-Version: 1.0 X-Originating-smarthost01a-IP: [217.155.46.38] Feedback-ID: 217.155.46.38 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,sean@starlabs.systems X-Gm-Message-State: YZM0X37pgQsJwuS2XDRxWbfFx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1644531864; bh=EQ+7cewlpfzFOpfQFk5CStN/AkQQj2uBKIfgVT8Yg9U=; h=Cc:Date:From:Reply-To:Subject:To; b=i3cPQJKL7+5424qJhgc2AzrYeKcSbkB0gfgQYmlTGKX3kpraOC5txi1fcVRSp4A4VHs l5ueHkKG/4wkdqdRb5eN3NCZkCTmH8kufFb5o/9M7G0OOBUhm1ypoQWY7s3fvnEQCVbyh jdJP5RKXs7JpqhIhzx2KlPor9VSmsNtM810= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1644531866434100002 Content-Type: text/plain; charset="utf-8" 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 + + Copyright (c) 2021, Intel Corporation. All rights reserved.
+ + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include +#include +#include +#include "PlatformGopPolicy.h" + +#include +#include + +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 speci= fic + policy action. + + @param CurrentLidStatus Gives the current LID Status + + @retval EFI_SUCCESS. +**/ +EFI_STATUS +EFIAPI +GetPlatformLidStatus ( + OUT LID_STATUS *CurrentLidStatus + ) +{ + *CurrentLidStatus =3D LidOpen; + + return EFI_SUCCESS; +} + +/** + The function will execute and gives the Video Bios Table Size and Addres= s. + + @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 =3D 0; + FvHandles =3D NULL; + + if ((VbtAddress =3D=3D NULL) || (VbtSize =3D=3D NULL)) { + return EFI_INVALID_PARAMETER; + } + + Status =3D gBS->LocateHandleBuffer ( + ByProtocol, + &gEfiFirmwareVolume2ProtocolGuid, + NULL, + &FvProtocolCount, + &FvHandles + ); + + if (!EFI_ERROR (Status)) { + for (Index =3D 0; Index < FvProtocolCount; Index++) { + Status =3D gBS->HandleProtocol ( + FvHandles[Index], + &gEfiFirmwareVolume2ProtocolGuid, + (VOID **)&Fv + ); + VbtBufferSize =3D 0; + Status =3D Fv->ReadSection ( + Fv, + &gBmpImageGuid, + EFI_SECTION_RAW, + 0, + (void **)&Buffer, + &VbtBufferSize, + &AuthenticationStatus + ); + + if (!EFI_ERROR (Status)) { + *VbtAddress =3D (EFI_PHYSICAL_ADDRESS)(UINTN)Buffer; + *VbtSize =3D (UINT32)VbtBufferSize; + Status =3D EFI_SUCCESS; + break; + } + } + } else { + Status =3D EFI_NOT_FOUND; + } + + if (FvHandles !=3D NULL) { + gBS->FreePool (FvHandles); + FvHandles =3D 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 =3D EFI_SUCCESS; + + gBS =3D SystemTable->BootServices; + + gBS->SetMem ( + &mPlatformGOPPolicy, + sizeof (PLATFORM_GOP_POLICY_PROTOCOL), + 0 + ); + + mPlatformGOPPolicy.Revision =3D PLATFORM_GOP_POLICY_PROTOCOL= _REVISION_01; + mPlatformGOPPolicy.GetPlatformLidStatus =3D GetPlatformLidStatus; + mPlatformGOPPolicy.GetVbtData =3D GetVbtData; + + // + // Install protocol to allow access to this Policy. + // + Status =3D gBS->InstallMultipleProtocolInterfaces ( + &ImageHandle, + &gPlatformGOPPolicyGuid, + &mPlatformGOPPolicy, + NULL + ); + + return Status; +} 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 + The header file for Platform GPO. + +Copyright (c) 2021, Intel Corporation. All rights reserved.
+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, 0= x5d } + +#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/UefiP= ayloadPkg/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.
+# +# SPDX-License-Identifier: BSD-2-Clause-Patent +# +## + +[Defines] + INF_VERSION =3D 0x00010005 + BASE_NAME =3D PlatformGOPPolicy + FILE_GUID =3D 9737D7CA-D869-45e5-A5EF-75D9438688DE + MODULE_TYPE =3D DXE_DRIVER + VERSION_STRING =3D 1.0 + ENTRY_POINT =3D PlatformGOPPolicyEntryPoint + +# +# The following information is for reference only and not required by the = build tools. +# +# VALID_ARCHITECTURES =3D 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/UefiPayload= Pkg.dsc index 1ce96a51c1..cb050b7269 100644 --- a/UefiPayloadPkg/UefiPayloadPkg.dsc +++ b/UefiPayloadPkg/UefiPayloadPkg.dsc @@ -33,6 +33,7 @@ DEFINE UNIVERSAL_PAYLOAD =3D FALSE DEFINE SECURITY_STUB_ENABLE =3D TRUE DEFINE SMM_SUPPORT =3D FALSE + DEFINE USE_PLATFORM_GOP =3D FALSE # # SBL: UEFI payload for Slim Bootloader # COREBOOT: UEFI payload for coreboot @@ -666,7 +667,11 @@ !if $(DISABLE_SERIAL_TERMINAL) =3D=3D FALSE MdeModulePkg/Universal/Console/TerminalDxe/TerminalDxe.inf !endif +!if $(USE_PLATFORM_GOP) =3D=3D TRUE + UefiPayloadPkg/PlatformGopPolicy/PlatformGopPolicy.inf +!else UefiPayloadPkg/GraphicsOutputDxe/GraphicsOutputDxe.inf +!endif !if $(PERFORMANCE_MEASUREMENT_ENABLE) MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableDxe/FirmwarePerf= ormanceDxe.inf !endif 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 INF MdeModulePkg/Universal/Console/TerminalDxe/TerminalDxe.inf !endif +!if $(USE_PLATFORM_GOP) =3D=3D TRUE +INF UefiPayloadPkg/PlatformGopPolicy/PlatformGopPolicy.inf +FILE DRIVER =3D FF0C8745-3270-4439-B74F-3E45F8C77064 { + SECTION DXE_DEPEX_EXP =3D {gPlatformGOPPolicyGuid} + SECTION PE32 =3D UefiPayloadPkg/IntelGopDriver.efi + SECTION UI =3D "IntelGopDriver" +} + +FILE FREEFORM =3D 878AC2CC-5343-46F2-B563-51F89DAF56BA { + SECTION RAW =3D UefiPayloadPkg/vbt.bin + SECTION UI =3D "IntelGopVbt" +} +!else INF UefiPayloadPkg/GraphicsOutputDxe/GraphicsOutputDxe.inf +!endif =20 # # SCSI/ATA/IDE/DISK Support --=20 2.32.0 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- 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] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-