hv: pass the cmdline to hypervisor

That can allow the user to pass the cmdline to hypervisor
from UEFI Shell or BIOS. For example:

Shell> EFI\acrn\acrn.efi bootloader=\EFI\org.clearlinux\bootloaderx64.efi uart=mmio@0x91230000

$ sudo efibootmgr -c -l "\EFI\acrn\acrn.efi" -d /dev/sda -p 1 -L \
"ACRN Hypervisor" -u "bootloader=\EFI\org.clearlinux\bootloaderx64.efi uart=mmio@0x91230000"

Signed-off-by: Jack Ren <jack.ren@intel.com>
Signed-off-by: Jason Chen CJ <jason.cj.chen@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
This commit is contained in:
Jack Ren 2018-05-20 13:26:41 +08:00 committed by lijinxia
parent 160df8433a
commit 6d3ceaef98
2 changed files with 28 additions and 3 deletions

View File

@ -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)) {

View File

@ -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__ */