mirror of https://github.com/acidanthera/audk.git
ArmPlatformPkg/NorFlashDxe: Clean the driver
- Marked some functions as STATIC - Simplified some conditions Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Olivier Martin <olivier.martin@arm.com> git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@15907 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
parent
bcb53c42d0
commit
22044caa2c
|
@ -182,7 +182,7 @@ NorFlashReadStatusRegister (
|
|||
return MmioRead32 (Instance->DeviceBaseAddress);
|
||||
}
|
||||
|
||||
|
||||
STATIC
|
||||
BOOLEAN
|
||||
NorFlashBlockIsLocked (
|
||||
IN NOR_FLASH_INSTANCE *Instance,
|
||||
|
@ -190,9 +190,6 @@ NorFlashBlockIsLocked (
|
|||
)
|
||||
{
|
||||
UINT32 LockStatus;
|
||||
BOOLEAN BlockIsLocked;
|
||||
|
||||
BlockIsLocked = TRUE;
|
||||
|
||||
// Send command for reading device id
|
||||
SEND_NOR_COMMAND (BlockAddress, 2, P30_CMD_READ_DEVICE_ID);
|
||||
|
@ -207,23 +204,16 @@ NorFlashBlockIsLocked (
|
|||
DEBUG((EFI_D_ERROR, "NorFlashBlockIsLocked: WARNING: Block LOCKED DOWN\n"));
|
||||
}
|
||||
|
||||
if ((LockStatus & 0x1) == 0) {
|
||||
// This means the block is unlocked
|
||||
DEBUG((DEBUG_BLKIO, "UnlockSingleBlock: Block 0x%08x unlocked\n", BlockAddress));
|
||||
BlockIsLocked = FALSE;
|
||||
return ((LockStatus & 0x1) != 0);
|
||||
}
|
||||
|
||||
return BlockIsLocked;
|
||||
}
|
||||
|
||||
|
||||
STATIC
|
||||
EFI_STATUS
|
||||
NorFlashUnlockSingleBlock (
|
||||
IN NOR_FLASH_INSTANCE *Instance,
|
||||
IN UINTN BlockAddress
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status = EFI_SUCCESS;
|
||||
UINT32 LockStatus;
|
||||
|
||||
// Raise the Task Priority Level to TPL_NOTIFY to serialise all its operations
|
||||
|
@ -262,19 +252,21 @@ NorFlashUnlockSingleBlock (
|
|||
// Put device back into Read Array mode
|
||||
SEND_NOR_COMMAND (BlockAddress, 0, P30_CMD_READ_ARRAY);
|
||||
|
||||
DEBUG((DEBUG_BLKIO, "UnlockSingleBlock: BlockAddress=0x%08x, Exit Status = \"%r\".\n", BlockAddress, Status));
|
||||
DEBUG((DEBUG_BLKIO, "UnlockSingleBlock: BlockAddress=0x%08x\n", BlockAddress));
|
||||
|
||||
return Status;
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
STATIC
|
||||
EFI_STATUS
|
||||
NorFlashUnlockSingleBlockIfNecessary (
|
||||
IN NOR_FLASH_INSTANCE *Instance,
|
||||
IN UINTN BlockAddress
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status = EFI_SUCCESS;
|
||||
EFI_STATUS Status;
|
||||
|
||||
Status = EFI_SUCCESS;
|
||||
|
||||
if (NorFlashBlockIsLocked (Instance, BlockAddress) == TRUE) {
|
||||
Status = NorFlashUnlockSingleBlock (Instance, BlockAddress);
|
||||
|
@ -287,6 +279,7 @@ NorFlashUnlockSingleBlockIfNecessary (
|
|||
/**
|
||||
* The following function presumes that the block has already been unlocked.
|
||||
**/
|
||||
STATIC
|
||||
EFI_STATUS
|
||||
NorFlashEraseSingleBlock (
|
||||
IN NOR_FLASH_INSTANCE *Instance,
|
||||
|
@ -340,7 +333,7 @@ NorFlashEraseSingleBlock (
|
|||
}
|
||||
|
||||
/**
|
||||
* The following function presumes that the block has already been unlocked.
|
||||
* This function unlock and erase an entire NOR Flash block.
|
||||
**/
|
||||
EFI_STATUS
|
||||
NorFlashUnlockAndEraseSingleBlock (
|
||||
|
@ -366,9 +359,10 @@ NorFlashUnlockAndEraseSingleBlock (
|
|||
do {
|
||||
// Unlock the block if we have to
|
||||
Status = NorFlashUnlockSingleBlockIfNecessary (Instance, BlockAddress);
|
||||
if (!EFI_ERROR(Status)) {
|
||||
Status = NorFlashEraseSingleBlock (Instance, BlockAddress);
|
||||
if (EFI_ERROR (Status)) {
|
||||
break;
|
||||
}
|
||||
Status = NorFlashEraseSingleBlock (Instance, BlockAddress);
|
||||
Index++;
|
||||
} while ((Index < NOR_FLASH_ERASE_RETRY) && (Status == EFI_WRITE_PROTECTED));
|
||||
|
||||
|
|
|
@ -364,10 +364,4 @@ NorFlashReset (
|
|||
IN NOR_FLASH_INSTANCE *Instance
|
||||
);
|
||||
|
||||
EFI_STATUS
|
||||
NorFlashUnlockSingleBlockIfNecessary (
|
||||
IN NOR_FLASH_INSTANCE *Instance,
|
||||
IN UINTN BlockAddress
|
||||
);
|
||||
|
||||
#endif /* __NOR_FLASH_DXE_H__ */
|
||||
|
|
Loading…
Reference in New Issue