1 /* 2 * Copyright (C) 2018-2022 Intel Corporation. 3 * 4 * SPDX-License-Identifier: BSD-3-Clause 5 */ 6 7 #ifndef SHELL_PRIV_H 8 #define SHELL_PRIV_H 9 10 #include <asm/lib/spinlock.h> 11 12 #define SHELL_CMD_MAX_LEN 100U 13 #define SHELL_STRING_MAX_LEN (PAGE_SIZE << 2U) 14 15 extern int16_t console_vmid; 16 17 /* Shell Command Function */ 18 typedef int32_t (*shell_cmd_fn_t)(int32_t argc, char **argv); 19 20 /* Shell Command */ 21 struct shell_cmd { 22 char *str; /* Command string */ 23 char *cmd_param; /* Command parameter string */ 24 char *help_str; /* Help text associated with the command */ 25 shell_cmd_fn_t fcn; /* Command call-back function */ 26 27 }; 28 29 #define MAX_BUFFERED_CMDS 8 30 31 /* Shell Control Block */ 32 struct shell { 33 /* a ring buffer to buffer former commands and use one as current active input */ 34 char buffered_line[MAX_BUFFERED_CMDS][SHELL_CMD_MAX_LEN + 1U]; 35 uint32_t input_line_len; /* Length of current input line */ 36 int32_t input_line_active; /* Active input line index */ 37 38 int32_t to_select_index; /* used for up/down key to select former cmds */ 39 uint32_t cursor_offset; /* cursor offset position from left input line */ 40 41 struct shell_cmd *cmds; /* cmds supported */ 42 uint32_t cmd_count; /* Count of cmds supported */ 43 }; 44 45 /* Shell Command list with parameters and help description */ 46 #define SHELL_CMD_HELP "help" 47 #define SHELL_CMD_HELP_PARAM NULL 48 #define SHELL_CMD_HELP_HELP "Display information about supported hypervisor shell commands" 49 50 #define SHELL_CMD_VERSION "version" 51 #define SHELL_CMD_VERSION_PARAM NULL 52 #define SHELL_CMD_VERSION_HELP "Display the HV version information" 53 54 #define SHELL_CMD_VM_LIST "vm_list" 55 #define SHELL_CMD_VM_LIST_PARAM NULL 56 #define SHELL_CMD_VM_LIST_HELP "List all VMs, displaying the VM UUID, ID, name and state" 57 58 #define SHELL_CMD_VCPU_LIST "vcpu_list" 59 #define SHELL_CMD_VCPU_LIST_PARAM NULL 60 #define SHELL_CMD_VCPU_LIST_HELP "List all vCPUs in all VMs" 61 62 #define SHELL_CMD_VCPU_DUMPREG "vcpu_dumpreg" 63 #define SHELL_CMD_VCPU_DUMPREG_PARAM "<vm id, vcpu id>" 64 #define SHELL_CMD_VCPU_DUMPREG_HELP "Dump registers for a specific vCPU" 65 66 #define SHELL_CMD_DUMP_HOST_MEM "dump_host_mem" 67 #define SHELL_CMD_DUMP_HOST_MEM_PARAM "<addr, length>" 68 #define SHELL_CMD_DUMP_HOST_MEM_HELP "Dump host memory, starting at a given address(Hex), and for a given length (Dec in bytes)" 69 70 #define SHELL_CMD_DUMP_GUEST_MEM "dump_guest_mem" 71 #define SHELL_CMD_DUMP_GUEST_MEM_PARAM "<vm_id, addr, length>" 72 #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)" 73 74 #define SHELL_CMD_VM_CONSOLE "vm_console" 75 #define SHELL_CMD_VM_CONSOLE_PARAM "<vm id>" 76 #define SHELL_CMD_VM_CONSOLE_HELP "Switch to the VM's console. Use 'BREAK + e' to return to the ACRN shell "\ 77 "console" 78 79 #define SHELL_CMD_INTERRUPT "int" 80 #define SHELL_CMD_INTERRUPT_PARAM NULL 81 #define SHELL_CMD_INTERRUPT_HELP "List interrupt information per CPU" 82 83 #define SHELL_CMD_PTDEV "pt" 84 #define SHELL_CMD_PTDEV_PARAM NULL 85 #define SHELL_CMD_PTDEV_HELP "Show pass-through device information" 86 87 #define SHELL_CMD_REBOOT "reboot" 88 #define SHELL_CMD_REBOOT_PARAM NULL 89 #define SHELL_CMD_REBOOT_HELP "Trigger a system reboot (immediately)" 90 91 #define SHELL_CMD_IOAPIC "dump_ioapic" 92 #define SHELL_CMD_IOAPIC_PARAM NULL 93 #define SHELL_CMD_IOAPIC_HELP "Show native IOAPIC information" 94 95 #define SHELL_CMD_VIOAPIC "vioapic" 96 #define SHELL_CMD_VIOAPIC_PARAM "<vm id>" 97 #define SHELL_CMD_VIOAPIC_HELP "Show virtual IOAPIC (vIOAPIC) information for a specific VM" 98 99 #define SHELL_CMD_LOG_LVL "loglevel" 100 #define SHELL_CMD_LOG_LVL_PARAM "[<console_loglevel> [<mem_loglevel> [npk_loglevel]]]" 101 #define SHELL_CMD_LOG_LVL_HELP "No argument: get the level of logging for the console, memory and npk. Set "\ 102 "the level by giving (up to) 3 parameters between 0 and 6 (verbose)" 103 104 #define SHELL_CMD_CPUID "cpuid" 105 #define SHELL_CMD_CPUID_PARAM "<leaf> [subleaf]" 106 #define SHELL_CMD_CPUID_HELP "Display the CPUID leaf [subleaf], in hexadecimal" 107 108 #define SHELL_CMD_RDMSR "rdmsr" 109 #define SHELL_CMD_RDMSR_PARAM "[-p<pcpu_id>] <msr_index>" 110 #define SHELL_CMD_RDMSR_HELP "Read the MSR at msr_index (in hexadecimal) for CPU ID pcpu_id" 111 112 #define SHELL_CMD_WRMSR "wrmsr" 113 #define SHELL_CMD_WRMSR_PARAM "[-p<pcpu_id>] <msr_index> <value>" 114 #define SHELL_CMD_WRMSR_HELP "Write value (in hexadecimal) to the MSR at msr_index (in hexadecimal) for CPU"\ 115 " ID pcpu_id" 116 #endif /* SHELL_PRIV_H */ 117