diff options
author | andrewfish <andrewfish@6f19259b-4bc3-4df7-8a09-765794883524> | 2011-06-18 17:53:31 +0000 |
---|---|---|
committer | andrewfish <andrewfish@6f19259b-4bc3-4df7-8a09-765794883524> | 2011-06-18 17:53:31 +0000 |
commit | 112a857f61378fe7b37a938fc37e95addb328318 (patch) | |
tree | 3ebf4a64995e31d732d183810ad029ee8d0279ec /InOsEmuPkg/Unix | |
parent | 2a5c4680269cefa6555abae13d09f1a5358c83c9 (diff) | |
download | edk2-platforms-112a857f61378fe7b37a938fc37e95addb328318.tar.xz |
InOsEmuPkg: Unix emulator now compiles for IA-32.
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
Diffstat (limited to 'InOsEmuPkg/Unix')
-rw-r--r-- | InOsEmuPkg/Unix/Sec/Ia32/Gasket.S | 1505 | ||||
-rw-r--r-- | InOsEmuPkg/Unix/Sec/Ia32/SwitchStack.c | 74 | ||||
-rw-r--r-- | InOsEmuPkg/Unix/Sec/SecMain.c | 2 | ||||
-rw-r--r-- | InOsEmuPkg/Unix/Sec/SecMain.inf | 5 | ||||
-rw-r--r-- | InOsEmuPkg/Unix/UnixX64.dsc | 18 | ||||
-rwxr-xr-x | InOsEmuPkg/Unix/build.sh | 129 |
6 files changed, 1725 insertions, 8 deletions
diff --git a/InOsEmuPkg/Unix/Sec/Ia32/Gasket.S b/InOsEmuPkg/Unix/Sec/Ia32/Gasket.S new file mode 100644 index 0000000000..227be548da --- /dev/null +++ b/InOsEmuPkg/Unix/Sec/Ia32/Gasket.S @@ -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 index 0000000000..c75073ac2e --- /dev/null +++ b/InOsEmuPkg/Unix/Sec/Ia32/SwitchStack.c @@ -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); +} + + + diff --git a/InOsEmuPkg/Unix/Sec/SecMain.c b/InOsEmuPkg/Unix/Sec/SecMain.c index 4b6cb98e83..807f067ceb 100644 --- a/InOsEmuPkg/Unix/Sec/SecMain.c +++ b/InOsEmuPkg/Unix/Sec/SecMain.c @@ -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, diff --git a/InOsEmuPkg/Unix/Sec/SecMain.inf b/InOsEmuPkg/Unix/Sec/SecMain.inf index a0976efe86..294cf31d26 100644 --- a/InOsEmuPkg/Unix/Sec/SecMain.inf +++ b/InOsEmuPkg/Unix/Sec/SecMain.inf @@ -20,7 +20,6 @@ BASE_NAME = SecMain
FILE_GUID = 8863C0AD-7724-C84B-88E5-A33B116D1485
MODULE_TYPE = USER_DEFINED
-# MODULE_TYPE = BASE
VERSION_STRING = 1.0
#
@@ -43,6 +42,10 @@ X64/Gasket.S # convert between Emu x86_64 ABI and EFI X64 ABI
X64/SwitchStack.S
+[Sources.IA32]
+ Ia32/Gasket.S # enforce 16-byte stack alignment for Mac OS X
+ Ia32/SwitchStack.c
+
[Packages]
MdePkg/MdePkg.dec
diff --git a/InOsEmuPkg/Unix/UnixX64.dsc b/InOsEmuPkg/Unix/UnixX64.dsc index a601c0cbce..79c0ac67ef 100644 --- a/InOsEmuPkg/Unix/UnixX64.dsc +++ b/InOsEmuPkg/Unix/UnixX64.dsc @@ -28,7 +28,7 @@ PLATFORM_VERSION = 0.3
DSC_ SPECIFICATION = 0x00010005
OUTPUT_DIRECTORY = Build/EmuUnixX64
- SUPPORTED_ARCHITECTURES = X64
+ SUPPORTED_ARCHITECTURES = X64|IA32
BUILD_TARGETS = DEBUG|RELEASE
SKUID_IDENTIFIER = DEFAULT
FLASH_DEFINITION = InOsEmuPkg/Unix/UnixX64.fdf
@@ -264,6 +264,17 @@ # generated for it, but the binary will not be put into any firmware volume.
#
###################################################################################################
+
+[Components.X64]
+ MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf {
+ <LibraryClasses>
+ # turn off CR3 write so that DXE IPL will not crash emulator
+ BaseLib|UnixPkg/Library/UnixBaseLib/UnixBaseLib.inf
+ }
+
+[Components.IA32]
+ MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf
+
[Components]
!if $(SEC_ONLY)
##
@@ -294,11 +305,6 @@ InOsEmuPkg/FirmwareVolumePei/FirmwareVolumePei.inf
InOsEmuPkg/FlashMapPei/FlashMapPei.inf
InOsEmuPkg/ThunkPpiToProtocolPei/ThunkPpiToProtocolPei.inf
- MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf {
- <LibraryClasses>
- # turn off CR3 write so that DXE IPL will not crash emulator
- BaseLib|UnixPkg/Library/UnixBaseLib/UnixBaseLib.inf
- }
##
# DXE Phase modules
diff --git a/InOsEmuPkg/Unix/build.sh b/InOsEmuPkg/Unix/build.sh new file mode 100755 index 0000000000..e7e7b33b4c --- /dev/null +++ b/InOsEmuPkg/Unix/build.sh @@ -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 $? + |