[kvm-unit-tests PATCH v8 04/12] x86: Introduce lib/x86/asm/io.h

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Make x86 consistent with other architectures and put
IO specific defines to lib/x86/asm/io.h

Cc: Andrew Jones <drjones@xxxxxxxxxx>
Cc: Thomas Huth <thuth@xxxxxxxxxx>
Cc: Paolo Bonzini <pbonzini@xxxxxxxxxx>
Cc: Radim Krčmář <rkrcmar@xxxxxxxxxx>
Reviewed-by: Andrew Jones <drjones@xxxxxxxxxx>
Signed-off-by: Alexander Gordeev <agordeev@xxxxxxxxxx>
---
 lib/x86/asm/io.h    | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++
 lib/x86/asm/pci.h   |  2 +-
 lib/x86/io.c        |  2 +-
 lib/x86/io.h        | 40 ----------------------------------------
 lib/x86/vm.h        | 11 +----------
 x86/eventinj.c      |  7 +------
 x86/hyperv.c        |  1 +
 x86/hyperv.h        |  1 -
 x86/hyperv_stimer.c |  1 -
 x86/hyperv_synic.c  |  1 -
 x86/init.c          |  2 +-
 x86/svm.c           |  1 -
 x86/vmexit.c        |  1 -
 x86/vmx.c           |  1 -
 x86/vmx_tests.c     |  1 -
 15 files changed, 56 insertions(+), 66 deletions(-)
 create mode 100644 lib/x86/asm/io.h
 delete mode 100644 lib/x86/io.h

diff --git a/lib/x86/asm/io.h b/lib/x86/asm/io.h
new file mode 100644
index 000000000000..c944df4b07c8
--- /dev/null
+++ b/lib/x86/asm/io.h
@@ -0,0 +1,50 @@
+#ifndef _ASM_X86_IO_H_
+#define _ASM_X86_IO_H_
+
+static inline unsigned char inb(unsigned short port)
+{
+    unsigned char value;
+    asm volatile("inb %w1, %0" : "=a" (value) : "Nd" (port));
+    return value;
+}
+
+static inline unsigned short inw(unsigned short port)
+{
+    unsigned short value;
+    asm volatile("inw %w1, %0" : "=a" (value) : "Nd" (port));
+    return value;
+}
+
+static inline unsigned int inl(unsigned short port)
+{
+    unsigned int value;
+    asm volatile("inl %w1, %0" : "=a" (value) : "Nd" (port));
+    return value;
+}
+
+static inline void outb(unsigned char value, unsigned short port)
+{
+    asm volatile("outb %b0, %w1" : : "a"(value), "Nd"(port));
+}
+
+static inline void outw(unsigned short value, unsigned short port)
+{
+    asm volatile("outw %w0, %w1" : : "a"(value), "Nd"(port));
+}
+
+static inline void outl(unsigned int value, unsigned short port)
+{
+    asm volatile("outl %0, %w1" : : "a"(value), "Nd"(port));
+}
+
+static inline unsigned long virt_to_phys(const void *virt)
+{
+    return (unsigned long)virt;
+}
+
+static inline void *phys_to_virt(unsigned long phys)
+{
+    return (void *)phys;
+}
+
+#endif
diff --git a/lib/x86/asm/pci.h b/lib/x86/asm/pci.h
index 4ec20e17d25b..cddde41a7d97 100644
--- a/lib/x86/asm/pci.h
+++ b/lib/x86/asm/pci.h
@@ -7,7 +7,7 @@
  */
 #include "libcflat.h"
 #include "pci.h"
-#include "x86/io.h"
+#include "x86/asm/io.h"
 
 static inline uint32_t pci_config_read(pcidevaddr_t dev, uint8_t reg)
 {
diff --git a/lib/x86/io.c b/lib/x86/io.c
index d3b971ef67b0..d396d42d0535 100644
--- a/lib/x86/io.c
+++ b/lib/x86/io.c
@@ -1,6 +1,6 @@
 #include "libcflat.h"
 #include "smp.h"
-#include "io.h"
+#include "asm/io.h"
 #ifndef USE_SERIAL
 #define USE_SERIAL
 #endif
diff --git a/lib/x86/io.h b/lib/x86/io.h
deleted file mode 100644
index bd6341c6c103..000000000000
--- a/lib/x86/io.h
+++ /dev/null
@@ -1,40 +0,0 @@
-#ifndef IO_H
-#define IO_H
-
-static inline unsigned char inb(unsigned short port)
-{
-    unsigned char value;
-    asm volatile("inb %w1, %0" : "=a" (value) : "Nd" (port));
-    return value;
-}
-
-static inline unsigned short inw(unsigned short port)
-{
-    unsigned short value;
-    asm volatile("inw %w1, %0" : "=a" (value) : "Nd" (port));
-    return value;
-}
-
-static inline unsigned int inl(unsigned short port)
-{
-    unsigned int value;
-    asm volatile("inl %w1, %0" : "=a" (value) : "Nd" (port));
-    return value;
-}
-
-static inline void outb(unsigned char value, unsigned short port)
-{
-    asm volatile("outb %b0, %w1" : : "a"(value), "Nd"(port));
-}
-
-static inline void outw(unsigned short value, unsigned short port)
-{
-    asm volatile("outw %w0, %w1" : : "a"(value), "Nd"(port));
-}
-
-static inline void outl(unsigned int value, unsigned short port)
-{
-    asm volatile("outl %0, %w1" : : "a"(value), "Nd"(port));
-}
-
-#endif
diff --git a/lib/x86/vm.h b/lib/x86/vm.h
index 72f84e6f5544..6a4384f5a48d 100644
--- a/lib/x86/vm.h
+++ b/lib/x86/vm.h
@@ -3,6 +3,7 @@
 
 #include "processor.h"
 #include "asm/page.h"
+#include "asm/io.h"
 
 void setup_vm();
 
@@ -27,14 +28,4 @@ unsigned long *install_large_page(unsigned long *cr3,unsigned long phys,
                                   void *virt);
 unsigned long *install_page(unsigned long *cr3, unsigned long phys, void *virt);
 
-static inline unsigned long virt_to_phys(const void *virt)
-{
-    return (unsigned long)virt;
-}
-
-static inline void *phys_to_virt(unsigned long phys)
-{
-    return (void *)phys;
-}
-
 #endif
diff --git a/x86/eventinj.c b/x86/eventinj.c
index 57c2a2d0cf28..84dfe71d8e2a 100644
--- a/x86/eventinj.c
+++ b/x86/eventinj.c
@@ -16,11 +16,6 @@ static inline void io_delay(void)
 {
 }
 
-static inline void outl(int addr, int val)
-{
-        asm volatile ("outl %1, %w0" : : "d" (addr), "a" (val));
-}
-
 void apic_self_ipi(u8 v)
 {
 	apic_icr_write(APIC_DEST_SELF | APIC_DEST_PHYSICAL | APIC_DM_FIXED |
@@ -32,7 +27,7 @@ void apic_self_nmi(void)
 	apic_icr_write(APIC_DEST_PHYSICAL | APIC_DM_NMI | APIC_INT_ASSERT, 0);
 }
 
-#define flush_phys_addr(__s) outl(0xe4, __s)
+#define flush_phys_addr(__s) outl(__s, 0xe4)
 #define flush_stack() do {						\
 		int __l;						\
 		flush_phys_addr(virt_to_phys(&__l));			\
diff --git a/x86/hyperv.c b/x86/hyperv.c
index 824773d07d67..2511aa2e24b3 100644
--- a/x86/hyperv.c
+++ b/x86/hyperv.c
@@ -1,4 +1,5 @@
 #include "hyperv.h"
+#include "asm/io.h"
 
 static void synic_ctl(u8 ctl, u8 vcpu_id, u8 sint)
 {
diff --git a/x86/hyperv.h b/x86/hyperv.h
index faf931bb4373..434a9334e2fd 100644
--- a/x86/hyperv.h
+++ b/x86/hyperv.h
@@ -3,7 +3,6 @@
 
 #include "libcflat.h"
 #include "processor.h"
-#include "io.h"
 
 #define HYPERV_CPUID_FEATURES                   0x40000003
 
diff --git a/x86/hyperv_stimer.c b/x86/hyperv_stimer.c
index bf2e4294ddad..9a971ef3593a 100644
--- a/x86/hyperv_stimer.c
+++ b/x86/hyperv_stimer.c
@@ -5,7 +5,6 @@
 #include "vm.h"
 #include "apic.h"
 #include "desc.h"
-#include "io.h"
 #include "smp.h"
 #include "atomic.h"
 #include "hyperv.h"
diff --git a/x86/hyperv_synic.c b/x86/hyperv_synic.c
index 5a06fb724a87..3f98c4280ef0 100644
--- a/x86/hyperv_synic.c
+++ b/x86/hyperv_synic.c
@@ -5,7 +5,6 @@
 #include "vm.h"
 #include "apic.h"
 #include "desc.h"
-#include "io.h"
 #include "smp.h"
 #include "atomic.h"
 #include "hyperv.h"
diff --git a/x86/init.c b/x86/init.c
index 344dc1c0b234..f47d671e62a8 100644
--- a/x86/init.c
+++ b/x86/init.c
@@ -1,6 +1,6 @@
 #include "libcflat.h"
 #include "apic.h"
-#include "io.h"
+#include "asm/io.h"
 
 #define KBD_CCMD_READ_OUTPORT   0xD0    /* read output port */
 #define KBD_CCMD_WRITE_OUTPORT  0xD1    /* write output port */
diff --git a/x86/svm.c b/x86/svm.c
index 301cf8cb2d6b..cef0f568d611 100644
--- a/x86/svm.c
+++ b/x86/svm.c
@@ -6,7 +6,6 @@
 #include "vm.h"
 #include "smp.h"
 #include "types.h"
-#include "io.h"
 
 /* for the nested page table*/
 u64 *pml4e;
diff --git a/x86/vmexit.c b/x86/vmexit.c
index 9e049752f6c6..db7dbd88fe2a 100644
--- a/x86/vmexit.c
+++ b/x86/vmexit.c
@@ -6,7 +6,6 @@
 #include "x86/vm.h"
 #include "x86/desc.h"
 #include "x86/acpi.h"
-#include "x86/io.h"
 
 struct test {
 	void (*func)(void);
diff --git a/x86/vmx.c b/x86/vmx.c
index 6618008e3d13..411ed3211d4d 100644
--- a/x86/vmx.c
+++ b/x86/vmx.c
@@ -35,7 +35,6 @@
 #include "vmx.h"
 #include "msr.h"
 #include "smp.h"
-#include "io.h"
 
 u64 *vmxon_region;
 struct vmcs *vmcs_root;
diff --git a/x86/vmx_tests.c b/x86/vmx_tests.c
index 71c571cd661b..e83c8a26d34c 100644
--- a/x86/vmx_tests.c
+++ b/x86/vmx_tests.c
@@ -7,7 +7,6 @@
 #include "msr.h"
 #include "processor.h"
 #include "vm.h"
-#include "io.h"
 #include "fwcfg.h"
 #include "isr.h"
 #include "apic.h"
-- 
1.8.3.1

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux