mirror of https://github.com/acidanthera/audk.git
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
This commit is contained in:
parent
2a5c468026
commit
112a857f61
|
@ -0,0 +1,103 @@
|
||||||
|
#------------------------------------------------------------------------------
|
||||||
|
#
|
||||||
|
# Copyright (c) 2007, 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.
|
||||||
|
#
|
||||||
|
# Module Name:
|
||||||
|
#
|
||||||
|
# Stack.asm
|
||||||
|
#
|
||||||
|
# Abstract:
|
||||||
|
#
|
||||||
|
# Switch the stack from temporary memory to permenent memory.
|
||||||
|
#
|
||||||
|
#------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
.text
|
||||||
|
|
||||||
|
|
||||||
|
// EFI_STATUS
|
||||||
|
// EFIAPI
|
||||||
|
// SecTemporaryRamSupport (
|
||||||
|
// IN CONST EFI_PEI_SERVICES **PeiServices, // %rcx
|
||||||
|
// IN EFI_PHYSICAL_ADDRESS TemporaryMemoryBase, // %rdx
|
||||||
|
// IN EFI_PHYSICAL_ADDRESS PermanentMemoryBase, // %r8
|
||||||
|
// IN UINTN CopySize // %r9
|
||||||
|
// )
|
||||||
|
//
|
||||||
|
ASM_GLOBAL ASM_PFX(SecTemporaryRamSupport)
|
||||||
|
ASM_PFX(SecTemporaryRamSupport):
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
// VOID
|
||||||
|
// EFIAPI
|
||||||
|
// SecSwitchStack (
|
||||||
|
// UINT32 TemporaryMemoryBase,
|
||||||
|
// UINT32 PermenentMemoryBase
|
||||||
|
// )//
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
//
|
||||||
|
// Save three register: eax, ebx, ecx
|
||||||
|
//
|
||||||
|
push %eax
|
||||||
|
push %ebx
|
||||||
|
push %ecx
|
||||||
|
push %edx
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
// Port me to GAS syntax
|
||||||
|
//
|
||||||
|
// !!CAUTION!! this function addresss is pushed into stack after
|
||||||
|
// migration of whole temporary memory, so need save it to permenent
|
||||||
|
// memory at first!
|
||||||
|
//
|
||||||
|
|
||||||
|
mov ebx, [esp + 20] // Save the first parameter
|
||||||
|
mov ecx, [esp + 24] // Save the second parameter
|
||||||
|
|
||||||
|
//
|
||||||
|
// Save this functions return address into permenent memory at first.
|
||||||
|
// Then, Fixup the esp point to permenent memory
|
||||||
|
//
|
||||||
|
mov eax, esp
|
||||||
|
sub eax, ebx
|
||||||
|
add eax, ecx
|
||||||
|
mov edx, dword ptr [esp] // copy pushed registers value to permenent memory
|
||||||
|
mov dword ptr [eax], edx
|
||||||
|
mov edx, dword ptr [esp + 4]
|
||||||
|
mov dword ptr [eax + 4], edx
|
||||||
|
mov edx, dword ptr [esp + 8]
|
||||||
|
mov dword ptr [eax + 8], edx
|
||||||
|
mov edx, dword ptr [esp + 12]
|
||||||
|
mov dword ptr [eax + 12], edx
|
||||||
|
mov edx, dword ptr [esp + 16] // Update this functions return address into permenent memory
|
||||||
|
mov dword ptr [eax + 16], edx
|
||||||
|
mov esp, eax // From now, esp is pointed to permenent memory
|
||||||
|
|
||||||
|
//
|
||||||
|
// Fixup the ebp point to permenent memory
|
||||||
|
//
|
||||||
|
mov eax, ebp
|
||||||
|
sub eax, ebx
|
||||||
|
add eax, ecx
|
||||||
|
mov ebp, eax // From now, ebp is pointed to permenent memory
|
||||||
|
|
||||||
|
//
|
||||||
|
// Fixup callees ebp point for PeiDispatch
|
||||||
|
//
|
||||||
|
mov eax, dword ptr [ebp]
|
||||||
|
sub eax, ebx
|
||||||
|
add eax, ecx
|
||||||
|
mov dword ptr [ebp], eax // From now, Temporarys PPI callers stack is in permenent memory
|
||||||
|
#endif
|
||||||
|
pop %edx
|
||||||
|
pop %ecx
|
||||||
|
pop %ebx
|
||||||
|
pop %eax
|
||||||
|
ret
|
|
@ -28,6 +28,9 @@
|
||||||
[Sources.X64]
|
[Sources.X64]
|
||||||
X64/SwitchRam.S
|
X64/SwitchRam.S
|
||||||
|
|
||||||
|
[Sources.IA32]
|
||||||
|
Ia32/SwitchRam.S
|
||||||
|
|
||||||
[Packages]
|
[Packages]
|
||||||
MdePkg/MdePkg.dec
|
MdePkg/MdePkg.dec
|
||||||
InOsEmuPkg/InOsEmuPkg.dec
|
InOsEmuPkg/InOsEmuPkg.dec
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -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);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -439,7 +439,7 @@ MapFd0 (
|
||||||
|
|
||||||
// Map the rest of the FD as read/write
|
// Map the rest of the FD as read/write
|
||||||
res2 = mmap (
|
res2 = mmap (
|
||||||
(void *)(FixedPcdGet64 (PcdEmuFlashFvRecoveryBase) + FvSize),
|
(void *)(UINTN)(FixedPcdGet64 (PcdEmuFlashFvRecoveryBase) + FvSize),
|
||||||
FileSize - FvSize,
|
FileSize - FvSize,
|
||||||
PROT_READ | PROT_WRITE | PROT_EXEC,
|
PROT_READ | PROT_WRITE | PROT_EXEC,
|
||||||
MAP_SHARED,
|
MAP_SHARED,
|
||||||
|
|
|
@ -20,7 +20,6 @@
|
||||||
BASE_NAME = SecMain
|
BASE_NAME = SecMain
|
||||||
FILE_GUID = 8863C0AD-7724-C84B-88E5-A33B116D1485
|
FILE_GUID = 8863C0AD-7724-C84B-88E5-A33B116D1485
|
||||||
MODULE_TYPE = USER_DEFINED
|
MODULE_TYPE = USER_DEFINED
|
||||||
# MODULE_TYPE = BASE
|
|
||||||
VERSION_STRING = 1.0
|
VERSION_STRING = 1.0
|
||||||
|
|
||||||
#
|
#
|
||||||
|
@ -43,6 +42,10 @@
|
||||||
X64/Gasket.S # convert between Emu x86_64 ABI and EFI X64 ABI
|
X64/Gasket.S # convert between Emu x86_64 ABI and EFI X64 ABI
|
||||||
X64/SwitchStack.S
|
X64/SwitchStack.S
|
||||||
|
|
||||||
|
[Sources.IA32]
|
||||||
|
Ia32/Gasket.S # enforce 16-byte stack alignment for Mac OS X
|
||||||
|
Ia32/SwitchStack.c
|
||||||
|
|
||||||
|
|
||||||
[Packages]
|
[Packages]
|
||||||
MdePkg/MdePkg.dec
|
MdePkg/MdePkg.dec
|
||||||
|
|
|
@ -28,7 +28,7 @@
|
||||||
PLATFORM_VERSION = 0.3
|
PLATFORM_VERSION = 0.3
|
||||||
DSC_ SPECIFICATION = 0x00010005
|
DSC_ SPECIFICATION = 0x00010005
|
||||||
OUTPUT_DIRECTORY = Build/EmuUnixX64
|
OUTPUT_DIRECTORY = Build/EmuUnixX64
|
||||||
SUPPORTED_ARCHITECTURES = X64
|
SUPPORTED_ARCHITECTURES = X64|IA32
|
||||||
BUILD_TARGETS = DEBUG|RELEASE
|
BUILD_TARGETS = DEBUG|RELEASE
|
||||||
SKUID_IDENTIFIER = DEFAULT
|
SKUID_IDENTIFIER = DEFAULT
|
||||||
FLASH_DEFINITION = InOsEmuPkg/Unix/UnixX64.fdf
|
FLASH_DEFINITION = InOsEmuPkg/Unix/UnixX64.fdf
|
||||||
|
@ -264,6 +264,17 @@
|
||||||
# generated for it, but the binary will not be put into any firmware volume.
|
# 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]
|
[Components]
|
||||||
!if $(SEC_ONLY)
|
!if $(SEC_ONLY)
|
||||||
##
|
##
|
||||||
|
@ -294,11 +305,6 @@
|
||||||
InOsEmuPkg/FirmwareVolumePei/FirmwareVolumePei.inf
|
InOsEmuPkg/FirmwareVolumePei/FirmwareVolumePei.inf
|
||||||
InOsEmuPkg/FlashMapPei/FlashMapPei.inf
|
InOsEmuPkg/FlashMapPei/FlashMapPei.inf
|
||||||
InOsEmuPkg/ThunkPpiToProtocolPei/ThunkPpiToProtocolPei.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
|
# DXE Phase modules
|
||||||
|
|
|
@ -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 $?
|
||||||
|
|
Loading…
Reference in New Issue