shell: split arch special code

Now moved all the guest related (risc-v doesn't support VMs) and x86 specific
commands to x86_shell.c except shell_dump_host_mem.

common for guest.
> -static int32_t shell_list_vm(__unused int32_t argc, __unused char **argv);
> -static int32_t shell_list_vcpu(__unused int32_t argc, __unused char **argv);
> -static int32_t shell_to_vm_console(int32_t argc, char **argv);
  depends on how we map guest memory.
> -static int32_t shell_dump_guest_mem(int32_t argc, char **argv);

common concept but arch special implementation.
> -static int32_t shell_vcpu_dumpreg(int32_t argc, char **argv);
> -static int32_t shell_show_cpu_int(__unused int32_t argc, __unused char **argv);
> -static int32_t shell_show_ptdev_info(__unused int32_t argc, __unused char **argv);
> -static int32_t shell_reboot(int32_t argc, char **argv);

x86 special
> -static int32_t shell_show_vioapic_info(int32_t argc, char **argv);
> -static int32_t shell_show_ioapic_info(__unused int32_t argc, __unused char **argv);
> -static int32_t shell_cpuid(int32_t argc, char **argv);
> -static int32_t shell_rdmsr(int32_t argc, char **argv);
> -static int32_t shell_wrmsr(int32_t argc, char **argv);

common but not added for now.
> -static int32_t shell_dump_host_mem(int32_t argc, char **argv);

Tracked-On: #8805
Signed-off-by: Fei Li <fei1.li@intel.com>
This commit is contained in:
Fei Li
2025-09-25 22:12:35 +08:00
committed by acrnsi-robot
parent b26ef37519
commit 712568f949
13 changed files with 1157 additions and 1030 deletions

View File

@@ -4,6 +4,7 @@
FILE_PATH := $(dir $(MKFL_NAME))
SRCS += $(wildcard $(FILE_PATH)/*.c)
SRCS += $(wildcard $(FILE_PATH)/$(ARCH)/*.c)
OBJS += $(patsubst %.c,$(HV_OBJDIR)/%.o,$(SRCS))
.PHONY: default

View File

@@ -0,0 +1,14 @@
/*
* Copyright (C) 2018-2022 Intel Corporation.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#include <types.h>
#include <asm/irq.h>
struct intr_excp_ctx;
void dump_intr_excp_frame(__unused const struct intr_excp_ctx *ctx) {}
void dump_exception(__unused struct intr_excp_ctx *ctx, __unused uint16_t pcpu_id) {}
void asm_assert(__unused int32_t line, __unused const char *file, __unused const char *txt) {}

View File

@@ -0,0 +1,16 @@
/*
* Copyright (C) 2018-2022 Intel Corporation.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#include <types.h>
#include <acrn_hv_defs.h>
uint16_t npk_loglevel;
void npk_log_setup(__unused struct hv_npk_log_param *param) {}
void npk_log_write(__unused const char *buf, __unused size_t len) {}
bool npk_need_log(__unused uint32_t severity) { return false; }
void npk_log(__unused char *buffer) {}

View File

@@ -0,0 +1,41 @@
/*
* Copyright (C) 2018-2025 Intel Corporation.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#include <types.h>
#include <errno.h>
#include <bits.h>
#include <console.h>
#include <sprintf.h>
#include <logmsg.h>
#include <version.h>
#include <cpu.h>
#include "debug/shell_priv.h"
#define SHELL_RISCV_DEMO_SHELL "riscv_demo_shell"
#define SHELL_RISCV_DEMO_SHELL_PARAM NULL
#define SHELL_RISCV_DEMO_SHELL_HELP "RISC-V shell demo"
static int32_t shell_riscv_demo_shell(__unused int32_t argc, __unused char **argv);
struct shell_cmd arch_shell_cmds[] = {
{
.str = SHELL_RISCV_DEMO_SHELL,
.cmd_param = SHELL_RISCV_DEMO_SHELL_PARAM,
.help_str = SHELL_RISCV_DEMO_SHELL_HELP,
.fcn = shell_riscv_demo_shell,
},
};
uint32_t arch_shell_cmds_sz = ARRAY_SIZE(arch_shell_cmds);
static int32_t shell_riscv_demo_shell(__unused int32_t argc, __unused char **argv)
{
shell_puts("\r\n RISC-V SHELL DEMO\r\n");
return 0;
}

File diff suppressed because it is too large Load Diff

View File

@@ -7,12 +7,19 @@
#ifndef SHELL_PRIV_H
#define SHELL_PRIV_H
#include <board_info.h>
#include <spinlock.h>
#include <asm/page.h>
#define SHELL_CMD_MAX_LEN 100U
#define SHELL_STRING_MAX_LEN (PAGE_SIZE << 2U)
#define TEMP_STR_SIZE 60U
#define MAX_STR_SIZE 256U
#define SHELL_LOG_BUF_SIZE (PAGE_SIZE * MAX_PCPU_NUM / 2U)
extern int16_t console_vmid;
extern char shell_log_buf[SHELL_LOG_BUF_SIZE];
/* Shell Command Function */
typedef int32_t (*shell_cmd_fn_t)(int32_t argc, char **argv);
@@ -39,7 +46,10 @@ struct shell {
uint32_t cursor_offset; /* cursor offset position from left input line */
struct shell_cmd *cmds; /* cmds supported */
uint32_t cmd_count; /* Count of cmds supported */
uint32_t cmd_count; /* Count of cmds supported */
struct shell_cmd *arch_cmds; /* arch cmds supported */
uint32_t arch_cmd_count; /* arch Count of cmds supported */
};
/* Shell Command list with parameters and help description */
@@ -51,66 +61,11 @@ struct shell {
#define SHELL_CMD_VERSION_PARAM NULL
#define SHELL_CMD_VERSION_HELP "Display the HV version information"
#define SHELL_CMD_VM_LIST "vm_list"
#define SHELL_CMD_VM_LIST_PARAM NULL
#define SHELL_CMD_VM_LIST_HELP "List all VMs, displaying the VM UUID, ID, name and state"
#define SHELL_CMD_VCPU_LIST "vcpu_list"
#define SHELL_CMD_VCPU_LIST_PARAM NULL
#define SHELL_CMD_VCPU_LIST_HELP "List all vCPUs in all VMs"
#define SHELL_CMD_VCPU_DUMPREG "vcpu_dumpreg"
#define SHELL_CMD_VCPU_DUMPREG_PARAM "<vm id, vcpu id>"
#define SHELL_CMD_VCPU_DUMPREG_HELP "Dump registers for a specific vCPU"
#define SHELL_CMD_DUMP_HOST_MEM "dump_host_mem"
#define SHELL_CMD_DUMP_HOST_MEM_PARAM "<addr, length>"
#define SHELL_CMD_DUMP_HOST_MEM_HELP "Dump host memory, starting at a given address(Hex), and for a given length (Dec in bytes)"
#define SHELL_CMD_DUMP_GUEST_MEM "dump_guest_mem"
#define SHELL_CMD_DUMP_GUEST_MEM_PARAM "<vm_id, addr, length>"
#define SHELL_CMD_DUMP_GUEST_MEM_HELP "Dump guest memory, vm id(Dec), starting at a given address(Hex), and for a given length (Dec in bytes)"
#define SHELL_CMD_VM_CONSOLE "vm_console"
#define SHELL_CMD_VM_CONSOLE_PARAM "<vm id>"
#define SHELL_CMD_VM_CONSOLE_HELP "Switch to the VM's console. Use 'BREAK + e' to return to the ACRN shell "\
"console"
#define SHELL_CMD_INTERRUPT "int"
#define SHELL_CMD_INTERRUPT_PARAM NULL
#define SHELL_CMD_INTERRUPT_HELP "List interrupt information per CPU"
#define SHELL_CMD_PTDEV "pt"
#define SHELL_CMD_PTDEV_PARAM NULL
#define SHELL_CMD_PTDEV_HELP "Show pass-through device information"
#define SHELL_CMD_REBOOT "reboot"
#define SHELL_CMD_REBOOT_PARAM NULL
#define SHELL_CMD_REBOOT_HELP "Trigger a system reboot (immediately)"
#define SHELL_CMD_IOAPIC "dump_ioapic"
#define SHELL_CMD_IOAPIC_PARAM NULL
#define SHELL_CMD_IOAPIC_HELP "Show native IOAPIC information"
#define SHELL_CMD_VIOAPIC "vioapic"
#define SHELL_CMD_VIOAPIC_PARAM "<vm id>"
#define SHELL_CMD_VIOAPIC_HELP "Show virtual IOAPIC (vIOAPIC) information for a specific VM"
#define SHELL_CMD_LOG_LVL "loglevel"
#define SHELL_CMD_LOG_LVL_PARAM "[<console_loglevel> [<mem_loglevel> [npk_loglevel]]]"
#define SHELL_CMD_LOG_LVL_HELP "No argument: get the level of logging for the console, memory and npk. Set "\
"the level by giving (up to) 3 parameters between 0 and 6 (verbose)"
#define SHELL_CMD_CPUID "cpuid"
#define SHELL_CMD_CPUID_PARAM "<leaf> [subleaf]"
#define SHELL_CMD_CPUID_HELP "Display the CPUID leaf [subleaf], in hexadecimal"
void shell_puts(const char *string_ptr);
#define SHELL_CMD_RDMSR "rdmsr"
#define SHELL_CMD_RDMSR_PARAM "[-p<pcpu_id>] <msr_index>"
#define SHELL_CMD_RDMSR_HELP "Read the MSR at msr_index (in hexadecimal) for CPU ID pcpu_id"
#define SHELL_CMD_WRMSR "wrmsr"
#define SHELL_CMD_WRMSR_PARAM "[-p<pcpu_id>] <msr_index> <value>"
#define SHELL_CMD_WRMSR_HELP "Write value (in hexadecimal) to the MSR at msr_index (in hexadecimal) for CPU"\
" ID pcpu_id"
#endif /* SHELL_PRIV_H */

File diff suppressed because it is too large Load Diff

View File

@@ -7,5 +7,7 @@
#include <types.h>
#include <asm/irq.h>
struct intr_excp_ctx;
void dump_intr_excp_frame(__unused const struct intr_excp_ctx *ctx) {}
void dump_exception(__unused struct intr_excp_ctx *ctx, __unused uint16_t pcpu_id) {}

View File

@@ -7,6 +7,8 @@
#include <types.h>
#include <acrn_hv_defs.h>
uint16_t npk_loglevel;
void npk_log_setup(__unused struct hv_npk_log_param *param) {}
void npk_log_write(__unused const char *buf, __unused size_t len) {}