diff options
author | Ruiyu Ni <ruiyu.ni@intel.com> | 2015-05-18 05:29:01 +0000 |
---|---|---|
committer | niruiyu <niruiyu@Edk2> | 2015-05-18 05:29:01 +0000 |
commit | 987a8a64a147ff7f0d813487b995fe7eb5aa5423 (patch) | |
tree | a3a2b0147a8f9e1ae2deefb249a769e398f14acb | |
parent | f3b6e048e2454c4692bcd66c7592aefde14bcfa4 (diff) | |
download | edk2-platforms-987a8a64a147ff7f0d813487b995fe7eb5aa5423.tar.xz |
SourceLevelDebugPkg: Fix Serial Port connection cannot be setup
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
-rw-r--r-- | SourceLevelDebugPkg/Library/DebugAgent/DebugAgentCommon/DebugAgent.c | 46 |
1 files changed, 25 insertions, 21 deletions
diff --git a/SourceLevelDebugPkg/Library/DebugAgent/DebugAgentCommon/DebugAgent.c b/SourceLevelDebugPkg/Library/DebugAgent/DebugAgentCommon/DebugAgent.c index 3daa6336cb..10dd302694 100644 --- a/SourceLevelDebugPkg/Library/DebugAgent/DebugAgentCommon/DebugAgent.c +++ b/SourceLevelDebugPkg/Library/DebugAgent/DebugAgentCommon/DebugAgent.c @@ -1471,31 +1471,32 @@ CopyMemByWidth ( 2. Compute the CRC of the compressed data buffer;
3. Compress the data and send to the debug channel.
+ @param[in] Handle The debug channel handle to send the compressed data buffer.
@param[in] Data The data buffer.
@param[in] Length The length of the data buffer.
+ @param[in] Send TRUE to send the compressed data buffer.
@param[out] CompressedLength Return the length of the compressed data buffer.
It may be larger than the Length in some cases.
@param[out] CompressedCrc Return the CRC of the compressed data buffer.
- @param[in] Handle The debug channel handle to send the compressed data buffer.
**/
VOID
-CompressDataThenSend (
+CompressData (
+ IN DEBUG_PORT_HANDLE Handle,
IN UINT8 *Data,
IN UINT8 Length,
+ IN BOOLEAN Send,
OUT UINTN *CompressedLength, OPTIONAL
- OUT UINT16 *CompressedCrc, OPTIONAL
- IN DEBUG_PORT_HANDLE Handle OPTIONAL
+ OUT UINT16 *CompressedCrc OPTIONAL
)
{
- UINTN Index;
- UINT8 LastChar;
- UINT8 LastCharCount;
- UINT8 CurrentChar;
- UINTN CompressedIndex;
+ UINTN Index;
+ UINT8 LastChar;
+ UINT8 LastCharCount;
+ UINT8 CurrentChar;
+ UINTN CompressedIndex;
ASSERT (Length > 0);
-
- LastChar = Data[0] + 1; // Just ensure it's different from the first byte.
+ LastChar = Data[0] + 1; // Just ensure it's different from the first byte.
LastCharCount = 0;
for (Index = 0, CompressedIndex = 0; Index <= Length; Index++) {
@@ -1510,7 +1511,7 @@ CompressDataThenSend ( if (CompressedCrc != NULL) {
*CompressedCrc = CalculateCrc16 (&LastChar, 1, *CompressedCrc);
}
- if (Handle != NULL) {
+ if (Send) {
DebugPortWriteBuffer (Handle, &LastChar, 1);
}
@@ -1522,7 +1523,7 @@ CompressDataThenSend ( *CompressedCrc = CalculateCrc16 (&LastChar, 1, *CompressedCrc);
*CompressedCrc = CalculateCrc16 (&LastCharCount, 1, *CompressedCrc);
}
- if (Handle != NULL) {
+ if (Send) {
DebugPortWriteBuffer (Handle, &LastChar, 1);
DebugPortWriteBuffer (Handle, &LastChar, 1);
DebugPortWriteBuffer (Handle, &LastCharCount, 1);
@@ -1605,11 +1606,12 @@ ReadMemoryAndSendResponsePacket ( //
// Get the compressed data size without modifying the packet.
//
- CompressDataThenSend (
+ CompressData (
+ Handle,
(UINT8 *) (DebugHeader + 1),
CurrentDataSize,
+ FALSE,
&CompressedDataSize,
- NULL,
NULL
);
} else {
@@ -1622,12 +1624,13 @@ ReadMemoryAndSendResponsePacket ( // Compute the CRC of the packet head without modifying the packet.
//
DebugHeader->Crc = CalculateCrc16 ((UINT8 *) DebugHeader, sizeof (DEBUG_PACKET_HEADER), 0);
- CompressDataThenSend (
+ CompressData (
+ Handle,
(UINT8 *) (DebugHeader + 1),
CurrentDataSize,
+ FALSE,
NULL,
- &DebugHeader->Crc,
- NULL
+ &DebugHeader->Crc
);
//
// Send out the packet head.
@@ -1636,12 +1639,13 @@ ReadMemoryAndSendResponsePacket ( //
// Compress and send out the packet data.
//
- CompressDataThenSend (
+ CompressData (
+ Handle,
(UINT8 *) (DebugHeader + 1),
CurrentDataSize,
+ TRUE,
NULL,
- NULL,
- Handle
+ NULL
);
} else {
|