This repository has been archived on 2023-07-17. You can view files and clone it, but cannot push or open issues or pull requests.
bl_mcu_sdk/drivers/soc/bl616/std/startup/start_load.c
2023-02-24 21:33:36 +08:00

93 lines
2.3 KiB
C

#include <stdint.h>
#define __STARTUP_CLEAR_BSS 1
/*----------------------------------------------------------------------------
Linker generated Symbols
*----------------------------------------------------------------------------*/
extern uint32_t __itcm_load_addr;
extern uint32_t __dtcm_load_addr;
extern uint32_t __system_ram_load_addr;
extern uint32_t __ram_load_addr;
extern uint32_t __nocache_ram_load_addr;
extern uint32_t __text_code_start__;
extern uint32_t __text_code_end__;
extern uint32_t __tcm_code_start__;
extern uint32_t __tcm_code_end__;
extern uint32_t __tcm_data_start__;
extern uint32_t __tcm_data_end__;
extern uint32_t __ram_data_start__;
extern uint32_t __ram_data_end__;
extern uint32_t __bss_start__;
extern uint32_t __bss_end__;
extern uint32_t __noinit_data_start__;
extern uint32_t __noinit_data_end__;
extern uint32_t __nocache_ram_data_start__;
extern uint32_t __nocache_ram_data_end__;
extern uint32_t __StackTop;
extern uint32_t __StackLimit;
extern uint32_t __HeapBase;
extern uint32_t __HeapLimit;
//extern uint32_t __copy_table_start__;
//extern uint32_t __copy_table_end__;
//extern uint32_t __zero_table_start__;
//extern uint32_t __zero_table_end__;
void start_load(void)
{
uint32_t *pSrc, *pDest;
uint32_t *pTable __attribute__((unused));
/* Copy ITCM code */
pSrc = &__itcm_load_addr;
pDest = &__tcm_code_start__;
for (; pDest < &__tcm_code_end__;) {
*pDest++ = *pSrc++;
}
/* Copy DTCM code */
pSrc = &__dtcm_load_addr;
pDest = &__tcm_data_start__;
for (; pDest < &__tcm_data_end__;) {
*pDest++ = *pSrc++;
}
/* BF Add OCARAM data copy */
pSrc = &__ram_load_addr;
pDest = &__ram_data_start__;
for (; pDest < &__ram_data_end__;) {
*pDest++ = *pSrc++;
}
/* BF Add no cache ram data copy */
pSrc = &__nocache_ram_load_addr;
pDest = &__nocache_ram_data_start__;
for (; pDest < &__nocache_ram_data_end__;) {
*pDest++ = *pSrc++;
}
#ifdef __STARTUP_CLEAR_BSS
/* Single BSS section scheme.
*
* The BSS section is specified by following symbols
* __bss_start__: start of the BSS section.
* __bss_end__: end of the BSS section.
*
* Both addresses must be aligned to 4 bytes boundary.
*/
pDest = &__bss_start__;
for (; pDest < &__bss_end__;) {
*pDest++ = 0ul;
}
#endif
}