Commit Graph

8102 Commits

Author SHA1 Message Date
Yongrong Wang f56ea30479 drivers/rpmsg: refactor internal APIs to private header
Move rpmsg internal APIs from public header include/nuttx/rpmsg/rpmsg.h
to private header drivers/rpmsg/rpmsg.h. These APIs are only used within
the rpmsg driver implementation and should not be exposed to external
modules.

Moved APIs:
- rpmsg_modify_signals()
- rpmsg_ns_bind() / rpmsg_ns_unbind()
- rpmsg_device_created() / rpmsg_device_destory()
- rpmsg_register() / rpmsg_unregister()

Signed-off-by: Yongrong Wang <wangyongrong@xiaomi.com>
Signed-off-by: Bowen Wang <wangbowen6@xiaomi.com>
2026-01-26 17:23:31 -03:00
yukangzhi 890f2e4625 sched: add trace points during system startup and board initialization
Add trace points to record transitions of g_nx_initstate and to mark
board early/late initialization boundaries. Also add trace marks for
RESET and PANIC to improve boot-time diagnostics and failure analysis.

Add OSINIT_RESET to indicate system is in reset process.

Signed-off-by: yukangzhi <yukangzhi@xiaomi.com>
2026-01-27 03:18:11 +08:00
yukangzhi 6ccc2fc7c8 driver/ramlog: Implement the rate limiting function for ramlog driver.
Limit the maximum number of log entries allowed within
the specified time interval in seconds.

Signed-off-by: yukangzhi <yukangzhi@xiaomi.com>
2026-01-27 03:17:05 +08:00
liaoao ae6ad9c193 drivers/rpmsg_port_spi_slave: add getrecvbuf callback for zero-copy receive
Add a new getrecvbuf callback to the SPI slave device operations
that allows the slave device to provide a pre-allocated receive
buffer directly to the controller. This enables zero-copy data
transfer by allowing the controller to receive data directly into
the device's buffer instead of copying.

Changes:
- Add SPIS_DEV_GETRECVBUF macro and getrecvbuf callback to
  spi_slave_devops_s structure in include/nuttx/spi/slave.h
- Implement getrecvbuf in rpmsg_port_spi_slave driver
- Update getdata to return 0 as it's no longer used for this path

Signed-off-by: liaoao <liaoao@xiaomi.com>
2026-01-26 21:17:27 +08:00
wangzhi16 03ca455066 sched/sched: Modify the critical section interface name.
replace _wo_note to _notrace.

Signed-off-by: wangzhi16 <wangzhi16@xiaomi.com>
2026-01-26 21:13:05 +08:00
Yongrong Wang aa567d43f6 drivers/rpmsg: fix struct alignment issue by removing zero array member
This commit fixes a memory alignment issue in the rpmsg subsystem.
The previous implementation used a flexible array member (rdev[0])
in struct rpmsg_s, but due to automatic 8-byte padding, rpmsg->rdev
could differ from the transport layer's rdev address (e.g.,
rpmsg_virtio->rvdev.rdev), causing potential memory corruption.

Changes:
- Remove rdev[0] flexible array member from struct rpmsg_s
- Add rpmsg_get_rdev_by_rpmsg() inline helper to calculate rdev
  address as (rpmsg + 1), ensuring correct pointer arithmetic
- Update all rpmsg->rdev references to use the new helper function
- Fix rpmsg_virtio_notify_wait() to use correct container_of macro

Signed-off-by: Yongrong Wang <wangyongrong@xiaomi.com>
2026-01-26 21:12:34 +08:00
anjiahao fea492cf6f libc/spawn:support get/set priority
support get/set priority

Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2026-01-26 21:01:01 +08:00
yukangzhi a6e15f6fbd driver/note: Add tag to note_event_s and note_printf_s
Record the tag in note_event_s and note_printf_s for log filtering.

Signed-off-by: yukangzhi <yukangzhi@xiaomi.com>
2026-01-26 20:56:45 +08:00
hujun5 082a3d3085 pthread: remove tl_lock
This lock is currently used in three places,
mainly to protect tls->tl_mhead. Among them,
pthread_mutex_add and pthread_mutex_remove involve
writing to tls->tl_mhead, and there is
certainly no conflict within the same thread.
As for pthread_mutex_inconsistent, it involves reading. Currently,
it can only be called when the TCB task corresponding to
this tls exits, and the TCB corresponding to the
tls can no longer continue to run.
It seems that adding the lock serves no real purpose.

Signed-off-by: hujun5 <hujun5@xiaomi.com>
2026-01-26 20:56:12 +08:00
Gao Jiawei 564c9d7dcd arm: systick: fix off-by-one in SysTick RELOAD programming
ARM specifies that SysTick RELOAD must be programmed with N-1 to get a period of N CPU cycles.
Adjust the timeout/reload conversions accordingly: subtract 1 when writing RELOAD and add 1 back when converting RELOAD to a timeout/interval.
Also clamp RELOAD to the valid 24-bit range (1..0x00ffffff) for Armv7-M/Armv8-M to avoid invalid values.
Reference: https://developer.arm.com/documentation/dui0646/c/Cortex-M7-Peripherals/System-timer--SysTick/SysTick-Reload-Value-Register

Signed-off-by: Gao Jiawei <gaojiawei@xiaomi.com>
2026-01-26 19:34:00 +08:00
ouyangxiangzhen 0048a5c21b sched/hrtimer: Fix the functional correctness issue in hrtimer_start.
This commit fixed the functional correctness issue in hrtimer_start by
adding HRTIMER_MAX_DELAY fr the HRTIMER_MODE_REL.

Signed-off-by: ouyangxiangzhen <ouyangxiangzhen@xiaomi.com>
2026-01-26 16:37:10 +08:00
ouyangxiangzhen 4d283260ab sched/hrtimer: Add hrtimer_gettime.
This commit added hrtimer_gettime API to support the query of the
rest of the delay time of the hrtimer in nanoseconds.

Signed-off-by: ouyangxiangzhen <ouyangxiangzhen@xiaomi.com>
2026-01-26 16:37:10 +08:00
ouyangxiangzhen 89dbed25a0 sched/hrtimer: Replace hrtimer_gettime with clock_systime_nsec.
This commit move the hrtimer_gettime to clock_systime_nsec to improve
the code reusability.

Signed-off-by: ouyangxiangzhen <ouyangxiangzhen@xiaomi.com>
2026-01-26 16:37:10 +08:00
ouyangxiangzhen d18fd4640e sched/hrtimer: Fix functional correctness issue in SMP.
Since the hrtimer->expired is not monotonic, it can not be used as the
version. This commit added the ownership encoding to ensure the
invariant that the cancelled the timer can not modify the hrtimer again.

Signed-off-by: ouyangxiangzhen <ouyangxiangzhen@xiaomi.com>
2026-01-26 16:37:10 +08:00
zhangyuan29 de77967144 addrenv: support addrenv when mpu is used
Conditionally enable MMU-specific configuration
checks (CONFIG_MM_PGALLOC, CONFIG_MM_PGSIZE,
address base/size definitions) only when
CONFIG_ARCH_USE_MMU is defined. This allows
addrenv support in MPU-based systems that
don't use MMU paging.

Signed-off-by: zhangyuan29 <zhangyuan29@xiaomi.com>
2026-01-26 16:27:19 +08:00
hujun5 217e685beb pthread: move pthread_cond to userspace
Move pthread condition variable implementation from kernel (sched/pthread)
to userspace library (libs/libc/pthread). This allows userspace to handle
condition variable operations directly, reducing syscall overhead and
improving performance for pthread applications.

Signed-off-by: hujun5 <hujun5@xiaomi.com>
2026-01-26 16:26:39 +08:00
dongjiuzhu1 8127c48507 drivers/sensors: sensor rpmsg add new features.
support set_nonwakeup ops for sensor driver to save power

Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
Signed-off-by: likun17 <likun17@xiaomi.com>
2026-01-26 15:04:11 +08:00
makejian 85ba80a90e crypto/ecc: add SPDX license identifier
Add BSD-2-Clause SPDX license identifier to ECC source and header files.

Signed-off-by: makejian <makejian@xiaomi.com>
2026-01-26 10:55:57 +08:00
makejian be2e72dac2 crypto/ecc: supports exporting generated keys in uncompressed form
Export public keys as separate X and Y coordinates for uncompressed format.

Signed-off-by: makejian <makejian@xiaomi.com>
2026-01-26 10:55:57 +08:00
makejian 3f0cc5f09c crypto: export algorithm about ecc
Transplanting the ECC algorithm from https://github.com/jestan/easy-ecc

which is BSD lisence

Signed-off-by: makejian <makejian@xiaomi.com>
2026-01-26 10:55:57 +08:00
zhaoxingyu1 e4a73edec8 mtdconfig: lomtdconfig device change to depends on !MTD_CONFIG_NONE
The structure of mtd_config in Kconfig has changed.

Signed-off-by: zhaoxingyu1 <zhaoxingyu1@xiaomi.com>
2026-01-26 10:52:51 +08:00
wangchengdong 3538d805fc sched/hrtimer: refresh code comments to match implementation
Several code comments in the hrtimer subsystem have become outdated
following recent implementation changes. This patch updates them to
accurately describe the current code behavior and algorithms.

Signed-off-by: Chengdong Wang <wangcd91@gmail.com>
2026-01-26 10:10:57 +08:00
hujun5 172c548812 trace: fix macro line continuation formatting
Fix macro line continuation formatting in trace.h by consolidating
multi-line macro definitions onto single lines. This eliminates unnecessary
line continuations and improves code readability while maintaining functionality.

Signed-off-by: hujun5 <hujun5@xiaomi.com>
2026-01-25 10:45:26 -03:00
yinshengkai d3460aa111 note/ram: support multiple noterams to dump data when panic occurs
When creating a noteram, you can choose whether to dump
this noteram when the system crashes.

Signed-off-by: yinshengkai <yinshengkai@xiaomi.com>
2026-01-24 19:33:17 +08:00
Bowen Wang 2795918932 drivers/rpmsg: unify cpuname/local_cpuname to struct rpmsg_s
Unify all the cpuname/local_cpuname to struct rpmsg_s, so we can
remove the ops->get_cpuname and ops->get_local_cpuname in
struct rpmsg_ops_s.

Signed-off-by: Bowen Wang <wangbowen6@xiaomi.com>
2026-01-24 17:10:18 +08:00
hujun5 fd67ef3af9 assert: fix DEBUGASSERT recursive triggering
Add head pointer checks in notifier_call_chain macros to prevent recursion into
sched_lock() when assertions are triggered during early system startup. This avoids
cascading DEBUGASSERT failures when the notifier head is empty or uninitialized.
backtrace:
  DEBUGASSERT(rtcb && rtcb->lockcount < MAX_LOCK_COUNT);
  sched_lock()
  panic_notifier_call_chain
  _assert()
  arm64_fatal_handler

Signed-off-by: hujun5 <hujun5@xiaomi.com>
2026-01-24 17:03:57 +08:00
yinshengkai 9015f40909 trace: add mark and printf support
Build Documentation / build-html (push) Has been cancelled
Add new trace macros: trace_mark and trace_printf.

Signed-off-by: yinshengkai <yinshengkai@xiaomi.com>
2026-01-23 11:30:28 -03:00
yukangzhi 1b22f8c65b driver/note: Fix compilation error when CONFIG_SYSLOG_TO_SCHED_NOTE=y
Add compilation condition for 'nx_vsyslog' syscall.
Export 'sched_note_printf_ip' syscall when CONFIG_SYSLOG_TO_SCHED_NOTE=y
Put the implementation of sched_note_printf_ip in libc/misc/lib_note.c

Signed-off-by: yukangzhi <yukangzhi@xiaomi.com>
2026-01-23 07:48:08 -03:00
hujun5 5051721298 sched/pthread: move pthread mutex from syscall to user-space
Move pthread mutex operations from kernel-space syscall
interface to user-space implementations
to reduce syscall overhead. Relocate mutex holder list
tracking from task control block (tcb) to
thread local storage (tls) to improve memory layout and
cache efficiency. Add helper macros for
conditional mutex implementations and update syscall
interface accordingly.

Signed-off-by: hujun5 <hujun5@xiaomi.com>
2026-01-22 12:40:49 -03:00
guohao15 5e117fda60 mtdconfig: support ram_mtdconfig device && lomtdconfig device
For nvs test in qemu

Signed-off-by: guohao15 <guohao15@xiaomi.com>
2026-01-22 23:18:26 +08:00
ouyangxiangzhen 048ef54c55 include/clock: Remove the inclusion of the macro.h.
Since the macro.h may confilict with the user definition, we should
avoid including the macro.h in clock.h.

Signed-off-by: ouyangxiangzhen <ouyangxiangzhen@xiaomi.com>
2026-01-22 22:14:00 +08:00
jiangtao16 e01fbb757c include/clock.h: Fix type of macro defination of constants
keep type of constants as ul add clock_t cast to tick relate macro.

Signed-off-by: jiangtao16 <jiangtao16@xiaomi.com>
2026-01-22 22:14:00 +08:00
jiangtao16 caafba07bc sched/timer: Fix MISRA Rule 10.4
Fix MISRA Rule 10.4 convert signed variabled to unsigned ones.

Signed-off-by: jiangtao16 <jiangtao16@xiaomi.com>
2026-01-22 22:14:00 +08:00
jiangtao16 3b005dbdf7 sched/wdog: Fix MISRA 2004 rule 10.1
Fix MISRA 2004 rule 10.1 implicit type conversion

Signed-off-by: jiangtao16 <jiangtao16@xiaomi.com>
2026-01-22 22:14:00 +08:00
jiangtao16 e171415897 sched/clock: has external linkage but is only used in one translation unit
Fix for MISRA-C rule 8.10

Signed-off-by: jiangtao16 <jiangtao16@xiaomi.com>
2026-01-22 22:14:00 +08:00
chenxiaoyi 397e7e7a4f macro: use portable variadic macros
The old implementation used a GCC extension related to variadic macros,
where a name prepends the ellipsis, which has portability issues.

Signed-off-by: chenxiaoyi <chenxiaoyi@xiaomi.com>
2026-01-22 22:14:00 +08:00
yinshengkai 34e8267fcc macro: FOREACH_ARG Add parameter field
Adjust the definition and fix CONCATENATE.

Signed-off-by: yinshengkai <yinshengkai@xiaomi.com>
2026-01-22 22:14:00 +08:00
yinshengkai cc578e33a9 macro: FOREACH_ARG Add parameter field
FOREACH_ARG Add parameter field.

Signed-off-by: yinshengkai <yinshengkai@xiaomi.com>
2026-01-22 22:14:00 +08:00
daichuan 763caabf6d boards/boardctl: Add BOARDIOC_MACADDR command
Add a new boardctl command BOARDIOC_MACADDR to retrieve the MAC address of the network interface.

The board_macaddr function needs to be implemented by the board logic.

Signed-off-by: daichuan <daichuan@xiaomi.com>
2026-01-22 22:13:31 +08:00
wangzhi16 d5ed98c11f sched/rwspinlock: There is a bug in the rw_spinlock.
There is a bug in the rw_spinlock. Each time atomic_compare_exchange_strong(object, expected, desired) is executed, the value of object is assigned to expected, so the value of expected needs to be reset each time.

Signed-off-by: wangzhi16 <wangzhi16@xiaomi.com>
2026-01-22 22:11:17 +08:00
yukangzhi dd307ab82c libc/pthread: Avoid compiler optimizations for once_control->done
Prevent compiler reordering that may read stale value of once_control->done.
Use volatile to ensure visibility across threads and prevent incorrect once initialization.

Signed-off-by: yukangzhi <yukangzhi@xiaomi.com>
2026-01-22 19:47:45 +08:00
hujun5 223230a9ed spinlock: add rspin_lock_count
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>
2026-01-22 15:38:37 +08:00
hujun5 4c43efafa5 spinlock: optimize the implementation of rspinlock in a single-core
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>
2026-01-22 15:38:37 +08:00
hujun5 bb69f77164 spinlock: add rspinlock interface for recursive spinlock support
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>
2026-01-22 15:38:37 +08:00
hujun5 6f03601169 arch: rename STACK_ALIGNMENT to STACKFRAME_ALIGN across all architectures
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>
2026-01-22 15:37:24 +08:00
Côme VINCENT 34d3b06955 drivers/timers/capture: fix typo in capture.h
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>
2026-01-22 00:06:45 +08:00
fangxinyong cd958831d8 sched/init: use enum type for g_nx_initstate
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>
2026-01-21 20:31:35 +08:00
wangchengdong 291938150f sched/hrtimer: add option for list-based hrtimer management
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>
2026-01-21 10:33:12 +08:00
yintao f7dc54e869 drivers/rpmsg: use nuttx/atomic.h instead meatl/atomic.h
All the atomic operation already changed to nuttx's, so change
the include header too

Signed-off-by: yintao <yintao@xiaomi.com>
2026-01-21 10:01:40 +08:00
makejian 5b52a32f5a crypto/crypto.c: Determine the order of obtained crypto drivers
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>
2026-01-21 00:25:07 +08:00