X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?a=blobdiff_plain;f=palacios%2Finclude%2Fpalacios%2Fvmm_lowlevel.h;h=f3c8db524babbc498b3e4dde09d43d32f4da5fc6;hb=ed2b3c62f54f46c31ed18a100bb442e1656a3ddd;hp=4719cce1e77caebe2754b4dcdf42996beec92187;hpb=773e6e7d212b3ece194cd0e75a383db7d2b9a2b1;p=palacios.git diff --git a/palacios/include/palacios/vmm_lowlevel.h b/palacios/include/palacios/vmm_lowlevel.h index 4719cce..f3c8db5 100644 --- a/palacios/include/palacios/vmm_lowlevel.h +++ b/palacios/include/palacios/vmm_lowlevel.h @@ -20,51 +20,104 @@ #include -#ifdef __V3_32BIT__ +#define CPUID_FEATURE_IDS 0x00000001 +#define CPUID_EXT_FEATURE_IDS 0x80000001 + + -void __inline__ v3_cpuid(uint_t target, uint_t * eax, uint_t * ebx, uint_t * ecx, uint_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) - ); - return; +static void __inline__ v3_cpuid(uint32_t target, + uint32_t * eax, uint32_t * ebx, + uint32_t * ecx, uint32_t * edx) { + __asm__ __volatile__ ( + "cpuid\n\t" + : "=a" (*eax), "=b" (*ebx), "=c" (*ecx), "=d" (*edx) + : "0" (target), "2" (*ecx) + ); + return; } +static void __inline__ v3_set_msr(uint_t msr, uint_t high_byte, uint_t low_byte) { + __asm__ __volatile__ ( + "wrmsr" + : + : "c" (msr), "d" (high_byte), "a" (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) + : "c" (msr) + ); +} -void __inline__ v3_set_msr(uint_t msr, uint_t high_byte, uint_t low_byte) { - __asm__ __volatile__ ( - "wrmsr" - : - : "c" (msr), "d" (high_byte), "a" (low_byte) - ); +static void __inline__ v3_enable_ints() { + __asm__ __volatile__ ("sti"); +} +static void __inline__ v3_disable_ints() { + __asm__ __volatile__ ("cli"); } -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) - : "c" (msr) - ); + +#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; -void __inline__ v3_enable_ints() { - __asm__ __volatile__ ("sti"); + __asm__ __volatile__ ("pushfq \n\t" + "popq %0 \n\t" + "cli \n\t" + :"=g" (state) + : + :"memory" + ); + + return state; } -void __inline__ v3_disable_ints() { - __asm__ __volatile__ ("cli"); + +static void __inline__ v3_irq_restore(addr_t state) { + __asm__ __volatile__("pushq %0 \n\t" + "popfq \n\t" + : + :"g" (state) + :"memory", "cc" + ); } #endif