From nobody Fri May 3 01:23:48 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+66651+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+66651+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1603800589; cv=none; d=zohomail.com; s=zohoarc; b=W1r3l9eog0HB1qYSqFJy0cx1uJbU2DWbq746P8UIhFEg9K6+U801fi0r+5l5LnLYn5sEJlUbJqhtd3fP0D2TviAfykX+k45M5PSiveYbcdw5Evavs1BVm9j4SfmldDivBHCKtHiZZ839sA4+MSAKGRaf1SMvWYkJafVvFwdH1N8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1603800589; h=Content-Type:Content-Transfer-Encoding:Date:From:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Sender:Subject:To; bh=Ws7dX6kge0FGkW7r78gs5XmGFP0F3QqwQXjaJ3tHm5k=; b=OWdKBtIkXeFuJMiToECbT4xQ6npKtTxvucx0/ub9x010io1m4ATAHPWUuEuMetjvZE4TKM7eJlAB1RvyM5xNGZdAO9NoW3X0DgVEDCHcb6SKQRCSif0xcr04BO5DtXPW+Q+mkPyeD6RulHRFM9sHtMb9TR+co14S3rJ1RbQkVBE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+66651+1787277+3901457@groups.io Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1603800589103711.7794220591752; Tue, 27 Oct 2020 05:09:49 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id VuhhYY1788612x4FXtvkdnZ1; Tue, 27 Oct 2020 05:09:48 -0700 X-Received: from mail.byosoft.com.cn (mail.byosoft.com.cn [58.240.74.242]) by mx.groups.io with SMTP id smtpd.web08.10552.1603706353138381662 for ; Mon, 26 Oct 2020 02:59:14 -0700 X-Received: from localhost.localdomain ([58.246.60.130]) (envelope-sender ) by 192.168.6.13 with ESMTP for ; Mon, 26 Oct 2020 17:59:05 +0800 X-WM-Sender: zhuyanming@byosoft.com.cn From: "Yanming Zhu" To: devel@edk2.groups.io Subject: =?UTF-8?B?W2VkazItZGV2ZWxdIFtQQVRDSF0gTWRlTW9kdWxlUGtn77yaZml4IG1lbW9yeSB3YXN0aW5nIGlzc3Vl?= Date: Mon, 26 Oct 2020 17:59:01 +0800 Message-Id: <661812a7ab20f93e5929507d0bdd761270e789a3.1603706303.git.zhuyanming@byosoft.com.cn> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: 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,zhuyanming@byosoft.com.cn X-Gm-Message-State: C4GmMBVUSoCxltHvzukbtlWrx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1603800588; bh=yg8Szk8Em8RPEeHSBi7CE2hPeMqdGSM3ROT4KKQHRd4=; h=Content-Type:Date:From:Reply-To:Subject:To; b=C3Xh1ApkFUUhh5P4lScu2ZX/CQHEW5LsgSdi5kNT9Cg2y3QanlmRDu6ctALBKynpUaN Z8iG9kGMmHTc3HsFaEXQQHSWG2ndBm3aSk4BmSy2gJ7e9g37nGJd0iLtHJFBzO7fbbFq6 bqCOTTjr5IHadLO0s7IhTl+WEcLKmROmsTM= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" REF:https://bugzilla.tianocore.org/show_bug.cgi?id=3D2964 Use GuidHob instead of AllocatePool. In PEI phase, variable is read only. So, GuidHob can be used to cache the variable data for the following usage. This GuidHob is the private GUID hob for PcdPei. So I add one internal guid for this guidhob. GuidHob data include VariableGuid, VariableName and VariableBuffer. One GuidHob is for one EFI variable. Signed-off-by: Yanming Zhu --- MdeModulePkg/Universal/PCD/Pei/Service.c | 34 ++++++++++++++++-------- MdeModulePkg/Universal/PCD/Pei/Service.h | 14 +++++++++- 2 files changed, 36 insertions(+), 12 deletions(-) diff --git a/MdeModulePkg/Universal/PCD/Pei/Service.c b/MdeModulePkg/Univer= sal/PCD/Pei/Service.c index 5b037353ad..38ed4546d6 100644 --- a/MdeModulePkg/Universal/PCD/Pei/Service.c +++ b/MdeModulePkg/Universal/PCD/Pei/Service.c @@ -472,9 +472,12 @@ GetHiiVariable ( OUT UINTN *VariableSize ) { - UINTN Size; - EFI_STATUS Status; - VOID *Buffer; + UINTN Size; + EFI_STATUS Status; + TEST_DATA TestData; + EFI_HOB_GUID_TYPE *GuidHob; + TEST_DATA *DataPtr; + UINT32 DataSize; EFI_PEI_READ_ONLY_VARIABLE2_PPI *VariablePpi; =20 Status =3D PeiServicesLocatePpi (&gEfiPeiReadOnlyVariable2PpiGuid, 0, NU= LL, (VOID **) &VariablePpi); @@ -489,23 +492,32 @@ GetHiiVariable ( &Size, NULL ); - if (Status =3D=3D EFI_BUFFER_TOO_SMALL) { - Status =3D PeiServicesAllocatePool (Size, &Buffer); - ASSERT_EFI_ERROR (Status); - + //Status =3D PeiServicesAllocatePool (Size, &Buffer); + //create guid hob + BuildGuidDataHob ( + (EFI_GUID *)VariableGuid, + &TestData, + sizeof (TestData) + ); + // find guid hob + GuidHob =3D GetFirstGuidHob ((EFI_GUID *)VariableGuid); + if (GuidHob !=3D NULL) { + DataPtr =3D GET_GUID_HOB_DATA (GuidHob); + DataSize =3D GET_GUID_HOB_DATA_SIZE (GuidHob); + } Status =3D VariablePpi->GetVariable ( VariablePpi, (UINT16 *) VariableName, (EFI_GUID *) VariableGuid, NULL, - &Size, - Buffer + &DataSize, + DataPtr ); ASSERT_EFI_ERROR (Status); =20 - *VariableSize =3D Size; - *VariableData =3D Buffer; + *VariableSize =3D DataSize; + *VariableData =3D DataPtr; =20 return EFI_SUCCESS; } diff --git a/MdeModulePkg/Universal/PCD/Pei/Service.h b/MdeModulePkg/Univer= sal/PCD/Pei/Service.h index 547094fe8a..2fa57a768e 100644 --- a/MdeModulePkg/Universal/PCD/Pei/Service.h +++ b/MdeModulePkg/Universal/PCD/Pei/Service.h @@ -26,7 +26,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #include #include #include - // // Please make sure the PCD Serivce PEIM Version is consistent with // the version of the generated PEIM PCD Database by build tool. @@ -40,6 +39,19 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #error "Please make sure the version of PCD PEIM Service and the generat= ed PCD PEI Database match." #endif =20 +/** + GuidHob can be used to cache the variable data for the following usage. + This GuidHob is the private GUID hob for PcdPei + One GuidHob will be for one EFI variable. + + This structure contains three members:VariableGuid,VariableName,Variable= Buffer. +**/ +typedef struct { + IN CONST EFI_GUID *VariableGuid; + IN UINT16 *VariableName; + VOID *VariableBuffer; +} TEST_DATA; + /** Retrieve additional information associated with a PCD token in the defau= lt token space. =20 --=20 2.28.0.windows.1 -=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 (#66651): https://edk2.groups.io/g/devel/message/66651 Mute This Topic: https://groups.io/mt/77836833/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-