mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-09-08 12:19:06 +00:00
restruct boot and bsp dir for firmware stuff
currently, ACRN hypervisor can either boot from sbl/abl or uefi, that's why we have different firmware method under bsp & boot dirs. but the fact is that we actually have two different operations based on different guest boot mode: 1. de-privilege-boot: ACRN hypervisor will boot VM0 in the same context as native(before entering hypervisor) - it means hypervisor will co-work with ACRN UEFI bootloader, restore the context env and de-privilege this env to VM0 guest. 2. direct-boot: ACRN hypervisor will directly boot different pre-launched VM(including SOS), it will setup guest env by pre-defined configuration, and prepare guest kernel image, ramdisk which fetch from multiboot modules. this patch is trying to: - rename files related with firmware, change them to guest vboot related - restruct all guest boot stuff in boot & bsp dirs into a new boot/guest dir - use de-privilege & direct boot to distinguish two different boot operations this patch is pure file movement, the rename of functions based on old assumption will be in the following patch. Changes to be committed: modified: ../efi-stub/Makefile modified: ../efi-stub/boot.c modified: Makefile modified: arch/x86/cpu.c modified: arch/x86/guest/vm.c modified: arch/x86/init.c modified: arch/x86/irq.c modified: arch/x86/trampoline.c modified: boot/acpi.c renamed: bsp/cmdline.c -> boot/cmdline.c renamed: bsp/firmware_uefi.c -> boot/guest/deprivilege_boot.c renamed: boot/uefi/uefi_boot.c -> boot/guest/deprivilege_boot_info.c renamed: bsp/firmware_sbl.c -> boot/guest/direct_boot.c renamed: boot/sbl/multiboot.c -> boot/guest/direct_boot_info.c renamed: bsp/firmware_wrapper.c -> boot/guest/vboot_wrapper.c modified: boot/include/acpi.h renamed: bsp/include/firmware_uefi.h -> boot/include/guest/deprivilege_boot.h renamed: bsp/include/firmware_sbl.h -> boot/include/guest/direct_boot.h renamed: bsp/include/firmware.h -> boot/include/guest/vboot.h modified: include/arch/x86/multiboot.h 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:
committed by
Eddie Dong
parent
c336686321
commit
20f97f7559
@@ -1,54 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2018 Intel Corporation. All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*/
|
||||
|
||||
#include <types.h>
|
||||
#include <errno.h>
|
||||
#include <multiboot.h>
|
||||
#include <pgtable.h>
|
||||
#include <dbg_cmd.h>
|
||||
#include <logmsg.h>
|
||||
|
||||
#define ACRN_DBG_PARSE 6
|
||||
|
||||
int32_t parse_hv_cmdline(void)
|
||||
{
|
||||
const char *start;
|
||||
const char *end;
|
||||
struct multiboot_info *mbi = NULL;
|
||||
|
||||
if (boot_regs[0] != MULTIBOOT_INFO_MAGIC) {
|
||||
ASSERT(0, "no multiboot info found");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
mbi = (struct multiboot_info *)(hpa2hva((uint64_t)boot_regs[1]));
|
||||
dev_dbg(ACRN_DBG_PARSE, "Multiboot detected, flag=0x%x", mbi->mi_flags);
|
||||
|
||||
if (!(mbi->mi_flags & MULTIBOOT_INFO_HAS_CMDLINE)) {
|
||||
dev_dbg(ACRN_DBG_PARSE, "no hv cmdline!");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
start = (char *)hpa2hva((uint64_t)mbi->mi_cmdline);
|
||||
dev_dbg(ACRN_DBG_PARSE, "hv cmdline: %s", start);
|
||||
|
||||
do {
|
||||
while (*start == ' ')
|
||||
start++;
|
||||
|
||||
end = start + 1;
|
||||
while (*end != ' ' && *end)
|
||||
end++;
|
||||
|
||||
if (!handle_dbg_cmd(start, end - start)) {
|
||||
/* if not handled by handle_dbg_cmd, it can be handled further */
|
||||
}
|
||||
start = end + 1;
|
||||
|
||||
} while (*end && *start);
|
||||
|
||||
return 0;
|
||||
}
|
@@ -1,47 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2019 Intel Corporation. All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*/
|
||||
|
||||
/* this is for both SBL and ABL platform */
|
||||
|
||||
#include <types.h>
|
||||
#include <e820.h>
|
||||
#include <cpu.h>
|
||||
#include <firmware_sbl.h>
|
||||
|
||||
static void sbl_init(void)
|
||||
{
|
||||
/* nothing to do for now */
|
||||
}
|
||||
|
||||
|
||||
/* @post: return != 0UL */
|
||||
static uint64_t sbl_get_ap_trampoline(void)
|
||||
{
|
||||
return e820_alloc_low_memory(CONFIG_LOW_RAM_SIZE);
|
||||
}
|
||||
|
||||
static void* sbl_get_rsdp(void)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void sbl_init_irq(void)
|
||||
{
|
||||
CPU_IRQ_ENABLE();
|
||||
}
|
||||
|
||||
static struct firmware_operations firmware_sbl_ops = {
|
||||
.init = sbl_init,
|
||||
.get_ap_trampoline = sbl_get_ap_trampoline,
|
||||
.get_rsdp = sbl_get_rsdp,
|
||||
.init_irq = sbl_init_irq,
|
||||
.init_vm_boot_info = sbl_init_vm_boot_info,
|
||||
};
|
||||
|
||||
struct firmware_operations* sbl_get_firmware_operations(void)
|
||||
{
|
||||
return &firmware_sbl_ops;
|
||||
}
|
@@ -1,95 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2019 Intel Corporation. All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*/
|
||||
|
||||
/* this is for UEFI platform */
|
||||
|
||||
#include <types.h>
|
||||
#include <acrn_common.h>
|
||||
#include <pgtable.h>
|
||||
#include <logmsg.h>
|
||||
#include <rtl.h>
|
||||
#include <vlapic.h>
|
||||
#include <lapic.h>
|
||||
#include <per_cpu.h>
|
||||
#include <multiboot.h>
|
||||
#include <firmware_uefi.h>
|
||||
|
||||
static struct uefi_context uefi_ctx;
|
||||
static struct lapic_regs uefi_lapic_regs;
|
||||
|
||||
static void uefi_init(void)
|
||||
{
|
||||
static bool uefi_initialized = false;
|
||||
struct multiboot_info *mbi = NULL;
|
||||
|
||||
if (!uefi_initialized) {
|
||||
parse_hv_cmdline();
|
||||
|
||||
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 {
|
||||
memcpy_s(&uefi_ctx, sizeof(struct uefi_context), hpa2hva((uint64_t)mbi->mi_drives_addr),
|
||||
sizeof(struct uefi_context));
|
||||
save_lapic(&uefi_lapic_regs);
|
||||
}
|
||||
uefi_initialized = true;
|
||||
}
|
||||
}
|
||||
|
||||
const struct uefi_context *get_uefi_ctx(void)
|
||||
{
|
||||
uefi_init();
|
||||
return &uefi_ctx;
|
||||
}
|
||||
|
||||
const struct lapic_regs *get_uefi_lapic_regs(void)
|
||||
{
|
||||
uefi_init();
|
||||
return &uefi_lapic_regs;
|
||||
}
|
||||
|
||||
static uint64_t uefi_get_ap_trampoline(void)
|
||||
{
|
||||
return (uint64_t)(uefi_ctx.ap_trampoline_buf);
|
||||
}
|
||||
|
||||
static void* uefi_get_rsdp(void)
|
||||
{
|
||||
return hpa2hva((uint64_t)(uefi_ctx.rsdp));
|
||||
}
|
||||
|
||||
static void uefi_spurious_handler(int32_t vector)
|
||||
{
|
||||
if (get_pcpu_id() == BOOT_CPU_ID) {
|
||||
struct acrn_vcpu *vcpu = per_cpu(vcpu, BOOT_CPU_ID);
|
||||
|
||||
if (vcpu != NULL) {
|
||||
vlapic_set_intr(vcpu, vector, LAPIC_TRIG_EDGE);
|
||||
} else {
|
||||
pr_err("%s vcpu or vlapic is not ready, interrupt lost\n", __func__);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void uefi_init_irq(void)
|
||||
{
|
||||
spurious_handler = (spurious_handler_t)uefi_spurious_handler;
|
||||
/* we defer irq enabling till vlapic is ready */
|
||||
}
|
||||
|
||||
static struct firmware_operations firmware_uefi_ops = {
|
||||
.init = uefi_init,
|
||||
.get_ap_trampoline = uefi_get_ap_trampoline,
|
||||
.get_rsdp = uefi_get_rsdp,
|
||||
.init_irq = uefi_init_irq,
|
||||
.init_vm_boot_info = uefi_init_vm_boot_info,
|
||||
};
|
||||
|
||||
struct firmware_operations* uefi_get_firmware_operations(void)
|
||||
{
|
||||
return &firmware_uefi_ops;
|
||||
}
|
@@ -1,75 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2019 Intel Corporation. All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*/
|
||||
|
||||
#include <multiboot.h>
|
||||
#include <vm.h>
|
||||
#include <types.h>
|
||||
#include <pgtable.h>
|
||||
#include <acpi.h>
|
||||
#include <firmware.h>
|
||||
#include <firmware_sbl.h>
|
||||
#include <firmware_uefi.h>
|
||||
|
||||
static struct firmware_operations *firmware_ops;
|
||||
|
||||
/**
|
||||
* @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)
|
||||
{
|
||||
|
||||
struct multiboot_info *mbi;
|
||||
uint32_t i;
|
||||
|
||||
const struct firmware_candidates fw_candidates[NUM_FIRMWARE_SUPPORTING] = {
|
||||
{"Slim BootLoader", 15U, sbl_get_firmware_operations},
|
||||
{"Intel IOTG/TSD ABL", 18U, sbl_get_firmware_operations},
|
||||
{"ACRN UEFI loader", 16U, uefi_get_firmware_operations},
|
||||
{"GRUB", 4U, sbl_get_firmware_operations},
|
||||
};
|
||||
|
||||
mbi = (struct multiboot_info *)hpa2hva((uint64_t)boot_regs[1]);
|
||||
for (i = 0U; i < NUM_FIRMWARE_SUPPORTING; i++) {
|
||||
if (strncmp(hpa2hva(mbi->mi_loader_name), fw_candidates[i].name, fw_candidates[i].name_sz) == 0) {
|
||||
firmware_ops = fw_candidates[i].ops();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* @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();
|
||||
}
|
||||
|
||||
/* @pre: firmware_ops->init_vm_boot_info != NULL */
|
||||
int32_t firmware_init_vm_boot_info(struct acrn_vm *vm)
|
||||
{
|
||||
return firmware_ops->init_vm_boot_info(vm);
|
||||
}
|
@@ -1,35 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2019 Intel Corporation. All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*/
|
||||
|
||||
#ifndef FIRMWARE_H
|
||||
|
||||
#define FIRMWARE_H
|
||||
|
||||
#define NUM_FIRMWARE_SUPPORTING 4U
|
||||
|
||||
struct acrn_vm;
|
||||
struct firmware_operations {
|
||||
void (*init)(void);
|
||||
uint64_t (*get_ap_trampoline)(void);
|
||||
void *(*get_rsdp)(void);
|
||||
void (*init_irq)(void);
|
||||
int32_t (*init_vm_boot_info)(struct acrn_vm *vm);
|
||||
};
|
||||
|
||||
struct firmware_candidates {
|
||||
const char name[20];
|
||||
size_t name_sz;
|
||||
struct firmware_operations *(*ops)(void);
|
||||
};
|
||||
|
||||
void init_firmware_operations(void);
|
||||
void init_firmware(void);
|
||||
uint64_t firmware_get_ap_trampoline(void);
|
||||
void *firmware_get_rsdp(void);
|
||||
void firmware_init_irq(void);
|
||||
int32_t firmware_init_vm_boot_info(struct acrn_vm *vm);
|
||||
|
||||
#endif /* end of include guard: FIRMWARE_H */
|
@@ -1,16 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2019 Intel Corporation. All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*/
|
||||
|
||||
#ifndef FIRMWARE_SBL_H
|
||||
|
||||
#define FIRMWARE_SBL_H
|
||||
|
||||
#include <firmware.h>
|
||||
|
||||
struct firmware_operations* sbl_get_firmware_operations(void);
|
||||
int32_t sbl_init_vm_boot_info(struct acrn_vm *vm);
|
||||
|
||||
#endif /* end of include guard: FIRMWARE_SBL_H */
|
@@ -1,24 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2019 Intel Corporation. All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*/
|
||||
#ifndef FIRMWARE_UEFI_H
|
||||
|
||||
#define FIRMWARE_UEFI_H
|
||||
|
||||
#include <firmware.h>
|
||||
|
||||
struct uefi_context {
|
||||
struct acrn_vcpu_regs vcpu_regs;
|
||||
void *rsdp;
|
||||
void *ap_trampoline_buf;
|
||||
} __packed;
|
||||
|
||||
const struct uefi_context *get_uefi_ctx(void);
|
||||
const struct lapic_regs *get_uefi_lapic_regs(void);
|
||||
|
||||
struct firmware_operations* uefi_get_firmware_operations(void);
|
||||
int32_t uefi_init_vm_boot_info(__unused struct acrn_vm *vm);
|
||||
|
||||
#endif /* end of include guard: FIRMWARE_UEFI_H */
|
Reference in New Issue
Block a user