2008-05-21 06:03:40 +02:00
|
|
|
#/** @file
|
|
|
|
#
|
|
|
|
# This code provides low level routines that support the Virtual Machine
|
|
|
|
# for option ROMs.
|
|
|
|
#
|
2011-11-21 09:35:14 +01:00
|
|
|
# Copyright (c) 2007 - 2011, Intel Corporation. All rights reserved.<BR>
|
2010-04-24 11:33:45 +02:00
|
|
|
# This program and the accompanying materials
|
2008-05-21 06:03:40 +02:00
|
|
|
# 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.
|
|
|
|
#
|
2008-04-11 05:36:07 +02:00
|
|
|
#**/
|
2007-07-18 16:32:48 +02:00
|
|
|
|
|
|
|
#---------------------------------------------------------------------------
|
|
|
|
# Equate files needed.
|
|
|
|
#---------------------------------------------------------------------------
|
|
|
|
|
2011-11-21 09:35:14 +01:00
|
|
|
ASM_GLOBAL ASM_PFX(CopyMem);
|
2007-07-18 16:32:48 +02:00
|
|
|
|
|
|
|
#****************************************************************************
|
|
|
|
# EbcLLCALLEX
|
|
|
|
#
|
2008-04-11 05:36:07 +02:00
|
|
|
# This function is called to execute an EBC CALLEX instruction.
|
2007-07-18 16:32:48 +02:00
|
|
|
# This instruction requires that we thunk out to external native
|
|
|
|
# code. For x64, we switch stacks, copy the arguments to the stack
|
2008-04-11 05:36:07 +02:00
|
|
|
# and jump to the specified function.
|
2007-07-18 16:32:48 +02:00
|
|
|
# On return, we restore the stack pointer to its original location.
|
|
|
|
#
|
|
|
|
# Destroys no working registers.
|
|
|
|
#****************************************************************************
|
|
|
|
# VOID EbcLLCALLEXNative(UINTN FuncAddr, UINTN NewStackPointer, VOID *FramePtr)
|
2009-05-20 11:42:59 +02:00
|
|
|
ASM_GLOBAL ASM_PFX(EbcLLCALLEXNative);
|
2009-04-10 22:58:04 +02:00
|
|
|
ASM_PFX(EbcLLCALLEXNative):
|
2007-07-18 16:32:48 +02:00
|
|
|
push %rbp
|
|
|
|
push %rbx
|
|
|
|
mov %rsp, %rbp
|
|
|
|
# Function prolog
|
|
|
|
|
|
|
|
# Copy FuncAddr to a preserved register.
|
|
|
|
mov %rcx, %rbx
|
|
|
|
|
|
|
|
# Set stack pointer to new value
|
2010-02-24 03:21:42 +01:00
|
|
|
sub %rdx, %r8
|
|
|
|
sub %r8, %rsp
|
2007-07-18 16:32:48 +02:00
|
|
|
mov %rsp, %rcx
|
2010-02-24 03:21:42 +01:00
|
|
|
sub $0x20, %rsp
|
2009-04-10 22:58:04 +02:00
|
|
|
call ASM_PFX(CopyMem)
|
2010-02-24 03:21:42 +01:00
|
|
|
add $0x20, %rsp
|
2007-07-18 16:32:48 +02:00
|
|
|
|
|
|
|
# Considering the worst case, load 4 potiential arguments
|
|
|
|
# into registers.
|
|
|
|
mov (%rsp), %rcx
|
2010-02-24 03:21:42 +01:00
|
|
|
mov 0x8(%rsp), %rdx
|
|
|
|
mov 0x10(%rsp), %r8
|
|
|
|
mov 0x18(%rsp), %r9
|
2007-07-18 16:32:48 +02:00
|
|
|
|
|
|
|
# Now call the external routine
|
|
|
|
call *%rbx
|
|
|
|
|
|
|
|
# Function epilog
|
|
|
|
mov %rbp, %rsp
|
|
|
|
pop %rbx
|
|
|
|
pop %rbp
|
|
|
|
ret
|
|
|
|
|
|
|
|
|
|
|
|
# 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
|
2008-04-11 05:36:07 +02:00
|
|
|
# the interpreter C code, stuff it into the return value
|
2007-07-18 16:32:48 +02:00
|
|
|
# register and return.
|
|
|
|
#
|
|
|
|
# Arguments:
|
|
|
|
# None.
|
|
|
|
#
|
|
|
|
# Returns:
|
|
|
|
# The contents of the register in which the entry point is passed.
|
|
|
|
#
|
2009-05-20 11:42:59 +02:00
|
|
|
ASM_GLOBAL ASM_PFX(EbcLLGetEbcEntryPoint);
|
2009-04-10 22:58:04 +02:00
|
|
|
ASM_PFX(EbcLLGetEbcEntryPoint):
|
2009-07-18 18:00:10 +02:00
|
|
|
mov %r10, %rax
|
2007-07-18 16:32:48 +02:00
|
|
|
ret
|