diff options
author | Lucas Stach <l.stach@pengutronix.de> | 2017-07-31 20:21:01 +0200 |
---|---|---|
committer | Lucas Stach <l.stach@pengutronix.de> | 2017-07-31 20:21:01 +0200 |
commit | d6d7441e90d7859c60cba8b9bc160d7d24692452 (patch) | |
tree | 31337dbe64d7006b5a1a399879c1915819041140 /common | |
parent | fcad2a76f7981320ef14592599c7955e985c264d (diff) | |
parent | 69d50079bb0bf5cc6db2c3376fec691208b25c40 (diff) | |
download | barebox-d6d7441e90d7859c60cba8b9bc160d7d24692452.tar.gz barebox-d6d7441e90d7859c60cba8b9bc160d7d24692452.tar.xz |
Merge branch 'for-next/efi'
Diffstat (limited to 'common')
-rw-r--r-- | common/blspec.c | 16 | ||||
-rw-r--r-- | common/efi/efi.c | 66 | ||||
-rw-r--r-- | common/state/backend_format_dtb.c | 2 | ||||
-rw-r--r-- | common/state/backend_format_raw.c | 2 | ||||
-rw-r--r-- | common/state/backend_storage.c | 2 |
5 files changed, 75 insertions, 13 deletions
diff --git a/common/blspec.c b/common/blspec.c index 8132d141ab..b258e6600b 100644 --- a/common/blspec.c +++ b/common/blspec.c @@ -361,6 +361,14 @@ static bool entry_is_of_compatible(struct blspec_entry *entry) const char *compat; char *filename; + /* If the entry doesn't specifiy a devicetree we are compatible */ + devicetree = blspec_entry_var_get(entry, "devicetree"); + if (!devicetree) + return true; + + if (!strcmp(devicetree, "none")) + return true; + /* If we don't have a root node every entry is compatible */ barebox_root = of_get_root_node(); if (!barebox_root) @@ -375,14 +383,6 @@ static bool entry_is_of_compatible(struct blspec_entry *entry) else abspath = ""; - /* If the entry doesn't specifiy a devicetree we are compatible */ - devicetree = blspec_entry_var_get(entry, "devicetree"); - if (!devicetree) - return true; - - if (!strcmp(devicetree, "none")) - return true; - filename = basprintf("%s/%s", abspath, devicetree); fdt = read_file(filename, &size); diff --git a/common/efi/efi.c b/common/efi/efi.c index 05c58250f4..4b42f5d676 100644 --- a/common/efi/efi.c +++ b/common/efi/efi.c @@ -40,6 +40,9 @@ #include <efi.h> #include <efi/efi.h> #include <efi/efi-device.h> +#include <libfile.h> +#include <state.h> +#include <bbu.h> efi_runtime_services_t *RT; efi_boot_services_t *BS; @@ -266,8 +269,7 @@ static int efi_console_init(void) add_generic_device("efi-stdio", DEVICE_ID_SINGLE, NULL, 0 , 0, 0, NULL); - if (IS_ENABLED(CONFIG_ARCH_EFI_REGISTER_COM1)) - add_ns16550_device(0, 0x3f8, 0x10, IORESOURCE_IO | IORESOURCE_MEM_8BIT, + add_ns16550_device(0, 0x3f8, 0x10, IORESOURCE_IO | IORESOURCE_MEM_8BIT, &ns16550_plat); return 0; @@ -381,10 +383,70 @@ static int efi_postcore_init(void) free(uuid16); } + bbu_register_std_file_update("fat", 0, "/boot/EFI/BOOT/BOOTx64.EFI", + filetype_exe); + return 0; } postcore_initcall(efi_postcore_init); +static int efi_late_init(void) +{ + char *state_desc; + int ret; + + if (!IS_ENABLED(CONFIG_STATE)) + return 0; + + state_desc = xasprintf("/boot/EFI/barebox/state.dtb"); + + if (state_desc) { + void *fdt; + size_t size; + struct device_node *root = NULL; + struct device_node *np = NULL; + struct state *state; + + fdt = read_file(state_desc, &size); + if (!fdt) { + pr_err("unable to read %s: %s\n", state_desc, + strerror(errno)); + return -errno; + } + + if (file_detect_type(fdt, size) != filetype_oftree) { + pr_err("%s is not an oftree file.\n", state_desc); + free(fdt); + return -EINVAL; + } + + root = of_unflatten_dtb(fdt); + + free(fdt); + + if (IS_ERR(root)) + return PTR_ERR(root); + + of_set_root_node(root); + + np = of_find_node_by_alias(root, "state"); + + state = state_new_from_node(np, NULL, 0, 0, false); + if (IS_ERR(state)) + return PTR_ERR(state); + + ret = state_load(state); + if (ret) + pr_warn("Failed to load persistent state, continuing with defaults, %d\n", + ret); + + return 0; + } + + return 0; +} +late_initcall(efi_late_init); + static int do_efiexit(int argc, char *argv[]) { return BS->exit(efi_parent_image, EFI_SUCCESS, 0, NULL); diff --git a/common/state/backend_format_dtb.c b/common/state/backend_format_dtb.c index e88cda499b..4c9d2eefc7 100644 --- a/common/state/backend_format_dtb.c +++ b/common/state/backend_format_dtb.c @@ -49,7 +49,7 @@ static int state_backend_format_dtb_verify(struct state_backend_format *format, size_t len = *lenp; if (dtb_len > len) { - dev_err(fdtb->dev, "Error, stored DTB length (%d) longer than read buffer (%d)\n", + dev_err(fdtb->dev, "Error, stored DTB length (%zd) longer than read buffer (%zd)\n", dtb_len, len); return -EINVAL; } diff --git a/common/state/backend_format_raw.c b/common/state/backend_format_raw.c index d76718cf82..2ba97e08a0 100644 --- a/common/state/backend_format_raw.c +++ b/common/state/backend_format_raw.c @@ -108,7 +108,7 @@ static int backend_format_raw_verify(struct state_backend_format *format, ssize_t complete_len; if (len < format_raw_min_length) { - dev_err(backend_raw->dev, "Error, buffer length (%d) is shorter than the minimum required header length\n", + dev_err(backend_raw->dev, "Error, buffer length (%zd) is shorter than the minimum required header length\n", len); return -EINVAL; } diff --git a/common/state/backend_storage.c b/common/state/backend_storage.c index 3249d0bca6..d2d1778915 100644 --- a/common/state/backend_storage.c +++ b/common/state/backend_storage.c @@ -247,7 +247,7 @@ static int state_storage_mtd_buckets_init(struct state_backend_storage *storage, end = meminfo->size; if (!IS_ALIGNED(storage->offset, meminfo->erasesize)) { - dev_err(storage->dev, "Offset within the device is not aligned to eraseblocks. Offset is %ld, erasesize %zu\n", + dev_err(storage->dev, "Offset within the device is not aligned to eraseblocks. Offset is %ld, erasesize %u\n", storage->offset, meminfo->erasesize); return -EINVAL; } |