adds several fixes to etrax, make openssl work on etrax
[openwrt.git] / target / linux / etrax / patches / 100-compile_fixes.patch
1 diff -urN linux-2.6.25.7/arch/cris/Makefile linux-2.6.25.7.cris/arch/cris/Makefile
2 --- linux-2.6.25.7/arch/cris/Makefile   2008-06-16 22:24:36.000000000 +0200
3 +++ linux-2.6.25.7.cris/arch/cris/Makefile      2008-06-24 13:22:48.000000000 +0200
4 @@ -33,7 +33,7 @@
5  
6  LD = $(CROSS_COMPILE)ld -mcrislinux
7  
8 -OBJCOPYFLAGS := -O binary -R .note -R .comment -S
9 +OBJCOPYFLAGS := -O binary -R .bss -R .note -R .note.gnu.build-id -R .comment -S
10  
11  CPPFLAGS_vmlinux.lds = -DDRAM_VIRTUAL_BASE=0x$(CONFIG_ETRAX_DRAM_VIRTUAL_BASE)
12  
13 diff -urN linux-2.6.25.7/arch/cris/arch-v10/boot/Makefile linux-2.6.25.7.cris/arch/cris/arch-v10/boot/Makefile
14 --- linux-2.6.25.7/arch/cris/arch-v10/boot/Makefile     2008-06-16 22:24:36.000000000 +0200
15 +++ linux-2.6.25.7.cris/arch/cris/arch-v10/boot/Makefile        2008-06-24 13:23:03.000000000 +0200
16 @@ -2,9 +2,6 @@
17  # arch/cris/arch-v10/boot/Makefile
18  #
19  
20 -OBJCOPY = objcopy-cris
21 -OBJCOPYFLAGS = -O binary --remove-section=.bss
22 -
23  subdir- := compressed rescue
24  targets := Image
25  
26 @@ -14,7 +11,6 @@
27  
28  $(obj)/compressed/vmlinux: $(obj)/Image FORCE
29         $(Q)$(MAKE) $(build)=$(obj)/compressed $@
30 -       $(Q)$(MAKE) $(build)=$(obj)/rescue $(obj)/rescue/rescue.bin
31  
32  $(obj)/zImage:  $(obj)/compressed/vmlinux
33         @cp $< $@
34 diff -urN linux-2.6.25.7/arch/cris/arch-v10/boot/compressed/Makefile linux-2.6.25.7.cris/arch/cris/arch-v10/boot/compressed/Makefile
35 --- linux-2.6.25.7/arch/cris/arch-v10/boot/compressed/Makefile  2008-06-16 22:24:36.000000000 +0200
36 +++ linux-2.6.25.7.cris/arch/cris/arch-v10/boot/compressed/Makefile     2008-06-24 13:23:14.000000000 +0200
37 @@ -2,13 +2,9 @@
38  # arch/cris/arch-v10/boot/compressed/Makefile
39  #
40  
41 -CC = gcc-cris -melf $(LINUXINCLUDE)
42  ccflags-y += -O2
43 -LD = ld-cris
44  ldflags-y += -T $(obj)/decompress.ld
45  OBJECTS = $(obj)/head.o $(obj)/misc.o
46 -OBJCOPY = objcopy-cris
47 -OBJCOPYFLAGS = -O binary --remove-section=.bss
48  
49  quiet_cmd_image = BUILD   $@
50  cmd_image = cat $(obj)/decompress.bin $(obj)/piggy.gz > $@
51 @@ -22,10 +18,10 @@
52         $(call if_changed,objcopy)
53  
54  $(obj)/head.o: $(obj)/head.S .config
55 -       @$(CC) -D__ASSEMBLY__ -traditional -c $< -o $@
56 +       @$(CC) -Iinclude  -D__ASSEMBLY__ -traditional -Wa,--em=criself -c $< -o $@
57  
58  $(obj)/misc.o: $(obj)/misc.c .config
59 -       @$(CC) -D__KERNEL__ -c $< -o $@
60 +       @$(CC) -Iinclude -D__KERNEL__ -Wa,--em=criself -c $< -o $@
61  
62  $(obj)/vmlinux: $(obj)/piggy.gz $(obj)/decompress.bin FORCE
63         $(call if_changed,image)
64 diff -urN linux-2.6.25.7/arch/cris/arch-v10/boot/compressed/decompress.ld linux-2.6.25.7.cris/arch/cris/arch-v10/boot/compressed/decompress.ld
65 --- linux-2.6.25.7/arch/cris/arch-v10/boot/compressed/decompress.ld     2008-06-16 22:24:36.000000000 +0200
66 +++ linux-2.6.25.7.cris/arch/cris/arch-v10/boot/compressed/decompress.ld        2008-06-24 12:57:25.000000000 +0200
67 @@ -1,4 +1,4 @@
68 -OUTPUT_FORMAT(elf32-us-cris)
69 +OUTPUT_FORMAT(elf32-cris)
70  
71  MEMORY 
72         {
73 diff -urN linux-2.6.25.7/arch/cris/arch-v10/boot/compressed/head.S linux-2.6.25.7.cris/arch/cris/arch-v10/boot/compressed/head.S
74 --- linux-2.6.25.7/arch/cris/arch-v10/boot/compressed/head.S    2008-06-16 22:24:36.000000000 +0200
75 +++ linux-2.6.25.7.cris/arch/cris/arch-v10/boot/compressed/head.S       2008-06-24 13:24:50.000000000 +0200
76 @@ -10,13 +10,14 @@
77  
78  #define ASSEMBLER_MACROS_ONLY
79  #include <asm/arch/sv_addr_ag.h>
80 +#include <linux/autoconf.h>
81  
82  #define RAM_INIT_MAGIC 0x56902387
83  #define COMMAND_LINE_MAGIC 0x87109563
84  
85         ;; Exported symbols
86         
87 -       .globl  _input_data
88 +       .globl  input_data
89  
90         
91         .text
92 @@ -26,7 +27,7 @@
93  
94  ;; We need to initialze DRAM registers before we start using the DRAM
95         
96 -       cmp.d   RAM_INIT_MAGIC, r8      ; Already initialized?
97 +       cmp.d   RAM_INIT_MAGIC, $r8     ; Already initialized?
98         beq     dram_init_finished
99         nop
100         
101 @@ -36,91 +37,91 @@
102                 
103         ;; Initiate the PA and PB ports
104  
105 -       move.b   CONFIG_ETRAX_DEF_R_PORT_PA_DATA, r0
106 -       move.b   r0, [R_PORT_PA_DATA]
107 +       move.b   CONFIG_ETRAX_DEF_R_PORT_PA_DATA, $r0
108 +       move.b   $r0, [R_PORT_PA_DATA]
109  
110 -       move.b   CONFIG_ETRAX_DEF_R_PORT_PA_DIR, r0
111 -       move.b   r0, [R_PORT_PA_DIR]
112 +       move.b   CONFIG_ETRAX_DEF_R_PORT_PA_DIR, $r0
113 +       move.b   $r0, [R_PORT_PA_DIR]
114  
115 -       move.b   CONFIG_ETRAX_DEF_R_PORT_PB_DATA, r0
116 -       move.b   r0, [R_PORT_PB_DATA]
117 +       move.b   CONFIG_ETRAX_DEF_R_PORT_PB_DATA, $r0
118 +       move.b   $r0, [R_PORT_PB_DATA]
119  
120 -       move.b   CONFIG_ETRAX_DEF_R_PORT_PB_DIR, r0
121 -       move.b   r0, [R_PORT_PB_DIR]
122 +       move.b   CONFIG_ETRAX_DEF_R_PORT_PB_DIR, $r0
123 +       move.b   $r0, [R_PORT_PB_DIR]
124  
125         ;; Setup the stack to a suitably high address.
126         ;; We assume 8 MB is the minimum DRAM in an eLinux
127         ;; product and put the sp at the top for now.
128  
129 -       move.d  0x40800000, sp
130 +       move.d  0x40800000, $sp
131  
132         ;; Figure out where the compressed piggyback image is
133         ;; in the flash (since we wont try to copy it to DRAM
134         ;; before unpacking). It is at _edata, but in flash.
135         ;; Use (_edata - basse) as offset to the current PC.
136         
137 -basse: move.d  pc, r5
138 -       and.d   0x7fffffff, r5  ; strip any non-cache bit
139 -       subq    2, r5           ; compensate for the move.d pc instr
140 -       move.d  r5, r0          ; save for later - flash address of 'basse'
141 -       add.d   _edata, r5
142 -       sub.d   basse, r5       ; r5 = flash address of '_edata'
143 +basse: move.d  $pc, $r5
144 +       and.d   0x7fffffff, $r5 ; strip any non-cache bit
145 +       subq    2, $r5          ; compensate for the move.d pc instr
146 +       move.d  $r5, $r0                ; save for later - flash address of 'basse'
147 +       add.d   _edata, $r5
148 +       sub.d   basse, $r5      ; r5 = flash address of '_edata'
149         
150         ;; Copy text+data to DRAM
151         
152 -       move.d  basse, r1       ; destination
153 -       move.d  _edata, r2      ; end destination
154 -1:     move.w  [r0+], r3
155 -       move.w  r3, [r1+]
156 -       cmp.d   r2, r1
157 +       move.d  basse, $r1      ; destination
158 +       move.d  _edata, $r2     ; end destination
159 +1:     move.w  [$r0+], $r3
160 +       move.w  $r3, [$r1+]
161 +       cmp.d   $r2, $r1
162         bcs     1b
163         nop
164  
165 -       move.d  r5, [_input_data] ; for the decompressor
166 +       move.d  $r5, [input_data] ; for the decompressor
167  
168  
169         ;; Clear the decompressors BSS (between _edata and _end)
170         
171 -       moveq   0, r0
172 -       move.d  _edata, r1
173 -       move.d  _end, r2
174 -1:     move.w  r0, [r1+]
175 -       cmp.d   r2, r1
176 +       moveq   0, $r0
177 +       move.d  _edata, $r1
178 +       move.d  _end, $r2
179 +1:     move.w  $r0, [$r1+]
180 +       cmp.d   $r2, $r1
181         bcs     1b
182         nop
183  
184         ;;  Save command line magic and address.
185 -       move.d  _cmd_line_magic, $r12
186 +       move.d  cmd_line_magic, $r12
187         move.d  $r10, [$r12]
188 -       move.d  _cmd_line_addr, $r12
189 +       move.d  cmd_line_addr, $r12
190         move.d  $r11, [$r12]
191         
192         ;; Do the decompression and save compressed size in _inptr
193  
194 -       jsr     _decompress_kernel
195 +       jsr     decompress_kernel
196         
197         ;; Put start address of root partition in r9 so the kernel can use it
198         ;; when mounting from flash
199  
200 -       move.d  [_input_data], r9       ; flash address of compressed kernel
201 -       add.d   [_inptr], r9            ; size of compressed kernel
202 +       move.d  [input_data], $r9       ; flash address of compressed kernel
203 +       add.d   [inptr], $r9            ; size of compressed kernel
204  
205         ;; Restore command line magic and address.
206 -       move.d  _cmd_line_magic, $r10
207 +       move.d  cmd_line_magic, $r10
208         move.d  [$r10], $r10
209 -       move.d  _cmd_line_addr, $r11
210 +       move.d  cmd_line_addr, $r11
211         move.d  [$r11], $r11
212  
213         ;; Enter the decompressed kernel
214 -       move.d  RAM_INIT_MAGIC, r8      ; Tell kernel that DRAM is initialized
215 +       move.d  RAM_INIT_MAGIC, $r8     ; Tell kernel that DRAM is initialized
216         jump    0x40004000      ; kernel is linked to this address
217         
218         .data
219  
220 -_input_data:
221 +input_data:
222         .dword  0               ; used by the decompressor
223 -_cmd_line_magic:
224 +cmd_line_magic:
225         .dword 0
226 -_cmd_line_addr:
227 +cmd_line_addr:
228         .dword 0
229  #include "../../lib/hw_settings.S"
230 diff -urN linux-2.6.25.7/arch/cris/arch-v10/boot/compressed/misc.c linux-2.6.25.7.cris/arch/cris/arch-v10/boot/compressed/misc.c
231 --- linux-2.6.25.7/arch/cris/arch-v10/boot/compressed/misc.c    2008-06-16 22:24:36.000000000 +0200
232 +++ linux-2.6.25.7.cris/arch/cris/arch-v10/boot/compressed/misc.c       2008-06-24 12:57:25.000000000 +0200
233 @@ -5,7 +5,7 @@
234   * adapted for Linux.
235   *
236   * malloc by Hannu Savolainen 1993 and Matthias Urlichs 1994
237 - * puts by Nick Holloway 1993, better puts by Martin Mares 1995
238 + * putstr by Nick Holloway 1993, better putstr by Martin Mares 1995
239   * adaptation for Linux/CRIS Axis Communications AB, 1999
240   *
241   */
242 @@ -99,12 +99,12 @@
243  static void gzip_mark(void **);
244  static void gzip_release(void **);
245   
246 -static void puts(const char *);
247 +static void putstr(const char *);
248  
249  /* the "heap" is put directly after the BSS ends, at end */
250    
251 -extern int end;
252 -static long free_mem_ptr = (long)&end;
253 +extern int _end;
254 +static long free_mem_ptr = (long)&_end;
255   
256  #include "../../../../../lib/inflate.c"
257  
258 @@ -139,7 +139,7 @@
259  /* decompressor info and error messages to serial console */
260  
261  static void
262 -puts(const char *s)
263 +putstr(const char *s)
264  {
265  #ifndef CONFIG_ETRAX_DEBUG_PORT_NULL
266         while(*s) {
267 @@ -209,9 +209,9 @@
268  static void
269  error(char *x)
270  {
271 -       puts("\n\n");
272 -       puts(x);
273 -       puts("\n\n -- System halted\n");
274 +       putstr("\n\n");
275 +       putstr(x);
276 +       putstr("\n\n -- System halted\n");
277  
278         while(1);       /* Halt */
279  }
280 @@ -257,14 +257,7 @@
281  
282         makecrc();
283  
284 -       __asm__ volatile ("move vr,%0" : "=rm" (revision));
285 -       if (revision < 10)
286 -       {
287 -               puts("You need an ETRAX 100LX to run linux 2.6\n");
288 -               while(1);
289 -       }
290 -
291 -       puts("Uncompressing Linux...\n");
292 +       putstr("Uncompressing Linux...\n");
293         gunzip();
294 -       puts("Done. Now booting the kernel.\n");
295 +       putstr("Done. Now booting the kernel.\n");
296  }
297 diff -urN linux-2.6.25.7/arch/cris/arch-v10/mm/init.c linux-2.6.25.7.cris/arch/cris/arch-v10/mm/init.c
298 --- linux-2.6.25.7/arch/cris/arch-v10/mm/init.c 2008-06-16 22:24:36.000000000 +0200
299 +++ linux-2.6.25.7.cris/arch/cris/arch-v10/mm/init.c    2008-06-24 12:57:25.000000000 +0200
300 @@ -184,6 +184,9 @@
301  
302         free_area_init_node(0, &contig_page_data, zones_size, PAGE_OFFSET >> PAGE_SHIFT, 0);
303  }
304 +void free_initrd_mem(unsigned long start, unsigned long end)
305 +{
306 +}
307  
308  /* Initialize remaps of some I/O-ports. It is important that this
309   * is called before any driver is initialized.