Commit Graph

45126 Commits

Author SHA1 Message Date
Ville Juven
a014daf44f RISC-V: Add implementation for vfork 2022-04-25 15:44:32 +08:00
Ville Juven
2580520828 RISC-V: Fix system crash when FPU is in use
FPU registers need to be written prior to updating CSR_STATUS
2022-04-25 15:44:06 +08:00
Xiang Xiao
25d819253b boards/risc-v: Remove "MAXOPTIMIZATION = -Os" from Make.defs
since it is already defined in Toolchain.defs

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-04-25 07:58:00 +03:00
Xiang Xiao
75326e563d boards: Move -fno-common from Make.defs to Toolchain.defs
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-04-25 07:57:29 +03:00
Xiang Xiao
547c85b0ae boards: Switch the elf link script to binfmt/libelf/gnu-elf.ld
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-04-24 17:02:37 +02:00
Xiang Xiao
f4d5a23571 libc/fixedmatch: Avoid "divide by zero" error
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-04-23 20:15:31 +03:00
anjiahao
cbdd39b6c9 tools:fix parsememdump.py match error
Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2022-04-23 23:59:36 +08:00
Petro Karashchenko
8f7af29d74 libs/libc/string: unify implementation across the functions
Signed-off-by: Petro Karashchenko <petro.karashchenko@gmail.com>
2022-04-23 23:58:54 +08:00
wangbowen6
b9827f7ede compiler.h: optimization option is not supported before GCC 4.6
-fno-tree-loop-distribute-patterns is not supported before
GCC 4.6

Signed-off-by: wangbowen6 <wangbowen6@xiaomi.com>
2022-04-23 22:14:26 +08:00
Oki Minabe
185b1cb1b7 libc/string: strcmp/strncmp cast unsigned char
Summary:
- Cast to unsigned char for strcmp and strncmp
- strcmp and strncmp are described following by opengroup.org

  The sign of a non-zero return value shall be determined by the sign
  of the difference between the values of the first pair of bytes
  (both interpreted as type unsigned char) that differ in the strings
  being compared.

  https://pubs.opengroup.org/onlinepubs/9699919799/functions/strcmp.html
  https://pubs.opengroup.org/onlinepubs/9699919799/functions/strncmp.html

Impact:
- strcmp and strncmp return value

Testing:
- ostest on sabre-6quad:smp w/ qemu

Signed-off-by: Oki Minabe <minabe.oki@gmail.com>
2022-04-23 16:11:00 +03:00
Oki Minabe
54508a3798 boards/boardctl: correct boarctl return value
Summary:
- Correct boardctl function's return value
- In case of BOARDIOC_TESTSET, `ret' has 0 or 1 or an error,
  but `ret' is ignored except error.

Impact:
- boardctl return value except errors

Testing:
- custom Cortex-A9 board

Signed-off-by: Oki Minabe <minabe.oki@gmail.com>
2022-04-23 16:25:53 +08:00
Abdelatif Guettouche
3942f4d133 arch/xtensa: No need to save SP in EXCSAVE_1 when linking the interrupt
frame with the previous frame.  The SP is already saved in A12.

Signed-off-by: Abdelatif Guettouche <abdelatif.guettouche@espressif.com>
2022-04-23 10:19:23 +08:00
Abdelatif Guettouche
f130d8c143 xtensa_user_handler.S: Fix backtrace.
Signed-off-by: Abdelatif Guettouche <abdelatif.guettouche@espressif.com>
2022-04-23 10:19:23 +08:00
Abdelatif Guettouche
7a3ad4b224 xtensa_user_handler.S: Use the ps_setup macro when dealing with an
exception.

Signed-off-by: Abdelatif Guettouche <abdelatif.guettouche@espressif.com>
2022-04-23 10:19:23 +08:00
Petro Karashchenko
1b4d8b3734 sched: remove DEBUGASSERT from nx_waitpid
Signed-off-by: Petro Karashchenko <petro.karashchenko@gmail.com>
2022-04-22 15:06:26 -03:00
Xiang Xiao
5a565e753c pm: Move pm_initialize call from driver_initialize to xxx_pminitialize
since it's too late with the below commit:
ommit a594a5d7a8
Author: chao.an <anchao@xiaomi.com>
Date:   Mon Apr 11 19:44:26 2022 +0800

    sched/init: drivers_initialize() should be late than up_initialize()

    up_initialize
    |
     ->up_serialinit
       |
        ->uart_register  /* ("/dev/console", &CONSOLE_DEV); */

    drivers_initialize
    |
     ->syslog_console_init
       |
        ->register_driver /* ("/dev/console", &g_consoleops, 0666, NULL); */

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-04-22 14:36:27 +03:00
Ville Juven
cf90e3f66b syscall: Fix prototype of exec() to syscall.csv 2022-04-22 14:34:42 +03:00
Xiang Xiao
69b5799b74 libc: Fix typo error in execle
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-04-22 12:23:09 +03:00
Xiang Xiao
49eb2bd415 libc: Implement execvp, execlp and execvpe as macro
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-04-22 10:40:31 +03:00
Xiang Xiao
55b5561fdb sched/task: Implement execle and execve
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-04-22 10:40:31 +03:00
Masayuki Ishikawa
04f81ecddb arch: risc-v: Do not enable FPU for K210 with QEMU
Summary:
- I noticed that maix-bit:smp does not work with QEMU.
- Actually, QEMU supports sifive_u (not K210) but it works
  if FPU is disabled.
- This commit fixes this issue.

Impact:
- K210 with QEMU only

Testing:
- Tested with qemu-5.2

Signed-off-by: Masayuki Ishikawa <Masayuki.Ishikawa@jp.sony.com>
2022-04-22 14:52:04 +08:00
Huang Qi
06c7a3ca59 arch/risc-v/riscv_misaligned: Implement float load/store support
Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
2022-04-22 12:23:10 +08:00
Xiang Xiao
2f32c8dcf2 environ: Don't expose get_environ_ptr in csdlib
since it isn't defined in c/c++ standard

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-04-21 22:55:47 +03:00
Xiang Xiao
76803f4a07 sched/environ: Replace get_environ_ptr with environ
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-04-21 22:55:47 +03:00
Xiang Xiao
9794068a9c sched/environ: Remove the unneeded cast in env_dup
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-04-21 22:55:47 +03:00
Xiang Xiao
ce49c80976 sched/task: Correct the comment about environment variable
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-04-21 22:55:47 +03:00
Huang Qi
be95e76910 arch/risc-v: Enable FPU for K210
K210 support rv64gc ISA, now we enable F/D extension for it.

Note: QEMU for K210 don't support FPU now.

Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
2022-04-21 21:47:29 +03:00
chao.an
1c8e12406e compile/opt: add config DEBUG_LINK_MAP
Selecting this option will pass "-Map=$(TOPDIR)$(DELIM)nuttx.map" to ld
when linking NuttX ELF. That file can be useful for verifying
and debugging magic section games, and for seeing which
pieces of code get eliminated with DEBUG_OPT_UNUSED_SECTIONS.

Signed-off-by: chao.an <anchao@xiaomi.com>
2022-04-22 01:37:23 +08:00
chao.an
64d7326ed5 compile/opt: add config DEBUG_OPT_UNUSED_SECTIONS
Enable this option to optimization the unused input sections with the
linker by compiling with " -ffunction-sections -fdata-sections ", and
linking with " --gc-sections ".

Signed-off-by: chao.an <anchao@xiaomi.com>
2022-04-22 01:37:23 +08:00
Abdelatif Guettouche
56ecd44f63 arch/xtensa: Color the other CPUs task when they are created.
Signed-off-by: Abdelatif Guettouche <abdelatif.guettouche@espressif.com>
2022-04-22 01:12:55 +08:00
wangbowen6
913c7148e5 assert: static_assert is not support in c standard C89,C99.
Signed-off-by: wangbowen6 <wangbowen6@xiaomi.com>
2022-04-21 23:11:21 +08:00
Ville Juven
1a7d81c942 binfmt_execmodule: If incoming envp is NULL get parent envp
This keeps backwards compatibility with apps that do not provide
envp. The old implementation passes NULL always and this change fixes
any regression caused by it.
2022-04-21 18:38:37 +08:00
Ville Juven
d6ef4849a9 syscall: Add call gate for get_environ_ptr
Now that the environment strings are stored as an array of strings,
they can be passed from the application via char **environ, which
is really defined as a function call to get_environ_ptr().

This works as is for flat build, but protected mode and kernel mode
require a call gate, which is added here.
2022-04-21 18:38:37 +08:00
Ville Juven
4c1b66246d env_dup: Fix copying of env between address environments
If address environments are in use, it is not possible to simply
memcpy from from one process to another. The current implementation
of env_dup does precisely this and thus, it fails at once when it is
attempted between two user processes.

The solution is to use the kernel's heap as an intermediate buffer.
This is a simple, effective and common way to do a fork().

Obviously this is not needed for kernel processes.
2022-04-21 18:38:37 +08:00
Ville Juven
6b1ee4c2e2 binfmt_execmodule: add errout_with_args exit point
Ensures that when errout_xx is taken, args are freed
2022-04-21 18:38:37 +08:00
Xiang Xiao
1320e5add4 arch/arm: Move the duplicated assembly code to common folder
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-04-21 12:56:34 +03:00
Xiang Xiao
ebf1093cff arch/arm: Switch the context of save and restore from assembler to c
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-04-21 12:56:34 +03:00
Jiuzhu Dong
de1c184e6c boards/sim: support rc.sysinit
Follow: http://glennastory.net/boot/sysinit.html

This is first script that init runs is rc.sysinit. This
script does serval initialization tasks about basic service.

The boot sequence currently provided to the board level is:
board_earlyinitialize->
    board_lateinitialize(Peripherals driver, core driver, ...)->
	run rcS script(mount fs, run service) ->
	    board_appinitialize->

After this patch:
The boot sequence currently provided to the board level is:
board_earlyinitialize->
    board_lateinitialize(core driver,...)->
	run rc.sysinit script(mount fs, run core service) ->
	    board_appinitialize(Peripherals driver)->
		run rcS script(run other service)->

So, Peripheral drivers can do more with the file system and
core services.

Signed-off-by: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>
2022-04-21 12:54:53 +03:00
Xiang Xiao
c29a3b7bd8 pipe: Increase buffer size by one byte to ompensate the full indicator
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-04-21 12:45:30 +03:00
Huang Qi
0332b78f99 arch/risc-v: Don't clear reserved bits in fcsr in riscv_fpuconfig
Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
2022-04-21 15:26:05 +08:00
chao.an
875c5dac75 arm/armv[7|8]m: compare of hardware fp registers should skip REG_FP_RESERVED
Fix fpu test break

Signed-off-by: chao.an <anchao@xiaomi.com>
2022-04-21 14:55:54 +09:00
Abdelatif Guettouche
64e4c9ca02 arch/xtensa: Move xtensa_save_context to up_saveusercontext for
consistency with other archs.

Signed-off-by: Abdelatif Guettouche <abdelatif.guettouche@espressif.com>
2022-04-21 01:59:34 +08:00
Abdelatif Guettouche
0831539af1 arch.h: Fix up_exit prototype.
Signed-off-by: Abdelatif Guettouche <abdelatif.guettouche@espressif.com>
2022-04-21 01:59:34 +08:00
Abdelatif Guettouche
6db910a1aa arch/xtensa: Use syscall interface for xtensa_save/restore_context.
Signed-off-by: Abdelatif Guettouche <abdelatif.guettouche@espressif.com>
2022-04-21 01:59:34 +08:00
chao.an
0315283c21 arch/clang: add support for Clang LTO
add support of Clang's Link Time Optimization (LTO) on NuttX build system

Reference:
https://gcc.gnu.org/onlinedocs/gccint/LTO-Overview.html
https://llvm.org/docs/LinkTimeOptimization.html

Signed-off-by: chao.an <anchao@xiaomi.com>
2022-04-21 01:21:54 +08:00
chao.an
67fbfda974 arch/armv6-m: add support of LLVM Clang
Signed-off-by: chao.an <anchao@xiaomi.com>
2022-04-21 01:21:54 +08:00
Huang Qi
48b81bda09 arch/risc-v: Change riscv_savefpu/riscv_loadfpu to macro
Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
2022-04-20 16:08:17 +03:00
Alin Jerpelea
148c4903e3 LICENSE: document missing libc files
add missing files to the LICENSE file.

Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>
2022-04-20 21:05:45 +08:00
Alin Jerpelea
d32427b56f LICENSE: document missing wireless files
add missing files to the LICENSE file.

Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>
2022-04-20 21:05:45 +08:00
Alin Jerpelea
844a0db1a1 LICENSE: document missing igmp files
add missing files to the LICENSE file.

Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>
2022-04-20 21:05:45 +08:00