diff options
author | Michael Kubacki <michael.kubacki@microsoft.com> | 2021-12-05 14:54:15 -0800 |
---|---|---|
committer | mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> | 2021-12-07 17:24:28 +0000 |
commit | c1e126b1196de75e0a4cda21e4551ea9bb05e059 (patch) | |
tree | da0e06602097dc7bb7e5a97a270d1834b6cf76e7 /SourceLevelDebugPkg/Library/DebugAgent/SmmDebugAgent | |
parent | b87864896714cf3062a7bc6d577d8fbd62d105e5 (diff) | |
download | edk2-c1e126b1196de75e0a4cda21e4551ea9bb05e059.zip edk2-c1e126b1196de75e0a4cda21e4551ea9bb05e059.tar.gz edk2-c1e126b1196de75e0a4cda21e4551ea9bb05e059.tar.bz2 |
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>
Diffstat (limited to 'SourceLevelDebugPkg/Library/DebugAgent/SmmDebugAgent')
-rw-r--r-- | SourceLevelDebugPkg/Library/DebugAgent/SmmDebugAgent/SmmDebugAgentLib.c | 412 |
1 files changed, 212 insertions, 200 deletions
diff --git a/SourceLevelDebugPkg/Library/DebugAgent/SmmDebugAgent/SmmDebugAgentLib.c b/SourceLevelDebugPkg/Library/DebugAgent/SmmDebugAgent/SmmDebugAgentLib.c index 5f0fe05..f49a592 100644 --- a/SourceLevelDebugPkg/Library/DebugAgent/SmmDebugAgent/SmmDebugAgentLib.c +++ b/SourceLevelDebugPkg/Library/DebugAgent/SmmDebugAgent/SmmDebugAgentLib.c @@ -8,19 +8,19 @@ #include "SmmDebugAgentLib.h"
-DEBUG_AGENT_MAILBOX *mMailboxPointer = NULL;
-DEBUG_AGENT_MAILBOX mLocalMailbox;
-UINTN mSavedDebugRegisters[6];
-IA32_IDT_GATE_DESCRIPTOR mIdtEntryTable[33];
-BOOLEAN mSkipBreakpoint = FALSE;
-BOOLEAN mSmmDebugIdtInitFlag = FALSE;
-BOOLEAN mApicTimerRestore = FALSE;
-BOOLEAN mPeriodicMode;
-UINT32 mTimerCycle;
-UINTN mApicTimerDivisor;
-UINT8 mVector;
-
-CHAR8 mWarningMsgIgnoreSmmEntryBreak[] = "Ignore smmentrybreak setting for SMI issued during DXE debugging!\r\n";
+DEBUG_AGENT_MAILBOX *mMailboxPointer = NULL;
+DEBUG_AGENT_MAILBOX mLocalMailbox;
+UINTN mSavedDebugRegisters[6];
+IA32_IDT_GATE_DESCRIPTOR mIdtEntryTable[33];
+BOOLEAN mSkipBreakpoint = FALSE;
+BOOLEAN mSmmDebugIdtInitFlag = FALSE;
+BOOLEAN mApicTimerRestore = FALSE;
+BOOLEAN mPeriodicMode;
+UINT32 mTimerCycle;
+UINTN mApicTimerDivisor;
+UINT8 mVector;
+
+CHAR8 mWarningMsgIgnoreSmmEntryBreak[] = "Ignore smmentrybreak setting for SMI issued during DXE debugging!\r\n";
/**
Check if debug agent support multi-processor.
@@ -49,8 +49,8 @@ MultiProcessorDebugSupport ( **/
EFI_STATUS
DebugReadBreakSymbol (
- IN DEBUG_PORT_HANDLE Handle,
- OUT UINT8 *BreakSymbol
+ IN DEBUG_PORT_HANDLE Handle,
+ OUT UINT8 *BreakSymbol
)
{
//
@@ -70,16 +70,17 @@ GetMailboxFromHob ( VOID
)
{
- EFI_HOB_GUID_TYPE *GuidHob;
- UINT64 *MailboxLocation;
- DEBUG_AGENT_MAILBOX *Mailbox;
+ EFI_HOB_GUID_TYPE *GuidHob;
+ UINT64 *MailboxLocation;
+ DEBUG_AGENT_MAILBOX *Mailbox;
GuidHob = GetFirstGuidHob (&gEfiDebugAgentGuid);
if (GuidHob == NULL) {
return NULL;
}
- MailboxLocation = (UINT64 *) (GET_GUID_HOB_DATA(GuidHob));
- Mailbox = (DEBUG_AGENT_MAILBOX *)(UINTN)(*MailboxLocation);
+
+ MailboxLocation = (UINT64 *)(GET_GUID_HOB_DATA (GuidHob));
+ Mailbox = (DEBUG_AGENT_MAILBOX *)(UINTN)(*MailboxLocation);
VerifyMailboxChecksum (Mailbox);
return Mailbox;
@@ -111,7 +112,7 @@ GetDebugPortHandle ( VOID
)
{
- return (DEBUG_PORT_HANDLE) (UINTN)(GetMailboxPointer()->DebugPortHandle);
+ return (DEBUG_PORT_HANDLE)(UINTN)(GetMailboxPointer ()->DebugPortHandle);
}
/**
@@ -179,207 +180,218 @@ InitializeDebugAgent ( IN DEBUG_AGENT_CONTINUE Function OPTIONAL
)
{
- EFI_STATUS Status;
- UINT64 DebugPortHandle;
- IA32_IDT_GATE_DESCRIPTOR IdtEntry[33];
- IA32_DESCRIPTOR IdtDescriptor;
- IA32_DESCRIPTOR *Ia32Idtr;
- IA32_IDT_ENTRY *Ia32IdtEntry;
- IA32_DESCRIPTOR Idtr;
- UINT16 IdtEntryCount;
- DEBUG_AGENT_MAILBOX *Mailbox;
- UINT64 *MailboxLocation;
- UINT32 DebugTimerFrequency;
+ EFI_STATUS Status;
+ UINT64 DebugPortHandle;
+ IA32_IDT_GATE_DESCRIPTOR IdtEntry[33];
+ IA32_DESCRIPTOR IdtDescriptor;
+ IA32_DESCRIPTOR *Ia32Idtr;
+ IA32_IDT_ENTRY *Ia32IdtEntry;
+ IA32_DESCRIPTOR Idtr;
+ UINT16 IdtEntryCount;
+ DEBUG_AGENT_MAILBOX *Mailbox;
+ UINT64 *MailboxLocation;
+ UINT32 DebugTimerFrequency;
switch (InitFlag) {
- case DEBUG_AGENT_INIT_SMM:
- //
- // Install configuration table for persisted vector handoff info
- //
- Status = gSmst->SmmInstallConfigurationTable (
- gSmst,
- &gEfiVectorHandoffTableGuid,
- (VOID *) &mVectorHandoffInfoDebugAgent[0],
- sizeof (EFI_VECTOR_HANDOFF_INFO) * mVectorHandoffInfoCount
- );
- if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_ERROR, "DebugAgent: Cannot install configuration table for persisted vector handoff info!\n"));
- CpuDeadLoop ();
- }
- //
- // Check if Debug Agent initialized in DXE phase
- //
- Status = EfiGetSystemConfigurationTable (&gEfiDebugAgentGuid, (VOID **) &Mailbox);
- if (Status == EFI_SUCCESS && Mailbox != NULL) {
- VerifyMailboxChecksum (Mailbox);
- mMailboxPointer = Mailbox;
- break;
- }
- //
- // Check if Debug Agent initialized in SEC/PEI phase
- //
- Mailbox = GetMailboxFromHob ();
- if (Mailbox != NULL) {
- mMailboxPointer = Mailbox;
- break;
- }
- //
- // Debug Agent was not initialized before, use the local mailbox.
- //
- ZeroMem (&mLocalMailbox, sizeof (DEBUG_AGENT_MAILBOX));
- Mailbox = &mLocalMailbox;
- //
- // Save original IDT entries
- //
- AsmReadIdtr (&IdtDescriptor);
- CopyMem (&IdtEntry, (VOID *)IdtDescriptor.Base, 33 * sizeof(IA32_IDT_GATE_DESCRIPTOR));
- //
- // Initialized Debug Agent
- //
- InitializeDebugIdt ();
- //
- // Initialize Debug Timer hardware and save its frequency
- //
- InitializeDebugTimer (&DebugTimerFrequency, TRUE);
- UpdateMailboxContent (Mailbox, DEBUG_MAILBOX_DEBUG_TIMER_FREQUENCY, DebugTimerFrequency);
-
- DebugPortHandle = (UINT64) (UINTN)DebugPortInitialize ((DEBUG_PORT_HANDLE) (UINTN)Mailbox->DebugPortHandle, NULL);
- UpdateMailboxContent (Mailbox, DEBUG_MAILBOX_DEBUG_PORT_HANDLE_INDEX, DebugPortHandle);
- mMailboxPointer = Mailbox;
- //
- // Trigger one software interrupt to inform HOST
- //
- TriggerSoftInterrupt (SYSTEM_RESET_SIGNATURE);
-
- SetDebugFlag (DEBUG_AGENT_FLAG_MEMORY_READY, 1);
- //
- // Memory has been ready
- //
- if (IsHostAttached ()) {
+ case DEBUG_AGENT_INIT_SMM:
//
- // Trigger one software interrupt to inform HOST
+ // Install configuration table for persisted vector handoff info
+ //
+ Status = gSmst->SmmInstallConfigurationTable (
+ gSmst,
+ &gEfiVectorHandoffTableGuid,
+ (VOID *)&mVectorHandoffInfoDebugAgent[0],
+ sizeof (EFI_VECTOR_HANDOFF_INFO) * mVectorHandoffInfoCount
+ );
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "DebugAgent: Cannot install configuration table for persisted vector handoff info!\n"));
+ CpuDeadLoop ();
+ }
+
+ //
+ // Check if Debug Agent initialized in DXE phase
+ //
+ Status = EfiGetSystemConfigurationTable (&gEfiDebugAgentGuid, (VOID **)&Mailbox);
+ if ((Status == EFI_SUCCESS) && (Mailbox != NULL)) {
+ VerifyMailboxChecksum (Mailbox);
+ mMailboxPointer = Mailbox;
+ break;
+ }
+
+ //
+ // Check if Debug Agent initialized in SEC/PEI phase
+ //
+ Mailbox = GetMailboxFromHob ();
+ if (Mailbox != NULL) {
+ mMailboxPointer = Mailbox;
+ break;
+ }
+
+ //
+ // Debug Agent was not initialized before, use the local mailbox.
//
- TriggerSoftInterrupt (MEMORY_READY_SIGNATURE);
- }
- //
- // Find and report PE/COFF image info to HOST
- //
- FindAndReportModuleImageInfo (SIZE_4KB);
- //
- // Restore saved IDT entries
- //
- CopyMem ((VOID *)IdtDescriptor.Base, &IdtEntry, 33 * sizeof(IA32_IDT_GATE_DESCRIPTOR));
-
- break;
-
- case DEBUG_AGENT_INIT_ENTER_SMI:
- SaveDebugRegister ();
- if (!mSmmDebugIdtInitFlag) {
+ ZeroMem (&mLocalMailbox, sizeof (DEBUG_AGENT_MAILBOX));
+ Mailbox = &mLocalMailbox;
//
- // We only need to initialize Debug IDT table at first SMI entry
- // after SMM relocation.
+ // Save original IDT entries
+ //
+ AsmReadIdtr (&IdtDescriptor);
+ CopyMem (&IdtEntry, (VOID *)IdtDescriptor.Base, 33 * sizeof (IA32_IDT_GATE_DESCRIPTOR));
+ //
+ // Initialized Debug Agent
//
InitializeDebugIdt ();
- mSmmDebugIdtInitFlag = TRUE;
- }
- //
- // Check if CPU APIC Timer is working, otherwise initialize it.
- //
- InitializeLocalApicSoftwareEnable (TRUE);
- GetApicTimerState (&mApicTimerDivisor, &mPeriodicMode, &mVector);
- mTimerCycle = GetApicTimerInitCount ();
- if (!mPeriodicMode || mTimerCycle == 0) {
- mApicTimerRestore = TRUE;
- InitializeDebugTimer (NULL, FALSE);
- }
- Mailbox = GetMailboxPointer ();
- if (GetDebugFlag (DEBUG_AGENT_FLAG_AGENT_IN_PROGRESS) == 1) {
//
- // If Debug Agent has been communication state with HOST, we need skip
- // any break points set in SMM, set Skip Breakpoint flag
+ // Initialize Debug Timer hardware and save its frequency
+ //
+ InitializeDebugTimer (&DebugTimerFrequency, TRUE);
+ UpdateMailboxContent (Mailbox, DEBUG_MAILBOX_DEBUG_TIMER_FREQUENCY, DebugTimerFrequency);
+
+ DebugPortHandle = (UINT64)(UINTN)DebugPortInitialize ((DEBUG_PORT_HANDLE)(UINTN)Mailbox->DebugPortHandle, NULL);
+ UpdateMailboxContent (Mailbox, DEBUG_MAILBOX_DEBUG_PORT_HANDLE_INDEX, DebugPortHandle);
+ mMailboxPointer = Mailbox;
+ //
+ // Trigger one software interrupt to inform HOST
//
- mSkipBreakpoint = TRUE;
- }
- if (GetDebugFlag (DEBUG_AGENT_FLAG_BREAK_ON_NEXT_SMI) == 1) {
- if (mSkipBreakpoint) {
+ TriggerSoftInterrupt (SYSTEM_RESET_SIGNATURE);
+
+ SetDebugFlag (DEBUG_AGENT_FLAG_MEMORY_READY, 1);
+ //
+ // Memory has been ready
+ //
+ if (IsHostAttached ()) {
//
- // Print warning message if ignore smm entry break
+ // Trigger one software interrupt to inform HOST
//
- DebugPortWriteBuffer ((DEBUG_PORT_HANDLE) (UINTN)Mailbox->DebugPortHandle,
- (UINT8 *)mWarningMsgIgnoreSmmEntryBreak,
- AsciiStrLen (mWarningMsgIgnoreSmmEntryBreak)
- );
- } else {
+ TriggerSoftInterrupt (MEMORY_READY_SIGNATURE);
+ }
+
+ //
+ // Find and report PE/COFF image info to HOST
+ //
+ FindAndReportModuleImageInfo (SIZE_4KB);
+ //
+ // Restore saved IDT entries
+ //
+ CopyMem ((VOID *)IdtDescriptor.Base, &IdtEntry, 33 * sizeof (IA32_IDT_GATE_DESCRIPTOR));
+
+ break;
+
+ case DEBUG_AGENT_INIT_ENTER_SMI:
+ SaveDebugRegister ();
+ if (!mSmmDebugIdtInitFlag) {
//
- // If SMM entry break is set, SMM code will be break at here.
+ // We only need to initialize Debug IDT table at first SMI entry
+ // after SMM relocation.
//
- CpuBreakpoint ();
+ InitializeDebugIdt ();
+ mSmmDebugIdtInitFlag = TRUE;
}
- }
- break;
-
- case DEBUG_AGENT_INIT_EXIT_SMI:
- Mailbox = GetMailboxPointer ();
- //
- // Clear Skip Breakpoint flag
- //
- mSkipBreakpoint = FALSE;
- RestoreDebugRegister ();
- //
- // Restore APIC Timer
- //
- if (mApicTimerRestore) {
- InitializeApicTimer (mApicTimerDivisor, mTimerCycle, mPeriodicMode, mVector);
- mApicTimerRestore = FALSE;
- }
- break;
-
- case DEBUG_AGENT_INIT_THUNK_PEI_IA32TOX64:
- if (Context == NULL) {
- DEBUG ((DEBUG_ERROR, "DebugAgent: Input parameter Context cannot be NULL!\n"));
- CpuDeadLoop ();
- } else {
- Ia32Idtr = (IA32_DESCRIPTOR *) Context;
- Ia32IdtEntry = (IA32_IDT_ENTRY *)(Ia32Idtr->Base);
- MailboxLocation = (UINT64 *) ((UINTN) Ia32IdtEntry[DEBUG_MAILBOX_VECTOR].Bits.OffsetLow +
- ((UINTN) Ia32IdtEntry[DEBUG_MAILBOX_VECTOR].Bits.OffsetHigh << 16));
- mMailboxPointer = (DEBUG_AGENT_MAILBOX *)(UINTN)(*MailboxLocation);
- VerifyMailboxChecksum (mMailboxPointer);
+
//
- // Get original IDT address and size.
+ // Check if CPU APIC Timer is working, otherwise initialize it.
//
- AsmReadIdtr ((IA32_DESCRIPTOR *) &Idtr);
- IdtEntryCount = (UINT16) ((Idtr.Limit + 1) / sizeof (IA32_IDT_GATE_DESCRIPTOR));
- if (IdtEntryCount < 33) {
- Idtr.Limit = (UINT16) (sizeof (IA32_IDT_GATE_DESCRIPTOR) * 33 - 1);
- Idtr.Base = (UINTN) &mIdtEntryTable;
- ZeroMem (&mIdtEntryTable, Idtr.Limit + 1);
- AsmWriteIdtr ((IA32_DESCRIPTOR *) &Idtr);
+ InitializeLocalApicSoftwareEnable (TRUE);
+ GetApicTimerState (&mApicTimerDivisor, &mPeriodicMode, &mVector);
+ mTimerCycle = GetApicTimerInitCount ();
+ if (!mPeriodicMode || (mTimerCycle == 0)) {
+ mApicTimerRestore = TRUE;
+ InitializeDebugTimer (NULL, FALSE);
}
- InitializeDebugIdt ();
+ Mailbox = GetMailboxPointer ();
+ if (GetDebugFlag (DEBUG_AGENT_FLAG_AGENT_IN_PROGRESS) == 1) {
+ //
+ // If Debug Agent has been communication state with HOST, we need skip
+ // any break points set in SMM, set Skip Breakpoint flag
+ //
+ mSkipBreakpoint = TRUE;
+ }
+
+ if (GetDebugFlag (DEBUG_AGENT_FLAG_BREAK_ON_NEXT_SMI) == 1) {
+ if (mSkipBreakpoint) {
+ //
+ // Print warning message if ignore smm entry break
+ //
+ DebugPortWriteBuffer (
+ (DEBUG_PORT_HANDLE)(UINTN)Mailbox->DebugPortHandle,
+ (UINT8 *)mWarningMsgIgnoreSmmEntryBreak,
+ AsciiStrLen (mWarningMsgIgnoreSmmEntryBreak)
+ );
+ } else {
+ //
+ // If SMM entry break is set, SMM code will be break at here.
+ //
+ CpuBreakpoint ();
+ }
+ }
+
+ break;
+
+ case DEBUG_AGENT_INIT_EXIT_SMI:
+ Mailbox = GetMailboxPointer ();
//
- // Initialize Debug Timer hardware and save its frequency
+ // Clear Skip Breakpoint flag
//
- InitializeDebugTimer (&DebugTimerFrequency, TRUE);
- UpdateMailboxContent (mMailboxPointer, DEBUG_MAILBOX_DEBUG_TIMER_FREQUENCY, DebugTimerFrequency);
+ mSkipBreakpoint = FALSE;
+ RestoreDebugRegister ();
//
- // Enable Debug Timer interrupt and CPU interrupt
+ // Restore APIC Timer
//
- SaveAndSetDebugTimerInterrupt (TRUE);
- EnableInterrupts ();
+ if (mApicTimerRestore) {
+ InitializeApicTimer (mApicTimerDivisor, mTimerCycle, mPeriodicMode, mVector);
+ mApicTimerRestore = FALSE;
+ }
- FindAndReportModuleImageInfo (SIZE_4KB);
- }
- break;
-
- default:
- //
- // Only DEBUG_AGENT_INIT_PREMEM_SEC and DEBUG_AGENT_INIT_POSTMEM_SEC are allowed for this
- // Debug Agent library instance.
- //
- DEBUG ((DEBUG_ERROR, "Debug Agent: The InitFlag value is not allowed!\n"));
- CpuDeadLoop ();
- break;
+ break;
+
+ case DEBUG_AGENT_INIT_THUNK_PEI_IA32TOX64:
+ if (Context == NULL) {
+ DEBUG ((DEBUG_ERROR, "DebugAgent: Input parameter Context cannot be NULL!\n"));
+ CpuDeadLoop ();
+ } else {
+ Ia32Idtr = (IA32_DESCRIPTOR *)Context;
+ Ia32IdtEntry = (IA32_IDT_ENTRY *)(Ia32Idtr->Base);
+ MailboxLocation = (UINT64 *)((UINTN)Ia32IdtEntry[DEBUG_MAILBOX_VECTOR].Bits.OffsetLow +
+ ((UINTN)Ia32IdtEntry[DEBUG_MAILBOX_VECTOR].Bits.OffsetHigh << 16));
+ mMailboxPointer = (DEBUG_AGENT_MAILBOX *)(UINTN)(*MailboxLocation);
+ VerifyMailboxChecksum (mMailboxPointer);
+ //
+ // Get original IDT address and size.
+ //
+ AsmReadIdtr ((IA32_DESCRIPTOR *)&Idtr);
+ IdtEntryCount = (UINT16)((Idtr.Limit + 1) / sizeof (IA32_IDT_GATE_DESCRIPTOR));
+ if (IdtEntryCount < 33) {
+ Idtr.Limit = (UINT16)(sizeof (IA32_IDT_GATE_DESCRIPTOR) * 33 - 1);
+ Idtr.Base = (UINTN)&mIdtEntryTable;
+ ZeroMem (&mIdtEntryTable, Idtr.Limit + 1);
+ AsmWriteIdtr ((IA32_DESCRIPTOR *)&Idtr);
+ }
+
+ InitializeDebugIdt ();
+ //
+ // Initialize Debug Timer hardware and save its frequency
+ //
+ InitializeDebugTimer (&DebugTimerFrequency, TRUE);
+ UpdateMailboxContent (mMailboxPointer, DEBUG_MAILBOX_DEBUG_TIMER_FREQUENCY, DebugTimerFrequency);
+ //
+ // Enable Debug Timer interrupt and CPU interrupt
+ //
+ SaveAndSetDebugTimerInterrupt (TRUE);
+ EnableInterrupts ();
+
+ FindAndReportModuleImageInfo (SIZE_4KB);
+ }
+
+ break;
+
+ default:
+ //
+ // Only DEBUG_AGENT_INIT_PREMEM_SEC and DEBUG_AGENT_INIT_POSTMEM_SEC are allowed for this
+ // Debug Agent library instance.
+ //
+ DEBUG ((DEBUG_ERROR, "Debug Agent: The InitFlag value is not allowed!\n"));
+ CpuDeadLoop ();
+ break;
}
}
|