hv: modularization: make parse_hv_cmdline() an internal function.

This way, we void exposing acrn_mbi as a global variable.

Tracked-On: #5661
Signed-off-by: Vijay Dhanraj <vijay.dhanraj@intel.com>
Reviewed-by: Jason Chen CJ <jason.cj.chen@intel.com>
This commit is contained in:
Liang Yi 2021-01-18 06:22:29 +08:00 committed by wenlingz
parent f6aa0a70c5
commit c23e557a18
6 changed files with 33 additions and 49 deletions

View File

@ -240,7 +240,6 @@ endif
HW_C_SRCS += hw/pci.c
HW_C_SRCS += arch/x86/configs/vm_config.c
HW_C_SRCS += boot/acpi_base.c
HW_C_SRCS += boot/cmdline.c
# ACPI parsing component
# This part should be isolated from FuSa Cert
ifeq ($(CONFIG_ACPI_PARSE_ENABLED),y)

View File

@ -88,8 +88,6 @@ void init_primary_pcpu(void)
init_acrn_multiboot_info();
parse_hv_cmdline();
init_debug_pre();
init_pcpu_pre(true);

View File

@ -1,37 +0,0 @@
/*
* Copyright (C) 2018 Intel Corporation. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#include <types.h>
#include <errno.h>
#include <multiboot.h>
#include <pgtable.h>
#include <dbg_cmd.h>
void parse_hv_cmdline(void)
{
const char *start = NULL, *end = NULL;
struct acrn_multiboot_info *mbi = &acrn_mbi;
if ((mbi->mi_flags & MULTIBOOT_INFO_HAS_CMDLINE) != 0U) {
start = mbi->mi_cmdline;
}
while ((start != NULL) && ((*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 */
}
start = end;
}
}
}

View File

@ -76,18 +76,10 @@ struct acrn_multiboot_info {
struct efi_info mi_efi_info;
};
/*
* The extern declaration for acrn_mbi is for cmdline.c use only, other functions should use
* get_multiboot_info() API to access struct acrn_mbi because it has explict @post condition
*/
extern struct acrn_multiboot_info acrn_mbi;
void init_acrn_multiboot_info(void);
struct acrn_multiboot_info *get_multiboot_info(void);
int32_t sanitize_multiboot_info(void);
void parse_hv_cmdline(void);
#endif /* ASSEMBLER */
#endif /* MULTIBOOT_H */

View File

@ -64,7 +64,7 @@ struct multiboot_info {
uint32_t unused_mi_vbe_interface_len;
};
struct acrn_multiboot_info acrn_mbi = { 0U };
static struct acrn_multiboot_info acrn_mbi = { 0U };
static int32_t mbi_status;

View File

@ -14,6 +14,8 @@
#include <acrn_hv_defs.h>
#include <vm.h>
#include <console.h>
#include <multiboot.h>
#include <dbg_cmd.h>
struct hv_timer console_timer;
@ -22,8 +24,38 @@ struct hv_timer console_timer;
#define GUEST_CONSOLE_TO_HV_SWITCH_KEY 0 /* CTRL + SPACE */
uint16_t console_vmid = ACRN_INVALID_VMID;
static void parse_hvdbg_cmdline(void)
{
const char *start = NULL;
const char *end = NULL;
struct acrn_multiboot_info *mbi = get_multiboot_info();
if ((mbi->mi_flags & MULTIBOOT_INFO_HAS_CMDLINE) != 0U) {
start = mbi->mi_cmdline;
}
while ((start != NULL) && ((*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 */
}
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.