Clean up GCD DEBUG() macros so DEBUG_CODE() is only used to enable/disable the DBG MMIO and GCD I/O map dumps

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@11243 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
mdkinney 2011-01-11 23:11:23 +00:00
parent b452ca8992
commit aa927cae81
1 changed files with 81 additions and 109 deletions

View File

@ -132,13 +132,16 @@ GLOBAL_REMOVE_IF_UNREFERENCED CONST CHAR8 *mGcdAllocationTypeNames[] = {
Dump the entire contents if the GCD Memory Space Map using DEBUG() macros when Dump the entire contents if the GCD Memory Space Map using DEBUG() macros when
PcdDebugPrintErrorLevel has the DEBUG_GCD bit set. PcdDebugPrintErrorLevel has the DEBUG_GCD bit set.
@param InitialMap TRUE if the initial GCD Memory Map is being dumped. Otherwise, FALSE.
**/ **/
VOID VOID
EFIAPI EFIAPI
CoreDumpGcdMemorySpaceMap ( CoreDumpGcdMemorySpaceMap (
VOID BOOLEAN InitialMap
) )
{ {
DEBUG_CODE (
EFI_STATUS Status; EFI_STATUS Status;
UINTN NumberOfDescriptors; UINTN NumberOfDescriptors;
EFI_GCD_MEMORY_SPACE_DESCRIPTOR *MemorySpaceMap; EFI_GCD_MEMORY_SPACE_DESCRIPTOR *MemorySpaceMap;
@ -147,6 +150,9 @@ CoreDumpGcdMemorySpaceMap (
Status = CoreGetMemorySpaceMap (&NumberOfDescriptors, &MemorySpaceMap); Status = CoreGetMemorySpaceMap (&NumberOfDescriptors, &MemorySpaceMap);
ASSERT_EFI_ERROR (Status); ASSERT_EFI_ERROR (Status);
if (InitialMap) {
DEBUG ((DEBUG_GCD, "GCD:Initial GCD Memory Space Map\n"));
}
DEBUG ((DEBUG_GCD, "GCDMemType Range Capabilities Attributes \n")); DEBUG ((DEBUG_GCD, "GCDMemType Range Capabilities Attributes \n"));
DEBUG ((DEBUG_GCD, "========== ================================= ================ ================\n")); DEBUG ((DEBUG_GCD, "========== ================================= ================ ================\n"));
for (Index = 0; Index < NumberOfDescriptors; Index++) { for (Index = 0; Index < NumberOfDescriptors; Index++) {
@ -161,19 +167,23 @@ CoreDumpGcdMemorySpaceMap (
} }
DEBUG ((DEBUG_GCD, "\n")); DEBUG ((DEBUG_GCD, "\n"));
FreePool (MemorySpaceMap); FreePool (MemorySpaceMap);
);
} }
/** /**
Dump the entire contents if the GCD I/O Space Map using DEBUG() macros when Dump the entire contents if the GCD I/O Space Map using DEBUG() macros when
PcdDebugPrintErrorLevel has the DEBUG_GCD bit set. PcdDebugPrintErrorLevel has the DEBUG_GCD bit set.
@param InitialMap TRUE if the initial GCD I/O Map is being dumped. Otherwise, FALSE.
**/ **/
VOID VOID
EFIAPI EFIAPI
CoreDumpGcdIoSpaceMap ( CoreDumpGcdIoSpaceMap (
VOID BOOLEAN InitialMap
) )
{ {
DEBUG_CODE (
EFI_STATUS Status; EFI_STATUS Status;
UINTN NumberOfDescriptors; UINTN NumberOfDescriptors;
EFI_GCD_IO_SPACE_DESCRIPTOR *IoSpaceMap; EFI_GCD_IO_SPACE_DESCRIPTOR *IoSpaceMap;
@ -182,6 +192,10 @@ CoreDumpGcdIoSpaceMap (
Status = CoreGetIoSpaceMap (&NumberOfDescriptors, &IoSpaceMap); Status = CoreGetIoSpaceMap (&NumberOfDescriptors, &IoSpaceMap);
ASSERT_EFI_ERROR (Status); ASSERT_EFI_ERROR (Status);
if (InitialMap) {
DEBUG ((DEBUG_GCD, "GCD:Initial GCD I/O Space Map\n"));
}
DEBUG ((DEBUG_GCD, "GCDIoType Range \n")); DEBUG ((DEBUG_GCD, "GCDIoType Range \n"));
DEBUG ((DEBUG_GCD, "========== =================================\n")); DEBUG ((DEBUG_GCD, "========== =================================\n"));
for (Index = 0; Index < NumberOfDescriptors; Index++) { for (Index = 0; Index < NumberOfDescriptors; Index++) {
@ -194,6 +208,7 @@ CoreDumpGcdIoSpaceMap (
} }
DEBUG ((DEBUG_GCD, "\n")); DEBUG ((DEBUG_GCD, "\n"));
FreePool (IoSpaceMap); FreePool (IoSpaceMap);
);
} }
@ -676,9 +691,7 @@ CoreConvertSpace (
UINT64 CpuArchAttributes; UINT64 CpuArchAttributes;
if (Length == 0) { if (Length == 0) {
DEBUG_CODE_BEGIN ();
DEBUG ((DEBUG_GCD, " Status = %r\n", EFI_INVALID_PARAMETER)); DEBUG ((DEBUG_GCD, " Status = %r\n", EFI_INVALID_PARAMETER));
DEBUG_CODE_END ();
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
@ -866,26 +879,15 @@ CoreConvertSpace (
Status = CoreCleanupGcdMapEntry (TopEntry, BottomEntry, StartLink, EndLink, Map); Status = CoreCleanupGcdMapEntry (TopEntry, BottomEntry, StartLink, EndLink, Map);
Done: Done:
DEBUG_CODE_BEGIN ();
DEBUG ((DEBUG_GCD, " Status = %r\n", Status)); DEBUG ((DEBUG_GCD, " Status = %r\n", Status));
DEBUG_CODE_END ();
if ((Operation & GCD_MEMORY_SPACE_OPERATION) != 0) { if ((Operation & GCD_MEMORY_SPACE_OPERATION) != 0) {
CoreReleaseGcdMemoryLock (); CoreReleaseGcdMemoryLock ();
DEBUG_CODE_BEGIN (); CoreDumpGcdMemorySpaceMap (FALSE);
//
// Do not dump GCD Memory Space Map for GCD changes below 16 MB
//
if (BaseAddress >= BASE_16MB) {
CoreDumpGcdMemorySpaceMap ();
}
DEBUG_CODE_END ();
} }
if ((Operation & GCD_IO_SPACE_OPERATION) != 0) { if ((Operation & GCD_IO_SPACE_OPERATION) != 0) {
CoreReleaseGcdIoLock (); CoreReleaseGcdIoLock ();
DEBUG_CODE_BEGIN (); CoreDumpGcdIoSpaceMap (FALSE);
CoreDumpGcdIoSpaceMap ();
DEBUG_CODE_END ();
} }
return Status; return Status;
@ -984,45 +986,31 @@ CoreAllocateSpace (
// Make sure parameters are valid // Make sure parameters are valid
// //
if (GcdAllocateType < 0 || GcdAllocateType >= EfiGcdMaxAllocateType) { if (GcdAllocateType < 0 || GcdAllocateType >= EfiGcdMaxAllocateType) {
DEBUG_CODE_BEGIN ();
DEBUG ((DEBUG_GCD, " Status = %r\n", EFI_INVALID_PARAMETER)); DEBUG ((DEBUG_GCD, " Status = %r\n", EFI_INVALID_PARAMETER));
DEBUG_CODE_END ();
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
if (GcdMemoryType < 0 || GcdMemoryType >= EfiGcdMemoryTypeMaximum) { if (GcdMemoryType < 0 || GcdMemoryType >= EfiGcdMemoryTypeMaximum) {
DEBUG_CODE_BEGIN ();
DEBUG ((DEBUG_GCD, " Status = %r\n", EFI_INVALID_PARAMETER)); DEBUG ((DEBUG_GCD, " Status = %r\n", EFI_INVALID_PARAMETER));
DEBUG_CODE_END ();
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
if (GcdIoType < 0 || GcdIoType >= EfiGcdIoTypeMaximum) { if (GcdIoType < 0 || GcdIoType >= EfiGcdIoTypeMaximum) {
DEBUG_CODE_BEGIN ();
DEBUG ((DEBUG_GCD, " Status = %r\n", EFI_INVALID_PARAMETER)); DEBUG ((DEBUG_GCD, " Status = %r\n", EFI_INVALID_PARAMETER));
DEBUG_CODE_END ();
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
if (BaseAddress == NULL) { if (BaseAddress == NULL) {
DEBUG_CODE_BEGIN ();
DEBUG ((DEBUG_GCD, " Status = %r\n", EFI_INVALID_PARAMETER)); DEBUG ((DEBUG_GCD, " Status = %r\n", EFI_INVALID_PARAMETER));
DEBUG_CODE_END ();
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
if (ImageHandle == NULL) { if (ImageHandle == NULL) {
DEBUG_CODE_BEGIN ();
DEBUG ((DEBUG_GCD, " Status = %r\n", EFI_INVALID_PARAMETER)); DEBUG ((DEBUG_GCD, " Status = %r\n", EFI_INVALID_PARAMETER));
DEBUG_CODE_END ();
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
if (Alignment >= 64) { if (Alignment >= 64) {
DEBUG_CODE_BEGIN ();
DEBUG ((DEBUG_GCD, " Status = %r\n", EFI_NOT_FOUND)); DEBUG ((DEBUG_GCD, " Status = %r\n", EFI_NOT_FOUND));
DEBUG_CODE_END ();
return EFI_NOT_FOUND; return EFI_NOT_FOUND;
} }
if (Length == 0) { if (Length == 0) {
DEBUG_CODE_BEGIN ();
DEBUG ((DEBUG_GCD, " Status = %r\n", EFI_INVALID_PARAMETER)); DEBUG ((DEBUG_GCD, " Status = %r\n", EFI_INVALID_PARAMETER));
DEBUG_CODE_END ();
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
@ -1202,30 +1190,19 @@ CoreAllocateSpace (
Status = CoreCleanupGcdMapEntry (TopEntry, BottomEntry, StartLink, EndLink, Map); Status = CoreCleanupGcdMapEntry (TopEntry, BottomEntry, StartLink, EndLink, Map);
Done: Done:
DEBUG_CODE_BEGIN ();
DEBUG ((DEBUG_GCD, " Status = %r", Status)); DEBUG ((DEBUG_GCD, " Status = %r", Status));
if (!EFI_ERROR (Status)) { if (!EFI_ERROR (Status)) {
DEBUG ((DEBUG_GCD, " (BaseAddress = %016lx)\n", *BaseAddress)); DEBUG ((DEBUG_GCD, " (BaseAddress = %016lx)", *BaseAddress));
} }
DEBUG ((DEBUG_GCD, "\n")); DEBUG ((DEBUG_GCD, "\n"));
DEBUG_CODE_END ();
if ((Operation & GCD_MEMORY_SPACE_OPERATION) != 0) { if ((Operation & GCD_MEMORY_SPACE_OPERATION) != 0) {
CoreReleaseGcdMemoryLock (); CoreReleaseGcdMemoryLock ();
DEBUG_CODE_BEGIN (); CoreDumpGcdMemorySpaceMap (FALSE);
//
// Do not dump GCD Memory Space Map for GCD changes below 16 MB
//
if (*BaseAddress >= BASE_16MB) {
CoreDumpGcdMemorySpaceMap ();
}
DEBUG_CODE_END ();
} }
if ((Operation & GCD_IO_SPACE_OPERATION) !=0) { if ((Operation & GCD_IO_SPACE_OPERATION) !=0) {
CoreReleaseGcdIoLock (); CoreReleaseGcdIoLock ();
DEBUG_CODE_BEGIN (); CoreDumpGcdIoSpaceMap (FALSE);
CoreDumpGcdIoSpaceMap ();
DEBUG_CODE_END ();
} }
return Status; return Status;
@ -1881,6 +1858,7 @@ Done:
return Status; return Status;
} }
/** /**
Converts a Resource Descriptor HOB attributes mask to an EFI Memory Descriptor Converts a Resource Descriptor HOB attributes mask to an EFI Memory Descriptor
capabilities mask capabilities mask
@ -2204,10 +2182,7 @@ CoreInitializeGcdServices (
InsertHeadList (&mGcdMemorySpaceMap, &Entry->Link); InsertHeadList (&mGcdMemorySpaceMap, &Entry->Link);
DEBUG_CODE_BEGIN (); CoreDumpGcdMemorySpaceMap (TRUE);
DEBUG ((DEBUG_GCD, "GCD:Initial GCD Memory Space Map\n"));
CoreDumpGcdMemorySpaceMap ();
DEBUG_CODE_END ();
// //
// Initialize the GCD I/O Space Map // Initialize the GCD I/O Space Map
@ -2219,10 +2194,7 @@ CoreInitializeGcdServices (
InsertHeadList (&mGcdIoSpaceMap, &Entry->Link); InsertHeadList (&mGcdIoSpaceMap, &Entry->Link);
DEBUG_CODE_BEGIN (); CoreDumpGcdIoSpaceMap (TRUE);
DEBUG ((DEBUG_GCD, "GCD:Initial GCD I/O Space Map\n"));
CoreDumpGcdIoSpaceMap ();
DEBUG_CODE_END ();
// //
// Walk the HOB list and add all resource descriptors to the GCD // Walk the HOB list and add all resource descriptors to the GCD