]> git.proxmox.com Git - mirror_edk2.git/blobdiff - SourceLevelDebugPkg/Library/DebugAgent/DebugAgentCommon/DebugMp.c
SourceLevelDebugPkg DebugAgentLib: Rename IsBsp to DebugAgentIsBsp
[mirror_edk2.git] / SourceLevelDebugPkg / Library / DebugAgent / DebugAgentCommon / DebugMp.c
index 6ae9deef10c78cc3662c2e19b0890abc4be78bf1..e3ed08db4946487cb0ec50c657b4d5e2de67dc89 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Multi-Processor support functions implementation.\r
 \r
-  Copyright (c) 2010 - 2014, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2010 - 2018, Intel Corporation. All rights reserved.<BR>\r
   This program and the accompanying materials\r
   are licensed and made available under the terms and conditions of the BSD License\r
   which accompanies this distribution.  The full text of the license may be found at\r
@@ -75,7 +75,7 @@ HaltOtherProcessors (
   )\r
 {\r
   DebugAgentMsgPrint (DEBUG_AGENT_INFO, "processor[%x]:Try to halt other processors.\n", CurrentProcessorIndex);\r
-  if (!IsBsp (CurrentProcessorIndex)) {\r
+  if (!DebugAgentIsBsp (CurrentProcessorIndex)) {\r
     SetIpiSentByApFlag (TRUE);;\r
   }\r
 \r
@@ -137,11 +137,23 @@ GetProcessorIndex (
 \r
 **/\r
 BOOLEAN\r
-IsBsp (\r
-  IN UINT32             ProcessorIndex\r
+DebugAgentIsBsp (\r
+  IN UINT32  ProcessorIndex\r
   )\r
 {\r
-  if (AsmMsrBitFieldRead64 (MSR_IA32_APIC_BASE_ADDRESS, 8, 8) == 1) {\r
+  MSR_IA32_APIC_BASE_REGISTER  MsrApicBase;\r
+  \r
+  //\r
+  // If there are less than 2 CPUs detected, then the currently executing CPU\r
+  // must be the BSP.  This avoids an access to an MSR that may not be supported \r
+  // on single core CPUs.\r
+  //\r
+  if (mDebugCpuData.CpuCount < 2) {\r
+    return TRUE;\r
+  }\r
+\r
+  MsrApicBase.Uint64 = AsmReadMsr64 (MSR_IA32_APIC_BASE);\r
+  if (MsrApicBase.Bits.BSP == 1) {\r
     if (mDebugMpContext.BspIndex != ProcessorIndex) {\r
       AcquireMpSpinLock (&mDebugMpContext.MpContextSpinLock);\r
       mDebugMpContext.BspIndex = ProcessorIndex;\r