mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-08-06 10:44:41 +00:00
hv: shell: add cpuid command
Add cpuid shell command for test Signed-off-by: Li, Fei1 <fei1.li@intel.com>
This commit is contained in:
parent
c83bcded99
commit
ace23b5088
@ -1040,6 +1040,34 @@ int shell_set_loglevel(struct shell *p_shell, int argc, char **argv)
|
||||
return status;
|
||||
}
|
||||
|
||||
int shell_cpuid(struct shell *p_shell, int argc, char **argv)
|
||||
{
|
||||
char str[MAX_STR_SIZE] = {0};
|
||||
uint32_t leaf, subleaf = 0;
|
||||
uint32_t eax, ebx, ecx, edx;
|
||||
|
||||
if (argc == 2) {
|
||||
leaf = strtoul(argv[1], NULL, 16);
|
||||
} else if (argc == 3) {
|
||||
leaf = strtoul(argv[1], NULL, 16);
|
||||
subleaf = strtoul(argv[2], NULL, 16);
|
||||
} else {
|
||||
shell_puts(p_shell,
|
||||
"Please enter correct cmd with "
|
||||
"cpuid <leaf> [subleaf]\r\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
cpuid_subleaf(leaf, subleaf, &eax, &ebx, &ecx, &edx);
|
||||
snprintf(str, MAX_STR_SIZE,
|
||||
"cpuid leaf: 0x%x, subleaf: 0x%x, 0x%x:0x%x:0x%x:0x%x\r\n",
|
||||
leaf, subleaf, eax, ebx, ecx, edx);
|
||||
|
||||
shell_puts(p_shell, str);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int shell_terminate_serial(struct shell *p_shell)
|
||||
{
|
||||
/* Shell shouldn't own the serial port handle anymore. */
|
||||
|
@ -149,6 +149,10 @@ struct shell_cmd {
|
||||
#define SHELL_CMD_SET_LOG_LVL_PARAM "<console_loglevel> [mem_loglevel]"
|
||||
#define SHELL_CMD_SET_LOG_LVL_HELP "Set loglevel [0-6]"
|
||||
|
||||
#define SHELL_CMD_CPUID "cpuid"
|
||||
#define SHELL_CMD_CPUID_PARAM "<leaf> [subleaf]"
|
||||
#define SHELL_CMD_CPUID_HELP "cpuid leaf [subleaf], in hexadecimal"
|
||||
|
||||
|
||||
/* Global function prototypes */
|
||||
int shell_show_req_info(struct shell *p_shell, int argc, char **argv);
|
||||
@ -172,6 +176,7 @@ int shell_show_vmexit_profile(struct shell *p_shell, int argc, char **argv);
|
||||
int shell_dump_logbuf(struct shell *p_shell, int argc, char **argv);
|
||||
int shell_get_loglevel(struct shell *p_shell, int argc, char **argv);
|
||||
int shell_set_loglevel(struct shell *p_shell, int argc, char **argv);
|
||||
int shell_cpuid(struct shell *p_shell, int argc, char **argv);
|
||||
struct shell_cmd *shell_find_cmd(struct shell *p_shell, const char *cmd);
|
||||
int shell_process_cmd(struct shell *p_shell, char *p_input_line);
|
||||
int shell_terminate_serial(struct shell *p_shell);
|
||||
|
@ -356,6 +356,17 @@ int shell_init(void)
|
||||
pr_err("Error: Command \"%s\" registration failed.",
|
||||
SHELL_CMD_SET_LOG_LVL);
|
||||
}
|
||||
|
||||
status = shell_register_cmd(serial_session,
|
||||
SHELL_CMD_CPUID,
|
||||
SHELL_CMD_CPUID_PARAM,
|
||||
SHELL_CMD_CPUID_HELP,
|
||||
shell_cpuid);
|
||||
|
||||
if (status != 0) {
|
||||
pr_err("Error: Command \"%s\" registration failed.",
|
||||
SHELL_CMD_CPUID);
|
||||
}
|
||||
}
|
||||
|
||||
return status;
|
||||
|
Loading…
Reference in New Issue
Block a user