diff --git a/hypervisor/arch/x86/cpu.c b/hypervisor/arch/x86/cpu.c index 042cc6196..ca92a5b7a 100644 --- a/hypervisor/arch/x86/cpu.c +++ b/hypervisor/arch/x86/cpu.c @@ -40,6 +40,7 @@ #include #include #include +#include static uint16_t phys_cpu_num = 0U; static uint64_t pcpu_sync = 0UL; @@ -51,6 +52,9 @@ static void print_hv_banner(void); static uint16_t get_pcpu_id_from_lapic_id(uint32_t lapic_id); static uint64_t start_tick __attribute__((__section__(".bss_noinit"))); +/* if use INIT to kick pcpu only, if not notification IPI still is used for sharing CPU */ +static bool use_init_ipi = false; + /** * This function will be called by function get_pcpu_nums() * in common/cpu.c @@ -588,3 +592,38 @@ uint64_t msr_read_pcpu(uint32_t msr_index, uint16_t pcpu_id) return ret; } + +bool is_using_init_ipi(void) +{ + return use_init_ipi; +} + +void arch_parse_hvdbg_cmdline(void) +{ + const char *start = NULL; + const char *end = NULL; + struct acrn_boot_info *abi = get_acrn_boot_info(); + + start = abi->cmdline; + + while ((*start) != '\0') { + while ((*start) == ' ') { + start++; + } + if ((*start) != '\0') { + end = start + 1; + while ((*end != ' ') && ((*end) != '\0')) { + end++; + } + + if (!handle_dbg_cmd(start, (int32_t)(end - start))) { + /* if not handled by handle_dbg_cmd, it can be handled further */ + if (strncmp(start, "USE_INIT_IPI", (size_t)(end - start)) == 0) { + use_init_ipi = true; + } + } + start = end; + } + } + +} diff --git a/hypervisor/arch/x86/init.c b/hypervisor/arch/x86/init.c index c33f00cc2..cc3ca9ea7 100644 --- a/hypervisor/arch/x86/init.c +++ b/hypervisor/arch/x86/init.c @@ -34,6 +34,9 @@ extern uint32_t boot_regs[2]; /*TODO: move into debug module */ static void init_debug_pre(void) { + /*Parse cmdline to get UART setting*/ + arch_parse_hvdbg_cmdline(); + /* Initialize console */ console_init(); } diff --git a/hypervisor/debug/console.c b/hypervisor/debug/console.c index 50ffbaa10..5c1f4d933 100644 --- a/hypervisor/debug/console.c +++ b/hypervisor/debug/console.c @@ -27,50 +27,11 @@ struct hv_timer console_timer; #define GUEST_CONSOLE_TO_HV_SWITCH_KEY 'e' /* escape + e to switch back to hv console */ uint16_t console_vmid = CONFIG_CONSOLE_DEFAULT_VM; -/* if use INIT to kick pcpu only, if not notification IPI still is used for sharing CPU */ -static bool use_init_ipi = false; - uint16_t console_loglevel = CONFIG_CONSOLE_LOGLEVEL_DEFAULT; static spinlock_t console_log_lock; -bool is_using_init_ipi(void) -{ - return use_init_ipi; -} - -static void parse_hvdbg_cmdline(void) -{ - const char *start = NULL; - const char *end = NULL; - struct acrn_boot_info *abi = get_acrn_boot_info(); - - start = abi->cmdline; - - while ((*start) != '\0') { - while ((*start) == ' ') - start++; - if ((*start) != '\0') { - end = start + 1; - while ((*end != ' ') && ((*end) != '\0')) - end++; - - if (!handle_dbg_cmd(start, (int32_t)(end - start))) { - /* if not handled by handle_dbg_cmd, it can be handled further */ - if (strncmp(start, "USE_INIT_IPI", (size_t)(end - start)) == 0) { - use_init_ipi = true; - } - } - start = end; - } - } - -} - void console_init(void) { - /*Parse cmdline to get UART setting*/ - parse_hvdbg_cmdline(); - /* * Enable UART as early as possible. * Then we could use printf for debugging on early boot stage. diff --git a/hypervisor/include/arch/x86/asm/cpu.h b/hypervisor/include/arch/x86/asm/cpu.h index 70eeeb816..c3946a49a 100644 --- a/hypervisor/include/arch/x86/asm/cpu.h +++ b/hypervisor/include/arch/x86/asm/cpu.h @@ -459,6 +459,9 @@ void wait_pcpus_offline(uint64_t mask); void stop_pcpus(void); void wait_sync_change(volatile const uint64_t *sync, uint64_t wake_sync); +bool is_using_init_ipi(void); +void arch_parse_hvdbg_cmdline(void); + #define CPU_SEG_READ(seg, result_ptr) \ { \ asm volatile ("mov %%" STRINGIFY(seg) ", %0": "=r" (*(result_ptr))); \ diff --git a/hypervisor/include/debug/console.h b/hypervisor/include/debug/console.h index cf2dd8d46..8c4a78c85 100644 --- a/hypervisor/include/debug/console.h +++ b/hypervisor/include/debug/console.h @@ -41,7 +41,6 @@ void console_vmexit_callback(struct acrn_vcpu *vcpu); void suspend_console(void); void resume_console(void); struct acrn_vuart *vm_console_vuart(struct acrn_vm *vm); -bool is_using_init_ipi(void); bool console_need_log(uint32_t severity); void console_log(char *buffer); diff --git a/hypervisor/release/console.c b/hypervisor/release/console.c index 7da519896..a38416859 100644 --- a/hypervisor/release/console.c +++ b/hypervisor/release/console.c @@ -29,8 +29,6 @@ void resume_console(void) {} bool handle_dbg_cmd(__unused const char *cmd, __unused int32_t len) { return false; } void console_vmexit_callback(__unused struct acrn_vcpu *vcpu) {} -bool is_using_init_ipi(void) { return false; } - void shell_init(void) {} void shell_kick(void) {}