Avoid hardcoded flashmap address

Current FLASH_MAP address is hard-coded at 0xFFFFFFF8. It will work
in most of the cases.  However, if region is added on top of the
Stage1A FV, it will cause FLASH_MAP address shift.  Instead, the code
can use relative address to locate FLASH_MAP.  The address can be
calculated with (Stage1AFvBase + Stage1AFvSize + 0xFFFFFFF8).

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
This commit is contained in:
Maurice Ma 2020-01-29 08:23:38 -08:00
parent a7a5b88c97
commit 753129ff2b
1 changed files with 1 additions and 1 deletions

View File

@ -47,8 +47,8 @@ GetFlashMapBufInfo (
UINT32 Stage1aFvBase;
FlashMap = NULL;
FlashMapBase = (* (UINT32 *)FLASH_MAP_ADDRESS);
Stage1aFvBase = PcdGet32 (PcdStage1AFdBase) + PcdGet32 (PcdFSPTSize);
FlashMapBase = (* (UINT32 *)(UINT32)(Stage1aFvBase + PcdGet32 (PcdStage1AFvSize) + FLASH_MAP_ADDRESS));
if ( (FlashMapBase > Stage1aFvBase) && \
(FlashMapBase + sizeof(FLASH_MAP) < Stage1aFvBase + PcdGet32 (PcdStage1AFvSize) - 1) ) {
// Verify FLASH_MAP is valid before access