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:
committed by
mergify[bot]
parent
b878648967
commit
c1e126b119
@ -81,14 +81,17 @@ DebugAgentDxeInitialize(
|
|||||||
Print (L"3: Shell> disconnect EA\r\n");
|
Print (L"3: Shell> disconnect EA\r\n");
|
||||||
Print (L"4: Shell> load -nc DebugAgentDxe.efi\r\n\r\n");
|
Print (L"4: Shell> load -nc DebugAgentDxe.efi\r\n\r\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
Status = EFI_UNSUPPORTED;
|
Status = EFI_UNSUPPORTED;
|
||||||
InitializeDebugAgent (DEBUG_AGENT_INIT_DXE_LOAD, &Status, NULL);
|
InitializeDebugAgent (DEBUG_AGENT_INIT_DXE_LOAD, &Status, NULL);
|
||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (gST->ConOut != NULL) {
|
if (gST->ConOut != NULL) {
|
||||||
Print (L"Debug Agent: Initialized successfully!\r\n\r\n");
|
Print (L"Debug Agent: Initialized successfully!\r\n\r\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Create event to disable Debug Timer interrupt when exit boot service.
|
// Create event to disable Debug Timer interrupt when exit boot service.
|
||||||
//
|
//
|
||||||
|
@ -301,4 +301,3 @@ typedef struct {
|
|||||||
#pragma pack()
|
#pragma pack()
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -19,4 +19,3 @@
|
|||||||
#define DEBUG_AGENT_IMAGE_CONTINUE 0x01
|
#define DEBUG_AGENT_IMAGE_CONTINUE 0x01
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -70,7 +70,6 @@ DebugPortInitialize (
|
|||||||
IN DEBUG_PORT_CONTINUE Function
|
IN DEBUG_PORT_CONTINUE Function
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Read data from debug device and save the datas in buffer.
|
Read data from debug device and save the datas in buffer.
|
||||||
|
|
||||||
@ -97,7 +96,6 @@ DebugPortReadBuffer (
|
|||||||
IN UINTN Timeout
|
IN UINTN Timeout
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Write data from buffer to debug device.
|
Write data from buffer to debug device.
|
||||||
|
|
||||||
@ -143,4 +141,3 @@ DebugPortPollBuffer (
|
|||||||
);
|
);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -367,4 +367,3 @@ typedef struct {
|
|||||||
#pragma pack()
|
#pragma pack()
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -157,10 +157,10 @@ CalculateCrc16 (
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return Crc;
|
return Crc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Read IDT entry to check if IDT entries are setup by Debug Agent.
|
Read IDT entry to check if IDT entries are setup by Debug Agent.
|
||||||
|
|
||||||
@ -176,7 +176,7 @@ IsDebugAgentInitialzed (
|
|||||||
UINTN InterruptHandler;
|
UINTN InterruptHandler;
|
||||||
|
|
||||||
InterruptHandler = (UINTN)GetExceptionHandlerInIdtEntry (0);
|
InterruptHandler = (UINTN)GetExceptionHandlerInIdtEntry (0);
|
||||||
if (InterruptHandler >= 4 && *(UINT32 *)(InterruptHandler - 4) == AGENT_HANDLER_SIGNATURE) {
|
if ((InterruptHandler >= 4) && (*(UINT32 *)(InterruptHandler - 4) == AGENT_HANDLER_SIGNATURE)) {
|
||||||
return TRUE;
|
return TRUE;
|
||||||
} else {
|
} else {
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@ -245,7 +245,6 @@ TriggerSoftInterrupt (
|
|||||||
//
|
//
|
||||||
AsmWriteDr0 (Dr0);
|
AsmWriteDr0 (Dr0);
|
||||||
AsmWriteDr1 (Dr1);
|
AsmWriteDr1 (Dr1);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -282,7 +281,7 @@ VerifyMailboxChecksum (
|
|||||||
// The checksum updating process may be disturbed by hardware SMI, we need to check CheckSum field
|
// The checksum updating process may be disturbed by hardware SMI, we need to check CheckSum field
|
||||||
// and ToBeCheckSum field to validate the mail box.
|
// 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: 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));
|
DEBUG ((DEBUG_ERROR, "DebugAgent: CheckSum = %x, Mailbox->CheckSum = %x, Mailbox->ToBeCheckSum = %x\n", CheckSum, Mailbox->CheckSum, Mailbox->ToBeCheckSum));
|
||||||
CpuDeadLoop ();
|
CpuDeadLoop ();
|
||||||
@ -342,6 +341,7 @@ UpdateMailboxContent (
|
|||||||
Mailbox->DebugTimerFrequency = (UINT32)Value;
|
Mailbox->DebugTimerFrequency = (UINT32)Value;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
UpdateMailboxChecksum (Mailbox);
|
UpdateMailboxChecksum (Mailbox);
|
||||||
ReleaseMpSpinLock (&mDebugMpContext.MailboxSpinLock);
|
ReleaseMpSpinLock (&mDebugMpContext.MailboxSpinLock);
|
||||||
}
|
}
|
||||||
@ -395,6 +395,7 @@ DebugAgentReadBuffer (
|
|||||||
);
|
);
|
||||||
TimerRound = (UINT32)DivU64x32Remainder (TimeoutTicker, TimerCycle / 2, &TimeoutTicker);
|
TimerRound = (UINT32)DivU64x32Remainder (TimeoutTicker, TimerCycle / 2, &TimeoutTicker);
|
||||||
}
|
}
|
||||||
|
|
||||||
Index = 0;
|
Index = 0;
|
||||||
while (Index < NumberOfBytes) {
|
while (Index < NumberOfBytes) {
|
||||||
if (DebugPortPollBuffer (Handle)) {
|
if (DebugPortPollBuffer (Handle)) {
|
||||||
@ -402,6 +403,7 @@ DebugAgentReadBuffer (
|
|||||||
Index++;
|
Index++;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Timeout != 0) {
|
if (Timeout != 0) {
|
||||||
if (TimerRound == 0) {
|
if (TimerRound == 0) {
|
||||||
if (IsDebugTimerTimeout (TimerCycle, Begin, TimeoutTicker)) {
|
if (IsDebugTimerTimeout (TimerCycle, Begin, TimeoutTicker)) {
|
||||||
@ -490,7 +492,8 @@ SendDebugMsgPacket (
|
|||||||
DebugHeader.SequenceNo = 0xEE;
|
DebugHeader.SequenceNo = 0xEE;
|
||||||
DebugHeader.Crc = 0;
|
DebugHeader.Crc = 0;
|
||||||
DebugHeader.Crc = CalculateCrc16 (
|
DebugHeader.Crc = CalculateCrc16 (
|
||||||
(UINT8 *)Buffer, Length,
|
(UINT8 *)Buffer,
|
||||||
|
Length,
|
||||||
CalculateCrc16 ((UINT8 *)&DebugHeader, sizeof (DEBUG_PACKET_HEADER), 0)
|
CalculateCrc16 ((UINT8 *)&DebugHeader, sizeof (DEBUG_PACKET_HEADER), 0)
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -590,6 +593,7 @@ DebugAgentDataMsgPrint (
|
|||||||
SendDebugMsgPacket (Buffer, DestBuffer - Buffer);
|
SendDebugMsgPacket (Buffer, DestBuffer - Buffer);
|
||||||
DestBuffer = Buffer;
|
DestBuffer = Buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
DestBuffer += AsciiSPrint (DestBuffer, DEBUG_DATA_MAXIMUM_REAL_DATA - (DestBuffer - Buffer), "%02x ", Data[Index]);
|
DestBuffer += AsciiSPrint (DestBuffer, DEBUG_DATA_MAXIMUM_REAL_DATA - (DestBuffer - Buffer), "%02x ", Data[Index]);
|
||||||
Index++;
|
Index++;
|
||||||
if (Index >= Length) {
|
if (Index >= Length) {
|
||||||
@ -642,6 +646,7 @@ ReadRemainingBreakPacket (
|
|||||||
DebugAgentDataMsgPrint (DEBUG_AGENT_VERBOSE, FALSE, (UINT8 *)DebugHeader, DebugHeader->Length);
|
DebugAgentDataMsgPrint (DEBUG_AGENT_VERBOSE, FALSE, (UINT8 *)DebugHeader, DebugHeader->Length);
|
||||||
return EFI_CRC_ERROR;
|
return EFI_CRC_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
Mailbox = GetMailboxPointer ();
|
Mailbox = GetMailboxPointer ();
|
||||||
if (IS_REQUEST (DebugHeader)) {
|
if (IS_REQUEST (DebugHeader)) {
|
||||||
if (DebugHeader->SequenceNo == (UINT8)(Mailbox->HostSequenceNo + 1)) {
|
if (DebugHeader->SequenceNo == (UINT8)(Mailbox->HostSequenceNo + 1)) {
|
||||||
@ -651,6 +656,7 @@ ReadRemainingBreakPacket (
|
|||||||
UpdateMailboxContent (Mailbox, DEBUG_MAILBOX_HOST_SEQUENCE_NO_INDEX, DebugHeader->SequenceNo);
|
UpdateMailboxContent (Mailbox, DEBUG_MAILBOX_HOST_SEQUENCE_NO_INDEX, DebugHeader->SequenceNo);
|
||||||
return EFI_SUCCESS;
|
return EFI_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (DebugHeader->SequenceNo == Mailbox->HostSequenceNo) {
|
if (DebugHeader->SequenceNo == Mailbox->HostSequenceNo) {
|
||||||
return EFI_SUCCESS;
|
return EFI_SUCCESS;
|
||||||
}
|
}
|
||||||
@ -719,6 +725,7 @@ SetDebugSetting (
|
|||||||
default:
|
default:
|
||||||
Status = RETURN_UNSUPPORTED;
|
Status = RETURN_UNSUPPORTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -850,21 +857,23 @@ ClearDebugRegister (
|
|||||||
CpuContext->Dr0 = 0;
|
CpuContext->Dr0 = 0;
|
||||||
CpuContext->Dr7 &= (UINTN)(~(0x3 << 0));
|
CpuContext->Dr7 &= (UINTN)(~(0x3 << 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((ClearHwBreakpoint->IndexMask & BIT1) != 0) {
|
if ((ClearHwBreakpoint->IndexMask & BIT1) != 0) {
|
||||||
CpuContext->Dr1 = 0;
|
CpuContext->Dr1 = 0;
|
||||||
CpuContext->Dr7 &= (UINTN)(~(0x3 << 2));
|
CpuContext->Dr7 &= (UINTN)(~(0x3 << 2));
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((ClearHwBreakpoint->IndexMask & BIT2) != 0) {
|
if ((ClearHwBreakpoint->IndexMask & BIT2) != 0) {
|
||||||
CpuContext->Dr2 = 0;
|
CpuContext->Dr2 = 0;
|
||||||
CpuContext->Dr7 &= (UINTN)(~(0x3 << 4));
|
CpuContext->Dr7 &= (UINTN)(~(0x3 << 4));
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((ClearHwBreakpoint->IndexMask & BIT3) != 0) {
|
if ((ClearHwBreakpoint->IndexMask & BIT3) != 0) {
|
||||||
CpuContext->Dr3 = 0;
|
CpuContext->Dr3 = 0;
|
||||||
CpuContext->Dr7 &= (UINTN)(~(0x3 << 6));
|
CpuContext->Dr7 &= (UINTN)(~(0x3 << 6));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Return the offset of FP / MMX / XMM registers in the FPU saved state by register index.
|
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);
|
DebugAgentMsgPrint (DEBUG_AGENT_ERROR, "Send ACK(%d)\n", AckCommand);
|
||||||
}
|
}
|
||||||
|
|
||||||
Mailbox = GetMailboxPointer ();
|
Mailbox = GetMailboxPointer ();
|
||||||
SequenceNo = Mailbox->HostSequenceNo;
|
SequenceNo = Mailbox->HostSequenceNo;
|
||||||
DebugAgentMsgPrint (DEBUG_AGENT_INFO, "SendAckPacket: SequenceNo = %x\n", SequenceNo);
|
DebugAgentMsgPrint (DEBUG_AGENT_INFO, "SendAckPacket: SequenceNo = %x\n", SequenceNo);
|
||||||
@ -1062,6 +1072,7 @@ DecompressDataInPlace (
|
|||||||
if (LastChar != CurrentChar) {
|
if (LastChar != CurrentChar) {
|
||||||
LastCharCount = 0;
|
LastCharCount = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
LastCharCount++;
|
LastCharCount++;
|
||||||
LastChar = CurrentChar;
|
LastChar = CurrentChar;
|
||||||
}
|
}
|
||||||
@ -1141,6 +1152,7 @@ ReceivePacket (
|
|||||||
DebugAgentMsgPrint (DEBUG_AGENT_ERROR, "DebugAgentReadBuffer(Command) timeout\n");
|
DebugAgentMsgPrint (DEBUG_AGENT_ERROR, "DebugAgentReadBuffer(Command) timeout\n");
|
||||||
return RETURN_TIMEOUT;
|
return RETURN_TIMEOUT;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (DebugHeader->Length < sizeof (DEBUG_PACKET_HEADER)) {
|
if (DebugHeader->Length < sizeof (DEBUG_PACKET_HEADER)) {
|
||||||
if (IncompatibilityFlag != NULL) {
|
if (IncompatibilityFlag != NULL) {
|
||||||
//
|
//
|
||||||
@ -1162,6 +1174,7 @@ ReceivePacket (
|
|||||||
DebugAgentMsgPrint (DEBUG_AGENT_ERROR, "DebugAgentReadBuffer(SequenceNo) timeout\n");
|
DebugAgentMsgPrint (DEBUG_AGENT_ERROR, "DebugAgentReadBuffer(SequenceNo) timeout\n");
|
||||||
return RETURN_TIMEOUT;
|
return RETURN_TIMEOUT;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Calculate the CRC of Debug Packet
|
// Calculate the CRC of Debug Packet
|
||||||
//
|
//
|
||||||
@ -1170,6 +1183,7 @@ ReceivePacket (
|
|||||||
if (Crc == CalculateCrc16 ((UINT8 *)DebugHeader, DebugHeader->Length, 0)) {
|
if (Crc == CalculateCrc16 ((UINT8 *)DebugHeader, DebugHeader->Length, 0)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
DebugAgentMsgPrint (DEBUG_AGENT_WARNING, "CRC Error (received CRC is %x)\n", Crc);
|
DebugAgentMsgPrint (DEBUG_AGENT_WARNING, "CRC Error (received CRC is %x)\n", Crc);
|
||||||
DebugAgentDataMsgPrint (DEBUG_AGENT_VERBOSE, FALSE, (UINT8 *)DebugHeader, DebugHeader->Length);
|
DebugAgentDataMsgPrint (DEBUG_AGENT_VERBOSE, FALSE, (UINT8 *)DebugHeader, DebugHeader->Length);
|
||||||
}
|
}
|
||||||
@ -1180,9 +1194,11 @@ ReceivePacket (
|
|||||||
if (DebugHeader->StartSymbol == DEBUG_STARTING_SYMBOL_COMPRESS) {
|
if (DebugHeader->StartSymbol == DEBUG_STARTING_SYMBOL_COMPRESS) {
|
||||||
DebugHeader->StartSymbol = DEBUG_STARTING_SYMBOL_NORMAL;
|
DebugHeader->StartSymbol = DEBUG_STARTING_SYMBOL_NORMAL;
|
||||||
DebugHeader->Length = DecompressDataInPlace (
|
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);
|
) + sizeof (DEBUG_PACKET_HEADER);
|
||||||
}
|
}
|
||||||
|
|
||||||
return RETURN_SUCCESS;
|
return RETURN_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1233,26 +1249,30 @@ SendCommandAndWaitForAckOK (
|
|||||||
} else {
|
} else {
|
||||||
DebugAgentMsgPrint (DEBUG_AGENT_WARNING, "TARGET: Timeout when waiting for ACK packet.\n");
|
DebugAgentMsgPrint (DEBUG_AGENT_WARNING, "TARGET: Timeout when waiting for ACK packet.\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
ASSERT_EFI_ERROR (Status);
|
ASSERT_EFI_ERROR (Status);
|
||||||
//
|
//
|
||||||
// Status == RETURN_SUCCESS
|
// Status == RETURN_SUCCESS
|
||||||
//
|
//
|
||||||
if (DebugHeader->Command == DEBUG_COMMAND_OK && DebugHeader->SequenceNo == SequenceNo) {
|
if ((DebugHeader->Command == DEBUG_COMMAND_OK) && (DebugHeader->SequenceNo == SequenceNo)) {
|
||||||
//
|
//
|
||||||
// Received Ack OK
|
// Received Ack OK
|
||||||
//
|
//
|
||||||
UpdateMailboxContent (GetMailboxPointer (), DEBUG_MAILBOX_SEQUENCE_NO_INDEX, ++SequenceNo);
|
UpdateMailboxContent (GetMailboxPointer (), DEBUG_MAILBOX_SEQUENCE_NO_INDEX, ++SequenceNo);
|
||||||
return Status;
|
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
|
// Received Old GO
|
||||||
//
|
//
|
||||||
if (Command == DEBUG_COMMAND_INIT_BREAK) {
|
if (Command == DEBUG_COMMAND_INIT_BREAK) {
|
||||||
DebugAgentMsgPrint (DEBUG_AGENT_WARNING, "TARGET: Receive GO() in last boot\n");
|
DebugAgentMsgPrint (DEBUG_AGENT_WARNING, "TARGET: Receive GO() in last boot\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
SendPacketWithoutData (DEBUG_COMMAND_OK, DebugHeader->SequenceNo);
|
SendPacketWithoutData (DEBUG_COMMAND_OK, DebugHeader->SequenceNo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1299,7 +1319,6 @@ GetBreakCause (
|
|||||||
// to report image load/unload).
|
// to report image load/unload).
|
||||||
//
|
//
|
||||||
return Cause;
|
return Cause;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
Cause = DEBUG_DATA_BREAK_CAUSE_HW_BREAKPOINT;
|
Cause = DEBUG_DATA_BREAK_CAUSE_HW_BREAKPOINT;
|
||||||
}
|
}
|
||||||
@ -1315,10 +1334,10 @@ GetBreakCause (
|
|||||||
case IMAGE_UNLOAD_SIGNATURE:
|
case IMAGE_UNLOAD_SIGNATURE:
|
||||||
|
|
||||||
if (CpuContext->Dr3 == IO_PORT_BREAKPOINT_ADDRESS) {
|
if (CpuContext->Dr3 == IO_PORT_BREAKPOINT_ADDRESS) {
|
||||||
|
|
||||||
Cause = (UINT8)((CpuContext->Dr0 == IMAGE_LOAD_SIGNATURE) ?
|
Cause = (UINT8)((CpuContext->Dr0 == IMAGE_LOAD_SIGNATURE) ?
|
||||||
DEBUG_DATA_BREAK_CAUSE_IMAGE_LOAD : DEBUG_DATA_BREAK_CAUSE_IMAGE_UNLOAD);
|
DEBUG_DATA_BREAK_CAUSE_IMAGE_LOAD : DEBUG_DATA_BREAK_CAUSE_IMAGE_UNLOAD);
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SOFT_INTERRUPT_SIGNATURE:
|
case SOFT_INTERRUPT_SIGNATURE:
|
||||||
@ -1330,11 +1349,11 @@ GetBreakCause (
|
|||||||
Cause = DEBUG_DATA_BREAK_CAUSE_SYSTEM_RESET;
|
Cause = DEBUG_DATA_BREAK_CAUSE_SYSTEM_RESET;
|
||||||
CpuContext->Dr0 = 0;
|
CpuContext->Dr0 = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
@ -1354,6 +1373,7 @@ GetBreakCause (
|
|||||||
Cause = DEBUG_DATA_BREAK_CAUSE_EXCEPTION;
|
Cause = DEBUG_DATA_BREAK_CAUSE_EXCEPTION;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1411,6 +1431,7 @@ CopyMemByWidth (
|
|||||||
default:
|
default:
|
||||||
ASSERT (FALSE);
|
ASSERT (FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
Source += Step;
|
Source += Step;
|
||||||
Destination += Step;
|
Destination += Step;
|
||||||
}
|
}
|
||||||
@ -1461,16 +1482,17 @@ CompressData (
|
|||||||
} else {
|
} else {
|
||||||
CurrentChar = (UINT8)LastChar + 1; // just ensure it's different from LastChar
|
CurrentChar = (UINT8)LastChar + 1; // just ensure it's different from LastChar
|
||||||
}
|
}
|
||||||
|
|
||||||
if (LastChar != CurrentChar) {
|
if (LastChar != CurrentChar) {
|
||||||
if (LastCharCount == 1) {
|
if (LastCharCount == 1) {
|
||||||
CompressedIndex++;
|
CompressedIndex++;
|
||||||
if (CompressedCrc != NULL) {
|
if (CompressedCrc != NULL) {
|
||||||
*CompressedCrc = CalculateCrc16 (&LastChar, 1, *CompressedCrc);
|
*CompressedCrc = CalculateCrc16 (&LastChar, 1, *CompressedCrc);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Send) {
|
if (Send) {
|
||||||
DebugPortWriteBuffer (Handle, &LastChar, 1);
|
DebugPortWriteBuffer (Handle, &LastChar, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (LastCharCount >= 2) {
|
} else if (LastCharCount >= 2) {
|
||||||
CompressedIndex += 3;
|
CompressedIndex += 3;
|
||||||
LastCharCount -= 2;
|
LastCharCount -= 2;
|
||||||
@ -1479,14 +1501,17 @@ CompressData (
|
|||||||
*CompressedCrc = CalculateCrc16 (&LastChar, 1, *CompressedCrc);
|
*CompressedCrc = CalculateCrc16 (&LastChar, 1, *CompressedCrc);
|
||||||
*CompressedCrc = CalculateCrc16 (&LastCharCount, 1, *CompressedCrc);
|
*CompressedCrc = CalculateCrc16 (&LastCharCount, 1, *CompressedCrc);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Send) {
|
if (Send) {
|
||||||
DebugPortWriteBuffer (Handle, &LastChar, 1);
|
DebugPortWriteBuffer (Handle, &LastChar, 1);
|
||||||
DebugPortWriteBuffer (Handle, &LastChar, 1);
|
DebugPortWriteBuffer (Handle, &LastChar, 1);
|
||||||
DebugPortWriteBuffer (Handle, &LastCharCount, 1);
|
DebugPortWriteBuffer (Handle, &LastCharCount, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
LastCharCount = 0;
|
LastCharCount = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
LastCharCount++;
|
LastCharCount++;
|
||||||
LastChar = CurrentChar;
|
LastChar = CurrentChar;
|
||||||
}
|
}
|
||||||
@ -1545,6 +1570,7 @@ ReadMemoryAndSendResponsePacket (
|
|||||||
LastPacket = FALSE;
|
LastPacket = FALSE;
|
||||||
DebugHeader->Command = DEBUG_COMMAND_IN_PROGRESS;
|
DebugHeader->Command = DEBUG_COMMAND_IN_PROGRESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Construct the rest Debug header
|
// Construct the rest Debug header
|
||||||
//
|
//
|
||||||
@ -1573,6 +1599,7 @@ ReadMemoryAndSendResponsePacket (
|
|||||||
} else {
|
} else {
|
||||||
CompressedDataSize = CurrentDataSize;
|
CompressedDataSize = CurrentDataSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (CompressedDataSize < CurrentDataSize) {
|
if (CompressedDataSize < CurrentDataSize) {
|
||||||
DebugHeader->Length = (UINT8)CompressedDataSize + sizeof (DEBUG_PACKET_HEADER);
|
DebugHeader->Length = (UINT8)CompressedDataSize + sizeof (DEBUG_PACKET_HEADER);
|
||||||
DebugHeader->StartSymbol = DEBUG_STARTING_SYMBOL_COMPRESS;
|
DebugHeader->StartSymbol = DEBUG_STARTING_SYMBOL_COMPRESS;
|
||||||
@ -1604,7 +1631,6 @@ ReadMemoryAndSendResponsePacket (
|
|||||||
NULL
|
NULL
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
//
|
//
|
||||||
// Calculate and fill the checksum, DebugHeader->Crc should be 0 before invoking CalculateCrc16 ()
|
// 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");
|
DebugAgentMsgPrint (DEBUG_AGENT_WARNING, "TARGET: Timeout in SendDataResponsePacket()\n");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((DebugHeader->Command == DEBUG_COMMAND_OK) && (DebugHeader->SequenceNo == SequenceNo) && LastPacket) {
|
if ((DebugHeader->Command == DEBUG_COMMAND_OK) && (DebugHeader->SequenceNo == SequenceNo) && LastPacket) {
|
||||||
//
|
//
|
||||||
// If this is the last packet, return RETURN_SUCCESS.
|
// If this is the last packet, return RETURN_SUCCESS.
|
||||||
//
|
//
|
||||||
return RETURN_SUCCESS;
|
return RETURN_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((DebugHeader->Command == DEBUG_COMMAND_CONTINUE) && (DebugHeader->SequenceNo == (UINT8)(SequenceNo + 1))) {
|
if ((DebugHeader->Command == DEBUG_COMMAND_CONTINUE) && (DebugHeader->SequenceNo == (UINT8)(SequenceNo + 1))) {
|
||||||
//
|
//
|
||||||
// Calculate the rest data size
|
// Calculate the rest data size
|
||||||
@ -1636,6 +1664,7 @@ ReadMemoryAndSendResponsePacket (
|
|||||||
UpdateMailboxContent (GetMailboxPointer (), DEBUG_MAILBOX_HOST_SEQUENCE_NO_INDEX, DebugHeader->SequenceNo);
|
UpdateMailboxContent (GetMailboxPointer (), DEBUG_MAILBOX_HOST_SEQUENCE_NO_INDEX, DebugHeader->SequenceNo);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (DebugHeader->SequenceNo >= SequenceNo) {
|
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);
|
DebugAgentMsgPrint (DEBUG_AGENT_WARNING, "TARGET: Received one old or new command(SequenceNo is %x, last SequenceNo is %x)\n", SequenceNo, DebugHeader->SequenceNo);
|
||||||
break;
|
break;
|
||||||
@ -1703,6 +1732,7 @@ AttachHost (
|
|||||||
} else {
|
} else {
|
||||||
Status = SendCommandAndWaitForAckOK (DEBUG_COMMAND_ATTACH_BREAK, Timeout, BreakReceived, &IncompatibilityFlag);
|
Status = SendCommandAndWaitForAckOK (DEBUG_COMMAND_ATTACH_BREAK, Timeout, BreakReceived, &IncompatibilityFlag);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IncompatibilityFlag) {
|
if (IncompatibilityFlag) {
|
||||||
//
|
//
|
||||||
// If the incompatible Debug Packet received, the HOST should be running transfer protocol before PcdTransferProtocolRevision.
|
// If the incompatible Debug Packet received, the HOST should be running transfer protocol before PcdTransferProtocolRevision.
|
||||||
@ -1721,6 +1751,7 @@ AttachHost (
|
|||||||
//
|
//
|
||||||
SetHostAttached (TRUE);
|
SetHostAttached (TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1762,13 +1793,14 @@ SendBreakPacketToHost (
|
|||||||
do {
|
do {
|
||||||
DebugAgentReadBuffer (Handle, &InputCharacter, 1, 0);
|
DebugAgentReadBuffer (Handle, &InputCharacter, 1, 0);
|
||||||
} while (InputCharacter != DEBUG_STARTING_SYMBOL_ATTACH);
|
} while (InputCharacter != DEBUG_STARTING_SYMBOL_ATTACH);
|
||||||
|
|
||||||
SendAckPacket (DEBUG_COMMAND_OK);
|
SendAckPacket (DEBUG_COMMAND_OK);
|
||||||
|
|
||||||
//
|
//
|
||||||
// Try to attach HOST
|
// 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) {
|
while (TRUE) {
|
||||||
|
|
||||||
if (MultiProcessorDebugSupport ()) {
|
if (MultiProcessorDebugSupport ()) {
|
||||||
//
|
//
|
||||||
// Check if the current processor is HOST view point
|
// 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");
|
DebugAgentMsgPrint (DEBUG_AGENT_INFO, "TARGET: Try to get command from HOST...\n");
|
||||||
Status = ReceivePacket ((UINT8 *)DebugHeader, &BreakReceived, NULL, READ_PACKET_TIMEOUT, TRUE);
|
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[%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");
|
DebugAgentMsgPrint (DEBUG_AGENT_WARNING, "TARGET: Get command failed or it's response packet not expected! \n");
|
||||||
ReleaseMpSpinLock (&mDebugMpContext.DebugPortSpinLock);
|
ReleaseMpSpinLock (&mDebugMpContext.DebugPortSpinLock);
|
||||||
@ -1910,7 +1941,6 @@ CommandCommunication (
|
|||||||
DebugAgentMsgPrint (DEBUG_AGENT_INFO, "Processor[%x]:Received one command(%x)\n", mDebugMpContext.ViewPointIndex, DebugHeader->Command);
|
DebugAgentMsgPrint (DEBUG_AGENT_INFO, "Processor[%x]:Received one command(%x)\n", mDebugMpContext.ViewPointIndex, DebugHeader->Command);
|
||||||
|
|
||||||
switch (DebugHeader->Command) {
|
switch (DebugHeader->Command) {
|
||||||
|
|
||||||
case DEBUG_COMMAND_HALT:
|
case DEBUG_COMMAND_HALT:
|
||||||
SendAckPacket (DEBUG_COMMAND_HALT_DEFERRED);
|
SendAckPacket (DEBUG_COMMAND_HALT_DEFERRED);
|
||||||
HaltDeferred = TRUE;
|
HaltDeferred = TRUE;
|
||||||
@ -1943,7 +1973,7 @@ CommandCommunication (
|
|||||||
// If HOST changed Dr0 before GO, we will not change Dr0 here
|
// If HOST changed Dr0 before GO, we will not change Dr0 here
|
||||||
//
|
//
|
||||||
Data8 = GetBreakCause (Vector, CpuContext);
|
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;
|
CpuContext->Dr0 = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1992,6 +2022,7 @@ CommandCommunication (
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Set BSP to be current view point.
|
// Set BSP to be current view point.
|
||||||
//
|
//
|
||||||
@ -2015,8 +2046,8 @@ CommandCommunication (
|
|||||||
UpdateMailboxContent (Mailbox, DEBUG_MAILBOX_SEQUENCE_NO_INDEX, 0);
|
UpdateMailboxContent (Mailbox, DEBUG_MAILBOX_SEQUENCE_NO_INDEX, 0);
|
||||||
UpdateMailboxContent (Mailbox, DEBUG_MAILBOX_HOST_SEQUENCE_NO_INDEX, 0);
|
UpdateMailboxContent (Mailbox, DEBUG_MAILBOX_HOST_SEQUENCE_NO_INDEX, 0);
|
||||||
}
|
}
|
||||||
return;
|
|
||||||
|
|
||||||
|
return;
|
||||||
} else {
|
} else {
|
||||||
//
|
//
|
||||||
// If received HALT command, need to defer the GO command
|
// If received HALT command, need to defer the GO command
|
||||||
@ -2026,15 +2057,17 @@ CommandCommunication (
|
|||||||
|
|
||||||
Vector = DEBUG_TIMER_VECTOR;
|
Vector = DEBUG_TIMER_VECTOR;
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case DEBUG_COMMAND_BREAK_CAUSE:
|
case DEBUG_COMMAND_BREAK_CAUSE:
|
||||||
BreakCause.StopAddress = CpuContext->Eip;
|
BreakCause.StopAddress = CpuContext->Eip;
|
||||||
if (MultiProcessorDebugSupport() && ProcessorIndex != mDebugMpContext.BreakAtCpuIndex) {
|
if (MultiProcessorDebugSupport () && (ProcessorIndex != mDebugMpContext.BreakAtCpuIndex)) {
|
||||||
BreakCause.Cause = GetBreakCause (DEBUG_TIMER_VECTOR, CpuContext);
|
BreakCause.Cause = GetBreakCause (DEBUG_TIMER_VECTOR, CpuContext);
|
||||||
} else {
|
} else {
|
||||||
BreakCause.Cause = GetBreakCause (Vector, CpuContext);
|
BreakCause.Cause = GetBreakCause (Vector, CpuContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
SendDataResponsePacket ((UINT8 *)&BreakCause, (UINT16)sizeof (DEBUG_DATA_RESPONSE_BREAK_CAUSE), DebugHeader);
|
SendDataResponsePacket ((UINT8 *)&BreakCause, (UINT16)sizeof (DEBUG_DATA_RESPONSE_BREAK_CAUSE), DebugHeader);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -2055,7 +2088,7 @@ CommandCommunication (
|
|||||||
// If HOST changed Dr0 before GO, we will not change Dr0 here
|
// If HOST changed Dr0 before GO, we will not change Dr0 here
|
||||||
//
|
//
|
||||||
Data8 = GetBreakCause (Vector, CpuContext);
|
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;
|
CpuContext->Dr0 = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2088,6 +2121,7 @@ CommandCommunication (
|
|||||||
if (AlignedDataPtr != (UINT8 *)&MemoryWrite->Data) {
|
if (AlignedDataPtr != (UINT8 *)&MemoryWrite->Data) {
|
||||||
CopyMem (AlignedDataPtr, (UINT8 *)&MemoryWrite->Data, MemoryWrite->Count * MemoryWrite->Width);
|
CopyMem (AlignedDataPtr, (UINT8 *)&MemoryWrite->Data, MemoryWrite->Count * MemoryWrite->Width);
|
||||||
}
|
}
|
||||||
|
|
||||||
CopyMemByWidth ((UINT8 *)(UINTN)MemoryWrite->Address, AlignedDataPtr, MemoryWrite->Count, MemoryWrite->Width);
|
CopyMemByWidth ((UINT8 *)(UINTN)MemoryWrite->Address, AlignedDataPtr, MemoryWrite->Count, MemoryWrite->Width);
|
||||||
SendAckPacket (DEBUG_COMMAND_OK);
|
SendAckPacket (DEBUG_COMMAND_OK);
|
||||||
break;
|
break;
|
||||||
@ -2110,6 +2144,7 @@ CommandCommunication (
|
|||||||
default:
|
default:
|
||||||
Data64 = (UINT64)-1;
|
Data64 = (UINT64)-1;
|
||||||
}
|
}
|
||||||
|
|
||||||
Status = SendDataResponsePacket ((UINT8 *)&Data64, IoRead->Width, DebugHeader);
|
Status = SendDataResponsePacket ((UINT8 *)&Data64, IoRead->Width, DebugHeader);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -2131,6 +2166,7 @@ CommandCommunication (
|
|||||||
default:
|
default:
|
||||||
Data64 = (UINT64)-1;
|
Data64 = (UINT64)-1;
|
||||||
}
|
}
|
||||||
|
|
||||||
SendAckPacket (DEBUG_COMMAND_OK);
|
SendAckPacket (DEBUG_COMMAND_OK);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -2147,6 +2183,7 @@ CommandCommunication (
|
|||||||
} else {
|
} else {
|
||||||
Status = RETURN_UNSUPPORTED;
|
Status = RETURN_UNSUPPORTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case DEBUG_COMMAND_WRITE_REGISTER:
|
case DEBUG_COMMAND_WRITE_REGISTER:
|
||||||
@ -2159,6 +2196,7 @@ CommandCommunication (
|
|||||||
} else {
|
} else {
|
||||||
Status = RETURN_UNSUPPORTED;
|
Status = RETURN_UNSUPPORTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case DEBUG_COMMAND_ARCH_MODE:
|
case DEBUG_COMMAND_ARCH_MODE:
|
||||||
@ -2183,6 +2221,7 @@ CommandCommunication (
|
|||||||
if (Status == RETURN_SUCCESS) {
|
if (Status == RETURN_SUCCESS) {
|
||||||
SendAckPacket (DEBUG_COMMAND_OK);
|
SendAckPacket (DEBUG_COMMAND_OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case DEBUG_COMMAND_GET_REVISION:
|
case DEBUG_COMMAND_GET_REVISION:
|
||||||
@ -2211,7 +2250,6 @@ CommandCommunication (
|
|||||||
}
|
}
|
||||||
} else if (SetViewPoint->ViewPoint == 0) {
|
} else if (SetViewPoint->ViewPoint == 0) {
|
||||||
SendAckPacket (DEBUG_COMMAND_OK);
|
SendAckPacket (DEBUG_COMMAND_OK);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
SendAckPacket (DEBUG_COMMAND_NOT_SUPPORTED);
|
SendAckPacket (DEBUG_COMMAND_NOT_SUPPORTED);
|
||||||
}
|
}
|
||||||
@ -2236,9 +2274,12 @@ CommandCommunication (
|
|||||||
case DEBUG_COMMAND_CPUID:
|
case DEBUG_COMMAND_CPUID:
|
||||||
Cpuid = (DEBUG_DATA_CPUID *)(DebugHeader + 1);
|
Cpuid = (DEBUG_DATA_CPUID *)(DebugHeader + 1);
|
||||||
AsmCpuidEx (
|
AsmCpuidEx (
|
||||||
Cpuid->Eax, Cpuid->Ecx,
|
Cpuid->Eax,
|
||||||
&CpuidResponse.Eax, &CpuidResponse.Ebx,
|
Cpuid->Ecx,
|
||||||
&CpuidResponse.Ecx, &CpuidResponse.Edx
|
&CpuidResponse.Eax,
|
||||||
|
&CpuidResponse.Ebx,
|
||||||
|
&CpuidResponse.Ecx,
|
||||||
|
&CpuidResponse.Edx
|
||||||
);
|
);
|
||||||
SendDataResponsePacket ((UINT8 *)&CpuidResponse, (UINT16)sizeof (CpuidResponse), DebugHeader);
|
SendDataResponsePacket ((UINT8 *)&CpuidResponse, (UINT16)sizeof (CpuidResponse), DebugHeader);
|
||||||
break;
|
break;
|
||||||
@ -2247,17 +2288,20 @@ CommandCommunication (
|
|||||||
SearchSignature = (DEBUG_DATA_SEARCH_SIGNATURE *)(DebugHeader + 1);
|
SearchSignature = (DEBUG_DATA_SEARCH_SIGNATURE *)(DebugHeader + 1);
|
||||||
if ((SearchSignature->Alignment != 0) &&
|
if ((SearchSignature->Alignment != 0) &&
|
||||||
(SearchSignature->Alignment == GetPowerOfTwo32 (SearchSignature->Alignment))
|
(SearchSignature->Alignment == GetPowerOfTwo32 (SearchSignature->Alignment))
|
||||||
) {
|
)
|
||||||
|
{
|
||||||
if (SearchSignature->Positive) {
|
if (SearchSignature->Positive) {
|
||||||
for (
|
for (
|
||||||
Data64 = ALIGN_VALUE ((UINTN)SearchSignature->Start, SearchSignature->Alignment);
|
Data64 = ALIGN_VALUE ((UINTN)SearchSignature->Start, SearchSignature->Alignment);
|
||||||
Data64 <= SearchSignature->Start + SearchSignature->Count - SearchSignature->DataLength;
|
Data64 <= SearchSignature->Start + SearchSignature->Count - SearchSignature->DataLength;
|
||||||
Data64 += SearchSignature->Alignment
|
Data64 += SearchSignature->Alignment
|
||||||
) {
|
)
|
||||||
|
{
|
||||||
if (CompareMem ((VOID *)(UINTN)Data64, &SearchSignature->Data, SearchSignature->DataLength) == 0) {
|
if (CompareMem ((VOID *)(UINTN)Data64, &SearchSignature->Data, SearchSignature->DataLength) == 0) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Data64 > SearchSignature->Start + SearchSignature->Count - SearchSignature->DataLength) {
|
if (Data64 > SearchSignature->Start + SearchSignature->Count - SearchSignature->DataLength) {
|
||||||
Data64 = (UINT64)-1;
|
Data64 = (UINT64)-1;
|
||||||
}
|
}
|
||||||
@ -2266,19 +2310,23 @@ CommandCommunication (
|
|||||||
Data64 = ALIGN_VALUE ((UINTN)SearchSignature->Start - SearchSignature->Alignment, SearchSignature->Alignment);
|
Data64 = ALIGN_VALUE ((UINTN)SearchSignature->Start - SearchSignature->Alignment, SearchSignature->Alignment);
|
||||||
Data64 >= SearchSignature->Start - SearchSignature->Count;
|
Data64 >= SearchSignature->Start - SearchSignature->Count;
|
||||||
Data64 -= SearchSignature->Alignment
|
Data64 -= SearchSignature->Alignment
|
||||||
) {
|
)
|
||||||
|
{
|
||||||
if (CompareMem ((VOID *)(UINTN)Data64, &SearchSignature->Data, SearchSignature->DataLength) == 0) {
|
if (CompareMem ((VOID *)(UINTN)Data64, &SearchSignature->Data, SearchSignature->DataLength) == 0) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Data64 < SearchSignature->Start - SearchSignature->Count) {
|
if (Data64 < SearchSignature->Start - SearchSignature->Count) {
|
||||||
Data64 = (UINT64)-1;
|
Data64 = (UINT64)-1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SendDataResponsePacket ((UINT8 *)&Data64, (UINT16)sizeof (Data64), DebugHeader);
|
SendDataResponsePacket ((UINT8 *)&Data64, (UINT16)sizeof (Data64), DebugHeader);
|
||||||
} else {
|
} else {
|
||||||
Status = RETURN_UNSUPPORTED;
|
Status = RETURN_UNSUPPORTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
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
|
// Check if this exception is issued by Debug Agent itself
|
||||||
// If yes, fill the debug agent exception buffer and LongJump() back to
|
// If yes, fill the debug agent exception buffer and LongJump() back to
|
||||||
@ -2392,6 +2440,7 @@ InterruptProcess (
|
|||||||
//
|
//
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
CommandCommunication (Vector, CpuContext, BreakReceived);
|
CommandCommunication (Vector, CpuContext, BreakReceived);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -2402,6 +2451,7 @@ InterruptProcess (
|
|||||||
if (MultiProcessorDebugSupport ()) {
|
if (MultiProcessorDebugSupport ()) {
|
||||||
mDebugMpContext.BreakAtCpuIndex = ProcessorIndex;
|
mDebugMpContext.BreakAtCpuIndex = ProcessorIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Clear Stepping Flag and restore EFLAGS.IF
|
// Clear Stepping Flag and restore EFLAGS.IF
|
||||||
//
|
//
|
||||||
@ -2432,6 +2482,7 @@ InterruptProcess (
|
|||||||
//
|
//
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Continue to run the following common code
|
// Continue to run the following common code
|
||||||
//
|
//
|
||||||
@ -2449,6 +2500,7 @@ InterruptProcess (
|
|||||||
if (IsFirstBreakProcessor (ProcessorIndex)) {
|
if (IsFirstBreakProcessor (ProcessorIndex)) {
|
||||||
SendBreakPacketToHost (BreakCause, ProcessorIndex, &BreakReceived);
|
SendBreakPacketToHost (BreakCause, ProcessorIndex, &BreakReceived);
|
||||||
}
|
}
|
||||||
|
|
||||||
ReleaseMpSpinLock (&mDebugMpContext.DebugPortSpinLock);
|
ReleaseMpSpinLock (&mDebugMpContext.DebugPortSpinLock);
|
||||||
|
|
||||||
if (Vector == DEBUG_INT3_VECTOR) {
|
if (Vector == DEBUG_INT3_VECTOR) {
|
||||||
@ -2459,7 +2511,8 @@ InterruptProcess (
|
|||||||
SavedEip = CpuContext->Eip;
|
SavedEip = CpuContext->Eip;
|
||||||
CommandCommunication (Vector, CpuContext, BreakReceived);
|
CommandCommunication (Vector, CpuContext, BreakReceived);
|
||||||
if ((SavedEip == CpuContext->Eip) &&
|
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,
|
// If this is not a software breakpoint set by HOST,
|
||||||
// restore EIP
|
// restore EIP
|
||||||
@ -2469,6 +2522,7 @@ InterruptProcess (
|
|||||||
} else {
|
} else {
|
||||||
CommandCommunication (Vector, CpuContext, BreakReceived);
|
CommandCommunication (Vector, CpuContext, BreakReceived);
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2525,7 +2579,8 @@ InterruptProcess (
|
|||||||
if ((!IsHostAttached () && (InputCharacter == DEBUG_STARTING_SYMBOL_ATTACH)) ||
|
if ((!IsHostAttached () && (InputCharacter == DEBUG_STARTING_SYMBOL_ATTACH)) ||
|
||||||
(IsHostAttached () && (InputCharacter == DEBUG_COMMAND_HALT)) ||
|
(IsHostAttached () && (InputCharacter == DEBUG_COMMAND_HALT)) ||
|
||||||
(IsHostAttached () && (InputCharacter == DEBUG_COMMAND_GO))
|
(IsHostAttached () && (InputCharacter == DEBUG_COMMAND_GO))
|
||||||
) {
|
)
|
||||||
|
{
|
||||||
DebugAgentMsgPrint (DEBUG_AGENT_VERBOSE, "Received data [%02x]\n", InputCharacter);
|
DebugAgentMsgPrint (DEBUG_AGENT_VERBOSE, "Received data [%02x]\n", InputCharacter);
|
||||||
//
|
//
|
||||||
// Ack OK for break-in symbol
|
// Ack OK for break-in symbol
|
||||||
@ -2555,6 +2610,7 @@ InterruptProcess (
|
|||||||
HaltOtherProcessors (ProcessorIndex);
|
HaltOtherProcessors (ProcessorIndex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ReleaseMpSpinLock (&mDebugMpContext.DebugPortSpinLock);
|
ReleaseMpSpinLock (&mDebugMpContext.DebugPortSpinLock);
|
||||||
CommandCommunication (Vector, CpuContext, BreakReceived);
|
CommandCommunication (Vector, CpuContext, BreakReceived);
|
||||||
AcquireMpSpinLock (&mDebugMpContext.DebugPortSpinLock);
|
AcquireMpSpinLock (&mDebugMpContext.DebugPortSpinLock);
|
||||||
@ -2587,6 +2643,7 @@ InterruptProcess (
|
|||||||
if (MultiProcessorDebugSupport ()) {
|
if (MultiProcessorDebugSupport ()) {
|
||||||
mDebugMpContext.BreakAtCpuIndex = ProcessorIndex;
|
mDebugMpContext.BreakAtCpuIndex = ProcessorIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Clear Stepping flag and restore EFLAGS.IF
|
// Clear Stepping flag and restore EFLAGS.IF
|
||||||
//
|
//
|
||||||
@ -2603,11 +2660,13 @@ InterruptProcess (
|
|||||||
if (IsFirstBreakProcessor (ProcessorIndex)) {
|
if (IsFirstBreakProcessor (ProcessorIndex)) {
|
||||||
SendBreakPacketToHost (BreakCause, ProcessorIndex, &BreakReceived);
|
SendBreakPacketToHost (BreakCause, ProcessorIndex, &BreakReceived);
|
||||||
}
|
}
|
||||||
|
|
||||||
ReleaseMpSpinLock (&mDebugMpContext.DebugPortSpinLock);
|
ReleaseMpSpinLock (&mDebugMpContext.DebugPortSpinLock);
|
||||||
}
|
}
|
||||||
|
|
||||||
CommandCommunication (Vector, CpuContext, BreakReceived);
|
CommandCommunication (Vector, CpuContext, BreakReceived);
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
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
|
// If the command is not stepping, clean up AgentInProgress flag
|
||||||
//
|
//
|
||||||
|
@ -156,7 +156,6 @@ typedef union {
|
|||||||
UINT64 Uint64;
|
UINT64 Uint64;
|
||||||
} IA32_IDT_ENTRY;
|
} IA32_IDT_ENTRY;
|
||||||
|
|
||||||
|
|
||||||
typedef union {
|
typedef union {
|
||||||
struct {
|
struct {
|
||||||
UINT32 LimitLow : 16;
|
UINT32 LimitLow : 16;
|
||||||
@ -495,4 +494,3 @@ DebugAgentReadBuffer (
|
|||||||
);
|
);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -34,6 +34,7 @@ AcquireMpSpinLock (
|
|||||||
if (AcquireSpinLockOrFail (MpSpinLock)) {
|
if (AcquireSpinLockOrFail (MpSpinLock)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
CpuPause ();
|
CpuPause ();
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -70,7 +71,7 @@ HaltOtherProcessors (
|
|||||||
{
|
{
|
||||||
DebugAgentMsgPrint (DEBUG_AGENT_INFO, "processor[%x]:Try to halt other processors.\n", CurrentProcessorIndex);
|
DebugAgentMsgPrint (DEBUG_AGENT_INFO, "processor[%x]:Try to halt other processors.\n", CurrentProcessorIndex);
|
||||||
if (!DebugAgentIsBsp (CurrentProcessorIndex)) {
|
if (!DebugAgentIsBsp (CurrentProcessorIndex)) {
|
||||||
SetIpiSentByApFlag (TRUE);;
|
SetIpiSentByApFlag (TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
mDebugMpContext.BreakAtCpuIndex = CurrentProcessorIndex;
|
mDebugMpContext.BreakAtCpuIndex = CurrentProcessorIndex;
|
||||||
@ -84,7 +85,6 @@ HaltOtherProcessors (
|
|||||||
// Send fixed IPI to other processors.
|
// Send fixed IPI to other processors.
|
||||||
//
|
//
|
||||||
SendFixedIpiAllExcludingSelf (DEBUG_TIMER_VECTOR);
|
SendFixedIpiAllExcludingSelf (DEBUG_TIMER_VECTOR);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -153,6 +153,7 @@ DebugAgentIsBsp (
|
|||||||
mDebugMpContext.BspIndex = ProcessorIndex;
|
mDebugMpContext.BspIndex = ProcessorIndex;
|
||||||
ReleaseMpSpinLock (&mDebugMpContext.MpContextSpinLock);
|
ReleaseMpSpinLock (&mDebugMpContext.MpContextSpinLock);
|
||||||
}
|
}
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
} else {
|
} else {
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@ -185,6 +186,7 @@ SetCpuStopFlagByIndex (
|
|||||||
} else {
|
} else {
|
||||||
Value = BitFieldWrite8 (Value, Index, Index, 0);
|
Value = BitFieldWrite8 (Value, Index, Index, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
mDebugMpContext.CpuStopStatusMask[ProcessorIndex / 8] = Value;
|
mDebugMpContext.CpuStopStatusMask[ProcessorIndex / 8] = Value;
|
||||||
|
|
||||||
ReleaseMpSpinLock (&mDebugMpContext.MpContextSpinLock);
|
ReleaseMpSpinLock (&mDebugMpContext.MpContextSpinLock);
|
||||||
@ -216,6 +218,7 @@ SetCpuBreakFlagByIndex (
|
|||||||
} else {
|
} else {
|
||||||
Value = BitFieldWrite8 (Value, Index, Index, 0);
|
Value = BitFieldWrite8 (Value, Index, Index, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
mDebugMpContext.CpuBreakMask[ProcessorIndex / 8] = Value;
|
mDebugMpContext.CpuBreakMask[ProcessorIndex / 8] = Value;
|
||||||
|
|
||||||
ReleaseMpSpinLock (&mDebugMpContext.MpContextSpinLock);
|
ReleaseMpSpinLock (&mDebugMpContext.MpContextSpinLock);
|
||||||
@ -316,6 +319,7 @@ FindNextPendingBreakCpu (
|
|||||||
return (UINT32)LowBitSet32 (mDebugMpContext.CpuBreakMask[Index]) + Index * 8;
|
return (UINT32)LowBitSet32 (mDebugMpContext.CpuBreakMask[Index]) + Index * 8;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return (UINT32)-1;
|
return (UINT32)-1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -338,6 +342,7 @@ IsAllCpuRunning (
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -372,6 +377,6 @@ IsFirstBreakProcessor (
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -213,4 +213,3 @@ IsFirstBreakProcessor (
|
|||||||
);
|
);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -53,9 +53,11 @@ InitializeDebugTimer (
|
|||||||
DEBUG ((DEBUG_INFO, "Debug Timer: Frequency = %d\n", ApicTimerFrequency));
|
DEBUG ((DEBUG_INFO, "Debug Timer: Frequency = %d\n", ApicTimerFrequency));
|
||||||
DEBUG ((DEBUG_INFO, "Debug Timer: InitialCount = %d\n", InitialCount));
|
DEBUG ((DEBUG_INFO, "Debug Timer: InitialCount = %d\n", InitialCount));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (TimerFrequency != NULL) {
|
if (TimerFrequency != NULL) {
|
||||||
*TimerFrequency = ApicTimerFrequency;
|
*TimerFrequency = ApicTimerFrequency;
|
||||||
}
|
}
|
||||||
|
|
||||||
return InitialCount;
|
return InitialCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -88,6 +90,7 @@ SaveAndSetDebugTimerInterrupt (
|
|||||||
} else {
|
} else {
|
||||||
DisableApicTimerInterrupt ();
|
DisableApicTimerInterrupt ();
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Validate the Debug Timer interrupt state
|
// Validate the Debug Timer interrupt state
|
||||||
// This will make additional delay after Local Apic Timer interrupt state is changed.
|
// This will make additional delay after Local Apic Timer interrupt state is changed.
|
||||||
|
@ -42,4 +42,3 @@ IsDebugTimerTimeout (
|
|||||||
);
|
);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -40,6 +40,7 @@ InitializeDebugIdt (
|
|||||||
//
|
//
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
InterruptHandler = (UINTN)&Exception0Handle + Index * ExceptionStubHeaderSize;
|
InterruptHandler = (UINTN)&Exception0Handle + Index * ExceptionStubHeaderSize;
|
||||||
IdtEntry[Index].Bits.OffsetLow = (UINT16)(UINTN)InterruptHandler;
|
IdtEntry[Index].Bits.OffsetLow = (UINT16)(UINTN)InterruptHandler;
|
||||||
IdtEntry[Index].Bits.OffsetHigh = (UINT16)((UINTN)InterruptHandler >> 16);
|
IdtEntry[Index].Bits.OffsetHigh = (UINT16)((UINTN)InterruptHandler >> 16);
|
||||||
|
@ -40,6 +40,7 @@ InitializeDebugIdt (
|
|||||||
//
|
//
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
InterruptHandler = (UINTN)&Exception0Handle + Index * ExceptionStubHeaderSize;
|
InterruptHandler = (UINTN)&Exception0Handle + Index * ExceptionStubHeaderSize;
|
||||||
IdtEntry[Index].Bits.OffsetLow = (UINT16)(UINTN)InterruptHandler;
|
IdtEntry[Index].Bits.OffsetLow = (UINT16)(UINTN)InterruptHandler;
|
||||||
IdtEntry[Index].Bits.OffsetHigh = (UINT16)((UINTN)InterruptHandler >> 16);
|
IdtEntry[Index].Bits.OffsetHigh = (UINT16)((UINTN)InterruptHandler >> 16);
|
||||||
|
@ -59,14 +59,15 @@ InternalConstructorWorker (
|
|||||||
//
|
//
|
||||||
Status = EFI_SUCCESS;
|
Status = EFI_SUCCESS;
|
||||||
GuidHob = GetFirstGuidHob (&gEfiVectorHandoffInfoPpiGuid);
|
GuidHob = GetFirstGuidHob (&gEfiVectorHandoffInfoPpiGuid);
|
||||||
if (GuidHob != NULL && !mDxeCoreFlag) {
|
if ((GuidHob != NULL) && !mDxeCoreFlag) {
|
||||||
//
|
//
|
||||||
// Check if configuration table is installed or not if GUIDed HOB existed,
|
// Check if configuration table is installed or not if GUIDed HOB existed,
|
||||||
// only when Debug Agent is not linked by DXE Core
|
// only when Debug Agent is not linked by DXE Core
|
||||||
//
|
//
|
||||||
Status = EfiGetSystemConfigurationTable (&gEfiVectorHandoffTableGuid, (VOID **)&VectorHandoffInfo);
|
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
|
// Install configuration table for persisted vector handoff info if GUIDed HOB cannot be found or
|
||||||
// configuration table does not exist
|
// configuration table does not exist
|
||||||
@ -161,7 +162,7 @@ GetMailboxFromConfigurationTable (
|
|||||||
DEBUG_AGENT_MAILBOX *Mailbox;
|
DEBUG_AGENT_MAILBOX *Mailbox;
|
||||||
|
|
||||||
Status = EfiGetSystemConfigurationTable (&gEfiDebugAgentGuid, (VOID **)&Mailbox);
|
Status = EfiGetSystemConfigurationTable (&gEfiDebugAgentGuid, (VOID **)&Mailbox);
|
||||||
if (Status == EFI_SUCCESS && Mailbox != NULL) {
|
if ((Status == EFI_SUCCESS) && (Mailbox != NULL)) {
|
||||||
VerifyMailboxChecksum (Mailbox);
|
VerifyMailboxChecksum (Mailbox);
|
||||||
return Mailbox;
|
return Mailbox;
|
||||||
} else {
|
} else {
|
||||||
@ -190,6 +191,7 @@ GetMailboxFromHob (
|
|||||||
if (GuidHob == NULL) {
|
if (GuidHob == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
MailboxLocation = (UINT64 *)(GET_GUID_HOB_DATA (GuidHob));
|
MailboxLocation = (UINT64 *)(GET_GUID_HOB_DATA (GuidHob));
|
||||||
Mailbox = (DEBUG_AGENT_MAILBOX *)(UINTN)(*MailboxLocation);
|
Mailbox = (DEBUG_AGENT_MAILBOX *)(UINTN)(*MailboxLocation);
|
||||||
VerifyMailboxChecksum (Mailbox);
|
VerifyMailboxChecksum (Mailbox);
|
||||||
@ -294,6 +296,7 @@ SetupDebugAgentEnvironment (
|
|||||||
} else {
|
} else {
|
||||||
ZeroMem (&mMailbox, sizeof (DEBUG_AGENT_MAILBOX));
|
ZeroMem (&mMailbox, sizeof (DEBUG_AGENT_MAILBOX));
|
||||||
}
|
}
|
||||||
|
|
||||||
mMailboxPointer = &mMailbox;
|
mMailboxPointer = &mMailbox;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -326,7 +329,6 @@ SetupDebugAgentEnvironment (
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Initialize debug agent.
|
Initialize debug agent.
|
||||||
|
|
||||||
@ -369,9 +371,10 @@ InitializeDebugAgent (
|
|||||||
InitializeLocalApicSoftwareEnable (TRUE);
|
InitializeLocalApicSoftwareEnable (TRUE);
|
||||||
GetApicTimerState (NULL, &PeriodicMode, NULL);
|
GetApicTimerState (NULL, &PeriodicMode, NULL);
|
||||||
TimerCycle = GetApicTimerInitCount ();
|
TimerCycle = GetApicTimerInitCount ();
|
||||||
if (!PeriodicMode || TimerCycle == 0) {
|
if (!PeriodicMode || (TimerCycle == 0)) {
|
||||||
InitializeDebugTimer (NULL, FALSE);
|
InitializeDebugTimer (NULL, FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Invoked by AP, enable interrupt to let AP could receive IPI from other processors
|
// Invoked by AP, enable interrupt to let AP could receive IPI from other processors
|
||||||
//
|
//
|
||||||
@ -396,7 +399,6 @@ InitializeDebugAgent (
|
|||||||
MailboxLocation = NULL;
|
MailboxLocation = NULL;
|
||||||
|
|
||||||
switch (InitFlag) {
|
switch (InitFlag) {
|
||||||
|
|
||||||
case DEBUG_AGENT_INIT_DXE_LOAD:
|
case DEBUG_AGENT_INIT_DXE_LOAD:
|
||||||
//
|
//
|
||||||
// Check if Debug Agent has been initialized before
|
// Check if Debug Agent has been initialized before
|
||||||
@ -423,6 +425,7 @@ InitializeDebugAgent (
|
|||||||
HobList = GetHobList ();
|
HobList = GetHobList ();
|
||||||
Mailbox = GetMailboxFromHob (HobList);
|
Mailbox = GetMailboxFromHob (HobList);
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Set up Debug Agent Environment and try to connect HOST if required
|
// Set up Debug Agent Environment and try to connect HOST if required
|
||||||
//
|
//
|
||||||
@ -511,6 +514,7 @@ InitializeDebugAgent (
|
|||||||
Mailbox = (DEBUG_AGENT_MAILBOX *)(UINTN)(*MailboxLocation);
|
Mailbox = (DEBUG_AGENT_MAILBOX *)(UINTN)(*MailboxLocation);
|
||||||
VerifyMailboxChecksum (Mailbox);
|
VerifyMailboxChecksum (Mailbox);
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Save Mailbox pointer in global variable
|
// Save Mailbox pointer in global variable
|
||||||
//
|
//
|
||||||
@ -530,6 +534,7 @@ InitializeDebugAgent (
|
|||||||
//
|
//
|
||||||
CpuBreakpoint ();
|
CpuBreakpoint ();
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
@ -235,8 +235,12 @@ typedef struct {
|
|||||||
//
|
//
|
||||||
EFI_HANDLE mSerialIoHandle = NULL;
|
EFI_HANDLE mSerialIoHandle = NULL;
|
||||||
UINTN mLoopbackBuffer = 0;
|
UINTN mLoopbackBuffer = 0;
|
||||||
DEBUG_SERIAL_FIFO mSerialFifoForTerminal = {0, 0, DEBGU_SERIAL_IO_FIFO_DEPTH, { 0 }};
|
DEBUG_SERIAL_FIFO mSerialFifoForTerminal = {
|
||||||
DEBUG_SERIAL_FIFO mSerialFifoForDebug = {0, 0, DEBGU_SERIAL_IO_FIFO_DEPTH, { 0 }};
|
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.
|
Detect whether specific FIFO is empty or not.
|
||||||
@ -302,6 +306,7 @@ DebugTerminalFifoAdd (
|
|||||||
if (IsDebugTerminalFifoFull (Fifo)) {
|
if (IsDebugTerminalFifoFull (Fifo)) {
|
||||||
return EFI_OUT_OF_RESOURCES;
|
return EFI_OUT_OF_RESOURCES;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// FIFO is not full can add data
|
// FIFO is not full can add data
|
||||||
//
|
//
|
||||||
@ -337,6 +342,7 @@ DebugTerminalFifoRemove (
|
|||||||
if (IsDebugTermianlFifoEmpty (Fifo)) {
|
if (IsDebugTermianlFifoEmpty (Fifo)) {
|
||||||
return EFI_OUT_OF_RESOURCES;
|
return EFI_OUT_OF_RESOURCES;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// FIFO is not empty, can remove data
|
// FIFO is not empty, can remove data
|
||||||
//
|
//
|
||||||
@ -363,8 +369,10 @@ InstallSerialIo (
|
|||||||
|
|
||||||
Status = gBS->InstallMultipleProtocolInterfaces (
|
Status = gBS->InstallMultipleProtocolInterfaces (
|
||||||
&mSerialIoHandle,
|
&mSerialIoHandle,
|
||||||
&gEfiDevicePathProtocolGuid, &mSerialIoDevicePath,
|
&gEfiDevicePathProtocolGuid,
|
||||||
&gEfiSerialIoProtocolGuid, &mSerialIo,
|
&mSerialIoDevicePath,
|
||||||
|
&gEfiSerialIoProtocolGuid,
|
||||||
|
&mSerialIo,
|
||||||
NULL
|
NULL
|
||||||
);
|
);
|
||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
@ -445,7 +453,7 @@ SerialSetAttributes (
|
|||||||
// SERIAL_PORT_DEFAULT_RECEIVE_FIFO_DEPTH. The Debug Communication Library may actually be
|
// SERIAL_PORT_DEFAULT_RECEIVE_FIFO_DEPTH. The Debug Communication Library may actually be
|
||||||
// using a larger FIFO, but there is no way to tell.
|
// 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;
|
mSerialIoMode.ReceiveFifoDepth = SERIAL_PORT_DEFAULT_RECEIVE_FIFO_DEPTH;
|
||||||
} else {
|
} else {
|
||||||
return EFI_INVALID_PARAMETER;
|
return EFI_INVALID_PARAMETER;
|
||||||
@ -478,6 +486,7 @@ SerialSetControl (
|
|||||||
if ((Control & (~EFI_SERIAL_SOFTWARE_LOOPBACK_ENABLE)) != 0) {
|
if ((Control & (~EFI_SERIAL_SOFTWARE_LOOPBACK_ENABLE)) != 0) {
|
||||||
return EFI_UNSUPPORTED;
|
return EFI_UNSUPPORTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
mSerialIoMode.ControlMask = Control;
|
mSerialIoMode.ControlMask = Control;
|
||||||
return EFI_SUCCESS;
|
return EFI_SUCCESS;
|
||||||
}
|
}
|
||||||
@ -580,10 +589,12 @@ SerialWrite (
|
|||||||
if (*BufferSize == 0) {
|
if (*BufferSize == 0) {
|
||||||
return EFI_SUCCESS;
|
return EFI_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((mLoopbackBuffer & SERIAL_PORT_LOOPBACK_BUFFER_FULL) != 0) {
|
if ((mLoopbackBuffer & SERIAL_PORT_LOOPBACK_BUFFER_FULL) != 0) {
|
||||||
*BufferSize = 0;
|
*BufferSize = 0;
|
||||||
return EFI_TIMEOUT;
|
return EFI_TIMEOUT;
|
||||||
}
|
}
|
||||||
|
|
||||||
mLoopbackBuffer = SERIAL_PORT_LOOPBACK_BUFFER_FULL | *(UINT8 *)Buffer;
|
mLoopbackBuffer = SERIAL_PORT_LOOPBACK_BUFFER_FULL | *(UINT8 *)Buffer;
|
||||||
*BufferSize = 1;
|
*BufferSize = 1;
|
||||||
} else {
|
} else {
|
||||||
@ -650,6 +661,7 @@ SerialRead (
|
|||||||
if ((mLoopbackBuffer & SERIAL_PORT_LOOPBACK_BUFFER_FULL) == 0) {
|
if ((mLoopbackBuffer & SERIAL_PORT_LOOPBACK_BUFFER_FULL) == 0) {
|
||||||
return EFI_TIMEOUT;
|
return EFI_TIMEOUT;
|
||||||
}
|
}
|
||||||
|
|
||||||
*Uint8Buffer = (UINT8)(mLoopbackBuffer & 0xff);
|
*Uint8Buffer = (UINT8)(mLoopbackBuffer & 0xff);
|
||||||
mLoopbackBuffer = 0;
|
mLoopbackBuffer = 0;
|
||||||
*BufferSize = 1;
|
*BufferSize = 1;
|
||||||
@ -664,12 +676,14 @@ SerialRead (
|
|||||||
Uint8Buffer++;
|
Uint8Buffer++;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Read the input character from Debug Port
|
// Read the input character from Debug Port
|
||||||
//
|
//
|
||||||
if (!DebugPortPollBuffer (Handle)) {
|
if (!DebugPortPollBuffer (Handle)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
DebugAgentReadBuffer (Handle, Data8, 1, 0);
|
DebugAgentReadBuffer (Handle, Data8, 1, 0);
|
||||||
|
|
||||||
if (*Data8 == DEBUG_STARTING_SYMBOL_ATTACH) {
|
if (*Data8 == DEBUG_STARTING_SYMBOL_ATTACH) {
|
||||||
@ -684,6 +698,7 @@ SerialRead (
|
|||||||
DebugAgentMsgPrint (DEBUG_AGENT_INFO, "Terminal Timer break symbol received %x", DebugHeader.Command);
|
DebugAgentMsgPrint (DEBUG_AGENT_INFO, "Terminal Timer break symbol received %x", DebugHeader.Command);
|
||||||
DebugTerminalFifoAdd (&mSerialFifoForDebug, DebugHeader.Command);
|
DebugTerminalFifoAdd (&mSerialFifoForDebug, DebugHeader.Command);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Status == EFI_TIMEOUT) {
|
if (Status == EFI_TIMEOUT) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -692,6 +707,7 @@ SerialRead (
|
|||||||
Uint8Buffer++;
|
Uint8Buffer++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
*BufferSize = (UINTN)Uint8Buffer - (UINTN)Buffer;
|
*BufferSize = (UINTN)Uint8Buffer - (UINTN)Buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -743,6 +759,7 @@ DebugReadBreakFromDebugPort (
|
|||||||
//
|
//
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Try to read the start symbol
|
// Try to read the start symbol
|
||||||
//
|
//
|
||||||
@ -752,6 +769,7 @@ DebugReadBreakFromDebugPort (
|
|||||||
*BreakSymbol = *Data8;
|
*BreakSymbol = *Data8;
|
||||||
return EFI_SUCCESS;
|
return EFI_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (*Data8 == DEBUG_STARTING_SYMBOL_NORMAL) {
|
if (*Data8 == DEBUG_STARTING_SYMBOL_NORMAL) {
|
||||||
Status = ReadRemainingBreakPacket (Handle, &DebugHeader);
|
Status = ReadRemainingBreakPacket (Handle, &DebugHeader);
|
||||||
if (Status == EFI_SUCCESS) {
|
if (Status == EFI_SUCCESS) {
|
||||||
@ -759,6 +777,7 @@ DebugReadBreakFromDebugPort (
|
|||||||
*BreakSymbol = DebugHeader.Command;
|
*BreakSymbol = DebugHeader.Command;
|
||||||
return EFI_SUCCESS;
|
return EFI_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Status == EFI_TIMEOUT) {
|
if (Status == EFI_TIMEOUT) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,6 @@
|
|||||||
|
|
||||||
GLOBAL_REMOVE_IF_UNREFERENCED BOOLEAN mSkipBreakpoint = FALSE;
|
GLOBAL_REMOVE_IF_UNREFERENCED BOOLEAN mSkipBreakpoint = FALSE;
|
||||||
|
|
||||||
|
|
||||||
GLOBAL_REMOVE_IF_UNREFERENCED EFI_PEI_VECTOR_HANDOFF_INFO_PPI mVectorHandoffInfoPpi = {
|
GLOBAL_REMOVE_IF_UNREFERENCED EFI_PEI_VECTOR_HANDOFF_INFO_PPI mVectorHandoffInfoPpi = {
|
||||||
&mVectorHandoffInfoDebugAgent[0]
|
&mVectorHandoffInfoDebugAgent[0]
|
||||||
};
|
};
|
||||||
@ -84,6 +83,7 @@ DebugReadBreakSymbol (
|
|||||||
//
|
//
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Try to read the start symbol
|
// Try to read the start symbol
|
||||||
//
|
//
|
||||||
@ -93,6 +93,7 @@ DebugReadBreakSymbol (
|
|||||||
DebugAgentMsgPrint (DEBUG_AGENT_INFO, "Debug Timer attach symbol received %x", *BreakSymbol);
|
DebugAgentMsgPrint (DEBUG_AGENT_INFO, "Debug Timer attach symbol received %x", *BreakSymbol);
|
||||||
return EFI_SUCCESS;
|
return EFI_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (*Data8 == DEBUG_STARTING_SYMBOL_NORMAL) {
|
if (*Data8 == DEBUG_STARTING_SYMBOL_NORMAL) {
|
||||||
Status = ReadRemainingBreakPacket (Handle, &DebugHeader);
|
Status = ReadRemainingBreakPacket (Handle, &DebugHeader);
|
||||||
if (Status == EFI_SUCCESS) {
|
if (Status == EFI_SUCCESS) {
|
||||||
@ -100,6 +101,7 @@ DebugReadBreakSymbol (
|
|||||||
DebugAgentMsgPrint (DEBUG_AGENT_INFO, "Debug Timer break symbol received %x", *BreakSymbol);
|
DebugAgentMsgPrint (DEBUG_AGENT_INFO, "Debug Timer break symbol received %x", *BreakSymbol);
|
||||||
return EFI_SUCCESS;
|
return EFI_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Status == EFI_TIMEOUT) {
|
if (Status == EFI_TIMEOUT) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -159,6 +161,7 @@ GetMailboxLocationFromHob (
|
|||||||
if (GuidHob == NULL) {
|
if (GuidHob == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (UINT64 *)(GET_GUID_HOB_DATA (GuidHob));
|
return (UINT64 *)(GET_GUID_HOB_DATA (GuidHob));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -186,8 +189,9 @@ GetMailboxPointer (
|
|||||||
//
|
//
|
||||||
// Cannot used GetDebugFlag() to get Debug Flag to avoid GetMailboxPointer() nested
|
// Cannot used GetDebugFlag() to get Debug Flag to avoid GetMailboxPointer() nested
|
||||||
//
|
//
|
||||||
if (Mailbox->DebugFlag.Bits.CheckMailboxInHob != 1 ||
|
if ((Mailbox->DebugFlag.Bits.CheckMailboxInHob != 1) ||
|
||||||
Mailbox->DebugFlag.Bits.InitArch != DEBUG_ARCH_SYMBOL) {
|
(Mailbox->DebugFlag.Bits.InitArch != DEBUG_ARCH_SYMBOL))
|
||||||
|
{
|
||||||
//
|
//
|
||||||
// If mailbox was setup in SEC or the current CPU arch is different from the init arch
|
// 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.
|
// Debug Agent initialized, return the mailbox from IDT entry directly.
|
||||||
@ -201,7 +205,7 @@ GetMailboxPointer (
|
|||||||
// Compare mailbox in IDT entry with mailbox in HOB,
|
// Compare mailbox in IDT entry with mailbox in HOB,
|
||||||
// need to fix mailbox location if HOB moved by PEI CORE
|
// 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);
|
Mailbox = (DEBUG_AGENT_MAILBOX *)(UINTN)(*MailboxLocationInHob);
|
||||||
//
|
//
|
||||||
// Fix up Debug Port handler and save new mailbox in IDT entry
|
// Fix up Debug Port handler and save new mailbox in IDT entry
|
||||||
@ -378,7 +382,6 @@ InitializeDebugAgent (
|
|||||||
CpuInterruptState = SaveAndDisableInterrupts ();
|
CpuInterruptState = SaveAndDisableInterrupts ();
|
||||||
|
|
||||||
switch (InitFlag) {
|
switch (InitFlag) {
|
||||||
|
|
||||||
case DEBUG_AGENT_INIT_PREMEM_SEC:
|
case DEBUG_AGENT_INIT_PREMEM_SEC:
|
||||||
|
|
||||||
InitializeDebugIdt ();
|
InitializeDebugIdt ();
|
||||||
@ -427,6 +430,7 @@ InitializeDebugAgent (
|
|||||||
//
|
//
|
||||||
TriggerSoftInterrupt (MEMORY_READY_SIGNATURE);
|
TriggerSoftInterrupt (MEMORY_READY_SIGNATURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Install Vector Handoff Info PPI to persist vectors used by Debug Agent
|
// 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"));
|
DEBUG ((DEBUG_ERROR, "DebugAgent: Failed to install Vector Handoff Info PPI!\n"));
|
||||||
CpuDeadLoop ();
|
CpuDeadLoop ();
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Fix up Debug Port handle address and mailbox address
|
// Fix up Debug Port handle address and mailbox address
|
||||||
//
|
//
|
||||||
@ -467,6 +472,7 @@ InitializeDebugAgent (
|
|||||||
DEBUG ((DEBUG_ERROR, "DebugAgent: Failed to allocate pages!\n"));
|
DEBUG ((DEBUG_ERROR, "DebugAgent: Failed to allocate pages!\n"));
|
||||||
CpuDeadLoop ();
|
CpuDeadLoop ();
|
||||||
}
|
}
|
||||||
|
|
||||||
NewMailbox = (DEBUG_AGENT_MAILBOX *)(UINTN)Address;
|
NewMailbox = (DEBUG_AGENT_MAILBOX *)(UINTN)Address;
|
||||||
//
|
//
|
||||||
// Copy Mailbox and Debug Port Handle buffer to new location in ACPI NVS memory, because original Mailbox
|
// Copy Mailbox and Debug Port Handle buffer to new location in ACPI NVS memory, because original Mailbox
|
||||||
@ -486,6 +492,7 @@ InitializeDebugAgent (
|
|||||||
sizeof (UINT64)
|
sizeof (UINT64)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Update IDT entry to save the location saved mailbox pointer
|
// 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"));
|
DEBUG ((DEBUG_ERROR, "DebugAgent: Input parameter Context cannot be NULL!\n"));
|
||||||
CpuDeadLoop ();
|
CpuDeadLoop ();
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Check if Debug Agent has initialized before
|
// 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"));
|
DEBUG ((DEBUG_WARN, "Debug Agent: It has already initialized in SEC Core!\n"));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Install Vector Handoff Info PPI to persist vectors used by Debug Agent
|
// 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"));
|
DEBUG ((DEBUG_ERROR, "DebugAgent: Failed to install Vector Handoff Info PPI!\n"));
|
||||||
CpuDeadLoop ();
|
CpuDeadLoop ();
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Set up IDT entries
|
// Set up IDT entries
|
||||||
//
|
//
|
||||||
@ -540,6 +550,7 @@ InitializeDebugAgent (
|
|||||||
//
|
//
|
||||||
SetLocationSavedMailboxPointerInIdtEntry (MailboxLocationPointer);
|
SetLocationSavedMailboxPointerInIdtEntry (MailboxLocationPointer);
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Save init arch type when debug agent initialized
|
// 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"));
|
DEBUG ((DEBUG_ERROR, "DebugAgent: Failed to register memory discovered callback function!\n"));
|
||||||
CpuDeadLoop ();
|
CpuDeadLoop ();
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Set HOB check flag if memory has not been ready yet
|
// Set HOB check flag if memory has not been ready yet
|
||||||
//
|
//
|
||||||
@ -597,6 +609,7 @@ InitializeDebugAgent (
|
|||||||
|
|
||||||
FindAndReportModuleImageInfo (4);
|
FindAndReportModuleImageInfo (4);
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@ -625,16 +638,18 @@ InitializeDebugAgent (
|
|||||||
//
|
//
|
||||||
EnableInterrupts ();
|
EnableInterrupts ();
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// If Function is not NULL, invoke it always whatever debug agent was initialized successfully or not.
|
// If Function is not NULL, invoke it always whatever debug agent was initialized successfully or not.
|
||||||
//
|
//
|
||||||
if (Function != NULL) {
|
if (Function != NULL) {
|
||||||
Function (Context);
|
Function (Context);
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Set return status for DEBUG_AGENT_INIT_PEI
|
// 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;
|
*(EFI_STATUS *)Context = EFI_SUCCESS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -666,11 +681,12 @@ InitializeDebugAgentPhase2 (
|
|||||||
MailboxLocation = GetLocationSavedMailboxPointerInIdtEntry ();
|
MailboxLocation = GetLocationSavedMailboxPointerInIdtEntry ();
|
||||||
Mailbox = (DEBUG_AGENT_MAILBOX *)(UINTN)(*MailboxLocation);
|
Mailbox = (DEBUG_AGENT_MAILBOX *)(UINTN)(*MailboxLocation);
|
||||||
BufferSize = PcdGet16 (PcdDebugPortHandleBufferSize);
|
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);
|
NewDebugPortHandle = (UINT64)(UINTN)AllocateCopyPool (BufferSize, DebugPortHandle);
|
||||||
} else {
|
} else {
|
||||||
NewDebugPortHandle = (UINT64)(UINTN)DebugPortHandle;
|
NewDebugPortHandle = (UINT64)(UINTN)DebugPortHandle;
|
||||||
}
|
}
|
||||||
|
|
||||||
UpdateMailboxContent (Mailbox, DEBUG_MAILBOX_DEBUG_PORT_HANDLE_INDEX, NewDebugPortHandle);
|
UpdateMailboxContent (Mailbox, DEBUG_MAILBOX_DEBUG_PORT_HANDLE_INDEX, NewDebugPortHandle);
|
||||||
|
|
||||||
//
|
//
|
||||||
@ -684,10 +700,11 @@ InitializeDebugAgentPhase2 (
|
|||||||
// host to disable low memory filtering.
|
// host to disable low memory filtering.
|
||||||
//
|
//
|
||||||
SecCoreData = (EFI_SEC_PEI_HAND_OFF *)Phase2Context->Context;
|
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);
|
SetDebugFlag (DEBUG_AGENT_FLAG_MEMORY_READY, 1);
|
||||||
TriggerSoftInterrupt (MEMORY_READY_SIGNATURE);
|
TriggerSoftInterrupt (MEMORY_READY_SIGNATURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Enable Debug Timer interrupt
|
// Enable Debug Timer interrupt
|
||||||
//
|
//
|
||||||
|
@ -56,4 +56,3 @@ DebugAgentCallbackMemoryDiscoveredPpi (
|
|||||||
);
|
);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -78,6 +78,7 @@ GetMailboxFromHob (
|
|||||||
if (GuidHob == NULL) {
|
if (GuidHob == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
MailboxLocation = (UINT64 *)(GET_GUID_HOB_DATA (GuidHob));
|
MailboxLocation = (UINT64 *)(GET_GUID_HOB_DATA (GuidHob));
|
||||||
Mailbox = (DEBUG_AGENT_MAILBOX *)(UINTN)(*MailboxLocation);
|
Mailbox = (DEBUG_AGENT_MAILBOX *)(UINTN)(*MailboxLocation);
|
||||||
VerifyMailboxChecksum (Mailbox);
|
VerifyMailboxChecksum (Mailbox);
|
||||||
@ -206,15 +207,17 @@ InitializeDebugAgent (
|
|||||||
DEBUG ((DEBUG_ERROR, "DebugAgent: Cannot install configuration table for persisted vector handoff info!\n"));
|
DEBUG ((DEBUG_ERROR, "DebugAgent: Cannot install configuration table for persisted vector handoff info!\n"));
|
||||||
CpuDeadLoop ();
|
CpuDeadLoop ();
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Check if Debug Agent initialized in DXE phase
|
// Check if Debug Agent initialized in DXE phase
|
||||||
//
|
//
|
||||||
Status = EfiGetSystemConfigurationTable (&gEfiDebugAgentGuid, (VOID **)&Mailbox);
|
Status = EfiGetSystemConfigurationTable (&gEfiDebugAgentGuid, (VOID **)&Mailbox);
|
||||||
if (Status == EFI_SUCCESS && Mailbox != NULL) {
|
if ((Status == EFI_SUCCESS) && (Mailbox != NULL)) {
|
||||||
VerifyMailboxChecksum (Mailbox);
|
VerifyMailboxChecksum (Mailbox);
|
||||||
mMailboxPointer = Mailbox;
|
mMailboxPointer = Mailbox;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Check if Debug Agent initialized in SEC/PEI phase
|
// Check if Debug Agent initialized in SEC/PEI phase
|
||||||
//
|
//
|
||||||
@ -223,6 +226,7 @@ InitializeDebugAgent (
|
|||||||
mMailboxPointer = Mailbox;
|
mMailboxPointer = Mailbox;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Debug Agent was not initialized before, use the local mailbox.
|
// Debug Agent was not initialized before, use the local mailbox.
|
||||||
//
|
//
|
||||||
@ -261,6 +265,7 @@ InitializeDebugAgent (
|
|||||||
//
|
//
|
||||||
TriggerSoftInterrupt (MEMORY_READY_SIGNATURE);
|
TriggerSoftInterrupt (MEMORY_READY_SIGNATURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Find and report PE/COFF image info to HOST
|
// Find and report PE/COFF image info to HOST
|
||||||
//
|
//
|
||||||
@ -282,16 +287,18 @@ InitializeDebugAgent (
|
|||||||
InitializeDebugIdt ();
|
InitializeDebugIdt ();
|
||||||
mSmmDebugIdtInitFlag = TRUE;
|
mSmmDebugIdtInitFlag = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Check if CPU APIC Timer is working, otherwise initialize it.
|
// Check if CPU APIC Timer is working, otherwise initialize it.
|
||||||
//
|
//
|
||||||
InitializeLocalApicSoftwareEnable (TRUE);
|
InitializeLocalApicSoftwareEnable (TRUE);
|
||||||
GetApicTimerState (&mApicTimerDivisor, &mPeriodicMode, &mVector);
|
GetApicTimerState (&mApicTimerDivisor, &mPeriodicMode, &mVector);
|
||||||
mTimerCycle = GetApicTimerInitCount ();
|
mTimerCycle = GetApicTimerInitCount ();
|
||||||
if (!mPeriodicMode || mTimerCycle == 0) {
|
if (!mPeriodicMode || (mTimerCycle == 0)) {
|
||||||
mApicTimerRestore = TRUE;
|
mApicTimerRestore = TRUE;
|
||||||
InitializeDebugTimer (NULL, FALSE);
|
InitializeDebugTimer (NULL, FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
Mailbox = GetMailboxPointer ();
|
Mailbox = GetMailboxPointer ();
|
||||||
if (GetDebugFlag (DEBUG_AGENT_FLAG_AGENT_IN_PROGRESS) == 1) {
|
if (GetDebugFlag (DEBUG_AGENT_FLAG_AGENT_IN_PROGRESS) == 1) {
|
||||||
//
|
//
|
||||||
@ -300,12 +307,14 @@ InitializeDebugAgent (
|
|||||||
//
|
//
|
||||||
mSkipBreakpoint = TRUE;
|
mSkipBreakpoint = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (GetDebugFlag (DEBUG_AGENT_FLAG_BREAK_ON_NEXT_SMI) == 1) {
|
if (GetDebugFlag (DEBUG_AGENT_FLAG_BREAK_ON_NEXT_SMI) == 1) {
|
||||||
if (mSkipBreakpoint) {
|
if (mSkipBreakpoint) {
|
||||||
//
|
//
|
||||||
// Print warning message if ignore smm entry break
|
// Print warning message if ignore smm entry break
|
||||||
//
|
//
|
||||||
DebugPortWriteBuffer ((DEBUG_PORT_HANDLE) (UINTN)Mailbox->DebugPortHandle,
|
DebugPortWriteBuffer (
|
||||||
|
(DEBUG_PORT_HANDLE)(UINTN)Mailbox->DebugPortHandle,
|
||||||
(UINT8 *)mWarningMsgIgnoreSmmEntryBreak,
|
(UINT8 *)mWarningMsgIgnoreSmmEntryBreak,
|
||||||
AsciiStrLen (mWarningMsgIgnoreSmmEntryBreak)
|
AsciiStrLen (mWarningMsgIgnoreSmmEntryBreak)
|
||||||
);
|
);
|
||||||
@ -316,6 +325,7 @@ InitializeDebugAgent (
|
|||||||
CpuBreakpoint ();
|
CpuBreakpoint ();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case DEBUG_AGENT_INIT_EXIT_SMI:
|
case DEBUG_AGENT_INIT_EXIT_SMI:
|
||||||
@ -332,6 +342,7 @@ InitializeDebugAgent (
|
|||||||
InitializeApicTimer (mApicTimerDivisor, mTimerCycle, mPeriodicMode, mVector);
|
InitializeApicTimer (mApicTimerDivisor, mTimerCycle, mPeriodicMode, mVector);
|
||||||
mApicTimerRestore = FALSE;
|
mApicTimerRestore = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case DEBUG_AGENT_INIT_THUNK_PEI_IA32TOX64:
|
case DEBUG_AGENT_INIT_THUNK_PEI_IA32TOX64:
|
||||||
@ -371,6 +382,7 @@ InitializeDebugAgent (
|
|||||||
|
|
||||||
FindAndReportModuleImageInfo (SIZE_4KB);
|
FindAndReportModuleImageInfo (SIZE_4KB);
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
@ -95,7 +95,7 @@ DebugPortReadBuffer (
|
|||||||
IN UINTN Timeout
|
IN UINTN Timeout
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
if (NumberOfBytes != 1 || Buffer == NULL || Timeout != 0) {
|
if ((NumberOfBytes != 1) || (Buffer == NULL) || (Timeout != 0)) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -223,6 +223,7 @@ CalculateUsbDebugPortBar (
|
|||||||
if (CapabilityId == PCI_CAPABILITY_ID_DEBUG_PORT) {
|
if (CapabilityId == PCI_CAPABILITY_ID_DEBUG_PORT) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
CapabilityPtr = PciRead8 (PcdGet32 (PcdUsbEhciPciAddress) + CapabilityPtr + 1);
|
CapabilityPtr = PciRead8 (PcdGet32 (PcdUsbEhciPciAddress) + CapabilityPtr + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -275,6 +276,7 @@ UsbDebugPortIn (
|
|||||||
if (Length == NULL) {
|
if (Length == NULL) {
|
||||||
return RETURN_INVALID_PARAMETER;
|
return RETURN_INVALID_PARAMETER;
|
||||||
}
|
}
|
||||||
|
|
||||||
*Length = 0;
|
*Length = 0;
|
||||||
|
|
||||||
DebugPortRegister->TokenPid = Token;
|
DebugPortRegister->TokenPid = Token;
|
||||||
@ -302,7 +304,8 @@ UsbDebugPortIn (
|
|||||||
//
|
//
|
||||||
while ((MmioRead32 ((UINTN)&DebugPortRegister->ControlStatus) & (UINT32)BIT16) == 0) {
|
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))
|
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;
|
return RETURN_DEVICE_ERROR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -334,6 +337,7 @@ UsbDebugPortIn (
|
|||||||
for (Index = 0; Index < *Length; Index++) {
|
for (Index = 0; Index < *Length; Index++) {
|
||||||
Buffer[Index] = DebugPortRegister->DataBuffer[Index];
|
Buffer[Index] = DebugPortRegister->DataBuffer[Index];
|
||||||
}
|
}
|
||||||
|
|
||||||
return RETURN_SUCCESS;
|
return RETURN_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -377,6 +381,7 @@ UsbDebugPortOut (
|
|||||||
} else {
|
} else {
|
||||||
DebugPortRegister->SendPid = DATA0_PID;
|
DebugPortRegister->SendPid = DATA0_PID;
|
||||||
}
|
}
|
||||||
|
|
||||||
DebugPortRegister->UsbAddress = (UINT8)(Addr & 0x7F);
|
DebugPortRegister->UsbAddress = (UINT8)(Addr & 0x7F);
|
||||||
DebugPortRegister->UsbEndPoint = (UINT8)(Ep & 0xF);
|
DebugPortRegister->UsbEndPoint = (UINT8)(Ep & 0xF);
|
||||||
|
|
||||||
@ -403,7 +408,8 @@ UsbDebugPortOut (
|
|||||||
//
|
//
|
||||||
while ((MmioRead32 ((UINTN)&DebugPortRegister->ControlStatus) & BIT16) == 0) {
|
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))
|
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;
|
return RETURN_DEVICE_ERROR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -563,7 +569,8 @@ NeedReinitializeHardware(
|
|||||||
//
|
//
|
||||||
UsbDebugPortRegister = (USB_DEBUG_PORT_REGISTER *)((UINTN)Handle->UsbDebugPortMemoryBase + Handle->DebugPortOffset);
|
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))
|
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;
|
Status = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -572,6 +579,7 @@ NeedReinitializeHardware(
|
|||||||
} else if (Handle->Initialized != USBDBG_INIT_DONE) {
|
} else if (Handle->Initialized != USBDBG_INIT_DONE) {
|
||||||
Status = TRUE;
|
Status = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -615,7 +623,8 @@ InitializeUsbDebugHardware (
|
|||||||
// Check if the debug port is enabled and owned by myself.
|
// 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))
|
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 ((
|
||||||
DEBUG_INFO,
|
DEBUG_INFO,
|
||||||
"UsbDbg: Need to reset the host controller. ControlStatus = %08x\n",
|
"UsbDbg: Need to reset the host controller. ControlStatus = %08x\n",
|
||||||
@ -633,11 +642,13 @@ InitializeUsbDebugHardware (
|
|||||||
//
|
//
|
||||||
// ensure that the host controller is reset.
|
// ensure that the host controller is reset.
|
||||||
//
|
//
|
||||||
while ((MmioRead32((UINTN)UsbCmd) & BIT1) != 0);
|
while ((MmioRead32 ((UINTN)UsbCmd) & BIT1) != 0) {
|
||||||
|
}
|
||||||
|
|
||||||
MmioOr32 ((UINTN)UsbCmd, BIT0);
|
MmioOr32 ((UINTN)UsbCmd, BIT0);
|
||||||
// ensure that the host controller is started (HALTED bit must be cleared)
|
// 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);
|
MicroSecondDelay (200000);
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Find out which port is used as debug port.
|
// Find out which port is used as debug port.
|
||||||
//
|
//
|
||||||
@ -660,8 +672,9 @@ InitializeUsbDebugHardware (
|
|||||||
return RETURN_NOT_FOUND;
|
return RETURN_NOT_FOUND;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Handle->Initialized != USBDBG_INIT_DONE ||
|
if ((Handle->Initialized != USBDBG_INIT_DONE) ||
|
||||||
(MmioRead32 ((UINTN) &UsbDebugPortRegister->ControlStatus) & USB_DEBUG_PORT_ENABLE) == 0) {
|
((MmioRead32 ((UINTN)&UsbDebugPortRegister->ControlStatus) & USB_DEBUG_PORT_ENABLE) == 0))
|
||||||
|
{
|
||||||
DEBUG ((DEBUG_INFO, "UsbDbg: Reset the debug port.\n"));
|
DEBUG ((DEBUG_INFO, "UsbDbg: Reset the debug port.\n"));
|
||||||
//
|
//
|
||||||
// Reset the debug port
|
// Reset the debug port
|
||||||
@ -669,7 +682,8 @@ InitializeUsbDebugHardware (
|
|||||||
MmioOr32 ((UINTN)PortStatus, BIT8);
|
MmioOr32 ((UINTN)PortStatus, BIT8);
|
||||||
MicroSecondDelay (500000);
|
MicroSecondDelay (500000);
|
||||||
MmioAnd32 ((UINTN)PortStatus, (UINT32) ~BIT8);
|
MmioAnd32 ((UINTN)PortStatus, (UINT32) ~BIT8);
|
||||||
while (MmioRead32((UINTN)PortStatus) & BIT8);
|
while (MmioRead32 ((UINTN)PortStatus) & BIT8) {
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// The port enabled bit should be set by HW.
|
// The port enabled bit should be set by HW.
|
||||||
@ -783,7 +797,7 @@ DebugPortReadBuffer (
|
|||||||
RETURN_STATUS Status;
|
RETURN_STATUS Status;
|
||||||
UINT8 Index;
|
UINT8 Index;
|
||||||
|
|
||||||
if (NumberOfBytes != 1 || Buffer == NULL || Timeout != 0) {
|
if ((NumberOfBytes != 1) || (Buffer == NULL) || (Timeout != 0)) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -815,8 +829,10 @@ DebugPortReadBuffer (
|
|||||||
if ((Index + 1) >= USB_DEBUG_PORT_MAX_PACKET_SIZE) {
|
if ((Index + 1) >= USB_DEBUG_PORT_MAX_PACKET_SIZE) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
UsbDebugPortHandle->Data[Index] = UsbDebugPortHandle->Data[Index + 1];
|
UsbDebugPortHandle->Data[Index] = UsbDebugPortHandle->Data[Index + 1];
|
||||||
}
|
}
|
||||||
|
|
||||||
UsbDebugPortHandle->DataCount = (UINT8)(UsbDebugPortHandle->DataCount - 1);
|
UsbDebugPortHandle->DataCount = (UINT8)(UsbDebugPortHandle->DataCount - 1);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -854,7 +870,7 @@ DebugPortWriteBuffer (
|
|||||||
UINTN Total;
|
UINTN Total;
|
||||||
UINT8 ReceivedPid;
|
UINT8 ReceivedPid;
|
||||||
|
|
||||||
if (NumberOfBytes == 0 || Buffer == NULL) {
|
if ((NumberOfBytes == 0) || (Buffer == NULL)) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -903,8 +919,10 @@ DebugPortWriteBuffer (
|
|||||||
} else {
|
} else {
|
||||||
UsbDebugPortHandle->BulkOutToggle ^= 1;
|
UsbDebugPortHandle->BulkOutToggle ^= 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
Total += Sent;
|
Total += Sent;
|
||||||
}
|
}
|
||||||
|
|
||||||
return Total;
|
return Total;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -966,6 +984,7 @@ DebugPortPollBuffer (
|
|||||||
} else {
|
} else {
|
||||||
UsbDebugPortRegister->SendPid = DATA1_PID;
|
UsbDebugPortRegister->SendPid = DATA1_PID;
|
||||||
}
|
}
|
||||||
|
|
||||||
UsbDebugPortRegister->UsbAddress = 0x7F;
|
UsbDebugPortRegister->UsbAddress = 0x7F;
|
||||||
UsbDebugPortRegister->UsbEndPoint = UsbDebugPortHandle->InEndpoint & 0x0F;
|
UsbDebugPortRegister->UsbEndPoint = UsbDebugPortHandle->InEndpoint & 0x0F;
|
||||||
|
|
||||||
@ -983,7 +1002,8 @@ DebugPortPollBuffer (
|
|||||||
//
|
//
|
||||||
while ((MmioRead32 ((UINTN)&UsbDebugPortRegister->ControlStatus) & (UINT32)BIT16) == 0) {
|
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))
|
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;
|
return FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1007,6 +1027,7 @@ DebugPortPollBuffer (
|
|||||||
for (Index = 0; Index < Length; Index++) {
|
for (Index = 0; Index < Length; Index++) {
|
||||||
UsbDebugPortHandle->Data[Index] = UsbDebugPortRegister->DataBuffer[Index];
|
UsbDebugPortHandle->Data[Index] = UsbDebugPortRegister->DataBuffer[Index];
|
||||||
}
|
}
|
||||||
|
|
||||||
UsbDebugPortHandle->DataCount = Length;
|
UsbDebugPortHandle->DataCount = Length;
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
@ -1051,9 +1072,10 @@ DebugPortInitialize (
|
|||||||
//
|
//
|
||||||
ASSERT (PcdGet16 (PcdDebugPortHandleBufferSize) == sizeof (USB_DEBUG_PORT_HANDLE));
|
ASSERT (PcdGet16 (PcdDebugPortHandleBufferSize) == sizeof (USB_DEBUG_PORT_HANDLE));
|
||||||
|
|
||||||
if (Function == NULL && Context != NULL) {
|
if ((Function == NULL) && (Context != NULL)) {
|
||||||
return (DEBUG_PORT_HANDLE *)Context;
|
return (DEBUG_PORT_HANDLE *)Context;
|
||||||
}
|
}
|
||||||
|
|
||||||
ZeroMem (&Handle, sizeof (USB_DEBUG_PORT_HANDLE));
|
ZeroMem (&Handle, sizeof (USB_DEBUG_PORT_HANDLE));
|
||||||
|
|
||||||
Status = CalculateUsbDebugPortBar (&Handle.DebugPortOffset, &Handle.DebugPortBarNumber);
|
Status = CalculateUsbDebugPortBar (&Handle.DebugPortOffset, &Handle.DebugPortBarNumber);
|
||||||
|
@ -287,12 +287,14 @@ CalculateUsbDebugPortMmioBase (
|
|||||||
Flag = TRUE;
|
Flag = TRUE;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((((Capability & XHC_NEXT_CAPABILITY_MASK) >> 8) & XHC_CAPABILITY_ID_MASK) == 0) {
|
if ((((Capability & XHC_NEXT_CAPABILITY_MASK) >> 8) & XHC_CAPABILITY_ID_MASK) == 0) {
|
||||||
//
|
//
|
||||||
// Reach the end of capability list, quit
|
// Reach the end of capability list, quit
|
||||||
//
|
//
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
CapabilityPointer += ((Capability & XHC_NEXT_CAPABILITY_MASK) >> 8) * 4;
|
CapabilityPointer += ((Capability & XHC_NEXT_CAPABILITY_MASK) >> 8) * 4;
|
||||||
Capability = MmioRead32 ((UINTN)CapabilityPointer);
|
Capability = MmioRead32 ((UINTN)CapabilityPointer);
|
||||||
}
|
}
|
||||||
@ -642,6 +644,7 @@ XhcDetectDebugCapabilityReady (
|
|||||||
Handle->Ready = TRUE;
|
Handle->Ready = TRUE;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
MicroSecondDelay (XHC_POLL_DELAY);
|
MicroSecondDelay (XHC_POLL_DELAY);
|
||||||
TimeOut--;
|
TimeOut--;
|
||||||
} while (TimeOut != 0);
|
} while (TimeOut != 0);
|
||||||
@ -680,6 +683,7 @@ InitializeUsbDebugHardware (
|
|||||||
//
|
//
|
||||||
return EFI_DEVICE_ERROR;
|
return EFI_DEVICE_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// If XHCI supports debug capability, hardware resource has been allocated,
|
// If XHCI supports debug capability, hardware resource has been allocated,
|
||||||
// but it has not been enabled, try to enable again.
|
// but it has not been enabled, try to enable again.
|
||||||
@ -880,7 +884,7 @@ DebugPortReadBuffer (
|
|||||||
UINT8 Index;
|
UINT8 Index;
|
||||||
UINT8 *Data;
|
UINT8 *Data;
|
||||||
|
|
||||||
if (NumberOfBytes != 1 || Buffer == NULL || Timeout != 0) {
|
if ((NumberOfBytes != 1) || (Buffer == NULL) || (Timeout != 0)) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -894,6 +898,7 @@ DebugPortReadBuffer (
|
|||||||
} else {
|
} else {
|
||||||
UsbDebugPortHandle = GetUsb3DebugPortInstance ();
|
UsbDebugPortHandle = GetUsb3DebugPortInstance ();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (UsbDebugPortHandle == NULL) {
|
if (UsbDebugPortHandle == NULL) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -922,8 +927,10 @@ DebugPortReadBuffer (
|
|||||||
if ((Index + 1) >= XHCI_DEBUG_DEVICE_MAX_PACKET_SIZE) {
|
if ((Index + 1) >= XHCI_DEBUG_DEVICE_MAX_PACKET_SIZE) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
Data[Index] = Data[Index + 1];
|
Data[Index] = Data[Index + 1];
|
||||||
}
|
}
|
||||||
|
|
||||||
UsbDebugPortHandle->DataCount = (UINT8)(UsbDebugPortHandle->DataCount - 1);
|
UsbDebugPortHandle->DataCount = (UINT8)(UsbDebugPortHandle->DataCount - 1);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -958,7 +965,7 @@ DebugPortWriteBuffer (
|
|||||||
UINTN Sent;
|
UINTN Sent;
|
||||||
UINTN Total;
|
UINTN Total;
|
||||||
|
|
||||||
if (NumberOfBytes == 0 || Buffer == NULL) {
|
if ((NumberOfBytes == 0) || (Buffer == NULL)) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -975,6 +982,7 @@ DebugPortWriteBuffer (
|
|||||||
} else {
|
} else {
|
||||||
UsbDebugPortHandle = GetUsb3DebugPortInstance ();
|
UsbDebugPortHandle = GetUsb3DebugPortInstance ();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (UsbDebugPortHandle == NULL) {
|
if (UsbDebugPortHandle == NULL) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -1001,6 +1009,7 @@ DebugPortWriteBuffer (
|
|||||||
} else {
|
} else {
|
||||||
Sent = (UINT8)(NumberOfBytes - Total);
|
Sent = (UINT8)(NumberOfBytes - Total);
|
||||||
}
|
}
|
||||||
|
|
||||||
XhcDataTransfer (UsbDebugPortHandle, EfiUsbDataOut, Buffer + Total, &Sent, DATA_TRANSFER_WRITE_TIMEOUT);
|
XhcDataTransfer (UsbDebugPortHandle, EfiUsbDataOut, Buffer + Total, &Sent, DATA_TRANSFER_WRITE_TIMEOUT);
|
||||||
Total += Sent;
|
Total += Sent;
|
||||||
}
|
}
|
||||||
@ -1040,6 +1049,7 @@ DebugPortPollBuffer (
|
|||||||
} else {
|
} else {
|
||||||
UsbDebugPortHandle = GetUsb3DebugPortInstance ();
|
UsbDebugPortHandle = GetUsb3DebugPortInstance ();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (UsbDebugPortHandle == NULL) {
|
if (UsbDebugPortHandle == NULL) {
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
@ -1121,10 +1131,11 @@ DebugPortInitialize (
|
|||||||
//
|
//
|
||||||
ASSERT (PcdGet16 (PcdDebugPortHandleBufferSize) == sizeof (USB3_DEBUG_PORT_HANDLE));
|
ASSERT (PcdGet16 (PcdDebugPortHandleBufferSize) == sizeof (USB3_DEBUG_PORT_HANDLE));
|
||||||
|
|
||||||
if (Function == NULL && Context != NULL) {
|
if ((Function == NULL) && (Context != NULL)) {
|
||||||
SetUsb3DebugPortInstance ((USB3_DEBUG_PORT_HANDLE *)Context);
|
SetUsb3DebugPortInstance ((USB3_DEBUG_PORT_HANDLE *)Context);
|
||||||
return (DEBUG_PORT_HANDLE)Context;
|
return (DEBUG_PORT_HANDLE)Context;
|
||||||
}
|
}
|
||||||
|
|
||||||
UsbDebugPortHandle = GetUsb3DebugPortInstance ();
|
UsbDebugPortHandle = GetUsb3DebugPortInstance ();
|
||||||
if (UsbDebugPortHandle == NULL) {
|
if (UsbDebugPortHandle == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -274,7 +274,8 @@ Usb3PciIoNotify (
|
|||||||
);
|
);
|
||||||
if (!EFI_ERROR (Status) &&
|
if (!EFI_ERROR (Status) &&
|
||||||
(PciIoHandleBuffer != NULL) &&
|
(PciIoHandleBuffer != NULL) &&
|
||||||
(PciIoHandleCount != 0)) {
|
(PciIoHandleCount != 0))
|
||||||
|
{
|
||||||
for (Index = 0; Index < PciIoHandleCount; Index++) {
|
for (Index = 0; Index < PciIoHandleCount; Index++) {
|
||||||
Status = gBS->HandleProtocol (
|
Status = gBS->HandleProtocol (
|
||||||
PciIoHandleBuffer[Index],
|
PciIoHandleBuffer[Index],
|
||||||
@ -309,6 +310,7 @@ Usb3PciIoNotify (
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
gBS->CloseEvent (Event);
|
gBS->CloseEvent (Event);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -334,6 +336,7 @@ GetUsb3DebugPortInstanceAddrPtr (
|
|||||||
mUsb3InstanceAddr = (EFI_PHYSICAL_ADDRESS)(UINTN)&mUsb3Instance;
|
mUsb3InstanceAddr = (EFI_PHYSICAL_ADDRESS)(UINTN)&mUsb3Instance;
|
||||||
mUsb3InstanceAddrPtr = &mUsb3InstanceAddr;
|
mUsb3InstanceAddrPtr = &mUsb3InstanceAddr;
|
||||||
}
|
}
|
||||||
|
|
||||||
return mUsb3InstanceAddrPtr;
|
return mUsb3InstanceAddrPtr;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -378,6 +381,7 @@ Usb3AllocateDmaBuffer (
|
|||||||
EFI_PAGES_TO_SIZE (Pages)
|
EFI_PAGES_TO_SIZE (Pages)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -478,6 +482,7 @@ DebugCommunicationUsb3DxeConstructor (
|
|||||||
if (mUsb3InstanceAddrPtr != NULL) {
|
if (mUsb3InstanceAddrPtr != NULL) {
|
||||||
*AddrPtr = *mUsb3InstanceAddrPtr;
|
*AddrPtr = *mUsb3InstanceAddrPtr;
|
||||||
}
|
}
|
||||||
|
|
||||||
mUsb3InstanceAddrPtr = AddrPtr;
|
mUsb3InstanceAddrPtr = AddrPtr;
|
||||||
|
|
||||||
Instance = GetUsb3DebugPortInstance ();
|
Instance = GetUsb3DebugPortInstance ();
|
||||||
@ -526,6 +531,6 @@ DebugCommunicationUsb3DxeDestructor (
|
|||||||
gBS->CloseEvent ((EFI_EVENT)(UINTN)Instance->PciIoEvent);
|
gBS->CloseEvent ((EFI_EVENT)(UINTN)Instance->PciIoEvent);
|
||||||
Instance->PciIoEvent = 0;
|
Instance->PciIoEvent = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return EFI_SUCCESS;
|
return EFI_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -126,6 +126,7 @@ IoMmuAllocateBuffer (
|
|||||||
*HostAddress = NULL;
|
*HostAddress = NULL;
|
||||||
return EFI_OUT_OF_RESOURCES;
|
return EFI_OUT_OF_RESOURCES;
|
||||||
}
|
}
|
||||||
|
|
||||||
Status = IoMmu->SetAttribute (
|
Status = IoMmu->SetAttribute (
|
||||||
IoMmu,
|
IoMmu,
|
||||||
*Mapping,
|
*Mapping,
|
||||||
@ -268,6 +269,6 @@ AllocateAlignBuffer (
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return Buf;
|
return Buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -40,6 +40,7 @@ XhcSyncTrsRing (
|
|||||||
if (TrsTrb->CycleBit != (TrsRing->RingPCS & BIT0)) {
|
if (TrsTrb->CycleBit != (TrsRing->RingPCS & BIT0)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
TrsTrb++;
|
TrsTrb++;
|
||||||
if ((UINT8)TrsTrb->Type == TRB_TYPE_LINK) {
|
if ((UINT8)TrsTrb->Type == TRB_TYPE_LINK) {
|
||||||
ASSERT (((LINK_TRB *)TrsTrb)->TC != 0);
|
ASSERT (((LINK_TRB *)TrsTrb)->TC != 0);
|
||||||
@ -54,6 +55,7 @@ XhcSyncTrsRing (
|
|||||||
TrsTrb = (TRB_TEMPLATE *)(UINTN)((TrsTrb->Parameter1 | LShiftU64 ((UINT64)TrsTrb->Parameter2, 32)) & ~0x0F);
|
TrsTrb = (TRB_TEMPLATE *)(UINTN)((TrsTrb->Parameter1 | LShiftU64 ((UINT64)TrsTrb->Parameter2, 32)) & ~0x0F);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ASSERT (Index != TrsRing->TrbNumber);
|
ASSERT (Index != TrsRing->TrbNumber);
|
||||||
|
|
||||||
if ((EFI_PHYSICAL_ADDRESS)(UINTN)TrsTrb != TrsRing->RingEnqueue) {
|
if ((EFI_PHYSICAL_ADDRESS)(UINTN)TrsTrb != TrsRing->RingEnqueue) {
|
||||||
@ -188,6 +190,7 @@ IsTrbInTrsRing (
|
|||||||
if (Trb == CheckedTrb) {
|
if (Trb == CheckedTrb) {
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
CheckedTrb++;
|
CheckedTrb++;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -231,7 +234,6 @@ XhcCheckUrbResult (
|
|||||||
XhcSyncEventRing (Handle, &Handle->EventRing);
|
XhcSyncEventRing (Handle, &Handle->EventRing);
|
||||||
|
|
||||||
for (Index = 0; Index < Handle->EventRing.TrbNumber; Index++) {
|
for (Index = 0; Index < Handle->EventRing.TrbNumber; Index++) {
|
||||||
|
|
||||||
Status = XhcCheckNewEvent (Handle, &Handle->EventRing, ((TRB_TEMPLATE **)&EvtTrb));
|
Status = XhcCheckNewEvent (Handle, &Handle->EventRing, ((TRB_TEMPLATE **)&EvtTrb));
|
||||||
if (Status == EFI_NOT_READY) {
|
if (Status == EFI_NOT_READY) {
|
||||||
//
|
//
|
||||||
@ -265,7 +267,8 @@ XhcCheckUrbResult (
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ((EvtTrb->Completecode == TRB_COMPLETION_SHORT_PACKET) ||
|
if ((EvtTrb->Completecode == TRB_COMPLETION_SHORT_PACKET) ||
|
||||||
(EvtTrb->Completecode == TRB_COMPLETION_SUCCESS)) {
|
(EvtTrb->Completecode == TRB_COMPLETION_SUCCESS))
|
||||||
|
{
|
||||||
//
|
//
|
||||||
// The length of data which were transferred.
|
// The length of data which were transferred.
|
||||||
//
|
//
|
||||||
@ -273,6 +276,7 @@ XhcCheckUrbResult (
|
|||||||
} else {
|
} else {
|
||||||
CheckedUrb->Result |= EFI_USB_ERR_TIMEOUT;
|
CheckedUrb->Result |= EFI_USB_ERR_TIMEOUT;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// This Urb has been processed
|
// This Urb has been processed
|
||||||
//
|
//
|
||||||
@ -356,6 +360,7 @@ XhcExecTransfer (
|
|||||||
if (Timeout == 0) {
|
if (Timeout == 0) {
|
||||||
Loop = 0xFFFFFFFF;
|
Loop = 0xFFFFFFFF;
|
||||||
}
|
}
|
||||||
|
|
||||||
XhcRingDoorBell (Handle, Urb);
|
XhcRingDoorBell (Handle, Urb);
|
||||||
//
|
//
|
||||||
// Event Ring Not Empty bit can only be set to 1 by XHC after ringing door bell with some delay.
|
// 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) {
|
if (Urb->Finished) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
MicroSecondDelay (XHC_DEBUG_PORT_1_MILLISECOND);
|
MicroSecondDelay (XHC_DEBUG_PORT_1_MILLISECOND);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Index == Loop) {
|
if (Index == Loop) {
|
||||||
//
|
//
|
||||||
// If time out occurs.
|
// If time out occurs.
|
||||||
//
|
//
|
||||||
Urb->Result |= EFI_USB_ERR_TIMEOUT;
|
Urb->Result |= EFI_USB_ERR_TIMEOUT;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// If URB transfer is error, restore transfer ring to original value before URB transfer
|
// 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.
|
// This will make the current transfer TRB is always at the latest unused one in transfer ring.
|
||||||
@ -574,4 +582,3 @@ XhcDataTransfer (
|
|||||||
|
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,7 +34,7 @@ CheckDebugAgentHandler (
|
|||||||
|
|
||||||
InterruptHandler = IdtEntry[InterruptType].Bits.OffsetLow +
|
InterruptHandler = IdtEntry[InterruptType].Bits.OffsetLow +
|
||||||
(IdtEntry[InterruptType].Bits.OffsetHigh << 16);
|
(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;
|
return TRUE;
|
||||||
} else {
|
} else {
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
@ -84,6 +84,7 @@ PeCoffLoaderExtraActionCommon (
|
|||||||
LoadImageMethod = DEBUG_LOAD_IMAGE_METHOD_SOFT_INT3;
|
LoadImageMethod = DEBUG_LOAD_IMAGE_METHOD_SOFT_INT3;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
AsmReadIdtr (&IdtDescriptor);
|
AsmReadIdtr (&IdtDescriptor);
|
||||||
if (LoadImageMethod == DEBUG_LOAD_IMAGE_METHOD_SOFT_INT3) {
|
if (LoadImageMethod == DEBUG_LOAD_IMAGE_METHOD_SOFT_INT3) {
|
||||||
if (!CheckDebugAgentHandler (&IdtDescriptor, SOFT_INT_VECTOR_NUM)) {
|
if (!CheckDebugAgentHandler (&IdtDescriptor, SOFT_INT_VECTOR_NUM)) {
|
||||||
@ -136,7 +137,6 @@ PeCoffLoaderExtraActionCommon (
|
|||||||
do {
|
do {
|
||||||
DebugAgentStatus = IoRead8 (IO_PORT_BREAKPOINT_ADDRESS);
|
DebugAgentStatus = IoRead8 (IO_PORT_BREAKPOINT_ADDRESS);
|
||||||
} while (DebugAgentStatus == DEBUG_AGENT_IMAGE_WAIT);
|
} while (DebugAgentStatus == DEBUG_AGENT_IMAGE_WAIT);
|
||||||
|
|
||||||
} else if (LoadImageMethod == DEBUG_LOAD_IMAGE_METHOD_SOFT_INT3) {
|
} else if (LoadImageMethod == DEBUG_LOAD_IMAGE_METHOD_SOFT_INT3) {
|
||||||
//
|
//
|
||||||
// Generate a software break point.
|
// Generate a software break point.
|
||||||
@ -150,26 +150,31 @@ PeCoffLoaderExtraActionCommon (
|
|||||||
// in the above exception handler
|
// in the above exception handler
|
||||||
//
|
//
|
||||||
NewDr7 = AsmReadDr7 () | BIT10; // H/w sets bit 10, some simulators don't
|
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,
|
// 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.
|
// we will not set Dr0 to 0 in GO/STEP handler because the break cause is not IMAGE_LOAD/_UNLOAD.
|
||||||
//
|
//
|
||||||
AsmWriteDr0 (Dr0);
|
AsmWriteDr0 (Dr0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!IsDrxEnabled (1, NewDr7) && (AsmReadDr1 () == (UINTN)ImageContext->PdbPointer)) {
|
if (!IsDrxEnabled (1, NewDr7) && (AsmReadDr1 () == (UINTN)ImageContext->PdbPointer)) {
|
||||||
AsmWriteDr1 (Dr1);
|
AsmWriteDr1 (Dr1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!IsDrxEnabled (2, NewDr7) && (AsmReadDr2 () == (UINTN)ImageContext)) {
|
if (!IsDrxEnabled (2, NewDr7) && (AsmReadDr2 () == (UINTN)ImageContext)) {
|
||||||
AsmWriteDr2 (Dr2);
|
AsmWriteDr2 (Dr2);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!IsDrxEnabled (3, NewDr7) && (AsmReadDr3 () == IO_PORT_BREAKPOINT_ADDRESS)) {
|
if (!IsDrxEnabled (3, NewDr7) && (AsmReadDr3 () == IO_PORT_BREAKPOINT_ADDRESS)) {
|
||||||
AsmWriteDr3 (Dr3);
|
AsmWriteDr3 (Dr3);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (LoadImageMethod == DEBUG_LOAD_IMAGE_METHOD_IO_HW_BREAKPOINT) {
|
if (LoadImageMethod == DEBUG_LOAD_IMAGE_METHOD_IO_HW_BREAKPOINT) {
|
||||||
if (AsmReadCr4 () == (Cr4 | BIT3)) {
|
if (AsmReadCr4 () == (Cr4 | BIT3)) {
|
||||||
AsmWriteCr4 (Cr4);
|
AsmWriteCr4 (Cr4);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (NewDr7 == 0x20000480) {
|
if (NewDr7 == 0x20000480) {
|
||||||
AsmWriteDr7 (Dr7);
|
AsmWriteDr7 (Dr7);
|
||||||
}
|
}
|
||||||
@ -178,12 +183,14 @@ PeCoffLoaderExtraActionCommon (
|
|||||||
AsmWriteDr7 (Dr7);
|
AsmWriteDr7 (Dr7);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Restore original IDT entry for INT1 if it was hooked.
|
// Restore original IDT entry for INT1 if it was hooked.
|
||||||
//
|
//
|
||||||
if (IdtEntryHooked) {
|
if (IdtEntryHooked) {
|
||||||
RestoreIdtEntry1 (&IdtDescriptor, &OriginalIdtEntry);
|
RestoreIdtEntry1 (&IdtDescriptor, &OriginalIdtEntry);
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Restore the interrupt state
|
// Restore the interrupt state
|
||||||
//
|
//
|
||||||
|
@ -70,4 +70,3 @@ RestoreIdtEntry1 (
|
|||||||
);
|
);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -35,7 +35,7 @@ CheckDebugAgentHandler (
|
|||||||
InterruptHandler = IdtEntry[InterruptType].Bits.OffsetLow +
|
InterruptHandler = IdtEntry[InterruptType].Bits.OffsetLow +
|
||||||
(((UINTN)IdtEntry[InterruptType].Bits.OffsetHigh) << 16) +
|
(((UINTN)IdtEntry[InterruptType].Bits.OffsetHigh) << 16) +
|
||||||
(((UINTN)IdtEntry[InterruptType].Bits.OffsetUpper) << 32);
|
(((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;
|
return TRUE;
|
||||||
} else {
|
} else {
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
Reference in New Issue
Block a user