]> git.proxmox.com Git - mirror_edk2.git/commitdiff
1) Fix GCC version EBC interpreter bug.
authorjyao1 <jyao1@6f19259b-4bc3-4df7-8a09-765794883524>
Mon, 21 Nov 2011 08:35:14 +0000 (08:35 +0000)
committerjyao1 <jyao1@6f19259b-4bc3-4df7-8a09-765794883524>
Mon, 21 Nov 2011 08:35:14 +0000 (08:35 +0000)
Add missing EFIPAI for EbcInterpret and ExecuteEbcImageEntryPoint().
Get return value in EbcLLCALLEXNative(), remove EbcLLGetReturnValue().

2) Fix IA32 EBC interpreter bug on MOVsnw and MOVsnd.

3) Some cleanup
Add missing ReturnEBCStack() for IA32 build.
Remove unnecessary EbcLLGetStackPointer() for X64 and IPF build.
Remove deadcode EbcLLGetStackPointer() and EbcLLGetReturnValue() in IA32/X64/IPF ASM code.
Dump more info in CommonEbcExceptionHandler().

Signed-off-by: jyao1
Reviewed-by: Elvinli
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@12745 6f19259b-4bc3-4df7-8a09-765794883524

MdeModulePkg/Universal/EbcDxe/EbcExecute.c
MdeModulePkg/Universal/EbcDxe/EbcInt.c
MdeModulePkg/Universal/EbcDxe/EbcInt.h
MdeModulePkg/Universal/EbcDxe/Ia32/EbcLowLevel.S
MdeModulePkg/Universal/EbcDxe/Ia32/EbcLowLevel.asm
MdeModulePkg/Universal/EbcDxe/Ia32/EbcSupport.c
MdeModulePkg/Universal/EbcDxe/Ipf/EbcLowLevel.s
MdeModulePkg/Universal/EbcDxe/Ipf/EbcSupport.c
MdeModulePkg/Universal/EbcDxe/X64/EbcLowLevel.S
MdeModulePkg/Universal/EbcDxe/X64/EbcLowLevel.asm
MdeModulePkg/Universal/EbcDxe/X64/EbcSupport.c

index 07e2f0a9f7fcdf0ca7038a2f07bf388068359c53..29ff464a466dfef7d15cd4fab9243443fb2827f6 100644 (file)
@@ -2546,9 +2546,9 @@ ExecuteMOVsnw (
   //\r
   // Get the data from the source.\r
   //\r
-  Op2 = (UINT64) (VmPtr->Gpr[OPERAND2_REGNUM (Operands)] + Op2Index);\r
+  Op2 = (UINT64)(INT64)(INTN)(VmPtr->Gpr[OPERAND2_REGNUM (Operands)] + Op2Index);\r
   if (OPERAND2_INDIRECT (Operands)) {\r
-    Op2 = (UINT64) VmReadMemN (VmPtr, (UINTN) Op2);\r
+    Op2 = (UINT64)(INT64)(INTN)VmReadMemN (VmPtr, (UINTN) Op2);\r
   }\r
   //\r
   // Now write back the result.\r
@@ -2639,9 +2639,9 @@ ExecuteMOVsnd (
   //\r
   // Get the data from the source.\r
   //\r
-  Op2 = (UINT64) (VmPtr->Gpr[OPERAND2_REGNUM (Operands)] + Op2Index);\r
+  Op2 = (UINT64)(INT64)(INTN)(INT64)(VmPtr->Gpr[OPERAND2_REGNUM (Operands)] + Op2Index);\r
   if (OPERAND2_INDIRECT (Operands)) {\r
-    Op2 = (UINT64) VmReadMemN (VmPtr, (UINTN) Op2);\r
+    Op2 = (UINT64)(INT64)(INTN)(INT64)VmReadMemN (VmPtr, (UINTN) Op2);\r
   }\r
   //\r
   // Now write back the result.\r
index 609f103995423e3d7dc7331d4e6f5fe38213e58b..549e0dd8dc1c9c1395ef253f56d18a393d7abb37 100644 (file)
@@ -874,10 +874,63 @@ CommonEbcExceptionHandler (
   IN EFI_SYSTEM_CONTEXT   SystemContext\r
   )\r
 {\r
+  //\r
+  // We print debug information to let user know what happen.\r
+  //\r
+  DEBUG ((\r
+    EFI_D_ERROR,\r
+    "EBC Interrupter Version - 0x%016lx\n",\r
+    (UINT64) (((VM_MAJOR_VERSION & 0xFFFF) << 16) | ((VM_MINOR_VERSION & 0xFFFF)))\r
+    ));\r
+  DEBUG ((\r
+    EFI_D_ERROR,\r
+    "Exception Type - 0x%016lx\n",\r
+    (UINT64)(UINTN)InterruptType\r
+    ));\r
+  DEBUG ((\r
+    EFI_D_ERROR,\r
+    "  R0 - 0x%016lx, R1 - 0x%016lx\n",\r
+    SystemContext.SystemContextEbc->R0,\r
+    SystemContext.SystemContextEbc->R1\r
+    ));\r
+  DEBUG ((\r
+    EFI_D_ERROR,\r
+    "  R2 - 0x%016lx, R3 - 0x%016lx\n",\r
+    SystemContext.SystemContextEbc->R2,\r
+    SystemContext.SystemContextEbc->R3\r
+    ));\r
+  DEBUG ((\r
+    EFI_D_ERROR,\r
+    "  R4 - 0x%016lx, R5 - 0x%016lx\n",\r
+    SystemContext.SystemContextEbc->R4,\r
+    SystemContext.SystemContextEbc->R5\r
+    ));\r
+  DEBUG ((\r
+    EFI_D_ERROR,\r
+    "  R6 - 0x%016lx, R7 - 0x%016lx\n",\r
+    SystemContext.SystemContextEbc->R6,\r
+    SystemContext.SystemContextEbc->R7\r
+    ));\r
+  DEBUG ((\r
+    EFI_D_ERROR,\r
+    "  Flags - 0x%016lx\n",\r
+    SystemContext.SystemContextEbc->Flags\r
+    ));\r
+  DEBUG ((\r
+    EFI_D_ERROR,\r
+    "  ControlFlags - 0x%016lx\n",\r
+    SystemContext.SystemContextEbc->ControlFlags\r
+    ));\r
+  DEBUG ((\r
+    EFI_D_ERROR,\r
+    "  Ip - 0x%016lx\n\n",\r
+    SystemContext.SystemContextEbc->Ip\r
+    ));\r
+\r
   //\r
   // We deadloop here to make it easy to debug this issue.\r
   //\r
-  ASSERT (FALSE);\r
+  CpuDeadLoop ();\r
 \r
   return ;\r
 }\r
index 98ba7e66f34629cb02f2d3691161edb2dff4e583..01ac4412151ce6b8be304b427a3236215c57985d 100644 (file)
@@ -145,21 +145,6 @@ EbcLLGetEbcEntryPoint (
   VOID\r
   );\r
 \r
-/**\r
-  Returns the caller's value of the stack pointer.\r
-\r
-  We adjust it by 4 here because when they called us, the return address\r
-  is put on the stack, thereby lowering it by 4 bytes.\r
-\r
-  @return The current value of the stack pointer for the caller.\r
-\r
-**/\r
-UINTN\r
-EFIAPI\r
-EbcLLGetStackPointer (\r
-  VOID\r
-  );\r
-\r
 /**\r
   This function is called to execute an EBC CALLEX instruction.\r
   This instruction requires that we thunk out to external native\r
@@ -172,8 +157,10 @@ EbcLLGetStackPointer (
   @param  EbcSp        The new EBC stack pointer.\r
   @param  FramePtr     The frame pointer.\r
 \r
+  @return The unmodified value returned by the native code.\r
+\r
 **/\r
-VOID\r
+INT64\r
 EFIAPI\r
 EbcLLCALLEXNative (\r
   IN UINTN        CallAddr,\r
@@ -205,21 +192,6 @@ EbcLLCALLEX (
   IN UINT8        Size\r
   );\r
 \r
-/**\r
-  When EBC calls native, on return the VM has to stuff the return\r
-  value into a VM register. It's assumed here that the value is still\r
-  in the register, so simply return and the caller should get the\r
-  return result properly.\r
-\r
-  @return The unmodified value returned by the native code.\r
-\r
-**/\r
-INT64\r
-EFIAPI\r
-EbcLLGetReturnValue (\r
-  VOID\r
-  );\r
-\r
 /**\r
   Returns the stack index and buffer assosicated with the Handle parameter.\r
 \r
index 5dde824e94d78908195088e30acca4b2c3d6f58a..056885678bf345d019483bdea8a62e3901ccb37d 100644 (file)
@@ -2,7 +2,7 @@
 #  \r
 #    Low level IA32 specific EBC support routines.\r
 #  \r
-#  Copyright (c) 2007 - 2008, Intel Corporation. All rights reserved.<BR>\r
+#  Copyright (c) 2007 - 2011, 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
@@ -45,13 +45,3 @@ ASM_PFX(EbcLLCALLEXNative):
 ASM_GLOBAL ASM_PFX(EbcLLGetEbcEntryPoint)\r
 ASM_PFX(EbcLLGetEbcEntryPoint):\r
         ret\r
-\r
-ASM_GLOBAL ASM_PFX(EbcLLGetStackPointer)\r
-ASM_PFX(EbcLLGetStackPointer):\r
-        mov    %esp,%eax\r
-        add    $0x4,%eax\r
-        ret\r
-\r
-ASM_GLOBAL ASM_PFX(EbcLLGetReturnValue)\r
-ASM_PFX(EbcLLGetReturnValue):\r
-        ret\r
index 7596c56ccb244f85ba569fd9a83d167331718610..73d48e7c7f97eca8443144f490c043efe85b2583 100644 (file)
@@ -3,7 +3,7 @@
 ;    This code provides low level routines that support the Virtual Machine\r
 ;    for option ROMs.\r
 ;  \r
-;  Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved.<BR>\r
+;  Copyright (c) 2006 - 2011, 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
@@ -32,9 +32,6 @@
 .686p\r
 .model  flat\r
 .code\r
-;---------------------------------------------------------------------------\r
-;;GenericPostSegment      SEGMENT USE16\r
-;---------------------------------------------------------------------------\r
 CopyMem  PROTO  C Destination:PTR DWORD, Source:PTR DWORD, Count:DWORD\r
 \r
 ;****************************************************************************\r
@@ -49,8 +46,8 @@ CopyMem  PROTO  C Destination:PTR DWORD, Source:PTR DWORD, Count:DWORD
 ;\r
 ; Destroys no working registers.\r
 ;****************************************************************************\r
-; VOID EbcLLCALLEXNative(UINTN FuncAddr, UINTN NewStackPointer, VOID *FramePtr)\r
-_EbcLLCALLEXNative        PROC    NEAR    PUBLIC\r
+; INT64 EbcLLCALLEXNative(UINTN FuncAddr, UINTN NewStackPointer, VOID *FramePtr)\r
+_EbcLLCALLEXNative        PROC        PUBLIC\r
       push   ebp\r
       push   ebx\r
       mov    ebp, esp              ; standard function prolog\r
@@ -104,50 +101,9 @@ _EbcLLCALLEXNative    ENDP
 ; Returns:\r
 ;     The contents of the register in which the entry point is passed.\r
 ;\r
-_EbcLLGetEbcEntryPoint        PROC    NEAR    PUBLIC\r
+_EbcLLGetEbcEntryPoint        PROC        PUBLIC\r
+    ; The EbcEntryPoint is saved to EAX, so just return here.\r
     ret\r
 _EbcLLGetEbcEntryPoint    ENDP\r
 \r
-;/*++\r
-;\r
-;Routine Description:\r
-;\r
-;  Return the caller's value of the stack pointer.\r
-;\r
-;Arguments:\r
-;\r
-;  None.\r
-;\r
-;Returns:\r
-;\r
-;  The current value of the stack pointer for the caller. We\r
-;  adjust it by 4 here because when they called us, the return address\r
-;  is put on the stack, thereby lowering it by 4 bytes.\r
-;\r
-;--*/\r
-\r
-; UINTN EbcLLGetStackPointer()\r
-_EbcLLGetStackPointer        PROC    NEAR    PUBLIC\r
-    mov    eax, esp      ; get current stack pointer\r
-    add   eax, 4        ; stack adjusted by this much when we were called\r
-    ret\r
-_EbcLLGetStackPointer    ENDP\r
-\r
-; UINT64 EbcLLGetReturnValue(VOID);\r
-; Routine Description:\r
-;   When EBC calls native, on return the VM has to stuff the return\r
-;   value into a VM register. It's assumed here that the value is still\r
-;    in the register, so simply return and the caller should get the\r
-;   return result properly.\r
-;\r
-; Arguments:\r
-;     None.\r
-;\r
-; Returns:\r
-;     The unmodified value returned by the native code.\r
-;\r
-_EbcLLGetReturnValue   PROC    NEAR    PUBLIC\r
-    ret\r
-_EbcLLGetReturnValue    ENDP\r
-\r
 END\r
index 3205d8fc8ab2f40262d5f25eaaf924281d9aaf10..549b04afd2d26e599bb7ea35222705c6190f14af 100644 (file)
@@ -2,7 +2,7 @@
   This module contains EBC support routines that are customized based on\r
   the target processor.\r
 \r
-Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 2011, 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
@@ -117,14 +117,14 @@ Action:
     VmPtr->Ip = (VMIP) (UINTN) TargetEbcAddr;\r
   } else {\r
     //\r
-    // The callee is not a thunk to EBC, call native code.\r
+    // The callee is not a thunk to EBC, call native code,\r
+    // and get return value\r
     //\r
-    EbcLLCALLEXNative (FuncAddr, NewStackPointer, FramePtr);\r
+    VmPtr->Gpr[7] = EbcLLCALLEXNative (FuncAddr, NewStackPointer, FramePtr);\r
 \r
     //\r
-    // Get return value and advance the IP.\r
+    // Advance the IP.\r
     //\r
-    VmPtr->Gpr[7] = EbcLLGetReturnValue ();\r
     VmPtr->Ip += Size;\r
   }\r
 }\r
@@ -160,6 +160,7 @@ Action:
 \r
 **/\r
 UINT64\r
+EFIAPI\r
 EbcInterpret (\r
   IN OUT UINTN      Arg1,\r
   IN OUT UINTN      Arg2,\r
@@ -308,6 +309,7 @@ EbcInterpret (
 \r
 **/\r
 UINT64\r
+EFIAPI\r
 ExecuteEbcImageEntryPoint (\r
   IN EFI_HANDLE           ImageHandle,\r
   IN EFI_SYSTEM_TABLE     *SystemTable\r
@@ -394,6 +396,7 @@ ExecuteEbcImageEntryPoint (
   //\r
   // Return the value in R[7] unless there was an error\r
   //\r
+  ReturnEBCStack(StackIndex);\r
   return (UINT64) VmContext.Gpr[7];\r
 }\r
 \r
index 002af6937fe1b3dee1426aec5113332540f4731d..4ae24dee7db5e8c42bf9f4aaae6c8fd5fd75e8f9 100644 (file)
@@ -3,7 +3,7 @@
 //  Contains low level routines for the Virtual Machine implementation\r
 //  on an Itanium-based platform.\r
 //\r
-//  Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved.<BR>\r
+//  Copyright (c) 2006 - 2011, 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
@@ -198,27 +198,6 @@ PROCEDURE_ENTRY(EbcLLGetEbcEntryPoint)
     br.ret.sptk  b0 ;;\r
 PROCEDURE_EXIT(EbcLLGetEbcEntryPoint)\r
 \r
-//\r
-// INT64 EbcLLGetReturnValue(VOID)\r
-//\r
-// Description:\r
-//    This function is called to get the value returned by native code\r
-//     to EBC. It simply returns because the return value should still\r
-//    be in the register, so the caller just gets the unmodified value.\r
-//\r
-PROCEDURE_ENTRY(EbcLLGetReturnValue)\r
-    br.ret.sptk  b0 ;;\r
-PROCEDURE_EXIT(EbcLLGetReturnValue)\r
-\r
-//\r
-// UINTN EbcLLGetStackPointer(VOID)\r
-//\r
-PROCEDURE_ENTRY(EbcLLGetStackPointer)\r
-    mov    r8 = r12 ;;\r
-    br.ret.sptk  b0 ;;\r
-    br.sptk.few b6\r
-PROCEDURE_EXIT(EbcLLGetStackPointer)\r
-\r
 \r
 \r
 \r
index cf21cc7a21eca64b392638da2668256c4bb84d20..1321dd4288759e1061ec9e56a266f1efc23a7401 100644 (file)
@@ -2,7 +2,7 @@
   This module contains EBC support routines that are customized based on\r
   the target processor.\r
 \r
-Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 2011, 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
@@ -238,6 +238,7 @@ EbcInterpret (
 \r
 **/\r
 UINT64\r
+EFIAPI\r
 ExecuteEbcImageEntryPoint (\r
   IN EFI_HANDLE           ImageHandle,\r
   IN EFI_SYSTEM_TABLE     *SystemTable\r
@@ -277,7 +278,6 @@ ExecuteEbcImageEntryPoint (
   //\r
   // Get the stack pointer. This is the bottom of the upper stack.\r
   //\r
-  Addr                      = EbcLLGetStackPointer ();\r
 \r
   Status = GetEBCStack(ImageHandle, &VmContext.StackPool, &StackIndex);\r
   if (EFI_ERROR(Status)) {\r
@@ -865,14 +865,14 @@ Action:
     VmPtr->Ip = (VMIP) (UINTN) TargetEbcAddr;\r
   } else {\r
     //\r
-    // The callee is not a thunk to EBC, call native code.\r
+    // The callee is not a thunk to EBC, call native code,\r
+    // and get return value.\r
     //\r
-    EbcLLCALLEXNative (FuncAddr, NewStackPointer, FramePtr);\r
+    VmPtr->Gpr[7] = EbcLLCALLEXNative (FuncAddr, NewStackPointer, FramePtr);\r
 \r
     //\r
-    // Get return value and advance the IP.\r
+    // Advance the IP.\r
     //\r
-    VmPtr->Gpr[7] = EbcLLGetReturnValue ();\r
     VmPtr->Ip += Size;\r
   }\r
 }\r
index e94e8cefac6c8c6bc0d431b99a8ce71dec1f6d1f..eb2b9cd085415c1d2b41a3c932a548487361671f 100644 (file)
@@ -3,7 +3,7 @@
 #    This code provides low level routines that support the Virtual Machine\r
 #   for option ROMs.\r
 #  \r
-#  Copyright (c) 2007 - 2008, Intel Corporation. All rights reserved.<BR>\r
+#  Copyright (c) 2007 - 2011, 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
@@ -18,9 +18,7 @@
 # Equate files needed.\r
 #---------------------------------------------------------------------------\r
 \r
-#---------------------------------------------------------------------------\r
-##GenericPostSegment      SEGMENT USE16\r
-#---------------------------------------------------------------------------\r
+ASM_GLOBAL ASM_PFX(CopyMem);\r
 \r
 #****************************************************************************\r
 # EbcLLCALLEX\r
@@ -33,8 +31,6 @@
 #\r
 # Destroys no working registers.\r
 #****************************************************************************\r
-ASM_GLOBAL _CopyMem;\r
-\r
 # VOID EbcLLCALLEXNative(UINTN FuncAddr, UINTN NewStackPointer, VOID *FramePtr)\r
 ASM_GLOBAL ASM_PFX(EbcLLCALLEXNative);\r
 ASM_PFX(EbcLLCALLEXNative):\r
@@ -88,47 +84,3 @@ ASM_GLOBAL ASM_PFX(EbcLLGetEbcEntryPoint);
 ASM_PFX(EbcLLGetEbcEntryPoint):\r
     mov    %r10, %rax\r
     ret\r
-\r
-#/*++\r
-#\r
-#Routine Description:\r
-#\r
-#  Return the caller's value of the stack pointer.\r
-#\r
-#Arguments:\r
-#\r
-#  None.\r
-#\r
-#Returns:\r
-#\r
-#  The current value of the stack pointer for the caller. We\r
-#  adjust it by 4 here because when they called us, the return address\r
-#  is put on the stack, thereby lowering it by 4 bytes.\r
-#\r
-#--*/\r
-\r
-# UINTN EbcLLGetStackPointer()\r
-ASM_GLOBAL ASM_PFX(EbcLLGetStackPointer);\r
-ASM_PFX(EbcLLGetStackPointer):\r
-    mov    %rsp, %rax\r
-    # Stack adjusted by this much when we were called,\r
-    # For this function, it's 4.\r
-    add   $4, %rax\r
-    ret\r
-\r
-ASM_GLOBAL ASM_PFX(EbcLLGetReturnValue);\r
-ASM_PFX(EbcLLGetReturnValue):\r
-# UINT64 EbcLLGetReturnValue(VOID);\r
-# Routine Description:\r
-#   When EBC calls native, on return the VM has to stuff the return\r
-#   value into a VM register. It's assumed here that the value is still\r
-#    in the register, so simply return and the caller should get the\r
-#   return result properly.\r
-#\r
-# Arguments:\r
-#     None.\r
-#\r
-# Returns:\r
-#     The unmodified value returned by the native code.\r
-#\r
-    ret\r
index c2e91ff117a953e5b32e540d781c50de989c63bc..19fc35b0fc403f82901963babbb066d346eef00e 100644 (file)
@@ -3,7 +3,7 @@
 ;    This code provides low level routines that support the Virtual Machine.\r
 ;    for option ROMs.\r
 ;  \r
-;  Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved.<BR>\r
+;  Copyright (c) 2006 - 2011, 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
 ; Equate files needed.\r
 ;---------------------------------------------------------------------------\r
 \r
-text SEGMENT\r
+.CODE\r
 \r
-;---------------------------------------------------------------------------\r
-;;GenericPostSegment      SEGMENT USE16\r
-;---------------------------------------------------------------------------\r
+CopyMem  PROTO  Destination:PTR DWORD, Source:PTR DWORD, Count:DWORD\r
 \r
 ;****************************************************************************\r
 ; EbcLLCALLEX\r
@@ -38,11 +36,7 @@ text SEGMENT
 ;\r
 ; Destroys no working registers.\r
 ;****************************************************************************\r
-; VOID EbcLLCALLEXNative(UINTN FuncAddr, UINTN NewStackPointer, VOID *FramePtr)\r
-\r
-CopyMem  PROTO  Destination:PTR DWORD, Source:PTR DWORD, Count:DWORD\r
-\r
-\r
+; INT64 EbcLLCALLEXNative(UINTN FuncAddr, UINTN NewStackPointer, VOID *FramePtr)\r
 EbcLLCALLEXNative        PROC    PUBLIC\r
       push   rbp\r
       push   rbx\r
@@ -92,54 +86,10 @@ EbcLLCALLEXNative    ENDP
 ;     The contents of the register in which the entry point is passed.\r
 ;\r
 EbcLLGetEbcEntryPoint        PROC    PUBLIC\r
+    ; The EbcEntryPoint is saved to R10.\r
     mov  rax, r10\r
     ret\r
 EbcLLGetEbcEntryPoint    ENDP\r
 \r
-;/*++\r
-;\r
-;Routine Description:\r
-;\r
-;  Return the caller's value of the stack pointer.\r
-;\r
-;Arguments:\r
-;\r
-;  None.\r
-;\r
-;Returns:\r
-;\r
-;  The current value of the stack pointer for the caller. We\r
-;  adjust it by 4 here because when they called us, the return address\r
-;  is put on the stack, thereby lowering it by 4 bytes.\r
-;\r
-;--*/\r
-\r
-; UINTN EbcLLGetStackPointer()\r
-EbcLLGetStackPointer        PROC    PUBLIC\r
-    mov    rax, rsp      ; get current stack pointer\r
-    ; Stack adjusted by this much when we were called,\r
-    ; For this function, it's 4.\r
-    add   rax, 4\r
-    ret\r
-EbcLLGetStackPointer    ENDP\r
-\r
-; UINT64 EbcLLGetReturnValue(VOID);\r
-; Routine Description:\r
-;   When EBC calls native, on return the VM has to stuff the return\r
-;   value into a VM register. It's assumed here that the value is still\r
-;    in the register, so simply return and the caller should get the\r
-;   return result properly.\r
-;\r
-; Arguments:\r
-;     None.\r
-;\r
-; Returns:\r
-;     The unmodified value returned by the native code.\r
-;\r
-EbcLLGetReturnValue   PROC    PUBLIC\r
-    ret\r
-EbcLLGetReturnValue    ENDP\r
-\r
-text  ENDS\r
 END\r
 \r
index 5266122b76608855eab192463686d4c2a94197c2..184c672f16e09db75ea618220887d601323f84e0 100644 (file)
@@ -2,7 +2,7 @@
   This module contains EBC support routines that are customized based on\r
   the target x64 processor.\r
 \r
-Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 2011, 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
@@ -81,6 +81,7 @@ PushU64 (
 \r
 **/\r
 UINT64\r
+EFIAPI\r
 EbcInterpret (\r
   IN OUT UINTN      Arg1,\r
   IN OUT UINTN      Arg2,\r
@@ -129,7 +130,6 @@ EbcInterpret (
   // Initialize the stack pointer for the EBC. Get the current system stack\r
   // pointer and adjust it down by the max needed for the interpreter.\r
   //\r
-  Addr            = EbcLLGetStackPointer ();\r
 \r
   //\r
   // Adjust the VM's stack pointer down.\r
@@ -233,6 +233,7 @@ EbcInterpret (
 \r
 **/\r
 UINT64\r
+EFIAPI\r
 ExecuteEbcImageEntryPoint (\r
   IN EFI_HANDLE           ImageHandle,\r
   IN EFI_SYSTEM_TABLE     *SystemTable\r
@@ -273,7 +274,6 @@ ExecuteEbcImageEntryPoint (
   // Initialize the stack pointer for the EBC. Get the current system stack\r
   // pointer and adjust it down by the max needed for the interpreter.\r
   //\r
-  Addr = EbcLLGetStackPointer ();\r
 \r
   Status = GetEBCStack(ImageHandle, &VmContext.StackPool, &StackIndex);\r
   if (EFI_ERROR(Status)) {\r
@@ -586,14 +586,14 @@ Action:
     VmPtr->Ip = (VMIP) (UINTN) TargetEbcAddr;\r
   } else {\r
     //\r
-    // The callee is not a thunk to EBC, call native code.\r
+    // The callee is not a thunk to EBC, call native code,\r
+    // and get return value.\r
     //\r
-    EbcLLCALLEXNative (FuncAddr, NewStackPointer, FramePtr);\r
+    VmPtr->Gpr[7] = EbcLLCALLEXNative (FuncAddr, NewStackPointer, FramePtr);\r
 \r
     //\r
-    // Get return value and advance the IP.\r
+    // Advance the IP.\r
     //\r
-    VmPtr->Gpr[7] = EbcLLGetReturnValue ();\r
     VmPtr->Ip += Size;\r
   }\r
 }\r