static unsigned long expected_time;
static unsigned long min = -1, max;
-static struct jailhouse_comm_region *comm_region =
- (struct jailhouse_comm_region *)0x100000UL;
-
struct desc_table_reg {
u16 limit;
u64 base;
write_msr(X2APIC_EOI, APIC_EOI_ACK);
- delta = read_pm_timer(comm_region) - expected_time;
+ delta = read_pm_timer() - expected_time;
if (delta < min)
min = delta;
if (delta > max)
delta, min, max);
expected_time += 100 * NS_PER_MSEC;
- write_msr(X2APIC_TMICT, (expected_time - read_pm_timer(comm_region)) *
+ write_msr(X2APIC_TMICT, (expected_time - read_pm_timer()) *
apic_frequency / NS_PER_SEC);
}
write_msr(X2APIC_TDCR, 3);
- start = read_pm_timer(comm_region);
+ start = read_pm_timer();
write_msr(X2APIC_TMICT, 0xffffffff);
- while (read_pm_timer(comm_region) - start < 100 * NS_PER_MSEC)
+ while (read_pm_timer() - start < 100 * NS_PER_MSEC)
cpu_relax();
- end = read_pm_timer(comm_region);
+ end = read_pm_timer();
tmr = read_msr(X2APIC_TMCCT);
apic_frequency = (0xffffffff - tmr) * NS_PER_SEC / (end - start);
write_idtr(&dtr);
write_msr(X2APIC_LVTT, APIC_TIMER_VECTOR);
- expected_time = read_pm_timer(comm_region);
+ expected_time = read_pm_timer();
write_msr(X2APIC_TMICT, 1);
asm volatile("sti");
#define UART_BASE 0x2f8
#endif
-static struct jailhouse_comm_region *comm_region =
- (struct jailhouse_comm_region *)0x100000UL;
-
void inmate_main(void)
{
unsigned long long start, now;
printk_uart_base = UART_BASE;
printk("Hello from this tiny cell!\n");
- start = read_pm_timer(comm_region);
+ start = read_pm_timer();
for (n = 0; n < 10; n++) {
do {
- now = read_pm_timer(comm_region);
+ now = read_pm_timer();
cpu_relax();
} while (now - start < 1000000000ULL);
start += 1000000000ULL;
* the COPYING file in the top-level directory.
*/
-#define FSEGMENT_BASE 0xf0000
+#define FSEGMENT_BASE 0x0f0000
+#define COMM_REGION_BASE 0x100000
-#define INMATE_CS32 0x8
-#define INMATE_CS64 0x10
-#define INMATE_DS32 0x18
+#define INMATE_CS32 0x8
+#define INMATE_CS64 0x10
+#define INMATE_DS32 0x18
#ifndef __ASSEMBLY__
typedef signed char s8;
typedef enum { true=1, false=0 } bool;
-#include <jailhouse/hypercall.h>
-
static inline void cpu_relax(void)
{
asm volatile("rep; nop" : : : "memory");
return v;
}
+#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 inmate_main(void);
-unsigned long read_pm_timer(struct jailhouse_comm_region *comm_region);
+unsigned long read_pm_timer(void);
#endif
#define PM_TIMER_HZ 3579545
#define PM_TIMER_OVERFLOW ((0x1000000 * 1000000000ULL) / PM_TIMER_HZ)
-unsigned long read_pm_timer(struct jailhouse_comm_region *comm_region)
+unsigned long read_pm_timer(void)
{
static unsigned long last, overflows;
unsigned long tmr;