summaryrefslogtreecommitdiff
path: root/Kernel/Devices
diff options
context:
space:
mode:
authorLiav A <liavalb@gmail.com>2020-02-05 19:38:45 +0200
committerAndreas Kling <kling@serenityos.org>2020-02-05 18:58:27 +0100
commitf6ce24eb48dfc6f9f66e3b7a45920e8a866ee930 (patch)
tree944cbc427948989cdb7632dfb5da90c4cbe67148 /Kernel/Devices
parent8e8f5c212b5acd313215ea2b78fae528be54db8f (diff)
downloadserenity-f6ce24eb48dfc6f9f66e3b7a45920e8a866ee930.zip
Kernel: Move the VMWare helpers out of the IO namespace
Diffstat (limited to 'Kernel/Devices')
-rw-r--r--Kernel/Devices/VMWareBackdoor.cpp45
-rw-r--r--Kernel/Devices/VMWareBackdoor.h8
2 files changed, 41 insertions, 12 deletions
diff --git a/Kernel/Devices/VMWareBackdoor.cpp b/Kernel/Devices/VMWareBackdoor.cpp
index dbd2613486..3a7621e890 100644
--- a/Kernel/Devices/VMWareBackdoor.cpp
+++ b/Kernel/Devices/VMWareBackdoor.cpp
@@ -38,8 +38,41 @@
#define VMMOUSE_REQUEST_ABSOLUTE 0x53424152
#define VMMOUSE_QEMU_VERSION 0x3442554a
+
+#define VMWARE_MAGIC 0x564D5868
+#define VMWARE_PORT 0x5658
+#define VMWARE_PORT_HIGHBANDWIDTH 0x5659
+
//#define VMWAREBACKDOOR_DEBUG
+inline void vmware_out(VMWareCommand& command)
+{
+ command.magic = VMWARE_MAGIC;
+ command.port = VMWARE_PORT;
+ command.si = 0;
+ command.di = 0;
+ asm volatile("in %%dx, %0"
+ : "+a"(command.ax), "+b"(command.bx), "+c"(command.cx), "+d"(command.dx), "+S"(command.si), "+D"(command.di));
+}
+
+inline void vmware_high_bandwidth_send(VMWareCommand& command)
+{
+
+ command.magic = VMWARE_MAGIC;
+ command.port = VMWARE_PORT_HIGHBANDWIDTH;
+
+ asm volatile("cld; rep; outsb"
+ : "+a"(command.ax), "+b"(command.bx), "+c"(command.cx), "+d"(command.dx), "+S"(command.si), "+D"(command.di));
+}
+
+inline void vmware_high_bandwidth_get(VMWareCommand& command)
+{
+ command.magic = VMWARE_MAGIC;
+ command.port = VMWARE_PORT_HIGHBANDWIDTH;
+ asm volatile("cld; rep; insb"
+ : "+a"(command.ax), "+b"(command.bx), "+c"(command.cx), "+d"(command.dx), "+S"(command.si), "+D"(command.di));
+}
+
static VMWareBackdoor* s_vmware_backdoor;
static bool is_initialized()
@@ -74,7 +107,7 @@ bool VMWareBackdoor::detect_presence()
VMWareCommand command;
command.bx = ~VMWARE_MAGIC;
command.command = VMWARE_CMD_GETVERSION;
- IO::vmware_out(command);
+ vmware_out(command);
if (command.bx != VMWARE_MAGIC || command.ax == 0xFFFFFFFF)
return false;
return true;
@@ -140,20 +173,20 @@ void VMWareBackdoor::disable_absolute_vmmouse()
m_vmmouse_absolute = false;
}
-void VMWareBackdoor::send_highbandwidth(VMWareCommand& command)
+void VMWareBackdoor::send_high_bandwidth(VMWareCommand& command)
{
if (supported()) {
- IO::vmware_highbandwidth_send(command);
+ vmware_high_bandwidth_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_high_bandwidth(VMWareCommand& command)
{
if (supported()) {
- IO::vmware_highbandwidth_get(command);
+ vmware_high_bandwidth_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
@@ -163,7 +196,7 @@ void VMWareBackdoor::get_highbandwidth(VMWareCommand& command)
void VMWareBackdoor::send(VMWareCommand& command)
{
if (supported()) {
- IO::vmware_out(command);
+ 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
diff --git a/Kernel/Devices/VMWareBackdoor.h b/Kernel/Devices/VMWareBackdoor.h
index df0f325960..2a60bd6ab9 100644
--- a/Kernel/Devices/VMWareBackdoor.h
+++ b/Kernel/Devices/VMWareBackdoor.h
@@ -28,10 +28,6 @@
#include <AK/Types.h>
-#define VMWARE_MAGIC 0x564D5868
-#define VMWARE_PORT 0x5658
-#define VMWARE_PORT_HIGHBANDWIDTH 0x5659
-
#define VMMOUSE_GETVERSION 10
#define VMMOUSE_DATA 39
#define VMMOUSE_STATUS 40
@@ -69,8 +65,8 @@ public:
void send(VMWareCommand& command);
private:
- void send_highbandwidth(VMWareCommand& command);
- void get_highbandwidth(VMWareCommand& command);
+ void send_high_bandwidth(VMWareCommand& command);
+ void get_high_bandwidth(VMWareCommand& command);
VMWareBackdoor();
bool detect_presence();
bool detect_vmmouse();