summaryrefslogtreecommitdiff
path: root/MdeModulePkg/Universal/PlatformDriverOverride
diff options
context:
space:
mode:
authorklu2 <klu2@6f19259b-4bc3-4df7-8a09-765794883524>2008-11-11 15:42:40 +0000
committerklu2 <klu2@6f19259b-4bc3-4df7-8a09-765794883524>2008-11-11 15:42:40 +0000
commit1232b21473646661a4ac1ae4b7bf5113d4613e83 (patch)
treed941add025ac902858b1aa8cf38ffaa055baa41b /MdeModulePkg/Universal/PlatformDriverOverride
parente5dab01618850f8c8be029336ad93dcd1680865f (diff)
downloadedk2-platforms-1232b21473646661a4ac1ae4b7bf5113d4613e83.tar.xz
1, Add <Library/DevicePathLib.h> for all source that use device path utility macros
2, Add DevicePathLib library class to module's INF that use device path utility macros git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@6456 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'MdeModulePkg/Universal/PlatformDriverOverride')
-rw-r--r--MdeModulePkg/Universal/PlatformDriverOverride/PlatOverMngr/PlatOverMngr.c90
-rw-r--r--MdeModulePkg/Universal/PlatformDriverOverride/PlatOverMngr/PlatOverMngr.h7
-rw-r--r--MdeModulePkg/Universal/PlatformDriverOverride/PlatOverMngr/PlatOverMngr.inf3
3 files changed, 17 insertions, 83 deletions
diff --git a/MdeModulePkg/Universal/PlatformDriverOverride/PlatOverMngr/PlatOverMngr.c b/MdeModulePkg/Universal/PlatformDriverOverride/PlatOverMngr/PlatOverMngr.c
index 5269c35198..5d9bfe127a 100644
--- a/MdeModulePkg/Universal/PlatformDriverOverride/PlatOverMngr/PlatOverMngr.c
+++ b/MdeModulePkg/Universal/PlatformDriverOverride/PlatOverMngr/PlatOverMngr.c
@@ -340,8 +340,8 @@ GetImageName (
)
{
EFI_STATUS Status;
- EFI_DEVICE_PATH_PROTOCOL *DevPath;
EFI_DEVICE_PATH_PROTOCOL *DevPathNode;
+ EFI_DEVICE_PATH_PROTOCOL *AlignedDevPathNode;
MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *FvFilePath;
VOID *Buffer;
UINTN BufferSize;
@@ -357,21 +357,24 @@ GetImageName (
return NULL;
}
- DevPath = UnpackDevicePath (Image->FilePath);
+ DevPathNode = Image->FilePath;
- if (DevPath == NULL) {
+ if (DevPathNode == NULL) {
return NULL;
}
- DevPathNode = DevPath;
-
while (!IsDevicePathEnd (DevPathNode)) {
//
+ // Make sure device path node is aligned when accessing it's FV Name Guid field.
+ //
+ AlignedDevPathNode = AllocateCopyPool (DevicePathNodeLength(DevPathNode), DevPathNode);
+
+ //
// Find the Fv File path
//
- NameGuid = EfiGetNameGuidFromFwVolDevicePathNode ((MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *)DevPathNode);
+ NameGuid = EfiGetNameGuidFromFwVolDevicePathNode ((MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *)AlignedDevPathNode);
if (NameGuid != NULL) {
- FvFilePath = (MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *) DevPathNode;
+ FvFilePath = (MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *) AlignedDevPathNode;
Status = gBS->HandleProtocol (
Image->DeviceHandle,
&gEfiFirmwareVolume2ProtocolGuid,
@@ -388,18 +391,21 @@ GetImageName (
&AuthenticationStatus
);
if (!EFI_ERROR (Status)) {
+ FreePool (AlignedDevPathNode);
break;
}
Buffer = NULL;
}
}
+
+ FreePool (AlignedDevPathNode);
+
//
// Next device path node
//
DevPathNode = NextDevicePathNode (DevPathNode);
}
- gBS->FreePool (DevPath);
return Buffer;
}
@@ -1317,74 +1323,6 @@ PlatOverMngrCallback (
}
/**
- Function unpacks a device path data structure so that all the nodes
- of a device path are naturally aligned.
-
- @param DevPath A pointer to a device path data structure
-
- @return If the memory for the device path is successfully allocated, then a
- @return pointer to the new device path is returned. Otherwise, NULL is returned.
-
-**/
-EFI_DEVICE_PATH_PROTOCOL *
-UnpackDevicePath (
- IN EFI_DEVICE_PATH_PROTOCOL *DevPath
- )
-{
- EFI_DEVICE_PATH_PROTOCOL *Src;
- EFI_DEVICE_PATH_PROTOCOL *Dest;
- EFI_DEVICE_PATH_PROTOCOL *NewPath;
- UINTN Size;
-
- //
- // Walk device path and round sizes to valid boundries
- //
- Src = DevPath;
- Size = 0;
- for (;;) {
- Size += DevicePathNodeLength (Src);
- Size += ALIGN_SIZE (Size);
-
- if (IsDevicePathEnd (Src)) {
- break;
- }
-
- Src = NextDevicePathNode (Src);
- }
- //
- // Allocate space for the unpacked path
- //
- NewPath = AllocateZeroPool (Size);
- if (NewPath) {
-
- ASSERT (((UINTN) NewPath) % MIN_ALIGNMENT_SIZE == 0);
-
- //
- // Copy each node
- //
- Src = DevPath;
- Dest = NewPath;
- for (;;) {
- Size = DevicePathNodeLength (Src);
- CopyMem (Dest, Src, Size);
- Size += ALIGN_SIZE (Size);
- SetDevicePathNodeLength (Dest, Size);
- Dest->Type |= EFI_DP_TYPE_UNPACKED;
- Dest = (EFI_DEVICE_PATH_PROTOCOL *) (((UINT8 *) Dest) + Size);
-
- if (IsDevicePathEnd (Src)) {
- break;
- }
-
- Src = NextDevicePathNode (Src);
- }
- }
-
- return NewPath;
-}
-
-
-/**
Get the description string by device path.
@param DevPath The input device path.
diff --git a/MdeModulePkg/Universal/PlatformDriverOverride/PlatOverMngr/PlatOverMngr.h b/MdeModulePkg/Universal/PlatformDriverOverride/PlatOverMngr/PlatOverMngr.h
index 793f9d83c9..5ac780c8bf 100644
--- a/MdeModulePkg/Universal/PlatformDriverOverride/PlatOverMngr/PlatOverMngr.h
+++ b/MdeModulePkg/Universal/PlatformDriverOverride/PlatOverMngr/PlatOverMngr.h
@@ -49,6 +49,7 @@ Abstract:
#include <Library/HiiLib.h>
#include <Library/ExtendedHiiLib.h>
#include <Library/UefiRuntimeServicesTableLib.h>
+#include <Library/DevicePathLib.h>
#define MIN_ALIGNMENT_SIZE 4
#define ALIGN_SIZE(a) ((a % MIN_ALIGNMENT_SIZE) ? MIN_ALIGNMENT_SIZE - (a % MIN_ALIGNMENT_SIZE) : 0)
@@ -171,10 +172,4 @@ DevicePathToStr (
EFI_DEVICE_PATH_PROTOCOL *DevPath
);
-
-EFI_DEVICE_PATH_PROTOCOL *
-UnpackDevicePath (
- IN EFI_DEVICE_PATH_PROTOCOL *DevPath
- );
-
#endif
diff --git a/MdeModulePkg/Universal/PlatformDriverOverride/PlatOverMngr/PlatOverMngr.inf b/MdeModulePkg/Universal/PlatformDriverOverride/PlatOverMngr/PlatOverMngr.inf
index f4b37825d5..3f529133b1 100644
--- a/MdeModulePkg/Universal/PlatformDriverOverride/PlatOverMngr/PlatOverMngr.inf
+++ b/MdeModulePkg/Universal/PlatformDriverOverride/PlatOverMngr/PlatOverMngr.inf
@@ -58,7 +58,8 @@
HiiLib
ExtendedHiiLib
UefiRuntimeServicesTableLib
-
+ DevicePathLib
+
[Protocols]
gEfiLoadedImageProtocolGuid # PROTOCOL ALWAYS_CONSUMED
gEfiPciIoProtocolGuid # PROTOCOL ALWAYS_CONSUMED