mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-05-02 21:46:58 +00:00
1. add static for local functions and variables. 2. move vm_sw_loader from vcpu to vm 3. refine uefi.c to follow the code rules. 4. separate uefi.c for vm0 boot and bsp two parts. bsp layer just access native HW related, can't access vm/vcpu, vm0 boot part can access vm / vcpu data structure. Tracked-On: #1842 Signed-off-by: Minggui Cao <minggui.cao@intel.com> Reviewed-by: Jason Chen CJ <jason.cj.chen@intel.com>
81 lines
1.4 KiB
C
81 lines
1.4 KiB
C
/*
|
|
* Copyright (C) 2018 Intel Corporation. All rights reserved.
|
|
*
|
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
*/
|
|
|
|
#include <hypervisor.h>
|
|
#include <multiboot.h>
|
|
#include <boot_context.h>
|
|
#include <vm0_boot.h>
|
|
|
|
#ifdef CONFIG_EFI_STUB
|
|
|
|
static struct efi_context *efi_ctx = NULL;
|
|
static struct lapic_regs uefi_lapic_regs;
|
|
static int32_t efi_initialized;
|
|
|
|
static void efi_init(void)
|
|
{
|
|
struct multiboot_info *mbi = NULL;
|
|
|
|
if (boot_regs[0] != MULTIBOOT_INFO_MAGIC) {
|
|
pr_err("no multiboot info found");
|
|
} else {
|
|
|
|
mbi = (struct multiboot_info *) hpa2hva(((uint64_t)(uint32_t)boot_regs[1]));
|
|
if ((mbi->mi_flags & MULTIBOOT_INFO_HAS_DRIVES) == 0U) {
|
|
pr_err("no multiboot drivers for uefi found");
|
|
} else {
|
|
|
|
efi_ctx = (struct efi_context *)hpa2hva((uint64_t)mbi->mi_drives_addr);
|
|
if (efi_ctx == NULL) {
|
|
pr_err("no uefi context found");
|
|
} else {
|
|
|
|
save_lapic(&uefi_lapic_regs);
|
|
efi_initialized = 1;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
void *get_rsdp_from_uefi(void)
|
|
{
|
|
if (!efi_initialized) {
|
|
efi_init();
|
|
}
|
|
|
|
return hpa2hva((uint64_t)efi_ctx->rsdp);
|
|
}
|
|
|
|
void *get_ap_trampoline_buf(void)
|
|
{
|
|
return efi_ctx->ap_trampoline_buf;
|
|
}
|
|
|
|
const struct efi_context *get_efi_ctx(void)
|
|
{
|
|
return efi_ctx;
|
|
}
|
|
|
|
const struct lapic_regs *get_efi_lapic_regs(void)
|
|
{
|
|
return &uefi_lapic_regs;
|
|
}
|
|
|
|
#endif
|
|
|
|
void init_bsp(void)
|
|
{
|
|
#ifndef CONFIG_CONSTANT_ACPI
|
|
acpi_fixup();
|
|
#endif
|
|
parse_hv_cmdline();
|
|
|
|
#ifdef CONFIG_EFI_STUB
|
|
if (!efi_initialized)
|
|
efi_init();
|
|
#endif
|
|
}
|