Home | History | Annotate | Download | only in EbcDxe
      1 /** @file
      2   Header file for Virtual Machine support. Contains EBC defines that can
      3   be of use to a disassembler for the most part. Also provides function
      4   prototypes for VM functions.
      5 
      6 Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>
      7 This program and the accompanying materials
      8 are licensed and made available under the terms and conditions of the BSD License
      9 which accompanies this distribution.  The full text of the license may be found at
     10 http://opensource.org/licenses/bsd-license.php
     11 
     12 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
     13 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
     14 
     15 **/
     16 
     17 #ifndef _EBC_EXECUTE_H_
     18 #define _EBC_EXECUTE_H_
     19 
     20 //
     21 // Macros to check and set alignment
     22 //
     23 #define ASSERT_ALIGNED(addr, size)  ASSERT (!((UINT32) (addr) & (size - 1)))
     24 #define IS_ALIGNED(addr, size)      !((UINT32) (addr) & (size - 1))
     25 
     26 //
     27 // Debug macro
     28 //
     29 #define EBCMSG(s) gST->ConOut->OutputString (gST->ConOut, s)
     30 
     31 
     32 /**
     33   Execute an EBC image from an entry point or from a published protocol.
     34 
     35   @param  VmPtr             A pointer to a VM context.
     36 
     37   @retval EFI_UNSUPPORTED   At least one of the opcodes is not supported.
     38   @retval EFI_SUCCESS       All of the instructions are executed successfully.
     39 
     40 **/
     41 EFI_STATUS
     42 EbcExecute (
     43   IN VM_CONTEXT *VmPtr
     44   );
     45 
     46 
     47 
     48 /**
     49   Returns the version of the EBC virtual machine.
     50 
     51   @return The 64-bit version of EBC virtual machine.
     52 
     53 **/
     54 UINT64
     55 GetVmVersion (
     56   VOID
     57   );
     58 
     59 /**
     60   Writes UINTN data to memory address.
     61 
     62   This routine is called by the EBC data
     63   movement instructions that write to memory. Since these writes
     64   may be to the stack, which looks like (high address on top) this,
     65 
     66   [EBC entry point arguments]
     67   [VM stack]
     68   [EBC stack]
     69 
     70   we need to detect all attempts to write to the EBC entry point argument
     71   stack area and adjust the address (which will initially point into the
     72   VM stack) to point into the EBC entry point arguments.
     73 
     74   @param  VmPtr             A pointer to a VM context.
     75   @param  Addr              Address to write to.
     76   @param  Data              Value to write to Addr.
     77 
     78   @retval EFI_SUCCESS       The instruction is executed successfully.
     79   @retval Other             Some error occurs when writing data to the address.
     80 
     81 **/
     82 EFI_STATUS
     83 VmWriteMemN (
     84   IN VM_CONTEXT   *VmPtr,
     85   IN UINTN        Addr,
     86   IN UINTN        Data
     87   );
     88 
     89 /**
     90   Writes 64-bit data to memory address.
     91 
     92   This routine is called by the EBC data
     93   movement instructions that write to memory. Since these writes
     94   may be to the stack, which looks like (high address on top) this,
     95 
     96   [EBC entry point arguments]
     97   [VM stack]
     98   [EBC stack]
     99 
    100   we need to detect all attempts to write to the EBC entry point argument
    101   stack area and adjust the address (which will initially point into the
    102   VM stack) to point into the EBC entry point arguments.
    103 
    104   @param  VmPtr             A pointer to a VM context.
    105   @param  Addr              Address to write to.
    106   @param  Data              Value to write to Addr.
    107 
    108   @retval EFI_SUCCESS       The instruction is executed successfully.
    109   @retval Other             Some error occurs when writing data to the address.
    110 
    111 **/
    112 EFI_STATUS
    113 VmWriteMem64 (
    114   IN VM_CONTEXT   *VmPtr,
    115   IN UINTN        Addr,
    116   IN UINT64       Data
    117   );
    118 
    119 /**
    120   Given a pointer to a new VM context, execute one or more instructions. This
    121   function is only used for test purposes via the EBC VM test protocol.
    122 
    123   @param  This              A pointer to the EFI_EBC_VM_TEST_PROTOCOL structure.
    124   @param  VmPtr             A pointer to a VM context.
    125   @param  InstructionCount  A pointer to a UINTN value holding the number of
    126                             instructions to execute. If it holds value of 0,
    127                             then the instruction to be executed is 1.
    128 
    129   @retval EFI_UNSUPPORTED   At least one of the opcodes is not supported.
    130   @retval EFI_SUCCESS       All of the instructions are executed successfully.
    131 
    132 **/
    133 EFI_STATUS
    134 EFIAPI
    135 EbcExecuteInstructions (
    136   IN EFI_EBC_VM_TEST_PROTOCOL *This,
    137   IN VM_CONTEXT               *VmPtr,
    138   IN OUT UINTN                *InstructionCount
    139   );
    140 
    141 #endif // ifndef _EBC_EXECUTE_H_
    142