1 /* SPDX-License-Identifier: GPL-2.0+ OR MIT */
2 /**************************************************************************
4 * Copyright 2016-2021 VMware, Inc., Palo Alto, CA., USA
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the
8 * "Software"), to deal in the Software without restriction, including
9 * without limitation the rights to use, copy, modify, merge, publish,
10 * distribute, sub license, and/or sell copies of the Software, and to
11 * permit persons to whom the Software is furnished to do so, subject to
12 * the following conditions:
14 * The above copyright notice and this permission notice (including the
15 * next paragraph) shall be included in all copies or substantial portions
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
21 * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
22 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
23 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
24 * USE OR OTHER DEALINGS IN THE SOFTWARE.
26 **************************************************************************
28 * Based on code from vmware.c and vmmouse.c.
32 #ifndef _VMWGFX_MSG_X86_H
33 #define _VMWGFX_MSG_X86_H
36 #if defined(__i386__) || defined(__x86_64__)
38 #include <asm/vmware.h>
41 * Hypervisor-specific bi-directional communication channel. Should never
42 * execute on bare metal hardware. The caller must make sure to check for
43 * supported hypervisor before using these macros.
45 * The last two parameters are both input and output and must be initialized.
47 * @cmd: [IN] Message Cmd
48 * @in_ebx: [IN] Message Len, through EBX
49 * @in_si: [IN] Input argument through SI, set to 0 if not used
50 * @in_di: [IN] Input argument through DI, set ot 0 if not used
51 * @flags: [IN] hypercall flags + [channel id]
52 * @magic: [IN] hypervisor magic value
53 * @eax: [OUT] value of EAX register
54 * @ebx: [OUT] e.g. status from an HB message status command
55 * @ecx: [OUT] e.g. status from a non-HB message status command
56 * @edx: [OUT] e.g. channel id
60 #define VMW_PORT(cmd, in_ebx, in_si, in_di, \
62 eax, ebx, ecx, edx, si, di) \
64 asm volatile (VMWARE_HYPERCALL : \
82 * Hypervisor-specific bi-directional communication channel. Should never
83 * execute on bare metal hardware. The caller must make sure to check for
84 * supported hypervisor before using these macros.
86 * The last 3 parameters are both input and output and must be initialized.
88 * @cmd: [IN] Message Cmd
89 * @in_ecx: [IN] Message Len, through ECX
90 * @in_si: [IN] Input argument through SI, set to 0 if not used
91 * @in_di: [IN] Input argument through DI, set to 0 if not used
92 * @flags: [IN] hypercall flags + [channel id]
93 * @magic: [IN] hypervisor magic value
95 * @eax: [OUT] value of EAX register
96 * @ebx: [OUT] e.g. status from an HB message status command
97 * @ecx: [OUT] e.g. status from a non-HB message status command
98 * @edx: [OUT] e.g. channel id
104 #define VMW_PORT_HB_OUT(cmd, in_ecx, in_si, in_di, \
106 eax, ebx, ecx, edx, si, di) \
108 asm volatile ("push %%rbp;" \
110 VMWARE_HYPERCALL_HB_OUT \
129 #define VMW_PORT_HB_IN(cmd, in_ecx, in_si, in_di, \
131 eax, ebx, ecx, edx, si, di) \
133 asm volatile ("push %%rbp;" \
135 VMWARE_HYPERCALL_HB_IN \
153 #elif defined(__i386__)
156 * In the 32-bit version of this macro, we store bp in a memory location
157 * because we've ran out of registers.
158 * Now we can't reference that memory location while we've modified
159 * %esp or %ebp, so we first push it on the stack, just before we push
160 * %ebp, and then when we need it we read it from the stack where we
163 #define VMW_PORT_HB_OUT(cmd, in_ecx, in_si, in_di, \
165 eax, ebx, ecx, edx, si, di) \
167 asm volatile ("push %12;" \
169 "mov 0x04(%%esp), %%ebp;" \
170 VMWARE_HYPERCALL_HB_OUT \
172 "add $0x04, %%esp;" : \
190 #define VMW_PORT_HB_IN(cmd, in_ecx, in_si, in_di, \
192 eax, ebx, ecx, edx, si, di) \
194 asm volatile ("push %12;" \
196 "mov 0x04(%%esp), %%ebp;" \
197 VMWARE_HYPERCALL_HB_IN \
199 "add $0x04, %%esp;" : \
215 #endif /* defined(__i386__) */
217 #endif /* defined(__i386__) || defined(__x86_64__) */
219 #endif /* _VMWGFX_MSG_X86_H */