2 Esrt management implementation head file.
4 Copyright (c) 2015 - 2018, Intel Corporation. All rights reserved.<BR>
5 SPDX-License-Identifier: BSD-2-Clause-Patent
9 #ifndef _DXE_ESRT_IMPL_H_
10 #define _DXE_ESRT_IMPL_H_
12 #include <Guid/EventGroup.h>
13 #include <Guid/SystemResourceTable.h>
15 #include <Library/UefiLib.h>
16 #include <Library/UefiRuntimeServicesTableLib.h>
17 #include <Library/UefiLib.h>
18 #include <Library/PcdLib.h>
19 #include <Library/BaseLib.h>
20 #include <Library/BaseMemoryLib.h>
21 #include <Library/MemoryAllocationLib.h>
22 #include <Library/UefiBootServicesTableLib.h>
23 #include <Library/DebugLib.h>
24 #include <Library/CapsuleLib.h>
26 #include <Protocol/FirmwareManagement.h>
27 #include <Protocol/EsrtManagement.h>
28 #include <Protocol/VariableLock.h>
31 // Name of Variable for Non-FMP ESRT Repository
33 #define EFI_ESRT_NONFMP_VARIABLE_NAME L"EsrtNonFmp"
36 // Name of Variable for FMP
38 #define EFI_ESRT_FMP_VARIABLE_NAME L"EsrtFmp"
41 // Attribute of Cached ESRT entry
43 #define ESRT_FROM_FMP 0x00000001
44 #define ESRT_FROM_NONFMP 0x00000002
49 // Ready to boot event
54 // Updates to Fmp storage must be locked.
59 // Update to Non-Fmp storage must be locked
65 Find Esrt Entry stored in ESRT repository.
67 @param[in] FwClass Firmware class guid in Esrt entry
68 @param[in] Attribute Esrt from Non FMP or FMP instance
69 @param[out] Entry Esrt entry returned
71 @retval EFI_SUCCESS Successfully find an Esrt entry
72 @retval EF_NOT_FOUND No Esrt entry found
79 OUT EFI_SYSTEM_RESOURCE_ENTRY
*Entry
83 Insert a new ESRT entry into ESRT Cache repository.
85 @param[in] Entry Esrt entry to be set
86 @param[in] Attribute Esrt from Esrt private protocol or FMP instance
88 @retval EFI_SUCCESS Successfully set a variable.
93 IN EFI_SYSTEM_RESOURCE_ENTRY
*Entry
,
98 Delete ESRT Entry from ESRT repository.
100 @param[in] FwClass FwClass of Esrt entry to delete
101 @param[in] Attribute Esrt from Esrt private protocol or FMP instance
103 @retval EFI_SUCCESS Insert all entries Successfully
104 @retval EFI_NOT_FOUND ESRT entry with FwClass doesn't exsit
109 IN EFI_GUID
*FwClass
,
114 Update one ESRT entry in ESRT repository
116 @param[in] Entry Esrt entry to be set
117 @param[in] Attribute Esrt from Non Esrt or FMP instance
119 @retval EFI_SUCCESS Successfully Update a variable.
120 @retval EFI_NOT_FOUND The Esrt enry doesn't exist
125 IN EFI_SYSTEM_RESOURCE_ENTRY
*Entry
,
130 Init one ESRT entry according to input FmpImageInfo (V1, V2, V3) .
132 @param[in, out] EsrtEntry Esrt entry to be Init
133 @param[in] FmpImageInfo FMP image info descriptor
134 @param[in] DescriptorVersion FMP Image info descriptor version
138 SetEsrtEntryFromFmpInfo (
139 IN OUT EFI_SYSTEM_RESOURCE_ENTRY
*EsrtEntry
,
140 IN EFI_FIRMWARE_IMAGE_DESCRIPTOR
*FmpImageInfo
,
141 IN UINT32 DescriptorVersion
145 Get ESRT entry from ESRT Cache by FwClass Guid
147 @param[in] FwClass FwClass of Esrt entry to get
148 @param[in, out] Entry Esrt entry returned
150 @retval EFI_SUCCESS The variable saving this Esrt Entry exists.
151 @retval EF_NOT_FOUND No correct variable found.
152 @retval EFI_WRITE_PROTECTED ESRT Cache repository is locked
157 EsrtDxeGetEsrtEntry (
158 IN EFI_GUID
*FwClass
,
159 IN OUT EFI_SYSTEM_RESOURCE_ENTRY
*Entry
163 Update one ESRT entry in ESRT Cache.
165 @param[in] Entry Esrt entry to be updated
167 @retval EFI_SUCCESS Successfully update an ESRT entry in cache.
168 @retval EFI_INVALID_PARAMETER Entry does't exist in ESRT Cache
169 @retval EFI_WRITE_PROTECTED ESRT Cache is locked
174 EsrtDxeUpdateEsrtEntry (
175 IN EFI_SYSTEM_RESOURCE_ENTRY
*Entry
179 Non-FMP instance to unregister Esrt Entry from ESRT Cache.
181 @param[in] FwClass FwClass of Esrt entry to Unregister
183 @retval EFI_SUCCESS Insert all entries Successfully
184 @retval EFI_NOT_FOUND Entry of FwClass does not exsit
189 EsrtDxeUnRegisterEsrtEntry (
194 Non-FMP instance to register one ESRT entry into ESRT Cache.
196 @param[in] Entry Esrt entry to be set
198 @retval EFI_SUCCESS Successfully set a variable.
199 @retval EFI_INVALID_PARAMETER ESRT Entry is already exist
203 EsrtDxeRegisterEsrtEntry (
204 IN EFI_SYSTEM_RESOURCE_ENTRY
*Entry
208 This function syn up Cached ESRT with data from FMP instances
209 Function should be called after Connect All in order to locate all FMP protocols
212 @retval EFI_SUCCESS Successfully sync cache repository from FMP instances
213 @retval EFI_NOT_FOUND No FMP Instance are found
214 @retval EFI_OUT_OF_RESOURCES Resource allocaton fail
224 This function locks up Esrt repository to be readonly. It should be called
225 before gEfiEndOfDxeEventGroupGuid event signaled
227 @retval EFI_SUCCESS Locks up FMP Non-FMP repository successfully
232 EsrtDxeLockEsrtRepository (
236 #endif // #ifndef _EFI_ESRT_IMPL_H_