\r
**/\r
\r
-\r
#include <Uefi.h>\r
\r
#include <Protocol/DevicePathUtilities.h>\r
#include <Library/UefiBootServicesTableLib.h>\r
#include <Library/PcdLib.h>\r
\r
-GLOBAL_REMOVE_IF_UNREFERENCED EFI_DEVICE_PATH_UTILITIES_PROTOCOL *mDevicePathLibDevicePathUtilities = NULL;\r
-GLOBAL_REMOVE_IF_UNREFERENCED EFI_DEVICE_PATH_TO_TEXT_PROTOCOL *mDevicePathLibDevicePathToText = NULL;\r
-GLOBAL_REMOVE_IF_UNREFERENCED EFI_DEVICE_PATH_FROM_TEXT_PROTOCOL *mDevicePathLibDevicePathFromText = NULL;\r
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_DEVICE_PATH_UTILITIES_PROTOCOL *mDevicePathLibDevicePathUtilities = NULL;\r
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_DEVICE_PATH_TO_TEXT_PROTOCOL *mDevicePathLibDevicePathToText = NULL;\r
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_DEVICE_PATH_FROM_TEXT_PROTOCOL *mDevicePathLibDevicePathFromText = NULL;\r
\r
//\r
// Template for an end-of-device path node.\r
EFI_STATUS\r
EFIAPI\r
DevicePathLibConstructor (\r
- IN EFI_HANDLE ImageHandle,\r
- IN EFI_SYSTEM_TABLE *SystemTable\r
+ IN EFI_HANDLE ImageHandle,\r
+ IN EFI_SYSTEM_TABLE *SystemTable\r
)\r
{\r
- EFI_STATUS Status;\r
+ EFI_STATUS Status;\r
\r
Status = gBS->LocateProtocol (\r
&gEfiDevicePathUtilitiesProtocolGuid,\r
NULL,\r
- (VOID**) &mDevicePathLibDevicePathUtilities\r
+ (VOID **)&mDevicePathLibDevicePathUtilities\r
);\r
ASSERT_EFI_ERROR (Status);\r
ASSERT (mDevicePathLibDevicePathUtilities != NULL);\r
BOOLEAN\r
EFIAPI\r
IsDevicePathValid (\r
- IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath,\r
- IN UINTN MaxSize\r
+ IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath,\r
+ IN UINTN MaxSize\r
)\r
{\r
- UINTN Count;\r
- UINTN Size;\r
- UINTN NodeLength;\r
+ UINTN Count;\r
+ UINTN Size;\r
+ UINTN NodeLength;\r
\r
ASSERT (DevicePath != NULL);\r
\r
if (NodeLength > MAX_UINTN - Size) {\r
return FALSE;\r
}\r
+\r
Size += NodeLength;\r
\r
//\r
//\r
// FilePath must be a NULL-terminated string.\r
//\r
- if (DevicePathType (DevicePath) == MEDIA_DEVICE_PATH &&\r
- DevicePathSubType (DevicePath) == MEDIA_FILEPATH_DP &&\r
- *(CHAR16 *)((UINT8 *)DevicePath + NodeLength - 2) != 0) {\r
+ if ((DevicePathType (DevicePath) == MEDIA_DEVICE_PATH) &&\r
+ (DevicePathSubType (DevicePath) == MEDIA_FILEPATH_DP) &&\r
+ (*(CHAR16 *)((UINT8 *)DevicePath + NodeLength - 2) != 0))\r
+ {\r
return FALSE;\r
}\r
}\r
//\r
// Only return TRUE when the End Device Path node is valid.\r
//\r
- return (BOOLEAN) (DevicePathNodeLength (DevicePath) == END_DEVICE_PATH_LENGTH);\r
+ return (BOOLEAN)(DevicePathNodeLength (DevicePath) == END_DEVICE_PATH_LENGTH);\r
}\r
\r
/**\r
)\r
{\r
ASSERT (Node != NULL);\r
- return (EFI_DEVICE_PATH_PROTOCOL *)((UINT8 *)(Node) + DevicePathNodeLength(Node));\r
+ return (EFI_DEVICE_PATH_PROTOCOL *)((UINT8 *)(Node) + DevicePathNodeLength (Node));\r
}\r
\r
/**\r
)\r
{\r
ASSERT (Node != NULL);\r
- return (BOOLEAN) (DevicePathType (Node) == END_DEVICE_PATH_TYPE);\r
+ return (BOOLEAN)(DevicePathType (Node) == END_DEVICE_PATH_TYPE);\r
}\r
\r
/**\r
)\r
{\r
ASSERT (Node != NULL);\r
- return (BOOLEAN) (IsDevicePathEndType (Node) && DevicePathSubType(Node) == END_ENTIRE_DEVICE_PATH_SUBTYPE);\r
+ return (BOOLEAN)(IsDevicePathEndType (Node) && DevicePathSubType (Node) == END_ENTIRE_DEVICE_PATH_SUBTYPE);\r
}\r
\r
/**\r
)\r
{\r
ASSERT (Node != NULL);\r
- return (BOOLEAN) (IsDevicePathEndType (Node) && DevicePathSubType(Node) == END_INSTANCE_DEVICE_PATH_SUBTYPE);\r
+ return (BOOLEAN)(IsDevicePathEndType (Node) && DevicePathSubType (Node) == END_INSTANCE_DEVICE_PATH_SUBTYPE);\r
}\r
\r
/**\r
EFI_DEVICE_PATH_PROTOCOL *\r
EFIAPI\r
GetNextDevicePathInstance (\r
- IN OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath,\r
- OUT UINTN *Size\r
+ IN OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath,\r
+ OUT UINTN *Size\r
)\r
{\r
ASSERT (Size != NULL);\r
EFI_DEVICE_PATH_PROTOCOL *\r
EFIAPI\r
CreateDeviceNode (\r
- IN UINT8 NodeType,\r
- IN UINT8 NodeSubType,\r
- IN UINT16 NodeLength\r
+ IN UINT8 NodeType,\r
+ IN UINT8 NodeSubType,\r
+ IN UINT16 NodeLength\r
)\r
{\r
return mDevicePathLibDevicePathUtilities->CreateDeviceNode (NodeType, NodeSubType, NodeLength);\r
EFI_DEVICE_PATH_PROTOCOL *\r
EFIAPI\r
DevicePathFromHandle (\r
- IN EFI_HANDLE Handle\r
+ IN EFI_HANDLE Handle\r
)\r
{\r
EFI_DEVICE_PATH_PROTOCOL *DevicePath;\r
Status = gBS->HandleProtocol (\r
Handle,\r
&gEfiDevicePathProtocolGuid,\r
- (VOID *) &DevicePath\r
+ (VOID *)&DevicePath\r
);\r
if (EFI_ERROR (Status)) {\r
DevicePath = NULL;\r
}\r
+\r
return DevicePath;\r
}\r
\r
EFI_DEVICE_PATH_PROTOCOL *\r
EFIAPI\r
FileDevicePath (\r
- IN EFI_HANDLE Device OPTIONAL,\r
- IN CONST CHAR16 *FileName\r
+ IN EFI_HANDLE Device OPTIONAL,\r
+ IN CONST CHAR16 *FileName\r
)\r
{\r
UINTN Size;\r
\r
DevicePath = NULL;\r
\r
- Size = StrSize (FileName);\r
+ Size = StrSize (FileName);\r
FileDevicePath = AllocatePool (Size + SIZE_OF_FILEPATH_DEVICE_PATH + END_DEVICE_PATH_LENGTH);\r
if (FileDevicePath != NULL) {\r
- FilePath = (FILEPATH_DEVICE_PATH *) FileDevicePath;\r
+ FilePath = (FILEPATH_DEVICE_PATH *)FileDevicePath;\r
FilePath->Header.Type = MEDIA_DEVICE_PATH;\r
FilePath->Header.SubType = MEDIA_FILEPATH_DP;\r
CopyMem (&FilePath->PathName, FileName, Size);\r
**/\r
VOID *\r
UefiDevicePathLibLocateProtocol (\r
- EFI_GUID *ProtocolGuid\r
+ EFI_GUID *ProtocolGuid\r
)\r
{\r
- EFI_STATUS Status;\r
- VOID *Protocol;\r
+ EFI_STATUS Status;\r
+ VOID *Protocol;\r
+\r
Status = gBS->LocateProtocol (\r
ProtocolGuid,\r
NULL,\r
- (VOID**) &Protocol\r
+ (VOID **)&Protocol\r
);\r
if (EFI_ERROR (Status)) {\r
return NULL;\r
if (mDevicePathLibDevicePathToText == NULL) {\r
mDevicePathLibDevicePathToText = UefiDevicePathLibLocateProtocol (&gEfiDevicePathToTextProtocolGuid);\r
}\r
+\r
if (mDevicePathLibDevicePathToText != NULL) {\r
return mDevicePathLibDevicePathToText->ConvertDeviceNodeToText (DeviceNode, DisplayOnly, AllowShortcuts);\r
} else {\r
CHAR16 *\r
EFIAPI\r
ConvertDevicePathToText (\r
- IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath,\r
- IN BOOLEAN DisplayOnly,\r
- IN BOOLEAN AllowShortcuts\r
+ IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath,\r
+ IN BOOLEAN DisplayOnly,\r
+ IN BOOLEAN AllowShortcuts\r
)\r
{\r
if (mDevicePathLibDevicePathToText == NULL) {\r
mDevicePathLibDevicePathToText = UefiDevicePathLibLocateProtocol (&gEfiDevicePathToTextProtocolGuid);\r
}\r
+\r
if (mDevicePathLibDevicePathToText != NULL) {\r
return mDevicePathLibDevicePathToText->ConvertDevicePathToText (DevicePath, DisplayOnly, AllowShortcuts);\r
} else {\r
EFI_DEVICE_PATH_PROTOCOL *\r
EFIAPI\r
ConvertTextToDeviceNode (\r
- IN CONST CHAR16 *TextDeviceNode\r
+ IN CONST CHAR16 *TextDeviceNode\r
)\r
{\r
if (mDevicePathLibDevicePathFromText == NULL) {\r
mDevicePathLibDevicePathFromText = UefiDevicePathLibLocateProtocol (&gEfiDevicePathFromTextProtocolGuid);\r
}\r
+\r
if (mDevicePathLibDevicePathFromText != NULL) {\r
return mDevicePathLibDevicePathFromText->ConvertTextToDeviceNode (TextDeviceNode);\r
} else {\r
EFI_DEVICE_PATH_PROTOCOL *\r
EFIAPI\r
ConvertTextToDevicePath (\r
- IN CONST CHAR16 *TextDevicePath\r
+ IN CONST CHAR16 *TextDevicePath\r
)\r
{\r
if (mDevicePathLibDevicePathFromText == NULL) {\r
mDevicePathLibDevicePathFromText = UefiDevicePathLibLocateProtocol (&gEfiDevicePathFromTextProtocolGuid);\r
}\r
+\r
if (mDevicePathLibDevicePathFromText != NULL) {\r
return mDevicePathLibDevicePathFromText->ConvertTextToDevicePath (TextDevicePath);\r
} else {\r