All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alexander Gordeev <agordeev@redhat.com>
To: kvm@vger.kernel.org
Cc: "Alexander Gordeev" <agordeev@redhat.com>,
	"Andrew Jones" <drjones@redhat.com>,
	"Thomas Huth" <thuth@redhat.com>,
	"Radim Krčmář" <rkrcmar@redhat.com>
Subject: [PATCH 4/9] x86: Introduce lib/x86/asm/io.h
Date: Wed, 20 Apr 2016 15:18:50 +0200	[thread overview]
Message-ID: <f0529f2cf7a704410d89757ddb7aa432bd4e2d7d.1461155725.git.agordeev@redhat.com> (raw)
In-Reply-To: <cover.1461155725.git.agordeev@redhat.com>

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

Cc: Andrew Jones <drjones@redhat.com>
Cc: Thomas Huth <thuth@redhat.com>
Cc: Radim Krčmář <rkrcmar@redhat.com>
Signed-off-by: Alexander Gordeev <agordeev@redhat.com>
---
 lib/x86/asm/io.h    | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 lib/x86/asm/pci.h   |  2 +-
 lib/x86/io.c        |  2 +-
 lib/x86/io.h        | 40 ----------------------------------------
 lib/x86/vm.h        | 12 +-----------
 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, 58 insertions(+), 67 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 0000000..68b10e5
--- /dev/null
+++ b/lib/x86/asm/io.h
@@ -0,0 +1,52 @@
+#ifndef _ASM_X86_IO_H_
+#define _ASM_X86_IO_H_
+
+#include "asm/page.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 4ec20e1..cddde41 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 d3b971e..d396d42 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 bd6341c..0000000
--- 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 72f84e6..21ed2b6 100644
--- a/lib/x86/vm.h
+++ b/lib/x86/vm.h
@@ -2,7 +2,7 @@
 #define VM_H
 
 #include "processor.h"
-#include "asm/page.h"
+#include "asm/io.h"
 
 void setup_vm();
 
@@ -27,14 +27,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 57c2a2d..84dfe71 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 824773d..2511aa2 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 faf931b..434a933 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 bf2e429..9a971ef 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 6e08894..4bd07c3 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 344dc1c..f47d671 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 934b2ae..401ff6c 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 9e04975..db7dbd8 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 6618008..411ed32 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 71c571c..e83c8a2 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


  parent reply	other threads:[~2016-04-20 13:19 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-20 13:18 [PATCH 0/9] x86: Cleanup low-level arch code Alexander Gordeev
2016-04-20 13:18 ` [PATCH 1/9] Remove unused and unnecessary PHYS32 macro Alexander Gordeev
2016-04-20 13:54   ` Andrew Jones
2016-04-20 13:18 ` [PATCH 2/9] Move phys_addr_t type definition to lib/libcflat.h Alexander Gordeev
2016-04-20 14:02   ` Andrew Jones
2016-04-20 13:18 ` [PATCH 3/9] x86: Introduce lib/x86/asm/page.h Alexander Gordeev
2016-04-20 13:18 ` Alexander Gordeev [this message]
2016-04-20 13:18 ` [PATCH 5/9] x86: Introduce lib/x86/asm/barrier.h Alexander Gordeev
2016-04-20 13:18 ` [PATCH 6/9] x86: Optimize virt_to_phys() and phys_to_virt() Alexander Gordeev
2016-04-20 13:18 ` [PATCH 7/9] io: Introduce generic IO accessors Alexander Gordeev
2016-04-20 14:09   ` Andrew Jones
2016-04-21  6:37     ` Alexander Gordeev
2016-04-20 13:18 ` [PATCH 8/9] io: Make ioremap() prototype conform to Linux one Alexander Gordeev
2016-04-20 14:10   ` Andrew Jones
2016-04-21  6:19     ` Alexander Gordeev
2016-04-20 13:18 ` [PATCH 9/9] io/x86: Factor out ioremap() Alexander Gordeev
2016-04-20 14:13 ` [PATCH 0/9] x86: Cleanup low-level arch code Andrew Jones

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=f0529f2cf7a704410d89757ddb7aa432bd4e2d7d.1461155725.git.agordeev@redhat.com \
    --to=agordeev@redhat.com \
    --cc=drjones@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=rkrcmar@redhat.com \
    --cc=thuth@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.