boarc: nsim: add source code to initialize board and start os

Signed-off-by: Jingru <jingru@synopsys.com>
This commit is contained in:
Jingru
2020-03-17 18:17:10 +08:00
parent 65f55e73e5
commit ddd2d53f06
9 changed files with 123 additions and 115 deletions

View File

@@ -49,7 +49,7 @@
.weak _f_sdata /* start of small data, defined in link script */
.weak init_hardware_hook /* app hardware init hook */
.extern board_main
.extern main
.extern exc_entry_table
/* initial vector table */
@@ -188,7 +188,7 @@ _s3_clear_bss_loop:
/* STAGE 3: go to next level initialization */
_arc_reset_call_main:
jl board_main /* board-level main */
jl main /* board-level main */
b _exit_loop
.global _exit_loop

View File

@@ -84,80 +84,6 @@ static volatile uint32_t gl_ms_cnt = 0;
#define HZ_COUNT_CONV(precision, base) ((precision) / (base))
/**
* @brief Board bare-metal timer interrupt.
* Interrupt frequency is based on the defined @ref BOARD_SYS_TIMER_HZ
*/
static void board_timer_isr(void *ptr)
{
timer_int_clear(BOARD_SYS_TIMER_ID);
board_timer_update(BOARD_SYS_TIMER_HZ);
}
/**
* @brief Initialise bare-metal board timer and interrupt
* @details
* This function is called in @ref board_init, and
* it initializes the 1-MS timer interrupt for bare-metal mode
*/
static void board_timer_init(void)
{
if (timer_present(BOARD_SYS_TIMER_ID)) {
int_disable(BOARD_SYS_TIMER_INTNO); /* disable first then enable */
int_handler_install(BOARD_SYS_TIMER_INTNO, board_timer_isr);
timer_start(BOARD_SYS_TIMER_ID, TIMER_CTRL_IE | TIMER_CTRL_NH, cyc_hz_count); /* start 1ms timer interrupt */
int_enable(BOARD_SYS_TIMER_INTNO);
}
}
static void platform_print_banner(void)
{
EMBARC_PRINTF("%s\r\n", embarc_banner);
EMBARC_PRINTF("embARC Build Time: %s, %s\r\n", __DATE__, __TIME__);
#if defined(__GNU__)
EMBARC_PRINTF("Compiler Version: ARC GNU, %s\r\n", __VERSION__);
#else
EMBARC_PRINTF("Compiler Version: Metaware, %s\r\n\r\n", __VERSION__);
#endif
}
EMBARC_WEAK void platform_main(void)
{
#ifdef LIB_CONSOLE
xprintf_setup();
#endif
platform_print_banner();
arc_goto_main(0, NULL);
}
EMBARC_WEAK void board_main(void)
{
#if defined(__MW__)
/* Metaware toolchain C++ init */
arc_mwdt_init();
#elif defined(__GNU__)
/* ARC GNU toolchain C++ init */
arc_gnu_do_global_ctors_aux();
arc_gnu_do_init_array_aux();
#endif
/* init core level interrupt & exception management */
exc_int_init();
/* init cache */
arc_cache_init();
/* necessary board level init */
board_init();
/* Initialise bare-metal board timer and interrupt */
board_timer_init();
/* platform (e.g RTOS, baremetal)level init */
platform_main();
#if defined(__MW__)
arc_mwdt_fini();
#elif defined(__GNU__)
arc_gnu_do_global_dtors_aux();
#endif
}
/**
* @brief Update timer counter and other MS period operation