Fixes the MAC address handling on avila NPE on startup
[openwrt.git] / target / linux / ixp4xx / patches-2.6.23 / 001-kexec_atags.patch
1 diff -uprN linux-2.6.23.orig/arch/arm/kernel/relocate_kernel.S linux-2.6.23/arch/arm/kernel/relocate_kernel.S
2 --- linux-2.6.23.orig/arch/arm/kernel/relocate_kernel.S 2007-10-09 15:31:38.000000000 -0500
3 +++ linux-2.6.23/arch/arm/kernel/relocate_kernel.S      2007-10-09 22:19:32.000000000 -0500
4 @@ -7,6 +7,23 @@
5         .globl relocate_new_kernel
6  relocate_new_kernel:
7  
8 +       /* Move boot params back to where the kernel expects them */
9 +
10 +       ldr     r0,kexec_boot_params_address
11 +       teq     r0,#0
12 +       beq     8f
13 +
14 +       ldr     r1,kexec_boot_params_copy
15 +       mov     r6,#KEXEC_BOOT_PARAMS_SIZE/4
16 +7:
17 +       ldr     r5,[r1],#4
18 +       str     r5,[r0],#4
19 +       subs    r6,r6,#1
20 +       bne     7b
21 +
22 +8:
23 +       /* Boot params moved, now go on with the kernel */
24 +
25         ldr     r0,kexec_indirection_page
26         ldr     r1,kexec_start_address
27  
28 @@ -50,7 +67,7 @@ relocate_new_kernel:
29         mov lr,r1
30         mov r0,#0
31         ldr r1,kexec_mach_type
32 -       mov r2,#0
33 +       ldr r2,kexec_boot_params_address
34         mov pc,lr
35  
36         .globl kexec_start_address
37 @@ -65,6 +82,16 @@ kexec_indirection_page:
38  kexec_mach_type:
39         .long   0x0
40  
41 +       /* phy addr where new kernel will expect to find boot params */
42 +       .globl kexec_boot_params_address
43 +kexec_boot_params_address:
44 +       .long   0x0
45 +
46 +       /* phy addr where old kernel put a copy of orig boot params */
47 +       .globl kexec_boot_params_copy
48 +kexec_boot_params_copy:
49 +       .long   0x0
50 +
51  relocate_new_kernel_end:
52  
53         .globl relocate_new_kernel_size
54 diff -uprN linux-2.6.23.orig/arch/arm/kernel/setup.c linux-2.6.23/arch/arm/kernel/setup.c
55 --- linux-2.6.23.orig/arch/arm/kernel/setup.c   2007-10-09 15:31:38.000000000 -0500
56 +++ linux-2.6.23/arch/arm/kernel/setup.c        2007-10-09 20:06:10.000000000 -0500
57 @@ -24,6 +24,7 @@
58  #include <linux/interrupt.h>
59  #include <linux/smp.h>
60  #include <linux/fs.h>
61 +#include <linux/kexec.h>
62  
63  #include <asm/cpu.h>
64  #include <asm/elf.h>
65 @@ -770,6 +771,23 @@ static int __init customize_machine(void
66  }
67  arch_initcall(customize_machine);
68  
69 +#ifdef CONFIG_KEXEC
70 +
71 +/* Physical addr of where the boot params should be for this machine */
72 +extern unsigned long kexec_boot_params_address;
73 +
74 +/* Physical addr of the buffer into which the boot params are copied */
75 +extern unsigned long kexec_boot_params_copy;
76 +
77 +/* Pointer to the boot params buffer, for manipulation and display */
78 +unsigned long kexec_boot_params;
79 +EXPORT_SYMBOL(kexec_boot_params);
80 +
81 +/* The buffer itself - make sure it is sized correctly */
82 +static unsigned long kexec_boot_params_buf[(KEXEC_BOOT_PARAMS_SIZE + 3) / 4];
83 +
84 +#endif
85 +
86  void __init setup_arch(char **cmdline_p)
87  {
88         struct tag *tags = (struct tag *)&init_tags;
89 @@ -788,6 +806,18 @@ void __init setup_arch(char **cmdline_p)
90         else if (mdesc->boot_params)
91                 tags = phys_to_virt(mdesc->boot_params);
92  
93 +#ifdef CONFIG_KEXEC
94 +       kexec_boot_params_copy = virt_to_phys(kexec_boot_params_buf);
95 +       kexec_boot_params = (unsigned long)kexec_boot_params_buf;
96 +       if (__atags_pointer) {
97 +               kexec_boot_params_address = __atags_pointer;
98 +               memcpy((void *)kexec_boot_params, tags, KEXEC_BOOT_PARAMS_SIZE);
99 +       } else if (mdesc->boot_params) {
100 +               kexec_boot_params_address = mdesc->boot_params;
101 +               memcpy((void *)kexec_boot_params, tags, KEXEC_BOOT_PARAMS_SIZE);
102 +       }
103 +#endif
104 +
105         /*
106          * If we have the old style parameters, convert them to
107          * a tag list.
108 diff -uprN linux-2.6.23.orig/include/asm-arm/kexec.h linux-2.6.23/include/asm-arm/kexec.h
109 --- linux-2.6.23.orig/include/asm-arm/kexec.h   2007-10-09 15:31:38.000000000 -0500
110 +++ linux-2.6.23/include/asm-arm/kexec.h        2007-10-09 22:19:32.000000000 -0500
111 @@ -14,6 +14,8 @@
112  
113  #define KEXEC_ARCH KEXEC_ARCH_ARM
114  
115 +#define KEXEC_BOOT_PARAMS_SIZE 1536
116 +
117  #ifndef __ASSEMBLY__
118  
119  struct kimage;