From 7b3b39a2e4bdb0f216d539fa1271c49063c49df2 Mon Sep 17 00:00:00 2001 From: Jiaxin Wu Date: Fri, 15 Dec 2023 16:36:18 +0800 Subject: SourceLevelDebugPkg/Library: Indicate SMM Debug Agent support or not This patch is to use the Context to indicate SMM Debug Agent support or not if InitFlag is DEBUG_AGENT_INIT_SMM. Context must point to a BOOLEAN if it's not NULL. Cc: Ray Ni Signed-off-by: Jiaxin Wu Reviewed-by: Ray Ni --- .../DebugAgent/SmmDebugAgent/SmmDebugAgentLib.c | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/SourceLevelDebugPkg/Library/DebugAgent/SmmDebugAgent/SmmDebugAgentLib.c b/SourceLevelDebugPkg/Library/DebugAgent/SmmDebugAgent/SmmDebugAgentLib.c index f49a592d27..cc5bb957f7 100644 --- a/SourceLevelDebugPkg/Library/DebugAgent/SmmDebugAgent/SmmDebugAgentLib.c +++ b/SourceLevelDebugPkg/Library/DebugAgent/SmmDebugAgent/SmmDebugAgentLib.c @@ -159,8 +159,9 @@ RestoreDebugRegister ( 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 + point to a BOOLEAN 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 @@ -205,6 +206,10 @@ InitializeDebugAgent ( ); if (EFI_ERROR (Status)) { DEBUG ((DEBUG_ERROR, "DebugAgent: Cannot install configuration table for persisted vector handoff info!\n")); + if (Context != NULL) { + *(BOOLEAN *)Context = FALSE; + } + CpuDeadLoop (); } @@ -215,6 +220,10 @@ InitializeDebugAgent ( if ((Status == EFI_SUCCESS) && (Mailbox != NULL)) { VerifyMailboxChecksum (Mailbox); mMailboxPointer = Mailbox; + if (Context != NULL) { + *(BOOLEAN *)Context = TRUE; + } + break; } @@ -224,6 +233,10 @@ InitializeDebugAgent ( Mailbox = GetMailboxFromHob (); if (Mailbox != NULL) { mMailboxPointer = Mailbox; + if (Context != NULL) { + *(BOOLEAN *)Context = TRUE; + } + break; } @@ -275,6 +288,10 @@ InitializeDebugAgent ( // CopyMem ((VOID *)IdtDescriptor.Base, &IdtEntry, 33 * sizeof (IA32_IDT_GATE_DESCRIPTOR)); + if (Context != NULL) { + *(BOOLEAN *)Context = TRUE; + } + break; case DEBUG_AGENT_INIT_ENTER_SMI: -- cgit