similarity index 79%
rename from lib/x86/io.h
rename to lib/x86/asm/io.h
@@ -1,5 +1,5 @@
-#ifndef IO_H
-#define IO_H
+#ifndef _ASM_X86_IO_H_
+#define _ASM_X86_IO_H_
static inline unsigned char inb(unsigned short port)
{
@@ -37,4 +37,14 @@ 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
@@ -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)
{
@@ -1,6 +1,6 @@
#include "libcflat.h"
#include "smp.h"
-#include "io.h"
+#include "asm/io.h"
#ifndef USE_SERIAL
#define USE_SERIAL
#endif
@@ -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
@@ -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)); \
@@ -1,4 +1,5 @@
#include "hyperv.h"
+#include "asm/io.h"
static void synic_ctl(u8 ctl, u8 vcpu_id, u8 sint)
{
@@ -3,7 +3,6 @@
#include "libcflat.h"
#include "processor.h"
-#include "io.h"
#define HYPERV_CPUID_FEATURES 0x40000003
@@ -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"
@@ -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"
@@ -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,6 @@
#include "vm.h"
#include "smp.h"
#include "types.h"
-#include "io.h"
/* for the nested page table*/
u64 *pml4e;
@@ -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);
@@ -35,7 +35,6 @@
#include "vmx.h"
#include "msr.h"
#include "smp.h"
-#include "io.h"
u64 *vmxon_region;
struct vmcs *vmcs_root;
@@ -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"