diff options
Diffstat (limited to 'common')
-rw-r--r-- | common/block.c | 2 | ||||
-rw-r--r-- | common/efi/guid.c | 2 | ||||
-rw-r--r-- | common/efi/payload/Makefile | 1 | ||||
-rw-r--r-- | common/efi/payload/fdt.c | 43 | ||||
-rw-r--r-- | common/efi/payload/image.c | 14 |
5 files changed, 56 insertions, 6 deletions
diff --git a/common/block.c b/common/block.c index 19bb81df2c..a4cfd6e227 100644 --- a/common/block.c +++ b/common/block.c @@ -366,7 +366,7 @@ struct block_device *cdev_get_block_device(struct cdev *cdev) if (!cdev || cdev->ops != &block_ops) return NULL; - return container_of(cdev, struct block_device, cdev); + return cdev->priv; } int blockdevice_register(struct block_device *blk) diff --git a/common/efi/guid.c b/common/efi/guid.c index f16c597a20..ca16f4520f 100644 --- a/common/efi/guid.c +++ b/common/efi/guid.c @@ -11,8 +11,10 @@ efi_guid_t efi_unknown_device_guid = EFI_UNKNOWN_DEVICE_GUID; efi_guid_t efi_null_guid = EFI_NULL_GUID; efi_guid_t efi_global_variable_guid = EFI_GLOBAL_VARIABLE_GUID; efi_guid_t efi_block_io_protocol_guid = EFI_BLOCK_IO_PROTOCOL_GUID; +efi_guid_t efi_rng_protocol_guid = EFI_RNG_PROTOCOL_GUID; efi_guid_t efi_barebox_vendor_guid = EFI_BAREBOX_VENDOR_GUID; efi_guid_t efi_systemd_vendor_guid = EFI_SYSTEMD_VENDOR_GUID; +efi_guid_t efi_fdt_guid = EFI_DEVICE_TREE_GUID; #define EFI_GUID_STRING(guid, short, long) do { \ if (!efi_guidcmp(guid, *g)) \ diff --git a/common/efi/payload/Makefile b/common/efi/payload/Makefile index bcbdda335f..eeed046b00 100644 --- a/common/efi/payload/Makefile +++ b/common/efi/payload/Makefile @@ -2,5 +2,6 @@ obj-y += init.o obj-y += image.o +obj-$(CONFIG_OFTREE) += fdt.o bbenv-y += env-efi obj-$(CONFIG_CMD_IOMEM) += iomem.o diff --git a/common/efi/payload/fdt.c b/common/efi/payload/fdt.c new file mode 100644 index 0000000000..dbbc93fb7d --- /dev/null +++ b/common/efi/payload/fdt.c @@ -0,0 +1,43 @@ +// SPDX-License-Identifier: GPL-2.0 + +#define pr_fmt(fmt) "efi-fdt: " fmt + +#include <common.h> +#include <init.h> +#include <libfile.h> +#include <efi/efi-payload.h> +#include <efi/efi-device.h> + +static int efi_fdt_probe(void) +{ + efi_config_table_t *ect; + + for_each_efi_config_table(ect) { + struct fdt_header *oftree; + u32 magic, size; + int ret; + + if (efi_guidcmp(ect->guid, EFI_DEVICE_TREE_GUID)) + continue; + + oftree = (void *)ect->table; + magic = be32_to_cpu(oftree->magic); + + if (magic != FDT_MAGIC) { + pr_err("table has invalid magic 0x%08x\n", magic); + return -EILSEQ; + } + + size = be32_to_cpu(oftree->totalsize); + ret = write_file("/efi.dtb", oftree, size); + if (ret) { + pr_err("error saving /efi.dtb: %pe\n", ERR_PTR(ret)); + return ret; + } + + return 0; + } + + return 0; +} +late_initcall(efi_fdt_probe); diff --git a/common/efi/payload/image.c b/common/efi/payload/image.c index e63da9ddf0..8e39098ae8 100644 --- a/common/efi/payload/image.c +++ b/common/efi/payload/image.c @@ -133,9 +133,11 @@ static int efi_execute_image(const char *file) pr_debug("Linux kernel detected. Adding bootargs."); options = linux_bootargs_get(); pr_err("add linux options '%s'\n", options); - loaded_image->load_options = xstrdup_char_to_wchar(options); - loaded_image->load_options_size = - (strlen(options) + 1) * sizeof(wchar_t); + if (options) { + loaded_image->load_options = xstrdup_char_to_wchar(options); + loaded_image->load_options_size = + (strlen(options) + 1) * sizeof(wchar_t); + } shutdown_barebox(); } @@ -227,8 +229,10 @@ static int do_bootm_efi(struct image_data *data) } options = linux_bootargs_get(); - boot_header->cmd_line_ptr = (uint64_t)options; - boot_header->cmdline_size = strlen(options); + if (options) { + boot_header->cmd_line_ptr = (uint64_t)options; + boot_header->cmdline_size = strlen(options); + } boot_header->code32_start = (uint64_t)loaded_image->image_base + (image_header->setup_sects+1) * 512; |