]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/DevicePathDxe/DevicePath.h
Code scrub for DevicePathDxe driver.
[mirror_edk2.git] / MdeModulePkg / Universal / DevicePathDxe / DevicePath.h
index 7cd0626b90e8a77e2e36746aa7e7ab2f9f73a691..073f9b99597a75b15d4aa137afda1a3aaa169570 100644 (file)
@@ -12,8 +12,8 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 \r
 **/\r
 \r
-#ifndef _DEVICE_PATH_DRIVER_H\r
-#define _DEVICE_PATH_DRIVER_H\r
+#ifndef _DEVICE_PATH_DRIVER_H_\r
+#define _DEVICE_PATH_DRIVER_H_\r
 \r
 #include <PiDxe.h>\r
 #include <Protocol/DevicePathUtilities.h>\r
@@ -51,7 +51,7 @@ extern const EFI_GUID mEfiDevicePathMessagingSASGuid;
 #define DEVICE_PATH_INSTANCE_END   2\r
 #define DEVICE_PATH_END            3\r
 \r
-#define SetDevicePathInstanceEndNode(a) {                \\r
+#define SET_DEVICE_PATH_INSTANCE_END_NODE(a) {                \\r
     (a)->Type       = END_DEVICE_PATH_TYPE;              \\r
     (a)->SubType    = END_INSTANCE_DEVICE_PATH_SUBTYPE;  \\r
     (a)->Length[0]  = sizeof (EFI_DEVICE_PATH_PROTOCOL); \\r
@@ -67,6 +67,12 @@ typedef struct {
   UINTN   MaxLen;\r
 } POOL_PRINT;\r
 \r
+typedef\r
+EFI_DEVICE_PATH_PROTOCOL  *\r
+(*DUMP_NODE) (\r
+  IN  CHAR16 *DeviceNodeStr\r
+  );\r
+\r
 typedef struct {\r
   UINT8   Type;\r
   UINT8   SubType;\r
@@ -75,7 +81,7 @@ typedef struct {
 \r
 typedef struct {\r
   CHAR16                    *DevicePathNodeText;\r
-  EFI_DEVICE_PATH_PROTOCOL  * (*Function) (CHAR16 *);\r
+  DUMP_NODE                 Function;\r
 } DEVICE_PATH_FROM_TEXT_TABLE;\r
 \r
 typedef struct {\r
@@ -148,273 +154,279 @@ typedef struct {
 \r
 #pragma pack()\r
 \r
+/**\r
+  Converts a device node to its string representation.\r
+\r
+  @param DeviceNode        A Pointer to the device node to be converted.\r
+  @param DisplayOnly       If DisplayOnly is TRUE, then the shorter text representation\r
+                           of the display node is used, where applicable. If DisplayOnly\r
+                           is FALSE, then the longer text representation of the display node\r
+                           is used.\r
+  @param AllowShortcuts    If AllowShortcuts is TRUE, then the shortcut forms of text\r
+                           representation for a device node can be used, where applicable.\r
+\r
+  @return A pointer to the allocated text representation of the device node or NULL if DeviceNode\r
+          is NULL or there was insufficient memory.\r
+\r
+**/\r
 CHAR16 *\r
+EFIAPI\r
 ConvertDeviceNodeToText (\r
   IN CONST EFI_DEVICE_PATH_PROTOCOL  *DeviceNode,\r
   IN BOOLEAN                         DisplayOnly,\r
   IN BOOLEAN                         AllowShortcuts\r
-  )\r
-/*++\r
+  );\r
 \r
-  Routine Description:\r
-    Convert a device node to its text representation.\r
+/**\r
+  Converts a device path to its text representation.\r
 \r
-  Arguments:\r
-    DeviceNode       -   Points to the device node to be converted.\r
-    DisplayOnly      -   If DisplayOnly is TRUE, then the shorter text representation\r
+  @param DevicePath      A Pointer to the device to be converted.\r
+  @param DisplayOnly     If DisplayOnly is TRUE, then the shorter text representation\r
                          of the display node is used, where applicable. If DisplayOnly\r
                          is FALSE, then the longer text representation of the display node\r
                          is used.\r
-    AllowShortcuts   -   If AllowShortcuts is TRUE, then the shortcut forms of text\r
+  @param AllowShortcuts  If AllowShortcuts is TRUE, then the shortcut forms of text\r
                          representation for a device node can be used, where applicable.\r
 \r
-  Returns:\r
-    A pointer        -   a pointer to the allocated text representation of the device node.\r
-    NULL             -   if DeviceNode is NULL or there was insufficient memory.\r
-\r
---*/\r
-;\r
+  @return A pointer to the allocated text representation of the device path or\r
+          NULL if DeviceNode is NULL or there was insufficient memory.\r
 \r
+**/\r
 CHAR16 *\r
+EFIAPI\r
 ConvertDevicePathToText (\r
-  IN CONST EFI_DEVICE_PATH_PROTOCOL  *DeviceNode,\r
-  IN BOOLEAN                         DisplayOnly,\r
-  IN BOOLEAN                         AllowShortcuts\r
-  )\r
-/*++\r
+  IN CONST EFI_DEVICE_PATH_PROTOCOL   *DevicePath,\r
+  IN BOOLEAN                          DisplayOnly,\r
+  IN BOOLEAN                          AllowShortcuts\r
+  );\r
 \r
-  Routine Description:\r
-    Convert a device path to its text representation.\r
+/**\r
+  Convert text to the binary representation of a device node.\r
 \r
-  Arguments:\r
-    DeviceNode       -   Points to the device path to be converted.\r
-    DisplayOnly      -   If DisplayOnly is TRUE, then the shorter text representation\r
-                         of the display node is used, where applicable. If DisplayOnly\r
-                         is FALSE, then the longer text representation of the display node\r
-                         is used.\r
-    AllowShortcuts   -   If AllowShortcuts is TRUE, then the shortcut forms of text\r
-                         representation for a device node can be used, where applicable.\r
-\r
-  Returns:\r
-    A pointer        -   a pointer to the allocated text representation of the device path.\r
-    NULL             -   if DeviceNode is NULL or there was insufficient memory.\r
+  @param TextDeviceNode  TextDeviceNode points to the text representation of a device\r
+                         node. Conversion starts with the first character and continues\r
+                         until the first non-device node character.\r
 \r
---*/\r
-;\r
+  @return A pointer to the EFI device node or NULL if TextDeviceNode is NULL or there was\r
+          insufficient memory or text unsupported.\r
 \r
+**/\r
 EFI_DEVICE_PATH_PROTOCOL *\r
+EFIAPI\r
 ConvertTextToDeviceNode (\r
   IN CONST CHAR16 *TextDeviceNode\r
-  )\r
-/*++\r
+  );\r
 \r
-  Routine Description:\r
-    Convert text to the binary representation of a device node.\r
+/**\r
+  Convert text to the binary representation of a device path.\r
 \r
-  Arguments:\r
-    TextDeviceNode   -   TextDeviceNode points to the text representation of a device\r
-                         node. Conversion starts with the first character and continues\r
-                         until the first non-device node character.\r
 \r
-  Returns:\r
-    A pointer        -   Pointer to the EFI device node.\r
-    NULL             -   if TextDeviceNode is NULL or there was insufficient memory.\r
+  @param TextDevicePath  TextDevicePath points to the text representation of a device\r
+                         path. Conversion starts with the first character and continues\r
+                         until the first non-device node character.\r
 \r
---*/\r
-;\r
+  @return A pointer to the allocated device path or NULL if TextDeviceNode is NULL or\r
+          there was insufficient memory.\r
 \r
+**/\r
 EFI_DEVICE_PATH_PROTOCOL *\r
+EFIAPI\r
 ConvertTextToDevicePath (\r
   IN CONST CHAR16 *TextDevicePath\r
-  )\r
-/*++\r
+  );\r
 \r
-  Routine Description:\r
-    Convert text to the binary representation of a device path.\r
+/**\r
+  Returns the size of a device path in bytes.\r
 \r
-  Arguments:\r
-    TextDevicePath   -   TextDevicePath points to the text representation of a device\r
-                         path. Conversion starts with the first character and continues\r
-                         until the first non-device node character.\r
+  This function returns the size, in bytes, of the device path data structure specified by\r
+  DevicePath including the end of device path node.  If DevicePath is NULL, then 0 is returned.\r
 \r
-  Returns:\r
-    A pointer        -   Pointer to the allocated device path.\r
-    NULL             -   if TextDeviceNode is NULL or there was insufficient memory.\r
+  @param  DevicePath                 A pointer to a device path data structure.\r
 \r
---*/\r
-;\r
+  @return The size of a device path in bytes.\r
 \r
+**/\r
 UINTN\r
+EFIAPI\r
 GetDevicePathSizeProtocolInterface (\r
   IN CONST EFI_DEVICE_PATH_PROTOCOL  *DevicePath\r
-  )\r
-/*++\r
+  );\r
 \r
-  Routine Description:\r
-    Returns the size of the device path, in bytes.\r
+/**\r
+  Creates a new device path by appending a second device path to a first device path.\r
 \r
-  Arguments:\r
-    DevicePath  -   Points to the start of the EFI device path.\r
+  This function allocates space for a new copy of the device path specified by DevicePath.  If\r
+  DevicePath is NULL, then NULL is returned.  If the memory is successfully allocated, then the\r
+  contents of DevicePath are copied to the newly allocated buffer, and a pointer to that buffer\r
+  is returned.  Otherwise, NULL is returned.\r
 \r
-  Returns:\r
-    Size        -   Size of the specified device path, in bytes, including the end-of-path tag.\r
+  @param  DevicePath                 A pointer to a device path data structure.\r
 \r
---*/\r
-;\r
+  @return A pointer to the duplicated device path.\r
 \r
+**/\r
 EFI_DEVICE_PATH_PROTOCOL *\r
+EFIAPI\r
 DuplicateDevicePathProtocolInterface (\r
   IN CONST EFI_DEVICE_PATH_PROTOCOL  *DevicePath\r
-  )\r
-/*++\r
+  );\r
 \r
-  Routine Description:\r
-    Create a duplicate of the specified path.\r
+/**\r
+  Creates a new device path by appending a second device path to a first device path.\r
 \r
-  Arguments:\r
-    DevicePath  -   Points to the source EFI device path.\r
+  This function creates a new device path by appending a copy of SecondDevicePath to a copy of\r
+  FirstDevicePath in a newly allocated buffer.  Only the end-of-device-path device node from\r
+  SecondDevicePath is retained. The newly created device path is returned.\r
+  If FirstDevicePath is NULL, then it is ignored, and a duplicate of SecondDevicePath is returned.\r
+  If SecondDevicePath is NULL, then it is ignored, and a duplicate of FirstDevicePath is returned.\r
+  If both FirstDevicePath and SecondDevicePath are NULL, then a copy of an end-of-device-path is\r
+  returned.\r
+  If there is not enough memory for the newly allocated buffer, then NULL is returned.\r
+  The memory for the new device path is allocated from EFI boot services memory. It is the\r
+  responsibility of the caller to free the memory allocated.\r
 \r
-  Returns:\r
-    Pointer     -   A pointer to the duplicate device path.\r
-    NULL        -   Insufficient memory.\r
+  @param  FirstDevicePath            A pointer to a device path data structure.\r
+  @param  SecondDevicePath           A pointer to a device path data structure.\r
 \r
---*/\r
-;\r
+  @return A pointer to the new device path.\r
 \r
+**/\r
 EFI_DEVICE_PATH_PROTOCOL *\r
+EFIAPI\r
 AppendDevicePathProtocolInterface (\r
-  IN CONST EFI_DEVICE_PATH_PROTOCOL *Src1,\r
-  IN CONST EFI_DEVICE_PATH_PROTOCOL *Src2\r
-  )\r
-/*++\r
-\r
-  Routine Description:\r
-    Create a new path by appending the second device path to the first.\r
-\r
-  Arguments:\r
-    Src1      -   Points to the first device path. If NULL, then it is ignored.\r
-    Src2      -   Points to the second device path. If NULL, then it is ignored.\r
-\r
-  Returns:\r
-    Pointer   -   A pointer to the newly created device path.\r
-    NULL      -   Memory could not be allocated\r
-                  or either DevicePath or DeviceNode is NULL.\r
-\r
---*/\r
-;\r
+  IN CONST EFI_DEVICE_PATH_PROTOCOL *FirstDevicePath,\r
+  IN CONST EFI_DEVICE_PATH_PROTOCOL *SecondDevicePath\r
+  );\r
+\r
+/**\r
+  Creates a new path by appending the device node to the device path.\r
+\r
+  This function creates a new device path by appending a copy of the device node specified by\r
+  DevicePathNode to a copy of the device path specified by DevicePath in an allocated buffer.\r
+  The end-of-device-path device node is moved after the end of the appended device node.\r
+  If DevicePathNode is NULL then a copy of DevicePath is returned.\r
+  If DevicePath is NULL then a copy of DevicePathNode, followed by an end-of-device path device\r
+  node is returned.\r
+  If both DevicePathNode and DevicePath are NULL then a copy of an end-of-device-path device node\r
+  is returned.\r
+  If there is not enough memory to allocate space for the new device path, then NULL is returned.\r
+  The memory is allocated from EFI boot services memory. It is the responsibility of the caller to\r
+  free the memory allocated.\r
+\r
+  @param  DevicePath                 A pointer to a device path data structure.\r
+  @param  DevicePathNode             A pointer to a single device path node.\r
+\r
+  @return A pointer to the new device path.\r
 \r
+**/\r
 EFI_DEVICE_PATH_PROTOCOL *\r
+EFIAPI\r
 AppendDeviceNodeProtocolInterface (\r
   IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath,\r
-  IN CONST EFI_DEVICE_PATH_PROTOCOL *DeviceNode\r
-  )\r
-/*++\r
+  IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePathNode\r
+  );\r
 \r
-  Routine Description:\r
-    Creates a new path by appending the device node to the device path.\r
+/**\r
+  Creates a new device path by appending the specified device path instance to the specified device\r
+  path.\r
 \r
-  Arguments:\r
-    DevicePath   -   Points to the device path.\r
-    DeviceNode   -   Points to the device node.\r
+  This function creates a new device path by appending a copy of the device path instance specified\r
+  by DevicePathInstance to a copy of the device path secified by DevicePath in a allocated buffer.\r
+  The end-of-device-path device node is moved after the end of the appended device path instance\r
+  and a new end-of-device-path-instance node is inserted between.\r
+  If DevicePath is NULL, then a copy if DevicePathInstance is returned.\r
+  If DevicePathInstance is NULL, then NULL is returned.\r
+  If there is not enough memory to allocate space for the new device path, then NULL is returned.\r
+  The memory is allocated from EFI boot services memory. It is the responsibility of the caller to\r
+  free the memory allocated.\r
 \r
-  Returns:\r
-    Pointer      -   A pointer to the allocated device node.\r
-    NULL         -   Memory could not be allocated\r
-                     or either DevicePath or DeviceNode is NULL.\r
+  @param  DevicePath                 A pointer to a device path data structure.\r
+  @param  DevicePathInstance         A pointer to a device path instance.\r
 \r
---*/\r
-;\r
+  @return A pointer to the new device path.\r
 \r
+**/\r
 EFI_DEVICE_PATH_PROTOCOL *\r
+EFIAPI\r
 AppendDevicePathInstanceProtocolInterface (\r
   IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath,\r
   IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePathInstance\r
-  )\r
-/*++\r
-\r
-  Routine Description:\r
-    Creates a new path by appending the specified device path instance to the specified device path.\r
-\r
-  Arguments:\r
-    DevicePath           -   Points to the device path. If NULL, then ignored.\r
-    DevicePathInstance   -   Points to the device path instance.\r
-\r
-  Returns:\r
-    Pointer              -   A pointer to the newly created device path\r
-    NULL                 -   Memory could not be allocated or DevicePathInstance is NULL.\r
-\r
---*/\r
-;\r
+  );\r
+\r
+/**\r
+  Creates a copy of the current device path instance and returns a pointer to the next device path\r
+  instance.\r
+\r
+  This function creates a copy of the current device path instance. It also updates DevicePath to\r
+  point to the next device path instance in the device path (or NULL if no more) and updates Size\r
+  to hold the size of the device path instance copy.\r
+  If DevicePath is NULL, then NULL is returned.\r
+  If there is not enough memory to allocate space for the new device path, then NULL is returned.\r
+  The memory is allocated from EFI boot services memory. It is the responsibility of the caller to\r
+  free the memory allocated.\r
+  If Size is NULL, then ASSERT().\r
+\r
+  @param  DevicePath                 On input, this holds the pointer to the current device path\r
+                                     instance. On output, this holds the pointer to the next device\r
+                                     path instance or NULL if there are no more device path\r
+                                     instances in the device path pointer to a device path data\r
+                                     structure.\r
+  @param  Size                       On output, this holds the size of the device path instance, in\r
+                                     bytes or zero, if DevicePath is NULL.\r
+\r
+  @return A pointer to the current device path instance.\r
 \r
+**/\r
 EFI_DEVICE_PATH_PROTOCOL *\r
+EFIAPI\r
 GetNextDevicePathInstanceProtocolInterface (\r
-  IN OUT EFI_DEVICE_PATH_PROTOCOL   **DevicePathInstance,\r
-  OUT UINTN                         *DevicePathInstanceSize\r
-  )\r
-/*++\r
+  IN OUT EFI_DEVICE_PATH_PROTOCOL   **DevicePath,\r
+  OUT UINTN                         *Size\r
+  );\r
 \r
-  Routine Description:\r
-    Creates a copy of the current device path instance and returns a pointer to the next device path instance.\r
+/**\r
+  Determines if a device path is single or multi-instance.\r
 \r
-  Arguments:\r
-    DevicePathInstance       -   On input, this holds the pointer to the current device path\r
-                                 instance. On output, this holds the pointer to the next\r
-                                 device path instance or NULL if there are no more device\r
-                                 path instances in the device path.\r
-    DevicePathInstanceSize   -   On output, this holds the size of the device path instance,\r
-                                 in bytes or zero, if DevicePathInstance is zero.\r
+  This function returns TRUE if the device path specified by DevicePath is multi-instance.\r
+  Otherwise, FALSE is returned.  If DevicePath is NULL, then FALSE is returned.\r
 \r
-  Returns:\r
-    Pointer                  -   A pointer to the copy of the current device path instance.\r
-    NULL                     -   DevicePathInstace was NULL on entry or there was insufficient memory.\r
+  @param  DevicePath                 A pointer to a device path data structure.\r
 \r
---*/\r
-;\r
+  @retval  TRUE                      DevicePath is multi-instance.\r
+  @retval  FALSE                     DevicePath is not multi-instance or DevicePath is NULL.\r
 \r
+**/\r
 BOOLEAN\r
+EFIAPI\r
 IsDevicePathMultiInstanceProtocolInterface (\r
   IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath\r
-  )\r
-/*++\r
+  );\r
 \r
-  Routine Description:\r
-    Returns whether a device path is multi-instance.\r
+/**\r
+  Creates a copy of the current device path instance and returns a pointer to the next device path\r
+  instance.\r
 \r
-  Arguments:\r
-    DevicePath  -   Points to the device path. If NULL, then ignored.\r
+  This function creates a new device node in a newly allocated buffer of size NodeLength and\r
+  initializes the device path node header with NodeType and NodeSubType.  The new device path node\r
+  is returned.\r
+  If NodeLength is smaller than a device path header, then NULL is returned.\r
+  If there is not enough memory to allocate space for the new device path, then NULL is returned.\r
+  The memory is allocated from EFI boot services memory. It is the responsibility of the caller to\r
+  free the memory allocated.\r
 \r
-  Returns:\r
-    TRUE        -   The device path has more than one instance\r
-    FALSE       -   The device path is empty or contains only a single instance.\r
+  @param  NodeType                   The device node type for the new device node.\r
+  @param  NodeSubType                The device node sub-type for the new device node.\r
+  @param  NodeLength                 The length of the new device node.\r
 \r
---*/\r
-;\r
+  @return The new device path.\r
 \r
+**/\r
 EFI_DEVICE_PATH_PROTOCOL *\r
+EFIAPI\r
 CreateDeviceNodeProtocolInterface (\r
   IN UINT8  NodeType,\r
   IN UINT8  NodeSubType,\r
   IN UINT16 NodeLength\r
-  )\r
-/*++\r
-\r
-  Routine Description:\r
-    Creates a device node\r
-\r
-  Arguments:\r
-    NodeType     -    NodeType is the device node type (EFI_DEVICE_PATH.Type) for\r
-                      the new device node.\r
-    NodeSubType  -    NodeSubType is the device node sub-type\r
-                      EFI_DEVICE_PATH.SubType) for the new device node.\r
-    NodeLength   -    NodeLength is the length of the device node\r
-                      (EFI_DEVICE_PATH.Length) for the new device node.\r
-\r
-  Returns:\r
-    Pointer      -    A pointer to the newly created device node.\r
-    NULL         -    NodeLength is less than\r
-                      the size of the header or there was insufficient memory.\r
-\r
---*/\r
-;\r
+  );\r
 \r
 #endif\r