x86: Add a cpuid command
It is useful to obtain the results of cpuid queries, so add a command for this. Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
# SPDX-License-Identifier: GPL-2.0+
|
||||
|
||||
obj-$(CONFIG_CMD_CBSYSINFO) += cbsysinfo.o
|
||||
obj-y += mtrr.o
|
||||
obj-y += cpuid.o mtrr.o
|
||||
obj-$(CONFIG_CMD_EXCEPTION) += exception.o
|
||||
obj-$(CONFIG_USE_HOB) += hob.o
|
||||
obj-$(CONFIG_HAVE_FSP) += fsp.o
|
||||
|
||||
37
cmd/x86/cpuid.c
Normal file
37
cmd/x86/cpuid.c
Normal file
@@ -0,0 +1,37 @@
|
||||
// SPDX-License-Identifier: GPL-2.0+
|
||||
/*
|
||||
* The 'cpuid' command provides access to the CPU's cpuid information
|
||||
*
|
||||
* Copyright 2024 Google, LLC
|
||||
* Written by Simon Glass <sjg@chromium.org>
|
||||
*/
|
||||
|
||||
#include <command.h>
|
||||
#include <vsprintf.h>
|
||||
#include <asm/cpu.h>
|
||||
|
||||
static int do_cpuid(struct cmd_tbl *cmdtp, int flag, int argc,
|
||||
char *const argv[])
|
||||
{
|
||||
struct cpuid_result res;
|
||||
ulong op;
|
||||
|
||||
if (argc < 2)
|
||||
return CMD_RET_USAGE;
|
||||
|
||||
op = hextoul(argv[1], NULL);
|
||||
res = cpuid(op);
|
||||
printf("eax %08x\n", res.eax);
|
||||
printf("ebx %08x\n", res.ebx);
|
||||
printf("ecx %08x\n", res.ecx);
|
||||
printf("edx %08x\n", res.edx);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
U_BOOT_LONGHELP(cpuid, "Show CPU Identification information");
|
||||
|
||||
U_BOOT_CMD(
|
||||
cpuid, 2, 1, do_cpuid,
|
||||
"cpuid <op>", cpuid_help_text
|
||||
);
|
||||
Reference in New Issue
Block a user