After addrenv_switch(), the current running task (this_task) may change due to
deferred work execution. Update all architecture interrupt, syscall, and exit
handlers to re-fetch tcb = this_task() after addrenv_switch(). Ensures scheduler
and context operations use the correct TCB, preventing context corruption and
exceptions across SMP and memory-protected builds.
Signed-off-by: hujun5 <hujun5@xiaomi.com>
Add stack dump functionality when tasks exit, which helps with
debugging and understanding task termination conditions.
Signed-off-by: ligd <liguiding1@xiaomi.com>
In SMP mode, running tasks are in g_assignedtasks[cpu], not the
ready-to-run list, so tcb->flink is NULL. When a round-robin timeslice
expires, checking tcb->flink fails to find the next task.
Fix by calling nxsched_switch_running() directly in SMP mode when the
timeslice expires, which properly finds the next eligible task from the
ready-to-run list.
Signed-off-by: Filipe Cavalcanti <filipe.cavalcanti@espressif.com>
Move addrenv_join() call after group_initialize() in nxtask_setup_fork() to fix
null pointer dereference. addrenv_join() accesses child->group which is
initialized by group_initialize(), so the operations must be sequenced
correctly. Reorder initialization to ensure child task group is set up before
address environment join operations.
Signed-off-by: hujun5 <hujun5@xiaomi.com>
The rwcnt (read word count) field in ctucanfd_frame_fmt_s was previously
limited to 4 bits, allowing a maximum value of 15. This is insufficient
to correctly represent the frame size (excluding the FRAME_FORMAT word)
for larger CAN FD frames as required by the CTU CAN FD hardware.
Increase the rwcnt bitfield width to support a larger range and adjust
the structure layout so that ctucanfd_frame_fmt_s has a size that is a
multiple of 4 bytes, as required by the hardware interface.
This change improves correctness and robustness when handling larger
CAN FD frames without affecting existing users.
Signed-off-by: xucheng5 <xucheng5@xiaomi.com>
This patch introduces support for generating a linker map file during
the build process for the x86_64 configuration.
Signed-off-by: xucheng5 <xucheng5@xiaomi.com>
Add REG_SCTLR_EL1 system register initialization in arm64_init_signal_process
when setting up register context for signal handlers. Initialize with current
sctlr_el1 value and apply CONFIG_ARM64_MTE settings if enabled. Fixes regression
where signal handler context was missing critical system control register setup.
Signed-off-by: hujun5 <hujun5@xiaomi.com>
Replace global enter_critical_section() with lightweight spinlock in
gethostname() and sethostname() to reduce interrupt latency while protecting
access to the shared hostname string.
Signed-off-by: hujun5 <hujun5@xiaomi.com>
Replace global critical section with mutex in environment
variable operations. Use nxrmutex_lock/unlock(&group->tg_mutex)
instead of enter/leave_critical_section() to protect
environment access, reducing interrupt latency and
improving SMP responsiveness. Clean up unused
irqstate_t flags variables in env_dup,
env_getenv, env_setenv, and env_unsetenv.
Signed-off-by: hujun5 <hujun5@xiaomi.com>
Add key management interfaces and support for generating key pairs in RSA and ECDSA cryptographic processes to the cryptodev module.
Signed-off-by: makejian <makejian@xiaomi.com>
Replace direct labels for CPU startup routines with indirection through global
variables. Export cpu1_start, cpu2_start, cpu3_start as global objects containing
addresses to __cpu1_start, __cpu2_start, __cpu3_start respectively. Use load-then-
branch-exchange (ldr r1, =cpu*_start; ldr r1, [r1]; bxeq r1) instead of direct beq
jumps. Enables flexible control of CPU startup positions and supports future AMP/
dynamic loading scenarios.
Signed-off-by: hujun5 <hujun5@xiaomi.com>
Add new CONFIG_NCPUS configuration option to support both SMP and AMP modes.
Replace SMP-specific CONFIG_SMP_NCPUS checks with generic CONFIG_NCPUS in ARM
boot code (ARMv7-A, ARMv7-R, ARMv8-R). CONFIG_NCPUS defaults to SMP_NCPUS when
SMP is enabled, or 1 otherwise, enabling multi-CPU support regardless of SMP mode.
Signed-off-by: hujun5 <hujun5@xiaomi.com>
Enable SGI (Software Generated Interrupts) usage in AMP mode for inter-core
communication. Modify arm_cpu_sgi() to use SGI_TGTFILTER_LIST for both SMP and
AMP modes instead of requiring CONFIG_SMP. Add CPU0-only guard checks using
sched_getcpu() to ensure arm_gic0_initialize() executes only once on CPU0 during
initialization in both SMP and AMP configurations.
Signed-off-by: hujun5 <hujun5@xiaomi.com>
We need IFF_IS_RUNNING(dev->d_flags) to be true for ethernet device to
work properly. However, dev->d_flags are not set anywhere in the
Kinetis' ethernet code.
This change updates kinetis_ifup and kinetis_ifdown procedures to call
netdev_carrier_on and netdev_carrier_off to set dev->d_flags.
Signed-off-by: Jiri Vlasak <jvlasak@elektroline.cz>
CC: mm_heap/mm_mallinfo.c chip/bcm2711_serial.c: In function 'bcm2711_miniuart_attach':
chip/bcm2711_serial.c:571:3: error: implicit declaration of function 'up_prioritize_irq' [-Werror=implicit-function-declaration]
571 | up_prioritize_irq(BCM_IRQ_VC_AUX, 0);
| ^~~~~~~~~~~~~~~~~
CC: mm_heap/mm_memalign.c chip/bcm2711_gpio.c: In function 'bcm2711_gpio_irqs_init':
chip/bcm2711_gpio.c:275:7: error: implicit declaration of function 'up_prioritize_irq' [-Werror=implicit-function-declaration]
275 | up_prioritize_irq(g_gpio_irqs[i], 0);
| ^~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
Signed-off-by: ligd <liguiding1@xiaomi.com>
Use regs[REG_SP_EL0] from register context instead of direct sp_el0 system
register read/write operations in arm64_syscall(). Replace read_sysreg(sp_el0)
with regs[REG_SP_EL0] and write_sysreg(usp, sp_el0) with direct assignment to
regs[REG_SP_EL0]. Ensures userspace stack pointer is correctly maintained from
register context during signal delivery, preventing userspace SP corruption on
syscall return.
Signed-off-by: hujun5 <hujun5@xiaomi.com>
Update the can_sendmsg() signature from "struct msghdr *msg" to
"const struct msghdr *msg" to match the updated sendmsg() prototype
and resolve compilation errors due to parameter type inconsistency.
Signed-off-by: guoshichao <guoshichao@xiaomi.com>
To ensure consistency, in all places where the "sendmsg" function is used
either directly or indirectly, the type of the "struct msghdr *msg" parameter
needs to be modified to "const struct msghdr *msg".
Signed-off-by: guoshichao <guoshichao@xiaomi.com>
Since the directory structure of the examples/elf project
has been reorganized, the corresponding ROMFS_IMAGEFILE path
also needs to be adjusted.
Signed-off-by: guoshichao <guoshichao@xiaomi.com>
We have added a defconfig configuration to set the page size of the flash.
According to the CFI protocol, the flash supports a single write operation
with a data volume ranging from byte size up to the maximum number of bytes.
However, the MTD device structure requires defining a page size, which serves
as the minimum write unit of the flash. Hence, this configuration is introduced.
Any page size within the range of 1 to the maximum number of bytes is considered
valid.
Signed-off-by: jingfei <jingfei@xiaomi.com>
Convert g_mpu_region from single-CPU global variable to per-CPU array indexed
by this_cpu(). Change declaration from "unsigned int g_mpu_region" to
"unsigned int g_mpu_region[CONFIG_SMP_NCPUS]". Update all accesses in
mpu_allocregion(), mpu_freeregion(), and mpu_modify_region() to use
g_mpu_region[this_cpu()] for proper per-CPU MPU region tracking in multi-core
configurations.
Signed-off-by: hujun5 <hujun5@xiaomi.com>
Add FIQ bit (DAIF_FIQ_BIT) initialization to SPSR register when creating new
ARM64 tasks. By default, FIQ interrupts are masked unless CONFIG_ARM64_DECODEFIQ
is enabled. Ensures consistent FIQ masking behavior across all task contexts.
Signed-off-by: hujun5 <hujun5@xiaomi.com>
Write 0xffffffff to the BAR when probing resource size, so the
returned mask is computed correctly.
Signed-off-by: lipengfei28 <lipengfei28@xiaomi.com>
The notifier doesn't need to hold the critical section for the entire
operation, allowing for better performance and reduced lock contention
on multi-core systems.
Signed-off-by: hujun5 <hujun5@xiaomi.com>
Modify nuttx_generate_preprocess_target() to inject
$<TARGET_PROPERTY:nuttx_global,NUTTX_CPP_COMPILE_OPTIONS> into the
preprocessing command, ensuring that linker script preprocessing uses
the same C preprocessor flags as the rest of the build (e.g., -D defines,
include paths).
Signed-off-by: guoshichao <guoshichao@xiaomi.com>
Fix compilation error in optee_va_to_pa() caused by undefined 'struct addrenv_s'
type when CONFIG_ARCH_ADDRENV is enabled. Add the missing nuttx/addrenv.h header
to provide the required type definition.
Signed-off-by: hujun5 <hujun5@xiaomi.com>
Added conditional compilation guards (#if/#endif) around GPIO function prototypes, operation structures, and interrupt handler to ensure proper compilation when GPIO input, output, or interrupt features are disabled.
Signed-off-by: Alexey Matveev <tippet@yandex.ru>
Fix arm64_backtrace to access TCB register context directly instead of using
running_regs(), which may not reflect the actual context being backtraced.
Add CONFIG_ARCH_HAVE_DEBUG guard to prevent undefined references in non-debug builds.
Signed-off-by: hujun5 <hujun5@xiaomi.com>
Replace synchronous nxsched_smp_call with asynchronous nxsched_smp_call_async
in gdb debugpoint operations to prevent deadlocks when called from IRQ handlers.
Use static smp_call_data_s for async communication between SMP cores safely.
Signed-off-by: hujun5 <hujun5@xiaomi.com>
Set interrupt status flag in tpidr_el1 register (bit 0 set to 1) when entering
syscall handler to indicate IRQ-in-progress state, and clear it when exiting
to properly track kernel execution context across all code paths.
Signed-off-by: hujun5 <hujun5@xiaomi.com>
When cross-compiling PSE52 VSX testcases based on Vela, VSX defines its
own "OK" constant as a macro, which conflicts with the "OK" constant
defined as an enum in <sys/types.h>. To ensure compatibility, we
have undef'd the macro version of "OK" in advance.
Signed-off-by: guoshichao <guoshichao@xiaomi.com>
Add three POSIX‑required pthread‑related constants to limits.h:
- _POSIX_THREAD_DESTRUCTOR_ITERATIONS
- _POSIX_THREAD_KEYS_MAX
- _POSIX_THREAD_THREADS_MAX
These constants are needed for full POSIX pthread compatibility and are
required by certain PSE52 test suites and applications.
Signed-off-by: guoshichao <guoshichao@xiaomi.com>
Initialize the rlim_max field in the rlp structure when handling
UL_SETFSIZE command in ulimit(), resolving an uninitialized variable
warning from Coverity static analysis.
Signed-off-by: guoshichao <guoshichao@xiaomi.com>