since creating resources on the remote core takes time,
we need to wait for the remote core to return ack.
Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
Rename arm64_addrenv.c to arm64_addrenv_mmu.c to separate MMU-specific logic.
Add new arm64_addrenv_mpu.c with stub implementations of address environment
functions for MPU-based systems. Enable address environment support in FVP ARMv8-R
Kconfig to support kernel stacks in protected mode. Conditionally build MPU or
MMU address environment code based on CONFIG_ARCH_USE_MMU/CONFIG_ARCH_USE_MPU.
Signed-off-by: hujun5 <hujun5@xiaomi.com>
The limit register contains the enable/disable bit for the MPU region,
so it must be written first before writing the base register to ensure
proper region disable operation.
Signed-off-by: hujun5 <hujun5@xiaomi.com>
spinlock: add rspin_lock_count query interface
Add rspin_lock_count() function to query the current recursion count of a
recursive spinlock. This allows callers to inspect the lock state without
modifying it, useful for debugging and diagnostics.
Signed-off-by: hujun5 <hujun5@xiaomi.com>
Add CONFIG_SPINLOCK conditional compilation to optimize rspinlock functions
for systems without spinlock support. Provide simple macro implementations
that bypass recursive lock logic when spinlock is not configured.
Signed-off-by: hujun5 <hujun5@xiaomi.com>
Add new recursive spinlock (rspinlock) interface functions to support nested
spinlock acquisitions by the same CPU. Includes rspin_lock, rspin_unlock,
rspin_breaklock, and rspin_restorelock for proper recursive lock management.
Signed-off-by: hujun5 <hujun5@xiaomi.com>
Rename STACK_ALIGNMENT macro to STACKFRAME_ALIGN throughout the codebase
to provide clearer naming semantics. The new name better reflects the macro's
purpose of frame alignment rather than general stack alignment.
Signed-off-by: hujun5 <hujun5@xiaomi.com>
Add null pointer check for ioctl operations in RTC driver.
Return -ENOTTY when ioctl function pointer is NULL to prevent crashes.
Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
Fix potential crash when removing client from server list.
Add proper list initialization check before deletion operation.
Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
without rpmsg rtc client driver
Avoid sending rpmsg messages to cores that don't have RTC client driver.
Check endpoint availability before attempting to send messages.
Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
Export rpmsg endpoint to allow remote CPU to access RTC services.
Simplify the initialization flow and remove unnecessary Kconfig options.
Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
In multi-core scenarios, a problem occurs: the target thread receives SIGCONT but does not execute them.
Further analysis reveals that in the sig_dispatch function, the target thread is placed in the readytorun queue only if the SIGCONT signal is sent and the target thread is in the TSTATE_TASK_STOPPED state. However, if the following conditions occur:
CPU0 CPU1
dispatch SIGSTOP
dispatch SIGCONT(check state)
sched_suspend(set task_state = TSTATE_TASK_STOPPED)
This causes the target thread on CPU 1 to receive SIGCONT but not be placed in the readytorun queue, remaining in the stopped state.
Therefore, A flag is needed to indicate whether the SIGCONT action has been executed. At the same time, the critical section protection range of nxsig_stop_task needs to be expanded to prevent another thread from executing the SIGCONT logic during the execution of this function.
Signed-off-by: wangzhi16 <wangzhi16@xiaomi.com>
In irq_attach_thread.c and irq_attach_wqueue.c, there are static functions named irq_default_handler with the same name, which can be easily misunderstood. Therefore, they have been renamed to different functions.
Signed-off-by: pangzhen1 <pangzhen1@xiaomi.com>
Do not compile up_putc functions in stm32_serial.c to avoid conflicts
with implementation from arm_semi_syslog.c when semihosting is enabled.
Signed-off-by: Jean THOMAS <jean@lambdaconcept.com>
Add a concise RPMsg documentation covering:
- Overview of RPMsg framework for AMP systems
- Application scenarios (heterogeneous/homogeneous AMP)
- Layered architecture (Services/Framework/Transport/Physical)
- Message encapsulation process
- Workflow: channel establishment, sending and receiving
- Key design considerations (FIFO order, callback blocking)
- Transport layer comparison
All diagrams use ASCII art for portability.
Signed-off-by: Bowen Wang <wangbowen6@xiaomi.com>
implement the pm feature in rpmsg virtio common part, now the rpmsg
virtio can use in the low power case.
Signed-off-by: Bowen Wang <wangbowen6@xiaomi.com>
Previously the ioctl-based configuration was not encoded properly.
It lacked the three command bits selecting the "set volatile
configuration" mode.
Thus, configuration the reference, power-down or gain resulted in no
change.
Now the configuration is properly applied.
The DAC value to be send is now combined with the proper command prefix
bits, too.
But this operation was already working, since the command prefix is zero.
Signed-off-by: Lars Kruse <devel@sumpfralle.de>
This commit fixes a typo in the capture.h header file. This is a
breaking change, but the fix is trivial (replace macro with new one).
Signed-off-by: Côme VINCENT <44554692+comejv@users.noreply.github.com>
Change g_nx_initstate type from uint8_t to enum nx_initstate_e.
Avoid enum/integer base-type mismatch in init state comparisons.
Satisfies MISRA C:2012 Rule 10.4 without behavior change.
Signed-off-by: fangxinyong <fangxinyong@xiaomi.com>
Zero-initialize posix_spawnattr_t in posix_spawnattr_init().
Prevent use of uninitialized fields reported by Coverity.
Preserve existing default flag initialization.
Signed-off-by: fangxinyong <fangxinyong@xiaomi.com>
Use 1u/~1u constants for TPIDRPRW bit operations.
Avoid implicit conversion to a different underlying type (MISRA Rule 10.3).
No functional change to task pointer tagging logic.
Signed-off-by: fangxinyong <fangxinyong@xiaomi.com>
Refactor nxtask_setup_stackargs() to use a single ret exit path.
Avoid partially-initialized state on error paths and improve readability.
Addresses Coverity HIS_metric_violation: RETURN.
Signed-off-by: fangxinyong <fangxinyong@xiaomi.com>
Initialize ret and propagate scheduler/param errors via a single return.
Make spawn_file_is_duplicateable() decision explicit using a dup state.
Addresses Coverity HIS_metric_violation: RETURN.
Signed-off-by: fangxinyong <fangxinyong@xiaomi.com>
Replace early return with a ret flag to unify the exit path.
Keep critical section behavior unchanged while simplifying control flow.
Addresses Coverity HIS_metric_violation: RETURN.
Signed-off-by: fangxinyong <fangxinyong@xiaomi.com>
Use a local ret variable and return once at the end.
This keeps the IDLE_PROCESS_ID fallback behavior unchanged.
Addresses Coverity HIS_metric_violation: RETURN.
Signed-off-by: fangxinyong <fangxinyong@xiaomi.com>
Add spinlock protection to sched_note_preemption and nxsched_critmon_preemption.
Ensures thread-safe access to global state in preemption notification and critical
monitoring, preventing race conditions in SMP and interrupt contexts.
Signed-off-by: hujun5 <hujun5@xiaomi.com>
The main content of this submission is to limit both the TX/RX buffers
of TCP/UDP to throttled IOBs, avoiding impacts on the sending and
receiving of control-type messages.
Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
Fix incorrect direct access to semcount field by using val intermediate
field in memory pool and network stats debugging scripts. This corrects
the data structure navigation to match actual kernel semaphore layout.
Signed-off-by: hujun5 <hujun5@xiaomi.com>
the lock in the "bluetooth_conn" was not initialized, which resulted in
a blocking situation when attempting to hold the lock for the first
time.
Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
When the system startup from the PL1 SYS mode, the initialization
of the PL2 HYP register needs to be skipped. Put the Hypervisor
initialization code together and skip it all at once.
Signed-off-by: yukangzhi <yukangzhi@xiaomi.com>
Add default values (0x0) for ARCH_TEXT_VBASE, ARCH_DATA_VBASE, and
ARCH_HEAP_VBASE to resolve cmake configuration warnings when these
values are not explicitly set during initialization.
Signed-off-by: hujun5 <hujun5@xiaomi.com>
Remove redundant leave_critical_section() call in nxsem_trywait_slow() as the
critical section is properly released at the exit point via 'out' label, making
the intermediate call unnecessary and eliminating code duplication.
Signed-off-by: hujun5 <hujun5@xiaomi.com>
Prevent getenv() from being called in interrupt context by adding
up_interrupt_context() check. This ensures thread-safe access to
environment variables in multi-threaded scenarios.
Signed-off-by: hujun5 <hujun5@xiaomi.com>
Set the thread ID (tl_tid) to the destination task's pid during TLS
duplication in fork operations. This ensures the duplicated TLS info
correctly reflects the forked task's thread identifier.
Signed-off-by: hujun5 <hujun5@xiaomi.com>
Add support for managing hrtimers using a simple list. This approach
is more memory-efficient, as list nodes use less memory, and it is
preferable to an RB-tree when the number of hrtimers is relatively small.
Signed-off-by: Chengdong Wang <wangchengdong@lixiang.com>
Stop the report handler from re-entering KASAN by halting checks when printing.
Reuse the dump_only flag so read/write panic toggles only emit stack traces.
Retain stack dumps for panic-disabled paths without risking another overflow.
Signed-off-by: anpeiyun <anpeiyun@xiaomi.com>
Remove redundant robust mutex owner validation code from pthread_mutex_timedlock
that duplicates similar logic already present in pthread_mutex_take. This reduces
code duplication and improves maintainability.
Signed-off-by: hujun5 <hujun5@xiaomi.com>
Replace spin_lock_irqsave with spin_lock_irqsave_nopreempt in
pthread_mutex_inconsistent to prevent preemption during mutex list
manipulation and avoid potential deadlocks or race conditions.
Signed-off-by: hujun5 <hujun5@xiaomi.com>
Enable building the legacy idf format of nuttx when rtc is enabled.
Without this addition the build fails because the rtc data is placed in
rom.
Signed-off-by: Laczen JMS <laczenjms@gmail.com>
After adding the cross-core crypto driver, there are now three encryption modes:
1. Hardware driver in local core
2. Crypto driver in remote core
3. Software encryption in local core
This prioritizes local hardware driver first, then remote driver (typically hardware),
and finally local software encryption as a fallback.
Signed-off-by: makejian <makejian@xiaomi.com>
Replace dynamic memory allocation with stack-based variables in cryptodev_op().
This eliminates kmm_malloc/kmm_free overhead and simplifies error handling
by removing the need for goto bail cleanup paths.
Signed-off-by: makejian <makejian@xiaomi.com>
Add ivlen field to crypt_op and crp_ivlen to cryptop structure to support
cipher algorithms with different IV lengths.
Signed-off-by: makejian <makejian@xiaomi.com>