From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by mx.groups.io with SMTP id smtpd.web10.7422.1684931339636052825 for ; Wed, 24 May 2023 05:29:05 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="unable to parse pub key" header.i=@intel.com header.s=intel header.b=F+OUzHOv; spf=pass (domain: intel.com, ip: 134.134.136.100, mailfrom: ray.ni@intel.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1684931345; x=1716467345; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=PsVAZtIfV4JonZhU59ZmqLYKNGHYf9zzYroxew6m0kY=; b=F+OUzHOvb8Z9plIuKXmxKhxrA5T+ElNVa/vZQGauM+ESob3KRnCCo9Hs hkBGagcf2sCAJmq+nLhiz2zflHanUUZT4uNkyVL4lzdelhsUMLAXSbuJr 3ORGSJr+XnWlvq3+ggzEcqmYsDkyXmmp1xkvOlWWZ2KJJntPFhJ83w6oS 6ixpEzq/UcLdG8YRMuDsoYLZaBi+Of25udN4z2JCSvkN1iHJ1sRJQrLEo 2PdG4oMyMKxMxpQCbmZQ7idAIEILYYtoc1YscoVtAet+RMZFcCi5teaYo SH1pfhmDxWFLBelFZ0h3LLB+f1AB8y+RSgG+n4wBVTUWd0WIEtCvc7QhO g==; X-IronPort-AV: E=McAfee;i="6600,9927,10720"; a="419259522" X-IronPort-AV: E=Sophos;i="6.00,189,1681196400"; d="scan'208";a="419259522" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 May 2023 05:29:03 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10720"; a="704328077" X-IronPort-AV: E=Sophos;i="6.00,189,1681196400"; d="scan'208";a="704328077" Received: from shwdeopenlab706.ccr.corp.intel.com ([10.239.55.95]) by orsmga002.jf.intel.com with ESMTP; 24 May 2023 05:29:01 -0700 From: "Ni, Ray" To: devel@edk2.groups.io Cc: Nate DeSimone , Zhiguang Liu , Michael D Kinney Subject: [PATCH 2/6] SimicsOpenBoardPkg: Remove logic that loads variable from disk file Date: Wed, 24 May 2023 20:28:48 +0800 Message-Id: <20230524122852.2047-3-ray.ni@intel.com> X-Mailer: git-send-email 2.39.1.windows.1 In-Reply-To: <20230524122852.2047-1-ray.ni@intel.com> References: <20230524122852.2047-1-ray.ni@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Simics QSP platform always supports flash devices. The logic that was ported from OVMF where the flash devices might not be supported in some configurations is useless in QSP platform. So, the patch removes all of them. Signed-off-by: Ray Ni Cc: Nate DeSimone Cc: Zhiguang Liu Cc: Michael D Kinney --- .../BoardX58Ich10/OpenBoardPkg.dsc | 2 - .../Include/Library/SerializeVariablesLib.h | 224 ----- .../Library/BoardBdsHookLib/BoardBdsHookLib.c | 124 --- .../BoardBdsHookLib/BoardBdsHookLib.inf | 3 - .../Library/NvVarsFileLib/FsAccess.c | 507 ---------- .../Library/NvVarsFileLib/NvVarsFileLib.c | 77 -- .../Library/NvVarsFileLib/NvVarsFileLib.h | 55 -- .../Library/NvVarsFileLib/NvVarsFileLib.inf | 53 -- .../SerializeVariablesLib.c | 869 ------------------ .../SerializeVariablesLib.h | 33 - .../SerializeVariablesLib.inf | 36 - .../Intel/SimicsOpenBoardPkg/OpenBoardPkg.dec | 3 - 12 files changed, 1986 deletions(-) delete mode 100644 Platform/Intel/SimicsOpenBoardPkg/Include/Library/Seria= lizeVariablesLib.h delete mode 100644 Platform/Intel/SimicsOpenBoardPkg/Library/NvVarsFileLib= /FsAccess.c delete mode 100644 Platform/Intel/SimicsOpenBoardPkg/Library/NvVarsFileLib= /NvVarsFileLib.c delete mode 100644 Platform/Intel/SimicsOpenBoardPkg/Library/NvVarsFileLib= /NvVarsFileLib.h delete mode 100644 Platform/Intel/SimicsOpenBoardPkg/Library/NvVarsFileLib= /NvVarsFileLib.inf delete mode 100644 Platform/Intel/SimicsOpenBoardPkg/Library/SerializeVari= ablesLib/SerializeVariablesLib.c delete mode 100644 Platform/Intel/SimicsOpenBoardPkg/Library/SerializeVari= ablesLib/SerializeVariablesLib.h delete mode 100644 Platform/Intel/SimicsOpenBoardPkg/Library/SerializeVari= ablesLib/SerializeVariablesLib.inf diff --git a/Platform/Intel/SimicsOpenBoardPkg/BoardX58Ich10/OpenBoardPkg.d= sc b/Platform/Intel/SimicsOpenBoardPkg/BoardX58Ich10/OpenBoardPkg.dsc index 5ac260a26f..4e8991dbdf 100644 --- a/Platform/Intel/SimicsOpenBoardPkg/BoardX58Ich10/OpenBoardPkg.dsc +++ b/Platform/Intel/SimicsOpenBoardPkg/BoardX58Ich10/OpenBoardPkg.dsc @@ -114,9 +114,7 @@ #######################################=0D DxeLoadLinuxLib|$(BOARD_PKG)/Library/LoadLinuxLib/DxeLoadLinuxLib.inf=0D LogoLib|$(BOARD_PKG)/Library/DxeLogoLib/DxeLogoLib.inf=0D - NvVarsFileLib|$(BOARD_PKG)/Library/NvVarsFileLib/NvVarsFileLib.inf=0D ReportFvLib|$(BOARD_PKG)/Library/PeiReportFvLib/PeiReportFvLib.inf=0D - SerializeVariablesLib|$(BOARD_PKG)/Library/SerializeVariablesLib/Seriali= zeVariablesLib.inf=0D SiliconPolicyInitLib|$(BOARD_PKG)/Policy/Library/SiliconPolicyInitLib/Si= liconPolicyInitLib.inf=0D SiliconPolicyUpdateLib|$(BOARD_PKG)/Policy/Library/SiliconPolicyUpdateLi= b/SiliconPolicyUpdateLib.inf=0D PlatformCmosAccessLib|BoardModulePkg/Library/PlatformCmosAccessLibNull/P= latformCmosAccessLibNull.inf=0D diff --git a/Platform/Intel/SimicsOpenBoardPkg/Include/Library/SerializeVar= iablesLib.h b/Platform/Intel/SimicsOpenBoardPkg/Include/Library/SerializeVa= riablesLib.h deleted file mode 100644 index c32f97d787..0000000000 --- a/Platform/Intel/SimicsOpenBoardPkg/Include/Library/SerializeVariablesL= ib.h +++ /dev/null @@ -1,224 +0,0 @@ -/** @file=0D - Serialize & Deserialize UEFI Variables=0D -=0D - Copyright (c) 2019, Intel Corporation. All rights reserved.
=0D -=0D - SPDX-License-Identifier: BSD-2-Clause-Patent=0D -=0D -**/=0D -=0D -#ifndef __SERIALIZE_VARIABLES_LIB__=0D -#define __SERIALIZE_VARIABLES_LIB__=0D -=0D -=0D -/**=0D - Callback function for each variable=0D -=0D - @param[in] Context - Context as sent to the iteration function=0D - @param[in] VariableName - Refer to RuntimeServices GetNextVariableName=0D - @param[in] VendorGuid - Refer to RuntimeServices GetNextVariableName=0D - @param[in] Attributes - Refer to RuntimeServices GetVariable=0D - @param[in] DataSize - Refer to RuntimeServices GetVariable=0D - @param[in] Data - Refer to RuntimeServices GetVariable=0D -=0D - @retval RETURN_SUCCESS Continue iterating through the variables= =0D - @return Any RETURN_ERROR Stop iterating through the variables=0D -=0D -**/=0D -typedef=0D -RETURN_STATUS=0D -(EFIAPI *VARIABLE_SERIALIZATION_ITERATION_CALLBACK)(=0D - IN VOID *Context,=0D - IN CHAR16 *VariableName,=0D - IN EFI_GUID *VendorGuid,=0D - IN UINT32 Attributes,=0D - IN UINTN DataSize,=0D - IN VOID *Data=0D - );=0D -=0D -=0D -/**=0D - Creates a new variable serialization instance=0D -=0D - @param[out] Handle - Handle for a variable serialization instance=0D -=0D - @retval RETURN_SUCCESS - The variable serialization instance was=0D - successfully created.=0D - @retval RETURN_OUT_OF_RESOURCES - There we not enough resources to= =0D - create the variable serialization instance.=0D -=0D -**/=0D -RETURN_STATUS=0D -EFIAPI=0D -SerializeVariablesNewInstance (=0D - OUT EFI_HANDLE *Handle=0D - );=0D -=0D -=0D -/**=0D - Free memory associated with a variable serialization instance=0D -=0D - @param[in] Handle - Handle for a variable serialization instance=0D -=0D - @retval RETURN_SUCCESS - The variable serialization instance was=0D - successfully freed.=0D - @retval RETURN_INVALID_PARAMETER - Handle was not a valid=0D - variable serialization instance.=0D -=0D -**/=0D -RETURN_STATUS=0D -EFIAPI=0D -SerializeVariablesFreeInstance (=0D - IN EFI_HANDLE Handle=0D - );=0D -=0D -=0D -/**=0D - Creates a new variable serialization instance using the given=0D - binary representation of the variables to fill the new instance=0D -=0D - @param[out] Handle - Handle for a variable serialization instance=0D - @param[in] Buffer - A buffer with the serialized representation=0D - of the variables. Must be the same format as produced=0D - by SerializeVariablesToBuffer.=0D - @param[in] Size - This is the size of the binary representation=0D - of the variables.=0D -=0D - @retval RETURN_SUCCESS - The binary representation was successfully= =0D - imported into a new variable serialization instance=0D - @retval RETURN_OUT_OF_RESOURCES - There we not enough resources to= =0D - create the new variable serialization instance=0D -=0D -**/=0D -RETURN_STATUS=0D -EFIAPI=0D -SerializeVariablesNewInstanceFromBuffer (=0D - OUT EFI_HANDLE *Handle,=0D - IN VOID *Buffer,=0D - IN UINTN Size=0D - );=0D -=0D -=0D -/**=0D - Iterates all variables found with RuntimeServices GetNextVariableName=0D -=0D - @param[in] CallbackFunction - Function called for each variable instan= ce=0D - @param[in] Context - Passed to each call of CallbackFunction=0D -=0D - @retval RETURN_SUCCESS - All variables were iterated without the=0D - CallbackFunction returning an error=0D - @retval RETURN_OUT_OF_RESOURCES - There we not enough resources to= =0D - iterate through the variables=0D - @return Any of RETURN_ERROR indicates an error reading the variable= =0D - or an error was returned from CallbackFunction=0D -=0D -**/=0D -RETURN_STATUS=0D -EFIAPI=0D -SerializeVariablesIterateSystemVariables (=0D - IN VARIABLE_SERIALIZATION_ITERATION_CALLBACK CallbackFunction,=0D - IN VOID *Context=0D - );=0D -=0D -=0D -/**=0D - Iterates all variables found in the variable serialization instance=0D -=0D - @param[in] Handle - Handle for a variable serialization instance=0D - @param[in] CallbackFunction - Function called for each variable instan= ce=0D - @param[in] Context - Passed to each call of CallbackFunction=0D -=0D - @retval RETURN_SUCCESS - All variables were iterated without the=0D - CallbackFunction returning an error=0D - @retval RETURN_OUT_OF_RESOURCES - There we not enough resources to= =0D - iterate through the variables=0D - @return Any of RETURN_ERROR indicates an error reading the variable= =0D - or an error was returned from CallbackFunction=0D -=0D -**/=0D -RETURN_STATUS=0D -EFIAPI=0D -SerializeVariablesIterateInstanceVariables (=0D - IN EFI_HANDLE Handle,=0D - IN VARIABLE_SERIALIZATION_ITERATION_CALLBACK CallbackFunction,=0D - IN VOID *Context=0D - );=0D -=0D -=0D -/**=0D - Sets all variables found in the variable serialization instance=0D -=0D - @param[in] Handle - Handle for a variable serialization instance=0D -=0D - @retval RETURN_SUCCESS - All variables were set successfully=0D - @retval RETURN_OUT_OF_RESOURCES - There we not enough resources to= =0D - set all the variables=0D - @return Any of RETURN_ERROR indicates an error reading the variable= s=0D - or in attempting to set a variable=0D -=0D -**/=0D -RETURN_STATUS=0D -EFIAPI=0D -SerializeVariablesSetSerializedVariables (=0D - IN EFI_HANDLE Handle=0D - );=0D -=0D -=0D -/**=0D - Adds a variable to the variable serialization instance=0D -=0D - @param[in] Handle - Handle for a variable serialization instance=0D - @param[in] VariableName - Refer to RuntimeServices GetVariable=0D - @param[in] VendorGuid - Refer to RuntimeServices GetVariable=0D - @param[in] Attributes - Refer to RuntimeServices GetVariable=0D - @param[in] DataSize - Refer to RuntimeServices GetVariable=0D - @param[in] Data - Refer to RuntimeServices GetVariable=0D -=0D - @retval RETURN_SUCCESS - All variables were set successfully=0D - @retval RETURN_OUT_OF_RESOURCES - There we not enough resources to= =0D - add the variable=0D -=0D -**/=0D -RETURN_STATUS=0D -EFIAPI=0D -SerializeVariablesAddVariable (=0D - IN EFI_HANDLE Handle,=0D - IN CHAR16 *VariableName,=0D - IN EFI_GUID *VendorGuid,=0D - IN UINT32 Attributes,=0D - IN UINTN DataSize,=0D - IN VOID *Data=0D - );=0D -=0D -=0D -/**=0D - Serializes the variables known to this instance into the=0D - provided buffer.=0D -=0D - @param[in] Handle - Handle for a variable serialization instance=0D - @param[out] Buffer - A buffer to store the binary representation=0D - of the variables.=0D - @param[in,out] Size - On input this is the size of the buffer.=0D - On output this is the size of the binary representation= =0D - of the variables.=0D -=0D - @retval RETURN_SUCCESS - The binary representation was successfully= =0D - completed and returned in the buffer.=0D - @retval RETURN_OUT_OF_RESOURCES - There we not enough resources to= =0D - save the variables to the buffer.=0D - @retval RETURN_INVALID_PARAMETER - Handle was not a valid=0D - variable serialization instance or=0D - Size or Buffer were NULL.=0D -=0D -**/=0D -RETURN_STATUS=0D -EFIAPI=0D -SerializeVariablesToBuffer (=0D - IN EFI_HANDLE Handle,=0D - OUT VOID *Buffer,=0D - IN OUT UINTN *Size=0D - );=0D -=0D -=0D -#endif=0D -=0D diff --git a/Platform/Intel/SimicsOpenBoardPkg/Library/BoardBdsHookLib/Boar= dBdsHookLib.c b/Platform/Intel/SimicsOpenBoardPkg/Library/BoardBdsHookLib/B= oardBdsHookLib.c index ba4d2b02d8..3c6385c12f 100644 --- a/Platform/Intel/SimicsOpenBoardPkg/Library/BoardBdsHookLib/BoardBdsHoo= kLib.c +++ b/Platform/Intel/SimicsOpenBoardPkg/Library/BoardBdsHookLib/BoardBdsHoo= kLib.c @@ -1111,119 +1111,6 @@ PciAcpiInitialization ( Interrupt8259WriteMask(0xFFFF, 0x0000);=0D }=0D =0D -EFI_STATUS=0D -EFIAPI=0D -ConnectRecursivelyIfPciMassStorage (=0D - IN EFI_HANDLE Handle,=0D - IN EFI_PCI_IO_PROTOCOL *Instance,=0D - IN PCI_TYPE00 *PciHeader=0D - )=0D -{=0D - EFI_STATUS Status;=0D - EFI_DEVICE_PATH_PROTOCOL *DevicePath;=0D - CHAR16 *DevPathStr;=0D -=0D - //=0D - // Recognize PCI Mass Storage=0D - //=0D - if (IS_CLASS1 (PciHeader, PCI_CLASS_MASS_STORAGE)) {=0D - DevicePath =3D NULL;=0D - Status =3D gBS->HandleProtocol (=0D - Handle,=0D - &gEfiDevicePathProtocolGuid,=0D - (VOID*)&DevicePath=0D - );=0D - if (EFI_ERROR (Status)) {=0D - return Status;=0D - }=0D -=0D - //=0D - // Print Device Path=0D - //=0D - DevPathStr =3D ConvertDevicePathToText (DevicePath, FALSE, FALSE);=0D - if (DevPathStr !=3D NULL) {=0D - DEBUG(( DEBUG_INFO, "Found Mass Storage device: %s\n", DevPathStr));= =0D - FreePool(DevPathStr);=0D - }=0D -=0D - Status =3D gBS->ConnectController (Handle, NULL, NULL, TRUE);=0D - if (EFI_ERROR (Status)) {=0D - return Status;=0D - }=0D -=0D - }=0D -=0D - return EFI_SUCCESS;=0D -}=0D -=0D -=0D -/**=0D - This notification function is invoked when the=0D - EMU Variable FVB has been changed.=0D -=0D - @param Event The event that occurred=0D - @param Context For EFI compatibility. Not used.=0D -=0D -**/=0D -VOID=0D -EFIAPI=0D -EmuVariablesUpdatedCallback (=0D - IN EFI_EVENT Event,=0D - IN VOID *Context=0D - )=0D -{=0D - DEBUG ((DEBUG_INFO, "%a called\n", __FUNCTION__));=0D - UpdateNvVarsOnFileSystem ();=0D -}=0D -=0D -=0D -EFI_STATUS=0D -EFIAPI=0D -VisitingFileSystemInstance (=0D - IN EFI_HANDLE Handle,=0D - IN VOID *Instance,=0D - IN VOID *Context=0D - )=0D -{=0D - EFI_STATUS Status;=0D - STATIC BOOLEAN ConnectedToFileSystem =3D FALSE;=0D -=0D - if (ConnectedToFileSystem) {=0D - return EFI_ALREADY_STARTED;=0D - }=0D -=0D - Status =3D ConnectNvVarsToFileSystem (Handle);=0D - if (EFI_ERROR (Status)) {=0D - return Status;=0D - }=0D -=0D - ConnectedToFileSystem =3D TRUE;=0D - mEmuVariableEvent =3D=0D - EfiCreateProtocolNotifyEvent (=0D - &gEfiDevicePathProtocolGuid,=0D - TPL_CALLBACK,=0D - EmuVariablesUpdatedCallback,=0D - NULL,=0D - &mEmuVariableEventReg=0D - );=0D - PcdSet64S (PcdEmuVariableEvent, (UINT64)(UINTN) mEmuVariableEvent);=0D -=0D - return EFI_SUCCESS;=0D -}=0D -=0D -=0D -VOID=0D -PlatformBdsRestoreNvVarsFromHardDisk (=0D - )=0D -{=0D - VisitAllPciInstances (ConnectRecursivelyIfPciMassStorage);=0D - VisitAllInstancesOfProtocol (=0D - &gEfiSimpleFileSystemProtocolGuid,=0D - VisitingFileSystemInstance,=0D - NULL=0D - );=0D -}=0D -=0D /**=0D Connect with predefined platform connect sequence.=0D =0D @@ -1584,17 +1471,6 @@ BdsAfterConsoleReadyBeforeBootOptionCallback ( =0D DEBUG ((DEBUG_INFO, "%a called\n", __FUNCTION__));=0D =0D - if (PcdGetBool (PcdOvmfFlashVariablesEnable)) {=0D - DEBUG ((DEBUG_INFO, "PlatformBdsPolicyBehavior: not restoring NvVars "= =0D - "from disk since flash variables appear to be supported.\n"));=0D - } else {=0D - //=0D - // Try to restore variables from the hard disk early so=0D - // they can be used for the other BDS connect operations.=0D - //=0D - PlatformBdsRestoreNvVarsFromHardDisk ();=0D - }=0D -=0D //=0D // Get current Boot Mode=0D //=0D diff --git a/Platform/Intel/SimicsOpenBoardPkg/Library/BoardBdsHookLib/Boar= dBdsHookLib.inf b/Platform/Intel/SimicsOpenBoardPkg/Library/BoardBdsHookLib= /BoardBdsHookLib.inf index a77edf2699..bcfbdca996 100644 --- a/Platform/Intel/SimicsOpenBoardPkg/Library/BoardBdsHookLib/BoardBdsHoo= kLib.inf +++ b/Platform/Intel/SimicsOpenBoardPkg/Library/BoardBdsHookLib/BoardBdsHoo= kLib.inf @@ -45,14 +45,11 @@ BootLogoLib=0D DevicePathLib=0D PciLib=0D - NvVarsFileLib=0D DxeLoadLinuxLib=0D UefiLib=0D LogoLib=0D =0D [Pcd]=0D - gSimicsOpenBoardPkgTokenSpaceGuid.PcdEmuVariableEvent=0D - gSimicsOpenBoardPkgTokenSpaceGuid.PcdOvmfFlashVariablesEnable=0D gSimicsOpenBoardPkgTokenSpaceGuid.PcdSimicsX58HostBridgePciDevId=0D gEfiMdePkgTokenSpaceGuid.PcdPlatformBootTimeOut=0D gSimicsOpenBoardPkgTokenSpaceGuid.PcdShellFile=0D diff --git a/Platform/Intel/SimicsOpenBoardPkg/Library/NvVarsFileLib/FsAcce= ss.c b/Platform/Intel/SimicsOpenBoardPkg/Library/NvVarsFileLib/FsAccess.c deleted file mode 100644 index 3d98291410..0000000000 --- a/Platform/Intel/SimicsOpenBoardPkg/Library/NvVarsFileLib/FsAccess.c +++ /dev/null @@ -1,507 +0,0 @@ -/** @file=0D - File System Access for NvVarsFileLib=0D -=0D - Copyright (c) 2004 - 2019 Intel Corporation. All rights reserved.
=0D -=0D - SPDX-License-Identifier: BSD-2-Clause-Patent=0D -**/=0D -=0D -#include "NvVarsFileLib.h"=0D -=0D -#include =0D -#include =0D -#include =0D -=0D -=0D -/**=0D - Open the NvVars file for reading or writing=0D -=0D - @param[in] FsHandle - Handle for a gEfiSimpleFileSystemProtocolGuid ins= tance=0D - @param[in] ReadingFile - TRUE: open the file for reading. FALSE: writi= ng=0D - @param[out] NvVarsFile - If EFI_SUCCESS is returned, then this is update= d=0D - with the opened NvVars file.=0D -=0D - @return EFI_SUCCESS if the file was opened=0D -=0D -**/=0D -EFI_STATUS=0D -GetNvVarsFile (=0D - IN EFI_HANDLE FsHandle,=0D - IN BOOLEAN ReadingFile,=0D - OUT EFI_FILE_HANDLE *NvVarsFile=0D - )=0D -{=0D - EFI_STATUS Status;=0D - EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *Fs;=0D - EFI_FILE_HANDLE Root;=0D -=0D - //=0D - // Get the FileSystem protocol on that handle=0D - //=0D - Status =3D gBS->HandleProtocol (=0D - FsHandle,=0D - &gEfiSimpleFileSystemProtocolGuid,=0D - (VOID **)&Fs=0D - );=0D - if (EFI_ERROR (Status)) {=0D - return Status;=0D - }=0D -=0D - //=0D - // Get the volume (the root directory)=0D - //=0D - Status =3D Fs->OpenVolume (Fs, &Root);=0D - if (EFI_ERROR (Status)) {=0D - return Status;=0D - }=0D -=0D - //=0D - // Attempt to open the NvVars file in the root directory=0D - //=0D - Status =3D Root->Open (=0D - Root,=0D - NvVarsFile,=0D - L"NvVars",=0D - ReadingFile ?=0D - EFI_FILE_MODE_READ :=0D - (=0D - EFI_FILE_MODE_CREATE |=0D - EFI_FILE_MODE_READ |=0D - EFI_FILE_MODE_WRITE=0D - ),=0D - 0=0D - );=0D -=0D - return Status;=0D -}=0D -=0D -=0D -/**=0D - Open the NvVars file for reading or writing=0D -=0D - @param[in] File - The file to inspect=0D - @param[out] Exists - Returns whether the file exists=0D - @param[out] Size - Returns the size of the file=0D - (0 if the file does not exist)=0D -=0D -**/=0D -VOID=0D -NvVarsFileReadCheckup (=0D - IN EFI_FILE_HANDLE File,=0D - OUT BOOLEAN *Exists,=0D - OUT UINTN *Size=0D - )=0D -{=0D - EFI_FILE_INFO *FileInfo;=0D -=0D - *Exists =3D FALSE;=0D - *Size =3D 0;=0D -=0D - FileInfo =3D FileHandleGetInfo (File);=0D - if (FileInfo =3D=3D NULL) {=0D - return;=0D - }=0D -=0D - if ((FileInfo->Attribute & EFI_FILE_DIRECTORY) !=3D 0) {=0D - FreePool (FileInfo);=0D - return;=0D - }=0D -=0D - *Exists =3D TRUE;=0D - *Size =3D (UINTN) FileInfo->FileSize;=0D -=0D - FreePool (FileInfo);=0D -}=0D -=0D -=0D -/**=0D - Open the NvVars file for reading or writing=0D -=0D - @param[in] File - The file to inspect=0D - @param[out] Exists - Returns whether the file exists=0D - @param[out] Size - Returns the size of the file=0D - (0 if the file does not exist)=0D -=0D -**/=0D -EFI_STATUS=0D -FileHandleEmpty (=0D - IN EFI_FILE_HANDLE File=0D - )=0D -{=0D - EFI_STATUS Status;=0D - EFI_FILE_INFO *FileInfo;=0D -=0D - //=0D - // Retrieve the FileInfo structure=0D - //=0D - FileInfo =3D FileHandleGetInfo (File);=0D - if (FileInfo =3D=3D NULL) {=0D - return EFI_INVALID_PARAMETER;=0D - }=0D -=0D - //=0D - // If the path is a directory, then return an error=0D - //=0D - if ((FileInfo->Attribute & EFI_FILE_DIRECTORY) !=3D 0) {=0D - FreePool (FileInfo);=0D - return EFI_INVALID_PARAMETER;=0D - }=0D -=0D - //=0D - // If the file size is already 0, then it is empty, so=0D - // we can return success.=0D - //=0D - if (FileInfo->FileSize =3D=3D 0) {=0D - FreePool (FileInfo);=0D - return EFI_SUCCESS;=0D - }=0D -=0D - //=0D - // Set the file size to 0.=0D - //=0D - FileInfo->FileSize =3D 0;=0D - Status =3D FileHandleSetInfo (File, FileInfo);=0D -=0D - FreePool (FileInfo);=0D -=0D - return Status;=0D -}=0D -=0D -=0D -/**=0D - Reads a file to a newly allocated buffer=0D -=0D - @param[in] File - The file to read=0D - @param[in] ReadSize - The size of data to read from the file=0D -=0D - @return Pointer to buffer allocated to hold the file=0D - contents. NULL if an error occurred.=0D -=0D -**/=0D -VOID*=0D -FileHandleReadToNewBuffer (=0D - IN EFI_FILE_HANDLE FileHandle,=0D - IN UINTN ReadSize=0D - )=0D -{=0D - EFI_STATUS Status;=0D - UINTN ActualReadSize;=0D - VOID *FileContents;=0D -=0D - ActualReadSize =3D ReadSize;=0D - FileContents =3D AllocatePool (ReadSize);=0D - if (FileContents !=3D NULL) {=0D - Status =3D FileHandleRead (=0D - FileHandle,=0D - &ReadSize,=0D - FileContents=0D - );=0D - if (EFI_ERROR (Status) || (ActualReadSize !=3D ReadSize)) {=0D - FreePool (FileContents);=0D - return NULL;=0D - }=0D - }=0D -=0D - return FileContents;=0D -}=0D -=0D -=0D -/**=0D - Reads the contents of the NvVars file on the file system=0D -=0D - @param[in] FsHandle - Handle for a gEfiSimpleFileSystemProtocolGuid ins= tance=0D -=0D - @return EFI_STATUS based on the success or failure of the file read= =0D -=0D -**/=0D -EFI_STATUS=0D -ReadNvVarsFile (=0D - IN EFI_HANDLE FsHandle=0D - )=0D -{=0D - EFI_STATUS Status;=0D - EFI_FILE_HANDLE File;=0D - UINTN FileSize;=0D - BOOLEAN FileExists;=0D - VOID *FileContents;=0D - EFI_HANDLE SerializedVariables;=0D -=0D - Status =3D GetNvVarsFile (FsHandle, TRUE, &File);=0D - if (EFI_ERROR (Status)) {=0D - DEBUG ((EFI_D_INFO, "FsAccess.c: Could not open NV Variables file on t= his file system\n"));=0D - return Status;=0D - }=0D -=0D - NvVarsFileReadCheckup (File, &FileExists, &FileSize);=0D - if (FileSize =3D=3D 0) {=0D - FileHandleClose (File);=0D - return EFI_UNSUPPORTED;=0D - }=0D -=0D - FileContents =3D FileHandleReadToNewBuffer (File, FileSize);=0D - if (FileContents =3D=3D NULL) {=0D - FileHandleClose (File);=0D - return EFI_UNSUPPORTED;=0D - }=0D -=0D - DEBUG ((=0D - EFI_D_INFO,=0D - "FsAccess.c: Read %Lu bytes from NV Variables file\n",=0D - (UINT64)FileSize=0D - ));=0D -=0D - Status =3D SerializeVariablesNewInstanceFromBuffer (=0D - &SerializedVariables,=0D - FileContents,=0D - FileSize=0D - );=0D - if (!RETURN_ERROR (Status)) {=0D - Status =3D SerializeVariablesSetSerializedVariables (SerializedVariabl= es);=0D - }=0D -=0D - FreePool (FileContents);=0D - FileHandleClose (File);=0D -=0D - return Status;=0D -}=0D -=0D -=0D -/**=0D - Writes a variable to indicate that the NV variables=0D - have been loaded from the file system.=0D -=0D -**/=0D -STATIC=0D -VOID=0D -SetNvVarsVariable (=0D - VOID=0D - )=0D -{=0D - BOOLEAN VarData;=0D - UINTN Size;=0D -=0D - //=0D - // Write a variable to indicate we've already loaded the=0D - // variable data. If it is found, we skip the loading on=0D - // subsequent attempts.=0D - //=0D - Size =3D sizeof (VarData);=0D - VarData =3D TRUE;=0D - gRT->SetVariable (=0D - L"NvVars",=0D - &gEfiSimpleFileSystemProtocolGuid,=0D - EFI_VARIABLE_NON_VOLATILE |=0D - EFI_VARIABLE_BOOTSERVICE_ACCESS |=0D - EFI_VARIABLE_RUNTIME_ACCESS,=0D - Size,=0D - (VOID*) &VarData=0D - );=0D -}=0D -=0D -=0D -/**=0D - Loads the non-volatile variables from the NvVars file on the=0D - given file system.=0D -=0D - @param[in] FsHandle - Handle for a gEfiSimpleFileSystemProtocolGuid ins= tance=0D -=0D - @return EFI_STATUS based on the success or failure of load operation= =0D -=0D -**/=0D -EFI_STATUS=0D -LoadNvVarsFromFs (=0D - EFI_HANDLE FsHandle=0D - )=0D -{=0D - EFI_STATUS Status;=0D - BOOLEAN VarData;=0D - UINTN Size;=0D -=0D - DEBUG ((EFI_D_INFO, "FsAccess.c: LoadNvVarsFromFs\n"));=0D -=0D - //=0D - // We write a variable to indicate we've already loaded the=0D - // variable data. If it is found, we skip the loading.=0D - //=0D - // This is relevant if the non-volatile variable have been=0D - // able to survive a reboot operation. In that case, we don't=0D - // want to re-load the file as it would overwrite newer changes=0D - // made to the variables.=0D - //=0D - Size =3D sizeof (VarData);=0D - VarData =3D TRUE;=0D - Status =3D gRT->GetVariable (=0D - L"NvVars",=0D - &gEfiSimpleFileSystemProtocolGuid,=0D - NULL,=0D - &Size,=0D - (VOID*) &VarData=0D - );=0D - if (Status =3D=3D EFI_SUCCESS) {=0D - DEBUG ((EFI_D_INFO, "NV Variables were already loaded\n"));=0D - return EFI_ALREADY_STARTED;=0D - }=0D -=0D - //=0D - // Attempt to restore the variables from the NvVars file.=0D - //=0D - Status =3D ReadNvVarsFile (FsHandle);=0D - if (EFI_ERROR (Status)) {=0D - DEBUG ((EFI_D_INFO, "Error while restoring NV variable data\n"));=0D - return Status;=0D - }=0D -=0D - //=0D - // Write a variable to indicate we've already loaded the=0D - // variable data. If it is found, we skip the loading on=0D - // subsequent attempts.=0D - //=0D - SetNvVarsVariable();=0D -=0D - DEBUG ((=0D - EFI_D_INFO,=0D - "FsAccess.c: Read NV Variables file (size=3D%Lu)\n",=0D - (UINT64)Size=0D - ));=0D -=0D - return Status;=0D -}=0D -=0D -=0D -STATIC=0D -RETURN_STATUS=0D -EFIAPI=0D -IterateVariablesCallbackAddAllNvVariables (=0D - IN VOID *Context,=0D - IN CHAR16 *VariableName,=0D - IN EFI_GUID *VendorGuid,=0D - IN UINT32 Attributes,=0D - IN UINTN DataSize,=0D - IN VOID *Data=0D - )=0D -{=0D - EFI_HANDLE Instance;=0D -=0D - Instance =3D (EFI_HANDLE) Context;=0D -=0D - //=0D - // Only save non-volatile variables=0D - //=0D - if ((Attributes & EFI_VARIABLE_NON_VOLATILE) =3D=3D 0) {=0D - return RETURN_SUCCESS;=0D - }=0D -=0D - return SerializeVariablesAddVariable (=0D - Instance,=0D - VariableName,=0D - VendorGuid,=0D - Attributes,=0D - DataSize,=0D - Data=0D - );=0D -}=0D -=0D -=0D -/**=0D - Saves the non-volatile variables into the NvVars file on the=0D - given file system.=0D -=0D - @param[in] FsHandle - Handle for a gEfiSimpleFileSystemProtocolGuid ins= tance=0D -=0D - @return EFI_STATUS based on the success or failure of load operation= =0D -=0D -**/=0D -EFI_STATUS=0D -SaveNvVarsToFs (=0D - EFI_HANDLE FsHandle=0D - )=0D -{=0D - EFI_STATUS Status;=0D - EFI_FILE_HANDLE File;=0D - UINTN WriteSize;=0D - UINTN VariableDataSize;=0D - VOID *VariableData;=0D - EFI_HANDLE SerializedVariables;=0D -=0D - SerializedVariables =3D NULL;=0D -=0D - Status =3D SerializeVariablesNewInstance (&SerializedVariables);=0D - if (EFI_ERROR (Status)) {=0D - return Status;=0D - }=0D -=0D - Status =3D SerializeVariablesIterateSystemVariables (=0D - IterateVariablesCallbackAddAllNvVariables,=0D - (VOID*) SerializedVariables=0D - );=0D - if (EFI_ERROR (Status)) {=0D - return Status;=0D - }=0D -=0D - VariableData =3D NULL;=0D - VariableDataSize =3D 0;=0D - Status =3D SerializeVariablesToBuffer (=0D - SerializedVariables,=0D - NULL,=0D - &VariableDataSize=0D - );=0D - if (Status =3D=3D RETURN_BUFFER_TOO_SMALL) {=0D - VariableData =3D AllocatePool (VariableDataSize);=0D - if (VariableData =3D=3D NULL) {=0D - Status =3D EFI_OUT_OF_RESOURCES;=0D - } else {=0D - Status =3D SerializeVariablesToBuffer (=0D - SerializedVariables,=0D - VariableData,=0D - &VariableDataSize=0D - );=0D - }=0D - }=0D -=0D - SerializeVariablesFreeInstance (SerializedVariables);=0D -=0D - if (EFI_ERROR (Status)) {=0D - return Status;=0D - }=0D -=0D - //=0D - // Open the NvVars file for writing.=0D - //=0D - Status =3D GetNvVarsFile (FsHandle, FALSE, &File);=0D - if (EFI_ERROR (Status)) {=0D - DEBUG ((EFI_D_INFO, "FsAccess.c: Unable to open file to saved NV Varia= bles\n"));=0D - return Status;=0D - }=0D -=0D - //=0D - // Empty the starting file contents.=0D - //=0D - Status =3D FileHandleEmpty (File);=0D - if (EFI_ERROR (Status)) {=0D - FileHandleClose (File);=0D - return Status;=0D - }=0D -=0D - WriteSize =3D VariableDataSize;=0D - Status =3D FileHandleWrite (File, &WriteSize, VariableData);=0D - if (EFI_ERROR (Status)) {=0D - return Status;=0D - }=0D -=0D - FileHandleClose (File);=0D -=0D - if (!EFI_ERROR (Status)) {=0D - //=0D - // Write a variable to indicate we've already loaded the=0D - // variable data. If it is found, we skip the loading on=0D - // subsequent attempts.=0D - //=0D - SetNvVarsVariable();=0D -=0D - DEBUG ((EFI_D_INFO, "Saved NV Variables to NvVars file\n"));=0D - }=0D -=0D - return Status;=0D -}=0D -=0D -=0D diff --git a/Platform/Intel/SimicsOpenBoardPkg/Library/NvVarsFileLib/NvVars= FileLib.c b/Platform/Intel/SimicsOpenBoardPkg/Library/NvVarsFileLib/NvVarsF= ileLib.c deleted file mode 100644 index 2e9618455d..0000000000 --- a/Platform/Intel/SimicsOpenBoardPkg/Library/NvVarsFileLib/NvVarsFileLib= .c +++ /dev/null @@ -1,77 +0,0 @@ -/** @file=0D - Save Non-Volatile Variables to a file system.=0D -=0D - Copyright (c) 2019 Intel Corporation. All rights reserved.
=0D -=0D - SPDX-License-Identifier: BSD-2-Clause-Patent=0D -**/=0D -=0D -#include "NvVarsFileLib.h"=0D -#include =0D -#include =0D -=0D -EFI_HANDLE mNvVarsFileLibFsHandle =3D NULL;=0D -=0D -=0D -/**=0D - Attempts to connect the NvVarsFileLib to the specified file system.=0D -=0D - @param[in] FsHandle - Handle for a gEfiSimpleFileSystemProtocolGuid ins= tance=0D -=0D - @return The EFI_STATUS while attempting to connect the NvVarsFileLib= =0D - to the file system instance.=0D - @retval EFI_SUCCESS - The given file system was connected successful= ly=0D -=0D -**/=0D -EFI_STATUS=0D -EFIAPI=0D -ConnectNvVarsToFileSystem (=0D - IN EFI_HANDLE FsHandle=0D - )=0D -{=0D - EFI_STATUS Status;=0D -=0D - //=0D - // We might fail to load the variable, since the file system initially=0D - // will not have the NvVars file.=0D - //=0D - LoadNvVarsFromFs (FsHandle);=0D -=0D - //=0D - // We must be able to save the variables successfully to the file system= =0D - // to have connected successfully.=0D - //=0D - Status =3D SaveNvVarsToFs (FsHandle);=0D - if (!EFI_ERROR (Status)) {=0D - mNvVarsFileLibFsHandle =3D FsHandle;=0D - }=0D -=0D - return Status;=0D -}=0D -=0D -=0D -/**=0D - Update non-volatile variables stored on the file system.=0D -=0D - @return The EFI_STATUS while attempting to update the variable on=0D - the connected file system.=0D - @retval EFI_SUCCESS - The non-volatile variables were saved to the d= isk=0D - @retval EFI_NOT_STARTED - A file system has not been connected=0D -=0D -**/=0D -EFI_STATUS=0D -EFIAPI=0D -UpdateNvVarsOnFileSystem (=0D - )=0D -{=0D - if (mNvVarsFileLibFsHandle =3D=3D NULL) {=0D - //=0D - // A file system had not been connected to the library.=0D - //=0D - return EFI_NOT_STARTED;=0D - } else {=0D - return SaveNvVarsToFs (mNvVarsFileLibFsHandle);=0D - }=0D -}=0D -=0D -=0D diff --git a/Platform/Intel/SimicsOpenBoardPkg/Library/NvVarsFileLib/NvVars= FileLib.h b/Platform/Intel/SimicsOpenBoardPkg/Library/NvVarsFileLib/NvVarsF= ileLib.h deleted file mode 100644 index 80776fd003..0000000000 --- a/Platform/Intel/SimicsOpenBoardPkg/Library/NvVarsFileLib/NvVarsFileLib= .h +++ /dev/null @@ -1,55 +0,0 @@ -/** @file=0D - Save Non-Volatile Variables to a file system.=0D -=0D - Copyright (c) 2009 - 2019 Intel Corporation. All rights reserved.
=0D -=0D - SPDX-License-Identifier: BSD-2-Clause-Patent=0D -**/=0D -=0D -#ifndef __NV_VARS_FILE_LIB_INSTANCE__=0D -#define __NV_VARS_FILE_LIB_INSTANCE__=0D -=0D -#include =0D -=0D -#include =0D -=0D -#include =0D -=0D -#include =0D -#include =0D -#include =0D -#include =0D -#include =0D -#include =0D -=0D -/**=0D - Loads the non-volatile variables from the NvVars file on the=0D - given file system.=0D -=0D - @param[in] FsHandle - Handle for a gEfiSimpleFileSystemProtocolGuid ins= tance=0D -=0D - @return EFI_STATUS based on the success or failure of load operation= =0D -=0D -**/=0D -EFI_STATUS=0D -LoadNvVarsFromFs (=0D - EFI_HANDLE FsHandle=0D - );=0D -=0D -=0D -/**=0D - Saves the non-volatile variables into the NvVars file on the=0D - given file system.=0D -=0D - @param[in] FsHandle - Handle for a gEfiSimpleFileSystemProtocolGuid ins= tance=0D -=0D - @return EFI_STATUS based on the success or failure of load operation= =0D -=0D -**/=0D -EFI_STATUS=0D -SaveNvVarsToFs (=0D - EFI_HANDLE FsHandle=0D - );=0D -=0D -#endif=0D -=0D diff --git a/Platform/Intel/SimicsOpenBoardPkg/Library/NvVarsFileLib/NvVars= FileLib.inf b/Platform/Intel/SimicsOpenBoardPkg/Library/NvVarsFileLib/NvVar= sFileLib.inf deleted file mode 100644 index 4731e77865..0000000000 --- a/Platform/Intel/SimicsOpenBoardPkg/Library/NvVarsFileLib/NvVarsFileLib= .inf +++ /dev/null @@ -1,53 +0,0 @@ -## @file=0D -# NvVarsFileLib=0D -#=0D -# This library saves and restores non-volatile variables in a=0D -# file within a file system.=0D -#=0D -# Copyright (c) 2006 - 2019 Intel Corporation. All rights reserved.
=0D -#=0D -# SPDX-License-Identifier: BSD-2-Clause-Patent=0D -#=0D -##=0D -=0D -[Defines]=0D - INF_VERSION =3D 0x00010005=0D - BASE_NAME =3D NvVarsFileLib=0D - FILE_GUID =3D 8ECD4CC0-1772-4583-8A74-83633A15FAA0= =0D - MODULE_TYPE =3D UEFI_DRIVER=0D - VERSION_STRING =3D 1.0=0D - LIBRARY_CLASS =3D NvVarsFileLib|DXE_DRIVER DXE_RUNTIME_= DRIVER UEFI_DRIVER=0D -=0D -#=0D -# The following information is for reference only and not required by the = build tools.=0D -#=0D -# VALID_ARCHITECTURES =3D IA32 X64 EBC=0D -#=0D -=0D -[Sources]=0D - FsAccess.c=0D - NvVarsFileLib.c=0D -=0D -[Packages]=0D - MdePkg/MdePkg.dec=0D - MdeModulePkg/MdeModulePkg.dec=0D - ShellPkg/ShellPkg.dec=0D - OvmfPkg/OvmfPkg.dec=0D -=0D -[LibraryClasses]=0D - BaseLib=0D - BaseMemoryLib=0D - DebugLib=0D - FileHandleLib=0D - MemoryAllocationLib=0D - SerializeVariablesLib=0D -=0D -[Protocols]=0D - gEfiSimpleFileSystemProtocolGuid ## CONSUMES=0D -=0D -[Guids]=0D - gEfiFileInfoGuid=0D -=0D -[Depex]=0D - gEfiVariableWriteArchProtocolGuid=0D -=0D diff --git a/Platform/Intel/SimicsOpenBoardPkg/Library/SerializeVariablesLi= b/SerializeVariablesLib.c b/Platform/Intel/SimicsOpenBoardPkg/Library/Seria= lizeVariablesLib/SerializeVariablesLib.c deleted file mode 100644 index be619c838a..0000000000 --- a/Platform/Intel/SimicsOpenBoardPkg/Library/SerializeVariablesLib/Seria= lizeVariablesLib.c +++ /dev/null @@ -1,869 +0,0 @@ -/** @file=0D - Serialize Variables Library implementation=0D -=0D - Copyright (c) 2004 - 2019 Intel Corporation. All rights reserved.
=0D -=0D - SPDX-License-Identifier: BSD-2-Clause-Patent=0D -**/=0D -=0D -#include "SerializeVariablesLib.h"=0D -=0D -/**=0D - Serialization format:=0D -=0D - The SerializeVariablesLib interface does not specify a format=0D - for the serialization of the variable data. This library uses=0D - a packed array of a non-uniformly sized data structure elements.=0D -=0D - Each variable is stored (packed) as:=0D - UINT32 VendorNameSize; // Name size in bytes=0D - CHAR16 VendorName[?]; // The variable unicode name including the=0D - // null terminating character.=0D - EFI_GUID VendorGuid; // The variable GUID=0D - UINT32 DataSize; // The size of variable data in bytes=0D - UINT8 Data[?]; // The variable data=0D -=0D -**/=0D -=0D -=0D -/**=0D - Unpacks the next variable from the buffer=0D -=0D - @param[in] Buffer - Buffer pointing to the next variable instance=0D - On subsequent calls, the pointer should be incremented=0D - by the returned SizeUsed value.=0D - @param[in] MaxSize - Max allowable size for the variable data=0D - On subsequent calls, this should be decremented=0D - by the returned SizeUsed value.=0D - @param[out] Name - Variable name string (address in Buffer)=0D - @param[out] NameSize - Size of Name in bytes=0D - @param[out] Guid - GUID of variable (address in Buffer)=0D - @param[out] Attributes - Attributes of variable=0D - @param[out] Data - Buffer containing Data for variable (address in Buffe= r)=0D - @param[out] DataSize - Size of Data in bytes=0D - @param[out] SizeUsed - Total size used for this variable instance in Buf= fer=0D -=0D - @return EFI_STATUS based on the success or failure of the operation= =0D -=0D -**/=0D -STATIC=0D -EFI_STATUS=0D -UnpackVariableFromBuffer (=0D - IN VOID *Buffer,=0D - IN UINTN MaxSize,=0D - OUT CHAR16 **Name,=0D - OUT UINT32 *NameSize,=0D - OUT EFI_GUID **Guid,=0D - OUT UINT32 *Attributes,=0D - OUT UINT32 *DataSize,=0D - OUT VOID **Data,=0D - OUT UINTN *SizeUsed=0D - )=0D -{=0D - UINT8 *BytePtr;=0D - UINTN Offset;=0D -=0D - BytePtr =3D (UINT8*)Buffer;=0D - Offset =3D 0;=0D -=0D - *NameSize =3D *(UINT32*) (BytePtr + Offset);=0D - Offset =3D Offset + sizeof (UINT32);=0D -=0D - if (Offset > MaxSize) {=0D - return EFI_INVALID_PARAMETER;=0D - }=0D -=0D - *Name =3D (CHAR16*) (BytePtr + Offset);=0D - Offset =3D Offset + *(UINT32*)BytePtr;=0D - if (Offset > MaxSize) {=0D - return EFI_INVALID_PARAMETER;=0D - }=0D -=0D - *Guid =3D (EFI_GUID*) (BytePtr + Offset);=0D - Offset =3D Offset + sizeof (EFI_GUID);=0D - if (Offset > MaxSize) {=0D - return EFI_INVALID_PARAMETER;=0D - }=0D -=0D - *Attributes =3D *(UINT32*) (BytePtr + Offset);=0D - Offset =3D Offset + sizeof (UINT32);=0D - if (Offset > MaxSize) {=0D - return EFI_INVALID_PARAMETER;=0D - }=0D -=0D - *DataSize =3D *(UINT32*) (BytePtr + Offset);=0D - Offset =3D Offset + sizeof (UINT32);=0D - if (Offset > MaxSize) {=0D - return EFI_INVALID_PARAMETER;=0D - }=0D -=0D - *Data =3D (VOID*) (BytePtr + Offset);=0D - Offset =3D Offset + *DataSize;=0D - if (Offset > MaxSize) {=0D - return EFI_INVALID_PARAMETER;=0D - }=0D -=0D - *SizeUsed =3D Offset;=0D -=0D - return EFI_SUCCESS;=0D -}=0D -=0D -=0D -/**=0D - Iterates through the variables in the buffer, and calls a callback=0D - function for each variable found.=0D -=0D - @param[in] CallbackFunction - Function called for each variable instanc= e=0D - @param[in] Context - Passed to each call of CallbackFunction=0D - @param[in] Buffer - Buffer containing serialized variables=0D - @param[in] MaxSize - Size of Buffer in bytes=0D -=0D - @return EFI_STATUS based on the success or failure of the operation= =0D -=0D -**/=0D -STATIC=0D -EFI_STATUS=0D -IterateVariablesInBuffer (=0D - IN VARIABLE_SERIALIZATION_ITERATION_CALLBACK CallbackFunction,=0D - IN VOID *CallbackContext,=0D - IN VOID *Buffer,=0D - IN UINTN MaxSize=0D - )=0D -{=0D - RETURN_STATUS Status;=0D - UINTN TotalSizeUsed;=0D - UINTN SizeUsed;=0D -=0D - CHAR16 *Name;=0D - UINT32 NameSize;=0D - CHAR16 *AlignedName;=0D - UINT32 AlignedNameMaxSize;=0D - EFI_GUID *Guid;=0D - UINT32 Attributes;=0D - UINT32 DataSize;=0D - VOID *Data;=0D -=0D - SizeUsed =3D 0;=0D - AlignedName =3D NULL;=0D - AlignedNameMaxSize =3D 0;=0D - Name =3D NULL;=0D - Guid =3D NULL;=0D - Attributes =3D 0;=0D - DataSize =3D 0;=0D - Data =3D NULL;=0D -=0D - for (=0D - Status =3D EFI_SUCCESS, TotalSizeUsed =3D 0;=0D - !EFI_ERROR (Status) && (TotalSizeUsed < MaxSize);=0D - ) {=0D - Status =3D UnpackVariableFromBuffer (=0D - (VOID*) ((UINT8*) Buffer + TotalSizeUsed),=0D - (MaxSize - TotalSizeUsed),=0D - &Name,=0D - &NameSize,=0D - &Guid,=0D - &Attributes,=0D - &DataSize,=0D - &Data,=0D - &SizeUsed=0D - );=0D - if (EFI_ERROR (Status)) {=0D - return Status;=0D - }=0D -=0D - //=0D - // We copy the name to a separately allocated buffer,=0D - // to be sure it is 16-bit aligned.=0D - //=0D - if (NameSize > AlignedNameMaxSize) {=0D - if (AlignedName !=3D NULL) {=0D - FreePool (AlignedName);=0D - }=0D - AlignedName =3D AllocatePool (NameSize);=0D - }=0D - if (AlignedName =3D=3D NULL) {=0D - return EFI_OUT_OF_RESOURCES;=0D - }=0D - CopyMem (AlignedName, Name, NameSize);=0D -=0D - TotalSizeUsed =3D TotalSizeUsed + SizeUsed;=0D -=0D - //=0D - // Run the callback function=0D - //=0D - Status =3D (*CallbackFunction) (=0D - CallbackContext,=0D - AlignedName,=0D - Guid,=0D - Attributes,=0D - DataSize,=0D - Data=0D - );=0D -=0D - }=0D -=0D - if (AlignedName !=3D NULL) {=0D - FreePool (AlignedName);=0D - }=0D -=0D - //=0D - // Make sure the entire buffer was used, or else return an error=0D - //=0D - if (TotalSizeUsed !=3D MaxSize) {=0D - DEBUG ((=0D - EFI_D_ERROR,=0D - "Deserialize variables error: TotalSizeUsed(%Lu) !=3D MaxSize(%Lu)\n= ",=0D - (UINT64)TotalSizeUsed,=0D - (UINT64)MaxSize=0D - ));=0D - return EFI_INVALID_PARAMETER;=0D - }=0D -=0D - return EFI_SUCCESS;=0D -}=0D -=0D -=0D -STATIC=0D -RETURN_STATUS=0D -EFIAPI=0D -IterateVariablesCallbackNop (=0D - IN VOID *Context,=0D - IN CHAR16 *VariableName,=0D - IN EFI_GUID *VendorGuid,=0D - IN UINT32 Attributes,=0D - IN UINTN DataSize,=0D - IN VOID *Data=0D - )=0D -{=0D - return RETURN_SUCCESS;=0D -}=0D -=0D -=0D -STATIC=0D -RETURN_STATUS=0D -EFIAPI=0D -IterateVariablesCallbackSetInInstance (=0D - IN VOID *Context,=0D - IN CHAR16 *VariableName,=0D - IN EFI_GUID *VendorGuid,=0D - IN UINT32 Attributes,=0D - IN UINTN DataSize,=0D - IN VOID *Data=0D - )=0D -{=0D - EFI_HANDLE Instance;=0D -=0D - Instance =3D (EFI_HANDLE) Context;=0D -=0D - return SerializeVariablesAddVariable (=0D - Instance,=0D - VariableName,=0D - VendorGuid,=0D - Attributes,=0D - DataSize,=0D - Data=0D - );=0D -}=0D -=0D -=0D -STATIC=0D -RETURN_STATUS=0D -EFIAPI=0D -IterateVariablesCallbackSetSystemVariable (=0D - IN VOID *Context,=0D - IN CHAR16 *VariableName,=0D - IN EFI_GUID *VendorGuid,=0D - IN UINT32 Attributes,=0D - IN UINTN DataSize,=0D - IN VOID *Data=0D - )=0D -{=0D - EFI_STATUS Status;=0D - STATIC CONST UINT32 AuthMask =3D=0D - EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS |=0D - EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS= ;=0D -=0D - Status =3D gRT->SetVariable (=0D - VariableName,=0D - VendorGuid,=0D - Attributes,=0D - DataSize,=0D - Data=0D - );=0D -=0D - if (Status =3D=3D EFI_SECURITY_VIOLATION && (Attributes & AuthMask) !=3D= 0) {=0D - DEBUG ((DEBUG_WARN, "%a: setting authenticated variable \"%s\" "=0D - "failed with EFI_SECURITY_VIOLATION, ignoring\n", __FUNCTION__= ,=0D - VariableName));=0D - Status =3D EFI_SUCCESS;=0D - } else if (Status =3D=3D EFI_WRITE_PROTECTED) {=0D - DEBUG ((DEBUG_WARN, "%a: setting ReadOnly variable \"%s\" "=0D - "failed with EFI_WRITE_PROTECTED, ignoring\n", __FUNCTION__,=0D - VariableName));=0D - Status =3D EFI_SUCCESS;=0D - }=0D - return Status;=0D -}=0D -=0D -=0D -STATIC=0D -RETURN_STATUS=0D -EnsureExtraBufferSpace (=0D - IN SV_INSTANCE *Instance,=0D - IN UINTN Size=0D - )=0D -{=0D - VOID *NewBuffer;=0D - UINTN NewSize;=0D -=0D - NewSize =3D Instance->DataSize + Size;=0D - if (NewSize <=3D Instance->BufferSize) {=0D - return RETURN_SUCCESS;=0D - }=0D -=0D - //=0D - // Double the required size to lessen the need to re-allocate in the fut= ure=0D - //=0D - NewSize =3D 2 * NewSize;=0D -=0D - NewBuffer =3D AllocatePool (NewSize);=0D - if (NewBuffer =3D=3D NULL) {=0D - return RETURN_OUT_OF_RESOURCES;=0D - }=0D -=0D - if (Instance->BufferPtr !=3D NULL) {=0D - CopyMem (NewBuffer, Instance->BufferPtr, Instance->DataSize);=0D - FreePool (Instance->BufferPtr);=0D - }=0D -=0D - Instance->BufferPtr =3D NewBuffer;=0D - Instance->BufferSize =3D NewSize;=0D -=0D - return RETURN_SUCCESS;=0D -}=0D -=0D -=0D -STATIC=0D -VOID=0D -AppendToBuffer (=0D - IN SV_INSTANCE *Instance,=0D - IN VOID *Data,=0D - IN UINTN Size=0D - )=0D -{=0D - UINTN NewSize;=0D -=0D - ASSERT (Instance !=3D NULL);=0D - ASSERT (Data !=3D NULL);=0D -=0D - NewSize =3D Instance->DataSize + Size;=0D - ASSERT ((Instance->DataSize + Size) <=3D Instance->BufferSize);=0D -=0D - CopyMem (=0D - (VOID*) (((UINT8*) (Instance->BufferPtr)) + Instance->DataSize),=0D - Data,=0D - Size=0D - );=0D -=0D - Instance->DataSize =3D NewSize;=0D -}=0D -=0D -=0D -/**=0D - Creates a new variable serialization instance=0D -=0D - @param[out] Handle - Handle for a variable serialization instance=0D -=0D - @retval RETURN_SUCCESS - The variable serialization instance was=0D - successfully created.=0D - @retval RETURN_OUT_OF_RESOURCES - There we not enough resources to= =0D - create the variable serialization instance.=0D -=0D -**/=0D -RETURN_STATUS=0D -EFIAPI=0D -SerializeVariablesNewInstance (=0D - OUT EFI_HANDLE *Handle=0D - )=0D -{=0D - SV_INSTANCE *New;=0D -=0D - New =3D AllocateZeroPool (sizeof (*New));=0D - if (New =3D=3D NULL) {=0D - return RETURN_OUT_OF_RESOURCES;=0D - }=0D -=0D - New->Signature =3D SV_SIGNATURE;=0D -=0D - *Handle =3D (EFI_HANDLE) New;=0D - return RETURN_SUCCESS;=0D -}=0D -=0D -=0D -/**=0D - Free memory associated with a variable serialization instance=0D -=0D - @param[in] Handle - Handle for a variable serialization instance=0D -=0D - @retval RETURN_SUCCESS - The variable serialization instance was=0D - successfully freed.=0D - @retval RETURN_INVALID_PARAMETER - Handle was not a valid=0D - variable serialization instance.=0D -=0D -**/=0D -RETURN_STATUS=0D -EFIAPI=0D -SerializeVariablesFreeInstance (=0D - IN EFI_HANDLE Handle=0D - )=0D -{=0D - SV_INSTANCE *Instance;=0D -=0D - Instance =3D SV_FROM_HANDLE (Handle);=0D -=0D - if (Instance->Signature !=3D SV_SIGNATURE) {=0D - return RETURN_INVALID_PARAMETER;=0D - }=0D -=0D - Instance->Signature =3D 0;=0D -=0D - if (Instance->BufferPtr !=3D NULL) {=0D - FreePool (Instance->BufferPtr);=0D - }=0D -=0D - FreePool (Instance);=0D -=0D - return RETURN_SUCCESS;=0D -}=0D -=0D -=0D -/**=0D - Creates a new variable serialization instance using the given=0D - binary representation of the variables to fill the new instance=0D -=0D - @param[out] Handle - Handle for a variable serialization instance=0D - @param[in] Buffer - A buffer with the serialized representation=0D - of the variables. Must be the same format as produced=0D - by SerializeVariablesToBuffer.=0D - @param[in] Size - This is the size of the binary representation=0D - of the variables.=0D -=0D - @retval RETURN_SUCCESS - The binary representation was successfully= =0D - imported into a new variable serialization instance=0D - @retval RETURN_OUT_OF_RESOURCES - There we not enough resources to= =0D - create the new variable serialization instance=0D -=0D -**/=0D -RETURN_STATUS=0D -EFIAPI=0D -SerializeVariablesNewInstanceFromBuffer (=0D - OUT EFI_HANDLE *Handle,=0D - IN VOID *Buffer,=0D - IN UINTN Size=0D - )=0D -{=0D - RETURN_STATUS Status;=0D -=0D - Status =3D SerializeVariablesNewInstance (Handle);=0D - if (RETURN_ERROR (Status)) {=0D - return Status;=0D - }=0D -=0D - Status =3D IterateVariablesInBuffer (=0D - IterateVariablesCallbackNop,=0D - NULL,=0D - Buffer,=0D - Size=0D - );=0D - if (RETURN_ERROR (Status)) {=0D - SerializeVariablesFreeInstance (*Handle);=0D - return Status;=0D - }=0D -=0D - Status =3D IterateVariablesInBuffer (=0D - IterateVariablesCallbackSetInInstance,=0D - (VOID*) *Handle,=0D - Buffer,=0D - Size=0D - );=0D - if (RETURN_ERROR (Status)) {=0D - SerializeVariablesFreeInstance (*Handle);=0D - return Status;=0D - }=0D -=0D - return Status;=0D -}=0D -=0D -=0D -/**=0D - Iterates all variables found with RuntimeServices GetNextVariableName=0D -=0D - @param[in] CallbackFunction - Function called for each variable instan= ce=0D - @param[in] Context - Passed to each call of CallbackFunction=0D -=0D - @retval RETURN_SUCCESS - All variables were iterated without the=0D - CallbackFunction returning an error=0D - @retval RETURN_OUT_OF_RESOURCES - There we not enough resources to= =0D - iterate through the variables=0D - @return Any of RETURN_ERROR indicates an error reading the variable= =0D - or an error was returned from CallbackFunction=0D -=0D -**/=0D -RETURN_STATUS=0D -EFIAPI=0D -SerializeVariablesIterateSystemVariables (=0D - IN VARIABLE_SERIALIZATION_ITERATION_CALLBACK CallbackFunction,=0D - IN VOID *Context=0D - )=0D -{=0D - RETURN_STATUS Status;=0D - UINTN VariableNameBufferSize;=0D - UINTN VariableNameSize;=0D - CHAR16 *VariableName;=0D - EFI_GUID VendorGuid;=0D - UINTN VariableDataBufferSize;=0D - UINTN VariableDataSize;=0D - VOID *VariableData;=0D - UINT32 VariableAttributes;=0D - VOID *NewBuffer;=0D -=0D - //=0D - // Initialize the variable name and data buffer variables.=0D - //=0D - VariableNameBufferSize =3D sizeof (CHAR16);=0D - VariableName =3D AllocateZeroPool (VariableNameBufferSize);=0D -=0D - VariableDataBufferSize =3D 0;=0D - VariableData =3D NULL;=0D -=0D - for (;;) {=0D - //=0D - // Get the next variable name and guid=0D - //=0D - VariableNameSize =3D VariableNameBufferSize;=0D - Status =3D gRT->GetNextVariableName (=0D - &VariableNameSize,=0D - VariableName,=0D - &VendorGuid=0D - );=0D - if (Status =3D=3D EFI_BUFFER_TOO_SMALL) {=0D - //=0D - // The currently allocated VariableName buffer is too small,=0D - // so we allocate a larger buffer, and copy the old buffer=0D - // to it.=0D - //=0D - NewBuffer =3D AllocatePool (VariableNameSize);=0D - if (NewBuffer =3D=3D NULL) {=0D - Status =3D EFI_OUT_OF_RESOURCES;=0D - break;=0D - }=0D - CopyMem (NewBuffer, VariableName, VariableNameBufferSize);=0D - if (VariableName !=3D NULL) {=0D - FreePool (VariableName);=0D - }=0D - VariableName =3D NewBuffer;=0D - VariableNameBufferSize =3D VariableNameSize;=0D -=0D - //=0D - // Try to get the next variable name again with the larger buffer.=0D - //=0D - Status =3D gRT->GetNextVariableName (=0D - &VariableNameSize,=0D - VariableName,=0D - &VendorGuid=0D - );=0D - }=0D -=0D - if (EFI_ERROR (Status)) {=0D - if (Status =3D=3D EFI_NOT_FOUND) {=0D - Status =3D EFI_SUCCESS;=0D - }=0D - break;=0D - }=0D -=0D - //=0D - // Get the variable data and attributes=0D - //=0D - VariableDataSize =3D VariableDataBufferSize;=0D - Status =3D gRT->GetVariable (=0D - VariableName,=0D - &VendorGuid,=0D - &VariableAttributes,=0D - &VariableDataSize,=0D - VariableData=0D - );=0D - if (Status =3D=3D EFI_BUFFER_TOO_SMALL) {=0D - //=0D - // The currently allocated VariableData buffer is too small,=0D - // so we allocate a larger buffer.=0D - //=0D - if (VariableDataBufferSize !=3D 0) {=0D - FreePool (VariableData);=0D - VariableData =3D NULL;=0D - VariableDataBufferSize =3D 0;=0D - }=0D - VariableData =3D AllocatePool (VariableDataSize);=0D - if (VariableData =3D=3D NULL) {=0D - Status =3D EFI_OUT_OF_RESOURCES;=0D - break;=0D - }=0D - VariableDataBufferSize =3D VariableDataSize;=0D -=0D - //=0D - // Try to read the variable again with the larger buffer.=0D - //=0D - Status =3D gRT->GetVariable (=0D - VariableName,=0D - &VendorGuid,=0D - &VariableAttributes,=0D - &VariableDataSize,=0D - VariableData=0D - );=0D - }=0D - if (EFI_ERROR (Status)) {=0D - break;=0D - }=0D -=0D - //=0D - // Run the callback function=0D - //=0D - Status =3D (*CallbackFunction) (=0D - Context,=0D - VariableName,=0D - &VendorGuid,=0D - VariableAttributes,=0D - VariableDataSize,=0D - VariableData=0D - );=0D - if (EFI_ERROR (Status)) {=0D - break;=0D - }=0D -=0D - }=0D -=0D - if (VariableName !=3D NULL) {=0D - FreePool (VariableName);=0D - }=0D -=0D - if (VariableData !=3D NULL) {=0D - FreePool (VariableData);=0D - }=0D -=0D - return Status;=0D -}=0D -=0D -=0D -/**=0D - Iterates all variables found in the variable serialization instance=0D -=0D - @param[in] Handle - Handle for a variable serialization instance=0D - @param[in] CallbackFunction - Function called for each variable instan= ce=0D - @param[in] Context - Passed to each call of CallbackFunction=0D -=0D - @retval RETURN_SUCCESS - All variables were iterated without the=0D - CallbackFunction returning an error=0D - @retval RETURN_OUT_OF_RESOURCES - There we not enough resources to= =0D - iterate through the variables=0D - @return Any of RETURN_ERROR indicates an error reading the variable= =0D - or an error was returned from CallbackFunction=0D -=0D -**/=0D -RETURN_STATUS=0D -EFIAPI=0D -SerializeVariablesIterateInstanceVariables (=0D - IN EFI_HANDLE Handle,=0D - IN VARIABLE_SERIALIZATION_ITERATION_CALLBACK CallbackFunction,=0D - IN VOID *Context=0D - )=0D -{=0D - SV_INSTANCE *Instance;=0D -=0D - Instance =3D SV_FROM_HANDLE (Handle);=0D -=0D - if ((Instance->BufferPtr !=3D NULL) && (Instance->DataSize !=3D 0)) {=0D - return IterateVariablesInBuffer (=0D - CallbackFunction,=0D - Context,=0D - Instance->BufferPtr,=0D - Instance->DataSize=0D - );=0D - } else {=0D - return RETURN_SUCCESS;=0D - }=0D -}=0D -=0D -=0D -/**=0D - Sets all variables found in the variable serialization instance=0D -=0D - @param[in] Handle - Handle for a variable serialization instance=0D -=0D - @retval RETURN_SUCCESS - All variables were set successfully=0D - @retval RETURN_OUT_OF_RESOURCES - There we not enough resources to= =0D - set all the variables=0D - @return Any of RETURN_ERROR indicates an error reading the variable= s=0D - or in attempting to set a variable=0D -=0D -**/=0D -RETURN_STATUS=0D -EFIAPI=0D -SerializeVariablesSetSerializedVariables (=0D - IN EFI_HANDLE Handle=0D - )=0D -{=0D - return SerializeVariablesIterateInstanceVariables (=0D - Handle,=0D - IterateVariablesCallbackSetSystemVariable,=0D - NULL=0D - );=0D -}=0D -=0D -=0D -/**=0D - Adds a variable to the variable serialization instance=0D -=0D - @param[in] Handle - Handle for a variable serialization instance=0D - @param[in] VariableName - Refer to RuntimeServices GetVariable=0D - @param[in] VendorGuid - Refer to RuntimeServices GetVariable=0D - @param[in] Attributes - Refer to RuntimeServices GetVariable=0D - @param[in] DataSize - Refer to RuntimeServices GetVariable=0D - @param[in] Data - Refer to RuntimeServices GetVariable=0D -=0D - @retval RETURN_SUCCESS - All variables were set successfully=0D - @retval RETURN_OUT_OF_RESOURCES - There we not enough resources to= =0D - add the variable=0D - @retval RETURN_INVALID_PARAMETER - Handle was not a valid=0D - variable serialization instance or=0D - VariableName, VariableGuid or Data are NULL.=0D -=0D -**/=0D -RETURN_STATUS=0D -EFIAPI=0D -SerializeVariablesAddVariable (=0D - IN EFI_HANDLE Handle,=0D - IN CHAR16 *VariableName,=0D - IN EFI_GUID *VendorGuid,=0D - IN UINT32 Attributes,=0D - IN UINTN DataSize,=0D - IN VOID *Data=0D - )=0D -{=0D - RETURN_STATUS Status;=0D - SV_INSTANCE *Instance;=0D - UINT32 SerializedNameSize;=0D - UINT32 SerializedDataSize;=0D - UINTN SerializedSize;=0D -=0D - Instance =3D SV_FROM_HANDLE (Handle);=0D -=0D - if ((Instance->Signature !=3D SV_SIGNATURE) ||=0D - (VariableName =3D=3D NULL) || (VendorGuid =3D=3D NULL) || (Data =3D= =3D NULL)) {=0D - }=0D -=0D - SerializedNameSize =3D (UINT32) StrSize (VariableName);=0D -=0D - SerializedSize =3D=0D - sizeof (SerializedNameSize) +=0D - SerializedNameSize +=0D - sizeof (*VendorGuid) +=0D - sizeof (Attributes) +=0D - sizeof (SerializedDataSize) +=0D - DataSize;=0D -=0D - Status =3D EnsureExtraBufferSpace (=0D - Instance,=0D - SerializedSize=0D - );=0D - if (RETURN_ERROR (Status)) {=0D - return Status;=0D - }=0D -=0D - //=0D - // Add name size (UINT32)=0D - //=0D - AppendToBuffer (Instance, (VOID*) &SerializedNameSize, sizeof (Serialize= dNameSize));=0D -=0D - //=0D - // Add variable unicode name string=0D - //=0D - AppendToBuffer (Instance, (VOID*) VariableName, SerializedNameSize);=0D -=0D - //=0D - // Add variable GUID=0D - //=0D - AppendToBuffer (Instance, (VOID*) VendorGuid, sizeof (*VendorGuid));=0D -=0D - //=0D - // Add variable attributes=0D - //=0D - AppendToBuffer (Instance, (VOID*) &Attributes, sizeof (Attributes));=0D -=0D - //=0D - // Add variable data size (UINT32)=0D - //=0D - SerializedDataSize =3D (UINT32) DataSize;=0D - AppendToBuffer (Instance, (VOID*) &SerializedDataSize, sizeof (Serialize= dDataSize));=0D -=0D - //=0D - // Add variable data=0D - //=0D - AppendToBuffer (Instance, Data, DataSize);=0D -=0D - return RETURN_SUCCESS;=0D -}=0D -=0D -=0D -/**=0D - Serializes the variables known to this instance into the=0D - provided buffer.=0D -=0D - @param[in] Handle - Handle for a variable serialization instance=0D - @param[out] Buffer - A buffer to store the binary representation=0D - of the variables.=0D - @param[in,out] Size - On input this is the size of the buffer.=0D - On output this is the size of the binary representation= =0D - of the variables.=0D -=0D - @retval RETURN_SUCCESS - The binary representation was successfully= =0D - completed and returned in the buffer.=0D - @retval RETURN_OUT_OF_RESOURCES - There we not enough resources to= =0D - save the variables to the buffer.=0D - @retval RETURN_INVALID_PARAMETER - Handle was not a valid=0D - variable serialization instance or=0D - Size or Buffer were NULL.=0D - @retval RETURN_BUFFER_TOO_SMALL - The Buffer size as indicated by=0D - the Size parameter was too small for the serialized=0D - variable data. Size is returned with the required size.= =0D -=0D -**/=0D -RETURN_STATUS=0D -EFIAPI=0D -SerializeVariablesToBuffer (=0D - IN EFI_HANDLE Handle,=0D - OUT VOID *Buffer,=0D - IN OUT UINTN *Size=0D - )=0D -{=0D - SV_INSTANCE *Instance;=0D -=0D - Instance =3D SV_FROM_HANDLE (Handle);=0D -=0D - if (Size =3D=3D NULL) {=0D - return RETURN_INVALID_PARAMETER;=0D - }=0D -=0D - if (*Size < Instance->DataSize) {=0D - *Size =3D Instance->DataSize;=0D - return RETURN_BUFFER_TOO_SMALL;=0D - }=0D -=0D - if (Buffer =3D=3D NULL) {=0D - return RETURN_INVALID_PARAMETER;=0D - }=0D -=0D - *Size =3D Instance->DataSize;=0D - CopyMem (Buffer, Instance->BufferPtr, Instance->DataSize);=0D -=0D - return RETURN_SUCCESS;=0D -}=0D -=0D diff --git a/Platform/Intel/SimicsOpenBoardPkg/Library/SerializeVariablesLi= b/SerializeVariablesLib.h b/Platform/Intel/SimicsOpenBoardPkg/Library/Seria= lizeVariablesLib/SerializeVariablesLib.h deleted file mode 100644 index 9b4c2a629a..0000000000 --- a/Platform/Intel/SimicsOpenBoardPkg/Library/SerializeVariablesLib/Seria= lizeVariablesLib.h +++ /dev/null @@ -1,33 +0,0 @@ -/** @file=0D - Serialize Variables Library implementation=0D -=0D - Copyright (c) 2009 - 2019 Intel Corporation. All rights reserved.
=0D -=0D - SPDX-License-Identifier: BSD-2-Clause-Patent=0D -**/=0D -=0D -#ifndef __SERIALIZE_VARIABLES_LIB_INSTANCE__=0D -#define __SERIALIZE_VARIABLES_LIB_INSTANCE__=0D -=0D -#include =0D -=0D -#include =0D -#include =0D -#include =0D -#include =0D -#include =0D -#include =0D -#include =0D -=0D -#define SV_FROM_HANDLE(a) CR (a, SV_INSTANCE, Signature, SV_SIGNATUR= E)=0D -#define SV_SIGNATURE SIGNATURE_32 ('S', 'V', 'A', 'R')=0D -=0D -typedef struct {=0D - UINT32 Signature;=0D - VOID *BufferPtr;=0D - UINTN BufferSize;=0D - UINTN DataSize;=0D -} SV_INSTANCE;=0D -=0D -#endif=0D -=0D diff --git a/Platform/Intel/SimicsOpenBoardPkg/Library/SerializeVariablesLi= b/SerializeVariablesLib.inf b/Platform/Intel/SimicsOpenBoardPkg/Library/Ser= ializeVariablesLib/SerializeVariablesLib.inf deleted file mode 100644 index 08c561f586..0000000000 --- a/Platform/Intel/SimicsOpenBoardPkg/Library/SerializeVariablesLib/Seria= lizeVariablesLib.inf +++ /dev/null @@ -1,36 +0,0 @@ -## @file=0D -# Serialize Variables Library implementation=0D -#=0D -# This library serializes and deserializes UEFI variables=0D -#=0D -# Copyright (c) 2006 - 2019 Intel Corporation. All rights reserved.
=0D -#=0D -# SPDX-License-Identifier: BSD-2-Clause-Patent=0D -#=0D -##=0D -=0D -[Defines]=0D - INF_VERSION =3D 0x00010005=0D - BASE_NAME =3D DxeSerializeVariablesLib=0D - FILE_GUID =3D 266A1434-6B22-441F-A8D2-D54AA8FDF95C= =0D - MODULE_TYPE =3D UEFI_DRIVER=0D - VERSION_STRING =3D 1.0=0D - LIBRARY_CLASS =3D SerializeVariablesLib|DXE_DRIVER DXE_= RUNTIME_DRIVER UEFI_DRIVER=0D -=0D -[Sources]=0D - SerializeVariablesLib.c=0D -=0D -[Packages]=0D - MdePkg/MdePkg.dec=0D - MdeModulePkg/MdeModulePkg.dec=0D - ShellPkg/ShellPkg.dec=0D - SimicsOpenBoardPkg/OpenBoardPkg.dec=0D -=0D -[LibraryClasses]=0D - BaseLib=0D - BaseMemoryLib=0D - DebugLib=0D - MemoryAllocationLib=0D - UefiBootServicesTableLib=0D - UefiRuntimeServicesTableLib=0D -=0D diff --git a/Platform/Intel/SimicsOpenBoardPkg/OpenBoardPkg.dec b/Platform/= Intel/SimicsOpenBoardPkg/OpenBoardPkg.dec index e8aefdd893..c4e24f1e0c 100644 --- a/Platform/Intel/SimicsOpenBoardPkg/OpenBoardPkg.dec +++ b/Platform/Intel/SimicsOpenBoardPkg/OpenBoardPkg.dec @@ -48,9 +48,6 @@ =0D [PcdsDynamic, PcdsDynamicEx]=0D =0D - # TODO: investigate whether next two Pcds are needed=0D - gSimicsOpenBoardPkgTokenSpaceGuid.PcdEmuVariableEvent|0|UINT64|0x28=0D - gSimicsOpenBoardPkgTokenSpaceGuid.PcdOvmfFlashVariablesEnable|FALSE|BOOL= EAN|0x10=0D gSimicsOpenBoardPkgTokenSpaceGuid.PcdSimicsX58HostBridgePciDevId|0|UINT1= 6|0x1b=0D =0D ## The IO port aperture shared by all PCI root bridges.=0D --=20 2.39.1.windows.1