diff options
author | klu2 <klu2@6f19259b-4bc3-4df7-8a09-765794883524> | 2008-11-11 15:39:02 +0000 |
---|---|---|
committer | klu2 <klu2@6f19259b-4bc3-4df7-8a09-765794883524> | 2008-11-11 15:39:02 +0000 |
commit | e5dab01618850f8c8be029336ad93dcd1680865f (patch) | |
tree | fa32c88c3b641fab583b082c475dcc593788b611 /MdePkg | |
parent | 96e1079fa412753e42edf293ce28adda88e68a45 (diff) | |
download | edk2-e5dab01618850f8c8be029336ad93dcd1680865f.tar.gz edk2-e5dab01618850f8c8be029336ad93dcd1680865f.tar.bz2 edk2-e5dab01618850f8c8be029336ad93dcd1680865f.zip |
1, Move device path utility macros from protocol's header file to DevicePathLib library classes
2, Remove Unpack type
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@6455 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'MdePkg')
-rw-r--r-- | MdePkg/Include/Library/DevicePathLib.h | 18 | ||||
-rw-r--r-- | MdePkg/Include/Protocol/DevicePath.h | 50 | ||||
-rw-r--r-- | MdePkg/Library/UefiDevicePathLib/UefiDevicePathLib.c | 25 | ||||
-rw-r--r-- | MdePkg/Library/UefiDevicePathLibDevicePathProtocol/UefiDevicePathLib.c | 2 | ||||
-rw-r--r-- | MdePkg/Library/UefiLib/UefiLib.inf | 3 | ||||
-rw-r--r-- | MdePkg/Library/UefiLib/UefiLibInternal.h | 2 |
6 files changed, 37 insertions, 63 deletions
diff --git a/MdePkg/Include/Library/DevicePathLib.h b/MdePkg/Include/Library/DevicePathLib.h index 244e351400..8df025353b 100644 --- a/MdePkg/Include/Library/DevicePathLib.h +++ b/MdePkg/Include/Library/DevicePathLib.h @@ -15,6 +15,24 @@ #ifndef __DEVICE_PATH_LIB_H__
#define __DEVICE_PATH_LIB_H__
+#include <Library/BaseLib.h>
+
+#define END_DEVICE_PATH_LENGTH (sizeof (EFI_DEVICE_PATH_PROTOCOL))
+#define DevicePathNodeLength(Node) ReadUnaligned16 ((UINT16 *)&((EFI_DEVICE_PATH_PROTOCOL *)(Node))->Length[0])
+#define NextDevicePathNode(Node) ((EFI_DEVICE_PATH_PROTOCOL *)((UINT8 *)(Node) + DevicePathNodeLength(Node)))
+#define DevicePathType(Node) (((EFI_DEVICE_PATH_PROTOCOL *)(Node))->Type)
+#define DevicePathSubType(Node) (((EFI_DEVICE_PATH_PROTOCOL *)(Node))->SubType)
+#define IsDevicePathEndType(Node) (DevicePathType (Node) == END_DEVICE_PATH_TYPE)
+#define IsDevicePathEnd(Node) (IsDevicePathEndType (Node) && DevicePathSubType(Node) == END_ENTIRE_DEVICE_PATH_SUBTYPE)
+#define IsDevicePathEndInstance(Node) (IsDevicePathEndType (Node) && DevicePathSubType(Node) == END_INSTANCE_DEVICE_PATH_SUBTYPE)
+
+#define SetDevicePathNodeLength(Node,NodeLength) WriteUnaligned16 ((UINT16 *)&((EFI_DEVICE_PATH_PROTOCOL *)(Node))->Length[0], (UINT16)(NodeLength))
+#define SetDevicePathEndNode(Node) { \
+ DevicePathType (Node) = END_DEVICE_PATH_TYPE; \
+ DevicePathSubType (Node) = END_ENTIRE_DEVICE_PATH_SUBTYPE; \
+ SetDevicePathNodeLength ((Node), END_DEVICE_PATH_LENGTH); \
+ }
+
/**
Returns the size of a device path in bytes.
diff --git a/MdePkg/Include/Protocol/DevicePath.h b/MdePkg/Include/Protocol/DevicePath.h index f5df67a97f..2304205754 100644 --- a/MdePkg/Include/Protocol/DevicePath.h +++ b/MdePkg/Include/Protocol/DevicePath.h @@ -526,55 +526,9 @@ typedef union { #pragma pack()
-#define EFI_DP_TYPE_MASK 0x7F
-#define EFI_DP_TYPE_UNPACKED 0x80
#define END_DEVICE_PATH_TYPE 0x7f
-
-#define EFI_END_ENTIRE_DEVICE_PATH 0xff
-#define EFI_END_ENTIRE_DEVICE_PATH_SUBTYPE 0xff
-#define EFI_END_INSTANCE_DEVICE_PATH 0x01
-#define END_ENTIRE_DEVICE_PATH_SUBTYPE EFI_END_ENTIRE_DEVICE_PATH_SUBTYPE
-#define END_INSTANCE_DEVICE_PATH_SUBTYPE EFI_END_INSTANCE_DEVICE_PATH
-
-#define EFI_END_DEVICE_PATH_LENGTH (sizeof (EFI_DEVICE_PATH_PROTOCOL))
-#define END_DEVICE_PATH_LENGTH EFI_END_DEVICE_PATH_LENGTH
-
-#define DP_IS_END_TYPE(a)
-#define DP_IS_END_SUBTYPE(a) (((a)->SubType == END_ENTIRE_DEVICE_PATH_SUBTYPE)
-#define DevicePathSubType(a) ((a)->SubType)
-#define IsDevicePathUnpacked(a) ((a)->Type & EFI_DP_TYPE_UNPACKED)
-
-#define EfiDevicePathNodeLength(a) (((a)->Length[0]) | ((a)->Length[1] << 8))
-#define DevicePathNodeLength(a) (EfiDevicePathNodeLength(a))
-#define EfiNextDevicePathNode(a) ((EFI_DEVICE_PATH_PROTOCOL *) (((UINT8 *) (a)) + EfiDevicePathNodeLength (a)))
-#define NextDevicePathNode(a) (EfiNextDevicePathNode(a))
-
-#define EfiDevicePathType(a) (((a)->Type) & EFI_DP_TYPE_MASK)
-#define DevicePathType(a) (EfiDevicePathType(a))
-#define EfiIsDevicePathEndType(a) (EfiDevicePathType (a) == END_DEVICE_PATH_TYPE)
-#define IsDevicePathEndType(a) (EfiIsDevicePathEndType(a))
-
-
-#define EfiIsDevicePathEndSubType(a) ((a)->SubType == EFI_END_ENTIRE_DEVICE_PATH_SUBTYPE)
-#define IsDevicePathEndSubType(a) (EfiIsDevicePathEndSubType(a))
-#define EfiIsDevicePathEndInstanceSubType(a) ((a)->SubType == EFI_END_INSTANCE_DEVICE_PATH)
-
-#define EfiIsDevicePathEnd(a) (EfiIsDevicePathEndType (a) && EfiIsDevicePathEndSubType (a))
-#define IsDevicePathEnd(a) (EfiIsDevicePathEnd(a))
-#define EfiIsDevicePathEndInstance(a) (EfiIsDevicePathEndType (a) && EfiIsDevicePathEndInstanceSubType (a))
-
-
-#define SetDevicePathNodeLength(a,l) { \
- (a)->Length[0] = (UINT8) (l); \
- (a)->Length[1] = (UINT8) ((l) >> 8); \
- }
-
-#define SetDevicePathEndNode(a) { \
- (a)->Type = END_DEVICE_PATH_TYPE; \
- (a)->SubType = END_ENTIRE_DEVICE_PATH_SUBTYPE; \
- (a)->Length[0] = sizeof(EFI_DEVICE_PATH_PROTOCOL); \
- (a)->Length[1] = 0; \
- }
+#define END_ENTIRE_DEVICE_PATH_SUBTYPE 0xFF
+#define END_INSTANCE_DEVICE_PATH_SUBTYPE 0x01
extern EFI_GUID gEfiDevicePathProtocolGuid;
diff --git a/MdePkg/Library/UefiDevicePathLib/UefiDevicePathLib.c b/MdePkg/Library/UefiDevicePathLib/UefiDevicePathLib.c index 2d266c70b7..708b48a088 100644 --- a/MdePkg/Library/UefiDevicePathLib/UefiDevicePathLib.c +++ b/MdePkg/Library/UefiDevicePathLib/UefiDevicePathLib.c @@ -70,14 +70,14 @@ GetDevicePathSize ( // Search for the end of the device path structure
//
Start = DevicePath;
- while (!EfiIsDevicePathEnd (DevicePath)) {
- DevicePath = EfiNextDevicePathNode (DevicePath);
+ while (!IsDevicePathEnd (DevicePath)) {
+ DevicePath = NextDevicePathNode (DevicePath);
}
//
// Compute the size and add back in the size of the end device path structure
//
- return ((UINTN) DevicePath - (UINTN) Start) + EfiDevicePathNodeLength (DevicePath);
+ return ((UINTN) DevicePath - (UINTN) Start) + DevicePathNodeLength (DevicePath);
}
/**
@@ -166,7 +166,7 @@ AppendDevicePath ( //
Size1 = GetDevicePathSize (FirstDevicePath);
Size2 = GetDevicePathSize (SecondDevicePath);
- Size = Size1 + Size2 - EFI_END_DEVICE_PATH_LENGTH;
+ Size = Size1 + Size2 - END_DEVICE_PATH_LENGTH;
NewDevicePath = AllocatePool (Size);
@@ -176,7 +176,7 @@ AppendDevicePath ( // Over write FirstDevicePath EndNode and do the copy
//
DevicePath2 = (EFI_DEVICE_PATH_PROTOCOL *) ((CHAR8 *) NewDevicePath +
- (Size1 - EFI_END_DEVICE_PATH_LENGTH));
+ (Size1 - END_DEVICE_PATH_LENGTH));
CopyMem (DevicePath2, SecondDevicePath, Size2);
}
@@ -224,7 +224,7 @@ AppendDevicePathNode ( //
NodeLength = DevicePathNodeLength (DevicePathNode);
- TempDevicePath = AllocatePool (NodeLength + EFI_END_DEVICE_PATH_LENGTH);
+ TempDevicePath = AllocatePool (NodeLength + END_DEVICE_PATH_LENGTH);
if (TempDevicePath == NULL) {
return NULL;
}
@@ -451,12 +451,12 @@ IsDevicePathMultiInstance ( }
Node = DevicePath;
- while (!EfiIsDevicePathEnd (Node)) {
- if (EfiIsDevicePathEndInstance (Node)) {
+ while (!IsDevicePathEnd (Node)) {
+ if (IsDevicePathEndInstance (Node)) {
return TRUE;
}
- Node = EfiNextDevicePathNode (Node);
+ Node = NextDevicePathNode (Node);
}
return FALSE;
@@ -518,15 +518,16 @@ FileDevicePath ( IN CONST CHAR16 *FileName
)
{
- UINTN Size;
+ UINT16 Size;
FILEPATH_DEVICE_PATH *FilePath;
EFI_DEVICE_PATH_PROTOCOL *DevicePath;
EFI_DEVICE_PATH_PROTOCOL *FileDevicePath;
DevicePath = NULL;
- Size = StrSize (FileName);
- FileDevicePath = AllocatePool (Size + SIZE_OF_FILEPATH_DEVICE_PATH + EFI_END_DEVICE_PATH_LENGTH);
+ Size = (UINT16) StrSize (FileName);
+
+ FileDevicePath = AllocatePool (Size + SIZE_OF_FILEPATH_DEVICE_PATH + END_DEVICE_PATH_LENGTH);
if (FileDevicePath != NULL) {
FilePath = (FILEPATH_DEVICE_PATH *) FileDevicePath;
FilePath->Header.Type = MEDIA_DEVICE_PATH;
diff --git a/MdePkg/Library/UefiDevicePathLibDevicePathProtocol/UefiDevicePathLib.c b/MdePkg/Library/UefiDevicePathLibDevicePathProtocol/UefiDevicePathLib.c index 6ea34237bc..37a0ae792b 100644 --- a/MdePkg/Library/UefiDevicePathLibDevicePathProtocol/UefiDevicePathLib.c +++ b/MdePkg/Library/UefiDevicePathLibDevicePathProtocol/UefiDevicePathLib.c @@ -342,7 +342,7 @@ FileDevicePath ( DevicePath = NULL;
Size = StrSize (FileName);
- FileDevicePath = AllocatePool (Size + SIZE_OF_FILEPATH_DEVICE_PATH + EFI_END_DEVICE_PATH_LENGTH);
+ FileDevicePath = AllocatePool (Size + SIZE_OF_FILEPATH_DEVICE_PATH + END_DEVICE_PATH_LENGTH);
if (FileDevicePath != NULL) {
FilePath = (FILEPATH_DEVICE_PATH *) FileDevicePath;
FilePath->Header.Type = MEDIA_DEVICE_PATH;
diff --git a/MdePkg/Library/UefiLib/UefiLib.inf b/MdePkg/Library/UefiLib/UefiLib.inf index 315eec1d5c..103014cd3d 100644 --- a/MdePkg/Library/UefiLib/UefiLib.inf +++ b/MdePkg/Library/UefiLib/UefiLib.inf @@ -55,7 +55,8 @@ BaseLib
UefiBootServicesTableLib
UefiRuntimeServicesTableLib
-
+ DevicePathLib
+
[Guids]
gEfiEventReadyToBootGuid # ALWAYS_CONSUMED
gEfiEventLegacyBootGuid # ALWAYS_CONSUMED
diff --git a/MdePkg/Library/UefiLib/UefiLibInternal.h b/MdePkg/Library/UefiLib/UefiLibInternal.h index bd4f056098..ef28195b97 100644 --- a/MdePkg/Library/UefiLib/UefiLibInternal.h +++ b/MdePkg/Library/UefiLib/UefiLibInternal.h @@ -35,6 +35,6 @@ #include <Library/MemoryAllocationLib.h>
#include <Library/PcdLib.h>
#include <Library/PrintLib.h>
-
+#include <Library/DevicePathLib.h>
#endif
|