summaryrefslogtreecommitdiff
path: root/kexec/arch/mips/kexec-elf-mips.c
diff options
context:
space:
mode:
authorMarcin Nowakowski <marcin.nowakowski@imgtec.com>2016-12-02 10:49:11 +0100
committerSimon Horman <horms@verge.net.au>2016-12-09 08:56:34 +0100
commit6d972b95c6d9d980d53bbe4e85d471ccae72140e (patch)
treeff2e18a21290fd6c6ad365d44b1eba7447e60a9b /kexec/arch/mips/kexec-elf-mips.c
parent83a53ce9248fbcdf9dcac507b895d818db8c1706 (diff)
mips: add option to load initrd from a specified file
Use kexec's existing infrastrucutre for supporting initrd loading. The initrd image is loaded into a buffer after the dtb and its details passed through the device tree, so it's supported on newer platforms that make use of the device tree passed from kexec. Signed-off-by: Marcin Nowakowski <marcin.nowakowski@imgtec.com> Cc: Ralf Baechle <ralf@linux-mips.org> Cc: linux-mips@linux-mips.org Signed-off-by: Simon Horman <horms@verge.net.au>
Diffstat (limited to 'kexec/arch/mips/kexec-elf-mips.c')
-rw-r--r--kexec/arch/mips/kexec-elf-mips.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/kexec/arch/mips/kexec-elf-mips.c b/kexec/arch/mips/kexec-elf-mips.c
index 6ca7ca0..849a7ba 100644
--- a/kexec/arch/mips/kexec-elf-mips.c
+++ b/kexec/arch/mips/kexec-elf-mips.c
@@ -79,6 +79,7 @@ int elf_mips_load(int argc, char **argv, const char *buf, off_t len,
size_t i;
off_t dtb_length;
char *dtb_buf;
+ char *initrd_buf = NULL;
unsigned long long kernel_addr = 0, kernel_size = 0;
unsigned long pagesize = getpagesize();
@@ -152,6 +153,24 @@ int elf_mips_load(int argc, char **argv, const char *buf, off_t len,
create_flatten_tree(&dtb_buf, &dtb_length, cmdline_buf + strlen(CMDLINE_PREFIX));
}
+ if (arch_options.initrd_file) {
+ initrd_buf = slurp_file(arch_options.initrd_file, &initrd_size);
+
+ /* Create initrd entries in dtb - although at this time
+ * they would not point to the correct location */
+ dtb_set_initrd(&dtb_buf, &dtb_length, initrd_buf, initrd_buf + initrd_size);
+
+ initrd_base = add_buffer(info, initrd_buf, initrd_size,
+ initrd_size, sizeof(void *),
+ _ALIGN_UP(kernel_addr + kernel_size + dtb_length,
+ pagesize), 0x0fffffff, 1);
+
+ /* Now that the buffer for initrd is prepared, update the dtb
+ * with an appropriate location */
+ dtb_set_initrd(&dtb_buf, &dtb_length, initrd_base, initrd_base + initrd_size);
+ }
+
+
/* This is a legacy method for commandline passing used
* currently by Octeon CPUs only */
add_buffer(info, cmdline_buf, sizeof(cmdline_buf),