diff --git a/arch/x86/cpu_primary.S b/arch/x86/cpu_primary.S index 0c54e2e6d..066bac0fe 100644 --- a/arch/x86/cpu_primary.S +++ b/arch/x86/cpu_primary.S @@ -118,9 +118,6 @@ cpu_primary_start_64: /* save the MULTBOOT magic number & MBI */ movl %edi, (boot_regs) movl %esi, (boot_regs+4) -#ifdef CONFIG_EFI_STUB - movl %edx, (boot_regs+8) -#endif primary_start_long_mode: @@ -187,9 +184,6 @@ loop: boot_regs: .long 0x00000000 .long 0x00000000 -#ifdef CONFIG_EFI_STUB - .long 0x00000000 -#endif /* GDT table */ .align 4 diff --git a/bsp/uefi/efi/boot.c b/bsp/uefi/efi/boot.c index 4a4f9f59c..4500de85d 100644 --- a/bsp/uefi/efi/boot.c +++ b/bsp/uefi/efi/boot.c @@ -155,7 +155,7 @@ struct acpi_table_header { UINT32 asl_compiler_revision; /* ASL compiler version */ }; -typedef void(*hv_func)(int, struct multiboot_info*, struct efi_ctx*); +typedef void(*hv_func)(int, struct multiboot_info*); EFI_IMAGE_ENTRY_POINT get_pe_entry(CHAR8 *base); static inline void hv_jump(EFI_PHYSICAL_ADDRESS hv_start, @@ -177,7 +177,7 @@ static inline void hv_jump(EFI_PHYSICAL_ADDRESS hv_start, asm volatile ("cli"); /* jump to acrn hypervisor */ - hf(MULTIBOOT_INFO_MAGIC, mbi, efi_ctx); + hf(MULTIBOOT_INFO_MAGIC, mbi); } EFI_STATUS get_path(CHAR16* name, EFI_LOADED_IMAGE *info, EFI_DEVICE_PATH **path) @@ -410,6 +410,9 @@ again: mbi->mi_cmdline = (UINTN)"uart=disabled"; mbi->mi_mmap_addr = (UINTN)mmap; + mbi->mi_flags |= MULTIBOOT_INFO_HAS_DRIVES; + mbi->mi_drives_addr = (UINT32)(UINTN)efi_ctx; + efi_ctx->rsdp = rsdp; //Print(L"start 9!\n"); diff --git a/bsp/uefi/uefi.c b/bsp/uefi/uefi.c index b12f80fc4..e0b13d242 100644 --- a/bsp/uefi/uefi.c +++ b/bsp/uefi/uefi.c @@ -138,7 +138,7 @@ int uefi_sw_loader(struct vm *vm, struct vcpu *vcpu) vlapic_restore(vcpu->arch_vcpu.vlapic, &uefi_lapic_regs); - vcpu->entry_addr = efi_ctx->rip; + vcpu->entry_addr = (void *)efi_ctx->rip; cur_context->guest_cpu_regs.regs.rax = efi_ctx->rax; cur_context->guest_cpu_regs.regs.rbx = efi_ctx->rbx; cur_context->guest_cpu_regs.regs.rdx = efi_ctx->rcx; @@ -171,8 +171,18 @@ void *get_rsdp_from_uefi(void) static void efi_init(void) { - efi_ctx = (struct efi_ctx *)(uint64_t)(uint32_t)boot_regs[2]; - ASSERT(efi_ctx != NULL, ""); + struct multiboot_info *mbi = NULL; + + if (boot_regs[0] != MULTIBOOT_INFO_MAGIC) + ASSERT(0, "no multiboot info found"); + + mbi = (struct multiboot_info *)((uint64_t)(uint32_t)boot_regs[1]); + + if (!(mbi->mi_flags & MULTIBOOT_INFO_HAS_DRIVES)) + ASSERT(0, "no multiboot drivers for uefi found"); + + efi_ctx = (struct efi_ctx *)(uint64_t)mbi->mi_drives_addr; + ASSERT(efi_ctx != NULL, "no uefi context found"); vm_sw_loader = uefi_sw_loader; diff --git a/include/arch/x86/multiboot.h b/include/arch/x86/multiboot.h index 0792866a6..64ed9ed8f 100644 --- a/include/arch/x86/multiboot.h +++ b/include/arch/x86/multiboot.h @@ -34,6 +34,7 @@ #define MULTIBOOT_INFO_MAGIC 0x2BADB002 #define MULTIBOOT_INFO_HAS_CMDLINE 0x00000004 #define MULTIBOOT_INFO_HAS_MODS 0x00000008 +#define MULTIBOOT_INFO_HAS_DRIVES 0x00000080 struct multiboot_info { uint32_t mi_flags;