2 * Jailhouse, a Linux-based partitioning hypervisor
4 * Copyright (c) Siemens AG, 2013
7 * Jan Kiszka <jan.kiszka@siemens.com>
9 * This work is licensed under the terms of the GNU GPL, version 2. See
10 * the COPYING file in the top-level directory.
13 #define FSEGMENT_BASE 0x0f0000
14 #define COMM_REGION_BASE 0x100000
16 #define INMATE_CS32 0x8
17 #define INMATE_CS64 0x10
18 #define INMATE_DS32 0x18
20 #define NS_PER_MSEC 1000000UL
21 #define NS_PER_SEC 1000000000UL
23 #define X2APIC_ID 0x802
26 typedef signed char s8;
27 typedef unsigned char u8;
29 typedef signed short s16;
30 typedef unsigned short u16;
32 typedef signed int s32;
33 typedef unsigned int u32;
35 typedef signed long long s64;
36 typedef unsigned long long u64;
50 typedef enum { true=1, false=0 } bool;
52 static inline void cpu_relax(void)
54 asm volatile("rep; nop" : : : "memory");
57 static inline void outb(u8 v, u16 port)
59 asm volatile("outb %0,%1" : : "a" (v), "dN" (port));
62 static inline u8 inb(u16 port)
65 asm volatile("inb %1,%0" : "=a" (v) : "dN" (port));
69 static inline u32 inl(u16 port)
72 asm volatile("inl %1,%0" : "=a" (v) : "dN" (port));
76 static inline u64 read_msr(unsigned int msr)
80 asm volatile("rdmsr" : "=a" (low), "=d" (high) : "c" (msr));
81 return low | ((u64)high << 32);
84 static inline void write_msr(unsigned int msr, u64 val)
88 : "c" (msr), "a" (val), "d" (val >> 32)
92 static inline unsigned int cpu_id(void)
94 return read_msr(X2APIC_ID);
97 #include <jailhouse/hypercall.h>
99 #define comm_region ((struct jailhouse_comm_region *)COMM_REGION_BASE)
101 extern unsigned int printk_uart_base;
102 void printk(const char *fmt, ...);
104 void *memset(void *s, int c, unsigned long n);
106 typedef void(*int_handler_t)(void);
109 void int_set_handler(unsigned int vector, int_handler_t handler);
111 void inmate_main(void);
113 unsigned long pm_timer_read(void);
114 unsigned long apic_timer_init(unsigned int vector);
115 void apic_timer_set(unsigned long timeout_ns);