This patch use the Context to indicate SMM Debug Agent support or
not if InitFlag is DEBUG_AGENT_INIT_SMM. Context must be the pointer
to the BOOLEAN value if it's not NULL.

Cc: Ray Ni <ray...@intel.com>
Signed-off-by: Jiaxin Wu <jiaxin...@intel.com>
---
 .../Library/DebugAgent/SmmDebugAgent/SmmDebugAgentLib.c    | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git 
a/SourceLevelDebugPkg/Library/DebugAgent/SmmDebugAgent/SmmDebugAgentLib.c 
b/SourceLevelDebugPkg/Library/DebugAgent/SmmDebugAgent/SmmDebugAgentLib.c
index f49a592d27..1648c2b33e 100644
--- a/SourceLevelDebugPkg/Library/DebugAgent/SmmDebugAgent/SmmDebugAgentLib.c
+++ b/SourceLevelDebugPkg/Library/DebugAgent/SmmDebugAgent/SmmDebugAgentLib.c
@@ -157,12 +157,13 @@ RestoreDebugRegister (
   in SMM code.
 
   If InitFlag is DEBUG_AGENT_INIT_SMM, it will override IDT table entries
   and initialize debug port. It will get debug agent Mailbox from GUIDed HOB,
   it it exists, debug agent wiil copied it into the local Mailbox in SMM space.
-  it will override IDT table entries and initialize debug port. Context will be
-  NULL.
+  it will override IDT table entries and initialize debug port. Context must be
+  the pointer to the BOOLEAN value if it's not NULL, which indicates SMM Debug
+  Agent supported or not.
   If InitFlag is DEBUG_AGENT_INIT_ENTER_SMI, debug agent will save Debug
   Registers and get local Mailbox in SMM space. Context will be NULL.
   If InitFlag is DEBUG_AGENT_INIT_EXIT_SMI, debug agent will restore Debug
   Registers. Context will be NULL.
 
@@ -203,29 +204,32 @@ InitializeDebugAgent (
                         (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"));
+        *(BOOLEAN *)Context = FALSE;
         CpuDeadLoop ();
       }
 
       //
       // Check if Debug Agent initialized in DXE phase
       //
       Status = EfiGetSystemConfigurationTable (&gEfiDebugAgentGuid, (VOID 
**)&Mailbox);
       if ((Status == EFI_SUCCESS) && (Mailbox != NULL)) {
         VerifyMailboxChecksum (Mailbox);
-        mMailboxPointer = Mailbox;
+        mMailboxPointer     = Mailbox;
+        *(BOOLEAN *)Context = TRUE;
         break;
       }
 
       //
       // Check if Debug Agent initialized in SEC/PEI phase
       //
       Mailbox = GetMailboxFromHob ();
       if (Mailbox != NULL) {
-        mMailboxPointer = Mailbox;
+        mMailboxPointer     = Mailbox;
+        *(BOOLEAN *)Context = TRUE;
         break;
       }
 
       //
       // Debug Agent was not initialized before, use the local mailbox.
@@ -273,10 +277,12 @@ InitializeDebugAgent (
       //
       // Restore saved IDT entries
       //
       CopyMem ((VOID *)IdtDescriptor.Base, &IdtEntry, 33 * sizeof 
(IA32_IDT_GATE_DESCRIPTOR));
 
+      *(BOOLEAN *)Context = TRUE;
+
       break;
 
     case DEBUG_AGENT_INIT_ENTER_SMI:
       SaveDebugRegister ();
       if (!mSmmDebugIdtInitFlag) {
-- 
2.16.2.windows.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#112792): https://edk2.groups.io/g/devel/message/112792
Mute This Topic: https://groups.io/mt/103293798/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-


Reply via email to