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