diff options
-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 fa0eccd40d..33f2c561f1 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;
|