Oops. Should commit patches correctly.
[Rockbox.git] / firmware / boot.lds
blobe6c9326c7cd5ba6635e1a2728d9ba0af120a0599
1 #include "config.h"
3 ENTRY(start)
4 #ifdef CPU_COLDFIRE
5 OUTPUT_FORMAT(elf32-m68k)
6 INPUT(target/coldfire/crt0.o)
7 #elif defined (CPU_ARM)
8 OUTPUT_FORMAT(elf32-littlearm)
9 OUTPUT_ARCH(arm)
10 #ifdef CPU_PP
11 INPUT(target/arm/crt0-pp-bl.o)
12 #elif CONFIG_CPU==DM320
13 INPUT(target/arm/tms320dm320/crt0.o)
14 #elif CONFIG_CPU==S3C2440
15 INPUT(target/arm/s3c2440/crt0.o)
16 #elif defined(CPU_TCC77X)
17 INPUT(target/arm/tcc77x/crt0.o)
18 #elif defined(CPU_TCC780X)
19 INPUT(target/arm/tcc780x/crt0.o)
20 #elif CONFIG_CPU==IMX31L
21 INPUT(target/arm/imx31/crt0.o)
22 #else
23 INPUT(target/arm/crt0.o)
24 #endif
25 #else
26 OUTPUT_FORMAT(elf32-sh)
27 INPUT(target/sh/crt0.o)
28 #endif
30 #define DRAMSIZE (MEMORYSIZE * 0x100000)
32 #ifdef IRIVER_H100_SERIES
33 #define DRAMORIG 0x31000000
34 #define IRAMORIG 0x10000000
35 #define IRAMSIZE 0x18000
36 #define FLASHORIG 0x001f0000
37 #define FLASHSIZE 2M
38 #elif defined(IRIVER_H300_SERIES)
39 #define DRAMORIG 0x31000000
40 #define IRAMORIG 0x10000000
41 #define IRAMSIZE 0x18000
42 #define FLASHORIG 0x003f0000
43 #define FLASHSIZE 4M
44 #elif defined(IAUDIO_X5) || defined(IAUDIO_M5)
45 #define DRAMORIG 0x31000000
46 #define IRAMORIG 0x10000000
47 #define IRAMSIZE 0x20000
48 #define FLASHORIG 0x00010000
49 #define FLASHSIZE 4M
50 #elif defined(IAUDIO_M3)
51 #define DRAMORIG 0x31000000
52 #define IRAMORIG 0x10000000
53 #define IRAMSIZE 0x18000
54 #define FLASHORIG 0x00010000
55 #define FLASHSIZE 4M
56 #elif CONFIG_CPU == PP5020
57 #define DRAMORIG 0x10000000
58 #define IRAMORIG 0x40000000
59 #define IRAMSIZE 0x18000
60 #define FLASHORIG 0x001f0000
61 #define FLASHSIZE 2M
62 #elif (CONFIG_CPU == PP5022) || (CONFIG_CPU == PP5024)
63 #define DRAMORIG 0x10000000
64 #ifndef IRAMORIG
65 #define IRAMORIG 0x40000000
66 #endif
67 #define IRAMSIZE 0x20000
68 #define FLASHORIG 0x001f0000
69 #define FLASHSIZE 2M
70 #elif CONFIG_CPU == S3C2440
71 #define DRAMORIG 0x30000000
72 #define IRAMORIG 0x40000000
73 #define IRAMSIZE 4K
74 #define FLASHORIG 0x0000000
75 #define FLASHSIZE 1M
76 #elif CONFIG_CPU == DM320
77 #define DRAMORIG 0x00900000
78 #define IRAMORIG 0x00000000
79 #define IRAMSIZE 16K
80 #define FLASHORIG 0x00100000
81 #define FLASHSIZE 8M
82 #elif CONFIG_CPU == PP5002
83 #define DRAMORIG 0x28000000
84 #define IRAMORIG 0x40000000
85 #define IRAMSIZE 0x18000
86 #define FLASHORIG 0x001f0000
87 #define FLASHSIZE 2M
88 #elif CONFIG_CPU == IMX31L
89 #define DRAMORIG (0x02000000-0x00100000)
90 #undef  DRAMSIZE
91 #define DRAMSIZE (1 << 20) /* Limit 1 MB for bootloader */
92 #define IRAM DRAM
93 #define IRAMORIG 0x1FFFC000
94 #define IRAMSIZE 16K
95 #define FLASHORIG 0x0000000
96 #define FLASHSIZE 1M
97 #elif defined(CPU_TCC77X)
98 #define DRAMORIG 0x20000000
99 #define IRAMORIG 0x00000000
100 #define IRAMSIZE 64K
101 #define FLASHORIG 0x0000000
102 #define FLASHSIZE 1M
103 #elif defined(CPU_TCC780X)
104 #define DRAMORIG 0x20000000
105 #define IRAMORIG 0x00000000
106 #define IRAMSIZE 4K
107 #define FLASHORIG 0x0000000
108 #define FLASHSIZE 1M
109 #else
110 #define DRAMORIG 0x09000000
111 #define IRAMORIG 0x0f000000
112 #define IRAMSIZE 0x1000
113 #define FLASHORIG 0x02000000 + ROM_START
114 #define FLASHSIZE 256K - ROM_START
115 #endif
117 #if defined(CPU_TCC77X) || defined(CPU_TCC780X)
118 MEMORY
120 #ifdef TCCBOOT
121    DRAM : ORIGIN = DRAMORIG + DRAMSIZE - 0x100000, LENGTH = 0x100000
122 #else
123    DRAM : ORIGIN = DRAMORIG, LENGTH = DRAMSIZE
124 #endif
125    IRAM : ORIGIN = IRAMORIG, LENGTH = IRAMSIZE
127 #elif CONFIG_CPU == IMX31L
128 MEMORY
130    DRAM : ORIGIN = DRAMORIG, LENGTH = DRAMSIZE
132 #elif !defined(CPU_PP) && (CONFIG_CPU!=S3C2440)
133 MEMORY
135    DRAM : ORIGIN = DRAMORIG, LENGTH = DRAMSIZE
136    IRAM : ORIGIN = IRAMORIG, LENGTH = IRAMSIZE
137    FLASH : ORIGIN = FLASHORIG, LENGTH = FLASHSIZE
139 #endif
141 SECTIONS
142 #ifdef CPU_PP
144   . = IRAMORIG;
146   .text : {
147     *(.init.text)
148     *(.text*)
149   }
151   .data : {
152     *(.icode)
153     *(.irodata)
154     *(.idata)
155     *(.data*)
156     _dataend = . ;
157    }
159   .stack :
160   {
161      *(.stack)
162      _stackbegin = .;
163      stackbegin = .;
164      . += 0x2000;
165      _stackend = .;
166      stackend = .;
167   }
169   /* The bss section is too large for IRAM - we just move it 16MB into the
170      DRAM */
172   . = (DRAMORIG+16*1024*1024);
173   .bss : {
174      _edata = .;
175      *(.bss*);
176      *(.ibss);
177      _end = .;
178    }
180 #elif (CONFIG_CPU==S3C2440)
182     . = DRAMORIG + 0x1000000;
184     .text : {
185         *(.init.text)
186         *(.text*)
187     }
189     .data : {
190         *(.icode)
191         *(.irodata)
192         *(.idata)
193         *(.data*)
194         . = ALIGN(0x4);
195         _dataend = . ;
196      }
198     .stack :
199     {
200          *(.stack)
201          _stackbegin = .;
202          stackbegin = .;
203          . += 0x2000;
204          _stackend = .;
205          stackend = .;
206     }
207     .bss : {
208          _edata = .;
209          *(.bss*);
210          *(.ibss);
211          *(COMMON)
212          _end = .;
213      }
215 #elif defined(CPU_TCC77X) || defined(CPU_TCC780X)
217     .text : {
218         *(.init.text)
219         *(.text)
220         *(.text*)
221         *(.glue_7)
222         *(.glue_7t)
223    } > DRAM
225     .data : {
226         *(.icode)
227         *(.irodata)
228         *(.idata)
229         *(.data*)
230         *(.rodata.*)
231         . = ALIGN(0x4);
232         _dataend = . ;
233     } > DRAM
235     .stack :
236     {
237          *(.stack)
238          _stackbegin = .;
239          stackbegin = .;
240          . += 0x2000;
241          _stackend = .;
242          stackend = .;
243     } > DRAM
244     .bss : {
245          _edata = .;
246          *(.bss*);
247          *(.ibss);
248          *(COMMON)
249          _end = .;
250      } > DRAM
252 #elif (CONFIG_CPU==DM320)
254     . = DRAMORIG + 0x1000000;
256     .text : {
257         loadaddress = .;
258         _loadaddress = .;
259         *(.init.text)
260         *(.text*)
261         *(.glue_7)
262         *(.glue_7t)
263         . = ALIGN(0x4);
264     } > DRAM
266     .rodata :
267     {
268         *(.rodata)  /* problems without this, dunno why */
269         *(.rodata*)
270         *(.rodata.str1.1)
271         *(.rodata.str1.4)
272         . = ALIGN(0x4);
274         /* Pseudo-allocate the copies of the data sections */
275         _datacopy = .;
276     } > DRAM
278     .data : {
279         *(.icode)
280         *(.irodata)
281         *(.idata)
282         *(.data*)
283         . = ALIGN(0x4);
284         _dataend = . ;
285     } > DRAM
287     .stack :
288     {
289          *(.stack)
290          _stackbegin = .;
291          stackbegin = .;
292          . += 0x2000;
293          _stackend = .;
294          stackend = .;
295     } > DRAM
297     .bss :
298     {
299          _edata = .;
300          *(.bss*);
301          *(.ibss);
302          *(COMMON)
303          _end = .;
304     } > DRAM
306     .vectors IRAMORIG :
307     {
308         _vectorsstart = .;
309         KEEP(*(.resetvectors));
310         *(.resetvectors);
311         KEEP(*(.vectors));
312         *(.vectors);
313         _vectorsend = .;
314     } AT > DRAM
315     _vectorscopy = LOADADDR(.vectors);
317 #elif (CONFIG_CPU==IMX31L)
319     . = DRAMORIG;
321     .text :
322     {
323         *(.init.text)
324         *(.text*)
325         *(.icode)
326         *(.glue_7)
327         *(.glue_7t)
328         . = ALIGN(0x4);
329     } > DRAM
331     .rodata :
332     {
333         *(.rodata)  /* problems without this, dunno why */
334         *(.rodata*)
335         *(.rodata.str1.1)
336         *(.rodata.str1.4)
337         . = ALIGN(0x4);
339         /* Pseudo-allocate the copies of the data sections */
340         _datacopy = .;
341     } > DRAM
343     .data :
344     {
345         *(.irodata)
346         *(.idata)
347         *(.data*)
348         . = ALIGN(0x4);
349         _dataend = . ;
350     } > DRAM
352     .stack :
353     {
354         *(.stack)
355         _stackbegin = .;
356         stackbegin = .;
357         . += 0x2000;
358         _stackend = .;
359         stackend = .;
360     } > IRAM
362     .bss :
363     {
364          _edata = .;
365          *(.bss*);
366          *(.ibss);
367          *(COMMON)
368          _end = .;
369     } > DRAM
371     .vectors 0x0 :
372     {
373         _vectorsstart = .;
374         *(.vectors);
375         KEEP(*(.vectors));
376         _vectorsend = .;
377     } AT > DRAM
378     _vectorscopy = LOADADDR(.vectors);
380 #else
382     .vectors :
383     {
384 #if defined(IAUDIO_X5) || defined(IAUDIO_M5) || defined(IAUDIO_M3)
385         *(.init.text)
386 #endif
387         _datacopy = .;
388     } > FLASH
390     .data : AT ( _datacopy )
391     {
392         _datastart = .;
393         KEEP(*(.resetvectors));
394         *(.resetvectors);
395         KEEP(*(.vectors));
396         *(.vectors);
397         . = ALIGN(0x200);
398         *(.icode)
399         *(.irodata)
400         *(.idata)
401         *(.data*)
402         . = ALIGN(0x4);
403         _dataend = .;
404         . = ALIGN(0x10);  /* Maintain proper alignment for .text section */
405     } > IRAM
407     /* TRICK ALERT! Newer versions of the linker don't allow output sections
408        to overlap even if one of them is empty, so advance the location pointer
409        "by hand" */
410     .text LOADADDR(.data) + SIZEOF(.data) :
411     {
412         *(.init.text)
413         *(.text*)
414         . = ALIGN(0x4);
415     } > FLASH
417     .rodata :
418     {
419         *(.rodata*)
420         . = ALIGN(0x4);
421         _iramcopy = .;
422     } > FLASH
424     .stack :
425     {
426        *(.stack)
427        _stackbegin = .;
428        stackbegin = .;
429        . += 0x2000;
430        _stackend = .;
431        stackend = .;
432     } > IRAM
434 #if defined(IRIVER_H100_SERIES) || defined(IRIVER_H300_SERIES) \
435  || defined(IAUDIO_X5) || defined(IAUDIO_M5) || defined(IAUDIO_M3)
436     .bss DRAMORIG+0x800000:
437 #else
438     .bss :
439 #endif
440     {
441        _edata = .;
442         *(.ibss)
443         *(.bss*)
444         *(COMMON)
445        _end = .;
446 #if defined(IRIVER_H100_SERIES) || defined(IRIVER_H300_SERIES) \
447  || defined(IAUDIO_X5) || defined(IAUDIO_M5) || defined(IAUDIO_M3)
448     } > DRAM
449 #else
450     } > IRAM
451 #endif
454 #endif