]> git.proxmox.com Git - mirror_edk2.git/blobdiff - UefiCpuPkg/CpuDxe/Ia32/MpAsm.asm
UefiCpuPkg/CpuDxe: Add stackless assembly AP entry points
[mirror_edk2.git] / UefiCpuPkg / CpuDxe / Ia32 / MpAsm.asm
diff --git a/UefiCpuPkg/CpuDxe/Ia32/MpAsm.asm b/UefiCpuPkg/CpuDxe/Ia32/MpAsm.asm
new file mode 100644 (file)
index 0000000..d476829
--- /dev/null
@@ -0,0 +1,75 @@
+;------------------------------------------------------------------------------\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
+.586p\r
+.model flat, C\r
+\r
+extern mTopOfApCommonStack:DWORD\r
+extern ApEntryPointInC:PROC\r
+\r
+.code\r
+\r
+;\r
+; This lock only allows one AP to use the mTopOfApCommonStack stack at a time\r
+;\r
+ApStackLock dd      0\r
+\r
+;.code\r
+\r
+;------------------------------------------------------------------------------\r
+; VOID\r
+; EFIAPI\r
+; AsmApEntryPoint (\r
+;   VOID\r
+;   );\r
+;------------------------------------------------------------------------------\r
+AsmApEntryPoint PROC\r
+\r
+    cli\r
+AsmApEntryPointAcquireLock:\r
+lock bts    dword ptr [ApStackLock], 0\r
+    pause\r
+    jc      AsmApEntryPointAcquireLock\r
+\r
+    mov     esp, [mTopOfApCommonStack]\r
+    call    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     AsmApEntryPoint\r
+\r
+AsmApEntryPoint ENDP\r
+\r
+;------------------------------------------------------------------------------\r
+; VOID\r
+; EFIAPI\r
+; AsmApDoneWithCommonStack (\r
+;   VOID\r
+;   );\r
+;------------------------------------------------------------------------------\r
+AsmApDoneWithCommonStack PROC PUBLIC\r
+\r
+lock btc    dword ptr [ApStackLock], 0\r
+    ret\r
+\r
+AsmApDoneWithCommonStack ENDP\r
+\r
+END\r