12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182 |
- #include <zephyr.h>
- #include <kernel.h>
- #include <string.h>
- #include <linker/linker-defs.h>
- #ifdef CONFIG_STACK_CANARIES
- extern volatile uintptr_t __stack_chk_guard;
- #endif
- void z_data_copy(void)
- {
- (void)memcpy(&__data_region_start, &__data_region_load_start,
- (uintptr_t)&__data_region_end - (uintptr_t)&__data_region_start);
- #ifdef CONFIG_ARCH_HAS_RAMFUNC_SUPPORT
- (void)memcpy(&__ramfunc_start, &__ramfunc_load_start,
- (uintptr_t) &__ramfunc_size);
- #endif
- #ifdef CONFIG_SLEEP_FUNC_IN_SRAM
- (void)memcpy(&_sram_data_start, &_sram_data_rom_start,
- (uintptr_t) &_sram_data_ram_size);
- #endif
- #if DT_NODE_HAS_STATUS(DT_CHOSEN(zephyr_ccm), okay)
- (void)memcpy(&__ccm_data_start, &__ccm_data_rom_start,
- __ccm_data_end - __ccm_data_start);
- #endif
- #if DT_NODE_HAS_STATUS(DT_CHOSEN(zephyr_itcm), okay)
- (void)memcpy(&__itcm_start, &__itcm_load_start,
- (uintptr_t) &__itcm_size);
- #endif
- #if DT_NODE_HAS_STATUS(DT_CHOSEN(zephyr_dtcm), okay)
- (void)memcpy(&__dtcm_data_start, &__dtcm_data_load_start,
- __dtcm_data_end - __dtcm_data_start);
- #endif
- #ifdef CONFIG_CODE_DATA_RELOCATION
- extern void data_copy_xip_relocation(void);
- data_copy_xip_relocation();
- #endif
- #ifdef CONFIG_USERSPACE
- #ifdef CONFIG_STACK_CANARIES
-
- uintptr_t guard_copy = __stack_chk_guard;
- uint8_t *src = (uint8_t *)&_app_smem_rom_start;
- uint8_t *dst = (uint8_t *)&_app_smem_start;
- uint32_t count = _app_smem_end - _app_smem_start;
- guard_copy = __stack_chk_guard;
- while (count > 0) {
- *(dst++) = *(src++);
- count--;
- }
- __stack_chk_guard = guard_copy;
- #else
- (void)memcpy(&_app_smem_start, &_app_smem_rom_start,
- _app_smem_end - _app_smem_start);
- #endif
- #endif
- }
|