diff options
| author | Simon Glass <[email protected]> | 2024-08-27 19:44:29 -0600 |
|---|---|---|
| committer | Simon Glass <[email protected]> | 2024-10-18 14:10:21 -0600 |
| commit | c4e582654a94fc085196464ebe409ce7f89739f6 (patch) | |
| tree | c5b4f57fe4c820d1abad1eb2dce1aa840ee835f0 /cmd | |
| parent | 557767f80294054932c7453be0e268ad39643fdc (diff) | |
x86: Add msr command
It is useful to obtain the results of MSR queries as well as to update
MSR registers, so add a command these tasks.
Signed-off-by: Simon Glass <[email protected]>
Diffstat (limited to 'cmd')
| -rw-r--r-- | cmd/x86/Makefile | 2 | ||||
| -rw-r--r-- | cmd/x86/msr.c | 52 |
2 files changed, 53 insertions, 1 deletions
diff --git a/cmd/x86/Makefile b/cmd/x86/Makefile index 1648907ac2d..925215235d3 100644 --- a/cmd/x86/Makefile +++ b/cmd/x86/Makefile @@ -1,7 +1,7 @@ # SPDX-License-Identifier: GPL-2.0+ obj-$(CONFIG_CMD_CBSYSINFO) += cbsysinfo.o -obj-y += cpuid.o mtrr.o +obj-y += cpuid.o msr.o mtrr.o obj-$(CONFIG_CMD_EXCEPTION) += exception.o obj-$(CONFIG_USE_HOB) += hob.o obj-$(CONFIG_HAVE_FSP) += fsp.o diff --git a/cmd/x86/msr.c b/cmd/x86/msr.c new file mode 100644 index 00000000000..3cb70d1f89a --- /dev/null +++ b/cmd/x86/msr.c @@ -0,0 +1,52 @@ +// 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 <[email protected]> + */ + +#include <command.h> +#include <vsprintf.h> +#include <asm/msr.h> + +static int do_read(struct cmd_tbl *cmdtp, int flag, int argc, + char *const argv[]) +{ + struct msr_t msr; + ulong op; + + if (argc < 2) + return CMD_RET_USAGE; + + op = hextoul(argv[1], NULL); + msr = msr_read(op); + printf("%08x %08x\n", msr.hi, msr.lo); + + return 0; +} + +static int do_write(struct cmd_tbl *cmdtp, int flag, int argc, + char *const argv[]) +{ + struct msr_t msr; + ulong op; + + if (argc < 4) + return CMD_RET_USAGE; + + op = hextoul(argv[1], NULL); + msr.hi = hextoul(argv[2], NULL); + msr.lo = hextoul(argv[3], NULL); + msr_write(op, msr); + + return 0; +} + +U_BOOT_LONGHELP(msr, + "read <op> - read a machine-status register (MSR) as <hi 32-bits> <lo 32-bits>\n" + "write <op< <hi> <lo> - write an MSR"); + +U_BOOT_CMD_WITH_SUBCMDS(msr, "Machine Status Registers", msr_help_text, + U_BOOT_CMD_MKENT(read, CONFIG_SYS_MAXARGS, 1, do_read, "", ""), + U_BOOT_CMD_MKENT(write, CONFIG_SYS_MAXARGS, 1, do_write, "", "")); |
