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