ladybird/Kernel/Devices/VMWareBackdoor.h
Jelle Raaijmakers a4b1c0fd0c Kernel: Process available VMWare mouse events immediately
The Qemu I8042 controller does not send one IRQ per event, it sends
over four since it will not stop trying to emulate the PS/2 mouse.

If the VMWare backdoor is active, a fake I8042 mouse event will be sent
that we can then use to check if there are VMWare mouse events present.
However, we were only processing one mouse event at a time, even though
multiple events could have been queued up. Luckily this does not often
lead to issues, since after the first IRQ we would still get three
additional interrupts that would then empty the queue.

This change makes sure we always empty the event queue immediately,
instead of waiting on the next interrupt to happen. Functionally this
changes nothing - it could merely improve latency by not waiting for
new interrupts to come in.

Coincidently, this brings our implementation closer to how Linux deals
with the VMMouse.
2021-11-04 18:53:37 +01:00

64 lines
1.1 KiB
C++

/*
* Copyright (c) 2020, Liav A. <liavalb@hotmail.co.il>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <AK/Types.h>
#include <AK/kmalloc.h>
#include <Kernel/API/MousePacket.h>
namespace Kernel {
#define VMMOUSE_GETVERSION 10
#define VMMOUSE_DATA 39
#define VMMOUSE_STATUS 40
#define VMMOUSE_COMMAND 41
struct VMWareCommand {
union {
u32 ax;
u32 magic;
};
union {
u32 bx;
u32 size;
};
union {
u32 cx;
u32 command;
};
union {
u32 dx;
u32 port;
};
u32 si;
u32 di;
};
class VMWareBackdoor {
AK_MAKE_ETERNAL;
public:
VMWareBackdoor();
static VMWareBackdoor* the();
bool vmmouse_is_absolute() const;
void enable_absolute_vmmouse();
void disable_absolute_vmmouse();
void send(VMWareCommand& command);
u16 read_mouse_status_queue_size();
MousePacket receive_mouse_packet();
private:
void send_high_bandwidth(VMWareCommand& command);
void get_high_bandwidth(VMWareCommand& command);
bool detect_vmmouse();
bool m_vmmouse_absolute { false };
};
}