2008-04-10 10:49:28 +02:00
|
|
|
/** @file
|
2007-07-18 16:32:48 +02:00
|
|
|
Header file for Virtual Machine support. Contains EBC defines that can
|
2008-04-10 10:49:28 +02:00
|
|
|
be of use to a disassembler for the most part. Also provides function
|
2007-07-18 16:32:48 +02:00
|
|
|
prototypes for VM functions.
|
|
|
|
|
2011-09-18 14:21:01 +02:00
|
|
|
Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>
|
2010-04-24 11:33:45 +02:00
|
|
|
This program and the accompanying materials
|
2008-04-10 10:49:28 +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.
|
|
|
|
|
|
|
|
**/
|
2007-07-18 16:32:48 +02:00
|
|
|
|
|
|
|
#ifndef _EBC_EXECUTE_H_
|
|
|
|
#define _EBC_EXECUTE_H_
|
|
|
|
|
|
|
|
//
|
|
|
|
// Macros to check and set alignment
|
|
|
|
//
|
|
|
|
#define ASSERT_ALIGNED(addr, size) ASSERT (!((UINT32) (addr) & (size - 1)))
|
|
|
|
#define IS_ALIGNED(addr, size) !((UINT32) (addr) & (size - 1))
|
|
|
|
|
|
|
|
//
|
|
|
|
// Debug macro
|
|
|
|
//
|
|
|
|
#define EBCMSG(s) gST->ConOut->OutputString (gST->ConOut, s)
|
|
|
|
|
|
|
|
|
2008-05-13 10:46:12 +02:00
|
|
|
/**
|
|
|
|
Execute an EBC image from an entry point or from a published protocol.
|
|
|
|
|
|
|
|
@param VmPtr A pointer to a VM context.
|
|
|
|
|
|
|
|
@retval EFI_UNSUPPORTED At least one of the opcodes is not supported.
|
|
|
|
@retval EFI_SUCCESS All of the instructions are executed successfully.
|
|
|
|
|
|
|
|
**/
|
2007-07-18 16:32:48 +02:00
|
|
|
EFI_STATUS
|
|
|
|
EbcExecute (
|
|
|
|
IN VM_CONTEXT *VmPtr
|
2008-05-14 08:07:07 +02:00
|
|
|
);
|
2007-07-18 16:32:48 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
2008-05-13 10:46:12 +02:00
|
|
|
/**
|
|
|
|
Returns the version of the EBC virtual machine.
|
2008-07-26 09:35:34 +02:00
|
|
|
|
2008-05-13 10:46:12 +02:00
|
|
|
@return The 64-bit version of EBC virtual machine.
|
|
|
|
|
|
|
|
**/
|
2007-07-18 16:32:48 +02:00
|
|
|
UINT64
|
|
|
|
GetVmVersion (
|
|
|
|
VOID
|
2008-05-14 08:07:07 +02:00
|
|
|
);
|
2007-07-18 16:32:48 +02:00
|
|
|
|
2008-05-13 10:46:12 +02:00
|
|
|
/**
|
|
|
|
Writes UINTN data to memory address.
|
2008-07-26 09:35:34 +02:00
|
|
|
|
2008-05-13 10:46:12 +02:00
|
|
|
This routine is called by the EBC data
|
|
|
|
movement instructions that write to memory. Since these writes
|
|
|
|
may be to the stack, which looks like (high address on top) this,
|
|
|
|
|
|
|
|
[EBC entry point arguments]
|
|
|
|
[VM stack]
|
|
|
|
[EBC stack]
|
|
|
|
|
|
|
|
we need to detect all attempts to write to the EBC entry point argument
|
2008-07-26 09:35:34 +02:00
|
|
|
stack area and adjust the address (which will initially point into the
|
2008-05-13 10:46:12 +02:00
|
|
|
VM stack) to point into the EBC entry point arguments.
|
|
|
|
|
|
|
|
@param VmPtr A pointer to a VM context.
|
2008-12-23 17:20:43 +01:00
|
|
|
@param Addr Address to write to.
|
2008-05-13 10:46:12 +02:00
|
|
|
@param Data Value to write to Addr.
|
|
|
|
|
2008-07-26 09:35:34 +02:00
|
|
|
@retval EFI_SUCCESS The instruction is executed successfully.
|
2008-05-13 10:46:12 +02:00
|
|
|
@retval Other Some error occurs when writing data to the address.
|
|
|
|
|
|
|
|
**/
|
2007-07-18 16:32:48 +02:00
|
|
|
EFI_STATUS
|
|
|
|
VmWriteMemN (
|
|
|
|
IN VM_CONTEXT *VmPtr,
|
|
|
|
IN UINTN Addr,
|
|
|
|
IN UINTN Data
|
2008-05-14 08:07:07 +02:00
|
|
|
);
|
2007-07-18 16:32:48 +02:00
|
|
|
|
2008-05-13 10:46:12 +02:00
|
|
|
/**
|
|
|
|
Writes 64-bit data to memory address.
|
2008-07-26 09:35:34 +02:00
|
|
|
|
2008-05-13 10:46:12 +02:00
|
|
|
This routine is called by the EBC data
|
|
|
|
movement instructions that write to memory. Since these writes
|
|
|
|
may be to the stack, which looks like (high address on top) this,
|
|
|
|
|
|
|
|
[EBC entry point arguments]
|
|
|
|
[VM stack]
|
|
|
|
[EBC stack]
|
|
|
|
|
|
|
|
we need to detect all attempts to write to the EBC entry point argument
|
2008-07-26 09:35:34 +02:00
|
|
|
stack area and adjust the address (which will initially point into the
|
2008-05-13 10:46:12 +02:00
|
|
|
VM stack) to point into the EBC entry point arguments.
|
|
|
|
|
|
|
|
@param VmPtr A pointer to a VM context.
|
2008-12-23 17:20:43 +01:00
|
|
|
@param Addr Address to write to.
|
2008-05-13 10:46:12 +02:00
|
|
|
@param Data Value to write to Addr.
|
|
|
|
|
2008-07-26 09:35:34 +02:00
|
|
|
@retval EFI_SUCCESS The instruction is executed successfully.
|
2008-05-13 10:46:12 +02:00
|
|
|
@retval Other Some error occurs when writing data to the address.
|
|
|
|
|
|
|
|
**/
|
2007-07-18 16:32:48 +02:00
|
|
|
EFI_STATUS
|
|
|
|
VmWriteMem64 (
|
2008-05-14 08:07:07 +02:00
|
|
|
IN VM_CONTEXT *VmPtr,
|
|
|
|
IN UINTN Addr,
|
|
|
|
IN UINT64 Data
|
|
|
|
);
|
2007-07-18 16:32:48 +02:00
|
|
|
|
2008-05-13 10:46:12 +02:00
|
|
|
/**
|
|
|
|
Given a pointer to a new VM context, execute one or more instructions. This
|
|
|
|
function is only used for test purposes via the EBC VM test protocol.
|
|
|
|
|
|
|
|
@param This A pointer to the EFI_EBC_VM_TEST_PROTOCOL structure.
|
|
|
|
@param VmPtr A pointer to a VM context.
|
|
|
|
@param InstructionCount A pointer to a UINTN value holding the number of
|
|
|
|
instructions to execute. If it holds value of 0,
|
|
|
|
then the instruction to be executed is 1.
|
|
|
|
|
|
|
|
@retval EFI_UNSUPPORTED At least one of the opcodes is not supported.
|
|
|
|
@retval EFI_SUCCESS All of the instructions are executed successfully.
|
|
|
|
|
|
|
|
**/
|
2007-07-18 16:32:48 +02:00
|
|
|
EFI_STATUS
|
2011-09-18 14:21:01 +02:00
|
|
|
EFIAPI
|
2007-07-18 16:32:48 +02:00
|
|
|
EbcExecuteInstructions (
|
|
|
|
IN EFI_EBC_VM_TEST_PROTOCOL *This,
|
|
|
|
IN VM_CONTEXT *VmPtr,
|
|
|
|
IN OUT UINTN *InstructionCount
|
2008-05-14 08:07:07 +02:00
|
|
|
);
|
2007-07-18 16:32:48 +02:00
|
|
|
|
|
|
|
#endif // ifndef _EBC_EXECUTE_H_
|