diff options
-rw-r--r-- | core/cortex-m/ec.lds.S | 16 | ||||
-rw-r--r-- | core/cortex-m0/ec.lds.S | 16 | ||||
-rw-r--r-- | include/config.h | 10 | ||||
-rw-r--r-- | include/link_defs.h | 7 |
4 files changed, 49 insertions, 0 deletions
diff --git a/core/cortex-m/ec.lds.S b/core/cortex-m/ec.lds.S index 5e84b56db0..c3ed3c9c80 100644 --- a/core/cortex-m/ec.lds.S +++ b/core/cortex-m/ec.lds.S @@ -57,6 +57,12 @@ MEMORY ORIGIN = CONFIG_USB_RAM_BASE, \ LENGTH = CONFIG_USB_RAM_SIZE * CONFIG_USB_RAM_ACCESS_SIZE / 2 #endif +#ifdef CONFIG_CHIP_MEMORY_REGIONS +#define REGION(name, attr, start, size) \ + name(attr) : ORIGIN = (start), LENGTH = (size) +#include "memory_regions.inc" +#undef REGION +#endif /* CONFIG_MEMORY_REGIONS */ } SECTIONS { @@ -378,6 +384,16 @@ SECTIONS *(.usb_ram.data) } > USB_RAM #endif +#ifdef CONFIG_CHIP_MEMORY_REGIONS +#define REGION(name, attr, start, size) \ + .name(NOLOAD) : { \ + __##name##_start = .; \ + *(SORT(.name.*)) \ + } > name +#include "memory_regions.inc" +#undef REGION +#endif /* CONFIG_CHIP_MEMORY_REGIONS */ + #if !(defined(SECTION_IS_RO) && defined(CONFIG_FLASH)) /DISCARD/ : { *(.google) diff --git a/core/cortex-m0/ec.lds.S b/core/cortex-m0/ec.lds.S index ce4ef3849d..ce1bcdbc70 100644 --- a/core/cortex-m0/ec.lds.S +++ b/core/cortex-m0/ec.lds.S @@ -30,6 +30,12 @@ MEMORY ORIGIN = CONFIG_USB_RAM_BASE, \ LENGTH = CONFIG_USB_RAM_SIZE * CONFIG_USB_RAM_ACCESS_SIZE / 2 #endif +#ifdef CONFIG_CHIP_MEMORY_REGIONS +#define REGION(name, attr, start, size) \ + name(attr) : ORIGIN = (start), LENGTH = (size) +#include "memory_regions.inc" +#undef REGION +#endif /* CONFIG_MEMORY_REGIONS */ } SECTIONS { @@ -248,6 +254,16 @@ SECTIONS *(.usb_ram.data) } > USB_RAM #endif +#ifdef CONFIG_CHIP_MEMORY_REGIONS +#define REGION(name, attr, start, size) \ + .name(NOLOAD) : { \ + __##name##_start = .; \ + *(SORT(.name.*)) \ + } > name +#include "memory_regions.inc" +#undef REGION +#endif /* CONFIG_CHIP_MEMORY_REGIONS */ + #if !(defined(SECTION_IS_RO) && defined(CONFIG_FLASH)) /DISCARD/ : { *(.google) diff --git a/include/config.h b/include/config.h index 902c4c11e2..a6cf65efa1 100644 --- a/include/config.h +++ b/include/config.h @@ -676,6 +676,16 @@ /*****************************************************************************/ /* + * The chip needs to define special SRAM memory regions as linker sections. + * Those regions are defined in the special-purpose preprocessed file in + * chip/<chip_name>/memory_regions.inc using the following macro: + * REGION(name, attributes, start_address, size) + * + * Note: these 'special' regions are NOT cleared at startup contrary to .bss. + */ +#undef CONFIG_CHIP_MEMORY_REGIONS + +/* * Chip needs to do pre-init very early in main(), and provides chip_pre_init() * to do so. */ diff --git a/include/link_defs.h b/include/link_defs.h index c12a350924..f27651691c 100644 --- a/include/link_defs.h +++ b/include/link_defs.h @@ -104,4 +104,11 @@ extern const void *__ro_end; extern const void *__data_start; extern const void *__data_end; +/* Helper for special chip-specific memory sections */ +#ifdef CONFIG_CHIP_MEMORY_REGIONS +#define __SECTION(name) __attribute__((section("." STRINGIFY(name) ".50_auto"))) +#else +#define __SECTION(name) +#endif /* CONFIG_MEMORY_REGIONS */ + #endif /* __CROS_EC_LINK_DEFS_H */ |