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