From 338324dc66c15a8c8c92d73f14d0a489732abe1d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Revol?= Date: Sat, 25 Aug 2012 00:33:24 +0200 Subject: [PATCH] U-Boot: check for /chosen in the FDT for an initrd holding our tgz * since the FDT linux boot method doesn't pass the uimage, we can't use it to pass the kernel+driver tgz in a multi-file uimage. * instead we check for the linux initrd properties in the /chosen node. (cherry picked from my sam460ex branch) --- src/system/boot/platform/u-boot/start.cpp | 31 ++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/src/system/boot/platform/u-boot/start.cpp b/src/system/boot/platform/u-boot/start.cpp index c379aa1ab4..81b03bf03c 100644 --- a/src/system/boot/platform/u-boot/start.cpp +++ b/src/system/boot/platform/u-boot/start.cpp @@ -21,6 +21,12 @@ #include +extern "C" { +#include +#include +#include +}; + #define HEAP_SIZE (128 * 1024) @@ -171,12 +177,35 @@ start_raw(int argc, const char **argv) console_init(); cpu_init(); + // if we get passed an FDT, check /chosen for initrd + if (gFDT != NULL) { + int node = fdt_path_offset(gFDT, "/chosen"); + const void *prop; + int len; + phys_addr_t initrd_start = 0, initrd_end = 0; + + if (node >= 0) { + prop = fdt_getprop(gFDT, node, "linux,initrd-start", &len); + if (prop && len == 4) + initrd_start = fdt32_to_cpu(*(uint32_t *)prop); + prop = fdt_getprop(gFDT, node, "linux,initrd-end", &len); + if (prop && len == 4) + initrd_end = fdt32_to_cpu(*(uint32_t *)prop); + if (initrd_end > initrd_start) { + args.platform.boot_tgz_data = (void *)initrd_start; + args.platform.boot_tgz_size = initrd_end - initrd_start; + dprintf("Found boot tgz from FDT @ %p, %" B_PRIu32 " bytes\n", + args.platform.boot_tgz_data, args.platform.boot_tgz_size); + } + } + } + // if we get passed a uimage, try to find the second blob if (gUImage != NULL && image_multi_getimg(gUImage, 1, (uint32*)&args.platform.boot_tgz_data, &args.platform.boot_tgz_size)) { - dprintf("Found boot tgz @ %p, %" B_PRIu32 " bytes\n", + dprintf("Found boot tgz from uimage @ %p, %" B_PRIu32 " bytes\n", args.platform.boot_tgz_data, args.platform.boot_tgz_size); }