--- /dev/null
+;------------------------------------------------------------------------------\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
+extern ASM_PFX(mTopOfApCommonStack)\r
+extern ASM_PFX(ApEntryPointInC)\r
+\r
+DEFAULT REL\r
+\r
+SECTION .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
+SECTION .text\r
+\r
+;------------------------------------------------------------------------------\r
+; VOID\r
+; EFIAPI\r
+; AsmApEntryPoint (\r
+; VOID\r
+; );\r
+;------------------------------------------------------------------------------\r
+global ASM_PFX(AsmApEntryPoint)\r
+ASM_PFX(AsmApEntryPoint):\r
+ cli\r
+AsmApEntryPointAcquireLock:\r
+lock bts dword [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 [ApStackLock], 0\r
+\r
+ mov eax, 0x100\r
+AsmApEntryPointShareLock:\r
+ pause\r
+ dec eax\r
+ jnz AsmApEntryPointShareLock\r
+\r
+ jmp ASM_PFX(AsmApEntryPoint)\r
+\r
+;------------------------------------------------------------------------------\r
+; VOID\r
+; EFIAPI\r
+; AsmApDoneWithCommonStack (\r
+; VOID\r
+; );\r
+;------------------------------------------------------------------------------\r
+global ASM_PFX(AsmApDoneWithCommonStack)\r
+ASM_PFX(AsmApDoneWithCommonStack):\r
+lock btc dword [ApStackLock], 0\r
+ ret\r
+\r