Compare commits

...

1 Commits
prof ... rd2

Author SHA1 Message Date
Simon Glass
40716ecf7e efi_loader: Support loading a ramdisk with bootefi
It is sometimes useful to be able to boot via EFI using a ramdisk. Add
support for this.

Fix a 'specifiy' typo while here.

Series-to: heinrich
Series-version: 1
Series-changes: 1
- Drop mention of the '-' argument-value as it is not needed

Fixes: #8
2025-06-10 08:53:13 -06:00
2 changed files with 31 additions and 11 deletions

View File

@@ -133,23 +133,34 @@ static int do_bootefi(struct cmd_tbl *cmdtp, int flag, int argc,
{
efi_status_t ret;
char *p;
void *fdt, *image_buf;
unsigned long addr, size;
void *fdt, *ramdisk = NULL, *image_buf;
unsigned long addr, size, rd_len = 0, fdt_addr = 0;
void *image_addr;
size_t image_size;
if (argc < 2)
return CMD_RET_USAGE;
if (argc > 2) {
uintptr_t fdt_addr;
if (argc > 3) {
ulong rd_addr = 0;
char *end = NULL;
rd_addr = hextoul(argv[2], NULL);
end = strchr(argv[2], ':');
if (!end)
return CMD_RET_USAGE;
rd_len = hextoul(++end, NULL);
ramdisk = map_sysmem(rd_addr, rd_len);
fdt_addr = hextoul(argv[3], NULL);
} else if (argc > 2) {
fdt_addr = hextoul(argv[2], NULL);
fdt = map_sysmem(fdt_addr, 0);
} else {
fdt = EFI_FDT_USE_INTERNAL;
}
if (fdt_addr)
fdt = map_sysmem(fdt_addr, 0);
else
fdt = EFI_FDT_USE_INTERNAL;
if (IS_ENABLED(CONFIG_CMD_BOOTEFI_BOOTMGR) &&
!strcmp(argv[1], "bootmgr")) {
ret = efi_bootmgr_run(fdt);
@@ -212,7 +223,7 @@ static int do_bootefi(struct cmd_tbl *cmdtp, int flag, int argc,
}
}
ret = efi_binary_run(image_buf, size, fdt, NULL, 0);
ret = efi_binary_run(image_buf, size, fdt, ramdisk, rd_len);
if (ret != EFI_SUCCESS)
return CMD_RET_FAILURE;
@@ -221,7 +232,7 @@ static int do_bootefi(struct cmd_tbl *cmdtp, int flag, int argc,
}
U_BOOT_LONGHELP(bootefi,
"<image address>[:<image size>] [<fdt address>]\n"
"<image address>[:<image size>] [<ramdisk_address>:<size>] [<fdt address>]\n"
" - boot EFI payload\n"
#ifdef CONFIG_CMD_BOOTEFI_HELLO
"bootefi hello\n"

View File

@@ -12,7 +12,7 @@ Synopsis
::
bootefi <image_addr>[:<image_size>] [<fdt_addr>]
bootefi <image_addr>[:<image_size>] [<ramdisk_addr>] [<fdt_addr>]
bootefi bootmgr [<fdt_addr>]
bootefi hello [<fdt_addr>]
bootefi selftest [<fdt_addr>]
@@ -51,11 +51,20 @@ The value of the environment variable *bootargs* is converted from UTF-8 to
UTF-16 and passed as load options in the loaded image protocol to the UEFI
binary.
Note: The 'bootefi' command accepts one, two or three arguments. When two
arguments are provided, the second one is interpreted as `fdt_addr`. When three
are provided, the second one is interpreted as `ramdisk_addr` and the third as
`fdt_addr`.
image_addr
Address of the UEFI binary.
ramdisk_addr
Address of the ramdisk or '-'. If no address is specified, a ramdisk is not
used when booting.
fdt_addr
Address of the device-tree or '-'. If no address is specifiy, the
Address of the device-tree or '-'. If no address is specified, the
environment variable $fdt_addr is used as first fallback, the address of
U-Boot's internal device-tree $fdtcontroladdr as second fallback.
When using ACPI no device-tree shall be specified.