mirror of https://github.com/acidanthera/audk.git
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
This commit is contained in:
parent
f3b6e048e2
commit
987a8a64a1
|
@ -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 {
|
||||
|
||||
|
|
Loading…
Reference in New Issue