Commit Graph

6755 Commits

Author SHA1 Message Date
yinshengkai
ca99e69c28 fs: update hostfs structure definition
Signed-off-by: yinshengkai <yinshengkai@xiaomi.com>
2023-12-26 17:41:12 -08:00
yinshengkai
9b10255088 fs: fix structure layout inconsistency in hostfs
Use the following command to view the structure layout:
pahole nuttx > struct_size.h

Signed-off-by: yinshengkai <yinshengkai@xiaomi.com>
2023-12-26 17:41:12 -08:00
YAMAMOTO Takashi
992719730f Fix hostfs after uid/gid changes
This fixes a regression in https://github.com/apache/nuttx/pull/10869
2023-12-25 19:40:47 -08:00
yinshengkai
81fccf96db libc/stream: add file out stream
Signed-off-by: yinshengkai <yinshengkai@xiaomi.com>
2023-12-25 16:54:16 -03:00
yinshengkai
0c95bf73dc libc/stream: provide lowerout_stream default initialization function
Signed-off-by: yinshengkai <yinshengkai@xiaomi.com>
2023-12-25 16:54:16 -03:00
Tiago Medicci Serrano
d1326e81bc drivers/leds/ws2812: Fix WS2812 pixel size
Although the LED might be RGB-only, the LED data is packed in a
32-bit long variable and, then, this is the default size of a LED
pixel to define the 'WS2812_RW_PIXEL_SIZE' macro. Please note that
the lower-half driver will deal with the case of the addressable
LED being 3 or 4-pixel sized.
2023-12-24 16:38:06 -08:00
Tiago Medicci Serrano
fcff5d43b7 drivers/rmt: Implement an upper-half RMT character driver
The RMT (Remote Control) character driver allows to use the RMT
peripheral (usually, a one-wire peripheral dedicated to driving
IR remote control) as a character driver.

Please note that this perpiheral depends on the lower-half specific
driver implementation.
2023-12-24 16:38:06 -08:00
Jukka Laitinen
ebe961df9e drivers/net/ksz9477: Add simple port-based static VLAN configuration
Add a static port-based VLAN configuration for KSZ9477 switch. This doesn't
use the VLAN tagging, but is a switch's internal mechanism to simply configure
if the packet forwarding is allowed from one port to another.

Signed-off-by: Jukka Laitinen <jukkax@ssrc.tii.ae>
2023-12-20 01:30:54 -08:00
jianglianfang
2a92748c42 drivers/goldfish_fb: optimize goldfish fb register
The Goldfish FB register should be optimized by considering the need to pass in parameters for base and irq.

Signed-off-by: jianglianfang <jianglianfang@xiaomi.com>
2023-12-18 09:08:32 -08:00
jianglianfang
f4c8a17837 sim_lcd: add open & close
The opening and closing of the window has been associated with the opening and closing of fb, but the LCD has not yet been optimized. The window will only open when sim_x11openwindow is called, and similarly, the window will only close when sim_x11closewindow is called.

Signed-off-by: jianglianfang <jianglianfang@xiaomi.com>
2023-12-18 09:06:29 -08:00
guoshichao
b3867d5230 libs/libc/wchar: add ungetwc implementation
Signed-off-by: guoshichao <guoshichao@xiaomi.com>
2023-12-17 01:39:06 -08:00
guoshichao
0b2f7f7f3c libs/libc/wchar: add getwc implementation
Signed-off-by: guoshichao <guoshichao@xiaomi.com>
2023-12-17 01:39:06 -08:00
guoshichao
8c37c3841b libs/libc/wchar: add fgetwc implementation
Signed-off-by: guoshichao <guoshichao@xiaomi.com>
2023-12-17 01:39:06 -08:00
liqinhui
98e3615b60 net/netdev: Modify the logic for setting the IFF_RUNNING status of interfaces.
Refer to the logic of the `netif_carrier_on` on linux.
https://github.com/torvalds/linux/blob/master/net/sched/sch_generic.c#L575

Signed-off-by: liqinhui <liqinhui@xiaomi.com>
2023-12-15 18:24:23 -08:00
liqinhui
6a8c638d57 qemu/wifi: Add the virtual wifi function on the emulator.
-The qemu wifi fucntion only supports the STA mode and the following
 operations:
 wapi mode wlan0 2
 wapi scan wlan0
 wapi psk wlan0 password 3
 wapi essid wlan0 wifi_name 1
 wapi show wlan0
 wapi disconnect wlan0
-Eanble the virtual wifi function with the MACRO `CONFIG_DRIVERS_WIFI_SIM`.

Signed-off-by: liqinhui <liqinhui@xiaomi.com>
2023-12-14 20:22:12 -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
simbit18
9d50d180b1 Fix nuttx coding style
Remove spaces
Remove extra */
2023-12-13 17:29:08 +01:00
Petteri Aimonen
c3a234fe99 ipv6: Fix source address with many addresses in same network
Previously ipv6 multi-address support decided packet source
address based on its destination. This doesn't work if NuttX
device has multiple addresses within same subnet.

Instead when a packet is a response to existing connection,
the source address should be based on the destination address
used in the received packet.
2023-12-13 06:13:25 -08:00
Ville Juven
996625ec58 riscv/arch_elf.c: Handle PCREL_HI20/LO12_I/S relocations correctly
There is a problem with the current elf loader for risc-v: when a pair of
PCREL_HI20 / LO12 relocations are encountered, it is assumed that these
will follow each other immediately, as follows:

label:
	auipc      a0, %pcrel_hi(symbol)    // R_RISCV_PCREL_HI20
	load/store a0, %pcrel_lo(label)(a0) // R_RISCV_PCREL_LO12_I/S

With this assumption, the hi/lo relocations are both done when a hi20
relocation entry is encountered, first to the current instruction (addr)
and to the next instruction (addr + 4).

However, this assumption is wrong. There is nothing in the elf relocation
specification[1] that mandates this. Thus, the hi/lo relocation always
needs to first fixup the hi-part, and when the lo-part is encountered, it
needs to find the corresponding hi relocation entry, via the given "label".
This necessitates (re-)visiting the relocation entries for the current
section as well as looking for "label" in the symbol table.

The NuttX elf loader does not allow such operations to be done in the
machine specific part, so this patch fixes the relocation issue by
introducing an architecture specific cache for the hi20 relocation and
symbol table entries. When a lo12 relocation is encountered, the cache
can be consulted to find the hi20 part.

[1] https://github.com/riscv-non-isa/riscv-elf-psabi-doc/blob/master/riscv-elf.adoc
2023-12-12 17:32:36 -08:00
Xiang Xiao
ca5a9c711a Remove @ and % tag from all comments
and format the multiple line comments

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-12-11 17:00:10 -03:00
anjiahao
bf03bb557f support gdbstub use serial.
we can use uart to debug nuttx,like debugger:

1. read/write memory
2. Use watchpoint,breakpoint,single step.
    use up_debugpoint api

3. Ctrl+c to stop, continue, or single step.
    hold uart send and receive

4. register a panic event, when crash or assert/panic, we use uart to
   debug.

Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2023-12-11 08:43:26 -08:00
anjiahao
bb0a706bdc arch/arm:add up_debugpoint api
on armv8-m/armv7-m,implement breakpoint & watchpoint using FBP & DWT

Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2023-12-11 08:43:26 -08:00
anjiahao
94d449e722 arch:Mark key functions to prohibit instrumentation to prevent recursive calls
Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2023-12-11 02:06:51 -08:00
anjiahao
d932e0af2a sched/procfs:use instrument to statistics run time max stack
Usage:
1. CONFIG_FS_PROCFS_MAX_STACK_RECORD > 0, such as 32,
2. add '-finstrument-functions' to CFLAGS for What you want to check
   stack.
3. mount porcfs
4. cat /proc/<pid>/stack will print backtace & size

Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2023-12-11 02:06:51 -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
Bowen Wang
449197c188 virtio.h: add virtio_has_feature api for virtio driver
Virtio driver can used this api to judge whether the this feature
is supported by both virtio driver and device.

Signed-off-by: Bowen Wang <wangbowen6@xiaomi.com>
2023-12-10 21:54:56 -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
Petteri Aimonen
99a8c00807 usbdev: Add callback for CONFIG_USBDEV_SOFINTERRUPT
Previously CONFIG_USBDEV_SOFINTERRUPT existed in many platform
drivers but did nothing. This commit adds a callback function
usbdev_sof_irq() that can be used to take action on this interrupt.
2023-12-08 21:27:36 -03:00
Dong Heng
bf54a5ae50 driver/net/lan9250: Add LAN9250 driver(SPI and QSPI mode) 2023-12-07 19:53:05 -08:00
Zhe Weng
bffe858e47 fs/proc: Fix groupfd to get fd by group instead of current tcb
/proc/<pid>/group/fd should read the fds of <pid>, not current tcb.

Signed-off-by: Zhe Weng <wengzhe@xiaomi.com>
2023-12-04 21:37:28 -08:00
Petro Karashchenko
a3cd8f921a arch/arm/samv7/sam_emac: Implement errata workaround for KSZ8061 PHY
Signed-off-by: Petro Karashchenko <petro.karashchenko@gmail.com>
2023-12-04 00:37:43 -08:00
shizhenghui
49398d32aa move userspace interface from video.h to sys/videoio.h
Signed-off-by: shizhenghui <shizhenghui@xiaomi.com>
2023-12-02 19:44:39 -08:00
wangzhaofeng
1967b8432a copy part of linux videodev2.h which is used in v4l2m2m
Signed-off-by: wangzhaofeng <wangzhaofeng@xiaomi.com>
2023-12-02 19:44:39 -08:00
chenrun1
a6dc4412ba misc/rwlock:Implementing read/write locks.
A new locking mechanism: read/write locks
When there is a writer it is not possible to put on a read lock or a write lock; when there is a reader it is possible to reenter the read lock but not the write lock.
Writers are exclusive locks, readers are shared locks.
At the same time through the waiter count to determine whether there is currently a blocked task, if there is then in the unlock time to wake up all the waiter, through the priority of the competition to complete the blocked lock execution.
For example:
When we have a reader blocking two waiter writers, when the reader is unlocked it wakes up both writers. The writer with higher priority wakes up and checks for a successful condition and locks the lock, the second writer wakes up and fails to check for a condition and continues to block the lock.

Signed-off-by: chenrun1 <chenrun1@xiaomi.com>
2023-12-02 19:43:19 -08:00
chenwen@espressif.com
53beaf1a67 xtensa/esp32s3: Add SPIRAM high memory support
1. Configurable mapping of virtual address to psram physical address
  2. Access SPIRAM memory at high physical address through bank switching

Signed-off-by: chenwen@espressif.com <chenwen@espressif.com>
2023-11-29 06:33:51 -08:00
Michal Lenc
eea7db24f3 libc: add support for open_memstream
Adds support for POSIX interface open_memstream() that allows writing
to dynamic memory buffer stream. The stream is dynamically reallocated
as the buffer grows with initial size set to zero.

The caller has to free the buffer after the stream is closed.

The implementation uses fopencookie() for custom stream operations and
callbacks.

Signed-off-by: Michal Lenc <michallenc@seznam.cz>
2023-11-29 02:13:19 -08:00
yaojingwei
a57e3f365a video.c: modify set_buf call seqence in start_capture function.
To avoid losing the first frame, the set_buf needs to excute first. At the same time, imgdata->start_capture should excuted before the imgsensor->start_capture.

Signed-off-by: yaojingwei <yaojingwei@xiaomi.com>
2023-11-29 02:01:34 -08:00
Takumi Ando
3353bd3ced sensors: mx5611: Add support for MS5607
MS5607 has few differences between MS5611.

Signed-off-by: Takumi Ando <t-ando@advaly.co.jp>
2023-11-28 16:48:50 -03:00
Ville Juven
e39ef8563e semaphore/_SEM_XX: Remove the _SEM redirection macros as unnecessary 2023-11-27 04:52:54 -08:00
Ville Juven
5f36a43609 sched/semaphore: Move named semaphores to user space 2023-11-27 04:52:54 -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
Ville Juven
8a2b83c482 mm/kmap: Finalize kmap implementation for RISC-V
After this, RISC-V fully supports the kmap interface.

Due to the current design limitations of having only a single L2 table
per process, the kernel kmap area cannot be mapped via any user page
directory, as they do not contain the page tables to address that range.

So a "kernel address environment" is added, which can do the mapping. The
mapping is reflected to every process as only the root page directory (L1)
is copied to users, which means every change to L2 / L3 tables will be
seen by every user.
2023-11-23 16:38:41 -08:00
hujun5
0c2cfc767d driver/tee: add optee client driver module
The driver's main purpose is to support the porting of the open source
component optee_client (https://github.com/OP-TEE/optee_client) to nttux.

The basic function of the driver module is to convert the REE application layer data and send it to the TEE through rpmsg.

The main functions include
1 driver registration.
we need to register a device driver(/dev/tee0) through optee_register function.
2 open the driver
3 ioctl the driver
The ioctl command passes different parameters and commands, and interacts with the TEE through rpmsg.
4 close the driver

Signed-off-by: hujun5 <hujun5@xiaomi.com>
2023-11-23 06:25:48 -08:00
liaoao
27f672d55a rpmsgblk: bind block inode to ept when create ept
A segmentfault might happen when read/write/unlink ops called without an open
ops called because it bind ept's ops in rpmsgblk_open_handler.

proxy> rm /dev/ram1
segmentfault

proxy> ls /dev/ram1
segmentfault

Signed-off-by: liaoao <liaoao@xiaomi.com>
2023-11-22 08:08:12 -08:00
Ville Juven
57de6484e9 task/pthread_cancelpt: Fix task_delete from another task group
PR #11165 causes an unnecessary regression; task_delete no longer works,
if the deleted task is from another group.

The logic that prevents this comes from:

nxnotify_cancellation() ->
tls_get_info_pid() ->
nxsched_get_stackinfo()

Which checks for permissions, which does not make sense in this case since
it is the kernel asking for the stack information.

Fix this by partially reverting 11165 and implementing a direct path for
the kernel to query for any tasks TLS.
2023-11-22 08:05:58 -08:00
Petteri Aimonen
0648a61668 sigaction: Expand si_user for non-kernel signals
Commit 9244b5a737 added support
for non-standard field si_user that is useful for passing context
pointers to signal handlers.

This commits makes it work for all signals, not just SA_KERNELHAND.
Previously si_user for normal signals was uninitialized garbage.
2023-11-22 08:00:43 -08:00
anjiahao
749655d785 tcbinfo:remove total_num form tcbinfo.
total_num is not required
test:

make -f tools/Makefile.host
cp tools/jlink-nuttx /opt/SEGGER/JLink_V786a/libnuttxplugin.so
JLinkGDBServer -if SWD -speed 5000 -device STM32F429ZI -NoGui 1 -rtos libnuttxplugin

can run normally

Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2023-11-21 21:52:24 -08:00
liaoao
4446b34b2c list: search prev item in reverse order
Signed-off-by: liaoao <liaoao@xiaomi.com>
2023-11-21 07:59:42 -08:00
chenrun1
f12c4fb887 Revert "libc/lib_bzero:Add bzero prototype." 2023-11-21 07:56:52 -08:00