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 <drjones@xxxxxxxxxx> --- 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 -- 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