[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 6/6] hw/arm/boot: enable DTB support when booting EL
From: |
Ard Biesheuvel |
Subject: |
[Qemu-devel] [PATCH 6/6] hw/arm/boot: enable DTB support when booting ELF images |
Date: |
Fri, 5 Sep 2014 17:15:26 +0200 |
Add support for loading DTB images when booting ELF images via -kernel.
The DTB image is located at the next 4 KB boundary above the highest address
covered by the loaded ELF image.
Signed-off-by: Ard Biesheuvel <address@hidden>
---
hw/arm/boot.c | 18 ++++++++++++++++--
1 file changed, 16 insertions(+), 2 deletions(-)
diff --git a/hw/arm/boot.c b/hw/arm/boot.c
index 8d8653978dfe..60c4f6af7884 100644
--- a/hw/arm/boot.c
+++ b/hw/arm/boot.c
@@ -458,7 +458,7 @@ void arm_load_kernel(ARMCPU *cpu, struct arm_boot_info
*info)
int kernel_size;
int initrd_size;
int is_linux = 0;
- uint64_t elf_entry;
+ uint64_t elf_entry, elf_low_addr;
int elf_machine;
hwaddr entry, kernel_load_offset;
int big_endian;
@@ -529,7 +529,21 @@ void arm_load_kernel(ARMCPU *cpu, struct arm_boot_info
*info)
/* Assume that raw images are linux kernels, and ELF images are not. */
kernel_size = load_elf(info->kernel_filename, NULL, NULL, &elf_entry,
- NULL, NULL, big_endian, elf_machine, 1);
+ &elf_low_addr, NULL, big_endian, elf_machine, 1);
+ if (kernel_size > 0 && have_dtb(info)) {
+ /* If we have a DTB in combination with an ELF executable image,
+ * put the DTB at the base of RAM like we do for bootloaders.
+ */
+ uint32_t dtb_size;
+
+ if (load_dtb(info->loader_start, info, &dtb_size)) {
+ exit(1);
+ }
+ if (info->loader_start + dtb_size > elf_low_addr) {
+ fprintf(stderr, "Image %s overlaps DTB\n", info->kernel_filename);
+ exit(1);
+ }
+ }
entry = elf_entry;
if (kernel_size < 0) {
kernel_size = load_uimage(info->kernel_filename, &entry, NULL,
--
1.8.3.2
- Re: [Qemu-devel] [PATCH 3/6] hw/arm/boot: load device tree to base of DRAM if no -kernel option was passed, (continued)