mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-12-28 13:43:45 +03:00
Kernel: Fix vmmouse detection method
Also, add debug messages in the VMWareBackdoor class.
This commit is contained in:
parent
6070fe581b
commit
8e8f5c212b
Notes:
sideshowbarker
2024-07-19 09:36:16 +09:00
Author: https://github.com/supercomputer7 Commit: https://github.com/SerenityOS/serenity/commit/8e8f5c212b5 Pull-request: https://github.com/SerenityOS/serenity/pull/1182 Reviewed-by: https://github.com/awesomekling
@ -25,6 +25,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <AK/Assertions.h>
|
#include <AK/Assertions.h>
|
||||||
|
#include <AK/String.h>
|
||||||
#include <Kernel/Arch/i386/CPU.h>
|
#include <Kernel/Arch/i386/CPU.h>
|
||||||
#include <Kernel/Devices/VMWareBackdoor.h>
|
#include <Kernel/Devices/VMWareBackdoor.h>
|
||||||
#include <Kernel/IO.h>
|
#include <Kernel/IO.h>
|
||||||
@ -36,6 +37,9 @@
|
|||||||
#define VMMOUSE_REQUEST_RELATIVE 0x4c455252
|
#define VMMOUSE_REQUEST_RELATIVE 0x4c455252
|
||||||
#define VMMOUSE_REQUEST_ABSOLUTE 0x53424152
|
#define VMMOUSE_REQUEST_ABSOLUTE 0x53424152
|
||||||
|
|
||||||
|
#define VMMOUSE_QEMU_VERSION 0x3442554a
|
||||||
|
//#define VMWAREBACKDOOR_DEBUG
|
||||||
|
|
||||||
static VMWareBackdoor* s_vmware_backdoor;
|
static VMWareBackdoor* s_vmware_backdoor;
|
||||||
|
|
||||||
static bool is_initialized()
|
static bool is_initialized()
|
||||||
@ -86,11 +90,13 @@ bool VMWareBackdoor::detect_vmmouse()
|
|||||||
if (!supported())
|
if (!supported())
|
||||||
return false;
|
return false;
|
||||||
VMWareCommand command;
|
VMWareCommand command;
|
||||||
command.bx = 0;
|
command.bx = VMMOUSE_READ_ID;
|
||||||
command.command = VMMOUSE_GETVERSION;
|
command.command = VMMOUSE_COMMAND;
|
||||||
send(command);
|
send(command);
|
||||||
// Apparently after a VMMOUSE_GETVERSION command, we should see that EBX register = VMWARE_MAGIC
|
command.bx = 1;
|
||||||
if (command.bx != VMWARE_MAGIC || command.ax == 0xFFFFFFFF)
|
command.command = VMMOUSE_DATA;
|
||||||
|
send(command);
|
||||||
|
if (command.ax != VMMOUSE_QEMU_VERSION)
|
||||||
return false;
|
return false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -108,21 +114,13 @@ void VMWareBackdoor::enable_absolute_vmmouse()
|
|||||||
|
|
||||||
VMWareCommand command;
|
VMWareCommand command;
|
||||||
|
|
||||||
// Enable vmmouse
|
|
||||||
command.bx = VMMOUSE_READ_ID;
|
|
||||||
command.command = VMMOUSE_COMMAND;
|
|
||||||
send(command);
|
|
||||||
|
|
||||||
// Status
|
|
||||||
command.bx = 0;
|
command.bx = 0;
|
||||||
command.command = VMMOUSE_STATUS;
|
command.command = VMMOUSE_STATUS;
|
||||||
|
|
||||||
send(command);
|
|
||||||
|
|
||||||
// Read Data
|
|
||||||
command.bx = 1;
|
|
||||||
command.command = VMMOUSE_DATA;
|
|
||||||
send(command);
|
send(command);
|
||||||
|
if (command.ax == 0xFFFF0000) {
|
||||||
|
kprintf("VMMouse retuned bad status.\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Enable absolute vmmouse
|
// Enable absolute vmmouse
|
||||||
command.bx = VMMOUSE_REQUEST_ABSOLUTE;
|
command.bx = VMMOUSE_REQUEST_ABSOLUTE;
|
||||||
@ -144,18 +142,30 @@ void VMWareBackdoor::disable_absolute_vmmouse()
|
|||||||
|
|
||||||
void VMWareBackdoor::send_highbandwidth(VMWareCommand& command)
|
void VMWareBackdoor::send_highbandwidth(VMWareCommand& command)
|
||||||
{
|
{
|
||||||
if (supported())
|
if (supported()) {
|
||||||
IO::vmware_highbandwidth_send(command);
|
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)
|
void VMWareBackdoor::get_highbandwidth(VMWareCommand& command)
|
||||||
{
|
{
|
||||||
if (supported())
|
if (supported()) {
|
||||||
IO::vmware_highbandwidth_get(command);
|
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)
|
void VMWareBackdoor::send(VMWareCommand& command)
|
||||||
{
|
{
|
||||||
if (supported())
|
if (supported()) {
|
||||||
IO::vmware_out(command);
|
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
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user