summaryrefslogtreecommitdiff
path: root/MdeModulePkg/Universal
diff options
context:
space:
mode:
Diffstat (limited to 'MdeModulePkg/Universal')
-rw-r--r--MdeModulePkg/Universal/BdsDxe/BootMaint/Variable.c8
-rw-r--r--MdeModulePkg/Universal/DebugPortDxe/DebugPort.c6
-rw-r--r--MdeModulePkg/Universal/DevicePathDxe/DevicePathToText.c91
-rw-r--r--MdeModulePkg/Universal/Disk/PartitionDxe/Mbr.c4
-rw-r--r--MdeModulePkg/Universal/FirmwareVolume/FaultTolerantWriteDxe/FtwLite.h1
-rw-r--r--MdeModulePkg/Universal/FirmwareVolume/FaultTolerantWriteDxe/FtwLite.inf3
-rw-r--r--MdeModulePkg/Universal/Network/IScsiDxe/IScsiExtScsiPassThru.c2
-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
10 files changed, 37 insertions, 178 deletions
diff --git a/MdeModulePkg/Universal/BdsDxe/BootMaint/Variable.c b/MdeModulePkg/Universal/BdsDxe/BootMaint/Variable.c
index 622093c..a211ae2 100644
--- a/MdeModulePkg/Universal/BdsDxe/BootMaint/Variable.c
+++ b/MdeModulePkg/Universal/BdsDxe/BootMaint/Variable.c
@@ -1257,7 +1257,7 @@ Var_UpdateBBSOption (
NewOptionSize = sizeof (UINT32) + sizeof (UINT16) + StrSize (DescString) +
sizeof (BBS_BBS_DEVICE_PATH);
NewOptionSize += AsciiStrLen (DescAsciiString) +
- EFI_END_DEVICE_PATH_LENGTH + sizeof (BBS_TABLE) + sizeof (UINT16);
+ END_DEVICE_PATH_LENGTH + sizeof (BBS_TABLE) + sizeof (UINT16);
UnicodeSPrint (VarName, 100, L"Boot%04x", Index);
@@ -1300,7 +1300,7 @@ Var_UpdateBBSOption (
//
*((UINT16 *) TempPtr) = (UINT16) (sizeof (BBS_BBS_DEVICE_PATH) +
AsciiStrLen (DescAsciiString) +
- EFI_END_DEVICE_PATH_LENGTH);
+ END_DEVICE_PATH_LENGTH);
TempPtr += sizeof (UINT16);
@@ -1343,9 +1343,9 @@ Var_UpdateBBSOption (
CopyMem (
TempPtr,
EndDevicePath,
- EFI_END_DEVICE_PATH_LENGTH
+ END_DEVICE_PATH_LENGTH
);
- TempPtr += EFI_END_DEVICE_PATH_LENGTH;
+ TempPtr += END_DEVICE_PATH_LENGTH;
//
// Now TempPtr point to optional data, i.e. Bbs Table
diff --git a/MdeModulePkg/Universal/DebugPortDxe/DebugPort.c b/MdeModulePkg/Universal/DebugPortDxe/DebugPort.c
index 932c772..0ddbf1e 100644
--- a/MdeModulePkg/Universal/DebugPortDxe/DebugPort.c
+++ b/MdeModulePkg/Universal/DebugPortDxe/DebugPort.c
@@ -73,11 +73,11 @@ GetDebugPortVariable (
DebugPortDevice->DebugPortVariable
);
DevicePath = (EFI_DEVICE_PATH_PROTOCOL *) DebugPortDevice->DebugPortVariable;
- while (!EfiIsDevicePathEnd (DevicePath) && !IS_UART_DEVICEPATH (DevicePath)) {
- DevicePath = EfiNextDevicePathNode (DevicePath);
+ while (!IsDevicePathEnd (DevicePath) && !IS_UART_DEVICEPATH (DevicePath)) {
+ DevicePath = NextDevicePathNode (DevicePath);
}
- if (EfiIsDevicePathEnd (DevicePath)) {
+ if (IsDevicePathEnd (DevicePath)) {
FreePool (gDebugPortDevice->DebugPortVariable);
DebugPortDevice->DebugPortVariable = NULL;
} else {
diff --git a/MdeModulePkg/Universal/DevicePathDxe/DevicePathToText.c b/MdeModulePkg/Universal/DevicePathDxe/DevicePathToText.c
index a1d560c..a9f6afc 100644
--- a/MdeModulePkg/Universal/DevicePathDxe/DevicePathToText.c
+++ b/MdeModulePkg/Universal/DevicePathDxe/DevicePathToText.c
@@ -15,76 +15,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include "DevicePath.h"
/**
- 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 pointer to the
- new device path is returned. Otherwise, NULL is returned.
-
-**/
-EFI_DEVICE_PATH_PROTOCOL *
-UnpackDevicePath (
- IN CONST EFI_DEVICE_PATH_PROTOCOL *DevPath
- )
-{
- CONST EFI_DEVICE_PATH_PROTOCOL *Src;
- EFI_DEVICE_PATH_PROTOCOL *Dest;
- EFI_DEVICE_PATH_PROTOCOL *NewPath;
- UINTN Size;
-
- if (DevPath == NULL) {
- return NULL;
- }
- //
- // 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 = (EFI_DEVICE_PATH_PROTOCOL *) NextDevicePathNode (Src);
- }
- //
- // Allocate space for the unpacked path
- //
- NewPath = AllocateZeroPool (Size);
- if (NewPath != NULL) {
-
- 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 = (EFI_DEVICE_PATH_PROTOCOL *) NextDevicePathNode (Src);
- }
- }
-
- return NewPath;
-}
-
-/**
Adjusts the size of a previously allocated buffer.
@param OldPool A pointer to the buffer whose size is being adjusted.
@@ -1853,7 +1783,7 @@ ConvertDevicePathToText (
{
POOL_PRINT Str;
EFI_DEVICE_PATH_PROTOCOL *DevPathNode;
- EFI_DEVICE_PATH_PROTOCOL *UnpackDevPath;
+ EFI_DEVICE_PATH_PROTOCOL *AlignedDevPathNode;
UINTN Index;
UINTN NewSize;
VOID (*DumpNode) (POOL_PRINT *, VOID *, BOOLEAN, BOOLEAN);
@@ -1865,15 +1795,9 @@ ConvertDevicePathToText (
ZeroMem (&Str, sizeof (Str));
//
- // Unpacked the device path
- //
- UnpackDevPath = UnpackDevicePath ((EFI_DEVICE_PATH_PROTOCOL *) DevicePath);
- ASSERT (UnpackDevPath != NULL);
-
- //
// Process each device path node
//
- DevPathNode = UnpackDevPath;
+ DevPathNode = (EFI_DEVICE_PATH_PROTOCOL *) DevicePath;
while (!IsDevicePathEnd (DevPathNode)) {
//
// Find the handler to dump this device path node
@@ -1902,20 +1826,19 @@ ConvertDevicePathToText (
CatPrint (&Str, L"/");
}
}
+
+ AlignedDevPathNode = AllocateCopyPool (DevicePathNodeLength (DevPathNode), DevPathNode);
//
// Print this node of the device path
//
- DumpNode (&Str, DevPathNode, DisplayOnly, AllowShortcuts);
-
+ DumpNode (&Str, AlignedDevPathNode, DisplayOnly, AllowShortcuts);
+ FreePool (AlignedDevPathNode);
+
//
// Next device path node
//
DevPathNode = NextDevicePathNode (DevPathNode);
}
- //
- // Shrink pool used for string allocation
- //
- FreePool (UnpackDevPath);
NewSize = (Str.Len + 1) * sizeof (CHAR16);
Str.Str = ReallocatePool (Str.Str, NewSize, NewSize);
diff --git a/MdeModulePkg/Universal/Disk/PartitionDxe/Mbr.c b/MdeModulePkg/Universal/Disk/PartitionDxe/Mbr.c
index 51fdca4..21d1163 100644
--- a/MdeModulePkg/Universal/Disk/PartitionDxe/Mbr.c
+++ b/MdeModulePkg/Universal/Disk/PartitionDxe/Mbr.c
@@ -163,9 +163,9 @@ PartitionInstallMbrChildHandles (
LastDevicePathNode = NULL;
ZeroMem (&ParentHdDev, sizeof (ParentHdDev));
DevicePathNode = DevicePath;
- while (!EfiIsDevicePathEnd (DevicePathNode)) {
+ while (!IsDevicePathEnd (DevicePathNode)) {
LastDevicePathNode = DevicePathNode;
- DevicePathNode = EfiNextDevicePathNode (DevicePathNode);
+ DevicePathNode = NextDevicePathNode (DevicePathNode);
}
if (LastDevicePathNode != NULL) {
diff --git a/MdeModulePkg/Universal/FirmwareVolume/FaultTolerantWriteDxe/FtwLite.h b/MdeModulePkg/Universal/FirmwareVolume/FaultTolerantWriteDxe/FtwLite.h
index 2a5195b..a7cc406 100644
--- a/MdeModulePkg/Universal/FirmwareVolume/FaultTolerantWriteDxe/FtwLite.h
+++ b/MdeModulePkg/Universal/FirmwareVolume/FaultTolerantWriteDxe/FtwLite.h
@@ -31,6 +31,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include <Library/BaseMemoryLib.h>
#include <Library/MemoryAllocationLib.h>
#include <Library/UefiBootServicesTableLib.h>
+#include <Library/DevicePathLib.h>
#include <WorkingBlockHeader.h>
diff --git a/MdeModulePkg/Universal/FirmwareVolume/FaultTolerantWriteDxe/FtwLite.inf b/MdeModulePkg/Universal/FirmwareVolume/FaultTolerantWriteDxe/FtwLite.inf
index 6011c74..113f6ed 100644
--- a/MdeModulePkg/Universal/FirmwareVolume/FaultTolerantWriteDxe/FtwLite.inf
+++ b/MdeModulePkg/Universal/FirmwareVolume/FaultTolerantWriteDxe/FtwLite.inf
@@ -63,7 +63,8 @@
UefiDriverEntryPoint
DebugLib
PcdLib
-
+ DevicePathLib
+
[Guids]
gEfiSystemNvDataFvGuid # ALWAYS_CONSUMED
diff --git a/MdeModulePkg/Universal/Network/IScsiDxe/IScsiExtScsiPassThru.c b/MdeModulePkg/Universal/Network/IScsiDxe/IScsiExtScsiPassThru.c
index 2e99efc..e1d2bc0 100644
--- a/MdeModulePkg/Universal/Network/IScsiDxe/IScsiExtScsiPassThru.c
+++ b/MdeModulePkg/Universal/Network/IScsiDxe/IScsiExtScsiPassThru.c
@@ -188,7 +188,7 @@ IScsiExtScsiPassThruBuildDevicePath (
Node->DevPath.Type = MESSAGING_DEVICE_PATH;
Node->DevPath.SubType = MSG_ISCSI_DP;
- SetDevicePathNodeLength (&Node->DevPath, DevPathNodeLen);
+ SetDevicePathNodeLength (&Node->DevPath, (UINT16)DevPathNodeLen);
//
// 0 for TCP, others are reserved.
diff --git a/MdeModulePkg/Universal/PlatformDriverOverride/PlatOverMngr/PlatOverMngr.c b/MdeModulePkg/Universal/PlatformDriverOverride/PlatOverMngr/PlatOverMngr.c
index 5269c35..5d9bfe1 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 793f9d8..5ac780c 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 f4b3782..3f52913 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