similarity index 87%
rename from lib/x86/io.h
rename to 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
new file mode 100644
@@ -0,0 +1 @@
+#include "asm-generic/page.h"
@@ -1,6 +1,6 @@
#include "libcflat.h"
#include "smp.h"
-#include "io.h"
+#include "asm/io.h"
#ifndef USE_SERIAL
#define USE_SERIAL
#endif
@@ -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;
@@ -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;
@@ -3,7 +3,7 @@
#include "libcflat.h"
#include "processor.h"
-#include "io.h"
+#include "asm/io.h"
#define HYPERV_CPUID_FEATURES 0x40000003
@@ -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
@@ -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
@@ -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 */
@@ -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;
@@ -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;
@@ -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"
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@redhat.com> --- 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