]> git.proxmox.com Git - mirror_edk2.git/blobdiff - UefiCpuPkg/CpuDxe/X64/MpAsm.asm
UefiCpuPkg/CpuDxe: Add stackless assembly AP entry points
[mirror_edk2.git] / UefiCpuPkg / CpuDxe / X64 / MpAsm.asm
diff --git a/UefiCpuPkg/CpuDxe/X64/MpAsm.asm b/UefiCpuPkg/CpuDxe/X64/MpAsm.asm
new file mode 100644 (file)
index 0000000..308de51
--- /dev/null
@@ -0,0 +1,76 @@
+;------------------------------------------------------------------------------\r
+;\r
+; Copyright (c) 2006 - 2014, 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
+; http://opensource.org/licenses/bsd-license.php.\r
+;\r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+#include <Base.h>\r
+\r
+extern ASM_PFX(mTopOfApCommonStack):QWORD\r
+extern ASM_PFX(ApEntryPointInC):PROC\r
+\r
+.data\r
+\r
+;\r
+; This lock only allows one AP to use the mTopOfApCommonStack stack at a time\r
+;\r
+ApStackLock:\r
+    dd      0\r
+\r
+.code\r
+\r
+;------------------------------------------------------------------------------\r
+; VOID\r
+; EFIAPI\r
+; AsmApEntryPoint (\r
+;   VOID\r
+;   );\r
+;------------------------------------------------------------------------------\r
+ASM_PFX(AsmApEntryPoint) PROC PUBLIC\r
+\r
+    cli\r
+AsmApEntryPointAcquireLock:\r
+lock bts    dword ptr [ApStackLock], 0\r
+    pause\r
+    jc      AsmApEntryPointAcquireLock\r
+\r
+    mov     rsp, [ASM_PFX(mTopOfApCommonStack)]\r
+    call    ASM_PFX(ApEntryPointInC)\r
+\r
+    cli\r
+\r
+lock btc    dword ptr [ApStackLock], 0\r
+\r
+    mov     eax, 100h\r
+AsmApEntryPointShareLock:\r
+    pause\r
+    dec     eax\r
+    jnz     AsmApEntryPointShareLock\r
+\r
+    jmp     ASM_PFX(AsmApEntryPoint)\r
+\r
+ASM_PFX(AsmApEntryPoint) ENDP\r
+\r
+;------------------------------------------------------------------------------\r
+; VOID\r
+; EFIAPI\r
+; AsmApDoneWithCommonStack (\r
+;   VOID\r
+;   );\r
+;------------------------------------------------------------------------------\r
+ASM_PFX(AsmApDoneWithCommonStack) PROC PUBLIC\r
+\r
+lock btc    dword ptr [ApStackLock], 0\r
+    ret\r
+\r
+ASM_PFX(AsmApDoneWithCommonStack) ENDP\r
+\r
+END\r
+\r