]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Core/Dxe/Gcd/Gcd.c
Clean up GCD DEBUG() macros so DEBUG_CODE() is only used to enable/disable the DBG...
[mirror_edk2.git] / MdeModulePkg / Core / Dxe / Gcd / Gcd.c
index 467e4a00793e8dbae029ff4c365fa3841d9b4709..a5fb033babbaeac42e32afc6183abc8102ce5caa 100644 (file)
@@ -132,68 +132,83 @@ GLOBAL_REMOVE_IF_UNREFERENCED CONST CHAR8 *mGcdAllocationTypeNames[] = {
   Dump the entire contents if the GCD Memory Space Map using DEBUG() macros when\r
   PcdDebugPrintErrorLevel has the DEBUG_GCD bit set.\r
 \r
+  @param  InitialMap  TRUE if the initial GCD Memory Map is being dumped.  Otherwise, FALSE.\r
+  \r
 **/\r
 VOID\r
 EFIAPI\r
 CoreDumpGcdMemorySpaceMap (\r
-  VOID\r
+  BOOLEAN  InitialMap\r
   )\r
 {\r
-  EFI_STATUS                       Status;\r
-  UINTN                            NumberOfDescriptors;\r
-  EFI_GCD_MEMORY_SPACE_DESCRIPTOR  *MemorySpaceMap;\r
-  UINTN                            Index;\r
-  \r
-  Status = CoreGetMemorySpaceMap (&NumberOfDescriptors, &MemorySpaceMap);\r
-  ASSERT_EFI_ERROR (Status);\r
-  \r
-  DEBUG ((DEBUG_GCD, "GCDMemType Range                             Capabilities     Attributes      \n"));\r
-  DEBUG ((DEBUG_GCD, "========== ================================= ================ ================\n"));\r
-  for (Index = 0; Index < NumberOfDescriptors; Index++) {\r
-    DEBUG ((DEBUG_GCD, "%a  %016lx-%016lx %016lx %016lx%c\n", \r
-      mGcdMemoryTypeNames[MIN (MemorySpaceMap[Index].GcdMemoryType, EfiGcdMemoryTypeMaximum)],\r
-      MemorySpaceMap[Index].BaseAddress, \r
-      MemorySpaceMap[Index].BaseAddress + MemorySpaceMap[Index].Length - 1,\r
-      MemorySpaceMap[Index].Capabilities, \r
-      MemorySpaceMap[Index].Attributes,\r
-      MemorySpaceMap[Index].ImageHandle == NULL ? ' ' : '*'\r
-      ));\r
-  }\r
-  DEBUG ((DEBUG_GCD, "\n"));\r
-  FreePool (MemorySpaceMap);\r
+  DEBUG_CODE (\r
+    EFI_STATUS                       Status;\r
+    UINTN                            NumberOfDescriptors;\r
+    EFI_GCD_MEMORY_SPACE_DESCRIPTOR  *MemorySpaceMap;\r
+    UINTN                            Index;\r
+   \r
+    Status = CoreGetMemorySpaceMap (&NumberOfDescriptors, &MemorySpaceMap);\r
+    ASSERT_EFI_ERROR (Status);\r
+\r
+    if (InitialMap) {\r
+      DEBUG ((DEBUG_GCD, "GCD:Initial GCD Memory Space Map\n"));\r
+    }\r
+    DEBUG ((DEBUG_GCD, "GCDMemType Range                             Capabilities     Attributes      \n"));\r
+    DEBUG ((DEBUG_GCD, "========== ================================= ================ ================\n"));\r
+    for (Index = 0; Index < NumberOfDescriptors; Index++) {\r
+      DEBUG ((DEBUG_GCD, "%a  %016lx-%016lx %016lx %016lx%c\n", \r
+        mGcdMemoryTypeNames[MIN (MemorySpaceMap[Index].GcdMemoryType, EfiGcdMemoryTypeMaximum)],\r
+        MemorySpaceMap[Index].BaseAddress, \r
+        MemorySpaceMap[Index].BaseAddress + MemorySpaceMap[Index].Length - 1,\r
+        MemorySpaceMap[Index].Capabilities, \r
+        MemorySpaceMap[Index].Attributes,\r
+        MemorySpaceMap[Index].ImageHandle == NULL ? ' ' : '*'\r
+        ));\r
+    }\r
+    DEBUG ((DEBUG_GCD, "\n"));\r
+    FreePool (MemorySpaceMap);\r
+  );\r
 }\r
 \r
 /**\r
   Dump the entire contents if the GCD I/O Space Map using DEBUG() macros when \r
   PcdDebugPrintErrorLevel has the DEBUG_GCD bit set.\r
 \r
+  @param  InitialMap  TRUE if the initial GCD I/O Map is being dumped.  Otherwise, FALSE.\r
+  \r
 **/\r
 VOID\r
 EFIAPI\r
 CoreDumpGcdIoSpaceMap (\r
-  VOID\r
+  BOOLEAN  InitialMap\r
   )\r
 {\r
-  EFI_STATUS                   Status;\r
-  UINTN                        NumberOfDescriptors;\r
-  EFI_GCD_IO_SPACE_DESCRIPTOR  *IoSpaceMap;\r
-  UINTN                        Index;\r
-  \r
-  Status = CoreGetIoSpaceMap (&NumberOfDescriptors, &IoSpaceMap);\r
-  ASSERT_EFI_ERROR (Status);\r
-  \r
-  DEBUG ((DEBUG_GCD, "GCDIoType  Range                            \n"));\r
-  DEBUG ((DEBUG_GCD, "========== =================================\n"));\r
-  for (Index = 0; Index < NumberOfDescriptors; Index++) {\r
-    DEBUG ((DEBUG_GCD, "%a   %016lx-%016lx%c\n", \r
-      mGcdIoTypeNames[MIN (IoSpaceMap[Index].GcdIoType, EfiGcdIoTypeMaximum)],\r
-      IoSpaceMap[Index].BaseAddress, \r
-      IoSpaceMap[Index].BaseAddress + IoSpaceMap[Index].Length - 1,\r
-      IoSpaceMap[Index].ImageHandle == NULL ? ' ' : '*'\r
-      ));\r
-  }\r
-  DEBUG ((DEBUG_GCD, "\n"));\r
-  FreePool (IoSpaceMap);\r
+  DEBUG_CODE (\r
+    EFI_STATUS                   Status;\r
+    UINTN                        NumberOfDescriptors;\r
+    EFI_GCD_IO_SPACE_DESCRIPTOR  *IoSpaceMap;\r
+    UINTN                        Index;\r
+    \r
+    Status = CoreGetIoSpaceMap (&NumberOfDescriptors, &IoSpaceMap);\r
+    ASSERT_EFI_ERROR (Status);\r
+    \r
+    if (InitialMap) {\r
+      DEBUG ((DEBUG_GCD, "GCD:Initial GCD I/O Space Map\n"));\r
+    }  \r
+    \r
+    DEBUG ((DEBUG_GCD, "GCDIoType  Range                            \n"));\r
+    DEBUG ((DEBUG_GCD, "========== =================================\n"));\r
+    for (Index = 0; Index < NumberOfDescriptors; Index++) {\r
+      DEBUG ((DEBUG_GCD, "%a   %016lx-%016lx%c\n", \r
+        mGcdIoTypeNames[MIN (IoSpaceMap[Index].GcdIoType, EfiGcdIoTypeMaximum)],\r
+        IoSpaceMap[Index].BaseAddress, \r
+        IoSpaceMap[Index].BaseAddress + IoSpaceMap[Index].Length - 1,\r
+        IoSpaceMap[Index].ImageHandle == NULL ? ' ' : '*'\r
+        ));\r
+    }\r
+    DEBUG ((DEBUG_GCD, "\n"));\r
+    FreePool (IoSpaceMap);\r
+  );\r
 }\r
   \r
 \r
@@ -676,9 +691,7 @@ CoreConvertSpace (
   UINT64             CpuArchAttributes;\r
 \r
   if (Length == 0) {\r
-    DEBUG_CODE_BEGIN ();\r
-      DEBUG ((DEBUG_GCD, "  Status = %r\n", EFI_INVALID_PARAMETER));\r
-    DEBUG_CODE_END ();\r
+    DEBUG ((DEBUG_GCD, "  Status = %r\n", EFI_INVALID_PARAMETER));\r
     return EFI_INVALID_PARAMETER;\r
   }\r
 \r
@@ -866,26 +879,15 @@ CoreConvertSpace (
   Status = CoreCleanupGcdMapEntry (TopEntry, BottomEntry, StartLink, EndLink, Map);\r
 \r
 Done:\r
-  DEBUG_CODE_BEGIN ();\r
-    DEBUG ((DEBUG_GCD, "  Status = %r\n", Status));\r
-  DEBUG_CODE_END ();\r
+  DEBUG ((DEBUG_GCD, "  Status = %r\n", Status));\r
 \r
   if ((Operation & GCD_MEMORY_SPACE_OPERATION) != 0) {\r
     CoreReleaseGcdMemoryLock ();\r
-    DEBUG_CODE_BEGIN ();\r
-      //\r
-      // Do not dump GCD Memory Space Map for GCD changes below 16 MB  \r
-      //\r
-      if (BaseAddress >= BASE_16MB) {\r
-        CoreDumpGcdMemorySpaceMap ();\r
-      }\r
-    DEBUG_CODE_END ();\r
+    CoreDumpGcdMemorySpaceMap (FALSE);\r
   }\r
   if ((Operation & GCD_IO_SPACE_OPERATION) != 0) {\r
     CoreReleaseGcdIoLock ();\r
-    DEBUG_CODE_BEGIN ();\r
-      CoreDumpGcdIoSpaceMap ();\r
-    DEBUG_CODE_END ();\r
+    CoreDumpGcdIoSpaceMap (FALSE);\r
   }\r
 \r
   return Status;\r
@@ -984,45 +986,31 @@ CoreAllocateSpace (
   // Make sure parameters are valid\r
   //\r
   if (GcdAllocateType < 0 || GcdAllocateType >= EfiGcdMaxAllocateType) {\r
-    DEBUG_CODE_BEGIN ();\r
-      DEBUG ((DEBUG_GCD, "  Status = %r\n", EFI_INVALID_PARAMETER));\r
-    DEBUG_CODE_END ();\r
+    DEBUG ((DEBUG_GCD, "  Status = %r\n", EFI_INVALID_PARAMETER));\r
     return EFI_INVALID_PARAMETER;\r
   }\r
   if (GcdMemoryType < 0 || GcdMemoryType >= EfiGcdMemoryTypeMaximum) {\r
-    DEBUG_CODE_BEGIN ();\r
-      DEBUG ((DEBUG_GCD, "  Status = %r\n", EFI_INVALID_PARAMETER));\r
-    DEBUG_CODE_END ();\r
+    DEBUG ((DEBUG_GCD, "  Status = %r\n", EFI_INVALID_PARAMETER));\r
     return EFI_INVALID_PARAMETER;\r
   }\r
   if (GcdIoType < 0 || GcdIoType >= EfiGcdIoTypeMaximum) {\r
-    DEBUG_CODE_BEGIN ();\r
-      DEBUG ((DEBUG_GCD, "  Status = %r\n", EFI_INVALID_PARAMETER));\r
-    DEBUG_CODE_END ();\r
+    DEBUG ((DEBUG_GCD, "  Status = %r\n", EFI_INVALID_PARAMETER));\r
     return EFI_INVALID_PARAMETER;\r
   }\r
   if (BaseAddress == NULL) {\r
-    DEBUG_CODE_BEGIN ();\r
-      DEBUG ((DEBUG_GCD, "  Status = %r\n", EFI_INVALID_PARAMETER));\r
-    DEBUG_CODE_END ();\r
+    DEBUG ((DEBUG_GCD, "  Status = %r\n", EFI_INVALID_PARAMETER));\r
     return EFI_INVALID_PARAMETER;\r
   }\r
   if (ImageHandle == NULL) {\r
-    DEBUG_CODE_BEGIN ();\r
-      DEBUG ((DEBUG_GCD, "  Status = %r\n", EFI_INVALID_PARAMETER));\r
-    DEBUG_CODE_END ();\r
+    DEBUG ((DEBUG_GCD, "  Status = %r\n", EFI_INVALID_PARAMETER));\r
     return EFI_INVALID_PARAMETER;\r
   }\r
   if (Alignment >= 64) {\r
-    DEBUG_CODE_BEGIN ();\r
-      DEBUG ((DEBUG_GCD, "  Status = %r\n", EFI_NOT_FOUND));\r
-    DEBUG_CODE_END ();\r
+    DEBUG ((DEBUG_GCD, "  Status = %r\n", EFI_NOT_FOUND));\r
     return EFI_NOT_FOUND;\r
   }\r
   if (Length == 0) {\r
-    DEBUG_CODE_BEGIN ();\r
-      DEBUG ((DEBUG_GCD, "  Status = %r\n", EFI_INVALID_PARAMETER));\r
-    DEBUG_CODE_END ();\r
+    DEBUG ((DEBUG_GCD, "  Status = %r\n", EFI_INVALID_PARAMETER));\r
     return EFI_INVALID_PARAMETER;\r
   }\r
 \r
@@ -1202,32 +1190,21 @@ CoreAllocateSpace (
   Status = CoreCleanupGcdMapEntry (TopEntry, BottomEntry, StartLink, EndLink, Map);\r
 \r
 Done:\r
-  DEBUG_CODE_BEGIN ();\r
-    DEBUG ((DEBUG_GCD, "  Status = %r", Status));\r
-    if (!EFI_ERROR (Status)) {\r
-      DEBUG ((DEBUG_GCD, "  (BaseAddress = %016lx)\n", *BaseAddress));\r
-    }\r
-    DEBUG ((DEBUG_GCD, "\n"));\r
-  DEBUG_CODE_END ();\r
+  DEBUG ((DEBUG_GCD, "  Status = %r", Status));\r
+  if (!EFI_ERROR (Status)) {\r
+    DEBUG ((DEBUG_GCD, "  (BaseAddress = %016lx)", *BaseAddress));\r
+  }\r
+  DEBUG ((DEBUG_GCD, "\n"));\r
   \r
   if ((Operation & GCD_MEMORY_SPACE_OPERATION) != 0) {\r
     CoreReleaseGcdMemoryLock ();\r
-    DEBUG_CODE_BEGIN ();\r
-      //\r
-      // Do not dump GCD Memory Space Map for GCD changes below 16 MB  \r
-      //\r
-      if (*BaseAddress >= BASE_16MB) {\r
-        CoreDumpGcdMemorySpaceMap ();\r
-      }\r
-    DEBUG_CODE_END ();\r
+    CoreDumpGcdMemorySpaceMap (FALSE);\r
   }\r
   if ((Operation & GCD_IO_SPACE_OPERATION) !=0) {\r
     CoreReleaseGcdIoLock ();\r
-    DEBUG_CODE_BEGIN ();\r
-      CoreDumpGcdIoSpaceMap ();\r
-    DEBUG_CODE_END ();\r
+    CoreDumpGcdIoSpaceMap (FALSE);\r
   }\r
-  \r
+\r
   return Status;\r
 }\r
 \r
@@ -1881,6 +1858,7 @@ Done:
   return Status;\r
 }\r
 \r
+\r
 /**\r
   Converts a Resource Descriptor HOB attributes mask to an EFI Memory Descriptor\r
   capabilities mask\r
@@ -2204,10 +2182,7 @@ CoreInitializeGcdServices (
 \r
   InsertHeadList (&mGcdMemorySpaceMap, &Entry->Link);\r
 \r
-  DEBUG_CODE_BEGIN ();\r
-    DEBUG ((DEBUG_GCD, "GCD:Initial GCD Memory Space Map\n"));\r
-    CoreDumpGcdMemorySpaceMap ();\r
-  DEBUG_CODE_END ();\r
+  CoreDumpGcdMemorySpaceMap (TRUE);\r
   \r
   //\r
   // Initialize the GCD I/O Space Map\r
@@ -2219,10 +2194,7 @@ CoreInitializeGcdServices (
 \r
   InsertHeadList (&mGcdIoSpaceMap, &Entry->Link);\r
 \r
-  DEBUG_CODE_BEGIN ();\r
-    DEBUG ((DEBUG_GCD, "GCD:Initial GCD I/O Space Map\n"));\r
-    CoreDumpGcdIoSpaceMap ();\r
-  DEBUG_CODE_END ();\r
+  CoreDumpGcdIoSpaceMap (TRUE);\r
   \r
   //\r
   // Walk the HOB list and add all resource descriptors to the GCD\r