mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-06-20 04:33:55 +00:00
rename function & definition from firmware to guest boot
The interface struct & API changes like below: struct uefi_context->struct depri_boot_context init_firmware_operations()->init_vboot_operations() init_firmware()->init_vboot() firmware_init_irq()->init_vboot_irq() firmware_get_rsdp()->get_rsdp_ptr() firmware_get_ap_trampoline()->get_ap_trampoline_buf() firmware_init_vm_boot_info()->init_vm_boot_info() Tracked-On: #1842 Signed-off-by: Jason Chen CJ <jason.cj.chen@intel.com> Acked-by: Eddie Dong <eddie.dong@intel.com>
This commit is contained in:
parent
20f97f7559
commit
41ac9e5d10
@ -88,7 +88,7 @@ enable_disable_all_ap(BOOLEAN enable)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static inline void hv_jump(EFI_PHYSICAL_ADDRESS hv_start,
|
static inline void hv_jump(EFI_PHYSICAL_ADDRESS hv_start,
|
||||||
struct multiboot_info *mbi, struct uefi_context *efi_ctx)
|
struct multiboot_info *mbi, struct depri_boot_context *efi_ctx)
|
||||||
{
|
{
|
||||||
hv_func hf;
|
hv_func hf;
|
||||||
|
|
||||||
@ -243,7 +243,7 @@ switch_to_guest_mode(EFI_HANDLE image, EFI_PHYSICAL_ADDRESS hv_hpa)
|
|||||||
EFI_STATUS err;
|
EFI_STATUS err;
|
||||||
struct multiboot_mmap *mmap;
|
struct multiboot_mmap *mmap;
|
||||||
struct multiboot_info *mbi;
|
struct multiboot_info *mbi;
|
||||||
struct uefi_context *efi_ctx;
|
struct depri_boot_context *efi_ctx;
|
||||||
struct acpi_table_rsdp *rsdp = NULL;
|
struct acpi_table_rsdp *rsdp = NULL;
|
||||||
int32_t i;
|
int32_t i;
|
||||||
EFI_CONFIGURATION_TABLE *config_table;
|
EFI_CONFIGURATION_TABLE *config_table;
|
||||||
|
@ -78,7 +78,7 @@ typedef void(*hv_func)(int32_t, struct multiboot_info*);
|
|||||||
#define MBOOT_MMAP_NUMS 256
|
#define MBOOT_MMAP_NUMS 256
|
||||||
#define MBOOT_MMAP_SIZE (sizeof(struct multiboot_mmap) * MBOOT_MMAP_NUMS)
|
#define MBOOT_MMAP_SIZE (sizeof(struct multiboot_mmap) * MBOOT_MMAP_NUMS)
|
||||||
#define MBOOT_INFO_SIZE (sizeof(struct multiboot_info))
|
#define MBOOT_INFO_SIZE (sizeof(struct multiboot_info))
|
||||||
#define BOOT_CTX_SIZE (sizeof(struct uefi_context))
|
#define BOOT_CTX_SIZE (sizeof(struct depri_boot_context))
|
||||||
#define BOOT_LOADER_NAME_SIZE 17U
|
#define BOOT_LOADER_NAME_SIZE 17U
|
||||||
#define EFI_BOOT_MEM_SIZE \
|
#define EFI_BOOT_MEM_SIZE \
|
||||||
(MBOOT_MMAP_SIZE + MBOOT_INFO_SIZE + BOOT_CTX_SIZE + BOOT_LOADER_NAME_SIZE)
|
(MBOOT_MMAP_SIZE + MBOOT_INFO_SIZE + BOOT_CTX_SIZE + BOOT_LOADER_NAME_SIZE)
|
||||||
@ -87,7 +87,7 @@ typedef void(*hv_func)(int32_t, struct multiboot_info*);
|
|||||||
#define MBOOT_INFO_PTR(addr) \
|
#define MBOOT_INFO_PTR(addr) \
|
||||||
((struct multiboot_info *)((VOID *)(addr) + MBOOT_MMAP_SIZE))
|
((struct multiboot_info *)((VOID *)(addr) + MBOOT_MMAP_SIZE))
|
||||||
#define BOOT_CTX_PTR(addr) \
|
#define BOOT_CTX_PTR(addr) \
|
||||||
((struct uefi_context *)((VOID *)(addr) + MBOOT_MMAP_SIZE + MBOOT_INFO_SIZE))
|
((struct depri_boot_context *)((VOID *)(addr) + MBOOT_MMAP_SIZE + MBOOT_INFO_SIZE))
|
||||||
#define BOOT_LOADER_NAME_PTR(addr) \
|
#define BOOT_LOADER_NAME_PTR(addr) \
|
||||||
((char *)((VOID *)(addr) + MBOOT_MMAP_SIZE + MBOOT_INFO_SIZE + BOOT_CTX_SIZE))
|
((char *)((VOID *)(addr) + MBOOT_MMAP_SIZE + MBOOT_INFO_SIZE + BOOT_CTX_SIZE))
|
||||||
|
|
||||||
|
@ -116,7 +116,7 @@ void init_pcpu_pre(uint16_t pcpu_id_args)
|
|||||||
*/
|
*/
|
||||||
init_pcpu_capabilities();
|
init_pcpu_capabilities();
|
||||||
|
|
||||||
init_firmware_operations();
|
init_vboot_operations();
|
||||||
|
|
||||||
init_pcpu_model_name();
|
init_pcpu_model_name();
|
||||||
|
|
||||||
|
@ -363,7 +363,7 @@ int32_t create_vm(uint16_t vm_id, struct acrn_vm_config *vm_config, struct acrn_
|
|||||||
create_sos_vm_e820(vm);
|
create_sos_vm_e820(vm);
|
||||||
prepare_sos_vm_memmap(vm);
|
prepare_sos_vm_memmap(vm);
|
||||||
|
|
||||||
status = firmware_init_vm_boot_info(vm);
|
status = init_vm_boot_info(vm);
|
||||||
if (status != 0) {
|
if (status != 0) {
|
||||||
need_cleanup = true;
|
need_cleanup = true;
|
||||||
}
|
}
|
||||||
@ -388,7 +388,7 @@ int32_t create_vm(uint16_t vm_id, struct acrn_vm_config *vm_config, struct acrn_
|
|||||||
if (vm_config->load_order == PRE_LAUNCHED_VM) {
|
if (vm_config->load_order == PRE_LAUNCHED_VM) {
|
||||||
create_prelaunched_vm_e820(vm);
|
create_prelaunched_vm_e820(vm);
|
||||||
prepare_prelaunched_vm_memmap(vm, vm_config);
|
prepare_prelaunched_vm_memmap(vm, vm_config);
|
||||||
(void)firmware_init_vm_boot_info(vm);
|
(void)init_vm_boot_info(vm);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -64,8 +64,8 @@ static void enter_guest_mode(uint16_t pcpu_id)
|
|||||||
|
|
||||||
static void init_primary_pcpu_post(void)
|
static void init_primary_pcpu_post(void)
|
||||||
{
|
{
|
||||||
/* Perform any necessary firmware initialization */
|
/* Perform any necessary guest vboot initialization */
|
||||||
init_firmware();
|
init_vboot();
|
||||||
|
|
||||||
init_debug_pre();
|
init_debug_pre();
|
||||||
|
|
||||||
|
@ -458,5 +458,5 @@ void init_interrupt(uint16_t pcpu_id)
|
|||||||
init_lapic(pcpu_id);
|
init_lapic(pcpu_id);
|
||||||
init_default_irqs(pcpu_id);
|
init_default_irqs(pcpu_id);
|
||||||
|
|
||||||
firmware_init_irq();
|
init_vboot_irq();
|
||||||
}
|
}
|
||||||
|
@ -110,7 +110,7 @@ uint64_t prepare_trampoline(void)
|
|||||||
uint64_t size, dest_pa, i;
|
uint64_t size, dest_pa, i;
|
||||||
|
|
||||||
size = (uint64_t)(&ld_trampoline_end - &ld_trampoline_start);
|
size = (uint64_t)(&ld_trampoline_end - &ld_trampoline_start);
|
||||||
dest_pa = firmware_get_ap_trampoline();
|
dest_pa = get_ap_trampoline_buf();
|
||||||
|
|
||||||
pr_dbg("trampoline code: %llx size %x", dest_pa, size);
|
pr_dbg("trampoline code: %llx size %x", dest_pa, size);
|
||||||
|
|
||||||
|
@ -152,7 +152,7 @@ static struct acpi_table_rsdp *get_rsdp(void)
|
|||||||
struct acpi_table_rsdp *rsdp = NULL;
|
struct acpi_table_rsdp *rsdp = NULL;
|
||||||
uint16_t *addr;
|
uint16_t *addr;
|
||||||
|
|
||||||
rsdp = (struct acpi_table_rsdp *)firmware_get_rsdp();
|
rsdp = (struct acpi_table_rsdp *)get_rsdp_ptr();
|
||||||
if (rsdp == NULL) {
|
if (rsdp == NULL) {
|
||||||
/* EBDA is addressed by the 16 bit pointer at 0x40E */
|
/* EBDA is addressed by the 16 bit pointer at 0x40E */
|
||||||
addr = (uint16_t *)hpa2hva(0x40eUL);
|
addr = (uint16_t *)hpa2hva(0x40eUL);
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
* SPDX-License-Identifier: BSD-3-Clause
|
* SPDX-License-Identifier: BSD-3-Clause
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* this is for UEFI platform */
|
/* this is for de-privilege guest vboot method */
|
||||||
|
|
||||||
#include <types.h>
|
#include <types.h>
|
||||||
#include <acrn_common.h>
|
#include <acrn_common.h>
|
||||||
@ -17,52 +17,53 @@
|
|||||||
#include <multiboot.h>
|
#include <multiboot.h>
|
||||||
#include <deprivilege_boot.h>
|
#include <deprivilege_boot.h>
|
||||||
|
|
||||||
static struct uefi_context uefi_ctx;
|
static struct depri_boot_context depri_boot_ctx;
|
||||||
static struct lapic_regs uefi_lapic_regs;
|
static struct lapic_regs depri_boot_lapic_regs;
|
||||||
|
|
||||||
static void uefi_init(void)
|
static void init_depri_boot(void)
|
||||||
{
|
{
|
||||||
static bool uefi_initialized = false;
|
static bool depri_initialized = false;
|
||||||
struct multiboot_info *mbi = NULL;
|
struct multiboot_info *mbi = NULL;
|
||||||
|
|
||||||
if (!uefi_initialized) {
|
if (!depri_initialized) {
|
||||||
parse_hv_cmdline();
|
parse_hv_cmdline();
|
||||||
|
|
||||||
mbi = (struct multiboot_info *) hpa2hva(((uint64_t)(uint32_t)boot_regs[1]));
|
mbi = (struct multiboot_info *) hpa2hva(((uint64_t)(uint32_t)boot_regs[1]));
|
||||||
if ((mbi->mi_flags & MULTIBOOT_INFO_HAS_DRIVES) == 0U) {
|
if ((mbi->mi_flags & MULTIBOOT_INFO_HAS_DRIVES) == 0U) {
|
||||||
pr_err("no multiboot drivers for uefi found");
|
pr_err("no multiboot drivers for depri_boot found");
|
||||||
} else {
|
} else {
|
||||||
memcpy_s(&uefi_ctx, sizeof(struct uefi_context), hpa2hva((uint64_t)mbi->mi_drives_addr),
|
memcpy_s(&depri_boot_ctx, sizeof(struct depri_boot_context),
|
||||||
sizeof(struct uefi_context));
|
hpa2hva((uint64_t)mbi->mi_drives_addr),
|
||||||
save_lapic(&uefi_lapic_regs);
|
sizeof(struct depri_boot_context));
|
||||||
|
save_lapic(&depri_boot_lapic_regs);
|
||||||
}
|
}
|
||||||
uefi_initialized = true;
|
depri_initialized = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const struct uefi_context *get_uefi_ctx(void)
|
const struct depri_boot_context *get_depri_boot_ctx(void)
|
||||||
{
|
{
|
||||||
uefi_init();
|
init_depri_boot();
|
||||||
return &uefi_ctx;
|
return &depri_boot_ctx;
|
||||||
}
|
}
|
||||||
|
|
||||||
const struct lapic_regs *get_uefi_lapic_regs(void)
|
const struct lapic_regs *get_depri_boot_lapic_regs(void)
|
||||||
{
|
{
|
||||||
uefi_init();
|
init_depri_boot();
|
||||||
return &uefi_lapic_regs;
|
return &depri_boot_lapic_regs;
|
||||||
}
|
}
|
||||||
|
|
||||||
static uint64_t uefi_get_ap_trampoline(void)
|
static uint64_t get_depri_boot_ap_trampoline(void)
|
||||||
{
|
{
|
||||||
return (uint64_t)(uefi_ctx.ap_trampoline_buf);
|
return (uint64_t)(depri_boot_ctx.ap_trampoline_buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void* uefi_get_rsdp(void)
|
static void* get_depri_boot_rsdp(void)
|
||||||
{
|
{
|
||||||
return hpa2hva((uint64_t)(uefi_ctx.rsdp));
|
return hpa2hva((uint64_t)(depri_boot_ctx.rsdp));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void uefi_spurious_handler(int32_t vector)
|
static void depri_boot_spurious_handler(int32_t vector)
|
||||||
{
|
{
|
||||||
if (get_pcpu_id() == BOOT_CPU_ID) {
|
if (get_pcpu_id() == BOOT_CPU_ID) {
|
||||||
struct acrn_vcpu *vcpu = per_cpu(vcpu, BOOT_CPU_ID);
|
struct acrn_vcpu *vcpu = per_cpu(vcpu, BOOT_CPU_ID);
|
||||||
@ -75,21 +76,21 @@ static void uefi_spurious_handler(int32_t vector)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void uefi_init_irq(void)
|
static void init_depri_boot_irq(void)
|
||||||
{
|
{
|
||||||
spurious_handler = (spurious_handler_t)uefi_spurious_handler;
|
spurious_handler = (spurious_handler_t)depri_boot_spurious_handler;
|
||||||
/* we defer irq enabling till vlapic is ready */
|
/* we defer irq enabling till vlapic is ready */
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct firmware_operations firmware_uefi_ops = {
|
static struct vboot_operations depri_boot_ops = {
|
||||||
.init = uefi_init,
|
.init = init_depri_boot,
|
||||||
.get_ap_trampoline = uefi_get_ap_trampoline,
|
.get_ap_trampoline = get_depri_boot_ap_trampoline,
|
||||||
.get_rsdp = uefi_get_rsdp,
|
.get_rsdp = get_depri_boot_rsdp,
|
||||||
.init_irq = uefi_init_irq,
|
.init_irq = init_depri_boot_irq,
|
||||||
.init_vm_boot_info = uefi_init_vm_boot_info,
|
.init_vboot_info = init_depri_vboot_info,
|
||||||
};
|
};
|
||||||
|
|
||||||
struct firmware_operations* uefi_get_firmware_operations(void)
|
struct vboot_operations* get_deprivilege_boot_ops(void)
|
||||||
{
|
{
|
||||||
return &firmware_uefi_ops;
|
return &depri_boot_ops;
|
||||||
}
|
}
|
||||||
|
@ -11,29 +11,29 @@
|
|||||||
#include <boot_context.h>
|
#include <boot_context.h>
|
||||||
#include <deprivilege_boot.h>
|
#include <deprivilege_boot.h>
|
||||||
|
|
||||||
static int32_t uefi_sw_loader(struct acrn_vm *vm)
|
static int32_t depri_boot_sw_loader(struct acrn_vm *vm)
|
||||||
{
|
{
|
||||||
int32_t ret = 0;
|
int32_t ret = 0;
|
||||||
/* get primary vcpu */
|
/* get primary vcpu */
|
||||||
struct acrn_vcpu *vcpu = vcpu_from_vid(vm, BOOT_CPU_ID);
|
struct acrn_vcpu *vcpu = vcpu_from_vid(vm, BOOT_CPU_ID);
|
||||||
struct acrn_vcpu_regs *vcpu_regs = &boot_context;
|
struct acrn_vcpu_regs *vcpu_regs = &boot_context;
|
||||||
const struct uefi_context *uefi_ctx = get_uefi_ctx();
|
const struct depri_boot_context *depri_boot_ctx = get_depri_boot_ctx();
|
||||||
const struct lapic_regs *uefi_lapic_regs = get_uefi_lapic_regs();
|
const struct lapic_regs *depri_boot_lapic_regs = get_depri_boot_lapic_regs();
|
||||||
|
|
||||||
pr_dbg("Loading guest to run-time location");
|
pr_dbg("Loading guest to run-time location");
|
||||||
|
|
||||||
vlapic_restore(vcpu_vlapic(vcpu), uefi_lapic_regs);
|
vlapic_restore(vcpu_vlapic(vcpu), depri_boot_lapic_regs);
|
||||||
|
|
||||||
/* For UEFI platform, the bsp init regs come from two places:
|
/* For UEFI platform, the bsp init regs come from two places:
|
||||||
* 1. saved in uefi_boot: gpregs, rip
|
* 1. saved in depri_boot: gpregs, rip
|
||||||
* 2. saved when HV started: other registers
|
* 2. saved when HV started: other registers
|
||||||
* We copy the info saved in uefi_boot to boot_context and
|
* We copy the info saved in depri_boot to boot_context and
|
||||||
* init bsp with boot_context.
|
* init bsp with boot_context.
|
||||||
*/
|
*/
|
||||||
memcpy_s(&(vcpu_regs->gprs), sizeof(struct acrn_gp_regs),
|
memcpy_s(&(vcpu_regs->gprs), sizeof(struct acrn_gp_regs),
|
||||||
&(uefi_ctx->vcpu_regs.gprs), sizeof(struct acrn_gp_regs));
|
&(depri_boot_ctx->vcpu_regs.gprs), sizeof(struct acrn_gp_regs));
|
||||||
|
|
||||||
vcpu_regs->rip = uefi_ctx->vcpu_regs.rip;
|
vcpu_regs->rip = depri_boot_ctx->vcpu_regs.rip;
|
||||||
set_vcpu_regs(vcpu, vcpu_regs);
|
set_vcpu_regs(vcpu, vcpu_regs);
|
||||||
|
|
||||||
/* defer irq enabling till vlapic is ready */
|
/* defer irq enabling till vlapic is ready */
|
||||||
@ -42,9 +42,9 @@ static int32_t uefi_sw_loader(struct acrn_vm *vm)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t uefi_init_vm_boot_info(__unused struct acrn_vm *vm)
|
int32_t init_depri_vboot_info(__unused struct acrn_vm *vm)
|
||||||
{
|
{
|
||||||
vm_sw_loader = uefi_sw_loader;
|
vm_sw_loader = depri_boot_sw_loader;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -4,44 +4,43 @@
|
|||||||
* SPDX-License-Identifier: BSD-3-Clause
|
* SPDX-License-Identifier: BSD-3-Clause
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* this is for both SBL and ABL platform */
|
/* this is for direct guest_boot method */
|
||||||
|
|
||||||
#include <types.h>
|
#include <types.h>
|
||||||
#include <e820.h>
|
#include <e820.h>
|
||||||
#include <cpu.h>
|
#include <cpu.h>
|
||||||
#include <direct_boot.h>
|
#include <direct_boot.h>
|
||||||
|
|
||||||
static void sbl_init(void)
|
static void init_direct_boot(void)
|
||||||
{
|
{
|
||||||
/* nothing to do for now */
|
/* nothing to do for now */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* @post: return != 0UL */
|
/* @post: return != 0UL */
|
||||||
static uint64_t sbl_get_ap_trampoline(void)
|
static uint64_t get_direct_boot_ap_trampoline(void)
|
||||||
{
|
{
|
||||||
return e820_alloc_low_memory(CONFIG_LOW_RAM_SIZE);
|
return e820_alloc_low_memory(CONFIG_LOW_RAM_SIZE);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void* sbl_get_rsdp(void)
|
static void* get_direct_boot_rsdp(void)
|
||||||
{
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void sbl_init_irq(void)
|
static void init_direct_boot_irq(void)
|
||||||
{
|
{
|
||||||
CPU_IRQ_ENABLE();
|
CPU_IRQ_ENABLE();
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct firmware_operations firmware_sbl_ops = {
|
static struct vboot_operations direct_boot_ops = {
|
||||||
.init = sbl_init,
|
.init = init_direct_boot,
|
||||||
.get_ap_trampoline = sbl_get_ap_trampoline,
|
.get_ap_trampoline = get_direct_boot_ap_trampoline,
|
||||||
.get_rsdp = sbl_get_rsdp,
|
.get_rsdp = get_direct_boot_rsdp,
|
||||||
.init_irq = sbl_init_irq,
|
.init_irq = init_direct_boot_irq,
|
||||||
.init_vm_boot_info = sbl_init_vm_boot_info,
|
.init_vboot_info = init_direct_vboot_info,
|
||||||
};
|
};
|
||||||
|
|
||||||
struct firmware_operations* sbl_get_firmware_operations(void)
|
struct vboot_operations* get_direct_boot_ops(void)
|
||||||
{
|
{
|
||||||
return &firmware_sbl_ops;
|
return &direct_boot_ops;
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
#define MAX_BOOT_PARAMS_LEN 64U
|
#define MAX_BOOT_PARAMS_LEN 64U
|
||||||
|
|
||||||
/* There are two sources for sos_vm kernel cmdline:
|
/* There are two sources for sos_vm kernel cmdline:
|
||||||
* - cmdline from sbl. mbi->cmdline
|
* - cmdline from direct boot mbi->cmdline
|
||||||
* - cmdline from acrn stitching tool. mod[0].mm_string
|
* - cmdline from acrn stitching tool. mod[0].mm_string
|
||||||
* We need to merge them together
|
* We need to merge them together
|
||||||
*/
|
*/
|
||||||
@ -160,7 +160,7 @@ static void *get_kernel_load_addr(void *kernel_src_addr)
|
|||||||
* @pre vm != NULL
|
* @pre vm != NULL
|
||||||
* @pre is_sos_vm(vm) == true
|
* @pre is_sos_vm(vm) == true
|
||||||
*/
|
*/
|
||||||
int32_t sbl_init_vm_boot_info(struct acrn_vm *vm)
|
int32_t init_direct_vboot_info(struct acrn_vm *vm)
|
||||||
{
|
{
|
||||||
struct multiboot_module *mods = NULL;
|
struct multiboot_module *mods = NULL;
|
||||||
struct multiboot_info *mbi = NULL;
|
struct multiboot_info *mbi = NULL;
|
||||||
|
@ -13,63 +13,64 @@
|
|||||||
#include <direct_boot.h>
|
#include <direct_boot.h>
|
||||||
#include <deprivilege_boot.h>
|
#include <deprivilege_boot.h>
|
||||||
|
|
||||||
static struct firmware_operations *firmware_ops;
|
static struct vboot_operations *vboot_ops;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @pre: this function is called during detect mode which is very early stage,
|
* @pre: this function is called during detect mode which is very early stage,
|
||||||
* other exported interfaces should not be called beforehand.
|
* other exported interfaces should not be called beforehand.
|
||||||
*/
|
*/
|
||||||
void init_firmware_operations(void)
|
void init_vboot_operations(void)
|
||||||
{
|
{
|
||||||
|
|
||||||
struct multiboot_info *mbi;
|
struct multiboot_info *mbi;
|
||||||
uint32_t i;
|
uint32_t i;
|
||||||
|
|
||||||
const struct firmware_candidates fw_candidates[NUM_FIRMWARE_SUPPORTING] = {
|
const struct vboot_candidates vboot_candidates[NUM_VBOOT_SUPPORTING] = {
|
||||||
{"Slim BootLoader", 15U, sbl_get_firmware_operations},
|
{"Slim BootLoader", 15U, get_direct_boot_ops},
|
||||||
{"Intel IOTG/TSD ABL", 18U, sbl_get_firmware_operations},
|
{"Intel IOTG/TSD ABL", 18U, get_direct_boot_ops},
|
||||||
{"ACRN UEFI loader", 16U, uefi_get_firmware_operations},
|
{"ACRN UEFI loader", 16U, get_deprivilege_boot_ops},
|
||||||
{"GRUB", 4U, sbl_get_firmware_operations},
|
{"GRUB", 4U, get_direct_boot_ops},
|
||||||
};
|
};
|
||||||
|
|
||||||
mbi = (struct multiboot_info *)hpa2hva((uint64_t)boot_regs[1]);
|
mbi = (struct multiboot_info *)hpa2hva((uint64_t)boot_regs[1]);
|
||||||
for (i = 0U; i < NUM_FIRMWARE_SUPPORTING; i++) {
|
for (i = 0U; i < NUM_VBOOT_SUPPORTING; i++) {
|
||||||
if (strncmp(hpa2hva(mbi->mi_loader_name), fw_candidates[i].name, fw_candidates[i].name_sz) == 0) {
|
if (strncmp(hpa2hva(mbi->mi_loader_name), vboot_candidates[i].name,
|
||||||
firmware_ops = fw_candidates[i].ops();
|
vboot_candidates[i].name_sz) == 0) {
|
||||||
|
vboot_ops = vboot_candidates[i].ops();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* @pre: firmware_ops->init != NULL */
|
/* @pre: vboot_ops->init != NULL */
|
||||||
void init_firmware(void)
|
void init_vboot(void)
|
||||||
{
|
{
|
||||||
#ifndef CONFIG_CONSTANT_ACPI
|
#ifndef CONFIG_CONSTANT_ACPI
|
||||||
acpi_fixup();
|
acpi_fixup();
|
||||||
#endif
|
#endif
|
||||||
firmware_ops->init();
|
vboot_ops->init();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* @pre: firmware_ops->get_ap_trampoline != NULL */
|
/* @pre: vboot_ops->get_ap_trampoline != NULL */
|
||||||
uint64_t firmware_get_ap_trampoline(void)
|
uint64_t get_ap_trampoline_buf(void)
|
||||||
{
|
{
|
||||||
return firmware_ops->get_ap_trampoline();
|
return vboot_ops->get_ap_trampoline();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* @pre: firmware_ops->get_rsdp != NULL */
|
/* @pre: vboot_ops->get_rsdp != NULL */
|
||||||
void *firmware_get_rsdp(void)
|
void *get_rsdp_ptr(void)
|
||||||
{
|
{
|
||||||
return firmware_ops->get_rsdp();
|
return vboot_ops->get_rsdp();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* @pre: firmware_ops->init_irq != NULL */
|
/* @pre: vboot_ops->init_irq != NULL */
|
||||||
void firmware_init_irq(void)
|
void init_vboot_irq(void)
|
||||||
{
|
{
|
||||||
return firmware_ops->init_irq();
|
return vboot_ops->init_irq();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* @pre: firmware_ops->init_vm_boot_info != NULL */
|
/* @pre: vboot_ops->init_vboot_info != NULL */
|
||||||
int32_t firmware_init_vm_boot_info(struct acrn_vm *vm)
|
int32_t init_vm_boot_info(struct acrn_vm *vm)
|
||||||
{
|
{
|
||||||
return firmware_ops->init_vm_boot_info(vm);
|
return vboot_ops->init_vboot_info(vm);
|
||||||
}
|
}
|
||||||
|
@ -3,22 +3,22 @@
|
|||||||
*
|
*
|
||||||
* SPDX-License-Identifier: BSD-3-Clause
|
* SPDX-License-Identifier: BSD-3-Clause
|
||||||
*/
|
*/
|
||||||
#ifndef FIRMWARE_UEFI_H
|
#ifndef DEPRIVILEGE_BOOT_H
|
||||||
|
|
||||||
#define FIRMWARE_UEFI_H
|
#define DEPRIVILEGE_BOOT_H
|
||||||
|
|
||||||
#include <vboot.h>
|
#include <vboot.h>
|
||||||
|
|
||||||
struct uefi_context {
|
struct depri_boot_context {
|
||||||
struct acrn_vcpu_regs vcpu_regs;
|
struct acrn_vcpu_regs vcpu_regs;
|
||||||
void *rsdp;
|
void *rsdp;
|
||||||
void *ap_trampoline_buf;
|
void *ap_trampoline_buf;
|
||||||
} __packed;
|
} __packed;
|
||||||
|
|
||||||
const struct uefi_context *get_uefi_ctx(void);
|
const struct depri_boot_context *get_depri_boot_ctx(void);
|
||||||
const struct lapic_regs *get_uefi_lapic_regs(void);
|
const struct lapic_regs *get_depri_boot_lapic_regs(void);
|
||||||
|
|
||||||
struct firmware_operations* uefi_get_firmware_operations(void);
|
struct vboot_operations* get_deprivilege_boot_ops(void);
|
||||||
int32_t uefi_init_vm_boot_info(__unused struct acrn_vm *vm);
|
int32_t init_depri_vboot_info(__unused struct acrn_vm *vm);
|
||||||
|
|
||||||
#endif /* end of include guard: FIRMWARE_UEFI_H */
|
#endif /* end of include guard: DEPRIVILEGE_BOOT_H */
|
||||||
|
@ -4,13 +4,13 @@
|
|||||||
* SPDX-License-Identifier: BSD-3-Clause
|
* SPDX-License-Identifier: BSD-3-Clause
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef FIRMWARE_SBL_H
|
#ifndef DIRECT_BOOT_H
|
||||||
|
|
||||||
#define FIRMWARE_SBL_H
|
#define DIRECT_BOOT_H
|
||||||
|
|
||||||
#include <vboot.h>
|
#include <vboot.h>
|
||||||
|
|
||||||
struct firmware_operations* sbl_get_firmware_operations(void);
|
struct vboot_operations* get_direct_boot_ops(void);
|
||||||
int32_t sbl_init_vm_boot_info(struct acrn_vm *vm);
|
int32_t init_direct_vboot_info(struct acrn_vm *vm);
|
||||||
|
|
||||||
#endif /* end of include guard: FIRMWARE_SBL_H */
|
#endif /* end of include guard: DIRECT_BOOT_H */
|
||||||
|
@ -4,34 +4,34 @@
|
|||||||
* SPDX-License-Identifier: BSD-3-Clause
|
* SPDX-License-Identifier: BSD-3-Clause
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef FIRMWARE_H
|
#ifndef VBOOT_H
|
||||||
|
|
||||||
#define FIRMWARE_H
|
#define VBOOT_H
|
||||||
|
|
||||||
#define NUM_FIRMWARE_SUPPORTING 4U
|
#define NUM_VBOOT_SUPPORTING 4U
|
||||||
|
|
||||||
struct acrn_vm;
|
struct acrn_vm;
|
||||||
struct firmware_operations {
|
struct vboot_operations {
|
||||||
void (*init)(void);
|
void (*init)(void);
|
||||||
uint64_t (*get_ap_trampoline)(void);
|
uint64_t (*get_ap_trampoline)(void);
|
||||||
void *(*get_rsdp)(void);
|
void *(*get_rsdp)(void);
|
||||||
void (*init_irq)(void);
|
void (*init_irq)(void);
|
||||||
int32_t (*init_vm_boot_info)(struct acrn_vm *vm);
|
int32_t (*init_vboot_info)(struct acrn_vm *vm);
|
||||||
};
|
};
|
||||||
|
|
||||||
struct firmware_candidates {
|
struct vboot_candidates {
|
||||||
const char name[20];
|
const char name[20];
|
||||||
size_t name_sz;
|
size_t name_sz;
|
||||||
struct firmware_operations *(*ops)(void);
|
struct vboot_operations *(*ops)(void);
|
||||||
};
|
};
|
||||||
|
|
||||||
void init_firmware_operations(void);
|
void init_vboot_operations(void);
|
||||||
void init_firmware(void);
|
void init_vboot(void);
|
||||||
uint64_t firmware_get_ap_trampoline(void);
|
void init_vboot_irq(void);
|
||||||
void *firmware_get_rsdp(void);
|
int32_t init_vm_boot_info(struct acrn_vm *vm);
|
||||||
void firmware_init_irq(void);
|
uint64_t get_ap_trampoline_buf(void);
|
||||||
int32_t firmware_init_vm_boot_info(struct acrn_vm *vm);
|
void *get_rsdp_ptr(void);
|
||||||
|
|
||||||
int32_t parse_hv_cmdline(void);
|
int32_t parse_hv_cmdline(void);
|
||||||
|
|
||||||
#endif /* end of include guard: FIRMWARE_H */
|
#endif /* end of include guard: VBOOT_H */
|
||||||
|
Loading…
Reference in New Issue
Block a user