From bf5228ea5661d3c9fdc45ac41c83f07b90b1b09e Mon Sep 17 00:00:00 2001 From: Andrew Boie Date: Mon, 19 Jun 2017 11:13:19 -0700 Subject: [PATCH] kernel: add early init routines for app RAM Applications will have their own BSS and data sections which will need to be additionally copied. This covers the common C implementation of these functions. Arches which implement their own optimized versions will need to be updated. Signed-off-by: Andrew Boie --- include/linker/linker-defs.h | 21 ++++++++++++++++++++- kernel/init.c | 8 ++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/include/linker/linker-defs.h b/include/linker/linker-defs.h index 810d7db9e99..ef61f93f02a 100644 --- a/include/linker/linker-defs.h +++ b/include/linker/linker-defs.h @@ -145,16 +145,35 @@ GDATA(__data_num_words) #include +#ifdef CONFIG_APPLICATION_MEMORY +/* Application memory area bounds */ +extern char __app_ram_start[]; +extern char __app_ram_end[]; +#endif + +/* Memory owned by the kernel */ +extern char __kernel_ram_start[]; +extern char __kernel_ram_end[]; + /* Used by _bss_zero or arch-specific implementation */ extern char __bss_start[]; extern char __bss_end[]; +#ifdef CONFIG_APPLICATION_MEMORY +extern char __app_bss_start[]; +extern char __app_bss_end[]; +#endif /* Used by _data_copy() or arch-specific implementation */ #ifdef CONFIG_XIP extern char __data_rom_start[]; extern char __data_ram_start[]; extern char __data_ram_end[]; -#endif +#ifdef CONFIG_APPLICATION_MEMORY +extern char __app_data_rom_start[]; +extern char __app_data_ram_start[]; +extern char __app_data_ram_end[]; +#endif /* CONFIG_APPLICATION_MEMORY */ +#endif /* CONFIG_XIP */ /* used by mem_safe subsystem */ extern char _image_rom_start[]; diff --git a/kernel/init.c b/kernel/init.c index 04200fb6448..236d2775693 100644 --- a/kernel/init.c +++ b/kernel/init.c @@ -143,6 +143,10 @@ void _bss_zero(void) { memset(&__bss_start, 0, ((u32_t) &__bss_end - (u32_t) &__bss_start)); +#ifdef CONFIG_APPLICATION_MEMORY + memset(&__app_bss_start, 0, + ((u32_t) &__app_bss_end - (u32_t) &__app_bss_start)); +#endif } @@ -159,6 +163,10 @@ void _data_copy(void) { memcpy(&__data_ram_start, &__data_rom_start, ((u32_t) &__data_ram_end - (u32_t) &__data_ram_start)); +#ifdef CONFIG_APPLICATION_MEMORY + memcpy(&__app_data_ram_start, &__app_data_rom_start, + ((u32_t) &__app_data_ram_end - (u32_t) &__app_data_ram_start)); +#endif } #endif