ArmPlatformPkg/NorFlashDxe: Make the driver more compliant with the UEFI specification

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Olivier Martin <olivier.martin@arm.com>



git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@14263 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
oliviermartin
2013-04-14 09:25:34 +00:00
parent 09f2cf8295
commit 3d783074e1
2 changed files with 21 additions and 12 deletions

View File

@@ -1,6 +1,6 @@
/** @file NorFlashDxe.c
Copyright (c) 2011-2012, ARM Ltd. All rights reserved.<BR>
Copyright (c) 2011-2013, 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
@@ -721,19 +721,20 @@ NorFlashReadBlocks (
UINT32 NumBlocks;
UINTN StartAddress;
DEBUG((DEBUG_BLKIO, "NorFlashReadBlocks: BufferSize=0x%xB BlockSize=0x%xB LastBlock=%ld, Lba=%ld.\n",
BufferSizeInBytes, Instance->Media.BlockSize, Instance->Media.LastBlock, Lba));
// The buffer must be valid
if (Buffer == NULL) {
return EFI_INVALID_PARAMETER;
}
// We must have some bytes to read
DEBUG((DEBUG_BLKIO, "NorFlashReadBlocks: BufferSize=0x%x bytes.\n", BufferSizeInBytes));
if(BufferSizeInBytes == 0) {
return EFI_BAD_BUFFER_SIZE;
// Return if we have not any byte to read
if (BufferSizeInBytes == 0) {
return EFI_SUCCESS;
}
// The size of the buffer must be a multiple of the block size
DEBUG((DEBUG_BLKIO, "NorFlashReadBlocks: BlockSize=0x%x bytes.\n", Instance->Media.BlockSize));
if ((BufferSizeInBytes % Instance->Media.BlockSize) != 0) {
return EFI_BAD_BUFFER_SIZE;
}
@@ -741,8 +742,6 @@ NorFlashReadBlocks (
// All blocks must be within the device
NumBlocks = ((UINT32)BufferSizeInBytes) / Instance->Media.BlockSize ;
DEBUG((DEBUG_BLKIO, "NorFlashReadBlocks: NumBlocks=%d, LastBlock=%ld, Lba=%ld\n", NumBlocks, Instance->Media.LastBlock, Lba));
if ((Lba + NumBlocks) > (Instance->Media.LastBlock + 1)) {
DEBUG((EFI_D_ERROR, "NorFlashReadBlocks: ERROR - Read will exceed last block\n"));
return EFI_INVALID_PARAMETER;