HV: remove DBG_LEVEL_PARSE

- It is meaningless to enable debug function in parse_hv_cmdline() because
the function run in very eary stage and uart has not been initialized at
that time, so remove this debug level definition;

- Rewrite parse_hv_cmdline() function to make it compliant with MISRA-C;

- Decouple uart16550 stuff from Init.c module and let console.c handle it;

Tracked-On: #4419

Signed-off-by: Victor Sun <victor.sun@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
This commit is contained in:
Victor Sun 2020-02-11 21:06:40 +08:00 committed by wenlingz
parent a46a7b3524
commit 708cae7c88
4 changed files with 15 additions and 30 deletions

View File

@ -8,14 +8,11 @@
#include <init.h>
#include <console.h>
#include <per_cpu.h>
#include <profiling.h>
#include <vtd.h>
#include <shell.h>
#include <vmx.h>
#include <vm.h>
#include <logmsg.h>
#include <seed.h>
#include <uart16550.h>
#include <ld_sym.h>
#include <vboot.h>
@ -32,12 +29,6 @@
/*TODO: move into debug module */
static void init_debug_pre(void)
{
/*
* Enable UART as early as possible.
* Then we could use printf for debugging on early boot stage.
*/
uart16550_init(true);
/* Initialize console */
console_init();
@ -88,7 +79,7 @@ void init_primary_pcpu(void)
/* Clear BSS */
(void)memset(&ld_bss_start, 0U, (size_t)(&ld_bss_end - &ld_bss_start));
(void)parse_hv_cmdline();
parse_hv_cmdline();
init_debug_pre();

View File

@ -12,28 +12,18 @@
#include <logmsg.h>
#include <vboot.h>
#define DBG_LEVEL_PARSE 6
int32_t parse_hv_cmdline(void)
void parse_hv_cmdline(void)
{
const char *start;
const char *start = NULL;
const char *end = NULL;
struct multiboot_info *mbi = NULL;
if (boot_regs[0] != MULTIBOOT_INFO_MAGIC) {
return -EINVAL;
}
mbi = (struct multiboot_info *)(hpa2hva_early((uint64_t)boot_regs[1]));
dev_dbg(DBG_LEVEL_PARSE, "Multiboot detected, flag=0x%x", mbi->mi_flags);
if ((mbi->mi_flags & MULTIBOOT_INFO_HAS_CMDLINE) == 0U) {
dev_dbg(DBG_LEVEL_PARSE, "no hv cmdline!");
return -EINVAL;
}
if ((boot_regs[0] == MULTIBOOT_INFO_MAGIC) && (boot_regs[1] != 0U)) {
struct multiboot_info *mbi = (struct multiboot_info *)(hpa2hva_early((uint64_t)boot_regs[1]));
if ((mbi->mi_flags & MULTIBOOT_INFO_HAS_CMDLINE) != 0U) {
start = (char *)hpa2hva_early((uint64_t)mbi->mi_cmdline);
dev_dbg(DBG_LEVEL_PARSE, "hv cmdline: %s", start);
}
}
while ((start != NULL) && ((*start) != '\0')) {
while ((*start) == ' ')
@ -50,5 +40,4 @@ int32_t parse_hv_cmdline(void)
}
}
return 0;
}

View File

@ -26,6 +26,6 @@ uint64_t get_ap_trampoline_buf(void);
void *get_rsdp_ptr(void);
enum vboot_mode get_sos_boot_mode(void);
int32_t parse_hv_cmdline(void);
void parse_hv_cmdline(void);
#endif /* end of include guard: VBOOT_H */

View File

@ -24,6 +24,11 @@ uint16_t console_vmid = ACRN_INVALID_VMID;
void console_init(void)
{
/*
* Enable UART as early as possible.
* Then we could use printf for debugging on early boot stage.
*/
uart16550_init(true);
}
void console_putc(const char *ch)