1 /* SPDX-License-Identifier: GPL-2.0+ OR MIT */
2 /**************************************************************************
4 * Copyright 2016 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.
30 * Sinclair Yeh <syeh@vmware.com>
35 #include <asm/vmware.h>
38 * Hypervisor-specific bi-directional communication channel. Should never
39 * execute on bare metal hardware. The caller must make sure to check for
40 * supported hypervisor before using these macros.
42 * The last two parameters are both input and output and must be initialized.
44 * @cmd: [IN] Message Cmd
45 * @in_ebx: [IN] Message Len, through EBX
46 * @in_si: [IN] Input argument through SI, set to 0 if not used
47 * @in_di: [IN] Input argument through DI, set ot 0 if not used
48 * @flags: [IN] hypercall flags + [channel id]
49 * @magic: [IN] hypervisor magic value
50 * @eax: [OUT] value of EAX register
51 * @ebx: [OUT] e.g. status from an HB message status command
52 * @ecx: [OUT] e.g. status from a non-HB message status command
53 * @edx: [OUT] e.g. channel id
57 #define VMW_PORT(cmd, in_ebx, in_si, in_di, \
59 eax, ebx, ecx, edx, si, di) \
61 asm volatile (VMWARE_HYPERCALL : \
79 * Hypervisor-specific bi-directional communication channel. Should never
80 * execute on bare metal hardware. The caller must make sure to check for
81 * supported hypervisor before using these macros.
83 * The last 3 parameters are both input and output and must be initialized.
85 * @cmd: [IN] Message Cmd
86 * @in_ecx: [IN] Message Len, through ECX
87 * @in_si: [IN] Input argument through SI, set to 0 if not used
88 * @in_di: [IN] Input argument through DI, set to 0 if not used
89 * @flags: [IN] hypercall flags + [channel id]
90 * @magic: [IN] hypervisor magic value
92 * @eax: [OUT] value of EAX register
93 * @ebx: [OUT] e.g. status from an HB message status command
94 * @ecx: [OUT] e.g. status from a non-HB message status command
95 * @edx: [OUT] e.g. channel id
101 #define VMW_PORT_HB_OUT(cmd, in_ecx, in_si, in_di, \
103 eax, ebx, ecx, edx, si, di) \
105 asm volatile ("push %%rbp;" \
107 VMWARE_HYPERCALL_HB_OUT \
126 #define VMW_PORT_HB_IN(cmd, in_ecx, in_si, in_di, \
128 eax, ebx, ecx, edx, si, di) \
130 asm volatile ("push %%rbp;" \
132 VMWARE_HYPERCALL_HB_IN \
153 * In the 32-bit version of this macro, we store bp in a memory location
154 * because we've ran out of registers.
155 * Now we can't reference that memory location while we've modified
156 * %esp or %ebp, so we first push it on the stack, just before we push
157 * %ebp, and then when we need it we read it from the stack where we
160 #define VMW_PORT_HB_OUT(cmd, in_ecx, in_si, in_di, \
162 eax, ebx, ecx, edx, si, di) \
164 asm volatile ("push %12;" \
166 "mov 0x04(%%esp), %%ebp;" \
167 VMWARE_HYPERCALL_HB_OUT \
169 "add $0x04, %%esp;" : \
187 #define VMW_PORT_HB_IN(cmd, in_ecx, in_si, in_di, \
189 eax, ebx, ecx, edx, si, di) \
191 asm volatile ("push %12;" \
193 "mov 0x04(%%esp), %%ebp;" \
194 VMWARE_HYPERCALL_HB_IN \
196 "add $0x04, %%esp;" : \
212 #endif /* #if __x86_64__ */