From 572f5d8a7b704eed9f54381b6bb3a6e3a3e79816 Mon Sep 17 00:00:00 2001 From: qhuang8 Date: Wed, 16 Jul 2008 01:10:45 +0000 Subject: [PATCH] Code scrub for DevicePathDxe driver. git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@5479 6f19259b-4bc3-4df7-8a09-765794883524 --- .../Universal/DevicePathDxe/DevicePath.c | 45 +- .../Universal/DevicePathDxe/DevicePath.h | 382 +++--- .../Universal/DevicePathDxe/DevicePathDxe.inf | 10 +- .../DevicePathDxe/DevicePathFromText.c | 1067 ++++++++++++----- .../DevicePathDxe/DevicePathToText.c | 828 +++++++++---- .../DevicePathDxe/DevicePathUtilities.c | 266 ++-- 6 files changed, 1726 insertions(+), 872 deletions(-) diff --git a/MdeModulePkg/Universal/DevicePathDxe/DevicePath.c b/MdeModulePkg/Universal/DevicePathDxe/DevicePath.c index 3149184a34..660b595de5 100644 --- a/MdeModulePkg/Universal/DevicePathDxe/DevicePath.c +++ b/MdeModulePkg/Universal/DevicePathDxe/DevicePath.c @@ -17,7 +17,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. EFI_HANDLE mDevicePathHandle = NULL; -GLOBAL_REMOVE_IF_UNREFERENCED const EFI_DEVICE_PATH_UTILITIES_PROTOCOL mDevicePathUtilities = { +GLOBAL_REMOVE_IF_UNREFERENCED CONST EFI_DEVICE_PATH_UTILITIES_PROTOCOL mDevicePathUtilities = { GetDevicePathSizeProtocolInterface, DuplicateDevicePathProtocolInterface, AppendDevicePathProtocolInterface, @@ -28,42 +28,43 @@ GLOBAL_REMOVE_IF_UNREFERENCED const EFI_DEVICE_PATH_UTILITIES_PROTOCOL mDevicePa CreateDeviceNodeProtocolInterface }; -GLOBAL_REMOVE_IF_UNREFERENCED const EFI_DEVICE_PATH_TO_TEXT_PROTOCOL mDevicePathToText = { +GLOBAL_REMOVE_IF_UNREFERENCED CONST EFI_DEVICE_PATH_TO_TEXT_PROTOCOL mDevicePathToText = { ConvertDeviceNodeToText, ConvertDevicePathToText }; -GLOBAL_REMOVE_IF_UNREFERENCED const EFI_DEVICE_PATH_FROM_TEXT_PROTOCOL mDevicePathFromText = { - ConvertTextToDeviceNode, - ConvertTextToDevicePath +GLOBAL_REMOVE_IF_UNREFERENCED CONST EFI_DEVICE_PATH_FROM_TEXT_PROTOCOL mDevicePathFromText = { + ConvertTextToDeviceNode, + ConvertTextToDevicePath }; -GLOBAL_REMOVE_IF_UNREFERENCED const EFI_GUID mEfiDevicePathMessagingUartFlowControlGuid = DEVICE_PATH_MESSAGING_UART_FLOW_CONTROL; -GLOBAL_REMOVE_IF_UNREFERENCED const EFI_GUID mEfiDevicePathMessagingSASGuid = DEVICE_PATH_MESSAGING_SAS; +GLOBAL_REMOVE_IF_UNREFERENCED CONST EFI_GUID mEfiDevicePathMessagingUartFlowControlGuid = DEVICE_PATH_MESSAGING_UART_FLOW_CONTROL; +GLOBAL_REMOVE_IF_UNREFERENCED CONST EFI_GUID mEfiDevicePathMessagingSASGuid = DEVICE_PATH_MESSAGING_SAS; + + +/** + The user Entry Point for DevicePath module. + + This is the entrhy point for DevicePath module. It installs the UEFI Device Path Utility Protocol and + optionall the Device Path to Text and Device Path from Text protocols based on feature flags. + + @param[in] ImageHandle The firmware allocated handle for the EFI image. + @param[in] SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The entry point is executed successfully. + @retval Others Some error occurs when executing this entry point. + +**/ EFI_STATUS EFIAPI DevicePathEntryPoint ( IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable ) -/*++ - - Routine Description: - Entry point for EFI drivers. - - Arguments: - ImageHandle - EFI_HANDLE - SystemTable - EFI_SYSTEM_TABLE - - Returns: - EFI_SUCCESS - others - ---*/ { EFI_STATUS Status; - + Status = EFI_UNSUPPORTED; if (FeaturePcdGet (PcdDevicePathSupportDevicePathToText)) { if (FeaturePcdGet (PcdDevicePathSupportDevicePathFromText)) { diff --git a/MdeModulePkg/Universal/DevicePathDxe/DevicePath.h b/MdeModulePkg/Universal/DevicePathDxe/DevicePath.h index 7cd0626b90..073f9b9959 100644 --- a/MdeModulePkg/Universal/DevicePathDxe/DevicePath.h +++ b/MdeModulePkg/Universal/DevicePathDxe/DevicePath.h @@ -12,8 +12,8 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. **/ -#ifndef _DEVICE_PATH_DRIVER_H -#define _DEVICE_PATH_DRIVER_H +#ifndef _DEVICE_PATH_DRIVER_H_ +#define _DEVICE_PATH_DRIVER_H_ #include #include @@ -51,7 +51,7 @@ extern const EFI_GUID mEfiDevicePathMessagingSASGuid; #define DEVICE_PATH_INSTANCE_END 2 #define DEVICE_PATH_END 3 -#define SetDevicePathInstanceEndNode(a) { \ +#define SET_DEVICE_PATH_INSTANCE_END_NODE(a) { \ (a)->Type = END_DEVICE_PATH_TYPE; \ (a)->SubType = END_INSTANCE_DEVICE_PATH_SUBTYPE; \ (a)->Length[0] = sizeof (EFI_DEVICE_PATH_PROTOCOL); \ @@ -67,6 +67,12 @@ typedef struct { UINTN MaxLen; } POOL_PRINT; +typedef +EFI_DEVICE_PATH_PROTOCOL * +(*DUMP_NODE) ( + IN CHAR16 *DeviceNodeStr + ); + typedef struct { UINT8 Type; UINT8 SubType; @@ -75,7 +81,7 @@ typedef struct { typedef struct { CHAR16 *DevicePathNodeText; - EFI_DEVICE_PATH_PROTOCOL * (*Function) (CHAR16 *); + DUMP_NODE Function; } DEVICE_PATH_FROM_TEXT_TABLE; typedef struct { @@ -148,273 +154,279 @@ typedef struct { #pragma pack() +/** + Converts a device node to its string representation. + + @param DeviceNode A Pointer to the device node to be converted. + @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation + of the display node is used, where applicable. If DisplayOnly + is FALSE, then the longer text representation of the display node + is used. + @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text + representation for a device node can be used, where applicable. + + @return A pointer to the allocated text representation of the device node or NULL if DeviceNode + is NULL or there was insufficient memory. + +**/ CHAR16 * +EFIAPI ConvertDeviceNodeToText ( IN CONST EFI_DEVICE_PATH_PROTOCOL *DeviceNode, IN BOOLEAN DisplayOnly, IN BOOLEAN AllowShortcuts - ) -/*++ + ); - Routine Description: - Convert a device node to its text representation. +/** + Converts a device path to its text representation. - Arguments: - DeviceNode - Points to the device node to be converted. - DisplayOnly - If DisplayOnly is TRUE, then the shorter text representation + @param DevicePath A Pointer to the device to be converted. + @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation of the display node is used, where applicable. If DisplayOnly is FALSE, then the longer text representation of the display node is used. - AllowShortcuts - If AllowShortcuts is TRUE, then the shortcut forms of text + @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text representation for a device node can be used, where applicable. - Returns: - A pointer - a pointer to the allocated text representation of the device node. - NULL - if DeviceNode is NULL or there was insufficient memory. - ---*/ -; + @return A pointer to the allocated text representation of the device path or + NULL if DeviceNode is NULL or there was insufficient memory. +**/ CHAR16 * +EFIAPI ConvertDevicePathToText ( - IN CONST EFI_DEVICE_PATH_PROTOCOL *DeviceNode, - IN BOOLEAN DisplayOnly, - IN BOOLEAN AllowShortcuts - ) -/*++ + IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath, + IN BOOLEAN DisplayOnly, + IN BOOLEAN AllowShortcuts + ); - Routine Description: - Convert a device path to its text representation. +/** + Convert text to the binary representation of a device node. - Arguments: - DeviceNode - Points to the device path to be converted. - DisplayOnly - If DisplayOnly is TRUE, then the shorter text representation - of the display node is used, where applicable. If DisplayOnly - is FALSE, then the longer text representation of the display node - is used. - AllowShortcuts - If AllowShortcuts is TRUE, then the shortcut forms of text - representation for a device node can be used, where applicable. - - Returns: - A pointer - a pointer to the allocated text representation of the device path. - NULL - if DeviceNode is NULL or there was insufficient memory. + @param TextDeviceNode TextDeviceNode points to the text representation of a device + node. Conversion starts with the first character and continues + until the first non-device node character. ---*/ -; + @return A pointer to the EFI device node or NULL if TextDeviceNode is NULL or there was + insufficient memory or text unsupported. +**/ EFI_DEVICE_PATH_PROTOCOL * +EFIAPI ConvertTextToDeviceNode ( IN CONST CHAR16 *TextDeviceNode - ) -/*++ + ); - Routine Description: - Convert text to the binary representation of a device node. +/** + Convert text to the binary representation of a device path. - Arguments: - TextDeviceNode - TextDeviceNode points to the text representation of a device - node. Conversion starts with the first character and continues - until the first non-device node character. - Returns: - A pointer - Pointer to the EFI device node. - NULL - if TextDeviceNode is NULL or there was insufficient memory. + @param TextDevicePath TextDevicePath points to the text representation of a device + path. Conversion starts with the first character and continues + until the first non-device node character. ---*/ -; + @return A pointer to the allocated device path or NULL if TextDeviceNode is NULL or + there was insufficient memory. +**/ EFI_DEVICE_PATH_PROTOCOL * +EFIAPI ConvertTextToDevicePath ( IN CONST CHAR16 *TextDevicePath - ) -/*++ + ); - Routine Description: - Convert text to the binary representation of a device path. +/** + Returns the size of a device path in bytes. - Arguments: - TextDevicePath - TextDevicePath points to the text representation of a device - path. Conversion starts with the first character and continues - until the first non-device node character. + This function returns the size, in bytes, of the device path data structure specified by + DevicePath including the end of device path node. If DevicePath is NULL, then 0 is returned. - Returns: - A pointer - Pointer to the allocated device path. - NULL - if TextDeviceNode is NULL or there was insufficient memory. + @param DevicePath A pointer to a device path data structure. ---*/ -; + @return The size of a device path in bytes. +**/ UINTN +EFIAPI GetDevicePathSizeProtocolInterface ( IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath - ) -/*++ + ); - Routine Description: - Returns the size of the device path, in bytes. +/** + Creates a new device path by appending a second device path to a first device path. - Arguments: - DevicePath - Points to the start of the EFI device path. + This function allocates space for a new copy of the device path specified by DevicePath. If + DevicePath is NULL, then NULL is returned. If the memory is successfully allocated, then the + contents of DevicePath are copied to the newly allocated buffer, and a pointer to that buffer + is returned. Otherwise, NULL is returned. - Returns: - Size - Size of the specified device path, in bytes, including the end-of-path tag. + @param DevicePath A pointer to a device path data structure. ---*/ -; + @return A pointer to the duplicated device path. +**/ EFI_DEVICE_PATH_PROTOCOL * +EFIAPI DuplicateDevicePathProtocolInterface ( IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath - ) -/*++ + ); - Routine Description: - Create a duplicate of the specified path. +/** + Creates a new device path by appending a second device path to a first device path. - Arguments: - DevicePath - Points to the source EFI device path. + This function creates a new device path by appending a copy of SecondDevicePath to a copy of + FirstDevicePath in a newly allocated buffer. Only the end-of-device-path device node from + SecondDevicePath is retained. The newly created device path is returned. + If FirstDevicePath is NULL, then it is ignored, and a duplicate of SecondDevicePath is returned. + If SecondDevicePath is NULL, then it is ignored, and a duplicate of FirstDevicePath is returned. + If both FirstDevicePath and SecondDevicePath are NULL, then a copy of an end-of-device-path is + returned. + If there is not enough memory for the newly allocated buffer, then NULL is returned. + The memory for the new device path is allocated from EFI boot services memory. It is the + responsibility of the caller to free the memory allocated. - Returns: - Pointer - A pointer to the duplicate device path. - NULL - Insufficient memory. + @param FirstDevicePath A pointer to a device path data structure. + @param SecondDevicePath A pointer to a device path data structure. ---*/ -; + @return A pointer to the new device path. +**/ EFI_DEVICE_PATH_PROTOCOL * +EFIAPI AppendDevicePathProtocolInterface ( - IN CONST EFI_DEVICE_PATH_PROTOCOL *Src1, - IN CONST EFI_DEVICE_PATH_PROTOCOL *Src2 - ) -/*++ - - Routine Description: - Create a new path by appending the second device path to the first. - - Arguments: - Src1 - Points to the first device path. If NULL, then it is ignored. - Src2 - Points to the second device path. If NULL, then it is ignored. - - Returns: - Pointer - A pointer to the newly created device path. - NULL - Memory could not be allocated - or either DevicePath or DeviceNode is NULL. - ---*/ -; + IN CONST EFI_DEVICE_PATH_PROTOCOL *FirstDevicePath, + IN CONST EFI_DEVICE_PATH_PROTOCOL *SecondDevicePath + ); + +/** + Creates a new path by appending the device node to the device path. + + This function creates a new device path by appending a copy of the device node specified by + DevicePathNode to a copy of the device path specified by DevicePath in an allocated buffer. + The end-of-device-path device node is moved after the end of the appended device node. + If DevicePathNode is NULL then a copy of DevicePath is returned. + If DevicePath is NULL then a copy of DevicePathNode, followed by an end-of-device path device + node is returned. + If both DevicePathNode and DevicePath are NULL then a copy of an end-of-device-path device node + is returned. + If there is not enough memory to allocate space for the new device path, then NULL is returned. + The memory is allocated from EFI boot services memory. It is the responsibility of the caller to + free the memory allocated. + + @param DevicePath A pointer to a device path data structure. + @param DevicePathNode A pointer to a single device path node. + + @return A pointer to the new device path. +**/ EFI_DEVICE_PATH_PROTOCOL * +EFIAPI AppendDeviceNodeProtocolInterface ( IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath, - IN CONST EFI_DEVICE_PATH_PROTOCOL *DeviceNode - ) -/*++ + IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePathNode + ); - Routine Description: - Creates a new path by appending the device node to the device path. +/** + Creates a new device path by appending the specified device path instance to the specified device + path. - Arguments: - DevicePath - Points to the device path. - DeviceNode - Points to the device node. + This function creates a new device path by appending a copy of the device path instance specified + by DevicePathInstance to a copy of the device path secified by DevicePath in a allocated buffer. + The end-of-device-path device node is moved after the end of the appended device path instance + and a new end-of-device-path-instance node is inserted between. + If DevicePath is NULL, then a copy if DevicePathInstance is returned. + If DevicePathInstance is NULL, then NULL is returned. + If there is not enough memory to allocate space for the new device path, then NULL is returned. + The memory is allocated from EFI boot services memory. It is the responsibility of the caller to + free the memory allocated. - Returns: - Pointer - A pointer to the allocated device node. - NULL - Memory could not be allocated - or either DevicePath or DeviceNode is NULL. + @param DevicePath A pointer to a device path data structure. + @param DevicePathInstance A pointer to a device path instance. ---*/ -; + @return A pointer to the new device path. +**/ EFI_DEVICE_PATH_PROTOCOL * +EFIAPI AppendDevicePathInstanceProtocolInterface ( IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath, IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePathInstance - ) -/*++ - - Routine Description: - Creates a new path by appending the specified device path instance to the specified device path. - - Arguments: - DevicePath - Points to the device path. If NULL, then ignored. - DevicePathInstance - Points to the device path instance. - - Returns: - Pointer - A pointer to the newly created device path - NULL - Memory could not be allocated or DevicePathInstance is NULL. - ---*/ -; + ); + +/** + Creates a copy of the current device path instance and returns a pointer to the next device path + instance. + + This function creates a copy of the current device path instance. It also updates DevicePath to + point to the next device path instance in the device path (or NULL if no more) and updates Size + to hold the size of the device path instance copy. + If DevicePath is NULL, then NULL is returned. + If there is not enough memory to allocate space for the new device path, then NULL is returned. + The memory is allocated from EFI boot services memory. It is the responsibility of the caller to + free the memory allocated. + If Size is NULL, then ASSERT(). + + @param DevicePath On input, this holds the pointer to the current device path + instance. On output, this holds the pointer to the next device + path instance or NULL if there are no more device path + instances in the device path pointer to a device path data + structure. + @param Size On output, this holds the size of the device path instance, in + bytes or zero, if DevicePath is NULL. + + @return A pointer to the current device path instance. +**/ EFI_DEVICE_PATH_PROTOCOL * +EFIAPI GetNextDevicePathInstanceProtocolInterface ( - IN OUT EFI_DEVICE_PATH_PROTOCOL **DevicePathInstance, - OUT UINTN *DevicePathInstanceSize - ) -/*++ + IN OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath, + OUT UINTN *Size + ); - Routine Description: - Creates a copy of the current device path instance and returns a pointer to the next device path instance. +/** + Determines if a device path is single or multi-instance. - Arguments: - DevicePathInstance - On input, this holds the pointer to the current device path - instance. On output, this holds the pointer to the next - device path instance or NULL if there are no more device - path instances in the device path. - DevicePathInstanceSize - On output, this holds the size of the device path instance, - in bytes or zero, if DevicePathInstance is zero. + This function returns TRUE if the device path specified by DevicePath is multi-instance. + Otherwise, FALSE is returned. If DevicePath is NULL, then FALSE is returned. - Returns: - Pointer - A pointer to the copy of the current device path instance. - NULL - DevicePathInstace was NULL on entry or there was insufficient memory. + @param DevicePath A pointer to a device path data structure. ---*/ -; + @retval TRUE DevicePath is multi-instance. + @retval FALSE DevicePath is not multi-instance or DevicePath is NULL. +**/ BOOLEAN +EFIAPI IsDevicePathMultiInstanceProtocolInterface ( IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath - ) -/*++ + ); - Routine Description: - Returns whether a device path is multi-instance. +/** + Creates a copy of the current device path instance and returns a pointer to the next device path + instance. - Arguments: - DevicePath - Points to the device path. If NULL, then ignored. + This function creates a new device node in a newly allocated buffer of size NodeLength and + initializes the device path node header with NodeType and NodeSubType. The new device path node + is returned. + If NodeLength is smaller than a device path header, then NULL is returned. + If there is not enough memory to allocate space for the new device path, then NULL is returned. + The memory is allocated from EFI boot services memory. It is the responsibility of the caller to + free the memory allocated. - Returns: - TRUE - The device path has more than one instance - FALSE - The device path is empty or contains only a single instance. + @param NodeType The device node type for the new device node. + @param NodeSubType The device node sub-type for the new device node. + @param NodeLength The length of the new device node. ---*/ -; + @return The new device path. +**/ EFI_DEVICE_PATH_PROTOCOL * +EFIAPI CreateDeviceNodeProtocolInterface ( IN UINT8 NodeType, IN UINT8 NodeSubType, IN UINT16 NodeLength - ) -/*++ - - Routine Description: - Creates a device node - - Arguments: - NodeType - NodeType is the device node type (EFI_DEVICE_PATH.Type) for - the new device node. - NodeSubType - NodeSubType is the device node sub-type - EFI_DEVICE_PATH.SubType) for the new device node. - NodeLength - NodeLength is the length of the device node - (EFI_DEVICE_PATH.Length) for the new device node. - - Returns: - Pointer - A pointer to the newly created device node. - NULL - NodeLength is less than - the size of the header or there was insufficient memory. - ---*/ -; + ); #endif diff --git a/MdeModulePkg/Universal/DevicePathDxe/DevicePathDxe.inf b/MdeModulePkg/Universal/DevicePathDxe/DevicePathDxe.inf index f6fe98eeb8..8036570b09 100644 --- a/MdeModulePkg/Universal/DevicePathDxe/DevicePathDxe.inf +++ b/MdeModulePkg/Universal/DevicePathDxe/DevicePathDxe.inf @@ -1,19 +1,19 @@ #/** @file -# +# # Component description file for Device Path Driver. -# +# # This driver implement these three UEFI deveice path protocols ( # DevicePathUtilities, DevicePahtToText and DevicePathFromText) and install them. -# +# # Copyright (c) 2006 - 2008, Intel Corporation.
# All rights reserved. This program and the accompanying materials # are licensed and made available under the terms and conditions of the BSD License # which accompanies this distribution. The full text of the license may be found at # http://opensource.org/licenses/bsd-license.php -# +# # THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, # WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -# +# #**/ [Defines] diff --git a/MdeModulePkg/Universal/DevicePathDxe/DevicePathFromText.c b/MdeModulePkg/Universal/DevicePathDxe/DevicePathFromText.c index 75e5cf8a32..e183abbfe0 100644 --- a/MdeModulePkg/Universal/DevicePathDxe/DevicePathFromText.c +++ b/MdeModulePkg/Universal/DevicePathDxe/DevicePathFromText.c @@ -14,54 +14,40 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. #include "DevicePath.h" -STATIC -CHAR16 * -StrDuplicate ( - IN CONST CHAR16 *Src - ) -/*++ - Routine Description: - Duplicate a string +/** - Arguments: - Src - Source string + Duplicates a string. - Returns: - Duplicated string + @param Src Source string. ---*/ + @return The duplicated string. + +**/ +CHAR16 * +StrDuplicate ( + IN CONST CHAR16 *Src + ) { - UINTN Length; - CHAR16 *ReturnStr; + return AllocateCopyPool (StrSize (Src), Src); +} - Length = StrLen ((CHAR16 *) Src); +/** - ReturnStr = AllocateCopyPool ((Length + 1) * sizeof (CHAR16), (VOID *) Src); + Get parameter in a pair of parentheses follow the given node name. + For example, given the "Pci(0,1)" and NodeName "Pci", it returns "0,1". - return ReturnStr; -} + @param Str Device Path Text. + @param NodeName Name of the node. -STATIC + @return Parameter text for the node. + +**/ CHAR16 * GetParamByNodeName ( IN CHAR16 *Str, IN CHAR16 *NodeName ) -/*++ - - Routine Description: - Get parameter in a pair of parentheses follow the given node name. - For example, given the "Pci(0,1)" and NodeName "Pci", it returns "0,1". - - Arguments: - Str - Device Path Text - NodeName - Name of the node - - Returns: - Parameter text for the node - ---*/ { CHAR16 *ParamStr; CHAR16 *StrPointer; @@ -113,28 +99,23 @@ GetParamByNodeName ( return ParamStr; } -STATIC +/** + Gets current sub-string from a string list, before return + the list header is moved to next sub-string. The sub-string is separated + by the specified character. For example, the separator is ',', the string + list is "2,0,3", it returns "2", the remain list move to "0,3" + + @param List A string list separated by the specified separator + @param Separator The separator character + + @return A pointer to the current sub-string + +**/ CHAR16 * SplitStr ( IN OUT CHAR16 **List, IN CHAR16 Separator ) -/*++ - - Routine Description: - Get current sub-string from a string list, before return - the list header is moved to next sub-string. The sub-string is separated - by the specified character. For example, the separator is ',', the string - list is "2,0,3", it returns "2", the remain list move to "0,3" - - Arguments: - List - A string list separated by the specified separator - Separator - The separator character - - Returns: - pointer - The current sub-string - ---*/ { CHAR16 *Str; CHAR16 *ReturnStr; @@ -172,7 +153,14 @@ SplitStr ( return ReturnStr; } -STATIC +/** + Gets the next parameter string from the list. + + @param List A string list separated by the specified separator + + @return A pointer to the current sub-string + +**/ CHAR16 * GetNextParamStr ( IN OUT CHAR16 **List @@ -184,26 +172,20 @@ GetNextParamStr ( return SplitStr (List, L','); } -STATIC +/** + Get one device node from entire device path text. + + @param DevicePath On input, the current Device Path node; on output, the next device path node + @param IsInstanceEnd This node is the end of a device path instance + + @return A device node text or NULL if no more device node available + +**/ CHAR16 * GetNextDeviceNodeStr ( IN OUT CHAR16 **DevicePath, OUT BOOLEAN *IsInstanceEnd ) -/*++ - - Routine Description: - Get one device node from entire device path text. - - Arguments: - Str - The entire device path text string - IsInstanceEnd - This node is the end of a device path instance - - Returns: - a pointer - A device node text - NULL - No more device node available - ---*/ { CHAR16 *Str; CHAR16 *ReturnStr; @@ -272,43 +254,39 @@ GetNextDeviceNodeStr ( } -STATIC +/** + Skip the leading white space and '0x' or '0X' of a integer string + + @param Str The integer string + @param IsHex TRUE: Hex string, FALSE: Decimal string + + @return The trimmed Hex string. + +**/ CHAR16 * TrimHexStr ( IN CHAR16 *Str, OUT BOOLEAN *IsHex ) -/*++ - - Routine Description: - Skip the leading white space and '0x' or '0X' of a integer string - - Arguments: - Str - The integer string - IsHex - 1: Hex string, 0: Decimal string - - Returns: - ---*/ { *IsHex = FALSE; // // skip preceeding white space // - while (*Str && *Str == ' ') { + while ((*Str != 0) && *Str == ' ') { Str += 1; } // // skip preceeding zeros // - while (*Str && *Str == '0') { + while ((*Str != 0) && *Str == '0') { Str += 1; } // // skip preceeding character 'x' or 'X' // - if (*Str && (*Str == 'x' || *Str == 'X')) { + if ((*Str != 0) && (*Str == 'x' || *Str == 'X')) { Str += 1; *IsHex = TRUE; } @@ -316,24 +294,19 @@ TrimHexStr ( return Str; } -STATIC -UINTN -Xtoi ( - IN CHAR16 *Str - ) -/*++ - -Routine Description: +/** - Convert hex string to uint + Convert hex string to uint. -Arguments: + @param Str The hex string - Str - The string - -Returns: + @return A UINTN value represented by Str ---*/ +**/ +UINTN +Xtoi ( + IN CHAR16 *Str + ) { UINTN Rvalue; UINTN Length; @@ -350,25 +323,19 @@ Returns: return Rvalue; } -STATIC -VOID -Xtoi64 ( - IN CHAR16 *Str, - IN UINT64 *Data - ) -/*++ - -Routine Description: +/** Convert hex string to 64 bit data. -Arguments: - - Str - The string - -Returns: + @param Str The hex string + @param Data A pointer to the UINT64 value represented by Str ---*/ +**/ +VOID +Xtoi64 ( + IN CHAR16 *Str, + OUT UINT64 *Data + ) { UINTN Length; @@ -377,46 +344,41 @@ Returns: HexStringToBuf ((UINT8 *) Data, &Length, Str, NULL); } -STATIC -UINTN -Dtoi ( - IN CHAR16 *str - ) -/*++ +/** -Routine Description: + Convert decimal string to uint. - Convert decimal string to uint + @param Str The decimal string -Arguments: + @return A UINTN value represented by Str - Str - The string - -Returns: - ---*/ +**/ +UINTN +Dtoi ( + IN CHAR16 *Str + ) { UINTN Rvalue; CHAR16 Char; UINTN High; UINTN Low; - ASSERT (str != NULL); + ASSERT (Str != NULL); High = (UINTN) -1 / 10; Low = (UINTN) -1 % 10; // // skip preceeding white space // - while (*str && *str == ' ') { - str += 1; + while ((*Str != 0) && *Str == ' ') { + Str += 1; } // // convert digits // Rvalue = 0; - Char = *(str++); - while (Char) { + Char = *(Str++); + while (Char != 0) { if (Char >= '0' && Char <= '9') { if ((Rvalue > High || Rvalue == High) && (Char - '0' > (INTN) Low)) { return (UINTN) -1; @@ -427,52 +389,46 @@ Returns: break; } - Char = *(str++); + Char = *(Str++); } return Rvalue; } -STATIC +/** + + Convert decimal string to uint. + + @param Str The decimal string + @param Data A pointer to the UINT64 value represented by Str + +**/ VOID Dtoi64 ( - IN CHAR16 *str, + IN CHAR16 *Str, OUT UINT64 *Data ) -/*++ - -Routine Description: - - Convert decimal string to uint - -Arguments: - - Str - The string - -Returns: - ---*/ { UINT64 Rvalue; CHAR16 Char; UINT64 High; UINT64 Low; - ASSERT (str != NULL); + ASSERT (Str != NULL); ASSERT (Data != NULL); // // skip preceeding white space // - while (*str && *str == ' ') { - str += 1; + while ((*Str != 0) && *Str == ' ') { + Str += 1; } // // convert digits // Rvalue = 0; - Char = *(str++); - while (Char) { + Char = *(Str++); + while (Char != 0) { if (Char >= '0' && Char <= '9') { High = LShiftU64 (Rvalue, 3); Low = LShiftU64 (Rvalue, 1); @@ -481,30 +437,25 @@ Returns: break; } - Char = *(str++); + Char = *(Str++); } *Data = Rvalue; } -STATIC -UINTN -Strtoi ( - IN CHAR16 *Str - ) -/*++ - -Routine Description: +/** Convert integer string to uint. -Arguments: + @param Str The integer string. If leading with "0x" or "0X", it's heximal. - Str - The integer string. If leading with "0x" or "0X", it's heximal. + @return A UINTN value represented by Str -Returns: - ---*/ +**/ +UINTN +Strtoi ( + IN CHAR16 *Str + ) { BOOLEAN IsHex; @@ -517,25 +468,19 @@ Returns: } } -STATIC -VOID -Strtoi64 ( - IN CHAR16 *Str, - IN UINT64 *Data - ) -/*++ - -Routine Description: +/** Convert integer string to 64 bit data. -Arguments: - - Str - The integer string. If leading with "0x" or "0X", it's heximal. - -Returns: + @param Str The integer string. If leading with "0x" or "0X", it's heximal. + @param Data A pointer to the UINT64 value represented by Str ---*/ +**/ +VOID +Strtoi64 ( + IN CHAR16 *Str, + OUT UINT64 *Data + ) { BOOLEAN IsHex; @@ -548,8 +493,17 @@ Returns: } } -STATIC -EFI_STATUS +/** + Converts a list of string to a specified buffer. + + @param Buf The output buffer that contains the string. + @param BufferLength The length of the buffer + @param Str The input string that contains the hex number + + @retval EFI_SUCCESS The string was successfully converted to the buffer. + +**/ +EFI_STATUS StrToBuf ( OUT UINT8 *Buf, IN UINTN BufferLength, @@ -590,7 +544,17 @@ StrToBuf ( return EFI_SUCCESS; } -STATIC +/** + Converts a string to GUID value. + + @param Str The registry format GUID string that contains the GUID value. + @param Guid A pointer to the converted GUID value. + + @retval EFI_SUCCESS The GUID string was successfully converted to the GUID value. + @retval EFI_UNSUPPORTED The input string is not in registry format. + @return others Some error occurred when converting part of GUID value. + +**/ EFI_STATUS StrToGuid ( IN CHAR16 *Str, @@ -608,7 +572,7 @@ StrToGuid ( } Str += ConvertedStrLen; if (IS_HYPHEN (*Str)) { - Str++; + Str++; } else { return EFI_UNSUPPORTED; } @@ -653,7 +617,13 @@ StrToGuid ( return EFI_SUCCESS; } -STATIC +/** + Converts a string to IPv4 address + + @param Str A string representation of IPv4 address. + @param IPv4Addr A pointer to the converted IPv4 address. + +**/ VOID StrToIPv4Addr ( IN OUT CHAR16 **Str, @@ -667,7 +637,13 @@ StrToIPv4Addr ( } } -STATIC +/** + Converts a string to IPv4 address + + @param Str A string representation of IPv6 address. + @param IPv6Addr A pointer to the converted IPv6 address. + +**/ VOID StrToIPv6Addr ( IN OUT CHAR16 **Str, @@ -684,7 +660,14 @@ StrToIPv6Addr ( } } -STATIC +/** + Converts a Unicode string to ASCII string. + + @param Str The equiventant Unicode string + @param AsciiStr On input, it points to destination ASCII string buffer; on output, it points + to the next ASCII string next to it + +**/ VOID StrToAscii ( IN CHAR16 *Str, @@ -705,7 +688,14 @@ StrToAscii ( *AsciiStr = Dest + 1; } -STATIC +/** + Converts a text device path node to Hardware PCI device path structure. + + @param TextDeviceNode The input Text device path node. + + @return A pointer to Hardware PCI device path structure. + +**/ EFI_DEVICE_PATH_PROTOCOL * DevPathFromTextPci ( IN CHAR16 *TextDeviceNode @@ -729,7 +719,14 @@ DevPathFromTextPci ( return (EFI_DEVICE_PATH_PROTOCOL *) Pci; } -STATIC +/** + Converts a text device path node to Hardware PC card device path structure. + + @param TextDeviceNode The input Text device path node. + + @return A pointer to Hardware PC card device path structure. + +**/ EFI_DEVICE_PATH_PROTOCOL * DevPathFromTextPcCard ( IN CHAR16 *TextDeviceNode @@ -750,7 +747,14 @@ DevPathFromTextPcCard ( return (EFI_DEVICE_PATH_PROTOCOL *) Pccard; } -STATIC +/** + Converts a text device path node to Hardware memory map device path structure. + + @param TextDeviceNode The input Text device path node. + + @return A pointer to Hardware memory map device path structure. + +**/ EFI_DEVICE_PATH_PROTOCOL * DevPathFromTextMemoryMapped ( IN CHAR16 *TextDeviceNode @@ -777,7 +781,17 @@ DevPathFromTextMemoryMapped ( return (EFI_DEVICE_PATH_PROTOCOL *) MemMap; } -STATIC +/** + Converts a text device path node to Vendor device path structure based on the input Type + and SubType. + + @param TextDeviceNode The input Text device path node. + @param Type The type of device path node. + @param SubType The subtype of device path node. + + @return A pointer to the newly-created Vendor device path structure. + +**/ EFI_DEVICE_PATH_PROTOCOL * ConvertFromTextVendor ( IN CHAR16 *TextDeviceNode, @@ -811,7 +825,14 @@ ConvertFromTextVendor ( return (EFI_DEVICE_PATH_PROTOCOL *) Vendor; } -STATIC +/** + Converts a text device path node to Vendor Hardware device path structure. + + @param TextDeviceNode The input Text device path node. + + @return A pointer to the newly-created Vendor Hardware device path structure. + +**/ EFI_DEVICE_PATH_PROTOCOL * DevPathFromTextVenHw ( IN CHAR16 *TextDeviceNode @@ -824,7 +845,14 @@ DevPathFromTextVenHw ( ); } -STATIC +/** + Converts a text device path node to Hardware Controller device path structure. + + @param TextDeviceNode The input Text device path node. + + @return A pointer to the newly-created Hardware Controller device path structure. + +**/ EFI_DEVICE_PATH_PROTOCOL * DevPathFromTextCtrl ( IN CHAR16 *TextDeviceNode @@ -844,7 +872,13 @@ DevPathFromTextCtrl ( return (EFI_DEVICE_PATH_PROTOCOL *) Controller; } -STATIC +/** + Converts a string to EisaId. + + @param Text The input string. + @param EisaId A pointer to the output EisaId. + +**/ VOID EisaIdFromText ( IN CHAR16 *Text, @@ -854,12 +888,20 @@ EisaIdFromText ( UINTN PnpId; PnpId = Xtoi (Text + 3); - *EisaId = (((Text[0] - '@') & 0x1f) << 10) + - (((Text[1] - '@') & 0x1f) << 5) + + *EisaId = (((Text[0] - '@') & 0x1f) << 10) + + (((Text[1] - '@') & 0x1f) << 5) + ((Text[2] - '@') & 0x1f) + (UINT32) (PnpId << 16); } +/** + Converts a text device path node to ACPI HID device path structure. + + @param TextDeviceNode The input Text device path node. + + @return A pointer to the newly-created ACPI HID device path structure. + +**/ EFI_DEVICE_PATH_PROTOCOL * DevPathFromTextAcpi ( IN CHAR16 *TextDeviceNode @@ -883,7 +925,15 @@ DevPathFromTextAcpi ( return (EFI_DEVICE_PATH_PROTOCOL *) Acpi; } -STATIC +/** + Converts a text device path node to ACPI HID device path structure. + + @param TextDeviceNode The input Text device path node. + @param PnPId The input plug and play identification. + + @return A pointer to the newly-created ACPI HID device path structure. + +**/ EFI_DEVICE_PATH_PROTOCOL * ConvertFromTextAcpi ( IN CHAR16 *TextDeviceNode, @@ -906,7 +956,14 @@ ConvertFromTextAcpi ( return (EFI_DEVICE_PATH_PROTOCOL *) Acpi; } -STATIC +/** + Converts a text device path node to PCI root device path structure. + + @param TextDeviceNode The input Text device path node. + + @return A pointer to the newly-created PCI root device path structure. + +**/ EFI_DEVICE_PATH_PROTOCOL * DevPathFromTextPciRoot ( IN CHAR16 *TextDeviceNode @@ -915,7 +972,14 @@ DevPathFromTextPciRoot ( return ConvertFromTextAcpi (TextDeviceNode, 0x0a03); } -STATIC +/** + Converts a text device path node to Floppy device path structure. + + @param TextDeviceNode The input Text device path node. + + @return A pointer to the newly-created Floppy device path structure. + +**/ EFI_DEVICE_PATH_PROTOCOL * DevPathFromTextFloppy ( IN CHAR16 *TextDeviceNode @@ -924,7 +988,14 @@ DevPathFromTextFloppy ( return ConvertFromTextAcpi (TextDeviceNode, 0x0604); } -STATIC +/** + Converts a text device path node to Keyboard device path structure. + + @param TextDeviceNode The input Text device path node. + + @return A pointer to the newly-created Keyboard device path structure. + +**/ EFI_DEVICE_PATH_PROTOCOL * DevPathFromTextKeyboard ( IN CHAR16 *TextDeviceNode @@ -933,7 +1004,14 @@ DevPathFromTextKeyboard ( return ConvertFromTextAcpi (TextDeviceNode, 0x0301); } -STATIC +/** + Converts a text device path node to Serial device path structure. + + @param TextDeviceNode The input Text device path node. + + @return A pointer to the newly-created Serial device path structure. + +**/ EFI_DEVICE_PATH_PROTOCOL * DevPathFromTextSerial ( IN CHAR16 *TextDeviceNode @@ -942,7 +1020,14 @@ DevPathFromTextSerial ( return ConvertFromTextAcpi (TextDeviceNode, 0x0501); } -STATIC +/** + Converts a text device path node to Parallel Port device path structure. + + @param TextDeviceNode The input Text device path node. + + @return A pointer to the newly-created Parallel Port device path structure. + +**/ EFI_DEVICE_PATH_PROTOCOL * DevPathFromTextParallelPort ( IN CHAR16 *TextDeviceNode @@ -951,7 +1036,14 @@ DevPathFromTextParallelPort ( return ConvertFromTextAcpi (TextDeviceNode, 0x0401); } -STATIC +/** + Converts a text device path node to ACPI extention device path structure. + + @param TextDeviceNode The input Text device path node. + + @return A pointer to the newly-created ACPI extention device path structure. + +**/ EFI_DEVICE_PATH_PROTOCOL * DevPathFromTextAcpiEx ( IN CHAR16 *TextDeviceNode @@ -995,7 +1087,14 @@ DevPathFromTextAcpiEx ( return (EFI_DEVICE_PATH_PROTOCOL *) AcpiEx; } -STATIC +/** + Converts a text device path node to ACPI extention device path structure. + + @param TextDeviceNode The input Text device path node. + + @return A pointer to the newly-created ACPI extention device path structure. + +**/ EFI_DEVICE_PATH_PROTOCOL * DevPathFromTextAcpiExp ( IN CHAR16 *TextDeviceNode @@ -1040,7 +1139,14 @@ DevPathFromTextAcpiExp ( return (EFI_DEVICE_PATH_PROTOCOL *) AcpiEx; } -STATIC +/** + Converts a text device path node to Parallel Port device path structure. + + @param TextDeviceNode The input Text device path node. + + @return A pointer to the newly-created Parallel Port device path structure. + +**/ EFI_DEVICE_PATH_PROTOCOL * DevPathFromTextAta ( IN CHAR16 *TextDeviceNode @@ -1068,7 +1174,14 @@ DevPathFromTextAta ( return (EFI_DEVICE_PATH_PROTOCOL *) Atapi; } -STATIC +/** + Converts a text device path node to SCSI device path structure. + + @param TextDeviceNode The input Text device path node. + + @return A pointer to the newly-created SCSI device path structure. + +**/ EFI_DEVICE_PATH_PROTOCOL * DevPathFromTextScsi ( IN CHAR16 *TextDeviceNode @@ -1092,7 +1205,14 @@ DevPathFromTextScsi ( return (EFI_DEVICE_PATH_PROTOCOL *) Scsi; } -STATIC +/** + Converts a text device path node to Fibre device path structure. + + @param TextDeviceNode The input Text device path node. + + @return A pointer to the newly-created Fibre device path structure. + +**/ EFI_DEVICE_PATH_PROTOCOL * DevPathFromTextFibre ( IN CHAR16 *TextDeviceNode @@ -1117,29 +1237,43 @@ DevPathFromTextFibre ( return (EFI_DEVICE_PATH_PROTOCOL *) Fibre; } -STATIC +/** + Converts a text device path node to 1394 device path structure. + + @param TextDeviceNode The input Text device path node. + + @return A pointer to the newly-created 1394 device path structure. + +**/ EFI_DEVICE_PATH_PROTOCOL * DevPathFromText1394 ( IN CHAR16 *TextDeviceNode ) { CHAR16 *GuidStr; - F1394_DEVICE_PATH *F1394; + F1394_DEVICE_PATH *F1394DevPath; GuidStr = GetNextParamStr (&TextDeviceNode); - F1394 = (F1394_DEVICE_PATH *) CreateDeviceNode ( - MESSAGING_DEVICE_PATH, - MSG_1394_DP, - sizeof (F1394_DEVICE_PATH) - ); + F1394DevPath = (F1394_DEVICE_PATH *) CreateDeviceNode ( + MESSAGING_DEVICE_PATH, + MSG_1394_DP, + sizeof (F1394_DEVICE_PATH) + ); - F1394->Reserved = 0; - Xtoi64 (GuidStr, &F1394->Guid); + F1394DevPath->Reserved = 0; + Xtoi64 (GuidStr, &F1394DevPath->Guid); - return (EFI_DEVICE_PATH_PROTOCOL *) F1394; + return (EFI_DEVICE_PATH_PROTOCOL *) F1394DevPath; } -STATIC +/** + Converts a text device path node to USB device path structure. + + @param TextDeviceNode The input Text device path node. + + @return A pointer to the newly-created USB device path structure. + +**/ EFI_DEVICE_PATH_PROTOCOL * DevPathFromTextUsb ( IN CHAR16 *TextDeviceNode @@ -1163,28 +1297,42 @@ DevPathFromTextUsb ( return (EFI_DEVICE_PATH_PROTOCOL *) Usb; } -STATIC +/** + Converts a text device path node to I20 device path structure. + + @param TextDeviceNode The input Text device path node. + + @return A pointer to the newly-created I20 device path structure. + +**/ EFI_DEVICE_PATH_PROTOCOL * DevPathFromTextI2O ( IN CHAR16 *TextDeviceNode ) { CHAR16 *TIDStr; - I2O_DEVICE_PATH *I2O; + I2O_DEVICE_PATH *I2ODevPath; - TIDStr = GetNextParamStr (&TextDeviceNode); - I2O = (I2O_DEVICE_PATH *) CreateDeviceNode ( + TIDStr = GetNextParamStr (&TextDeviceNode); + I2ODevPath = (I2O_DEVICE_PATH *) CreateDeviceNode ( MESSAGING_DEVICE_PATH, MSG_I2O_DP, sizeof (I2O_DEVICE_PATH) ); - I2O->Tid = (UINT32) Strtoi (TIDStr); + I2ODevPath->Tid = (UINT32) Strtoi (TIDStr); - return (EFI_DEVICE_PATH_PROTOCOL *) I2O; + return (EFI_DEVICE_PATH_PROTOCOL *) I2ODevPath; } -STATIC +/** + Converts a text device path node to Infini Band device path structure. + + @param TextDeviceNode The input Text device path node. + + @return A pointer to the newly-created Infini Band device path structure. + +**/ EFI_DEVICE_PATH_PROTOCOL * DevPathFromTextInfiniband ( IN CHAR16 *TextDeviceNode @@ -1219,7 +1367,14 @@ DevPathFromTextInfiniband ( return (EFI_DEVICE_PATH_PROTOCOL *) InfiniBand; } -STATIC +/** + Converts a text device path node to Vendor-Defined Messaging device path structure. + + @param TextDeviceNode The input Text device path node. + + @return A pointer to the newly-created Vendor-Defined Messaging device path structure. + +**/ EFI_DEVICE_PATH_PROTOCOL * DevPathFromTextVenMsg ( IN CHAR16 *TextDeviceNode @@ -1232,7 +1387,14 @@ DevPathFromTextVenMsg ( ); } -STATIC +/** + Converts a text device path node to Vendor defined PC-ANSI device path structure. + + @param TextDeviceNode The input Text device path node. + + @return A pointer to the newly-created Vendor defined PC-ANSI device path structure. + +**/ EFI_DEVICE_PATH_PROTOCOL * DevPathFromTextVenPcAnsi ( IN CHAR16 *TextDeviceNode @@ -1249,7 +1411,14 @@ DevPathFromTextVenPcAnsi ( return (EFI_DEVICE_PATH_PROTOCOL *) Vendor; } -STATIC +/** + Converts a text device path node to Vendor defined VT100 device path structure. + + @param TextDeviceNode The input Text device path node. + + @return A pointer to the newly-created Vendor defined VT100 device path structure. + +**/ EFI_DEVICE_PATH_PROTOCOL * DevPathFromTextVenVt100 ( IN CHAR16 *TextDeviceNode @@ -1266,7 +1435,14 @@ DevPathFromTextVenVt100 ( return (EFI_DEVICE_PATH_PROTOCOL *) Vendor; } -STATIC +/** + Converts a text device path node to Vendor defined VT100 Plus device path structure. + + @param TextDeviceNode The input Text device path node. + + @return A pointer to the newly-created Vendor defined VT100 Plus device path structure. + +**/ EFI_DEVICE_PATH_PROTOCOL * DevPathFromTextVenVt100Plus ( IN CHAR16 *TextDeviceNode @@ -1283,7 +1459,14 @@ DevPathFromTextVenVt100Plus ( return (EFI_DEVICE_PATH_PROTOCOL *) Vendor; } -STATIC +/** + Converts a text device path node to Vendor defined UTF8 device path structure. + + @param TextDeviceNode The input Text device path node. + + @return A pointer to the newly-created Vendor defined UTF8 device path structure. + +**/ EFI_DEVICE_PATH_PROTOCOL * DevPathFromTextVenUtf8 ( IN CHAR16 *TextDeviceNode @@ -1300,7 +1483,14 @@ DevPathFromTextVenUtf8 ( return (EFI_DEVICE_PATH_PROTOCOL *) Vendor; } -STATIC +/** + Converts a text device path node to UART Flow Control device path structure. + + @param TextDeviceNode The input Text device path node. + + @return A pointer to the newly-created UART Flow Control device path structure. + +**/ EFI_DEVICE_PATH_PROTOCOL * DevPathFromTextUartFlowCtrl ( IN CHAR16 *TextDeviceNode @@ -1328,7 +1518,14 @@ DevPathFromTextUartFlowCtrl ( return (EFI_DEVICE_PATH_PROTOCOL *) UartFlowControl; } -STATIC +/** + Converts a text device path node to Serial Attached SCSI device path structure. + + @param TextDeviceNode The input Text device path node. + + @return A pointer to the newly-created Serial Attached SCSI device path structure. + +**/ EFI_DEVICE_PATH_PROTOCOL * DevPathFromTextSAS ( IN CHAR16 *TextDeviceNode @@ -1391,7 +1588,14 @@ DevPathFromTextSAS ( return (EFI_DEVICE_PATH_PROTOCOL *) Sas; } -STATIC +/** + Converts a text device path node to Debug Port device path structure. + + @param TextDeviceNode The input Text device path node. + + @return A pointer to the newly-created Debug Port device path structure. + +**/ EFI_DEVICE_PATH_PROTOCOL * DevPathFromTextDebugPort ( IN CHAR16 *TextDeviceNode @@ -1410,7 +1614,14 @@ DevPathFromTextDebugPort ( return (EFI_DEVICE_PATH_PROTOCOL *) Vend; } -STATIC +/** + Converts a text device path node to MAC device path structure. + + @param TextDeviceNode The input Text device path node. + + @return A pointer to the newly-created MAC device path structure. + +**/ EFI_DEVICE_PATH_PROTOCOL * DevPathFromTextMAC ( IN CHAR16 *TextDeviceNode @@ -1419,25 +1630,32 @@ DevPathFromTextMAC ( CHAR16 *AddressStr; CHAR16 *IfTypeStr; UINTN Length; - MAC_ADDR_DEVICE_PATH *MAC; + MAC_ADDR_DEVICE_PATH *MACDevPath; AddressStr = GetNextParamStr (&TextDeviceNode); IfTypeStr = GetNextParamStr (&TextDeviceNode); - MAC = (MAC_ADDR_DEVICE_PATH *) CreateDeviceNode ( + MACDevPath = (MAC_ADDR_DEVICE_PATH *) CreateDeviceNode ( MESSAGING_DEVICE_PATH, MSG_MAC_ADDR_DP, sizeof (MAC_ADDR_DEVICE_PATH) ); - MAC->IfType = (UINT8) Strtoi (IfTypeStr); + MACDevPath->IfType = (UINT8) Strtoi (IfTypeStr); Length = sizeof (EFI_MAC_ADDRESS); - StrToBuf (&MAC->MacAddress.Addr[0], Length, AddressStr); + StrToBuf (&MACDevPath->MacAddress.Addr[0], Length, AddressStr); - return (EFI_DEVICE_PATH_PROTOCOL *) MAC; + return (EFI_DEVICE_PATH_PROTOCOL *) MACDevPath; } -STATIC +/** + Converts a text device path node to IPV4 device path structure. + + @param TextDeviceNode The input Text device path node. + + @return A pointer to the newly-created IPV4 device path structure. + +**/ EFI_DEVICE_PATH_PROTOCOL * DevPathFromTextIPv4 ( IN CHAR16 *TextDeviceNode @@ -1475,7 +1693,14 @@ DevPathFromTextIPv4 ( return (EFI_DEVICE_PATH_PROTOCOL *) IPv4; } -STATIC +/** + Converts a text device path node to IPV6 device path structure. + + @param TextDeviceNode The input Text device path node. + + @return A pointer to the newly-created IPV6 device path structure. + +**/ EFI_DEVICE_PATH_PROTOCOL * DevPathFromTextIPv6 ( IN CHAR16 *TextDeviceNode @@ -1513,7 +1738,14 @@ DevPathFromTextIPv6 ( return (EFI_DEVICE_PATH_PROTOCOL *) IPv6; } -STATIC +/** + Converts a text device path node to UART device path structure. + + @param TextDeviceNode The input Text device path node. + + @return A pointer to the newly-created UART device path structure. + +**/ EFI_DEVICE_PATH_PROTOCOL * DevPathFromTextUart ( IN CHAR16 *TextDeviceNode @@ -1580,7 +1812,15 @@ DevPathFromTextUart ( return (EFI_DEVICE_PATH_PROTOCOL *) Uart; } -STATIC +/** + Converts a text device path node to USB class device path structure. + + @param TextDeviceNode The input Text device path node. + @param UsbClassText A pointer to USB_CLASS_TEXT structure to be integrated to USB Class Text. + + @return A pointer to the newly-created USB class device path structure. + +**/ EFI_DEVICE_PATH_PROTOCOL * ConvertFromTextUsbClass ( IN CHAR16 *TextDeviceNode, @@ -1613,7 +1853,7 @@ ConvertFromTextUsbClass ( UsbClass->DeviceSubClass = (UINT8) Strtoi (SubClassStr); } else { UsbClass->DeviceSubClass = UsbClassText->SubClass; - } + } ProtocolStr = GetNextParamStr (&TextDeviceNode); @@ -1625,7 +1865,14 @@ ConvertFromTextUsbClass ( } -STATIC +/** + Converts a text device path node to USB class device path structure. + + @param TextDeviceNode The input Text device path node. + + @return A pointer to the newly-created USB class device path structure. + +**/ EFI_DEVICE_PATH_PROTOCOL * DevPathFromTextUsbClass ( IN CHAR16 *TextDeviceNode @@ -1639,7 +1886,14 @@ DevPathFromTextUsbClass ( return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText); } -STATIC +/** + Converts a text device path node to USB audio device path structure. + + @param TextDeviceNode The input Text device path node. + + @return A pointer to the newly-created USB audio device path structure. + +**/ EFI_DEVICE_PATH_PROTOCOL * DevPathFromTextUsbAudio ( IN CHAR16 *TextDeviceNode @@ -1654,7 +1908,14 @@ DevPathFromTextUsbAudio ( return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText); } -STATIC +/** + Converts a text device path node to USB CDC Control device path structure. + + @param TextDeviceNode The input Text device path node. + + @return A pointer to the newly-created USB CDC Control device path structure. + +**/ EFI_DEVICE_PATH_PROTOCOL * DevPathFromTextUsbCDCControl ( IN CHAR16 *TextDeviceNode @@ -1669,7 +1930,14 @@ DevPathFromTextUsbCDCControl ( return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText); } -STATIC +/** + Converts a text device path node to USB HID device path structure. + + @param TextDeviceNode The input Text device path node. + + @return A pointer to the newly-created USB HID device path structure. + +**/ EFI_DEVICE_PATH_PROTOCOL * DevPathFromTextUsbHID ( IN CHAR16 *TextDeviceNode @@ -1684,7 +1952,14 @@ DevPathFromTextUsbHID ( return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText); } -STATIC +/** + Converts a text device path node to USB Image device path structure. + + @param TextDeviceNode The input Text device path node. + + @return A pointer to the newly-created USB Image device path structure. + +**/ EFI_DEVICE_PATH_PROTOCOL * DevPathFromTextUsbImage ( IN CHAR16 *TextDeviceNode @@ -1699,7 +1974,14 @@ DevPathFromTextUsbImage ( return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText); } -STATIC +/** + Converts a text device path node to USB Print device path structure. + + @param TextDeviceNode The input Text device path node. + + @return A pointer to the newly-created USB Print device path structure. + +**/ EFI_DEVICE_PATH_PROTOCOL * DevPathFromTextUsbPrinter ( IN CHAR16 *TextDeviceNode @@ -1714,7 +1996,14 @@ DevPathFromTextUsbPrinter ( return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText); } -STATIC +/** + Converts a text device path node to USB mass storage device path structure. + + @param TextDeviceNode The input Text device path node. + + @return A pointer to the newly-created USB mass storage device path structure. + +**/ EFI_DEVICE_PATH_PROTOCOL * DevPathFromTextUsbMassStorage ( IN CHAR16 *TextDeviceNode @@ -1729,7 +2018,14 @@ DevPathFromTextUsbMassStorage ( return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText); } -STATIC +/** + Converts a text device path node to USB HUB device path structure. + + @param TextDeviceNode The input Text device path node. + + @return A pointer to the newly-created USB HUB device path structure. + +**/ EFI_DEVICE_PATH_PROTOCOL * DevPathFromTextUsbHub ( IN CHAR16 *TextDeviceNode @@ -1744,7 +2040,14 @@ DevPathFromTextUsbHub ( return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText); } -STATIC +/** + Converts a text device path node to USB CDC data device path structure. + + @param TextDeviceNode The input Text device path node. + + @return A pointer to the newly-created USB CDC data device path structure. + +**/ EFI_DEVICE_PATH_PROTOCOL * DevPathFromTextUsbCDCData ( IN CHAR16 *TextDeviceNode @@ -1759,7 +2062,14 @@ DevPathFromTextUsbCDCData ( return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText); } -STATIC +/** + Converts a text device path node to USB smart card device path structure. + + @param TextDeviceNode The input Text device path node. + + @return A pointer to the newly-created USB smart card device path structure. + +**/ EFI_DEVICE_PATH_PROTOCOL * DevPathFromTextUsbSmartCard ( IN CHAR16 *TextDeviceNode @@ -1774,7 +2084,14 @@ DevPathFromTextUsbSmartCard ( return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText); } -STATIC +/** + Converts a text device path node to USB video device path structure. + + @param TextDeviceNode The input Text device path node. + + @return A pointer to the newly-created USB video device path structure. + +**/ EFI_DEVICE_PATH_PROTOCOL * DevPathFromTextUsbVideo ( IN CHAR16 *TextDeviceNode @@ -1789,7 +2106,14 @@ DevPathFromTextUsbVideo ( return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText); } -STATIC +/** + Converts a text device path node to USB diagnostic device path structure. + + @param TextDeviceNode The input Text device path node. + + @return A pointer to the newly-created USB diagnostic device path structure. + +**/ EFI_DEVICE_PATH_PROTOCOL * DevPathFromTextUsbDiagnostic ( IN CHAR16 *TextDeviceNode @@ -1804,7 +2128,14 @@ DevPathFromTextUsbDiagnostic ( return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText); } -STATIC +/** + Converts a text device path node to USB wireless device path structure. + + @param TextDeviceNode The input Text device path node. + + @return A pointer to the newly-created USB wireless device path structure. + +**/ EFI_DEVICE_PATH_PROTOCOL * DevPathFromTextUsbWireless ( IN CHAR16 *TextDeviceNode @@ -1819,7 +2150,14 @@ DevPathFromTextUsbWireless ( return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText); } -STATIC +/** + Converts a text device path node to USB device firmware update device path structure. + + @param TextDeviceNode The input Text device path node. + + @return A pointer to the newly-created USB device firmware update device path structure. + +**/ EFI_DEVICE_PATH_PROTOCOL * DevPathFromTextUsbDeviceFirmwareUpdate ( IN CHAR16 *TextDeviceNode @@ -1835,7 +2173,14 @@ DevPathFromTextUsbDeviceFirmwareUpdate ( return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText); } -STATIC +/** + Converts a text device path node to USB IRDA bridge device path structure. + + @param TextDeviceNode The input Text device path node. + + @return A pointer to the newly-created USB IRDA bridge device path structure. + +**/ EFI_DEVICE_PATH_PROTOCOL * DevPathFromTextUsbIrdaBridge ( IN CHAR16 *TextDeviceNode @@ -1851,7 +2196,14 @@ DevPathFromTextUsbIrdaBridge ( return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText); } -STATIC +/** + Converts a text device path node to USB text and measurement device path structure. + + @param TextDeviceNode The input Text device path node. + + @return A pointer to the newly-created USB text and measurement device path structure. + +**/ EFI_DEVICE_PATH_PROTOCOL * DevPathFromTextUsbTestAndMeasurement ( IN CHAR16 *TextDeviceNode @@ -1867,7 +2219,14 @@ DevPathFromTextUsbTestAndMeasurement ( return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText); } -STATIC +/** + Converts a text device path node to USB WWID device path structure. + + @param TextDeviceNode The input Text device path node. + + @return A pointer to the newly-created USB WWID device path structure. + +**/ EFI_DEVICE_PATH_PROTOCOL * DevPathFromTextUsbWwid ( IN CHAR16 *TextDeviceNode @@ -1897,7 +2256,14 @@ DevPathFromTextUsbWwid ( return (EFI_DEVICE_PATH_PROTOCOL *) UsbWwid; } -STATIC +/** + Converts a text device path node to Logic Unit device path structure. + + @param TextDeviceNode The input Text device path node. + + @return A pointer to the newly-created Logic Unit device path structure. + +**/ EFI_DEVICE_PATH_PROTOCOL * DevPathFromTextUnit ( IN CHAR16 *TextDeviceNode @@ -1918,7 +2284,14 @@ DevPathFromTextUnit ( return (EFI_DEVICE_PATH_PROTOCOL *) LogicalUnit; } -STATIC +/** + Converts a text device path node to iSCSI device path structure. + + @param TextDeviceNode The input Text device path node. + + @return A pointer to the newly-created iSCSI device path structure. + +**/ EFI_DEVICE_PATH_PROTOCOL * DevPathFromTextiSCSI ( IN CHAR16 *TextDeviceNode @@ -1933,7 +2306,7 @@ DevPathFromTextiSCSI ( CHAR16 *AuthenticationStr; CHAR16 *ProtocolStr; CHAR8 *AsciiStr; - ISCSI_DEVICE_PATH_WITH_NAME *iSCSI; + ISCSI_DEVICE_PATH_WITH_NAME *ISCSIDevPath; NameStr = GetNextParamStr (&TextDeviceNode); PortalGroupStr = GetNextParamStr (&TextDeviceNode); @@ -1942,17 +2315,17 @@ DevPathFromTextiSCSI ( DataDigestStr = GetNextParamStr (&TextDeviceNode); AuthenticationStr = GetNextParamStr (&TextDeviceNode); ProtocolStr = GetNextParamStr (&TextDeviceNode); - iSCSI = (ISCSI_DEVICE_PATH_WITH_NAME *) CreateDeviceNode ( + ISCSIDevPath = (ISCSI_DEVICE_PATH_WITH_NAME *) CreateDeviceNode ( MESSAGING_DEVICE_PATH, MSG_ISCSI_DP, (UINT16) (sizeof (ISCSI_DEVICE_PATH_WITH_NAME) + StrLen (NameStr)) ); - AsciiStr = iSCSI->iSCSITargetName; + AsciiStr = ISCSIDevPath->iSCSITargetName; StrToAscii (NameStr, &AsciiStr); - iSCSI->TargetPortalGroupTag = (UINT16) Strtoi (PortalGroupStr); - Strtoi64 (LunStr, &iSCSI->Lun); + ISCSIDevPath->TargetPortalGroupTag = (UINT16) Strtoi (PortalGroupStr); + Strtoi64 (LunStr, &ISCSIDevPath->Lun); Options = 0x0000; if (StrCmp (HeaderDigestStr, L"CRC32C") == 0) { @@ -1971,14 +2344,21 @@ DevPathFromTextiSCSI ( Options |= 0x1000; } - iSCSI->LoginOption = (UINT16) Options; + ISCSIDevPath->LoginOption = (UINT16) Options; - iSCSI->NetworkProtocol = (UINT16) StrCmp (ProtocolStr, L"TCP"); + ISCSIDevPath->NetworkProtocol = (UINT16) StrCmp (ProtocolStr, L"TCP"); - return (EFI_DEVICE_PATH_PROTOCOL *) iSCSI; + return (EFI_DEVICE_PATH_PROTOCOL *) ISCSIDevPath; } -STATIC +/** + Converts a text device path node to HD device path structure. + + @param TextDeviceNode The input Text device path node. + + @return A pointer to the newly-created HD device path structure. + +**/ EFI_DEVICE_PATH_PROTOCOL * DevPathFromTextHD ( IN CHAR16 *TextDeviceNode @@ -2031,7 +2411,14 @@ DevPathFromTextHD ( return (EFI_DEVICE_PATH_PROTOCOL *) Hd; } -STATIC +/** + Converts a text device path node to CDROM device path structure. + + @param TextDeviceNode The input Text device path node. + + @return A pointer to the newly-created CDROM device path structure. + +**/ EFI_DEVICE_PATH_PROTOCOL * DevPathFromTextCDROM ( IN CHAR16 *TextDeviceNode @@ -2040,25 +2427,32 @@ DevPathFromTextCDROM ( CHAR16 *EntryStr; CHAR16 *StartStr; CHAR16 *SizeStr; - CDROM_DEVICE_PATH *CDROM; + CDROM_DEVICE_PATH *CDROMDevPath; EntryStr = GetNextParamStr (&TextDeviceNode); StartStr = GetNextParamStr (&TextDeviceNode); SizeStr = GetNextParamStr (&TextDeviceNode); - CDROM = (CDROM_DEVICE_PATH *) CreateDeviceNode ( + CDROMDevPath = (CDROM_DEVICE_PATH *) CreateDeviceNode ( MEDIA_DEVICE_PATH, MEDIA_CDROM_DP, sizeof (CDROM_DEVICE_PATH) ); - CDROM->BootEntry = (UINT32) Strtoi (EntryStr); - Strtoi64 (StartStr, &CDROM->PartitionStart); - Strtoi64 (SizeStr, &CDROM->PartitionSize); + CDROMDevPath->BootEntry = (UINT32) Strtoi (EntryStr); + Strtoi64 (StartStr, &CDROMDevPath->PartitionStart); + Strtoi64 (SizeStr, &CDROMDevPath->PartitionSize); - return (EFI_DEVICE_PATH_PROTOCOL *) CDROM; + return (EFI_DEVICE_PATH_PROTOCOL *) CDROMDevPath; } -STATIC +/** + Converts a text device path node to Vendor-defined media device path structure. + + @param TextDeviceNode The input Text device path node. + + @return A pointer to the newly-created Vendor-defined media device path structure. + +**/ EFI_DEVICE_PATH_PROTOCOL * DevPathFromTextVenMEDIA ( IN CHAR16 *TextDeviceNode @@ -2071,7 +2465,14 @@ DevPathFromTextVenMEDIA ( ); } -STATIC +/** + Converts a text device path node to File device path structure. + + @param TextDeviceNode The input Text device path node. + + @return A pointer to the newly-created File device path structure. + +**/ EFI_DEVICE_PATH_PROTOCOL * DevPathFromTextFilePath ( IN CHAR16 *TextDeviceNode @@ -2090,7 +2491,14 @@ DevPathFromTextFilePath ( return (EFI_DEVICE_PATH_PROTOCOL *) File; } -STATIC +/** + Converts a text device path node to Media protocol device path structure. + + @param TextDeviceNode The input Text device path node. + + @return A pointer to the newly-created Media protocol device path structure. + +**/ EFI_DEVICE_PATH_PROTOCOL * DevPathFromTextMedia ( IN CHAR16 *TextDeviceNode @@ -2111,7 +2519,14 @@ DevPathFromTextMedia ( return (EFI_DEVICE_PATH_PROTOCOL *) Media; } -STATIC +/** + Converts a text device path node to firmware volume device path structure. + + @param TextDeviceNode The input Text device path node. + + @return A pointer to the newly-created firmware volume device path structure. + +**/ EFI_DEVICE_PATH_PROTOCOL * DevPathFromTextFv ( IN CHAR16 *TextDeviceNode @@ -2132,7 +2547,14 @@ DevPathFromTextFv ( return (EFI_DEVICE_PATH_PROTOCOL *) Fv; } -STATIC +/** + Converts a text device path node to firmware file device path structure. + + @param TextDeviceNode The input Text device path node. + + @return A pointer to the newly-created firmware file device path structure. + +**/ EFI_DEVICE_PATH_PROTOCOL * DevPathFromTextFvFile ( IN CHAR16 *TextDeviceNode @@ -2153,7 +2575,14 @@ DevPathFromTextFvFile ( return (EFI_DEVICE_PATH_PROTOCOL *) FvFile; } -STATIC +/** + Converts a text device path node to BIOS Boot Specification device path structure. + + @param TextDeviceNode The input Text device path node. + + @return A pointer to the newly-created BIOS Boot Specificationa device path structure. + +**/ EFI_DEVICE_PATH_PROTOCOL * DevPathFromTextBBS ( IN CHAR16 *TextDeviceNode @@ -2198,7 +2627,14 @@ DevPathFromTextBBS ( return (EFI_DEVICE_PATH_PROTOCOL *) Bbs; } -STATIC +/** + Converts a text device path node to SATA device path structure. + + @param TextDeviceNode The input Text device path node. + + @return A pointer to the newly-created SATA device path structure. + +**/ EFI_DEVICE_PATH_PROTOCOL * DevPathFromTextSata ( IN CHAR16 *TextDeviceNode @@ -2299,27 +2735,24 @@ GLOBAL_REMOVE_IF_UNREFERENCED DEVICE_PATH_FROM_TEXT_TABLE DevPathFromTextTable[] {NULL, NULL} }; -EFI_DEVICE_PATH_PROTOCOL * -ConvertTextToDeviceNode ( - IN CONST CHAR16 *TextDeviceNode - ) -/*++ +/** + Convert text to the binary representation of a device node. - Routine Description: - Convert text to the binary representation of a device node. - - Arguments: - TextDeviceNode - TextDeviceNode points to the text representation of a device + @param TextDeviceNode TextDeviceNode points to the text representation of a device node. Conversion starts with the first character and continues until the first non-device node character. - Returns: - A pointer - Pointer to the EFI device node. - NULL - If TextDeviceNode is NULL or there was insufficient memory or text unsupported. + @return A pointer to the EFI device node or NULL if TextDeviceNode is NULL or there was + insufficient memory or text unsupported. ---*/ +**/ +EFI_DEVICE_PATH_PROTOCOL * +EFIAPI +ConvertTextToDeviceNode ( + IN CONST CHAR16 *TextDeviceNode + ) { - EFI_DEVICE_PATH_PROTOCOL * (*DumpNode) (CHAR16 *); + DUMP_NODE DumpNode; CHAR16 *ParamStr; EFI_DEVICE_PATH_PROTOCOL *DeviceNode; CHAR16 *DeviceNodeStr; @@ -2357,27 +2790,25 @@ ConvertTextToDeviceNode ( return DeviceNode; } -EFI_DEVICE_PATH_PROTOCOL * -ConvertTextToDevicePath ( - IN CONST CHAR16 *TextDevicePath - ) -/*++ +/** + Convert text to the binary representation of a device path. - Routine Description: - Convert text to the binary representation of a device path. - Arguments: - TextDevicePath - TextDevicePath points to the text representation of a device + @param TextDevicePath TextDevicePath points to the text representation of a device path. Conversion starts with the first character and continues until the first non-device node character. - Returns: - A pointer - Pointer to the allocated device path. - NULL - If TextDeviceNode is NULL or there was insufficient memory. + @return A pointer to the allocated device path or NULL if TextDeviceNode is NULL or + there was insufficient memory. ---*/ +**/ +EFI_DEVICE_PATH_PROTOCOL * +EFIAPI +ConvertTextToDevicePath ( + IN CONST CHAR16 *TextDevicePath + ) { - EFI_DEVICE_PATH_PROTOCOL * (*DumpNode) (CHAR16 *); + DUMP_NODE DumpNode; CHAR16 *ParamStr; EFI_DEVICE_PATH_PROTOCOL *DeviceNode; UINTN Index; @@ -2426,9 +2857,9 @@ ConvertTextToDevicePath ( FreePool (DeviceNode); DevicePath = NewDevicePath; - if (IsInstanceEnd) { + if (IsInstanceEnd != 0) { DeviceNode = (EFI_DEVICE_PATH_PROTOCOL *) AllocatePool (END_DEVICE_PATH_LENGTH); - SetDevicePathInstanceEndNode (DeviceNode); + SET_DEVICE_PATH_INSTANCE_END_NODE (DeviceNode); NewDevicePath = AppendDeviceNodeProtocolInterface (DevicePath, DeviceNode); FreePool (DevicePath); diff --git a/MdeModulePkg/Universal/DevicePathDxe/DevicePathToText.c b/MdeModulePkg/Universal/DevicePathDxe/DevicePathToText.c index 0ba2a25618..a1d560cfd5 100644 --- a/MdeModulePkg/Universal/DevicePathDxe/DevicePathToText.c +++ b/MdeModulePkg/Universal/DevicePathDxe/DevicePathToText.c @@ -14,25 +14,20 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. #include "DevicePath.h" -STATIC +/** + 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 ) -/*++ - - Routine Description: - Function unpacks a device path data structure so that all the nodes of a device path - are naturally aligned. - - Arguments: - DevPath - A pointer to a device path data structure - - Returns: - If the memory for the device path is successfully allocated, then a pointer to the - new device path is returned. Otherwise, NULL is returned. - ---*/ { CONST EFI_DEVICE_PATH_PROTOCOL *Src; EFI_DEVICE_PATH_PROTOCOL *Dest; @@ -89,39 +84,32 @@ UnpackDevicePath ( return NewPath; } -STATIC +/** + Adjusts the size of a previously allocated buffer. + + @param OldPool A pointer to the buffer whose size is being adjusted. + @param OldSize The size of the current buffer. + @param NewSize The size of the new buffer. + + @return A pointer to the new buffer or NULL if allocation fails. + +**/ VOID * ReallocatePool ( IN VOID *OldPool, IN UINTN OldSize, IN UINTN NewSize ) -/*++ - - Routine Description: - Adjusts the size of a previously allocated buffer. - - Arguments: - OldPool - A pointer to the buffer whose size is being adjusted. - OldSize - The size of the current buffer. - NewSize - The size of the new buffer. - - Returns: - EFI_SUCEESS - The requested number of bytes were allocated. - EFI_OUT_OF_RESOURCES - The pool requested could not be allocated. - EFI_INVALID_PARAMETER - The buffer was invalid. - ---*/ { VOID *NewPool; NewPool = NULL; - if (NewSize) { + if (NewSize != 0) { NewPool = AllocateZeroPool (NewSize); } - if (OldPool) { - if (NewPool) { + if (OldPool != NULL) { + if (NewPool != NULL) { CopyMem (NewPool, OldPool, OldSize < NewSize ? OldSize : NewSize); } @@ -131,30 +119,26 @@ ReallocatePool ( return NewPool; } -STATIC +/** + Concatenates a formatted unicode string to allocated pool. The caller must + free the resulting buffer. + + @param Str Tracks the allocated pool, size in use, and + amount of pool allocated. + @param Fmt The format string + @param ... Variable arguments based on the format string. + + @return Allocated buffer with the formatted string printed in it. + The caller must free the allocated buffer. The buffer + allocation is not packed. + +**/ CHAR16 * CatPrint ( IN OUT POOL_PRINT *Str, IN CHAR16 *Fmt, ... ) -/*++ - - Routine Description: - Concatenates a formatted unicode string to allocated pool. - The caller must free the resulting buffer. - - Arguments: - Str - Tracks the allocated pool, size in use, and - amount of pool allocated. - Fmt - The format string - - Returns: - Allocated buffer with the formatted string printed in it. - The caller must free the allocated buffer. The buffer - allocation is not packed. - ---*/ { UINT16 *AppendStr; VA_LIST Args; @@ -173,7 +157,7 @@ CatPrint ( Str->Str = AllocateZeroPool (Size); ASSERT (Str->Str != NULL); } else { - Size = StrSize (AppendStr) - sizeof (UINT16); + Size = StrSize (AppendStr) - sizeof (UINT16); Size = Size + StrSize (Str->Str); Str->Str = ReallocatePool ( Str->Str, @@ -193,7 +177,19 @@ CatPrint ( return Str->Str; } -STATIC +/** + Converts a PCI device path structure to its string representive. + + @param Str The string representive of input device. + @param DevPath The input device path structure. + @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation + of the display node is used, where applicable. If DisplayOnly + is FALSE, then the longer text representation of the display node + is used. + @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text + representation for a device node can be used, where applicable. + +**/ VOID DevPathToTextPci ( IN OUT POOL_PRINT *Str, @@ -208,7 +204,19 @@ DevPathToTextPci ( CatPrint (Str, L"Pci(0x%x,0x%x)", Pci->Device, Pci->Function); } -STATIC +/** + Converts a PC Card device path structure to its string representive. + + @param Str The string representive of input device. + @param DevPath The input device path structure. + @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation + of the display node is used, where applicable. If DisplayOnly + is FALSE, then the longer text representation of the display node + is used. + @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text + representation for a device node can be used, where applicable. + +**/ VOID DevPathToTextPccard ( IN OUT POOL_PRINT *Str, @@ -223,7 +231,19 @@ DevPathToTextPccard ( CatPrint (Str, L"PcCard(0x%x)", Pccard->FunctionNumber); } -STATIC +/** + Converts a Memory Map device path structure to its string representive. + + @param Str The string representive of input device. + @param DevPath The input device path structure. + @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation + of the display node is used, where applicable. If DisplayOnly + is FALSE, then the longer text representation of the display node + is used. + @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text + representation for a device node can be used, where applicable. + +**/ VOID DevPathToTextMemMap ( IN OUT POOL_PRINT *Str, @@ -244,7 +264,19 @@ DevPathToTextMemMap ( ); } -STATIC +/** + Converts a Vendor device path structure to its string representive. + + @param Str The string representive of input device. + @param DevPath The input device path structure. + @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation + of the display node is used, where applicable. If DisplayOnly + is FALSE, then the longer text representation of the display node + is used. + @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text + representation for a device node can be used, where applicable. + +**/ VOID DevPathToTextVendor ( IN OUT POOL_PRINT *Str, @@ -316,9 +348,9 @@ DevPathToTextVendor ( CatPrint ( Str, L"%s,%s,%s,", - (Info & (0x1 << 4)) ? L"SATA" : L"SAS", - (Info & (0x1 << 5)) ? L"External" : L"Internal", - (Info & (0x1 << 6)) ? L"Expanded" : L"Direct" + ((Info & (0x1 << 4)) != 0) ? L"SATA" : L"SAS", + ((Info & (0x1 << 5)) != 0) ? L"External" : L"Internal", + ((Info & (0x1 << 6)) != 0) ? L"Expanded" : L"Direct" ); if ((Info & 0x0f) == 1) { CatPrint (Str, L"0,"); @@ -359,7 +391,19 @@ DevPathToTextVendor ( CatPrint (Str, L")"); } -STATIC +/** + Converts a Controller device path structure to its string representive. + + @param Str The string representive of input device. + @param DevPath The input device path structure. + @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation + of the display node is used, where applicable. If DisplayOnly + is FALSE, then the longer text representation of the display node + is used. + @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text + representation for a device node can be used, where applicable. + +**/ VOID DevPathToTextController ( IN OUT POOL_PRINT *Str, @@ -378,7 +422,19 @@ DevPathToTextController ( ); } -STATIC +/** + Converts a ACPI device path structure to its string representive. + + @param Str The string representive of input device. + @param DevPath The input device path structure. + @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation + of the display node is used, where applicable. If DisplayOnly + is FALSE, then the longer text representation of the display node + is used. + @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text + representation for a device node can be used, where applicable. + +**/ VOID DevPathToTextAcpi ( IN OUT POOL_PRINT *Str, @@ -421,11 +477,17 @@ DevPathToTextAcpi ( } } -STATIC +/** + Converts EISA identification to string. + + @param EisaId The input EISA identification. + @param Text A pointer to the output string. + +**/ VOID EisaIdToText ( IN UINT32 EisaId, - IN OUT CHAR16 *Text + IN OUT CHAR16 *Text ) { CHAR16 PnpIdStr[17]; @@ -446,7 +508,19 @@ EisaIdToText ( ); } -STATIC +/** + Converts a ACPI extended HID device path structure to its string representive. + + @param Str The string representive of input device. + @param DevPath The input device path structure. + @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation + of the display node is used, where applicable. If DisplayOnly + is FALSE, then the longer text representation of the display node + is used. + @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text + representation for a device node can be used, where applicable. + +**/ VOID DevPathToTextAcpiEx ( IN OUT POOL_PRINT *Str, @@ -518,7 +592,19 @@ DevPathToTextAcpiEx ( } } -STATIC +/** + Converts a ACPI address device path structure to its string representive. + + @param Str The string representive of input device. + @param DevPath The input device path structure. + @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation + of the display node is used, where applicable. If DisplayOnly + is FALSE, then the longer text representation of the display node + is used. + @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text + representation for a device node can be used, where applicable. + +**/ VOID DevPathToTextAcpiAdr ( IN OUT POOL_PRINT *Str, @@ -543,7 +629,19 @@ DevPathToTextAcpiAdr ( CatPrint (Str, L")"); } -STATIC +/** + Converts a ATAPI device path structure to its string representive. + + @param Str The string representive of input device. + @param DevPath The input device path structure. + @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation + of the display node is used, where applicable. If DisplayOnly + is FALSE, then the longer text representation of the display node + is used. + @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text + representation for a device node can be used, where applicable. + +**/ VOID DevPathToTextAtapi ( IN OUT POOL_PRINT *Str, @@ -569,7 +667,19 @@ DevPathToTextAtapi ( } } -STATIC +/** + Converts a SCSI device path structure to its string representive. + + @param Str The string representive of input device. + @param DevPath The input device path structure. + @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation + of the display node is used, where applicable. If DisplayOnly + is FALSE, then the longer text representation of the display node + is used. + @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text + representation for a device node can be used, where applicable. + +**/ VOID DevPathToTextScsi ( IN OUT POOL_PRINT *Str, @@ -584,7 +694,19 @@ DevPathToTextScsi ( CatPrint (Str, L"Scsi(0x%x,0x%x)", Scsi->Pun, Scsi->Lun); } -STATIC +/** + Converts a Fibre device path structure to its string representive. + + @param Str The string representive of input device. + @param DevPath The input device path structure. + @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation + of the display node is used, where applicable. If DisplayOnly + is FALSE, then the longer text representation of the display node + is used. + @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text + representation for a device node can be used, where applicable. + +**/ VOID DevPathToTextFibre ( IN OUT POOL_PRINT *Str, @@ -599,7 +721,19 @@ DevPathToTextFibre ( CatPrint (Str, L"Fibre(0x%lx,0x%lx)", Fibre->WWN, Fibre->Lun); } -STATIC +/** + Converts a 1394 device path structure to its string representive. + + @param Str The string representive of input device. + @param DevPath The input device path structure. + @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation + of the display node is used, where applicable. If DisplayOnly + is FALSE, then the longer text representation of the display node + is used. + @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text + representation for a device node can be used, where applicable. + +**/ VOID DevPathToText1394 ( IN OUT POOL_PRINT *Str, @@ -608,16 +742,28 @@ DevPathToText1394 ( IN BOOLEAN AllowShortcuts ) { - F1394_DEVICE_PATH *F1394; + F1394_DEVICE_PATH *F1394DevPath; - F1394 = DevPath; + F1394DevPath = DevPath; // // Guid has format of IEEE-EUI64 // - CatPrint (Str, L"I1394(%016lx)", F1394->Guid); + CatPrint (Str, L"I1394(%016lx)", F1394DevPath->Guid); } -STATIC +/** + Converts a USB device path structure to its string representive. + + @param Str The string representive of input device. + @param DevPath The input device path structure. + @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation + of the display node is used, where applicable. If DisplayOnly + is FALSE, then the longer text representation of the display node + is used. + @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text + representation for a device node can be used, where applicable. + +**/ VOID DevPathToTextUsb ( IN OUT POOL_PRINT *Str, @@ -632,7 +778,19 @@ DevPathToTextUsb ( CatPrint (Str, L"USB(0x%x,0x%x)", Usb->ParentPortNumber, Usb->InterfaceNumber); } -STATIC +/** + Converts a USB WWID device path structure to its string representive. + + @param Str The string representive of input device. + @param DevPath The input device path structure. + @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation + of the display node is used, where applicable. If DisplayOnly + is FALSE, then the longer text representation of the display node + is used. + @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text + representation for a device node can be used, where applicable. + +**/ VOID DevPathToTextUsbWWID ( IN OUT POOL_PRINT *Str, @@ -669,7 +827,19 @@ DevPathToTextUsbWWID ( ); } -STATIC +/** + Converts a Logic Unit device path structure to its string representive. + + @param Str The string representive of input device. + @param DevPath The input device path structure. + @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation + of the display node is used, where applicable. If DisplayOnly + is FALSE, then the longer text representation of the display node + is used. + @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text + representation for a device node can be used, where applicable. + +**/ VOID DevPathToTextLogicalUnit ( IN OUT POOL_PRINT *Str, @@ -684,7 +854,19 @@ DevPathToTextLogicalUnit ( CatPrint (Str, L"Unit(0x%x)", LogicalUnit->Lun); } -STATIC +/** + Converts a USB class device path structure to its string representive. + + @param Str The string representive of input device. + @param DevPath The input device path structure. + @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation + of the display node is used, where applicable. If DisplayOnly + is FALSE, then the longer text representation of the display node + is used. + @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text + representation for a device node can be used, where applicable. + +**/ VOID DevPathToTextUsbClass ( IN OUT POOL_PRINT *Str, @@ -808,7 +990,19 @@ DevPathToTextUsbClass ( ); } -STATIC +/** + Converts a SATA device path structure to its string representive. + + @param Str The string representive of input device. + @param DevPath The input device path structure. + @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation + of the display node is used, where applicable. If DisplayOnly + is FALSE, then the longer text representation of the display node + is used. + @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text + representation for a device node can be used, where applicable. + +**/ VOID DevPathToTextSata ( IN OUT POOL_PRINT *Str, @@ -829,7 +1023,19 @@ DevPathToTextSata ( ); } -STATIC +/** + Converts a I20 device path structure to its string representive. + + @param Str The string representive of input device. + @param DevPath The input device path structure. + @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation + of the display node is used, where applicable. If DisplayOnly + is FALSE, then the longer text representation of the display node + is used. + @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text + representation for a device node can be used, where applicable. + +**/ VOID DevPathToTextI2O ( IN OUT POOL_PRINT *Str, @@ -838,13 +1044,25 @@ DevPathToTextI2O ( IN BOOLEAN AllowShortcuts ) { - I2O_DEVICE_PATH *I2O; + I2O_DEVICE_PATH *I2ODevPath; - I2O = DevPath; - CatPrint (Str, L"I2O(0x%x)", I2O->Tid); + I2ODevPath = DevPath; + CatPrint (Str, L"I2O(0x%x)", I2ODevPath->Tid); } -STATIC +/** + Converts a MAC address device path structure to its string representive. + + @param Str The string representive of input device. + @param DevPath The input device path structure. + @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation + of the display node is used, where applicable. If DisplayOnly + is FALSE, then the longer text representation of the display node + is used. + @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text + representation for a device node can be used, where applicable. + +**/ VOID DevPathToTextMacAddr ( IN OUT POOL_PRINT *Str, @@ -853,27 +1071,39 @@ DevPathToTextMacAddr ( IN BOOLEAN AllowShortcuts ) { - MAC_ADDR_DEVICE_PATH *MAC; + MAC_ADDR_DEVICE_PATH *MacDevPath; UINTN HwAddressSize; UINTN Index; - MAC = DevPath; + MacDevPath = DevPath; HwAddressSize = sizeof (EFI_MAC_ADDRESS); - if (MAC->IfType == 0x01 || MAC->IfType == 0x00) { + if (MacDevPath->IfType == 0x01 || MacDevPath->IfType == 0x00) { HwAddressSize = 6; } CatPrint (Str, L"MAC("); for (Index = 0; Index < HwAddressSize; Index++) { - CatPrint (Str, L"%02x", MAC->MacAddress.Addr[Index]); + CatPrint (Str, L"%02x", MacDevPath->MacAddress.Addr[Index]); } - CatPrint (Str, L",0x%x)", MAC->IfType); + CatPrint (Str, L",0x%x)", MacDevPath->IfType); } -STATIC +/** + Converts a IPv4 device path structure to its string representive. + + @param Str The string representive of input device. + @param DevPath The input device path structure. + @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation + of the display node is used, where applicable. If DisplayOnly + is FALSE, then the longer text representation of the display node + is used. + @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text + representation for a device node can be used, where applicable. + +**/ VOID DevPathToTextIPv4 ( IN OUT POOL_PRINT *Str, @@ -882,17 +1112,17 @@ DevPathToTextIPv4 ( IN BOOLEAN AllowShortcuts ) { - IPv4_DEVICE_PATH *IP; + IPv4_DEVICE_PATH *IPDevPath; - IP = DevPath; - if (DisplayOnly == TRUE) { + IPDevPath = DevPath; + if (DisplayOnly) { CatPrint ( Str, L"IPv4(%d.%d.%d.%d)", - IP->RemoteIpAddress.Addr[0], - IP->RemoteIpAddress.Addr[1], - IP->RemoteIpAddress.Addr[2], - IP->RemoteIpAddress.Addr[3] + IPDevPath->RemoteIpAddress.Addr[0], + IPDevPath->RemoteIpAddress.Addr[1], + IPDevPath->RemoteIpAddress.Addr[2], + IPDevPath->RemoteIpAddress.Addr[3] ); return ; } @@ -900,20 +1130,32 @@ DevPathToTextIPv4 ( CatPrint ( Str, L"IPv4(%d.%d.%d.%d,%s,%s,%d.%d.%d.%d)", - IP->RemoteIpAddress.Addr[0], - IP->RemoteIpAddress.Addr[1], - IP->RemoteIpAddress.Addr[2], - IP->RemoteIpAddress.Addr[3], - IP->Protocol ? L"TCP" : L"UDP", - (IP->StaticIpAddress == TRUE) ? L"Static" : L"DHCP", - IP->LocalIpAddress.Addr[0], - IP->LocalIpAddress.Addr[1], - IP->LocalIpAddress.Addr[2], - IP->LocalIpAddress.Addr[3] + IPDevPath->RemoteIpAddress.Addr[0], + IPDevPath->RemoteIpAddress.Addr[1], + IPDevPath->RemoteIpAddress.Addr[2], + IPDevPath->RemoteIpAddress.Addr[3], + IPDevPath->Protocol ? L"TCP" : L"UDP", + (IPDevPath->StaticIpAddress == TRUE) ? L"Static" : L"DHCP", + IPDevPath->LocalIpAddress.Addr[0], + IPDevPath->LocalIpAddress.Addr[1], + IPDevPath->LocalIpAddress.Addr[2], + IPDevPath->LocalIpAddress.Addr[3] ); } -STATIC +/** + Converts a IPv6 device path structure to its string representive. + + @param Str The string representive of input device. + @param DevPath The input device path structure. + @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation + of the display node is used, where applicable. If DisplayOnly + is FALSE, then the longer text representation of the display node + is used. + @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text + representation for a device node can be used, where applicable. + +**/ VOID DevPathToTextIPv6 ( IN OUT POOL_PRINT *Str, @@ -922,29 +1164,29 @@ DevPathToTextIPv6 ( IN BOOLEAN AllowShortcuts ) { - IPv6_DEVICE_PATH *IP; + IPv6_DEVICE_PATH *IPDevPath; - IP = DevPath; - if (DisplayOnly == TRUE) { + IPDevPath = DevPath; + if (DisplayOnly) { CatPrint ( Str, L"IPv6(%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x)", - IP->RemoteIpAddress.Addr[0], - IP->RemoteIpAddress.Addr[1], - IP->RemoteIpAddress.Addr[2], - IP->RemoteIpAddress.Addr[3], - IP->RemoteIpAddress.Addr[4], - IP->RemoteIpAddress.Addr[5], - IP->RemoteIpAddress.Addr[6], - IP->RemoteIpAddress.Addr[7], - IP->RemoteIpAddress.Addr[8], - IP->RemoteIpAddress.Addr[9], - IP->RemoteIpAddress.Addr[10], - IP->RemoteIpAddress.Addr[11], - IP->RemoteIpAddress.Addr[12], - IP->RemoteIpAddress.Addr[13], - IP->RemoteIpAddress.Addr[14], - IP->RemoteIpAddress.Addr[15] + IPDevPath->RemoteIpAddress.Addr[0], + IPDevPath->RemoteIpAddress.Addr[1], + IPDevPath->RemoteIpAddress.Addr[2], + IPDevPath->RemoteIpAddress.Addr[3], + IPDevPath->RemoteIpAddress.Addr[4], + IPDevPath->RemoteIpAddress.Addr[5], + IPDevPath->RemoteIpAddress.Addr[6], + IPDevPath->RemoteIpAddress.Addr[7], + IPDevPath->RemoteIpAddress.Addr[8], + IPDevPath->RemoteIpAddress.Addr[9], + IPDevPath->RemoteIpAddress.Addr[10], + IPDevPath->RemoteIpAddress.Addr[11], + IPDevPath->RemoteIpAddress.Addr[12], + IPDevPath->RemoteIpAddress.Addr[13], + IPDevPath->RemoteIpAddress.Addr[14], + IPDevPath->RemoteIpAddress.Addr[15] ); return ; } @@ -952,44 +1194,56 @@ DevPathToTextIPv6 ( CatPrint ( Str, L"IPv6(%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x,%s,%s,%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x)", - IP->RemoteIpAddress.Addr[0], - IP->RemoteIpAddress.Addr[1], - IP->RemoteIpAddress.Addr[2], - IP->RemoteIpAddress.Addr[3], - IP->RemoteIpAddress.Addr[4], - IP->RemoteIpAddress.Addr[5], - IP->RemoteIpAddress.Addr[6], - IP->RemoteIpAddress.Addr[7], - IP->RemoteIpAddress.Addr[8], - IP->RemoteIpAddress.Addr[9], - IP->RemoteIpAddress.Addr[10], - IP->RemoteIpAddress.Addr[11], - IP->RemoteIpAddress.Addr[12], - IP->RemoteIpAddress.Addr[13], - IP->RemoteIpAddress.Addr[14], - IP->RemoteIpAddress.Addr[15], - IP->Protocol ? L"TCP" : L"UDP", - (IP->StaticIpAddress == TRUE) ? L"Static" : L"DHCP", - IP->LocalIpAddress.Addr[0], - IP->LocalIpAddress.Addr[1], - IP->LocalIpAddress.Addr[2], - IP->LocalIpAddress.Addr[3], - IP->LocalIpAddress.Addr[4], - IP->LocalIpAddress.Addr[5], - IP->LocalIpAddress.Addr[6], - IP->LocalIpAddress.Addr[7], - IP->LocalIpAddress.Addr[8], - IP->LocalIpAddress.Addr[9], - IP->LocalIpAddress.Addr[10], - IP->LocalIpAddress.Addr[11], - IP->LocalIpAddress.Addr[12], - IP->LocalIpAddress.Addr[13], - IP->LocalIpAddress.Addr[14], - IP->LocalIpAddress.Addr[15] + IPDevPath->RemoteIpAddress.Addr[0], + IPDevPath->RemoteIpAddress.Addr[1], + IPDevPath->RemoteIpAddress.Addr[2], + IPDevPath->RemoteIpAddress.Addr[3], + IPDevPath->RemoteIpAddress.Addr[4], + IPDevPath->RemoteIpAddress.Addr[5], + IPDevPath->RemoteIpAddress.Addr[6], + IPDevPath->RemoteIpAddress.Addr[7], + IPDevPath->RemoteIpAddress.Addr[8], + IPDevPath->RemoteIpAddress.Addr[9], + IPDevPath->RemoteIpAddress.Addr[10], + IPDevPath->RemoteIpAddress.Addr[11], + IPDevPath->RemoteIpAddress.Addr[12], + IPDevPath->RemoteIpAddress.Addr[13], + IPDevPath->RemoteIpAddress.Addr[14], + IPDevPath->RemoteIpAddress.Addr[15], + IPDevPath->Protocol ? L"TCP" : L"UDP", + (IPDevPath->StaticIpAddress == TRUE) ? L"Static" : L"DHCP", + IPDevPath->LocalIpAddress.Addr[0], + IPDevPath->LocalIpAddress.Addr[1], + IPDevPath->LocalIpAddress.Addr[2], + IPDevPath->LocalIpAddress.Addr[3], + IPDevPath->LocalIpAddress.Addr[4], + IPDevPath->LocalIpAddress.Addr[5], + IPDevPath->LocalIpAddress.Addr[6], + IPDevPath->LocalIpAddress.Addr[7], + IPDevPath->LocalIpAddress.Addr[8], + IPDevPath->LocalIpAddress.Addr[9], + IPDevPath->LocalIpAddress.Addr[10], + IPDevPath->LocalIpAddress.Addr[11], + IPDevPath->LocalIpAddress.Addr[12], + IPDevPath->LocalIpAddress.Addr[13], + IPDevPath->LocalIpAddress.Addr[14], + IPDevPath->LocalIpAddress.Addr[15] ); } -STATIC +/** + Converts an Infini Band device path structure to its string representive. + + @param Str The string representive of input device. + @param DevPath The input device path structure. + @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation + of the display node is used, where applicable. If DisplayOnly + is FALSE, then the longer text representation of the display node + is used. + @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text + representation for a device node can be used, where applicable. + +**/ VOID DevPathToTextInfiniBand ( IN OUT POOL_PRINT *Str, @@ -1012,7 +1266,19 @@ DevPathToTextInfiniBand ( ); } -STATIC +/** + Converts a UART device path structure to its string representive. + + @param Str The string representive of input device. + @param DevPath The input device path structure. + @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation + of the display node is used, where applicable. If DisplayOnly + is FALSE, then the longer text representation of the display node + is used. + @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text + representation for a device node can be used, where applicable. + +**/ VOID DevPathToTextUart ( IN OUT POOL_PRINT *Str, @@ -1092,7 +1358,19 @@ DevPathToTextUart ( } } -STATIC +/** + Converts an iSCSI device path structure to its string representive. + + @param Str The string representive of input device. + @param DevPath The input device path structure. + @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation + of the display node is used, where applicable. If DisplayOnly + is FALSE, then the longer text representation of the display node + is used. + @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text + representation for a device node can be used, where applicable. + +**/ VOID DevPathToTextiSCSI ( IN OUT POOL_PRINT *Str, @@ -1101,34 +1379,46 @@ DevPathToTextiSCSI ( IN BOOLEAN AllowShortcuts ) { - ISCSI_DEVICE_PATH_WITH_NAME *iSCSI; + ISCSI_DEVICE_PATH_WITH_NAME *ISCSIDevPath; UINT16 Options; - iSCSI = DevPath; + ISCSIDevPath = DevPath; CatPrint ( Str, L"iSCSI(%a,0x%x,0x%lx,", - iSCSI->iSCSITargetName, - iSCSI->TargetPortalGroupTag, - iSCSI->Lun + ISCSIDevPath->iSCSITargetName, + ISCSIDevPath->TargetPortalGroupTag, + ISCSIDevPath->Lun ); - Options = iSCSI->LoginOption; - CatPrint (Str, L"%s,", ((Options >> 1) & 0x0001) ? L"CRC32C" : L"None"); - CatPrint (Str, L"%s,", ((Options >> 3) & 0x0001) ? L"CRC32C" : L"None"); - if ((Options >> 11) & 0x0001) { + Options = ISCSIDevPath->LoginOption; + CatPrint (Str, L"%s,", (((Options >> 1) & 0x0001) != 0) ? L"CRC32C" : L"None"); + CatPrint (Str, L"%s,", (((Options >> 3) & 0x0001) != 0) ? L"CRC32C" : L"None"); + if (((Options >> 11) & 0x0001) != 0) { CatPrint (Str, L"%s,", L"None"); - } else if ((Options >> 12) & 0x0001) { + } else if (((Options >> 12) & 0x0001) != 0) { CatPrint (Str, L"%s,", L"CHAP_UNI"); } else { CatPrint (Str, L"%s,", L"CHAP_BI"); } - CatPrint (Str, L"%s)", (iSCSI->NetworkProtocol == 0) ? L"TCP" : L"reserved"); + CatPrint (Str, L"%s)", (ISCSIDevPath->NetworkProtocol == 0) ? L"TCP" : L"reserved"); } -STATIC +/** + Converts a Hard drive device path structure to its string representive. + + @param Str The string representive of input device. + @param DevPath The input device path structure. + @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation + of the display node is used, where applicable. If DisplayOnly + is FALSE, then the longer text representation of the display node + is used. + @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text + representation for a device node can be used, where applicable. + +**/ VOID DevPathToTextHardDrive ( IN OUT POOL_PRINT *Str, @@ -1174,7 +1464,19 @@ DevPathToTextHardDrive ( CatPrint (Str, L"0x%lx,0x%lx)", Hd->PartitionStart, Hd->PartitionSize); } -STATIC +/** + Converts a CDROM device path structure to its string representive. + + @param Str The string representive of input device. + @param DevPath The input device path structure. + @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation + of the display node is used, where applicable. If DisplayOnly + is FALSE, then the longer text representation of the display node + is used. + @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text + representation for a device node can be used, where applicable. + +**/ VOID DevPathToTextCDROM ( IN OUT POOL_PRINT *Str, @@ -1186,7 +1488,7 @@ DevPathToTextCDROM ( CDROM_DEVICE_PATH *Cd; Cd = DevPath; - if (DisplayOnly == TRUE) { + if (DisplayOnly) { CatPrint (Str, L"CDROM(0x%x)", Cd->BootEntry); return ; } @@ -1194,7 +1496,19 @@ DevPathToTextCDROM ( CatPrint (Str, L"CDROM(0x%x,0x%lx,0x%lx)", Cd->BootEntry, Cd->PartitionStart, Cd->PartitionSize); } -STATIC +/** + Converts a File device path structure to its string representive. + + @param Str The string representive of input device. + @param DevPath The input device path structure. + @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation + of the display node is used, where applicable. If DisplayOnly + is FALSE, then the longer text representation of the display node + is used. + @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text + representation for a device node can be used, where applicable. + +**/ VOID DevPathToTextFilePath ( IN OUT POOL_PRINT *Str, @@ -1209,7 +1523,19 @@ DevPathToTextFilePath ( CatPrint (Str, L"%s", Fp->PathName); } -STATIC +/** + Converts a Media protocol device path structure to its string representive. + + @param Str The string representive of input device. + @param DevPath The input device path structure. + @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation + of the display node is used, where applicable. If DisplayOnly + is FALSE, then the longer text representation of the display node + is used. + @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text + representation for a device node can be used, where applicable. + +**/ VOID DevPathToTextMediaProtocol ( IN OUT POOL_PRINT *Str, @@ -1224,7 +1550,19 @@ DevPathToTextMediaProtocol ( CatPrint (Str, L"Media(%g)", &MediaProt->Protocol); } -STATIC +/** + Converts a Firmware Volume device path structure to its string representive. + + @param Str The string representive of input device. + @param DevPath The input device path structure. + @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation + of the display node is used, where applicable. If DisplayOnly + is FALSE, then the longer text representation of the display node + is used. + @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text + representation for a device node can be used, where applicable. + +**/ VOID DevPathToTextFv ( IN OUT POOL_PRINT *Str, @@ -1239,7 +1577,19 @@ DevPathToTextFv ( CatPrint (Str, L"Fv(%g)", &Fv->FvName); } -STATIC +/** + Converts a Firmware Volume File device path structure to its string representive. + + @param Str The string representive of input device. + @param DevPath The input device path structure. + @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation + of the display node is used, where applicable. If DisplayOnly + is FALSE, then the longer text representation of the display node + is used. + @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text + representation for a device node can be used, where applicable. + +**/ VOID DevPathToTextFvFile ( IN OUT POOL_PRINT *Str, @@ -1254,7 +1604,19 @@ DevPathToTextFvFile ( CatPrint (Str, L"FvFile(%g)", &FvFile->FvFileName); } -STATIC +/** + Converts a BIOS Boot Specification device path structure to its string representive. + + @param Str The string representive of input device. + @param DevPath The input device path structure. + @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation + of the display node is used, where applicable. If DisplayOnly + is FALSE, then the longer text representation of the display node + is used. + @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text + representation for a device node can be used, where applicable. + +**/ VOID DevPathToTextBBS ( IN OUT POOL_PRINT *Str, @@ -1303,7 +1665,7 @@ DevPathToTextBBS ( CatPrint (Str, L"BBS(0x%x,%a", Bbs->DeviceType, Bbs->String); } - if (DisplayOnly == TRUE) { + if (DisplayOnly) { CatPrint (Str, L")"); return ; } @@ -1311,7 +1673,19 @@ DevPathToTextBBS ( CatPrint (Str, L",0x%x)", Bbs->StatusFlag); } -STATIC +/** + Converts an End-of-Device-Path structure to its string representive. + + @param Str The string representive of input device. + @param DevPath The input device path structure. + @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation + of the display node is used, where applicable. If DisplayOnly + is FALSE, then the longer text representation of the display node + is used. + @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text + representation for a device node can be used, where applicable. + +**/ VOID DevPathToTextEndInstance ( IN OUT POOL_PRINT *Str, @@ -1323,7 +1697,19 @@ DevPathToTextEndInstance ( CatPrint (Str, L","); } -STATIC +/** + Converts an unknown device path structure to its string representive. + + @param Str The string representive of input device. + @param DevPath The input device path structure. + @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation + of the display node is used, where applicable. If DisplayOnly + is FALSE, then the longer text representation of the display node + is used. + @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text + representation for a device node can be used, where applicable. + +**/ VOID DevPathToTextNodeUnknown ( IN OUT POOL_PRINT *Str, @@ -1374,31 +1760,28 @@ GLOBAL_REMOVE_IF_UNREFERENCED const DEVICE_PATH_TO_TEXT_TABLE DevPathToTextTable {0, 0, NULL} }; +/** + Converts a device node to its string representation. + + @param DeviceNode A Pointer to the device node to be converted. + @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation + of the display node is used, where applicable. If DisplayOnly + is FALSE, then the longer text representation of the display node + is used. + @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text + representation for a device node can be used, where applicable. + + @return A pointer to the allocated text representation of the device node or NULL if DeviceNode + is NULL or there was insufficient memory. + +**/ CHAR16 * +EFIAPI ConvertDeviceNodeToText ( IN CONST EFI_DEVICE_PATH_PROTOCOL *DeviceNode, IN BOOLEAN DisplayOnly, IN BOOLEAN AllowShortcuts ) -/*++ - - Routine Description: - Convert a device node to its text representation. - - Arguments: - DeviceNode - Points to the device node to be converted. - DisplayOnly - If DisplayOnly is TRUE, then the shorter text representation - of the display node is used, where applicable. If DisplayOnly - is FALSE, then the longer text representation of the display node - is used. - AllowShortcuts - If AllowShortcuts is TRUE, then the shortcut forms of text - representation for a device node can be used, where applicable. - - Returns: - A pointer - a pointer to the allocated text representation of the device node. - NULL - if DeviceNode is NULL or there was insufficient memory. - ---*/ { POOL_PRINT Str; UINTN Index; @@ -1445,31 +1828,28 @@ ConvertDeviceNodeToText ( return Str.Str; } -CHAR16 * -ConvertDevicePathToText ( - IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath, - IN BOOLEAN DisplayOnly, - IN BOOLEAN AllowShortcuts - ) -/*++ - - Routine Description: - Convert a device path to its text representation. +/** + Converts a device path to its text representation. - Arguments: - DeviceNode - Points to the device path to be converted. - DisplayOnly - If DisplayOnly is TRUE, then the shorter text representation + @param DevicePath A Pointer to the device to be converted. + @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation of the display node is used, where applicable. If DisplayOnly is FALSE, then the longer text representation of the display node is used. - AllowShortcuts - If AllowShortcuts is TRUE, then the shortcut forms of text + @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text representation for a device node can be used, where applicable. - Returns: - A pointer - a pointer to the allocated text representation of the device path. - NULL - if DeviceNode is NULL or there was insufficient memory. + @return A pointer to the allocated text representation of the device path or + NULL if DeviceNode is NULL or there was insufficient memory. ---*/ +**/ +CHAR16 * +EFIAPI +ConvertDevicePathToText ( + IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath, + IN BOOLEAN DisplayOnly, + IN BOOLEAN AllowShortcuts + ) { POOL_PRINT Str; EFI_DEVICE_PATH_PROTOCOL *DevPathNode; @@ -1517,7 +1897,7 @@ ConvertDevicePathToText ( // // Put a path seperator in if needed // - if (Str.Len && DumpNode != DevPathToTextEndInstance) { + if ((Str.Len != 0) && DumpNode != DevPathToTextEndInstance) { if (*(Str.Str + Str.Len / sizeof (CHAR16) - 1) != L',') { CatPrint (&Str, L"/"); } diff --git a/MdeModulePkg/Universal/DevicePathDxe/DevicePathUtilities.c b/MdeModulePkg/Universal/DevicePathDxe/DevicePathUtilities.c index 4484ddae27..ba031d5365 100644 --- a/MdeModulePkg/Universal/DevicePathDxe/DevicePathUtilities.c +++ b/MdeModulePkg/Universal/DevicePathDxe/DevicePathUtilities.c @@ -14,191 +14,221 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. #include "DevicePath.h" +/** + Returns the size of a device path in bytes. + + This function returns the size, in bytes, of the device path data structure specified by + DevicePath including the end of device path node. If DevicePath is NULL, then 0 is returned. + + @param DevicePath A pointer to a device path data structure. + + @return The size of a device path in bytes. + +**/ UINTN +EFIAPI GetDevicePathSizeProtocolInterface ( IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath ) -/*++ +{ + return GetDevicePathSize (DevicePath); +} - Routine Description: - Returns the size of the device path, in bytes. - Arguments: - DevicePath - Points to the start of the EFI device path. +/** + Creates a new device path by appending a second device path to a first device path. - Returns: - Size - Size of the specified device path, in bytes, including the end-of-path tag. + This function allocates space for a new copy of the device path specified by DevicePath. If + DevicePath is NULL, then NULL is returned. If the memory is successfully allocated, then the + contents of DevicePath are copied to the newly allocated buffer, and a pointer to that buffer + is returned. Otherwise, NULL is returned. ---*/ -{ - return GetDevicePathSize (DevicePath); -} + @param DevicePath A pointer to a device path data structure. + + @return A pointer to the duplicated device path. +**/ EFI_DEVICE_PATH_PROTOCOL * +EFIAPI DuplicateDevicePathProtocolInterface ( IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath ) -/*++ +{ + return DuplicateDevicePath (DevicePath); +} - Routine Description: - Create a duplicate of the specified path. +/** + Creates a new device path by appending a second device path to a first device path. - Arguments: - DevicePath - Points to the source EFI device path. + This function creates a new device path by appending a copy of SecondDevicePath to a copy of + FirstDevicePath in a newly allocated buffer. Only the end-of-device-path device node from + SecondDevicePath is retained. The newly created device path is returned. + If FirstDevicePath is NULL, then it is ignored, and a duplicate of SecondDevicePath is returned. + If SecondDevicePath is NULL, then it is ignored, and a duplicate of FirstDevicePath is returned. + If both FirstDevicePath and SecondDevicePath are NULL, then a copy of an end-of-device-path is + returned. + If there is not enough memory for the newly allocated buffer, then NULL is returned. + The memory for the new device path is allocated from EFI boot services memory. It is the + responsibility of the caller to free the memory allocated. - Returns: - Pointer - A pointer to the duplicate device path. - NULL - Insufficient memory. + @param FirstDevicePath A pointer to a device path data structure. + @param SecondDevicePath A pointer to a device path data structure. ---*/ -{ - return DuplicateDevicePath (DevicePath); -} + @return A pointer to the new device path. +**/ EFI_DEVICE_PATH_PROTOCOL * +EFIAPI AppendDevicePathProtocolInterface ( - IN CONST EFI_DEVICE_PATH_PROTOCOL *Src1, - IN CONST EFI_DEVICE_PATH_PROTOCOL *Src2 + IN CONST EFI_DEVICE_PATH_PROTOCOL *FirstDevicePath, + IN CONST EFI_DEVICE_PATH_PROTOCOL *SecondDevicePath ) -/*++ +{ + return AppendDevicePath (FirstDevicePath, SecondDevicePath); +} - Routine Description: - Create a new path by appending the second device path to the first. +/** + Creates a new path by appending the device node to the device path. - Arguments: - Src1 - Points to the first device path. If NULL, then it is ignored. - Src2 - Points to the second device path. If NULL, then it is ignored. + This function creates a new device path by appending a copy of the device node specified by + DevicePathNode to a copy of the device path specified by DevicePath in an allocated buffer. + The end-of-device-path device node is moved after the end of the appended device node. + If DevicePathNode is NULL then a copy of DevicePath is returned. + If DevicePath is NULL then a copy of DevicePathNode, followed by an end-of-device path device + node is returned. + If both DevicePathNode and DevicePath are NULL then a copy of an end-of-device-path device node + is returned. + If there is not enough memory to allocate space for the new device path, then NULL is returned. + The memory is allocated from EFI boot services memory. It is the responsibility of the caller to + free the memory allocated. - Returns: - Pointer - A pointer to the newly created device path. - NULL - Memory could not be allocated - or either DevicePath or DeviceNode is NULL. + @param DevicePath A pointer to a device path data structure. + @param DevicePathNode A pointer to a single device path node. ---*/ -{ - return AppendDevicePath (Src1, Src2); -} + @return A pointer to the new device path. +**/ EFI_DEVICE_PATH_PROTOCOL * +EFIAPI AppendDeviceNodeProtocolInterface ( IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath, - IN CONST EFI_DEVICE_PATH_PROTOCOL *DeviceNode + IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePathNode ) -/*++ +{ + return AppendDevicePathNode (DevicePath, DevicePathNode); +} - Routine Description: - Creates a new path by appending the device node to the device path. +/** + Creates a new device path by appending the specified device path instance to the specified device + path. - Arguments: - DevicePath - Points to the device path. - DeviceNode - Points to the device node. + This function creates a new device path by appending a copy of the device path instance specified + by DevicePathInstance to a copy of the device path secified by DevicePath in a allocated buffer. + The end-of-device-path device node is moved after the end of the appended device path instance + and a new end-of-device-path-instance node is inserted between. + If DevicePath is NULL, then a copy if DevicePathInstance is returned. + If DevicePathInstance is NULL, then NULL is returned. + If there is not enough memory to allocate space for the new device path, then NULL is returned. + The memory is allocated from EFI boot services memory. It is the responsibility of the caller to + free the memory allocated. - Returns: - Pointer - A pointer to the allocated device node. - NULL - Memory could not be allocated - or either DevicePath or DeviceNode is NULL. + @param DevicePath A pointer to a device path data structure. + @param DevicePathInstance A pointer to a device path instance. ---*/ -{ - return AppendDevicePathNode (DevicePath, DeviceNode); -} + @return A pointer to the new device path. +**/ EFI_DEVICE_PATH_PROTOCOL * +EFIAPI AppendDevicePathInstanceProtocolInterface ( IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath, IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePathInstance ) -/*++ - - Routine Description: - Creates a new path by appending the specified device path instance to the specified device path. - - Arguments: - DevicePath - Points to the device path. If NULL, then ignored. - DevicePathInstance - Points to the device path instance. - - Returns: - Pointer - A pointer to the newly created device path - NULL - Memory could not be allocated or DevicePathInstance is NULL. - ---*/ { return AppendDevicePathInstance (DevicePath, DevicePathInstance); } +/** + Creates a copy of the current device path instance and returns a pointer to the next device path + instance. + + This function creates a copy of the current device path instance. It also updates DevicePath to + point to the next device path instance in the device path (or NULL if no more) and updates Size + to hold the size of the device path instance copy. + If DevicePath is NULL, then NULL is returned. + If there is not enough memory to allocate space for the new device path, then NULL is returned. + The memory is allocated from EFI boot services memory. It is the responsibility of the caller to + free the memory allocated. + If Size is NULL, then ASSERT(). + + @param DevicePath On input, this holds the pointer to the current device path + instance. On output, this holds the pointer to the next device + path instance or NULL if there are no more device path + instances in the device path pointer to a device path data + structure. + @param Size On output, this holds the size of the device path instance, in + bytes or zero, if DevicePath is NULL. + + @return A pointer to the current device path instance. + +**/ EFI_DEVICE_PATH_PROTOCOL * +EFIAPI GetNextDevicePathInstanceProtocolInterface ( - IN OUT EFI_DEVICE_PATH_PROTOCOL **DevicePathInstance, - OUT UINTN *DevicePathInstanceSize + IN OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath, + OUT UINTN *Size ) -/*++ +{ + return GetNextDevicePathInstance (DevicePath, Size); +} - Routine Description: - Creates a copy of the current device path instance and returns a pointer to the next device path instance. +/** + Determines if a device path is single or multi-instance. - Arguments: - DevicePathInstance - On input, this holds the pointer to the current device path - instance. On output, this holds the pointer to the next - device path instance or NULL if there are no more device - path instances in the device path. - DevicePathInstanceSize - On output, this holds the size of the device path instance, - in bytes or zero, if DevicePathInstance is zero. + This function returns TRUE if the device path specified by DevicePath is multi-instance. + Otherwise, FALSE is returned. If DevicePath is NULL, then FALSE is returned. - Returns: - Pointer - A pointer to the copy of the current device path instance. - NULL - DevicePathInstace was NULL on entry or there was insufficient memory. + @param DevicePath A pointer to a device path data structure. ---*/ -{ - return GetNextDevicePathInstance (DevicePathInstance, DevicePathInstanceSize); -} + @retval TRUE DevicePath is multi-instance. + @retval FALSE DevicePath is not multi-instance or DevicePath is NULL. +**/ BOOLEAN +EFIAPI IsDevicePathMultiInstanceProtocolInterface ( IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath ) -/*++ +{ + return IsDevicePathMultiInstance (DevicePath); +} - Routine Description: - Returns whether a device path is multi-instance. +/** + Creates a copy of the current device path instance and returns a pointer to the next device path + instance. - Arguments: - DevicePath - Points to the device path. If NULL, then ignored. + This function creates a new device node in a newly allocated buffer of size NodeLength and + initializes the device path node header with NodeType and NodeSubType. The new device path node + is returned. + If NodeLength is smaller than a device path header, then NULL is returned. + If there is not enough memory to allocate space for the new device path, then NULL is returned. + The memory is allocated from EFI boot services memory. It is the responsibility of the caller to + free the memory allocated. - Returns: - TRUE - The device path has more than one instance - FALSE - The device path is empty or contains only a single instance. + @param NodeType The device node type for the new device node. + @param NodeSubType The device node sub-type for the new device node. + @param NodeLength The length of the new device node. ---*/ -{ - return IsDevicePathMultiInstance (DevicePath); -} + @return The new device path. +**/ EFI_DEVICE_PATH_PROTOCOL * +EFIAPI CreateDeviceNodeProtocolInterface ( IN UINT8 NodeType, IN UINT8 NodeSubType, IN UINT16 NodeLength ) -/*++ - - Routine Description: - Creates a device node - - Arguments: - NodeType - NodeType is the device node type (EFI_DEVICE_PATH.Type) for - the new device node. - NodeSubType - NodeSubType is the device node sub-type - EFI_DEVICE_PATH.SubType) for the new device node. - NodeLength - NodeLength is the length of the device node - (EFI_DEVICE_PATH.Length) for the new device node. - - Returns: - Pointer - A pointer to the newly created device node. - NULL - NodeLength is less than - the size of the header or there was insufficient memory. - ---*/ { return CreateDeviceNode (NodeType, NodeSubType, NodeLength); } -- 2.39.2