Add an x86-64 compatible _ExecuteCommand()

This implementation introduces the minimal changes necessary to support
the existing VMWareTypes API on x86-64. If a more expansive set of guest
additions are required, it may make sense to adopt a more general
approach akin to the one used here:
	https://github.com/jcs/vmwh/blob/f177dd3cf/vmware.c#L49

Signed-off-by: Michael Lotz <[email protected]>
This commit is contained in:
Landon Fuller
2012-11-27 21:03:02 +01:00
committed by Michael Lotz
parent 054ec8a776
commit 297feca8e5
@@ -104,6 +104,26 @@ VMWareMouseFilter::_ExecuteCommand(union packet_u &packet)
packet.command.port = VMWARE_PORT_NUMBER; packet.command.port = VMWARE_PORT_NUMBER;
int dummy; int dummy;
#ifdef __x86_64__
asm volatile (
"pushq %%rbx;"
"pushq %%rax;"
"movl 12(%%rax), %%edx;"
"movl 8(%%rax), %%ecx;"
"movl 4(%%rax), %%ebx;"
"movl (%%rax), %%eax;"
"inl %%dx, %%eax;"
"xchgq %%rax, (%%rsp);"
"movl %%edx, 12(%%rax);"
"movl %%ecx, 8(%%rax);"
"movl %%ebx, 4(%%rax);"
"popq %%rbx;"
"movl %%ebx, (%%rax);"
"popq %%rbx;"
: "=a"(dummy)
: "0"(&packet)
: "rcx", "rdx", "memory");
#else
asm volatile ( asm volatile (
"pushl %%ebx;" "pushl %%ebx;"
"pushl %%eax;" "pushl %%eax;"
@@ -121,6 +141,7 @@ VMWareMouseFilter::_ExecuteCommand(union packet_u &packet)
: "=a"(dummy) : "=a"(dummy)
: "0"(&packet) : "0"(&packet)
: "ecx", "edx", "memory"); : "ecx", "edx", "memory");
#endif
} }