]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
Support cpuid --pae.
authorVladimir Serbinenko <phcoder@gmail.com>
Tue, 17 Dec 2013 22:27:22 +0000 (23:27 +0100)
committerVladimir Serbinenko <phcoder@gmail.com>
Tue, 17 Dec 2013 22:40:49 +0000 (23:40 +0100)
ChangeLog
grub-core/commands/i386/cpuid.c
include/grub/i386/cpuid.h

index de70dae810d2b52a17677172a745c853d07ea136..09f9cd9464cdaa8ab0e707e68e1807fc8540dfd5 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2013-12-17  Vladimir Serbinenko  <phcoder@gmail.com>
+
+       Support cpuid --pae.
+
 2013-12-17  Vladimir Serbinenko  <phcoder@gmail.com>
 
        Use AT keyboard on Yeeloong 3A.
index af753590d769062a288edf64c35ceecd5a1238d0..42b98415451abc412f52dcfedd4f66bf3420ce16 100644 (file)
@@ -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
+  };
+
+enum
+  {
+    bit_PAE = (1 << 6),
+  };
+enum
+  {
+    bit_LM = (1 << 29)
+  };
 
-unsigned char grub_cpuid_has_longmode = 0;
+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)
index fc5522bd6c09d5daaa3baafc462f8000ee0cf987..f7ae4b0a46418410619b6226d75050fa682bb4ce 100644 (file)
@@ -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__