From: qhuang8 Date: Wed, 5 Jul 2006 04:17:04 +0000 (+0000) Subject: DebugLib: X-Git-Tag: edk2-stable201903~25082 X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=commitdiff_plain;h=add13dc21720eff1a37fdea34c0fef190e2ad37d DebugLib: Fix a bug in PeiDxeDebugLibReportStatusCode: it should use gReportStatusCodeDebugType so that report status code infrastructure can correctly extract debug info. Fix functional and coding style issues in the three instances in EdkModulePkg, namely: EdkDxeDebugLibReportStatusCode, EdkUefiDebugLibStderr, EdkUefiDebugLibConout. DevicePathLib: Sync with MWG 0.57 and add new interface of CreateDevicePathNode(). All the function headers have been updated. PeiServicesLib: Adjust coding style and fix a minor comment error. PciLib: Adjust assert() condition to sync with MWG 0.57 BaseMemoryLib: Adjust assert() for ScanMemXX (), ScanGuid() Rename UefiMemoryLib to DxeMemoryLib PrintLib: Change the return value of all print services to exclude the NULL-terminator. Misc: Slightly adjust the coding style in hob.c in PeiCore module. git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@757 6f19259b-4bc3-4df7-8a09-765794883524 --- diff --git a/EdkModulePkg/Application/HelloWorld/HelloWorld.mbd b/EdkModulePkg/Application/HelloWorld/HelloWorld.mbd index 6d44bac022..caa6536f14 100644 --- a/EdkModulePkg/Application/HelloWorld/HelloWorld.mbd +++ b/EdkModulePkg/Application/HelloWorld/HelloWorld.mbd @@ -30,7 +30,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. UefiBootServicesTableLib BaseLib - UefiMemoryLib + DxeMemoryLib UefiLib UefiDriverEntryPoint UefiDebugLibStdErr diff --git a/EdkModulePkg/Bus/Pci/AtapiPassThru/Dxe/AtapiPassThru.mbd b/EdkModulePkg/Bus/Pci/AtapiPassThru/Dxe/AtapiPassThru.mbd index 6de42bb9bb..00cee210f1 100644 --- a/EdkModulePkg/Bus/Pci/AtapiPassThru/Dxe/AtapiPassThru.mbd +++ b/EdkModulePkg/Bus/Pci/AtapiPassThru/Dxe/AtapiPassThru.mbd @@ -29,7 +29,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. UefiBootServicesTableLib - UefiMemoryLib + DxeMemoryLib UefiLib UefiDriverEntryPoint UefiDriverModelLib diff --git a/EdkModulePkg/Bus/Pci/CirrusLogic/Dxe/CirrusLogic5430.mbd b/EdkModulePkg/Bus/Pci/CirrusLogic/Dxe/CirrusLogic5430.mbd index a8757d7b73..dbbddaef22 100644 --- a/EdkModulePkg/Bus/Pci/CirrusLogic/Dxe/CirrusLogic5430.mbd +++ b/EdkModulePkg/Bus/Pci/CirrusLogic/Dxe/CirrusLogic5430.mbd @@ -29,7 +29,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. UefiBootServicesTableLib - UefiMemoryLib + DxeMemoryLib UefiLib UefiDriverEntryPoint UefiDriverModelLib diff --git a/EdkModulePkg/Bus/Pci/IdeBus/Dxe/idebus.mbd b/EdkModulePkg/Bus/Pci/IdeBus/Dxe/idebus.mbd index b9ad38fffa..315a07faa0 100644 --- a/EdkModulePkg/Bus/Pci/IdeBus/Dxe/idebus.mbd +++ b/EdkModulePkg/Bus/Pci/IdeBus/Dxe/idebus.mbd @@ -30,7 +30,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. UefiBootServicesTableLib UefiRuntimeServicesTableLib - UefiMemoryLib + DxeMemoryLib UefiLib UefiDriverEntryPoint UefiDriverModelLib diff --git a/EdkModulePkg/Bus/Pci/IdeBus/Dxe/idebusLite.mbd b/EdkModulePkg/Bus/Pci/IdeBus/Dxe/idebusLite.mbd index fa4bc333d4..8ea34aa9b8 100644 --- a/EdkModulePkg/Bus/Pci/IdeBus/Dxe/idebusLite.mbd +++ b/EdkModulePkg/Bus/Pci/IdeBus/Dxe/idebusLite.mbd @@ -30,7 +30,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. UefiBootServicesTableLib UefiRuntimeServicesTableLib - UefiMemoryLib + DxeMemoryLib UefiLib UefiDriverEntryPoint UefiDriverModelLib diff --git a/EdkModulePkg/Bus/Pci/PciBus/Dxe/LightPciBus.mbd b/EdkModulePkg/Bus/Pci/PciBus/Dxe/LightPciBus.mbd index 2bed01a330..7f27c02060 100644 --- a/EdkModulePkg/Bus/Pci/PciBus/Dxe/LightPciBus.mbd +++ b/EdkModulePkg/Bus/Pci/PciBus/Dxe/LightPciBus.mbd @@ -29,7 +29,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. UefiBootServicesTableLib - UefiMemoryLib + DxeMemoryLib UefiLib UefiDriverEntryPoint UefiDriverModelLib diff --git a/EdkModulePkg/Bus/Pci/PciBus/Dxe/PciBus.mbd b/EdkModulePkg/Bus/Pci/PciBus/Dxe/PciBus.mbd index d343fd581a..08e8de6672 100644 --- a/EdkModulePkg/Bus/Pci/PciBus/Dxe/PciBus.mbd +++ b/EdkModulePkg/Bus/Pci/PciBus/Dxe/PciBus.mbd @@ -29,7 +29,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. UefiBootServicesTableLib - UefiMemoryLib + DxeMemoryLib UefiLib UefiDriverEntryPoint UefiDriverModelLib diff --git a/EdkModulePkg/Bus/Pci/PciBus/Dxe/PciBusLite.mbd b/EdkModulePkg/Bus/Pci/PciBus/Dxe/PciBusLite.mbd index 3e2db59a4c..80188cd27b 100644 --- a/EdkModulePkg/Bus/Pci/PciBus/Dxe/PciBusLite.mbd +++ b/EdkModulePkg/Bus/Pci/PciBus/Dxe/PciBusLite.mbd @@ -29,7 +29,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. UefiBootServicesTableLib - UefiMemoryLib + DxeMemoryLib UefiLib UefiDriverEntryPoint UefiDriverModelLib diff --git a/EdkModulePkg/Bus/Pci/Uhci/Dxe/Uhci.mbd b/EdkModulePkg/Bus/Pci/Uhci/Dxe/Uhci.mbd index e0ea5838b7..9af8c72bdb 100644 --- a/EdkModulePkg/Bus/Pci/Uhci/Dxe/Uhci.mbd +++ b/EdkModulePkg/Bus/Pci/Uhci/Dxe/Uhci.mbd @@ -29,7 +29,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. UefiBootServicesTableLib - UefiMemoryLib + DxeMemoryLib UefiLib UefiDriverEntryPoint UefiDriverModelLib diff --git a/EdkModulePkg/Bus/Scsi/ScsiBus/Dxe/ScsiBus.mbd b/EdkModulePkg/Bus/Scsi/ScsiBus/Dxe/ScsiBus.mbd index 1681a92a1e..7fd7f0f4fb 100644 --- a/EdkModulePkg/Bus/Scsi/ScsiBus/Dxe/ScsiBus.mbd +++ b/EdkModulePkg/Bus/Scsi/ScsiBus/Dxe/ScsiBus.mbd @@ -29,7 +29,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. UefiBootServicesTableLib - UefiMemoryLib + DxeMemoryLib UefiLib UefiDriverEntryPoint UefiDriverModelLib diff --git a/EdkModulePkg/Bus/Scsi/ScsiDisk/Dxe/ScsiDisk.mbd b/EdkModulePkg/Bus/Scsi/ScsiDisk/Dxe/ScsiDisk.mbd index 87b9331c24..fb4ed4a5f0 100644 --- a/EdkModulePkg/Bus/Scsi/ScsiDisk/Dxe/ScsiDisk.mbd +++ b/EdkModulePkg/Bus/Scsi/ScsiDisk/Dxe/ScsiDisk.mbd @@ -29,7 +29,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. UefiBootServicesTableLib - UefiMemoryLib + DxeMemoryLib UefiLib UefiDriverEntryPoint UefiDriverModelLib diff --git a/EdkModulePkg/Bus/Usb/UsbBot/Dxe/UsbBot.mbd b/EdkModulePkg/Bus/Usb/UsbBot/Dxe/UsbBot.mbd index c853ed4dc5..449b8e9cbb 100644 --- a/EdkModulePkg/Bus/Usb/UsbBot/Dxe/UsbBot.mbd +++ b/EdkModulePkg/Bus/Usb/UsbBot/Dxe/UsbBot.mbd @@ -29,7 +29,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. UefiBootServicesTableLib - UefiMemoryLib + DxeMemoryLib UefiLib UefiDriverEntryPoint UefiDriverModelLib diff --git a/EdkModulePkg/Bus/Usb/UsbBus/Dxe/UsbBus.mbd b/EdkModulePkg/Bus/Usb/UsbBus/Dxe/UsbBus.mbd index 405aab5014..3b40cbc28c 100644 --- a/EdkModulePkg/Bus/Usb/UsbBus/Dxe/UsbBus.mbd +++ b/EdkModulePkg/Bus/Usb/UsbBus/Dxe/UsbBus.mbd @@ -29,7 +29,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. UefiBootServicesTableLib - UefiMemoryLib + DxeMemoryLib UefiLib UefiDriverEntryPoint UefiDriverModelLib diff --git a/EdkModulePkg/Bus/Usb/UsbCbi/Dxe/Cbi0/UsbCbi0.mbd b/EdkModulePkg/Bus/Usb/UsbCbi/Dxe/Cbi0/UsbCbi0.mbd index 935e3b5c8d..66a7e973bc 100644 --- a/EdkModulePkg/Bus/Usb/UsbCbi/Dxe/Cbi0/UsbCbi0.mbd +++ b/EdkModulePkg/Bus/Usb/UsbCbi/Dxe/Cbi0/UsbCbi0.mbd @@ -29,7 +29,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. UefiBootServicesTableLib - UefiMemoryLib + DxeMemoryLib UefiLib UefiDriverEntryPoint UefiDriverModelLib diff --git a/EdkModulePkg/Bus/Usb/UsbCbi/Dxe/Cbi1/UsbCbi1.mbd b/EdkModulePkg/Bus/Usb/UsbCbi/Dxe/Cbi1/UsbCbi1.mbd index 416976a869..1dd3dbd133 100644 --- a/EdkModulePkg/Bus/Usb/UsbCbi/Dxe/Cbi1/UsbCbi1.mbd +++ b/EdkModulePkg/Bus/Usb/UsbCbi/Dxe/Cbi1/UsbCbi1.mbd @@ -29,7 +29,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. UefiBootServicesTableLib - UefiMemoryLib + DxeMemoryLib UefiLib UefiDriverEntryPoint UefiDriverModelLib diff --git a/EdkModulePkg/Bus/Usb/UsbKb/Dxe/UsbKb.mbd b/EdkModulePkg/Bus/Usb/UsbKb/Dxe/UsbKb.mbd index 7a26566d95..f9d9f7ec2d 100644 --- a/EdkModulePkg/Bus/Usb/UsbKb/Dxe/UsbKb.mbd +++ b/EdkModulePkg/Bus/Usb/UsbKb/Dxe/UsbKb.mbd @@ -30,7 +30,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. UefiBootServicesTableLib UefiRuntimeServicesTableLib - UefiMemoryLib + DxeMemoryLib UefiLib UefiDriverEntryPoint UefiDriverModelLib diff --git a/EdkModulePkg/Bus/Usb/UsbMassStorage/Dxe/UsbMassStorage.mbd b/EdkModulePkg/Bus/Usb/UsbMassStorage/Dxe/UsbMassStorage.mbd index e77c35d60e..ae24788cd0 100644 --- a/EdkModulePkg/Bus/Usb/UsbMassStorage/Dxe/UsbMassStorage.mbd +++ b/EdkModulePkg/Bus/Usb/UsbMassStorage/Dxe/UsbMassStorage.mbd @@ -29,7 +29,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. UefiBootServicesTableLib - UefiMemoryLib + DxeMemoryLib UefiLib UefiDriverEntryPoint UefiDriverModelLib diff --git a/EdkModulePkg/Bus/Usb/UsbMouse/Dxe/UsbMouse.mbd b/EdkModulePkg/Bus/Usb/UsbMouse/Dxe/UsbMouse.mbd index 026a9bf68c..b3eca8f558 100644 --- a/EdkModulePkg/Bus/Usb/UsbMouse/Dxe/UsbMouse.mbd +++ b/EdkModulePkg/Bus/Usb/UsbMouse/Dxe/UsbMouse.mbd @@ -29,7 +29,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. UefiBootServicesTableLib - UefiMemoryLib + DxeMemoryLib UefiLib UefiDriverEntryPoint UefiDriverModelLib diff --git a/EdkModulePkg/Core/Pei/Hob/Hob.c b/EdkModulePkg/Core/Pei/Hob/Hob.c index 6117827522..1eadf9458c 100644 --- a/EdkModulePkg/Core/Pei/Hob/Hob.c +++ b/EdkModulePkg/Core/Pei/Hob/Hob.c @@ -61,7 +61,7 @@ Returns: PrivateData = PEI_CORE_INSTANCE_FROM_PS_THIS(PeiServices); - *HobList = PrivateData->HobList.Raw; + *HobList = PrivateData->HobList.Raw; return EFI_SUCCESS; @@ -111,7 +111,7 @@ Returns: HandOffHob = *Hob; - Length = (UINT16)((Length + 0x7) & (~0x7)); + Length = (UINT16)((Length + 0x7) & (~0x7)); FreeMemory = HandOffHob->EfiFreeMemoryTop - HandOffHob->EfiFreeMemoryBottom; @@ -121,9 +121,9 @@ Returns: } *Hob = (VOID*) (UINTN) HandOffHob->EfiEndOfHobList; - ((EFI_HOB_GENERIC_HEADER*) *Hob)->HobType = Type; + ((EFI_HOB_GENERIC_HEADER*) *Hob)->HobType = Type; ((EFI_HOB_GENERIC_HEADER*) *Hob)->HobLength = Length; - ((EFI_HOB_GENERIC_HEADER*) *Hob)->Reserved = 0; + ((EFI_HOB_GENERIC_HEADER*) *Hob)->Reserved = 0; HobEnd = (EFI_HOB_GENERIC_HEADER*) ((UINTN) *Hob + Length); HandOffHob->EfiEndOfHobList = (EFI_PHYSICAL_ADDRESS) (UINTN) HobEnd; @@ -164,13 +164,13 @@ Returns: --*/ { EFI_HOB_HANDOFF_INFO_TABLE *Hob; - EFI_HOB_GENERIC_HEADER *HobEnd; + EFI_HOB_GENERIC_HEADER *HobEnd; - Hob = (VOID *)(UINTN)MemoryBegin; + Hob = (VOID *)(UINTN)MemoryBegin; HobEnd = (EFI_HOB_GENERIC_HEADER*) (Hob+1); - Hob->Header.HobType = EFI_HOB_TYPE_HANDOFF; - Hob->Header.HobLength = sizeof(EFI_HOB_HANDOFF_INFO_TABLE); - Hob->Header.Reserved = 0; + Hob->Header.HobType = EFI_HOB_TYPE_HANDOFF; + Hob->Header.HobLength = sizeof(EFI_HOB_HANDOFF_INFO_TABLE); + Hob->Header.Reserved = 0; HobEnd->HobType = EFI_HOB_TYPE_END_OF_HOB_LIST; HobEnd->HobLength = sizeof(EFI_HOB_GENERIC_HEADER); diff --git a/EdkModulePkg/Library/EdkDxeDebugLibReportStatusCode/DebugLib.c b/EdkModulePkg/Library/EdkDxeDebugLibReportStatusCode/DebugLib.c index 51ea6bd9ba..fed9ba4d66 100644 --- a/EdkModulePkg/Library/EdkDxeDebugLibReportStatusCode/DebugLib.c +++ b/EdkModulePkg/Library/EdkDxeDebugLibReportStatusCode/DebugLib.c @@ -1,176 +1,99 @@ -/*++ +/** @file + EFI Debug Library that installs Debug Level Protocol. -Copyright (c) 2006, Intel Corporation -All rights reserved. This program and the accompanying materials -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 -http://opensource.org/licenses/bsd-license.php - -THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + Copyright (c) 2006, Intel Corporation
+ All rights reserved. This program and the accompanying materials + 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 + http://opensource.org/licenses/bsd-license.php -Module Name: + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - DebugLib.c - -Abstract: +**/ - EFI Debug Library +STATIC BOOLEAN mDebugLevelInstalled = FALSE; +STATIC EFI_DEBUG_LEVEL_PROTOCOL mDebugLevel = { 0 }; ---*/ +/** + Installs Debug Level Protocol. + + The constructor function installs Debug Level Protocol on the ImageHandle. + It will ASSERT() if the installation fails and will always return EFI_SUCCESS. -static BOOLEAN mDebugLevelInstalled = FALSE; -static EFI_DEBUG_LEVEL_PROTOCOL mDebugLevel = { 0 }; + @param ImageHandle The firmware allocated handle for the EFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The constructor always returns EFI_SUCCESS. +**/ EFI_STATUS +EFIAPI DebugLibConstructor ( IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable ) -/*++ - -Routine Description: - -Arguments: - -Returns: - ---*/ { - EFI_STATUS Status; + EFI_STATUS Status; // - // Initialize Debug Level Protocol + // Initialize Debug Level Protocol. // mDebugLevel.DebugLevel = PcdGet32(PcdDebugPrintErrorLevel); // - // Install Debug Level Protocol + // Install Debug Level Protocol. // Status = gBS->InstallMultipleProtocolInterfaces ( &ImageHandle, - &gEfiDebugLevelProtocolGuid, &mDebugLevel, + &gEfiDebugLevelProtocolGuid, + &mDebugLevel, NULL ); ASSERT_EFI_ERROR (Status); // - // Set flag to show that the Debug Level Protocol has been installed + // Set flag to show that the Debug Level Protocol has been installed. // mDebugLevelInstalled = TRUE; - return EFI_SUCCESS; + return Status; } -VOID -EFIAPI -DebugAssert ( - IN CHAR8 *FileName, - IN UINTN LineNumber, - IN CHAR8 *Description - ) -/*++ - -Routine Description: - - Worker function for ASSERT(). If Error Logging hub is loaded log ASSERT - information. If Error Logging hub is not loaded CpuBreakpoint (). - - We use UINT64 buffers due to IPF alignment concerns. - -Arguments: - - FileName - File name of failing routine. - - LineNumber - Line number of failing ASSERT(). - - Description - Descritption, usally the assertion, - -Returns: - - None - ---*/ -{ - UINT64 Buffer[EFI_STATUS_CODE_DATA_MAX_SIZE / sizeof(UINT64)]; - EFI_DEBUG_ASSERT_DATA *AssertData; - UINTN TotalSize; - CHAR8 *Temp; - - if ((PcdGet8(PcdDebugPropertyMask) & DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED) == 0) { - return; - } - - // - // Make sure it will all fit in the passed in buffer - // - TotalSize = sizeof (EFI_DEBUG_ASSERT_DATA) + AsciiStrLen (FileName) + 1 + AsciiStrLen (Description) + 1; - if (TotalSize <= EFI_STATUS_CODE_DATA_MAX_SIZE) { - // - // Fill in EFI_DEBUG_ASSERT_DATA - // - AssertData = (EFI_DEBUG_ASSERT_DATA *)Buffer; - AssertData->LineNumber = (UINT32)LineNumber; +/** - // - // Copy Ascii FileName including NULL. - // - Temp = AsciiStrCpy ((CHAR8 *)(AssertData + 1), FileName); + Prints a debug message to the debug output device if the specified error level is enabled. - // - // Copy Ascii Description - // - AsciiStrCpy (Temp + AsciiStrLen(FileName) + 1, Description); + If any bit in ErrorLevel is also set in PcdDebugPrintErrorLevel, then print + the message specified by Format and the associated variable argument list to + the debug output device. - REPORT_STATUS_CODE_WITH_EXTENDED_DATA ( - (EFI_ERROR_CODE | EFI_ERROR_UNRECOVERED), - (EFI_SOFTWARE_DXE_BS_DRIVER | EFI_SW_EC_ILLEGAL_SOFTWARE_STATE), - AssertData, - TotalSize - ); - } + If Format is NULL, then ASSERT(). - // - // Put break point in module that contained the error. - // - CpuBreakpoint (); -} + @param ErrorLevel The error level of the debug message. + @param Format Format string for the debug message to print. +**/ VOID -DebugVPrint ( - IN UINTN ErrorLevel, - IN CHAR8 *Format, - IN VA_LIST Marker +EFIAPI +DebugPrint ( + IN UINTN ErrorLevel, + IN CONST CHAR8 *Format, + ... ) -/*++ - -Routine Description: - - Worker function for DEBUG(). If Error Logging hub is loaded log ASSERT - information. If Error Logging hub is not loaded do nothing. - - We use UINT64 buffers due to IPF alignment concerns. - -Arguments: - - ErrorLevel - If error level is set do the debug print. - - Format - String to use for the print, followed by Print arguments. - - Marker - VarArgs - -Returns: - - None - ---*/ { UINT64 Buffer[EFI_STATUS_CODE_DATA_MAX_SIZE / sizeof (UINT64)]; EFI_DEBUG_INFO *DebugInfo; UINTN TotalSize; UINTN Index; + VA_LIST Marker; UINT64 *ArgumentPointer; + // + // If Format is NULL, then ASSERT(). + // + ASSERT (Format != NULL); + // // Check driver Debug Level value and global debug level // @@ -184,7 +107,7 @@ Returns: } } - TotalSize = sizeof (EFI_DEBUG_INFO) + 12 * sizeof (UINT64 *) + AsciiStrLen (Format) + 1; + TotalSize = sizeof (EFI_DEBUG_INFO) + 12 * sizeof (UINT64) + AsciiStrLen (Format) + 1; if (TotalSize > EFI_STATUS_CODE_DATA_MAX_SIZE) { return; } @@ -198,57 +121,103 @@ Returns: // // 256 byte mini Var Arg stack. That is followed by the format string. // + VA_START (Marker, Format); for (Index = 0, ArgumentPointer = (UINT64 *)(DebugInfo + 1); Index < 12; Index++, ArgumentPointer++) { *ArgumentPointer = VA_ARG (Marker, UINT64); } + VA_END (Marker); AsciiStrCpy ((CHAR8 *)ArgumentPointer, Format); - // - // - // - REPORT_STATUS_CODE_WITH_EXTENDED_DATA ( + REPORT_STATUS_CODE_EX ( EFI_DEBUG_CODE, (EFI_SOFTWARE_DXE_BS_DRIVER | EFI_DC_UNSPECIFIED), + 0, + NULL, + &gEfiStatusCodeDataTypeDebugGuid, DebugInfo, TotalSize ); } -VOID -EFIAPI -DebugPrint ( - IN UINTN ErrorLevel, - IN CHAR8 *Format, - ... - ) -/*++ -Routine Description: +/** - Wrapper for DebugVPrint () - -Arguments: + Prints an assert message containing a filename, line number, and description. + This may be followed by a breakpoint or a dead loop. - ErrorLevel - If error level is set do the debug print. + 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 + CpuDeadLoop() is called. If neither of these bits are set, then this function + returns immediately after the message is printed to the debug output device. + DebugAssert() must actively prevent recusrsion. If DebugAssert() is called while + processing another DebugAssert(), then DebugAssert() must return immediately. - Format - String to use for the print, followed by Print arguments. + If FileName is NULL, then a string of "(NULL) Filename" is printed. - ... - Print arguments. + If Description is NULL, then a string of "(NULL) Description" is printed. -Returns: - - None + @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 + @param Description Pointer to the description of the assert condition. ---*/ +**/ +VOID +EFIAPI +DebugAssert ( + IN CONST CHAR8 *FileName, + IN UINTN LineNumber, + IN CONST CHAR8 *Description + ) { - VA_LIST Marker; + UINT64 Buffer[EFI_STATUS_CODE_DATA_MAX_SIZE / sizeof(UINT64)]; + EFI_DEBUG_ASSERT_DATA *AssertData; + UINTN TotalSize; + CHAR8 *Temp; - VA_START (Marker, Format); - DebugVPrint (ErrorLevel, Format, Marker); - VA_END (Marker); + // + // Make sure it will all fit in the passed in buffer. + // + TotalSize = sizeof (EFI_DEBUG_ASSERT_DATA) + AsciiStrLen (FileName) + 1 + AsciiStrLen (Description) + 1; + if (TotalSize <= EFI_STATUS_CODE_DATA_MAX_SIZE) { + // + // Fill in EFI_DEBUG_ASSERT_DATA + // + AssertData = (EFI_DEBUG_ASSERT_DATA *)Buffer; + AssertData->LineNumber = (UINT32)LineNumber; + + // + // Copy Ascii FileName including NULL. + // + Temp = AsciiStrCpy ((CHAR8 *)(AssertData + 1), FileName); + + // + // Copy Ascii Description. + // + AsciiStrCpy (Temp + AsciiStrLen (FileName) + 1, Description); + + REPORT_STATUS_CODE_WITH_EXTENDED_DATA ( + (EFI_ERROR_CODE | EFI_ERROR_UNRECOVERED), + (EFI_SOFTWARE_DXE_BS_DRIVER | EFI_SW_EC_ILLEGAL_SOFTWARE_STATE), + AssertData, + TotalSize + ); + } + + // + // Generate a Breakpoint, DeadLoop, or NOP based on PCD settings + // + if ((PcdGet8(PcdDebugPropertyMask) & DEBUG_PROPERTY_ASSERT_BREAKPOINT_ENABLED) != 0) { + CpuBreakpoint (); + } else if ((PcdGet8(PcdDebugPropertyMask) & DEBUG_PROPERTY_ASSERT_DEADLOOP_ENABLED) != 0) { + CpuDeadLoop (); + } } + /** + Fills a target buffer with PcdDebugClearMemoryValue, and returns the target buffer. This function fills Length bytes of Buffer with the value specified by @@ -258,8 +227,8 @@ Returns: If Length is greater than (MAX_ADDRESS – Buffer + 1), then ASSERT(). - @param Buffer Pointer to the target buffer to fill with PcdDebugClearMemoryValue. - @param Length Number of bytes in Buffer to fill with zeros PcdDebugClearMemoryValue. + @param Buffer Pointer to the target buffer to fill with PcdDebugClearMemoryValue. + @param Length Number of bytes in Buffer to fill with zeros PcdDebugClearMemoryValue. @return Buffer @@ -271,11 +240,29 @@ DebugClearMemory ( IN UINTN Length ) { -// SetMem (Buffer, Length, PcdGet8(PcdDebugClearMemoryValue)); - SetMem (Buffer, Length, 0xAF); - return Buffer; + // + // If Buffer is NULL, then ASSERT(). + // + ASSERT (Buffer != NULL); + + // + // 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. + + This function returns TRUE if the DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED bit of + PcdDebugProperyMask is set. Otherwise FALSE is returned. + + @retval TRUE The DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED bit of PcdDebugProperyMask is set. + @retval FALSE The DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED bit of PcdDebugProperyMask is clear. + +**/ BOOLEAN EFIAPI DebugAssertEnabled ( @@ -285,6 +272,18 @@ DebugAssertEnabled ( return ((PcdGet8(PcdDebugPropertyMask) & DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED) != 0); } + +/** + + Returns TRUE if DEBUG()macros are enabled. + + This function returns TRUE if the DEBUG_PROPERTY_DEBUG_PRINT_ENABLED bit of + PcdDebugProperyMask is set. Otherwise FALSE is returned. + + @retval TRUE The DEBUG_PROPERTY_DEBUG_PRINT_ENABLED bit of PcdDebugProperyMask is set. + @retval FALSE The DEBUG_PROPERTY_DEBUG_PRINT_ENABLED bit of PcdDebugProperyMask is clear. + +**/ BOOLEAN EFIAPI DebugPrintEnabled ( @@ -294,6 +293,18 @@ DebugPrintEnabled ( return ((PcdGet8(PcdDebugPropertyMask) & DEBUG_PROPERTY_DEBUG_PRINT_ENABLED) != 0); } + +/** + + Returns TRUE if DEBUG_CODE()macros are enabled. + + This function returns TRUE if the DEBUG_PROPERTY_DEBUG_CODE_ENABLED bit of + PcdDebugProperyMask is set. Otherwise FALSE is returned. + + @retval TRUE The DEBUG_PROPERTY_DEBUG_CODE_ENABLED bit of PcdDebugProperyMask is set. + @retval FALSE The DEBUG_PROPERTY_DEBUG_CODE_ENABLED bit of PcdDebugProperyMask is clear. + +**/ BOOLEAN EFIAPI DebugCodeEnabled ( @@ -303,6 +314,18 @@ DebugCodeEnabled ( return ((PcdGet8(PcdDebugPropertyMask) & DEBUG_PROPERTY_DEBUG_CODE_ENABLED) != 0); } + +/** + + Returns TRUE if DEBUG_CLEAR_MEMORY()macro is enabled. + + This function returns TRUE if the DEBUG_PROPERTY_DEBUG_CLEAR_MEMORY_ENABLED bit of + PcdDebugProperyMask is set. Otherwise FALSE is returned. + + @retval TRUE The DEBUG_PROPERTY_DEBUG_CLEAR_MEMORY_ENABLED bit of PcdDebugProperyMask is set. + @retval FALSE The DEBUG_PROPERTY_DEBUG_CLEAR_MEMORY_ENABLED bit of PcdDebugProperyMask is clear. + +**/ BOOLEAN EFIAPI DebugClearMemoryEnabled ( @@ -311,4 +334,3 @@ DebugClearMemoryEnabled ( { return ((PcdGet8(PcdDebugPropertyMask) & DEBUG_PROPERTY_CLEAR_MEMORY_ENABLED) != 0); } - diff --git a/EdkModulePkg/Library/EdkDxeDebugLibReportStatusCode/EdkDxeDebugLibReportStatusCode.msa b/EdkModulePkg/Library/EdkDxeDebugLibReportStatusCode/EdkDxeDebugLibReportStatusCode.msa index 3de21286b0..752bc570a4 100644 --- a/EdkModulePkg/Library/EdkDxeDebugLibReportStatusCode/EdkDxeDebugLibReportStatusCode.msa +++ b/EdkModulePkg/Library/EdkDxeDebugLibReportStatusCode/EdkDxeDebugLibReportStatusCode.msa @@ -49,10 +49,15 @@ - + DebugLevel + + + StatusCodeDataTypeDebug + + EFI_SPECIFICATION_VERSION 0x00020000 EDK_RELEASE_VERSION 0x00090000 @@ -66,6 +71,11 @@ gEfiMdePkgTokenSpaceGuid + + PcdDebugClearMemoryValue + FIX_ME_PcdDebugClearMemoryValue + + PcdDebugPrintErrorLevel gEfiMdePkgTokenSpaceGuid diff --git a/EdkModulePkg/Library/EdkUefiDebugLibConOut/DebugLib.c b/EdkModulePkg/Library/EdkUefiDebugLibConOut/DebugLib.c index 9945143dc4..5f5f2c56ca 100644 --- a/EdkModulePkg/Library/EdkUefiDebugLibConOut/DebugLib.c +++ b/EdkModulePkg/Library/EdkUefiDebugLibConOut/DebugLib.c @@ -1,105 +1,99 @@ -/*++ +/** @file + UEFI Debug Library that uses PrintLib to send messages to CONOUT. -Copyright (c) 2006, Intel Corporation -All rights reserved. This program and the accompanying materials -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 -http://opensource.org/licenses/bsd-license.php - -THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + Copyright (c) 2006, Intel Corporation
+ All rights reserved. This program and the accompanying materials + 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 + http://opensource.org/licenses/bsd-license.php -Module Name: + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - DebugLib.c +**/ -Abstract: +// +// Define the maximum debug and assert message length that this library supports. +// +#define MAX_DEBUG_MESSAGE_LENGTH 0x100 - UEFI Debug Library that uses PrintLib to send messages to CONOUT +STATIC BOOLEAN mDebugLevelInstalled = FALSE; +STATIC EFI_DEBUG_LEVEL_PROTOCOL mDebugLevel = { 0 }; ---*/ +/** + Installs Debug Level Protocol. + + The constructor function installs Debug Level Protocol on the ImageHandle. + It will ASSERT() if the installation fails and will always return EFI_SUCCESS. -static BOOLEAN mDebugLevelInstalled = FALSE; -static EFI_DEBUG_LEVEL_PROTOCOL mDebugLevel = { 0 }; + @param ImageHandle The firmware allocated handle for the EFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The constructor always returns EFI_SUCCESS. +**/ EFI_STATUS +EFIAPI DebugLibConstructor ( IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable ) -/*++ - -Routine Description: - -Arguments: - -Returns: - ---*/ { - EFI_STATUS Status; + EFI_STATUS Status; // - // Initialize Debug Level Protocol + // Initialize Debug Level Protocol. // mDebugLevel.DebugLevel = PcdGet32(PcdDebugPrintErrorLevel); // - // Install Debug Level Protocol + // Install Debug Level Protocol. // Status = gBS->InstallMultipleProtocolInterfaces ( &ImageHandle, - &gEfiDebugLevelProtocolGuid, &mDebugLevel, + &gEfiDebugLevelProtocolGuid, + &mDebugLevel, NULL ); ASSERT_EFI_ERROR (Status); // - // Set flag to show that the Debug Level Protocol has been installed + // Set flag to show that the Debug Level Protocol has been installed. // mDebugLevelInstalled = TRUE; - return EFI_SUCCESS; + return Status; } -VOID -EFIAPI -DebugPrint ( - IN UINTN ErrorLevel, - IN CHAR8 *Format, - ... - ) -/*++ - -Routine Description: - - Wrapper for DebugVPrint () - -Arguments: +/** - ErrorLevel - If error level is set do the debug print. + Prints a debug message to the debug output device if the specified error level is enabled. - Format - String to use for the print, followed by Print arguments. + If any bit in ErrorLevel is also set in PcdDebugPrintErrorLevel, then print + the message specified by Format and the associated variable argument list to + the debug output device. - ... - Print arguments. + If Format is NULL, then ASSERT(). -Returns: - - None + @param ErrorLevel The error level of the debug message. + @param Format Format string for the debug message to print. ---*/ +**/ +VOID +EFIAPI +DebugPrint ( + IN UINTN ErrorLevel, + IN CONST CHAR8 *Format, + ... + ) { - CHAR16 Buffer[0x100]; - CHAR16 UnicodeBuffer[0x100]; - UINT32 Index; + CHAR16 Buffer[MAX_DEBUG_MESSAGE_LENGTH]; VA_LIST Marker; // - // Check to see if CONOUT is avilable + // If Format is NULL, then ASSERT(). // - if (gST->ConOut == NULL) { - return; - } + ASSERT (Format != NULL); // // Check driver Debug Level value and global debug level @@ -114,83 +108,80 @@ Returns: } } - // - // BUGBUG: Need print that take CHAR8 Format and returns CHAR16 Buffer - // - for (Index = 0; Format[Index] != 0; Index++) { - UnicodeBuffer[Index] = Format[Index]; - } - UnicodeBuffer[Index] = Format[Index]; - // // Convert the DEBUG() message to a Unicode String // VA_START (Marker, Format); - UnicodeVSPrint (Buffer, sizeof (Buffer), UnicodeBuffer, Marker); + UnicodeVSPrintAsciiFormat (Buffer, sizeof (Buffer), Format, Marker); VA_END (Marker); // - // Send the print string to the Standard Error device + // Send the print string to the Console Output device if CONOUT is available. // - gST->ConOut->OutputString (gST->ConOut, Buffer); + if (gST->ConOut != NULL) { + gST->ConOut->OutputString (gST->ConOut, Buffer); + } } -VOID -EFIAPI -DebugAssert ( - IN CHAR8 *FileName, - IN UINTN LineNumber, - IN CHAR8 *Description - ) -/*++ -Routine Description: - - Worker function for ASSERT(). If Error Logging hub is loaded log ASSERT - information. If Error Logging hub is not loaded CpuBreakpoint (). +/** - We use UINT64 buffers due to IPF alignment concerns. + Prints an assert message containing a filename, line number, and description. + This may be followed by a breakpoint or a dead loop. -Arguments: + 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 + CpuDeadLoop() is called. If neither of these bits are set, then this function + returns immediately after the message is printed to the debug output device. + DebugAssert() must actively prevent recusrsion. If DebugAssert() is called while + processing another DebugAssert(), then DebugAssert() must return immediately. - FileName - File name of failing routine. + If FileName is NULL, then a string of "(NULL) Filename" is printed. - LineNumber - Line number of failing ASSERT(). + If Description is NULL, then a string of "(NULL) Description" is printed. - Description - Descritption, usally the assertion, - -Returns: - - None + @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 + @param Description Pointer to the description of the assert condition. ---*/ +**/ +VOID +EFIAPI +DebugAssert ( + IN CONST CHAR8 *FileName, + IN UINTN LineNumber, + IN CONST CHAR8 *Description + ) { - CHAR16 Buffer[0x100]; - - // - // Check to see if CONOUT is avilable - // - if (gST->ConOut == NULL) { - return; - } + CHAR16 Buffer[MAX_DEBUG_MESSAGE_LENGTH]; // // Generate the ASSERT() message in Unicode format // - UnicodeSPrint (Buffer, sizeof (Buffer), (CHAR16 *)L"ASSERT %s(%d): %s\n", FileName, LineNumber, Description); + UnicodeSPrintAsciiFormat (Buffer, sizeof (Buffer), "ASSERT %s(%d): %s\n", FileName, LineNumber, Description); // - // Send the print string to the Standard Error device + // Send the print string to the Console Output device if CONOUT is available. // - gST->ConOut->OutputString (gST->ConOut, Buffer); + if (gST->ConOut != NULL) { + gST->ConOut->OutputString (gST->ConOut, Buffer); + } // - // Put break point in module that contained the error. + // Generate a Breakpoint, DeadLoop, or NOP based on PCD settings // - CpuBreakpoint (); + if ((PcdGet8(PcdDebugPropertyMask) & DEBUG_PROPERTY_ASSERT_BREAKPOINT_ENABLED) != 0) { + CpuBreakpoint (); + } else if ((PcdGet8(PcdDebugPropertyMask) & DEBUG_PROPERTY_ASSERT_DEADLOOP_ENABLED) != 0) { + CpuDeadLoop (); + } } + /** + Fills a target buffer with PcdDebugClearMemoryValue, and returns the target buffer. This function fills Length bytes of Buffer with the value specified by @@ -200,8 +191,8 @@ Returns: If Length is greater than (MAX_ADDRESS – Buffer + 1), then ASSERT(). - @param Buffer Pointer to the target buffer to fill with PcdDebugClearMemoryValue. - @param Length Number of bytes in Buffer to fill with zeros PcdDebugClearMemoryValue. + @param Buffer Pointer to the target buffer to fill with PcdDebugClearMemoryValue. + @param Length Number of bytes in Buffer to fill with zeros PcdDebugClearMemoryValue. @return Buffer @@ -213,11 +204,29 @@ DebugClearMemory ( IN UINTN Length ) { -// SetMem (Buffer, Length, PcdGet8(PcdDebugClearMemoryValue)); - SetMem (Buffer, Length, 0xAF); - return Buffer; + // + // If Buffer is NULL, then ASSERT(). + // + ASSERT (Buffer != NULL); + + // + // 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. + + This function returns TRUE if the DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED bit of + PcdDebugProperyMask is set. Otherwise FALSE is returned. + + @retval TRUE The DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED bit of PcdDebugProperyMask is set. + @retval FALSE The DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED bit of PcdDebugProperyMask is clear. + +**/ BOOLEAN EFIAPI DebugAssertEnabled ( @@ -227,6 +236,18 @@ DebugAssertEnabled ( return ((PcdGet8(PcdDebugPropertyMask) & DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED) != 0); } + +/** + + Returns TRUE if DEBUG()macros are enabled. + + This function returns TRUE if the DEBUG_PROPERTY_DEBUG_PRINT_ENABLED bit of + PcdDebugProperyMask is set. Otherwise FALSE is returned. + + @retval TRUE The DEBUG_PROPERTY_DEBUG_PRINT_ENABLED bit of PcdDebugProperyMask is set. + @retval FALSE The DEBUG_PROPERTY_DEBUG_PRINT_ENABLED bit of PcdDebugProperyMask is clear. + +**/ BOOLEAN EFIAPI DebugPrintEnabled ( @@ -236,6 +257,18 @@ DebugPrintEnabled ( return ((PcdGet8(PcdDebugPropertyMask) & DEBUG_PROPERTY_DEBUG_PRINT_ENABLED) != 0); } + +/** + + Returns TRUE if DEBUG_CODE()macros are enabled. + + This function returns TRUE if the DEBUG_PROPERTY_DEBUG_CODE_ENABLED bit of + PcdDebugProperyMask is set. Otherwise FALSE is returned. + + @retval TRUE The DEBUG_PROPERTY_DEBUG_CODE_ENABLED bit of PcdDebugProperyMask is set. + @retval FALSE The DEBUG_PROPERTY_DEBUG_CODE_ENABLED bit of PcdDebugProperyMask is clear. + +**/ BOOLEAN EFIAPI DebugCodeEnabled ( @@ -245,6 +278,18 @@ DebugCodeEnabled ( return ((PcdGet8(PcdDebugPropertyMask) & DEBUG_PROPERTY_DEBUG_CODE_ENABLED) != 0); } + +/** + + Returns TRUE if DEBUG_CLEAR_MEMORY()macro is enabled. + + This function returns TRUE if the DEBUG_PROPERTY_DEBUG_CLEAR_MEMORY_ENABLED bit of + PcdDebugProperyMask is set. Otherwise FALSE is returned. + + @retval TRUE The DEBUG_PROPERTY_DEBUG_CLEAR_MEMORY_ENABLED bit of PcdDebugProperyMask is set. + @retval FALSE The DEBUG_PROPERTY_DEBUG_CLEAR_MEMORY_ENABLED bit of PcdDebugProperyMask is clear. + +**/ BOOLEAN EFIAPI DebugClearMemoryEnabled ( diff --git a/EdkModulePkg/Library/EdkUefiDebugLibConOut/EdkUefiDebugLibConOut.msa b/EdkModulePkg/Library/EdkUefiDebugLibConOut/EdkUefiDebugLibConOut.msa index 915dad137a..6f7db31d7f 100644 --- a/EdkModulePkg/Library/EdkUefiDebugLibConOut/EdkUefiDebugLibConOut.msa +++ b/EdkModulePkg/Library/EdkUefiDebugLibConOut/EdkUefiDebugLibConOut.msa @@ -53,6 +53,11 @@ DebugLevel + + + StatusCodeDataTypeDebug + + EFI_SPECIFICATION_VERSION 0x00020000 EDK_RELEASE_VERSION 0x00090000 @@ -66,6 +71,11 @@ gEfiMdePkgTokenSpaceGuid
+ + PcdDebugClearMemoryValue + FIX_ME_PcdDebugClearMemoryValue + + PcdDebugPrintErrorLevel gEfiMdePkgTokenSpaceGuid diff --git a/EdkModulePkg/Library/EdkUefiDebugLibStdErr/DebugLib.c b/EdkModulePkg/Library/EdkUefiDebugLibStdErr/DebugLib.c index dc0c3ab497..2016701284 100644 --- a/EdkModulePkg/Library/EdkUefiDebugLibStdErr/DebugLib.c +++ b/EdkModulePkg/Library/EdkUefiDebugLibStdErr/DebugLib.c @@ -1,105 +1,99 @@ -/*++ +/** @file + UEFI Debug Library that uses PrintLib to send messages to STDERR. -Copyright (c) 2006, Intel Corporation -All rights reserved. This program and the accompanying materials -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 -http://opensource.org/licenses/bsd-license.php - -THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + Copyright (c) 2006, Intel Corporation
+ All rights reserved. This program and the accompanying materials + 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 + http://opensource.org/licenses/bsd-license.php -Module Name: + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - DebugLib.c +**/ -Abstract: +// +// Define the maximum debug and assert message length that this library supports. +// +#define MAX_DEBUG_MESSAGE_LENGTH 0x100 - UEFI Debug Library that uses PrintLib to send messages to STDERR +STATIC BOOLEAN mDebugLevelInstalled = FALSE; +STATIC EFI_DEBUG_LEVEL_PROTOCOL mDebugLevel = { 0 }; ---*/ +/** + Installs Debug Level Protocol. + + The constructor function installs Debug Level Protocol on the ImageHandle. + It will ASSERT() if the installation fails and will always return EFI_SUCCESS. -static BOOLEAN mDebugLevelInstalled = FALSE; -static EFI_DEBUG_LEVEL_PROTOCOL mDebugLevel = { 0 }; + @param ImageHandle The firmware allocated handle for the EFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The constructor always returns EFI_SUCCESS. +**/ EFI_STATUS +EFIAPI DebugLibConstructor ( IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable ) -/*++ - -Routine Description: - -Arguments: - -Returns: - ---*/ { - EFI_STATUS Status; + EFI_STATUS Status; // - // Initialize Debug Level Protocol + // Initialize Debug Level Protocol. // mDebugLevel.DebugLevel = PcdGet32(PcdDebugPrintErrorLevel); // - // Install Debug Level Protocol + // Install Debug Level Protocol. // Status = gBS->InstallMultipleProtocolInterfaces ( &ImageHandle, - &gEfiDebugLevelProtocolGuid, &mDebugLevel, + &gEfiDebugLevelProtocolGuid, + &mDebugLevel, NULL ); ASSERT_EFI_ERROR (Status); // - // Set flag to show that the Debug Level Protocol has been installed + // Set flag to show that the Debug Level Protocol has been installed. // mDebugLevelInstalled = TRUE; - return EFI_SUCCESS; + return Status; } -VOID -EFIAPI -DebugPrint ( - IN UINTN ErrorLevel, - IN CHAR8 *Format, - ... - ) -/*++ - -Routine Description: - - Wrapper for DebugVPrint () - -Arguments: +/** - ErrorLevel - If error level is set do the debug print. + Prints a debug message to the debug output device if the specified error level is enabled. - Format - String to use for the print, followed by Print arguments. + If any bit in ErrorLevel is also set in PcdDebugPrintErrorLevel, then print + the message specified by Format and the associated variable argument list to + the debug output device. - ... - Print arguments. + If Format is NULL, then ASSERT(). -Returns: - - None + @param ErrorLevel The error level of the debug message. + @param Format Format string for the debug message to print. ---*/ +**/ +VOID +EFIAPI +DebugPrint ( + IN UINTN ErrorLevel, + IN CONST CHAR8 *Format, + ... + ) { - CHAR16 Buffer[0x100]; - CHAR16 UnicodeBuffer[0x100]; - UINT32 Index; + CHAR16 Buffer[MAX_DEBUG_MESSAGE_LENGTH]; VA_LIST Marker; // - // Check to see if STDERR is avilable + // If Format is NULL, then ASSERT(). // - if (gST->StdErr == NULL) { - return; - } + ASSERT (Format != NULL); // // Check driver Debug Level value and global debug level @@ -114,83 +108,80 @@ Returns: } } - // - // BUGBUG: Need print that take CHAR8 Format and returns CHAR16 Buffer - // - for (Index = 0; Format[Index] != 0; Index++) { - UnicodeBuffer[Index] = Format[Index]; - } - UnicodeBuffer[Index] = Format[Index]; - // // Convert the DEBUG() message to a Unicode String // VA_START (Marker, Format); - UnicodeVSPrint (Buffer, sizeof (Buffer), UnicodeBuffer, Marker); + UnicodeVSPrintAsciiFormat (Buffer, sizeof (Buffer), Format, Marker); VA_END (Marker); // - // Send the print string to the Standard Error device + // Send the print string to the Standard Error device if STDERR is available. // - gST->StdErr->OutputString (gST->StdErr, Buffer); + if (gST->StdErr != NULL) { + gST->StdErr->OutputString (gST->StdErr, Buffer); + } } -VOID -EFIAPI -DebugAssert ( - IN CHAR8 *FileName, - IN UINTN LineNumber, - IN CHAR8 *Description - ) -/*++ -Routine Description: - - Worker function for ASSERT(). If Error Logging hub is loaded log ASSERT - information. If Error Logging hub is not loaded CpuBreakpoint (). +/** - We use UINT64 buffers due to IPF alignment concerns. + Prints an assert message containing a filename, line number, and description. + This may be followed by a breakpoint or a dead loop. -Arguments: + 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 + CpuDeadLoop() is called. If neither of these bits are set, then this function + returns immediately after the message is printed to the debug output device. + DebugAssert() must actively prevent recusrsion. If DebugAssert() is called while + processing another DebugAssert(), then DebugAssert() must return immediately. - FileName - File name of failing routine. + If FileName is NULL, then a string of "(NULL) Filename" is printed. - LineNumber - Line number of failing ASSERT(). + If Description is NULL, then a string of "(NULL) Description" is printed. - Description - Descritption, usally the assertion, - -Returns: - - None + @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 + @param Description Pointer to the description of the assert condition. ---*/ +**/ +VOID +EFIAPI +DebugAssert ( + IN CONST CHAR8 *FileName, + IN UINTN LineNumber, + IN CONST CHAR8 *Description + ) { - CHAR16 Buffer[0x100]; - - // - // Check to see if STDERR is avilable - // - if (gST->StdErr == NULL) { - return; - } + CHAR16 Buffer[MAX_DEBUG_MESSAGE_LENGTH]; // // Generate the ASSERT() message in Unicode format // - UnicodeSPrint (Buffer, sizeof (Buffer), (CHAR16 *)L"ASSERT %s(%d): %s\n", FileName, LineNumber, Description); + UnicodeSPrintAsciiFormat (Buffer, sizeof (Buffer), "ASSERT %s(%d): %s\n", FileName, LineNumber, Description); // - // Send the print string to the Standard Error device + // Send the print string to the Standard Error device if STDERR is available. // - gST->StdErr->OutputString (gST->StdErr, Buffer); + if (gST->StdErr != NULL) { + gST->StdErr->OutputString (gST->StdErr, Buffer); + } // - // Put break point in module that contained the error. + // Generate a Breakpoint, DeadLoop, or NOP based on PCD settings // - CpuBreakpoint (); + if ((PcdGet8(PcdDebugPropertyMask) & DEBUG_PROPERTY_ASSERT_BREAKPOINT_ENABLED) != 0) { + CpuBreakpoint (); + } else if ((PcdGet8(PcdDebugPropertyMask) & DEBUG_PROPERTY_ASSERT_DEADLOOP_ENABLED) != 0) { + CpuDeadLoop (); + } } + /** + Fills a target buffer with PcdDebugClearMemoryValue, and returns the target buffer. This function fills Length bytes of Buffer with the value specified by @@ -200,8 +191,8 @@ Returns: If Length is greater than (MAX_ADDRESS – Buffer + 1), then ASSERT(). - @param Buffer Pointer to the target buffer to fill with PcdDebugClearMemoryValue. - @param Length Number of bytes in Buffer to fill with zeros PcdDebugClearMemoryValue. + @param Buffer Pointer to the target buffer to fill with PcdDebugClearMemoryValue. + @param Length Number of bytes in Buffer to fill with zeros PcdDebugClearMemoryValue. @return Buffer @@ -213,11 +204,29 @@ DebugClearMemory ( IN UINTN Length ) { -// SetMem (Buffer, Length, PcdGet8(PcdDebugClearMemoryValue)); - SetMem (Buffer, Length, 0xAF); - return Buffer; + // + // If Buffer is NULL, then ASSERT(). + // + ASSERT (Buffer != NULL); + + // + // 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. + + This function returns TRUE if the DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED bit of + PcdDebugProperyMask is set. Otherwise FALSE is returned. + + @retval TRUE The DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED bit of PcdDebugProperyMask is set. + @retval FALSE The DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED bit of PcdDebugProperyMask is clear. + +**/ BOOLEAN EFIAPI DebugAssertEnabled ( @@ -227,6 +236,18 @@ DebugAssertEnabled ( return ((PcdGet8(PcdDebugPropertyMask) & DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED) != 0); } + +/** + + Returns TRUE if DEBUG()macros are enabled. + + This function returns TRUE if the DEBUG_PROPERTY_DEBUG_PRINT_ENABLED bit of + PcdDebugProperyMask is set. Otherwise FALSE is returned. + + @retval TRUE The DEBUG_PROPERTY_DEBUG_PRINT_ENABLED bit of PcdDebugProperyMask is set. + @retval FALSE The DEBUG_PROPERTY_DEBUG_PRINT_ENABLED bit of PcdDebugProperyMask is clear. + +**/ BOOLEAN EFIAPI DebugPrintEnabled ( @@ -236,6 +257,18 @@ DebugPrintEnabled ( return ((PcdGet8(PcdDebugPropertyMask) & DEBUG_PROPERTY_DEBUG_PRINT_ENABLED) != 0); } + +/** + + Returns TRUE if DEBUG_CODE()macros are enabled. + + This function returns TRUE if the DEBUG_PROPERTY_DEBUG_CODE_ENABLED bit of + PcdDebugProperyMask is set. Otherwise FALSE is returned. + + @retval TRUE The DEBUG_PROPERTY_DEBUG_CODE_ENABLED bit of PcdDebugProperyMask is set. + @retval FALSE The DEBUG_PROPERTY_DEBUG_CODE_ENABLED bit of PcdDebugProperyMask is clear. + +**/ BOOLEAN EFIAPI DebugCodeEnabled ( @@ -245,6 +278,18 @@ DebugCodeEnabled ( return ((PcdGet8(PcdDebugPropertyMask) & DEBUG_PROPERTY_DEBUG_CODE_ENABLED) != 0); } + +/** + + Returns TRUE if DEBUG_CLEAR_MEMORY()macro is enabled. + + This function returns TRUE if the DEBUG_PROPERTY_DEBUG_CLEAR_MEMORY_ENABLED bit of + PcdDebugProperyMask is set. Otherwise FALSE is returned. + + @retval TRUE The DEBUG_PROPERTY_DEBUG_CLEAR_MEMORY_ENABLED bit of PcdDebugProperyMask is set. + @retval FALSE The DEBUG_PROPERTY_DEBUG_CLEAR_MEMORY_ENABLED bit of PcdDebugProperyMask is clear. + +**/ BOOLEAN EFIAPI DebugClearMemoryEnabled ( diff --git a/EdkModulePkg/Library/EdkUefiDebugLibStdErr/EdkUefiDebugLibStdErr.msa b/EdkModulePkg/Library/EdkUefiDebugLibStdErr/EdkUefiDebugLibStdErr.msa index 327e12621f..2ab58bbbd9 100644 --- a/EdkModulePkg/Library/EdkUefiDebugLibStdErr/EdkUefiDebugLibStdErr.msa +++ b/EdkModulePkg/Library/EdkUefiDebugLibStdErr/EdkUefiDebugLibStdErr.msa @@ -19,7 +19,7 @@ IA32 X64 IPF EBC false - EdkUefiDebugLibStdErr + EdkUefiDebugLibConOut @@ -53,6 +53,11 @@ DebugLevel + + + StatusCodeDataTypeDebug + + EFI_SPECIFICATION_VERSION 0x00020000 EDK_RELEASE_VERSION 0x00090000 @@ -66,6 +71,11 @@ gEfiMdePkgTokenSpaceGuid
+ + PcdDebugClearMemoryValue + FIX_ME_PcdDebugClearMemoryValue + + PcdDebugPrintErrorLevel gEfiMdePkgTokenSpaceGuid diff --git a/EdkModulePkg/Universal/Console/ConSplitter/Dxe/ConSplitter.mbd b/EdkModulePkg/Universal/Console/ConSplitter/Dxe/ConSplitter.mbd index 6da93681ff..8d32865aa1 100644 --- a/EdkModulePkg/Universal/Console/ConSplitter/Dxe/ConSplitter.mbd +++ b/EdkModulePkg/Universal/Console/ConSplitter/Dxe/ConSplitter.mbd @@ -29,7 +29,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. UefiBootServicesTableLib - UefiMemoryLib + DxeMemoryLib UefiLib UefiDriverEntryPoint UefiDriverModelLib diff --git a/EdkModulePkg/Universal/Console/GraphicsConsole/Dxe/GraphicsConsole.mbd b/EdkModulePkg/Universal/Console/GraphicsConsole/Dxe/GraphicsConsole.mbd index b23fd9220c..7e6d607aae 100644 --- a/EdkModulePkg/Universal/Console/GraphicsConsole/Dxe/GraphicsConsole.mbd +++ b/EdkModulePkg/Universal/Console/GraphicsConsole/Dxe/GraphicsConsole.mbd @@ -31,7 +31,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. UefiBootServicesTableLib UefiDriverEntryPoint UefiLib - UefiMemoryLib + DxeMemoryLib HiiLib UefiDriverModelLib DxeReportStatusCodeLib diff --git a/EdkModulePkg/Universal/Console/Terminal/Dxe/Terminal.mbd b/EdkModulePkg/Universal/Console/Terminal/Dxe/Terminal.mbd index 230399e76e..602b027cd5 100644 --- a/EdkModulePkg/Universal/Console/Terminal/Dxe/Terminal.mbd +++ b/EdkModulePkg/Universal/Console/Terminal/Dxe/Terminal.mbd @@ -30,7 +30,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. UefiBootServicesTableLib UefiRuntimeServicesTableLib - UefiMemoryLib + DxeMemoryLib UefiLib UefiDriverEntryPoint UefiDriverModelLib diff --git a/EdkModulePkg/Universal/DataHub/DataHub/Dxe/DataHub.mbd b/EdkModulePkg/Universal/DataHub/DataHub/Dxe/DataHub.mbd index d117880c41..b03adbb77d 100644 --- a/EdkModulePkg/Universal/DataHub/DataHub/Dxe/DataHub.mbd +++ b/EdkModulePkg/Universal/DataHub/DataHub/Dxe/DataHub.mbd @@ -30,7 +30,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. UefiBootServicesTableLib UefiRuntimeServicesTableLib - UefiMemoryLib + DxeMemoryLib UefiLib UefiDriverEntryPoint DxeReportStatusCodeLib diff --git a/EdkModulePkg/Universal/DataHub/DataHubStdErr/Dxe/DataHubStdErr.mbd b/EdkModulePkg/Universal/DataHub/DataHubStdErr/Dxe/DataHubStdErr.mbd index 3df19f1dc0..00378d69e9 100644 --- a/EdkModulePkg/Universal/DataHub/DataHubStdErr/Dxe/DataHubStdErr.mbd +++ b/EdkModulePkg/Universal/DataHub/DataHubStdErr/Dxe/DataHubStdErr.mbd @@ -29,7 +29,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. UefiBootServicesTableLib - UefiMemoryLib + DxeMemoryLib UefiDriverEntryPoint DxeReportStatusCodeLib PeiDxeDebugLibReportStatusCode diff --git a/EdkModulePkg/Universal/DebugSupport/Dxe/DebugSupport.mbd b/EdkModulePkg/Universal/DebugSupport/Dxe/DebugSupport.mbd index db485cb445..c85b5f0d0f 100644 --- a/EdkModulePkg/Universal/DebugSupport/Dxe/DebugSupport.mbd +++ b/EdkModulePkg/Universal/DebugSupport/Dxe/DebugSupport.mbd @@ -30,7 +30,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. UefiBootServicesTableLib BaseLib - UefiMemoryLib + DxeMemoryLib UefiDriverEntryPoint DxeReportStatusCodeLib PeiDxeDebugLibReportStatusCode diff --git a/EdkModulePkg/Universal/Debugger/Debugport/Dxe/DebugPort.mbd b/EdkModulePkg/Universal/Debugger/Debugport/Dxe/DebugPort.mbd index 5a5f505ca5..a50e07d3dd 100644 --- a/EdkModulePkg/Universal/Debugger/Debugport/Dxe/DebugPort.mbd +++ b/EdkModulePkg/Universal/Debugger/Debugport/Dxe/DebugPort.mbd @@ -30,7 +30,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. UefiBootServicesTableLib UefiRuntimeServicesTableLib - UefiMemoryLib + DxeMemoryLib UefiLib UefiDriverEntryPoint UefiDriverModelLib diff --git a/EdkModulePkg/Universal/Disk/DiskIo/Dxe/DiskIo.mbd b/EdkModulePkg/Universal/Disk/DiskIo/Dxe/DiskIo.mbd index 5cddc5ae37..36b10a9934 100644 --- a/EdkModulePkg/Universal/Disk/DiskIo/Dxe/DiskIo.mbd +++ b/EdkModulePkg/Universal/Disk/DiskIo/Dxe/DiskIo.mbd @@ -29,7 +29,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. UefiBootServicesTableLib - UefiMemoryLib + DxeMemoryLib UefiLib UefiDriverEntryPoint UefiDriverModelLib diff --git a/EdkModulePkg/Universal/Disk/Partition/Dxe/Partition.mbd b/EdkModulePkg/Universal/Disk/Partition/Dxe/Partition.mbd index 628c2ff3de..20e96d20d1 100644 --- a/EdkModulePkg/Universal/Disk/Partition/Dxe/Partition.mbd +++ b/EdkModulePkg/Universal/Disk/Partition/Dxe/Partition.mbd @@ -30,7 +30,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. UefiBootServicesTableLib BaseLib - UefiMemoryLib + DxeMemoryLib UefiLib UefiDriverEntryPoint UefiDriverModelLib diff --git a/EdkModulePkg/Universal/Disk/UnicodeCollation/English/Dxe/English.mbd b/EdkModulePkg/Universal/Disk/UnicodeCollation/English/Dxe/English.mbd index 4d6e50b1b9..8ea3fa159f 100644 --- a/EdkModulePkg/Universal/Disk/UnicodeCollation/English/Dxe/English.mbd +++ b/EdkModulePkg/Universal/Disk/UnicodeCollation/English/Dxe/English.mbd @@ -30,7 +30,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. UefiBootServicesTableLib BaseLib - UefiMemoryLib + DxeMemoryLib UefiDriverEntryPoint DxeReportStatusCodeLib PeiDxeDebugLibReportStatusCode diff --git a/EdkModulePkg/Universal/Ebc/Dxe/Ebc.mbd b/EdkModulePkg/Universal/Ebc/Dxe/Ebc.mbd index a8ac736d1a..6df88d81e8 100644 --- a/EdkModulePkg/Universal/Ebc/Dxe/Ebc.mbd +++ b/EdkModulePkg/Universal/Ebc/Dxe/Ebc.mbd @@ -29,7 +29,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. UefiBootServicesTableLib BaseLib - UefiMemoryLib + DxeMemoryLib UefiLib UefiDriverEntryPoint DxeReportStatusCodeLib diff --git a/EdkModulePkg/Universal/FirmwareVolume/FaultTolerantWriteLite/Dxe/FtwLite.mbd b/EdkModulePkg/Universal/FirmwareVolume/FaultTolerantWriteLite/Dxe/FtwLite.mbd index fa4818868c..5a05499c18 100644 --- a/EdkModulePkg/Universal/FirmwareVolume/FaultTolerantWriteLite/Dxe/FtwLite.mbd +++ b/EdkModulePkg/Universal/FirmwareVolume/FaultTolerantWriteLite/Dxe/FtwLite.mbd @@ -29,7 +29,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. UefiBootServicesTableLib BaseLib - UefiMemoryLib + DxeMemoryLib DxeHobLib UefiLib UefiDriverEntryPoint diff --git a/EdkModulePkg/Universal/FirmwareVolume/GuidedSectionExtraction/Crc32SectionExtract/Dxe/Crc32SectionExtract.mbd b/EdkModulePkg/Universal/FirmwareVolume/GuidedSectionExtraction/Crc32SectionExtract/Dxe/Crc32SectionExtract.mbd index ba3ea42682..35dadef861 100644 --- a/EdkModulePkg/Universal/FirmwareVolume/GuidedSectionExtraction/Crc32SectionExtract/Dxe/Crc32SectionExtract.mbd +++ b/EdkModulePkg/Universal/FirmwareVolume/GuidedSectionExtraction/Crc32SectionExtract/Dxe/Crc32SectionExtract.mbd @@ -29,7 +29,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. UefiBootServicesTableLib - UefiMemoryLib + DxeMemoryLib UefiLib UefiDriverEntryPoint DxeReportStatusCodeLib diff --git a/EdkModulePkg/Universal/GenericMemoryTest/Dxe/NullMemoryTest.mbd b/EdkModulePkg/Universal/GenericMemoryTest/Dxe/NullMemoryTest.mbd index ff035c5900..7a9b1eec2b 100644 --- a/EdkModulePkg/Universal/GenericMemoryTest/Dxe/NullMemoryTest.mbd +++ b/EdkModulePkg/Universal/GenericMemoryTest/Dxe/NullMemoryTest.mbd @@ -30,7 +30,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. UefiBootServicesTableLib BaseLib - UefiMemoryLib + DxeMemoryLib UefiLib UefiDriverEntryPoint DxeServicesTableLib diff --git a/EdkModulePkg/Universal/Network/PxeBc/Dxe/BC.mbd b/EdkModulePkg/Universal/Network/PxeBc/Dxe/BC.mbd index 94e8e7cff4..f3f8175297 100644 --- a/EdkModulePkg/Universal/Network/PxeBc/Dxe/BC.mbd +++ b/EdkModulePkg/Universal/Network/PxeBc/Dxe/BC.mbd @@ -29,7 +29,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. UefiBootServicesTableLib - UefiMemoryLib + DxeMemoryLib UefiLib UefiDriverEntryPoint UefiDriverModelLib diff --git a/EdkModulePkg/Universal/Network/PxeDhcp4/Dxe/Dhcp4.mbd b/EdkModulePkg/Universal/Network/PxeDhcp4/Dxe/Dhcp4.mbd index eda3e289f8..d9a50f4708 100644 --- a/EdkModulePkg/Universal/Network/PxeDhcp4/Dxe/Dhcp4.mbd +++ b/EdkModulePkg/Universal/Network/PxeDhcp4/Dxe/Dhcp4.mbd @@ -29,7 +29,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. UefiBootServicesTableLib - UefiMemoryLib + DxeMemoryLib UefiLib UefiDriverEntryPoint UefiDriverModelLib diff --git a/EdkModulePkg/Universal/PCD/Dxe/Pcd.mbd b/EdkModulePkg/Universal/PCD/Dxe/Pcd.mbd index 5306a8f9a2..66bd5a0312 100644 --- a/EdkModulePkg/Universal/PCD/Dxe/Pcd.mbd +++ b/EdkModulePkg/Universal/PCD/Dxe/Pcd.mbd @@ -33,7 +33,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. DxeHobLib UefiLib HiiLib - UefiMemoryLib + DxeMemoryLib UefiDriverEntryPoint DxeReportStatusCodeLib PeiDxeDebugLibReportStatusCode diff --git a/EdkModulePkg/Universal/Security/SecurityStub/Dxe/SecurityStub.mbd b/EdkModulePkg/Universal/Security/SecurityStub/Dxe/SecurityStub.mbd index facb62ce8f..98995856df 100644 --- a/EdkModulePkg/Universal/Security/SecurityStub/Dxe/SecurityStub.mbd +++ b/EdkModulePkg/Universal/Security/SecurityStub/Dxe/SecurityStub.mbd @@ -30,7 +30,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. UefiBootServicesTableLib BaseLib - UefiMemoryLib + DxeMemoryLib UefiLib UefiDriverEntryPoint DxeReportStatusCodeLib diff --git a/EdkModulePkg/Universal/UserInterface/SetupBrowser/Dxe/DriverSample/DriverSample.mbd b/EdkModulePkg/Universal/UserInterface/SetupBrowser/Dxe/DriverSample/DriverSample.mbd index 24ec052551..54bcafa49f 100644 --- a/EdkModulePkg/Universal/UserInterface/SetupBrowser/Dxe/DriverSample/DriverSample.mbd +++ b/EdkModulePkg/Universal/UserInterface/SetupBrowser/Dxe/DriverSample/DriverSample.mbd @@ -31,7 +31,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. UefiBootServicesTableLib UefiRuntimeServicesTableLib BaseLib - UefiMemoryLib + DxeMemoryLib UefiLib UefiDriverEntryPoint DxeReportStatusCodeLib diff --git a/EdkModulePkg/Universal/UserInterface/SetupBrowser/Dxe/SetupBrowser.mbd b/EdkModulePkg/Universal/UserInterface/SetupBrowser/Dxe/SetupBrowser.mbd index ba9532a661..609bcf8c83 100644 --- a/EdkModulePkg/Universal/UserInterface/SetupBrowser/Dxe/SetupBrowser.mbd +++ b/EdkModulePkg/Universal/UserInterface/SetupBrowser/Dxe/SetupBrowser.mbd @@ -33,7 +33,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. BaseLib DxeReportStatusCodeLib PeiDxeDebugLibReportStatusCode - UefiMemoryLib + DxeMemoryLib BasePrintLib UefiDriverEntryPoint DxeMemoryAllocationLib diff --git a/EdkModulePkg/Universal/WatchdogTimer/Dxe/WatchDogTimer.mbd b/EdkModulePkg/Universal/WatchdogTimer/Dxe/WatchDogTimer.mbd index 9a605c91fc..1079e2692e 100644 --- a/EdkModulePkg/Universal/WatchdogTimer/Dxe/WatchDogTimer.mbd +++ b/EdkModulePkg/Universal/WatchdogTimer/Dxe/WatchDogTimer.mbd @@ -31,7 +31,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. UefiBootServicesTableLib UefiRuntimeServicesTableLib BaseLib - UefiMemoryLib + DxeMemoryLib UefiLib UefiDriverEntryPoint DxeReportStatusCodeLib diff --git a/EdkNt32Pkg/Dxe/ConPlatform/ConPlatform.mbd b/EdkNt32Pkg/Dxe/ConPlatform/ConPlatform.mbd index 57e0a8974d..aa87078e81 100644 --- a/EdkNt32Pkg/Dxe/ConPlatform/ConPlatform.mbd +++ b/EdkNt32Pkg/Dxe/ConPlatform/ConPlatform.mbd @@ -30,7 +30,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. UefiBootServicesTableLib UefiRuntimeServicesTableLib - UefiMemoryLib + DxeMemoryLib UefiLib UefiDriverEntryPoint UefiDriverModelLib diff --git a/EdkNt32Pkg/Dxe/Nt32Platform/MiscSubclass/MiscSubclassDriver.mbd b/EdkNt32Pkg/Dxe/Nt32Platform/MiscSubclass/MiscSubclassDriver.mbd index a487dba941..0367c18338 100644 --- a/EdkNt32Pkg/Dxe/Nt32Platform/MiscSubclass/MiscSubclassDriver.mbd +++ b/EdkNt32Pkg/Dxe/Nt32Platform/MiscSubclass/MiscSubclassDriver.mbd @@ -32,7 +32,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. BaseLib UefiLib HiiLib - UefiMemoryLib + DxeMemoryLib UefiDriverEntryPoint DxeReportStatusCodeLib PeiDxeDebugLibReportStatusCode diff --git a/EdkNt32Pkg/Dxe/PlatformBds/PlatformBds.mbd b/EdkNt32Pkg/Dxe/PlatformBds/PlatformBds.mbd index 486f16882f..82ffc52bf9 100644 --- a/EdkNt32Pkg/Dxe/PlatformBds/PlatformBds.mbd +++ b/EdkNt32Pkg/Dxe/PlatformBds/PlatformBds.mbd @@ -32,7 +32,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. UefiRuntimeServicesTableLib BaseLib UefiLib - UefiMemoryLib + DxeMemoryLib UefiDriverEntryPoint DxeServicesTableLib DxeReportStatusCodeLib diff --git a/EdkNt32Pkg/Dxe/WinNtThunk/Bus/BlockIo/WinNtBlockIo.mbd b/EdkNt32Pkg/Dxe/WinNtThunk/Bus/BlockIo/WinNtBlockIo.mbd index 078350addc..5ac3148a6f 100644 --- a/EdkNt32Pkg/Dxe/WinNtThunk/Bus/BlockIo/WinNtBlockIo.mbd +++ b/EdkNt32Pkg/Dxe/WinNtThunk/Bus/BlockIo/WinNtBlockIo.mbd @@ -31,7 +31,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. UefiBootServicesTableLib BaseLib UefiLib - UefiMemoryLib + DxeMemoryLib UefiDriverEntryPoint UefiDriverModelLib UefiDebugLibStdErr diff --git a/EdkNt32Pkg/Dxe/WinNtThunk/Bus/Console/WinNtConsole.mbd b/EdkNt32Pkg/Dxe/WinNtThunk/Bus/Console/WinNtConsole.mbd index 566a7481af..945067077c 100644 --- a/EdkNt32Pkg/Dxe/WinNtThunk/Bus/Console/WinNtConsole.mbd +++ b/EdkNt32Pkg/Dxe/WinNtThunk/Bus/Console/WinNtConsole.mbd @@ -31,7 +31,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. UefiBootServicesTableLib BaseLib UefiLib - UefiMemoryLib + DxeMemoryLib UefiDriverEntryPoint UefiDriverModelLib UefiDebugLibStdErr diff --git a/EdkNt32Pkg/Dxe/WinNtThunk/Bus/SerialIo/WinNtSerialIo.mbd b/EdkNt32Pkg/Dxe/WinNtThunk/Bus/SerialIo/WinNtSerialIo.mbd index a5b19f99c4..6468fd029c 100644 --- a/EdkNt32Pkg/Dxe/WinNtThunk/Bus/SerialIo/WinNtSerialIo.mbd +++ b/EdkNt32Pkg/Dxe/WinNtThunk/Bus/SerialIo/WinNtSerialIo.mbd @@ -31,7 +31,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. UefiBootServicesTableLib BaseLib UefiLib - UefiMemoryLib + DxeMemoryLib UefiDriverEntryPoint UefiDriverModelLib UefiDebugLibStdErr diff --git a/EdkNt32Pkg/Dxe/WinNtThunk/Bus/SimpleFileSystem/WinNtSimpleFileSystem.mbd b/EdkNt32Pkg/Dxe/WinNtThunk/Bus/SimpleFileSystem/WinNtSimpleFileSystem.mbd index 3a3e7845c6..25aef78949 100644 --- a/EdkNt32Pkg/Dxe/WinNtThunk/Bus/SimpleFileSystem/WinNtSimpleFileSystem.mbd +++ b/EdkNt32Pkg/Dxe/WinNtThunk/Bus/SimpleFileSystem/WinNtSimpleFileSystem.mbd @@ -31,7 +31,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. UefiBootServicesTableLib BaseLib UefiLib - UefiMemoryLib + DxeMemoryLib UefiDriverEntryPoint UefiDriverModelLib UefiDebugLibStdErr diff --git a/EdkNt32Pkg/Dxe/WinNtThunk/Bus/Uga/WinNtUga.mbd b/EdkNt32Pkg/Dxe/WinNtThunk/Bus/Uga/WinNtUga.mbd index 18add2fe18..8981a35741 100644 --- a/EdkNt32Pkg/Dxe/WinNtThunk/Bus/Uga/WinNtUga.mbd +++ b/EdkNt32Pkg/Dxe/WinNtThunk/Bus/Uga/WinNtUga.mbd @@ -31,7 +31,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. UefiBootServicesTableLib BaseLib UefiLib - UefiMemoryLib + DxeMemoryLib UefiDriverEntryPoint UefiDriverModelLib UefiDebugLibStdErr diff --git a/EdkNt32Pkg/Dxe/WinNtThunk/Bus/WinNtBusDriver/WinNtBusDriver.mbd b/EdkNt32Pkg/Dxe/WinNtThunk/Bus/WinNtBusDriver/WinNtBusDriver.mbd index ca1a8f3542..5059326ed7 100644 --- a/EdkNt32Pkg/Dxe/WinNtThunk/Bus/WinNtBusDriver/WinNtBusDriver.mbd +++ b/EdkNt32Pkg/Dxe/WinNtThunk/Bus/WinNtBusDriver/WinNtBusDriver.mbd @@ -31,7 +31,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. UefiBootServicesTableLib BaseLib UefiLib - UefiMemoryLib + DxeMemoryLib UefiDriverEntryPoint UefiDriverModelLib DxeReportStatusCodeLib diff --git a/EdkNt32Pkg/Dxe/WinNtThunk/Chipset/Metronome/Metronome.mbd b/EdkNt32Pkg/Dxe/WinNtThunk/Chipset/Metronome/Metronome.mbd index 3ee5bf161f..1e43726ef4 100644 --- a/EdkNt32Pkg/Dxe/WinNtThunk/Chipset/Metronome/Metronome.mbd +++ b/EdkNt32Pkg/Dxe/WinNtThunk/Chipset/Metronome/Metronome.mbd @@ -32,7 +32,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. DxeHobLib BaseLib UefiLib - UefiMemoryLib + DxeMemoryLib UefiDriverEntryPoint DxeReportStatusCodeLib PeiDxeDebugLibReportStatusCode diff --git a/EdkNt32Pkg/Dxe/WinNtThunk/Chipset/RealTimeClock/RealTimeClock.mbd b/EdkNt32Pkg/Dxe/WinNtThunk/Chipset/RealTimeClock/RealTimeClock.mbd index f76db8e9af..9a824efbb3 100644 --- a/EdkNt32Pkg/Dxe/WinNtThunk/Chipset/RealTimeClock/RealTimeClock.mbd +++ b/EdkNt32Pkg/Dxe/WinNtThunk/Chipset/RealTimeClock/RealTimeClock.mbd @@ -33,7 +33,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. DxeWinNtLib BaseLib UefiLib - UefiMemoryLib + DxeMemoryLib UefiDriverEntryPoint DxeReportStatusCodeLib PeiDxeDebugLibReportStatusCode diff --git a/EdkNt32Pkg/Dxe/WinNtThunk/Chipset/Reset/Reset.mbd b/EdkNt32Pkg/Dxe/WinNtThunk/Chipset/Reset/Reset.mbd index ff6e2c9c3a..3e61fdd8dc 100644 --- a/EdkNt32Pkg/Dxe/WinNtThunk/Chipset/Reset/Reset.mbd +++ b/EdkNt32Pkg/Dxe/WinNtThunk/Chipset/Reset/Reset.mbd @@ -32,7 +32,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. DxeHobLib BaseLib UefiLib - UefiMemoryLib + DxeMemoryLib UefiDriverEntryPoint DxeReportStatusCodeLib PeiDxeDebugLibReportStatusCode diff --git a/EdkNt32Pkg/Dxe/WinNtThunk/Chipset/Timer/Timer.mbd b/EdkNt32Pkg/Dxe/WinNtThunk/Chipset/Timer/Timer.mbd index aa850fbd2c..1c03cfeab5 100644 --- a/EdkNt32Pkg/Dxe/WinNtThunk/Chipset/Timer/Timer.mbd +++ b/EdkNt32Pkg/Dxe/WinNtThunk/Chipset/Timer/Timer.mbd @@ -34,7 +34,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. BaseLib UefiLib HiiLib - UefiMemoryLib + DxeMemoryLib UefiDriverEntryPoint DxeReportStatusCodeLib DxeWinNtLib diff --git a/EdkNt32Pkg/Dxe/WinNtThunk/Cpu/Cpu.mbd b/EdkNt32Pkg/Dxe/WinNtThunk/Cpu/Cpu.mbd index 0e198b7524..7cc131daff 100644 --- a/EdkNt32Pkg/Dxe/WinNtThunk/Cpu/Cpu.mbd +++ b/EdkNt32Pkg/Dxe/WinNtThunk/Cpu/Cpu.mbd @@ -32,7 +32,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. BaseLib UefiLib HiiLib - UefiMemoryLib + DxeMemoryLib UefiDriverEntryPoint DxeReportStatusCodeLib PeiDxeDebugLibReportStatusCode diff --git a/EdkNt32Pkg/Dxe/WinNtThunk/WinNtThunk/WinNtThunk.mbd b/EdkNt32Pkg/Dxe/WinNtThunk/WinNtThunk/WinNtThunk.mbd index b58acbb65b..43add04dbc 100644 --- a/EdkNt32Pkg/Dxe/WinNtThunk/WinNtThunk/WinNtThunk.mbd +++ b/EdkNt32Pkg/Dxe/WinNtThunk/WinNtThunk/WinNtThunk.mbd @@ -32,7 +32,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. BaseLib DxeHobLib UefiLib - UefiMemoryLib + DxeMemoryLib UefiDriverEntryPoint DxeReportStatusCodeLib PeiDxeDebugLibReportStatusCode diff --git a/EdkNt32Pkg/Nt32.fpd b/EdkNt32Pkg/Nt32.fpd index 82cbafa255..7dea2ca884 100644 --- a/EdkNt32Pkg/Nt32.fpd +++ b/EdkNt32Pkg/Nt32.fpd @@ -6315,6 +6315,7 @@ + diff --git a/MdePkg/Include/Library/BaseMemoryLib.h b/MdePkg/Include/Library/BaseMemoryLib.h index 38f6c489d5..af3e1ecfaf 100644 --- a/MdePkg/Include/Library/BaseMemoryLib.h +++ b/MdePkg/Include/Library/BaseMemoryLib.h @@ -48,7 +48,7 @@ CopyMem ( If Length is greater than (MAX_ADDRESS – Buffer + 1), then ASSERT(). @param Buffer Memory to set. - @param Length Number of bytes to set + @param Length Number of bytes to set. @param Value Value of the set operation. @return Buffer. @@ -175,7 +175,6 @@ ZeroMem ( If Length is greater than (MAX_ADDRESS - DestinationBuffer + 1), then ASSERT(). If Length is greater than (MAX_ADDRESS - SourceBuffer + 1), then ASSERT(). - @param DestinationBuffer Pointer to the destination buffer to compare. @param SourceBuffer Pointer to the source buffer to compare. @param Length Number of bytes to compare. @@ -229,6 +228,7 @@ ScanMem8 ( then NULL is returned. If Length is 0, then NULL is returned. If Length > 0 and Buffer is NULL, then ASSERT(). If Buffer is not aligned on a 16-bit boundary, then ASSERT(). + If Length is not aligned on a 16-bit boundary, then ASSERT(). If Length is greater than (MAX_ADDRESS – Buffer + 1), then ASSERT(). @param Buffer Pointer to the target buffer to scan. @@ -256,6 +256,7 @@ ScanMem16 ( then NULL is returned. If Length is 0, then NULL is returned. If Length > 0 and Buffer is NULL, then ASSERT(). If Buffer is not aligned on a 32-bit boundary, then ASSERT(). + If Length is not aligned on a 32-bit boundary, then ASSERT(). If Length is greater than (MAX_ADDRESS – Buffer + 1), then ASSERT(). @param Buffer Pointer to the target buffer to scan. @@ -283,6 +284,7 @@ ScanMem32 ( then NULL is returned. If Length is 0, then NULL is returned. If Length > 0 and Buffer is NULL, then ASSERT(). If Buffer is not aligned on a 64-bit boundary, then ASSERT(). + If Length is not aligned on a 64-bit boundary, then ASSERT(). If Length is greater than (MAX_ADDRESS – Buffer + 1), then ASSERT(). @param Buffer Pointer to the target buffer to scan. @@ -353,7 +355,8 @@ CompareGuid ( GUID in the target buffer is returned. If no match is found, then NULL is returned. If Length is 0, then NULL is returned. If Length > 0 and Buffer is NULL, then ASSERT(). - If Buffer is not aligned on a 64-bit boundary, then ASSERT(). + If Buffer is not aligned on a 32-bit boundary, then ASSERT(). + If Length is not aligned on a 128-bit boundary, then ASSERT(). If Length is greater than (MAX_ADDRESS – Buffer + 1), then ASSERT(). @param Buffer Pointer to the target buffer to scan. diff --git a/MdePkg/Include/Library/DevicePathLib.h b/MdePkg/Include/Library/DevicePathLib.h index 299d607118..aee5426ca2 100644 --- a/MdePkg/Include/Library/DevicePathLib.h +++ b/MdePkg/Include/Library/DevicePathLib.h @@ -18,11 +18,12 @@ #define __DEVICE_PATH_LIB_H__ /** - This function returns the size, in bytes, - of the device path data structure specified by DevicePath. - If DevicePath is NULL, then 0 is returned. + Returns the size of a device path in bytes. - @param DevicePath A pointer to a device path data structure. + This function returns the size, in bytes, of the device path data structure specified by + DevicePath including the end of device path node. If DevicePath is NULL, then 0 is returned. + + @param DevicePath A pointer to a device path data structure. @return The size of a device path in bytes. @@ -31,166 +32,220 @@ UINTN EFIAPI GetDevicePathSize ( IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath - ) -; + ); /** - This function allocates space for a new copy of the device path - specified by DevicePath. + Creates a new device path by appending a second device path to a first device path. - @param DevicePath A pointer to a device path data structure. + This function allocates space for a new copy of the device path specified by DevicePath. If + DevicePath is NULL, then NULL is returned. If the memory is successfully allocated, then the + contents of DevicePath are copied to the newly allocated buffer, and a pointer to that buffer + is returned. Otherwise, NULL is returned. + + @param DevicePath A pointer to a device path data structure. - @return The duplicated device path. + @return A pointer to the duplicated device path. **/ EFI_DEVICE_PATH_PROTOCOL * EFIAPI DuplicateDevicePath ( - IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath - ) -; + IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath + ); /** - This function appends the device path SecondDevicePath - to every device path instance in FirstDevicePath. + Creates a new device path by appending a second device path to a first device path. - @param FirstDevicePath A pointer to a device path data structure. - - @param SecondDevicePath A pointer to a device path data structure. + This function creates a new device path by appending a copy of SecondDevicePath to a copy of + FirstDevicePath in a newly allocated buffer. Only the end-of-device-path device node from + SecondDevicePath is retained. The newly created device path is returned. + If FirstDevicePath is NULL, then it is ignored, and a duplicate of SecondDevicePath is returned. + If SecondDevicePath is NULL, then it is ignored, and a duplicate of FirstDevicePath is returned. + If both FirstDevicePath and SecondDevicePath are NULL, then NULL is returned. + If there is not enough memory for the newly allocated buffer, then NULL is returned. + The memory for the new device path is allocated from EFI boot services memory. It is the + responsibility of the caller to free the memory allocated. + + @param FirstDevicePath A pointer to a device path data structure. + @param SecondDevicePath A pointer to a device path data structure. - @return - A pointer to the new device path is returned. - NULL is returned if space for the new device path could not be allocated from pool. - It is up to the caller to free the memory used by FirstDevicePath and SecondDevicePath - if they are no longer needed. + @return A pointer to the new device path. **/ EFI_DEVICE_PATH_PROTOCOL * EFIAPI AppendDevicePath ( - IN CONST EFI_DEVICE_PATH_PROTOCOL *FirstDevicePath, - IN CONST EFI_DEVICE_PATH_PROTOCOL *SecondDevicePath - ) -; + IN CONST EFI_DEVICE_PATH_PROTOCOL *FirstDevicePath, OPTIONAL + IN CONST EFI_DEVICE_PATH_PROTOCOL *SecondDevicePath OPTIONAL + ); /** - This function appends the device path node SecondDevicePath - to every device path instance in FirstDevicePath. + Creates a new path by appending the device node to the device path. - @param DevicePath A pointer to a device path data structure. - - @param DevicePathNode A pointer to a single device path node. + This function creates a new device path by appending a copy of the device node specified by + DevicePathNode to a copy of the device path specified by DevicePath in an allocated buffer. + The end-of-device-path device node is moved after the end of the appended device node. + If DevicePath is NULL, then NULL is returned. + If DevicePathNode is NULL, then NULL is returned. + If there is not enough memory to allocate space for the new device path, then NULL is returned. + The memory is allocated from EFI boot services memory. It is the responsibility of the caller to + free the memory allocated. + + @param DevicePath A pointer to a device path data structure. + @param DevicePathNode A pointer to a single device path node. @return A pointer to the new device path. - If there is not enough temporary pool memory available to complete this function, - then NULL is returned. **/ EFI_DEVICE_PATH_PROTOCOL * EFIAPI AppendDevicePathNode ( - IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath, - IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePathNode - ) -; + IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath, OPTIONAL + IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePathNode OPTIONAL + ); /** - This function appends the device path instance Instance to the device path Source. - If Source is NULL, then a new device path with one instance is created. - - @param Source A pointer to a device path data structure. - @param Instance A pointer to a device path instance. + Creates a new device path by appending the specified device path instance to the specified device + path. + + This function creates a new device path by appending a copy of the device path instance specified + by DevicePathInstance to a copy of the device path secified by DevicePath in a allocated buffer. + The end-of-device-path device node is moved after the end of the appended device path instance + and a new end-of-device-path-instance node is inserted between. + If DevicePath is NULL, then a copy if DevicePathInstance is returned. + If DevicePathInstance is NULL, then NULL is returned. + If there is not enough memory to allocate space for the new device path, then NULL is returned. + The memory is allocated from EFI boot services memory. It is the responsibility of the caller to + free the memory allocated. + + @param DevicePath A pointer to a device path data structure. + @param DevicePathInstance A pointer to a device path instance. - @return - A pointer to the new device path. - If there is not enough temporary pool memory available to complete this function, - then NULL is returned. + @return A pointer to the new device path. **/ EFI_DEVICE_PATH_PROTOCOL * EFIAPI AppendDevicePathInstance ( - IN CONST EFI_DEVICE_PATH_PROTOCOL *Source, - IN CONST EFI_DEVICE_PATH_PROTOCOL *Instance - ) -; + IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath, OPTIONAL + IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePathInstance OPTIONAL + ); /** - Function retrieves the next device path instance from a device path data structure. + Creates a copy of the current device path instance and returns a pointer to the next device path + instance. + + This function creates a copy of the current device path instance. It also updates DevicePath to + point to the next device path instance in the device path (or NULL if no more) and updates Size + to hold the size of the device path instance copy. + If DevicePath is NULL, then NULL is returned. + If there is not enough memory to allocate space for the new device path, then NULL is returned. + The memory is allocated from EFI boot services memory. It is the responsibility of the caller to + free the memory allocated. + If Size is NULL, then ASSERT(). + + @param DevicePath On input, this holds the pointer to the current device path + instance. On output, this holds the pointer to the next device + path instance or NULL if there are no more device path + instances in the device path pointer to a device path data + structure. + @param Size On output, this holds the size of the device path instance, in + bytes or zero, if DevicePath is NULL. + + @return A pointer to the current device path instance. - @param DevicePath A pointer to a device path data structure. - - @param Size A pointer to the size of a device path instance in bytes. +**/ +EFI_DEVICE_PATH_PROTOCOL * +EFIAPI +GetNextDevicePathInstance ( + IN OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath, + OUT UINTN *Size + ); + +/** + Creates a copy of the current device path instance and returns a pointer to the next device path + instance. - @return - This function returns a pointer to the current device path instance. - In addition, it returns the size in bytes of the current device path instance in Size, - and a pointer to the next device path instance in DevicePath. - If there are no more device path instances in DevicePath, then DevicePath will be set to NULL. + This function creates a new device node in a newly allocated buffer of size NodeLength and + initializes the device path node header with NodeType and NodeSubType. The new device path node + is returned. + If NodeLength is smaller than a device path header, then NULL is returned. + If there is not enough memory to allocate space for the new device path, then NULL is returned. + The memory is allocated from EFI boot services memory. It is the responsibility of the caller to + free the memory allocated. + + @param NodeType The device node type for the new device node. + @param NodeSubType The device node sub-type for the new device node. + @param NodeLength The length of the new device node. + + @return The new device path. **/ EFI_DEVICE_PATH_PROTOCOL * EFIAPI -GetNextDevicePathInstance ( - IN OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath, - OUT UINTN *Size - ) -; +CreateDeviceNode ( + IN UINT8 NodeType, + IN UINT8 NodeSubType, + IN UINT16 NodeLength + ); /** - Return TRUE is this is a multi instance device path. + Determines if a device path is single or multi-instance. - @param DevicePath A pointer to a device path data structure. + This function returns TRUE if the device path specified by DevicePath is multi-instance. + Otherwise, FALSE is returned. If DevicePath is NULL, then FALSE is returned. - @retval TRUE If DevicePath is multi-instance. - @retval FALSE If DevicePath is not multi-instance or DevicePath is NULL. + @param DevicePath A pointer to a device path data structure. + + @retval TRUE DevicePath is multi-instance. + @retval FALSE DevicePath is not multi-instance or DevicePath is NULL. **/ BOOLEAN EFIAPI IsDevicePathMultiInstance ( IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath - ) -; + ); /** - This function retrieves the device path protocol from a handle. + Retrieves the device path protocol from a handle. - @param Handle The handle from which to retrieve the device path protocol. + This function returns the device path protocol from the handle specified by Handle. If Handle is + NULL or Handle does not contain a device path protocol, then NULL is returned. + + @param Handle The handle from which to retrieve the device path protocol. - @return - This function returns the device path protocol from the handle specified by Handle. - If Handle is NULL or Handle does not contain a device path protocol, then NULL is returned. + @return The device path protocol from the handle specified by Handle. **/ EFI_DEVICE_PATH_PROTOCOL * EFIAPI DevicePathFromHandle ( - IN EFI_HANDLE Handle - ) -; + IN EFI_HANDLE Handle + ); /** - This function allocates a device path for a file and appends it to an existing device path. + Allocates a device path for a file and appends it to an existing device path. + + If Device is a valid device handle that contains a device path protocol, then a device path for + the file specified by FileName is allocated and appended to the device path associated with the + handle Device. The allocated device path is returned. If Device is NULL or Device is a handle + that does not support the device path protocol, then a device path containing a single device + path node for the file specified by FileName is allocated and returned. + If FileName is NULL, then ASSERT(). - @param Device A pointer to a device handle. This parameter is optional and may be NULL. - @param FileName A pointer to a Null-terminated Unicode string. + @param Device A pointer to a device handle. This parameter is optional and + may be NULL. + @param FileName A pointer to a Null-terminated Unicode string. - @return - If Device is a valid device handle that contains a device path protocol, - then a device path for the file specified by FileName is allocated - and appended to the device path associated with the handle Device. The allocated device path is returned. - If Device is NULL or Device is a handle that does not support the device path protocol, - then a device path containing a single device path node for the file specified by FileName - is allocated and returned. + @return The allocated device path. **/ EFI_DEVICE_PATH_PROTOCOL * EFIAPI FileDevicePath ( - IN EFI_HANDLE Device, OPTIONAL - IN CONST CHAR16 *FileName - ) -; + IN EFI_HANDLE Device, OPTIONAL + IN CONST CHAR16 *FileName + ); #endif diff --git a/MdePkg/Include/Library/PciCf8Lib.h b/MdePkg/Include/Library/PciCf8Lib.h index e2ac1b2a01..e2808418fa 100644 --- a/MdePkg/Include/Library/PciCf8Lib.h +++ b/MdePkg/Include/Library/PciCf8Lib.h @@ -996,8 +996,7 @@ PciCf8BitFieldAndThenOr32 ( If StartAddress > 0x0FFFFFFF, then ASSERT(). If the register specified by StartAddress >= 0x100, then ASSERT(). If ((StartAddress & 0xFFF) + Size) > 0x100, then ASSERT(). - If (StartAddress + Size - 1) > 0x0FFFFFFF, then ASSERT(). - If Buffer is NULL, then ASSERT(). + If Size > 0 and Buffer is NULL, then ASSERT(). @param StartAddress Starting address that encodes the PCI Bus, Device, Function and Register. @@ -1030,8 +1029,7 @@ PciCf8ReadBuffer ( If StartAddress > 0x0FFFFFFF, then ASSERT(). If the register specified by StartAddress >= 0x100, then ASSERT(). If ((StartAddress & 0xFFF) + Size) > 0x100, then ASSERT(). - If (StartAddress + Size - 1) > 0x0FFFFFFF, then ASSERT(). - If Buffer is NULL, then ASSERT(). + If Size > 0 and Buffer is NULL, then ASSERT(). @param StartAddress Starting address that encodes the PCI Bus, Device, Function and Register. diff --git a/MdePkg/Include/Library/PciExpressLib.h b/MdePkg/Include/Library/PciExpressLib.h index c21a2795c1..9bd1166a87 100644 --- a/MdePkg/Include/Library/PciExpressLib.h +++ b/MdePkg/Include/Library/PciExpressLib.h @@ -965,8 +965,7 @@ PciExpressBitFieldAndThenOr32 ( If StartAddress > 0x0FFFFFFF, then ASSERT(). If ((StartAddress & 0xFFF) + Size) > 0x1000, then ASSERT(). - If (StartAddress + Size - 1) > 0x0FFFFFFF, then ASSERT(). - If Buffer is NULL, then ASSERT(). + If Size > 0 and Buffer is NULL, then ASSERT(). @param StartAddress Starting address that encodes the PCI Bus, Device, Function and Register. @@ -998,8 +997,7 @@ PciExpressReadBuffer ( If StartAddress > 0x0FFFFFFF, then ASSERT(). If ((StartAddress & 0xFFF) + Size) > 0x1000, then ASSERT(). - If (StartAddress + Size - 1) > 0x0FFFFFFF, then ASSERT(). - If Buffer is NULL, then ASSERT(). + If Size > 0 and Buffer is NULL, then ASSERT(). @param StartAddress Starting address that encodes the PCI Bus, Device, Function and Register. diff --git a/MdePkg/Include/Library/PciLib.h b/MdePkg/Include/Library/PciLib.h index 4d21cb7708..6acf13c7be 100644 --- a/MdePkg/Include/Library/PciLib.h +++ b/MdePkg/Include/Library/PciLib.h @@ -960,8 +960,7 @@ PciBitFieldAndThenOr32 ( If StartAddress > 0x0FFFFFFF, then ASSERT(). If ((StartAddress & 0xFFF) + Size) > 0x1000, then ASSERT(). - If (StartAddress + Size - 1) > 0x0FFFFFFF, then ASSERT(). - If Buffer is NULL, then ASSERT(). + If Size > 0 and Buffer is NULL, then ASSERT(). @param StartAddress Starting address that encodes the PCI Bus, Device, Function and Register. @@ -993,8 +992,7 @@ PciReadBuffer ( If StartAddress > 0x0FFFFFFF, then ASSERT(). If ((StartAddress & 0xFFF) + Size) > 0x1000, then ASSERT(). - If (StartAddress + Size - 1) > 0x0FFFFFFF, then ASSERT(). - If Buffer is NULL, then ASSERT(). + If Size > 0 and Buffer is NULL, then ASSERT(). @param StartAddress Starting address that encodes the PCI Bus, Device, Function and Register. diff --git a/MdePkg/Include/Library/PeiServicesLib.h b/MdePkg/Include/Library/PeiServicesLib.h index 10eebb5bf0..53d1cdba42 100644 --- a/MdePkg/Include/Library/PeiServicesLib.h +++ b/MdePkg/Include/Library/PeiServicesLib.h @@ -1,5 +1,5 @@ /** @file - PEI Core Library implementation + Header file for PEI Services Library. Copyright (c) 2006, Intel Corporation All rights reserved. This program and the accompanying materials @@ -20,287 +20,279 @@ /** This service enables a given PEIM to register an interface into the PEI Foundation. - @param PpiList A pointer to the list of interfaces that the caller shall install. + @param PpiList A pointer to the list of interfaces that the caller shall install. - @retval EFI_SUCCESS The interface was successfully installed. - @retval EFI_INVALID_PARAMETER The PpiList pointer is NULL. - @retval EFI_INVALID_PARAMETER Any of the PEI PPI descriptors in the list do not have - the EFI_PEI_PPI_DESCRIPTOR_PPI bit set in the Flags field. - @retval EFI_OUT_OF_RESOURCES There is no additional space in the PPI database. + @retval EFI_SUCCESS The interface was successfully installed. + @retval EFI_INVALID_PARAMETER The PpiList pointer is NULL. + @retval EFI_INVALID_PARAMETER Any of the PEI PPI descriptors in the list do not have the + EFI_PEI_PPI_DESCRIPTOR_PPI bit set in the Flags field. + @retval EFI_OUT_OF_RESOURCES There is no additional space in the PPI database. **/ EFI_STATUS EFIAPI PeiServicesInstallPpi ( - IN EFI_PEI_PPI_DESCRIPTOR *PpiList - ) -; + IN EFI_PEI_PPI_DESCRIPTOR *PpiList + ); /** This service enables PEIMs to replace an entry in the PPI database with an alternate entry. - @param OldPpi Pointer to the old PEI PPI Descriptors. - @param NewPpi Pointer to the new PEI PPI Descriptors. + @param OldPpi Pointer to the old PEI PPI Descriptors. + @param NewPpi Pointer to the new PEI PPI Descriptors. - @retval EFI_SUCCESS The interface was successfully installed. - @retval EFI_INVALID_PARAMETER The OldPpi or NewPpi is NULL. - @retval EFI_INVALID_PARAMETER Any of the PEI PPI descriptors in the list do not have - the EFI_PEI_PPI_DESCRIPTOR_PPI bit set in the Flags field. - @retval EFI_OUT_OF_RESOURCES There is no additional space in the PPI database. - @retval EFI_NOT_FOUND The PPI for which the reinstallation was requested has not been installed. + @retval EFI_SUCCESS The interface was successfully installed. + @retval EFI_INVALID_PARAMETER The OldPpi or NewPpi is NULL. + @retval EFI_INVALID_PARAMETER Any of the PEI PPI descriptors in the list do not have the + EFI_PEI_PPI_DESCRIPTOR_PPI bit set in the Flags field. + @retval EFI_OUT_OF_RESOURCES There is no additional space in the PPI database. + @retval EFI_NOT_FOUND The PPI for which the reinstallation was requested has not been + installed. **/ EFI_STATUS EFIAPI PeiServicesReInstallPpi ( - IN EFI_PEI_PPI_DESCRIPTOR *OldPpi, - IN EFI_PEI_PPI_DESCRIPTOR *NewPpi - ) -; + IN EFI_PEI_PPI_DESCRIPTOR *OldPpi, + IN EFI_PEI_PPI_DESCRIPTOR *NewPpi + ); /** This service enables PEIMs to discover a given instance of an interface. - @param Guid A pointer to the GUID whose corresponding interface needs to be found. - @param Instance The N-th instance of the interface that is required. - @param PpiDescriptor A pointer to instance of the EFI_PEI_PPI_DESCRIPTOR. - @param Ppi A pointer to the instance of the interface. + @param Guid A pointer to the GUID whose corresponding interface needs to be + found. + @param Instance The N-th instance of the interface that is required. + @param PpiDescriptor A pointer to instance of the EFI_PEI_PPI_DESCRIPTOR. + @param Ppi A pointer to the instance of the interface. - @retval EFI_SUCCESS The interface was successfully returned. - @retval EFI_NOT_FOUND The PPI descriptor is not found in the database. + @retval EFI_SUCCESS The interface was successfully returned. + @retval EFI_NOT_FOUND The PPI descriptor is not found in the database. **/ EFI_STATUS EFIAPI PeiServicesLocatePpi ( - IN EFI_GUID *Guid, - IN UINTN Instance, - IN OUT EFI_PEI_PPI_DESCRIPTOR **PpiDescriptor, - IN OUT VOID **Ppi - ) -; + IN EFI_GUID *Guid, + IN UINTN Instance, + IN OUT EFI_PEI_PPI_DESCRIPTOR **PpiDescriptor, + IN OUT VOID **Ppi + ); /** - This service enables PEIMs to register a given service to be invoked - when another service is installed or reinstalled. + This service enables PEIMs to register a given service to be invoked when another service is + installed or reinstalled. - @param NotifyList A pointer to the list of notification interfaces that the caller shall install. + @param NotifyList A pointer to the list of notification interfaces that the caller + shall install. - @retval EFI_SUCCESS The interface was successfully installed. - @retval EFI_INVALID_PARAMETER The NotifyList pointer is NULL. - @retval EFI_INVALID_PARAMETER Any of the PEI notify descriptors in the list do not have - the EFI_PEI_PPI_DESCRIPTOR_NOTIFY_TYPES bit set in the Flags field. - @retval EFI_OUT_OF_RESOURCES There is no additional space in the PPI database. + @retval EFI_SUCCESS The interface was successfully installed. + @retval EFI_INVALID_PARAMETER The NotifyList pointer is NULL. + @retval EFI_INVALID_PARAMETER Any of the PEI notify descriptors in the list do not have the + EFI_PEI_PPI_DESCRIPTOR_NOTIFY_TYPES bit set in the Flags field. + @retval EFI_OUT_OF_RESOURCES There is no additional space in the PPI database. **/ EFI_STATUS EFIAPI PeiServicesNotifyPpi ( - IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyList - ) -; + IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyList + ); /** This service enables PEIMs to ascertain the present value of the boot mode. - @param BootMode A pointer to contain the value of the boot mode. + @param BootMode A pointer to contain the value of the boot mode. - @retval EFI_SUCCESS The boot mode was returned successfully. - @retval EFI_INVALID_PARAMETER BootMode is NULL. + @retval EFI_SUCCESS The boot mode was returned successfully. + @retval EFI_INVALID_PARAMETER BootMode is NULL. **/ EFI_STATUS EFIAPI PeiServicesGetBootMode ( - IN OUT EFI_BOOT_MODE *BootMode - ) -; + IN OUT EFI_BOOT_MODE *BootMode + ); /** This service enables PEIMs to update the boot mode variable. - @param BootMode The value of the boot mode to set. + @param BootMode The value of the boot mode to set. - @retval EFI_SUCCESS The value was successfully updated + @retval EFI_SUCCESS The value was successfully updated **/ EFI_STATUS EFIAPI PeiServicesSetBootMode ( - IN EFI_BOOT_MODE BootMode - ) -; + IN EFI_BOOT_MODE BootMode + ); /** This service enables a PEIM to ascertain the address of the list of HOBs in memory. - @param HobList A pointer to the list of HOBs that the PEI Foundation will initialize. + @param HobList A pointer to the list of HOBs that the PEI Foundation will initialize. - @retval EFI_SUCCESS The list was successfully returned. - @retval EFI_NOT_AVAILABLE_YET The HOB list is not yet published. + @retval EFI_SUCCESS The list was successfully returned. + @retval EFI_NOT_AVAILABLE_YET The HOB list is not yet published. **/ EFI_STATUS EFIAPI PeiServicesGetHobList ( - IN OUT VOID **HobList - ) -; + IN OUT VOID **HobList + ); /** This service enables PEIMs to create various types of HOBs. - @param Type The type of HOB to be installed. - @param Length The length of the HOB to be added. - @param Hob The address of a pointer that will contain the HOB header. + @param Type The type of HOB to be installed. + @param Length The length of the HOB to be added. + @param Hob The address of a pointer that will contain the HOB header. - @retval EFI_SUCCESS The HOB was successfully created. - @retval EFI_OUT_OF_RESOURCES There is no additional space for HOB creation. + @retval EFI_SUCCESS The HOB was successfully created. + @retval EFI_OUT_OF_RESOURCES There is no additional space for HOB creation. **/ EFI_STATUS EFIAPI PeiServicesCreateHob ( - IN UINT16 Type, - IN UINT16 Length, - IN OUT VOID **Hob - ) -; + IN UINT16 Type, + IN UINT16 Length, + IN OUT VOID **Hob + ); /** This service enables PEIMs to discover additional firmware volumes. - @param Instance This instance of the firmware volume to find. - The value 0 is the Boot Firmware Volume (BFV). - @param FwVolHeader Pointer to the firmware volume header of the volume to return. + @param Instance This instance of the firmware volume to find. The value 0 is the + Boot Firmware Volume (BFV). + @param FwVolHeader Pointer to the firmware volume header of the volume to return. - @retval EFI_SUCCESS The volume was found. - @retval EFI_NOT_FOUND The volume was not found. - @retval EFI_INVALID_PARAMETER FwVolHeader is NULL. + @retval EFI_SUCCESS The volume was found. + @retval EFI_NOT_FOUND The volume was not found. + @retval EFI_INVALID_PARAMETER FwVolHeader is NULL. **/ EFI_STATUS EFIAPI PeiServicesFfsFindNextVolume ( - IN UINTN Instance, - IN OUT EFI_FIRMWARE_VOLUME_HEADER **FwVolHeader - ) -; + IN UINTN Instance, + IN OUT EFI_FIRMWARE_VOLUME_HEADER **FwVolHeader + ); /** This service enables PEIMs to discover additional firmware files. - @param SearchType A filter to find files only of this type. - @param FwVolHeader Pointer to the firmware volume header of the volume to search. - This parameter must point to a valid FFS volume. - @param FileHeader Pointer to the current file from which to begin searching. + @param SearchType A filter to find files only of this type. + @param FwVolHeader Pointer to the firmware volume header of the volume to search. + This parameter must point to a valid FFS volume. + @param FileHeader Pointer to the current file from which to begin searching. - @retval EFI_SUCCESS The file was found. - @retval EFI_NOT_FOUND The file was not found. - @retval EFI_NOT_FOUND The header checksum was not zero. + @retval EFI_SUCCESS The file was found. + @retval EFI_NOT_FOUND The file was not found. + @retval EFI_NOT_FOUND The header checksum was not zero. **/ EFI_STATUS EFIAPI PeiServicesFfsFindNextFile ( - IN EFI_FV_FILETYPE SearchType, - IN EFI_FIRMWARE_VOLUME_HEADER *FwVolHeader, - IN OUT EFI_FFS_FILE_HEADER **FileHeader - ) -; + IN EFI_FV_FILETYPE SearchType, + IN EFI_FIRMWARE_VOLUME_HEADER *FwVolHeader, + IN OUT EFI_FFS_FILE_HEADER **FileHeader + ); /** This service enables PEIMs to discover sections of a given type within a valid FFS file. - @param SearchType The value of the section type to find. - @param FfsFileHeader A pointer to the file header that contains the set of sections to be searched. - @param SectionData A pointer to the discovered section, if successful. + @param SearchType The value of the section type to find. + @param FfsFileHeader A pointer to the file header that contains the set of sections to + be searched. + @param SectionData A pointer to the discovered section, if successful. - @retval EFI_SUCCESS The section was found. - @retval EFI_NOT_FOUND The section was not found. + @retval EFI_SUCCESS The section was found. + @retval EFI_NOT_FOUND The section was not found. **/ EFI_STATUS EFIAPI PeiServicesFfsFindSectionData ( - IN EFI_SECTION_TYPE SectionType, - IN EFI_FFS_FILE_HEADER *FfsFileHeader, - IN OUT VOID **SectionData - ) -; + IN EFI_SECTION_TYPE SectionType, + IN EFI_FFS_FILE_HEADER *FfsFileHeader, + IN OUT VOID **SectionData + ); /** This service enables PEIMs to register the permanent memory configuration that has been initialized with the PEI Foundation. - @param MemoryBegin The value of a region of installed memory. - @param MemoryLength The corresponding length of a region of installed memory. + @param MemoryBegin The value of a region of installed memory. + @param MemoryLength The corresponding length of a region of installed memory. - @retval EFI_SUCCESS The region was successfully installed in a HOB. - @retval EFI_INVALID_PARAMETER MemoryBegin and MemoryLength are illegal for this system. - @retval EFI_OUT_OF_RESOURCES There is no additional space for HOB creation. + @retval EFI_SUCCESS The region was successfully installed in a HOB. + @retval EFI_INVALID_PARAMETER MemoryBegin and MemoryLength are illegal for this system. + @retval EFI_OUT_OF_RESOURCES There is no additional space for HOB creation. **/ EFI_STATUS EFIAPI PeiServicesInstallPeiMemory ( - IN EFI_PHYSICAL_ADDRESS MemoryBegin, - IN UINT64 MemoryLength - ) -; + IN EFI_PHYSICAL_ADDRESS MemoryBegin, + IN UINT64 MemoryLength + ); /** - This service enables PEIMs to allocate memory after the permanent memory has been installed by a PEIM. + This service enables PEIMs to allocate memory after the permanent memory has been installed by a + PEIM. - @param MemoryType Type of memory to allocate. - @param Pages Number of pages to allocate. - @param Memory Pointer of memory allocated. + @param MemoryType Type of memory to allocate. + @param Pages Number of pages to allocate. + @param Memory Pointer of memory allocated. - @retval EFI_SUCCESS The memory range was successfully allocated. - @retval EFI_INVALID_PARAMETER Type is not equal to AllocateAnyPages. - @retval EFI_NOT_AVAILABLE_YET Called with permanent memory not available. - @retval EFI_OUT_OF_RESOURCES The pages could not be allocated. + @retval EFI_SUCCESS The memory range was successfully allocated. + @retval EFI_INVALID_PARAMETER Type is not equal to AllocateAnyPages. + @retval EFI_NOT_AVAILABLE_YET Called with permanent memory not available. + @retval EFI_OUT_OF_RESOURCES The pages could not be allocated. **/ EFI_STATUS EFIAPI PeiServicesAllocatePages ( - IN EFI_MEMORY_TYPE MemoryType, - IN UINTN Pages, - IN OUT EFI_PHYSICAL_ADDRESS *Memory - ) -; + IN EFI_MEMORY_TYPE MemoryType, + IN UINTN Pages, + IN OUT EFI_PHYSICAL_ADDRESS *Memory + ); /** This service allocates memory from the Hand-Off Block (HOB) heap. - @param Size The number of bytes to allocate from the pool. - @param Buffer If the call succeeds, a pointer to a pointer to the allocated buffer; - undefined otherwise. + @param Size The number of bytes to allocate from the pool. + @param Buffer If the call succeeds, a pointer to a pointer to the allocate + buffer; undefined otherwise. - @retval EFI_SUCCESS The allocation was successful - @retval EFI_OUT_OF_RESOURCES There is not enough heap to allocate the requested size. + @retval EFI_SUCCESS The allocation was successful + @retval EFI_OUT_OF_RESOURCES There is not enough heap to allocate the requested size. **/ EFI_STATUS EFIAPI PeiServicesAllocatePool ( - IN UINTN Size, - OUT VOID **Buffer - ) -; + IN UINTN Size, + OUT VOID **Buffer + ); /** - This service resets the entire platform, including all processors and devices, and reboots the system. + This service resets the entire platform, including all processors and devices, and reboots the + system. - @retval EFI_NOT_AVAILABLE_YET The service has not been installed yet. + @retval EFI_NOT_AVAILABLE_YET The service has not been installed yet. **/ EFI_STATUS EFIAPI PeiServicesResetSystem ( VOID - ) -; + ); + #endif diff --git a/MdePkg/Include/Library/PrintLib.h b/MdePkg/Include/Library/PrintLib.h index bdab062638..e1b3cb37bb 100644 --- a/MdePkg/Include/Library/PrintLib.h +++ b/MdePkg/Include/Library/PrintLib.h @@ -50,23 +50,27 @@ The Unicode string is produced by parsing the format string specified by FormatString. Arguments are pulled from the variable argument list specified by Marker based on the contents of the format string. - The length of the produced output buffer is returned. - If BufferSize is 0, then no output buffer is produced and 0 is returned. + The number of Unicode characters in the produced output buffer is returned not including + the Null-terminator. + If BufferSize is 0 or 1, then no output buffer is produced and 0 is returned. - If BufferSize is not 0 and StartOfBuffer is NULL, then ASSERT(). - If BufferSize is not 0 and FormatString is NULL, then ASSERT(). + If BufferSize > 1 and StartOfBuffer is NULL, then ASSERT(). + If BufferSize > 1 and FormatString is NULL, then ASSERT(). If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than - PcdMaximumUnicodeStringLength Unicode characters, then ASSERT(). + PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator, then + ASSERT(). If PcdMaximumUnicodeStringLength is not zero, and produced Null-terminated Unicode string - contains more than PcdMaximumUnicodeStringLength Unicode characters, then ASSERT(). + contains more than PcdMaximumUnicodeStringLength Unicode characters not including the + Null-terminator, then ASSERT(). - @param StartOfBuffer APointer to the output buffer for the produced Null-terminated + @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated Unicode string. @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer. @param FormatString Null-terminated Unicode format string. @param Marker VA_LIST marker for the variable argument list. - @return return Length of the produced output buffer. + @return The number of Unicode characters in the produced output buffer not including the + Null-terminator. **/ UINTN @@ -86,22 +90,26 @@ UnicodeVSPrint ( and BufferSize. The Unicode string is produced by parsing the format string specified by FormatString. Arguments are pulled from the variable argument list based on the contents of the format string. - The length of the produced output buffer is returned. - If BufferSize is 0, then no output buffer is produced and 0 is returned. + The number of Unicode characters in the produced output buffer is returned not including + the Null-terminator. + If BufferSize is 0 or 1, then no output buffer is produced and 0 is returned. - If BufferSize is not 0 and StartOfBuffer is NULL, then ASSERT(). - If BufferSize is not 0 and FormatString is NULL, then ASSERT(). + If BufferSize > 1 and StartOfBuffer is NULL, then ASSERT(). + If BufferSize > 1 and FormatString is NULL, then ASSERT(). If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than - PcdMaximumUnicodeStringLength Unicode characters, then ASSERT(). + PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator, then + ASSERT(). If PcdMaximumUnicodeStringLength is not zero, and produced Null-terminated Unicode string - contains more than PcdMaximumUnicodeStringLength Unicode characters, then ASSERT(). + contains more than PcdMaximumUnicodeStringLength Unicode characters not including the + Null-terminator, then ASSERT(). - @param StartOfBuffer APointer to the output buffer for the produced Null-terminated + @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated Unicode string. @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer. @param FormatString Null-terminated Unicode format string. - @return Length of the produced output buffer. + @return The number of Unicode characters in the produced output buffer not including the + Null-terminator. **/ UINTN @@ -122,23 +130,27 @@ UnicodeSPrint ( The Unicode string is produced by parsing the format string specified by FormatString. Arguments are pulled from the variable argument list specified by Marker based on the contents of the format string. - The length of the produced output buffer is returned. - If BufferSize is 0, then no output buffer is produced and 0 is returned. - - If BufferSize is not 0 and StartOfBuffer is NULL, then ASSERT(). - If BufferSize is not 0 and FormatString is NULL, then ASSERT(). - If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than - PcdMaximumUnicodeStringLength Unicode characters, then ASSERT(). + The number of Unicode characters in the produced output buffer is returned not including + the Null-terminator. + If BufferSize is 0 or 1, then no output buffer is produced and 0 is returned. + + If BufferSize > 1 and StartOfBuffer is NULL, then ASSERT(). + If BufferSize > 1 and FormatString is NULL, then ASSERT(). + If PcdMaximumAsciiStringLength is not zero, and FormatString contains more than + PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator, then + ASSERT(). If PcdMaximumUnicodeStringLength is not zero, and produced Null-terminated Unicode string - contains more than PcdMaximumUnicodeStringLength Unicode characters, then ASSERT(). + contains more than PcdMaximumUnicodeStringLength Unicode characters not including the + Null-terminator, then ASSERT(). - @param StartOfBuffer APointer to the output buffer for the produced Null-terminated + @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated Unicode string. @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer. @param FormatString Null-terminated Unicode format string. @param Marker VA_LIST marker for the variable argument list. - @return Length of the produced output buffer. + @return The number of Unicode characters in the produced output buffer not including the + Null-terminator. **/ UINTN @@ -159,22 +171,26 @@ UnicodeVSPrintAsciiFormat ( The Unicode string is produced by parsing the format string specified by FormatString. Arguments are pulled from the variable argument list based on the contents of the format string. - The length of the produced output buffer is returned. - If BufferSize is 0, then no output buffer is produced and 0 is returned. - - If BufferSize is not 0 and StartOfBuffer is NULL, then ASSERT(). - If BufferSize is not 0 and FormatString is NULL, then ASSERT(). - If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than - PcdMaximumUnicodeStringLength Unicode characters, then ASSERT(). + The number of Unicode characters in the produced output buffer is returned not including + the Null-terminator. + If BufferSize is 0 or 1, then no output buffer is produced and 0 is returned. + + If BufferSize > 1 and StartOfBuffer is NULL, then ASSERT(). + If BufferSize > 1 and FormatString is NULL, then ASSERT(). + If PcdMaximumAsciiStringLength is not zero, and FormatString contains more than + PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator, then + ASSERT(). If PcdMaximumUnicodeStringLength is not zero, and produced Null-terminated Unicode string - contains more than PcdMaximumUnicodeStringLength Unicode characters, then ASSERT(). + contains more than PcdMaximumUnicodeStringLength Unicode characters not including the + Null-terminator, then ASSERT(). - @param StartOfBuffer APointer to the output buffer for the produced Null-terminated + @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated Unicode string. @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer. @param FormatString Null-terminated Unicode format string. - @return Length of the produced output buffer. + @return The number of Unicode characters in the produced output buffer not including the + Null-terminator. **/ UINTN @@ -195,23 +211,27 @@ UnicodeSPrintAsciiFormat ( The ASCII string is produced by parsing the format string specified by FormatString. Arguments are pulled from the variable argument list specified by Marker based on the contents of the format string. - The length of the produced output buffer is returned. + The number of ASCII characters in the produced output buffer is returned not including + the Null-terminator. If BufferSize is 0, then no output buffer is produced and 0 is returned. - If BufferSize is not 0 and StartOfBuffer is NULL, then ASSERT(). - If BufferSize is not 0 and FormatString is NULL, then ASSERT(). - If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than - PcdMaximumUnicodeStringLength ASCII characters, then ASSERT(). - If PcdMaximumUnicodeStringLength is not zero, and produced Null-terminated Unicode string - contains more than PcdMaximumUnicodeStringLength ASCII characters, then ASSERT(). + If BufferSize > 0 and StartOfBuffer is NULL, then ASSERT(). + If BufferSize > 0 and FormatString is NULL, then ASSERT(). + If PcdMaximumAsciiStringLength is not zero, and FormatString contains more than + PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator, then + ASSERT(). + If PcdMaximumAsciiStringLength is not zero, and produced Null-terminated ASCII string + contains more than PcdMaximumAsciiStringLength ASCII characters not including the + Null-terminator, then ASSERT(). - @param StartOfBuffer APointer to the output buffer for the produced Null-terminated + @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated ASCII string. @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer. @param FormatString Null-terminated Unicode format string. @param Marker VA_LIST marker for the variable argument list. - @return Length of the produced output buffer. + @return The number of ASCII characters in the produced output buffer not including the + Null-terminator. **/ UINTN @@ -232,22 +252,26 @@ AsciiVSPrint ( The ASCII string is produced by parsing the format string specified by FormatString. Arguments are pulled from the variable argument list based on the contents of the format string. - The length of the produced output buffer is returned. + The number of ASCII characters in the produced output buffer is returned not including + the Null-terminator. If BufferSize is 0, then no output buffer is produced and 0 is returned. - If BufferSize is not 0 and StartOfBuffer is NULL, then ASSERT(). - If BufferSize is not 0 and FormatString is NULL, then ASSERT(). - If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than - PcdMaximumUnicodeStringLength ASCII characters, then ASSERT(). - If PcdMaximumUnicodeStringLength is not zero, and produced Null-terminated Unicode string - contains more than PcdMaximumUnicodeStringLength ASCII characters, then ASSERT(). + If BufferSize > 0 and StartOfBuffer is NULL, then ASSERT(). + If BufferSize > 0 and FormatString is NULL, then ASSERT(). + If PcdMaximumAsciiStringLength is not zero, and FormatString contains more than + PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator, then + ASSERT(). + If PcdMaximumAsciiStringLength is not zero, and produced Null-terminated ASCII string + contains more than PcdMaximumAsciiStringLength ASCII characters not including the + Null-terminator, then ASSERT(). - @param StartOfBuffer APointer to the output buffer for the produced Null-terminated + @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated ASCII string. @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer. @param FormatString Null-terminated Unicode format string. - @return Length of the produced output buffer. + @return The number of ASCII characters in the produced output buffer not including the + Null-terminator. **/ UINTN @@ -268,23 +292,27 @@ AsciiSPrint ( The ASCII string is produced by parsing the format string specified by FormatString. Arguments are pulled from the variable argument list specified by Marker based on the contents of the format string. - The length of the produced output buffer is returned. + The number of ASCII characters in the produced output buffer is returned not including + the Null-terminator. If BufferSize is 0, then no output buffer is produced and 0 is returned. - If BufferSize is not 0 and StartOfBuffer is NULL, then ASSERT(). - If BufferSize is not 0 and FormatString is NULL, then ASSERT(). - If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than - PcdMaximumUnicodeStringLength ASCII characters, then ASSERT(). - If PcdMaximumUnicodeStringLength is not zero, and produced Null-terminated Unicode string - contains more than PcdMaximumUnicodeStringLength ASCII characters, then ASSERT(). + If BufferSize > 0 and StartOfBuffer is NULL, then ASSERT(). + If BufferSize > 0 and FormatString is NULL, then ASSERT(). + If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than + PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator, then + ASSERT(). + If PcdMaximumAsciiStringLength is not zero, and produced Null-terminated ASCII string + contains more than PcdMaximumAsciiStringLength ASCII characters not including the + Null-terminator, then ASSERT(). - @param StartOfBuffer APointer to the output buffer for the produced Null-terminated + @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated ASCII string. @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer. @param FormatString Null-terminated Unicode format string. @param Marker VA_LIST marker for the variable argument list. - @return Length of the produced output buffer. + @return The number of ASCII characters in the produced output buffer not including the + Null-terminator. **/ UINTN @@ -305,22 +333,26 @@ AsciiVSPrintUnicodeFormat ( The ASCII string is produced by parsing the format string specified by FormatString. Arguments are pulled from the variable argument list based on the contents of the format string. - The length of the produced output buffer is returned. + The number of ASCII characters in the produced output buffer is returned not including + the Null-terminator. If BufferSize is 0, then no output buffer is produced and 0 is returned. - If BufferSize is not 0 and StartOfBuffer is NULL, then ASSERT(). - If BufferSize is not 0 and FormatString is NULL, then ASSERT(). - If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than - PcdMaximumUnicodeStringLength ASCII characters, then ASSERT(). - If PcdMaximumUnicodeStringLength is not zero, and produced Null-terminated Unicode string - contains more than PcdMaximumUnicodeStringLength ASCII characters, then ASSERT(). + If BufferSize > 0 and StartOfBuffer is NULL, then ASSERT(). + If BufferSize > 0 and FormatString is NULL, then ASSERT(). + If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than + PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator, then + ASSERT(). + If PcdMaximumAsciiStringLength is not zero, and produced Null-terminated ASCII string + contains more than PcdMaximumAsciiStringLength ASCII characters not including the + Null-terminator, then ASSERT(). - @param StartOfBuffer APointer to the output buffer for the produced Null-terminated + @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated ASCII string. @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer. @param FormatString Null-terminated Unicode format string. - @return Length of the produced output buffer. + @return The number of ASCII characters in the produced output buffer not including the + Null-terminator. **/ UINTN @@ -338,7 +370,7 @@ AsciiSPrintUnicodeFormat ( Converts the decimal number specified by Value to a Null-terminated Unicode string specified by Buffer containing at most Width characters. If Width is 0 then a width of MAXIMUM_VALUE_CHARACTERS is assumed. - The total number of characters placed in Buffer is returned. + The number of Unicode characters in Buffer is returned not including the Null-terminator. If the conversion contains more than Width characters, then only the first Width characters are returned, and the total number of characters required to perform the conversion is returned. @@ -362,9 +394,9 @@ AsciiSPrintUnicodeFormat ( Unicode string. @param Flags The bitmask of flags that specify left justification, zero pad, and commas. @param Value The 64-bit signed value to convert to a string. - @param Width The maximum number of Unicode characters to place in Buffer. + @param Width The maximum number of Unicode characters to place in Buffer. - @return Total number of characters required to perform the conversion. + @return The number of Unicode characters in Buffer not including the Null-terminator. **/ UINTN @@ -382,7 +414,7 @@ UnicodeValueToString ( Converts the decimal number specified by Value to a Null-terminated ASCII string specified by Buffer containing at most Width characters. If Width is 0 then a width of MAXIMUM_VALUE_CHARACTERS is assumed. - The total number of characters placed in Buffer is returned. + The number of ASCII characters in Buffer is returned not including the Null-terminator. If the conversion contains more than Width characters, then only the first Width characters are returned, and the total number of characters required to perform the conversion is returned. @@ -406,9 +438,9 @@ UnicodeValueToString ( ASCII string. @param Flags The bitmask of flags that specify left justification, zero pad, and commas. @param Value The 64-bit signed value to convert to a string. - @param Width The maximum number of ASCII characters to place in Buffer. + @param Width The maximum number of ASCII characters to place in Buffer. - @return Total number of characters required to perform the conversion. + @return The number of ASCII characters in Buffer not including the Null-terminator. **/ UINTN diff --git a/MdePkg/Library/BaseMemoryLib/CompareMemWrapper.c b/MdePkg/Library/BaseMemoryLib/CompareMemWrapper.c index e3b0fe3fd6..4c0d3eaadb 100644 --- a/MdePkg/Library/BaseMemoryLib/CompareMemWrapper.c +++ b/MdePkg/Library/BaseMemoryLib/CompareMemWrapper.c @@ -19,7 +19,7 @@ BaseMemoryLibSse2 BaseMemoryLibRepStr PeiMemoryLib - UefiMemoryLib + DxeMemoryLib **/ diff --git a/MdePkg/Library/BaseMemoryLib/CopyMemWrapper.c b/MdePkg/Library/BaseMemoryLib/CopyMemWrapper.c index 1fd00acabd..9e620e2200 100644 --- a/MdePkg/Library/BaseMemoryLib/CopyMemWrapper.c +++ b/MdePkg/Library/BaseMemoryLib/CopyMemWrapper.c @@ -19,7 +19,7 @@ BaseMemoryLibSse2 BaseMemoryLibRepStr PeiMemoryLib - UefiMemoryLib + DxeMemoryLib **/ diff --git a/MdePkg/Library/BaseMemoryLib/MemLibGeneric.c b/MdePkg/Library/BaseMemoryLib/MemLibGeneric.c index 3fecfc9ff0..759377483c 100644 --- a/MdePkg/Library/BaseMemoryLib/MemLibGeneric.c +++ b/MdePkg/Library/BaseMemoryLib/MemLibGeneric.c @@ -16,7 +16,7 @@ BaseMemoryLib PeiMemoryLib - UefiMemoryLib + DxeMemoryLib **/ diff --git a/MdePkg/Library/BaseMemoryLib/MemLibGuid.c b/MdePkg/Library/BaseMemoryLib/MemLibGuid.c index 351e370c2c..8932af7083 100644 --- a/MdePkg/Library/BaseMemoryLib/MemLibGuid.c +++ b/MdePkg/Library/BaseMemoryLib/MemLibGuid.c @@ -19,7 +19,7 @@ BaseMemoryLibSse2 BaseMemoryLibRepStr PeiMemoryLib - UefiMemoryLib + DxeMemoryLib **/ @@ -95,7 +95,8 @@ CompareGuid ( GUID in the target buffer is returned. If no match is found, then NULL is returned. If Length is 0, then NULL is returned. If Length > 0 and Buffer is NULL, then ASSERT(). - If Buffer is not aligned on a 64-bit boundary, then ASSERT(). + If Buffer is not aligned on a 32-bit boundary, then ASSERT(). + If Length is not aligned on a 128-bit boundary, then ASSERT(). If Length is greater than (MAX_ADDRESS – Buffer + 1), then ASSERT(). @param Buffer Pointer to the target buffer to scan. @@ -115,16 +116,12 @@ ScanGuid ( { CONST GUID *GuidPtr; - ASSERT (Buffer != NULL); - // - // Make sure Buffer is aligned on a 64-bit boundary. - // - ASSERT (((UINTN) Buffer & 7) == 0); - + ASSERT (((UINTN)Buffer & (sizeof (Guid->Data1) - 1)) == 0); ASSERT (Length <= (MAX_ADDRESS - (UINTN)Buffer + 1)); + ASSERT ((Length & (sizeof (*GuidPtr) - 1)) == 0); GuidPtr = (GUID*)Buffer; - Buffer = GuidPtr + Length / sizeof (*GuidPtr); + Buffer = GuidPtr + Length / sizeof (*GuidPtr); while (GuidPtr < (CONST GUID*)Buffer) { if (CompareGuid (GuidPtr, Guid)) { return (VOID*)GuidPtr; diff --git a/MdePkg/Library/BaseMemoryLib/MemLibInternals.h b/MdePkg/Library/BaseMemoryLib/MemLibInternals.h index ca7311a407..8646b24e79 100644 --- a/MdePkg/Library/BaseMemoryLib/MemLibInternals.h +++ b/MdePkg/Library/BaseMemoryLib/MemLibInternals.h @@ -19,7 +19,7 @@ BaseMemoryLibSse2 BaseMemoryLibRepStr PeiMemoryLib - UefiMemoryLib + DxeMemoryLib **/ diff --git a/MdePkg/Library/BaseMemoryLib/ScanMem16Wrapper.c b/MdePkg/Library/BaseMemoryLib/ScanMem16Wrapper.c index 9ffc2cf159..29170594d3 100644 --- a/MdePkg/Library/BaseMemoryLib/ScanMem16Wrapper.c +++ b/MdePkg/Library/BaseMemoryLib/ScanMem16Wrapper.c @@ -19,7 +19,7 @@ BaseMemoryLibSse2 BaseMemoryLibRepStr PeiMemoryLib - UefiMemoryLib + DxeMemoryLib **/ @@ -35,6 +35,7 @@ then NULL is returned. If Length is 0, then NULL is returned. If Length > 0 and Buffer is NULL, then ASSERT(). If Buffer is not aligned on a 16-bit boundary, then ASSERT(). + If Length is not aligned on a 16-bit boundary, then ASSERT(). If Length is greater than (MAX_ADDRESS – Buffer + 1), then ASSERT(). @param Buffer Pointer to the target buffer to scan. @@ -52,16 +53,14 @@ ScanMem16 ( IN UINT16 Value ) { - UINTN Stride; - - Stride = Length / sizeof (Value); - if (Stride == 0) { + if (Length == 0) { return NULL; } ASSERT (Buffer != NULL); ASSERT (((UINTN)Buffer & (sizeof (Value) - 1)) == 0); ASSERT ((Length - 1) <= (MAX_ADDRESS - (UINTN)Buffer)); + ASSERT ((Length & (sizeof (Value) - 1)) == 0); - return (VOID*)InternalMemScanMem16 (Buffer, Stride, Value); + return (VOID*)InternalMemScanMem16 (Buffer, Length / sizeof (Value), Value); } diff --git a/MdePkg/Library/BaseMemoryLib/ScanMem32Wrapper.c b/MdePkg/Library/BaseMemoryLib/ScanMem32Wrapper.c index 6b0beee632..b54d5da07c 100644 --- a/MdePkg/Library/BaseMemoryLib/ScanMem32Wrapper.c +++ b/MdePkg/Library/BaseMemoryLib/ScanMem32Wrapper.c @@ -19,7 +19,7 @@ BaseMemoryLibSse2 BaseMemoryLibRepStr PeiMemoryLib - UefiMemoryLib + DxeMemoryLib **/ @@ -35,6 +35,7 @@ then NULL is returned. If Length is 0, then NULL is returned. If Length > 0 and Buffer is NULL, then ASSERT(). If Buffer is not aligned on a 32-bit boundary, then ASSERT(). + If Length is not aligned on a 32-bit boundary, then ASSERT(). If Length is greater than (MAX_ADDRESS – Buffer + 1), then ASSERT(). @param Buffer Pointer to the target buffer to scan. @@ -52,16 +53,14 @@ ScanMem32 ( IN UINT32 Value ) { - UINTN Stride; - - Stride = Length / sizeof (Value); - if (Stride == 0) { + if (Length == 0) { return NULL; } ASSERT (Buffer != NULL); ASSERT (((UINTN)Buffer & (sizeof (Value) - 1)) == 0); ASSERT ((Length - 1) <= (MAX_ADDRESS - (UINTN)Buffer)); + ASSERT ((Length & (sizeof (Value) - 1)) == 0); - return (VOID*)InternalMemScanMem32 (Buffer, Stride, Value); + return (VOID*)InternalMemScanMem32 (Buffer, Length / sizeof (Value), Value); } diff --git a/MdePkg/Library/BaseMemoryLib/ScanMem64Wrapper.c b/MdePkg/Library/BaseMemoryLib/ScanMem64Wrapper.c index 589d45c1a1..7bfc7d721e 100644 --- a/MdePkg/Library/BaseMemoryLib/ScanMem64Wrapper.c +++ b/MdePkg/Library/BaseMemoryLib/ScanMem64Wrapper.c @@ -19,7 +19,7 @@ BaseMemoryLibSse2 BaseMemoryLibRepStr PeiMemoryLib - UefiMemoryLib + DxeMemoryLib **/ @@ -35,6 +35,7 @@ then NULL is returned. If Length is 0, then NULL is returned. If Length > 0 and Buffer is NULL, then ASSERT(). If Buffer is not aligned on a 64-bit boundary, then ASSERT(). + If Length is not aligned on a 64-bit boundary, then ASSERT(). If Length is greater than (MAX_ADDRESS – Buffer + 1), then ASSERT(). @param Buffer Pointer to the target buffer to scan. @@ -52,16 +53,14 @@ ScanMem64 ( IN UINT64 Value ) { - UINTN Stride; - - Stride = Length / sizeof (Value); - if (Stride == 0) { + if (Length == 0) { return NULL; } ASSERT (Buffer != NULL); ASSERT (((UINTN)Buffer & (sizeof (Value) - 1)) == 0); ASSERT ((Length - 1) <= (MAX_ADDRESS - (UINTN)Buffer)); + ASSERT ((Length & (sizeof (Value) - 1)) == 0); - return (VOID*)InternalMemScanMem64 (Buffer, Stride, Value); + return (VOID*)InternalMemScanMem64 (Buffer, Length / sizeof (Value), Value); } diff --git a/MdePkg/Library/BaseMemoryLib/ScanMem8Wrapper.c b/MdePkg/Library/BaseMemoryLib/ScanMem8Wrapper.c index 4dc8bac073..0f7289d3df 100644 --- a/MdePkg/Library/BaseMemoryLib/ScanMem8Wrapper.c +++ b/MdePkg/Library/BaseMemoryLib/ScanMem8Wrapper.c @@ -19,7 +19,7 @@ BaseMemoryLibSse2 BaseMemoryLibRepStr PeiMemoryLib - UefiMemoryLib + DxeMemoryLib **/ diff --git a/MdePkg/Library/BaseMemoryLib/SetMem16Wrapper.c b/MdePkg/Library/BaseMemoryLib/SetMem16Wrapper.c index 41467a9cb0..889339c953 100644 --- a/MdePkg/Library/BaseMemoryLib/SetMem16Wrapper.c +++ b/MdePkg/Library/BaseMemoryLib/SetMem16Wrapper.c @@ -19,7 +19,7 @@ BaseMemoryLibSse2 BaseMemoryLibRepStr PeiMemoryLib - UefiMemoryLib + DxeMemoryLib **/ diff --git a/MdePkg/Library/BaseMemoryLib/SetMem32Wrapper.c b/MdePkg/Library/BaseMemoryLib/SetMem32Wrapper.c index 425840682d..15f8205ebc 100644 --- a/MdePkg/Library/BaseMemoryLib/SetMem32Wrapper.c +++ b/MdePkg/Library/BaseMemoryLib/SetMem32Wrapper.c @@ -19,7 +19,7 @@ BaseMemoryLibSse2 BaseMemoryLibRepStr PeiMemoryLib - UefiMemoryLib + DxeMemoryLib **/ diff --git a/MdePkg/Library/BaseMemoryLib/SetMem64Wrapper.c b/MdePkg/Library/BaseMemoryLib/SetMem64Wrapper.c index 4a1eda80e8..981a7d4731 100644 --- a/MdePkg/Library/BaseMemoryLib/SetMem64Wrapper.c +++ b/MdePkg/Library/BaseMemoryLib/SetMem64Wrapper.c @@ -19,7 +19,7 @@ BaseMemoryLibSse2 BaseMemoryLibRepStr PeiMemoryLib - UefiMemoryLib + DxeMemoryLib **/ diff --git a/MdePkg/Library/BaseMemoryLib/SetMemWrapper.c b/MdePkg/Library/BaseMemoryLib/SetMemWrapper.c index 3965be759a..c73168841b 100644 --- a/MdePkg/Library/BaseMemoryLib/SetMemWrapper.c +++ b/MdePkg/Library/BaseMemoryLib/SetMemWrapper.c @@ -19,7 +19,7 @@ BaseMemoryLibSse2 BaseMemoryLibRepStr PeiMemoryLib - UefiMemoryLib + DxeMemoryLib **/ @@ -32,7 +32,7 @@ If Length is greater than (MAX_ADDRESS – Buffer + 1), then ASSERT(). @param Buffer Memory to set. - @param Length Number of bytes to set + @param Length Number of bytes to set. @param Value Value of the set operation. @return Buffer. diff --git a/MdePkg/Library/BaseMemoryLib/ZeroMemWrapper.c b/MdePkg/Library/BaseMemoryLib/ZeroMemWrapper.c index 56dbe5d8be..08247681c5 100644 --- a/MdePkg/Library/BaseMemoryLib/ZeroMemWrapper.c +++ b/MdePkg/Library/BaseMemoryLib/ZeroMemWrapper.c @@ -19,7 +19,7 @@ BaseMemoryLibSse2 BaseMemoryLibRepStr PeiMemoryLib - UefiMemoryLib + DxeMemoryLib **/ diff --git a/MdePkg/Library/BaseMemoryLibMmx/CompareMemWrapper.c b/MdePkg/Library/BaseMemoryLibMmx/CompareMemWrapper.c index e3b0fe3fd6..4c0d3eaadb 100644 --- a/MdePkg/Library/BaseMemoryLibMmx/CompareMemWrapper.c +++ b/MdePkg/Library/BaseMemoryLibMmx/CompareMemWrapper.c @@ -19,7 +19,7 @@ BaseMemoryLibSse2 BaseMemoryLibRepStr PeiMemoryLib - UefiMemoryLib + DxeMemoryLib **/ diff --git a/MdePkg/Library/BaseMemoryLibMmx/CopyMemWrapper.c b/MdePkg/Library/BaseMemoryLibMmx/CopyMemWrapper.c index 1fd00acabd..9e620e2200 100644 --- a/MdePkg/Library/BaseMemoryLibMmx/CopyMemWrapper.c +++ b/MdePkg/Library/BaseMemoryLibMmx/CopyMemWrapper.c @@ -19,7 +19,7 @@ BaseMemoryLibSse2 BaseMemoryLibRepStr PeiMemoryLib - UefiMemoryLib + DxeMemoryLib **/ diff --git a/MdePkg/Library/BaseMemoryLibMmx/MemLibGuid.c b/MdePkg/Library/BaseMemoryLibMmx/MemLibGuid.c index 351e370c2c..8932af7083 100644 --- a/MdePkg/Library/BaseMemoryLibMmx/MemLibGuid.c +++ b/MdePkg/Library/BaseMemoryLibMmx/MemLibGuid.c @@ -19,7 +19,7 @@ BaseMemoryLibSse2 BaseMemoryLibRepStr PeiMemoryLib - UefiMemoryLib + DxeMemoryLib **/ @@ -95,7 +95,8 @@ CompareGuid ( GUID in the target buffer is returned. If no match is found, then NULL is returned. If Length is 0, then NULL is returned. If Length > 0 and Buffer is NULL, then ASSERT(). - If Buffer is not aligned on a 64-bit boundary, then ASSERT(). + If Buffer is not aligned on a 32-bit boundary, then ASSERT(). + If Length is not aligned on a 128-bit boundary, then ASSERT(). If Length is greater than (MAX_ADDRESS – Buffer + 1), then ASSERT(). @param Buffer Pointer to the target buffer to scan. @@ -115,16 +116,12 @@ ScanGuid ( { CONST GUID *GuidPtr; - ASSERT (Buffer != NULL); - // - // Make sure Buffer is aligned on a 64-bit boundary. - // - ASSERT (((UINTN) Buffer & 7) == 0); - + ASSERT (((UINTN)Buffer & (sizeof (Guid->Data1) - 1)) == 0); ASSERT (Length <= (MAX_ADDRESS - (UINTN)Buffer + 1)); + ASSERT ((Length & (sizeof (*GuidPtr) - 1)) == 0); GuidPtr = (GUID*)Buffer; - Buffer = GuidPtr + Length / sizeof (*GuidPtr); + Buffer = GuidPtr + Length / sizeof (*GuidPtr); while (GuidPtr < (CONST GUID*)Buffer) { if (CompareGuid (GuidPtr, Guid)) { return (VOID*)GuidPtr; diff --git a/MdePkg/Library/BaseMemoryLibMmx/MemLibInternals.h b/MdePkg/Library/BaseMemoryLibMmx/MemLibInternals.h index ca7311a407..8646b24e79 100644 --- a/MdePkg/Library/BaseMemoryLibMmx/MemLibInternals.h +++ b/MdePkg/Library/BaseMemoryLibMmx/MemLibInternals.h @@ -19,7 +19,7 @@ BaseMemoryLibSse2 BaseMemoryLibRepStr PeiMemoryLib - UefiMemoryLib + DxeMemoryLib **/ diff --git a/MdePkg/Library/BaseMemoryLibMmx/ScanMem16Wrapper.c b/MdePkg/Library/BaseMemoryLibMmx/ScanMem16Wrapper.c index 9ffc2cf159..29170594d3 100644 --- a/MdePkg/Library/BaseMemoryLibMmx/ScanMem16Wrapper.c +++ b/MdePkg/Library/BaseMemoryLibMmx/ScanMem16Wrapper.c @@ -19,7 +19,7 @@ BaseMemoryLibSse2 BaseMemoryLibRepStr PeiMemoryLib - UefiMemoryLib + DxeMemoryLib **/ @@ -35,6 +35,7 @@ then NULL is returned. If Length is 0, then NULL is returned. If Length > 0 and Buffer is NULL, then ASSERT(). If Buffer is not aligned on a 16-bit boundary, then ASSERT(). + If Length is not aligned on a 16-bit boundary, then ASSERT(). If Length is greater than (MAX_ADDRESS – Buffer + 1), then ASSERT(). @param Buffer Pointer to the target buffer to scan. @@ -52,16 +53,14 @@ ScanMem16 ( IN UINT16 Value ) { - UINTN Stride; - - Stride = Length / sizeof (Value); - if (Stride == 0) { + if (Length == 0) { return NULL; } ASSERT (Buffer != NULL); ASSERT (((UINTN)Buffer & (sizeof (Value) - 1)) == 0); ASSERT ((Length - 1) <= (MAX_ADDRESS - (UINTN)Buffer)); + ASSERT ((Length & (sizeof (Value) - 1)) == 0); - return (VOID*)InternalMemScanMem16 (Buffer, Stride, Value); + return (VOID*)InternalMemScanMem16 (Buffer, Length / sizeof (Value), Value); } diff --git a/MdePkg/Library/BaseMemoryLibMmx/ScanMem32Wrapper.c b/MdePkg/Library/BaseMemoryLibMmx/ScanMem32Wrapper.c index 6b0beee632..b54d5da07c 100644 --- a/MdePkg/Library/BaseMemoryLibMmx/ScanMem32Wrapper.c +++ b/MdePkg/Library/BaseMemoryLibMmx/ScanMem32Wrapper.c @@ -19,7 +19,7 @@ BaseMemoryLibSse2 BaseMemoryLibRepStr PeiMemoryLib - UefiMemoryLib + DxeMemoryLib **/ @@ -35,6 +35,7 @@ then NULL is returned. If Length is 0, then NULL is returned. If Length > 0 and Buffer is NULL, then ASSERT(). If Buffer is not aligned on a 32-bit boundary, then ASSERT(). + If Length is not aligned on a 32-bit boundary, then ASSERT(). If Length is greater than (MAX_ADDRESS – Buffer + 1), then ASSERT(). @param Buffer Pointer to the target buffer to scan. @@ -52,16 +53,14 @@ ScanMem32 ( IN UINT32 Value ) { - UINTN Stride; - - Stride = Length / sizeof (Value); - if (Stride == 0) { + if (Length == 0) { return NULL; } ASSERT (Buffer != NULL); ASSERT (((UINTN)Buffer & (sizeof (Value) - 1)) == 0); ASSERT ((Length - 1) <= (MAX_ADDRESS - (UINTN)Buffer)); + ASSERT ((Length & (sizeof (Value) - 1)) == 0); - return (VOID*)InternalMemScanMem32 (Buffer, Stride, Value); + return (VOID*)InternalMemScanMem32 (Buffer, Length / sizeof (Value), Value); } diff --git a/MdePkg/Library/BaseMemoryLibMmx/ScanMem64Wrapper.c b/MdePkg/Library/BaseMemoryLibMmx/ScanMem64Wrapper.c index 589d45c1a1..7bfc7d721e 100644 --- a/MdePkg/Library/BaseMemoryLibMmx/ScanMem64Wrapper.c +++ b/MdePkg/Library/BaseMemoryLibMmx/ScanMem64Wrapper.c @@ -19,7 +19,7 @@ BaseMemoryLibSse2 BaseMemoryLibRepStr PeiMemoryLib - UefiMemoryLib + DxeMemoryLib **/ @@ -35,6 +35,7 @@ then NULL is returned. If Length is 0, then NULL is returned. If Length > 0 and Buffer is NULL, then ASSERT(). If Buffer is not aligned on a 64-bit boundary, then ASSERT(). + If Length is not aligned on a 64-bit boundary, then ASSERT(). If Length is greater than (MAX_ADDRESS – Buffer + 1), then ASSERT(). @param Buffer Pointer to the target buffer to scan. @@ -52,16 +53,14 @@ ScanMem64 ( IN UINT64 Value ) { - UINTN Stride; - - Stride = Length / sizeof (Value); - if (Stride == 0) { + if (Length == 0) { return NULL; } ASSERT (Buffer != NULL); ASSERT (((UINTN)Buffer & (sizeof (Value) - 1)) == 0); ASSERT ((Length - 1) <= (MAX_ADDRESS - (UINTN)Buffer)); + ASSERT ((Length & (sizeof (Value) - 1)) == 0); - return (VOID*)InternalMemScanMem64 (Buffer, Stride, Value); + return (VOID*)InternalMemScanMem64 (Buffer, Length / sizeof (Value), Value); } diff --git a/MdePkg/Library/BaseMemoryLibMmx/ScanMem8Wrapper.c b/MdePkg/Library/BaseMemoryLibMmx/ScanMem8Wrapper.c index 4dc8bac073..0f7289d3df 100644 --- a/MdePkg/Library/BaseMemoryLibMmx/ScanMem8Wrapper.c +++ b/MdePkg/Library/BaseMemoryLibMmx/ScanMem8Wrapper.c @@ -19,7 +19,7 @@ BaseMemoryLibSse2 BaseMemoryLibRepStr PeiMemoryLib - UefiMemoryLib + DxeMemoryLib **/ diff --git a/MdePkg/Library/BaseMemoryLibMmx/SetMem16Wrapper.c b/MdePkg/Library/BaseMemoryLibMmx/SetMem16Wrapper.c index 41467a9cb0..889339c953 100644 --- a/MdePkg/Library/BaseMemoryLibMmx/SetMem16Wrapper.c +++ b/MdePkg/Library/BaseMemoryLibMmx/SetMem16Wrapper.c @@ -19,7 +19,7 @@ BaseMemoryLibSse2 BaseMemoryLibRepStr PeiMemoryLib - UefiMemoryLib + DxeMemoryLib **/ diff --git a/MdePkg/Library/BaseMemoryLibMmx/SetMem32Wrapper.c b/MdePkg/Library/BaseMemoryLibMmx/SetMem32Wrapper.c index 425840682d..15f8205ebc 100644 --- a/MdePkg/Library/BaseMemoryLibMmx/SetMem32Wrapper.c +++ b/MdePkg/Library/BaseMemoryLibMmx/SetMem32Wrapper.c @@ -19,7 +19,7 @@ BaseMemoryLibSse2 BaseMemoryLibRepStr PeiMemoryLib - UefiMemoryLib + DxeMemoryLib **/ diff --git a/MdePkg/Library/BaseMemoryLibMmx/SetMem64Wrapper.c b/MdePkg/Library/BaseMemoryLibMmx/SetMem64Wrapper.c index 4a1eda80e8..981a7d4731 100644 --- a/MdePkg/Library/BaseMemoryLibMmx/SetMem64Wrapper.c +++ b/MdePkg/Library/BaseMemoryLibMmx/SetMem64Wrapper.c @@ -19,7 +19,7 @@ BaseMemoryLibSse2 BaseMemoryLibRepStr PeiMemoryLib - UefiMemoryLib + DxeMemoryLib **/ diff --git a/MdePkg/Library/BaseMemoryLibMmx/SetMemWrapper.c b/MdePkg/Library/BaseMemoryLibMmx/SetMemWrapper.c index 3965be759a..c73168841b 100644 --- a/MdePkg/Library/BaseMemoryLibMmx/SetMemWrapper.c +++ b/MdePkg/Library/BaseMemoryLibMmx/SetMemWrapper.c @@ -19,7 +19,7 @@ BaseMemoryLibSse2 BaseMemoryLibRepStr PeiMemoryLib - UefiMemoryLib + DxeMemoryLib **/ @@ -32,7 +32,7 @@ If Length is greater than (MAX_ADDRESS – Buffer + 1), then ASSERT(). @param Buffer Memory to set. - @param Length Number of bytes to set + @param Length Number of bytes to set. @param Value Value of the set operation. @return Buffer. diff --git a/MdePkg/Library/BaseMemoryLibMmx/ZeroMemWrapper.c b/MdePkg/Library/BaseMemoryLibMmx/ZeroMemWrapper.c index 56dbe5d8be..08247681c5 100644 --- a/MdePkg/Library/BaseMemoryLibMmx/ZeroMemWrapper.c +++ b/MdePkg/Library/BaseMemoryLibMmx/ZeroMemWrapper.c @@ -19,7 +19,7 @@ BaseMemoryLibSse2 BaseMemoryLibRepStr PeiMemoryLib - UefiMemoryLib + DxeMemoryLib **/ diff --git a/MdePkg/Library/BaseMemoryLibRepStr/CompareMemWrapper.c b/MdePkg/Library/BaseMemoryLibRepStr/CompareMemWrapper.c index e3b0fe3fd6..4c0d3eaadb 100644 --- a/MdePkg/Library/BaseMemoryLibRepStr/CompareMemWrapper.c +++ b/MdePkg/Library/BaseMemoryLibRepStr/CompareMemWrapper.c @@ -19,7 +19,7 @@ BaseMemoryLibSse2 BaseMemoryLibRepStr PeiMemoryLib - UefiMemoryLib + DxeMemoryLib **/ diff --git a/MdePkg/Library/BaseMemoryLibRepStr/CopyMemWrapper.c b/MdePkg/Library/BaseMemoryLibRepStr/CopyMemWrapper.c index 1fd00acabd..9e620e2200 100644 --- a/MdePkg/Library/BaseMemoryLibRepStr/CopyMemWrapper.c +++ b/MdePkg/Library/BaseMemoryLibRepStr/CopyMemWrapper.c @@ -19,7 +19,7 @@ BaseMemoryLibSse2 BaseMemoryLibRepStr PeiMemoryLib - UefiMemoryLib + DxeMemoryLib **/ diff --git a/MdePkg/Library/BaseMemoryLibRepStr/MemLibGuid.c b/MdePkg/Library/BaseMemoryLibRepStr/MemLibGuid.c index 351e370c2c..8932af7083 100644 --- a/MdePkg/Library/BaseMemoryLibRepStr/MemLibGuid.c +++ b/MdePkg/Library/BaseMemoryLibRepStr/MemLibGuid.c @@ -19,7 +19,7 @@ BaseMemoryLibSse2 BaseMemoryLibRepStr PeiMemoryLib - UefiMemoryLib + DxeMemoryLib **/ @@ -95,7 +95,8 @@ CompareGuid ( GUID in the target buffer is returned. If no match is found, then NULL is returned. If Length is 0, then NULL is returned. If Length > 0 and Buffer is NULL, then ASSERT(). - If Buffer is not aligned on a 64-bit boundary, then ASSERT(). + If Buffer is not aligned on a 32-bit boundary, then ASSERT(). + If Length is not aligned on a 128-bit boundary, then ASSERT(). If Length is greater than (MAX_ADDRESS – Buffer + 1), then ASSERT(). @param Buffer Pointer to the target buffer to scan. @@ -115,16 +116,12 @@ ScanGuid ( { CONST GUID *GuidPtr; - ASSERT (Buffer != NULL); - // - // Make sure Buffer is aligned on a 64-bit boundary. - // - ASSERT (((UINTN) Buffer & 7) == 0); - + ASSERT (((UINTN)Buffer & (sizeof (Guid->Data1) - 1)) == 0); ASSERT (Length <= (MAX_ADDRESS - (UINTN)Buffer + 1)); + ASSERT ((Length & (sizeof (*GuidPtr) - 1)) == 0); GuidPtr = (GUID*)Buffer; - Buffer = GuidPtr + Length / sizeof (*GuidPtr); + Buffer = GuidPtr + Length / sizeof (*GuidPtr); while (GuidPtr < (CONST GUID*)Buffer) { if (CompareGuid (GuidPtr, Guid)) { return (VOID*)GuidPtr; diff --git a/MdePkg/Library/BaseMemoryLibRepStr/MemLibInternals.h b/MdePkg/Library/BaseMemoryLibRepStr/MemLibInternals.h index ca7311a407..8646b24e79 100644 --- a/MdePkg/Library/BaseMemoryLibRepStr/MemLibInternals.h +++ b/MdePkg/Library/BaseMemoryLibRepStr/MemLibInternals.h @@ -19,7 +19,7 @@ BaseMemoryLibSse2 BaseMemoryLibRepStr PeiMemoryLib - UefiMemoryLib + DxeMemoryLib **/ diff --git a/MdePkg/Library/BaseMemoryLibRepStr/ScanMem16Wrapper.c b/MdePkg/Library/BaseMemoryLibRepStr/ScanMem16Wrapper.c index 9ffc2cf159..29170594d3 100644 --- a/MdePkg/Library/BaseMemoryLibRepStr/ScanMem16Wrapper.c +++ b/MdePkg/Library/BaseMemoryLibRepStr/ScanMem16Wrapper.c @@ -19,7 +19,7 @@ BaseMemoryLibSse2 BaseMemoryLibRepStr PeiMemoryLib - UefiMemoryLib + DxeMemoryLib **/ @@ -35,6 +35,7 @@ then NULL is returned. If Length is 0, then NULL is returned. If Length > 0 and Buffer is NULL, then ASSERT(). If Buffer is not aligned on a 16-bit boundary, then ASSERT(). + If Length is not aligned on a 16-bit boundary, then ASSERT(). If Length is greater than (MAX_ADDRESS – Buffer + 1), then ASSERT(). @param Buffer Pointer to the target buffer to scan. @@ -52,16 +53,14 @@ ScanMem16 ( IN UINT16 Value ) { - UINTN Stride; - - Stride = Length / sizeof (Value); - if (Stride == 0) { + if (Length == 0) { return NULL; } ASSERT (Buffer != NULL); ASSERT (((UINTN)Buffer & (sizeof (Value) - 1)) == 0); ASSERT ((Length - 1) <= (MAX_ADDRESS - (UINTN)Buffer)); + ASSERT ((Length & (sizeof (Value) - 1)) == 0); - return (VOID*)InternalMemScanMem16 (Buffer, Stride, Value); + return (VOID*)InternalMemScanMem16 (Buffer, Length / sizeof (Value), Value); } diff --git a/MdePkg/Library/BaseMemoryLibRepStr/ScanMem32Wrapper.c b/MdePkg/Library/BaseMemoryLibRepStr/ScanMem32Wrapper.c index 6b0beee632..b54d5da07c 100644 --- a/MdePkg/Library/BaseMemoryLibRepStr/ScanMem32Wrapper.c +++ b/MdePkg/Library/BaseMemoryLibRepStr/ScanMem32Wrapper.c @@ -19,7 +19,7 @@ BaseMemoryLibSse2 BaseMemoryLibRepStr PeiMemoryLib - UefiMemoryLib + DxeMemoryLib **/ @@ -35,6 +35,7 @@ then NULL is returned. If Length is 0, then NULL is returned. If Length > 0 and Buffer is NULL, then ASSERT(). If Buffer is not aligned on a 32-bit boundary, then ASSERT(). + If Length is not aligned on a 32-bit boundary, then ASSERT(). If Length is greater than (MAX_ADDRESS – Buffer + 1), then ASSERT(). @param Buffer Pointer to the target buffer to scan. @@ -52,16 +53,14 @@ ScanMem32 ( IN UINT32 Value ) { - UINTN Stride; - - Stride = Length / sizeof (Value); - if (Stride == 0) { + if (Length == 0) { return NULL; } ASSERT (Buffer != NULL); ASSERT (((UINTN)Buffer & (sizeof (Value) - 1)) == 0); ASSERT ((Length - 1) <= (MAX_ADDRESS - (UINTN)Buffer)); + ASSERT ((Length & (sizeof (Value) - 1)) == 0); - return (VOID*)InternalMemScanMem32 (Buffer, Stride, Value); + return (VOID*)InternalMemScanMem32 (Buffer, Length / sizeof (Value), Value); } diff --git a/MdePkg/Library/BaseMemoryLibRepStr/ScanMem64Wrapper.c b/MdePkg/Library/BaseMemoryLibRepStr/ScanMem64Wrapper.c index 589d45c1a1..7bfc7d721e 100644 --- a/MdePkg/Library/BaseMemoryLibRepStr/ScanMem64Wrapper.c +++ b/MdePkg/Library/BaseMemoryLibRepStr/ScanMem64Wrapper.c @@ -19,7 +19,7 @@ BaseMemoryLibSse2 BaseMemoryLibRepStr PeiMemoryLib - UefiMemoryLib + DxeMemoryLib **/ @@ -35,6 +35,7 @@ then NULL is returned. If Length is 0, then NULL is returned. If Length > 0 and Buffer is NULL, then ASSERT(). If Buffer is not aligned on a 64-bit boundary, then ASSERT(). + If Length is not aligned on a 64-bit boundary, then ASSERT(). If Length is greater than (MAX_ADDRESS – Buffer + 1), then ASSERT(). @param Buffer Pointer to the target buffer to scan. @@ -52,16 +53,14 @@ ScanMem64 ( IN UINT64 Value ) { - UINTN Stride; - - Stride = Length / sizeof (Value); - if (Stride == 0) { + if (Length == 0) { return NULL; } ASSERT (Buffer != NULL); ASSERT (((UINTN)Buffer & (sizeof (Value) - 1)) == 0); ASSERT ((Length - 1) <= (MAX_ADDRESS - (UINTN)Buffer)); + ASSERT ((Length & (sizeof (Value) - 1)) == 0); - return (VOID*)InternalMemScanMem64 (Buffer, Stride, Value); + return (VOID*)InternalMemScanMem64 (Buffer, Length / sizeof (Value), Value); } diff --git a/MdePkg/Library/BaseMemoryLibRepStr/ScanMem8Wrapper.c b/MdePkg/Library/BaseMemoryLibRepStr/ScanMem8Wrapper.c index 4dc8bac073..0f7289d3df 100644 --- a/MdePkg/Library/BaseMemoryLibRepStr/ScanMem8Wrapper.c +++ b/MdePkg/Library/BaseMemoryLibRepStr/ScanMem8Wrapper.c @@ -19,7 +19,7 @@ BaseMemoryLibSse2 BaseMemoryLibRepStr PeiMemoryLib - UefiMemoryLib + DxeMemoryLib **/ diff --git a/MdePkg/Library/BaseMemoryLibRepStr/SetMem16Wrapper.c b/MdePkg/Library/BaseMemoryLibRepStr/SetMem16Wrapper.c index 41467a9cb0..889339c953 100644 --- a/MdePkg/Library/BaseMemoryLibRepStr/SetMem16Wrapper.c +++ b/MdePkg/Library/BaseMemoryLibRepStr/SetMem16Wrapper.c @@ -19,7 +19,7 @@ BaseMemoryLibSse2 BaseMemoryLibRepStr PeiMemoryLib - UefiMemoryLib + DxeMemoryLib **/ diff --git a/MdePkg/Library/BaseMemoryLibRepStr/SetMem32Wrapper.c b/MdePkg/Library/BaseMemoryLibRepStr/SetMem32Wrapper.c index 425840682d..15f8205ebc 100644 --- a/MdePkg/Library/BaseMemoryLibRepStr/SetMem32Wrapper.c +++ b/MdePkg/Library/BaseMemoryLibRepStr/SetMem32Wrapper.c @@ -19,7 +19,7 @@ BaseMemoryLibSse2 BaseMemoryLibRepStr PeiMemoryLib - UefiMemoryLib + DxeMemoryLib **/ diff --git a/MdePkg/Library/BaseMemoryLibRepStr/SetMem64Wrapper.c b/MdePkg/Library/BaseMemoryLibRepStr/SetMem64Wrapper.c index 4a1eda80e8..981a7d4731 100644 --- a/MdePkg/Library/BaseMemoryLibRepStr/SetMem64Wrapper.c +++ b/MdePkg/Library/BaseMemoryLibRepStr/SetMem64Wrapper.c @@ -19,7 +19,7 @@ BaseMemoryLibSse2 BaseMemoryLibRepStr PeiMemoryLib - UefiMemoryLib + DxeMemoryLib **/ diff --git a/MdePkg/Library/BaseMemoryLibRepStr/SetMemWrapper.c b/MdePkg/Library/BaseMemoryLibRepStr/SetMemWrapper.c index 3965be759a..c73168841b 100644 --- a/MdePkg/Library/BaseMemoryLibRepStr/SetMemWrapper.c +++ b/MdePkg/Library/BaseMemoryLibRepStr/SetMemWrapper.c @@ -19,7 +19,7 @@ BaseMemoryLibSse2 BaseMemoryLibRepStr PeiMemoryLib - UefiMemoryLib + DxeMemoryLib **/ @@ -32,7 +32,7 @@ If Length is greater than (MAX_ADDRESS – Buffer + 1), then ASSERT(). @param Buffer Memory to set. - @param Length Number of bytes to set + @param Length Number of bytes to set. @param Value Value of the set operation. @return Buffer. diff --git a/MdePkg/Library/BaseMemoryLibRepStr/ZeroMemWrapper.c b/MdePkg/Library/BaseMemoryLibRepStr/ZeroMemWrapper.c index 56dbe5d8be..08247681c5 100644 --- a/MdePkg/Library/BaseMemoryLibRepStr/ZeroMemWrapper.c +++ b/MdePkg/Library/BaseMemoryLibRepStr/ZeroMemWrapper.c @@ -19,7 +19,7 @@ BaseMemoryLibSse2 BaseMemoryLibRepStr PeiMemoryLib - UefiMemoryLib + DxeMemoryLib **/ diff --git a/MdePkg/Library/BaseMemoryLibSse2/CompareMemWrapper.c b/MdePkg/Library/BaseMemoryLibSse2/CompareMemWrapper.c index e3b0fe3fd6..4c0d3eaadb 100644 --- a/MdePkg/Library/BaseMemoryLibSse2/CompareMemWrapper.c +++ b/MdePkg/Library/BaseMemoryLibSse2/CompareMemWrapper.c @@ -19,7 +19,7 @@ BaseMemoryLibSse2 BaseMemoryLibRepStr PeiMemoryLib - UefiMemoryLib + DxeMemoryLib **/ diff --git a/MdePkg/Library/BaseMemoryLibSse2/CopyMemWrapper.c b/MdePkg/Library/BaseMemoryLibSse2/CopyMemWrapper.c index 1fd00acabd..9e620e2200 100644 --- a/MdePkg/Library/BaseMemoryLibSse2/CopyMemWrapper.c +++ b/MdePkg/Library/BaseMemoryLibSse2/CopyMemWrapper.c @@ -19,7 +19,7 @@ BaseMemoryLibSse2 BaseMemoryLibRepStr PeiMemoryLib - UefiMemoryLib + DxeMemoryLib **/ diff --git a/MdePkg/Library/BaseMemoryLibSse2/MemLibGuid.c b/MdePkg/Library/BaseMemoryLibSse2/MemLibGuid.c index 351e370c2c..8932af7083 100644 --- a/MdePkg/Library/BaseMemoryLibSse2/MemLibGuid.c +++ b/MdePkg/Library/BaseMemoryLibSse2/MemLibGuid.c @@ -19,7 +19,7 @@ BaseMemoryLibSse2 BaseMemoryLibRepStr PeiMemoryLib - UefiMemoryLib + DxeMemoryLib **/ @@ -95,7 +95,8 @@ CompareGuid ( GUID in the target buffer is returned. If no match is found, then NULL is returned. If Length is 0, then NULL is returned. If Length > 0 and Buffer is NULL, then ASSERT(). - If Buffer is not aligned on a 64-bit boundary, then ASSERT(). + If Buffer is not aligned on a 32-bit boundary, then ASSERT(). + If Length is not aligned on a 128-bit boundary, then ASSERT(). If Length is greater than (MAX_ADDRESS – Buffer + 1), then ASSERT(). @param Buffer Pointer to the target buffer to scan. @@ -115,16 +116,12 @@ ScanGuid ( { CONST GUID *GuidPtr; - ASSERT (Buffer != NULL); - // - // Make sure Buffer is aligned on a 64-bit boundary. - // - ASSERT (((UINTN) Buffer & 7) == 0); - + ASSERT (((UINTN)Buffer & (sizeof (Guid->Data1) - 1)) == 0); ASSERT (Length <= (MAX_ADDRESS - (UINTN)Buffer + 1)); + ASSERT ((Length & (sizeof (*GuidPtr) - 1)) == 0); GuidPtr = (GUID*)Buffer; - Buffer = GuidPtr + Length / sizeof (*GuidPtr); + Buffer = GuidPtr + Length / sizeof (*GuidPtr); while (GuidPtr < (CONST GUID*)Buffer) { if (CompareGuid (GuidPtr, Guid)) { return (VOID*)GuidPtr; diff --git a/MdePkg/Library/BaseMemoryLibSse2/MemLibInternals.h b/MdePkg/Library/BaseMemoryLibSse2/MemLibInternals.h index ca7311a407..8646b24e79 100644 --- a/MdePkg/Library/BaseMemoryLibSse2/MemLibInternals.h +++ b/MdePkg/Library/BaseMemoryLibSse2/MemLibInternals.h @@ -19,7 +19,7 @@ BaseMemoryLibSse2 BaseMemoryLibRepStr PeiMemoryLib - UefiMemoryLib + DxeMemoryLib **/ diff --git a/MdePkg/Library/BaseMemoryLibSse2/ScanMem16Wrapper.c b/MdePkg/Library/BaseMemoryLibSse2/ScanMem16Wrapper.c index 9ffc2cf159..29170594d3 100644 --- a/MdePkg/Library/BaseMemoryLibSse2/ScanMem16Wrapper.c +++ b/MdePkg/Library/BaseMemoryLibSse2/ScanMem16Wrapper.c @@ -19,7 +19,7 @@ BaseMemoryLibSse2 BaseMemoryLibRepStr PeiMemoryLib - UefiMemoryLib + DxeMemoryLib **/ @@ -35,6 +35,7 @@ then NULL is returned. If Length is 0, then NULL is returned. If Length > 0 and Buffer is NULL, then ASSERT(). If Buffer is not aligned on a 16-bit boundary, then ASSERT(). + If Length is not aligned on a 16-bit boundary, then ASSERT(). If Length is greater than (MAX_ADDRESS – Buffer + 1), then ASSERT(). @param Buffer Pointer to the target buffer to scan. @@ -52,16 +53,14 @@ ScanMem16 ( IN UINT16 Value ) { - UINTN Stride; - - Stride = Length / sizeof (Value); - if (Stride == 0) { + if (Length == 0) { return NULL; } ASSERT (Buffer != NULL); ASSERT (((UINTN)Buffer & (sizeof (Value) - 1)) == 0); ASSERT ((Length - 1) <= (MAX_ADDRESS - (UINTN)Buffer)); + ASSERT ((Length & (sizeof (Value) - 1)) == 0); - return (VOID*)InternalMemScanMem16 (Buffer, Stride, Value); + return (VOID*)InternalMemScanMem16 (Buffer, Length / sizeof (Value), Value); } diff --git a/MdePkg/Library/BaseMemoryLibSse2/ScanMem32Wrapper.c b/MdePkg/Library/BaseMemoryLibSse2/ScanMem32Wrapper.c index 6b0beee632..b54d5da07c 100644 --- a/MdePkg/Library/BaseMemoryLibSse2/ScanMem32Wrapper.c +++ b/MdePkg/Library/BaseMemoryLibSse2/ScanMem32Wrapper.c @@ -19,7 +19,7 @@ BaseMemoryLibSse2 BaseMemoryLibRepStr PeiMemoryLib - UefiMemoryLib + DxeMemoryLib **/ @@ -35,6 +35,7 @@ then NULL is returned. If Length is 0, then NULL is returned. If Length > 0 and Buffer is NULL, then ASSERT(). If Buffer is not aligned on a 32-bit boundary, then ASSERT(). + If Length is not aligned on a 32-bit boundary, then ASSERT(). If Length is greater than (MAX_ADDRESS – Buffer + 1), then ASSERT(). @param Buffer Pointer to the target buffer to scan. @@ -52,16 +53,14 @@ ScanMem32 ( IN UINT32 Value ) { - UINTN Stride; - - Stride = Length / sizeof (Value); - if (Stride == 0) { + if (Length == 0) { return NULL; } ASSERT (Buffer != NULL); ASSERT (((UINTN)Buffer & (sizeof (Value) - 1)) == 0); ASSERT ((Length - 1) <= (MAX_ADDRESS - (UINTN)Buffer)); + ASSERT ((Length & (sizeof (Value) - 1)) == 0); - return (VOID*)InternalMemScanMem32 (Buffer, Stride, Value); + return (VOID*)InternalMemScanMem32 (Buffer, Length / sizeof (Value), Value); } diff --git a/MdePkg/Library/BaseMemoryLibSse2/ScanMem64Wrapper.c b/MdePkg/Library/BaseMemoryLibSse2/ScanMem64Wrapper.c index 589d45c1a1..7bfc7d721e 100644 --- a/MdePkg/Library/BaseMemoryLibSse2/ScanMem64Wrapper.c +++ b/MdePkg/Library/BaseMemoryLibSse2/ScanMem64Wrapper.c @@ -19,7 +19,7 @@ BaseMemoryLibSse2 BaseMemoryLibRepStr PeiMemoryLib - UefiMemoryLib + DxeMemoryLib **/ @@ -35,6 +35,7 @@ then NULL is returned. If Length is 0, then NULL is returned. If Length > 0 and Buffer is NULL, then ASSERT(). If Buffer is not aligned on a 64-bit boundary, then ASSERT(). + If Length is not aligned on a 64-bit boundary, then ASSERT(). If Length is greater than (MAX_ADDRESS – Buffer + 1), then ASSERT(). @param Buffer Pointer to the target buffer to scan. @@ -52,16 +53,14 @@ ScanMem64 ( IN UINT64 Value ) { - UINTN Stride; - - Stride = Length / sizeof (Value); - if (Stride == 0) { + if (Length == 0) { return NULL; } ASSERT (Buffer != NULL); ASSERT (((UINTN)Buffer & (sizeof (Value) - 1)) == 0); ASSERT ((Length - 1) <= (MAX_ADDRESS - (UINTN)Buffer)); + ASSERT ((Length & (sizeof (Value) - 1)) == 0); - return (VOID*)InternalMemScanMem64 (Buffer, Stride, Value); + return (VOID*)InternalMemScanMem64 (Buffer, Length / sizeof (Value), Value); } diff --git a/MdePkg/Library/BaseMemoryLibSse2/ScanMem8Wrapper.c b/MdePkg/Library/BaseMemoryLibSse2/ScanMem8Wrapper.c index 4dc8bac073..0f7289d3df 100644 --- a/MdePkg/Library/BaseMemoryLibSse2/ScanMem8Wrapper.c +++ b/MdePkg/Library/BaseMemoryLibSse2/ScanMem8Wrapper.c @@ -19,7 +19,7 @@ BaseMemoryLibSse2 BaseMemoryLibRepStr PeiMemoryLib - UefiMemoryLib + DxeMemoryLib **/ diff --git a/MdePkg/Library/BaseMemoryLibSse2/SetMem16Wrapper.c b/MdePkg/Library/BaseMemoryLibSse2/SetMem16Wrapper.c index 41467a9cb0..889339c953 100644 --- a/MdePkg/Library/BaseMemoryLibSse2/SetMem16Wrapper.c +++ b/MdePkg/Library/BaseMemoryLibSse2/SetMem16Wrapper.c @@ -19,7 +19,7 @@ BaseMemoryLibSse2 BaseMemoryLibRepStr PeiMemoryLib - UefiMemoryLib + DxeMemoryLib **/ diff --git a/MdePkg/Library/BaseMemoryLibSse2/SetMem32Wrapper.c b/MdePkg/Library/BaseMemoryLibSse2/SetMem32Wrapper.c index 425840682d..15f8205ebc 100644 --- a/MdePkg/Library/BaseMemoryLibSse2/SetMem32Wrapper.c +++ b/MdePkg/Library/BaseMemoryLibSse2/SetMem32Wrapper.c @@ -19,7 +19,7 @@ BaseMemoryLibSse2 BaseMemoryLibRepStr PeiMemoryLib - UefiMemoryLib + DxeMemoryLib **/ diff --git a/MdePkg/Library/BaseMemoryLibSse2/SetMem64Wrapper.c b/MdePkg/Library/BaseMemoryLibSse2/SetMem64Wrapper.c index 4a1eda80e8..981a7d4731 100644 --- a/MdePkg/Library/BaseMemoryLibSse2/SetMem64Wrapper.c +++ b/MdePkg/Library/BaseMemoryLibSse2/SetMem64Wrapper.c @@ -19,7 +19,7 @@ BaseMemoryLibSse2 BaseMemoryLibRepStr PeiMemoryLib - UefiMemoryLib + DxeMemoryLib **/ diff --git a/MdePkg/Library/BaseMemoryLibSse2/SetMemWrapper.c b/MdePkg/Library/BaseMemoryLibSse2/SetMemWrapper.c index 3965be759a..c73168841b 100644 --- a/MdePkg/Library/BaseMemoryLibSse2/SetMemWrapper.c +++ b/MdePkg/Library/BaseMemoryLibSse2/SetMemWrapper.c @@ -19,7 +19,7 @@ BaseMemoryLibSse2 BaseMemoryLibRepStr PeiMemoryLib - UefiMemoryLib + DxeMemoryLib **/ @@ -32,7 +32,7 @@ If Length is greater than (MAX_ADDRESS – Buffer + 1), then ASSERT(). @param Buffer Memory to set. - @param Length Number of bytes to set + @param Length Number of bytes to set. @param Value Value of the set operation. @return Buffer. diff --git a/MdePkg/Library/BaseMemoryLibSse2/ZeroMemWrapper.c b/MdePkg/Library/BaseMemoryLibSse2/ZeroMemWrapper.c index 56dbe5d8be..08247681c5 100644 --- a/MdePkg/Library/BaseMemoryLibSse2/ZeroMemWrapper.c +++ b/MdePkg/Library/BaseMemoryLibSse2/ZeroMemWrapper.c @@ -19,7 +19,7 @@ BaseMemoryLibSse2 BaseMemoryLibRepStr PeiMemoryLib - UefiMemoryLib + DxeMemoryLib **/ diff --git a/MdePkg/Library/BasePciCf8Lib/PciLib.c b/MdePkg/Library/BasePciCf8Lib/PciLib.c index 89cf0db2b7..a3897bfaa4 100644 --- a/MdePkg/Library/BasePciCf8Lib/PciLib.c +++ b/MdePkg/Library/BasePciCf8Lib/PciLib.c @@ -1277,8 +1277,7 @@ PciCf8BitFieldAndThenOr32( If StartAddress > 0x0FFFFFFF, then ASSERT(). If the register specified by StartAddress >= 0x100, then ASSERT(). If ((StartAddress & 0xFFF) + Size) > 0x100, then ASSERT(). - If (StartAddress + Size - 1) > 0x0FFFFFFF, then ASSERT(). - If Buffer is NULL, then ASSERT(). + If Size > 0 and Buffer is NULL, then ASSERT(). @param StartAddress Starting address that encodes the PCI Bus, Device, Function and Register. @@ -1300,11 +1299,11 @@ PciCf8ReadBuffer ( ASSERT_INVALID_PCI_ADDRESS (StartAddress, 0); ASSERT (((StartAddress & 0xFFF) + Size) <= 0x100); - ASSERT (Buffer != NULL); + ASSERT ((Buffer != NULL) || (Size == 0)); EndAddress = StartAddress + Size; - if (StartAddress < EndAddress && (StartAddress & 1)) { + if ((StartAddress < EndAddress) && ((StartAddress & 1) != 0)) { // // Read a byte if StartAddress is byte aligned // @@ -1313,7 +1312,7 @@ PciCf8ReadBuffer ( Buffer = (UINT8*)Buffer + 1; } - if (StartAddress < EndAddress && (StartAddress & 2)) { + if ((StartAddress < EndAddress) && ((StartAddress & 2) != 0)) { // // Read a word if StartAddress is word aligned // @@ -1322,7 +1321,7 @@ PciCf8ReadBuffer ( Buffer = (UINT16*)Buffer + 1; } - while (EndAddress - StartAddress >= 4) { + while ((EndAddress - StartAddress) >= 4) { // // Read as many double words as possible // @@ -1340,7 +1339,7 @@ PciCf8ReadBuffer ( Buffer = (UINT16*)Buffer + 1; } - if (EndAddress & 1) { + if ((EndAddress & 1) != 0) { // // Read the last remaining byte if exist // @@ -1365,8 +1364,7 @@ PciCf8ReadBuffer ( If StartAddress > 0x0FFFFFFF, then ASSERT(). If the register specified by StartAddress >= 0x100, then ASSERT(). If ((StartAddress & 0xFFF) + Size) > 0x100, then ASSERT(). - If (StartAddress + Size - 1) > 0x0FFFFFFF, then ASSERT(). - If Buffer is NULL, then ASSERT(). + If Size > 0 and Buffer is NULL, then ASSERT(). @param StartAddress Starting address that encodes the PCI Bus, Device, Function and Register. @@ -1388,7 +1386,7 @@ PciCf8WriteBuffer ( ASSERT_INVALID_PCI_ADDRESS (StartAddress, 0); ASSERT (((StartAddress & 0xFFF) + Size) <= 0x100); - ASSERT (Buffer != NULL); + ASSERT ((Buffer != NULL) || (Size == 0)); EndAddress = StartAddress + Size; @@ -1401,7 +1399,7 @@ PciCf8WriteBuffer ( Buffer = (UINT8*)Buffer + 1; } - if (StartAddress < EndAddress && (StartAddress & 2)) { + if ((StartAddress < EndAddress) && ((StartAddress & 2) != 0)) { // // Write a word if StartAddress is word aligned // @@ -1410,7 +1408,7 @@ PciCf8WriteBuffer ( Buffer = (UINT16*)Buffer + 1; } - while (EndAddress - StartAddress >= 4) { + while ((EndAddress - StartAddress) >= 4) { // // Write as many double words as possible // @@ -1419,7 +1417,7 @@ PciCf8WriteBuffer ( Buffer = (UINT32*)Buffer + 1; } - if (EndAddress & 2) { + if ((EndAddress & 2) != 0) { // // Write the last remaining word if exist // @@ -1428,7 +1426,7 @@ PciCf8WriteBuffer ( Buffer = (UINT16*)Buffer + 1; } - if (EndAddress & 1) { + if ((EndAddress & 1) != 0) { // // Write the last remaining byte if exist // diff --git a/MdePkg/Library/BasePciExpressLib/PciLib.c b/MdePkg/Library/BasePciExpressLib/PciLib.c index e027955ceb..036994aa7b 100644 --- a/MdePkg/Library/BasePciExpressLib/PciLib.c +++ b/MdePkg/Library/BasePciExpressLib/PciLib.c @@ -1174,8 +1174,7 @@ PciExpressBitFieldAndThenOr32 ( If StartAddress > 0x0FFFFFFF, then ASSERT(). If ((StartAddress & 0xFFF) + Size) > 0x1000, then ASSERT(). - If (StartAddress + Size - 1) > 0x0FFFFFFF, then ASSERT(). - If Buffer is NULL, then ASSERT(). + If Size > 0 and Buffer is NULL, then ASSERT(). @param StartAddress Starting address that encodes the PCI Bus, Device, Function and Register. @@ -1197,11 +1196,11 @@ PciExpressReadBuffer ( ASSERT_INVALID_PCI_ADDRESS (StartAddress); ASSERT (((StartAddress & 0xFFF) + Size) <= 0x1000); - ASSERT (Buffer != NULL); + ASSERT ((Buffer != NULL) || (Size == 0)); EndAddress = StartAddress + Size; - if (StartAddress < EndAddress && (StartAddress & 1)) { + if ((StartAddress < EndAddress) && ((StartAddress & 1) != 0)) { // // Read a byte if StartAddress is byte aligned // @@ -1210,7 +1209,7 @@ PciExpressReadBuffer ( Buffer = (UINT8*)Buffer + 1; } - if (StartAddress < EndAddress && (StartAddress & 2)) { + if ((StartAddress < EndAddress) && ((StartAddress & 2) != 0)) { // // Read a word if StartAddress is word aligned // @@ -1219,7 +1218,7 @@ PciExpressReadBuffer ( Buffer = (UINT16*)Buffer + 1; } - while (EndAddress - StartAddress >= 4) { + while ((EndAddress - StartAddress) >= 4) { // // Read as many double words as possible // @@ -1237,7 +1236,7 @@ PciExpressReadBuffer ( Buffer = (UINT16*)Buffer + 1; } - if (EndAddress & 1) { + if ((EndAddress & 1) != 0) { // // Read the last remaining byte if exist // @@ -1261,8 +1260,7 @@ PciExpressReadBuffer ( If StartAddress > 0x0FFFFFFF, then ASSERT(). If ((StartAddress & 0xFFF) + Size) > 0x1000, then ASSERT(). - If (StartAddress + Size - 1) > 0x0FFFFFFF, then ASSERT(). - If Buffer is NULL, then ASSERT(). + If Size > 0 and Buffer is NULL, then ASSERT(). @param StartAddress Starting address that encodes the PCI Bus, Device, Function and Register. @@ -1284,11 +1282,11 @@ PciExpressWriteBuffer ( ASSERT_INVALID_PCI_ADDRESS (StartAddress); ASSERT (((StartAddress & 0xFFF) + Size) <= 0x1000); - ASSERT (Buffer != NULL); + ASSERT ((Buffer != NULL) || (Size == 0)); EndAddress = StartAddress + Size; - if ((StartAddress < EndAddress) && ((StartAddress & 1)!= 0)) { + if ((StartAddress < EndAddress) && ((StartAddress & 1) != 0)) { // // Write a byte if StartAddress is byte aligned // @@ -1297,7 +1295,7 @@ PciExpressWriteBuffer ( Buffer = (UINT8*)Buffer + 1; } - if (StartAddress < EndAddress && (StartAddress & 2)) { + if ((StartAddress < EndAddress) && ((StartAddress & 2) != 0)) { // // Write a word if StartAddress is word aligned // @@ -1306,7 +1304,7 @@ PciExpressWriteBuffer ( Buffer = (UINT16*)Buffer + 1; } - while (EndAddress - StartAddress >= 4) { + while ((EndAddress - StartAddress) >= 4) { // // Write as many double words as possible // @@ -1315,7 +1313,7 @@ PciExpressWriteBuffer ( Buffer = (UINT32*)Buffer + 1; } - if (EndAddress & 2) { + if ((EndAddress & 2) != 0) { // // Write the last remaining word if exist // @@ -1324,7 +1322,7 @@ PciExpressWriteBuffer ( Buffer = (UINT16*)Buffer + 1; } - if (EndAddress & 1) { + if ((EndAddress & 1) != 0) { // // Write the last remaining byte if exist // diff --git a/MdePkg/Library/BasePciLibCf8/PciLib.c b/MdePkg/Library/BasePciLibCf8/PciLib.c index 5cfa952b12..7e21e23174 100644 --- a/MdePkg/Library/BasePciLibCf8/PciLib.c +++ b/MdePkg/Library/BasePciLibCf8/PciLib.c @@ -1011,8 +1011,7 @@ PciBitFieldAndThenOr32 ( If StartAddress > 0x0FFFFFFF, then ASSERT(). If ((StartAddress & 0xFFF) + Size) > 0x1000, then ASSERT(). - If (StartAddress + Size - 1) > 0x0FFFFFFF, then ASSERT(). - If Buffer is NULL, then ASSERT(). + If Size > 0 and Buffer is NULL, then ASSERT(). @param StartAddress Starting address that encodes the PCI Bus, Device, Function and Register. @@ -1047,8 +1046,7 @@ PciReadBuffer ( If StartAddress > 0x0FFFFFFF, then ASSERT(). If ((StartAddress & 0xFFF) + Size) > 0x1000, then ASSERT(). - If (StartAddress + Size - 1) > 0x0FFFFFFF, then ASSERT(). - If Buffer is NULL, then ASSERT(). + If Size > 0 and Buffer is NULL, then ASSERT(). @param StartAddress Starting address that encodes the PCI Bus, Device, Function and Register. diff --git a/MdePkg/Library/BasePciLibPciExpress/PciLib.c b/MdePkg/Library/BasePciLibPciExpress/PciLib.c index 7c60974955..1b543da3aa 100644 --- a/MdePkg/Library/BasePciLibPciExpress/PciLib.c +++ b/MdePkg/Library/BasePciLibPciExpress/PciLib.c @@ -1011,8 +1011,7 @@ PciBitFieldAndThenOr32 ( If StartAddress > 0x0FFFFFFF, then ASSERT(). If ((StartAddress & 0xFFF) + Size) > 0x1000, then ASSERT(). - If (StartAddress + Size - 1) > 0x0FFFFFFF, then ASSERT(). - If Buffer is NULL, then ASSERT(). + If Size > 0 and Buffer is NULL, then ASSERT(). @param StartAddress Starting address that encodes the PCI Bus, Device, Function and Register. @@ -1047,8 +1046,7 @@ PciReadBuffer ( If StartAddress > 0x0FFFFFFF, then ASSERT(). If ((StartAddress & 0xFFF) + Size) > 0x1000, then ASSERT(). - If (StartAddress + Size - 1) > 0x0FFFFFFF, then ASSERT(). - If Buffer is NULL, then ASSERT(). + If Size > 0 and Buffer is NULL, then ASSERT(). @param StartAddress Starting address that encodes the PCI Bus, Device, Function and Register. diff --git a/MdePkg/Library/BasePrintLib/PrintLib.c b/MdePkg/Library/BasePrintLib/PrintLib.c index 1484d891b6..d33f49d388 100644 --- a/MdePkg/Library/BasePrintLib/PrintLib.c +++ b/MdePkg/Library/BasePrintLib/PrintLib.c @@ -57,17 +57,17 @@ STATIC CONST CHAR8 *StatusString [] = { VSPrint function to process format and place the results in Buffer. Since a VA_LIST is used this rountine allows the nesting of Vararg routines. Thus - this is the main print working routine + this is the main print working routine. @param Buffer Character buffer to print the results of the parsing of Format into. @param BufferSize Maximum number of characters to put into buffer. @param Flags Intial flags value. - Can only have FORMAT_UNICODE and OUTPUT_UNICODE set + Can only have FORMAT_UNICODE and OUTPUT_UNICODE set. @param Format Null-terminated format string. @param Marker Vararg list consumed by processing Format. - @return Number of characters printed. + @return Number of characters printed not including the Null-terminator. **/ UINTN @@ -127,8 +127,8 @@ BasePrintLibVSPrint ( FormatMask = 0xffff; } else { // - // Make sure format string cannot contain more than PcdMaximumUnicodeStringLength - // Ascii characters if PcdMaximumUnicodeStringLength is not zero. + // Make sure format string cannot contain more than PcdMaximumAsciiStringLength + // Ascii characters if PcdMaximumAsciiStringLength is not zero. // ASSERT (AsciiStrSize (Format) != 0); BytesPerFormatCharacter = 1; @@ -506,7 +506,7 @@ BasePrintLibVSPrint ( // Output the Prefix character if it is present // Index = 0; - if (Prefix) { + if (Prefix != 0) { Index++; } @@ -557,18 +557,17 @@ BasePrintLibVSPrint ( // // Null terminate the Unicode or ASCII string // - Buffer = BasePrintLibFillBuffer (Buffer, 1, 0, BytesPerOutputCharacter); + BasePrintLibFillBuffer (Buffer, 1, 0, BytesPerOutputCharacter); // // Make sure output buffer cannot contain more than PcdMaximumUnicodeStringLength // Unicode characters if PcdMaximumUnicodeStringLength is not zero. // ASSERT ((((Flags & OUTPUT_UNICODE) == 0)) || (StrSize ((CHAR16 *) OriginalBuffer) != 0)); // - // Make sure output buffer cannot contain more than PcdMaximumUnicodeStringLength - // Ascii characters if PcdMaximumUnicodeStringLength is not zero. + // Make sure output buffer cannot contain more than PcdMaximumAsciiStringLength + // ASCII characters if PcdMaximumAsciiStringLength is not zero. // ASSERT ((((Flags & OUTPUT_UNICODE) != 0)) || (AsciiStrSize (OriginalBuffer) != 0)); - return ((Buffer - OriginalBuffer) / BytesPerOutputCharacter); } @@ -579,7 +578,7 @@ BasePrintLibVSPrint ( VSPrint function to process format and place the results in Buffer. Since a VA_LIST is used this rountine allows the nesting of Vararg routines. Thus - this is the main print working routine + this is the main print working routine. @param Buffer Character buffer to print the results of the parsing of Format into. @@ -589,7 +588,7 @@ BasePrintLibVSPrint ( Can only have FORMAT_UNICODE and OUTPUT_UNICODE set @param FormatString Null-terminated format string. - @return Number of characters printed. + @return Number of characters printed not including the Null-terminator. **/ UINTN @@ -616,23 +615,27 @@ BasePrintLibSPrint ( The Unicode string is produced by parsing the format string specified by FormatString. Arguments are pulled from the variable argument list specified by Marker based on the contents of the format string. - The length of the produced output buffer is returned. - If BufferSize is 0, then no output buffer is produced and 0 is returned. + The number of Unicode characters in the produced output buffer is returned not including + the Null-terminator. + If BufferSize is 0 or 1, then no output buffer is produced and 0 is returned. - If BufferSize is not 0 and StartOfBuffer is NULL, then ASSERT(). - If BufferSize is not 0 and FormatString is NULL, then ASSERT(). + If BufferSize > 1 and StartOfBuffer is NULL, then ASSERT(). + If BufferSize > 1 and FormatString is NULL, then ASSERT(). If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than - PcdMaximumUnicodeStringLength Unicode characters, then ASSERT(). + PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator, then + ASSERT(). If PcdMaximumUnicodeStringLength is not zero, and produced Null-terminated Unicode string - contains more than PcdMaximumUnicodeStringLength Unicode characters, then ASSERT(). + contains more than PcdMaximumUnicodeStringLength Unicode characters not including the + Null-terminator, then ASSERT(). - @param StartOfBuffer APointer to the output buffer for the produced Null-terminated + @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated Unicode string. @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer. @param FormatString Null-terminated Unicode format string. @param Marker VA_LIST marker for the variable argument list. - @return return Length of the produced output buffer. + @return The number of Unicode characters in the produced output buffer not including the + Null-terminator. **/ UINTN @@ -655,22 +658,26 @@ UnicodeVSPrint ( and BufferSize. The Unicode string is produced by parsing the format string specified by FormatString. Arguments are pulled from the variable argument list based on the contents of the format string. - The length of the produced output buffer is returned. - If BufferSize is 0, then no output buffer is produced and 0 is returned. + The number of Unicode characters in the produced output buffer is returned not including + the Null-terminator. + If BufferSize is 0 or 1, then no output buffer is produced and 0 is returned. - If BufferSize is not 0 and StartOfBuffer is NULL, then ASSERT(). - If BufferSize is not 0 and FormatString is NULL, then ASSERT(). + If BufferSize > 1 and StartOfBuffer is NULL, then ASSERT(). + If BufferSize > 1 and FormatString is NULL, then ASSERT(). If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than - PcdMaximumUnicodeStringLength Unicode characters, then ASSERT(). + PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator, then + ASSERT(). If PcdMaximumUnicodeStringLength is not zero, and produced Null-terminated Unicode string - contains more than PcdMaximumUnicodeStringLength Unicode characters, then ASSERT(). + contains more than PcdMaximumUnicodeStringLength Unicode characters not including the + Null-terminator, then ASSERT(). - @param StartOfBuffer APointer to the output buffer for the produced Null-terminated + @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated Unicode string. @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer. @param FormatString Null-terminated Unicode format string. - @return Length of the produced output buffer. + @return The number of Unicode characters in the produced output buffer not including the + Null-terminator. **/ UINTN @@ -697,23 +704,27 @@ UnicodeSPrint ( The Unicode string is produced by parsing the format string specified by FormatString. Arguments are pulled from the variable argument list specified by Marker based on the contents of the format string. - The length of the produced output buffer is returned. - If BufferSize is 0, then no output buffer is produced and 0 is returned. - - If BufferSize is not 0 and StartOfBuffer is NULL, then ASSERT(). - If BufferSize is not 0 and FormatString is NULL, then ASSERT(). - If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than - PcdMaximumUnicodeStringLength Unicode characters, then ASSERT(). + The number of Unicode characters in the produced output buffer is returned not including + the Null-terminator. + If BufferSize is 0 or 1, then no output buffer is produced and 0 is returned. + + If BufferSize > 1 and StartOfBuffer is NULL, then ASSERT(). + If BufferSize > 1 and FormatString is NULL, then ASSERT(). + If PcdMaximumAsciiStringLength is not zero, and FormatString contains more than + PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator, then + ASSERT(). If PcdMaximumUnicodeStringLength is not zero, and produced Null-terminated Unicode string - contains more than PcdMaximumUnicodeStringLength Unicode characters, then ASSERT(). + contains more than PcdMaximumUnicodeStringLength Unicode characters not including the + Null-terminator, then ASSERT(). - @param StartOfBuffer APointer to the output buffer for the produced Null-terminated + @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated Unicode string. @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer. @param FormatString Null-terminated Unicode format string. @param Marker VA_LIST marker for the variable argument list. - @return Length of the produced output buffer. + @return The number of Unicode characters in the produced output buffer not including the + Null-terminator. **/ UINTN @@ -737,22 +748,26 @@ UnicodeVSPrintAsciiFormat ( The Unicode string is produced by parsing the format string specified by FormatString. Arguments are pulled from the variable argument list based on the contents of the format string. - The length of the produced output buffer is returned. - If BufferSize is 0, then no output buffer is produced and 0 is returned. - - If BufferSize is not 0 and StartOfBuffer is NULL, then ASSERT(). - If BufferSize is not 0 and FormatString is NULL, then ASSERT(). - If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than - PcdMaximumUnicodeStringLength Unicode characters, then ASSERT(). + The number of Unicode characters in the produced output buffer is returned not including + the Null-terminator. + If BufferSize is 0 or 1, then no output buffer is produced and 0 is returned. + + If BufferSize > 1 and StartOfBuffer is NULL, then ASSERT(). + If BufferSize > 1 and FormatString is NULL, then ASSERT(). + If PcdMaximumAsciiStringLength is not zero, and FormatString contains more than + PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator, then + ASSERT(). If PcdMaximumUnicodeStringLength is not zero, and produced Null-terminated Unicode string - contains more than PcdMaximumUnicodeStringLength Unicode characters, then ASSERT(). + contains more than PcdMaximumUnicodeStringLength Unicode characters not including the + Null-terminator, then ASSERT(). - @param StartOfBuffer APointer to the output buffer for the produced Null-terminated + @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated Unicode string. @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer. @param FormatString Null-terminated Unicode format string. - @return Length of the produced output buffer. + @return The number of Unicode characters in the produced output buffer not including the + Null-terminator. **/ UINTN @@ -779,23 +794,27 @@ UnicodeSPrintAsciiFormat ( The ASCII string is produced by parsing the format string specified by FormatString. Arguments are pulled from the variable argument list specified by Marker based on the contents of the format string. - The length of the produced output buffer is returned. + The number of ASCII characters in the produced output buffer is returned not including + the Null-terminator. If BufferSize is 0, then no output buffer is produced and 0 is returned. - If BufferSize is not 0 and StartOfBuffer is NULL, then ASSERT(). - If BufferSize is not 0 and FormatString is NULL, then ASSERT(). - If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than - PcdMaximumUnicodeStringLength ASCII characters, then ASSERT(). - If PcdMaximumUnicodeStringLength is not zero, and produced Null-terminated Unicode string - contains more than PcdMaximumUnicodeStringLength ASCII characters, then ASSERT(). + If BufferSize > 0 and StartOfBuffer is NULL, then ASSERT(). + If BufferSize > 0 and FormatString is NULL, then ASSERT(). + If PcdMaximumAsciiStringLength is not zero, and FormatString contains more than + PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator, then + ASSERT(). + If PcdMaximumAsciiStringLength is not zero, and produced Null-terminated ASCII string + contains more than PcdMaximumAsciiStringLength ASCII characters not including the + Null-terminator, then ASSERT(). - @param StartOfBuffer APointer to the output buffer for the produced Null-terminated + @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated ASCII string. @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer. @param FormatString Null-terminated Unicode format string. @param Marker VA_LIST marker for the variable argument list. - @return Length of the produced output buffer. + @return The number of ASCII characters in the produced output buffer not including the + Null-terminator. **/ UINTN @@ -819,22 +838,26 @@ AsciiVSPrint ( The ASCII string is produced by parsing the format string specified by FormatString. Arguments are pulled from the variable argument list based on the contents of the format string. - The length of the produced output buffer is returned. + The number of ASCII characters in the produced output buffer is returned not including + the Null-terminator. If BufferSize is 0, then no output buffer is produced and 0 is returned. - If BufferSize is not 0 and StartOfBuffer is NULL, then ASSERT(). - If BufferSize is not 0 and FormatString is NULL, then ASSERT(). - If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than - PcdMaximumUnicodeStringLength ASCII characters, then ASSERT(). - If PcdMaximumUnicodeStringLength is not zero, and produced Null-terminated Unicode string - contains more than PcdMaximumUnicodeStringLength ASCII characters, then ASSERT(). + If BufferSize > 0 and StartOfBuffer is NULL, then ASSERT(). + If BufferSize > 0 and FormatString is NULL, then ASSERT(). + If PcdMaximumAsciiStringLength is not zero, and FormatString contains more than + PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator, then + ASSERT(). + If PcdMaximumAsciiStringLength is not zero, and produced Null-terminated ASCII string + contains more than PcdMaximumAsciiStringLength ASCII characters not including the + Null-terminator, then ASSERT(). - @param StartOfBuffer APointer to the output buffer for the produced Null-terminated + @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated ASCII string. @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer. @param FormatString Null-terminated Unicode format string. - @return Length of the produced output buffer. + @return The number of ASCII characters in the produced output buffer not including the + Null-terminator. **/ UINTN @@ -861,23 +884,27 @@ AsciiSPrint ( The ASCII string is produced by parsing the format string specified by FormatString. Arguments are pulled from the variable argument list specified by Marker based on the contents of the format string. - The length of the produced output buffer is returned. + The number of ASCII characters in the produced output buffer is returned not including + the Null-terminator. If BufferSize is 0, then no output buffer is produced and 0 is returned. - If BufferSize is not 0 and StartOfBuffer is NULL, then ASSERT(). - If BufferSize is not 0 and FormatString is NULL, then ASSERT(). - If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than - PcdMaximumUnicodeStringLength ASCII characters, then ASSERT(). - If PcdMaximumUnicodeStringLength is not zero, and produced Null-terminated Unicode string - contains more than PcdMaximumUnicodeStringLength ASCII characters, then ASSERT(). + If BufferSize > 0 and StartOfBuffer is NULL, then ASSERT(). + If BufferSize > 0 and FormatString is NULL, then ASSERT(). + If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than + PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator, then + ASSERT(). + If PcdMaximumAsciiStringLength is not zero, and produced Null-terminated ASCII string + contains more than PcdMaximumAsciiStringLength ASCII characters not including the + Null-terminator, then ASSERT(). - @param StartOfBuffer APointer to the output buffer for the produced Null-terminated + @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated ASCII string. @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer. @param FormatString Null-terminated Unicode format string. @param Marker VA_LIST marker for the variable argument list. - @return Length of the produced output buffer. + @return The number of ASCII characters in the produced output buffer not including the + Null-terminator. **/ UINTN @@ -901,22 +928,26 @@ AsciiVSPrintUnicodeFormat ( The ASCII string is produced by parsing the format string specified by FormatString. Arguments are pulled from the variable argument list based on the contents of the format string. - The length of the produced output buffer is returned. + The number of ASCII characters in the produced output buffer is returned not including + the Null-terminator. If BufferSize is 0, then no output buffer is produced and 0 is returned. - If BufferSize is not 0 and StartOfBuffer is NULL, then ASSERT(). - If BufferSize is not 0 and FormatString is NULL, then ASSERT(). - If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than - PcdMaximumUnicodeStringLength ASCII characters, then ASSERT(). - If PcdMaximumUnicodeStringLength is not zero, and produced Null-terminated Unicode string - contains more than PcdMaximumUnicodeStringLength ASCII characters, then ASSERT(). + If BufferSize > 0 and StartOfBuffer is NULL, then ASSERT(). + If BufferSize > 0 and FormatString is NULL, then ASSERT(). + If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than + PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator, then + ASSERT(). + If PcdMaximumAsciiStringLength is not zero, and produced Null-terminated ASCII string + contains more than PcdMaximumAsciiStringLength ASCII characters not including the + Null-terminator, then ASSERT(). - @param StartOfBuffer APointer to the output buffer for the produced Null-terminated + @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated ASCII string. @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer. @param FormatString Null-terminated Unicode format string. - @return Length of the produced output buffer. + @return The number of ASCII characters in the produced output buffer not including the + Null-terminator. **/ UINTN @@ -940,7 +971,7 @@ AsciiSPrintUnicodeFormat ( Converts the decimal number specified by Value to a Null-terminated Unicode string specified by Buffer containing at most Width characters. If Width is 0 then a width of MAXIMUM_VALUE_CHARACTERS is assumed. - The total number of characters placed in Buffer is returned. + The number of Unicode characters in Buffer is returned not including the Null-terminator. If the conversion contains more than Width characters, then only the first Width characters are returned, and the total number of characters required to perform the conversion is returned. @@ -964,9 +995,9 @@ AsciiSPrintUnicodeFormat ( Unicode string. @param Flags The bitmask of flags that specify left justification, zero pad, and commas. @param Value The 64-bit signed value to convert to a string. - @param Width The maximum number of Unicode characters to place in Buffer. + @param Width The maximum number of Unicode characters to place in Buffer. - @return Total number of characters required to perform the conversion. + @return The number of Unicode characters in Buffer not including the Null-terminator. **/ UINTN @@ -987,7 +1018,7 @@ UnicodeValueToString ( Converts the decimal number specified by Value to a Null-terminated ASCII string specified by Buffer containing at most Width characters. If Width is 0 then a width of MAXIMUM_VALUE_CHARACTERS is assumed. - The total number of characters placed in Buffer is returned. + The number of ASCII characters in Buffer is returned not including the Null-terminator. If the conversion contains more than Width characters, then only the first Width characters are returned, and the total number of characters required to perform the conversion is returned. @@ -1011,9 +1042,9 @@ UnicodeValueToString ( ASCII string. @param Flags The bitmask of flags that specify left justification, zero pad, and commas. @param Value The 64-bit signed value to convert to a string. - @param Width The maximum number of ASCII characters to place in Buffer. + @param Width The maximum number of ASCII characters to place in Buffer. - @return Total number of characters required to perform the conversion. + @return The number of ASCII characters in Buffer not including the Null-terminator. **/ UINTN diff --git a/MdePkg/Library/BasePrintLib/PrintLibInternal.c b/MdePkg/Library/BasePrintLib/PrintLibInternal.c index 30b4539141..8f417fbf11 100644 --- a/MdePkg/Library/BasePrintLib/PrintLibInternal.c +++ b/MdePkg/Library/BasePrintLib/PrintLibInternal.c @@ -92,7 +92,7 @@ BasePrintLibValueToString ( Converts the decimal number specified by Value to a Null-terminated string specified by Buffer containing at most Width characters. If Width is 0 then a width of MAXIMUM_VALUE_CHARACTERS is assumed. - The total number of characters placed in Buffer is returned. + The number of characters in Buffer is returned not including the Null-terminator. If the conversion contains more than Width characters, then only the first Width characters are returned, and the total number of characters required to perform the conversion is returned. @@ -120,7 +120,7 @@ BasePrintLibValueToString ( @param Width The maximum number of characters to place in Buffer. @param Increment Character increment in Buffer. - @return Total number of characters required to perform the conversion. + @return The number of characters in Buffer not including the Null-terminator. **/ UINTN @@ -184,7 +184,7 @@ BasePrintLibConvertValueToString ( } } - Buffer = BasePrintLibFillBuffer (Buffer, 1, 0, Increment); + BasePrintLibFillBuffer (Buffer, 1, 0, Increment); return ((Buffer - OriginalBuffer) / Increment); } diff --git a/MdePkg/Library/BasePrintLib/PrintLibInternal.h b/MdePkg/Library/BasePrintLib/PrintLibInternal.h index 5e650b0123..b7c95a8e43 100644 --- a/MdePkg/Library/BasePrintLib/PrintLibInternal.h +++ b/MdePkg/Library/BasePrintLib/PrintLibInternal.h @@ -14,6 +14,9 @@ **/ +#ifndef __PRINT_LIB_INTERNAL_H +#define __PRINT_LIB_INTERNAL_H + // // Print primitives // @@ -148,7 +151,7 @@ BasePrintLibValueToString ( @param Flags The bitmask of flags that specify left justification, zero pad, and commas. @param Value The 64-bit signed value to convert to a string. - @param Width The maximum number of characters to place in Buffer. + @param Width The maximum number of characters to place in Buffer. @param Increment Character increment in Buffer. @return Total number of characters required to perform the conversion. @@ -162,3 +165,5 @@ BasePrintLibConvertValueToString ( IN UINTN Width, IN UINTN Increment ); + +#endif diff --git a/MdePkg/Library/DxeMemoryLib/CompareMemWrapper.c b/MdePkg/Library/DxeMemoryLib/CompareMemWrapper.c new file mode 100644 index 0000000000..4c0d3eaadb --- /dev/null +++ b/MdePkg/Library/DxeMemoryLib/CompareMemWrapper.c @@ -0,0 +1,67 @@ +/** @file + CompareMem() implementation. + + Copyright (c) 2006, Intel Corporation
+ All rights reserved. This program and the accompanying materials + 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 + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + Module Name: CompareMemWrapper.c + + The following BaseMemoryLib instances share the same version of this file: + + BaseMemoryLib + BaseMemoryLibMmx + BaseMemoryLibSse2 + BaseMemoryLibRepStr + PeiMemoryLib + DxeMemoryLib + +**/ + +#include "MemLibInternals.h" + +/** + Compares the contents of two buffers. + + This function compares Length bytes of SourceBuffer to Length bytes of DestinationBuffer. + If all Length bytes of the two buffers are identical, then 0 is returned. Otherwise, the + value returned is the first mismatched byte in SourceBuffer subtracted from the first + mismatched byte in DestinationBuffer. + If Length > 0 and DestinationBuffer is NULL and Length > 0, then ASSERT(). + If Length > 0 and SourceBuffer is NULL and Length > 0, then ASSERT(). + If Length is greater than (MAX_ADDRESS - DestinationBuffer + 1), then ASSERT(). + If Length is greater than (MAX_ADDRESS - SourceBuffer + 1), then ASSERT(). + + + @param DestinationBuffer Pointer to the destination buffer to compare. + @param SourceBuffer Pointer to the source buffer to compare. + @param Length Number of bytes to compare. + + @return 0 All Length bytes of the two buffers are identical. + @retval Non-zero The first mismatched byte in SourceBuffer subtracted from the first + mismatched byte in DestinationBuffer. + +**/ +INTN +EFIAPI +CompareMem ( + IN CONST VOID *DestinationBuffer, + IN CONST VOID *SourceBuffer, + IN UINTN Length + ) +{ + if (Length == 0) { + return 0; + } + ASSERT (DestinationBuffer != NULL); + ASSERT (SourceBuffer != NULL); + ASSERT ((Length - 1) <= (MAX_ADDRESS - (UINTN)DestinationBuffer)); + ASSERT ((Length - 1) <= (MAX_ADDRESS - (UINTN)SourceBuffer)); + + return InternalMemCompareMem (DestinationBuffer, SourceBuffer, Length); +} diff --git a/MdePkg/Library/DxeMemoryLib/CopyMemWrapper.c b/MdePkg/Library/DxeMemoryLib/CopyMemWrapper.c new file mode 100644 index 0000000000..9e620e2200 --- /dev/null +++ b/MdePkg/Library/DxeMemoryLib/CopyMemWrapper.c @@ -0,0 +1,62 @@ +/** @file + CopyMem() implementation. + + Copyright (c) 2006, Intel Corporation
+ All rights reserved. This program and the accompanying materials + 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 + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + Module Name: CopyMemWrapper.c + + The following BaseMemoryLib instances share the same version of this file: + + BaseMemoryLib + BaseMemoryLibMmx + BaseMemoryLibSse2 + BaseMemoryLibRepStr + PeiMemoryLib + DxeMemoryLib + +**/ + +#include "MemLibInternals.h" + +/** + Copies a source buffer to a destination buffer, and returns the destination buffer. + + This function copies Length bytes from SourceBuffer to DestinationBuffer, and returns + DestinationBuffer. The implementation must be reentrant, and it must handle the case + where SourceBuffer overlaps DestinationBuffer. + If Length is greater than (MAX_ADDRESS - DestinationBuffer + 1), then ASSERT(). + If Length is greater than (MAX_ADDRESS - SourceBuffer + 1), then ASSERT(). + + @param DestinationBuffer Pointer to the destination buffer of the memory copy. + @param SourceBuffer Pointer to the source buffer of the memory copy. + @param Length Number of bytes to copy from SourceBuffer to DestinationBuffer. + + @return DestinationBuffer. + +**/ +VOID * +EFIAPI +CopyMem ( + OUT VOID *DestinationBuffer, + IN CONST VOID *SourceBuffer, + IN UINTN Length + ) +{ + if (Length == 0) { + return DestinationBuffer; + } + ASSERT ((Length - 1) <= (MAX_ADDRESS - (UINTN)DestinationBuffer)); + ASSERT ((Length - 1) <= (MAX_ADDRESS - (UINTN)SourceBuffer)); + + if (DestinationBuffer == SourceBuffer) { + return DestinationBuffer; + } + return InternalMemCopyMem (DestinationBuffer, SourceBuffer, Length); +} diff --git a/MdePkg/Library/DxeMemoryLib/DxeMemoryLib.mbd b/MdePkg/Library/DxeMemoryLib/DxeMemoryLib.mbd new file mode 100644 index 0000000000..0bf1b7ef2e --- /dev/null +++ b/MdePkg/Library/DxeMemoryLib/DxeMemoryLib.mbd @@ -0,0 +1,29 @@ + + + + + DxeMemoryLib + f1bbe03d-2f28-4dee-bec7-d98d7a30c36a + EDK_RELEASE_VERSION 0x00090000 + FIX ME! + Copyright (c) 2004-2006, Intel Corporation + + All rights reserved. This program and the accompanying materials + 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 + http://opensource.org/licenses/bsd-license.php + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + 2006-04-12 13:39 + + diff --git a/MdePkg/Library/DxeMemoryLib/DxeMemoryLib.msa b/MdePkg/Library/DxeMemoryLib/DxeMemoryLib.msa new file mode 100644 index 0000000000..254ca0d407 --- /dev/null +++ b/MdePkg/Library/DxeMemoryLib/DxeMemoryLib.msa @@ -0,0 +1,61 @@ + + + + DxeMemoryLib + UEFI_DRIVER + f1bbe03d-2f28-4dee-bec7-d98d7a30c36a + 1.0 + Memory-only library functions with no library constructor/destructor + FIX ME! + Copyright (c) 2004-2006, Intel Corporation + All rights reserved. This program and the accompanying materials + 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 + http://opensource.org/licenses/bsd-license.php + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + FRAMEWORK_BUILD_PACKAGING_SPECIFICATION 0x00000052 + + + IA32 X64 IPF EBC + false + DxeMemoryLib + + + + BaseMemoryLib + + + DebugLib + + + UefiBootServicesTableLib + + + BaseLib + + + + MemLib.c + MemLibGuid.c + MemLibGeneric.c + CopyMemWrapper.c + SetMemWrapper.c + SetMem16Wrapper.c + SetMem32Wrapper.c + SetMem64Wrapper.c + CompareMemWrapper.c + ZeroMemWrapper.c + ScanMem8Wrapper.c + ScanMem16Wrapper.c + ScanMem32Wrapper.c + ScanMem64Wrapper.c + + + + + + EFI_SPECIFICATION_VERSION 0x00020000 + EDK_RELEASE_VERSION 0x00090000 + + \ No newline at end of file diff --git a/MdePkg/Library/DxeMemoryLib/MemLib.c b/MdePkg/Library/DxeMemoryLib/MemLib.c new file mode 100644 index 0000000000..f8f8e30d0a --- /dev/null +++ b/MdePkg/Library/DxeMemoryLib/MemLib.c @@ -0,0 +1,39 @@ +/** @file + Base Memory Library. + + Copyright (c) 2006, Intel Corporation
+ All rights reserved. This program and the accompanying materials + 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 + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + Module Name: MemLib.c + +**/ + +VOID * +EFIAPI +InternalMemCopyMem ( + OUT VOID *Destination, + IN CONST VOID *Source, + IN UINTN Length + ) +{ + gBS->CopyMem (Destination, (VOID*)Source, Length); + return Destination; +} + +VOID * +EFIAPI +InternalMemSetMem ( + OUT VOID *Buffer, + IN UINTN Size, + IN UINT8 Value + ) +{ + gBS->SetMem (Buffer, Size, Value); + return Buffer; +} diff --git a/MdePkg/Library/DxeMemoryLib/MemLibGeneric.c b/MdePkg/Library/DxeMemoryLib/MemLibGeneric.c new file mode 100644 index 0000000000..759377483c --- /dev/null +++ b/MdePkg/Library/DxeMemoryLib/MemLibGeneric.c @@ -0,0 +1,261 @@ +/** @file + Architecture Independent Base Memory Library Implementation. + + Copyright (c) 2006, Intel Corporation
+ All rights reserved. This program and the accompanying materials + 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 + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + Module Name: MemLibGeneric.c + + The following BaseMemoryLib instances share the same version of this file: + + BaseMemoryLib + PeiMemoryLib + DxeMemoryLib + +**/ + +#include "MemLibInternals.h" + +/** + Fills a target buffer with a 16-bit value, and returns the target buffer. + + @param Buffer Pointer to the target buffer to fill. + @param Length Number of bytes in Buffer to fill. + @param Value Value with which to fill Length bytes of Buffer. + + @return Buffer + +**/ +VOID * +EFIAPI +InternalMemSetMem16 ( + OUT VOID *Buffer, + IN UINTN Length, + IN UINT16 Value + ) +{ + do { + ((UINT16*)Buffer)[--Length] = Value; + } while (Length != 0); + return Buffer; +} + +/** + Fills a target buffer with a 32-bit value, and returns the target buffer. + + @param Buffer Pointer to the target buffer to fill. + @param Length Number of bytes in Buffer to fill. + @param Value Value with which to fill Length bytes of Buffer. + + @return Buffer + +**/ +VOID * +EFIAPI +InternalMemSetMem32 ( + OUT VOID *Buffer, + IN UINTN Length, + IN UINT32 Value + ) +{ + do { + ((UINT32*)Buffer)[--Length] = Value; + } while (Length != 0); + return Buffer; +} + +/** + Fills a target buffer with a 64-bit value, and returns the target buffer. + + @param Buffer Pointer to the target buffer to fill. + @param Length Number of bytes in Buffer to fill. + @param Value Value with which to fill Length bytes of Buffer. + + @return Buffer + +**/ +VOID * +EFIAPI +InternalMemSetMem64 ( + OUT VOID *Buffer, + IN UINTN Length, + IN UINT64 Value + ) +{ + do { + ((UINT64*)Buffer)[--Length] = Value; + } while (Length != 0); + return Buffer; +} + +/** + Set Buffer to 0 for Size bytes. + + @param Buffer Memory to set. + @param Size Number of bytes to set + + @return Buffer + +**/ +VOID * +EFIAPI +InternalMemZeroMem ( + OUT VOID *Buffer, + IN UINTN Length + ) +{ + return InternalMemSetMem (Buffer, Length, 0); +} + +/** + Compares two memory buffers of a given length. + + @param DestinationBuffer First memory buffer + @param SourceBuffer Second memory buffer + @param Length Length of DestinationBuffer and SourceBuffer memory + regions to compare. Must be non-zero. + + @retval 0 if MemOne == MemTwo + +**/ +INTN +EFIAPI +InternalMemCompareMem ( + IN CONST VOID *DestinationBuffer, + IN CONST VOID *SourceBuffer, + IN UINTN Length + ) +{ + while ((--Length != 0) && + (*(INT8*)DestinationBuffer == *(INT8*)SourceBuffer)) { + DestinationBuffer = (INT8*)DestinationBuffer + 1; + SourceBuffer = (INT8*)SourceBuffer + 1; + } + return (INTN)*(UINT8*)DestinationBuffer - (INTN)*(UINT8*)SourceBuffer; +} + +/** + Scans a target buffer for an 8-bit value, and returns a pointer to the + matching 8-bit value in the target buffer. + + @param Buffer Pointer to the target buffer to scan. + @param Length Number of bytes in Buffer to scan. Must be non-zero. + @param Value Value to search for in the target buffer. + + @return Pointer to the first occurrence or NULL if not found. + +**/ +CONST VOID * +EFIAPI +InternalMemScanMem8 ( + IN CONST VOID *Buffer, + IN UINTN Length, + IN UINT8 Value + ) +{ + CONST UINT8 *Pointer; + + Pointer = (CONST UINT8*)Buffer; + do { + if (*(Pointer++) == Value) { + return Pointer; + } + } while (--Length != 0); + return NULL; +} + +/** + Scans a target buffer for a 16-bit value, and returns a pointer to the + matching 16-bit value in the target buffer. + + @param Buffer Pointer to the target buffer to scan. + @param Length Number of bytes in Buffer to scan. Must be non-zero. + @param Value Value to search for in the target buffer. + + @return Pointer to the first occurrence or NULL if not found. + +**/ +CONST VOID * +EFIAPI +InternalMemScanMem16 ( + IN CONST VOID *Buffer, + IN UINTN Length, + IN UINT16 Value + ) +{ + CONST UINT16 *Pointer; + + Pointer = (CONST UINT16*)Buffer; + do { + if (*(Pointer++) == Value) { + return Pointer; + } + } while (--Length != 0); + return NULL; +} + +/** + Scans a target buffer for a 32-bit value, and returns a pointer to the + matching 32-bit value in the target buffer. + + @param Buffer Pointer to the target buffer to scan. + @param Length Number of bytes in Buffer to scan. Must be non-zero. + @param Value Value to search for in the target buffer. + + @return Pointer to the first occurrence or NULL if not found. + +**/ +CONST VOID * +EFIAPI +InternalMemScanMem32 ( + IN CONST VOID *Buffer, + IN UINTN Length, + IN UINT32 Value + ) +{ + CONST UINT32 *Pointer; + + Pointer = (CONST UINT32*)Buffer; + do { + if (*(Pointer++) == Value) { + return Pointer; + } + } while (--Length != 0); + return NULL; +} + +/** + Scans a target buffer for a 64-bit value, and returns a pointer to the + matching 64-bit value in the target buffer. + + @param Buffer Pointer to the target buffer to scan. + @param Length Number of bytes in Buffer to scan. Must be non-zero. + @param Value Value to search for in the target buffer. + + @return Pointer to the first occurrence or NULL if not found. + +**/ +CONST VOID * +EFIAPI +InternalMemScanMem64 ( + IN CONST VOID *Buffer, + IN UINTN Length, + IN UINT64 Value + ) +{ + CONST UINT64 *Pointer; + + Pointer = (CONST UINT64*)Buffer; + do { + if (*(Pointer++) == Value) { + return Pointer; + } + } while (--Length != 0); + return NULL; +} diff --git a/MdePkg/Library/DxeMemoryLib/MemLibGuid.c b/MdePkg/Library/DxeMemoryLib/MemLibGuid.c new file mode 100644 index 0000000000..8932af7083 --- /dev/null +++ b/MdePkg/Library/DxeMemoryLib/MemLibGuid.c @@ -0,0 +1,132 @@ +/** @file + Implementation of GUID functions. + + Copyright (c) 2006, Intel Corporation
+ All rights reserved. This program and the accompanying materials + 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 + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + Module Name: MemLibGuid.c + + The following BaseMemoryLib instances share the same version of this file: + + BaseMemoryLib + BaseMemoryLibMmx + BaseMemoryLibSse2 + BaseMemoryLibRepStr + PeiMemoryLib + DxeMemoryLib + +**/ + +/** + Copies a source GUID to a destination GUID. + + This function copies the contents of the 128-bit GUID specified by SourceGuid to + DestinationGuid, and returns DestinationGuid. + If DestinationGuid is NULL, then ASSERT(). + If SourceGuid is NULL, then ASSERT(). + + @param DestinationGuid Pointer to the destination GUID. + @param SourceGuid Pointer to the source GUID. + + @return DestinationGuid. + +**/ +GUID * +EFIAPI +CopyGuid ( + OUT GUID *DestinationGuid, + IN CONST GUID *SourceGuid + ) +{ + WriteUnaligned64 ( + (UINT64*)DestinationGuid, + ReadUnaligned64 ((CONST UINT64*)SourceGuid) + ); + WriteUnaligned64 ( + (UINT64*)DestinationGuid + 1, + ReadUnaligned64 ((CONST UINT64*)SourceGuid + 1) + ); + return DestinationGuid; +} + +/** + Compares two GUIDs. + + This function compares Guid1 to Guid2. If the GUIDs are identical then TRUE is returned. + If there are any bit differences in the two GUIDs, then FALSE is returned. + If Guid1 is NULL, then ASSERT(). + If Guid2 is NULL, then ASSERT(). + + @param Guid1 A pointer to a 128 bit GUID. + @param Guid2 A pointer to a 128 bit GUID. + + @retval TRUE Guid1 and Guid2 are identical. + @retval FALSE Guid1 and Guid2 are not identical. + +**/ +BOOLEAN +EFIAPI +CompareGuid ( + IN CONST GUID *Guid1, + IN CONST GUID *Guid2 + ) +{ + return (BOOLEAN)( + ReadUnaligned64 ((CONST UINT64*)Guid1) + == ReadUnaligned64 ((CONST UINT64*)Guid2) && + ReadUnaligned64 ((CONST UINT64*)Guid1 + 1) + == ReadUnaligned64 ((CONST UINT64*)Guid2 + 1) + ); +} + +/** + Scans a target buffer for a GUID, and returns a pointer to the matching GUID + in the target buffer. + + This function searches target the buffer specified by Buffer and Length from + the lowest address to the highest address at 128-bit increments for the 128-bit + GUID value that matches Guid. If a match is found, then a pointer to the matching + GUID in the target buffer is returned. If no match is found, then NULL is returned. + If Length is 0, then NULL is returned. + If Length > 0 and Buffer is NULL, then ASSERT(). + If Buffer is not aligned on a 32-bit boundary, then ASSERT(). + If Length is not aligned on a 128-bit boundary, then ASSERT(). + If Length is greater than (MAX_ADDRESS – Buffer + 1), then ASSERT(). + + @param Buffer Pointer to the target buffer to scan. + @param Length Number of bytes in Buffer to scan. + @param Guid Value to search for in the target buffer. + + @return A pointer to the matching Guid in the target buffer or NULL otherwise. + +**/ +VOID * +EFIAPI +ScanGuid ( + IN CONST VOID *Buffer, + IN UINTN Length, + IN CONST GUID *Guid + ) +{ + CONST GUID *GuidPtr; + + ASSERT (((UINTN)Buffer & (sizeof (Guid->Data1) - 1)) == 0); + ASSERT (Length <= (MAX_ADDRESS - (UINTN)Buffer + 1)); + ASSERT ((Length & (sizeof (*GuidPtr) - 1)) == 0); + + GuidPtr = (GUID*)Buffer; + Buffer = GuidPtr + Length / sizeof (*GuidPtr); + while (GuidPtr < (CONST GUID*)Buffer) { + if (CompareGuid (GuidPtr, Guid)) { + return (VOID*)GuidPtr; + } + GuidPtr++; + } + return NULL; +} diff --git a/MdePkg/Library/DxeMemoryLib/MemLibInternals.h b/MdePkg/Library/DxeMemoryLib/MemLibInternals.h new file mode 100644 index 0000000000..8646b24e79 --- /dev/null +++ b/MdePkg/Library/DxeMemoryLib/MemLibInternals.h @@ -0,0 +1,230 @@ +/** @file + Declaration of internal functions for Base Memory Library. + + Copyright (c) 2006, Intel Corporation
+ All rights reserved. This program and the accompanying materials + 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 + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + Module Name: MemLibInternals.h + + The following BaseMemoryLib instances share the same version of this file: + + BaseMemoryLib + BaseMemoryLibMmx + BaseMemoryLibSse2 + BaseMemoryLibRepStr + PeiMemoryLib + DxeMemoryLib + +**/ + +#ifndef __MEM_LIB_INTERNALS__ +#define __MEM_LIB_INTERNALS__ + +/** + Copy Length bytes from Source to Destination. + + @param Destination Target of copy + @param Source Place to copy from + @param Length Number of bytes to copy + + @return Destination + +**/ +VOID * +EFIAPI +InternalMemCopyMem ( + OUT VOID *DestinationBuffer, + IN CONST VOID *SourceBuffer, + IN UINTN Length + ); + +/** + Set Buffer to Value for Size bytes. + + @param Buffer Memory to set. + @param Size Number of bytes to set + @param Value Value of the set operation. + + @return Buffer + +**/ +VOID * +EFIAPI +InternalMemSetMem ( + OUT VOID *Buffer, + IN UINTN Length, + IN UINT8 Value + ); + +/** + Fills a target buffer with a 16-bit value, and returns the target buffer. + + @param Buffer Pointer to the target buffer to fill. + @param Length Number of bytes in Buffer to fill. + @param Value Value with which to fill Length bytes of Buffer. + + @return Buffer + +**/ +VOID * +EFIAPI +InternalMemSetMem16 ( + OUT VOID *Buffer, + IN UINTN Length, + IN UINT16 Value + ); + +/** + Fills a target buffer with a 32-bit value, and returns the target buffer. + + @param Buffer Pointer to the target buffer to fill. + @param Length Number of bytes in Buffer to fill. + @param Value Value with which to fill Length bytes of Buffer. + + @return Buffer + +**/ +VOID * +EFIAPI +InternalMemSetMem32 ( + OUT VOID *Buffer, + IN UINTN Length, + IN UINT32 Value + ); + +/** + Fills a target buffer with a 64-bit value, and returns the target buffer. + + @param Buffer Pointer to the target buffer to fill. + @param Length Number of bytes in Buffer to fill. + @param Value Value with which to fill Length bytes of Buffer. + + @return Buffer + +**/ +VOID * +EFIAPI +InternalMemSetMem64 ( + OUT VOID *Buffer, + IN UINTN Length, + IN UINT64 Value + ); + +/** + Set Buffer to 0 for Size bytes. + + @param Buffer Memory to set. + @param Size Number of bytes to set + + @return Buffer + +**/ +VOID * +EFIAPI +InternalMemZeroMem ( + OUT VOID *Buffer, + IN UINTN Length + ); + +/** + Compares two memory buffers of a given length. + + @param DestinationBuffer First memory buffer + @param SourceBuffer Second memory buffer + @param Length Length of DestinationBuffer and SourceBuffer memory + regions to compare. Must be non-zero. + + @retval 0 if MemOne == MemTwo + +**/ +INTN +EFIAPI +InternalMemCompareMem ( + IN CONST VOID *DestinationBuffer, + IN CONST VOID *SourceBuffer, + IN UINTN Length + ); + +/** + Scans a target buffer for an 8-bit value, and returns a pointer to the + matching 8-bit value in the target buffer. + + @param Buffer Pointer to the target buffer to scan. + @param Length Number of bytes in Buffer to scan. Must be non-zero. + @param Value Value to search for in the target buffer. + + @return Pointer to the first occurrence or NULL if not found. + +**/ +CONST VOID * +EFIAPI +InternalMemScanMem8 ( + IN CONST VOID *Buffer, + IN UINTN Length, + IN UINT8 Value + ); + +/** + Scans a target buffer for a 16-bit value, and returns a pointer to the + matching 16-bit value in the target buffer. + + @param Buffer Pointer to the target buffer to scan. + @param Length Number of bytes in Buffer to scan. Must be non-zero. + @param Value Value to search for in the target buffer. + + @return Pointer to the first occurrence or NULL if not found. + +**/ +CONST VOID * +EFIAPI +InternalMemScanMem16 ( + IN CONST VOID *Buffer, + IN UINTN Length, + IN UINT16 Value + ); + +/** + Scans a target buffer for a 32-bit value, and returns a pointer to the + matching 32-bit value in the target buffer. + + @param Buffer Pointer to the target buffer to scan. + @param Length Number of bytes in Buffer to scan. Must be non-zero. + @param Value Value to search for in the target buffer. + + @return Pointer to the first occurrence or NULL if not found. + +**/ +CONST VOID * +EFIAPI +InternalMemScanMem32 ( + IN CONST VOID *Buffer, + IN UINTN Length, + IN UINT32 Value + ); + +/** + Scans a target buffer for a 64-bit value, and returns a pointer to the + matching 64-bit value in the target buffer. + + @param Buffer Pointer to the target buffer to scan. + @param Length Number of bytes in Buffer to scan. Must be non-zero. + @param Value Value to search for in the target buffer. + + @return Pointer to the first occurrence or NULL if not found. + +**/ +CONST VOID * +EFIAPI +InternalMemScanMem64 ( + IN CONST VOID *Buffer, + IN UINTN Length, + IN UINT64 Value + ); + +#endif diff --git a/MdePkg/Library/DxeMemoryLib/ScanMem16Wrapper.c b/MdePkg/Library/DxeMemoryLib/ScanMem16Wrapper.c new file mode 100644 index 0000000000..29170594d3 --- /dev/null +++ b/MdePkg/Library/DxeMemoryLib/ScanMem16Wrapper.c @@ -0,0 +1,66 @@ +/** @file + ScanMem16() implementation. + + Copyright (c) 2006, Intel Corporation
+ All rights reserved. This program and the accompanying materials + 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 + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + Module Name: ScanMem16Wrapper.c + + The following BaseMemoryLib instances share the same version of this file: + + BaseMemoryLib + BaseMemoryLibMmx + BaseMemoryLibSse2 + BaseMemoryLibRepStr + PeiMemoryLib + DxeMemoryLib + +**/ + +#include "MemLibInternals.h" + +/** + Scans a target buffer for a 16-bit value, and returns a pointer to the matching 16-bit value + in the target buffer. + + This function searches target the buffer specified by Buffer and Length from the lowest + address to the highest address for a 16-bit value that matches Value. If a match is found, + then a pointer to the matching byte in the target buffer is returned. If no match is found, + then NULL is returned. If Length is 0, then NULL is returned. + If Length > 0 and Buffer is NULL, then ASSERT(). + If Buffer is not aligned on a 16-bit boundary, then ASSERT(). + If Length is not aligned on a 16-bit boundary, then ASSERT(). + If Length is greater than (MAX_ADDRESS – Buffer + 1), then ASSERT(). + + @param Buffer Pointer to the target buffer to scan. + @param Length Number of bytes in Buffer to scan. + @param Value Value to search for in the target buffer. + + @return A pointer to the matching byte in the target buffer or NULL otherwise. + +**/ +VOID * +EFIAPI +ScanMem16 ( + IN CONST VOID *Buffer, + IN UINTN Length, + IN UINT16 Value + ) +{ + if (Length == 0) { + return NULL; + } + + ASSERT (Buffer != NULL); + ASSERT (((UINTN)Buffer & (sizeof (Value) - 1)) == 0); + ASSERT ((Length - 1) <= (MAX_ADDRESS - (UINTN)Buffer)); + ASSERT ((Length & (sizeof (Value) - 1)) == 0); + + return (VOID*)InternalMemScanMem16 (Buffer, Length / sizeof (Value), Value); +} diff --git a/MdePkg/Library/DxeMemoryLib/ScanMem32Wrapper.c b/MdePkg/Library/DxeMemoryLib/ScanMem32Wrapper.c new file mode 100644 index 0000000000..b54d5da07c --- /dev/null +++ b/MdePkg/Library/DxeMemoryLib/ScanMem32Wrapper.c @@ -0,0 +1,66 @@ +/** @file + ScanMem32() implementation. + + Copyright (c) 2006, Intel Corporation
+ All rights reserved. This program and the accompanying materials + 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 + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + Module Name: ScanMem32Wrapper.c + + The following BaseMemoryLib instances share the same version of this file: + + BaseMemoryLib + BaseMemoryLibMmx + BaseMemoryLibSse2 + BaseMemoryLibRepStr + PeiMemoryLib + DxeMemoryLib + +**/ + +#include "MemLibInternals.h" + +/** + Scans a target buffer for a 32-bit value, and returns a pointer to the matching 32-bit value + in the target buffer. + + This function searches target the buffer specified by Buffer and Length from the lowest + address to the highest address for a 32-bit value that matches Value. If a match is found, + then a pointer to the matching byte in the target buffer is returned. If no match is found, + then NULL is returned. If Length is 0, then NULL is returned. + If Length > 0 and Buffer is NULL, then ASSERT(). + If Buffer is not aligned on a 32-bit boundary, then ASSERT(). + If Length is not aligned on a 32-bit boundary, then ASSERT(). + If Length is greater than (MAX_ADDRESS – Buffer + 1), then ASSERT(). + + @param Buffer Pointer to the target buffer to scan. + @param Length Number of bytes in Buffer to scan. + @param Value Value to search for in the target buffer. + + @return A pointer to the matching byte in the target buffer or NULL otherwise. + +**/ +VOID * +EFIAPI +ScanMem32 ( + IN CONST VOID *Buffer, + IN UINTN Length, + IN UINT32 Value + ) +{ + if (Length == 0) { + return NULL; + } + + ASSERT (Buffer != NULL); + ASSERT (((UINTN)Buffer & (sizeof (Value) - 1)) == 0); + ASSERT ((Length - 1) <= (MAX_ADDRESS - (UINTN)Buffer)); + ASSERT ((Length & (sizeof (Value) - 1)) == 0); + + return (VOID*)InternalMemScanMem32 (Buffer, Length / sizeof (Value), Value); +} diff --git a/MdePkg/Library/DxeMemoryLib/ScanMem64Wrapper.c b/MdePkg/Library/DxeMemoryLib/ScanMem64Wrapper.c new file mode 100644 index 0000000000..7bfc7d721e --- /dev/null +++ b/MdePkg/Library/DxeMemoryLib/ScanMem64Wrapper.c @@ -0,0 +1,66 @@ +/** @file + ScanMem64() implementation. + + Copyright (c) 2006, Intel Corporation
+ All rights reserved. This program and the accompanying materials + 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 + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + Module Name: ScanMem64Wrapper.c + + The following BaseMemoryLib instances share the same version of this file: + + BaseMemoryLib + BaseMemoryLibMmx + BaseMemoryLibSse2 + BaseMemoryLibRepStr + PeiMemoryLib + DxeMemoryLib + +**/ + +#include "MemLibInternals.h" + +/** + Scans a target buffer for a 64-bit value, and returns a pointer to the matching 64-bit value + in the target buffer. + + This function searches target the buffer specified by Buffer and Length from the lowest + address to the highest address for a 64-bit value that matches Value. If a match is found, + then a pointer to the matching byte in the target buffer is returned. If no match is found, + then NULL is returned. If Length is 0, then NULL is returned. + If Length > 0 and Buffer is NULL, then ASSERT(). + If Buffer is not aligned on a 64-bit boundary, then ASSERT(). + If Length is not aligned on a 64-bit boundary, then ASSERT(). + If Length is greater than (MAX_ADDRESS – Buffer + 1), then ASSERT(). + + @param Buffer Pointer to the target buffer to scan. + @param Length Number of bytes in Buffer to scan. + @param Value Value to search for in the target buffer. + + @return A pointer to the matching byte in the target buffer or NULL otherwise. + +**/ +VOID * +EFIAPI +ScanMem64 ( + IN CONST VOID *Buffer, + IN UINTN Length, + IN UINT64 Value + ) +{ + if (Length == 0) { + return NULL; + } + + ASSERT (Buffer != NULL); + ASSERT (((UINTN)Buffer & (sizeof (Value) - 1)) == 0); + ASSERT ((Length - 1) <= (MAX_ADDRESS - (UINTN)Buffer)); + ASSERT ((Length & (sizeof (Value) - 1)) == 0); + + return (VOID*)InternalMemScanMem64 (Buffer, Length / sizeof (Value), Value); +} diff --git a/MdePkg/Library/DxeMemoryLib/ScanMem8Wrapper.c b/MdePkg/Library/DxeMemoryLib/ScanMem8Wrapper.c new file mode 100644 index 0000000000..0f7289d3df --- /dev/null +++ b/MdePkg/Library/DxeMemoryLib/ScanMem8Wrapper.c @@ -0,0 +1,61 @@ +/** @file + ScanMem8() implementation. + + Copyright (c) 2006, Intel Corporation
+ All rights reserved. This program and the accompanying materials + 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 + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + Module Name: ScanMem8Wrapper.c + + The following BaseMemoryLib instances share the same version of this file: + + BaseMemoryLib + BaseMemoryLibMmx + BaseMemoryLibSse2 + BaseMemoryLibRepStr + PeiMemoryLib + DxeMemoryLib + +**/ + +#include "MemLibInternals.h" + +/** + Scans a target buffer for an 8-bit value, and returns a pointer to the matching 8-bit value + in the target buffer. + + This function searches target the buffer specified by Buffer and Length from the lowest + address to the highest address for an 8-bit value that matches Value. If a match is found, + then a pointer to the matching byte in the target buffer is returned. If no match is found, + then NULL is returned. If Length is 0, then NULL is returned. + If Length > 0 and Buffer is NULL, then ASSERT(). + If Length is greater than (MAX_ADDRESS – Buffer + 1), then ASSERT(). + + @param Buffer Pointer to the target buffer to scan. + @param Length Number of bytes in Buffer to scan. + @param Value Value to search for in the target buffer. + + @return A pointer to the matching byte in the target buffer or NULL otherwise. + +**/ +VOID * +EFIAPI +ScanMem8 ( + IN CONST VOID *Buffer, + IN UINTN Length, + IN UINT8 Value + ) +{ + if (Length == 0) { + return NULL; + } + ASSERT (Buffer != NULL); + ASSERT ((Length - 1) <= (MAX_ADDRESS - (UINTN)Buffer)); + + return (VOID*)InternalMemScanMem8 (Buffer, Length, Value); +} diff --git a/MdePkg/Library/DxeMemoryLib/SetMem16Wrapper.c b/MdePkg/Library/DxeMemoryLib/SetMem16Wrapper.c new file mode 100644 index 0000000000..889339c953 --- /dev/null +++ b/MdePkg/Library/DxeMemoryLib/SetMem16Wrapper.c @@ -0,0 +1,65 @@ +/** @file + SetMem16() implementation. + + Copyright (c) 2006, Intel Corporation
+ All rights reserved. This program and the accompanying materials + 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 + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + Module Name: SetMem16Wrapper.c + + The following BaseMemoryLib instances share the same version of this file: + + BaseMemoryLib + BaseMemoryLibMmx + BaseMemoryLibSse2 + BaseMemoryLibRepStr + PeiMemoryLib + DxeMemoryLib + +**/ + +#include "MemLibInternals.h" + +/** + Fills a target buffer with a 16-bit value, and returns the target buffer. + + This function fills Length bytes of Buffer with the 16-bit value specified by + Value, and returns Buffer. Value is repeated every 16-bits in for Length + bytes of Buffer. + + If Length > 0 and Buffer is NULL, then ASSERT(). + If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT(). + If Buffer is not aligned on a 16-bit boundary, then ASSERT(). + If Length is not aligned on a 16-bit boundary, then ASSERT(). + + @param Buffer Pointer to the target buffer to fill. + @param Length Number of bytes in Buffer to fill. + @param Value Value with which to fill Length bytes of Buffer. + + @return Buffer. + +**/ +VOID * +EFIAPI +SetMem16 ( + OUT VOID *Buffer, + IN UINTN Length, + IN UINT16 Value + ) +{ + if (Length == 0) { + return Buffer; + } + + ASSERT (Buffer != NULL); + ASSERT ((Length - 1) <= (MAX_ADDRESS - (UINTN)Buffer)); + ASSERT ((((UINTN)Buffer) & (sizeof (Value) - 1)) == 0); + ASSERT ((Length & (sizeof (Value) - 1)) == 0); + + return InternalMemSetMem16 (Buffer, Length / sizeof (Value), Value); +} diff --git a/MdePkg/Library/DxeMemoryLib/SetMem32Wrapper.c b/MdePkg/Library/DxeMemoryLib/SetMem32Wrapper.c new file mode 100644 index 0000000000..15f8205ebc --- /dev/null +++ b/MdePkg/Library/DxeMemoryLib/SetMem32Wrapper.c @@ -0,0 +1,65 @@ +/** @file + SetMem32() implementation. + + Copyright (c) 2006, Intel Corporation
+ All rights reserved. This program and the accompanying materials + 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 + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + Module Name: SetMem32Wrapper.c + + The following BaseMemoryLib instances share the same version of this file: + + BaseMemoryLib + BaseMemoryLibMmx + BaseMemoryLibSse2 + BaseMemoryLibRepStr + PeiMemoryLib + DxeMemoryLib + +**/ + +#include "MemLibInternals.h" + +/** + Fills a target buffer with a 32-bit value, and returns the target buffer. + + This function fills Length bytes of Buffer with the 32-bit value specified by + Value, and returns Buffer. Value is repeated every 32-bits in for Length + bytes of Buffer. + + If Length > 0 and Buffer is NULL, then ASSERT(). + If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT(). + If Buffer is not aligned on a 32-bit boundary, then ASSERT(). + If Length is not aligned on a 32-bit boundary, then ASSERT(). + + @param Buffer Pointer to the target buffer to fill. + @param Length Number of bytes in Buffer to fill. + @param Value Value with which to fill Length bytes of Buffer. + + @return Buffer. + +**/ +VOID * +EFIAPI +SetMem32 ( + OUT VOID *Buffer, + IN UINTN Length, + IN UINT32 Value + ) +{ + if (Length == 0) { + return Buffer; + } + + ASSERT (Buffer != NULL); + ASSERT ((Length - 1) <= (MAX_ADDRESS - (UINTN)Buffer)); + ASSERT ((((UINTN)Buffer) & (sizeof (Value) - 1)) == 0); + ASSERT ((Length & (sizeof (Value) - 1)) == 0); + + return InternalMemSetMem32 (Buffer, Length / sizeof (Value), Value); +} diff --git a/MdePkg/Library/DxeMemoryLib/SetMem64Wrapper.c b/MdePkg/Library/DxeMemoryLib/SetMem64Wrapper.c new file mode 100644 index 0000000000..981a7d4731 --- /dev/null +++ b/MdePkg/Library/DxeMemoryLib/SetMem64Wrapper.c @@ -0,0 +1,65 @@ +/** @file + SetMem64() implementation. + + Copyright (c) 2006, Intel Corporation
+ All rights reserved. This program and the accompanying materials + 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 + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + Module Name: SetMem64Wrapper.c + + The following BaseMemoryLib instances share the same version of this file: + + BaseMemoryLib + BaseMemoryLibMmx + BaseMemoryLibSse2 + BaseMemoryLibRepStr + PeiMemoryLib + DxeMemoryLib + +**/ + +#include "MemLibInternals.h" + +/** + Fills a target buffer with a 64-bit value, and returns the target buffer. + + This function fills Length bytes of Buffer with the 64-bit value specified by + Value, and returns Buffer. Value is repeated every 64-bits in for Length + bytes of Buffer. + + If Length > 0 and Buffer is NULL, then ASSERT(). + If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT(). + If Buffer is not aligned on a 64-bit boundary, then ASSERT(). + If Length is not aligned on a 64-bit boundary, then ASSERT(). + + @param Buffer Pointer to the target buffer to fill. + @param Length Number of bytes in Buffer to fill. + @param Value Value with which to fill Length bytes of Buffer. + + @return Buffer. + +**/ +VOID * +EFIAPI +SetMem64 ( + OUT VOID *Buffer, + IN UINTN Length, + IN UINT64 Value + ) +{ + if (Length == 0) { + return Buffer; + } + + ASSERT (Buffer != NULL); + ASSERT ((Length - 1) <= (MAX_ADDRESS - (UINTN)Buffer)); + ASSERT ((((UINTN)Buffer) & (sizeof (Value) - 1)) == 0); + ASSERT ((Length & (sizeof (Value) - 1)) == 0); + + return InternalMemSetMem64 (Buffer, Length / sizeof (Value), Value); +} diff --git a/MdePkg/Library/DxeMemoryLib/SetMemWrapper.c b/MdePkg/Library/DxeMemoryLib/SetMemWrapper.c new file mode 100644 index 0000000000..c73168841b --- /dev/null +++ b/MdePkg/Library/DxeMemoryLib/SetMemWrapper.c @@ -0,0 +1,56 @@ +/** @file + SetMem() implementation. + + Copyright (c) 2006, Intel Corporation
+ All rights reserved. This program and the accompanying materials + 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 + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + Module Name: SetMemWrapper.c + + The following BaseMemoryLib instances share the same version of this file: + + BaseMemoryLib + BaseMemoryLibMmx + BaseMemoryLibSse2 + BaseMemoryLibRepStr + PeiMemoryLib + DxeMemoryLib + +**/ + +#include "MemLibInternals.h" + +/** + Fills a target buffer with a byte value, and returns the target buffer. + + This function fills Length bytes of Buffer with Value, and returns Buffer. + If Length is greater than (MAX_ADDRESS – Buffer + 1), then ASSERT(). + + @param Buffer Memory to set. + @param Length Number of bytes to set. + @param Value Value of the set operation. + + @return Buffer. + +**/ +VOID * +EFIAPI +SetMem ( + OUT VOID *Buffer, + IN UINTN Length, + IN UINT8 Value + ) +{ + if (Length == 0) { + return Buffer; + } + + ASSERT ((Length - 1) <= (MAX_ADDRESS - (UINTN)Buffer)); + + return InternalMemSetMem (Buffer, Length, Value); +} diff --git a/MdePkg/Library/DxeMemoryLib/ZeroMemWrapper.c b/MdePkg/Library/DxeMemoryLib/ZeroMemWrapper.c new file mode 100644 index 0000000000..08247681c5 --- /dev/null +++ b/MdePkg/Library/DxeMemoryLib/ZeroMemWrapper.c @@ -0,0 +1,51 @@ +/** @file + ZeroMem() implementation. + + Copyright (c) 2006, Intel Corporation
+ All rights reserved. This program and the accompanying materials + 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 + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + Module Name: ZeroMemWrapper.c + + The following BaseMemoryLib instances share the same version of this file: + + BaseMemoryLib + BaseMemoryLibMmx + BaseMemoryLibSse2 + BaseMemoryLibRepStr + PeiMemoryLib + DxeMemoryLib + +**/ + +#include "MemLibInternals.h" + +/** + Fills a target buffer with zeros, and returns the target buffer. + + This function fills Length bytes of Buffer with zeros, and returns Buffer. + If Length > 0 and Buffer is NULL, then ASSERT(). + If Length is greater than (MAX_ADDRESS – Buffer + 1), then ASSERT(). + + @param Buffer Pointer to the target buffer to fill with zeros. + @param Length Number of bytes in Buffer to fill with zeros. + + @return Buffer. + +**/ +VOID * +EFIAPI +ZeroMem ( + OUT VOID *Buffer, + IN UINTN Length + ) +{ + ASSERT (!(Buffer == NULL && Length > 0)); + ASSERT (Length <= (MAX_ADDRESS - (UINTN)Buffer + 1)); + return InternalMemSetMem (Buffer, Length, 0); +} diff --git a/MdePkg/Library/DxeMemoryLib/build.xml b/MdePkg/Library/DxeMemoryLib/build.xml new file mode 100644 index 0000000000..4b5ee9f56a --- /dev/null +++ b/MdePkg/Library/DxeMemoryLib/build.xml @@ -0,0 +1,47 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/MdePkg/Library/PeiDxeDebugLibReportStatusCode/DebugLib.c b/MdePkg/Library/PeiDxeDebugLibReportStatusCode/DebugLib.c index b06a75660f..8c8bbc2719 100644 --- a/MdePkg/Library/PeiDxeDebugLibReportStatusCode/DebugLib.c +++ b/MdePkg/Library/PeiDxeDebugLibReportStatusCode/DebugLib.c @@ -75,12 +75,12 @@ DebugPrint ( VA_END (Marker); AsciiStrCpy ((CHAR8 *)ArgumentPointer, Format); - // - // - // - REPORT_STATUS_CODE_WITH_EXTENDED_DATA ( + REPORT_STATUS_CODE_EX ( EFI_DEBUG_CODE, (EFI_SOFTWARE_DXE_BS_DRIVER | EFI_DC_UNSPECIFIED), + 0, + NULL, + &gEfiStatusCodeDataTypeDebugGuid, DebugInfo, TotalSize ); @@ -142,7 +142,7 @@ DebugAssert ( // // Copy Ascii Description // - AsciiStrCpy (Temp + AsciiStrLen(FileName) + 1, Description); + AsciiStrCpy (Temp + AsciiStrLen (FileName) + 1, Description); REPORT_STATUS_CODE_WITH_EXTENDED_DATA ( (EFI_ERROR_CODE | EFI_ERROR_UNRECOVERED), diff --git a/MdePkg/Library/PeiDxeDebugLibReportStatusCode/PeiDxeDebugLibReportStatusCode.msa b/MdePkg/Library/PeiDxeDebugLibReportStatusCode/PeiDxeDebugLibReportStatusCode.msa index a3c923693f..f65ed5a058 100644 --- a/MdePkg/Library/PeiDxeDebugLibReportStatusCode/PeiDxeDebugLibReportStatusCode.msa +++ b/MdePkg/Library/PeiDxeDebugLibReportStatusCode/PeiDxeDebugLibReportStatusCode.msa @@ -5,7 +5,7 @@ PEIM bda39d3a-451b-4350-8266-81ab10fa0523 1.0 - Debug Library for PEIMs that send debug messages to ReportStatusCode + Debug Library for PEIMs and DXE drivers that send debug messages to ReportStatusCode FIX ME! Copyright (c) 2004-2006, Intel Corporation All rights reserved. This program and the accompanying materials @@ -44,6 +44,11 @@ + + + StatusCodeDataTypeDebug + + EFI_SPECIFICATION_VERSION 0x00020000 EDK_RELEASE_VERSION 0x00090000 diff --git a/MdePkg/Library/PeiMemoryLib/CompareMemWrapper.c b/MdePkg/Library/PeiMemoryLib/CompareMemWrapper.c index e3b0fe3fd6..4c0d3eaadb 100644 --- a/MdePkg/Library/PeiMemoryLib/CompareMemWrapper.c +++ b/MdePkg/Library/PeiMemoryLib/CompareMemWrapper.c @@ -19,7 +19,7 @@ BaseMemoryLibSse2 BaseMemoryLibRepStr PeiMemoryLib - UefiMemoryLib + DxeMemoryLib **/ diff --git a/MdePkg/Library/PeiMemoryLib/CopyMemWrapper.c b/MdePkg/Library/PeiMemoryLib/CopyMemWrapper.c index 1fd00acabd..9e620e2200 100644 --- a/MdePkg/Library/PeiMemoryLib/CopyMemWrapper.c +++ b/MdePkg/Library/PeiMemoryLib/CopyMemWrapper.c @@ -19,7 +19,7 @@ BaseMemoryLibSse2 BaseMemoryLibRepStr PeiMemoryLib - UefiMemoryLib + DxeMemoryLib **/ diff --git a/MdePkg/Library/PeiMemoryLib/MemLibGeneric.c b/MdePkg/Library/PeiMemoryLib/MemLibGeneric.c index 3fecfc9ff0..759377483c 100644 --- a/MdePkg/Library/PeiMemoryLib/MemLibGeneric.c +++ b/MdePkg/Library/PeiMemoryLib/MemLibGeneric.c @@ -16,7 +16,7 @@ BaseMemoryLib PeiMemoryLib - UefiMemoryLib + DxeMemoryLib **/ diff --git a/MdePkg/Library/PeiMemoryLib/MemLibGuid.c b/MdePkg/Library/PeiMemoryLib/MemLibGuid.c index 351e370c2c..8932af7083 100644 --- a/MdePkg/Library/PeiMemoryLib/MemLibGuid.c +++ b/MdePkg/Library/PeiMemoryLib/MemLibGuid.c @@ -19,7 +19,7 @@ BaseMemoryLibSse2 BaseMemoryLibRepStr PeiMemoryLib - UefiMemoryLib + DxeMemoryLib **/ @@ -95,7 +95,8 @@ CompareGuid ( GUID in the target buffer is returned. If no match is found, then NULL is returned. If Length is 0, then NULL is returned. If Length > 0 and Buffer is NULL, then ASSERT(). - If Buffer is not aligned on a 64-bit boundary, then ASSERT(). + If Buffer is not aligned on a 32-bit boundary, then ASSERT(). + If Length is not aligned on a 128-bit boundary, then ASSERT(). If Length is greater than (MAX_ADDRESS – Buffer + 1), then ASSERT(). @param Buffer Pointer to the target buffer to scan. @@ -115,16 +116,12 @@ ScanGuid ( { CONST GUID *GuidPtr; - ASSERT (Buffer != NULL); - // - // Make sure Buffer is aligned on a 64-bit boundary. - // - ASSERT (((UINTN) Buffer & 7) == 0); - + ASSERT (((UINTN)Buffer & (sizeof (Guid->Data1) - 1)) == 0); ASSERT (Length <= (MAX_ADDRESS - (UINTN)Buffer + 1)); + ASSERT ((Length & (sizeof (*GuidPtr) - 1)) == 0); GuidPtr = (GUID*)Buffer; - Buffer = GuidPtr + Length / sizeof (*GuidPtr); + Buffer = GuidPtr + Length / sizeof (*GuidPtr); while (GuidPtr < (CONST GUID*)Buffer) { if (CompareGuid (GuidPtr, Guid)) { return (VOID*)GuidPtr; diff --git a/MdePkg/Library/PeiMemoryLib/MemLibInternals.h b/MdePkg/Library/PeiMemoryLib/MemLibInternals.h index ca7311a407..8646b24e79 100644 --- a/MdePkg/Library/PeiMemoryLib/MemLibInternals.h +++ b/MdePkg/Library/PeiMemoryLib/MemLibInternals.h @@ -19,7 +19,7 @@ BaseMemoryLibSse2 BaseMemoryLibRepStr PeiMemoryLib - UefiMemoryLib + DxeMemoryLib **/ diff --git a/MdePkg/Library/PeiMemoryLib/ScanMem16Wrapper.c b/MdePkg/Library/PeiMemoryLib/ScanMem16Wrapper.c index 9ffc2cf159..29170594d3 100644 --- a/MdePkg/Library/PeiMemoryLib/ScanMem16Wrapper.c +++ b/MdePkg/Library/PeiMemoryLib/ScanMem16Wrapper.c @@ -19,7 +19,7 @@ BaseMemoryLibSse2 BaseMemoryLibRepStr PeiMemoryLib - UefiMemoryLib + DxeMemoryLib **/ @@ -35,6 +35,7 @@ then NULL is returned. If Length is 0, then NULL is returned. If Length > 0 and Buffer is NULL, then ASSERT(). If Buffer is not aligned on a 16-bit boundary, then ASSERT(). + If Length is not aligned on a 16-bit boundary, then ASSERT(). If Length is greater than (MAX_ADDRESS – Buffer + 1), then ASSERT(). @param Buffer Pointer to the target buffer to scan. @@ -52,16 +53,14 @@ ScanMem16 ( IN UINT16 Value ) { - UINTN Stride; - - Stride = Length / sizeof (Value); - if (Stride == 0) { + if (Length == 0) { return NULL; } ASSERT (Buffer != NULL); ASSERT (((UINTN)Buffer & (sizeof (Value) - 1)) == 0); ASSERT ((Length - 1) <= (MAX_ADDRESS - (UINTN)Buffer)); + ASSERT ((Length & (sizeof (Value) - 1)) == 0); - return (VOID*)InternalMemScanMem16 (Buffer, Stride, Value); + return (VOID*)InternalMemScanMem16 (Buffer, Length / sizeof (Value), Value); } diff --git a/MdePkg/Library/PeiMemoryLib/ScanMem32Wrapper.c b/MdePkg/Library/PeiMemoryLib/ScanMem32Wrapper.c index 6b0beee632..b54d5da07c 100644 --- a/MdePkg/Library/PeiMemoryLib/ScanMem32Wrapper.c +++ b/MdePkg/Library/PeiMemoryLib/ScanMem32Wrapper.c @@ -19,7 +19,7 @@ BaseMemoryLibSse2 BaseMemoryLibRepStr PeiMemoryLib - UefiMemoryLib + DxeMemoryLib **/ @@ -35,6 +35,7 @@ then NULL is returned. If Length is 0, then NULL is returned. If Length > 0 and Buffer is NULL, then ASSERT(). If Buffer is not aligned on a 32-bit boundary, then ASSERT(). + If Length is not aligned on a 32-bit boundary, then ASSERT(). If Length is greater than (MAX_ADDRESS – Buffer + 1), then ASSERT(). @param Buffer Pointer to the target buffer to scan. @@ -52,16 +53,14 @@ ScanMem32 ( IN UINT32 Value ) { - UINTN Stride; - - Stride = Length / sizeof (Value); - if (Stride == 0) { + if (Length == 0) { return NULL; } ASSERT (Buffer != NULL); ASSERT (((UINTN)Buffer & (sizeof (Value) - 1)) == 0); ASSERT ((Length - 1) <= (MAX_ADDRESS - (UINTN)Buffer)); + ASSERT ((Length & (sizeof (Value) - 1)) == 0); - return (VOID*)InternalMemScanMem32 (Buffer, Stride, Value); + return (VOID*)InternalMemScanMem32 (Buffer, Length / sizeof (Value), Value); } diff --git a/MdePkg/Library/PeiMemoryLib/ScanMem64Wrapper.c b/MdePkg/Library/PeiMemoryLib/ScanMem64Wrapper.c index 589d45c1a1..7bfc7d721e 100644 --- a/MdePkg/Library/PeiMemoryLib/ScanMem64Wrapper.c +++ b/MdePkg/Library/PeiMemoryLib/ScanMem64Wrapper.c @@ -19,7 +19,7 @@ BaseMemoryLibSse2 BaseMemoryLibRepStr PeiMemoryLib - UefiMemoryLib + DxeMemoryLib **/ @@ -35,6 +35,7 @@ then NULL is returned. If Length is 0, then NULL is returned. If Length > 0 and Buffer is NULL, then ASSERT(). If Buffer is not aligned on a 64-bit boundary, then ASSERT(). + If Length is not aligned on a 64-bit boundary, then ASSERT(). If Length is greater than (MAX_ADDRESS – Buffer + 1), then ASSERT(). @param Buffer Pointer to the target buffer to scan. @@ -52,16 +53,14 @@ ScanMem64 ( IN UINT64 Value ) { - UINTN Stride; - - Stride = Length / sizeof (Value); - if (Stride == 0) { + if (Length == 0) { return NULL; } ASSERT (Buffer != NULL); ASSERT (((UINTN)Buffer & (sizeof (Value) - 1)) == 0); ASSERT ((Length - 1) <= (MAX_ADDRESS - (UINTN)Buffer)); + ASSERT ((Length & (sizeof (Value) - 1)) == 0); - return (VOID*)InternalMemScanMem64 (Buffer, Stride, Value); + return (VOID*)InternalMemScanMem64 (Buffer, Length / sizeof (Value), Value); } diff --git a/MdePkg/Library/PeiMemoryLib/ScanMem8Wrapper.c b/MdePkg/Library/PeiMemoryLib/ScanMem8Wrapper.c index 4dc8bac073..0f7289d3df 100644 --- a/MdePkg/Library/PeiMemoryLib/ScanMem8Wrapper.c +++ b/MdePkg/Library/PeiMemoryLib/ScanMem8Wrapper.c @@ -19,7 +19,7 @@ BaseMemoryLibSse2 BaseMemoryLibRepStr PeiMemoryLib - UefiMemoryLib + DxeMemoryLib **/ diff --git a/MdePkg/Library/PeiMemoryLib/SetMem16Wrapper.c b/MdePkg/Library/PeiMemoryLib/SetMem16Wrapper.c index 41467a9cb0..889339c953 100644 --- a/MdePkg/Library/PeiMemoryLib/SetMem16Wrapper.c +++ b/MdePkg/Library/PeiMemoryLib/SetMem16Wrapper.c @@ -19,7 +19,7 @@ BaseMemoryLibSse2 BaseMemoryLibRepStr PeiMemoryLib - UefiMemoryLib + DxeMemoryLib **/ diff --git a/MdePkg/Library/PeiMemoryLib/SetMem32Wrapper.c b/MdePkg/Library/PeiMemoryLib/SetMem32Wrapper.c index 425840682d..15f8205ebc 100644 --- a/MdePkg/Library/PeiMemoryLib/SetMem32Wrapper.c +++ b/MdePkg/Library/PeiMemoryLib/SetMem32Wrapper.c @@ -19,7 +19,7 @@ BaseMemoryLibSse2 BaseMemoryLibRepStr PeiMemoryLib - UefiMemoryLib + DxeMemoryLib **/ diff --git a/MdePkg/Library/PeiMemoryLib/SetMem64Wrapper.c b/MdePkg/Library/PeiMemoryLib/SetMem64Wrapper.c index 4a1eda80e8..981a7d4731 100644 --- a/MdePkg/Library/PeiMemoryLib/SetMem64Wrapper.c +++ b/MdePkg/Library/PeiMemoryLib/SetMem64Wrapper.c @@ -19,7 +19,7 @@ BaseMemoryLibSse2 BaseMemoryLibRepStr PeiMemoryLib - UefiMemoryLib + DxeMemoryLib **/ diff --git a/MdePkg/Library/PeiMemoryLib/SetMemWrapper.c b/MdePkg/Library/PeiMemoryLib/SetMemWrapper.c index 3965be759a..c73168841b 100644 --- a/MdePkg/Library/PeiMemoryLib/SetMemWrapper.c +++ b/MdePkg/Library/PeiMemoryLib/SetMemWrapper.c @@ -19,7 +19,7 @@ BaseMemoryLibSse2 BaseMemoryLibRepStr PeiMemoryLib - UefiMemoryLib + DxeMemoryLib **/ @@ -32,7 +32,7 @@ If Length is greater than (MAX_ADDRESS – Buffer + 1), then ASSERT(). @param Buffer Memory to set. - @param Length Number of bytes to set + @param Length Number of bytes to set. @param Value Value of the set operation. @return Buffer. diff --git a/MdePkg/Library/PeiMemoryLib/ZeroMemWrapper.c b/MdePkg/Library/PeiMemoryLib/ZeroMemWrapper.c index 56dbe5d8be..08247681c5 100644 --- a/MdePkg/Library/PeiMemoryLib/ZeroMemWrapper.c +++ b/MdePkg/Library/PeiMemoryLib/ZeroMemWrapper.c @@ -19,7 +19,7 @@ BaseMemoryLibSse2 BaseMemoryLibRepStr PeiMemoryLib - UefiMemoryLib + DxeMemoryLib **/ diff --git a/MdePkg/Library/PeiServicesLib/PeiServicesLib.c b/MdePkg/Library/PeiServicesLib/PeiServicesLib.c index 2f666a6963..e64618de21 100644 --- a/MdePkg/Library/PeiServicesLib/PeiServicesLib.c +++ b/MdePkg/Library/PeiServicesLib/PeiServicesLib.c @@ -1,5 +1,5 @@ /** @file - PEI Library. + Implementation for PEI Services Library. Copyright (c) 2006, Intel Corporation
All rights reserved. This program and the accompanying materials @@ -17,19 +17,19 @@ /** This service enables a given PEIM to register an interface into the PEI Foundation. - @param PpiList A pointer to the list of interfaces that the caller shall install. + @param PpiList A pointer to the list of interfaces that the caller shall install. - @retval EFI_SUCCESS The interface was successfully installed. - @retval EFI_INVALID_PARAMETER The PpiList pointer is NULL. - @retval EFI_INVALID_PARAMETER Any of the PEI PPI descriptors in the list do not have - the EFI_PEI_PPI_DESCRIPTOR_PPI bit set in the Flags field. - @retval EFI_OUT_OF_RESOURCES There is no additional space in the PPI database. + @retval EFI_SUCCESS The interface was successfully installed. + @retval EFI_INVALID_PARAMETER The PpiList pointer is NULL. + @retval EFI_INVALID_PARAMETER Any of the PEI PPI descriptors in the list do not have the + EFI_PEI_PPI_DESCRIPTOR_PPI bit set in the Flags field. + @retval EFI_OUT_OF_RESOURCES There is no additional space in the PPI database. **/ EFI_STATUS EFIAPI PeiServicesInstallPpi ( - IN EFI_PEI_PPI_DESCRIPTOR *PpiList + IN EFI_PEI_PPI_DESCRIPTOR *PpiList ) { EFI_PEI_SERVICES **PeiServices; @@ -41,22 +41,23 @@ PeiServicesInstallPpi ( /** This service enables PEIMs to replace an entry in the PPI database with an alternate entry. - @param OldPpi Pointer to the old PEI PPI Descriptors. - @param NewPpi Pointer to the new PEI PPI Descriptors. + @param OldPpi Pointer to the old PEI PPI Descriptors. + @param NewPpi Pointer to the new PEI PPI Descriptors. - @retval EFI_SUCCESS The interface was successfully installed. - @retval EFI_INVALID_PARAMETER The OldPpi or NewPpi is NULL. - @retval EFI_INVALID_PARAMETER Any of the PEI PPI descriptors in the list do not have - the EFI_PEI_PPI_DESCRIPTOR_PPI bit set in the Flags field. - @retval EFI_OUT_OF_RESOURCES There is no additional space in the PPI database. - @retval EFI_NOT_FOUND The PPI for which the reinstallation was requested has not been installed. + @retval EFI_SUCCESS The interface was successfully installed. + @retval EFI_INVALID_PARAMETER The OldPpi or NewPpi is NULL. + @retval EFI_INVALID_PARAMETER Any of the PEI PPI descriptors in the list do not have the + EFI_PEI_PPI_DESCRIPTOR_PPI bit set in the Flags field. + @retval EFI_OUT_OF_RESOURCES There is no additional space in the PPI database. + @retval EFI_NOT_FOUND The PPI for which the reinstallation was requested has not been + installed. **/ EFI_STATUS EFIAPI PeiServicesReInstallPpi ( - IN EFI_PEI_PPI_DESCRIPTOR *OldPpi, - IN EFI_PEI_PPI_DESCRIPTOR *NewPpi + IN EFI_PEI_PPI_DESCRIPTOR *OldPpi, + IN EFI_PEI_PPI_DESCRIPTOR *NewPpi ) { EFI_PEI_SERVICES **PeiServices; @@ -68,22 +69,23 @@ PeiServicesReInstallPpi ( /** This service enables PEIMs to discover a given instance of an interface. - @param Guid A pointer to the GUID whose corresponding interface needs to be found. - @param Instance The N-th instance of the interface that is required. - @param PpiDescriptor A pointer to instance of the EFI_PEI_PPI_DESCRIPTOR. - @param Ppi A pointer to the instance of the interface. + @param Guid A pointer to the GUID whose corresponding interface needs to be + found. + @param Instance The N-th instance of the interface that is required. + @param PpiDescriptor A pointer to instance of the EFI_PEI_PPI_DESCRIPTOR. + @param Ppi A pointer to the instance of the interface. - @retval EFI_SUCCESS The interface was successfully returned. - @retval EFI_NOT_FOUND The PPI descriptor is not found in the database. + @retval EFI_SUCCESS The interface was successfully returned. + @retval EFI_NOT_FOUND The PPI descriptor is not found in the database. **/ EFI_STATUS EFIAPI PeiServicesLocatePpi ( - IN EFI_GUID *Guid, - IN UINTN Instance, - IN OUT EFI_PEI_PPI_DESCRIPTOR **PpiDescriptor, - IN OUT VOID **Ppi + IN EFI_GUID *Guid, + IN UINTN Instance, + IN OUT EFI_PEI_PPI_DESCRIPTOR **PpiDescriptor, + IN OUT VOID **Ppi ) { EFI_PEI_SERVICES **PeiServices; @@ -93,22 +95,23 @@ PeiServicesLocatePpi ( } /** - This service enables PEIMs to register a given service to be invoked - when another service is installed or reinstalled. + This service enables PEIMs to register a given service to be invoked when another service is + installed or reinstalled. - @param NotifyList A pointer to the list of notification interfaces that the caller shall install. + @param NotifyList A pointer to the list of notification interfaces that the caller + shall install. - @retval EFI_SUCCESS The interface was successfully installed. - @retval EFI_INVALID_PARAMETER The NotifyList pointer is NULL. - @retval EFI_INVALID_PARAMETER Any of the PEI notify descriptors in the list do not have - the EFI_PEI_PPI_DESCRIPTOR_NOTIFY_TYPES bit set in the Flags field. - @retval EFI_OUT_OF_RESOURCES There is no additional space in the PPI database. + @retval EFI_SUCCESS The interface was successfully installed. + @retval EFI_INVALID_PARAMETER The NotifyList pointer is NULL. + @retval EFI_INVALID_PARAMETER Any of the PEI notify descriptors in the list do not have the + EFI_PEI_PPI_DESCRIPTOR_NOTIFY_TYPES bit set in the Flags field. + @retval EFI_OUT_OF_RESOURCES There is no additional space in the PPI database. **/ EFI_STATUS EFIAPI PeiServicesNotifyPpi ( - IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyList + IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyList ) { EFI_PEI_SERVICES **PeiServices; @@ -120,16 +123,16 @@ PeiServicesNotifyPpi ( /** This service enables PEIMs to ascertain the present value of the boot mode. - @param BootMode A pointer to contain the value of the boot mode. + @param BootMode A pointer to contain the value of the boot mode. - @retval EFI_SUCCESS The boot mode was returned successfully. - @retval EFI_INVALID_PARAMETER BootMode is NULL. + @retval EFI_SUCCESS The boot mode was returned successfully. + @retval EFI_INVALID_PARAMETER BootMode is NULL. **/ EFI_STATUS EFIAPI PeiServicesGetBootMode ( - IN OUT EFI_BOOT_MODE *BootMode + IN OUT EFI_BOOT_MODE *BootMode ) { EFI_PEI_SERVICES **PeiServices; @@ -141,15 +144,15 @@ PeiServicesGetBootMode ( /** This service enables PEIMs to update the boot mode variable. - @param BootMode The value of the boot mode to set. + @param BootMode The value of the boot mode to set. - @retval EFI_SUCCESS The value was successfully updated + @retval EFI_SUCCESS The value was successfully updated **/ EFI_STATUS EFIAPI PeiServicesSetBootMode ( - IN EFI_BOOT_MODE BootMode + IN EFI_BOOT_MODE BootMode ) { EFI_PEI_SERVICES **PeiServices; @@ -161,16 +164,16 @@ PeiServicesSetBootMode ( /** This service enables a PEIM to ascertain the address of the list of HOBs in memory. - @param HobList A pointer to the list of HOBs that the PEI Foundation will initialize. + @param HobList A pointer to the list of HOBs that the PEI Foundation will initialize. - @retval EFI_SUCCESS The list was successfully returned. - @retval EFI_NOT_AVAILABLE_YET The HOB list is not yet published. + @retval EFI_SUCCESS The list was successfully returned. + @retval EFI_NOT_AVAILABLE_YET The HOB list is not yet published. **/ EFI_STATUS EFIAPI PeiServicesGetHobList ( - IN OUT VOID **HobList + IN OUT VOID **HobList ) { EFI_PEI_SERVICES **PeiServices; @@ -182,20 +185,20 @@ PeiServicesGetHobList ( /** This service enables PEIMs to create various types of HOBs. - @param Type The type of HOB to be installed. - @param Length The length of the HOB to be added. - @param Hob The address of a pointer that will contain the HOB header. + @param Type The type of HOB to be installed. + @param Length The length of the HOB to be added. + @param Hob The address of a pointer that will contain the HOB header. - @retval EFI_SUCCESS The HOB was successfully created. - @retval EFI_OUT_OF_RESOURCES There is no additional space for HOB creation. + @retval EFI_SUCCESS The HOB was successfully created. + @retval EFI_OUT_OF_RESOURCES There is no additional space for HOB creation. **/ EFI_STATUS EFIAPI PeiServicesCreateHob ( - IN UINT16 Type, - IN UINT16 Length, - IN OUT VOID **Hob + IN UINT16 Type, + IN UINT16 Length, + IN OUT VOID **Hob ) { EFI_PEI_SERVICES **PeiServices; @@ -207,20 +210,20 @@ PeiServicesCreateHob ( /** This service enables PEIMs to discover additional firmware volumes. - @param Instance This instance of the firmware volume to find. - The value 0 is the Boot Firmware Volume (BFV). - @param FwVolHeader Pointer to the firmware volume header of the volume to return. + @param Instance This instance of the firmware volume to find. The value 0 is the + Boot Firmware Volume (BFV). + @param FwVolHeader Pointer to the firmware volume header of the volume to return. - @retval EFI_SUCCESS The volume was found. - @retval EFI_NOT_FOUND The volume was not found. - @retval EFI_INVALID_PARAMETER FwVolHeader is NULL. + @retval EFI_SUCCESS The volume was found. + @retval EFI_NOT_FOUND The volume was not found. + @retval EFI_INVALID_PARAMETER FwVolHeader is NULL. **/ EFI_STATUS EFIAPI PeiServicesFfsFindNextVolume ( - IN UINTN Instance, - IN OUT EFI_FIRMWARE_VOLUME_HEADER **FwVolHeader + IN UINTN Instance, + IN OUT EFI_FIRMWARE_VOLUME_HEADER **FwVolHeader ) { EFI_PEI_SERVICES **PeiServices; @@ -232,22 +235,22 @@ PeiServicesFfsFindNextVolume ( /** This service enables PEIMs to discover additional firmware files. - @param SearchType A filter to find files only of this type. - @param FwVolHeader Pointer to the firmware volume header of the volume to search. - This parameter must point to a valid FFS volume. - @param FileHeader Pointer to the current file from which to begin searching. + @param SearchType A filter to find files only of this type. + @param FwVolHeader Pointer to the firmware volume header of the volume to search. + This parameter must point to a valid FFS volume. + @param FileHeader Pointer to the current file from which to begin searching. - @retval EFI_SUCCESS The file was found. - @retval EFI_NOT_FOUND The file was not found. - @retval EFI_NOT_FOUND The header checksum was not zero. + @retval EFI_SUCCESS The file was found. + @retval EFI_NOT_FOUND The file was not found. + @retval EFI_NOT_FOUND The header checksum was not zero. **/ EFI_STATUS EFIAPI PeiServicesFfsFindNextFile ( - IN EFI_FV_FILETYPE SearchType, - IN EFI_FIRMWARE_VOLUME_HEADER *FwVolHeader, - IN OUT EFI_FFS_FILE_HEADER **FileHeader + IN EFI_FV_FILETYPE SearchType, + IN EFI_FIRMWARE_VOLUME_HEADER *FwVolHeader, + IN OUT EFI_FFS_FILE_HEADER **FileHeader ) { EFI_PEI_SERVICES **PeiServices; @@ -259,20 +262,21 @@ PeiServicesFfsFindNextFile ( /** This service enables PEIMs to discover sections of a given type within a valid FFS file. - @param SearchType The value of the section type to find. - @param FfsFileHeader A pointer to the file header that contains the set of sections to be searched. - @param SectionData A pointer to the discovered section, if successful. + @param SearchType The value of the section type to find. + @param FfsFileHeader A pointer to the file header that contains the set of sections to + be searched. + @param SectionData A pointer to the discovered section, if successful. - @retval EFI_SUCCESS The section was found. - @retval EFI_NOT_FOUND The section was not found. + @retval EFI_SUCCESS The section was found. + @retval EFI_NOT_FOUND The section was not found. **/ EFI_STATUS EFIAPI PeiServicesFfsFindSectionData ( - IN EFI_SECTION_TYPE SectionType, - IN EFI_FFS_FILE_HEADER *FfsFileHeader, - IN OUT VOID **SectionData + IN EFI_SECTION_TYPE SectionType, + IN EFI_FFS_FILE_HEADER *FfsFileHeader, + IN OUT VOID **SectionData ) { EFI_PEI_SERVICES **PeiServices; @@ -285,19 +289,19 @@ PeiServicesFfsFindSectionData ( This service enables PEIMs to register the permanent memory configuration that has been initialized with the PEI Foundation. - @param MemoryBegin The value of a region of installed memory. - @param MemoryLength The corresponding length of a region of installed memory. + @param MemoryBegin The value of a region of installed memory. + @param MemoryLength The corresponding length of a region of installed memory. - @retval EFI_SUCCESS The region was successfully installed in a HOB. - @retval EFI_INVALID_PARAMETER MemoryBegin and MemoryLength are illegal for this system. - @retval EFI_OUT_OF_RESOURCES There is no additional space for HOB creation. + @retval EFI_SUCCESS The region was successfully installed in a HOB. + @retval EFI_INVALID_PARAMETER MemoryBegin and MemoryLength are illegal for this system. + @retval EFI_OUT_OF_RESOURCES There is no additional space for HOB creation. **/ EFI_STATUS EFIAPI PeiServicesInstallPeiMemory ( - IN EFI_PHYSICAL_ADDRESS MemoryBegin, - IN UINT64 MemoryLength + IN EFI_PHYSICAL_ADDRESS MemoryBegin, + IN UINT64 MemoryLength ) { EFI_PEI_SERVICES **PeiServices; @@ -307,24 +311,25 @@ PeiServicesInstallPeiMemory ( } /** - This service enables PEIMs to allocate memory after the permanent memory has been installed by a PEIM. + This service enables PEIMs to allocate memory after the permanent memory has been installed by a + PEIM. - @param MemoryType Type of memory to allocate. - @param Pages Number of pages to allocate. - @param Memory Pointer of memory allocated. + @param MemoryType Type of memory to allocate. + @param Pages Number of pages to allocate. + @param Memory Pointer of memory allocated. - @retval EFI_SUCCESS The memory range was successfully allocated. - @retval EFI_INVALID_PARAMETER Type is not equal to AllocateAnyPages. - @retval EFI_NOT_AVAILABLE_YET Called with permanent memory not available. - @retval EFI_OUT_OF_RESOURCES The pages could not be allocated. + @retval EFI_SUCCESS The memory range was successfully allocated. + @retval EFI_INVALID_PARAMETER Type is not equal to AllocateAnyPages. + @retval EFI_NOT_AVAILABLE_YET Called with permanent memory not available. + @retval EFI_OUT_OF_RESOURCES The pages could not be allocated. **/ EFI_STATUS EFIAPI PeiServicesAllocatePages ( - IN EFI_MEMORY_TYPE MemoryType, - IN UINTN Pages, - IN OUT EFI_PHYSICAL_ADDRESS *Memory + IN EFI_MEMORY_TYPE MemoryType, + IN UINTN Pages, + IN OUT EFI_PHYSICAL_ADDRESS *Memory ) { EFI_PEI_SERVICES **PeiServices; @@ -336,19 +341,19 @@ PeiServicesAllocatePages ( /** This service allocates memory from the Hand-Off Block (HOB) heap. - @param Size The number of bytes to allocate from the pool. - @param Buffer If the call succeeds, a pointer to a pointer to the allocated buffer; - undefined otherwise. + @param Size The number of bytes to allocate from the pool. + @param Buffer If the call succeeds, a pointer to a pointer to the allocate + buffer; undefined otherwise. - @retval EFI_SUCCESS The allocation was successful - @retval EFI_OUT_OF_RESOURCES There is not enough heap to allocate the requested size. + @retval EFI_SUCCESS The allocation was successful + @retval EFI_OUT_OF_RESOURCES There is not enough heap to allocate the requested size. **/ EFI_STATUS EFIAPI PeiServicesAllocatePool ( - IN UINTN Size, - OUT VOID **Buffer + IN UINTN Size, + OUT VOID **Buffer ) { EFI_PEI_SERVICES **PeiServices; @@ -358,9 +363,10 @@ PeiServicesAllocatePool ( } /** - This service resets the entire platform, including all processors and devices, and reboots the system. + This service resets the entire platform, including all processors and devices, and reboots the + system. - @retval EFI_NOT_AVAILABLE_YET The service has not been installed yet. + @retval EFI_NOT_AVAILABLE_YET The service has not been installed yet. **/ EFI_STATUS diff --git a/MdePkg/Library/UefiDevicePathLib/UefiDevicePathLib.c b/MdePkg/Library/UefiDevicePathLib/UefiDevicePathLib.c index 1b1376e2cf..31a0462f07 100644 --- a/MdePkg/Library/UefiDevicePathLib/UefiDevicePathLib.c +++ b/MdePkg/Library/UefiDevicePathLib/UefiDevicePathLib.c @@ -22,11 +22,12 @@ **/ /** - This function returns the size, in bytes, - of the device path data structure specified by DevicePath. - If DevicePath is NULL, then 0 is returned. + Returns the size of a device path in bytes. - @param DevicePath A pointer to a device path data structure. + This function returns the size, in bytes, of the device path data structure specified by + DevicePath including the end of device path node. If DevicePath is NULL, then 0 is returned. + + @param DevicePath A pointer to a device path data structure. @return The size of a device path in bytes. @@ -58,18 +59,22 @@ GetDevicePathSize ( } /** - This function allocates space for a new copy of the device path - specified by DevicePath. + Creates a new device path by appending a second device path to a first device path. - @param DevicePath A pointer to a device path data structure. + This function allocates space for a new copy of the device path specified by DevicePath. If + DevicePath is NULL, then NULL is returned. If the memory is successfully allocated, then the + contents of DevicePath are copied to the newly allocated buffer, and a pointer to that buffer + is returned. Otherwise, NULL is returned. + + @param DevicePath A pointer to a device path data structure. - @return The duplicated device path. + @return A pointer to the duplicated device path. **/ EFI_DEVICE_PATH_PROTOCOL * EFIAPI DuplicateDevicePath ( - IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath + IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath ) { EFI_DEVICE_PATH_PROTOCOL *NewDevicePath; @@ -92,24 +97,29 @@ DuplicateDevicePath ( } /** - This function appends the device path SecondDevicePath - to every device path instance in FirstDevicePath. + Creates a new device path by appending a second device path to a first device path. - @param FirstDevicePath A pointer to a device path data structure. - - @param SecondDevicePath A pointer to a device path data structure. + This function creates a new device path by appending a copy of SecondDevicePath to a copy of + FirstDevicePath in a newly allocated buffer. Only the end-of-device-path device node from + SecondDevicePath is retained. The newly created device path is returned. + If FirstDevicePath is NULL, then it is ignored, and a duplicate of SecondDevicePath is returned. + If SecondDevicePath is NULL, then it is ignored, and a duplicate of FirstDevicePath is returned. + If both FirstDevicePath and SecondDevicePath are NULL, then NULL is returned. + If there is not enough memory for the newly allocated buffer, then NULL is returned. + The memory for the new device path is allocated from EFI boot services memory. It is the + responsibility of the caller to free the memory allocated. - @return A pointer to the new device path is returned. - NULL is returned if space for the new device path could not be allocated from pool. - It is up to the caller to free the memory used by FirstDevicePath and SecondDevicePath - if they are no longer needed. + @param FirstDevicePath A pointer to a device path data structure. + @param SecondDevicePath A pointer to a device path data structure. + + @return A pointer to the new device path. **/ EFI_DEVICE_PATH_PROTOCOL * EFIAPI AppendDevicePath ( - IN CONST EFI_DEVICE_PATH_PROTOCOL *FirstDevicePath, - IN CONST EFI_DEVICE_PATH_PROTOCOL *SecondDevicePath + IN CONST EFI_DEVICE_PATH_PROTOCOL *FirstDevicePath, OPTIONAL + IN CONST EFI_DEVICE_PATH_PROTOCOL *SecondDevicePath OPTIONAL ) { UINTN Size; @@ -119,7 +129,7 @@ AppendDevicePath ( EFI_DEVICE_PATH_PROTOCOL *DevicePath2; // - // If there's only 1 path, just duplicate it + // If there's only 1 path, just duplicate it. // if (FirstDevicePath == NULL) { return DuplicateDevicePath (SecondDevicePath); @@ -131,7 +141,7 @@ AppendDevicePath ( // // Allocate space for the combined device path. It only has one end node of - // length EFI_DEVICE_PATH_PROTOCOL + // length EFI_DEVICE_PATH_PROTOCOL. // Size1 = GetDevicePathSize (FirstDevicePath); Size2 = GetDevicePathSize (SecondDevicePath); @@ -142,9 +152,10 @@ AppendDevicePath ( if (NewDevicePath != NULL) { NewDevicePath = CopyMem (NewDevicePath, FirstDevicePath, Size1); // - // Over write Src1 EndNode and do the copy + // Over write FirstDevicePath EndNode and do the copy // - DevicePath2 = (EFI_DEVICE_PATH_PROTOCOL *) ((CHAR8 *) NewDevicePath + (Size1 - sizeof (EFI_DEVICE_PATH_PROTOCOL))); + DevicePath2 = (EFI_DEVICE_PATH_PROTOCOL *) ((CHAR8 *) NewDevicePath + + (Size1 - sizeof (EFI_DEVICE_PATH_PROTOCOL))); CopyMem (DevicePath2, SecondDevicePath, Size2); } @@ -152,23 +163,28 @@ AppendDevicePath ( } /** - This function appends the device path node SecondDevicePath - to every device path instance in FirstDevicePath. + Creates a new path by appending the device node to the device path. - @param DevicePath A pointer to a device path data structure. - - @param DevicePathNode A pointer to a single device path node. + This function creates a new device path by appending a copy of the device node specified by + DevicePathNode to a copy of the device path specified by DevicePath in an allocated buffer. + The end-of-device-path device node is moved after the end of the appended device node. + If DevicePath is NULL, then NULL is returned. + If DevicePathNode is NULL, then NULL is returned. + If there is not enough memory to allocate space for the new device path, then NULL is returned. + The memory is allocated from EFI boot services memory. It is the responsibility of the caller to + free the memory allocated. + + @param DevicePath A pointer to a device path data structure. + @param DevicePathNode A pointer to a single device path node. @return A pointer to the new device path. - If there is not enough temporary pool memory available to complete this function, - then NULL is returned. **/ EFI_DEVICE_PATH_PROTOCOL * EFIAPI AppendDevicePathNode ( - IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath, - IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePathNode + IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath, OPTIONAL + IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePathNode OPTIONAL ) { EFI_DEVICE_PATH_PROTOCOL *TempDevicePath; @@ -176,6 +192,9 @@ AppendDevicePathNode ( EFI_DEVICE_PATH_PROTOCOL *NewDevicePath; UINTN NodeLength; + if (DevicePath == NULL || DevicePathNode == NULL) { + return NULL; + } // // Build a Node that has a terminator on it // @@ -202,81 +221,103 @@ AppendDevicePathNode ( } /** - This function appends the device path instance Instance to the device path Source. - If Source is NULL, then a new device path with one instance is created. - - @param Source A pointer to a device path data structure. - @param Instance A pointer to a device path instance. + Creates a new device path by appending the specified device path instance to the specified device + path. + + This function creates a new device path by appending a copy of the device path instance specified + by DevicePathInstance to a copy of the device path secified by DevicePath in a allocated buffer. + The end-of-device-path device node is moved after the end of the appended device path instance + and a new end-of-device-path-instance node is inserted between. + If DevicePath is NULL, then a copy if DevicePathInstance is returned. + If DevicePathInstance is NULL, then NULL is returned. + If there is not enough memory to allocate space for the new device path, then NULL is returned. + The memory is allocated from EFI boot services memory. It is the responsibility of the caller to + free the memory allocated. + + @param DevicePath A pointer to a device path data structure. + @param DevicePathInstance A pointer to a device path instance. @return A pointer to the new device path. - If there is not enough temporary pool memory available to complete this function, - then NULL is returned. **/ EFI_DEVICE_PATH_PROTOCOL * EFIAPI AppendDevicePathInstance ( - IN CONST EFI_DEVICE_PATH_PROTOCOL *Source, - IN CONST EFI_DEVICE_PATH_PROTOCOL *Instance + IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath, OPTIONAL + IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePathInstance OPTIONAL ) { EFI_DEVICE_PATH_PROTOCOL *NewDevicePath; - EFI_DEVICE_PATH_PROTOCOL *DevicePath; + EFI_DEVICE_PATH_PROTOCOL *TempDevicePath; UINTN SrcSize; UINTN InstanceSize; - if (Source == NULL) { - return DuplicateDevicePath (Instance); + if (DevicePath == NULL) { + return DuplicateDevicePath (DevicePathInstance); + } + + if (DevicePathInstance == NULL) { + return NULL; } - SrcSize = GetDevicePathSize (Source); - InstanceSize = GetDevicePathSize (Instance); + SrcSize = GetDevicePathSize (DevicePath); + InstanceSize = GetDevicePathSize (DevicePathInstance); NewDevicePath = AllocatePool (SrcSize + InstanceSize); if (NewDevicePath != NULL) { - DevicePath = CopyMem (NewDevicePath, Source, SrcSize);; + TempDevicePath = CopyMem (NewDevicePath, DevicePath, SrcSize);; - while (!IsDevicePathEnd (DevicePath)) { - DevicePath = NextDevicePathNode (DevicePath); + while (!IsDevicePathEnd (TempDevicePath)) { + TempDevicePath = NextDevicePathNode (TempDevicePath); } - DevicePath->SubType = END_INSTANCE_DEVICE_PATH_SUBTYPE; - - DevicePath = NextDevicePathNode (DevicePath); - CopyMem (DevicePath, Instance, InstanceSize); + TempDevicePath->SubType = END_INSTANCE_DEVICE_PATH_SUBTYPE; + TempDevicePath = NextDevicePathNode (TempDevicePath); + CopyMem (TempDevicePath, DevicePathInstance, InstanceSize); } return NewDevicePath; } /** - Function retrieves the next device path instance from a device path data structure. - - @param DevicePath A pointer to a device path data structure. - - @param Size A pointer to the size of a device path instance in bytes. + Creates a copy of the current device path instance and returns a pointer to the next device path + instance. + + This function creates a copy of the current device path instance. It also updates DevicePath to + point to the next device path instance in the device path (or NULL if no more) and updates Size + to hold the size of the device path instance copy. + If DevicePath is NULL, then NULL is returned. + If there is not enough memory to allocate space for the new device path, then NULL is returned. + The memory is allocated from EFI boot services memory. It is the responsibility of the caller to + free the memory allocated. + If Size is NULL, then ASSERT(). + + @param DevicePath On input, this holds the pointer to the current device path + instance. On output, this holds the pointer to the next device + path instance or NULL if there are no more device path + instances in the device path pointer to a device path data + structure. + @param Size On output, this holds the size of the device path instance, in + bytes or zero, if DevicePath is NULL. - @return This function returns a pointer to the current device path instance. - In addition, it returns the size in bytes of the current device path instance in Size, - and a pointer to the next device path instance in DevicePath. - If there are no more device path instances in DevicePath, then DevicePath will be set to NULL. + @return A pointer to the current device path instance. **/ EFI_DEVICE_PATH_PROTOCOL * EFIAPI GetNextDevicePathInstance ( - IN OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath, - OUT UINTN *Size + IN OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath, + OUT UINTN *Size ) { EFI_DEVICE_PATH_PROTOCOL *DevPath; EFI_DEVICE_PATH_PROTOCOL *ReturnValue; UINT8 Temp; - ASSERT (DevicePath != NULL); ASSERT (Size != NULL); - if (*DevicePath == NULL) { + + if (DevicePath == NULL || *DevicePath == NULL) { *Size = 0; return NULL; } @@ -316,12 +357,60 @@ GetNextDevicePathInstance ( } /** - Return TRUE is this is a multi instance device path. + Creates a copy of the current device path instance and returns a pointer to the next device path + instance. + + This function creates a new device node in a newly allocated buffer of size NodeLength and + initializes the device path node header with NodeType and NodeSubType. The new device path node + is returned. + If NodeLength is smaller than a device path header, then NULL is returned. + If there is not enough memory to allocate space for the new device path, then NULL is returned. + The memory is allocated from EFI boot services memory. It is the responsibility of the caller to + free the memory allocated. + + @param NodeType The device node type for the new device node. + @param NodeSubType The device node sub-type for the new device node. + @param NodeLength The length of the new device node. + + @return The new device path. + +**/ +EFI_DEVICE_PATH_PROTOCOL * +EFIAPI +CreateDeviceNode ( + IN UINT8 NodeType, + IN UINT8 NodeSubType, + IN UINT16 NodeLength + ) +{ + EFI_DEVICE_PATH_PROTOCOL *DevicePath; + + if (NodeLength < sizeof (EFI_DEVICE_PATH_PROTOCOL)) { + // + // NodeLength is less than the size of the header. + // + return NULL; + } + + DevicePath = AllocatePool (NodeLength); + if (DevicePath != NULL) { + DevicePath->Type = NodeType; + DevicePath->SubType = NodeSubType; + } + + return DevicePath; +} + +/** + Determines if a device path is single or multi-instance. + + This function returns TRUE if the device path specified by DevicePath is multi-instance. + Otherwise, FALSE is returned. If DevicePath is NULL, then FALSE is returned. - @param DevicePath A pointer to a device path data structure. + @param DevicePath A pointer to a device path data structure. - @retval TRUE If DevicePath is multi-instance. - @retval FALSE If DevicePath is not multi-instance or DevicePath is NULL. + @retval TRUE DevicePath is multi-instance. + @retval FALSE DevicePath is not multi-instance or DevicePath is NULL. **/ BOOLEAN @@ -330,7 +419,7 @@ IsDevicePathMultiInstance ( IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath ) { - CONST EFI_DEVICE_PATH_PROTOCOL *Node; + CONST EFI_DEVICE_PATH_PROTOCOL *Node; if (DevicePath == NULL) { return FALSE; @@ -348,19 +437,22 @@ IsDevicePathMultiInstance ( return FALSE; } + /** - This function retrieves the device path protocol from a handle. + Retrieves the device path protocol from a handle. - @param Handle The handle from which to retrieve the device path protocol. + This function returns the device path protocol from the handle specified by Handle. If Handle is + NULL or Handle does not contain a device path protocol, then NULL is returned. + + @param Handle The handle from which to retrieve the device path protocol. - @return This function returns the device path protocol from the handle specified by Handle. - If Handle is NULL or Handle does not contain a device path protocol, then NULL is returned. + @return The device path protocol from the handle specified by Handle. **/ EFI_DEVICE_PATH_PROTOCOL * EFIAPI DevicePathFromHandle ( - IN EFI_HANDLE Handle + IN EFI_HANDLE Handle ) { EFI_DEVICE_PATH_PROTOCOL *DevicePath; @@ -378,54 +470,52 @@ DevicePathFromHandle ( } /** - This function allocates a device path for a file and appends it to an existing device path. + Allocates a device path for a file and appends it to an existing device path. - @param Device A pointer to a device handle. This parameter is optional and may be NULL. - @param FileName A pointer to a Null-terminated Unicode string. + If Device is a valid device handle that contains a device path protocol, then a device path for + the file specified by FileName is allocated and appended to the device path associated with the + handle Device. The allocated device path is returned. If Device is NULL or Device is a handle + that does not support the device path protocol, then a device path containing a single device + path node for the file specified by FileName is allocated and returned. + If FileName is NULL, then ASSERT(). - @return If Device is a valid device handle that contains a device path protocol, - then a device path for the file specified by FileName is allocated - and appended to the device path associated with the handle Device. The allocated device path is returned. - If Device is NULL or Device is a handle that does not support the device path protocol, - then a device path containing a single device path node for the file specified by FileName - is allocated and returned. + @param Device A pointer to a device handle. This parameter is optional and + may be NULL. + @param FileName A pointer to a Null-terminated Unicode string. + + @return The allocated device path. **/ EFI_DEVICE_PATH_PROTOCOL * EFIAPI FileDevicePath ( - IN EFI_HANDLE Device, OPTIONAL - IN CONST CHAR16 *FileName + IN EFI_HANDLE Device, OPTIONAL + IN CONST CHAR16 *FileName ) { - UINTN FileNameSize; - UINTN FilePathNodeSize; - FILEPATH_DEVICE_PATH *FilePathNode; + UINTN Size; + FILEPATH_DEVICE_PATH *FilePath; EFI_DEVICE_PATH_PROTOCOL *DevicePath; - - DevicePath = NULL; - - FileNameSize = StrSize (FileName); - FilePathNodeSize = FileNameSize + SIZE_OF_FILEPATH_DEVICE_PATH; - FilePathNode = AllocatePool (FilePathNodeSize); - if (FilePathNode != NULL) { - // - // Build a file path node - // - FilePathNode->Header.Type = MEDIA_DEVICE_PATH; - FilePathNode->Header.SubType = MEDIA_FILEPATH_DP; - SetDevicePathNodeLength (&FilePathNode->Header, FilePathNodeSize); - CopyMem (FilePathNode->PathName, FileName, FileNameSize); - - // - // Append file path node to device's device path - // + EFI_DEVICE_PATH_PROTOCOL *FileDevicePathNode; + + DevicePath = NULL; + + Size = StrSize (FileName); + FileDevicePathNode = CreateDeviceNode ( + MEDIA_DEVICE_PATH, + MEDIA_FILEPATH_DP, + (UINT16) (Size + SIZE_OF_FILEPATH_DEVICE_PATH) + ); + if (FileDevicePathNode != NULL) { + FilePath = (FILEPATH_DEVICE_PATH *) FileDevicePathNode; + CopyMem (&FilePath->PathName, FileName, Size); if (Device != NULL) { DevicePath = DevicePathFromHandle (Device); } - DevicePath = AppendDevicePathNode (DevicePath, (EFI_DEVICE_PATH_PROTOCOL *) FilePathNode); - FreePool (FilePathNode); + DevicePath = AppendDevicePathNode (DevicePath, FileDevicePathNode); + FreePool (FileDevicePathNode); } + return DevicePath; } diff --git a/MdePkg/Library/UefiDevicePathLibDevicePathProtocol/UefiDevicePathLib.c b/MdePkg/Library/UefiDevicePathLibDevicePathProtocol/UefiDevicePathLib.c index aea75aa496..ec4325cf39 100644 --- a/MdePkg/Library/UefiDevicePathLibDevicePathProtocol/UefiDevicePathLib.c +++ b/MdePkg/Library/UefiDevicePathLibDevicePathProtocol/UefiDevicePathLib.c @@ -49,11 +49,12 @@ DevicePathLibConstructor ( } /** - This function returns the size, in bytes, - of the device path data structure specified by DevicePath. - If DevicePath is NULL, then 0 is returned. + Returns the size of a device path in bytes. - @param DevicePath A pointer to a device path data structure. + This function returns the size, in bytes, of the device path data structure specified by + DevicePath including the end of device path node. If DevicePath is NULL, then 0 is returned. + + @param DevicePath A pointer to a device path data structure. @return The size of a device path in bytes. @@ -68,124 +69,189 @@ GetDevicePathSize ( } /** - This function allocates space for a new copy of the device path - specified by DevicePath. + Creates a new device path by appending a second device path to a first device path. - @param DevicePath A pointer to a device path data structure. + This function allocates space for a new copy of the device path specified by DevicePath. If + DevicePath is NULL, then NULL is returned. If the memory is successfully allocated, then the + contents of DevicePath are copied to the newly allocated buffer, and a pointer to that buffer + is returned. Otherwise, NULL is returned. + + @param DevicePath A pointer to a device path data structure. - @return The duplicated device path. + @return A pointer to the duplicated device path. **/ EFI_DEVICE_PATH_PROTOCOL * EFIAPI DuplicateDevicePath ( - IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath + IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath ) { return mDevicePathUtilities->DuplicateDevicePath (DevicePath); } /** - This function appends the device path SecondDevicePath - to every device path instance in FirstDevicePath. + Creates a new device path by appending a second device path to a first device path. - @param FirstDevicePath A pointer to a device path data structure. - - @param SecondDevicePath A pointer to a device path data structure. + This function creates a new device path by appending a copy of SecondDevicePath to a copy of + FirstDevicePath in a newly allocated buffer. Only the end-of-device-path device node from + SecondDevicePath is retained. The newly created device path is returned. + If FirstDevicePath is NULL, then it is ignored, and a duplicate of SecondDevicePath is returned. + If SecondDevicePath is NULL, then it is ignored, and a duplicate of FirstDevicePath is returned. + If both FirstDevicePath and SecondDevicePath are NULL, then NULL is returned. + If there is not enough memory for the newly allocated buffer, then NULL is returned. + The memory for the new device path is allocated from EFI boot services memory. It is the + responsibility of the caller to free the memory allocated. - @return A pointer to the new device path is returned. - NULL is returned if space for the new device path could not be allocated from pool. - It is up to the caller to free the memory used by FirstDevicePath and SecondDevicePath - if they are no longer needed. + @param FirstDevicePath A pointer to a device path data structure. + @param SecondDevicePath A pointer to a device path data structure. + + @return A pointer to the new device path. **/ EFI_DEVICE_PATH_PROTOCOL * EFIAPI AppendDevicePath ( - IN CONST EFI_DEVICE_PATH_PROTOCOL *FirstDevicePath, - IN CONST EFI_DEVICE_PATH_PROTOCOL *SecondDevicePath + IN CONST EFI_DEVICE_PATH_PROTOCOL *FirstDevicePath, OPTIONAL + IN CONST EFI_DEVICE_PATH_PROTOCOL *SecondDevicePath OPTIONAL ) { return mDevicePathUtilities->AppendDevicePath (FirstDevicePath, SecondDevicePath); } /** - This function appends the device path node SecondDevicePath - to every device path instance in FirstDevicePath. + Creates a new path by appending the device node to the device path. - @param FirstDevicePath A pointer to a device path data structure. - - @param SecondDevicePath A pointer to a single device path node. + This function creates a new device path by appending a copy of the device node specified by + DevicePathNode to a copy of the device path specified by DevicePath in an allocated buffer. + The end-of-device-path device node is moved after the end of the appended device node. + If DevicePath is NULL, then NULL is returned. + If DevicePathNode is NULL, then NULL is returned. + If there is not enough memory to allocate space for the new device path, then NULL is returned. + The memory is allocated from EFI boot services memory. It is the responsibility of the caller to + free the memory allocated. + + @param DevicePath A pointer to a device path data structure. + @param DevicePathNode A pointer to a single device path node. @return A pointer to the new device path. - If there is not enough temporary pool memory available to complete this function, - then NULL is returned. **/ EFI_DEVICE_PATH_PROTOCOL * EFIAPI AppendDevicePathNode ( - IN CONST EFI_DEVICE_PATH_PROTOCOL *FirstDevicePath, - IN CONST EFI_DEVICE_PATH_PROTOCOL *SecondDevicePath + IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath, OPTIONAL + IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePathNode OPTIONAL ) { - return mDevicePathUtilities->AppendDeviceNode (FirstDevicePath, SecondDevicePath); + return mDevicePathUtilities->AppendDeviceNode (DevicePath, DevicePathNode); } /** - This function appends the device path instance Instance to the device path Source. - If Source is NULL, then a new device path with one instance is created. - - @param Source A pointer to a device path data structure. - @param Instance A pointer to a device path instance. + Creates a new device path by appending the specified device path instance to the specified device + path. + + This function creates a new device path by appending a copy of the device path instance specified + by DevicePathInstance to a copy of the device path secified by DevicePath in a allocated buffer. + The end-of-device-path device node is moved after the end of the appended device path instance + and a new end-of-device-path-instance node is inserted between. + If DevicePath is NULL, then a copy if DevicePathInstance is returned. + If DevicePathInstance is NULL, then NULL is returned. + If there is not enough memory to allocate space for the new device path, then NULL is returned. + The memory is allocated from EFI boot services memory. It is the responsibility of the caller to + free the memory allocated. + + @param DevicePath A pointer to a device path data structure. + @param DevicePathInstance A pointer to a device path instance. @return A pointer to the new device path. - If there is not enough temporary pool memory available to complete this function, - then NULL is returned. **/ EFI_DEVICE_PATH_PROTOCOL * EFIAPI AppendDevicePathInstance ( - IN CONST EFI_DEVICE_PATH_PROTOCOL *Source, - IN CONST EFI_DEVICE_PATH_PROTOCOL *Instance + IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath, OPTIONAL + IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePathInstance OPTIONAL ) { - return mDevicePathUtilities->AppendDevicePathInstance (Source, Instance); + return mDevicePathUtilities->AppendDevicePathInstance (DevicePath, DevicePathInstance); } /** - Function retrieves the next device path instance from a device path data structure. - - @param DevicePath A pointer to a device path data structure. - - @param Size A pointer to the size of a device path instance in bytes. - - @return This function returns a pointer to the current device path instance. - In addition, it returns the size in bytes of the current device path instance in Size, - and a pointer to the next device path instance in DevicePath. - If there are no more device path instances in DevicePath, then DevicePath will be set to NULL. + Creates a copy of the current device path instance and returns a pointer to the next device path + instance. + + This function creates a copy of the current device path instance. It also updates DevicePath to + point to the next device path instance in the device path (or NULL if no more) and updates Size + to hold the size of the device path instance copy. + If DevicePath is NULL, then NULL is returned. + If there is not enough memory to allocate space for the new device path, then NULL is returned. + The memory is allocated from EFI boot services memory. It is the responsibility of the caller to + free the memory allocated. + If Size is NULL, then ASSERT(). + + @param DevicePath On input, this holds the pointer to the current device path + instance. On output, this holds the pointer to the next device + path instance or NULL if there are no more device path + instances in the device path pointer to a device path data + structure. + @param Size On output, this holds the size of the device path instance, in + bytes or zero, if DevicePath is NULL. + + @return A pointer to the current device path instance. **/ EFI_DEVICE_PATH_PROTOCOL * EFIAPI GetNextDevicePathInstance ( - IN OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath, - OUT UINTN *Size + IN OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath, + OUT UINTN *Size ) { - ASSERT (DevicePath != NULL); ASSERT (Size != NULL); return mDevicePathUtilities->GetNextDevicePathInstance (DevicePath, Size); } /** - Return TRUE is this is a multi instance device path. + Creates a copy of the current device path instance and returns a pointer to the next device path + instance. + + This function creates a new device node in a newly allocated buffer of size NodeLength and + initializes the device path node header with NodeType and NodeSubType. The new device path node + is returned. + If NodeLength is smaller than a device path header, then NULL is returned. + If there is not enough memory to allocate space for the new device path, then NULL is returned. + The memory is allocated from EFI boot services memory. It is the responsibility of the caller to + free the memory allocated. + + @param NodeType The device node type for the new device node. + @param NodeSubType The device node sub-type for the new device node. + @param NodeLength The length of the new device node. + + @return The new device path. + +**/ +EFI_DEVICE_PATH_PROTOCOL * +EFIAPI +CreateDeviceNode ( + IN UINT8 NodeType, + IN UINT8 NodeSubType, + IN UINT16 NodeLength + ) +{ + return mDevicePathUtilities->CreateDeviceNode (NodeType, NodeSubType, NodeLength); +} + +/** + Determines if a device path is single or multi-instance. - @param DevicePath A pointer to a device path data structure. + This function returns TRUE if the device path specified by DevicePath is multi-instance. + Otherwise, FALSE is returned. If DevicePath is NULL, then FALSE is returned. - @retval TRUE If DevicePath is multi-instance. - @retval FALSE If DevicePath is not multi-instance or DevicePath is NULL. + @param DevicePath A pointer to a device path data structure. + + @retval TRUE DevicePath is multi-instance. + @retval FALSE DevicePath is not multi-instance or DevicePath is NULL. **/ BOOLEAN @@ -198,18 +264,20 @@ IsDevicePathMultiInstance ( } /** - This function retrieves the device path protocol from a handle. + Retrieves the device path protocol from a handle. - @param Handle The handle from which to retrieve the device path protocol. + This function returns the device path protocol from the handle specified by Handle. If Handle is + NULL or Handle does not contain a device path protocol, then NULL is returned. + + @param Handle The handle from which to retrieve the device path protocol. - @return This function returns the device path protocol from the handle specified by Handle. - If Handle is NULL or Handle does not contain a device path protocol, then NULL is returned. + @return The device path protocol from the handle specified by Handle. **/ EFI_DEVICE_PATH_PROTOCOL * EFIAPI DevicePathFromHandle ( - IN EFI_HANDLE Handle + IN EFI_HANDLE Handle ) { EFI_DEVICE_PATH_PROTOCOL *DevicePath; @@ -227,24 +295,27 @@ DevicePathFromHandle ( } /** - This function allocates a device path for a file and appends it to an existing device path. + Allocates a device path for a file and appends it to an existing device path. + + If Device is a valid device handle that contains a device path protocol, then a device path for + the file specified by FileName is allocated and appended to the device path associated with the + handle Device. The allocated device path is returned. If Device is NULL or Device is a handle + that does not support the device path protocol, then a device path containing a single device + path node for the file specified by FileName is allocated and returned. + If FileName is NULL, then ASSERT(). - @param Device A pointer to a device handle. This parameter is optional and may be NULL. - @param FileName A pointer to a Null-terminated Unicode string. + @param Device A pointer to a device handle. This parameter is optional and + may be NULL. + @param FileName A pointer to a Null-terminated Unicode string. - @return If Device is a valid device handle that contains a device path protocol, - then a device path for the file specified by FileName is allocated - and appended to the device path associated with the handle Device. The allocated device path is returned. - If Device is NULL or Device is a handle that does not support the device path protocol, - then a device path containing a single device path node for the file specified by FileName - is allocated and returned. + @return The allocated device path. **/ EFI_DEVICE_PATH_PROTOCOL * EFIAPI FileDevicePath ( - IN EFI_HANDLE Device, OPTIONAL - IN CONST CHAR16 *FileName + IN EFI_HANDLE Device, OPTIONAL + IN CONST CHAR16 *FileName ) { UINTN Size; @@ -255,11 +326,11 @@ FileDevicePath ( DevicePath = NULL; Size = StrSize (FileName); - FileDevicePathNode = mDevicePathUtilities->CreateDeviceNode ( - MEDIA_DEVICE_PATH, - MEDIA_FILEPATH_DP, - (UINT16) (Size + SIZE_OF_FILEPATH_DEVICE_PATH) - ); + FileDevicePathNode = CreateDeviceNode ( + MEDIA_DEVICE_PATH, + MEDIA_FILEPATH_DP, + (UINT16) (Size + SIZE_OF_FILEPATH_DEVICE_PATH) + ); if (FileDevicePathNode != NULL) { FilePath = (FILEPATH_DEVICE_PATH *) FileDevicePathNode; CopyMem (&FilePath->PathName, FileName, Size); @@ -269,6 +340,7 @@ FileDevicePath ( DevicePath = AppendDevicePathNode (DevicePath, FileDevicePathNode); FreePool (FileDevicePathNode); } + return DevicePath; } diff --git a/MdePkg/MdePkg.spd b/MdePkg/MdePkg.spd index bb3271035e..0c98aef5fb 100644 --- a/MdePkg/MdePkg.spd +++ b/MdePkg/MdePkg.spd @@ -237,7 +237,7 @@ Library/UefiDriverEntryPoint/UefiDriverEntryPoint.msa Library/UefiDriverModelLib/UefiDriverModelLib.msa Library/UefiLib/UefiLib.msa - Library/UefiMemoryLib/UefiMemoryLib.msa + Library/DxeMemoryLib/DxeMemoryLib.msa Library/UefiRuntimeServicesTableLib/UefiRuntimeServicesTableLib.msa