]> git.proxmox.com Git - mirror_edk2.git/blobdiff - UefiCpuPkg/Library/MpInitLib/DxeMpLib.c
UefiCpuPkg/MpInitLib: needn't to allocate AP reset vector
[mirror_edk2.git] / UefiCpuPkg / Library / MpInitLib / DxeMpLib.c
index e75c26930db3b12a07d996e627efdd3a6e00a8ab..b393244e0582a369f884fc89176037024509b2e4 100644 (file)
@@ -16,6 +16,9 @@
 \r
 #include <Library/UefiLib.h>\r
 #include <Library/UefiBootServicesTableLib.h>\r
+#include <Library/DebugAgentLib.h>\r
+\r
+#include <Protocol/Timer.h>\r
 \r
 #define  AP_CHECK_INTERVAL     (EFI_TIMER_PERIOD_MILLISECONDS (100))\r
 #define  AP_SAFE_STACK_SIZE    128\r
@@ -29,6 +32,21 @@ VOID             *mReservedApLoopFunc = NULL;
 UINTN            mReservedTopOfApStack;\r
 volatile UINT32  mNumberToFinish = 0;\r
 \r
+/**\r
+  Enable Debug Agent to support source debugging on AP function.\r
+\r
+**/\r
+VOID\r
+EnableDebugAgent (\r
+  VOID\r
+  )\r
+{\r
+  //\r
+  // Initialize Debug Agent to support source level debug in DXE phase\r
+  //\r
+  InitializeDebugAgent (DEBUG_AGENT_INIT_DXE_AP, NULL, NULL);\r
+}\r
+\r
 /**\r
   Get the pointer to CPU MP Data structure.\r
 \r
@@ -629,29 +647,38 @@ MpInitLibSwitchBSP (
   IN BOOLEAN                   EnableOldBSP\r
   )\r
 {\r
-  EFI_STATUS            Status;\r
-  BOOLEAN               OldInterruptState;\r
+  EFI_STATUS                   Status;\r
+  EFI_TIMER_ARCH_PROTOCOL      *Timer;\r
+  UINT64                       TimerPeriod;\r
 \r
+  TimerPeriod = 0;\r
   //\r
-  // Before send both BSP and AP to a procedure to exchange their roles,\r
-  // interrupt must be disabled. This is because during the exchange role\r
-  // process, 2 CPU may use 1 stack. If interrupt happens, the stack will\r
-  // be corrupted, since interrupt return address will be pushed to stack\r
-  // by hardware.\r
+  // Locate Timer Arch Protocol\r
   //\r
-  OldInterruptState = SaveAndDisableInterrupts ();\r
+  Status = gBS->LocateProtocol (&gEfiTimerArchProtocolGuid, NULL, (VOID **) &Timer);\r
+  if (EFI_ERROR (Status)) {\r
+    Timer = NULL;\r
+  }\r
 \r
-  //\r
-  // Mask LINT0 & LINT1 for the old BSP\r
-  //\r
-  DisableLvtInterrupts ();\r
+  if (Timer != NULL) {\r
+    //\r
+    // Save current rate of DXE Timer\r
+    //\r
+    Timer->GetTimerPeriod (Timer, &TimerPeriod);\r
+    //\r
+    // Disable DXE Timer and drain pending interrupts\r
+    //\r
+    Timer->SetTimerPeriod (Timer, 0);\r
+  }\r
 \r
   Status = SwitchBSPWorker (ProcessorNumber, EnableOldBSP);\r
 \r
-  //\r
-  // Restore interrupt state.\r
-  //\r
-  SetInterruptState (OldInterruptState);\r
+  if (Timer != NULL) {\r
+    //\r
+    // Enable and restore rate of DXE Timer\r
+    //\r
+    Timer->SetTimerPeriod (Timer, TimerPeriod);\r
+  }\r
 \r
   return Status;\r
 }\r