SourceLevelDebugPkg: Apply uncrustify changes

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3737

Apply uncrustify changes to .c/.h files in the SourceLevelDebugPkg package

Cc: Andrew Fish <afish@apple.com>
Cc: Leif Lindholm <leif@nuviainc.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
Reviewed-by: Hao A Wu <hao.a.wu@intel.com>
Reviewed-by: Ray Ni <ray.ni@intel.com>
This commit is contained in:
Michael Kubacki
2021-12-05 14:54:15 -08:00
committed by mergify[bot]
parent b878648967
commit c1e126b119
35 changed files with 3547 additions and 3381 deletions

View File

@ -81,14 +81,17 @@ DebugAgentDxeInitialize(
Print (L"3: Shell> disconnect EA\r\n");
Print (L"4: Shell> load -nc DebugAgentDxe.efi\r\n\r\n");
}
Status = EFI_UNSUPPORTED;
InitializeDebugAgent (DEBUG_AGENT_INIT_DXE_LOAD, &Status, NULL);
if (EFI_ERROR (Status)) {
return Status;
}
if (gST->ConOut != NULL) {
Print (L"Debug Agent: Initialized successfully!\r\n\r\n");
}
//
// Create event to disable Debug Timer interrupt when exit boot service.
//

View File

@ -301,4 +301,3 @@ typedef struct {
#pragma pack()
#endif

View File

@ -19,4 +19,3 @@
#define DEBUG_AGENT_IMAGE_CONTINUE 0x01
#endif

View File

@ -70,7 +70,6 @@ DebugPortInitialize (
IN DEBUG_PORT_CONTINUE Function
);
/**
Read data from debug device and save the datas in buffer.
@ -97,7 +96,6 @@ DebugPortReadBuffer (
IN UINTN Timeout
);
/**
Write data from buffer to debug device.
@ -143,4 +141,3 @@ DebugPortPollBuffer (
);
#endif

View File

@ -367,4 +367,3 @@ typedef struct {
#pragma pack()
#endif

View File

@ -157,10 +157,10 @@ CalculateCrc16 (
}
}
}
return Crc;
}
/**
Read IDT entry to check if IDT entries are setup by Debug Agent.
@ -176,7 +176,7 @@ IsDebugAgentInitialzed (
UINTN InterruptHandler;
InterruptHandler = (UINTN)GetExceptionHandlerInIdtEntry (0);
if (InterruptHandler >= 4 && *(UINT32 *)(InterruptHandler - 4) == AGENT_HANDLER_SIGNATURE) {
if ((InterruptHandler >= 4) && (*(UINT32 *)(InterruptHandler - 4) == AGENT_HANDLER_SIGNATURE)) {
return TRUE;
} else {
return FALSE;
@ -245,7 +245,6 @@ TriggerSoftInterrupt (
//
AsmWriteDr0 (Dr0);
AsmWriteDr1 (Dr1);
}
/**
@ -282,7 +281,7 @@ VerifyMailboxChecksum (
// The checksum updating process may be disturbed by hardware SMI, we need to check CheckSum field
// and ToBeCheckSum field to validate the mail box.
//
if (CheckSum != Mailbox->CheckSum && CheckSum != Mailbox->ToBeCheckSum) {
if ((CheckSum != Mailbox->CheckSum) && (CheckSum != Mailbox->ToBeCheckSum)) {
DEBUG ((DEBUG_ERROR, "DebugAgent: Mailbox checksum error, stack or heap crashed!\n"));
DEBUG ((DEBUG_ERROR, "DebugAgent: CheckSum = %x, Mailbox->CheckSum = %x, Mailbox->ToBeCheckSum = %x\n", CheckSum, Mailbox->CheckSum, Mailbox->ToBeCheckSum));
CpuDeadLoop ();
@ -342,6 +341,7 @@ UpdateMailboxContent (
Mailbox->DebugTimerFrequency = (UINT32)Value;
break;
}
UpdateMailboxChecksum (Mailbox);
ReleaseMpSpinLock (&mDebugMpContext.MailboxSpinLock);
}
@ -395,6 +395,7 @@ DebugAgentReadBuffer (
);
TimerRound = (UINT32)DivU64x32Remainder (TimeoutTicker, TimerCycle / 2, &TimeoutTicker);
}
Index = 0;
while (Index < NumberOfBytes) {
if (DebugPortPollBuffer (Handle)) {
@ -402,6 +403,7 @@ DebugAgentReadBuffer (
Index++;
continue;
}
if (Timeout != 0) {
if (TimerRound == 0) {
if (IsDebugTimerTimeout (TimerCycle, Begin, TimeoutTicker)) {
@ -490,7 +492,8 @@ SendDebugMsgPacket (
DebugHeader.SequenceNo = 0xEE;
DebugHeader.Crc = 0;
DebugHeader.Crc = CalculateCrc16 (
(UINT8 *)Buffer, Length,
(UINT8 *)Buffer,
Length,
CalculateCrc16 ((UINT8 *)&DebugHeader, sizeof (DEBUG_PACKET_HEADER), 0)
);
@ -590,6 +593,7 @@ DebugAgentDataMsgPrint (
SendDebugMsgPacket (Buffer, DestBuffer - Buffer);
DestBuffer = Buffer;
}
DestBuffer += AsciiSPrint (DestBuffer, DEBUG_DATA_MAXIMUM_REAL_DATA - (DestBuffer - Buffer), "%02x ", Data[Index]);
Index++;
if (Index >= Length) {
@ -642,6 +646,7 @@ ReadRemainingBreakPacket (
DebugAgentDataMsgPrint (DEBUG_AGENT_VERBOSE, FALSE, (UINT8 *)DebugHeader, DebugHeader->Length);
return EFI_CRC_ERROR;
}
Mailbox = GetMailboxPointer ();
if (IS_REQUEST (DebugHeader)) {
if (DebugHeader->SequenceNo == (UINT8)(Mailbox->HostSequenceNo + 1)) {
@ -651,6 +656,7 @@ ReadRemainingBreakPacket (
UpdateMailboxContent (Mailbox, DEBUG_MAILBOX_HOST_SEQUENCE_NO_INDEX, DebugHeader->SequenceNo);
return EFI_SUCCESS;
}
if (DebugHeader->SequenceNo == Mailbox->HostSequenceNo) {
return EFI_SUCCESS;
}
@ -719,6 +725,7 @@ SetDebugSetting (
default:
Status = RETURN_UNSUPPORTED;
}
return Status;
}
@ -850,21 +857,23 @@ ClearDebugRegister (
CpuContext->Dr0 = 0;
CpuContext->Dr7 &= (UINTN)(~(0x3 << 0));
}
if ((ClearHwBreakpoint->IndexMask & BIT1) != 0) {
CpuContext->Dr1 = 0;
CpuContext->Dr7 &= (UINTN)(~(0x3 << 2));
}
if ((ClearHwBreakpoint->IndexMask & BIT2) != 0) {
CpuContext->Dr2 = 0;
CpuContext->Dr7 &= (UINTN)(~(0x3 << 4));
}
if ((ClearHwBreakpoint->IndexMask & BIT3) != 0) {
CpuContext->Dr3 = 0;
CpuContext->Dr7 &= (UINTN)(~(0x3 << 6));
}
}
/**
Return the offset of FP / MMX / XMM registers in the FPU saved state by register index.
@ -1020,6 +1029,7 @@ SendAckPacket (
//
DebugAgentMsgPrint (DEBUG_AGENT_ERROR, "Send ACK(%d)\n", AckCommand);
}
Mailbox = GetMailboxPointer ();
SequenceNo = Mailbox->HostSequenceNo;
DebugAgentMsgPrint (DEBUG_AGENT_INFO, "SendAckPacket: SequenceNo = %x\n", SequenceNo);
@ -1062,6 +1072,7 @@ DecompressDataInPlace (
if (LastChar != CurrentChar) {
LastCharCount = 0;
}
LastCharCount++;
LastChar = CurrentChar;
}
@ -1141,6 +1152,7 @@ ReceivePacket (
DebugAgentMsgPrint (DEBUG_AGENT_ERROR, "DebugAgentReadBuffer(Command) timeout\n");
return RETURN_TIMEOUT;
}
if (DebugHeader->Length < sizeof (DEBUG_PACKET_HEADER)) {
if (IncompatibilityFlag != NULL) {
//
@ -1162,6 +1174,7 @@ ReceivePacket (
DebugAgentMsgPrint (DEBUG_AGENT_ERROR, "DebugAgentReadBuffer(SequenceNo) timeout\n");
return RETURN_TIMEOUT;
}
//
// Calculate the CRC of Debug Packet
//
@ -1170,6 +1183,7 @@ ReceivePacket (
if (Crc == CalculateCrc16 ((UINT8 *)DebugHeader, DebugHeader->Length, 0)) {
break;
}
DebugAgentMsgPrint (DEBUG_AGENT_WARNING, "CRC Error (received CRC is %x)\n", Crc);
DebugAgentDataMsgPrint (DEBUG_AGENT_VERBOSE, FALSE, (UINT8 *)DebugHeader, DebugHeader->Length);
}
@ -1180,9 +1194,11 @@ ReceivePacket (
if (DebugHeader->StartSymbol == DEBUG_STARTING_SYMBOL_COMPRESS) {
DebugHeader->StartSymbol = DEBUG_STARTING_SYMBOL_NORMAL;
DebugHeader->Length = DecompressDataInPlace (
(UINT8 *) (DebugHeader + 1), DebugHeader->Length - sizeof (DEBUG_PACKET_HEADER)
(UINT8 *)(DebugHeader + 1),
DebugHeader->Length - sizeof (DEBUG_PACKET_HEADER)
) + sizeof (DEBUG_PACKET_HEADER);
}
return RETURN_SUCCESS;
}
@ -1233,26 +1249,30 @@ SendCommandAndWaitForAckOK (
} else {
DebugAgentMsgPrint (DEBUG_AGENT_WARNING, "TARGET: Timeout when waiting for ACK packet.\n");
}
continue;
}
ASSERT_EFI_ERROR (Status);
//
// Status == RETURN_SUCCESS
//
if (DebugHeader->Command == DEBUG_COMMAND_OK && DebugHeader->SequenceNo == SequenceNo) {
if ((DebugHeader->Command == DEBUG_COMMAND_OK) && (DebugHeader->SequenceNo == SequenceNo)) {
//
// Received Ack OK
//
UpdateMailboxContent (GetMailboxPointer (), DEBUG_MAILBOX_SEQUENCE_NO_INDEX, ++SequenceNo);
return Status;
}
if (DebugHeader->Command == DEBUG_COMMAND_GO && (DebugHeader->SequenceNo == HostSequenceNo || Command == DEBUG_COMMAND_INIT_BREAK)) {
if ((DebugHeader->Command == DEBUG_COMMAND_GO) && ((DebugHeader->SequenceNo == HostSequenceNo) || (Command == DEBUG_COMMAND_INIT_BREAK))) {
//
// Received Old GO
//
if (Command == DEBUG_COMMAND_INIT_BREAK) {
DebugAgentMsgPrint (DEBUG_AGENT_WARNING, "TARGET: Receive GO() in last boot\n");
}
SendPacketWithoutData (DEBUG_COMMAND_OK, DebugHeader->SequenceNo);
}
}
@ -1299,7 +1319,6 @@ GetBreakCause (
// to report image load/unload).
//
return Cause;
} else {
Cause = DEBUG_DATA_BREAK_CAUSE_HW_BREAKPOINT;
}
@ -1315,10 +1334,10 @@ GetBreakCause (
case IMAGE_UNLOAD_SIGNATURE:
if (CpuContext->Dr3 == IO_PORT_BREAKPOINT_ADDRESS) {
Cause = (UINT8)((CpuContext->Dr0 == IMAGE_LOAD_SIGNATURE) ?
DEBUG_DATA_BREAK_CAUSE_IMAGE_LOAD : DEBUG_DATA_BREAK_CAUSE_IMAGE_UNLOAD);
}
break;
case SOFT_INTERRUPT_SIGNATURE:
@ -1330,11 +1349,11 @@ GetBreakCause (
Cause = DEBUG_DATA_BREAK_CAUSE_SYSTEM_RESET;
CpuContext->Dr0 = 0;
}
break;
default:
break;
}
break;
@ -1354,6 +1373,7 @@ GetBreakCause (
Cause = DEBUG_DATA_BREAK_CAUSE_EXCEPTION;
}
}
break;
}
@ -1411,6 +1431,7 @@ CopyMemByWidth (
default:
ASSERT (FALSE);
}
Source += Step;
Destination += Step;
}
@ -1461,16 +1482,17 @@ CompressData (
} else {
CurrentChar = (UINT8)LastChar + 1; // just ensure it's different from LastChar
}
if (LastChar != CurrentChar) {
if (LastCharCount == 1) {
CompressedIndex++;
if (CompressedCrc != NULL) {
*CompressedCrc = CalculateCrc16 (&LastChar, 1, *CompressedCrc);
}
if (Send) {
DebugPortWriteBuffer (Handle, &LastChar, 1);
}
} else if (LastCharCount >= 2) {
CompressedIndex += 3;
LastCharCount -= 2;
@ -1479,14 +1501,17 @@ CompressData (
*CompressedCrc = CalculateCrc16 (&LastChar, 1, *CompressedCrc);
*CompressedCrc = CalculateCrc16 (&LastCharCount, 1, *CompressedCrc);
}
if (Send) {
DebugPortWriteBuffer (Handle, &LastChar, 1);
DebugPortWriteBuffer (Handle, &LastChar, 1);
DebugPortWriteBuffer (Handle, &LastCharCount, 1);
}
}
LastCharCount = 0;
}
LastCharCount++;
LastChar = CurrentChar;
}
@ -1545,6 +1570,7 @@ ReadMemoryAndSendResponsePacket (
LastPacket = FALSE;
DebugHeader->Command = DEBUG_COMMAND_IN_PROGRESS;
}
//
// Construct the rest Debug header
//
@ -1573,6 +1599,7 @@ ReadMemoryAndSendResponsePacket (
} else {
CompressedDataSize = CurrentDataSize;
}
if (CompressedDataSize < CurrentDataSize) {
DebugHeader->Length = (UINT8)CompressedDataSize + sizeof (DEBUG_PACKET_HEADER);
DebugHeader->StartSymbol = DEBUG_STARTING_SYMBOL_COMPRESS;
@ -1604,7 +1631,6 @@ ReadMemoryAndSendResponsePacket (
NULL
);
} else {
//
// Calculate and fill the checksum, DebugHeader->Crc should be 0 before invoking CalculateCrc16 ()
//
@ -1621,12 +1647,14 @@ ReadMemoryAndSendResponsePacket (
DebugAgentMsgPrint (DEBUG_AGENT_WARNING, "TARGET: Timeout in SendDataResponsePacket()\n");
break;
}
if ((DebugHeader->Command == DEBUG_COMMAND_OK) && (DebugHeader->SequenceNo == SequenceNo) && LastPacket) {
//
// If this is the last packet, return RETURN_SUCCESS.
//
return RETURN_SUCCESS;
}
if ((DebugHeader->Command == DEBUG_COMMAND_CONTINUE) && (DebugHeader->SequenceNo == (UINT8)(SequenceNo + 1))) {
//
// Calculate the rest data size
@ -1636,6 +1664,7 @@ ReadMemoryAndSendResponsePacket (
UpdateMailboxContent (GetMailboxPointer (), DEBUG_MAILBOX_HOST_SEQUENCE_NO_INDEX, DebugHeader->SequenceNo);
break;
}
if (DebugHeader->SequenceNo >= SequenceNo) {
DebugAgentMsgPrint (DEBUG_AGENT_WARNING, "TARGET: Received one old or new command(SequenceNo is %x, last SequenceNo is %x)\n", SequenceNo, DebugHeader->SequenceNo);
break;
@ -1703,6 +1732,7 @@ AttachHost (
} else {
Status = SendCommandAndWaitForAckOK (DEBUG_COMMAND_ATTACH_BREAK, Timeout, BreakReceived, &IncompatibilityFlag);
}
if (IncompatibilityFlag) {
//
// If the incompatible Debug Packet received, the HOST should be running transfer protocol before PcdTransferProtocolRevision.
@ -1721,6 +1751,7 @@ AttachHost (
//
SetHostAttached (TRUE);
}
return Status;
}
@ -1762,13 +1793,14 @@ SendBreakPacketToHost (
do {
DebugAgentReadBuffer (Handle, &InputCharacter, 1, 0);
} while (InputCharacter != DEBUG_STARTING_SYMBOL_ATTACH);
SendAckPacket (DEBUG_COMMAND_OK);
//
// Try to attach HOST
//
while (AttachHost (BreakCause, 0, NULL) != RETURN_SUCCESS);
while (AttachHost (BreakCause, 0, NULL) != RETURN_SUCCESS) {
}
}
}
@ -1843,7 +1875,6 @@ CommandCommunication (
}
while (TRUE) {
if (MultiProcessorDebugSupport ()) {
//
// Check if the current processor is HOST view point
@ -1872,7 +1903,7 @@ CommandCommunication (
DebugAgentMsgPrint (DEBUG_AGENT_INFO, "TARGET: Try to get command from HOST...\n");
Status = ReceivePacket ((UINT8 *)DebugHeader, &BreakReceived, NULL, READ_PACKET_TIMEOUT, TRUE);
if (Status != RETURN_SUCCESS || !IS_REQUEST (DebugHeader)) {
if ((Status != RETURN_SUCCESS) || !IS_REQUEST (DebugHeader)) {
DebugAgentMsgPrint (DEBUG_AGENT_WARNING, "TARGET: Get command[%x] sequenceno[%x] returned status is [%x] \n", DebugHeader->Command, DebugHeader->SequenceNo, Status);
DebugAgentMsgPrint (DEBUG_AGENT_WARNING, "TARGET: Get command failed or it's response packet not expected! \n");
ReleaseMpSpinLock (&mDebugMpContext.DebugPortSpinLock);
@ -1910,7 +1941,6 @@ CommandCommunication (
DebugAgentMsgPrint (DEBUG_AGENT_INFO, "Processor[%x]:Received one command(%x)\n", mDebugMpContext.ViewPointIndex, DebugHeader->Command);
switch (DebugHeader->Command) {
case DEBUG_COMMAND_HALT:
SendAckPacket (DEBUG_COMMAND_HALT_DEFERRED);
HaltDeferred = TRUE;
@ -1943,7 +1973,7 @@ CommandCommunication (
// If HOST changed Dr0 before GO, we will not change Dr0 here
//
Data8 = GetBreakCause (Vector, CpuContext);
if (Data8 == DEBUG_DATA_BREAK_CAUSE_IMAGE_LOAD || Data8 == DEBUG_DATA_BREAK_CAUSE_IMAGE_UNLOAD) {
if ((Data8 == DEBUG_DATA_BREAK_CAUSE_IMAGE_LOAD) || (Data8 == DEBUG_DATA_BREAK_CAUSE_IMAGE_UNLOAD)) {
CpuContext->Dr0 = 0;
}
@ -1992,6 +2022,7 @@ CommandCommunication (
break;
}
}
//
// Set BSP to be current view point.
//
@ -2015,8 +2046,8 @@ CommandCommunication (
UpdateMailboxContent (Mailbox, DEBUG_MAILBOX_SEQUENCE_NO_INDEX, 0);
UpdateMailboxContent (Mailbox, DEBUG_MAILBOX_HOST_SEQUENCE_NO_INDEX, 0);
}
return;
return;
} else {
//
// If received HALT command, need to defer the GO command
@ -2026,15 +2057,17 @@ CommandCommunication (
Vector = DEBUG_TIMER_VECTOR;
}
break;
case DEBUG_COMMAND_BREAK_CAUSE:
BreakCause.StopAddress = CpuContext->Eip;
if (MultiProcessorDebugSupport() && ProcessorIndex != mDebugMpContext.BreakAtCpuIndex) {
if (MultiProcessorDebugSupport () && (ProcessorIndex != mDebugMpContext.BreakAtCpuIndex)) {
BreakCause.Cause = GetBreakCause (DEBUG_TIMER_VECTOR, CpuContext);
} else {
BreakCause.Cause = GetBreakCause (Vector, CpuContext);
}
SendDataResponsePacket ((UINT8 *)&BreakCause, (UINT16)sizeof (DEBUG_DATA_RESPONSE_BREAK_CAUSE), DebugHeader);
break;
@ -2055,7 +2088,7 @@ CommandCommunication (
// If HOST changed Dr0 before GO, we will not change Dr0 here
//
Data8 = GetBreakCause (Vector, CpuContext);
if (Data8 == DEBUG_DATA_BREAK_CAUSE_IMAGE_LOAD || Data8 == DEBUG_DATA_BREAK_CAUSE_IMAGE_UNLOAD) {
if ((Data8 == DEBUG_DATA_BREAK_CAUSE_IMAGE_LOAD) || (Data8 == DEBUG_DATA_BREAK_CAUSE_IMAGE_UNLOAD)) {
CpuContext->Dr0 = 0;
}
@ -2088,6 +2121,7 @@ CommandCommunication (
if (AlignedDataPtr != (UINT8 *)&MemoryWrite->Data) {
CopyMem (AlignedDataPtr, (UINT8 *)&MemoryWrite->Data, MemoryWrite->Count * MemoryWrite->Width);
}
CopyMemByWidth ((UINT8 *)(UINTN)MemoryWrite->Address, AlignedDataPtr, MemoryWrite->Count, MemoryWrite->Width);
SendAckPacket (DEBUG_COMMAND_OK);
break;
@ -2110,6 +2144,7 @@ CommandCommunication (
default:
Data64 = (UINT64)-1;
}
Status = SendDataResponsePacket ((UINT8 *)&Data64, IoRead->Width, DebugHeader);
break;
@ -2131,6 +2166,7 @@ CommandCommunication (
default:
Data64 = (UINT64)-1;
}
SendAckPacket (DEBUG_COMMAND_OK);
break;
@ -2147,6 +2183,7 @@ CommandCommunication (
} else {
Status = RETURN_UNSUPPORTED;
}
break;
case DEBUG_COMMAND_WRITE_REGISTER:
@ -2159,6 +2196,7 @@ CommandCommunication (
} else {
Status = RETURN_UNSUPPORTED;
}
break;
case DEBUG_COMMAND_ARCH_MODE:
@ -2183,6 +2221,7 @@ CommandCommunication (
if (Status == RETURN_SUCCESS) {
SendAckPacket (DEBUG_COMMAND_OK);
}
break;
case DEBUG_COMMAND_GET_REVISION:
@ -2211,7 +2250,6 @@ CommandCommunication (
}
} else if (SetViewPoint->ViewPoint == 0) {
SendAckPacket (DEBUG_COMMAND_OK);
} else {
SendAckPacket (DEBUG_COMMAND_NOT_SUPPORTED);
}
@ -2236,9 +2274,12 @@ CommandCommunication (
case DEBUG_COMMAND_CPUID:
Cpuid = (DEBUG_DATA_CPUID *)(DebugHeader + 1);
AsmCpuidEx (
Cpuid->Eax, Cpuid->Ecx,
&CpuidResponse.Eax, &CpuidResponse.Ebx,
&CpuidResponse.Ecx, &CpuidResponse.Edx
Cpuid->Eax,
Cpuid->Ecx,
&CpuidResponse.Eax,
&CpuidResponse.Ebx,
&CpuidResponse.Ecx,
&CpuidResponse.Edx
);
SendDataResponsePacket ((UINT8 *)&CpuidResponse, (UINT16)sizeof (CpuidResponse), DebugHeader);
break;
@ -2247,17 +2288,20 @@ CommandCommunication (
SearchSignature = (DEBUG_DATA_SEARCH_SIGNATURE *)(DebugHeader + 1);
if ((SearchSignature->Alignment != 0) &&
(SearchSignature->Alignment == GetPowerOfTwo32 (SearchSignature->Alignment))
) {
)
{
if (SearchSignature->Positive) {
for (
Data64 = ALIGN_VALUE ((UINTN)SearchSignature->Start, SearchSignature->Alignment);
Data64 <= SearchSignature->Start + SearchSignature->Count - SearchSignature->DataLength;
Data64 += SearchSignature->Alignment
) {
)
{
if (CompareMem ((VOID *)(UINTN)Data64, &SearchSignature->Data, SearchSignature->DataLength) == 0) {
break;
}
}
if (Data64 > SearchSignature->Start + SearchSignature->Count - SearchSignature->DataLength) {
Data64 = (UINT64)-1;
}
@ -2266,19 +2310,23 @@ CommandCommunication (
Data64 = ALIGN_VALUE ((UINTN)SearchSignature->Start - SearchSignature->Alignment, SearchSignature->Alignment);
Data64 >= SearchSignature->Start - SearchSignature->Count;
Data64 -= SearchSignature->Alignment
) {
)
{
if (CompareMem ((VOID *)(UINTN)Data64, &SearchSignature->Data, SearchSignature->DataLength) == 0) {
break;
}
}
if (Data64 < SearchSignature->Start - SearchSignature->Count) {
Data64 = (UINT64)-1;
}
}
SendDataResponsePacket ((UINT8 *)&Data64, (UINT16)sizeof (Data64), DebugHeader);
} else {
Status = RETURN_UNSUPPORTED;
}
break;
default:
@ -2348,7 +2396,7 @@ InterruptProcess (
}
}
if (IssuedViewPoint == ProcessorIndex && GetDebugFlag (DEBUG_AGENT_FLAG_STEPPING) != 1) {
if ((IssuedViewPoint == ProcessorIndex) && (GetDebugFlag (DEBUG_AGENT_FLAG_STEPPING) != 1)) {
//
// Check if this exception is issued by Debug Agent itself
// If yes, fill the debug agent exception buffer and LongJump() back to
@ -2392,6 +2440,7 @@ InterruptProcess (
//
break;
}
CommandCommunication (Vector, CpuContext, BreakReceived);
break;
@ -2402,6 +2451,7 @@ InterruptProcess (
if (MultiProcessorDebugSupport ()) {
mDebugMpContext.BreakAtCpuIndex = ProcessorIndex;
}
//
// Clear Stepping Flag and restore EFLAGS.IF
//
@ -2432,6 +2482,7 @@ InterruptProcess (
//
break;
}
//
// Continue to run the following common code
//
@ -2449,6 +2500,7 @@ InterruptProcess (
if (IsFirstBreakProcessor (ProcessorIndex)) {
SendBreakPacketToHost (BreakCause, ProcessorIndex, &BreakReceived);
}
ReleaseMpSpinLock (&mDebugMpContext.DebugPortSpinLock);
if (Vector == DEBUG_INT3_VECTOR) {
@ -2459,7 +2511,8 @@ InterruptProcess (
SavedEip = CpuContext->Eip;
CommandCommunication (Vector, CpuContext, BreakReceived);
if ((SavedEip == CpuContext->Eip) &&
(*(UINT8 *) (UINTN) CpuContext->Eip == DEBUG_SW_BREAKPOINT_SYMBOL)) {
(*(UINT8 *)(UINTN)CpuContext->Eip == DEBUG_SW_BREAKPOINT_SYMBOL))
{
//
// If this is not a software breakpoint set by HOST,
// restore EIP
@ -2469,6 +2522,7 @@ InterruptProcess (
} else {
CommandCommunication (Vector, CpuContext, BreakReceived);
}
break;
}
@ -2525,7 +2579,8 @@ InterruptProcess (
if ((!IsHostAttached () && (InputCharacter == DEBUG_STARTING_SYMBOL_ATTACH)) ||
(IsHostAttached () && (InputCharacter == DEBUG_COMMAND_HALT)) ||
(IsHostAttached () && (InputCharacter == DEBUG_COMMAND_GO))
) {
)
{
DebugAgentMsgPrint (DEBUG_AGENT_VERBOSE, "Received data [%02x]\n", InputCharacter);
//
// Ack OK for break-in symbol
@ -2555,6 +2610,7 @@ InterruptProcess (
HaltOtherProcessors (ProcessorIndex);
}
}
ReleaseMpSpinLock (&mDebugMpContext.DebugPortSpinLock);
CommandCommunication (Vector, CpuContext, BreakReceived);
AcquireMpSpinLock (&mDebugMpContext.DebugPortSpinLock);
@ -2587,6 +2643,7 @@ InterruptProcess (
if (MultiProcessorDebugSupport ()) {
mDebugMpContext.BreakAtCpuIndex = ProcessorIndex;
}
//
// Clear Stepping flag and restore EFLAGS.IF
//
@ -2603,11 +2660,13 @@ InterruptProcess (
if (IsFirstBreakProcessor (ProcessorIndex)) {
SendBreakPacketToHost (BreakCause, ProcessorIndex, &BreakReceived);
}
ReleaseMpSpinLock (&mDebugMpContext.DebugPortSpinLock);
}
CommandCommunication (Vector, CpuContext, BreakReceived);
}
break;
}
@ -2628,7 +2687,7 @@ InterruptProcess (
}
}
if (IssuedViewPoint == ProcessorIndex && GetDebugFlag (DEBUG_AGENT_FLAG_STEPPING) != 1) {
if ((IssuedViewPoint == ProcessorIndex) && (GetDebugFlag (DEBUG_AGENT_FLAG_STEPPING) != 1)) {
//
// If the command is not stepping, clean up AgentInProgress flag
//

View File

@ -156,7 +156,6 @@ typedef union {
UINT64 Uint64;
} IA32_IDT_ENTRY;
typedef union {
struct {
UINT32 LimitLow : 16;
@ -495,4 +494,3 @@ DebugAgentReadBuffer (
);
#endif

View File

@ -34,6 +34,7 @@ AcquireMpSpinLock (
if (AcquireSpinLockOrFail (MpSpinLock)) {
break;
}
CpuPause ();
continue;
}
@ -70,7 +71,7 @@ HaltOtherProcessors (
{
DebugAgentMsgPrint (DEBUG_AGENT_INFO, "processor[%x]:Try to halt other processors.\n", CurrentProcessorIndex);
if (!DebugAgentIsBsp (CurrentProcessorIndex)) {
SetIpiSentByApFlag (TRUE);;
SetIpiSentByApFlag (TRUE);
}
mDebugMpContext.BreakAtCpuIndex = CurrentProcessorIndex;
@ -84,7 +85,6 @@ HaltOtherProcessors (
// Send fixed IPI to other processors.
//
SendFixedIpiAllExcludingSelf (DEBUG_TIMER_VECTOR);
}
/**
@ -153,6 +153,7 @@ DebugAgentIsBsp (
mDebugMpContext.BspIndex = ProcessorIndex;
ReleaseMpSpinLock (&mDebugMpContext.MpContextSpinLock);
}
return TRUE;
} else {
return FALSE;
@ -185,6 +186,7 @@ SetCpuStopFlagByIndex (
} else {
Value = BitFieldWrite8 (Value, Index, Index, 0);
}
mDebugMpContext.CpuStopStatusMask[ProcessorIndex / 8] = Value;
ReleaseMpSpinLock (&mDebugMpContext.MpContextSpinLock);
@ -216,6 +218,7 @@ SetCpuBreakFlagByIndex (
} else {
Value = BitFieldWrite8 (Value, Index, Index, 0);
}
mDebugMpContext.CpuBreakMask[ProcessorIndex / 8] = Value;
ReleaseMpSpinLock (&mDebugMpContext.MpContextSpinLock);
@ -316,6 +319,7 @@ FindNextPendingBreakCpu (
return (UINT32)LowBitSet32 (mDebugMpContext.CpuBreakMask[Index]) + Index * 8;
}
}
return (UINT32)-1;
}
@ -338,6 +342,7 @@ IsAllCpuRunning (
return FALSE;
}
}
return TRUE;
}
@ -372,6 +377,6 @@ IsFirstBreakProcessor (
return TRUE;
}
}
return TRUE;
}

View File

@ -213,4 +213,3 @@ IsFirstBreakProcessor (
);
#endif

View File

@ -53,9 +53,11 @@ InitializeDebugTimer (
DEBUG ((DEBUG_INFO, "Debug Timer: Frequency = %d\n", ApicTimerFrequency));
DEBUG ((DEBUG_INFO, "Debug Timer: InitialCount = %d\n", InitialCount));
}
if (TimerFrequency != NULL) {
*TimerFrequency = ApicTimerFrequency;
}
return InitialCount;
}
@ -88,6 +90,7 @@ SaveAndSetDebugTimerInterrupt (
} else {
DisableApicTimerInterrupt ();
}
//
// Validate the Debug Timer interrupt state
// This will make additional delay after Local Apic Timer interrupt state is changed.

View File

@ -42,4 +42,3 @@ IsDebugTimerTimeout (
);
#endif

View File

@ -40,6 +40,7 @@ InitializeDebugIdt (
//
continue;
}
InterruptHandler = (UINTN)&Exception0Handle + Index * ExceptionStubHeaderSize;
IdtEntry[Index].Bits.OffsetLow = (UINT16)(UINTN)InterruptHandler;
IdtEntry[Index].Bits.OffsetHigh = (UINT16)((UINTN)InterruptHandler >> 16);

View File

@ -40,6 +40,7 @@ InitializeDebugIdt (
//
continue;
}
InterruptHandler = (UINTN)&Exception0Handle + Index * ExceptionStubHeaderSize;
IdtEntry[Index].Bits.OffsetLow = (UINT16)(UINTN)InterruptHandler;
IdtEntry[Index].Bits.OffsetHigh = (UINT16)((UINTN)InterruptHandler >> 16);

View File

@ -59,14 +59,15 @@ InternalConstructorWorker (
//
Status = EFI_SUCCESS;
GuidHob = GetFirstGuidHob (&gEfiVectorHandoffInfoPpiGuid);
if (GuidHob != NULL && !mDxeCoreFlag) {
if ((GuidHob != NULL) && !mDxeCoreFlag) {
//
// Check if configuration table is installed or not if GUIDed HOB existed,
// only when Debug Agent is not linked by DXE Core
//
Status = EfiGetSystemConfigurationTable (&gEfiVectorHandoffTableGuid, (VOID **)&VectorHandoffInfo);
}
if (GuidHob == NULL || Status != EFI_SUCCESS) {
if ((GuidHob == NULL) || (Status != EFI_SUCCESS)) {
//
// Install configuration table for persisted vector handoff info if GUIDed HOB cannot be found or
// configuration table does not exist
@ -161,7 +162,7 @@ GetMailboxFromConfigurationTable (
DEBUG_AGENT_MAILBOX *Mailbox;
Status = EfiGetSystemConfigurationTable (&gEfiDebugAgentGuid, (VOID **)&Mailbox);
if (Status == EFI_SUCCESS && Mailbox != NULL) {
if ((Status == EFI_SUCCESS) && (Mailbox != NULL)) {
VerifyMailboxChecksum (Mailbox);
return Mailbox;
} else {
@ -190,6 +191,7 @@ GetMailboxFromHob (
if (GuidHob == NULL) {
return NULL;
}
MailboxLocation = (UINT64 *)(GET_GUID_HOB_DATA (GuidHob));
Mailbox = (DEBUG_AGENT_MAILBOX *)(UINTN)(*MailboxLocation);
VerifyMailboxChecksum (Mailbox);
@ -294,6 +296,7 @@ SetupDebugAgentEnvironment (
} else {
ZeroMem (&mMailbox, sizeof (DEBUG_AGENT_MAILBOX));
}
mMailboxPointer = &mMailbox;
}
@ -326,7 +329,6 @@ SetupDebugAgentEnvironment (
}
}
/**
Initialize debug agent.
@ -369,9 +371,10 @@ InitializeDebugAgent (
InitializeLocalApicSoftwareEnable (TRUE);
GetApicTimerState (NULL, &PeriodicMode, NULL);
TimerCycle = GetApicTimerInitCount ();
if (!PeriodicMode || TimerCycle == 0) {
if (!PeriodicMode || (TimerCycle == 0)) {
InitializeDebugTimer (NULL, FALSE);
}
//
// Invoked by AP, enable interrupt to let AP could receive IPI from other processors
//
@ -396,7 +399,6 @@ InitializeDebugAgent (
MailboxLocation = NULL;
switch (InitFlag) {
case DEBUG_AGENT_INIT_DXE_LOAD:
//
// Check if Debug Agent has been initialized before
@ -423,6 +425,7 @@ InitializeDebugAgent (
HobList = GetHobList ();
Mailbox = GetMailboxFromHob (HobList);
}
//
// Set up Debug Agent Environment and try to connect HOST if required
//
@ -511,6 +514,7 @@ InitializeDebugAgent (
Mailbox = (DEBUG_AGENT_MAILBOX *)(UINTN)(*MailboxLocation);
VerifyMailboxChecksum (Mailbox);
}
//
// Save Mailbox pointer in global variable
//
@ -530,6 +534,7 @@ InitializeDebugAgent (
//
CpuBreakpoint ();
}
break;
default:

View File

@ -235,8 +235,12 @@ typedef struct {
//
EFI_HANDLE mSerialIoHandle = NULL;
UINTN mLoopbackBuffer = 0;
DEBUG_SERIAL_FIFO mSerialFifoForTerminal = {0, 0, DEBGU_SERIAL_IO_FIFO_DEPTH, { 0 }};
DEBUG_SERIAL_FIFO mSerialFifoForDebug = {0, 0, DEBGU_SERIAL_IO_FIFO_DEPTH, { 0 }};
DEBUG_SERIAL_FIFO mSerialFifoForTerminal = {
0, 0, DEBGU_SERIAL_IO_FIFO_DEPTH, { 0 }
};
DEBUG_SERIAL_FIFO mSerialFifoForDebug = {
0, 0, DEBGU_SERIAL_IO_FIFO_DEPTH, { 0 }
};
/**
Detect whether specific FIFO is empty or not.
@ -302,6 +306,7 @@ DebugTerminalFifoAdd (
if (IsDebugTerminalFifoFull (Fifo)) {
return EFI_OUT_OF_RESOURCES;
}
//
// FIFO is not full can add data
//
@ -337,6 +342,7 @@ DebugTerminalFifoRemove (
if (IsDebugTermianlFifoEmpty (Fifo)) {
return EFI_OUT_OF_RESOURCES;
}
//
// FIFO is not empty, can remove data
//
@ -363,8 +369,10 @@ InstallSerialIo (
Status = gBS->InstallMultipleProtocolInterfaces (
&mSerialIoHandle,
&gEfiDevicePathProtocolGuid, &mSerialIoDevicePath,
&gEfiSerialIoProtocolGuid, &mSerialIo,
&gEfiDevicePathProtocolGuid,
&mSerialIoDevicePath,
&gEfiSerialIoProtocolGuid,
&mSerialIo,
NULL
);
if (EFI_ERROR (Status)) {
@ -445,7 +453,7 @@ SerialSetAttributes (
// SERIAL_PORT_DEFAULT_RECEIVE_FIFO_DEPTH. The Debug Communication Library may actually be
// using a larger FIFO, but there is no way to tell.
//
if (ReceiveFifoDepth == 0 || ReceiveFifoDepth >= SERIAL_PORT_DEFAULT_RECEIVE_FIFO_DEPTH) {
if ((ReceiveFifoDepth == 0) || (ReceiveFifoDepth >= SERIAL_PORT_DEFAULT_RECEIVE_FIFO_DEPTH)) {
mSerialIoMode.ReceiveFifoDepth = SERIAL_PORT_DEFAULT_RECEIVE_FIFO_DEPTH;
} else {
return EFI_INVALID_PARAMETER;
@ -478,6 +486,7 @@ SerialSetControl (
if ((Control & (~EFI_SERIAL_SOFTWARE_LOOPBACK_ENABLE)) != 0) {
return EFI_UNSUPPORTED;
}
mSerialIoMode.ControlMask = Control;
return EFI_SUCCESS;
}
@ -580,10 +589,12 @@ SerialWrite (
if (*BufferSize == 0) {
return EFI_SUCCESS;
}
if ((mLoopbackBuffer & SERIAL_PORT_LOOPBACK_BUFFER_FULL) != 0) {
*BufferSize = 0;
return EFI_TIMEOUT;
}
mLoopbackBuffer = SERIAL_PORT_LOOPBACK_BUFFER_FULL | *(UINT8 *)Buffer;
*BufferSize = 1;
} else {
@ -650,6 +661,7 @@ SerialRead (
if ((mLoopbackBuffer & SERIAL_PORT_LOOPBACK_BUFFER_FULL) == 0) {
return EFI_TIMEOUT;
}
*Uint8Buffer = (UINT8)(mLoopbackBuffer & 0xff);
mLoopbackBuffer = 0;
*BufferSize = 1;
@ -664,12 +676,14 @@ SerialRead (
Uint8Buffer++;
continue;
}
//
// Read the input character from Debug Port
//
if (!DebugPortPollBuffer (Handle)) {
break;
}
DebugAgentReadBuffer (Handle, Data8, 1, 0);
if (*Data8 == DEBUG_STARTING_SYMBOL_ATTACH) {
@ -684,6 +698,7 @@ SerialRead (
DebugAgentMsgPrint (DEBUG_AGENT_INFO, "Terminal Timer break symbol received %x", DebugHeader.Command);
DebugTerminalFifoAdd (&mSerialFifoForDebug, DebugHeader.Command);
}
if (Status == EFI_TIMEOUT) {
continue;
}
@ -692,6 +707,7 @@ SerialRead (
Uint8Buffer++;
}
}
*BufferSize = (UINTN)Uint8Buffer - (UINTN)Buffer;
}
@ -743,6 +759,7 @@ DebugReadBreakFromDebugPort (
//
break;
}
//
// Try to read the start symbol
//
@ -752,6 +769,7 @@ DebugReadBreakFromDebugPort (
*BreakSymbol = *Data8;
return EFI_SUCCESS;
}
if (*Data8 == DEBUG_STARTING_SYMBOL_NORMAL) {
Status = ReadRemainingBreakPacket (Handle, &DebugHeader);
if (Status == EFI_SUCCESS) {
@ -759,6 +777,7 @@ DebugReadBreakFromDebugPort (
*BreakSymbol = DebugHeader.Command;
return EFI_SUCCESS;
}
if (Status == EFI_TIMEOUT) {
break;
}

View File

@ -10,7 +10,6 @@
GLOBAL_REMOVE_IF_UNREFERENCED BOOLEAN mSkipBreakpoint = FALSE;
GLOBAL_REMOVE_IF_UNREFERENCED EFI_PEI_VECTOR_HANDOFF_INFO_PPI mVectorHandoffInfoPpi = {
&mVectorHandoffInfoDebugAgent[0]
};
@ -84,6 +83,7 @@ DebugReadBreakSymbol (
//
break;
}
//
// Try to read the start symbol
//
@ -93,6 +93,7 @@ DebugReadBreakSymbol (
DebugAgentMsgPrint (DEBUG_AGENT_INFO, "Debug Timer attach symbol received %x", *BreakSymbol);
return EFI_SUCCESS;
}
if (*Data8 == DEBUG_STARTING_SYMBOL_NORMAL) {
Status = ReadRemainingBreakPacket (Handle, &DebugHeader);
if (Status == EFI_SUCCESS) {
@ -100,6 +101,7 @@ DebugReadBreakSymbol (
DebugAgentMsgPrint (DEBUG_AGENT_INFO, "Debug Timer break symbol received %x", *BreakSymbol);
return EFI_SUCCESS;
}
if (Status == EFI_TIMEOUT) {
break;
}
@ -159,6 +161,7 @@ GetMailboxLocationFromHob (
if (GuidHob == NULL) {
return NULL;
}
return (UINT64 *)(GET_GUID_HOB_DATA (GuidHob));
}
@ -186,8 +189,9 @@ GetMailboxPointer (
//
// Cannot used GetDebugFlag() to get Debug Flag to avoid GetMailboxPointer() nested
//
if (Mailbox->DebugFlag.Bits.CheckMailboxInHob != 1 ||
Mailbox->DebugFlag.Bits.InitArch != DEBUG_ARCH_SYMBOL) {
if ((Mailbox->DebugFlag.Bits.CheckMailboxInHob != 1) ||
(Mailbox->DebugFlag.Bits.InitArch != DEBUG_ARCH_SYMBOL))
{
//
// If mailbox was setup in SEC or the current CPU arch is different from the init arch
// Debug Agent initialized, return the mailbox from IDT entry directly.
@ -201,7 +205,7 @@ GetMailboxPointer (
// Compare mailbox in IDT entry with mailbox in HOB,
// need to fix mailbox location if HOB moved by PEI CORE
//
if (MailboxLocationInHob != MailboxLocationInIdt && MailboxLocationInHob != NULL) {
if ((MailboxLocationInHob != MailboxLocationInIdt) && (MailboxLocationInHob != NULL)) {
Mailbox = (DEBUG_AGENT_MAILBOX *)(UINTN)(*MailboxLocationInHob);
//
// Fix up Debug Port handler and save new mailbox in IDT entry
@ -378,7 +382,6 @@ InitializeDebugAgent (
CpuInterruptState = SaveAndDisableInterrupts ();
switch (InitFlag) {
case DEBUG_AGENT_INIT_PREMEM_SEC:
InitializeDebugIdt ();
@ -427,6 +430,7 @@ InitializeDebugAgent (
//
TriggerSoftInterrupt (MEMORY_READY_SIGNATURE);
}
//
// Install Vector Handoff Info PPI to persist vectors used by Debug Agent
//
@ -435,6 +439,7 @@ InitializeDebugAgent (
DEBUG ((DEBUG_ERROR, "DebugAgent: Failed to install Vector Handoff Info PPI!\n"));
CpuDeadLoop ();
}
//
// Fix up Debug Port handle address and mailbox address
//
@ -467,6 +472,7 @@ InitializeDebugAgent (
DEBUG ((DEBUG_ERROR, "DebugAgent: Failed to allocate pages!\n"));
CpuDeadLoop ();
}
NewMailbox = (DEBUG_AGENT_MAILBOX *)(UINTN)Address;
//
// Copy Mailbox and Debug Port Handle buffer to new location in ACPI NVS memory, because original Mailbox
@ -486,6 +492,7 @@ InitializeDebugAgent (
sizeof (UINT64)
);
}
//
// Update IDT entry to save the location saved mailbox pointer
//
@ -497,6 +504,7 @@ InitializeDebugAgent (
DEBUG ((DEBUG_ERROR, "DebugAgent: Input parameter Context cannot be NULL!\n"));
CpuDeadLoop ();
}
//
// Check if Debug Agent has initialized before
//
@ -504,6 +512,7 @@ InitializeDebugAgent (
DEBUG ((DEBUG_WARN, "Debug Agent: It has already initialized in SEC Core!\n"));
break;
}
//
// Install Vector Handoff Info PPI to persist vectors used by Debug Agent
//
@ -512,6 +521,7 @@ InitializeDebugAgent (
DEBUG ((DEBUG_ERROR, "DebugAgent: Failed to install Vector Handoff Info PPI!\n"));
CpuDeadLoop ();
}
//
// Set up IDT entries
//
@ -540,6 +550,7 @@ InitializeDebugAgent (
//
SetLocationSavedMailboxPointerInIdtEntry (MailboxLocationPointer);
}
//
// Save init arch type when debug agent initialized
//
@ -553,6 +564,7 @@ InitializeDebugAgent (
DEBUG ((DEBUG_ERROR, "DebugAgent: Failed to register memory discovered callback function!\n"));
CpuDeadLoop ();
}
//
// Set HOB check flag if memory has not been ready yet
//
@ -597,6 +609,7 @@ InitializeDebugAgent (
FindAndReportModuleImageInfo (4);
}
break;
default:
@ -625,16 +638,18 @@ InitializeDebugAgent (
//
EnableInterrupts ();
}
//
// If Function is not NULL, invoke it always whatever debug agent was initialized successfully or not.
//
if (Function != NULL) {
Function (Context);
}
//
// Set return status for DEBUG_AGENT_INIT_PEI
//
if (InitFlag == DEBUG_AGENT_INIT_PEI && Context != NULL) {
if ((InitFlag == DEBUG_AGENT_INIT_PEI) && (Context != NULL)) {
*(EFI_STATUS *)Context = EFI_SUCCESS;
}
}
@ -666,11 +681,12 @@ InitializeDebugAgentPhase2 (
MailboxLocation = GetLocationSavedMailboxPointerInIdtEntry ();
Mailbox = (DEBUG_AGENT_MAILBOX *)(UINTN)(*MailboxLocation);
BufferSize = PcdGet16 (PcdDebugPortHandleBufferSize);
if (Phase2Context->InitFlag == DEBUG_AGENT_INIT_PEI && BufferSize != 0) {
if ((Phase2Context->InitFlag == DEBUG_AGENT_INIT_PEI) && (BufferSize != 0)) {
NewDebugPortHandle = (UINT64)(UINTN)AllocateCopyPool (BufferSize, DebugPortHandle);
} else {
NewDebugPortHandle = (UINT64)(UINTN)DebugPortHandle;
}
UpdateMailboxContent (Mailbox, DEBUG_MAILBOX_DEBUG_PORT_HANDLE_INDEX, NewDebugPortHandle);
//
@ -684,10 +700,11 @@ InitializeDebugAgentPhase2 (
// host to disable low memory filtering.
//
SecCoreData = (EFI_SEC_PEI_HAND_OFF *)Phase2Context->Context;
if ((UINTN)SecCoreData->TemporaryRamBase < BASE_128MB && IsHostAttached ()) {
if (((UINTN)SecCoreData->TemporaryRamBase < BASE_128MB) && IsHostAttached ()) {
SetDebugFlag (DEBUG_AGENT_FLAG_MEMORY_READY, 1);
TriggerSoftInterrupt (MEMORY_READY_SIGNATURE);
}
//
// Enable Debug Timer interrupt
//

View File

@ -56,4 +56,3 @@ DebugAgentCallbackMemoryDiscoveredPpi (
);
#endif

View File

@ -78,6 +78,7 @@ GetMailboxFromHob (
if (GuidHob == NULL) {
return NULL;
}
MailboxLocation = (UINT64 *)(GET_GUID_HOB_DATA (GuidHob));
Mailbox = (DEBUG_AGENT_MAILBOX *)(UINTN)(*MailboxLocation);
VerifyMailboxChecksum (Mailbox);
@ -206,15 +207,17 @@ InitializeDebugAgent (
DEBUG ((DEBUG_ERROR, "DebugAgent: Cannot install configuration table for persisted vector handoff info!\n"));
CpuDeadLoop ();
}
//
// Check if Debug Agent initialized in DXE phase
//
Status = EfiGetSystemConfigurationTable (&gEfiDebugAgentGuid, (VOID **)&Mailbox);
if (Status == EFI_SUCCESS && Mailbox != NULL) {
if ((Status == EFI_SUCCESS) && (Mailbox != NULL)) {
VerifyMailboxChecksum (Mailbox);
mMailboxPointer = Mailbox;
break;
}
//
// Check if Debug Agent initialized in SEC/PEI phase
//
@ -223,6 +226,7 @@ InitializeDebugAgent (
mMailboxPointer = Mailbox;
break;
}
//
// Debug Agent was not initialized before, use the local mailbox.
//
@ -261,6 +265,7 @@ InitializeDebugAgent (
//
TriggerSoftInterrupt (MEMORY_READY_SIGNATURE);
}
//
// Find and report PE/COFF image info to HOST
//
@ -282,16 +287,18 @@ InitializeDebugAgent (
InitializeDebugIdt ();
mSmmDebugIdtInitFlag = TRUE;
}
//
// Check if CPU APIC Timer is working, otherwise initialize it.
//
InitializeLocalApicSoftwareEnable (TRUE);
GetApicTimerState (&mApicTimerDivisor, &mPeriodicMode, &mVector);
mTimerCycle = GetApicTimerInitCount ();
if (!mPeriodicMode || mTimerCycle == 0) {
if (!mPeriodicMode || (mTimerCycle == 0)) {
mApicTimerRestore = TRUE;
InitializeDebugTimer (NULL, FALSE);
}
Mailbox = GetMailboxPointer ();
if (GetDebugFlag (DEBUG_AGENT_FLAG_AGENT_IN_PROGRESS) == 1) {
//
@ -300,12 +307,14 @@ InitializeDebugAgent (
//
mSkipBreakpoint = TRUE;
}
if (GetDebugFlag (DEBUG_AGENT_FLAG_BREAK_ON_NEXT_SMI) == 1) {
if (mSkipBreakpoint) {
//
// Print warning message if ignore smm entry break
//
DebugPortWriteBuffer ((DEBUG_PORT_HANDLE) (UINTN)Mailbox->DebugPortHandle,
DebugPortWriteBuffer (
(DEBUG_PORT_HANDLE)(UINTN)Mailbox->DebugPortHandle,
(UINT8 *)mWarningMsgIgnoreSmmEntryBreak,
AsciiStrLen (mWarningMsgIgnoreSmmEntryBreak)
);
@ -316,6 +325,7 @@ InitializeDebugAgent (
CpuBreakpoint ();
}
}
break;
case DEBUG_AGENT_INIT_EXIT_SMI:
@ -332,6 +342,7 @@ InitializeDebugAgent (
InitializeApicTimer (mApicTimerDivisor, mTimerCycle, mPeriodicMode, mVector);
mApicTimerRestore = FALSE;
}
break;
case DEBUG_AGENT_INIT_THUNK_PEI_IA32TOX64:
@ -371,6 +382,7 @@ InitializeDebugAgent (
FindAndReportModuleImageInfo (SIZE_4KB);
}
break;
default:

View File

@ -95,7 +95,7 @@ DebugPortReadBuffer (
IN UINTN Timeout
)
{
if (NumberOfBytes != 1 || Buffer == NULL || Timeout != 0) {
if ((NumberOfBytes != 1) || (Buffer == NULL) || (Timeout != 0)) {
return 0;
}

View File

@ -223,6 +223,7 @@ CalculateUsbDebugPortBar (
if (CapabilityId == PCI_CAPABILITY_ID_DEBUG_PORT) {
break;
}
CapabilityPtr = PciRead8 (PcdGet32 (PcdUsbEhciPciAddress) + CapabilityPtr + 1);
}
@ -275,6 +276,7 @@ UsbDebugPortIn (
if (Length == NULL) {
return RETURN_INVALID_PARAMETER;
}
*Length = 0;
DebugPortRegister->TokenPid = Token;
@ -302,7 +304,8 @@ UsbDebugPortIn (
//
while ((MmioRead32 ((UINTN)&DebugPortRegister->ControlStatus) & (UINT32)BIT16) == 0) {
if ((MmioRead32 ((UINTN)&DebugPortRegister->ControlStatus) & (USB_DEBUG_PORT_OWNER | USB_DEBUG_PORT_IN_USE | USB_DEBUG_PORT_ENABLE))
!= (USB_DEBUG_PORT_OWNER | USB_DEBUG_PORT_IN_USE | USB_DEBUG_PORT_ENABLE)) {
!= (USB_DEBUG_PORT_OWNER | USB_DEBUG_PORT_IN_USE | USB_DEBUG_PORT_ENABLE))
{
return RETURN_DEVICE_ERROR;
}
}
@ -334,6 +337,7 @@ UsbDebugPortIn (
for (Index = 0; Index < *Length; Index++) {
Buffer[Index] = DebugPortRegister->DataBuffer[Index];
}
return RETURN_SUCCESS;
}
@ -377,6 +381,7 @@ UsbDebugPortOut (
} else {
DebugPortRegister->SendPid = DATA0_PID;
}
DebugPortRegister->UsbAddress = (UINT8)(Addr & 0x7F);
DebugPortRegister->UsbEndPoint = (UINT8)(Ep & 0xF);
@ -403,7 +408,8 @@ UsbDebugPortOut (
//
while ((MmioRead32 ((UINTN)&DebugPortRegister->ControlStatus) & BIT16) == 0) {
if ((MmioRead32 ((UINTN)&DebugPortRegister->ControlStatus) & (USB_DEBUG_PORT_OWNER | USB_DEBUG_PORT_IN_USE | USB_DEBUG_PORT_ENABLE))
!= (USB_DEBUG_PORT_OWNER | USB_DEBUG_PORT_IN_USE | USB_DEBUG_PORT_ENABLE)) {
!= (USB_DEBUG_PORT_OWNER | USB_DEBUG_PORT_IN_USE | USB_DEBUG_PORT_ENABLE))
{
return RETURN_DEVICE_ERROR;
}
}
@ -563,7 +569,8 @@ NeedReinitializeHardware(
//
UsbDebugPortRegister = (USB_DEBUG_PORT_REGISTER *)((UINTN)Handle->UsbDebugPortMemoryBase + Handle->DebugPortOffset);
if ((MmioRead32 ((UINTN)&UsbDebugPortRegister->ControlStatus) & (USB_DEBUG_PORT_OWNER | USB_DEBUG_PORT_ENABLE | USB_DEBUG_PORT_IN_USE))
!= (USB_DEBUG_PORT_OWNER | USB_DEBUG_PORT_ENABLE | USB_DEBUG_PORT_IN_USE)) {
!= (USB_DEBUG_PORT_OWNER | USB_DEBUG_PORT_ENABLE | USB_DEBUG_PORT_IN_USE))
{
Status = TRUE;
}
@ -572,6 +579,7 @@ NeedReinitializeHardware(
} else if (Handle->Initialized != USBDBG_INIT_DONE) {
Status = TRUE;
}
return Status;
}
@ -615,7 +623,8 @@ InitializeUsbDebugHardware (
// Check if the debug port is enabled and owned by myself.
//
if (((MmioRead32 ((UINTN)&UsbDebugPortRegister->ControlStatus) & (USB_DEBUG_PORT_OWNER | USB_DEBUG_PORT_IN_USE))
!= (USB_DEBUG_PORT_OWNER | USB_DEBUG_PORT_IN_USE)) || (Handle->Initialized == USBDBG_RESET)) {
!= (USB_DEBUG_PORT_OWNER | USB_DEBUG_PORT_IN_USE)) || (Handle->Initialized == USBDBG_RESET))
{
DEBUG ((
DEBUG_INFO,
"UsbDbg: Need to reset the host controller. ControlStatus = %08x\n",
@ -633,11 +642,13 @@ InitializeUsbDebugHardware (
//
// ensure that the host controller is reset.
//
while ((MmioRead32((UINTN)UsbCmd) & BIT1) != 0);
while ((MmioRead32 ((UINTN)UsbCmd) & BIT1) != 0) {
}
MmioOr32 ((UINTN)UsbCmd, BIT0);
// ensure that the host controller is started (HALTED bit must be cleared)
while ((MmioRead32((UINTN)UsbStatus) & BIT12) != 0);
while ((MmioRead32 ((UINTN)UsbStatus) & BIT12) != 0) {
}
}
//
@ -647,6 +658,7 @@ InitializeUsbDebugHardware (
MicroSecondDelay (200000);
}
//
// Find out which port is used as debug port.
//
@ -660,8 +672,9 @@ InitializeUsbDebugHardware (
return RETURN_NOT_FOUND;
}
if (Handle->Initialized != USBDBG_INIT_DONE ||
(MmioRead32 ((UINTN) &UsbDebugPortRegister->ControlStatus) & USB_DEBUG_PORT_ENABLE) == 0) {
if ((Handle->Initialized != USBDBG_INIT_DONE) ||
((MmioRead32 ((UINTN)&UsbDebugPortRegister->ControlStatus) & USB_DEBUG_PORT_ENABLE) == 0))
{
DEBUG ((DEBUG_INFO, "UsbDbg: Reset the debug port.\n"));
//
// Reset the debug port
@ -669,7 +682,8 @@ InitializeUsbDebugHardware (
MmioOr32 ((UINTN)PortStatus, BIT8);
MicroSecondDelay (500000);
MmioAnd32 ((UINTN)PortStatus, (UINT32) ~BIT8);
while (MmioRead32((UINTN)PortStatus) & BIT8);
while (MmioRead32 ((UINTN)PortStatus) & BIT8) {
}
//
// The port enabled bit should be set by HW.
@ -783,7 +797,7 @@ DebugPortReadBuffer (
RETURN_STATUS Status;
UINT8 Index;
if (NumberOfBytes != 1 || Buffer == NULL || Timeout != 0) {
if ((NumberOfBytes != 1) || (Buffer == NULL) || (Timeout != 0)) {
return 0;
}
@ -815,8 +829,10 @@ DebugPortReadBuffer (
if ((Index + 1) >= USB_DEBUG_PORT_MAX_PACKET_SIZE) {
return 0;
}
UsbDebugPortHandle->Data[Index] = UsbDebugPortHandle->Data[Index + 1];
}
UsbDebugPortHandle->DataCount = (UINT8)(UsbDebugPortHandle->DataCount - 1);
return 1;
}
@ -854,7 +870,7 @@ DebugPortWriteBuffer (
UINTN Total;
UINT8 ReceivedPid;
if (NumberOfBytes == 0 || Buffer == NULL) {
if ((NumberOfBytes == 0) || (Buffer == NULL)) {
return 0;
}
@ -903,8 +919,10 @@ DebugPortWriteBuffer (
} else {
UsbDebugPortHandle->BulkOutToggle ^= 1;
}
Total += Sent;
}
return Total;
}
@ -966,6 +984,7 @@ DebugPortPollBuffer (
} else {
UsbDebugPortRegister->SendPid = DATA1_PID;
}
UsbDebugPortRegister->UsbAddress = 0x7F;
UsbDebugPortRegister->UsbEndPoint = UsbDebugPortHandle->InEndpoint & 0x0F;
@ -983,7 +1002,8 @@ DebugPortPollBuffer (
//
while ((MmioRead32 ((UINTN)&UsbDebugPortRegister->ControlStatus) & (UINT32)BIT16) == 0) {
if ((MmioRead32 ((UINTN)&UsbDebugPortRegister->ControlStatus) & (USB_DEBUG_PORT_OWNER | USB_DEBUG_PORT_IN_USE | USB_DEBUG_PORT_ENABLE))
!= (USB_DEBUG_PORT_OWNER | USB_DEBUG_PORT_IN_USE | USB_DEBUG_PORT_ENABLE)) {
!= (USB_DEBUG_PORT_OWNER | USB_DEBUG_PORT_IN_USE | USB_DEBUG_PORT_ENABLE))
{
return FALSE;
}
}
@ -1007,6 +1027,7 @@ DebugPortPollBuffer (
for (Index = 0; Index < Length; Index++) {
UsbDebugPortHandle->Data[Index] = UsbDebugPortRegister->DataBuffer[Index];
}
UsbDebugPortHandle->DataCount = Length;
return TRUE;
@ -1051,9 +1072,10 @@ DebugPortInitialize (
//
ASSERT (PcdGet16 (PcdDebugPortHandleBufferSize) == sizeof (USB_DEBUG_PORT_HANDLE));
if (Function == NULL && Context != NULL) {
if ((Function == NULL) && (Context != NULL)) {
return (DEBUG_PORT_HANDLE *)Context;
}
ZeroMem (&Handle, sizeof (USB_DEBUG_PORT_HANDLE));
Status = CalculateUsbDebugPortBar (&Handle.DebugPortOffset, &Handle.DebugPortBarNumber);

View File

@ -287,12 +287,14 @@ CalculateUsbDebugPortMmioBase (
Flag = TRUE;
break;
}
if ((((Capability & XHC_NEXT_CAPABILITY_MASK) >> 8) & XHC_CAPABILITY_ID_MASK) == 0) {
//
// Reach the end of capability list, quit
//
break;
}
CapabilityPointer += ((Capability & XHC_NEXT_CAPABILITY_MASK) >> 8) * 4;
Capability = MmioRead32 ((UINTN)CapabilityPointer);
}
@ -642,6 +644,7 @@ XhcDetectDebugCapabilityReady (
Handle->Ready = TRUE;
break;
}
MicroSecondDelay (XHC_POLL_DELAY);
TimeOut--;
} while (TimeOut != 0);
@ -680,6 +683,7 @@ InitializeUsbDebugHardware (
//
return EFI_DEVICE_ERROR;
}
//
// If XHCI supports debug capability, hardware resource has been allocated,
// but it has not been enabled, try to enable again.
@ -880,7 +884,7 @@ DebugPortReadBuffer (
UINT8 Index;
UINT8 *Data;
if (NumberOfBytes != 1 || Buffer == NULL || Timeout != 0) {
if ((NumberOfBytes != 1) || (Buffer == NULL) || (Timeout != 0)) {
return 0;
}
@ -894,6 +898,7 @@ DebugPortReadBuffer (
} else {
UsbDebugPortHandle = GetUsb3DebugPortInstance ();
}
if (UsbDebugPortHandle == NULL) {
return 0;
}
@ -922,8 +927,10 @@ DebugPortReadBuffer (
if ((Index + 1) >= XHCI_DEBUG_DEVICE_MAX_PACKET_SIZE) {
return 0;
}
Data[Index] = Data[Index + 1];
}
UsbDebugPortHandle->DataCount = (UINT8)(UsbDebugPortHandle->DataCount - 1);
return 1;
}
@ -958,7 +965,7 @@ DebugPortWriteBuffer (
UINTN Sent;
UINTN Total;
if (NumberOfBytes == 0 || Buffer == NULL) {
if ((NumberOfBytes == 0) || (Buffer == NULL)) {
return 0;
}
@ -975,6 +982,7 @@ DebugPortWriteBuffer (
} else {
UsbDebugPortHandle = GetUsb3DebugPortInstance ();
}
if (UsbDebugPortHandle == NULL) {
return 0;
}
@ -1001,6 +1009,7 @@ DebugPortWriteBuffer (
} else {
Sent = (UINT8)(NumberOfBytes - Total);
}
XhcDataTransfer (UsbDebugPortHandle, EfiUsbDataOut, Buffer + Total, &Sent, DATA_TRANSFER_WRITE_TIMEOUT);
Total += Sent;
}
@ -1040,6 +1049,7 @@ DebugPortPollBuffer (
} else {
UsbDebugPortHandle = GetUsb3DebugPortInstance ();
}
if (UsbDebugPortHandle == NULL) {
return FALSE;
}
@ -1121,10 +1131,11 @@ DebugPortInitialize (
//
ASSERT (PcdGet16 (PcdDebugPortHandleBufferSize) == sizeof (USB3_DEBUG_PORT_HANDLE));
if (Function == NULL && Context != NULL) {
if ((Function == NULL) && (Context != NULL)) {
SetUsb3DebugPortInstance ((USB3_DEBUG_PORT_HANDLE *)Context);
return (DEBUG_PORT_HANDLE)Context;
}
UsbDebugPortHandle = GetUsb3DebugPortInstance ();
if (UsbDebugPortHandle == NULL) {
return NULL;

View File

@ -274,7 +274,8 @@ Usb3PciIoNotify (
);
if (!EFI_ERROR (Status) &&
(PciIoHandleBuffer != NULL) &&
(PciIoHandleCount != 0)) {
(PciIoHandleCount != 0))
{
for (Index = 0; Index < PciIoHandleCount; Index++) {
Status = gBS->HandleProtocol (
PciIoHandleBuffer[Index],
@ -309,6 +310,7 @@ Usb3PciIoNotify (
}
}
}
gBS->CloseEvent (Event);
break;
}
@ -334,6 +336,7 @@ GetUsb3DebugPortInstanceAddrPtr (
mUsb3InstanceAddr = (EFI_PHYSICAL_ADDRESS)(UINTN)&mUsb3Instance;
mUsb3InstanceAddrPtr = &mUsb3InstanceAddr;
}
return mUsb3InstanceAddrPtr;
}
@ -378,6 +381,7 @@ Usb3AllocateDmaBuffer (
EFI_PAGES_TO_SIZE (Pages)
);
}
return Status;
}
@ -478,6 +482,7 @@ DebugCommunicationUsb3DxeConstructor (
if (mUsb3InstanceAddrPtr != NULL) {
*AddrPtr = *mUsb3InstanceAddrPtr;
}
mUsb3InstanceAddrPtr = AddrPtr;
Instance = GetUsb3DebugPortInstance ();
@ -526,6 +531,6 @@ DebugCommunicationUsb3DxeDestructor (
gBS->CloseEvent ((EFI_EVENT)(UINTN)Instance->PciIoEvent);
Instance->PciIoEvent = 0;
}
return EFI_SUCCESS;
}

View File

@ -126,6 +126,7 @@ IoMmuAllocateBuffer (
*HostAddress = NULL;
return EFI_OUT_OF_RESOURCES;
}
Status = IoMmu->SetAttribute (
IoMmu,
*Mapping,
@ -268,6 +269,6 @@ AllocateAlignBuffer (
}
}
}
return Buf;
}

View File

@ -40,6 +40,7 @@ XhcSyncTrsRing (
if (TrsTrb->CycleBit != (TrsRing->RingPCS & BIT0)) {
break;
}
TrsTrb++;
if ((UINT8)TrsTrb->Type == TRB_TYPE_LINK) {
ASSERT (((LINK_TRB *)TrsTrb)->TC != 0);
@ -54,6 +55,7 @@ XhcSyncTrsRing (
TrsTrb = (TRB_TEMPLATE *)(UINTN)((TrsTrb->Parameter1 | LShiftU64 ((UINT64)TrsTrb->Parameter2, 32)) & ~0x0F);
}
}
ASSERT (Index != TrsRing->TrbNumber);
if ((EFI_PHYSICAL_ADDRESS)(UINTN)TrsTrb != TrsRing->RingEnqueue) {
@ -188,6 +190,7 @@ IsTrbInTrsRing (
if (Trb == CheckedTrb) {
return TRUE;
}
CheckedTrb++;
}
@ -231,7 +234,6 @@ XhcCheckUrbResult (
XhcSyncEventRing (Handle, &Handle->EventRing);
for (Index = 0; Index < Handle->EventRing.TrbNumber; Index++) {
Status = XhcCheckNewEvent (Handle, &Handle->EventRing, ((TRB_TEMPLATE **)&EvtTrb));
if (Status == EFI_NOT_READY) {
//
@ -265,7 +267,8 @@ XhcCheckUrbResult (
}
if ((EvtTrb->Completecode == TRB_COMPLETION_SHORT_PACKET) ||
(EvtTrb->Completecode == TRB_COMPLETION_SUCCESS)) {
(EvtTrb->Completecode == TRB_COMPLETION_SUCCESS))
{
//
// The length of data which were transferred.
//
@ -273,6 +276,7 @@ XhcCheckUrbResult (
} else {
CheckedUrb->Result |= EFI_USB_ERR_TIMEOUT;
}
//
// This Urb has been processed
//
@ -356,6 +360,7 @@ XhcExecTransfer (
if (Timeout == 0) {
Loop = 0xFFFFFFFF;
}
XhcRingDoorBell (Handle, Urb);
//
// Event Ring Not Empty bit can only be set to 1 by XHC after ringing door bell with some delay.
@ -365,14 +370,17 @@ XhcExecTransfer (
if (Urb->Finished) {
break;
}
MicroSecondDelay (XHC_DEBUG_PORT_1_MILLISECOND);
}
if (Index == Loop) {
//
// If time out occurs.
//
Urb->Result |= EFI_USB_ERR_TIMEOUT;
}
//
// If URB transfer is error, restore transfer ring to original value before URB transfer
// This will make the current transfer TRB is always at the latest unused one in transfer ring.
@ -574,4 +582,3 @@ XhcDataTransfer (
return Status;
}

View File

@ -34,7 +34,7 @@ CheckDebugAgentHandler (
InterruptHandler = IdtEntry[InterruptType].Bits.OffsetLow +
(IdtEntry[InterruptType].Bits.OffsetHigh << 16);
if (InterruptHandler >= sizeof (UINT32) && *(UINT32 *)(InterruptHandler - sizeof (UINT32)) == AGENT_HANDLER_SIGNATURE) {
if ((InterruptHandler >= sizeof (UINT32)) && (*(UINT32 *)(InterruptHandler - sizeof (UINT32)) == AGENT_HANDLER_SIGNATURE)) {
return TRUE;
} else {
return FALSE;

View File

@ -84,6 +84,7 @@ PeCoffLoaderExtraActionCommon (
LoadImageMethod = DEBUG_LOAD_IMAGE_METHOD_SOFT_INT3;
}
}
AsmReadIdtr (&IdtDescriptor);
if (LoadImageMethod == DEBUG_LOAD_IMAGE_METHOD_SOFT_INT3) {
if (!CheckDebugAgentHandler (&IdtDescriptor, SOFT_INT_VECTOR_NUM)) {
@ -136,7 +137,6 @@ PeCoffLoaderExtraActionCommon (
do {
DebugAgentStatus = IoRead8 (IO_PORT_BREAKPOINT_ADDRESS);
} while (DebugAgentStatus == DEBUG_AGENT_IMAGE_WAIT);
} else if (LoadImageMethod == DEBUG_LOAD_IMAGE_METHOD_SOFT_INT3) {
//
// Generate a software break point.
@ -150,26 +150,31 @@ PeCoffLoaderExtraActionCommon (
// in the above exception handler
//
NewDr7 = AsmReadDr7 () | BIT10; // H/w sets bit 10, some simulators don't
if (!IsDrxEnabled (0, NewDr7) && (AsmReadDr0 () == 0 || AsmReadDr0 () == Signature)) {
if (!IsDrxEnabled (0, NewDr7) && ((AsmReadDr0 () == 0) || (AsmReadDr0 () == Signature))) {
//
// If user changed Dr3 (by setting HW bp in the above exception handler,
// we will not set Dr0 to 0 in GO/STEP handler because the break cause is not IMAGE_LOAD/_UNLOAD.
//
AsmWriteDr0 (Dr0);
}
if (!IsDrxEnabled (1, NewDr7) && (AsmReadDr1 () == (UINTN)ImageContext->PdbPointer)) {
AsmWriteDr1 (Dr1);
}
if (!IsDrxEnabled (2, NewDr7) && (AsmReadDr2 () == (UINTN)ImageContext)) {
AsmWriteDr2 (Dr2);
}
if (!IsDrxEnabled (3, NewDr7) && (AsmReadDr3 () == IO_PORT_BREAKPOINT_ADDRESS)) {
AsmWriteDr3 (Dr3);
}
if (LoadImageMethod == DEBUG_LOAD_IMAGE_METHOD_IO_HW_BREAKPOINT) {
if (AsmReadCr4 () == (Cr4 | BIT3)) {
AsmWriteCr4 (Cr4);
}
if (NewDr7 == 0x20000480) {
AsmWriteDr7 (Dr7);
}
@ -178,12 +183,14 @@ PeCoffLoaderExtraActionCommon (
AsmWriteDr7 (Dr7);
}
}
//
// Restore original IDT entry for INT1 if it was hooked.
//
if (IdtEntryHooked) {
RestoreIdtEntry1 (&IdtDescriptor, &OriginalIdtEntry);
}
//
// Restore the interrupt state
//

View File

@ -70,4 +70,3 @@ RestoreIdtEntry1 (
);
#endif

View File

@ -35,7 +35,7 @@ CheckDebugAgentHandler (
InterruptHandler = IdtEntry[InterruptType].Bits.OffsetLow +
(((UINTN)IdtEntry[InterruptType].Bits.OffsetHigh) << 16) +
(((UINTN)IdtEntry[InterruptType].Bits.OffsetUpper) << 32);
if (InterruptHandler >= sizeof (UINT32) && *(UINT32 *)(InterruptHandler - sizeof (UINT32)) == AGENT_HANDLER_SIGNATURE) {
if ((InterruptHandler >= sizeof (UINT32)) && (*(UINT32 *)(InterruptHandler - sizeof (UINT32)) == AGENT_HANDLER_SIGNATURE)) {
return TRUE;
} else {
return FALSE;