]> git.proxmox.com Git - mirror_edk2.git/commitdiff
EmbeddedPkg: Fix Ebl dumpgcd bug with memory type and IO type
authorHeyi Guo <heyi.guo@linaro.org>
Wed, 27 May 2015 15:11:19 +0000 (15:11 +0000)
committeroliviermartin <oliviermartin@Edk2>
Wed, 27 May 2015 15:11:19 +0000 (15:11 +0000)
1. Data type for GcdMemoryType and GcdIoType is enumeration type
rather than bit field, so we need to use strict equation "=="
instead of bit-and "&";
2. Testing for GcdIoType should use EfiGcdIoType*** constants
rather than EfiGcdMemoryType***;
3. As we are going to use strict equation, it is clearer to use
switch-case than if-else.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Heyi Guo <heyi.guo@linaro.org>
Reviewed-by: Olivier Martin <Olivier.Martin@arm.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@17527 6f19259b-4bc3-4df7-8a09-765794883524

ArmPlatformPkg/Library/EblCmdLib/EblCmdLib.c

index 899991062fc90518862ebbe191cd0acb00e44784..4a5f2be3947ef4fde1809c0c478c2cd56c2da194 100644 (file)
@@ -325,14 +325,23 @@ EblDumpGcd (
     if (MemorySpaceMap[i].Attributes & EFI_MEMORY_XP)\r
         AsciiPrint (" MEM_XP");\r
 \r
-    if (MemorySpaceMap[i].GcdMemoryType & EfiGcdMemoryTypeNonExistent)\r
+    switch (MemorySpaceMap[i].GcdMemoryType) {\r
+      case EfiGcdMemoryTypeNonExistent:\r
         AsciiPrint (" TYPE_NONEXISTENT");\r
-    if (MemorySpaceMap[i].GcdMemoryType & EfiGcdMemoryTypeReserved)\r
+        break;\r
+      case EfiGcdMemoryTypeReserved:\r
         AsciiPrint (" TYPE_RESERVED");\r
-    if (MemorySpaceMap[i].GcdMemoryType & EfiGcdMemoryTypeSystemMemory)\r
+        break;\r
+      case EfiGcdMemoryTypeSystemMemory:\r
         AsciiPrint (" TYPE_SYSMEM");\r
-    if (MemorySpaceMap[i].GcdMemoryType & EfiGcdMemoryTypeMemoryMappedIo)\r
+        break;\r
+      case EfiGcdMemoryTypeMemoryMappedIo:\r
         AsciiPrint (" TYPE_MEMMAP");\r
+        break;\r
+      default:\r
+        AsciiPrint (" TYPE_UNKNOWN");\r
+        break;\r
+    }\r
 \r
     AsciiPrint ("\n");\r
   }\r
@@ -347,12 +356,20 @@ EblDumpGcd (
     AsciiPrint ("IO  %08lx - %08lx",IoSpaceMap[i].BaseAddress,IoSpaceMap[i].BaseAddress+IoSpaceMap[i].Length);\r
     AsciiPrint ("\t%08x %08x",IoSpaceMap[i].ImageHandle,IoSpaceMap[i].DeviceHandle);\r
 \r
-    if (IoSpaceMap[i].GcdIoType & EfiGcdMemoryTypeNonExistent)\r
+    switch (IoSpaceMap[i].GcdIoType) {\r
+      case EfiGcdIoTypeNonExistent:\r
         AsciiPrint (" TYPE_NONEXISTENT");\r
-    if (IoSpaceMap[i].GcdIoType & EfiGcdMemoryTypeReserved)\r
+        break;\r
+      case EfiGcdIoTypeReserved:\r
         AsciiPrint (" TYPE_RESERVED");\r
-    if (IoSpaceMap[i].GcdIoType & EfiGcdIoTypeIo)\r
+        break;\r
+      case EfiGcdIoTypeIo:\r
         AsciiPrint (" TYPE_IO");\r
+        break;\r
+      default:\r
+        AsciiPrint (" TYPE_UNKNOWN");\r
+        break;\r
+    }\r
 \r
     AsciiPrint ("\n");\r
   }\r