This is an automated email from the ASF dual-hosted git repository. GUIDINGLI pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit 2b7563fc546c3e053a09d526b73ec2369274870b Author: zhangyu117 <[email protected]> AuthorDate: Sat Feb 8 10:18:45 2025 +0800 arch/tricore: add Infineon MPU driver Add the MPU initialization interface and invoke it during startup. Switch between kernel and user protection register sets on syscall entry and return, with board-specific initialization stubs for TC397 and TC4D9. Signed-off-by: zhangyu117 <[email protected]> --- arch/tricore/src/common/tricore_internal.h | 4 ++++ arch/tricore/src/common/tricore_main.c | 4 ++++ arch/tricore/src/common/tricore_svcall.c | 12 ++++++++---- boards/tricore/tc3xx/a2g-tc397-5v-tft/src/tc397_bringup.c | 8 ++++++++ boards/tricore/tc4xx/triboard_tc4x9_com/src/tc4da_bringup.c | 8 ++++++++ 5 files changed, 32 insertions(+), 4 deletions(-) diff --git a/arch/tricore/src/common/tricore_internal.h b/arch/tricore/src/common/tricore_internal.h index 91017e3e935..2ebf0dc6a68 100644 --- a/arch/tricore/src/common/tricore_internal.h +++ b/arch/tricore/src/common/tricore_internal.h @@ -246,6 +246,10 @@ int tricore_init_dbgmonitor(void); void tricore_userspace(void); #endif +#ifdef CONFIG_ARCH_USE_MPU +void tricore_mpuinit(void); +#endif + /* System Timer *************************************************************/ struct oneshot_lowerhalf_s * diff --git a/arch/tricore/src/common/tricore_main.c b/arch/tricore/src/common/tricore_main.c index b9ec352dde3..f604026c42b 100644 --- a/arch/tricore/src/common/tricore_main.c +++ b/arch/tricore/src/common/tricore_main.c @@ -42,6 +42,10 @@ static void core_main(void) tricore_fpuinit(); #endif +#ifdef CONFIG_ARCH_USE_MPU + tricore_mpuinit(); +#endif + /* !!WATCHDOG0 AND SAFETY WATCHDOG ARE DISABLED HERE!! * Enable the watchdogs and service them periodically if it is required */ diff --git a/arch/tricore/src/common/tricore_svcall.c b/arch/tricore/src/common/tricore_svcall.c index 7bf21d20e85..0f65de36099 100644 --- a/arch/tricore/src/common/tricore_svcall.c +++ b/arch/tricore/src/common/tricore_svcall.c @@ -146,7 +146,8 @@ void tricore_svcall(volatile void *trap) /* Return unprivileged mode */ puregs[REG_PSW] = - (puregs[REG_PSW] & ~PSW_MODE_MASK) | PSW_IO_USER0; + (puregs[REG_PSW] & (~PSW_MODE_MASK) & (~PSW_PRS_MASK)) | + (PSW_IO_USER0 | PSW_PRS_USER); } break; #endif @@ -188,7 +189,8 @@ void tricore_svcall(volatile void *trap) /* Return unprivileged mode */ puregs[REG_PSW] = - (puregs[REG_PSW] & ~PSW_MODE_MASK) | PSW_IO_USER0; + (puregs[REG_PSW] & (~PSW_MODE_MASK) & (~PSW_PRS_MASK)) | + (PSW_IO_USER0 | PSW_PRS_USER); } break; #endif @@ -235,7 +237,8 @@ void tricore_svcall(volatile void *trap) /* Return unprivileged mode */ puregs[REG_PSW] = - (puregs[REG_PSW] & ~PSW_MODE_MASK) | PSW_IO_USER0; + (puregs[REG_PSW] & (~PSW_MODE_MASK) & (~PSW_PRS_MASK)) | + (PSW_IO_USER0 | PSW_PRS_USER); } break; #endif @@ -260,7 +263,8 @@ void tricore_svcall(volatile void *trap) /* Return privileged mode */ puregs[REG_PSW] = - (puregs[REG_PSW] & ~PSW_MODE_MASK) | PSW_IO_SUPERVISOR; + (puregs[REG_PSW] & (~PSW_MODE_MASK) & (~PSW_PRS_MASK)) | + (PSW_IO_SUPERVISOR); } break; #endif diff --git a/boards/tricore/tc3xx/a2g-tc397-5v-tft/src/tc397_bringup.c b/boards/tricore/tc3xx/a2g-tc397-5v-tft/src/tc397_bringup.c index a7c229de88a..0ee14dc79cf 100644 --- a/boards/tricore/tc3xx/a2g-tc397-5v-tft/src/tc397_bringup.c +++ b/boards/tricore/tc3xx/a2g-tc397-5v-tft/src/tc397_bringup.c @@ -31,12 +31,20 @@ #include <nuttx/fs/fs.h> +#include "tricore_internal.h" #include "tc397.h" /**************************************************************************** * Public Functions ****************************************************************************/ +#ifdef CONFIG_ARCH_USE_MPU +void tricore_mpuinit(void) +{ + /* TODO: Initialize the MPU. */ +} +#endif + /**************************************************************************** * Name: tc397_bringup * diff --git a/boards/tricore/tc4xx/triboard_tc4x9_com/src/tc4da_bringup.c b/boards/tricore/tc4xx/triboard_tc4x9_com/src/tc4da_bringup.c index 7a27567b277..ef901bb53d2 100644 --- a/boards/tricore/tc4xx/triboard_tc4x9_com/src/tc4da_bringup.c +++ b/boards/tricore/tc4xx/triboard_tc4x9_com/src/tc4da_bringup.c @@ -31,12 +31,20 @@ #include <nuttx/fs/fs.h> +#include "tricore_internal.h" #include "tc4da.h" /**************************************************************************** * Public Functions ****************************************************************************/ +#ifdef CONFIG_ARCH_USE_MPU +void tricore_mpuinit(void) +{ + /* TODO: Initialize the MPU. */ +} +#endif + /**************************************************************************** * Name: tc4da_bringup *
