X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?a=blobdiff_plain;f=palacios%2Finclude%2Fpalacios%2Fvmm_lowlevel.h;h=71af1051247b400ae923ac43cc9d9c63c92a165f;hb=e63be432894673d56526c4f1c2cb4fa64daf01d9;hp=b7f46fafe2214800457a2ed94a1ab945d2e39de9;hpb=9b4bfeefac09294a6f0ae12dbadf102eb547f5ec;p=palacios.git diff --git a/palacios/include/palacios/vmm_lowlevel.h b/palacios/include/palacios/vmm_lowlevel.h index b7f46fa..71af105 100644 --- a/palacios/include/palacios/vmm_lowlevel.h +++ b/palacios/include/palacios/vmm_lowlevel.h @@ -20,30 +20,28 @@ #include +#define CPUID_FEATURE_IDS 0x00000001 +#define CPUID_EXT_FEATURE_IDS 0x80000001 + + #ifdef __V3_32BIT__ -void __inline__ v3_cpuid(uint_t target, addr_t * eax, addr_t * ebx, addr_t * ecx, addr_t * edx) { +static void __inline__ v3_cpuid(uint_t target, addr_t * eax, addr_t * ebx, addr_t * ecx, addr_t * edx) { __asm__ __volatile__ ( - "pushl %%ebx\n\t" "cpuid\n\t" - "movl %%ebx, %%esi\n\t" - "popl %%ebx\n\t" : "=a" (*eax), "=S" (*ebx), "=c" (*ecx), "=d" (*edx) - : "a" (target) + : "0" (target), "2" (*ecx) ); return; } #elif __V3_64BIT__ -void __inline__ v3_cpuid(uint_t target, addr_t * eax, addr_t * ebx, addr_t * ecx, addr_t * edx) { +static void __inline__ v3_cpuid(uint_t target, addr_t * eax, addr_t * ebx, addr_t * ecx, addr_t * edx) { __asm__ __volatile__ ( - "pushq %%rbx\n\t" "cpuid\n\t" - "movq %%rbx, %%rsi\n\t" - "popq %%rbx\n\t" - : "=a" (*eax), "=S" (*ebx), "=c" (*ecx), "=d" (*edx) - : "a" (target) + : "=a" (*eax), "=b" (*ebx), "=c" (*ecx), "=d" (*edx) + : "0" (target), "2" (*ecx) ); return; } @@ -51,7 +49,7 @@ void __inline__ v3_cpuid(uint_t target, addr_t * eax, addr_t * ebx, addr_t * ecx #endif -void __inline__ v3_set_msr(uint_t msr, uint_t high_byte, uint_t low_byte) { +static void __inline__ v3_set_msr(uint_t msr, uint_t high_byte, uint_t low_byte) { __asm__ __volatile__ ( "wrmsr" : @@ -63,7 +61,7 @@ void __inline__ v3_set_msr(uint_t msr, uint_t high_byte, uint_t low_byte) { -void __inline__ v3_get_msr(uint_t msr, uint_t * high_byte, uint_t * low_byte) { +static void __inline__ v3_get_msr(uint_t msr, uint_t * high_byte, uint_t * low_byte) { __asm__ __volatile__ ( "rdmsr" : "=d" (*high_byte), "=a" (*low_byte) @@ -73,11 +71,65 @@ void __inline__ v3_get_msr(uint_t msr, uint_t * high_byte, uint_t * low_byte) { -void __inline__ v3_enable_ints() { +static void __inline__ v3_enable_ints() { __asm__ __volatile__ ("sti"); } -void __inline__ v3_disable_ints() { +static void __inline__ v3_disable_ints() { __asm__ __volatile__ ("cli"); } + + + +#ifdef __V3_32BIT__ + +static addr_t __inline__ v3_irq_save() { + addr_t state; + + __asm__ __volatile__ ("pushf \n\t" + "popl %0 \n\t" + "cli \n\t" + :"=g" (state) + : + :"memory" + ); + return state; +} + +static void __inline__ v3_irq_restore(addr_t state) { + __asm__ __volatile__("pushl %0 \n\t" + "popfl \n\t" + : + :"g" (state) + :"memory", "cc" + ); +} + +#elif __V3_64BIT__ + +static addr_t __inline__ v3_irq_save() { + addr_t state; + + __asm__ __volatile__ ("pushfq \n\t" + "popq %0 \n\t" + "cli \n\t" + :"=g" (state) + : + :"memory" + ); + + return state; +} + + +static void __inline__ v3_irq_restore(addr_t state) { + __asm__ __volatile__("pushq %0 \n\t" + "popfq \n\t" + : + :"g" (state) + :"memory", "cc" + ); +} + +#endif