The sim_bthcisock_interrupt() handler for Bluetooth HCI sockets in the simulatorwas using
an if statement to check for available data on the HCI socket. Thismeant that only a single
packet would be read and processed per interrupt trigger,even if multiple packets were waiting
in the socket buffer.
This led to incomplete data processing: unread packets would remain in the bufferuntil the next
interrupt tick, causing delayed handling of Bluetooth HCI events/commands,packet backlogs,
or missed data in high-throughput scenarios.
This fix replaces the if with a while loop to:
1. Continuously check for and read available data from the HCI socket until no more
packets are present in the buffer.
2. Ensure all pending HCI packets are processed in a single interrupt handler invocation.
3. Eliminate packet backlogs and reduce latency in Bluetooth HCI communication.
The change maintains the same core data reception logic (bthcisock_receive()) butensures it runs
for all available packets, improving the reliability and responsivenessof the simulator's Bluetooth HCI socket implementation.
Signed-off-by: chao an <anchao.archer@bytedance.com>
Intermediate files of make depend like .ddc and .dds may remain
when make is interrupted. Remove them using make distclean.
Signed-off-by: SPRESENSE <41312067+SPRESENSE@users.noreply.github.com>
and migrate arch/sim from the customized mm_heap to
umm_heap, so the default mm_heap implementation can
still be used(e.g. shared memory in OpenAMP).
Signed-off-by: ganjing <ganjing@xiaomi.com>
Add validation to ensure allocated stack size does not exceed TLS_MAXSTACK when
CONFIG_TLS_ALIGNED is enabled, and verify proper stack alignment using STACK_ALIGN_MASK
across all architectures. This improves stack safety and prevents potential TLS overflow conditions.
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>
Remove restore_critical_section() call from up_switch_context() in simulator
as it is not necessary during interrupt context switching. The critical
section state is properly managed elsewhere in the interrupt handling flow.
Signed-off-by: hujun5 <hujun5@xiaomi.com>
Move stack alignment and kernel stack macros from architecture-specific internal
headers to public include/nuttx/irq.h. Consolidates duplicate definitions across
17 architecture families, reducing code duplication while enabling common code
to access these core alignment utilities without architecture dependencies.
Signed-off-by: hujun5 <hujun5@xiaomi.com>
Support user pass it own heap struct to the mm_initialize_heap() to
avoid the heap struct is reserved from the heap range
Signed-off-by: anjiahao <anjiahao@xiaomi.com>
1. Use reserved[0] filed in struct fw_rsc_vdev and the driver
master/slave to judge the device role;
2. Use struct fw_rsc_carveout in resource table to provide the
share memory to virtio driver side;
Signed-off-by: Bowen Wang <wangbowen6@xiaomi.com>
Signed-off-by: Yongrong Wang <wangyongrong@xiaomi.com>
Add support to disable signals actions related struct
Co-authored-by: guoshichao <guoshichao@xiaomi.com>
Signed-off-by: Chengdong Wang <wangchengdong@lixiang.com>
usrsock register work in net_initialize before g_work_queue is created, so move g_work_queue in irq_initialize.
Signed-off-by: guanyi3 <guanyi3@xiaomi.com>
rpmsg work in hpwork are waiting for remote buffer, remote get buffer and callback, but callback also in hpwork, deadlock occurs here.
now we move periodic work to global work queue instead of hpwork to fix deadlock.
Signed-off-by: guanyi3 <guanyi3@xiaomi.com>
The wdog callbacks are executed in the host's signal handler context, which has strict limitations on what operations can be safely performed. Specifically, signal handlers should not call non-async-signal-safe functions (e.g., sim_alsa use mutex_lock in wdog and cause deadlock).
This change only replaces uses of wdog for periodic tasks. Other interrupt callbacks that are still invoked from the host signal handler are not replace to work queue.
Signed-off-by: guanyi3 <guanyi3@xiaomi.com>
Remove the interception of unknown levels and option names in sim usrsock.
This allows the system socket interface to handle them and return the correct error codes or behavior, rather than returning a generic error locally.
Signed-off-by: liqinhui <liqinhui@xiaomi.com>
Avoid the errno changed after interrupt in sim and make return value
mistake when according to errno.
Move host_errno_convert from macro to sim_errno.c.
Signed-off-by: buxiasen <buxiasen@xiaomi.com>
We will remove the API in next commit, so remove the errno manual save
API and save errno more commonly.
After whole pull request, should no longer need to care about errno.
Signed-off-by: buxiasen <buxiasen@xiaomi.com>
This reverts commit ac5b38c9e5.
Keep host_errno_convert as a common interface in sim_internal.h
Keep the up_irq_save & up_irq_restore as common interface
Signed-off-by: buxiasen <buxiasen@xiaomi.com>
modify the code of the adapted protocol stack to avoid deadlocks and the
logic that cannot be protected by locks after modification.
Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
The USB driver framework only implements a single ISOC transfer.
If multiple transfers are needed, the class driver can initiate
multiple urbs to meet the real-time requirements of the ISOC
endpoint. The class driver's urb record the buf address, length,
and number of packets sent. The callback function calculates the
data location in the buf based on the callback number and length
returned.
Signed-off-by: yangsong8 <yangsong8@xiaomi.com>
On success, zero (OK) is returned. On a failure, a negated errno value
is returned indicating the nature of the failure.
Signed-off-by: yangsong8 <yangsong8@xiaomi.com>