acrn-hypervisor/hypervisor/boot/include/boot.h
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

45 lines
985 B
C

/*
* Copyright (C) 2020 Intel Corporation. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#ifndef BOOT_H_
#define BOOT_H_
#include <multiboot.h>
#include <e820.h>
#define MAX_BOOTARGS_SIZE 2048U
#define MAX_MODULE_COUNT 4U
struct acrn_multiboot_info {
uint32_t mi_flags; /* the flags is back-compatible with multiboot1 */
char *mi_cmdline;
char *mi_loader_name;
uint32_t mi_mods_count;
struct multiboot_module mi_mods[MAX_MODULE_COUNT];
uint32_t mi_drives_length;
uint32_t mi_drives_addr;
uint32_t mi_mmap_entries;
struct multiboot_mmap mi_mmap_entry[E820_MAX_ENTRIES];
};
/* boot_regs store the multiboot info magic and address */
extern uint32_t boot_regs[2];
static inline bool boot_from_multiboot1(void)
{
return ((boot_regs[0] == MULTIBOOT_INFO_MAGIC) && (boot_regs[1] != 0U));
}
struct acrn_multiboot_info *get_multiboot_info(void);
int32_t sanitize_multiboot_info(void);
void parse_hv_cmdline(void);
#endif /* BOOT_H_ */