diff options
author | oliviermartin <oliviermartin@6f19259b-4bc3-4df7-8a09-765794883524> | 2013-04-14 09:26:28 +0000 |
---|---|---|
committer | oliviermartin <oliviermartin@6f19259b-4bc3-4df7-8a09-765794883524> | 2013-04-14 09:26:28 +0000 |
commit | 5ab765a7ad42933b4ea51a1f9593c37f7b32e6d7 (patch) | |
tree | 8dc3acb77c3dd9a179006e2007a69de85a6c8c13 /EmbeddedPkg/Universal | |
parent | 3d783074e1a965dcbcb8f7bb78caf0880b672ed0 (diff) | |
download | edk2-5ab765a7ad42933b4ea51a1f9593c37f7b32e6d7.zip edk2-5ab765a7ad42933b4ea51a1f9593c37f7b32e6d7.tar.gz edk2-5ab765a7ad42933b4ea51a1f9593c37f7b32e6d7.tar.bz2 |
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
Diffstat (limited to 'EmbeddedPkg/Universal')
-rw-r--r-- | EmbeddedPkg/Universal/MmcDxe/MmcBlockIo.c | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/EmbeddedPkg/Universal/MmcDxe/MmcBlockIo.c b/EmbeddedPkg/Universal/MmcDxe/MmcBlockIo.c index fa0eccd..33f2c56 100644 --- a/EmbeddedPkg/Universal/MmcDxe/MmcBlockIo.c +++ b/EmbeddedPkg/Universal/MmcDxe/MmcBlockIo.c @@ -515,6 +515,10 @@ MmcIoBlocks ( MmcHost = MmcHostInstance->MmcHost;
ASSERT (MmcHost);
+ if (This->Media->MediaId != MediaId) {
+ return EFI_MEDIA_CHANGED;
+ }
+
if ((MmcHost == 0)|| (Buffer == NULL)) {
return EFI_INVALID_PARAMETER;
}
@@ -529,17 +533,23 @@ MmcIoBlocks ( return EFI_INVALID_PARAMETER;
}
- // The buffer size must not be zero and it must be an exact multiple of the block size
- if ((BufferSize == 0) || ((BufferSize % This->Media->BlockSize) != 0)) {
- return EFI_BAD_BUFFER_SIZE;
+ if((Transfer == MMC_IOBLOCKS_WRITE) && (This->Media->ReadOnly == TRUE)) {
+ return EFI_WRITE_PROTECTED;
}
- if (This->Media->MediaId != MediaId) {
- return EFI_MEDIA_CHANGED;
+ // Reading 0 Byte is valid
+ if (BufferSize == 0) {
+ return EFI_SUCCESS;
}
- if((Transfer == MMC_IOBLOCKS_WRITE) && (This->Media->ReadOnly == TRUE)) {
- return EFI_WRITE_PROTECTED;
+ // The buffer size must be an exact multiple of the block size
+ if ((BufferSize % This->Media->BlockSize) != 0) {
+ return EFI_BAD_BUFFER_SIZE;
+ }
+
+ // Check the alignment
+ if ((This->Media->IoAlign > 2) && (((UINTN)Buffer & (This->Media->IoAlign - 1)) != 0)) {
+ return EFI_INVALID_PARAMETER;
}
BytesRemainingToBeTransfered = BufferSize;
|