diff options
author | Liav A <liavalb@gmail.com> | 2020-02-05 17:54:15 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-02-05 18:58:27 +0100 |
commit | 8e8f5c212b5acd313215ea2b78fae528be54db8f (patch) | |
tree | ced45540e263c0f36a3031ad431195749205a791 /Kernel/Devices | |
parent | 6070fe581bb1b4af05374de0cd268f8d88ed6e63 (diff) | |
download | serenity-8e8f5c212b5acd313215ea2b78fae528be54db8f.zip |
Kernel: Fix vmmouse detection method
Also, add debug messages in the VMWareBackdoor class.
Diffstat (limited to 'Kernel/Devices')
-rw-r--r-- | Kernel/Devices/VMWareBackdoor.cpp | 48 |
1 files changed, 29 insertions, 19 deletions
diff --git a/Kernel/Devices/VMWareBackdoor.cpp b/Kernel/Devices/VMWareBackdoor.cpp index b63a3cff1e..dbd2613486 100644 --- a/Kernel/Devices/VMWareBackdoor.cpp +++ b/Kernel/Devices/VMWareBackdoor.cpp @@ -25,6 +25,7 @@ */ #include <AK/Assertions.h> +#include <AK/String.h> #include <Kernel/Arch/i386/CPU.h> #include <Kernel/Devices/VMWareBackdoor.h> #include <Kernel/IO.h> @@ -36,6 +37,9 @@ #define VMMOUSE_REQUEST_RELATIVE 0x4c455252 #define VMMOUSE_REQUEST_ABSOLUTE 0x53424152 +#define VMMOUSE_QEMU_VERSION 0x3442554a +//#define VMWAREBACKDOOR_DEBUG + static VMWareBackdoor* s_vmware_backdoor; static bool is_initialized() @@ -86,11 +90,13 @@ bool VMWareBackdoor::detect_vmmouse() if (!supported()) return false; VMWareCommand command; - command.bx = 0; - command.command = VMMOUSE_GETVERSION; + command.bx = VMMOUSE_READ_ID; + command.command = VMMOUSE_COMMAND; send(command); - // Apparently after a VMMOUSE_GETVERSION command, we should see that EBX register = VMWARE_MAGIC - if (command.bx != VMWARE_MAGIC || command.ax == 0xFFFFFFFF) + command.bx = 1; + command.command = VMMOUSE_DATA; + send(command); + if (command.ax != VMMOUSE_QEMU_VERSION) return false; return true; } @@ -108,21 +114,13 @@ void VMWareBackdoor::enable_absolute_vmmouse() VMWareCommand command; - // Enable vmmouse - command.bx = VMMOUSE_READ_ID; - command.command = VMMOUSE_COMMAND; - send(command); - - // Status command.bx = 0; command.command = VMMOUSE_STATUS; - - send(command); - - // Read Data - command.bx = 1; - command.command = VMMOUSE_DATA; send(command); + if (command.ax == 0xFFFF0000) { + kprintf("VMMouse retuned bad status.\n"); + return; + } // Enable absolute vmmouse command.bx = VMMOUSE_REQUEST_ABSOLUTE; @@ -144,18 +142,30 @@ void VMWareBackdoor::disable_absolute_vmmouse() void VMWareBackdoor::send_highbandwidth(VMWareCommand& command) { - if (supported()) + if (supported()) { IO::vmware_highbandwidth_send(command); +#ifdef VMWAREBACKDOOR_DEBUG + dbg() << "VMWareBackdoor Command High bandwidth Send Results: EAX " << String::format("%x", command.ax) << " EBX " << String::format("%x", command.bx) << " ECX " << String::format("%x", command.cx) << " EDX " << String::format("%x", command.dx); +#endif + } } void VMWareBackdoor::get_highbandwidth(VMWareCommand& command) { - if (supported()) + if (supported()) { IO::vmware_highbandwidth_get(command); +#ifdef VMWAREBACKDOOR_DEBUG + dbg() << "VMWareBackdoor Command High bandwidth Get Results: EAX " << String::format("%x", command.ax) << " EBX " << String::format("%x", command.bx) << " ECX " << String::format("%x", command.cx) << " EDX " << String::format("%x", command.dx); +#endif + } } void VMWareBackdoor::send(VMWareCommand& command) { - if (supported()) + if (supported()) { IO::vmware_out(command); +#ifdef VMWAREBACKDOOR_DEBUG + dbg() << "VMWareBackdoor Command Send Results: EAX " << String::format("%x", command.ax) << " EBX " << String::format("%x", command.bx) << " ECX " << String::format("%x", command.cx) << " EDX " << String::format("%x", command.dx); +#endif + } } |