Add AsmGetAddressMap() function to get assembly functions' entry addresses and
the sizes.

Cc: Michael Kinney <michael.d.kin...@intel.com>
Cc: Feng Tian <feng.t...@intel.com>
Cc: Giri P Mudusuru <giri.p.mudus...@intel.com>
Cc: Laszlo Ersek <ler...@redhat.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jeff Fan <jeff....@intel.com>
---
 UefiCpuPkg/Library/MpInitLib/Ia32/MpFuncs.nasm | 17 +++++++++++++++++
 UefiCpuPkg/Library/MpInitLib/MpLib.c           |  5 +++++
 UefiCpuPkg/Library/MpInitLib/MpLib.h           | 23 +++++++++++++++++++++++
 UefiCpuPkg/Library/MpInitLib/X64/MpFuncs.nasm  | 14 ++++++++++++++
 4 files changed, 59 insertions(+)

diff --git a/UefiCpuPkg/Library/MpInitLib/Ia32/MpFuncs.nasm 
b/UefiCpuPkg/Library/MpInitLib/Ia32/MpFuncs.nasm
index a289f24..29d14e2 100644
--- a/UefiCpuPkg/Library/MpInitLib/Ia32/MpFuncs.nasm
+++ b/UefiCpuPkg/Library/MpInitLib/Ia32/MpFuncs.nasm
@@ -192,3 +192,20 @@ HltLoop:
     ret
 AsmRellocateApLoopEnd:
 
+;-------------------------------------------------------------------------------------
+;  AsmGetAddressMap (&AddressMap);
+;-------------------------------------------------------------------------------------
+global ASM_PFX(AsmGetAddressMap)
+ASM_PFX(AsmGetAddressMap):
+    pushad
+    mov        ebp,esp
+
+    mov        ebx,  [ebp + 24h]
+    mov        dword [ebx], RendezvousFunnelProcStart
+    mov        dword [ebx +  4h], Flat32Start - RendezvousFunnelProcStart
+    mov        dword [ebx +  8h], RendezvousFunnelProcEnd - 
RendezvousFunnelProcStart
+    mov        dword [ebx + 0Ch], AsmRellocateApLoopStart
+    mov        dword [ebx + 10h], AsmRellocateApLoopEnd - 
AsmRellocateApLoopStart
+
+    popad
+    ret
diff --git a/UefiCpuPkg/Library/MpInitLib/MpLib.c 
b/UefiCpuPkg/Library/MpInitLib/MpLib.c
index b78f794..506e839 100644
--- a/UefiCpuPkg/Library/MpInitLib/MpLib.c
+++ b/UefiCpuPkg/Library/MpInitLib/MpLib.c
@@ -34,6 +34,11 @@ MpInitLibInitialize (
   VOID
   )
 {
+  MP_ASSEMBLY_ADDRESS_MAP  AddressMap;
+  UINTN                    ApResetVectorSize;
+
+  AsmGetAddressMap (&AddressMap);
+  ApResetVectorSize = AddressMap.RendezvousFunnelSize + sizeof 
(MP_CPU_EXCHANGE_INFO);
   return EFI_SUCCESS;
 }
 
diff --git a/UefiCpuPkg/Library/MpInitLib/MpLib.h 
b/UefiCpuPkg/Library/MpInitLib/MpLib.h
index ffa12af..84f5821 100644
--- a/UefiCpuPkg/Library/MpInitLib/MpLib.h
+++ b/UefiCpuPkg/Library/MpInitLib/MpLib.h
@@ -35,6 +35,16 @@
 #include <Library/MtrrLib.h>
 #include <Library/HobLib.h>
 
+//
+// AP reset code information
+//
+typedef struct {
+  UINT8             *RendezvousFunnelAddress;
+  UINTN             ModeEntryOffset;
+  UINTN             RendezvousFunnelSize;
+  UINT8             *RellocateApLoopFuncAddress;
+  UINTN             RellocateApLoopFuncSize;
+} MP_ASSEMBLY_ADDRESS_MAP;
 
 #pragma pack(1)
 
@@ -81,5 +91,18 @@ VOID
   IN UINTN                   ApTargetCState,
   IN UINTN                   PmCodeSegment
   );
+
+/**
+  Assembly code to get starting address and size of the rendezvous entry for 
APs.
+  Information for fixing a jump instruction in the code is also returned.
+
+  @param[out] AddressMap  Output buffer for address map information.
+**/
+VOID
+EFIAPI
+AsmGetAddressMap (
+  OUT MP_ASSEMBLY_ADDRESS_MAP    *AddressMap
+  );
+
 #endif
 
diff --git a/UefiCpuPkg/Library/MpInitLib/X64/MpFuncs.nasm 
b/UefiCpuPkg/Library/MpInitLib/X64/MpFuncs.nasm
index ff413be..7436705 100644
--- a/UefiCpuPkg/Library/MpInitLib/X64/MpFuncs.nasm
+++ b/UefiCpuPkg/Library/MpInitLib/X64/MpFuncs.nasm
@@ -229,3 +229,17 @@ HltLoop:
     ret
 BITS 64
 AsmRellocateApLoopEnd:
+
+;-------------------------------------------------------------------------------------
+;  AsmGetAddressMap (&AddressMap);
+;-------------------------------------------------------------------------------------
+global ASM_PFX(AsmGetAddressMap)
+ASM_PFX(AsmGetAddressMap):
+    mov        rax, ASM_PFX(RendezvousFunnelProc)
+    mov        qword [rcx], rax
+    mov        qword [rcx +  8h], LongModeStart - RendezvousFunnelProcStart
+    mov        qword [rcx + 10h], RendezvousFunnelProcEnd - 
RendezvousFunnelProcStart
+    mov        rax, ASM_PFX(AsmRellocateApLoop)
+    mov        qword [rcx + 18h], rax
+    mov        qword [rcx + 20h], AsmRellocateApLoopEnd - 
AsmRellocateApLoopStart
+    ret
-- 
2.7.4.windows.1

_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel

Reply via email to