From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mx.groups.io with SMTP id smtpd.web09.37219.1650925314577697172 for ; Mon, 25 Apr 2022 15:21:54 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="body hash did not verify" header.i=@linux.microsoft.com header.s=default header.b=RaHDHp5/; spf=pass (domain: linux.microsoft.com, ip: 13.77.154.182, mailfrom: mikuback@linux.microsoft.com) Received: from [192.168.4.22] (unknown [47.195.228.134]) by linux.microsoft.com (Postfix) with ESMTPSA id 2728C20E2C1A; Mon, 25 Apr 2022 15:21:53 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 2728C20E2C1A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1650925314; bh=516aHljF69S1dWd0cLikhCMsXNDUwP0hipq8sXTcqZI=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=RaHDHp5/hiLgx2uZsE3l0NngG43fyRMIeOHSbX7aeYequd4VnRbQeyVc7YirddwGP ddo8agePg2m6uAZovY6yKA5q8AO/hLKUPgCkODUjw9Z+hZ7XJP7tIpltwmgQ9Gdv3O 1v8nd+MMxTD3gDoS0kzGW/NL9jmIywoUANKCIdrM= Message-ID: <7a458180-d131-fb33-12f9-03362df72a14@linux.microsoft.com> Date: Mon, 25 Apr 2022 18:21:52 -0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.8.0 Subject: Re: [edk2-devel] [PATCH v4 2/8] MdeModulePkg/VariableFlashInfoLib: Add initial library To: devel@edk2.groups.io, sami.mujawar@arm.com Cc: Jian J Wang , Hao A Wu , Liming Gao , nd@arm.com References: <20220412162940.4978-1-mikuback@linux.microsoft.com> <20220412162940.4978-3-mikuback@linux.microsoft.com> <45a37a8e-0fd7-45a4-5eec-dbbc0d42ba33@arm.com> From: "Michael Kubacki" In-Reply-To: <45a37a8e-0fd7-45a4-5eec-dbbc0d42ba33@arm.com> Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: quoted-printable Thanks for your review. I will make that change. Regards, Michael On 4/25/2022 12:05 PM, Sami Mujawar wrote: > Hi Michael, >=20 > I have a minor suggestion marked inline as [SAMI]. >=20 > Otherwise this patch looks good to me. >=20 > Reviewed-by: Sami Mujawar >=20 > Regards, >=20 > Sami Mujawar >=20 > On 12/04/2022 05:29 pm, Michael Kubacki via groups.io wrote: >> From: Michael Kubacki >> >> REF:https://bugzilla.tianocore.org/show_bug.cgi?id=3D3479 >> >> Adds a new library class VariableFlashInfoLib that abstracts access >> to variable flash information. The instance provided first attempts >> to retrieve information from the Variable Flash Info HOB. If that >> HOB is not present, it falls back to the PCDs defined in >> MdeModulePkg. >> >> This fall back behavior provides backward compatibility for platforms >> that only provide PCDs but also allows platforms that need to >> dynamically provide the information using the Variable Flash Info HOB >> to do so at runtime. >> >> Cc: Jian J Wang >> Cc: Hao A Wu >> Cc: Liming Gao >> Signed-off-by: Michael Kubacki >> --- >> =20 >> MdeModulePkg/Library/BaseVariableFlashInfoLib/BaseVariableFlashInfoLib.c= =20 >> | 178 ++++++++++++++++++++ >> =20 >> MdeModulePkg/Include/Library/VariableFlashInfoLib.h = =20 >> |=C2=A0 68 ++++++++ >> =20 >> MdeModulePkg/Library/BaseVariableFlashInfoLib/BaseVariableFlashInfoLib.i= nf=20 >> |=C2=A0 48 ++++++ >> =20 >> MdeModulePkg/Library/BaseVariableFlashInfoLib/BaseVariableFlashInfoLib.u= ni=20 >> |=C2=A0 12 ++ >> =20 >> MdeModulePkg/MdeModulePkg.dec = =20 >> |=C2=A0=C2=A0 4 + >> =20 >> MdeModulePkg/MdeModulePkg.dsc = =20 >> |=C2=A0=C2=A0 2 + >> =C2=A0 6 files changed, 312 insertions(+) >> >> diff --git=20 >> a/MdeModulePkg/Library/BaseVariableFlashInfoLib/BaseVariableFlashInfoLib= .c=20 >> b/MdeModulePkg/Library/BaseVariableFlashInfoLib/BaseVariableFlashInfoLib= .c=20 >> >> new file mode 100644 >> index 000000000000..a1db97bdf218 >> --- /dev/null >> +++=20 >> b/MdeModulePkg/Library/BaseVariableFlashInfoLib/BaseVariableFlashInfoLib= .c=20 >> >> @@ -0,0 +1,178 @@ >> +/** @file >> +=C2=A0 Variable Flash Information Library >> + >> +=C2=A0 Copyright (c) Microsoft Corporation
>> + >> +=C2=A0 SPDX-License-Identifier: BSD-2-Clause-Patent >> + >> +**/ >> + >> +#include >> +#include >> +#include >> +#include >> +#include >> +#include >> + >> +/** >> +=C2=A0 Get the HOB that contains variable flash information. >> + >> +=C2=A0 @param[out] VariableFlashInfo=C2=A0=C2=A0 Pointer to a pointer t= o set to the=20 >> variable flash information structure. >> + >> +=C2=A0 @retval EFI_SUCCESS=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0 Variable flash information was=20 >> found successfully. >> +=C2=A0 @retval EFI_INVALID_PARAMETER=C2=A0=C2=A0 The VariableFlashInfo = pointer given=20 >> is NULL. >> +=C2=A0 @retval EFI_NOT_FOUND=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0 Variable flash information could=20 >> not be found. >> + >> +**/ >> +EFI_STATUS >> +GetVariableFlashInfoFromHob ( >> +=C2=A0 OUT VARIABLE_FLASH_INFO=C2=A0 **VariableFlashInfo >> +=C2=A0 ) > [SAMI] Can this function be made STATIC, please? >> +{ >> +=C2=A0 EFI_HOB_GUID_TYPE=C2=A0 *GuidHob; >> + >> +=C2=A0 if (VariableFlashInfo =3D=3D NULL) { >> +=C2=A0=C2=A0=C2=A0 return EFI_INVALID_PARAMETER; >> +=C2=A0 } >> + >> +=C2=A0 GuidHob =3D GetFirstGuidHob (&gVariableFlashInfoHobGuid); >> +=C2=A0 if (GuidHob =3D=3D NULL) { >> +=C2=A0=C2=A0=C2=A0 return EFI_NOT_FOUND; >> +=C2=A0 } >> + >> +=C2=A0 *VariableFlashInfo =3D GET_GUID_HOB_DATA (GuidHob); >> + >> +=C2=A0 // >> +=C2=A0 // Assert if more than one variable flash information HOB is pre= sent. >> +=C2=A0 // >> +=C2=A0 DEBUG_CODE ( >> +=C2=A0=C2=A0=C2=A0 if ((GetNextGuidHob (&gVariableFlashInfoHobGuid, GET= _NEXT_HOB=20 >> (GuidHob)) !=3D NULL)) { >> +=C2=A0=C2=A0=C2=A0 DEBUG ((DEBUG_ERROR, "ERROR: Found two variable flas= h information=20 >> HOBs\n")); >> +=C2=A0=C2=A0=C2=A0 ASSERT (FALSE); >> +=C2=A0 } >> + >> +=C2=A0=C2=A0=C2=A0 ); >> + >> +=C2=A0 return EFI_SUCCESS; >> +} >> + >> +/** >> +=C2=A0 Get the base address and size for the NV storage area used for U= EFI=20 >> variable storage. >> + >> +=C2=A0 @param[out] BaseAddress=C2=A0=C2=A0=C2=A0 The NV storage base ad= dress. >> +=C2=A0 @param[out] Length=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0 The NV storage length in bytes. >> + >> +=C2=A0 @retval EFI_SUCCESS=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0 NV storage information was found=20 >> successfully. >> +=C2=A0 @retval EFI_INVALID_PARAMETER=C2=A0=C2=A0 A required pointer par= ameter is NULL. >> + >> +**/ >> +EFI_STATUS >> +EFIAPI >> +GetVariableFlashNvStorageInfo ( >> +=C2=A0 OUT EFI_PHYSICAL_ADDRESS=C2=A0 *BaseAddress, >> +=C2=A0 OUT UINT64=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 *Length >> +=C2=A0 ) >> +{ >> +=C2=A0 EFI_STATUS=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0 Status; >> +=C2=A0 VARIABLE_FLASH_INFO=C2=A0 *VariableFlashInfo; >> + >> +=C2=A0 if ((BaseAddress =3D=3D NULL) || (Length =3D=3D NULL)) { >> +=C2=A0=C2=A0=C2=A0 return EFI_INVALID_PARAMETER; >> +=C2=A0 } >> + >> +=C2=A0 Status =3D GetVariableFlashInfoFromHob (&VariableFlashInfo); >> +=C2=A0 if (!EFI_ERROR (Status)) { >> +=C2=A0=C2=A0=C2=A0 *BaseAddress =3D VariableFlashInfo->NvVariableBaseAd= dress; >> +=C2=A0=C2=A0=C2=A0 *Length=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 =3D VariableFl= ashInfo->NvVariableLength; >> +=C2=A0 } else { >> +=C2=A0=C2=A0=C2=A0 *BaseAddress =3D (EFI_PHYSICAL_ADDRESS)(PcdGet64=20 >> (PcdFlashNvStorageVariableBase64) !=3D 0 ? >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0 PcdGet64=20 >> (PcdFlashNvStorageVariableBase64) : >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0 PcdGet32=20 >> (PcdFlashNvStorageVariableBase) >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0 ); >> +=C2=A0=C2=A0=C2=A0 *Length =3D (UINT64)PcdGet32 (PcdFlashNvStorageVaria= bleSize); >> +=C2=A0 } >> + >> +=C2=A0 return EFI_SUCCESS; >> +} >> + >> +/** >> +=C2=A0 Get the base address and size for the fault tolerant write (FTW)= spare >> +=C2=A0 area used for UEFI variable storage. >> + >> +=C2=A0 @param[out] BaseAddress=C2=A0=C2=A0=C2=A0 The FTW spare base add= ress. >> +=C2=A0 @param[out] Length=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0 The FTW spare length in bytes. >> + >> +=C2=A0 @retval EFI_SUCCESS=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0 FTW spare information was found=20 >> successfully. >> +=C2=A0 @retval EFI_INVALID_PARAMETER=C2=A0=C2=A0 A required pointer par= ameter is NULL. >> +=C2=A0 @retval EFI_NOT_FOUND=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0 FTW spare information could not be=20 >> found. >> + >> +**/ >> +EFI_STATUS >> +EFIAPI >> +GetVariableFlashFtwSpareInfo ( >> +=C2=A0 OUT EFI_PHYSICAL_ADDRESS=C2=A0 *BaseAddress, >> +=C2=A0 OUT UINT64=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 *Length >> +=C2=A0 ) >> +{ >> +=C2=A0 EFI_STATUS=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0 Status; >> +=C2=A0 VARIABLE_FLASH_INFO=C2=A0 *VariableFlashInfo; >> + >> +=C2=A0 if ((BaseAddress =3D=3D NULL) || (Length =3D=3D NULL)) { >> +=C2=A0=C2=A0=C2=A0 return EFI_INVALID_PARAMETER; >> +=C2=A0 } >> + >> +=C2=A0 Status =3D GetVariableFlashInfoFromHob (&VariableFlashInfo); >> +=C2=A0 if (!EFI_ERROR (Status)) { >> +=C2=A0=C2=A0=C2=A0 *BaseAddress =3D VariableFlashInfo->FtwSpareBaseAddr= ess; >> +=C2=A0=C2=A0=C2=A0 *Length=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 =3D VariableFl= ashInfo->FtwSpareLength; >> +=C2=A0 } else { >> +=C2=A0=C2=A0=C2=A0 *BaseAddress =3D (EFI_PHYSICAL_ADDRESS)(PcdGet64=20 >> (PcdFlashNvStorageFtwSpareBase64) !=3D 0 ? >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0 PcdGet64=20 >> (PcdFlashNvStorageFtwSpareBase64) : >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0 PcdGet32=20 >> (PcdFlashNvStorageFtwSpareBase) >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0 ); >> +=C2=A0=C2=A0=C2=A0 *Length =3D (UINT64)PcdGet32 (PcdFlashNvStorageFtwSp= areSize); >> +=C2=A0 } >> + >> +=C2=A0 return EFI_SUCCESS; >> +} >> + >> +/** >> +=C2=A0 Get the base address and size for the fault tolerant write (FTW)= =20 >> working >> +=C2=A0 area used for UEFI variable storage. >> + >> +=C2=A0 @param[out] BaseAddress=C2=A0=C2=A0=C2=A0 The FTW working area b= ase address. >> +=C2=A0 @param[out] Length=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0 The FTW working area length in bytes. >> + >> +=C2=A0 @retval EFI_SUCCESS=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0 FTW working information was found=20 >> successfully. >> +=C2=A0 @retval EFI_INVALID_PARAMETER=C2=A0=C2=A0 A required pointer par= ameter is NULL. >> +=C2=A0 @retval EFI_NOT_FOUND=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0 FTW working information could not=20 >> be found. >> + >> +**/ >> +EFI_STATUS >> +EFIAPI >> +GetVariableFlashFtwWorkingInfo ( >> +=C2=A0 OUT EFI_PHYSICAL_ADDRESS=C2=A0 *BaseAddress, >> +=C2=A0 OUT UINT64=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 *Length >> +=C2=A0 ) >> +{ >> +=C2=A0 EFI_STATUS=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0 Status; >> +=C2=A0 VARIABLE_FLASH_INFO=C2=A0 *VariableFlashInfo; >> + >> +=C2=A0 if ((BaseAddress =3D=3D NULL) || (Length =3D=3D NULL)) { >> +=C2=A0=C2=A0=C2=A0 return EFI_INVALID_PARAMETER; >> +=C2=A0 } >> + >> +=C2=A0 Status =3D GetVariableFlashInfoFromHob (&VariableFlashInfo); >> +=C2=A0 if (!EFI_ERROR (Status)) { >> +=C2=A0=C2=A0=C2=A0 *BaseAddress =3D VariableFlashInfo->FtwWorkingBaseAd= dress; >> +=C2=A0=C2=A0=C2=A0 *Length=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 =3D VariableFl= ashInfo->FtwWorkingLength; >> +=C2=A0 } else { >> +=C2=A0=C2=A0=C2=A0 *BaseAddress =3D (EFI_PHYSICAL_ADDRESS)(PcdGet64=20 >> (PcdFlashNvStorageFtwWorkingBase64) !=3D 0 ? >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0 PcdGet64=20 >> (PcdFlashNvStorageFtwWorkingBase64) : >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0 PcdGet32=20 >> (PcdFlashNvStorageFtwWorkingBase) >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0 ); >> +=C2=A0=C2=A0=C2=A0 *Length =3D (UINT64)PcdGet32 (PcdFlashNvStorageFtwWo= rkingSize); >> +=C2=A0 } >> + >> +=C2=A0 return EFI_SUCCESS; >> +} >> diff --git a/MdeModulePkg/Include/Library/VariableFlashInfoLib.h=20 >> b/MdeModulePkg/Include/Library/VariableFlashInfoLib.h >> new file mode 100644 >> index 000000000000..1367be9376ea >> --- /dev/null >> +++ b/MdeModulePkg/Include/Library/VariableFlashInfoLib.h >> @@ -0,0 +1,68 @@ >> +/** @file >> +=C2=A0 Variable Flash Information Library >> + >> +Copyright (c) Microsoft Corporation
>> +SPDX-License-Identifier: BSD-2-Clause-Patent >> + >> +**/ >> + >> +#ifndef VARIABLE_FLASH_INFO_LIB_H_ >> +#define VARIABLE_FLASH_INFO_LIB_H_ >> + >> +/** >> +=C2=A0 Get the base address and size for the NV storage area used for U= EFI=20 >> variable storage. >> + >> +=C2=A0 @param[out] BaseAddress=C2=A0=C2=A0=C2=A0 The NV storage base ad= dress. >> +=C2=A0 @param[out] Length=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0 The NV storage length in bytes. >> + >> +=C2=A0 @retval EFI_SUCCESS=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0 NV storage information was found=20 >> successfully. >> +=C2=A0 @retval EFI_INVALID_PARAMETER=C2=A0=C2=A0 A required pointer par= ameter is NULL. >> +=C2=A0 @retval EFI_NOT_FOUND=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0 NV storage information could not be=20 >> found. >> + >> +**/ >> +EFI_STATUS >> +EFIAPI >> +GetVariableFlashNvStorageInfo ( >> +=C2=A0 OUT EFI_PHYSICAL_ADDRESS=C2=A0 *BaseAddress, >> +=C2=A0 OUT UINT64=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 *Length >> +=C2=A0 ); >> + >> +/** >> +=C2=A0 Get the base address and size for the fault tolerant write (FTW)= spare >> +=C2=A0 area used for UEFI variable storage. >> + >> +=C2=A0 @param[out] BaseAddress=C2=A0=C2=A0=C2=A0 The FTW spare base add= ress. >> +=C2=A0 @param[out] Length=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0 The FTW spare length in bytes. >> + >> +=C2=A0 @retval EFI_SUCCESS=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0 FTW spare information was found=20 >> successfully. >> +=C2=A0 @retval EFI_INVALID_PARAMETER=C2=A0=C2=A0 A required pointer par= ameter is NULL. >> +=C2=A0 @retval EFI_NOT_FOUND=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0 FTW spare information could not be=20 >> found. >> + >> +**/ >> +EFI_STATUS >> +EFIAPI >> +GetVariableFlashFtwSpareInfo ( >> +=C2=A0 OUT EFI_PHYSICAL_ADDRESS=C2=A0 *BaseAddress, >> +=C2=A0 OUT UINT64=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 *Length >> +=C2=A0 ); >> + >> +/** >> +=C2=A0 Get the base address and size for the fault tolerant write (FTW)= =20 >> working >> +=C2=A0 area used for UEFI variable storage. >> + >> +=C2=A0 @param[out] BaseAddress=C2=A0=C2=A0=C2=A0 The FTW working area b= ase address. >> +=C2=A0 @param[out] Length=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0 The FTW working area length in bytes. >> + >> +=C2=A0 @retval EFI_SUCCESS=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0 FTW working information was found=20 >> successfully. >> +=C2=A0 @retval EFI_INVALID_PARAMETER=C2=A0=C2=A0 A required pointer par= ameter is NULL. >> +=C2=A0 @retval EFI_NOT_FOUND=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0 FTW working information could not=20 >> be found. >> + >> +**/ >> +EFI_STATUS >> +EFIAPI >> +GetVariableFlashFtwWorkingInfo ( >> +=C2=A0 OUT EFI_PHYSICAL_ADDRESS=C2=A0 *BaseAddress, >> +=C2=A0 OUT UINT64=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 *Length >> +=C2=A0 ); >> + >> +#endif >> diff --git=20 >> a/MdeModulePkg/Library/BaseVariableFlashInfoLib/BaseVariableFlashInfoLib= .inf=20 >> b/MdeModulePkg/Library/BaseVariableFlashInfoLib/BaseVariableFlashInfoLib= .inf=20 >> >> new file mode 100644 >> index 000000000000..70175e75f9b1 >> --- /dev/null >> +++=20 >> b/MdeModulePkg/Library/BaseVariableFlashInfoLib/BaseVariableFlashInfoLib= .inf=20 >> >> @@ -0,0 +1,48 @@ >> +## @file >> +#=C2=A0 Variable Flash Information Library >> +# >> +#=C2=A0 Provides services to access UEFI variable flash information. >> +# >> +#=C2=A0 Copyright (c) Microsoft Corporation
>> +#=C2=A0 SPDX-License-Identifier: BSD-2-Clause-Patent >> +## >> + >> +[Defines] >> +=C2=A0 INF_VERSION=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 =3D 0x00010005 >> +=C2=A0 BASE_NAME=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 =3D Ba= seVariableFlashInfoLib >> +=C2=A0 MODULE_UNI_FILE=C2=A0=C2=A0 =3D BaseVariableFlashInfoLib.uni >> +=C2=A0 FILE_GUID=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 =3D DE= C426C9-C92E-4BAD-8E93-3F61C261118B >> +=C2=A0 MODULE_TYPE=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 =3D BASE >> +=C2=A0 VERSION_STRING=C2=A0=C2=A0=C2=A0 =3D 1.0 >> +=C2=A0 LIBRARY_CLASS=C2=A0=C2=A0=C2=A0=C2=A0 =3D VariableFlashInfoLib >> + >> +# >> +# The following information is for reference only and not required by= =20 >> the build tools. >> +# >> +#=C2=A0 VALID_ARCHITECTURES=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0 =3D ANY >> +# >> + >> +[Sources] >> +=C2=A0 BaseVariableFlashInfoLib.c >> + >> +[Packages] >> +=C2=A0 MdePkg/MdePkg.dec >> +=C2=A0 MdeModulePkg/MdeModulePkg.dec >> + >> +[LibraryClasses] >> +=C2=A0 DebugLib >> +=C2=A0 HobLib >> + >> +[Guids] >> +=C2=A0 gVariableFlashInfoHobGuid=C2=A0=C2=A0=C2=A0=C2=A0 ## CONSUMES=C2= =A0=C2=A0=C2=A0=C2=A0 ## HOB >> + >> +[Pcd] >> +=C2=A0 gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase = =20 >> ## SOMETIMES_CONSUMES >> +=C2=A0 gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase64 = =20 >> ## SOMETIMES_CONSUMES >> +=C2=A0 gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableSize = =20 >> ## SOMETIMES_CONSUMES >> +=C2=A0 gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareBase = =20 >> ## SOMETIMES_CONSUMES >> +=C2=A0 gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareBase64 = =20 >> ## SOMETIMES_CONSUMES >> +=C2=A0 gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareSize = =20 >> ## SOMETIMES_CONSUMES >> +=C2=A0 gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingBase = =20 >> ## SOMETIMES_CONSUMES >> +=C2=A0 gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingBase64= =20 >> ## SOMETIMES_CONSUMES >> +=C2=A0 gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingSize = =20 >> ## SOMETIMES_CONSUMES >> diff --git=20 >> a/MdeModulePkg/Library/BaseVariableFlashInfoLib/BaseVariableFlashInfoLib= .uni=20 >> b/MdeModulePkg/Library/BaseVariableFlashInfoLib/BaseVariableFlashInfoLib= .uni=20 >> >> new file mode 100644 >> index 000000000000..9a5348fa02a0 >> --- /dev/null >> +++=20 >> b/MdeModulePkg/Library/BaseVariableFlashInfoLib/BaseVariableFlashInfoLib= .uni=20 >> >> @@ -0,0 +1,12 @@ >> +// /** @file >> +// Variable Flash Information Library >> +// >> +// Copyright (c) Microsoft Corporation
>> +// >> +// SPDX-License-Identifier: BSD-2-Clause-Patent >> +// >> +// **/ >> + >> +#string STR_MODULE_ABSTRACT=C2=A0=C2=A0=C2=A0=C2=A0 #language en-US "UE= FI variable flash=20 >> information library" >> + >> +#string STR_MODULE_DESCRIPTION=C2=A0 #language en-US "Provides services= to=20 >> access UEFI variable flash information." >> diff --git a/MdeModulePkg/MdeModulePkg.dec=20 >> b/MdeModulePkg/MdeModulePkg.dec >> index 4e82f5836096..2bcb9f9453af 100644 >> --- a/MdeModulePkg/MdeModulePkg.dec >> +++ b/MdeModulePkg/MdeModulePkg.dec >> @@ -154,6 +154,10 @@ [LibraryClasses] >> =C2=A0=C2=A0=C2=A0 # >> =C2=A0=C2=A0=C2=A0 VariablePolicyHelperLib|Include/Library/VariablePolic= yHelperLib.h >> +=C2=A0 ##=C2=A0 @libraryclass=C2=A0 Provides services to access UEFI va= riable flash=20 >> information. >> +=C2=A0 # >> +=C2=A0 VariableFlashInfoLib|Include/Library/VariableFlashInfoLib.h >> + >> =C2=A0 [Guids] >> =C2=A0=C2=A0=C2=A0 ## MdeModule package token space guid >> =C2=A0=C2=A0=C2=A0 # Include/Guid/MdeModulePkgTokenSpace.h >> diff --git a/MdeModulePkg/MdeModulePkg.dsc=20 >> b/MdeModulePkg/MdeModulePkg.dsc >> index b1d83461865e..90a0a7ec4a7c 100644 >> --- a/MdeModulePkg/MdeModulePkg.dsc >> +++ b/MdeModulePkg/MdeModulePkg.dsc >> @@ -103,6 +103,7 @@ [LibraryClasses] >> =20 >> DisplayUpdateProgressLib|MdeModulePkg/Library/DisplayUpdateProgressLibGr= aphics/DisplayUpdateProgressLibGraphics.inf=20 >> >> =20 >> VariablePolicyHelperLib|MdeModulePkg/Library/VariablePolicyHelperLib/Var= iablePolicyHelperLib.inf=20 >> >> =20 >> MmUnblockMemoryLib|MdePkg/Library/MmUnblockMemoryLib/MmUnblockMemoryLibN= ull.inf=20 >> >> + =20 >> VariableFlashInfoLib|MdeModulePkg/Library/BaseVariableFlashInfoLib/BaseV= ariableFlashInfoLib.inf=20 >> >> =C2=A0 [LibraryClasses.EBC.PEIM] >> =C2=A0=C2=A0=C2=A0 IoLib|MdePkg/Library/PeiIoLibCpuIo/PeiIoLibCpuIo.inf >> @@ -440,6 +441,7 @@ [Components] >> =20 >> MdeModulePkg/Library/FmpAuthenticationLibNull/FmpAuthenticationLibNull.i= nf=20 >> >> =C2=A0=C2=A0=C2=A0 MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.i= nf >> =C2=A0=C2=A0=C2=A0 MdeModulePkg/Library/DxeCapsuleLibFmp/DxeRuntimeCapsu= leLib.inf >> + =20 >> MdeModulePkg/Library/BaseVariableFlashInfoLib/BaseVariableFlashInfoLib.i= nf=20 >> >> =C2=A0 [Components.IA32, Components.X64, Components.AARCH64] >> =C2=A0=C2=A0=C2=A0 MdeModulePkg/Universal/EbcDxe/EbcDxe.inf >=20 >=20 >=20 >=20