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
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
*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
//\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
// 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
//\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