From f008fc323b7ea9bcb0e29a804611a3cc99149121 Mon Sep 17 00:00:00 2001 From: klu2 Date: Tue, 9 Sep 2008 04:41:59 +0000 Subject: [PATCH] Code cleanup for library instances in MdePkg. git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@5856 6f19259b-4bc3-4df7-8a09-765794883524 --- .../Library/PeiPalCallLib/PeiPalCallLib.inf | 2 +- .../UefiDevicePathLib/UefiDevicePathLib.c | 16 ++++---- .../UefiDevicePathLib/UefiDevicePathLib.inf | 4 +- .../UefiDevicePathLib.c | 9 ++--- .../UefiDevicePathLibInternal.h | 38 ------------------- 5 files changed, 14 insertions(+), 55 deletions(-) delete mode 100644 MdePkg/Library/UefiDevicePathLibDevicePathProtocol/UefiDevicePathLibInternal.h diff --git a/MdePkg/Library/PeiPalCallLib/PeiPalCallLib.inf b/MdePkg/Library/PeiPalCallLib/PeiPalCallLib.inf index 046e80cda2..b3632564dd 100644 --- a/MdePkg/Library/PeiPalCallLib/PeiPalCallLib.inf +++ b/MdePkg/Library/PeiPalCallLib/PeiPalCallLib.inf @@ -22,7 +22,7 @@ FILE_GUID = B53DC524-6B98-4584-940B-8F1363DEF09E MODULE_TYPE = PEIM VERSION_STRING = 1.0 - LIBRARY_CLASS = PalCallLib + LIBRARY_CLASS = PalCallLib|PEI_CORE PEIM SEC EDK_RELEASE_VERSION = 0x00020000 EFI_SPECIFICATION_VERSION = 0x00020000 diff --git a/MdePkg/Library/UefiDevicePathLib/UefiDevicePathLib.c b/MdePkg/Library/UefiDevicePathLib/UefiDevicePathLib.c index 83372e86d4..91d77f5fcb 100644 --- a/MdePkg/Library/UefiDevicePathLib/UefiDevicePathLib.c +++ b/MdePkg/Library/UefiDevicePathLib/UefiDevicePathLib.c @@ -77,7 +77,7 @@ GetDevicePathSize ( // // Compute the size and add back in the size of the end device path structure // - return ((UINTN) DevicePath - (UINTN) Start) + sizeof (EFI_DEVICE_PATH_PROTOCOL); + return ((UINTN) DevicePath - (UINTN) Start) + EfiDevicePathNodeLength (DevicePath); } /** @@ -99,7 +99,6 @@ DuplicateDevicePath ( IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath ) { - EFI_DEVICE_PATH_PROTOCOL *NewDevicePath; UINTN Size; // @@ -113,9 +112,8 @@ DuplicateDevicePath ( // // Allocate space for duplicate device path // - NewDevicePath = AllocateCopyPool (Size, DevicePath); - return NewDevicePath; + return AllocateCopyPool (Size, DevicePath); } /** @@ -168,7 +166,7 @@ AppendDevicePath ( // Size1 = GetDevicePathSize (FirstDevicePath); Size2 = GetDevicePathSize (SecondDevicePath); - Size = Size1 + Size2 - sizeof (EFI_DEVICE_PATH_PROTOCOL); + Size = Size1 + Size2 - EFI_END_DEVICE_PATH_LENGTH; NewDevicePath = AllocatePool (Size); @@ -178,7 +176,7 @@ AppendDevicePath ( // Over write FirstDevicePath EndNode and do the copy // DevicePath2 = (EFI_DEVICE_PATH_PROTOCOL *) ((CHAR8 *) NewDevicePath + - (Size1 - sizeof (EFI_DEVICE_PATH_PROTOCOL))); + (Size1 - EFI_END_DEVICE_PATH_LENGTH)); CopyMem (DevicePath2, SecondDevicePath, Size2); } @@ -226,7 +224,7 @@ AppendDevicePathNode ( // NodeLength = DevicePathNodeLength (DevicePathNode); - TempDevicePath = AllocatePool (NodeLength + sizeof (EFI_DEVICE_PATH_PROTOCOL)); + TempDevicePath = AllocatePool (NodeLength + EFI_END_DEVICE_PATH_LENGTH); if (TempDevicePath == NULL) { return NULL; } @@ -398,7 +396,7 @@ GetNextDevicePathInstance ( @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. + @return A pointer to the new create device path. **/ EFI_DEVICE_PATH_PROTOCOL * @@ -510,7 +508,7 @@ DevicePathFromHandle ( may be NULL. @param FileName A pointer to a Null-terminated Unicode string. - @return The allocated device path. + @return A pointer to the new created file device path. **/ EFI_DEVICE_PATH_PROTOCOL * diff --git a/MdePkg/Library/UefiDevicePathLib/UefiDevicePathLib.inf b/MdePkg/Library/UefiDevicePathLib/UefiDevicePathLib.inf index f0cd5e2e34..2ec381d262 100644 --- a/MdePkg/Library/UefiDevicePathLib/UefiDevicePathLib.inf +++ b/MdePkg/Library/UefiDevicePathLib/UefiDevicePathLib.inf @@ -1,7 +1,7 @@ #/** @file -# Component description file for the entry point to a EFIDXE Drivers +# Library instance implement the library class UefiDevicePathLib defined in Mde +# library specification. # -# Library to abstract Framework extensions that conflict with UEFI 2.0 Specification # Copyright (c) 2007, Intel Corporation # # All rights reserved. This program and the accompanying materials diff --git a/MdePkg/Library/UefiDevicePathLibDevicePathProtocol/UefiDevicePathLib.c b/MdePkg/Library/UefiDevicePathLibDevicePathProtocol/UefiDevicePathLib.c index 607a701dd7..a1a8650f0d 100644 --- a/MdePkg/Library/UefiDevicePathLibDevicePathProtocol/UefiDevicePathLib.c +++ b/MdePkg/Library/UefiDevicePathLibDevicePathProtocol/UefiDevicePathLib.c @@ -1,5 +1,6 @@ /** @file - UEFI Device Path Library. + Library instance that implement UEFI Device Path Library class based on protocol + gEfiDevicePathUtilitiesProtocolGuid. Copyright (c) 2006, Intel Corporation
All rights reserved. This program and the accompanying materials @@ -25,8 +26,6 @@ #include #include -#include "UefiDevicePathLibInternal.h" - STATIC EFI_DEVICE_PATH_UTILITIES_PROTOCOL *mDevicePathUtilities = NULL; /** @@ -245,7 +244,7 @@ GetNextDevicePathInstance ( @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. + @return A pointer to the new created file device path **/ EFI_DEVICE_PATH_PROTOCOL * @@ -325,7 +324,7 @@ DevicePathFromHandle ( may be NULL. @param FileName A pointer to a Null-terminated Unicode string. - @return The allocated device path. + @return A pointer to the new created file device path **/ EFI_DEVICE_PATH_PROTOCOL * diff --git a/MdePkg/Library/UefiDevicePathLibDevicePathProtocol/UefiDevicePathLibInternal.h b/MdePkg/Library/UefiDevicePathLibDevicePathProtocol/UefiDevicePathLibInternal.h deleted file mode 100644 index 9587712e81..0000000000 --- a/MdePkg/Library/UefiDevicePathLibDevicePathProtocol/UefiDevicePathLibInternal.h +++ /dev/null @@ -1,38 +0,0 @@ -/** @file - Internal Header file for UEFI Device Path 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. - -**/ - -#ifndef _UEFI_DEVICEPATH_LIB_INTERNAL_H_ -#define _UEFI_DEVICEPATH_LIB_INTERNAL_H_ - - -/** - The constructor function caches the pointer to DevicePathUtilites protocol. - - The constructor function locates DevicePathUtilities protocol from protocol database. - It will ASSERT() if that operation fails and it will always return EFI_SUCCESS. - - @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 -DevicePathLibConstructor ( - IN EFI_HANDLE ImageHandle, - IN EFI_SYSTEM_TABLE *SystemTable - ); - -#endif