From 5f10fa0140f7100aa04c12f87d63a66755d20d58 Mon Sep 17 00:00:00 2001 From: qhuang8 Date: Thu, 11 May 2006 07:19:55 +0000 Subject: *BaseSmbusLib: (new version) Complete function header, detailed description, ASSERT()s & pass smoke test in MRC of Lakeport package by replacing Smbus PPI. *Device Patch Lib Fix a bug in AppendDevicePathNode() (Solve Track #44 in Remodel PVCS). The original logic failed if the first device path was NULL. *Performance Lib Add PeiPerformanceHob & Performance protocol in spd file in EdkModule Package (Solve Tracker #41, #42 in Remodel PVCS). *Hob Lib Add detailed description for each Hob function. git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@126 6f19259b-4bc3-4df7-8a09-765794883524 --- .../Library/UefiDevicePathLib/UefiDevicePathLib.c | 47 ++++++++++------------ 1 file changed, 22 insertions(+), 25 deletions(-) (limited to 'MdePkg/Library/UefiDevicePathLib') diff --git a/MdePkg/Library/UefiDevicePathLib/UefiDevicePathLib.c b/MdePkg/Library/UefiDevicePathLib/UefiDevicePathLib.c index 8dc84f48b7..1b1376e2cf 100644 --- a/MdePkg/Library/UefiDevicePathLib/UefiDevicePathLib.c +++ b/MdePkg/Library/UefiDevicePathLib/UefiDevicePathLib.c @@ -155,9 +155,9 @@ AppendDevicePath ( This function appends the device path node SecondDevicePath to every device path instance in FirstDevicePath. - @param FirstDevicePath A pointer to a device path data structure. + @param DevicePath A pointer to a device path data structure. - @param SecondDevicePath A pointer to a single device path node. + @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, @@ -167,40 +167,37 @@ AppendDevicePath ( 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, + IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePathNode ) { + EFI_DEVICE_PATH_PROTOCOL *TempDevicePath; EFI_DEVICE_PATH_PROTOCOL *NextNode; EFI_DEVICE_PATH_PROTOCOL *NewDevicePath; UINTN NodeLength; - UINTN Size1; // // Build a Node that has a terminator on it // - NodeLength = DevicePathNodeLength (SecondDevicePath); - Size1 = GetDevicePathSize (FirstDevicePath); - - NewDevicePath = AllocatePool (NodeLength + Size1); - if (NewDevicePath != NULL) { - // - // Copy the first device path to the new device path - // - NewDevicePath = CopyMem (NewDevicePath, FirstDevicePath, Size1); - - // - // Copy the device path node to the new device path - // - NextNode = (EFI_DEVICE_PATH_PROTOCOL *) ((CHAR8 *) NewDevicePath + (Size1 - sizeof (EFI_DEVICE_PATH_PROTOCOL))); - NextNode = CopyMem (NextNode, SecondDevicePath, NodeLength); + NodeLength = DevicePathNodeLength (DevicePathNode); - // - // Terminate the whole device path - // - NextNode = NextDevicePathNode (NextNode); - SetDevicePathEndNode (NextNode); + TempDevicePath = AllocatePool (NodeLength + sizeof (EFI_DEVICE_PATH_PROTOCOL)); + if (TempDevicePath == NULL) { + return NULL; } + TempDevicePath = CopyMem (TempDevicePath, DevicePathNode, NodeLength); + // + // Add and end device path node to convert Node to device path + // + NextNode = NextDevicePathNode (TempDevicePath); + SetDevicePathEndNode (NextNode); + // + // Append device paths + // + NewDevicePath = AppendDevicePath (DevicePath, TempDevicePath); + + FreePool (TempDevicePath); + return NewDevicePath; } -- cgit v1.2.3