Skip to content

Commit 56d8b08

Browse files
tw4452852wenlingz
authored andcommitted
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>
1 parent 23e85ff commit 56d8b08

File tree

21 files changed

+295
-181
lines changed

21 files changed

+295
-181
lines changed

hypervisor/Makefile

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -226,15 +226,16 @@ C_SRCS += dm/vpci/msi.c
226226
C_SRCS += dm/vpci/msix.c
227227
endif
228228

229+
C_SRCS += bsp/firmware_wrapper.c
230+
C_SRCS += bsp/firmware_sbl.c
231+
C_SRCS += bsp/firmware_uefi.c
232+
C_SRCS += bsp/cmdline.c
233+
C_SRCS += bsp/const_dmar.c
234+
229235
ifeq ($(CONFIG_PLATFORM_UEFI),y)
230-
INCLUDE_PATH += bsp/include/uefi
231-
C_SRCS += bsp/uefi/uefi.c
232-
C_SRCS += bsp/uefi/cmdline.c
233236
C_SRCS += boot/uefi/uefi_boot.c
234237
else
235238
ifeq ($(CONFIG_PLATFORM_SBL),y)
236-
C_SRCS += bsp/sbl/sbl.c
237-
C_SRCS += bsp/sbl/const_dmar.c
238239
C_SRCS += boot/sbl/multiboot.c
239240
C_SRCS += boot/sbl/sbl_seed_parse.c
240241
C_SRCS += boot/sbl/abl_seed_parse.c

hypervisor/arch/x86/cpu.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#include <ld_sym.h>
2626
#include <logmsg.h>
2727
#include <cat.h>
28+
#include <firmware.h>
2829

2930
struct per_cpu_region per_cpu_data[CONFIG_MAX_PCPU_NUM] __aligned(PAGE_SIZE);
3031
static uint16_t phys_cpu_num = 0U;
@@ -112,6 +113,8 @@ void init_cpu_pre(uint16_t pcpu_id_args)
112113
*/
113114
init_cpu_capabilities();
114115

116+
init_firmware_operations();
117+
115118
init_cpu_model_name();
116119

117120
load_cpu_state_data();

hypervisor/arch/x86/init.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@ static void enter_guest_mode(uint16_t pcpu_id)
6262

6363
static void init_primary_cpu_post(void)
6464
{
65-
/* Perform any necessary BSP initialization */
66-
init_bsp();
65+
/* Perform any necessary firmware initialization */
66+
init_firmware();
6767

6868
init_debug_pre();
6969

hypervisor/arch/x86/irq.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
#include <ioapic.h>
1616
#include <lapic.h>
1717
#include <softirq.h>
18-
#include <bsp_extern.h>
18+
#include <firmware.h>
1919
#include <dump.h>
2020
#include <logmsg.h>
2121

@@ -480,5 +480,5 @@ void interrupt_init(uint16_t pcpu_id)
480480
init_lapic(pcpu_id);
481481
init_default_irqs(pcpu_id);
482482

483-
bsp_init_irq();
483+
firmware_init_irq();
484484
}

hypervisor/arch/x86/trampoline.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#include <per_cpu.h>
1010
#include <trampoline.h>
1111
#include <reloc.h>
12-
#include <bsp_extern.h>
12+
#include <firmware.h>
1313
#include <ld_sym.h>
1414

1515
static uint64_t trampoline_start16_paddr;
@@ -110,7 +110,7 @@ uint64_t prepare_trampoline(void)
110110
uint64_t size, dest_pa, i;
111111

112112
size = (uint64_t)(&ld_trampoline_end - &ld_trampoline_start);
113-
dest_pa = bsp_get_ap_trampoline();
113+
dest_pa = firmware_get_ap_trampoline();
114114

115115
pr_dbg("trampoline code: %llx size %x", dest_pa, size);
116116

hypervisor/boot/acpi.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ static struct acpi_table_rsdp *get_rsdp(void)
146146
struct acpi_table_rsdp *rsdp = NULL;
147147
uint16_t *addr;
148148

149-
rsdp = (struct acpi_table_rsdp *)bsp_get_rsdp();
149+
rsdp = (struct acpi_table_rsdp *)firmware_get_rsdp();
150150
if (rsdp == NULL) {
151151
/* EBDA is addressed by the 16 bit pointer at 0x40E */
152152
addr = (uint16_t *)hpa2hva(0x40eUL);

hypervisor/boot/uefi/uefi_boot.c

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,6 @@
99
#include <boot_context.h>
1010
#include <uefi.h>
1111

12-
static void efi_spurious_handler(int32_t vector)
13-
{
14-
if (get_cpu_id() == BOOT_CPU_ID) {
15-
struct acrn_vcpu *vcpu = per_cpu(vcpu, BOOT_CPU_ID);
16-
17-
if (vcpu != NULL) {
18-
vlapic_set_intr(vcpu, vector, LAPIC_TRIG_EDGE);
19-
} else {
20-
pr_err("%s vcpu or vlapic is not ready, interrupt lost\n", __func__);
21-
}
22-
}
23-
}
24-
2512
static int32_t uefi_sw_loader(struct acrn_vm *vm)
2613
{
2714
int32_t ret = 0;
@@ -56,7 +43,6 @@ static int32_t uefi_sw_loader(struct acrn_vm *vm)
5643
int32_t init_vm_boot_info(__unused struct acrn_vm *vm)
5744
{
5845
vm_sw_loader = uefi_sw_loader;
59-
spurious_handler = (spurious_handler_t)efi_spurious_handler;
6046

6147
return 0;
6248
}
File renamed without changes.
File renamed without changes.

hypervisor/bsp/firmware_sbl.c

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/*
2+
* Copyright (C) 2019 Intel Corporation. All rights reserved.
3+
*
4+
* SPDX-License-Identifier: BSD-3-Clause
5+
*/
6+
7+
/* this is for both SBL and ABL platform */
8+
9+
#include <hypervisor.h>
10+
#include <firmware_sbl.h>
11+
12+
static void sbl_init(void)
13+
{
14+
/* nothing to do for now */
15+
}
16+
17+
18+
/* @post: return != 0UL */
19+
static uint64_t sbl_get_ap_trampoline(void)
20+
{
21+
return e820_alloc_low_memory(CONFIG_LOW_RAM_SIZE);
22+
}
23+
24+
static void* sbl_get_rsdp(void)
25+
{
26+
return NULL;
27+
}
28+
29+
static void sbl_init_irq(void)
30+
{
31+
CPU_IRQ_ENABLE();
32+
}
33+
34+
static struct firmware_operations firmware_sbl_ops = {
35+
.init = sbl_init,
36+
.get_ap_trampoline = sbl_get_ap_trampoline,
37+
.get_rsdp = sbl_get_rsdp,
38+
.init_irq = sbl_init_irq,
39+
};
40+
41+
struct firmware_operations* sbl_get_firmware_operations(void)
42+
{
43+
return &firmware_sbl_ops;
44+
}

0 commit comments

Comments
 (0)