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 X2APIC_ID 0x802
23 typedef signed char s8;
24 typedef unsigned char u8;
26 typedef signed short s16;
27 typedef unsigned short u16;
29 typedef signed int s32;
30 typedef unsigned int u32;
32 typedef signed long long s64;
33 typedef unsigned long long u64;
47 typedef enum { true=1, false=0 } bool;
49 static inline void cpu_relax(void)
51 asm volatile("rep; nop" : : : "memory");
54 static inline void outb(u8 v, u16 port)
56 asm volatile("outb %0,%1" : : "a" (v), "dN" (port));
59 static inline u8 inb(u16 port)
62 asm volatile("inb %1,%0" : "=a" (v) : "dN" (port));
66 static inline u32 inl(u16 port)
69 asm volatile("inl %1,%0" : "=a" (v) : "dN" (port));
73 static inline u64 read_msr(unsigned int msr)
77 asm volatile("rdmsr" : "=a" (low), "=d" (high) : "c" (msr));
78 return low | ((u64)high << 32);
81 static inline void write_msr(unsigned int msr, u64 val)
85 : "c" (msr), "a" (val), "d" (val >> 32)
89 static inline unsigned int cpu_id(void)
91 return read_msr(X2APIC_ID);
94 #include <jailhouse/hypercall.h>
96 #define comm_region ((struct jailhouse_comm_region *)COMM_REGION_BASE)
98 extern unsigned int printk_uart_base;
99 void printk(const char *fmt, ...);
101 void *memset(void *s, int c, unsigned long n);
103 typedef void(*int_handler_t)(void);
106 void int_set_handler(unsigned int vector, int_handler_t handler);
108 void inmate_main(void);
110 unsigned long read_pm_timer(void);