summaryrefslogtreecommitdiffstats
path: root/firmware/target/arm/tms320dm320/boot.lds
blob: c59cc7f5141a36b6245e47e6ba60a7d162ca67e7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
#include "config.h"

ENTRY(_vectors)

OUTPUT_FORMAT(elf32-littlearm)
OUTPUT_ARCH(arm)
STARTUP(target/arm/tms320dm320/crt0.o)

#ifndef LCD_NATIVE_WIDTH
#define LCD_NATIVE_WIDTH LCD_WIDTH
#endif

#ifndef LCD_NATIVE_HEIGHT
#define LCD_NATIVE_HEIGHT LCD_HEIGHT
#endif

#define LCD_FUDGE       LCD_NATIVE_WIDTH%32

#define LCD_BUFFER_SIZE  ((LCD_NATIVE_WIDTH+LCD_FUDGE)*LCD_NATIVE_HEIGHT*2)

/* must be 16Kb (0x4000) aligned */
#define TTB_SIZE         (0x4000)

/* Give this some memory to allow it to align to the MMU boundary.
 * Note that since there are two buffers (YUV/RGB) it calculates the approximate
 * memory needed in steps of 1 Meg.
 */
#define LCD_TTB_AREA    0x100000*((LCD_BUFFER_SIZE>>19)+1)

/* Bootloader only uses/knows about the upper 32 M */
#define DRAMORIG    CONFIG_SDRAM_START+0x02000000
#define DRAMSIZE    (MEMORYSIZE * 0x80000)

#define IRAMORIG    0x00000000
#define IRAMSIZE    0x4000

#define FLASHORIG   0x00100000

#ifdef SANSA_CONNECT
/* Offset in flash from beginning, we don't want overwrite OF bootloader
   due to recovery mode and more importantly - hardware block protection.
   This offset makes Rockbox bootloader a replacement for OF vmlinux.
   In .srr file header add any valid memory address from following
   <0x1000000; 0x1300180) u (0x131EAF4; 0x1420000) u (0x1440000; 0x5000000>
   ensuring that complete bootloader fits in.
   Entry point in .srr file should be equal to _loadaddress. */
#define FLASHSIZE     0x00400000
#define FLASHMEMORIG  0x00120010
/* Kernel partition is 2 M, srr header is 16 bytes, sig is 2048 bytes */
#define FLASHMEMSIZE  0x001FF7F0
#else
/* On targets other than Sansa Connect use whole flash for bootloader */
#define FLASHSIZE     0x00800000
#define FLASHMEMORIG   FLASHORIG
#define FLASHMEMSIZE   FLASHSIZE
#endif

PRO_STACK_SIZE =  0x2000;
IRQ_STACK_SIZE =  0x400;
FIQ_STACK_SIZE =  0x400;

/* End of the audio buffer, where the codec buffer starts */
#define TTB_BEGIN   (DRAMORIG + DRAMSIZE - LCD_TTB_AREA)

MEMORY
{
   DRAM : ORIGIN = DRAMORIG, LENGTH = DRAMSIZE
   IRAM : ORIGIN = IRAMORIG, LENGTH = IRAMSIZE
   FLASH : ORIGIN = FLASHMEMORIG, LENGTH = FLASHMEMSIZE
}

SECTIONS
{
    /* Set up variables needed for memory initialization */
    _sdram_start    = DRAMORIG;
    _sdram_sizem    = (DRAMSIZE / 0x100000);

    _flash_start    = FLASHORIG;
    _flash_sizem    = (FLASHSIZE / 0x100000);

    .vectors :
    {
        _vectorsstart = .;
        KEEP(*(.vectors))
        _vectorsend = .;
    } > IRAM AT> FLASH
    _vectorscopy = LOADADDR(.vectors);

    /* crt0.S initialization */
    .init :
    {
        . = ALIGN(0x4);
        _loadaddress = .;
        *(.init)
    } > FLASH

    /* Program code */
    .text :
    {
        . = ALIGN(0x4);
        *(.text*)
    } > FLASH

    /* Thumb interworking sections - for some reason LD dies even if these
     * sections are empty.
     */
    .glue :
    {
       . = ALIGN(0x4);
       *(.glue_7)  /* ARM calling Thumb */
       *(.glue_7t) /* Thumb calling ARM */
    } > FLASH

    /* Read-only data */
    .rodata :
    {
        . = ALIGN(0x4);
        *(.rodata*)
    } > FLASH

    /* Dynamic data - this needs to be copied out of flash before it is used. */
    .data :
    {
        . = ALIGN(0x4);
        _dramstart = .;
        *(.data*)
        _dramend = .;
    } > DRAM AT> FLASH
    _dramcopy = LOADADDR(.data);

 	.bss (NOLOAD) :
    {
        . = ALIGN(0x4);
       	_bss_start = .;
        *(.bss*)
        *(COMMON)
       	_bss_end = .;
    } > DRAM

    .iram :
    {
        . = ALIGN(0x4);
        _iramstart = .;
        *(.icode*)
        *(.irodata*)
        *(.idata*)
        _iramend = .;
    } > IRAM AT> FLASH

    _iramcopy = LOADADDR(.iram);
    
    .ibss (NOLOAD) :
    {
        . = ALIGN(0x4);
        _ibss_start = .;
        *(.ibss*)
        _ibss_end = .;
    } > IRAM

    /* Program stack space */
    .pro_stack (NOLOAD): 
    {
        . = ALIGN(0x4);
        *(.stack)
        stackbegin = .;        /* Variable for thread.c */
        _pro_stack_end = .;       
        . += PRO_STACK_SIZE;
        _pro_stack_start = .;
        stackend = .;          /* Variable for tread.c */
    } > IRAM

    /* IRQ stack space */
    .irq_stack (NOLOAD):
    {
        . = ALIGN(0x4);
        _irq_stack_end = .;
        . += IRQ_STACK_SIZE;
        _irq_stack_start = .;
    } > IRAM

    /* FIQ stack space */
    .fiq_stack (NOLOAD):
    {
        . = ALIGN(0x4);
        _fiq_stack_end = .;
        . += FIQ_STACK_SIZE;
        _fiq_stack_start = .;
    } > IRAM
    
    .ttbtable TTB_BEGIN (NOLOAD) :
    {
        . = ALIGN (0x4000);
        _ttbstart = .;
        . += TTB_SIZE;
    } > DRAM
    
    /* The LCD buffer should be at the end of memory to protect against
     * overflowing something else when the YUV blitter is fudging the screen 
     * size.
     */
    
    .lcdbuffer (NOLOAD) :
    {
        _lcdbuf = .;
        . += LCD_BUFFER_SIZE;
    } > DRAM
    
    .lcdbuffer2 (NOLOAD) :
    {
        _lcdbuf2 = .;
        . += LCD_BUFFER_SIZE;
    } > DRAM
}