Added support for an EFI X64 ABI compatible UnixPkg. With an internal only compiler I've been able to run checked in X64 EFI shell binary! We are hoping to get the open source LLVM compiler working for this... Since the SEC has to be UNIX ABI to make the POSIX calls it is compiled using a different compiler and the rest of the UnixPkg is compiled with UNIXPKG tool. You just need to point UNIXPKG at your EFI X64 ABI compiler of choice, it should work like MYTOOLS. Some one may want to port this to Linux at some point. To build cd into UnixPkg and ./build64.sh
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@10806 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
@@ -256,7 +256,36 @@ _ReverseGasketUint64:
|
||||
ret
|
||||
|
||||
|
||||
.subsections_via_symbols
|
||||
// Sec PPI Callbacks
|
||||
|
||||
.globl _GasketSecUnixPeiLoadFile
|
||||
_GasketSecUnixPeiLoadFile:
|
||||
jmp _SecUnixPeiLoadFile
|
||||
|
||||
|
||||
.globl _GasketSecUnixPeiAutoScan
|
||||
_GasketSecUnixPeiAutoScan:
|
||||
jmp _SecUnixPeiAutoScan
|
||||
|
||||
|
||||
.globl _GasketSecUnixUnixThunkAddress
|
||||
_GasketSecUnixUnixThunkAddress:
|
||||
jmp _SecUnixUnixThunkAddress
|
||||
|
||||
|
||||
.globl _GasketSecPeiReportStatusCode
|
||||
_GasketSecPeiReportStatusCode:
|
||||
jmp _SecPeiReportStatusCode
|
||||
|
||||
|
||||
.globl _GasketSecUnixFdAddress
|
||||
_GasketSecUnixFdAddress:
|
||||
jmp _SecUnixFdAddress
|
||||
|
||||
|
||||
.globl _GasketSecTemporaryRamSupport
|
||||
_GasketSecTemporaryRamSupport:
|
||||
jmp _SecTemporaryRamSupport
|
||||
|
||||
#endif
|
||||
|
||||
|
@@ -48,18 +48,21 @@ char *gGdbWorkingFileName = NULL;
|
||||
//
|
||||
// Globals
|
||||
//
|
||||
|
||||
UNIX_PEI_LOAD_FILE_PPI mSecUnixLoadFilePpi = { SecUnixPeiLoadFile };
|
||||
|
||||
PEI_UNIX_AUTOSCAN_PPI mSecUnixAutoScanPpi = { SecUnixPeiAutoScan };
|
||||
|
||||
PEI_UNIX_THUNK_PPI mSecUnixThunkPpi = { SecUnixUnixThunkAddress };
|
||||
|
||||
#ifdef __APPLE__
|
||||
UNIX_PEI_LOAD_FILE_PPI mSecUnixLoadFilePpi = { GasketSecUnixPeiLoadFile };
|
||||
PEI_UNIX_AUTOSCAN_PPI mSecUnixAutoScanPpi = { GasketSecUnixPeiAutoScan };
|
||||
PEI_UNIX_THUNK_PPI mSecUnixThunkPpi = { GasketSecUnixUnixThunkAddress };
|
||||
EFI_PEI_PROGRESS_CODE_PPI mSecStatusCodePpi = { GasketSecPeiReportStatusCode };
|
||||
UNIX_FWH_PPI mSecFwhInformationPpi = { GasketSecUnixFdAddress };
|
||||
TEMPORARY_RAM_SUPPORT_PPI mSecTemporaryRamSupportPpi = { GasketSecTemporaryRamSupport };
|
||||
#else
|
||||
UNIX_PEI_LOAD_FILE_PPI mSecUnixLoadFilePpi = { SecUnixPeiLoadFile };
|
||||
PEI_UNIX_AUTOSCAN_PPI mSecUnixAutoScanPpi = { SecUnixPeiAutoScan };
|
||||
PEI_UNIX_THUNK_PPI mSecUnixThunkPpi = { SecUnixUnixThunkAddress };
|
||||
EFI_PEI_PROGRESS_CODE_PPI mSecStatusCodePpi = { SecPeiReportStatusCode };
|
||||
|
||||
UNIX_FWH_PPI mSecFwhInformationPpi = { SecUnixFdAddress };
|
||||
|
||||
TEMPORARY_RAM_SUPPORT_PPI mSecTemporaryRamSupportPpi = {SecTemporaryRamSupport};
|
||||
TEMPORARY_RAM_SUPPORT_PPI mSecTemporaryRamSupportPpi = { SecTemporaryRamSupport };
|
||||
#endif
|
||||
|
||||
EFI_PEI_PPI_DESCRIPTOR gPrivateDispatchTable[] = {
|
||||
{
|
||||
@@ -1068,13 +1071,20 @@ PrintLoadAddress (
|
||||
IN PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext
|
||||
)
|
||||
{
|
||||
fprintf (stderr,
|
||||
"0x%08lx Loading %s with entry point 0x%08lx\n",
|
||||
(unsigned long)(ImageContext->ImageAddress + ImageContext->SizeOfHeaders),
|
||||
ImageContext->PdbPointer,
|
||||
(unsigned long)ImageContext->EntryPoint
|
||||
);
|
||||
|
||||
if (ImageContext->PdbPointer == NULL) {
|
||||
fprintf (stderr,
|
||||
"0x%08lx Loading NO DEBUG with entry point 0x%08lx\n",
|
||||
(unsigned long)(ImageContext->ImageAddress),
|
||||
(unsigned long)ImageContext->EntryPoint
|
||||
);
|
||||
} else {
|
||||
fprintf (stderr,
|
||||
"0x%08lx Loading %s with entry point 0x%08lx\n",
|
||||
(unsigned long)(ImageContext->ImageAddress + ImageContext->SizeOfHeaders),
|
||||
ImageContext->PdbPointer,
|
||||
(unsigned long)ImageContext->EntryPoint
|
||||
);
|
||||
}
|
||||
// Keep output synced up
|
||||
fflush (stderr);
|
||||
}
|
||||
|
@@ -55,6 +55,15 @@ typedef struct {
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
SecUnixPeiLoadFile (
|
||||
VOID *Pe32Data, // TODO: add IN/OUT modifier to Pe32Data
|
||||
EFI_PHYSICAL_ADDRESS *ImageAddress, // TODO: add IN/OUT modifier to ImageAddress
|
||||
UINT64 *ImageSize, // TODO: add IN/OUT modifier to ImageSize
|
||||
EFI_PHYSICAL_ADDRESS *EntryPoint // TODO: add IN/OUT modifier to EntryPoint
|
||||
);
|
||||
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
GasketSecUnixPeiLoadFile (
|
||||
VOID *Pe32Data, // TODO: add IN/OUT modifier to Pe32Data
|
||||
EFI_PHYSICAL_ADDRESS *ImageAddress, // TODO: add IN/OUT modifier to ImageAddress
|
||||
UINT64 *ImageSize, // TODO: add IN/OUT modifier to ImageSize
|
||||
@@ -83,6 +92,14 @@ Returns:
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
SecUnixPeiAutoScan (
|
||||
IN UINTN Index,
|
||||
OUT EFI_PHYSICAL_ADDRESS *MemoryBase,
|
||||
OUT UINT64 *MemorySize
|
||||
);
|
||||
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
GasketSecUnixPeiAutoScan (
|
||||
IN UINTN Index,
|
||||
OUT EFI_PHYSICAL_ADDRESS *MemoryBase,
|
||||
OUT UINT64 *MemorySize
|
||||
@@ -109,6 +126,12 @@ Returns:
|
||||
VOID *
|
||||
EFIAPI
|
||||
SecUnixUnixThunkAddress (
|
||||
VOID
|
||||
);
|
||||
|
||||
VOID *
|
||||
EFIAPI
|
||||
GasketSecUnixUnixThunkAddress (
|
||||
VOID
|
||||
)
|
||||
/*++
|
||||
@@ -132,6 +155,13 @@ Returns:
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
SecUnixUnixFwhAddress (
|
||||
IN OUT UINT64 *FwhSize,
|
||||
IN OUT EFI_PHYSICAL_ADDRESS *FwhBase
|
||||
);
|
||||
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
GasketSecUnixUnixFwhAddress (
|
||||
IN OUT UINT64 *FwhSize,
|
||||
IN OUT EFI_PHYSICAL_ADDRESS *FwhBase
|
||||
)
|
||||
@@ -156,6 +186,17 @@ Returns:
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
SecPeiReportStatusCode (
|
||||
IN CONST EFI_PEI_SERVICES **PeiServices,
|
||||
IN EFI_STATUS_CODE_TYPE CodeType,
|
||||
IN EFI_STATUS_CODE_VALUE Value,
|
||||
IN UINT32 Instance,
|
||||
IN CONST EFI_GUID *CallerId,
|
||||
IN CONST EFI_STATUS_CODE_DATA *Data OPTIONAL
|
||||
);
|
||||
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
GasketSecPeiReportStatusCode (
|
||||
IN CONST EFI_PEI_SERVICES **PeiServices,
|
||||
IN EFI_STATUS_CODE_TYPE CodeType,
|
||||
IN EFI_STATUS_CODE_VALUE Value,
|
||||
@@ -395,6 +436,17 @@ SecUnixFdAddress (
|
||||
)
|
||||
;
|
||||
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
GasketSecUnixFdAddress (
|
||||
IN UINTN Index,
|
||||
IN OUT EFI_PHYSICAL_ADDRESS *FdBase,
|
||||
IN OUT UINT64 *FdSize,
|
||||
IN OUT EFI_PHYSICAL_ADDRESS *FixUp
|
||||
)
|
||||
;
|
||||
|
||||
|
||||
EFI_STATUS
|
||||
GetImageReadFunction (
|
||||
IN PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext,
|
||||
@@ -500,6 +552,15 @@ SecTemporaryRamSupport (
|
||||
IN EFI_PHYSICAL_ADDRESS PermanentMemoryBase,
|
||||
IN UINTN CopySize
|
||||
);
|
||||
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
GasketSecTemporaryRamSupport (
|
||||
IN CONST EFI_PEI_SERVICES **PeiServices,
|
||||
IN EFI_PHYSICAL_ADDRESS TemporaryMemoryBase,
|
||||
IN EFI_PHYSICAL_ADDRESS PermanentMemoryBase,
|
||||
IN UINTN CopySize
|
||||
);
|
||||
|
||||
|
||||
RETURN_STATUS
|
||||
|
@@ -42,12 +42,12 @@
|
||||
Ia32/SwitchStack.c
|
||||
|
||||
[Sources.X64]
|
||||
X64/Gasket.S
|
||||
# X64/Gasket.S # pure UINX x86_64 ABI also need to fix issues in BaseLib
|
||||
X64/MangleGasket.S # convert between UNIX x86_64 ABI and EFI X64 ABI
|
||||
|
||||
X64/SwitchStack.S
|
||||
X64/NameManglingFix.c
|
||||
|
||||
# Only used to help construct Gasket.S
|
||||
# X64/GasketEfiTemplate.c
|
||||
|
||||
|
||||
[Packages]
|
||||
MdePkg/MdePkg.dec
|
||||
|
@@ -130,7 +130,7 @@ GetLocalTime (EFI_TIME *Time)
|
||||
Time->Minute = tm->tm_min;
|
||||
Time->Second = tm->tm_sec;
|
||||
Time->Nanosecond = 0;
|
||||
Time->TimeZone = timezone;
|
||||
Time->TimeZone = GetTimeZone ();
|
||||
Time->Daylight = (daylight ? EFI_TIME_ADJUST_DAYLIGHT : 0)
|
||||
| (tm->tm_isdst > 0 ? EFI_TIME_IN_DAYLIGHT : 0);
|
||||
}
|
||||
|
@@ -1146,6 +1146,39 @@ _EfiReverseGasketUint64:
|
||||
leave
|
||||
ret
|
||||
|
||||
// Sec PPI Callbacks
|
||||
|
||||
.globl _GasketSecUnixPeiLoadFile
|
||||
_GasketSecUnixPeiLoadFile:
|
||||
jmp _SecUnixPeiLoadFile
|
||||
|
||||
|
||||
.globl _GasketSecUnixPeiAutoScan
|
||||
_GasketSecUnixPeiAutoScan:
|
||||
jmp _SecUnixPeiAutoScan
|
||||
|
||||
|
||||
.globl _GasketSecUnixUnixThunkAddress
|
||||
_GasketSecUnixUnixThunkAddress:
|
||||
jmp _SecUnixUnixThunkAddress
|
||||
|
||||
|
||||
.globl _GasketSecPeiReportStatusCode
|
||||
_GasketSecPeiReportStatusCode:
|
||||
jmp _SecPeiReportStatusCode
|
||||
|
||||
|
||||
.globl _GasketSecUnixFdAddress
|
||||
_GasketSecUnixFdAddress:
|
||||
jmp _SecUnixFdAddress
|
||||
|
||||
|
||||
.globl _GasketSecTemporaryRamSupport
|
||||
_GasketSecTemporaryRamSupport:
|
||||
jmp _SecTemporaryRamSupport
|
||||
|
||||
|
||||
|
||||
#if __APPLE__
|
||||
|
||||
LFE63:
|
||||
|
@@ -166,7 +166,7 @@ _Gasketexit:
|
||||
movq %rcx, %rdi // Swizzle args
|
||||
call _exit // Less to do as we will never return to EFI ABI world
|
||||
LDEAD_LOOP:
|
||||
jmp LDEAD_LOOP: // _exit should never return
|
||||
jmp LDEAD_LOOP // _exit should never return
|
||||
|
||||
|
||||
|
||||
@@ -508,7 +508,6 @@ _Gaskettcflush:
|
||||
popq %rdi // restore state
|
||||
popq %rsi
|
||||
ret
|
||||
call
|
||||
|
||||
|
||||
.globl _GasketUgaCreate
|
||||
@@ -566,7 +565,7 @@ _Gasketfcntl:
|
||||
movq %rdx, %rsi
|
||||
movq %r8, %rdx
|
||||
|
||||
call _UnixFctl1
|
||||
call _UnixFcntl1
|
||||
|
||||
popq %rdi // restore state
|
||||
popq %rsi
|
||||
@@ -754,7 +753,7 @@ _GasketUgaBlt:
|
||||
|
||||
popq %rdi // restore state
|
||||
popq %rsi
|
||||
|
||||
ret
|
||||
|
||||
|
||||
//
|
||||
@@ -775,10 +774,115 @@ _ReverseGasketUint64:
|
||||
movq %rcx, %r8
|
||||
movq %r9, %rcx
|
||||
|
||||
subq 40, %rsp // 32-byte shadow space plus alignment pad
|
||||
subq $40, %rsp // 32-byte shadow space plus alignment pad
|
||||
call *%rax
|
||||
addq 40, %rsp
|
||||
addq $40, %rsp
|
||||
|
||||
ret
|
||||
|
||||
|
||||
// Sec PPI Callbacks
|
||||
|
||||
.globl _GasketSecUnixPeiLoadFile
|
||||
_GasketSecUnixPeiLoadFile:
|
||||
pushq %rsi // %rsi & %rdi are volatie in Unix and callee-save in EFI ABI
|
||||
pushq %rdi
|
||||
|
||||
movq %rcx, %rdi // Swizzle args
|
||||
movq %rdx, %rsi
|
||||
movq %r8, %rdx
|
||||
movq %r9, %rcx
|
||||
|
||||
call _SecUnixPeiLoadFile
|
||||
|
||||
popq %rdi // restore state
|
||||
popq %rsi
|
||||
ret
|
||||
|
||||
|
||||
|
||||
.globl _GasketSecUnixPeiAutoScan
|
||||
_GasketSecUnixPeiAutoScan:
|
||||
pushq %rsi // %rsi & %rdi are volatie in Unix and callee-save in EFI ABI
|
||||
pushq %rdi
|
||||
|
||||
movq %rcx, %rdi // Swizzle args
|
||||
movq %rdx, %rsi
|
||||
movq %r8, %rdx
|
||||
|
||||
call _SecUnixPeiAutoScan
|
||||
|
||||
popq %rdi // restore state
|
||||
popq %rsi
|
||||
ret
|
||||
|
||||
.globl _GasketSecUnixUnixThunkAddress
|
||||
_GasketSecUnixUnixThunkAddress:
|
||||
pushq %rsi // %rsi & %rdi are volatie in Unix and callee-save in EFI ABI
|
||||
pushq %rdi
|
||||
|
||||
call _SecUnixUnixThunkAddress
|
||||
|
||||
popq %rdi // restore state
|
||||
popq %rsi
|
||||
ret
|
||||
|
||||
|
||||
.globl _GasketSecPeiReportStatusCode
|
||||
_GasketSecPeiReportStatusCode:
|
||||
pushq %rsi // %rsi & %rdi are volatie in Unix and callee-save in EFI ABI
|
||||
pushq %rdi
|
||||
|
||||
movq %rcx, %rdi // Swizzle args
|
||||
movq %rdx, %rsi
|
||||
movq %r8, %rdx
|
||||
movq %r9, %rcx
|
||||
movq $0, %r8 // BugBug: This should come from the stack
|
||||
movq $0, %r9 // But we can cheat since they are optional for bringup....
|
||||
|
||||
call _SecPeiReportStatusCode
|
||||
|
||||
popq %rdi // restore state
|
||||
popq %rsi
|
||||
ret
|
||||
|
||||
|
||||
.globl _GasketSecUnixFdAddress
|
||||
_GasketSecUnixFdAddress:
|
||||
pushq %rsi // %rsi & %rdi are volatie in Unix and callee-save in EFI ABI
|
||||
pushq %rdi
|
||||
|
||||
movq %rcx, %rdi // Swizzle args
|
||||
movq %rdx, %rsi
|
||||
movq %r8, %rdx
|
||||
movq %r9, %rcx
|
||||
|
||||
call _SecUnixFdAddress
|
||||
|
||||
popq %rdi // restore state
|
||||
popq %rsi
|
||||
ret
|
||||
|
||||
|
||||
|
||||
|
||||
.globl _GasketSecTemporaryRamSupport
|
||||
_GasketSecTemporaryRamSupport:
|
||||
pushq %rsi // %rsi & %rdi are volatie in Unix and callee-save in EFI ABI
|
||||
pushq %rdi
|
||||
|
||||
movq %rcx, %rdi // Swizzle args
|
||||
movq %rdx, %rsi
|
||||
movq %r8, %rdx
|
||||
movq %r9, %rcx
|
||||
|
||||
call _SecTemporaryRamSupport
|
||||
|
||||
popq %rdi // restore state
|
||||
popq %rsi
|
||||
ret
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@@ -37,8 +37,8 @@
|
||||
# None
|
||||
#
|
||||
#------------------------------------------------------------------------------
|
||||
ASM_GLOBAL ASM_PFX(GasketPeiSwitchStacks)
|
||||
ASM_PFX(GasketPeiSwitchStacks):
|
||||
ASM_GLOBAL ASM_PFX(PeiSwitchStacks)
|
||||
ASM_PFX(PeiSwitchStacks):
|
||||
// movq %rdx, %rdx
|
||||
movq %r8, %rsp
|
||||
|
||||
@@ -50,7 +50,7 @@ ASM_PFX(GasketPeiSwitchStacks):
|
||||
# Reserve space for register parameters (rcx, rdx, r8 & r9) on the stack,
|
||||
# in case the callee wishes to spill them.
|
||||
#
|
||||
subq 40, %rsp // 32-byte shadow space plus alignment pad
|
||||
subq $40, %rsp // 32-byte shadow space plus alignment pad
|
||||
call *%rax
|
||||
|
||||
|
||||
@@ -72,8 +72,8 @@ ASM_PFX(GasketPeiSwitchStacks):
|
||||
# None
|
||||
#
|
||||
#------------------------------------------------------------------------------
|
||||
ASM_GLOBAL ASM_PFX(PeiSwitchStacks)
|
||||
ASM_PFX(PeiSwitchStacks):
|
||||
ASM_GLOBAL ASM_PFX(UnixPeiSwitchStacks)
|
||||
ASM_PFX(UnixPeiSwitchStacks):
|
||||
mov %rdi, %rax
|
||||
mov %rsi, %rdi
|
||||
mov %rdx, %rsi
|
||||
|
Reference in New Issue
Block a user