]> git.proxmox.com Git - mirror_edk2.git/commitdiff
SourceLevelDebugPkg: Fix Serial Port connection cannot be setup
authorRuiyu Ni <ruiyu.ni@intel.com>
Mon, 18 May 2015 05:29:01 +0000 (05:29 +0000)
committerniruiyu <niruiyu@Edk2>
Mon, 18 May 2015 05:29:01 +0000 (05:29 +0000)
The root cause is SerialPortDebugCommunicationLib returns NULL debug port handle causing the CompressData() doesn't send the compressed data.
The fix doesn't rely on the debug port handle value and uses Send parameter to indicate whether to send the compressed data.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Jeff Fan <jeff.fan@intel.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@17464 6f19259b-4bc3-4df7-8a09-765794883524

SourceLevelDebugPkg/Library/DebugAgent/DebugAgentCommon/DebugAgent.c

index 3daa6336cb7781da34c92b71e25ef00e74b287e1..10dd302694bb19d74c0df114207c4c52ec01a014 100644 (file)
@@ -1471,31 +1471,32 @@ CopyMemByWidth (
   2. Compute the CRC of the compressed data buffer;\r
   3. Compress the data and send to the debug channel.\r
 \r
+  @param[in]  Handle           The debug channel handle to send the compressed data buffer.\r
   @param[in]  Data             The data buffer.\r
   @param[in]  Length           The length of the data buffer.\r
+  @param[in]  Send             TRUE to send the compressed data buffer.\r
   @param[out] CompressedLength Return the length of the compressed data buffer.\r
                                It may be larger than the Length in some cases.\r
   @param[out] CompressedCrc    Return the CRC of the compressed data buffer.\r
-  @param[in]  Handle           The debug channel handle to send the compressed data buffer.\r
 **/\r
 VOID\r
-CompressDataThenSend (\r
+CompressData (\r
+  IN  DEBUG_PORT_HANDLE Handle,\r
   IN  UINT8             *Data,\r
   IN  UINT8             Length,\r
+  IN  BOOLEAN           Send,\r
   OUT UINTN             *CompressedLength,  OPTIONAL\r
-  OUT UINT16            *CompressedCrc,     OPTIONAL\r
-  IN  DEBUG_PORT_HANDLE Handle              OPTIONAL\r
+  OUT UINT16            *CompressedCrc      OPTIONAL\r
   )\r
 {\r
-  UINTN  Index;\r
-  UINT8  LastChar;\r
-  UINT8  LastCharCount;\r
-  UINT8  CurrentChar;\r
-  UINTN  CompressedIndex;\r
+  UINTN                 Index;\r
+  UINT8                 LastChar;\r
+  UINT8                 LastCharCount;\r
+  UINT8                 CurrentChar;\r
+  UINTN                 CompressedIndex;\r
 \r
   ASSERT (Length > 0);\r
-\r
-  LastChar = Data[0] + 1; // Just ensure it's different from the first byte.\r
+  LastChar      = Data[0] + 1; // Just ensure it's different from the first byte.\r
   LastCharCount = 0;\r
 \r
   for (Index = 0, CompressedIndex = 0; Index <= Length; Index++) {\r
@@ -1510,7 +1511,7 @@ CompressDataThenSend (
         if (CompressedCrc != NULL) {\r
           *CompressedCrc = CalculateCrc16 (&LastChar, 1, *CompressedCrc);\r
         }\r
-        if (Handle != NULL) {\r
+        if (Send) {\r
           DebugPortWriteBuffer (Handle, &LastChar, 1);\r
         }\r
         \r
@@ -1522,7 +1523,7 @@ CompressDataThenSend (
           *CompressedCrc = CalculateCrc16 (&LastChar, 1, *CompressedCrc);\r
           *CompressedCrc = CalculateCrc16 (&LastCharCount, 1, *CompressedCrc);\r
         }\r
-        if (Handle != NULL) {\r
+        if (Send) {\r
           DebugPortWriteBuffer (Handle, &LastChar, 1);\r
           DebugPortWriteBuffer (Handle, &LastChar, 1);\r
           DebugPortWriteBuffer (Handle, &LastCharCount, 1);\r
@@ -1605,11 +1606,12 @@ ReadMemoryAndSendResponsePacket (
       //\r
       // Get the compressed data size without modifying the packet.\r
       //\r
-      CompressDataThenSend (\r
+      CompressData (\r
+        Handle,\r
         (UINT8 *) (DebugHeader + 1),\r
         CurrentDataSize,\r
+        FALSE,\r
         &CompressedDataSize,\r
-        NULL,\r
         NULL\r
         );\r
     } else {\r
@@ -1622,12 +1624,13 @@ ReadMemoryAndSendResponsePacket (
       // Compute the CRC of the packet head without modifying the packet.\r
       //\r
       DebugHeader->Crc = CalculateCrc16 ((UINT8 *) DebugHeader, sizeof (DEBUG_PACKET_HEADER), 0);\r
-      CompressDataThenSend (\r
+      CompressData (\r
+        Handle,\r
         (UINT8 *) (DebugHeader + 1),\r
         CurrentDataSize,\r
+        FALSE,\r
         NULL,\r
-        &DebugHeader->Crc,\r
-        NULL\r
+        &DebugHeader->Crc\r
         );\r
       //\r
       // Send out the packet head.\r
@@ -1636,12 +1639,13 @@ ReadMemoryAndSendResponsePacket (
       //\r
       // Compress and send out the packet data.\r
       //\r
-      CompressDataThenSend (\r
+      CompressData (\r
+        Handle,\r
         (UINT8 *) (DebugHeader + 1),\r
         CurrentDataSize,\r
+        TRUE,\r
         NULL,\r
-        NULL,\r
-        Handle\r
+        NULL\r
         );\r
     } else {\r
 \r