From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail.byosoft.com.cn (mail.byosoft.com.cn [58.240.74.242]) by mx.groups.io with SMTP id smtpd.web12.6825.1604019894660350177 for ; Thu, 29 Oct 2020 18:04:55 -0700 Authentication-Results: mx.groups.io; dkim=missing; spf=none, err=permanent DNS error (domain: byosoft.com.cn, ip: 58.240.74.242, mailfrom: gaoliming@byosoft.com.cn) Received: from DESKTOPS6D0PVI ([58.246.60.130]) (envelope-sender ) by 192.168.6.13 with ESMTP for ; Fri, 30 Oct 2020 09:04:44 +0800 X-WM-Sender: gaoliming@byosoft.com.cn X-WM-AuthFlag: YES X-WM-AuthUser: gaoliming@byosoft.com.cn From: "gaoliming" To: , References: <661812a7ab20f93e5929507d0bdd761270e789a3.1603706303.git.zhuyanming@byosoft.com.cn> In-Reply-To: <661812a7ab20f93e5929507d0bdd761270e789a3.1603706303.git.zhuyanming@byosoft.com.cn> Subject: =?UTF-8?B?5Zue5aSNOiBbZWRrMi1kZXZlbF0gW1BBVENIXSBNZGVNb2R1bGVQa2fvvJpmaXggbWVtb3J5IHdhc3RpbmcgaXNzdWU=?= Date: Fri, 30 Oct 2020 09:04:51 +0800 Message-ID: <004601d6ae58$abe169c0$03a43d40$@byosoft.com.cn> MIME-Version: 1.0 X-Mailer: Microsoft Outlook 16.0 Thread-Index: AQKJ7tLrSu2hVr/JkMGakXjMMuDG4ahI02Zw Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Content-Language: zh-cn Yanming: This patch doesn't catch variable data in guided hob. Please create GUID= hob to store the variable guid/name/data.=20 Thanks Liming > -----=E9=82=AE=E4=BB=B6=E5=8E=9F=E4=BB=B6----- > =E5=8F=91=E4=BB=B6=E4=BA=BA: bounce+27952+66651+4905953+8761045@groups.i= o > =E4=BB=A3=E8=A1=A8 Yanmin= g Zhu > =E5=8F=91=E9=80=81=E6=97=B6=E9=97=B4: 2020=E5=B9=B410=E6=9C=8826=E6=97= =A5 17:59 > =E6=94=B6=E4=BB=B6=E4=BA=BA: devel@edk2.groups.io > =E4=B8=BB=E9=A2=98: [edk2-devel] [PATCH] MdeModulePkg=EF=BC=9Afix memory= wasting issue >=20 > REF:https://bugzilla.tianocore.org/show_bug.cgi?id=3D2964 >=20 > 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. >=20 > 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(-) >=20 > diff --git a/MdeModulePkg/Universal/PCD/Pei/Service.c > b/MdeModulePkg/Universal/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, > NULL, (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/Universal/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 > generated PCD PEI Database match." > #endif >=20 > +/** > + GuidHob can be used to cache the variable data for the following usag= e. > + This GuidHob is the private GUID hob for PcdPei > + One GuidHob will be for one EFI variable. > + > + This structure contains three > members:VariableGuid,VariableName,VariableBuffer. > +**/ > +typedef struct { > + IN CONST EFI_GUID *VariableGuid; > + IN UINT16 *VariableName; > + VOID *VariableBuffer; > +} TEST_DATA; > + > /** > Retrieve additional information associated with a PCD token in the de= fault > token space. >=20 > -- > 2.28.0.windows.1 >=20 >=20 >=20 >=20 >=20 >=20