diff --git a/boot/acpi.c b/boot/acpi.c index c4d356416..796152253 100644 --- a/boot/acpi.c +++ b/boot/acpi.c @@ -35,6 +35,9 @@ #include #include #include "acpi.h" +#ifdef CONFIG_EFI_STUB +#include +#endif #define ACPI_SIG_RSDP "RSD PTR " /* Root System Description Ptr */ #define ACPI_OEM_ID_SIZE 6 @@ -140,6 +143,12 @@ static void *get_rsdp(void) struct acpi_table_rsdp *rsdp = NULL; uint16_t *addr; +#ifdef CONFIG_EFI_STUB + rsdp = get_rsdp_from_uefi(); + if (rsdp) + return rsdp; +#endif + /* EBDA is addressed by the 16 bit pointer at 0x40E */ addr = (uint16_t *)0x40E; diff --git a/bsp/uefi/efi/boot.c b/bsp/uefi/efi/boot.c index bf2c22ee3..a2463aedf 100644 --- a/bsp/uefi/efi/boot.c +++ b/bsp/uefi/efi/boot.c @@ -41,8 +41,6 @@ #define ERROR_STRING_LENGTH 32 #define EFI_LOADER_SIGNATURE "EL64" -#define LEAGCY_BIOS - #define ACPI_XSDT_ENTRY_SIZE (sizeof (UINT64)) #define ACPI_NAME_SIZE 4 #define ACPI_OEM_ID_SIZE 6 @@ -448,11 +446,8 @@ again: mbi->mi_cmdline = (UINTN)"uart=disabled"; mbi->mi_mmap_addr = (UINTN)mmap; -#ifdef LEAGCY_BIOS - /* copy rsdt in low memory space(0~0x1000) for hypervisor parsing */ - memcpy((void *)0x500, (void*)rsdp, sizeof(struct acpi_table_rsdp)); - *(UINT16*)(0x40E) = 0x50; -#endif + pe->rsdp = rsdp; + //Print(L"start 9!\n"); asm volatile ("mov %%cr0, %0":"=r"(pe->cr0)); diff --git a/bsp/uefi/efi/boot.h b/bsp/uefi/efi/boot.h index 21cb87536..1bd01bd9f 100644 --- a/bsp/uefi/efi/boot.h +++ b/bsp/uefi/efi/boot.h @@ -76,7 +76,8 @@ struct e820_entry { struct efi_ctx { EFI_IMAGE_ENTRY_POINT entry; EFI_HANDLE handle; - EFI_SYSTEM_TABLE* table; + EFI_SYSTEM_TABLE *table; + VOID *rsdp; dt_addr_t gdt; dt_addr_t idt; uint16_t tr_sel; diff --git a/bsp/uefi/uefi.c b/bsp/uefi/uefi.c index bb654296f..2476015cd 100644 --- a/bsp/uefi/uefi.c +++ b/bsp/uefi/uefi.c @@ -53,12 +53,15 @@ #define UEFI_PCI_IRQ_ASSIGNMENT_NUM 28 #ifdef CONFIG_EFI_STUB +static void efi_init(void); + uint32_t efi_physical_available_ap_bitmap = 0; uint32_t efi_wake_up_ap_bitmap = 0; struct efi_ctx* efi_ctx = NULL; struct lapic_regs uefi_lapic_regs; extern uint32_t up_count; extern unsigned long pcpu_sync; +static int efi_initialized; void efi_spurious_handler(int vector) { @@ -144,14 +147,18 @@ int uefi_sw_loader(struct vm *vm, struct vcpu *vcpu) return ret; } -#endif -void init_bsp(void) +void *get_rsdp_from_uefi(void) { - parse_hv_cmdline(); + if (!efi_initialized) + efi_init(); -#ifdef CONFIG_EFI_STUB - efi_ctx = (struct efi_ctx*)(uint64_t)boot_regs[2]; + return efi_ctx->rsdp; +} + +static void efi_init(void) +{ + efi_ctx = (struct efi_ctx *)(uint64_t)(uint32_t)boot_regs[2]; ASSERT(efi_ctx != NULL, ""); vm_sw_loader = uefi_sw_loader; @@ -159,5 +166,17 @@ void init_bsp(void) spurious_handler = efi_spurious_handler; save_lapic(&uefi_lapic_regs); + + efi_initialized = 1; +} +#endif + +void init_bsp(void) +{ + parse_hv_cmdline(); + +#ifdef CONFIG_EFI_STUB + if (!efi_initialized) + efi_init(); #endif } diff --git a/include/common/acrn_efi.h b/include/common/acrn_efi.h index 3939614e2..c228e1097 100644 --- a/include/common/acrn_efi.h +++ b/include/common/acrn_efi.h @@ -37,9 +37,10 @@ typedef struct { } __attribute__((packed)) dt_addr_t; struct efi_ctx { - void* entry; - void* handle; - void* table; + void *entry; + void *handle; + void *table; + void *rsdp; dt_addr_t gdt; dt_addr_t idt; uint16_t tr_sel; @@ -59,4 +60,6 @@ struct efi_ctx { uint64_t efer; }__attribute__((packed)); +void *get_rsdp_from_uefi(void); + #endif /* UEFI_H*/