36 EsrtRepository =
NULL;
41 if (Attribute == ESRT_FROM_FMP) {
42 VariableName = EFI_ESRT_FMP_VARIABLE_NAME;
44 VariableName = EFI_ESRT_NONFMP_VARIABLE_NAME;
50 (VOID **)&EsrtRepository,
54 if (EFI_ERROR (Status)) {
59 DEBUG ((DEBUG_ERROR,
"Repository Corrupt. Need to rebuild Repository.\n"));
64 Status = EFI_NOT_FOUND;
66 for (Index = 0; Index < EsrtNum; Index++) {
67 if (
CompareGuid (FwClass, &EsrtRepository[Index].FwClass)) {
75 if (EsrtRepository !=
NULL) {
100 UINTN RepositorySize;
103 EsrtRepository =
NULL;
104 EsrtRepositoryNew =
NULL;
109 if (Attribute == ESRT_FROM_FMP) {
110 VariableName = EFI_ESRT_FMP_VARIABLE_NAME;
112 VariableName = EFI_ESRT_NONFMP_VARIABLE_NAME;
118 (VOID **)&EsrtRepository,
122 if (Status == EFI_NOT_FOUND) {
126 Status =
gRT->SetVariable (
139 DEBUG ((DEBUG_ERROR,
"Repository Corrupt. Need to rebuild Repository.\n"));
143 Status =
gRT->SetVariable (
152 EsrtRepository =
NULL;
161 Status = EFI_OUT_OF_RESOURCES;
166 if (EsrtRepositoryNew ==
NULL) {
167 Status = EFI_OUT_OF_RESOURCES;
171 if ((RepositorySize != 0) && (EsrtRepository !=
NULL)) {
172 CopyMem (EsrtRepositoryNew, EsrtRepository, RepositorySize);
177 Status =
gRT->SetVariable (
187 if (EsrtRepository !=
NULL) {
191 if (EsrtRepositoryNew !=
NULL) {
215 CHAR16 *VariableName;
217 UINTN RepositorySize;
221 EsrtRepository =
NULL;
226 if (Attribute == ESRT_FROM_FMP) {
227 VariableName = EFI_ESRT_FMP_VARIABLE_NAME;
229 VariableName = EFI_ESRT_NONFMP_VARIABLE_NAME;
235 (VOID **)&EsrtRepository,
239 if (EFI_ERROR (Status)) {
243 if (EsrtRepository ==
NULL) {
244 Status = EFI_OUT_OF_RESOURCES;
249 DEBUG ((DEBUG_ERROR,
"Repository Corrupt. Need to rebuild Repository.\n"));
253 Status =
gRT->SetVariable (
263 Status = EFI_NOT_FOUND;
265 for (Index = 0; Index < EsrtNum; Index++) {
269 if (
CompareGuid (FwClass, &EsrtRepository[Index].FwClass)) {
273 if (Index < EsrtNum - 1) {
280 Status =
gRT->SetVariable (
292 if (EsrtRepository !=
NULL) {
316 CHAR16 *VariableName;
318 UINTN RepositorySize;
322 EsrtRepository =
NULL;
327 if (Attribute == ESRT_FROM_FMP) {
328 VariableName = EFI_ESRT_FMP_VARIABLE_NAME;
330 VariableName = EFI_ESRT_NONFMP_VARIABLE_NAME;
336 (VOID **)&EsrtRepository,
340 if (EsrtRepository ==
NULL) {
341 Status = EFI_OUT_OF_RESOURCES;
345 if (!EFI_ERROR (Status)) {
350 DEBUG ((DEBUG_ERROR,
"Repository Corrupt. Need to rebuild Repository.\n"));
354 Status =
gRT->SetVariable (
361 Status = EFI_NOT_FOUND;
365 Status = EFI_NOT_FOUND;
367 for (Index = 0; Index < EsrtNum; Index++) {
376 Status =
gRT->SetVariable (
389 if (EsrtRepository !=
NULL) {
413 Guid =
PcdGetPtr (PcdSystemFmpCapsuleImageTypeIdGuid);
414 Count =
PcdGetSize (PcdSystemFmpCapsuleImageTypeIdGuid)/
sizeof (
GUID);
416 for (Index = 0; Index < Count; Index++, Guid++) {
417 if (
CompareGuid (&FmpImageInfo->ImageTypeId, Guid)) {
437 IN UINT32 DescriptorVersion
440 EsrtEntry->FwVersion = FmpImageInfo->Version;
441 EsrtEntry->FwClass = FmpImageInfo->ImageTypeId;
443 EsrtEntry->FwType = ESRT_FW_TYPE_SYSTEMFIRMWARE;
445 EsrtEntry->FwType = ESRT_FW_TYPE_DEVICEFIRMWARE;
448 EsrtEntry->LowestSupportedFwVersion = 0;
449 EsrtEntry->CapsuleFlags = 0;
450 EsrtEntry->LastAttemptVersion = 0;
453 if (DescriptorVersion >= 2) {
457 EsrtEntry->LowestSupportedFwVersion = FmpImageInfo->LowestSupportedImageVersion;
460 if (DescriptorVersion >= 3) {
464 EsrtEntry->LastAttemptVersion = FmpImageInfo->LastAttemptVersion;
465 EsrtEntry->LastAttemptStatus = FmpImageInfo->LastAttemptStatus;
474 EsrtEntry->CapsuleFlags =
PcdGet16 (PcdSystemRebootAfterCapsuleProcessFlag);
VOID *EFIAPI CopyMem(OUT VOID *DestinationBuffer, IN CONST VOID *SourceBuffer, IN UINTN Length)
BOOLEAN EFIAPI CompareGuid(IN CONST GUID *Guid1, IN CONST GUID *Guid2)
VOID EFIAPI FreePool(IN VOID *Buffer)
VOID SetEsrtEntryFromFmpInfo(IN OUT EFI_SYSTEM_RESOURCE_ENTRY *EsrtEntry, IN EFI_FIRMWARE_IMAGE_DESCRIPTOR *FmpImageInfo, IN UINT32 DescriptorVersion)
EFI_STATUS DeleteEsrtEntry(IN EFI_GUID *FwClass, IN UINTN Attribute)
EFI_STATUS GetEsrtEntry(IN EFI_GUID *FwClass, IN UINTN Attribute, OUT EFI_SYSTEM_RESOURCE_ENTRY *Entry)
EFI_STATUS UpdateEsrtEntry(IN EFI_SYSTEM_RESOURCE_ENTRY *Entry, UINTN Attribute)
BOOLEAN IsSystemFmp(IN EFI_FIRMWARE_IMAGE_DESCRIPTOR *FmpImageInfo)
EFI_STATUS InsertEsrtEntry(IN EFI_SYSTEM_RESOURCE_ENTRY *Entry, UINTN Attribute)
#define IMAGE_ATTRIBUTE_RESET_REQUIRED
EFI_RUNTIME_SERVICES * gRT
#define DEBUG(Expression)
#define PcdGet16(TokenName)
#define PcdGetSize(TokenName)
#define PcdGet32(TokenName)
#define PcdGetPtr(TokenName)
VOID *EFIAPI AllocatePool(IN UINTN AllocationSize)
#define LAST_ATTEMPT_STATUS_SUCCESS
EFI_STATUS EFIAPI GetVariable2(IN CONST CHAR16 *Name, IN CONST EFI_GUID *Guid, OUT VOID **Value, OUT UINTN *Size OPTIONAL)
#define EFI_VARIABLE_NON_VOLATILE