From: qhuang8 Date: Tue, 13 Jun 2006 06:31:11 +0000 (+0000) Subject: BaseMemoryLib (BaseMemoryLibRepStr): X-Git-Tag: edk2-stable201903~25265 X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=commitdiff_plain;h=8960cdebac8c75f13f1cb6afa932f0ae323a138b BaseMemoryLib (BaseMemoryLibRepStr): Fix a logic error in SetMem64 (); The correct stride should be 8 instead of 4. BasePrintLib: Fix Printf(“%\n”) passer error. Fix BufferSize = 0, 1 issue Fix some missing ASSERT ()s Move MAXIMUM_VALUE_CHARACTERS from PrintLibInternal.h to PrintLib.h ReportStatusCodeLib: Add CONST modifier to some interfaces Modify DebugLib: Replace some Unicode in comments. PeiServicesTablePointerLib Add ASSERT()s PciLib: Remove unnecessary ASSERT()s in PciRead/WriteBuffer() git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@496 6f19259b-4bc3-4df7-8a09-765794883524 --- diff --git a/MdePkg/Include/Library/DebugLib.h b/MdePkg/Include/Library/DebugLib.h index 5efb304016..b1d320057f 100644 --- a/MdePkg/Include/Library/DebugLib.h +++ b/MdePkg/Include/Library/DebugLib.h @@ -72,7 +72,7 @@ DebugPrint ( Prints an assert message containing a filename, line number, and description. This may be followed by a breakpoint or a dead loop. - Print a message of the form “ASSERT (): \n? + Print a message of the form "ASSERT (): \n" to the debug output device. If DEBUG_PROPERTY_ASSERT_BREAKPOINT_ENABLED bit of PcdDebugProperyMask is set then CpuBreakpoint() is called. Otherwise, if DEBUG_PROPERTY_ASSERT_DEADLOOP_ENABLED bit of PcdDebugProperyMask is set then @@ -411,7 +411,7 @@ DebugClearMemoryEnabled ( by TYPE is compared to TestSignature. If the signatures match, then a pointer to the pointer to a data structure of the type specified by TYPE is returned. If the signatures do not match, then DebugAssert() is called with a description - of “CR has a bad signature?and Record is returned. + of "CR has a bad signature" and Record is returned. If the data type specified by TYPE does not contain the field specified by Field, then the module will not compile. diff --git a/MdePkg/Include/Library/PrintLib.h b/MdePkg/Include/Library/PrintLib.h index 9c65459a59..22df74c65a 100644 --- a/MdePkg/Include/Library/PrintLib.h +++ b/MdePkg/Include/Library/PrintLib.h @@ -17,9 +17,26 @@ #ifndef __PRINT_LIB_H__ #define __PRINT_LIB_H__ -// -// Print primitives -// +/// +/// Define the maximum number of characters that are required to +/// encode a decimal, hexidecimal, GUID, or TIME value with a NULL +/// terminator. +/// +/// Maximum Length Decimal String = 28 +/// "-9,223,372,036,854,775,808" +/// Maximum Length Hexidecimal String = 17 +/// "FFFFFFFFFFFFFFFF" +/// Maximum Length GUID = 37 +/// "00000000-0000-0000-0000-000000000000" +/// Maximum Length TIME = 18 +/// "12/12/2006 12:12" +/// +#define MAXIMUM_VALUE_CHARACTERS 38 + +/// +/// Flags bitmask values use in UnicodeValueToString() and +/// AcsiiValueToString() +/// #define LEFT_JUSTIFY 0x01 #define COMMA_TYPE 0x08 #define PREFIX_ZERO 0x20 diff --git a/MdePkg/Include/Library/ReportStatusCodeLib.h b/MdePkg/Include/Library/ReportStatusCodeLib.h index 9a3d4daabd..6b32ddb137 100644 --- a/MdePkg/Include/Library/ReportStatusCodeLib.h +++ b/MdePkg/Include/Library/ReportStatusCodeLib.h @@ -241,12 +241,12 @@ CodeTypeToPostCode ( BOOLEAN EFIAPI ReportStatusCodeExtractAssertInfo ( - IN EFI_STATUS_CODE_TYPE CodeType, - IN EFI_STATUS_CODE_VALUE Value, - IN EFI_STATUS_CODE_DATA *Data, - OUT CHAR8 **Filename, - OUT CHAR8 **Description, - OUT UINT32 *LineNumber + IN EFI_STATUS_CODE_TYPE CodeType, + IN EFI_STATUS_CODE_VALUE Value, + IN CONST EFI_STATUS_CODE_DATA *Data, + OUT CHAR8 **Filename, + OUT CHAR8 **Description, + OUT UINT32 *LineNumber ); @@ -282,10 +282,10 @@ ReportStatusCodeExtractAssertInfo ( BOOLEAN EFIAPI ReportStatusCodeExtractDebugInfo ( - IN EFI_STATUS_CODE_DATA *Data, - OUT UINT32 *ErrorLevel, - OUT VA_LIST *Marker, - OUT CHAR8 **Format + IN CONST EFI_STATUS_CODE_DATA *Data, + OUT UINT32 *ErrorLevel, + OUT VA_LIST *Marker, + OUT CHAR8 **Format ); @@ -349,9 +349,9 @@ ReportStatusCode ( EFI_STATUS EFIAPI ReportStatusCodeWithDevicePath ( - IN EFI_STATUS_CODE_TYPE Type, - IN EFI_STATUS_CODE_VALUE Value, - IN EFI_DEVICE_PATH_PROTOCOL *DevicePath + IN EFI_STATUS_CODE_TYPE Type, + IN EFI_STATUS_CODE_VALUE Value, + IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath ); @@ -393,7 +393,7 @@ EFIAPI ReportStatusCodeWithExtendedData ( IN EFI_STATUS_CODE_TYPE Type, IN EFI_STATUS_CODE_VALUE Value, - IN VOID *ExtendedData, + IN CONST VOID *ExtendedData, IN UINTN ExtendedDataSize ); @@ -445,9 +445,9 @@ ReportStatusCodeEx ( IN EFI_STATUS_CODE_TYPE Type, IN EFI_STATUS_CODE_VALUE Value, IN UINT32 Instance, - IN EFI_GUID *CallerId OPTIONAL, - IN EFI_GUID *ExtendedDataGuid OPTIONAL, - IN VOID *ExtendedData OPTIONAL, + IN CONST EFI_GUID *CallerId OPTIONAL, + IN CONST EFI_GUID *ExtendedDataGuid OPTIONAL, + IN CONST VOID *ExtendedData OPTIONAL, IN UINTN ExtendedDataSize ); diff --git a/MdePkg/Library/BaseDebugLibNull/DebugLib.c b/MdePkg/Library/BaseDebugLibNull/DebugLib.c index 35aea32259..9081b632d8 100644 --- a/MdePkg/Library/BaseDebugLibNull/DebugLib.c +++ b/MdePkg/Library/BaseDebugLibNull/DebugLib.c @@ -61,7 +61,7 @@ DebugPrint ( Prints an assert message containing a filename, line number, and description. This may be followed by a breakpoint or a dead loop. - Print a message of the form “ASSERT (): \n” + Print a message of the form "ASSERT (): \n" to the debug output device. If DEBUG_PROPERTY_ASSERT_BREAKPOINT_ENABLED bit of PcdDebugProperyMask is set then CpuBreakpoint() is called. Otherwise, if DEBUG_PROPERTY_ASSERT_DEADLOOP_ENABLED bit of PcdDebugProperyMask is set then @@ -70,9 +70,9 @@ DebugPrint ( DebugAssert() must actively prevent recusrsion. If DebugAssert() is called while processing another DebugAssert(), then DebugAssert() must return immediately. - If FileName is NULL, then a string of “(NULL) Filename” is printed. + If FileName is NULL, then a string of "(NULL) Filename" is printed. - If Description is NULL, then a string of “(NULL) Description” is printed. + If Description is NULL, then a string of "(NULL) Description" is printed. @param FileName Pointer to the name of the source file that generated the assert condition. @param LineNumber The line number in the source file that generated the assert condition diff --git a/MdePkg/Library/BaseDebugLibReportStatusCode/DebugLib.c b/MdePkg/Library/BaseDebugLibReportStatusCode/DebugLib.c index d330c0f989..a239e91d9d 100644 --- a/MdePkg/Library/BaseDebugLibReportStatusCode/DebugLib.c +++ b/MdePkg/Library/BaseDebugLibReportStatusCode/DebugLib.c @@ -92,7 +92,7 @@ DebugPrint ( Prints an assert message containing a filename, line number, and description. This may be followed by a breakpoint or a dead loop. - Print a message of the form “ASSERT (): \n” + Print a message of the form "ASSERT (): \n" to the debug output device. If DEBUG_PROPERTY_ASSERT_BREAKPOINT_ENABLED bit of PcdDebugProperyMask is set then CpuBreakpoint() is called. Otherwise, if DEBUG_PROPERTY_ASSERT_DEADLOOP_ENABLED bit of PcdDebugProperyMask is set then @@ -101,9 +101,9 @@ DebugPrint ( DebugAssert() must actively prevent recusrsion. If DebugAssert() is called while processing another DebugAssert(), then DebugAssert() must return immediately. - If FileName is NULL, then a string of “(NULL) Filename” is printed. + If FileName is NULL, then a string of "(NULL) Filename" is printed. - If Description is NULL, then a string of “(NULL) Description” is printed. + If Description is NULL, then a string of "(NULL) Description" is printed. @param FileName Pointer to the name of the source file that generated the assert condition. @param LineNumber The line number in the source file that generated the assert condition diff --git a/MdePkg/Library/BaseMemoryLibRepStr/Ia32/SetMem64.asm b/MdePkg/Library/BaseMemoryLibRepStr/Ia32/SetMem64.asm index 3f6f3ecf9d..4679a384c6 100644 --- a/MdePkg/Library/BaseMemoryLibRepStr/Ia32/SetMem64.asm +++ b/MdePkg/Library/BaseMemoryLibRepStr/Ia32/SetMem64.asm @@ -31,8 +31,8 @@ InternalMemSetMem64 PROC USES edi mov edx, [esp + 20] mov edi, [esp + 8] @@: - mov [edi + ecx*4 - 8], eax - mov [edi + ecx*4 - 4], edx + mov [edi + ecx*8 - 8], eax + mov [edi + ecx*8 - 4], edx loop @B mov eax, edi ret diff --git a/MdePkg/Library/BaseMemoryLibRepStr/Ia32/SetMem64.s b/MdePkg/Library/BaseMemoryLibRepStr/Ia32/SetMem64.s index 81f706841f..1a12bc6ee5 100644 --- a/MdePkg/Library/BaseMemoryLibRepStr/Ia32/SetMem64.s +++ b/MdePkg/Library/BaseMemoryLibRepStr/Ia32/SetMem64.s @@ -32,8 +32,8 @@ InternalMemSetMem64: movl 20(%esp),%edx movl 8(%esp),%edi L0: - mov %eax,-8(%edi,%ecx,4) - mov %edx,-4(%edi,%ecx,4) + mov %eax,-8(%edi,%ecx,8) + mov %edx,-4(%edi,%ecx,8) loop L0 movl %edi,%eax pop %edi diff --git a/MdePkg/Library/BasePciCf8Lib/PciLib.c b/MdePkg/Library/BasePciCf8Lib/PciLib.c index 108c95291c..2f82fbe2c8 100644 --- a/MdePkg/Library/BasePciCf8Lib/PciLib.c +++ b/MdePkg/Library/BasePciCf8Lib/PciLib.c @@ -1299,8 +1299,6 @@ PciCf8ReadBuffer ( UINTN EndAddress; ASSERT_INVALID_PCI_ADDRESS (StartAddress, 0); - ASSERT (((StartAddress & 0xFFF) + Size) <= 0x1000); - ASSERT ((StartAddress + Size - 1) <= 0x0FFFFFFF); ASSERT (Buffer != NULL); EndAddress = StartAddress + Size; @@ -1388,8 +1386,6 @@ PciCf8WriteBuffer ( UINTN EndAddress; ASSERT_INVALID_PCI_ADDRESS (StartAddress, 0); - ASSERT (((StartAddress & 0xFFF) + Size) <= 0x1000); - ASSERT ((StartAddress + Size - 1) <= 0x0FFFFFFF); ASSERT (Buffer != NULL); EndAddress = StartAddress + Size; diff --git a/MdePkg/Library/BasePciExpressLib/PciLib.c b/MdePkg/Library/BasePciExpressLib/PciLib.c index de33bf3055..125da5793b 100644 --- a/MdePkg/Library/BasePciExpressLib/PciLib.c +++ b/MdePkg/Library/BasePciExpressLib/PciLib.c @@ -1196,8 +1196,6 @@ PciExpressReadBuffer ( UINTN EndAddress; ASSERT_INVALID_PCI_ADDRESS (StartAddress); - ASSERT (((StartAddress & 0xFFF) + Size) <= 0x1000); - ASSERT ((StartAddress + Size - 1) <= 0x0FFFFFFF); ASSERT (Buffer != NULL); EndAddress = StartAddress + Size; @@ -1284,8 +1282,6 @@ PciExpressWriteBuffer ( UINTN EndAddress; ASSERT_INVALID_PCI_ADDRESS (StartAddress); - ASSERT (((StartAddress & 0xFFF) + Size) <= 0x1000); - ASSERT ((StartAddress + Size - 1) <= 0x0FFFFFFF); ASSERT (Buffer != NULL); EndAddress = StartAddress + Size; diff --git a/MdePkg/Library/BasePrintLib/PrintLib.c b/MdePkg/Library/BasePrintLib/PrintLib.c index 24e0175545..e940bedb34 100644 --- a/MdePkg/Library/BasePrintLib/PrintLib.c +++ b/MdePkg/Library/BasePrintLib/PrintLib.c @@ -66,7 +66,6 @@ static CONST STATUS_LOOKUP_TABLE_ENTRY StatusString[] = { @param Buffer Character buffer to print the results of the parsing of Format into. @param BufferSize Maximum number of characters to put into buffer. - Zero means no limit. @param Flags Intial flags value. Can only have FORMAT_UNICODE and OUTPUT_UNICODE set @param Format Null-terminated format string. @@ -110,6 +109,9 @@ BasePrintLibVSPrint ( UINTN Radix; RETURN_STATUS Status; + if (BufferSize == 0) { + return 0; + } ASSERT (Buffer != NULL); ASSERT (Format != NULL); @@ -130,7 +132,6 @@ BasePrintLibVSPrint ( // // Reserve space for the Null terminator. - // If BufferSize is 0, this will set BufferSize to the max unsigned value // BufferSize--; @@ -338,7 +339,7 @@ BasePrintLibVSPrint ( } else { BasePrintLibSPrint ( ValueBuffer, - 0, + MAXIMUM_VALUE_CHARACTERS, 0, "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x", TmpGuid->Data1, @@ -364,7 +365,7 @@ BasePrintLibVSPrint ( } else { BasePrintLibSPrint ( ValueBuffer, - 0, + MAXIMUM_VALUE_CHARACTERS, 0, "%02d/%02d/%04d %02d:%02d", TmpTime->Month, @@ -386,10 +387,14 @@ BasePrintLibVSPrint ( } } if (ArgumentString == ValueBuffer) { - BasePrintLibSPrint ((CHAR8 *) ValueBuffer, 0, 0, "%08X", Status); + BasePrintLibSPrint ((CHAR8 *) ValueBuffer, MAXIMUM_VALUE_CHARACTERS, 0, "%08X", Status); } break; + case '\n': + ArgumentString = "\r\n"; + break; + case '%': default: // @@ -400,9 +405,6 @@ BasePrintLibVSPrint ( break; } break; - case '\n': - ArgumentString = "\r\n"; - break; default: ArgumentString = (CHAR8 *)&FormatCharacter; Flags |= ARGUMENT_UNICODE; @@ -717,7 +719,7 @@ UnicodeSPrintAsciiFormat ( VA_LIST Marker; VA_START (Marker, FormatString); - return UnicodeVSPrintAsciiFormat (StartOfBuffer, BufferSize >> 1, FormatString, Marker); + return UnicodeVSPrintAsciiFormat (StartOfBuffer, BufferSize, FormatString, Marker); } /** diff --git a/MdePkg/Library/BasePrintLib/PrintLibInternal.c b/MdePkg/Library/BasePrintLib/PrintLibInternal.c index 89d18b09a2..06c220692e 100644 --- a/MdePkg/Library/BasePrintLib/PrintLibInternal.c +++ b/MdePkg/Library/BasePrintLib/PrintLibInternal.c @@ -138,13 +138,20 @@ BasePrintLibConvertValueToString ( UINTN Digits; UINTN Index; + ASSERT (Buffer != NULL); + ASSERT (Width < MAXIMUM_VALUE_CHARACTERS); + // + // Make sure Flags can only contain supported bits. + // + ASSERT ((Flags & ~(LEFT_JUSTIFY | COMMA_TYPE | PREFIX_ZERO)) == 0); + OriginalBuffer = Buffer; if (Width == 0 || (Flags & COMMA_TYPE) != 0) { Flags &= (~PREFIX_ZERO); } - if (Width == 0 || Width > (MAXIMUM_VALUE_CHARACTERS - 1)) { + if (Width == 0) { Width = MAXIMUM_VALUE_CHARACTERS - 1; } diff --git a/MdePkg/Library/BasePrintLib/PrintLibInternal.h b/MdePkg/Library/BasePrintLib/PrintLibInternal.h index 0f7bebff45..f395bb7956 100644 --- a/MdePkg/Library/BasePrintLib/PrintLibInternal.h +++ b/MdePkg/Library/BasePrintLib/PrintLibInternal.h @@ -31,16 +31,6 @@ #define PRECISION 0x800 #define ARGUMENT_REVERSED 0x1000 -/// -/// Define the maximum number of characters that are required to encode -/// a decimal, hexidecimal, GUID, or TIME value with a Nll terminator. -/// Maximum Length Decimal String = 28 "-9,223,372,036,854,775,808" -/// Maximum Length Hexidecimal String = 17 "FFFFFFFFFFFFFFFF" -/// Maximum Length GUID = 37 "00000000-0000-0000-0000-000000000000" -/// Maximum Length TIME = 18 "12/12/2006 12:12" -/// -#define MAXIMUM_VALUE_CHARACTERS 38 - // // Record date and time information // diff --git a/MdePkg/Library/BaseReportStatusCodeLibNull/ReportStatusCodeLib.c b/MdePkg/Library/BaseReportStatusCodeLibNull/ReportStatusCodeLib.c index 752dc72c79..4459c0350e 100644 --- a/MdePkg/Library/BaseReportStatusCodeLibNull/ReportStatusCodeLib.c +++ b/MdePkg/Library/BaseReportStatusCodeLibNull/ReportStatusCodeLib.c @@ -95,12 +95,12 @@ CodeTypeToPostCode ( BOOLEAN EFIAPI ReportStatusCodeExtractAssertInfo ( - IN EFI_STATUS_CODE_TYPE CodeType, - IN EFI_STATUS_CODE_VALUE Value, - IN EFI_STATUS_CODE_DATA *Data, - OUT CHAR8 **Filename, - OUT CHAR8 **Description, - OUT UINT32 *LineNumber + IN EFI_STATUS_CODE_TYPE CodeType, + IN EFI_STATUS_CODE_VALUE Value, + IN CONST EFI_STATUS_CODE_DATA *Data, + OUT CHAR8 **Filename, + OUT CHAR8 **Description, + OUT UINT32 *LineNumber ) { EFI_DEBUG_ASSERT_DATA *AssertData; @@ -155,10 +155,10 @@ ReportStatusCodeExtractAssertInfo ( BOOLEAN EFIAPI ReportStatusCodeExtractDebugInfo ( - IN EFI_STATUS_CODE_DATA *Data, - OUT UINT32 *ErrorLevel, - OUT VA_LIST *Marker, - OUT CHAR8 **Format + IN CONST EFI_STATUS_CODE_DATA *Data, + OUT UINT32 *ErrorLevel, + OUT VA_LIST *Marker, + OUT CHAR8 **Format ) { EFI_DEBUG_INFO *DebugInfo; @@ -256,9 +256,9 @@ ReportStatusCode ( EFI_STATUS EFIAPI ReportStatusCodeWithDevicePath ( - IN EFI_STATUS_CODE_TYPE Type, - IN EFI_STATUS_CODE_VALUE Value, - IN EFI_DEVICE_PATH_PROTOCOL *DevicePath + IN EFI_STATUS_CODE_TYPE Type, + IN EFI_STATUS_CODE_VALUE Value, + IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath ) { ASSERT (DevicePath != NULL); @@ -304,7 +304,7 @@ EFIAPI ReportStatusCodeWithExtendedData ( IN EFI_STATUS_CODE_TYPE Type, IN EFI_STATUS_CODE_VALUE Value, - IN VOID *ExtendedData, + IN CONST VOID *ExtendedData, IN UINTN ExtendedDataSize ) { @@ -361,9 +361,9 @@ ReportStatusCodeEx ( IN EFI_STATUS_CODE_TYPE Type, IN EFI_STATUS_CODE_VALUE Value, IN UINT32 Instance, - IN EFI_GUID *CallerId OPTIONAL, - IN EFI_GUID *ExtendedDataGuid OPTIONAL, - IN VOID *ExtendedData OPTIONAL, + IN CONST EFI_GUID *CallerId OPTIONAL, + IN CONST EFI_GUID *ExtendedDataGuid OPTIONAL, + IN CONST VOID *ExtendedData OPTIONAL, IN UINTN ExtendedDataSize ) { diff --git a/MdePkg/Library/DxeReportStatusCodeLib/ReportStatusCodeLib.c b/MdePkg/Library/DxeReportStatusCodeLib/ReportStatusCodeLib.c index 9edb753137..616c237dad 100644 --- a/MdePkg/Library/DxeReportStatusCodeLib/ReportStatusCodeLib.c +++ b/MdePkg/Library/DxeReportStatusCodeLib/ReportStatusCodeLib.c @@ -45,7 +45,7 @@ InternalReportStatusCode ( IN EFI_STATUS_CODE_TYPE Type, IN EFI_STATUS_CODE_VALUE Value, IN UINT32 Instance, - IN EFI_GUID *CallerId OPTIONAL, + IN CONST EFI_GUID *CallerId OPTIONAL, IN EFI_STATUS_CODE_DATA *Data OPTIONAL ) { @@ -66,7 +66,7 @@ InternalReportStatusCode ( // A Status Code Protocol is present in the handle database, so pass in all the // parameters to the ReportStatusCode() service of the Status Code Protocol // - return gStatusCode->ReportStatusCode (Type, Value, Instance, CallerId, Data); + return gStatusCode->ReportStatusCode (Type, Value, Instance, (EFI_GUID *)CallerId, Data); } @@ -80,14 +80,10 @@ InternalReportStatusCode ( **/ UINTN InternalReportStatusCodeDevicePathSize ( - IN EFI_DEVICE_PATH_PROTOCOL *DevicePath + IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath ) { - EFI_DEVICE_PATH_PROTOCOL *Start; - - if (DevicePath == NULL) { - return 0; - } + CONST EFI_DEVICE_PATH_PROTOCOL *Start; // // Search for the end of the device path structure @@ -187,12 +183,12 @@ CodeTypeToPostCode ( BOOLEAN EFIAPI ReportStatusCodeExtractAssertInfo ( - IN EFI_STATUS_CODE_TYPE CodeType, - IN EFI_STATUS_CODE_VALUE Value, - IN EFI_STATUS_CODE_DATA *Data, - OUT CHAR8 **Filename, - OUT CHAR8 **Description, - OUT UINT32 *LineNumber + IN EFI_STATUS_CODE_TYPE CodeType, + IN EFI_STATUS_CODE_VALUE Value, + IN CONST EFI_STATUS_CODE_DATA *Data, + OUT CHAR8 **Filename, + OUT CHAR8 **Description, + OUT UINT32 *LineNumber ) { EFI_DEBUG_ASSERT_DATA *AssertData; @@ -247,10 +243,10 @@ ReportStatusCodeExtractAssertInfo ( BOOLEAN EFIAPI ReportStatusCodeExtractDebugInfo ( - IN EFI_STATUS_CODE_DATA *Data, - OUT UINT32 *ErrorLevel, - OUT VA_LIST *Marker, - OUT CHAR8 **Format + IN CONST EFI_STATUS_CODE_DATA *Data, + OUT UINT32 *ErrorLevel, + OUT VA_LIST *Marker, + OUT CHAR8 **Format ) { EFI_DEBUG_INFO *DebugInfo; @@ -348,9 +344,9 @@ ReportStatusCode ( EFI_STATUS EFIAPI ReportStatusCodeWithDevicePath ( - IN EFI_STATUS_CODE_TYPE Type, - IN EFI_STATUS_CODE_VALUE Value, - IN EFI_DEVICE_PATH_PROTOCOL *DevicePath + IN EFI_STATUS_CODE_TYPE Type, + IN EFI_STATUS_CODE_VALUE Value, + IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath ) { ASSERT (DevicePath != NULL); @@ -401,7 +397,7 @@ EFIAPI ReportStatusCodeWithExtendedData ( IN EFI_STATUS_CODE_TYPE Type, IN EFI_STATUS_CODE_VALUE Value, - IN VOID *ExtendedData, + IN CONST VOID *ExtendedData, IN UINTN ExtendedDataSize ) { @@ -466,9 +462,9 @@ ReportStatusCodeEx ( IN EFI_STATUS_CODE_TYPE Type, IN EFI_STATUS_CODE_VALUE Value, IN UINT32 Instance, - IN EFI_GUID *CallerId OPTIONAL, - IN EFI_GUID *ExtendedDataGuid OPTIONAL, - IN VOID *ExtendedData OPTIONAL, + IN CONST EFI_GUID *CallerId OPTIONAL, + IN CONST EFI_GUID *ExtendedDataGuid OPTIONAL, + IN CONST VOID *ExtendedData OPTIONAL, IN UINTN ExtendedDataSize ) { diff --git a/MdePkg/Library/PeiReportStatusCodeLib/ReportStatusCodeLib.c b/MdePkg/Library/PeiReportStatusCodeLib/ReportStatusCodeLib.c index 5c022d6adc..dda3d717e8 100644 --- a/MdePkg/Library/PeiReportStatusCodeLib/ReportStatusCodeLib.c +++ b/MdePkg/Library/PeiReportStatusCodeLib/ReportStatusCodeLib.c @@ -45,48 +45,21 @@ InternalReportStatusCode ( IN EFI_STATUS_CODE_TYPE Type, IN EFI_STATUS_CODE_VALUE Value, IN UINT32 Instance, - IN EFI_GUID *CallerId OPTIONAL, + IN CONST EFI_GUID *CallerId OPTIONAL, IN EFI_STATUS_CODE_DATA *Data OPTIONAL ) { EFI_PEI_SERVICES **PeiServices; PeiServices = GetPeiServicesTablePointer (); - return (*PeiServices)->PeiReportStatusCode (PeiServices, Type, Value, Instance, CallerId, Data); -} - - -/** - Computes and returns the size, in bytes, of a device path. - - @param DevicePath A pointer to a device path. - - @return The size, in bytes, of DevicePath. - -**/ -UINTN -InternalReportStatusCodeDevicePathSize ( - IN EFI_DEVICE_PATH_PROTOCOL *DevicePath - ) -{ - EFI_DEVICE_PATH_PROTOCOL *Start; - - if (DevicePath == NULL) { - return 0; - } - - // - // Search for the end of the device path structure - // - Start = DevicePath; - while (!EfiIsDevicePathEnd (DevicePath)) { - DevicePath = EfiNextDevicePathNode (DevicePath); - } - - // - // Subtract the start node from the end node and add in the size of the end node - // - return ((UINTN) DevicePath - (UINTN) Start) + DevicePathNodeLength (DevicePath); + return (*PeiServices)->PeiReportStatusCode ( + PeiServices, + Type, + Value, + Instance, + (EFI_GUID *)CallerId, + Data + ); } @@ -173,12 +146,12 @@ CodeTypeToPostCode ( BOOLEAN EFIAPI ReportStatusCodeExtractAssertInfo ( - IN EFI_STATUS_CODE_TYPE CodeType, - IN EFI_STATUS_CODE_VALUE Value, - IN EFI_STATUS_CODE_DATA *Data, - OUT CHAR8 **Filename, - OUT CHAR8 **Description, - OUT UINT32 *LineNumber + IN EFI_STATUS_CODE_TYPE CodeType, + IN EFI_STATUS_CODE_VALUE Value, + IN CONST EFI_STATUS_CODE_DATA *Data, + OUT CHAR8 **Filename, + OUT CHAR8 **Description, + OUT UINT32 *LineNumber ) { EFI_DEBUG_ASSERT_DATA *AssertData; @@ -233,10 +206,10 @@ ReportStatusCodeExtractAssertInfo ( BOOLEAN EFIAPI ReportStatusCodeExtractDebugInfo ( - IN EFI_STATUS_CODE_DATA *Data, - OUT UINT32 *ErrorLevel, - OUT VA_LIST *Marker, - OUT CHAR8 **Format + IN CONST EFI_STATUS_CODE_DATA *Data, + OUT UINT32 *ErrorLevel, + OUT VA_LIST *Marker, + OUT CHAR8 **Format ) { EFI_DEBUG_INFO *DebugInfo; @@ -334,18 +307,13 @@ ReportStatusCode ( EFI_STATUS EFIAPI ReportStatusCodeWithDevicePath ( - IN EFI_STATUS_CODE_TYPE Type, - IN EFI_STATUS_CODE_VALUE Value, - IN EFI_DEVICE_PATH_PROTOCOL *DevicePath + IN EFI_STATUS_CODE_TYPE Type, + IN EFI_STATUS_CODE_VALUE Value, + IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath ) { ASSERT (DevicePath != NULL); - return ReportStatusCodeWithExtendedData ( - Type, - Value, - (VOID *)DevicePath, - InternalReportStatusCodeDevicePathSize (DevicePath) - ); + return EFI_UNSUPPORTED; } @@ -387,7 +355,7 @@ EFIAPI ReportStatusCodeWithExtendedData ( IN EFI_STATUS_CODE_TYPE Type, IN EFI_STATUS_CODE_VALUE Value, - IN VOID *ExtendedData, + IN CONST VOID *ExtendedData, IN UINTN ExtendedDataSize ) { @@ -452,9 +420,9 @@ ReportStatusCodeEx ( IN EFI_STATUS_CODE_TYPE Type, IN EFI_STATUS_CODE_VALUE Value, IN UINT32 Instance, - IN EFI_GUID *CallerId OPTIONAL, - IN EFI_GUID *ExtendedDataGuid OPTIONAL, - IN VOID *ExtendedData OPTIONAL, + IN CONST EFI_GUID *CallerId OPTIONAL, + IN CONST EFI_GUID *ExtendedDataGuid OPTIONAL, + IN CONST VOID *ExtendedData OPTIONAL, IN UINTN ExtendedDataSize ) { diff --git a/MdePkg/Library/PeiServicesTablePointerLib/PeiServicesTablePointer.c b/MdePkg/Library/PeiServicesTablePointerLib/PeiServicesTablePointer.c index 0240c38dbc..b4c13c850b 100644 --- a/MdePkg/Library/PeiServicesTablePointerLib/PeiServicesTablePointer.c +++ b/MdePkg/Library/PeiServicesTablePointerLib/PeiServicesTablePointer.c @@ -23,6 +23,7 @@ GetPeiServicesTablePointer ( VOID ) { + ASSERT (gPeiServices != NULL); return gPeiServices; } diff --git a/MdePkg/Library/PeiServicesTablePointerLib/PeiServicesTablePointerLib.msa b/MdePkg/Library/PeiServicesTablePointerLib/PeiServicesTablePointerLib.msa index 4578872a33..3b895013a7 100644 --- a/MdePkg/Library/PeiServicesTablePointerLib/PeiServicesTablePointerLib.msa +++ b/MdePkg/Library/PeiServicesTablePointerLib/PeiServicesTablePointerLib.msa @@ -33,6 +33,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. PeiServicesTablePointerLib + DebugLib PeiServicesTablePointer.c diff --git a/MdePkg/Library/PeiServicesTablePointerLibMm7/PeiServicesTablePointer.c b/MdePkg/Library/PeiServicesTablePointerLibMm7/PeiServicesTablePointer.c index 285a5a05ad..f5faf63086 100644 --- a/MdePkg/Library/PeiServicesTablePointerLibMm7/PeiServicesTablePointer.c +++ b/MdePkg/Library/PeiServicesTablePointerLibMm7/PeiServicesTablePointer.c @@ -21,7 +21,11 @@ GetPeiServicesTablePointer ( VOID ) { - return (EFI_PEI_SERVICES **)(UINTN)AsmReadMm7 (); + EFI_PEI_SERVICES **PeiServices; + + PeiServices = (EFI_PEI_SERVICES **)(UINTN)AsmReadMm7 (); + ASSERT (PeiServices != NULL); + return PeiServices; } /** diff --git a/MdePkg/Library/PeiServicesTablePointerLibMm7/PeiServicesTablePointerLibMm7.msa b/MdePkg/Library/PeiServicesTablePointerLibMm7/PeiServicesTablePointerLibMm7.msa index 7a6d8ba45a..e9aac1d2cd 100644 --- a/MdePkg/Library/PeiServicesTablePointerLibMm7/PeiServicesTablePointerLibMm7.msa +++ b/MdePkg/Library/PeiServicesTablePointerLibMm7/PeiServicesTablePointerLibMm7.msa @@ -34,6 +34,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. PeiServicesTablePointerLib BaseLib + DebugLib PeiServicesTablePointer.c diff --git a/MdePkg/Library/UefiDebugLibConOut/DebugLib.c b/MdePkg/Library/UefiDebugLibConOut/DebugLib.c index 27d82b3feb..97db1f41ba 100644 --- a/MdePkg/Library/UefiDebugLibConOut/DebugLib.c +++ b/MdePkg/Library/UefiDebugLibConOut/DebugLib.c @@ -76,7 +76,7 @@ DebugPrint ( Prints an assert message containing a filename, line number, and description. This may be followed by a breakpoint or a dead loop. - Print a message of the form “ASSERT (): \n” + Print a message of the form "ASSERT (): \n" to the debug output device. If DEBUG_PROPERTY_ASSERT_BREAKPOINT_ENABLED bit of PcdDebugProperyMask is set then CpuBreakpoint() is called. Otherwise, if DEBUG_PROPERTY_ASSERT_DEADLOOP_ENABLED bit of PcdDebugProperyMask is set then @@ -85,9 +85,9 @@ DebugPrint ( DebugAssert() must actively prevent recusrsion. If DebugAssert() is called while processing another DebugAssert(), then DebugAssert() must return immediately. - If FileName is NULL, then a string of “(NULL) Filename” is printed. + If FileName is NULL, then a string of "(NULL) Filename" is printed. - If Description is NULL, then a string of “(NULL) Description” is printed. + If Description is NULL, then a string of "(NULL) Description" is printed. @param FileName Pointer to the name of the source file that generated the assert condition. @param LineNumber The line number in the source file that generated the assert condition diff --git a/MdePkg/Library/UefiDebugLibStdErr/DebugLib.c b/MdePkg/Library/UefiDebugLibStdErr/DebugLib.c index 18f651c194..986c5234cc 100644 --- a/MdePkg/Library/UefiDebugLibStdErr/DebugLib.c +++ b/MdePkg/Library/UefiDebugLibStdErr/DebugLib.c @@ -76,7 +76,7 @@ DebugPrint ( Prints an assert message containing a filename, line number, and description. This may be followed by a breakpoint or a dead loop. - Print a message of the form “ASSERT (): \n” + Print a message of the form "ASSERT (): \n" to the debug output device. If DEBUG_PROPERTY_ASSERT_BREAKPOINT_ENABLED bit of PcdDebugProperyMask is set then CpuBreakpoint() is called. Otherwise, if DEBUG_PROPERTY_ASSERT_DEADLOOP_ENABLED bit of PcdDebugProperyMask is set then @@ -85,9 +85,9 @@ DebugPrint ( DebugAssert() must actively prevent recusrsion. If DebugAssert() is called while processing another DebugAssert(), then DebugAssert() must return immediately. - If FileName is NULL, then a string of “(NULL) Filename” is printed. + If FileName is NULL, then a string of "(NULL) Filename" is printed. - If Description is NULL, then a string of “(NULL) Description” is printed. + If Description is NULL, then a string of "(NULL) Description" is printed. @param FileName Pointer to the name of the source file that generated the assert condition. @param LineNumber The line number in the source file that generated the assert condition