/** Routine Description: Write a block of data. Arguments: BaseAddress - Base address of the block. Buffer - Data buffer. BufferSize - Size of the buffer. Returns: EFI_SUCCESS - The command completed successfully. EFI_INVALID_PARAMETER - Invalid parameter, can not proceed. Other - Device error or wirte-locked, operation failed. **/ EFI_STATUS InternalWriteBlock ( IN EFI_PHYSICAL_ADDRESS BaseAddress, IN UINT8 *Buffer, IN UINT32 BufferSize ) { EFI_STATUS Status; Status = SpiFlashWrite ((UINTN) BaseAddress, &BufferSize, Buffer); if (EFI_ERROR (Status)) { DEBUG((DEBUG_ERROR, "\nFlash write error.")); return Status; } WriteBackInvalidateDataCacheRange ((VOID *) (UINTN) BaseAddress, BLOCK_SIZE); Status = InternalCompareBlock (BaseAddress, Buffer); if (EFI_ERROR (Status)) { DEBUG((DEBUG_ERROR, "\nError when writing to BaseAddress %x with different at offset %x.", BaseAddress, Status)); } else { DEBUG((DEBUG_INFO, "\nVerified data written to Block at %x is correct.", BaseAddress)); } return Status; }
STATIC EFI_STATUS InternalWriteBlock ( IN EFI_PHYSICAL_ADDRESS BaseAddress, IN UINT8 *Buffer, IN UINT32 BufferSize ) /*++ Routine Description: Write a block of data. Arguments: BaseAddress - Base address of the block. Buffer - Data buffer. BufferSize - Size of the buffer. Returns: EFI_SUCCESS - The command completed successfully. EFI_INVALID_PARAMETER - Invalid parameter, can not proceed. Other - Device error or wirte-locked, operation failed. --*/ { EFI_STATUS Status; Status = SpiFlashWrite ((UINTN) BaseAddress, &BufferSize, Buffer); ASSERT_EFI_ERROR(Status); if (EFI_ERROR (Status)) { DEBUG((EFI_D_ERROR, "\nFlash write error.")); return Status; } WriteBackInvalidateDataCacheRange ((VOID *) (UINTN) BaseAddress, BLOCK_SIZE); Status = InternalCompareBlock (BaseAddress, Buffer); if (EFI_ERROR (Status)) { DEBUG((EFI_D_ERROR, "\nError when writing to BaseAddress %lx with different at offset %x.", BaseAddress, Status)); } else { DEBUG((EFI_D_INFO, "\nVerified data written to Block at %lx is correct.", BaseAddress)); } return Status; }