Work-in-progress iriver iFP-7xx port by Tomasz Malesinski
[Rockbox.git] / firmware / app.lds
blobfeff264d399ca21a25c108952c1a192f6d83af47
1 #include "config.h"
3 ENTRY(start)
4 #ifdef CPU_COLDFIRE
5 OUTPUT_FORMAT(elf32-m68k)
6 INPUT(crt0.o)
7 #elif CONFIG_CPU == TCC730
8 OUTPUT_FORMAT(elf32-calmrisc16)
9 INPUT(crt0.o)
10 #elif defined(CPU_ARM)
11 OUTPUT_FORMAT(elf32-littlearm)
12 OUTPUT_ARCH(arm)
13 INPUT(crt0.o)
14 #else
15 OUTPUT_FORMAT(elf32-sh)
16 INPUT(crt0.o)
17 #endif
19 #if CONFIG_CPU == TCC730
20 MEMORY
22    FIRMWARE : ORIGIN = LOADADDRESS, LENGTH = 256K
23    FLASH (RX) : ORIGIN = 0x000000, LENGTH = 1024K
24    ICMEM (RX) : ORIGIN = 0x3FC000, LENGTH = 32K
25    IMEM1 : ORIGIN = 0x200000, LENGTH = 32K
26    IMEM2 : ORIGIN = 0x210000, LENGTH = 16K
27    IMEM3 : ORIGIN = 0x220000, LENGTH = 32K
28    IMEM4 : ORIGIN = 0x230000, LENGTH = 16K
30    DRAM : ORIGIN = 0x000000, LENGTH = 0x3F0000
33 SECTIONS
35 .text LOADADDRESS : {
36         *(.init.text)
37         *(.text) 
38         }> FLASH  AT> FIRMWARE 
40 .icode 0x3FC040: {
41         *(.vectors)
42         *(.icode)
43         }> ICMEM  AT> FIRMWARE
45 /* We start at 0x2000, to avoid overwriting Archos' loader datasegment.
46  * If it turns out that we won't call back the loader, this can be set to 0.
47  */
48 .bss 0x2000 : {
49         *(.bss)
50         . = ALIGN(2);
51         }> DRAM 
53 /* Data is put after BSS, to have all strings addresses > VIRT_PTR + VIRT_SIZE.
54    Strings are in rodata, so what we really assert is (.rodata > VIRT_PTR + VIRT_SIZE)
55    See settings.h for details */
56 .data ALIGN(2): { 
57         *(.data) 
58         . = ALIGN(2);
59         *(.rodata) 
60         . = ALIGN(2);
61         *(.rodata.str1.2)
62         . = ALIGN(2);
63         }> DRAM AT> FIRMWARE
66 .stack ALIGN(2) : {     
67    . = . + 0x2000;
68 }> DRAM
70 .idata 0x200000: {
71         *(.idata)
72 }> IMEM1
74 .idata2 0x220000: {
75         *(.idata2)
76 }> IMEM3
78 _codesize = SIZEOF(.text);
80 _icodecopy = LOADADDR(.icode);
81 _icodestart = ADDR(.icode);
82 _icodesize = SIZEOF(.icode);
84 _datacopy = LOADADDR(.data);
85 _datastart = ADDR(.data);
86 _datasize = SIZEOF(.data);
89 _bssstart = ADDR(.bss);
90 _bsssize = (SIZEOF(.bss) + 1) & ~ 1;
92 _stackbegin = ADDR(.stack);
93 _stackend = ADDR(.stack) + SIZEOF(.stack);
95 _idatastart = ADDR(.idata);
97 /* FIXME: Where to put audio buffer? */
99 _audiobuffer = 0;
100 _audiobufend = 0;
102 /* Plugins are not supported on the Gmini*/
104 _pluginbuf = 0;
107 #else
109 #define PLUGINSIZE PLUGIN_BUFFER_SIZE
110 #define CODECSIZE CODEC_SIZE
113 #ifdef DEBUG
114 #define STUBOFFSET 0x10000
115 #else
116 #define STUBOFFSET 0
117 #endif
119 #define DRAMSIZE (MEMORYSIZE * 0x100000) - PLUGINSIZE - STUBOFFSET - CODECSIZE
121 #if defined(IRIVER_H100_SERIES) || defined(IRIVER_H300)
122 #define DRAMORIG 0x31000000 + STUBOFFSET
123 #define IRAMORIG 0x10000000
124 #define IRAMSIZE 0xc000
125 #elif CONFIG_CPU==PP5020
126 #define DRAMORIG 0x00000000 + STUBOFFSET
127 #define IRAMORIG 0x40000000
128 #define IRAMSIZE 0xc000
129 #elif CONFIG_CPU==PNX0101
130 #define DRAMORIG 0x24000000 + STUBOFFSET
131 #define IRAMORIG 0x400100
132 #define IRAMSIZE 0x7f00
133 #else
134 #define DRAMORIG 0x09000000 + STUBOFFSET
135 #define IRAMORIG 0x0f000000
136 #define IRAMSIZE 0x1000
137 #endif
139 /* End of the audio buffer, where the codec buffer starts */
140 #define ENDAUDIOADDR  (DRAMORIG + DRAMSIZE)
142 /* Where the codec buffer ends, and the plugin buffer starts */
143 #define ENDADDR (ENDAUDIOADDR + CODECSIZE)
145 MEMORY
147    DRAM : ORIGIN = DRAMORIG, LENGTH = DRAMSIZE
148    IRAM : ORIGIN = IRAMORIG, LENGTH = IRAMSIZE
151 SECTIONS
153     .vectors :
154     {
155         loadaddress = .;
156         _loadaddress = .;
157         KEEP(*(.resetvectors));
158         *(.resetvectors);
159         KEEP(*(.vectors));
160         *(.vectors);
161     } > DRAM
163     .text :
164     {
165         . = ALIGN(0x200);
166         *(.init.text)
167         *(.text*)
168 #ifdef CPU_ARM
169         *(.glue_7)
170         *(.glue_7t)
171 #endif
172         . = ALIGN(0x4);
173     } > DRAM
175     .rodata :
176     {
177         *(.rodata)  /* problems without this, dunno why */
178         *(.rodata*)
179         *(.rodata.str1.1)
180         *(.rodata.str1.4)
181         . = ALIGN(0x4);
183         /* Pseudo-allocate the copies of the data sections */
184         _datacopy = .;
185     } > DRAM
187     /* TRICK ALERT! For RAM execution, we put the .data section at the
188        same load address as the copy. Thus, we don't waste extra RAM
189        when we don't actually need the copy.  */
190     .data : AT ( _datacopy )
191     {
192         _datastart = .;
193         *(.data*)
194         . = ALIGN(0x4);
195         _dataend  = .;
196         _iramcopy = .;
197     } > DRAM
199     /DISCARD/ : 
200     {
201         *(.eh_frame)
202     }
204     .iram IRAMORIG : AT ( _iramcopy)
205     {
206         _iramstart = .;
207         *(.icode)
208         *(.irodata)
209         *(.idata)
210         _iramend = .;
211     } > IRAM
212     
213     .ibss (NOLOAD) :
214     {
215         _iedata = .;
216         *(.ibss)
217         . = ALIGN(0x4);
218         _iend = .;
219     } > IRAM
221 #if defined(CPU_COLDFIRE) || defined(CPU_ARM)
222     .stack :
223     {
224        *(.stack)
225        stackbegin = .;
226        . += 0x2000;
227        stackend = .;
228     } > IRAM
229 #else
230     /* TRICK ALERT! We want 0x2000 bytes of stack, but we set the section
231        size smaller, and allow the stack to grow into the .iram copy */
232     .stack ADDR(.data) + SIZEOF(.data) + SIZEOF(.iram):
233     {
234        *(.stack)
235        _stackbegin = . - SIZEOF(.iram);
236        . += 0x2000 - SIZEOF(.iram);
237        _stackend = .;
238     } > DRAM
239 #endif
241 #if defined(CPU_COLDFIRE) || defined(CPU_ARM)
242     .bss ADDR(.data) + SIZEOF(.data) + SIZEOF(.iram):
243 #else
244     .bss :
245 #endif
246     {
247        _edata = .;
248         *(.bss*)
249         *(COMMON)
250         . = ALIGN(0x4);
251        _end = .;
252     } > DRAM
254     .audiobuf ALIGN(4) :
255     {
256         _audiobuffer = .;
257         audiobuffer = .;
258     } > DRAM
260     .audiobufend ENDAUDIOADDR:
261     {
262         audiobufend = .;
263         _audiobufend = .;
264     } > DRAM
266     .codec ENDAUDIOADDR:
267     {
268         codecbuf = .;
269         _codecbuf = .;
270     }
272     .plugin ENDADDR:
273     {
274         _pluginbuf = .;
275         pluginbuf = .;
276     }
279 #endif