LCOV - code coverage report
Current view: top level - kernel - xip.c (source / functions) Hit Total Coverage
Test: coverage.info Lines: 5 5 100.0 %
Date: 2022-08-18 11:36:24 Functions: 1 1 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 0 -

           Branch data     Line data    Source code
       1                 :            : /*
       2                 :            :  * Copyright (c) 2010-2014 Wind River Systems, Inc.
       3                 :            :  * Copyright (c) 2020 Intel Corporation
       4                 :            :  *
       5                 :            :  * SPDX-License-Identifier: Apache-2.0
       6                 :            :  */
       7                 :            : 
       8                 :            : 
       9                 :            : #include <zephyr.h>
      10                 :            : #include <kernel.h>
      11                 :            : #include <kernel_internal.h>
      12                 :            : #include <linker/linker-defs.h>
      13                 :            : 
      14                 :            : #ifdef CONFIG_STACK_CANARIES
      15                 :            : extern volatile uintptr_t __stack_chk_guard;
      16                 :            : #endif /* CONFIG_STACK_CANARIES */
      17                 :            : 
      18                 :            : /**
      19                 :            :  * @brief Copy the data section from ROM to RAM
      20                 :            :  *
      21                 :            :  * This routine copies the data section from ROM to RAM.
      22                 :            :  */
      23                 :          1 : void z_data_copy(void)
      24                 :            : {
      25                 :          1 :         z_early_memcpy(&__data_region_start, &__data_region_load_start,
      26                 :          1 :                        __data_region_end - __data_region_start);
      27                 :            : #ifdef CONFIG_ARCH_HAS_RAMFUNC_SUPPORT
      28                 :          1 :         z_early_memcpy(&__ramfunc_start, &__ramfunc_load_start,
      29                 :            :                        (uintptr_t) &__ramfunc_size);
      30                 :            : #endif /* CONFIG_ARCH_HAS_RAMFUNC_SUPPORT */
      31                 :            : #if DT_NODE_HAS_STATUS(DT_CHOSEN(zephyr_ccm), okay)
      32                 :            :         z_early_memcpy(&__ccm_data_start, &__ccm_data_rom_start,
      33                 :            :                        __ccm_data_end - __ccm_data_start);
      34                 :            : #endif
      35                 :            : #if DT_NODE_HAS_STATUS(DT_CHOSEN(zephyr_itcm), okay)
      36                 :            :         z_early_memcpy(&__itcm_start, &__itcm_load_start,
      37                 :            :                        (uintptr_t) &__itcm_size);
      38                 :            : #endif
      39                 :            : #if DT_NODE_HAS_STATUS(DT_CHOSEN(zephyr_dtcm), okay)
      40                 :            :         z_early_memcpy(&__dtcm_data_start, &__dtcm_data_load_start,
      41                 :            :                        __dtcm_data_end - __dtcm_data_start);
      42                 :            : #endif
      43                 :            : #ifdef CONFIG_CODE_DATA_RELOCATION
      44                 :            :         extern void data_copy_xip_relocation(void);
      45                 :            : 
      46                 :            :         data_copy_xip_relocation();
      47                 :            : #endif  /* CONFIG_CODE_DATA_RELOCATION */
      48                 :            : #ifdef CONFIG_USERSPACE
      49                 :            : #ifdef CONFIG_STACK_CANARIES
      50                 :            :         /* stack canary checking is active for all C functions.
      51                 :            :          * __stack_chk_guard is some uninitialized value living in the
      52                 :            :          * app shared memory sections. Preserve it, and don't make any
      53                 :            :          * function calls to perform the memory copy. The true canary
      54                 :            :          * value gets set later in z_cstart().
      55                 :            :          */
      56                 :            :         uintptr_t guard_copy = __stack_chk_guard;
      57                 :            :         uint8_t *src = (uint8_t *)&_app_smem_rom_start;
      58                 :            :         uint8_t *dst = (uint8_t *)&_app_smem_start;
      59                 :            :         uint32_t count = _app_smem_end - _app_smem_start;
      60                 :            : 
      61                 :            :         guard_copy = __stack_chk_guard;
      62                 :            :         while (count > 0) {
      63                 :            :                 *(dst++) = *(src++);
      64                 :            :                 count--;
      65                 :            :         }
      66                 :            :         __stack_chk_guard = guard_copy;
      67                 :            : #else
      68                 :            :         z_early_memcpy(&_app_smem_start, &_app_smem_rom_start,
      69                 :            :                        _app_smem_end - _app_smem_start);
      70                 :            : #endif /* CONFIG_STACK_CANARIES */
      71                 :            : #endif /* CONFIG_USERSPACE */
      72                 :          1 : }

Generated by: LCOV version 1.14