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