Compare commits

..

113 commits

Author SHA1 Message Date
hujun5
aa6265a7fa
Merge 5e23c4a79b into a2d4d74af7 2025-01-12 16:54:09 +08:00
hujun5
a2d4d74af7 clock_timekeeping: remove enter_critical_section in sched/clock/clock_timekeeping.c
reason:
We would like to replace the critical section with a small lock.

Signed-off-by: hujun5 <hujun5@xiaomi.com>
2025-01-12 16:51:40 +08:00
wangmingrong1
2149d89336 macro/align: Use ALIGN_UP and ALIGN_DOWN uniformly
Signed-off-by: wangmingrong1 <wangmingrong1@xiaomi.com>
2025-01-12 16:48:35 +08:00
Yanfeng Liu
71a4e86718 risc-v/Toolchain.defs: guard -r in LDELFFLAGS
This guards use of `-r` in LDELFFLAGS in risc-v common/Toolchain.defs so
that it is only used when BINFMT_ELF_RELOCATABLE is selected.

Signed-off-by: Yanfeng Liu <yfliu2008@qq.com>
2025-01-12 16:47:54 +08:00
Leo Chung
63c8de5f03 sim: Fixes the linker 'noexecstack' warning
Signed-off-by: Leo Chung <gewalalb@gmail.com>
2025-01-12 16:17:52 +08:00
yaojiaqi
43797ea6cc drivers/timers/watchdog: add watchdog timer notifier chain
Add support for watchdog timer notifer chain so that users
can customize the callback function when the watchdog timer
times out which enabled by Auto-monitor

Signed-off-by: yaojiaqi <yaojiaqi@lixiang.com>
2025-01-12 11:15:42 +08:00
wangmingrong1
aa0aecbd80 mempool: addbacktrace should be before kasan_unpoison
If thread 1 is executing kasan_unpoison but a scheduling occurs and the block is trampled upon, the displayed backtracking may still be from the previously allocated backtracking

Signed-off-by: wangmingrong1 <wangmingrong1@xiaomi.com>
2025-01-12 01:29:14 +08:00
rongyichang
39780fdae1 drivers/vhost-rng: fix compile error in vhost-rng.
vhost/vhost-rng.c:154:9: error: too few arguments to function 'virtio_create_virtqueues'
  154 |   ret = vhost_create_virtqueues(hdev, 0, 1, vqnames, callback);

Signed-off-by: rongyichang <rongyichang@xiaomi.com>
2025-01-12 00:06:12 +08:00
rongyichang
ee2f3df2ff drivers/vhost: fix compile error while get vhost status.
vhost/vhost.c: In function 'vhost_status_driver_ok':
vhost/vhost.c:86:20: error: too few arguments to function 'virtio_get_status'
   86 |   uint8_t status = vhost_get_status(hdev);

Signed-off-by: rongyichang <rongyichang@xiaomi.com>
2025-01-12 00:06:12 +08:00
Yanfeng Liu
ff488133c9 qemu-armv7a: allows ELF_EXECUTABLE
This allows using BINFMT_ELF_EXECUTABLE for qemu-armv7a target.

Signed-off-by: Yanfeng Liu <p-liuyanfeng9@xiaomi.com>
2025-01-11 18:54:36 +08:00
Yanfeng Liu
48846954d8 arm/Toolchain.defs: skip -r for ELF_EXECUTABLE
This avoids using `-r` option when linking executable programs.

Signed-off-by: Yanfeng Liu <p-liuyanfeng9@xiaomi.com>
2025-01-11 18:54:36 +08:00
Yanfeng Liu
657247bda8 libc/modlib: preprocess gnu-elf.ld
This generates gnu-elf.ld via preprocessing of gnu-elf.ld.in so
that to reduce board specific app linker scripts in kernel mode
when BINFMT_ELF_EXECUTABLE is enabled.

Signed-off-by: Yanfeng Liu <p-liuyanfeng9@xiaomi.com>
2025-01-11 18:54:36 +08:00
Yanfeng Liu
be40c01ddd nuttx/addrenv.h: revise assembly guard
This allows the header file to be useful from non-C sources such as
assembly code or linker scripts.

Signed-off-by: Yanfeng Liu <p-liuyanfeng9@xiaomi.com>
2025-01-11 18:54:36 +08:00
wangmingrong1
91c71ed00a mm: Add mm_lock_irq, mm_unlock_iq
Signed-off-by: wangmingrong1 <wangmingrong1@xiaomi.com>
2025-01-11 12:28:30 +08:00
wangmingrong1
1d8ce18d7f macro/align: Fix ALIGN_UP and ALIGN_DOWN
Signed-off-by: wangmingrong1 <wangmingrong1@xiaomi.com>
2025-01-11 12:13:10 +08:00
Kyle Wilson
558fe83f6d Add Timer Support to STM32H5 ADC Driver
Added support for using timers with ADCs. Updated Kconfig to support TRGO2, although driver support for TRGO and TRGO2 not developed yet. Updated hardware/stm32_tim.h with missing CCER bits needed for compilation.
2025-01-11 12:04:48 +08:00
wangmingrong1
7c7a64c84c kconfiglib/mark: It should use pip instead of apt install
Signed-off-by: wangmingrong1 <wangmingrong1@xiaomi.com>
2025-01-10 15:27:06 -03:00
Huang Qi
f2a88059e7 tools/nxstyle.c: Add missing zlib function names to white list
The zlib compression functions are used in network utilities
for compression/decompression. These functions need to be added to
the nxstyle white list to prevent style checking errors since they
follow the zlib naming convention rather than NuttX's style guide.

Specifically, these functions are used in:
- apps/netutils/telnetc/telnetc.c for compressed data handling

Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
2025-01-10 15:26:39 -03:00
hujun5
4bd8d9eac7 sched: remove spin_lock_irqsave(NULL) support
Signed-off-by: hujun5 <hujun5@xiaomi.com>
2025-01-10 22:35:14 +08:00
hujun5
69ee240b45 rp2040_pio: remove spin_lock_irqsave(NULL) in arch/arm/src/rp2040/rp2040_pio.c
Signed-off-by: hujun5 <hujun5@xiaomi.com>
2025-01-10 22:35:14 +08:00
wangzhi16
b9837bed08 use small lock to protect g_ram_vectors, involving armv6-m, armv7-m, armv8-m.
Signed-off-by: wangzhi16 <wangzhi16@xiaomi.com>
2025-01-10 21:33:23 +08:00
wangzhi16
d84ba608a1 use small lock in following files:
arch/arm/src/am335x/am335x_can.c
    arch/arm/src/am335x/am335x_gpio.c
    arch/arm/src/am335x/am335x_i2c.c
    arch/arm/src/am335x/am335x_irq.c
    arch/arm/src/am335x/am335x_serial.c
    arch/arm64/src/imx9/imx9_gpio.c
    arch/arm64/src/imx9/imx9_lpi2c.c
    arch/arm64/src/imx9/imx9_lpspi.c
    arch/arm64/src/imx9/imx9_usbdev.c
    arch/x86_64/src/intel64/intel64_tsc_tickless.c

Signed-off-by: wangzhi16 <wangzhi16@xiaomi.com>
2025-01-10 21:32:23 +08:00
Huang Qi
58c95f5d85 armv7-a/Toolchain.defs: Update LLVM arch type to thumbv7a
Changed the LLVM architecture type from thumbv7 to thumbv7a in
Toolchain.defs to better match the ARMv7-A architecture specification.

This change ensures proper code generation and optimization for
Cortex-A series processors when using the Thumb instruction set.

Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
2025-01-10 21:21:26 +08:00
wangzhi16
f179cb81b5 use small lock to protect register about l2cc, involving the following files:
arch/arm/src/armv7-a/arm_l2cc_pl310.c
arch/arm/src/armv7-r/arm_l2cc_pl310.c
arch/arm/src/armv8-r/arm_l2cc_pl310.c

Signed-off-by: wangzhi16 <wangzhi16@xiaomi.com>
2025-01-10 21:20:52 +08:00
Jukka Laitinen
575c608be8 drivers/usbdev/cdcacm.c: Fix a crash in cdcacm if usbdev gets unregistered while client calls close for the tty
Make sure that the cdcacm is disconnected before the usbdev gets unregistered.

Also, check if the device is connected or not in cdcuart_txempty (uart_txempty). Otherwise there may be a crash during uart_tcdrain, called in tty close path, if the usbdev unregistration happens during the loop.

This issue can be triggered by monitoring the cable connection status in one thread, sending BOARDIOC_USBDEV_DISCONNECT if the usb cable is detached. In another thread close the ttyACM.

Signed-off-by: Jukka Laitinen <jukkax@ssrc.tii.ae>
2025-01-10 21:14:55 +08:00
Eren Terzioglu
af6147fb2c esp32[c6]: Fix misconfigured pin functions for esp32c6-devkitm 2025-01-10 21:13:26 +08:00
YAMAMOTO Takashi
b2735751d1 rv-virt:citest64: Bump CONFIG_SYSTEM_POPEN_STACKSIZE
With today's master, according to up_check_tcbstack(),
the thread consumes 2432 bytes with examples/popen.
2025-01-10 21:12:12 +08:00
Huang Qi
6dbdfb3cd5 arch/arm: Add LLVM configuration to CMake
Added LLVM-specific configuration variables to ARM architecture CMake files:
- LLVM_ARCHTYPE for architecture variant (thumbv6m, thumbv7a, etc)
- LLVM_CPUTYPE for CPU target (cortex-m0, cortex-a5, etc)
- LLVM_ABITYPE for ABI (eabi/eabihf)

These changes enable LLVM/Clang toolchain support while maintaining
compatibility with existing GCC configurations. The LLVM variables
are set based on the same architecture/CPU/FPU configurations used
for GCC flags.

Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
2025-01-10 16:58:01 +08:00
Huang Qi
f2934935d0 armv7-a.cmake: Improve FPU options table formatting and readability
Reformatted the FPU options table to use a clearer markdown-style table format
with proper alignment and column headers. Added visual separators (~~~) to make
the table stand out from surrounding code. Improved consistency in column widths
and fixed line wrapping for better readability.

Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
2025-01-10 16:58:01 +08:00
Kyle Wilson
9783c88425 Initial STM32H5 Timers Commit
Used the STM32H7 as a reference.

Removed APB enabling from stm32h5xx_rcc.c. This is done in timer initialization, like STM32H7.

Also removed LPTIM. Will add later.

tim_lowerhalf: Timers 9, 10, and 11 removed. Timers 15,16, and 17 added.

Removed low-power timers from Kconfig. Not implemented yet.

Style Updates

Added stm32_tim_enable and stm32_tim_disable to Timer operations.
2025-01-10 09:40:10 +01:00
wangmingrong1
e5e9032ea0 arm64/vector: Reduce two useless instructions
Signed-off-by: wangmingrong1 <wangmingrong1@xiaomi.com>
2025-01-10 14:59:20 +08:00
wangmingrong1
d22e6d7489 arm64/sctlr: Allows thread to independent control the switch of sctlr
The method is the same as the method of saving the current DAIF state of the thread
It will pave the way for the future implementation of hwasan's memory management
Allows each thread to independently control the mte switch function

Signed-off-by: wangmingrong1 <wangmingrong1@xiaomi.com>
2025-01-10 14:59:20 +08:00
chenzihan1
724797e05c goldfish_sensor_uorb.c: add set_interval for goldfish sensor
Added the ability to set sampling rate for goldfish

Signed-off-by: chenzihan1 <chenzihan1@xiaomi.com>
2025-01-10 04:31:29 +08:00
Eren Terzioglu
8c9162ef8c esp32[c3|c6|h2]: Fix misconfigured gpio issue 2025-01-10 02:13:41 +08:00
Huang Qi
1b8d5a4367 arch/risc-v: Refactor LLVM CPU type handling in Toolchain.cmake
- Replace direct string comparisons with regex pattern matching for ARCHCPUEXTFLAGS
- Change from using LLVM_CPUFLAGS list to setting LLVM_CPUTYPE directly
- Simplify CPU type detection logic while maintaining same functionality
- Use more consistent string variable naming convention

This change makes the CPU type detection more flexible and maintainable
while keeping the same behavior for supported RISC-V configurations.

Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
2025-01-10 02:06:19 +08:00
zhanghongyu
70489fe56b net/tcp_timer: remove tcp_callback(TIMEOUT) when accept conn timeout
when accept conn timeout, only accept conn itself should handle the event
(send TCP_RESET), and there is no need to notify the listening conn.
otherwise, the server's poll will return with POLLERR and POLLHUP.
this may cause some applications to execute incorrect logic in the future.

Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
2025-01-10 02:04:37 +08:00
YAMAMOTO Takashi
a76cdfda47 rv-virt:citest64: bump CONFIG_INIT_STACKSIZE
Fix crashes with "popen" example.

```
dump_tasks:    PID GROUP PRI POLICY   TYPE    NPX STATE   EVENT      SIGMASK          STACKBASE  STACKSIZE      USED   FILLED    COMMAND
dump_tasks:   ----   --- --- -------- ------- --- ------- ---------- ---------------- 0x800525e0      2048      1016    49.6%    irq
dump_task:       0     0   0 FIFO     Kthread -   Ready              0000000000000000 0x80056550      2032      1168    57.4%    Idle_Task
dump_task:       1     0 224 RR       Kthread -   Waiting Semaphore  0000000000000000 0x80057500      1968       768    39.0%    hpwork 0x80051470 0x800514b8
dump_task:       2     0 100 RR       Kthread -   Waiting Semaphore  0000000000000000 0x80057e48      1960       720    36.7%    lpwork 0x80051400 0x80051448
dump_task:       3     3 100 RR       Task    -   Waiting Semaphore  0000000000000000 0x80058ca0      3024      3008    99.4%!   nsh_main
dump_task:       4     4 100 RR       Task    -   Ready              0000000000000000 0x8005a2f0      2000      1376    68.8%    popen
riscv_exception: EXCEPTION: Load access fault. MCAUSE: 0000000000000005, EPC: 000000008000594e, MTVAL: fffffffffffffffc
riscv_exception: PANIC!!! Exception = 0000000000000005
```
2025-01-10 02:01:21 +08:00
hujun5
8fd4bea2ba segger: rm spin_lock_irqsave(NULL) in drivers/segger/config/SEGGER_RTT_Conf.h
Signed-off-by: hujun5 <hujun5@xiaomi.com>
2025-01-09 23:52:55 +08:00
Huang Qi
cfd0cc0d1a Remove duplicate includes across multiple files
This commit cleans up redundant header file includes throughout the codebase.
 The changes include:

 - Removing duplicate #include directives that were present in the same file
 - Consolidating includes that were split across multiple lines unnecessarily
 - Removing unused includes that were no longer needed
 - Fixing some formatting issues with includes

 The changes improve code organization and maintainability by:
 - Reducing unnecessary dependencies
 - Making include dependencies more explicit
 - Following consistent include patterns
 - Removing dead code

 No functional changes are made - this is purely a code cleanup commit.

Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
2025-01-09 23:30:23 +08:00
jerryslhao
bb4eb12fa3 arch/arm/stm32:add stm32g4 spi driver.
Signed-off-by: jerryslhao <jerryslhao@gmail.com>
2025-01-09 09:25:10 +01:00
Huang Qi
a8ba833cde Documentation: Add Rust integration guide for NuttX
Some checks failed
Build Documentation / build-html (push) Has been cancelled
Add a new guide documenting how to integrate Rust with NuttX, including:
- Prerequisites and supported platforms
- Setup instructions for Rust toolchain
- Required NuttX configurations
- Example build and run instructions for RISCV32 target

The guide provides an experimental but working example of running
a Rust application on NuttX using the rv-virt:nsh board.

Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
2025-01-09 15:43:10 +08:00
nuttxs
cb980cc977 arch/esp32s3_partition: Read data from SPI Flash
at designated address (with decryption)
2025-01-09 07:52:40 +08:00
raiden00pl
b3120e535b arch/arm/stm32{|f0l0g0|f7|h5|h7}/i2c: raise compilation error when configuration is invalid
Raise compilation error when I2C configuration is invalid.
It's better to catch invalid clock configuration during compilation instead of
producing binary that doesn't work as expected anyway.

Signed-off-by: raiden00pl <raiden00@railab.me>
2025-01-09 07:49:39 +08:00
wangmingrong1
11d54b34a7 Revert "mm_heap: double malloced memory default alignment (4 -> 8, 8 -> 16)"
This reverts commit 3e971d2e6d.
2025-01-09 00:00:11 +08:00
Huang Qi
00794b92c4 arch/risc-v: Improve LLVM CPU type detection with findstring
Use findstring instead of direct equality checks for LLVM_CPUTYPE
conditions to better handle ARCHCPUEXTFLAGS that may contain additional
ISA extensions. This makes the CPU type detection more robust when
dealing with extended instruction sets while still ensuring the required
base ISA extensions are present.

For example, ARCHCPUEXTFLAGS="imc_zicsr_zifencei" will now correctly
match as sifive-e20 rather than failing the exact match check.

Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
2025-01-08 23:58:19 +08:00
Ville Juven
ae9815a888 riscv_cpustart.c: Change CPU start related traces to sinfo
Like all other platforms do.
2025-01-08 23:57:34 +08:00
YAMAMOTO Takashi
c0eaf12661 esp32s3_wifi_adapter.c: Fix a deadlock
Fixes: https://github.com/apache/nuttx/issues/15314
2025-01-08 23:56:43 +08:00
wangjianyu3
8282ed9ab0 drivers/sensors/gnss: Macro UINT8_MAX for maximum value of uint8_t crefs
libs/libc/gnssutils/minmea/minmea.h:17:#include <stdint.h>

Signed-off-by: wangjianyu3 <wangjianyu3@xiaomi.com>
2025-01-08 22:50:03 +08:00
hujun5
428c2bfb91 Remove duplicate code
Signed-off-by: hujun5 <hujun5@xiaomi.com>
2025-01-08 22:48:12 +08:00
YAMAMOTO Takashi
0b960de1e0 sim:citest: Bump the nsh line length
One of the test scripts tries to send a very long command
(166 characters, [1]), which is immediately truncated by NSH.
I guess it isn't the intention of the test.

[1] 1bcaacd5cc/tools/ci/testrun/script/test_framework/test_cmocka.py (L50-L55)
2025-01-08 21:13:54 +08:00
Huang Qi
40bd8f9ad4 arch/risc-v: Make CPU index handling based on ARCH_RV_CPUID_MAP
This patch refactors the CPU index handling in the RISC-V architecture to be based on the ARCH_RV_CPUID_MAP configuration.

Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
2025-01-08 13:48:00 +02:00
cd83dc1317 CI: Increase CI Jobs to 100% for Complex PRs
This PR increases the CI Jobs for Complex PRs from 50% to 100%, as explained here:
- https://github.com/apache/nuttx/issues/15451#issuecomment-2576576664
2025-01-08 15:05:18 +08:00
jerryslhao
1bcaacd5cc arch/arm/stm32: fix stm32g4 enable pll code.
In the file stm32g474xxxx_rcc.c, the enable PLL
code, according to the intent of the comment,
wants to keep the reserved bit, but the code
clears the reserved bit.

Signed-off-by: jerryslhao <jerryslhao@gmail.com>
2025-01-08 10:41:22 +08:00
hujun5
fabf4a5142 fix compile error
Error: /github/workspace/sources/nuttx/include/nuttx/spinlock_type.h:57:3: error: unknown type name 'atomic_t'
368   57 |   atomic_t owner;
369      |   ^~~~~~~~
370Error: /github/workspace/sources/nuttx/include/nuttx/spinlock_type.h:58:3: error: unknown type name 'atomic_t'
371   58 |   atomic_t next;
372      |   ^~~~~~~~

Signed-off-by: hujun5 <hujun5@xiaomi.com>
2025-01-08 09:28:58 +08:00
hujun5
9d5ecc29d0 Revert "SEGGER_RTT_Conf.h: rm spin_lock_irqsave(NULL) in drivers/segger/config/SEGGER_RTT_Conf.h"
This reverts commit 5e7c640976.

Signed-off-by: hujun5 <hujun5@xiaomi.com>
2025-01-08 09:28:58 +08:00
Tiago Medicci Serrano
154a91c323 Documentation: Update Python documentation for socket module
Some checks failed
Build Documentation / build-html (push) Has been cancelled
Update Python documentation after supporting Python's socket module
to reflect the commands used to run the RISC-V QEMU.
2025-01-08 09:27:25 +08:00
Tiago Medicci Serrano
6469e30671 rv-virt/python: Enable Python's socket module on defconfig
Enables the Python's socket module. This allows applications to be
built to interact with POSIX-compatible sockets.
2025-01-08 09:27:25 +08:00
Daniel P. Carvalho
ba32b61d2e arch/arm/stm32/: Fix I2C driver for STM32G4 devices. 2025-01-07 23:45:59 +08:00
Daniel P. Carvalho
3f3e6dd9b8 arch/arm/stm32/: Added enable/disable to timer low level ops. 2025-01-07 23:32:06 +08:00
YAMAMOTO Takashi
e5ac1c620e sim: Disable chained fixups for sim_macho_init.c
This is a workaround for https://github.com/apache/nuttx/issues/15208

Tested with:
    macOS 15.2
    x86-64
    Xcode 16.2
2025-01-07 23:28:30 +08:00
Zhe Weng
3e62be8361 net: Enable dynamic allocation of tcp/udp/ipfwd buffer by default
Signed-off-by: Zhe Weng <wengzhe@xiaomi.com>
2025-01-07 22:00:21 +08:00
Zhe Weng
50b3ab7671 net/bufpool: Call init automatically on alloc
Note: Initialize function of protocols (tcp, udp, pkt, etc.) are kept empty.

Signed-off-by: Zhe Weng <wengzhe@xiaomi.com>
2025-01-07 22:00:21 +08:00
Zhe Weng
f702f1705f net/bufpool: Use SEM_INITIALIZER to init sem
Signed-off-by: Zhe Weng <wengzhe@xiaomi.com>
2025-01-07 22:00:21 +08:00
Filipe Cavalcanti
407a62a33a boards/xtensa: update Make.defs for linker scripts on ESP32|S2 2025-01-07 21:58:09 +08:00
Filipe Cavalcanti
91511ae280 boards/xtensa: merge MCUBoot and Simple Boot linker scripts on ESP32|S2 2025-01-07 21:58:09 +08:00
zhangshoukui
aef24f5f3c rename lib_pathbuffer to lib_tempbuffer
Signed-off-by: zhangshoukui <zhangshoukui@xiaomi.com>
2025-01-07 21:54:33 +08:00
rongyichang
553406e801 drivers/video: add BRGA8888 support for goldfish gpu fb
Some checks are pending
Build Documentation / build-html (push) Waiting to run
Signed-off-by: rongyichang <rongyichang@xiaomi.com>
2025-01-07 21:47:56 +08:00
Gao Feng
f64a48f4e5 cxx: size and un-size functions should be defined in one file
fix error when "-Werror=sized-deallocation" is enabled.

refer to https://timsong-cpp.github.io/cppwp/n4861/new.delete,
displace the default versions defined by the C++ standard library.
2025-01-07 21:45:59 +08:00
wangmingrong1
c5655d5a11 arm64/tbi: Unified TBI flags for MTE and software kasan
The TCMA flag is not critical, it will be set separately in "arm64_mte.c"

Signed-off-by: wangmingrong1 <wangmingrong1@xiaomi.com>
2025-01-07 21:44:18 +08:00
Jani Paalijarvi
dd4ee256c3 arch/risc-v/src/mpfs/mpfs_ethernet.c: Set correct return value
Return error in case of mpfs_i2cbus_initialize() failure.

Signed-off-by: Jani Paalijarvi <jani.paalijarvi@unikie.com>
2025-01-07 21:42:00 +08:00
Jani Paalijarvi
e1fb0b30c4 drivers/net/ksz9477.c: Check return values in init
Check that writes to configuration registers success.

Signed-off-by: Jani Paalijarvi <jani.paalijarvi@unikie.com>
2025-01-07 21:42:00 +08:00
simbit18
0641e6f287 [DOC] implementation/simulation.rst: Removed the execute permissions. 2025-01-07 21:40:40 +08:00
simbit18
aaef87e5b6 Fix Kconfig style
Remove spaces from Kconfig files
Add TABs
2025-01-07 21:39:50 +08:00
wangjianyu3
350f396aa5 drivers/sensors/gnss: Fix integer overflow error
CID 1309501: (#1 of 1): Overflow constant (INTEGER_OVERFLOW)
overflow_const: Expression upper->crefs, which is equal to 255, where enable ? 1 : -1 is known to be equal to -1, overflows the type that receives it, an unsigned integer 8 bits wide.

Signed-off-by: wangjianyu3 <wangjianyu3@xiaomi.com>
2025-01-07 21:38:17 +08:00
buxiasen
7e0e4dea75 arm/irq.h: fix ARCH_ARM7TDMI missing up_getusrsp after move to irq.h
Causing c5471evm/httpd ci break.

Signed-off-by: buxiasen <buxiasen@xiaomi.com>
2025-01-07 14:29:32 +08:00
Gao Feng
55da7d89b5 xtensa/esp32s3: porting of spi_flash_chip_generic_write_encrypted from ESP-IDF 2025-01-07 12:18:43 +08:00
Kyle Wilson
4bd2c0443b Preliminary add of fdcan source files.
Some checks are pending
Build Documentation / build-html (push) Waiting to run
Adding source files to the fdcan branch based on identical register set. These files should mostly just work.

Removed references to FDCAN3. H5 only has 2 FDCAN interfaces.

Add basic FDCAN Kconfig

FDCAN Kconfig options

Added various options for FDCAN mode, FDCAN bitrate, clock selection and division, and timing.

Added bit timing config options (nominal and data). Added stm32h56xxx pin mappings.

Fixed Data Bit Timing. Pulled in STM32H5_FDCAN_PDIV_VALUE. Added stm32_fdcan.c to Make.defs. Added DBITRATE to Kconfig

Clock source changes to FDCAN

Moved the setting of the clock source to the stm32h5xx_rcc.c file. Added notes to stm32_fdcan.c that STM32_FDCAN_FREQUENCY and STM32_FDCAN_PDIV should be set in board.h

Change STM32H5_FDCAN_PDIV to STM32_FDCAN_PDIV

Updated Kconfig to match G4 implementation. Removed stm32_fdcan_sock for now.

Removed FDCAN3 from stm32_fdcan.h

incomplete changes for bit timning

Set NBRP and DBRP registers based on STM32H7 FDCAN socket algorithm.

Added board file for initializing 1 can device. Will update later to initialize second device.

Fixed ifdefs. Changed STM32 to STM32H5.

Add some can testing changes.

Added option to configure bit timing, with automatic bit timing set as default.

Style fixes

Fixed FDCAN2 and memory access issues

FDCAN2 msgram offset was wrong by 1 word (4 bytes). I removed the + 4 at the end of the definition. This fixed the issues with fdcan2. Also changed ifdefs when setting ESI, FDF, and BRS bits. When CAN FD was used, this resulted in the first command after the endif (the setting of dest at line 2325) being skipped because it was included in the else block when it shouldn't have. This resulted in exceptions. Adjust ifdefs fixes this problem. Other minor fixes.

Restoring board files to upstream versions. These files will be pulled in later in a separate pull request. stm32h5_fdcan_test branch created for this.

Fixed Queue Mode Transmit

The can driver checks the TFFL bits in the TXFQS register. In Queue mode, this always returns 0. As a result, fdcan_txempty was always returning false, which resulted in no transmissions. This code fixes that.

Add stm32h5 fdcan chardriver to Make.defs
2025-01-07 01:05:23 +08:00
Eren Terzioglu
6eabe35a60 esp32[h2]: Fix esp32h2 get mac address issue 2025-01-07 01:03:44 +08:00
Eren Terzioglu
5e2fc181c2 tools/Unix.mk: Add host_info target to print nxdiag output
Nxdiag examples scripts  modified to print system information
without building and flashing nxdiag application to get report
about system without reflash or reconfigure.
2025-01-07 01:03:44 +08:00
hujun5
57e54b399b sched: remove all spin_lock_irqsave(NULL)
Signed-off-by: hujun5 <hujun5@xiaomi.com>
2025-01-06 23:11:44 +08:00
hujun5
4e563e3a86 SEGGER_RTT_Conf.h: rm spin_lock_irqsave(NULL) in drivers/segger/config/SEGGER_RTT_Conf.h
Signed-off-by: hujun5 <hujun5@xiaomi.com>
2025-01-06 23:07:58 +08:00
hujun5
62566734a4 rp23xx_pio.c: rm spin_lock_irqsave(NULL) in arch/arm/src/rp23xx/rp23xx_pio.c
Signed-off-by: hujun5 <hujun5@xiaomi.com>
2025-01-06 23:07:58 +08:00
hujun5
57ca4e1789 up_rtc_gettime: add spinlock to protect up_rtc_gettime
reason:
We have removed the critical section protection
for the up_rtc_gettime function in common code.

Signed-off-by: hujun5 <hujun5@xiaomi.com>
2025-01-06 23:07:58 +08:00
buxiasen
89455bc9a1 arch: up_getusrsp change to inline and implement in irq.h
Signed-off-by: buxiasen <buxiasen@xiaomi.com>
2025-01-06 23:03:05 +08:00
buxiasen
1358942132 arch/tricore: move tricore_csa2addr from internal.h to arch.h
Make up_getusrsp possible move to irq as depends on tricore_csa2addr

Signed-off-by: buxiasen <buxiasen@xiaomi.com>
2025-01-06 23:03:05 +08:00
buxiasen
7a0ea108f6 arch/arm-m: add api getpsp, for exception direct case
For exception_direct causing unwind to read NULL and breaks thread backtrace.

Signed-off-by: buxiasen <buxiasen@xiaomi.com>
2025-01-06 23:03:05 +08:00
buxiasen
9bdcc4dc4b arch/irq.h: update all inline to inline_function
Inline & inline_function both used make confuze, let's modify all inline
in irq.h to inline_function, also clear the always_inline_funcion
declaration.

Signed-off-by: buxiasen <buxiasen@xiaomi.com>
2025-01-06 23:03:05 +08:00
Kevin Zhou
1bc2e1a175 xtensa/esp32s3: set cpuint to initial value after deallocate 2025-01-06 22:57:14 +08:00
Yanfeng Liu
ae26129e6e stm32ldiscovery/chrono: add CONFIG_SLCD
This is to unblock CI check,
https://github.com/apache/nuttx/actions/runs/12628628318/job/35185115826

following suggestion per:
https://github.com/apache/nuttx/pull/15423#pullrequestreview-2530760373

Signed-off-by: Yanfeng Liu <p-liuyanfeng9@xiaomi.com>
2025-01-06 22:11:54 +08:00
Yanfeng Liu
5f1a2696b3 board/qemu-armv7a: add board_power_off
This allows to power off qemu-armv7a target via NSH `quit` command.

Signed-off-by: Yanfeng Liu <p-liuyanfeng9@xiaomi.com>
2025-01-06 22:11:54 +08:00
Ritvik
3e6649856b Fix Overlap Handling in sim_copyfullstate to Prevent Undefined Behavior 2025-01-06 08:19:04 +08:00
hujun5
4d63921f0a use atomic operation for g_system_ticks
Signed-off-by: hujun5 <hujun5@xiaomi.com>
2025-01-05 12:01:16 +08:00
wangzhi16
bbaf1ff9fd use small lock in following files:
arch/arm64/src/a64/a64_twi.c
arch/arm64/src/imx9/imx9_gpioirq.c
arch/arm64/src/imx9/imx9_lpi2c.c
arch/arm64/src/imx9/imx9_usbdev.c
arch/arm64/src/imx9/imx9_usdhc.c

Signed-off-by: wangzhi16 <wangzhi16@xiaomi.com>
2025-01-04 22:43:20 -03:00
Tiago Medicci Serrano
7c24ef438e risc-v/qemu-rv: Initialize the userleds without late initialization
If CONFIG_BOARD_LATE_INITIALIZE is not selected, the userleds will
not be initialized. The userled initialization is not required to
be done within board_late_initialize(), thus this commit enables
initializing it in board_app_initialize() too.
2025-01-04 01:30:41 +08:00
wangmingrong1
2c5d849e01 gcov.py: Supports parsing multiple sets of gcov outputs at the same time and merging the results
Use the "-a" parameter to pass in gcda files exported by multiple devices

Signed-off-by: wangmingrong1 <wangmingrong1@xiaomi.com>
2025-01-03 21:15:28 +08:00
wangmingrong1
66e074ed97 gcov: add reboot gcov storage coverage info
Signed-off-by: wangmingrong1 <wangmingrong1@xiaomi.com>
2025-01-03 21:15:04 +08:00
cuiziwei
781c27a98e sim/oneshot: Remove redundant variables.
Signed-off-by: cuiziwei <cuiziwei@xiaomi.com>
2025-01-03 21:12:41 +08:00
wangjianyu3
6020cdb816 esp32s3-devkit/adb: ADB shell service depends on SCHED_CHILD_STATUS
Log

  $ adb -s 1234 shell
  error: closed

  # BULK out
  0000   4f 50 45 4e cb 71 06 00 00 00 00 00 07 00 00 00   OPEN.q..........
  0010   52 02 00 00 b0 af ba b1                           R.......

  # BULK out
  0000   73 68 65 6c 6c 3a 00                              shell:.

  # BULK in
  0000   43 4c 53 45 00 00 00 00 cb 71 06 00 00 00 00 00   CLSE.....q......
  0010   00 00 00 00 bc b3 ac ba                           ........

Signed-off-by: wangjianyu3 <wangjianyu3@xiaomi.com>
2025-01-03 21:12:20 +08:00
p-szafonimateusz
f0137d51a3 drivers/serial: simplify 16550_PCI_UARTx_CLOCK config
drivers/serial: simplify 16550_PCI_UARTx_CLOCK config

Signed-off-by: p-szafonimateusz <p-szafonimateusz@xiaomi.com>
2025-01-03 08:52:43 +08:00
p-szafonimateusz
9f93621b90 libs/libc/gdbstub/lib_gdbstub.c: fix warning
libs/libc/gdbstub/lib_gdbstub.c: fix warning

Signed-off-by: p-szafonimateusz <p-szafonimateusz@xiaomi.com>
2025-01-03 08:52:32 +08:00
p-szafonimateusz
6f9d0c97d2 libs/libc/gdbstub/lib_gdbstub.c: fix format for trap response
fix gdb crash after a few step breakpoints because trap is not correctly reported

Signed-off-by: p-szafonimateusz <p-szafonimateusz@xiaomi.com>
2025-01-03 08:52:32 +08:00
Tiago Medicci Serrano
6b1be7c66c virtio-rng: Register /dev/urandom driver if CONFIG_DEV_URANDOM=y
Virtio RNG support (CONFIG_DRIVERS_VIRTIO_RNG=y) selects
CONFIG_ARCH_HAVE_RNG. On the other hand, if CONFIG_DEV_URANDOM=y,
it defaults to CONFIG_DEV_URANDOM_ARCH if CONFIG_ARCH_HAVE_RNG=y.
DEV_URANDOM_ARCH definition states that the implementation of the
/dev/urandom should be provided by the architecture-specifig logic,
including the function devurandom_register(). In this case, the
/dev/urandom may refer to the same driver as /dev/random that is
provided by the Virtio RNG driver, which is implemented by this
commit.
2025-01-03 08:52:20 +08:00
wangzhi16
893c5e92c2 Reduce the size of tcb by four bytes.
Signed-off-by: wangzhi16 <wangzhi16@xiaomi.com>
2025-01-02 23:18:42 +08:00
Zhe Weng
3b26c6df51 net/udp: Let cansend return EWOULDBLOCK when send buffer is full
Notes:
1. This commit do the same thing as TCP did: https://github.com/apache/nuttx/pull/10627
2. UDP uses `iob_navail(false)` but TCP uses `iob_navail(true)`, this is because of a problem related to TCP recv window (https://github.com/apache/nuttx/pull/4142), so we don't need to change UDP now.

Signed-off-by: Zhe Weng <wengzhe@xiaomi.com>
2025-01-02 23:13:39 +08:00
Yanfeng Liu
6fb12b0284 arch/qemu-armv7a: kernel mode cmake support
This allows to build kernel mode NuttX with cmake.

Signed-off-by: Yanfeng Liu <p-liuyanfeng9@xiaomi.com>
2025-01-02 23:13:07 +08:00
Filipe Cavalcanti
75aa80dba8 arch/xtensa: enable SPIRAM test during boot of ESP32|S3 2025-01-02 23:12:39 +08:00
p-szafonimateusz
eeef185558 arch/x86_64/include/intel64/irq.h: align definitions
align all definitions in intel64/irq.h

Signed-off-by: p-szafonimateusz <p-szafonimateusz@xiaomi.com>
2025-01-02 23:11:38 +08:00
p-szafonimateusz
cfaeb74dd3 arch/intel64: allow to attach handlers to ISR
arch/intel64: allow to attach handlers to ISR

Signed-off-by: p-szafonimateusz <p-szafonimateusz@xiaomi.com>
2025-01-02 23:10:14 +08:00
chenrun1
6f4f50e2fe v9fs/client.c:Use int ret as the return value to avoid uint32_t not supporting negative values
Summary:
 iModify the return variable in the v9fs_client_walk

Signed-off-by: chenrun1 <chenrun1@xiaomi.com>
2025-01-02 22:34:35 +08:00
chenrun1
1f540a93d2 v9fs/client.c:add check response.nwqid == nwname
Summary:
  There are differences in different server implementations, so it is necessary to check whether the returned nwqid satisfies the requested number.

Signed-off-by: chenrun1 <chenrun1@xiaomi.com>
2025-01-02 22:34:35 +08:00
chenrun1
2ac2d5d511 v9fs/client.c:fix struct attach wrong parameter size
Summary:
  Change uint16_t afid -> uint32_t afid in struct v9fs_attach_s
  See: https://github.com/chaos/diod/blob/master/protocol.md

Signed-off-by: chenrun1 <chenrun1@xiaomi.com>
2025-01-02 22:34:35 +08:00
chenrun1
928656f3cb v9fs/client.c:count should be assigned a value before being used
Summary:
  move request.count = buflen > fidp->iounit ? fidp->iounit : buflen
before request.header.size

Signed-off-by: chenrun1 <chenrun1@xiaomi.com>
2025-01-02 22:34:35 +08:00
liwenxiang1
1fad0f1654 arch/x86_64: this_task is stored in the CPU private data
By default in SMP, obtaining this_task requires disabling interrupts, obtaining the current CPU index, accessing a global variable, and re-enabling interrupts. Storing this_task in percpu makes retrieval faster.

Signed-off-by: liwenxiang1 <liwenxiang1@xiaomi.com>
2025-01-02 15:19:25 +08:00
561 changed files with 16171 additions and 3247 deletions

View file

@ -173,21 +173,14 @@ jobs:
# If Not a Simple PR: Build all targets
if [[ "$quit" == "1" ]]; then
# If PR was Created or Modified: Exclude some boards
# If PR was Created or Modified: Include all boards
pr=${{github.event.pull_request.number}}
if [[ "$pr" != "" ]]; then
echo "Excluding arm-0[1249], arm-1[124-9], risc-v-04..06, sim-03, xtensa-02"
echo "Include all boards"
boards=$(
echo '${{ inputs.boards }}' |
jq --compact-output \
'map(
select(
test("arm-0[1249]") == false and test("arm-1[124-9]") == false and
test("risc-v-0[4-9]") == false and
test("sim-0[3-9]") == false and
test("xtensa-0[2-9]") == false
)
)'
'.'
)
fi
echo "selected_builds=$boards" | tee -a $GITHUB_OUTPUT

View file

@ -87,7 +87,7 @@ find_program(KCONFIGLIB olddefconfig)
if(NOT KCONFIGLIB)
message(
FATAL_ERROR "Kconfig environment depends on kconfiglib, Please install:
$ sudo apt install python3-kconfiglib")
$ sudo pip3 install kconfiglib")
endif()
# BOARD CONFIG can be set to directory path, or <board-name>[/:]<config-name>
@ -727,6 +727,7 @@ else()
OUTPUT nuttx.rel
COMMAND
${CMAKE_C_COMPILER} ARGS -r $<$<BOOL:${CONFIG_SIM_M32}>:-m32>
$<$<BOOL:${CONFIG_HOST_LINUX}>:-Wl,-z,noexecstack>
$<TARGET_OBJECTS:sim_head> $<$<NOT:$<BOOL:${APPLE}>>:-Wl,--start-group>
${nuttx_libs_paths} $<$<NOT:$<BOOL:${APPLE}>>:-Wl,--end-group> -o
nuttx.rel

View file

@ -38,13 +38,35 @@ This will generate a ``nutxx`` binary. This file can be run using the RISC-V QEM
Try Python in NSH
=================
Before running the RISC-V QEMU, create a raw disk image with the following command:
.. code:: console
$ .qemu-system-riscv32 -semihosting -M virt,aclint=on -cpu rv32 -smp 1 -bios none -kernel nuttx -nographic
$ dd if=/dev/zero of=./mydisk-1gb.img bs=1M count=1024
Then, run RISC-V QEMU with the following command:
.. code:: console
$ qemu-system-riscv32 -semihosting -M virt,aclint=on -cpu rv32 -smp 8 \
-global virtio-mmio.force-legacy=false \
-device virtio-serial-device,bus=virtio-mmio-bus.0 \
-chardev socket,telnet=on,host=127.0.0.1,port=3450,server=on,wait=off,id=foo \
-device virtconsole,chardev=foo \
-device virtio-rng-device,bus=virtio-mmio-bus.1 \
-netdev user,id=u1,hostfwd=tcp:127.0.0.1:10023-10.0.2.15:23,hostfwd=tcp:127.0.0.1:15001-10.0.2.15:5001 \
-device virtio-net-device,netdev=u1,bus=virtio-mmio-bus.2 \
-drive file=./mydisk-1gb.img,if=none,format=raw,id=hd \
-device virtio-blk-device,bus=virtio-mmio-bus.3,drive=hd \
-bios none -kernel ./nuttx -nographic
ABC[ 0.062131] board_userled: LED 1 set to 0
[ 0.063269] board_userled: LED 2 set to 0
[ 0.063367] board_userled: LED 3 set to 0
telnetd [4:100]
ABC
NuttShell (NSH) NuttX-10.4.0
nsh> mount_modules
nsh> python_mount_modules
Mounting ROMFS filesystem at target=/usr/local/lib/ with source=/dev/ram1
nsh> export PYTHONHOME /usr/local
nsh> export PYTHON_BASIC_REPL 1
@ -58,5 +80,5 @@ Demo
Check the following `asciinema <https://asciinema.org/>`_ demo to see how to run Python on NuttX. You can copy and paste the commands from the demo to try it yourself.
.. image:: https://asciinema.org/a/orkD8fKuahMEgQfBak9abliE4.svg
:target: https://asciinema.org/a/orkD8fKuahMEgQfBak9abliE4
.. image:: https://asciinema.org/a/bYYy1fyIOQ3hOY4lJ7L3WFcNb.svg
:target: https://asciinema.org/a/bYYy1fyIOQ3hOY4lJ7L3WFcNb

View file

@ -7,9 +7,12 @@ It also can be used to run a tests to verify that the vendor's tools are properl
Its primary purpose is to gather information that can be used to debug problems and ease the process of reporting bugs for uninexperienced users.
This tool uses a Python script (``apps/tools/host_sysinfo.py``) to gather information about the host system during build and a C
This tool uses a Python script (``nuttx/tools/host_info_dump.py``) to gather information about the host system during build and a C
program to gather information about the NuttX system and display all available information. For more information about the python
script, check the command line options and code comments of ``host_sysinfo.py``.
script, check the command line options and code comments of ``host_info_dump.py``.
Alternatively, ``host_info`` target can be used without enabling nxdiag application and reflashing to get information about system.
Target can work after configuration step and prints information about the NuttX and host systems.
.. note:: Nxdiag requires Python 3.6 or later. On Linux distributions, the ``distro`` Python module is
recommended as it provides more accurate information about the host system.

View file

@ -69,4 +69,5 @@ Guides
ram_rom_disks.rst
reading_can_msgs.rst
remove_device_drivers_nsh.rst
rust.rst

View file

@ -0,0 +1,90 @@
===============
Rust in NuttX
===============
.. warning::
This guide is under development. Rust support in NuttX is experimental.
Introduction
============
NuttX is exploring Rust integration to provide memory safety guarantees and modern
language features while maintaining its small footprint and real-time capabilities.
This guide covers:
- Setting up Rust toolchain for NuttX development
- Building Rust components with NuttX
- Interoperability between Rust and C
- Testing Rust components
Prerequisites
=============
- Rust toolchain installed (rustup recommended)
- NuttX build environment configured
- Basic knowledge of Rust and NuttX development
Supported Platforms
===================
- AArch64 (WIP)
- ARMv7-A (WIP)
- ARMv6-M
- ARMv7-M
- ARMv8-M
- RISCV32
- RISCV64
Getting Started
===============
1. Install Rust toolchain and switch to nightly
Please refer to the official Rust installation guide for more details: https://www.rust-lang.org/tools/install
.. code-block:: bash
rustup toolchain install nightly
rustup default nightly
2. Prepare NuttX build environment
Please ensure that you have a working NuttX build environment, and with the following PR merged or cherry-picked:
- https://github.com/apache/nuttx-apps/pull/2487
- https://github.com/apache/nuttx/pull/15469
3. Enable essential kernel configurations
Pleae enable the following configurations in your NuttX configuration:
- CONFIG_SYSTEM_TIME64
- CONFIG_FS_LARGEFILE
- CONFIG_TLS_NELEM = 16
- CONFIG_DEV_URANDOM
The `rv-virt:nsh` board using make as the build system is recommended for testing Rust applications as it has been verified to work with this configuration.
For `rv-virt:nsh` board, you should disable `CONFIG_ARCH_FPU` configuration since RISCV32 with FPU is not supported yet.
4. Enable sample application
Please enable the sample application in your NuttX configuration:
- CONFIG_EXAMPLES_HELLO_RUST_CARGO
5. Build and run the sample application
Build the NuttX image and run it on your target platform:
.. code-block:: bash
qemu-system-riscv32 -semihosting -M virt,aclint=on -cpu rv32 -smp 8 -bios nuttx/nuttx -nographic
NuttShell (NSH) NuttX-12.8.0
nsh> hello_rust_cargo
{"name":"John","age":30}
{"name":"Jane","age":25}
Deserialized: Alice is 28 years old
Pretty JSON:
{
"name": "Alice",
"age": 28
}
Hello world from tokio!
Congratulations! You have successfully built and run a Rust application on NuttX.

0
Documentation/implementation/simulation.rst Executable file → Normal file
View file

View file

@ -361,7 +361,7 @@ This configuration is used for 32-bit RISC-V
python
------
Enables the Python interpreter for NuttX. This configuration is based on `nsh`_.
Enables the Python interpreter for NuttX. This configuration is based on `netnsh`_.
For more information on how to build and run Python on NuttX,
please refer to the :doc:`Python Interpreter </applications/interpreters/python/index>` page.

View file

@ -177,7 +177,7 @@ extern volatile bool g_interrupt_context[CONFIG_SMP_NCPUS];
/* Save the current interrupt enable state & disable IRQs. */
static inline irqstate_t up_irq_save(void)
static inline_function irqstate_t up_irq_save(void)
{
unsigned int flags;
unsigned int temp;
@ -194,7 +194,7 @@ static inline irqstate_t up_irq_save(void)
/* Restore saved IRQ & FIQ state */
static inline void up_irq_restore(irqstate_t flags)
static inline_function void up_irq_restore(irqstate_t flags)
{
__asm__ __volatile__
(
@ -206,7 +206,7 @@ static inline void up_irq_restore(irqstate_t flags)
/* Enable IRQs and return the previous IRQ state */
static inline irqstate_t up_irq_enable(void)
static inline_function irqstate_t up_irq_enable(void)
{
unsigned int flags;
unsigned int temp;
@ -256,6 +256,25 @@ static inline_function void up_set_interrupt_context(bool flag)
#endif
}
static inline_function uint32_t up_getsp(void)
{
register uint32_t sp;
__asm__ __volatile__
(
"mov %0, sp\n"
: "=r" (sp)
);
return sp;
}
static inline_function uintptr_t up_getusrsp(void *regs)
{
uint32_t *ptr = (uint32_t *)regs;
return ptr[REG_SP];
}
/****************************************************************************
* Public Function Prototypes
****************************************************************************/

View file

@ -209,8 +209,7 @@ struct xcptcontext
/* Get/set the PRIMASK register */
static inline uint8_t getprimask(void) always_inline_function;
static inline uint8_t getprimask(void)
static always_inline_function uint8_t getprimask(void)
{
uint32_t primask;
__asm__ __volatile__
@ -223,8 +222,7 @@ static inline uint8_t getprimask(void)
return (uint8_t)primask;
}
static inline void setprimask(uint32_t primask) always_inline_function;
static inline void setprimask(uint32_t primask)
static always_inline_function void setprimask(uint32_t primask)
{
__asm__ __volatile__
(
@ -236,16 +234,14 @@ static inline void setprimask(uint32_t primask)
/* Disable IRQs */
static inline void up_irq_disable(void) always_inline_function;
static inline void up_irq_disable(void)
static always_inline_function void up_irq_disable(void)
{
__asm__ __volatile__ ("\tcpsid i\n");
}
/* Save the current primask state & disable IRQs */
static inline irqstate_t up_irq_save(void) always_inline_function;
static inline irqstate_t up_irq_save(void)
static always_inline_function irqstate_t up_irq_save(void)
{
unsigned short primask;
@ -266,16 +262,14 @@ static inline irqstate_t up_irq_save(void)
/* Enable IRQs */
static inline void up_irq_enable(void) always_inline_function;
static inline void up_irq_enable(void)
static always_inline_function void up_irq_enable(void)
{
__asm__ __volatile__ ("\tcpsie i\n");
}
/* Restore saved primask state */
static inline void up_irq_restore(irqstate_t flags) always_inline_function;
static inline void up_irq_restore(irqstate_t flags)
static always_inline_function void up_irq_restore(irqstate_t flags)
{
/* If bit 0 of the primask is 0, then we need to restore
* interrupts.
@ -291,8 +285,7 @@ static inline void up_irq_restore(irqstate_t flags)
/* Get/set IPSR */
static inline uint32_t getipsr(void) always_inline_function;
static inline uint32_t getipsr(void)
static always_inline_function uint32_t getipsr(void)
{
uint32_t ipsr;
__asm__ __volatile__
@ -307,8 +300,7 @@ static inline uint32_t getipsr(void)
/* Get/set CONTROL */
static inline uint32_t getcontrol(void) always_inline_function;
static inline uint32_t getcontrol(void)
static always_inline_function uint32_t getcontrol(void)
{
uint32_t control;
__asm__ __volatile__
@ -321,8 +313,7 @@ static inline uint32_t getcontrol(void)
return control;
}
static inline void setcontrol(uint32_t control) always_inline_function;
static inline void setcontrol(uint32_t control)
static always_inline_function void setcontrol(uint32_t control)
{
__asm__ __volatile__
(
@ -332,6 +323,20 @@ static inline void setcontrol(uint32_t control)
: "memory");
}
static always_inline_function uint32_t getpsp(void)
{
uint32_t psp;
__asm__ __volatile__
(
"\tmrs %0, psp\n"
: "=r" (psp)
:
: "memory");
return psp;
}
/****************************************************************************
* Name: up_cpu_index
*
@ -344,7 +349,7 @@ static inline void setcontrol(uint32_t control)
int up_cpu_index(void) noinstrument_function;
#endif /* CONFIG_ARCH_HAVE_MULTICPU */
static inline_function uint32_t up_getsp(void)
static always_inline_function uint32_t up_getsp(void)
{
register uint32_t sp;
@ -357,8 +362,13 @@ static inline_function uint32_t up_getsp(void)
return sp;
}
noinstrument_function
static inline_function bool up_interrupt_context(void)
static always_inline_function uintptr_t up_getusrsp(void *regs)
{
uint32_t *ptr = (uint32_t *)regs;
return ptr[REG_SP];
}
static always_inline_function bool up_interrupt_context(void)
{
return getipsr() != 0;
}

View file

@ -343,7 +343,7 @@ struct xcptcontext
/* Return the current IRQ state */
static inline irqstate_t irqstate(void)
static inline_function irqstate_t irqstate(void)
{
unsigned int cpsr;
@ -360,7 +360,7 @@ static inline irqstate_t irqstate(void)
/* Disable IRQs and return the previous IRQ state */
noinstrument_function static inline irqstate_t up_irq_save(void)
noinstrument_function static inline_function irqstate_t up_irq_save(void)
{
unsigned int cpsr;
@ -382,7 +382,7 @@ noinstrument_function static inline irqstate_t up_irq_save(void)
/* Enable IRQs and return the previous IRQ state */
static inline irqstate_t up_irq_enable(void)
static inline_function irqstate_t up_irq_enable(void)
{
unsigned int cpsr;
@ -406,7 +406,7 @@ static inline irqstate_t up_irq_enable(void)
/* Disable IRQs and return the previous IRQ state */
static inline irqstate_t up_irq_disable(void)
static inline_function irqstate_t up_irq_disable(void)
{
unsigned int cpsr;
@ -424,7 +424,8 @@ static inline irqstate_t up_irq_disable(void)
/* Restore saved IRQ & FIQ state */
noinstrument_function static inline void up_irq_restore(irqstate_t flags)
noinstrument_function static inline_function
void up_irq_restore(irqstate_t flags)
{
__asm__ __volatile__
(
@ -472,6 +473,12 @@ static inline_function uint32_t up_getsp(void)
return sp;
}
static inline_function uintptr_t up_getusrsp(void *regs)
{
uint32_t *ptr = (uint32_t *)regs;
return ptr[REG_SP];
}
noinstrument_function
static inline_function void up_set_interrupt_context(bool flag)
{

View file

@ -267,8 +267,7 @@ struct xcptcontext
/* Get/set the PRIMASK register */
static inline uint8_t getprimask(void) always_inline_function;
static inline uint8_t getprimask(void)
static always_inline_function uint8_t getprimask(void)
{
uint32_t primask;
__asm__ __volatile__
@ -281,8 +280,7 @@ static inline uint8_t getprimask(void)
return (uint8_t)primask;
}
static inline void setprimask(uint32_t primask) always_inline_function;
static inline void setprimask(uint32_t primask)
static always_inline_function void setprimask(uint32_t primask)
{
__asm__ __volatile__
(
@ -292,14 +290,12 @@ static inline void setprimask(uint32_t primask)
: "memory");
}
static inline void cpsie(void) always_inline_function;
static inline void cpsie(void)
static always_inline_function void cpsie(void)
{
__asm__ __volatile__ ("\tcpsie i\n");
}
static inline void cpsid(void) always_inline_function;
static inline void cpsid(void)
static always_inline_function void cpsid(void)
{
__asm__ __volatile__ ("\tcpsid i\n");
}
@ -310,8 +306,7 @@ static inline void cpsid(void)
* lower priority level as the BASEPRI value.
*/
static inline uint8_t getbasepri(void) always_inline_function;
static inline uint8_t getbasepri(void)
static always_inline_function uint8_t getbasepri(void)
{
uint32_t basepri;
@ -325,8 +320,7 @@ static inline uint8_t getbasepri(void)
return (uint8_t)basepri;
}
static inline void setbasepri(uint32_t basepri) always_inline_function;
static inline void setbasepri(uint32_t basepri)
static always_inline_function void setbasepri(uint32_t basepri)
{
__asm__ __volatile__
(
@ -343,8 +337,7 @@ static inline void setbasepri(uint32_t basepri)
* 837070 Workaround may be required if we are raising the priority.
*/
static inline void raisebasepri(uint32_t basepri) always_inline_function;
static inline void raisebasepri(uint32_t basepri)
static always_inline_function void raisebasepri(uint32_t basepri)
{
register uint32_t primask;
@ -378,8 +371,7 @@ static inline void raisebasepri(uint32_t basepri)
/* Disable IRQs */
static inline void up_irq_disable(void) always_inline_function;
static inline void up_irq_disable(void)
static always_inline_function void up_irq_disable(void)
{
/* Probably raising priority */
@ -388,9 +380,7 @@ static inline void up_irq_disable(void)
/* Save the current primask state & disable IRQs */
static inline irqstate_t up_irq_save(void)
always_inline_function noinstrument_function;
static inline irqstate_t up_irq_save(void)
static always_inline_function irqstate_t up_irq_save(void)
{
/* Probably raising priority */
@ -401,8 +391,7 @@ static inline irqstate_t up_irq_save(void)
/* Enable IRQs */
static inline void up_irq_enable(void) always_inline_function;
static inline void up_irq_enable(void)
static always_inline_function void up_irq_enable(void)
{
/* In this case, we are always retaining or lowering the priority value */
@ -412,9 +401,7 @@ static inline void up_irq_enable(void)
/* Restore saved primask state */
static inline void up_irq_restore(irqstate_t flags)
always_inline_function noinstrument_function;
static inline void up_irq_restore(irqstate_t flags)
static always_inline_function void up_irq_restore(irqstate_t flags)
{
/* In this case, we are always retaining or lowering the priority value */
@ -423,8 +410,7 @@ static inline void up_irq_restore(irqstate_t flags)
/* Get/set IPSR */
static inline uint32_t getipsr(void) always_inline_function;
static inline uint32_t getipsr(void)
static always_inline_function uint32_t getipsr(void)
{
uint32_t ipsr;
__asm__ __volatile__
@ -439,8 +425,7 @@ static inline uint32_t getipsr(void)
/* Get/set FAULTMASK */
static inline uint32_t getfaultmask(void) always_inline_function;
static inline uint32_t getfaultmask(void)
static always_inline_function uint32_t getfaultmask(void)
{
uint32_t faultmask;
__asm__ __volatile__
@ -453,8 +438,7 @@ static inline uint32_t getfaultmask(void)
return faultmask;
}
static inline void setfaultmask(uint32_t faultmask) always_inline_function;
static inline void setfaultmask(uint32_t faultmask)
static always_inline_function void setfaultmask(uint32_t faultmask)
{
__asm__ __volatile__
(
@ -466,8 +450,7 @@ static inline void setfaultmask(uint32_t faultmask)
/* Get/set CONTROL */
static inline uint32_t getcontrol(void) always_inline_function;
static inline uint32_t getcontrol(void)
static always_inline_function uint32_t getcontrol(void)
{
uint32_t control;
__asm__ __volatile__
@ -480,8 +463,7 @@ static inline uint32_t getcontrol(void)
return control;
}
static inline void setcontrol(uint32_t control) always_inline_function;
static inline void setcontrol(uint32_t control)
static always_inline_function void setcontrol(uint32_t control)
{
__asm__ __volatile__
(
@ -491,6 +473,20 @@ static inline void setcontrol(uint32_t control)
: "memory");
}
static always_inline_function uint32_t getpsp(void)
{
uint32_t psp;
__asm__ __volatile__
(
"\tmrs %0, psp\n"
: "=r" (psp)
:
: "memory");
return psp;
}
/****************************************************************************
* Name: up_cpu_index
*
@ -503,7 +499,7 @@ static inline void setcontrol(uint32_t control)
int up_cpu_index(void) noinstrument_function;
#endif /* CONFIG_ARCH_HAVE_MULTICPU */
static inline_function uint32_t up_getsp(void)
static always_inline_function uint32_t up_getsp(void)
{
register uint32_t sp;
@ -516,8 +512,13 @@ static inline_function uint32_t up_getsp(void)
return sp;
}
noinstrument_function
static inline_function bool up_interrupt_context(void)
static always_inline_function uintptr_t up_getusrsp(void *regs)
{
uint32_t *ptr = (uint32_t *)regs;
return ptr[REG_SP];
}
static always_inline_function bool up_interrupt_context(void)
{
return getipsr() != 0;
}

View file

@ -342,7 +342,7 @@ struct xcptcontext
/* Return the current IRQ state */
static inline irqstate_t irqstate(void)
static inline_function irqstate_t irqstate(void)
{
unsigned int cpsr;
@ -359,7 +359,7 @@ static inline irqstate_t irqstate(void)
/* Disable IRQs and return the previous IRQ state */
noinstrument_function static inline irqstate_t up_irq_save(void)
noinstrument_function static inline_function irqstate_t up_irq_save(void)
{
unsigned int cpsr;
@ -380,7 +380,7 @@ noinstrument_function static inline irqstate_t up_irq_save(void)
/* Enable IRQs and return the previous IRQ state */
static inline irqstate_t up_irq_enable(void)
static inline_function irqstate_t up_irq_enable(void)
{
unsigned int cpsr;
@ -401,7 +401,7 @@ static inline irqstate_t up_irq_enable(void)
/* Disable IRQs and return the previous IRQ state */
static inline irqstate_t up_irq_disable(void)
static inline_function irqstate_t up_irq_disable(void)
{
unsigned int cpsr;
@ -419,7 +419,8 @@ static inline irqstate_t up_irq_disable(void)
/* Restore saved IRQ & FIQ state */
noinstrument_function static inline void up_irq_restore(irqstate_t flags)
noinstrument_function static inline_function
void up_irq_restore(irqstate_t flags)
{
__asm__ __volatile__
(
@ -467,6 +468,12 @@ static inline_function uint32_t up_getsp(void)
return sp;
}
static inline_function uintptr_t up_getusrsp(void *regs)
{
uint32_t *ptr = (uint32_t *)regs;
return ptr[REG_SP];
}
noinstrument_function
static inline_function void up_set_interrupt_context(bool flag)
{

View file

@ -278,8 +278,7 @@ struct xcptcontext
/* Get/set the PRIMASK register */
static inline uint8_t getprimask(void) always_inline_function;
static inline uint8_t getprimask(void)
static always_inline_function uint8_t getprimask(void)
{
uint32_t primask;
__asm__ __volatile__
@ -292,8 +291,7 @@ static inline uint8_t getprimask(void)
return (uint8_t)primask;
}
static inline void setprimask(uint32_t primask) always_inline_function;
static inline void setprimask(uint32_t primask)
static always_inline_function void setprimask(uint32_t primask)
{
__asm__ __volatile__
(
@ -303,14 +301,12 @@ static inline void setprimask(uint32_t primask)
: "memory");
}
static inline void cpsie(void) always_inline_function;
static inline void cpsie(void)
static always_inline_function void cpsie(void)
{
__asm__ __volatile__ ("\tcpsie i\n");
}
static inline void cpsid(void) always_inline_function;
static inline void cpsid(void)
static always_inline_function void cpsid(void)
{
__asm__ __volatile__ ("\tcpsid i\n");
}
@ -321,8 +317,7 @@ static inline void cpsid(void)
* lower priority level as the BASEPRI value.
*/
static inline uint8_t getbasepri(void) always_inline_function;
static inline uint8_t getbasepri(void)
static always_inline_function uint8_t getbasepri(void)
{
uint32_t basepri;
@ -336,8 +331,7 @@ static inline uint8_t getbasepri(void)
return (uint8_t)basepri;
}
static inline void setbasepri(uint32_t basepri) always_inline_function;
static inline void setbasepri(uint32_t basepri)
static always_inline_function void setbasepri(uint32_t basepri)
{
__asm__ __volatile__
(
@ -351,8 +345,7 @@ static inline void setbasepri(uint32_t basepri)
/* Disable IRQs */
static inline void up_irq_disable(void) always_inline_function;
static inline void up_irq_disable(void)
static always_inline_function void up_irq_disable(void)
{
/* Probably raising priority */
@ -361,9 +354,7 @@ static inline void up_irq_disable(void)
/* Save the current primask state & disable IRQs */
static inline irqstate_t up_irq_save(void)
always_inline_function noinstrument_function;
static inline irqstate_t up_irq_save(void)
static always_inline_function irqstate_t up_irq_save(void)
{
/* Probably raising priority */
@ -374,8 +365,7 @@ static inline irqstate_t up_irq_save(void)
/* Enable IRQs */
static inline void up_irq_enable(void) always_inline_function;
static inline void up_irq_enable(void)
static always_inline_function void up_irq_enable(void)
{
/* In this case, we are always retaining or lowering the priority value */
@ -385,9 +375,8 @@ static inline void up_irq_enable(void)
/* Restore saved primask state */
static inline void up_irq_restore(irqstate_t flags)
always_inline_function noinstrument_function;
static inline void up_irq_restore(irqstate_t flags)
static always_inline_function
void up_irq_restore(irqstate_t flags)
{
/* In this case, we are always retaining or lowering the priority value */
@ -396,8 +385,7 @@ static inline void up_irq_restore(irqstate_t flags)
/* Get/set IPSR */
static inline uint32_t getipsr(void) always_inline_function;
static inline uint32_t getipsr(void)
static always_inline_function uint32_t getipsr(void)
{
uint32_t ipsr;
__asm__ __volatile__
@ -412,8 +400,7 @@ static inline uint32_t getipsr(void)
/* Get/set FAULTMASK */
static inline uint32_t getfaultmask(void) always_inline_function;
static inline uint32_t getfaultmask(void)
static always_inline_function uint32_t getfaultmask(void)
{
uint32_t faultmask;
__asm__ __volatile__
@ -426,8 +413,7 @@ static inline uint32_t getfaultmask(void)
return faultmask;
}
static inline void setfaultmask(uint32_t faultmask) always_inline_function;
static inline void setfaultmask(uint32_t faultmask)
static always_inline_function void setfaultmask(uint32_t faultmask)
{
__asm__ __volatile__
(
@ -439,8 +425,7 @@ static inline void setfaultmask(uint32_t faultmask)
/* Get/set CONTROL */
static inline uint32_t getcontrol(void) always_inline_function;
static inline uint32_t getcontrol(void)
static always_inline_function uint32_t getcontrol(void)
{
uint32_t control;
__asm__ __volatile__
@ -453,8 +438,7 @@ static inline uint32_t getcontrol(void)
return control;
}
static inline void setcontrol(uint32_t control) always_inline_function;
static inline void setcontrol(uint32_t control)
static always_inline_function void setcontrol(uint32_t control)
{
__asm__ __volatile__
(
@ -464,6 +448,20 @@ static inline void setcontrol(uint32_t control)
: "memory");
}
static always_inline_function uint32_t getpsp(void)
{
uint32_t psp;
__asm__ __volatile__
(
"\tmrs %0, psp\n"
: "=r" (psp)
:
: "memory");
return psp;
}
/****************************************************************************
* Name: up_cpu_index
*
@ -476,7 +474,7 @@ static inline void setcontrol(uint32_t control)
int up_cpu_index(void) noinstrument_function;
#endif /* CONFIG_ARCH_HAVE_MULTICPU */
static inline_function uint32_t up_getsp(void)
static always_inline_function uint32_t up_getsp(void)
{
uint32_t sp;
@ -489,8 +487,13 @@ static inline_function uint32_t up_getsp(void)
return sp;
}
noinstrument_function
static inline_function bool up_interrupt_context(void)
static always_inline_function uintptr_t up_getusrsp(void *regs)
{
uint32_t *ptr = (uint32_t *)regs;
return ptr[REG_SP];
}
static always_inline_function bool up_interrupt_context(void)
{
return getipsr() != 0;
}

View file

@ -342,7 +342,7 @@ struct xcptcontext
/* Return the current IRQ state */
static inline irqstate_t irqstate(void)
static inline_function irqstate_t irqstate(void)
{
unsigned int cpsr;
@ -359,7 +359,7 @@ static inline irqstate_t irqstate(void)
/* Disable IRQs and return the previous IRQ state */
noinstrument_function static inline irqstate_t up_irq_save(void)
noinstrument_function static inline_function irqstate_t up_irq_save(void)
{
unsigned int cpsr;
@ -380,7 +380,7 @@ noinstrument_function static inline irqstate_t up_irq_save(void)
/* Enable IRQs and return the previous IRQ state */
static inline irqstate_t up_irq_enable(void)
static inline_function irqstate_t up_irq_enable(void)
{
unsigned int cpsr;
@ -401,7 +401,7 @@ static inline irqstate_t up_irq_enable(void)
/* Disable IRQs and return the previous IRQ state */
static inline irqstate_t up_irq_disable(void)
static inline_function irqstate_t up_irq_disable(void)
{
unsigned int cpsr;
@ -419,7 +419,8 @@ static inline irqstate_t up_irq_disable(void)
/* Restore saved IRQ & FIQ state */
noinstrument_function static inline void up_irq_restore(irqstate_t flags)
noinstrument_function static inline_function
void up_irq_restore(irqstate_t flags)
{
__asm__ __volatile__
(
@ -467,6 +468,12 @@ static inline_function uint32_t up_getsp(void)
return sp;
}
static inline_function uintptr_t up_getusrsp(void *regs)
{
uint32_t *ptr = (uint32_t *)regs;
return ptr[REG_SP];
}
noinstrument_function
static inline_function void up_set_interrupt_context(bool flag)
{

View file

@ -194,7 +194,7 @@ extern volatile bool g_interrupt_context[CONFIG_SMP_NCPUS];
/* Save the current interrupt enable state & disable IRQs. */
static inline irqstate_t up_irq_save(void)
static inline_function irqstate_t up_irq_save(void)
{
irqstate_t r = _IRQ_EN_REG;
_IRQ_EN_REG = 0;
@ -203,36 +203,36 @@ static inline irqstate_t up_irq_save(void)
/* Restore saved IRQ & FIQ state */
static inline void up_irq_restore(irqstate_t flags)
static inline_function void up_irq_restore(irqstate_t flags)
{
_IRQ_EN_REG = flags;
}
/* Enable IRQs and return the previous IRQ state */
static inline irqstate_t up_irq_enable(void)
static inline_function irqstate_t up_irq_enable(void)
{
irqstate_t r = _IRQ_EN_REG;
_IRQ_EN_REG = 1;
return r;
}
static inline void up_irq_disable(void)
static inline_function void up_irq_disable(void)
{
up_irq_save();
}
static inline void up_disable_irq(int irq)
static inline_function void up_disable_irq(int irq)
{
_IRQ_MASK_REG &= ~(1 << irq);
}
static inline void up_enable_irq(int irq)
static inline_function void up_enable_irq(int irq)
{
_IRQ_MASK_REG |= (1 << irq);
}
static inline uint32_t getcontrol(void)
static inline_function uint32_t getcontrol(void)
{
return 0;
}
@ -262,6 +262,12 @@ static inline_function uint32_t up_getsp(void)
return sp;
}
static inline_function uintptr_t up_getusrsp(void *regs)
{
uint32_t *ptr = (uint32_t *)regs;
return ptr[REG_SP];
}
noinstrument_function
static inline_function bool up_interrupt_context(void)
{

View file

@ -29,7 +29,7 @@ add_subdirectory(common)
target_include_directories(arch BEFORE PUBLIC ${NUTTX_CHIP_ABS_DIR} common
${ARCH_SUBDIR})
if(NOT CONFIG_BUILD_FLAT)
if(CONFIG_BUILD_PROTECTED)
target_include_directories(arch_interface BEFORE PUBLIC ${NUTTX_CHIP_ABS_DIR}
common ${ARCH_SUBDIR})
endif()

View file

@ -27,9 +27,11 @@
#include <nuttx/config.h>
#include <assert.h>
#include <sched.h>
#include <arch/board/board.h>
#include <nuttx/irq.h>
#include <nuttx/spinlock.h>
#include <nuttx/arch.h>
#include <nuttx/can/can.h>
@ -205,6 +207,8 @@ static struct can_dev_s g_can1dev =
};
#endif
static spinlock_t g_can_lock = SP_UNLOCKED;
/****************************************************************************
* Private Functions
****************************************************************************/
@ -1079,7 +1083,8 @@ struct can_dev_s *am335x_can_initialize(int port)
syslog(LOG_DEBUG, "CAN%d\n", port);
flags = enter_critical_section();
flags = spin_lock_irqsave(&g_can_lock);
sched_lock();
#ifdef CONFIG_AM335X_CAN0
if (port == 0)
@ -1109,11 +1114,13 @@ struct can_dev_s *am335x_can_initialize(int port)
{
canerr("Unsupported port: %d\n", port);
leave_critical_section(flags);
spin_unlock_irqrestore(&g_can_lock, flags);
sched_unlock();
return NULL;
}
leave_critical_section(flags);
spin_unlock_irqrestore(&g_can_lock, flags);
sched_unlock();
return candev;
}
@ -1124,7 +1131,8 @@ void am335x_can_uninitialize(struct can_dev_s *dev)
DEBUGASSERT(dev);
flags = enter_critical_section();
flags = spin_lock_irqsave(&g_can_lock);
sched_lock();
#ifdef CONFIG_AM335X_CAN0
if (dev == &g_can0dev)
@ -1151,7 +1159,8 @@ void am335x_can_uninitialize(struct can_dev_s *dev)
canerr("Not a CAN device: %p\n", dev);
}
leave_critical_section(flags);
spin_unlock_irqrestore(&g_can_lock, flags);
sched_unlock();
}
#endif

View file

@ -31,6 +31,7 @@
#include <errno.h>
#include <nuttx/irq.h>
#include <nuttx/spinlock.h>
#include "chip.h"
#include "arm_internal.h"
@ -219,6 +220,8 @@ static const uint8_t *g_gpio_padctl[AM335X_GPIO_NPORTS] =
g_gpio3_padctl, /* GPIO3 */
};
static spinlock_t g_gpio_lock = SP_UNLOCKED;
/****************************************************************************
* Private Functions
****************************************************************************/
@ -364,7 +367,7 @@ int am335x_gpio_config(gpio_pinset_t pinset)
/* Configure the pin as an input initially to avoid any spurious outputs */
flags = enter_critical_section();
flags = spin_lock_irqsave(&g_gpio_lock);
/* Configure based upon the pin mode */
@ -407,7 +410,7 @@ int am335x_gpio_config(gpio_pinset_t pinset)
break;
}
leave_critical_section(flags);
spin_unlock_irqrestore(&g_gpio_lock, flags);
return ret;
}
@ -425,9 +428,9 @@ void am335x_gpio_write(gpio_pinset_t pinset, bool value)
int port = (pinset & GPIO_PORT_MASK) >> GPIO_PORT_SHIFT;
int pin = (pinset & GPIO_PIN_MASK) >> GPIO_PIN_SHIFT;
flags = enter_critical_section();
flags = spin_lock_irqsave(&g_gpio_lock);
am335x_gpio_setoutput(port, pin, value);
leave_critical_section(flags);
spin_unlock_irqrestore(&g_gpio_lock, flags);
}
/****************************************************************************
@ -445,9 +448,9 @@ bool am335x_gpio_read(gpio_pinset_t pinset)
int pin = (pinset & GPIO_PIN_MASK) >> GPIO_PIN_SHIFT;
bool value;
flags = enter_critical_section();
flags = spin_lock_irqsave(&g_gpio_lock);
value = am335x_gpio_getinput(port, pin);
leave_critical_section(flags);
spin_unlock_irqrestore(&g_gpio_lock, flags);
return value;
}

View file

@ -37,6 +37,7 @@
#include <nuttx/arch.h>
#include <nuttx/irq.h>
#include <nuttx/spinlock.h>
#include <nuttx/clock.h>
#include <nuttx/mutex.h>
#include <nuttx/semaphore.h>
@ -185,6 +186,7 @@ struct am335x_i2c_priv_s
int refs; /* Reference count */
mutex_t lock; /* Mutual exclusion mutex */
spinlock_t spinlock; /* Spinlock */
#ifndef CONFIG_I2C_POLLED
sem_t sem_isr; /* Interrupt wait semaphore */
#endif
@ -317,6 +319,7 @@ static struct am335x_i2c_priv_s am335x_i2c0_priv =
.config = &am335x_i2c0_config,
.refs = 0,
.lock = NXMUTEX_INITIALIZER,
.spinlock = SP_UNLOCKED,
#ifndef CONFIG_I2C_POLLED
.sem_isr = SEM_INITIALIZER(0),
#endif
@ -352,6 +355,7 @@ static struct am335x_i2c_priv_s am335x_i2c1_priv =
.config = &am335x_i2c1_config,
.refs = 0,
.lock = NXMUTEX_INITIALIZER,
.spinlock = SP_UNLOCKED,
#ifndef CONFIG_I2C_POLLED
.sem_isr = SEM_INITIALIZER(0),
#endif
@ -387,6 +391,7 @@ static struct am335x_i2c_priv_s am335x_i2c2_priv =
.config = &am335x_i2c2_config,
.refs = 0,
.lock = NXMUTEX_INITIALIZER,
.spinlock = SP_UNLOCKED,
#ifndef CONFIG_I2C_POLLED
.sem_isr = SEM_INITIALIZER(0),
#endif
@ -492,7 +497,7 @@ static inline int am335x_i2c_sem_waitdone(struct am335x_i2c_priv_s *priv)
uint32_t regval;
int ret;
flags = enter_critical_section();
flags = spin_lock_irqsave(&priv->spinlock);
/* Enable Interrupts when master mode */
@ -529,6 +534,8 @@ static inline int am335x_i2c_sem_waitdone(struct am335x_i2c_priv_s *priv)
*/
priv->intstate = INTSTATE_WAITING;
spin_unlock_irqrestore(&priv->spinlock, flags);
do
{
/* Wait until either the transfer is complete or the timeout expires */
@ -551,6 +558,8 @@ static inline int am335x_i2c_sem_waitdone(struct am335x_i2c_priv_s *priv)
}
}
flags = spin_lock_irqsave(&priv->spinlock);
/* Loop until the interrupt level transfer is complete. */
while (priv->intstate != INTSTATE_DONE);
@ -563,7 +572,7 @@ static inline int am335x_i2c_sem_waitdone(struct am335x_i2c_priv_s *priv)
am335x_i2c_putreg(priv, AM335X_I2C_IRQ_EN_CLR_OFFSET, I2C_ICR_CLEARMASK);
leave_critical_section(flags);
spin_unlock_irqrestore(&priv->spinlock, flags);
return ret;
}
#else
@ -992,7 +1001,7 @@ static int am335x_i2c_isr_process(struct am335x_i2c_priv_s *priv)
*/
#ifdef CONFIG_I2C_POLLED
irqstate_t flags = enter_critical_section();
irqstate_t flags = spin_lock_irqsave(&priv->spinlock);
#endif
/* Transmit a byte */
@ -1001,7 +1010,7 @@ static int am335x_i2c_isr_process(struct am335x_i2c_priv_s *priv)
priv->dcnt--;
#ifdef CONFIG_I2C_POLLED
leave_critical_section(flags);
spin_unlock_irqrestore(&priv->spinlock, flags);
#endif
if ((priv->dcnt == 0) && ((priv->flags & I2C_M_NOSTOP) == 0))
{
@ -1026,7 +1035,7 @@ static int am335x_i2c_isr_process(struct am335x_i2c_priv_s *priv)
*/
#ifdef CONFIG_I2C_POLLED
irqstate_t flags = enter_critical_section();
irqstate_t flags = spin_lock_irqsave(&priv->spinlock);
#endif
/* Receive a byte */
@ -1036,7 +1045,7 @@ static int am335x_i2c_isr_process(struct am335x_i2c_priv_s *priv)
priv->dcnt--;
#ifdef CONFIG_I2C_POLLED
leave_critical_section(flags);
spin_unlock_irqrestore(&priv->spinlock, flags);
#endif
if ((priv->msgc <= 0) && (priv->dcnt == 0))
{
@ -1100,7 +1109,7 @@ static int am335x_i2c_isr_process(struct am335x_i2c_priv_s *priv)
*/
#ifdef CONFIG_I2C_POLLED
irqstate_t flags = enter_critical_section();
irqstate_t flags = spin_lock_irqsave(&priv->spinlock);
#endif
/* Transmit a byte */
@ -1109,7 +1118,7 @@ static int am335x_i2c_isr_process(struct am335x_i2c_priv_s *priv)
priv->dcnt--;
#ifdef CONFIG_I2C_POLLED
leave_critical_section(flags);
spin_unlock_irqrestore(&priv->spinlock, flags);
#endif
if ((priv->dcnt == 0) && ((priv->flags & I2C_M_NOSTOP) == 0))
{

View file

@ -29,6 +29,7 @@
#include <assert.h>
#include <nuttx/arch.h>
#include <nuttx/spinlock.h>
#include "arm_internal.h"
#include "sctlr.h"
@ -36,6 +37,13 @@
#include "am335x_gpio.h"
#include "am335x_irq.h"
/****************************************************************************
* Private Data
****************************************************************************/
#ifdef CONFIG_ARCH_IRQPRIO
static spinlock_t g_irq_lock = SP_UNLOCKED;
#endif
/****************************************************************************
* Public Data
****************************************************************************/
@ -328,7 +336,7 @@ int up_prioritize_irq(int irq, int priority)
{
/* These operations must be atomic */
flags = enter_critical_section();
flags = spin_lock_irqsave(&g_irq_lock);
#if 0 // TODO
/* Set the new priority */
@ -340,7 +348,7 @@ int up_prioritize_irq(int irq, int priority)
putreg32(regval, regaddr);
#endif
leave_critical_section(flags);
spin_unlock_irqrestore(&g_irq_lock, flags);
return OK;
}

View file

@ -39,6 +39,7 @@
#endif
#include <nuttx/irq.h>
#include <nuttx/spinlock.h>
#include <nuttx/arch.h>
#include <nuttx/fs/ioctl.h>
#include <nuttx/serial/serial.h>
@ -76,13 +77,14 @@
struct up_dev_s
{
uint32_t uartbase; /* Base address of UART registers */
uint32_t baud; /* Configured baud */
uint32_t ier; /* Saved IER value */
uint8_t irq; /* IRQ associated with this UART */
uint8_t parity; /* 0=none, 1=odd, 2=even */
uint8_t bits; /* Number of bits (7 or 8) */
bool stopbits2; /* true: Configure with 2 stop bits instead of 1 */
uint32_t uartbase; /* Base address of UART registers */
uint32_t baud; /* Configured baud */
uint32_t ier; /* Saved IER value */
uint8_t irq; /* IRQ associated with this UART */
uint8_t parity; /* 0=none, 1=odd, 2=even */
uint8_t bits; /* Number of bits (7 or 8) */
bool stopbits2; /* true: Configure with 2 stop bits instead of 1 */
spinlock_t spinlock; /* Spinlock */
};
/****************************************************************************
@ -169,6 +171,7 @@ static struct up_dev_s g_uart0priv =
.parity = CONFIG_UART0_PARITY,
.bits = CONFIG_UART0_BITS,
.stopbits2 = CONFIG_UART0_2STOP,
.spinlock = SP_UNLOCKED,
};
static uart_dev_t g_uart0port =
@ -200,6 +203,7 @@ static struct up_dev_s g_uart1priv =
.parity = CONFIG_UART1_PARITY,
.bits = CONFIG_UART1_BITS,
.stopbits2 = CONFIG_UART1_2STOP,
.spinlock = SP_UNLOCKED,
};
static uart_dev_t g_uart1port =
@ -230,6 +234,7 @@ static struct up_dev_s g_uart2priv =
.parity = CONFIG_UART2_PARITY,
.bits = CONFIG_UART2_BITS,
.stopbits2 = CONFIG_UART2_2STOP,
.spinlock = SP_UNLOCKED,
};
static uart_dev_t g_uart2port =
@ -260,6 +265,7 @@ static struct up_dev_s g_uart3priv =
.parity = CONFIG_UART3_PARITY,
.bits = CONFIG_UART3_BITS,
.stopbits2 = CONFIG_UART3_2STOP,
.spinlock = SP_UNLOCKED,
};
static uart_dev_t g_uart3port =
@ -290,6 +296,7 @@ static struct up_dev_s g_uart4priv =
.parity = CONFIG_UART4_PARITY,
.bits = CONFIG_UART4_BITS,
.stopbits2 = CONFIG_UART4_2STOP,
.spinlock = SP_UNLOCKED,
};
static uart_dev_t g_uart4port =
@ -320,6 +327,7 @@ static struct up_dev_s g_uart5priv =
.parity = CONFIG_UART5_PARITY,
.bits = CONFIG_UART5_BITS,
.stopbits2 = CONFIG_UART5_2STOP,
.spinlock = SP_UNLOCKED,
};
static uart_dev_t g_uart5port =
@ -484,6 +492,10 @@ static uart_dev_t g_uart5port =
# define UART5_ASSIGNED 1
#endif
/* Spinlock */
static spinlock_t g_gpio_lock = SP_UNLOCKED;
/****************************************************************************
* Inline Functions
****************************************************************************/
@ -567,7 +579,7 @@ static inline void am335x_uart0config(void)
/* Step 1: Enable power to UART0 */
flags = enter_critical_section();
flags = spin_lock_irqsave(&g_gpio_lock);
#warning Missing logic
/* Step 2: Enable clocking to UART0 */
@ -577,7 +589,7 @@ static inline void am335x_uart0config(void)
am335x_gpio_config(GPIO_UART0_TXD);
am335x_gpio_config(GPIO_UART0_RXD);
leave_critical_section(flags);
spin_unlock_irqrestore(&g_gpio_lock, flags);
};
#endif
@ -588,7 +600,7 @@ static inline void am335x_uart1config(void)
/* Step 1: Enable power to UART1 */
flags = enter_critical_section();
flags = spin_lock_irqsave(&g_gpio_lock);
#warning Missing logic
/* Step 2: Enable clocking to UART1 */
@ -598,7 +610,7 @@ static inline void am335x_uart1config(void)
am335x_gpio_config(GPIO_UART1_TXD);
am335x_gpio_config(GPIO_UART1_RXD);
leave_critical_section(flags);
spin_unlock_irqrestore(&g_gpio_lock, flags);
};
#endif
@ -609,7 +621,7 @@ static inline void am335x_uart2config(void)
/* Step 1: Enable power to UART2 */
flags = enter_critical_section();
flags = spin_lock_irqsave(&g_gpio_lock);
#warning Missing logic
/* Step 2: Enable clocking on UART2 */
@ -619,7 +631,7 @@ static inline void am335x_uart2config(void)
am335x_gpio_config(GPIO_UART2_TXD);
am335x_gpio_config(GPIO_UART2_RXD);
leave_critical_section(flags);
spin_unlock_irqrestore(&g_gpio_lock, flags);
};
#endif
@ -630,7 +642,7 @@ static inline void am335x_uart3config(void)
/* Step 1: Enable power to UART3 */
flags = enter_critical_section();
flags = spin_lock_irqsave(&g_gpio_lock);
#warning Missing logic
/* Step 2: Enable clocking to UART3 */
@ -640,7 +652,7 @@ static inline void am335x_uart3config(void)
am335x_gpio_config(GPIO_UART3_TXD);
am335x_gpio_config(GPIO_UART3_RXD);
leave_critical_section(flags);
spin_unlock_irqrestore(&g_gpio_lock, flags);
};
#endif
@ -651,7 +663,7 @@ static inline void am335x_uart4config(void)
/* Step 1: Enable power to UART4 */
flags = enter_critical_section();
flags = spin_lock_irqsave(&g_gpio_lock);
#warning Missing logic
/* Step 2: Enable clocking to UART4 */
@ -661,7 +673,7 @@ static inline void am335x_uart4config(void)
am335x_gpio_config(GPIO_UART4_TXD);
am335x_gpio_config(GPIO_UART4_RXD);
leave_critical_section(flags);
spin_unlock_irqrestore(&g_gpio_lock, flags);
};
#endif
@ -672,7 +684,7 @@ static inline void am335x_uart5config(void)
/* Step 1: Enable power to UART5 */
flags = enter_critical_section();
flags = spin_lock_irqsave(&g_gpio_lock);
#warning Missing logic
/* Step 2: Enable clocking to UART5 */
@ -682,7 +694,7 @@ static inline void am335x_uart5config(void)
am335x_gpio_config(GPIO_UART5_TXD);
am335x_gpio_config(GPIO_UART5_RXD);
leave_critical_section(flags);
spin_unlock_irqrestore(&g_gpio_lock, flags);
};
#endif
@ -1029,18 +1041,18 @@ static int up_ioctl(struct file *filep, int cmd, unsigned long arg)
case TIOCSBRK: /* BSD compatibility: Turn break on, unconditionally */
{
irqstate_t flags = enter_critical_section();
irqstate_t flags = spin_lock_irqsave(&priv->spinlock);
up_enablebreaks(priv, true);
leave_critical_section(flags);
spin_unlock_irqrestore(&priv->spinlock, flags);
}
break;
case TIOCCBRK: /* BSD compatibility: Turn break off, unconditionally */
{
irqstate_t flags;
flags = enter_critical_section();
flags = spin_lock_irqsave(&priv->spinlock);
up_enablebreaks(priv, false);
leave_critical_section(flags);
spin_unlock_irqrestore(&priv->spinlock, flags);
}
break;
@ -1204,13 +1216,15 @@ static void up_txint(struct uart_dev_s *dev, bool enable)
struct up_dev_s *priv = (struct up_dev_s *)dev->priv;
irqstate_t flags;
flags = enter_critical_section();
flags = spin_lock_irqsave(&priv->spinlock);
if (enable)
{
#ifndef CONFIG_SUPPRESS_SERIAL_INTS
priv->ier |= UART_IER_THR;
up_serialout(priv, AM335X_UART_IER_OFFSET, priv->ier);
spin_unlock_irqrestore(&priv->spinlock, flags);
/* Fake a TX interrupt here by just calling uart_xmitchars() with
* interrupts disabled (note this may recurse).
*/
@ -1222,9 +1236,9 @@ static void up_txint(struct uart_dev_s *dev, bool enable)
{
priv->ier &= ~UART_IER_THR;
up_serialout(priv, AM335X_UART_IER_OFFSET, priv->ier);
}
leave_critical_section(flags);
spin_unlock_irqrestore(&priv->spinlock, flags);
}
}
/****************************************************************************

View file

@ -35,6 +35,7 @@
#include "arm.h"
#include "sched/sched.h"
#include "signal/signal.h"
#include "arm_internal.h"
/****************************************************************************
@ -90,8 +91,8 @@ void up_schedule_sigaction(struct tcb_s *tcb)
{
/* In this case just deliver the signal now. */
(tcb->sigdeliver)(tcb);
tcb->sigdeliver = NULL;
nxsig_deliver(tcb);
tcb->flags &= ~TCB_FLAG_SIGDELIVER;
}
/* Otherwise, we are (1) signaling a task is not running

View file

@ -37,6 +37,7 @@
#include <arch/board/board.h>
#include "sched/sched.h"
#include "signal/signal.h"
#include "arm_internal.h"
/****************************************************************************
@ -59,9 +60,9 @@ void arm_sigdeliver(void)
board_autoled_on(LED_SIGNAL);
sinfo("rtcb=%p sigdeliver=%p sigpendactionq.head=%p\n",
rtcb, rtcb->sigdeliver, rtcb->sigpendactionq.head);
DEBUGASSERT(rtcb->sigdeliver != NULL);
sinfo("rtcb=%p sigpendactionq.head=%p\n",
rtcb, rtcb->sigpendactionq.head);
DEBUGASSERT((rtcb->flags & TCB_FLAG_SIGDELIVER) != 0);
#ifndef CONFIG_SUPPRESS_INTERRUPTS
/* Then make sure that interrupts are enabled. Signal handlers must always
@ -73,7 +74,7 @@ void arm_sigdeliver(void)
/* Deliver the signal */
(rtcb->sigdeliver)(rtcb);
nxsig_deliver(rtcb);
/* Output any debug messages BEFORE restoring errno (because they may
* alter errno), then disable interrupts again and restore the original
@ -93,7 +94,9 @@ void arm_sigdeliver(void)
* could be modified by a hostile program.
*/
rtcb->sigdeliver = NULL; /* Allows next handler to be scheduled */
/* Allows next handler to be scheduled */
rtcb->flags &= ~TCB_FLAG_SIGDELIVER;
/* Then restore the correct state for this thread of execution. */

View file

@ -34,6 +34,7 @@
#include <nuttx/board.h>
#include <arch/board/board.h>
#include <sched/sched.h>
#include <signal/signal.h>
#include "arm_internal.h"
#include "exc_return.h"
@ -86,7 +87,7 @@ uint32_t *arm_doirq(int irq, uint32_t *regs)
irq_dispatch(irq, regs);
#endif
if (tcb->sigdeliver)
if ((tcb->flags & TCB_FLAG_SIGDELIVER) != 0)
{
/* Pendsv able to access running tcb with no critical section */

View file

@ -31,11 +31,18 @@
#include <nuttx/irq.h>
#include <nuttx/arch.h>
#include <nuttx/spinlock.h>
#include "ram_vectors.h"
#ifdef CONFIG_ARCH_RAMVECTORS
/****************************************************************************
* Private Data
****************************************************************************/
static spinlock_t g_ramvec_lock = SP_UNLOCKED;
/****************************************************************************
* Public Functions
****************************************************************************/
@ -68,7 +75,7 @@ int arm_ramvec_attach(int irq, up_vector_t vector)
* common exception handler.
*/
flags = enter_critical_section();
flags = spin_lock_irqsave(&g_ramvec_lock);
if (vector == NULL)
{
/* Disable the interrupt if we can before detaching it. We might
@ -87,7 +94,7 @@ int arm_ramvec_attach(int irq, up_vector_t vector)
/* Save the new vector in the vector table */
g_ram_vectors[irq] = vector;
leave_critical_section(flags);
spin_unlock_irqrestore(&g_ramvec_lock, flags);
ret = OK;
}

View file

@ -37,6 +37,7 @@
#include "psr.h"
#include "exc_return.h"
#include "sched/sched.h"
#include "signal/signal.h"
#include "arm_internal.h"
#include "irq/irq.h"
#include "nvic.h"
@ -96,8 +97,8 @@ void up_schedule_sigaction(struct tcb_s *tcb)
* REVISIT: Signal handle will run in a critical section!
*/
(tcb->sigdeliver)(tcb);
tcb->sigdeliver = NULL;
nxsig_deliver(tcb);
tcb->flags &= ~TCB_FLAG_SIGDELIVER;
}
else if (tcb == rtcb && ipsr != NVIC_IRQ_PENDSV)
{

View file

@ -37,6 +37,7 @@
#include <arch/board/board.h>
#include "sched/sched.h"
#include "signal/signal.h"
#include "arm_internal.h"
/****************************************************************************
@ -69,9 +70,9 @@ void arm_sigdeliver(void)
board_autoled_on(LED_SIGNAL);
sinfo("rtcb=%p sigdeliver=%p sigpendactionq.head=%p\n",
rtcb, rtcb->sigdeliver, rtcb->sigpendactionq.head);
DEBUGASSERT(rtcb->sigdeliver != NULL);
sinfo("rtcb=%p sigpendactionq.head=%p\n",
rtcb, rtcb->sigpendactionq.head);
DEBUGASSERT((rtcb->flags & TCB_FLAG_SIGDELIVER) != 0);
retry:
#ifdef CONFIG_SMP
@ -103,7 +104,7 @@ retry:
/* Deliver the signal */
(rtcb->sigdeliver)(rtcb);
nxsig_deliver(rtcb);
/* Output any debug messages BEFORE restoring errno (because they may
* alter errno), then disable interrupts again and restore the original
@ -150,7 +151,9 @@ retry:
* could be modified by a hostile program.
*/
rtcb->sigdeliver = NULL; /* Allows next handler to be scheduled */
/* Allows next handler to be scheduled */
rtcb->flags &= ~TCB_FLAG_SIGDELIVER;
/* Then restore the correct state for this thread of
* execution.

View file

@ -35,7 +35,7 @@ else ifeq ($(CONFIG_ARCH_CORTEXA9),y)
endif
ifeq ($(CONFIG_ARM_THUMB),y)
LLVM_ARCHTYPE := thumbv7
LLVM_ARCHTYPE := thumbv7a
else
LLVM_ARCHTYPE := armv7a
endif

View file

@ -38,6 +38,7 @@
#include <debug.h>
#include <nuttx/irq.h>
#include <nuttx/spinlock.h>
#include "arm_internal.h"
#include "barriers.h"
@ -225,6 +226,12 @@
#define PL310_GULP_SIZE 4096
/****************************************************************************
* Private Data
****************************************************************************/
static spinlock_t g_l2cc_lock = SP_UNLOCKED;
/****************************************************************************
* Private Functions
****************************************************************************/
@ -262,6 +269,66 @@ static void pl310_flush_all(void)
putreg32(0, L2CC_CSR);
}
/****************************************************************************
* Name: l2cc_disable_nolock
*
* Description:
* Disable the L2CC-P310 L2 cache by clearing the Control Register (CR)
*
* Input Parameters:
* None
*
* Returned Value:
* None
*
****************************************************************************/
static void l2cc_disable_nolock(void)
{
/* Flush all ways using the Clean Invalidate Way Register (CIWR). */
pl310_flush_all();
/* Disable the L2CC-P310 L2 cache by clearing the Control Register (CR) */
putreg32(0, L2CC_CR);
ARM_DSB();
ARM_ISB();
}
/****************************************************************************
* Name: l2cc_invalidate_all_nolock
*
* Description:
* Invalidate all ways using the Invalidate Way Register (IWR).
*
* Input Parameters:
* None
*
* Returned Value:
* None
*
****************************************************************************/
static void l2cc_invalidate_all_nolock(void)
{
/* Invalidate all ways by writing the bit mask of ways to be invalidated
* the Invalidate Way Register (IWR).
*/
putreg32(PL310_WAY_MASK, L2CC_IWR);
/* Wait for cache operation by way to complete */
while ((getreg32(L2CC_IWR) & PL310_WAY_MASK) != 0);
/* Drain the STB. Operation complete when all buffers, LRB, LFB, STB, and
* EB, are empty.
*/
putreg32(0, L2CC_CSR);
}
/****************************************************************************
* Public Functions
****************************************************************************/
@ -457,18 +524,18 @@ void l2cc_enable(void)
/* Invalidate and enable the cache (must be disabled to do this!) */
flags = enter_critical_section();
flags = spin_lock_irqsave(&g_l2cc_lock);
if ((getreg32(L2CC_CR) & L2CC_CR_L2CEN) != 0)
{
l2cc_disable();
l2cc_disable_nolock();
}
l2cc_invalidate_all();
l2cc_invalidate_all_nolock();
putreg32(L2CC_CR_L2CEN, L2CC_CR);
ARM_DSB();
ARM_ISB();
leave_critical_section(flags);
spin_unlock_irqrestore(&g_l2cc_lock, flags);
}
/****************************************************************************
@ -489,17 +556,11 @@ void l2cc_disable(void)
{
irqstate_t flags;
/* Flush all ways using the Clean Invalidate Way Register (CIWR). */
flags = spin_lock_irqsave(&g_l2cc_lock);
flags = enter_critical_section();
pl310_flush_all();
l2cc_disable_nolock();
/* Disable the L2CC-P310 L2 cache by clearing the Control Register (CR) */
putreg32(0, L2CC_CR);
ARM_DSB();
ARM_ISB();
leave_critical_section(flags);
spin_unlock_irqrestore(&g_l2cc_lock, flags);
}
/****************************************************************************
@ -525,9 +586,9 @@ void l2cc_sync(void)
* EB, are empty.
*/
flags = enter_critical_section();
flags = spin_lock_irqsave(&g_l2cc_lock);
putreg32(0, L2CC_CSR);
leave_critical_section(flags);
spin_unlock_irqrestore(&g_l2cc_lock, flags);
}
/****************************************************************************
@ -548,27 +609,11 @@ void l2cc_invalidate_all(void)
{
irqstate_t flags;
/* Invalidate all ways */
flags = spin_lock_irqsave(&g_l2cc_lock);
flags = enter_critical_section();
l2cc_invalidate_all_nolock();
/* Invalidate all ways by writing the bit mask of ways to be invalidated
* the Invalidate Way Register (IWR).
*/
putreg32(PL310_WAY_MASK, L2CC_IWR);
/* Wait for cache operation by way to complete */
while ((getreg32(L2CC_IWR) & PL310_WAY_MASK) != 0);
/* Drain the STB. Operation complete when all buffers, LRB, LFB, STB, and
* EB, are empty.
*/
putreg32(0, L2CC_CSR);
leave_critical_section(flags);
spin_unlock_irqrestore(&g_l2cc_lock, flags);
}
/****************************************************************************
@ -595,7 +640,7 @@ void l2cc_invalidate(uintptr_t startaddr, uintptr_t endaddr)
/* Check if the start address is aligned with a cacheline */
flags = enter_critical_section();
flags = spin_lock_irqsave(&g_l2cc_lock);
if ((startaddr & PL310_CACHE_LINE_MASK) != 0)
{
/* No.. align down and flush the cache line by writing the address to
@ -622,7 +667,7 @@ void l2cc_invalidate(uintptr_t startaddr, uintptr_t endaddr)
putreg32(endaddr, L2CC_CIPALR);
}
leave_critical_section(flags);
spin_unlock_irqrestore(&g_l2cc_lock, flags);
/* Loop, invalidated the address range by cache line. Interrupts are re-
* enabled momentarily every PL310_GULP_SIZE bytes.
@ -640,7 +685,7 @@ void l2cc_invalidate(uintptr_t startaddr, uintptr_t endaddr)
/* Disable interrupts and invalidate the gulp */
flags = enter_critical_section();
flags = spin_lock_irqsave(&g_l2cc_lock);
while (startaddr < gulpend)
{
/* Invalidate the cache line by writing the address to the
@ -656,16 +701,16 @@ void l2cc_invalidate(uintptr_t startaddr, uintptr_t endaddr)
/* Enable interrupts momentarily */
leave_critical_section(flags);
spin_unlock_irqrestore(&g_l2cc_lock, flags);
}
/* Drain the STB. Operation complete when all buffers, LRB, LFB, STB, and
* EB, are empty.
*/
flags = enter_critical_section();
flags = spin_lock_irqsave(&g_l2cc_lock);
putreg32(0, L2CC_CSR);
leave_critical_section(flags);
spin_unlock_irqrestore(&g_l2cc_lock, flags);
}
/****************************************************************************
@ -690,7 +735,7 @@ void l2cc_clean_all(void)
* Ways Register (CWR).
*/
flags = enter_critical_section();
flags = spin_lock_irqsave(&g_l2cc_lock);
putreg32(PL310_WAY_MASK, L2CC_CWR);
/* Wait for cache operation by way to complete */
@ -702,7 +747,7 @@ void l2cc_clean_all(void)
*/
putreg32(0, L2CC_CSR);
leave_critical_section(flags);
spin_unlock_irqrestore(&g_l2cc_lock, flags);
}
/****************************************************************************
@ -758,7 +803,7 @@ void l2cc_clean(uintptr_t startaddr, uintptr_t endaddr)
/* Disable interrupts and clean the gulp */
flags = enter_critical_section();
flags = spin_lock_irqsave(&g_l2cc_lock);
while (startaddr < gulpend)
{
/* Clean the cache line by writing the address to the Clean
@ -774,16 +819,16 @@ void l2cc_clean(uintptr_t startaddr, uintptr_t endaddr)
/* Enable interrupts momentarily */
leave_critical_section(flags);
spin_unlock_irqrestore(&g_l2cc_lock, flags);
}
/* Drain the STB. Operation complete when all buffers, LRB, LFB, STB, and
* EB, are empty.
*/
flags = enter_critical_section();
flags = spin_lock_irqsave(&g_l2cc_lock);
putreg32(0, L2CC_CSR);
leave_critical_section(flags);
spin_unlock_irqrestore(&g_l2cc_lock, flags);
}
/****************************************************************************
@ -806,9 +851,9 @@ void l2cc_flush_all(void)
/* Flush all ways using the Clean Invalidate Way Register (CIWR). */
flags = enter_critical_section();
flags = spin_lock_irqsave(&g_l2cc_lock);
pl310_flush_all();
leave_critical_section(flags);
spin_unlock_irqrestore(&g_l2cc_lock, flags);
}
/****************************************************************************
@ -864,7 +909,7 @@ void l2cc_flush(uint32_t startaddr, uint32_t endaddr)
/* Disable interrupts and flush the gulp */
flags = enter_critical_section();
flags = spin_lock_irqsave(&g_l2cc_lock);
while (startaddr < gulpend)
{
/* Flush the cache line by writing the address to the Clean
@ -880,16 +925,16 @@ void l2cc_flush(uint32_t startaddr, uint32_t endaddr)
/* Enable interrupts momentarily */
leave_critical_section(flags);
spin_unlock_irqrestore(&g_l2cc_lock, flags);
}
/* Drain the STB. Operation complete when all buffers, LRB, LFB, STB, and
* EB, are empty.
*/
flags = enter_critical_section();
flags = spin_lock_irqsave(&g_l2cc_lock);
putreg32(0, L2CC_CSR);
leave_critical_section(flags);
spin_unlock_irqrestore(&g_l2cc_lock, flags);
}
#endif /* CONFIG_ARMV7A_L2CC_PL310 */

View file

@ -36,6 +36,7 @@
#include "arm.h"
#include "sched/sched.h"
#include "signal/signal.h"
#include "arm_internal.h"
#include "irq/irq.h"
@ -94,8 +95,8 @@ void up_schedule_sigaction(struct tcb_s *tcb)
* REVISIT: Signal handler will run in a critical section!
*/
(tcb->sigdeliver)(tcb);
tcb->sigdeliver = NULL;
nxsig_deliver(tcb);
tcb->flags &= ~TCB_FLAG_SIGDELIVER;
}
else
{

View file

@ -37,6 +37,7 @@
#include <arch/board/board.h>
#include "sched/sched.h"
#include "signal/signal.h"
#include "arm_internal.h"
/****************************************************************************
@ -69,9 +70,9 @@ void arm_sigdeliver(void)
board_autoled_on(LED_SIGNAL);
sinfo("rtcb=%p sigdeliver=%p sigpendactionq.head=%p\n",
rtcb, rtcb->sigdeliver, rtcb->sigpendactionq.head);
DEBUGASSERT(rtcb->sigdeliver != NULL);
sinfo("rtcb=%p sigpendactionq.head=%p\n",
rtcb, rtcb->sigpendactionq.head);
DEBUGASSERT((rtcb->flags & TCB_FLAG_SIGDELIVER) != 0);
retry:
#ifdef CONFIG_SMP
@ -103,7 +104,7 @@ retry:
/* Deliver the signal */
(rtcb->sigdeliver)(rtcb);
nxsig_deliver(rtcb);
/* Output any debug messages BEFORE restoring errno (because they may
* alter errno), then disable interrupts again and restore the original
@ -150,7 +151,9 @@ retry:
* could be modified by a hostile program.
*/
rtcb->sigdeliver = NULL; /* Allows next handler to be scheduled */
/* Allows next handler to be scheduled */
rtcb->flags &= ~TCB_FLAG_SIGDELIVER;
/* Then restore the correct state for this thread of execution. */

View file

@ -410,7 +410,7 @@ uint32_t *arm_syscall(uint32_t *regs)
/* Copy "info" into user stack */
if (rtcb->sigdeliver)
if ((rtcb->flags & TCB_FLAG_SIGDELIVER) != 0)
{
usp = rtcb->xcp.saved_regs[REG_SP];
}

View file

@ -34,6 +34,7 @@
#include <nuttx/board.h>
#include <arch/board/board.h>
#include <sched/sched.h>
#include <signal/signal.h>
#include "arm_internal.h"
#include "exc_return.h"
@ -86,7 +87,7 @@ uint32_t *arm_doirq(int irq, uint32_t *regs)
irq_dispatch(irq, regs);
#endif
if (tcb->sigdeliver)
if ((tcb->flags & TCB_FLAG_SIGDELIVER) != 0)
{
/* Pendsv able to access running tcb with no critical section */

View file

@ -31,11 +31,18 @@
#include <nuttx/irq.h>
#include <nuttx/arch.h>
#include <nuttx/spinlock.h>
#include "ram_vectors.h"
#ifdef CONFIG_ARCH_RAMVECTORS
/****************************************************************************
* Private Data
****************************************************************************/
static spinlock_t g_ramvec_lock = SP_UNLOCKED;
/****************************************************************************
* Public Functions
****************************************************************************/
@ -68,7 +75,7 @@ int arm_ramvec_attach(int irq, up_vector_t vector)
* common exception handler.
*/
flags = enter_critical_section();
flags = spin_lock_irqsave(&g_ramvec_lock);
if (vector == NULL)
{
/* Disable the interrupt if we can before detaching it. We might
@ -87,7 +94,7 @@ int arm_ramvec_attach(int irq, up_vector_t vector)
/* Save the new vector in the vector table */
g_ram_vectors[irq] = vector;
leave_critical_section(flags);
spin_unlock_irqrestore(&g_ramvec_lock, flags);
ret = OK;
}

View file

@ -38,6 +38,7 @@
#include "psr.h"
#include "exc_return.h"
#include "sched/sched.h"
#include "signal/signal.h"
#include "arm_internal.h"
#include "irq/irq.h"
#include "nvic.h"
@ -97,8 +98,8 @@ void up_schedule_sigaction(struct tcb_s *tcb)
* REVISIT: Signal handle will run in a critical section!
*/
(tcb->sigdeliver)(tcb);
tcb->sigdeliver = NULL;
nxsig_deliver(tcb);
tcb->flags &= ~TCB_FLAG_SIGDELIVER;
}
else if (tcb == rtcb && ipsr != NVIC_IRQ_PENDSV)
{

View file

@ -37,6 +37,7 @@
#include <arch/board/board.h>
#include "sched/sched.h"
#include "signal/signal.h"
#include "arm_internal.h"
/****************************************************************************
@ -69,9 +70,9 @@ void arm_sigdeliver(void)
board_autoled_on(LED_SIGNAL);
sinfo("rtcb=%p sigdeliver=%p sigpendactionq.head=%p\n",
rtcb, rtcb->sigdeliver, rtcb->sigpendactionq.head);
DEBUGASSERT(rtcb->sigdeliver != NULL);
sinfo("rtcb=%p sigpendactionq.head=%p\n",
rtcb, rtcb->sigpendactionq.head);
DEBUGASSERT((rtcb->flags & TCB_FLAG_SIGDELIVER) != 0);
retry:
#ifdef CONFIG_SMP
@ -103,7 +104,7 @@ retry:
/* Deliver the signal */
(rtcb->sigdeliver)(rtcb);
nxsig_deliver(rtcb);
/* Output any debug messages BEFORE restoring errno (because they may
* alter errno), then disable interrupts again and restore the original
@ -150,7 +151,9 @@ retry:
* could be modified by a hostile program.
*/
rtcb->sigdeliver = NULL; /* Allows next handler to be scheduled */
/* Allows next handler to be scheduled */
rtcb->flags &= ~TCB_FLAG_SIGDELIVER;
/* Then restore the correct state for this thread of
* execution.

View file

@ -38,6 +38,7 @@
#include <debug.h>
#include <nuttx/irq.h>
#include <nuttx/spinlock.h>
#include "arm_internal.h"
#include "barriers.h"
@ -225,6 +226,12 @@
#define PL310_GULP_SIZE 4096
/****************************************************************************
* Private Data
****************************************************************************/
static volatile spinlock_t g_l2cc_lock = SP_UNLOCKED;
/****************************************************************************
* Private Functions
****************************************************************************/
@ -262,6 +269,66 @@ static void pl310_flush_all(void)
putreg32(0, L2CC_CSR);
}
/****************************************************************************
* Name: l2cc_disable_nolock
*
* Description:
* Disable the L2CC-P310 L2 cache by clearing the Control Register (CR)
*
* Input Parameters:
* None
*
* Returned Value:
* None
*
****************************************************************************/
static void l2cc_disable_nolock(void)
{
/* Flush all ways using the Clean Invalidate Way Register (CIWR). */
pl310_flush_all();
/* Disable the L2CC-P310 L2 cache by clearing the Control Register (CR) */
putreg32(0, L2CC_CR);
ARM_DSB();
ARM_ISB();
}
/****************************************************************************
* Name: l2cc_invalidate_all_nolock
*
* Description:
* Invalidate all ways using the Invalidate Way Register (IWR).
*
* Input Parameters:
* None
*
* Returned Value:
* None
*
****************************************************************************/
static void l2cc_invalidate_all_nolock(void)
{
/* Invalidate all ways by writing the bit mask of ways to be invalidated
* the Invalidate Way Register (IWR).
*/
putreg32(PL310_WAY_MASK, L2CC_IWR);
/* Wait for cache operation by way to complete */
while ((getreg32(L2CC_IWR) & PL310_WAY_MASK) != 0);
/* Drain the STB. Operation complete when all buffers, LRB, LFB, STB, and
* EB, are empty.
*/
putreg32(0, L2CC_CSR);
}
/****************************************************************************
* Public Functions
****************************************************************************/
@ -457,18 +524,18 @@ void l2cc_enable(void)
/* Invalidate and enable the cache (must be disabled to do this!) */
flags = enter_critical_section();
flags = spin_lock_irqsave(&g_l2cc_lock);
if ((getreg32(L2CC_CR) & L2CC_CR_L2CEN) != 0)
{
l2cc_disable();
l2cc_disable_nolock();
}
l2cc_invalidate_all();
l2cc_invalidate_all_nolock();
putreg32(L2CC_CR_L2CEN, L2CC_CR);
ARM_DSB();
ARM_ISB();
leave_critical_section(flags);
spin_unlock_irqrestore(&g_l2cc_lock, flags);
}
/****************************************************************************
@ -489,17 +556,11 @@ void l2cc_disable(void)
{
irqstate_t flags;
/* Flush all ways using the Clean Invalidate Way Register (CIWR). */
flags = spin_lock_irqsave(&g_l2cc_lock);
flags = enter_critical_section();
pl310_flush_all();
l2cc_disable_nolock();
/* Disable the L2CC-P310 L2 cache by clearing the Control Register (CR) */
putreg32(0, L2CC_CR);
ARM_DSB();
ARM_ISB();
leave_critical_section(flags);
spin_unlock_irqrestore(&g_l2cc_lock, flags);
}
/****************************************************************************
@ -525,9 +586,9 @@ void l2cc_sync(void)
* EB, are empty.
*/
flags = enter_critical_section();
flags = spin_lock_irqsave(&g_l2cc_lock);
putreg32(0, L2CC_CSR);
leave_critical_section(flags);
spin_unlock_irqrestore(&g_l2cc_lock, flags);
}
/****************************************************************************
@ -548,27 +609,11 @@ void l2cc_invalidate_all(void)
{
irqstate_t flags;
/* Invalidate all ways */
flags = spin_lock_irqsave(&g_l2cc_lock);
flags = enter_critical_section();
l2cc_invalidate_all_nolock();
/* Invalidate all ways by writing the bit mask of ways to be invalidated
* the Invalidate Way Register (IWR).
*/
putreg32(PL310_WAY_MASK, L2CC_IWR);
/* Wait for cache operation by way to complete */
while ((getreg32(L2CC_IWR) & PL310_WAY_MASK) != 0);
/* Drain the STB. Operation complete when all buffers, LRB, LFB, STB, and
* EB, are empty.
*/
putreg32(0, L2CC_CSR);
leave_critical_section(flags);
spin_unlock_irqrestore(&g_l2cc_lock, flags);
}
/****************************************************************************
@ -595,7 +640,7 @@ void l2cc_invalidate(uintptr_t startaddr, uintptr_t endaddr)
/* Check if the start address is aligned with a cacheline */
flags = enter_critical_section();
flags = spin_lock_irqsave(&g_l2cc_lock);
if ((startaddr & PL310_CACHE_LINE_MASK) != 0)
{
/* No.. align down and flush the cache line by writing the address to
@ -622,7 +667,7 @@ void l2cc_invalidate(uintptr_t startaddr, uintptr_t endaddr)
putreg32(endaddr, L2CC_CIPALR);
}
leave_critical_section(flags);
spin_unlock_irqrestore(&g_l2cc_lock, flags);
/* Loop, invalidated the address range by cache line. Interrupts are re-
* enabled momentarily every PL310_GULP_SIZE bytes.
@ -640,7 +685,7 @@ void l2cc_invalidate(uintptr_t startaddr, uintptr_t endaddr)
/* Disable interrupts and invalidate the gulp */
flags = enter_critical_section();
flags = spin_lock_irqsave(&g_l2cc_lock);
while (startaddr < gulpend)
{
/* Invalidate the cache line by writing the address to the
@ -656,16 +701,16 @@ void l2cc_invalidate(uintptr_t startaddr, uintptr_t endaddr)
/* Enable interrupts momentarily */
leave_critical_section(flags);
spin_unlock_irqrestore(&g_l2cc_lock, flags);
}
/* Drain the STB. Operation complete when all buffers, LRB, LFB, STB, and
* EB, are empty.
*/
flags = enter_critical_section();
flags = spin_lock_irqsave(&g_l2cc_lock);
putreg32(0, L2CC_CSR);
leave_critical_section(flags);
spin_unlock_irqrestore(&g_l2cc_lock, flags);
}
/****************************************************************************
@ -690,7 +735,7 @@ void l2cc_clean_all(void)
* Ways Register (CWR).
*/
flags = enter_critical_section();
flags = spin_lock_irqsave(&g_l2cc_lock);
putreg32(PL310_WAY_MASK, L2CC_CWR);
/* Wait for cache operation by way to complete */
@ -702,7 +747,7 @@ void l2cc_clean_all(void)
*/
putreg32(0, L2CC_CSR);
leave_critical_section(flags);
spin_unlock_irqrestore(&g_l2cc_lock, flags);
}
/****************************************************************************
@ -758,7 +803,7 @@ void l2cc_clean(uintptr_t startaddr, uintptr_t endaddr)
/* Disable interrupts and clean the gulp */
flags = enter_critical_section();
flags = spin_lock_irqsave(&g_l2cc_lock);
while (startaddr < gulpend)
{
/* Clean the cache line by writing the address to the Clean
@ -774,16 +819,16 @@ void l2cc_clean(uintptr_t startaddr, uintptr_t endaddr)
/* Enable interrupts momentarily */
leave_critical_section(flags);
spin_unlock_irqrestore(&g_l2cc_lock, flags);
}
/* Drain the STB. Operation complete when all buffers, LRB, LFB, STB, and
* EB, are empty.
*/
flags = enter_critical_section();
flags = spin_lock_irqsave(&g_l2cc_lock);
putreg32(0, L2CC_CSR);
leave_critical_section(flags);
spin_unlock_irqrestore(&g_l2cc_lock, flags);
}
/****************************************************************************
@ -806,9 +851,9 @@ void l2cc_flush_all(void)
/* Flush all ways using the Clean Invalidate Way Register (CIWR). */
flags = enter_critical_section();
flags = spin_lock_irqsave(&g_l2cc_lock);
pl310_flush_all();
leave_critical_section(flags);
spin_unlock_irqrestore(&g_l2cc_lock, flags);
}
/****************************************************************************
@ -864,7 +909,7 @@ void l2cc_flush(uint32_t startaddr, uint32_t endaddr)
/* Disable interrupts and flush the gulp */
flags = enter_critical_section();
flags = spin_lock_irqsave(&g_l2cc_lock);
while (startaddr < gulpend)
{
/* Flush the cache line by writing the address to the Clean
@ -880,16 +925,16 @@ void l2cc_flush(uint32_t startaddr, uint32_t endaddr)
/* Enable interrupts momentarily */
leave_critical_section(flags);
spin_unlock_irqrestore(&g_l2cc_lock, flags);
}
/* Drain the STB. Operation complete when all buffers, LRB, LFB, STB, and
* EB, are empty.
*/
flags = enter_critical_section();
flags = spin_lock_irqsave(&g_l2cc_lock);
putreg32(0, L2CC_CSR);
leave_critical_section(flags);
spin_unlock_irqrestore(&g_l2cc_lock, flags);
}
#endif /* CONFIG_ARMV7R_L2CC_PL310 */

View file

@ -35,6 +35,7 @@
#include "arm.h"
#include "sched/sched.h"
#include "signal/signal.h"
#include "arm_internal.h"
/****************************************************************************
@ -92,8 +93,8 @@ void up_schedule_sigaction(struct tcb_s *tcb)
* REVISIT: Signal handler will run in a critical section!
*/
(tcb->sigdeliver)(tcb);
tcb->sigdeliver = NULL;
nxsig_deliver(tcb);
tcb->flags &= ~TCB_FLAG_SIGDELIVER;
}
else
{

View file

@ -37,6 +37,7 @@
#include <arch/board/board.h>
#include "sched/sched.h"
#include "signal/signal.h"
#include "arm_internal.h"
/****************************************************************************
@ -69,9 +70,9 @@ void arm_sigdeliver(void)
board_autoled_on(LED_SIGNAL);
sinfo("rtcb=%p sigdeliver=%p sigpendactionq.head=%p\n",
rtcb, rtcb->sigdeliver, rtcb->sigpendactionq.head);
DEBUGASSERT(rtcb->sigdeliver != NULL);
sinfo("rtcb=%p sigpendactionq.head=%p\n",
rtcb, rtcb->sigpendactionq.head);
DEBUGASSERT((rtcb->flags & TCB_FLAG_SIGDELIVER) != 0);
retry:
#ifdef CONFIG_SMP
@ -103,7 +104,7 @@ retry:
/* Deliver the signal */
(rtcb->sigdeliver)(rtcb);
nxsig_deliver(rtcb);
/* Output any debug messages BEFORE restoring errno (because they may
* alter errno), then disable interrupts again and restore the original
@ -147,7 +148,9 @@ retry:
* could be modified by a hostile program.
*/
rtcb->sigdeliver = NULL; /* Allows next handler to be scheduled */
/* Allows next handler to be scheduled */
rtcb->flags &= ~TCB_FLAG_SIGDELIVER;
/* Then restore the correct state for this thread of execution. */

View file

@ -407,7 +407,7 @@ uint32_t *arm_syscall(uint32_t *regs)
/* Copy "info" into user stack */
if (rtcb->sigdeliver)
if ((rtcb->flags & TCB_FLAG_SIGDELIVER) != 0)
{
usp = rtcb->xcp.saved_regs[REG_SP];
}

View file

@ -97,7 +97,7 @@ uint32_t *arm_doirq(int irq, uint32_t *regs)
irq_dispatch(irq, regs);
#endif
if (tcb->sigdeliver)
if ((tcb->flags & TCB_FLAG_SIGDELIVER) != 0)
{
/* Pendsv able to access running tcb with no critical section */

View file

@ -31,11 +31,18 @@
#include <nuttx/irq.h>
#include <nuttx/arch.h>
#include <nuttx/spinlock.h>
#include "ram_vectors.h"
#ifdef CONFIG_ARCH_RAMVECTORS
/****************************************************************************
* Private Data
****************************************************************************/
static spinlock_t g_ramvec_lock = SP_UNLOCKED;
/****************************************************************************
* Public Functions
****************************************************************************/
@ -68,7 +75,7 @@ int arm_ramvec_attach(int irq, up_vector_t vector)
* common exception handler.
*/
flags = enter_critical_section();
flags = spin_lock_irqsave(&g_ramvec_lock);
if (vector == NULL)
{
/* Disable the interrupt if we can before detaching it. We might
@ -87,7 +94,7 @@ int arm_ramvec_attach(int irq, up_vector_t vector)
/* Save the new vector in the vector table */
g_ram_vectors[irq] = vector;
leave_critical_section(flags);
spin_unlock_irqrestore(&g_ramvec_lock, flags);
ret = OK;
}

View file

@ -38,6 +38,7 @@
#include "psr.h"
#include "exc_return.h"
#include "sched/sched.h"
#include "signal/signal.h"
#include "arm_internal.h"
#include "irq/irq.h"
#include "nvic.h"
@ -97,8 +98,8 @@ void up_schedule_sigaction(struct tcb_s *tcb)
* REVISIT: Signal handle will run in a critical section!
*/
(tcb->sigdeliver)(tcb);
tcb->sigdeliver = NULL;
nxsig_deliver(tcb);
tcb->flags &= ~TCB_FLAG_SIGDELIVER;
}
else if (tcb == rtcb && ipsr != NVIC_IRQ_PENDSV)
{

View file

@ -37,6 +37,7 @@
#include <arch/board/board.h>
#include "sched/sched.h"
#include "signal/signal.h"
#include "arm_internal.h"
/****************************************************************************
@ -69,9 +70,9 @@ void arm_sigdeliver(void)
board_autoled_on(LED_SIGNAL);
sinfo("rtcb=%p sigdeliver=%p sigpendactionq.head=%p\n",
rtcb, rtcb->sigdeliver, rtcb->sigpendactionq.head);
DEBUGASSERT(rtcb->sigdeliver != NULL);
sinfo("rtcb=%p sigpendactionq.head=%p\n",
rtcb, rtcb->sigpendactionq.head);
DEBUGASSERT((rtcb->flags & TCB_FLAG_SIGDELIVER) != 0);
retry:
#ifdef CONFIG_SMP
@ -103,7 +104,7 @@ retry:
/* Deliver the signal */
(rtcb->sigdeliver)(rtcb);
nxsig_deliver(rtcb);
/* Output any debug messages BEFORE restoring errno (because they may
* alter errno), then disable interrupts again and restore the original
@ -150,7 +151,9 @@ retry:
* could be modified by a hostile program.
*/
rtcb->sigdeliver = NULL; /* Allows next handler to be scheduled */
/* Allows next handler to be scheduled */
rtcb->flags &= ~TCB_FLAG_SIGDELIVER;
/* Then restore the correct state for this thread of
* execution.

View file

@ -38,6 +38,7 @@
#include <debug.h>
#include <nuttx/irq.h>
#include <nuttx/spinlock.h>
#include "arm_internal.h"
#include "barriers.h"
@ -225,6 +226,12 @@
#define PL310_GULP_SIZE 4096
/****************************************************************************
* Private Data
****************************************************************************/
static volatile spinlock_t g_l2cc_lock = SP_UNLOCKED;
/****************************************************************************
* Private Functions
****************************************************************************/
@ -262,6 +269,66 @@ static void pl310_flush_all(void)
putreg32(0, L2CC_CSR);
}
/****************************************************************************
* Name: l2cc_disable_nolock
*
* Description:
* Disable the L2CC-P310 L2 cache by clearing the Control Register (CR)
*
* Input Parameters:
* None
*
* Returned Value:
* None
*
****************************************************************************/
static void l2cc_disable_nolock(void)
{
/* Flush all ways using the Clean Invalidate Way Register (CIWR). */
pl310_flush_all();
/* Disable the L2CC-P310 L2 cache by clearing the Control Register (CR) */
putreg32(0, L2CC_CR);
ARM_DSB();
ARM_ISB();
}
/****************************************************************************
* Name: l2cc_invalidate_all_nolock
*
* Description:
* Invalidate all ways using the Invalidate Way Register (IWR).
*
* Input Parameters:
* None
*
* Returned Value:
* None
*
****************************************************************************/
static void l2cc_invalidate_all_nolock(void)
{
/* Invalidate all ways by writing the bit mask of ways to be invalidated
* the Invalidate Way Register (IWR).
*/
putreg32(PL310_WAY_MASK, L2CC_IWR);
/* Wait for cache operation by way to complete */
while ((getreg32(L2CC_IWR) & PL310_WAY_MASK) != 0);
/* Drain the STB. Operation complete when all buffers, LRB, LFB, STB, and
* EB, are empty.
*/
putreg32(0, L2CC_CSR);
}
/****************************************************************************
* Public Functions
****************************************************************************/
@ -457,18 +524,18 @@ void l2cc_enable(void)
/* Invalidate and enable the cache (must be disabled to do this!) */
flags = enter_critical_section();
flags = spin_lock_irqsave(&g_l2cc_lock);
if ((getreg32(L2CC_CR) & L2CC_CR_L2CEN) != 0)
{
l2cc_disable();
l2cc_disable_nolock();
}
l2cc_invalidate_all();
l2cc_invalidate_all_nolock();
putreg32(L2CC_CR_L2CEN, L2CC_CR);
ARM_DSB();
ARM_ISB();
leave_critical_section(flags);
spin_unlock_irqrestore(&g_l2cc_lock, flags);
}
/****************************************************************************
@ -489,17 +556,11 @@ void l2cc_disable(void)
{
irqstate_t flags;
/* Flush all ways using the Clean Invalidate Way Register (CIWR). */
flags = spin_lock_irqsave(&g_l2cc_lock);
flags = enter_critical_section();
pl310_flush_all();
l2cc_disable_nolock();
/* Disable the L2CC-P310 L2 cache by clearing the Control Register (CR) */
putreg32(0, L2CC_CR);
ARM_DSB();
ARM_ISB();
leave_critical_section(flags);
spin_unlock_irqrestore(&g_l2cc_lock, flags);
}
/****************************************************************************
@ -525,9 +586,9 @@ void l2cc_sync(void)
* EB, are empty.
*/
flags = enter_critical_section();
flags = spin_lock_irqsave(&g_l2cc_lock);
putreg32(0, L2CC_CSR);
leave_critical_section(flags);
spin_unlock_irqrestore(&g_l2cc_lock, flags);
}
/****************************************************************************
@ -548,27 +609,11 @@ void l2cc_invalidate_all(void)
{
irqstate_t flags;
/* Invalidate all ways */
flags = spin_lock_irqsave(&g_l2cc_lock);
flags = enter_critical_section();
l2cc_invalidate_all_nolock();
/* Invalidate all ways by writing the bit mask of ways to be invalidated
* the Invalidate Way Register (IWR).
*/
putreg32(PL310_WAY_MASK, L2CC_IWR);
/* Wait for cache operation by way to complete */
while ((getreg32(L2CC_IWR) & PL310_WAY_MASK) != 0);
/* Drain the STB. Operation complete when all buffers, LRB, LFB, STB, and
* EB, are empty.
*/
putreg32(0, L2CC_CSR);
leave_critical_section(flags);
spin_unlock_irqrestore(&g_l2cc_lock, flags);
}
/****************************************************************************
@ -595,7 +640,7 @@ void l2cc_invalidate(uintptr_t startaddr, uintptr_t endaddr)
/* Check if the start address is aligned with a cacheline */
flags = enter_critical_section();
flags = spin_lock_irqsave(&g_l2cc_lock);
if ((startaddr & PL310_CACHE_LINE_MASK) != 0)
{
/* No.. align down and flush the cache line by writing the address to
@ -622,7 +667,7 @@ void l2cc_invalidate(uintptr_t startaddr, uintptr_t endaddr)
putreg32(endaddr, L2CC_CIPALR);
}
leave_critical_section(flags);
spin_unlock_irqrestore(&g_l2cc_lock, flags);
/* Loop, invalidated the address range by cache line. Interrupts are re-
* enabled momentarily every PL310_GULP_SIZE bytes.
@ -640,7 +685,7 @@ void l2cc_invalidate(uintptr_t startaddr, uintptr_t endaddr)
/* Disable interrupts and invalidate the gulp */
flags = enter_critical_section();
flags = spin_lock_irqsave(&g_l2cc_lock);
while (startaddr < gulpend)
{
/* Invalidate the cache line by writing the address to the
@ -656,16 +701,16 @@ void l2cc_invalidate(uintptr_t startaddr, uintptr_t endaddr)
/* Enable interrupts momentarily */
leave_critical_section(flags);
spin_unlock_irqrestore(&g_l2cc_lock, flags);
}
/* Drain the STB. Operation complete when all buffers, LRB, LFB, STB, and
* EB, are empty.
*/
flags = enter_critical_section();
flags = spin_lock_irqsave(&g_l2cc_lock);
putreg32(0, L2CC_CSR);
leave_critical_section(flags);
spin_unlock_irqrestore(&g_l2cc_lock, flags);
}
/****************************************************************************
@ -690,7 +735,7 @@ void l2cc_clean_all(void)
* Ways Register (CWR).
*/
flags = enter_critical_section();
flags = spin_lock_irqsave(&g_l2cc_lock);
putreg32(PL310_WAY_MASK, L2CC_CWR);
/* Wait for cache operation by way to complete */
@ -702,7 +747,7 @@ void l2cc_clean_all(void)
*/
putreg32(0, L2CC_CSR);
leave_critical_section(flags);
spin_unlock_irqrestore(&g_l2cc_lock, flags);
}
/****************************************************************************
@ -758,7 +803,7 @@ void l2cc_clean(uintptr_t startaddr, uintptr_t endaddr)
/* Disable interrupts and clean the gulp */
flags = enter_critical_section();
flags = spin_lock_irqsave(&g_l2cc_lock);
while (startaddr < gulpend)
{
/* Clean the cache line by writing the address to the Clean
@ -774,16 +819,16 @@ void l2cc_clean(uintptr_t startaddr, uintptr_t endaddr)
/* Enable interrupts momentarily */
leave_critical_section(flags);
spin_unlock_irqrestore(&g_l2cc_lock, flags);
}
/* Drain the STB. Operation complete when all buffers, LRB, LFB, STB, and
* EB, are empty.
*/
flags = enter_critical_section();
flags = spin_lock_irqsave(&g_l2cc_lock);
putreg32(0, L2CC_CSR);
leave_critical_section(flags);
spin_unlock_irqrestore(&g_l2cc_lock, flags);
}
/****************************************************************************
@ -806,9 +851,9 @@ void l2cc_flush_all(void)
/* Flush all ways using the Clean Invalidate Way Register (CIWR). */
flags = enter_critical_section();
flags = spin_lock_irqsave(&g_l2cc_lock);
pl310_flush_all();
leave_critical_section(flags);
spin_unlock_irqrestore(&g_l2cc_lock, flags);
}
/****************************************************************************
@ -864,7 +909,7 @@ void l2cc_flush(uint32_t startaddr, uint32_t endaddr)
/* Disable interrupts and flush the gulp */
flags = enter_critical_section();
flags = spin_lock_irqsave(&g_l2cc_lock);
while (startaddr < gulpend)
{
/* Flush the cache line by writing the address to the Clean
@ -880,16 +925,16 @@ void l2cc_flush(uint32_t startaddr, uint32_t endaddr)
/* Enable interrupts momentarily */
leave_critical_section(flags);
spin_unlock_irqrestore(&g_l2cc_lock, flags);
}
/* Drain the STB. Operation complete when all buffers, LRB, LFB, STB, and
* EB, are empty.
*/
flags = enter_critical_section();
flags = spin_lock_irqsave(&g_l2cc_lock);
putreg32(0, L2CC_CSR);
leave_critical_section(flags);
spin_unlock_irqrestore(&g_l2cc_lock, flags);
}
#endif /* CONFIG_ARMV8R_L2CC_PL310 */

View file

@ -35,6 +35,7 @@
#include "arm.h"
#include "sched/sched.h"
#include "signal/signal.h"
#include "arm_internal.h"
/****************************************************************************
@ -92,8 +93,8 @@ void up_schedule_sigaction(struct tcb_s *tcb)
* REVISIT: Signal handler will run in a critical section!
*/
(tcb->sigdeliver)(tcb);
tcb->sigdeliver = NULL;
nxsig_deliver(tcb);
tcb->flags &= ~TCB_FLAG_SIGDELIVER;
}
else
{

View file

@ -37,6 +37,7 @@
#include <arch/board/board.h>
#include "sched/sched.h"
#include "signal/signal.h"
#include "arm_internal.h"
/****************************************************************************
@ -69,9 +70,9 @@ void arm_sigdeliver(void)
board_autoled_on(LED_SIGNAL);
sinfo("rtcb=%p sigdeliver=%p sigpendactionq.head=%p\n",
rtcb, rtcb->sigdeliver, rtcb->sigpendactionq.head);
DEBUGASSERT(rtcb->sigdeliver != NULL);
sinfo("rtcb=%p sigpendactionq.head=%p\n",
rtcb, rtcb->sigpendactionq.head);
DEBUGASSERT((rtcb->flags & TCB_FLAG_SIGDELIVER) != 0);
retry:
#ifdef CONFIG_SMP
@ -103,7 +104,7 @@ retry:
/* Deliver the signal */
(rtcb->sigdeliver)(rtcb);
nxsig_deliver(rtcb);
/* Output any debug messages BEFORE restoring errno (because they may
* alter errno), then disable interrupts again and restore the original
@ -147,7 +148,9 @@ retry:
* could be modified by a hostile program.
*/
rtcb->sigdeliver = NULL; /* Allows next handler to be scheduled */
/* Allows next handler to be scheduled */
rtcb->flags &= ~TCB_FLAG_SIGDELIVER;
/* Then restore the correct state for this thread of execution. */

View file

@ -407,7 +407,7 @@ uint32_t *arm_syscall(uint32_t *regs)
/* Copy "info" into user stack */
if (rtcb->sigdeliver)
if ((rtcb->flags & TCB_FLAG_SIGDELIVER) != 0)
{
usp = rtcb->xcp.saved_regs[REG_SP];
}

View file

@ -36,7 +36,6 @@
#include <errno.h>
#include <assert.h>
#include <debug.h>
#include <unistd.h>
#include <arch/board/board.h>
#include <nuttx/irq.h>

View file

@ -34,7 +34,6 @@
#include <string.h>
#include <assert.h>
#include <debug.h>
#include <assert.h>
#include <errno.h>
#include <arpa/inet.h>

View file

@ -21,3 +21,8 @@
# ##############################################################################
add_compile_options(-mcpu=cortex-m0 -mthumb -mfloat-abi=soft)
# LLVM Configuration
set(LLVM_ARCHTYPE thumbv6m)
set(LLVM_ABITYPE eabi)
set(LLVM_CPUTYPE cortex-m0)

View file

@ -24,24 +24,43 @@ set(PLATFORM_FLAGS)
if(CONFIG_ARCH_CORTEXA5)
list(APPEND PLATFORM_FLAGS -mcpu=cortex-a5)
set(LLVM_CPUTYPE cortex-a5)
elseif(CONFIG_ARCH_CORTEXA7)
list(APPEND PLATFORM_FLAGS -mcpu=cortex-a7)
set(LLVM_CPUTYPE cortex-a7)
elseif(CONFIG_ARCH_CORTEXA8)
list(APPEND PLATFORM_FLAGS -mcpu=cortex-a8)
set(LLVM_CPUTYPE cortex-a8)
elseif(CONFIG_ARCH_CORTEXA9)
list(APPEND PLATFORM_FLAGS -mcpu=cortex-a9)
set(LLVM_CPUTYPE cortex-a9)
endif()
if(CONFIG_ARM_THUMB)
set(LLVM_ARCHTYPE thumbv7a)
else()
set(LLVM_ARCHTYPE armv7-a)
endif()
if(CONFIG_ARCH_FPU)
set(LLVM_ABITYPE eabihf)
else()
set(LLVM_ABITYPE eabi)
endif()
if(NOT CONFIG_ARM_DPFPU32)
set(ARCHFPUD16 -d16)
endif()
# Cortex-A5 | -mfpu=vfpv4-fp16 | -mfpu=vfpv4-d16-fp16 | -mfpu=neon-fp16
# Cortex-A7 | -mfpu=vfpv4 | -mfpu=vfpv4-d16 | -mfpu=neon-vfpv4
# Cortex-A8 | -mfpu=vfpv3 | | -mfpu=neon (alias for
# neon-vfpv3) Cortex-A9 | -mfpu=vfpv3-fp16 | -mfpu=vfpv3-d16-fp16 |
# -mfpu=neon-fp16 Cortex-A15 | -mfpu=vfpv4 | |
# -mfpu=neon-vfpv4
# ~~~
# | Cortex | FPU Option 1 | FPU Option 2 | FPU Option 3 |
# |--------|--------------------|------------------------|-----------------------|
# | A5 | -mfpu=vfpv4-fp16 | -mfpu=vfpv4-d16-fp16 | -mfpu=neon-fp16 |
# | A7 | -mfpu=vfpv4 | -mfpu=vfpv4-d16 | -mfpu=neon-vfpv4 |
# | A8 | -mfpu=vfpv3 | | -mfpu=neon (alias for neon-vfpv3) |
# | A9 | -mfpu=vfpv3-fp16 | -mfpu=vfpv3-d16-fp16 | -mfpu=neon-fp16 |
# | A15 | -mfpu=vfpv4 | | -mfpu=neon-vfpv4 |
# ~~~
if(CONFIG_ARCH_FPU)
if(CONFIG_ARM_FPU_ABI_SOFT)

View file

@ -38,4 +38,23 @@ else() # gcc
set(TOOLCHAIN_ARCH_FILE armv7-m_gcc)
endif()
# LLVM Configuration
if(CONFIG_ARCH_CORTEXM3)
set(LLVM_ARCHTYPE thumbv7m)
set(LLVM_CPUTYPE cortex-m3)
else()
set(LLVM_ARCHTYPE thumbv7em)
if(CONFIG_ARCH_CORTEXM4)
set(LLVM_CPUTYPE cortex-m4)
elseif(CONFIG_ARCH_CORTEXM7)
set(LLVM_CPUTYPE cortex-m7)
endif()
endif()
if(CONFIG_ARCH_FPU)
set(LLVM_ABITYPE eabihf)
else()
set(LLVM_ABITYPE eabi)
endif()
include(${TOOLCHAIN_ARCH_FILE})

View file

@ -22,6 +22,31 @@
set(PLATFORM_FLAGS)
# LLVM Configuration
if(CONFIG_ARCH_CORTEXM23)
set(LLVM_ARCHTYPE thumbv8m.base)
set(LLVM_CPUTYPE cortex-m23)
elseif(CONFIG_ARCH_CORTEXM33)
set(LLVM_ARCHTYPE thumbv8m.main)
set(LLVM_CPUTYPE cortex-m33)
elseif(CONFIG_ARCH_CORTEXM35P)
set(LLVM_ARCHTYPE thumbv8m.main)
set(LLVM_CPUTYPE cortex-m35p)
elseif(CONFIG_ARCH_CORTEXM55)
set(LLVM_ARCHTYPE thumbv8.1m.main)
set(LLVM_CPUTYPE cortex-m55)
elseif(CONFIG_ARCH_CORTEXM85)
set(LLVM_ARCHTYPE thumbv8.1m.main)
set(LLVM_CPUTYPE cortex-m85)
endif()
# Set ABI type based on FPU configuration
if(CONFIG_ARCH_FPU)
set(LLVM_ABITYPE eabihf)
else()
set(LLVM_ABITYPE eabi)
endif()
if(CONFIG_ARM_DSP)
set(EXTCPUFLAGS +dsp)
endif()

View file

@ -546,7 +546,9 @@ ifeq ($(CONFIG_PIC),y)
# Generate an executable elf, need to ignore undefined symbols
LDELFFLAGS += --unresolved-symbols=ignore-in-object-files --emit-relocs
else
LDELFFLAGS += -r
ifneq ($(CONFIG_BINFMT_ELF_EXECUTABLE),y)
LDELFFLAGS += -r
endif
endif
LDELFFLAGS += -e main -T $(call CONVERT_PATH,$(TOPDIR)$(DELIM)libs$(DELIM)libc$(DELIM)modlib$(DELIM)gnu-elf.ld)

View file

@ -43,16 +43,6 @@
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: up_getusrsp
****************************************************************************/
uintptr_t up_getusrsp(void *regs)
{
uint32_t *ptr = regs;
return ptr[REG_SP];
}
/****************************************************************************
* Name: up_dump_register
****************************************************************************/

View file

@ -29,7 +29,6 @@
#include <nuttx/config.h>
#include <assert.h>
#include <debug.h>
#include <sys/types.h>
#include <stdio.h>

View file

@ -27,7 +27,6 @@
****************************************************************************/
#include <nuttx/config.h>
#include <debug.h>
#include <sys/types.h>
#include <stdio.h>

View file

@ -399,10 +399,14 @@ time_t up_rtc_time(void)
#ifdef CONFIG_RTC_HIRES
int up_rtc_gettime(struct timespec *tp)
{
irqstate_t flags;
uint64_t count;
count = cxd56_rtc_count();
flags = spin_lock_irqsave(&g_rtc_lock);
count = cxd56_rtc_count_nolock();
count += g_rtc_save->offset;
spin_unlock_irqrestore(&g_rtc_lock, flags);
/* Then we can save the time in seconds and fractional seconds. */
@ -477,21 +481,28 @@ int up_rtc_settime(const struct timespec *tp)
*
****************************************************************************/
uint64_t cxd56_rtc_count(void)
uint64_t cxd56_rtc_count_nolock(void)
{
uint64_t val;
irqstate_t flags;
/* The pre register is latched with reading the post rtcounter register,
* so these registers always have to been read in the below order,
* 1st post -> 2nd pre, and should be operated in atomic.
*/
flags = spin_lock_irqsave(&g_rtc_lock);
val = (uint64_t)getreg32(CXD56_RTC0_RTPOSTCNT) << 15;
val |= getreg32(CXD56_RTC0_RTPRECNT);
return val;
}
uint64_t cxd56_rtc_count(void)
{
uint64_t val;
irqstate_t flags;
flags = spin_lock_irqsave(&g_rtc_lock);
val = cxd56_rtc_count_nolock();
spin_unlock_irqrestore(&g_rtc_lock, flags);
return val;

View file

@ -92,6 +92,7 @@ extern "C"
****************************************************************************/
uint64_t cxd56_rtc_count(void);
uint64_t cxd56_rtc_count_nolock(void);
/****************************************************************************
* Name: cxd56_rtc_almcount

View file

@ -35,7 +35,6 @@
#include <errno.h>
#include <assert.h>
#include <debug.h>
#include <unistd.h>
#include <arch/board/board.h>
#include <nuttx/irq.h>

View file

@ -33,7 +33,6 @@
#include <nuttx/irq.h>
#include <nuttx/arch.h>
#include <nuttx/irq.h>
#include <arch/armv7-m/nvicpri.h>
#include "nvic.h"

View file

@ -33,7 +33,6 @@
#include <nuttx/irq.h>
#include <nuttx/arch.h>
#include <nuttx/irq.h>
#include <arch/armv7-m/nvicpri.h>
#include "nvic.h"

View file

@ -41,7 +41,6 @@
#include "imx9_clockconfig.h"
#include "imx9_iomuxc.h"
#include "hardware/imx9_clock.h"
#include "hardware/imx9_pinmux.h"
#include <arch/board/board.h> /* Include last: has dependencies */

View file

@ -1103,7 +1103,7 @@ static void imx9_lpi2c_setclock(struct imx9_lpi2c_priv_s *priv,
&src_freq);
/* LPI2C output frequency = (Source Clock (Hz)/ 2^prescale) /
* (CLKLO + 1 + CLKHI + 1 + ROUNDDOWN((2 + FILTSCL) / 2^prescale)
* (CLKLO + 1 + CLKHI + 1 + ALIGN_DOWN((2 + FILTSCL)/2^prescale)
*
* Assume CLKLO = 2 * CLKHI, SETHOLD = CLKHI, DATAVD = CLKHI / 2
*/

View file

@ -24,13 +24,11 @@
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <sys/types.h>
#include <stdint.h>
#include <stdbool.h>
#include <nuttx/config.h>
#include <stdint.h>
#include <assert.h>
#include <errno.h>

View file

@ -24,13 +24,11 @@
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <sys/types.h>
#include <stdint.h>
#include <stdbool.h>
#include <nuttx/config.h>
#include <stdint.h>
#include <assert.h>
#include <errno.h>

View file

@ -49,7 +49,6 @@
#include "imxrt_lpi2c.h"
#include "imxrt_edma.h"
#include "imxrt_gpio.h"
#include "imxrt_lpi2c.h"
#include "hardware/imxrt_dmamux.h"
#include "hardware/imxrt_pinmux.h"
@ -1162,7 +1161,7 @@ static void imxrt_lpi2c_setclock(struct imxrt_lpi2c_priv_s *priv,
#endif
/* LPI2C output frequency = (Source Clock (Hz)/ 2^prescale) /
* (CLKLO + 1 + CLKHI + 1 + ROUNDDOWN((2 + FILTSCL) / 2^prescale)
* (CLKLO + 1 + CLKHI + 1 + ALIGN_DOWN((2 + FILTSCL)/2^prescale)
*
* Assume CLKLO = 2 * CLKHI, SETHOLD = CLKHI, DATAVD = CLKHI / 2
*/

View file

@ -34,7 +34,6 @@
#include <arch/board/board.h>
#include <nuttx/arch.h>
#include <nuttx/arch.h>
#include "arm_internal.h"
#include "kinetis_config.h"

View file

@ -28,6 +28,7 @@
#include <nuttx/arch.h>
#include <nuttx/irq.h>
#include <nuttx/timers/rtc.h>
#include <nuttx/spinlock.h>
#include <arch/board/board.h>
#include <stdlib.h>
@ -62,6 +63,10 @@
* Private Data
****************************************************************************/
#ifdef CONFIG_RTC_HIRES
static spinlock_t g_rtc_lock = SP_UNLOCKED;
#endif
#ifdef CONFIG_RTC_ALARM
static alarmcb_t g_alarmcb;
static bool rtc_irq_state = false;
@ -436,7 +441,7 @@ int up_rtc_gettime(struct timespec *tp)
* wrapped-around.
*/
flags = enter_critical_section();
flags = spin_lock_irqsave(&g_rtc_lock);
do
{
prescaler = getreg32(KINETIS_RTC_TPR);
@ -445,7 +450,7 @@ int up_rtc_gettime(struct timespec *tp)
}
while (prescaler > prescaler2);
leave_critical_section(flags);
spin_unlock_irqrestore(&g_rtc_lock, flags);
/* Build seconds + nanoseconds from seconds and prescaler register */
@ -479,7 +484,7 @@ int up_rtc_settime(const struct timespec *tp)
seconds = tp->tv_sec;
prescaler = tp->tv_nsec / (1000000000 / CONFIG_RTC_FREQUENCY);
flags = enter_critical_section();
flags = spin_lock_irqsave(&g_rtc_lock);
putreg32(0, KINETIS_RTC_SR); /* Disable counter */
@ -488,7 +493,7 @@ int up_rtc_settime(const struct timespec *tp)
putreg32(RTC_SR_TCE, KINETIS_RTC_SR); /* Re-enable counter */
leave_critical_section(flags);
spin_unlock_irqrestore(&g_rtc_lock, flags);
return OK;
}

View file

@ -40,7 +40,6 @@
#include "hardware/kl_uart.h"
#include "hardware/kl_sim.h"
#include "hardware/kl_port.h"
#include "hardware/kl_uart.h"
#include "hardware/kl_pinmux.h"
/****************************************************************************

View file

@ -36,7 +36,6 @@
#include <errno.h>
#include <assert.h>
#include <debug.h>
#include <unistd.h>
#include <arch/board/board.h>

View file

@ -59,7 +59,6 @@
#include "arm_internal.h"
#include "lc823450_sddrv_type.h"
#include "lc823450_sddrv_if.h"
#include "lc823450_dma.h"
#include "lc823450_gpio.h"
#include "lc823450_syscontrol.h"
#include "lc823450_timer.h"

View file

@ -65,7 +65,6 @@
#include "chip.h"
#include "arm_internal.h"
#include "chip.h"
#include "hardware/lpc17_40_syscon.h"
#include "lpc17_40_gpio.h"
#include "lpc17_40_i2c.h"

View file

@ -23,12 +23,6 @@
#ifndef __ARCH_ARM_SRC_MAX326XX_HARDWARE_MAX326_GCR_H
#define __ARCH_ARM_SRC_MAX326XX_HARDWARE_MAX326_GCR_H
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
/****************************************************************************
* Included Files
****************************************************************************/

View file

@ -403,11 +403,14 @@ time_t up_rtc_time(void)
#ifdef CONFIG_RTC_HIRES
int up_rtc_gettime(struct timespec *tp)
{
irqstate_t flags;
uint64_t tmp;
uint32_t sec;
uint32_t ssec;
uint32_t verify;
flags = spin_lock_irqsave(&g_rtc_lock);
/* Read the time handling rollover to full seconds */
do
@ -418,6 +421,8 @@ int up_rtc_gettime(struct timespec *tp)
}
while (verify != sec);
spin_unlock_irqrestore(&g_rtc_lock, flags);
/* Format as a tm */
tmp = ((uint64_t)ssec * NSEC_PER_SEC) / 256;

View file

@ -50,8 +50,6 @@
#include "max326_lowputc.h"
#include "max326_serial.h"
#include <arch/board/board.h>
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/

View file

@ -25,7 +25,6 @@
****************************************************************************/
#include <nuttx/config.h>
#include <nuttx/init.h>
#include <nuttx/cache.h>
#include <nuttx/init.h>

View file

@ -45,7 +45,6 @@
#include <errno.h>
#include <debug.h>
#include <nuttx/config.h>
#include <nuttx/progmem.h>
#include "chip.h"

View file

@ -30,7 +30,6 @@
#include <nuttx/config.h>
#include <stdbool.h>
#include <nuttx/config.h>
#include <nuttx/usb/usbdev.h>
#include <stdint.h>

View file

@ -28,9 +28,8 @@
****************************************************************************/
#include <nuttx/config.h>
#include <stdbool.h>
#include <nuttx/config.h>
#include <stdbool.h>
#include <nuttx/usb/usbdev.h>
#include <stdint.h>

View file

@ -42,7 +42,6 @@
#include "phyplus_tim.h"
#include "timer.h"
#include "mcu_phy_bumbee.h"
#include "phyplus_gpio.h"
/****************************************************************************
* Pre-processor Definitions

View file

@ -30,4 +30,8 @@ if(CONFIG_ARCH_IDLE_CUSTOM)
list(APPEND SRCS qemu_idle.c)
endif()
if(CONFIG_BUILD_KERNEL)
list(APPEND SRCS qemu_pgalloc.c)
endif()
target_sources(arch PRIVATE ${SRCS})

View file

@ -15,6 +15,7 @@ config ARCH_CHIP_QEMU_CORTEXA7
bool "Qemu virtual Processor (cortex-a7)"
select ARCH_CORTEXA7
select ARCH_HAVE_ADDRENV
select ARCH_HAVE_ELF_EXECUTABLE
select ARCH_HAVE_LOWVECTORS
select ARCH_HAVE_MULTICPU
select ARCH_NEED_ADDRENV_MAPPING

View file

@ -63,7 +63,6 @@
#include <stdlib.h>
#include <fcntl.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>

View file

@ -59,8 +59,8 @@
#define hw_claim_lock() spin_lock_irqsave(&pio_lock)
#define hw_claim_unlock(save) spin_unlock_irqrestore(&pio_lock, save)
#else
#define hw_claim_lock() spin_lock_irqsave(NULL)
#define hw_claim_unlock(save) spin_unlock_irqrestore(NULL, save)
#define hw_claim_lock() up_irq_save()
#define hw_claim_unlock(save) up_irq_restore(save)
#endif
/****************************************************************************

View file

@ -28,7 +28,6 @@
#include <stdlib.h>
#include <fcntl.h>
#include <stdlib.h>
#include <string.h>
#include <nuttx/kmalloc.h>

View file

@ -63,7 +63,6 @@
#include <stdlib.h>
#include <fcntl.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>

View file

@ -46,8 +46,8 @@
#define hw_claim_lock() spin_lock_irqsave(&pio_lock)
#define hw_claim_unlock(save) spin_unlock_irqrestore(&pio_lock, save)
#else
#define hw_claim_lock() spin_lock_irqsave(NULL)
#define hw_claim_unlock(save) spin_unlock_irqrestore(NULL, save)
#define hw_claim_lock() up_irq_save()
#define hw_claim_unlock(save) up_irq_restore(save)
#endif
/****************************************************************************

View file

@ -28,7 +28,6 @@
#include <stdlib.h>
#include <fcntl.h>
#include <stdlib.h>
#include <string.h>
#include <nuttx/kmalloc.h>

View file

@ -47,7 +47,6 @@
#include "arm_internal.h"
#include "s32k1xx_edma.h"
#include "s32k1xx_pin.h"
#include "hardware/s32k1xx_dmamux.h"
#include "hardware/s32k1xx_pinmux.h"
#include "s32k1xx_flexio_i2c.h"

View file

@ -1010,7 +1010,7 @@ static void s32k1xx_lpi2c_setclock(struct s32k1xx_lpi2c_priv_s *priv,
DEBUGASSERT(src_freq != 0);
/* LPI2C output frequency = (Source Clock (Hz)/ 2^prescale) /
* (CLKLO + 1 + CLKHI + 1 + ROUNDDOWN((2 + FILTSCL) / 2^prescale)
* (CLKLO + 1 + CLKHI + 1 + ALIGN_DOWN((2 + FILTSCL)/2^prescale)
*
* Assume CLKLO = 2 * CLKHI, SETHOLD = CLKHI, DATAVD = CLKHI / 2
*/

View file

@ -32,7 +32,6 @@
#include <errno.h>
#include <debug.h>
#include <nuttx/arch.h>
#include <nuttx/arch.h>
#include "arm_internal.h"
#include "s32k1xx_pin.h"

View file

@ -37,6 +37,7 @@
#include <nuttx/arch.h>
#include <nuttx/irq.h>
#include <nuttx/timers/rtc.h>
#include <nuttx/spinlock.h>
#include <arch/board/board.h>
@ -60,6 +61,12 @@
volatile bool g_rtc_enabled = false;
/****************************************************************************
* Private Data
****************************************************************************/
static spinlock_t g_rtc_lock = SP_UNLOCKED;
/****************************************************************************
* Private Functions
****************************************************************************/
@ -247,7 +254,7 @@ int up_rtc_gettime(struct timespec *tp)
* wrapped-around.
*/
flags = enter_critical_section();
flags = spin_lock_irqsave(&g_rtc_lock);
do
{
prescaler = getreg32(S32K1XX_RTC_TPR);
@ -256,7 +263,7 @@ int up_rtc_gettime(struct timespec *tp)
}
while (prescaler > prescaler2);
leave_critical_section(flags);
spin_unlock_irqrestore(&g_rtc_lock, flags);
/* Build seconds + nanoseconds from seconds and prescaler register */
@ -296,7 +303,7 @@ int up_rtc_settime(const struct timespec *ts)
prescaler = 0;
#endif
flags = enter_critical_section();
flags = spin_lock_irqsave(&g_rtc_lock);
s32k1xx_rtc_disable();
@ -305,7 +312,7 @@ int up_rtc_settime(const struct timespec *ts)
s32k1xx_rtc_enable();
leave_critical_section(flags);
spin_unlock_irqrestore(&g_rtc_lock, flags);
return OK;
}

View file

@ -990,7 +990,7 @@ static void s32k3xx_lpi2c_setclock(struct s32k3xx_lpi2c_priv_s *priv,
DEBUGASSERT(src_freq != 0);
/* LPI2C output frequency = (Source Clock (Hz)/ 2^prescale) /
* (CLKLO + 1 + CLKHI + 1 + ROUNDDOWN((2 + FILTSCL) / 2^prescale)
* (CLKLO + 1 + CLKHI + 1 + ALIGN_DOWN((2 + FILTSCL)/2^prescale)
*
* Assume CLKLO = 2 * CLKHI, SETHOLD = CLKHI, DATAVD = CLKHI / 2
*/

View file

@ -34,6 +34,7 @@
#include <nuttx/arch.h>
#include <nuttx/irq.h>
#include <nuttx/wqueue.h>
#include <nuttx/spinlock.h>
#include <arch/board/board.h>
@ -72,6 +73,8 @@
* Private Data
****************************************************************************/
static spinlock_t g_rtc_lock = SP_UNLOCKED;
/* Callback to use when the alarm expires */
#ifdef CONFIG_RTC_ALARM
@ -654,7 +657,8 @@ int sam_rtc_setalarm(const struct timespec *tp, alarmcb_t callback)
/* Is there already something waiting on the ALARM? */
flags = enter_critical_section();
flags = spin_lock_irqsave(&g_rtc_lock);
sched_lock();
if (g_alarmcb == NULL)
{
/* No.. Save the callback function pointer */
@ -732,7 +736,8 @@ int sam_rtc_setalarm(const struct timespec *tp, alarmcb_t callback)
ret = OK;
}
leave_critical_section(flags);
spin_unlock_irqrestore(&g_rtc_lock, flags);
sched_unlock();
return ret;
}
#endif
@ -759,11 +764,13 @@ int up_rtc_gettime(struct timespec *tp)
{
/* This is a hack to emulate a high resolution rtc using the rtt */
irqstate_t flags;
uint32_t rtc_cal;
uint32_t rtc_tim;
uint32_t rtt_val;
struct tm t;
flags = spin_lock_irqsave(&g_rtc_lock);
do
{
rtc_cal = getreg32(SAM_RTC_CALR);
@ -774,6 +781,7 @@ int up_rtc_gettime(struct timespec *tp)
rtc_tim != getreg32(SAM_RTC_TIMR) ||
rtt_val != getreg32(SAM_RTT_VR));
spin_unlock_irqrestore(&g_rtc_lock, flags);
t.tm_sec = rtc_bcd2bin((rtc_tim & RTC_TIMR_SEC_MASK) >>
RTC_TIMR_SEC_SHIFT);
t.tm_min = rtc_bcd2bin((rtc_tim & RTC_TIMR_MIN_MASK) >>

View file

@ -28,16 +28,13 @@
#include <nuttx/arch.h>
#include <nuttx/irq.h>
#include <nuttx/wqueue.h>
#include <time.h>
#include <assert.h>
#include <errno.h>
#include <debug.h>
#include <nuttx/arch.h>
#include <nuttx/irq.h>
#include <nuttx/wqueue.h>
#include <arch/board/board.h>
#include "arm_internal.h"

View file

@ -670,11 +670,20 @@
#define STM32_RCC_APB1ENR_OFFSET STM32_RCC_APB1ENR1_OFFSET
#define STM32_RCC_APB1ENR STM32_RCC_APB1ENR1
#define STM32_RCC_APB1RSTR_OFFSET STM32_RCC_APB1RSTR1_OFFSET
#define STM32_RCC_APB1RSTR STM32_RCC_APB1RSTR1
#define RCC_APB1ENR_USART2EN RCC_APB1ENR1_USART2EN
#define RCC_APB1ENR_USART3EN RCC_APB1ENR1_USART3EN
#define RCC_APB1ENR_UART4EN RCC_APB1ENR1_UART4EN
#define RCC_APB1ENR_UART5EN RCC_APB1ENR1_UART5EN
#define RCC_APB1ENR_I2C1EN RCC_APB1ENR1_I2C1EN
#define RCC_APB1ENR_I2C2EN RCC_APB1ENR1_I2C2EN
#define RCC_APB1RSTR_I2C1RST RCC_APB1RSTR1_I2C1RST
#define RCC_APB1RSTR_I2C2RST RCC_APB1RSTR1_I2C2RST
#define RCC_APB1ENR_TIM2EN RCC_APB1ENR1_TIM2EN
#define RCC_APB1ENR_TIM3EN RCC_APB1ENR1_TIM3EN
#define RCC_APB1ENR_TIM4EN RCC_APB1ENR1_TIM4EN

View file

@ -48,6 +48,7 @@
#include <nuttx/net/mii.h>
#include <nuttx/net/ip.h>
#include <nuttx/net/netdev.h>
#include <nuttx/spinlock.h>
#if defined(CONFIG_NET_PKT)
# include <nuttx/net/pkt.h>
@ -651,6 +652,7 @@ static uint8_t g_alloc[STM32_ETH_NFREEBUFFERS *
static struct stm32_ethmac_s g_stm32ethmac[STM32_NETHERNET];
#ifdef CONFIG_STM32_ETH_PTP_RTC_HIRES
static spinlock_t g_rtc_lock = SP_UNLOCKED;
volatile bool g_rtc_enabled;
static struct timespec g_stm32_eth_ptp_basetime;
#endif
@ -3778,10 +3780,10 @@ static void stm32_eth_ptp_convert_rxtime(struct stm32_ethmac_s *priv)
/* Sample PTP and CLOCK_REALTIME close to each other */
flags = enter_critical_section();
clock_gettime(CLOCK_REALTIME, &realtime);
flags = spin_lock_irqsave(&g_rtc_lock);
ptptime = stm32_eth_ptp_gettime();
leave_critical_section(flags);
spin_unlock_irqrestore(&g_rtc_lock, flags);
/* Compute how much time has elapsed since packet reception
* and add that to current time.
@ -4308,7 +4310,10 @@ int up_rtc_initialize(void)
int up_rtc_gettime(struct timespec *tp)
{
irqstate_t flags;
uint64_t timestamp;
flags = spin_lock_irqsave(&g_rtc_lock);
timestamp = stm32_eth_ptp_gettime();
if (timestamp == 0)
@ -4317,12 +4322,14 @@ int up_rtc_gettime(struct timespec *tp)
* Normally we shouldn't end up here because g_rtc_enabled is false.
*/
spin_unlock_irqrestore(&g_rtc_lock, flags);
DEBUGASSERT(!g_rtc_enabled);
return -EBUSY;
}
ptp_to_timespec(timestamp, tp);
clock_timespec_add(tp, &g_stm32_eth_ptp_basetime, tp);
spin_unlock_irqrestore(&g_rtc_lock, flags);
return OK;
}
@ -4346,6 +4353,9 @@ int up_rtc_settime(const struct timespec *tp)
{
struct timespec ptptime;
uint64_t timestamp;
irqstate_t flags;
flags = spin_lock_irqsave(&g_rtc_lock);
timestamp = stm32_eth_ptp_gettime();
if (timestamp == 0)
@ -4354,6 +4364,7 @@ int up_rtc_settime(const struct timespec *tp)
* Normally we shouldn't end up here because g_rtc_enabled is false.
*/
spin_unlock_irqrestore(&g_rtc_lock, flags);
DEBUGASSERT(!g_rtc_enabled);
return -EBUSY;
}
@ -4365,6 +4376,7 @@ int up_rtc_settime(const struct timespec *tp)
ptp_to_timespec(timestamp, &ptptime);
clock_timespec_subtract(tp, &ptptime, &g_stm32_eth_ptp_basetime);
spin_unlock_irqrestore(&g_rtc_lock, flags);
return OK;
}

Some files were not shown because too many files have changed in this diff Show more