mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-09-24 02:08:04 +00:00
hv: merge SBL and UEFI related stuff under bsp
This patch unifies the bsp interface between UEFI and SBL. Tracked-On: #2708 Signed-off-by: Tw <wei.tan@intel.com> Acked-by: Eddie Dong <eddie.dong@intel.com>
This commit is contained in:
79
hypervisor/bsp/firmware_wrapper.c
Normal file
79
hypervisor/bsp/firmware_wrapper.c
Normal file
@@ -0,0 +1,79 @@
|
||||
/*
|
||||
* Copyright (C) 2019 Intel Corporation. All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*/
|
||||
|
||||
#include <hypervisor.h>
|
||||
#include <multiboot.h>
|
||||
#include <firmware.h>
|
||||
#include <firmware_sbl.h>
|
||||
#include <firmware_uefi.h>
|
||||
|
||||
static struct firmware_operations *firmware_ops;
|
||||
|
||||
static bool is_firmware_sbl(void)
|
||||
{
|
||||
bool ret = false;
|
||||
struct multiboot_info *mbi = NULL;
|
||||
size_t i;
|
||||
const char *sbl_candidates[] = {
|
||||
"Slim BootLoader",
|
||||
"Intel IOTG/TSD ABL",
|
||||
};
|
||||
|
||||
mbi = (struct multiboot_info *)hpa2hva((uint64_t)boot_regs[1]);
|
||||
if (mbi != NULL) {
|
||||
if ((mbi->mi_flags & MULTIBOOT_INFO_HAS_LOADER_NAME) != 0U) {
|
||||
for (i = 0; i < sizeof(sbl_candidates); i++) {
|
||||
if (strcmp(hpa2hva(mbi->mi_loader_name), sbl_candidates[i]) == 0) {
|
||||
ret = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* @pre: this function is called during detect mode which is very early stage,
|
||||
* other exported interfaces should not be called beforehand.
|
||||
*/
|
||||
void init_firmware_operations(void)
|
||||
{
|
||||
if (is_firmware_sbl()) {
|
||||
firmware_ops = sbl_get_firmware_operations();
|
||||
} else {
|
||||
firmware_ops = uefi_get_firmware_operations();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* @pre: firmware_ops->init != NULL */
|
||||
void init_firmware(void)
|
||||
{
|
||||
#ifndef CONFIG_CONSTANT_ACPI
|
||||
acpi_fixup();
|
||||
#endif
|
||||
firmware_ops->init();
|
||||
}
|
||||
|
||||
/* @pre: firmware_ops->get_ap_trampoline != NULL */
|
||||
uint64_t firmware_get_ap_trampoline(void)
|
||||
{
|
||||
return firmware_ops->get_ap_trampoline();
|
||||
}
|
||||
|
||||
/* @pre: firmware_ops->get_rsdp != NULL */
|
||||
void *firmware_get_rsdp(void)
|
||||
{
|
||||
return firmware_ops->get_rsdp();
|
||||
}
|
||||
|
||||
/* @pre: firmware_ops->init_irq != NULL */
|
||||
void firmware_init_irq(void)
|
||||
{
|
||||
return firmware_ops->init_irq();
|
||||
}
|
Reference in New Issue
Block a user