Files
system76-edk2/MdeModulePkg/Universal/EbcDxe/X64/EbcLowLevel.asm
jyao1 fa97cbf4ef 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
2011-11-21 08:35:14 +00:00

96 lines
2.9 KiB
NASM

;/** @file
;
; This code provides low level routines that support the Virtual Machine.
; for option ROMs.
;
; 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
; http://opensource.org/licenses/bsd-license.php
;
; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
;
;**/
page ,132
title VM ASSEMBLY LANGUAGE ROUTINES
;---------------------------------------------------------------------------
; Equate files needed.
;---------------------------------------------------------------------------
.CODE
CopyMem PROTO Destination:PTR DWORD, Source:PTR DWORD, Count:DWORD
;****************************************************************************
; EbcLLCALLEX
;
; 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
; and jump to the specified function.
; On return, we restore the stack pointer to its original location.
;
; Destroys no working registers.
;****************************************************************************
; INT64 EbcLLCALLEXNative(UINTN FuncAddr, UINTN NewStackPointer, VOID *FramePtr)
EbcLLCALLEXNative PROC PUBLIC
push rbp
push rbx
mov rbp, rsp
; Function prolog
; Copy FuncAddr to a preserved register.
mov rbx, rcx
; Set stack pointer to new value
sub r8, rdx
sub rsp, r8
mov rcx, rsp
sub rsp, 20h
call CopyMem
add rsp, 20h
; Considering the worst case, load 4 potiential arguments
; into registers.
mov rcx, qword ptr [rsp]
mov rdx, qword ptr [rsp+8h]
mov r8, qword ptr [rsp+10h]
mov r9, qword ptr [rsp+18h]
; Now call the external routine
call rbx
; Function epilog
mov rsp, rbp
pop rbx
pop rbp
ret
EbcLLCALLEXNative ENDP
; UINTN EbcLLGetEbcEntryPoint(VOID);
; Routine Description:
; The VM thunk code stuffs an EBC entry point into a processor
; register. Since we can't use inline assembly to get it from
; the interpreter C code, stuff it into the return value
; register and return.
;
; Arguments:
; None.
;
; Returns:
; 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
END