Revision: 17370
          http://sourceforge.net/p/edk2/code/17370
Author:   niruiyu
Date:     2015-05-08 07:31:39 +0000 (Fri, 08 May 2015)
Log Message:
-----------
MdePkg: Add ToText/FromText support for URI device path node

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ruiyu Ni <[email protected]>
Reviewed-by: Feng Tian <[email protected]>

Modified Paths:
--------------
    trunk/edk2/MdePkg/Library/UefiDevicePathLib/DevicePathFromText.c
    trunk/edk2/MdePkg/Library/UefiDevicePathLib/DevicePathToText.c

Modified: trunk/edk2/MdePkg/Library/UefiDevicePathLib/DevicePathFromText.c
===================================================================
--- trunk/edk2/MdePkg/Library/UefiDevicePathLib/DevicePathFromText.c    
2015-05-08 07:31:12 UTC (rev 17369)
+++ trunk/edk2/MdePkg/Library/UefiDevicePathLib/DevicePathFromText.c    
2015-05-08 07:31:39 UTC (rev 17370)
@@ -2742,6 +2742,38 @@
 }
 
 /**
+  Converts a text device path node to URI device path structure.
+
+  @param TextDeviceNode  The input Text device path node.
+
+  @return A pointer to the newly-created URI device path structure.
+
+**/
+EFI_DEVICE_PATH_PROTOCOL *
+DevPathFromTextUri (
+  IN CHAR16 *TextDeviceNode
+  )
+{
+  CHAR16           *UriStr;
+  UINTN            UriLength;
+  URI_DEVICE_PATH  *Uri;
+
+  UriStr = GetNextParamStr (&TextDeviceNode);
+  UriLength = StrnLenS (UriStr, MAX_UINT16 - sizeof (URI_DEVICE_PATH));
+  Uri    = (URI_DEVICE_PATH *) CreateDeviceNode (
+                                 MESSAGING_DEVICE_PATH,
+                                 MSG_URI_DP,
+                                 (UINT16) (sizeof (URI_DEVICE_PATH) + 
UriLength)
+                                 );
+
+  while (UriLength-- != 0) {
+    Uri->Uri[UriLength] = (CHAR8) UriStr[UriLength];
+  }
+
+  return (EFI_DEVICE_PATH_PROTOCOL *) Uri;
+}
+
+/**
   Converts a media text device path node to media device path structure.
 
   @param TextDeviceNode  The input Text device path node.
@@ -3181,6 +3213,7 @@
   {L"Unit",                    DevPathFromTextUnit                    },
   {L"iSCSI",                   DevPathFromTextiSCSI                   },
   {L"Vlan",                    DevPathFromTextVlan                    },
+  {L"Uri",                     DevPathFromTextUri                     },
   {L"Bluetooth",               DevPathFromTextBluetooth               },
   {L"MediaPath",               DevPathFromTextMediaPath               },
   {L"HD",                      DevPathFromTextHD                      },

Modified: trunk/edk2/MdePkg/Library/UefiDevicePathLib/DevicePathToText.c
===================================================================
--- trunk/edk2/MdePkg/Library/UefiDevicePathLib/DevicePathToText.c      
2015-05-08 07:31:12 UTC (rev 17369)
+++ trunk/edk2/MdePkg/Library/UefiDevicePathLib/DevicePathToText.c      
2015-05-08 07:31:39 UTC (rev 17370)
@@ -1531,6 +1531,45 @@
 }
 
 /**
+  Converts a URI device path structure to its string representative.
+
+  @param Str             The string representative 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
+DevPathToTextUri (
+  IN OUT POOL_PRINT  *Str,
+  IN VOID            *DevPath,
+  IN BOOLEAN         DisplayOnly,
+  IN BOOLEAN         AllowShortcuts
+  )
+{
+  URI_DEVICE_PATH    *Uri;
+  UINTN              UriLength;
+  CHAR8              *UriStr;
+
+  //
+  // Uri in the device path may not be null terminated.
+  //
+  Uri       = DevPath;
+  UriLength = DevicePathNodeLength (Uri) - sizeof (URI_DEVICE_PATH);
+  UriStr = AllocatePool (UriLength + 1);
+  ASSERT (UriStr != NULL);
+
+  CopyMem (UriStr, Uri->Uri, UriLength);
+  UriStr[UriLength] = '\0';
+  UefiDevicePathLibCatPrint (Str, L"Uri(%a)", UriStr);
+  FreePool (UriStr);
+}
+
+/**
   Converts a Hard drive device path structure to its string representative.
 
   @param Str             The string representative of input device.
@@ -1948,6 +1987,7 @@
   {MESSAGING_DEVICE_PATH, MSG_VENDOR_DP,                    
DevPathToTextVendor         },
   {MESSAGING_DEVICE_PATH, MSG_ISCSI_DP,                     DevPathToTextiSCSI 
         },
   {MESSAGING_DEVICE_PATH, MSG_VLAN_DP,                      DevPathToTextVlan  
         },
+  {MESSAGING_DEVICE_PATH, MSG_URI_DP,                       DevPathToTextUri   
         },
   {MESSAGING_DEVICE_PATH, MSG_BLUETOOTH_DP,                 
DevPathToTextBluetooth      },
   {MEDIA_DEVICE_PATH,     MEDIA_HARDDRIVE_DP,               
DevPathToTextHardDrive      },
   {MEDIA_DEVICE_PATH,     MEDIA_CDROM_DP,                   DevPathToTextCDROM 
         },


------------------------------------------------------------------------------
One dashboard for servers and applications across Physical-Virtual-Cloud 
Widest out-of-the-box monitoring support with 50+ applications
Performance metrics, stats and reports that give you Actionable Insights
Deep dive visibility with transaction tracing using APM Insight.
http://ad.doubleclick.net/ddm/clk/290420510;117567292;y
_______________________________________________
edk2-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/edk2-commits

Reply via email to