From 43c9fdcccd3254e929eb7b800b46418d78a4c2e8 Mon Sep 17 00:00:00 2001 From: Jeff Fan Date: Mon, 26 Dec 2016 16:28:58 +0800 Subject: [PATCH] UefiCpuPkg/DxeMpInitLib: Support source debugging on AP function The current DxeDebugAgentLib supports source debugging on AP function. This update is to update DxeMpInitLib to consume Debug Agent Library by DEBUG_AGENT_INIT_DXE_AP flag. Thus, we could source debugging AP function invoked by CPU MP Protocol. However, current SecPeiDebugAgentLib does not support source debugging on AP function invoked by CPU MP PPI. I have submitted one bugzilla to add this support at https://bugzilla.tianocore.org/show_bug.cgi?id=308. Cc: Feng Tian Cc: Kinney Michael D Cc: Ruiyu Ni Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Jeff Fan Reviewed-by: Feng Tian --- UefiCpuPkg/Library/MpInitLib/DxeMpInitLib.inf | 2 ++ UefiCpuPkg/Library/MpInitLib/DxeMpLib.c | 16 ++++++++++++++++ UefiCpuPkg/Library/MpInitLib/MpLib.c | 4 ++++ UefiCpuPkg/Library/MpInitLib/MpLib.h | 9 +++++++++ UefiCpuPkg/Library/MpInitLib/PeiMpLib.c | 12 ++++++++++++ 5 files changed, 43 insertions(+) diff --git a/UefiCpuPkg/Library/MpInitLib/DxeMpInitLib.inf b/UefiCpuPkg/Library/MpInitLib/DxeMpInitLib.inf index 11b230174e..cc4f2e93be 100644 --- a/UefiCpuPkg/Library/MpInitLib/DxeMpInitLib.inf +++ b/UefiCpuPkg/Library/MpInitLib/DxeMpInitLib.inf @@ -43,6 +43,7 @@ [Packages] MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec UefiCpuPkg/UefiCpuPkg.dec [LibraryClasses] @@ -54,6 +55,7 @@ CpuLib UefiCpuLib UefiBootServicesTableLib + DebugAgentLib [Guids] gEfiEventExitBootServicesGuid ## CONSUMES ## Event diff --git a/UefiCpuPkg/Library/MpInitLib/DxeMpLib.c b/UefiCpuPkg/Library/MpInitLib/DxeMpLib.c index e75c26930d..1204abd577 100644 --- a/UefiCpuPkg/Library/MpInitLib/DxeMpLib.c +++ b/UefiCpuPkg/Library/MpInitLib/DxeMpLib.c @@ -16,6 +16,7 @@ #include #include +#include #define AP_CHECK_INTERVAL (EFI_TIMER_PERIOD_MILLISECONDS (100)) #define AP_SAFE_STACK_SIZE 128 @@ -29,6 +30,21 @@ VOID *mReservedApLoopFunc = NULL; UINTN mReservedTopOfApStack; volatile UINT32 mNumberToFinish = 0; +/** + Enable Debug Agent to support source debugging on AP function. + +**/ +VOID +EnableDebugAgent ( + VOID + ) +{ + // + // Initialize Debug Agent to support source level debug in DXE phase + // + InitializeDebugAgent (DEBUG_AGENT_INIT_DXE_AP, NULL, NULL); +} + /** Get the pointer to CPU MP Data structure. diff --git a/UefiCpuPkg/Library/MpInitLib/MpLib.c b/UefiCpuPkg/Library/MpInitLib/MpLib.c index 0495b0f8a4..a21a980b58 100644 --- a/UefiCpuPkg/Library/MpInitLib/MpLib.c +++ b/UefiCpuPkg/Library/MpInitLib/MpLib.c @@ -539,6 +539,10 @@ ApWakeupFunction ( if (Procedure != NULL) { SetApState (&CpuMpData->CpuData[ProcessorNumber], CpuStateBusy); // + // Enable source debugging on AP function + // + EnableDebugAgent (); + // // Invoke AP function here // Procedure (Parameter); diff --git a/UefiCpuPkg/Library/MpInitLib/MpLib.h b/UefiCpuPkg/Library/MpInitLib/MpLib.h index 9861a5c859..b67ea9d11f 100644 --- a/UefiCpuPkg/Library/MpInitLib/MpLib.h +++ b/UefiCpuPkg/Library/MpInitLib/MpLib.h @@ -575,5 +575,14 @@ RestoreWakeupBuffer( IN CPU_MP_DATA *CpuMpData ); +/** + Enable Debug Agent to support source debugging on AP function. + +**/ +VOID +EnableDebugAgent ( + VOID + ); + #endif diff --git a/UefiCpuPkg/Library/MpInitLib/PeiMpLib.c b/UefiCpuPkg/Library/MpInitLib/PeiMpLib.c index a4166a4bc6..fb1d48fad8 100644 --- a/UefiCpuPkg/Library/MpInitLib/PeiMpLib.c +++ b/UefiCpuPkg/Library/MpInitLib/PeiMpLib.c @@ -25,6 +25,18 @@ GLOBAL_REMOVE_IF_UNREFERENCED EFI_PEI_NOTIFY_DESCRIPTOR mMpInitLibNotifyList = { CpuMpEndOfPeiCallback }; + +/** + Enable Debug Agent to support source debugging on AP function. + +**/ +VOID +EnableDebugAgent ( + VOID + ) +{ +} + /** Get pointer to CPU MP Data structure. -- 2.39.2