From 6d972b95c6d9d980d53bbe4e85d471ccae72140e Mon Sep 17 00:00:00 2001 From: Marcin Nowakowski Date: Fri, 2 Dec 2016 10:49:11 +0100 Subject: 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 Cc: Ralf Baechle Cc: linux-mips@linux-mips.org Signed-off-by: Simon Horman --- kexec/arch/mips/kexec-elf-mips.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'kexec/arch/mips/kexec-elf-mips.c') 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), -- cgit