From 121ac757204b54316d4762840a52d618243f8d79 Mon Sep 17 00:00:00 2001 From: lgao4 Date: Tue, 24 Mar 2009 07:57:42 +0000 Subject: [PATCH] Update Nt32 FVB driver to provide the valid FvHeader that header checksum is zero. git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@7930 6f19259b-4bc3-4df7-8a09-765794883524 --- .../FvbServicesRuntimeDxe/FWBlockService.c | 24 ++----------------- Nt32Pkg/FvbServicesRuntimeDxe/FvbInfo.c | 20 +++++++++------- 2 files changed, 14 insertions(+), 30 deletions(-) diff --git a/Nt32Pkg/FvbServicesRuntimeDxe/FWBlockService.c b/Nt32Pkg/FvbServicesRuntimeDxe/FWBlockService.c index 350672448f..a3981f6b0f 100644 --- a/Nt32Pkg/FvbServicesRuntimeDxe/FWBlockService.c +++ b/Nt32Pkg/FvbServicesRuntimeDxe/FWBlockService.c @@ -1104,10 +1104,6 @@ Returns: --*/ { - UINT16 *Ptr; - UINT16 HeaderLength; - UINT16 Checksum; - // // Verify the header revision, header signature, length // Length of FvBlock cannot be 2**64-1 @@ -1124,26 +1120,10 @@ Returns: // // Verify the header checksum // - HeaderLength = (UINT16) (FwVolHeader->HeaderLength / 2); - Ptr = (UINT16 *) FwVolHeader; - Checksum = 0; - while (HeaderLength > 0) { - Checksum = (UINT16)(Checksum + (*Ptr)); - HeaderLength--; - Ptr++; - } - - if (Checksum != 0) { + if (CalculateCheckSum16 ((UINT16 *) FwVolHeader, FwVolHeader->HeaderLength) != 0) { return EFI_NOT_FOUND; } - // - // PI specification defines the name guid of FV exists in extension header. - // - if (FwVolHeader->ExtHeaderOffset == 0) { - return EFI_NOT_FOUND; - } - return EFI_SUCCESS; } @@ -1180,7 +1160,7 @@ Returns: UINTN NumOfBlocks; EFI_PEI_HOB_POINTERS FvHob; - // + // // Get the DXE services table // DxeServices = gDS; diff --git a/Nt32Pkg/FvbServicesRuntimeDxe/FvbInfo.c b/Nt32Pkg/FvbServicesRuntimeDxe/FvbInfo.c index d4ecf3b9bd..b39cd2ea91 100644 --- a/Nt32Pkg/FvbServicesRuntimeDxe/FvbInfo.c +++ b/Nt32Pkg/FvbServicesRuntimeDxe/FvbInfo.c @@ -70,14 +70,16 @@ EFI_FVB_MEDIA_INFO mPlatformFvbMediaInfo[] = { EFI_FIRMWARE_FILE_SYSTEM2_GUID, FixedPcdGet32 (PcdWinNtFlashFvRecoverySize), EFI_FVH_SIGNATURE, - EFI_FVB2_READ_ENABLED_CAP | + EFI_FVB2_MEMORY_MAPPED | + EFI_FVB2_READ_ENABLED_CAP | EFI_FVB2_READ_STATUS | EFI_FVB2_WRITE_ENABLED_CAP | EFI_FVB2_WRITE_STATUS | - EFI_FVB2_ERASE_POLARITY, + EFI_FVB2_ERASE_POLARITY | + EFI_FVB2_ALIGNMENT_16, sizeof (EFI_FIRMWARE_VOLUME_HEADER) + sizeof (EFI_FV_BLOCK_MAP_ENTRY), - 0, // CheckSum - 0, // ExtHeaderOffset + 0xE947, // CheckSum + 0, // ExtHeaderOffset { 0, }, // Reserved[1] @@ -110,14 +112,16 @@ EFI_FVB_MEDIA_INFO mPlatformFvbMediaInfo[] = { FixedPcdGet32 (PcdFlashNvStorageFtwSpareSize) + FixedPcdGet32 (PcdWinNtFlashNvStorageEventLogSize), EFI_FVH_SIGNATURE, - EFI_FVB2_READ_ENABLED_CAP | + EFI_FVB2_MEMORY_MAPPED | + EFI_FVB2_READ_ENABLED_CAP | EFI_FVB2_READ_STATUS | EFI_FVB2_WRITE_ENABLED_CAP | EFI_FVB2_WRITE_STATUS | - EFI_FVB2_ERASE_POLARITY, + EFI_FVB2_ERASE_POLARITY | + EFI_FVB2_ALIGNMENT_16, sizeof (EFI_FIRMWARE_VOLUME_HEADER) + sizeof (EFI_FV_BLOCK_MAP_ENTRY), - 0, // CheckSum - 0, // ExtHeaderOffset + 0xFBFF, // CheckSum + 0, // ExtHeaderOffset { 0, }, // Reserved[1]