2020-02-20 15:15:03 +08:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2020 Intel Corporation. All rights reserved.
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef BOOT_H_
|
|
|
|
#define BOOT_H_
|
|
|
|
|
|
|
|
#include <multiboot.h>
|
2020-02-17 10:36:08 +08:00
|
|
|
#ifdef CONFIG_MULTIBOOT2
|
|
|
|
#include <multiboot2.h>
|
|
|
|
#endif
|
2020-02-17 09:24:44 +08:00
|
|
|
#include <e820.h>
|
2020-02-19 16:12:55 +08:00
|
|
|
#include <zeropage.h>
|
2020-02-20 15:15:03 +08:00
|
|
|
|
|
|
|
#define MAX_BOOTARGS_SIZE 2048U
|
2020-02-17 09:24:44 +08:00
|
|
|
#define MAX_MODULE_COUNT 4U
|
|
|
|
|
2020-02-19 16:12:55 +08:00
|
|
|
/* extended flags for acrn multiboot info from multiboot2 */
|
|
|
|
#define MULTIBOOT_INFO_HAS_EFI_MMAP 0x00010000U
|
|
|
|
#define MULTIBOOT_INFO_HAS_EFI64 0x00020000U
|
|
|
|
|
2020-02-17 09:24:44 +08:00
|
|
|
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];
|
2020-02-17 10:48:16 +08:00
|
|
|
|
|
|
|
void *mi_acpi_rsdp;
|
2020-02-19 16:12:55 +08:00
|
|
|
struct efi_info mi_efi_info;
|
2020-02-17 09:24:44 +08:00
|
|
|
};
|
2020-02-20 15:15:03 +08:00
|
|
|
|
|
|
|
/* boot_regs store the multiboot info magic and address */
|
|
|
|
extern uint32_t boot_regs[2];
|
|
|
|
|
2020-02-19 16:12:55 +08:00
|
|
|
extern char *efiloader_sig;
|
|
|
|
|
2020-02-17 09:24:44 +08:00
|
|
|
static inline bool boot_from_multiboot1(void)
|
|
|
|
{
|
|
|
|
return ((boot_regs[0] == MULTIBOOT_INFO_MAGIC) && (boot_regs[1] != 0U));
|
|
|
|
}
|
|
|
|
|
2020-02-17 10:36:08 +08:00
|
|
|
#ifdef CONFIG_MULTIBOOT2
|
2020-03-30 13:25:41 +08:00
|
|
|
/*
|
|
|
|
* @post boot_regs[1] stores the address pointer that point to a valid multiboot2 info
|
|
|
|
*/
|
2020-02-17 10:36:08 +08:00
|
|
|
static inline bool boot_from_multiboot2(void)
|
|
|
|
{
|
2020-03-03 02:16:49 +08:00
|
|
|
/*
|
|
|
|
* Multiboot spec states that the Multiboot information structure may be placed
|
|
|
|
* anywhere in memory by the boot loader.
|
|
|
|
*
|
|
|
|
* Seems both SBL and GRUB won't place multiboot1 MBI structure at 0 address,
|
|
|
|
* but GRUB could place Multiboot2 MBI structure at 0 address until commit
|
|
|
|
* 0f3f5b7c13fa9b67 ("multiboot2: Set min address for mbi allocation to 0x1000")
|
|
|
|
* which dates on Dec 26 2019.
|
|
|
|
*/
|
|
|
|
return (boot_regs[0] == MULTIBOOT2_INFO_MAGIC);
|
2020-02-17 10:36:08 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
int32_t multiboot2_to_acrn_mbi(struct acrn_multiboot_info *mbi, void *mb2_info);
|
|
|
|
#endif
|
|
|
|
|
2020-02-17 09:24:44 +08:00
|
|
|
struct acrn_multiboot_info *get_multiboot_info(void);
|
|
|
|
int32_t sanitize_multiboot_info(void);
|
|
|
|
void parse_hv_cmdline(void);
|
|
|
|
|
2020-02-20 15:15:03 +08:00
|
|
|
#endif /* BOOT_H_ */
|