ssekar15 commented on code in PR #22588: URL: https://github.com/apache/nuttx/pull/22588#discussion_r4737839992
########## arch/tricore/src/common/gnu/tricore_head.S: ########## @@ -25,195 +25,172 @@ ****************************************************************************/ #include <nuttx/config.h> -#include <arch/csfr.h> -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -#define TRICORE_PSW_RESET 0x980 /* Supervisor, call depth counting on */ - -#ifdef CONFIG_ARCH_CHIP_TC3X -# define TC3X_WDTCPU0_CON0 0xf003624c /* CPU0 watchdog CON0, 0xc apart per CPU */ -#endif -#ifdef CONFIG_ARCH_CHIP_TC4X -# define TC4X_PSW_VIRT 0xb00 /* PSW for disabling the virtualization */ -#endif - -/* Make the CSA link word of the CSA address in addr: the segment in bits - * 19:16 and the offset in bits 15:0. - */ - - .macro tricore_csa_link addr, tmp1, tmp2 - extr.u \tmp1, \addr, 6, 16 - extr.u \tmp2, \addr, 12, 20 - insert \addr, \tmp2, \tmp1, 0, 16 - .endm +#include <arch/irq.h> +#include <chip.h> /**************************************************************************** - * Private Functions + * Pre-processor Definitions ****************************************************************************/ -/**************************************************************************** - * Name: tricore_head - * - * Description: - * Set up the core registers and the CSA list, which the code has to do - * before it can call anything: the small data base registers, the trap - * and interrupt vectors, the interrupt stack, the caches and the free - * CSA list with LCX at the third last entry. Then set the stack and the - * PSW, disable the watchdogs, copy .data and clear .bss, set up the - * clocks (see tricore_internal.h) and jump to tricore_start. - * - * On TC3xx BTV, BIV, ISP, PCON0 and DCON0 are CPU ENDINIT protected, - * so the ENDINIT of the CPU watchdog is cleared around them. - * - * TC4xx first disables the virtualization with a call to - * tricore_virt_off, on the boot stack and the single boot CSA in the - * PSPR that the linker script gives, as the iLLD startup code does. - * Then it links the boot CSAs in the PSPR and, before the DSPR that - * holds the CSA list and the DLMU that holds .data and .bss are - * initialized, disables the watchdogs and initializes the RAMs in C - * (tricore_wdt_disable, tricore_ram_init). - * - ****************************************************************************/ +/* 32-bit address to address register */ - .text - .type tricore_head, %function -tricore_head: - movh.a %a1, hi:__a1_mem - lea %a1, [%a1]lo:__a1_mem - movh.a %a0, hi:__a0_mem - lea %a0, [%a0]lo:__a0_mem - movh.a %a8, hi:__a8_mem - lea %a8, [%a8]lo:__a8_mem - movh.a %a9, hi:__a9_mem - lea %a9, [%a9]lo:__a9_mem +.macro mov32a areg, val + movh.a \areg, hi:\val + lea \areg, [\areg]lo:\val +.endm -#ifdef CONFIG_ARCH_CHIP_TC3X - jl tc3x_endinit_clear +/* 32-bit address to data register */ -#endif - movh.a %a15, hi:__TRAPTAB_CPU0 - lea %a15, [%a15]lo:__TRAPTAB_CPU0 - mov.d %d15, %a15 - mtcr TRICORE_CPU_BTV, %d15 - isync +.macro mov32d dreg, val + movh \dreg, hi:\val + addi \dreg, \dreg, lo:\val +.endm -#ifdef CONFIG_ARCH_CHIP_TC4X - movh.a %a15, hi:__psram_boot_csa - lea %a15, [%a15]lo:__psram_boot_csa - mov.d %d15, %a15 - tricore_csa_link %d15, %d14, %d13 - mtcr TRICORE_CPU_FCX, %d15 - isync +/* address to pcxi word */ - call tricore_virt_off +.macro addr2csa addr, tmp + extr.u \tmp, \addr, 6, 16 + extr.u \addr, \addr, 12, 20 + insert \addr, \addr, \tmp, 0, 16 +.endm - movh.a %a15, hi:__TRAPTAB_CPU0 - lea %a15, [%a15]lo:__TRAPTAB_CPU0 - mov.d %d15, %a15 - mtcr TRICORE_CPU_BTV, %d15 - isync +/* chain the free csa list [begin, end), the last link is null */ - /* Free CSA list in the PSPR from __psram_boot_csa to - * __psram_boot_csa_end, LCX at the third last, for the C steps that - * run before the DSPR and the DLMU are initialized - */ - - movh.a %a15, hi:__psram_boot_csa - lea %a15, [%a15]lo:__psram_boot_csa - movh.a %a14, hi:__psram_boot_csa_end - lea %a14, [%a14]lo:__psram_boot_csa_end - mov.d %d15, %a15 - tricore_csa_link %d15, %d14, %d13 - mtcr TRICORE_CPU_FCX, %d15 - isync -1: - addi %d15, %d15, 1 - st.w [%a15], %d15 - lea %a15, [%a15]64 - jne.a %a15, %a14, 1b - - mov %d14, 0 - st.w [%a15]-64, %d14 - addi %d15, %d15, -3 - mtcr TRICORE_CPU_LCX, %d15 - isync +.macro tricore_csainit begin, end, tmp1, tmp2 + mov.d \tmp1, \begin + addr2csa \tmp1, \tmp2 +.Lcsainit\@: + add \tmp1, \tmp1, 1 + st.w [\begin], \tmp1 + lea \begin, [\begin]TC_CONTEXT_SIZE + jne.a \begin, \end, .Lcsainit\@ + mov \tmp1, 0 + st.w [\begin]-TC_CONTEXT_SIZE, \tmp1 +.endm - call tricore_wdt_disable Review Comment: watchdog must be disable otherwise we faced issue if .data section is too big would take time to copy to dsram. triboard_tc4x9_com does not boot on TC4D7 with this PR, with GCC or TASKING. The same configuration from master (75b4dc85275) boots to nsh and passes ostest on the same. I doubt this is related to wdt issue. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
