1
- /* Linker script to configure memory regions. */
1
+ M_VECTOR_RAM_SIZE = 0x400;
2
+
3
+ /* Heap : 1/4 of RAM. Stack : 1/8 of RAM. */
4
+ STACK_SIZE = 0x6000;
5
+ HEAP_SIZE = 0xC000;
6
+
7
+ /* Specify the memory areas */
2
8
MEMORY
3
- {
4
- FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 2048k
5
- CCM (rwx) : ORIGIN = 0x10000000, LENGTH = 64K
6
- RAM (rwx) : ORIGIN = 0x200001AC, LENGTH = 192k - 0x1AC
9
+ {
10
+ VECTORS (rx) : ORIGIN = 0x08000000, LENGTH = 0x400
11
+ FLASH (rx) : ORIGIN = 0x08000400, LENGTH = 2048k - 0x400
12
+ CCM (rwx) : ORIGIN = 0x10000000, LENGTH = 64K
13
+ RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 192k
7
14
}
8
15
9
16
/* Linker script to place sections and symbol values. Should be used together
10
17
* with other linker script that defines memory regions FLASH and RAM.
11
18
* It references following symbols, which must be defined in code :
12
19
* Reset_Handler : Entry of reset handler
13
- *
20
+ *
14
21
* It defines following symbols, which code can use without definition :
15
22
* __exidx_start
16
23
* __exidx_end
@@ -37,10 +44,28 @@ ENTRY(Reset_Handler)
37
44
38
45
SECTIONS
39
46
{
40
- .text :
47
+ .isr_vector :
41
48
{
49
+ __vector_table = .;
42
50
KEEP(*(.isr_vector))
51
+ . = ALIGN (4);
52
+ } > VECTORS
53
+
54
+ /* Note : The uVisor expects this section at a fixed location, as specified
55
+ * by the porting process configuration parameter :
56
+ * FLASH_OFFSET. */
57
+ __UVISOR_FLASH_OFFSET = 0x400;
58
+ __UVISOR_FLASH_START = ORIGIN (VECTORS) + __UVISOR_FLASH_OFFSET;
59
+ .text __UVISOR_FLASH_START :
60
+ {
61
+ /* uVisor code and data */
62
+ . = ALIGN (4);
63
+ __uvisor_main_start = .;
64
+ *(.uvisor.main)
65
+ __uvisor_main_end = .;
66
+
43
67
*(.text*)
68
+
44
69
KEEP(*(.init))
45
70
KEEP(*(.fini))
46
71
@@ -69,6 +94,7 @@ SECTIONS
69
94
} > FLASH
70
95
71
96
__exidx_start = .;
97
+
72
98
.ARM.exidx :
73
99
{
74
100
*(.ARM.exidx* .gnu.linkonce.armexidx.*)
@@ -78,8 +104,62 @@ SECTIONS
78
104
__etext = .;
79
105
_sidata = .;
80
106
81
- .data : AT (__etext)
107
+ .interrupts_ram :
108
+ {
109
+ . = ALIGN (4);
110
+ __VECTOR_RAM__ = .;
111
+ __interrupts_ram_start__ = .; /* Create a global symbol at data start */
112
+ *(.m_interrupts_ram) /* This is a user defined section */
113
+ . += M_VECTOR_RAM_SIZE;
114
+ . = ALIGN (4);
115
+ __interrupts_ram_end__ = .; /* Define a global symbol at data end */
116
+ } > RAM
117
+
118
+ /* uVisor own memory and private box memories
119
+ /* Note : The uVisor expects this section at a fixed location, as specified
120
+ by the porting process configuration parameter : SRAM_OFFSET. */
121
+ __UVISOR_SRAM_OFFSET = 0x0;
122
+ __UVISOR_SRAM_START = ORIGIN (CCM) + __UVISOR_SRAM_OFFSET;
123
+ .uvisor.bss __UVISOR_SRAM_START (NOLOAD) :
124
+ {
125
+ . = ALIGN (32);
126
+ __uvisor_bss_start = .;
127
+
128
+ /* Protected uVisor own BSS section */
129
+ . = ALIGN (32);
130
+ __uvisor_bss_main_start = .;
131
+ KEEP(*(.keep.uvisor.bss.main))
132
+ . = ALIGN (32);
133
+ __uvisor_bss_main_end = .;
134
+
135
+ /* Protected uVisor boxes' static memories */
136
+ . = ALIGN (32);
137
+ __uvisor_bss_boxes_start = .;
138
+ KEEP(*(.keep.uvisor.bss.boxes))
139
+ . = ALIGN (32);
140
+ __uvisor_bss_boxes_end = .;
141
+
142
+ . = ALIGN (32);
143
+ __uvisor_bss_end = .;
144
+ } > CCM
145
+
146
+ /* Heap space for the page allocator
147
+ /* If uVisor shares the SRAM with the OS/app, ensure that this section is
148
+ * the first one after the uVisor BSS section. Otherwise, ensure it is the
149
+ * first one after the VTOR relocation section. */
150
+ .page_heap (NOLOAD) :
82
151
{
152
+ . = ALIGN (32);
153
+ __uvisor_page_start = .;
154
+ KEEP(*(.keep.uvisor.page_heap))
155
+ . = ALIGN ((1 << LOG2CEIL(LENGTH (RAM))) / 8);
156
+ __uvisor_page_end = .;
157
+ } > RAM
158
+
159
+ .data :
160
+ {
161
+ PROVIDE ( __etext = LOADADDR (.data) );
162
+
83
163
__data_start__ = .;
84
164
_sdata = .;
85
165
*(vtable)
@@ -112,9 +192,54 @@ SECTIONS
112
192
__data_end__ = .;
113
193
_edata = .;
114
194
195
+ } > RAM AT > FLASH
196
+
197
+ /* uVisor configuration section
198
+ * This section must be located after all other flash regions. */
199
+ .uvisor.secure :
200
+ {
201
+ . = ALIGN (32);
202
+ __uvisor_secure_start = .;
203
+
204
+ /* uVisor secure boxes configuration tables */
205
+ . = ALIGN (32);
206
+ __uvisor_cfgtbl_start = .;
207
+ KEEP(*(.keep.uvisor.cfgtbl))
208
+ . = ALIGN (32);
209
+ __uvisor_cfgtbl_end = .;
210
+
211
+ /* Pointers to the uVisor secure boxes configuration tables */
212
+ /* Note : Do not add any further alignment here, as uVisor will need to
213
+ * have access to the exact list of pointers. */
214
+ __uvisor_cfgtbl_ptr_start = .;
215
+ KEEP(*(.keep.uvisor.cfgtbl_ptr_first))
216
+ KEEP(*(.keep.uvisor.cfgtbl_ptr))
217
+ __uvisor_cfgtbl_ptr_end = .;
218
+
219
+ /* Pointers to all boxes register gateways. These are grouped here to
220
+ allow discoverability and firmware verification. */
221
+ __uvisor_register_gateway_ptr_start = .;
222
+ KEEP(*(.keep.uvisor.register_gateway_ptr))
223
+ __uvisor_register_gateway_ptr_end = .;
224
+
225
+ . = ALIGN (32);
226
+ __uvisor_secure_end = .;
227
+ } > FLASH
228
+
229
+ /* Uninitialized data section
230
+ * This region is not initialized by the C/C++ library and can be used to
231
+ * store state across soft reboots. */
232
+ .uninitialized (NOLOAD) :
233
+ {
234
+ . = ALIGN (32);
235
+ __uninitialized_start = .;
236
+ *(.uninitialized)
237
+ KEEP(*(.keep.uninitialized))
238
+ . = ALIGN (32);
239
+ __uninitialized_end = .;
115
240
} > RAM
116
241
117
- .bss :
242
+ .bss (NOLOAD) :
118
243
{
119
244
. = ALIGN (4);
120
245
__bss_start__ = .;
@@ -126,29 +251,27 @@ SECTIONS
126
251
_ebss = .;
127
252
} > RAM
128
253
129
- .heap (COPY ) :
254
+ .heap (NOLOAD ) :
130
255
{
256
+ __uvisor_heap_start = .;
131
257
__end__ = .;
132
258
end = __end__;
133
- *(.heap*)
259
+ . += HEAP_SIZE;
134
260
__HeapLimit = .;
261
+ __uvisor_heap_end = .;
135
262
} > RAM
136
263
137
- /* .stack_dummy section doesn't contains any symbols. It is only
138
- * used for linker to calculate size of stack sections, and assign
139
- * values to stack symbols later */
140
- .stack_dummy (COPY) :
141
- {
142
- *(.stack*)
143
- } > RAM
144
-
145
- /* Set stack top to end of RAM, and stack limit move down by
146
- * size of stack_dummy section */
147
264
__StackTop = ORIGIN (RAM) + LENGTH (RAM);
148
- _estack = __StackTop;
149
- __StackLimit = __StackTop - SIZEOF (.stack_dummy);
150
- PROVIDE (__stack = __StackTop);
265
+ __stack = __StackTop;
266
+ __StackLimit = __StackTop - STACK_SIZE;
267
+
268
+ ASSERT (__StackLimit >= __HeapLimit, "Region RAM overflowed with stack and heap")
151
269
152
- /* Check if data + heap + stack exceeds RAM limit */
153
- ASSERT (__StackLimit >= __HeapLimit, "region RAM overflowed with stack")
270
+ /* Provide physical memory boundaries for uVisor. */
271
+ __uvisor_flash_start = ORIGIN (VECTORS);
272
+ __uvisor_flash_end = ORIGIN (FLASH) + LENGTH (FLASH);
273
+ __uvisor_sram_start = ORIGIN (CCM);
274
+ __uvisor_sram_end = ORIGIN (CCM) + LENGTH (CCM);
275
+ __uvisor_public_sram_start = ORIGIN (RAM);
276
+ __uvisor_public_sram_end = ORIGIN (RAM) + LENGTH (RAM);
154
277
}
0 commit comments