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

93 lines
2.3 KiB
C
Raw Normal View History

2021-06-04 17:53:16 +08:00
#include <stdint.h>
2021-06-20 12:25:46 +08:00
#define __STARTUP_CLEAR_BSS 1
2021-06-04 17:53:16 +08:00
/*----------------------------------------------------------------------------
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;
2022-11-05 10:44:08 +08:00
extern uint32_t __nocache_ram_load_addr;
2021-06-04 17:53:16 +08:00
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__;
2022-11-05 10:44:08 +08:00
extern uint32_t __nocache_ram_data_start__;
extern uint32_t __nocache_ram_data_end__;
2021-06-04 17:53:16 +08:00
extern uint32_t __StackTop;
extern uint32_t __StackLimit;
extern uint32_t __HeapBase;
extern uint32_t __HeapLimit;
2021-06-04 17:53:16 +08:00
//extern uint32_t __copy_table_start__;
//extern uint32_t __copy_table_end__;
//extern uint32_t __zero_table_start__;
//extern uint32_t __zero_table_end__;
2021-06-20 12:25:46 +08:00
void start_load(void)
{
2021-06-04 17:53:16 +08:00
uint32_t *pSrc, *pDest;
2021-06-20 12:25:46 +08:00
uint32_t *pTable __attribute__((unused));
2021-06-04 17:53:16 +08:00
/* Copy ITCM code */
2021-06-20 12:25:46 +08:00
pSrc = &__itcm_load_addr;
2021-06-04 17:53:16 +08:00
pDest = &__tcm_code_start__;
2021-06-20 12:25:46 +08:00
for (; pDest < &__tcm_code_end__;) {
2021-06-04 17:53:16 +08:00
*pDest++ = *pSrc++;
}
/* Copy DTCM code */
2021-06-20 12:25:46 +08:00
pSrc = &__dtcm_load_addr;
2021-06-04 17:53:16 +08:00
pDest = &__tcm_data_start__;
2021-06-20 12:25:46 +08:00
for (; pDest < &__tcm_data_end__;) {
2021-06-04 17:53:16 +08:00
*pDest++ = *pSrc++;
}
/* BF Add OCARAM data copy */
2021-06-20 12:25:46 +08:00
pSrc = &__ram_load_addr;
2021-06-04 17:53:16 +08:00
pDest = &__ram_data_start__;
2021-06-20 12:25:46 +08:00
for (; pDest < &__ram_data_end__;) {
2021-06-04 17:53:16 +08:00
*pDest++ = *pSrc++;
}
2022-11-05 10:44:08 +08:00
/* 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++;
}
2021-06-04 17:53:16 +08:00
#ifdef __STARTUP_CLEAR_BSS
/* Single BSS section scheme.
2021-06-20 12:25:46 +08:00
*
* 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.
*/
2021-06-04 17:53:16 +08:00
pDest = &__bss_start__;
2021-06-20 12:25:46 +08:00
for (; pDest < &__bss_end__;) {
2021-06-04 17:53:16 +08:00
*pDest++ = 0ul;
}
2021-06-20 12:25:46 +08:00
#endif
2021-06-04 17:53:16 +08:00
}