summaryrefslogtreecommitdiff
path: root/ArmPlatformPkg/ArmVExpressPkg/NorFlashDxe
diff options
context:
space:
mode:
Diffstat (limited to 'ArmPlatformPkg/ArmVExpressPkg/NorFlashDxe')
-rw-r--r--ArmPlatformPkg/ArmVExpressPkg/NorFlashDxe/NorFlashDxe.c10
-rw-r--r--ArmPlatformPkg/ArmVExpressPkg/NorFlashDxe/NorFlashDxe.h1
-rw-r--r--ArmPlatformPkg/ArmVExpressPkg/NorFlashDxe/NorFlashDxe.inf9
-rw-r--r--ArmPlatformPkg/ArmVExpressPkg/NorFlashDxe/NorFlashFvbDxe.c32
4 files changed, 22 insertions, 30 deletions
diff --git a/ArmPlatformPkg/ArmVExpressPkg/NorFlashDxe/NorFlashDxe.c b/ArmPlatformPkg/ArmVExpressPkg/NorFlashDxe/NorFlashDxe.c
index 333e7d4de8..0fd41cee71 100644
--- a/ArmPlatformPkg/ArmVExpressPkg/NorFlashDxe/NorFlashDxe.c
+++ b/ArmPlatformPkg/ArmVExpressPkg/NorFlashDxe/NorFlashDxe.c
@@ -1,6 +1,6 @@
/** @file NorFlashDxe.c
- Copyright (c) 2010, ARM Ltd. All rights reserved.<BR>
+ Copyright (c) 2011, ARM Ltd. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
@@ -16,6 +16,7 @@
#include <Library/BaseMemoryLib.h>
#include <Library/MemoryAllocationLib.h>
#include <Library/UefiBootServicesTableLib.h>
+#include <Library/PcdLib.h>
#include "NorFlashDxe.h"
@@ -31,28 +32,24 @@ NOR_FLASH_DESCRIPTION mNorFlashDescription[NOR_FLASH_LAST_DEVICE] = {
ARM_VE_SMB_NOR0_BASE,
SIZE_256KB * 255,
SIZE_256KB,
- FALSE,
{0xE7223039, 0x5836, 0x41E1, 0xB5, 0x42, 0xD7, 0xEC, 0x73, 0x6C, 0x5E, 0x59}
},
{ // BootMon non-volatile storage
ARM_VE_SMB_NOR0_BASE + SIZE_256KB * 255,
SIZE_64KB * 4,
SIZE_64KB,
- FALSE,
{0x02118005, 0x9DA7, 0x443A, 0x92, 0xD5, 0x78, 0x1F, 0x02, 0x2A, 0xED, 0xBB}
},
{ // UEFI
ARM_VE_SMB_NOR1_BASE,
SIZE_256KB * 255,
SIZE_256KB,
- FALSE,
{0x1F15DA3C, 0x37FF, 0x4070, 0xB4, 0x71, 0xBB, 0x4A, 0xF1, 0x2A, 0x72, 0x4A}
},
{ // UEFI Variable Services non-volatile storage
ARM_VE_SMB_NOR1_BASE + SIZE_256KB * 255,
SIZE_64KB * 3, //FIXME: Set 3 blocks because I did not succeed to copy 4 blocks into the ARM Versastile Express NOR Falsh in the last NOR Flash. It should be 4 blocks
SIZE_64KB,
- TRUE,
{0xCC2CBF29, 0x1498, 0x4CDD, 0x81, 0x71, 0xF8, 0xB6, 0xB4, 0x1D, 0x09, 0x09}
}
};
@@ -782,6 +779,7 @@ NorFlashInitialise (
{
EFI_STATUS Status = EFI_SUCCESS;
UINT32 Index;
+ UINTN NvStorageVariableBase = (UINTN) PcdGet32 (PcdFlashNvStorageVariableBase);
for (Index = 0; Index < NOR_FLASH_LAST_DEVICE; Index++) {
Status = NorFlashCreateInstance(
@@ -789,7 +787,7 @@ NorFlashInitialise (
mNorFlashDescription[Index].Size,
Index,
mNorFlashDescription[Index].BlockSize,
- mNorFlashDescription[Index].SupportFvb,
+ (mNorFlashDescription[Index].BaseAddress == NvStorageVariableBase),
&mNorFlashDescription[Index].Guid,
&mNorFlashInstances[Index]
);
diff --git a/ArmPlatformPkg/ArmVExpressPkg/NorFlashDxe/NorFlashDxe.h b/ArmPlatformPkg/ArmVExpressPkg/NorFlashDxe/NorFlashDxe.h
index e5ce220a79..7da9942c34 100644
--- a/ArmPlatformPkg/ArmVExpressPkg/NorFlashDxe/NorFlashDxe.h
+++ b/ArmPlatformPkg/ArmVExpressPkg/NorFlashDxe/NorFlashDxe.h
@@ -124,7 +124,6 @@ typedef struct {
UINTN BaseAddress;
UINTN Size;
UINTN BlockSize;
- BOOLEAN SupportFvb;
EFI_GUID Guid;
} NOR_FLASH_DESCRIPTION;
diff --git a/ArmPlatformPkg/ArmVExpressPkg/NorFlashDxe/NorFlashDxe.inf b/ArmPlatformPkg/ArmVExpressPkg/NorFlashDxe/NorFlashDxe.inf
index a5e5f13bdf..0ea1ded211 100644
--- a/ArmPlatformPkg/ArmVExpressPkg/NorFlashDxe/NorFlashDxe.inf
+++ b/ArmPlatformPkg/ArmVExpressPkg/NorFlashDxe/NorFlashDxe.inf
@@ -48,12 +48,13 @@
gEfiDevicePathProtocolGuid
gEfiFirmwareVolumeBlockProtocolGuid
-[FixedPcd.common]
+[Pcd.common]
gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableSize
gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase
-[Pcd.common]
-
[Depex]
-TRUE
+ #
+ # NorFlashDxe must be loaded before VariableRuntimeDxe in case empty flash needs populating with default values
+ #
+ BEFORE gVariableRuntimeDxeFileGuid
diff --git a/ArmPlatformPkg/ArmVExpressPkg/NorFlashDxe/NorFlashFvbDxe.c b/ArmPlatformPkg/ArmVExpressPkg/NorFlashDxe/NorFlashFvbDxe.c
index 1ec24a1c27..ffc2d5db59 100644
--- a/ArmPlatformPkg/ArmVExpressPkg/NorFlashDxe/NorFlashFvbDxe.c
+++ b/ArmPlatformPkg/ArmVExpressPkg/NorFlashDxe/NorFlashFvbDxe.c
@@ -1,6 +1,6 @@
/*++ @file NorFlashFvbDxe.c
- Copyright (c) 2010, ARM Ltd. All rights reserved.<BR>
+ Copyright (c) 2011, ARM Ltd. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
@@ -60,8 +60,7 @@ InitializeFvAndVariableStoreHeaders (
}
HeadersLength = sizeof(EFI_FIRMWARE_VOLUME_HEADER) + sizeof(EFI_FV_BLOCK_MAP_ENTRY) + sizeof(VARIABLE_STORE_HEADER);
- Headers = AllocatePool(HeadersLength);
- ZeroMem (&Headers,HeadersLength);
+ Headers = AllocateZeroPool(HeadersLength);
//
// EFI_FIRMWARE_VOLUME_HEADER
@@ -85,7 +84,7 @@ InitializeFvAndVariableStoreHeaders (
FirmwareVolumeHeader->BlockMap[0].Length = Instance->Media.BlockSize;
FirmwareVolumeHeader->BlockMap[1].NumBlocks = 0;
FirmwareVolumeHeader->BlockMap[1].Length = 0;
- FirmwareVolumeHeader->Checksum = CalculateCheckSum16 (FirmwareVolumeHeader,FirmwareVolumeHeader->HeaderLength);
+ FirmwareVolumeHeader->Checksum = CalculateCheckSum16 ((UINT16*)FirmwareVolumeHeader,FirmwareVolumeHeader->HeaderLength);
//
// VARIABLE_STORE_HEADER
@@ -97,7 +96,7 @@ InitializeFvAndVariableStoreHeaders (
VariableStoreHeader->State = VARIABLE_STORE_HEALTHY;
// Install the combined super-header in the NorFlash
- Status = FvbWrite(&Instance->FvbProtocol, 0, 0, &FirmwareVolumeHeader, Headers );
+ Status = FvbWrite(&Instance->FvbProtocol, 0, 0, &HeadersLength, Headers );
FreePool(Headers);
return Status;
@@ -133,6 +132,7 @@ ValidateFvHeader (
|| ( FwVolHeader->Signature != EFI_FVH_SIGNATURE )
|| ( FwVolHeader->FvLength != Instance->Media.BlockSize * (Instance->Media.LastBlock + 1) )
) {
+ DEBUG ((EFI_D_ERROR, "ValidateFvHeader: No Firmware Volume header present\n"));
return EFI_NOT_FOUND;
}
@@ -143,11 +143,11 @@ ValidateFvHeader (
}
// Verify the header checksum
- /*Checksum = CalculateSum16((VOID*) FwVolHeader, FwVolHeader->HeaderLength);
+ Checksum = CalculateSum16((UINT16*)FwVolHeader, FwVolHeader->HeaderLength);
if (Checksum != 0) {
DEBUG ((EFI_D_ERROR, "ValidateFvHeader: FV checksum is invalid (Checksum:0x%X)\n",Checksum));
return EFI_NOT_FOUND;
- }*/
+ }
VariableStoreHeader = (VARIABLE_STORE_HEADER*)((UINT32)FwVolHeader + FwVolHeader->HeaderLength);
@@ -383,7 +383,7 @@ FvbGetBlockSize(
**/
EFI_STATUS
EFIAPI
-FvbRead(
+FvbRead (
IN CONST EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL *This,
IN EFI_LBA Lba,
IN UINTN Offset,
@@ -408,12 +408,6 @@ FvbRead(
Status = EFI_SUCCESS;
TempStatus = Status;
- if (FALSE) {
- DEBUG ((EFI_D_ERROR, "FvbRead: Can not read: Device is in ReadDisabled state.\n"));
- // It is in ReadDisabled state, return an error right away
- return EFI_ACCESS_DENIED;
- }
-
// Cache the block size to avoid de-referencing pointers all the time
BlockSize = Instance->Media.BlockSize;
@@ -520,7 +514,7 @@ FREE_MEMORY:
**/
EFI_STATUS
EFIAPI
-FvbWrite(
+FvbWrite (
IN CONST EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL *This,
IN EFI_LBA Lba,
IN UINTN Offset,
@@ -650,7 +644,7 @@ FREE_MEMORY:
**/
EFI_STATUS
EFIAPI
-FvbEraseBlocks(
+FvbEraseBlocks (
IN CONST EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL *This,
...
)
@@ -729,7 +723,7 @@ FvbEraseBlocks(
while (NumOfLba > 0) {
// Get the physical address of Lba to erase
- BlockAddress = GET_NOR_BLOCK_ADDRESS(
+ BlockAddress = GET_NOR_BLOCK_ADDRESS (
Instance->BaseAddress,
StartingLba,
Instance->Media.BlockSize
@@ -737,7 +731,7 @@ FvbEraseBlocks(
// Erase it
DEBUG ((DEBUG_BLKIO, "FvbEraseBlocks: Erasing Lba=%ld @ 0x%08x.\n", StartingLba, BlockAddress));
- Status = NorFlashUnlockAndEraseSingleBlock(BlockAddress);
+ Status = NorFlashUnlockAndEraseSingleBlock (BlockAddress);
if (EFI_ERROR(Status)) {
VA_END (args);
Status = EFI_DEVICE_ERROR;
@@ -777,7 +771,7 @@ NorFlashFvbInitialize (
Status = ValidateFvHeader (Instance);
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. Install a correct one for this volume.\n"));
+ DEBUG((EFI_D_ERROR,"NorFlashFvbInitialize: ERROR - The FVB Header is not valid. Installing a correct one for this volume.\n"));
// Erase all the NorFlash that is reserved for variable storage
Status = FvbEraseBlocks ( &Instance->FvbProtocol, (EFI_LBA)0, (UINT32)(Instance->Media.LastBlock + 1), EFI_LBA_LIST_TERMINATOR );