acrn-hypervisor/hypervisor/boot/cmdline.c
Victor Sun 19ffaa50dc HV: init and sanitize acrn multiboot info
Initialize and sanitize a acrn specific multiboot info struct with current
supported multiboot1 in very early boot stage, which would bring below
benifits:

- don't need to do hpa2hva convention every time when refering boot_regs;

- panic early if failed to sanitize multiboot info, so that don't need to
  check multiboot info pointer/flags and panic in later boot process;

- keep most code unchanged when introduce multiboot2 support in future;

Tracked-On: #4419

Signed-off-by: Victor Sun <victor.sun@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2020-02-26 09:24:16 +08:00

43 lines
922 B
C

/*
* Copyright (C) 2018 Intel Corporation. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#include <types.h>
#include <errno.h>
#include <boot.h>
#include <pgtable.h>
#include <dbg_cmd.h>
#include <logmsg.h>
void parse_hv_cmdline(void)
{
const char *start = NULL;
const char *end = NULL;
if (boot_from_multiboot1()) {
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);
}
}
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;
}
}
}