1 /** @file 2 Esrt management implementation head file. 3 4 Copyright (c) 2015, Intel Corporation. All rights reserved.<BR> 5 This program and the accompanying materials 6 are licensed and made available under the terms and conditions of the BSD License 7 which accompanies this distribution. The full text of the license may be found at 8 http://opensource.org/licenses/bsd-license.php 9 10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, 11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. 12 13 **/ 14 15 #ifndef _DXE_ESRT_IMPL_H_ 16 #define _DXE_ESRT_IMPL_H_ 17 18 #include <Guid/EventGroup.h> 19 #include <Guid/SystemResourceTable.h> 20 21 #include <Library/UefiLib.h> 22 #include <Library/UefiRuntimeServicesTableLib.h> 23 #include <Library/UefiLib.h> 24 #include <Library/PcdLib.h> 25 #include <Library/BaseLib.h> 26 #include <Library/BaseMemoryLib.h> 27 #include <Library/MemoryAllocationLib.h> 28 #include <Library/UefiBootServicesTableLib.h> 29 #include <Library/DebugLib.h> 30 #include <Library/CapsuleLib.h> 31 #include <Library/PrintLib.h> 32 33 #include <Protocol/FirmwareManagement.h> 34 #include <Protocol/EsrtManagement.h> 35 #include <Protocol/VariableLock.h> 36 37 // 38 // Name of Variable for Non-FMP ESRT Repository 39 // 40 #define EFI_ESRT_NONFMP_VARIABLE_NAME L"EsrtNonFmp" 41 42 // 43 // Name of Variable for FMP 44 // 45 #define EFI_ESRT_FMP_VARIABLE_NAME L"EsrtFmp" 46 47 // 48 // Attribute of Cached ESRT entry 49 // 50 #define ESRT_FROM_FMP 0x00000001 51 #define ESRT_FROM_NONFMP 0x00000002 52 53 typedef struct { 54 EFI_HANDLE Handle; 55 // 56 // Ready to boot event 57 // 58 EFI_EVENT Event; 59 60 // 61 // Updates to Fmp storage must be locked. 62 // 63 EFI_LOCK FmpLock; 64 65 // 66 // Update to Non-Fmp storage must be locked 67 // 68 EFI_LOCK NonFmpLock; 69 } ESRT_PRIVATE_DATA; 70 71 72 /** 73 Find Esrt Entry stored in ESRT repository. 74 75 @param[in] FwClass Firmware class guid in Esrt entry 76 @param[in] Attribute Esrt from Non FMP or FMP instance 77 @param[out] Entry Esrt entry returned 78 79 @retval EFI_SUCCESS Successfully find an Esrt entry 80 @retval EF_NOT_FOUND No Esrt entry found 81 82 **/ 83 EFI_STATUS 84 GetEsrtEntry ( 85 IN EFI_GUID *FwClass, 86 IN UINTN Attribute, 87 OUT EFI_SYSTEM_RESOURCE_ENTRY *Entry 88 ); 89 90 /** 91 Insert a new ESRT entry into ESRT Cache repository. 92 93 @param[in] Entry Esrt entry to be set 94 @param[in] Attribute Esrt from Esrt private protocol or FMP instance 95 96 @retval EFI_SUCCESS Successfully set a variable. 97 98 **/ 99 EFI_STATUS 100 InsertEsrtEntry( 101 IN EFI_SYSTEM_RESOURCE_ENTRY *Entry, 102 UINTN Attribute 103 ); 104 105 /** 106 Delete ESRT Entry from ESRT repository. 107 108 @param[in] FwClass FwClass of Esrt entry to delete 109 @param[in] Attribute Esrt from Esrt private protocol or FMP instance 110 111 @retval EFI_SUCCESS Insert all entries Successfully 112 @retval EFI_NOT_FOUND ESRT entry with FwClass doesn't exsit 113 114 **/ 115 EFI_STATUS 116 DeleteEsrtEntry( 117 IN EFI_GUID *FwClass, 118 IN UINTN Attribute 119 ); 120 121 /** 122 Update one ESRT entry in ESRT repository 123 124 @param[in] Entry Esrt entry to be set 125 @param[in] Attribute Esrt from Non Esrt or FMP instance 126 127 @retval EFI_SUCCESS Successfully Update a variable. 128 @retval EFI_NOT_FOUND The Esrt enry doesn't exist 129 130 **/ 131 EFI_STATUS 132 UpdateEsrtEntry( 133 IN EFI_SYSTEM_RESOURCE_ENTRY *Entry, 134 UINTN Attribute 135 ); 136 137 /** 138 Init one ESRT entry according to input FmpImageInfo (V1, V2, V3) . 139 140 @param[in, out] EsrtEntry Esrt entry to be Init 141 @param[in] FmpImageInfo FMP image info descriptor 142 @param[in] DescriptorVersion FMP Image info descriptor version 143 144 **/ 145 VOID 146 SetEsrtEntryFromFmpInfo ( 147 IN OUT EFI_SYSTEM_RESOURCE_ENTRY *EsrtEntry, 148 IN EFI_FIRMWARE_IMAGE_DESCRIPTOR *FmpImageInfo, 149 IN UINT32 DescriptorVersion 150 ); 151 152 /** 153 Get ESRT entry from ESRT Cache by FwClass Guid 154 155 @param[in] FwClass FwClass of Esrt entry to get 156 @param[in, out] Entry Esrt entry returned 157 158 @retval EFI_SUCCESS The variable saving this Esrt Entry exists. 159 @retval EF_NOT_FOUND No correct variable found. 160 @retval EFI_WRITE_PROTECTED ESRT Cache repository is locked 161 162 **/ 163 EFI_STATUS 164 EFIAPI 165 EsrtDxeGetEsrtEntry( 166 IN EFI_GUID *FwClass, 167 IN OUT EFI_SYSTEM_RESOURCE_ENTRY *Entry 168 ); 169 170 /** 171 Update one ESRT entry in ESRT Cache. 172 173 @param[in] Entry Esrt entry to be updated 174 175 @retval EFI_SUCCESS Successfully update an ESRT entry in cache. 176 @retval EFI_INVALID_PARAMETER Entry does't exist in ESRT Cache 177 @retval EFI_WRITE_PROTECTED ESRT Cache is locked 178 179 **/ 180 EFI_STATUS 181 EFIAPI 182 EsrtDxeUpdateEsrtEntry( 183 IN EFI_SYSTEM_RESOURCE_ENTRY *Entry 184 ); 185 186 /** 187 Non-FMP instance to unregister Esrt Entry from ESRT Cache. 188 189 @param[in] FwClass FwClass of Esrt entry to Unregister 190 191 @retval EFI_SUCCESS Insert all entries Successfully 192 @retval EFI_NOT_FOUND Entry of FwClass does not exsit 193 194 **/ 195 EFI_STATUS 196 EFIAPI 197 EsrtDxeUnRegisterEsrtEntry( 198 IN EFI_GUID *FwClass 199 ); 200 201 /** 202 Non-FMP instance to register one ESRT entry into ESRT Cache. 203 204 @param[in] Entry Esrt entry to be set 205 206 @retval EFI_SUCCESS Successfully set a variable. 207 @retval EFI_INVALID_PARAMETER ESRT Entry is already exist 208 **/ 209 EFI_STATUS 210 EFIAPI 211 EsrtDxeRegisterEsrtEntry( 212 IN EFI_SYSTEM_RESOURCE_ENTRY *Entry 213 ); 214 215 /** 216 This function syn up Cached ESRT with data from FMP instances 217 Function should be called after Connect All in order to locate all FMP protocols 218 installed. 219 220 @retval EFI_SUCCESS Successfully sync cache repository from FMP instances 221 @retval EFI_NOT_FOUND No FMP Instance are found 222 @retval EFI_OUT_OF_RESOURCES Resource allocaton fail 223 224 **/ 225 EFI_STATUS 226 EFIAPI 227 EsrtDxeSyncFmp( 228 VOID 229 ); 230 231 /** 232 This function locks up Esrt repository to be readonly. It should be called 233 before gEfiEndOfDxeEventGroupGuid event signaled 234 235 @retval EFI_SUCCESS Locks up FMP Non-FMP repository successfully 236 237 **/ 238 EFI_STATUS 239 EFIAPI 240 EsrtDxeLockEsrtRepository( 241 VOID 242 ); 243 244 #endif // #ifndef _EFI_ESRT_IMPL_H_ 245 246