]> rtime.felk.cvut.cz Git - jailhouse.git/blobdiff - inmates/lib/x86/inmate.h
Merge remote-tracking branch 'kiszka/master'
[jailhouse.git] / inmates / lib / x86 / inmate.h
index 0dcea56df1f389691de2827a9ae091e070fb0ce5..2c22de06d8753ad24dbdd029742cbefeaf9ac9a5 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * Jailhouse, a Linux-based partitioning hypervisor
  *
- * Copyright (c) Siemens AG, 2013
+ * Copyright (c) Siemens AG, 2013-2016
  *
  * Authors:
  *  Jan Kiszka <jan.kiszka@siemens.com>
@@ -10,7 +10,8 @@
  * the COPYING file in the top-level directory.
  */
 
-#define NULL                   ((void *)0)
+#ifndef _JAILHOUSE_INMATE_H
+#define _JAILHOUSE_INMATE_H
 
 #define HEAP_BASE              0x000000
 #define FSEGMENT_BASE          0x0f0000
 #define INMATE_CS64            0x10
 #define INMATE_DS32            0x18
 
-#define NS_PER_USEC            1000UL
-#define NS_PER_MSEC            1000000UL
-#define NS_PER_SEC             1000000000UL
-
 #define PAGE_SIZE              (4 * 1024ULL)
 #ifdef __x86_64__
+#define BITS_PER_LONG          64
 #define HUGE_PAGE_SIZE         (2 * 1024 * 1024ULL)
 #else
+#define BITS_PER_LONG          32
 #define HUGE_PAGE_SIZE         (4 * 1024 * 1024ULL)
 #endif
 #define PAGE_MASK              (~(PAGE_SIZE - 1))
 #define HUGE_PAGE_MASK         (~(HUGE_PAGE_SIZE - 1))
 
 #define X2APIC_ID              0x802
+#define X2APIC_ICR             0x830
+
+#define APIC_LVL_ASSERT                (1 << 14)
 
 #define PCI_CFG_VENDOR_ID      0x000
 #define PCI_CFG_DEVICE_ID      0x002
@@ -44,6 +46,7 @@
 # define PCI_CMD_INTX_OFF      (1 << 10)
 #define PCI_CFG_STATUS         0x006
 # define PCI_STS_INT           (1 << 3)
+# define PCI_STS_CAPS          (1 << 4)
 #define PCI_CFG_BAR            0x010
 # define PCI_BAR_64BIT         0x4
 #define PCI_CFG_CAP_PTR                0x034
@@ -56,6 +59,8 @@
 #define MSIX_CTRL_ENABLE       0x8000
 #define MSIX_CTRL_FMASK                0x4000
 
+#define SMP_MAX_CPUS           255
+
 #ifndef __ASSEMBLY__
 typedef signed char s8;
 typedef unsigned char u8;
@@ -69,20 +74,6 @@ typedef unsigned int u32;
 typedef signed long long s64;
 typedef unsigned long long u64;
 
-typedef s8 __s8;
-typedef u8 __u8;
-
-typedef s16 __s16;
-typedef u16 __u16;
-
-typedef s32 __s32;
-typedef u32 __u32;
-
-typedef s64 __s64;
-typedef u64 __u64;
-
-typedef enum { true=1, false=0 } bool;
-
 static inline void cpu_relax(void)
 {
        asm volatile("rep; nop" : : : "memory");
@@ -181,7 +172,7 @@ static inline void write_msr(unsigned int msr, u64 val)
 {
        asm volatile("wrmsr"
                : /* no output */
-               : "c" (msr), "a" (val), "d" (val >> 32)
+               : "c" (msr), "a" ((u32)val), "d" ((u32)(val >> 32))
                : "memory");
 }
 
@@ -190,20 +181,11 @@ static inline unsigned int cpu_id(void)
        return read_msr(X2APIC_ID);
 }
 
-#include <jailhouse/hypercall.h>
-
-#define comm_region    ((struct jailhouse_comm_region *)COMM_REGION_BASE)
-
-extern unsigned int printk_uart_base;
-void printk(const char *fmt, ...);
-
-void *memset(void *s, int c, unsigned long n);
-void *memcpy(void *d, const void *s, unsigned long n);
-
 typedef void(*int_handler_t)(void);
 
 void int_init(void);
 void int_set_handler(unsigned int vector, int_handler_t handler);
+void int_send_ipi(unsigned int cpu_id, unsigned int vector);
 
 enum ioapic_trigger_mode {
        TRIGGER_EDGE = 0,
@@ -216,11 +198,15 @@ void ioapic_pin_set_vector(unsigned int pin,
                           enum ioapic_trigger_mode trigger_mode,
                           unsigned int vector);
 
-void inmate_main(void);
+void hypercall_init(void);
 
-void pm_timer_init(void);
 unsigned long pm_timer_read(void);
+
+unsigned long tsc_read(void);
+unsigned long tsc_init(void);
+
 void delay_us(unsigned long microsecs);
+
 unsigned long apic_timer_init(unsigned int vector);
 void apic_timer_set(unsigned long timeout_ns);
 
@@ -236,4 +222,13 @@ int pci_find_device(u16 vendor, u16 device, u16 start_bdf);
 int pci_find_cap(u16 bdf, u16 cap);
 void pci_msi_set_vector(u16 bdf, unsigned int vector);
 void pci_msix_set_vector(u16 bdf, unsigned int vector, u32 index);
+
+extern volatile u32 smp_num_cpus;
+extern u8 smp_cpu_ids[SMP_MAX_CPUS];
+void smp_wait_for_all_cpus(void);
+void smp_start_cpu(unsigned int cpu_id, void (*entry)(void));
 #endif
+
+#include "../inmate_common.h"
+
+#endif /* !_JAILHOUSE_INMATE_H */