From 9eb210023718c65a1300cb0b768ba478b0a2b211 Mon Sep 17 00:00:00 2001 From: Kevin O'Connor Date: Sun, 29 Jan 2012 13:30:56 -0500 Subject: [PATCH] Detect CPUID instruction before using it. Enable SeaBIOS to work on 386/486 machines that don't have CPUID instruction. Based on patch by Rudolf Marek. Signed-off-by: Rudolf Marek Signed-off-by: Kevin O'Connor --- src/bregs.h | 1 + src/mtrr.c | 6 +++--- src/paravirt.h | 2 ++ src/util.c | 16 ++++++++++++++++ src/util.h | 12 ++++++------ 5 files changed, 28 insertions(+), 9 deletions(-) diff --git a/src/bregs.h b/src/bregs.h index f026fa8..577effc 100644 --- a/src/bregs.h +++ b/src/bregs.h @@ -11,6 +11,7 @@ #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 diff --git a/src/mtrr.c b/src/mtrr.c index 0548043..ec3be4f 100644 --- a/src/mtrr.c +++ b/src/mtrr.c @@ -84,9 +84,9 @@ void mtrr_setup(void) 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