]> git.proxmox.com Git - mirror_edk2.git/commitdiff
EmbeddedPkg/MmcDxe: Make the driver more compliant with the UEFI specification
authoroliviermartin <oliviermartin@6f19259b-4bc3-4df7-8a09-765794883524>
Sun, 14 Apr 2013 09:26:28 +0000 (09:26 +0000)
committeroliviermartin <oliviermartin@6f19259b-4bc3-4df7-8a09-765794883524>
Sun, 14 Apr 2013 09:26:28 +0000 (09:26 +0000)
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

EmbeddedPkg/Universal/MmcDxe/MmcBlockIo.c

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