Commit Graph

1361 Commits

Author SHA1 Message Date
yinshengkai 79eab8783f note: add memory tracing event support
Record all memory allocation and release, save to ram, used to analyze memory allocation rate and memory usage
Its absolute value is not trustworthy because the memory will be allocated in thread A and released in thread B

 netinit-5   [0]   0.105984392: tracing_mark_write: C|5|Heap Usage|96|free: heap: 0x606000000020 size:24, address: 0x603000000370
 netinit-5   [0]   0.105996874: tracing_mark_write: C|5|Heap Usage|24|free: heap: 0x606000000020 size:72, address: 0x6070000008e0
nsh_main-4   [0]   3.825169408: tracing_mark_write: C|4|Heap Usage|2177665|free: heap: 0x606000000020 size:424, address: 0x614000000840
nsh_main-4   [0]   3.825228525: tracing_mark_write: C|4|Heap Usage|14977|free: heap: 0x606000000020 size:2162688, address: 0x7f80a639f800
nsh_main-4   [0]   3.825298789: tracing_mark_write: C|4|Heap Usage|15189|malloc: heap: 0x606000000020 size:20, address: 0x6030000003a0

Signed-off-by: yinshengkai <yinshengkai@xiaomi.com>
Signed-off-by: Neo Xu <neo.xu1990@gmail.com>
2024-10-07 17:34:59 +08:00
lijianjun 9762ddee6e add mm_uninitialize empty implementation for sim
Signed-off-by: lijianjun <lijianjun@xiaomi.com>
Signed-off-by: Neo Xu <neo.xu1990@gmail.com>
2024-10-07 17:34:59 +08:00
hujun5 f132ed2edb signal: adjust the signal processing logic to remove the judgment
Signed-off-by: hujun5 <hujun5@xiaomi.com>
2024-10-07 13:32:57 +08:00
hujun5 7eea4223ee arch: move sigdeliver to common code
Signed-off-by: hujun5 <hujun5@xiaomi.com>
2024-10-07 13:32:57 +08:00
hujun5 eae57cb0e6 sched: replace sync pause with async pause for nxtask_terminate
reason:
In the kernel, we are planning to remove all occurrences of up_cpu_pause as one of the steps to
simplify the implementation of critical sections. The goal is to enable spin_lock_irqsave to encapsulate critical sections,
thereby facilitating the replacement of critical sections(big lock) with smaller spin_lock_irqsave(small lock)

Signed-off-by: hujun5 <hujun5@xiaomi.com>
2024-10-06 09:26:56 +08:00
chenxiaoyi 56bcbcc6b0 sim: change the type of xcpt_reg_t
Signed-off-by: chenxiaoyi <chenxiaoyi@xiaomi.com>
2024-10-04 08:21:35 +08:00
chenxiaoyi f6fc4cdded 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-04 08:21:35 +08:00
chenxiaoyi 43de53c93f 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-04 08:21:35 +08:00
Yongrong Wang d0e4c4436e rpmsg_virtio: move rpmsg virtio cmd definition before the resource table
use reserved[2] in struct resource_table as the command, avoid the
resource table format do not follow the standard.

Signed-off-by: Yongrong Wang <wangyongrong@xiaomi.com>
2024-10-03 09:37:24 +08:00
W-M-R 5febd80efe cmake: add_compile_options recognizes parameter exception
add_compile_options(--param asan-globals=1) is recognized as
--param-lasan-globals=1, which causes compilation exception:

Signed-off-by: W-M-R <Mike_0528@163.com>
2024-10-02 21:09:31 +08:00
xuxin19 18b6b72240 cmake:fix windows build break
-U_WIN32 will cause windows host source such as sim_hostirq.c hearder windows.h exception

Signed-off-by: xuxin19 <xuxin19@xiaomi.com>
2024-10-01 21:34:26 +08:00
xuxin19 b9dc9fb0fc cmake:refine SIM platform CMake Toolchain file
Signed-off-by: xuxin19 <xuxin19@xiaomi.com>
2024-10-01 21:34:26 +08:00
guoshichao ff4ad07576 greenhills: add cmake support
1. refactor the ghs/gcc/clang/armclang toolchain management in CMake
2. unify the cmake toolchain naming style
3. support greenhills build procedure with CMake
4. add protect build for greenhills and gnu toolchain with CMake

Signed-off-by: guoshichao <guoshichao@xiaomi.com>
2024-10-01 11:48:09 +08:00
hujun5 5fb56f6d95 sim: add NXSYMBOLS pthread_gettid_np pthread_self
reason:
enable sim:smp can boot

This commit fixes the regression from https://github.com/apache/nuttx/pull/12561

Signed-off-by: hujun5 <hujun5@xiaomi.com>
2024-09-30 18:26:00 +08:00
dongjiuzhu1 1f1d90de1c 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-09-29 15:06:54 +08:00
hujun5 9de9f8168d 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-09-29 08:54:51 +08:00
dulibo1 14f278ab89 sim:fix oneshot sim_cancel assert
when CONFIG_PM and CONFIG_CPULOAD_ONESHOT are defined
sim_cancel may assert:
[429492.185400] [ 0] [ EMERG] [ap] _assert: Current Version: NuttX ap 12.3.0 5ffeb16111-dirty Dec  4 2023 14:32:27 sim
[429492.185400] [ 0] [ EMERG] [ap] _assert: Assertion failed : at file: sim/sim_oneshot.c:367 task: Idle_Task process: Kernel 0x323254d
[429492.185400] [ 0] [ EMERG] [ap] backtrace:
[429492.185400] [ 0] [ EMERG] [ap] [ 0] [<0xf7941ad5>] _fini+0xf0753010/0xf8e1155b
[429492.185400] [ 0] [ EMERG] [ap] [ 0] [<0x71def50>] host_backtrace+0x41/0x72
[429492.185400] [ 0] [ EMERG] [ap] [ 0] [<0x65b68bd>] up_backtrace+0x126/0x2f8
[429492.185400] [ 0] [ EMERG] [ap] [ 0] [<0x6554ceb>] sched_backtrace+0x70/0x8a
[429492.185400] [ 0] [ EMERG] [ap] [ 0] [<0x37585d2>] sched_dumpstack+0xed/0x494
[429492.185400] [ 0] [ EMERG] [ap] [ 0] [<0x3694d8e>] _assert+0x93b/0xa82
[429492.185400] [ 0] [ EMERG] [ap] [ 0] [<0x33223eb>] __assert+0x3e/0x4c
[429492.185400] [ 0] [ EMERG] [ap] [ 0] [<0x336b6d5>] sim_cancel+0xde/0x392
[429492.185400] [ 0] [ EMERG] [ap] [ 0] [<0x36a4301>] nxsched_oneshot_pmnotify+0x2aa/0x2ee
[429492.185400] [ 0] [ EMERG] [ap] [ 0] [<0x36bce77>] pm_changeall+0x478/0x526
[429492.185400] [ 0] [ EMERG] [ap] [ 0] [<0x36bd71f>] pm_changestate+0x380/0x82c
[429492.185400] [ 0] [ EMERG] [ap] [ 0] [<0x336297b>] up_idle+0x54/0xa6
[429492.185400] [ 0] [ EMERG] [ap] [ 0] [<0x32347b8>] nx_start+0x226b/0x226e
[429492.185400] [ 0] [ EMERG] [ap] [ 0] [<0x31d49f5>] main+0x54/0x70
[429492.185400] [ 0] [ EMERG] [ap] [ 0] [<0xf6bbcfa1>] _fini+0xef9ce4dc/0xf8e1155b
[429492.185400] [ 0] [ EMERG] [ap] [ 0] [<0x31914ac>] _start+0x31/0x46

Signed-off-by: dulibo1 <dulibo1@xiaomi.com>
2024-09-28 10:43:09 +08:00
dulibo1 3107822c08 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-09-27 23:30:40 +08:00
ligd 551e6ce3ab compile: add DEBUG_SYMBOLS_LEVEL allow custom the level
Signed-off-by: ligd <liguiding1@xiaomi.com>
2024-09-27 00:13:07 +08:00
anjiahao c76e83beaa Debug option:change -g to -g3, add macro information to elf
Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2024-09-27 00:13:07 +08:00
Bowen Wang dbe43b0ae9 rptun: move rptun cmd definition before the resource table
Because locate the command at the end the resource table is unfriendly
when we want to support multi virtio devices instead only one virtio
rpmsg device.

Signed-off-by: Bowen Wang <wangbowen6@xiaomi.com>
2024-09-26 00:04:05 +08:00
Yongrong Wang 10e8b6c9f6 rptun/rpmsg_virtio: remove chip cmd and reuse the common ones
Add more common command for rptun and rpmsg_virtio frameworks,
also modify the rptun and rpmsg_virtio driver to use the common
commands.

Signed-off-by: Yongrong Wang <wangyongrong@xiaomi.com>
2024-09-26 00:04:05 +08:00
Yongrong Wang 420af99797 sim_rptun.c: remove sim_rptun_panic
Because we can use the common part implemented in rptun

Signed-off-by: Yongrong Wang <wangyongrong@xiaomi.com>
2024-09-26 00:04:05 +08:00
Yongrong Wang 7c7d08d13a rptun.c/rpmsg_virtio.c: move panic logic from chip to rptun/rpmsg_virtio
Move the panic logic in common places, later we can move more logic to
the framework instead of having the drivers implement it repeatedly.

Signed-off-by: Yongrong Wang <wangyongrong@xiaomi.com>
Signed-off-by: Bowen Wang <wangbowen6@xiaomi.com>
2024-09-26 00:04:05 +08:00
Bowen Wang 9cceccb14a sim/sim_rptun: add 64-bit support for sim_rptun
add remote addrenv to make the da is start from 0, so the uint32_t
da in resource table can store the correct address

Signed-off-by: Bowen Wang <wangbowen6@xiaomi.com>
2024-09-26 00:04:05 +08:00
hujun5 c9bdb598b7 irq: use up_interrupt_context to replace up_current_regs
Signed-off-by: hujun5 <hujun5@xiaomi.com>
2024-09-25 08:58:20 +08:00
wangmingrong1 469418f3c9 mm/kasan: Kasan global support setting alignment length
1. Similar to asan, supports single byte out of bounds detection
2. Fix the script to address the issue of not supporting the big end

Signed-off-by: wangmingrong1 <wangmingrong1@xiaomi.com>
2024-09-20 21:47:23 +08:00
Masayuki Ishikawa df298c186f Revert "build depend:Revert Make.dep intermediate ddc file"
This reverts commit ddc3119c4e.
2024-09-15 19:29:47 +08:00
xuxin19 ddc3119c4e build depend:Revert Make.dep intermediate ddc file
Revert "Parallelize depend file generation"
This reverts commit d5b6ec450f.

parallel depend ddc does not significantly speed up compilation,
intermediately generated .ddc files can cause problems if compilation is interrupted unexpectedly

Signed-off-by: xuxin19 <xuxin19@xiaomi.com>
2024-09-15 10:01:58 +08:00
wangyongrong ff399054c1 rptun/rpmsg_virtio: fix addrenv/raddrenv num error
Buf fix, simple_addrenv assume the last addrenv in addrenv array
be zero value

Signed-off-by: wangyongrong <wangyongrong@xiaomi.com>
2024-09-14 17:34:52 +08:00
wangyongrong 842486ff52 sim_rptun/rpmsg_virtio: Replace work queue with wdog
Wdog has better performance than work queue

Signed-off-by: wangyongrong <wangyongrong@xiaomi.com>
2024-09-14 17:34:52 +08:00
yintao 30fd12c687 sim/sim_rptun.c: Fixed data type for sim_rptun_shmem_s
Use fixed length data type for the struct shared in cross-core
communication

Signed-off-by: yintao <yintao@xiaomi.com>
2024-09-14 17:34:52 +08:00
yintao 5a04670600 sim/sim_rptun: Check if the shared memory has been allocated
Bug fix

Signed-off-by: yintao <yintao@xiaomi.com>
2024-09-14 17:34:52 +08:00
yintao 4f14f8226a sim/sim_rptun: Support master/slave notifies opposite side when recovery
When in a multi-core structure, as the intermediate core,
remote is both the master and slave;When the remote exception or
restart occurs, it needs to notify the slave and reestablish the connection

Signed-off-by: yintao <yintao@xiaomi.com>
2024-09-14 17:34:52 +08:00
Yongrong Wang a20cc9f04c sim rpmsg virtio: add sim rpmsg virtio support
add sim_rpmsg_virtio.c to verify the new rpmsg virtio wrapper layer,
new the rpmsg virtio can be used in sim platfrom

Signed-off-by: Yongrong Wang <wangyongrong@xiaomi.com>
2024-09-14 17:34:52 +08:00
hujun5 908df725ad arch: use up_current_regs/up_set_current_regs replace CURRENT_REGS
reason:
1 On different architectures, we can utilize more optimized strategies
  to implement up_current_regs/up_set_current_regs.
eg. use interrupt registersor percpu registers.

code size
before
    text    data     bss     dec     hex filename
 262848   49985   63893  376726   5bf96 nuttx

after
       text    data     bss     dec     hex filename
 262844   49985   63893  376722   5bf92 nuttx

size change -4

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-09-13 23:18:58 +08:00
hujun5 1aab457b4c sched:add parameters to restore_critical_section
reason:
In SMP, when a context switch occurs, restore_critical_section is executed.
To reduce the time taken for context switching, we directly pass the required
parameters to restore_critical_section instead of acquiring them repeatedly.

Signed-off-by: hujun5 <hujun5@xiaomi.com>
2024-09-10 23:14:09 +08:00
shizhenghui 7472b08851 sim_sound: add AUDIOUTILS_LAME to dependency list
Signed-off-by: shizhenghui <shizhenghui@xiaomi.com>
2024-09-10 20:25:48 +08:00
shizhenghui dea9e5343d arch/sim/Makefile: add libmad & lame include path
Signed-off-by: shizhenghui <shizhenghui@xiaomi.com>
2024-09-10 20:25:48 +08:00
shizhenghui 6637606096 sim_offload: move out of the posix directory
The libmad and libmp3lame libraries have been ported to
apps/audioutils and will be compiled with NuttX.

Signed-off-by: shizhenghui <shizhenghui@xiaomi.com>
2024-09-10 20:25:48 +08:00
cuiziwei 6eb286ae01 sim:Remove -lmad cause it has been ported to the apps/audioutils directory.
Signed-off-by: cuiziwei <cuiziwei@xiaomi.com>
2024-09-10 20:25:48 +08:00
hujun5 608b59e401 smp: enable smp_call in all smp arch
reason:
In subsequent implementations, we will replace up_cpu_pause with smp_call.
Signed-off-by: hujun5 <hujun5@xiaomi.com>
2024-09-06 07:11:38 +09:00
fangxinyong 7b05a550dc sched: replace up_cpu_index with this_cpu
Make this_cpu is arch independent and up_cpu_index do that.
In AMP mode, up_cpu_index() may return the index of the physical core.

Signed-off-by: fangxinyong <fangxinyong@xiaomi.com>
2024-09-05 12:09:24 +08:00
guoshichao 4c01594d5b nuttx: remove the unnecessary -pipe build option
Signed-off-by: guoshichao <guoshichao@xiaomi.com>
2024-08-31 10:22:20 +08:00
jinxiuxu 575c9b12ab drivers/audio: fix samp rate conversion issue
use ac_controls.hw to get the correct sample rate intead of ac_controls.b

Signed-off-by: jinxiuxu <jinxiuxu@xiaomi.com>
2024-08-27 22:00:39 +08:00
yinshengkai 84333881d7 mm: add mm_largest api to get the current largest available memory block
Signed-off-by: yinshengkai <yinshengkai@xiaomi.com>
2024-08-25 23:09:28 +08:00
yinshengkai 49d1b4198f mm: add memory pressure notification support
Add mm_heap_free interface to pass remaining memory to memory pressure

Signed-off-by: yinshengkai <yinshengkai@xiaomi.com>
2024-08-25 23:09:28 +08:00
Petro Karashchenko d499ac9d58 nuttx: fix multiple 'FAR', 'CODE' and style issues
Signed-off-by: Petro Karashchenko <petro.karashchenko@gmail.com>
2024-08-25 19:22:15 +08:00
wangchen f0cdaca660 nuttx-names.in:add popen & pclose assign to glibc interface
Signed-off-by: wangchen <wangchen41@xiaomi.com>
2024-08-23 20:20:25 +08:00
Xu Xingliang cfdbc856ff sim/lcd: fix compile break
Signed-off-by: Xu Xingliang <xuxingliang@xiaomi.com>
2024-08-23 15:26:16 +08:00