summaryrefslogtreecommitdiffstats
path: root/arch/mips/lib/bootm.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/mips/lib/bootm.c')
-rw-r--r--arch/mips/lib/bootm.c50
1 files changed, 29 insertions, 21 deletions
diff --git a/arch/mips/lib/bootm.c b/arch/mips/lib/bootm.c
index 5bb09cc2de..86573dec7f 100644
--- a/arch/mips/lib/bootm.c
+++ b/arch/mips/lib/bootm.c
@@ -1,3 +1,5 @@
+// SPDX-License-Identifier: GPL-2.0-only
+
#include <boot.h>
#include <bootm.h>
#include <common.h>
@@ -14,12 +16,21 @@
static int do_bootm_barebox(struct image_data *data)
{
- void (*barebox)(void);
+ void (*barebox)(int, void *);
+ void *fdt = NULL;
barebox = read_file(data->os_file, NULL);
if (!barebox)
return -EINVAL;
+ if (data->oftree_file) {
+ fdt = bootm_get_devicetree(data);
+ if (IS_ERR(fdt)) {
+ pr_err("Failed to load dtb\n");
+ return PTR_ERR(fdt);
+ }
+ }
+
if (data->dryrun) {
free(barebox);
return 0;
@@ -27,7 +38,7 @@ static int do_bootm_barebox(struct image_data *data)
shutdown_barebox();
- barebox();
+ barebox(-2, fdt);
restart_machine();
}
@@ -46,43 +57,40 @@ static struct binfmt_hook binfmt_barebox_hook = {
static int do_bootm_elf(struct image_data *data)
{
void (*entry)(int, void *);
- struct elf_image *elf;
- void *fdt, *buf;
+ void *fdt;
int ret = 0;
- buf = read_file(data->os_file, NULL);
- if (!buf)
- return -EINVAL;
-
- elf = elf_load_image(buf);
- if (IS_ERR(elf))
- return PTR_ERR(elf);
+ ret = bootm_load_os(data, data->os_address);
+ if (ret)
+ return ret;
fdt = bootm_get_devicetree(data);
if (IS_ERR(fdt)) {
- ret = PTR_ERR(fdt);
- goto bootm_elf_done;
+ pr_err("Failed to load dtb\n");
+ return PTR_ERR(fdt);
}
- pr_info("Starting application at 0x%08lx, dts 0x%08lx...\n",
- phys_to_virt(elf->entry), data->of_root_node);
+ pr_info("Starting application at 0x%08lx, dts 0x%p...\n",
+ data->os_address, data->of_root_node);
if (data->dryrun)
- goto bootm_elf_done;
+ goto bootm_free_fdt;
+
+ ret = of_overlay_load_firmware();
+ if (ret)
+ goto bootm_free_fdt;
shutdown_barebox();
- entry = (void *) (unsigned long) elf->entry;
+ entry = (void *) (unsigned long) data->os_address;
- entry(-2, phys_to_virt((unsigned long)fdt));
+ entry(-2, fdt);
pr_err("ELF application terminated\n");
ret = -EINVAL;
-bootm_elf_done:
- elf_release_image(elf);
+bootm_free_fdt:
free(fdt);
- free(buf);
return ret;
}