diff --git a/hypervisor/bsp/uefi/efi/boot.c b/hypervisor/bsp/uefi/efi/boot.c index 7a6721103..9be26d41b 100644 --- a/hypervisor/bsp/uefi/efi/boot.c +++ b/hypervisor/bsp/uefi/efi/boot.c @@ -39,6 +39,7 @@ EFI_SYSTEM_TABLE *sys_table; EFI_BOOT_SERVICES *boot; +char *cmdline = NULL; extern const uint64_t guest_entry; static inline void hv_jump(EFI_PHYSICAL_ADDRESS hv_start, @@ -198,9 +199,7 @@ again: mbi->mi_flags |= MULTIBOOT_INFO_HAS_MMAP | MULTIBOOT_INFO_HAS_CMDLINE; mbi->mi_mmap_length = j*sizeof(struct multiboot_mmap); - //mbi->mi_cmdline = (UINTN)"uart=mmio@0x92230000"; - //mbi->mi_cmdline = (UINTN)"uart=port@0x3F8"; - mbi->mi_cmdline = (UINTN)"uart=disabled"; + mbi->mi_cmdline = (UINTN)cmdline; mbi->mi_mmap_addr = (UINTN)mmap; mbi->mi_flags |= MULTIBOOT_INFO_HAS_DRIVES; @@ -337,6 +336,8 @@ efi_main(EFI_HANDLE image, EFI_SYSTEM_TABLE *_table) CHAR16 *bootloader_name = NULL; CHAR16 bootloader_param[] = L"bootloader="; EFI_HANDLE bootloader_image; + CHAR16 *options = NULL; + UINT32 options_size = 0; InitializeLib(image, _table); Argc = GetShellArgcArgv(image, &Argv); @@ -350,6 +351,14 @@ efi_main(EFI_HANDLE image, EFI_SYSTEM_TABLE *_table) if (err != EFI_SUCCESS) goto failed; + /* get the options */ + options = info->LoadOptions; + options_size = info->LoadOptionsSize; + + /* convert the options to cmdline */ + if (options_size > 0) + cmdline = ch16_2_ch8(options); + section = ".hv"; err = get_pe_section(info->ImageBase, section, &sec_addr, &sec_size); if (EFI_ERROR(err)) { diff --git a/hypervisor/bsp/uefi/efi/stdlib.h b/hypervisor/bsp/uefi/efi/stdlib.h index 843dc1fc4..8fbbff980 100644 --- a/hypervisor/bsp/uefi/efi/stdlib.h +++ b/hypervisor/bsp/uefi/efi/stdlib.h @@ -150,4 +150,20 @@ static inline CHAR16 *ch8_2_ch16(char *str8) return str16; } +static inline char *ch16_2_ch8(CHAR16 *str16) +{ + UINTN len, i; + char *str8; + + len = StrLen(str16); + str8 = AllocatePool((len + 1) * sizeof(char)); + + for (i = 0; i < len; i++) + str8[i] = str16[i]; + + str8[len] = 0; + + return str8; +} + #endif /* __STDLIB_H__ */