mirror of https://github.com/acidanthera/audk.git
Code scrub for PeiDxeDebugLibReportStatusCode.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@8594 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
parent
f88b7fd42e
commit
9ba6cd30fa
|
@ -1,7 +1,7 @@
|
||||||
/** @file
|
/** @file
|
||||||
Debug Library that fowards all messages to ReportStatusCode()
|
Debug Library based on report status code library.
|
||||||
|
|
||||||
Copyright (c) 2006, Intel Corporation<BR>
|
Copyright (c) 2006 - 2009, Intel Corporation<BR>
|
||||||
All rights reserved. This program and the accompanying materials
|
All rights reserved. This program and the accompanying materials
|
||||||
are licensed and made available under the terms and conditions of the BSD License
|
are licensed and made available under the terms and conditions of the BSD License
|
||||||
which accompanies this distribution. The full text of the license may be found at
|
which accompanies this distribution. The full text of the license may be found at
|
||||||
|
@ -25,7 +25,6 @@
|
||||||
#include <Library/PcdLib.h>
|
#include <Library/PcdLib.h>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
||||||
Prints a debug message to the debug output device if the specified error level is enabled.
|
Prints a debug message to the debug output device if the specified error level is enabled.
|
||||||
|
|
||||||
If any bit in ErrorLevel is also set in PcdDebugPrintErrorLevel, then print
|
If any bit in ErrorLevel is also set in PcdDebugPrintErrorLevel, then print
|
||||||
|
@ -65,14 +64,14 @@ DebugPrint (
|
||||||
//
|
//
|
||||||
// Check driver Debug Level value and global debug level
|
// Check driver Debug Level value and global debug level
|
||||||
//
|
//
|
||||||
if ((ErrorLevel & PcdGet32(PcdDebugPrintErrorLevel)) == 0) {
|
if ((ErrorLevel & PcdGet32 (PcdDebugPrintErrorLevel)) == 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Compute the total size of the record
|
// Compute the total size of the record
|
||||||
//
|
//
|
||||||
TotalSize = sizeof (EFI_DEBUG_INFO) + 12 * sizeof (UINT64) + AsciiStrLen (Format) + 1;
|
TotalSize = sizeof (EFI_DEBUG_INFO) + 12 * sizeof (UINT64) + AsciiStrSize (Format);
|
||||||
|
|
||||||
//
|
//
|
||||||
// If the TotalSize is larger than the maximum record size, then return
|
// If the TotalSize is larger than the maximum record size, then return
|
||||||
|
@ -84,6 +83,11 @@ DebugPrint (
|
||||||
//
|
//
|
||||||
// Fill in EFI_DEBUG_INFO
|
// Fill in EFI_DEBUG_INFO
|
||||||
//
|
//
|
||||||
|
// Here we skip the first 4 bytes of Buffer, because we must ensure BaseListMarker is
|
||||||
|
// 64-bit aligned, otherwise retrieving 64-bit parameter from BaseListMarker will cause
|
||||||
|
// exception on IPF. Buffer starts at 64-bit aligned address, so skipping 4 types (sizeof(EFI_DEBUG_INFO))
|
||||||
|
// just makes addess of BaseListMarker, which follows DebugInfo, 64-bit aligned.
|
||||||
|
//
|
||||||
DebugInfo = (EFI_DEBUG_INFO *)(Buffer) + 1;
|
DebugInfo = (EFI_DEBUG_INFO *)(Buffer) + 1;
|
||||||
DebugInfo->ErrorLevel = (UINT32)ErrorLevel;
|
DebugInfo->ErrorLevel = (UINT32)ErrorLevel;
|
||||||
BaseListMarker = (BASE_LIST)(DebugInfo + 1);
|
BaseListMarker = (BASE_LIST)(DebugInfo + 1);
|
||||||
|
@ -95,10 +99,15 @@ DebugPrint (
|
||||||
AsciiStrCpy (FormatString, Format);
|
AsciiStrCpy (FormatString, Format);
|
||||||
|
|
||||||
//
|
//
|
||||||
// 256 byte mini Var Arg stack. That is followed by the format string.
|
// The first 12 * sizeof (UINT64) bytes following EFI_DEBUG_INFO are for variable arguments
|
||||||
|
// of format in DEBUG string, which is followed by the DEBUG format string.
|
||||||
|
// Here we will process the variable arguments and pack them in this area.
|
||||||
//
|
//
|
||||||
VA_START (VaListMarker, Format);
|
VA_START (VaListMarker, Format);
|
||||||
for (; *Format != '\0'; Format++) {
|
for (; *Format != '\0'; Format++) {
|
||||||
|
//
|
||||||
|
// Only format with prefix % is processed.
|
||||||
|
//
|
||||||
if (*Format != '%') {
|
if (*Format != '%') {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -124,12 +133,22 @@ DebugPrint (
|
||||||
case '7':
|
case '7':
|
||||||
case '8':
|
case '8':
|
||||||
case '9':
|
case '9':
|
||||||
|
//
|
||||||
|
// These characters in format field are omitted.
|
||||||
|
//
|
||||||
break;
|
break;
|
||||||
case 'L':
|
case 'L':
|
||||||
case 'l':
|
case 'l':
|
||||||
|
//
|
||||||
|
// 'L" or "l" in format field means the number being printed is a UINT64
|
||||||
|
//
|
||||||
Long = TRUE;
|
Long = TRUE;
|
||||||
break;
|
break;
|
||||||
case '*':
|
case '*':
|
||||||
|
//
|
||||||
|
// '*' in format field means the precision of the field is specified by
|
||||||
|
// a UINTN argument in the argument list.
|
||||||
|
//
|
||||||
BASE_ARG (BaseListMarker, UINTN) = VA_ARG (VaListMarker, UINTN);
|
BASE_ARG (BaseListMarker, UINTN) = VA_ARG (VaListMarker, UINTN);
|
||||||
break;
|
break;
|
||||||
case '\0':
|
case '\0':
|
||||||
|
@ -142,13 +161,17 @@ DebugPrint (
|
||||||
// break skipped on purpose.
|
// break skipped on purpose.
|
||||||
//
|
//
|
||||||
default:
|
default:
|
||||||
|
//
|
||||||
|
// When valid argument type detected or format string terminates unexpectedly,
|
||||||
|
// the inner loop is done.
|
||||||
|
//
|
||||||
Done = TRUE;
|
Done = TRUE;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Handle each argument type
|
// Pack variable arguments into the storage area following EFI_DEBUG_INFO.
|
||||||
//
|
//
|
||||||
switch (*Format) {
|
switch (*Format) {
|
||||||
case 'p':
|
case 'p':
|
||||||
|
@ -210,7 +233,6 @@ DebugPrint (
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
||||||
Prints an assert message containing a filename, line number, and description.
|
Prints an assert message containing a filename, line number, and description.
|
||||||
This may be followed by a breakpoint or a dead loop.
|
This may be followed by a breakpoint or a dead loop.
|
||||||
|
|
||||||
|
@ -224,7 +246,6 @@ DebugPrint (
|
||||||
processing another DebugAssert(), then DebugAssert() must return immediately.
|
processing another DebugAssert(), then DebugAssert() must return immediately.
|
||||||
|
|
||||||
If FileName is NULL, then a <FileName> string of "(NULL) Filename" is printed.
|
If FileName is NULL, then a <FileName> string of "(NULL) Filename" is printed.
|
||||||
|
|
||||||
If Description is NULL, then a <Description> string of "(NULL) Description" is printed.
|
If Description is NULL, then a <Description> string of "(NULL) Description" is printed.
|
||||||
|
|
||||||
@param FileName Pointer to the name of the source file that generated the assert condition.
|
@param FileName Pointer to the name of the source file that generated the assert condition.
|
||||||
|
@ -244,15 +265,15 @@ DebugAssert (
|
||||||
EFI_DEBUG_ASSERT_DATA *AssertData;
|
EFI_DEBUG_ASSERT_DATA *AssertData;
|
||||||
UINTN TotalSize;
|
UINTN TotalSize;
|
||||||
CHAR8 *Temp;
|
CHAR8 *Temp;
|
||||||
UINTN FileNameLength;
|
UINTN FileNameSize;
|
||||||
UINTN DescriptionLength;
|
UINTN DescriptionSize;
|
||||||
|
|
||||||
//
|
//
|
||||||
// Make sure it will all fit in the passed in buffer
|
// Make sure it will all fit in the passed in buffer
|
||||||
//
|
//
|
||||||
FileNameLength = AsciiStrLen (FileName);
|
FileNameSize = AsciiStrSize (FileName);
|
||||||
DescriptionLength = AsciiStrLen (Description);
|
DescriptionSize = AsciiStrSize (Description);
|
||||||
TotalSize = sizeof (EFI_DEBUG_ASSERT_DATA) + FileNameLength + 1 + DescriptionLength + 1;
|
TotalSize = sizeof (EFI_DEBUG_ASSERT_DATA) + FileNameSize + DescriptionSize;
|
||||||
if (TotalSize <= sizeof (Buffer)) {
|
if (TotalSize <= sizeof (Buffer)) {
|
||||||
//
|
//
|
||||||
// Fill in EFI_DEBUG_ASSERT_DATA
|
// Fill in EFI_DEBUG_ASSERT_DATA
|
||||||
|
@ -268,7 +289,7 @@ DebugAssert (
|
||||||
//
|
//
|
||||||
// Copy Ascii Description
|
// Copy Ascii Description
|
||||||
//
|
//
|
||||||
AsciiStrCpy (Temp + AsciiStrLen (FileName) + 1, Description);
|
AsciiStrCpy (Temp + FileNameSize, Description);
|
||||||
|
|
||||||
REPORT_STATUS_CODE_EX (
|
REPORT_STATUS_CODE_EX (
|
||||||
(EFI_ERROR_CODE | EFI_ERROR_UNRECOVERED),
|
(EFI_ERROR_CODE | EFI_ERROR_UNRECOVERED),
|
||||||
|
@ -284,29 +305,27 @@ DebugAssert (
|
||||||
//
|
//
|
||||||
// Generate a Breakpoint, DeadLoop, or NOP based on PCD settings
|
// Generate a Breakpoint, DeadLoop, or NOP based on PCD settings
|
||||||
//
|
//
|
||||||
if ((PcdGet8(PcdDebugPropertyMask) & DEBUG_PROPERTY_ASSERT_BREAKPOINT_ENABLED) != 0) {
|
if ((PcdGet8 (PcdDebugPropertyMask) & DEBUG_PROPERTY_ASSERT_BREAKPOINT_ENABLED) != 0) {
|
||||||
CpuBreakpoint ();
|
CpuBreakpoint ();
|
||||||
} else if ((PcdGet8(PcdDebugPropertyMask) & DEBUG_PROPERTY_ASSERT_DEADLOOP_ENABLED) != 0) {
|
} else if ((PcdGet8 (PcdDebugPropertyMask) & DEBUG_PROPERTY_ASSERT_DEADLOOP_ENABLED) != 0) {
|
||||||
CpuDeadLoop ();
|
CpuDeadLoop ();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
||||||
Fills a target buffer with PcdDebugClearMemoryValue, and returns the target buffer.
|
Fills a target buffer with PcdDebugClearMemoryValue, and returns the target buffer.
|
||||||
|
|
||||||
This function fills Length bytes of Buffer with the value specified by
|
This function fills Length bytes of Buffer with the value specified by
|
||||||
PcdDebugClearMemoryValue, and returns Buffer.
|
PcdDebugClearMemoryValue, and returns Buffer.
|
||||||
|
|
||||||
If Buffer is NULL, then ASSERT().
|
If Buffer is NULL, then ASSERT().
|
||||||
|
If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
|
||||||
|
|
||||||
If Length is greater than (MAX_ADDRESS ? Buffer + 1), then ASSERT().
|
@param Buffer Pointer to the target buffer to be filled with PcdDebugClearMemoryValue.
|
||||||
|
|
||||||
@param Buffer Pointer to the target buffer to fill with PcdDebugClearMemoryValue.
|
|
||||||
@param Length Number of bytes in Buffer to fill with zeros PcdDebugClearMemoryValue.
|
@param Length Number of bytes in Buffer to fill with zeros PcdDebugClearMemoryValue.
|
||||||
|
|
||||||
@return Buffer
|
@return Buffer Pointer to the target buffer filled with PcdDebugClearMemoryValue.
|
||||||
|
|
||||||
**/
|
**/
|
||||||
VOID *
|
VOID *
|
||||||
|
@ -316,20 +335,13 @@ DebugClearMemory (
|
||||||
IN UINTN Length
|
IN UINTN Length
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
//
|
|
||||||
// If Buffer is NULL, then ASSERT().
|
|
||||||
//
|
|
||||||
ASSERT (Buffer != NULL);
|
ASSERT (Buffer != NULL);
|
||||||
|
|
||||||
//
|
return SetMem (Buffer, Length, PcdGet8 (PcdDebugClearMemoryValue));
|
||||||
// SetMem() checks for the the ASSERT() condition on Length and returns Buffer
|
|
||||||
//
|
|
||||||
return SetMem (Buffer, Length, PcdGet8(PcdDebugClearMemoryValue));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
||||||
Returns TRUE if ASSERT() macros are enabled.
|
Returns TRUE if ASSERT() macros are enabled.
|
||||||
|
|
||||||
This function returns TRUE if the DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED bit of
|
This function returns TRUE if the DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED bit of
|
||||||
|
@ -345,13 +357,13 @@ DebugAssertEnabled (
|
||||||
VOID
|
VOID
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
return (BOOLEAN) ((PcdGet8(PcdDebugPropertyMask) & DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED) != 0);
|
__asm int 3
|
||||||
|
return (BOOLEAN) ((PcdGet8 (PcdDebugPropertyMask) & DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED) != 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Returns TRUE if DEBUG() macros are enabled.
|
||||||
Returns TRUE if DEBUG()macros are enabled.
|
|
||||||
|
|
||||||
This function returns TRUE if the DEBUG_PROPERTY_DEBUG_PRINT_ENABLED bit of
|
This function returns TRUE if the DEBUG_PROPERTY_DEBUG_PRINT_ENABLED bit of
|
||||||
PcdDebugProperyMask is set. Otherwise FALSE is returned.
|
PcdDebugProperyMask is set. Otherwise FALSE is returned.
|
||||||
|
@ -366,13 +378,12 @@ DebugPrintEnabled (
|
||||||
VOID
|
VOID
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
return (BOOLEAN) ((PcdGet8(PcdDebugPropertyMask) & DEBUG_PROPERTY_DEBUG_PRINT_ENABLED) != 0);
|
return (BOOLEAN) ((PcdGet8 (PcdDebugPropertyMask) & DEBUG_PROPERTY_DEBUG_PRINT_ENABLED) != 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Returns TRUE if DEBUG_CODE() macros are enabled.
|
||||||
Returns TRUE if DEBUG_CODE()macros are enabled.
|
|
||||||
|
|
||||||
This function returns TRUE if the DEBUG_PROPERTY_DEBUG_CODE_ENABLED bit of
|
This function returns TRUE if the DEBUG_PROPERTY_DEBUG_CODE_ENABLED bit of
|
||||||
PcdDebugProperyMask is set. Otherwise FALSE is returned.
|
PcdDebugProperyMask is set. Otherwise FALSE is returned.
|
||||||
|
@ -387,19 +398,18 @@ DebugCodeEnabled (
|
||||||
VOID
|
VOID
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
return (BOOLEAN) ((PcdGet8(PcdDebugPropertyMask) & DEBUG_PROPERTY_DEBUG_CODE_ENABLED) != 0);
|
return (BOOLEAN) ((PcdGet8 (PcdDebugPropertyMask) & DEBUG_PROPERTY_DEBUG_CODE_ENABLED) != 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Returns TRUE if DEBUG_CLEAR_MEMORY() macro is enabled.
|
||||||
|
|
||||||
Returns TRUE if DEBUG_CLEAR_MEMORY()macro is enabled.
|
This function returns TRUE if the DEBUG_PROPERTY_CLEAR_MEMORY_ENABLED bit of
|
||||||
|
|
||||||
This function returns TRUE if the DEBUG_PROPERTY_DEBUG_CLEAR_MEMORY_ENABLED bit of
|
|
||||||
PcdDebugProperyMask is set. Otherwise FALSE is returned.
|
PcdDebugProperyMask is set. Otherwise FALSE is returned.
|
||||||
|
|
||||||
@retval TRUE The DEBUG_PROPERTY_DEBUG_CLEAR_MEMORY_ENABLED bit of PcdDebugProperyMask is set.
|
@retval TRUE The DEBUG_PROPERTY_CLEAR_MEMORY_ENABLED bit of PcdDebugProperyMask is set.
|
||||||
@retval FALSE The DEBUG_PROPERTY_DEBUG_CLEAR_MEMORY_ENABLED bit of PcdDebugProperyMask is clear.
|
@retval FALSE The DEBUG_PROPERTY_CLEAR_MEMORY_ENABLED bit of PcdDebugProperyMask is clear.
|
||||||
|
|
||||||
**/
|
**/
|
||||||
BOOLEAN
|
BOOLEAN
|
||||||
|
@ -408,5 +418,5 @@ DebugClearMemoryEnabled (
|
||||||
VOID
|
VOID
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
return (BOOLEAN) ((PcdGet8(PcdDebugPropertyMask) & DEBUG_PROPERTY_CLEAR_MEMORY_ENABLED) != 0);
|
return (BOOLEAN) ((PcdGet8 (PcdDebugPropertyMask) & DEBUG_PROPERTY_CLEAR_MEMORY_ENABLED) != 0);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#/** @file
|
#/** @file
|
||||||
# Debug Library based on report status code library
|
# Debug Library based on report status code library
|
||||||
#
|
#
|
||||||
# Debug Library for PEIMs and DXE drivers that send debug messages to ReportStatusCode
|
# Debug Library for PEIMs and DXE drivers that sends debug messages to ReportStatusCode
|
||||||
# Copyright (c) 2006 - 2009, Intel Corporation.
|
# Copyright (c) 2006 - 2009, Intel Corporation.
|
||||||
#
|
#
|
||||||
# All rights reserved. This program and the accompanying materials
|
# All rights reserved. This program and the accompanying materials
|
||||||
|
@ -21,7 +21,6 @@
|
||||||
MODULE_TYPE = PEIM
|
MODULE_TYPE = PEIM
|
||||||
VERSION_STRING = 1.0
|
VERSION_STRING = 1.0
|
||||||
LIBRARY_CLASS = DebugLib|DXE_CORE DXE_DRIVER DXE_RUNTIME_DRIVER DXE_SAL_DRIVER DXE_SMM_DRIVER PEIM SEC PEI_CORE UEFI_APPLICATION UEFI_DRIVER
|
LIBRARY_CLASS = DebugLib|DXE_CORE DXE_DRIVER DXE_RUNTIME_DRIVER DXE_SAL_DRIVER DXE_SMM_DRIVER PEIM SEC PEI_CORE UEFI_APPLICATION UEFI_DRIVER
|
||||||
EFI_SPECIFICATION_VERSION = 0x00020000
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# The following information is for reference only and not required by the build tools.
|
# The following information is for reference only and not required by the build tools.
|
||||||
|
@ -50,6 +49,6 @@
|
||||||
gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask
|
gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask
|
||||||
|
|
||||||
[Guids.common]
|
[Guids.common]
|
||||||
gEfiStatusCodeDataTypeDebugGuid
|
gEfiStatusCodeDataTypeDebugGuid ## CONSUMES
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue