|
28 | 28 | {
|
29 | 29 | VECTORS (rx) : ORIGIN = 0x00000000, LENGTH = 0x00000400
|
30 | 30 | FLASH (rx) : ORIGIN = 0x00000400, LENGTH = 0x00040000 - 0x00000400
|
31 |
| - RAM (rwx) : ORIGIN = 0x20000140, LENGTH = 0x00020000 - 0x00000140 |
| 31 | + RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 0x00020000 |
32 | 32 | }
|
33 | 33 |
|
34 | 34 | /* Linker script to place sections and symbol values. Should be used together
|
@@ -59,25 +59,37 @@ MEMORY
|
59 | 59 | */
|
60 | 60 | ENTRY(Reset_Handler)
|
61 | 61 |
|
| 62 | +/* Heap 1/4 of ram and stack 1/8 */ |
| 63 | +__stack_size__ = 0x4000; |
| 64 | +__heap_size__ = 0x8000; |
| 65 | + |
| 66 | +HEAP_SIZE = DEFINED(__heap_size__) ? __heap_size__ : 0x0400; |
| 67 | +STACK_SIZE = DEFINED(__stack_size__) ? __stack_size__ : 0x0400; |
| 68 | + |
| 69 | +/* Size of the vector table in SRAM */ |
| 70 | +M_VECTOR_RAM_SIZE = 0x140; |
| 71 | + |
62 | 72 | SECTIONS
|
63 | 73 | {
|
64 | 74 | .isr_vector :
|
65 | 75 | {
|
66 | 76 | __vector_table = .;
|
67 | 77 | KEEP(*(.vector_table))
|
68 |
| - *(.text.Reset_Handler) |
69 |
| - *(.text.System_Init) |
70 | 78 | . = ALIGN(4);
|
71 | 79 | } > VECTORS
|
72 | 80 |
|
73 |
| - .cordio : |
| 81 | + /* Note: The uVisor expects this section at a fixed location, as specified |
| 82 | + by the porting process configuration parameter: FLASH_OFFSET. */ |
| 83 | + __UVISOR_TEXT_OFFSET = 0x0; |
| 84 | + __UVISOR_TEXT_START = ORIGIN(FLASH) + __UVISOR_TEXT_OFFSET; |
| 85 | + .text __UVISOR_TEXT_START : |
74 | 86 | {
|
75 |
| - *CORDIO_RO_2.1.o |
76 |
| - *TRIM_2.1.o |
77 |
| - } > FLASH |
| 87 | + /* uVisor code and data */ |
| 88 | + . = ALIGN(4); |
| 89 | + __uvisor_main_start = .; |
| 90 | + *(.uvisor.main) |
| 91 | + __uvisor_main_end = .; |
78 | 92 |
|
79 |
| - .text : |
80 |
| - { |
81 | 93 | *(.text*)
|
82 | 94 |
|
83 | 95 | KEEP(*(.init))
|
@@ -114,12 +126,67 @@ SECTIONS
|
114 | 126 | } > FLASH
|
115 | 127 | __exidx_end = .;
|
116 | 128 |
|
117 |
| - __etext = .; |
| 129 | + .cordio : |
| 130 | + { |
| 131 | + *CORDIO_RO_2.1.o |
| 132 | + *TRIM_2.1.o |
| 133 | + } > FLASH |
118 | 134 |
|
119 |
| - .data : AT (__etext) |
| 135 | + .interrupts_ram : |
120 | 136 | {
|
| 137 | + . = ALIGN(4); |
| 138 | + __VECTOR_RAM__ = .; |
| 139 | + __interrupts_ram_start__ = .; /* Create a global symbol at data start */ |
| 140 | + . += M_VECTOR_RAM_SIZE; |
| 141 | + . = ALIGN(4); |
| 142 | + __interrupts_ram_end__ = .; /* Define a global symbol at data end */ |
| 143 | + } > RAM |
| 144 | + |
| 145 | + /* ensure that uvisor bss is at the beginning of memory */ |
| 146 | + /* Note: The uVisor expects this section at a fixed location, as specified by |
| 147 | + * the porting process configuration parameter: SRAM_OFFSET. */ |
| 148 | + __UVISOR_SRAM_OFFSET = 0x140; |
| 149 | + __UVISOR_BSS_START = ORIGIN(RAM) + __UVISOR_SRAM_OFFSET; |
| 150 | + .uvisor.bss __UVISOR_BSS_START (NOLOAD): |
| 151 | + { |
| 152 | + . = ALIGN(32); |
| 153 | + __uvisor_bss_start = .; |
| 154 | + |
| 155 | + /* protected uvisor main bss */ |
| 156 | + . = ALIGN(32); |
| 157 | + __uvisor_bss_main_start = .; |
| 158 | + KEEP(*(.keep.uvisor.bss.main)) |
| 159 | + . = ALIGN(32); |
| 160 | + __uvisor_bss_main_end = .; |
| 161 | + |
| 162 | + /* protected uvisor secure boxes bss */ |
| 163 | + . = ALIGN(32); |
| 164 | + __uvisor_bss_boxes_start = .; |
| 165 | + KEEP(*(.keep.uvisor.bss.boxes)) |
| 166 | + . = ALIGN(32); |
| 167 | + __uvisor_bss_boxes_end = .; |
| 168 | + |
| 169 | + . = ALIGN((1 << LOG2CEIL(LENGTH(RAM))) / 8); |
| 170 | + __uvisor_bss_end = .; |
| 171 | + } > RAM |
| 172 | + |
| 173 | + /* Heap space for the page allocator */ |
| 174 | + .page_heap (NOLOAD) : |
| 175 | + { |
| 176 | + . = ALIGN(32); |
| 177 | + __uvisor_page_start = .; |
| 178 | + KEEP(*(.keep.uvisor.page_heap)) |
| 179 | + . = ALIGN(32); |
| 180 | + __uvisor_page_end = .; |
| 181 | + } > RAM |
| 182 | + |
| 183 | + .data : |
| 184 | + { |
| 185 | + PROVIDE(__etext = LOADADDR(.data)); |
| 186 | + . = ALIGN(4); |
121 | 187 | __data_start__ = .;
|
122 | 188 | *(vtable)
|
| 189 | + *(.data) |
123 | 190 | *(.data*)
|
124 | 191 |
|
125 | 192 | . = ALIGN(4);
|
@@ -147,41 +214,89 @@ SECTIONS
|
147 | 214 | /* All data end */
|
148 | 215 | __data_end__ = .;
|
149 | 216 |
|
| 217 | + } > RAM AT > FLASH |
| 218 | + |
| 219 | + /* uvisor configuration data */ |
| 220 | + .uvisor.secure : |
| 221 | + { |
| 222 | + . = ALIGN(32); |
| 223 | + __uvisor_secure_start = .; |
| 224 | + |
| 225 | + /* uvisor secure boxes configuration tables */ |
| 226 | + . = ALIGN(32); |
| 227 | + __uvisor_cfgtbl_start = .; |
| 228 | + KEEP(*(.keep.uvisor.cfgtbl)) |
| 229 | + . = ALIGN(32); |
| 230 | + __uvisor_cfgtbl_end = .; |
| 231 | + |
| 232 | + __uvisor_cfgtbl_ptr_start = .; |
| 233 | + KEEP(*(.keep.uvisor.cfgtbl_ptr_first)) |
| 234 | + KEEP(*(.keep.uvisor.cfgtbl_ptr)) |
| 235 | + __uvisor_cfgtbl_ptr_end = .; |
| 236 | + |
| 237 | + /* Pointers to all boxes register gateways. These are grouped here to allow |
| 238 | + * discoverability and firmware verification. */ |
| 239 | + __uvisor_register_gateway_ptr_start = .; |
| 240 | + KEEP(*(.keep.uvisor.register_gateway_ptr)) |
| 241 | + __uvisor_register_gateway_ptr_end = .; |
| 242 | + |
| 243 | + . = ALIGN(32); |
| 244 | + __uvisor_secure_end = .; |
| 245 | + } > FLASH |
| 246 | + |
| 247 | + /* From now on you can insert any other SRAM region. */ |
| 248 | + |
| 249 | + .uninitialized (NOLOAD): |
| 250 | + { |
| 251 | + . = ALIGN(32); |
| 252 | + __uninitialized_start = .; |
| 253 | + *(.uninitialized) |
| 254 | + KEEP(*(.keep.uninitialized)) |
| 255 | + . = ALIGN(32); |
| 256 | + __uninitialized_end = .; |
150 | 257 | } > RAM
|
151 | 258 |
|
152 | 259 | .bss :
|
153 | 260 | {
|
| 261 | + . = ALIGN(4); |
| 262 | + __START_BSS = .; |
154 | 263 | __bss_start__ = .;
|
| 264 | + *(.bss) |
155 | 265 | *(.bss*)
|
156 | 266 | *(COMMON)
|
| 267 | + . = ALIGN(4); |
157 | 268 | __bss_end__ = .;
|
| 269 | + __END_BSS = .; |
| 270 | + |
158 | 271 | } > RAM
|
159 | 272 |
|
160 | 273 | bss_size = __bss_end__ - __bss_start__;
|
161 | 274 |
|
162 | 275 | .heap :
|
163 | 276 | {
|
| 277 | + . = ALIGN(8); |
| 278 | + __uvisor_heap_start = .; |
164 | 279 | __end__ = .;
|
165 |
| - end = __end__; |
166 |
| - *(.heap*) |
| 280 | + PROVIDE(end = .); |
| 281 | + __HeapBase = .; |
| 282 | + . += HEAP_SIZE; |
167 | 283 | __HeapLimit = .;
|
168 |
| - } > RAM |
169 |
| - |
170 |
| - /* .stack_dummy section doesn't contains any symbols. It is only |
171 |
| - * used for linker to calculate size of stack sections, and assign |
172 |
| - * values to stack symbols later */ |
173 |
| - .stack_dummy : |
174 |
| - { |
175 |
| - *(.stack) |
| 284 | + __heap_limit = .; /* Add for _sbrk */ |
| 285 | + __uvisor_heap_end = .; |
176 | 286 | } > RAM
|
177 | 287 |
|
178 | 288 | /* Set stack top to end of RAM, and stack limit move down by
|
179 | 289 | * size of stack_dummy section */
|
180 | 290 | __StackTop = ORIGIN(RAM) + LENGTH(RAM);
|
181 |
| - __StackLimit = __StackTop - SIZEOF(.stack_dummy); |
| 291 | + __StackLimit = __StackTop - STACK_SIZE; |
182 | 292 | PROVIDE(__stack = __StackTop);
|
183 | 293 |
|
184 | 294 | /* Check if data + heap + stack exceeds RAM limit */
|
185 | 295 | ASSERT(__StackLimit >= __HeapLimit, "region RAM overflowed with stack")
|
| 296 | + /* Provide physical memory boundaries for uVisor. */ |
| 297 | + __uvisor_flash_start = ORIGIN(VECTORS); |
| 298 | + __uvisor_flash_end = ORIGIN(FLASH) + LENGTH(FLASH); |
| 299 | + __uvisor_sram_start = ORIGIN(RAM); |
| 300 | + __uvisor_sram_end = ORIGIN(RAM) + LENGTH(RAM); |
186 | 301 |
|
187 | 302 | } /* End of sections */
|
0 commit comments