board: nsim: add nsim.props and fix libraries

Signed-off-by: Jingru <jingru@synopsys.com>
This commit is contained in:
Jingru
2020-03-23 21:33:23 +08:00
parent 7d7f67e32f
commit bfe3ee1964
10 changed files with 185 additions and 50 deletions

View File

@@ -4,6 +4,10 @@
"arc_timer.h": "c",
"board.h": "c",
"console_io.h": "c",
"xprintf.h": "c"
"xprintf.h": "c",
"array": "c",
"string_view": "c",
"initializer_list": "c",
"utility": "c"
}
}

View File

@@ -21,6 +21,7 @@
typedef struct cpu_context_st {
cpu_data_t pc;
cpu_data_t blink;
cpu_data_t task;
cpu_data_t status32;
cpu_data_t r0;
} cpu_context_t;

View File

@@ -188,7 +188,7 @@ __KNL__ void cpu_standby_mode_enter(void)
}
#endif /* TOS_CFG_PWR_MGR_EN */
extern void start_r(void);
__KNL__ k_stack_t *cpu_task_stk_init(void *entry,
void *arg,
void *exit,
@@ -199,15 +199,16 @@ __KNL__ k_stack_t *cpu_task_stk_init(void *entry,
cpu_context_t *regs = 0;
sp = (cpu_data_t *)&stk_base[stk_size];
sp = (cpu_data_t *)((cpu_addr_t)sp & 0xFFFFFFFC);
sp = (cpu_data_t *)((cpu_addr_t)sp & 0xFFFFFFC);
sp -= (sizeof(cpu_context_t)/sizeof(cpu_data_t));
regs = (cpu_context_t*) sp;
/* auto-saved on exception(pendSV) by hardware */
regs->pc = (cpu_data_t)entry;
regs->pc = (cpu_data_t)start_r;
regs->blink = (cpu_data_t)exit;
regs->r0 = (cpu_data_t)arg;
regs->task = (cpu_data_t)entry;
regs->status32 = (cpu_data_t)(AUX_STATUS_MASK_IE | ((-1 - INT_PRI_MIN) << 1) | STATUS32_RESET_VALUE);
regs->r0 = (cpu_data_t)arg;
return (k_stack_t *)sp;
}

View File

@@ -7,6 +7,8 @@
.global port_sched_start
.global port_context_switch
.global start_r
.extern k_curr_task
.extern k_next_task
@@ -40,18 +42,26 @@ port_cpsr_restore:
.type port_sched_start, %function
port_sched_start:
push_s blink
clri
mov r0, 0
mov r0, k_curr_task
mov r1, k_next_task
ld r0, [k_curr_task]
ld r1, [k_next_task]
ld r2, [r1]
st r2, [r0] /* k_curr_task = k_next_task*/
ld sp, [r2]
seti
j [r0]
st r2, [r0] /*k_curr_task=k_next_task*/
ld r0, [r2]
ld sp, [r0]
pop r3
j [r3]
.type start_r, %function
start_r:
pop blink;
pop r1
pop r2
pop r0
j_s.d [r1]
kflag r2
.type port_context_switch, %function
port_context_switch:
pop r15

View File

@@ -1,28 +1,7 @@
#include "cmsis_os.h"
#include "embARC.h"
#include "embARC_debug.h"
static uint32_t cyc_hz_count = (BOARD_CPU_CLOCK / BOARD_SYS_TIMER_HZ);
#define APPLICATION_TASK_STK_SIZE 1024*64
static void board_timer_isr(void *ptr)
{
timer_int_clear(BOARD_SYS_TIMER_ID);
board_timer_update(BOARD_SYS_TIMER_HZ);
}
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);
}
}
#define APPLICATION_TASK_STK_SIZE 4096
extern void application_entry(void *arg);
osThreadDef(application_entry, osPriorityNormal, 1, APPLICATION_TASK_STK_SIZE);
@@ -36,14 +15,8 @@ EMBARC_WEAK void application_entry(void *arg)
int main(void)
{
exc_int_init();
arc_cache_init();
board_init();
board_timer_init();
xprintf_setup();
printf("Welcome to TencentOS tiny\r\n");
osKernelInitialize(); // TOS Tiny kernel initialize
osThreadCreate(osThread(application_entry), NULL); // Create TOS Tiny task
osKernelStart(); // Start TOS Tiny
}

View File

@@ -178,8 +178,8 @@ CFLAGS += -MMD -MP -MF"$(@:%.o=%.d)"
# link script
LDSCRIPT = linker_template_gnu.ldf
# libraries
LIBS = -lc -lm -lnosys
# libraries -lc -lm -lnosys
LIBS = -lc -lgcc
LIBDIR =
LDFLAGS = --specs=nsim.specs -mcpu=em4_dmips -mlittle-endian -mcode-density -mdiv-rem -mswap -mnorm -mmpy-option=6 -mbarrel-shifter --param l1-cache-size=16384 --param l1-cache-line-size=32 $(LIBDIR) $(LIBS) -mno-sdata -nostartfiles -Wl,-M,-Map=$(BUILD_DIR)/$(TARGET).map -lm -Wl,--script=$(LDSCRIPT)
@@ -227,6 +227,8 @@ $(BUILD_DIR):
clean:
-rm -fR $(BUILD_DIR)
run : build/TencentOS_tiny.elf
nsimdrv -p nsim_emt=1 -propsfile nsim.props build/TencentOS_tiny.elf
#######################################
# dependencies
#######################################

View File

@@ -0,0 +1,68 @@
nsim_isa_family=av2em
nsim_isa_core=3
arcver=0x3
nsim_isa_rgf_num_banks=2
nsim_isa_rgf_banked_regs=32
nsim_isa_rgf_num_regs=32
nsim_isa_rgf_num_wr_ports=2
nsim_isa_big_endian=0
nsim_isa_lpc_size=32
nsim_isa_pc_size=32
nsim_isa_addr_size=32
nsim_isa_code_density_option=2
nsim_isa_div_rem_option=1
nsim_isa_turbo_boost=1
nsim_isa_swap_option=1
nsim_isa_bitscan_option=1
nsim_isa_mpy_option=8
nsim_isa_shift_option=3
mpu_regions=16
mpu_version=2
nsim_isa_dsp_option=2
nsim_isa_dsp_complex_option=1
nsim_isa_dsp_divsqrt_option=1
nsim_isa_dsp_itu_option=1
nsim_isa_dsp_itu_option=1
nsim_isa_dsp_accshift_option=2
nsim_isa_agu_size=large
nsim_isa_agu_wb_depth=4
nsim_isa_agu_accord=1
nsim_isa_xy=1
nsim_isa_xy_config=dccm_y
nsim_isa_xy_size=8K
nsim_isa_xy_interleave=1
nsim_isa_xy_y_base=0xe0000000
nsim_isa_fpus_div_option=1
nsim_isa_fpu_mac_option=1
nsim_isa_fpuda_option=1
nsim_isa_fpu_fast_mpy_option=0
nsim_isa_fpu_fast_div_option=0
nsim_isa_bitstream_option=1
nsim_isa_enable_timer_0=1
nsim_isa_timer_0_int_level=1
nsim_isa_enable_timer_1=1
nsim_isa_timer_1_int_level=0
nsim_isa_num_actionpoints=2
nsim_isa_stack_checking=1
nsim_isa_has_dmp_peripheral=1
nsim_isa_smart_stack_entries=8
nsim_isa_number_of_interrupts=20
nsim_isa_number_of_levels=4
nsim_isa_number_of_external_interrupts=16
nsim_isa_fast_irq=1
nsim_isa_intvbase_preset=0x0
dcache=16384,32,2,a
nsim_isa_dc_feature_level=2
icache=16384,32,2,a
nsim_isa_ic_feature_level=2
dccm_size=0x80000
dccm_base=0x80000000
nsim_isa_dccm_interleave=1
iccm0_size=0x80000
iccm0_base=0x00000000
nsim_isa_pct_counters=8
nsim_isa_dmac_option=1
nsim_isa_dmac_channels=2
nsim_isa_dmac_registers=0
nsim_isa_dmac_fifo_depth=2
nsim_isa_dmac_int_config=single_internal

View File

@@ -65,6 +65,7 @@ void task3(void *arg)
void application_entry(void *arg)
{
printf("***I am task\r\n");
osThreadCreate(osThread(task1), NULL); // Create task1
osThreadCreate(osThread(task2), NULL); // Create task2
}

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 main
.extern board_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 main /* board-level main */
jl board_main /* board-level main */
b _exit_loop
.global _exit_loop

View File

@@ -84,6 +84,81 @@ 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