diff options
author | jyao1 <jyao1@6f19259b-4bc3-4df7-8a09-765794883524> | 2011-11-21 08:35:14 +0000 |
---|---|---|
committer | jyao1 <jyao1@6f19259b-4bc3-4df7-8a09-765794883524> | 2011-11-21 08:35:14 +0000 |
commit | fa97cbf4ef6f4fd2dc0312c09b6b5003780facb8 (patch) | |
tree | ef755da1081954d431c37d23934cd67d481fe067 | |
parent | ea71453f72e9a1990aaf7af76689a3f69c7b603f (diff) | |
download | edk2-platforms-fa97cbf4ef6f4fd2dc0312c09b6b5003780facb8.tar.xz |
1) Fix GCC version EBC interpreter bug.
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
-rw-r--r-- | MdeModulePkg/Universal/EbcDxe/EbcExecute.c | 8 | ||||
-rw-r--r-- | MdeModulePkg/Universal/EbcDxe/EbcInt.c | 55 | ||||
-rw-r--r-- | MdeModulePkg/Universal/EbcDxe/EbcInt.h | 34 | ||||
-rw-r--r-- | MdeModulePkg/Universal/EbcDxe/Ia32/EbcLowLevel.S | 12 | ||||
-rw-r--r-- | MdeModulePkg/Universal/EbcDxe/Ia32/EbcLowLevel.asm | 54 | ||||
-rw-r--r-- | MdeModulePkg/Universal/EbcDxe/Ia32/EbcSupport.c | 13 | ||||
-rw-r--r-- | MdeModulePkg/Universal/EbcDxe/Ipf/EbcLowLevel.s | 23 | ||||
-rw-r--r-- | MdeModulePkg/Universal/EbcDxe/Ipf/EbcSupport.c | 12 | ||||
-rw-r--r-- | MdeModulePkg/Universal/EbcDxe/X64/EbcLowLevel.S | 52 | ||||
-rw-r--r-- | MdeModulePkg/Universal/EbcDxe/X64/EbcLowLevel.asm | 60 | ||||
-rw-r--r-- | MdeModulePkg/Universal/EbcDxe/X64/EbcSupport.c | 14 |
11 files changed, 96 insertions, 241 deletions
diff --git a/MdeModulePkg/Universal/EbcDxe/EbcExecute.c b/MdeModulePkg/Universal/EbcDxe/EbcExecute.c index 07e2f0a9f7..29ff464a46 100644 --- a/MdeModulePkg/Universal/EbcDxe/EbcExecute.c +++ b/MdeModulePkg/Universal/EbcDxe/EbcExecute.c @@ -2546,9 +2546,9 @@ ExecuteMOVsnw ( //
// Get the data from the source.
//
- Op2 = (UINT64) (VmPtr->Gpr[OPERAND2_REGNUM (Operands)] + Op2Index);
+ Op2 = (UINT64)(INT64)(INTN)(VmPtr->Gpr[OPERAND2_REGNUM (Operands)] + Op2Index);
if (OPERAND2_INDIRECT (Operands)) {
- Op2 = (UINT64) VmReadMemN (VmPtr, (UINTN) Op2);
+ Op2 = (UINT64)(INT64)(INTN)VmReadMemN (VmPtr, (UINTN) Op2);
}
//
// Now write back the result.
@@ -2639,9 +2639,9 @@ ExecuteMOVsnd ( //
// Get the data from the source.
//
- Op2 = (UINT64) (VmPtr->Gpr[OPERAND2_REGNUM (Operands)] + Op2Index);
+ Op2 = (UINT64)(INT64)(INTN)(INT64)(VmPtr->Gpr[OPERAND2_REGNUM (Operands)] + Op2Index);
if (OPERAND2_INDIRECT (Operands)) {
- Op2 = (UINT64) VmReadMemN (VmPtr, (UINTN) Op2);
+ Op2 = (UINT64)(INT64)(INTN)(INT64)VmReadMemN (VmPtr, (UINTN) Op2);
}
//
// Now write back the result.
diff --git a/MdeModulePkg/Universal/EbcDxe/EbcInt.c b/MdeModulePkg/Universal/EbcDxe/EbcInt.c index 609f103995..549e0dd8dc 100644 --- a/MdeModulePkg/Universal/EbcDxe/EbcInt.c +++ b/MdeModulePkg/Universal/EbcDxe/EbcInt.c @@ -875,9 +875,62 @@ CommonEbcExceptionHandler ( )
{
//
+ // We print debug information to let user know what happen.
+ //
+ DEBUG ((
+ EFI_D_ERROR,
+ "EBC Interrupter Version - 0x%016lx\n",
+ (UINT64) (((VM_MAJOR_VERSION & 0xFFFF) << 16) | ((VM_MINOR_VERSION & 0xFFFF)))
+ ));
+ DEBUG ((
+ EFI_D_ERROR,
+ "Exception Type - 0x%016lx\n",
+ (UINT64)(UINTN)InterruptType
+ ));
+ DEBUG ((
+ EFI_D_ERROR,
+ " R0 - 0x%016lx, R1 - 0x%016lx\n",
+ SystemContext.SystemContextEbc->R0,
+ SystemContext.SystemContextEbc->R1
+ ));
+ DEBUG ((
+ EFI_D_ERROR,
+ " R2 - 0x%016lx, R3 - 0x%016lx\n",
+ SystemContext.SystemContextEbc->R2,
+ SystemContext.SystemContextEbc->R3
+ ));
+ DEBUG ((
+ EFI_D_ERROR,
+ " R4 - 0x%016lx, R5 - 0x%016lx\n",
+ SystemContext.SystemContextEbc->R4,
+ SystemContext.SystemContextEbc->R5
+ ));
+ DEBUG ((
+ EFI_D_ERROR,
+ " R6 - 0x%016lx, R7 - 0x%016lx\n",
+ SystemContext.SystemContextEbc->R6,
+ SystemContext.SystemContextEbc->R7
+ ));
+ DEBUG ((
+ EFI_D_ERROR,
+ " Flags - 0x%016lx\n",
+ SystemContext.SystemContextEbc->Flags
+ ));
+ DEBUG ((
+ EFI_D_ERROR,
+ " ControlFlags - 0x%016lx\n",
+ SystemContext.SystemContextEbc->ControlFlags
+ ));
+ DEBUG ((
+ EFI_D_ERROR,
+ " Ip - 0x%016lx\n\n",
+ SystemContext.SystemContextEbc->Ip
+ ));
+
+ //
// We deadloop here to make it easy to debug this issue.
//
- ASSERT (FALSE);
+ CpuDeadLoop ();
return ;
}
diff --git a/MdeModulePkg/Universal/EbcDxe/EbcInt.h b/MdeModulePkg/Universal/EbcDxe/EbcInt.h index 98ba7e66f3..01ac441215 100644 --- a/MdeModulePkg/Universal/EbcDxe/EbcInt.h +++ b/MdeModulePkg/Universal/EbcDxe/EbcInt.h @@ -146,21 +146,6 @@ EbcLLGetEbcEntryPoint ( );
/**
- Returns the caller's value of the stack pointer.
-
- We adjust it by 4 here because when they called us, the return address
- is put on the stack, thereby lowering it by 4 bytes.
-
- @return The current value of the stack pointer for the caller.
-
-**/
-UINTN
-EFIAPI
-EbcLLGetStackPointer (
- VOID
- );
-
-/**
This function is called to execute an EBC CALLEX instruction.
This instruction requires that we thunk out to external native
code. For x64, we switch stacks, copy the arguments to the stack
@@ -172,8 +157,10 @@ EbcLLGetStackPointer ( @param EbcSp The new EBC stack pointer.
@param FramePtr The frame pointer.
+ @return The unmodified value returned by the native code.
+
**/
-VOID
+INT64
EFIAPI
EbcLLCALLEXNative (
IN UINTN CallAddr,
@@ -206,21 +193,6 @@ EbcLLCALLEX ( );
/**
- When EBC calls native, on return the VM has to stuff the return
- value into a VM register. It's assumed here that the value is still
- in the register, so simply return and the caller should get the
- return result properly.
-
- @return The unmodified value returned by the native code.
-
-**/
-INT64
-EFIAPI
-EbcLLGetReturnValue (
- VOID
- );
-
-/**
Returns the stack index and buffer assosicated with the Handle parameter.
@param Handle The EFI handle as the index to the EBC stack.
diff --git a/MdeModulePkg/Universal/EbcDxe/Ia32/EbcLowLevel.S b/MdeModulePkg/Universal/EbcDxe/Ia32/EbcLowLevel.S index 5dde824e94..056885678b 100644 --- a/MdeModulePkg/Universal/EbcDxe/Ia32/EbcLowLevel.S +++ b/MdeModulePkg/Universal/EbcDxe/Ia32/EbcLowLevel.S @@ -2,7 +2,7 @@ #
# Low level IA32 specific EBC support routines.
#
-# Copyright (c) 2007 - 2008, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2007 - 2011, 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
@@ -45,13 +45,3 @@ ASM_PFX(EbcLLCALLEXNative): ASM_GLOBAL ASM_PFX(EbcLLGetEbcEntryPoint)
ASM_PFX(EbcLLGetEbcEntryPoint):
ret
-
-ASM_GLOBAL ASM_PFX(EbcLLGetStackPointer)
-ASM_PFX(EbcLLGetStackPointer):
- mov %esp,%eax
- add $0x4,%eax
- ret
-
-ASM_GLOBAL ASM_PFX(EbcLLGetReturnValue)
-ASM_PFX(EbcLLGetReturnValue):
- ret
diff --git a/MdeModulePkg/Universal/EbcDxe/Ia32/EbcLowLevel.asm b/MdeModulePkg/Universal/EbcDxe/Ia32/EbcLowLevel.asm index 7596c56ccb..73d48e7c7f 100644 --- a/MdeModulePkg/Universal/EbcDxe/Ia32/EbcLowLevel.asm +++ b/MdeModulePkg/Universal/EbcDxe/Ia32/EbcLowLevel.asm @@ -3,7 +3,7 @@ ; This code provides low level routines that support the Virtual Machine
; for option ROMs.
;
-; Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved.<BR>
+; Copyright (c) 2006 - 2011, 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
@@ -32,9 +32,6 @@ .686p
.model flat
.code
-;---------------------------------------------------------------------------
-;;GenericPostSegment SEGMENT USE16
-;---------------------------------------------------------------------------
CopyMem PROTO C Destination:PTR DWORD, Source:PTR DWORD, Count:DWORD
;****************************************************************************
@@ -49,8 +46,8 @@ CopyMem PROTO C Destination:PTR DWORD, Source:PTR DWORD, Count:DWORD ;
; Destroys no working registers.
;****************************************************************************
-; VOID EbcLLCALLEXNative(UINTN FuncAddr, UINTN NewStackPointer, VOID *FramePtr)
-_EbcLLCALLEXNative PROC NEAR PUBLIC
+; INT64 EbcLLCALLEXNative(UINTN FuncAddr, UINTN NewStackPointer, VOID *FramePtr)
+_EbcLLCALLEXNative PROC PUBLIC
push ebp
push ebx
mov ebp, esp ; standard function prolog
@@ -104,50 +101,9 @@ _EbcLLCALLEXNative ENDP ; Returns:
; The contents of the register in which the entry point is passed.
;
-_EbcLLGetEbcEntryPoint PROC NEAR PUBLIC
+_EbcLLGetEbcEntryPoint PROC PUBLIC
+ ; The EbcEntryPoint is saved to EAX, so just return here.
ret
_EbcLLGetEbcEntryPoint ENDP
-;/*++
-;
-;Routine Description:
-;
-; Return the caller's value of the stack pointer.
-;
-;Arguments:
-;
-; None.
-;
-;Returns:
-;
-; The current value of the stack pointer for the caller. We
-; adjust it by 4 here because when they called us, the return address
-; is put on the stack, thereby lowering it by 4 bytes.
-;
-;--*/
-
-; UINTN EbcLLGetStackPointer()
-_EbcLLGetStackPointer PROC NEAR PUBLIC
- mov eax, esp ; get current stack pointer
- add eax, 4 ; stack adjusted by this much when we were called
- ret
-_EbcLLGetStackPointer ENDP
-
-; UINT64 EbcLLGetReturnValue(VOID);
-; Routine Description:
-; When EBC calls native, on return the VM has to stuff the return
-; value into a VM register. It's assumed here that the value is still
-; in the register, so simply return and the caller should get the
-; return result properly.
-;
-; Arguments:
-; None.
-;
-; Returns:
-; The unmodified value returned by the native code.
-;
-_EbcLLGetReturnValue PROC NEAR PUBLIC
- ret
-_EbcLLGetReturnValue ENDP
-
END
diff --git a/MdeModulePkg/Universal/EbcDxe/Ia32/EbcSupport.c b/MdeModulePkg/Universal/EbcDxe/Ia32/EbcSupport.c index 3205d8fc8a..549b04afd2 100644 --- a/MdeModulePkg/Universal/EbcDxe/Ia32/EbcSupport.c +++ b/MdeModulePkg/Universal/EbcDxe/Ia32/EbcSupport.c @@ -2,7 +2,7 @@ This module contains EBC support routines that are customized based on
the target processor.
-Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2006 - 2011, 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
@@ -117,14 +117,14 @@ Action: VmPtr->Ip = (VMIP) (UINTN) TargetEbcAddr;
} else {
//
- // The callee is not a thunk to EBC, call native code.
+ // The callee is not a thunk to EBC, call native code,
+ // and get return value
//
- EbcLLCALLEXNative (FuncAddr, NewStackPointer, FramePtr);
+ VmPtr->Gpr[7] = EbcLLCALLEXNative (FuncAddr, NewStackPointer, FramePtr);
//
- // Get return value and advance the IP.
+ // Advance the IP.
//
- VmPtr->Gpr[7] = EbcLLGetReturnValue ();
VmPtr->Ip += Size;
}
}
@@ -160,6 +160,7 @@ Action: **/
UINT64
+EFIAPI
EbcInterpret (
IN OUT UINTN Arg1,
IN OUT UINTN Arg2,
@@ -308,6 +309,7 @@ EbcInterpret ( **/
UINT64
+EFIAPI
ExecuteEbcImageEntryPoint (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
@@ -394,6 +396,7 @@ ExecuteEbcImageEntryPoint ( //
// Return the value in R[7] unless there was an error
//
+ ReturnEBCStack(StackIndex);
return (UINT64) VmContext.Gpr[7];
}
diff --git a/MdeModulePkg/Universal/EbcDxe/Ipf/EbcLowLevel.s b/MdeModulePkg/Universal/EbcDxe/Ipf/EbcLowLevel.s index 002af6937f..4ae24dee7d 100644 --- a/MdeModulePkg/Universal/EbcDxe/Ipf/EbcLowLevel.s +++ b/MdeModulePkg/Universal/EbcDxe/Ipf/EbcLowLevel.s @@ -3,7 +3,7 @@ // Contains low level routines for the Virtual Machine implementation
// on an Itanium-based platform.
//
-// Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved.<BR>
+// Copyright (c) 2006 - 2011, 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
@@ -198,27 +198,6 @@ PROCEDURE_ENTRY(EbcLLGetEbcEntryPoint) br.ret.sptk b0 ;;
PROCEDURE_EXIT(EbcLLGetEbcEntryPoint)
-//
-// INT64 EbcLLGetReturnValue(VOID)
-//
-// Description:
-// This function is called to get the value returned by native code
-// to EBC. It simply returns because the return value should still
-// be in the register, so the caller just gets the unmodified value.
-//
-PROCEDURE_ENTRY(EbcLLGetReturnValue)
- br.ret.sptk b0 ;;
-PROCEDURE_EXIT(EbcLLGetReturnValue)
-
-//
-// UINTN EbcLLGetStackPointer(VOID)
-//
-PROCEDURE_ENTRY(EbcLLGetStackPointer)
- mov r8 = r12 ;;
- br.ret.sptk b0 ;;
- br.sptk.few b6
-PROCEDURE_EXIT(EbcLLGetStackPointer)
-
diff --git a/MdeModulePkg/Universal/EbcDxe/Ipf/EbcSupport.c b/MdeModulePkg/Universal/EbcDxe/Ipf/EbcSupport.c index cf21cc7a21..1321dd4288 100644 --- a/MdeModulePkg/Universal/EbcDxe/Ipf/EbcSupport.c +++ b/MdeModulePkg/Universal/EbcDxe/Ipf/EbcSupport.c @@ -2,7 +2,7 @@ This module contains EBC support routines that are customized based on
the target processor.
-Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2006 - 2011, 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
@@ -238,6 +238,7 @@ EbcInterpret ( **/
UINT64
+EFIAPI
ExecuteEbcImageEntryPoint (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
@@ -277,7 +278,6 @@ ExecuteEbcImageEntryPoint ( //
// Get the stack pointer. This is the bottom of the upper stack.
//
- Addr = EbcLLGetStackPointer ();
Status = GetEBCStack(ImageHandle, &VmContext.StackPool, &StackIndex);
if (EFI_ERROR(Status)) {
@@ -865,14 +865,14 @@ Action: VmPtr->Ip = (VMIP) (UINTN) TargetEbcAddr;
} else {
//
- // The callee is not a thunk to EBC, call native code.
+ // The callee is not a thunk to EBC, call native code,
+ // and get return value.
//
- EbcLLCALLEXNative (FuncAddr, NewStackPointer, FramePtr);
+ VmPtr->Gpr[7] = EbcLLCALLEXNative (FuncAddr, NewStackPointer, FramePtr);
//
- // Get return value and advance the IP.
+ // Advance the IP.
//
- VmPtr->Gpr[7] = EbcLLGetReturnValue ();
VmPtr->Ip += Size;
}
}
diff --git a/MdeModulePkg/Universal/EbcDxe/X64/EbcLowLevel.S b/MdeModulePkg/Universal/EbcDxe/X64/EbcLowLevel.S index e94e8cefac..eb2b9cd085 100644 --- a/MdeModulePkg/Universal/EbcDxe/X64/EbcLowLevel.S +++ b/MdeModulePkg/Universal/EbcDxe/X64/EbcLowLevel.S @@ -3,7 +3,7 @@ # This code provides low level routines that support the Virtual Machine
# for option ROMs.
#
-# Copyright (c) 2007 - 2008, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2007 - 2011, 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
@@ -18,9 +18,7 @@ # Equate files needed.
#---------------------------------------------------------------------------
-#---------------------------------------------------------------------------
-##GenericPostSegment SEGMENT USE16
-#---------------------------------------------------------------------------
+ASM_GLOBAL ASM_PFX(CopyMem);
#****************************************************************************
# EbcLLCALLEX
@@ -33,8 +31,6 @@ #
# Destroys no working registers.
#****************************************************************************
-ASM_GLOBAL _CopyMem;
-
# VOID EbcLLCALLEXNative(UINTN FuncAddr, UINTN NewStackPointer, VOID *FramePtr)
ASM_GLOBAL ASM_PFX(EbcLLCALLEXNative);
ASM_PFX(EbcLLCALLEXNative):
@@ -88,47 +84,3 @@ ASM_GLOBAL ASM_PFX(EbcLLGetEbcEntryPoint); ASM_PFX(EbcLLGetEbcEntryPoint):
mov %r10, %rax
ret
-
-#/*++
-#
-#Routine Description:
-#
-# Return the caller's value of the stack pointer.
-#
-#Arguments:
-#
-# None.
-#
-#Returns:
-#
-# The current value of the stack pointer for the caller. We
-# adjust it by 4 here because when they called us, the return address
-# is put on the stack, thereby lowering it by 4 bytes.
-#
-#--*/
-
-# UINTN EbcLLGetStackPointer()
-ASM_GLOBAL ASM_PFX(EbcLLGetStackPointer);
-ASM_PFX(EbcLLGetStackPointer):
- mov %rsp, %rax
- # Stack adjusted by this much when we were called,
- # For this function, it's 4.
- add $4, %rax
- ret
-
-ASM_GLOBAL ASM_PFX(EbcLLGetReturnValue);
-ASM_PFX(EbcLLGetReturnValue):
-# UINT64 EbcLLGetReturnValue(VOID);
-# Routine Description:
-# When EBC calls native, on return the VM has to stuff the return
-# value into a VM register. It's assumed here that the value is still
-# in the register, so simply return and the caller should get the
-# return result properly.
-#
-# Arguments:
-# None.
-#
-# Returns:
-# The unmodified value returned by the native code.
-#
- ret
diff --git a/MdeModulePkg/Universal/EbcDxe/X64/EbcLowLevel.asm b/MdeModulePkg/Universal/EbcDxe/X64/EbcLowLevel.asm index c2e91ff117..19fc35b0fc 100644 --- a/MdeModulePkg/Universal/EbcDxe/X64/EbcLowLevel.asm +++ b/MdeModulePkg/Universal/EbcDxe/X64/EbcLowLevel.asm @@ -3,7 +3,7 @@ ; This code provides low level routines that support the Virtual Machine.
; for option ROMs.
;
-; Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved.<BR>
+; Copyright (c) 2006 - 2011, 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
@@ -21,11 +21,9 @@ ; Equate files needed.
;---------------------------------------------------------------------------
-text SEGMENT
+.CODE
-;---------------------------------------------------------------------------
-;;GenericPostSegment SEGMENT USE16
-;---------------------------------------------------------------------------
+CopyMem PROTO Destination:PTR DWORD, Source:PTR DWORD, Count:DWORD
;****************************************************************************
; EbcLLCALLEX
@@ -38,11 +36,7 @@ text SEGMENT ;
; Destroys no working registers.
;****************************************************************************
-; VOID EbcLLCALLEXNative(UINTN FuncAddr, UINTN NewStackPointer, VOID *FramePtr)
-
-CopyMem PROTO Destination:PTR DWORD, Source:PTR DWORD, Count:DWORD
-
-
+; INT64 EbcLLCALLEXNative(UINTN FuncAddr, UINTN NewStackPointer, VOID *FramePtr)
EbcLLCALLEXNative PROC PUBLIC
push rbp
push rbx
@@ -92,54 +86,10 @@ EbcLLCALLEXNative ENDP ; The contents of the register in which the entry point is passed.
;
EbcLLGetEbcEntryPoint PROC PUBLIC
+ ; The EbcEntryPoint is saved to R10.
mov rax, r10
ret
EbcLLGetEbcEntryPoint ENDP
-;/*++
-;
-;Routine Description:
-;
-; Return the caller's value of the stack pointer.
-;
-;Arguments:
-;
-; None.
-;
-;Returns:
-;
-; The current value of the stack pointer for the caller. We
-; adjust it by 4 here because when they called us, the return address
-; is put on the stack, thereby lowering it by 4 bytes.
-;
-;--*/
-
-; UINTN EbcLLGetStackPointer()
-EbcLLGetStackPointer PROC PUBLIC
- mov rax, rsp ; get current stack pointer
- ; Stack adjusted by this much when we were called,
- ; For this function, it's 4.
- add rax, 4
- ret
-EbcLLGetStackPointer ENDP
-
-; UINT64 EbcLLGetReturnValue(VOID);
-; Routine Description:
-; When EBC calls native, on return the VM has to stuff the return
-; value into a VM register. It's assumed here that the value is still
-; in the register, so simply return and the caller should get the
-; return result properly.
-;
-; Arguments:
-; None.
-;
-; Returns:
-; The unmodified value returned by the native code.
-;
-EbcLLGetReturnValue PROC PUBLIC
- ret
-EbcLLGetReturnValue ENDP
-
-text ENDS
END
diff --git a/MdeModulePkg/Universal/EbcDxe/X64/EbcSupport.c b/MdeModulePkg/Universal/EbcDxe/X64/EbcSupport.c index 5266122b76..184c672f16 100644 --- a/MdeModulePkg/Universal/EbcDxe/X64/EbcSupport.c +++ b/MdeModulePkg/Universal/EbcDxe/X64/EbcSupport.c @@ -2,7 +2,7 @@ This module contains EBC support routines that are customized based on
the target x64 processor.
-Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2006 - 2011, 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
@@ -81,6 +81,7 @@ PushU64 ( **/
UINT64
+EFIAPI
EbcInterpret (
IN OUT UINTN Arg1,
IN OUT UINTN Arg2,
@@ -129,7 +130,6 @@ EbcInterpret ( // Initialize the stack pointer for the EBC. Get the current system stack
// pointer and adjust it down by the max needed for the interpreter.
//
- Addr = EbcLLGetStackPointer ();
//
// Adjust the VM's stack pointer down.
@@ -233,6 +233,7 @@ EbcInterpret ( **/
UINT64
+EFIAPI
ExecuteEbcImageEntryPoint (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
@@ -273,7 +274,6 @@ ExecuteEbcImageEntryPoint ( // Initialize the stack pointer for the EBC. Get the current system stack
// pointer and adjust it down by the max needed for the interpreter.
//
- Addr = EbcLLGetStackPointer ();
Status = GetEBCStack(ImageHandle, &VmContext.StackPool, &StackIndex);
if (EFI_ERROR(Status)) {
@@ -586,14 +586,14 @@ Action: VmPtr->Ip = (VMIP) (UINTN) TargetEbcAddr;
} else {
//
- // The callee is not a thunk to EBC, call native code.
+ // The callee is not a thunk to EBC, call native code,
+ // and get return value.
//
- EbcLLCALLEXNative (FuncAddr, NewStackPointer, FramePtr);
+ VmPtr->Gpr[7] = EbcLLCALLEXNative (FuncAddr, NewStackPointer, FramePtr);
//
- // Get return value and advance the IP.
+ // Advance the IP.
//
- VmPtr->Gpr[7] = EbcLLGetReturnValue ();
VmPtr->Ip += Size;
}
}
|