summaryrefslogtreecommitdiffstats
path: root/arch/arm/lib64/armlinux.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/arm/lib64/armlinux.c')
-rw-r--r--arch/arm/lib64/armlinux.c98
1 files changed, 33 insertions, 65 deletions
diff --git a/arch/arm/lib64/armlinux.c b/arch/arm/lib64/armlinux.c
index afa56792fb..3b108b21cb 100644
--- a/arch/arm/lib64/armlinux.c
+++ b/arch/arm/lib64/armlinux.c
@@ -1,86 +1,35 @@
-/*
- * Copyright (C) 2018 Sascha Hauer <s.hauer@pengutronix.de>
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; version 2.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- */
-
-#include <boot.h>
+// SPDX-License-Identifier: GPL-2.0-only
+// SPDX-FileCopyrightText: 2018 Sascha Hauer <s.hauer@pengutronix.de>
+
#include <common.h>
-#include <environment.h>
-#include <image.h>
-#include <fs.h>
-#include <xfuncs.h>
-#include <malloc.h>
-#include <fcntl.h>
-#include <errno.h>
#include <memory.h>
-#include <of.h>
#include <init.h>
#include <bootm.h>
-#include <linux/list.h>
-#include <asm/byteorder.h>
-#include <asm/setup.h>
-#include <asm/barebox-arm.h>
-#include <asm/armlinux.h>
-#include <asm/system.h>
+#include <efi/efi-mode.h>
static int do_bootm_linux(struct image_data *data)
{
void (*fn)(unsigned long dtb, unsigned long x1, unsigned long x2,
unsigned long x3);
- resource_size_t start, end;
- unsigned long text_offset, image_size, devicetree, kernel;
+ phys_addr_t devicetree;
int ret;
- void *fdt;
-
- text_offset = le64_to_cpup(data->os_header + 8);
- image_size = le64_to_cpup(data->os_header + 16);
-
- ret = memory_bank_first_find_space(&start, &end);
- if (ret)
- goto out;
-
- kernel = ALIGN(start, SZ_2M) + text_offset;
-
- ret = bootm_load_os(data, kernel);
- if (ret)
- goto out;
-
- devicetree = ALIGN(kernel + image_size, PAGE_SIZE);
-
- fdt = bootm_get_devicetree(data);
- if (IS_ERR(fdt)) {
- ret = PTR_ERR(fdt);
- goto out;
- }
- ret = bootm_load_devicetree(data, fdt, devicetree);
+ fn = booti_load_image(data, &devicetree);
+ if (IS_ERR(fn))
+ return PTR_ERR(fn);
- free(fdt);
+ if (data->dryrun)
+ return 0;
+ ret = of_overlay_load_firmware();
if (ret)
- goto out;
-
- printf("Loaded kernel to 0x%08lx, devicetree at 0x%08lx\n",
- kernel, devicetree);
+ return ret;
shutdown_barebox();
- fn = (void *)kernel;
-
fn(devicetree, 0, 0, 0);
- ret = -EINVAL;
-
-out:
- return ret;
+ return -EINVAL;
}
static struct image_handler aarch64_linux_handler = {
@@ -89,6 +38,18 @@ static struct image_handler aarch64_linux_handler = {
.filetype = filetype_arm64_linux_image,
};
+static struct image_handler aarch64_linux_efi_handler = {
+ .name = "ARM aarch64 Linux/EFI image",
+ .bootm = do_bootm_linux,
+ .filetype = filetype_arm64_efi_linux_image,
+};
+
+static struct image_handler aarch64_fit_handler = {
+ .name = "FIT image",
+ .bootm = do_bootm_linux,
+ .filetype = filetype_oftree,
+};
+
static int do_bootm_barebox(struct image_data *data)
{
void (*fn)(unsigned long x0, unsigned long x1, unsigned long x2,
@@ -101,7 +62,7 @@ static int do_bootm_barebox(struct image_data *data)
if (ret)
goto out;
- barebox = start;
+ barebox = PAGE_ALIGN(start);
ret = bootm_load_os(data, barebox);
if (ret)
@@ -129,9 +90,16 @@ static struct image_handler aarch64_barebox_handler = {
static int aarch64_register_image_handler(void)
{
+ if (efi_is_payload())
+ return 0;
+
+ register_image_handler(&aarch64_linux_efi_handler);
register_image_handler(&aarch64_linux_handler);
register_image_handler(&aarch64_barebox_handler);
+ if (IS_ENABLED(CONFIG_FITIMAGE))
+ register_image_handler(&aarch64_fit_handler);
+
return 0;
}
late_initcall(aarch64_register_image_handler);