--- /dev/null
+/** @file\r
+ Esrt management implementation head file.\r
+\r
+Copyright (c) 2015, Intel Corporation. All rights reserved.<BR>\r
+This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution. The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+#ifndef _DXE_ESRT_IMPL_H_\r
+#define _DXE_ESRT_IMPL_H_\r
+\r
+#include <Guid/EventGroup.h>\r
+#include <Guid/SystemResourceTable.h>\r
+\r
+#include <Library/UefiLib.h>\r
+#include <Library/UefiRuntimeServicesTableLib.h>\r
+#include <Library/UefiLib.h>\r
+#include <Library/PcdLib.h>\r
+#include <Library/BaseLib.h>\r
+#include <Library/BaseMemoryLib.h>\r
+#include <Library/MemoryAllocationLib.h>\r
+#include <Library/UefiBootServicesTableLib.h>\r
+#include <Library/DebugLib.h>\r
+#include <Library/CapsuleLib.h>\r
+#include <Library/PrintLib.h>\r
+\r
+#include <Protocol/FirmwareManagement.h>\r
+#include <Protocol/EsrtManagement.h>\r
+#include <Protocol/VariableLock.h>\r
+\r
+//\r
+// Name of Variable for Non-FMP ESRT Repository\r
+// \r
+#define EFI_ESRT_NONFMP_VARIABLE_NAME L"EsrtNonFmp"\r
+\r
+//\r
+// Name of Variable for FMP\r
+// \r
+#define EFI_ESRT_FMP_VARIABLE_NAME L"EsrtFmp"\r
+\r
+//\r
+// Attribute of Cached ESRT entry\r
+//\r
+#define ESRT_FROM_FMP 0x00000001\r
+#define ESRT_FROM_NONFMP 0x00000002\r
+\r
+typedef struct {\r
+ EFI_HANDLE Handle;\r
+ //\r
+ // Ready to boot event\r
+ //\r
+ EFI_EVENT Event;\r
+ \r
+ //\r
+ // Updates to Fmp storage must be locked.\r
+ //\r
+ EFI_LOCK FmpLock;\r
+\r
+ //\r
+ // Update to Non-Fmp storage must be locked\r
+ //\r
+ EFI_LOCK NonFmpLock;\r
+} ESRT_PRIVATE_DATA;\r
+\r
+\r
+/**\r
+ Find Esrt Entry stored in ESRT repository. \r
+\r
+ @param[in] FwClass Firmware class guid in Esrt entry\r
+ @param[in] Attribute Esrt from Non FMP or FMP instance\r
+ @param[out] Entry Esrt entry returned\r
+ \r
+ @retval EFI_SUCCESS Successfully find an Esrt entry\r
+ @retval EF_NOT_FOUND No Esrt entry found\r
+\r
+**/\r
+EFI_STATUS\r
+GetEsrtEntry (\r
+ IN EFI_GUID *FwClass,\r
+ IN UINTN Attribute,\r
+ OUT EFI_SYSTEM_RESOURCE_ENTRY *Entry\r
+ );\r
+\r
+/**\r
+ Insert a new ESRT entry into ESRT Cache repository.\r
+\r
+ @param[in] Entry Esrt entry to be set\r
+ @param[in] Attribute Esrt from Esrt private protocol or FMP instance\r
+ \r
+ @retval EFI_SUCCESS Successfully set a variable.\r
+\r
+**/\r
+EFI_STATUS\r
+InsertEsrtEntry(\r
+ IN EFI_SYSTEM_RESOURCE_ENTRY *Entry,\r
+ UINTN Attribute\r
+ );\r
+\r
+/**\r
+ Delete ESRT Entry from ESRT repository. \r
+\r
+ @param[in] FwClass FwClass of Esrt entry to delete \r
+ @param[in] Attribute Esrt from Esrt private protocol or FMP instance\r
+ \r
+ @retval EFI_SUCCESS Insert all entries Successfully \r
+ @retval EFI_NOT_FOUND ESRT entry with FwClass doesn't exsit\r
+ \r
+**/\r
+EFI_STATUS\r
+DeleteEsrtEntry(\r
+ IN EFI_GUID *FwClass,\r
+ IN UINTN Attribute\r
+ );\r
+\r
+/**\r
+ Update one ESRT entry in ESRT repository\r
+\r
+ @param[in] Entry Esrt entry to be set\r
+ @param[in] Attribute Esrt from Non Esrt or FMP instance\r
+ \r
+ @retval EFI_SUCCESS Successfully Update a variable.\r
+ @retval EFI_NOT_FOUND The Esrt enry doesn't exist\r
+\r
+**/\r
+EFI_STATUS\r
+UpdateEsrtEntry(\r
+ IN EFI_SYSTEM_RESOURCE_ENTRY *Entry,\r
+ UINTN Attribute\r
+ );\r
+\r
+/**\r
+ Init one ESRT entry according to input FmpImageInfo (V1, V2, V3) .\r
+\r
+ @param[in] EsrtEntry Esrt entry to be Init\r
+ @param[in] FmpImageInfo FMP image info descriptor\r
+ @param[in] DescriptorVersion FMP Image info descriptor version\r
+ \r
+**/\r
+VOID \r
+SetEsrtEntryFromFmpInfo (\r
+ IN OUT EFI_SYSTEM_RESOURCE_ENTRY *EsrtEntry,\r
+ IN EFI_FIRMWARE_IMAGE_DESCRIPTOR *FmpImageInfo,\r
+ IN UINT32 DescriptorVersion\r
+ );\r
+\r
+/**\r
+ Get ESRT entry from ESRT Cache by FwClass Guid \r
+\r
+ @param[in] FwClass FwClass of Esrt entry to get \r
+ @param[in out] Entry Esrt entry returned \r
+ \r
+ @retval EFI_SUCCESS The variable saving this Esrt Entry exists.\r
+ @retval EF_NOT_FOUND No correct variable found.\r
+ @retval EFI_WRITE_PROTECTED ESRT Cache repository is locked\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EsrtDxeGetEsrtEntry(\r
+ IN EFI_GUID *FwClass,\r
+ IN OUT EFI_SYSTEM_RESOURCE_ENTRY *Entry\r
+ );\r
+\r
+/**\r
+ Update one ESRT entry in ESRT Cache.\r
+\r
+ @param[in] Entry Esrt entry to be updated\r
+ \r
+ @retval EFI_SUCCESS Successfully update an ESRT entry in cache.\r
+ @retval EFI_INVALID_PARAMETER Entry does't exist in ESRT Cache\r
+ @retval EFI_WRITE_PROTECTED ESRT Cache is locked\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EsrtDxeUpdateEsrtEntry(\r
+ IN EFI_SYSTEM_RESOURCE_ENTRY *Entry\r
+ );\r
+\r
+/**\r
+ Non-FMP instance to unregister Esrt Entry from ESRT Cache. \r
+\r
+ @param[in] FwClass FwClass of Esrt entry to Unregister \r
+ \r
+ @retval EFI_SUCCESS Insert all entries Successfully \r
+ @retval EFI_NOT_FOUND Entry of FwClass does not exsit\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EsrtDxeUnRegisterEsrtEntry(\r
+ IN EFI_GUID *FwClass\r
+ );\r
+\r
+/**\r
+ Non-FMP instance to register one ESRT entry into ESRT Cache.\r
+\r
+ @param[in] Entry Esrt entry to be set\r
+\r
+ @retval EFI_SUCCESS Successfully set a variable.\r
+ @retval EFI_INVALID_PARAMETER ESRT Entry is already exist\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EsrtDxeRegisterEsrtEntry(\r
+ IN EFI_SYSTEM_RESOURCE_ENTRY *Entry\r
+ );\r
+\r
+/**\r
+ This function syn up Cached ESRT with data from FMP instances\r
+ Function should be called after Connect All in order to locate all FMP protocols\r
+ installed\r
+\r
+ @retval EFI_SUCCESS Successfully sync cache repository from FMP instances\r
+ @retval EFI_NOT_FOUND No FMP Instance are found\r
+ @retval EFI_OUT_OF_RESOURCES Resource allocaton fail\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EsrtDxeSyncFmp(\r
+ VOID\r
+ );\r
+\r
+/**\r
+ This function locks up Esrt repository to be readonly. It should be called \r
+ before gEfiEndOfDxeEventGroupGuid event signaled\r
+\r
+ @retval EFI_SUCCESS Locks up FMP Non-FMP repository successfully \r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EsrtDxeLockEsrtRepository(\r
+ VOID\r
+ );\r
+\r
+#endif // #ifndef _EFI_ESRT_IMPL_H_\r
+\r