cc y / mbed

Fork of mbed by mbed official

Revision:
128:9bcdf88f62b0
Parent:
113:f141b2784e32
--- a/TARGET_EFM32GG_STK3700/TOOLCHAIN_GCC_ARM/efm32gg.ld	Fri Sep 30 16:49:46 2016 +0100
+++ b/TARGET_EFM32GG_STK3700/TOOLCHAIN_GCC_ARM/efm32gg.ld	Thu Oct 27 16:45:56 2016 +0100
@@ -9,6 +9,9 @@
 /* Version 4.2.0 */
 /*                                                                  */
 
+STACK_SIZE = 0x400;
+HEAP_SIZE = 0xC00;
+
 MEMORY
 {
   FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 1048576
@@ -53,6 +56,11 @@
  */
 ENTRY(Reset_Handler)
 
+/* Note: The uVisor expects the text section at a fixed location, as specified
+             by the porting process configuration parameter: FLASH_OFFSET. */
+__UVISOR_TEXT_OFFSET = 0x100;
+__UVISOR_TEXT_START = ORIGIN(FLASH) + __UVISOR_TEXT_OFFSET;
+
 SECTIONS
 {
   .text :
@@ -62,6 +70,13 @@
     __Vectors_Size = __Vectors_End - __Vectors;
     __end__ = .;
 
+    /* uVisor code and data */
+    . = __UVISOR_TEXT_OFFSET;
+    . = ALIGN(4);
+    __uvisor_main_start = .;
+    *(.uvisor.main)
+    __uvisor_main_end = .;
+
     *(.text*)
 
     KEEP(*(.init))
@@ -132,10 +147,51 @@
   } > FLASH
   */
 
-  __etext = .;
+  /* Ensure that the uVisor BSS section is put first in SRAM. */
+  /* Note: The uVisor expects this section at a fixed location, as specified
+           by the porting process configuration parameter: SRAM_OFFSET. */
+  __UVISOR_SRAM_OFFSET = 0x0;
+  __UVISOR_BSS_START = ORIGIN(RAM) + __UVISOR_SRAM_OFFSET;
+  .uvisor.bss __UVISOR_BSS_START (NOLOAD):
+  {
+    . = ALIGN(32);
+    __uvisor_bss_start = .;
+
+    /* uVisor main BSS section */
+    . = ALIGN(32);
+    __uvisor_bss_main_start = .;
+    KEEP(*(.keep.uvisor.bss.main))
+    . = ALIGN(32);
+    __uvisor_bss_main_end = .;
 
-  .data : AT (__etext)
+    /* Secure boxes BSS section */
+    . = ALIGN(32);
+    __uvisor_bss_boxes_start = .;
+    KEEP(*(.keep.uvisor.bss.boxes))
+    . = ALIGN(32);
+    __uvisor_bss_boxes_end = .;
+
+    . = ALIGN(32);
+    __uvisor_bss_end = .;
+  } > RAM
+
+  /* Heap space for the page allocator */
+  .page_heap (NOLOAD) :
   {
+    . = ALIGN(32);
+    __uvisor_page_start = .;
+    KEEP(*(.keep.uvisor.page_heap))
+
+    . = ALIGN( (1 << LOG2CEIL(LENGTH(RAM))) / 8);
+
+    __uvisor_page_end = .;
+  } > RAM
+
+  .data :
+  {
+    PROVIDE(__etext = LOADADDR(.data));    /* Define a global symbol at end of code, */
+    PROVIDE(__DATA_ROM = LOADADDR(.data)); /* Symbol is used by startup for data initialization. */
+
     __data_start__ = .;
     *("dma")
     PROVIDE( __start_vector_table__ = .);
@@ -171,6 +227,51 @@
     /* All data end */
     __data_end__ = .;
 
+  } > RAM AT > FLASH
+
+  /* uVisor configuration section
+   * This section must be located after all other flash regions. */
+  .uvisor.secure :
+  {
+    . = ALIGN(32);
+    __uvisor_secure_start = .;
+
+    /* uVisor secure boxes configuration tables */
+    . = ALIGN(32);
+    __uvisor_cfgtbl_start = .;
+    KEEP(*(.keep.uvisor.cfgtbl))
+    . = ALIGN(32);
+    __uvisor_cfgtbl_end = .;
+
+    /* Pointers to the uVisor secure boxes configuration tables */
+    /* Note: Do not add any further alignment here, as uVisor will need to
+             have access to the exact list of pointers. */
+    __uvisor_cfgtbl_ptr_start = .;
+    KEEP(*(.keep.uvisor.cfgtbl_ptr_first))
+    KEEP(*(.keep.uvisor.cfgtbl_ptr))
+    __uvisor_cfgtbl_ptr_end = .;
+
+    /* Pointers to all boxes register gateways. These are grouped here to
+       allow discoverability and firmware verification. */
+    __uvisor_register_gateway_ptr_start = .;
+    KEEP(*(.keep.uvisor.register_gateway_ptr))
+    __uvisor_register_gateway_ptr_end = .;
+
+    . = ALIGN(32);
+    __uvisor_secure_end = .;
+  } > FLASH
+
+  /* Uninitialized data section
+   * This region is not initialized by the C/C++ library and can be used to
+   * store state across soft reboots. */
+  .uninitialized (NOLOAD):
+  {
+    . = ALIGN(32);
+    __uninitialized_start = .;
+    *(.uninitialized)
+    KEEP(*(.keep.uninitialized))
+    . = ALIGN(32);
+    __uninitialized_end = .;
   } > RAM
 
   .bss :
@@ -183,33 +284,29 @@
     __bss_end__ = .;
   } > RAM
 
-  .heap (COPY):
+  __StackTop = ORIGIN(RAM) + LENGTH(RAM);
+  __stack = __StackTop;
+  __StackLimit = __StackTop - STACK_SIZE;
+
+  .heap (NOLOAD):
   {
+    __uvisor_heap_start = .;
     __HeapBase = .;
     __end__ = .;
     end = __end__;
     _end = __end__;
-    KEEP(*(.heap*))
-    __HeapLimit = .;
-  } > RAM
-
-  /* .stack_dummy section doesn't contains any symbols. It is only
-   * used for linker to calculate size of stack sections, and assign
-   * values to stack symbols later */
-  .stack_dummy (COPY):
-  {
-    KEEP(*(.stack*))
+    . += HEAP_SIZE;
   } > RAM
 
-  /* Set stack top to end of RAM, and stack limit move down by
-   * size of stack_dummy section */
-  __StackTop = ORIGIN(RAM) + LENGTH(RAM);
-  __StackLimit = __StackTop - SIZEOF(.stack_dummy);
-  PROVIDE(__stack = __StackTop);
+  __HeapLimit = __StackLimit;
+  __uvisor_heap_end = __StackLimit;
 
-  /* Check if data + heap + stack exceeds RAM limit */
-  ASSERT(__StackLimit >= __HeapLimit, "region RAM overflowed with stack")
+  /* Provide physical memory boundaries for uVisor. */
+  __uvisor_flash_start = ORIGIN(FLASH);
+  __uvisor_flash_end = ORIGIN(FLASH) + LENGTH(FLASH);
+  __uvisor_sram_start = ORIGIN(RAM);
+  __uvisor_sram_end = ORIGIN(RAM) + LENGTH(RAM);
 
-  /* Check if FLASH usage exceeds FLASH size */
-  ASSERT( LENGTH(FLASH) >= (__etext + SIZEOF(.data)), "FLASH memory overflowed !")
+  /* Check if FLASH usage exceeds FLASH size. */
+  ASSERT(LENGTH(FLASH) >= __uvisor_secure_end, "FLASH memory overflowed!")
 }