After the HLT instruction stops the execution of AP, an
enabled interrupt will resume execution. including including NMI
and SMI, here we introduce NMI interrupt to wake up AP with
hlt state.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Chen Fan <chen.fan.f...@cn.fujitsu.com>
---
 UefiCpuPkg/Include/Library/LocalApicLib.h           | 16 +++++++++++++++-
 UefiCpuPkg/Library/BaseXApicLib/BaseXApicLib.c      | 21 +++++++++++++++++++++
 .../Library/BaseXApicX2ApicLib/BaseXApicX2ApicLib.c | 21 +++++++++++++++++++++
 3 files changed, 57 insertions(+), 1 deletion(-)

diff --git a/UefiCpuPkg/Include/Library/LocalApicLib.h 
b/UefiCpuPkg/Include/Library/LocalApicLib.h
index b92b99e..887b2b4 100644
--- a/UefiCpuPkg/Include/Library/LocalApicLib.h
+++ b/UefiCpuPkg/Include/Library/LocalApicLib.h
@@ -396,6 +396,20 @@ GetApicMsiValue (
   IN BOOLEAN  LevelTriggered,
   IN BOOLEAN  AssertionLevel
   );
-  
+
+/**
+  Send a NMI IPI to a specified target processor.
+
+  This function returns after the IPI has been accepted by the target 
processor.
+
+  @param  ApicId   Specify the local APIC ID of the target processor.
+
+**/
+VOID
+EFIAPI
+SendNmiIpi (
+  IN UINT32          ApicId
+  );
+
 #endif
 
diff --git a/UefiCpuPkg/Library/BaseXApicLib/BaseXApicLib.c 
b/UefiCpuPkg/Library/BaseXApicLib/BaseXApicLib.c
index 6f8cd2e..a8a729d 100644
--- a/UefiCpuPkg/Library/BaseXApicLib/BaseXApicLib.c
+++ b/UefiCpuPkg/Library/BaseXApicLib/BaseXApicLib.c
@@ -852,3 +852,24 @@ GetApicMsiValue (
   }
   return MsiData.Uint64;
 }
+
+/**
+  Send a NMI IPI to a specified target processor.
+
+  This function returns after the IPI has been accepted by the target 
processor.
+
+  @param  ApicId   Specify the local APIC ID of the target processor.
+**/
+VOID
+EFIAPI
+SendNmiIpi (
+  IN UINT32          ApicId
+  )
+{
+  LOCAL_APIC_ICR_LOW IcrLow;
+
+  IcrLow.Uint32 = 0;
+  IcrLow.Bits.DeliveryMode = LOCAL_APIC_DELIVERY_MODE_NMI;
+  IcrLow.Bits.Level = 1;
+  SendIpi (IcrLow.Uint32, ApicId);
+}
diff --git a/UefiCpuPkg/Library/BaseXApicX2ApicLib/BaseXApicX2ApicLib.c 
b/UefiCpuPkg/Library/BaseXApicX2ApicLib/BaseXApicX2ApicLib.c
index bf318e0..2119852 100644
--- a/UefiCpuPkg/Library/BaseXApicX2ApicLib/BaseXApicX2ApicLib.c
+++ b/UefiCpuPkg/Library/BaseXApicX2ApicLib/BaseXApicX2ApicLib.c
@@ -938,3 +938,24 @@ GetApicMsiValue (
   }
   return MsiData.Uint64;
 }
+
+/**
+  Send a NMI IPI to a specified target processor.
+
+  This function returns after the IPI has been accepted by the target 
processor.
+
+  @param  ApicId   Specify the local APIC ID of the target processor.
+**/
+VOID
+EFIAPI
+SendNmiIpi (
+  IN UINT32          ApicId
+  )
+{
+  LOCAL_APIC_ICR_LOW IcrLow;
+
+  IcrLow.Uint32 = 0;
+  IcrLow.Bits.DeliveryMode = LOCAL_APIC_DELIVERY_MODE_NMI;
+  IcrLow.Bits.Level = 1;
+  SendIpi (IcrLow.Uint32, ApicId);
+}
-- 
1.9.3


------------------------------------------------------------------------------
Dive into the World of Parallel Programming. The Go Parallel Website,
sponsored by Intel and developed in partnership with Slashdot Media, is your
hub for all things parallel software development, from weekly thought
leadership blogs to news, videos, case studies, tutorials and more. Take a
look and join the conversation now. http://goparallel.sourceforge.net/
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/edk2-devel

Reply via email to