EmbeddedPkg/MmcDxe: 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@14264 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
oliviermartin 2013-04-14 09:26:28 +00:00
parent 3d783074e1
commit 5ab765a7ad

View File

@ -515,6 +515,10 @@ MmcIoBlocks (
MmcHost = MmcHostInstance->MmcHost; MmcHost = MmcHostInstance->MmcHost;
ASSERT (MmcHost); ASSERT (MmcHost);
if (This->Media->MediaId != MediaId) {
return EFI_MEDIA_CHANGED;
}
if ((MmcHost == 0)|| (Buffer == NULL)) { if ((MmcHost == 0)|| (Buffer == NULL)) {
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
@ -529,17 +533,23 @@ MmcIoBlocks (
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
// The buffer size must not be zero and it must be an exact multiple of the block size if((Transfer == MMC_IOBLOCKS_WRITE) && (This->Media->ReadOnly == TRUE)) {
if ((BufferSize == 0) || ((BufferSize % This->Media->BlockSize) != 0)) { return EFI_WRITE_PROTECTED;
}
// Reading 0 Byte is valid
if (BufferSize == 0) {
return EFI_SUCCESS;
}
// The buffer size must be an exact multiple of the block size
if ((BufferSize % This->Media->BlockSize) != 0) {
return EFI_BAD_BUFFER_SIZE; return EFI_BAD_BUFFER_SIZE;
} }
if (This->Media->MediaId != MediaId) { // Check the alignment
return EFI_MEDIA_CHANGED; if ((This->Media->IoAlign > 2) && (((UINTN)Buffer & (This->Media->IoAlign - 1)) != 0)) {
} return EFI_INVALID_PARAMETER;
if((Transfer == MMC_IOBLOCKS_WRITE) && (This->Media->ReadOnly == TRUE)) {
return EFI_WRITE_PROTECTED;
} }
BytesRemainingToBeTransfered = BufferSize; BytesRemainingToBeTransfered = BufferSize;