X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=ArmPlatformPkg%2FDrivers%2FNorFlashDxe%2FNorFlashFvbDxe.c;h=12a861267a86e8846e963c1bc0b96fbbaa653d0b;hp=efe87e57fd4e87921c4245d1cacf65918b958609;hb=90d1f671cdad43fa80ba295b3f8d1133d68229df;hpb=36d66acf275135699fea9243e58e25990ab0db7f diff --git a/ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashFvbDxe.c b/ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashFvbDxe.c index efe87e57fd..12a861267a 100644 --- a/ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashFvbDxe.c +++ b/ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashFvbDxe.c @@ -111,7 +111,7 @@ InitializeFvAndVariableStoreHeaders ( // VARIABLE_STORE_HEADER // VariableStoreHeader = (VARIABLE_STORE_HEADER*)((UINTN)Headers + FirmwareVolumeHeader->HeaderLength); - CopyGuid (&VariableStoreHeader->Signature, &gEfiVariableGuid); + CopyGuid (&VariableStoreHeader->Signature, &gEfiAuthenticatedVariableGuid); VariableStoreHeader->Size = PcdGet32(PcdFlashNvStorageVariableSize) - FirmwareVolumeHeader->HeaderLength; VariableStoreHeader->Format = VARIABLE_STORE_FORMATTED; VariableStoreHeader->State = VARIABLE_STORE_HEALTHY; @@ -141,7 +141,7 @@ ValidateFvHeader ( EFI_FIRMWARE_VOLUME_HEADER *FwVolHeader; VARIABLE_STORE_HEADER *VariableStoreHeader; UINTN VariableStoreLength; - UINTN FvLength; + UINTN FvLength; FwVolHeader = (EFI_FIRMWARE_VOLUME_HEADER*)Instance->RegionBaseAddress; @@ -158,34 +158,40 @@ ValidateFvHeader ( || (FwVolHeader->FvLength != FvLength) ) { - DEBUG ((EFI_D_ERROR, "ValidateFvHeader: No Firmware Volume header present\n")); + DEBUG ((EFI_D_INFO, "%a: No Firmware Volume header present\n", + __FUNCTION__)); return EFI_NOT_FOUND; } // Check the Firmware Volume Guid if( CompareGuid (&FwVolHeader->FileSystemGuid, &gEfiSystemNvDataFvGuid) == FALSE ) { - DEBUG ((EFI_D_ERROR, "ValidateFvHeader: Firmware Volume Guid non-compatible\n")); + DEBUG ((EFI_D_INFO, "%a: Firmware Volume Guid non-compatible\n", + __FUNCTION__)); return EFI_NOT_FOUND; } // Verify the header checksum Checksum = CalculateSum16((UINT16*)FwVolHeader, FwVolHeader->HeaderLength); if (Checksum != 0) { - DEBUG ((EFI_D_ERROR, "ValidateFvHeader: FV checksum is invalid (Checksum:0x%X)\n",Checksum)); + DEBUG ((EFI_D_INFO, "%a: FV checksum is invalid (Checksum:0x%X)\n", + __FUNCTION__, Checksum)); return EFI_NOT_FOUND; } VariableStoreHeader = (VARIABLE_STORE_HEADER*)((UINTN)FwVolHeader + FwVolHeader->HeaderLength); // Check the Variable Store Guid - if( CompareGuid (&VariableStoreHeader->Signature, &gEfiVariableGuid) == FALSE ) { - DEBUG ((EFI_D_ERROR, "ValidateFvHeader: Variable Store Guid non-compatible\n")); + if (!CompareGuid (&VariableStoreHeader->Signature, &gEfiVariableGuid) && + !CompareGuid (&VariableStoreHeader->Signature, &gEfiAuthenticatedVariableGuid)) { + DEBUG ((EFI_D_INFO, "%a: Variable Store Guid non-compatible\n", + __FUNCTION__)); return EFI_NOT_FOUND; } VariableStoreLength = PcdGet32 (PcdFlashNvStorageVariableSize) - FwVolHeader->HeaderLength; if (VariableStoreHeader->Size != VariableStoreLength) { - DEBUG ((EFI_D_ERROR, "ValidateFvHeader: Variable Store Length does not match\n")); + DEBUG ((EFI_D_INFO, "%a: Variable Store Length does not match\n", + __FUNCTION__)); return EFI_NOT_FOUND; } @@ -713,6 +719,29 @@ NorFlashFvbInitialize ( UINTN RuntimeMmioRegionSize; DEBUG((DEBUG_BLKIO,"NorFlashFvbInitialize\n")); + ASSERT((Instance != NULL)); + + // + // Declare the Non-Volatile storage as EFI_MEMORY_RUNTIME + // + + // Note: all the NOR Flash region needs to be reserved into the UEFI Runtime memory; + // even if we only use the small block region at the top of the NOR Flash. + // The reason is when the NOR Flash memory is set into program mode, the command + // is written as the base of the flash region (ie: Instance->DeviceBaseAddress) + RuntimeMmioRegionSize = (Instance->RegionBaseAddress - Instance->DeviceBaseAddress) + Instance->Size; + + Status = gDS->AddMemorySpace ( + EfiGcdMemoryTypeMemoryMappedIo, + Instance->DeviceBaseAddress, RuntimeMmioRegionSize, + EFI_MEMORY_UC | EFI_MEMORY_RUNTIME + ); + ASSERT_EFI_ERROR (Status); + + Status = gDS->SetMemorySpaceAttributes ( + Instance->DeviceBaseAddress, RuntimeMmioRegionSize, + EFI_MEMORY_UC | EFI_MEMORY_RUNTIME); + ASSERT_EFI_ERROR (Status); Instance->Initialized = TRUE; mFlashNvStorageVariableBase = FixedPcdGet32 (PcdFlashNvStorageVariableBase); @@ -728,10 +757,12 @@ NorFlashFvbInitialize ( Status = ValidateFvHeader (Instance); } - // Install the Default FVB header if required + // Install the Default FVB header if required if (EFI_ERROR(Status)) { // There is no valid header, so time to install one. - DEBUG((EFI_D_ERROR,"NorFlashFvbInitialize: ERROR - The FVB Header is not valid. Installing a correct one for this volume.\n")); + DEBUG ((EFI_D_INFO, "%a: The FVB Header is not valid.\n", __FUNCTION__)); + DEBUG ((EFI_D_INFO, "%a: Installing a correct one for this volume.\n", + __FUNCTION__)); // Erase all the NorFlash that is reserved for variable storage FvbNumLba = (PcdGet32(PcdFlashNvStorageVariableSize) + PcdGet32(PcdFlashNvStorageFtwWorkingSize) + PcdGet32(PcdFlashNvStorageFtwSpareSize)) / Instance->Media.BlockSize; @@ -748,28 +779,6 @@ NorFlashFvbInitialize ( } } - // - // Declare the Non-Volatile storage as EFI_MEMORY_RUNTIME - // - - // Note: all the NOR Flash region needs to be reserved into the UEFI Runtime memory; - // even if we only use the small block region at the top of the NOR Flash. - // The reason is when the NOR Flash memory is set into program mode, the command - // is written as the base of the flash region (ie: Instance->DeviceBaseAddress) - RuntimeMmioRegionSize = (Instance->RegionBaseAddress - Instance->DeviceBaseAddress) + Instance->Size; - - Status = gDS->AddMemorySpace ( - EfiGcdMemoryTypeMemoryMappedIo, - Instance->DeviceBaseAddress, RuntimeMmioRegionSize, - EFI_MEMORY_UC | EFI_MEMORY_RUNTIME - ); - ASSERT_EFI_ERROR (Status); - - Status = gDS->SetMemorySpaceAttributes ( - Instance->DeviceBaseAddress, RuntimeMmioRegionSize, - EFI_MEMORY_UC | EFI_MEMORY_RUNTIME); - ASSERT_EFI_ERROR (Status); - // // Register for the virtual address change event //