#define F_CF (1<<0)
#define F_ZF (1<<6)
#define F_IF (1<<9)
+#define F_ID (1<<21)
// CR0 flags
#define CR0_PG (1<<31) // Paging
int phys_bits = 36;
cpuid(0x80000000u, &eax, &ebx, &ecx, &edx);
if (eax >= 0x80000008) {
- /* Get physical bits from leaf 0x80000008 (if available) */
- cpuid(0x80000008u, &eax, &ebx, &ecx, &edx);
- phys_bits = eax & 0xff;
+ /* Get physical bits from leaf 0x80000008 (if available) */
+ cpuid(0x80000008u, &eax, &ebx, &ecx, &edx);
+ phys_bits = eax & 0xff;
}
u64 phys_mask = ((1ull << phys_bits) - 1);
for (i=0; i<vcnt; i++) {
static inline int kvm_para_available(void)
{
+ if (CONFIG_COREBOOT)
+ return 0;
unsigned int eax, ebx, ecx, edx;
char signature[13];
#include "bregs.h" // struct bregs
#include "config.h" // BUILD_STACK_ADDR
+void
+cpuid(u32 index, u32 *eax, u32 *ebx, u32 *ecx, u32 *edx)
+{
+ // Check for cpu id
+ u32 origflags = save_flags();
+ restore_flags(origflags ^ F_ID);
+ u32 newflags = save_flags();
+ restore_flags(origflags);
+
+ if (((origflags ^ newflags) & F_ID) != F_ID)
+ // no cpuid
+ *eax = *ebx = *ecx = *edx = 0;
+ else
+ __cpuid(index, eax, ebx, ecx, edx);
+}
+
/****************************************************************
* 16bit calls
asm volatile("sti": : :"memory");
}
-static inline unsigned long irq_save(void)
+static inline u32 save_flags(void)
{
- unsigned long flags;
- asm volatile("pushfl ; popl %0" : "=g" (flags): :"memory");
- irq_disable();
+ u32 flags;
+ asm volatile("pushfl ; popl %0" : "=rm" (flags));
return flags;
}
-static inline void irq_restore(unsigned long flags)
+static inline void restore_flags(u32 flags)
{
asm volatile("pushl %0 ; popfl" : : "g" (flags) : "memory", "cc");
}
#define CPUID_MSR (1 << 5)
#define CPUID_APIC (1 << 9)
#define CPUID_MTRR (1 << 12)
-static inline void cpuid(u32 index, u32 *eax, u32 *ebx, u32 *ecx, u32 *edx)
+static inline void __cpuid(u32 index, u32 *eax, u32 *ebx, u32 *ecx, u32 *edx)
{
asm("cpuid"
: "=a" (*eax), "=b" (*ebx), "=c" (*ecx), "=d" (*edx)
} PACKED;
// util.c
+void cpuid(u32 index, u32 *eax, u32 *ebx, u32 *ecx, u32 *edx);
struct bregs;
inline void call16(struct bregs *callregs);
inline void call16big(struct bregs *callregs);