]> git.proxmox.com Git - mirror_edk2.git/commitdiff
InOsEmuPkg: Unix emulator now compiles for IA-32.
authorandrewfish <andrewfish@6f19259b-4bc3-4df7-8a09-765794883524>
Sat, 18 Jun 2011 17:53:31 +0000 (17:53 +0000)
committerandrewfish <andrewfish@6f19259b-4bc3-4df7-8a09-765794883524>
Sat, 18 Jun 2011 17:53:31 +0000 (17:53 +0000)
Wrote IA-32 (align stack to 16-bytes) gaskets for emulator and got it to compile for IA-32. TempRam switch code is not ported to IA-32 in Sec. Code crashes in Sec.

Signed-off-by: andrewfish
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@11849 6f19259b-4bc3-4df7-8a09-765794883524

InOsEmuPkg/Sec/Ia32/SwitchRam.S [new file with mode: 0644]
InOsEmuPkg/Sec/Sec.inf
InOsEmuPkg/Unix/Sec/Ia32/Gasket.S [new file with mode: 0644]
InOsEmuPkg/Unix/Sec/Ia32/SwitchStack.c [new file with mode: 0644]
InOsEmuPkg/Unix/Sec/SecMain.c
InOsEmuPkg/Unix/Sec/SecMain.inf
InOsEmuPkg/Unix/UnixX64.dsc
InOsEmuPkg/Unix/build.sh [new file with mode: 0755]

diff --git a/InOsEmuPkg/Sec/Ia32/SwitchRam.S b/InOsEmuPkg/Sec/Ia32/SwitchRam.S
new file mode 100644 (file)
index 0000000..abb8e7d
--- /dev/null
@@ -0,0 +1,103 @@
+#------------------------------------------------------------------------------\r
+#\r
+# Copyright (c) 2007, 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
+# Module Name:\r
+#\r
+#   Stack.asm\r
+#\r
+# Abstract:\r
+#\r
+#   Switch the stack from temporary memory to permenent memory.\r
+#\r
+#------------------------------------------------------------------------------\r
+\r
+ .text\r
\r
+\r
+//  EFI_STATUS\r
+//  EFIAPI\r
+//  SecTemporaryRamSupport (\r
+//    IN CONST EFI_PEI_SERVICES   **PeiServices,         // %rcx\r
+//    IN EFI_PHYSICAL_ADDRESS     TemporaryMemoryBase,   // %rdx\r
+//    IN EFI_PHYSICAL_ADDRESS     PermanentMemoryBase,   // %r8 \r
+//    IN UINTN                    CopySize               // %r9\r
+//    )\r
+//\r
+ASM_GLOBAL ASM_PFX(SecTemporaryRamSupport)\r
+ASM_PFX(SecTemporaryRamSupport):\r
+//------------------------------------------------------------------------------\r
+// VOID\r
+// EFIAPI\r
+// SecSwitchStack (\r
+//   UINT32   TemporaryMemoryBase,\r
+//   UINT32   PermenentMemoryBase\r
+//   )//\r
+//------------------------------------------------------------------------------    \r
+\r
+    //\r
+    // Save three register: eax, ebx, ecx\r
+    //\r
+    push  %eax\r
+    push  %ebx\r
+    push  %ecx\r
+    push  %edx\r
+\r
+#if 0    \r
+// Port me to GAS syntax\r
+    //\r
+    // !!CAUTION!! this function addresss is pushed into stack after\r
+    // migration of whole temporary memory, so need save it to permenent\r
+    // memory at first!\r
+    //\r
+    \r
+    mov   ebx, [esp + 20]          // Save the first parameter\r
+    mov   ecx, [esp + 24]          // Save the second parameter\r
+    \r
+    //\r
+    // Save this functions return address into permenent memory at first.\r
+    // Then, Fixup the esp point to permenent memory\r
+    //\r
+    mov   eax, esp\r
+    sub   eax, ebx\r
+    add   eax, ecx\r
+    mov   edx, dword ptr [esp]         // copy pushed registers value to permenent memory\r
+    mov   dword ptr [eax], edx    \r
+    mov   edx, dword ptr [esp + 4]\r
+    mov   dword ptr [eax + 4], edx    \r
+    mov   edx, dword ptr [esp + 8]\r
+    mov   dword ptr [eax + 8], edx    \r
+    mov   edx, dword ptr [esp + 12]\r
+    mov   dword ptr [eax + 12], edx    \r
+    mov   edx, dword ptr [esp + 16]    // Update this functions return address into permenent memory\r
+    mov   dword ptr [eax + 16], edx    \r
+    mov   esp, eax                     // From now, esp is pointed to permenent memory\r
+        \r
+    //\r
+    // Fixup the ebp point to permenent memory\r
+    //\r
+    mov   eax, ebp\r
+    sub   eax, ebx\r
+    add   eax, ecx\r
+    mov   ebp, eax                // From now, ebp is pointed to permenent memory\r
+    \r
+    //\r
+    // Fixup callees ebp point for PeiDispatch\r
+    //\r
+    mov   eax, dword ptr [ebp]\r
+    sub   eax, ebx\r
+    add   eax, ecx\r
+    mov   dword ptr [ebp], eax    // From now, Temporarys PPI callers stack is in permenent memory\r
+#endif\r
+    pop   %edx\r
+    pop   %ecx\r
+    pop   %ebx\r
+    pop   %eax\r
+    ret\r
index c263f9db2bce5504d0d43ee4bcd6239486a0d4b7..5d875b55b57c955197483aa526f79da517ebfeec 100644 (file)
@@ -28,6 +28,9 @@
 [Sources.X64]\r
   X64/SwitchRam.S\r
 \r
+[Sources.IA32]\r
+  Ia32/SwitchRam.S\r
+\r
 [Packages]\r
   MdePkg/MdePkg.dec\r
   InOsEmuPkg/InOsEmuPkg.dec\r
diff --git a/InOsEmuPkg/Unix/Sec/Ia32/Gasket.S b/InOsEmuPkg/Unix/Sec/Ia32/Gasket.S
new file mode 100644 (file)
index 0000000..227be54
--- /dev/null
@@ -0,0 +1,1505 @@
+#------------------------------------------------------------------------------
+#
+# Manage differenced between UNIX ABI and EFI/Windows ABI
+#
+# For IA-32 the only difference is Mac OS X requires a 16-byte aligned stack.
+# For Linux this stack adjustment is a no-op, but we may as well make the 
+# the code common. 
+#
+# Copyright (c) 2008 - 2011, Apple Inc. All rights reserved.<BR>
+# This program and the accompanying materials
+# are licensed and made available under the terms and conditions of the BSD License
+# which accompanies this distribution.  The full text of the license may be found at
+# http://opensource.org/licenses/bsd-license.php
+#
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+#
+#------------------------------------------------------------------------------
+
+
+  .text
+  
+//
+// EMU_THUNK_PROTOCOL gaskets (EFIAPI to UNIX ABI)
+//
+
+
+ASM_GLOBAL ASM_PFX(GasketSecWriteStdErr) 
+ASM_PFX(GasketSecWriteStdErr):
+  pushl %ebp
+  movl  %esp, %ebp
+  subl  $24, %esp      // sub extra 16 from the stack for alignment
+  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
+  movl  12(%ebp), %eax
+  movl  %eax, 4(%esp)
+  movl  8(%ebp), %eax
+  movl  %eax, (%esp)
+
+  call  ASM_PFX(SecWriteStdErr)
+
+  addl  $24, %esp
+  popl  %ebp
+  ret
+
+
+ASM_GLOBAL ASM_PFX(GasketSecConfigStdIn) 
+ASM_PFX(GasketSecConfigStdIn):
+  pushl %ebp
+  movl  %esp, %ebp
+  subl  $24, %esp      // sub extra 16 from the stack for alignment
+  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
+  movl  12(%ebp), %eax
+  movl  %eax, 4(%esp)
+  movl  8(%ebp), %eax
+  movl  %eax, (%esp)
+
+  call  ASM_PFX(SecConfigStdIn)
+  
+  addl  $24, %esp
+  popl  %ebp
+  ret
+
+ASM_GLOBAL ASM_PFX(GasketSecWriteStdOut) 
+ASM_PFX(GasketSecWriteStdOut):
+  pushl %ebp
+  movl  %esp, %ebp
+  subl  $24, %esp      // sub extra 16 from the stack for alignment
+  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
+  movl  12(%ebp), %eax
+  movl  %eax, 4(%esp)
+  movl  8(%ebp), %eax
+  movl  %eax, (%esp)
+
+  call  ASM_PFX(SecWriteStdOut)
+  
+  addl  $24, %esp
+  popl  %ebp
+  ret
+
+ASM_GLOBAL ASM_PFX(GasketSecReadStdIn)  
+ASM_PFX(GasketSecReadStdIn):
+  pushl %ebp
+  movl  %esp, %ebp
+  subl  $24, %esp      // sub extra 16 from the stack for alignment
+  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
+  movl  12(%ebp), %eax
+  movl  %eax, 4(%esp)
+  movl  8(%ebp), %eax
+  movl  %eax, (%esp)
+
+  call  ASM_PFX(SecReadStdIn)
+  
+  addl  $24, %esp
+  popl  %ebp
+  ret
+
+ASM_GLOBAL ASM_PFX(GasketSecPollStdIn)  
+ASM_PFX(GasketSecPollStdIn):
+  pushl %ebp
+  movl  %esp, %ebp
+  subl  $24, %esp      // sub extra 16 from the stack for alignment
+  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
+  movl  12(%ebp), %eax
+  movl  %eax, 4(%esp)
+  movl  8(%ebp), %eax
+  movl  %eax, (%esp)
+
+  call  ASM_PFX(SecPollStdIn)
+  
+  addl  $24, %esp
+  popl  %ebp
+  ret
+
+
+ASM_GLOBAL ASM_PFX(GasketSecSetTimer) 
+ASM_PFX(GasketSecSetTimer):
+  pushl %ebp
+  movl  %esp, %ebp
+  subl  $24, %esp      // sub extra 16 from the stack for alignment
+  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
+  movl  12(%ebp), %eax
+  movl  %eax, 4(%esp)
+  movl  8(%ebp), %eax
+  movl  %eax, (%esp)
+
+  call  ASM_PFX(SecSetTimer)
+  
+  addl  $24, %esp
+  popl  %ebp
+  ret
+
+
+ASM_GLOBAL ASM_PFX(GasketSecEnableInterrupt) 
+ASM_PFX(GasketSecEnableInterrupt):
+  pushl %ebp
+  movl  %esp, %ebp
+  subl  $24, %esp      // sub extra 16 from the stack for alignment
+  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
+
+  call    ASM_PFX(SecEnableInterrupt)
+  
+  addl  $24, %esp
+  popl  %ebp
+  ret
+
+
+ASM_GLOBAL ASM_PFX(GasketSecDisableInterrupt) 
+ASM_PFX(GasketSecDisableInterrupt):
+  pushl %ebp
+  movl  %esp, %ebp
+  subl  $24, %esp      // sub extra 16 from the stack for alignment
+  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
+
+  call    ASM_PFX(SecDisableInterrupt)
+  
+  addl  $24, %esp
+  popl  %ebp
+  ret
+
+ASM_GLOBAL ASM_PFX(GasketQueryPerformanceFrequency) 
+ASM_PFX(GasketQueryPerformanceFrequency):
+  pushl %ebp
+  movl  %esp, %ebp
+  subl  $24, %esp      // sub extra 16 from the stack for alignment
+  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
+
+  call    ASM_PFX(QueryPerformanceFrequency)
+  
+  addl  $24, %esp
+  popl  %ebp
+  ret
+
+
+ASM_GLOBAL ASM_PFX(GasketQueryPerformanceCounter) 
+ASM_PFX(GasketQueryPerformanceCounter):
+  pushl %ebp
+  movl  %esp, %ebp
+  subl  $24, %esp      // sub extra 16 from the stack for alignment
+  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
+
+  call    ASM_PFX(QueryPerformanceCounter)
+  
+  addl  $24, %esp
+  popl  %ebp
+  ret
+
+
+ASM_GLOBAL ASM_PFX(GasketSecSleep) 
+ASM_PFX(GasketSecSleep):
+  pushl %ebp
+  movl  %esp, %ebp
+  subl  $24, %esp      // sub extra 16 from the stack for alignment
+  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
+  movl  8(%ebp), %eax
+  movl  %eax, (%esp)
+
+  call  ASM_PFX(SecSleep)
+  
+  addl  $24, %esp
+  popl  %ebp
+  ret
+  
+   
+ASM_GLOBAL ASM_PFX(GasketSecCpuSleep) 
+ASM_PFX(GasketSecCpuSleep):
+  pushl %ebp
+  movl  %esp, %ebp
+  subl  $24, %esp      // sub extra 16 from the stack for alignment
+  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
+
+  call  ASM_PFX(SecCpuSleep)
+  
+  addl  $24, %esp
+  popl  %ebp
+  ret
+  
+  
+ASM_GLOBAL ASM_PFX(GasketSecExit) 
+ASM_PFX(GasketSecExit):
+  pushl %ebp
+  movl  %esp, %ebp
+  subl  $24, %esp      // sub extra 16 from the stack for alignment
+  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
+  movl  8(%ebp), %eax
+  movl  %eax, (%esp)
+
+  call    ASM_PFX(SecExit)     // Less to do as we will never return to EFI ABI world
+LDEAD_LOOP:
+  jmp  LDEAD_LOOP              // _exit should never return
+
+  
+ASM_GLOBAL ASM_PFX(GasketSecGetTime) 
+ASM_PFX(GasketSecGetTime):
+  pushl %ebp
+  movl  %esp, %ebp
+  subl  $24, %esp      // sub extra 16 from the stack for alignment
+  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
+  movl  12(%ebp), %eax
+  movl  %eax, 4(%esp)
+  movl  8(%ebp), %eax
+  movl  %eax, (%esp)
+
+  call  ASM_PFX(SecGetTime)
+
+  addl  $24, %esp
+  popl  %ebp
+  ret
+
+ASM_GLOBAL ASM_PFX(GasketSecSetTime) 
+ASM_PFX(GasketSecSetTime):
+  pushl %ebp
+  movl  %esp, %ebp
+  subl  $24, %esp      // sub extra 16 from the stack for alignment
+  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
+  movl  12(%ebp), %eax
+  movl  %eax, 4(%esp)
+  movl  8(%ebp), %eax
+  movl  %eax, (%esp)
+
+  call  ASM_PFX(SecSetTime)
+
+  addl  $24, %esp
+  popl  %ebp
+  ret
+
+
+ASM_GLOBAL ASM_PFX(GasketSecGetNextProtocol) 
+ASM_PFX(GasketSecGetNextProtocol):
+       pushl   %ebp
+       movl    %esp, %ebp
+  subl  $40, %esp      // sub extra 16 from the stack for alignment
+  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
+       movl    20(%ebp), %eax
+       movl    %eax, 12(%esp)
+       movl    16(%ebp), %eax
+       movl    %eax, 8(%esp)
+       movl    12(%ebp), %eax
+       movl    %eax, 4(%esp)
+       movl    8(%ebp), %eax
+       movl    %eax, (%esp)
+
+  call    ASM_PFX(SecGetNextProtocol)
+  
+  addl  $40, %esp
+  popl  %ebp
+  ret
+
+// PPIs produced by SEC
+
+ASM_GLOBAL ASM_PFX(GasketSecPeCoffGetEntryPoint) 
+ASM_PFX(GasketSecPeCoffGetEntryPoint):
+  pushl %ebp
+  movl  %esp, %ebp
+  subl  $24, %esp      // sub extra 16 from the stack for alignment
+  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
+  movl  12(%ebp), %eax
+  movl  %eax, 4(%esp)
+  movl  8(%ebp), %eax
+  movl  %eax, (%esp)
+
+  call    ASM_PFX(SecPeCoffGetEntryPoint)
+  
+  addl  $24, %esp
+  popl  %ebp
+  ret
+ASM_GLOBAL ASM_PFX(GasketSecPeCoffRelocateImageExtraAction) 
+ASM_PFX(GasketSecPeCoffRelocateImageExtraAction):
+  pushl %ebp
+  movl  %esp, %ebp
+  subl  $24, %esp      // sub extra 16 from the stack for alignment
+  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
+  movl  8(%ebp), %eax
+  movl  %eax, (%esp)
+
+  call    ASM_PFX(SecPeCoffRelocateImageExtraAction)
+  
+  addl  $24, %esp
+  popl  %ebp
+  ret
+ASM_GLOBAL ASM_PFX(GasketSecPeCoffUnloadImageExtraAction) 
+ASM_PFX(GasketSecPeCoffUnloadImageExtraAction):
+  pushl %ebp
+  movl  %esp, %ebp
+  subl  $24, %esp      // sub extra 16 from the stack for alignment
+  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
+  movl  8(%ebp), %eax
+  movl  %eax, (%esp)
+
+  call    ASM_PFX(SecPeCoffUnloadImageExtraAction)
+  
+  addl  $24, %esp
+  popl  %ebp
+  ret
+
+ASM_GLOBAL ASM_PFX(GasketSecEmuThunkAddress) 
+ASM_PFX(GasketSecEmuThunkAddress):
+  pushl %ebp
+  movl  %esp, %ebp
+  subl  $24, %esp      // sub extra 16 from the stack for alignment
+  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
+
+  call    ASM_PFX(SecEmuThunkAddress)
+  
+  addl  $24, %esp
+  popl  %ebp
+  ret
+
+//
+// Gasket functions for EFI_EMU_UGA_IO_PROTOCOL
+//
+
+ASM_GLOBAL ASM_PFX(GasketX11Size) 
+ASM_PFX(GasketX11Size):
+       pushl   %ebp
+       movl    %esp, %ebp
+  subl  $40, %esp      // sub extra 16 from the stack for alignment
+  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
+       movl    20(%ebp), %eax
+       movl    %eax, 12(%esp)
+       movl    16(%ebp), %eax
+       movl    %eax, 8(%esp)
+       movl    12(%ebp), %eax
+       movl    %eax, 4(%esp)
+       movl    8(%ebp), %eax
+       movl    %eax, (%esp)
+
+  call    ASM_PFX(X11Size)
+  
+  addl  $40, %esp
+  popl  %ebp
+  ret
+
+
+ASM_GLOBAL ASM_PFX(GasketX11CheckKey) 
+ASM_PFX(GasketX11CheckKey):
+  pushl %ebp
+  movl  %esp, %ebp
+  subl  $24, %esp      // sub extra 16 from the stack for alignment
+  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
+  movl  8(%ebp), %eax
+  movl  %eax, (%esp)
+
+  call    ASM_PFX(X11CheckKey)
+  
+  addl  $24, %esp
+  popl  %ebp
+  ret
+
+ASM_GLOBAL ASM_PFX(GasketX11GetKey) 
+ASM_PFX(GasketX11GetKey):
+  pushl %ebp
+  movl  %esp, %ebp
+  subl  $24, %esp      // sub extra 16 from the stack for alignment
+  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
+  movl  12(%ebp), %eax
+  movl  %eax, 4(%esp)
+  movl  8(%ebp), %eax
+  movl  %eax, (%esp)
+
+  call    ASM_PFX(X11GetKey)
+  
+  addl  $24, %esp
+  popl  %ebp
+  ret
+
+
+ASM_GLOBAL ASM_PFX(GasketX11KeySetState) 
+ASM_PFX(GasketX11KeySetState):
+  pushl %ebp
+  movl  %esp, %ebp
+  subl  $24, %esp      // sub extra 16 from the stack for alignment
+  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
+  movl  12(%ebp), %eax
+  movl  %eax, 4(%esp)
+  movl  8(%ebp), %eax
+  movl  %eax, (%esp)
+
+  call    ASM_PFX(X11KeySetState)
+  
+  addl  $24, %esp
+  popl  %ebp
+  ret
+
+  
+ASM_GLOBAL ASM_PFX(GasketX11RegisterKeyNotify) 
+ASM_PFX(GasketX11RegisterKeyNotify):
+       pushl   %ebp
+       movl    %esp, %ebp
+  subl  $40, %esp      // sub extra 16 from the stack for alignment
+  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
+       movl    20(%ebp), %eax
+       movl    %eax, 12(%esp)
+       movl    16(%ebp), %eax
+       movl    %eax, 8(%esp)
+       movl    12(%ebp), %eax
+       movl    %eax, 4(%esp)
+       movl    8(%ebp), %eax
+       movl    %eax, (%esp)
+
+  call    ASM_PFX(X11RegisterKeyNotify)
+  
+  addl  $40, %esp
+  popl  %ebp
+  ret
+
+  
+ASM_GLOBAL ASM_PFX(GasketX11Blt) 
+ASM_PFX(GasketX11Blt):
+       pushl   %ebp
+       movl    %esp, %ebp
+  subl  $40, %esp      // sub extra 16 from the stack for alignment
+  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
+       movl    20(%ebp), %eax
+       movl    %eax, 12(%esp)
+       movl    16(%ebp), %eax
+       movl    %eax, 8(%esp)
+       movl    12(%ebp), %eax
+       movl    %eax, 4(%esp)
+       movl    8(%ebp), %eax
+       movl    %eax, (%esp)
+
+  call    ASM_PFX(X11Blt)
+  
+  addl  $40, %esp
+  popl  %ebp
+  ret
+
+
+ASM_GLOBAL ASM_PFX(GasketX11CheckPointer) 
+ASM_PFX(GasketX11CheckPointer):
+  pushl %ebp
+  movl  %esp, %ebp
+  subl  $24, %esp      // sub extra 16 from the stack for alignment
+  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
+  movl  8(%ebp), %eax
+  movl  %eax, (%esp)
+
+  call    ASM_PFX(X11CheckPointer)
+  
+  addl  $24, %esp
+  popl  %ebp
+  ret
+
+
+ASM_GLOBAL ASM_PFX(GasketX11GetPointerState) 
+ASM_PFX(GasketX11GetPointerState):
+  pushl %ebp
+  movl  %esp, %ebp
+  subl  $24, %esp      // sub extra 16 from the stack for alignment
+  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
+  movl  12(%ebp), %eax
+  movl  %eax, 4(%esp)
+  movl  8(%ebp), %eax
+  movl  %eax, (%esp)
+
+  call    ASM_PFX(X11GetPointerState)
+  
+  addl  $24, %esp
+  popl  %ebp
+  ret
+
+
+ASM_GLOBAL ASM_PFX(GasketX11GraphicsWindowOpen) 
+ASM_PFX(GasketX11GraphicsWindowOpen):
+  pushl %ebp
+  movl  %esp, %ebp
+  subl  $24, %esp      // sub extra 16 from the stack for alignment
+  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
+  movl  8(%ebp), %eax
+  movl  %eax, (%esp)
+
+  call    ASM_PFX(X11GraphicsWindowOpen)
+  
+  addl  $24, %esp
+  popl  %ebp
+  ret
+
+ASM_GLOBAL ASM_PFX(GasketX11GraphicsWindowClose) 
+ASM_PFX(GasketX11GraphicsWindowClose):
+  pushl %ebp
+  movl  %esp, %ebp
+  subl  $24, %esp      // sub extra 16 from the stack for alignment
+  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
+  movl  12(%ebp), %eax
+  movl  %eax, 4(%esp)
+  movl  8(%ebp), %eax
+  movl  %eax, (%esp)
+
+  call    ASM_PFX(X11GraphicsWindowClose)
+  
+  addl  $24, %esp
+  popl  %ebp
+  ret
+
+
+// Pthreads
+
+ASM_GLOBAL ASM_PFX(GasketPthreadMutexLock) 
+ASM_PFX(GasketPthreadMutexLock):
+  pushl %ebp
+  movl  %esp, %ebp
+  subl  $24, %esp      // sub extra 16 from the stack for alignment
+  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
+  movl  8(%ebp), %eax
+  movl  %eax, (%esp)
+
+  call    ASM_PFX(PthreadMutexLock)
+  
+  addl  $24, %esp
+  popl  %ebp
+  ret
+
+
+ASM_GLOBAL ASM_PFX(GasketPthreadMutexUnLock) 
+ASM_PFX(GasketPthreadMutexUnLock):
+  pushl %ebp
+  movl  %esp, %ebp
+  subl  $24, %esp      // sub extra 16 from the stack for alignment
+  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
+  movl  8(%ebp), %eax
+  movl  %eax, (%esp)
+
+  call    ASM_PFX(PthreadMutexUnLock)
+  
+  addl  $24, %esp
+  popl  %ebp
+  ret
+
+ASM_GLOBAL ASM_PFX(GasketPthreadMutexTryLock) 
+ASM_PFX(GasketPthreadMutexTryLock):
+  pushl %ebp
+  movl  %esp, %ebp
+  subl  $24, %esp      // sub extra 16 from the stack for alignment
+  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
+  movl  8(%ebp), %eax
+  movl  %eax, (%esp)
+
+  call    ASM_PFX(PthreadMutexTryLock)
+  
+  addl  $24, %esp
+  popl  %ebp
+  ret
+
+ASM_GLOBAL ASM_PFX(GasketPthreadMutexInit) 
+ASM_PFX(GasketPthreadMutexInit):
+  pushl %ebp
+  movl  %esp, %ebp
+  subl  $24, %esp      // sub extra 16 from the stack for alignment
+  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
+
+  call    ASM_PFX(PthreadMutexInit)
+  
+  addl  $24, %esp
+  popl  %ebp
+  ret
+
+
+ASM_GLOBAL ASM_PFX(GasketPthreadMutexDestroy) 
+ASM_PFX(GasketPthreadMutexDestroy):
+  pushl %ebp
+  movl  %esp, %ebp
+  subl  $24, %esp      // sub extra 16 from the stack for alignment
+  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
+  movl  8(%ebp), %eax
+  movl  %eax, (%esp)
+
+  call    ASM_PFX(PthreadMutexDestroy)
+  
+  addl  $24, %esp
+  popl  %ebp
+  ret
+
+
+ASM_GLOBAL ASM_PFX(GasketPthreadCreate)  
+ASM_PFX(GasketPthreadCreate):
+       pushl   %ebp
+       movl    %esp, %ebp
+  subl  $40, %esp      // sub extra 16 from the stack for alignment
+  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
+       movl    20(%ebp), %eax
+       movl    %eax, 12(%esp)
+       movl    16(%ebp), %eax
+       movl    %eax, 8(%esp)
+       movl    12(%ebp), %eax
+       movl    %eax, 4(%esp)
+       movl    8(%ebp), %eax
+       movl    %eax, (%esp)
+
+  call    ASM_PFX(PthreadCreate)
+  
+  addl  $40, %esp
+  popl  %ebp
+  ret
+
+                          
+ASM_GLOBAL ASM_PFX(GasketPthreadExit) 
+ASM_PFX(GasketPthreadExit):
+  pushl %ebp
+  movl  %esp, %ebp
+  subl  $24, %esp      // sub extra 16 from the stack for alignment
+  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
+  movl  8(%ebp), %eax
+  movl  %eax, (%esp)
+
+  call    ASM_PFX(PthreadExit)
+  
+  addl  $24, %esp
+  popl  %ebp
+  ret
+
+
+                             
+ASM_GLOBAL ASM_PFX(GasketPthreadSelf) 
+ASM_PFX(GasketPthreadSelf):
+  pushl %ebp
+  movl  %esp, %ebp
+  subl  $24, %esp      // sub extra 16 from the stack for alignment
+  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
+
+  call    ASM_PFX(PthreadSelf)
+  
+  addl  $24, %esp
+  popl  %ebp
+  ret
+
+
+ASM_GLOBAL ASM_PFX(GasketPthreadOpen) 
+ASM_PFX(GasketPthreadOpen):
+  pushl %ebp
+  movl  %esp, %ebp
+  subl  $24, %esp      // sub extra 16 from the stack for alignment
+  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
+  movl  8(%ebp), %eax
+  movl  %eax, (%esp)
+
+  call    ASM_PFX(PthreadOpen)
+  
+  addl  $24, %esp
+  popl  %ebp
+  ret
+
+
+ASM_GLOBAL ASM_PFX(GasketPthreadClose)  
+ASM_PFX(GasketPthreadClose):
+  pushl %ebp
+  movl  %esp, %ebp
+  subl  $24, %esp      // sub extra 16 from the stack for alignment
+  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
+  movl  8(%ebp), %eax
+  movl  %eax, (%esp)
+
+  call    ASM_PFX(PthreadClose)
+  
+  addl  $24, %esp
+  popl  %ebp
+  ret
+
+
+
+
+//
+// UNIX ABI to EFI ABI call
+//
+// UINTN
+// ReverseGasketUint64 (
+//   void *Api,
+//   UINTN Arg1
+//   );
+ASM_GLOBAL ASM_PFX(ReverseGasketUint64)
+ASM_PFX(ReverseGasketUint64):
+  pushl %ebp
+  movl  %esp, %ebp        // stack frame is for the debugger
+  subl  $8, %esp
+  movl  12(%ebp), %eax
+  movl  %eax, (%esp)
+  calll *8(%ebp)
+  addl  $8, %esp
+  popl  %ebp
+  ret
+
+//
+// UNIX ABI to EFI ABI call
+//
+// UINTN
+// ReverseGasketUint64Uint64 (
+//   void *Api,
+//   UINTN Arg1
+//   UINTN Arg2
+//   );
+ASM_GLOBAL ASM_PFX(ReverseGasketUint64Uint64)
+ASM_PFX(ReverseGasketUint64Uint64):
+  pushl %ebp
+  movl  %esp, %ebp      // stack frame is for the debugger
+  subl  $8, %esp
+  movl  16(%ebp), %eax
+  movl  %eax, 4(%esp)
+  movl  12(%ebp), %eax
+  movl  %eax, (%esp)
+  calll *8(%ebp)
+  addl  $8, %esp
+  popl  %ebp
+  ret
+  
+
+ASM_GLOBAL ASM_PFX(GasketSecUnixPeiAutoScan)  
+ASM_PFX(GasketSecUnixPeiAutoScan):
+       pushl   %ebp
+       movl    %esp, %ebp
+  subl  $40, %esp      // sub extra 16 from the stack for alignment
+  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
+       movl    16(%ebp), %eax
+       movl    %eax, 8(%esp)
+       movl    12(%ebp), %eax
+       movl    %eax, 4(%esp)
+       movl    8(%ebp), %eax
+       movl    %eax, (%esp)
+
+  call    ASM_PFX(SecUnixPeiAutoScan)
+  
+  addl  $40, %esp
+  popl  %ebp
+  ret
+
+
+ASM_GLOBAL ASM_PFX(GasketSecUnixFdAddress) 
+ASM_PFX(GasketSecUnixFdAddress):
+       pushl   %ebp
+       movl    %esp, %ebp
+  subl  $40, %esp      // sub extra 16 from the stack for alignment
+  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
+       movl    20(%ebp), %eax
+       movl    %eax, 12(%esp)
+       movl    16(%ebp), %eax
+       movl    %eax, 8(%esp)
+       movl    12(%ebp), %eax
+       movl    %eax, 4(%esp)
+       movl    8(%ebp), %eax
+       movl    %eax, (%esp)
+
+  call    ASM_PFX(SecUnixFdAddress)
+
+  addl  $40, %esp
+  popl  %ebp
+  ret
+
+
+// EmuIoThunk SimpleFileSystem
+
+ASM_GLOBAL ASM_PFX(GasketPosixOpenVolume) 
+ASM_PFX(GasketPosixOpenVolume):
+       pushl   %ebp
+       movl    %esp, %ebp
+  subl  $40, %esp      // sub extra 16 from the stack for alignment
+  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
+       movl    20(%ebp), %eax
+       movl    %eax, 12(%esp)
+       movl    16(%ebp), %eax
+       movl    %eax, 8(%esp)
+       movl    12(%ebp), %eax
+       movl    %eax, 4(%esp)
+       movl    8(%ebp), %eax
+       movl    %eax, (%esp)
+
+  call    ASM_PFX(PosixOpenVolume)
+
+  addl  $40, %esp
+  popl  %ebp
+  ret
+
+
+ASM_GLOBAL ASM_PFX(GasketPosixFileOpen) 
+ASM_PFX(GasketPosixFileOpen):
+       pushl   %ebp
+       movl    %esp, %ebp
+  subl  $40, %esp      // sub extra 16 from the stack for alignment
+  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
+       movl    24(%ebp), %eax
+       movl    %eax, 16(%esp)
+       movl    20(%ebp), %eax
+       movl    %eax, 12(%esp)
+       movl    16(%ebp), %eax
+       movl    %eax, 8(%esp)
+       movl    12(%ebp), %eax
+       movl    %eax, 4(%esp)
+       movl    8(%ebp), %eax
+       movl    %eax, (%esp)
+  call    ASM_PFX(PosixFileOpen)
+
+  addl  $40, %esp
+  popl  %ebp
+  ret
+
+
+ASM_GLOBAL ASM_PFX(GasketPosixFileCLose) 
+ASM_PFX(GasketPosixFileCLose):
+  pushl %ebp
+  movl  %esp, %ebp
+  subl  $24, %esp      // sub extra 16 from the stack for alignment
+  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
+  movl  8(%ebp), %eax
+  movl  %eax, (%esp)
+
+  call    ASM_PFX(PosixFileCLose)
+
+  addl  $24, %esp
+  popl  %ebp
+  ret
+
+   
+ASM_GLOBAL ASM_PFX(GasketPosixFileDelete) 
+ASM_PFX(GasketPosixFileDelete):
+  pushl %ebp
+  movl  %esp, %ebp
+  subl  $24, %esp      // sub extra 16 from the stack for alignment
+  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
+  movl  8(%ebp), %eax
+  movl  %eax, (%esp)
+
+  call    ASM_PFX(PosixFileDelete)
+
+  addl  $24, %esp
+  popl  %ebp
+  ret
+
+
+ASM_GLOBAL ASM_PFX(GasketPosixFileRead) 
+ASM_PFX(GasketPosixFileRead):
+       pushl   %ebp
+       movl    %esp, %ebp
+  subl  $40, %esp      // sub extra 16 from the stack for alignment
+  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
+       movl    16(%ebp), %eax
+       movl    %eax, 8(%esp)
+       movl    12(%ebp), %eax
+       movl    %eax, 4(%esp)
+       movl    8(%ebp), %eax
+       movl    %eax, (%esp)
+
+  call    ASM_PFX(PosixFileRead)
+
+  addl  $40, %esp
+  popl  %ebp
+  ret
+
+  
+ASM_GLOBAL ASM_PFX(GasketPosixFileWrite) 
+ASM_PFX(GasketPosixFileWrite):
+       pushl   %ebp
+       movl    %esp, %ebp
+  subl  $40, %esp      // sub extra 16 from the stack for alignment
+  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
+       movl    16(%ebp), %eax
+       movl    %eax, 8(%esp)
+       movl    12(%ebp), %eax
+       movl    %eax, 4(%esp)
+       movl    8(%ebp), %eax
+       movl    %eax, (%esp)
+
+  call    ASM_PFX(PosixFileWrite)
+
+  addl  $40, %esp
+  popl  %ebp
+  ret
+
+
+ASM_GLOBAL ASM_PFX(GasketPosixFileSetPossition) 
+ASM_PFX(GasketPosixFileSetPossition):
+  pushl %ebp
+  movl  %esp, %ebp
+  subl  $24, %esp      // sub extra 16 from the stack for alignment
+  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
+  movl  12(%ebp), %eax
+  movl  %eax, 4(%esp)
+  movl  8(%ebp), %eax
+  movl  %eax, (%esp)
+
+  call    ASM_PFX(PosixFileSetPossition)
+
+  addl  $24, %esp
+  popl  %ebp
+  ret
+
+
+ASM_GLOBAL ASM_PFX(GasketPosixFileGetPossition) 
+ASM_PFX(GasketPosixFileGetPossition):
+  pushl %ebp
+  movl  %esp, %ebp
+  subl  $24, %esp      // sub extra 16 from the stack for alignment
+  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
+  movl  12(%ebp), %eax
+  movl  %eax, 4(%esp)
+  movl  8(%ebp), %eax
+  movl  %eax, (%esp)
+
+  call    ASM_PFX(PosixFileGetPossition)
+
+  addl  $24, %esp
+  popl  %ebp
+  ret
+
+
+ASM_GLOBAL ASM_PFX(GasketPosixFileGetInfo) 
+ASM_PFX(GasketPosixFileGetInfo):
+       pushl   %ebp
+       movl    %esp, %ebp
+  subl  $40, %esp      // sub extra 16 from the stack for alignment
+  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
+       movl    20(%ebp), %eax
+       movl    %eax, 12(%esp)
+       movl    16(%ebp), %eax
+       movl    %eax, 8(%esp)
+       movl    12(%ebp), %eax
+       movl    %eax, 4(%esp)
+       movl    8(%ebp), %eax
+       movl    %eax, (%esp)
+
+  call    ASM_PFX(PosixFileGetInfo)
+
+  addl  $40, %esp
+  popl  %ebp
+  ret
+
+
+ASM_GLOBAL ASM_PFX(GasketPosixFileSetInfo) 
+ASM_PFX(GasketPosixFileSetInfo):
+       pushl   %ebp
+       movl    %esp, %ebp
+  subl  $40, %esp      // sub extra 16 from the stack for alignment
+  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
+       movl    20(%ebp), %eax
+       movl    %eax, 12(%esp)
+       movl    16(%ebp), %eax
+       movl    %eax, 8(%esp)
+       movl    12(%ebp), %eax
+       movl    %eax, 4(%esp)
+       movl    8(%ebp), %eax
+       movl    %eax, (%esp)
+
+  call    ASM_PFX(PosixFileSetInfo)
+
+  addl  $40, %esp
+  popl  %ebp
+  ret
+
+
+ASM_GLOBAL ASM_PFX(GasketPosixFileFlush) 
+ASM_PFX(GasketPosixFileFlush):
+  pushl %ebp
+  movl  %esp, %ebp
+  subl  $24, %esp      // sub extra 16 from the stack for alignment
+  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
+  movl  8(%ebp), %eax
+  movl  %eax, (%esp)
+
+  call    ASM_PFX(PosixFileFlush)
+
+  addl  $24, %esp
+  popl  %ebp
+  ret
+
+
+ASM_GLOBAL ASM_PFX(GasketPosixFileSystmeThunkOpen) 
+ASM_PFX(GasketPosixFileSystmeThunkOpen):
+  pushl %ebp
+  movl  %esp, %ebp
+  subl  $24, %esp      // sub extra 16 from the stack for alignment
+  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
+  movl  8(%ebp), %eax
+  movl  %eax, (%esp)
+
+  call    ASM_PFX(PosixFileSystmeThunkOpen)
+
+  addl  $24, %esp
+  popl  %ebp
+  ret
+
+
+ASM_GLOBAL ASM_PFX(GasketPosixFileSystmeThunkClose) 
+ASM_PFX(GasketPosixFileSystmeThunkClose):
+  pushl %ebp
+  movl  %esp, %ebp
+  subl  $24, %esp      // sub extra 16 from the stack for alignment
+  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
+  movl  8(%ebp), %eax
+  movl  %eax, (%esp)
+
+  call    ASM_PFX(PosixFileSystmeThunkClose)
+
+  addl  $24, %esp
+  popl  %ebp
+  ret
+
+ASM_GLOBAL ASM_PFX(GasketEmuBlockIoReset) 
+ASM_PFX(GasketEmuBlockIoReset):
+  pushl %ebp
+  movl  %esp, %ebp
+  subl  $24, %esp      // sub extra 16 from the stack for alignment
+  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
+  movl  12(%ebp), %eax
+  movl  %eax, 4(%esp)
+  movl  8(%ebp), %eax
+  movl  %eax, (%esp)
+
+  call    ASM_PFX(EmuBlockIoReset)
+
+  addl  $24, %esp
+  popl  %ebp
+  ret
+
+
+ASM_GLOBAL ASM_PFX(GasketEmuBlockIoReadBlocks) 
+ASM_PFX(GasketEmuBlockIoReadBlocks):
+       pushl   %ebp
+       movl    %esp, %ebp
+  subl  $40, %esp      // sub extra 16 from the stack for alignment
+  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
+       movl    28(%ebp), %eax
+       movl    %eax, 20(%esp)
+       movl    24(%ebp), %eax
+       movl    %eax, 16(%esp)
+       movl    20(%ebp), %eax
+       movl    %eax, 12(%esp)
+       movl    16(%ebp), %eax
+       movl    %eax, 8(%esp)
+       movl    12(%ebp), %eax
+       movl    %eax, 4(%esp)
+       movl    8(%ebp), %eax
+       movl    %eax, (%esp)
+
+  call    ASM_PFX(EmuBlockIoReadBlocks)
+
+  addl  $40, %esp
+  popl  %ebp
+  ret
+
+
+ASM_GLOBAL ASM_PFX(GasketEmuBlockIoWriteBlocks)  
+ASM_PFX(GasketEmuBlockIoWriteBlocks):
+       pushl   %ebp
+       movl    %esp, %ebp
+  subl  $40, %esp      // sub extra 16 from the stack for alignment
+  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
+       movl    28(%ebp), %eax
+       movl    %eax, 20(%esp)
+       movl    24(%ebp), %eax
+       movl    %eax, 16(%esp)
+       movl    20(%ebp), %eax
+       movl    %eax, 12(%esp)
+       movl    16(%ebp), %eax
+       movl    %eax, 8(%esp)
+       movl    12(%ebp), %eax
+       movl    %eax, 4(%esp)
+       movl    8(%ebp), %eax
+       movl    %eax, (%esp)
+
+  call    ASM_PFX(EmuBlockIoWriteBlocks)
+
+  addl  $40, %esp
+  popl  %ebp
+  ret
+
+
+ASM_GLOBAL ASM_PFX(GasketEmuBlockIoFlushBlocks)  
+ASM_PFX(GasketEmuBlockIoFlushBlocks):  pushl %ebp
+  movl  %esp, %ebp
+  subl  $24, %esp      // sub extra 16 from the stack for alignment
+  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
+  movl  12(%ebp), %eax
+  movl  %eax, 4(%esp)
+  movl  8(%ebp), %eax
+  movl  %eax, (%esp)
+
+
+  call    ASM_PFX(EmuBlockIoFlushBlocks)
+
+  addl  $24, %esp
+  popl  %ebp
+  ret
+
+
+ASM_GLOBAL ASM_PFX(GasketEmuBlockIoCreateMapping) 
+ASM_PFX(GasketEmuBlockIoCreateMapping):
+  pushl %ebp
+  movl  %esp, %ebp
+  subl  $24, %esp      // sub extra 16 from the stack for alignment
+  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
+  movl  12(%ebp), %eax
+  movl  %eax, 4(%esp)
+  movl  8(%ebp), %eax
+  movl  %eax, (%esp)
+
+  call    ASM_PFX(EmuBlockIoCreateMapping)
+
+  addl  $24, %esp
+  popl  %ebp
+  ret
+
+
+ASM_GLOBAL ASM_PFX(GasketBlockIoThunkOpen)  
+ASM_PFX(GasketBlockIoThunkOpen):
+  pushl %ebp
+  movl  %esp, %ebp
+  subl  $24, %esp      // sub extra 16 from the stack for alignment
+  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
+  movl  8(%ebp), %eax
+  movl  %eax, (%esp)
+
+  call    ASM_PFX(EmuBlockIoThunkOpen)
+
+  addl  $24, %esp
+  popl  %ebp
+  ret
+
+
+ASM_GLOBAL ASM_PFX(GasketBlockIoThunkClose)  
+ASM_PFX(GasketBlockIoThunkClose):
+  pushl %ebp
+  movl  %esp, %ebp
+  subl  $24, %esp      // sub extra 16 from the stack for alignment
+  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
+  movl  8(%ebp), %eax
+  movl  %eax, (%esp)
+
+  call    ASM_PFX(EmuBlockIoThunkClose)
+
+  addl  $24, %esp
+  popl  %ebp
+  ret
+
+
+
+ASM_GLOBAL ASM_PFX(GasketSnpCreateMapping) 
+ASM_PFX(GasketSnpCreateMapping):
+  pushl %ebp
+  movl  %esp, %ebp
+  subl  $24, %esp      // sub extra 16 from the stack for alignment
+  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
+  movl  12(%ebp), %eax
+  movl  %eax, 4(%esp)
+  movl  8(%ebp), %eax
+  movl  %eax, (%esp)
+
+  call    ASM_PFX(EmuSnpCreateMapping)
+
+  addl  $24, %esp
+  popl  %ebp
+  ret
+
+
+ASM_GLOBAL ASM_PFX(GasketSnpStart) 
+ASM_PFX(GasketSnpStart):
+  pushl %ebp
+  movl  %esp, %ebp
+  subl  $24, %esp      // sub extra 16 from the stack for alignment
+  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
+  movl  8(%ebp), %eax
+  movl  %eax, (%esp)
+
+  call    ASM_PFX(EmuSnpStart)
+
+  addl  $24, %esp
+  popl  %ebp
+  ret
+
+
+ASM_GLOBAL ASM_PFX(GasketSnpStop) 
+ASM_PFX(GasketSnpStop):
+  pushl %ebp
+  movl  %esp, %ebp
+  subl  $24, %esp      // sub extra 16 from the stack for alignment
+  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
+  movl  8(%ebp), %eax
+  movl  %eax, (%esp)
+
+  call    ASM_PFX(EmuSnpStop)
+
+  addl  $24, %esp
+  popl  %ebp
+  ret
+
+
+ASM_GLOBAL ASM_PFX(GasketSnpInitialize) 
+ASM_PFX(GasketSnpInitialize):
+       pushl   %ebp
+       movl    %esp, %ebp
+  subl  $40, %esp      // sub extra 16 from the stack for alignment
+  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
+       movl    16(%ebp), %eax
+       movl    %eax, 8(%esp)
+       movl    12(%ebp), %eax
+       movl    %eax, 4(%esp)
+       movl    8(%ebp), %eax
+       movl    %eax, (%esp)
+
+  call    ASM_PFX(EmuSnpInitialize)
+
+  addl  $40, %esp
+  popl  %ebp
+  ret
+
+
+ASM_GLOBAL ASM_PFX(GasketSnpReset)  
+ASM_PFX(GasketSnpReset):
+  pushl %ebp
+  movl  %esp, %ebp
+  subl  $24, %esp      // sub extra 16 from the stack for alignment
+  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
+  movl  12(%ebp), %eax
+  movl  %eax, 4(%esp)
+  movl  8(%ebp), %eax
+  movl  %eax, (%esp)
+
+  call    ASM_PFX(EmuSnpReset)
+
+  addl  $24, %esp
+  popl  %ebp
+  ret
+
+
+ASM_GLOBAL ASM_PFX(GasketSnpShutdown) 
+ASM_PFX(GasketSnpShutdown):
+  pushl %ebp
+  movl  %esp, %ebp
+  subl  $24, %esp      // sub extra 16 from the stack for alignment
+  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
+  movl  8(%ebp), %eax
+  movl  %eax, (%esp)
+
+  call    ASM_PFX(EmuSnpShutdown)
+
+  addl  $24, %esp
+  popl  %ebp
+  ret
+
+
+ASM_GLOBAL ASM_PFX(GasketSnpReceiveFilters)  
+ASM_PFX(GasketSnpReceiveFilters):
+       pushl   %ebp
+       movl    %esp, %ebp
+  subl  $40, %esp      // sub extra 16 from the stack for alignment
+  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
+       movl    28(%ebp), %eax
+       movl    %eax, 20(%esp)
+       movl    24(%ebp), %eax
+       movl    %eax, 16(%esp)
+       movl    20(%ebp), %eax
+       movl    %eax, 12(%esp)
+       movl    16(%ebp), %eax
+       movl    %eax, 8(%esp)
+       movl    12(%ebp), %eax
+       movl    %eax, 4(%esp)
+       movl    8(%ebp), %eax
+       movl    %eax, (%esp)
+
+  call    ASM_PFX(EmuSnpReceiveFilters)
+
+  addl  $40, %esp
+  popl  %ebp
+  ret
+
+
+ASM_GLOBAL ASM_PFX(GasketSnpStationAddress)  
+ASM_PFX(GasketSnpStationAddress):
+       pushl   %ebp
+       movl    %esp, %ebp
+  subl  $40, %esp      // sub extra 16 from the stack for alignment
+  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
+       movl    16(%ebp), %eax
+       movl    %eax, 8(%esp)
+       movl    12(%ebp), %eax
+       movl    %eax, 4(%esp)
+       movl    8(%ebp), %eax
+       movl    %eax, (%esp)
+
+  addl  $40, %esp
+  popl  %ebp
+  ret
+
+
+
+ASM_GLOBAL ASM_PFX(GasketSnpStatistics) 
+ASM_PFX(GasketSnpStatistics):
+       pushl   %ebp
+       movl    %esp, %ebp
+  subl  $40, %esp      // sub extra 16 from the stack for alignment
+  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
+       movl    20(%ebp), %eax
+       movl    %eax, 12(%esp)
+       movl    16(%ebp), %eax
+       movl    %eax, 8(%esp)
+       movl    12(%ebp), %eax
+       movl    %eax, 4(%esp)
+       movl    8(%ebp), %eax
+       movl    %eax, (%esp)
+
+  call    ASM_PFX(EmuSnpStatistics)
+
+  addl  $40, %esp
+  popl  %ebp
+  ret
+
+
+ASM_GLOBAL ASM_PFX(GasketSnpMCastIpToMac) 
+ASM_PFX(GasketSnpMCastIpToMac):
+       pushl   %ebp
+       movl    %esp, %ebp
+  subl  $40, %esp      // sub extra 16 from the stack for alignment
+  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
+       movl    20(%ebp), %eax
+       movl    %eax, 12(%esp)
+       movl    16(%ebp), %eax
+       movl    %eax, 8(%esp)
+       movl    12(%ebp), %eax
+       movl    %eax, 4(%esp)
+       movl    8(%ebp), %eax
+       movl    %eax, (%esp)
+
+  call    ASM_PFX(EmuSnpMCastIpToMac)
+
+  addl  $40, %esp
+  popl  %ebp
+  ret
+
+
+ASM_GLOBAL ASM_PFX(GasketSnpNvData) 
+ASM_PFX(GasketSnpNvData):
+       pushl   %ebp
+       movl    %esp, %ebp
+  subl  $40, %esp      // sub extra 16 from the stack for alignment
+  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
+       movl    24(%ebp), %eax
+       movl    %eax, 16(%esp)
+       movl    20(%ebp), %eax
+       movl    %eax, 12(%esp)
+       movl    16(%ebp), %eax
+       movl    %eax, 8(%esp)
+       movl    12(%ebp), %eax
+       movl    %eax, 4(%esp)
+       movl    8(%ebp), %eax
+       movl    %eax, (%esp)
+
+  call    ASM_PFX(EmuSnpNvData)
+
+  addl  $40, %esp
+  popl  %ebp
+  ret
+
+
+ASM_GLOBAL ASM_PFX(GasketSnpGetStatus) 
+ASM_PFX(GasketSnpGetStatus):
+       pushl   %ebp
+       movl    %esp, %ebp
+  subl  $40, %esp      // sub extra 16 from the stack for alignment
+  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
+       movl    16(%ebp), %eax
+       movl    %eax, 8(%esp)
+       movl    12(%ebp), %eax
+       movl    %eax, 4(%esp)
+       movl    8(%ebp), %eax
+       movl    %eax, (%esp)
+
+  call    ASM_PFX(EmuSnpGetStatus)
+
+  addl  $40, %esp
+  popl  %ebp
+  ret
+
+
+
+ASM_GLOBAL ASM_PFX(GasketSnpTransmit) 
+ASM_PFX(GasketSnpTransmit):
+       pushl   %ebp
+       movl    %esp, %ebp
+  subl  $56, %esp      // sub extra 16 from the stack for alignment
+  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
+       movl    32(%ebp), %eax
+       movl    %eax, 24(%esp)
+       movl    28(%ebp), %eax
+       movl    %eax, 20(%esp)
+       movl    24(%ebp), %eax
+       movl    %eax, 16(%esp)
+       movl    20(%ebp), %eax
+       movl    %eax, 12(%esp)
+       movl    16(%ebp), %eax
+       movl    %eax, 8(%esp)
+       movl    12(%ebp), %eax
+       movl    %eax, 4(%esp)
+       movl    8(%ebp), %eax
+       movl    %eax, (%esp)
+
+  call    ASM_PFX(EmuSnpTransmit)
+
+  addl  $56, %esp
+  popl  %ebp
+  ret
+
+
+
+ASM_GLOBAL ASM_PFX(GasketSnpReceive) 
+ASM_PFX(GasketSnpReceive):
+       pushl   %ebp
+       movl    %esp, %ebp
+  subl  $56, %esp      // sub extra 16 from the stack for alignment
+  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
+       movl    32(%ebp), %eax
+       movl    %eax, 24(%esp)
+       movl    28(%ebp), %eax
+       movl    %eax, 20(%esp)
+       movl    24(%ebp), %eax
+       movl    %eax, 16(%esp)
+       movl    20(%ebp), %eax
+       movl    %eax, 12(%esp)
+       movl    16(%ebp), %eax
+       movl    %eax, 8(%esp)
+       movl    12(%ebp), %eax
+       movl    %eax, 4(%esp)
+       movl    8(%ebp), %eax
+       movl    %eax, (%esp)
+
+  call    ASM_PFX(EmuSnpReceive)
+
+  addl  $24, %esp
+  popl  %ebp
+  ret
+
+
+ASM_GLOBAL ASM_PFX(GasketSnpThunkOpen) 
+ASM_PFX(GasketSnpThunkOpen):
+  pushl %ebp
+  movl  %esp, %ebp
+  subl  $24, %esp      // sub extra 16 from the stack for alignment
+  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
+  movl  8(%ebp), %eax
+  movl  %eax, (%esp)
+
+  call    ASM_PFX(EmuSnpThunkOpen)
+
+  addl  $24, %esp
+  popl  %ebp
+  ret
+
+
+ASM_GLOBAL ASM_PFX(GasketSnpThunkClose) 
+ASM_PFX(GasketSnpThunkClose):
+  pushl %ebp
+  movl  %esp, %ebp
+  subl  $24, %esp      // sub extra 16 from the stack for alignment
+  and   $-16, %esp    // stack needs to end in 0xFFFFFFF0 before call
+  movl  8(%ebp), %eax
+  movl  %eax, (%esp)
+
+  call    ASM_PFX(EmuSnpThunkClose)
+
+  addl  $24, %esp
+  popl  %ebp
+  ret
+
+
diff --git a/InOsEmuPkg/Unix/Sec/Ia32/SwitchStack.c b/InOsEmuPkg/Unix/Sec/Ia32/SwitchStack.c
new file mode 100644 (file)
index 0000000..c75073a
--- /dev/null
@@ -0,0 +1,74 @@
+/*++
+
+Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
+Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>
+This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution.  The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+--*/
+
+#include "SecMain.h"
+
+
+/**
+  Transfers control to a function starting with a new stack.
+
+  Transfers control to the function specified by EntryPoint using the new stack
+  specified by NewStack and passing in the parameters specified by Context1 and
+  Context2. Context1 and Context2 are optional and may be NULL. The function
+  EntryPoint must never return.
+
+  If EntryPoint is NULL, then ASSERT().
+  If NewStack is NULL, then ASSERT().
+
+  @param  EntryPoint  A pointer to function to call with the new stack.
+  @param  Context1    A pointer to the context to pass into the EntryPoint
+                      function.
+  @param  Context2    A pointer to the context to pass into the EntryPoint
+                      function.
+  @param  NewStack    A pointer to the new stack to use for the EntryPoint
+                      function.
+
+**/
+VOID
+EFIAPI
+PeiSwitchStacks (
+  IN      SWITCH_STACK_ENTRY_POINT  EntryPoint,
+  IN      VOID                      *Context1,  OPTIONAL
+  IN      VOID                      *Context2,  OPTIONAL
+  IN      VOID                      *NewStack
+  )
+{
+  BASE_LIBRARY_JUMP_BUFFER  JumpBuffer;
+  
+  ASSERT (EntryPoint != NULL);
+  ASSERT (NewStack != NULL);
+
+  //
+  // Stack should be aligned with CPU_STACK_ALIGNMENT
+  //
+  ASSERT (((UINTN)NewStack & (CPU_STACK_ALIGNMENT - 1)) == 0);
+
+  JumpBuffer.Eip = (UINTN)EntryPoint;
+  JumpBuffer.Esp = (UINTN)NewStack - sizeof (VOID*);
+  JumpBuffer.Esp -= sizeof (Context1) + sizeof (Context2);
+  ((VOID**)JumpBuffer.Esp)[1] = Context1;
+  ((VOID**)JumpBuffer.Esp)[2] = Context2;
+
+  LongJump (&JumpBuffer, (UINTN)-1);
+  
+
+  //
+  // PeiSwitchStacks () will never return
+  //
+  ASSERT (FALSE);  
+}
+
+
+
index 4b6cb98e839cc137fa6234fcb26168529b24f1d6..807f067cebd9e34473c4d5c58d4642f1174999d2 100644 (file)
@@ -439,7 +439,7 @@ MapFd0 (
   
   // Map the rest of the FD as read/write
   res2 = mmap (
-          (void *)(FixedPcdGet64 (PcdEmuFlashFvRecoveryBase) + FvSize), 
+          (void *)(UINTN)(FixedPcdGet64 (PcdEmuFlashFvRecoveryBase) + FvSize), 
           FileSize - FvSize, 
           PROT_READ | PROT_WRITE | PROT_EXEC, 
           MAP_SHARED,
index a0976efe860e008ce7159e772e763d70044756be..294cf31d26d3fd9adbf31ba04bc21b339b6bfd0c 100644 (file)
@@ -20,7 +20,6 @@
   BASE_NAME                      = SecMain\r
   FILE_GUID                      = 8863C0AD-7724-C84B-88E5-A33B116D1485\r
   MODULE_TYPE                    = USER_DEFINED\r
-#  MODULE_TYPE                    = BASE\r
   VERSION_STRING                 = 1.0\r
 \r
 #\r
   X64/Gasket.S        # convert between Emu x86_64 ABI and EFI X64 ABI\r
   X64/SwitchStack.S\r
 \r
+[Sources.IA32]\r
+  Ia32/Gasket.S       # enforce 16-byte stack alignment for Mac OS X\r
+  Ia32/SwitchStack.c\r
+\r
 \r
 [Packages]\r
   MdePkg/MdePkg.dec\r
index a601c0cbceb70350db4f7269feba24491da0c1c6..79c0ac67ef69a5d26dbea587b8cf0e8779459d2f 100644 (file)
@@ -28,7 +28,7 @@
   PLATFORM_VERSION               = 0.3\r
   DSC_ SPECIFICATION             = 0x00010005\r
   OUTPUT_DIRECTORY               = Build/EmuUnixX64\r
-  SUPPORTED_ARCHITECTURES        = X64\r
+  SUPPORTED_ARCHITECTURES        = X64|IA32\r
   BUILD_TARGETS                  = DEBUG|RELEASE\r
   SKUID_IDENTIFIER               = DEFAULT\r
   FLASH_DEFINITION               = InOsEmuPkg/Unix/UnixX64.fdf\r
 #       generated for it, but the binary will not be put into any firmware volume.\r
 #\r
 ###################################################################################################\r
+\r
+[Components.X64]\r
+  MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf {\r
+    <LibraryClasses>\r
+      # turn off CR3 write so that DXE IPL will not crash emulator\r
+      BaseLib|UnixPkg/Library/UnixBaseLib/UnixBaseLib.inf\r
+  }\r
+\r
+[Components.IA32]\r
+  MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf \r
+\r
 [Components]\r
 !if $(SEC_ONLY)\r
   ##\r
   InOsEmuPkg/FirmwareVolumePei/FirmwareVolumePei.inf\r
   InOsEmuPkg/FlashMapPei/FlashMapPei.inf\r
   InOsEmuPkg/ThunkPpiToProtocolPei/ThunkPpiToProtocolPei.inf\r
-  MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf {\r
-    <LibraryClasses>\r
-      # turn off CR3 write so that DXE IPL will not crash emulator\r
-      BaseLib|UnixPkg/Library/UnixBaseLib/UnixBaseLib.inf\r
-  }\r
 \r
   ##\r
   #  DXE Phase modules\r
diff --git a/InOsEmuPkg/Unix/build.sh b/InOsEmuPkg/Unix/build.sh
new file mode 100755 (executable)
index 0000000..e7e7b33
--- /dev/null
@@ -0,0 +1,129 @@
+#!/bin/bash
+#
+# Copyright (c) 2008 - 2011, Apple Inc. All rights reserved.<BR>
+# Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>
+#
+# This program and the accompanying materials
+# are licensed and made available under the terms and conditions of the BSD License
+# which accompanies this distribution.  The full text of the license may be found at
+# http://opensource.org/licenses/bsd-license.php
+#
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+#
+
+set -e
+shopt -s nocasematch
+
+
+#
+# Setup workspace if it is not set
+#
+if [ -z "$WORKSPACE" ]
+then
+  echo Initializing workspace
+  if [ ! -e `pwd`/edksetup.sh ]
+  then
+    cd ../..
+  fi
+# This version is for the tools in the BaseTools project.
+# this assumes svn pulls have the same root dir
+#  export EDK_TOOLS_PATH=`pwd`/../BaseTools
+# This version is for the tools source in edk2
+  export EDK_TOOLS_PATH=`pwd`/BaseTools
+  echo $EDK_TOOLS_PATH
+  source edksetup.sh BaseTools
+else
+  echo Building from: $WORKSPACE
+fi
+
+#
+# Pick a default tool type for a given OS
+#
+TARGET_TOOLS=MYTOOLS
+UNIXPKG_TOOLS=GCC44
+NETWORK_SUPPORT=
+BUILD_NEW_SHELL=
+BUILD_FAT=
+case `uname` in
+  CYGWIN*) echo Cygwin not fully supported yet. ;;
+  Darwin*)
+      Major=$(uname -r | cut -f 1 -d '.')
+      if [[ $Major == 9 ]]
+      then
+        echo UnixPkg requires Snow Leopard or later OS
+        exit 1
+      else
+        TARGET_TOOLS=XCODE32
+        UNIXPKG_TOOLS=XCLANG
+      fi
+#      NETWORK_SUPPORT="-D NETWORK_SUPPORT"
+      BUILD_NEW_SHELL="-D BUILD_NEW_SHELL"
+      BUILD_FAT="-D BUILD_FAT"
+      ;;
+  Linux*) TARGET_TOOLS=ELFGCC ;;
+
+esac
+
+BUILD_ROOT_ARCH=$WORKSPACE/Build/EmuUnixX64/DEBUG_"$UNIXPKG_TOOLS"/IA32
+
+if  [[ ! -f `which build` || ! -f `which GenFv` ]];
+then
+  # build the tools if they don't yet exist. Bin scheme
+  echo Building tools as they are not in the path
+  make -C $WORKSPACE/BaseTools
+elif [[ ( -f `which build` ||  -f `which GenFv` )  && ! -d  $EDK_TOOLS_PATH/Source/C/bin ]];
+then
+  # build the tools if they don't yet exist. BinWrapper scheme
+  echo Building tools no $EDK_TOOLS_PATH/Source/C/bin directory
+  make -C $WORKSPACE/BaseTools
+else
+  echo using prebuilt tools
+fi
+
+
+for arg in "$@"
+do
+  if [[ $arg == run ]]; then
+    case `uname` in
+      Darwin*)
+        #
+        # On Darwin we can't use dlopen, so we have to load the real PE/COFF images.
+        # This .gdbinit script sets a breakpoint that loads symbols for the PE/COFFEE
+        # images that get loaded in SecMain
+        #
+        cp $WORKSPACE/InOsEmuPkg/Unix/.gdbinit $WORKSPACE/Build/EmuUnixX64/DEBUG_"$UNIXPKG_TOOLS"/IA32
+        ;;
+    esac
+
+    /usr/bin/gdb $BUILD_ROOT_ARCH/SecMain -q -cd=$BUILD_ROOT_ARCH
+    exit
+  fi
+
+  if [[ $arg == cleanall ]]; then
+    make -C $WORKSPACE/BaseTools clean
+    build -p $WORKSPACE/InOsEmuPkg/Unix/UnixX64.dsc -a IA32 -t $TARGET_TOOLS -D SEC_ONLY -n 3 clean
+    build -p $WORKSPACE/InOsEmuPkg/Unix/UnixX64.dsc -a IA32 -t $UNIXPKG_TOOLS -n 3 clean
+    build -p $WORKSPACE/ShellPkg/ShellPkg.dsc -a IA32 -t $UNIXPKG_TOOLS -n 3 clean
+    exit $?
+  fi
+
+  if [[ $arg == clean ]]; then
+    build -p $WORKSPACE/InOsEmuPkg/Unix/UnixX64.dsc -a IA32 -t $TARGET_TOOLS -D SEC_ONLY -n 3 clean
+    build -p $WORKSPACE/InOsEmuPkg/Unix/UnixX64.dsc -a IA32 -t $UNIXPKG_TOOLS -n 3 clean
+    exit $?
+  fi
+
+done
+
+
+#
+# Build the edk2 UnixPkg
+#
+echo $PATH
+echo `which build`
+build -p $WORKSPACE/InOsEmuPkg/Unix/UnixX64.dsc      -a IA32 -t $TARGET_TOOLS -D SEC_ONLY -n 3 $1 $2 $3 $4 $5 $6 $7 $8  modules
+build -p $WORKSPACE/InOsEmuPkg/Unix/UnixX64.dsc      -a IA32 -t $UNIXPKG_TOOLS $NETWORK_SUPPORT $BUILD_NEW_SHELL $BUILD_FAT -n 3 $1 $2 $3 $4 $5 $6 $7 $8
+cp $WORKSPACE/Build/EmuUnixX64/DEBUG_"$TARGET_TOOLS"/IA32/SecMain $WORKSPACE/Build/EmuUnixX64/DEBUG_"$UNIXPKG_TOOLS"/IA32
+exit $?
+