From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=192.55.52.43; helo=mga05.intel.com; envelope-from=liming.gao@intel.com; receiver=edk2-devel@lists.01.org Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 17FF920971733 for ; Mon, 28 Jan 2019 19:07:08 -0800 (PST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 28 Jan 2019 19:07:08 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,535,1539673200"; d="scan'208";a="122127576" Received: from fmsmsx105.amr.corp.intel.com ([10.18.124.203]) by orsmga003.jf.intel.com with ESMTP; 28 Jan 2019 19:07:07 -0800 Received: from fmsmsx157.amr.corp.intel.com (10.18.116.73) by FMSMSX105.amr.corp.intel.com (10.18.124.203) with Microsoft SMTP Server (TLS) id 14.3.408.0; Mon, 28 Jan 2019 19:07:07 -0800 Received: from shsmsx106.ccr.corp.intel.com (10.239.4.159) by FMSMSX157.amr.corp.intel.com (10.18.116.73) with Microsoft SMTP Server (TLS) id 14.3.408.0; Mon, 28 Jan 2019 19:07:06 -0800 Received: from shsmsx104.ccr.corp.intel.com ([169.254.5.102]) by SHSMSX106.ccr.corp.intel.com ([169.254.10.174]) with mapi id 14.03.0415.000; Tue, 29 Jan 2019 11:07:04 +0800 From: "Gao, Liming" To: "Xu, JiansongX" , "edk2-devel@lists.01.org" CC: "Xu, JiansongX" Thread-Topic: [edk2] [PATCH] MdePkg/UefiLib: Add a new API GetVariable3 Thread-Index: AQHUpj7OywSAWmSjWk22qqhKfc8nvKXFsiaw Date: Tue, 29 Jan 2019 03:07:04 +0000 Message-ID: <4A89E2EF3DFEDB4C8BFDE51014F606A14E3D1B39@SHSMSX104.ccr.corp.intel.com> References: <20190107040927.964-1-jiansongx.xu@intel.com> In-Reply-To: <20190107040927.964-1-jiansongx.xu@intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ctpclassification: CTP_NT x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiYzJhNjRlMDAtMGZhMC00OGJjLWIyMTgtNjY3MThjNmUyOTIwIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoibzhVNGxTRTM0czVOWFdmVlo2M1hiNzJqem9PQ01MYmVUSVwvb2NmMXA4NW4xb1VsZ3p1ODZNSGpXTWxUcmNSV3MifQ== dlp-product: dlpe-windows dlp-version: 11.0.400.15 dlp-reaction: no-action x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [PATCH] MdePkg/UefiLib: Add a new API GetVariable3 X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 29 Jan 2019 03:07:09 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Jiansong: The patch is good. Reviewed-by: Liming Gao =20 Besides, this patch is from MS Mu, please keep original patch author. Don= 't need to send the patch again.=20 Thanks LIming > -----Original Message----- > From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of Ji= ansong Xu > Sent: Monday, January 7, 2019 12:09 PM > To: edk2-devel@lists.01.org > Cc: Xu, JiansongX > Subject: [edk2] [PATCH] MdePkg/UefiLib: Add a new API GetVariable3 >=20 > From: jiansonx >=20 > BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=3D1396 > Add a new API GetVariable3, which can return the attributes of a variable= during reading it. >=20 > Contributed-under: TianoCore Contribution Agreement 1.1 > Signed-off-by: Jiansong Xu > Cc: Liming Gao --- > MdePkg/Include/Library/UefiLib.h | 33 ++++++++++++++++ > MdePkg/Library/UefiLib/UefiLib.c | 81 ++++++++++++++++++++++++++++++++++= ++++++ > 2 files changed, 114 insertions(+) >=20 > diff --git a/MdePkg/Include/Library/UefiLib.h b/MdePkg/Include/Library/Ue= fiLib.h > index 468bffc3cb..929ee8afb7 100644 > --- a/MdePkg/Include/Library/UefiLib.h > +++ b/MdePkg/Include/Library/UefiLib.h > @@ -777,6 +777,39 @@ GetEfiGlobalVariable2 ( > OUT UINTN *Size OPTIONAL > ); >=20 > +/** Return the attributes of the variable. > + > + Returns the status whether get the variable success. The function retr= ieves > + variable through the UEFI Runtime Service GetVariable(). The > + returned buffer is allocated using AllocatePool(). The caller is resp= onsible > + for freeing this buffer with FreePool(). The attributes are returned = if > + the caller provides a valid Attribute parameter. > + > + If Name is NULL, then ASSERT(). > + If Guid is NULL, then ASSERT(). > + If Value is NULL, then ASSERT(). > + > + @param[in] Name The pointer to a Null-terminated Unicode string. > + @param[in] Guid The pointer to an EFI_GUID structure > + @param[out] Value The buffer point saved the variable info. > + @param[out] Size The buffer size of the variable. > + @param[out] Attr The pointer to the variable attributes as found in v= ar store > + > + @retval EFI_OUT_OF_RESOURCES Allocate buffer failed. > + @retval EFI_SUCCESS Find the specified variable. > + @retval Others Errors Return errors from call to gRT->GetV= ariable. > + > +**/ > +EFI_STATUS > +EFIAPI > +GetVariable3( > + IN CONST CHAR16 *Name, > + IN CONST EFI_GUID *Guid, > + OUT VOID **Value, > + OUT UINTN *Size OPTIONAL, > + OUT UINT32 *Attr OPTIONAL > + ); > + > /** > Returns a pointer to an allocated buffer that contains the best matchi= ng language > from a set of supported languages. > diff --git a/MdePkg/Library/UefiLib/UefiLib.c b/MdePkg/Library/UefiLib/Ue= fiLib.c > index 39d0ce2b21..475017690c 100644 > --- a/MdePkg/Library/UefiLib/UefiLib.c > +++ b/MdePkg/Library/UefiLib/UefiLib.c > @@ -1439,6 +1439,87 @@ GetVariable2 ( > return Status; > } >=20 > +/** Return the attributes of the variable. > + > + Returns the status whether get the variable success. The function retr= ieves > + variable through the UEFI Runtime Service GetVariable(). The > + returned buffer is allocated using AllocatePool(). The caller is resp= onsible > + for freeing this buffer with FreePool(). The attributes are returned = if > + the caller provides a valid Attribute parameter. > + > + If Name is NULL, then ASSERT(). > + If Guid is NULL, then ASSERT(). > + If Value is NULL, then ASSERT(). > + > + @param[in] Name The pointer to a Null-terminated Unicode string. > + @param[in] Guid The pointer to an EFI_GUID structure > + @param[out] Value The buffer point saved the variable info. > + @param[out] Size The buffer size of the variable. > + @param[out] Attr The pointer to the variable attributes as found in v= ar store > + > + @retval EFI_OUT_OF_RESOURCES Allocate buffer failed. > + @retval EFI_SUCCESS Find the specified variable. > + @retval Others Errors Return errors from call to gRT->GetV= ariable. > + > +**/ > +EFI_STATUS > +EFIAPI > +GetVariable3( > + IN CONST CHAR16 *Name, > + IN CONST EFI_GUID *Guid, > + OUT VOID **Value, > + OUT UINTN *Size OPTIONAL, > + OUT UINT32 *Attr OPTIONAL > + ) > +{ > + EFI_STATUS Status; > + UINTN BufferSize; > + > + ASSERT(Name !=3D NULL && Guid !=3D NULL && Value !=3D NULL); > + > + // > + // Try to get the variable size. > + // > + BufferSize =3D 0; > + *Value =3D NULL; > + if (Size !=3D NULL) { > + *Size =3D 0; > + } > + > + if (Attr !=3D NULL) { > + *Attr =3D 0; > + } > + > + Status =3D gRT->GetVariable((CHAR16 *)Name, (EFI_GUID *)Guid, Attr, &B= ufferSize, *Value); > + if (Status !=3D EFI_BUFFER_TOO_SMALL) { > + return Status; > + } > + > + // > + // Allocate buffer to get the variable. > + // > + *Value =3D AllocatePool(BufferSize); > + ASSERT(*Value !=3D NULL); > + if (*Value =3D=3D NULL) { > + return EFI_OUT_OF_RESOURCES; > + } > + > + // > + // Get the variable data. > + // > + Status =3D gRT->GetVariable((CHAR16 *)Name, (EFI_GUID *)Guid, Attr, &B= ufferSize, *Value); > + if (EFI_ERROR(Status)) { > + FreePool(*Value); > + *Value =3D NULL; > + } > + > + if (Size !=3D NULL) { > + *Size =3D BufferSize; > + } > + > + return Status; > +} > + > /** > Returns a pointer to an allocated buffer that contains the contents of= a > variable retrieved through the UEFI Runtime Service GetVariable(). Th= is > -- > 2.16.2.windows.1 >=20 > _______________________________________________ > edk2-devel mailing list > edk2-devel@lists.01.org > https://lists.01.org/mailman/listinfo/edk2-devel