From ba144760511b9bf7e783e0c2ea442c8266b63b34 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Tue, 17 Dec 2013 23:27:22 +0100 Subject: [PATCH] Support cpuid --pae. --- ChangeLog | 4 ++++ grub-core/commands/i386/cpuid.c | 34 +++++++++++++++++++++++++++++---- include/grub/i386/cpuid.h | 1 + 3 files changed, 35 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index de70dae81..09f9cd946 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2013-12-17 Vladimir Serbinenko + + Support cpuid --pae. + 2013-12-17 Vladimir Serbinenko Use AT keyboard on Yeeloong 3A. diff --git a/grub-core/commands/i386/cpuid.c b/grub-core/commands/i386/cpuid.c index af753590d..42b984154 100644 --- a/grub-core/commands/i386/cpuid.c +++ b/grub-core/commands/i386/cpuid.c @@ -34,19 +34,38 @@ static const struct grub_arg_option options[] = /* TRANSLATORS: "(default)" at the end means that this option is used if no argument is specified. */ {"long-mode", 'l', 0, N_("Check if CPU supports 64-bit (long) mode (default)."), 0, 0}, + {"pae", 'p', 0, N_("Check if CPU supports Physical Address Extension."), 0, 0}, {0, 0, 0, 0, 0, 0} }; -#define bit_LM (1 << 29) +enum + { + MODE_LM = 0, + MODE_PAE = 1 + }; -unsigned char grub_cpuid_has_longmode = 0; +enum + { + bit_PAE = (1 << 6), + }; +enum + { + bit_LM = (1 << 29) + }; + +unsigned char grub_cpuid_has_longmode = 0, grub_cpuid_has_pae = 0; static grub_err_t -grub_cmd_cpuid (grub_extcmd_context_t ctxt __attribute__ ((unused)), +grub_cmd_cpuid (grub_extcmd_context_t ctxt, int argc __attribute__ ((unused)), char **args __attribute__ ((unused))) { - return grub_cpuid_has_longmode ? GRUB_ERR_NONE + int val = 0; + if (ctxt->state[MODE_PAE].set) + val = grub_cpuid_has_pae; + else + val = grub_cpuid_has_longmode; + return val ? GRUB_ERR_NONE /* TRANSLATORS: it's a standalone boolean value, opposite of "true". */ : grub_error (GRUB_ERR_TEST_FAILURE, N_("false")); @@ -59,6 +78,7 @@ GRUB_MOD_INIT(cpuid) #ifdef __x86_64__ /* grub-emu */ grub_cpuid_has_longmode = 1; + grub_cpuid_has_pae = 1; #else unsigned int eax, ebx, ecx, edx; unsigned int max_level; @@ -79,6 +99,12 @@ GRUB_MOD_INIT(cpuid) if (max_level == 0) goto done; + if (max_level >= 1) + { + grub_cpuid (1, eax, ebx, ecx, edx); + grub_cpuid_has_pae = !!(edx & bit_PAE); + } + grub_cpuid (0x80000000, eax, ebx, ecx, edx); ext_level = eax; if (ext_level < 0x80000000) diff --git a/include/grub/i386/cpuid.h b/include/grub/i386/cpuid.h index fc5522bd6..f7ae4b0a4 100644 --- a/include/grub/i386/cpuid.h +++ b/include/grub/i386/cpuid.h @@ -20,6 +20,7 @@ #define GRUB_CPU_CPUID_HEADER 1 extern unsigned char grub_cpuid_has_longmode; +extern unsigned char grub_cpuid_has_pae; #ifdef __x86_64__