return MmioRead32 (Instance->DeviceBaseAddress);\r
}\r
\r
-\r
+STATIC\r
BOOLEAN\r
NorFlashBlockIsLocked (\r
IN NOR_FLASH_INSTANCE *Instance,\r
)\r
{\r
UINT32 LockStatus;\r
- BOOLEAN BlockIsLocked;\r
-\r
- BlockIsLocked = TRUE;\r
\r
// Send command for reading device id\r
SEND_NOR_COMMAND (BlockAddress, 2, P30_CMD_READ_DEVICE_ID);\r
DEBUG((EFI_D_ERROR, "NorFlashBlockIsLocked: WARNING: Block LOCKED DOWN\n"));\r
}\r
\r
- if ((LockStatus & 0x1) == 0) {\r
- // This means the block is unlocked\r
- DEBUG((DEBUG_BLKIO, "UnlockSingleBlock: Block 0x%08x unlocked\n", BlockAddress));\r
- BlockIsLocked = FALSE;\r
- }\r
-\r
- return BlockIsLocked;\r
+ return ((LockStatus & 0x1) != 0);\r
}\r
\r
-\r
+STATIC\r
EFI_STATUS\r
NorFlashUnlockSingleBlock (\r
IN NOR_FLASH_INSTANCE *Instance,\r
IN UINTN BlockAddress\r
)\r
{\r
- EFI_STATUS Status = EFI_SUCCESS;\r
UINT32 LockStatus;\r
\r
// Raise the Task Priority Level to TPL_NOTIFY to serialise all its operations\r
// Put device back into Read Array mode\r
SEND_NOR_COMMAND (BlockAddress, 0, P30_CMD_READ_ARRAY);\r
\r
- DEBUG((DEBUG_BLKIO, "UnlockSingleBlock: BlockAddress=0x%08x, Exit Status = \"%r\".\n", BlockAddress, Status));\r
+ DEBUG((DEBUG_BLKIO, "UnlockSingleBlock: BlockAddress=0x%08x\n", BlockAddress));\r
\r
- return Status;\r
+ return EFI_SUCCESS;\r
}\r
\r
-\r
+STATIC\r
EFI_STATUS\r
NorFlashUnlockSingleBlockIfNecessary (\r
IN NOR_FLASH_INSTANCE *Instance,\r
IN UINTN BlockAddress\r
)\r
{\r
- EFI_STATUS Status = EFI_SUCCESS;\r
+ EFI_STATUS Status;\r
+\r
+ Status = EFI_SUCCESS;\r
\r
if (NorFlashBlockIsLocked (Instance, BlockAddress) == TRUE) {\r
Status = NorFlashUnlockSingleBlock (Instance, BlockAddress);\r
/**\r
* The following function presumes that the block has already been unlocked.\r
**/\r
+STATIC\r
EFI_STATUS\r
NorFlashEraseSingleBlock (\r
IN NOR_FLASH_INSTANCE *Instance,\r
}\r
\r
/**\r
- * The following function presumes that the block has already been unlocked.\r
+ * This function unlock and erase an entire NOR Flash block.\r
**/\r
EFI_STATUS\r
NorFlashUnlockAndEraseSingleBlock (\r
do {\r
// Unlock the block if we have to\r
Status = NorFlashUnlockSingleBlockIfNecessary (Instance, BlockAddress);\r
- if (!EFI_ERROR(Status)) {\r
- Status = NorFlashEraseSingleBlock (Instance, BlockAddress);\r
+ if (EFI_ERROR (Status)) {\r
+ break;\r
}\r
+ Status = NorFlashEraseSingleBlock (Instance, BlockAddress);\r
Index++;\r
} while ((Index < NOR_FLASH_ERASE_RETRY) && (Status == EFI_WRITE_PROTECTED));\r
\r