From 153e83a19ef5fd9517f823272a8b67ae164c2896 Mon Sep 17 00:00:00 2001 From: Liang Yi Date: Mon, 18 Jan 2021 03:28:39 +0800 Subject: [PATCH] hv: modularization: multiboot private header Create multiboot_pri.h and move the relevant declarations into this file. Tracked-On: #5661 Signed-off-by: Vijay Dhanraj Reviewed-by: Jason Chen CJ --- hypervisor/boot/include/boot.h | 26 ------ hypervisor/boot/include/multiboot2.h | 65 ------------- hypervisor/boot/multiboot/multiboot.c | 1 + hypervisor/boot/multiboot/multiboot2.c | 1 + hypervisor/boot/multiboot/multiboot_priv.h | 101 +++++++++++++++++++++ 5 files changed, 103 insertions(+), 91 deletions(-) create mode 100644 hypervisor/boot/multiboot/multiboot_priv.h diff --git a/hypervisor/boot/include/boot.h b/hypervisor/boot/include/boot.h index ee129cf32..4d4a8845a 100644 --- a/hypervisor/boot/include/boot.h +++ b/hypervisor/boot/include/boot.h @@ -52,32 +52,6 @@ extern uint32_t boot_regs[2]; extern char *efiloader_sig; -static inline bool boot_from_multiboot1(void) -{ - return ((boot_regs[0] == MULTIBOOT_INFO_MAGIC) && (boot_regs[1] != 0U)); -} - -#ifdef CONFIG_MULTIBOOT2 -/* - * @post boot_regs[1] stores the address pointer that point to a valid multiboot2 info - */ -static inline bool boot_from_multiboot2(void) -{ - /* - * 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); -} - -int32_t multiboot2_to_acrn_mbi(struct acrn_multiboot_info *mbi, void *mb2_info); -#endif - /* * 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 diff --git a/hypervisor/boot/include/multiboot2.h b/hypervisor/boot/include/multiboot2.h index dbddec1d3..2f163c584 100644 --- a/hypervisor/boot/include/multiboot2.h +++ b/hypervisor/boot/include/multiboot2.h @@ -79,69 +79,4 @@ #define MULTIBOOT2_ARCHITECTURE_I386 0 #define MULTIBOOT2_ARCHITECTURE_MIPS32 4 -#ifndef ASSEMBLER -struct multiboot2_mmap_entry -{ - uint64_t addr; - uint64_t len; - uint32_t type; - uint32_t zero; -}; - -struct multiboot2_tag -{ - uint32_t type; - uint32_t size; -}; - -struct multiboot2_tag_string -{ - uint32_t type; - uint32_t size; - char string[0]; -}; - -struct multiboot2_tag_module -{ - uint32_t type; - uint32_t size; - uint32_t mod_start; - uint32_t mod_end; - char cmdline[0]; -}; - -struct multiboot2_tag_mmap -{ - uint32_t type; - uint32_t size; - uint32_t entry_size; - uint32_t entry_version; - struct multiboot2_mmap_entry entries[0]; -}; - -struct multiboot2_tag_new_acpi -{ - uint32_t type; - uint32_t size; - uint8_t rsdp[0]; -}; - -struct multiboot2_tag_efi64 -{ - uint32_t type; - uint32_t size; - uint64_t pointer; -}; - -struct multiboot2_tag_efi_mmap -{ - uint32_t type; - uint32_t size; - uint32_t descr_size; - uint32_t descr_vers; - uint8_t efi_mmap[0]; -}; - -#endif /* ASSEMBLER */ - #endif /* MULTIBOOT2_H */ diff --git a/hypervisor/boot/multiboot/multiboot.c b/hypervisor/boot/multiboot/multiboot.c index 83bf4cd01..fdf49da22 100644 --- a/hypervisor/boot/multiboot/multiboot.c +++ b/hypervisor/boot/multiboot/multiboot.c @@ -10,6 +10,7 @@ #include #include #include +#include "multiboot_priv.h" struct acrn_multiboot_info acrn_mbi = { 0U }; diff --git a/hypervisor/boot/multiboot/multiboot2.c b/hypervisor/boot/multiboot/multiboot2.c index ba0b691a7..a3b30b3c3 100644 --- a/hypervisor/boot/multiboot/multiboot2.c +++ b/hypervisor/boot/multiboot/multiboot2.c @@ -8,6 +8,7 @@ #include #include #include +#include "multiboot_priv.h" /** * @pre mbi != NULL && mb2_tag_mmap != NULL diff --git a/hypervisor/boot/multiboot/multiboot_priv.h b/hypervisor/boot/multiboot/multiboot_priv.h new file mode 100644 index 000000000..c0d370f9e --- /dev/null +++ b/hypervisor/boot/multiboot/multiboot_priv.h @@ -0,0 +1,101 @@ +/* + * Copyright (C) 2020 Intel Corporation. All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#ifndef MULTIBOOT_PRIV_H +#define MULTIBOOT_PRIV_H + +#ifdef CONFIG_MULTIBOOT2 +#include + +struct multiboot2_mmap_entry +{ + uint64_t addr; + uint64_t len; + uint32_t type; + uint32_t zero; +}; + +struct multiboot2_tag +{ + uint32_t type; + uint32_t size; +}; + +struct multiboot2_tag_string +{ + uint32_t type; + uint32_t size; + char string[0]; +}; + +struct multiboot2_tag_module +{ + uint32_t type; + uint32_t size; + uint32_t mod_start; + uint32_t mod_end; + char cmdline[0]; +}; + +struct multiboot2_tag_mmap +{ + uint32_t type; + uint32_t size; + uint32_t entry_size; + uint32_t entry_version; + struct multiboot2_mmap_entry entries[0]; +}; + +struct multiboot2_tag_new_acpi +{ + uint32_t type; + uint32_t size; + uint8_t rsdp[0]; +}; + +struct multiboot2_tag_efi64 +{ + uint32_t type; + uint32_t size; + uint64_t pointer; +}; + +struct multiboot2_tag_efi_mmap +{ + uint32_t type; + uint32_t size; + uint32_t descr_size; + uint32_t descr_vers; + uint8_t efi_mmap[0]; +}; + +/* + * @post boot_regs[1] stores the address pointer that point to a valid multiboot2 info + */ +static inline bool boot_from_multiboot2(void) +{ + /* + * 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); +} + +int32_t multiboot2_to_acrn_mbi(struct acrn_multiboot_info *mbi, void *mb2_info); +#endif + + +static inline bool boot_from_multiboot1(void) +{ + return ((boot_regs[0] == MULTIBOOT_INFO_MAGIC) && (boot_regs[1] != 0U)); +} + +#endif /* MULTIBOOT_PRIV_H */