]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Universal/EbcDxe/EbcExecute.h
MdeModulePkg/EbcDxe: implement the PE/COFF emulator protocol
[mirror_edk2.git] / MdeModulePkg / Universal / EbcDxe / EbcExecute.h
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 SPDX-License-Identifier: BSD-2-Clause-Patent
8
9 **/
10
11 #ifndef _EBC_EXECUTE_H_
12 #define _EBC_EXECUTE_H_
13
14 //
15 // Macros to check and set alignment
16 //
17 #define ASSERT_ALIGNED(addr, size) ASSERT (!((UINT32) (addr) & (size - 1)))
18 #define IS_ALIGNED(addr, size) !((UINT32) (addr) & (size - 1))
19
20 //
21 // Debug macro
22 //
23 #define EBCMSG(s) gST->ConOut->OutputString (gST->ConOut, s)
24
25
26 /**
27 Execute an EBC image from an entry point or from a published protocol.
28
29 @param VmPtr A pointer to a VM context.
30
31 @retval EFI_UNSUPPORTED At least one of the opcodes is not supported.
32 @retval EFI_SUCCESS All of the instructions are executed successfully.
33
34 **/
35 EFI_STATUS
36 EbcExecute (
37 IN VM_CONTEXT *VmPtr
38 );
39
40
41
42 /**
43 Returns the version of the EBC virtual machine.
44
45 @return The 64-bit version of EBC virtual machine.
46
47 **/
48 UINT64
49 GetVmVersion (
50 VOID
51 );
52
53 /**
54 Writes UINTN data to memory address.
55
56 This routine is called by the EBC data
57 movement instructions that write to memory. Since these writes
58 may be to the stack, which looks like (high address on top) this,
59
60 [EBC entry point arguments]
61 [VM stack]
62 [EBC stack]
63
64 we need to detect all attempts to write to the EBC entry point argument
65 stack area and adjust the address (which will initially point into the
66 VM stack) to point into the EBC entry point arguments.
67
68 @param VmPtr A pointer to a VM context.
69 @param Addr Address to write to.
70 @param Data Value to write to Addr.
71
72 @retval EFI_SUCCESS The instruction is executed successfully.
73 @retval Other Some error occurs when writing data to the address.
74
75 **/
76 EFI_STATUS
77 VmWriteMemN (
78 IN VM_CONTEXT *VmPtr,
79 IN UINTN Addr,
80 IN UINTN Data
81 );
82
83 /**
84 Writes 64-bit data to memory address.
85
86 This routine is called by the EBC data
87 movement instructions that write to memory. Since these writes
88 may be to the stack, which looks like (high address on top) this,
89
90 [EBC entry point arguments]
91 [VM stack]
92 [EBC stack]
93
94 we need to detect all attempts to write to the EBC entry point argument
95 stack area and adjust the address (which will initially point into the
96 VM stack) to point into the EBC entry point arguments.
97
98 @param VmPtr A pointer to a VM context.
99 @param Addr Address to write to.
100 @param Data Value to write to Addr.
101
102 @retval EFI_SUCCESS The instruction is executed successfully.
103 @retval Other Some error occurs when writing data to the address.
104
105 **/
106 EFI_STATUS
107 VmWriteMem64 (
108 IN VM_CONTEXT *VmPtr,
109 IN UINTN Addr,
110 IN UINT64 Data
111 );
112
113 /**
114 Given a pointer to a new VM context, execute one or more instructions. This
115 function is only used for test purposes via the EBC VM test protocol.
116
117 @param This A pointer to the EFI_EBC_VM_TEST_PROTOCOL structure.
118 @param VmPtr A pointer to a VM context.
119 @param InstructionCount A pointer to a UINTN value holding the number of
120 instructions to execute. If it holds value of 0,
121 then the instruction to be executed is 1.
122
123 @retval EFI_UNSUPPORTED At least one of the opcodes is not supported.
124 @retval EFI_SUCCESS All of the instructions are executed successfully.
125
126 **/
127 EFI_STATUS
128 EFIAPI
129 EbcExecuteInstructions (
130 IN EFI_EBC_VM_TEST_PROTOCOL *This,
131 IN VM_CONTEXT *VmPtr,
132 IN OUT UINTN *InstructionCount
133 );
134
135 #endif // ifndef _EBC_EXECUTE_H_