From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andrew Jones Subject: [kvm-unit-tests PATCH v2 02/10] x86: move io.h to asm Date: Fri, 15 Jan 2016 17:51:27 +0100 Message-ID: <1452876695-9240-3-git-send-email-drjones@redhat.com> References: <1452876695-9240-1-git-send-email-drjones@redhat.com> Cc: pbonzini@redhat.com, mst@redhat.com, agordeev@redhat.com, rkrcmar@redhat.com To: kvm@vger.kernel.org Return-path: Received: from mx1.redhat.com ([209.132.183.28]:52799 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752205AbcAOQvp (ORCPT ); Fri, 15 Jan 2016 11:51:45 -0500 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (Postfix) with ESMTPS id 8D37BC813 for ; Fri, 15 Jan 2016 16:51:45 +0000 (UTC) In-Reply-To: <1452876695-9240-1-git-send-email-drjones@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: Also throw an '#include "asm-generic/io.h"' at the bottom. Doing that requires also adding an asm/page.h, and then some changes to vm.[ch] to integrate with it. Signed-off-by: Andrew Jones --- lib/x86/{ => asm}/io.h | 8 ++++++++ lib/x86/asm/page.h | 1 + lib/x86/io.c | 2 +- lib/x86/vm.c | 7 ------- lib/x86/vm.h | 4 +++- x86/hyperv.h | 2 +- x86/hyperv_stimer.c | 2 +- x86/hyperv_synic.c | 2 +- x86/init.c | 2 +- x86/svm.c | 2 +- x86/vmx.c | 2 +- x86/vmx_tests.c | 2 +- 12 files changed, 20 insertions(+), 16 deletions(-) rename lib/x86/{ => asm}/io.h (87%) create mode 100644 lib/x86/asm/page.h diff --git a/lib/x86/io.h b/lib/x86/asm/io.h similarity index 87% rename from lib/x86/io.h rename to lib/x86/asm/io.h index bd6341c6c103e..19f4dd73ae173 100644 --- a/lib/x86/io.h +++ b/lib/x86/asm/io.h @@ -1,6 +1,7 @@ #ifndef IO_H #define IO_H +#define inb inb static inline unsigned char inb(unsigned short port) { unsigned char value; @@ -8,6 +9,7 @@ static inline unsigned char inb(unsigned short port) return value; } +#define inw inw static inline unsigned short inw(unsigned short port) { unsigned short value; @@ -15,6 +17,7 @@ static inline unsigned short inw(unsigned short port) return value; } +#define inl inl static inline unsigned int inl(unsigned short port) { unsigned int value; @@ -22,19 +25,24 @@ static inline unsigned int inl(unsigned short port) return value; } +#define outb outb static inline void outb(unsigned char value, unsigned short port) { asm volatile("outb %b0, %w1" : : "a"(value), "Nd"(port)); } +#define outw outw static inline void outw(unsigned short value, unsigned short port) { asm volatile("outw %w0, %w1" : : "a"(value), "Nd"(port)); } +#define outl outl static inline void outl(unsigned int value, unsigned short port) { asm volatile("outl %0, %w1" : : "a"(value), "Nd"(port)); } +#include "asm-generic/io.h" + #endif diff --git a/lib/x86/asm/page.h b/lib/x86/asm/page.h new file mode 100644 index 0000000000000..91a4bc3b7f86e --- /dev/null +++ b/lib/x86/asm/page.h @@ -0,0 +1 @@ +#include "asm-generic/page.h" diff --git a/lib/x86/io.c b/lib/x86/io.c index d3b971ef67b0e..d396d42d0535c 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/vm.c b/lib/x86/vm.c index b820c7def72ab..dfd6d512dc650 100644 --- a/lib/x86/vm.c +++ b/lib/x86/vm.c @@ -2,13 +2,6 @@ #include "vm.h" #include "libcflat.h" -#define PAGE_SIZE 4096ul -#ifdef __x86_64__ -#define LARGE_PAGE_SIZE (512 * PAGE_SIZE) -#else -#define LARGE_PAGE_SIZE (1024 * PAGE_SIZE) -#endif - static void *free = 0; static void *vfree_top = 0; diff --git a/lib/x86/vm.h b/lib/x86/vm.h index 28794d7f26c6b..0d549a810ffb8 100644 --- a/lib/x86/vm.h +++ b/lib/x86/vm.h @@ -2,8 +2,8 @@ #define VM_H #include "processor.h" +#include "asm/page.h" -#define PAGE_SIZE 4096ul #ifdef __x86_64__ #define LARGE_PAGE_SIZE (512 * PAGE_SIZE) #else @@ -39,11 +39,13 @@ 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); +#define virt_to_phys virt_to_phys static inline unsigned long virt_to_phys(const void *virt) { return (unsigned long)virt; } +#define phys_to_virt phys_to_virt static inline void *phys_to_virt(unsigned long phys) { return (void *)phys; diff --git a/x86/hyperv.h b/x86/hyperv.h index faf931bb4373e..628c08b5b565b 100644 --- a/x86/hyperv.h +++ b/x86/hyperv.h @@ -3,7 +3,7 @@ #include "libcflat.h" #include "processor.h" -#include "io.h" +#include "asm/io.h" #define HYPERV_CPUID_FEATURES 0x40000003 diff --git a/x86/hyperv_stimer.c b/x86/hyperv_stimer.c index 767459e55cc0b..0031835b44a9f 100644 --- a/x86/hyperv_stimer.c +++ b/x86/hyperv_stimer.c @@ -5,10 +5,10 @@ #include "vm.h" #include "apic.h" #include "desc.h" -#include "io.h" #include "smp.h" #include "atomic.h" #include "hyperv.h" +#include "asm/io.h" #define MAX_CPUS 4 diff --git a/x86/hyperv_synic.c b/x86/hyperv_synic.c index 6e088944be1f2..dee4ec373a760 100644 --- a/x86/hyperv_synic.c +++ b/x86/hyperv_synic.c @@ -5,10 +5,10 @@ #include "vm.h" #include "apic.h" #include "desc.h" -#include "io.h" #include "smp.h" #include "atomic.h" #include "hyperv.h" +#include "asm/io.h" #define MAX_CPUS 4 diff --git a/x86/init.c b/x86/init.c index 344dc1c0b234e..f47d671e62a85 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 1046ddf73732f..d659ae8aafefd 100644 --- a/x86/svm.c +++ b/x86/svm.c @@ -6,7 +6,7 @@ #include "vm.h" #include "smp.h" #include "types.h" -#include "io.h" +#include "asm/io.h" /* for the nested page table*/ u64 *pml4e; diff --git a/x86/vmx.c b/x86/vmx.c index 3fa1a735881f7..56edb2f9086b2 100644 --- a/x86/vmx.c +++ b/x86/vmx.c @@ -35,7 +35,7 @@ #include "vmx.h" #include "msr.h" #include "smp.h" -#include "io.h" +#include "asm/io.h" u64 *vmxon_region; struct vmcs *vmcs_root; diff --git a/x86/vmx_tests.c b/x86/vmx_tests.c index 451fdd75d24e1..8b055086c7d60 100644 --- a/x86/vmx_tests.c +++ b/x86/vmx_tests.c @@ -7,7 +7,7 @@ #include "msr.h" #include "processor.h" #include "vm.h" -#include "io.h" +#include "asm/io.h" #include "fwcfg.h" #include "isr.h" #include "apic.h" -- 2.4.3