mirror of https://github.com/acidanthera/audk.git
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
This commit is contained in:
parent
e5dab01618
commit
1232b21473
|
@ -28,6 +28,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||||
#include <Library/BaseMemoryLib.h>
|
#include <Library/BaseMemoryLib.h>
|
||||||
#include <Library/UefiBootServicesTableLib.h>
|
#include <Library/UefiBootServicesTableLib.h>
|
||||||
#include <Library/UefiLib.h>
|
#include <Library/UefiLib.h>
|
||||||
|
#include <Library/DevicePathLib.h>
|
||||||
|
|
||||||
#include <IndustryStandard/Pci.h>
|
#include <IndustryStandard/Pci.h>
|
||||||
|
|
||||||
|
|
|
@ -759,7 +759,7 @@ GetUsbDPFromFullDP (
|
||||||
// Get the Usb part first Begin node in full device path
|
// Get the Usb part first Begin node in full device path
|
||||||
//
|
//
|
||||||
UsbDevicePathBeginPtr = DevicePath;
|
UsbDevicePathBeginPtr = DevicePath;
|
||||||
while ( (!EfiIsDevicePathEnd (UsbDevicePathBeginPtr))&&
|
while ( (!IsDevicePathEnd (UsbDevicePathBeginPtr))&&
|
||||||
((UsbDevicePathBeginPtr->Type != MESSAGING_DEVICE_PATH) ||
|
((UsbDevicePathBeginPtr->Type != MESSAGING_DEVICE_PATH) ||
|
||||||
(UsbDevicePathBeginPtr->SubType != MSG_USB_DP &&
|
(UsbDevicePathBeginPtr->SubType != MSG_USB_DP &&
|
||||||
UsbDevicePathBeginPtr->SubType != MSG_USB_CLASS_DP
|
UsbDevicePathBeginPtr->SubType != MSG_USB_CLASS_DP
|
||||||
|
@ -773,7 +773,7 @@ GetUsbDPFromFullDP (
|
||||||
// Get the Usb part first End node in full device path
|
// Get the Usb part first End node in full device path
|
||||||
//
|
//
|
||||||
UsbDevicePathEndPtr = UsbDevicePathBeginPtr;
|
UsbDevicePathEndPtr = UsbDevicePathBeginPtr;
|
||||||
while ((!EfiIsDevicePathEnd (UsbDevicePathEndPtr))&&
|
while ((!IsDevicePathEnd (UsbDevicePathEndPtr))&&
|
||||||
(UsbDevicePathEndPtr->Type == MESSAGING_DEVICE_PATH) &&
|
(UsbDevicePathEndPtr->Type == MESSAGING_DEVICE_PATH) &&
|
||||||
(UsbDevicePathEndPtr->SubType == MSG_USB_DP ||
|
(UsbDevicePathEndPtr->SubType == MSG_USB_DP ||
|
||||||
UsbDevicePathEndPtr->SubType == MSG_USB_CLASS_DP
|
UsbDevicePathEndPtr->SubType == MSG_USB_CLASS_DP
|
||||||
|
|
|
@ -691,9 +691,7 @@ CoreFvToDevicePath (
|
||||||
// Build a device path to the file in the FV to pass into gBS->LoadImage
|
// Build a device path to the file in the FV to pass into gBS->LoadImage
|
||||||
//
|
//
|
||||||
EfiInitializeFwVolDevicepathNode (&mFvDevicePath.File, DriverName);
|
EfiInitializeFwVolDevicepathNode (&mFvDevicePath.File, DriverName);
|
||||||
mFvDevicePath.End.Type = EFI_END_ENTIRE_DEVICE_PATH;
|
SetDevicePathEndNode (&mFvDevicePath.End);
|
||||||
mFvDevicePath.End.SubType = END_ENTIRE_DEVICE_PATH_SUBTYPE;
|
|
||||||
SetDevicePathNodeLength (&mFvDevicePath.End, sizeof (EFI_DEVICE_PATH_PROTOCOL));
|
|
||||||
|
|
||||||
FileNameDevicePath = AppendDevicePath (
|
FileNameDevicePath = AppendDevicePath (
|
||||||
FvDevicePath,
|
FvDevicePath,
|
||||||
|
@ -1046,9 +1044,7 @@ CoreFwVolEventProtocolNotify (
|
||||||
// be initialized completely.
|
// be initialized completely.
|
||||||
//
|
//
|
||||||
EfiInitializeFwVolDevicepathNode (&mFvDevicePath.File, &NameGuid);
|
EfiInitializeFwVolDevicepathNode (&mFvDevicePath.File, &NameGuid);
|
||||||
mFvDevicePath.End.Type = EFI_END_ENTIRE_DEVICE_PATH;
|
SetDevicePathEndNode (&mFvDevicePath.End);
|
||||||
mFvDevicePath.End.SubType = END_ENTIRE_DEVICE_PATH_SUBTYPE;
|
|
||||||
SetDevicePathNodeLength (&mFvDevicePath.End, sizeof (EFI_DEVICE_PATH_PROTOCOL));
|
|
||||||
|
|
||||||
gDxeCoreLoadedImage->FilePath = DuplicateDevicePath (
|
gDxeCoreLoadedImage->FilePath = DuplicateDevicePath (
|
||||||
(EFI_DEVICE_PATH_PROTOCOL *)&mFvDevicePath
|
(EFI_DEVICE_PATH_PROTOCOL *)&mFvDevicePath
|
||||||
|
|
|
@ -505,22 +505,6 @@ BdsLibConnectConsoleVariable (
|
||||||
//
|
//
|
||||||
// Bds device path related lib functions
|
// Bds device path related lib functions
|
||||||
//
|
//
|
||||||
/**
|
|
||||||
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 *
|
|
||||||
EFIAPI
|
|
||||||
BdsLibUnpackDevicePath (
|
|
||||||
IN EFI_DEVICE_PATH_PROTOCOL *DevPath
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Delete the instance in Multi which matches partly with Single instance
|
Delete the instance in Multi which matches partly with Single instance
|
||||||
|
|
||||||
|
|
|
@ -38,7 +38,7 @@ Abstract:
|
||||||
#include <Library/UefiRuntimeServicesTableLib.h>
|
#include <Library/UefiRuntimeServicesTableLib.h>
|
||||||
#include <Library/UefiLib.h>
|
#include <Library/UefiLib.h>
|
||||||
#include <Library/MemoryAllocationLib.h>
|
#include <Library/MemoryAllocationLib.h>
|
||||||
|
#include <Library/DevicePathLib.h>
|
||||||
|
|
||||||
EFI_DPC_PROTOCOL *mDpc = NULL;
|
EFI_DPC_PROTOCOL *mDpc = NULL;
|
||||||
|
|
||||||
|
|
|
@ -51,6 +51,7 @@
|
||||||
UefiRuntimeServicesTableLib
|
UefiRuntimeServicesTableLib
|
||||||
UefiLib
|
UefiLib
|
||||||
MemoryAllocationLib
|
MemoryAllocationLib
|
||||||
|
DevicePathLib
|
||||||
|
|
||||||
[Protocols]
|
[Protocols]
|
||||||
gEfiSimpleNetworkProtocolGuid # PROTOCOL ALWAYS_CONSUMED
|
gEfiSimpleNetworkProtocolGuid # PROTOCOL ALWAYS_CONSUMED
|
||||||
|
|
|
@ -1590,9 +1590,9 @@ UpdateFvFileDevicePath (
|
||||||
//
|
//
|
||||||
TempDevicePath = *DevicePath;
|
TempDevicePath = *DevicePath;
|
||||||
LastDeviceNode = TempDevicePath;
|
LastDeviceNode = TempDevicePath;
|
||||||
while (!EfiIsDevicePathEnd (TempDevicePath)) {
|
while (!IsDevicePathEnd (TempDevicePath)) {
|
||||||
LastDeviceNode = TempDevicePath;
|
LastDeviceNode = TempDevicePath;
|
||||||
TempDevicePath = EfiNextDevicePathNode (TempDevicePath);
|
TempDevicePath = NextDevicePathNode (TempDevicePath);
|
||||||
}
|
}
|
||||||
GuidPoint = EfiGetNameGuidFromFwVolDevicePathNode ((MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *) LastDeviceNode);
|
GuidPoint = EfiGetNameGuidFromFwVolDevicePathNode ((MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *) LastDeviceNode);
|
||||||
if (GuidPoint == NULL) {
|
if (GuidPoint == NULL) {
|
||||||
|
@ -1618,7 +1618,7 @@ UpdateFvFileDevicePath (
|
||||||
//
|
//
|
||||||
TempDevicePath = *DevicePath;
|
TempDevicePath = *DevicePath;
|
||||||
HasFvNode = FALSE;
|
HasFvNode = FALSE;
|
||||||
while (!EfiIsDevicePathEnd (TempDevicePath)) {
|
while (!IsDevicePathEnd (TempDevicePath)) {
|
||||||
//
|
//
|
||||||
// Use old Device Path
|
// Use old Device Path
|
||||||
//
|
//
|
||||||
|
@ -1627,7 +1627,7 @@ UpdateFvFileDevicePath (
|
||||||
HasFvNode = TRUE;
|
HasFvNode = TRUE;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
TempDevicePath = EfiNextDevicePathNode (TempDevicePath);
|
TempDevicePath = NextDevicePathNode (TempDevicePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!HasFvNode) {
|
if (!HasFvNode) {
|
||||||
|
|
|
@ -21,6 +21,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||||
#include <Library/DebugLib.h>
|
#include <Library/DebugLib.h>
|
||||||
#include <Library/MemoryAllocationLib.h>
|
#include <Library/MemoryAllocationLib.h>
|
||||||
#include <Library/UefiBootServicesTableLib.h>
|
#include <Library/UefiBootServicesTableLib.h>
|
||||||
|
#include <Library/DevicePathLib.h>
|
||||||
#include <MdeModuleHii.h>
|
#include <MdeModuleHii.h>
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -42,6 +42,7 @@
|
||||||
DebugLib
|
DebugLib
|
||||||
PcdLib
|
PcdLib
|
||||||
UefiRuntimeServicesTableLib
|
UefiRuntimeServicesTableLib
|
||||||
|
DevicePathLib
|
||||||
|
|
||||||
[Protocols]
|
[Protocols]
|
||||||
gEfiDevicePathProtocolGuid
|
gEfiDevicePathProtocolGuid
|
||||||
|
|
|
@ -523,7 +523,6 @@ MatchPartitionDevicePathNode (
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
HARDDRIVE_DEVICE_PATH *TmpHdPath;
|
HARDDRIVE_DEVICE_PATH *TmpHdPath;
|
||||||
HARDDRIVE_DEVICE_PATH *TempPath;
|
|
||||||
EFI_DEVICE_PATH_PROTOCOL *DevicePath;
|
EFI_DEVICE_PATH_PROTOCOL *DevicePath;
|
||||||
BOOLEAN Match;
|
BOOLEAN Match;
|
||||||
EFI_DEVICE_PATH_PROTOCOL *BlockIoHdDevicePathNode;
|
EFI_DEVICE_PATH_PROTOCOL *BlockIoHdDevicePathNode;
|
||||||
|
@ -559,20 +558,19 @@ MatchPartitionDevicePathNode (
|
||||||
// See if the harddrive device path in blockio matches the orig Hard Drive Node
|
// See if the harddrive device path in blockio matches the orig Hard Drive Node
|
||||||
//
|
//
|
||||||
TmpHdPath = (HARDDRIVE_DEVICE_PATH *) BlockIoHdDevicePathNode;
|
TmpHdPath = (HARDDRIVE_DEVICE_PATH *) BlockIoHdDevicePathNode;
|
||||||
TempPath = (HARDDRIVE_DEVICE_PATH *) BdsLibUnpackDevicePath ((EFI_DEVICE_PATH_PROTOCOL *) HardDriveDevicePath);
|
|
||||||
Match = FALSE;
|
Match = FALSE;
|
||||||
|
|
||||||
//
|
//
|
||||||
// Check for the match
|
// Check for the match
|
||||||
//
|
//
|
||||||
if ((TmpHdPath->MBRType == TempPath->MBRType) &&
|
if ((TmpHdPath->MBRType == HardDriveDevicePath->MBRType) &&
|
||||||
(TmpHdPath->SignatureType == TempPath->SignatureType)) {
|
(TmpHdPath->SignatureType == HardDriveDevicePath->SignatureType)) {
|
||||||
switch (TmpHdPath->SignatureType) {
|
switch (TmpHdPath->SignatureType) {
|
||||||
case SIGNATURE_TYPE_GUID:
|
case SIGNATURE_TYPE_GUID:
|
||||||
Match = CompareGuid ((EFI_GUID *)TmpHdPath->Signature, (EFI_GUID *)TempPath->Signature);
|
Match = CompareGuid ((EFI_GUID *)TmpHdPath->Signature, (EFI_GUID *)HardDriveDevicePath->Signature);
|
||||||
break;
|
break;
|
||||||
case SIGNATURE_TYPE_MBR:
|
case SIGNATURE_TYPE_MBR:
|
||||||
Match = (BOOLEAN)(*((UINT32 *)(&(TmpHdPath->Signature[0]))) == *(UINT32 *)(&(TempPath->Signature[0])));
|
Match = (BOOLEAN)(*((UINT32 *)(&(TmpHdPath->Signature[0]))) == ReadUnaligned32((UINT32 *)(&(HardDriveDevicePath->Signature[0]))));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
Match = FALSE;
|
Match = FALSE;
|
||||||
|
@ -1624,9 +1622,9 @@ BdsLibIsValidEFIBootOptDevicePath (
|
||||||
// If the boot option point to a file, it is a valid EFI boot option,
|
// If the boot option point to a file, it is a valid EFI boot option,
|
||||||
// and assume it is ready to boot now
|
// and assume it is ready to boot now
|
||||||
//
|
//
|
||||||
while (!EfiIsDevicePathEnd (TempDevicePath)) {
|
while (!IsDevicePathEnd (TempDevicePath)) {
|
||||||
LastDeviceNode = TempDevicePath;
|
LastDeviceNode = TempDevicePath;
|
||||||
TempDevicePath = EfiNextDevicePathNode (TempDevicePath);
|
TempDevicePath = NextDevicePathNode (TempDevicePath);
|
||||||
}
|
}
|
||||||
if ((DevicePathType (LastDeviceNode) == MEDIA_DEVICE_PATH) &&
|
if ((DevicePathType (LastDeviceNode) == MEDIA_DEVICE_PATH) &&
|
||||||
(DevicePathSubType (LastDeviceNode) == MEDIA_FILEPATH_DP)) {
|
(DevicePathSubType (LastDeviceNode) == MEDIA_FILEPATH_DP)) {
|
||||||
|
@ -1765,9 +1763,9 @@ BdsLibUpdateFvFileDevicePath (
|
||||||
//
|
//
|
||||||
TempDevicePath = *DevicePath;
|
TempDevicePath = *DevicePath;
|
||||||
LastDeviceNode = TempDevicePath;
|
LastDeviceNode = TempDevicePath;
|
||||||
while (!EfiIsDevicePathEnd (TempDevicePath)) {
|
while (!IsDevicePathEnd (TempDevicePath)) {
|
||||||
LastDeviceNode = TempDevicePath;
|
LastDeviceNode = TempDevicePath;
|
||||||
TempDevicePath = EfiNextDevicePathNode (TempDevicePath);
|
TempDevicePath = NextDevicePathNode (TempDevicePath);
|
||||||
}
|
}
|
||||||
GuidPoint = EfiGetNameGuidFromFwVolDevicePathNode (
|
GuidPoint = EfiGetNameGuidFromFwVolDevicePathNode (
|
||||||
(MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *) LastDeviceNode
|
(MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *) LastDeviceNode
|
||||||
|
|
|
@ -112,75 +112,6 @@ CatPrint (
|
||||||
return Str->str;
|
return Str->str;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
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 A ponter to new device 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 *
|
|
||||||
EFIAPI
|
|
||||||
BdsLibUnpackDevicePath (
|
|
||||||
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 != 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 = NextDevicePathNode (Src);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return NewPath;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Convert Device Path to a Unicode string for printing.
|
Convert Device Path to a Unicode string for printing.
|
||||||
|
|
||||||
|
@ -1545,12 +1476,6 @@ DevicePathToStr (
|
||||||
return ToText;
|
return ToText;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
|
||||||
// Unpacked the device path
|
|
||||||
//
|
|
||||||
DevPath = BdsLibUnpackDevicePath (DevPath);
|
|
||||||
ASSERT (DevPath);
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Process each device path node
|
// Process each device path node
|
||||||
//
|
//
|
||||||
|
|
|
@ -1257,7 +1257,7 @@ Var_UpdateBBSOption (
|
||||||
NewOptionSize = sizeof (UINT32) + sizeof (UINT16) + StrSize (DescString) +
|
NewOptionSize = sizeof (UINT32) + sizeof (UINT16) + StrSize (DescString) +
|
||||||
sizeof (BBS_BBS_DEVICE_PATH);
|
sizeof (BBS_BBS_DEVICE_PATH);
|
||||||
NewOptionSize += AsciiStrLen (DescAsciiString) +
|
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);
|
UnicodeSPrint (VarName, 100, L"Boot%04x", Index);
|
||||||
|
|
||||||
|
@ -1300,7 +1300,7 @@ Var_UpdateBBSOption (
|
||||||
//
|
//
|
||||||
*((UINT16 *) TempPtr) = (UINT16) (sizeof (BBS_BBS_DEVICE_PATH) +
|
*((UINT16 *) TempPtr) = (UINT16) (sizeof (BBS_BBS_DEVICE_PATH) +
|
||||||
AsciiStrLen (DescAsciiString) +
|
AsciiStrLen (DescAsciiString) +
|
||||||
EFI_END_DEVICE_PATH_LENGTH);
|
END_DEVICE_PATH_LENGTH);
|
||||||
|
|
||||||
TempPtr += sizeof (UINT16);
|
TempPtr += sizeof (UINT16);
|
||||||
|
|
||||||
|
@ -1343,9 +1343,9 @@ Var_UpdateBBSOption (
|
||||||
CopyMem (
|
CopyMem (
|
||||||
TempPtr,
|
TempPtr,
|
||||||
EndDevicePath,
|
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
|
// Now TempPtr point to optional data, i.e. Bbs Table
|
||||||
|
|
|
@ -73,11 +73,11 @@ GetDebugPortVariable (
|
||||||
DebugPortDevice->DebugPortVariable
|
DebugPortDevice->DebugPortVariable
|
||||||
);
|
);
|
||||||
DevicePath = (EFI_DEVICE_PATH_PROTOCOL *) DebugPortDevice->DebugPortVariable;
|
DevicePath = (EFI_DEVICE_PATH_PROTOCOL *) DebugPortDevice->DebugPortVariable;
|
||||||
while (!EfiIsDevicePathEnd (DevicePath) && !IS_UART_DEVICEPATH (DevicePath)) {
|
while (!IsDevicePathEnd (DevicePath) && !IS_UART_DEVICEPATH (DevicePath)) {
|
||||||
DevicePath = EfiNextDevicePathNode (DevicePath);
|
DevicePath = NextDevicePathNode (DevicePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (EfiIsDevicePathEnd (DevicePath)) {
|
if (IsDevicePathEnd (DevicePath)) {
|
||||||
FreePool (gDebugPortDevice->DebugPortVariable);
|
FreePool (gDebugPortDevice->DebugPortVariable);
|
||||||
DebugPortDevice->DebugPortVariable = NULL;
|
DebugPortDevice->DebugPortVariable = NULL;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -14,76 +14,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||||
|
|
||||||
#include "DevicePath.h"
|
#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.
|
Adjusts the size of a previously allocated buffer.
|
||||||
|
|
||||||
|
@ -1853,7 +1783,7 @@ ConvertDevicePathToText (
|
||||||
{
|
{
|
||||||
POOL_PRINT Str;
|
POOL_PRINT Str;
|
||||||
EFI_DEVICE_PATH_PROTOCOL *DevPathNode;
|
EFI_DEVICE_PATH_PROTOCOL *DevPathNode;
|
||||||
EFI_DEVICE_PATH_PROTOCOL *UnpackDevPath;
|
EFI_DEVICE_PATH_PROTOCOL *AlignedDevPathNode;
|
||||||
UINTN Index;
|
UINTN Index;
|
||||||
UINTN NewSize;
|
UINTN NewSize;
|
||||||
VOID (*DumpNode) (POOL_PRINT *, VOID *, BOOLEAN, BOOLEAN);
|
VOID (*DumpNode) (POOL_PRINT *, VOID *, BOOLEAN, BOOLEAN);
|
||||||
|
@ -1864,16 +1794,10 @@ ConvertDevicePathToText (
|
||||||
|
|
||||||
ZeroMem (&Str, sizeof (Str));
|
ZeroMem (&Str, sizeof (Str));
|
||||||
|
|
||||||
//
|
|
||||||
// Unpacked the device path
|
|
||||||
//
|
|
||||||
UnpackDevPath = UnpackDevicePath ((EFI_DEVICE_PATH_PROTOCOL *) DevicePath);
|
|
||||||
ASSERT (UnpackDevPath != NULL);
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Process each device path node
|
// Process each device path node
|
||||||
//
|
//
|
||||||
DevPathNode = UnpackDevPath;
|
DevPathNode = (EFI_DEVICE_PATH_PROTOCOL *) DevicePath;
|
||||||
while (!IsDevicePathEnd (DevPathNode)) {
|
while (!IsDevicePathEnd (DevPathNode)) {
|
||||||
//
|
//
|
||||||
// Find the handler to dump this device path node
|
// Find the handler to dump this device path node
|
||||||
|
@ -1902,20 +1826,19 @@ ConvertDevicePathToText (
|
||||||
CatPrint (&Str, L"/");
|
CatPrint (&Str, L"/");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
AlignedDevPathNode = AllocateCopyPool (DevicePathNodeLength (DevPathNode), DevPathNode);
|
||||||
//
|
//
|
||||||
// Print this node of the device path
|
// Print this node of the device path
|
||||||
//
|
//
|
||||||
DumpNode (&Str, DevPathNode, DisplayOnly, AllowShortcuts);
|
DumpNode (&Str, AlignedDevPathNode, DisplayOnly, AllowShortcuts);
|
||||||
|
FreePool (AlignedDevPathNode);
|
||||||
|
|
||||||
//
|
//
|
||||||
// Next device path node
|
// Next device path node
|
||||||
//
|
//
|
||||||
DevPathNode = NextDevicePathNode (DevPathNode);
|
DevPathNode = NextDevicePathNode (DevPathNode);
|
||||||
}
|
}
|
||||||
//
|
|
||||||
// Shrink pool used for string allocation
|
|
||||||
//
|
|
||||||
FreePool (UnpackDevPath);
|
|
||||||
|
|
||||||
NewSize = (Str.Len + 1) * sizeof (CHAR16);
|
NewSize = (Str.Len + 1) * sizeof (CHAR16);
|
||||||
Str.Str = ReallocatePool (Str.Str, NewSize, NewSize);
|
Str.Str = ReallocatePool (Str.Str, NewSize, NewSize);
|
||||||
|
|
|
@ -163,9 +163,9 @@ PartitionInstallMbrChildHandles (
|
||||||
LastDevicePathNode = NULL;
|
LastDevicePathNode = NULL;
|
||||||
ZeroMem (&ParentHdDev, sizeof (ParentHdDev));
|
ZeroMem (&ParentHdDev, sizeof (ParentHdDev));
|
||||||
DevicePathNode = DevicePath;
|
DevicePathNode = DevicePath;
|
||||||
while (!EfiIsDevicePathEnd (DevicePathNode)) {
|
while (!IsDevicePathEnd (DevicePathNode)) {
|
||||||
LastDevicePathNode = DevicePathNode;
|
LastDevicePathNode = DevicePathNode;
|
||||||
DevicePathNode = EfiNextDevicePathNode (DevicePathNode);
|
DevicePathNode = NextDevicePathNode (DevicePathNode);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (LastDevicePathNode != NULL) {
|
if (LastDevicePathNode != NULL) {
|
||||||
|
|
|
@ -31,6 +31,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||||
#include <Library/BaseMemoryLib.h>
|
#include <Library/BaseMemoryLib.h>
|
||||||
#include <Library/MemoryAllocationLib.h>
|
#include <Library/MemoryAllocationLib.h>
|
||||||
#include <Library/UefiBootServicesTableLib.h>
|
#include <Library/UefiBootServicesTableLib.h>
|
||||||
|
#include <Library/DevicePathLib.h>
|
||||||
|
|
||||||
#include <WorkingBlockHeader.h>
|
#include <WorkingBlockHeader.h>
|
||||||
|
|
||||||
|
|
|
@ -63,6 +63,7 @@
|
||||||
UefiDriverEntryPoint
|
UefiDriverEntryPoint
|
||||||
DebugLib
|
DebugLib
|
||||||
PcdLib
|
PcdLib
|
||||||
|
DevicePathLib
|
||||||
|
|
||||||
[Guids]
|
[Guids]
|
||||||
gEfiSystemNvDataFvGuid # ALWAYS_CONSUMED
|
gEfiSystemNvDataFvGuid # ALWAYS_CONSUMED
|
||||||
|
|
|
@ -188,7 +188,7 @@ IScsiExtScsiPassThruBuildDevicePath (
|
||||||
|
|
||||||
Node->DevPath.Type = MESSAGING_DEVICE_PATH;
|
Node->DevPath.Type = MESSAGING_DEVICE_PATH;
|
||||||
Node->DevPath.SubType = MSG_ISCSI_DP;
|
Node->DevPath.SubType = MSG_ISCSI_DP;
|
||||||
SetDevicePathNodeLength (&Node->DevPath, DevPathNodeLen);
|
SetDevicePathNodeLength (&Node->DevPath, (UINT16)DevPathNodeLen);
|
||||||
|
|
||||||
//
|
//
|
||||||
// 0 for TCP, others are reserved.
|
// 0 for TCP, others are reserved.
|
||||||
|
|
|
@ -340,8 +340,8 @@ GetImageName (
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
EFI_STATUS Status;
|
EFI_STATUS Status;
|
||||||
EFI_DEVICE_PATH_PROTOCOL *DevPath;
|
|
||||||
EFI_DEVICE_PATH_PROTOCOL *DevPathNode;
|
EFI_DEVICE_PATH_PROTOCOL *DevPathNode;
|
||||||
|
EFI_DEVICE_PATH_PROTOCOL *AlignedDevPathNode;
|
||||||
MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *FvFilePath;
|
MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *FvFilePath;
|
||||||
VOID *Buffer;
|
VOID *Buffer;
|
||||||
UINTN BufferSize;
|
UINTN BufferSize;
|
||||||
|
@ -357,21 +357,24 @@ GetImageName (
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
DevPath = UnpackDevicePath (Image->FilePath);
|
DevPathNode = Image->FilePath;
|
||||||
|
|
||||||
if (DevPath == NULL) {
|
if (DevPathNode == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
DevPathNode = DevPath;
|
|
||||||
|
|
||||||
while (!IsDevicePathEnd (DevPathNode)) {
|
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
|
// 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) {
|
if (NameGuid != NULL) {
|
||||||
FvFilePath = (MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *) DevPathNode;
|
FvFilePath = (MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *) AlignedDevPathNode;
|
||||||
Status = gBS->HandleProtocol (
|
Status = gBS->HandleProtocol (
|
||||||
Image->DeviceHandle,
|
Image->DeviceHandle,
|
||||||
&gEfiFirmwareVolume2ProtocolGuid,
|
&gEfiFirmwareVolume2ProtocolGuid,
|
||||||
|
@ -388,18 +391,21 @@ GetImageName (
|
||||||
&AuthenticationStatus
|
&AuthenticationStatus
|
||||||
);
|
);
|
||||||
if (!EFI_ERROR (Status)) {
|
if (!EFI_ERROR (Status)) {
|
||||||
|
FreePool (AlignedDevPathNode);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
Buffer = NULL;
|
Buffer = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FreePool (AlignedDevPathNode);
|
||||||
|
|
||||||
//
|
//
|
||||||
// Next device path node
|
// Next device path node
|
||||||
//
|
//
|
||||||
DevPathNode = NextDevicePathNode (DevPathNode);
|
DevPathNode = NextDevicePathNode (DevPathNode);
|
||||||
}
|
}
|
||||||
|
|
||||||
gBS->FreePool (DevPath);
|
|
||||||
return Buffer;
|
return Buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1316,74 +1322,6 @@ PlatOverMngrCallback (
|
||||||
return EFI_SUCCESS;
|
return EFI_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
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.
|
Get the description string by device path.
|
||||||
|
|
||||||
|
|
|
@ -49,6 +49,7 @@ Abstract:
|
||||||
#include <Library/HiiLib.h>
|
#include <Library/HiiLib.h>
|
||||||
#include <Library/ExtendedHiiLib.h>
|
#include <Library/ExtendedHiiLib.h>
|
||||||
#include <Library/UefiRuntimeServicesTableLib.h>
|
#include <Library/UefiRuntimeServicesTableLib.h>
|
||||||
|
#include <Library/DevicePathLib.h>
|
||||||
|
|
||||||
#define MIN_ALIGNMENT_SIZE 4
|
#define MIN_ALIGNMENT_SIZE 4
|
||||||
#define ALIGN_SIZE(a) ((a % MIN_ALIGNMENT_SIZE) ? MIN_ALIGNMENT_SIZE - (a % MIN_ALIGNMENT_SIZE) : 0)
|
#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 *DevPath
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
EFI_DEVICE_PATH_PROTOCOL *
|
|
||||||
UnpackDevicePath (
|
|
||||||
IN EFI_DEVICE_PATH_PROTOCOL *DevPath
|
|
||||||
);
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -58,6 +58,7 @@
|
||||||
HiiLib
|
HiiLib
|
||||||
ExtendedHiiLib
|
ExtendedHiiLib
|
||||||
UefiRuntimeServicesTableLib
|
UefiRuntimeServicesTableLib
|
||||||
|
DevicePathLib
|
||||||
|
|
||||||
[Protocols]
|
[Protocols]
|
||||||
gEfiLoadedImageProtocolGuid # PROTOCOL ALWAYS_CONSUMED
|
gEfiLoadedImageProtocolGuid # PROTOCOL ALWAYS_CONSUMED
|
||||||
|
|
Loading…
Reference in New Issue