Commit a subset of the dual core changes that have to do with cache handling, stacks...
[Rockbox.git] / firmware / app.lds
blob8df9aaf8e3fbd77e41b4758a633e68da4278b37a
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.o)
12 #elif CONFIG_CPU == PNX0101
13 INPUT(target/arm/pnx0101/crt0-pnx0101.o)
14 #elif defined(CPU_ARM)
15 INPUT(target/arm/crt0.o)
16 #endif
17 #else
18 OUTPUT_FORMAT(elf32-sh)
19 INPUT(target/sh/crt0.o)
20 #endif
22 #define PLUGINSIZE PLUGIN_BUFFER_SIZE
23 #define CODECSIZE CODEC_SIZE
25 #ifdef DEBUG
26 #define STUBOFFSET 0x10000
27 #else
28 #define STUBOFFSET 0
29 #endif
31 #if CONFIG_CPU==S3C2440
32 #include "s3c2440.h"
33 #define DRAMSIZE (MEMORYSIZE * 0x100000) - 0x100 - PLUGINSIZE - STUBOFFSET - CODECSIZE - LCD_BUFFER_SIZE - TTB_SIZE
34 #else
35 #define DRAMSIZE (MEMORYSIZE * 0x100000) - PLUGINSIZE - STUBOFFSET - CODECSIZE
36 #endif
38 #if defined(IRIVER_H100_SERIES) || defined(IRIVER_H300)
39 #define DRAMORIG 0x31000000 + STUBOFFSET
40 #define IRAMORIG 0x10000000
41 #define IRAMSIZE 0xc000
42 #elif defined(IAUDIO_X5) || defined(IAUDIO_M5)
43 #define DRAMORIG 0x31000000 + STUBOFFSET
44 #define IRAMORIG 0x10000000
45 #define IRAMSIZE 0x10000
46 #elif defined(CPU_PP)
47 #define DRAMORIG 0x00000000 + STUBOFFSET
48 #define IRAMORIG 0x40000000
49 #define IRAMSIZE 0xc000
50 #elif CONFIG_CPU==PNX0101
51 #define DRAMORIG 0xc00000 + STUBOFFSET
52 #define IRAMORIG 0x400000
53 #define IRAMSIZE 0x7000
54 #elif CONFIG_CPU==S3C2440
55 #define DRAMORIG 0x00000100 + STUBOFFSET
56 #define IRAMORIG DRAMORIG
57 #define IRAMSIZE 0x1000
58 #define IRAM DRAM
59 #elif CONFIG_CPU==DM320
60 #define DRAMORIG 0x00900000 + STUBOFFSET
61 #define IRAMORIG 0x00000000
62 #define IRAMSIZE 0x4000
63 #elif CONFIG_CPU==IMX31L
64 #define DRAMORIG (0x80000000 + STUBOFFSET)
65 #define IRAMORIG 0x1FFFC000
66 #define IRAMSIZE 0x4000
67 #else
68 #define DRAMORIG 0x09000000 + STUBOFFSET
69 #define IRAMORIG 0x0f000000
70 #define IRAMSIZE 0x1000
71 #endif
73 /* End of the audio buffer, where the codec buffer starts */
74 #define ENDAUDIOADDR  (DRAMORIG + DRAMSIZE)
76 /* Where the codec buffer ends, and the plugin buffer starts */
77 #define ENDADDR (ENDAUDIOADDR + CODECSIZE)
79 MEMORY
81    DRAM : ORIGIN = DRAMORIG, LENGTH = DRAMSIZE
82 #if CONFIG_CPU != S3C2440
83    IRAM : ORIGIN = IRAMORIG, LENGTH = IRAMSIZE
84 #endif
85 #if CONFIG_CPU==PNX0101
86    IRAM0 : ORIGIN = 0x0, LENGTH = IRAMSIZE
87 #endif
90 SECTIONS
92 #if !defined(CPU_ARM)
93     .vectors :
94     {
95         loadaddress = .;
96         _loadaddress = .;
97         KEEP(*(.resetvectors));
98         *(.resetvectors);
99         KEEP(*(.vectors));
100         *(.vectors);
101     } > DRAM
103     .text :
104     {
105 #else
106     .text :
107     {
108         loadaddress = .;
109         _loadaddress = .;
110 #endif
111         . = ALIGN(0x200);
112         *(.init.text)
113         *(.text*)
114 #ifdef CPU_ARM
115         *(.glue_7)
116         *(.glue_7t)
117 #endif
118         . = ALIGN(0x4);
119     } > DRAM
121     .rodata :
122     {
123         *(.rodata)  /* problems without this, dunno why */
124         *(.rodata*)
125         *(.rodata.str1.1)
126         *(.rodata.str1.4)
127         . = ALIGN(0x4);
129         /* Pseudo-allocate the copies of the data sections */
130         _datacopy = .;
131     } > DRAM
133     /* TRICK ALERT! For RAM execution, we put the .data section at the
134        same load address as the copy. Thus, we don't waste extra RAM
135        when we don't actually need the copy.  */
136     .data : AT ( _datacopy )
137     {
138         _datastart = .;
139         *(.data*)
140         . = ALIGN(0x4);
141         _dataend  = .;
142     } > DRAM
144     /DISCARD/ :
145     {
146         *(.eh_frame)
147     }
149 #if defined(CPU_ARM)
150     .vectors 0x0 :
151     {
152         _vectorsstart = .;
153         *(.vectors);
154         _vectorsend = .;
155 #if CONFIG_CPU==PNX0101
156         *(.dmabuf)
157     } >IRAM0 AT> DRAM
158 #else
159     } AT> DRAM
160 #endif
162     _vectorscopy = LOADADDR(.vectors);
163 #endif
165 #if CONFIG_CPU==PNX0101
166     .iram IRAMORIG + SIZEOF(.vectors) :
167 #elif CONFIG_CPU==S3C2440
168     .iram :
169 #else
170     .iram IRAMORIG :
171 #endif
172     {
173         _iramstart = .;
174         *(.icode)
175         *(.irodata)
176         *(.idata)
177         _iramend = .;
178     } > IRAM AT> DRAM
180     _iramcopy = LOADADDR(.iram);
182     .ibss (NOLOAD) :
183     {
184         _iedata = .;
185         *(.ibss)
186         . = ALIGN(0x4);
187         _iend = .;
188     } > IRAM
190 #if defined(CPU_COLDFIRE) || defined(CPU_ARM)
191     .stack :
192     {
193        *(.stack)
194        stackbegin = .;
195        . += 0x2000;
196        stackend = .;
197     } > IRAM
199 #ifdef CPU_PP
200 #if NUM_CORES > 1
201     .idle_stacks :
202     {
203        *(.idle_stacks)
204        cpu_idlestackbegin = .;
205        . += 0x0080;
206        cpu_idlestackend = .;
207        cop_idlestackbegin = .;
208        . += 0x0080;
209        cop_idlestackend = .;
210     } > IRAM
211 #else
212     .cop_stack :
213     {
214        *(.cop_stack)
215        cop_stackbegin = .;
216        . += 0x0500;
217        cop_stackend = .;
218     } > IRAM
219 #endif
220 #endif
222 #else
223     /* TRICK ALERT! We want 0x2000 bytes of stack, but we set the section
224        size smaller, and allow the stack to grow into the .iram copy */
225     .stack ADDR(.data) + SIZEOF(.data) + SIZEOF(.iram):
226     {
227        *(.stack)
228        _stackbegin = . - SIZEOF(.iram);
229        . += 0x2000 - SIZEOF(.iram);
230        _stackend = .;
231     } > DRAM
232 #endif
234 #if defined(CPU_COLDFIRE)
235     .bss ADDR(.data) + SIZEOF(.data) + SIZEOF(.iram):
236 #elif defined(CPU_ARM) && CONFIG_CPU != S3C2440
237     .bss ADDR(.data) + SIZEOF(.data) + SIZEOF(.iram) + SIZEOF(.vectors):
238 #else
239     .bss :
240 #endif
241     {
242        _edata = .;
243         *(.bss*)
244         *(COMMON)
245         . = ALIGN(0x4);
246        _end = .;
247     } > DRAM
249     .audiobuf ALIGN(4) :
250     {
251         _audiobuffer = .;
252         audiobuffer = .;
253     } > DRAM
255     .audiobufend ENDAUDIOADDR:
256     {
257         audiobufend = .;
258         _audiobufend = .;
259     } > DRAM
261     .codec ENDAUDIOADDR:
262     {
263         codecbuf = .;
264         _codecbuf = .;
265     }
267     .plugin ENDADDR:
268     {
269         _pluginbuf = .;
270         pluginbuf = .;
271     }