Commit Graph

190 Commits

Author SHA1 Message Date
chao an d49db03e04 libs/misc/memoryregion: remove unused memory_region
memory region will no longer be used

Signed-off-by: chao an <anchao@lixiang.com>
2024-10-18 21:32:48 +08:00
Bowen Wang 8cfe8a0f3e circbuf: fix circbuf_get_read/writeptr return *size = 0 when circbuf full
In circbuf_get_read/writeptr, when circbuf is full, off == pos, and
*size = off - pos = 0. So add circbuf_is_full() condition to return
correct *size.

Signed-off-by: Bowen Wang <wangbowen6@xiaomi.com>
2024-10-16 16:59:51 +08:00
likun17 9de0465a8a lib_libvsprintf.c:add option in Kconfig to control "%p*" special format specifier.
Signed-off-by: likun17 <likun17@xiaomi.com>
2024-10-15 15:33:13 +08:00
yinshengkai 38e474b0c5 libc: add CRC-8-ROHC support
Signed-off-by: yinshengkai <yinshengkai@xiaomi.com>
2024-10-13 03:09:26 +08:00
Bowen Wang 101b147a24 lib_memoryregion: fix the comments about the memory flags
Follow the elf format, correct the memory region flag description:
Executable 0x1, Writable 0x2, Readable 0x4

Signed-off-by: Bowen Wang <wangbowen6@xiaomi.com>
2024-10-13 02:28:55 +08:00
xuxin19 351781d601 cmake:refine nuttx cmake build system fix CMake build missing part
Signed-off-by: xuxin19 <xuxin19@xiaomi.com>
2024-10-13 02:25:06 +08:00
wangmingrong1 6e12b3d74b libc/utsname: Only store version in RAM, use rodata for all others
Signed-off-by: wangmingrong1 <wangmingrong1@xiaomi.com>
2024-10-12 15:36:28 +08:00
wangmingrong1 f233c5860c libc/lib_utsname: Store version number for debugging and preventing optimization
In order to directly read the version information of the current file from elf or bin files, memory files, etc., for easy debugging and one-to-one correspondence.

Signed-off-by: wangmingrong1 <wangmingrong1@xiaomi.com>
2024-10-12 15:36:28 +08:00
yinshengkai ba2865f20a sched: support backtrace record
Signed-off-by: yinshengkai <yinshengkai@xiaomi.com>
2024-10-11 00:37:27 +08:00
yinshengkai 1a00ca3cd7 libc: rename lib_execinfo.c to lib_backtrace.c
Signed-off-by: yinshengkai <yinshengkai@xiaomi.com>
2024-10-11 00:37:27 +08:00
Xiang Xiao b068e2357a circbuf: Move from mm/circbuf to libs/libc/misc
so that it can be used by userspace program.

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Signed-off-by: Neo Xu <neo.xu1990@gmail.com>
2024-10-09 08:41:49 +08:00
fangpeina b5145c528e misc/assert: add backtrace dump support for mutex hold task
Signed-off-by: fangpeina <fangpeina@xiaomi.com>
2024-10-09 08:37:01 +08:00
chenxiaoyi c8e0f5c890 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-04 08:21:35 +08:00
anjiahao 60796a7063 coredump:add const to memory region struct ptr
Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2024-10-01 20:40:28 +08:00
Alin Jerpelea 6b5dddd5d7 libs/libc: migrate to SPDX identifier
Most tools used for compliance and SBOM generation use SPDX identifiers
This change brings us a step closer to an easy SBOM generation.

Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>
2024-10-01 12:25:52 +08:00
yangguangcai 523b72d095 ftok:check mkdir return value.
Signed-off-by: yangguangcai <yangguangcai@xiaomi.com>
2024-09-28 19:10:31 +08:00
likun17 65264051aa stdio/va_format: move non-standard structure va_format to nuttx/streams.h
Signed-off-by: likun17 <likun17@xiaomi.com>
Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
2024-09-27 10:29:22 +08:00
chao an f44a9c44a7 libc/pathbuffer: fix build warning on tasking
[263/1096] Building C object libs/libc/CMakeFiles/c.dir/misc/lib_pathbuffer.c.obj
ctc W574: ["libs/libc/misc/lib_pathbuffer.c" 144/3] 'return' with an expression in function returning void

Signed-off-by: chao an <anchao@lixiang.com>
2024-09-24 23:10:31 +08:00
lipengfei28 56308bf202 bitmap: add bitmap_find_free_region
The pci ep framewoek use bitmap manage the pci outbond memory

Signed-off-by: lipengfei28 <lipengfei28@xiaomi.com>
2024-09-23 10:03:54 +02:00
lipengfei28 ca39dc2e74 math: Optimize the implementation of log2ceil and log2floor
and move common math funtions to math32.h:
div_round_up
div_round_closest
is_power_of_2
roundup_pow_of_two
rounddown_pow_of_two

Signed-off-by: lipengfei28 <lipengfei28@xiaomi.com>
2024-09-23 10:03:54 +02:00
lipengfei28 4fd78583f7 libc: add find_next_zero_bit
The pci ep framework use bitmap manage free bar

Signed-off-by: lipengfei28 <lipengfei28@xiaomi.com>
2024-09-23 10:03:54 +02:00
buxiasen fba0324bd7 libc/misc/crc32: crc32 add slow mode, optional decrease size
Signed-off-by: buxiasen <buxiasen@xiaomi.com>
2024-09-12 16:17:21 +02:00
ligd 6a2c03732f clock: Replace all ts and tick conversion functions
Using the ts/tick conversion functions provided in clock.h

Do this caused we want speed up the time calculation, so change:
clock_time2ticks, clock_ticks2time, clock_timespec_add,
clock_timespec_compare, clock_timespec_subtract... to MACRO

Signed-off-by: ligd <liguiding1@xiaomi.com>
2024-09-12 18:14:39 +08:00
makejian 85f8677e21 nxmutex: export priority ceiling interfaces with nxsem
Signed-off-by: makejian <makejian@xiaomi.com>
2024-09-10 01:26:31 +08:00
Petro Karashchenko 1528b8dcca nuttx: resolve various 'FAR' and 'CODE' issues
Signed-off-by: Petro Karashchenko <petro.karashchenko@gmail.com>
2024-08-26 10:21:03 +08:00
yinshengkai 667de7be32 mutex: add nxrmutex_is_recursive api
Signed-off-by: yinshengkai <yinshengkai@xiaomi.com>
2024-08-23 08:56:00 +08:00
yinshengkai a2b8c83e0e mutex: align nxmutex_breaklock interface with nxrmutex_breaklock
Signed-off-by: yinshengkai <yinshengkai@xiaomi.com>
2024-08-23 08:56:00 +08:00
yinshengkai eee7cb6efa libc: nxmutex_clocklock abstime supports NULL pointer
Signed-off-by: yinshengkai <yinshengkai@xiaomi.com>
2024-08-23 08:56:00 +08:00
yinshengkai 01864d262c sched: add mutex_holder and mutex_clocklock API
Signed-off-by: yinshengkai <yinshengkai@xiaomi.com>
2024-08-23 08:56:00 +08:00
yinshengkai 4af6db7c80 mutex: remove mutex trylock holder check
The standard describes trylock as follows, trylock should never cause the system to stop running:

The pthread_mutex_trylock() function shall be equivalent to
pthread_mutex_lock(), except that if the mutex object referenced by
mutex is currently locked (by any thread, including the current thread),
the call shall return immediately.

https://linux.die.net/man/3/pthread_mutex_trylock

Signed-off-by: yinshengkai <yinshengkai@xiaomi.com>
2024-08-23 08:56:00 +08:00
chenrun1 271f76590f fs_lock/pathbuffer:Optimize code structure
Summary:
  Adjust code logic

Signed-off-by: chenrun1 <chenrun1@xiaomi.com>
2024-08-22 01:54:22 +08:00
chenrun1 36a8ff0540 lib_pathbuffer.c:Determine whether to malloc from the heap by CONFIG_LIBC_PATHBUFFER_MALLOC
Summary:
  If we disable LIB_PATHBUFFER_MALLOC, that when the path buffer is insufficient, NULL is returned to avoid applying for a buffer from the heap.

Signed-off-by: chenrun1 <chenrun1@xiaomi.com>
2024-08-22 01:54:22 +08:00
guohao15 16afee6f0c notify:add path tmp buffer
Signed-off-by: guohao15 <guohao15@xiaomi.com>
2024-08-22 01:54:22 +08:00
chenrun1 5bf24a15b5 lib_getnprocs:add #include <sys/types.h> instead of ifdef
Summary:
  Since there is a default definition for CONFIG_SMP_NCPUS in sys/types.h, we can remove #ifdef and return CONFIG_SMP_NCPUS directly.

Signed-off-by: chenrun1 <chenrun1@xiaomi.com>
2024-08-21 02:04:15 +08:00
chenrun1 f3cf11dcb5 libc/msic:Implement get_nprocs API
Summary:
 1.Remove the macro definition of getnproc in sysinfo
 2.New get_nprocs_conf and get_nprocs interfaces, return CONFIG_SMP_NCPUS, return 1 when not defined

Signed-off-by: chenrun1 <chenrun1@xiaomi.com>
2024-08-21 02:04:15 +08:00
chenrun1 97338c9f3d idr:New idr_find interface
Different from idr_get_next, if idr_find directly when could not find the node id return an error

Signed-off-by: chenrun1 <chenrun1@xiaomi.com>
2024-08-19 11:05:40 -03:00
chenrun1 a1ccf15e39 idr:Tool for associating discrete ids with addresses
This is a tool for associating discrete IDs with addresses.
This tool is implemented through the red-black tree method provided by <sys/tree.h>, and the time complexity when calling, searching, and deleting is optimized to O(logn)
The implementation is the moving node operation of two red-black trees
1. When applying for a node, it will first check whether there is an available node in the "removed" tree. If so, the memory address of the node will be reused and moved to the "alloced" tree.
2. If the "removed" tree is an "empty tree", then the node will be requested from the memory and added to the "alloced" tree
3. Similarly, when removing a node, we set the address pointed to in the node to "NULL" and move it to the "removed" tree. Next time we alloc the node, we can reduce the overhead caused by memory application
For now, we still have something that can be optimized, and that is the memory elimination mechanism of the "removed tree". The current implementation will only release all the content under the "removed" tree when the idtree is destroyed.

Signed-off-by: chenrun1 <chenrun1@xiaomi.com>
2024-08-19 11:05:40 -03:00
hujun5 08e6f56176 fdcheck: fix race condition in fdcheck
reason: ioctl will use the fl_lock file lock, causing context switching,
further leading to the failure of g_fdcheck_lock protection

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-08-18 10:27:03 -03:00
xuxin19 af10e1b470 lib_ustname:keep the incrementally compiled version time updated
fix phoney target mismatch issue, always rebuild ustname

Signed-off-by: xuxin19 <xuxin19@xiaomi.com>
2024-08-13 19:42:32 +08:00
fangpeina 242b50f921 libc/execinfo: extract a common backtrace format function
Add a common method to format backtrace to buffer, so it can be used by both mm, fs and other possoble modules.

Signed-off-by: fangpeina <fangpeina@xiaomi.com>
2024-06-29 22:44:39 +08:00
hujun5 638716504d fdcheck: update fdcheck impl
1 store fd in the high position
2 removing the pid information , as the tag information is sufficient.

Signed-off-by: hujun5 <hujun5@xiaomi.com>
2024-04-11 10:45:44 +08:00
Alan Carvalho de Assis 97e217b0ff libc/uname: Add option to disable uname timestamp
Don't include the build timestamp into final binary when the symbol
CONFIG_LIBC_UNAME_DISABLE_TIMESTAMP is defined.

Signed-off-by: Alan C. Assis <acassis@gmail.com>
2024-03-23 11:42:22 +08:00
hujun5 577eb47966 fdcheck: Enable fdcheck to automatically detect ownership of fd
Signed-off-by: hujun5 <hujun5@xiaomi.com>
2024-03-07 09:08:48 +08:00
Ville Juven e03599d9ae libs/log2ceil: Move implementation of log2ceil to a common place
Move log2ceil from riscv_pmp to libc. Also, implement log2floor for
completeness.

These are the run-time alternative to the compile-time macros.
2023-12-14 08:46:12 -08:00
anjiahao 7dfbd14eba libc: add instrument api support
Add registration function instrumentation API,
which can achieve instrumentation of entering and
exiting functions through the compiler's functionality.

We can use CONFIG_ARCH_INSTRUMENT_ALL to add instrumentation for all
source, or add '-finstrument-functions' to CFLAGS for Part of the
source.

Notice:
1. use CONFIG_ARCH_INSTRUMENT_ALL must mark _start or entry noinstrument_function,
   becuase bss not set.
2. Make sure your callbacks are not instrumented recursively.

use instrument_register to register entry function and exit function.
They will be called by the instrumented function

Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2023-12-11 02:06:51 -08:00
Federico Braghiroli 8b9c64eecf lib_slcd: fix encode/decode of binary nibble to/from ascii hex
Binary nibble to/from ascii hex conversion was buggy on both
lib_slcdencode and lib_slcddecode libraries.

This bug caused the slcd library to fail to decode 5-byte sequence command
which have 'count' argument value bigger than 0x9.

Signed-off-by: Federico Braghiroli <federico.braghiroli@gmail.com>
2023-12-10 21:54:01 -08:00
anjiahao 35051dd715 coredump: support coredump save to block device when crash
Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2023-12-10 07:02:03 -08:00
anjiahao 542a5555d3 libc:add parse_memory_range to parse memory string
Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2023-12-10 07:02:03 -08:00
Ville Juven c9bdadd541 sched/semaphore: Move cancel point and errno handling to libc / user-space
This moves all the public POSIX semaphore functions into libc and with
this most of the user-space logic is also moved; namely cancel point and
errno handling.

This also removes the need for the _SEM_XX macros used to differentiate
which API is used per user-/kernel mode. Such macros are henceforth
unnecessary.
2023-11-27 04:52:54 -08:00
zhanghongyu 766e4a4154 libs/libc: adapt the cmake script from the makefile
fix the cmake build error.

Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
2023-11-07 17:39:03 +01:00