Commit Graph

6398 Commits

Author SHA1 Message Date
dulibo1
7ccdb2cfa8 battery:fix poll return type
Signed-off-by: dulibo1 <dulibo1@xiaomi.com>
2023-07-12 11:06:47 -03:00
fangxinyong
ffa084f3d2 signal: SIGKILL or SIGSTOP cannot be caught
pass ltp signal test cases, for posix spec, SIGKILL and SIGSTOP cannot be caught.

https://pubs.opengroup.org/onlinepubs/9699919799/functions/signal.html
https://pubs.opengroup.org/onlinepubs/007904875/functions/sigset.html

Signed-off-by: fangxinyong <fangxinyong@xiaomi.com>
2023-07-12 21:27:06 +08:00
yinshengkai
9c6f48e57b drivers/segger: add RTT serial support
usage:
  1. Connect Jlink, start JLinkGDBServer
     JLinkGDBServer -if SWD -device stm32h743zi -speed 16000
  2. Listen to the RTT port data and forward it to the virtual serial port
     sudo socat -d -d PTY,link=/dev/ttyRTT0,raw,ignoreeof TCP:127.0.0.1:19021,reuseaddr
  3. Read serial data
     minicom -D /dev/ttyRTT0

Performance:(STM32H743, 400MHZ)
time "dd if=/dev/zero of=/dev/console bs=512 count=2048"
6.67 sec  157KB/s

Signed-off-by: yinshengkai <yinshengkai@xiaomi.com>
2023-07-12 09:54:50 +08:00
Zhe Weng
c253bb91a2 drivers/net: Add wireless ops in upper-half driver
Take the idea from Linux's iw_handler array and esp32c3_wlan's wlan_ops_s, and make it a common logic of upper-half driver.

Signed-off-by: Zhe Weng <wengzhe@xiaomi.com>
2023-07-12 03:32:02 +08:00
guoshichao
c33d1c9c97 sched/task/fork: add fork implementation
1. as we can use fork to implement vfork, so we rename the vfork to
fork, and use the fork method as the base to implement vfork method
2. create the vfork function as a libc function based on fork
function

Signed-off-by: guoshichao <guoshichao@xiaomi.com>
2023-07-12 02:27:37 +08:00
rongyichang
5d7864fbcb drivers/spi: add support for qspi hwfeatures
add QSPI_BITORDER and QSPI_WORD_REVERSE hwfeatures

Signed-off-by: rongyichang <rongyichang@xiaomi.com>
2023-07-12 01:42:25 +08:00
simbit18
9681c52517 Fix nuttx coding style
Remove TABs
Fix indentation
2023-07-11 23:32:17 +08:00
yanghuatao
2529f371ee change clockid_t type from uint8_t to int
make the clock_getres pass the ltp/open_posix_testsuite/clock_getres testcases, posix has no explain about clockid_t type, referrence linux: 858fd168a9/include/linux/types.h (L27) and 858fd168a9/include/uapi/asm-generic/posix_types.h (L96)

Signed-off-by: yanghuatao <yanghuatao@xiaomi.com>
2023-07-11 22:36:23 +08:00
Xiang Xiao
9dc59e9109 Fix error: Mixed case identifier found
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-07-10 23:03:17 +03:00
Xiang Xiao
ebcb03dce9 libc/symtab: Don't include symtab.h in the header files
to unify the inclusion of symtab.h only from the source files

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-07-10 23:03:17 +03:00
Xiang Xiao
229293f9f8 binfmt: Move [elf|nxflat]_[un]initialize to private header file
like what builtin binary format do

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-07-10 23:03:17 +03:00
liuzhao
899471c6bd add support for YT8512 phy 2023-07-11 03:40:53 +08:00
Xiang Xiao
813b652ba5 elf: Move 32/64bit generic mapping from risc-v/arch_elf.c to elfxx.h
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-07-10 13:09:47 -03:00
Xiang Xiao
5849cf71d8 libc/symtab: Move SYMTAB_XXX from unistd/Kconfig to symtab/Kconfig
Make code and config in the same location

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-07-10 13:09:47 -03:00
guoshichao
dc08798764 libs/libc/pthread: add the implementation of pthread_getcpuclockid
1. the implementation can pass the
ltp/open_posix_testsuite/pthread_getcpuclockid testcases
2. the modification are referred to https://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_getcpuclockid.html

Signed-off-by: guoshichao <guoshichao@xiaomi.com>
2023-07-10 13:40:49 +08:00
zhanghongyu
859b96e727 net/ioctl: add some bridge calls command
In order to support the compilation of third-party library, we encounter
some situations where the macro is not defined, refer to the common
implementation of other systems and add relevant definitions.

Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
2023-07-09 12:02:28 +08:00
zhanghongyu
6efeec77e1 net: add netfilter compatible definitions for iptables
In order to support the compilation of third-party library, we encounter
some situations where the macro is not defined, refer to the common
implementation of other systems and add relevant definitions.

Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
2023-07-08 15:29:21 -03:00
zhanghongyu
3538d1b313 netlink: add some definition
In order to support the compilation of third-party library, we encounter
some situations where the macro is not defined, refer to the common
implementation of other systems and add relevant definitions.

Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
2023-07-08 11:12:41 -03:00
zhanghongyu
f917416340 netlink: add statistics-related struct definitions
In order to support the compilation of third-party library, we encounter
some situations where the macro is not defined, refer to the common
implementation of other systems and add relevant definitions.

Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
2023-07-08 11:12:41 -03:00
zhanghongyu
3b186dabe0 net/if.h: add definitions associated with IF_OPER_
In order to support the compilation of third-party library, we encounter
some situations where the macro is not defined, refer to the common
implementation of other systems and add relevant definitions.

Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
2023-07-08 10:59:37 -03:00
zhanghongyu
08b92ef7cf ifaddrs: add union ifa_ifu include ifu_broadaddr and ifu_dstaddr
In order to support the compilation of third-party library, we encounter
some situations where the macro is not defined, refer to the common
implementation of other systems and add relevant definitions.

Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
2023-07-08 15:42:11 +08:00
Petro Karashchenko
b8d3e32bdf sched/clock: move clock_getcpuclockid() and clock_getres() to libc
Signed-off-by: Petro Karashchenko <petro.karashchenko@gmail.com>
2023-07-07 17:39:39 -03:00
Petro Karashchenko
15991ef919 include/nuttx: remove semicolon in _SIG_KILL definition
Signed-off-by: Petro Karashchenko <petro.karashchenko@gmail.com>
2023-07-07 17:39:39 -03:00
Petro Karashchenko
9369b75ee5 includes/nuttx: fix _SCHED_GET(T/P/PP)ID definition issue
Signed-off-by: Petro Karashchenko <petro.karashchenko@gmail.com>
2023-07-07 17:39:39 -03:00
qiaohaijiao1
a5d1d2d4e5 audio: add AUDIOIOC_FLUSH ioctl
Signed-off-by: qiaohaijiao1 <qiaohaijiao1@xiaomi.com>
2023-07-07 23:06:11 +08:00
Gregory Nutt
8868c58720 Fix Deadloop in VFS if CONFIG_CANCELLATION_POINTS is enabled
If cancellation points are enabled, then the following logic is activated in sem_wait().  This causes ECANCELED to be returned every time that sem_wait is called.

    int sem_wait(FAR sem_t *sem)
    {
      ...

      /* sem_wait() is a cancellation point */

      if (enter_cancellation_point())
        {
    #ifdef CONFIG_CANCELLATION_POINTS
          /* If there is a pending cancellation, then do not perform
           * the wait.  Exit now with ECANCELED.
           */

          errcode = ECANCELED;
          goto errout_with_cancelpt;
    #endif
        }
      ...

Normally this works fine.  sem_wait() is the OS API called by the application and will cancel the thread just before it returns to the application.  Since it is cancellation point, it should never be called from within the OS.

There there is is one perverse cases where sem_wait() may be nested within another cancellation point.  If open() is called, it will attempt to lock a VFS data structure and will eventually call nxmutex_lock().  nxmutex_lock() waits on a semaphore:

   int nxmutex_lock(FAR mutex_t *mutex)
   {
     ...

     for (; ; )
       {
         /* Take the semaphore (perhaps waiting) */

         ret = _SEM_WAIT(&mutex->sem);
         if (ret >= 0)
           {
             mutex->holder = _SCHED_GETTID();
             break;
           }

         ret = _SEM_ERRVAL(ret);
         if (ret != -EINTR && ret != -ECANCELED)
           {
             break;
           }
       }
   ...
}

In the FLAT build, _SEM_WAIT expands to sem_wait().  That causes the error in the logic:  It should always expand to nxsem_wait().  That is because sem_wait() is cancellation point and should never be called from with the OS or the C library internally.

The failure occurs because the cancellation point logic in sem_wait() returns -ECANCELED (via _SEM_ERRVAL) because sem_wait() is nested; it needs to return the -ECANCELED error to the outermost cancellation point which is open() in this case.  Returning -ECANCELED then causes an infinite loop to occur in nxmutex_lock().

The correct behavior in this case is to call nxsem_wait() instead of sem_wait().  nxsem_wait() is identical to sem_wait() except that it is not a cancelation point.  It will return -ECANCELED if the thread is canceled, but only once.  So no infinite loop results.

In addition, an nxsem_wait() system call was added to support the call from nxmutex_lock().

This resolves Issue #9695
2023-07-06 14:20:29 -03:00
Xiang Xiao
62480d1a8b boardctl: Add const to struct boardioc_symtab_s::symtab
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-07-06 09:24:02 -03:00
Xiang Xiao
935f43185f libc/modlib: Replace nx_stat with file_stat
to avoid searching the path twice

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-07-06 09:20:24 -03:00
Neale Ferguson
fec789047a Add support for the loading of ET_DYN objects
* libs/libc/machine/arm/armv7-m/arch_elf.c
      - Fix cast of error message parameters

    * build-globals.sh
      - Build the modlib_globals.S file used to resolve symbols when dynamically loading

    * libs/libc/modlib/Make.defs
      - Build modlib_globals.S for all targets

    * libs/libc/modlib/modlib_load.c
      - Calculate sizes and text/data addresses based on program headers rather than section headers
      - Handle objects with no program headers

    * libs/libc/modlib/modlib_bind.c
      - Call modlib_readsym with pointer to symbol table
      - Add modlib_relocatedyn to manage relocation of symbols with shared object (ET_DYN)
      - Differentiate between ET_REL and ET_DYN objects
      - Use arch independent symbol ELF_R_SYM
      - Cast sizes to avoid warnings

    * libs/libc/modlib/modlib_load.c
      - Cast sizes to avoid warnings

    * include/elf.h
      - Add definitions that may be found in shared objects

    * include/nuttx/lib/modlib.h
      - Add parameter to modlib_readsym prototype
      - Add prototypes for:
        - modlib_insertsymtab
        - modlib_findglobal
      - Define Elf_Dyn and Elf_Off according to the elf architecture
      - Add fields to mod_loadifno_s:
        - Program headers
        - Exported symbols
        - Data section address
        - Padding requirement
        - Section index for dynamic symbol table
        - Number of symbols exported
      - Add prottotype for modlib_freesymtab

    * libs/libc/dlfcn/lib_dlclose.c
      - Free the symbol table when the dll is closed

    * libs/libc/dlfcn/lib_dlopen.c
      - Add dump of program headers to debug routine
      - Differentiate between ET_REL and ET_DYN objects

    * libs/libc/machine/arm/armv7-m/arch_elf.c
      - Add handling of R_ARM_RELATIVE and R_ARM_JUMP slot relocation types

    * libs/libc/modlib/modlib_loadshdrs.c
      - Rename modlib_loadshdrs.c to modlib_loadhdrs.c
      - Rename modlib_loadshdrs to modlib_loadhdrs
      - Add code to load program headers

    * libs/libc/modlib/modlib_symbols.c
      - Define entry point structure
      - Add offset parameter to modlib_symname() and use to find symbol names
      - Add symtab section header parameter to modlib_readsym()
      - Add offset parameter to modlib_symvalue() to locate symbol names
      - Add modlib_insertsyntab() to create a symbol table for exporting and resolution
      - Add findEP() to resolve a symbol in the modlib_global table
      - Add modlib_findglobal() to find symbol in the modlib_global table
      - Add modlib_freesymtab() to free the symbol table

    * libs/libc/modlib/modlib_uninit.c
      - Free header and sections from a module_loadinfo_s control block

    * libs/libc/modlib/modlib_verify.c
      - Handle ET_DYN shared objects

    * libs/libc/modlib/modlib_globals.S
      - Multi-target global table
      - Define library APIs that may be resolved when loading a shared object
2023-07-06 09:13:38 -03:00
SPRESENSE
4eb6da33c2 cxd56/alt1250: Change power on sequence
Change the power on sequence according to ALT1250 modem spec.
2023-07-06 13:18:57 +08:00
raiden00pl
206d339b37 arch/arm: add support for ARMv8-M Security Extensions 2023-07-05 11:20:46 -03:00
Xiang Xiao
015e30a866 drivers/net: Remove HAVE_ATOMICS and use CONFIG_HAVE_ATOMICS directly
since OpenAMP never support to compile in c89 only mode

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-07-05 13:43:17 +03:00
fangxinyong
dc7f8f136c signal: correct to const pointer for sigorset and sigandset
the two GNU functions, should use const input pointer parameter.

https://refspecs.linuxfoundation.org/LSB_1.3.0/gLSB/gLSB/baselib-sigorset.html
https://refspecs.linuxfoundation.org/LSB_1.3.0/gLSB/gLSB/baselib-sigandset.html

Signed-off-by: fangxinyong <fangxinyong@xiaomi.com>
2023-07-05 16:26:18 +08:00
guoshichao
bc084a8505 sched/clock/clock_getcpuclockid: add clock_getcpuclockid implementation
1. the implementation can pass the full
ltp/open_posix_testsuite/clock_getcpuclockid testcases
2. the modification are referred to https://pubs.opengroup.org/onlinepubs/9699919799/functions/clock_getcpuclockid.html

Signed-off-by: guoshichao <guoshichao@xiaomi.com>
2023-07-05 00:32:11 +08:00
libei1
63774125d9 arch/sim : Audio driver add AUDIOIOC_GETLATENCY ioctl
add AUDIOIOC_GETLATENCY definition, and add reference code in sim alsa.

Signed-off-by: libei1 <libei1@xiaomi.com>
2023-07-04 13:48:58 +08:00
guoshichao
42f8308423 sched/clock/clock_getres: add two CPUTIME_ID res support
1. make the clock_getres can pass the
ltp/open_posix_testsuite/clock_getres 7-1, 8-1 two cases
2. the modification are referred to https://pubs.opengroup.org/onlinepubs/9699919799/functions/clock_getres.html

Signed-off-by: guoshichao <guoshichao@xiaomi.com>
2023-07-03 23:11:00 +03:00
Nicolas Caramelli
e82b762fb7 input/touchscreen: Translate raw X/Y data into pixel coordinates 2023-07-03 10:17:04 -03:00
Zhe Weng
210c72a651 errno: Adjust help string for EALREADY and ESTALE
EALREADY:
Both Linux(asm-generic/errno.h) and FreeBSD(sys/sys/errno.h) regard it as "Operation already in progress"

ESTALE:
Linux specifically removed the "NFS" description, and we may not only use it for NFS
0ca4343518

The ECANCELED and EOWNERDEAD also use different strings from Linux's header, but their meanings are same, and NuttX's description are more likely to obey POSIX 1003.1-2008, so not changing them.

Signed-off-by: Zhe Weng <wengzhe@xiaomi.com>
2023-07-03 13:38:02 +08:00
Petro Karashchenko
46facd44b3 drivers/net/netdev: improve granularity of 'quota' locking
There is no need to use global spinlock to protect netdev
specific data counters. Allocate per-netdev specific spinlock
to get better locking granularity.

Move C/C++ atomic support checking to compiler.h

Signed-off-by: Petro Karashchenko <petro.karashchenko@gmail.com>
2023-07-01 15:27:09 -03:00
Xiang Xiao
5af99c65de fs: Define __USE_FILE_OFFSET64 when CONFIG_FS_LARGEFILE is enabled
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-06-30 20:22:10 -03:00
guoshichao
d5f45dc33b libs/libc/aio: fix aio_cancel compatible issue
1. make the aio_cancel implementation can pass the
ltp/open_posix_testsuite/aio_cancel testcases
2. the modification are referred to https://pubs.opengroup.org/onlinepubs/9699919799/functions/aio_cancel.html

Signed-off-by: guoshichao <guoshichao@xiaomi.com>
2023-06-29 23:25:33 +08:00
chao an
4de2284614 compiler/fortify: remove unused label prefix and fix build warning
string/lib_memmove.c:39:1: warning: optimization attribute on 'memmove' follows definition but the attribute doesn't match [-Wattributes]
   39 | {
      | ^
In file included from string/lib_memmove.c:27:
nuttx/include/string.h:177:37: note: previous definition of 'memmove' with type 'void *(void *, const void *, size_t)' {aka 'void *(void *, const void *, unsigned int)'}
  177 | fortify_function(memmove) FAR void *memmove(FAR void *dest,
      |                                     ^~~~~~~
string/lib_memset.c:55:1: warning: optimization attribute on 'memset' follows definition but the attribute doesn't match [-Wattributes]
   55 | {
      | ^
In file included from string/lib_memset.c:30:
nuttx/include/string.h:194:36: note: previous definition of 'memset' with type 'void *(void *, int,  size_t)' {aka 'void *(void *, int,  unsigned int)'}
  194 | fortify_function(memset) FAR void *memset(FAR void *s, int c, size_t n)
      |                                    ^~~~~~
CC:  unistd/lib_sysconf.c string/lib_memcpy.c:43:1: warning: optimization attribute on 'memcpy' follows definition but the attribute doesn't match [-Wattributes]
   43 | {
      | ^
In file included from string/lib_memcpy.c:27:
nuttx/include/string.h:186:36: note: previous definition of 'memcpy' with type 'void *(void *, const void *, size_t)' {aka 'void *(void *, const void *, unsigned int)'}
  186 | fortify_function(memcpy) FAR void *memcpy(FAR void *dest,
      |

Signed-off-by: chao an <anchao@xiaomi.com>
2023-06-28 08:47:33 +08:00
raiden00pl
dc608de144 drivers/ioexpander: add support for SX1509
SX1509 from Semtech is GPIO expander with LED driver and keypad engine.
For now, the keypad engine is not supported.
2023-06-27 14:44:00 -03:00
raiden00pl
c63b2d5c91 drivers/userled: add an interface to support LED effects.
LED effects must be implemented in the lower-half of the LED driver.
The interface is designed to supports the following LED effects:
  - intenisty (PWM)
  - Bling (Timer)
  - Fade in, Fade out (Ramp)
2023-06-27 14:44:00 -03:00
Stuart Ianna
8a668fe733 include/sys: Include string.h to silence implicit memset declration.
This change stops the warning "implicit declaration of function 'memset'" when using the `FD_ZERO` macro.
2023-06-27 10:36:13 +03:00
guoshichao
037a6f5836 libs/libc/signal: add killpg function
1. the killpg function can make all the
ltp/open_posix_testsuite/killpg testcaes passed
2. Nuttx do not support process group, so we use kill process instead
3. the implementation are referred to:
https://pubs.opengroup.org/onlinepubs/9699919799/functions/killpg.html

Signed-off-by: guoshichao <guoshichao@xiaomi.com>
2023-06-27 13:26:20 +08:00
Xiang Xiao
7f80b4aeba clock: Move the content of include/nuttx/time.h to include/nuttx/clock.h
and remove include/nuttx/time.h to reduce the nuttx specific header files

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-06-26 19:14:08 +03:00
Xiang Xiao
b5c48f3ed8 binfmt: Always include arch/elf.h in include/nuttx/elf.h
since symbols defined in arch/elf.h is also used in other case, for example:
CC:  pthread/pthread_testcancel.c machine/arm/gnu_unwind_find_exidx.c:32:8: error: unknown type name '__EIT_entry'
   32 | static __EIT_entry *__exidx_start_elf;
      |        ^~~~~~~~~~~

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-06-25 19:02:53 -03:00
guoshichao
3821ad514d libs/libc/unistd: add getpgrp function
1. the getpgrp function can help to pass the ltp/open_posix_teststuite/killpg related testcases
2. Nuttx do not support process group, so we use getpid to implement this
3. the implementation are referred to: https://pubs.opengroup.org/onlinepubs/9699919799/functions/getpgrp.html

Signed-off-by: guoshichao <guoshichao@xiaomi.com>
2023-06-26 01:03:36 +08:00
Filipe Cavalcanti
9603288c80 drivers/sensors/mpu60x0.c: add IOCTL for AFS_SEL, sample rate and FIFO support 2023-06-24 10:57:12 -03:00