mirror of https://github.com/acidanthera/audk.git
Started trying to get the UnixPkg to compile for X64 with UnixABI. So far only have Sec compiling with Xcode. This is the first step in trying to get the EFIABI to work. Note since SEC is a Posix application it will still need to be Unix ABI.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@10649 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
parent
72ed3d7575
commit
67f86803ce
|
@ -121,7 +121,7 @@ GasketUint64Uintn (void *api, UINT64 a, UINTN b)
|
|||
}
|
||||
|
||||
UINT64
|
||||
GasketUintnUiny64Uintn (void *api, UINTN a, UINT64 b, UINTN c)
|
||||
GasketUintnUint64Uintn (void *api, UINTN a, UINT64 b, UINTN c)
|
||||
{
|
||||
GASKET_UINTN_UINT64_UINTN func;
|
||||
|
||||
|
|
|
@ -0,0 +1,98 @@
|
|||
/*++
|
||||
|
||||
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.
|
||||
|
||||
Module Name:
|
||||
|
||||
SecMain.c
|
||||
|
||||
Abstract:
|
||||
Unix emulator of SEC phase. It's really a Posix application, but this is
|
||||
Ok since all the other modules for NT32 are NOT Posix applications.
|
||||
|
||||
This program processes host environment variables and figures out
|
||||
what the memory layout will be, how may FD's will be loaded and also
|
||||
what the boot mode is.
|
||||
|
||||
The SEC registers a set of services with the SEC core. gPrivateDispatchTable
|
||||
is a list of PPI's produced by the SEC that are availble for usage in PEI.
|
||||
|
||||
This code produces 128 K of temporary memory for the PEI stack by opening a
|
||||
host file and mapping it directly to memory addresses.
|
||||
|
||||
The system.cmd script is used to set host environment variables that drive
|
||||
the configuration opitons of the SEC.
|
||||
|
||||
--*/
|
||||
|
||||
#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.
|
||||
@param NewBsp A pointer to the new BSP for the EntryPoint on IPF. It's
|
||||
Reserved on other architectures.
|
||||
|
||||
**/
|
||||
VOID
|
||||
EFIAPI
|
||||
PeiSwitchStacks (
|
||||
IN SWITCH_STACK_ENTRY_POINT EntryPoint,
|
||||
IN VOID *Context1, OPTIONAL
|
||||
IN VOID *Context2, OPTIONAL
|
||||
IN VOID *Context3, 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) + sizeof(Context3);
|
||||
((VOID**)JumpBuffer.Esp)[1] = Context1;
|
||||
((VOID**)JumpBuffer.Esp)[2] = Context2;
|
||||
((VOID**)JumpBuffer.Esp)[3] = Context3;
|
||||
|
||||
LongJump (&JumpBuffer, (UINTN)-1);
|
||||
|
||||
|
||||
//
|
||||
// InternalSwitchStack () will never return
|
||||
//
|
||||
ASSERT (FALSE);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -499,28 +499,6 @@ Returns:
|
|||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
/**
|
||||
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.
|
||||
@param NewBsp A pointer to the new BSP for the EntryPoint on IPF. It's
|
||||
Reserved on other architectures.
|
||||
|
||||
**/
|
||||
VOID
|
||||
EFIAPI
|
||||
PeiSwitchStacks (
|
||||
|
@ -529,33 +507,7 @@ PeiSwitchStacks (
|
|||
IN VOID *Context2, OPTIONAL
|
||||
IN VOID *Context3, 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) + sizeof(Context3);
|
||||
((VOID**)JumpBuffer.Esp)[1] = Context1;
|
||||
((VOID**)JumpBuffer.Esp)[2] = Context2;
|
||||
((VOID**)JumpBuffer.Esp)[3] = Context3;
|
||||
|
||||
LongJump (&JumpBuffer, (UINTN)-1);
|
||||
|
||||
|
||||
//
|
||||
// InternalSwitchStack () will never return
|
||||
//
|
||||
ASSERT (FALSE);
|
||||
}
|
||||
);
|
||||
|
||||
VOID
|
||||
SecLoadFromCore (
|
||||
|
@ -1110,7 +1062,7 @@ PrintLoadAddress (
|
|||
{
|
||||
fprintf (stderr,
|
||||
"0x%08lx Loading %s with entry point 0x%08lx\n",
|
||||
(unsigned long)ImageContext->ImageAddress + ImageContext->SizeOfHeaders,
|
||||
(unsigned long)(ImageContext->ImageAddress + ImageContext->SizeOfHeaders),
|
||||
ImageContext->PdbPointer,
|
||||
(unsigned long)ImageContext->EntryPoint
|
||||
);
|
||||
|
@ -1171,7 +1123,7 @@ SecPeCoffRelocateImageExtraAction (
|
|||
//
|
||||
GdbTempFile = fopen (gGdbWorkingFileName, "w");
|
||||
if (GdbTempFile != NULL) {
|
||||
fprintf (GdbTempFile, "add-symbol-file %s 0x%x\n", ImageContext->PdbPointer, (UINTN)(ImageContext->ImageAddress + ImageContext->SizeOfHeaders));
|
||||
fprintf (GdbTempFile, "add-symbol-file %s 0x%x\n", ImageContext->PdbPointer, (unsigned int)(ImageContext->ImageAddress + ImageContext->SizeOfHeaders));
|
||||
fclose (GdbTempFile);
|
||||
|
||||
//
|
||||
|
|
|
@ -39,6 +39,11 @@
|
|||
[Sources.Ia32]
|
||||
Ia32/Gasket.S
|
||||
Ia32/Stack.S
|
||||
Ia32/SwitchStack.c
|
||||
|
||||
[Sources.X64]
|
||||
X64/Gasket.S
|
||||
X64/SwitchStack.S
|
||||
|
||||
[Packages]
|
||||
MdePkg/MdePkg.dec
|
||||
|
@ -84,3 +89,7 @@
|
|||
XCODE:*_*_IA32_DLINK_PATH == gcc
|
||||
XCODE:*_*_IA32_DLINK_FLAGS == -arch i386 -o $(BIN_DIR)/SecMain -L/usr/X11R6/lib -lXext -lX11 -lIOKit -framework Carbon
|
||||
XCODE:*_*_IA32_ASM_FLAGS == -arch i386 -g
|
||||
|
||||
XCODE:*_*_X64_DLINK_PATH == gcc
|
||||
XCODE:*_*_X64_DLINK_FLAGS == -o $(BIN_DIR)/SecMain -L/usr/X11R6/lib -lXext -lX11 -lIOKit -framework Carbon
|
||||
XCODE:*_*_X64_ASM_FLAGS == -g
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,111 @@
|
|||
#------------------------------------------------------------------------------
|
||||
#
|
||||
# Copyright (c) 2006 - 2008, 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:
|
||||
#
|
||||
# SwitchStack.S
|
||||
#
|
||||
# Abstract:
|
||||
#
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# Routine Description:
|
||||
#
|
||||
# Routine for switching stacks with 3 parameters EFI ABI
|
||||
#
|
||||
# Arguments:
|
||||
#
|
||||
# (rcx) EntryPoint - Entry point with new stack.
|
||||
# (rdx) Context1 - Parameter1 for entry point.
|
||||
# (r8) Context2 - Parameter2 for entry point.
|
||||
# (r9) Context3 - Parameter3 for entry point.
|
||||
# (rsp)0x20 NewStack - The pointer to new stack.
|
||||
#
|
||||
# Returns:
|
||||
#
|
||||
# None
|
||||
#
|
||||
#------------------------------------------------------------------------------
|
||||
ASM_GLOBAL ASM_PFX(MsftPeiSwitchStacks)
|
||||
ASM_PFX(MsftPeiSwitchStacks):
|
||||
mov %rcx, %rax
|
||||
mov %rdx, %rcx
|
||||
mov %r8, %rdx
|
||||
mov %r9, %r8
|
||||
|
||||
# get new stack from the stack
|
||||
mov 0x20(%rsp), %rsp # is this off by 8?
|
||||
|
||||
#
|
||||
# Reserve space for register parameters (rcx, rdx, r8 & r9) on the stack,
|
||||
# in case the callee wishes to spill them.
|
||||
#
|
||||
lea -0x20(%rsp), %rsp
|
||||
call *%rax
|
||||
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# Routine Description:
|
||||
#
|
||||
# Routine for switching stacks with 3 parameters UNIX ABI
|
||||
#
|
||||
# Arguments:
|
||||
#
|
||||
# (rdi) EntryPoint - Entry point with new stack.
|
||||
# (rsi) Context1 - Parameter1 for entry point.
|
||||
# (rdx) Context2 - Parameter2 for entry point.
|
||||
# (rcx) Context3 - Parameter3 for entry point.
|
||||
# (r8) NewStack - The pointer to new stack.
|
||||
#
|
||||
# Returns:
|
||||
#
|
||||
# None
|
||||
#
|
||||
#------------------------------------------------------------------------------
|
||||
ASM_GLOBAL ASM_PFX(PeiSwitchStacks)
|
||||
ASM_PFX(PeiSwitchStacks):
|
||||
mov %rdi, %rax
|
||||
mov %rsi, %rdi
|
||||
mov %rdx, %rsi
|
||||
mov %rcx, %rdx
|
||||
mov %r8, %rsp
|
||||
|
||||
|
||||
#
|
||||
# Reserve space for redzone on the stack,
|
||||
# in case the callee wishes to spill them.
|
||||
#
|
||||
lea -0x80(%rsp), %rsp
|
||||
call *%rax
|
||||
|
||||
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# VOID
|
||||
# EFIAPI
|
||||
# SecSwitchStack (
|
||||
# UINT32 TemporaryMemoryBase, // Rcx, Rdi
|
||||
# UINT32 PermenentMemoryBase // Rdx, Rsi
|
||||
# );
|
||||
#------------------------------------------------------------------------------
|
||||
ASM_GLOBAL ASM_PFX(SecSwitchStack)
|
||||
ASM_PFX(SecSwitchStack):
|
||||
|
||||
mov %rsp, %rax
|
||||
sub %rdi, %rax
|
||||
add %rsi, %rax
|
||||
mov (%rip), %r10
|
||||
mov %r10, (%rax)
|
||||
ret
|
||||
|
||||
|
|
@ -27,7 +27,7 @@
|
|||
PLATFORM_VERSION = 0.3
|
||||
DSC_ SPECIFICATION = 0x00010005
|
||||
OUTPUT_DIRECTORY = Build/Unix
|
||||
SUPPORTED_ARCHITECTURES = IA32
|
||||
SUPPORTED_ARCHITECTURES = IA32|X64
|
||||
BUILD_TARGETS = DEBUG|RELEASE
|
||||
SKUID_IDENTIFIER = DEFAULT
|
||||
FLASH_DEFINITION = UnixPkg/UnixPkg.fdf
|
||||
|
@ -224,7 +224,7 @@
|
|||
# generated for it, but the binary will not be put into any firmware volume.
|
||||
#
|
||||
###################################################################################################
|
||||
[Components.IA32]
|
||||
[Components.common]
|
||||
##
|
||||
# SEC Phase modules
|
||||
##
|
||||
|
|
|
@ -0,0 +1,106 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
|
||||
set -e
|
||||
shopt -s nocasematch
|
||||
|
||||
|
||||
|
||||
#
|
||||
# Setup workspace if it is not set
|
||||
#
|
||||
if [ -z "$WORKSPACE" ]
|
||||
then
|
||||
echo Initializing workspace
|
||||
cd ..
|
||||
# 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
|
||||
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
|
||||
fi
|
||||
;;
|
||||
Linux*) TARGET_TOOLS=ELFGCC ;;
|
||||
|
||||
esac
|
||||
|
||||
BUILD_ROOT_ARCH=$WORKSPACE/Build/Unix/DEBUG_"$TARGET_TOOLS"/X64
|
||||
|
||||
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/UnixPkg/.gdbinit $WORKSPACE/Build/Unix/DEBUG_"$TARGET_TOOLS"/X64
|
||||
;;
|
||||
esac
|
||||
|
||||
/usr/bin/gdb $BUILD_ROOT_ARCH/SecMain -q -cd=$BUILD_ROOT_ARCH
|
||||
exit
|
||||
fi
|
||||
|
||||
if [[ $arg == cleanall ]]; then
|
||||
make -C $WORKSPACE/BaseTools clean
|
||||
fi
|
||||
done
|
||||
|
||||
|
||||
#
|
||||
# Build the edk2 UnixPkg
|
||||
#
|
||||
echo $PATH
|
||||
echo `which build`
|
||||
# Uncomment this if you want to build the shell.
|
||||
#build -p $WORKSPACE/EdkShellPkg/EdkShellPkg.dsc -a X64 -t $TARGET_TOOLS $1 $2 $3 $4 $5 $6 $7 $8
|
||||
build -p $WORKSPACE/UnixPkg/UnixPkg.dsc -a X64 -t $TARGET_TOOLS $1 $2 $3 $4 $5 $6 $7 $8
|
||||
exit $?
|
||||
|
Loading…
Reference in New Issue