]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Added support for an EFI X64 ABI compatible UnixPkg. With an internal only compiler...
authorandrewfish <andrewfish@6f19259b-4bc3-4df7-8a09-765794883524>
Wed, 18 Aug 2010 20:24:08 +0000 (20:24 +0000)
committerandrewfish <andrewfish@6f19259b-4bc3-4df7-8a09-765794883524>
Wed, 18 Aug 2010 20:24:08 +0000 (20:24 +0000)
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@10806 6f19259b-4bc3-4df7-8a09-765794883524

18 files changed:
UnixPkg/Library/UnixBaseLib/GetPowerOfTwo64.c
UnixPkg/Library/UnixBaseLib/MultS64x64.c
UnixPkg/Library/UnixBaseLib/String.c
UnixPkg/Library/UnixBaseLib/X64/LongJump.S
UnixPkg/Library/UnixBaseLib/X64/SetJump.S
UnixPkg/Library/UnixBaseLib/X64/SwitchStack.S
UnixPkg/Sec/Ia32/Gasket.S
UnixPkg/Sec/SecMain.c
UnixPkg/Sec/SecMain.h
UnixPkg/Sec/SecMain.inf
UnixPkg/Sec/UnixThunk.c
UnixPkg/Sec/X64/Gasket.S
UnixPkg/Sec/X64/MangleGasket.S
UnixPkg/Sec/X64/SwitchStack.S
UnixPkg/UnixPkgX64.dsc
UnixPkg/UnixPkgX64.fdf
UnixPkg/UnixUgaDxe/UnixUgaScreen.c
UnixPkg/build64.sh

index 4623c2a656a40747d146f53a7031b365ef759c08..3574bc4d3c8e5a4bb4416631bbbe11339047076b 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Math worker functions.\r
 \r
-  Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>\r
   This program and the accompanying materials\r
   are licensed and made available under the terms and conditions of the BSD License\r
   which accompanies this distribution.  The full text of the license may be found at\r
@@ -40,5 +40,5 @@ GetPowerOfTwo64 (
     return 0;\r
   }\r
 \r
-  return LShiftU64 (1, HighBitSet64 (Operand));\r
+  return LShiftU64 (1, (UINTN) HighBitSet64 (Operand));\r
 }\r
index cbeaf02117785c737b3b3dcf6f378f7cbbad5c0c..229c76ce6806d549674223b8fe176b6c597ff33a 100644 (file)
@@ -38,5 +38,5 @@ MultS64x64 (
   IN      INT64                     Multiplier\r
   )\r
 {\r
-  return (INT64)MultU64x64 (Multiplicand, Multiplier);\r
+  return (INT64)MultU64x64 ((UINT64) Multiplicand, (UINT64) Multiplier);\r
 }\r
index 2279720951f347bedf65ac529bb3205b5c1cdecc..273291a915b281ce1eebeaa611b63074da2a9a24 100644 (file)
 \r
 #include "BaseLibInternals.h"\r
 \r
-#define QUOTIENT_MAX_UINTN_DIVIDED_BY_10      ((UINTN) -1 / 10)\r
-#define REMAINDER_MAX_UINTN_DIVIDED_BY_10    ((UINTN) -1 % 10)\r
-\r
-#define QUOTIENT_MAX_UINTN_DIVIDED_BY_16      ((UINTN) -1 / 16)\r
-#define REMAINDER_MAX_UINTN_DIVIDED_BY_16    ((UINTN) -1 % 16)\r
-\r
-#define QUOTIENT_MAX_UINT64_DIVIDED_BY_10      ((UINT64) -1 / 10)\r
-#define REMAINDER_MAX_UINT64_DIVIDED_BY_10    ((UINT64) -1 % 10)\r
-\r
-#define QUOTIENT_MAX_UINT64_DIVIDED_BY_16      ((UINT64) -1 / 16)\r
-#define REMAINDER_MAX_UINT64_DIVIDED_BY_16    ((UINT64) -1 % 16)\r
 \r
 /**\r
   Copies one Null-terminated Unicode string to another Null-terminated Unicode\r
@@ -681,10 +670,7 @@ StrDecimalToUintn (
     // If the number represented by String overflows according \r
     // to the range defined by UINTN, then ASSERT().\r
     //\r
-    ASSERT ((Result < QUOTIENT_MAX_UINTN_DIVIDED_BY_10) ||\r
-      ((Result == QUOTIENT_MAX_UINTN_DIVIDED_BY_10) &&\r
-      (*String - L'0') <= REMAINDER_MAX_UINTN_DIVIDED_BY_10)\r
-      );\r
+    ASSERT (Result <= ((((UINTN) ~0) - (*String - L'0')) / 10));\r
 \r
     Result = Result * 10 + (*String - L'0');\r
     String++;\r
@@ -763,10 +749,7 @@ StrDecimalToUint64 (
     // If the number represented by String overflows according \r
     // to the range defined by UINTN, then ASSERT().\r
     //\r
-    ASSERT ((Result < QUOTIENT_MAX_UINT64_DIVIDED_BY_10) || \r
-      ((Result == QUOTIENT_MAX_UINT64_DIVIDED_BY_10) && \r
-      (*String - L'0') <= REMAINDER_MAX_UINT64_DIVIDED_BY_10)\r
-      );\r
+    ASSERT (Result <= DivU64x32 (((UINT64) ~0) - (*String - L'0') , 10));\r
 \r
     Result = MultU64x32 (Result, 10) + (*String - L'0');\r
     String++;\r
@@ -855,10 +838,7 @@ StrHexToUintn (
     // If the Hex Number represented by String overflows according \r
     // to the range defined by UINTN, then ASSERT().\r
     //\r
-    ASSERT ((Result < QUOTIENT_MAX_UINTN_DIVIDED_BY_16) ||\r
-      ((Result == QUOTIENT_MAX_UINTN_DIVIDED_BY_16) && \r
-      (InternalHexCharToUintn (*String) <= REMAINDER_MAX_UINTN_DIVIDED_BY_16))\r
-      );\r
+    ASSERT (Result <= ((((UINTN) ~0) - InternalHexCharToUintn (*String)) >> 4));\r
 \r
     Result = (Result << 4) + InternalHexCharToUintn (*String);\r
     String++;\r
@@ -949,10 +929,7 @@ StrHexToUint64 (
     // If the Hex Number represented by String overflows according \r
     // to the range defined by UINTN, then ASSERT().\r
     //\r
-    ASSERT ((Result < QUOTIENT_MAX_UINT64_DIVIDED_BY_16)|| \r
-      ((Result == QUOTIENT_MAX_UINT64_DIVIDED_BY_16) && \r
-      (InternalHexCharToUintn (*String) <= REMAINDER_MAX_UINT64_DIVIDED_BY_16))\r
-      );\r
+    ASSERT (Result <= RShiftU64 (((UINT64) ~0) - InternalHexCharToUintn (*String) , 4));\r
 \r
     Result = LShiftU64 (Result, 4);\r
     Result = Result + InternalHexCharToUintn (*String);\r
@@ -1716,10 +1693,7 @@ AsciiStrDecimalToUintn (
     // If the number represented by String overflows according \r
     // to the range defined by UINTN, then ASSERT().\r
     //\r
-    ASSERT ((Result < QUOTIENT_MAX_UINTN_DIVIDED_BY_10) ||\r
-      ((Result == QUOTIENT_MAX_UINTN_DIVIDED_BY_10) && \r
-      (*String - '0') <= REMAINDER_MAX_UINTN_DIVIDED_BY_10)\r
-      );\r
+    ASSERT (Result <= ((((UINTN) ~0) - (*String - L'0')) / 10));\r
 \r
     Result = Result * 10 + (*String - '0');\r
     String++;\r
@@ -1793,10 +1767,7 @@ AsciiStrDecimalToUint64 (
     // If the number represented by String overflows according \r
     // to the range defined by UINTN, then ASSERT().\r
     //\r
-    ASSERT ((Result < QUOTIENT_MAX_UINT64_DIVIDED_BY_10) || \r
-      ((Result == QUOTIENT_MAX_UINT64_DIVIDED_BY_10) && \r
-      (*String - '0') <= REMAINDER_MAX_UINT64_DIVIDED_BY_10)\r
-      );\r
+    ASSERT (Result <= DivU64x32 (((UINT64) ~0) - (*String - L'0') , 10));\r
 \r
     Result = MultU64x32 (Result, 10) + (*String - '0');\r
     String++;\r
@@ -1884,10 +1855,7 @@ AsciiStrHexToUintn (
     // If the Hex Number represented by String overflows according \r
     // to the range defined by UINTN, then ASSERT().\r
     //\r
-     ASSERT ((Result < QUOTIENT_MAX_UINTN_DIVIDED_BY_16) ||\r
-       ((Result == QUOTIENT_MAX_UINTN_DIVIDED_BY_16) && \r
-       (InternalAsciiHexCharToUintn (*String) <= REMAINDER_MAX_UINTN_DIVIDED_BY_16))\r
-       );\r
+    ASSERT (Result <= ((((UINTN) ~0) - InternalHexCharToUintn (*String)) >> 4));\r
 \r
     Result = (Result << 4) + InternalAsciiHexCharToUintn (*String);\r
     String++;\r
@@ -1979,10 +1947,7 @@ AsciiStrHexToUint64 (
     // If the Hex Number represented by String overflows according \r
     // to the range defined by UINTN, then ASSERT().\r
     //\r
-    ASSERT ((Result < QUOTIENT_MAX_UINT64_DIVIDED_BY_16) ||\r
-      ((Result == QUOTIENT_MAX_UINT64_DIVIDED_BY_16) && \r
-      (InternalAsciiHexCharToUintn (*String) <= REMAINDER_MAX_UINT64_DIVIDED_BY_16))\r
-      );\r
+    ASSERT (Result <= RShiftU64 (((UINT64) ~0) - InternalHexCharToUintn (*String) , 4));\r
 \r
     Result = LShiftU64 (Result, 4);\r
     Result = Result + InternalAsciiHexCharToUintn (*String);\r
index d17592cf379052ca3d756f2e20fb635443c41a32..f20446fcf01fa1683ec5574c4bd2815118d56a05 100644 (file)
 # VOID\r
 # EFIAPI\r
 # InternalLongJump (\r
-#   IN      BASE_LIBRARY_JUMP_BUFFER  *JumpBuffer, // %rcx\r
-#   IN      UINTN                     Value        // %rdx\r
+#   IN      BASE_LIBRARY_JUMP_BUFFER  *JumpBuffer,\r
+#   IN      UINTN                     Value\r
 #   );\r
 #------------------------------------------------------------------------------\r
-ASM_GLOBAL ASM_PFX(EfiInternalLongJump)\r
-ASM_PFX(EfiInternalLongJump):\r
+ASM_GLOBAL ASM_PFX(InternalLongJump)\r
+ASM_PFX(InternalLongJump):\r
     mov     (%rcx), %rbx\r
     mov     0x8(%rcx), %rsp\r
     mov     0x10(%rcx), %rbp\r
@@ -52,37 +52,3 @@ ASM_PFX(EfiInternalLongJump):
     movdqu  0xE8(%rcx), %xmm15  \r
     mov     %rdx, %rax          # set return value\r
     jmp     *0x48(%rcx)\r
-\r
-#------------------------------------------------------------------------------\r
-# VOID\r
-# EFIAPI\r
-# UnixInternalLongJump (\r
-#   IN      BASE_LIBRARY_JUMP_BUFFER  *JumpBuffer, // %rdi\r
-#   IN      UINTN                     Value        // %rsi\r
-#   );\r
-#------------------------------------------------------------------------------\r
-ASM_GLOBAL ASM_PFX(InternalLongJump)\r
-ASM_PFX(InternalLongJump):\r
-    mov     (%rdi), %rbx\r
-    mov     0x8(%rdi), %rsp\r
-    mov     0x10(%rdi), %rbp\r
-    mov     0x18(%rdi), %rdi\r
-    mov     0x20(%rdi), %rsi\r
-    mov     0x28(%rdi), %r12\r
-    mov     0x30(%rdi), %r13\r
-    mov     0x38(%rdi), %r14\r
-    mov     0x40(%rdi), %r15\r
-    # load non-volatile fp registers\r
-    ldmxcsr 0x50(%rdi)\r
-    movdqu  0x58(%rdi), %xmm6\r
-    movdqu  0x68(%rdi), %xmm7\r
-    movdqu  0x78(%rdi), %xmm8\r
-    movdqu  0x88(%rdi), %xmm9\r
-    movdqu  0x98(%rdi), %xmm10\r
-    movdqu  0xA8(%rdi), %xmm11\r
-    movdqu  0xB8(%rdi), %xmm12\r
-    movdqu  0xC8(%rdi), %xmm13\r
-    movdqu  0xD8(%rdi), %xmm14\r
-    movdqu  0xE8(%rdi), %xmm15  \r
-    mov     %rsi, %rax          # set return value\r
-    jmp     *0x48(%rdi)\r
index b5fd38ab6ab127c66bf8f268e838b1c546086b9e..ea9e225a938e657461ddbf1ddff3435250f13900 100644 (file)
@@ -19,8 +19,8 @@
 #\r
 #------------------------------------------------------------------------------\r
 \r
-ASM_GLOBAL ASM_PFX(EfiSetJump)\r
-ASM_PFX(EfiSetJump):\r
+ASM_GLOBAL ASM_PFX(SetJump)\r
+ASM_PFX(SetJump):\r
     push   %rcx\r
     add    $0xffffffffffffffe0,%rsp\r
     call   ASM_PFX(InternalAssertJumpBuffer)\r
@@ -51,32 +51,3 @@ ASM_PFX(EfiSetJump):
     movdqu  %xmm15, 0xE8(%rcx)     \r
     xor    %rax,%rax\r
     jmpq   *%rdx\r
-    \r
-    \r
-ASM_GLOBAL ASM_PFX(SetJump)\r
-ASM_PFX(SetJump):\r
-    pop    %rdx\r
-    mov    %rbx,(%rdi)                  # Rbx\r
-    mov    %rsp,0x8(%rdi)\r
-    mov    %rbp,0x10(%rdi)\r
-    mov    %rcx,0x18(%rdi)\r
-    mov    %rsi,0x20(%rdi)\r
-    mov    %r12,0x28(%rdi)\r
-    mov    %r13,0x30(%rdi)\r
-    mov    %r14,0x38(%rdi)\r
-    mov    %r15,0x40(%rdi)\r
-    mov    %rdx,0x48(%rdi)\r
-    # save non-volatile fp registers\r
-    stmxcsr 0x50(%rdi)\r
-    movdqu  %xmm6, 0x58(%rdi) \r
-    movdqu  %xmm7, 0x68(%rdi)\r
-    movdqu  %xmm8, 0x78(%rdi)\r
-    movdqu  %xmm9, 0x88(%rdi)\r
-    movdqu  %xmm10, 0x98(%rdi)\r
-    movdqu  %xmm11, 0xA8(%rdi)\r
-    movdqu  %xmm12, 0xB8(%rdi)\r
-    movdqu  %xmm13, 0xC8(%rdi)\r
-    movdqu  %xmm14, 0xD8(%rdi)\r
-    movdqu  %xmm15, 0xE8(%rdi)     \r
-    xor    %rax,%rax\r
-    jmpq   *%rdx\r
index b6dff5ed77463f1528dc982302b42fbc8b487797..3a84b0d22f8e79e425e98041fb764b295a78a5af 100644 (file)
 #   None\r
 #\r
 #------------------------------------------------------------------------------\r
-ASM_GLOBAL ASM_PFX(EfiInternalSwitchStack)\r
-ASM_PFX(EfiInternalSwitchStack):\r
-    mov     %rcx, %rax\r
-    mov     %rdx, %rcx\r
-    mov     %r8, %rdx\r
-    #\r
-    # Reserve space for register parameters (rcx, rdx, r8 & r9) on the stack,\r
-    # in case the callee wishes to spill them.\r
-    #\r
-    lea     -0x20(%r9), %rsp\r
-    call    *%rax\r
-\r
-\r
-\r
-#------------------------------------------------------------------------------\r
-# Routine Description:\r
-#\r
-#   Routine for switching stacks with 2 parameters (Unix ABI)\r
-#\r
-# Arguments:\r
-#\r
-#   (rdi) EntryPoint    - Entry point with new stack.\r
-#   (rsi) Context1      - Parameter1 for entry point.\r
-#   (rdx) Context2      - Parameter2 for entry point.\r
-#   (rcx) NewStack      - The pointer to new stack.\r
-#\r
-# Returns:\r
-#\r
-#   None\r
-#\r
-#------------------------------------------------------------------------------\r
 ASM_GLOBAL ASM_PFX(InternalSwitchStack)\r
 ASM_PFX(InternalSwitchStack):\r
-    mov     %rdi, %rax\r
-    mov     %rsi, %rdi\r
-    mov     %rdx, %rsi\r
+    movq    %rcx, %rax\r
+    movq    %rdx, %rcx\r
+    movq    %r8,  %rdx\r
+    movq    %r9,  %rsp\r
+\r
     #\r
     # Reserve space for register parameters (rcx, rdx, r8 & r9) on the stack,\r
     # in case the callee wishes to spill them.\r
     #\r
-    lea     -0x20(%rcx), %rsp\r
+         subq    $40, %rsp  // 32-byte shadow space plus alignment pad\r
+\r
     call    *%rax\r
index 046409052788b917cb5314d9edb4c91a4ca8d26a..93d92b50deb14ba02ae362494198093af19b9957 100644 (file)
@@ -256,7 +256,36 @@ _ReverseGasketUint64:
        ret\r
   \r
   \r
-  .subsections_via_symbols\r
+// Sec PPI Callbacks\r
+\r
+.globl _GasketSecUnixPeiLoadFile\r
+_GasketSecUnixPeiLoadFile:\r
+       jmp       _SecUnixPeiLoadFile\r
+\r
+\r
+.globl _GasketSecUnixPeiAutoScan\r
+_GasketSecUnixPeiAutoScan:\r
+       jmp       _SecUnixPeiAutoScan\r
+\r
+\r
+.globl _GasketSecUnixUnixThunkAddress\r
+_GasketSecUnixUnixThunkAddress:\r
+       jmp       _SecUnixUnixThunkAddress\r
+\r
+\r
+.globl _GasketSecPeiReportStatusCode\r
+_GasketSecPeiReportStatusCode:\r
+       jmp       _SecPeiReportStatusCode\r
+\r
+\r
+.globl _GasketSecUnixFdAddress\r
+_GasketSecUnixFdAddress:\r
+       jmp       _SecUnixFdAddress\r
+\r
+\r
+.globl _GasketSecTemporaryRamSupport\r
+_GasketSecTemporaryRamSupport:\r
+       jmp       _SecTemporaryRamSupport\r
   \r
   #endif\r
   \r
index 4d66bfa30125355c8b9e5a40c0880bbd39374b86..76ac58e63687dddcef89e61a600424fe6a8b661d 100644 (file)
@@ -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);
 }
index 27edff873f3c1119cdc5dbfae671b41f57e7dd8f..9d34787fc44684cbe910810c9ea4c420059ddb00 100644 (file)
@@ -55,6 +55,15 @@ typedef struct {
 EFI_STATUS\r
 EFIAPI\r
 SecUnixPeiLoadFile (\r
+  VOID                  *Pe32Data,  // TODO: add IN/OUT modifier to Pe32Data\r
+  EFI_PHYSICAL_ADDRESS  *ImageAddress,  // TODO: add IN/OUT modifier to ImageAddress\r
+  UINT64                *ImageSize,  // TODO: add IN/OUT modifier to ImageSize\r
+  EFI_PHYSICAL_ADDRESS  *EntryPoint  // TODO: add IN/OUT modifier to EntryPoint\r
+  );\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+GasketSecUnixPeiLoadFile (\r
   VOID                  *Pe32Data,  // TODO: add IN/OUT modifier to Pe32Data\r
   EFI_PHYSICAL_ADDRESS  *ImageAddress,  // TODO: add IN/OUT modifier to ImageAddress\r
   UINT64                *ImageSize,  // TODO: add IN/OUT modifier to ImageSize\r
@@ -83,6 +92,14 @@ Returns:
 EFI_STATUS\r
 EFIAPI\r
 SecUnixPeiAutoScan (\r
+  IN  UINTN                 Index,\r
+  OUT EFI_PHYSICAL_ADDRESS  *MemoryBase,\r
+  OUT UINT64                *MemorySize\r
+  );\r
+  \r
+EFI_STATUS\r
+EFIAPI\r
+GasketSecUnixPeiAutoScan (\r
   IN  UINTN                 Index,\r
   OUT EFI_PHYSICAL_ADDRESS  *MemoryBase,\r
   OUT UINT64                *MemorySize\r
@@ -109,6 +126,12 @@ Returns:
 VOID *\r
 EFIAPI\r
 SecUnixUnixThunkAddress (\r
+  VOID\r
+  );\r
+  \r
+VOID *\r
+EFIAPI\r
+GasketSecUnixUnixThunkAddress (\r
   VOID\r
   )\r
 /*++\r
@@ -132,6 +155,13 @@ Returns:
 EFI_STATUS\r
 EFIAPI\r
 SecUnixUnixFwhAddress (\r
+  IN OUT UINT64                *FwhSize,\r
+  IN OUT EFI_PHYSICAL_ADDRESS  *FwhBase\r
+  );\r
+  \r
+EFI_STATUS\r
+EFIAPI\r
+GasketSecUnixUnixFwhAddress (\r
   IN OUT UINT64                *FwhSize,\r
   IN OUT EFI_PHYSICAL_ADDRESS  *FwhBase\r
   )\r
@@ -156,6 +186,17 @@ Returns:
 EFI_STATUS\r
 EFIAPI\r
 SecPeiReportStatusCode (\r
+  IN CONST EFI_PEI_SERVICES     **PeiServices,\r
+  IN EFI_STATUS_CODE_TYPE       CodeType,\r
+  IN EFI_STATUS_CODE_VALUE      Value,\r
+  IN UINT32                     Instance,\r
+  IN CONST EFI_GUID             *CallerId,\r
+  IN CONST EFI_STATUS_CODE_DATA *Data OPTIONAL\r
+  );\r
+  \r
+EFI_STATUS\r
+EFIAPI\r
+GasketSecPeiReportStatusCode (\r
   IN CONST EFI_PEI_SERVICES     **PeiServices,\r
   IN EFI_STATUS_CODE_TYPE       CodeType,\r
   IN EFI_STATUS_CODE_VALUE      Value,\r
@@ -395,6 +436,17 @@ SecUnixFdAddress (
   )\r
 ;\r
 \r
+EFI_STATUS\r
+EFIAPI\r
+GasketSecUnixFdAddress (\r
+  IN     UINTN                 Index,\r
+  IN OUT EFI_PHYSICAL_ADDRESS  *FdBase,\r
+  IN OUT UINT64                *FdSize,\r
+  IN OUT EFI_PHYSICAL_ADDRESS  *FixUp\r
+  )\r
+;\r
+\r
+\r
 EFI_STATUS\r
 GetImageReadFunction (\r
   IN PE_COFF_LOADER_IMAGE_CONTEXT          *ImageContext,\r
@@ -500,6 +552,15 @@ SecTemporaryRamSupport (
   IN EFI_PHYSICAL_ADDRESS     PermanentMemoryBase,\r
   IN UINTN                    CopySize\r
   );\r
+  \r
+EFI_STATUS\r
+EFIAPI\r
+GasketSecTemporaryRamSupport (\r
+  IN CONST EFI_PEI_SERVICES   **PeiServices,\r
+  IN EFI_PHYSICAL_ADDRESS     TemporaryMemoryBase,\r
+  IN EFI_PHYSICAL_ADDRESS     PermanentMemoryBase,\r
+  IN UINTN                    CopySize\r
+  );\r
 \r
 \r
 RETURN_STATUS\r
index 88477c60cda1d42391e13dcf18735feb4c49281a..3bad28bf595712c78e08879b307dc7c4712f875a 100644 (file)
   Ia32/SwitchStack.c\r
 \r
 [Sources.X64]  \r
-  X64/Gasket.S\r
+#  X64/Gasket.S       # pure UINX x86_64 ABI also need to fix issues in BaseLib\r
+  X64/MangleGasket.S  # convert between UNIX x86_64 ABI and EFI X64 ABI\r
\r
   X64/SwitchStack.S\r
   X64/NameManglingFix.c\r
-  \r
-# Only used to help construct Gasket.S\r
-#  X64/GasketEfiTemplate.c\r
+\r
 \r
 [Packages]\r
   MdePkg/MdePkg.dec\r
index 29d9328d902686d66821c299b4f96e13d984ed82..6c9bb74ce0dcd6e2073c6693ce46256f4d8b9557 100644 (file)
@@ -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);
 }
index 2797d84de6c2e97f8a5b38a79fcf49d621cd87a0..4d6123f55572a4a46336eb11800cd7ff664ec590 100644 (file)
@@ -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:
index d496fcba159182cb59e89a7998e9f742801ef67a..f29b1e314d71ba553a2f3f459064c8b39d8a15fb 100644 (file)
@@ -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
+
+
+
+
+
index 9f62e71cefff70bf5addf0c7602dd44188f06590..dfb618b39572bc504bc1010d6ef74fcfba484a7b 100644 (file)
@@ -37,8 +37,8 @@
 #   None\r
 #\r
 #------------------------------------------------------------------------------\r
-ASM_GLOBAL ASM_PFX(GasketPeiSwitchStacks)\r
-ASM_PFX(GasketPeiSwitchStacks):\r
+ASM_GLOBAL ASM_PFX(PeiSwitchStacks)\r
+ASM_PFX(PeiSwitchStacks):\r
 //  movq    %rdx, %rdx   \r
     movq    %r8,  %rsp\r
     \r
@@ -50,7 +50,7 @@ ASM_PFX(GasketPeiSwitchStacks):
     # Reserve space for register parameters (rcx, rdx, r8 & r9) on the stack,\r
     # in case the callee wishes to spill them.\r
     #\r
-         subq    40, %rsp  // 32-byte shadow space plus alignment pad\r
+         subq    $40, %rsp  // 32-byte shadow space plus alignment pad\r
     call    *%rax\r
 \r
 \r
@@ -72,8 +72,8 @@ ASM_PFX(GasketPeiSwitchStacks):
 #   None\r
 #\r
 #------------------------------------------------------------------------------\r
-ASM_GLOBAL ASM_PFX(PeiSwitchStacks)\r
-ASM_PFX(PeiSwitchStacks):\r
+ASM_GLOBAL ASM_PFX(UnixPeiSwitchStacks)\r
+ASM_PFX(UnixPeiSwitchStacks):\r
     mov     %rdi, %rax\r
     mov     %rsi, %rdi\r
     mov     %rdx, %rsi\r
index d6e87fa796431f0fcea9c77576985a70cc56e80c..e843d09863ad262183f4c10cc0c7893f14eaeeef 100644 (file)
   PrintLib|MdeModulePkg/Library/DxePrintLibPrint2Protocol/DxePrintLibPrint2Protocol.inf\r
 \r
 [LibraryClasses.X64]\r
+  # turn off CR3 write so that DXE IPL will not crash emulator\r
   BaseLib|UnixPkg/Library/UnixBaseLib/UnixBaseLib.inf\r
 \r
 ################################################################################\r
 #\r
 ###################################################################################################\r
 [Components.common]\r
+!if $(SEC_ONLY)\r
   ##\r
   #  SEC Phase modules\r
   ##\r
   UnixPkg/Sec/SecMain.inf\r
-\r
+!else\r
   ##\r
   #  PEI Phase modules\r
   ##\r
   }\r
 \r
   FatPkg/EnhancedFatDxe/Fat.inf\r
-  \r
+!endif  \r
index 706824d21c605fd228c620f7b762603fa10a6be1..9f677464e1efe0ad0876bcffd2777250d4f9c2c3 100644 (file)
@@ -31,7 +31,7 @@
 # buffer for the FD (0x41000000). If this address does not match the FV will get\r
 # relocated in place (works, but not a great idea).\r
 #\r
-BaseAddress   = 0x41000000|gEfiUnixPkgTokenSpaceGuid.PcdUnixFdBaseAddress   #The base address of the FLASH Device.\r
+BaseAddress   = 0x102000000|gEfiUnixPkgTokenSpaceGuid.PcdUnixFdBaseAddress   #The base address of the FLASH Device.\r
 Size          = 0x004a0000|gEfiUnixPkgTokenSpaceGuid.PcdUnixFirmwareFdSize  #The size in bytes of the FLASH Device\r
 ErasePolarity = 1\r
 BlockSize     = 0x10000\r
@@ -244,16 +244,17 @@ INF  MdeModulePkg/Application/HelloWorld/HelloWorld.inf
 #INF  MdeModulePkg/Universal/Network/Udp4Dxe/Udp4Dxe.inf\r
 #INF  UnixPkg/SnpUnixDxe/SnpUnixDxe.inf\r
  \r
+!if $(COMPILE_BINS)\r
 INF FatPkg/EnhancedFatDxe/Fat.inf\r
 \r
-FILE APPLICATION = PCD(gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdShellFile) {\r
-  SECTION PE32 =Build/GccShellPkg/DEBUG_XCODE32/X64/ShellFull.efi\r
+ FILE APPLICATION = PCD(gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdShellFile) {\r
+  SECTION PE32 =Build/GccShellPkg/DEBUG_UNIXPKG/X64/ShellFull.efi\r
  }\r
-\r
-# Note: Warning current X64 port does not use EFI ABI so thease bins will crash\r
-#INF  RuleOverride = BINARY USE = X64 FatBinPkg/EnhancedFatDxe/Fat.inf\r
-#INF  RuleOverride = BINARY USE = X64 EdkShellBinPkg/FullShell/FullShell.inf\r
-\r
+!else\r
+# Used checked in Visual Studio binaries\r
+INF  RuleOverride = BINARY USE = X64 FatBinPkg/EnhancedFatDxe/Fat.inf\r
+INF  RuleOverride = BINARY USE = X64 EdkShellBinPkg/FullShell/FullShell.inf\r
+!endif\r
 \r
 FILE FREEFORM = PCD(gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdLogoFile) {\r
         SECTION RAW = MdeModulePkg/Logo/Logo.bmp\r
index ddd2fc28fb3d808a85a62ad49e462c17f3588f3f..45e84b0f2501dca54bf037f57906865a1dead81f 100644 (file)
@@ -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.
index f2a6927d5723092347bbdf92207dfd0c46a62abb..c80d29591d4f0dd4ee93e1bd55cabffdce0a2453 100755 (executable)
@@ -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 $?