]> rtime.felk.cvut.cz Git - jailhouse.git/commitdiff
inmates: Map Comm Region always at 0x100000 for inmates framework
authorJan Kiszka <jan.kiszka@siemens.com>
Wed, 16 Jul 2014 11:46:49 +0000 (13:46 +0200)
committerJan Kiszka <jan.kiszka@siemens.com>
Mon, 21 Jul 2014 06:53:05 +0000 (08:53 +0200)
Standardize mapping and access to the Comm Region within the inmates
framework. Reduces the work to be done for new inmates. We will move it
higher once paging services are available so that larger inmates can be
created.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
inmates/demos/x86/apic-demo.c
inmates/demos/x86/tiny-demo.c
inmates/lib/x86/inmate.h
inmates/lib/x86/pm-timer.c

index b2231a9bc58b67c94ea672517adbb1026df81965..1796204b6eb65df0889eb7fb7a49bae60d5cf210 100644 (file)
@@ -42,9 +42,6 @@ static unsigned long apic_frequency;
 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;
@@ -77,7 +74,7 @@ void irq_handler(void)
 
        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)
@@ -86,7 +83,7 @@ void irq_handler(void)
               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);
 }
 
@@ -101,13 +98,13 @@ static void init_apic(void)
 
        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);
@@ -124,7 +121,7 @@ static void init_apic(void)
        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");
index 985b6e900bb16f429436aefbbacfbdaf53977168..92c9dc2eabf9121928db793b81635a5844ffc834 100644 (file)
@@ -18,9 +18,6 @@
 #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;
@@ -29,10 +26,10 @@ void inmate_main(void)
        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;
index 85e1616655c51692aeb466a9a8d4a533c09f641c..3aa3c2659774bbe4a311129c564733e60ad0315a 100644 (file)
  * 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;
@@ -43,8 +44,6 @@ typedef u64 __u64;
 
 typedef enum { true=1, false=0 } bool;
 
-#include <jailhouse/hypercall.h>
-
 static inline void cpu_relax(void)
 {
        asm volatile("rep; nop" : : : "memory");
@@ -69,6 +68,10 @@ static inline u32 inl(u16 port)
        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, ...);
 
@@ -79,5 +82,5 @@ void irq_handler(void);
 
 void inmate_main(void);
 
-unsigned long read_pm_timer(struct jailhouse_comm_region *comm_region);
+unsigned long read_pm_timer(void);
 #endif
index 3c1c29203c43ce5058a41d30d85fcac8c244468b..22641328bb5ec7480ee4450efb7e9774a48bda52 100644 (file)
@@ -17,7 +17,7 @@
 #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;