Created
July 25, 2018 00:14
-
-
Save telent/a4fefdb7e21f97c38233a676a27db73e to your computer and use it in GitHub Desktop.
ralink-dtb.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff -x '*.o' -urw linux-4.14.53/arch/mips/generic/kexec.c linux-mine/arch/mips/generic/kexec.c | |
--- linux-4.14.53/arch/mips/generic/kexec.c 2018-07-03 09:25:05.000000000 +0000 | |
+++ linux-mine/arch/mips/generic/kexec.c 2018-07-23 22:09:23.337067165 +0000 | |
@@ -25,8 +25,12 @@ | |
if (copy_from_user(&fdt, image->segment[i].buf, sizeof(fdt))) | |
continue; | |
- if (fdt_check_header(&fdt)) | |
+ if (fdt_check_header(&fdt)) { | |
+ pr_info("seg %d has no fdt header\n", i); | |
continue; | |
+ } else { | |
+ pr_info("seg %d has fdt header\n", i); | |
+ } | |
kexec_args[0] = -2; | |
kexec_args[1] = (unsigned long) | |
diff -x '*.o' -urw linux-4.14.53/arch/mips/kernel/machine_kexec.c linux-mine/arch/mips/kernel/machine_kexec.c | |
--- linux-4.14.53/arch/mips/kernel/machine_kexec.c 2018-07-25 00:05:29.833892484 +0000 | |
+++ linux-mine/arch/mips/kernel/machine_kexec.c 2018-07-24 23:45:27.839135740 +0000 | |
@@ -27,14 +27,15 @@ | |
static void machine_kexec_print_args(void) | |
{ | |
- unsigned long argc = (int)kexec_args[0]; | |
+ long argc = (int)kexec_args[0]; | |
int i; | |
- pr_info("kexec_args[0] (argc): %lu\n", argc); | |
+ pr_info("kexec_args[0] (argc): %ld\n", argc); | |
pr_info("kexec_args[1] (argv): %p\n", (void *)kexec_args[1]); | |
pr_info("kexec_args[2] (env ): %p\n", (void *)kexec_args[2]); | |
pr_info("kexec_args[3] (desc): %p\n", (void *)kexec_args[3]); | |
+ if(argc<0) return; | |
for (i = 0; i < argc; i++) { | |
pr_info("kexec_argv[%d] = %p, %s\n", | |
i, kexec_argv[i], kexec_argv[i]); | |
diff -x '*.o' -urw linux-4.14.53/arch/mips/kernel/setup.c linux-mine/arch/mips/kernel/setup.c | |
--- linux-4.14.53/arch/mips/kernel/setup.c 2018-07-25 00:05:24.580913801 +0000 | |
+++ linux-mine/arch/mips/kernel/setup.c 2018-07-22 23:04:17.957066904 +0000 | |
@@ -852,5 +852,9 @@ | |
pr_info("Determined physical RAM map:\n"); | |
print_memory_map(); | |
+ pr_info("boot_command_line: %s\n", boot_command_line); | |
+ pr_info("arcs_cmdline: %s\n", arcs_cmdline); | |
+ pr_info("builtin_cmdline: %s\n", builtin_cmdline); | |
+ | |
#if defined(CONFIG_CMDLINE_BOOL) && defined(CONFIG_CMDLINE_OVERRIDE) | |
strlcpy(boot_command_line, builtin_cmdline, COMMAND_LINE_SIZE); | |
#else | |
if ((USE_PROM_CMDLINE && arcs_cmdline[0]) || | |
(USE_DTB_CMDLINE && !boot_command_line[0])) | |
diff -x '*.o' -urw linux-4.14.53/arch/mips/ralink/of.c linux-mine/arch/mips/ralink/of.c | |
--- linux-4.14.53/arch/mips/ralink/of.c 2018-07-25 00:05:25.535909925 +0000 | |
+++ linux-mine/arch/mips/ralink/of.c 2018-07-24 23:49:37.772127121 +0000 | |
@@ -19,6 +19,10 @@ | |
#include <linux/of_platform.h> | |
#include <linux/of_address.h> | |
+#include <linux/kexec.h> | |
+#include <linux/libfdt.h> | |
+#include <linux/uaccess.h> | |
+ | |
#include <asm/reboot.h> | |
#include <asm/bootinfo.h> | |
#include <asm/addrspace.h> | |
@@ -71,14 +75,52 @@ | |
static int __init early_init_dt_find_chosen(unsigned long node, const char *uname, | |
int depth, void *data) | |
{ | |
- if (depth == 1 && !strcmp(uname, "chosen")) | |
+ if (depth == 1 && !strcmp(uname, "chosen")) { | |
+ pr_info("found chosen node\n"); | |
chosen_dtb = 1; | |
- | |
+ } | |
return 0; | |
} | |
extern struct boot_param_header __image_dtb; | |
+static int | |
+ralink_kexec_prepare(struct kimage *image) | |
+{ | |
+ int i; | |
+ pr_info("ralink_kexec_prepare\n"); | |
+ for (i = 0; i < image->nr_segments; i++) { | |
+ struct fdt_header fdt; | |
+ | |
+ if (image->segment[i].memsz <= sizeof(fdt)) | |
+ continue; | |
+ | |
+ if (copy_from_user(&fdt, image->segment[i].buf, sizeof(fdt))) | |
+ continue; | |
+ | |
+ if (fdt_check_header(&fdt)) { | |
+ pr_info("seg %d has no fdt header\n", i); | |
+ continue; | |
+ } else { | |
+ pr_info("seg %d has fdt header\n", i); | |
+ } | |
+ | |
+ kexec_args[0] = -2; | |
+ kexec_args[1] = (unsigned long) | |
+ phys_to_virt((unsigned long)image->segment[i].mem); | |
+ break; | |
+ } | |
+ return 0; | |
+} | |
+ | |
+static int __init register_ralink_kexec(void) | |
+{ | |
+ pr_info("register ralink_kexec\n"); | |
+ _machine_kexec_prepare = ralink_kexec_prepare; | |
+ return 0; | |
+} | |
+arch_initcall(register_ralink_kexec); | |
+ | |
void __init plat_mem_setup(void) | |
{ | |
void *dtb = NULL; | |
@@ -90,12 +132,14 @@ | |
* parsed resulting in our memory appearing. fw_passed_dtb is used | |
* by CONFIG_MIPS_APPENDED_RAW_DTB as well. | |
*/ | |
+ pr_info("dtbs: %p %p %lx %p\n", fw_passed_dtb, __dtb_start, __dtb_end, &__image_dtb); | |
if (fw_passed_dtb) | |
dtb = (void *)fw_passed_dtb; | |
else if (__dtb_start != __dtb_end) | |
dtb = (void *)__dtb_start; | |
- | |
- __dt_setup_arch(&__image_dtb); | |
+ else | |
+ dtb = (void *) &__image_dtb; | |
+ __dt_setup_arch(dtb); | |
of_scan_flat_dt(early_init_dt_find_chosen, NULL); | |
if (chosen_dtb) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment