Simon Glass | 8af719c | 2024-08-27 19:44:28 -0600 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
| 2 | /* |
| 3 | * The 'cpuid' command provides access to the CPU's cpuid information |
| 4 | * |
| 5 | * Copyright 2024 Google, LLC |
| 6 | * Written by Simon Glass <sjg@chromium.org> |
| 7 | */ |
| 8 | |
| 9 | #include <command.h> |
| 10 | #include <vsprintf.h> |
| 11 | #include <asm/cpu.h> |
| 12 | |
| 13 | static int do_cpuid(struct cmd_tbl *cmdtp, int flag, int argc, |
| 14 | char *const argv[]) |
| 15 | { |
| 16 | struct cpuid_result res; |
| 17 | ulong op; |
| 18 | |
| 19 | if (argc < 2) |
| 20 | return CMD_RET_USAGE; |
| 21 | |
| 22 | op = hextoul(argv[1], NULL); |
| 23 | res = cpuid(op); |
| 24 | printf("eax %08x\n", res.eax); |
| 25 | printf("ebx %08x\n", res.ebx); |
| 26 | printf("ecx %08x\n", res.ecx); |
| 27 | printf("edx %08x\n", res.edx); |
| 28 | |
| 29 | return 0; |
| 30 | } |
| 31 | |
| 32 | U_BOOT_LONGHELP(cpuid, "Show CPU Identification information"); |
| 33 | |
| 34 | U_BOOT_CMD( |
| 35 | cpuid, 2, 1, do_cpuid, |
| 36 | "cpuid <op>", cpuid_help_text |
| 37 | ); |