Commit Graph

54932 Commits

Author SHA1 Message Date
chenrun1
3f47fd767a fs/xxfs:Replace kmm with fs heap
Summary:
  1.Add configuration to allocate memory from the specified section
  2.Replace all memory operations (kmm_) in the vfs with
    fs_heap_. When FS_HEAPSIZE > 0, memory is requested for the file system by specifying a configured heap location. By default (i.e. FS_HEAPSIZE=0) fs_heap_ is equivalent to kmm_

Signed-off-by: chenrun1 <chenrun1@xiaomi.com>
2024-10-10 15:30:41 +02:00
chenrun1
94fe00ebec accept4:move function from net to fs
Summary:
  Implementation in accept4 is special, the requested newsock is saved as filep->priv. This will cause sock_file_close to use fs_heap_free filep->priv during close. When fs_heap is configured, the released memory will not be on fs_heap, causing a crash.

Signed-off-by: chenrun1 <chenrun1@xiaomi.com>
2024-10-10 15:30:41 +02:00
Michal Lenc
01bed328ef smartfs: add support for FIOC_FILEPATH ioctl
The FIOC_FILEPATH ioctl call is required if smartfs is to be used
together with inotify monitoring system. This implements the
call support to smartfs file system. The path to the file has to
be stored in smartfs_ofile_s structure during file open (and is freed
during close) as smartfs currently is not able to obtain the path
knowing only the file node. The full path is concatenated with the file
name and creates the full path needed for inotify to detect whether
the file is on the watchlist.

Signed-off-by: Michal Lenc <michallenc@seznam.cz>
2024-10-10 15:30:41 +02:00
chenrun1
0ac21a911b fs_rammap:Check last fileseek restore fpos
Summary:
  When restoring rammap fpos, we check the return value to avoid potential problems caused by no error return if the restore fails.

Signed-off-by: chenrun1 <chenrun1@xiaomi.com>
2024-10-10 15:30:41 +02:00
zhangshoukui
8155102f7d FS_RAMMAP depends on FS_REFCOUNT and remove useless macro
Signed-off-by: zhangshoukui <zhangshoukui@xiaomi.com>
2024-10-10 15:30:41 +02:00
zhangshoukui
e6b703c29f Should call fs_putfilep put fs reference when call files_fget complete
Signed-off-by: zhangshoukui <zhangshoukui@xiaomi.com>
2024-10-10 15:30:41 +02:00
yezhonghui
52ffca5b8e arm64 support gicv2m for pci irq
Signed-off-by: yezhonghui <yezhonghui@xiaomi.com>
2024-10-10 15:30:00 +02:00
zhaohaiyang1
45bb7a9c1c char driver CAN: add tx_confirm function in upperCAN driver.
add tx_confirm function in upperCAN driver1

Signed-off-by: zhaohaiyang1 <zhaohaiyang1@xiaomi.com>
2024-10-10 17:58:36 +08:00
zhaohaiyang1
63515d584b chardriver upperCAN: support to independent set TX/RX FIFO size.
support to independent set TX/RX FIFO size.

Signed-off-by: zhaohaiyang1 <zhaohaiyang1@xiaomi.com>
2024-10-10 17:58:36 +08:00
zhaohaiyang1
9b698b2304 add the ability that control CAN transceiver state.
add the ability that control CAN transceiver state in nuttx.

Signed-off-by: zhaohaiyang1 <zhaohaiyang1@xiaomi.com>
2024-10-10 17:58:36 +08:00
zhaohaiyang1
2bb4ec0fd2 nuttx/can: add can controller state setting and getting in uppercan.
add can controller state setting and getting in uppercan.

Signed-off-by: zhaohaiyang1 <zhaohaiyang1@xiaomi.com>
2024-10-10 17:58:36 +08:00
Xiang Xiao
ccddaa78c9 can: Add more critical section to fix the race condition.
since routines called by IRQ need to be protected in SMP too.

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2024-10-10 17:58:36 +08:00
Xiang Xiao
4324970980 can: Merge cd_error and rx_overflow into rx_error so the error could dispath to each client without interference
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2024-10-10 17:58:36 +08:00
hujun5
f791311138 sched/sched: next pointer value is definitely not null
Signed-off-by: hujun5 <hujun5@xiaomi.com>
2024-10-10 17:57:30 +08:00
hujun5
508c5889d7 sched: change nxsched_islocked_global to nxsched_islocked_tcb
reason:
1 To improve efficiency, we mimic Linux's behavior where preemption disabling is only applicable to the current CPU and does not affect other CPUs.
2 In the future, we will implement "spinlock+sched_lock", and use it extensively. Under such circumstances, if preemption is still globally disabled, it will seriously impact the scheduling efficiency.
3 We have removed g_cpu_lockset and used irqcount in order to eliminate the dependency of schedlock on critical sections in the future, simplify the logic, and further enhance the performance of sched_lock.
4 We set lockcount to 1 in order to lock scheduling on all CPUs during startup, without the need to provide additional functions to disable scheduling on other CPUs.
5 Cpu1~n must wait for cpu0 to enter the idle state before enabling scheduling because it prevents CPUs1~n from competing with cpu0 for the memory manager mutex, which could cause the cpu0 idle task to enter a wait state and trigger an assert.

size nuttx
before:
   text    data     bss     dec     hex filename
 265396   51057   63646  380099   5ccc3 nuttx
after:
   text    data     bss     dec     hex filename
 265184   51057   63642  379883   5cbeb nuttx

size -216

Configuring NuttX and compile:
$ ./tools/configure.sh -l qemu-armv8a:nsh_smp
$ make
Running with qemu
$ qemu-system-aarch64 -cpu cortex-a53 -smp 4 -nographic \
   -machine virt,virtualization=on,gic-version=3 \
   -net none -chardev stdio,id=con,mux=on -serial chardev:con \
   -mon chardev=con,mode=readline -kernel ./nuttx

Signed-off-by: hujun5 <hujun5@xiaomi.com>
2024-10-10 17:57:30 +08:00
dulibo1
1237e9fcea smp:fix sim build error under config CONFIG_SMP
CC:  sim/sim_smpsignal.c init/nx_smpstart.c: In function ‘nx_idle_trampoline’:
init/nx_smpstart.c:68:21: warning: unused variable ‘tcb’ [-Wunused-variable]
   68 |   FAR struct tcb_s *tcb = this_task_inirq();
      |                     ^~~
sim/sim_smpsignal.c: In function ‘host_cpu_started’:
sim/sim_smpsignal.c:271:17: warning: unused variable ‘tcb’ [-Wunused-variable]
  271 |   struct tcb_s *tcb = this_task();

sim/sim_smpsignal.c:249:33: error: ‘cpu’ undeclared (first use in this function)
  249 |   restore_critical_section(tcb, cpu);
      |                                 ^~~

Signed-off-by: buxiasen <buxiasen@xiaomi.com>
2024-10-10 17:55:47 +08:00
dulibo1
f1f38b6e16 sched_smp:adjust the critical section to protect refcount from multi cores access
Signed-off-by: dulibo1 <dulibo1@xiaomi.com>
Signed-off-by: buxiasen <buxiasen@xiaomi.com>
2024-10-10 17:55:47 +08:00
dulibo1
6fd1ca64a1 sched_smp:sync refcount before enqueue smp call queue
Signed-off-by: dulibo1 <dulibo1@xiaomi.com>

1.call_data->refcount is not remote_cpus;
2.nxsched_smp_call_add enqueue  the call_data;
3.maybe nxsched_smp_call_handler is just doing;
4.dequeue the call_data but call_data->refcount is not corret;
5.unpredictability case will occur;
2024-10-10 17:55:47 +08:00
xuxingliang
a26051e7bc fs: fix wrong config for FS_SHMFS
Signed-off-by: xuxingliang <xuxingliang@xiaomi.com>
2024-10-10 00:29:57 +08:00
hujun5
a8717c6453 arch: We can use an independent SIG interrupt to handle async pause, which can save processing time.
Signed-off-by: hujun5 <hujun5@xiaomi.com>
2024-10-09 23:32:31 +08:00
hujun5
ed998c08c4 sched: change the SMP scheduling policy from synchronous to asynchronous
reason:
Currently, if we need to schedule a task to another CPU, we have to completely halt the other CPU,
manipulate the scheduling linked list, and then resume the operation of that CPU. This process is both time-consuming and unnecessary.

During this process, both the current CPU and the target CPU are inevitably subjected to busyloop.

The improved strategy is to simply send a cross-core interrupt to the target CPU.
The current CPU continues to run while the target CPU responds to the interrupt, eliminating the certainty of a busyloop occurring.

Signed-off-by: hujun5 <hujun5@xiaomi.com>
2024-10-09 23:32:31 +08:00
fangzhenwei
cc9d42804b local_sock: fix accept use-after-free
we should get next waiter before acceptor released

Signed-off-by: fangzhenwei <fangzhenwei@xiaomi.com>
2024-10-09 23:00:32 +08:00
raiden00pl
a8ffa96b65 arch/arm/Kconfig: fix copy-paste error
ARCH_CHIP_CSK6 has nothing to do with ST chips:
fix option string and move below ST related options
2024-10-09 23:00:06 +08:00
Lup Yuen Lee
7edb84c0c5 build.yml: Check out the correct branch of nuttx-apps
When building a branch like `releases/12.7`, the CI Workflow incorrectly checks out the `master` branch of `nuttx-apps`, instead of `releases/12.7`. This PR fixes a typo in `apps_ref`, to check out the correct branch.
2024-10-09 19:30:38 +08:00
hujun5
5f6eb292a8 sched: add nxsched_remove_self
reason:
1In the scenario of active waiting, context switching is inevitable, and we can eliminate redundant judgments.

code size
before
hujun5@hujun5-OptiPlex-7070:~/downloads1/vela_sim/nuttx$ size nuttx
   text    data     bss     dec     hex filename
 262848   49985   63893  376726   5bf96 nuttx

after
hujun5@hujun5-OptiPlex-7070:~/downloads1/vela_sim/nuttx$ size nuttx
   text    data     bss     dec     hex filename
 263324   49985   63893  377202   5c172 nuttx

reduce code size by  -476

Configuring NuttX and compile:
$ ./tools/configure.sh -l qemu-armv8a:nsh_smp
$ make
Running with qemu
$ qemu-system-aarch64 -cpu cortex-a53 -smp 4 -nographic \
   -machine virt,virtualization=on,gic-version=3 \
   -net none -chardev stdio,id=con,mux=on -serial chardev:con \
   -mon chardev=con,mode=readline -kernel ./nuttx

Signed-off-by: hujun5 <hujun5@xiaomi.com>
2024-10-09 18:19:13 +08:00
chao an
9dbde04327 Revert "toolchain/ghs: Fix CONFIG_SCHED_CRITMONITOR_MAXTIME_XXX "zero used for undefined preprocessing identifier" warnings"
move private define to public

This reverts commit 236678d730.

Signed-off-by: chao an <anchao@lixiang.com>
2024-10-09 18:16:56 +08:00
hujun5
8cd52bee2e arm64: g_current_regs is only used to determine if we are in irq, with other functionalities removed.
Signed-off-by: hujun5 <hujun5@xiaomi.com>
2024-10-09 18:16:43 +08:00
hujun5
d573952790 irq: use up_interrupt_context to replace up_current_regs
Signed-off-by: hujun5 <hujun5@xiaomi.com>
2024-10-09 18:16:43 +08:00
hujun5
4ecb6efee8 arm: tc32 nested interrupts are not supported
Signed-off-by: hujun5 <hujun5@xiaomi.com>
2024-10-09 18:16:43 +08:00
hujun5
ee81823546 arm: g_current_regs is only used to determine if we are in irq, with other functionalities removed.
reason:
by doing this we can reduce context switch time,
When we exit from an interrupt handler, we directly use tcb->xcp.regs

before
size nuttx
   text    data     bss     dec     hex filename
 225920     409   30925  257254   3ece6 nuttx

after
   text    data     bss     dec     hex filename
 225604     409   30925  256938   3ebaa nuttx

 szie change -316

Signed-off-by: hujun5 <hujun5@xiaomi.com>
2024-10-09 18:16:43 +08:00
xuxingliang
b63826a736 arch/sim: fix uart could lose log
Need to loop to write untill all data written or error happened

Signed-off-by: xuxingliang <xuxingliang@xiaomi.com>
2024-10-09 18:16:28 +08:00
Xiang Xiao
42ee317eab arch/sim: dataheap should disable exec permission
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2024-10-09 18:16:28 +08:00
yinshengkai
593768e11e sim/gcov: Fix conflicts between fprofile-orderate and __asan_default_options
Signed-off-by: yinshengkai <yinshengkai@xiaomi.com>
2024-10-09 18:16:28 +08:00
yinshengkai
b7121aac86 Revert "arch/sim: suppress libasan checks"
This reverts commit 53ddc3ef7f

Signed-off-by: yinshengkai <yinshengkai@xiaomi.com>
Signed-off-by: ligd <liguiding1@xiaomi.com>
2024-10-09 18:16:28 +08:00
ligd
d8637788a7 sim: fix context-switch when do wdog callback()
Signed-off-by: ligd <liguiding1@xiaomi.com>
2024-10-09 18:16:28 +08:00
raiden00pl
dff79e8e54 boards/stm32f7/stm32f746g-disco: fix FMC pin
during migration from legacy pinout some of the FMC pins were ommited because
their names were identical to the new pinout, which didn't cause a compilation error.

This fixes LCD examples.

Also update incomplete stm32f769i-disco FMC support to avoid this kind of bug in the future
2024-10-09 00:04:57 +08:00
buxiasen
77d1f78996 board/arm/stm32: highpri up_interrupt_context to is_nesting_interrupt
up_interrupt_context indicates that we self inside interrupt/handler mode,
replaced to private function is_nesting_interrupt to make less confused.

Signed-off-by: buxiasen <buxiasen@xiaomi.com>
2024-10-08 23:53:57 +08:00
buxiasen
431b848c79 board/arm/nrf52: fix use up_interrupt_context to is_nesting_interrupt
The case want to determine if a interrupt with higher priority and the
interrupt preemption occurred, but up_interrupt_context indicates that we
self inside interrupt/handler mode. As we previously did not handle the
ramvector interrupt correctly, after update breaked the case. We should
use a more clear private function is_nesting_interrupt.

Signed-off-by: buxiasen <buxiasen@xiaomi.com>
2024-10-08 23:53:57 +08:00
chenxiaoyi
21501f65b1 sim: add link option /LARGEADDRESSAWARE:NO for windows64
Signed-off-by: chenxiaoyi <chenxiaoyi@xiaomi.com>
2024-10-08 23:51:33 +08:00
chenxiaoyi
a23ed77782 sim: add windows64 setjmp/longjmp support
Signed-off-by: chenxiaoyi <chenxiaoyi@xiaomi.com>
2024-10-08 23:51:33 +08:00
chenxiaoyi
835aac23b7 sim: change the type of xcpt_reg_t
Signed-off-by: chenxiaoyi <chenxiaoyi@xiaomi.com>
2024-10-08 23:51:33 +08:00
chenxiaoyi
2f512f78bf libc: fix build warning
nuttx\libs\libc\misc\lib_bitmap.c(1,1): warning C4819: The file contains a character that cannot
 be represented in the current code page (936).

Signed-off-by: chenxiaoyi <chenxiaoyi@xiaomi.com>
2024-10-08 23:51:33 +08:00
chenxiaoyi
753e4d64ee sim/irq: fix windows64 build error
nuttx\vs2022\include\arch\irq.h(144,9): error C2065: 'mov': undeclared identifier

Signed-off-by: chenxiaoyi <chenxiaoyi@xiaomi.com>
2024-10-08 23:51:33 +08:00
chenxiaoyi
d309d49cae sim/types: fix windows64 build error
nuttx\include\sys\types.h(133,22): error C2371: 'size_t': redefinition; different basic types

Signed-off-by: chenxiaoyi <chenxiaoyi@xiaomi.com>
2024-10-08 23:51:33 +08:00
chenxiaoyi
3100deda9d sim: add windows64 defconfig
Signed-off-by: chenxiaoyi <chenxiaoyi@xiaomi.com>
2024-10-08 23:51:33 +08:00
anjiahao
9403bc126b modlib/dlfcn:unify same code
Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2024-10-08 23:51:33 +08:00
dongjiuzhu1
79b4b39994 libc/modlib: free memory resource when rmmod elf
Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
2024-10-08 23:51:33 +08:00
dongjiuzhu1
3b0e2be058 binfmt/modlib: support loading each sections to different memory for Relocate object
The feature depends on ARCH_USE_SEPARATED_SECTION
the different memory area has different access speed and cache
capability, so the arch can custom allocate them based on
section names to achieve performance optimization

test:
sim:elf
sim:sotest

Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
2024-10-08 23:51:33 +08:00
ligd
a965e3c3f9 math: remove is_power_of_2() keep IS_POWER_OF_2()
Caused it may conflict with other platfrom

Signed-off-by: ligd <liguiding1@xiaomi.com>
2024-10-08 23:50:47 +08:00
Ville Juven
10e44f8915 riscv_fork.c: Fix race condition when handling parent integer registers
We need to record the parent's integer register context upon exception
entry to a separate non-volatile area. Why?

Because xcp.regs can move due to a context switch within the fork() system
call, be it either via interrupt or a synchronization point.

Fix this by adding a "sregs" area where the saved user context is placed.
The critical section within fork() is also unnecessary.
2024-10-03 09:07:57 +08:00