zhangyu-duck commented on code in PR #21546: URL: https://github.com/apache/nuttx/pull/21546#discussion_r4510764383
########## arch/tricore/src/tc3xx/tc3xx_start.c: ########## @@ -0,0 +1,277 @@ +/**************************************************************************** + * arch/tricore/src/tc3xx/tc3xx_start.c + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include <nuttx/config.h> + +#include <stdbool.h> +#include <stdint.h> + +#include <arch/arch.h> + +#include "tricore_internal.h" +#include "hardware/tc3xx_cpu.h" +#include "hardware/tc3xx_scu.h" +#include "tc3xx_wdt.h" + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/* The BIV of the single interrupt vector at INTTAB + 0x1fe0 */ + +#define TC3XX_BIV_VECTOR 0x1fe0 + +/**************************************************************************** + * External Function Prototypes + ****************************************************************************/ + +void core0_main(void); + +/**************************************************************************** + * Public Data + ****************************************************************************/ + +/* Provided by the linker script */ + +extern uintptr_t __CSA0[]; +extern uintptr_t __CSA0_END[]; +extern uintptr_t __TRAPTAB_CPU0[]; +extern uintptr_t __INTTAB_CPU0[]; +extern uintptr_t __ISTACK0[]; +extern uintptr_t __START1[]; + +#ifndef CONFIG_TRICORE_TOOLCHAIN_TASKING +extern const uintptr_t __clear_table[]; +extern const uintptr_t __copy_table[]; +#endif + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: tc3xx_csa_init + * + * Description: + * Link the CSAs from start to end into the free context list, with LCX + * at the third last. It runs before any function call is possible, so + * it must not call. + * + ****************************************************************************/ + +static inline_function void tc3xx_csa_init(uintptr_t *start, uintptr_t *end) +{ + uint32_t num = ((uintptr_t)end - (uintptr_t)start) / TC_CONTEXT_SIZE; + uintptr_t *prev = NULL; + uintptr_t *csa = start; + uint32_t link; + uint32_t k; + + for (k = 0; k < num; k++) + { + link = tricore_addr2csa(csa); + if (k == 0) + { + tricore_mtcr(TRICORE_CPU_FCX, link); + } + else + { + *prev = link; + } + + if (k == num - 3) + { + tricore_mtcr(TRICORE_CPU_LCX, link); + } + + prev = csa; + csa += TC_CONTEXT_REGS; + } + + *prev = 0; + UP_DSB(); +} + +/**************************************************************************** + * Name: tc3xx_application_reset + ****************************************************************************/ + +static bool tc3xx_application_reset(void) +{ + uint32_t rststat = getreg32(TC3XX_SCU_RSTSTAT); + uint32_t bit; + + if ((rststat & TC3XX_RSTSTAT_POWERON) != 0) + { + return false; + } + + if ((rststat & TC3XX_RSTSTAT_RESET) != 0) + { + rststat &= TC3XX_RSTSTAT_RESET; + for (bit = 31; (rststat & (1u << bit)) == 0; bit--); + + return ((getreg32(TC3XX_SCU_RSTCON) >> (bit << 1)) & 3) == + TC3XX_RSTCON_APPLICATION; + } + + if ((rststat & TC3XX_RSTSTAT_CB3) != 0) + { + return true; + } + + return (getreg32(TC3XX_CPU0_KRST0) & TC3XX_KRST0_RSTSTAT_MASK) != 0; +} + +/**************************************************************************** + * Name: tc3xx_c_init + * + * Description: + * Clear .bss and copy .data, from the tables of the linker script on + * GCC, with the TASKING runtime otherwise. + * + ****************************************************************************/ + +static void tc3xx_c_init(void) +{ +#ifdef CONFIG_TRICORE_TOOLCHAIN_TASKING + extern void _c_init(void); + + _c_init(); Review Comment: remove,define self not depend on tasking -- 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]
