diff options
Diffstat (limited to 'UnixPkg')
-rw-r--r-- | UnixPkg/Library/UnixBaseLib/GetPowerOfTwo64.c | 4 | ||||
-rw-r--r-- | UnixPkg/Library/UnixBaseLib/MultS64x64.c | 2 | ||||
-rw-r--r-- | UnixPkg/Library/UnixBaseLib/String.c | 51 | ||||
-rw-r--r-- | UnixPkg/Library/UnixBaseLib/X64/LongJump.S | 42 | ||||
-rw-r--r-- | UnixPkg/Library/UnixBaseLib/X64/SetJump.S | 33 | ||||
-rw-r--r-- | UnixPkg/Library/UnixBaseLib/X64/SwitchStack.S | 42 | ||||
-rw-r--r-- | UnixPkg/Sec/Ia32/Gasket.S | 31 | ||||
-rw-r--r-- | UnixPkg/Sec/SecMain.c | 44 | ||||
-rw-r--r-- | UnixPkg/Sec/SecMain.h | 61 | ||||
-rw-r--r-- | UnixPkg/Sec/SecMain.inf | 8 | ||||
-rw-r--r-- | UnixPkg/Sec/UnixThunk.c | 2 | ||||
-rw-r--r-- | UnixPkg/Sec/X64/Gasket.S | 33 | ||||
-rw-r--r-- | UnixPkg/Sec/X64/MangleGasket.S | 116 | ||||
-rw-r--r-- | UnixPkg/Sec/X64/SwitchStack.S | 10 | ||||
-rw-r--r-- | UnixPkg/UnixPkgX64.dsc | 6 | ||||
-rw-r--r-- | UnixPkg/UnixPkgX64.fdf | 17 | ||||
-rw-r--r-- | UnixPkg/UnixUgaDxe/UnixUgaScreen.c | 2 | ||||
-rwxr-xr-x | UnixPkg/build64.sh | 12 |
18 files changed, 316 insertions, 200 deletions
diff --git a/UnixPkg/Library/UnixBaseLib/GetPowerOfTwo64.c b/UnixPkg/Library/UnixBaseLib/GetPowerOfTwo64.c index 4623c2a656..3574bc4d3c 100644 --- a/UnixPkg/Library/UnixBaseLib/GetPowerOfTwo64.c +++ b/UnixPkg/Library/UnixBaseLib/GetPowerOfTwo64.c @@ -1,7 +1,7 @@ /** @file
Math worker functions.
- Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2006 - 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
@@ -40,5 +40,5 @@ GetPowerOfTwo64 ( return 0;
}
- return LShiftU64 (1, HighBitSet64 (Operand));
+ return LShiftU64 (1, (UINTN) HighBitSet64 (Operand));
}
diff --git a/UnixPkg/Library/UnixBaseLib/MultS64x64.c b/UnixPkg/Library/UnixBaseLib/MultS64x64.c index cbeaf02117..229c76ce68 100644 --- a/UnixPkg/Library/UnixBaseLib/MultS64x64.c +++ b/UnixPkg/Library/UnixBaseLib/MultS64x64.c @@ -38,5 +38,5 @@ MultS64x64 ( IN INT64 Multiplier
)
{
- return (INT64)MultU64x64 (Multiplicand, Multiplier);
+ return (INT64)MultU64x64 ((UINT64) Multiplicand, (UINT64) Multiplier);
}
diff --git a/UnixPkg/Library/UnixBaseLib/String.c b/UnixPkg/Library/UnixBaseLib/String.c index 2279720951..273291a915 100644 --- a/UnixPkg/Library/UnixBaseLib/String.c +++ b/UnixPkg/Library/UnixBaseLib/String.c @@ -14,17 +14,6 @@ #include "BaseLibInternals.h"
-#define QUOTIENT_MAX_UINTN_DIVIDED_BY_10 ((UINTN) -1 / 10)
-#define REMAINDER_MAX_UINTN_DIVIDED_BY_10 ((UINTN) -1 % 10)
-
-#define QUOTIENT_MAX_UINTN_DIVIDED_BY_16 ((UINTN) -1 / 16)
-#define REMAINDER_MAX_UINTN_DIVIDED_BY_16 ((UINTN) -1 % 16)
-
-#define QUOTIENT_MAX_UINT64_DIVIDED_BY_10 ((UINT64) -1 / 10)
-#define REMAINDER_MAX_UINT64_DIVIDED_BY_10 ((UINT64) -1 % 10)
-
-#define QUOTIENT_MAX_UINT64_DIVIDED_BY_16 ((UINT64) -1 / 16)
-#define REMAINDER_MAX_UINT64_DIVIDED_BY_16 ((UINT64) -1 % 16)
/**
Copies one Null-terminated Unicode string to another Null-terminated Unicode
@@ -681,10 +670,7 @@ StrDecimalToUintn ( // If the number represented by String overflows according
// to the range defined by UINTN, then ASSERT().
//
- ASSERT ((Result < QUOTIENT_MAX_UINTN_DIVIDED_BY_10) ||
- ((Result == QUOTIENT_MAX_UINTN_DIVIDED_BY_10) &&
- (*String - L'0') <= REMAINDER_MAX_UINTN_DIVIDED_BY_10)
- );
+ ASSERT (Result <= ((((UINTN) ~0) - (*String - L'0')) / 10));
Result = Result * 10 + (*String - L'0');
String++;
@@ -763,10 +749,7 @@ StrDecimalToUint64 ( // If the number represented by String overflows according
// to the range defined by UINTN, then ASSERT().
//
- ASSERT ((Result < QUOTIENT_MAX_UINT64_DIVIDED_BY_10) ||
- ((Result == QUOTIENT_MAX_UINT64_DIVIDED_BY_10) &&
- (*String - L'0') <= REMAINDER_MAX_UINT64_DIVIDED_BY_10)
- );
+ ASSERT (Result <= DivU64x32 (((UINT64) ~0) - (*String - L'0') , 10));
Result = MultU64x32 (Result, 10) + (*String - L'0');
String++;
@@ -855,10 +838,7 @@ StrHexToUintn ( // If the Hex Number represented by String overflows according
// to the range defined by UINTN, then ASSERT().
//
- ASSERT ((Result < QUOTIENT_MAX_UINTN_DIVIDED_BY_16) ||
- ((Result == QUOTIENT_MAX_UINTN_DIVIDED_BY_16) &&
- (InternalHexCharToUintn (*String) <= REMAINDER_MAX_UINTN_DIVIDED_BY_16))
- );
+ ASSERT (Result <= ((((UINTN) ~0) - InternalHexCharToUintn (*String)) >> 4));
Result = (Result << 4) + InternalHexCharToUintn (*String);
String++;
@@ -949,10 +929,7 @@ StrHexToUint64 ( // If the Hex Number represented by String overflows according
// to the range defined by UINTN, then ASSERT().
//
- ASSERT ((Result < QUOTIENT_MAX_UINT64_DIVIDED_BY_16)||
- ((Result == QUOTIENT_MAX_UINT64_DIVIDED_BY_16) &&
- (InternalHexCharToUintn (*String) <= REMAINDER_MAX_UINT64_DIVIDED_BY_16))
- );
+ ASSERT (Result <= RShiftU64 (((UINT64) ~0) - InternalHexCharToUintn (*String) , 4));
Result = LShiftU64 (Result, 4);
Result = Result + InternalHexCharToUintn (*String);
@@ -1716,10 +1693,7 @@ AsciiStrDecimalToUintn ( // If the number represented by String overflows according
// to the range defined by UINTN, then ASSERT().
//
- ASSERT ((Result < QUOTIENT_MAX_UINTN_DIVIDED_BY_10) ||
- ((Result == QUOTIENT_MAX_UINTN_DIVIDED_BY_10) &&
- (*String - '0') <= REMAINDER_MAX_UINTN_DIVIDED_BY_10)
- );
+ ASSERT (Result <= ((((UINTN) ~0) - (*String - L'0')) / 10));
Result = Result * 10 + (*String - '0');
String++;
@@ -1793,10 +1767,7 @@ AsciiStrDecimalToUint64 ( // If the number represented by String overflows according
// to the range defined by UINTN, then ASSERT().
//
- ASSERT ((Result < QUOTIENT_MAX_UINT64_DIVIDED_BY_10) ||
- ((Result == QUOTIENT_MAX_UINT64_DIVIDED_BY_10) &&
- (*String - '0') <= REMAINDER_MAX_UINT64_DIVIDED_BY_10)
- );
+ ASSERT (Result <= DivU64x32 (((UINT64) ~0) - (*String - L'0') , 10));
Result = MultU64x32 (Result, 10) + (*String - '0');
String++;
@@ -1884,10 +1855,7 @@ AsciiStrHexToUintn ( // If the Hex Number represented by String overflows according
// to the range defined by UINTN, then ASSERT().
//
- ASSERT ((Result < QUOTIENT_MAX_UINTN_DIVIDED_BY_16) ||
- ((Result == QUOTIENT_MAX_UINTN_DIVIDED_BY_16) &&
- (InternalAsciiHexCharToUintn (*String) <= REMAINDER_MAX_UINTN_DIVIDED_BY_16))
- );
+ ASSERT (Result <= ((((UINTN) ~0) - InternalHexCharToUintn (*String)) >> 4));
Result = (Result << 4) + InternalAsciiHexCharToUintn (*String);
String++;
@@ -1979,10 +1947,7 @@ AsciiStrHexToUint64 ( // If the Hex Number represented by String overflows according
// to the range defined by UINTN, then ASSERT().
//
- ASSERT ((Result < QUOTIENT_MAX_UINT64_DIVIDED_BY_16) ||
- ((Result == QUOTIENT_MAX_UINT64_DIVIDED_BY_16) &&
- (InternalAsciiHexCharToUintn (*String) <= REMAINDER_MAX_UINT64_DIVIDED_BY_16))
- );
+ ASSERT (Result <= RShiftU64 (((UINT64) ~0) - InternalHexCharToUintn (*String) , 4));
Result = LShiftU64 (Result, 4);
Result = Result + InternalAsciiHexCharToUintn (*String);
diff --git a/UnixPkg/Library/UnixBaseLib/X64/LongJump.S b/UnixPkg/Library/UnixBaseLib/X64/LongJump.S index d17592cf37..f20446fcf0 100644 --- a/UnixPkg/Library/UnixBaseLib/X64/LongJump.S +++ b/UnixPkg/Library/UnixBaseLib/X64/LongJump.S @@ -23,12 +23,12 @@ # VOID
# EFIAPI
# InternalLongJump (
-# IN BASE_LIBRARY_JUMP_BUFFER *JumpBuffer, // %rcx
-# IN UINTN Value // %rdx
+# IN BASE_LIBRARY_JUMP_BUFFER *JumpBuffer,
+# IN UINTN Value
# );
#------------------------------------------------------------------------------
-ASM_GLOBAL ASM_PFX(EfiInternalLongJump)
-ASM_PFX(EfiInternalLongJump):
+ASM_GLOBAL ASM_PFX(InternalLongJump)
+ASM_PFX(InternalLongJump):
mov (%rcx), %rbx
mov 0x8(%rcx), %rsp
mov 0x10(%rcx), %rbp
@@ -52,37 +52,3 @@ ASM_PFX(EfiInternalLongJump): movdqu 0xE8(%rcx), %xmm15
mov %rdx, %rax # set return value
jmp *0x48(%rcx)
-
-#------------------------------------------------------------------------------
-# VOID
-# EFIAPI
-# UnixInternalLongJump (
-# IN BASE_LIBRARY_JUMP_BUFFER *JumpBuffer, // %rdi
-# IN UINTN Value // %rsi
-# );
-#------------------------------------------------------------------------------
-ASM_GLOBAL ASM_PFX(InternalLongJump)
-ASM_PFX(InternalLongJump):
- mov (%rdi), %rbx
- mov 0x8(%rdi), %rsp
- mov 0x10(%rdi), %rbp
- mov 0x18(%rdi), %rdi
- mov 0x20(%rdi), %rsi
- mov 0x28(%rdi), %r12
- mov 0x30(%rdi), %r13
- mov 0x38(%rdi), %r14
- mov 0x40(%rdi), %r15
- # load non-volatile fp registers
- ldmxcsr 0x50(%rdi)
- movdqu 0x58(%rdi), %xmm6
- movdqu 0x68(%rdi), %xmm7
- movdqu 0x78(%rdi), %xmm8
- movdqu 0x88(%rdi), %xmm9
- movdqu 0x98(%rdi), %xmm10
- movdqu 0xA8(%rdi), %xmm11
- movdqu 0xB8(%rdi), %xmm12
- movdqu 0xC8(%rdi), %xmm13
- movdqu 0xD8(%rdi), %xmm14
- movdqu 0xE8(%rdi), %xmm15
- mov %rsi, %rax # set return value
- jmp *0x48(%rdi)
diff --git a/UnixPkg/Library/UnixBaseLib/X64/SetJump.S b/UnixPkg/Library/UnixBaseLib/X64/SetJump.S index b5fd38ab6a..ea9e225a93 100644 --- a/UnixPkg/Library/UnixBaseLib/X64/SetJump.S +++ b/UnixPkg/Library/UnixBaseLib/X64/SetJump.S @@ -19,8 +19,8 @@ #
#------------------------------------------------------------------------------
-ASM_GLOBAL ASM_PFX(EfiSetJump)
-ASM_PFX(EfiSetJump):
+ASM_GLOBAL ASM_PFX(SetJump)
+ASM_PFX(SetJump):
push %rcx
add $0xffffffffffffffe0,%rsp
call ASM_PFX(InternalAssertJumpBuffer)
@@ -51,32 +51,3 @@ ASM_PFX(EfiSetJump): movdqu %xmm15, 0xE8(%rcx)
xor %rax,%rax
jmpq *%rdx
-
-
-ASM_GLOBAL ASM_PFX(SetJump)
-ASM_PFX(SetJump):
- pop %rdx
- mov %rbx,(%rdi) # Rbx
- mov %rsp,0x8(%rdi)
- mov %rbp,0x10(%rdi)
- mov %rcx,0x18(%rdi)
- mov %rsi,0x20(%rdi)
- mov %r12,0x28(%rdi)
- mov %r13,0x30(%rdi)
- mov %r14,0x38(%rdi)
- mov %r15,0x40(%rdi)
- mov %rdx,0x48(%rdi)
- # save non-volatile fp registers
- stmxcsr 0x50(%rdi)
- movdqu %xmm6, 0x58(%rdi)
- movdqu %xmm7, 0x68(%rdi)
- movdqu %xmm8, 0x78(%rdi)
- movdqu %xmm9, 0x88(%rdi)
- movdqu %xmm10, 0x98(%rdi)
- movdqu %xmm11, 0xA8(%rdi)
- movdqu %xmm12, 0xB8(%rdi)
- movdqu %xmm13, 0xC8(%rdi)
- movdqu %xmm14, 0xD8(%rdi)
- movdqu %xmm15, 0xE8(%rdi)
- xor %rax,%rax
- jmpq *%rdx
diff --git a/UnixPkg/Library/UnixBaseLib/X64/SwitchStack.S b/UnixPkg/Library/UnixBaseLib/X64/SwitchStack.S index b6dff5ed77..3a84b0d22f 100644 --- a/UnixPkg/Library/UnixBaseLib/X64/SwitchStack.S +++ b/UnixPkg/Library/UnixBaseLib/X64/SwitchStack.S @@ -35,45 +35,17 @@ # None
#
#------------------------------------------------------------------------------
-ASM_GLOBAL ASM_PFX(EfiInternalSwitchStack)
-ASM_PFX(EfiInternalSwitchStack):
- mov %rcx, %rax
- mov %rdx, %rcx
- mov %r8, %rdx
- #
- # Reserve space for register parameters (rcx, rdx, r8 & r9) on the stack,
- # in case the callee wishes to spill them.
- #
- lea -0x20(%r9), %rsp
- call *%rax
-
-
-
-#------------------------------------------------------------------------------
-# Routine Description:
-#
-# Routine for switching stacks with 2 parameters (Unix ABI)
-#
-# Arguments:
-#
-# (rdi) EntryPoint - Entry point with new stack.
-# (rsi) Context1 - Parameter1 for entry point.
-# (rdx) Context2 - Parameter2 for entry point.
-# (rcx) NewStack - The pointer to new stack.
-#
-# Returns:
-#
-# None
-#
-#------------------------------------------------------------------------------
ASM_GLOBAL ASM_PFX(InternalSwitchStack)
ASM_PFX(InternalSwitchStack):
- mov %rdi, %rax
- mov %rsi, %rdi
- mov %rdx, %rsi
+ movq %rcx, %rax
+ movq %rdx, %rcx
+ movq %r8, %rdx
+ movq %r9, %rsp
+
#
# Reserve space for register parameters (rcx, rdx, r8 & r9) on the stack,
# in case the callee wishes to spill them.
#
- lea -0x20(%rcx), %rsp
+ subq $40, %rsp // 32-byte shadow space plus alignment pad
+
call *%rax
diff --git a/UnixPkg/Sec/Ia32/Gasket.S b/UnixPkg/Sec/Ia32/Gasket.S index 0464090527..93d92b50de 100644 --- a/UnixPkg/Sec/Ia32/Gasket.S +++ b/UnixPkg/Sec/Ia32/Gasket.S @@ -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
diff --git a/UnixPkg/Sec/SecMain.c b/UnixPkg/Sec/SecMain.c index 4d66bfa301..76ac58e636 100644 --- a/UnixPkg/Sec/SecMain.c +++ b/UnixPkg/Sec/SecMain.c @@ -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); } diff --git a/UnixPkg/Sec/SecMain.h b/UnixPkg/Sec/SecMain.h index 27edff873f..9d34787fc4 100644 --- a/UnixPkg/Sec/SecMain.h +++ b/UnixPkg/Sec/SecMain.h @@ -59,6 +59,15 @@ SecUnixPeiLoadFile ( 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
+ EFI_PHYSICAL_ADDRESS *EntryPoint // TODO: add IN/OUT modifier to EntryPoint
)
/*++
@@ -86,6 +95,14 @@ 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
)
/*++
@@ -110,6 +127,12 @@ VOID * EFIAPI
SecUnixUnixThunkAddress (
VOID
+ );
+
+VOID *
+EFIAPI
+GasketSecUnixUnixThunkAddress (
+ VOID
)
/*++
@@ -134,6 +157,13 @@ 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
)
/*++
@@ -162,6 +192,17 @@ SecPeiReportStatusCode ( 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,
+ IN UINT32 Instance,
+ IN CONST EFI_GUID *CallerId,
+ IN CONST EFI_STATUS_CODE_DATA *Data OPTIONAL
)
/*++
@@ -396,6 +437,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,
IN EFI_PHYSICAL_ADDRESS *TopOfMemory
@@ -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
diff --git a/UnixPkg/Sec/SecMain.inf b/UnixPkg/Sec/SecMain.inf index 88477c60cd..3bad28bf59 100644 --- a/UnixPkg/Sec/SecMain.inf +++ b/UnixPkg/Sec/SecMain.inf @@ -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
diff --git a/UnixPkg/Sec/UnixThunk.c b/UnixPkg/Sec/UnixThunk.c index 29d9328d90..6c9bb74ce0 100644 --- a/UnixPkg/Sec/UnixThunk.c +++ b/UnixPkg/Sec/UnixThunk.c @@ -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); } diff --git a/UnixPkg/Sec/X64/Gasket.S b/UnixPkg/Sec/X64/Gasket.S index 2797d84de6..4d6123f555 100644 --- a/UnixPkg/Sec/X64/Gasket.S +++ b/UnixPkg/Sec/X64/Gasket.S @@ -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: diff --git a/UnixPkg/Sec/X64/MangleGasket.S b/UnixPkg/Sec/X64/MangleGasket.S index d496fcba15..f29b1e314d 100644 --- a/UnixPkg/Sec/X64/MangleGasket.S +++ b/UnixPkg/Sec/X64/MangleGasket.S @@ -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 + + + + + diff --git a/UnixPkg/Sec/X64/SwitchStack.S b/UnixPkg/Sec/X64/SwitchStack.S index 9f62e71cef..dfb618b395 100644 --- a/UnixPkg/Sec/X64/SwitchStack.S +++ b/UnixPkg/Sec/X64/SwitchStack.S @@ -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
diff --git a/UnixPkg/UnixPkgX64.dsc b/UnixPkg/UnixPkgX64.dsc index d6e87fa796..e843d09863 100644 --- a/UnixPkg/UnixPkgX64.dsc +++ b/UnixPkg/UnixPkgX64.dsc @@ -155,6 +155,7 @@ PrintLib|MdeModulePkg/Library/DxePrintLibPrint2Protocol/DxePrintLibPrint2Protocol.inf
[LibraryClasses.X64]
+ # turn off CR3 write so that DXE IPL will not crash emulator
BaseLib|UnixPkg/Library/UnixBaseLib/UnixBaseLib.inf
################################################################################
@@ -222,11 +223,12 @@ #
###################################################################################################
[Components.common]
+!if $(SEC_ONLY)
##
# SEC Phase modules
##
UnixPkg/Sec/SecMain.inf
-
+!else
##
# PEI Phase modules
##
@@ -322,4 +324,4 @@ }
FatPkg/EnhancedFatDxe/Fat.inf
-
+!endif
diff --git a/UnixPkg/UnixPkgX64.fdf b/UnixPkg/UnixPkgX64.fdf index 706824d21c..9f677464e1 100644 --- a/UnixPkg/UnixPkgX64.fdf +++ b/UnixPkg/UnixPkgX64.fdf @@ -31,7 +31,7 @@ # buffer for the FD (0x41000000). If this address does not match the FV will get
# relocated in place (works, but not a great idea).
#
-BaseAddress = 0x41000000|gEfiUnixPkgTokenSpaceGuid.PcdUnixFdBaseAddress #The base address of the FLASH Device.
+BaseAddress = 0x102000000|gEfiUnixPkgTokenSpaceGuid.PcdUnixFdBaseAddress #The base address of the FLASH Device.
Size = 0x004a0000|gEfiUnixPkgTokenSpaceGuid.PcdUnixFirmwareFdSize #The size in bytes of the FLASH Device
ErasePolarity = 1
BlockSize = 0x10000
@@ -244,16 +244,17 @@ INF MdeModulePkg/Application/HelloWorld/HelloWorld.inf #INF MdeModulePkg/Universal/Network/Udp4Dxe/Udp4Dxe.inf
#INF UnixPkg/SnpUnixDxe/SnpUnixDxe.inf
+!if $(COMPILE_BINS)
INF FatPkg/EnhancedFatDxe/Fat.inf
-FILE APPLICATION = PCD(gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdShellFile) {
- SECTION PE32 =Build/GccShellPkg/DEBUG_XCODE32/X64/ShellFull.efi
+ FILE APPLICATION = PCD(gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdShellFile) {
+ SECTION PE32 =Build/GccShellPkg/DEBUG_UNIXPKG/X64/ShellFull.efi
}
-
-# Note: Warning current X64 port does not use EFI ABI so thease bins will crash
-#INF RuleOverride = BINARY USE = X64 FatBinPkg/EnhancedFatDxe/Fat.inf
-#INF RuleOverride = BINARY USE = X64 EdkShellBinPkg/FullShell/FullShell.inf
-
+!else
+# Used checked in Visual Studio binaries
+INF RuleOverride = BINARY USE = X64 FatBinPkg/EnhancedFatDxe/Fat.inf
+INF RuleOverride = BINARY USE = X64 EdkShellBinPkg/FullShell/FullShell.inf
+!endif
FILE FREEFORM = PCD(gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdLogoFile) {
SECTION RAW = MdeModulePkg/Logo/Logo.bmp
diff --git a/UnixPkg/UnixUgaDxe/UnixUgaScreen.c b/UnixPkg/UnixUgaDxe/UnixUgaScreen.c index ddd2fc28fb..45e84b0f25 100644 --- a/UnixPkg/UnixUgaDxe/UnixUgaScreen.c +++ b/UnixPkg/UnixUgaDxe/UnixUgaScreen.c @@ -256,7 +256,7 @@ UnixUgaBlt ( // doing this operation. // OriginalTPL = gBS->RaiseTPL (TPL_NOTIFY); - + // // Pack UGA Draw protocol parameters to UGA_BLT_ARGS structure to adapt to // UgaBlt() API of Unix UGA IO protocol. diff --git a/UnixPkg/build64.sh b/UnixPkg/build64.sh index f2a6927d57..c80d29591d 100755 --- a/UnixPkg/build64.sh +++ b/UnixPkg/build64.sh @@ -14,7 +14,6 @@ set -e shopt -s nocasematch - # # Setup workspace if it is not set # @@ -37,6 +36,7 @@ fi # Pick a default tool type for a given OS # TARGET_TOOLS=MYTOOLS +UNIXPKG_TOOLS=UNIXPKG case `uname` in CYGWIN*) echo Cygwin not fully supported yet. ;; Darwin*) @@ -53,7 +53,7 @@ case `uname` in esac -BUILD_ROOT_ARCH=$WORKSPACE/Build/UnixX64/DEBUG_"$TARGET_TOOLS"/X64 +BUILD_ROOT_ARCH=$WORKSPACE/Build/UnixX64/DEBUG_"$UNIXPKG_TOOLS"/X64 if [[ ! -f `which build` || ! -f `which GenFv` ]]; then @@ -80,7 +80,7 @@ do # 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/UnixX64/DEBUG_"$TARGET_TOOLS"/X64 + cp $WORKSPACE/UnixPkg/.gdbinit $WORKSPACE/Build/UnixX64/DEBUG_"$UNIXPKG_TOOLS"/X64 ;; esac @@ -92,7 +92,7 @@ do make -C $WORKSPACE/BaseTools clean fi if [[ $arg == shell ]]; then - build -p $WORKSPACE/GccShellPkg/GccShellPkg.dsc -a X64 -t $TARGET_TOOLS -n 3 $2 $3 $4 $5 $6 $7 $8 + build -p $WORKSPACE/GccShellPkg/GccShellPkg.dsc -a X64 -t $UNIXPKG_TOOLS -n 3 $2 $3 $4 $5 $6 $7 $8 exit $? fi @@ -105,6 +105,8 @@ done # echo $PATH echo `which build` -build -p $WORKSPACE/UnixPkg/UnixPkgX64.dsc -a X64 -t $TARGET_TOOLS -n 3 $1 $2 $3 $4 $5 $6 $7 $8 +build -p $WORKSPACE/UnixPkg/UnixPkgX64.dsc -a X64 -t $TARGET_TOOLS -D SEC_ONLY -n 3 $1 $2 $3 $4 $5 $6 $7 $8 modules +build -p $WORKSPACE/UnixPkg/UnixPkgX64.dsc -a X64 -t $UNIXPKG_TOOLS -n 3 $1 $2 $3 $4 $5 $6 $7 $8 +cp $WORKSPACE/Build/UnixX64/DEBUG_"$TARGET_TOOLS"/X64/SecMain $WORKSPACE/Build/UnixX64/DEBUG_"$UNIXPKG_TOOLS"/X64 exit $? |