From 32f2d624d0333a3eeb660cd6500401841e309ced Mon Sep 17 00:00:00 2001 From: Nazareno Bruschi Date: Mon, 21 Dec 2020 10:23:38 +0100 Subject: [PATCH] Added CONFIG_NO_STD_RELOC: Avoids tiny section -> Fixes linking-time optimizations --- .gitignore | 6 +++--- rtos/pulpos/common/include/pos/data/data.h | 6 ++++-- rtos/pulpos/common/kernel/soc_event_v2_itc.S | 17 +++++++++++++++++ rtos/pulpos/common/kernel/task_asm.S | 18 ++++++++++++++++++ .../common/rules/pulpos/configs/default.mk | 1 + rtos/pulpos/pulp/drivers/cluster/pe-eu-v3.S | 4 ++++ 6 files changed, 47 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index 04a70bba..11348367 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,6 @@ *~ __pycache__ -/build +build/ +install/ log_build.txt -/.sconsign.dblite - +tools/gap-configs/.sconsign.dblite diff --git a/rtos/pulpos/common/include/pos/data/data.h b/rtos/pulpos/common/include/pos/data/data.h index 32069a02..58a75814 100644 --- a/rtos/pulpos/common/include/pos/data/data.h +++ b/rtos/pulpos/common/include/pos/data/data.h @@ -38,7 +38,7 @@ #ifndef LANGUAGE_ASSEMBLY // We cannot use tiny attribute if we use a generic riscv toolchain or LLVM or we there is fc specific memeory (TCDM or L2) -#if (defined(ARCHI_HAS_FC_TCDM) || defined(ARCHI_HAS_L2_ALIAS)) && !defined(__LLVM__) && !defined(__RISCV_GENERIC__) +#if (defined(ARCHI_HAS_FC_TCDM) || defined(ARCHI_HAS_L2_ALIAS)) && !defined(__LLVM__) && !defined(__RISCV_GENERIC__) && defined(CONFIG_NO_STD_RELOC) #define POS_FC_TINY_ATTRIBUTE __attribute__ ((tiny)) #else #define POS_FC_TINY_ATTRIBUTE @@ -53,8 +53,10 @@ #define PI_L2 __attribute__((section(".l2_data"))) -#if defined(ARCHI_HAS_L1_ALIAS) +#if defined(ARCHI_HAS_L1_ALIAS) && defined(CONFIG_NO_STD_RELOC) #define PI_CL_L1_TINY __attribute__ ((tiny)) __attribute__((section(".data_tiny_l1"))) +#else +#define PI_CL_L1_TINY __attribute__((section(".data_tiny_l1"))) #endif #define PI_CL_L1 __attribute__((section(".data_l1"))) diff --git a/rtos/pulpos/common/kernel/soc_event_v2_itc.S b/rtos/pulpos/common/kernel/soc_event_v2_itc.S index ea91f13c..36ec4daf 100644 --- a/rtos/pulpos/common/kernel/soc_event_v2_itc.S +++ b/rtos/pulpos/common/kernel/soc_event_v2_itc.S @@ -68,8 +68,15 @@ #else +#ifdef CONFIG_NO_STD_RELOC lw x12, %tiny(pos_soc_event_callback)(x11) lw x11, %tiny(pos_soc_event_callback_arg)(x11) +#else + la t0, pos_soc_event_callback + p.lw x12, t0(x11) + la t0, pos_soc_event_callback_arg + p.lw x11, t0(x11) +#endif la x9, pos_soc_event_handler_end_asm j pos_irq_call_external_c_function @@ -89,12 +96,22 @@ pos_soc_event_store_asm: # If the event is not handled, store it in the soc event status mask srli x11, x10, 5 slli x11, x11, 2 +#ifdef CONFIG_NO_STD_RELOC lw x12, %tiny(pos_soc_event_status)(x11) +#else + la t0, pos_soc_event_status + p.lw x12, t0(x11) +#endif andi x10, x10, 0x1f p.bsetr x12, x12, x10 +#ifdef CONFIG_NO_STD_RELOC sw x12, %tiny(pos_soc_event_status)(x11) +#else + la t0, pos_soc_event_status + p.sw x12, t0(x11) +#endif diff --git a/rtos/pulpos/common/kernel/task_asm.S b/rtos/pulpos/common/kernel/task_asm.S index f8768fe2..7616ae61 100644 --- a/rtos/pulpos/common/kernel/task_asm.S +++ b/rtos/pulpos/common/kernel/task_asm.S @@ -31,18 +31,36 @@ pos_task_push_asm: // x11/a1: the task // x12/a2: temporary register +#ifdef CONFIG_NO_STD_RELOC lw x12, %tiny(pos_sched_first)(x0) +#else + la t0, pos_sched_first + lw x12, 0(t0) +#endif sw x0, PI_TASK_T_NEXT(x11) beqz x12, __rt_no_first +#ifdef CONFIG_NO_STD_RELOC lw x12, %tiny(pos_sched_last)(x0) +#else + la t0, pos_sched_last + lw x12, 0(t0) +#endif sw x11, PI_TASK_T_NEXT(x12) j __rt_common __rt_no_first: +#ifdef CONFIG_NO_STD_RELOC sw x11, %tiny(pos_sched_first)(x0) +#else + sw x11, pos_sched_first, t0 +#endif __rt_common: +#ifdef CONFIG_NO_STD_RELOC sw x11, %tiny(pos_sched_last)(x0) +#else + sw x11, pos_sched_last, t0 +#endif enqueue_end: jr x9 diff --git a/rtos/pulpos/common/rules/pulpos/configs/default.mk b/rtos/pulpos/common/rules/pulpos/configs/default.mk index ee7c3483..e31370c9 100644 --- a/rtos/pulpos/common/rules/pulpos/configs/default.mk +++ b/rtos/pulpos/common/rules/pulpos/configs/default.mk @@ -3,6 +3,7 @@ CONFIG_KERNEL=1 CONFIG_LDSCRIPT=1 CONFIG_LIBC_MINIMAL=1 #CONFIG_USE_ASM_OPTIM=1 +#CONFIG_NO_STD_RELOC=1 CONFIG_IO_UART_ITF=0 CONFIG_IO_UART_BAUDRATE=115200 CONFIG_IO_UART=0 diff --git a/rtos/pulpos/pulp/drivers/cluster/pe-eu-v3.S b/rtos/pulpos/pulp/drivers/cluster/pe-eu-v3.S index 9dab2c6f..90f3d4ec 100644 --- a/rtos/pulpos/pulp/drivers/cluster/pe-eu-v3.S +++ b/rtos/pulpos/pulp/drivers/cluster/pe-eu-v3.S @@ -117,7 +117,11 @@ pos_master_loop_exec_task: add sp, sp, t1 +#ifdef CONFIG_NO_STD_RELOC sw t6, %tiny(pos_cluster_nb_active_pe)(x0) +#else + sw t6, pos_cluster_nb_active_pe, t3 +#endif pos_no_stack_check: // Whatever the number of cores, we need to setup the barrier as the master code is compiled to use it