Support cpuid --pae.
This commit is contained in:
parent
daaa89dbe5
commit
ba14476051
3 changed files with 35 additions and 4 deletions
|
@ -1,3 +1,7 @@
|
||||||
|
2013-12-17 Vladimir Serbinenko <phcoder@gmail.com>
|
||||||
|
|
||||||
|
Support cpuid --pae.
|
||||||
|
|
||||||
2013-12-17 Vladimir Serbinenko <phcoder@gmail.com>
|
2013-12-17 Vladimir Serbinenko <phcoder@gmail.com>
|
||||||
|
|
||||||
Use AT keyboard on Yeeloong 3A.
|
Use AT keyboard on Yeeloong 3A.
|
||||||
|
|
|
@ -34,19 +34,38 @@ static const struct grub_arg_option options[] =
|
||||||
/* TRANSLATORS: "(default)" at the end means that this option is used if
|
/* TRANSLATORS: "(default)" at the end means that this option is used if
|
||||||
no argument is specified. */
|
no argument is specified. */
|
||||||
{"long-mode", 'l', 0, N_("Check if CPU supports 64-bit (long) mode (default)."), 0, 0},
|
{"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}
|
{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
|
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)),
|
int argc __attribute__ ((unused)),
|
||||||
char **args __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,
|
/* TRANSLATORS: it's a standalone boolean value,
|
||||||
opposite of "true". */
|
opposite of "true". */
|
||||||
: grub_error (GRUB_ERR_TEST_FAILURE, N_("false"));
|
: grub_error (GRUB_ERR_TEST_FAILURE, N_("false"));
|
||||||
|
@ -59,6 +78,7 @@ GRUB_MOD_INIT(cpuid)
|
||||||
#ifdef __x86_64__
|
#ifdef __x86_64__
|
||||||
/* grub-emu */
|
/* grub-emu */
|
||||||
grub_cpuid_has_longmode = 1;
|
grub_cpuid_has_longmode = 1;
|
||||||
|
grub_cpuid_has_pae = 1;
|
||||||
#else
|
#else
|
||||||
unsigned int eax, ebx, ecx, edx;
|
unsigned int eax, ebx, ecx, edx;
|
||||||
unsigned int max_level;
|
unsigned int max_level;
|
||||||
|
@ -79,6 +99,12 @@ GRUB_MOD_INIT(cpuid)
|
||||||
if (max_level == 0)
|
if (max_level == 0)
|
||||||
goto done;
|
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);
|
grub_cpuid (0x80000000, eax, ebx, ecx, edx);
|
||||||
ext_level = eax;
|
ext_level = eax;
|
||||||
if (ext_level < 0x80000000)
|
if (ext_level < 0x80000000)
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
#define GRUB_CPU_CPUID_HEADER 1
|
#define GRUB_CPU_CPUID_HEADER 1
|
||||||
|
|
||||||
extern unsigned char grub_cpuid_has_longmode;
|
extern unsigned char grub_cpuid_has_longmode;
|
||||||
|
extern unsigned char grub_cpuid_has_pae;
|
||||||
|
|
||||||
#ifdef __x86_64__
|
#ifdef __x86_64__
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue