浏览代码

Kernel: Move the VMWare helpers out of the IO namespace

Liav A 5 年之前
父节点
当前提交
f6ce24eb48
共有 3 个文件被更改,包括 41 次插入36 次删除
  1. 39 6
      Kernel/Devices/VMWareBackdoor.cpp
  2. 2 6
      Kernel/Devices/VMWareBackdoor.h
  3. 0 24
      Kernel/IO.h

+ 39 - 6
Kernel/Devices/VMWareBackdoor.cpp

@@ -38,8 +38,41 @@
 #define VMMOUSE_REQUEST_ABSOLUTE 0x53424152
 #define VMMOUSE_REQUEST_ABSOLUTE 0x53424152
 
 
 #define VMMOUSE_QEMU_VERSION 0x3442554a
 #define VMMOUSE_QEMU_VERSION 0x3442554a
+
+#define VMWARE_MAGIC 0x564D5868
+#define VMWARE_PORT 0x5658
+#define VMWARE_PORT_HIGHBANDWIDTH 0x5659
+
 //#define VMWAREBACKDOOR_DEBUG
 //#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 VMWareBackdoor* s_vmware_backdoor;
 
 
 static bool is_initialized()
 static bool is_initialized()
@@ -74,7 +107,7 @@ bool VMWareBackdoor::detect_presence()
     VMWareCommand command;
     VMWareCommand command;
     command.bx = ~VMWARE_MAGIC;
     command.bx = ~VMWARE_MAGIC;
     command.command = VMWARE_CMD_GETVERSION;
     command.command = VMWARE_CMD_GETVERSION;
-    IO::vmware_out(command);
+    vmware_out(command);
     if (command.bx != VMWARE_MAGIC || command.ax == 0xFFFFFFFF)
     if (command.bx != VMWARE_MAGIC || command.ax == 0xFFFFFFFF)
         return false;
         return false;
     return true;
     return true;
@@ -140,20 +173,20 @@ void VMWareBackdoor::disable_absolute_vmmouse()
     m_vmmouse_absolute = false;
     m_vmmouse_absolute = false;
 }
 }
 
 
-void VMWareBackdoor::send_highbandwidth(VMWareCommand& command)
+void VMWareBackdoor::send_high_bandwidth(VMWareCommand& command)
 {
 {
     if (supported()) {
     if (supported()) {
-        IO::vmware_highbandwidth_send(command);
+        vmware_high_bandwidth_send(command);
 #ifdef VMWAREBACKDOOR_DEBUG
 #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);
         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
 #endif
     }
     }
 }
 }
 
 
-void VMWareBackdoor::get_highbandwidth(VMWareCommand& command)
+void VMWareBackdoor::get_high_bandwidth(VMWareCommand& command)
 {
 {
     if (supported()) {
     if (supported()) {
-        IO::vmware_highbandwidth_get(command);
+        vmware_high_bandwidth_get(command);
 #ifdef VMWAREBACKDOOR_DEBUG
 #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);
         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
 #endif
@@ -163,7 +196,7 @@ void VMWareBackdoor::get_highbandwidth(VMWareCommand& command)
 void VMWareBackdoor::send(VMWareCommand& command)
 void VMWareBackdoor::send(VMWareCommand& command)
 {
 {
     if (supported()) {
     if (supported()) {
-        IO::vmware_out(command);
+        vmware_out(command);
 #ifdef VMWAREBACKDOOR_DEBUG
 #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);
         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
 #endif

+ 2 - 6
Kernel/Devices/VMWareBackdoor.h

@@ -28,10 +28,6 @@
 
 
 #include <AK/Types.h>
 #include <AK/Types.h>
 
 
-#define VMWARE_MAGIC 0x564D5868
-#define VMWARE_PORT 0x5658
-#define VMWARE_PORT_HIGHBANDWIDTH 0x5659
-
 #define VMMOUSE_GETVERSION 10
 #define VMMOUSE_GETVERSION 10
 #define VMMOUSE_DATA 39
 #define VMMOUSE_DATA 39
 #define VMMOUSE_STATUS 40
 #define VMMOUSE_STATUS 40
@@ -69,8 +65,8 @@ public:
     void send(VMWareCommand& command);
     void send(VMWareCommand& command);
 
 
 private:
 private:
-    void send_highbandwidth(VMWareCommand& command);
-    void get_highbandwidth(VMWareCommand& command);
+    void send_high_bandwidth(VMWareCommand& command);
+    void get_high_bandwidth(VMWareCommand& command);
     VMWareBackdoor();
     VMWareBackdoor();
     bool detect_presence();
     bool detect_presence();
     bool detect_vmmouse();
     bool detect_vmmouse();

+ 0 - 24
Kernel/IO.h

@@ -89,30 +89,6 @@ inline void repeated_out16(u16 port, const u8* data, int data_size)
                  : "d"(port));
                  : "d"(port));
 }
 }
 
 
-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_highbandwidth_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_highbandwidth_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));
-}
-
 inline void delay()
 inline void delay()
 {
 {
     // ~3 microsecs
     // ~3 microsecs