From 8b9778d57c39e01f3b884f9e921db8a56065e754 Mon Sep 17 00:00:00 2001 From: tianxin7 Date: Thu, 2 Sep 2021 14:46:31 +0800 Subject: [PATCH] fs:add _POSIX_OPEN_MAX limit to files_extend MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 田昕 workqueue: add work_foreach support Signed-off-by: ligd arch/risc-v: Rename up_fpuconfig to riscv_fpuconfig Signed-off-by: Huang Qi arch/risc-v: Use riscv_fpuconfig to enable FPU Use common function instead of chip specified code. Signed-off-by: Huang Qi riscv/bl602: Implement SPI Cmd/Data To control the Data/Command Pin on ST7789 SPI Display, the SPI Driver flips the MISO Pin as though it was a GPIO. To implement this on BL602, we reconfigure MISO from SPI Pin to GPIO Pin on the fly inside `bl602_spi_cmddata()`. When the SPI Port is deselected (after the SPI operation), we revert MISO back from GPIO Pin to SPI Pin. We implement this inside `bl602_spi_select()`. [More Details Here](https://github.com/lupyuen/st7789-nuttx#spi-cmddata) This change impacts 3 LCD drivers that call `SPI_CMDDATA()`: ST7735, ST7789, GC9A01. Previously the BL602 SPI Driver would fail with "SPI cmddata not supported" when the above drivers are used. After the change, the above drivers will set the LCD Data/Command Pin correctly. We tested this implementation of SPI Cmd/Data with NuttX ST7789 Driver and a Logic Analyser on PineCone BL602: - [Testing with Logic Analyser](https://github.com/lupyuen/st7789-nuttx#spi-cmddata) We also tested LVGL with ST7789 on PineCone BL602: - [Testing with LVGL](https://github.com/lupyuen/st7789-nuttx#run-lvgl-demo) As for regular SPI Devices that don't require SPI Cmd/Data, we tested `CONFIG_SPI_CMDDATA=y` with Semtech SX1262 SPI Transceiver on PineCone BL602: - [Testing Cmd/Data](https://github.com/lupyuen/incubator-nuttx/releases/tag/release-2022-03-29) arch/risc-v/litex: add cache_invalidate driver/mmcsd: add option to support SD/MMC PHYs that only run in 4-bit mode arch/risc-v/src/litex/litex_sdio: add litesdcard peripheral driver See the following for details on the pepheral: https://github.com/enjoy-digital/litesdcard boards/risc-v/litex/arty_a7: add SDCARD support for the Arty_A7 board boards/risc-v/litex/arty_a7: update README to include building in LITESDCARD peripheral opendir: use inode_find() instead when opendir() Signed-off-by: ligd arm/cortex-[a|r]: IRQ Switch return should with shadow SPSR The SPSR is used to store the current value of the CPSR when an exception is taken so that it can be restored after handling the exception. Each exception handling mode can access its own SPSR. User mode and System mode do not have an SPSR because they are not exception handling modes. Signed-off-by: chao.an signal: Don't do schedule_sigaction when there is no action Signed-off-by: ligd task: don't set default signal in kernal thread Signed-off-by: ligd riscv/bl602: Remove check for LCD driver `bl602_spi_cmddata()` implements SPI Cmd/Data `SPI_CMDDATA()` for only 3 LCD drivers: ST7735, ST7789 and GC9A01. This patch removes the check for LCD drivers, so that SPI Cmd/Data will work for all LCD drivers. More details: https://github.com/apache/incubator-nuttx/pull/5898 This change impacts LCD drivers that call `SPI_CMDDATA()`. Previously `SPI_CMDDATA()` would fail with `ENODEV` for LCD drivers other than ST7735, ST7789 and GC9A01. After patching, `SPI_CMDDATA()` will work correctly with all LCD drivers. We tested with LVGL and ST7789 on PineCone BL602: - [Testing with LVGL](https://github.com/lupyuen/st7789-nuttx#run-lvgl-demo) As for regular SPI Devices that don't require SPI Cmd/Data, we tested `CONFIG_SPI_CMDDATA=y` with Semtech SX1262 SPI Transceiver on PineCone BL602: - [Testing Cmd/Data](https://github.com/lupyuen/incubator-nuttx/releases/tag/release-2022-03-30) riscv/esp32c3: Remove check for LCD driver `esp32c3_spi2_cmddata()` implements SPI Cmd/Data `SPI_CMDDATA()` for only 3 LCD drivers: ST7735, ST7789 and GC9A01. This patch removes the check for LCD drivers, so that SPI Cmd/Data will work for all LCD drivers. More details: https://github.com/apache/incubator-nuttx/pull/5898 This change impacts LCD drivers that call `SPI_CMDDATA()`. Previously `SPI_CMDDATA()` would fail with `ENODEV` for LCD drivers other than ST7735, ST7789 and GC9A01. After patching, `SPI_CMDDATA()` will work correctly with all LCD drivers. This is a minor patch so no testing is needed. xtensa: Move XCHAL_SWINT_CALL definition into syscall header This is required to avoid the interface header (syscall.h) depending on the xtensa_swi.h header from the implementation Signed-off-by: Gustavo Henrique Nihei xtensa: Build OS-assisted atomic operations on ESP32-S2 ESP32-S2 lacks support for conditional load/store instructions. Signed-off-by: Gustavo Henrique Nihei risc-v/esp32c3: Fix inclusion of C++ constructors/destructors table RISC-V GCC is configured with --enable-initfini-array so it emits an .init_array section instead of .ctors Signed-off-by: Gustavo Henrique Nihei xtensa|risc-v: Make CXX exception and RTTI depend on Kconfig options Signed-off-by: Gustavo Henrique Nihei libcxx: Add patch for preventing redefinition of PS macro on Xtensa Signed-off-by: Gustavo Henrique Nihei libcxx: Fix libc++ for archs without conditional load/store support This commit brings a patch already merged to upstream LLVM project: https://reviews.llvm.org/D118391 Signed-off-by: Gustavo Henrique Nihei esp32[s2/s3/c3]: Add defconfigs for testing C++ Signed-off-by: Gustavo Henrique Nihei arch/arm: Make CXX exception and RTTI depend on Kconfig options Signed-off-by: Gustavo Henrique Nihei documentation: Add release notes for 10.3.0 release This is a local copy taken from the confluence notes https://cwiki.apache.org/confluence/display/NUTTX/NuttX+10.3 Signed-off-by: Alin Jerpelea fs/romfs: fix bug about compare path with same prefix Signed-off-by: Jiuzhu Dong boards/boardctl:common boardctl to read reset cause. Signed-off-by: 田昕 rptun: set rptun thread default stack size to 4K Signed-off-by: ligd rptun: add rptun_force_panic support Signed-off-by: ligd rptun: add rptun_reset support Signed-off-by: ligd rptun: use HPWORK instead of thread Signed-off-by: ligd rptun: add rptun_panic for both master & salve Signed-off-by: ligd rptun: add rpmsg_wait/post support for recursive dispatch Signed-off-by: ligd rptun: divide shram to TX & RX Signed-off-by: ligd rptun: add rptun dump support Signed-off-by: ligd rptun: pm_stay when send msg & pm_relax when all tx buffer returned Signed-off-by: ligd rptun: enable rx interrupts for virtq use wait_tx_buffer method need enable rx interrupts Signed-off-by: ligd rptun: add ping rpmsg support Signed-off-by: ligd openamp: add openamp patches 0006-openamp-fix-scenario-case.patch 0007-openamp-divide-shram-to-TX-shram-RX-shram.patch 0008-rpmsg_virtio-don-t-need-check-status-when-get_tx_pay.patch Signed-off-by: ligd rptun: forward panic/reset to lowerhalf Signed-off-by: ligd remove DISCLAIMER-WIP most licenses have been converted to Apache and the non Apache licenses have been documented. We can assume that now it should be the time to remove DISCLAIMER-WIP Signed-off-by: Alin Jerpelea arch/risc-v/mpfs: Remove duplicated riscv_restorefpu Signed-off-by: Huang Qi ioe_rpmsg: use rptun_wait/post to resolve deadlock with usrsock Signed-off-by: ligd arch/risc-v: Store/Restore FPU register in exception_common Signed-off-by: Huang Qi arch/risc-v: Rename up_doirq to riscv_doirq Signed-off-by: Huang Qi arch/risc-v: Remove deprecated logic from riscv_doirq Signed-off-by: Huang Qi arch/risc-v: Merge duplicated logic by riscv_doirq Signed-off-by: Huang Qi arch/risc-v: Dont' disable/enable irq in riscv_doirq Since these codes added to all chips but not fully tested, so we should changd this behavior. Signed-off-by: Huang Qi arch/risc-v: Remove unneeded group_addrenv call which handled by riscv_doirq Signed-off-by: Huang Qi arch/risc-v: move REGLOAD/REGSTORE macro to riscv_internal.h Signed-off-by: Petro Karashchenko arch/risc-v: include csr.h indirectly through nuttx/irq.h Signed-off-by: Petro Karashchenko arch/risc-v: fix ARCH_RV32 offset for the stub lookup table calculation Signed-off-by: Petro Karashchenko mm/mm_heap: place alloc-bit at the LSB of node->preceeding. Heap always allocate the memory at least 2bytes alignment. Signed-off-by: wangbowen6 mm_heap: heapsize align with MM_MIN_CHUNK. Signed-off-by: wangbowen6 driver/syslog: Add microseconds after date time Signed-off-by: Jiuzhu Dong ARCH_ADDRENV: Add guard against mis-configuration When process a is switched to process b, the address environment is swapped with a call to group_addrenv(). The stack upon entry will be a's, and upon exit b's. This will fail, so a neutral stack is required, either a kernel stack or an IRQ stack. Infrastructure for an IRQ stack is already in place, so give a hint that an interrupt stack should be provided if address environments are enabled. arch/risc-v: get wider visibility for arch instruction macros Signed-off-by: Petro Karashchenko rpmsgfs: add wait ready to rpmsgfs Signed-off-by: ligd rpmsgfs: add timeout when mount in rpmsgfs Signed-off-by: ligd rpmsgfs: use rptun_wait/post to resolve deadlock with usrsock Signed-off-by: ligd sigact: get free sigact from freelist always successful Signed-off-by: Jiuzhu Dong netdev_file_ioctl: Fix fcntl F_SETFL O_NONBLOCK regression This fixes a regression caused by the following commit, which prevents the file flag from being updated. ``` commit 28860b5242dd5efd86b5da8a089e5d898cd8a9a1 Author: chao.an Date: Sat Mar 19 14:47:37 2022 +0800 net/netdev: fix switch case missing break Signed-off-by: chao.an ``` Note: some applications like mbedtls uses F_GETFL to confirm the nonblock-ness of the socket. This is critical for such applications. nuttx: Add "#include " to tioctl.h Signed-off-by: zhouliang3 fs/unionfs: fix bug about use after free about ui Signed-off-by: Jiuzhu Dong fs/unionfs: check return value to avoid unused value Signed-off-by: Jiuzhu Dong fs/unionfs: add sanity check for parameter if relpath is NULL, it will cause system crash: unionfs_opendir with relpath NULL -> unionfs_tryopendir -> unionfs_offsetpath -> strncmp(prefix, relpath, pfxlen Signed-off-by: Jiuzhu Dong SEGGER_RTT: solve compile error when enable segger rtt in armv7m. 1. SEGGER_RTT_ASM_ARMv7M include SEGGER_RTT.h, and SEGGER_RTT.h include SEGGER_RTT_Conf.h, so add __ASSEMBLY__ in SEGGER_RTT_Conf.h; 2. AFLAG add segger/config because SEGGER_RTT_ASM_ARMv7M.S include SEGGER_RTT_Conf.h; Signed-off-by: wangbowen6 fs/procfstcbinfo: minor bug about print address Signed-off-by: Jiuzhu Dong fs/romfs: fix string overflow when the length of rn_name exceeds NAME_MAX + 1 Signed-off-by: Jiuzhu Dong fs and unistd: increase OPEN_MAX by claiming a Kconfig. Signed-off-by: 田昕 rpmsgfs: do NOT access the pointer when do remote ioctl Signed-off-by: ligd fs/rpmsgfs: fix bug about using uninit variable "times" Signed-off-by: Jiuzhu Dong arch/xtensa: add syscall note support in the flat build Signed-off-by: chao.an sched/note: unify the data format Signed-off-by: chao.an sched/trace: correct the note print format note print should with Instruction pointer. e.g: trace_printk("hello NuttX"); trace dump: hello-6 [000] .... 23080.367994: 0xc044a005: hello NuttX Signed-off-by: chao.an sched/note: add support of trace section mark The implementation of this feature is based on android systrace: https://source.android.com/devices/tech/debug/ftrace Application developers are more concerned about the performance of the specified application section, added two APIs to implement performance measurement: void sched_note_begin(uintptr_t ip, FAR const char *buf); void sched_note_end(uintptr_t ip, FAR const char *buf); or SCHED_NOTE_BEGIN(); /* defined to sched_note_begin(_THIS_IP_, __FUNCTION__) */ SCHED_NOTE_END(); /* defined to sched_note_end(_THIS_IP_, __FUNCTION__) */ Signed-off-by: chao.an unistd:rename CONFIG_OPEN_MAX to CONFIG_LIBC_OPEN_MAX Signed-off-by: 田昕 sim: Fix init of static C++ constructors when using glibc >= 2.34 glibc 2.34 changed the dynamic linker behavior during the startup process, which makes the previous "__init_array_start" replacement trick non-effective. Now the dynamic linker parses the constructors/destructors information from the DYNAMIC segment of the program. Signed-off-by: Gustavo Henrique Nihei libs/libc/lib_err.c:add va_end to vwarn call va_copy,after need call va_end Signed-off-by: anjiahao local socket: cancel assert about backlog exceed 255 Signed-off-by: zhanghu6 net/local: change 255 to UINT8_MAX Signed-off-by: Xiang Xiao power: unify lock states unify critical_section and nxsem with pm_lock/pm_unlock Signed-off-by: zhuyanlin power:driver: move pm_auto_update to outer dir Pm_auto_update maybe called by outter PM users Signed-off-by: zhuyanlin lib_chdir:use change ret judgment method Signed-off-by: anjiahao modlib/modlib_bind:fix unsigned_compare with zero Signed-off-by: anjiahao Update libs/libc/modlib/modlib_bind.c u are right Co-authored-by: Petro Karashchenko Update libs/libc/modlib/modlib_bind.c Co-authored-by: Petro Karashchenko mmcsd: Add gotextcsd callback to sdio_dev_s so the driver implementation could get critical EXTCSD info Signed-off-by: anjianjun mmcsd: Move SDIO_GOTEXTCSD after SDIO_DMASENDSETUP Signed-off-by: Xiang Xiao mmcsd: Fix mmc card error but system can not catch it Signed-off-by: anjianjun risc-v/esp32c3: Fix regression on IRQ handling for ECALL instruction Signed-off-by: Gustavo Henrique Nihei RISC-V: Implement option to run NuttX in supervisor mode (S-mode) - Add config "ARCH_USE_S_MODE" which controls whether the kernel runs in M-mode or S-mode - Add more MSTATUS and most of the SSTATUS register definitions - Add more MIP flags for interrupt delegation - Add handling of interrupts from S-mode - Add handling of FPU from S-mode - Add new context handling functions that are not dependent on the trap handlers / ecall NOTE: S-mode requires a companion SW (SBI) which is not yet implemented, thus S-mode is not usable as is, yet. RISC-V: Implement skeleton for a per CPU structure It might be useful to store things in memory per CPU. The tricky part is that all CPUs run the same code and see the same memory, so some kind of centralized access is required. For now, the structure contains the hart id. Access to the structure elements is provided via sscratch, which is unique for every hart! Fix ESP32-C3 toolchain download link arch/xtensa: Add xtensa_tcbinfo struct that contains helpful offsets. Signed-off-by: Abdelatif Guettouche fix:Temporarily remove udp send large pkt assert Signed-off-by: zhanghongyu net: tcp/udp/icmp/icmpv6 add FIONSPACE support Signed-off-by: zhanghongyu timerexpiration:fix DEADCODE when RR_INTERVAL or SCHED_SPORADIC not select tmp is always true for CONFIG_RR_INTERVAL > 0 and CONFIG_SCHED_SPORADIC not select Signed-off-by: zhuyanlin arch/riscv: Align the macro definition in csr.h Signed-off-by: Xiang Xiao arch/riscv: Rename riscv_syscall_dispatch to riscv_dispatch_syscall follow other function naming(e.g. riscv_dispatch_irq) Signed-off-by: Xiang Xiao arch/riscv: Remove riscv_sbi.c since it doesn't exist Signed-off-by: Xiang Xiao arch/riscv: Rename riscv_exception_macros.S to riscv_macros.S since macro defined in this file is also used in the normal context Signed-off-by: Xiang Xiao arch/riscv: Access [m|s]scratch through CSR_SCRATCH macro Signed-off-by: Xiang Xiao arch/riscv: Rename g_scratch to g_percpu Signed-off-by: Xiang Xiao sched_note: fix buffer size warning in coverity Signed-off-by: zhuyanlin mod_insmod: fix coverity warning Signed-off-by: zhuyanlin stm32: add support for up_perf boards/nucleo-f446re: initialize up_perf note_sysview.c: fix compilation for CONFIG_TASK_NAME_SIZE == 0 note_sysview.c: fix compilation if CONFIG_SCHED_INSTRUMENTATION_FILTER not defined arm/chip: add backtrace support for all chips that support thumb instruction set. Signed-off-by: wangbowen6 usrsock: Move event field to usrsock_message_common_s Signed-off-by: zhanghongyu net:fix coverity warning Signed-off-by: hejianliang3 stm32u5: stm32_stdclockconfig fixes Fix stm32_stdclockconfig for stm32u585xx to the extend that the B-U585I-IOT02A board's clock tree can be configured. This board uses the MSIS as PLL1's input clock and the LSE to autotrim the MSIS. b-u585i-iot02a: Fix stdclock initialization Correct the respective defines to initialize the B-U585I-IOT02A clock tree correctly by means of stm32_stdclockconfig(). b-u585i-iot02a:nsh: Drop TrustedFirmware-M dependency Make the nsh defconfig for the b-u585i-iot02a run stand-alone (i.e. not as a companion that relies on TF-M doing low-level board initialization). net/utils: fix IPv4 checksum calculation Signed-off-by: Petro Karashchenko arch/risc-v: use STACK_FRAME_SIZE for in S-mode syscall asm Signed-off-by: Petro Karashchenko arch/riscv: Rename SCRATCH_HARTID_OFFSET to RISCV_PERCPU_HARTID_OFFSET and fix the typo error Signed-off-by: Xiang Xiao modlib_bind.c: Restore "Relocation address out of range" checks Restore the checks which got completely broken by the following change. ``` commit 15142a8b106bee8db6ac744b963969feba5c8289 Author: anjiahao Date: Fri Apr 1 16:20:03 2022 +0800 modlib/modlib_bind:fix unsigned_compare with zero Signed-off-by: anjiahao ``` syscall: Fix Makefile:69: target 'syscall_names.o' given more than once in the same rule Signed-off-by: Xiang Xiao libc/netdb: Support the recursive lock Signed-off-by: Xiang Xiao libc/netdb: Remove the temporary unlock in dns_foreach_nameserver since netdb support the recursive lock Signed-off-by: Xiang Xiao libc/netdb: Hold dns lock when operating with resolv.conf Signed-off-by: Xiang Xiao arch/xtensa: Build the xtensa_tcbinfo.c file for S2 and S3. Signed-off-by: Abdelatif Guettouche nuttx: unify FAR attribute usage across the code Signed-off-by: Petro Karashchenko RISC-V: Fix file name of riscv_dispatch_syscall RISC-V: Fix usage of static_assert in riscv_percpu.c There is no alias for struct riscv_percu_s Update cpp_cmake.rst update CMAKE_C_FLAGS when compile C file Update cpp_cmake.rst openamp: Change the dependence from OPENAMP to RPTUN since all rpmsg driver need the extension api exposed by rptun driver Signed-off-by: Xiang Xiao libc/string: Fix the minor style issue Signed-off-by: Xiang Xiao libc: Avoid the compiler generate code call self(memcpy/memmove/memset/memcmp) recursively please reference the similar change done by other libc implementation: https://reviews.llvm.org/D68028?id=224286 https://github.com/bminor/glibc/commit/85c2e6110c9a01ec817c30f1b7e20549d7229987 https://github.com/bminor/musl/commit/4a1f55e92fa74ee382909baa96302231f566b5e1 https://github.com/bminor/newlib/commit/82dfae9ab0734b9946321590162dc6021057fec1 Signed-off-by: Xiang Xiao arch:tcbinfo: update tcbinfo as xcpcontext update Signed-off-by: zhuyanlin jlink-nuttx: update regs as nuttx regs save path change Signed-off-by: zhuyanlin include/nuttx: remove double definitions of UNUSED macro Signed-off-by: Petro Karashchenko fix uinput rpmsg logic error xtensa/esp32: Add support to TWAI/CANBus controller esp32: Add board support to TWAI/CANBus arch/sim: support simulator keyboard devices arch/risc-v: Replace riscv_fault with riscv_exception Remove riscv_fault since its code is duplicated with riscv_exception, and there are textual excpetion reason in riscv_exception. Signed-off-by: Huang Qi fs/epoll: change type of eventset from uint8_t to uint32_t to support EPOLLONESHOT and so on. Signed-off-by: Jiuzhu Dong fs/poll: change format for type pollevent_t Signed-off-by: Jiuzhu Dong lib_lib_vsprintf/backtrace: fix the type issue using 't': For integer types, causes printf to expect a ptrdiff_t-sized integer argument. Signed-off-by: Jiuzhu Dong fs/poll: change format for type pollevent_t complete the following commits: commit d87cf8d4ca5fe69c71c131015a7b64b68c917593 Author: Jiuzhu Dong Date: Fri Apr 1 20:59:55 2022 +0800 fs/poll: change format for type pollevent_t Signed-off-by: Jiuzhu Dong commit d535943a69f03033b077cb95cce162bb28b40b56 Author: Jiuzhu Dong Date: Fri Apr 1 17:49:10 2022 +0800 fs/epoll: change type of eventset from uint8_t to uint32_t to support EPOLLONESHOT and so on. Signed-off-by: Jiuzhu Dong Signed-off-by: chao.an arch/risc-v: Remove the unnecessary inclusion of board header files Signed-off-by: Xiang Xiao MPFS: Prepare support for S-mode - Access to PLIC via S-mode registers - Access to IRQs via S-mode registers / definitions - Initialize S-mode registers upon boot - Initialize per CPU area before nx_start NOTE: S-mode requires a companion SW (SBI) which is not yet implemented, thus S-mode is not usable as is, yet. esp32c3: Simplify irq dispatch logic ESP32C3 use customized irq encoding so it's hard to share further code with other risc-v based chips, in this patch, we keep the exception number definition with risc-v spec. Signed-off-by: Huang Qi Documentation/guides/pysimcoder.rst: update pysimCoder dependencies CONFIG_LIBM option may be required by some toolchains that do not include standard math library. Morover CONFIG_PTHREAD_STACK_MIN was listed twice in the list. Signed-off-by: Michal Lenc arch/riscv: Minor style change and text correction Signed-off-by: Huang Qi sched/pthread:need check pthread is DETACHED pthread_join need check thread is DETACHED, Whether to wait according to the result.And, if a thread is DETACHED,it will not set a new attr. Signed-off-by: anjiahao sched/note: add dummy definition if CONFIG_SCHED_INSTRUMENTATION disabled Signed-off-by: chao.an sched/note: correct flatten format Signed-off-by: chao.an arm/armv[7|8]-m: skip the fpu save/restore if stack frame is integer-only Signed-off-by: chao.an fs/vfs: fix st_mode mask check The full mask for st_mode is 0177777 Now modify any file permissions in hostfs and all will fail arch/risc-v: Add handler for misaligned load/store Some risc-v based chips don't support unaligned data access, it will trigger a exception and then lead to crash. In this patch, we handle the misaligned access by software to make system run continue. Signed-off-by: Huang Qi tools/checkrelease.sh: Don't check DISCLAIMER-WIP anymore since all license is clean up now Signed-off-by: Xiang Xiao sched/wqueue: Simplify CALL_WORKER dispatch condition Signed-off-by: Xiang Xiao sched/irq: Remove CONFIG_SCHED_IRQMONITOR when define CALL_VECTOR since up_perf_ API doesn't couple with CONFIG_SCHED_IRQMONITOR Signed-off-by: Xiang Xiao sched/irq: Fix array overrun in coverity check Signed-off-by: Xiang Xiao boards/nucleo-h743zi2: Enable up_perf API Signed-off-by: Xiang Xiao boards/lx_cpu: Enable up_perf API Signed-off-by: Xiang Xiao arch/risc-v: Align prototype of riscv_exception with xcpt_t Thus we can attach it to irq handler without any cast. Signed-off-by: Huang Qi arch/risc-v: Attach exception handler in common place Signed-off-by: Huang Qi arch/risc-v: Move epc adjustment to riscv_doirq Signed-off-by: Huang Qi checkpatch.sh: add -m option to enable/disable Change-Id check Defaultly disable Change-Id check in commit message. Signed-off-by: liuhaitao .github/workflows/check.yml: Enable Change-ID check explicitly Signed-off-by: Xiang Xiao Make top Make.defs symlink to board Make.defs instead Symlink to board Make.defs for top Make.defs, so top Make.defs syncs in realtime. Signed-off-by: liuhaitao riscv/riscv_exception_commin.S: Don't call riscv_hartid in single core mode. Signed-off-by: Abdelatif Guettouche riscv/riscv_exception_common.S: Allow chips to define the exception section. Signed-off-by: Abdelatif Guettouche riscv/esp32c3: Use the common exception handler. Signed-off-by: Abdelatif Guettouche riscv/bl602/chip.h: Add assembly guards for standard includes. tools/mkdeps: Extend MAX_SHQUOTE to 3072 Signed-off-by: nietingting audio: Return audio_lowerhalf_s pointer instead error code in audio_comp_initialize audio: Don't register audio device if name isn't given in audio_comp_initialize Signed-off-by: Xiang Xiao Fixes some issues with the implementation of the balance functionality. In function "wm8904_hw_reset" the priv->balance is initialized with b16HALF, indicating a range from 0 to b16ONE. In function "wm8904_setvolume" the assumed range for priv->balance is between 0 and 1000. The changes now make this consistent for 0 to b16ONE-1. Furthermore, in wm8904_configure the change of balance was not implemented. Minor fix, function name was wm8994_setvolume instead of wm8904_setvolume. Fixed source code format errors. Revert "mm_heap: heapsize align with MM_MIN_CHUNK." This reverts commit 69e69740b5f578e035befc762538b282d91ed1ba. mm_initialize: malloc() return aligend pointer. malloc() should return aligned (with MM_MIN_CHUNK) pointer, but pr #5906 destroy that, this pr find a better method to solve these questions. Signed-off-by: YAMAMOTO Takashi and Signed-off-by: wangbowen6 arch/riscv: Add mtimer driver Signed-off-by: Xiang Xiao sched/note: include-able from C++ files Signed-off-by: chao.an drivers/sensors: Add new driver for scd41 sensor module Add Sensirion's SCD41 CO2, temperature and humidity sensor driver. drivers/sensors/scd30: Fix invalid parameter check Fix invalid parameter check and redundant conditions. drivers/sensors/sgp30: Fix redundant parameter check Fix redundant conditions. littelfs: deal with block devices w/o ioctl Note: Some block devices has ioctl == NULL. eg. drivers/loop netdb/lib_dnsaddserver.c: Do not insert the duplicate DNS address Signed-off-by: songlinzhang graphics/nxterm: Avoid accessing freed memory Fix accessing freed priv data. drivers/syslog: update description if Kconfig Signed-off-by: Petro Karashchenko libc/lib_localtime:fix deadcode isdst always is false Signed-off-by: anjiahao RISC-V: Combine 3 variables that depend on CPU amount into one IRQ_NSTACKS, ARCH_CPU_COUNT, CONFIG_SMP_NCPUS all relate to each other. However, a bit of clean up can be done and everything can be merged into SMP_NCPUS. The MPFS bootloader case works also as it requires only 1 IRQ stack for the hart that executes as bootloader. RISC-V: Remove riscv_cpuindex.c from platforms that don't need it riscv_mhartid is no longer called by exception_common, so can remove this file from platforms that don't need it. Also fixes make warning: Makefile:123: target 'riscv_cpuindex.o' given more than once in the same rule RISC-V: Add setintstack for k210 and qemu This fixes CI issue, and I think the old implementation with SMP shared 1 IRQ stack for multiple CPUs. sched/init: drivers_initialize() should be late than up_initialize() up_initialize | ->up_serialinit | ->uart_register /* ("/dev/console", &CONSOLE_DEV); */ drivers_initialize | ->syslog_console_init | ->register_driver /* ("/dev/console", &g_consoleops, 0666, NULL); */ Signed-off-by: chao.an arch: cxd56xx: update loader and gnssfw version Update loader and gnssfw to version 2.2.20585 cxd56xx/cxd56_emmc.c: Fix compile warning Add necessary include header named debug.h for using ferr and finfo. arch: cxd56xx: Fix critical section in scu driver Add critical section to scu one-shot sequencer. boards: cxd56xx: Fix an issue i2c tool not working It caused i2c tool not to work due to i2c uninitializing processing. Since this process is not necessary in the normal case, we will move it to the error case. boards: cxd56xx: Make board_late_initialize a weak function Add a weak_function to the board_late_initialize function so that it can be replaced by another file, such as a user application. board/spresense: Add pin selection of ILI934x Add Kconfig choice for selecting RST and DC pins on ILI934x LCD. boards: cxd56xx: Add board function for scd41 sensor driver Add board function for SCD41 CO2, temperature and humidity sensor driver. cxd56/spresense: Add callback mechanism to notice SDCard injection Add a mechanism to callback to an application to notice the SDCard status is changed (inserted or ejected). .github/gcc.json: Fix space/tab inconsistency sim: bt: Add specific bluetooth HCI number id Add option for attached the local bluetooth device use specific bluetooth HCI number id. Signed-off-by: Lingao Meng lib_localtime:fix unsigned compare with zero Signed-off-by: anjiahao arch/risc-v: Apply common mtime driver to mtime based chps Signed-off-by: Huang Qi risc-v/c906: fix build break chip/c906_timerisr.c: In function 'up_timer_initialize': Error: chip/c906_timerisr.c:71:3: error: implicit declaration of function 'DEBUGASSERT' [-Werror=implicit-function-declaration] DEBUGASSERT(lower); ^~~~~~~~~~~ cc1: all warnings being treated as errors Signed-off-by: chao.an libc/lib_glob:use strlcpy instead of memcpy Signed-off-by: anjiahao libc/net:use strlcpy instead of strncpy Signed-off-by: anjiahao arch/risc-v: Add missing DMB to mtimer / setmtimecmp The memory mapped mtimecmp lives in I/O space so must add barrier to make sure the value sticks. Otherwise a new IRQ might fire at once. arch/risc-v: Apply misaligned access handler for k210/bl602 Signed-off-by: Huang Qi arch/riscv: Move toolchain config to arch/risc-v/Kconfig like xtensa Signed-off-by: Xiang Xiao riscv/riscv_schedulesigaction.c: Remove the duplicate state saving. Signed-off-by: Abdelatif Guettouche arch/arm: Move FPU initialization to common place Signed-off-by: Xiang Xiao arch/stack_color: correct the end address of stack color The different optimization of compilers will cause ambiguity in obtaining sp through up_getsp() in arm_stack_color(), if compile with clang and enable the optimization flag (-Ofast), up_getsp() call will be earlier than push {r0-r9,lr}, the end address of color stack will overlap with saved registers. Compile line: clang --target=arm-none-eabi -c "-Ofast" -fno-builtin -march=armv8.1-m.main+mve.fp+fp.dp \ -mtune=cortex-m55 -mthumb -mfpu=fpv5-d16 -mfloat-abi=hard -D__NuttX__ -common/arm_checkstack.c -o arm_checkstack.o Assembler code: llvm-objdump -aS arm_checkstack.o ------------------------------------ |00000000 : |; start = INT32_ALIGN_UP((uintptr_t)stackbase); | 0: c2 1c adds r2, r0, #3 | 2: 22 f0 03 02 bic r2, r2, #3 |; end = nbytes ? INT32_ALIGN_DOWN((uintptr_t)stackbase + nbytes) : | 6: 19 b1 cbz r1, 0x10 @ imm = #6 | 8: 08 44 add r0, r1 | a: 20 f0 03 00 bic r0, r0, #3 | e: 00 e0 b 0x12 @ imm = #0 |; __asm__ | 10: 68 46 mov r0, sp <--- fetch the sp before push {r7 lr} | 12: 80 b5 push {r7, lr} <--- sp changed |; nwords = (end - start) >> 2; | 14: 80 1a subs r0, r0, r2 | 16: 80 08 lsrs r0, r0, #2 |; } | 18: 08 bf it eq | 1a: 80 bd popeq {r7, pc} | 1c: 4b f6 ef 63 movw r3, #48879 | 20: cd f6 ad 63 movt r3, #57005 | 24: a0 ee 10 3b vdup.32 q0, r3 |; while (nwords-- > 0) | 28: 20 f0 01 e0 dlstp.32 lr, r0 |; *ptr++ = STACK_COLOR; <--- overwrite | 2c: a2 ec 04 1f vstrw.32 q0, [r2], #16 | 30: 1f f0 05 c0 letp lr, 0x2c @ imm = #-8 |; } | 34: 80 bd pop {r7, pc} ------------------------------------ Signed-off-by: chao.an arm/armv8-m: indicating no low-overhead-loop predication by default Fix usage fault on clang version 13.0.0 (-Ofast): ------------------------------------------------------------------ | arm_hardfault: Hard Fault escalation: | arm_usagefault: PANIC!!! Usage Fault: | arm_usagefault: IRQ: 3 regs: 0x3c58c510 | arm_usagefault: BASEPRI: 00000080 PRIMASK: 00000000 IPSR: 00000003 CONTROL: 00000004 | arm_usagefault: CFSR: 00020000 HFSR: 40000000 DFSR: 00000000 BFAR: 01608050 AFSR: 00000000 | arm_usagefault: Usage Fault Reason: | arm_usagefault: Invalid state | up_assert: Assertion failed at file:armv8-m/arm_usagefault.c line: 113 task: lpwork | backtrace: | [ 2] [<0x2c58124a>] up_backtrace+0xa/0x2e2 | [ 2] [<0x2c56f7cc>] sched_dumpstack+0x28/0x66 | [ 2] [<0x2c580cd0>] up_assert+0x62/0x254 | [ 2] [<0x2c56ab8a>] _assert+0/0xa | [ 2] [<0x2c55575a>] nxsched_add_prioritized+0x38/0xa2 | [ 2] [<0x2c555894>] nxsched_add_blocked+0x2e/0x44 | [ 2] [<0x2c580748>] up_block_task+0x2a/0x96 | [ 2] [<0x2c5569ea>] nxsem_wait+0x64/0xb4 | [ 2] [<0x2c556a40>] nxsem_wait_uninterruptible+0x6/0x10 | [ 2] [<0x2c559b9a>] work_thread+0x1c/0x48 ------------------------------------------------------------------- usage fault on 0x2c55575a: ------------------------------------ |2c555722 : |; { |2c555722: 80 b5 push {r7, lr} |... |2c55575a: 2f f0 17 c0 le 0x2c555732 @ imm = #-44 |... ------------------------------------ Arm v8-M Architecture Reference Manual: C2.4.103 LE, LETP B3.28 Low overhead loops: An INVSTATE UsageFault is raised if a LE instruction is executed and FPSCR.LTPSIZE does not read as four. When a new floating-point context is created and FPCCR.ASPEN is set to zero it is the responsibility of software to correctly initialize FPSCR.LTPSIZE. Signed-off-by: chao.an fs/vfs/fs_truncate.c: Use ioctl to truncate on non-mountpoint inode Signed-off-by: Jukka Laitinen libc/time: add strptime porting support lib_strptime.c copies from android bionic/libc/tzcode. Signed-off-by: liuhaitao Signed-off-by: anjiahao libc/strptime:_conv_num skip space Signed-off-by: anjiahao libc/strptime: fix warning unused-value warning: value computed is not used [-Wunused-value] Signed-off-by: Xiang Xiao Signed-off-by: anjiahao libc/lib_strptime:change code format & add notes Signed-off-by: anjiahao RISC-V: Move mhartid to own assembly macro+function Hartid and cpuindex are not the same thing. Hartid is needed regardless of SMP, for external interrupt handling etc. SMP needs cpuindex which might not be index == hartid, so both are needed. IMO it is clearer to provide separate API for both. Currently the implementation of up_cpu_index is done a bit lazily, because it assumes hartid == cpu index, but this is not 100% accurate, so it is still missing some logic. arch/risc-v/riscv_misaligned: Correct sw source register If source register of sw instruction is x0, we must point it to a constant zero since in NuttX's context, value of index 0 is EPC. Signed-off-by: Huang Qi arch/risc-v: Correct format of 32-bit insn in misaligned handler FIx: Format specifies type 'unsigned long' but the argument has type 'uint32_t' (aka 'unsigned int') Signed-off-by: Huang Qi power/governor: Remove the duplicated function prototype since they are declared include/nuttx/power/pm.h by: commit 5ce181e6b702cedbd79790fbe40aab7d29dae7c0 Author: zhuyanlin Date: Mon Feb 14 15:32:40 2022 +0800 power:govorner: add govorner to per domain. For mult domains scene,, activity and greety can be used at same time. Let user to select domain governor. Signed-off-by: zhuyanlin and add static const to g_pmgovernor Signed-off-by: zhuyanlin drivers/power: Remove activity_governor.h and greedy_governor.h since they aren't really used anymore Signed-off-by: Xiang Xiao MPFS: Fix mtimecmp address MTIMECMP0 was incorrect MPFS: Use riscv_exception_attach like the others do Exception / fault handling goes to unexpected ISR, fix by setting the common ISR handlers like all other RISC-V platforms do. arch: Fix compile error when enabling CONFIG_DUMP_ON_EXIT "error: incompatible types when assigning to type 'struct filelist *' from type 'struct filelist' filelist = tcb->group->tg_filelist;" Signed-off-by: Abdelatif Guettouche arch: Move the DUMP_ON_EXIT logic after nxtask_exit. Otherwise we will try to dump the state of the current task, however the exit handler has already started doing some cleanup and invalidated its group. Accessing the group from dumponexit will crash. Signed-off-by: Abdelatif Guettouche arch/Kconfig: Move the DUMP_ON_EXIT option out of the Bring-up group. Signed-off-by: Abdelatif Guettouche sched/pthread_create:fix bug,delete data_sem if a pthread set attr is detach,and when call pthread_create, new thread exit quikly,new thread's tcb be free,then pthread_create use new thread's tcb will crash. Signed-off-by: anjiahao rpmsg_usrsock: Support the wireless ioctl which contain pointer 1/2 Signed-off-by: zhanghongyu fix: usrsock iovec_do skip empty iov Signed-off-by: zhanghongyu sched/environ: Ensure tg_envp terminated by double '\0' so we can compute the whole environ string length from it Signed-off-by: Xiang Xiao RISC-V: Add SBI glue logic Currently only stubs for mtime handling added, with a gentle reminder that the actual implementation is still missing. RISC-V: mtimer register via SBI when S-mode is in use Cannot access the memory mapped registers directly when the kernel runs in S-mode, must forward the access to SBI. arch/[arm|sparc]: replace INT32_ALIGN_* to STACK_ALIGN_* Signed-off-by: chao.an arch/stack_color: correct the stack top of running task This PR to ensure the stack pointer is locate to the stack top Signed-off-by: chao.an arm/rtl8720c: Remove up_getsp which is already implemented in arch/arm/arch.h Signed-off-by: Xiang Xiao MPFS: Set correct interrupt per mode (M-/S-mode) for mtimer libc/string: Use Byte-Shift algorithm for very long needles Reference here: https://github.com/taleinat/byteshift_strstr Signed-off-by: chao.an Signed-off-by: anjiahao libc/string:delete small to big endian marco avoid byte alignment Signed-off-by: haopengxiang Signed-off-by: anjiahao libc/string:add LICENSE info Signed-off-by: anjiahao Add SPIRAM to ESP32-S2 driver/mmcsdio: do not hold the semaphore on interrupt context so we can do the full dump to mmc/sd card in the panic case Signed-off-by: chao.an driver/mmcsdio: do not hold the semaphore in idle thread too Signed-off-by: Xiang Xiao fs/fcntl: add O_APPEND flag judge in fcntl Signed-off-by: liuhaitao vfs/fcntl: Minor style fix Signed-off-by: Xiang Xiao arm/armv7-[a|r]: move fpu save/restore to assembly handler Save/Restore FPU registers in C environment is dangerous practive, which cannot guarantee the compiler won't generate the assembly code with float point registers, especially in interrupt handling Signed-off-by: chao.an arch/arm/src/sam34/sam_hsmci.c: delay required after sending command arch/arm/src/sam34/sam_hsmci.c: DMA setup before write is required arch/arm/src/sam34/sam_hsmci: DMA also present on SAM3X chips arch/arm/src/sam34/sam_hsmci.c: SAM3X GPIO setup arch/arm/src/sam34/Kconfig: fix typo in device name boards/arm/a1x: Remove the check CONFIG_ARCH_FPU around arm_fpuconfig forget in below change: commit df5a8a53ae92606e2d65149c6b5159b82dfc5d76 Author: Xiang Xiao Date: Tue Apr 12 03:18:46 2022 +0800 arch/arm: Move FPU initialization to common place Signed-off-by: Xiang Xiao Signed-off-by: Xiang Xiao boards/esp32_twai: Remove arm_arch.h from comment Signed-off-by: Xiang Xiao drivers: remove unimplemented open/close/ioctl interfaces Signed-off-by: Petro Karashchenko arch/risc-v: Use fs status definition from csr.h Signed-off-by: Huang Qi arch/riscv/esp32c3: esp32c3_twai.h TWAI (CAN) controller registers provided by Espressif. File provided by Abdelatif Guettouche Signed-off-by: Jan Charvat arch/riscv/esp32c3: ESP32C3 TWAI (CAN) controller driver. Signed-off-by: Jan Charvat arch/riscv/esp32c3: ESP32C3 TWAI (CAN) controller included into Kconfig. Signed-off-by: Jan Charvat boards/risc-v/esp32c3: ESP32C3 TWAI (CAN) controller bringup for DevKitM-1. Signed-off-by: Jan Charvat boards/risc-v/esp32c3: ESP32C3 TWAI (CAN) controller config for DevKitM-1. Signed-off-by: Jan Charvat Fixed a compile error, presumably caused by C&P error. arch/armv[7|8]m: enhance the clang support Signed-off-by: chao.an arch/Toolchain.defs: replace all ${/$} with $(/$) Signed-off-by: chao.an semaphore: fix usage of NXSEM_INITIALIZER Signed-off-by: Petro Karashchenko arch/xtensa: Remove FAR from chip and board folder Signed-off-by: Xiang Xiao arch/ceva: Remove FAR from chip folder Signed-off-by: Xiang Xiao arch/sim: Remove FAR from chip and board folder Signed-off-by: Xiang Xiao arch/x86_64: Remove FAR from chip folder Signed-off-by: Xiang Xiao arch/or1k: Remove FAR from chip folder Signed-off-by: Xiang Xiao arch/misoc: Remove FAR from chip folder Signed-off-by: Xiang Xiao arch/mips: Remove FAR from chip and board folder Signed-off-by: Xiang Xiao arch/sparc: Remove FAR from chip and board folder Signed-off-by: Xiang Xiao arm/arch: using __builtin_frame_address(0) implement up_getsp(). Signed-off-by: wangbowen6 arch/arm: Move arm_signal_dispatch.c to common folder Signed-off-by: Xiang Xiao Remove the unneeded worker_t cast Signed-off-by: Xiang Xiao Remove the unneeded void cast Signed-off-by: Xiang Xiao arm/a1x: fix compile break Signed-off-by: chao.an wireless/80211: update the 80211 header Upstream from: https://github.com/freebsd/freebsd-src/blob/main/sys/net80211/ieee80211.h Signed-off-by: chao.an sched/environ: Refine the environment variables storage layout to confirm the standard and then implement get_environ_ptr correctly Signed-off-by: Xiang Xiao libc: Don't duplicate string in chdir and lib_restoredir since the new layout doesn't reallocate the unchanged environ variable anymore Signed-off-by: Xiang Xiao tools/cibuild.sh: Migrate risc-v toolchian from 8.3.0 to 10.2.0 Signed-off-by: Xiang Xiao tools/cibuild.sh: Download risc-v toolchain with --no-check-certificate untils SiFive update their certification Signed-off-by: Xiang Xiao arch/arm: export arm_saveusercontext() rename arm_saveusercontext() -> up_arm_saveusercontext() Signed-off-by: chao.an boards/ostest: remove board ostest implement Signed-off-by: chao.an board/arch_fpu*: move arch_[get|cmp]fpu to common arch rename the arch api: arch_getfpu -> up_saveusercontext arch_cmpfpu -> up_cmpfpu Signed-off-by: chao.an arch/mips: Remove unneeded group_addrenv call which handled by mips_doirq Signed-off-by: Xiang Xiao arch/misoc: Remove unneeded group_addrenv call which handled by [lm32|minerva]_doirq Signed-off-by: Xiang Xiao arch/xtensa: Remove unneeded group_addrenv call which handled by xtensa_irq_dispatch Signed-off-by: Xiang Xiao arch/sparc: Remove unneeded group_addrenv call which handled by up_doirq Signed-off-by: Xiang Xiao libc/blockstream: add block out stream backend Signed-off-by: chao.an libc/blkoutstream: Minor style fix Signed-off-by: Xiang Xiao arch/arm: Remove unneeded group_addrenv call which handled by arm_doirq Signed-off-by: Xiang Xiao arch/risc-v: Remove FAR from chip and board folder Signed-off-by: Xiang Xiao arch/arm: Remove FAR and CODE from common/ and arm*/ folder Signed-off-by: Xiang Xiao Revert "tools/cibuild.sh: Download risc-v toolchain with --no-check-certificate" This reverts commit 3b97e37b525d50d8a78765f85276f900129dade5. arch/arm: Remove all lazy fpu related code since it is broken and inefficient, and then removed by: commit dc961baaea17107109d94575e9bb5d9fb725b801 Author: chao.an Date: Thu Apr 14 18:07:14 2022 +0800 arm/armv7-[a|r]: move fpu save/restore to assembly handler Save/Restore FPU registers in C environment is dangerous practive, which cannot guarantee the compiler won't generate the assembly code with float point registers, especially in interrupt handling Signed-off-by: chao.an commit 8d66dbc0680cb81f91674ace814b2b8a94c49cd2 Author: chao.an Date: Thu Apr 7 13:48:04 2022 +0800 arm/armv[7|8]-m: skip the fpu save/restore if stack frame is integer-only Signed-off-by: chao.an Signed-off-by: Xiang Xiao arch/armv[7|8]-m: Compare all FPU registers in up_fpucmp Signed-off-by: Xiang Xiao arch/armv7-[a|r]: correct the handing of group env switch This PR resolved 2 issues: 1. CURRENT_REGS is not set correctly on swint handling 2. group env is not changed properly Signed-off-by: chao.an fs:oflag need consistent with psock if don't consistent with psock,call fcntl will have differet flag Signed-off-by: anjiahao arm/arm_assert.c Fix dumping of status from ISR The status dump did not work if the first fault triggers before the first context switch (during nx_start()). risc-v/riscv_assert.c Fix dumping of status from ISR The status dump did not work if the first fault triggers before the first context switch (during nx_start()). fs:fs_getfilep changes fd judgment method if a fd was closed,need return EBADF Signed-off-by: anjiahao arch/armv8-m: Unify the toolchain definition of eabi/clang for linux and windows Signed-off-by: chao.an arch/armv7-m: Unify the toolchain definition of eabi/clang/iar for linux and windows Signed-off-by: chao.an arch/arm/armv6-m: Unify the toolchain definition of eabi for linux and windows Signed-off-by: chao.an arch/armv7-a/r: Unify the toolchain definition of eabi for linux and windows Signed-off-by: chao.an arch/risc-v: Unify the toolchain definition of RVG for linux and windows Signed-off-by: chao.an arch/misoc: Unify the toolchain definition of GNU for linux and windows Signed-off-by: chao.an arch/z80: Unify the toolchain definition of SDCC for linux and windows Signed-off-by: chao.an armv7/r:cp15_cache_all: fix error in LineSize 'r5' mask r5 = r3 & r1 Signed-off-by: zhuyanlin arch/sparc,xtensa: Control output by $(Q) as other arch Signed-off-by: Huang Qi LICENSE: document missing armv7-x files add missing armv7-a/armv7-r files to the LICENSE file. Signed-off-by: Alin Jerpelea LICENSE: document missing lpc files add missing lpc files to the LICENSE file. Signed-off-by: Alin Jerpelea LICENSE: document missing samdxxx files add missing files to the LICENSE file. Signed-off-by: Alin Jerpelea LICENSE: document missing am335x files add missing files to the LICENSE file. Signed-off-by: Alin Jerpelea arch: arm: cxd56xx: Add Apache license to files In the initial contribution those files were missing the license Signed-off-by: Alin Jerpelea arch: arm: imxrt: Add Apache license to files In the initial contribution those files were missing the license Signed-off-by: Alin Jerpelea arch: arm: lpc43xx: Add Apache license to files In the initial contribution those files were missing the license Signed-off-by: Alin Jerpelea arch: arm: phy62xx: Add Apache license to files In the initial contribution those files were missing the license Signed-off-by: Alin Jerpelea arch: arm: stm32l4: remove empty files during contribution empty files have been pushed. Signed-off-by: Alin Jerpelea LICENSE: document missing tiva files add missing files to the LICENSE file. Signed-off-by: Alin Jerpelea arch: arm: mor1kx: remove empty files during contribution empty files have been pushed. Signed-off-by: Alin Jerpelea LICENSE: document missing mor1k files add missing files to the LICENSE file. Signed-off-by: Alin Jerpelea arch: arm: sama5: Add Apache license to files In the initial contribution those files were missing the license Signed-off-by: Alin Jerpelea arch: arm: stm32: Add Apache license to files In the initial contribution those files were missing the license Signed-off-by: Alin Jerpelea boards: sim: Add Apache license to files In the initial contribution those files were missing the license Signed-off-by: Alin Jerpelea drivers: leds: ncp5623c: migrate the license to Apache Gregory Nutt is the copyright holder for those files and he has submitted the SGA as a result we can migrate the licenses to Apache. Signed-off-by: Alin Jerpelea LICENSE: document missing mtd files add missing files to the LICENSE file. Signed-off-by: Alin Jerpelea drivers: mtd: gd5f: migrate the license to Apache Xiaomi has submitted the SGA as a result we can migrate the licenses to Apache. Signed-off-by: Alin Jerpelea drivers: sensors: mlx90614: migrate the license to Apache Gregory Nutt is the copyright holder for those files and he has submitted the SGA as a result we can migrate the licenses to Apache. Signed-off-by: Alin Jerpelea LICENSE: document missing bcm43xxx files add missing files to the LICENSE file. Signed-off-by: Alin Jerpelea LICENSE: document missing nfs files add missing files to the LICENSE file. Signed-off-by: Alin Jerpelea include: himem: Add Apache license to files In the initial contribution those files were missing the license Signed-off-by: Alin Jerpelea include: leds: ncp5623c: migrate the license to Apache Gregory Nutt is the copyright holder for those files and he has submitted the SGA as a result we can migrate the licenses to Apache. Signed-off-by: Alin Jerpelea LICENSE: document missing uIP files add missing files to the LICENSE file. Signed-off-by: Alin Jerpelea LICENSE: document missing bluetooth files add missing files to the LICENSE file. Signed-off-by: Alin Jerpelea include: wireless: bluetooth: migrate the license to Apache Gregory Nutt is the copyright holder for those files and he has submitted the SGA as a result we can migrate the licenses to Apache. Signed-off-by: Alin Jerpelea LICENSE: document missing sixlowpan files add missing files to the LICENSE file. Signed-off-by: Alin Jerpelea LICENSE: document missing igmp files add missing files to the LICENSE file. Signed-off-by: Alin Jerpelea LICENSE: document missing wireless files add missing files to the LICENSE file. Signed-off-by: Alin Jerpelea LICENSE: document missing libc files add missing files to the LICENSE file. Signed-off-by: Alin Jerpelea arch/risc-v: Change riscv_savefpu/riscv_loadfpu to macro Signed-off-by: Huang Qi arch/armv6-m: add support of LLVM Clang Signed-off-by: chao.an arch/clang: add support for Clang LTO add support of Clang's Link Time Optimization (LTO) on NuttX build system Reference: https://gcc.gnu.org/onlinedocs/gccint/LTO-Overview.html https://llvm.org/docs/LinkTimeOptimization.html Signed-off-by: chao.an arch/xtensa: Use syscall interface for xtensa_save/restore_context. Signed-off-by: Abdelatif Guettouche arch.h: Fix up_exit prototype. Signed-off-by: Abdelatif Guettouche arch/xtensa: Move xtensa_save_context to up_saveusercontext for consistency with other archs. Signed-off-by: Abdelatif Guettouche arm/armv[7|8]m: compare of hardware fp registers should skip REG_FP_RESERVED Fix fpu test break Signed-off-by: chao.an arch/risc-v: Don't clear reserved bits in fcsr in riscv_fpuconfig Signed-off-by: Huang Qi pipe: Increase buffer size by one byte to ompensate the full indicator Signed-off-by: Xiang Xiao boards/sim: support rc.sysinit Follow: http://glennastory.net/boot/sysinit.html This is first script that init runs is rc.sysinit. This script does serval initialization tasks about basic service. The boot sequence currently provided to the board level is: board_earlyinitialize-> board_lateinitialize(Peripherals driver, core driver, ...)-> run rcS script(mount fs, run service) -> board_appinitialize-> After this patch: The boot sequence currently provided to the board level is: board_earlyinitialize-> board_lateinitialize(core driver,...)-> run rc.sysinit script(mount fs, run core service) -> board_appinitialize(Peripherals driver)-> run rcS script(run other service)-> So, Peripheral drivers can do more with the file system and core services. Signed-off-by: Jiuzhu Dong arch/arm: Switch the context of save and restore from assembler to c Signed-off-by: Xiang Xiao arch/arm: Move the duplicated assembly code to common folder Signed-off-by: Xiang Xiao binfmt_execmodule: add errout_with_args exit point Ensures that when errout_xx is taken, args are freed env_dup: Fix copying of env between address environments If address environments are in use, it is not possible to simply memcpy from from one process to another. The current implementation of env_dup does precisely this and thus, it fails at once when it is attempted between two user processes. The solution is to use the kernel's heap as an intermediate buffer. This is a simple, effective and common way to do a fork(). Obviously this is not needed for kernel processes. syscall: Add call gate for get_environ_ptr Now that the environment strings are stored as an array of strings, they can be passed from the application via char **environ, which is really defined as a function call to get_environ_ptr(). This works as is for flat build, but protected mode and kernel mode require a call gate, which is added here. binfmt_execmodule: If incoming envp is NULL get parent envp This keeps backwards compatibility with apps that do not provide envp. The old implementation passes NULL always and this change fixes any regression caused by it. assert: static_assert is not support in c standard C89,C99. Signed-off-by: wangbowen6 arch/xtensa: Color the other CPUs task when they are created. Signed-off-by: Abdelatif Guettouche compile/opt: add config DEBUG_OPT_UNUSED_SECTIONS Enable this option to optimization the unused input sections with the linker by compiling with " -ffunction-sections -fdata-sections ", and linking with " --gc-sections ". Signed-off-by: chao.an compile/opt: add config DEBUG_LINK_MAP Selecting this option will pass "-Map=$(TOPDIR)$(DELIM)nuttx.map" to ld when linking NuttX ELF. That file can be useful for verifying and debugging magic section games, and for seeing which pieces of code get eliminated with DEBUG_OPT_UNUSED_SECTIONS. Signed-off-by: chao.an arch/risc-v: Enable FPU for K210 K210 support rv64gc ISA, now we enable F/D extension for it. Note: QEMU for K210 don't support FPU now. Signed-off-by: Huang Qi sched/task: Correct the comment about environment variable Signed-off-by: Xiang Xiao sched/environ: Remove the unneeded cast in env_dup Signed-off-by: Xiang Xiao sched/environ: Replace get_environ_ptr with environ Signed-off-by: Xiang Xiao environ: Don't expose get_environ_ptr in csdlib since it isn't defined in c/c++ standard Signed-off-by: Xiang Xiao arch/risc-v/riscv_misaligned: Implement float load/store support Signed-off-by: Huang Qi arch: risc-v: Do not enable FPU for K210 with QEMU Summary: - I noticed that maix-bit:smp does not work with QEMU. - Actually, QEMU supports sifive_u (not K210) but it works if FPU is disabled. - This commit fixes this issue. Impact: - K210 with QEMU only Testing: - Tested with qemu-5.2 Signed-off-by: Masayuki Ishikawa sched/task: Implement execle and execve Signed-off-by: Xiang Xiao libc: Implement execvp, execlp and execvpe as macro Signed-off-by: Xiang Xiao libc: Fix typo error in execle Signed-off-by: Xiang Xiao syscall: Fix prototype of exec() to syscall.csv pm: Move pm_initialize call from driver_initialize to xxx_pminitialize since it's too late with the below commit: ommit a594a5d7a8dcd756884ca7d3449f37ba77f96af3 Author: chao.an Date: Mon Apr 11 19:44:26 2022 +0800 sched/init: drivers_initialize() should be late than up_initialize() up_initialize | ->up_serialinit | ->uart_register /* ("/dev/console", &CONSOLE_DEV); */ drivers_initialize | ->syslog_console_init | ->register_driver /* ("/dev/console", &g_consoleops, 0666, NULL); */ Signed-off-by: Xiang Xiao sched: remove DEBUGASSERT from nx_waitpid Signed-off-by: Petro Karashchenko xtensa_user_handler.S: Use the `ps_setup` macro when dealing with an exception. Signed-off-by: Abdelatif Guettouche xtensa_user_handler.S: Fix backtrace. Signed-off-by: Abdelatif Guettouche arch/xtensa: No need to save SP in EXCSAVE_1 when linking the interrupt frame with the previous frame. The SP is already saved in A12. Signed-off-by: Abdelatif Guettouche boards/boardctl: correct boarctl return value Summary: - Correct boardctl function's return value - In case of BOARDIOC_TESTSET, `ret' has 0 or 1 or an error, but `ret' is ignored except error. Impact: - boardctl return value except errors Testing: - custom Cortex-A9 board Signed-off-by: Oki Minabe libc/string: strcmp/strncmp cast unsigned char Summary: - Cast to unsigned char for strcmp and strncmp - strcmp and strncmp are described following by opengroup.org The sign of a non-zero return value shall be determined by the sign of the difference between the values of the first pair of bytes (both interpreted as type unsigned char) that differ in the strings being compared. https://pubs.opengroup.org/onlinepubs/9699919799/functions/strcmp.html https://pubs.opengroup.org/onlinepubs/9699919799/functions/strncmp.html Impact: - strcmp and strncmp return value Testing: - ostest on sabre-6quad:smp w/ qemu Signed-off-by: Oki Minabe compiler.h: optimization option is not supported before GCC 4.6 -fno-tree-loop-distribute-patterns is not supported before GCC 4.6 Signed-off-by: wangbowen6 libs/libc/string: unify implementation across the functions Signed-off-by: Petro Karashchenko tools:fix parsememdump.py match error Signed-off-by: anjiahao libc/fixedmatch: Avoid "divide by zero" error Signed-off-by: Xiang Xiao boards: Switch the elf link script to binfmt/libelf/gnu-elf.ld Signed-off-by: Xiang Xiao boards: Move -fno-common from Make.defs to Toolchain.defs Signed-off-by: Xiang Xiao boards/risc-v: Remove "MAXOPTIMIZATION = -Os" from Make.defs since it is already defined in Toolchain.defs Signed-off-by: Xiang Xiao RISC-V: Fix system crash when FPU is in use FPU registers need to be written prior to updating CSR_STATUS RISC-V: Add implementation for vfork boards: Move "-fno-exceptions -fcheck-new" from Make.defs to Toolchain.defs Signed-off-by: Xiang Xiao boards: Move -g from Make.defs to Toolchain.defs Signed-off-by: Xiang Xiao RISC-V: Add syscall support for vfork If vfork is called via syscall (PROTECTED/KERNEL build) need to set up return parameters for syscall. Otherwise the SW will get lost. arch/xtensa: Simply use xtensa_createstack for CPU1 idle task. Signed-off-by: Abdelatif Guettouche Documentation:fix error describe on message queue Signed-off-by: anjiahao Correct the code alignment found in review Signed-off-by: Xiang Xiao sched:fix mq_timedsend describe Signed-off-by: anjiahao riscv/Makefile: Delete old target used for debugging. Signed-off-by: Abdelatif Guettouche arm/assert: fix build warning on clang common/arm_assert.c:80:14: warning: format specifies type 'unsigned int' but the argument has type 'uint32_t' (aka 'unsigned long') [-Wformat] stack, ptr[0], ptr[1], ptr[2], ptr[3], ^~~~~ include/debug.h:119:59: note: expanded from macro '_alert' __arch_syslog(LOG_EMERG, EXTRA_FMT format EXTRA_ARG, ##__VA_ARGS__) ~~~~~~ ^~~~~~~~~~~ Signed-off-by: chao.an driver/ioexpander: remove response about irq_handler Signed-off-by: Jiuzhu Dong xtensa_int_handlers.S: Refactor the calls to ps_setup. Signed-off-by: Abdelatif Guettouche arch/xtensa: Group all the macros in one file. Signed-off-by: Abdelatif Guettouche RISC-V: workaround for the RV64 SoC which does not has mem mapped MTIMER currten value regs. MPFS: Remove # CONFIG_ARCH_FPU is not set from defconfigs For some reason # CONFIG_ARCH_FPU is not set also unsets ARCH_FPU for the .config file, meaning FPU support is not built. OpenSBI: Add riscv_hardfp.S to compilation It will just become an empty object if FPU support is not included. arm/arch_setjmp.S: armv6m support setjmp, longjmp Signed-off-by: wangbowen6 drivers: mtd: fix null buffer reference When device not support byte read or readlen less than device block size, will use `dev->buffer` as dst address. `CFGDIOC_FIRSTCONFIG` and `CFGDIOC_NEXTCONFIG` should also malloc buffer before call `mtdconfig_readbytes`. Signed-off-by: Lingao Meng arch/risc-v: add support for GCC LTO Signed-off-by: chao.an arch/arm: add support for GCC LTO 1. Enable GCC link-time optimizer 2. Enable use of a linker plugin during link-time optimization Signed-off-by: chao.an net/tcp:make initial tcp port more random Signed-off-by: 田昕 risc-v: Fix format specifier in debug log Signed-off-by: Gustavo Henrique Nihei risc-v: Restrict Fence instruction for chips that support S-mode Signed-off-by: Gustavo Henrique Nihei drivers/audio/cxd56: Workaround for HW issue of CXD56 Because of HW issue, Audio output volume is limited until -30db as maximum. This commit fix it. And fix the bug of voulme control. config: DEBUG_LINK_MAP don't need depend on ARCH_TOOLCHAIN_GNU since all toolchain could generate the map file Signed-off-by: Xiang Xiao config: It's enough to let LTO_FULL depend on ARCH_TOOLCHAIN_GNU only since ARCH_TOOLCHAIN_CLANG automatically select ARCH_TOOLCHAIN_GNU Signed-off-by: Xiang Xiao tools:minidumpserver.py support xtensa Signed-off-by: anjiahao libc.csv: sort Implement preadv and pwritev Fix udp recvfrom to correctly return addrlen According to POSIX the length of the source address of the received message shall be stored in the object pointed to by the address_len argument. This patch fixes two places where this did not happen correctly. Signed-off-by: Michael Jung RISC-V: Initial support for CONFIG_BUILD_KERNEL This implements initial support for kernel build (address environments, page allocator) for RISC-V. This is done a bit differently compared to the ARMV7 implementation: - Support implemented for Sv39 MMU, however the implementation should be extensible for other MMU types also. - Instead of preserving and moving the L1 references around, a canonical approach is used instead, where the page table base address register is switched upon context switch. - To preserve a bit of memory, only a single L1/L2 table is supported, this gives access to 1GiB of virtual memory for each process, which should be more than enough. Some things worth noting: - Assumes page pool is mapped with vaddr=paddr mappings - The CONFIG_ARCH_XXXX_VBASE and CONFIG_ARCH_XXXX_NPAGES values are ignored, with the exception of CONFIG_ARCH_DATA_VBASE which is used for ARCH_DATA_RESERVE - ARCH_DATA_RESERVE is placed at the beginning of the userspace task's address environment RISC-V: Copy kernel memory mappings to userspace addrenv Copy the kernel mappings to the new (user) address environment. The copyuing is done exactly once. This relies on the fact that the kernel L1/L2 mappings will never change, as all of the kernel memory is mapped upon boot. RISC-V: Add pgpool to vaddr utility function The only mapping that is supported now is vaddr=paddr, but the function DOES check that the address is within the page pool, so it is not useless. RISC-V: Move wipe_page to pgalloc.h and rename it riscv_pgwipe RISC-V: Add crt0 file Contains the code for the user process signal trampoline. arch/xtensa: Replace the xcp context with stack context to improve context switching Signed-off-by: Abdelatif Guettouche stm32l4+ DMAMUX register fix stm32l4 RCC SW/SWS comment fixes stm32l4 remove useless RTCPRE setup stm32l4 RCC multi-bit field fixes stm32l4 fixing proper register name RCC_APB1ENR1_PWREN stm32l4 FLASH_CR_FSTPG register fix stm32l4 TIM register fixes stm32l4 fix tim channel range checking stm32l4 rtcc register fixes stm32l4 fix ECCR comment libc/arch_atomic: add gcc legacy __sync buitins support. Signed-off-by: wangbowen6 libc/arch_atomic: add FAR to pointers. Signed-off-by: wangbowen6 UMM: Implement getter for address environment heap start vaddr Using the Kconfig macro does not work for RISC-V target, as there the user heap follows .data/.bss and does not obey any Kconfig provided boundary. Added stubs for ARM and Z80 also. armv7-a/r: use cps instruction to change cpu mode Summary: - Use CPS instruction to change cpu mode for code simplification - CPS which changes cpu mode is available in armv6 and above Impact: - armv7-a/r Testing: - smp and ostest on sabre-6quad:smp w/ qemu Signed-off-by: Oki Minabe libxx: Always build libcxx with -std=c++17 since the implementation of barrier require the aligned new which is defined in C++ 17 Signed-off-by: Xiang Xiao arch: Move -nostdinc++ to Tooolchain.defs Signed-off-by: Xiang Xiao boards/arm: Remove the unneeded C++ config from stm32l4/nucleo-l476rg Signed-off-by: Xiang Xiao boards: Remove -std=c++1x from Make.defs let the implementation of standard library choice what they want Signed-off-by: Xiang Xiao tools/ci: Enable libcxx test config Signed-off-by: Xiang Xiao arch/avr: Remvoe the error message when toolchain can't find to avoid blocking the basic ci check Signed-off-by: Xiang Xiao arch/arm/Make.defs: unify common source include Signed-off-by: chao.an arch/cortex-m/Make.defs: unify arch common source include Signed-off-by: chao.an arch/cortex-[a|r]/Make.defs: unify arch common source include Signed-off-by: chao.an arch/arm/Make.defs: unify arch common source include Signed-off-by: chao.an arm/cxd56xx/lc823450/rp2040: replace arch testset to board implement This patch to resolve the regression which leads to the breakage of spresense:smp Signed-off-by: chao.an tools/testbuild.sh: Don't skip configure and distclean to improve the test coverage Signed-off-by: Xiang Xiao boards: run tools/refresh.sh to normalize defconfig Signed-off-by: Xiang Xiao libc: Remove the redundant seek in writev since the file position isn't changed if write return fail Signed-off-by: Xiang Xiao arch: Fix the style found in review Signed-off-by: Xiang Xiao Revert "arch/risc-v: use STACK_FRAME_SIZE for in S-mode syscall asm" This reverts commit 9b7f9867aad7ff2d04b97516ab86b68d733447b6. arch/riscv: Optimize the syscall performance in kernel mode by renaming riscv_dispatch_syscall to sys_callx, so the caller don't need the immediate step(syscallx->riscv_dispatch_syscall) Signed-off-by: Xiang Xiao boards: Move -fno-strict-aliasing from Make.defs to Toolchain.defs and migrate MAXOPTIMIZATION into ARCHOPTIMIZATION Signed-off-by: Xiang Xiao arch: Move -fstack-protector-all from Make.defs to Toolchain.defs Signed-off-by: Xiang Xiao arch: Move -finstrument-functions from Make.defs to Toolchain.defs Signed-off-by: Xiang Xiao boards: sabre-6quad: Fix dramboot.ld for libcxx Summary: - I noticed that cxxtest does not work correctly. - Finally, I found that initializers for c++ is not called. - This commit fixes this issue Impact: - None Testing: - Tested with cxxtest (defconfig will be added later) Signed-off-by: Masayuki Ishikawa boards: sabre-6quad: Add defconfig for libcxx Summary: - This commit adds defconfig for libcxx Impact: - None Testing: - Tested with QEMU Signed-off-by: Masayuki Ishikawa RISC-V: Fix crt0 file compilation Definition of STACK_FRAME_SIZE was moved MPFS: Add sources for CONFIG_ARCH_ADDRENV MPFS: Add page pool allocation MPFS: Add knsh (CONFIG_BUILD_KERNEL=y) Re-name the old knsh (CONFIG_BUILD_PROTECTED=y) to pnsh MPFS: Add kernel space mappings Mappings are done with vaddr=paddr. - I/O space mapped with two gigapages - Kernel space mapped to statically allocated page tables. 2MB of kernel memory is supported. - Page pool is mapped to the kernel space, to allow virtual memory access for the kernel e.g. to initialize the page memory when it is allocated. MPFS: Add dummy rofms image To allow building with ROMFS enabled RISC-V: Temporarily disable error about missing SBI binfmt_execmodule: Use heap size getter for print arch: risc-v: Add support for semihosting and hostfs Summary: - This commit adds support for semihosting and hostfs Impact: - None Testing: - Tested with nsh and nsh64 (defconfig will be updated later) Signed-off-by: Masayuki Ishikawa boards: rv-virt: Add hostfs support to nsh and nsh64 defconfigs Summary: - This commit adds hostfs support to nsh and nsh64 defconfigs Impact: - None Testing: - Tested with qemu-6.2 Signed-off-by: Masayuki Ishikawa RISC-V: Fix bug in riscv_addrenv.c Need 1 full page extra for heap, not 1 byte. boards: rv-virt: Add support ELF to nsh and nsh64 defconfigs Summary: - This commit adds support ELF to nsh and nsh64 defconfigs Impact: - None Testing: nsh> mount -t hostfs -o fs=../apps/bin /system/bin nsh> hello Hello, World!! Signed-off-by: Masayuki Ishikawa armv7-a: smp: fix stack coloration Summary: - The stack pointer is subtracted to alloc xcptcontext area in the __cpu?_start block - Fix the stack coloration overrun to the previous cpu's xcpt area Impact: - armv7-a's smp configuration Testing: - smp and ostest on sabre-6quad:smp w/ qemu Signed-off-by: Oki Minabe Elf loader: give temporary write access to user .text memory When the .elf file is loaded from disk, the kernel must be given write access to the allocated .text section in the task's address environment. The access is removed after the elf is loaded and relocations are done. NOTE: The reason this works for the ARM implementation, is that the ARM MMU can be configured to give write access for the privileged mode, but revoke write access for the user mode. Regardless, it would be smart to revoke write access even for the kernel, when the kernel does not need it. This framework allows doing that, if someone wishes to take up the task. arm_addrenv: Add stubs for modifying permissions Adds stubs for up_addrenv_text_enable/disable_write. These don't have to do anything as the ARM MMU allows setting access per mode. Currently the settings for user .text area grants the kernel write access, but revokes user write access. boards/space: Remove the unneeded XXXEXT definition these make variable is defined in common place now Signed-off-by: Xiang Xiao MCAN_INT_ACKE must be on the list of MCAN_TXERR_INTS to be properly handeled formatting --- .github/gcc.json | 2 +- .github/workflows/check.yml | 4 +- DISCLAIMER-WIP | 20 - Documentation/applications/nsh/config.rst | 12 +- .../applications/nsh/customizing.rst | 31 +- .../applications/nsh/installation.rst | 51 +- Documentation/applications/nsh/login.rst | 4 +- Documentation/applications/nsh/nsh.rst | 45 +- Documentation/guides/cpp_cmake.rst | 6 +- Documentation/guides/pysimcoder.rst | 12 +- .../platforms/risc-v/esp32c3/index.rst | 2 +- .../reference/user/04_message_queue.rst | 4 +- .../reference/user/10_filesystem.rst | 4 +- Kconfig | 22 + LICENSE | 834 ++++- ReleaseNotes | 1054 ++++++ arch/Kconfig | 61 +- arch/arm/Kconfig | 7 - arch/arm/include/arch.h | 38 +- arch/arm/include/armv7-a/irq.h | 8 +- arch/arm/include/armv7-m/irq.h | 114 +- arch/arm/include/armv7-m/irq_cmnvector.h | 152 - arch/arm/include/armv7-m/irq_lazyfpu.h | 170 - arch/arm/include/armv7-r/irq.h | 8 +- arch/arm/include/armv8-m/irq.h | 120 +- arch/arm/include/armv8-m/irq_cmnvector.h | 158 - arch/arm/include/armv8-m/irq_lazyfpu.h | 176 - arch/arm/include/syscall.h | 8 +- arch/arm/src/Makefile | 15 +- arch/arm/src/a1x/Make.defs | 93 +- arch/arm/src/a1x/a1x_boot.c | 3 - arch/arm/src/a1x/a1x_pio.c | 22 +- arch/arm/src/am335x/Make.defs | 89 +- arch/arm/src/am335x/am335x_boot.c | 3 - arch/arm/src/arm/Kconfig | 15 +- arch/arm/src/arm/Make.defs | 37 + arch/arm/src/arm/Toolchain.defs | 91 +- arch/arm/src/arm/arm_allocpage.c | 2 +- arch/arm/src/arm/arm_checkmapping.c | 2 +- arch/arm/src/arm/arm_doirq.c | 10 +- arch/arm/src/arm/arm_initialstate.c | 6 +- arch/arm/src/arm/arm_saveusercontext.S | 100 - arch/arm/src/arm/arm_schedulesigaction.c | 6 +- arch/arm/src/arm/arm_syscall.c | 48 +- arch/arm/src/arm/arm_tcbinfo.c | 12 +- arch/arm/src/arm/arm_vectors.S | 203 +- arch/arm/src/arm/vfork.S | 124 - arch/arm/src/armv6-m/Kconfig | 18 +- arch/arm/src/armv6-m/Make.defs | 37 + arch/arm/src/armv6-m/Toolchain.defs | 140 +- arch/arm/src/armv6-m/arm_dumpnvic.c | 2 +- arch/arm/src/armv6-m/arm_fullcontextrestore.S | 79 - arch/arm/src/armv6-m/arm_hardfault.c | 2 +- arch/arm/src/armv6-m/arm_initialstate.c | 6 +- arch/arm/src/armv6-m/arm_ramvec_initialize.c | 2 +- arch/arm/src/armv6-m/arm_saveusercontext.S | 89 - arch/arm/src/armv6-m/arm_schedulesigaction.c | 24 +- arch/arm/src/armv6-m/arm_signal_dispatch.c | 76 - arch/arm/src/armv6-m/arm_signal_handler.S | 103 - arch/arm/src/armv6-m/arm_svcall.c | 12 +- arch/arm/src/armv6-m/arm_tcbinfo.c | 20 +- arch/arm/src/armv6-m/nvic.h | 2 +- arch/arm/src/armv7-a/Kconfig | 16 +- arch/arm/src/armv7-a/Make.defs | 93 + arch/arm/src/armv7-a/Toolchain.defs | 91 +- arch/arm/src/armv7-a/addrenv.h | 4 +- arch/arm/src/armv7-a/arm_addrenv.c | 73 +- arch/arm/src/armv7-a/arm_addrenv_kstack.c | 6 +- arch/arm/src/armv7-a/arm_addrenv_perms.c | 75 + arch/arm/src/armv7-a/arm_addrenv_shm.c | 32 +- arch/arm/src/armv7-a/arm_addrenv_ustack.c | 12 +- arch/arm/src/armv7-a/arm_addrenv_utils.c | 18 +- arch/arm/src/armv7-a/arm_allocpage.c | 2 +- arch/arm/src/armv7-a/arm_checkmapping.c | 2 +- arch/arm/src/armv7-a/arm_cpuhead.S | 11 +- arch/arm/src/armv7-a/arm_cpuidlestack.c | 6 +- arch/arm/src/armv7-a/arm_cpupause.c | 4 +- arch/arm/src/armv7-a/arm_cpustart.c | 6 +- arch/arm/src/armv7-a/arm_doirq.c | 15 +- arch/arm/src/armv7-a/arm_fetchadd.S | 240 -- .../arm/src/armv7-a/arm_fpucmp.c | 44 +- arch/arm/src/armv7-a/arm_head.S | 3 +- arch/arm/src/armv7-a/arm_initialstate.c | 6 +- arch/arm/src/armv7-a/arm_pgalloc.c | 20 +- arch/arm/src/armv7-a/arm_pghead.S | 3 +- arch/arm/src/armv7-a/arm_physpgaddr.c | 6 +- arch/arm/src/armv7-a/arm_restorefpu.S | 92 - arch/arm/src/armv7-a/arm_saveusercontext.S | 138 - arch/arm/src/armv7-a/arm_schedulesigaction.c | 16 +- arch/arm/src/armv7-a/arm_signal_dispatch.c | 92 - arch/arm/src/armv7-a/arm_syscall.c | 67 +- arch/arm/src/armv7-a/arm_tcbinfo.c | 12 +- arch/arm/src/armv7-a/arm_vectors.S | 339 +- arch/arm/src/armv7-a/cp15_flush_dcache_all.S | 2 +- .../src/armv7-a/cp15_invalidate_dcache_all.S | 2 +- arch/arm/src/armv7-a/crt0.c | 2 +- arch/arm/src/armv7-a/gic.h | 4 +- arch/arm/src/armv7-a/pgalloc.h | 8 +- arch/arm/src/armv7-a/vfork.S | 124 - arch/arm/src/armv7-m/Kconfig | 75 +- arch/arm/src/armv7-m/Make.defs | 57 + arch/arm/src/armv7-m/Toolchain.defs | 173 +- arch/arm/src/armv7-m/arm_busfault.c | 2 +- .../arm/src/armv7-m/{gnu => }/arm_exception.S | 15 +- arch/arm/src/armv7-m/arm_fpucmp.c | 62 + arch/arm/src/armv7-m/arm_fpuconfig.c | 83 + arch/arm/src/armv7-m/arm_hardfault.c | 2 +- arch/arm/src/armv7-m/arm_initialstate.c | 16 +- arch/arm/src/armv7-m/arm_itm_syslog.c | 8 +- arch/arm/src/armv7-m/arm_memfault.c | 2 +- arch/arm/src/armv7-m/arm_perf.c | 4 +- arch/arm/src/armv7-m/arm_ramvec_initialize.c | 2 +- arch/arm/src/armv7-m/arm_schedulesigaction.c | 24 +- arch/arm/src/armv7-m/arm_svcall.c | 18 +- arch/arm/src/armv7-m/arm_systick.c | 34 +- arch/arm/src/armv7-m/arm_tcbinfo.c | 22 +- arch/arm/src/armv7-m/arm_usagefault.c | 2 +- arch/arm/src/armv7-m/exc_return.h | 4 +- arch/arm/src/armv7-m/gnu/arm_fetchadd.S | 242 -- arch/arm/src/armv7-m/gnu/arm_fpu.S | 270 -- .../src/armv7-m/gnu/arm_fullcontextrestore.S | 79 - arch/arm/src/armv7-m/gnu/arm_lazyexception.S | 333 -- .../arm/src/armv7-m/gnu/arm_saveusercontext.S | 88 - arch/arm/src/armv7-m/gnu/arm_signal_handler.S | 102 - .../arm/src/armv7-m/iar/arm_saveusercontext.S | 86 - arch/arm/src/armv7-r/Kconfig | 16 +- arch/arm/src/armv7-r/Make.defs | 58 + arch/arm/src/armv7-r/Toolchain.defs | 91 +- arch/arm/src/armv7-r/arm_doirq.c | 16 - arch/arm/src/armv7-r/arm_fetchadd.S | 240 -- arch/arm/src/armv7-r/arm_fpucmp.c | 58 + arch/arm/src/armv7-r/arm_head.S | 3 +- arch/arm/src/armv7-r/arm_initialstate.c | 6 +- arch/arm/src/armv7-r/arm_restorefpu.S | 92 - arch/arm/src/armv7-r/arm_savefpu.S | 96 - arch/arm/src/armv7-r/arm_saveusercontext.S | 129 - arch/arm/src/armv7-r/arm_schedulesigaction.c | 6 +- arch/arm/src/armv7-r/arm_signal_dispatch.c | 92 - arch/arm/src/armv7-r/arm_signal_handler.S | 99 - arch/arm/src/armv7-r/arm_syscall.c | 46 +- arch/arm/src/armv7-r/arm_tcbinfo.c | 12 +- arch/arm/src/armv7-r/arm_vectors.S | 339 +- arch/arm/src/armv7-r/cp15_clean_dcache_all.S | 2 +- arch/arm/src/armv7-r/cp15_flush_dcache_all.S | 2 +- .../src/armv7-r/cp15_invalidate_dcache_all.S | 2 +- arch/arm/src/armv7-r/gic.h | 4 +- arch/arm/src/armv7-r/vfork.S | 124 - arch/arm/src/armv8-m/Kconfig | 64 +- arch/arm/src/armv8-m/Make.defs | 58 + arch/arm/src/armv8-m/Toolchain.defs | 176 +- arch/arm/src/armv8-m/arm_busfault.c | 2 +- arch/arm/src/armv8-m/arm_exception.S | 13 +- arch/arm/src/armv8-m/arm_fpu.S | 270 -- arch/arm/src/armv8-m/arm_fpucmp.c | 62 + arch/arm/src/armv8-m/arm_fpuconfig.c | 83 + arch/arm/src/armv8-m/arm_fullcontextrestore.S | 79 - arch/arm/src/armv8-m/arm_hardfault.c | 2 +- arch/arm/src/armv8-m/arm_initialstate.c | 18 +- arch/arm/src/armv8-m/arm_itm_syslog.c | 8 +- arch/arm/src/armv8-m/arm_lazyexception.S | 362 -- arch/arm/src/armv8-m/arm_memfault.c | 2 +- arch/arm/src/armv8-m/arm_perf.c | 4 +- arch/arm/src/armv8-m/arm_ramvec_initialize.c | 2 +- arch/arm/src/armv8-m/arm_saveusercontext.S | 88 - arch/arm/src/armv8-m/arm_schedulesigaction.c | 24 +- arch/arm/src/armv8-m/arm_securefault.c | 2 +- arch/arm/src/armv8-m/arm_signal_dispatch.c | 76 - arch/arm/src/armv8-m/arm_svcall.c | 18 +- arch/arm/src/armv8-m/arm_systick.c | 34 +- arch/arm/src/armv8-m/arm_tcbinfo.c | 22 +- arch/arm/src/armv8-m/arm_usagefault.c | 2 +- arch/arm/src/armv8-m/exc_return.h | 6 +- arch/arm/src/armv8-m/psr.h | 11 +- arch/arm/src/armv8-m/vfork.S | 127 - arch/arm/src/c5471/Make.defs | 21 +- arch/arm/src/common/Make.defs | 86 + arch/arm/src/common/arm_allocateheap.c | 12 +- arch/arm/src/common/arm_assert.c | 55 +- arch/arm/src/common/arm_backtrace_fp.c | 32 +- arch/arm/src/common/arm_backtrace_thumb.c | 87 +- arch/arm/src/common/arm_blocktask.c | 9 - arch/arm/src/common/arm_checkstack.c | 75 +- arch/arm/src/common/arm_createstack.c | 2 +- arch/arm/src/common/arm_etherstub.c | 2 + arch/arm/src/common/arm_exit.c | 24 +- .../src/common/arm_fullcontextrestore.c} | 14 +- arch/arm/src/common/arm_internal.h | 84 +- arch/arm/src/common/arm_releasepending.c | 9 - arch/arm/src/common/arm_releasestack.c | 2 +- arch/arm/src/common/arm_reprioritizertr.c | 9 - .../src/common/arm_saveusercontext.c} | 38 +- arch/arm/src/common/arm_semi_syslog.c | 2 +- .../{armv7-m => common}/arm_signal_dispatch.c | 6 +- arch/arm/src/common/arm_stackframe.c | 6 +- arch/arm/src/common/arm_task_start.c | 2 +- arch/arm/src/common/arm_tls.c | 4 +- arch/arm/src/common/arm_unblocktask.c | 9 - .../{armv8-m => common/gnu}/arm_fetchadd.S | 3 +- .../gnu}/arm_signal_handler.S | 3 +- .../src/{armv8-m => common/gnu}/arm_testset.S | 3 +- arch/arm/src/{armv6-m => common/gnu}/vfork.S | 17 +- .../{armv7-m => common}/iar/arm_fetchadd.S | 2 +- .../src/{armv7-m => common}/iar/arm_testset.S | 2 +- arch/arm/src/{armv7-m => common}/iar/vfork.S | 2 +- arch/arm/src/cxd56xx/Make.defs | 51 +- arch/arm/src/cxd56xx/cxd56_charger.c | 32 +- arch/arm/src/cxd56xx/cxd56_cpustart.c | 3 +- arch/arm/src/cxd56xx/cxd56_emmc.c | 1 + arch/arm/src/cxd56xx/cxd56_farapistub.h | 2 +- arch/arm/src/cxd56xx/cxd56_gauge.c | 34 +- arch/arm/src/cxd56xx/cxd56_ge2d.c | 28 +- arch/arm/src/cxd56xx/cxd56_geofence.c | 50 +- arch/arm/src/cxd56xx/cxd56_gnss.c | 4 +- arch/arm/src/cxd56xx/cxd56_hostif.c | 8 +- arch/arm/src/cxd56xx/cxd56_pwm.c | 2 - arch/arm/src/cxd56xx/cxd56_scu.c | 6 + arch/arm/src/cxd56xx/cxd56_sdhci.c | 2 +- arch/arm/src/cxd56xx/cxd56_sph.c | 6 +- arch/arm/src/cxd56xx/cxd56_start.c | 93 +- arch/arm/src/cxd56xx/cxd56_sysctl.c | 2 +- arch/arm/src/cxd56xx/cxd56_uart0.c | 14 +- arch/arm/src/cxd56xx/hardware/cxd5602_isop.h | 20 + .../hardware/cxd5602_isop_hadc0_highspeed.h | 20 + arch/arm/src/dm320/Make.defs | 22 +- arch/arm/src/dm320/dm320_decodeirq.c | 16 +- arch/arm/src/efm32/Make.defs | 42 +- arch/arm/src/efm32/efm32_start.c | 102 +- arch/arm/src/efm32/efm32_usbhost.c | 10 +- arch/arm/src/eoss3/Make.defs | 34 +- arch/arm/src/eoss3/eoss3_start.c | 104 +- arch/arm/src/imx1/Make.defs | 21 +- arch/arm/src/imx1/imx_decodeirq.c | 16 +- arch/arm/src/imx6/Make.defs | 113 +- arch/arm/src/imx6/imx_boot.c | 3 - arch/arm/src/imx6/imx_cpuboot.c | 3 - arch/arm/src/imxrt/Make.defs | 50 +- .../imxrt/hardware/rt102x/imxrt102x_xbar.h | 20 + .../imxrt/hardware/rt105x/imxrt105x_xbar.h | 20 + .../imxrt/hardware/rt106x/imxrt106x_xbar.h | 20 + arch/arm/src/imxrt/imxrt_ehci.c | 41 +- arch/arm/src/imxrt/imxrt_flexspi.c | 6 +- arch/arm/src/imxrt/imxrt_start.c | 102 +- arch/arm/src/imxrt/imxrt_usdhc.c | 6 +- arch/arm/src/kinetis/Make.defs | 60 +- arch/arm/src/kinetis/kinetis_sdhc.c | 2 +- arch/arm/src/kinetis/kinetis_start.c | 100 +- arch/arm/src/kinetis/kinetis_usbhshost.c | 43 +- arch/arm/src/kl/Make.defs | 27 +- arch/arm/src/lc823450/Make.defs | 45 +- arch/arm/src/lpc17xx_40xx/Make.defs | 52 +- arch/arm/src/lpc17xx_40xx/lpc17_40_adc.c | 2 +- arch/arm/src/lpc17xx_40xx/lpc17_40_ethernet.c | 6 +- arch/arm/src/lpc17xx_40xx/lpc17_40_sdcard.c | 4 +- arch/arm/src/lpc17xx_40xx/lpc17_40_start.c | 92 +- arch/arm/src/lpc214x/Make.defs | 23 +- arch/arm/src/lpc2378/Make.defs | 22 +- arch/arm/src/lpc31xx/Make.defs | 27 +- arch/arm/src/lpc31xx/lpc31_decodeirq.c | 16 +- arch/arm/src/lpc31xx/lpc31_ehci.c | 7 +- arch/arm/src/lpc43xx/Make.defs | 42 +- arch/arm/src/lpc43xx/lpc43_ehci.c | 7 +- arch/arm/src/lpc43xx/lpc43_emc.c | 15 + arch/arm/src/lpc43xx/lpc43_rtc.h | 41 +- arch/arm/src/lpc43xx/lpc43_sdmmc.c | 2 +- arch/arm/src/lpc43xx/lpc43_start.c | 95 +- arch/arm/src/lpc54xx/Make.defs | 42 +- arch/arm/src/lpc54xx/lpc54_sdmmc.c | 2 +- arch/arm/src/lpc54xx/lpc54_start.c | 93 +- arch/arm/src/max326xx/Make.defs | 38 +- arch/arm/src/max326xx/common/max326_start.c | 93 +- arch/arm/src/moxart/Make.defs | 17 +- arch/arm/src/nrf52/Make.defs | 48 +- arch/arm/src/nrf52/nrf52_pminitialize.c | 4 + arch/arm/src/nrf52/nrf52_start.c | 89 +- arch/arm/src/nuc1xx/Make.defs | 27 +- arch/arm/src/phy62xx/Make.defs | 38 +- arch/arm/src/phy62xx/phy62xx_exception.S | 19 + arch/arm/src/phy62xx/phy62xx_start.S | 19 + arch/arm/src/phy62xx/phyplus_stub.c | 45 +- arch/arm/src/phy62xx/uart.c | 4 +- arch/arm/src/rp2040/Make.defs | 32 +- arch/arm/src/rtl8720c/Make.defs | 30 +- arch/arm/src/rtl8720c/ameba_hci.c | 2 +- arch/arm/src/rtl8720c/ameba_nvic.c | 15 - arch/arm/src/rtl8720c/ameba_uart.c | 10 +- arch/arm/src/rtl8720c/ameba_wdt.c | 4 +- arch/arm/src/rtl8720c/amebaz_coex.c | 11 +- arch/arm/src/s32k1xx/Make.defs | 16 - arch/arm/src/s32k1xx/s32k11x/Make.defs | 18 +- arch/arm/src/s32k1xx/s32k14x/Make.defs | 29 +- arch/arm/src/s32k1xx/s32k1xx_pminitialize.c | 4 + arch/arm/src/s32k1xx/s32k1xx_start.c | 89 +- arch/arm/src/sam34/Kconfig | 2 +- arch/arm/src/sam34/Make.defs | 50 +- arch/arm/src/sam34/hardware/sam_hsmci.h | 10 +- arch/arm/src/sam34/sam_gpioirq.c | 2 +- arch/arm/src/sam34/sam_hsmci.c | 54 +- arch/arm/src/sam34/sam_start.c | 96 +- arch/arm/src/sama5/Make.defs | 95 +- arch/arm/src/sama5/sam_boot.c | 3 - arch/arm/src/sama5/sam_ehci.c | 7 +- arch/arm/src/sama5/sam_hsmci.c | 2 +- arch/arm/src/sama5/sam_pioirq.c | 2 +- arch/arm/src/sama5/sam_sdmmc.c | 6 +- arch/arm/src/sama5/sam_tsd.c | 4 +- arch/arm/src/samd2l2/Make.defs | 27 +- arch/arm/src/samd5e5/Make.defs | 40 +- arch/arm/src/samd5e5/sam_oneshot.c | 2 +- arch/arm/src/samd5e5/sam_progmem.c | 8 +- arch/arm/src/samd5e5/sam_start.c | 92 +- arch/arm/src/samd5e5/sam_tc.c | 2 +- arch/arm/src/samd5e5/sam_timerisr.c | 2 +- arch/arm/src/samd5e5/sam_usb.c | 2 +- arch/arm/src/samd5e5/sam_wdt.c | 2 +- arch/arm/src/samv7/Make.defs | 53 +- arch/arm/src/samv7/sam_gpioirq.c | 2 +- arch/arm/src/samv7/sam_hsmci.c | 2 +- arch/arm/src/samv7/sam_mcan.c | 3 +- arch/arm/src/samv7/sam_start.c | 100 +- arch/arm/src/stm32/Make.defs | 58 +- arch/arm/src/stm32/stm32_bbsram.c | 2 +- arch/arm/src/stm32/stm32_otgfshost.c | 2 +- arch/arm/src/stm32/stm32_otghshost.c | 2 +- arch/arm/src/stm32/stm32_pminitialize.c | 4 + arch/arm/src/stm32/stm32_sdio.c | 2 +- arch/arm/src/stm32/stm32_start.c | 100 +- arch/arm/src/stm32f0l0g0/Make.defs | 27 +- arch/arm/src/stm32f7/Make.defs | 58 +- arch/arm/src/stm32f7/stm32_bbsram.c | 2 +- arch/arm/src/stm32f7/stm32_ltdc.c | 6 +- arch/arm/src/stm32f7/stm32_otghost.c | 2 +- arch/arm/src/stm32f7/stm32_pminitialize.c | 4 + arch/arm/src/stm32f7/stm32_sdmmc.c | 2 +- arch/arm/src/stm32f7/stm32_start.c | 100 +- arch/arm/src/stm32h7/Make.defs | 61 +- arch/arm/src/stm32h7/stm32_bbsram.c | 2 +- arch/arm/src/stm32h7/stm32_otghost.c | 2 +- arch/arm/src/stm32h7/stm32_pminitialize.c | 4 + arch/arm/src/stm32h7/stm32_qspi.c | 4 +- arch/arm/src/stm32h7/stm32_sdmmc.c | 6 +- arch/arm/src/stm32h7/stm32_spi_slave.c | 14 +- arch/arm/src/stm32h7/stm32_start.c | 96 +- arch/arm/src/stm32l4/Make.defs | 48 +- arch/arm/src/stm32l4/hardware/stm32l4_flash.h | 4 +- arch/arm/src/stm32l4/hardware/stm32l4_rtcc.h | 6 +- arch/arm/src/stm32l4/hardware/stm32l4_tim.h | 30 +- .../src/stm32l4/hardware/stm32l4x3xx_rcc.h | 16 +- .../src/stm32l4/hardware/stm32l4x5xx_rcc.h | 16 +- .../src/stm32l4/hardware/stm32l4x6xx_rcc.h | 16 +- .../src/stm32l4/hardware/stm32l4xrxx_dmamux.h | 10 +- .../src/stm32l4/hardware/stm32l4xrxx_rcc.h | 16 +- arch/arm/src/stm32l4/stm32l4.h | 2 - arch/arm/src/stm32l4/stm32l4_fsmc.h | 1 - arch/arm/src/stm32l4/stm32l4_lcd.h | 1 - arch/arm/src/stm32l4/stm32l4_otgfshost.c | 2 +- arch/arm/src/stm32l4/stm32l4_pminitialize.c | 4 + arch/arm/src/stm32l4/stm32l4_sdmmc.c | 2 +- arch/arm/src/stm32l4/stm32l4_start.c | 100 +- arch/arm/src/stm32l4/stm32l4_tim.c | 2 +- arch/arm/src/stm32l4/stm32l4x3xx_rcc.c | 32 +- arch/arm/src/stm32l4/stm32l4x5xx_rcc.c | 25 +- arch/arm/src/stm32l4/stm32l4x6xx_rcc.c | 21 +- arch/arm/src/stm32l4/stm32l4xrxx_rcc.c | 21 +- arch/arm/src/stm32l5/Make.defs | 47 +- arch/arm/src/stm32l5/stm32l5_irq.c | 12 +- arch/arm/src/stm32l5/stm32l5_lse.c | 2 +- arch/arm/src/stm32l5/stm32l5_rcc.c | 4 +- arch/arm/src/stm32l5/stm32l5_serial.c | 12 +- arch/arm/src/stm32l5/stm32l5_spi.c | 6 +- arch/arm/src/stm32l5/stm32l5_start.c | 101 +- arch/arm/src/stm32l5/stm32l5_timerisr.c | 2 +- arch/arm/src/stm32u5/Make.defs | 48 +- .../src/stm32u5/hardware/stm32u585xx_rcc.h | 49 + arch/arm/src/stm32u5/stm32_irq.c | 12 +- arch/arm/src/stm32u5/stm32_lse.c | 2 +- arch/arm/src/stm32u5/stm32_rcc.c | 4 +- arch/arm/src/stm32u5/stm32_serial.c | 12 +- arch/arm/src/stm32u5/stm32_start.c | 101 +- arch/arm/src/stm32u5/stm32_timerisr.c | 2 +- arch/arm/src/stm32u5/stm32u585xx_rcc.c | 293 +- arch/arm/src/str71x/Make.defs | 23 +- arch/arm/src/tiva/Make.defs | 53 +- arch/arm/src/tiva/cc13xx/cc13xx_start.c | 93 +- arch/arm/src/tiva/common/lmxx_tm4c_start.c | 93 +- arch/arm/src/tms570/Make.defs | 61 +- arch/arm/src/tms570/tms570_boot.c | 3 - arch/arm/src/xmc4/Make.defs | 59 +- arch/arm/src/xmc4/xmc4_start.c | 96 +- arch/avr/src/at90usb/at90usb_serial.c | 4 +- arch/avr/src/atmega/atmega_serial.c | 8 +- arch/avr/src/avr/Toolchain.defs | 33 +- arch/avr/src/avr32/Toolchain.defs | 32 +- arch/avr/src/common/up_exit.c | 10 +- arch/ceva/include/syscall.h | 6 +- arch/ceva/include/xc5/irq.h | 2 +- arch/ceva/include/xm6/irq.h | 2 +- arch/ceva/include/xm6/spinlock.h | 2 +- arch/ceva/src/common/up_assert.c | 6 +- arch/ceva/src/common/up_checkstack.c | 10 +- arch/ceva/src/common/up_createstack.c | 32 +- arch/ceva/src/common/up_heap.c | 4 +- arch/ceva/src/common/up_idle.c | 3 + arch/ceva/src/common/up_internal.h | 7 +- arch/ceva/src/common/up_releasestack.c | 2 +- arch/ceva/src/common/up_saveusercontext.c | 4 +- arch/ceva/src/common/up_schedulesigaction.c | 4 +- arch/ceva/src/common/up_signal_dispatch.c | 2 +- arch/ceva/src/common/up_stackframe.c | 6 +- arch/ceva/src/common/up_svcall.c | 10 +- arch/ceva/src/common/up_task_start.c | 2 +- arch/ceva/src/common/up_usestack.c | 2 +- arch/ceva/src/common/up_vfork.c | 4 +- arch/ceva/src/xc5/Toolchain.defs | 26 +- arch/ceva/src/xc5/up_hardfault.c | 2 +- arch/ceva/src/xm6/Toolchain.defs | 26 +- arch/ceva/src/xm6/up_hardfault.c | 2 +- arch/hc/src/common/up_exit.c | 10 +- arch/hc/src/common/up_internal.h | 1 - arch/mips/include/syscall.h | 2 +- arch/mips/src/common/mips_allocateheap.c | 4 +- arch/mips/src/common/mips_createstack.c | 2 +- arch/mips/src/common/mips_exit.c | 24 +- arch/mips/src/common/mips_internal.h | 2 +- arch/mips/src/common/mips_releasestack.c | 2 +- arch/mips/src/common/mips_stackframe.c | 6 +- arch/mips/src/mips32/Toolchain.defs | 67 +- arch/mips/src/mips32/mips_assert.c | 4 +- arch/mips/src/mips32/mips_blocktask.c | 9 - arch/mips/src/mips32/mips_dumpstate.c | 2 +- arch/mips/src/mips32/mips_releasepending.c | 9 - arch/mips/src/mips32/mips_reprioritizertr.c | 9 - arch/mips/src/mips32/mips_swint0.c | 6 +- arch/mips/src/mips32/mips_unblocktask.c | 9 - arch/mips/src/pic32mx/pic32mx.h | 32 +- arch/mips/src/pic32mx/pic32mx_ethernet.c | 4 +- arch/mips/src/pic32mx/pic32mx_gpioirq.c | 2 +- arch/mips/src/pic32mx/pic32mx_spi.c | 66 +- arch/mips/src/pic32mx/pic32mx_usbdev.c | 4 +- arch/mips/src/pic32mz/pic32mz_dma.c | 88 +- arch/mips/src/pic32mz/pic32mz_dma.h | 6 +- arch/mips/src/pic32mz/pic32mz_ethernet.c | 6 +- arch/mips/src/pic32mz/pic32mz_freerun.h | 10 +- arch/mips/src/pic32mz/pic32mz_gpioirq.c | 4 +- arch/mips/src/pic32mz/pic32mz_i2c.c | 118 +- arch/mips/src/pic32mz/pic32mz_i2c.h | 4 +- arch/mips/src/pic32mz/pic32mz_oneshot.h | 18 +- .../src/pic32mz/pic32mz_oneshot_lowerhalf.c | 56 +- arch/mips/src/pic32mz/pic32mz_serial.c | 4 +- arch/mips/src/pic32mz/pic32mz_spi.c | 136 +- arch/mips/src/pic32mz/pic32mz_spi.h | 62 +- arch/mips/src/pic32mz/pic32mz_timer.c | 154 +- arch/mips/src/pic32mz/pic32mz_timer.h | 30 +- .../src/pic32mz/pic32mz_timer_lowerhalf.c | 94 +- arch/mips/src/pic32mz/pic32mz_usbdev.h | 4 +- arch/misoc/include/syscall.h | 2 +- arch/misoc/src/common/misoc_net.c | 114 +- arch/misoc/src/common/misoc_serial.c | 4 +- arch/misoc/src/lm32/Kconfig | 16 +- arch/misoc/src/lm32/Toolchain.defs | 46 +- arch/misoc/src/lm32/lm32.h | 2 +- arch/misoc/src/lm32/lm32_allocateheap.c | 4 +- arch/misoc/src/lm32/lm32_assert.c | 4 +- arch/misoc/src/lm32/lm32_blocktask.c | 9 - arch/misoc/src/lm32/lm32_createstack.c | 2 +- arch/misoc/src/lm32/lm32_dumpstate.c | 2 +- arch/misoc/src/lm32/lm32_exit.c | 24 +- arch/misoc/src/lm32/lm32_releasepending.c | 9 - arch/misoc/src/lm32/lm32_releasestack.c | 2 +- arch/misoc/src/lm32/lm32_reprioritizertr.c | 9 - arch/misoc/src/lm32/lm32_stackframe.c | 6 +- arch/misoc/src/lm32/lm32_swint.c | 32 +- arch/misoc/src/lm32/lm32_unblocktask.c | 9 - arch/misoc/src/minerva/Kconfig | 16 +- arch/misoc/src/minerva/Toolchain.defs | 28 +- arch/misoc/src/minerva/minerva.h | 2 +- arch/misoc/src/minerva/minerva_allocateheap.c | 4 +- arch/misoc/src/minerva/minerva_assert.c | 4 +- arch/misoc/src/minerva/minerva_blocktask.c | 9 - arch/misoc/src/minerva/minerva_createstack.c | 2 +- arch/misoc/src/minerva/minerva_dumpstate.c | 2 +- arch/misoc/src/minerva/minerva_exit.c | 24 +- .../src/minerva/minerva_releasepending.c | 9 - arch/misoc/src/minerva/minerva_releasestack.c | 2 +- .../src/minerva/minerva_reprioritizertr.c | 9 - arch/misoc/src/minerva/minerva_stackframe.c | 6 +- arch/misoc/src/minerva/minerva_swint.c | 32 +- arch/misoc/src/minerva/minerva_unblocktask.c | 9 - arch/or1k/include/arch.h | 16 +- arch/or1k/src/common/up_allocateheap.c | 12 +- arch/or1k/src/common/up_assert.c | 8 +- arch/or1k/src/common/up_checkstack.c | 12 +- arch/or1k/src/common/up_createstack.c | 32 +- arch/or1k/src/common/up_exit.c | 14 +- arch/or1k/src/common/up_internal.h | 7 +- arch/or1k/src/common/up_releasestack.c | 2 +- arch/or1k/src/common/up_stackframe.c | 6 +- arch/or1k/src/common/up_task_start.c | 2 +- arch/or1k/src/mor1kx/Toolchain.defs | 38 +- arch/or1k/src/mor1kx/hardware/irq.h | 1 - arch/renesas/src/common/up_exit.c | 10 +- arch/renesas/src/common/up_internal.h | 1 - arch/renesas/src/m16c/m16c_vectors.S | 2 +- arch/renesas/src/rx65n/rx65n_riic.c | 6 +- arch/renesas/src/rx65n/rx65n_rtc.c | 4 +- arch/renesas/src/rx65n/rx65n_rtc_lowerhalf.c | 2 +- arch/renesas/src/rx65n/rx65n_sbram.c | 4 +- arch/renesas/src/rx65n/rx65n_usbhost.c | 8 +- arch/renesas/src/rx65n/rx65n_vector.S | 2 +- arch/risc-v/Kconfig | 85 +- arch/risc-v/include/arch.h | 99 +- arch/risc-v/include/csr.h | 110 +- arch/risc-v/include/esp32c3/irq.h | 5 +- arch/risc-v/include/irq.h | 19 +- arch/risc-v/include/litex/irq.h | 3 +- arch/risc-v/include/mode.h | 103 + arch/risc-v/include/syscall.h | 64 +- arch/risc-v/src/Makefile | 25 +- arch/risc-v/src/bl602/Make.defs | 11 +- arch/risc-v/src/bl602/bl602_head.S | 16 +- arch/risc-v/src/bl602/bl602_irq.c | 9 +- arch/risc-v/src/bl602/bl602_irq_dispatch.c | 55 +- .../src/bl602/bl602_oneshot_lowerhalf.c | 2 +- arch/risc-v/src/bl602/bl602_os_hal.c | 4 +- arch/risc-v/src/bl602/bl602_pwm_lowerhalf.c | 4 +- arch/risc-v/src/bl602/bl602_serial.c | 5 +- arch/risc-v/src/bl602/bl602_spi.c | 44 +- arch/risc-v/src/bl602/bl602_start.c | 4 + arch/risc-v/src/bl602/bl602_timerisr.c | 93 +- arch/risc-v/src/bl602/chip.h | 9 +- arch/risc-v/src/c906/Make.defs | 7 +- arch/risc-v/src/c906/c906_allocateheap.c | 2 - arch/risc-v/src/c906/c906_head.S | 11 +- arch/risc-v/src/c906/c906_irq.c | 11 +- arch/risc-v/src/c906/c906_irq_dispatch.c | 64 +- arch/risc-v/src/c906/c906_start.c | 4 + arch/risc-v/src/c906/c906_timerisr.c | 78 +- arch/risc-v/src/common/Kconfig | 29 - arch/risc-v/src/common/Toolchain.defs | 89 +- arch/risc-v/src/common/crt0.c | 140 + .../src/common/pgalloc.h} | 99 +- arch/risc-v/src/common/riscv_addrenv.c | 815 +++++ arch/risc-v/src/common/riscv_addrenv_kstack.c | 4 +- arch/risc-v/src/common/riscv_addrenv_perms.c | 151 + arch/risc-v/src/common/riscv_assert.c | 5 +- arch/risc-v/src/common/riscv_blocktask.c | 9 - arch/risc-v/src/common/riscv_checkstack.c | 1 - arch/risc-v/src/common/riscv_copystate.c | 15 +- arch/risc-v/src/common/riscv_cpuindex.c | 21 +- arch/risc-v/src/common/riscv_createstack.c | 31 +- arch/risc-v/src/common/riscv_doirq.c | 29 +- arch/risc-v/src/common/riscv_exception.c | 67 +- .../src/common/riscv_exception_common.S | 194 +- arch/risc-v/src/common/riscv_exit.c | 20 +- arch/risc-v/src/common/riscv_fault.c | 115 - arch/risc-v/src/common/riscv_fpu.S | 197 +- arch/risc-v/src/common/riscv_fpucmp.c | 59 + arch/risc-v/src/common/riscv_getnewintctx.c | 17 +- arch/risc-v/src/common/riscv_hostfs.c | 359 ++ arch/risc-v/src/common/riscv_internal.h | 93 +- arch/risc-v/src/common/riscv_macros.S | 310 ++ arch/risc-v/src/common/riscv_mhartid.S | 53 + arch/risc-v/src/common/riscv_misaligned.c | 616 ++++ arch/risc-v/src/common/riscv_mmu.c | 19 +- arch/risc-v/src/common/riscv_mmu.h | 71 +- arch/risc-v/src/common/riscv_mtimer.c | 338 ++ arch/risc-v/src/common/riscv_mtimer.h | 51 + arch/risc-v/src/common/riscv_percpu.c | 194 + .../src/common/riscv_percpu.h} | 120 +- arch/risc-v/src/common/riscv_pgalloc.c | 206 ++ arch/risc-v/src/common/riscv_pmp.c | 20 +- arch/risc-v/src/common/riscv_releasepending.c | 9 - .../risc-v/src/common/riscv_reprioritizertr.c | 9 - .../risc-v/src/common/riscv_saveusercontext.c | 50 + .../src/common/riscv_schedulesigaction.c | 27 +- arch/risc-v/src/common/riscv_semihost.S | 40 + arch/risc-v/src/common/riscv_sigdeliver.c | 2 +- arch/risc-v/src/common/riscv_signal_handler.S | 11 +- arch/risc-v/src/common/riscv_swint.c | 73 +- arch/risc-v/src/common/riscv_tcbinfo.c | 18 +- arch/risc-v/src/common/riscv_unblocktask.c | 9 - arch/risc-v/src/common/riscv_vectors.S | 9 +- arch/risc-v/src/common/riscv_vfork.c | 79 +- arch/risc-v/src/common/riscv_vfork.h | 58 +- arch/risc-v/src/common/supervisor/Make.defs | 28 + .../common/supervisor/riscv_perform_syscall.c | 65 + arch/risc-v/src/common/supervisor/riscv_sbi.c | 91 + .../src/common/supervisor/riscv_syscall.S | 165 + .../armv7-m/gnu => risc-v/src/common}/vfork.S | 73 +- arch/risc-v/src/esp32c3/Kconfig | 62 + arch/risc-v/src/esp32c3/Make.defs | 21 +- arch/risc-v/src/esp32c3/chip.h | 8 + arch/risc-v/src/esp32c3/esp32c3_interrupt.S | 179 - arch/risc-v/src/esp32c3/esp32c3_irq.c | 79 +- arch/risc-v/src/esp32c3/esp32c3_irq.h | 17 - .../src/esp32c3/esp32c3_oneshot_lowerhalf.c | 4 +- .../risc-v/src/esp32c3/esp32c3_pminitialize.c | 6 +- arch/risc-v/src/esp32c3/esp32c3_resetcause.c | 1 - arch/risc-v/src/esp32c3/esp32c3_systemreset.c | 1 - arch/risc-v/src/esp32c3/esp32c3_twai.c | 1252 +++++++ .../src/esp32c3/esp32c3_twai.h} | 58 +- arch/risc-v/src/esp32c3/esp32c3_uid.c | 3 - arch/risc-v/src/esp32c3/esp32c3_usbserial.c | 2 +- arch/risc-v/src/esp32c3/esp32c3_vectors.S | 10 +- .../risc-v/src/esp32c3/esp32c3_wifi_adapter.c | 4 + .../src/esp32c3/hardware/esp32c3_twai.h | 856 +++++ arch/risc-v/src/fe310/Make.defs | 6 +- arch/risc-v/src/fe310/fe310_irq.c | 7 +- arch/risc-v/src/fe310/fe310_irq_dispatch.c | 34 +- arch/risc-v/src/fe310/fe310_timerisr.c | 73 +- arch/risc-v/src/k210/Make.defs | 14 +- arch/risc-v/src/k210/chip.h | 28 + arch/risc-v/src/k210/k210_irq.c | 14 +- arch/risc-v/src/k210/k210_irq_dispatch.c | 44 +- arch/risc-v/src/k210/k210_start.c | 4 + arch/risc-v/src/k210/k210_timerisr.c | 80 +- arch/risc-v/src/litex/Kconfig | 38 + arch/risc-v/src/litex/Make.defs | 9 +- .../src/litex/hardware/litex_memorymap.h | 11 +- arch/risc-v/src/litex/hardware/litex_sdio.h | 104 + arch/risc-v/src/litex/litex_cache.S | 82 + arch/risc-v/src/litex/litex_irq.c | 9 +- arch/risc-v/src/litex/litex_irq_dispatch.c | 35 +- arch/risc-v/src/litex/litex_sdio.c | 1497 ++++++++ arch/risc-v/src/litex/litex_sdio.h | 120 + arch/risc-v/src/mpfs/Kconfig | 15 +- arch/risc-v/src/mpfs/Make.defs | 26 +- arch/risc-v/src/mpfs/chip.h | 27 + arch/risc-v/src/mpfs/hardware/mpfs_plic.h | 4 +- arch/risc-v/src/mpfs/mpfs_allocateheap.c | 6 +- arch/risc-v/src/mpfs/mpfs_emmcsd.c | 2 +- arch/risc-v/src/mpfs/mpfs_ethernet.c | 6 +- arch/risc-v/src/mpfs/mpfs_head.S | 29 +- arch/risc-v/src/mpfs/mpfs_irq.c | 48 +- arch/risc-v/src/mpfs/mpfs_irq_dispatch.c | 87 +- arch/risc-v/src/mpfs/mpfs_mm_init.c | 144 + arch/risc-v/src/mpfs/mpfs_mm_init.h | 81 + .../src/mpfs/mpfs_pgalloc.c} | 49 +- arch/risc-v/src/mpfs/mpfs_plic.c | 20 +- arch/risc-v/src/mpfs/mpfs_start.c | 27 + arch/risc-v/src/mpfs/mpfs_systemreset.c | 1 - arch/risc-v/src/mpfs/mpfs_timerisr.c | 76 +- arch/risc-v/src/mpfs/mpfs_usb.c | 2 +- arch/risc-v/src/opensbi/Make.defs | 1 + arch/risc-v/src/qemu-rv/Make.defs | 13 +- arch/risc-v/src/qemu-rv/chip.h | 30 +- arch/risc-v/src/qemu-rv/qemu_rv_head.S | 8 +- arch/risc-v/src/qemu-rv/qemu_rv_irq.c | 9 +- .../risc-v/src/qemu-rv/qemu_rv_irq_dispatch.c | 60 +- arch/risc-v/src/qemu-rv/qemu_rv_start.c | 4 + arch/risc-v/src/qemu-rv/qemu_rv_timerisr.c | 73 +- arch/risc-v/src/rv32m1/Make.defs | 4 +- arch/risc-v/src/rv32m1/rv32m1_irq.c | 9 +- arch/risc-v/src/rv32m1/rv32m1_irq_dispatch.c | 35 +- arch/sim/Kconfig | 23 + arch/sim/src/Makefile | 22 +- arch/sim/src/sim/up_ajoystick.c | 26 +- arch/sim/src/sim/up_alsa.c | 4 +- arch/sim/src/sim/up_assert.c | 2 +- arch/sim/src/sim/up_blockdevice.c | 2 +- arch/sim/src/sim/up_blocktask.c | 2 +- arch/sim/src/sim/up_checkstack.c | 14 +- arch/sim/src/sim/up_cpuidlestack.c | 2 +- arch/sim/src/sim/up_createstack.c | 32 +- arch/sim/src/sim/up_exit.c | 2 +- arch/sim/src/sim/up_framebuffer.c | 54 +- arch/sim/src/sim/up_hcisocket.c | 46 +- arch/sim/src/sim/up_heap.c | 50 +- arch/sim/src/sim/up_hostfs.c | 4 + arch/sim/src/sim/up_initialize.c | 19 +- arch/sim/src/sim/up_internal.h | 9 +- .../src/sim/up_keyboard.c} | 109 +- arch/sim/src/sim/up_lcd.c | 34 +- arch/sim/src/sim/up_macho_init.c | 2 +- arch/sim/src/sim/up_netdriver.c | 38 +- arch/sim/src/sim/up_oneshot.c | 66 +- arch/sim/src/sim/up_releasepending.c | 2 +- arch/sim/src/sim/up_releasestack.c | 2 +- arch/sim/src/sim/up_reprioritizertr.c | 2 +- arch/sim/src/sim/up_romgetc.c | 2 +- arch/sim/src/sim/up_rtc.c | 26 +- arch/sim/src/sim/up_smpsignal.c | 6 +- arch/sim/src/sim/up_stackframe.c | 6 +- arch/sim/src/sim/up_touchscreen.c | 10 +- arch/sim/src/sim/up_uart.c | 54 +- arch/sim/src/sim/up_unblocktask.c | 4 +- arch/sim/src/sim/up_usestack.c | 2 +- arch/sim/src/sim/up_usrsock.c | 154 +- arch/sim/src/sim/up_x11eventloop.c | 10 + arch/sim/src/sim/up_x11framebuffer.c | 2 +- arch/sparc/include/syscall.h | 6 +- arch/sparc/src/Makefile | 2 +- arch/sparc/src/bm3803/bm3803-serial.c | 6 +- arch/sparc/src/bm3803/bm3803-timerisr.c | 6 +- arch/sparc/src/bm3803/bm3803_exti_gpio.c | 2 +- arch/sparc/src/bm3803/bm3803_freerun.c | 12 +- arch/sparc/src/bm3803/bm3803_freerun.h | 8 +- arch/sparc/src/bm3803/bm3803_oneshot.c | 20 +- arch/sparc/src/bm3803/bm3803_oneshot.h | 2 +- .../src/bm3803/bm3803_oneshot_lowerhalf.c | 58 +- arch/sparc/src/bm3803/bm3803_tickless.c | 14 +- arch/sparc/src/bm3803/bm3803_tim.c | 78 +- arch/sparc/src/bm3803/bm3803_tim.h | 24 +- arch/sparc/src/bm3803/bm3803_tim_lowerhalf.c | 78 +- arch/sparc/src/bm3803/bm3803_wdg.c | 54 +- arch/sparc/src/bm3803/bm3803_wdg.h | 2 +- arch/sparc/src/bm3823/bm3823-serial.c | 6 +- arch/sparc/src/bm3823/bm3823-timerisr.c | 6 +- arch/sparc/src/common/up_allocateheap.c | 4 +- arch/sparc/src/common/up_assert.c | 14 +- arch/sparc/src/common/up_checkstack.c | 69 +- arch/sparc/src/common/up_createstack.c | 2 +- arch/sparc/src/common/up_exit.c | 28 +- arch/sparc/src/common/up_internal.h | 6 +- arch/sparc/src/common/up_releasestack.c | 2 +- arch/sparc/src/common/up_stackframe.c | 6 +- arch/sparc/src/sparc_v8/Toolchain.defs | 40 +- arch/sparc/src/sparc_v8/up_blocktask.c | 9 - arch/sparc/src/sparc_v8/up_doirq.c | 2 +- arch/sparc/src/sparc_v8/up_romgetc.c | 2 +- arch/sparc/src/sparc_v8/up_sigdeliver.c | 2 +- arch/sparc/src/sparc_v8/up_swint1.c | 4 +- arch/sparc/src/sparc_v8/up_unblocktask.c | 9 - arch/x86/src/common/up_exit.c | 10 +- arch/x86/src/common/up_internal.h | 1 - arch/x86/src/qemu/qemu_keypad.c | 28 +- arch/x86/src/qemu/qemu_saveusercontext.S | 2 +- arch/x86/src/qemu/qemu_vga.c | 36 +- arch/x86_64/src/common/up_allocateheap.c | 2 +- arch/x86_64/src/common/up_assert.c | 10 +- arch/x86_64/src/common/up_blocktask.c | 2 +- arch/x86_64/src/common/up_exit.c | 14 +- arch/x86_64/src/common/up_internal.h | 1 - arch/x86_64/src/common/up_releasepending.c | 2 +- arch/x86_64/src/common/up_reprioritizertr.c | 2 +- arch/x86_64/src/common/up_unblocktask.c | 2 +- arch/x86_64/src/intel64/intel64_handlers.c | 2 +- arch/x86_64/src/intel64/intel64_rng.c | 4 +- .../src/intel64/intel64_saveusercontext.S | 2 +- arch/x86_64/src/intel64/intel64_tickless.c | 24 +- arch/x86_64/src/intel64/intel64_timerisr.c | 2 +- arch/x86_64/src/intel64/up_createstack.c | 2 +- arch/x86_64/src/intel64/up_releasestack.c | 2 +- arch/x86_64/src/intel64/up_rtc.c | 4 +- arch/x86_64/src/intel64/up_sigdeliver.c | 2 +- arch/x86_64/src/intel64/up_stackframe.c | 6 +- arch/xtensa/Kconfig | 1 + arch/xtensa/include/esp32/irq.h | 6 +- arch/xtensa/include/irq.h | 5 +- arch/xtensa/include/syscall.h | 47 +- arch/xtensa/src/Makefile | 10 +- arch/xtensa/src/common/xtensa.h | 26 +- arch/xtensa/src/common/xtensa_backtrace.c | 2 +- arch/xtensa/src/common/xtensa_blocktask.c | 2 +- arch/xtensa/src/common/xtensa_context.S | 89 - arch/xtensa/src/common/xtensa_createstack.c | 31 +- arch/xtensa/src/common/xtensa_dumpstate.c | 5 +- arch/xtensa/src/common/xtensa_exit.c | 26 +- arch/xtensa/src/common/xtensa_initialstate.c | 15 +- arch/xtensa/src/common/xtensa_int_handlers.S | 195 +- .../src/common/xtensa_macros.S} | 86 +- arch/xtensa/src/common/xtensa_panic.S | 31 +- .../xtensa/src/common/xtensa_releasepending.c | 2 +- .../src/common/xtensa_reprioritizertr.c | 2 +- .../src/common/xtensa_saveusercontext.c | 50 + .../xtensa/src/common/xtensa_schedsigaction.c | 105 +- arch/xtensa/src/common/xtensa_sigdeliver.c | 10 +- arch/xtensa/src/common/xtensa_swi.h | 72 - arch/xtensa/src/common/xtensa_swint.c | 7 +- arch/xtensa/src/common/xtensa_tcbinfo.c | 77 + arch/xtensa/src/common/xtensa_unblocktask.c | 2 +- arch/xtensa/src/common/xtensa_user_handler.S | 101 +- arch/xtensa/src/esp32/Kconfig | 62 + arch/xtensa/src/esp32/Make.defs | 18 +- arch/xtensa/src/esp32/esp32_cpuidlestack.c | 22 +- arch/xtensa/src/esp32/esp32_cpustart.c | 23 +- arch/xtensa/src/esp32/esp32_himem.c | 34 +- .../src/esp32/esp32_oneshot_lowerhalf.c | 4 +- arch/xtensa/src/esp32/esp32_pminitialize.c | 5 + arch/xtensa/src/esp32/esp32_smp.h | 15 - arch/xtensa/src/esp32/esp32_twai.c | 1257 +++++++ .../fpu.h => xtensa/src/esp32/esp32_twai.h} | 36 +- arch/xtensa/src/esp32/hardware/esp32_dport.h | 6 +- .../src/esp32/hardware/esp32_gpio_sigmap.h | 6 +- arch/xtensa/src/esp32/hardware/esp32_soc.h | 2 + arch/xtensa/src/esp32/hardware/esp32_twai.h | 856 +++++ arch/xtensa/src/esp32s2/Kconfig | 94 +- arch/xtensa/src/esp32s2/Make.defs | 13 +- .../src/esp32s2/esp32s2_oneshot_lowerhalf.c | 4 +- arch/xtensa/src/esp32s2/esp32s2_psram.c | 725 ++++ arch/xtensa/src/esp32s2/esp32s2_psram.h | 139 + arch/xtensa/src/esp32s2/esp32s2_spiram.c | 380 ++ arch/xtensa/src/esp32s2/esp32s2_spiram.h | 206 ++ arch/xtensa/src/esp32s2/esp32s2_start.c | 88 +- .../src/esp32s2/hardware/esp32s2_efuse.h | 23 + .../src/esp32s2/hardware/esp32s2_extmem.h | 32 + .../xtensa/src/esp32s2/hardware/esp32s2_soc.h | 2 + .../esp32s2/hardware/esp32s2_spi_mem_reg.h | 3165 +++++++++++++++++ .../src/esp32s2/rom/esp32s2_opi_flash.h | 367 ++ .../xtensa/src/esp32s2/rom/esp32s2_spiflash.h | 1020 ++++++ arch/xtensa/src/esp32s3/Make.defs | 8 +- .../xtensa/src/esp32s3/esp32s3_cpuidlestack.c | 22 +- arch/xtensa/src/esp32s3/esp32s3_cpustart.c | 23 +- .../src/esp32s3/esp32s3_oneshot_lowerhalf.c | 2 +- arch/xtensa/src/esp32s3/esp32s3_smp.h | 15 - arch/xtensa/src/lx6/Toolchain.defs | 61 +- arch/xtensa/src/lx7/Toolchain.defs | 61 +- arch/z16/src/common/z16_exit.c | 10 +- arch/z16/src/z16f/Toolchain.defs | 20 +- arch/z80/src/Makefile.clang | 2 +- arch/z80/src/common/z80_exit.c | 10 +- arch/z80/src/ez80/Toolchain.defs | 43 +- arch/z80/src/z180/Kconfig | 13 +- arch/z80/src/z180/Toolchain.defs | 3 +- arch/z80/src/z180/z180_mmu.c | 27 + arch/z80/src/z8/Toolchain.defs | 22 +- arch/z80/src/z80/Kconfig | 13 +- arch/z80/src/z80/Toolchain.defs | 3 +- audio/audio_comp.c | 20 +- binfmt/binfmt.h | 44 + binfmt/binfmt_exec.c | 16 +- binfmt/binfmt_execmodule.c | 45 +- binfmt/libelf/libelf.h | 4 +- binfmt/libelf/libelf_addrenv.c | 86 + boards/Kconfig | 9 + boards/arm/a1x/pcduino-a10/README.txt | 2 +- .../configs/nsh/pcduino-140107.patch | 2 - boards/arm/a1x/pcduino-a10/scripts/Make.defs | 15 - boards/arm/am335x/beaglebone-black/README.txt | 2 +- .../am335x/beaglebone-black/scripts/Make.defs | 15 - boards/arm/c5471/c5471evm/scripts/Make.defs | 6 - boards/arm/cxd56xx/common/src/Make.defs | 4 + boards/arm/cxd56xx/common/src/cxd56_i2cdev.c | 1 + .../arm/cxd56xx/common/src/cxd56_scd41_i2c.c | 72 + boards/arm/cxd56xx/common/src/cxd56_sensors.c | 3 + .../arm/cxd56xx/drivers/sensors/bmp280_scu.c | 16 +- boards/arm/cxd56xx/spresense/Kconfig | 183 + .../cxd56xx/spresense/configs/rndis/defconfig | 1 - .../spresense/configs/rndis_smp/defconfig | 1 - .../cxd56xx/spresense/configs/smp/defconfig | 1 - .../cxd56xx/spresense/configs/wifi/defconfig | 1 - .../spresense/configs/wifi_smp/defconfig | 1 - boards/arm/cxd56xx/spresense/include/board.h | 16 +- .../cxd56xx/spresense/include/board_lcdpins.h | 146 + .../cxd56xx/spresense/include/cxd56_scd41.h | 32 +- .../cxd56xx/spresense/include/cxd56_sdcard.h | 13 + .../arm/cxd56xx/spresense/scripts/Make.defs | 22 +- .../arm/cxd56xx/spresense/scripts/gnu-elf.ld | 125 - boards/arm/cxd56xx/spresense/src/Make.defs | 4 - .../arm/cxd56xx/spresense/src/cxd56_appinit.c | 3 +- .../arm/cxd56xx/spresense/src/cxd56_ioctl.c | 17 + .../arm/cxd56xx/spresense/src/cxd56_ostest.c | 97 - .../arm/cxd56xx/spresense/src/cxd56_sdcard.c | 36 + boards/arm/dm320/ntosd-dm320/README.txt | 4 +- .../arm/dm320/ntosd-dm320/scripts/Make.defs | 14 - boards/arm/efm32/efm32-g8xx-stk/README.txt | 2 +- .../efm32/efm32-g8xx-stk/scripts/Make.defs | 15 - boards/arm/efm32/efm32gg-stk3700/README.txt | 2 +- .../efm32/efm32gg-stk3700/scripts/Make.defs | 15 - .../efm32/olimex-efm32g880f128-stk/README.txt | 2 +- .../scripts/Make.defs | 15 - .../arm/eoss3/quickfeather/scripts/Make.defs | 15 +- boards/arm/imx6/sabre-6quad/README.txt | 2 +- .../imx6/sabre-6quad/configs/libcxx/defconfig | 68 + boards/arm/imx6/sabre-6quad/scripts/Make.defs | 19 +- .../arm/imx6/sabre-6quad/scripts/dramboot.ld | 2 +- .../arm/imx6/sabre-6quad/scripts/gnu-elf.ld | 125 - .../arm/imxrt/imxrt1020-evk/scripts/Make.defs | 16 +- .../imxrt1050-evk/configs/knsh/Make.defs | 16 +- .../imxrt1050-evk/configs/knsh/defconfig | 1 - .../arm/imxrt/imxrt1050-evk/scripts/Make.defs | 21 +- .../imxrt1060-evk/configs/knsh/Make.defs | 16 +- .../imxrt1060-evk/configs/knsh/defconfig | 1 - .../arm/imxrt/imxrt1060-evk/scripts/Make.defs | 22 +- .../imxrt1064-evk/configs/knsh/Make.defs | 16 +- .../imxrt1064-evk/configs/knsh/defconfig | 1 - .../arm/imxrt/imxrt1064-evk/scripts/Make.defs | 22 +- boards/arm/imxrt/teensy-4.x/scripts/Make.defs | 29 +- .../kinetis/freedom-k28f/scripts/Make.defs | 14 - boards/arm/kinetis/freedom-k64f/README.txt | 4 +- .../kinetis/freedom-k64f/scripts/Make.defs | 14 - boards/arm/kinetis/freedom-k66f/README.txt | 4 +- .../kinetis/freedom-k66f/scripts/Make.defs | 14 - .../kinetis/kwikstik-k40/scripts/Make.defs | 14 - boards/arm/kinetis/teensy-3.x/README.txt | 4 +- .../kinetis/teensy-3.x/configs/nsh/defconfig | 1 - .../arm/kinetis/teensy-3.x/scripts/Make.defs | 14 - .../arm/kinetis/twr-k60n512/scripts/Make.defs | 14 - .../kinetis/twr-k64f120m/scripts/Make.defs | 14 - boards/arm/kl/freedom-kl25z/README.txt | 2 +- boards/arm/kl/freedom-kl25z/scripts/Make.defs | 15 - boards/arm/kl/freedom-kl26z/README.txt | 2 +- boards/arm/kl/freedom-kl26z/scripts/Make.defs | 15 - boards/arm/kl/teensy-lc/scripts/Make.defs | 15 - .../lc823450/lc823450-xgevk/scripts/Make.defs | 22 +- .../lc823450-xgevk/scripts/gnu-elf.ld | 125 - boards/arm/lpc17xx_40xx/lincoln60/README.txt | 2 +- .../lpc17xx_40xx/lincoln60/scripts/Make.defs | 14 - .../lpc17xx_40xx/lpc4088-devkit/README.txt | 2 +- .../lpc4088-devkit/configs/knsh/Make.defs | 14 - .../lpc4088-devkit/scripts/Make.defs | 14 - .../lpc4088-quickstart/README.txt | 2 +- .../lpc4088-quickstart/configs/knsh/Make.defs | 14 - .../lpc4088-quickstart/scripts/Make.defs | 14 - .../lpcxpresso-lpc1768/README.txt | 2 +- .../configs/thttpd/Make.defs | 14 - .../lpcxpresso-lpc1768/scripts/Make.defs | 14 - .../arm/lpc17xx_40xx/lx_cpu/scripts/Make.defs | 16 +- .../lpc17xx_40xx/lx_cpu/scripts/gnu-elf.ld | 125 - .../lx_cpu/src/lpc17_40_boardinitialize.c | 4 + .../arm/lpc17xx_40xx/mbed/scripts/Make.defs | 14 - .../lpc17xx_40xx/mcb1700/scripts/Make.defs | 14 - .../lpc17xx_40xx/olimex-lpc1766stk/README.txt | 6 +- .../configs/thttpd-binfs/Make.defs | 14 - .../configs/thttpd-nxflat/Make.defs | 14 - .../olimex-lpc1766stk/scripts/Make.defs | 14 - boards/arm/lpc17xx_40xx/open1788/README.txt | 2 +- .../open1788/configs/knsh/Make.defs | 14 - .../open1788/configs/knxterm/Make.defs | 14 - .../lpc17xx_40xx/open1788/scripts/Make.defs | 14 - .../pnev5180b/configs/knsh/Make.defs | 23 +- .../lpc17xx_40xx/pnev5180b/scripts/Make.defs | 23 +- .../u-blox-c027/scripts/Make.defs | 14 - .../zkit-arm-1769/scripts/Make.defs | 14 - .../lpc214x/mcu123-lpc214x/scripts/Make.defs | 6 - boards/arm/lpc214x/zp214xpa/README.txt | 4 +- boards/arm/lpc214x/zp214xpa/scripts/Make.defs | 6 - .../lpc2378/olimex-lpc2378/scripts/Make.defs | 6 - boards/arm/lpc31xx/ea3131/README.txt | 4 +- .../lpc31xx/ea3131/configs/pgnsh/Make.defs | 14 - boards/arm/lpc31xx/ea3131/scripts/Make.defs | 14 - boards/arm/lpc31xx/ea3152/README.txt | 2 +- boards/arm/lpc31xx/ea3152/scripts/Make.defs | 14 - .../arm/lpc31xx/olimex-lpc-h3131/README.txt | 4 +- .../olimex-lpc-h3131/scripts/Make.defs | 14 - boards/arm/lpc43xx/bambino-200e/README.txt | 3 +- .../lpc43xx/bambino-200e/scripts/Make.defs | 14 - boards/arm/lpc43xx/bambino-200e/src/Makefile | 4 - .../lpc43xx/bambino-200e/src/lpc43_ostest.c | 94 - boards/arm/lpc43xx/lpc4330-xplorer/README.txt | 5 +- .../lpc43xx/lpc4330-xplorer/scripts/Make.defs | 14 - .../arm/lpc43xx/lpc4330-xplorer/src/Makefile | 4 - .../lpc4330-xplorer/src/lpc43_ostest.c | 98 - boards/arm/lpc43xx/lpc4337-ws/README.txt | 5 +- .../arm/lpc43xx/lpc4337-ws/scripts/Make.defs | 14 - boards/arm/lpc43xx/lpc4357-evb/README.txt | 5 +- .../arm/lpc43xx/lpc4357-evb/scripts/Make.defs | 14 - boards/arm/lpc43xx/lpc4357-evb/src/Makefile | 4 - .../lpc43xx/lpc4357-evb/src/lpc43_ostest.c | 98 - boards/arm/lpc43xx/lpc4370-link2/README.txt | 5 +- .../lpc43xx/lpc4370-link2/scripts/Make.defs | 14 - boards/arm/lpc43xx/lpc4370-link2/src/Makefile | 4 - .../lpc43xx/lpc4370-link2/src/lpc43_ostest.c | 98 - .../lpc54xx/lpcxpresso-lpc54628/README.txt | 2 +- .../lpcxpresso-lpc54628/scripts/Make.defs | 15 - .../max32660-evsys/configs/nsh/defconfig | 1 - .../max326xx/max32660-evsys/scripts/Make.defs | 16 +- boards/arm/moxart/moxa/scripts/Make.defs | 16 +- .../arm/nrf52/nrf52-feather/scripts/Make.defs | 15 - .../arm/nrf52/nrf52832-dk/scripts/Make.defs | 15 - boards/arm/nrf52/nrf52832-dk/src/nrf52_boot.c | 2 +- .../arm/nrf52/nrf52832-mdk/scripts/Make.defs | 15 - .../nrf52/nrf52832-sparkfun/scripts/Make.defs | 15 - .../arm/nrf52/nrf52840-dk/scripts/Make.defs | 15 - boards/arm/nrf52/nrf52840-dk/src/nrf52_boot.c | 2 +- .../nrf52/nrf52840-dongle/scripts/Make.defs | 15 - .../nrf52/nrf52840-dongle/src/nrf52_boot.c | 2 +- boards/arm/nuc1xx/nutiny-nuc120/README.txt | 2 +- .../nuc1xx/nutiny-nuc120/scripts/Make.defs | 15 - boards/arm/phy62xx/phy6222/scripts/Make.defs | 19 +- boards/arm/phy62xx/phy6222/scripts/gnu-elf.ld | 116 - .../pimoroni-tiny2040/scripts/Make.defs | 14 - .../rp2040/raspberrypi-pico/scripts/Make.defs | 14 - .../arm/s32k1xx/s32k118evb/scripts/Make.defs | 15 - .../arm/s32k1xx/s32k144evb/scripts/Make.defs | 14 - .../arm/s32k1xx/s32k146evb/scripts/Make.defs | 14 - .../arm/s32k1xx/s32k148evb/scripts/Make.defs | 14 - .../arm/s32k1xx/ucans32k146/scripts/Make.defs | 14 - boards/arm/sam34/arduino-due/README.txt | 2 +- .../arm/sam34/arduino-due/scripts/Make.defs | 14 - boards/arm/sam34/flipnclick-sam3x/README.txt | 2 +- .../sam34/flipnclick-sam3x/scripts/Make.defs | 14 - boards/arm/sam34/sam3u-ek/README.txt | 2 +- .../arm/sam34/sam3u-ek/configs/knsh/Make.defs | 14 - boards/arm/sam34/sam3u-ek/scripts/Make.defs | 14 - boards/arm/sam34/sam4cmp-db/scripts/Make.defs | 14 - boards/arm/sam34/sam4e-ek/README.txt | 2 +- boards/arm/sam34/sam4e-ek/scripts/Make.defs | 16 +- boards/arm/sam34/sam4l-xplained/README.txt | 2 +- .../sam34/sam4l-xplained/scripts/Make.defs | 14 - .../arm/sam34/sam4s-xplained-pro/README.txt | 2 +- .../sam4s-xplained-pro/scripts/Make.defs | 14 - boards/arm/sam34/sam4s-xplained/README.txt | 2 +- .../sam34/sam4s-xplained/scripts/Make.defs | 14 - boards/arm/sama5/giant-board/README.md | 2 +- .../arm/sama5/giant-board/scripts/Make.defs | 16 +- .../arm/sama5/giant-board/scripts/gnu-elf.ld | 124 - boards/arm/sama5/giant-board/src/Makefile | 4 - boards/arm/sama5/giant-board/src/sam_ostest.c | 94 - boards/arm/sama5/sama5d2-xult/README.txt | 2 +- .../arm/sama5/sama5d2-xult/scripts/Make.defs | 16 +- .../arm/sama5/sama5d2-xult/scripts/gnu-elf.ld | 124 - boards/arm/sama5/sama5d2-xult/src/Makefile | 4 - .../arm/sama5/sama5d2-xult/src/sam_ostest.c | 98 - boards/arm/sama5/sama5d3-xplained/README.txt | 9 +- .../sama5/sama5d3-xplained/scripts/Make.defs | 16 +- .../sama5/sama5d3-xplained/scripts/gnu-elf.ld | 124 - .../arm/sama5/sama5d3-xplained/src/Makefile | 4 - .../sama5/sama5d3-xplained/src/sam_ostest.c | 98 - boards/arm/sama5/sama5d3x-ek/README.txt | 11 +- .../arm/sama5/sama5d3x-ek/scripts/Make.defs | 16 +- .../arm/sama5/sama5d3x-ek/scripts/gnu-elf.ld | 124 - boards/arm/sama5/sama5d3x-ek/src/Makefile | 4 - boards/arm/sama5/sama5d3x-ek/src/sam_ostest.c | 98 - boards/arm/sama5/sama5d4-ek/README.txt | 17 +- .../sama5/sama5d4-ek/configs/knsh/Make.defs | 16 +- .../sama5/sama5d4-ek/include/nsh_romfsimg.h | 20 + .../sama5d4-ek/include/rc.sysinit.template | 12 + .../arm/sama5/sama5d4-ek/include/rcS.template | 12 - boards/arm/sama5/sama5d4-ek/scripts/Make.defs | 16 +- .../arm/sama5/sama5d4-ek/scripts/gnu-elf.ld | 125 - boards/arm/sama5/sama5d4-ek/src/Makefile | 4 - boards/arm/sama5/sama5d4-ek/src/sam_ostest.c | 98 - .../arm/samd2l2/arduino-m0/scripts/Make.defs | 15 - boards/arm/samd2l2/arduino-m0/src/sam_boot.c | 2 +- .../samd2l2/circuit-express/scripts/Make.defs | 15 - .../samd2l2/circuit-express/src/sam_boot.c | 2 +- boards/arm/samd2l2/samd20-xplained/README.txt | 5 +- .../samd2l2/samd20-xplained/scripts/Make.defs | 15 - boards/arm/samd2l2/samd21-xplained/README.txt | 2 +- .../samd2l2/samd21-xplained/scripts/Make.defs | 15 - boards/arm/samd2l2/saml21-xplained/README.txt | 6 +- .../samd2l2/saml21-xplained/scripts/Make.defs | 15 - boards/arm/samd5e5/metro-m4/scripts/Make.defs | 14 - .../arm/samd5e5/metro-m4/src/sam_automount.c | 4 +- boards/arm/samd5e5/metro-m4/src/sam_bringup.c | 2 +- boards/arm/samd5e5/metro-m4/src/sam_gpio.c | 6 +- .../same54-xplained-pro/scripts/Make.defs | 14 - .../same54-xplained-pro/src/sam_autoleds.c | 2 +- .../same54-xplained-pro/src/sam_boot.c | 2 +- boards/arm/samv7/common/scripts/gnu-elf.ld | 116 - boards/arm/samv7/common/src/sam_automount.c | 4 +- boards/arm/samv7/same70-qmtech/README.txt | 2 +- .../configs/mcuboot-loader/defconfig | 1 - .../configs/mcuboot-slot-confirm/defconfig | 1 - .../samv7/same70-qmtech/configs/nsh/defconfig | 1 - .../arm/samv7/same70-qmtech/scripts/Make.defs | 17 +- boards/arm/samv7/same70-xplained/README.txt | 2 +- .../same70-xplained/configs/adc/defconfig | 1 - .../configs/mcuboot-loader/defconfig | 1 - .../configs/mcuboot-slot-confirm/defconfig | 1 - .../configs/mrf24j40-starhub/defconfig | 1 - .../same70-xplained/configs/netnsh/defconfig | 1 - .../same70-xplained/configs/nsh/defconfig | 1 - .../same70-xplained/configs/pwm/defconfig | 1 - .../same70-xplained/configs/pysim/defconfig | 1 - .../same70-xplained/configs/twm4nx/defconfig | 1 - .../samv7/same70-xplained/scripts/Make.defs | 17 +- boards/arm/samv7/samv71-xult/README.txt | 2 +- .../samv7/samv71-xult/configs/knsh/Make.defs | 17 +- .../samv7/samv71-xult/configs/knsh/defconfig | 1 - .../configs/mcuboot-loader/defconfig | 1 - .../configs/mcuboot-slot-confirm/defconfig | 1 - .../configs/mcuboot-swap-test/defconfig | 1 - .../configs/mcuboot-update-agent/defconfig | 1 - .../samv71-xult/configs/module/defconfig | 1 - .../configs/mrf24j40-starhub/defconfig | 1 - .../samv71-xult/configs/mxtxplnd/defconfig | 1 - .../samv71-xult/configs/netnsh/defconfig | 1 - .../samv7/samv71-xult/configs/nsh/defconfig | 1 - .../samv7/samv71-xult/configs/nxwm/defconfig | 1 - .../samv7/samv71-xult/configs/vnc/defconfig | 1 - .../samv7/samv71-xult/configs/vnxwm/defconfig | 1 - .../arm/samv7/samv71-xult/scripts/Make.defs | 17 +- boards/arm/stm32/axoloti/scripts/Make.defs | 17 +- boards/arm/stm32/axoloti/scripts/gnu-elf.ld | 126 - .../arm/stm32/b-g431b-esc1/scripts/Make.defs | 23 +- .../stm32/b-g474e-dpow1/configs/nsh/defconfig | 1 - .../arm/stm32/b-g474e-dpow1/scripts/Make.defs | 23 +- boards/arm/stm32/clicker2-stm32/README.txt | 2 +- .../stm32/clicker2-stm32/scripts/Make.defs | 24 +- .../stm32/clicker2-stm32/scripts/gnu-elf.ld | 126 - boards/arm/stm32/cloudctrl/README.txt | 2 +- boards/arm/stm32/cloudctrl/scripts/Make.defs | 14 - boards/arm/stm32/emw3162/scripts/Make.defs | 15 - .../stm32/et-stm32-stamp/scripts/Make.defs | 15 - .../arm/stm32/fire-stm32v2/scripts/Make.defs | 14 - boards/arm/stm32/hymini-stm32v/README.txt | 2 +- .../arm/stm32/hymini-stm32v/scripts/Make.defs | 14 - boards/arm/stm32/maple/scripts/Make.defs | 14 - boards/arm/stm32/mikroe-stm32f4/README.txt | 5 +- .../stm32/mikroe-stm32f4/scripts/Make.defs | 15 - .../stm32/mikroe-stm32f4/scripts/gnu-elf.ld | 116 - .../arm/stm32/mikroe-stm32f4/src/stm32_pm.c | 5 + .../mikroe-stm32f4/src/stm32_touchscreen.c | 7 +- .../stm32/mikroe-stm32f4/src/stm32_vs1053.c | 2 +- .../arm/stm32/nucleo-f103rb/scripts/Make.defs | 15 - .../arm/stm32/nucleo-f207zg/scripts/Make.defs | 15 - .../arm/stm32/nucleo-f302r8/scripts/Make.defs | 15 - .../arm/stm32/nucleo-f303re/scripts/Make.defs | 15 - .../arm/stm32/nucleo-f303ze/scripts/Make.defs | 15 - .../arm/stm32/nucleo-f334r8/scripts/Make.defs | 15 - .../arm/stm32/nucleo-f410rb/scripts/Make.defs | 15 - .../arm/stm32/nucleo-f412zg/scripts/Make.defs | 15 - .../arm/stm32/nucleo-f429zi/scripts/Make.defs | 15 - .../stm32/nucleo-f429zi/scripts/gnu-elf.ld | 116 - boards/arm/stm32/nucleo-f446re/README.txt | 4 +- .../arm/stm32/nucleo-f446re/scripts/Make.defs | 16 +- .../arm/stm32/nucleo-f446re/src/stm32_boot.c | 4 + boards/arm/stm32/nucleo-f4x1re/README.txt | 4 +- .../arm/stm32/nucleo-f4x1re/scripts/Make.defs | 19 +- .../arm/stm32/nucleo-g431kb/scripts/Make.defs | 23 +- .../arm/stm32/nucleo-g431rb/scripts/Make.defs | 23 +- .../arm/stm32/nucleo-l152re/scripts/Make.defs | 15 - .../stm32/olimex-stm32-e407/scripts/Make.defs | 18 +- .../arm/stm32/olimex-stm32-e407/src/Make.defs | 4 - .../stm32/olimex-stm32-h405/scripts/Make.defs | 15 - .../stm32/olimex-stm32-h407/scripts/Make.defs | 15 - .../arm/stm32/olimex-stm32-h407/src/Make.defs | 4 - .../stm32/olimex-stm32-p107/scripts/Make.defs | 14 - .../stm32/olimex-stm32-p207/scripts/Make.defs | 15 - .../olimex-stm32-p407/configs/kelf/Make.defs | 14 - .../configs/kmodule/Make.defs | 14 - .../olimex-stm32-p407/configs/knsh/Make.defs | 14 - .../stm32/olimex-stm32-p407/scripts/Make.defs | 15 - .../stm32/olimexino-stm32/scripts/Make.defs | 14 - .../arm/stm32/omnibusf4/configs/nsh/defconfig | 1 - boards/arm/stm32/omnibusf4/scripts/Make.defs | 17 +- boards/arm/stm32/omnibusf4/scripts/gnu-elf.ld | 126 - boards/arm/stm32/omnibusf4/src/Make.defs | 4 - boards/arm/stm32/omnibusf4/src/stm32_ostest.c | 96 - boards/arm/stm32/omnibusf4/src/stm32_pm.c | 5 + boards/arm/stm32/photon/scripts/Make.defs | 16 - .../stm32/photon/src/stm32_wlan_firmware.c | 43 +- boards/arm/stm32/shenzhou/README.txt | 2 +- boards/arm/stm32/shenzhou/scripts/Make.defs | 14 - boards/arm/stm32/stm3210e-eval/README.txt | 4 +- .../arm/stm32/stm3210e-eval/scripts/Make.defs | 14 - boards/arm/stm32/stm3210e-eval/src/stm32_pm.c | 5 + boards/arm/stm32/stm3220g-eval/README.txt | 8 +- .../arm/stm32/stm3220g-eval/scripts/Make.defs | 15 - boards/arm/stm32/stm3240g-eval/README.txt | 13 +- .../stm3240g-eval/configs/knxwm/Make.defs | 15 +- .../arm/stm32/stm3240g-eval/scripts/Make.defs | 15 - boards/arm/stm32/stm3240g-eval/src/Make.defs | 4 - .../stm32/stm3240g-eval/src/stm32_ostest.c | 98 - boards/arm/stm32/stm32_tiny/README.txt | 4 +- boards/arm/stm32/stm32_tiny/scripts/Make.defs | 15 - .../stm32/stm32butterfly2/scripts/Make.defs | 14 - .../stm32butterfly2/src/stm32_butterfly2.h | 2 - boards/arm/stm32/stm32f103-minimum/README.txt | 2 +- .../stm32/stm32f103-minimum/scripts/Make.defs | 18 +- .../stm32/stm32f334-disco/scripts/Make.defs | 15 - boards/arm/stm32/stm32f3discovery/README.txt | 5 +- .../stm32/stm32f3discovery/scripts/Make.defs | 15 - .../stm32/stm32f3discovery/scripts/gnu-elf.ld | 115 - .../stm32/stm32f411-minimum/scripts/Make.defs | 15 - .../stm32/stm32f411e-disco/scripts/Make.defs | 15 - boards/arm/stm32/stm32f429i-disco/README.txt | 3 +- .../stm32/stm32f429i-disco/scripts/Make.defs | 15 - .../stm32/stm32f429i-disco/scripts/gnu-elf.ld | 116 - .../arm/stm32/stm32f429i-disco/src/Make.defs | 4 - .../stm32/stm32f429i-disco/src/stm32_ostest.c | 98 - boards/arm/stm32/stm32f4discovery/README.txt | 17 +- .../configs/testlibcxx/defconfig | 1 - .../stm32f4discovery/configs/wifi/defconfig | 2 - .../stm32/stm32f4discovery/scripts/Make.defs | 27 +- .../stm32/stm32f4discovery/scripts/gnu-elf.ld | 126 - .../arm/stm32/stm32f4discovery/src/Make.defs | 4 - .../stm32f4discovery/src/stm32_cs43l22.c | 2 +- .../stm32/stm32f4discovery/src/stm32_ostest.c | 94 - .../arm/stm32/stm32f4discovery/src/stm32_pm.c | 5 + boards/arm/stm32/stm32ldiscovery/README.txt | 2 +- .../stm32/stm32ldiscovery/scripts/Make.defs | 14 - .../stm32/stm32ldiscovery/scripts/gnu-elf.ld | 116 - boards/arm/stm32/stm32vldiscovery/README.txt | 2 +- .../stm32/stm32vldiscovery/scripts/Make.defs | 15 - .../arm/stm32/viewtool-stm32f107/README.txt | 6 +- .../viewtool-stm32f107/scripts/Make.defs | 14 - .../b-l072z-lrwan1/scripts/Make.defs | 15 - .../arm/stm32f0l0g0/nucleo-f072rb/README.txt | 2 +- .../nucleo-f072rb/scripts/Make.defs | 15 - .../arm/stm32f0l0g0/nucleo-f091rc/README.txt | 2 +- .../nucleo-f091rc/scripts/Make.defs | 15 - .../nucleo-g070rb/scripts/Make.defs | 15 - .../nucleo-g071rb/scripts/Make.defs | 15 - .../nucleo-l073rz/scripts/Make.defs | 15 - .../stm32f051-discovery/scripts/Make.defs | 15 - .../stm32f051-discovery/scripts/gnu-elf.ld | 116 - .../stm32f072-discovery/scripts/Make.defs | 15 - .../stm32f072-discovery/scripts/gnu-elf.ld | 116 - boards/arm/stm32f7/nucleo-144/README.txt | 4 +- .../nucleo-144/configs/f722-nsh/Make.defs | 15 - .../nucleo-144/configs/f746-evalos/Make.defs | 15 - .../nucleo-144/configs/f746-nsh/Make.defs | 15 - .../nucleo-144/configs/f746-pysim/Make.defs | 15 - .../nucleo-144/configs/f767-evalos/Make.defs | 15 - .../nucleo-144/configs/f767-netnsh/Make.defs | 15 - .../nucleo-144/configs/f767-nsh/Make.defs | 15 - .../stm32f7/stm32f746-ws/scripts/Make.defs | 15 - .../arm/stm32f7/stm32f746g-disco/README.txt | 3 +- .../stm32f746g-disco/configs/fb/defconfig | 1 - .../stm32f746g-disco/configs/nsh/defconfig | 1 - .../stm32f746g-disco/scripts/Make.defs | 20 +- .../arm/stm32f7/stm32f746g-disco/src/Makefile | 4 - .../stm32f746g-disco/src/stm32_ostest.c | 98 - .../stm32f746g-disco/src/stm32_sdmmc.c | 4 +- .../stm32f769i-disco/configs/netnsh/defconfig | 1 - .../stm32f769i-disco/configs/nsh/defconfig | 1 - .../stm32f769i-disco/scripts/Make.defs | 15 - .../arm/stm32f7/stm32f769i-disco/src/Makefile | 4 - .../stm32f769i-disco/src/stm32_ostest.c | 98 - .../stm32h7/nucleo-h743zi/scripts/Make.defs | 17 +- .../stm32h7/nucleo-h743zi/scripts/gnu-elf.ld | 126 - .../nucleo-h743zi2/configs/jumbo/defconfig | 2 - .../stm32h7/nucleo-h743zi2/scripts/Make.defs | 17 +- .../stm32h7/nucleo-h743zi2/scripts/gnu-elf.ld | 126 - .../arm/stm32h7/nucleo-h743zi2/src/Makefile | 4 - .../stm32h7/nucleo-h743zi2/src/stm32_boot.c | 4 + .../stm32h7/nucleo-h743zi2/src/stm32_ostest.c | 94 - .../stm32h747i-disco/scripts/Make.defs | 15 - .../stm32h7/stm32h747i-disco/src/stm32_boot.c | 2 +- boards/arm/stm32l4/b-l475e-iot01a/README.txt | 2 +- .../stm32l4/b-l475e-iot01a/scripts/Make.defs | 16 +- boards/arm/stm32l4/nucleo-l432kc/README.txt | 4 +- .../stm32l4/nucleo-l432kc/scripts/Make.defs | 15 - boards/arm/stm32l4/nucleo-l452re/README.txt | 2 +- .../stm32l4/nucleo-l452re/scripts/Make.defs | 15 - boards/arm/stm32l4/nucleo-l476rg/README.txt | 4 +- .../stm32l4/nucleo-l476rg/scripts/Make.defs | 24 - boards/arm/stm32l4/nucleo-l496zg/README.txt | 2 +- .../stm32l4/nucleo-l496zg/scripts/Make.defs | 15 - .../stm32l4/stm32l476-mdk/scripts/Make.defs | 15 - .../arm/stm32l4/stm32l476vg-disco/README.txt | 2 +- .../stm32l476vg-disco/configs/knsh/Make.defs | 15 - .../stm32l476vg-disco/include/nsh_romfsimg.h | 20 + .../include/rc.sysinit.template | 2 + .../stm32l476vg-disco/scripts/Make.defs | 16 - .../arm/stm32l4/stm32l4r9ai-disco/README.txt | 2 +- .../stm32l4r9ai-disco/configs/knsh/Make.defs | 15 - .../stm32l4r9ai-disco/include/nsh_romfsimg.h | 20 + .../include/rc.sysinit.template | 2 + .../stm32l4r9ai-disco/scripts/Make.defs | 16 - boards/arm/stm32l5/nucleo-l552ze/README.txt | 2 +- .../stm32l5/nucleo-l552ze/scripts/Make.defs | 23 +- .../stm32l5/nucleo-l552ze/src/stm32_boot.c | 2 +- boards/arm/stm32l5/stm32l562e-dk/README.txt | 2 +- .../stm32l5/stm32l562e-dk/scripts/Make.defs | 23 +- .../stm32l5/stm32l562e-dk/src/stm32_boot.c | 2 +- boards/arm/stm32u5/b-u585i-iot02a/README.txt | 9 +- .../b-u585i-iot02a/configs/nsh/defconfig | 4 +- .../stm32u5/b-u585i-iot02a/include/board.h | 77 +- .../stm32u5/b-u585i-iot02a/scripts/Make.defs | 25 +- .../stm32u5/b-u585i-iot02a/scripts/flash.ld | 103 + .../stm32u5/b-u585i-iot02a/src/stm32_boot.c | 2 +- .../str71x/olimex-strp711/scripts/Make.defs | 6 - boards/arm/tiva/dk-tm4c129x/README.txt | 2 +- boards/arm/tiva/dk-tm4c129x/scripts/Make.defs | 14 - boards/arm/tiva/eagle100/README.txt | 5 +- boards/arm/tiva/eagle100/scripts/Make.defs | 14 - .../arm/tiva/ekk-lm3s9b96/scripts/Make.defs | 14 - .../tiva/launchxl-cc1310/scripts/Make.defs | 17 +- .../launchxl-cc1312r1/configs/nsh/defconfig | 1 - .../tiva/launchxl-cc1312r1/scripts/Make.defs | 16 +- .../arm/tiva/lm3s6432-s2e/scripts/Make.defs | 14 - boards/arm/tiva/lm3s6965-ek/README.txt | 2 +- boards/arm/tiva/lm3s6965-ek/scripts/Make.defs | 16 +- .../arm/tiva/lm3s6965-ek/scripts/gnu-elf.ld | 126 - boards/arm/tiva/lm3s8962-ek/scripts/Make.defs | 14 - .../tiva/lm4f120-launchpad/scripts/Make.defs | 14 - .../tiva/tm4c123g-launchpad/scripts/Make.defs | 14 - .../tiva/tm4c1294-launchpad/scripts/Make.defs | 14 - .../arm/tms570/launchxl-tms57004/README.txt | 4 +- .../launchxl-tms57004/scripts/Make.defs | 17 +- .../tms570ls31x-usb-kit/scripts/Make.defs | 17 +- boards/arm/xmc4/xmc4500-relax/README.txt | 2 +- .../xmc4/xmc4500-relax/configs/nsh/defconfig | 1 - .../arm/xmc4/xmc4500-relax/scripts/Make.defs | 17 +- boards/arm/xmc4/xmc4500-relax/src/Makefile | 4 - .../arm/xmc4/xmc4500-relax/src/xmc4_ostest.c | 94 - .../xmc4/xmc4700-relax/configs/nsh/defconfig | 1 - .../arm/xmc4/xmc4700-relax/scripts/Make.defs | 17 +- boards/arm/xmc4/xmc4700-relax/src/Makefile | 4 - .../arm/xmc4/xmc4700-relax/src/xmc4_ostest.c | 94 - .../avr/at32uc3/avr32dev1/scripts/Make.defs | 15 +- .../at90usb/micropendous3/scripts/Make.defs | 10 - .../avr/at90usb/teensy-2.0/scripts/Make.defs | 11 - boards/avr/atmega/amber/scripts/Make.defs | 10 - boards/avr/atmega/amber/scripts/gnu-elf.ld | 124 - .../atmega/arduino-mega2560/scripts/Make.defs | 11 - .../avr/atmega/moteino-mega/scripts/Make.defs | 10 - boards/boardctl.c | 23 +- .../hc/m9s12/demo9s12ne64/scripts/Make.defs | 3 +- boards/hc/m9s12/ne64badge/scripts/Make.defs | 3 +- boards/mips/pic32mx/mirtoo/README.txt | 2 +- boards/mips/pic32mx/mirtoo/scripts/Make.defs | 10 - .../mips/pic32mx/mirtoo/src/pic32_appinit.c | 4 +- boards/mips/pic32mx/mirtoo/src/pic32_leds.c | 2 +- boards/mips/pic32mx/mirtoo/src/pic32_spi2.c | 6 +- .../pic32mx-starterkit/scripts/Make.defs | 10 - .../pic32mx-starterkit/src/pic32mx_appinit.c | 4 +- .../pic32mx-starterkit/src/pic32mx_leds.c | 2 +- .../pic32mx-starterkit/src/pic32mx_spi.c | 24 +- .../pic32mx-starterkit/src/pic32mx_usbdev.c | 4 +- .../pic32mx/pic32mx7mmb/scripts/Make.defs | 10 - .../pic32mx/pic32mx7mmb/src/pic32_bringup.c | 4 +- .../mips/pic32mx/pic32mx7mmb/src/pic32_leds.c | 2 +- .../pic32mx/pic32mx7mmb/src/pic32_mio283qt2.c | 42 +- .../mips/pic32mx/pic32mx7mmb/src/pic32_spi.c | 24 +- .../pic32mx7mmb/src/pic32_touchscreen.c | 105 +- .../pic32mx/pic32mx7mmb/src/pic32_usbdev.c | 4 +- .../pic32mx/sure-pic32mx/scripts/Make.defs | 10 - .../sure-pic32mx/src/pic32mx_appinit.c | 4 +- .../sure-pic32mx/src/pic32mx_autoleds.c | 2 +- .../sure-pic32mx/src/pic32mx_buttons.c | 2 +- .../sure-pic32mx/src/pic32mx_lcd1602.c | 48 +- .../pic32mx/sure-pic32mx/src/pic32mx_spi.c | 4 +- .../pic32mx/sure-pic32mx/src/pic32mx_usbdev.c | 4 +- boards/mips/pic32mx/ubw32/scripts/Make.defs | 10 - boards/mips/pic32mx/ubw32/src/pic32_buttons.c | 2 +- boards/mips/pic32mx/ubw32/src/pic32_leds.c | 2 +- boards/mips/pic32mx/ubw32/src/pic32_usbdev.c | 4 +- .../pic32mz/chipkit-wifire/scripts/Make.defs | 12 +- .../chipkit-wifire/src/pic32mz_buttons.c | 2 +- .../pic32mz/chipkit-wifire/src/pic32mz_spi.c | 60 +- .../flipnclick-pic32mz/scripts/Make.defs | 12 +- .../src/flipnclick-pic32mz.h | 2 +- .../flipnclick-pic32mz/src/pic32mz_buttons.c | 2 +- .../flipnclick-pic32mz/src/pic32mz_spi.c | 60 +- .../flipnclick-pic32mz/src/pic32mz_ssd1306.c | 8 +- .../pic32mz-starterkit/scripts/Make.defs | 12 +- .../pic32mz-starterkit/src/pic32mz_autoleds.c | 2 +- .../pic32mz-starterkit/src/pic32mz_bringup.c | 2 +- .../pic32mz-starterkit/src/pic32mz_buttons.c | 2 +- .../pic32mz-starterkit/src/pic32mz_spi.c | 36 +- boards/misoc/lm32/misoc/scripts/Make.defs | 10 - boards/or1k/mor1kx/or1k/scripts/Make.defs | 15 - .../rx65n/rx65n-grrose/include/README.TXT | 15 +- .../rx65n/rx65n-grrose/src/rx65n_bringup.c | 6 +- .../rx65n/rx65n-grrose/src/rx65n_sbram.c | 4 +- .../rx65n/rx65n-rsk2mb/include/README.TXT | 13 +- .../rx65n/rx65n-rsk2mb/src/rx65n_bringup.c | 6 +- .../rx65n/rx65n-rsk2mb/src/rx65n_sbram.c | 4 +- .../bl602/bl602evb/configs/elf/defconfig | 1 - .../bl602/bl602evb/configs/fpu/defconfig | 1 - .../bl602/bl602evb/configs/timer/defconfig | 1 - .../bl602/bl602evb/configs/wifi/defconfig | 1 - .../risc-v/bl602/bl602evb/scripts/Make.defs | 22 +- .../risc-v/bl602/bl602evb/scripts/gnu-elf.ld | 115 - boards/risc-v/bl602/bl602evb/src/Makefile | 4 - .../risc-v/bl602/bl602evb/src/bl602_bringup.c | 36 +- boards/risc-v/bl602/bl602evb/src/bl602_gpio.c | 60 +- .../risc-v/bl602/bl602evb/src/bl602_ostest.c | 92 - .../c906/smartl-c906/configs/elf/defconfig | 1 - .../c906/smartl-c906/configs/fpu/defconfig | 1 - .../c906/smartl-c906/configs/knsh/defconfig | 1 - .../c906/smartl-c906/configs/module/defconfig | 1 - .../c906/smartl-c906/configs/nsh/defconfig | 1 - .../c906/smartl-c906/configs/sotest/defconfig | 1 - .../risc-v/c906/smartl-c906/scripts/Make.defs | 19 +- .../c906/smartl-c906/scripts/gnu-elf.ld | 115 - boards/risc-v/c906/smartl-c906/src/Makefile | 4 - .../risc-v/c906/smartl-c906/src/c906_ostest.c | 92 - .../esp32c3-devkit/configs/cxx/defconfig | 49 + .../esp32c3-devkit/configs/twai/defconfig | 48 + .../esp32c3/esp32c3-devkit/scripts/Make.defs | 19 +- .../esp32c3/esp32c3-devkit/scripts/esp32c3.ld | 11 +- .../esp32c3/esp32c3-devkit/src/Makefile | 6 +- .../esp32c3/esp32c3-devkit/src/README.txt | 13 +- .../esp32c3-devkit/src/esp32c3-devkit.h | 16 + .../esp32c3-devkit/src/esp32c3_board_spi.c | 7 +- .../esp32c3-devkit/src/esp32c3_board_spidev.c | 2 +- .../src/esp32c3_board_spislavedev.c | 2 +- .../esp32c3-devkit/src/esp32c3_bringup.c | 11 + .../esp32c3-devkit/src/esp32c3_gc9a01.c | 2 +- .../esp32c3/esp32c3-devkit/src/esp32c3_gpio.c | 44 +- .../esp32c3/esp32c3-devkit/src/esp32c3_i2c.c | 2 +- .../esp32c3-devkit/src/esp32c3_oneshot.c | 2 +- .../esp32c3-devkit/src/esp32c3_spiflash.c | 14 +- .../esp32c3-devkit/src/esp32c3_st7735.c | 2 +- .../esp32c3-devkit/src/esp32c3_st7789.c | 2 +- .../esp32c3/esp32c3-devkit/src/esp32c3_twai.c | 93 + .../esp32c3-devkit/src/etc/init.d/rc.sysinit | 36 + .../esp32c3/esp32c3-devkit/src/etc/init.d/rcS | 17 - .../fe310/hifive1-revb/scripts/Make.defs | 17 +- .../fe310/hifive1-revb/src/fe310_buttons.c | 2 +- boards/risc-v/k210/maix-bit/scripts/Make.defs | 20 +- .../risc-v/k210/maix-bit/scripts/gnu-elf.ld | 115 - boards/risc-v/k210/maix-bit/src/k210_gpio.c | 16 +- boards/risc-v/litex/arty_a7/Kconfig | 20 + boards/risc-v/litex/arty_a7/README.txt | 3 + boards/risc-v/litex/arty_a7/scripts/Make.defs | 18 +- boards/risc-v/litex/arty_a7/src/Makefile | 8 + boards/risc-v/litex/arty_a7/src/arty_a7.h | 115 + .../litex/arty_a7/src/litex_automount.c | 336 ++ .../risc-v/litex/arty_a7/src/litex_bringup.c | 51 +- .../risc-v/litex/arty_a7/src/litex_sdio.c | 125 +- boards/risc-v/mpfs/common/src/Make.defs | 4 - boards/risc-v/mpfs/common/src/mpfs_emmcsd.c | 2 +- boards/risc-v/mpfs/common/src/mpfs_i2c.c | 2 +- boards/risc-v/mpfs/common/src/mpfs_ostest.c | 92 - .../mpfs/icicle/configs/hwtest/defconfig | 1 - .../risc-v/mpfs/icicle/configs/knsh/defconfig | 43 +- .../mpfs/icicle/configs/network/defconfig | 1 - .../risc-v/mpfs/icicle/configs/nsh/defconfig | 1 - .../mpfs/icicle/configs/opensbi/defconfig | 1 - .../risc-v/mpfs/icicle/configs/pnsh/defconfig | 80 + boards/risc-v/mpfs/icicle/include/.gitignore | 2 + .../mpfs/icicle/include/board_memorymap.h | 5 + .../mpfs/icicle/include/boot_romfsimg.h | 35 + boards/risc-v/mpfs/icicle/scripts/Make.defs | 19 +- boards/risc-v/mpfs/icicle/scripts/gnu-elf.ld | 115 - .../mpfs/icicle/scripts/ld-kernel.script | 11 +- .../mpfs/m100pfsevp/configs/nsh/defconfig | 1 - .../risc-v/mpfs/m100pfsevp/scripts/Make.defs | 19 +- .../risc-v/mpfs/m100pfsevp/scripts/gnu-elf.ld | 115 - boards/risc-v/qemu-rv/rv-virt/README.txt | 15 +- .../qemu-rv/rv-virt/configs/nsh/defconfig | 28 +- .../qemu-rv/rv-virt/configs/nsh64/defconfig | 29 +- .../qemu-rv/rv-virt/configs/smp/defconfig | 1 - .../qemu-rv/rv-virt/configs/smp64/defconfig | 1 - .../risc-v/qemu-rv/rv-virt/scripts/Make.defs | 35 +- boards/risc-v/qemu-rv/rv-virt/src/Makefile | 4 +- .../qemu-rv/rv-virt/src/etc/init.d/rc.sysinit | 19 + .../risc-v/qemu-rv/rv-virt/src/etc/init.d/rcS | 19 + .../qemu-rv/rv-virt/src/qemu_rv_ostest.c | 92 - .../rv32m1/rv32m1-vega/scripts/Make.defs | 17 +- .../rv32m1/rv32m1-vega/src/rv32m1_buttons.c | 2 +- boards/sim/sim/sim/README.txt | 4 +- boards/sim/sim/sim/include/board.h | 16 + boards/sim/sim/sim/scripts/Make.defs | 38 +- boards/sim/sim/sim/scripts/gnu-elf.ld | 117 - boards/sim/sim/sim/src/Makefile | 2 +- boards/sim/sim/sim/src/README.txt | 13 +- boards/sim/sim/sim/src/dummy.c | 20 +- boards/sim/sim/sim/src/etc/init.d/rc.sysinit | 36 + boards/sim/sim/sim/src/etc/init.d/rcS | 17 - boards/sim/sim/sim/src/sim_bringup.c | 26 +- boards/sim/sim/sim/src/sim_buttons.c | 4 +- boards/sim/sim/sim/src/sim_foc.c | 2 +- boards/sim/sim/sim/src/sim_gpio.c | 26 +- boards/sim/sim/sim/src/sim_ioexpander.c | 18 +- boards/sparc/bm3803/xx3803/scripts/Make.defs | 24 +- boards/sparc/bm3803/xx3803/scripts/gnu-elf.ld | 84 - .../sparc/bm3803/xx3803/src/bm3803_am29lv.c | 4 +- boards/sparc/bm3803/xx3803/src/bm3803_wdt.c | 8 +- .../sparc/bm3823/xx3823/configs/nsh/defconfig | 9 - boards/sparc/bm3823/xx3823/scripts/Make.defs | 17 +- .../sparc/bm3823/xx3823/src/bm3823_am29lv.c | 6 +- .../xtensa/esp32/common/src/esp32_board_i2c.c | 2 +- .../xtensa/esp32/common/src/esp32_board_spi.c | 12 +- .../esp32/common/src/esp32_board_spidev.c | 2 +- .../esp32/common/src/esp32_board_spiflash.c | 14 +- .../xtensa/esp32/common/src/esp32_ili9341.c | 52 +- .../esp32/common/src/esp32_lcd_backpack.c | 4 +- .../xtensa/esp32/common/src/esp32_mcp2515.c | 30 +- .../xtensa/esp32/common/src/esp32_oneshot.c | 2 +- .../xtensa/esp32/common/src/esp32_ssd1306.c | 6 +- .../esp32/esp32-devkitc/configs/cxx/defconfig | 50 + .../esp32/esp32-devkitc/scripts/Make.defs | 19 - .../xtensa/esp32/esp32-devkitc/src/Make.defs | 4 + .../esp32/esp32-devkitc/src/esp32_boot.c | 2 +- .../esp32/esp32-devkitc/src/esp32_bringup.c | 11 + .../esp32/esp32-devkitc/src/esp32_buttons.c | 2 +- .../esp32/esp32-devkitc/src/esp32_gpio.c | 46 +- .../esp32/esp32-devkitc/src/esp32_twai.c | 92 + .../esp32-ethernet-kit/scripts/Make.defs | 19 - .../esp32/esp32-ethernet-kit/src/esp32_boot.c | 2 +- .../esp32-ethernet-kit/src/esp32_buttons.c | 2 +- .../esp32/esp32-wrover-kit/scripts/Make.defs | 19 - .../esp32/esp32-wrover-kit/src/esp32_boot.c | 2 +- .../esp32-wrover-kit/src/esp32_buttons.c | 2 +- .../esp32/esp32-wrover-kit/src/esp32_gpio.c | 46 +- .../esp32/ttgo_lora_esp32/scripts/Make.defs | 19 - .../esp32/ttgo_lora_esp32/src/esp32_boot.c | 2 +- .../esp32/ttgo_lora_esp32/src/esp32_buttons.c | 2 +- .../esp32/ttgo_lora_esp32/src/esp32_gpio.c | 46 +- .../esp32s2-saola-1/configs/cxx/defconfig | 49 + .../esp32s2/esp32s2-saola-1/scripts/Make.defs | 23 +- .../esp32s2-saola-1/scripts/esp32s2_rom.ld | 15 +- .../esp32s2-saola-1/src/esp32s2_gpio.c | 52 +- .../common/src/esp32s3_board_spiflash.c | 10 +- .../esp32s3-devkit/configs/cxx/defconfig | 51 + .../esp32s3/esp32s3-devkit/scripts/Make.defs | 15 +- .../esp32s3-devkit/src/esp32s3_buttons.c | 2 +- boards/z80/z80/z80sim/README.txt | 6 +- drivers/analog/comp.c | 2 +- drivers/analog/dac.c | 2 +- drivers/audio/cs43l22.h | 2 +- drivers/audio/cxd56.c | 18 +- drivers/audio/cxd56.h | 2 +- drivers/audio/cxd56_src.c | 6 +- drivers/audio/vs1053.c | 2 +- drivers/audio/wm8776.h | 2 +- drivers/audio/wm8904.c | 47 +- drivers/audio/wm8904.h | 2 +- drivers/audio/wm8994.c | 10 +- drivers/audio/wm8994.h | 2 +- drivers/can/can.c | 2 +- drivers/clk/Kconfig | 2 +- drivers/drivers_initialize.c | 6 - drivers/efuse/efuse.c | 32 +- drivers/input/ads7843e.c | 20 +- drivers/input/ajoystick.c | 4 +- drivers/input/button_upper.c | 4 +- drivers/input/cypress_mbr3108.c | 2 +- drivers/input/djoystick.c | 4 +- drivers/input/ft5x06.c | 7 +- drivers/input/max11802.c | 4 +- drivers/input/mxt.c | 7 +- drivers/input/nunchuck.c | 8 +- drivers/input/spq10kbd.c | 4 +- drivers/input/stmpe811_tsc.c | 17 +- drivers/input/touchscreen_upper.c | 6 +- drivers/input/tsc2007.c | 7 +- drivers/input/uinput.c | 2 +- drivers/ioexpander/Kconfig | 1 + drivers/ioexpander/gpio.c | 33 +- drivers/ioexpander/ioe_rpmsg.c | 17 +- drivers/lcd/ht16k33_14seg.c | 42 +- drivers/lcd/lcd_dev.c | 36 +- drivers/lcd/pcf8574_lcd_backpack.c | 12 +- drivers/lcd/st7032.c | 32 +- drivers/leds/apa102.c | 34 +- drivers/leds/max7219.c | 36 +- drivers/leds/ncp5623c.c | 39 +- drivers/leds/ws2812.c | 32 +- drivers/math/cordic.c | 32 +- drivers/misc/lwl_console.c | 28 +- drivers/mmcsd/mmcsd_sdio.c | 79 +- drivers/modem/altair/altmdm.c | 44 +- drivers/mtd/at24xx.c | 10 - drivers/mtd/gd5f.c | 40 +- drivers/mtd/mtd_config.c | 237 +- drivers/net/Kconfig | 2 +- drivers/net/tun.c | 13 +- drivers/pipes/pipe_common.c | 4 +- drivers/power/Kconfig | 2 +- drivers/power/Make.defs | 2 +- drivers/power/activity_governor.c | 12 +- drivers/power/activity_governor.h | 190 - drivers/power/greedy_governor.c | 7 +- drivers/power/pm.h | 39 +- drivers/power/pm_activity.c | 8 +- drivers/power/pm_autoupdate.c | 4 +- drivers/power/pm_changestate.c | 4 +- drivers/power/pm_initialize.c | 6 - drivers/power/pm_lock.c | 75 + drivers/power/pm_register.c | 15 +- drivers/power/pm_unregister.c | 13 +- drivers/power/powerled.c | 8 +- drivers/power/regulator.c | 6 +- drivers/rc/lirc_dev.c | 2 +- drivers/rf/dat-31r5-sp.c | 34 +- drivers/rptun/Kconfig | 35 +- drivers/rptun/Make.defs | 7 +- drivers/rptun/rptun.c | 479 ++- drivers/rptun/rptun.h | 44 + drivers/rptun/rptun_dump.c | 123 + drivers/rptun/rptun_ping.c | 192 + drivers/segger/Make.defs | 1 + drivers/segger/config/SEGGER_RTT_Conf.h | 4 +- drivers/segger/note_sysview.c | 6 + drivers/sensors/Kconfig | 31 + drivers/sensors/Make.defs | 4 + drivers/sensors/adt7320.c | 16 +- drivers/sensors/adxl345_base.c | 34 +- drivers/sensors/apds9960.c | 44 +- drivers/sensors/as726x.c | 50 +- drivers/sensors/bh1750fvi.c | 40 +- drivers/sensors/bmg160.c | 24 +- drivers/sensors/bmp180.c | 32 +- drivers/sensors/dhtxx.c | 49 +- drivers/sensors/hc_sr04.c | 2 +- drivers/sensors/hts221.c | 2 +- drivers/sensors/ina219.c | 17 +- drivers/sensors/ina226.c | 17 +- drivers/sensors/ina3221.c | 55 +- drivers/sensors/isl29023.c | 39 +- drivers/sensors/kxtj9.c | 40 +- drivers/sensors/lis2dh.c | 2 +- drivers/sensors/lis3dsh.c | 24 +- drivers/sensors/lis3mdl.c | 36 +- drivers/sensors/lm75.c | 32 +- drivers/sensors/lm92.c | 36 +- drivers/sensors/lsm303agr.c | 37 +- drivers/sensors/lsm6dsl.c | 37 +- drivers/sensors/lsm9ds1.c | 32 +- drivers/sensors/ltc4151.c | 45 +- drivers/sensors/max31855.c | 32 +- drivers/sensors/max44009.c | 2 +- drivers/sensors/max6675.c | 39 +- drivers/sensors/mb7040.c | 32 +- drivers/sensors/mcp9844.c | 37 +- drivers/sensors/mlx90393.c | 26 +- drivers/sensors/mlx90614.c | 76 +- drivers/sensors/mpl115a.c | 32 +- drivers/sensors/mpu60x0.c | 22 +- drivers/sensors/ms58xx.c | 32 +- drivers/sensors/scd30.c | 10 +- drivers/sensors/scd41.c | 1030 ++++++ drivers/sensors/sensor.c | 2 +- drivers/sensors/sgp30.c | 2 +- drivers/sensors/t67xx.c | 47 - drivers/sensors/veml6070.c | 38 +- drivers/sensors/vl53l1x.c | 44 +- drivers/sensors/xen1210.c | 34 +- drivers/serial/Kconfig | 2 +- drivers/serial/pty.c | 6 +- drivers/serial/serial.c | 4 +- drivers/serial/uart_bth4.c | 20 +- drivers/spi/spi_slave_driver.c | 8 +- drivers/syslog/Kconfig | 12 +- drivers/syslog/syslog_console.c | 14 +- drivers/syslog/vsyslog.c | 7 +- drivers/timers/Kconfig | 4 +- drivers/timers/arch_timer.c | 2 +- drivers/timers/oneshot.c | 40 +- drivers/usbdev/adb.c | 10 +- drivers/usbdev/pl2303.c | 2 +- drivers/usbhost/usbhost_cdcacm.c | 2 +- drivers/usbhost/usbhost_cdcmbim.c | 34 +- drivers/usbhost/usbhost_hidkbd.c | 2 +- drivers/usbhost/usbhost_hidmouse.c | 4 +- drivers/usbhost/usbhost_hub.c | 4 +- drivers/usbhost/usbhost_max3421e.c | 2 +- drivers/usbhost/usbhost_xboxcontroller.c | 2 +- drivers/usbmisc/fusb301.c | 2 +- drivers/usbmisc/fusb303.c | 2 +- drivers/video/fb.c | 38 +- drivers/video/max7456.c | 77 +- drivers/video/video.c | 4 +- drivers/wireless/gs2200m.c | 24 +- drivers/wireless/nrf24l01.c | 34 +- fs/aio/aio_initialize.c | 2 +- fs/dirent/fs_opendir.c | 58 +- fs/fat/fs_fat32dirent.c | 2 +- fs/inode/fs_files.c | 26 +- fs/littlefs/lfs_vfs.c | 30 +- fs/procfs/fs_procfstcbinfo.c | 2 +- fs/romfs/fs_romfs.c | 3 +- fs/romfs/fs_romfsutil.c | 35 +- fs/rpmsgfs/Kconfig | 2 +- fs/rpmsgfs/rpmsgfs.c | 33 +- fs/rpmsgfs/rpmsgfs.h | 4 +- fs/rpmsgfs/rpmsgfs_client.c | 133 +- fs/rpmsgfs/rpmsgfs_server.c | 5 +- fs/socket/socket.c | 5 + fs/unionfs/fs_unionfs.c | 18 +- fs/vfs/fs_chstat.c | 2 +- fs/vfs/fs_fchstat.c | 2 +- fs/vfs/fs_fcntl.c | 5 + fs/vfs/fs_truncate.c | 15 +- graphics/nxglib/cursor/nxglib_cursor_backup.c | 2 +- graphics/nxterm/nxterm_driver.c | 6 +- graphics/nxterm/nxterm_register.c | 2 +- include/assert.h | 8 +- include/cxx/cstdlib | 1 - include/limits.h | 6 +- include/nuttx/addrenv.h | 2 + include/nuttx/arch.h | 88 +- include/nuttx/audio/audio_comp.h | 5 +- include/nuttx/binfmt/binfmt.h | 15 +- include/nuttx/board.h | 18 + include/nuttx/clk/clk.h | 2 +- include/nuttx/compiler.h | 52 +- include/nuttx/fs/ioctl.h | 3 + include/nuttx/himem/himem.h | 14 + include/nuttx/leds/ncp5623c.h | 39 +- include/nuttx/net/usrsock.h | 3 +- include/nuttx/power/pm.h | 16 + include/nuttx/rptun/openamp.h | 4 + include/nuttx/rptun/rptun.h | 56 +- include/nuttx/sched.h | 15 +- include/nuttx/sched_note.h | 128 +- include/nuttx/sdio.h | 20 + include/nuttx/sensors/as726x.h | 12 +- include/nuttx/sensors/scd41.h | 75 + include/nuttx/serial/tioctl.h | 1 + include/nuttx/streams.h | 53 + include/nuttx/video/imgdata.h | 2 +- include/nuttx/video/imgsensor.h | 2 +- include/nuttx/wireless/bluetooth/bt_buf.h | 7 - include/nuttx/wireless/bluetooth/bt_core.h | 7 - include/nuttx/wireless/bluetooth/bt_driver.h | 7 - include/nuttx/wireless/bluetooth/bt_gatt.h | 7 - include/nuttx/wireless/bluetooth/bt_hci.h | 7 - include/nuttx/wireless/bluetooth/bt_ioctl.h | 7 - include/nuttx/wireless/bluetooth/bt_null.h | 46 +- include/nuttx/wireless/bluetooth/bt_uart.h | 7 - include/nuttx/wireless/bluetooth/bt_uuid.h | 7 - include/nuttx/wireless/ieee80211/ieee80211.h | 1853 +++++++--- include/nuttx/wireless/wireless.h | 9 + include/nuttx/wqueue.h | 23 + include/spawn.h | 9 +- include/stdlib.h | 6 +- include/strings.h | 4 +- include/sys/boardctl.h | 42 +- include/sys/poll.h | 6 +- include/sys/syscall_lookup.h | 3 +- include/sys/uio.h | 6 + include/time.h | 2 + include/unistd.h | 14 + libs/libc/fixedmath/lib_ubsqrt.c | 6 +- libs/libc/libc.csv | 26 +- libs/libc/machine/arch_atomic.c | 386 +- libs/libc/machine/arm/gnu/arch_setjmp.S | 32 +- libs/libc/misc/lib_crc16.c | 53 +- libs/libc/misc/lib_err.c | 4 + libs/libc/misc/lib_glob.c | 2 +- libs/libc/modlib/modlib_bind.c | 6 +- libs/libc/net/lib_getifaddrs.c | 2 +- libs/libc/netdb/lib_dnsaddserver.c | 101 +- libs/libc/netdb/lib_dnscache.c | 2 +- libs/libc/netdb/lib_dnsforeach.c | 12 +- libs/libc/netdb/lib_dnsinit.c | 27 +- libs/libc/netdb/lib_netdb.c | 2 +- libs/libc/netdb/lib_netdb.h | 2 +- libs/libc/stdio/lib_libvsprintf.c | 2 +- libs/libc/stdlib/lib_realpath.c | 1 + libs/libc/stream/Make.defs | 4 + libs/libc/stream/lib_blkoutstream.c | 225 ++ libs/libc/stream/lib_memoutstream.c | 2 +- libs/libc/stream/lib_rawsostream.c | 2 +- libs/libc/string/lib_memcmp.c | 1 + libs/libc/string/lib_memcpy.c | 1 + libs/libc/string/lib_memmove.c | 1 + libs/libc/string/lib_memset.c | 1 + libs/libc/string/lib_strcasecmp.c | 5 +- libs/libc/string/lib_strcasestr.c | 11 +- libs/libc/string/lib_strcat.c | 6 +- libs/libc/string/lib_strcmp.c | 9 +- libs/libc/string/lib_strncasecmp.c | 7 +- libs/libc/string/lib_strncat.c | 4 +- libs/libc/string/lib_strncmp.c | 7 +- libs/libc/string/lib_strstr.c | 234 +- libs/libc/string/lib_strtokr.c | 4 +- libs/libc/string/lib_vikmemcpy.c | 7 +- libs/libc/time/Make.defs | 2 +- libs/libc/time/lib_localtime.c | 38 +- libs/libc/time/lib_strptime.c | 624 ++++ libs/libc/uio/Make.defs | 1 + libs/libc/uio/lib_preadv.c | 97 + .../libc/uio/lib_pwritev.c | 91 +- libs/libc/uio/lib_writev.c | 20 - libs/libc/unistd/Kconfig | 7 + libs/libc/unistd/Make.defs | 2 +- libs/libc/unistd/lib_chdir.c | 72 +- libs/libc/unistd/lib_execle.c | 183 + libs/libc/unistd/lib_execv.c | 101 + libs/libc/unistd/lib_restoredir.c | 8 +- libs/libc/unistd/lib_sysconf.c | 2 +- ...-macro-to-avoid-clashing-with-Xtensa.patch | 182 + ..._-un-signed_lock_free-if-unsupported.patch | 38 + libs/libxx/libcxx.defs | 6 +- mm/mm_heap/mm.h | 5 +- mm/mm_heap/mm_initialize.c | 10 +- net/arp/arp_send.c | 2 +- net/devif/devif_iobsend.c | 7 +- net/icmp/Make.defs | 2 +- net/icmp/icmp.h | 19 + net/icmp/icmp_ioctl.c | 90 + net/icmp/icmp_sockif.c | 3 +- net/icmpv6/Make.defs | 2 +- net/icmpv6/icmpv6.h | 19 + net/icmpv6/icmpv6_ioctl.c | 90 + net/icmpv6/icmpv6_sockif.c | 3 +- net/local/local_listen.c | 6 +- net/local/local_netpoll.c | 2 +- net/netdev/netdev_ifconf.c | 2 +- net/netdev/netdev_ioctl.c | 4 +- net/netdev/netdev_register.c | 2 +- net/netlink/netlink_route.c | 2 +- net/route/net_cacheroute.c | 4 +- net/rpmsg/Kconfig | 1 + net/rpmsg/rpmsg_sockif.c | 6 +- net/socket/connect.c | 10 +- net/tcp/tcp.h | 18 + net/tcp/tcp_conn.c | 17 +- net/tcp/tcp_ioctl.c | 13 + net/tcp/tcp_send_buffered.c | 42 +- net/tcp/tcp_wrbuffer.c | 40 + net/udp/udp.h | 18 + net/udp/udp_ioctl.c | 13 + net/udp/udp_recvfrom.c | 4 +- net/udp/udp_sendto_buffered.c | 36 +- net/udp/udp_wrbuffer.c | 34 + net/usrsock/usrsock_dev.c | 8 +- net/usrsock/usrsock_ioctl.c | 32 +- openamp/0006-openamp-fix-scenario-case.patch | 41 +- ...mp-divide-shram-to-TX-shram-RX-shram.patch | 130 + ...-t-need-check-status-when-get_tx_pay.patch | 34 + openamp/open-amp.defs | 2 + sched/environ/env_dup.c | 60 +- sched/environ/env_findvar.c | 27 +- sched/environ/env_foreach.c | 13 +- sched/environ/env_getenv.c | 12 +- sched/environ/env_getenvironptr.c | 24 +- sched/environ/env_release.c | 12 +- sched/environ/env_removevar.c | 60 +- sched/environ/env_setenv.c | 49 +- sched/environ/env_unsetenv.c | 45 +- sched/environ/environ.h | 17 +- sched/group/group_create.c | 12 - sched/init/nx_bringup.c | 2 +- sched/init/nx_start.c | 8 +- sched/irq/irq_dispatch.c | 39 +- sched/module/mod_insmod.c | 4 +- sched/mqueue/mq_timedsend.c | 2 +- sched/pthread/pthread.h | 1 - sched/pthread/pthread_create.c | 61 +- sched/pthread/pthread_detach.c | 15 +- sched/pthread/pthread_join.c | 7 + sched/sched/sched_note.c | 151 +- sched/sched/sched_timerexpiration.c | 7 + sched/sched/sched_waitpid.c | 21 +- sched/signal/sig_action.c | 3 +- sched/signal/sig_dispatch.c | 14 +- sched/task/Make.defs | 2 +- sched/task/spawn.h | 1 + sched/task/task_create.c | 3 +- sched/task/{task_execv.c => task_execve.c} | 10 +- sched/task/task_exithook.c | 2 +- sched/task/task_init.c | 12 +- sched/task/task_posixspawn.c | 21 +- sched/task/task_spawn.c | 4 +- sched/task/task_start.c | 7 +- sched/task/task_vfork.c | 9 + sched/wqueue/kwork_thread.c | 61 +- sched/wqueue/wqueue.h | 2 - syscall/Makefile | 2 +- syscall/syscall.csv | 5 +- tools/README.txt | 8 +- tools/checkpatch.sh | 11 +- tools/checkrelease.sh | 4 - tools/ci/cibuild.sh | 8 +- tools/ci/testlist/arm-01.dat | 4 +- tools/ci/testlist/arm-02.dat | 5 +- tools/ci/testlist/arm-03.dat | 2 +- tools/ci/testlist/arm-04.dat | 12 +- tools/ci/testlist/arm-05.dat | 6 +- tools/ci/testlist/arm-06.dat | 8 +- tools/ci/testlist/arm-07.dat | 8 +- tools/ci/testlist/arm-08.dat | 10 +- tools/ci/testlist/arm-09.dat | 14 +- tools/ci/testlist/arm-10.dat | 16 +- tools/ci/testlist/arm-11.dat | 10 +- tools/ci/testlist/arm-12.dat | 4 +- tools/ci/testlist/arm-13.dat | 6 +- tools/ci/testlist/macos.dat | 6 +- tools/ci/testlist/risc-v.dat | 2 +- tools/configure.sh | 4 +- tools/incdir.c | 4 +- tools/jlink-nuttx.c | 155 +- tools/minidumpserver.py | 24 +- tools/mkdeps.c | 2 +- tools/mkromfsimg.sh | 67 +- tools/mksyscall.c | 2 +- tools/parsememdump.py | 17 +- tools/testbuild.sh | 14 +- wireless/ieee802154/mac802154_device.c | 10 +- 1860 files changed, 38495 insertions(+), 31730 deletions(-) delete mode 100644 DISCLAIMER-WIP delete mode 100644 arch/arm/include/armv7-m/irq_cmnvector.h delete mode 100644 arch/arm/include/armv7-m/irq_lazyfpu.h delete mode 100644 arch/arm/include/armv8-m/irq_cmnvector.h delete mode 100644 arch/arm/include/armv8-m/irq_lazyfpu.h create mode 100644 arch/arm/src/arm/Make.defs delete mode 100644 arch/arm/src/arm/arm_saveusercontext.S delete mode 100644 arch/arm/src/arm/vfork.S create mode 100644 arch/arm/src/armv6-m/Make.defs delete mode 100644 arch/arm/src/armv6-m/arm_fullcontextrestore.S delete mode 100644 arch/arm/src/armv6-m/arm_saveusercontext.S delete mode 100644 arch/arm/src/armv6-m/arm_signal_dispatch.c delete mode 100644 arch/arm/src/armv6-m/arm_signal_handler.S create mode 100644 arch/arm/src/armv7-a/Make.defs create mode 100644 arch/arm/src/armv7-a/arm_addrenv_perms.c delete mode 100644 arch/arm/src/armv7-a/arm_fetchadd.S rename drivers/power/greedy_governor.h => arch/arm/src/armv7-a/arm_fpucmp.c (72%) delete mode 100644 arch/arm/src/armv7-a/arm_restorefpu.S delete mode 100644 arch/arm/src/armv7-a/arm_saveusercontext.S delete mode 100644 arch/arm/src/armv7-a/arm_signal_dispatch.c delete mode 100644 arch/arm/src/armv7-a/vfork.S create mode 100644 arch/arm/src/armv7-m/Make.defs rename arch/arm/src/armv7-m/{gnu => }/arm_exception.S (96%) create mode 100644 arch/arm/src/armv7-m/arm_fpucmp.c create mode 100644 arch/arm/src/armv7-m/arm_fpuconfig.c delete mode 100644 arch/arm/src/armv7-m/gnu/arm_fetchadd.S delete mode 100644 arch/arm/src/armv7-m/gnu/arm_fpu.S delete mode 100644 arch/arm/src/armv7-m/gnu/arm_fullcontextrestore.S delete mode 100644 arch/arm/src/armv7-m/gnu/arm_lazyexception.S delete mode 100644 arch/arm/src/armv7-m/gnu/arm_saveusercontext.S delete mode 100644 arch/arm/src/armv7-m/gnu/arm_signal_handler.S delete mode 100644 arch/arm/src/armv7-m/iar/arm_saveusercontext.S create mode 100644 arch/arm/src/armv7-r/Make.defs delete mode 100644 arch/arm/src/armv7-r/arm_fetchadd.S create mode 100644 arch/arm/src/armv7-r/arm_fpucmp.c delete mode 100644 arch/arm/src/armv7-r/arm_restorefpu.S delete mode 100644 arch/arm/src/armv7-r/arm_savefpu.S delete mode 100644 arch/arm/src/armv7-r/arm_saveusercontext.S delete mode 100644 arch/arm/src/armv7-r/arm_signal_dispatch.c delete mode 100644 arch/arm/src/armv7-r/arm_signal_handler.S delete mode 100644 arch/arm/src/armv7-r/vfork.S create mode 100644 arch/arm/src/armv8-m/Make.defs delete mode 100644 arch/arm/src/armv8-m/arm_fpu.S create mode 100644 arch/arm/src/armv8-m/arm_fpucmp.c create mode 100644 arch/arm/src/armv8-m/arm_fpuconfig.c delete mode 100644 arch/arm/src/armv8-m/arm_fullcontextrestore.S delete mode 100644 arch/arm/src/armv8-m/arm_lazyexception.S delete mode 100644 arch/arm/src/armv8-m/arm_saveusercontext.S delete mode 100644 arch/arm/src/armv8-m/arm_signal_dispatch.c delete mode 100644 arch/arm/src/armv8-m/vfork.S create mode 100644 arch/arm/src/common/Make.defs rename arch/{xtensa/src/common/xtensa_switchcontext.c => arm/src/common/arm_fullcontextrestore.c} (81%) rename arch/{xtensa/src/common/xtensa_copystate.c => arm/src/common/arm_saveusercontext.c} (71%) rename arch/arm/src/{armv7-m => common}/arm_signal_dispatch.c (94%) rename arch/arm/src/{armv8-m => common/gnu}/arm_fetchadd.S (99%) rename arch/arm/src/{armv8-m => common/gnu}/arm_signal_handler.S (98%) rename arch/arm/src/{armv8-m => common/gnu}/arm_testset.S (98%) rename arch/arm/src/{armv6-m => common/gnu}/vfork.S (90%) rename arch/arm/src/{armv7-m => common}/iar/arm_fetchadd.S (99%) rename arch/arm/src/{armv7-m => common}/iar/arm_testset.S (98%) rename arch/arm/src/{armv7-m => common}/iar/vfork.S (99%) delete mode 100644 arch/arm/src/stm32l4/stm32l4_fsmc.h delete mode 100644 arch/arm/src/stm32l4/stm32l4_lcd.h delete mode 100644 arch/or1k/src/mor1kx/hardware/irq.h create mode 100644 arch/risc-v/include/mode.h delete mode 100644 arch/risc-v/src/common/Kconfig create mode 100644 arch/risc-v/src/common/crt0.c rename arch/{arm/src/armv7-a/arm_savefpu.S => risc-v/src/common/pgalloc.h} (55%) create mode 100644 arch/risc-v/src/common/riscv_addrenv.c create mode 100644 arch/risc-v/src/common/riscv_addrenv_perms.c delete mode 100644 arch/risc-v/src/common/riscv_fault.c create mode 100644 arch/risc-v/src/common/riscv_fpucmp.c create mode 100644 arch/risc-v/src/common/riscv_hostfs.c create mode 100644 arch/risc-v/src/common/riscv_macros.S create mode 100644 arch/risc-v/src/common/riscv_mhartid.S create mode 100644 arch/risc-v/src/common/riscv_misaligned.c create mode 100644 arch/risc-v/src/common/riscv_mtimer.c create mode 100644 arch/risc-v/src/common/riscv_mtimer.h create mode 100644 arch/risc-v/src/common/riscv_percpu.c rename arch/{arm/src/armv7-r/arm_testset.S => risc-v/src/common/riscv_percpu.h} (54%) create mode 100644 arch/risc-v/src/common/riscv_pgalloc.c create mode 100644 arch/risc-v/src/common/riscv_saveusercontext.c create mode 100644 arch/risc-v/src/common/riscv_semihost.S create mode 100644 arch/risc-v/src/common/supervisor/Make.defs create mode 100644 arch/risc-v/src/common/supervisor/riscv_perform_syscall.c create mode 100644 arch/risc-v/src/common/supervisor/riscv_sbi.c create mode 100644 arch/risc-v/src/common/supervisor/riscv_syscall.S rename arch/{arm/src/armv7-m/gnu => risc-v/src/common}/vfork.S (76%) delete mode 100644 arch/risc-v/src/esp32c3/esp32c3_interrupt.S create mode 100644 arch/risc-v/src/esp32c3/esp32c3_twai.c rename arch/{arm/src/armv7-m/iar/arm_fullcontextrestore.S => risc-v/src/esp32c3/esp32c3_twai.h} (72%) create mode 100644 arch/risc-v/src/esp32c3/hardware/esp32c3_twai.h create mode 100644 arch/risc-v/src/litex/hardware/litex_sdio.h create mode 100644 arch/risc-v/src/litex/litex_cache.S create mode 100644 arch/risc-v/src/litex/litex_sdio.c create mode 100644 arch/risc-v/src/litex/litex_sdio.h create mode 100644 arch/risc-v/src/mpfs/mpfs_mm_init.c create mode 100644 arch/risc-v/src/mpfs/mpfs_mm_init.h rename arch/{arm/src/armv7-r/arm_fullcontextrestore.S => risc-v/src/mpfs/mpfs_pgalloc.c} (71%) rename arch/{arm/src/armv7-a/arm_testset.S => sim/src/sim/up_keyboard.c} (58%) rename arch/{arm/src/arm/arm_fullcontextrestore.S => xtensa/src/common/xtensa_macros.S} (53%) create mode 100644 arch/xtensa/src/common/xtensa_saveusercontext.c delete mode 100644 arch/xtensa/src/common/xtensa_swi.h create mode 100644 arch/xtensa/src/common/xtensa_tcbinfo.c create mode 100644 arch/xtensa/src/esp32/esp32_twai.c rename arch/{arm/src/armv7-a/fpu.h => xtensa/src/esp32/esp32_twai.h} (77%) create mode 100644 arch/xtensa/src/esp32/hardware/esp32_twai.h create mode 100644 arch/xtensa/src/esp32s2/esp32s2_psram.c create mode 100644 arch/xtensa/src/esp32s2/esp32s2_psram.h create mode 100644 arch/xtensa/src/esp32s2/esp32s2_spiram.c create mode 100644 arch/xtensa/src/esp32s2/esp32s2_spiram.h create mode 100644 arch/xtensa/src/esp32s2/hardware/esp32s2_spi_mem_reg.h create mode 100644 arch/xtensa/src/esp32s2/rom/esp32s2_opi_flash.h create mode 100644 arch/xtensa/src/esp32s2/rom/esp32s2_spiflash.h create mode 100644 boards/arm/cxd56xx/common/src/cxd56_scd41_i2c.c create mode 100644 boards/arm/cxd56xx/spresense/include/board_lcdpins.h rename arch/arm/src/armv7-r/fpu.h => boards/arm/cxd56xx/spresense/include/cxd56_scd41.h (78%) delete mode 100644 boards/arm/cxd56xx/spresense/scripts/gnu-elf.ld delete mode 100644 boards/arm/cxd56xx/spresense/src/cxd56_ostest.c create mode 100644 boards/arm/imx6/sabre-6quad/configs/libcxx/defconfig delete mode 100644 boards/arm/imx6/sabre-6quad/scripts/gnu-elf.ld delete mode 100644 boards/arm/lc823450/lc823450-xgevk/scripts/gnu-elf.ld delete mode 100644 boards/arm/lpc17xx_40xx/lx_cpu/scripts/gnu-elf.ld delete mode 100644 boards/arm/lpc43xx/bambino-200e/src/lpc43_ostest.c delete mode 100644 boards/arm/lpc43xx/lpc4330-xplorer/src/lpc43_ostest.c delete mode 100644 boards/arm/lpc43xx/lpc4357-evb/src/lpc43_ostest.c delete mode 100644 boards/arm/lpc43xx/lpc4370-link2/src/lpc43_ostest.c delete mode 100644 boards/arm/phy62xx/phy6222/scripts/gnu-elf.ld delete mode 100644 boards/arm/sama5/giant-board/scripts/gnu-elf.ld delete mode 100644 boards/arm/sama5/giant-board/src/sam_ostest.c delete mode 100644 boards/arm/sama5/sama5d2-xult/scripts/gnu-elf.ld delete mode 100644 boards/arm/sama5/sama5d2-xult/src/sam_ostest.c delete mode 100644 boards/arm/sama5/sama5d3-xplained/scripts/gnu-elf.ld delete mode 100644 boards/arm/sama5/sama5d3-xplained/src/sam_ostest.c delete mode 100644 boards/arm/sama5/sama5d3x-ek/scripts/gnu-elf.ld delete mode 100644 boards/arm/sama5/sama5d3x-ek/src/sam_ostest.c create mode 100644 boards/arm/sama5/sama5d4-ek/include/rc.sysinit.template delete mode 100644 boards/arm/sama5/sama5d4-ek/scripts/gnu-elf.ld delete mode 100644 boards/arm/sama5/sama5d4-ek/src/sam_ostest.c delete mode 100644 boards/arm/samv7/common/scripts/gnu-elf.ld delete mode 100644 boards/arm/stm32/axoloti/scripts/gnu-elf.ld delete mode 100644 boards/arm/stm32/clicker2-stm32/scripts/gnu-elf.ld delete mode 100644 boards/arm/stm32/mikroe-stm32f4/scripts/gnu-elf.ld delete mode 100644 boards/arm/stm32/nucleo-f429zi/scripts/gnu-elf.ld delete mode 100644 boards/arm/stm32/omnibusf4/scripts/gnu-elf.ld delete mode 100644 boards/arm/stm32/omnibusf4/src/stm32_ostest.c delete mode 100644 boards/arm/stm32/stm3240g-eval/src/stm32_ostest.c delete mode 100644 boards/arm/stm32/stm32f3discovery/scripts/gnu-elf.ld delete mode 100644 boards/arm/stm32/stm32f429i-disco/scripts/gnu-elf.ld delete mode 100644 boards/arm/stm32/stm32f429i-disco/src/stm32_ostest.c delete mode 100644 boards/arm/stm32/stm32f4discovery/scripts/gnu-elf.ld delete mode 100644 boards/arm/stm32/stm32f4discovery/src/stm32_ostest.c delete mode 100644 boards/arm/stm32/stm32ldiscovery/scripts/gnu-elf.ld delete mode 100644 boards/arm/stm32f0l0g0/stm32f051-discovery/scripts/gnu-elf.ld delete mode 100644 boards/arm/stm32f0l0g0/stm32f072-discovery/scripts/gnu-elf.ld delete mode 100644 boards/arm/stm32f7/stm32f746g-disco/src/stm32_ostest.c delete mode 100644 boards/arm/stm32f7/stm32f769i-disco/src/stm32_ostest.c delete mode 100644 boards/arm/stm32h7/nucleo-h743zi/scripts/gnu-elf.ld delete mode 100644 boards/arm/stm32h7/nucleo-h743zi2/scripts/gnu-elf.ld delete mode 100644 boards/arm/stm32h7/nucleo-h743zi2/src/stm32_ostest.c create mode 100644 boards/arm/stm32l4/stm32l476vg-disco/include/rc.sysinit.template create mode 100644 boards/arm/stm32l4/stm32l4r9ai-disco/include/rc.sysinit.template create mode 100644 boards/arm/stm32u5/b-u585i-iot02a/scripts/flash.ld delete mode 100644 boards/arm/tiva/lm3s6965-ek/scripts/gnu-elf.ld delete mode 100644 boards/arm/xmc4/xmc4500-relax/src/xmc4_ostest.c delete mode 100644 boards/arm/xmc4/xmc4700-relax/src/xmc4_ostest.c delete mode 100644 boards/avr/atmega/amber/scripts/gnu-elf.ld delete mode 100644 boards/risc-v/bl602/bl602evb/scripts/gnu-elf.ld delete mode 100644 boards/risc-v/bl602/bl602evb/src/bl602_ostest.c delete mode 100644 boards/risc-v/c906/smartl-c906/scripts/gnu-elf.ld delete mode 100644 boards/risc-v/c906/smartl-c906/src/c906_ostest.c create mode 100644 boards/risc-v/esp32c3/esp32c3-devkit/configs/cxx/defconfig create mode 100644 boards/risc-v/esp32c3/esp32c3-devkit/configs/twai/defconfig create mode 100644 boards/risc-v/esp32c3/esp32c3-devkit/src/esp32c3_twai.c create mode 100644 boards/risc-v/esp32c3/esp32c3-devkit/src/etc/init.d/rc.sysinit delete mode 100644 boards/risc-v/k210/maix-bit/scripts/gnu-elf.ld create mode 100644 boards/risc-v/litex/arty_a7/src/litex_automount.c rename arch/arm/src/armv7-m/gnu/arm_testset.S => boards/risc-v/litex/arty_a7/src/litex_sdio.c (54%) delete mode 100755 boards/risc-v/mpfs/common/src/mpfs_ostest.c create mode 100644 boards/risc-v/mpfs/icicle/configs/pnsh/defconfig create mode 100644 boards/risc-v/mpfs/icicle/include/.gitignore create mode 100644 boards/risc-v/mpfs/icicle/include/boot_romfsimg.h delete mode 100755 boards/risc-v/mpfs/icicle/scripts/gnu-elf.ld delete mode 100755 boards/risc-v/mpfs/m100pfsevp/scripts/gnu-elf.ld create mode 100644 boards/risc-v/qemu-rv/rv-virt/src/etc/init.d/rc.sysinit delete mode 100644 boards/risc-v/qemu-rv/rv-virt/src/qemu_rv_ostest.c delete mode 100644 boards/sim/sim/sim/scripts/gnu-elf.ld create mode 100644 boards/sim/sim/sim/src/etc/init.d/rc.sysinit delete mode 100644 boards/sparc/bm3803/xx3803/scripts/gnu-elf.ld create mode 100644 boards/xtensa/esp32/esp32-devkitc/configs/cxx/defconfig create mode 100644 boards/xtensa/esp32/esp32-devkitc/src/esp32_twai.c create mode 100644 boards/xtensa/esp32s2/esp32s2-saola-1/configs/cxx/defconfig create mode 100644 boards/xtensa/esp32s3/esp32s3-devkit/configs/cxx/defconfig delete mode 100644 drivers/power/activity_governor.h create mode 100644 drivers/power/pm_lock.c create mode 100644 drivers/rptun/rptun.h create mode 100644 drivers/rptun/rptun_dump.c create mode 100644 drivers/rptun/rptun_ping.c create mode 100644 drivers/sensors/scd41.c create mode 100644 include/nuttx/sensors/scd41.h create mode 100644 libs/libc/stream/lib_blkoutstream.c create mode 100644 libs/libc/time/lib_strptime.c create mode 100644 libs/libc/uio/lib_preadv.c rename arch/arm/src/armv7-a/arm_fullcontextrestore.S => libs/libc/uio/lib_pwritev.c (52%) create mode 100644 libs/libc/unistd/lib_execle.c create mode 100644 libs/libc/unistd/lib_execv.c create mode 100644 libs/libxx/0001-libcxx-Rename-PS-macro-to-avoid-clashing-with-Xtensa.patch create mode 100644 libs/libxx/0002-Omit-atomic_-un-signed_lock_free-if-unsupported.patch create mode 100644 net/icmp/icmp_ioctl.c create mode 100644 net/icmpv6/icmpv6_ioctl.c create mode 100644 openamp/0007-openamp-divide-shram-to-TX-shram-RX-shram.patch create mode 100644 openamp/0008-rpmsg_virtio-don-t-need-check-status-when-get_tx_pay.patch rename sched/task/{task_execv.c => task_execve.c} (93%) diff --git a/.github/gcc.json b/.github/gcc.json index c13c7b40d28f8..da3091e2090d3 100644 --- a/.github/gcc.json +++ b/.github/gcc.json @@ -21,7 +21,7 @@ "column": 3, "severity": 4, "message": 5 - } + } ] } ] diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index 4e4d9b2263787..2fb5a7700876d 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -39,5 +39,5 @@ jobs: cd nuttx commits="${{ github.event.pull_request.base.sha }}..HEAD" git log --oneline $commits - echo "../nuttx/tools/checkpatch.sh -g $commits" - ../nuttx/tools/checkpatch.sh -g $commits + echo "../nuttx/tools/checkpatch.sh -m -g $commits" + ../nuttx/tools/checkpatch.sh -m -g $commits diff --git a/DISCLAIMER-WIP b/DISCLAIMER-WIP deleted file mode 100644 index e4eb139f09c20..0000000000000 --- a/DISCLAIMER-WIP +++ /dev/null @@ -1,20 +0,0 @@ -Apache NuttX is an effort undergoing incubation at The Apache Software Foundation (ASF), -sponsored by the Apache Incubator. Incubation is required of all newly accepted projects -until a further review indicates that the infrastructure, communications, and decision -making process have stabilized in a manner consistent with other successful ASF projects. -While incubation status is not necessarily a reflection of the completeness or stability -of the code, it does indicate that the project has yet to be fully endorsed by the ASF. - -Some of the incubating project's releases may not be fully compliant with ASF policy. For -example, releases may have incomplete or un-reviewed licensing conditions. What follows is -a list of known issues the project is currently aware of (note that this list, by definition, -is likely to be incomplete): - - * Releases may have incomplete licensing conditions. - * Some ASF files still have BSD headers. Most of the top contributors have signed an ICLA and - we are working on updating the headers and getting approvals from other copyright holders. - -If you are planning to incorporate this work into your product/project, please be aware that -you will need to conduct a thorough licensing review to determine the overall implications of -including this work. For the current status of this project through the Apache Incubator -visit: https://incubator.apache.org/projects/nuttx.html diff --git a/Documentation/applications/nsh/config.rst b/Documentation/applications/nsh/config.rst index 9166f661c3006..8195ede4bf747 100644 --- a/Documentation/applications/nsh/config.rst +++ b/Documentation/applications/nsh/config.rst @@ -298,9 +298,10 @@ Configuration Description registered as ``/dev/mmcsd``\ *N* where *N* is the minor number. Default is zero. - ``CONFIG_NSH_ROMFSETC`` Mount a ROMFS file system at ``/etc`` and provide a startup - script at ``/etc/init.d/rcS``. - The default startup script will mount a FAT FS RAMDISK at + ``CONFIG_NSH_ROMFSETC`` Mount a ROMFS file system at ``/etc`` and provide a system init + script at ``/etc/init.d.rc.sysinit`` and a startup script at + ``/etc/init.d/rcS``. + The default system init script will mount a FAT FS RAMDISK at ``/tmp`` but the logic is `easily extensible <#startupscript>`__. ``CONFIG_NSH_CONSOLE`` If ``CONFIG_NSH_CONSOLE`` is set to *y*, then a serial console @@ -462,6 +463,9 @@ Configuration Description ``CONFIG_NSH_ROMFSMOUNTPT`` The default mountpoint for the ROMFS volume is ``"/etc"``, but that can be changed with this setting. This must be a absolute path beginning with '``/``' and enclosed in quotes. +``CONFIG_NSH_SYSINITSCRIPT`` This is the relative path to the system init script within the + mountpoint. The default is ``"init.d/rc.sysinit"``. This is a relative + path and must not start with '``/``' but must be enclosed in quotes. ``CONFIG_NSH_INITSCRIPT`` This is the relative path to the startup script within the mountpoint. The default is ``"init.d/rcS"``. This is a relative path and must not start with '``/``' but must be enclosed in quotes. @@ -473,7 +477,7 @@ Configuration Description Any value selected must be a power of 2. ============================== ============================================================== -When the default ``rcS`` file used when ``CONFIG_NSH_ROMFSETC`` is +When the default ``rc.sysinit`` file used when ``CONFIG_NSH_ROMFSETC`` is selected, it will mount a FAT FS under ``/tmp``. The following selections describe that FAT FS. diff --git a/Documentation/applications/nsh/customizing.rst b/Documentation/applications/nsh/customizing.rst index 38b28a08560a2..384b66a15e55c 100644 --- a/Documentation/applications/nsh/customizing.rst +++ b/Documentation/applications/nsh/customizing.rst @@ -46,18 +46,18 @@ does the following: ~~~~~~~~~~~~~~~~~~~~ The NSH initialization function, ``nsh_initialize()``, be found in -``apps/nshlib/nsh_init.c``. It does only three things: +``apps/nshlib/nsh_init.c``. It does only four things: - #. ``nsh_romfsetc()``: If so configured, it executes an NSH start-up - script that can be found at ``/etc/init.d/rcS`` in the target file - system. The ``nsh_romfsetc()`` function can be found in - ``apps/nshlib/nsh_romfsetc.c``. This function will (1) register a - ROMFS file system, then (2) mount the ROMFS file system. ``/etc`` is - the default location where a read-only, ROMFS file system is mounted - by ``nsh_romfsetc()``. + #. ``nsh_romfsetc()``: If so configured, it executes NSH system init and + start-up script that can be found at ``/etc/init.d/rc.sysinit`` and + ``/etc/init.d/rcS`` in the target file system. The ``nsh_romfsetc()`` + function can be found in ``apps/nshlib/nsh_romfsetc.c``. + This function will (1) register a ROMFS file system, then (2) mount + the ROMFS file system. ``/etc`` is the default location where a + read-only, ROMFS file system is mounted by ``nsh_romfsetc()``. The ROMFS image is, itself, just built into the firmware. By default, - this ``rcS`` start-up script contains the following logic:: + this ``rc.sysinit`` system init script contains the following logic:: # Create a RAMDISK and mount it at XXXRDMOUNTPOINTXXX @@ -79,7 +79,7 @@ The NSH initialization function, ``nsh_initialize()``, be found in - ``XXXRDMOUNTPOINTXXX`` will become the configured mount point. Default: ``/etc`` - By default, the substituted values would yield an ``rcS`` file like:: + By default, the substituted values would yield an ``rc.sysinit`` file like:: # Create a RAMDISK and mount it at /tmp @@ -96,8 +96,8 @@ The NSH initialization function, ``nsh_initialize()``, be found in - Mount the FAT file system at a configured mountpoint, ``/tmp``. - This ``rcS`` template file can be found at - ``apps/nshlib/rcS.template``. The resulting ROMFS file system can be + This ``rc.sysinit.template`` template file can be found at + ``apps/nshlib/rc.sysinit.template``. The resulting ROMFS file system can be found in ``apps/nshlib/nsh_romfsimg.h``. #. ``board_app_initialize()``: Next any architecture-specific NSH @@ -110,6 +110,13 @@ The NSH initialization function, ``nsh_initialize()``, be found in #. ``nsh_netinit()``: The ``nsh_netinit()`` function can be found in ``apps/nshlib/nsh_netinit.c``. + #. The start-up script ``rcS`` is executed after the system-init script + to startup some application and other system service. + + This ``rcS`` template file can be found at + ``apps/nshlib/rcS.template``. The resulting ROMFS file system can be + found in ``apps/nshlib/nsh_romfsimg.h``. + NSH Commands ************ diff --git a/Documentation/applications/nsh/installation.rst b/Documentation/applications/nsh/installation.rst index a6bd2e163ab0a..29e03a272e3dd 100644 --- a/Documentation/applications/nsh/installation.rst +++ b/Documentation/applications/nsh/installation.rst @@ -61,8 +61,10 @@ behave as follows at NSH start-up time: `--init.d/ `-- rcS + `-- rc.sysinit Where ``rcS`` is the NSH start-up script. + Where ``rc.sysinit`` is the NSH system-init script. - NSH will then mount the ROMFS file system at ``/etc``, resulting in:: @@ -71,8 +73,9 @@ behave as follows at NSH start-up time: `--etc/ `--init.d/ `-- rcS + `-- rc.sysinit - - By default, the contents of ``rcS`` script are:: + - By default, the contents of ``rc.sysinit`` script are:: # Create a RAMDISK and mount it at /tmp @@ -80,9 +83,9 @@ behave as follows at NSH start-up time: mkfatfs /dev/ram1 mount -t vfat /dev/ram1 /tmp - - NSH will execute the script at ``/etc/init.d/rcS`` at start-up - (before the first NSH prompt). After execution of the script, the - root FS will look like:: + - NSH will execute the script at ``/etc/init.d/rc.sysinit`` at system + init (before the first NSH prompt). After execution of the script, + the root FS will look like:: |--dev/ | |-- ram0 @@ -90,6 +93,7 @@ behave as follows at NSH start-up time: |--etc/ | `--init.d/ | `-- rcS + | `-- rc.sysinit `--tmp/ **Example Configurations**. Here are some configurations that have @@ -105,15 +109,16 @@ provide useful examples: - ``boards/sim/sim/sim/touchscreen`` In most of these cases, the configuration sets up the *default* -``/etc/init.d/rcS`` script. The default script is here: -``apps/nshlib/rcS.template``. (The funny values in the template like -``XXXMKRDMINORXXX`` get replaced via ``sed`` at build time). This +``/etc/init.d/rc.sysinit`` and ``/etc/init.d/rcS`` script. The default +script is here: ``apps/nshlib/rc.sysinit.template`` and +``apps/nshlib/rcS.template``. (The funny values in the rc.sysinit.template +like ``XXXMKRDMINORXXX`` get replaced via ``sed`` at build time). This default configuration creates a ramdisk and mounts it at ``/tmp`` as discussed above. If that default behavior is not what you want, then you can provide your -own custom ``rcS`` script by defining ``CONFIG_NSH_ARCHROMFS=y`` in the -configuration file. +own custom ``rc.sysinit`` and ``rcS`` script by defining +``CONFIG_NSH_ARCHROMFS=y`` in the configuration file. **Modifying the ROMFS Image**. The contents of the ``/etc`` directory are retained in the file ``apps/nshlib/nsh_romfsimg.h`` OR, if @@ -146,21 +151,34 @@ behavior, there are three things to study: is a normal part of a complete Linux or Cygwin installation, usually as part of the ``vi`` package). - #. The file ``apps/nshlib/rcS.template`` (OR, if + #. The file ``apps/nshlib/rc.sysinit.template`` (OR, if + ``CONFIG_NSH_ARCHROMFS`` is defined + ``include/arch/board/rc.sysinit.template``. + + The file ``apps/nshlib/rcS.template`` (OR, if ``CONFIG_NSH_ARCHROMFS`` is defined ``include/arch/board/rcs.template``. - #. ``rcS.template``. The file ``apps/nshlib/rcS.template`` contains the + #. ``rc.sysinit.template``. The file ``apps/nshlib/rc.sysinit.template`` + contains the general form of the ``rc.sysinit`` file; configured values + are plugged into this template file to produce the final ``rc.sysinit`` file. + + ``rcS.template``. The file ``apps/nshlib/rcS.template`` contains the general form of the ``rcS`` file; configured values are plugged into this template file to produce the final ``rcS`` file. - To generate a custom ``rcS`` file a copy of ``rcS.template`` needs to + To generate a custom ``rc.sysinit`` and ``rcS`` file a copy of + ``rc.sysinit.template`` and ``rcS.template`` needs to be placed at ``tools/`` and changed according to the desired start-up behaviour. Running ``tools/mkromfsimg.h`` creates ``nsh_romfsimg.h`` which needs to be copied to ``apps/nshlib`` OR if ``CONFIG_NSH_ARCHROMFS`` is defined to ``boards////include``. +``rc.sysinit.template``. The default ``rc.sysinit.template``, +``apps/nshlib/rc.sysinit.template``, generates the standard, default +``apps/nshlib/nsh_romfsimg.h`` file. + ``rcS.template``. The default ``rcS.template``, ``apps/nshlib/rcS.template``, generates the standard, default ``apps/nshlib/nsh_romfsimg.h`` file. @@ -171,10 +189,11 @@ then a custom, board-specific ``nsh_romfsimg.h`` file residing in is configured, ``include/arch/board`` will be linked to ``boards////include``. -All of the startup-behavior is contained in ``rcS.template``. The role -of ``mkromfsimg.sh`` script is to (1) apply the specific configuration -settings to ``rcS.template`` to create the final ``rcS``, and (2) to -generate the header file ``nsh_romfsimg.h`` containing the ROMFS file +All of the startup-behavior is contained in ``rc.sysinit.template`` and +``rcS.template``. The role of ``mkromfsimg.sh`` script is to (1) apply +the specific configuration settings to ``rc.sysinit.template`` to create +the final ``rc.sysinit``, and ``rcS.template`` to create the final ``rcS``, +and (2) to generate the header file ``nsh_romfsimg.h`` containing the ROMFS file system image. To do this, ``mkromfsimg.sh`` uses two tools that must be installed in your system: diff --git a/Documentation/applications/nsh/login.rst b/Documentation/applications/nsh/login.rst index 01d538630c14e..b8d1ea50aa25f 100644 --- a/Documentation/applications/nsh/login.rst +++ b/Documentation/applications/nsh/login.rst @@ -164,9 +164,11 @@ and containing the password file, ``passwd`` like:: /etc/init.d: dr-xr-xr-x 0 .. -r--r--r-- 110 rcS + -r--r--r-- 110 rc.sysinit nsh> -Where ``/etc/init.d/rcS`` is the start-up script; ``/etc/passwd`` is a +Where ``/etc/init.d/rc.sysinit`` is the system init script and +``/etc/init.d/rcS`` is the start-up script; ``/etc/passwd`` is a the password file. Note that here we assume that you are already using a start-up script. We can then piggyback the passwd file into the ``/etc`` file system already mounted for the NSH start up file as described above diff --git a/Documentation/applications/nsh/nsh.rst b/Documentation/applications/nsh/nsh.rst index 4cdde172a393d..ee2d71edb63e3 100644 --- a/Documentation/applications/nsh/nsh.rst +++ b/Documentation/applications/nsh/nsh.rst @@ -276,8 +276,10 @@ NSH to behave as follows at NSH startup time: `--init.d/ `-- rcS + `-- rc.sysinit Where rcS is the NSH start-up script. + Where rc.sysinit is the NSH system init script. - NSH will then mount the ROMFS file system at ``/etc``, resulting in:: @@ -287,8 +289,9 @@ NSH to behave as follows at NSH startup time: `--etc/ `--init.d/ `-- rcS + `-- rc.sysinit - - By default, the contents of rcS script are:: + - By default, the contents of rc.sysinit script are:: # Create a RAMDISK and mount it at XXXRDMOUNTPOINTXXX @@ -296,9 +299,9 @@ NSH to behave as follows at NSH startup time: mkfatfs /dev/ram1 mount -t vfat /dev/ram1 /tmp - - NSH will execute the script at ``/etc/init.d/rcS`` at start-up - (before the first NSH prompt). After execution of the script, - the root FS will look like:: + - NSH will execute the script at ``/etc/init.d/rc.sysinit`` at + system init script(before the first NSH prompt). After + execution of the script, the root FS will look like:: |--dev/ | |-- ram0 @@ -306,6 +309,7 @@ NSH to behave as follows at NSH startup time: |--etc/ | `--init.d/ | `-- rcS + | `-- rc.sysinit `--tmp/ **Modifying the ROMFS Image**. The contents of the ``/etc`` @@ -330,28 +334,37 @@ start-up behavior, there are three things to study: - The configuration settings then installed configuration. - The ``genromfs`` tool (available from http://romfs.sourceforge.net). - - The file ``apps/nshlib/rcS.template`` (OR, if + - The file ``apps/nshlib/rc.sysinit.template`` (OR, if + ``CONFIG_NSH_ARCHROMFS`` is defined + ``include/arch/board/rc.sysinit.template``. + The file ``apps/nshlib/rcS.template`` (OR, if ``CONFIG_NSH_ARCHROMFS`` is defined ``include/arch/board/rcs.template``. - #. ``rcS.template``: The file ``apps/nshlib/rcS.template`` + #. ``rc.sysinit.template``: The file ``apps/nshlib/rc.sysinit.template`` + contains the general form of the ``rc.sysinit`` file; configured + values are plugged into this template file to produce the final + ``rc.sysinit`` file. + + ``rcS.template``: The file ``apps/nshlib/rcS.template`` contains the general form of the ``rcS`` file; configured values are plugged into this template file to produce the final ``rcS`` file. .. note:: - ``apps/nshlib/rcS.template`` generates the standard, - default ``nsh_romfsimg.h`` file. If ``CONFIG_NSH_ARCHROMFS`` is - defined in the NuttX configuration file, then a custom, - board-specific ``nsh_romfsimg.h`` file residing in the - ``boards////include`` directory will be used. - NOTE when the OS is configured, ``include/arch/board`` will be + ``apps/nshlib/rcS.template`` and ``apps/nshlib/rc.sysinit.template`` + generates the standard, default ``nsh_romfsimg.h`` file. + If ``CONFIG_NSH_ARCHROMFS`` is defined in the NuttX configuration + file, then a custom, board-specific ``nsh_romfsimg.h`` file residing + in the ``boards////include`` directory will be + used. NOTE when the OS is configured, ``include/arch/board`` will be linked to ``boards////include``. -All of the startup-behavior is contained in ``rcS.template``. The -role of ``mkromfsimg.sh`` is to (1) apply the specific -configuration settings to ``rcS.template`` to create the final -``rcS``, and (2) to generate the header file ``nsh_romfsimg.h`` +All of the startup-behavior is contained in ``rc.sysinit.template`` +and ``rcS.template``. The role of ``mkromfsimg.sh`` is to (1) apply +the specific configuration settings to ``rc.sysinit.template`` to create +the final ``rc.sysinit``, and ``rc.sysinit.template`` to create the final +``rcS`` and (2) to generate the header file ``nsh_romfsimg.h`` containing the ROMFS file system image. **Further Information**. See the section on `Customizing the diff --git a/Documentation/guides/cpp_cmake.rst b/Documentation/guides/cpp_cmake.rst index f5167d3402aa3..0a6299a93543c 100644 --- a/Documentation/guides/cpp_cmake.rst +++ b/Documentation/guides/cpp_cmake.rst @@ -103,17 +103,15 @@ Creating the project ) set(EXE_NAME hellocpp) - + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${AC_HW_FLAGS} ${AC_DEFINES}") set(CMAKE_CXX_FLAGS "${AC_HW_FLAGS} ${AC_DEFINES} ${AC_COMMON_FLAGS} ${AC_CXX_EXTRA_FLAGS}") if (PARAM_DEBUG) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g") endif() - + set(CMAKE_SKIP_RPATH ON) set(CMAKE_CXX_LINK_EXECUTABLE "${CMAKE_LINKER} ${AC_LINKER_FLAGS} -o ${EXE_NAME}.elf ") - set(BUILD_SHARED_LIBS OFF) - add_subdirectory(src) * hellocpp/cmake/stm32f4discovery.cmake diff --git a/Documentation/guides/pysimcoder.rst b/Documentation/guides/pysimcoder.rst index 463c86f46af58..31fc3fe174ee9 100644 --- a/Documentation/guides/pysimcoder.rst +++ b/Documentation/guides/pysimcoder.rst @@ -41,7 +41,7 @@ in case this documentation was not updated when new fuctionalities were added to NuttX Configuration ------------------- -Several configuration options are neccessary to be set in order to succesfully compile pysimCoder +Several configuration options are necessary to be set in order to succesfully compile pysimCoder with NuttX. The list is the following: ==================================== ===================================== @@ -52,8 +52,8 @@ with NuttX. The list is the following: ``CONFIG_ELF=y`` ``CONFIG_PSEUDOTERM=y`` ``CONFIG_FS_BINFS=y`` ``CONFIG_PTHREAD_CLEANUP=y`` ``CONFIG_FS_PROCFS=y`` ``CONFIG_PTHREAD_MUTEX_TYPES=y`` -``CONFIG_FS_PROCFS_REGISTER=y`` ``CONFIG_PTHREAD_MUTEX_TYPES=y`` -``CONFIG_FS_ROMFS=y`` ``CONFIG_PTHREAD_STACK_MIN=1024`` +``CONFIG_FS_PROCFS_REGISTER=y`` ``CONFIG_PTHREAD_STACK_MIN=1024`` +``CONFIG_FS_ROMFS=y`` ``CONFIG_LIBM=y`` ``CONFIG_FS_TMPFS=y`` ``CONFIG_RR_INTERVAL=10`` ``CONFIG_IDLETHREAD_STACKSIZE=2048`` ``CONFIG_SCHED_WAITPID=y`` ``CONFIG_LIBC_EXECFUNCS=y`` ``CONFIG_SERIAL_TERMIOS=y`` @@ -63,6 +63,12 @@ with NuttX. The list is the following: ``CONFIG_NSH_FILEIOSIZE=512`` ``CONFIG_INIT_ENTRYPOINT="nsh_main"`` ==================================== ===================================== + +Note that ``CONFIG_LIBM=y`` might not be required for toolchains that already include +standard math library. However it is recommended to add ``CONFIG_LIBM=y`` to ensure +math library is included. Subsequently ``CONFIG_LIBC_FLOATINGPOINT=y`` is needed if double values +are to be printed on terminal. + In case you want to use Network and blocks like TCP or UDP, following configuration options are required: diff --git a/Documentation/platforms/risc-v/esp32c3/index.rst b/Documentation/platforms/risc-v/esp32c3/index.rst index d65e1382a324d..505be0b3a37b8 100644 --- a/Documentation/platforms/risc-v/esp32c3/index.rst +++ b/Documentation/platforms/risc-v/esp32c3/index.rst @@ -27,7 +27,7 @@ ESP32-C3 Toolchain ================== A generic RISC-V toolchain can be used to build ESP32-C3 projects. -SiFive's toolchain can be downloaded from: https://static.dev.sifive.com/dev-tools/riscv64-unknown-elf-gcc-8.3.0-2019.08.0-x86_64-linux-ubuntu14.tar.gz +SiFive's toolchain can be downloaded from: https://github.com/sifive/freedom-tools/releases Second stage bootloader and partition table =========================================== diff --git a/Documentation/reference/user/04_message_queue.rst b/Documentation/reference/user/04_message_queue.rst index d5d6b8ebe085d..7893258a776fe 100644 --- a/Documentation/reference/user/04_message_queue.rst +++ b/Documentation/reference/user/04_message_queue.rst @@ -167,7 +167,7 @@ handlers may send messages via named message queues. priority messages The value of ``prio`` must not exceed ``MQ_PRIO_MAX``. If the specified message queue is full and ``O_NONBLOCK`` is not set in - the message queue, then ``mq_send()`` will block until space becomes + the message queue, then ``mq_timedsend()`` will block until space becomes available to the queue the message or until a timeout occurs. ``mq_timedsend()`` behaves just like ``mq_send()``, except that if the @@ -188,7 +188,7 @@ handlers may send messages via named message queues. error, -1 (``ERROR``) is returned, with ```errno`` <#ErrnoAccess>`__ set to indicate the error: - - ``EAGAIN``. The queue was empty, and the ``O_NONBLOCK`` flag was set + - ``EAGAIN``. The queue was full, and the ``O_NONBLOCK`` flag was set for the message queue description referred to by ``mqdes``. - ``EINVAL``. Either ``msg`` or ``mqdes`` is ``NULL`` or the value of ``prio`` is invalid. diff --git a/Documentation/reference/user/10_filesystem.rst b/Documentation/reference/user/10_filesystem.rst index 4d162ae3e0ad7..ce2a0c60441b9 100644 --- a/Documentation/reference/user/10_filesystem.rst +++ b/Documentation/reference/user/10_filesystem.rst @@ -396,8 +396,8 @@ Standard String Operations #include #define bcmp(b1,b2,len) memcmp(b1,b2,(size_t)len) - #define bcopy(b1,b2,len) (void)memmove(b2,b1,len) - #define bzero(s,n) (void)memset(s,0,n) + #define bcopy(b1,b2,len) memmove(b2,b1,len) + #define bzero(s,n) memset(s,0,n) #define index(s,c) strchr(s,c) #define rindex(s,c) strrchr(s,c) diff --git a/Kconfig b/Kconfig index 87fefc98b1f74..836285687fad4 100644 --- a/Kconfig +++ b/Kconfig @@ -1956,6 +1956,28 @@ config DEBUG_OPTLEVEL This string represents the custom optimization level that will be used if DEBUG_CUSTOMOPT. +config DEBUG_OPT_UNUSED_SECTIONS + bool "Optimization to eliminate the unused input sections" + default y + depends on ARCH_TOOLCHAIN_GNU + ---help--- + Use these options on systems where the linker can perform optimizations + to improve locality of reference in the instruction space. Most systems + using the ELF object format have linkers with such optimizations. + + Enable this option to optimization the unused input sections with the + linker by compiling with " -ffunction-sections -fdata-sections ", and + linking with " --gc-sections ". + +config DEBUG_LINK_MAP + bool "Generate link map file" + default y + ---help--- + Selecting this option will pass "-Map=$(TOPDIR)$(DELIM)nuttx.map" to ld + when linking NuttX ELF. That file can be useful for verifying + and debugging magic section games, and for seeing which + pieces of code get eliminated with DEBUG_OPT_UNUSED_SECTIONS. + endmenu # Build Setup menu "System Type" diff --git a/LICENSE b/LICENSE index f6992d85847f3..680e68e4e1035 100644 --- a/LICENSE +++ b/LICENSE @@ -203,7 +203,46 @@ ------------------------------------------------------------------------------ uIP -=== +include/nuttx/net/arp.h +include/nuttx/net/can.h +include/nuttx/net/dns.h +include/nuttx/net/ethernet.h +include/nuttx/net/icmp.h +include/nuttx/net/icmpv6.h +include/nuttx/net/igmp.h +include/nuttx/net/ip.h +include/nuttx/net/netconfig.h +include/nuttx/net/netdev.h +include/nuttx/net/netstats.h +include/nuttx/net/tcp.h +include/nuttx/net/tun.h +include/nuttx/net/udp.h +net/arp/arp_arpin.c +net/arp/arp_dump.c +net/arp/arp_format.c +net/arp/arp_ipin.c +net/arp/arp_out.c +net/arp/arp_table.c +net/devif/devif.h +net/devif/devif_initialize.c +net/devif/devif_send.c +net/devif/ipv4_input.c +net/icmp/icmp_input.c +net/tcp/tcp_appsend.c +net/tcp/tcp_conn.c +net/tcp/tcp_devpoll.c +net/tcp/tcp_input.c +net/tcp/tcp_listen.c +net/tcp/tcp_send.c +net/tcp/tcp_seqno.c +net/tcp/tcp_timer.c +net/udp/udp_conn.c +net/udp/udp_devpoll.c +net/udp/udp_input.c +net/udp/udp_send.c +libs/libc/netdb/lib_dns.h +libs/libc/netdb/lib_dnsquery.c +==================== Many lower-level networking components of NuttX derive from uIP: @@ -292,6 +331,7 @@ Certain functions in the NuttX C-library derive from other BSD-compatible sources: fs/nfs +include/nuttx/fs/nfs.h ====== NFS: @@ -382,6 +422,349 @@ libc/string/lib_vikmemcpy.c 3. This notice may not be removed or altered from any source distribution. +libs/libc/machine/arm/armv7-a/arch_memcpy.S +libs/libc/machine/arm/armv7-r/arch_memcpy.S +libs/libc/machine/arm/armv7-m/gnu/arch_memcpy.S +================================================ + + Copyright (C) 2017 Gregory Nutt. All rights reserved. + + Based on the ARMv7-M version contributed by Mike Smith. Apparently in the public + domain and is re-released here under the modified BSD license: + + Obtained via a posting on the Stellaris forum: + http://e2e.ti.com/support/microcontrollers/\ + stellaris_arm_cortex-m3_microcontroller/f/473/t/44360.aspx + + Posted by rocksoft on Jul 24, 2008 10:19 AM + + Hi, + + I recently finished a "memcpy" replacement and thought it might be useful for + others... + + I've put some instructions and the code here: + + http://www.rock-software.net/downloads/memcpy/ + + Hope it works for you as well as it did for me. + + Liam. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + 3. Neither the name NuttX nor the names of its contributors may be + used to endorse or promote products derived from this software + without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + +libs/libc/misc/lib_crc32.c +========================= + + Copyright (C) 2010-2011 Gregory Nutt. All rights reserved. + + The logic in this file was developed by Gary S. Brown: + + COPYRIGHT (C) 1986 Gary S. Brown. You may use this program, or code or tables + extracted from it, as desired without restriction. + + First, the polynomial itself and its table of feedback terms. The polynomial is: + + X^32+X^26+X^23+X^22+X^16+X^12+X^11+X^10+X^8+X^7+X^5+X^4+X^2+X^1+X^0 + + Note that we take it "backwards" and put the highest-order term in the lowest-order bit. + The X^32 term is "implied"; the LSB is the X^31 term, etc. The X^0 term (usually shown + as "+1") results in the MSB being 1 + + Note that the usual hardware shift register implementation, which is what we're using + (we're merely optimizing it by doing eight-bit chunks at a time) shifts bits into the + lowest-order term. In our implementation, that means shifting towards the right. Why + do we do it this way? Because the calculated CRC must be transmitted in order from + highest-order term to lowest-order term. UARTs transmit characters in order from LSB + to MSB. By storing the CRC this way we hand it to the UART in the order low-byte to + high-byte; the UART sends each low-bit to hight-bit; and the result is transmission bit + by bit from highest- to lowest-order term without requiring any bit shuffling on our + part. Reception works similarly + + The feedback terms table consists of 256, 32-bit entries. Notes + + - The table can be generated at runtime if desired; code to do so is shown later. It + might not be obvious, but the feedback terms simply represent the results of eight + shift/xor operations for all combinations of data and CRC register values + + - The values must be right-shifted by eight bits by the updcrc logic; the shift must + be u_(bring in zeroes). On some hardware you could probably optimize the shift in + assembler by using byte-swap instructions polynomial $edb88320 + +libs/libc/misc/lib_fnmatch.c +=============================== + + Copyright 1995, 2000 by Jef Poskanzer . + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + SUCH DAMAGE. + +libs/libc/misc/lib_ncompress.c +============================== + + Copyright (C) 2008 Gregory Nutt. All rights reserved. + + This is the file compress24.c extracted from the ncompress-4.2.4 release + and adapted for NuttX. The original code was released into the public + domain. This NuttX version is re-released under the standard NuttX + BSD 3-clause license. The original authors are listed below: + + Spencer W. Thomas (decvax!harpo!utah-cs!utah-gr!thomas) + Jim McKie (decvax!mcvax!jim) + Steve Davies (decvax!vax135!petsd!peora!srd) + Ken Turkowski (decvax!decwrl!turtlevax!ken) + James A. Woods (decvax!ihnp4!ames!jaw) + Joe Orost (decvax!vax135!petsd!joe) + Dave Mack (csu@alembic.acs.com) + Peter Jannesen, Network Communication Systems + (peter@ncs.nl) + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + 3. Neither the name NuttX nor the names of its contributors may be + used to endorse or promote products derived from this software + without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + +libs/libc/misc/lib_utsname.c +============================= + + Copyright (C) 2015 Stavros Polymenis. All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + 3. Neither the name NuttX nor the names of its contributors may be + used to endorse or promote products derived from this software + without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + +libs/libc/net/lib_addrconfig.c +=============================== + + Copyright (c) 2015, Max Nekludov. All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + 3. Neither the name of the Institute nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND + ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE + FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + SUCH DAMAGE. + +libs/libc/stdlib/lib_strtod.c +libs/libc/stdlib/lib_strtof.c +libs/libc/stdlib/lib_strtold.c +============================= + + Copyright (C) 2002 Michael Ringgaard. All rights reserved. + Copyright (C) 2006-2007 H. Peter Anvin. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + 3. Neither the name of the project nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + OF THE POSSIBILITY OF SUCH DAMAGE. + +libs/libc/stdlib/lib_wctomb.c +============================= + + This code is derived from software contributed to Berkeley by + Chris Torek. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + 3. Neither the name of the University nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + SUCH DAMAGE. + +libs/libc/string/lib_vikmemcpy.c +================================== + + Copyright (C) 1999-2010 Daniel Vik + + Adaptations include: + - File name change + - Use of types defined in stdint.h + - Integration with the NuttX configuration system + - Other cosmetic changes for consistency with NuttX coding standards + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any + damages arising from the use of this software. + Permission is granted to anyone to use this software for any + purpose, including commercial applications, and to alter it and + redistribute it freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you + must not claim that you wrote the original software. If you + use this software in a product, an acknowledgment in the + use this software in a product, an acknowledgment in the + product documentation would be appreciated but is not + required. + + 2. Altered source versions must be plainly marked as such, and + must not be misrepresented as being the original software. + + 3. This notice may not be removed or altered from any source + distribution. + + Description: Implementation of the standard library function memcpy. + This implementation of memcpy() is ANSI-C89 compatible. + + The following configuration options can be set: + + CONFIG_ENDIAN_BIG + Uses processor with big endian addressing. Default is little endian. + + CONFIG_MEMCPY_PRE_INC_PTRS + Use pre increment of pointers. Default is post increment of pointers. + + CONFIG_MEMCPY_INDEXED_COPY + Copying data using array indexing. Using this option, disables the + CONFIG_MEMCPY_PRE_INC_PTRS option. + + CONFIG_MEMCPY_64BIT - Compiles memcpy for 64 bit architectures + libs/libc/math ============== @@ -587,9 +970,10 @@ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. include/nuttx/power/relay.h +arch/arm/src/tiva/hardware/tiva_epi.h ============================ - Copyright (C) 2015 Max Nekludov. All rights reserved. + Copyright (C) 2013, 2015 Max Nekludov. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions @@ -853,8 +1237,10 @@ arch/arm/src/armv6-m/arm_exception.S arch/arm/src/armv7-a/cp15_cacheops.h arch/arm/src/armv7-a/cp15_clean_dcache.S +arch/arm/src/armv7-a/cp15_clean_dcache_all.S arch/arm/src/armv7-a/cp15_coherent_dcache.S arch/arm/src/armv7-a/cp15_flush_dcache.S +arch/arm/src/armv7-a/cp15_flush_dcache_all.S arch/arm/src/armv7-a/cp15_invalidate_dcache.S arch/arm/src/armv7-a/cp15_invalidate_dcache_all.S ================================================= @@ -1232,8 +1618,10 @@ arch/arm/src/armv7-r/cp15_cacheops.h arch/arm/src/armv7-r/cp15_cacheops.h arch/arm/src/armv7-r/cp15_clean_dcache.S +arch/arm/src/armv7-r/cp15_clean_dcache_all.S arch/arm/src/armv7-r/cp15_coherent_dcache.S arch/arm/src/armv7-r/cp15_flush_dcache.S +arch/arm/src/armv7-r/cp15_flush_dcache_all.S arch/arm/src/armv7-r/cp15_invalidate_dcache.S arch/arm/src/armv7-r/cp15_invalidate_dcache_all.S ================================================= @@ -1375,6 +1763,45 @@ arch/arm/src/samv7/sam_twihs.c ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +arch/arm/src/samd2l2/sam_i2c_master.c +arch/arm/src/samd5e5/sam_i2c_master.c +======================================= + Copyright (C) 2013-2014, 2017 Gregory Nutt. All rights reserved. + Copyright (C) 2015 Filament - www.filament.com + + The Atmel sample code has a BSD compatible license that requires this + copyright notice: + + Copyright (c) 2011, Atmel Corporation + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + 3. Neither the name NuttX, Atmel, nor the names of its contributors may + be used to endorse or promote products derived from this software + without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + arch/arm/src/samv7/sam_usbdevhs.c ================================= @@ -1970,6 +2397,66 @@ drivers/wireless/ieee80211/bcm43xxx/bcmf_ioctl.h OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +drivers/wireless/ieee80211/bcm43xxx/bcmf_sdio_core.h +drivers/wireless/ieee80211/bcm43xxx/bcmf_sdio_regs.h +========================================== + + Permission to use, copy, modify, and/or distribute this software for any + purpose with or without fee is hereby granted, provided that the above + copyright notice and this permission notice appear in all copies. + + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +include/nuttx/wireless/ieee80211/ieee80211_cypto.h +========================================== + + Copyright (c) 2007, 2008 Damien Bergamini + + Permission to use, copy, modify, and distribute this software for any + purpose with or without fee is hereby granted, provided that the above + copyright notice and this permission notice appear in all copies. + + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +include/nuttx/wireless/ieee80211/ieee80211.h +=============================================== + + Copyright (c) 2002, 2003 Sam Leffler, Errno Consulting + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + arch/arm/src/lc823450/lc823450_sdc.c arch/arm/src/lc823450/lc823450_sddrv_dep.c arch/arm/src/lc823450/lc823450_sddrv_if.h @@ -2096,6 +2583,13 @@ STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +arch/xtensa/src/common/xtensa_asm_utils.h +=============================== + + Copyright (c) 2017, Intel Corporation + + SPDX-License-Identifier: Apache-2.0 + boards/or1k/mor1kx/or1k/src/or1k_boot.c boards/or1k/mor1kx/or1k/src/or1k_bringup.c ================================================= @@ -4147,6 +4641,164 @@ arch/arm/src/tiva/cc13xx/cc13x2_cc26x2_v2_rom.h ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +arch/arm/src/tiva/hardware/tiva_adc.h +arch/arm/src/tiva/tiva_adc.h +========================== + + Copyright (C) 2015 Calvin Maguranis. All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + 3. Neither the name NuttX nor the names of its contributors may be + used to endorse or promote products derived from this software + without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + +arch/arm/src/tiva/common/tiva_pwm.c +arch/arm/src/tiva/hardware/tiva_pwm.h +arch/arm/src/tiva/tiva_pwm.h +arch/arm/src/tiva/common/tiva_qencoder.c +arch/arm/src/tiva/hardware/tiva_qencoder.h +arch/arm/src/tiva/tiva_qencoder.h +==================================== + + Copyright (C) 2016 Young Mu. All rights reserved. + + The basic structure of this driver derives in spirit (if nothing more) + from the NuttX STM32 QEI driver which has: + + Copyright (C) 2012 Gregory Nutt. All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + 3. Neither the name NuttX nor the names of its contributors may be + used to endorse or promote products derived from this software + without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + +arch/arm/src/tiva/hardware/tm4c/tm4c_ethernet.h +arch/arm/src/tiva/hardware/tm4c/tm4c_flash.h +========================= + + Copyright (C) 2015 Gregory Nutt. All rights reserved. + + Based on register definitions provided by: + + Copyright (C) 2014 TRD2 Inc. All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + 3. Neither the name NuttX nor the names of its contributors may be + used to endorse or promote products derived from this software + without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + +arch/arm/src/tiva/hardware/lm/lm3s_timer.h +arch/arm/src/tiva/hardware/lm/lm4f_timer.h +arch/arm/src/tiva/hardware/tm4c/tm4c129_timer.h +arch/arm/src/tiva/hardware/tm4c/tm4c123_timer.h +=============================== + + Originally: + + Copyright (C) 2012, 2014 Max Nekludov. All rights reserved. + + Ongoing support and major revision to support the TM4C129 family + (essentially a full file replacement): + + Copyright (C) 2015, 2018 Gregory Nutt. All rights reserved. + + Some bitfield definitions taken from a header file provided by: + + Copyright (C) 2014 TRD2 Inc. All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + 3. Neither the name NuttX nor the names of its contributors may be + used to endorse or promote products derived from this software + without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + arch/arm/src/tms570/tms570_boot.c ================================= @@ -4583,6 +5235,38 @@ include/nuttx/mtd/onfi.h ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +drivers/mtd/at24xx.c +================================== + Copyright (C) 2011 Li Zhuoyi. All rights reserved. + Copyright (C) 2013, 2016 Gregory Nutt. All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + 3. Neither the name NuttX nor the names of its contributors may be + used to endorse or promote products derived from this software + without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + libs/libc/machine/arm/armv7-a/arch_memcpy.S libs/libc/marchine/arm/armv7-r/arch_memcpy.S ============================================== @@ -5139,6 +5823,30 @@ LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +libs/libc/string/lib_strstr.c +=============================== +The MIT License (MIT) + +Copyright (c) 2014-2015 Tal Einat + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + libs/libc/time/lib_localtime.c ================================= @@ -5181,6 +5889,29 @@ LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +libs/libc/time/lib_strptime.c +======================================= + + Copyright (c) 1997, 1998 The NetBSD Foundation, Inc. All rights reserved. + + This code was contributed to The NetBSD Foundation by Klaus Klein. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + 3. All advertising materials mentioning features or use of this software + must display the following acknowledgement: + This product includes software developed by the NetBSD + Foundation, Inc. and its contributors. + 4. Neither the name of The NetBSD Foundation nor the names of its + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + libs/libc/unistd/lib_gethostname.c libs/libc/unistd/lib_sethostname.c include/sys/uio.h @@ -5345,6 +6076,7 @@ SUCH DAMAGE. drivers/wireless/bluetooth/bt_uart.c drivers/wireless/bluetooth/bt_uart.h wireless/bluetooth +include/nuttx/wireless/bluetooth tools/size_report =========================== @@ -5701,7 +6433,7 @@ arch/arm/src/lpc2378/chip.h arch/arm/src/lpc2378/lpc2378.h arch/arm/src/lpc2378/lpc23xx_decodeirq.c arch/arm/src/lpc2378/lpc23xx_gpio.h -arch/arm/src/arm/lpc2378/lpc23xx_head.S +arch/arm/src/lpc2378/lpc23xx_head.S arch/arm/src/lpc2378/lpc23xx_i2c.c arch/arm/src/lpc2378/lpc23xx_io.c arch/arm/src/lpc2378/lpc23xx_irq.c @@ -5784,6 +6516,7 @@ ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. arch/arm/src/am335x/am335x_edid.c +arch/arm/src/am335x/am335x_lcdc.c arch/arm/src/am335x/am335x_lcdc.h ======================================= @@ -5822,3 +6555,98 @@ AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +net/sixlowpan/sixlowpan_framelist.c +net/sixlowpan/sixlowpan_hc06.c +net/sixlowpan/sixlowpan_hc1.c +net/sixlowpan/sixlowpan_input.c +net/sixlowpan/sixlowpan_internal.h +net/sixlowpan/sixlowpan_utils.c +include/nuttx/net/sixlowpan.h +============================ + + Copyright (C) 2017-2018 Gregory Nutt. All rights reserved. + Author: Gregory Nutt + + Parts of this file derive from Contiki: + + Copyright (c) 2008, Swedish Institute of Computer Science. + All rights reserved. + Authors: Adam Dunkels + Nicolas Tsiftes + Niclas Finne + Mathilde Durvy + Julien Abeille + Joakim Eriksson + Joel Hoglund + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + 3. Neither the name of the Institute nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND + ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE + FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + SUCH DAMAGE. + +net/igmp/igmp_group.c +net/igmp/igmp_initialize.c +net/igmp/igmp_input.c +net/igmp/igmp_join.c +net/igmp/igmp_leave.c +net/igmp/igmp_mcastmac.c +net/igmp/igmp_msg.c +net/igmp/igmp_poll.c +net/igmp/igmp_timer.c +============================== + + Copyright (C) 2010, 2013-2014, 2016, 2018 Gregory Nutt. + All rights reserved. + Author: Gregory Nutt + + The NuttX implementation of IGMP was inspired by the IGMP add-on for the + lwIP TCP/IP stack by Steve Reynolds: + + Copyright (c) 2002 CITEL Technologies Ltd. + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + 3. Neither the name of CITEL Technologies Ltd nor the names of its + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY CITEL TECHNOLOGIES AND CONTRIBUTORS ``AS IS'' + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL CITEL TECHNOLOGIES OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + THE POSSIBILITY OF SUCH DAMAGE. diff --git a/ReleaseNotes b/ReleaseNotes index cf2127920fec5..b68b9d008da5d 100644 --- a/ReleaseNotes +++ b/ReleaseNotes @@ -30561,3 +30561,1057 @@ LD = $(CROSSDEV)gcc - https://sourceware.org/pipermail/binutils/2021-June/116826.html * Description of -Wl,option in the GCC manual: - https://gcc.gnu.org/onlinedocs/gcc/Link-Options.html + +NuttX-10.3.0 Release Notes + +# What's New In This Release + +## Major Changes to Core OS + +### New Features + +* [#5524](https://github.com/apache/incubator-nuttx/pull/#5524) mm: iob: add support of alloc with timeout iob_timedalloc()  +* [#4743](https://github.com/apache/incubator-nuttx/pull/#4743) mm: Support the kernel address sanitizer  +* [#5498](https://github.com/apache/incubator-nuttx/pull/#5498) sched: Implement task local storage  +* [#5418](https://github.com/apache/incubator-nuttx/pull/#5418) sched: Implement sysinfo function  +* [#5590](https://github.com/apache/incubator-nuttx/pull/#5590) sched: os init_state: add new state OSINIT_IDLELOOP  +* [#4698](https://github.com/apache/incubator-nuttx/pull/#4698) sched: mq_open: add long file name check and parameter check  +* [#5445](https://github.com/apache/incubator-nuttx/pull/#5445) task: Always implement posix_spawnp as macro  +* [#4963](https://github.com/apache/incubator-nuttx/pull/#4963) trace: and sched note dump  +* [#5366](https://github.com/apache/incubator-nuttx/pull/#5366) binfmt: libelf: Implement sh_addralign handling +* [#4871](https://github.com/apache/incubator-nuttx/pull/#4871) binfmt: elf: add bare metal coredump support  + +### Bug Fixes + +* [#5503](https://github.com/apache/incubator-nuttx/pull/#5503) Replece clock_gettime with clock_systime_timespec if suitable  +* [#5721](https://github.com/apache/incubator-nuttx/pull/#5721) Remove the unnecessary code from nx_start +* [#5681](https://github.com/apache/incubator-nuttx/pull/#5681) Simplify and unify fcntl with FIOCLEX and FIONCLEX  +* [#5082](https://github.com/apache/incubator-nuttx/pull/#5082) compile/flags: add FRAME_POINTER into Toolchain.defs  +* [#5199](https://github.com/apache/incubator-nuttx/pull/#5199) file_operations: get back C89 compatible initializer  +* [#5065](https://github.com/apache/incubator-nuttx/pull/#5065) reanme CONFIG_USER_ENTRYPOINT to CONFIG_INIT_ENTRYPOINT +* [#5399](https://github.com/apache/incubator-nuttx/pull/#5399) Add CONFIG_NDEBUG Kconfig to control NDEBUG definition  +* [#5347](https://github.com/apache/incubator-nuttx/pull/#5347) register_driver: fix driver modes accross the code  +* [#5509](https://github.com/apache/incubator-nuttx/pull/#5509) libc.csv: Add pthread_setname_np and pthread_getname_np  +* [#5364](https://github.com/apache/incubator-nuttx/pull/#5364) libc.csv: Add more symbols  + +* [#4971](https://github.com/apache/incubator-nuttx/pull/#4971) audio: audio_comp.c: capbility should use collections  +* [#5072](https://github.com/apache/incubator-nuttx/pull/#5072) graphics: vncserver: Implement vsync  +* [#5058](https://github.com/apache/incubator-nuttx/pull/#5058) graphics: vncserver: Fix buffer overflow  +* [#5132](https://github.com/apache/incubator-nuttx/pull/#5132) graphics: vnc: Decouple VNC server from NX graphic stack  +* [#4998](https://github.com/apache/incubator-nuttx/pull/#4998) system: note dump: add CONFIG_SCHED_INSTRUMENTATION_SWITCH  +* [#5435](https://github.com/apache/incubator-nuttx/pull/#5435) wireless: bluetooth: fix build break if NET_6LOWPAN enabled  + +* [#5487](https://github.com/apache/incubator-nuttx/pull/#5487) binfmt: Decouple builtin from binfs file system +* [#4667](https://github.com/apache/incubator-nuttx/pull/#4667) binfmt: Remove umm_initialize from elf_load +* [#5351](https://github.com/apache/incubator-nuttx/pull/#5351) binfmt: elf.c: Fix syslog formats for ELF64  +* [#5522](https://github.com/apache/incubator-nuttx/pull/#5522) binfmt: Fix binfmt for BUILD_KERNEL & ADDRENV  +* [#4689](https://github.com/apache/incubator-nuttx/pull/#4689) binfmt: remove the specified prefix from target variables  +* [#5229](https://github.com/apache/incubator-nuttx/pull/#5229) binfmt: coredump: remove the block fragmentation  + +* [#5409](https://github.com/apache/incubator-nuttx/pull/#5409) libc: stdlib: Compile lib_openpty.c without checking CONFIG_SERIAL_TERMIOS  +* [#5600](https://github.com/apache/incubator-nuttx/pull/#5600) libc: Imx6 thumb  +* [#5474](https://github.com/apache/incubator-nuttx/pull/#5474) libc: posix_openpty should use the absolute path("dev/ptmx")  +* [#5508](https://github.com/apache/incubator-nuttx/pull/#5508) libc: sim: Rename arch_setjmp[64].S to arch_setjmp_x86[_64].S  +* [#4829](https://github.com/apache/incubator-nuttx/pull/#4829) libc: Make perror work without CONFIG_FILE_STREAM  +* [#4779](https://github.com/apache/incubator-nuttx/pull/#4779) libc: wqueue Correct time calculation in work_p…  +* [#4756](https://github.com/apache/incubator-nuttx/pull/#4756) libc: machine: xtensa: add xtensa libc implement  +* [#4752](https://github.com/apache/incubator-nuttx/pull/#4752) libc Move lib_filesem.c, lib_stream.c and lib_streamsem.c to libc/stdio  +* [#5288](https://github.com/apache/incubator-nuttx/pull/#5288) libc: misc: lib_execinfo.c: fix bad memory access  +* [#5290](https://github.com/apache/incubator-nuttx/pull/#5290) libc: backtrace_malloc change sprintf to snprintf  +* [#5381](https://github.com/apache/incubator-nuttx/pull/#5381) libc: sim: arch_elf64.c: Implement R_X86_64_PC64  +* [#4870](https://github.com/apache/incubator-nuttx/pull/#4870) libc: add interface to support output stream as buffer style  +* [#4861](https://github.com/apache/incubator-nuttx/pull/#4861) libc: pthread: Implement pthread_atfork  +* [#4992](https://github.com/apache/incubator-nuttx/pull/#4992) libc: Move stream implementation from libs/libc/stdio to libs/libc/stream  +* [#4768](https://github.com/apache/incubator-nuttx/pull/#4768) libc: machine: add config LIBC_ARCH_MEMCHR  +* [#4855](https://github.com/apache/incubator-nuttx/pull/#4855) libc: psignal: Output the message to STDERR_FILENO instead STDOUT_FILENO  +* [#4853](https://github.com/apache/incubator-nuttx/pull/#4853) libc: hex2bin: Handle the line ending(\r, \n and \r\n) dynamically  +* [#5690](https://github.com/apache/incubator-nuttx/pull/#5690) libc: gettext: Support the plural format  +* [#5692](https://github.com/apache/incubator-nuttx/pull/#5692) libc: stdio: Fix bug when CONFIG_LIBC_NUMBERED_ARGS is enabled  +* [#5465](https://github.com/apache/incubator-nuttx/pull/#5465) libc: chdir:"PWD" should save absolute path  +* [#4994](https://github.com/apache/incubator-nuttx/pull/#4994) libc: textdomain: Fix error behaviour  +* [#5039](https://github.com/apache/incubator-nuttx/pull/#5039) libc: lzfcompress: add lzf compress stream  +* [#4859](https://github.com/apache/incubator-nuttx/pull/#4859) libc: getdelim: Remove KERNEL check since it shouldn't be called inside kernel  +* [#4944](https://github.com/apache/incubator-nuttx/pull/#4944) libc: getopt: Move struct getopt_s to include/nuttx/tls.h  +* [#4881](https://github.com/apache/incubator-nuttx/pull/#4881) libc: Update include/nuttx/input/x11_keysymdef.h to the latest version  +* [#5126](https://github.com/apache/incubator-nuttx/pull/#5126) libc: math: fix fmod family operation  +* [#5125](https://github.com/apache/incubator-nuttx/pull/#5125) libc: math: fix log and logf calculations on ARMv7 (and maybe others)  +* [#5170](https://github.com/apache/incubator-nuttx/pull/#5170) libc: pthread:pthread_barrierinit sem use pri_none  +* [#2063](https://github.com/apache/incubator-nuttx/pull/#2063) libc: Fix libcxx for sim/macOS  +* [#5269](https://github.com/apache/incubator-nuttx/pull/#5269) libc: Fix a few libcxx build issues for sim/macOS  +* [#5202](https://github.com/apache/incubator-nuttx/pull/#5202) libc: libcxx-mini: operator new will assert when alloc failed.  +* [#5180](https://github.com/apache/incubator-nuttx/pull/#5180) libc: pthread: restore pthread mutex default protocol POSIX compatibility  +* [#5549](https://github.com/apache/incubator-nuttx/pull/#5549) libc: pthread: add the kernel stack allocation for ADDRENV=y and BUILD_KERNEL  +* [#4978](https://github.com/apache/incubator-nuttx/pull/#4978) libc: Add getprogname function  +* [#5004](https://github.com/apache/incubator-nuttx/pull/#5004) libc: unistd: getopt: Use argc to end parsing  +* [#5017](https://github.com/apache/incubator-nuttx/pull/#5017) libc: Enable terminal api regardless of CONFIG_SERIAL_TERMIOS setting  +* [#5053](https://github.com/apache/incubator-nuttx/pull/#5053) libc: symtab: optimize the find speed by bisection  +* [#5096](https://github.com/apache/incubator-nuttx/pull/#5096) libc: Add backtrace_symbols[_fd] functions  +* [#4874](https://github.com/apache/incubator-nuttx/pull/#4874) libc: stdoutstream: restore the output method to fputc()  +* [#5564](https://github.com/apache/incubator-nuttx/pull/#5564) libc: machine: Implement ARM aeabi_xxx API called by clang  +* [#5398](https://github.com/apache/incubator-nuttx/pull/#5398) libc: Implement posix_openpt  +* [#4962](https://github.com/apache/incubator-nuttx/pull/#4962) libc: allsyms: Load all symbols for debugging  +* [#4909](https://github.com/apache/incubator-nuttx/pull/#4909) libc: Add mknod implementation  +* [#4894](https://github.com/apache/incubator-nuttx/pull/#4894) libc: misc: add err.c to libc  +* [#4893](https://github.com/apache/incubator-nuttx/pull/#4893) libc: str: add strlcat to libc  +* [#5575](https://github.com/apache/incubator-nuttx/pull/#5575) libc: sched: task_setcanceltype: fix function name in comment  +* [#4828](https://github.com/apache/incubator-nuttx/pull/#4828) libc: stdio: Handle 64bits off_t correctly  +* [#4804](https://github.com/apache/incubator-nuttx/pull/#4804) libc: netdb: fix access within misaligned address error  +* [#4725](https://github.com/apache/incubator-nuttx/pull/#4725) libc: Improve the netdb config consistency  +* [#4985](https://github.com/apache/incubator-nuttx/pull/#4985) libc: Remove CEVA tl420/tl421 support on Nuttx  +* [#5036](https://github.com/apache/incubator-nuttx/pull/#5036) libc: net: Implement getifaddrs and freeifaddrs  +* [#5519](https://github.com/apache/incubator-nuttx/pull/#5519) libc: Fix -Werror=nonnull-compare and -Werror=format-truncation=  +* [#5629](https://github.com/apache/incubator-nuttx/pull/#5629) libc: fix up_tls_info define for BUILD_KERNEL  +* [#5307](https://github.com/apache/incubator-nuttx/pull/#5307) libc: bug patch for frexpf function  +* [#5107](https://github.com/apache/incubator-nuttx/pull/#5107) libc: Ensure that sethostname null terminates the hostname correctly  +* [#5479](https://github.com/apache/incubator-nuttx/pull/#5479) libdsp: lib_observer: add nolinear fluxlink observer  +* [#5483](https://github.com/apache/incubator-nuttx/pull/#5483) libdsp: improvements for lib_observer.c  +* [#5563](https://github.com/apache/incubator-nuttx/pull/#5563) libdsp: minor improvements and support for fixed16 observers  +* [#5527](https://github.com/apache/incubator-nuttx/pull/#5527) libnx: handle the bad message correctly  +* [#5321](https://github.com/apache/incubator-nuttx/pull/#5321) libxx: uclibxx: add patch use overload constructor of filebuf & ostream  +* [#4747](https://github.com/apache/incubator-nuttx/pull/#4747) Revert "libc: Implement fesetround & fegetround for arm"  +* [#4739](https://github.com/apache/incubator-nuttx/pull/#4739) Revert "lib/netdb: Change the default NETDB_DNSCLIENT_NAMESIZE to NAM…  + +* [#5459](https://github.com/apache/incubator-nuttx/pull/#5459) mm: mm_heap: add mm_foreach to run handler for every memory node +* [#5504](https://github.com/apache/incubator-nuttx/pull/#5504) mm: handle take mm sem in IRQ  +* [#4765](https://github.com/apache/incubator-nuttx/pull/#4765) mm: fix realloc overwrite memcpy when use a new block  +* [#4759](https://github.com/apache/incubator-nuttx/pull/#4759) mm: do kmm_checkcorruption in IRQ when TCB_FLAG_DEBUG_CHECK set +* [#5532](https://github.com/apache/incubator-nuttx/pull/#5532) mm: fix gran_alloc() array index range checking  +* [#5548](https://github.com/apache/incubator-nuttx/pull/#5548) mm: fix #if condition of g_mmheap for BUILD_KERNEL and ADDRENV  +* [#5539](https://github.com/apache/incubator-nuttx/pull/#5539) mm: handle take mm sem in IRQ  +* [#5585](https://github.com/apache/incubator-nuttx/pull/#5585) mm: Add memory dump function when enable CONFIG_DEBUG_MM  + +* [#5417](https://github.com/apache/incubator-nuttx/pull/#5417) pthread: Add len argument to pthread_getname_np  + +* [#4798](https://github.com/apache/incubator-nuttx/pull/#4798) sched: Reduce the default preallocated buffer when DEFAULT_SMALL=y  +* [#5632](https://github.com/apache/incubator-nuttx/pull/#5632) sched: group: Fix dataabort when exiting task or pthread if ARCH_ADDR_ENV=y  +* [#5658](https://github.com/apache/incubator-nuttx/pull/#5658) sched: group: Simplify the allocation and deallocation logic  +* [#5649](https://github.com/apache/incubator-nuttx/pull/#5649) Revert "sched: Don't duplicate caller file handler when creating kernel thread" +* [#5543](https://github.com/apache/incubator-nuttx/pull/#5543) sched: Mark pthread as non-cancelable to avoid additional calls to pthread_exit()  +* [#5583](https://github.com/apache/incubator-nuttx/pull/#5583) sched: note:add switch and dump instrumentation  +* [#5416](https://github.com/apache/incubator-nuttx/pull/#5416) sched: Disable pthread by default when DEFAULT_SMALL is enabled +* [#5015](https://github.com/apache/incubator-nuttx/pull/#5015) sched: add holder in sem_trywait  +* [#5264](https://github.com/apache/incubator-nuttx/pull/#5264) sched: Define SMP_NCPUS to 1 in no SMP case  +* [#4803](https://github.com/apache/incubator-nuttx/pull/#4803) sched: signal: add spinlock to g_sigfreeaction  +* [#4799](https://github.com/apache/incubator-nuttx/pull/#4799) sched: Disable message queue by default when DEFAULT_SMALL equals y  +* [#4772](https://github.com/apache/incubator-nuttx/pull/#4772) sched: vfork: allocate tls_info_s instead task_info_s from stack  +* [#4931](https://github.com/apache/incubator-nuttx/pull/#4931) sched: sched_waitpid:delete debugassert  +* [#4863](https://github.com/apache/incubator-nuttx/pull/#4863) sched: Move g_tcbinfo to include/nuttx/sched.h  +* [#5331](https://github.com/apache/incubator-nuttx/pull/#5331) sched: critmonitor: remove the assertion if counter == 0  +* [#5098](https://github.com/apache/incubator-nuttx/pull/#5098) sched: backtrace: Dump the complete stack regardless the depth  +* [#5185](https://github.com/apache/incubator-nuttx/pull/#5185) sched: Remove CONFIG_ prefix from SCHED_HPWORK  +* [#4666](https://github.com/apache/incubator-nuttx/pull/#4666) sched: Remove pidhash_s and move ticks to tcb_s  +* [#4676](https://github.com/apache/incubator-nuttx/pull/#4676) sched: Check g_pidhash[hash_ndx] isn't NULL before access pid field in nxsched_get_tcb  +* [#5545](https://github.com/apache/incubator-nuttx/pull/#5545) sched: clock: Remove CLOCK_MONOTONIC option from Kconfig  +* [#5464](https://github.com/apache/incubator-nuttx/pull/#5464) sched: tcbinfo: Fix warning by discarded qualifiers  +* [#5455](https://github.com/apache/incubator-nuttx/pull/#5455) sched: mqueue: remove unused leave_cancellation_point  +* [#5456](https://github.com/apache/incubator-nuttx/pull/#5456) sched: module: remove redundant unlock  +* [#5392](https://github.com/apache/incubator-nuttx/pull/#5392) sched: Remove SDCLONE_DISABLE option and config  +* [#4858](https://github.com/apache/incubator-nuttx/pull/#4858) sched: watchdog: remove tick check in wd_timer  +* [#5018](https://github.com/apache/incubator-nuttx/pull/#5018) sched: init/nx_start.c: fix compile break when CONIFG_TASK_NAME_SIZE=0  +* [#4999](https://github.com/apache/incubator-nuttx/pull/#4999) sched: sched_note: change uint32_t nbi_module into uint8_t array  +* [#4989](https://github.com/apache/incubator-nuttx/pull/#4989) sched: fix bug in the function nxsched_resume_scheduler  +* [#4958](https://github.com/apache/incubator-nuttx/pull/#4958) sched: signal: Introduce a private spinlock in sig_action.c  +* [#4954](https://github.com/apache/incubator-nuttx/pull/#4954) sched: dumpstack: raise the stack dump level to emergency  +* [#4953](https://github.com/apache/incubator-nuttx/pull/#4953) sched: semaphore: fix race condition for timed wait  +* [#4913](https://github.com/apache/incubator-nuttx/pull/#4913) sched: Move argv from tcb_s to task_info_s  +* [#5368](https://github.com/apache/incubator-nuttx/pull/#5368) sched: idle: remove heap & stack check in idle thread +* [#4782](https://github.com/apache/incubator-nuttx/pull/#4782) sched: sem: remove limitation of irq context when do sem_trywait +* [#4972](https://github.com/apache/incubator-nuttx/pull/#4972) sched: wqueue: update wqueue to support using wqueue before wqueue start  +* [#5266](https://github.com/apache/incubator-nuttx/pull/#5266) sched: IDLE thread will not boost up when IDLE hold sem  +* [#5540](https://github.com/apache/incubator-nuttx/pull/#5540) sched: semaphore: fix corner case sem_waitirq assert crash  +* [#4682](https://github.com/apache/incubator-nuttx/pull/#4682) sched: cpuload: fix crash because of the member of g_pidhash is NULL  +* [#5171](https://github.com/apache/incubator-nuttx/pull/#5171) sched: semphore: release all semphores' holder that the task held when exit  +* [#5063](https://github.com/apache/incubator-nuttx/pull/#5063) sched: wqueue: fix NO leave_critical_section() when only CONFIG_SCHED_HPWORK  + +## Major Changes to the Build System + +### New Features + +* [#5638](https://github.com/apache/incubator-nuttx/pull/#5638) tools: add parsememdump.py to parse memdump info(by cmd: memdump all)  +* [#5622](https://github.com/apache/incubator-nuttx/pull/#5622) tools: add rustfmt to checkpatch  +* [#4925](https://github.com/apache/incubator-nuttx/pull/#4925) tools: Add size report script +* [#5153](https://github.com/apache/incubator-nuttx/pull/#5153) tools: mpfs: prepare OpenSBI image  + +### Bug Fixes + +* [#5362](https://github.com/apache/incubator-nuttx/pull/#5362) tools: mkromfsimg.sh: add attribute to set minimum 4 bytes aignment for romfs image data  +* [#4794](https://github.com/apache/incubator-nuttx/pull/#4794) tools: mkconfig: Handle string with escape character correctly  +* [#4730](https://github.com/apache/incubator-nuttx/pull/#4730) tools: add code coverage tool  +* [#5174](https://github.com/apache/incubator-nuttx/pull/#5174) tools: Fix parallel build issue due to missing dependency  +* [#5275](https://github.com/apache/incubator-nuttx/pull/#5275) tools: mkromfsimg.sh: fix build error in case if romfs is used  +* [#5274](https://github.com/apache/incubator-nuttx/pull/#5274) tools: add option to reuse boards common files for custom boards  +* [#5715](https://github.com/apache/incubator-nuttx/pull/#5715) tools: define BOARD_COMMON_DIR only if ARCH_BOARD_COMMON is set  +* [#5533](https://github.com/apache/incubator-nuttx/pull/#5533) tools: Default macro to compile one Rust file.  +* [#5494](https://github.com/apache/incubator-nuttx/pull/#5494) tools: Unix.mk: silence output from version.sh  +* [#5400](https://github.com/apache/incubator-nuttx/pull/#5400) tools: mkconfig: Remove the unnecessary config option correction  +* [#4701](https://github.com/apache/incubator-nuttx/pull/#4701) tools: esp32: Refactor generation of QEMU-compatible image  +* [#4865](https://github.com/apache/incubator-nuttx/pull/#4865) tools: gdbinit: add sim:x86-m32 support  +* [#4926](https://github.com/apache/incubator-nuttx/pull/#4926) tools: rp2040: Compile with C++14 +* [#4936](https://github.com/apache/incubator-nuttx/pull/#4936) tools: Rename size_report to size_report.py  +* [#5518](https://github.com/apache/incubator-nuttx/pull/#5518) tools: mkallsyms.sh: Disable the mismatch warning of builtin declaration  +* [#5346](https://github.com/apache/incubator-nuttx/pull/#5346) tools: Config.mk: suppress all normal output for cmp  +* [#5374](https://github.com/apache/incubator-nuttx/pull/#5374) tools: Detect correct host CPU on MacOS/Linux running on ARM.  +* [#4673](https://github.com/apache/incubator-nuttx/pull/#4673) tools: CeDeROM add *BSD support 20211016  +* [#4494](https://github.com/apache/incubator-nuttx/pull/#4494) tools: build: Replace 'make download' with 'make flash', but keep both for now +* [#5116](https://github.com/apache/incubator-nuttx/pull/#5116) tools: Remove .clean_context  +* [#4869](https://github.com/apache/incubator-nuttx/pull/#4869) tools: Improve releasecheck.sh  +* [#5491](https://github.com/apache/incubator-nuttx/pull/#5491) tools: Fix configure.sh for custom apps dir.  +* [#5495](https://github.com/apache/incubator-nuttx/pull/#5495) tools: Fix jlink-nuttx build with GCC 10.2  +* [#5505](https://github.com/apache/incubator-nuttx/pull/#5505) tools: Fix JLinkGDBServer crash attaching to target +* [#5147](https://github.com/apache/incubator-nuttx/pull/#5147) tools: Improve dependencies for include/nuttx/version.h  +* [#5162](https://github.com/apache/incubator-nuttx/pull/#5162) tools: Improve dirlinks dependencies for Makefile.win  +* [#5055](https://github.com/apache/incubator-nuttx/pull/#5055) tools: Improve Makefile.[unix|win]::context's dependencies  +* [#5163](https://github.com/apache/incubator-nuttx/pull/#5163) tools: Rename Makefile.* to have the .mk extension  + +## Architectural Support + +### New Architecture Support + +* [#4897](https://github.com/apache/incubator-nuttx/pull/#4897) arch: arm: phy62xx: Phyplus release 1.2  +* [#5470](https://github.com/apache/incubator-nuttx/pull/#5470) arch: arm: STM32U5 Architecture Support  +* [#5165](https://github.com/apache/incubator-nuttx/pull/#5165) arch: ceva: add ceva platform xc5 xm6 support  +* [#5352](https://github.com/apache/incubator-nuttx/pull/#5352) arch: xtensa: Add initial support for ESP32-S3  +* [#5241](https://github.com/apache/incubator-nuttx/pull/#5241) arch: sparc: Port nuttx to sparc-v8 + +### Architecture with Significant Improvements + +* [#5468](https://github.com/apache/incubator-nuttx/pull/#5468) arch: Add xxx_tcbinfo.c to SoC level Make.defs  +* [#5482](https://github.com/apache/incubator-nuttx/pull/#5482) arch: Replace nx_vsyslog with vsyslog  +* [#5507](https://github.com/apache/incubator-nuttx/pull/#5507) arch: Align the implementation of stack related functions  +* [#4830](https://github.com/apache/incubator-nuttx/pull/#4830) arch: Remove fflush(stdout) from driver code  +* [#5741](https://github.com/apache/incubator-nuttx/pull/#5741) arch: Make the comment and definition of CONFIG_SYS_RESERVED correctly  +* [#5332](https://github.com/apache/incubator-nuttx/pull/#5332) arch: Toolchain.defs: Simplify addition builtin library to EXTRA_LIBS  +* [#5122](https://github.com/apache/incubator-nuttx/pull/#5122) arch: backtrace: correct the skip counter  +* [#5095](https://github.com/apache/incubator-nuttx/pull/#5095) arch: Select ARCH_HAVE_BACKTRACE in Kconfig for supported arch  +* [#5342](https://github.com/apache/incubator-nuttx/pull/#5342) arch: Add up_perf_getfreq function  +* [#5335](https://github.com/apache/incubator-nuttx/pull/#5335) arch: cache: flush/clean dcache all if size large than cache size  +* [#5328](https://github.com/apache/incubator-nuttx/pull/#5328) arch: Decouple up_critmon_[gettime|convert] from critmon  +* [#4699](https://github.com/apache/incubator-nuttx/pull/#4699) arch: cache: add lock & unlock feature  +* [#4910](https://github.com/apache/incubator-nuttx/pull/#4910) arch: Dump task name through tcb_s::name instead of argv[0]  +* [#4677](https://github.com/apache/incubator-nuttx/pull/#4677) arch: *_cpupause:Allow a spin before taking the g_cpu_wait spinlock.  +* [#5007](https://github.com/apache/incubator-nuttx/pull/#5007) arch: assert: flush the syslog before stack dump to avoid buffer overwrite  +* [#4942](https://github.com/apache/incubator-nuttx/pull/#4942) arch: tcbinfo: fix build break if task name disabled  +* [#4941](https://github.com/apache/incubator-nuttx/pull/#4941) arch: Remove the duplicated up_tls_info implementation  +* [#5385](https://github.com/apache/incubator-nuttx/pull/#5385) arch: Toolchain.defs: Replace --print-file-name=libgcc.a with --print-libgcc-file-name  +* [#5371](https://github.com/apache/incubator-nuttx/pull/#5371) arch: Toolchain.defs: Don't expand EXTRA_LIBS immediately  +* [#5057](https://github.com/apache/incubator-nuttx/pull/#5057) arch: arm/risc-v/xtensa: enhance the task dump  +* [#5397](https://github.com/apache/incubator-nuttx/pull/#5397) arch: arm/renesas/xtensa: fix leaving from critical section  +* [#5231](https://github.com/apache/incubator-nuttx/pull/#5231) arch: arm/xtensa/risc-v: save the running registers to xcp context  +* [#5719](https://github.com/apache/incubator-nuttx/pull/#5719) arch: Move [arm|xtensa]_intstack_[alloc|top] to common header file  +* [#5060](https://github.com/apache/incubator-nuttx/pull/#5060) arch: Kconfig: Add HAVE_SYSCALL_HOOKS configs to Xtensa arch.  +* [#4840](https://github.com/apache/incubator-nuttx/pull/#4840) arch: add MTDIOCTL_PROGMEM_ERASESTATE support  +* [#5259](https://github.com/apache/incubator-nuttx/pull/#5259) arch: use HTONS, NTOHS, HTONL, NTOHL macro in kernel code  +* [#5008](https://github.com/apache/incubator-nuttx/pull/#5008) arch: assert: unify stack and register dump across platforms  +* [#4810](https://github.com/apache/incubator-nuttx/pull/#4810) arch: debug: add tools for task aware debug  +* [#5088](https://github.com/apache/incubator-nuttx/pull/#5088) arch: make/allsyms: skip the unnecessary link operation  +* [#4749](https://github.com/apache/incubator-nuttx/pull/#4749) arch: Remove FILE dump code from _up_dumponexit +* [#5309](https://github.com/apache/incubator-nuttx/pull/#5309) arch: toolchain: add libm to EXTRA_LIBS only if it is provided by the compiler  +* [#5120](https://github.com/apache/incubator-nuttx/pull/#5120) arch: signal: signal handler may cause task's state error  +* [#4993](https://github.com/apache/incubator-nuttx/pull/#4993) arch: tls: restore C89 compatibility for TLS  + +#### ARM + +* [#4816](https://github.com/apache/incubator-nuttx/pull/#4816) arch: arm: Remove EXPERIMENTAL from ARCH_TRUSTZONE_XXX  +* [#5562](https://github.com/apache/incubator-nuttx/pull/#5562) arch: arm: add BUILD_KERNEL code in arm: arm_vectors.S  +* [#4980](https://github.com/apache/incubator-nuttx/pull/#4980) arch: arm: select LIBC_ARCH_ATOMIC when config ARCH_CHIP_RP2040  +* [#4961](https://github.com/apache/incubator-nuttx/pull/#4961) arch: arm: assert: fix the stack dump overflow  +* [#4935](https://github.com/apache/incubator-nuttx/pull/#4935) arch: arm: Implement TLS support  +* [#4917](https://github.com/apache/incubator-nuttx/pull/#4917) arch: arm: Kconfig: Add ARCH_HAVE_PROGMEM config  +* [#5593](https://github.com/apache/incubator-nuttx/pull/#5593) arch: arm: unify some duplicate code to common layer  +* [#5691](https://github.com/apache/incubator-nuttx/pull/#5691) arch: arm: Move setjmp to common place  +* [#4878](https://github.com/apache/incubator-nuttx/pull/#4878) arch: arm: fix unalign cacheline invalidate & add cache coherence config for semihosting option  +* [#5744](https://github.com/apache/incubator-nuttx/pull/#5744) arch: arm: timer_lowerhalf: minor improvements  +* [#5087](https://github.com/apache/incubator-nuttx/pull/#5087) arch: arm: assert: move the arm_assert to common code  +* [#5085](https://github.com/apache/incubator-nuttx/pull/#5085) arch: arm: move the backtrace implement to common code  +* [#5084](https://github.com/apache/incubator-nuttx/pull/#5084) arch: arm: select ARM_THUMB by default for Cortex-M  +* [#5329](https://github.com/apache/incubator-nuttx/pull/#5329) arch: arm: Fix make export for armv7-a SoCs  +* [#5105](https://github.com/apache/incubator-nuttx/pull/#5105) arch: arm: Fix rebase error in arm_backtrace_thumb.c  +* [#5703](https://github.com/apache/incubator-nuttx/pull/#5703) arch: arm: Support setjmp/longjmp for all socs  +* [#5582](https://github.com/apache/incubator-nuttx/pull/#5582) arch: arm: replace SYS_syscall_return hardcode from syscall  +* [#5502](https://github.com/apache/incubator-nuttx/pull/#5502) arch: arm: armv7-a: Add debug messages for addrenv +* [#5511](https://github.com/apache/incubator-nuttx/pull/#5511) arch: arm: armv7-a: Fix arm_syscall for SYS_pthread_start  +* [#5517](https://github.com/apache/incubator-nuttx/pull/#5517) arch: arm: armv7-a: fix gtm.h GTM_COMP1 and GTM_AUTO defines  +* [#5620](https://github.com/apache/incubator-nuttx/pull/#5620) arch: arm: armv7-a: Remove CONFIG_SMP guard from arm_scu.c  +* [#5742](https://github.com/apache/incubator-nuttx/pull/#5742) arch: arm: armv7-a/r: unified syscall registers dump  +* [#5066](https://github.com/apache/incubator-nuttx/pull/#5066) arch: arm: armv7-a/r: dump all registers with alias  +* [#5354](https://github.com/apache/incubator-nuttx/pull/#5354) arch: arm: armv7-a/r: cp15_invalidate_dcache_all: fix Sets mask error.  +* [#5367](https://github.com/apache/incubator-nuttx/pull/#5367) arch: arm: armv7-a/r: bugfix: fix a4 register use but not store in xxx_invalidate/flush/clean_all.S  +* [#5558](https://github.com/apache/incubator-nuttx/pull/#5558) arch: arm: armv7-a/r: fix SVC's sp restore in arm_vectors.S  +* [#5628](https://github.com/apache/incubator-nuttx/pull/#5628) arch: arm: armv7-a/r: handle swi on interrupt stack  +* [#5734](https://github.com/apache/incubator-nuttx/pull/#5734) arch: arm: armv7-a/r: set the default CPU mode to System  +* [#5506](https://github.com/apache/incubator-nuttx/pull/#5506) arch: arm: armv7-a/r: unify switch context from software interrupt  +* [#5441](https://github.com/apache/incubator-nuttx/pull/#5441) arch: arm: armv7-a/r: cache: add cp15_cache_size function and use flush/clean_all if size large than cache size  +* [#5650](https://github.com/apache/incubator-nuttx/pull/#5650) arch: arm: armv7-a/r: cache: modify hardcode in cache set/way operation  +* [#4702](https://github.com/apache/incubator-nuttx/pull/#4702) arch: arm: armv7-m,armv7-r,armv8-m:MPU Add mpu_reset and ARM_MPU_EARLY_RESET  +* [#5477](https://github.com/apache/incubator-nuttx/pull/#5477) arch: arm: armv8-m: Handle the special irq correctly in up_secure_irq  +* [#5355](https://github.com/apache/incubator-nuttx/pull/#5355) arch: arm: cortex-m: doirq: do not update the CURRENT_REGS on nested interrupt handling  +* [#4960](https://github.com/apache/incubator-nuttx/pull/#4960) arch: arm: cortex-m: backtrace: remove the push process to simplify backtrace  +* [#4956](https://github.com/apache/incubator-nuttx/pull/#4956) arch: arm: cortex-m: assert: dump all registers with alias  +* [#4955](https://github.com/apache/incubator-nuttx/pull/#4955) arch: arm: cortex-m: fault: add CFSR(Configurable Fault Status Register) Definitions  +* [#5048](https://github.com/apache/incubator-nuttx/pull/#5048) arch: arm: cortex-m: hardfault: add secure-fault handler  +* [#4959](https://github.com/apache/incubator-nuttx/pull/#4959) arch: arm: cortex-m: enhance the crash dump  +* [#4957](https://github.com/apache/incubator-nuttx/pull/#4957) arch: arm: cortex-m: hardfault: add usage/bus-fault handler  +* [#4965](https://github.com/apache/incubator-nuttx/pull/#4965) arch: arm: cortex-m23: remove mem-fault select from armv8-m baseline  + +#### EFM32 + +* [#5587](https://github.com/apache/incubator-nuttx/pull/#5587) arch: arm: efm32: Garbage configuration setting in EFM32 code  + +#### IMX6 + +* [#5633](https://github.com/apache/incubator-nuttx/pull/#5633) arch: arm: imx6: Fix imx6  +* [#5639](https://github.com/apache/incubator-nuttx/pull/#5639) arch: arm: imx6: Add the pgheap for imx6  + +#### IMXRT + +* [#4784](https://github.com/apache/incubator-nuttx/pull/#4784) arch: arm: imxrt: fixes  +* [#4717](https://github.com/apache/incubator-nuttx/pull/#4717) arch: arm: imxrt: rename imxrt_lowputc to arm_lowputc and drop CONFIG_DEBUG_FEATURES  + +#### LC823450 + +* [#4951](https://github.com/apache/incubator-nuttx/pull/#4951) arch: arm: lc823450: Replace the critical section with spinlock in lc823450_serial.c  + +#### NRF52 + +* [#5025](https://github.com/apache/incubator-nuttx/pull/#5025) arch: arm: nrf52: Fixes for NRF52 SoftDevice Controller  +* [#5032](https://github.com/apache/incubator-nuttx/pull/#5032) arch: arm: nrf52: NRF52_SDC_LE_CODED_PHY not available for nrf52832  +* [#5031](https://github.com/apache/incubator-nuttx/pull/#5031) arch: arm: nrf52: small improvements for softdevice  + +#### PHY62XX + +* [#5642](https://github.com/apache/incubator-nuttx/pull/#5642) arch: arm: phy62xx: remove unused private header  + +#### RP2040 + +* [#4786](https://github.com/apache/incubator-nuttx/pull/#4786) arch: arm: rp2040: support I2C_RESET  + +#### RTL8720C + +* [#5552](https://github.com/apache/incubator-nuttx/pull/#5552) arch: arm: rtl8720c: Remove the unused Toolchain.defs  + +#### S32K1XX + +* [#5220](https://github.com/apache/incubator-nuttx/pull/#5220) arch: arm: s32k1xx: implement uniqueid  + +#### SAM34 + +* [#5700](https://github.com/apache/incubator-nuttx/pull/#5700) arch: arm: sam34: sam_dmac.c: Fix compilation error  + +#### SAMV7 + +* [#5513](https://github.com/apache/incubator-nuttx/pull/#5513) arch: arm: samv7: fix peripheral id shift during transmit xdma configuration  +* [#5413](https://github.com/apache/incubator-nuttx/pull/#5413) arch: arm: samv7: sam_progmem: insert DMB instruction into data write loop  +* [#5411](https://github.com/apache/incubator-nuttx/pull/#5411) arch: arm: samv7: add arm_systemreset.c to CMN_CSRCS  +* [#5471](https://github.com/apache/incubator-nuttx/pull/#5471) arch: arm: samv7: Added support for PWM driver +* [#4795](https://github.com/apache/incubator-nuttx/pull/#4795) arch: arm: samv7: add support for AFEC driver  +* [#4737](https://github.com/apache/incubator-nuttx/pull/#4737) arch: arm: samv7: add support for QSPI driver in SPI Mode  +* [#5145](https://github.com/apache/incubator-nuttx/pull/#5145) arch: arm: samv7: correct number on interrupts  +* [#4950](https://github.com/apache/incubator-nuttx/pull/#4950) arch: arm: samv7: enable MCAN driver support for both rev A and rev B  +* [#4901](https://github.com/apache/incubator-nuttx/pull/#4901) arch: arm: samv7: Add DMA and TC support to AFEC (ADC) driver  +* [#5146](https://github.com/apache/incubator-nuttx/pull/#5146) arch: arm: samv7: rework SAMv7 timer counter implementation  +* [#5219](https://github.com/apache/incubator-nuttx/pull/#5219) arch: arm: samv7: implement quadrature encoder driver  +* [#5043](https://github.com/apache/incubator-nuttx/pull/#5043) arch: arm: samv7: initial support for LIN bus communication (Master only)  +* [#4904](https://github.com/apache/incubator-nuttx/pull/#4904) arch: arm: samv7: fix unaligned address write for progmem interface  +* [#4899](https://github.com/apache/incubator-nuttx/pull/#4899) arch: arm: samv7: fix page size flash writing for page unaligned addresses  +* [#5393](https://github.com/apache/incubator-nuttx/pull/#5393) arch: arm: samv7: fix leaving from critical section in HSMCI callback  + +#### STM32 + +* [#5206](https://github.com/apache/incubator-nuttx/pull/#5206) arch: arm: stm32: add FDCAN support  +* [#5169](https://github.com/apache/incubator-nuttx/pull/#5169) arch: arm: stm32: add SocketCAN support  +* [#5167](https://github.com/apache/incubator-nuttx/pull/#5167) arch: arm: stm32: add CAN error support  +* [#5419](https://github.com/apache/incubator-nuttx/pull/#5419) arch: arm: stm32: add FDCAN SocketCAN support  +* [#5523](https://github.com/apache/incubator-nuttx/pull/#5523) arch: arm: stm32: dp83848c ethernet phy interrupt support  +* [#5481](https://github.com/apache/incubator-nuttx/pull/#5481) arch: arm: stm32: fdcan: add CAN FD frames support  +* [#5370](https://github.com/apache/incubator-nuttx/pull/#5370) arch: arm: stm32: Add OTG ID GPIO disable  +* [#4790](https://github.com/apache/incubator-nuttx/pull/#4790) arch: arm: stm32: Qencoder: add support for the encoder index pin and implementation for stm32/qenco  +* [#5627](https://github.com/apache/incubator-nuttx/pull/#5627) arch: arm: stm32f103re has a dac module.but the pinmap file has no corresponding +* [#5300](https://github.com/apache/incubator-nuttx/pull/#5300) arch: arm: stm32f20xxf40xx: up_progmem_erasesize for stm32f20xxf40xx_flash.c  +* [#5605](https://github.com/apache/incubator-nuttx/pull/#5605) arch: arm: stm32f405: Add DAC2 configuration  +* [#4967](https://github.com/apache/incubator-nuttx/pull/#4967) arch: arm: stm32f412: add SPI2 & SPI3  +* [#5267](https://github.com/apache/incubator-nuttx/pull/#5267) arch: arm: stm32f7: serial fix PM_CONFIG build  +* [#5064](https://github.com/apache/incubator-nuttx/pull/#5064) arch: arm: stm32f7: sdmmc invalidate before DMA to avoid eviction overwrite - +* [#4704](https://github.com/apache/incubator-nuttx/pull/#4704) arch: arm: stm32f0/g0/l0: Add custom clock config option to stm32f0/g0/l0 chips  +* [#4872](https://github.com/apache/incubator-nuttx/pull/#4872) arch: arm: stm32f7: sdmmc defer invalidate until after DMA completion  +* [#5677](https://github.com/apache/incubator-nuttx/pull/#5677) arch: arm: stm32f7: fix CAN3 receiving  +* [#4741](https://github.com/apache/incubator-nuttx/pull/#4741) arch: arm: stm32g4: Minor fixes for stm32g4 foc  +* [#4780](https://github.com/apache/incubator-nuttx/pull/#4780) arch: arm: stm32h7: sdmmc: do not enable power saving configuration bit in SD 4-bit mode  +* [#4770](https://github.com/apache/incubator-nuttx/pull/#4770) arch: arm: stm32h7: dmamux: correct bit fields  +* [#4755](https://github.com/apache/incubator-nuttx/pull/#4755) arch: arm: stm32h7: sdmmc: added missing sdio_set_sdio_card_isr() function to initialize SDIO in-band interrupt logic  +* [#4731](https://github.com/apache/incubator-nuttx/pull/#4731) arch: arm: stm32h7: add low power timers  +* [#5492](https://github.com/apache/incubator-nuttx/pull/#5492) arch: arm: stm32h7: Fix build for all config {R|T}XDMA states  +* [#5493](https://github.com/apache/incubator-nuttx/pull/#5493) arch: arm: stm32h7: Flash fixes from 328374f4658d11655f268f968f4c6c7a3942f320  +* [#4815](https://github.com/apache/incubator-nuttx/pull/#4815) arch: arm: stm32l4: dfumode: enable for STM32L4+ chips  +* [#5666](https://github.com/apache/incubator-nuttx/pull/#5666) arch: arm: stm32l4: stm32l4+ might need flash data cache corruption workaround  +* [#4975](https://github.com/apache/incubator-nuttx/pull/#4975) arch: arm: stm32l4: stm32l4_pwm.c: fix printf format  + +#### CEVA + +* [#5520](https://github.com/apache/incubator-nuttx/pull/#5520) arch: ceva: update the code to the latest mainline  +* [#5568](https://github.com/apache/incubator-nuttx/pull/#5568) arch: ceva: Replace OUTDIR with TOPDIR  +* [#5727](https://github.com/apache/incubator-nuttx/pull/#5727) arch: ceva: Move the idle stack initialization to up_initial_state  + +#### SIM + +* [#5696](https://github.com/apache/incubator-nuttx/pull/#5696) arch: sim: add all symbols support  +* [#5641](https://github.com/apache/incubator-nuttx/pull/#5641) arch: sim: add loop thread to handle dev loops  +* [#4716](https://github.com/apache/incubator-nuttx/pull/#4716) arch: sim: add native socket support based on usrsock  +* [#4882](https://github.com/apache/incubator-nuttx/pull/#4882) arch: sim: Add new option to enable arch specific hostfs  +* [#4776](https://github.com/apache/incubator-nuttx/pull/#4776) arch: sim: host ASAN improvement  +* [#5401](https://github.com/apache/incubator-nuttx/pull/#5401) arch: sim: initial support sim:nsh on MacOS M1 based hosts.  +* [#5452](https://github.com/apache/incubator-nuttx/pull/#5452) arch: sim: detect clang native compiler on MacOS.  +* [#5414](https://github.com/apache/incubator-nuttx/pull/#5414) arch: sim: Unify the return value of usrsock_xxx_handler  +* [#5473](https://github.com/apache/incubator-nuttx/pull/#5473) arch: sim: Always typedef xcpt_reg_t to unsigned long  +* [#4751](https://github.com/apache/incubator-nuttx/pull/#4751) arch: arm: Add l suffix for INT32_C macro  +* [#5099](https://github.com/apache/incubator-nuttx/pull/#5099) arch: sim: Implement up_backtrace  +* [#5071](https://github.com/apache/incubator-nuttx/pull/#5071) arch: sim: Support vncserver as display device  +* [#4977](https://github.com/apache/incubator-nuttx/pull/#4977) arch: sim: add CONFIG_SIM_STACKSIZE_ADJUSTMENT to reduce variability  +* [#5384](https://github.com/apache/incubator-nuttx/pull/#5384) arch: sim: Adjust the stack size for up_use_stack too  +* [#5486](https://github.com/apache/incubator-nuttx/pull/#5486) arch: sim: Fix a build with clang on linux  +* [#5295](https://github.com/apache/incubator-nuttx/pull/#5295) arch: sim: Added Kconfig option for UART buffer size.  +* [#5188](https://github.com/apache/incubator-nuttx/pull/#5188) arch: sim: Rename up_vfork_x[32|64].S to up_vfork_x86[_64].S  +* [#5179](https://github.com/apache/incubator-nuttx/pull/#5179) arch: sim: Move spiflash simulation to drivers/spi instead  +* [#5178](https://github.com/apache/incubator-nuttx/pull/#5178) arch: sim: Rename up_vfork[32|64].S to up_vfork_x[32|64].S  +* [#5431](https://github.com/apache/incubator-nuttx/pull/#5431) arch: sim: Don't add up_tls_size in up_use_stack before foward to up_create_stack  +* [#4487](https://github.com/apache/incubator-nuttx/pull/#4487) arch: sim: Don't add -lc++abi to STDLIBS  +* [#4791](https://github.com/apache/incubator-nuttx/pull/#4791) arch: sim: btuart: Remove the unnecessary config  +* [#5313](https://github.com/apache/incubator-nuttx/pull/#5313) arch: sim: netdev: retrieve all the queued RX frames from the network device on every poll  +* [#4696](https://github.com/apache/incubator-nuttx/pull/#4696) arch: sim: rptun: Trigger the callback only the sequnece number change  +* [#5286](https://github.com/apache/incubator-nuttx/pull/#5286) arch: sim: up_macho_init.c: Add a workaround for Monterey  +* [#5046](https://github.com/apache/incubator-nuttx/pull/#5046) arch: sim: usrsock: increase the sim usrsock buffer size  +* [#5030](https://github.com/apache/incubator-nuttx/pull/#5030) arch: sim: usrsock: reuse the socket address to avoid bind timeout  +* [#5685](https://github.com/apache/incubator-nuttx/pull/#5685) arch: sim: syscall: add syscall note support in the flat build  +* [#4754](https://github.com/apache/incubator-nuttx/pull/#4754) Revert "sim: Specify -fshort-wchar as NuttX wchar_t is 16-bit"  +* [#5343](https://github.com/apache/incubator-nuttx/pull/#5343) arch: sim: netdev,tapdev: implemented emulation of TX done and RX ready interrupts  +* [#5295](https://github.com/apache/incubator-nuttx/pull/#5295) arch: sim: Added Kconfig option for UART buffer size. +* [#5260](https://github.com/apache/incubator-nuttx/pull/#5260) arch: sim: up_touchscreen: update up_touchscreen, using touch_upperhalf  +* [#5226](https://github.com/apache/incubator-nuttx/pull/#5226) arch: sim: netdev: eliminated RX data stream congestion in case of high TX network traffic  + +#### RISC-V + +* [#5619](https://github.com/apache/incubator-nuttx/pull/#5619) arch: espressif: Fix SCHED_CPULOAD feature using Oneshot Timer  +* [#4728](https://github.com/apache/incubator-nuttx/pull/#4728) arch: espressif: Rename MTD-related configs to become more intuitive  +* [#5044](https://github.com/apache/incubator-nuttx/pull/#5044) arch: espressif: Add hardware-supported Secure Boot on top of MCUboot  +* [#4671](https://github.com/apache/incubator-nuttx/pull/#4671) arch: espressif: Provide SPI Flash parameters to MCUboot build  +* [#5173](https://github.com/apache/incubator-nuttx/pull/#5173) arch: espressif: Fix build system issues related to Flash Encryption  +* [#5619](https://github.com/apache/incubator-nuttx/pull/#5619) arch: espressif: Fix SCHED_CPULOAD feature using Oneshot Timer  +* [#4727](https://github.com/apache/incubator-nuttx/pull/#4727) arch: espressif: Enable Partition Table allocation at custom offset  +* [#4945](https://github.com/apache/incubator-nuttx/pull/#4945) arch: risc-v: Introduce basic support for qemu rv32  +* [#5291](https://github.com/apache/incubator-nuttx/pull/#5291) arch: risc-v: Unify common irq code  +* [#5192](https://github.com/apache/incubator-nuttx/pull/#5192) arch: risc-v: Merge rv32im and rv64gc into common  +* [#5228](https://github.com/apache/incubator-nuttx/pull/#5228) arch: risc-v: Support both rv32/rv64 on qemu-rv  +* [#5160](https://github.com/apache/incubator-nuttx/pull/#5160) arch: risc-v: Replace __LP64__ with CONFIG_ARCH_RV64  +* [#5148](https://github.com/apache/incubator-nuttx/pull/#5148) arch: risc-v: Refine riscv_assert.c and arch.h  +* [#5243](https://github.com/apache/incubator-nuttx/pull/#5243) arch: risc-v: Make exception_common 8 byte align  +* [#5709](https://github.com/apache/incubator-nuttx/pull/#5709) arch: risc-v: mpfs: Make cleaner pinmux configurations for USB  +* [#5209](https://github.com/apache/incubator-nuttx/pull/#5209) arch: risc-v: Refine riscv_vectors.S  +* [#5123](https://github.com/apache/incubator-nuttx/pull/#5123) arch: risc-v: Correct epc adjustment with C ISA  +* [#5106](https://github.com/apache/incubator-nuttx/pull/#5106) arch: risc-v: Refine riscv_testset.S  +* [#5076](https://github.com/apache/incubator-nuttx/pull/#5076) arch: risc-v: Refine Toolchain.defs  +* [#5097](https://github.com/apache/incubator-nuttx/pull/#5097) arch: risc-v: Move riscv_blocktask.c to common  +* [#5092](https://github.com/apache/incubator-nuttx/pull/#5092) arch: risc-v: Remove unneeded kconfigs  +* [#5064](https://github.com/apache/incubator-nuttx/pull/#5064) arch: risc-v: opensbi: Make.defs: use a wildcard for file listing  +* [#5314](https://github.com/apache/incubator-nuttx/pull/#5314) arch: risc-v: Move xxx_cpustart.c to common  +* [#5103](https://github.com/apache/incubator-nuttx/pull/#5103) arch: risc-v: Refine riscv_fpu.S  +* [#5273](https://github.com/apache/incubator-nuttx/pull/#5273) arch: risc-v: Sv39 MMU driver +* [#5135](https://github.com/apache/incubator-nuttx/pull/#5135) arch: risc-v: Refine riscv_initialstate.c  +* [#5115](https://github.com/apache/incubator-nuttx/pull/#5115) arch: risc-v: Refine syscall interface  +* [#5113](https://github.com/apache/incubator-nuttx/pull/#5113) arch: risc-v: Add backtrace to risc-v common sources  +* [#4983](https://github.com/apache/incubator-nuttx/pull/#4983) arch: risc-v: Implement TLS support  +* [#5707](https://github.com/apache/incubator-nuttx/pull/#5707) arch: risc-v: Implement SYS_save_context in swint  +* [#5695](https://github.com/apache/incubator-nuttx/pull/#5695) arch: risc-v: Save/Load float register in setjmp  +* [#5478](https://github.com/apache/incubator-nuttx/pull/#5478) arch: risc-v: Use _ebss instead of _default_stack_limit as idle stack base +* [#5484](https://github.com/apache/incubator-nuttx/pull/#5484) arch: risc-v: Implement common up_cpu_idlestack  +* [#5490](https://github.com/apache/incubator-nuttx/pull/#5490) arch: risc-v: Let g_cpu_basestack determined at compile time  +* [#5091](https://github.com/apache/incubator-nuttx/pull/#5091) arch: risc-v: pwm: add option to break the loops when using multiple PWM channels  +* [#5454](https://github.com/apache/incubator-nuttx/pull/#5454) arch: risc-v: Remove duplicated up_idle logic  +* [#5358](https://github.com/apache/incubator-nuttx/pull/#5358) arch: risc-v: RISC-V MMU: Add missing implementation for PTE getter  +* [#5240](https://github.com/apache/incubator-nuttx/pull/#5240) arch: risc-v: Refine riscv_cpupause.c  +* [#5308](https://github.com/apache/incubator-nuttx/pull/#5308) arch: risc-v: Merge mcause.h into irq.h  +* [#5210](https://github.com/apache/incubator-nuttx/pull/#5210) arch: risc-v: Refine exception_common  +* [#5236](https://github.com/apache/incubator-nuttx/pull/#5236) arch: risc-v: Refine riscv_cpuindex.c  + +#### BL602 + +* [#5316](https://github.com/apache/incubator-nuttx/pull/#5316) arch: risc-v: bl602: Fix broken bl602 flash due to partition_table being incorrectly marked as unused  +* [#5221](https://github.com/apache/incubator-nuttx/pull/#5221) arch: risc-v: bl602: Rename bl602_entry.S to bl602_head.S  +* [#4876](https://github.com/apache/incubator-nuttx/pull/#4876) arch: risc-v: bl602: Enable GPIO output  +* [#4984](https://github.com/apache/incubator-nuttx/pull/#4984) arch: risc-v: bl602: Swap SPI MISO and MOSI  +* [#5131](https://github.com/apache/incubator-nuttx/pull/#5131) arch: risc-v: bl602: Fix preprocessing directives for uart flow control  +* [#5093](https://github.com/apache/incubator-nuttx/pull/#5093) arch: risc-v: bl602: Use userspace chosen channel numbers when starting bl602 pwm  + +#### ESP32C3 + +* [#5129](https://github.com/apache/incubator-nuttx/pull/#5129) arch: risc-v: esp32c3: SPI flash MTD device uses all flash space  +* [#4771](https://github.com/apache/incubator-nuttx/pull/#4771) arch: risc-v: esp32c3: Remove the DMA test included in the driver along with its defconfig.  +* [#4700](https://github.com/apache/incubator-nuttx/pull/#4700) arch: risc-v: esp32c3: Remove test code from crypto accelerators drivers.  +* [#4711](https://github.com/apache/incubator-nuttx/pull/#4711) arch: risc-v: esp32c3: Remove the stub implementations of the early serial  +* [#5615](https://github.com/apache/incubator-nuttx/pull/#5615) arch: risc-v: esp32c3: Fix detection of CPU reset by Watchdog Timer  +* [#4796](https://github.com/apache/incubator-nuttx/pull/#4796) arch: risc-v: esp32c3: Fix MMU pages number calculation error  +* [#4820](https://github.com/apache/incubator-nuttx/pull/#4820) arch: risc-v: esp32c3: Partition supports BIO cmd  +* [#4821](https://github.com/apache/incubator-nuttx/pull/#4821) arch: risc-v: esp32c3: Add hardware brownout check and reset  +* [#4834](https://github.com/apache/incubator-nuttx/pull/#4834) arch: risc-v: esp32c3: esp32c3_usbserial.c: Initialize cpuint to ENOMEM.  +* [#4813](https://github.com/apache/incubator-nuttx/pull/#4813) arch: risc-v: esp32c3: Fix GPIO Output on pins 18 and 19 USB/JTAG  +* [#4809](https://github.com/apache/incubator-nuttx/pull/#4809) arch: risc-v: esp32c3: Driver for the ESP32-C3's CDC console.  +* [#5615](https://github.com/apache/incubator-nuttx/pull/#5615) arch: risc-v: esp32c3: Fix detection of CPU reset by Watchdog Timer  +* [#4787](https://github.com/apache/incubator-nuttx/pull/#4787) arch: risc-v: esp32c3: Initialize the BLE Mac  +* [#4822](https://github.com/apache/incubator-nuttx/pull/#4822) arch: risc-v: esp32c3: Fix reset triggering crash nested when crash  +* [#4740](https://github.com/apache/incubator-nuttx/pull/#4740) arch: risc-v: esp32c3: Fix Wi-Fi & BLE coexist issues  +* [#4886](https://github.com/apache/incubator-nuttx/pull/#4886) arch: risc-v: esp32c3: Refactor SPI Flash to support umask interrupt when R/W/E SPI Flash  +* [#4885](https://github.com/apache/incubator-nuttx/pull/#4885) arch: risc-v: esp32c3: Refactor ADC calibration  +* [#5616](https://github.com/apache/incubator-nuttx/pull/#5616) arch: risc-v: esp32c3: Enable Timer Groups clocks on timer initialization  +* [#5304](https://github.com/apache/incubator-nuttx/pull/#5304) arch: risc-v: esp32c3: esp32c3_irq.c: Skip over ECALL instruction.  +* [#5457](https://github.com/apache/incubator-nuttx/pull/#5457) arch: risc-v: esp32c3: Fix issue #5377 UART1 not working because clock as disabled  +* [#5016](https://github.com/apache/incubator-nuttx/pull/#5016) arch: risc-v: esp32c3: Initialize rtc and peripheral parameters by default when chip starts  +* [#5124](https://github.com/apache/incubator-nuttx/pull/#5124) arch: risc-v: esp32s2/esp32c3: Remove unavailable support for ROM Basic Console  +* [#5133](https://github.com/apache/incubator-nuttx/pull/#5133) arch: risc-v: esp32s2/esp32c3: Add support for enabling hardware Flash Encryption on boot + +#### MPFS + +* [#4877](https://github.com/apache/incubator-nuttx/pull/#4877) arch: risc-v: mpfs: Add spi cs control for mpfs  +* [#5289](https://github.com/apache/incubator-nuttx/pull/#5289) arch: risc-v: mpfs: bootloader entrypoints  +* [#5247](https://github.com/apache/incubator-nuttx/pull/#5247) arch: risc-v: mpfs: switch to exception common  +* [#5360](https://github.com/apache/incubator-nuttx/pull/#5360) arch: risc-v: mpfs: Add support for a ROMFS image for MPFS  +* [#5322](https://github.com/apache/incubator-nuttx/pull/#5322) arch: risc-v: mpfs: build protected +* [#5109](https://github.com/apache/incubator-nuttx/pull/#5109) arch: risc-v: mpfs: Add MSSIO GPIO pinmap configuration  +* [#5306](https://github.com/apache/incubator-nuttx/pull/#5306) arch: risc-v: mpfs: OpenSBI: utilize an index2id table  +* [#5287](https://github.com/apache/incubator-nuttx/pull/#5287) arch: risc-v: mpfs: opensbi redefinition fixes +* [#5225](https://github.com/apache/incubator-nuttx/pull/#5225) arch: risc-v: mpfs: Opensbi fixes  +* [#5325](https://github.com/apache/incubator-nuttx/pull/#5325) arch: risc-v: mpfs: opensbi conf   +* [#5310](https://github.com/apache/incubator-nuttx/pull/#5310) arch: risc-v: mpfs: switch to NuttX types for opensbi  +* [#5702](https://github.com/apache/incubator-nuttx/pull/#5702) arch: risc-v: mpfs: usb: apply review fixes  +* [#5040](https://github.com/apache/incubator-nuttx/pull/#5040) arch: risc-v: mpfs: add opensbi support  +* [#4709](https://github.com/apache/incubator-nuttx/pull/#4709) arch: risc-v: mpfs: emmcsd: provide proper internal emmc settings  +* [#4714](https://github.com/apache/incubator-nuttx/pull/#4714) arch: risc-v: mpfs: ddr training and system clock init  +* [#4839](https://github.com/apache/incubator-nuttx/pull/#4839) arch: risc-v: mpfs: emmcsd: boost waitresponse perf  +* [#4817](https://github.com/apache/incubator-nuttx/pull/#4817) arch: risc-v: mpfs: uart: add a way to configure uart3 and uart4  +* [#4788](https://github.com/apache/incubator-nuttx/pull/#4788) arch: risc-v: mpfs: emmcsd: fix uninitialized value  +* [#4781](https://github.com/apache/incubator-nuttx/pull/#4781) arch: risc-v: mpfs: cache: provide L1/L2 cache enablers  +* [#4773](https://github.com/apache/incubator-nuttx/pull/#4773) arch: risc-v: mpfs: i2c: Add support for adaptive I2C bus frequency  +* [#5694](https://github.com/apache/incubator-nuttx/pull/#5694) arch: risc-v: mpfs: usb: fix an unused variable warning  +* [#5161](https://github.com/apache/incubator-nuttx/pull/#5161) arch: risc-v: mpfs: mpfs_serial.c: Correct setting of nbits  +* [#5152](https://github.com/apache/incubator-nuttx/pull/#5152) arch: risc-v: opensbi: update to version 1.0  +* [#5636](https://github.com/apache/incubator-nuttx/pull/#5636) arch: risc-v/qemu-rv: Set FS bits in mstatus  +* [#5529](https://github.com/apache/incubator-nuttx/pull/#5529) arch: risc-v/qemu-rv: Supports SMP up to 8 cores and other minor changes  +* [#4825](https://github.com/apache/incubator-nuttx/pull/#4825) arch: risc-v/xtensa: Kconfig: Some cleanup and improvements to arch versions of C library functions.  +* [#5683](https://github.com/apache/incubator-nuttx/pull/#5683) arch: risc-v/xtensa: corrent dumpstate xcp size  +* [#5717](https://github.com/apache/incubator-nuttx/pull/#5717) Revert "arch: risc-v: Correct FPU register save area in riscv_copystate"  + +#### SPARC + +* [#5394](https://github.com/apache/incubator-nuttx/pull/#5394) arch: sparc: adaptive patch  +* [#5521](https://github.com/apache/incubator-nuttx/pull/#5521) arch: sparc: Replace adj_stack_ptr with stack_base_ptr  + +#### XTENSA + +* [#4688](https://github.com/apache/incubator-nuttx/pull/#4688) arch: xtensa: Kconfig: add quotes in source to clean warnings from setconfig  +* [#5738](https://github.com/apache/incubator-nuttx/pull/#5738) arch: xtensa: Save exception cause and vaddr into the user frame  +* [#5149](https://github.com/apache/incubator-nuttx/pull/#5149) arch: xtensa: Rename up_stack_color to xtensa_stack_color.  +* [#5198](https://github.com/apache/incubator-nuttx/pull/#5198) arch: xtensa: fix lack of float register save & resotre  +* [#4663](https://github.com/apache/incubator-nuttx/pull/#4663) arch: xtensa: Correctly save/restore coprocessor0 state.  +* [#5450](https://github.com/apache/incubator-nuttx/pull/#5450) arch: xtensa: kconfig: move ARCH_HAVE_TESTSET config to chip  +* [#5648](https://github.com/apache/incubator-nuttx/pull/#5648) arch: xtensa: fix sp duplicate reduce in handler enter  +* [#5541](https://github.com/apache/incubator-nuttx/pull/#5541) arch: xtensa: modify svcall to swint  +* [#5729](https://github.com/apache/incubator-nuttx/pull/#5729) arch: xtensa: Small improvements around xtensa_context  +* [#5708](https://github.com/apache/incubator-nuttx/pull/#5708) arch: xtensa: small improvements around using the software interrupt.  +* [#5684](https://github.com/apache/incubator-nuttx/pull/#5684) arch: xtensa: backtrace: fix backtrace last buffer error in some scene  +* [#5250](https://github.com/apache/incubator-nuttx/pull/#5250) arch: xtensa: Fix core voltage level when SPI Flash runs at 80Mhz  +* [#5248](https://github.com/apache/incubator-nuttx/pull/#5248) arch: xtensa: some fixes in interrupt handler  +* [#4818](https://github.com/apache/incubator-nuttx/pull/#4818) arch: xtensa: mpu: use WRITEBACK attribute for intsram & extsram  +* [#4683](https://github.com/apache/incubator-nuttx/pull/#4683) arch: xtensa: mpu: modify acc and memtype to uint32_t  +* [#4664](https://github.com/apache/incubator-nuttx/pull/#4664) arch: xtensa: xtensa_context.S: Save and restore SCOMPARE1 when necessary.  +* [#4669](https://github.com/apache/incubator-nuttx/pull/#4669) arch: xtensa: xtensa_cpupause.c: Allow a spin before taking the g_cpu_wait spinlock.  +* [#5336](https://github.com/apache/incubator-nuttx/pull/#5336) arch: xtensa: use swint to swith context  +* [#5679](https://github.com/apache/incubator-nuttx/pull/#5679) arch: xtensa: xtensa_user_handler.S: Store EXCCAUSE and EXCVADDR into the user frame. +* [#5000](https://github.com/apache/incubator-nuttx/pull/#5000) arch: xtensa: correct the interrupt stack on irq handler  + +#### ESP32 + +* [#5056](https://github.com/apache/incubator-nuttx/pull/#5056) arch: xtensa: esp32: Add WiFi/BLE Coexistence support   +* [#5187](https://github.com/apache/incubator-nuttx/pull/#5187) arch: xtensa: esp32: Add PWM support using the LEDC peripheral  +* [#5143](https://github.com/apache/incubator-nuttx/pull/#5143) arch: xtensa: esp32: Use ROM implementations of libc functions  +* [#5117](https://github.com/apache/incubator-nuttx/pull/#5117) arch: xtensa: esp32: Add support for enabling hardware Flash Encryption on boot  +* [#4991](https://github.com/apache/incubator-nuttx/pull/#4991) arch: xtensa: esp32: Show CPUs activity using LEDs.  +* [#4670](https://github.com/apache/incubator-nuttx/pull/#4670) arch: xtensa: esp32: Few fixes around SPI Flash to make it SMP friendly.  +* [#4710](https://github.com/apache/incubator-nuttx/pull/#4710) arch: xtensa: esp32: Make SPI Flash initialization common to all ESP32 boards  +* [#5542](https://github.com/apache/incubator-nuttx/pull/#5542) arch: xtensa: esp32: setup software interrupt for esp32chips  +* [#5407](https://github.com/apache/incubator-nuttx/pull/#5407) arch: xtensa: esp32: Remove the QEMU special case when initializing the heap.  +* [#5536](https://github.com/apache/incubator-nuttx/pull/#5536) arch: xtensa: esp32: Few improvements around interrupt handling.  +* [#5196](https://github.com/apache/incubator-nuttx/pull/#5196) arch: xtensa: esp32: Add support to RS485  +* [#4543](https://github.com/apache/incubator-nuttx/pull/#4543) arch: xtensa: esp32: Use device specific lock as much as possible.  +* [#4796](https://github.com/apache/incubator-nuttx/pull/#4796) arch: xtensa: esp32: Fix MMU pages number calculation error  +* [#4820](https://github.com/apache/incubator-nuttx/pull/#4820) arch: xtensa: esp32: Partition supports BIO cmd  +* [#4933](https://github.com/apache/incubator-nuttx/pull/#4933) arch: xtensa: esp32: Remove CONFIG_SMP conditions in the code.  +* [#5073](https://github.com/apache/incubator-nuttx/pull/#5073) arch: xtensa: esp32: Fix some Wi-Fi issues +* [#4867](https://github.com/apache/incubator-nuttx/pull/#4867) arch: xtensa: esp32: Fix retrieving GPIOs' IRQ number and peripheral ID in SMP.  +* [#4769](https://github.com/apache/incubator-nuttx/pull/#4769) arch: xtensa: esp32: Make ESP32_BT_RESERVE_DRAM default to 0 again if Bluetooth is not enabled.  + +#### ESP32S2 + +* [#5213](https://github.com/apache/incubator-nuttx/pull/#5213) arch: xtensa: esp32s2: Fix some wrong definitions related to IRQ management  +* [#5212](https://github.com/apache/incubator-nuttx/pull/#5212) arch: xtensa: esp32s2: Fix data cache option in menuconfig  +* [#5693](https://github.com/apache/incubator-nuttx/pull/#5693) arch: xtensa: esp32s2: Sync IRQ management API with ESP32 and ESP32-S3  +* [#4902](https://github.com/apache/incubator-nuttx/pull/#4902) arch: xtensa: esp32xx: esp32xx_rtc.c: misc. fixes.  +* [#5609](https://github.com/apache/incubator-nuttx/pull/#5609) arch: xtensa: esp32s2: Correctly enable the software interrupt.  +* [#5698](https://github.com/apache/incubator-nuttx/pull/#5698) arch: xtensa: esp32s2: Add support for Main System Watchdog Timers  +* [#4703](https://github.com/apache/incubator-nuttx/pull/#4703) arch: xtensa: esp32s2: Add RNG driver support and board profile example  + +#### ESP32S3 + +* [#5665](https://github.com/apache/incubator-nuttx/pull/#5665) arch: xtensa: esp32s3: Add SPI-Flash support  +* [#5699](https://github.com/apache/incubator-nuttx/pull/#5699) arch: xtensa: esp32s3: Enable SMP support  +* [#5723](https://github.com/apache/incubator-nuttx/pull/#5723) arch: xtensa: esp32s3: Add support for RT-Timer based on Systimer peripheral  +* [#5668](https://github.com/apache/incubator-nuttx/pull/#5668) arch: xtensa: esp32s3: Add support for Tickless kernel using Systimer  +* [#5671](https://github.com/apache/incubator-nuttx/pull/#5671) arch: xtensa: esp32s3: Add support for Free-running Timer wrapper  +* [#5686](https://github.com/apache/incubator-nuttx/pull/#5686) arch: xtensa: esp32s3: Add SPI RAM/PSRAM Support  +* [#5601](https://github.com/apache/incubator-nuttx/pull/#5601) arch: xtensa: esp32s3: Add support for Main System Watchdog Timers  +* [#5602](https://github.com/apache/incubator-nuttx/pull/#5602) arch: xtensa: esp32s3: Add support for Timer Groups 0 and 1  +* [#5604](https://github.com/apache/incubator-nuttx/pull/#5604) arch: xtensa: esp32s3: Use the running CPU ID for enabling internal interrupts  +* [#5608](https://github.com/apache/incubator-nuttx/pull/#5608) arch: xtensa: esp32s3: Add support for Oneshot timer  +* [#5722](https://github.com/apache/incubator-nuttx/pull/#5722) arch: xtensa: esp32s3: Stall Timer ISR when core 1 is temporarily stalled  + +#### Z80 + +* [#5726](https://github.com/apache/incubator-nuttx/pull/#5726) arch: z[80|16]: Move up_getsp declaration to arch.h  +* [#5344](https://github.com/apache/incubator-nuttx/pull/#5344) arch: z80: fix garbage collector option to linker for ez80  + +## Driver Support + +### Drivers With Significant Improvements + +* [#5256](https://github.com/apache/incubator-nuttx/pull/#5256) drivers: Add usbdev serial use boardid  +* [#5728](https://github.com/apache/incubator-nuttx/pull/#5728) drivers: Merge the common driver initialization into one place  +* [#5716](https://github.com/apache/incubator-nuttx/pull/#5716) drivers: Move the common driver to misc folder  +* [#5080](https://github.com/apache/incubator-nuttx/pull/#5080) drivers: regulator/clk rpmsg: pending on wait IPC channel ready  +* [#4864](https://github.com/apache/incubator-nuttx/pull/#4864) drivers: audio: cxd56: various audio fixes  +* [#4976](https://github.com/apache/incubator-nuttx/pull/#4976) drivers: bch: support flush and aligned bch buffer  +* [#4712](https://github.com/apache/incubator-nuttx/pull/#4712) drivers: can: Fix can_poll() POLLOUT calculation  +* [#2641](https://github.com/apache/incubator-nuttx/pull/#2641) drivers: can: Cleanup usage of soft fifo semaphore  +* [#4661](https://github.com/apache/incubator-nuttx/pull/#4661) drivers: i2c: fix compile break when enable CONFIG_I2C_BITBANG_NO_DELAY  +* [#5042](https://github.com/apache/incubator-nuttx/pull/#5042) drivers: input: ads7843e: complement critical section operation  +* [#5631](https://github.com/apache/incubator-nuttx/pull/#5631) drivers: input: Remove the couple from uinput  +* [#5624](https://github.com/apache/incubator-nuttx/pull/#5624) drivers: input: joystick/buttons: Fix the event lose between the invocation of poll  +* [#5625](https://github.com/apache/incubator-nuttx/pull/#5625) drivers: input: joystick: Remove [a|d]joy_enable from [a|d]joy_sample  +* [#5204](https://github.com/apache/incubator-nuttx/pull/#5204) drivers: input: joystck/buttons: Always protect the open list by critical section  +* [#4837](https://github.com/apache/incubator-nuttx/pull/#4837) drivers: input: touchscreen: added time stamp for touchscreen event  +* [#4800](https://github.com/apache/incubator-nuttx/pull/#4800) drivers: input: touchscreen: separate the interface for user interaction  +* [#4928](https://github.com/apache/incubator-nuttx/pull/#4928) drivers: input: touchscreen: added touchscreen gesture  +* [#5005](https://github.com/apache/incubator-nuttx/pull/#5005) drivers: ioexpander: add ioe_rpmsg server and client +* [#5657](https://github.com/apache/incubator-nuttx/pull/#5657) drivers: ioexpander: Fix invert option value usage  +* [#5680](https://github.com/apache/incubator-nuttx/pull/#5680) drivers: ioexpander: fix output inversion for ioe_dummy  +* [#4697](https://github.com/apache/incubator-nuttx/pull/#4697) drivers: ioexpander: gpio: Remove the hardcode 100 lim +* [#4774](https://github.com/apache/incubator-nuttx/pull/#4774) drivers: ioexpander: gpio: Use generic /dev/gpioN  +* [#5183](https://github.com/apache/incubator-nuttx/pull/#5183) drivers: ioexpander: Select IOEXPANDER_INT_ENABLE instead depend on it  +* [#5037](https://github.com/apache/incubator-nuttx/pull/#5037) drivers: net: Replace self defined macros with NET_SOCK_[FAMILY|TYPE|PROTOCOL] itation +* [#5733](https://github.com/apache/incubator-nuttx/pull/#5733) drivers: note: Add macro guard for instrumention switch  +* [#4530](https://github.com/apache/incubator-nuttx/pull/#4530) drivers: mmcsd: Add RPMB ioctl  +* [#5215](https://github.com/apache/incubator-nuttx/pull/#5215) drivers: mmcsd: sdio.c: Fix struct packing of sdio_resp_r5  +* [#5155](https://github.com/apache/incubator-nuttx/pull/#5155) drivers: mmcsd: sdio: Move sdio utils functions to drivers/mmcsd +* [#4472](https://github.com/apache/incubator-nuttx/pull/#4472) drivers: mmcsd: sdio: Update the defintion to the latest spec  +* [#5294](https://github.com/apache/incubator-nuttx/pull/#5294) drivers: mmcsd: add option to limit block count in multiple-block trans…  +* [#5182](https://github.com/apache/incubator-nuttx/pull/#5182) drivers: motor: Move simulated drivers from sim to common place  +* [#4833](https://github.com/apache/incubator-nuttx/pull/#4833) drivers: motor: add upperhalf structure  +* [#5442](https://github.com/apache/incubator-nuttx/pull/#5442) drivers: mtd: enlarge the limits of blocksize in struct m…  +* [#5451](https://github.com/apache/incubator-nuttx/pull/#5451) drivers: mtd: sst39vf.c: patch address map issue  +* [#4924](https://github.com/apache/incubator-nuttx/pull/#4924) drivers: mtd: Support multiple SST26 devices on the same spi bus  +* [#4921](https://github.com/apache/incubator-nuttx/pull/#4921) drivers: mtd: fix overflow checks in mtdpart  +* [#4891](https://github.com/apache/incubator-nuttx/pull/#4891) drivers: mtd: ramtron: Remove errant code and definitions  +* [#4995](https://github.com/apache/incubator-nuttx/pull/#4995) drivers: mtd/filemtd: improve write and erase access  +* [#4964](https://github.com/apache/incubator-nuttx/pull/#4964) drivers: note: noteram: when the buffer overflow happen and give the asan report  +* [#4763](https://github.com/apache/incubator-nuttx/pull/#4763) drivers: pipes: pipe close should notify block writting, and write will return …  +* [#5425](https://github.com/apache/incubator-nuttx/pull/#5425) drivers: pipes: Remove pipe from file system after open  +* [#5475](https://github.com/apache/incubator-nuttx/pull/#5475) drivers: pipes: Don't use sched_[lock|unlock] to do protection  +* [#5423](https://github.com/apache/incubator-nuttx/pull/#5423) drivers: pipes: Add DEV_PIPE_VFS_PATH to specify the pipe location  +* [#4729](https://github.com/apache/incubator-nuttx/pull/#4729) drivers: power: battery: add baterr, batinfo, batwarn for debug log  +* [#4708](https://github.com/apache/incubator-nuttx/pull/#4708) drivers: power: charge: modify battery_gauge code  +* [#4990](https://github.com/apache/incubator-nuttx/pull/#4990) drivers: power: charger: fix crash when notify without pollwaiter  +* [#4889](https://github.com/apache/incubator-nuttx/pull/#4889) drivers: power: improve charger interface +* [#5701](https://github.com/apache/incubator-nuttx/pull/#5701) drivers: power: govorner: add govorner to per domain.  +* [#5591](https://github.com/apache/incubator-nuttx/pull/#5591) drivers: power: PM: add domain inner update power state feature  +* [#5050](https://github.com/apache/incubator-nuttx/pull/#5050) drivers: power: set ioexpander direction in regulator gpio init. +* [#5689](https://github.com/apache/incubator-nuttx/pull/#5689) drivers: segger/sysview: add syscall support   +* [#5140](https://github.com/apache/incubator-nuttx/pull/#5140) drivers: sensors: as5048b: fix lower half init issue  +* [#5061](https://github.com/apache/incubator-nuttx/pull/#5061) drivers: sensors: isl29023.c: fix compilation error and warnings  +* [#4838](https://github.com/apache/incubator-nuttx/pull/#4838) drivers: sensors: Add sensor type ots.  +* [#4850](https://github.com/apache/incubator-nuttx/pull/#4850) drivers: sensors: add set calibration interface  +* [#4842](https://github.com/apache/incubator-nuttx/pull/#4842) drivers: sensors: Optimized GPS sensor and add gps satellite sensor.  +* [#5356](https://github.com/apache/incubator-nuttx/pull/#5356) drivers: sensors: ppg of dual- and quad-channel sensor types  +* [#5024](https://github.com/apache/incubator-nuttx/pull/#5024) drivers: sensors: reset interval,latency and circbuf when sensor is closed  +* [#5128](https://github.com/apache/incubator-nuttx/pull/#5128) drivers: serial: uart16550: Support 64bit platform  +* [#5573](https://github.com/apache/incubator-nuttx/pull/#5573) drivers: serial: pty: Handle pty ioctl and fcntl to pipe ioctl  +* [#5114](https://github.com/apache/incubator-nuttx/pull/#5114) drivers: serial: add CONFIG_TTY_LAUNCH support  +* [#5197](https://github.com/apache/incubator-nuttx/pull/#5197) drivers: serial: merge serial check signo to one place  +* [#5430](https://github.com/apache/incubator-nuttx/pull/#5430) drivers: serial: fix cu crash caused by ioctl is NULL  +* [#5395](https://github.com/apache/incubator-nuttx/pull/#5395) drivers: serial: Consolidate the general termios in the common place  +* [#5427](https://github.com/apache/incubator-nuttx/pull/#5427) drivers: serial: Minor fix for ptmx driver  +* [#5415](https://github.com/apache/incubator-nuttx/pull/#5415) drivers: serial: pty: Sync the default value of iflag and oflag regardless CONFIG_SERIAL_TERMIOS  +* [#5444](https://github.com/apache/incubator-nuttx/pull/#5444) drivers: serial: pty: Decouple SUSv1 style from pseudo fs operation  +* [#5227](https://github.com/apache/incubator-nuttx/pull/#5227) drivers: serial: uart_16550: Allow uintptr_t as addr width  +* [#4940](https://github.com/apache/incubator-nuttx/pull/#4940) drivers: serial: Fix offset calculation in 16550  +* [#5569](https://github.com/apache/incubator-nuttx/pull/#5569) drivers: serial: pty: Move the post process after reading the buffer  +* [#5551](https://github.com/apache/incubator-nuttx/pull/#5551) drivers: serial: pty: Remove the unused code related to CONFIG_PSEUDOTERM_FULLBLOCKS  +* [#5402](https://github.com/apache/incubator-nuttx/pull/#5402) drivers: serial: pty: fix the lock handling  +* [#5428](https://github.com/apache/incubator-nuttx/pull/#5428) drivers: serial: pty: Close the internal pipe when reference count drop to zero  +* [#5429](https://github.com/apache/incubator-nuttx/pull/#5429) drivers: serial: pty: Don't use shced_[lock|unlock] to protect pp_locked  +* [#5433](https://github.com/apache/incubator-nuttx/pull/#5433) drivers: serial: pty: Reorder the register driver to simplify the error handling  +* [#5581](https://github.com/apache/incubator-nuttx/pull/#5581) drivers: serial: pty: Remove the TODO comment for O_NONBLOCK  +* [#5158](https://github.com/apache/incubator-nuttx/pull/#5158) drivers: serial: uart_rpmsg: fix data loss  +* [#4789](https://github.com/apache/incubator-nuttx/pull/#4789) drivers: spi: Extend CONFIG_SPI_CS_DELAY_CONTROL to do inter frame delay and rename CONFIG_SPI_DELAY_CONTROL  +* [#5408](https://github.com/apache/incubator-nuttx/pull/#5408) drivers: syslog: syslog_device: fix flushing data when end of line is detected  +* [#4873](https://github.com/apache/incubator-nuttx/pull/#4873) drivers: syslog: change /dev/syslog & /dev/ramlog for unix standard  +* [#5386](https://github.com/apache/incubator-nuttx/pull/#5386) drivers: syslog: Refine Kconfig option  +* [#5386](https://github.com/apache/incubator-nuttx/pull/#5388) drivers: syslog: Implement RTT based log channel  +* [#5735](https://github.com/apache/incubator-nuttx/pull/#5735) drivers: syslog: correct the return value of default channel write  +* [#5387](https://github.com/apache/incubator-nuttx/pull/#5387) drivers: syslog: Include nuttx/syslog/syslog.h in include/nuttx/syslog/syslog_rpmsg.h  +* [#5217](https://github.com/apache/incubator-nuttx/pull/#5217) drivers: syslog: Fix in file channel initialization.  +* [#5021](https://github.com/apache/incubator-nuttx/pull/#5021) drivers: syslog/rpmsg: using up_putc to force flush syslog_rpmsg buffer  +* [#5333](https://github.com/apache/incubator-nuttx/pull/#5333) drivers: timers: Add weak_function for up_ function  +* [#5265](https://github.com/apache/incubator-nuttx/pull/#5265) drivers: timers: dirctly call rpmsg_rtc_server_xx() in server_ept_cb()  +* [#5743](https://github.com/apache/incubator-nuttx/pull/#5743) drivers: timers: timer: Add option for non-periodic notification  +* [#5232](https://github.com/apache/incubator-nuttx/pull/#5232) drivers: timers: rpmsg_rtc: resolve deadlock when the receive SYNC cmd  +* [#5230](https://github.com/apache/incubator-nuttx/pull/#5230) drivers: timers: Simplify the RTC rpmsg driver implementation  +* [#4635](https://github.com/apache/incubator-nuttx/pull/#4635) drivers: userled: Implement getall by checking actual pin state  +* [#5594](https://github.com/apache/incubator-nuttx/pull/#5594) drivers: video: vncserver: Allow fb operation while no connection  +* [#5510](https://github.com/apache/incubator-nuttx/pull/#5510) drivers: video: vncserver: Fix dead lock on re-connect  +* [#5369](https://github.com/apache/incubator-nuttx/pull/#5369) drivers: usbdev: cdcacm:support returning c_cflag & speed via termios  +* [#5249](https://github.com/apache/incubator-nuttx/pull/#5249) drivers: usbdev: Fix aligment issue: pktbuf needs to be 16bit aligned  +* [#4766](https://github.com/apache/incubator-nuttx/pull/#4766) drivers: Fix syslog_write failed  +* [#4757](https://github.com/apache/incubator-nuttx/pull/#4757) drivers: rptun: add ns_unbind_notify support  +* [#4974](https://github.com/apache/incubator-nuttx/pull/#4974) drivers: rptun: support can_recursive check for openamp  +* [#5112](https://github.com/apache/incubator-nuttx/pull/#5112) drivers: wireless: bcm43xxx: supported ARM CR4 core and bcm43455 chip in particular  +* [#4690](https://github.com/apache/incubator-nuttx/pull/#4690) drivers: wireless: bcm43xxx: supported high-speed timing mode with a clock rate up to 50MHz +* [#4778](https://github.com/apache/incubator-nuttx/pull/#4778) drivers: wireless: bcm43xxx: corrected SDIO_CCCR_HIGHSPEED_SHS bit handling  +* [#5497](https://github.com/apache/incubator-nuttx/pull/#5497) drivers: wireless: Fix gs2200m_ioctl_accept()  + +### New Driver Support + +* [#5002](https://github.com/apache/incubator-nuttx/pull/#5002) drivers: analog: add mcp48xx dac support  +* [#5376](https://github.com/apache/incubator-nuttx/pull/#5376) drivers: i2c: Add TCA9548A I2C Multiplexer  +* [#4937](https://github.com/apache/incubator-nuttx/pull/#4937) drivers: mtd: add MTD null driver support  +* [#4943](https://github.com/apache/incubator-nuttx/pull/#4943) drivers: power: add regulator framework  +* [#5317](https://github.com/apache/incubator-nuttx/pull/#5317) drivers: sensors: add support to MS5611 barometer  +* [#4691](https://github.com/apache/incubator-nuttx/pull/#4691) drivers: sensors: support new sensor type  +* [#5499](https://github.com/apache/incubator-nuttx/pull/#5499) drivers: timers: add EPSON RX8010SJ I2C RTC timer support  +* [#4918](https://github.com/apache/incubator-nuttx/pull/#4918) drivers: clk: add clk framework  +* [#5258](https://github.com/apache/incubator-nuttx/pull/#5258) drivers: input: add touchscreen uinput driver  +* [#5327](https://github.com/apache/incubator-nuttx/pull/#5327) drivers: segger: add Segger System View support  + +## Board Support + +### New Board Support + +* [#5363](https://github.com/apache/incubator-nuttx/pull/#5363) boards: arm: phy62xx: add phyplus_rel_1.4  +* [#4916](https://github.com/apache/incubator-nuttx/pull/#4916) boards: arm: samv7: add support for SAME70 QMTECH board  +* [#5195](https://github.com/apache/incubator-nuttx/pull/#5195) boards: arm: rp2040: add support for Pimoroni Tiny 2040 board +* [#4851](https://github.com/apache/incubator-nuttx/pull/#4851) boards: risc-v: mpfs: Add support for Aries M100PFSMVP board  + +### Boards With Significant Improvements + +* [#5553](https://github.com/apache/incubator-nuttx/pull/#5553) boards: Add -fno-common to ARCHCFLAGS and ARCHCXXFLAGS  +* [#5330](https://github.com/apache/incubator-nuttx/pull/#5330) boards: Board.mk: Make romfs_img 4 byte aligned  +* [#5712](https://github.com/apache/incubator-nuttx/pull/#5712) boards: Kconfig: introduce ARCH_BOARD_COMMON option  +* [#4744](https://github.com/apache/incubator-nuttx/pull/#4744) boards: Rename FOC_VEL_ADC to FOC_SETPOINT_ADC +* [#5557](https://github.com/apache/incubator-nuttx/pull/#5557) boards: Replace CONFIG_CYGWIN_WINTOOL with CONVERT_PATH  +* [#5555](https://github.com/apache/incubator-nuttx/pull/#5555) boards: Remove the unnecessary customize Make.defs  +* [#5476](https://github.com/apache/incubator-nuttx/pull/#5476) boards: Remove -fno-builtin  +* [#5244](https://github.com/apache/incubator-nuttx/pull/#5244) boards: Remove -fno-strength-reduce  +* [#5349](https://github.com/apache/incubator-nuttx/pull/#5349) boards: Remove unused NXFLAT flags from Make.defs  +* [#5348](https://github.com/apache/incubator-nuttx/pull/#5348) boards: Revert user space / kernel space isolation for pthread_exit  +* [#5557](https://github.com/apache/incubator-nuttx/pull/#5557) boards: Replace CONFIG_CYGWIN_WINTOOL with CONVERT_PATH  +* [#5282](https://github.com/apache/incubator-nuttx/pull/#5282) boards: Update board Make.defs + +#### CXD56 + +* [#5440](https://github.com/apache/incubator-nuttx/pull/#5440) boards: arm: cxd56xx: audio: Support I2S input  +* [#4996](https://github.com/apache/incubator-nuttx/pull/#4996) boards: arm: cxd56xx: spresense: Adjust CONFIG_FAT_MAXFNAME and CONFIG_NAME_MAX  +* [#4969](https://github.com/apache/incubator-nuttx/pull/#4969) boards: arm: cxd56xx: spresense: Update smp/defconfig  + +#### IMX6 + +* [#5652](https://github.com/apache/incubator-nuttx/pull/#5652) boards: arm: imx6: sabre-6quad: Add knsh  +* [#5485](https://github.com/apache/incubator-nuttx/pull/#5485) boards: arm: imx6: sabre-6quad: Add -fno-common to Make.defs +* [#5724](https://github.com/apache/incubator-nuttx/pull/#5724) boards: arm: imx6: sabre-6quad: Add CONFIG_DEBUG_FULLOPT=y to knsh/defconfig  + +#### IMXRT + +* [#5670](https://github.com/apache/incubator-nuttx/pull/#5670) boards: arm: imxrt: fix userled config in appinit  +* [#5682](https://github.com/apache/incubator-nuttx/pull/#5682) boards: arm: imxrt: userleds: Teensy 4.x board LED is active high  + +#### LC823450 + +* [#4947](https://github.com/apache/incubator-nuttx/pull/#4947) boards: arm: lc823450: lc823450-xgevk: Update bt/defconfig for SMP  +  +#### NRF52 + +* [#5023](https://github.com/apache/incubator-nuttx/pull/#5023) boards: arm: nrf52: nrf52832-dk/nrf52840-dk: add procfs and sdc support  + +#### PHY62XX + +* [#5669](https://github.com/apache/incubator-nuttx/pull/#5669) boards: arm: phy62xx: phy6222: remove -nostartfiles -nodefaultlibs  + +#### SAMV7 + +* [#5406](https://github.com/apache/incubator-nuttx/pull/#5406) boards: arm: samv7: disable systick no matter if ARMV7M_SYSTICK is enabled or not +* [#5710](https://github.com/apache/incubator-nuttx/pull/#5710) boards: arm: samv7: rework linker script usage logic to allow custom linker scripts  +* [#5281](https://github.com/apache/incubator-nuttx/pull/#5281) boards: arm: samv7: move HSMCI interface to common  +* [#4981](https://github.com/apache/incubator-nuttx/pull/#4981) boards: arm: samv7: Introduce common folder and refactor MCUboot  +* [#5320](https://github.com/apache/incubator-nuttx/pull/#5320) boards: arm: samv7: common: add HSMCI0 boot mount configuration option  +* [#5127](https://github.com/apache/incubator-nuttx/pull/#5127) boards: arm: samv7: common: Improve SAMv7 common folder approach +* [#5318](https://github.com/apache/incubator-nuttx/pull/#5318) boards: arm: samv7: same70-qmtech: enable slow crystal  +* [#5410](https://github.com/apache/incubator-nuttx/pull/#5410) boards: arm: samv7: same70-qmtech: add buttons interface  +* [#4911](https://github.com/apache/incubator-nuttx/pull/#4911) boards: arm: samv7: samv71-xult: Set console at usart1  +* [#5676](https://github.com/apache/incubator-nuttx/pull/#5676) boards: arm: samv7: default BOARD_SAMV7_COMMON to n  +* [#5119](https://github.com/apache/incubator-nuttx/pull/#5119) boards: arm: samv7: improve progmem common interface  +* [#5276](https://github.com/apache/incubator-nuttx/pull/#5276) boards: arm: samv7: fix build error when automount is enabled  +* [#5277](https://github.com/apache/incubator-nuttx/pull/#5277) boards: arm: same70-qmtech: switch console to UART0  +* [#5312](https://github.com/apache/incubator-nuttx/pull/#5312) boards: arm: same70-qmtech: clarify usage of CD signal on SD card connector  +* [#4880](https://github.com/apache/incubator-nuttx/pull/#4880) boards: arm: same70-xplained: MCUboot support for SAM E70 Xplained  +* [#4912](https://github.com/apache/incubator-nuttx/pull/#4912) boards: arm: same70-xplained: disable systick before loading MCUboot application  +* [#4907](https://github.com/apache/incubator-nuttx/pull/#4907) boards: arm: same70-xplained: scripts: fix memory region size for MCUboot app  +* [#4906](https://github.com/apache/incubator-nuttx/pull/#4906) boards: arm: same70-xplained: fix usage of SAMV71XULT instead of SAME70XPLAINED  +* [#4915](https://github.com/apache/incubator-nuttx/pull/#4915) boards: arm: same70-xplained: MCUboot related improvements  + +#### STM32 + +* [#5011](https://github.com/apache/incubator-nuttx/pull/#5011) boards: arm: stm32: emw3162: enabled internal pull-up resistors on SDIO bus  +* [#4750](https://github.com/apache/incubator-nuttx/pull/#4750) boards: arm: stm32: Normalize FOC related project  +* [#5612](https://github.com/apache/incubator-nuttx/pull/#5612) boards: arm: stm32: Update adb configs  +* [#5675](https://github.com/apache/incubator-nuttx/pull/#5675) boards: arm: stm32: stm32f4discovery: Remove CONFIG_LIBC_EXECFUNCS from adb defconfig  +* [#4775](https://github.com/apache/incubator-nuttx/pull/#4775) boards: arm: stm32: b-g431b-esc1: add Hall and Qenco support  +* [#5420](https://github.com/apache/incubator-nuttx/pull/#5420) boards: arm: stm32: b-g431b-esc1/nucleo-g431rb: add SocketCAN examples  +* [#5237](https://github.com/apache/incubator-nuttx/pull/#5237) boards: arm: stm32: b-g431b-esc1/nucleo-g431rb: add CAN example for  +* [#5238](https://github.com/apache/incubator-nuttx/pull/#5238) boards: arm: stm32: nucleo-f302r8: nucleo-f446re: add SocketCAN example  +* [#4785](https://github.com/apache/incubator-nuttx/pull/#4785) boards: arm: stm32: nucleo-f302r8: disable NSH commands for FOC configs to save FLASH  +* [#4938](https://github.com/apache/incubator-nuttx/pull/#4938) boards: arm: stm32: nucleo-f302r8: add 3ph Hall sensor support  +* [#5166](https://github.com/apache/incubator-nuttx/pull/#5166) boards: arm: stm32: nucleo-f446re: add procfs support  +* [#5614](https://github.com/apache/incubator-nuttx/pull/#5614) boards: arm: stm32: nucleo-l152re: Added registering logic SPI on /dev. +* [#5439](https://github.com/apache/incubator-nuttx/pull/#5439) boards: arm: stm32: nucleo-l152re: Test/i2c  +* [#5009](https://github.com/apache/incubator-nuttx/pull/#5009) boards: arm: stm32: nucleo-f4x1re: Correct issues with userled support on the Nucleo F4x1RE.  +* [#5130](https://github.com/apache/incubator-nuttx/pull/#5130) boards: arm: stm32: photon: added configuration to measure wlan performance  + +#### STM32H7 + +* [#5697](https://github.com/apache/incubator-nuttx/pull/#5697) boards: arm: stm32[f7|l4]: fix SPI chip select GPIO access  +* [#4827](https://github.com/apache/incubator-nuttx/pull/#4827) boards: arm: stm32h7: nucleo-h743zi: add board_reset function  + +#### TIVA + +* [#5664](https://github.com/apache/incubator-nuttx/pull/#5664) boards: arm: tiva: ekk-lm3s9b96: Remove unused mmcsd option  +* [#5595](https://github.com/apache/incubator-nuttx/pull/#5595) boards: arm: tiva: lm3s6965-ek: Add qemu-kostest   +* [#5597](https://github.com/apache/incubator-nuttx/pull/#5597) boards: arm: tiva: lm3s6965-ek: Fix qemu-kostest  +* [#5597](https://github.com/apache/incubator-nuttx/pull/#5597) boards: arm: tiva: lm3s6965-ek: Fix qemu-kostest  + +#### RISC-V + +* [#5134](https://github.com/apache/incubator-nuttx/pull/#5134) boards: risc-v: hifive1-revb: Enable some nsh commands in nsh/defconfig  +* [#4675](https://github.com/apache/incubator-nuttx/pull/#4675) boards: risc-v: k210: Add initial gpio user space support  +* [#4665](https://github.com/apache/incubator-nuttx/pull/#4665) boards: risc-v: k210: Fix -march and -mabi  +* [#5067](https://github.com/apache/incubator-nuttx/pull/#5067) boards: risc-v: mpfs: update m100pfsevp board info  +* [#5688](https://github.com/apache/incubator-nuttx/pull/#5688) boards: risc-v: mpfs: MPFS USB driver  +* [#5111](https://github.com/apache/incubator-nuttx/pull/#5111) boards: risc-v: m100pfsevp: Decrease DDR lane temination values to 40 ohm and …  +* [#5500](https://github.com/apache/incubator-nuttx/pull/#5500) boards: risc-v: bl602: Remove -D__NuttX__ from Makefile  +* [#5515](https://github.com/apache/incubator-nuttx/pull/#5515) boards: risc-v: rv-virt: Supports FPU test and ostest in both rv32/rv64  + +#### SIM + +* [#5544](https://github.com/apache/incubator-nuttx/pull/#5544) boards: sim: Add missing options to sim:vncserver  +* [#5559](https://github.com/apache/incubator-nuttx/pull/#5559) boards: sim: Rename ARCHCPUFLAGS[XX] to ARCHC[XX]FLAGS  +* [#5739](https://github.com/apache/incubator-nuttx/pull/#5739) boards: sim: add support of custom optimization level  +* [#5186](https://github.com/apache/incubator-nuttx/pull/#5186) boards: sim: Turn on more rpmsg drivers in rpserver config  +* [#5101](https://github.com/apache/incubator-nuttx/pull/#5101) boards: sim: Remove sim_tsc_setup  +* [#5561](https://github.com/apache/incubator-nuttx/pull/#5561) boards: sim: defconfig for hello_rust  +* [#5535](https://github.com/apache/incubator-nuttx/pull/#5535) boards: sim: Enable Rust suppport for hello_rust application.  +* [#5640](https://github.com/apache/incubator-nuttx/pull/#5640) boards: sim: Remove CCLINKFLAGS, use CFLAGS/CXXFLAGS instead  +* [#5501](https://github.com/apache/incubator-nuttx/pull/#5501) boards: sim: Add adb config for test  +* [#5121](https://github.com/apache/incubator-nuttx/pull/#5121) boards: sim: recovered eth0 interface in sim:tcpblaster configuration  +* [#5383](https://github.com/apache/incubator-nuttx/pull/#5383) boards: sim: Make.defs: CELFFLAGS += -mcmodel=large  + +#### SPARC + +* [#5644](https://github.com/apache/incubator-nuttx/pull/#5644) boards: sparc: Remove HOSTCC related flags from Make.defs  + +#### XTENSA + +* [#4719](https://github.com/apache/incubator-nuttx/pull/#4719) boards: xtensa: esp32: Refactor SPI Flash File system mount options on menuconfig  +* [#5596](https://github.com/apache/incubator-nuttx/pull/#5596) boards: xtensa: esp32: Update esp-wireless-drivers-3rdparty  +* [#5074](https://github.com/apache/incubator-nuttx/pull/#5074) boards: xtensa: esp32: Add board support to SHT3X sensor  +* [#5051](https://github.com/apache/incubator-nuttx/pull/#5051) boards: xtensa: esp32: Enable canaries stack protection to ESP32 chips  +* [#5617](https://github.com/apache/incubator-nuttx/pull/#5617) boards: xtensa: esp32-devkitc: Fix boot failure on tickless defconfig  +* [#5654](https://github.com/apache/incubator-nuttx/pull/#5654) boards: xtensa: esp32-devkitc: Increase INIT_STACKSIZE to 3072 in smp/defconfig  +* [#5075](https://github.com/apache/incubator-nuttx/pull/#5075) boards: xtensa: esp32-devkitc: Change CONFIG_USER_ENTRYPOINT to CONFIG_INIT_ENTRYPOINT  + +## File System + +### Bug Fixes + +* [#4694](https://github.com/apache/incubator-nuttx/pull/#4694) fs: littlefs: fix rmdir can remove a file +* [#4722](https://github.com/apache/incubator-nuttx/pull/#4722) fs: mqueue: fix memory leak cause by lost inode_release  +* [#5214](https://github.com/apache/incubator-nuttx/pull/#5214) fs: partition: Fix compilation errors when CONFIG_FS_LARGEFIL…  +* [#5279](https://github.com/apache/incubator-nuttx/pull/#5279) fs: partition: Fix an overflow in blkcnt_t gpt_last_lba +* [#5653](https://github.com/apache/incubator-nuttx/pull/#5653) fs: romfs: fix read file mismatch when the length of file name is 16  +* [#5257](https://github.com/apache/incubator-nuttx/pull/#5257) fs: smartfs: Fix file size corruption when opening with truncate mode  +* [#4811](https://github.com/apache/incubator-nuttx/pull/#4811) fs: procfs: fix ps can't log out Group id  +* [#5172](https://github.com/apache/incubator-nuttx/pull/#5172) fs: procfs: fix readdir loss last character +* [#4968](https://github.com/apache/incubator-nuttx/pull/#4968) fs: fat: Use uint16_t instead of wchar_t  + +### Significant Improvements + +* [#5108](https://github.com/apache/incubator-nuttx/pull/#5108) fs: change fs strncpy to strlcpy to avoid losing'\0'  +* [#5460](https://github.com/apache/incubator-nuttx/pull/#5460) fs: epoll_fd: support dup file descriptor +* [#5345](https://github.com/apache/incubator-nuttx/pull/#5345) fs: fs_automount: add options for signaling when volume is mounted and unmounted  +* [#4934](https://github.com/apache/incubator-nuttx/pull/#4934) fs: hosfs_rpmsg: merge hostfs_rpmsg to rpmsgfs  +* [#4986](https://github.com/apache/incubator-nuttx/pull/#4986) fs: hostfs: add lock to hostfs_rewinddir  +* [#4718](https://github.com/apache/incubator-nuttx/pull/#4718) fs: mount: Properly handle missing FS on the supported list  +* [#4721](https://github.com/apache/incubator-nuttx/pull/#4721) fs: mqueue: Change MAX_MQUEUE_PATH to 64  +* [#4734](https://github.com/apache/incubator-nuttx/pull/#4734) fs: partition: support mbr and gpt partition parsing  +* [#4687](https://github.com/apache/incubator-nuttx/pull/#4687) fs: partition: Make read_partition_block callable outside ptable  +* [#5207](https://github.com/apache/incubator-nuttx/pull/#5207) fs: procfs: Remove the unnecessary strcmp  +* [#5554](https://github.com/apache/incubator-nuttx/pull/#5554) fs: procfs: add newline /proc/*/loadavg snprintf format  +* [#5157](https://github.com/apache/incubator-nuttx/pull/#5157) fs: romfs: remove the error single list and using reference  +* [#5461](https://github.com/apache/incubator-nuttx/pull/#5461) fs: romfs: add FAR for all pointer and optimize some code  +* [#5635](https://github.com/apache/incubator-nuttx/pull/#5635) fs: romfs: optimize romfs_open speed and get path by cmd FIOC_FILEPATH  +* [#5022](https://github.com/apache/incubator-nuttx/pull/#5022) fs: tmpfs: support fsync always successful  +* [#5014](https://github.com/apache/incubator-nuttx/pull/#5014) fs: vfs: Add file descriptor based timers support  +* [#5028](https://github.com/apache/incubator-nuttx/pull/#5028) fs: vfs: eventfd: Remove the unused and private eventfd_get_minor  +* [#5224](https://github.com/apache/incubator-nuttx/pull/#5224) fs: vfs: Do not require write-access for fsync  +* [#4767](https://github.com/apache/incubator-nuttx/pull/#4767) fs: vfs: sanity check for parameter:length  + +## Networking + +### Improvements + +* [#5254](https://github.com/apache/incubator-nuttx/pull/#5254) net: unify FAR keyword usage for all net buffer memory mapped buffers  +* [#5049](https://github.com/apache/incubator-nuttx/pull/#5049) net: Update IFF_RUNNING flag by netdev_carrier_on and netdev_carrier_off  +* [#4895](https://github.com/apache/incubator-nuttx/pull/#4895) net: arp: clean the arp table when netdev carrier off  +* [#5168](https://github.com/apache/incubator-nuttx/pull/#5168) net: can: add CAN error definitions  +* [#4814](https://github.com/apache/incubator-nuttx/pull/#4814) net: can: can_recvmsg.c : put can_readahead in critical section  +* [#5467](https://github.com/apache/incubator-nuttx/pull/#5467) net: can: remove psock reference from can connect  +* [#5110](https://github.com/apache/incubator-nuttx/pull/#5110) net: devif: allocate devif callback dynamically  +* [#5181](https://github.com/apache/incubator-nuttx/pull/#5181) net: devif: devif_callback_free() call is not needed anymore in devif_callback_alloc()  +* [#5136](https://github.com/apache/incubator-nuttx/pull/#5136) net: icmp: post the semaphore if multiple references  +* [#5525](https://github.com/apache/incubator-nuttx/pull/#5525) net: ioballoc: add support of alloc with timeout net_iobtimedalloc()  +* [#5426](https://github.com/apache/incubator-nuttx/pull/#5426) net: local: Rename NET_LOCAL_PATH_PREFIX to NET_LOCAL_VFS_PATH  +* [#4987](https://github.com/apache/incubator-nuttx/pull/#4987) net: local_socket: filename use "/var/socket/xx" instead of "/var/socketxx"  +* [#5150](https://github.com/apache/incubator-nuttx/pull/#5150) net: misc: add support for CONFIG_NET_ALLOC_CONNS  +* [#5725](https://github.com/apache/incubator-nuttx/pull/#5725) net: optimize network subsystem initialization  +* [#4973](https://github.com/apache/incubator-nuttx/pull/#4973) net: rpmsg: add ioctl & fix unblock connect crash  +* [#4760](https://github.com/apache/incubator-nuttx/pull/#4760) net: socket: rpmsg related bug fix & update  +* [#5337](https://github.com/apache/incubator-nuttx/pull/#5337) net: tcbinfo: Update tcbinfo struct, Fix the compile warning  +* [#5526](https://github.com/apache/incubator-nuttx/pull/#5526) net: tcp: add support for send timeout on buffer mode  +* [#5373](https://github.com/apache/incubator-nuttx/pull/#5373) net: tcp: add debug asserts and logging to investigate the rare (conn->dev == NULL) bug in callback handlers  +* [#5462](https://github.com/apache/incubator-nuttx/pull/#5462) net: tcp: monitor: do not migrate the state to close  +* [#5405](https://github.com/apache/incubator-nuttx/pull/#5405) net: tcp: netdev/mld: correct the netlock handling  +* [#4660](https://github.com/apache/incubator-nuttx/pull/#4660) net: tcp: Remove NET_TCP_SPLIT  +* [#5469](https://github.com/apache/incubator-nuttx/pull/#5469) net: tcp: support for FIN+ACK case in tcp send event handlers  +* [#5341](https://github.com/apache/incubator-nuttx/pull/#5341) net: tcp: transformed NET_TCP_FAST_RETRANSMIT_WATERMARK option to boolean.  +* [#5434](https://github.com/apache/incubator-nuttx/pull/#5434) net: tcp: udp: remove psock hook to avoid invalid reference  +* [#5339](https://github.com/apache/incubator-nuttx/pull/#5339) net: tcp/tcp_sendfile: optimized out sendfile_txnotify() function  +* [#5252](https://github.com/apache/incubator-nuttx/pull/#5252) net: tcp/tcp_send*: reliably obtain the TCP connection pointer in TCP event handlers  +* [#5268](https://github.com/apache/incubator-nuttx/pull/#5268) net: tcp/tcp_send*: added debug asserts for TCP_ACKDATA, TCP_REXMIT and TCP_DISCONN_EVENTS flags  +* [#5262](https://github.com/apache/incubator-nuttx/pull/#5262) net: tcp/sendfile: swapped the location of TCP_DISCONN_EVENTS and TCP_ACKDATA conditions  +* [#5340](https://github.com/apache/incubator-nuttx/pull/#5340) net: tcp/sendfile: notify the device driver of the availability of TX data on TCP retransmission  +* [#5311](https://github.com/apache/incubator-nuttx/pull/#5311) net: tcp/sendfile: fast retransmit on duplicate acknowledgments (RFC 5681)  +* [#5242](https://github.com/apache/incubator-nuttx/pull/#5242) net: tcp/sendfile: TCP retransmission could not start because of incorrect snd_ackcb callback handling  +* [#5104](https://github.com/apache/incubator-nuttx/pull/#5104) net: tcp/udp: allocate tcp/udp connect dynamically  +* [#5156](https://github.com/apache/incubator-nuttx/pull/#5156) net: usrsock: add support for CONFIG_NET_ALLOC_CONNS  +* [#5045](https://github.com/apache/incubator-nuttx/pull/#5045) net: usrsock: increase the sendto() length limit to UINT32_MAX  + +### Bug Fixes + +* [#5480](https://github.com/apache/incubator-nuttx/pull/#5480) net: can: can_setsockopt.c: fix assertion, value can be NULL  +* [#5141](https://github.com/apache/incubator-nuttx/pull/#5141) net: can: SocketCAN: minor fixes  +* [#4575](https://github.com/apache/incubator-nuttx/pull/#4575) net: devif: Fix the memory leak in case of netdev isn't alive  +* [#5437](https://github.com/apache/incubator-nuttx/pull/#5437) net: devif: remove invalid NET_IPv4_REASSEMBLY definition   +* [#5090](https://github.com/apache/incubator-nuttx/pull/#5090) net: fix unaligned memory access when creating ICMP Port Unreachable messages  +* [#5245](https://github.com/apache/incubator-nuttx/pull/#5245) net: icmp: fix build break if enable NET_ALLOC_CONNS  +* [#4761](https://github.com/apache/incubator-nuttx/pull/#4761) net: local: socket bug fix & update  +* [#5436](https://github.com/apache/incubator-nuttx/pull/#5436) net: netdev: lladdrsize: remove invalid duplicate case  +* [#5466](https://github.com/apache/incubator-nuttx/pull/#5466) net: rpmsg: fix the NULL pointer reference on nonblock accept  +* [#5531](https://github.com/apache/incubator-nuttx/pull/#5531) net: socket: fix shadow variable  +* [#5006](https://github.com/apache/incubator-nuttx/pull/#5006) net: tcp: fix send deadlock if disconnect  +* [#5296](https://github.com/apache/incubator-nuttx/pull/#5296) net: tcp: fixed warning: ISO C90 forbids mixed declarations and code  +* [#4639](https://github.com/apache/incubator-nuttx/pull/#4639) net: tcp_timer: eliminated false decrements of conn->timer in case of multiple network adapters.  +* [#4659](https://github.com/apache/incubator-nuttx/pull/#4659) net: tcp(unbuffered): retransmit only one the earliest not acknowledged segment  +* [#4656](https://github.com/apache/incubator-nuttx/pull/#4656) net: tcp(unbuffered): fixed an issue with unackseq calculation.  +* [#5138](https://github.com/apache/incubator-nuttx/pull/#5138) net: tcp(unbuffered): advance sndseq by +1 because SYN and FIN occupy one sequence number  +* [#5137](https://github.com/apache/incubator-nuttx/pull/#5137) net: tcp(unbuffered): fast retransmit on duplicate acknowledgments  +* [#5078](https://github.com/apache/incubator-nuttx/pull/#5078) net: tcp(unbuffered): tx_unacked overflow occurred if NET_TCP_WINDOW_SCALE option was enabled.  +* [#5102](https://github.com/apache/incubator-nuttx/pull/#5102) net: tcp(unbuffered): removed excessive overwrites of conn->sndseq  +* [#5297](https://github.com/apache/incubator-nuttx/pull/#5297) net: tcp/sendfile: removed excessive overwrites of conn->sndseq  +* [#5239](https://github.com/apache/incubator-nuttx/pull/#5239) net: tcp/sendfile: NET_TCP_WRITE_BUFFERS and NET_SENDFILE were inconsistent with each other  +* [#5293](https://github.com/apache/incubator-nuttx/pull/#5293) net: tcp/sendfile: fixed an issue with unackseq calculation.  +* [#5272](https://github.com/apache/incubator-nuttx/pull/#5272) net: tcp/sendfile: retransmit only one the earliest not acknowledged segment  +* [#5013](https://github.com/apache/incubator-nuttx/pull/#5013) net: udp: fix the invaild udp destination address  +* [#4890](https://github.com/apache/incubator-nuttx/pull/#4890) net: udp/icmp: correct the unreadchable handling  +* [#5154](https://github.com/apache/incubator-nuttx/pull/#5154) net: usrsock: replace xid type to uint64_t to avoid limitation of connections  + +## Security Issues Fixed In This Release + +Compatibility Concerns +Renamed Kconfigs + +PR-5065 has renamed the following Kconfigs: + +CONFIG_USER_ENTRYPOINT -> CONFIG_INIT_ENTRYPOINT +CONFIG_USERMAIN_STACKSIZE -> CONFIG_INIT_STACKSIZE + +These are the non-"CONFIG_"-prefixed names: + +USER_ENTRYPOINT -> INIT_ENTRYPOINT +USERMAIN_STACKSIZE -> INIT_STACKSIZE + +All in-tree boards have been updated. + +NuttX users developing their own out-of-tree boards need to update all references to the above names as well. + +See PR-5065, git commits 4bc7b8c802cd42bd2c3d98f4fd11207d2dd50de4, 632716dc7ad04f7cad48c5787f5c0b500cbee296, and 036d98a06ba873318061380b876b838f7ffa64fb. + +Changes to Build System + +PR-5496 has refactored the separate Unix and Windows handling of the build variable ARCHSCRIPT so that each board's Make.defs will not need logic like this: + +ifeq ($(CONFIG_CYGWIN_WINTOOL),y) +  ARCHSCRIPT = -T "${shell cygpath -w $(BOARD_DIR)$(DELIM)scripts$(DELIM)tfm-ns.ld}" +else +  ARCHSCRIPT = -T$(BOARD_DIR)$(DELIM)scripts$(DELIM)tfm-ns.ld +endif + +And can instead append the variable just one, like this: + +ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)tfm-ns.ld + +Note the assignment is changed to append (from "=" to "+=") and removal of "-T". + +All boards in the NuttX tree have been updated. + +NuttX users developing their own custom boards will need to update their board's scripts/Make.defs file as shown above. + +See PR-5496, git commit 855534deef50e1e9c957eb32a7b15497d1bfd34a. + + + + +PR-5712 has refactored board common logic. BOARD_SAMV7_COMMON and BOARD_STM32_COMMON options are removed and a new ARCH_BOARD_COMMON is introduced. + +All in-tree boards have been updated. + +NuttX users developing their own out-of-tree boards need to replace "CONFIG_BOARD_SAMV7_COMMON=y" and "CONFIG_BOARD_STM32_COMMON=y" to "CONFIG_ARCH_BOARD_COMMON=y" in defconfig files. Also for some out-of-tree boards the compilation may fail with next error messages: + +make[2]: *** No rule to make target 'libboard.a'.  Stop. +Makefile:139: recipe for target 'board/libboard.a' failed +make[1]: *** [board/libboard.a] Error 2 +tools/Unix.mk:509: recipe for target 'nuttx' failed + +In this case the out-of-tree board actually relies on in-tree boards common folder structure. To overcome the build error there are two possible options: + +Add "CONFIG_ARCH_BOARD_COMMON=y" to defconfig file (this will restore parity with previous NuttX release) +Rename "src/Make.defs" → "src/Makefile" in out-of-tree board directory and append "include $(TOPDIR)/boards/Board.mk" to "src/Makefile". +Refactored Arch Headers + +PR-5720 has refactored architectural headers affecting all ARM platforms: arm_arch.h has been removed and its contents merged into arm_internal.h. Previously, most low-level modules in arch/arm/* and boards/arm/* needed to include both headers. Following the refactor, only arm_internal.h is needed. + +All boards in the NuttX tree have been updated. + +NuttX users developing their own custom boards will need to remove any #include "arm_arch.h" and (if necessary), #include "arm_internal.h" instead. + +See PR-5720, git commit 54e630e14d7e32d6f81ae79d4e5df3d2fa787ef0. diff --git a/arch/Kconfig b/arch/Kconfig index bd5d0803bd666..49b9332611fc9 100644 --- a/arch/Kconfig +++ b/arch/Kconfig @@ -64,6 +64,7 @@ config ARCH_RISCV select ARCH_HAVE_BACKTRACE select ARCH_HAVE_INTERRUPTSTACK select ARCH_HAVE_STACKCHECK + select ARCH_HAVE_VFORK select ARCH_HAVE_CUSTOMOPT select ARCH_HAVE_SETJMP select ARCH_HAVE_STDARG_H @@ -222,6 +223,49 @@ config ARCH_TOOLCHAIN_GNU bool default n +config ARCH_TOOLCHAIN_CLANG + bool + select ARCH_TOOLCHAIN_GNU + default n + +choice + prompt "Link Time Optimization (LTO)" + default LTO_NONE + ---help--- + This option enables Link Time Optimization (LTO), which allows the + compiler to optimize binaries globally. + + If unsure, select LTO_NONE. Note that LTO is very resource-intensive + so it's disabled by default. + +config LTO_NONE + bool "None" + ---help--- + Build the kernel normally, without Link Time Optimization (LTO). + +config LTO_FULL + bool "GNU Full LTO (EXPERIMENTAL)" + depends on ARCH_TOOLCHAIN_GNU + ---help--- + Link time optimization is implemented as a GCC front end for a bytecode + bytecode representation of GIMPLE that is emitted in special sections + of .o files. Currently, LTO support is enabled in most ELF-based systems, + as well as darwin, cygwin and mingw systems. + +config LTO_THIN + bool "Clang ThinLTO (EXPERIMENTAL)" + depends on ARCH_TOOLCHAIN_CLANG + ---help--- + This option enables Clang's ThinLTO, which allows for parallel + optimization and faster incremental compiles compared to the + CONFIG_LTO_FULL option. More information can be found + from Clang's documentation: + + https://clang.llvm.org/docs/ThinLTO.html + + If unsure, say Y. +endchoice + config ARCH_GNU_NO_WEAKFUNCTIONS bool depends on ARCH_TOOLCHAIN_GNU @@ -327,9 +371,6 @@ config ARCH_HAVE_DPFPU default n select ARCH_HAVE_FPU -config ARCH_HAVE_LAZYFPU - bool - config ARCH_HAVE_MMU bool default n @@ -781,6 +822,13 @@ config ARCH_STACKDUMP ---help--- Enable to do stack dumps after assertions +config DUMP_ON_EXIT + bool "Dump all tasks state on exit" + default n + depends on DEBUG_SCHED_INFO + ---help--- + Dump all tasks state on exit() + config ARCH_USBDUMP bool "Dump USB trace data" default n @@ -932,13 +980,6 @@ config SUPPRESS_UART_CONFIG This is useful when a boot loader has already initialized the serial port. -config DUMP_ON_EXIT - bool "Dump task state" - default n - depends on DEBUG_SCHED_INFO - ---help--- - Dump task state on exit() - endmenu # Bring-Up Options comment "Board Settings" diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index ef0b98cea2cd0..653d063920393 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig @@ -607,7 +607,6 @@ config ARCH_CORTEXM3 select ARCH_HAVE_IRQPRIO select ARCH_HAVE_IRQTRIGGER select ARCH_HAVE_RAMVECTORS - select ARCH_HAVE_LAZYFPU select ARCH_HAVE_HIPRI_INTERRUPT select ARCH_HAVE_RESET select ARCH_HAVE_TESTSET @@ -624,7 +623,6 @@ config ARCH_CORTEXM4 select ARCH_HAVE_IRQPRIO select ARCH_HAVE_IRQTRIGGER select ARCH_HAVE_RAMVECTORS - select ARCH_HAVE_LAZYFPU select ARCH_HAVE_HIPRI_INTERRUPT select ARCH_HAVE_RESET select ARCH_HAVE_TESTSET @@ -642,7 +640,6 @@ config ARCH_CORTEXM7 select ARCH_HAVE_IRQPRIO select ARCH_HAVE_IRQTRIGGER select ARCH_HAVE_RAMVECTORS - select ARCH_HAVE_LAZYFPU select ARCH_HAVE_HIPRI_INTERRUPT select ARCH_HAVE_RESET select ARCH_HAVE_TESTSET @@ -739,7 +736,6 @@ config ARCH_CORTEXM23 select ARCH_HAVE_IRQPRIO select ARCH_HAVE_IRQTRIGGER select ARCH_HAVE_RAMVECTORS - select ARCH_HAVE_LAZYFPU select ARCH_HAVE_HIPRI_INTERRUPT select ARCH_HAVE_RESET select ARCH_HAVE_TESTSET @@ -753,7 +749,6 @@ config ARCH_CORTEXM33 select ARCH_HAVE_IRQPRIO select ARCH_HAVE_IRQTRIGGER select ARCH_HAVE_RAMVECTORS - select ARCH_HAVE_LAZYFPU select ARCH_HAVE_HIPRI_INTERRUPT select ARCH_HAVE_RESET select ARCH_HAVE_TESTSET @@ -771,7 +766,6 @@ config ARCH_CORTEXM35P select ARCH_HAVE_IRQPRIO select ARCH_HAVE_IRQTRIGGER select ARCH_HAVE_RAMVECTORS - select ARCH_HAVE_LAZYFPU select ARCH_HAVE_HIPRI_INTERRUPT select ARCH_HAVE_RESET select ARCH_HAVE_TESTSET @@ -789,7 +783,6 @@ config ARCH_CORTEXM55 select ARCH_HAVE_IRQPRIO select ARCH_HAVE_IRQTRIGGER select ARCH_HAVE_RAMVECTORS - select ARCH_HAVE_LAZYFPU select ARCH_HAVE_HIPRI_INTERRUPT select ARCH_HAVE_RESET select ARCH_HAVE_TESTSET diff --git a/arch/arm/include/arch.h b/arch/arm/include/arch.h index 42607cb5c381f..031c138707710 100644 --- a/arch/arm/include/arch.h +++ b/arch/arm/include/arch.h @@ -40,6 +40,8 @@ * Pre-processor Prototypes ****************************************************************************/ +#define up_getsp() (uintptr_t)__builtin_frame_address(0) + #ifdef CONFIG_PIC /* This identifies the register the is used by the processor as the PIC base @@ -63,7 +65,7 @@ do { \ "\tmov %0, " PIC_REG_STRING "\n\t" \ : "=r"(picbase) \ ); \ - *ppicbase = (FAR void*)picbase; \ + *ppicbase = (void *)picbase; \ } while (0) #define up_setpicbase(picbase) \ @@ -108,24 +110,6 @@ do { \ * Inline functions ****************************************************************************/ -/**************************************************************************** - * Name: up_getsp - ****************************************************************************/ - -/* I don't know if the builtin to get SP is enabled */ - -static inline uint32_t up_getsp(void) -{ - uint32_t sp; - __asm__ - ( - "\tmov %0, sp\n\t" - : "=r"(sp) - ); - - return sp; -} - /**************************************************************************** * Public Types ****************************************************************************/ @@ -145,12 +129,12 @@ struct group_addrenv_s { /* Level 1 page table entries for each group section */ - FAR uintptr_t *text[ARCH_TEXT_NSECTS]; - FAR uintptr_t *data[ARCH_DATA_NSECTS]; + uintptr_t *text[ARCH_TEXT_NSECTS]; + uintptr_t *data[ARCH_DATA_NSECTS]; #ifdef CONFIG_BUILD_KERNEL - FAR uintptr_t *heap[ARCH_HEAP_NSECTS]; + uintptr_t *heap[ARCH_HEAP_NSECTS]; #ifdef CONFIG_MM_SHM - FAR uintptr_t *shm[ARCH_SHM_NSECTS]; + uintptr_t *shm[ARCH_SHM_NSECTS]; #endif /* Initial heap allocation (in bytes). This exists only provide an @@ -176,12 +160,12 @@ typedef struct group_addrenv_s group_addrenv_t; struct save_addrenv_s { - FAR uint32_t text[ARCH_TEXT_NSECTS]; - FAR uint32_t data[ARCH_DATA_NSECTS]; + uint32_t text[ARCH_TEXT_NSECTS]; + uint32_t data[ARCH_DATA_NSECTS]; #ifdef CONFIG_BUILD_KERNEL - FAR uint32_t heap[ARCH_HEAP_NSECTS]; + uint32_t heap[ARCH_HEAP_NSECTS]; #ifdef CONFIG_MM_SHM - FAR uint32_t shm[ARCH_SHM_NSECTS]; + uint32_t shm[ARCH_SHM_NSECTS]; #endif #endif }; diff --git a/arch/arm/include/armv7-a/irq.h b/arch/arm/include/armv7-a/irq.h index 57b03ee261a43..e89d4d095caa4 100644 --- a/arch/arm/include/armv7-a/irq.h +++ b/arch/arm/include/armv7-a/irq.h @@ -295,7 +295,7 @@ struct xcptcontext * handling to support dynamically sized stacks for each thread. */ - FAR uintptr_t *ustack[ARCH_STACK_NSECTS]; + uintptr_t *ustack[ARCH_STACK_NSECTS]; #endif #ifdef CONFIG_ARCH_KERNEL_STACK @@ -307,9 +307,9 @@ struct xcptcontext * stack in place. */ - FAR uint32_t *ustkptr; /* Saved user stack pointer */ - FAR uint32_t *kstack; /* Allocate base of the (aligned) kernel stack */ - FAR uint32_t *kstkptr; /* Saved kernel stack pointer */ + uint32_t *ustkptr; /* Saved user stack pointer */ + uint32_t *kstack; /* Allocate base of the (aligned) kernel stack */ + uint32_t *kstkptr; /* Saved kernel stack pointer */ #endif #endif }; diff --git a/arch/arm/include/armv7-m/irq.h b/arch/arm/include/armv7-m/irq.h index e965fc7ab1dcf..6219bb888b296 100644 --- a/arch/arm/include/armv7-m/irq.h +++ b/arch/arm/include/armv7-m/irq.h @@ -38,14 +38,6 @@ # include #endif -/* Included implementation-dependent register save structure layouts */ - -#ifndef CONFIG_ARMV7M_LAZYFPU -# include -#else -# include -#endif - /**************************************************************************** * Pre-processor Prototypes ****************************************************************************/ @@ -60,6 +52,110 @@ # define CONFIG_SYS_NNEST 2 #endif +/* IRQ Stack Frame Format: */ + +/* The following additional registers are stored by the interrupt handling + * logic. + */ + +#define REG_R13 (0) /* R13 = SP at time of interrupt */ +#ifdef CONFIG_ARMV7M_USEBASEPRI +# define REG_BASEPRI (1) /* BASEPRI */ +#else +# define REG_PRIMASK (1) /* PRIMASK */ +#endif +#define REG_R4 (2) /* R4 */ +#define REG_R5 (3) /* R5 */ +#define REG_R6 (4) /* R6 */ +#define REG_R7 (5) /* R7 */ +#define REG_R8 (6) /* R8 */ +#define REG_R9 (7) /* R9 */ +#define REG_R10 (8) /* R10 */ +#define REG_R11 (9) /* R11 */ +#define REG_EXC_RETURN (10) /* EXC_RETURN */ +#define SW_INT_REGS (11) + +#ifdef CONFIG_ARCH_FPU + +/* If the MCU supports a floating point unit, then it will be necessary + * to save the state of the non-volatile registers before calling code + * that may save and overwrite them. + */ + +# define REG_S16 (SW_INT_REGS + 0) /* S16 */ +# define REG_S17 (SW_INT_REGS + 1) /* S17 */ +# define REG_S18 (SW_INT_REGS + 2) /* S18 */ +# define REG_S19 (SW_INT_REGS + 3) /* S19 */ +# define REG_S20 (SW_INT_REGS + 4) /* S20 */ +# define REG_S21 (SW_INT_REGS + 5) /* S21 */ +# define REG_S22 (SW_INT_REGS + 6) /* S22 */ +# define REG_S23 (SW_INT_REGS + 7) /* S23 */ +# define REG_S24 (SW_INT_REGS + 8) /* S24 */ +# define REG_S25 (SW_INT_REGS + 9) /* S25 */ +# define REG_S26 (SW_INT_REGS + 10) /* S26 */ +# define REG_S27 (SW_INT_REGS + 11) /* S27 */ +# define REG_S28 (SW_INT_REGS + 12) /* S28 */ +# define REG_S29 (SW_INT_REGS + 13) /* S29 */ +# define REG_S30 (SW_INT_REGS + 14) /* S30 */ +# define REG_S31 (SW_INT_REGS + 15) /* S31 */ +# define SW_FPU_REGS (16) +#else +# define SW_FPU_REGS (0) +#endif + +/* The total number of registers saved by software */ + +#define SW_XCPT_REGS (SW_INT_REGS + SW_FPU_REGS) +#define SW_XCPT_SIZE (4 * SW_XCPT_REGS) + +/* On entry into an IRQ, the hardware automatically saves the following + * registers on the stack in this (address) order: + */ + +#define REG_R0 (SW_XCPT_REGS + 0) /* R0 */ +#define REG_R1 (SW_XCPT_REGS + 1) /* R1 */ +#define REG_R2 (SW_XCPT_REGS + 2) /* R2 */ +#define REG_R3 (SW_XCPT_REGS + 3) /* R3 */ +#define REG_R12 (SW_XCPT_REGS + 4) /* R12 */ +#define REG_R14 (SW_XCPT_REGS + 5) /* R14 = LR */ +#define REG_R15 (SW_XCPT_REGS + 6) /* R15 = PC */ +#define REG_XPSR (SW_XCPT_REGS + 7) /* xPSR */ +#define HW_INT_REGS (8) + +#ifdef CONFIG_ARCH_FPU + +/* If the FPU is enabled, the hardware also saves the volatile FP registers. + */ + +# define REG_S0 (SW_XCPT_REGS + 8) /* S0 */ +# define REG_S1 (SW_XCPT_REGS + 9) /* S1 */ +# define REG_S2 (SW_XCPT_REGS + 10) /* S2 */ +# define REG_S3 (SW_XCPT_REGS + 11) /* S3 */ +# define REG_S4 (SW_XCPT_REGS + 12) /* S4 */ +# define REG_S5 (SW_XCPT_REGS + 13) /* S5 */ +# define REG_S6 (SW_XCPT_REGS + 14) /* S6 */ +# define REG_S7 (SW_XCPT_REGS + 15) /* S7 */ +# define REG_S8 (SW_XCPT_REGS + 16) /* S8 */ +# define REG_S9 (SW_XCPT_REGS + 17) /* S9 */ +# define REG_S10 (SW_XCPT_REGS + 18) /* S10 */ +# define REG_S11 (SW_XCPT_REGS + 19) /* S11 */ +# define REG_S12 (SW_XCPT_REGS + 20) /* S12 */ +# define REG_S13 (SW_XCPT_REGS + 21) /* S13 */ +# define REG_S14 (SW_XCPT_REGS + 22) /* S14 */ +# define REG_S15 (SW_XCPT_REGS + 23) /* S15 */ +# define REG_FPSCR (SW_XCPT_REGS + 24) /* FPSCR */ +# define REG_FP_RESERVED (SW_XCPT_REGS + 25) /* Reserved */ +# define HW_FPU_REGS (18) +#else +# define HW_FPU_REGS (0) +#endif + +#define HW_XCPT_REGS (HW_INT_REGS + HW_FPU_REGS) +#define HW_XCPT_SIZE (4 * HW_XCPT_REGS) + +#define XCPTCONTEXT_REGS (HW_XCPT_REGS + SW_XCPT_REGS) +#define XCPTCONTEXT_SIZE (4 * XCPTCONTEXT_REGS) + /* Alternate register names *************************************************/ #define REG_A1 REG_R0 @@ -118,7 +214,7 @@ struct xcptcontext * are pending signals to be processed. */ - FAR void *sigdeliver; /* Actual type is sig_deliver_t */ + void *sigdeliver; /* Actual type is sig_deliver_t */ /* These are saved copies of the context used during * signal processing. diff --git a/arch/arm/include/armv7-m/irq_cmnvector.h b/arch/arm/include/armv7-m/irq_cmnvector.h deleted file mode 100644 index 93b38357396c3..0000000000000 --- a/arch/arm/include/armv7-m/irq_cmnvector.h +++ /dev/null @@ -1,152 +0,0 @@ -/**************************************************************************** - * arch/arm/include/armv7-m/irq_cmnvector.h - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. The - * ASF licenses this file to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance with the - * License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - ****************************************************************************/ - -#ifndef __ARCH_ARM_INCLUDE_ARMV7_M_IRQ_CMNVECTOR_H -#define __ARCH_ARM_INCLUDE_ARMV7_M_IRQ_CMNVECTOR_H - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -/**************************************************************************** - * Pre-processor Prototypes - ****************************************************************************/ - -/* IRQ Stack Frame Format: */ - -/* The following additional registers are stored by the interrupt handling - * logic. - */ - -#define REG_R13 (0) /* R13 = SP at time of interrupt */ -#ifdef CONFIG_ARMV7M_USEBASEPRI -# define REG_BASEPRI (1) /* BASEPRI */ -#else -# define REG_PRIMASK (1) /* PRIMASK */ -#endif -#define REG_R4 (2) /* R4 */ -#define REG_R5 (3) /* R5 */ -#define REG_R6 (4) /* R6 */ -#define REG_R7 (5) /* R7 */ -#define REG_R8 (6) /* R8 */ -#define REG_R9 (7) /* R9 */ -#define REG_R10 (8) /* R10 */ -#define REG_R11 (9) /* R11 */ -#define REG_EXC_RETURN (10) /* EXC_RETURN */ -#define SW_INT_REGS (11) - -#ifdef CONFIG_ARCH_FPU - -/* If the MCU supports a floating point unit, then it will be necessary - * to save the state of the non-volatile registers before calling code - * that may save and overwrite them. - */ - -# define REG_S16 (SW_INT_REGS + 0) /* S16 */ -# define REG_S17 (SW_INT_REGS + 1) /* S17 */ -# define REG_S18 (SW_INT_REGS + 2) /* S18 */ -# define REG_S19 (SW_INT_REGS + 3) /* S19 */ -# define REG_S20 (SW_INT_REGS + 4) /* S20 */ -# define REG_S21 (SW_INT_REGS + 5) /* S21 */ -# define REG_S22 (SW_INT_REGS + 6) /* S22 */ -# define REG_S23 (SW_INT_REGS + 7) /* S23 */ -# define REG_S24 (SW_INT_REGS + 8) /* S24 */ -# define REG_S25 (SW_INT_REGS + 9) /* S25 */ -# define REG_S26 (SW_INT_REGS + 10) /* S26 */ -# define REG_S27 (SW_INT_REGS + 11) /* S27 */ -# define REG_S28 (SW_INT_REGS + 12) /* S28 */ -# define REG_S29 (SW_INT_REGS + 13) /* S29 */ -# define REG_S30 (SW_INT_REGS + 14) /* S30 */ -# define REG_S31 (SW_INT_REGS + 15) /* S31 */ -# define SW_FPU_REGS (16) -#else -# define SW_FPU_REGS (0) -#endif - -/* The total number of registers saved by software */ - -#define SW_XCPT_REGS (SW_INT_REGS + SW_FPU_REGS) -#define SW_XCPT_SIZE (4 * SW_XCPT_REGS) - -/* On entry into an IRQ, the hardware automatically saves the following - * registers on the stack in this (address) order: - */ - -#define REG_R0 (SW_XCPT_REGS + 0) /* R0 */ -#define REG_R1 (SW_XCPT_REGS + 1) /* R1 */ -#define REG_R2 (SW_XCPT_REGS + 2) /* R2 */ -#define REG_R3 (SW_XCPT_REGS + 3) /* R3 */ -#define REG_R12 (SW_XCPT_REGS + 4) /* R12 */ -#define REG_R14 (SW_XCPT_REGS + 5) /* R14 = LR */ -#define REG_R15 (SW_XCPT_REGS + 6) /* R15 = PC */ -#define REG_XPSR (SW_XCPT_REGS + 7) /* xPSR */ -#define HW_INT_REGS (8) - -#ifdef CONFIG_ARCH_FPU - -/* If the FPU is enabled, the hardware also saves the volatile FP registers. - */ - -# define REG_S0 (SW_XCPT_REGS + 8) /* S0 */ -# define REG_S1 (SW_XCPT_REGS + 9) /* S1 */ -# define REG_S2 (SW_XCPT_REGS + 10) /* S2 */ -# define REG_S3 (SW_XCPT_REGS + 11) /* S3 */ -# define REG_S4 (SW_XCPT_REGS + 12) /* S4 */ -# define REG_S5 (SW_XCPT_REGS + 13) /* S5 */ -# define REG_S6 (SW_XCPT_REGS + 14) /* S6 */ -# define REG_S7 (SW_XCPT_REGS + 15) /* S7 */ -# define REG_S8 (SW_XCPT_REGS + 16) /* S8 */ -# define REG_S9 (SW_XCPT_REGS + 17) /* S9 */ -# define REG_S10 (SW_XCPT_REGS + 18) /* S10 */ -# define REG_S11 (SW_XCPT_REGS + 19) /* S11 */ -# define REG_S12 (SW_XCPT_REGS + 20) /* S12 */ -# define REG_S13 (SW_XCPT_REGS + 21) /* S13 */ -# define REG_S14 (SW_XCPT_REGS + 22) /* S14 */ -# define REG_S15 (SW_XCPT_REGS + 23) /* S15 */ -# define REG_FPSCR (SW_XCPT_REGS + 24) /* FPSCR */ -# define REG_FP_RESERVED (SW_XCPT_REGS + 25) /* Reserved */ -# define HW_FPU_REGS (18) -#else -# define HW_FPU_REGS (0) -#endif - -#define HW_XCPT_REGS (HW_INT_REGS + HW_FPU_REGS) -#define HW_XCPT_SIZE (4 * HW_XCPT_REGS) - -#define XCPTCONTEXT_REGS (HW_XCPT_REGS + SW_XCPT_REGS) -#define XCPTCONTEXT_SIZE (4 * XCPTCONTEXT_REGS) - -/**************************************************************************** - * Public Types - ****************************************************************************/ - -/**************************************************************************** - * Inline functions - ****************************************************************************/ - -/**************************************************************************** - * Public Data - ****************************************************************************/ - -/**************************************************************************** - * Public Function Prototypes - ****************************************************************************/ - -#endif /* __ARCH_ARM_INCLUDE_ARMV7_M_IRQ_CMNVECTOR_H */ diff --git a/arch/arm/include/armv7-m/irq_lazyfpu.h b/arch/arm/include/armv7-m/irq_lazyfpu.h deleted file mode 100644 index d632d4c8a260a..0000000000000 --- a/arch/arm/include/armv7-m/irq_lazyfpu.h +++ /dev/null @@ -1,170 +0,0 @@ -/**************************************************************************** - * arch/arm/include/armv7-m/irq_lazyfpu.h - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. The - * ASF licenses this file to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance with the - * License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - ****************************************************************************/ - -#ifndef __ARCH_ARM_INCLUDE_ARMV7_M_IRQ_LAZYFPU_H -#define __ARCH_ARM_INCLUDE_ARMV7_M_IRQ_LAZYFPU_H - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -/**************************************************************************** - * Pre-processor Prototypes - ****************************************************************************/ - -/* IRQ Stack Frame Format: */ - -/* The following additional registers are stored by the interrupt handling - * logic. - */ - -#define REG_R13 (0) /* R13 = SP at time of interrupt */ -#ifdef CONFIG_ARMV7M_USEBASEPRI -# define REG_BASEPRI (1) /* BASEPRI */ -#else -# define REG_PRIMASK (1) /* PRIMASK */ -#endif -#define REG_R4 (2) /* R4 */ -#define REG_R5 (3) /* R5 */ -#define REG_R6 (4) /* R6 */ -#define REG_R7 (5) /* R7 */ -#define REG_R8 (6) /* R8 */ -#define REG_R9 (7) /* R9 */ -#define REG_R10 (8) /* R10 */ -#define REG_R11 (9) /* R11 */ - -#ifdef CONFIG_BUILD_PROTECTED -# define REG_EXC_RETURN (10) /* EXC_RETURN */ -# define SW_INT_REGS (11) -#else -# define SW_INT_REGS (10) -#endif - -/* If the MCU supports a floating point unit, then it will be necessary - * to save the state of the FPU status register and data registers on - * each context switch. These registers are not saved during interrupt - * level processing, however. So, as a consequence, floating point - * operations may NOT be performed in interrupt handlers. - * - * The FPU provides an extension register file containing 32 single- - * precision registers. These can be viewed as: - * - * - Sixteen 64-bit doubleword registers, D0-D15 - * - Thirty-two 32-bit single-word registers, S0-S31 - * S<2n> maps to the least significant half of D - * S<2n+1> maps to the most significant half of D. - */ - -#ifdef CONFIG_ARCH_FPU -# define REG_D0 (SW_INT_REGS+0) /* D0 */ -# define REG_S0 (SW_INT_REGS+0) /* S0 */ -# define REG_S1 (SW_INT_REGS+1) /* S1 */ -# define REG_D1 (SW_INT_REGS+2) /* D1 */ -# define REG_S2 (SW_INT_REGS+2) /* S2 */ -# define REG_S3 (SW_INT_REGS+3) /* S3 */ -# define REG_D2 (SW_INT_REGS+4) /* D2 */ -# define REG_S4 (SW_INT_REGS+4) /* S4 */ -# define REG_S5 (SW_INT_REGS+5) /* S5 */ -# define REG_D3 (SW_INT_REGS+6) /* D3 */ -# define REG_S6 (SW_INT_REGS+6) /* S6 */ -# define REG_S7 (SW_INT_REGS+7) /* S7 */ -# define REG_D4 (SW_INT_REGS+8) /* D4 */ -# define REG_S8 (SW_INT_REGS+8) /* S8 */ -# define REG_S9 (SW_INT_REGS+9) /* S9 */ -# define REG_D5 (SW_INT_REGS+10) /* D5 */ -# define REG_S10 (SW_INT_REGS+10) /* S10 */ -# define REG_S11 (SW_INT_REGS+11) /* S11 */ -# define REG_D6 (SW_INT_REGS+12) /* D6 */ -# define REG_S12 (SW_INT_REGS+12) /* S12 */ -# define REG_S13 (SW_INT_REGS+13) /* S13 */ -# define REG_D7 (SW_INT_REGS+14) /* D7 */ -# define REG_S14 (SW_INT_REGS+14) /* S14 */ -# define REG_S15 (SW_INT_REGS+15) /* S15 */ -# define REG_D8 (SW_INT_REGS+16) /* D8 */ -# define REG_S16 (SW_INT_REGS+16) /* S16 */ -# define REG_S17 (SW_INT_REGS+17) /* S17 */ -# define REG_D9 (SW_INT_REGS+18) /* D9 */ -# define REG_S18 (SW_INT_REGS+18) /* S18 */ -# define REG_S19 (SW_INT_REGS+19) /* S19 */ -# define REG_D10 (SW_INT_REGS+20) /* D10 */ -# define REG_S20 (SW_INT_REGS+20) /* S20 */ -# define REG_S21 (SW_INT_REGS+21) /* S21 */ -# define REG_D11 (SW_INT_REGS+22) /* D11 */ -# define REG_S22 (SW_INT_REGS+22) /* S22 */ -# define REG_S23 (SW_INT_REGS+23) /* S23 */ -# define REG_D12 (SW_INT_REGS+24) /* D12 */ -# define REG_S24 (SW_INT_REGS+24) /* S24 */ -# define REG_S25 (SW_INT_REGS+25) /* S25 */ -# define REG_D13 (SW_INT_REGS+26) /* D13 */ -# define REG_S26 (SW_INT_REGS+26) /* S26 */ -# define REG_S27 (SW_INT_REGS+27) /* S27 */ -# define REG_D14 (SW_INT_REGS+28) /* D14 */ -# define REG_S28 (SW_INT_REGS+28) /* S28 */ -# define REG_S29 (SW_INT_REGS+29) /* S29 */ -# define REG_D15 (SW_INT_REGS+30) /* D15 */ -# define REG_S30 (SW_INT_REGS+30) /* S30 */ -# define REG_S31 (SW_INT_REGS+31) /* S31 */ -# define REG_FPSCR (SW_INT_REGS+32) /* Floating point status and control */ -# define SW_FPU_REGS (33) -#else -# define SW_FPU_REGS (0) -#endif - -/* The total number of registers saved by software */ - -#define SW_XCPT_REGS (SW_INT_REGS + SW_FPU_REGS) -#define SW_XCPT_SIZE (4 * SW_XCPT_REGS) - -/* On entry into an IRQ, the hardware automatically saves the following - * registers on the stack in this (address) order: - */ - -#define REG_R0 (SW_XCPT_REGS+0) /* R0 */ -#define REG_R1 (SW_XCPT_REGS+1) /* R1 */ -#define REG_R2 (SW_XCPT_REGS+2) /* R2 */ -#define REG_R3 (SW_XCPT_REGS+3) /* R3 */ -#define REG_R12 (SW_XCPT_REGS+4) /* R12 */ -#define REG_R14 (SW_XCPT_REGS+5) /* R14 = LR */ -#define REG_R15 (SW_XCPT_REGS+6) /* R15 = PC */ -#define REG_XPSR (SW_XCPT_REGS+7) /* xPSR */ - -#define HW_XCPT_REGS (8) -#define HW_XCPT_SIZE (4 * HW_XCPT_REGS) - -#define XCPTCONTEXT_REGS (HW_XCPT_REGS + SW_XCPT_REGS) -#define XCPTCONTEXT_SIZE (HW_XCPT_SIZE + SW_XCPT_SIZE) - -/**************************************************************************** - * Public Types - ****************************************************************************/ - -/**************************************************************************** - * Inline functions - ****************************************************************************/ - -/**************************************************************************** - * Public Data - ****************************************************************************/ - -/**************************************************************************** - * Public Function Prototypes - ****************************************************************************/ - -#endif /* __ARCH_ARM_INCLUDE_ARMV7_M_IRQ_LAZYFPU_H */ diff --git a/arch/arm/include/armv7-r/irq.h b/arch/arm/include/armv7-r/irq.h index d26888882ecbc..06a7919b899de 100644 --- a/arch/arm/include/armv7-r/irq.h +++ b/arch/arm/include/armv7-r/irq.h @@ -294,7 +294,7 @@ struct xcptcontext * handling to support dynamically sized stacks for each thread. */ - FAR uintptr_t *ustack[ARCH_STACK_NSECTS]; + uintptr_t *ustack[ARCH_STACK_NSECTS]; #endif #ifdef CONFIG_ARCH_KERNEL_STACK @@ -306,9 +306,9 @@ struct xcptcontext * stack in place. */ - FAR uint32_t *ustkptr; /* Saved user stack pointer */ - FAR uint32_t *kstack; /* Allocate base of the (aligned) kernel stack */ - FAR uint32_t *kstkptr; /* Saved kernel stack pointer */ + uint32_t *ustkptr; /* Saved user stack pointer */ + uint32_t *kstack; /* Allocate base of the (aligned) kernel stack */ + uint32_t *kstkptr; /* Saved kernel stack pointer */ #endif #endif }; diff --git a/arch/arm/include/armv8-m/irq.h b/arch/arm/include/armv8-m/irq.h index 5395484d9d242..4874dbd032653 100644 --- a/arch/arm/include/armv8-m/irq.h +++ b/arch/arm/include/armv8-m/irq.h @@ -38,14 +38,6 @@ # include #endif -/* Included implementation-dependent register save structure layouts */ - -#ifndef CONFIG_ARMV8M_LAZYFPU -# include -#else -# include -#endif - /**************************************************************************** * Pre-processor Prototypes ****************************************************************************/ @@ -60,6 +52,116 @@ # define CONFIG_SYS_NNEST 2 #endif +/* IRQ Stack Frame Format: */ + +/* The following additional registers are stored by the interrupt handling + * logic. + */ + +#define REG_R13 (0) /* R13 = SP at time of interrupt */ +#ifdef CONFIG_ARMV8M_USEBASEPRI +# define REG_BASEPRI (1) /* BASEPRI */ +#else +# define REG_PRIMASK (1) /* PRIMASK */ +#endif +#define REG_R4 (2) /* R4 */ +#define REG_R5 (3) /* R5 */ +#define REG_R6 (4) /* R6 */ +#define REG_R7 (5) /* R7 */ +#define REG_R8 (6) /* R8 */ +#define REG_R9 (7) /* R9 */ +#define REG_R10 (8) /* R10 */ +#define REG_R11 (9) /* R11 */ +#define REG_EXC_RETURN (10) /* EXC_RETURN */ +#define SW_INT_REGS (11) + +#ifdef CONFIG_ARCH_FPU + +/* If the MCU supports a floating point unit, then it will be necessary + * to save the state of the non-volatile registers before calling code + * that may save and overwrite them. + */ + +# define REG_S16 (SW_INT_REGS + 0) /* S16 */ +# define REG_S17 (SW_INT_REGS + 1) /* S17 */ +# define REG_S18 (SW_INT_REGS + 2) /* S18 */ +# define REG_S19 (SW_INT_REGS + 3) /* S19 */ +# define REG_S20 (SW_INT_REGS + 4) /* S20 */ +# define REG_S21 (SW_INT_REGS + 5) /* S21 */ +# define REG_S22 (SW_INT_REGS + 6) /* S22 */ +# define REG_S23 (SW_INT_REGS + 7) /* S23 */ +# define REG_S24 (SW_INT_REGS + 8) /* S24 */ +# define REG_S25 (SW_INT_REGS + 9) /* S25 */ +# define REG_S26 (SW_INT_REGS + 10) /* S26 */ +# define REG_S27 (SW_INT_REGS + 11) /* S27 */ +# define REG_S28 (SW_INT_REGS + 12) /* S28 */ +# define REG_S29 (SW_INT_REGS + 13) /* S29 */ +# define REG_S30 (SW_INT_REGS + 14) /* S30 */ +# define REG_S31 (SW_INT_REGS + 15) /* S31 */ +# define SW_FPU_REGS (16) +#else +# define SW_FPU_REGS (0) +#endif + +/* The total number of registers saved by software */ + +#ifdef CONFIG_ARMV8M_STACKCHECK_HARDWARE +# define REG_SPLIM (SW_INT_REGS + SW_FPU_REGS + 0) /* REG_SPLIM */ +# define SW_XCPT_REGS (SW_INT_REGS + SW_FPU_REGS + 1) +#else +# define SW_XCPT_REGS (SW_INT_REGS + SW_FPU_REGS) +#endif + +#define SW_XCPT_SIZE (4 * SW_XCPT_REGS) + +/* On entry into an IRQ, the hardware automatically saves the following + * registers on the stack in this (address) order: + */ + +#define REG_R0 (SW_XCPT_REGS + 0) /* R0 */ +#define REG_R1 (SW_XCPT_REGS + 1) /* R1 */ +#define REG_R2 (SW_XCPT_REGS + 2) /* R2 */ +#define REG_R3 (SW_XCPT_REGS + 3) /* R3 */ +#define REG_R12 (SW_XCPT_REGS + 4) /* R12 */ +#define REG_R14 (SW_XCPT_REGS + 5) /* R14 = LR */ +#define REG_R15 (SW_XCPT_REGS + 6) /* R15 = PC */ +#define REG_XPSR (SW_XCPT_REGS + 7) /* xPSR */ +#define HW_INT_REGS (8) + +#ifdef CONFIG_ARCH_FPU + +/* If the FPU is enabled, the hardware also saves the volatile FP registers. + */ + +# define REG_S0 (SW_XCPT_REGS + 8) /* S0 */ +# define REG_S1 (SW_XCPT_REGS + 9) /* S1 */ +# define REG_S2 (SW_XCPT_REGS + 10) /* S2 */ +# define REG_S3 (SW_XCPT_REGS + 11) /* S3 */ +# define REG_S4 (SW_XCPT_REGS + 12) /* S4 */ +# define REG_S5 (SW_XCPT_REGS + 13) /* S5 */ +# define REG_S6 (SW_XCPT_REGS + 14) /* S6 */ +# define REG_S7 (SW_XCPT_REGS + 15) /* S7 */ +# define REG_S8 (SW_XCPT_REGS + 16) /* S8 */ +# define REG_S9 (SW_XCPT_REGS + 17) /* S9 */ +# define REG_S10 (SW_XCPT_REGS + 18) /* S10 */ +# define REG_S11 (SW_XCPT_REGS + 19) /* S11 */ +# define REG_S12 (SW_XCPT_REGS + 20) /* S12 */ +# define REG_S13 (SW_XCPT_REGS + 21) /* S13 */ +# define REG_S14 (SW_XCPT_REGS + 22) /* S14 */ +# define REG_S15 (SW_XCPT_REGS + 23) /* S15 */ +# define REG_FPSCR (SW_XCPT_REGS + 24) /* FPSCR */ +# define REG_FP_RESERVED (SW_XCPT_REGS + 25) /* Reserved */ +# define HW_FPU_REGS (18) +#else +# define HW_FPU_REGS (0) +#endif + +#define HW_XCPT_REGS (HW_INT_REGS + HW_FPU_REGS) +#define HW_XCPT_SIZE (4 * HW_XCPT_REGS) + +#define XCPTCONTEXT_REGS (HW_XCPT_REGS + SW_XCPT_REGS) +#define XCPTCONTEXT_SIZE (4 * XCPTCONTEXT_REGS) + /* Alternate register names *************************************************/ #define REG_A1 REG_R0 @@ -123,7 +225,7 @@ struct xcptcontext * are pending signals to be processed. */ - FAR void *sigdeliver; /* Actual type is sig_deliver_t */ + void *sigdeliver; /* Actual type is sig_deliver_t */ /* These are saved copies of the context used during * signal processing. diff --git a/arch/arm/include/armv8-m/irq_cmnvector.h b/arch/arm/include/armv8-m/irq_cmnvector.h deleted file mode 100644 index 9956374d43d56..0000000000000 --- a/arch/arm/include/armv8-m/irq_cmnvector.h +++ /dev/null @@ -1,158 +0,0 @@ -/**************************************************************************** - * arch/arm/include/armv8-m/irq_cmnvector.h - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. The - * ASF licenses this file to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance with the - * License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - ****************************************************************************/ - -#ifndef __ARCH_ARM_INCLUDE_ARMV8_M_IRQ_CMNVECTOR_H -#define __ARCH_ARM_INCLUDE_ARMV8_M_IRQ_CMNVECTOR_H - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -/**************************************************************************** - * Pre-processor Prototypes - ****************************************************************************/ - -/* IRQ Stack Frame Format: */ - -/* The following additional registers are stored by the interrupt handling - * logic. - */ - -#define REG_R13 (0) /* R13 = SP at time of interrupt */ -#ifdef CONFIG_ARMV8M_USEBASEPRI -# define REG_BASEPRI (1) /* BASEPRI */ -#else -# define REG_PRIMASK (1) /* PRIMASK */ -#endif -#define REG_R4 (2) /* R4 */ -#define REG_R5 (3) /* R5 */ -#define REG_R6 (4) /* R6 */ -#define REG_R7 (5) /* R7 */ -#define REG_R8 (6) /* R8 */ -#define REG_R9 (7) /* R9 */ -#define REG_R10 (8) /* R10 */ -#define REG_R11 (9) /* R11 */ -#define REG_EXC_RETURN (10) /* EXC_RETURN */ -#define SW_INT_REGS (11) - -#ifdef CONFIG_ARCH_FPU - -/* If the MCU supports a floating point unit, then it will be necessary - * to save the state of the non-volatile registers before calling code - * that may save and overwrite them. - */ - -# define REG_S16 (SW_INT_REGS + 0) /* S16 */ -# define REG_S17 (SW_INT_REGS + 1) /* S17 */ -# define REG_S18 (SW_INT_REGS + 2) /* S18 */ -# define REG_S19 (SW_INT_REGS + 3) /* S19 */ -# define REG_S20 (SW_INT_REGS + 4) /* S20 */ -# define REG_S21 (SW_INT_REGS + 5) /* S21 */ -# define REG_S22 (SW_INT_REGS + 6) /* S22 */ -# define REG_S23 (SW_INT_REGS + 7) /* S23 */ -# define REG_S24 (SW_INT_REGS + 8) /* S24 */ -# define REG_S25 (SW_INT_REGS + 9) /* S25 */ -# define REG_S26 (SW_INT_REGS + 10) /* S26 */ -# define REG_S27 (SW_INT_REGS + 11) /* S27 */ -# define REG_S28 (SW_INT_REGS + 12) /* S28 */ -# define REG_S29 (SW_INT_REGS + 13) /* S29 */ -# define REG_S30 (SW_INT_REGS + 14) /* S30 */ -# define REG_S31 (SW_INT_REGS + 15) /* S31 */ -# define SW_FPU_REGS (16) -#else -# define SW_FPU_REGS (0) -#endif - -/* The total number of registers saved by software */ - -#ifdef CONFIG_ARMV8M_STACKCHECK_HARDWARE -# define REG_SPLIM (SW_INT_REGS + SW_FPU_REGS + 0) /* REG_SPLIM */ -# define SW_XCPT_REGS (SW_INT_REGS + SW_FPU_REGS + 1) -#else -# define SW_XCPT_REGS (SW_INT_REGS + SW_FPU_REGS) -#endif - -#define SW_XCPT_SIZE (4 * SW_XCPT_REGS) - -/* On entry into an IRQ, the hardware automatically saves the following - * registers on the stack in this (address) order: - */ - -#define REG_R0 (SW_XCPT_REGS + 0) /* R0 */ -#define REG_R1 (SW_XCPT_REGS + 1) /* R1 */ -#define REG_R2 (SW_XCPT_REGS + 2) /* R2 */ -#define REG_R3 (SW_XCPT_REGS + 3) /* R3 */ -#define REG_R12 (SW_XCPT_REGS + 4) /* R12 */ -#define REG_R14 (SW_XCPT_REGS + 5) /* R14 = LR */ -#define REG_R15 (SW_XCPT_REGS + 6) /* R15 = PC */ -#define REG_XPSR (SW_XCPT_REGS + 7) /* xPSR */ -#define HW_INT_REGS (8) - -#ifdef CONFIG_ARCH_FPU - -/* If the FPU is enabled, the hardware also saves the volatile FP registers. - */ - -# define REG_S0 (SW_XCPT_REGS + 8) /* S0 */ -# define REG_S1 (SW_XCPT_REGS + 9) /* S1 */ -# define REG_S2 (SW_XCPT_REGS + 10) /* S2 */ -# define REG_S3 (SW_XCPT_REGS + 11) /* S3 */ -# define REG_S4 (SW_XCPT_REGS + 12) /* S4 */ -# define REG_S5 (SW_XCPT_REGS + 13) /* S5 */ -# define REG_S6 (SW_XCPT_REGS + 14) /* S6 */ -# define REG_S7 (SW_XCPT_REGS + 15) /* S7 */ -# define REG_S8 (SW_XCPT_REGS + 16) /* S8 */ -# define REG_S9 (SW_XCPT_REGS + 17) /* S9 */ -# define REG_S10 (SW_XCPT_REGS + 18) /* S10 */ -# define REG_S11 (SW_XCPT_REGS + 19) /* S11 */ -# define REG_S12 (SW_XCPT_REGS + 20) /* S12 */ -# define REG_S13 (SW_XCPT_REGS + 21) /* S13 */ -# define REG_S14 (SW_XCPT_REGS + 22) /* S14 */ -# define REG_S15 (SW_XCPT_REGS + 23) /* S15 */ -# define REG_FPSCR (SW_XCPT_REGS + 24) /* FPSCR */ -# define REG_FP_RESERVED (SW_XCPT_REGS + 25) /* Reserved */ -# define HW_FPU_REGS (18) -#else -# define HW_FPU_REGS (0) -#endif - -#define HW_XCPT_REGS (HW_INT_REGS + HW_FPU_REGS) -#define HW_XCPT_SIZE (4 * HW_XCPT_REGS) - -#define XCPTCONTEXT_REGS (HW_XCPT_REGS + SW_XCPT_REGS) -#define XCPTCONTEXT_SIZE (4 * XCPTCONTEXT_REGS) - -/**************************************************************************** - * Public Types - ****************************************************************************/ - -/**************************************************************************** - * Inline functions - ****************************************************************************/ - -/**************************************************************************** - * Public Data - ****************************************************************************/ - -/**************************************************************************** - * Public Function Prototypes - ****************************************************************************/ - -#endif /* __ARCH_ARM_INCLUDE_ARMV8_M_IRQ_CMNVECTOR_H */ diff --git a/arch/arm/include/armv8-m/irq_lazyfpu.h b/arch/arm/include/armv8-m/irq_lazyfpu.h deleted file mode 100644 index 1f3f0c77747a4..0000000000000 --- a/arch/arm/include/armv8-m/irq_lazyfpu.h +++ /dev/null @@ -1,176 +0,0 @@ -/**************************************************************************** - * arch/arm/include/armv8-m/irq_lazyfpu.h - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. The - * ASF licenses this file to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance with the - * License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - ****************************************************************************/ - -#ifndef __ARCH_ARM_INCLUDE_ARMV8_M_IRQ_LAZYFPU_H -#define __ARCH_ARM_INCLUDE_ARMV8_M_IRQ_LAZYFPU_H - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -/**************************************************************************** - * Pre-processor Prototypes - ****************************************************************************/ - -/* IRQ Stack Frame Format: */ - -/* The following additional registers are stored by the interrupt handling - * logic. - */ - -#define REG_R13 (0) /* R13 = SP at time of interrupt */ -#ifdef CONFIG_ARMV8M_USEBASEPRI -# define REG_BASEPRI (1) /* BASEPRI */ -#else -# define REG_PRIMASK (1) /* PRIMASK */ -#endif -#define REG_R4 (2) /* R4 */ -#define REG_R5 (3) /* R5 */ -#define REG_R6 (4) /* R6 */ -#define REG_R7 (5) /* R7 */ -#define REG_R8 (6) /* R8 */ -#define REG_R9 (7) /* R9 */ -#define REG_R10 (8) /* R10 */ -#define REG_R11 (9) /* R11 */ - -#ifdef CONFIG_BUILD_PROTECTED -# define REG_EXC_RETURN (10) /* EXC_RETURN */ -# define SW_INT_REGS (11) -#else -# define SW_INT_REGS (10) -#endif - -/* If the MCU supports a floating point unit, then it will be necessary - * to save the state of the FPU status register and data registers on - * each context switch. These registers are not saved during interrupt - * level processing, however. So, as a consequence, floating point - * operations may NOT be performed in interrupt handlers. - * - * The FPU provides an extension register file containing 32 single- - * precision registers. These can be viewed as: - * - * - Sixteen 64-bit doubleword registers, D0-D15 - * - Thirty-two 32-bit single-word registers, S0-S31 - * S<2n> maps to the least significant half of D - * S<2n+1> maps to the most significant half of D. - */ - -#ifdef CONFIG_ARCH_FPU -# define REG_D0 (SW_INT_REGS+0) /* D0 */ -# define REG_S0 (SW_INT_REGS+0) /* S0 */ -# define REG_S1 (SW_INT_REGS+1) /* S1 */ -# define REG_D1 (SW_INT_REGS+2) /* D1 */ -# define REG_S2 (SW_INT_REGS+2) /* S2 */ -# define REG_S3 (SW_INT_REGS+3) /* S3 */ -# define REG_D2 (SW_INT_REGS+4) /* D2 */ -# define REG_S4 (SW_INT_REGS+4) /* S4 */ -# define REG_S5 (SW_INT_REGS+5) /* S5 */ -# define REG_D3 (SW_INT_REGS+6) /* D3 */ -# define REG_S6 (SW_INT_REGS+6) /* S6 */ -# define REG_S7 (SW_INT_REGS+7) /* S7 */ -# define REG_D4 (SW_INT_REGS+8) /* D4 */ -# define REG_S8 (SW_INT_REGS+8) /* S8 */ -# define REG_S9 (SW_INT_REGS+9) /* S9 */ -# define REG_D5 (SW_INT_REGS+10) /* D5 */ -# define REG_S10 (SW_INT_REGS+10) /* S10 */ -# define REG_S11 (SW_INT_REGS+11) /* S11 */ -# define REG_D6 (SW_INT_REGS+12) /* D6 */ -# define REG_S12 (SW_INT_REGS+12) /* S12 */ -# define REG_S13 (SW_INT_REGS+13) /* S13 */ -# define REG_D7 (SW_INT_REGS+14) /* D7 */ -# define REG_S14 (SW_INT_REGS+14) /* S14 */ -# define REG_S15 (SW_INT_REGS+15) /* S15 */ -# define REG_D8 (SW_INT_REGS+16) /* D8 */ -# define REG_S16 (SW_INT_REGS+16) /* S16 */ -# define REG_S17 (SW_INT_REGS+17) /* S17 */ -# define REG_D9 (SW_INT_REGS+18) /* D9 */ -# define REG_S18 (SW_INT_REGS+18) /* S18 */ -# define REG_S19 (SW_INT_REGS+19) /* S19 */ -# define REG_D10 (SW_INT_REGS+20) /* D10 */ -# define REG_S20 (SW_INT_REGS+20) /* S20 */ -# define REG_S21 (SW_INT_REGS+21) /* S21 */ -# define REG_D11 (SW_INT_REGS+22) /* D11 */ -# define REG_S22 (SW_INT_REGS+22) /* S22 */ -# define REG_S23 (SW_INT_REGS+23) /* S23 */ -# define REG_D12 (SW_INT_REGS+24) /* D12 */ -# define REG_S24 (SW_INT_REGS+24) /* S24 */ -# define REG_S25 (SW_INT_REGS+25) /* S25 */ -# define REG_D13 (SW_INT_REGS+26) /* D13 */ -# define REG_S26 (SW_INT_REGS+26) /* S26 */ -# define REG_S27 (SW_INT_REGS+27) /* S27 */ -# define REG_D14 (SW_INT_REGS+28) /* D14 */ -# define REG_S28 (SW_INT_REGS+28) /* S28 */ -# define REG_S29 (SW_INT_REGS+29) /* S29 */ -# define REG_D15 (SW_INT_REGS+30) /* D15 */ -# define REG_S30 (SW_INT_REGS+30) /* S30 */ -# define REG_S31 (SW_INT_REGS+31) /* S31 */ -# define REG_FPSCR (SW_INT_REGS+32) /* Floating point status and control */ -# define SW_FPU_REGS (33) -#else -# define SW_FPU_REGS (0) -#endif - -/* The total number of registers saved by software */ - -#ifdef CONFIG_ARMV8M_STACKCHECK_HARDWARE -# define REG_SPLIM (SW_INT_REGS + SW_FPU_REGS + 0) /* REG_SPLIM */ -# define SW_XCPT_REGS (SW_INT_REGS + SW_FPU_REGS + 1) -#else -# define SW_XCPT_REGS (SW_INT_REGS + SW_FPU_REGS) -#endif - -#define SW_XCPT_SIZE (4 * SW_XCPT_REGS) - -/* On entry into an IRQ, the hardware automatically saves the following - * registers on the stack in this (address) order: - */ - -#define REG_R0 (SW_XCPT_REGS+0) /* R0 */ -#define REG_R1 (SW_XCPT_REGS+1) /* R1 */ -#define REG_R2 (SW_XCPT_REGS+2) /* R2 */ -#define REG_R3 (SW_XCPT_REGS+3) /* R3 */ -#define REG_R12 (SW_XCPT_REGS+4) /* R12 */ -#define REG_R14 (SW_XCPT_REGS+5) /* R14 = LR */ -#define REG_R15 (SW_XCPT_REGS+6) /* R15 = PC */ -#define REG_XPSR (SW_XCPT_REGS+7) /* xPSR */ - -#define HW_XCPT_REGS (8) -#define HW_XCPT_SIZE (4 * HW_XCPT_REGS) - -#define XCPTCONTEXT_REGS (HW_XCPT_REGS + SW_XCPT_REGS) -#define XCPTCONTEXT_SIZE (HW_XCPT_SIZE + SW_XCPT_SIZE) - -/**************************************************************************** - * Public Types - ****************************************************************************/ - -/**************************************************************************** - * Inline functions - ****************************************************************************/ - -/**************************************************************************** - * Public Data - ****************************************************************************/ - -/**************************************************************************** - * Public Function Prototypes - ****************************************************************************/ - -#endif /* __ARCH_ARM_INCLUDE_ARMV8_M_IRQ_LAZYFPU_H */ diff --git a/arch/arm/include/syscall.h b/arch/arm/include/syscall.h index 1b1289a0a9d93..d6053ae0f1ed8 100644 --- a/arch/arm/include/syscall.h +++ b/arch/arm/include/syscall.h @@ -66,7 +66,7 @@ /* SYS call 0: * - * int arm_saveusercontext(uint32_t *saveregs); + * int up_saveusercontext(void *saveregs); */ #define SYS_save_context (0) @@ -97,7 +97,7 @@ #ifndef CONFIG_BUILD_FLAT /* SYS call 4: * - * void up_task_start(main_t taskentry, int argc, FAR char *argv[]) + * void up_task_start(main_t taskentry, int argc, char *argv[]) * noreturn_function; */ @@ -115,8 +115,8 @@ /* SYS call 6: * * void signal_handler(_sa_sigaction_t sighand, - * int signo, FAR siginfo_t *info, - * FAR void *ucontext); + * int signo, siginfo_t *info, + * void *ucontext); */ #define SYS_signal_handler (6) diff --git a/arch/arm/src/Makefile b/arch/arm/src/Makefile index fc92b6ff3245a..5b159d388dff5 100644 --- a/arch/arm/src/Makefile +++ b/arch/arm/src/Makefile @@ -89,8 +89,15 @@ LDFLAGS += $(addprefix -T,$(call CONVERT_PATH,$(ARCHSCRIPT))) $(EXTRALINKCMDS) # Override in Make.defs if linker is not 'ld' -LDSTARTGROUP ?= --start-group -LDENDGROUP ?= --end-group +ifeq ($(LD),$(CC)) + LDSTARTGROUP ?= -Wl,--start-group + LDENDGROUP ?= -Wl,--end-group + LDFLAGS := $(addprefix -Xlinker ,$(LDFLAGS)) + LDFLAGS += $(CFLAGS) +else + LDSTARTGROUP ?= --start-group + LDENDGROUP ?= --end-group +endif BOARDMAKE = $(if $(wildcard board$(DELIM)Makefile),y,) @@ -109,9 +116,9 @@ VPATH += common VPATH += $(ARCH_SUBDIR) ifeq ($(CONFIG_ARCH_TOOLCHAIN_IAR),y) - VPATH += $(ARCH_SUBDIR)$(DELIM)iar + VPATH += common$(DELIM)iar else # ifeq ($(CONFIG_ARCH_TOOLCHAIN_GNU),y) - VPATH += $(ARCH_SUBDIR)$(DELIM)gnu + VPATH += common$(DELIM)gnu endif all: $(HEAD_OBJ) $(BIN) diff --git a/arch/arm/src/a1x/Make.defs b/arch/arm/src/a1x/Make.defs index 220bee248903e..1c5f691283812 100644 --- a/arch/arm/src/a1x/Make.defs +++ b/arch/arm/src/a1x/Make.defs @@ -18,98 +18,7 @@ # ############################################################################ -# The vector table is the "head" object, i.e., the one that must forced into -# the link in order to draw in all of the other components - -HEAD_ASRC = arm_vectortab.S - -ifeq ($(CONFIG_BUILD_KERNEL),y) -crt0$(OBJEXT): crt0.c - $(CC) $(CFLAGS) -c armv7-a$(DELIM)crt0.c -o crt0$(OBJEXT) - -STARTUP_OBJS = crt0$(OBJEXT) -endif - -# Force the start-up logic to be at the beginning of the .text to simplify -# debug. - -ifeq ($(CONFIG_PAGING),y) -CMN_ASRCS = arm_pghead.S -else -CMN_ASRCS = arm_head.S -endif - -# Common assembly language files - -CMN_ASRCS += arm_vectors.S arm_fpuconfig.S arm_fullcontextrestore.S -CMN_ASRCS += arm_saveusercontext.S arm_vectoraddrexcptn.S -CMN_ASRCS += arm_testset.S arm_fetchadd.S vfork.S -CMN_ASRCS += cp15_coherent_dcache.S cp15_invalidate_dcache.S -CMN_ASRCS += cp15_clean_dcache.S cp15_flush_dcache.S cp15_invalidate_dcache_all.S -CMN_ASRCS += cp15_clean_dcache_all.S cp15_flush_dcache_all.S cp15_cache_size.S - -# Common C source files - -CMN_CSRCS = arm_initialize.c arm_interruptcontext.c arm_exit.c arm_createstack.c -CMN_CSRCS += arm_releasestack.c arm_usestack.c arm_vfork.c arm_puts.c arm_mdelay.c -CMN_CSRCS += arm_stackframe.c arm_udelay.c arm_modifyreg8.c arm_modifyreg16.c -CMN_CSRCS += arm_modifyreg32.c - -CMN_CSRCS += arm_assert.c arm_blocktask.c arm_dataabort.c -CMN_CSRCS += arm_doirq.c arm_initialstate.c arm_mmu.c arm_prefetchabort.c -CMN_CSRCS += arm_releasepending.c arm_reprioritizertr.c -CMN_CSRCS += arm_schedulesigaction.c arm_sigdeliver.c arm_syscall.c -CMN_CSRCS += arm_unblocktask.c arm_undefinedinsn.c arm_tcbinfo.c -CMN_CSRCS += arm_switchcontext.c - -# Use common heap allocation for now (may need to be customized later) - -CMN_CSRCS += arm_allocateheap.c - -# Configuration dependent C and assembly language files - -ifneq ($(CONFIG_ARCH_IDLE_CUSTOM),y) -CMN_CSRCS += arm_idle.c -endif - -ifeq ($(CONFIG_PAGING),y) -CMN_CSRCS += arm_allocpage.c arm_checkmapping.c arm_pginitialize.c -CMN_CSRCS += arm_va2pte.c -endif - -ifeq ($(CONFIG_BUILD_KERNEL),y) -CMN_CSRCS += arm_task_start.c arm_pthread_start.c arm_signal_dispatch.c -endif - -ifeq ($(CONFIG_ARCH_ADDRENV),y) -CMN_CSRCS += arm_addrenv.c arm_addrenv_utils.c arm_pgalloc.c -ifeq ($(CONFIG_ARCH_STACK_DYNAMIC),y) -CMN_CSRCS += arm_addrenv_ustack.c -endif -ifeq ($(CONFIG_ARCH_KERNEL_STACK),y) -CMN_CSRCS += arm_addrenv_kstack.c -endif -ifeq ($(CONFIG_MM_SHM),y) -CMN_CSRCS += arm_addrenv_shm.c -endif -endif - -ifeq ($(CONFIG_MM_PGALLOC),y) -CMN_CSRCS += arm_physpgaddr.c -ifeq ($(CONFIG_ARCH_PGPOOL_MAPPING),y) -CMN_CSRCS += arm_virtpgaddr.c -endif -endif - -CMN_CSRCS += arm_cache.c - -ifeq ($(CONFIG_ARCH_FPU),y) -CMN_ASRCS += arm_savefpu.S arm_restorefpu.S -endif - -ifeq ($(CONFIG_STACK_COLORATION),y) -CMN_CSRCS += arm_checkstack.c -endif +include armv7-a/Make.defs # A1x-specific C source files diff --git a/arch/arm/src/a1x/a1x_boot.c b/arch/arm/src/a1x/a1x_boot.c index d6effb2173a39..ba475afb34df8 100644 --- a/arch/arm/src/a1x/a1x_boot.c +++ b/arch/arm/src/a1x/a1x_boot.c @@ -34,7 +34,6 @@ #include "chip.h" #include "arm.h" #include "mmu.h" -#include "fpu.h" #include "arm_internal.h" #include "a1x_lowputc.h" #include "a1x_boot.h" @@ -300,11 +299,9 @@ void arm_boot(void) a1x_copyvectorblock(); -#ifdef CONFIG_ARCH_FPU /* Initialize the FPU */ arm_fpuconfig(); -#endif #ifdef CONFIG_BOOT_SDRAM_DATA /* This setting is inappropriate for the A1x because the code is *always* diff --git a/arch/arm/src/a1x/a1x_pio.c b/arch/arm/src/a1x/a1x_pio.c index 0cfd9ea64cbfc..96820c9b59a28 100644 --- a/arch/arm/src/a1x/a1x_pio.c +++ b/arch/arm/src/a1x/a1x_pio.c @@ -90,12 +90,11 @@ static inline int a1x_pio_pin(pio_pinset_t cfgset) ****************************************************************************/ #ifdef CONFIG_A1X_PIO_IRQ -static int a1x_pio_interrupt(int irq, void *context) +static int a1x_pio_interrupt(int irq, void *context, void *arg) { uint32_t status; uint32_t mask; uint32_t pending; - int irq; /* Read the set of pending GPIO interrupts */ @@ -147,13 +146,15 @@ static int a1x_pio_interrupt(int irq, void *context) { /* Yes.. dispatch the interrupt */ - arm_doirq(irq, regs); + arm_doirq(irq, context); } irq++; pending >>= 1; } } + + return OK; } #endif @@ -173,18 +174,15 @@ static int a1x_pio_interrupt(int irq, void *context) #ifdef CONFIG_A1X_PIO_IRQ void a1x_pio_irqinitialize(void) { - int ret; - /* Disable all external PIO interrupts */ putreg32(0, A1X_PIO_INT_CTL); /* Attach the PIO interrupt handler */ - ret = irq_attach(A1X_IRQ_PIO) - if (ret < 0) + if (irq_attach(A1X_IRQ_PIO, a1x_pio_interrupt, NULL) < 0) { - return ret; + return; } /* And enable the PIO interrupt */ @@ -403,7 +401,7 @@ void a1x_pio_irqenable(int irq) { /* Convert the IRQ number to a bit position */ - pin = irq - A1X_PIO_EINT0 + pin = irq - A1X_PIO_EINT0; /* Un-mask the interrupt be setting the corresponding bit in the * PIO INT CTL register. @@ -411,7 +409,7 @@ void a1x_pio_irqenable(int irq) flags = enter_critical_section(); regval = getreg32(A1X_PIO_INT_CTL); - regval |= PIO_INT_CTL(irq); + regval |= PIO_INT_CTL(pin); leave_critical_section(flags); } } @@ -436,7 +434,7 @@ void a1x_pio_irqdisable(int irq) { /* Convert the IRQ number to a bit position */ - pin = irq - A1X_PIO_EINT0 + pin = irq - A1X_PIO_EINT0; /* Mask the interrupt be clearning the corresponding bit in the * PIO INT CTL register. @@ -444,7 +442,7 @@ void a1x_pio_irqdisable(int irq) flags = enter_critical_section(); regval = getreg32(A1X_PIO_INT_CTL); - regval &= ~PIO_INT_CTL(irq); + regval &= ~PIO_INT_CTL(pin); leave_critical_section(flags); } } diff --git a/arch/arm/src/am335x/Make.defs b/arch/arm/src/am335x/Make.defs index 81f6c36281efb..7a74566c858f4 100644 --- a/arch/arm/src/am335x/Make.defs +++ b/arch/arm/src/am335x/Make.defs @@ -18,94 +18,7 @@ # ############################################################################ -# The vector table is the "head" object, i.e., the one that must forced into -# the link in order to draw in all of the other components - -HEAD_ASRC = arm_vectortab.S - -ifeq ($(CONFIG_BUILD_KERNEL),y) -crt0$(OBJEXT): crt0.c - $(CC) $(CFLAGS) -c armv7-a$(DELIM)crt0.c -o crt0$(OBJEXT) - -STARTUP_OBJS = crt0$(OBJEXT) -endif - -# Force the start-up logic to be at the beginning of the .text to simplify -# debug. - -ifeq ($(CONFIG_PAGING),y) -CMN_ASRCS = arm_pghead.S -else -CMN_ASRCS = arm_head.S -endif - -# Common assembly language files - -CMN_ASRCS += arm_vectors.S arm_fpuconfig.S arm_fullcontextrestore.S -CMN_ASRCS += arm_saveusercontext.S arm_vectoraddrexcptn.S -CMN_ASRCS += arm_testset.S vfork.S -CMN_ASRCS += cp15_coherent_dcache.S cp15_invalidate_dcache.S -CMN_ASRCS += cp15_clean_dcache.S cp15_flush_dcache.S cp15_invalidate_dcache_all.S -CMN_ASRCS += cp15_clean_dcache_all.S cp15_flush_dcache_all.S cp15_cache_size.S - -# Common C source files - -CMN_CSRCS = arm_initialize.c arm_idle.c arm_interruptcontext.c arm_exit.c -CMN_CSRCS += arm_createstack.c arm_releasestack.c arm_usestack.c arm_vfork.c -CMN_CSRCS += arm_puts.c arm_mdelay.c arm_stackframe.c arm_udelay.c -CMN_CSRCS += arm_modifyreg8.c arm_modifyreg16.c arm_modifyreg32.c - -CMN_CSRCS += arm_assert.c arm_blocktask.c arm_dataabort.c -CMN_CSRCS += arm_doirq.c arm_initialstate.c arm_mmu.c arm_prefetchabort.c -CMN_CSRCS += arm_releasepending.c arm_reprioritizertr.c -CMN_CSRCS += arm_schedulesigaction.c arm_sigdeliver.c arm_syscall.c -CMN_CSRCS += arm_unblocktask.c arm_undefinedinsn.c arm_tcbinfo.c -CMN_CSRCS += arm_switchcontext.c - -# Use common heap allocation for now (may need to be customized later) - -CMN_CSRCS += arm_allocateheap.c - -# Configuration dependent C and assembly language files - -ifeq ($(CONFIG_PAGING),y) -CMN_CSRCS += arm_allocpage.c arm_checkmapping.c arm_pginitialize.c -CMN_CSRCS += arm_va2pte.c -endif - -ifeq ($(CONFIG_BUILD_KERNEL),y) -CMN_CSRCS += arm_task_start.c arm_pthread_start.c arm_signal_dispatch.c -endif - -ifeq ($(CONFIG_ARCH_ADDRENV),y) -CMN_CSRCS += arm_addrenv.c arm_addrenv_utils.c arm_pgalloc.c -ifeq ($(CONFIG_ARCH_STACK_DYNAMIC),y) -CMN_CSRCS += arm_addrenv_ustack.c -endif -ifeq ($(CONFIG_ARCH_KERNEL_STACK),y) -CMN_CSRCS += arm_addrenv_kstack.c -endif -ifeq ($(CONFIG_MM_SHM),y) -CMN_CSRCS += arm_addrenv_shm.c -endif -endif - -ifeq ($(CONFIG_MM_PGALLOC),y) -CMN_CSRCS += arm_physpgaddr.c -ifeq ($(CONFIG_ARCH_PGPOOL_MAPPING),y) -CMN_CSRCS += arm_virtpgaddr.c -endif -endif - -CMN_CSRCS += arm_cache.c - -ifeq ($(CONFIG_ARCH_FPU),y) -CMN_ASRCS += arm_savefpu.S arm_restorefpu.S -endif - -ifeq ($(CONFIG_STACK_COLORATION),y) -CMN_CSRCS += arm_checkstack.c -endif +include armv7-a/Make.defs # AM335x-specific C source files diff --git a/arch/arm/src/am335x/am335x_boot.c b/arch/arm/src/am335x/am335x_boot.c index 43223174a83fc..4a203fd27ae32 100644 --- a/arch/arm/src/am335x/am335x_boot.c +++ b/arch/arm/src/am335x/am335x_boot.c @@ -38,7 +38,6 @@ #include "chip.h" #include "arm.h" #include "mmu.h" -#include "fpu.h" #include "arm_internal.h" #include "am335x_clockconfig.h" #include "am335x_wdog.h" @@ -402,11 +401,9 @@ void arm_boot(void) am335x_clockconfig(); -#ifdef CONFIG_ARCH_FPU /* Initialize the FPU */ arm_fpuconfig(); -#endif /* Disable CPU Watchdog */ diff --git a/arch/arm/src/arm/Kconfig b/arch/arm/src/arm/Kconfig index ee5bcc7d26cfa..39547f4d8d4b4 100644 --- a/arch/arm/src/arm/Kconfig +++ b/arch/arm/src/arm/Kconfig @@ -7,23 +7,14 @@ comment "ARM Configuration Options" choice prompt "Toolchain Selection" - default ARM_TOOLCHAIN_GNU_EABIW if TOOLCHAIN_WINDOWS - default ARM_TOOLCHAIN_GNU_EABIL if !TOOLCHAIN_WINDOWS + default ARM_TOOLCHAIN_GNU_EABI config ARM_TOOLCHAIN_BUILDROOT bool "Buildroot (Cygwin or Linux)" depends on !WINDOWS_NATIVE -config ARM_TOOLCHAIN_GNU_EABIL - bool "Generic GNU EABI toolchain under Linux (or other POSIX environment)" - ---help--- - This option should work for any modern GNU toolchain (GCC 4.5 or newer) - configured for arm-none-eabi-. - -config ARM_TOOLCHAIN_GNU_EABIW - bool "Generic GNU EABI toolchain under Windows" - depends on TOOLCHAIN_WINDOWS - select CYGWIN_WINTOOL if WINDOWS_CYGWIN +config ARM_TOOLCHAIN_GNU_EABI + bool "Generic GNU EABI toolchain" ---help--- This option should work for any modern GNU toolchain (GCC 4.5 or newer) configured for arm-none-eabi-. diff --git a/arch/arm/src/arm/Make.defs b/arch/arm/src/arm/Make.defs new file mode 100644 index 0000000000000..15de37869158c --- /dev/null +++ b/arch/arm/src/arm/Make.defs @@ -0,0 +1,37 @@ +############################################################################ +# arch/arm/src/arm/Make.defs +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. The +# ASF licenses this file to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance with the +# License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +# +############################################################################ + +# Common ARM files + +include common/Make.defs + +HEAD_ASRC = arm_head.S + +CMN_CSRCS += arm_dataabort.c arm_doirq.c arm_initialstate.c +CMN_CSRCS += arm_prefetchabort.c arm_schedulesigaction.c +CMN_CSRCS += arm_sigdeliver.c arm_syscall.c arm_tcbinfo.c +CMN_CSRCS += arm_undefinedinsn.c + +CMN_ASRCS += arm_cache.S arm_vectoraddrexcptn.S +CMN_ASRCS += arm_vectors.S arm_vectortab.S + +ifeq ($(CONFIG_PAGING),y) + CMN_CSRCS += arm_pginitialize.c arm_checkmapping.c arm_allocpage.c arm_va2pte.c +endif diff --git a/arch/arm/src/arm/Toolchain.defs b/arch/arm/src/arm/Toolchain.defs index 07127dc568958..64eca4bb0d95b 100644 --- a/arch/arm/src/arm/Toolchain.defs +++ b/arch/arm/src/arm/Toolchain.defs @@ -34,13 +34,7 @@ ifeq ($(filter y, \ endif ifeq ($(filter y, \ - $(CONFIG_ARM_TOOLCHAIN_GNU_EABIL) \ - ),y) - CONFIG_ARM_TOOLCHAIN ?= GNU_EABI -endif - -ifeq ($(filter y, \ - $(CONFIG_ARM_TOOLCHAIN_GNU_EABIW) \ + $(CONFIG_ARM_TOOLCHAIN_GNU_EABI) \ ),y) CONFIG_ARM_TOOLCHAIN ?= GNU_EABI endif @@ -57,20 +51,28 @@ endif # CROSSDEV The GNU toolchain triple (command prefix) # ARCHCPUFLAGS CPU-specific flags selecting the instruction set # FPU options, etc. -# MAXOPTIMIZATION The maximum optimization level that results in +# ARCHOPTIMIZATION The optimization level that results in # reliable code generation. # ifeq ($(CONFIG_DEBUG_CUSTOMOPT),y) - MAXOPTIMIZATION := $(CONFIG_DEBUG_OPTLEVEL) -else - MAXOPTIMIZATION ?= -Os + ARCHOPTIMIZATION += $(CONFIG_DEBUG_OPTLEVEL) +else ifeq ($(CONFIG_DEBUG_FULLOPT),y) + ARCHOPTIMIZATION += -Os +endif + +ifneq ($(CONFIG_DEBUG_NOOPT),y) + ARCHOPTIMIZATION += -fno-strict-aliasing endif ifeq ($(CONFIG_FRAME_POINTER),y) - MAXOPTIMIZATION += -fno-omit-frame-pointer -fno-optimize-sibling-calls + ARCHOPTIMIZATION += -fno-omit-frame-pointer -fno-optimize-sibling-calls else - MAXOPTIMIZATION += -fomit-frame-pointer + ARCHOPTIMIZATION += -fomit-frame-pointer +endif + +ifeq ($(CONFIG_STACK_CANARIES),y) + ARCHOPTIMIZATION += -fstack-protector-all endif ifeq ($(CONFIG_MM_KASAN),y) @@ -93,26 +95,69 @@ ifeq ($(CONFIG_ARM_TOOLCHAIN),GNU_EABI) CROSSDEV ?= arm-none-eabi- endif +ARCHCFLAGS += -fno-common +ARCHCXXFLAGS += -fno-common -nostdinc++ + +ifneq ($(CONFIG_CXX_EXCEPTION),y) + ARCHCXXFLAGS += -fno-exceptions -fcheck-new +endif + +ifneq ($(CONFIG_CXX_RTTI),y) + ARCHCXXFLAGS += -fno-rtti +endif + +# Optimization of unused sections + +ifeq ($(CONFIG_DEBUG_OPT_UNUSED_SECTIONS),y) + LDFLAGS += --gc-sections + ARCHOPTIMIZATION += -ffunction-sections -fdata-sections +endif + +# Debug link map + +ifeq ($(CONFIG_DEBUG_LINK_MAP),y) + LDFLAGS += --cref -Map=$(call CONVERT_PATH,$(TOPDIR)$(DELIM)nuttx.map) +endif + +ifeq ($(CONFIG_DEBUG_SYMBOLS),y) + LDFLAGS += -g + ARCHOPTIMIZATION += -g +endif + # Default toolchain -CC = $(CROSSDEV)gcc -CXX = $(CROSSDEV)g++ -CPP = $(CROSSDEV)gcc -E -P -x c -LD = $(CROSSDEV)ld -STRIP = $(CROSSDEV)strip --strip-unneeded -AR = $(CROSSDEV)ar rcs -NM = $(CROSSDEV)nm +CC = $(CROSSDEV)gcc +CXX = $(CROSSDEV)g++ +CPP = $(CROSSDEV)gcc -E -P -x c +STRIP = $(CROSSDEV)strip --strip-unneeded OBJCOPY = $(CROSSDEV)objcopy OBJDUMP = $(CROSSDEV)objdump +LD = $(CROSSDEV)ld +AR = $(CROSSDEV)ar rcs +NM = $(CROSSDEV)nm + +# Link Time Optimization + +ifeq ($(CONFIG_LTO_FULL),y) + ARCHOPTIMIZATION += -flto + ifeq ($(CONFIG_ARM_TOOLCHAIN),GNU_EABI) + LD := $(CROSSDEV)gcc + AR := $(CROSSDEV)gcc-ar rcs + NM := $(CROSSDEV)gcc-nm + ARCHOPTIMIZATION += -fuse-linker-plugin + ARCHOPTIMIZATION += -fno-builtin + ARCHOPTIMIZATION += -nodefaultlibs + endif +endif # Add the builtin library -EXTRA_LIBS += ${wildcard ${shell $(CC) $(ARCHCPUFLAGS) --print-libgcc-file-name}} +EXTRA_LIBS += $(wildcard $(shell $(CC) $(ARCHCPUFLAGS) --print-libgcc-file-name)) ifneq ($(CONFIG_LIBM),y) - EXTRA_LIBS += ${wildcard ${shell $(CC) $(ARCHCPUFLAGS) --print-file-name=libm.a}} + EXTRA_LIBS += $(wildcard $(shell $(CC) $(ARCHCPUFLAGS) --print-file-name=libm.a)) endif ifeq ($(CONFIG_LIBSUPCXX),y) - EXTRA_LIBS += ${wildcard ${shell $(CC) $(ARCHCPUFLAGS) --print-file-name=libsupc++.a}} + EXTRA_LIBS += $(wildcard $(shell $(CC) $(ARCHCPUFLAGS) --print-file-name=libsupc++.a)) endif diff --git a/arch/arm/src/arm/arm_allocpage.c b/arch/arm/src/arm/arm_allocpage.c index 27de03bd29e56..480a034674ca9 100644 --- a/arch/arm/src/arm/arm_allocpage.c +++ b/arch/arm/src/arm/arm_allocpage.c @@ -150,7 +150,7 @@ static bool g_pgwrap; * ****************************************************************************/ -int up_allocpage(FAR struct tcb_s *tcb, FAR void **vpage) +int up_allocpage(struct tcb_s *tcb, void **vpage) { uintptr_t vaddr; uintptr_t paddr; diff --git a/arch/arm/src/arm/arm_checkmapping.c b/arch/arm/src/arm/arm_checkmapping.c index 80cb2b3dc4ddf..fd935ec72a7de 100644 --- a/arch/arm/src/arm/arm_checkmapping.c +++ b/arch/arm/src/arm/arm_checkmapping.c @@ -83,7 +83,7 @@ * ****************************************************************************/ -bool up_checkmapping(FAR struct tcb_s *tcb) +bool up_checkmapping(struct tcb_s *tcb) { uintptr_t vaddr; uint32_t *pte; diff --git a/arch/arm/src/arm/arm_doirq.c b/arch/arm/src/arm/arm_doirq.c index 03d58ec743ba8..6b5a97986fdaa 100644 --- a/arch/arm/src/arm/arm_doirq.c +++ b/arch/arm/src/arm/arm_doirq.c @@ -79,7 +79,7 @@ void arm_doirq(int irq, uint32_t *regs) irq_dispatch(irq, regs); -#if defined(CONFIG_ARCH_FPU) || defined(CONFIG_ARCH_ADDRENV) +#ifdef CONFIG_ARCH_ADDRENV /* Check for a context switch. If a context switch occurred, then * CURRENT_REGS will have a different value than it did on entry. If an * interrupt level context switch has occurred, then restore the floating @@ -89,13 +89,6 @@ void arm_doirq(int irq, uint32_t *regs) if (regs != CURRENT_REGS) { -#ifdef CONFIG_ARCH_FPU - /* Restore floating point registers */ - - arm_restorefpu((uint32_t *)CURRENT_REGS); -#endif - -#ifdef CONFIG_ARCH_ADDRENV /* Make sure that the address environment for the previously * running task is closed down gracefully (data caches dump, * MMU flushed) and set up the address environment for the new @@ -103,7 +96,6 @@ void arm_doirq(int irq, uint32_t *regs) */ group_addrenv(NULL); -#endif } #endif diff --git a/arch/arm/src/arm/arm_initialstate.c b/arch/arm/src/arm/arm_initialstate.c index e4e0c74914fe1..67de03095c17e 100644 --- a/arch/arm/src/arm/arm_initialstate.c +++ b/arch/arm/src/arm/arm_initialstate.c @@ -82,9 +82,9 @@ void up_initial_state(struct tcb_s *tcb) /* Initialize the context registers to stack top */ - xcp->regs = (FAR void *)((uint32_t)tcb->stack_base_ptr + - tcb->adj_stack_size - - XCPTCONTEXT_SIZE); + xcp->regs = (void *)((uint32_t)tcb->stack_base_ptr + + tcb->adj_stack_size - + XCPTCONTEXT_SIZE); /* Initialize the xcp registers */ diff --git a/arch/arm/src/arm/arm_saveusercontext.S b/arch/arm/src/arm/arm_saveusercontext.S deleted file mode 100644 index fe16a3a4b6001..0000000000000 --- a/arch/arm/src/arm/arm_saveusercontext.S +++ /dev/null @@ -1,100 +0,0 @@ -/**************************************************************************** - * arch/arm/src/arm/arm_saveusercontext.S - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. The - * ASF licenses this file to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance with the - * License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - ****************************************************************************/ - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include -#include - -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -/**************************************************************************** - * Public Symbols - ****************************************************************************/ - - .file "arm_saveusercontext.S" - -/**************************************************************************** - * Macros - ****************************************************************************/ - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: arm_saveusercontext - * - * Description: - * Save the current thread context. Full prototype is: - * - * int arm_saveusercontext(uint32_t *saveregs); - * - * Returned Value: - * 0: Normal return - * 1: Context switch return - * - ****************************************************************************/ - - .globl arm_saveusercontext - .type arm_saveusercontext, function -arm_saveusercontext: - - /* On entry, a1 (r0) holds address of struct xcptcontext */ - - /* Make sure that the return value will be non-zero (the value of the - * other volatile registers don't matter -- r1-r3, ip). This function - * is called through the normal C calling conventions and the values of - * these registers cannot be assumed at the point of setjmp return. - */ - - mov ip, #1 - str ip, [r0, #(4*REG_R0)] - - /* Save the volatile registers (plus r12 which really - * doesn't need to be saved) - */ - - add r1, r0, #(4*REG_R4) - stmia r1, {r4-r14} - - /* Save the current cpsr */ - - mrs r2, cpsr /* R2 = CPSR value */ - add r1, r0, #(4*REG_CPSR) - str r2, [r1] - - /* Save the return address as the PC so that we return to the exit from - * this function. - */ - - add r1, r0, #(4*REG_PC) - str lr, [r1] - - /* Return 0 now indicating that this return is not a context switch */ - - mov r0, #0 /* Return value == 0 */ - bx lr /* Return */ - .size arm_saveusercontext, .-arm_saveusercontext - .end diff --git a/arch/arm/src/arm/arm_schedulesigaction.c b/arch/arm/src/arm/arm_schedulesigaction.c index 2d37ec6ed8325..f7b7847e89cb4 100644 --- a/arch/arm/src/arm/arm_schedulesigaction.c +++ b/arch/arm/src/arm/arm_schedulesigaction.c @@ -134,10 +134,10 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver) * delivered. */ - CURRENT_REGS = (FAR void *) + CURRENT_REGS = (void *) ((uint32_t)CURRENT_REGS - (uint32_t)XCPTCONTEXT_SIZE); - memcpy((FAR uint32_t *)CURRENT_REGS, tcb->xcp.saved_regs, + memcpy((uint32_t *)CURRENT_REGS, tcb->xcp.saved_regs, XCPTCONTEXT_SIZE); CURRENT_REGS[REG_SP] = (uint32_t)CURRENT_REGS + @@ -176,7 +176,7 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver) * delivered. */ - tcb->xcp.regs = (FAR void *) + tcb->xcp.regs = (void *) ((uint32_t)tcb->xcp.regs - (uint32_t)XCPTCONTEXT_SIZE); memcpy(tcb->xcp.regs, tcb->xcp.saved_regs, XCPTCONTEXT_SIZE); diff --git a/arch/arm/src/arm/arm_syscall.c b/arch/arm/src/arm/arm_syscall.c index 06687dfd495f9..d12cf751fc422 100644 --- a/arch/arm/src/arm/arm_syscall.c +++ b/arch/arm/src/arm/arm_syscall.c @@ -32,6 +32,7 @@ #include #include "arm_internal.h" +#include "group/group.h" /**************************************************************************** * Public Functions @@ -54,10 +55,22 @@ uint32_t *arm_syscall(uint32_t *regs) { uint32_t cmd; - DEBUGASSERT(regs); + /* Nested interrupts are not supported */ + + DEBUGASSERT(CURRENT_REGS == NULL); + + /* Current regs non-zero indicates that we are processing an interrupt; + * CURRENT_REGS is also used to manage interrupt level context switches. + */ + + CURRENT_REGS = regs; + + /* The SYSCALL command is in R0 on entry. Parameters follow in R1..R7 */ cmd = regs[REG_R0]; + /* Handle the SVCall according to the command in R0 */ + switch (cmd) { /* R0=SYS_restore_context: Restore task context @@ -78,8 +91,8 @@ uint32_t *arm_syscall(uint32_t *regs) * set will determine the restored context. */ - regs = (uint32_t *)regs[REG_R1]; - DEBUGASSERT(regs); + CURRENT_REGS = (uint32_t *)regs[REG_R1]; + DEBUGASSERT(CURRENT_REGS); } break; @@ -104,7 +117,7 @@ uint32_t *arm_syscall(uint32_t *regs) { DEBUGASSERT(regs[REG_R1] != 0 && regs[REG_R2] != 0); *(uint32_t **)regs[REG_R1] = regs; - regs = (uint32_t *)regs[REG_R2]; + CURRENT_REGS = (uint32_t *)regs[REG_R2]; } break; @@ -112,12 +125,37 @@ uint32_t *arm_syscall(uint32_t *regs) { svcerr("ERROR: Bad SYS call: 0x%" PRIx32 "\n", regs[REG_R0]); _alert("Syscall from 0x%" PRIx32 "\n", regs[REG_PC]); - CURRENT_REGS = regs; PANIC(); } break; } +#ifdef CONFIG_ARCH_ADDRENV + /* Check for a context switch. If a context switch occurred, then + * CURRENT_REGS will have a different value than it did on entry. If an + * interrupt level context switch has occurred, then establish the correct + * address environment before returning from the interrupt. + */ + + if (regs != CURRENT_REGS) + { + /* Make sure that the address environment for the previously + * running task is closed down gracefully (data caches dump, + * MMU flushed) and set up the address environment for the new + * thread at the head of the ready-to-run list. + */ + + group_addrenv(NULL); + } +#endif + + /* Set CURRENT_REGS to NULL to indicate that we are no longer in an + * interrupt handler. + */ + + regs = (uint32_t *)CURRENT_REGS; + CURRENT_REGS = NULL; + /* Return the last value of curent_regs. This supports context switches * on return from the exception. That capability is only used with the * SYS_context_switch system call. diff --git a/arch/arm/src/arm/arm_tcbinfo.c b/arch/arm/src/arm/arm_tcbinfo.c index ad350f5c978ba..5540d8fc84adc 100644 --- a/arch/arm/src/arm/arm_tcbinfo.c +++ b/arch/arm/src/arm/arm_tcbinfo.c @@ -60,11 +60,13 @@ static const uint16_t g_reg_offs[] = const struct tcbinfo_s g_tcbinfo = { - TCB_PID_OFF, - TCB_STATE_OFF, - TCB_PRI_OFF, - TCB_NAME_OFF, - XCPTCONTEXT_REGS, + .pid_off = TCB_PID_OFF, + .state_off = TCB_STATE_OFF, + .pri_off = TCB_PRI_OFF, + .name_off = TCB_NAME_OFF, + .regs_off = TCB_REGS_OFF, + .basic_num = 17, + .total_num = XCPTCONTEXT_REGS, { .p = g_reg_offs, }, diff --git a/arch/arm/src/arm/arm_vectors.S b/arch/arm/src/arm/arm_vectors.S index e6f4d047ef4ab..fa30eed4dcf19 100644 --- a/arch/arm/src/arm/arm_vectors.S +++ b/arch/arm/src/arm/arm_vectors.S @@ -41,6 +41,66 @@ * Assembly Macros ****************************************************************************/ +/**************************************************************************** + * Name: savefpu + * + * Description: + * Save the state of the floating point registers. + * + ****************************************************************************/ + +#ifdef CONFIG_ARCH_FPU + .macro savefpu, out, tmp + /* Store all floating point registers. Registers are stored in numeric order, + * s0, s1, ... in increasing address order. + */ + +#ifdef CONFIG_ARM_DPFPU32 + vstmia.64 \out!, {d0-d15} /* Save the full FP context */ + vstmia.64 \out!, {d16-d31} +#else + vstmia \out!, {s0-s31} /* Save the full FP context */ +#endif + + /* Store the floating point control and status register. At the end of the + * vstmia, r1 will point to the FPSCR storage location. + */ + + vmrs \tmp, fpscr /* Fetch the FPSCR */ + str \tmp, [\out], #4 /* Save the floating point control and status register */ + .endm +#endif + +/**************************************************************************** + * Name: restorefpu + * + * Description: + * Restore the state of the floating point registers. + * + ****************************************************************************/ + +#ifdef CONFIG_ARCH_FPU + .macro restorefpu, in, tmp + /* Load all floating point registers. Registers are loaded in numeric order, + * s0, s1, ... in increasing address order. + */ + +#ifdef CONFIG_ARM_DPFPU32 + vldmia.64 \in!, {d0-d15} /* Restore the full FP context */ + vldmia.64 \in!, {d16-d31} +#else + vldmia \in!, {s0-s31} /* Restore the full FP context */ +#endif + + /* Load the floating point control and status register. At the end of the + * vstmia, \in will point to the FPSCR storage location. + */ + + ldr \tmp, [\in], #4 /* Fetch the floating point control and status register */ + vmsr fpscr, \tmp /* Restore the FPSCR */ + .endm +#endif + /**************************************************************************** * Private Functions ****************************************************************************/ @@ -101,6 +161,13 @@ arm_vectorirq: add r0, sp, #(4*REG_SP) /* Offset to pc, cpsr storage */ stmia r0, {r1-r4} +#ifdef CONFIG_ARCH_FPU + /* Save the state of the floating point registers. */ + + add r0, sp, #(4*REG_S0) /* R1=Address of FP register storage */ + savefpu r0, r1 +#endif + /* Then call the IRQ handler with interrupts disabled. */ mov fp, #0 /* Init frame pointer */ @@ -116,7 +183,7 @@ arm_vectorirq: #else /* Call arm_decodeirq() on the user stack */ - mov r4, sp /* Save the SP in a preserved register */ + mov r4, sp /* Save the SP in a preserved register */ /* If the interrupt stack is disabled, reserve xcpcontext to ensure * that signal processing can have a separate xcpcontext to handle @@ -131,17 +198,35 @@ arm_vectorirq: sub sp, sp, #XCPTCONTEXT_SIZE /* Reserve signal context */ - bic sp, sp, #7 /* Force 8-byte alignment */ - bl arm_decodeirq /* Call the handler */ - mov sp, r4 /* Restore the possibly unaligned stack pointer */ + bic sp, sp, #7 /* Force 8-byte alignment */ + bl arm_decodeirq /* Call the handler */ + mov sp, r4 /* Restore the possibly unaligned stack pointer */ #endif +#ifdef CONFIG_ARCH_FPU + /* Restore the state of the floating point registers. */ + + add r1, r0, #(4*REG_S0) /* R1=Address of FP register storage */ + restorefpu r1, r2 +#endif + + /* Switch back IRQ mode and return with shadow SPSR */ + + mov r4, #(PSR_MODE_IRQ | PSR_I_BIT) + msr cpsr_c, r4 /* Switch back IRQ mode */ + /* Restore the CPSR, SYS mode registers and return */ ldr r0, [sp, #(4*REG_CPSR)] /* Fetch the return SPSR */ msr spsr_cxsf, r0 /* Set the return mode SPSR */ - ldmia sp, {r0-r15}^ /* Return */ + /* Life is simple when everything is IRQ mode */ + + mov r14, sp /* (IRQ) r14=Register storage area */ + ldmia r14!, {r0-r12} /* Restore common r0-r12 */ + ldmia r14, {r13, r14}^ /* Restore user mode r13/r14 */ + add r14, r14, #(4*2) /* (IRQ) r14=address of r15 storage */ + ldmia r14, {r15}^ /* Return */ #if CONFIG_ARCH_INTERRUPTSTACK > 3 .Lirqstacktop: @@ -201,6 +286,13 @@ arm_vectorsvc: add r0, sp, #(4*REG_SP) /* Offset to pc, cpsr storage */ stmia r0, {r1-r4} +#ifdef CONFIG_ARCH_FPU + /* Save the state of the floating point registers. */ + + add r0, sp, #(4*REG_S0) /* R1=Address of FP register storage */ + savefpu r0, r1 +#endif + /* Then call the SVC handler with interrupts disabled. * void arm_syscall(struct xcptcontext *xcp) */ @@ -209,12 +301,30 @@ arm_vectorsvc: mov r0, sp /* Get r0=xcp */ bl arm_syscall /* Call the handler */ +#ifdef CONFIG_ARCH_FPU + /* Restore the state of the floating point registers. */ + + add r1, r0, #(4*REG_S0) /* R1=Address of FP register storage */ + restorefpu r1, r2 +#endif + + /* Switch back SVC mode and return with shadow SPSR */ + + mov r4, #(PSR_MODE_SVC | PSR_I_BIT) + msr cpsr_c, r4 /* Switch back SVC mode */ + /* Restore the CPSR, SYS mode registers and return */ ldr r0, [sp, #(4*REG_CPSR)] /* Fetch the return SPSR */ msr spsr_cxsf, r0 /* Set the return mode SPSR */ - ldmia sp, {r0-r15}^ /* Return */ + /* Life is simple when everything is SVC mode */ + + mov r14, sp /* (SVC) r14=Register storage area */ + ldmia r14!, {r0-r12} /* Restore common r0-r12 */ + ldmia r14, {r13, r14}^ /* Restore user mode r13/r14 */ + add r14, r14, #(4*2) /* (SVC) r14=address of r15 storage */ + ldmia r14, {r15}^ /* Return */ .size arm_vectorsvc, . - arm_vectorsvc .align 5 @@ -272,6 +382,13 @@ arm_vectordata: add r0, sp, #(4*REG_SP) /* Offset to pc, cpsr storage */ stmia r0, {r1-r4} +#ifdef CONFIG_ARCH_FPU + /* Save the state of the floating point registers. */ + + add r0, sp, #(4*REG_S0) /* R1=Address of FP register storage */ + savefpu r0, r1 +#endif + /* Then call the data abort handler with interrupts disabled. * void arm_dataabort(struct xcptcontext *xcp) */ @@ -284,12 +401,30 @@ arm_vectordata: #endif bl arm_dataabort /* Call the handler */ +#ifdef CONFIG_ARCH_FPU + /* Restore the state of the floating point registers. */ + + add r1, r0, #(4*REG_S0) /* R1=Address of FP register storage */ + restorefpu r1, r2 +#endif + + /* Switch back ABT mode and return with shadow SPSR */ + + mov r4, #(PSR_MODE_ABT | PSR_I_BIT) + msr cpsr_c, r4 /* Switch back ABT mode */ + /* Restore the CPSR, SYS mode registers and return */ ldr r0, [sp, #(4*REG_CPSR)] /* Fetch the return SPSR */ msr spsr_cxsf, r0 /* Set the return mode SPSR */ - ldmia sp, {r0-r15}^ /* Return */ + /* Life is simple when everything is ABT mode */ + + mov r14, sp /* (ABT) r14=Register storage area */ + ldmia r14!, {r0-r12} /* Restore common r0-r12 */ + ldmia r14, {r13, r14}^ /* Restore user mode r13/r14 */ + add r14, r14, #(4*2) /* (ABT) r14=address of r15 storage */ + ldmia r14, {r15}^ /* Return */ .size arm_vectordata, . - arm_vectordata .align 5 @@ -347,6 +482,13 @@ arm_vectorprefetch: add r0, sp, #(4*REG_SP) /* Offset to pc, cpsr storage */ stmia r0, {r1-r4} +#ifdef CONFIG_ARCH_FPU + /* Save the state of the floating point registers. */ + + add r0, sp, #(4*REG_S0) /* R1=Address of FP register storage */ + savefpu r0, r1 +#endif + /* Then call the prefetch abort handler with interrupts disabled. * void arm_prefetchabort(struct xcptcontext *xcp) */ @@ -355,12 +497,30 @@ arm_vectorprefetch: mov r0, sp /* Get r0=xcp */ bl arm_prefetchabort /* Call the handler */ +#ifdef CONFIG_ARCH_FPU + /* Restore the state of the floating point registers. */ + + add r1, r0, #(4*REG_S0) /* R1=Address of FP register storage */ + restorefpu r1, r2 +#endif + + /* Switch back ABT mode and return with shadow SPSR */ + + mov r4, #(PSR_MODE_ABT | PSR_I_BIT) + msr cpsr_c, r4 /* Switch back ABT mode */ + /* Restore the CPSR, SYS mode registers and return */ ldr r0, [sp, #(4*REG_CPSR)] /* Fetch the return SPSR */ msr spsr_cxsf, r0 /* Set the return mode SPSR */ - ldmia sp, {r0-r15}^ /* Return */ + /* Life is simple when everything is ABT mode */ + + mov r14, sp /* (ABT) r14=Register storage area */ + ldmia r14!, {r0-r12} /* Restore common r0-r12 */ + ldmia r14, {r13, r14}^ /* Restore user mode r13/r14 */ + add r14, r14, #(4*2) /* (ABT) r14=address of r15 storage */ + ldmia r14, {r15}^ /* Return */ .size arm_vectorprefetch, . - arm_vectorprefetch .align 5 @@ -416,6 +576,13 @@ arm_vectorundefinsn: add r0, sp, #(4*REG_SP) /* Offset to pc, cpsr storage */ stmia r0, {r1-r4} +#ifdef CONFIG_ARCH_FPU + /* Save the state of the floating point registers. */ + + add r0, sp, #(4*REG_S0) /* R1=Address of FP register storage */ + savefpu r0, r1 +#endif + /* Then call the undef insn handler with interrupts disabled. * void arm_undefinedinsn(struct xcptcontext *xcp) */ @@ -424,12 +591,30 @@ arm_vectorundefinsn: mov r0, sp /* Get r0=xcp */ bl arm_undefinedinsn /* Call the handler */ +#ifdef CONFIG_ARCH_FPU + /* Restore the state of the floating point registers. */ + + add r1, r0, #(4*REG_S0) /* R1=Address of FP register storage */ + restorefpu r1, r2 +#endif + + /* Switch back UND mode and return with shadow SPSR */ + + mov r4, #(PSR_MODE_UND | PSR_I_BIT) + msr cpsr_c, r4 /* Switch back UND mode */ + /* Restore the CPSR, SYS mode registers and return */ ldr r0, [sp, #(4*REG_CPSR)] /* Fetch the return SPSR */ msr spsr_cxsf, r0 /* Set the return mode SPSR */ - ldmia sp, {r0-r15}^ /* Return */ + /* Life is simple when everything is UND mode */ + + mov r14, sp /* (FIQ) r14=Register storage area */ + ldmia r14!, {r0-r7} /* Restore common r0-r7 */ + ldmia r14, {r8-r14}^ /* Restore user mode r8-r14 */ + add r14, r14, #(4*7) /* (FIQ) r14=address of r15 storage */ + ldmia r14, {r15}^ /* Return */ .size arm_vectorundefinsn, . - arm_vectorundefinsn .align 5 diff --git a/arch/arm/src/arm/vfork.S b/arch/arm/src/arm/vfork.S deleted file mode 100644 index 4abdf511bf028..0000000000000 --- a/arch/arm/src/arm/vfork.S +++ /dev/null @@ -1,124 +0,0 @@ -/**************************************************************************** - * arch/arm/src/arm/vfork.S - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. The - * ASF licenses this file to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance with the - * License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - ****************************************************************************/ - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include - -#include "arm_vfork.h" - -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -/**************************************************************************** - * Public Symbols - ****************************************************************************/ - - .file "vfork.S" - .globl up_vfork - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: vfork - * - * Description: - * The vfork() function has the same effect as fork(), except that the - * behavior is undefined if the process created by vfork() either modifies - * any data other than a variable of type pid_t used to store the return - * value from vfork(), or returns from the function in which vfork() was - * called, or calls any other function before successfully calling _exit() - * or one of the exec family of functions. - * - * This thin layer implements vfork by simply calling up_vfork() with the - * vfork() context as an argument. The overall sequence is: - * - * 1) User code calls vfork(). vfork() collects context information and - * transfers control up up_vfork(). - * 2) up_vfork() and calls nxtask_setup_vfork(). - * 3) nxtask_setup_vfork() allocates and configures the child task's TCB. - * This consists of: - * - Allocation of the child task's TCB. - * - Initialization of file descriptors and streams - * - Configuration of environment variables - * - Allocate and initialize the stack - * - Setup the input parameters for the task. - * - Initialization of the TCB (including call to up_initial_state()) - * 4) up_vfork() provides any additional operating context. up_vfork must: - * - Initialize special values in any CPU registers that were not - * already configured by up_initial_state() - * 5) up_vfork() then calls nxtask_start_vfork() - * 6) nxtask_start_vfork() then executes the child thread. - * - * Input Parameters: - * None - * - * Returned Value: - * Upon successful completion, vfork() returns 0 to the child process and - * returns the process ID of the child process to the parent process. - * Otherwise, -1 is returned to the parent, no child process is created, - * and errno is set to indicate the error. - * - ****************************************************************************/ - - .globl vfork - .type vfork, function -vfork: - /* Create a stack frame */ - - mov r0, sp /* Save the value of the stack on entry */ - sub sp, sp, #VFORK_SIZEOF /* Allocate the structure on the stack */ - - /* CPU registers */ - /* Save the volatile registers */ - - str r4, [sp, #VFORK_R4_OFFSET] - str r5, [sp, #VFORK_R5_OFFSET] - str r6, [sp, #VFORK_R6_OFFSET] - str r7, [sp, #VFORK_R7_OFFSET] - str r8, [sp, #VFORK_R8_OFFSET] - str r9, [sp, #VFORK_R9_OFFSET] - str r10, [sp, #VFORK_R10_OFFSET] - - /* Save the frame pointer, stack pointer, and return address */ - - str fp, [sp, #VFORK_FP_OFFSET] - str r0, [sp, #VFORK_SP_OFFSET] - str lr, [sp, #VFORK_LR_OFFSET] - - /* Floating point registers (not yet) */ - - /* Then, call up_vfork(), passing it a pointer to the stack structure */ - - mov r0, sp - bl up_vfork - - /* Release the stack data and return the value returned by up_vfork */ - - ldr lr, [sp, #VFORK_LR_OFFSET] - add sp, sp, #VFORK_SIZEOF - bx lr - .size vfork, .-vfork - .end diff --git a/arch/arm/src/armv6-m/Kconfig b/arch/arm/src/armv6-m/Kconfig index bd44674dfe06b..5268d48c73711 100644 --- a/arch/arm/src/armv6-m/Kconfig +++ b/arch/arm/src/armv6-m/Kconfig @@ -7,27 +7,21 @@ comment "ARMv6-M Configuration Options" choice prompt "Toolchain Selection" - default ARMV6M_TOOLCHAIN_GNU_EABIW if TOOLCHAIN_WINDOWS - default ARMV6M_TOOLCHAIN_GNU_EABIL if !TOOLCHAIN_WINDOWS + default ARMV6M_TOOLCHAIN_GNU_EABI config ARMV6M_TOOLCHAIN_BUILDROOT bool "Buildroot (Cygwin or Linux)" - depends on !WINDOWS_NATIVE select ARCH_TOOLCHAIN_GNU -config ARMV6M_TOOLCHAIN_GNU_EABIL - bool "Generic GNU EABI toolchain under Linux (or other POSIX environment)" +config ARMV6M_TOOLCHAIN_GNU_EABI + bool "Generic GNU EABI toolchain" select ARCH_TOOLCHAIN_GNU ---help--- This option should work for any modern GNU toolchain (GCC 4.5 or newer) configured for arm-none-eabi. -config ARMV6M_TOOLCHAIN_GNU_EABIW - bool "Generic GNU EABI toolchain under Windows" - depends on TOOLCHAIN_WINDOWS - select CYGWIN_WINTOOL if WINDOWS_CYGWIN - ---help--- - This option should work for any modern GNU toolchain (GCC 4.5 or newer) - configured for arm-none-eabi. +config ARMV6M_TOOLCHAIN_CLANG + bool "Generic Clang toolchain" + select ARCH_TOOLCHAIN_CLANG endchoice diff --git a/arch/arm/src/armv6-m/Make.defs b/arch/arm/src/armv6-m/Make.defs new file mode 100644 index 0000000000000..a99c4879615bd --- /dev/null +++ b/arch/arm/src/armv6-m/Make.defs @@ -0,0 +1,37 @@ +############################################################################ +# arch/arm/src/armv6-m/Make.defs +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. The +# ASF licenses this file to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance with the +# License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +# +############################################################################ + +# Common ARM files + +include common/Make.defs + +CMN_ASRCS += arm_exception.S + +CMN_CSRCS += arm_doirq.c arm_hardfault.c arm_initialstate.c +CMN_CSRCS += arm_schedulesigaction.c arm_sigdeliver.c arm_svcall.c +CMN_CSRCS += arm_systemreset.c arm_tcbinfo.c arm_vectors.c + +ifeq ($(CONFIG_DEBUG_FEATURES),y) + CMN_CSRCS += arm_dumpnvic.c +endif + +ifeq ($(CONFIG_ARCH_RAMVECTORS),y) + CMN_CSRCS += arm_ramvec_initialize.c arm_ramvec_attach.c +endif diff --git a/arch/arm/src/armv6-m/Toolchain.defs b/arch/arm/src/armv6-m/Toolchain.defs index c08d23e5b79d2..bb184aac86192 100644 --- a/arch/arm/src/armv6-m/Toolchain.defs +++ b/arch/arm/src/armv6-m/Toolchain.defs @@ -31,12 +31,12 @@ ifeq ($(filter y, $(CONFIG_ARMV6M_TOOLCHAIN_BUILDROOT)),y) CONFIG_ARMV6M_TOOLCHAIN ?= BUILDROOT endif -ifeq ($(filter y, $(CONFIG_ARMV6M_TOOLCHAIN_GNU_EABIL)),y) +ifeq ($(filter y, $(CONFIG_ARMV6M_TOOLCHAIN_GNU_EABI)),y) CONFIG_ARMV6M_TOOLCHAIN ?= GNU_EABI endif -ifeq ($(filter y, $(CONFIG_ARMV6M_TOOLCHAIN_GNU_EABIW)),y) - CONFIG_ARMV6M_TOOLCHAIN ?= GNU_EABI +ifeq ($(filter y, $(CONFIG_ARMV6M_TOOLCHAIN_CLANG)),y) + CONFIG_ARMV6M_TOOLCHAIN ?= CLANG endif # @@ -51,60 +51,152 @@ endif # CROSSDEV The GNU toolchain triple (command prefix) # ARCHCPUFLAGS CPU-specific flags selecting the instruction set # options, etc. -# MAXOPTIMIZATION The maximum optimization level that results in +# ARCHOPTIMIZATION The optimization level that results in # reliable code generation. # ifeq ($(CONFIG_DEBUG_CUSTOMOPT),y) - MAXOPTIMIZATION := $(CONFIG_DEBUG_OPTLEVEL) -else - MAXOPTIMIZATION ?= -Os + ARCHOPTIMIZATION += $(CONFIG_DEBUG_OPTLEVEL) +else ifeq ($(CONFIG_DEBUG_FULLOPT),y) + ifeq ($(CONFIG_ARMV6M_TOOLCHAIN),CLANG) + ARCHOPTIMIZATION += -Oz + else + ARCHOPTIMIZATION += -Os + endif +endif + +ifneq ($(CONFIG_DEBUG_NOOPT),y) + ARCHOPTIMIZATION += -fno-strict-aliasing endif ifeq ($(CONFIG_FRAME_POINTER),y) - MAXOPTIMIZATION += -fno-omit-frame-pointer -fno-optimize-sibling-calls + ARCHOPTIMIZATION += -fno-omit-frame-pointer -fno-optimize-sibling-calls else - MAXOPTIMIZATION += -fomit-frame-pointer + ARCHOPTIMIZATION += -fomit-frame-pointer +endif + +ifeq ($(CONFIG_STACK_CANARIES),y) + ARCHOPTIMIZATION += -fstack-protector-all +endif + +# Parametrization for ARCHCPUFLAGS + +TOOLCHAIN_MTUNE := -mcpu=cortex-m0 -mthumb +TOOLCHAIN_MFLOAT := -mfloat-abi=soft + +# Clang Configuration files + +ifeq ($(CONFIG_ARMV6M_TOOLCHAIN),CLANG) + TOOLCHAIN_MARCH := --config armv6m_soft_nofp_nosys +endif + +# Link Time Optimization + +ifeq ($(CONFIG_LTO_THIN),y) + ARCHOPTIMIZATION += -flto=thin +else ifeq ($(CONFIG_LTO_FULL),y) + ARCHOPTIMIZATION += -flto endif # NuttX buildroot under Linux or Cygwin ifeq ($(CONFIG_ARMV6M_TOOLCHAIN),BUILDROOT) CROSSDEV ?= arm-nuttx-eabi- - ARCHCPUFLAGS = -mcpu=cortex-m0 -mthumb -mfloat-abi=soft + ARCHCPUFLAGS = $(TOOLCHAIN_MARCH) $(TOOLCHAIN_MTUNE) $(TOOLCHAIN_MFLOAT) endif # Generic GNU EABI toolchain ifeq ($(CONFIG_ARMV6M_TOOLCHAIN),GNU_EABI) CROSSDEV ?= arm-none-eabi- - ARCHCPUFLAGS = -mcpu=cortex-m0 -mthumb -mfloat-abi=soft + ARCHCPUFLAGS = $(TOOLCHAIN_MARCH) $(TOOLCHAIN_MTUNE) $(TOOLCHAIN_MFLOAT) endif +# Clang toolchain + +ifeq ($(CONFIG_ARMV6M_TOOLCHAIN),CLANG) + ARCHCPUFLAGS = $(TOOLCHAIN_MARCH) $(TOOLCHAIN_MTUNE) $(TOOLCHAIN_MFLOAT) + + CC = clang + CXX = clang++ + CPP = clang -E -P -x c + LD = ld.lld -m armelf + STRIP = llvm-strip --strip-unneeded + AR = llvm-ar rcs + NM = llvm-nm + OBJCOPY = llvm-objcopy + OBJDUMP = llvm-objdump + + # Since the no_builtin attribute is not fully supported on Clang + # disable the built-in functions, refer: + # https://github.com/apache/incubator-nuttx/pull/5971 + + ARCHOPTIMIZATION += -fno-builtin + +# Default toolchain + +else + CC = $(CROSSDEV)gcc + CXX = $(CROSSDEV)g++ + CPP = $(CROSSDEV)gcc -E -P -x c + LD = $(CROSSDEV)ld + STRIP = $(CROSSDEV)strip --strip-unneeded + AR = $(CROSSDEV)ar rcs + NM = $(CROSSDEV)nm + OBJCOPY = $(CROSSDEV)objcopy + OBJDUMP = $(CROSSDEV)objdump +endif + +# Architecture flags + ifeq ($(CONFIG_MM_KASAN),y) ARCHCPUFLAGS += -fsanitize=kernel-address endif -# Default toolchain +ARCHCFLAGS += -fno-common +ARCHCXXFLAGS += -fno-common -nostdinc++ + +ifneq ($(CONFIG_CXX_EXCEPTION),y) + ARCHCXXFLAGS += -fno-exceptions -fcheck-new +endif + +ifneq ($(CONFIG_CXX_RTTI),y) + ARCHCXXFLAGS += -fno-rtti +endif -CC = $(CROSSDEV)gcc -CXX = $(CROSSDEV)g++ -CPP = $(CROSSDEV)gcc -E -P -x c -LD = $(CROSSDEV)ld -STRIP = $(CROSSDEV)strip --strip-unneeded -AR = $(CROSSDEV)ar rcs -NM = $(CROSSDEV)nm -OBJCOPY = $(CROSSDEV)objcopy -OBJDUMP = $(CROSSDEV)objdump +# Optimization of unused sections + +ifeq ($(CONFIG_DEBUG_OPT_UNUSED_SECTIONS),y) + LDFLAGS += --gc-sections + ARCHOPTIMIZATION += -ffunction-sections -fdata-sections +endif + +# Debug link map + +ifeq ($(CONFIG_DEBUG_LINK_MAP),y) + LDFLAGS += --cref -Map=$(call CONVERT_PATH,$(TOPDIR)$(DELIM)nuttx.map) +endif + +ifeq ($(CONFIG_DEBUG_SYMBOLS),y) + LDFLAGS += -g + ARCHOPTIMIZATION += -g +endif # Add the builtin library -EXTRA_LIBS += ${wildcard ${shell $(CC) $(ARCHCPUFLAGS) --print-libgcc-file-name}} +COMPILER_RT_LIB = $(shell $(CC) $(ARCHCPUFLAGS) --print-libgcc-file-name) +ifeq ($(wildcard $(COMPILER_RT_LIB)),) + # if "--print-libgcc-file-name" unable to find the correct libgcc PATH + # then go ahead and try "--print-file-name" + COMPILER_RT_LIB := $(wildcard $(shell $(CC) $(ARCHCPUFLAGS) --print-file-name $(notdir $(COMPILER_RT_LIB)))) +endif + +EXTRA_LIBS += $(COMPILER_RT_LIB) ifneq ($(CONFIG_LIBM),y) - EXTRA_LIBS += ${wildcard ${shell $(CC) $(ARCHCPUFLAGS) --print-file-name=libm.a}} + EXTRA_LIBS += $(wildcard $(shell $(CC) $(ARCHCPUFLAGS) --print-file-name=libm.a)) endif ifeq ($(CONFIG_LIBSUPCXX),y) - EXTRA_LIBS += ${wildcard ${shell $(CC) $(ARCHCPUFLAGS) --print-file-name=libsupc++.a}} + EXTRA_LIBS += $(wildcard $(shell $(CC) $(ARCHCPUFLAGS) --print-file-name=libsupc++.a)) endif diff --git a/arch/arm/src/armv6-m/arm_dumpnvic.c b/arch/arm/src/armv6-m/arm_dumpnvic.c index de8522c1d4ab9..5213593073b17 100644 --- a/arch/arm/src/armv6-m/arm_dumpnvic.c +++ b/arch/arm/src/armv6-m/arm_dumpnvic.c @@ -46,7 +46,7 @@ * ****************************************************************************/ -void arm_dumpnvic(FAR const char *msg) +void arm_dumpnvic(const char *msg) { #ifdef CONFIG_DEBUG_INFO irqstate_t flags; diff --git a/arch/arm/src/armv6-m/arm_fullcontextrestore.S b/arch/arm/src/armv6-m/arm_fullcontextrestore.S deleted file mode 100644 index 5f27ea3907489..0000000000000 --- a/arch/arm/src/armv6-m/arm_fullcontextrestore.S +++ /dev/null @@ -1,79 +0,0 @@ -/**************************************************************************** - * arch/arm/src/armv6-m/arm_fullcontextrestore.S - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. The - * ASF licenses this file to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance with the - * License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - ****************************************************************************/ - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include -#include -#include - -#include "nvic.h" - -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -/**************************************************************************** - * Public Symbols - ****************************************************************************/ - - .file "arm_fullcontextrestore.S" - -/**************************************************************************** - * Macros - ****************************************************************************/ - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: arm_fullcontextrestore - * - * Description: - * Restore the current thread context. Full prototype is: - * - * void arm_fullcontextrestore(uint32_t *restoreregs) noreturn_function; - * - * Returned Value: - * None - * - ****************************************************************************/ - - .align 2 - .code 16 - .thumb_func - .globl arm_fullcontextrestore - .type arm_fullcontextrestore, function -arm_fullcontextrestore: - - /* Perform the System call with R0=1 and R1=regs */ - - mov r1, r0 /* R1: regs */ - mov r0, #SYS_restore_context /* R0: restore context */ - svc #SYS_syscall /* Force synchronous SVCall (or Hard Fault) */ - - /* This call should not return */ - - bx lr /* Unnecessary ... will not return */ - .size arm_fullcontextrestore, .-arm_fullcontextrestore - .end diff --git a/arch/arm/src/armv6-m/arm_hardfault.c b/arch/arm/src/armv6-m/arm_hardfault.c index 6684d0b08fbaf..8fea235e925fa 100644 --- a/arch/arm/src/armv6-m/arm_hardfault.c +++ b/arch/arm/src/armv6-m/arm_hardfault.c @@ -65,7 +65,7 @@ * ****************************************************************************/ -int arm_hardfault(int irq, FAR void *context, FAR void *arg) +int arm_hardfault(int irq, void *context, void *arg) { uint32_t *regs = (uint32_t *)context; diff --git a/arch/arm/src/armv6-m/arm_initialstate.c b/arch/arm/src/armv6-m/arm_initialstate.c index b3e068fc3de40..2153777318c6f 100644 --- a/arch/arm/src/armv6-m/arm_initialstate.c +++ b/arch/arm/src/armv6-m/arm_initialstate.c @@ -83,9 +83,9 @@ void up_initial_state(struct tcb_s *tcb) /* Initialize the context registers to stack top */ - xcp->regs = (FAR void *)((uint32_t)tcb->stack_base_ptr + - tcb->adj_stack_size - - XCPTCONTEXT_SIZE); + xcp->regs = (void *)((uint32_t)tcb->stack_base_ptr + + tcb->adj_stack_size - + XCPTCONTEXT_SIZE); /* Initialize the xcp registers */ diff --git a/arch/arm/src/armv6-m/arm_ramvec_initialize.c b/arch/arm/src/armv6-m/arm_ramvec_initialize.c index 2fe0b02a0aa81..226a14b669f76 100644 --- a/arch/arm/src/armv6-m/arm_ramvec_initialize.c +++ b/arch/arm/src/armv6-m/arm_ramvec_initialize.c @@ -100,7 +100,7 @@ void arm_ramvec_initialize(void) * protect against NULL pointer references. */ - src = (const CODE up_vector_t *)getreg32(ARMV6M_SYSCON_VECTAB); + src = (const up_vector_t *)getreg32(ARMV6M_SYSCON_VECTAB); dest = g_ram_vectors; irqinfo("src=%p dest=%p\n", src, dest); diff --git a/arch/arm/src/armv6-m/arm_saveusercontext.S b/arch/arm/src/armv6-m/arm_saveusercontext.S deleted file mode 100644 index 284a3f7ecdeaa..0000000000000 --- a/arch/arm/src/armv6-m/arm_saveusercontext.S +++ /dev/null @@ -1,89 +0,0 @@ -/**************************************************************************** - * arch/arm/src/armv6-m/arm_saveusercontext.S - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. The - * ASF licenses this file to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance with the - * License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - ****************************************************************************/ - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include -#include -#include - -#include "nvic.h" - -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -/**************************************************************************** - * Public Symbols - ****************************************************************************/ - - .file "arm_saveusercontext.S" - -/**************************************************************************** - * Macros - ****************************************************************************/ - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: arm_saveusercontext - * - * Description: - * Save the current thread context. Full prototype is: - * - * int arm_saveusercontext(uint32_t *saveregs); - * - * Returned Value: - * 0: Normal return - * 1: Context switch return - * - ****************************************************************************/ - - .text - .align 2 - .code 16 - .thumb_func - .globl arm_saveusercontext - .type arm_saveusercontext, function -arm_saveusercontext: - - /* Perform the System call with R0=0 and R1=regs */ - - mov r1, r0 /* R1: regs */ - mov r0, #SYS_save_context /* R0: save context (also return value) */ - svc #SYS_syscall /* Force synchronous SVCall (or Hard Fault) */ - - /* There are two return conditions. On the first return, R0 (the - * return value will be zero. On the second return we need to - * force R0 to be 1. - */ - - mov r3, #(4*REG_R0) /* R3=Offset to R0 storage */ - add r2, r1, r3 /* R2=Address of R0 storage */ - mov r3, #1 /* R3=Return value of one */ - str r3, [r2, #0] /* Save return value */ - bx lr /* "normal" return with r0=0 or - * context switch with r0=1 */ - .size arm_saveusercontext, .-arm_saveusercontext - .end diff --git a/arch/arm/src/armv6-m/arm_schedulesigaction.c b/arch/arm/src/armv6-m/arm_schedulesigaction.c index 1f30fed6de88d..a8e0788d3a88b 100644 --- a/arch/arm/src/armv6-m/arm_schedulesigaction.c +++ b/arch/arm/src/armv6-m/arm_schedulesigaction.c @@ -123,7 +123,7 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver) * delivered. */ - tcb->xcp.sigdeliver = (FAR void *)sigdeliver; + tcb->xcp.sigdeliver = (void *)sigdeliver; /* And make sure that the saved context in the TCB is the same * as the interrupt return context. @@ -136,10 +136,10 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver) * delivered. */ - CURRENT_REGS = (FAR void *) + CURRENT_REGS = (void *) ((uint32_t)CURRENT_REGS - (uint32_t)XCPTCONTEXT_SIZE); - memcpy((FAR uint32_t *)CURRENT_REGS, tcb->xcp.saved_regs, + memcpy((uint32_t *)CURRENT_REGS, tcb->xcp.saved_regs, XCPTCONTEXT_SIZE); CURRENT_REGS[REG_SP] = (uint32_t)CURRENT_REGS + @@ -172,7 +172,7 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver) * by the signal trampoline after the signal has been delivered. */ - tcb->xcp.sigdeliver = (FAR void *)sigdeliver; + tcb->xcp.sigdeliver = (void *)sigdeliver; /* Save the current register context location */ @@ -183,7 +183,7 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver) * delivered. */ - tcb->xcp.regs = (FAR void *) + tcb->xcp.regs = (void *) ((uint32_t)tcb->xcp.regs - (uint32_t)XCPTCONTEXT_SIZE); memcpy(tcb->xcp.regs, tcb->xcp.saved_regs, XCPTCONTEXT_SIZE); @@ -276,7 +276,7 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver) * been delivered. */ - tcb->xcp.sigdeliver = (FAR void *)sigdeliver; + tcb->xcp.sigdeliver = (void *)sigdeliver; /* Save the current register context location */ @@ -287,7 +287,7 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver) * been delivered. */ - tcb->xcp.regs = (FAR void *) + tcb->xcp.regs = (void *) ((uint32_t)tcb->xcp.regs - (uint32_t)XCPTCONTEXT_SIZE); memcpy(tcb->xcp.regs, tcb->xcp.saved_regs, @@ -318,7 +318,7 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver) * signal has been delivered. */ - tcb->xcp.sigdeliver = (FAR void *)sigdeliver; + tcb->xcp.sigdeliver = (void *)sigdeliver; /* And make sure that the saved context in the TCB is the * same as the interrupt return context. @@ -331,10 +331,10 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver) * been delivered. */ - CURRENT_REGS = (FAR void *) + CURRENT_REGS = (void *) ((uint32_t)CURRENT_REGS - (uint32_t)XCPTCONTEXT_SIZE); - memcpy((FAR uint32_t *)CURRENT_REGS, tcb->xcp.saved_regs, + memcpy((uint32_t *)CURRENT_REGS, tcb->xcp.saved_regs, XCPTCONTEXT_SIZE); CURRENT_REGS[REG_SP] = (uint32_t)CURRENT_REGS + @@ -388,7 +388,7 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver) * by the signal trampoline after the signal has been delivered. */ - tcb->xcp.sigdeliver = (FAR void *)sigdeliver; + tcb->xcp.sigdeliver = (void *)sigdeliver; /* Save the current register context location */ @@ -399,7 +399,7 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver) * delivered. */ - tcb->xcp.regs = (FAR void *) + tcb->xcp.regs = (void *) ((uint32_t)tcb->xcp.regs - (uint32_t)XCPTCONTEXT_SIZE); memcpy(tcb->xcp.regs, tcb->xcp.saved_regs, XCPTCONTEXT_SIZE); diff --git a/arch/arm/src/armv6-m/arm_signal_dispatch.c b/arch/arm/src/armv6-m/arm_signal_dispatch.c deleted file mode 100644 index 932a812d05ea4..0000000000000 --- a/arch/arm/src/armv6-m/arm_signal_dispatch.c +++ /dev/null @@ -1,76 +0,0 @@ -/**************************************************************************** - * arch/arm/src/armv6-m/arm_signal_dispatch.c - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. The - * ASF licenses this file to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance with the - * License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - ****************************************************************************/ - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include -#include - -#include - -#include "arm_internal.h" - -#if !defined(CONFIG_BUILD_FLAT) && defined(__KERNEL__) - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: up_signal_dispatch - * - * Description: - * In this kernel mode build, this function will be called to execute a - * a signal handler in user-space. When the signal is delivered, a - * kernel-mode stub will first run to perform some housekeeping functions. - * This kernel-mode stub will then be called transfer control to the user - * mode signal handler by calling this function. - * - * Normally the user-mode signalling handling stub will also execute - * before the ultimate signal handler is called. See - * arch/arm/src/armv6-m/arm_signal_handler.S. This function is the - * user-space, signal handler trampoline function. It is called from - * up_signal_dispatch() in user-mode. - * - * Input Parameters: - * sighand - The address user-space signal handling function - * signo, info, and ucontext - Standard arguments to be passed to the - * signal handling function. - * - * Returned Value: - * None. This function does not return in the normal sense. It returns - * via an architecture specific system call made by up_signal_handler(). - * However, this will look like a normal return by the caller of - * up_signal_dispatch. - * - ****************************************************************************/ - -void up_signal_dispatch(_sa_sigaction_t sighand, int signo, - FAR siginfo_t *info, FAR void *ucontext) -{ - /* Let sys_call4() do all of the work */ - - sys_call4(SYS_signal_handler, (uintptr_t)sighand, (uintptr_t)signo, - (uintptr_t)info, (uintptr_t)ucontext); -} - -#endif /* !CONFIG_BUILD_FLAT && __KERNEL__ */ diff --git a/arch/arm/src/armv6-m/arm_signal_handler.S b/arch/arm/src/armv6-m/arm_signal_handler.S deleted file mode 100644 index 1f76daa2f7ead..0000000000000 --- a/arch/arm/src/armv6-m/arm_signal_handler.S +++ /dev/null @@ -1,103 +0,0 @@ -/**************************************************************************** - * arch/arm/srcm/armv6-m/arm_signal_handler.S - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. The - * ASF licenses this file to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance with the - * License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - ****************************************************************************/ - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include - -#include - -#if defined(CONFIG_BUILD_PROTECTED) && !defined(__KERNEL__) - -/**************************************************************************** - * File info - ****************************************************************************/ - - .file "arm_signal_handler.S" - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: up_signal_handler - * - * Description: - * This function is the user-space, signal handler trampoline function. It - * is called from up_signal_dispatch() in user-mode. - * - * R0-R3, R11 - volatile registers need not be preserved. - * R4-R10 - static registers must be preserved - * R12-R14 - LR and SP must be preserved - * - * Input Parameters: - * R0 = sighand - * The address user-space signal handling function - * R1-R3 = signo, info, and ucontext - * Standard arguments to be passed to the signal handling function. - * - * Returned Value: - * None. This function does not return in the normal sense. It returns - * via the SYS_signal_handler_return (see syscall.h) - * - ****************************************************************************/ - - .text - .align 2 - .code 16 - .thumb_func - .globl up_signal_handler - .type up_signal_handler, function -up_signal_handler: - - /* Save some register */ - - push {r4, r5} /* Save R4 and R5 on the stack */ - mov r5, lr /* Save LR in R5 */ - - /* Call the signal handler */ - - mov r4, r0 /* R4=sighand */ - mov r0, r1 /* R0=signo */ - mov r1, r2 /* R1=info */ - mov r2, r3 /* R2=ucontext */ - blx r4 /* Call the signal handler */ - - /* Restore the registers */ - - mov lr, r5 /* Restore LR */ - pop {r4, r5} /* Restore R4 and R5 */ - - /* Execute the SYS_signal_handler_return SVCall (will not return) */ - - mov r0, #SYS_signal_handler_return - svc #SYS_syscall - nop - - .size up_signal_handler, .-up_signal_handler - .end - -#endif /* CONFIG_BUILD_PROTECTED && !__KERNEL__ */ diff --git a/arch/arm/src/armv6-m/arm_svcall.c b/arch/arm/src/armv6-m/arm_svcall.c index 1ccf869bc962e..c589f2bb3efef 100644 --- a/arch/arm/src/armv6-m/arm_svcall.c +++ b/arch/arm/src/armv6-m/arm_svcall.c @@ -114,7 +114,7 @@ static void dispatch_syscall(void) * ****************************************************************************/ -int arm_svcall(int irq, FAR void *context, FAR void *arg) +int arm_svcall(int irq, void *context, void *arg) { uint32_t *regs = (uint32_t *)context; uint32_t cmd; @@ -154,7 +154,7 @@ int arm_svcall(int irq, FAR void *context, FAR void *arg) { /* R0=SYS_save_context: This is a save context command: * - * int arm_saveusercontext(uint32_t *saveregs); + * int up_saveusercontext(void *saveregs); * * At this point, the following values are saved in context: * @@ -261,14 +261,14 @@ int arm_svcall(int irq, FAR void *context, FAR void *arg) */ rtcb->flags &= ~TCB_FLAG_SYSCALL; - (void)nxsig_unmask_pendingsignal(); + nxsig_unmask_pendingsignal(); } break; #endif /* R0=SYS_task_start: This a user task start * - * void up_task_start(main_t taskentry, int argc, FAR char *argv[]) + * void up_task_start(main_t taskentry, int argc, char *argv[]) * noreturn_function; * * At this point, the following values are saved in context: @@ -335,7 +335,7 @@ int arm_svcall(int irq, FAR void *context, FAR void *arg) /* R0=SYS_signal_handler: This a user signal handler callback * * void signal_handler(_sa_sigaction_t sighand, int signo, - * FAR siginfo_t *info, FAR void *ucontext); + * siginfo_t *info, void *ucontext); * * At this point, the following values are saved in context: * @@ -408,7 +408,7 @@ int arm_svcall(int irq, FAR void *context, FAR void *arg) default: { #ifdef CONFIG_LIB_SYSCALL - FAR struct tcb_s *rtcb = nxsched_self(); + struct tcb_s *rtcb = nxsched_self(); int index = rtcb->xcp.nsyscalls; /* Verify that the SYS call number is within range */ diff --git a/arch/arm/src/armv6-m/arm_tcbinfo.c b/arch/arm/src/armv6-m/arm_tcbinfo.c index c9f1b2aed0331..cd80cf0d9c484 100644 --- a/arch/arm/src/armv6-m/arm_tcbinfo.c +++ b/arch/arm/src/armv6-m/arm_tcbinfo.c @@ -53,12 +53,12 @@ static const uint16_t g_reg_offs[] = TCB_REG_OFF(REG_R15), TCB_REG_OFF(REG_XPSR), - 0, /* msp */ + UINT16_MAX, /* msp */ TCB_REG_OFF(REG_R13), TCB_REG_OFF(REG_PRIMASK), - 0, /* basepri */ - 0, /* faultmask */ - 0, /* control */ + UINT16_MAX, /* basepri */ + UINT16_MAX, /* faultmask */ + UINT16_MAX, /* control */ }; /**************************************************************************** @@ -67,11 +67,13 @@ static const uint16_t g_reg_offs[] = const struct tcbinfo_s g_tcbinfo = { - TCB_PID_OFF, - TCB_STATE_OFF, - TCB_PRI_OFF, - TCB_NAME_OFF, - XCPTCONTEXT_REGS, + .pid_off = TCB_PID_OFF, + .state_off = TCB_STATE_OFF, + .pri_off = TCB_PRI_OFF, + .name_off = TCB_NAME_OFF, + .regs_off = TCB_REGS_OFF, + .basic_num = 17, + .total_num = XCPTCONTEXT_REGS, { .p = g_reg_offs, }, diff --git a/arch/arm/src/armv6-m/nvic.h b/arch/arm/src/armv6-m/nvic.h index 688a651e079c8..62be901b69ba2 100644 --- a/arch/arm/src/armv6-m/nvic.h +++ b/arch/arm/src/armv6-m/nvic.h @@ -378,7 +378,7 @@ extern "C" ****************************************************************************/ #ifdef CONFIG_DEBUG_FEATURES -void arm_dumpnvic(FAR const char *msg); +void arm_dumpnvic(const char *msg); #else # define arm_dumpnvic(m) #endif diff --git a/arch/arm/src/armv7-a/Kconfig b/arch/arm/src/armv7-a/Kconfig index 6ed729f53774e..9f68fc3cfc658 100644 --- a/arch/arm/src/armv7-a/Kconfig +++ b/arch/arm/src/armv7-a/Kconfig @@ -128,25 +128,15 @@ endif # ARMV7A_HAVE_L2CC choice prompt "Toolchain Selection" - default ARMV7A_TOOLCHAIN_GNU_EABIW if TOOLCHAIN_WINDOWS - default ARMV7A_TOOLCHAIN_GNU_EABIL if !TOOLCHAIN_WINDOWS + default ARMV7A_TOOLCHAIN_GNU_EABI config ARMV7A_TOOLCHAIN_BUILDROOT bool "Buildroot (Cygwin or Linux)" select ARCH_TOOLCHAIN_GNU depends on !WINDOWS_NATIVE -config ARMV7A_TOOLCHAIN_GNU_EABIL - bool "Generic GNU EABI toolchain under Linux (or other POSIX environment)" - select ARCH_TOOLCHAIN_GNU - ---help--- - This option should work for any modern GNU toolchain (GCC 4.5 or newer) - configured for arm-none-eabi-. - -config ARMV7A_TOOLCHAIN_GNU_EABIW - bool "Generic GNU EABI toolchain under Windows" - depends on TOOLCHAIN_WINDOWS - select CYGWIN_WINTOOL if WINDOWS_CYGWIN +config ARMV7A_TOOLCHAIN_GNU_EABI + bool "Generic GNU EABI toolchain" select ARCH_TOOLCHAIN_GNU ---help--- This option should work for any modern GNU toolchain (GCC 4.5 or newer) diff --git a/arch/arm/src/armv7-a/Make.defs b/arch/arm/src/armv7-a/Make.defs new file mode 100644 index 0000000000000..19a60b3954a9e --- /dev/null +++ b/arch/arm/src/armv7-a/Make.defs @@ -0,0 +1,93 @@ +############################################################################ +# arch/arm/src/armv7-a/Make.defs +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. The +# ASF licenses this file to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance with the +# License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +# +############################################################################ + +# Common ARM files + +include common/Make.defs + +# The vector table is the "head" object, i.e., the one that must forced into +# the link in order to draw in all of the other components + +HEAD_ASRC += arm_vectortab.S + +ifeq ($(CONFIG_BUILD_KERNEL),y) +crt0$(OBJEXT): crt0.c + $(CC) $(CFLAGS) -c armv7-a$(DELIM)crt0.c -o crt0$(OBJEXT) + +STARTUP_OBJS = crt0$(OBJEXT) +endif + +# Common assembly language files + +CMN_ASRCS += arm_cpuhead.S arm_fpuconfig.S arm_vectoraddrexcptn.S +CMN_ASRCS += arm_vectors.S cp15_cache_size.S cp15_clean_dcache_all.S +CMN_ASRCS += cp15_clean_dcache.S cp15_coherent_dcache.S +CMN_ASRCS += cp15_flush_dcache_all.S cp15_flush_dcache.S +CMN_ASRCS += cp15_invalidate_dcache_all.S cp15_invalidate_dcache.S + +# Common C source files + +CMN_CSRCS += arm_cache.c arm_dataabort.c +CMN_CSRCS += arm_doirq.c arm_gicv2.c arm_gicv2_dump.c +CMN_CSRCS += arm_initialstate.c arm_mmu.c arm_prefetchabort.c +CMN_CSRCS += arm_schedulesigaction.c arm_sigdeliver.c +CMN_CSRCS += arm_syscall.c arm_tcbinfo.c arm_undefinedinsn.c + +ifeq ($(CONFIG_ARMV7A_L2CC_PL310),y) + CMN_CSRCS += arm_l2cc_pl310.c +endif + +ifeq ($(CONFIG_PAGING),y) + CMN_CSRCS += arm_allocpage.c arm_checkmapping.c arm_pginitialize.c + CMN_CSRCS += arm_va2pte.c + CMN_ASRCS += arm_pghead.S +else + CMN_ASRCS += arm_head.S +endif + +ifeq ($(CONFIG_ARCH_ADDRENV),y) + CMN_CSRCS += arm_addrenv.c arm_addrenv_utils.c arm_addrenv_perms.c arm_pgalloc.c + ifeq ($(CONFIG_ARCH_STACK_DYNAMIC),y) + CMN_CSRCS += arm_addrenv_ustack.c + endif + ifeq ($(CONFIG_ARCH_KERNEL_STACK),y) + CMN_CSRCS += arm_addrenv_kstack.c + endif + ifeq ($(CONFIG_MM_SHM),y) + CMN_CSRCS += arm_addrenv_shm.c + endif +endif + +ifeq ($(CONFIG_MM_PGALLOC),y) + CMN_CSRCS += arm_physpgaddr.c + ifeq ($(CONFIG_ARCH_PGPOOL_MAPPING),y) + CMN_CSRCS += arm_virtpgaddr.c + endif +endif + +ifeq ($(CONFIG_ARCH_FPU),y) + CMN_CSRCS += arm_fpucmp.c +endif + +ifeq ($(CONFIG_SMP),y) + CMN_CSRCS += arm_cpuindex.c arm_cpustart.c arm_cpupause.c arm_cpuidlestack.c + CMN_CSRCS += arm_scu.c +endif + diff --git a/arch/arm/src/armv7-a/Toolchain.defs b/arch/arm/src/armv7-a/Toolchain.defs index 50dee48de983f..57ba38ed59c6d 100644 --- a/arch/arm/src/armv7-a/Toolchain.defs +++ b/arch/arm/src/armv7-a/Toolchain.defs @@ -32,13 +32,7 @@ ifeq ($(filter y, \ endif ifeq ($(filter y, \ - $(CONFIG_ARMV7A_TOOLCHAIN_GNU_EABIL) \ - ),y) - CONFIG_ARMV7A_TOOLCHAIN ?= GNU_EABI -endif - -ifeq ($(filter y, \ - $(CONFIG_ARMV7A_TOOLCHAIN_GNU_EABIW) \ + $(CONFIG_ARMV7A_TOOLCHAIN_GNU_EABI) \ ),y) CONFIG_ARMV7A_TOOLCHAIN ?= GNU_EABI endif @@ -51,7 +45,7 @@ endif # CROSSDEV The GNU toolchain triple (command prefix) # ARCHCPUFLAGS CPU-specific flags selecting the instruction set # FPU options, etc. -# MAXOPTIMIZATION The maximum optimization level that results in +# ARCHOPTIMIZATION The optimization level that results in # reliable code generation. # @@ -107,15 +101,23 @@ ifeq ($(CONFIG_MM_KASAN),y) endif ifeq ($(CONFIG_DEBUG_CUSTOMOPT),y) - MAXOPTIMIZATION := $(CONFIG_DEBUG_OPTLEVEL) -else - MAXOPTIMIZATION ?= -Os + ARCHOPTIMIZATION += $(CONFIG_DEBUG_OPTLEVEL) +else ifeq ($(CONFIG_DEBUG_FULLOPT),y) + ARCHOPTIMIZATION += -Os +endif + +ifneq ($(CONFIG_DEBUG_NOOPT),y) + ARCHOPTIMIZATION += -fno-strict-aliasing endif ifeq ($(CONFIG_FRAME_POINTER),y) - MAXOPTIMIZATION += -fno-omit-frame-pointer -fno-optimize-sibling-calls + ARCHOPTIMIZATION += -fno-omit-frame-pointer -fno-optimize-sibling-calls else - MAXOPTIMIZATION += -fomit-frame-pointer + ARCHOPTIMIZATION += -fomit-frame-pointer +endif + +ifeq ($(CONFIG_STACK_CANARIES),y) + ARCHOPTIMIZATION += -fstack-protector-all endif ifeq ($(CONFIG_ENDIAN_BIG),y) @@ -124,6 +126,35 @@ else TARGET_ARCH := arm endif +ARCHCFLAGS += -fno-common +ARCHCXXFLAGS += -fno-common -nostdinc++ + +ifneq ($(CONFIG_CXX_EXCEPTION),y) + ARCHCXXFLAGS += -fno-exceptions -fcheck-new +endif + +ifneq ($(CONFIG_CXX_RTTI),y) + ARCHCXXFLAGS += -fno-rtti +endif + +# Optimization of unused sections + +ifeq ($(CONFIG_DEBUG_OPT_UNUSED_SECTIONS),y) + LDFLAGS += --gc-sections + ARCHOPTIMIZATION += -ffunction-sections -fdata-sections +endif + +# Debug link map + +ifeq ($(CONFIG_DEBUG_LINK_MAP),y) + LDFLAGS += --cref -Map=$(call CONVERT_PATH,$(TOPDIR)$(DELIM)nuttx.map) +endif + +ifeq ($(CONFIG_DEBUG_SYMBOLS),y) + LDFLAGS += -g + ARCHOPTIMIZATION += -g +endif + # NuttX buildroot under Linux or Cygwin ifeq ($(CONFIG_ARMV7A_TOOLCHAIN),BUILDROOT) @@ -142,24 +173,38 @@ endif # Default toolchain -CC = $(CROSSDEV)gcc -CXX = $(CROSSDEV)g++ -CPP = $(CROSSDEV)gcc -E -P -x c -LD = $(CROSSDEV)ld -STRIP = $(CROSSDEV)strip --strip-unneeded -AR = $(CROSSDEV)ar rcs -NM = $(CROSSDEV)nm +CC = $(CROSSDEV)gcc +CXX = $(CROSSDEV)g++ +CPP = $(CROSSDEV)gcc -E -P -x c +STRIP = $(CROSSDEV)strip --strip-unneeded OBJCOPY = $(CROSSDEV)objcopy OBJDUMP = $(CROSSDEV)objdump +LD = $(CROSSDEV)ld +AR = $(CROSSDEV)ar rcs +NM = $(CROSSDEV)nm + +# Link Time Optimization + +ifeq ($(CONFIG_LTO_FULL),y) + ARCHOPTIMIZATION += -flto + ifeq ($(CONFIG_ARMV7A_TOOLCHAIN),GNU_EABI) + LD := $(CROSSDEV)gcc + AR := $(CROSSDEV)gcc-ar rcs + NM := $(CROSSDEV)gcc-nm + ARCHOPTIMIZATION += -fuse-linker-plugin + ARCHOPTIMIZATION += -fno-builtin + ARCHOPTIMIZATION += -nodefaultlibs + endif +endif # Add the builtin library -EXTRA_LIBS += ${wildcard ${shell $(CC) $(ARCHCPUFLAGS) --print-libgcc-file-name}} +EXTRA_LIBS += $(wildcard $(shell $(CC) $(ARCHCPUFLAGS) --print-libgcc-file-name)) ifneq ($(CONFIG_LIBM),y) - EXTRA_LIBS += ${wildcard ${shell $(CC) $(ARCHCPUFLAGS) --print-file-name=libm.a}} + EXTRA_LIBS += $(wildcard $(shell $(CC) $(ARCHCPUFLAGS) --print-file-name=libm.a)) endif ifeq ($(CONFIG_LIBSUPCXX),y) - EXTRA_LIBS += ${wildcard ${shell $(CC) $(ARCHCPUFLAGS) --print-file-name=libsupc++.a}} + EXTRA_LIBS += $(wildcard $(shell $(CC) $(ARCHCPUFLAGS) --print-file-name=libsupc++.a)) endif diff --git a/arch/arm/src/armv7-a/addrenv.h b/arch/arm/src/armv7-a/addrenv.h index c724c9b0b4552..b87a5ad7e26d6 100644 --- a/arch/arm/src/armv7-a/addrenv.h +++ b/arch/arm/src/armv7-a/addrenv.h @@ -85,7 +85,7 @@ extern "C" * ****************************************************************************/ -int arm_addrenv_create_region(FAR uintptr_t **list, unsigned int listlen, +int arm_addrenv_create_region(uintptr_t **list, unsigned int listlen, uintptr_t vaddr, size_t regionsize, uint32_t mmuflags); @@ -97,7 +97,7 @@ int arm_addrenv_create_region(FAR uintptr_t **list, unsigned int listlen, * ****************************************************************************/ -void arm_addrenv_destroy_region(FAR uintptr_t **list, unsigned int listlen, +void arm_addrenv_destroy_region(uintptr_t **list, unsigned int listlen, uintptr_t vaddr, bool keep); #undef EXTERN diff --git a/arch/arm/src/armv7-a/arm_addrenv.c b/arch/arm/src/armv7-a/arm_addrenv.c index 717e4475d37fe..0a5c0789063e5 100644 --- a/arch/arm/src/armv7-a/arm_addrenv.c +++ b/arch/arm/src/armv7-a/arm_addrenv.c @@ -147,7 +147,7 @@ static int up_addrenv_initdata(uintptr_t l2table) { irqstate_t flags; - FAR uint32_t *virtptr; + uint32_t *virtptr; uintptr_t paddr; #ifndef CONFIG_ARCH_PGPOOL_MAPPING uint32_t l1save; @@ -161,13 +161,13 @@ static int up_addrenv_initdata(uintptr_t l2table) * address */ - virtptr = (FAR uint32_t *)arm_pgvaddr(l2table); + virtptr = (uint32_t *)arm_pgvaddr(l2table); #else /* Temporarily map the page into the virtual address space */ l1save = mmu_l1_getentry(ARCH_SCRATCH_VBASE); mmu_l1_setentry(l2table & ~SECTION_MASK, ARCH_SCRATCH_VBASE, MMU_MEMFLAGS); - virtptr = (FAR uint32_t *)(ARCH_SCRATCH_VBASE | (l2table & SECTION_MASK)); + virtptr = (uint32_t *)(ARCH_SCRATCH_VBASE | (l2table & SECTION_MASK)); #endif /* Invalidate D-Cache so that we read from the physical memory */ @@ -183,12 +183,12 @@ static int up_addrenv_initdata(uintptr_t l2table) #ifdef CONFIG_ARCH_PGPOOL_MAPPING /* Get the virtual address corresponding to the physical page address */ - virtptr = (FAR uint32_t *)arm_pgvaddr(paddr); + virtptr = (uint32_t *)arm_pgvaddr(paddr); #else /* Temporarily map the page into the virtual address space */ mmu_l1_setentry(paddr & ~SECTION_MASK, ARCH_SCRATCH_VBASE, MMU_MEMFLAGS); - virtptr = (FAR uint32_t *)(ARCH_SCRATCH_VBASE | (paddr & SECTION_MASK)); + virtptr = (uint32_t *)(ARCH_SCRATCH_VBASE | (paddr & SECTION_MASK)); #endif /* Finally, after of all of that, we can initialize the tiny region at @@ -246,7 +246,7 @@ static int up_addrenv_initdata(uintptr_t l2table) ****************************************************************************/ int up_addrenv_create(size_t textsize, size_t datasize, size_t heapsize, - FAR group_addrenv_t *addrenv) + group_addrenv_t *addrenv) { int ret; @@ -349,7 +349,7 @@ int up_addrenv_create(size_t textsize, size_t datasize, size_t heapsize, * ****************************************************************************/ -int up_addrenv_destroy(FAR group_addrenv_t *addrenv) +int up_addrenv_destroy(group_addrenv_t *addrenv) { binfo("addrenv=%p\n", addrenv); DEBUGASSERT(addrenv); @@ -401,14 +401,14 @@ int up_addrenv_destroy(FAR group_addrenv_t *addrenv) * ****************************************************************************/ -int up_addrenv_vtext(FAR group_addrenv_t *addrenv, FAR void **vtext) +int up_addrenv_vtext(group_addrenv_t *addrenv, void **vtext) { - binfo("return=%p\n", (FAR void *)CONFIG_ARCH_TEXT_VBASE); + binfo("return=%p\n", (void *)CONFIG_ARCH_TEXT_VBASE); /* Not much to do in this case */ DEBUGASSERT(addrenv && vtext); - *vtext = (FAR void *)CONFIG_ARCH_TEXT_VBASE; + *vtext = (void *)CONFIG_ARCH_TEXT_VBASE; return OK; } @@ -434,19 +434,46 @@ int up_addrenv_vtext(FAR group_addrenv_t *addrenv, FAR void **vtext) * ****************************************************************************/ -int up_addrenv_vdata(FAR group_addrenv_t *addrenv, uintptr_t textsize, - FAR void **vdata) +int up_addrenv_vdata(group_addrenv_t *addrenv, uintptr_t textsize, + void **vdata) { binfo("return=%p\n", - (FAR void *)(CONFIG_ARCH_DATA_VBASE + ARCH_DATA_RESERVE_SIZE)); + (void *)(CONFIG_ARCH_DATA_VBASE + ARCH_DATA_RESERVE_SIZE)); /* Not much to do in this case */ DEBUGASSERT(addrenv && vdata); - *vdata = (FAR void *)(CONFIG_ARCH_DATA_VBASE + ARCH_DATA_RESERVE_SIZE); + *vdata = (void *)(CONFIG_ARCH_DATA_VBASE + ARCH_DATA_RESERVE_SIZE); return OK; } +/**************************************************************************** + * Name: up_addrenv_vheap + * + * Description: + * Return the heap virtual address associated with the newly created + * address environment. This function is used by the binary loaders in + * order get an address that can be used to initialize the new task. + * + * Input Parameters: + * addrenv - The representation of the task address environment previously + * returned by up_addrenv_create. + * vheap - The location to return the virtual address. + * + * Returned Value: + * Zero (OK) on success; a negated errno value on failure. + * + ****************************************************************************/ + +#ifdef CONFIG_BUILD_KERNEL +int up_addrenv_vheap(const group_addrenv_t *addrenv, void **vheap) +{ + DEBUGASSERT(addrenv && vheap); + *vheap = (void *)CONFIG_ARCH_HEAP_VBASE; + return OK; +} +#endif + /**************************************************************************** * Name: up_addrenv_heapsize * @@ -467,7 +494,7 @@ int up_addrenv_vdata(FAR group_addrenv_t *addrenv, uintptr_t textsize, ****************************************************************************/ #ifdef CONFIG_BUILD_KERNEL -ssize_t up_addrenv_heapsize(FAR const group_addrenv_t *addrenv) +ssize_t up_addrenv_heapsize(const group_addrenv_t *addrenv) { DEBUGASSERT(addrenv); return (ssize_t)addrenv->heapsize; @@ -499,8 +526,8 @@ ssize_t up_addrenv_heapsize(FAR const group_addrenv_t *addrenv) * ****************************************************************************/ -int up_addrenv_select(FAR const group_addrenv_t *addrenv, - FAR save_addrenv_t *oldenv) +int up_addrenv_select(const group_addrenv_t *addrenv, + save_addrenv_t *oldenv) { uintptr_t vaddr; uintptr_t paddr; @@ -636,7 +663,7 @@ int up_addrenv_select(FAR const group_addrenv_t *addrenv, * ****************************************************************************/ -int up_addrenv_restore(FAR const save_addrenv_t *oldenv) +int up_addrenv_restore(const save_addrenv_t *oldenv) { uintptr_t vaddr; int i; @@ -704,7 +731,7 @@ int up_addrenv_restore(FAR const save_addrenv_t *oldenv) * ****************************************************************************/ -int up_addrenv_coherent(FAR const group_addrenv_t *addrenv) +int up_addrenv_coherent(const group_addrenv_t *addrenv) { DEBUGASSERT(addrenv); @@ -754,8 +781,8 @@ int up_addrenv_coherent(FAR const group_addrenv_t *addrenv) * ****************************************************************************/ -int up_addrenv_clone(FAR const group_addrenv_t *src, - FAR group_addrenv_t *dest) +int up_addrenv_clone(const group_addrenv_t *src, + group_addrenv_t *dest) { binfo("src=%p dest=%p\n", src, dest); DEBUGASSERT(src && dest); @@ -787,7 +814,7 @@ int up_addrenv_clone(FAR const group_addrenv_t *src, * ****************************************************************************/ -int up_addrenv_attach(FAR struct task_group_s *group, FAR struct tcb_s *tcb) +int up_addrenv_attach(struct task_group_s *group, struct tcb_s *tcb) { binfo("group=%p tcb=%p\n", group, tcb); @@ -820,7 +847,7 @@ int up_addrenv_attach(FAR struct task_group_s *group, FAR struct tcb_s *tcb) * ****************************************************************************/ -int up_addrenv_detach(FAR struct task_group_s *group, FAR struct tcb_s *tcb) +int up_addrenv_detach(struct task_group_s *group, struct tcb_s *tcb) { binfo("group=%p tcb=%p\n", group, tcb); diff --git a/arch/arm/src/armv7-a/arm_addrenv_kstack.c b/arch/arm/src/armv7-a/arm_addrenv_kstack.c index 2146837c120fa..8ab91db758e19 100644 --- a/arch/arm/src/armv7-a/arm_addrenv_kstack.c +++ b/arch/arm/src/armv7-a/arm_addrenv_kstack.c @@ -129,7 +129,7 @@ * ****************************************************************************/ -int up_addrenv_kstackalloc(FAR struct tcb_s *tcb) +int up_addrenv_kstackalloc(struct tcb_s *tcb) { binfo("tcb=%p stacksize=%u\n", tcb, ARCH_KERNEL_STACKSIZE); @@ -137,7 +137,7 @@ int up_addrenv_kstackalloc(FAR struct tcb_s *tcb) /* Allocate the kernel stack */ - tcb->xcp.kstack = (FAR uint32_t *)kmm_memalign(8, ARCH_KERNEL_STACKSIZE); + tcb->xcp.kstack = (uint32_t *)kmm_memalign(8, ARCH_KERNEL_STACKSIZE); if (!tcb->xcp.kstack) { berr("ERROR: Failed to allocate the kernel stack\n"); @@ -162,7 +162,7 @@ int up_addrenv_kstackalloc(FAR struct tcb_s *tcb) * ****************************************************************************/ -int up_addrenv_kstackfree(FAR struct tcb_s *tcb) +int up_addrenv_kstackfree(struct tcb_s *tcb) { binfo("tcb=%p\n", tcb); DEBUGASSERT(tcb); diff --git a/arch/arm/src/armv7-a/arm_addrenv_perms.c b/arch/arm/src/armv7-a/arm_addrenv_perms.c new file mode 100644 index 0000000000000..c396f9f1e2efa --- /dev/null +++ b/arch/arm/src/armv7-a/arm_addrenv_perms.c @@ -0,0 +1,75 @@ +/**************************************************************************** + * arch/arm/src/armv7-a/arm_addrenv_perms.c + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: up_addrenv_text_enable_write + * + * Description: + * Temporarily enable write access to the .text section. This must be + * called prior to loading the process code into memory. + * + * Input Parameters: + * addrenv - The address environment to be modified. + * + * Returned Value: + * Zero (OK) on success; a negated errno value on failure. + * + ****************************************************************************/ + +int up_addrenv_text_enable_write(group_addrenv_t *addrenv) +{ + /* Nothing needs to be done */ + + return OK; +} + +/**************************************************************************** + * Name: up_addrenv_text_disable_write + * + * Description: + * Disable write access to the .text section. This must be called after the + * process code is loaded into memory. + * + * Input Parameters: + * addrenv - The address environment to be modified. + * + * Returned Value: + * Zero (OK) on success; a negated errno value on failure. + * + ****************************************************************************/ + +int up_addrenv_text_disable_write(group_addrenv_t *addrenv) +{ + /* Nothing needs to be done */ + + return OK; +} diff --git a/arch/arm/src/armv7-a/arm_addrenv_shm.c b/arch/arm/src/armv7-a/arm_addrenv_shm.c index 5548b439b56f8..04d711a5141d1 100644 --- a/arch/arm/src/armv7-a/arm_addrenv_shm.c +++ b/arch/arm/src/armv7-a/arm_addrenv_shm.c @@ -63,12 +63,12 @@ * ****************************************************************************/ -int up_shmat(FAR uintptr_t *pages, unsigned int npages, uintptr_t vaddr) +int up_shmat(uintptr_t *pages, unsigned int npages, uintptr_t vaddr) { - FAR struct tcb_s *tcb = nxsched_self(); - FAR struct task_group_s *group; - FAR uintptr_t *l1entry; - FAR uint32_t *l2table; + struct tcb_s *tcb = nxsched_self(); + struct task_group_s *group; + uintptr_t *l1entry; + uint32_t *l2table; irqstate_t flags; uintptr_t paddr; #ifndef CONFIG_ARCH_PGPOOL_MAPPING @@ -118,21 +118,21 @@ int up_shmat(FAR uintptr_t *pages, unsigned int npages, uintptr_t vaddr) */ flags = enter_critical_section(); - group->tg_addrenv.shm[shmndx] = (FAR uintptr_t *)paddr; + group->tg_addrenv.shm[shmndx] = (uintptr_t *)paddr; #ifdef CONFIG_ARCH_PGPOOL_MAPPING /* Get the virtual address corresponding to the physical page * address. */ - l2table = (FAR uint32_t *)arm_pgvaddr(paddr); + l2table = (uint32_t *)arm_pgvaddr(paddr); #else /* Temporarily map the page into the virtual address space */ l1save = mmu_l1_getentry(ARCH_SCRATCH_VBASE); mmu_l1_setentry(paddr & ~SECTION_MASK, ARCH_SCRATCH_VBASE, MMU_MEMFLAGS); - l2table = (FAR uint32_t *) + l2table = (uint32_t *) (ARCH_SCRATCH_VBASE | (paddr & SECTION_MASK)); #endif @@ -154,14 +154,14 @@ int up_shmat(FAR uintptr_t *pages, unsigned int npages, uintptr_t vaddr) * address. */ - l2table = (FAR uint32_t *)arm_pgvaddr(paddr); + l2table = (uint32_t *)arm_pgvaddr(paddr); #else /* Temporarily map the page into the virtual address space */ l1save = mmu_l1_getentry(ARCH_SCRATCH_VBASE); mmu_l1_setentry(paddr & ~SECTION_MASK, ARCH_SCRATCH_VBASE, MMU_MEMFLAGS); - l2table = (FAR uint32_t *) + l2table = (uint32_t *) (ARCH_SCRATCH_VBASE | (paddr & SECTION_MASK)); #endif } @@ -216,10 +216,10 @@ int up_shmat(FAR uintptr_t *pages, unsigned int npages, uintptr_t vaddr) int up_shmdt(uintptr_t vaddr, unsigned int npages) { - FAR struct tcb_s *tcb = nxsched_self(); - FAR struct task_group_s *group; - FAR uintptr_t *l1entry; - FAR uint32_t *l2table; + struct tcb_s *tcb = nxsched_self(); + struct task_group_s *group; + uintptr_t *l1entry; + uint32_t *l2table; irqstate_t flags; uintptr_t paddr; #ifndef CONFIG_ARCH_PGPOOL_MAPPING @@ -265,14 +265,14 @@ int up_shmdt(uintptr_t vaddr, unsigned int npages) * address. */ - l2table = (FAR uint32_t *)arm_pgvaddr(paddr); + l2table = (uint32_t *)arm_pgvaddr(paddr); #else /* Temporarily map the page into the virtual address space */ l1save = mmu_l1_getentry(ARCH_SCRATCH_VBASE); mmu_l1_setentry(paddr & ~SECTION_MASK, ARCH_SCRATCH_VBASE, MMU_MEMFLAGS); - l2table = (FAR uint32_t *) + l2table = (uint32_t *) (ARCH_SCRATCH_VBASE | (paddr & SECTION_MASK)); #endif diff --git a/arch/arm/src/armv7-a/arm_addrenv_ustack.c b/arch/arm/src/armv7-a/arm_addrenv_ustack.c index 37bf3975272a7..d081c4bfa4d85 100644 --- a/arch/arm/src/armv7-a/arm_addrenv_ustack.c +++ b/arch/arm/src/armv7-a/arm_addrenv_ustack.c @@ -126,7 +126,7 @@ * ****************************************************************************/ -int up_addrenv_ustackalloc(FAR struct tcb_s *tcb, size_t stacksize) +int up_addrenv_ustackalloc(struct tcb_s *tcb, size_t stacksize) { int ret; @@ -175,7 +175,7 @@ int up_addrenv_ustackalloc(FAR struct tcb_s *tcb, size_t stacksize) * ****************************************************************************/ -int up_addrenv_ustackfree(FAR struct tcb_s *tcb) +int up_addrenv_ustackfree(struct tcb_s *tcb) { binfo("tcb=%p\n", tcb); DEBUGASSERT(tcb); @@ -206,14 +206,14 @@ int up_addrenv_ustackfree(FAR struct tcb_s *tcb) * ****************************************************************************/ -int up_addrenv_vustack(FAR const struct tcb_s *tcb, FAR void **vstack) +int up_addrenv_vustack(const struct tcb_s *tcb, void **vstack) { - binfo("Return=%p\n", (FAR void *)CONFIG_ARCH_STACK_VBASE); + binfo("Return=%p\n", (void *)CONFIG_ARCH_STACK_VBASE); /* Not much to do in this case */ DEBUGASSERT(tcb); - *vstack = (FAR void *)CONFIG_ARCH_STACK_VBASE; + *vstack = (void *)CONFIG_ARCH_STACK_VBASE; return OK; } @@ -236,7 +236,7 @@ int up_addrenv_vustack(FAR const struct tcb_s *tcb, FAR void **vstack) * ****************************************************************************/ -int up_addrenv_ustackselect(FAR const struct tcb_s *tcb) +int up_addrenv_ustackselect(const struct tcb_s *tcb) { uintptr_t vaddr; uintptr_t paddr; diff --git a/arch/arm/src/armv7-a/arm_addrenv_utils.c b/arch/arm/src/armv7-a/arm_addrenv_utils.c index 1c735d4e20022..2eeb2aa85937b 100644 --- a/arch/arm/src/armv7-a/arm_addrenv_utils.c +++ b/arch/arm/src/armv7-a/arm_addrenv_utils.c @@ -55,13 +55,13 @@ * ****************************************************************************/ -int arm_addrenv_create_region(FAR uintptr_t **list, unsigned int listlen, +int arm_addrenv_create_region(uintptr_t **list, unsigned int listlen, uintptr_t vaddr, size_t regionsize, uint32_t mmuflags) { irqstate_t flags; uintptr_t paddr; - FAR uint32_t *l2table; + uint32_t *l2table; #ifndef CONFIG_ARCH_PGPOOL_MAPPING uint32_t l1save; #endif @@ -106,21 +106,21 @@ int arm_addrenv_create_region(FAR uintptr_t **list, unsigned int listlen, } DEBUGASSERT(MM_ISALIGNED(paddr)); - list[i] = (FAR uintptr_t *)paddr; + list[i] = (uintptr_t *)paddr; flags = enter_critical_section(); #ifdef CONFIG_ARCH_PGPOOL_MAPPING /* Get the virtual address corresponding to the physical page address */ - l2table = (FAR uint32_t *)arm_pgvaddr(paddr); + l2table = (uint32_t *)arm_pgvaddr(paddr); #else /* Temporarily map the page into the virtual address space */ l1save = mmu_l1_getentry(ARCH_SCRATCH_VBASE); mmu_l1_setentry(paddr & ~SECTION_MASK, ARCH_SCRATCH_VBASE, MMU_MEMFLAGS); - l2table = (FAR uint32_t *)(ARCH_SCRATCH_VBASE | + l2table = (uint32_t *)(ARCH_SCRATCH_VBASE | (paddr & SECTION_MASK)); #endif @@ -179,12 +179,12 @@ int arm_addrenv_create_region(FAR uintptr_t **list, unsigned int listlen, * ****************************************************************************/ -void arm_addrenv_destroy_region(FAR uintptr_t **list, unsigned int listlen, +void arm_addrenv_destroy_region(uintptr_t **list, unsigned int listlen, uintptr_t vaddr, bool keep) { irqstate_t flags; uintptr_t paddr; - FAR uint32_t *l2table; + uint32_t *l2table; #ifndef CONFIG_ARCH_PGPOOL_MAPPING uint32_t l1save; #endif @@ -211,14 +211,14 @@ void arm_addrenv_destroy_region(FAR uintptr_t **list, unsigned int listlen, * address */ - l2table = (FAR uint32_t *)arm_pgvaddr(paddr); + l2table = (uint32_t *)arm_pgvaddr(paddr); #else /* Temporarily map the page into the virtual address space */ l1save = mmu_l1_getentry(ARCH_SCRATCH_VBASE); mmu_l1_setentry(paddr & ~SECTION_MASK, ARCH_SCRATCH_VBASE, MMU_MEMFLAGS); - l2table = (FAR uint32_t *)(ARCH_SCRATCH_VBASE | + l2table = (uint32_t *)(ARCH_SCRATCH_VBASE | (paddr & SECTION_MASK)); #endif diff --git a/arch/arm/src/armv7-a/arm_allocpage.c b/arch/arm/src/armv7-a/arm_allocpage.c index 46891ec00b731..aed3a4d6a7391 100644 --- a/arch/arm/src/armv7-a/arm_allocpage.c +++ b/arch/arm/src/armv7-a/arm_allocpage.c @@ -142,7 +142,7 @@ static bool g_pgwrap; * ****************************************************************************/ -int arm_allocpage(FAR struct tcb_s *tcb, FAR void **vpage) +int arm_allocpage(struct tcb_s *tcb, void **vpage) { uintptr_t vaddr; uintptr_t paddr; diff --git a/arch/arm/src/armv7-a/arm_checkmapping.c b/arch/arm/src/armv7-a/arm_checkmapping.c index b1a8985f46d0b..3a5c16d4fbb87 100644 --- a/arch/arm/src/armv7-a/arm_checkmapping.c +++ b/arch/arm/src/armv7-a/arm_checkmapping.c @@ -69,7 +69,7 @@ * ****************************************************************************/ -bool arm_checkmapping(FAR struct tcb_s *tcb) +bool arm_checkmapping(struct tcb_s *tcb) { uintptr_t vaddr; uint32_t *pte; diff --git a/arch/arm/src/armv7-a/arm_cpuhead.S b/arch/arm/src/armv7-a/arm_cpuhead.S index 70f29a0886557..9d71005a7695e 100644 --- a/arch/arm/src/armv7-a/arm_cpuhead.S +++ b/arch/arm/src/armv7-a/arm_cpuhead.S @@ -94,8 +94,7 @@ __cpu1_start: /* Make sure that we are in SYS mode with IRQs and FIQs disabled */ - mov r0, #(PSR_MODE_SYS | PSR_I_BIT | PSR_F_BIT) - msr cpsr_c, r0 + cpsid if, #PSR_MODE_SYS /* Set up the stack pointer and the CPU index */ @@ -118,8 +117,7 @@ __cpu1_start: __cpu2_start: /* Make sure that we are in SYS mode with IRQs and FIQs disabled */ - mov r0, #(PSR_MODE_SYS | PSR_I_BIT | PSR_F_BIT) - msr cpsr_c, r0 + cpsid if, #PSR_MODE_SYS /* Set up the stack pointer and the CPU index */ @@ -142,8 +140,7 @@ __cpu2_start: __cpu3_start: /* Make sure that we are in SYS mode with IRQs and FIQs disabled */ - mov r0, #(PSR_MODE_SYS | PSR_I_BIT | PSR_F_BIT) - msr cpsr_c, r0 + cpsid if, #PSR_MODE_SYS /* Set up the stack pointer and the CPU index */ @@ -444,7 +441,7 @@ __cpu3_start: #ifdef CONFIG_STACK_COLORATION .type .Lstkinit, %object .Lstkinit: - .long SMP_STACK_WORDS + .long SMP_STACK_WORDS - (XCPTCONTEXT_SIZE / 4) .long STACK_COLOR /* Stack coloration word */ .size .Lstkinit, . -.Lstkinit #endif diff --git a/arch/arm/src/armv7-a/arm_cpuidlestack.c b/arch/arm/src/armv7-a/arm_cpuidlestack.c index fdc211ca98c58..b03862a3f30ff 100644 --- a/arch/arm/src/armv7-a/arm_cpuidlestack.c +++ b/arch/arm/src/armv7-a/arm_cpuidlestack.c @@ -48,7 +48,7 @@ ****************************************************************************/ #if CONFIG_SMP_NCPUS > 1 -static FAR const uint32_t *g_cpu_stackalloc[CONFIG_SMP_NCPUS] = +static const uint32_t *g_cpu_stackalloc[CONFIG_SMP_NCPUS] = { 0 , g_cpu1_idlestack @@ -108,7 +108,7 @@ static FAR const uint32_t *g_cpu_stackalloc[CONFIG_SMP_NCPUS] = * ****************************************************************************/ -int up_cpu_idlestack(int cpu, FAR struct tcb_s *tcb, size_t stack_size) +int up_cpu_idlestack(int cpu, struct tcb_s *tcb, size_t stack_size) { #if CONFIG_SMP_NCPUS > 1 uintptr_t stack_alloc; @@ -122,7 +122,7 @@ int up_cpu_idlestack(int cpu, FAR struct tcb_s *tcb, size_t stack_size) DEBUGASSERT(stack_alloc != 0 && STACK_ISALIGNED(stack_alloc)); tcb->adj_stack_size = SMP_STACK_SIZE; - tcb->stack_alloc_ptr = (FAR void *)stack_alloc; + tcb->stack_alloc_ptr = (void *)stack_alloc; tcb->stack_base_ptr = tcb->stack_alloc_ptr; #endif diff --git a/arch/arm/src/armv7-a/arm_cpupause.c b/arch/arm/src/armv7-a/arm_cpupause.c index 927e8b9258b0c..261418a28c7bf 100644 --- a/arch/arm/src/armv7-a/arm_cpupause.c +++ b/arch/arm/src/armv7-a/arm_cpupause.c @@ -112,7 +112,7 @@ bool up_cpu_pausereq(int cpu) int up_cpu_paused(int cpu) { - FAR struct tcb_s *tcb = this_task(); + struct tcb_s *tcb = this_task(); /* Update scheduler parameters */ @@ -188,7 +188,7 @@ int up_cpu_paused(int cpu) * ****************************************************************************/ -int arm_pause_handler(int irq, FAR void *context, FAR void *arg) +int arm_pause_handler(int irq, void *context, void *arg) { int cpu = this_cpu(); diff --git a/arch/arm/src/armv7-a/arm_cpustart.c b/arch/arm/src/armv7-a/arm_cpustart.c index 015931ab85233..83681cecc9524 100644 --- a/arch/arm/src/armv7-a/arm_cpustart.c +++ b/arch/arm/src/armv7-a/arm_cpustart.c @@ -48,7 +48,7 @@ ****************************************************************************/ #if 0 /* Was useful in solving some startup problems */ -static inline void arm_registerdump(FAR struct tcb_s *tcb) +static inline void arm_registerdump(struct tcb_s *tcb) { int regndx; @@ -90,9 +90,9 @@ static inline void arm_registerdump(FAR struct tcb_s *tcb) * ****************************************************************************/ -int arm_start_handler(int irq, FAR void *context, FAR void *arg) +int arm_start_handler(int irq, void *context, void *arg) { - FAR struct tcb_s *tcb = this_task(); + struct tcb_s *tcb = this_task(); sinfo("CPU%d Started\n", this_cpu()); diff --git a/arch/arm/src/armv7-a/arm_doirq.c b/arch/arm/src/armv7-a/arm_doirq.c index b4a0b5b3ea7e5..e8c7e1c66c979 100644 --- a/arch/arm/src/armv7-a/arm_doirq.c +++ b/arch/arm/src/armv7-a/arm_doirq.c @@ -70,23 +70,15 @@ uint32_t *arm_doirq(int irq, uint32_t *regs) irq_dispatch(irq, regs); -#if defined(CONFIG_ARCH_FPU) || defined(CONFIG_ARCH_ADDRENV) +#ifdef CONFIG_ARCH_ADDRENV /* Check for a context switch. If a context switch occurred, then * CURRENT_REGS will have a different value than it did on entry. If an - * interrupt level context switch has occurred, then restore the floating - * point state and the establish the correct address environment before - * returning from the interrupt. + * interrupt level context switch has occurred, then establish the correct + * address environment before returning from the interrupt. */ if (regs != CURRENT_REGS) { -#ifdef CONFIG_ARCH_FPU - /* Restore floating point registers */ - - arm_restorefpu((uint32_t *)CURRENT_REGS); -#endif - -#ifdef CONFIG_ARCH_ADDRENV /* Make sure that the address environment for the previously * running task is closed down gracefully (data caches dump, * MMU flushed) and set up the address environment for the new @@ -94,7 +86,6 @@ uint32_t *arm_doirq(int irq, uint32_t *regs) */ group_addrenv(NULL); -#endif } #endif diff --git a/arch/arm/src/armv7-a/arm_fetchadd.S b/arch/arm/src/armv7-a/arm_fetchadd.S deleted file mode 100644 index 930b048895a8c..0000000000000 --- a/arch/arm/src/armv7-a/arm_fetchadd.S +++ /dev/null @@ -1,240 +0,0 @@ -/**************************************************************************** - * arch/arm/src/armv7-a/arm_fetchadd.S - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. The - * ASF licenses this file to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance with the - * License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - ****************************************************************************/ - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include - - .file "arm_fetchadd.S" - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - - .text - -/**************************************************************************** - * Name: up_fetchadd32 - * - * Description: - * Perform an atomic fetch add operation on the provided 32-bit value. - * - * This function must be provided via the architecture-specific logic. - * - * Input Parameters: - * addr - The address of 32-bit value to be incremented. - * value - The 32-bit addend - * - * Returned Value: - * The incremented value (volatile!) - * - ****************************************************************************/ - - .globl up_fetchadd32 - .type up_fetchadd32, %function - -up_fetchadd32: - -1: - ldrex r2, [r0] /* Fetch the value to be incremented */ - add r2, r2, r1 /* Add the addend */ - - strex r3, r2, [r0] /* Attempt to save the result */ - teq r3, #0 /* r3 will be 1 if strex failed */ - bne 1b /* Failed to lock... try again */ - - mov r0, r2 /* Return the incremented value */ - bx lr /* Successful! */ - .size up_fetchadd32, . - up_fetchadd32 - -/**************************************************************************** - * Name: up_fetchsub32 - * - * Description: - * Perform an atomic fetch subtract operation on the provided 32-bit value. - * - * This function must be provided via the architecture-specific logic. - * - * Input Parameters: - * addr - The address of 32-bit value to be decremented. - * value - The 32-bit subtrahend - * - * Returned Value: - * The decremented value (volatile!) - * - ****************************************************************************/ - - .globl up_fetchsub32 - .type up_fetchsub32, %function - -up_fetchsub32: - -1: - ldrex r2, [r0] /* Fetch the value to be decremented */ - sub r2, r2, r1 /* Subtract the subtrahend */ - - strex r3, r2, [r0] /* Attempt to save the result */ - teq r3, #0 /* r3 will be 1 if strex failed */ - bne 1b /* Failed to lock... try again */ - - mov r0, r2 /* Return the decremented value */ - bx lr /* Successful! */ - .size up_fetchsub32, . - up_fetchsub32 - -/**************************************************************************** - * Name: up_fetchadd16 - * - * Description: - * Perform an atomic fetch add operation on the provided 16-bit value. - * - * This function must be provided via the architecture-specific logic. - * - * Input Parameters: - * addr - The address of 16-bit value to be incremented. - * value - The 16-bit addend - * - * Returned Value: - * The incremented value (volatile!) - * - ****************************************************************************/ - - .globl up_fetchadd16 - .type up_fetchadd16, %function - -up_fetchadd16: - -1: - ldrexh r2, [r0] /* Fetch the value to be incremented */ - add r2, r2, r1 /* Add the addend */ - - strexh r3, r2, [r0] /* Attempt to save the result */ - teq r3, #0 /* r3 will be 1 if strexh failed */ - bne 1b /* Failed to lock... try again */ - - mov r0, r2 /* Return the incremented value */ - bx lr /* Successful! */ - .size up_fetchadd16, . - up_fetchadd16 - -/**************************************************************************** - * Name: up_fetchsub16 - * - * Description: - * Perform an atomic fetch subtract operation on the provided 16-bit value. - * - * This function must be provided via the architecture-specific logic. - * - * Input Parameters: - * addr - The address of 16-bit value to be decremented. - * value - The 16-bit subtrahend - * - * Returned Value: - * The decremented value (volatile!) - * - ****************************************************************************/ - - .globl up_fetchsub16 - .type up_fetchsub16, %function - -up_fetchsub16: - -1: - ldrexh r2, [r0] /* Fetch the value to be decremented */ - sub r2, r2, r1 /* Subtract the subtrahend */ - - /* Attempt to save the decremented value */ - - strexh r3, r2, [r0] /* Attempt to save the result */ - teq r3, #0 /* r3 will be 1 if strexh failed */ - bne 1b /* Failed to lock... try again */ - - mov r0, r2 /* Return the decremented value */ - bx lr /* Successful! */ - .size up_fetchsub16, . - up_fetchsub16 - -/**************************************************************************** - * Name: up_fetchadd8 - * - * Description: - * Perform an atomic fetch add operation on the provided 8-bit value. - * - * This function must be provided via the architecture-specific logic. - * - * Input Parameters: - * addr - The address of 8-bit value to be incremented. - * value - The 8-bit addend - * - * Returned Value: - * The incremented value (volatile!) - * - ****************************************************************************/ - - .globl up_fetchadd8 - .type up_fetchadd8, %function - -up_fetchadd8: - -1: - ldrexb r2, [r0] /* Fetch the value to be incremented */ - add r2, r2, r1 /* Add the addend */ - - strexb r3, r2, [r0] /* Attempt to save the result */ - teq r3, #0 /* r3 will be 1 if strexb failed */ - bne 1b /* Failed to lock... try again */ - - mov r0, r2 /* Return the incremented value */ - bx lr /* Successful! */ - .size up_fetchadd8, . - up_fetchadd8 - -/**************************************************************************** - * Name: up_fetchsub8 - * - * Description: - * Perform an atomic fetch subtract operation on the provided 8-bit value. - * - * This function must be provided via the architecture-specific logic. - * - * Input Parameters: - * addr - The address of 8-bit value to be decremented. - * value - The 8-bit subtrahend - * - * Returned Value: - * The decremented value (volatile!) - * - ****************************************************************************/ - - .globl up_fetchsub8 - .type up_fetchsub8, %function - -up_fetchsub8: - -1: - ldrexb r2, [r0] /* Fetch the value to be decremented */ - sub r2, r2, r1 /* Subtract the subtrahend */ - - strexb r3, r2, [r0] /* Attempt to save the result */ - teq r3, #0 /* r3 will be 1 if strexb failed */ - bne 1b /* Failed to lock... try again */ - - mov r0, r2 /* Return the decremented value */ - bx lr /* Successful! */ - .size up_fetchsub8, . - up_fetchsub8 - .end diff --git a/drivers/power/greedy_governor.h b/arch/arm/src/armv7-a/arm_fpucmp.c similarity index 72% rename from drivers/power/greedy_governor.h rename to arch/arm/src/armv7-a/arm_fpucmp.c index 96bac1b2396cf..6bf2dbca3f574 100644 --- a/drivers/power/greedy_governor.h +++ b/arch/arm/src/armv7-a/arm_fpucmp.c @@ -1,5 +1,5 @@ /**************************************************************************** - * drivers/power/greedy_governor.h + * arch/arm/src/armv7-a/arm_fpucmp.c * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with @@ -18,49 +18,41 @@ * ****************************************************************************/ -#ifndef __DRIVERS_POWER_GREEDY_GOVERNER_H -#define __DRIVERS_POWER_GREEDY_GOVERNER_H - /**************************************************************************** * Included Files ****************************************************************************/ #include -#include -#include + +#include +#include +#include + +#include "arm_internal.h" /**************************************************************************** - * Public Data + * Pre-processor Definitions ****************************************************************************/ -#ifdef __cplusplus -#define EXTERN extern "C" -extern "C" -{ -#else -#define EXTERN extern -#endif +#ifdef CONFIG_ARCH_FPU /**************************************************************************** - * Public Function Prototypes + * Public Functions ****************************************************************************/ /**************************************************************************** - * Name: pm_greedy_governor_register + * Name: up_fpucmp * * Description: - * Return the greedy governor instance. - * - * Returned Value: - * A pointer to the governor struct. Otherwise NULL is returned on error. + * compare FPU areas from thread context * ****************************************************************************/ -FAR const struct pm_governor_s *pm_greedy_governor_initialize(void); +bool up_fpucmp(const void *saveregs1, const void *saveregs2) +{ + const uint32_t *regs1 = saveregs1; + const uint32_t *regs2 = saveregs2; -#undef EXTERN -#ifdef __cplusplus + return memcmp(®s1[REG_S0], ®s2[REG_S0], 4 * FPU_CONTEXT_REGS) == 0; } -#endif - -#endif /* __DRIVERS_POWER_GREEDY_GOVERNER_H */ +#endif /* CONFIG_ARCH_FPU */ diff --git a/arch/arm/src/armv7-a/arm_head.S b/arch/arm/src/armv7-a/arm_head.S index 4ff7db84d0f7f..53ab81fb5f2d1 100644 --- a/arch/arm/src/armv7-a/arm_head.S +++ b/arch/arm/src/armv7-a/arm_head.S @@ -174,8 +174,7 @@ __start: /* Make sure that we are in SYS mode with IRQs and FIQs disabled */ - mov r0, #(PSR_MODE_SYS | PSR_I_BIT | PSR_F_BIT) - msr cpsr_c, r0 + cpsid if, #PSR_MODE_SYS /* The MMU and caches should be disabled */ diff --git a/arch/arm/src/armv7-a/arm_initialstate.c b/arch/arm/src/armv7-a/arm_initialstate.c index 36650eb451f24..0125f2bf8d4c5 100644 --- a/arch/arm/src/armv7-a/arm_initialstate.c +++ b/arch/arm/src/armv7-a/arm_initialstate.c @@ -82,9 +82,9 @@ void up_initial_state(struct tcb_s *tcb) /* Initialize the context registers to stack top */ - xcp->regs = (FAR void *)((uint32_t)tcb->stack_base_ptr + - tcb->adj_stack_size - - XCPTCONTEXT_SIZE); + xcp->regs = (void *)((uint32_t)tcb->stack_base_ptr + + tcb->adj_stack_size - + XCPTCONTEXT_SIZE); /* Initialize the xcp registers */ diff --git a/arch/arm/src/armv7-a/arm_pgalloc.c b/arch/arm/src/armv7-a/arm_pgalloc.c index 4ca10bf3b4afc..8ced494326d3d 100644 --- a/arch/arm/src/armv7-a/arm_pgalloc.c +++ b/arch/arm/src/armv7-a/arm_pgalloc.c @@ -55,7 +55,7 @@ static uintptr_t alloc_pgtable(void) { irqstate_t flags; uintptr_t paddr; - FAR uint32_t *l2table; + uint32_t *l2table; #ifndef CONFIG_ARCH_PGPOOL_MAPPING uint32_t l1save; #endif @@ -73,14 +73,14 @@ static uintptr_t alloc_pgtable(void) #ifdef CONFIG_ARCH_PGPOOL_MAPPING /* Get the virtual address corresponding to the physical page address */ - l2table = (FAR uint32_t *)arm_pgvaddr(paddr); + l2table = (uint32_t *)arm_pgvaddr(paddr); #else /* Temporarily map the page into the virtual address space */ l1save = mmu_l1_getentry(ARCH_SCRATCH_VBASE); mmu_l1_setentry(paddr & ~SECTION_MASK, ARCH_SCRATCH_VBASE, MMU_MEMFLAGS); - l2table = (FAR uint32_t *)(ARCH_SCRATCH_VBASE | + l2table = (uint32_t *)(ARCH_SCRATCH_VBASE | (paddr & SECTION_MASK)); #endif @@ -115,7 +115,7 @@ static uintptr_t alloc_pgtable(void) * ****************************************************************************/ -static int get_pgtable(FAR group_addrenv_t *addrenv, uintptr_t vaddr) +static int get_pgtable(group_addrenv_t *addrenv, uintptr_t vaddr) { uint32_t l1entry; uintptr_t paddr; @@ -150,7 +150,7 @@ static int get_pgtable(FAR group_addrenv_t *addrenv, uintptr_t vaddr) */ l1entry = paddr | MMU_L1_PGTABFLAGS; - addrenv->heap[hpndx] = (FAR uintptr_t *)l1entry; + addrenv->heap[hpndx] = (uintptr_t *)l1entry; /* And instantiate the modified environment */ @@ -200,9 +200,9 @@ static int get_pgtable(FAR group_addrenv_t *addrenv, uintptr_t vaddr) uintptr_t pgalloc(uintptr_t brkaddr, unsigned int npages) { - FAR struct tcb_s *tcb = nxsched_self(); - FAR struct task_group_s *group; - FAR uint32_t *l2table; + struct tcb_s *tcb = nxsched_self(); + struct task_group_s *group; + uint32_t *l2table; irqstate_t flags; uintptr_t paddr; #ifndef CONFIG_ARCH_PGPOOL_MAPPING @@ -250,7 +250,7 @@ uintptr_t pgalloc(uintptr_t brkaddr, unsigned int npages) #ifdef CONFIG_ARCH_PGPOOL_MAPPING /* Get the virtual address corresponding to the physical page address */ - l2table = (FAR uint32_t *)arm_pgvaddr(paddr); + l2table = (uint32_t *)arm_pgvaddr(paddr); #else /* Temporarily map the level 2 page table into the "scratch" virtual * address space @@ -259,7 +259,7 @@ uintptr_t pgalloc(uintptr_t brkaddr, unsigned int npages) l1save = mmu_l1_getentry(ARCH_SCRATCH_VBASE); mmu_l1_setentry(paddr & ~SECTION_MASK, ARCH_SCRATCH_VBASE, MMU_MEMFLAGS); - l2table = (FAR uint32_t *)(ARCH_SCRATCH_VBASE | + l2table = (uint32_t *)(ARCH_SCRATCH_VBASE | (paddr & SECTION_MASK)); #endif diff --git a/arch/arm/src/armv7-a/arm_pghead.S b/arch/arm/src/armv7-a/arm_pghead.S index 26b3e319a697e..e53563d775792 100644 --- a/arch/arm/src/armv7-a/arm_pghead.S +++ b/arch/arm/src/armv7-a/arm_pghead.S @@ -203,8 +203,7 @@ __start: /* Make sure that we are in SYS mode with IRQs and FIQs disabled */ - mov r0, #(PSR_MODE_SYS | PSR_I_BIT | PSR_F_BIT) - msr cpsr_c, r0 + cpsid if, #PSR_MODE_SYS /* Clear the 16K level 1 page table */ diff --git a/arch/arm/src/armv7-a/arm_physpgaddr.c b/arch/arm/src/armv7-a/arm_physpgaddr.c index d5ccf73a03739..661aa27c5d8c5 100644 --- a/arch/arm/src/armv7-a/arm_physpgaddr.c +++ b/arch/arm/src/armv7-a/arm_physpgaddr.c @@ -54,7 +54,7 @@ uintptr_t arm_physpgaddr(uintptr_t vaddr) { - FAR uint32_t *l2table; + uint32_t *l2table; uintptr_t paddr; uint32_t l1entry; #ifndef CONFIG_ARCH_PGPOOL_MAPPING @@ -84,14 +84,14 @@ uintptr_t arm_physpgaddr(uintptr_t vaddr) #ifdef CONFIG_ARCH_PGPOOL_MAPPING /* Get the virtual address of the base of level 2 page table */ - l2table = (FAR uint32_t *)arm_pgvaddr(paddr); + l2table = (uint32_t *)arm_pgvaddr(paddr); #else /* Temporarily map the page into the virtual address space */ l1save = mmu_l1_getentry(ARCH_SCRATCH_VBASE); mmu_l1_setentry(paddr & ~SECTION_MASK, ARCH_SCRATCH_VBASE, MMU_MEMFLAGS); - l2table = (FAR uint32_t *)(ARCH_SCRATCH_VBASE | + l2table = (uint32_t *)(ARCH_SCRATCH_VBASE | (paddr & SECTION_MASK)); #endif if (l2table) diff --git a/arch/arm/src/armv7-a/arm_restorefpu.S b/arch/arm/src/armv7-a/arm_restorefpu.S deleted file mode 100644 index 809d3c2a9bb43..0000000000000 --- a/arch/arm/src/armv7-a/arm_restorefpu.S +++ /dev/null @@ -1,92 +0,0 @@ -/**************************************************************************** - * arch/arm/src/armv7-a/arm_restorefpu.S - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. The - * ASF licenses this file to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance with the - * License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - ****************************************************************************/ - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include - -#include - -#ifdef CONFIG_ARCH_FPU - -/**************************************************************************** - * Public Symbols - ****************************************************************************/ - - .globl arm_restorefpu - .file "arm_restorefpu.S" - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - - .text - -/**************************************************************************** - * Name: arm_restorefpu - * - * Description: - * Given the pointer to a register save area (in R0), restore the state of the - * floating point registers. - * - * C Function Prototype: - * void arm_restorefpu(const uint32_t *regs); - * - * Input Parameters: - * regs - A pointer to the register save area containing the floating point - * registers. - * - * Returned Value: - * This function does not return anything explicitly. However, it is called from - * interrupt level assembly logic that assumes that r0 is preserved. - * - ****************************************************************************/ - - .globl arm_restorefpu - .type arm_restorefpu, function - -arm_restorefpu: - - add r1, r0, #(4*REG_S0) /* R1=Address of FP register storage */ - - /* Load all floating point registers. Registers are loaded in numeric order, - * s0, s1, ... in increasing address order. - */ - -#ifdef CONFIG_ARM_DPFPU32 - vldmia.64 r1!, {d0-d15} /* Restore the full FP context */ - vldmia.64 r1!, {d16-d31} -#else - vldmia r1!, {s0-s31} /* Restore the full FP context */ -#endif - - /* Load the floating point control and status register. At the end of the - * vstmia, r1 will point to the FPSCR storage location. - */ - - ldr r2, [r1], #4 /* Fetch the floating point control and status register */ - vmsr fpscr, r2 /* Restore the FPSCR */ - bx lr - - .size arm_restorefpu, .-arm_restorefpu -#endif /* CONFIG_ARCH_FPU */ - .end diff --git a/arch/arm/src/armv7-a/arm_saveusercontext.S b/arch/arm/src/armv7-a/arm_saveusercontext.S deleted file mode 100644 index 174d3bfc05498..0000000000000 --- a/arch/arm/src/armv7-a/arm_saveusercontext.S +++ /dev/null @@ -1,138 +0,0 @@ -/**************************************************************************** - * arch/arm/src/armv7-a/arm_saveusercontext.S - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. The - * ASF licenses this file to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance with the - * License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - ****************************************************************************/ - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include -#include - -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -/**************************************************************************** - * Public Symbols - ****************************************************************************/ - - .file "arm_saveusercontext.S" - -/**************************************************************************** - * Macros - ****************************************************************************/ - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: arm_saveusercontext - * - * Description: - * Save the current thread context. Full prototype is: - * - * int arm_saveusercontext(uint32_t *saveregs); - * - * Returned Value: - * 0: Normal return - * 1: Context switch return - * - ****************************************************************************/ - - .globl arm_saveusercontext - .type arm_saveusercontext, function -arm_saveusercontext: - - /* On entry, a1 (r0) holds address of struct xcptcontext */ - - /* Make sure that the return value will be non-zero (the value of the - * other volatile registers don't matter -- r1-r3, ip). This function - * is called through the normal C calling conventions and the values of - * these registers cannot be assumed at the point of setjmp return. - */ - - mov ip, #1 - str ip, [r0, #(4*REG_R0)] - - /* Save the volatile registers (plus r12 which really - * doesn't need to be saved) - */ - - add r1, r0, #(4*REG_R4) - stmia r1, {r4-r14} - - /* Save the current cpsr */ - - mrs r2, cpsr /* R2 = CPSR value */ - add r1, r0, #(4*REG_CPSR) - str r2, [r1] - - /* Save the return address as the PC so that we return to the exit from - * this function. - */ - - ldr r2, =1f - add r1, r0, #(4*REG_PC) - str r2, [r1] - - /* Save the floating point registers. - * REVISIT: Not all of the floating point registers need to be saved. - * Some are volatile and need not be preserved across functions calls. - * But right now, I can't find the definitive list of the volatile - * floating point registers. - */ - -#ifdef CONFIG_ARCH_FPU - add r1, r0, #(4*REG_S0) /* R1=Address of FP register storage */ - - /* Store all floating point registers. Registers are stored in numeric order, - * s0, s1, ... in increasing address order. - */ - -#ifdef CONFIG_ARM_DPFPU32 - vstmia.64 r1!, {d0-d15} /* Save the full FP context */ - vstmia.64 r1!, {d16-d31} -#else - vstmia r1!, {s0-s31} /* Save the full FP context */ -#endif - - /* Store the floating point control and status register. At the end of the - * vstmia, r1 will point to the FPSCR storage location. - */ - - vmrs r2, fpscr /* Fetch the FPSCR */ - str r2, [r1], #4 /* Save the floating point control and status register */ -#endif - - /* Return 0 now indicating that this return is not a context switch */ - - mov r0, #0 /* Return value == 0 */ - bx lr /* Return */ - -1: - - /* Return 1 now indicating that this return is a context switch */ - - mov r0, #1 /* Return value == 1 */ - bx lr /* Return */ - - .size arm_saveusercontext, .-arm_saveusercontext - .end diff --git a/arch/arm/src/armv7-a/arm_schedulesigaction.c b/arch/arm/src/armv7-a/arm_schedulesigaction.c index 497cec24afe53..f21b7a905c412 100644 --- a/arch/arm/src/armv7-a/arm_schedulesigaction.c +++ b/arch/arm/src/armv7-a/arm_schedulesigaction.c @@ -139,10 +139,10 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver) * delivered. */ - CURRENT_REGS = (FAR void *) + CURRENT_REGS = (void *) ((uint32_t)CURRENT_REGS - (uint32_t)XCPTCONTEXT_SIZE); - memcpy((FAR uint32_t *)CURRENT_REGS, tcb->xcp.saved_regs, + memcpy((uint32_t *)CURRENT_REGS, tcb->xcp.saved_regs, XCPTCONTEXT_SIZE); CURRENT_REGS[REG_SP] = (uint32_t)CURRENT_REGS + @@ -184,7 +184,7 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver) * delivered. */ - tcb->xcp.regs = (FAR void *) + tcb->xcp.regs = (void *) ((uint32_t)tcb->xcp.regs - (uint32_t)XCPTCONTEXT_SIZE); memcpy(tcb->xcp.regs, tcb->xcp.saved_regs, XCPTCONTEXT_SIZE); @@ -286,7 +286,7 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver) * been delivered. */ - tcb->xcp.regs = (FAR void *) + tcb->xcp.regs = (void *) ((uint32_t)tcb->xcp.regs - (uint32_t)XCPTCONTEXT_SIZE); memcpy(tcb->xcp.regs, tcb->xcp.saved_regs, @@ -316,7 +316,7 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver) * has been delivered. */ - tcb->xcp.sigdeliver = (FAR void *)sigdeliver; + tcb->xcp.sigdeliver = (void *)sigdeliver; /* And make sure that the saved context in the TCB is the * same as the interrupt return context. @@ -329,10 +329,10 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver) * been delivered. */ - CURRENT_REGS = (FAR void *) + CURRENT_REGS = (void *) ((uint32_t)CURRENT_REGS - (uint32_t)XCPTCONTEXT_SIZE); - memcpy((FAR uint32_t *)CURRENT_REGS, tcb->xcp.saved_regs, + memcpy((uint32_t *)CURRENT_REGS, tcb->xcp.saved_regs, XCPTCONTEXT_SIZE); CURRENT_REGS[REG_SP] = (uint32_t)CURRENT_REGS + @@ -397,7 +397,7 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver) * delivered. */ - tcb->xcp.regs = (FAR void *) + tcb->xcp.regs = (void *) ((uint32_t)tcb->xcp.regs - (uint32_t)XCPTCONTEXT_SIZE); memcpy(tcb->xcp.regs, tcb->xcp.saved_regs, XCPTCONTEXT_SIZE); diff --git a/arch/arm/src/armv7-a/arm_signal_dispatch.c b/arch/arm/src/armv7-a/arm_signal_dispatch.c deleted file mode 100644 index 8a94b46f75735..0000000000000 --- a/arch/arm/src/armv7-a/arm_signal_dispatch.c +++ /dev/null @@ -1,92 +0,0 @@ -/**************************************************************************** - * arch/arm/src/armv7-a/arm_signal_dispatch.c - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. The - * ASF licenses this file to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance with the - * License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - ****************************************************************************/ - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include -#include - -#include - -#include "pgalloc.h" -#include "arm_internal.h" - -#if !defined(CONFIG_BUILD_FLAT) && defined(__KERNEL__) - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: up_signal_dispatch - * - * Description: - * In this kernel mode build, this function will be called to execute a - * a signal handler in user-space. When the signal is delivered, a - * kernel-mode stub will first run to perform some housekeeping functions. - * This kernel-mode stub will then be called transfer control to the user - * mode signal handler by calling this function. - * - * Normally the user-mode signalling handling stub will also execute - * before the ultimate signal handler is called. See - * arch/arm/src/armv7-a/crt0.c. This function is the - * user-space, signal handler trampoline function. It is called from - * up_signal_dispatch() in user-mode. - * - * Input Parameters: - * sighand - The address user-space signal handling function - * signo, info, and ucontext - Standard arguments to be passed to the - * signal handling function. - * - * Returned Value: - * None. This function does not return in the normal sense. It returns - * via an architecture specific system call made by up_signal_handler(). - * However, this will look like a normal return by the caller of - * up_signal_dispatch. - * - ****************************************************************************/ - -void up_signal_dispatch(_sa_sigaction_t sighand, int signo, - FAR siginfo_t *info, FAR void *ucontext) -{ - /* We are signalling a user group, but does the signal handler lie in the - * user address space? Or the kernel address space? The OS does - * intercept some signals for its own purpose (such as the death-of-child - * signal. - */ - - if (arm_uservaddr((uintptr_t)sighand)) - { - /* Yes.. Let sys_call4() do all of the work to get us into user space */ - - sys_call4(SYS_signal_handler, (uintptr_t)sighand, (uintptr_t)signo, - (uintptr_t)info, (uintptr_t)ucontext); - } - else - { - /* No.. we are already in kernel mode so just call the handler */ - - sighand(signo, info, ucontext); - } -} - -#endif /* !CONFIG_BUILD_FLAT && __KERNEL__ */ diff --git a/arch/arm/src/armv7-a/arm_syscall.c b/arch/arm/src/armv7-a/arm_syscall.c index 0ac7c8c636f6c..b621d6044fc6c 100644 --- a/arch/arm/src/armv7-a/arm_syscall.c +++ b/arch/arm/src/armv7-a/arm_syscall.c @@ -35,10 +35,11 @@ #include #include -#include "signal/signal.h" -#include "arm.h" #include "addrenv.h" +#include "arm.h" #include "arm_internal.h" +#include "group/group.h" +#include "signal/signal.h" /**************************************************************************** * Private Functions @@ -165,7 +166,13 @@ uint32_t *arm_syscall(uint32_t *regs) /* Nested interrupts are not supported */ - DEBUGASSERT(regs); + DEBUGASSERT(CURRENT_REGS == NULL); + + /* Current regs non-zero indicates that we are processing an interrupt; + * CURRENT_REGS is also used to manage interrupt level context switches. + */ + + CURRENT_REGS = regs; /* The SYSCALL command is in R0 on entry. Parameters follow in R1..R7 */ @@ -196,7 +203,7 @@ uint32_t *arm_syscall(uint32_t *regs) #ifdef CONFIG_LIB_SYSCALL case SYS_syscall_return: { - FAR struct tcb_s *rtcb = nxsched_self(); + struct tcb_s *rtcb = nxsched_self(); int index = (int)rtcb->xcp.nsyscalls - 1; /* Make sure that there is a saved SYSCALL return address. */ @@ -239,7 +246,7 @@ uint32_t *arm_syscall(uint32_t *regs) */ rtcb->flags &= ~TCB_FLAG_SYSCALL; - (void)nxsig_unmask_pendingsignal(); + nxsig_unmask_pendingsignal(); } break; #endif @@ -262,9 +269,8 @@ uint32_t *arm_syscall(uint32_t *regs) * set will determine the restored context. */ - arm_restorefpu((uint32_t *)regs[REG_R1]); - regs = (uint32_t *)regs[REG_R1]; - DEBUGASSERT(regs); + CURRENT_REGS = (uint32_t *)regs[REG_R1]; + DEBUGASSERT(CURRENT_REGS); } break; @@ -288,16 +294,14 @@ uint32_t *arm_syscall(uint32_t *regs) case SYS_switch_context: { DEBUGASSERT(regs[REG_R1] != 0 && regs[REG_R2] != 0); - arm_savefpu(regs); - arm_restorefpu((uint32_t *)regs[REG_R2]); *(uint32_t **)regs[REG_R1] = regs; - regs = (uint32_t *)regs[REG_R2]; + CURRENT_REGS = (uint32_t *)regs[REG_R2]; } break; /* R0=SYS_task_start: This a user task start * - * void up_task_start(main_t taskentry, int argc, FAR char *argv[]) + * void up_task_start(main_t taskentry, int argc, char *argv[]) * noreturn_function; * * At this point, the following values are saved in context: @@ -368,7 +372,7 @@ uint32_t *arm_syscall(uint32_t *regs) /* R0=SYS_signal_handler: This a user signal handler callback * * void signal_handler(_sa_sigaction_t sighand, int signo, - * FAR siginfo_t *info, FAR void *ucontext); + * siginfo_t *info, void *ucontext); * * At this point, the following values are saved in context: * @@ -381,7 +385,7 @@ uint32_t *arm_syscall(uint32_t *regs) case SYS_signal_handler: { - FAR struct tcb_s *rtcb = nxsched_self(); + struct tcb_s *rtcb = nxsched_self(); /* Remember the caller's return address */ @@ -418,7 +422,7 @@ uint32_t *arm_syscall(uint32_t *regs) DEBUGASSERT(rtcb->xcp.kstkptr == NULL && rtcb->xcp.ustkptr != NULL); - rtcb->xcp.kstkptr = (FAR uint32_t *)regs[REG_SP]; + rtcb->xcp.kstkptr = (uint32_t *)regs[REG_SP]; regs[REG_SP] = (uint32_t)rtcb->xcp.ustkptr; } #endif @@ -438,7 +442,7 @@ uint32_t *arm_syscall(uint32_t *regs) case SYS_signal_handler_return: { - FAR struct tcb_s *rtcb = nxsched_self(); + struct tcb_s *rtcb = nxsched_self(); /* Set up to return to the kernel-mode signal dispatching logic. */ @@ -476,7 +480,7 @@ uint32_t *arm_syscall(uint32_t *regs) default: { #ifdef CONFIG_LIB_SYSCALL - FAR struct tcb_s *rtcb = nxsched_self(); + struct tcb_s *rtcb = nxsched_self(); int index = rtcb->xcp.nsyscalls; /* Verify that the SYS call number is within range */ @@ -516,7 +520,7 @@ uint32_t *arm_syscall(uint32_t *regs) if (index == 0 && rtcb->xcp.kstack != NULL) { - rtcb->xcp.ustkptr = (FAR uint32_t *)regs[REG_SP]; + rtcb->xcp.ustkptr = (uint32_t *)regs[REG_SP]; regs[REG_SP] = (uint32_t)rtcb->xcp.kstack + ARCH_KERNEL_STACKSIZE; } @@ -532,10 +536,37 @@ uint32_t *arm_syscall(uint32_t *regs) break; } +#ifdef CONFIG_ARCH_ADDRENV + /* Check for a context switch. If a context switch occurred, then + * CURRENT_REGS will have a different value than it did on entry. If an + * interrupt level context switch has occurred, then establish the correct + * address environment before returning from the interrupt. + */ + + if (regs != CURRENT_REGS) + { + /* Make sure that the address environment for the previously + * running task is closed down gracefully (data caches dump, + * MMU flushed) and set up the address environment for the new + * thread at the head of the ready-to-run list. + */ + + group_addrenv(NULL); + } +#endif + + regs = (uint32_t *)CURRENT_REGS; + /* Report what happened */ dump_syscall("Exit", cmd, regs); + /* Set CURRENT_REGS to NULL to indicate that we are no longer in an + * interrupt handler. + */ + + CURRENT_REGS = NULL; + /* Return the last value of curent_regs. This supports context switches * on return from the exception. That capability is only used with the * SYS_context_switch system call. diff --git a/arch/arm/src/armv7-a/arm_tcbinfo.c b/arch/arm/src/armv7-a/arm_tcbinfo.c index a4fc0a595e257..2fefe348fbc5a 100644 --- a/arch/arm/src/armv7-a/arm_tcbinfo.c +++ b/arch/arm/src/armv7-a/arm_tcbinfo.c @@ -102,11 +102,13 @@ static const uint16_t g_reg_offs[] = const struct tcbinfo_s g_tcbinfo = { - TCB_PID_OFF, - TCB_STATE_OFF, - TCB_PRI_OFF, - TCB_NAME_OFF, - XCPTCONTEXT_REGS, + .pid_off = TCB_PID_OFF, + .state_off = TCB_STATE_OFF, + .pri_off = TCB_PRI_OFF, + .name_off = TCB_NAME_OFF, + .regs_off = TCB_REGS_OFF, + .basic_num = 17, + .total_num = XCPTCONTEXT_REGS, { .p = g_reg_offs, }, diff --git a/arch/arm/src/armv7-a/arm_vectors.S b/arch/arm/src/armv7-a/arm_vectors.S index a4a6bbc425662..178b6cca7c3bb 100644 --- a/arch/arm/src/armv7-a/arm_vectors.S +++ b/arch/arm/src/armv7-a/arm_vectors.S @@ -88,6 +88,66 @@ .endm #endif +/**************************************************************************** + * Name: savefpu + * + * Description: + * Save the state of the floating point registers. + * + ****************************************************************************/ + +#ifdef CONFIG_ARCH_FPU + .macro savefpu, out, tmp + /* Store all floating point registers. Registers are stored in numeric order, + * s0, s1, ... in increasing address order. + */ + +#ifdef CONFIG_ARM_DPFPU32 + vstmia.64 \out!, {d0-d15} /* Save the full FP context */ + vstmia.64 \out!, {d16-d31} +#else + vstmia \out!, {s0-s31} /* Save the full FP context */ +#endif + + /* Store the floating point control and status register. At the end of the + * vstmia, r1 will point to the FPSCR storage location. + */ + + vmrs \tmp, fpscr /* Fetch the FPSCR */ + str \tmp, [\out], #4 /* Save the floating point control and status register */ + .endm +#endif + +/**************************************************************************** + * Name: restorefpu + * + * Description: + * Restore the state of the floating point registers. + * + ****************************************************************************/ + +#ifdef CONFIG_ARCH_FPU + .macro restorefpu, in, tmp + /* Load all floating point registers. Registers are loaded in numeric order, + * s0, s1, ... in increasing address order. + */ + +#ifdef CONFIG_ARM_DPFPU32 + vldmia.64 \in!, {d0-d15} /* Restore the full FP context */ + vldmia.64 \in!, {d16-d31} +#else + vldmia \in!, {s0-s31} /* Restore the full FP context */ +#endif + + /* Load the floating point control and status register. At the end of the + * vstmia, \in will point to the FPSCR storage location. + */ + + ldr \tmp, [\in], #4 /* Fetch the floating point control and status register */ + vmsr fpscr, \tmp /* Restore the FPSCR */ + .endm +#endif + /**************************************************************************** * Private Functions ****************************************************************************/ @@ -111,16 +171,13 @@ .type arm_vectorirq, %function arm_vectorirq: - /* On entry, we are in IRQ mode. We are free to use the IRQ mode r13 - * and r14. - */ + /* Switch to SYS mode */ #ifdef CONFIG_ARMV7A_DECODEFIQ - mov r13, #(PSR_MODE_SYS | PSR_I_BIT | PSR_F_BIT) + cpsid if, #PSR_MODE_SYS #else - mov r13, #(PSR_MODE_SYS | PSR_I_BIT) + cpsid i, #PSR_MODE_SYS #endif - msr cpsr_c, r13 /* Switch to SYS mode */ /* Create a context structure. First set aside a stack frame * and store r0-r12 into the frame. @@ -129,26 +186,14 @@ arm_vectorirq: sub sp, sp, #XCPTCONTEXT_SIZE stmia sp, {r0-r12} /* Save the SYS mode regs */ -#ifdef CONFIG_ARMV7A_DECODEFIQ - mov r0, #(PSR_MODE_IRQ | PSR_I_BIT | PSR_F_BIT) -#else - mov r0, #(PSR_MODE_IRQ | PSR_I_BIT) -#endif - msr cpsr_c, r0 /* Switch back IRQ mode */ + cps #PSR_MODE_IRQ /* Switch back IRQ mode */ /* Get the values for r15(pc) and CPSR in r3 and r4 */ sub r3, lr, #4 mrs r4, spsr - /* Then switch back to SYS mode */ - -#ifdef CONFIG_ARMV7A_DECODEFIQ - orr r0, r0, #(PSR_MODE_SYS | PSR_I_BIT | PSR_F_BIT) -#else - orr r0, r0, #(PSR_MODE_SYS | PSR_I_BIT) -#endif - msr cpsr_c, r0 + cps #PSR_MODE_SYS /* Then switch back to SYS mode */ /* Get the correct values of USR/SYS r13(sp) and r14(lr) in r1 and r2 */ @@ -160,6 +205,13 @@ arm_vectorirq: add r0, sp, #(4*REG_SP) /* Offset to pc, cpsr storage */ stmia r0, {r1-r4} +#ifdef CONFIG_ARCH_FPU + /* Save the state of the floating point registers. */ + + add r0, sp, #(4*REG_S0) /* R1=Address of FP register storage */ + savefpu r0, r1 +#endif + /* Then call the IRQ handler with interrupts disabled. */ mov fp, #0 /* Init frame pointer */ @@ -196,20 +248,35 @@ arm_vectorirq: mov sp, r4 /* Restore the possibly unaligned stack pointer */ #endif +#ifdef CONFIG_ARCH_FPU + /* Restore the state of the floating point registers. */ + + add r1, r0, #(4*REG_S0) /* R1=Address of FP register storage */ + restorefpu r1, r2 +#endif + + /* Switch back IRQ mode and return with shadow SPSR */ + + cps #PSR_MODE_IRQ + /* Upon return from arm_decodeirq, r0 holds the pointer to the register * state save area to use to restore the registers. This may or may not * be the same value that was passed to arm_decodeirq: It will differ if a * context switch is required. */ - /* Restore the CPSR, SYS mode registers and return */ + /* Restore the CPSR, IRQ mode registers and return */ ldr r1, [r0, #(4*REG_CPSR)] /* Fetch the return SPSR */ msr spsr_cxsf, r1 /* Set the return mode SPSR */ - /* Life is simple when everything is SYS mode */ + /* Life is simple when everything is IRQ mode */ - ldmia r0, {r0-r15}^ /* Return */ + mov r14, r0 /* (IRQ) r14=Register storage area */ + ldmia r14!, {r0-r12} /* Restore common r0-r12 */ + ldmia r14, {r13, r14}^ /* Restore user mode r13/r14 */ + add r14, r14, #(4*2) /* (IRQ) r14=address of r15 storage */ + ldmia r14, {r15}^ /* Return */ #if !defined(CONFIG_SMP) && CONFIG_ARCH_INTERRUPTSTACK > 7 .Lirqstacktop: @@ -232,13 +299,13 @@ arm_vectorirq: .type arm_vectorsvc, %function arm_vectorsvc: + /* Switch to SYS mode */ #ifdef CONFIG_ARMV7A_DECODEFIQ - mov r13, #(PSR_MODE_SYS | PSR_I_BIT | PSR_F_BIT) + cpsid if, #PSR_MODE_SYS #else - mov r13, #(PSR_MODE_SYS | PSR_I_BIT) + cpsid i, #PSR_MODE_SYS #endif - msr cpsr_c, r13 /* Switch to SYS mode */ /* Create a context structure. First set aside a stack frame * and store r0-r12 into the frame. @@ -247,24 +314,14 @@ arm_vectorsvc: sub sp, sp, #XCPTCONTEXT_SIZE stmia sp, {r0-r12} /* Save the SYS mode regs */ -#ifdef CONFIG_ARMV7A_DECODEFIQ - mov r0, #(PSR_MODE_SVC | PSR_I_BIT | PSR_F_BIT) -#else - mov r0, #(PSR_MODE_SVC | PSR_I_BIT) -#endif - msr cpsr_c, r0 /* Switch back SVC mode */ + cps #PSR_MODE_SVC /* Switch back SVC mode */ /* Get the values for r15(pc) and CPSR in r3 and r4 */ mov r3, r14 /* Save r14 as the PC as well */ mrs r4, spsr /* Get the saved CPSR */ -#ifdef CONFIG_ARMV7A_DECODEFIQ - orr r0, r0, #(PSR_MODE_SYS | PSR_I_BIT | PSR_F_BIT) -#else - orr r0, r0, #(PSR_MODE_SYS | PSR_I_BIT) -#endif - msr cpsr_c, r0 + cps #PSR_MODE_SYS /* Then switch back to SYS mode */ /* Get the correct values of USR/SYS r13(sp) and r14(lr) in r1 and r2 */ @@ -276,6 +333,13 @@ arm_vectorsvc: add r0, sp, #(4*REG_SP) /* Offset to pc, cpsr storage */ stmia r0, {r1-r4} +#ifdef CONFIG_ARCH_FPU + /* Save the state of the floating point registers. */ + + add r0, sp, #(4*REG_S0) /* R1=Address of FP register storage */ + savefpu r0, r1 +#endif + /* Then call the SVC handler with interrupts disabled. * void arm_syscall(struct xcptcontext *xcp) */ @@ -314,6 +378,17 @@ arm_vectorsvc: mov sp, r4 /* Restore the possibly unaligned stack pointer */ #endif +#ifdef CONFIG_ARCH_FPU + /* Restore the state of the floating point registers. */ + + add r1, r0, #(4*REG_S0) /* R1=Address of FP register storage */ + restorefpu r1, r2 +#endif + + /* Switch back SVC mode and return with shadow SPSR */ + + cps #PSR_MODE_SVC + /* Upon return from arm_syscall, r0 holds the pointer to the register * state save area to use to restore the registers. This may or may not * be the same value that was passed to arm_syscall: It will differ if a @@ -325,9 +400,13 @@ arm_vectorsvc: ldr r1, [r0, #(4*REG_CPSR)] /* Fetch the return SPSR */ msr spsr_cxsf, r1 /* Set the return mode SPSR */ - /* Life is simple when everything is SYS mode */ + /* Life is simple when everything is SVC mode */ - ldmia r0, {r0-r15}^ /* Return */ + mov r14, r0 /* (SVC) r14=Register storage area */ + ldmia r14!, {r0-r12} /* Restore common r0-r12 */ + ldmia r14, {r13, r14}^ /* Restore user mode r13/r14 */ + add r14, r14, #(4*2) /* (SVC) r14=address of r15 storage */ + ldmia r14, {r15}^ /* Return */ .size arm_vectorsvc, . - arm_vectorsvc .align 5 @@ -348,16 +427,13 @@ arm_vectorsvc: .type arm_vectordata, %function arm_vectordata: - /* On entry we are free to use the ABORT mode registers - * r13 and r14 - */ + /* Switch to SYS mode */ #ifdef CONFIG_ARMV7A_DECODEFIQ - mov r13, #(PSR_MODE_SYS | PSR_I_BIT | PSR_F_BIT) + cpsid if, #PSR_MODE_SYS #else - mov r13, #(PSR_MODE_SYS | PSR_I_BIT) + cpsid i, #PSR_MODE_SYS #endif - msr cpsr_c, r13 /* Switch to SYS mode */ /* Create a context structure. First set aside a stack frame * and store r0-r12 into the frame. @@ -366,26 +442,14 @@ arm_vectordata: sub sp, sp, #XCPTCONTEXT_SIZE stmia sp, {r0-r12} /* Save the SYS mode regs */ -#ifdef CONFIG_ARMV7A_DECODEFIQ - mov r0, #(PSR_MODE_ABT | PSR_I_BIT | PSR_F_BIT) -#else - mov r0, #(PSR_MODE_ABT | PSR_I_BIT) -#endif - msr cpsr_c, r0 /* Switch back ABT mode */ + cps #PSR_MODE_ABT /* Switch back ABT mode */ /* Get the values for r15(pc) and CPSR in r3 and r4 */ sub r3, lr, #8 mrs r4, spsr - /* Then switch back to SYS mode */ - -#ifdef CONFIG_ARMV7A_DECODEFIQ - mov r0, #(PSR_MODE_SYS | PSR_I_BIT | PSR_F_BIT) -#else - mov r0, #(PSR_MODE_SYS | PSR_I_BIT) -#endif - msr cpsr_c, r0 + cps #PSR_MODE_SYS /* Then switch back to SYS mode */ /* Get the correct values of USR/SYS r13(sp) and r14(lr) in r1 and r2 */ @@ -397,6 +461,13 @@ arm_vectordata: add r0, sp, #(4*REG_SP) /* Offset to pc, cpsr storage */ stmia r0, {r1-r4} +#ifdef CONFIG_ARCH_FPU + /* Save the state of the floating point registers. */ + + add r0, sp, #(4*REG_S0) /* R1=Address of FP register storage */ + savefpu r0, r1 +#endif + /* Then call the data abort handler with interrupts disabled. * void arm_dataabort(struct xcptcontext *xcp) */ @@ -410,20 +481,35 @@ arm_vectordata: bl arm_dataabort /* Call the handler */ mov sp, r4 /* Restore the possibly unaligned stack pointer */ +#ifdef CONFIG_ARCH_FPU + /* Restore the state of the floating point registers. */ + + add r1, r0, #(4*REG_S0) /* R1=Address of FP register storage */ + restorefpu r1, r2 +#endif + + /* Switch back ABT mode and return with shadow SPSR */ + + cps #PSR_MODE_ABT + /* Upon return from arm_dataabort, r0 holds the pointer to the register * state save area to use to restore the registers. This may or may not * be the same value that was passed to arm_dataabort: It will differ if a * context switch is required. */ - /* Restore the CPSR, SYS mode registers and return */ + /* Restore the CPSR, ABT mode registers and return */ ldr r1, [r0, #(4*REG_CPSR)] /* Fetch the return SPSR */ msr spsr_cxsf, r1 /* Set the return mode SPSR */ - /* Life is simple when everything is SYS mode */ + /* Life is simple when everything is ABT mode */ - ldmia r0, {r0-r15}^ /* Return */ + mov r14, r0 /* (ABT) r14=Register storage area */ + ldmia r14!, {r0-r12} /* Restore common r0-r12 */ + ldmia r14, {r13, r14}^ /* Restore user mode r13/r14 */ + add r14, r14, #(4*2) /* (ABT) r14=address of r15 storage */ + ldmia r14, {r15}^ /* Return */ .size arm_vectordata, . - arm_vectordata .align 5 @@ -444,12 +530,7 @@ arm_vectordata: .type arm_vectorprefetch, %function arm_vectorprefetch: - /* On entry we are free to use the ABORT mode registers - * r13 and r14 - */ - - mov r13, #(PSR_MODE_SYS | PSR_I_BIT | PSR_F_BIT) - msr cpsr_c, r13 /* Switch to SYS mode */ + cpsid if, #PSR_MODE_SYS /* Switch to SYS mode */ /* Create a context structure. First set aside a stack frame * and store r0-r12 into the frame. @@ -458,18 +539,14 @@ arm_vectorprefetch: sub sp, sp, #XCPTCONTEXT_SIZE stmia sp, {r0-r12} /* Save the SYS mode regs */ - mov r0, #(PSR_MODE_ABT | PSR_I_BIT | PSR_F_BIT) - msr cpsr_c, r0 /* Switch back ABT mode */ + cps #PSR_MODE_ABT /* Switch back ABT mode */ /* Get the values for r15(pc) and CPSR in r3 and r4 */ sub r3, lr, #4 mrs r4, spsr - /* Then switch back to SYS mode */ - - mov r0, #(PSR_MODE_SYS | PSR_I_BIT | PSR_F_BIT) - msr cpsr_c, r0 + cps #PSR_MODE_SYS /* Then switch back to SYS mode */ /* Get the correct values of USR/SYS r13(sp) and r14(lr) in r1 and r2 */ @@ -481,6 +558,13 @@ arm_vectorprefetch: add r0, sp, #(4*REG_SP) /* Offset to pc, cpsr storage */ stmia r0, {r1-r4} +#ifdef CONFIG_ARCH_FPU + /* Save the state of the floating point registers. */ + + add r0, sp, #(4*REG_S0) /* R1=Address of FP register storage */ + savefpu r0, r1 +#endif + /* Then call the prefetch abort handler with interrupts disabled. * void arm_prefetchabort(struct xcptcontext *xcp) */ @@ -494,20 +578,35 @@ arm_vectorprefetch: bl arm_prefetchabort /* Call the handler */ mov sp, r4 /* Restore the possibly unaligned stack pointer */ +#ifdef CONFIG_ARCH_FPU + /* Restore the state of the floating point registers. */ + + add r1, r0, #(4*REG_S0) /* R1=Address of FP register storage */ + restorefpu r1, r2 +#endif + + /* Switch back ABT mode and return with shadow SPSR */ + + cps #PSR_MODE_ABT + /* Upon return from arm_prefetchabort, r0 holds the pointer to the register * state save area to use to restore the registers. This may or may not * be the same value that was passed to arm_prefetchabort: It will differ if a * context switch is required. */ - /* Restore the CPSR, SYS mode registers and return */ + /* Restore the CPSR, ABT mode registers and return */ ldr r1, [r0, #(4*REG_CPSR)] /* Fetch the return SPSR */ msr spsr_cxsf, r1 /* Set the return mode SPSR */ - /* Life is simple when everything is SYS mode */ + /* Life is simple when everything is ABT mode */ - ldmia r0, {r0-r15}^ /* Return */ + mov r14, r0 /* (ABT) r14=Register storage area */ + ldmia r14!, {r0-r12} /* Restore common r0-r12 */ + ldmia r14, {r13, r14}^ /* Restore user mode r13/r14 */ + add r14, r14, #(4*2) /* (ABT) r14=address of r15 storage */ + ldmia r14, {r15}^ /* Return */ .size arm_vectorprefetch, . - arm_vectorprefetch .align 5 @@ -526,12 +625,7 @@ arm_vectorprefetch: .type arm_vectorundefinsn, %function arm_vectorundefinsn: - /* On entry we are free to use the UND mode registers - * r13 and r14 - */ - - mov r13, #(PSR_MODE_SYS | PSR_I_BIT | PSR_F_BIT) - msr cpsr_c, r13 /* Switch to SYS mode */ + cpsid if, #PSR_MODE_SYS /* Switch to SYS mode */ /* Create a context structure. First set aside a stack frame * and store r0-r12 into the frame. @@ -540,18 +634,14 @@ arm_vectorundefinsn: sub sp, sp, #XCPTCONTEXT_SIZE stmia sp, {r0-r12} /* Save the SYS mode regs */ - mov r0, #(PSR_MODE_UND | PSR_I_BIT | PSR_F_BIT) - msr cpsr_c, r0 /* Switch back UND mode */ + cps #PSR_MODE_UND /* Switch back UND mode */ /* Get the values for r15(pc) and CPSR in r3 and r4 */ mov r3, lr mrs r4, spsr - /* Then switch back to SYS mode */ - - mov r0, #(PSR_MODE_SYS | PSR_I_BIT | PSR_F_BIT) - msr cpsr_c, r0 + cps #PSR_MODE_SYS /* Then switch back to SYS mode */ /* Get the correct values of USR/SYS r13(sp) and r14(lr) in r1 and r2 */ @@ -563,6 +653,13 @@ arm_vectorundefinsn: add r0, sp, #(4*REG_SP) /* Offset to pc, cpsr storage */ stmia r0, {r1-r4} +#ifdef CONFIG_ARCH_FPU + /* Save the state of the floating point registers. */ + + add r0, sp, #(4*REG_S0) /* R1=Address of FP register storage */ + savefpu r0, r1 +#endif + /* Then call the undef insn handler with interrupts disabled. * void arm_undefinedinsn(struct xcptcontext *xcp) */ @@ -574,20 +671,35 @@ arm_vectorundefinsn: bl arm_undefinedinsn /* Call the handler */ mov sp, r4 /* Restore the possibly unaligned stack pointer */ +#ifdef CONFIG_ARCH_FPU + /* Restore the state of the floating point registers. */ + + add r1, r0, #(4*REG_S0) /* R1=Address of FP register storage */ + restorefpu r1, r2 +#endif + + /* Switch back UND mode and return with shadow SPSR */ + + cps #PSR_MODE_UND + /* Upon return from arm_undefinedinsn, r0 holds the pointer to the register * state save area to use to restore the registers. This may or may not * be the same value that was passed to arm_undefinedinsn: It will differ if a * context switch is required. */ - /* Restore the CPSR, SYS mode registers and return */ + /* Restore the CPSR, UND mode registers and return */ ldr r1, [r0, #(4*REG_CPSR)] /* Fetch the return SPSR */ msr spsr_cxsf, r1 /* Set the return mode SPSR */ - /* Life is simple when everything is SYS mode */ + /* Life is simple when everything is UND mode */ - ldmia r0, {r0-r15}^ /* Return */ + mov r14, r0 /* (UND) r14=Register storage area */ + ldmia r14!, {r0-r12} /* Restore common r0-r12 */ + ldmia r14, {r13, r14}^ /* Restore user mode r13/r14 */ + add r14, r14, #(4*2) /* (UND) r14=address of r15 storage */ + ldmia r14, {r15}^ /* Return */ .size arm_vectorundefinsn, . - arm_vectorundefinsn .align 5 @@ -609,10 +721,7 @@ arm_vectorundefinsn: arm_vectorfiq: #ifdef CONFIG_ARMV7A_DECODEFIQ - /* On entry we are free to use the FIQ mode registers r8 through r14 */ - - mov r13, #(PSR_MODE_SYS | PSR_I_BIT | PSR_F_BIT) - msr cpsr_c, r13 /* Switch to SYS mode */ + cpsid if, #PSR_MODE_SYS /* Switch to SYS mode */ /* Create a context structure. First set aside a stack frame * and store r0-r12 into the frame. @@ -621,18 +730,14 @@ arm_vectorfiq: sub sp, sp, #XCPTCONTEXT_SIZE stmia sp, {r0-r12} /* Save the SYS mode regs */ - mov r0, #(PSR_MODE_FIQ | PSR_I_BIT | PSR_F_BIT) - msr cpsr_c, r0 /* Switch back FIQ mode */ + cps #PSR_MODE_FIQ /* Switch back FIQ mode */ /* Get the values for r15(pc) and CPSR in r3 and r4 */ sub r3, lr, #4 mrs r4, spsr - /* Then switch back to SYS mode */ - - mov r0, #(PSR_MODE_SYS | PSR_I_BIT | PSR_F_BIT) - msr cpsr_c, r0 + cps #PSR_MODE_SYS /* Then switch back to SYS mode */ /* Get the correct values of USR/SYS r13(sp) and r14(lr) in r1 and r2 */ @@ -644,6 +749,13 @@ arm_vectorfiq: add r0, sp, #(4*REG_SP) /* Offset to pc, cpsr storage */ stmia r0, {r1-r4} +#ifdef CONFIG_ARCH_FPU + /* Save the state of the floating point registers. */ + + add r0, sp, #(4*REG_S0) /* R1=Address of FP register storage */ + savefpu r0, r1 +#endif + /* Then call the FIQ handler with interrupts disabled. */ mov fp, #0 /* Init frame pointer */ @@ -667,20 +779,35 @@ arm_vectorfiq: mov sp, r4 /* Restore the possibly unaligned stack pointer */ #endif +#ifdef CONFIG_ARCH_FPU + /* Restore the state of the floating point registers. */ + + add r1, r0, #(4*REG_S0) /* R1=Address of FP register storage */ + restorefpu r1, r2 +#endif + + /* Switch back FIQ mode and return with shadow SPSR */ + + cps #PSR_MODE_FIQ + /* Upon return from arm_decodefiq, r0 holds the pointer to the register * state save area to use to restore the registers. This may or may not * be the same value that was passed to arm_decodefiq: It will differ if a * context switch is required. */ - /* Restore the CPSR, SYS mode registers and return */ + /* Restore the CPSR, FIQ mode registers and return */ ldr r1, [r0, #(4*REG_CPSR)] /* Fetch the return SPSR */ msr spsr_cxsf, r1 /* Set the return mode SPSR */ - /* Life is simple when everything is SYS mode */ + /* Life is simple when everything is FIQ mode */ - ldmia r0, {r0-r15}^ /* Return */ + mov r14, r0 /* (FIQ) r14=Register storage area */ + ldmia r14!, {r0-r7} /* Restore common r0-r7 */ + ldmia r14, {r8-r14}^ /* Restore user mode r8-r14 */ + add r14, r14, #(4*7) /* (FIQ) r14=address of r15 storage */ + ldmia r14, {r15}^ /* Return */ #if !defined(CONFIG_SMP) && CONFIG_ARCH_INTERRUPTSTACK > 7 .Lfiqstacktop: diff --git a/arch/arm/src/armv7-a/cp15_flush_dcache_all.S b/arch/arm/src/armv7-a/cp15_flush_dcache_all.S index fc7c2600f2acf..ddb5d70637ed7 100644 --- a/arch/arm/src/armv7-a/cp15_flush_dcache_all.S +++ b/arch/arm/src/armv7-a/cp15_flush_dcache_all.S @@ -99,7 +99,7 @@ cp15_flush_dcache_all: and r0, r3, r1, lsr #13 /* r0=NumSets (number of sets - 1) */ ldr r3,=0x7 /* Isolate the LineSize field (bits 0-2) */ - and r5, r3 /* r4=(Log2LineSize - 2) in word */ + and r5, r3, r1 /* r4=(Log2LineSize - 2) in word */ add r5, #4 /* r4=Set/way operation line shfit */ ldr r3, =0x3ff /* Isolate the way field (bits 3-12) */ diff --git a/arch/arm/src/armv7-a/cp15_invalidate_dcache_all.S b/arch/arm/src/armv7-a/cp15_invalidate_dcache_all.S index 9447b60c282f9..9b5f95491ec8d 100644 --- a/arch/arm/src/armv7-a/cp15_invalidate_dcache_all.S +++ b/arch/arm/src/armv7-a/cp15_invalidate_dcache_all.S @@ -99,7 +99,7 @@ cp15_invalidate_dcache_all: and r0, r3, r1, lsr #13 /* r0=NumSets (number of sets - 1) */ ldr r3,=0x7 /* Isolate the LineSize field (bits 0-2) */ - and r5, r3 /* r4=(Log2LineSize - 2) in word */ + and r5, r3, r1 /* r4=(Log2LineSize - 2) in word */ add r5, #4 /* r4=Set/way operation line shfit */ ldr r3, =0x3ff /* Isolate the way field (bits 3-12) */ diff --git a/arch/arm/src/armv7-a/crt0.c b/arch/arm/src/armv7-a/crt0.c index 71a3a71706805..eeaf4508e2790 100644 --- a/arch/arm/src/armv7-a/crt0.c +++ b/arch/arm/src/armv7-a/crt0.c @@ -110,7 +110,7 @@ static void sig_trampoline(void) * ****************************************************************************/ -void _start(int argc, FAR char *argv[]) +void _start(int argc, char *argv[]) { int ret; diff --git a/arch/arm/src/armv7-a/gic.h b/arch/arm/src/armv7-a/gic.h index 7317c9f1ad172..240b23874f5d8 100644 --- a/arch/arm/src/armv7-a/gic.h +++ b/arch/arm/src/armv7-a/gic.h @@ -797,7 +797,7 @@ uint32_t *arm_decodeirq(uint32_t *regs); ****************************************************************************/ #ifdef CONFIG_SMP -int arm_start_handler(int irq, FAR void *context, FAR void *arg); +int arm_start_handler(int irq, void *context, void *arg); #endif /**************************************************************************** @@ -821,7 +821,7 @@ int arm_start_handler(int irq, FAR void *context, FAR void *arg); ****************************************************************************/ #ifdef CONFIG_SMP -int arm_pause_handler(int irq, FAR void *context, FAR void *arg); +int arm_pause_handler(int irq, void *context, void *arg); #endif /**************************************************************************** diff --git a/arch/arm/src/armv7-a/pgalloc.h b/arch/arm/src/armv7-a/pgalloc.h index aade42da8ca0d..3cf6da744fb7d 100644 --- a/arch/arm/src/armv7-a/pgalloc.h +++ b/arch/arm/src/armv7-a/pgalloc.h @@ -58,7 +58,7 @@ ****************************************************************************/ #if !defined(CONFIG_ARCH_PGPOOL_MAPPING) && defined(CONFIG_ARCH_USE_MMU) -static inline uintptr_t arm_tmpmap(uintptr_t paddr, FAR uint32_t *l1save) +static inline uintptr_t arm_tmpmap(uintptr_t paddr, uint32_t *l1save) { *l1save = mmu_l1_getentry(ARCH_SCRATCH_VBASE); mmu_l1_setentry(paddr & ~SECTION_MASK, ARCH_SCRATCH_VBASE, MMU_MEMFLAGS); @@ -138,7 +138,7 @@ static inline bool arm_uservaddr(uintptr_t vaddr) * ****************************************************************************/ -static inline void set_l2_entry(FAR uint32_t *l2table, uintptr_t paddr, +static inline void set_l2_entry(uint32_t *l2table, uintptr_t paddr, uintptr_t vaddr, uint32_t mmuflags) { uint32_t index; @@ -163,7 +163,7 @@ static inline void set_l2_entry(FAR uint32_t *l2table, uintptr_t paddr, * ****************************************************************************/ -static inline void clr_l2_entry(FAR uint32_t *l2table, uintptr_t vaddr) +static inline void clr_l2_entry(uint32_t *l2table, uintptr_t vaddr) { uint32_t index; @@ -188,7 +188,7 @@ static inline void clr_l2_entry(FAR uint32_t *l2table, uintptr_t vaddr) * ****************************************************************************/ -static inline uintptr_t get_l2_entry(FAR uint32_t *l2table, uintptr_t vaddr) +static inline uintptr_t get_l2_entry(uint32_t *l2table, uintptr_t vaddr) { uint32_t index; diff --git a/arch/arm/src/armv7-a/vfork.S b/arch/arm/src/armv7-a/vfork.S deleted file mode 100644 index 9524c07b252c3..0000000000000 --- a/arch/arm/src/armv7-a/vfork.S +++ /dev/null @@ -1,124 +0,0 @@ -/**************************************************************************** - * arch/arm/src/armv7-a/vfork.S - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. The - * ASF licenses this file to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance with the - * License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - ****************************************************************************/ - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include - -#include "arm_vfork.h" - -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -/**************************************************************************** - * Public Symbols - ****************************************************************************/ - - .file "vfork.S" - .globl up_vfork - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: vfork - * - * Description: - * The vfork() function has the same effect as fork(), except that the - * behavior is undefined if the process created by vfork() either modifies - * any data other than a variable of type pid_t used to store the return - * value from vfork(), or returns from the function in which vfork() was - * called, or calls any other function before successfully calling _exit() - * or one of the exec family of functions. - * - * This thin layer implements vfork by simply calling up_vfork() with the - * vfork() context as an argument. The overall sequence is: - * - * 1) User code calls vfork(). vfork() collects context information and - * transfers control up up_vfork(). - * 2) up_vfork() and calls nxtask_setup_vfork(). - * 3) nxtask_setup_vfork() allocates and configures the child task's TCB. - * This consists of: - * - Allocation of the child task's TCB. - * - Initialization of file descriptors and streams - * - Configuration of environment variables - * - Allocate and initialize the stack - * - Setup the input parameters for the task. - * - Initialization of the TCB (including call to up_initial_state()) - * 4) up_vfork() provides any additional operating context. up_vfork must: - * - Initialize special values in any CPU registers that were not - * already configured by up_initial_state() - * 5) up_vfork() then calls nxtask_start_vfork() - * 6) nxtask_start_vfork() then executes the child thread. - * - * Input Parameters: - * None - * - * Returned Value: - * Upon successful completion, vfork() returns 0 to the child process and - * returns the process ID of the child process to the parent process. - * Otherwise, -1 is returned to the parent, no child process is created, - * and errno is set to indicate the error. - * - ****************************************************************************/ - - .globl vfork - .type vfork, function -vfork: - /* Create a stack frame */ - - mov r0, sp /* Save the value of the stack on entry */ - sub sp, sp, #VFORK_SIZEOF /* Allocate the structure on the stack */ - - /* CPU registers */ - /* Save the volatile registers */ - - str r4, [sp, #VFORK_R4_OFFSET] - str r5, [sp, #VFORK_R5_OFFSET] - str r6, [sp, #VFORK_R6_OFFSET] - str r7, [sp, #VFORK_R7_OFFSET] - str r8, [sp, #VFORK_R8_OFFSET] - str r9, [sp, #VFORK_R9_OFFSET] - str r10, [sp, #VFORK_R10_OFFSET] - - /* Save the frame pointer, stack pointer, and return address */ - - str fp, [sp, #VFORK_FP_OFFSET] - str r0, [sp, #VFORK_SP_OFFSET] - str lr, [sp, #VFORK_LR_OFFSET] - - /* Floating point registers (not yet) */ - - /* Then, call up_vfork(), passing it a pointer to the stack structure */ - - mov r0, sp - bl up_vfork - - /* Release the stack data and return the value returned by up_vfork */ - - ldr lr, [sp, #VFORK_LR_OFFSET] - add sp, sp, #VFORK_SIZEOF - bx lr - .size vfork, .-vfork - .end diff --git a/arch/arm/src/armv7-m/Kconfig b/arch/arm/src/armv7-m/Kconfig index 6625e37e1d209..fb401a64fff7a 100644 --- a/arch/arm/src/armv7-m/Kconfig +++ b/arch/arm/src/armv7-m/Kconfig @@ -13,40 +13,6 @@ config ARMV7M_HAVE_DCACHE bool default n -config ARMV7M_LAZYFPU - bool "Lazy FPU storage" - default n - depends on ARCH_HAVE_LAZYFPU - ---help--- - There are two forms of the common vector logic. There are pros and - cons to each option: - - 1) The standard common vector logic exploits features of the ARMv7-M - architecture to save the all of floating registers on entry into - each interrupt and then to restore the floating registers when - the interrupt returns. The primary advantage to this approach is - that floating point operations are available in interrupt - handling logic. Since the volatile registers are preserved, - operations on the floating point registers by interrupt handling - logic has no ill effect. The downside is, of course, that more - stack operations are required on each interrupt to save and store - the floating point registers. Because of the some special - features of the ARMv-M, this is not as much overhead as you might - expect, but overhead nonetheless. - - 2) The lazy FPU common vector logic does not save or restore - floating point registers on entry and exit from the interrupt - handler. Rather, the floating point registers are not restored - until it is absolutely necessary to do so when a context switch - occurs and the interrupt handler will be returning to a different - floating point context. Since floating point registers are not - protected, floating point operations must not be performed in - interrupt handling logic. Better interrupt performance is be - expected, however. - - By default, the "standard" common vector logic is build. This - option selects the alternate lazy FPU common vector logic. - config ARMV7M_USEBASEPRI bool "Use BASEPRI Register" default y if ARCH_HIPRI_INTERRUPT @@ -122,53 +88,30 @@ config ARMV7M_DTCM choice prompt "Toolchain Selection" - default ARMV7M_TOOLCHAIN_GNU_EABIW if TOOLCHAIN_WINDOWS - default ARMV7M_TOOLCHAIN_GNU_EABIL if !TOOLCHAIN_WINDOWS + default ARMV7M_TOOLCHAIN_GNU_EABI -config ARMV7M_TOOLCHAIN_IARW - bool "IAR for Windows" - depends on TOOLCHAIN_WINDOWS +config ARMV7M_TOOLCHAIN_IAR + bool "IAR ANSI C/C++ toolchain" select CYGWIN_WINTOOL if WINDOWS_CYGWIN select ARCH_TOOLCHAIN_IAR -config ARMV7M_TOOLCHAIN_IARL - bool "IAR for Linux" - depends on HOST_LINUX - select ARCH_TOOLCHAIN_IAR - config ARMV7M_TOOLCHAIN_BUILDROOT bool "Buildroot (Cygwin or Linux)" depends on !WINDOWS_NATIVE select ARCH_TOOLCHAIN_GNU -config ARMV7M_TOOLCHAIN_GNU_EABIL - bool "Generic GNU EABI toolchain under Linux (or other POSIX environment)" - depends on !WINDOWS_NATIVE - select ARCH_TOOLCHAIN_GNU - ---help--- - This option should work for any modern GNU toolchain (GCC 4.5 or newer) - configured for arm-none-eabi. - -config ARMV7M_TOOLCHAIN_GNU_EABIW - bool "Generic GNU EABI toolchain under Windows" - depends on TOOLCHAIN_WINDOWS - select CYGWIN_WINTOOL if WINDOWS_CYGWIN - select ARCH_TOOLCHAIN_GNU - -config ARMV7M_TOOLCHAIN_CLANGL - bool "Generic Clang toolchain under Linux (or other POSIX environment)" - depends on !WINDOWS_NATIVE - select ARCH_TOOLCHAIN_GNU - -config ARMV7M_TOOLCHAIN_CLANGW - bool "Generic Clang toolchain under Windows" - depends on TOOLCHAIN_WINDOWS +config ARMV7M_TOOLCHAIN_GNU_EABI + bool "Generic GNU EABI toolchain" select CYGWIN_WINTOOL if WINDOWS_CYGWIN select ARCH_TOOLCHAIN_GNU ---help--- This option should work for any modern GNU toolchain (GCC 4.5 or newer) configured for arm-none-eabi. +config ARMV7M_TOOLCHAIN_CLANG + bool "Generic Clang toolchain" + select ARCH_TOOLCHAIN_CLANG + endchoice config ARMV7M_OABI_TOOLCHAIN diff --git a/arch/arm/src/armv7-m/Make.defs b/arch/arm/src/armv7-m/Make.defs new file mode 100644 index 0000000000000..a5e1b5dc695bd --- /dev/null +++ b/arch/arm/src/armv7-m/Make.defs @@ -0,0 +1,57 @@ +############################################################################ +# arch/arm/src/armv7-m/Make.defs +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. The +# ASF licenses this file to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance with the +# License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +# +############################################################################ + +# Common ARM files + +include common/Make.defs + +CMN_ASRCS += arm_exception.S + +CMN_CSRCS += arm_busfault.c arm_cache.c arm_doirq.c +CMN_CSRCS += arm_hardfault.c arm_initialstate.c arm_itm.c +CMN_CSRCS += arm_memfault.c arm_perf.c +CMN_CSRCS += arm_schedulesigaction.c arm_sigdeliver.c +CMN_CSRCS += arm_svcall.c arm_systemreset.c arm_tcbinfo.c +CMN_CSRCS += arm_trigger_irq.c arm_usagefault.c arm_vectors.c + +ifeq ($(CONFIG_ARMV7M_SYSTICK),y) + CMN_CSRCS += arm_systick.c +endif + +ifeq ($(CONFIG_ARMV7M_ITMSYSLOG),y) + CMN_CSRCS += arm_itm_syslog.c +endif + +ifeq ($(CONFIG_ARMV7M_STACKCHECK),y) + CMN_CSRCS += arm_stackcheck.c +endif + +ifeq ($(CONFIG_ARCH_FPU),y) + CMN_CSRCS += arm_fpuconfig.c + CMN_CSRCS += arm_fpucmp.c +endif + +ifeq ($(CONFIG_ARCH_RAMVECTORS),y) + CMN_CSRCS += arm_ramvec_initialize.c arm_ramvec_attach.c +endif + +ifneq ($(filter y,$(CONFIG_ARM_MPU) $(CONFIG_ARM_MPU_EARLY_RESET)),) + CMN_CSRCS += arm_mpu.c +endif diff --git a/arch/arm/src/armv7-m/Toolchain.defs b/arch/arm/src/armv7-m/Toolchain.defs index c6f9639baab06..680f208de2941 100644 --- a/arch/arm/src/armv7-m/Toolchain.defs +++ b/arch/arm/src/armv7-m/Toolchain.defs @@ -34,25 +34,13 @@ ifeq ($(filter y, \ endif ifeq ($(filter y, \ - $(CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIL) \ + $(CONFIG_ARMV7M_TOOLCHAIN_GNU_EABI) \ ),y) CONFIG_ARMV7M_TOOLCHAIN ?= GNU_EABI endif ifeq ($(filter y, \ - $(CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIW) \ - ),y) - CONFIG_ARMV7M_TOOLCHAIN ?= GNU_EABI -endif - -ifeq ($(filter y, \ - $(CONFIG_ARMV7M_TOOLCHAIN_CLANGL) \ - ),y) - CONFIG_ARMV7M_TOOLCHAIN ?= CLANG -endif - -ifeq ($(filter y, \ - $(CONFIG_ARMV7M_TOOLCHAIN_CLANGW) \ + $(CONFIG_ARMV7M_TOOLCHAIN_CLANG) \ ),y) CONFIG_ARMV7M_TOOLCHAIN ?= CLANG endif @@ -65,20 +53,36 @@ endif # CROSSDEV The GNU toolchain triple (command prefix) # ARCHCPUFLAGS CPU-specific flags selecting the instruction set # FPU options, etc. -# MAXOPTIMIZATION The maximum optimization level that results in +# ARCHOPTIMIZATION The optimization level that results in # reliable code generation. # ifeq ($(CONFIG_DEBUG_CUSTOMOPT),y) - MAXOPTIMIZATION := $(CONFIG_DEBUG_OPTLEVEL) -else - MAXOPTIMIZATION ?= -Os + ARCHOPTIMIZATION += $(CONFIG_DEBUG_OPTLEVEL) +else ifeq ($(CONFIG_DEBUG_FULLOPT),y) + ifeq ($(CONFIG_ARMV6M_TOOLCHAIN),CLANG) + ARCHOPTIMIZATION += -Oz + else + ARCHOPTIMIZATION += -Os + endif +endif + +ifneq ($(CONFIG_DEBUG_NOOPT),y) + ARCHOPTIMIZATION += -fno-strict-aliasing endif ifeq ($(CONFIG_FRAME_POINTER),y) - MAXOPTIMIZATION += -fno-omit-frame-pointer -fno-optimize-sibling-calls + ARCHOPTIMIZATION += -fno-omit-frame-pointer -fno-optimize-sibling-calls else - MAXOPTIMIZATION += -fomit-frame-pointer + ARCHOPTIMIZATION += -fomit-frame-pointer +endif + +ifeq ($(CONFIG_STACK_CANARIES),y) + ARCHOPTIMIZATION += -fstack-protector-all +endif + +ifeq ($(CONFIG_ARMV7M_STACKCHECK),y) + ARCHOPTIMIZATION += -finstrument-functions -ffixed-r10 endif # Parametrization for ARCHCPUFLAGS @@ -118,6 +122,39 @@ else TOOLCHAIN_MFLOAT += -mfloat-abi=soft endif +# Clang Configuration files + +ifeq ($(CONFIG_ARMV7M_TOOLCHAIN),CLANG) + + ifeq ($(CONFIG_ARCH_CORTEXM4),y) + ifeq ($(CONFIG_ARCH_FPU),y) + TOOLCHAIN_MARCH += --config armv7em_hard_fpv4_sp_d16_nosys + else + TOOLCHAIN_MARCH += --config armv7em_soft_nofp_nosys + endif + else ifeq ($(CONFIG_ARCH_CORTEXM7),y) + ifeq ($(CONFIG_ARCH_FPU),y) + TOOLCHAIN_MARCH += --config armv7em_hard_fpv5_d16_nosys + else + TOOLCHAIN_MARCH += --config armv7em_soft_nofp_nosys + endif + else # ifeq ($(CONFIG_ARCH_CORTEXM3),y) + TOOLCHAIN_MARCH += --config armv7m_soft_nofp_nosys + endif + +endif + +# Link Time Optimization + +ifeq ($(CONFIG_LTO_THIN),y) + ARCHOPTIMIZATION += -flto=thin +else ifeq ($(CONFIG_LTO_FULL),y) + ARCHOPTIMIZATION += -flto + ifeq ($(CONFIG_ARMV7M_TOOLCHAIN),GNU_EABI) + ARCHOPTIMIZATION += -fuse-linker-plugin + endif +endif + # NuttX buildroot under Linux or Cygwin ifeq ($(CONFIG_ARMV7M_TOOLCHAIN),BUILDROOT) @@ -144,32 +181,94 @@ endif # Clang toolchain ifeq ($(CONFIG_ARMV7M_TOOLCHAIN),CLANG) - CROSSDEV ?= arm-none-eabi- - ARCHCPUFLAGS = -target arm-none-eabi $(TOOLCHAIN_MARCH) $(TOOLCHAIN_MTUNE) $(TOOLCHAIN_MFLOAT) - CC = clang - CXX = clang++ - CPP = clang -E -P -x c + ARCHCPUFLAGS = $(TOOLCHAIN_MARCH) $(TOOLCHAIN_MTUNE) $(TOOLCHAIN_MFLOAT) + + CC = clang + CXX = clang++ + CPP = clang -E -P -x c + LD = ld.lld -m armelf + STRIP = llvm-strip --strip-unneeded + AR = llvm-ar rcs + NM = llvm-nm + OBJCOPY = llvm-objcopy + OBJDUMP = llvm-objdump + + # Since the no_builtin attribute is not fully supported on Clang + # disable the built-in functions, refer: + # https://github.com/apache/incubator-nuttx/pull/5971 + + ARCHOPTIMIZATION += -fno-builtin + +# Default toolchain + else - CC = $(CROSSDEV)gcc - CXX = $(CROSSDEV)g++ - CPP = $(CROSSDEV)gcc -E -P -x c + CC = $(CROSSDEV)gcc + CXX = $(CROSSDEV)g++ + CPP = $(CROSSDEV)gcc -E -P -x c + STRIP = $(CROSSDEV)strip --strip-unneeded + OBJCOPY = $(CROSSDEV)objcopy + OBJDUMP = $(CROSSDEV)objdump + LD = $(CROSSDEV)ld + AR = $(CROSSDEV)ar rcs + NM = $(CROSSDEV)nm + + ifeq ($(CONFIG_LTO_FULL),y) + ifeq ($(CONFIG_ARMV7M_TOOLCHAIN),GNU_EABI) + LD := $(CROSSDEV)gcc + AR := $(CROSSDEV)gcc-ar rcs + NM := $(CROSSDEV)gcc-nm + ARCHOPTIMIZATION += -fno-builtin + ARCHOPTIMIZATION += -nodefaultlibs + endif + endif endif -LD = $(CROSSDEV)ld -STRIP = $(CROSSDEV)strip --strip-unneeded -AR = $(CROSSDEV)ar rcs -NM = $(CROSSDEV)nm -OBJCOPY = $(CROSSDEV)objcopy -OBJDUMP = $(CROSSDEV)objdump +# Architecture flags + +ARCHCFLAGS += -fno-common +ARCHCXXFLAGS += -fno-common -nostdinc++ + +ifneq ($(CONFIG_CXX_EXCEPTION),y) + ARCHCXXFLAGS += -fno-exceptions -fcheck-new +endif + +ifneq ($(CONFIG_CXX_RTTI),y) + ARCHCXXFLAGS += -fno-rtti +endif + +# Optimization of unused sections + +ifeq ($(CONFIG_DEBUG_OPT_UNUSED_SECTIONS),y) + LDFLAGS += --gc-sections + ARCHOPTIMIZATION += -ffunction-sections -fdata-sections +endif + +# Debug link map + +ifeq ($(CONFIG_DEBUG_LINK_MAP),y) + LDFLAGS += --cref -Map=$(call CONVERT_PATH,$(TOPDIR)$(DELIM)nuttx.map) +endif + +ifeq ($(CONFIG_DEBUG_SYMBOLS),y) + LDFLAGS += -g + ARCHOPTIMIZATION += -g +endif # Add the builtin library -EXTRA_LIBS += ${wildcard ${shell $(CC) $(ARCHCPUFLAGS) --print-libgcc-file-name}} +COMPILER_RT_LIB = $(shell $(CC) $(ARCHCPUFLAGS) --print-libgcc-file-name) +ifeq ($(wildcard $(COMPILER_RT_LIB)),) + # if "--print-libgcc-file-name" unable to find the correct libgcc PATH + # then go ahead and try "--print-file-name" + COMPILER_RT_LIB := $(wildcard $(shell $(CC) $(ARCHCPUFLAGS) --print-file-name $(notdir $(COMPILER_RT_LIB)))) +endif + +EXTRA_LIBS += $(COMPILER_RT_LIB) ifneq ($(CONFIG_LIBM),y) - EXTRA_LIBS += ${wildcard ${shell $(CC) $(ARCHCPUFLAGS) --print-file-name=libm.a}} + EXTRA_LIBS += $(wildcard $(shell $(CC) $(ARCHCPUFLAGS) --print-file-name=libm.a)) endif ifeq ($(CONFIG_LIBSUPCXX),y) - EXTRA_LIBS += ${wildcard ${shell $(CC) $(ARCHCPUFLAGS) --print-file-name=libsupc++.a}} + EXTRA_LIBS += $(wildcard $(shell $(CC) $(ARCHCPUFLAGS) --print-file-name=libsupc++.a)) endif diff --git a/arch/arm/src/armv7-m/arm_busfault.c b/arch/arm/src/armv7-m/arm_busfault.c index 3be6ea117539a..81ab7a6152280 100644 --- a/arch/arm/src/armv7-m/arm_busfault.c +++ b/arch/arm/src/armv7-m/arm_busfault.c @@ -57,7 +57,7 @@ * ****************************************************************************/ -int arm_busfault(int irq, FAR void *context, FAR void *arg) +int arm_busfault(int irq, void *context, void *arg) { uint32_t cfsr = getreg32(NVIC_CFAULTS); diff --git a/arch/arm/src/armv7-m/gnu/arm_exception.S b/arch/arm/src/armv7-m/arm_exception.S similarity index 96% rename from arch/arm/src/armv7-m/gnu/arm_exception.S rename to arch/arm/src/armv7-m/arm_exception.S index be6cc94d9daa9..cc4b59ad8a84e 100644 --- a/arch/arm/src/armv7-m/gnu/arm_exception.S +++ b/arch/arm/src/armv7-m/arm_exception.S @@ -1,5 +1,5 @@ /**************************************************************************** - * arch/arm/src/armv7-m/gnu/arm_exception.S + * arch/arm/src/armv7-m/arm_exception.S * * Copyright (C) 2009-2013, 2015-2016, 2018 Gregory Nutt. * All rights reserved. @@ -174,8 +174,12 @@ exception_common: * where to put the registers. */ - vstmdb sp!, {s16-s31} /* Save the non-volatile FP context */ + /* Switched-out task including volatile FP registers ? */ + tst r14, #EXC_RETURN_STD_CONTEXT + ite eq + vstmdbeq sp!, {s16-s31} /* Save the non-volatile FP context */ + subne sp, #(4*SW_FPU_REGS) #endif stmdb sp!, {r2-r11,r14} /* Save the remaining registers plus the SP/PRIMASK values */ @@ -225,7 +229,12 @@ exception_common: ldmia r0!, {r2-r11,r14} /* Recover R4-R11, r14 + 2 temp values */ #ifdef CONFIG_ARCH_FPU - vldmia r0!, {s16-s31} /* Recover S16-S31 */ + /* Switched-in task including volatile FP registers ? */ + + tst r14, #EXC_RETURN_STD_CONTEXT + ite eq + vldmiaeq r0!, {s16-s31} /* Recover S16-S31 */ + addne r0, #(4*SW_FPU_REGS) #endif /* The EXC_RETURN value tells us whether we are returning on the MSP or PSP diff --git a/arch/arm/src/armv7-m/arm_fpucmp.c b/arch/arm/src/armv7-m/arm_fpucmp.c new file mode 100644 index 0000000000000..5ddc18e89baf5 --- /dev/null +++ b/arch/arm/src/armv7-m/arm_fpucmp.c @@ -0,0 +1,62 @@ +/**************************************************************************** + * arch/arm/src/armv7-m/arm_fpucmp.c + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include +#include +#include + +#include "arm_internal.h" + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +#ifdef CONFIG_ARCH_FPU + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: up_fpucmp + * + * Description: + * compare FPU areas from thread context + * + ****************************************************************************/ + +bool up_fpucmp(const void *saveregs1, const void *saveregs2) +{ + const uint32_t *regs1 = saveregs1; + const uint32_t *regs2 = saveregs2; + + /* compare of hardware fp registers should skip REG_FP_RESERVED */ + + return memcmp(®s1[REG_S0], ®s2[REG_S0], + 4 * (HW_FPU_REGS - 1)) == 0 && + memcmp(®s1[REG_S16], ®s2[REG_S16], 4 * SW_FPU_REGS) == 0; +} +#endif /* CONFIG_ARCH_FPU */ diff --git a/arch/arm/src/armv7-m/arm_fpuconfig.c b/arch/arm/src/armv7-m/arm_fpuconfig.c new file mode 100644 index 0000000000000..0bcdeb45c04c6 --- /dev/null +++ b/arch/arm/src/armv7-m/arm_fpuconfig.c @@ -0,0 +1,83 @@ +/**************************************************************************** + * arch/arm/src/armv7-m/arm_fpuconfig.c + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include "nvic.h" +#include "arm_internal.h" + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: arm_fpuconfig + * + * Description: + * Configure the FPU. Relative bit settings: + * + * CPACR: Enables access to CP10 and CP11 + * CONTROL.FPCA: Determines whether the FP extension is active in the + * current context: + * FPCCR.ASPEN: Enables automatic FP state preservation, then the + * processor sets this bit to 1 on successful completion of any FP + * instruction. + * FPCCR.LSPEN: Enables lazy context save of FP state. When this is + * done, the processor reserves space on the stack for the FP state, + * but does not save that state information to the stack. + * + * Software must not change the value of the ASPEN bit or LSPEN bit while + * either: + * + * - the CPACR permits access to CP10 and CP11, that give access to the FP + * extension, or + * - the CONTROL.FPCA bit is set to 1 + * + ****************************************************************************/ + +void arm_fpuconfig(void) +{ + uint32_t regval; + + /* Set CONTROL.FPCA so that we always get the extended context frame + * with the volatile FP registers stacked above the basic context. + */ + + regval = getcontrol(); + regval |= CONTROL_FPCA; + setcontrol(regval); + + /* Ensure that FPCCR.LSPEN is disabled, so that we don't have to contend + * with the lazy FP context save behavior. Clear FPCCR.ASPEN since we + * are going to turn on CONTROL.FPCA for all contexts. + */ + + regval = getreg32(NVIC_FPCCR); + regval &= ~(NVIC_FPCCR_ASPEN | NVIC_FPCCR_LSPEN); + putreg32(regval, NVIC_FPCCR); + + /* Enable full access to CP10 and CP11 */ + + regval = getreg32(NVIC_CPACR); + regval |= NVIC_CPACR_CP_FULL(10) | NVIC_CPACR_CP_FULL(11); + putreg32(regval, NVIC_CPACR); +} diff --git a/arch/arm/src/armv7-m/arm_hardfault.c b/arch/arm/src/armv7-m/arm_hardfault.c index bcd0ab08ac04f..f0dfdf514ac30 100644 --- a/arch/arm/src/armv7-m/arm_hardfault.c +++ b/arch/arm/src/armv7-m/arm_hardfault.c @@ -71,7 +71,7 @@ * ****************************************************************************/ -int arm_hardfault(int irq, FAR void *context, FAR void *arg) +int arm_hardfault(int irq, void *context, void *arg) { uint32_t hfsr = getreg32(NVIC_HFAULTS); uint32_t cfsr = getreg32(NVIC_CFAULTS); diff --git a/arch/arm/src/armv7-m/arm_initialstate.c b/arch/arm/src/armv7-m/arm_initialstate.c index e57cdb93bff7d..a8f587b5feb8c 100644 --- a/arch/arm/src/armv7-m/arm_initialstate.c +++ b/arch/arm/src/armv7-m/arm_initialstate.c @@ -84,9 +84,9 @@ void up_initial_state(struct tcb_s *tcb) /* Initialize the context registers to stack top */ - xcp->regs = (FAR void *)((uint32_t)tcb->stack_base_ptr + - tcb->adj_stack_size - - XCPTCONTEXT_SIZE); + xcp->regs = (void *)((uint32_t)tcb->stack_base_ptr + + tcb->adj_stack_size - + XCPTCONTEXT_SIZE); /* Initialize the xcp registers */ @@ -136,7 +136,6 @@ void up_initial_state(struct tcb_s *tcb) #endif #endif /* CONFIG_PIC */ -#if !defined(CONFIG_ARMV7M_LAZYFPU) || defined(CONFIG_BUILD_PROTECTED) /* All tasks start via a stub function in kernel space. So all * tasks must start in privileged thread mode. If CONFIG_BUILD_PROTECTED * is defined, then that stub function will switch to unprivileged @@ -145,14 +144,9 @@ void up_initial_state(struct tcb_s *tcb) xcp->regs[REG_EXC_RETURN] = EXC_RETURN_PRIVTHR; -#endif /* !CONFIG_ARMV7M_LAZYFPU || CONFIG_BUILD_PROTECTED */ - -#if !defined(CONFIG_ARMV7M_LAZYFPU) && defined(CONFIG_ARCH_FPU) - +#ifdef CONFIG_ARCH_FPU xcp->regs[REG_FPSCR] = 0; /* REVISIT: Initial FPSCR should be configurable */ - xcp->regs[REG_FP_RESERVED] = 0; - -#endif /* !CONFIG_ARMV7M_LAZYFPU && CONFIG_ARCH_FPU */ +#endif /* CONFIG_ARCH_FPU */ /* Enable or disable interrupts, based on user configuration */ diff --git a/arch/arm/src/armv7-m/arm_itm_syslog.c b/arch/arm/src/armv7-m/arm_itm_syslog.c index 2d3513129df76..366d8aad4a4ae 100644 --- a/arch/arm/src/armv7-m/arm_itm_syslog.c +++ b/arch/arm/src/armv7-m/arm_itm_syslog.c @@ -62,8 +62,8 @@ /* SYSLOG channel methods */ -static int itm_putc(FAR struct syslog_channel_s *channel, int ch); -static int itm_flush(FAR struct syslog_channel_s *channel); +static int itm_putc(struct syslog_channel_s *channel, int ch); +static int itm_flush(struct syslog_channel_s *channel); /**************************************************************************** * Private Data @@ -97,7 +97,7 @@ static const struct syslog_channel_s g_itm_channel = * ****************************************************************************/ -static int itm_putc(FAR struct syslog_channel_s *channel, int ch) +static int itm_putc(struct syslog_channel_s *channel, int ch) { UNUSED(channel); @@ -127,7 +127,7 @@ static int itm_putc(FAR struct syslog_channel_s *channel, int ch) * ****************************************************************************/ -static int itm_flush(FAR struct syslog_channel_s *channel) +static int itm_flush(struct syslog_channel_s *channel) { UNUSED(channel); return OK; diff --git a/arch/arm/src/armv7-m/arm_memfault.c b/arch/arm/src/armv7-m/arm_memfault.c index e1fec9341a9a8..1f367898083fd 100644 --- a/arch/arm/src/armv7-m/arm_memfault.c +++ b/arch/arm/src/armv7-m/arm_memfault.c @@ -58,7 +58,7 @@ * ****************************************************************************/ -int arm_memfault(int irq, FAR void *context, FAR void *arg) +int arm_memfault(int irq, void *context, void *arg) { uint32_t cfsr = getreg32(NVIC_CFAULTS); diff --git a/arch/arm/src/armv7-m/arm_perf.c b/arch/arm/src/armv7-m/arm_perf.c index fdf78196f2c9e..70553c0999f0a 100644 --- a/arch/arm/src/armv7-m/arm_perf.c +++ b/arch/arm/src/armv7-m/arm_perf.c @@ -40,7 +40,7 @@ static uint32_t g_cpu_freq; * Public Functions ****************************************************************************/ -void up_perf_init(FAR void *arg) +void up_perf_init(void *arg) { g_cpu_freq = (uint32_t)(uintptr_t)arg; @@ -66,7 +66,7 @@ uint32_t up_perf_gettime(void) return getreg32(DWT_CYCCNT); } -void up_perf_convert(uint32_t elapsed, FAR struct timespec *ts) +void up_perf_convert(uint32_t elapsed, struct timespec *ts) { uint32_t left; diff --git a/arch/arm/src/armv7-m/arm_ramvec_initialize.c b/arch/arm/src/armv7-m/arm_ramvec_initialize.c index 54f33746d05d2..7bc69714e07d8 100644 --- a/arch/arm/src/armv7-m/arm_ramvec_initialize.c +++ b/arch/arm/src/armv7-m/arm_ramvec_initialize.c @@ -129,7 +129,7 @@ void arm_ramvec_initialize(void) * protect against NULL pointer references. */ - src = (const CODE up_vector_t *)getreg32(NVIC_VECTAB); + src = (const up_vector_t *)getreg32(NVIC_VECTAB); dest = g_ram_vectors; irqinfo("src=%p dest=%p\n", src, dest); diff --git a/arch/arm/src/armv7-m/arm_schedulesigaction.c b/arch/arm/src/armv7-m/arm_schedulesigaction.c index b8c224fbc4a32..f45d5c9304b43 100644 --- a/arch/arm/src/armv7-m/arm_schedulesigaction.c +++ b/arch/arm/src/armv7-m/arm_schedulesigaction.c @@ -124,7 +124,7 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver) * delivered. */ - tcb->xcp.sigdeliver = (FAR void *)sigdeliver; + tcb->xcp.sigdeliver = (void *)sigdeliver; /* And make sure that the saved context in the TCB is the same * as the interrupt return context. @@ -137,10 +137,10 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver) * delivered. */ - CURRENT_REGS = (FAR void *) + CURRENT_REGS = (void *) ((uint32_t)CURRENT_REGS - (uint32_t)XCPTCONTEXT_SIZE); - memcpy((FAR uint32_t *)CURRENT_REGS, tcb->xcp.saved_regs, + memcpy((uint32_t *)CURRENT_REGS, tcb->xcp.saved_regs, XCPTCONTEXT_SIZE); CURRENT_REGS[REG_SP] = (uint32_t)CURRENT_REGS + @@ -177,7 +177,7 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver) * by the signal trampoline after the signal has been delivered. */ - tcb->xcp.sigdeliver = (FAR void *)sigdeliver; + tcb->xcp.sigdeliver = (void *)sigdeliver; /* Save the current register context location */ @@ -188,7 +188,7 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver) * delivered. */ - tcb->xcp.regs = (FAR void *) + tcb->xcp.regs = (void *) ((uint32_t)tcb->xcp.regs - (uint32_t)XCPTCONTEXT_SIZE); memcpy(tcb->xcp.regs, tcb->xcp.saved_regs, XCPTCONTEXT_SIZE); @@ -285,7 +285,7 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver) * been delivered. */ - tcb->xcp.sigdeliver = (FAR void *)sigdeliver; + tcb->xcp.sigdeliver = (void *)sigdeliver; /* Save the current register context location */ @@ -296,7 +296,7 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver) * been delivered. */ - tcb->xcp.regs = (FAR void *) + tcb->xcp.regs = (void *) ((uint32_t)tcb->xcp.regs - (uint32_t)XCPTCONTEXT_SIZE); memcpy(tcb->xcp.regs, tcb->xcp.saved_regs, @@ -331,7 +331,7 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver) * signal has been delivered. */ - tcb->xcp.sigdeliver = (FAR void *)sigdeliver; + tcb->xcp.sigdeliver = (void *)sigdeliver; /* And make sure that the saved context in the TCB is the * same as the interrupt return context. @@ -344,10 +344,10 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver) * been delivered. */ - CURRENT_REGS = (FAR void *) + CURRENT_REGS = (void *) ((uint32_t)CURRENT_REGS - (uint32_t)XCPTCONTEXT_SIZE); - memcpy((FAR uint32_t *)CURRENT_REGS, tcb->xcp.saved_regs, + memcpy((uint32_t *)CURRENT_REGS, tcb->xcp.saved_regs, XCPTCONTEXT_SIZE); CURRENT_REGS[REG_SP] = (uint32_t)CURRENT_REGS + @@ -405,7 +405,7 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver) * by the signal trampoline after the signal has been delivered. */ - tcb->xcp.sigdeliver = (FAR void *)sigdeliver; + tcb->xcp.sigdeliver = (void *)sigdeliver; /* Save the current register context location */ @@ -416,7 +416,7 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver) * delivered. */ - tcb->xcp.regs = (FAR void *) + tcb->xcp.regs = (void *) ((uint32_t)tcb->xcp.regs - (uint32_t)XCPTCONTEXT_SIZE); memcpy(tcb->xcp.regs, tcb->xcp.saved_regs, XCPTCONTEXT_SIZE); diff --git a/arch/arm/src/armv7-m/arm_svcall.c b/arch/arm/src/armv7-m/arm_svcall.c index 71f526f010a88..2f2241b102df3 100644 --- a/arch/arm/src/armv7-m/arm_svcall.c +++ b/arch/arm/src/armv7-m/arm_svcall.c @@ -122,7 +122,7 @@ static void dispatch_syscall(void) * ****************************************************************************/ -int arm_svcall(int irq, FAR void *context, FAR void *arg) +int arm_svcall(int irq, void *context, void *arg) { uint32_t *regs = (uint32_t *)context; uint32_t cmd; @@ -161,7 +161,7 @@ int arm_svcall(int irq, FAR void *context, FAR void *arg) { /* R0=SYS_save_context: This is a save context command: * - * int arm_saveusercontext(uint32_t *saveregs); + * int up_saveusercontext(void *saveregs); * * At this point, the following values are saved in context: * @@ -175,9 +175,6 @@ int arm_svcall(int irq, FAR void *context, FAR void *arg) case SYS_save_context: { DEBUGASSERT(regs[REG_R1] != 0); -#if defined(CONFIG_ARCH_FPU) && defined(CONFIG_ARMV7M_LAZYFPU) - arm_savefpu(regs); -#endif memcpy((uint32_t *)regs[REG_R1], regs, XCPTCONTEXT_SIZE); } break; @@ -226,9 +223,6 @@ int arm_svcall(int irq, FAR void *context, FAR void *arg) case SYS_switch_context: { DEBUGASSERT(regs[REG_R1] != 0 && regs[REG_R2] != 0); -#if defined(CONFIG_ARCH_FPU) && defined(CONFIG_ARMV7M_LAZYFPU) - arm_savefpu(regs); -#endif *(uint32_t **)regs[REG_R1] = regs; CURRENT_REGS = (uint32_t *)regs[REG_R2]; } @@ -275,14 +269,14 @@ int arm_svcall(int irq, FAR void *context, FAR void *arg) */ rtcb->flags &= ~TCB_FLAG_SYSCALL; - (void)nxsig_unmask_pendingsignal(); + nxsig_unmask_pendingsignal(); } break; #endif /* R0=SYS_task_start: This a user task start * - * void up_task_start(main_t taskentry, int argc, FAR char *argv[]) + * void up_task_start(main_t taskentry, int argc, char *argv[]) * noreturn_function; * * At this point, the following values are saved in context: @@ -349,7 +343,7 @@ int arm_svcall(int irq, FAR void *context, FAR void *arg) /* R0=SYS_signal_handler: This a user signal handler callback * * void signal_handler(_sa_sigaction_t sighand, int signo, - * FAR siginfo_t *info, FAR void *ucontext); + * siginfo_t *info, void *ucontext); * * At this point, the following values are saved in context: * @@ -422,7 +416,7 @@ int arm_svcall(int irq, FAR void *context, FAR void *arg) default: { #ifdef CONFIG_LIB_SYSCALL - FAR struct tcb_s *rtcb = nxsched_self(); + struct tcb_s *rtcb = nxsched_self(); int index = rtcb->xcp.nsyscalls; /* Verify that the SYS call number is within range */ diff --git a/arch/arm/src/armv7-m/arm_systick.c b/arch/arm/src/armv7-m/arm_systick.c index 7af6842e2caac..25b2a08834a78 100644 --- a/arch/arm/src/armv7-m/arm_systick.c +++ b/arch/arm/src/armv7-m/arm_systick.c @@ -57,15 +57,15 @@ struct systick_lowerhalf_s * Private Function Prototypes ****************************************************************************/ -static int systick_start(FAR struct timer_lowerhalf_s *lower_); -static int systick_stop(FAR struct timer_lowerhalf_s *lower_); -static int systick_getstatus(FAR struct timer_lowerhalf_s *lower_, - FAR struct timer_status_s *status); -static int systick_settimeout(FAR struct timer_lowerhalf_s *lower_, +static int systick_start(struct timer_lowerhalf_s *lower_); +static int systick_stop(struct timer_lowerhalf_s *lower_); +static int systick_getstatus(struct timer_lowerhalf_s *lower_, + struct timer_status_s *status); +static int systick_settimeout(struct timer_lowerhalf_s *lower_, uint32_t timeout); -static void systick_setcallback(FAR struct timer_lowerhalf_s *lower_, - tccb_t callback, FAR void *arg); -static int systick_maxtimeout(FAR struct timer_lowerhalf_s *lower_, +static void systick_setcallback(struct timer_lowerhalf_s *lower_, + tccb_t callback, void *arg); +static int systick_maxtimeout(struct timer_lowerhalf_s *lower_, uint32_t *maxtimeout); /**************************************************************************** @@ -118,21 +118,21 @@ static bool systick_irq_pending(struct systick_lowerhalf_s *lower) } } -static int systick_start(FAR struct timer_lowerhalf_s *lower_) +static int systick_start(struct timer_lowerhalf_s *lower_) { putreg32(0, NVIC_SYSTICK_CURRENT); modifyreg32(NVIC_SYSTICK_CTRL, 0, NVIC_SYSTICK_CTRL_ENABLE); return 0; } -static int systick_stop(FAR struct timer_lowerhalf_s *lower_) +static int systick_stop(struct timer_lowerhalf_s *lower_) { modifyreg32(NVIC_SYSTICK_CTRL, NVIC_SYSTICK_CTRL_ENABLE, 0); return 0; } -static int systick_getstatus(FAR struct timer_lowerhalf_s *lower_, - FAR struct timer_status_s *status) +static int systick_getstatus(struct timer_lowerhalf_s *lower_, + struct timer_status_s *status) { struct systick_lowerhalf_s *lower = (struct systick_lowerhalf_s *)lower_; irqstate_t flags = enter_critical_section(); @@ -165,7 +165,7 @@ static int systick_getstatus(FAR struct timer_lowerhalf_s *lower_, return 0; } -static int systick_settimeout(FAR struct timer_lowerhalf_s *lower_, +static int systick_settimeout(struct timer_lowerhalf_s *lower_, uint32_t timeout) { struct systick_lowerhalf_s *lower = (struct systick_lowerhalf_s *)lower_; @@ -198,8 +198,8 @@ static int systick_settimeout(FAR struct timer_lowerhalf_s *lower_, return 0; } -static void systick_setcallback(FAR struct timer_lowerhalf_s *lower_, - CODE tccb_t callback, FAR void *arg) +static void systick_setcallback(struct timer_lowerhalf_s *lower_, + tccb_t callback, void *arg) { struct systick_lowerhalf_s *lower = (struct systick_lowerhalf_s *)lower_; @@ -209,7 +209,7 @@ static void systick_setcallback(FAR struct timer_lowerhalf_s *lower_, leave_critical_section(flags); } -static int systick_maxtimeout(FAR struct timer_lowerhalf_s *lower_, +static int systick_maxtimeout(struct timer_lowerhalf_s *lower_, uint32_t *maxtimeout) { uint64_t maxtimeout64 = usec_from_count( @@ -227,7 +227,7 @@ static int systick_maxtimeout(FAR struct timer_lowerhalf_s *lower_, return 0; } -static int systick_interrupt(int irq, FAR void *context, FAR void *arg) +static int systick_interrupt(int irq, void *context, void *arg) { struct systick_lowerhalf_s *lower = arg; diff --git a/arch/arm/src/armv7-m/arm_tcbinfo.c b/arch/arm/src/armv7-m/arm_tcbinfo.c index d212591ace8b8..97a967f6e3c8d 100644 --- a/arch/arm/src/armv7-m/arm_tcbinfo.c +++ b/arch/arm/src/armv7-m/arm_tcbinfo.c @@ -53,17 +53,17 @@ static const uint16_t g_reg_offs[] = TCB_REG_OFF(REG_R15), TCB_REG_OFF(REG_XPSR), - 0, /* msp */ + UINT16_MAX, /* msp */ TCB_REG_OFF(REG_R13), #ifdef CONFIG_ARMV7M_USEBASEPRI - 0, /* primask */ + UINT16_MAX, /* primask */ TCB_REG_OFF(REG_BASEPRI), #else TCB_REG_OFF(REG_PRIMASK), - 0, /* basepri */ + UINT16_MAX, /* basepri */ #endif - 0, /* faultmask */ - 0, /* control */ + UINT16_MAX, /* faultmask */ + UINT16_MAX, /* control */ #ifdef CONFIG_ARCH_FPU TCB_REG_OFF(REG_S0), @@ -108,11 +108,13 @@ static const uint16_t g_reg_offs[] = const struct tcbinfo_s g_tcbinfo = { - TCB_PID_OFF, - TCB_STATE_OFF, - TCB_PRI_OFF, - TCB_NAME_OFF, - XCPTCONTEXT_REGS, + .pid_off = TCB_PID_OFF, + .state_off = TCB_STATE_OFF, + .pri_off = TCB_PRI_OFF, + .name_off = TCB_NAME_OFF, + .regs_off = TCB_REGS_OFF, + .basic_num = 17, + .total_num = XCPTCONTEXT_REGS, { .p = g_reg_offs, }, diff --git a/arch/arm/src/armv7-m/arm_usagefault.c b/arch/arm/src/armv7-m/arm_usagefault.c index 310ecc2196b9d..7fb0a55221c31 100644 --- a/arch/arm/src/armv7-m/arm_usagefault.c +++ b/arch/arm/src/armv7-m/arm_usagefault.c @@ -57,7 +57,7 @@ * ****************************************************************************/ -int arm_usagefault(int irq, FAR void *context, FAR void *arg) +int arm_usagefault(int irq, void *context, void *arg) { uint32_t cfsr = getreg32(NVIC_CFAULTS); diff --git a/arch/arm/src/armv7-m/exc_return.h b/arch/arm/src/armv7-m/exc_return.h index 14147bef9f8a1..ddac01de579d6 100644 --- a/arch/arm/src/armv7-m/exc_return.h +++ b/arch/arm/src/armv7-m/exc_return.h @@ -81,7 +81,7 @@ * gets state from the main stack. Execution uses MSP after return. */ -#if !defined(CONFIG_ARMV7M_LAZYFPU) && defined(CONFIG_ARCH_FPU) +#ifdef CONFIG_ARCH_FPU # define EXC_RETURN_PRIVTHR (EXC_RETURN_BASE | EXC_RETURN_THREAD_MODE) #else # define EXC_RETURN_PRIVTHR (EXC_RETURN_BASE | EXC_RETURN_STD_CONTEXT | \ @@ -92,7 +92,7 @@ * gets state from the process stack. Execution uses PSP after return. */ -#if !defined(CONFIG_ARMV7M_LAZYFPU) && defined(CONFIG_ARCH_FPU) +#ifdef CONFIG_ARCH_FPU # define EXC_RETURN_UNPRIVTHR (EXC_RETURN_BASE | EXC_RETURN_THREAD_MODE | \ EXC_RETURN_PROCESS_STACK) #else diff --git a/arch/arm/src/armv7-m/gnu/arm_fetchadd.S b/arch/arm/src/armv7-m/gnu/arm_fetchadd.S deleted file mode 100644 index ed7591d4bcb54..0000000000000 --- a/arch/arm/src/armv7-m/gnu/arm_fetchadd.S +++ /dev/null @@ -1,242 +0,0 @@ -/**************************************************************************** - * arch/arm/src/armv7-m/gnu/arm_fetchadd.S - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. The - * ASF licenses this file to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance with the - * License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - ****************************************************************************/ - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include - - .syntax unified - .thumb - .file "arm_fetchadd.S" - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - - .text - -/**************************************************************************** - * Name: up_fetchadd32 - * - * Description: - * Perform an atomic fetch add operation on the provided 32-bit value. - * - * This function must be provided via the architecture-specific logic. - * - * Input Parameters: - * addr - The address of 32-bit value to be incremented. - * value - The 32-bit addend - * - * Returned Value: - * The incremented value (volatile!) - * - ****************************************************************************/ - - .globl up_fetchadd32 - .type up_fetchadd32, %function - -up_fetchadd32: - -1: - ldrex r2, [r0] /* Fetch the value to be incremented */ - add r2, r2, r1 /* Add the addend */ - - strex r3, r2, [r0] /* Attempt to save the result */ - teq r3, #0 /* r3 will be 1 if strex failed */ - bne 1b /* Failed to lock... try again */ - - mov r0, r2 /* Return the incremented value */ - bx lr /* Successful! */ - .size up_fetchadd32, . - up_fetchadd32 - -/**************************************************************************** - * Name: up_fetchsub32 - * - * Description: - * Perform an atomic fetch subtract operation on the provided 32-bit value. - * - * This function must be provided via the architecture-specific logic. - * - * Input Parameters: - * addr - The address of 32-bit value to be decremented. - * value - The 32-bit subtrahend - * - * Returned Value: - * The decremented value (volatile!) - * - ****************************************************************************/ - - .globl up_fetchsub32 - .type up_fetchsub32, %function - -up_fetchsub32: - -1: - ldrex r2, [r0] /* Fetch the value to be decremented */ - sub r2, r2, r1 /* Subtract the subtrahend */ - - strex r3, r2, [r0] /* Attempt to save the result */ - teq r3, #0 /* r3 will be 1 if strex failed */ - bne 1b /* Failed to lock... try again */ - - mov r0, r2 /* Return the decremented value */ - bx lr /* Successful! */ - .size up_fetchsub32, . - up_fetchsub32 - -/**************************************************************************** - * Name: up_fetchadd16 - * - * Description: - * Perform an atomic fetch add operation on the provided 16-bit value. - * - * This function must be provided via the architecture-specific logic. - * - * Input Parameters: - * addr - The address of 16-bit value to be incremented. - * value - The 16-bit addend - * - * Returned Value: - * The incremented value (volatile!) - * - ****************************************************************************/ - - .globl up_fetchadd16 - .type up_fetchadd16, %function - -up_fetchadd16: - -1: - ldrexh r2, [r0] /* Fetch the value to be incremented */ - add r2, r2, r1 /* Add the addend */ - - strexh r3, r2, [r0] /* Attempt to save the result */ - teq r3, #0 /* r3 will be 1 if strexh failed */ - bne 1b /* Failed to lock... try again */ - - mov r0, r2 /* Return the incremented value */ - bx lr /* Successful! */ - .size up_fetchadd16, . - up_fetchadd16 - -/**************************************************************************** - * Name: up_fetchsub16 - * - * Description: - * Perform an atomic fetch subtract operation on the provided 16-bit value. - * - * This function must be provided via the architecture-specific logic. - * - * Input Parameters: - * addr - The address of 16-bit value to be decremented. - * value - The 16-bit subtrahend - * - * Returned Value: - * The decremented value (volatile!) - * - ****************************************************************************/ - - .globl up_fetchsub16 - .type up_fetchsub16, %function - -up_fetchsub16: - -1: - ldrexh r2, [r0] /* Fetch the value to be decremented */ - sub r2, r2, r1 /* Subtract the subtrahend */ - - /* Attempt to save the decremented value */ - - strexh r3, r2, [r0] /* Attempt to save the result */ - teq r3, #0 /* r3 will be 1 if strexh failed */ - bne 1b /* Failed to lock... try again */ - - mov r0, r2 /* Return the decremented value */ - bx lr /* Successful! */ - .size up_fetchsub16, . - up_fetchsub16 - -/**************************************************************************** - * Name: up_fetchadd8 - * - * Description: - * Perform an atomic fetch add operation on the provided 8-bit value. - * - * This function must be provided via the architecture-specific logic. - * - * Input Parameters: - * addr - The address of 8-bit value to be incremented. - * value - The 8-bit addend - * - * Returned Value: - * The incremented value (volatile!) - * - ****************************************************************************/ - - .globl up_fetchadd8 - .type up_fetchadd8, %function - -up_fetchadd8: - -1: - ldrexb r2, [r0] /* Fetch the value to be incremented */ - add r2, r2, r1 /* Add the addend */ - - strexb r3, r2, [r0] /* Attempt to save the result */ - teq r3, #0 /* r3 will be 1 if strexb failed */ - bne 1b /* Failed to lock... try again */ - - mov r0, r2 /* Return the incremented value */ - bx lr /* Successful! */ - .size up_fetchadd8, . - up_fetchadd8 - -/**************************************************************************** - * Name: up_fetchsub8 - * - * Description: - * Perform an atomic fetch subtract operation on the provided 8-bit value. - * - * This function must be provided via the architecture-specific logic. - * - * Input Parameters: - * addr - The address of 8-bit value to be decremented. - * value - The 8-bit subtrahend - * - * Returned Value: - * The decremented value (volatile!) - * - ****************************************************************************/ - - .globl up_fetchsub8 - .type up_fetchsub8, %function - -up_fetchsub8: - -1: - ldrexb r2, [r0] /* Fetch the value to be decremented */ - sub r2, r2, r1 /* Subtract the subtrahend */ - - strexb r3, r2, [r0] /* Attempt to save the result */ - teq r3, #0 /* r3 will be 1 if strexb failed */ - bne 1b /* Failed to lock... try again */ - - mov r0, r2 /* Return the decremented value */ - bx lr /* Successful! */ - .size up_fetchsub8, . - up_fetchsub8 - .end diff --git a/arch/arm/src/armv7-m/gnu/arm_fpu.S b/arch/arm/src/armv7-m/gnu/arm_fpu.S deleted file mode 100644 index cf63f642f7b06..0000000000000 --- a/arch/arm/src/armv7-m/gnu/arm_fpu.S +++ /dev/null @@ -1,270 +0,0 @@ -/**************************************************************************** - * arch/arm/src/armv7-m/gnu/arm_fpu.S - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. The - * ASF licenses this file to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance with the - * License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - ****************************************************************************/ -/* - * When this file is assembled, it will require the following GCC options: - * - * -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=vfp -meabi=5 -mthumb - */ - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include - -#include - -#ifdef CONFIG_ARCH_FPU - -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -/**************************************************************************** - * Public Symbols - ****************************************************************************/ - - .globl arm_savefpu - .globl arm_restorefpu - - .syntax unified - .thumb - .file "arm_fpu.S" - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: arm_savefpu - * - * Description: - * Given the pointer to a register save area (in R0), save the state of the - * floating point registers. - * - * C Function Prototype: - * void arm_savefpu(uint32_t *regs); - * - * Input Parameters: - * regs - A pointer to the register save area in which to save the floating point - * registers - * - * Returned Value: - * None - * - ****************************************************************************/ - - .thumb_func - .type arm_savefpu, function -arm_savefpu: - - add r1, r0, #(4*REG_S0) /* R1=Address of FP register storage */ - - /* Some older GNU assemblers don't support all the newer UAL mnemonics. */ - -#if 1 /* Use UAL mnemonics */ - /* Store all floating point registers. Registers are stored in numeric order, - * s0, s1, ... in increasing address order. - */ - - vstmia r1!, {s0-s31} /* Save the full FP context */ - - /* Store the floating point control and status register. At the end of the - * vstmia, r1 will point to the FPSCR storage location. - */ - - vmrs r2, fpscr /* Fetch the FPSCR */ - str r2, [r1], #4 /* Save the floating point control and status register */ -#else - /* Store all floating point registers */ - -#if 1 /* Use store multiple */ - fstmias r1!, {s0-s31} /* Save the full FP context */ -#else - vmov r2, r3, d0 /* r2, r3 = d0 */ - str r2, [r1], #4 /* Save S0 and S1 values */ - str r3, [r1], #4 - vmov r2, r3, d1 /* r2, r3 = d1 */ - str r2, [r1], #4 /* Save S2 and S3 values */ - str r3, [r1], #4 - vmov r2, r3, d2 /* r2, r3 = d2 */ - str r2, [r1], #4 /* Save S4 and S5 values */ - str r3, [r1], #4 - vmov r2, r3, d3 /* r2, r3 = d3 */ - str r2, [r1], #4 /* Save S6 and S7 values */ - str r3, [r1], #4 - vmov r2, r3, d4 /* r2, r3 = d4 */ - str r2, [r1], #4 /* Save S8 and S9 values */ - str r3, [r1], #4 - vmov r2, r3, d5 /* r2, r3 = d5 */ - str r2, [r1], #4 /* Save S10 and S11 values */ - str r3, [r1], #4 - vmov r2, r3, d6 /* r2, r3 = d6 */ - str r2, [r1], #4 /* Save S12 and S13 values */ - str r3, [r1], #4 - vmov r2, r3, d7 /* r2, r3 = d7 */ - str r2, [r1], #4 /* Save S14 and S15 values */ - str r3, [r1], #4 - vmov r2, r3, d8 /* r2, r3 = d8 */ - str r2, [r1], #4 /* Save S16 and S17 values */ - str r3, [r1], #4 - vmov r2, r3, d9 /* r2, r3 = d9 */ - str r2, [r1], #4 /* Save S18 and S19 values */ - str r3, [r1], #4 - vmov r2, r3, d10 /* r2, r3 = d10 */ - str r2, [r1], #4 /* Save S20 and S21 values */ - str r3, [r1], #4 - vmov r2, r3, d11 /* r2, r3 = d11 */ - str r2, [r1], #4 /* Save S22 and S23 values */ - str r3, [r1], #4 - vmov r2, r3, d12 /* r2, r3 = d12 */ - str r2, [r1], #4 /* Save S24 and S25 values */ - str r3, [r1], #4 - vmov r2, r3, d13 /* r2, r3 = d13 */ - str r2, [r1], #4 /* Save S26 and S27 values */ - str r3, [r1], #4 - vmov r2, r3, d14 /* r2, r3 = d14 */ - str r2, [r1], #4 /* Save S28 and S29 values */ - str r3, [r1], #4 - vmov r2, r3, d15 /* r2, r3 = d15 */ - str r2, [r1], #4 /* Save S30 and S31 values */ - str r3, [r1], #4 -#endif - - /* Store the floating point control and status register */ - - fmrx r2, fpscr /* Fetch the FPSCR */ - str r2, [r1], #4 /* Save the floating point control and status register */ -#endif - bx lr - - .size arm_savefpu, .-arm_savefpu - -/**************************************************************************** - * Name: arm_restorefpu - * - * Description: - * Given the pointer to a register save area (in R0), restore the state of the - * floating point registers. - * - * C Function Prototype: - * void arm_restorefpu(const uint32_t *regs); - * - * Input Parameters: - * regs - A pointer to the register save area containing the floating point - * registers. - * - * Returned Value: - * This function does not return anything explicitly. However, it is called from - * interrupt level assembly logic that assumes that r0 is preserved. - * - ****************************************************************************/ - - .thumb_func - .type arm_restorefpu, function -arm_restorefpu: - - add r1, r0, #(4*REG_S0) /* R1=Address of FP register storage */ - - /* Some older GNU assemblers don't support all the newer UAL mnemonics. */ - -#if 1 /* Use UAL mnemonics */ - /* Load all floating point registers. Registers are loaded in numeric order, - * s0, s1, ... in increasing address order. - */ - - vldmia r1!, {s0-s31} /* Restore the full FP context */ - - /* Load the floating point control and status register. At the end of the - * vstmia, r1 will point to the FPSCR storage location. - */ - - ldr r2, [r1], #4 /* Fetch the floating point control and status register */ - vmsr fpscr, r2 /* Restore the FPSCR */ -#else - /* Load all floating point registers Registers are loaded in numeric order, - * s0, s1, ... in increasing address order. - */ - -#if 1 /* Use load multiple */ - fldmias r1!, {s0-s31} /* Restore the full FP context */ -#else - ldr r2, [r1], #4 /* Fetch S0 and S1 values */ - ldr r3, [r1], #4 - vmov d0, r2, r3 /* Save as d0 */ - ldr r2, [r1], #4 /* Fetch S2 and S3 values */ - ldr r3, [r1], #4 - vmov d1, r2, r3 /* Save as d1 */ - ldr r2, [r1], #4 /* Fetch S4 and S5 values */ - ldr r3, [r1], #4 - vmov d2, r2, r3 /* Save as d2 */ - ldr r2, [r1], #4 /* Fetch S6 and S7 values */ - ldr r3, [r1], #4 - vmov d3, r2, r3 /* Save as d3 */ - ldr r2, [r1], #4 /* Fetch S8 and S9 values */ - ldr r3, [r1], #4 - vmov d4, r2, r3 /* Save as d4 */ - ldr r2, [r1], #4 /* Fetch S10 and S11 values */ - ldr r3, [r1], #4 - vmov d5, r2, r3 /* Save as d5 */ - ldr r2, [r1], #4 /* Fetch S12 and S13 values */ - ldr r3, [r1], #4 - vmov d6, r2, r3 /* Save as d6 */ - ldr r2, [r1], #4 /* Fetch S14 and S15 values */ - ldr r3, [r1], #4 - vmov d7, r2, r3 /* Save as d7 */ - ldr r2, [r1], #4 /* Fetch S16 and S17 values */ - ldr r3, [r1], #4 - vmov d8, r2, r3 /* Save as d8 */ - ldr r2, [r1], #4 /* Fetch S18 and S19 values */ - ldr r3, [r1], #4 - vmov d9, r2, r3 /* Save as d9 */ - ldr r2, [r1], #4 /* Fetch S20 and S21 values */ - ldr r3, [r1], #4 - vmov d10, r2, r3 /* Save as d10 */ - ldr r2, [r1], #4 /* Fetch S22 and S23 values */ - ldr r3, [r1], #4 - vmov d11, r2, r3 /* Save as d11 */ - ldr r2, [r1], #4 /* Fetch S24 and S25 values */ - ldr r3, [r1], #4 - vmov d12, r2, r3 /* Save as d12 */ - ldr r2, [r1], #4 /* Fetch S26 and S27 values */ - ldr r3, [r1], #4 - vmov d13, r2, r3 /* Save as d13 */ - ldr r2, [r1], #4 /* Fetch S28 and S29 values */ - ldr r3, [r1], #4 - vmov d14, r2, r3 /* Save as d14 */ - ldr r2, [r1], #4 /* Fetch S30 and S31 values */ - ldr r3, [r1], #4 - vmov d15, r2, r3 /* Save as d15 */ -#endif - - /* Load the floating point control and status register. r1 points t - * the address of the FPSCR register. - */ - - ldr r2, [r1], #4 /* Fetch the floating point control and status register */ - fmxr fpscr, r2 /* Restore the FPSCR */ -#endif - bx lr - - .size arm_restorefpu, .-arm_restorefpu -#endif /* CONFIG_ARCH_FPU */ - .end diff --git a/arch/arm/src/armv7-m/gnu/arm_fullcontextrestore.S b/arch/arm/src/armv7-m/gnu/arm_fullcontextrestore.S deleted file mode 100644 index 54351f20636f4..0000000000000 --- a/arch/arm/src/armv7-m/gnu/arm_fullcontextrestore.S +++ /dev/null @@ -1,79 +0,0 @@ -/**************************************************************************** - * arch/arm/src/armv7-m/gnu/arm_fullcontextrestore.S - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. The - * ASF licenses this file to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance with the - * License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - ****************************************************************************/ - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include -#include -#include - -#include "nvic.h" - -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -/**************************************************************************** - * Public Symbols - ****************************************************************************/ - - .syntax unified - .thumb - .file "arm_fullcontextrestore.S" - -/**************************************************************************** - * Macros - ****************************************************************************/ - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: arm_fullcontextrestore - * - * Description: - * Restore the current thread context. Full prototype is: - * - * void arm_fullcontextrestore(uint32_t *restoreregs) noreturn_function; - * - * Returned Value: - * None - * - ****************************************************************************/ - - .thumb_func - .globl arm_fullcontextrestore - .type arm_fullcontextrestore, function -arm_fullcontextrestore: - - /* Perform the System call with R0=1 and R1=regs */ - - mov r1, r0 /* R1: regs */ - mov r0, #SYS_restore_context /* R0: restore context */ - svc #SYS_syscall /* Force synchronous SVCall (or Hard Fault) */ - - /* This call should not return */ - - bx lr /* Unnecessary ... will not return */ - .size arm_fullcontextrestore, .-arm_fullcontextrestore - .end diff --git a/arch/arm/src/armv7-m/gnu/arm_lazyexception.S b/arch/arm/src/armv7-m/gnu/arm_lazyexception.S deleted file mode 100644 index 29b88f638b123..0000000000000 --- a/arch/arm/src/armv7-m/gnu/arm_lazyexception.S +++ /dev/null @@ -1,333 +0,0 @@ -/**************************************************************************** - * arch/arm/src/armv7-m/gnu/up_lazyexcption.S - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. The - * ASF licenses this file to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance with the - * License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - ****************************************************************************/ - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include - -#include -#include - -#include "chip.h" -#include "exc_return.h" - -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -/* Configuration ************************************************************/ - -#ifdef CONFIG_ARCH_HIPRI_INTERRUPT - /* In protected mode without an interrupt stack, this interrupt handler will set the MSP to the - * stack pointer of the interrupted thread. If the interrupted thread was a privileged - * thread, that will be the MSP otherwise it will be the PSP. If the PSP is used, then the - * value of the MSP will be invalid when the interrupt handler returns because it will be a - * pointer to an old position in the unprivileged stack. Then when the high priority - * interrupt occurs and uses this stale MSP, there will most likely be a system failure. - * - * If the interrupt stack is selected, on the other hand, then the interrupt handler will - * always set the MSP to the interrupt stack. So when the high priority interrupt occurs, - * it will either use the MSP of the last privileged thread to run or, in the case of the - * nested interrupt, the interrupt stack if no privileged task has run. - */ - -# if defined(CONFIG_BUILD_PROTECTED) && CONFIG_ARCH_INTERRUPTSTACK < 8 -# error Interrupt stack must be used with high priority interrupts in protected mode -# endif - - /* Use the BASEPRI to control interrupts is required if nested, high - * priority interrupts are supported. - */ - -# ifndef CONFIG_ARMV7M_USEBASEPRI -# error CONFIG_ARMV7M_USEBASEPRI must be used with CONFIG_ARCH_HIPRI_INTERRUPT -# endif -#endif - -/**************************************************************************** - * Public Symbols - ****************************************************************************/ - - .globl exception_common - - .syntax unified - .thumb - .file "arm_lazyexception.S" - -/**************************************************************************** - * Macro Definitions - ****************************************************************************/ - -/**************************************************************************** - * Name: setintstack - * - * Description: - * Set the current stack pointer to the "top" the interrupt stack. Single CPU case. Must be - * provided by MCU-specific logic in chip.h for the SMP case. - * - ****************************************************************************/ - -#if !defined(CONFIG_SMP) && CONFIG_ARCH_INTERRUPTSTACK > 7 - .macro setintstack, tmp1, tmp2 - ldr sp, =g_intstacktop - .endm -#endif - -/**************************************************************************** - * .text - ****************************************************************************/ - -/* Common IRQ handling logic. On entry here, the return stack is on either - * the PSP or the MSP and looks like the following: - * - * REG_XPSR - * REG_R15 - * REG_R14 - * REG_R12 - * REG_R3 - * REG_R2 - * REG_R1 - * MSP->REG_R0 - * - * And - * IPSR contains the IRQ number - * R14 Contains the EXC_RETURN value - * We are in handler mode and the current SP is the MSP - */ - - .text - .type exception_common, function - -exception_common: - - /* Get the IRQ number from the IPSR */ - - mrs r0, ipsr /* R0=exception number */ - - /* Complete the context save */ - -#ifdef CONFIG_BUILD_PROTECTED - /* The EXC_RETURN value will be 0xfffffff9 (privileged thread) or 0xfffffff1 - * (handler mode) if the stack is on the MSP. It can only be on the PSP if - * EXC_RETURN is 0xfffffffd (unprivileged thread) - */ - - tst r14, #EXC_RETURN_PROCESS_STACK /* Nonzero if context on process stack */ - beq 1f /* Branch if context already on the MSP */ - mrs r1, psp /* R1=The process stack pointer (PSP) */ - mov sp, r1 /* Set the MSP to the PSP */ - -1: -#endif - - /* sp holds the value of the stack pointer AFTER the exception handling logic - * pushed the various registers onto the stack. Get r2 = the value of the - * stack pointer BEFORE the interrupt modified it. - */ - - mov r2, sp /* R2=Copy of the main/process stack pointer */ - add r2, #HW_XCPT_SIZE /* R2=MSP/PSP before the interrupt was taken */ - -#ifdef CONFIG_ARMV7M_USEBASEPRI - mrs r3, basepri /* R3=Current BASEPRI setting */ -#else - mrs r3, primask /* R3=Current PRIMASK setting */ -#endif - -#ifdef CONFIG_ARCH_FPU - /* Skip over the block of memory reserved for floating pointer register save. - * Lazy FPU register saving is used. FPU registers will be saved in this - * block only if a context switch occurs (this means, of course, that the FPU - * cannot be used in interrupt processing). - */ - - sub sp, #(4*SW_FPU_REGS) -#endif - - /* Save the remaining registers on the stack after the registers pushed - * by the exception handling logic. r2=SP and r3=primask or basepri, r4-r11, - * r14=register values. - */ - -#ifdef CONFIG_BUILD_PROTECTED - stmdb sp!, {r2-r11,r14} /* Save the remaining registers plus the SP value */ -#else - stmdb sp!, {r2-r11} /* Save the remaining registers plus the SP value */ -#endif - - /* There are two arguments to arm_doirq: - * - * R0 = The IRQ number - * R1 = The top of the stack points to the saved state - */ - - mov r1, sp - - /* Also save the top of the stack in a preserved register */ - - mov r4, sp - -#if CONFIG_ARCH_INTERRUPTSTACK > 7 - /* If CONFIG_ARCH_INTERRUPTSTACK is defined, we will set the MSP to use - * a special special interrupt stack pointer. The way that this is done - * here prohibits nested interrupts without some additional logic! - */ - - setintstack r2, r3 /* SP = IRQ stack top */ -#else - /* Otherwise, we will re-use the interrupted thread's stack. That may - * mean using either MSP or PSP stack for interrupt level processing (in - * kernel mode). - */ - - /* If the interrupt stack is disabled, reserve xcpcontext to ensure - * that signal processing can have a separate xcpcontext to handle - * signal context (reference: arm_schedulesigaction.c): - * ---------------------- - * | IRQ XCP context | - * ------------------- - * | Signal XCP context | - * ---------------------- <- SP - * also the sp should be restore after arm_doirq() - */ - - sub r2, r4, #XCPTCONTEXT_SIZE /* Reserve signal context */ - bic r2, r2, #7 /* Get the stack pointer with 8-byte alignment */ - mov sp, r2 /* Instantiate the aligned stack */ -#endif - - bl arm_doirq /* R0=IRQ, R1=register save (msp) */ - - /* On return from arm_doirq, R0 will hold a pointer to register context - * array to use for the interrupt return. If that return value is the same - * as current stack pointer, then things are relatively easy. - */ - - cmp r0, r4 /* Context switch? */ - beq 2f /* Branch if no context switch */ - - /* We are returning with a pending context switch. - * - * If the FPU is enabled, then we will need to restore FPU registers. - * This is not done in normal interrupt save/restore because the cost - * is prohibitive. This is only done when switching contexts. A - * consequence of this is that floating point operations may not be - * performed in interrupt handling logic. - * - * Here: - * r0 = Address of the register save area - * - * NOTE: It is a requirement that arm_restorefpu() preserve the value of - * r0! - */ - -#ifdef CONFIG_ARCH_FPU - bl arm_restorefpu /* Restore the FPU registers */ -#endif - -2: -#ifdef CONFIG_BUILD_PROTECTED - ldmia r0!, {r2-r11,r14} /* Recover R4-R11, r14 + 2 temp values */ -#else - ldmia r0!, {r2-r11} /* Recover R4-R11 + 2 temp values */ -#endif - -#ifdef CONFIG_ARCH_FPU - /* Skip over the block of memory reserved for floating pointer register - * save. Then R0 is the address of the HW save area - */ - - add r0, #(4*SW_FPU_REGS) -#endif - - /* Set up to return from the exception - * - * Here: - * r0 = Address on the target thread's stack position at the start of - * the registers saved by hardware - * r3 = primask or basepri - * r4-r11 = restored register values - */ - -#ifdef CONFIG_BUILD_PROTECTED - /* The EXC_RETURN value will be 0xfffffff9 (privileged thread) or 0xfffffff1 - * (handler mode) if the stack is on the MSP. It can only be on the PSP if - * EXC_RETURN is 0xfffffffd (unprivileged thread) - */ - - mrs r2, control /* R2=Contents of the control register */ - tst r14, #EXC_RETURN_PROCESS_STACK /* nonzero if context on process stack */ - beq 3f /* Branch if privileged */ - - orr r2, r2, #1 /* Unprivileged mode */ - msr psp, r0 /* R0=The process stack pointer */ - b 4f -3: - bic r2, r2, #1 /* Privileged mode */ - msr msp, r0 /* R0=The main stack pointer */ -4: - msr control, r2 /* Save the updated control register */ -#else - msr msp, r0 /* Recover the return MSP value */ - - /* Preload r14 with the special return value first (so that the return - * actually occurs with interrupts still disabled). - */ - - ldr r14, =EXC_RETURN_PRIVTHR /* Load the special value */ -#endif - - /* Restore the interrupt state */ - -#ifdef CONFIG_ARMV7M_USEBASEPRI - msr basepri, r3 /* Restore interrupts priority masking */ -#else - msr primask, r3 /* Restore interrupts */ -#endif - - /* Always return with R14 containing the special value that will: (1) - * return to thread mode, and (2) continue to use the MSP - */ - - bx r14 /* And return */ - .size exception_common, .-exception_common - -/**************************************************************************** - * Name: g_intstackalloc/g_intstacktop - * - * Description: - * Shouldn't happen - * - ****************************************************************************/ - -#if !defined(CONFIG_SMP) && CONFIG_ARCH_INTERRUPTSTACK > 7 - .bss - .global g_intstackalloc - .global g_intstacktop - .balign 8 -g_intstackalloc: - .skip ((CONFIG_ARCH_INTERRUPTSTACK + 4) & ~7) -g_intstacktop: - .size g_intstackalloc, .-g_intstackalloc -#endif - - .end diff --git a/arch/arm/src/armv7-m/gnu/arm_saveusercontext.S b/arch/arm/src/armv7-m/gnu/arm_saveusercontext.S deleted file mode 100644 index c5b12a3461a65..0000000000000 --- a/arch/arm/src/armv7-m/gnu/arm_saveusercontext.S +++ /dev/null @@ -1,88 +0,0 @@ -/**************************************************************************** - * arch/arm/src/armv7-m/gnu/arm_saveusercontext.S - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. The - * ASF licenses this file to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance with the - * License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - ****************************************************************************/ - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include -#include -#include - -#include "nvic.h" - -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -/**************************************************************************** - * Public Symbols - ****************************************************************************/ - - .syntax unified - .thumb - .file "arm_saveusercontext.S" - -/**************************************************************************** - * Macros - ****************************************************************************/ - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: arm_saveusercontext - * - * Description: - * Save the current thread context. Full prototype is: - * - * int arm_saveusercontext(uint32_t *saveregs); - * - * Returned Value: - * 0: Normal return - * 1: Context switch return - * - ****************************************************************************/ - - .text - .thumb_func - .globl arm_saveusercontext - .type arm_saveusercontext, function -arm_saveusercontext: - - /* Perform the System call with R0=0 and R1=regs */ - - mov r1, r0 /* R1: regs */ - mov r0, #SYS_save_context /* R0: save context (also return value) */ - svc #SYS_syscall /* Force synchronous SVCall (or Hard Fault) */ - - /* There are two return conditions. On the first return, R0 (the - * return value will be zero. On the second return we need to - * force R0 to be 1. - */ - - add r2, r1, #(4*REG_R0) - mov r3, #1 - str r3, [r2, #0] - bx lr /* "normal" return with r0=0 or - * context switch with r0=1 */ - .size arm_saveusercontext, .-arm_saveusercontext - .end diff --git a/arch/arm/src/armv7-m/gnu/arm_signal_handler.S b/arch/arm/src/armv7-m/gnu/arm_signal_handler.S deleted file mode 100644 index fa83e6c605088..0000000000000 --- a/arch/arm/src/armv7-m/gnu/arm_signal_handler.S +++ /dev/null @@ -1,102 +0,0 @@ -/**************************************************************************** - * arch/arm/src/armv7-m/gnu/arm_signal_handler.S - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. The - * ASF licenses this file to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance with the - * License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - ****************************************************************************/ - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include - -#include - -#if defined(CONFIG_BUILD_PROTECTED) && !defined(__KERNEL__) - -/**************************************************************************** - * File info - ****************************************************************************/ - - .syntax unified - .thumb - .file "arm_signal_handler.S" - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: up_signal_handler - * - * Description: - * This function is the user-space, signal handler trampoline function. It - * is called from up_signal_dispatch() in user-mode. - * - * R0-R3, R11 - volatile registers need not be preserved. - * R4-R10 - static registers must be preserved - * R12-R14 - LR and SP must be preserved - * - * Input Parameters: - * R0 = sighand - * The address user-space signal handling function - * R1-R3 = signo, info, and ucontext - * Standard arguments to be passed to the signal handling function. - * - * Returned Value: - * None. This function does not return in the normal sense. It returns - * via the SYS_signal_handler_return (see syscall.h) - * - ****************************************************************************/ - - .text - .thumb_func - .globl up_signal_handler - .type up_signal_handler, function -up_signal_handler: - - /* Save some register */ - - push {lr} /* Save LR on the stack */ - - /* Call the signal handler */ - - mov ip, r0 /* IP=sighand */ - mov r0, r1 /* R0=signo */ - mov r1, r2 /* R1=info */ - mov r2, r3 /* R2=ucontext */ - blx ip /* Call the signal handler */ - - /* Restore the registers */ - - pop {r2} /* Recover LR in R2 */ - mov lr, r2 /* Restore LR */ - - /* Execute the SYS_signal_handler_return SVCall (will not return) */ - - mov r0, #SYS_signal_handler_return - svc #SYS_syscall - nop - - .size up_signal_handler, .-up_signal_handler - .end - -#endif /* CONFIG_BUILD_PROTECTED && !__KERNEL__ */ diff --git a/arch/arm/src/armv7-m/iar/arm_saveusercontext.S b/arch/arm/src/armv7-m/iar/arm_saveusercontext.S deleted file mode 100644 index 1806865d6a3de..0000000000000 --- a/arch/arm/src/armv7-m/iar/arm_saveusercontext.S +++ /dev/null @@ -1,86 +0,0 @@ -/**************************************************************************** - * arch/arm/src/armv7-m/iar/arm_saveusercontext.S - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. The - * ASF licenses this file to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance with the - * License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - ****************************************************************************/ - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include -#include -#include - -#include "nvic.h" - - MODULE arm_saveusercontext - SECTION .text:CODE:NOROOT(2) - -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -/**************************************************************************** - * Public Symbols - ****************************************************************************/ - - PUBLIC arm_saveusercontext - -/**************************************************************************** - * Macros - ****************************************************************************/ - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: arm_saveusercontext - * - * Description: - * Save the current thread context. Full prototype is: - * - * int arm_saveusercontext(uint32_t *saveregs); - * - * Returned Value: - * 0: Normal return - * 1: Context switch return - * - ****************************************************************************/ - - THUMB - -arm_saveusercontext: - - /* Perform the System call with R0=0 and R1=regs */ - - mov r1, r0 /* R1: regs */ - mov r0, #SYS_save_context /* R0: save context (also return value) */ - svc #SYS_syscall /* Force synchronous SVCall (or Hard Fault) */ - - /* There are two return conditions. On the first return, R0 (the - * return value will be zero. On the second return we need to - * force R0 to be 1. - */ - - add r2, r1, #(4*REG_R0) - mov r3, #1 - str r3, [r2, #0] - bx lr /* "normal" return with r0=0 or - * context switch with r0=1 */ - END diff --git a/arch/arm/src/armv7-r/Kconfig b/arch/arm/src/armv7-r/Kconfig index ec787e786a68b..21f0dc19653d0 100644 --- a/arch/arm/src/armv7-r/Kconfig +++ b/arch/arm/src/armv7-r/Kconfig @@ -128,25 +128,15 @@ endif # ARMV7R_HAVE_L2CC choice prompt "Toolchain Selection" - default ARMV7R_TOOLCHAIN_GNU_EABIW if TOOLCHAIN_WINDOWS - default ARMV7R_TOOLCHAIN_GNU_EABIL if !TOOLCHAIN_WINDOWS + default ARMV7R_TOOLCHAIN_GNU_EABI config ARMV7R_TOOLCHAIN_BUILDROOT bool "Buildroot (Cygwin or Linux)" select ARCH_TOOLCHAIN_GNU depends on !WINDOWS_NATIVE -config ARMV7R_TOOLCHAIN_GNU_EABIL - bool "Generic GNU EABI toolchain under Linux (or other POSIX environment)" - select ARCH_TOOLCHAIN_GNU - ---help--- - This option should work for any modern GNU toolchain (GCC 4.5 or newer) - configured for arm-none-eabi-. - -config ARMV7R_TOOLCHAIN_GNU_EABIW - bool "Generic GNU EABI toolchain under Windows" - depends on TOOLCHAIN_WINDOWS - select CYGWIN_WINTOOL if WINDOWS_CYGWIN +config ARMV7R_TOOLCHAIN_GNU_EABI + bool "Generic GNU EABI toolchain" select ARCH_TOOLCHAIN_GNU ---help--- This option should work for any modern GNU toolchain (GCC 4.5 or newer) diff --git a/arch/arm/src/armv7-r/Make.defs b/arch/arm/src/armv7-r/Make.defs new file mode 100644 index 0000000000000..f6f29a67defd7 --- /dev/null +++ b/arch/arm/src/armv7-r/Make.defs @@ -0,0 +1,58 @@ +############################################################################ +# arch/arm/src/armv7-r/Make.defs +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. The +# ASF licenses this file to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance with the +# License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +# +############################################################################ + +# Common ARM files + +include common/Make.defs + +# The vector table is the "head" object, i.e., the one that must forced into +# the link in order to draw in all of the other components + +HEAD_ASRC += arm_vectortab.S + +# Common assembly language files + +CMN_CSRCS += arm_cache.c arm_dataabort.c arm_doirq.c arm_gicv2.c +CMN_CSRCS += arm_initialstate.c arm_prefetchabort.c +CMN_CSRCS += arm_schedulesigaction.c arm_sigdeliver.c +CMN_CSRCS += arm_syscall.c arm_tcbinfo.c arm_undefinedinsn.c + +# Common C source files + +CMN_ASRCS += arm_fpuconfig.S arm_head.S arm_vectoraddrexcptn.S +CMN_ASRCS += arm_vectors.S arm_vectortab.S cp15_cache_size.S +CMN_ASRCS += cp15_clean_dcache_all.S cp15_clean_dcache.S +CMN_ASRCS += cp15_coherent_dcache.S cp15_flush_dcache_all.S +CMN_ASRCS += cp15_flush_dcache.S cp15_invalidate_dcache_all.S +CMN_ASRCS += cp15_invalidate_dcache.S + + +ifeq ($(CONFIG_BUILD_PROTECTED),y) + CMN_CSRCS += arm_mpu.c +endif + +ifeq ($(CONFIG_ARMV7R_L2CC_PL310),y) + CMN_CSRCS += arm_l2cc_pl310.c +endif + +ifeq ($(CONFIG_ARCH_FPU),y) + CMN_CSRCS += arm_fpucmp.c + CMN_ASRCS += arm_fpuconfig.S +endif diff --git a/arch/arm/src/armv7-r/Toolchain.defs b/arch/arm/src/armv7-r/Toolchain.defs index 43860d442cb9e..d9c9427c544e9 100644 --- a/arch/arm/src/armv7-r/Toolchain.defs +++ b/arch/arm/src/armv7-r/Toolchain.defs @@ -32,13 +32,7 @@ ifeq ($(filter y, \ endif ifeq ($(filter y, \ - $(CONFIG_ARMV7R_TOOLCHAIN_GNU_EABIL) \ - ),y) - CONFIG_ARMV7R_TOOLCHAIN ?= GNU_EABI -endif - -ifeq ($(filter y, \ - $(CONFIG_ARMV7R_TOOLCHAIN_GNU_EABIW) \ + $(CONFIG_ARMV7R_TOOLCHAIN_GNU_EABI) \ ),y) CONFIG_ARMV7R_TOOLCHAIN ?= GNU_EABI endif @@ -51,20 +45,28 @@ endif # CROSSDEV The GNU toolchain triple (command prefix) # ARCHCPUFLAGS CPU-specific flags selecting the instruction set # FPU options, etc. -# MAXOPTIMIZATION The maximum optimization level that results in +# ARCHOPTIMIZATION The optimization level that results in # reliable code generation. # ifeq ($(CONFIG_DEBUG_CUSTOMOPT),y) - MAXOPTIMIZATION := $(CONFIG_DEBUG_OPTLEVEL) -else - MAXOPTIMIZATION ?= -Os + ARCHOPTIMIZATION += $(CONFIG_DEBUG_OPTLEVEL) +else ifeq ($(CONFIG_DEBUG_FULLOPT),y) + ARCHOPTIMIZATION += -Os +endif + +ifneq ($(CONFIG_DEBUG_NOOPT),y) + ARCHOPTIMIZATION += -fno-strict-aliasing endif ifeq ($(CONFIG_FRAME_POINTER),y) - MAXOPTIMIZATION += -fno-omit-frame-pointer -fno-optimize-sibling-calls + ARCHOPTIMIZATION += -fno-omit-frame-pointer -fno-optimize-sibling-calls else - MAXOPTIMIZATION += -fomit-frame-pointer + ARCHOPTIMIZATION += -fomit-frame-pointer +endif + +ifeq ($(CONFIG_STACK_CANARIES),y) + ARCHOPTIMIZATION += -fstack-protector-all endif ifeq ($(CONFIG_ARCH_CORTEXR4),y) @@ -116,26 +118,69 @@ ifeq ($(CONFIG_ARMV7R_TOOLCHAIN),GNU_EABI) CROSSDEV ?= $(TARGET_ARCH)-none-eabi- endif +ARCHCFLAGS += -fno-common +ARCHCXXFLAGS += -fno-common -nostdinc++ + +ifneq ($(CONFIG_CXX_EXCEPTION),y) + ARCHCXXFLAGS += -fno-exceptions -fcheck-new +endif + +ifneq ($(CONFIG_CXX_RTTI),y) + ARCHCXXFLAGS += -fno-rtti +endif + +# Optimization of unused sections + +ifeq ($(CONFIG_DEBUG_OPT_UNUSED_SECTIONS),y) + LDFLAGS += --gc-sections + ARCHOPTIMIZATION += -ffunction-sections -fdata-sections +endif + +# Debug link map + +ifeq ($(CONFIG_DEBUG_LINK_MAP),y) + LDFLAGS += --cref -Map=$(call CONVERT_PATH,$(TOPDIR)$(DELIM)nuttx.map) +endif + +ifeq ($(CONFIG_DEBUG_SYMBOLS),y) + LDFLAGS += -g + ARCHOPTIMIZATION += -g +endif + # Default toolchain -CC = $(CROSSDEV)gcc -CXX = $(CROSSDEV)g++ -CPP = $(CROSSDEV)gcc -E -P -x c -LD = $(CROSSDEV)ld -STRIP = $(CROSSDEV)strip --strip-unneeded -AR = $(CROSSDEV)ar rcs -NM = $(CROSSDEV)nm +CC = $(CROSSDEV)gcc +CXX = $(CROSSDEV)g++ +CPP = $(CROSSDEV)gcc -E -P -x c +STRIP = $(CROSSDEV)strip --strip-unneeded OBJCOPY = $(CROSSDEV)objcopy OBJDUMP = $(CROSSDEV)objdump +LD = $(CROSSDEV)ld +AR = $(CROSSDEV)ar rcs +NM = $(CROSSDEV)nm + +# Link Time Optimization + +ifeq ($(CONFIG_LTO_FULL),y) + ARCHOPTIMIZATION += -flto + ifeq ($(CONFIG_ARMV7R_TOOLCHAIN),GNU_EABI) + LD := $(CROSSDEV)gcc + AR := $(CROSSDEV)gcc-ar rcs + NM := $(CROSSDEV)gcc-nm + ARCHOPTIMIZATION += -fuse-linker-plugin + ARCHOPTIMIZATION += -fno-builtin + ARCHOPTIMIZATION += -nodefaultlibs + endif +endif # Add the builtin library -EXTRA_LIBS += ${wildcard ${shell $(CC) $(ARCHCPUFLAGS) --print-libgcc-file-name}} +EXTRA_LIBS += $(wildcard $(shell $(CC) $(ARCHCPUFLAGS) --print-libgcc-file-name)) ifneq ($(CONFIG_LIBM),y) - EXTRA_LIBS += ${wildcard ${shell $(CC) $(ARCHCPUFLAGS) --print-file-name=libm.a}} + EXTRA_LIBS += $(wildcard $(shell $(CC) $(ARCHCPUFLAGS) --print-file-name=libm.a)) endif ifeq ($(CONFIG_LIBSUPCXX),y) - EXTRA_LIBS += ${wildcard ${shell $(CC) $(ARCHCPUFLAGS) --print-file-name=libsupc++.a}} + EXTRA_LIBS += $(wildcard $(shell $(CC) $(ARCHCPUFLAGS) --print-file-name=libsupc++.a)) endif diff --git a/arch/arm/src/armv7-r/arm_doirq.c b/arch/arm/src/armv7-r/arm_doirq.c index c5c0b8ff5910d..6d59fc035da9f 100644 --- a/arch/arm/src/armv7-r/arm_doirq.c +++ b/arch/arm/src/armv7-r/arm_doirq.c @@ -60,22 +60,6 @@ uint32_t *arm_doirq(int irq, uint32_t *regs) irq_dispatch(irq, regs); -#ifdef CONFIG_ARCH_FPU - /* Check for a context switch. If a context switch occurred, then - * CURRENT_REGS will have a different value than it did on entry. If an - * interrupt level context switch has occurred, then restore the floating - * point state and the establish the correct address environment before - * returning from the interrupt. - */ - - if (regs != CURRENT_REGS) - { - /* Restore floating point registers */ - - arm_restorefpu((uint32_t *)CURRENT_REGS); - } -#endif - /* Set CURRENT_REGS to NULL to indicate that we are no longer in an * interrupt handler. */ diff --git a/arch/arm/src/armv7-r/arm_fetchadd.S b/arch/arm/src/armv7-r/arm_fetchadd.S deleted file mode 100644 index e8c1f38cfc5e0..0000000000000 --- a/arch/arm/src/armv7-r/arm_fetchadd.S +++ /dev/null @@ -1,240 +0,0 @@ -/**************************************************************************** - * arch/arm/src/armv7-r/arm_fetchadd.S - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. The - * ASF licenses this file to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance with the - * License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - ****************************************************************************/ - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include - - .file "arm_fetchadd.S" - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - - .text - -/**************************************************************************** - * Name: up_fetchadd32 - * - * Description: - * Perform an atomic fetch add operation on the provided 32-bit value. - * - * This function must be provided via the architecture-specific logic. - * - * Input Parameters: - * addr - The address of 32-bit value to be incremented. - * value - The 32-bit addend - * - * Returned Value: - * The incremented value (volatile!) - * - ****************************************************************************/ - - .globl up_fetchadd32 - .type up_fetchadd32, %function - -up_fetchadd32: - -1: - ldrex r2, [r0] /* Fetch the value to be incremented */ - add r2, r2, r1 /* Add the addend */ - - strex r3, r2, [r0] /* Attempt to save the result */ - teq r3, #0 /* r3 will be 1 if strex failed */ - bne 1b /* Failed to lock... try again */ - - mov r0, r2 /* Return the incremented value */ - bx lr /* Successful! */ - .size up_fetchadd32, . - up_fetchadd32 - -/**************************************************************************** - * Name: up_fetchsub32 - * - * Description: - * Perform an atomic fetch subtract operation on the provided 32-bit value. - * - * This function must be provided via the architecture-specific logic. - * - * Input Parameters: - * addr - The address of 32-bit value to be decremented. - * value - The 32-bit subtrahend - * - * Returned Value: - * The decremented value (volatile!) - * - ****************************************************************************/ - - .globl up_fetchsub32 - .type up_fetchsub32, %function - -up_fetchsub32: - -1: - ldrex r2, [r0] /* Fetch the value to be decremented */ - sub r2, r2, r1 /* Subtract the subtrahend */ - - strex r3, r2, [r0] /* Attempt to save the result */ - teq r3, #0 /* r3 will be 1 if strex failed */ - bne 1b /* Failed to lock... try again */ - - mov r0, r2 /* Return the decremented value */ - bx lr /* Successful! */ - .size up_fetchsub32, . - up_fetchsub32 - -/**************************************************************************** - * Name: up_fetchadd16 - * - * Description: - * Perform an atomic fetch add operation on the provided 16-bit value. - * - * This function must be provided via the architecture-specific logic. - * - * Input Parameters: - * addr - The address of 16-bit value to be incremented. - * value - The 16-bit addend - * - * Returned Value: - * The incremented value (volatile!) - * - ****************************************************************************/ - - .globl up_fetchadd16 - .type up_fetchadd16, %function - -up_fetchadd16: - -1: - ldrexh r2, [r0] /* Fetch the value to be incremented */ - add r2, r2, r1 /* Add the addend */ - - strexh r3, r2, [r0] /* Attempt to save the result */ - teq r3, #0 /* r3 will be 1 if strexh failed */ - bne 1b /* Failed to lock... try again */ - - mov r0, r2 /* Return the incremented value */ - bx lr /* Successful! */ - .size up_fetchadd16, . - up_fetchadd16 - -/**************************************************************************** - * Name: up_fetchsub16 - * - * Description: - * Perform an atomic fetch subtract operation on the provided 16-bit value. - * - * This function must be provided via the architecture-specific logic. - * - * Input Parameters: - * addr - The address of 16-bit value to be decremented. - * value - The 16-bit subtrahend - * - * Returned Value: - * The decremented value (volatile!) - * - ****************************************************************************/ - - .globl up_fetchsub16 - .type up_fetchsub16, %function - -up_fetchsub16: - -1: - ldrexh r2, [r0] /* Fetch the value to be decremented */ - sub r2, r2, r1 /* Subtract the subtrahend */ - - /* Attempt to save the decremented value */ - - strexh r3, r2, [r0] /* Attempt to save the result */ - teq r3, #0 /* r3 will be 1 if strexh failed */ - bne 1b /* Failed to lock... try again */ - - mov r0, r2 /* Return the decremented value */ - bx lr /* Successful! */ - .size up_fetchsub16, . - up_fetchsub16 - -/**************************************************************************** - * Name: up_fetchadd8 - * - * Description: - * Perform an atomic fetch add operation on the provided 8-bit value. - * - * This function must be provided via the architecture-specific logic. - * - * Input Parameters: - * addr - The address of 8-bit value to be incremented. - * value - The 8-bit addend - * - * Returned Value: - * The incremented value (volatile!) - * - ****************************************************************************/ - - .globl up_fetchadd8 - .type up_fetchadd8, %function - -up_fetchadd8: - -1: - ldrexb r2, [r0] /* Fetch the value to be incremented */ - add r2, r2, r1 /* Add the addend */ - - strexb r3, r2, [r0] /* Attempt to save the result */ - teq r3, #0 /* r3 will be 1 if strexb failed */ - bne 1b /* Failed to lock... try again */ - - mov r0, r2 /* Return the incremented value */ - bx lr /* Successful! */ - .size up_fetchadd8, . - up_fetchadd8 - -/**************************************************************************** - * Name: up_fetchsub8 - * - * Description: - * Perform an atomic fetch subtract operation on the provided 8-bit value. - * - * This function must be provided via the architecture-specific logic. - * - * Input Parameters: - * addr - The address of 8-bit value to be decremented. - * value - The 8-bit subtrahend - * - * Returned Value: - * The decremented value (volatile!) - * - ****************************************************************************/ - - .globl up_fetchsub8 - .type up_fetchsub8, %function - -up_fetchsub8: - -1: - ldrexb r2, [r0] /* Fetch the value to be decremented */ - sub r2, r2, r1 /* Subtract the subtrahend */ - - strexb r3, r2, [r0] /* Attempt to save the result */ - teq r3, #0 /* r3 will be 1 if strexb failed */ - bne 1b /* Failed to lock... try again */ - - mov r0, r2 /* Return the decremented value */ - bx lr /* Successful! */ - .size up_fetchsub8, . - up_fetchsub8 - .end diff --git a/arch/arm/src/armv7-r/arm_fpucmp.c b/arch/arm/src/armv7-r/arm_fpucmp.c new file mode 100644 index 0000000000000..e37ee256daea1 --- /dev/null +++ b/arch/arm/src/armv7-r/arm_fpucmp.c @@ -0,0 +1,58 @@ +/**************************************************************************** + * arch/arm/src/armv7-r/arm_fpucmp.c + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include +#include +#include + +#include "arm_internal.h" + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +#ifdef CONFIG_ARCH_FPU + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: up_fpucmp + * + * Description: + * compare FPU areas from thread context + * + ****************************************************************************/ + +bool up_fpucmp(const void *saveregs1, const void *saveregs2) +{ + const uint32_t *regs1 = saveregs1; + const uint32_t *regs2 = saveregs2; + + return memcmp(®s1[REG_S0], ®s2[REG_S0], 4 * FPU_CONTEXT_REGS) == 0; +} +#endif /* CONFIG_ARCH_FPU */ diff --git a/arch/arm/src/armv7-r/arm_head.S b/arch/arm/src/armv7-r/arm_head.S index 09186d41e0f40..d5744dd145549 100644 --- a/arch/arm/src/armv7-r/arm_head.S +++ b/arch/arm/src/armv7-r/arm_head.S @@ -136,8 +136,7 @@ __start: /* Make sure that we are in SYS mode with IRQs and FIQs disabled */ - mov r0, #(PSR_MODE_SYS | PSR_I_BIT | PSR_F_BIT) - msr cpsr_c, r0 + cpsid if, #PSR_MODE_SYS /* Set up the stack pointer and clear the frame pointer. */ diff --git a/arch/arm/src/armv7-r/arm_initialstate.c b/arch/arm/src/armv7-r/arm_initialstate.c index 1c40415f00d73..eeba7b6cabba2 100644 --- a/arch/arm/src/armv7-r/arm_initialstate.c +++ b/arch/arm/src/armv7-r/arm_initialstate.c @@ -82,9 +82,9 @@ void up_initial_state(struct tcb_s *tcb) /* Initialize the context registers to stack top */ - xcp->regs = (FAR void *)((uint32_t)tcb->stack_base_ptr + - tcb->adj_stack_size - - XCPTCONTEXT_SIZE); + xcp->regs = (void *)((uint32_t)tcb->stack_base_ptr + + tcb->adj_stack_size - + XCPTCONTEXT_SIZE); /* Initialize the xcp registers */ diff --git a/arch/arm/src/armv7-r/arm_restorefpu.S b/arch/arm/src/armv7-r/arm_restorefpu.S deleted file mode 100644 index 746a3e121e334..0000000000000 --- a/arch/arm/src/armv7-r/arm_restorefpu.S +++ /dev/null @@ -1,92 +0,0 @@ -/**************************************************************************** - * arch/arm/src/armv7-r/arm_restorefpu.S - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. The - * ASF licenses this file to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance with the - * License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - ****************************************************************************/ - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include - -#include - -#ifdef CONFIG_ARCH_FPU - -/**************************************************************************** - * Public Symbols - ****************************************************************************/ - - .globl arm_restorefpu - .file "arm_restorefpu.S" - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - - .text - -/**************************************************************************** - * Name: arm_restorefpu - * - * Description: - * Given the pointer to a register save area (in R0), restore the state of the - * floating point registers. - * - * C Function Prototype: - * void arm_restorefpu(const uint32_t *regs); - * - * Input Parameters: - * regs - A pointer to the register save area containing the floating point - * registers. - * - * Returned Value: - * This function does not return anything explicitly. However, it is called from - * interrupt level assembly logic that assumes that r0 is preserved. - * - ****************************************************************************/ - - .globl arm_restorefpu - .type arm_restorefpu, function - -arm_restorefpu: - - add r1, r0, #(4*REG_S0) /* R1=Address of FP register storage */ - - /* Load all floating point registers. Registers are loaded in numeric order, - * s0, s1, ... in increasing address order. - */ - -#ifdef CONFIG_ARM_DPFPU32 - vldmia.64 r1!, {d0-d15} /* Restore the full FP context */ - vldmia.64 r1!, {d16-d31} -#else - vldmia r1!, {s0-s31} /* Restore the full FP context */ -#endif - - /* Load the floating point control and status register. At the end of the - * vstmia, r1 will point to the FPSCR storage location. - */ - - ldr r2, [r1], #4 /* Fetch the floating point control and status register */ - vmsr fpscr, r2 /* Restore the FPSCR */ - bx lr - - .size arm_restorefpu, .-arm_restorefpu -#endif /* CONFIG_ARCH_FPU */ - .end diff --git a/arch/arm/src/armv7-r/arm_savefpu.S b/arch/arm/src/armv7-r/arm_savefpu.S deleted file mode 100644 index 2ae4830b85ea7..0000000000000 --- a/arch/arm/src/armv7-r/arm_savefpu.S +++ /dev/null @@ -1,96 +0,0 @@ -/**************************************************************************** - * arch/arm/src/armv7-r/arm_savefpu.S - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. The - * ASF licenses this file to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance with the - * License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - ****************************************************************************/ - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include - -#include - -#ifdef CONFIG_ARCH_FPU - - .file "arm_savefpu.S" - -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -/**************************************************************************** - * Public Symbols - ****************************************************************************/ - - .globl arm_savefpu - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - - .text - -/**************************************************************************** - * Name: arm_savefpu - * - * Description: - * Given the pointer to a register save area (in R0), save the state of the - * floating point registers. - * - * C Function Prototype: - * void arm_savefpu(uint32_t *regs); - * - * Input Parameters: - * regs - A pointer to the register save area in which to save the floating point - * registers - * - * Returned Value: - * None - * - ****************************************************************************/ - - .globl arm_savefpu - .type arm_savefpu, function - -arm_savefpu: - - add r1, r0, #(4*REG_S0) /* R1=Address of FP register storage */ - - /* Store all floating point registers. Registers are stored in numeric order, - * s0, s1, ... in increasing address order. - */ - -#ifdef CONFIG_ARM_DPFPU32 - vstmia.64 r1!, {d0-d15} /* Save the full FP context */ - vstmia.64 r1!, {d16-d31} -#else - vstmia r1!, {s0-s31} /* Save the full FP context */ -#endif - - /* Store the floating point control and status register. At the end of the - * vstmia, r1 will point to the FPSCR storage location. - */ - - vmrs r2, fpscr /* Fetch the FPSCR */ - str r2, [r1], #4 /* Save the floating point control and status register */ - bx lr - - .size arm_savefpu, .-arm_savefpu -#endif /* CONFIG_ARCH_FPU */ - .end diff --git a/arch/arm/src/armv7-r/arm_saveusercontext.S b/arch/arm/src/armv7-r/arm_saveusercontext.S deleted file mode 100644 index e1a46861626e6..0000000000000 --- a/arch/arm/src/armv7-r/arm_saveusercontext.S +++ /dev/null @@ -1,129 +0,0 @@ -/**************************************************************************** - * arch/arm/src/armv7-r/arm_saveusercontext.S - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. The - * ASF licenses this file to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance with the - * License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - ****************************************************************************/ - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include -#include - -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -/**************************************************************************** - * Public Symbols - ****************************************************************************/ - - .file "arm_saveusercontext.S" - -/**************************************************************************** - * Macros - ****************************************************************************/ - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: arm_saveusercontext - * - * Description: - * Save the current thread context. Full prototype is: - * - * int arm_saveusercontext(uint32_t *saveregs); - * - * Returned Value: - * 0: Normal return - * 1: Context switch return - * - ****************************************************************************/ - - .globl arm_saveusercontext - .type arm_saveusercontext, function -arm_saveusercontext: - - /* On entry, a1 (r0) holds address of struct xcptcontext */ - - /* Make sure that the return value will be non-zero (the value of the - * other volatile registers don't matter -- r1-r3, ip). This function - * is called through the normal C calling conventions and the values of - * these registers cannot be assumed at the point of setjmp return. - */ - - mov ip, #1 - str ip, [r0, #(4*REG_R0)] - - /* Save the volatile registers (plus r12 which really - * doesn't need to be saved) - */ - - add r1, r0, #(4*REG_R4) - stmia r1, {r4-r14} - - /* Save the current cpsr */ - - mrs r2, cpsr /* R2 = CPSR value */ - add r1, r0, #(4*REG_CPSR) - str r2, [r1] - - /* Save the return address as the PC so that we return to the exit from - * this function. - */ - - add r1, r0, #(4*REG_PC) - str lr, [r1] - - /* Save the floating point registers. - * REVISIT: Not all of the floating point registers need to be saved. - * Some are volatile and need not be preserved across functions calls. - * But right now, I can't find the definitive list of the volatile - * floating point registers. - */ - -#ifdef CONFIG_ARCH_FPU - add r1, r0, #(4*REG_S0) /* R1=Address of FP register storage */ - - /* Store all floating point registers. Registers are stored in numeric order, - * s0, s1, ... in increasing address order. - */ - -#ifdef CONFIG_ARM_DPFPU32 - vstmia.64 r1!, {d0-d15} /* Save the full FP context */ - vstmia.64 r1!, {d16-d31} -#else - vstmia r1!, {s0-s31} /* Save the full FP context */ -#endif - - /* Store the floating point control and status register. At the end of the - * vstmia, r1 will point to the FPSCR storage location. - */ - - vmrs r2, fpscr /* Fetch the FPSCR */ - str r2, [r1], #4 /* Save the floating point control and status register */ -#endif - - /* Return 0 now indicating that this return is not a context switch */ - - mov r0, #0 /* Return value == 0 */ - bx lr /* Return */ - .size arm_saveusercontext, .-arm_saveusercontext - .end diff --git a/arch/arm/src/armv7-r/arm_schedulesigaction.c b/arch/arm/src/armv7-r/arm_schedulesigaction.c index 245696378a468..122d5bf441cff 100644 --- a/arch/arm/src/armv7-r/arm_schedulesigaction.c +++ b/arch/arm/src/armv7-r/arm_schedulesigaction.c @@ -134,10 +134,10 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver) * delivered. */ - CURRENT_REGS = (FAR void *) + CURRENT_REGS = (void *) ((uint32_t)CURRENT_REGS - (uint32_t)XCPTCONTEXT_SIZE); - memcpy((FAR uint32_t *)CURRENT_REGS, tcb->xcp.saved_regs, + memcpy((uint32_t *)CURRENT_REGS, tcb->xcp.saved_regs, XCPTCONTEXT_SIZE); CURRENT_REGS[REG_SP] = (uint32_t)CURRENT_REGS + @@ -180,7 +180,7 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver) * delivered. */ - tcb->xcp.regs = (FAR void *) + tcb->xcp.regs = (void *) ((uint32_t)tcb->xcp.regs - (uint32_t)XCPTCONTEXT_SIZE); memcpy(tcb->xcp.regs, tcb->xcp.saved_regs, XCPTCONTEXT_SIZE); diff --git a/arch/arm/src/armv7-r/arm_signal_dispatch.c b/arch/arm/src/armv7-r/arm_signal_dispatch.c deleted file mode 100644 index a229d42851c98..0000000000000 --- a/arch/arm/src/armv7-r/arm_signal_dispatch.c +++ /dev/null @@ -1,92 +0,0 @@ -/**************************************************************************** - * arch/arm/src/armv7-r/arm_signal_dispatch.c - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. The - * ASF licenses this file to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance with the - * License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - ****************************************************************************/ - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include -#include - -#include - -#include "pgalloc.h" -#include "arm_internal.h" - -#if !defined(CONFIG_BUILD_FLAT) && defined(__KERNEL__) - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: up_signal_dispatch - * - * Description: - * In the protected mode build, this function will be called to execute a - * a signal handler in user-space. When the signal is delivered, a - * kernel-mode stub will first run to perform some housekeeping functions. - * This kernel-mode stub will then be called transfer control to the user - * mode signal handler by calling this function. - * - * Normally the a user-mode signalling handling stub will also execute - * before the ultimate signal handler is called. See - * arch/arm/src/armv[6\7]/up_signal_handler. This function is the - * user-space, signal handler trampoline function. It is called from - * up_signal_dispatch() in user-mode. - * - * Input Parameters: - * sighand - The address user-space signal handling function - * signo, info, and ucontext - Standard arguments to be passed to the - * signal handling function. - * - * Returned Value: - * None. This function does not return in the normal sense. It returns - * via an architecture specific system call made by up_signal_handler(). - * However, this will look like a normal return by the caller of - * up_signal_dispatch. - * - ****************************************************************************/ - -void up_signal_dispatch(_sa_sigaction_t sighand, int signo, - FAR siginfo_t *info, FAR void *ucontext) -{ - /* We are signalling a user group, but does the signal handler lie in the - * user address space? Or the kernel address space? The OS does - * intercept some signals for its own purpose (such as the death-of-child - * signal. - */ - - if (arm_uservaddr((uintptr_t)sighand)) - { - /* Yes.. Let sys_call4() do all of the work to get us into user space */ - - sys_call4(SYS_signal_handler, (uintptr_t)sighand, (uintptr_t)signo, - (uintptr_t)info, (uintptr_t)ucontext); - } - else - { - /* No.. we are already in kernel mode so just call the handler */ - - sighand(signo, info, ucontext); - } -} - -#endif /* !CONFIG_BUILD_FLAT && __KERNEL__ */ diff --git a/arch/arm/src/armv7-r/arm_signal_handler.S b/arch/arm/src/armv7-r/arm_signal_handler.S deleted file mode 100644 index 585f362d127d7..0000000000000 --- a/arch/arm/src/armv7-r/arm_signal_handler.S +++ /dev/null @@ -1,99 +0,0 @@ -/**************************************************************************** - * arch/arm/src/armv7-r/arm_signal_handler.S - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. The - * ASF licenses this file to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance with the - * License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - ****************************************************************************/ - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include - -#include - -#if defined(CONFIG_BUILD_PROTECTED) && !defined(__KERNEL__) - -/**************************************************************************** - * File info - ****************************************************************************/ - - .file "arm_signal_handler.S" - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: up_signal_handler - * - * Description: - * This function is the user-space, signal handler trampoline function. It - * is called from up_signal_dispatch() in user-mode. - * - * R0-R3, R11 - volatile registers need not be preserved. - * R4-R10 - static registers must be preserved - * R12-R14 - LR and SP must be preserved - * - * Input Parameters: - * R0 = sighand - * The address user-space signal handling function - * R1-R3 = signo, info, and ucontext - * Standard arguments to be passed to the signal handling function. - * - * Returned Value: - * None. This function does not return in the normal sense. It returns - * via the SYS_signal_handler_return (see syscall.h) - * - ****************************************************************************/ - - .text - .globl up_signal_handler - .type up_signal_handler, function -up_signal_handler: - - /* Save some register */ - - push {lr} /* Save LR on the stack */ - - /* Call the signal handler */ - - mov ip, r0 /* IP=sighand */ - mov r0, r1 /* R0=signo */ - mov r1, r2 /* R1=info */ - mov r2, r3 /* R2=ucontext */ - blx ip /* Call the signal handler */ - - /* Restore the registers */ - - pop {r2} /* Recover LR in R2 */ - mov lr, r2 /* Restore LR */ - - /* Execute the SYS_signal_handler_return SVCall (will not return) */ - - mov r0, #SYS_signal_handler_return - svc #SYS_syscall - nop - - .size up_signal_handler, .-up_signal_handler - .end - -#endif /* CONFIG_BUILD_PROTECTED && !__KERNEL__ */ diff --git a/arch/arm/src/armv7-r/arm_syscall.c b/arch/arm/src/armv7-r/arm_syscall.c index 4a52d0191bbda..8283583ca86aa 100644 --- a/arch/arm/src/armv7-r/arm_syscall.c +++ b/arch/arm/src/armv7-r/arm_syscall.c @@ -33,9 +33,10 @@ #include #include -#include "signal/signal.h" +#include "addrenv.h" #include "arm.h" #include "arm_internal.h" +#include "signal/signal.h" /**************************************************************************** * Private Functions @@ -162,7 +163,13 @@ uint32_t *arm_syscall(uint32_t *regs) /* Nested interrupts are not supported */ - DEBUGASSERT(regs); + DEBUGASSERT(CURRENT_REGS == NULL); + + /* Current regs non-zero indicates that we are processing an interrupt; + * CURRENT_REGS is also used to manage interrupt level context switches. + */ + + CURRENT_REGS = regs; /* The SYSCALL command is in R0 on entry. Parameters follow in R1..R7 */ @@ -193,7 +200,7 @@ uint32_t *arm_syscall(uint32_t *regs) #ifdef CONFIG_LIB_SYSCALL case SYS_syscall_return: { - FAR struct tcb_s *rtcb = nxsched_self(); + struct tcb_s *rtcb = nxsched_self(); int index = (int)rtcb->xcp.nsyscalls - 1; /* Make sure that there is a saved SYSCALL return address. */ @@ -236,7 +243,7 @@ uint32_t *arm_syscall(uint32_t *regs) */ rtcb->flags &= ~TCB_FLAG_SYSCALL; - (void)nxsig_unmask_pendingsignal(); + nxsig_unmask_pendingsignal(); } break; #endif @@ -259,9 +266,8 @@ uint32_t *arm_syscall(uint32_t *regs) * set will determine the restored context. */ - arm_restorefpu((uint32_t *)regs[REG_R1]); - regs = (uint32_t *)regs[REG_R1]; - DEBUGASSERT(regs); + CURRENT_REGS = (uint32_t *)regs[REG_R1]; + DEBUGASSERT(CURRENT_REGS); } break; @@ -285,16 +291,14 @@ uint32_t *arm_syscall(uint32_t *regs) case SYS_switch_context: { DEBUGASSERT(regs[REG_R1] != 0 && regs[REG_R2] != 0); - arm_savefpu(regs); - arm_restorefpu((uint32_t *)regs[REG_R2]); *(uint32_t **)regs[REG_R1] = regs; - regs = (uint32_t *)regs[REG_R2]; + CURRENT_REGS = (uint32_t *)regs[REG_R2]; } break; /* R0=SYS_task_start: This a user task start * - * void up_task_start(main_t taskentry, int argc, FAR char *argv[]) + * void up_task_start(main_t taskentry, int argc, char *argv[]) * noreturn_function; * * At this point, the following values are saved in context: @@ -365,7 +369,7 @@ uint32_t *arm_syscall(uint32_t *regs) /* R0=SYS_signal_handler: This a user signal handler callback * * void signal_handler(_sa_sigaction_t sighand, int signo, - * FAR siginfo_t *info, FAR void *ucontext); + * siginfo_t *info, void *ucontext); * * At this point, the following values are saved in context: * @@ -378,7 +382,7 @@ uint32_t *arm_syscall(uint32_t *regs) case SYS_signal_handler: { - FAR struct tcb_s *rtcb = nxsched_self(); + struct tcb_s *rtcb = nxsched_self(); /* Remember the caller's return address */ @@ -415,7 +419,7 @@ uint32_t *arm_syscall(uint32_t *regs) DEBUGASSERT(rtcb->xcp.kstkptr == NULL && rtcb->xcp.ustkptr != NULL); - rtcb->xcp.kstkptr = (FAR uint32_t *)regs[REG_SP]; + rtcb->xcp.kstkptr = (uint32_t *)regs[REG_SP]; regs[REG_SP] = (uint32_t)rtcb->xcp.ustkptr; } #endif @@ -435,7 +439,7 @@ uint32_t *arm_syscall(uint32_t *regs) case SYS_signal_handler_return: { - FAR struct tcb_s *rtcb = nxsched_self(); + struct tcb_s *rtcb = nxsched_self(); /* Set up to return to the kernel-mode signal dispatching logic. */ @@ -473,7 +477,7 @@ uint32_t *arm_syscall(uint32_t *regs) default: { #ifdef CONFIG_LIB_SYSCALL - FAR struct tcb_s *rtcb = nxsched_self(); + struct tcb_s *rtcb = nxsched_self(); int index = rtcb->xcp.nsyscalls; /* Verify that the SYS call number is within range */ @@ -513,7 +517,7 @@ uint32_t *arm_syscall(uint32_t *regs) if (index == 0 && rtcb->xcp.kstack != NULL) { - rtcb->xcp.ustkptr = (FAR uint32_t *)regs[REG_SP]; + rtcb->xcp.ustkptr = (uint32_t *)regs[REG_SP]; regs[REG_SP] = (uint32_t)rtcb->xcp.kstack + ARCH_KERNEL_STACKSIZE; } @@ -529,10 +533,18 @@ uint32_t *arm_syscall(uint32_t *regs) break; } + regs = (uint32_t *)CURRENT_REGS; + /* Report what happened */ dump_syscall("Exit", cmd, regs); + /* Set CURRENT_REGS to NULL to indicate that we are no longer in an + * interrupt handler. + */ + + CURRENT_REGS = NULL; + /* Return the last value of curent_regs. This supports context switches * on return from the exception. That capability is only used with the * SYS_context_switch system call. diff --git a/arch/arm/src/armv7-r/arm_tcbinfo.c b/arch/arm/src/armv7-r/arm_tcbinfo.c index b8d8a438a7345..72b1f895e6fc3 100644 --- a/arch/arm/src/armv7-r/arm_tcbinfo.c +++ b/arch/arm/src/armv7-r/arm_tcbinfo.c @@ -102,11 +102,13 @@ static const uint16_t g_reg_offs[] = const struct tcbinfo_s g_tcbinfo = { - TCB_PID_OFF, - TCB_STATE_OFF, - TCB_PRI_OFF, - TCB_NAME_OFF, - XCPTCONTEXT_REGS, + .pid_off = TCB_PID_OFF, + .state_off = TCB_STATE_OFF, + .pri_off = TCB_PRI_OFF, + .name_off = TCB_NAME_OFF, + .regs_off = TCB_REGS_OFF, + .basic_num = 17, + .total_num = XCPTCONTEXT_REGS, { .p = g_reg_offs, }, diff --git a/arch/arm/src/armv7-r/arm_vectors.S b/arch/arm/src/armv7-r/arm_vectors.S index 68e47faa13fab..6939900ad670a 100644 --- a/arch/arm/src/armv7-r/arm_vectors.S +++ b/arch/arm/src/armv7-r/arm_vectors.S @@ -42,6 +42,66 @@ * Assembly Macros ****************************************************************************/ +/**************************************************************************** + * Name: savefpu + * + * Description: + * Save the state of the floating point registers. + * + ****************************************************************************/ + +#ifdef CONFIG_ARCH_FPU + .macro savefpu, out, tmp + /* Store all floating point registers. Registers are stored in numeric order, + * s0, s1, ... in increasing address order. + */ + +#ifdef CONFIG_ARM_DPFPU32 + vstmia.64 \out!, {d0-d15} /* Save the full FP context */ + vstmia.64 \out!, {d16-d31} +#else + vstmia \out!, {s0-s31} /* Save the full FP context */ +#endif + + /* Store the floating point control and status register. At the end of the + * vstmia, r1 will point to the FPSCR storage location. + */ + + vmrs \tmp, fpscr /* Fetch the FPSCR */ + str \tmp, [\out], #4 /* Save the floating point control and status register */ + .endm +#endif + +/**************************************************************************** + * Name: restorefpu + * + * Description: + * Restore the state of the floating point registers. + * + ****************************************************************************/ + +#ifdef CONFIG_ARCH_FPU + .macro restorefpu, in, tmp + /* Load all floating point registers. Registers are loaded in numeric order, + * s0, s1, ... in increasing address order. + */ + +#ifdef CONFIG_ARM_DPFPU32 + vldmia.64 \in!, {d0-d15} /* Restore the full FP context */ + vldmia.64 \in!, {d16-d31} +#else + vldmia \in!, {s0-s31} /* Restore the full FP context */ +#endif + + /* Load the floating point control and status register. At the end of the + * vstmia, \in will point to the FPSCR storage location. + */ + + ldr \tmp, [\in], #4 /* Fetch the floating point control and status register */ + vmsr fpscr, \tmp /* Restore the FPSCR */ + .endm +#endif + /**************************************************************************** * Private Functions ****************************************************************************/ @@ -65,16 +125,13 @@ .type arm_vectorirq, %function arm_vectorirq: - /* On entry, we are in IRQ mode. We are free to use the IRQ mode r13 - * and r14. - */ + /* Switch to SYS mode */ #ifdef CONFIG_ARMV7A_DECODEFIQ - mov r13, #(PSR_MODE_SYS | PSR_I_BIT | PSR_F_BIT) + cpsid if, #PSR_MODE_SYS #else - mov r13, #(PSR_MODE_SYS | PSR_I_BIT) + cpsid i, #PSR_MODE_SYS #endif - msr cpsr_c, r13 /* Switch to SYS mode */ /* Create a context structure. First set aside a stack frame * and store r0-r12 into the frame. @@ -83,26 +140,14 @@ arm_vectorirq: sub sp, sp, #XCPTCONTEXT_SIZE stmia sp, {r0-r12} /* Save the SYS mode regs */ -#ifdef CONFIG_ARMV7A_DECODEFIQ - mov r0, #(PSR_MODE_IRQ | PSR_I_BIT | PSR_F_BIT) -#else - mov r0, #(PSR_MODE_IRQ | PSR_I_BIT) -#endif - msr cpsr_c, r0 /* Switch back IRQ mode */ + cps #PSR_MODE_IRQ /* Switch back IRQ mode */ /* Get the values for r15(pc) and CPSR in r3 and r4 */ sub r3, lr, #4 mrs r4, spsr - /* Then switch back to SYS mode */ - -#ifdef CONFIG_ARMV7A_DECODEFIQ - orr r0, r0, #(PSR_MODE_SYS | PSR_I_BIT | PSR_F_BIT) -#else - orr r0, r0, #(PSR_MODE_SYS | PSR_I_BIT) -#endif - msr cpsr_c, r0 + cps #PSR_MODE_SYS /* Then switch back to SYS mode */ /* Get the correct values of USR/SYS r13(sp) and r14(lr) in r1 and r2 */ @@ -114,6 +159,13 @@ arm_vectorirq: add r0, sp, #(4*REG_SP) /* Offset to pc, cpsr storage */ stmia r0, {r1-r4} +#ifdef CONFIG_ARCH_FPU + /* Save the state of the floating point registers. */ + + add r0, sp, #(4*REG_S0) /* R1=Address of FP register storage */ + savefpu r0, r1 +#endif + /* Then call the IRQ handler with interrupts disabled. */ mov fp, #0 /* Init frame pointer */ @@ -150,20 +202,35 @@ arm_vectorirq: mov sp, r4 /* Restore the possibly unaligned stack pointer */ #endif +#ifdef CONFIG_ARCH_FPU + /* Restore the state of the floating point registers. */ + + add r1, r0, #(4*REG_S0) /* R1=Address of FP register storage */ + restorefpu r1, r2 +#endif + + /* Switch back IRQ mode and return with shadow SPSR */ + + cps #PSR_MODE_IRQ + /* Upon return from arm_decodeirq, r0 holds the pointer to the register * state save area to use to restore the registers. This may or may not * be the same value that was passed to arm_decodeirq: It will differ if a * context switch is required. */ - /* Restore the CPSR, SYS mode registers and return */ + /* Restore the CPSR, IRQ mode registers and return */ ldr r1, [r0, #(4*REG_CPSR)] /* Fetch the return SPSR */ msr spsr_cxsf, r1 /* Set the return mode SPSR */ - /* Life is simple when everything is SYS mode */ + /* Life is simple when everything is IRQ mode */ - ldmia r0, {r0-r15}^ /* Return */ + mov r14, r0 /* (IRQ) r14=Register storage area */ + ldmia r14!, {r0-r12} /* Restore common r0-r12 */ + ldmia r14, {r13, r14}^ /* Restore user mode r13/r14 */ + add r14, r14, #(4*2) /* (IRQ) r14=address of r15 storage */ + ldmia r14, {r15}^ /* Return */ #if CONFIG_ARCH_INTERRUPTSTACK > 7 .Lirqstacktop: @@ -186,13 +253,13 @@ arm_vectorirq: .type arm_vectorsvc, %function arm_vectorsvc: + /* Switch to SYS mode */ #ifdef CONFIG_ARMV7A_DECODEFIQ - mov r13, #(PSR_MODE_SYS | PSR_I_BIT | PSR_F_BIT) + cpsid if, #PSR_MODE_SYS #else - mov r13, #(PSR_MODE_SYS | PSR_I_BIT) + cpsid i, #PSR_MODE_SYS #endif - msr cpsr_c, r13 /* Switch to SYS mode */ /* Create a context structure. First set aside a stack frame * and store r0-r12 into the frame. @@ -201,24 +268,14 @@ arm_vectorsvc: sub sp, sp, #XCPTCONTEXT_SIZE stmia sp, {r0-r12} /* Save the SYS mode regs */ -#ifdef CONFIG_ARMV7A_DECODEFIQ - mov r0, #(PSR_MODE_SVC | PSR_I_BIT | PSR_F_BIT) -#else - mov r0, #(PSR_MODE_SVC | PSR_I_BIT) -#endif - msr cpsr_c, r0 /* Switch back SVC mode */ + cps #PSR_MODE_SVC /* Switch back SVC mode */ /* Get the values for r15(pc) and CPSR in r3 and r4 */ mov r3, r14 /* Save r14 as the PC as well */ mrs r4, spsr /* Get the saved CPSR */ -#ifdef CONFIG_ARMV7A_DECODEFIQ - orr r0, r0, #(PSR_MODE_SYS | PSR_I_BIT | PSR_F_BIT) -#else - orr r0, r0, #(PSR_MODE_SYS | PSR_I_BIT) -#endif - msr cpsr_c, r0 + cps #PSR_MODE_SYS /* Then switch back to SYS mode */ /* Get the correct values of USR/SYS r13(sp) and r14(lr) in r1 and r2 */ @@ -230,6 +287,13 @@ arm_vectorsvc: add r0, sp, #(4*REG_SP) /* Offset to pc, cpsr storage */ stmia r0, {r1-r4} +#ifdef CONFIG_ARCH_FPU + /* Save the state of the floating point registers. */ + + add r0, sp, #(4*REG_S0) /* R1=Address of FP register storage */ + savefpu r0, r1 +#endif + /* Then call the SVC handler with interrupts disabled. * void arm_syscall(struct xcptcontext *xcp) */ @@ -268,6 +332,17 @@ arm_vectorsvc: mov sp, r4 /* Restore the possibly unaligned stack pointer */ #endif +#ifdef CONFIG_ARCH_FPU + /* Restore the state of the floating point registers. */ + + add r1, r0, #(4*REG_S0) /* R1=Address of FP register storage */ + restorefpu r1, r2 +#endif + + /* Switch back SVC mode and return with shadow SPSR */ + + cps #PSR_MODE_SVC + /* Upon return from arm_syscall, r0 holds the pointer to the register * state save area to use to restore the registers. This may or may not * be the same value that was passed to arm_syscall: It will differ if a @@ -279,9 +354,13 @@ arm_vectorsvc: ldr r1, [r0, #(4*REG_CPSR)] /* Fetch the return SPSR */ msr spsr_cxsf, r1 /* Set the return mode SPSR */ - /* Life is simple when everything is SYS mode */ + /* Life is simple when everything is SVC mode */ - ldmia r0, {r0-r15}^ /* Return */ + mov r14, r0 /* (SVC) r14=Register storage area */ + ldmia r14!, {r0-r12} /* Restore common r0-r12 */ + ldmia r14, {r13, r14}^ /* Restore user mode r13/r14 */ + add r14, r14, #(4*2) /* (SVC) r14=address of r15 storage */ + ldmia r14, {r15}^ /* Return */ .size arm_vectorsvc, . - arm_vectorsvc .align 5 @@ -302,16 +381,13 @@ arm_vectorsvc: .type arm_vectordata, %function arm_vectordata: - /* On entry we are free to use the ABORT mode registers - * r13 and r14 - */ + /* Switch to SYS mode */ #ifdef CONFIG_ARMV7A_DECODEFIQ - mov r13, #(PSR_MODE_SYS | PSR_I_BIT | PSR_F_BIT) + cpsid if, #PSR_MODE_SYS #else - mov r13, #(PSR_MODE_SYS | PSR_I_BIT) + cpsid i, #PSR_MODE_SYS #endif - msr cpsr_c, r13 /* Switch to SYS mode */ /* Create a context structure. First set aside a stack frame * and store r0-r12 into the frame. @@ -320,26 +396,14 @@ arm_vectordata: sub sp, sp, #XCPTCONTEXT_SIZE stmia sp, {r0-r12} /* Save the SYS mode regs */ -#ifdef CONFIG_ARMV7A_DECODEFIQ - mov r0, #(PSR_MODE_ABT | PSR_I_BIT | PSR_F_BIT) -#else - mov r0, #(PSR_MODE_ABT | PSR_I_BIT) -#endif - msr cpsr_c, r0 /* Switch back ABT mode */ + cps #PSR_MODE_ABT /* Switch back ABT mode */ /* Get the values for r15(pc) and CPSR in r3 and r4 */ sub r3, lr, #8 mrs r4, spsr - /* Then switch back to SYS mode */ - -#ifdef CONFIG_ARMV7A_DECODEFIQ - mov r0, #(PSR_MODE_SYS | PSR_I_BIT | PSR_F_BIT) -#else - mov r0, #(PSR_MODE_SYS | PSR_I_BIT) -#endif - msr cpsr_c, r0 + cps #PSR_MODE_SYS /* Then switch back to SYS mode */ /* Get the correct values of USR/SYS r13(sp) and r14(lr) in r1 and r2 */ @@ -351,6 +415,13 @@ arm_vectordata: add r0, sp, #(4*REG_SP) /* Offset to pc, cpsr storage */ stmia r0, {r1-r4} +#ifdef CONFIG_ARCH_FPU + /* Save the state of the floating point registers. */ + + add r0, sp, #(4*REG_S0) /* R1=Address of FP register storage */ + savefpu r0, r1 +#endif + /* Then call the data abort handler with interrupts disabled. * void arm_dataabort(struct xcptcontext *xcp) */ @@ -364,20 +435,35 @@ arm_vectordata: bl arm_dataabort /* Call the handler */ mov sp, r4 /* Restore the possibly unaligned stack pointer */ +#ifdef CONFIG_ARCH_FPU + /* Restore the state of the floating point registers. */ + + add r1, r0, #(4*REG_S0) /* R1=Address of FP register storage */ + restorefpu r1, r2 +#endif + + /* Switch back ABT mode and return with shadow SPSR */ + + cps #PSR_MODE_ABT + /* Upon return from arm_dataabort, r0 holds the pointer to the register * state save area to use to restore the registers. This may or may not * be the same value that was passed to arm_dataabort: It will differ if a * context switch is required. */ - /* Restore the CPSR, SYS mode registers and return */ + /* Restore the CPSR, ABT mode registers and return */ ldr r1, [r0, #(4*REG_CPSR)] /* Fetch the return SPSR */ msr spsr_cxsf, r1 /* Set the return mode SPSR */ - /* Life is simple when everything is SYS mode */ + /* Life is simple when everything is ABT mode */ - ldmia r0, {r0-r15}^ /* Return */ + mov r14, r0 /* (ABT) r14=Register storage area */ + ldmia r14!, {r0-r12} /* Restore common r0-r12 */ + ldmia r14, {r13, r14}^ /* Restore user mode r13/r14 */ + add r14, r14, #(4*2) /* (ABT) r14=address of r15 storage */ + ldmia r14, {r15}^ /* Return */ .size arm_vectordata, . - arm_vectordata .align 5 @@ -398,12 +484,7 @@ arm_vectordata: .type arm_vectorprefetch, %function arm_vectorprefetch: - /* On entry we are free to use the ABORT mode registers - * r13 and r14 - */ - - mov r13, #(PSR_MODE_SYS | PSR_I_BIT | PSR_F_BIT) - msr cpsr_c, r13 /* Switch to SYS mode */ + cpsid if, #PSR_MODE_SYS /* Switch to SYS mode */ /* Create a context structure. First set aside a stack frame * and store r0-r12 into the frame. @@ -412,18 +493,14 @@ arm_vectorprefetch: sub sp, sp, #XCPTCONTEXT_SIZE stmia sp, {r0-r12} /* Save the SYS mode regs */ - mov r0, #(PSR_MODE_ABT | PSR_I_BIT | PSR_F_BIT) - msr cpsr_c, r0 /* Switch back ABT mode */ + cps #PSR_MODE_ABT /* Switch back ABT mode */ /* Get the values for r15(pc) and CPSR in r3 and r4 */ sub r3, lr, #4 mrs r4, spsr - /* Then switch back to SYS mode */ - - mov r0, #(PSR_MODE_SYS | PSR_I_BIT | PSR_F_BIT) - msr cpsr_c, r0 + cps #PSR_MODE_SYS /* Then switch back to SYS mode */ /* Get the correct values of USR/SYS r13(sp) and r14(lr) in r1 and r2 */ @@ -435,6 +512,13 @@ arm_vectorprefetch: add r0, sp, #(4*REG_SP) /* Offset to pc, cpsr storage */ stmia r0, {r1-r4} +#ifdef CONFIG_ARCH_FPU + /* Save the state of the floating point registers. */ + + add r0, sp, #(4*REG_S0) /* R1=Address of FP register storage */ + savefpu r0, r1 +#endif + /* Then call the prefetch abort handler with interrupts disabled. * void arm_prefetchabort(struct xcptcontext *xcp) */ @@ -448,20 +532,35 @@ arm_vectorprefetch: bl arm_prefetchabort /* Call the handler */ mov sp, r4 /* Restore the possibly unaligned stack pointer */ +#ifdef CONFIG_ARCH_FPU + /* Restore the state of the floating point registers. */ + + add r1, r0, #(4*REG_S0) /* R1=Address of FP register storage */ + restorefpu r1, r2 +#endif + + /* Switch back ABT mode and return with shadow SPSR */ + + cps #PSR_MODE_ABT + /* Upon return from arm_prefetchabort, r0 holds the pointer to the register * state save area to use to restore the registers. This may or may not * be the same value that was passed to arm_prefetchabort: It will differ if a * context switch is required. */ - /* Restore the CPSR, SYS mode registers and return */ + /* Restore the CPSR, ABT mode registers and return */ ldr r1, [r0, #(4*REG_CPSR)] /* Fetch the return SPSR */ msr spsr_cxsf, r1 /* Set the return mode SPSR */ - /* Life is simple when everything is SYS mode */ + /* Life is simple when everything is ABT mode */ - ldmia r0, {r0-r15}^ /* Return */ + mov r14, r0 /* (ABT) r14=Register storage area */ + ldmia r14!, {r0-r12} /* Restore common r0-r12 */ + ldmia r14, {r13, r14}^ /* Restore user mode r13/r14 */ + add r14, r14, #(4*2) /* (ABT) r14=address of r15 storage */ + ldmia r14, {r15}^ /* Return */ .size arm_vectorprefetch, . - arm_vectorprefetch .align 5 @@ -480,12 +579,7 @@ arm_vectorprefetch: .type arm_vectorundefinsn, %function arm_vectorundefinsn: - /* On entry we are free to use the UND mode registers - * r13 and r14 - */ - - mov r13, #(PSR_MODE_SYS | PSR_I_BIT | PSR_F_BIT) - msr cpsr_c, r13 /* Switch to SYS mode */ + cpsid if, #PSR_MODE_SYS /* Switch to SYS mode */ /* Create a context structure. First set aside a stack frame * and store r0-r12 into the frame. @@ -494,18 +588,14 @@ arm_vectorundefinsn: sub sp, sp, #XCPTCONTEXT_SIZE stmia sp, {r0-r12} /* Save the SYS mode regs */ - mov r0, #(PSR_MODE_UND | PSR_I_BIT | PSR_F_BIT) - msr cpsr_c, r0 /* Switch back UND mode */ + cps #PSR_MODE_UND /* Switch back UND mode */ /* Get the values for r15(pc) and CPSR in r3 and r4 */ mov r3, lr mrs r4, spsr - /* Then switch back to SYS mode */ - - mov r0, #(PSR_MODE_SYS | PSR_I_BIT | PSR_F_BIT) - msr cpsr_c, r0 + cps #PSR_MODE_SYS /* Then switch back to SYS mode */ /* Get the correct values of USR/SYS r13(sp) and r14(lr) in r1 and r2 */ @@ -517,6 +607,13 @@ arm_vectorundefinsn: add r0, sp, #(4*REG_SP) /* Offset to pc, cpsr storage */ stmia r0, {r1-r4} +#ifdef CONFIG_ARCH_FPU + /* Save the state of the floating point registers. */ + + add r0, sp, #(4*REG_S0) /* R1=Address of FP register storage */ + savefpu r0, r1 +#endif + /* Then call the undef insn handler with interrupts disabled. * void arm_undefinedinsn(struct xcptcontext *xcp) */ @@ -528,20 +625,35 @@ arm_vectorundefinsn: bl arm_undefinedinsn /* Call the handler */ mov sp, r4 /* Restore the possibly unaligned stack pointer */ +#ifdef CONFIG_ARCH_FPU + /* Restore the state of the floating point registers. */ + + add r1, r0, #(4*REG_S0) /* R1=Address of FP register storage */ + restorefpu r1, r2 +#endif + + /* Switch back UND mode and return with shadow SPSR */ + + cps #PSR_MODE_UND + /* Upon return from arm_undefinedinsn, r0 holds the pointer to the register * state save area to use to restore the registers. This may or may not * be the same value that was passed to arm_undefinedinsn: It will differ if a * context switch is required. */ - /* Restore the CPSR, SYS mode registers and return */ + /* Restore the CPSR, UND mode registers and return */ ldr r1, [r0, #(4*REG_CPSR)] /* Fetch the return SPSR */ msr spsr_cxsf, r1 /* Set the return mode SPSR */ - /* Life is simple when everything is SYS mode */ + /* Life is simple when everything is UND mode */ - ldmia r0, {r0-r15}^ /* Return */ + mov r14, r0 /* (UND) r14=Register storage area */ + ldmia r14!, {r0-r12} /* Restore common r0-r12 */ + ldmia r14, {r13, r14}^ /* Restore user mode r13/r14 */ + add r14, r14, #(4*2) /* (UND) r14=address of r15 storage */ + ldmia r14, {r15}^ /* Return */ .size arm_vectorundefinsn, . - arm_vectorundefinsn .align 5 @@ -563,10 +675,7 @@ arm_vectorundefinsn: arm_vectorfiq: #ifdef CONFIG_ARMV7R_DECODEFIQ - /* On entry we are free to use the FIQ mode registers r8 through r14 */ - - mov r13, #(PSR_MODE_SYS | PSR_I_BIT | PSR_F_BIT) - msr cpsr_c, r13 /* Switch to SYS mode */ + cpsid if, #PSR_MODE_SYS /* Switch to SYS mode */ /* Create a context structure. First set aside a stack frame * and store r0-r12 into the frame. @@ -575,18 +684,14 @@ arm_vectorfiq: sub sp, sp, #XCPTCONTEXT_SIZE stmia sp, {r0-r12} /* Save the SYS mode regs */ - mov r0, #(PSR_MODE_FIQ | PSR_I_BIT | PSR_F_BIT) - msr cpsr_c, r0 /* Switch back FIQ mode */ + cps #PSR_MODE_FIQ /* Switch back FIQ mode */ /* Get the values for r15(pc) and CPSR in r3 and r4 */ sub r3, lr, #4 mrs r4, spsr - /* Then switch back to SYS mode */ - - mov r0, #(PSR_MODE_SYS | PSR_I_BIT | PSR_F_BIT) - msr cpsr_c, r0 + cps #PSR_MODE_SYS /* Then switch back to SYS mode */ /* Get the correct values of USR/SYS r13(sp) and r14(lr) in r1 and r2 */ @@ -598,6 +703,13 @@ arm_vectorfiq: add r0, sp, #(4*REG_SP) /* Offset to pc, cpsr storage */ stmia r0, {r1-r4} +#ifdef CONFIG_ARCH_FPU + /* Save the state of the floating point registers. */ + + add r0, sp, #(4*REG_S0) /* R1=Address of FP register storage */ + savefpu r0, r1 +#endif + /* Then call the FIQ handler with interrupts disabled. */ mov fp, #0 /* Init frame pointer */ @@ -621,20 +733,35 @@ arm_vectorfiq: mov sp, r4 /* Restore the possibly unaligned stack pointer */ #endif +#ifdef CONFIG_ARCH_FPU + /* Restore the state of the floating point registers. */ + + add r1, r0, #(4*REG_S0) /* R1=Address of FP register storage */ + restorefpu r1, r2 +#endif + + /* Switch back FIQ mode and return with shadow SPSR */ + + cps #PSR_MODE_FIQ + /* Upon return from arm_decodefiq, r0 holds the pointer to the register * state save area to use to restore the registers. This may or may not * be the same value that was passed to arm_decodefiq: It will differ if a * context switch is required. */ - /* Restore the CPSR, SYS mode registers and return */ + /* Restore the CPSR, FIQ mode registers and return */ ldr r1, [r0, #(4*REG_CPSR)] /* Fetch the return SPSR */ msr spsr_cxsf, r1 /* Set the return mode SPSR */ - /* Life is simple when everything is SYS mode */ + /* Life is simple when everything is FIQ mode */ - ldmia r0, {r0-r15}^ /* Return */ + mov r14, r0 /* (FIQ) r14=Register storage area */ + ldmia r14!, {r0-r7} /* Restore common r0-r7 */ + ldmia r14, {r8-r14}^ /* Restore user mode r8-r14 */ + add r14, r14, #(4*7) /* (FIQ) r14=address of r15 storage */ + ldmia r14, {r15}^ /* Return */ #if CONFIG_ARCH_INTERRUPTSTACK > 7 .Lfiqstacktop: diff --git a/arch/arm/src/armv7-r/cp15_clean_dcache_all.S b/arch/arm/src/armv7-r/cp15_clean_dcache_all.S index c3c199fb10768..4a08dfbc70fbd 100644 --- a/arch/arm/src/armv7-r/cp15_clean_dcache_all.S +++ b/arch/arm/src/armv7-r/cp15_clean_dcache_all.S @@ -99,7 +99,7 @@ cp15_clean_dcache_all: and r0, r3, r1, lsr #13 /* r0=NumSets (number of sets - 1) */ ldr r3,=0x7 /* Isolate the LineSize field (bits 0-2) */ - and r5, r3 /* r4=(Log2LineSize - 2) in word */ + and r5, r3, r1 /* r4=(Log2LineSize - 2) in word */ add r5, #4 /* r4=Set/way operation line shfit */ ldr r3, =0x3ff /* Isolate the way field (bits 3-12) */ diff --git a/arch/arm/src/armv7-r/cp15_flush_dcache_all.S b/arch/arm/src/armv7-r/cp15_flush_dcache_all.S index 0ae8cfe6c856c..747d12271da31 100644 --- a/arch/arm/src/armv7-r/cp15_flush_dcache_all.S +++ b/arch/arm/src/armv7-r/cp15_flush_dcache_all.S @@ -99,7 +99,7 @@ cp15_flush_dcache_all: and r0, r3, r1, lsr #13 /* r0=NumSets (number of sets - 1) */ ldr r3,=0x7 /* Isolate the LineSize field (bits 0-2) */ - and r5, r3 /* r4=(Log2LineSize - 2) in word */ + and r5, r3, r1 /* r4=(Log2LineSize - 2) in word */ add r5, #4 /* r4=Set/way operation line shfit */ ldr r3, =0x3ff /* Isolate the way field (bits 3-12) */ diff --git a/arch/arm/src/armv7-r/cp15_invalidate_dcache_all.S b/arch/arm/src/armv7-r/cp15_invalidate_dcache_all.S index d1836a8c03540..399e8cf8e2cae 100644 --- a/arch/arm/src/armv7-r/cp15_invalidate_dcache_all.S +++ b/arch/arm/src/armv7-r/cp15_invalidate_dcache_all.S @@ -99,7 +99,7 @@ cp15_invalidate_dcache_all: and r0, r3, r1, lsr #13 /* r0=NumSets (number of sets - 1) */ ldr r3,=0x7 /* Isolate the LineSize field (bits 0-2) */ - and r5, r3 /* r4=(Log2LineSize - 2) in word */ + and r5, r3, r1 /* r4=(Log2LineSize - 2) in word */ add r5, #4 /* r4=Set/way operation line shfit */ ldr r3, =0x3ff /* Isolate the way field (bits 3-12) */ diff --git a/arch/arm/src/armv7-r/gic.h b/arch/arm/src/armv7-r/gic.h index 17c0fd0cd400e..6ed485bf0ff40 100644 --- a/arch/arm/src/armv7-r/gic.h +++ b/arch/arm/src/armv7-r/gic.h @@ -633,7 +633,7 @@ int arm_cpu_sgi(int sgi, unsigned int cpuset); ****************************************************************************/ #ifdef CONFIG_SMP -int arm_start_handler(int irq, FAR void *context, FAR void *arg); +int arm_start_handler(int irq, void *context, void *arg); #endif /**************************************************************************** @@ -657,7 +657,7 @@ int arm_start_handler(int irq, FAR void *context, FAR void *arg); ****************************************************************************/ #ifdef CONFIG_SMP -int arm_pause_handler(int irq, FAR void *context, FAR void *arg); +int arm_pause_handler(int irq, void *context, void *arg); #endif #undef EXTERN diff --git a/arch/arm/src/armv7-r/vfork.S b/arch/arm/src/armv7-r/vfork.S deleted file mode 100644 index 670fdb30dedba..0000000000000 --- a/arch/arm/src/armv7-r/vfork.S +++ /dev/null @@ -1,124 +0,0 @@ -/**************************************************************************** - * arch/arm/src/armv7-r/vfork.S - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. The - * ASF licenses this file to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance with the - * License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - ****************************************************************************/ - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include - -#include "arm_vfork.h" - -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -/**************************************************************************** - * Public Symbols - ****************************************************************************/ - - .file "vfork.S" - .globl up_vfork - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: vfork - * - * Description: - * The vfork() function has the same effect as fork(), except that the - * behavior is undefined if the process created by vfork() either modifies - * any data other than a variable of type pid_t used to store the return - * value from vfork(), or returns from the function in which vfork() was - * called, or calls any other function before successfully calling _exit() - * or one of the exec family of functions. - * - * This thin layer implements vfork by simply calling up_vfork() with the - * vfork() context as an argument. The overall sequence is: - * - * 1) User code calls vfork(). vfork() collects context information and - * transfers control up up_vfork(). - * 2) up_vfork() and calls nxtask_setup_vfork(). - * 3) nxtask_setup_vfork() allocates and configures the child task's TCB. - * This consists of: - * - Allocation of the child task's TCB. - * - Initialization of file descriptors and streams - * - Configuration of environment variables - * - Allocate and initialize the stack - * - Setup the input parameters for the task. - * - Initialization of the TCB (including call to up_initial_state()) - * 4) up_vfork() provides any additional operating context. up_vfork must: - * - Initialize special values in any CPU registers that were not - * already configured by up_initial_state() - * 5) up_vfork() then calls nxtask_start_vfork() - * 6) nxtask_start_vfork() then executes the child thread. - * - * Input Parameters: - * None - * - * Returned Value: - * Upon successful completion, vfork() returns 0 to the child process and - * returns the process ID of the child process to the parent process. - * Otherwise, -1 is returned to the parent, no child process is created, - * and errno is set to indicate the error. - * - ****************************************************************************/ - - .globl vfork - .type vfork, function -vfork: - /* Create a stack frame */ - - mov r0, sp /* Save the value of the stack on entry */ - sub sp, sp, #VFORK_SIZEOF /* Allocate the structure on the stack */ - - /* CPU registers */ - /* Save the volatile registers */ - - str r4, [sp, #VFORK_R4_OFFSET] - str r5, [sp, #VFORK_R5_OFFSET] - str r6, [sp, #VFORK_R6_OFFSET] - str r7, [sp, #VFORK_R7_OFFSET] - str r8, [sp, #VFORK_R8_OFFSET] - str r9, [sp, #VFORK_R9_OFFSET] - str r10, [sp, #VFORK_R10_OFFSET] - - /* Save the frame pointer, stack pointer, and return address */ - - str fp, [sp, #VFORK_FP_OFFSET] - str r0, [sp, #VFORK_SP_OFFSET] - str lr, [sp, #VFORK_LR_OFFSET] - - /* Floating point registers (not yet) */ - - /* Then, call up_vfork(), passing it a pointer to the stack structure */ - - mov r0, sp - bl up_vfork - - /* Release the stack data and return the value returned by up_vfork */ - - ldr lr, [sp, #VFORK_LR_OFFSET] - add sp, sp, #VFORK_SIZEOF - bx lr - .size vfork, .-vfork - .end diff --git a/arch/arm/src/armv8-m/Kconfig b/arch/arm/src/armv8-m/Kconfig index c868c59de9324..82ba9d60d4044 100644 --- a/arch/arm/src/armv8-m/Kconfig +++ b/arch/arm/src/armv8-m/Kconfig @@ -13,40 +13,6 @@ config ARMV8M_HAVE_DCACHE bool default n -config ARMV8M_LAZYFPU - bool "Lazy FPU storage" - default n - depends on ARCH_HAVE_LAZYFPU - ---help--- - There are two forms of the common vector logic. There are pros and - cons to each option: - - 1) The standard common vector logic exploits features of the ARMv8-M - architecture to save the all of floating registers on entry into - each interrupt and then to restore the floating registers when - the interrupt returns. The primary advantage to this approach is - that floating point operations are available in interrupt - handling logic. Since the volatile registers are preserved, - operations on the floating point registers by interrupt handling - logic has no ill effect. The downside is, of course, that more - stack operations are required on each interrupt to save and store - the floating point registers. Because of the some special - features of the ARMv-M, this is not as much overhead as you might - expect, but overhead nonetheless. - - 2) The lazy FPU common vector logic does not save or restore - floating point registers on entry and exit from the interrupt - handler. Rather, the floating point registers are not restored - until it is absolutely necessary to do so when a context switch - occurs and the interrupt handler will be returning to a different - floating point context. Since floating point registers are not - protected, floating point operations must not be performed in - interrupt handling logic. Better interrupt performance is be - expected, however. - - By default, the "standard" common vector logic is build. This - option selects the alternate lazy FPU common vector logic. - config ARMV8M_USEBASEPRI bool "Use BASEPRI Register" default y if ARCH_HIPRI_INTERRUPT @@ -103,41 +69,23 @@ config ARMV8M_DTCM choice prompt "Toolchain Selection" - default ARMV8M_TOOLCHAIN_GNU_EABIW if TOOLCHAIN_WINDOWS - default ARMV8M_TOOLCHAIN_GNU_EABIL if !TOOLCHAIN_WINDOWS + default ARMV8M_TOOLCHAIN_GNU_EABI config ARMV8M_TOOLCHAIN_BUILDROOT bool "Buildroot (Cygwin or Linux)" depends on !WINDOWS_NATIVE select ARCH_TOOLCHAIN_GNU -config ARMV8M_TOOLCHAIN_GNU_EABIL - bool "Generic GNU EABI toolchain under Linux (or other POSIX environment)" - depends on !WINDOWS_NATIVE +config ARMV8M_TOOLCHAIN_GNU_EABI + bool "Generic GNU EABI toolchain" select ARCH_TOOLCHAIN_GNU ---help--- This option should work for any modern GNU toolchain (GCC 4.5 or newer) configured for arm-none-eabi. -config ARMV8M_TOOLCHAIN_GNU_EABIW - bool "Generic GNU EABI toolchain under Windows" - depends on TOOLCHAIN_WINDOWS - select CYGWIN_WINTOOL if WINDOWS_CYGWIN - select ARCH_TOOLCHAIN_GNU - -config ARMV8M_TOOLCHAIN_CLANGL - bool "Generic Clang toolchain under Linux (or other POSIX environment)" - depends on !WINDOWS_NATIVE - select ARCH_TOOLCHAIN_GNU - -config ARMV8M_TOOLCHAIN_CLANGW - bool "Generic Clang toolchain under Windows" - depends on TOOLCHAIN_WINDOWS - select CYGWIN_WINTOOL if WINDOWS_CYGWIN - select ARCH_TOOLCHAIN_GNU - ---help--- - This option should work for any modern GNU toolchain (GCC 4.5 or newer) - configured for arm-none-eabi. +config ARMV8M_TOOLCHAIN_CLANG + bool "Generic Clang toolchain" + select ARCH_TOOLCHAIN_CLANG endchoice diff --git a/arch/arm/src/armv8-m/Make.defs b/arch/arm/src/armv8-m/Make.defs new file mode 100644 index 0000000000000..b4a0da3bed00f --- /dev/null +++ b/arch/arm/src/armv8-m/Make.defs @@ -0,0 +1,58 @@ +############################################################################ +# arch/arm/src/armv8-m/Make.defs +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. The +# ASF licenses this file to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance with the +# License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +# +############################################################################ + +# Common ARM files + +include common/Make.defs + +CMN_ASRCS += arm_exception.S + +CMN_CSRCS += arm_busfault.c arm_cache.c arm_doirq.c +CMN_CSRCS += arm_hardfault.c arm_initialstate.c arm_itm.c +CMN_CSRCS += arm_memfault.c arm_perf.c arm_sau.c +CMN_CSRCS += arm_schedulesigaction.c arm_securefault.c arm_secure_irq.c +CMN_CSRCS += arm_sigdeliver.c arm_svcall.c +CMN_CSRCS += arm_systemreset.c arm_tcbinfo.c +CMN_CSRCS += arm_trigger_irq.c arm_usagefault.c arm_vectors.c + +ifeq ($(CONFIG_ARMV8M_SYSTICK),y) + CMN_CSRCS += arm_systick.c +endif + +ifeq ($(CONFIG_ARMV8M_ITMSYSLOG),y) + CMN_CSRCS += arm_itm_syslog.c +endif + +ifeq ($(CONFIG_ARMV8M_STACKCHECK),y) + CMN_CSRCS += arm_stackcheck.c +endif + +ifeq ($(CONFIG_ARCH_FPU),y) + CMN_CSRCS += arm_fpuconfig.c + CMN_CSRCS += arm_fpucmp.c +endif + +ifeq ($(CONFIG_ARCH_RAMVECTORS),y) + CMN_CSRCS += arm_ramvec_initialize.c arm_ramvec_attach.c +endif + +ifneq ($(filter y,$(CONFIG_ARM_MPU) $(CONFIG_ARM_MPU_EARLY_RESET)),) + CMN_CSRCS += arm_mpu.c +endif diff --git a/arch/arm/src/armv8-m/Toolchain.defs b/arch/arm/src/armv8-m/Toolchain.defs index eee0ba5b8df07..1302e676e2899 100644 --- a/arch/arm/src/armv8-m/Toolchain.defs +++ b/arch/arm/src/armv8-m/Toolchain.defs @@ -34,25 +34,13 @@ ifeq ($(filter y, \ endif ifeq ($(filter y, \ - $(CONFIG_ARMV8M_TOOLCHAIN_GNU_EABIL) \ + $(CONFIG_ARMV8M_TOOLCHAIN_GNU_EABI) \ ),y) CONFIG_ARMV8M_TOOLCHAIN ?= GNU_EABI endif ifeq ($(filter y, \ - $(CONFIG_ARMV8M_TOOLCHAIN_GNU_EABIW) \ - ),y) - CONFIG_ARMV8M_TOOLCHAIN ?= GNU_EABI -endif - -ifeq ($(filter y, \ - $(CONFIG_ARMV8M_TOOLCHAIN_CLANGL) \ - ),y) - CONFIG_ARMV8M_TOOLCHAIN ?= CLANG -endif - -ifeq ($(filter y, \ - $(CONFIG_ARMV8M_TOOLCHAIN_CLANGW) \ + $(CONFIG_ARMV8M_TOOLCHAIN_CLANG) \ ),y) CONFIG_ARMV8M_TOOLCHAIN ?= CLANG endif @@ -65,23 +53,40 @@ endif # CROSSDEV The GNU toolchain triple (command prefix) # ARCHCPUFLAGS CPU-specific flags selecting the instruction set # FPU options, etc. -# MAXOPTIMIZATION The maximum optimization level that results in +# ARCHOPTIMIZATION The optimization level that results in # reliable code generation. # ifeq ($(CONFIG_DEBUG_CUSTOMOPT),y) - MAXOPTIMIZATION := $(CONFIG_DEBUG_OPTLEVEL) -else - MAXOPTIMIZATION ?= -Os + ARCHOPTIMIZATION += $(CONFIG_DEBUG_OPTLEVEL) +else ifeq ($(CONFIG_DEBUG_FULLOPT),y) + ifeq ($(CONFIG_ARMV6M_TOOLCHAIN),CLANG) + ARCHOPTIMIZATION += -Oz + else + ARCHOPTIMIZATION += -Os + endif +endif + +ifneq ($(CONFIG_DEBUG_NOOPT),y) + ARCHOPTIMIZATION += -fno-strict-aliasing endif ifeq ($(CONFIG_FRAME_POINTER),y) - MAXOPTIMIZATION += -fno-omit-frame-pointer -fno-optimize-sibling-calls + ARCHOPTIMIZATION += -fno-omit-frame-pointer -fno-optimize-sibling-calls else - MAXOPTIMIZATION += -fomit-frame-pointer + ARCHOPTIMIZATION += -fomit-frame-pointer +endif + +ifeq ($(CONFIG_STACK_CANARIES),y) + ARCHOPTIMIZATION += -fstack-protector-all +endif + +ifeq ($(CONFIG_ARMV8M_STACKCHECK),y) + ARCHOPTIMIZATION += -finstrument-functions -ffixed-r10 endif # Parametrization for ARCHCPUFLAGS + ifeq ($(CONFIG_ARCH_CORTEXM23),y) TOOLCHAIN_MTUNE := -mtune=cortex-m23 TOOLCHAIN_MARCH := -march=armv8-m.main @@ -120,6 +125,45 @@ else TOOLCHAIN_MFLOAT += -mfloat-abi=soft endif +# Clang Configuration files + +ifeq ($(CONFIG_ARMV8M_TOOLCHAIN),CLANG) + + ifeq ($(CONFIG_ARCH_CORTEXM23),y) + TOOLCHAIN_MARCH += --config armv8m.main_soft_nofp_nosys + else ifeq ($(CONFIG_ARCH_CORTEXM33),y) + ifeq ($(CONFIG_ARCH_FPU),y) + TOOLCHAIN_MARCH += --config armv8m.main_hard_fp_nosys + else + TOOLCHAIN_MARCH += --config armv8m.main_soft_nofp_nosys + endif + else ifeq ($(CONFIG_ARCH_CORTEXM35P),y) + ifeq ($(CONFIG_ARCH_FPU),y) + TOOLCHAIN_MARCH += --config armv8m.main_hard_fp_nosys + else + TOOLCHAIN_MARCH += --config armv8m.main_soft_nofp_nosys + endif + else ifeq ($(CONFIG_ARCH_CORTEXM55),y) + ifeq ($(CONFIG_ARCH_FPU),y) + TOOLCHAIN_MARCH += --config armv8.1m.main_hard_fp_nosys + else + TOOLCHAIN_MARCH += --config armv8.1m.main_soft_nofp_nomve_nosys + endif + endif + +endif + +# Link Time Optimization + +ifeq ($(CONFIG_LTO_THIN),y) + ARCHOPTIMIZATION += -flto=thin +else ifeq ($(CONFIG_LTO_FULL),y) + ARCHOPTIMIZATION += -flto + ifeq ($(CONFIG_ARMV8M_TOOLCHAIN),GNU_EABI) + ARCHOPTIMIZATION += -fuse-linker-plugin + endif +endif + # NuttX buildroot under Linux or Cygwin ifeq ($(CONFIG_ARMV8M_TOOLCHAIN),BUILDROOT) @@ -146,30 +190,94 @@ endif # Clang toolchain ifeq ($(CONFIG_ARMV8M_TOOLCHAIN),CLANG) - CROSSDEV ?= arm-none-eabi- ARCHCPUFLAGS = $(TOOLCHAIN_MARCH) $(TOOLCHAIN_MTUNE) -mthumb $(TOOLCHAIN_MFLOAT) -endif + + CC = clang + CXX = clang++ + CPP = clang -E -P -x c + LD = ld.lld -m armelf + STRIP = llvm-strip --strip-unneeded + AR = llvm-ar rcs + NM = llvm-nm + OBJCOPY = llvm-objcopy + OBJDUMP = llvm-objdump + + # Since the no_builtin attribute is not fully supported on Clang + # disable the built-in functions, refer: + # https://github.com/apache/incubator-nuttx/pull/5971 + + ARCHOPTIMIZATION += -fno-builtin # Default toolchain -CC = $(CROSSDEV)gcc -CXX = $(CROSSDEV)g++ -CPP = $(CROSSDEV)gcc -E -P -x c -LD = $(CROSSDEV)ld -STRIP = $(CROSSDEV)strip --strip-unneeded -AR = $(CROSSDEV)ar rcs -NM = $(CROSSDEV)nm -OBJCOPY = $(CROSSDEV)objcopy -OBJDUMP = $(CROSSDEV)objdump +else + CC = $(CROSSDEV)gcc + CXX = $(CROSSDEV)g++ + CPP = $(CROSSDEV)gcc -E -P -x c + LD = $(CROSSDEV)ld + STRIP = $(CROSSDEV)strip --strip-unneeded + AR = $(CROSSDEV)ar rcs + NM = $(CROSSDEV)nm + OBJCOPY = $(CROSSDEV)objcopy + OBJDUMP = $(CROSSDEV)objdump + + ifeq ($(CONFIG_LTO_FULL),y) + ifeq ($(CONFIG_ARMV8M_TOOLCHAIN),GNU_EABI) + LD := $(CROSSDEV)gcc + AR := $(CROSSDEV)gcc-ar rcs + NM := $(CROSSDEV)gcc-nm + ARCHOPTIMIZATION += -fno-builtin + ARCHOPTIMIZATION += -nodefaultlibs + endif + endif +endif + +# Architecture flags + +ARCHCFLAGS += -fno-common +ARCHCXXFLAGS += -fno-common -nostdinc++ + +ifneq ($(CONFIG_CXX_EXCEPTION),y) + ARCHCXXFLAGS += -fno-exceptions -fcheck-new +endif + +ifneq ($(CONFIG_CXX_RTTI),y) + ARCHCXXFLAGS += -fno-rtti +endif + +# Optimization of unused sections + +ifeq ($(CONFIG_DEBUG_OPT_UNUSED_SECTIONS),y) + LDFLAGS += --gc-sections + ARCHOPTIMIZATION += -ffunction-sections -fdata-sections +endif + +# Debug link map + +ifeq ($(CONFIG_DEBUG_LINK_MAP),y) + LDFLAGS += --cref -Map=$(call CONVERT_PATH,$(TOPDIR)$(DELIM)nuttx.map) +endif + +ifeq ($(CONFIG_DEBUG_SYMBOLS),y) + LDFLAGS += -g + ARCHOPTIMIZATION += -g +endif # Add the builtin library -EXTRA_LIBS += ${wildcard ${shell $(CC) $(ARCHCPUFLAGS) --print-libgcc-file-name}} +COMPILER_RT_LIB = $(shell $(CC) $(ARCHCPUFLAGS) --print-libgcc-file-name) +ifeq ($(wildcard $(COMPILER_RT_LIB)),) + # if "--print-libgcc-file-name" unable to find the correct libgcc PATH + # then go ahead and try "--print-file-name" + COMPILER_RT_LIB := $(wildcard $(shell $(CC) $(ARCHCPUFLAGS) --print-file-name $(notdir $(COMPILER_RT_LIB)))) +endif + +EXTRA_LIBS += $(COMPILER_RT_LIB) ifneq ($(CONFIG_LIBM),y) - EXTRA_LIBS += ${wildcard ${shell $(CC) $(ARCHCPUFLAGS) --print-file-name=libm.a}} + EXTRA_LIBS += $(wildcard $(shell $(CC) $(ARCHCPUFLAGS) --print-file-name=libm.a)) endif ifeq ($(CONFIG_LIBSUPCXX),y) - EXTRA_LIBS += ${wildcard ${shell $(CC) $(ARCHCPUFLAGS) --print-file-name=libsupc++.a}} + EXTRA_LIBS += $(wildcard $(shell $(CC) $(ARCHCPUFLAGS) --print-file-name=libsupc++.a)) endif diff --git a/arch/arm/src/armv8-m/arm_busfault.c b/arch/arm/src/armv8-m/arm_busfault.c index ce4d232a0fc33..11ccac444e0ae 100644 --- a/arch/arm/src/armv8-m/arm_busfault.c +++ b/arch/arm/src/armv8-m/arm_busfault.c @@ -57,7 +57,7 @@ * ****************************************************************************/ -int arm_busfault(int irq, FAR void *context, FAR void *arg) +int arm_busfault(int irq, void *context, void *arg) { uint32_t cfsr = getreg32(NVIC_CFAULTS); diff --git a/arch/arm/src/armv8-m/arm_exception.S b/arch/arm/src/armv8-m/arm_exception.S index 042b3609aaab3..bec4f68b31968 100644 --- a/arch/arm/src/armv8-m/arm_exception.S +++ b/arch/arm/src/armv8-m/arm_exception.S @@ -190,8 +190,12 @@ exception_common: * where to put the registers. */ - vstmdb sp!, {s16-s31} /* Save the non-volatile FP context */ + /* Switched-out task including volatile FP registers ? */ + tst r14, #EXC_RETURN_STD_CONTEXT + ite eq + vstmdbeq sp!, {s16-s31} /* Save the non-volatile FP context */ + subne sp, #(4*SW_FPU_REGS) #endif stmdb sp!, {r2-r11,r14} /* Save the remaining registers plus the SP/PRIMASK values */ @@ -241,7 +245,12 @@ exception_common: ldmia r0!, {r2-r11,r14} /* Recover R4-R11, r14 + 2 temp values */ #ifdef CONFIG_ARCH_FPU - vldmia r0!, {s16-s31} /* Recover S16-S31 */ + /* Switched-in task including volatile FP registers ? */ + + tst r14, #EXC_RETURN_STD_CONTEXT + ite eq + vldmiaeq r0!, {s16-s31} /* Recover S16-S31 */ + addne r0, #(4*SW_FPU_REGS) #endif #ifdef CONFIG_ARMV8M_STACKCHECK_HARDWARE diff --git a/arch/arm/src/armv8-m/arm_fpu.S b/arch/arm/src/armv8-m/arm_fpu.S deleted file mode 100644 index 5ced4630591a1..0000000000000 --- a/arch/arm/src/armv8-m/arm_fpu.S +++ /dev/null @@ -1,270 +0,0 @@ -/**************************************************************************** - * arch/arm/src/armv8-m/arm_fpu.S - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. The - * ASF licenses this file to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance with the - * License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - ****************************************************************************/ -/* - * When this file is assembled, it will require the following GCC options: - * - * -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=vfp -meabi=5 -mthumb - */ - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include - -#include - -#ifdef CONFIG_ARCH_FPU - -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -/**************************************************************************** - * Public Symbols - ****************************************************************************/ - - .globl arm_savefpu - .globl arm_restorefpu - - .syntax unified - .thumb - .file "arm_fpu.S" - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: arm_savefpu - * - * Description: - * Given the pointer to a register save area (in R0), save the state of the - * floating point registers. - * - * C Function Prototype: - * void arm_savefpu(uint32_t *regs); - * - * Input Parameters: - * regs - A pointer to the register save area in which to save the floating point - * registers - * - * Returned Value: - * None - * - ****************************************************************************/ - - .thumb_func - .type arm_savefpu, function -arm_savefpu: - - add r1, r0, #(4*REG_S0) /* R1=Address of FP register storage */ - - /* Some older GNU assemblers don't support all the newer UAL mnemonics. */ - -#if 1 /* Use UAL mnemonics */ - /* Store all floating point registers. Registers are stored in numeric order, - * s0, s1, ... in increasing address order. - */ - - vstmia r1!, {s0-s31} /* Save the full FP context */ - - /* Store the floating point control and status register. At the end of the - * vstmia, r1 will point to the FPSCR storage location. - */ - - vmrs r2, fpscr /* Fetch the FPSCR */ - str r2, [r1], #4 /* Save the floating point control and status register */ -#else - /* Store all floating point registers */ - -#if 1 /* Use store multiple */ - fstmias r1!, {s0-s31} /* Save the full FP context */ -#else - vmov r2, r3, d0 /* r2, r3 = d0 */ - str r2, [r1], #4 /* Save S0 and S1 values */ - str r3, [r1], #4 - vmov r2, r3, d1 /* r2, r3 = d1 */ - str r2, [r1], #4 /* Save S2 and S3 values */ - str r3, [r1], #4 - vmov r2, r3, d2 /* r2, r3 = d2 */ - str r2, [r1], #4 /* Save S4 and S5 values */ - str r3, [r1], #4 - vmov r2, r3, d3 /* r2, r3 = d3 */ - str r2, [r1], #4 /* Save S6 and S7 values */ - str r3, [r1], #4 - vmov r2, r3, d4 /* r2, r3 = d4 */ - str r2, [r1], #4 /* Save S8 and S9 values */ - str r3, [r1], #4 - vmov r2, r3, d5 /* r2, r3 = d5 */ - str r2, [r1], #4 /* Save S10 and S11 values */ - str r3, [r1], #4 - vmov r2, r3, d6 /* r2, r3 = d6 */ - str r2, [r1], #4 /* Save S12 and S13 values */ - str r3, [r1], #4 - vmov r2, r3, d7 /* r2, r3 = d7 */ - str r2, [r1], #4 /* Save S14 and S15 values */ - str r3, [r1], #4 - vmov r2, r3, d8 /* r2, r3 = d8 */ - str r2, [r1], #4 /* Save S16 and S17 values */ - str r3, [r1], #4 - vmov r2, r3, d9 /* r2, r3 = d9 */ - str r2, [r1], #4 /* Save S18 and S19 values */ - str r3, [r1], #4 - vmov r2, r3, d10 /* r2, r3 = d10 */ - str r2, [r1], #4 /* Save S20 and S21 values */ - str r3, [r1], #4 - vmov r2, r3, d11 /* r2, r3 = d11 */ - str r2, [r1], #4 /* Save S22 and S23 values */ - str r3, [r1], #4 - vmov r2, r3, d12 /* r2, r3 = d12 */ - str r2, [r1], #4 /* Save S24 and S25 values */ - str r3, [r1], #4 - vmov r2, r3, d13 /* r2, r3 = d13 */ - str r2, [r1], #4 /* Save S26 and S27 values */ - str r3, [r1], #4 - vmov r2, r3, d14 /* r2, r3 = d14 */ - str r2, [r1], #4 /* Save S28 and S29 values */ - str r3, [r1], #4 - vmov r2, r3, d15 /* r2, r3 = d15 */ - str r2, [r1], #4 /* Save S30 and S31 values */ - str r3, [r1], #4 -#endif - - /* Store the floating point control and status register */ - - fmrx r2, fpscr /* Fetch the FPSCR */ - str r2, [r1], #4 /* Save the floating point control and status register */ -#endif - bx lr - - .size arm_savefpu, .-arm_savefpu - -/**************************************************************************** - * Name: arm_restorefpu - * - * Description: - * Given the pointer to a register save area (in R0), restore the state of the - * floating point registers. - * - * C Function Prototype: - * void arm_restorefpu(const uint32_t *regs); - * - * Input Parameters: - * regs - A pointer to the register save area containing the floating point - * registers. - * - * Returned Value: - * This function does not return anything explicitly. However, it is called from - * interrupt level assembly logic that assumes that r0 is preserved. - * - ****************************************************************************/ - - .thumb_func - .type arm_restorefpu, function -arm_restorefpu: - - add r1, r0, #(4*REG_S0) /* R1=Address of FP register storage */ - - /* Some older GNU assemblers don't support all the newer UAL mnemonics. */ - -#if 1 /* Use UAL mnemonics */ - /* Load all floating point registers. Registers are loaded in numeric order, - * s0, s1, ... in increasing address order. - */ - - vldmia r1!, {s0-s31} /* Restore the full FP context */ - - /* Load the floating point control and status register. At the end of the - * vstmia, r1 will point to the FPSCR storage location. - */ - - ldr r2, [r1], #4 /* Fetch the floating point control and status register */ - vmsr fpscr, r2 /* Restore the FPSCR */ -#else - /* Load all floating point registers Registers are loaded in numeric order, - * s0, s1, ... in increasing address order. - */ - -#if 1 /* Use load multiple */ - fldmias r1!, {s0-s31} /* Restore the full FP context */ -#else - ldr r2, [r1], #4 /* Fetch S0 and S1 values */ - ldr r3, [r1], #4 - vmov d0, r2, r3 /* Save as d0 */ - ldr r2, [r1], #4 /* Fetch S2 and S3 values */ - ldr r3, [r1], #4 - vmov d1, r2, r3 /* Save as d1 */ - ldr r2, [r1], #4 /* Fetch S4 and S5 values */ - ldr r3, [r1], #4 - vmov d2, r2, r3 /* Save as d2 */ - ldr r2, [r1], #4 /* Fetch S6 and S7 values */ - ldr r3, [r1], #4 - vmov d3, r2, r3 /* Save as d3 */ - ldr r2, [r1], #4 /* Fetch S8 and S9 values */ - ldr r3, [r1], #4 - vmov d4, r2, r3 /* Save as d4 */ - ldr r2, [r1], #4 /* Fetch S10 and S11 values */ - ldr r3, [r1], #4 - vmov d5, r2, r3 /* Save as d5 */ - ldr r2, [r1], #4 /* Fetch S12 and S13 values */ - ldr r3, [r1], #4 - vmov d6, r2, r3 /* Save as d6 */ - ldr r2, [r1], #4 /* Fetch S14 and S15 values */ - ldr r3, [r1], #4 - vmov d7, r2, r3 /* Save as d7 */ - ldr r2, [r1], #4 /* Fetch S16 and S17 values */ - ldr r3, [r1], #4 - vmov d8, r2, r3 /* Save as d8 */ - ldr r2, [r1], #4 /* Fetch S18 and S19 values */ - ldr r3, [r1], #4 - vmov d9, r2, r3 /* Save as d9 */ - ldr r2, [r1], #4 /* Fetch S20 and S21 values */ - ldr r3, [r1], #4 - vmov d10, r2, r3 /* Save as d10 */ - ldr r2, [r1], #4 /* Fetch S22 and S23 values */ - ldr r3, [r1], #4 - vmov d11, r2, r3 /* Save as d11 */ - ldr r2, [r1], #4 /* Fetch S24 and S25 values */ - ldr r3, [r1], #4 - vmov d12, r2, r3 /* Save as d12 */ - ldr r2, [r1], #4 /* Fetch S26 and S27 values */ - ldr r3, [r1], #4 - vmov d13, r2, r3 /* Save as d13 */ - ldr r2, [r1], #4 /* Fetch S28 and S29 values */ - ldr r3, [r1], #4 - vmov d14, r2, r3 /* Save as d14 */ - ldr r2, [r1], #4 /* Fetch S30 and S31 values */ - ldr r3, [r1], #4 - vmov d15, r2, r3 /* Save as d15 */ -#endif - - /* Load the floating point control and status register. r1 points t - * the address of the FPSCR register. - */ - - ldr r2, [r1], #4 /* Fetch the floating point control and status register */ - fmxr fpscr, r2 /* Restore the FPSCR */ -#endif - bx lr - - .size arm_restorefpu, .-arm_restorefpu -#endif /* CONFIG_ARCH_FPU */ - .end diff --git a/arch/arm/src/armv8-m/arm_fpucmp.c b/arch/arm/src/armv8-m/arm_fpucmp.c new file mode 100644 index 0000000000000..08b2da7f9422e --- /dev/null +++ b/arch/arm/src/armv8-m/arm_fpucmp.c @@ -0,0 +1,62 @@ +/**************************************************************************** + * arch/arm/src/armv8-m/arm_fpucmp.c + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include +#include +#include + +#include "arm_internal.h" + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +#ifdef CONFIG_ARCH_FPU + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: up_fpucmp + * + * Description: + * compare FPU areas from thread context + * + ****************************************************************************/ + +bool up_fpucmp(const void *saveregs1, const void *saveregs2) +{ + const uint32_t *regs1 = saveregs1; + const uint32_t *regs2 = saveregs2; + + /* compare of hardware fp registers should skip REG_FP_RESERVED */ + + return memcmp(®s1[REG_S0], ®s2[REG_S0], + 4 * (HW_FPU_REGS - 1)) == 0 && + memcmp(®s1[REG_S16], ®s2[REG_S16], 4 * SW_FPU_REGS) == 0; +} +#endif /* CONFIG_ARCH_FPU */ diff --git a/arch/arm/src/armv8-m/arm_fpuconfig.c b/arch/arm/src/armv8-m/arm_fpuconfig.c new file mode 100644 index 0000000000000..b0b1642128e48 --- /dev/null +++ b/arch/arm/src/armv8-m/arm_fpuconfig.c @@ -0,0 +1,83 @@ +/**************************************************************************** + * arch/arm/src/armv8-m/arm_fpuconfig.c + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include "nvic.h" +#include "arm_internal.h" + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: arm_fpuconfig + * + * Description: + * Configure the FPU. Relative bit settings: + * + * CPACR: Enables access to CP10 and CP11 + * CONTROL.FPCA: Determines whether the FP extension is active in the + * current context: + * FPCCR.ASPEN: Enables automatic FP state preservation, then the + * processor sets this bit to 1 on successful completion of any FP + * instruction. + * FPCCR.LSPEN: Enables lazy context save of FP state. When this is + * done, the processor reserves space on the stack for the FP state, + * but does not save that state information to the stack. + * + * Software must not change the value of the ASPEN bit or LSPEN bit while + * either: + * + * - the CPACR permits access to CP10 and CP11, that give access to the FP + * extension, or + * - the CONTROL.FPCA bit is set to 1 + * + ****************************************************************************/ + +void arm_fpuconfig(void) +{ + uint32_t regval; + + /* Set CONTROL.FPCA so that we always get the extended context frame + * with the volatile FP registers stacked above the basic context. + */ + + regval = getcontrol(); + regval |= CONTROL_FPCA; + setcontrol(regval); + + /* Ensure that FPCCR.LSPEN is disabled, so that we don't have to contend + * with the lazy FP context save behavior. Clear FPCCR.ASPEN since we + * are going to turn on CONTROL.FPCA for all contexts. + */ + + regval = getreg32(NVIC_FPCCR); + regval &= ~(NVIC_FPCCR_ASPEN | NVIC_FPCCR_LSPEN); + putreg32(regval, NVIC_FPCCR); + + /* Enable full access to CP10 and CP11 */ + + regval = getreg32(NVIC_CPACR); + regval |= NVIC_CPACR_CP_FULL(10) | NVIC_CPACR_CP_FULL(11); + putreg32(regval, NVIC_CPACR); +} diff --git a/arch/arm/src/armv8-m/arm_fullcontextrestore.S b/arch/arm/src/armv8-m/arm_fullcontextrestore.S deleted file mode 100644 index 0227bd21f6000..0000000000000 --- a/arch/arm/src/armv8-m/arm_fullcontextrestore.S +++ /dev/null @@ -1,79 +0,0 @@ -/**************************************************************************** - * arch/arm/src/armv8-m/arm_fullcontextrestore.S - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. The - * ASF licenses this file to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance with the - * License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - ****************************************************************************/ - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include -#include -#include - -#include "nvic.h" - -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -/**************************************************************************** - * Public Symbols - ****************************************************************************/ - - .syntax unified - .thumb - .file "arm_fullcontextrestore.S" - -/**************************************************************************** - * Macros - ****************************************************************************/ - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: arm_fullcontextrestore - * - * Description: - * Restore the current thread context. Full prototype is: - * - * void arm_fullcontextrestore(uint32_t *restoreregs) noreturn_function; - * - * Returned Value: - * None - * - ****************************************************************************/ - - .thumb_func - .globl arm_fullcontextrestore - .type arm_fullcontextrestore, function -arm_fullcontextrestore: - - /* Perform the System call with R0=1 and R1=regs */ - - mov r1, r0 /* R1: regs */ - mov r0, #SYS_restore_context /* R0: restore context */ - svc #SYS_syscall /* Force synchronous SVCall (or Hard Fault) */ - - /* This call should not return */ - - bx lr /* Unnecessary ... will not return */ - .size arm_fullcontextrestore, .-arm_fullcontextrestore - .end diff --git a/arch/arm/src/armv8-m/arm_hardfault.c b/arch/arm/src/armv8-m/arm_hardfault.c index f5af2ab71e9cd..0e459b8ade0bd 100644 --- a/arch/arm/src/armv8-m/arm_hardfault.c +++ b/arch/arm/src/armv8-m/arm_hardfault.c @@ -71,7 +71,7 @@ * ****************************************************************************/ -int arm_hardfault(int irq, FAR void *context, FAR void *arg) +int arm_hardfault(int irq, void *context, void *arg) { uint32_t hfsr = getreg32(NVIC_HFAULTS); uint32_t cfsr = getreg32(NVIC_CFAULTS); diff --git a/arch/arm/src/armv8-m/arm_initialstate.c b/arch/arm/src/armv8-m/arm_initialstate.c index bb92eb196931b..46c53dda1aa67 100644 --- a/arch/arm/src/armv8-m/arm_initialstate.c +++ b/arch/arm/src/armv8-m/arm_initialstate.c @@ -84,9 +84,9 @@ void up_initial_state(struct tcb_s *tcb) /* Initialize the context registers to stack top */ - xcp->regs = (FAR void *)((uint32_t)tcb->stack_base_ptr + - tcb->adj_stack_size - - XCPTCONTEXT_SIZE); + xcp->regs = (void *)((uint32_t)tcb->stack_base_ptr + + tcb->adj_stack_size - + XCPTCONTEXT_SIZE); /* Initialize the xcp registers */ @@ -142,7 +142,6 @@ void up_initial_state(struct tcb_s *tcb) #endif #endif /* CONFIG_PIC */ -#if !defined(CONFIG_ARMV8M_LAZYFPU) || defined(CONFIG_BUILD_PROTECTED) /* All tasks start via a stub function in kernel space. So all * tasks must start in privileged thread mode. If CONFIG_BUILD_PROTECTED * is defined, then that stub function will switch to unprivileged @@ -151,14 +150,9 @@ void up_initial_state(struct tcb_s *tcb) xcp->regs[REG_EXC_RETURN] = EXC_RETURN_PRIVTHR; -#endif /* !CONFIG_ARMV8M_LAZYFPU || CONFIG_BUILD_PROTECTED */ - -#if !defined(CONFIG_ARMV8M_LAZYFPU) && defined(CONFIG_ARCH_FPU) - - xcp->regs[REG_FPSCR] = 0; /* REVISIT: Initial FPSCR should be configurable */ - xcp->regs[REG_FP_RESERVED] = 0; - -#endif /* !CONFIG_ARMV8M_LAZYFPU && CONFIG_ARCH_FPU */ +#ifdef CONFIG_ARCH_FPU + xcp->regs[REG_FPSCR] |= ARMV8M_FPSCR_LTPSIZE_NONE; +#endif /* CONFIG_ARCH_FPU */ /* Enable or disable interrupts, based on user configuration */ diff --git a/arch/arm/src/armv8-m/arm_itm_syslog.c b/arch/arm/src/armv8-m/arm_itm_syslog.c index 2c4d2f68ff5d6..9900de225e282 100644 --- a/arch/arm/src/armv8-m/arm_itm_syslog.c +++ b/arch/arm/src/armv8-m/arm_itm_syslog.c @@ -62,8 +62,8 @@ /* SYSLOG channel methods */ -static int itm_putc(FAR struct syslog_channel_s *channel, int ch); -static int itm_flush(FAR struct syslog_channel_s *channel); +static int itm_putc(struct syslog_channel_s *channel, int ch); +static int itm_flush(struct syslog_channel_s *channel); /**************************************************************************** * Private Data @@ -97,7 +97,7 @@ static const struct syslog_channel_s g_itm_channel = * ****************************************************************************/ -static int itm_putc(FAR struct syslog_channel_s *channel, int ch) +static int itm_putc(struct syslog_channel_s *channel, int ch) { UNUSED(channel); @@ -127,7 +127,7 @@ static int itm_putc(FAR struct syslog_channel_s *channel, int ch) * ****************************************************************************/ -static int itm_flush(FAR struct syslog_channel_s *channel) +static int itm_flush(struct syslog_channel_s *channel) { UNUSED(channel); return OK; diff --git a/arch/arm/src/armv8-m/arm_lazyexception.S b/arch/arm/src/armv8-m/arm_lazyexception.S deleted file mode 100644 index cc9b994925a0c..0000000000000 --- a/arch/arm/src/armv8-m/arm_lazyexception.S +++ /dev/null @@ -1,362 +0,0 @@ -/**************************************************************************** - * arch/arm/src/armv8-m/up_lazyexcption.S - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. The - * ASF licenses this file to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance with the - * License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - ****************************************************************************/ - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include - -#include -#include - -#include "chip.h" -#include "exc_return.h" - -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -/* Configuration ************************************************************/ - -#ifdef CONFIG_ARCH_HIPRI_INTERRUPT - /* In protected mode without an interrupt stack, this interrupt handler will set the MSP to the - * stack pointer of the interrupted thread. If the interrupted thread was a privileged - * thread, that will be the MSP otherwise it will be the PSP. If the PSP is used, then the - * value of the MSP will be invalid when the interrupt handler returns because it will be a - * pointer to an old position in the unprivileged stack. Then when the high priority - * interrupt occurs and uses this stale MSP, there will most likely be a system failure. - * - * If the interrupt stack is selected, on the other hand, then the interrupt handler will - * always set the MSP to the interrupt stack. So when the high priority interrupt occurs, - * it will either use the MSP of the last privileged thread to run or, in the case of the - * nested interrupt, the interrupt stack if no privileged task has run. - */ - -# if defined(CONFIG_BUILD_PROTECTED) && CONFIG_ARCH_INTERRUPTSTACK < 8 -# error Interrupt stack must be used with high priority interrupts in protected mode -# endif - - /* Use the BASEPRI to control interrupts is required if nested, high - * priority interrupts are supported. - */ - -# ifndef CONFIG_ARMV8M_USEBASEPRI -# error CONFIG_ARMV8M_USEBASEPRI must be used with CONFIG_ARCH_HIPRI_INTERRUPT -# endif -#endif - -/**************************************************************************** - * Public Symbols - ****************************************************************************/ - - .globl exception_common - - .syntax unified - .thumb - .file "arm_lazyexception.S" - -/**************************************************************************** - * Macro Definitions - ****************************************************************************/ - -/**************************************************************************** - * Name: setintstack - * - * Description: - * Set the current stack pointer to the "top" the interrupt stack. Single CPU case. Must be - * provided by MCU-specific logic in chip.h for the SMP case. - * - ****************************************************************************/ - -#if !defined(CONFIG_SMP) && CONFIG_ARCH_INTERRUPTSTACK > 7 - .macro setintstack, tmp1, tmp2 -#ifdef CONFIG_ARMV8M_STACKCHECK_HARDWARE - ldr \tmp1, =g_intstackalloc - msr msplim, \tmp1 -#endif - ldr sp, =g_intstacktop - .endm -#endif - -/**************************************************************************** - * .text - ****************************************************************************/ - -/* Common IRQ handling logic. On entry here, the return stack is on either - * the PSP or the MSP and looks like the following: - * - * REG_XPSR - * REG_R15 - * REG_R14 - * REG_R12 - * REG_R3 - * REG_R2 - * REG_R1 - * MSP->REG_R0 - * - * And - * IPSR contains the IRQ number - * R14 Contains the EXC_RETURN value - * We are in handler mode and the current SP is the MSP - */ - - .text - .type exception_common, function - -exception_common: - - /* Get the IRQ number from the IPSR */ - - mrs r0, ipsr /* R0=exception number */ - - /* Complete the context save */ - - tst r14, #EXC_RETURN_PROCESS_STACK /* Nonzero if context on process stack */ - -#ifdef CONFIG_BUILD_PROTECTED - /* The EXC_RETURN value will be 0xfffffff9 (privileged thread) or 0xfffffff1 - * (handler mode) if the stack is on the MSP. It can only be on the PSP if - * EXC_RETURN is 0xfffffffd (unprivileged thread) - */ - - beq 1f /* Branch if context already on the MSP */ - mrs r1, psp /* R1=The process stack pointer (PSP) */ - mov sp, r1 /* Set the MSP to the PSP */ - -1: -#endif - - /* sp holds the value of the stack pointer AFTER the exception handling logic - * pushed the various registers onto the stack. Get r2 = the value of the - * stack pointer BEFORE the interrupt modified it. - */ - - mov r2, sp /* R2=Copy of the main/process stack pointer */ - add r2, #HW_XCPT_SIZE /* R2=MSP/PSP before the interrupt was taken */ - -#ifdef CONFIG_ARMV8M_STACKCHECK_HARDWARE - mov r3, #0x0 - - ittee eq - mrseq r1, msplim - msreq msplim, r3 - mrsne r1, psplim - msrne psplim, r3 - - stmdb sp!, {r1} -#endif - -#ifdef CONFIG_ARMV8M_USEBASEPRI - mrs r3, basepri /* R3=Current BASEPRI setting */ -#else - mrs r3, primask /* R3=Current PRIMASK setting */ -#endif - -#ifdef CONFIG_ARCH_FPU - /* Skip over the block of memory reserved for floating pointer register save. - * Lazy FPU register saving is used. FPU registers will be saved in this - * block only if a context switch occurs (this means, of course, that the FPU - * cannot be used in interrupt processing). - */ - - sub sp, #(4*SW_FPU_REGS) -#endif - - /* Save the remaining registers on the stack after the registers pushed - * by the exception handling logic. r2=SP and r3=primask or basepri, r4-r11, - * r14=register values. - */ - -#ifdef CONFIG_BUILD_PROTECTED - stmdb sp!, {r2-r11,r14} /* Save the remaining registers plus the SP value */ -#else - stmdb sp!, {r2-r11} /* Save the remaining registers plus the SP value */ -#endif - - /* There are two arguments to arm_doirq: - * - * R0 = The IRQ number - * R1 = The top of the stack points to the saved state - */ - - mov r1, sp - - /* Also save the top of the stack in a preserved register */ - - mov r4, sp - -#if CONFIG_ARCH_INTERRUPTSTACK > 7 - /* If CONFIG_ARCH_INTERRUPTSTACK is defined, we will set the MSP to use - * a special special interrupt stack pointer. The way that this is done - * here prohibits nested interrupts without some additional logic! - */ - - setintstack r2, r3 /* SP = IRQ stack top */ -#else - /* Otherwise, we will re-use the interrupted thread's stack. That may - * mean using either MSP or PSP stack for interrupt level processing (in - * kernel mode). - */ - - /* If the interrupt stack is disabled, reserve xcpcontext to ensure - * that signal processing can have a separate xcpcontext to handle - * signal context (reference: arm_schedulesigaction.c): - * ---------------------- - * | IRQ XCP context | - * ------------------- - * | Signal XCP context | - * ---------------------- <- SP - * also the sp should be restore after arm_doirq() - */ - - sub r2, r4, #XCPTCONTEXT_SIZE /* Reserve signal context */ - bic r2, r2, #7 /* Get the stack pointer with 8-byte alignment */ - mov sp, r2 /* Instantiate the aligned stack */ -#endif - - bl arm_doirq /* R0=IRQ, R1=register save (msp) */ - - /* On return from arm_doirq, R0 will hold a pointer to register context - * array to use for the interrupt return. - */ - - cmp r0, r4 /* Context switch? */ - beq 2f /* Branch if no context switch */ - - /* We are returning with a pending context switch. - * - * If the FPU is enabled, then we will need to restore FPU registers. - * This is not done in normal interrupt save/restore because the cost - * is prohibitive. This is only done when switching contexts. A - * consequence of this is that floating point operations may not be - * performed in interrupt handling logic. - * - * Here: - * r0 = Address of the register save area - * - * NOTE: It is a requirement that arm_restorefpu() preserve the value of - * r0! - */ - -#ifdef CONFIG_ARCH_FPU - bl arm_restorefpu /* Restore the FPU registers */ -#endif - -2: -#ifdef CONFIG_BUILD_PROTECTED - ldmia r0!, {r2-r11,r14} /* Recover R4-R11, r14 + 2 temp values */ -#else - ldmia r0!, {r2-r11} /* Recover R4-R11 + 2 temp values */ -#endif - -#ifdef CONFIG_ARCH_FPU - /* Skip over the block of memory reserved for floating pointer register - * save. Then R1 is the address of the HW save area - */ - - add r0, #(4*SW_FPU_REGS) -#endif - -#ifdef CONFIG_ARMV8M_STACKCHECK_HARDWARE - ldmia r0!, {r1} /* Get psplim/msplim */ -#endif - - /* Set up to return from the exception - * - * Here: - * r0 = Address on the target thread's stack position at the start of - * the registers saved by hardware - * r3 = primask or basepri - * r4-r11 = restored register values - */ - -#ifdef CONFIG_BUILD_PROTECTED - /* The EXC_RETURN value will be 0xfffffff9 (privileged thread) or 0xfffffff1 - * (handler mode) if the stack is on the MSP. It can only be on the PSP if - * EXC_RETURN is 0xfffffffd (unprivileged thread) - */ - - mrs r2, control /* R2=Contents of the control register */ - tst r14, #EXC_RETURN_PROCESS_STACK /* nonzero if context on process stack */ - beq 3f /* Branch if privileged */ - - orr r2, r2, #1 /* Unprivileged mode */ -#ifdef CONFIG_ARMV8M_STACKCHECK_HARDWARE - msr psplim, r1 -#endif - msr psp, r0 /* R1=The process stack pointer */ - b 4f -3: - bic r2, r2, #1 /* Privileged mode */ -#ifdef CONFIG_ARMV8M_STACKCHECK_HARDWARE - msr msplim, r1 -#endif - msr msp, r0 /* R1=The main stack pointer */ -4: - msr control, r2 /* Save the updated control register */ -#else -#ifdef CONFIG_ARMV8M_STACKCHECK_HARDWARE - msr msplim, r1 -#endif - msr msp, r0 /* Recover the return MSP value */ - - /* Preload r14 with the special return value first (so that the return - * actually occurs with interrupts still disabled). - */ - - ldr r14, =EXC_RETURN_PRIVTHR /* Load the special value */ -#endif - - /* Restore the interrupt state */ - -#ifdef CONFIG_ARMV8M_USEBASEPRI - msr basepri, r3 /* Restore interrupts priority masking */ -#else - msr primask, r3 /* Restore interrupts */ -#endif - - /* Always return with R14 containing the special value that will: (1) - * return to thread mode, and (2) continue to use the MSP - */ - - bx r14 /* And return */ - .size exception_common, .-exception_common - -/**************************************************************************** - * Name: g_intstackalloc/g_intstacktop - * - * Description: - * Shouldn't happen - * - ****************************************************************************/ - -#if !defined(CONFIG_SMP) && CONFIG_ARCH_INTERRUPTSTACK > 7 - .bss - .global g_intstackalloc - .global g_intstacktop - .balign 8 -g_intstackalloc: - .skip ((CONFIG_ARCH_INTERRUPTSTACK + 4) & ~7) -g_intstacktop: - .size g_intstackalloc, .-g_intstackalloc -#endif - - .end diff --git a/arch/arm/src/armv8-m/arm_memfault.c b/arch/arm/src/armv8-m/arm_memfault.c index 4c459e97a9ca3..526a02af8febb 100644 --- a/arch/arm/src/armv8-m/arm_memfault.c +++ b/arch/arm/src/armv8-m/arm_memfault.c @@ -58,7 +58,7 @@ * ****************************************************************************/ -int arm_memfault(int irq, FAR void *context, FAR void *arg) +int arm_memfault(int irq, void *context, void *arg) { uint32_t cfsr = getreg32(NVIC_CFAULTS); diff --git a/arch/arm/src/armv8-m/arm_perf.c b/arch/arm/src/armv8-m/arm_perf.c index 0a981a4948653..f04811fece200 100644 --- a/arch/arm/src/armv8-m/arm_perf.c +++ b/arch/arm/src/armv8-m/arm_perf.c @@ -40,7 +40,7 @@ static uint32_t g_cpu_freq; * Public Functions ****************************************************************************/ -void up_perf_init(FAR void *arg) +void up_perf_init(void *arg) { g_cpu_freq = (uint32_t)(uintptr_t)arg; @@ -66,7 +66,7 @@ uint32_t up_perf_gettime(void) return getreg32(DWT_CYCCNT); } -void up_perf_convert(uint32_t elapsed, FAR struct timespec *ts) +void up_perf_convert(uint32_t elapsed, struct timespec *ts) { uint32_t left; diff --git a/arch/arm/src/armv8-m/arm_ramvec_initialize.c b/arch/arm/src/armv8-m/arm_ramvec_initialize.c index 7eb7409d4029b..dbf5b8ee597bd 100644 --- a/arch/arm/src/armv8-m/arm_ramvec_initialize.c +++ b/arch/arm/src/armv8-m/arm_ramvec_initialize.c @@ -128,7 +128,7 @@ void arm_ramvec_initialize(void) * protect against NULL pointer references. */ - src = (const CODE up_vector_t *)getreg32(NVIC_VECTAB); + src = (const up_vector_t *)getreg32(NVIC_VECTAB); dest = g_ram_vectors; irqinfo("src=%p dest=%p\n", src, dest); diff --git a/arch/arm/src/armv8-m/arm_saveusercontext.S b/arch/arm/src/armv8-m/arm_saveusercontext.S deleted file mode 100644 index 0de40f3e81655..0000000000000 --- a/arch/arm/src/armv8-m/arm_saveusercontext.S +++ /dev/null @@ -1,88 +0,0 @@ -/**************************************************************************** - * arch/arm/src/armv8-m/arm_saveusercontext.S - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. The - * ASF licenses this file to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance with the - * License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - ****************************************************************************/ - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include -#include -#include - -#include "nvic.h" - -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -/**************************************************************************** - * Public Symbols - ****************************************************************************/ - - .syntax unified - .thumb - .file "arm_saveusercontext.S" - -/**************************************************************************** - * Macros - ****************************************************************************/ - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: arm_saveusercontext - * - * Description: - * Save the current thread context. Full prototype is: - * - * int arm_saveusercontext(uint32_t *saveregs); - * - * Returned Value: - * 0: Normal return - * 1: Context switch return - * - ****************************************************************************/ - - .text - .thumb_func - .globl arm_saveusercontext - .type arm_saveusercontext, function -arm_saveusercontext: - - /* Perform the System call with R0=0 and R1=regs */ - - mov r1, r0 /* R1: regs */ - mov r0, #SYS_save_context /* R0: save context (also return value) */ - svc #SYS_syscall /* Force synchronous SVCall (or Hard Fault) */ - - /* There are two return conditions. On the first return, R0 (the - * return value will be zero. On the second return we need to - * force R0 to be 1. - */ - - add r2, r1, #(4*REG_R0) - mov r3, #1 - str r3, [r2, #0] - bx lr /* "normal" return with r0=0 or - * context switch with r0=1 */ - .size arm_saveusercontext, .-arm_saveusercontext - .end diff --git a/arch/arm/src/armv8-m/arm_schedulesigaction.c b/arch/arm/src/armv8-m/arm_schedulesigaction.c index 495aed85a5c9b..e62cdcb1b2bdc 100644 --- a/arch/arm/src/armv8-m/arm_schedulesigaction.c +++ b/arch/arm/src/armv8-m/arm_schedulesigaction.c @@ -124,7 +124,7 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver) * delivered. */ - tcb->xcp.sigdeliver = (FAR void *)sigdeliver; + tcb->xcp.sigdeliver = (void *)sigdeliver; /* And make sure that the saved context in the TCB is the same * as the interrupt return context. @@ -137,10 +137,10 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver) * delivered. */ - CURRENT_REGS = (FAR void *) + CURRENT_REGS = (void *) ((uint32_t)CURRENT_REGS - (uint32_t)XCPTCONTEXT_SIZE); - memcpy((FAR uint32_t *)CURRENT_REGS, tcb->xcp.saved_regs, + memcpy((uint32_t *)CURRENT_REGS, tcb->xcp.saved_regs, XCPTCONTEXT_SIZE); CURRENT_REGS[REG_SP] = (uint32_t)CURRENT_REGS + @@ -177,7 +177,7 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver) * by the signal trampoline after the signal has been delivered. */ - tcb->xcp.sigdeliver = (FAR void *)sigdeliver; + tcb->xcp.sigdeliver = (void *)sigdeliver; /* Save the current register context location */ @@ -188,7 +188,7 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver) * delivered. */ - tcb->xcp.regs = (FAR void *) + tcb->xcp.regs = (void *) ((uint32_t)tcb->xcp.regs - (uint32_t)XCPTCONTEXT_SIZE); memcpy(tcb->xcp.regs, tcb->xcp.saved_regs, XCPTCONTEXT_SIZE); @@ -285,7 +285,7 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver) * been delivered. */ - tcb->xcp.sigdeliver = (FAR void *)sigdeliver; + tcb->xcp.sigdeliver = (void *)sigdeliver; /* Save the current register context location */ @@ -296,7 +296,7 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver) * been delivered. */ - tcb->xcp.regs = (FAR void *) + tcb->xcp.regs = (void *) ((uint32_t)tcb->xcp.regs - (uint32_t)XCPTCONTEXT_SIZE); memcpy(tcb->xcp.regs, tcb->xcp.saved_regs, @@ -331,7 +331,7 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver) * signal has been delivered. */ - tcb->xcp.sigdeliver = (FAR void *)sigdeliver; + tcb->xcp.sigdeliver = (void *)sigdeliver; /* And make sure that the saved context in the TCB is the * same as the interrupt return context. @@ -344,10 +344,10 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver) * been delivered. */ - CURRENT_REGS = (FAR void *) + CURRENT_REGS = (void *) ((uint32_t)CURRENT_REGS - (uint32_t)XCPTCONTEXT_SIZE); - memcpy((FAR uint32_t *)CURRENT_REGS, tcb->xcp.saved_regs, + memcpy((uint32_t *)CURRENT_REGS, tcb->xcp.saved_regs, XCPTCONTEXT_SIZE); CURRENT_REGS[REG_SP] = (uint32_t)CURRENT_REGS + @@ -409,7 +409,7 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver) * by the signal trampoline after the signal has been delivered. */ - tcb->xcp.sigdeliver = (FAR void *)sigdeliver; + tcb->xcp.sigdeliver = (void *)sigdeliver; /* Save the current register context location */ @@ -420,7 +420,7 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver) * delivered. */ - tcb->xcp.regs = (FAR void *) + tcb->xcp.regs = (void *) ((uint32_t)tcb->xcp.regs - (uint32_t)XCPTCONTEXT_SIZE); memcpy(tcb->xcp.regs, tcb->xcp.saved_regs, XCPTCONTEXT_SIZE); diff --git a/arch/arm/src/armv8-m/arm_securefault.c b/arch/arm/src/armv8-m/arm_securefault.c index a06a72b4f36d0..47327d901fe53 100644 --- a/arch/arm/src/armv8-m/arm_securefault.c +++ b/arch/arm/src/armv8-m/arm_securefault.c @@ -103,7 +103,7 @@ bool weak_function arm_should_generate_nonsecure_busfault(void) * ****************************************************************************/ -int arm_securefault(int irq, FAR void *context, FAR void *arg) +int arm_securefault(int irq, void *context, void *arg) { uint32_t sfsr = getreg32(SAU_SFSR); diff --git a/arch/arm/src/armv8-m/arm_signal_dispatch.c b/arch/arm/src/armv8-m/arm_signal_dispatch.c deleted file mode 100644 index 62baf3cba1de6..0000000000000 --- a/arch/arm/src/armv8-m/arm_signal_dispatch.c +++ /dev/null @@ -1,76 +0,0 @@ -/**************************************************************************** - * arch/arm/src/armv8-m/arm_signal_dispatch.c - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. The - * ASF licenses this file to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance with the - * License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - ****************************************************************************/ - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include -#include - -#include - -#include "arm_internal.h" - -#if !defined(CONFIG_BUILD_FLAT) && defined(__KERNEL__) - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: up_signal_dispatch - * - * Description: - * In the kernel mode build, this function will be called to execute a - * a signal handler in user-space. When the signal is delivered, a - * kernel-mode stub will first run to perform some housekeeping functions. - * This kernel-mode stub will then be called transfer control to the user - * mode signal handler by calling this function. - * - * Normally the user-mode signaling handling stub will also execute - * before the ultimate signal handler is called. See - * arch/arm/src/armv8-m/gnu/arm_signal_handler.S. This function is the - * user-space, signal handler trampoline function. It is called from - * up_signal_dispatch() in user-mode. - * - * Input Parameters: - * sighand - The address user-space signal handling function - * signo, info, and ucontext - Standard arguments to be passed to the - * signal handling function. - * - * Returned Value: - * None. This function does not return in the normal sense. It returns - * via an architecture specific system call made by up_signal_handler(). - * However, this will look like a normal return by the caller of - * up_signal_dispatch. - * - ****************************************************************************/ - -void up_signal_dispatch(_sa_sigaction_t sighand, int signo, - FAR siginfo_t *info, FAR void *ucontext) -{ - /* Let sys_call4() do all of the work */ - - sys_call4(SYS_signal_handler, (uintptr_t)sighand, (uintptr_t)signo, - (uintptr_t)info, (uintptr_t)ucontext); -} - -#endif /* !CONFIG_BUILD_FLAT && __KERNEL__ */ diff --git a/arch/arm/src/armv8-m/arm_svcall.c b/arch/arm/src/armv8-m/arm_svcall.c index 351b1adcb7cb0..23f9b2cdff20a 100644 --- a/arch/arm/src/armv8-m/arm_svcall.c +++ b/arch/arm/src/armv8-m/arm_svcall.c @@ -121,7 +121,7 @@ static void dispatch_syscall(void) * ****************************************************************************/ -int arm_svcall(int irq, FAR void *context, FAR void *arg) +int arm_svcall(int irq, void *context, void *arg) { uint32_t *regs = (uint32_t *)context; uint32_t cmd; @@ -160,7 +160,7 @@ int arm_svcall(int irq, FAR void *context, FAR void *arg) { /* R0=SYS_save_context: This is a save context command: * - * int arm_saveusercontext(uint32_t *saveregs); + * int up_saveusercontext(void *saveregs); * * At this point, the following values are saved in context: * @@ -174,9 +174,6 @@ int arm_svcall(int irq, FAR void *context, FAR void *arg) case SYS_save_context: { DEBUGASSERT(regs[REG_R1] != 0); -#if defined(CONFIG_ARCH_FPU) && defined(CONFIG_ARMV8M_LAZYFPU) - arm_savefpu(regs); -#endif memcpy((uint32_t *)regs[REG_R1], regs, XCPTCONTEXT_SIZE); } break; @@ -225,9 +222,6 @@ int arm_svcall(int irq, FAR void *context, FAR void *arg) case SYS_switch_context: { DEBUGASSERT(regs[REG_R1] != 0 && regs[REG_R2] != 0); -#if defined(CONFIG_ARCH_FPU) && defined(CONFIG_ARMV8M_LAZYFPU) - arm_savefpu(regs); -#endif *(uint32_t **)regs[REG_R1] = regs; CURRENT_REGS = (uint32_t *)regs[REG_R2]; } @@ -274,14 +268,14 @@ int arm_svcall(int irq, FAR void *context, FAR void *arg) */ rtcb->flags &= ~TCB_FLAG_SYSCALL; - (void)nxsig_unmask_pendingsignal(); + nxsig_unmask_pendingsignal(); } break; #endif /* R0=SYS_task_start: This a user task start * - * void up_task_start(main_t taskentry, int argc, FAR char *argv[]) + * void up_task_start(main_t taskentry, int argc, char *argv[]) * noreturn_function; * * At this point, the following values are saved in context: @@ -348,7 +342,7 @@ int arm_svcall(int irq, FAR void *context, FAR void *arg) /* R0=SYS_signal_handler: This a user signal handler callback * * void signal_handler(_sa_sigaction_t sighand, int signo, - * FAR siginfo_t *info, FAR void *ucontext); + * siginfo_t *info, void *ucontext); * * At this point, the following values are saved in context: * @@ -421,7 +415,7 @@ int arm_svcall(int irq, FAR void *context, FAR void *arg) default: { #ifdef CONFIG_LIB_SYSCALL - FAR struct tcb_s *rtcb = nxsched_self(); + struct tcb_s *rtcb = nxsched_self(); int index = rtcb->xcp.nsyscalls; /* Verify that the SYS call number is within range */ diff --git a/arch/arm/src/armv8-m/arm_systick.c b/arch/arm/src/armv8-m/arm_systick.c index c2800cc41567e..87dad9078807d 100644 --- a/arch/arm/src/armv8-m/arm_systick.c +++ b/arch/arm/src/armv8-m/arm_systick.c @@ -57,15 +57,15 @@ struct systick_lowerhalf_s * Private Function Prototypes ****************************************************************************/ -static int systick_start(FAR struct timer_lowerhalf_s *lower_); -static int systick_stop(FAR struct timer_lowerhalf_s *lower_); -static int systick_getstatus(FAR struct timer_lowerhalf_s *lower_, - FAR struct timer_status_s *status); -static int systick_settimeout(FAR struct timer_lowerhalf_s *lower_, +static int systick_start(struct timer_lowerhalf_s *lower_); +static int systick_stop(struct timer_lowerhalf_s *lower_); +static int systick_getstatus(struct timer_lowerhalf_s *lower_, + struct timer_status_s *status); +static int systick_settimeout(struct timer_lowerhalf_s *lower_, uint32_t timeout); -static void systick_setcallback(FAR struct timer_lowerhalf_s *lower_, - tccb_t callback, FAR void *arg); -static int systick_maxtimeout(FAR struct timer_lowerhalf_s *lower_, +static void systick_setcallback(struct timer_lowerhalf_s *lower_, + tccb_t callback, void *arg); +static int systick_maxtimeout(struct timer_lowerhalf_s *lower_, uint32_t *maxtimeout); /**************************************************************************** @@ -118,21 +118,21 @@ static bool systick_irq_pending(struct systick_lowerhalf_s *lower) } } -static int systick_start(FAR struct timer_lowerhalf_s *lower_) +static int systick_start(struct timer_lowerhalf_s *lower_) { putreg32(0, NVIC_SYSTICK_CURRENT); modifyreg32(NVIC_SYSTICK_CTRL, 0, NVIC_SYSTICK_CTRL_ENABLE); return 0; } -static int systick_stop(FAR struct timer_lowerhalf_s *lower_) +static int systick_stop(struct timer_lowerhalf_s *lower_) { modifyreg32(NVIC_SYSTICK_CTRL, NVIC_SYSTICK_CTRL_ENABLE, 0); return 0; } -static int systick_getstatus(FAR struct timer_lowerhalf_s *lower_, - FAR struct timer_status_s *status) +static int systick_getstatus(struct timer_lowerhalf_s *lower_, + struct timer_status_s *status) { struct systick_lowerhalf_s *lower = (struct systick_lowerhalf_s *)lower_; irqstate_t flags = enter_critical_section(); @@ -165,7 +165,7 @@ static int systick_getstatus(FAR struct timer_lowerhalf_s *lower_, return 0; } -static int systick_settimeout(FAR struct timer_lowerhalf_s *lower_, +static int systick_settimeout(struct timer_lowerhalf_s *lower_, uint32_t timeout) { struct systick_lowerhalf_s *lower = (struct systick_lowerhalf_s *)lower_; @@ -198,8 +198,8 @@ static int systick_settimeout(FAR struct timer_lowerhalf_s *lower_, return 0; } -static void systick_setcallback(FAR struct timer_lowerhalf_s *lower_, - CODE tccb_t callback, FAR void *arg) +static void systick_setcallback(struct timer_lowerhalf_s *lower_, + tccb_t callback, void *arg) { struct systick_lowerhalf_s *lower = (struct systick_lowerhalf_s *)lower_; @@ -209,7 +209,7 @@ static void systick_setcallback(FAR struct timer_lowerhalf_s *lower_, leave_critical_section(flags); } -static int systick_maxtimeout(FAR struct timer_lowerhalf_s *lower_, +static int systick_maxtimeout(struct timer_lowerhalf_s *lower_, uint32_t *maxtimeout) { uint64_t maxtimeout64 = usec_from_count( @@ -227,7 +227,7 @@ static int systick_maxtimeout(FAR struct timer_lowerhalf_s *lower_, return 0; } -static int systick_interrupt(int irq, FAR void *context, FAR void *arg) +static int systick_interrupt(int irq, void *context, void *arg) { struct systick_lowerhalf_s *lower = arg; diff --git a/arch/arm/src/armv8-m/arm_tcbinfo.c b/arch/arm/src/armv8-m/arm_tcbinfo.c index 6ec9219342470..40b4db8b0e07d 100644 --- a/arch/arm/src/armv8-m/arm_tcbinfo.c +++ b/arch/arm/src/armv8-m/arm_tcbinfo.c @@ -53,17 +53,17 @@ static const uint16_t g_reg_offs[] = TCB_REG_OFF(REG_R15), TCB_REG_OFF(REG_XPSR), - 0, /* msp */ + UINT16_MAX, /* msp */ TCB_REG_OFF(REG_R13), #ifdef CONFIG_ARMV8M_USEBASEPRI - 0, /* primask */ + UINT16_MAX, /* primask */ TCB_REG_OFF(REG_BASEPRI), #else TCB_REG_OFF(REG_PRIMASK), - 0, /* basepri */ + UINT16_MAX, /* basepri */ #endif - 0, /* faultmask */ - 0, /* control */ + UINT16_MAX, /* faultmask */ + UINT16_MAX, /* control */ #ifdef CONFIG_ARCH_FPU TCB_REG_OFF(REG_S0), @@ -108,11 +108,13 @@ static const uint16_t g_reg_offs[] = const struct tcbinfo_s g_tcbinfo = { - TCB_PID_OFF, - TCB_STATE_OFF, - TCB_PRI_OFF, - TCB_NAME_OFF, - XCPTCONTEXT_REGS, + .pid_off = TCB_PID_OFF, + .state_off = TCB_STATE_OFF, + .pri_off = TCB_PRI_OFF, + .name_off = TCB_NAME_OFF, + .regs_off = TCB_REGS_OFF, + .basic_num = 17, + .total_num = XCPTCONTEXT_REGS, { .p = g_reg_offs, }, diff --git a/arch/arm/src/armv8-m/arm_usagefault.c b/arch/arm/src/armv8-m/arm_usagefault.c index de91292b4cdcf..7f1f774443692 100644 --- a/arch/arm/src/armv8-m/arm_usagefault.c +++ b/arch/arm/src/armv8-m/arm_usagefault.c @@ -57,7 +57,7 @@ * ****************************************************************************/ -int arm_usagefault(int irq, FAR void *context, FAR void *arg) +int arm_usagefault(int irq, void *context, void *arg) { uint32_t cfsr = getreg32(NVIC_CFAULTS); diff --git a/arch/arm/src/armv8-m/exc_return.h b/arch/arm/src/armv8-m/exc_return.h index 9bb3976c8650e..f415558a7caa5 100644 --- a/arch/arm/src/armv8-m/exc_return.h +++ b/arch/arm/src/armv8-m/exc_return.h @@ -108,7 +108,7 @@ * gets state from the main stack. Execution uses MSP after return. */ -#if !defined(CONFIG_ARMV8M_LAZYFPU) && defined(CONFIG_ARCH_FPU) +#ifdef CONFIG_ARCH_FPU # define EXC_RETURN_PRIVTHR (EXC_RETURN_BASE | EXC_RETURN_THREAD_MODE | \ EXC_RETURN_DEF_STACKING) #else @@ -120,7 +120,7 @@ * gets state from the process stack. Execution uses PSP after return. */ -#if !defined(CONFIG_ARMV8M_LAZYFPU) && defined(CONFIG_ARCH_FPU) +#ifdef CONFIG_ARCH_FPU # define EXC_RETURN_UNPRIVTHR (EXC_RETURN_BASE | EXC_RETURN_THREAD_MODE | \ EXC_RETURN_PROCESS_STACK | EXC_RETURN_DEF_STACKING) #else @@ -129,7 +129,7 @@ EXC_RETURN_DEF_STACKING) #endif -#if defined(CONFIG_ARCH_FPU) +#ifdef CONFIG_ARCH_FPU #define EXC_INTEGRITY_SIGNATURE (0xfefa125a) #else #define EXC_INTEGRITY_SIGNATURE (0xfefa125b) diff --git a/arch/arm/src/armv8-m/psr.h b/arch/arm/src/armv8-m/psr.h index f97890ef46cc8..8944bf12b527a 100644 --- a/arch/arm/src/armv8-m/psr.h +++ b/arch/arm/src/armv8-m/psr.h @@ -89,11 +89,12 @@ #define ARMV8M_FPSCR_IDC (1 << 7) /* Bit 7: Input Denormal */ #define ARMV8M_FPSCR_LTPSIZE_SHIFT 16 /* Bits 16-18: Vector element size */ -#define ARMV8M_FPSCR_LTPSIZE_8BIT (0x0 << ARMV8M_FPSCR_RM_SHIFT) -#define ARMV8M_FPSCR_LTPSIZE_16BIT (0x1 << ARMV8M_FPSCR_RM_SHIFT) -#define ARMV8M_FPSCR_LTPSIZE_32BIT (0x2 << ARMV8M_FPSCR_RM_SHIFT) -#define ARMV8M_FPSCR_LTPSIZE_DONE (0x3 << ARMV8M_FPSCR_RM_SHIFT) -#define ARMV8M_FPSCR_LTPSIZE_MASK (0x7 << ARMV8M_FPSCR_RM_SHIFT) +#define ARMV8M_FPSCR_LTPSIZE_8BIT (0x0 << ARMV8M_FPSCR_LTPSIZE_SHIFT) +#define ARMV8M_FPSCR_LTPSIZE_16BIT (0x1 << ARMV8M_FPSCR_LTPSIZE_SHIFT) +#define ARMV8M_FPSCR_LTPSIZE_32BIT (0x2 << ARMV8M_FPSCR_LTPSIZE_SHIFT) +#define ARMV8M_FPSCR_LTPSIZE_64BIT (0x3 << ARMV8M_FPSCR_LTPSIZE_SHIFT) +#define ARMV8M_FPSCR_LTPSIZE_NONE (0x4 << ARMV8M_FPSCR_LTPSIZE_SHIFT) +#define ARMV8M_FPSCR_LTPSIZE_MASK (0x7 << ARMV8M_FPSCR_LTPSIZE_SHIFT) #define ARMV8M_FPSCR_FZ16 (1 << 19) /* Bit 19: Flush-to-zero mode(half-precision) */ diff --git a/arch/arm/src/armv8-m/vfork.S b/arch/arm/src/armv8-m/vfork.S deleted file mode 100644 index 7f68b3b777cb1..0000000000000 --- a/arch/arm/src/armv8-m/vfork.S +++ /dev/null @@ -1,127 +0,0 @@ -/**************************************************************************** - * arch/arm/src/armv8-m/vfork.S - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. The - * ASF licenses this file to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance with the - * License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - ****************************************************************************/ - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include - -#include "arm_vfork.h" - -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -/**************************************************************************** - * Public Symbols - ****************************************************************************/ - - .syntax unified - .thumb - .file "vfork.S" - .globl up_vfork - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: vfork - * - * Description: - * The vfork() function has the same effect as fork(), except that the - * behavior is undefined if the process created by vfork() either modifies - * any data other than a variable of type pid_t used to store the return - * value from vfork(), or returns from the function in which vfork() was - * called, or calls any other function before successfully calling _exit() - * or one of the exec family of functions. - * - * This thin layer implements vfork by simply calling up_vfork() with the - * vfork() context as an argument. The overall sequence is: - * - * 1) User code calls vfork(). vfork() collects context information and - * transfers control up up_vfork(). - * 2) up_vfork() and calls nxtask_setup_vfork(). - * 3) nxtask_setup_vfork() allocates and configures the child task's TCB. - * This consists of: - * - Allocation of the child task's TCB. - * - Initialization of file descriptors and streams - * - Configuration of environment variables - * - Allocate and initialize the stack - * - Setup the input parameters for the task. - * - Initialization of the TCB (including call to up_initial_state()) - * 4) up_vfork() provides any additional operating context. up_vfork must: - * - Initialize special values in any CPU registers that were not - * already configured by up_initial_state() - * 5) up_vfork() then calls nxtask_start_vfork() - * 6) nxtask_start_vfork() then executes the child thread. - * - * Input Parameters: - * None - * - * Returned Value: - * Upon successful completion, vfork() returns 0 to the child process and - * returns the process ID of the child process to the parent process. - * Otherwise, -1 is returned to the parent, no child process is created, - * and errno is set to indicate the error. - * - ****************************************************************************/ - - .thumb_func - .globl vfork - .type vfork, function -vfork: - /* Create a stack frame */ - - mov r0, sp /* Save the value of the stack on entry */ - sub sp, sp, #VFORK_SIZEOF /* Allocate the structure on the stack */ - - /* CPU registers */ - /* Save the volatile registers */ - - str r4, [sp, #VFORK_R4_OFFSET] - str r5, [sp, #VFORK_R5_OFFSET] - str r6, [sp, #VFORK_R6_OFFSET] - str r7, [sp, #VFORK_R7_OFFSET] - str r8, [sp, #VFORK_R8_OFFSET] - str r9, [sp, #VFORK_R9_OFFSET] - str r10, [sp, #VFORK_R10_OFFSET] - - /* Save the frame pointer, stack pointer, and return address */ - - str fp, [sp, #VFORK_FP_OFFSET] - str r0, [sp, #VFORK_SP_OFFSET] - str lr, [sp, #VFORK_LR_OFFSET] - - /* Floating point registers (not yet) */ - - /* Then, call up_vfork(), passing it a pointer to the stack structure */ - - mov r0, sp - bl up_vfork - - /* Release the stack data and return the value returned by up_vfork */ - - ldr lr, [sp, #VFORK_LR_OFFSET] - add sp, sp, #VFORK_SIZEOF - bx lr - .size vfork, .-vfork - .end diff --git a/arch/arm/src/c5471/Make.defs b/arch/arm/src/c5471/Make.defs index affa2f5936a2e..b79fb2d35ee4d 100644 --- a/arch/arm/src/c5471/Make.defs +++ b/arch/arm/src/c5471/Make.defs @@ -18,26 +18,9 @@ # ############################################################################ -HEAD_ASRC = arm_nommuhead.S +include arm/Make.defs -CMN_ASRCS = arm_saveusercontext.S arm_fullcontextrestore.S vfork.S - -CMN_CSRCS = arm_allocateheap.c arm_assert.c arm_blocktask.c -CMN_CSRCS += arm_createstack.c arm_dataabort.c arm_mdelay.c arm_udelay.c arm_doirq.c -CMN_CSRCS += arm_exit.c arm_initialize.c arm_initialstate.c arm_interruptcontext.c -CMN_CSRCS += arm_prefetchabort.c arm_releasepending.c arm_releasestack.c -CMN_CSRCS += arm_reprioritizertr.c arm_schedulesigaction.c arm_sigdeliver.c -CMN_CSRCS += arm_stackframe.c arm_syscall.c arm_unblocktask.c arm_undefinedinsn.c -CMN_CSRCS += arm_usestack.c arm_vfork.c arm_puts.c arm_tcbinfo.c -CMN_CSRCS += arm_switchcontext.c - -ifneq ($(CONFIG_ARCH_IDLE_CUSTOM),y) -CMN_CSRCS += arm_idle.c -endif - -ifeq ($(CONFIG_STACK_COLORATION),y) -CMN_CSRCS += arm_checkstack.c -endif +HEAD_ASRC = arm_nommuhead.S CHIP_ASRCS = c5471_lowputc.S c5471_vectors.S CHIP_CSRCS = c5471_irq.c c5471_serial.c c5471_watchdog.c c5471_ethernet.c diff --git a/arch/arm/src/common/Make.defs b/arch/arm/src/common/Make.defs new file mode 100644 index 0000000000000..f8f3b1229b345 --- /dev/null +++ b/arch/arm/src/common/Make.defs @@ -0,0 +1,86 @@ +############################################################################ +# arch/arm/src/common/Make.defs +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. The +# ASF licenses this file to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance with the +# License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +# +############################################################################ + +# Common ARM files + +CMN_CSRCS += arm_allocateheap.c arm_assert.c arm_blocktask.c +CMN_CSRCS += arm_createstack.c arm_exit.c arm_fullcontextrestore.c +CMN_CSRCS += arm_initialize.c arm_interruptcontext.c arm_lowputs.c +CMN_CSRCS += arm_mdelay.c arm_modifyreg16.c arm_modifyreg32.c +CMN_CSRCS += arm_modifyreg8.c arm_puts.c arm_releasepending.c +CMN_CSRCS += arm_releasestack.c arm_reprioritizertr.c arm_saveusercontext.c +CMN_CSRCS += arm_stackframe.c arm_switchcontext.c arm_udelay.c +CMN_CSRCS += arm_vfork.c arm_unblocktask.c arm_usestack.c + +ifeq ($(CONFIG_STACK_COLORATION),y) + CMN_CSRCS += arm_checkstack.c +endif + +ifneq ($(CONFIG_ARCH_IDLE_CUSTOM),y) + CMN_CSRCS += arm_idle.c +endif + +ifeq ($(CONFIG_BUILD_PROTECTED)$(CONFIG_BUILD_KERNEL),y) + CMN_CSRCS += arm_task_start.c arm_pthread_start.c + CMN_CSRCS += arm_signal_dispatch.c + ifeq ($(CONFIG_BUILD_PROTECTED),y) + CMN_UASRCS += arm_signal_handler.S + endif +endif + +ifeq ($(CONFIG_ARM_SEMIHOSTING_SYSLOG),y) + CMN_CSRCS += arm_semi_syslog.c +endif + +ifeq ($(CONFIG_ARM_SEMIHOSTING_HOSTFS),y) + CMN_CSRCS += arm_hostfs.c +endif + +ifeq ($(CONFIG_SCHED_THREAD_LOCAL),y) + CMN_CSRCS += arm_tls.c +endif + +ifeq ($(CONFIG_SCHED_BACKTRACE),y) + ifeq ($(CONFIG_FRAME_POINTER),y) + CMN_CSRCS += arm_backtrace_fp.c + else + CMN_CSRCS += arm_backtrace_thumb.c + endif +endif + +CMN_ASRCS += vfork.S +ifeq ($(CONFIG_ARCH_HAVE_TESTSET),y) + ifeq ($(CONFIG_ARCH_ARMV6M),) + CMN_ASRCS += arm_testset.S + endif +endif +ifeq ($(CONFIG_ARCH_HAVE_FETCHADD),y) + CMN_ASRCS += arm_fetchadd.S +endif + +# Use of common/arm_etherstub.c is deprecated. The preferred mechanism is to +# use CONFIG_NETDEV_LATEINIT=y to suppress the call to arm_netinitialize() in +# up_initialize(). Then this stub would not be needed. + +ifeq ($(CONFIG_NET),y) + ifneq ($(CONFIG_ARCH_HAVE_PHY),y) + CMN_CSRCS += arm_etherstub.c + endif +endif diff --git a/arch/arm/src/common/arm_allocateheap.c b/arch/arm/src/common/arm_allocateheap.c index 28fffbdcb11dc..83b878423a482 100644 --- a/arch/arm/src/common/arm_allocateheap.c +++ b/arch/arm/src/common/arm_allocateheap.c @@ -103,9 +103,9 @@ ****************************************************************************/ #ifdef CONFIG_BUILD_KERNEL -void up_allocate_kheap(FAR void **heap_start, size_t *heap_size) +void up_allocate_kheap(void **heap_start, size_t *heap_size) #else -void up_allocate_heap(FAR void **heap_start, size_t *heap_size) +void up_allocate_heap(void **heap_start, size_t *heap_size) #endif { #if defined(CONFIG_BUILD_PROTECTED) && defined(CONFIG_MM_KERNEL_HEAP) @@ -123,14 +123,14 @@ void up_allocate_heap(FAR void **heap_start, size_t *heap_size) /* Return the user-space heap settings */ board_autoled_on(LED_HEAPALLOCATE); - *heap_start = (FAR void *)ubase; + *heap_start = (void *)ubase; *heap_size = usize; #else /* Return the heap settings */ board_autoled_on(LED_HEAPALLOCATE); - *heap_start = (FAR void *)g_idle_topstack; + *heap_start = (void *)g_idle_topstack; *heap_size = CONFIG_RAM_END - g_idle_topstack; #endif } @@ -147,7 +147,7 @@ void up_allocate_heap(FAR void **heap_start, size_t *heap_size) ****************************************************************************/ #if defined(CONFIG_BUILD_PROTECTED) && defined(CONFIG_MM_KERNEL_HEAP) -void up_allocate_kheap(FAR void **heap_start, size_t *heap_size) +void up_allocate_kheap(void **heap_start, size_t *heap_size) { /* Get the unaligned size and position of the user-space heap. * This heap begins after the user-space .bss section at an offset @@ -162,7 +162,7 @@ void up_allocate_kheap(FAR void **heap_start, size_t *heap_size) * that was not dedicated to the user heap). */ - *heap_start = (FAR void *)USERSPACE->us_bssend; + *heap_start = (void *)USERSPACE->us_bssend; *heap_size = ubase - (uintptr_t)USERSPACE->us_bssend; } #endif diff --git a/arch/arm/src/common/arm_assert.c b/arch/arm/src/common/arm_assert.c index ee6306170d175..8be91268143ab 100644 --- a/arch/arm/src/common/arm_assert.c +++ b/arch/arm/src/common/arm_assert.c @@ -76,7 +76,9 @@ static void arm_stackdump(uint32_t sp, uint32_t stack_top) for (stack = sp & ~0x1f; stack < (stack_top & ~0x1f); stack += 32) { uint32_t *ptr = (uint32_t *)stack; - _alert("%08x: %08x %08x %08x %08x %08x %08x %08x %08x\n", + _alert("%08" PRIx32 ": %08" PRIx32 " %08" PRIx32 " %08" PRIx32 + " %08" PRIx32 " %08" PRIx32 " %08" PRIx32 " %08" PRIx32 + " %08" PRIx32 "\n", stack, ptr[0], ptr[1], ptr[2], ptr[3], ptr[4], ptr[5], ptr[6], ptr[7]); } @@ -86,38 +88,46 @@ static void arm_stackdump(uint32_t sp, uint32_t stack_top) * Name: arm_registerdump ****************************************************************************/ -static void arm_registerdump(FAR volatile uint32_t *regs) +static void arm_registerdump(volatile uint32_t *regs) { /* Dump the interrupt registers */ - _alert("R0: %08x R1: %08x R2: %08x R3: %08x\n", + _alert("R0: %08" PRIx32 " R1: %08" PRIx32 + " R2: %08" PRIx32 " R3: %08" PRIx32 "\n", regs[REG_R0], regs[REG_R1], regs[REG_R2], regs[REG_R3]); #ifdef CONFIG_ARM_THUMB - _alert("R4: %08x R5: %08x R6: %08x FP: %08x\n", + _alert("R4: %08" PRIx32 " R5: %08" PRIx32 + " R6: %08" PRIx32 " FP: %08" PRIx32 "\n", regs[REG_R4], regs[REG_R5], regs[REG_R6], regs[REG_R7]); - _alert("R8: %08x SB: %08x SL: %08x R11: %08x\n", + _alert("R8: %08" PRIx32 " SB: %08" PRIx32 + " SL: %08" PRIx32 " R11: %08" PRIx32 "\n", regs[REG_R8], regs[REG_R9], regs[REG_R10], regs[REG_R11]); #else - _alert("R4: %08x R5: %08x R6: %08x R7: %08x\n", + _alert("R4: %08" PRIx32 " R5: %08" PRIx32 + " R6: %08" PRIx32 " R7: %08" PRIx32 "\n", regs[REG_R4], regs[REG_R5], regs[REG_R6], regs[REG_R7]); - _alert("R8: %08x SB: %08x SL: %08x FP: %08x\n", + _alert("R8: %08" PRIx32 " SB: %08" PRIx32 + " SL: %08" PRIx32 " FP: %08" PRIx32 "\n", regs[REG_R8], regs[REG_R9], regs[REG_R10], regs[REG_R11]); #endif - _alert("IP: %08x SP: %08x LR: %08x PC: %08x\n", + _alert("IP: %08" PRIx32 " SP: %08" PRIx32 + " LR: %08" PRIx32 " PC: %08" PRIx32 "\n", regs[REG_R12], regs[REG_R13], regs[REG_R14], regs[REG_R15]); #if defined(REG_BASEPRI) - _alert("xPSR: %08x BASEPRI: %08x CONTROL: %08x\n", + _alert("xPSR: %08" PRIx32 " BASEPRI: %08" PRIx32 + " CONTROL: %08" PRIx32 "\n", regs[REG_XPSR], regs[REG_BASEPRI], getcontrol()); #elif defined(REG_PRIMASK) - _alert("xPSR: %08x PRIMASK: %08x CONTROL: %08x\n", + _alert("xPSR: %08" PRIx32 " PRIMASK: %08" PRIx32 + " CONTROL: %08" PRIx32 "\n", regs[REG_XPSR], regs[REG_PRIMASK], getcontrol()); #elif defined(REG_CPSR) - _alert("CPSR: %08x\n", regs[REG_CPSR]); + _alert("CPSR: %08" PRIx32 "\n", regs[REG_CPSR]); #endif #ifdef REG_EXC_RETURN - _alert("EXC_RETURN: %08x\n", regs[REG_EXC_RETURN]); + _alert("EXC_RETURN: %08" PRIx32 "\n", regs[REG_EXC_RETURN]); #endif } @@ -125,7 +135,7 @@ static void arm_registerdump(FAR volatile uint32_t *regs) * Name: arm_dump_task ****************************************************************************/ -static void arm_dump_task(FAR struct tcb_s *tcb, FAR void *arg) +static void arm_dump_task(struct tcb_s *tcb, void *arg) { #ifdef CONFIG_STACK_COLORATION uint32_t stack_filled = 0; @@ -208,7 +218,7 @@ static void arm_dump_task(FAR struct tcb_s *tcb, FAR void *arg) ****************************************************************************/ #ifdef CONFIG_SCHED_BACKTRACE -static void arm_dump_backtrace(FAR struct tcb_s *tcb, FAR void *arg) +static void arm_dump_backtrace(struct tcb_s *tcb, void *arg) { /* Show back trace */ @@ -299,7 +309,7 @@ static void arm_showtasks(void) ****************************************************************************/ #ifdef CONFIG_ARCH_USBDUMP -static int usbtrace_syslog(FAR const char *fmt, ...) +static int usbtrace_syslog(const char *fmt, ...) { va_list ap; @@ -311,7 +321,7 @@ static int usbtrace_syslog(FAR const char *fmt, ...) return OK; } -static int assert_tracecallback(FAR struct usbtrace_s *trace, FAR void *arg) +static int assert_tracecallback(struct usbtrace_s *trace, void *arg) { usbtrace_trprintf(usbtrace_syslog, trace->event, trace->value); return 0; @@ -328,9 +338,9 @@ static void arm_dump_stack(const char *tag, uint32_t sp, uint32_t top = base + size; _alert("%s Stack:\n", tag); - _alert("sp: %08x\n", sp); - _alert(" base: %08x\n", base); - _alert(" size: %08x\n", size); + _alert("sp: %08" PRIx32 "\n", sp); + _alert(" base: %08" PRIx32 "\n", base); + _alert(" size: %08" PRIx32 "\n", size); if (sp >= base && sp < top) { @@ -353,7 +363,7 @@ static void arm_dump_stack(const char *tag, uint32_t sp, static void arm_dumpstate(void) { - FAR struct tcb_s *rtcb = running_task(); + struct tcb_s *rtcb = running_task(); uint32_t sp = up_getsp(); /* Show back trace */ @@ -366,12 +376,11 @@ static void arm_dumpstate(void) if (CURRENT_REGS) { - memcpy(rtcb->xcp.regs, - (FAR uintptr_t *)CURRENT_REGS, XCPTCONTEXT_SIZE); + rtcb->xcp.regs = (uint32_t *)CURRENT_REGS; } else { - arm_saveusercontext(rtcb->xcp.regs); + up_saveusercontext(rtcb->xcp.regs); } /* Dump the registers */ diff --git a/arch/arm/src/common/arm_backtrace_fp.c b/arch/arm/src/common/arm_backtrace_fp.c index 6e3950fc9fd67..d1273882fd036 100644 --- a/arch/arm/src/common/arm_backtrace_fp.c +++ b/arch/arm/src/common/arm_backtrace_fp.c @@ -46,9 +46,9 @@ #ifdef CONFIG_MM_KASAN __attribute__((no_sanitize_address)) #endif -static int backtrace(FAR uintptr_t *base, FAR uintptr_t *limit, - FAR uintptr_t *fp, FAR uintptr_t *pc, - FAR void **buffer, int size, FAR int *skip) +static int backtrace(uintptr_t *base, uintptr_t *limit, + uintptr_t *fp, uintptr_t *pc, + void **buffer, int size, int *skip) { int i = 0; @@ -61,7 +61,7 @@ static int backtrace(FAR uintptr_t *base, FAR uintptr_t *limit, } } - for (; i < size; fp = (FAR uintptr_t *)*(fp - 1), i++) + for (; i < size; fp = (uintptr_t *)*(fp - 1), i++) { if (fp > limit || fp < base || *fp == 0) { @@ -70,7 +70,7 @@ static int backtrace(FAR uintptr_t *base, FAR uintptr_t *limit, if (*skip-- <= 0) { - *buffer++ = (FAR void *)*fp; + *buffer++ = (void *)*fp; } } @@ -109,12 +109,12 @@ static int backtrace(FAR uintptr_t *base, FAR uintptr_t *limit, #ifdef CONFIG_MM_KASAN __attribute__((no_sanitize_address)) #endif -int up_backtrace(FAR struct tcb_s *tcb, - FAR void **buffer, int size, int skip) +int up_backtrace(struct tcb_s *tcb, + void **buffer, int size, int skip) { - FAR struct tcb_s *rtcb = running_task(); + struct tcb_s *rtcb = running_task(); #if CONFIG_ARCH_INTERRUPTSTACK > 7 - FAR void *istacklimit; + void *istacklimit; #endif irqstate_t flags; int ret; @@ -136,20 +136,20 @@ int up_backtrace(FAR struct tcb_s *tcb, # endif /* CONFIG_SMP */ ret = backtrace(istacklimit - (CONFIG_ARCH_INTERRUPTSTACK & ~7), istacklimit, - (FAR void *)__builtin_frame_address(0), + (void *)__builtin_frame_address(0), NULL, buffer, size, &skip); #else ret = backtrace(rtcb->stack_base_ptr, rtcb->stack_base_ptr + rtcb->adj_stack_size, - (FAR void *)__builtin_frame_address(0), + (void *)__builtin_frame_address(0), NULL, buffer, size, &skip); #endif /* CONFIG_ARCH_INTERRUPTSTACK > 7 */ if (ret < size) { ret += backtrace(rtcb->stack_base_ptr, rtcb->stack_base_ptr + rtcb->adj_stack_size, - (FAR void *)CURRENT_REGS[REG_FP], - (FAR void *)CURRENT_REGS[REG_PC], + (void *)CURRENT_REGS[REG_FP], + (void *)CURRENT_REGS[REG_PC], &buffer[ret], size - ret, &skip); } } @@ -157,7 +157,7 @@ int up_backtrace(FAR struct tcb_s *tcb, { ret = backtrace(rtcb->stack_base_ptr, rtcb->stack_base_ptr + rtcb->adj_stack_size, - (FAR void *)__builtin_frame_address(0), + (void *)__builtin_frame_address(0), NULL, buffer, size, &skip); } } @@ -167,8 +167,8 @@ int up_backtrace(FAR struct tcb_s *tcb, ret = backtrace(tcb->stack_base_ptr, tcb->stack_base_ptr + tcb->adj_stack_size, - (FAR void *)tcb->xcp.regs[REG_FP], - (FAR void *)tcb->xcp.regs[REG_PC], + (void *)tcb->xcp.regs[REG_FP], + (void *)tcb->xcp.regs[REG_PC], buffer, size, &skip); leave_critical_section(flags); diff --git a/arch/arm/src/common/arm_backtrace_thumb.c b/arch/arm/src/common/arm_backtrace_thumb.c index 00b587a1a7a75..8e4497fa04cbe 100644 --- a/arch/arm/src/common/arm_backtrace_thumb.c +++ b/arch/arm/src/common/arm_backtrace_thumb.c @@ -79,7 +79,7 @@ * Private Data ****************************************************************************/ -static FAR void **g_backtrace_code_regions; +static void **g_backtrace_code_regions; /**************************************************************************** * Private Functions @@ -102,16 +102,16 @@ static FAR void **g_backtrace_code_regions; #ifdef CONFIG_MM_KASAN __attribute__((no_sanitize_address)) #endif -static int getlroffset(FAR uint8_t *lr) +static int getlroffset(uint8_t *lr) { - lr = (FAR uint8_t *)((uintptr_t)lr & 0xfffffffe); + lr = (uint8_t *)((uintptr_t)lr & 0xfffffffe); if (((uintptr_t)lr & 0xffffffe0) == 0xffffffe0) { return 0; } - return (*(FAR uint16_t *)(lr - 4) & 0xf000) == 0xf000 ? 5 : 3; + return (*(uint16_t *)(lr - 4) & 0xf000) == 0xf000 ? 5 : 3; } /**************************************************************************** @@ -133,7 +133,7 @@ static int getlroffset(FAR uint8_t *lr) #ifdef CONFIG_MM_KASAN __attribute__((no_sanitize_address)) #endif -static bool in_code_region(FAR void *pc) +static bool in_code_region(void *pc) { int i = 0; @@ -184,13 +184,12 @@ static bool in_code_region(FAR void *pc) #ifdef CONFIG_MM_KASAN __attribute__((no_sanitize_address)) #endif -static FAR void *backtrace_push_internal(FAR void **psp, - FAR void **ppc) +static void *backtrace_push_internal(void **psp, void **ppc) { - FAR uint8_t *sp = *psp; - FAR uint8_t *pc = *ppc; - FAR uint8_t *base; - FAR uint8_t *lr; + uint8_t *sp = *psp; + uint8_t *pc = *ppc; + uint8_t *base; + uint8_t *lr; uint32_t ins32; uint16_t ins16; int offset = 1; @@ -199,11 +198,11 @@ static FAR void *backtrace_push_internal(FAR void **psp, for (i = 0; i < INSTR_LIMIT; i += 2) { - ins16 = *(FAR uint16_t *)(pc - i); + ins16 = *(uint16_t *)(pc - i); if (INSTR_IS(ins16, T_PUSH)) { frame = __builtin_popcount(ins16 & 0xff) + 1; - ins16 = *(FAR uint16_t *)(pc - i - 2); + ins16 = *(uint16_t *)(pc - i - 2); if (INSTR_IS(ins16, T_PUSH_LO)) { offset += __builtin_popcount(ins16 & 0xff); @@ -214,11 +213,11 @@ static FAR void *backtrace_push_internal(FAR void **psp, } ins32 = ins16 << 16; - ins32 |= *(FAR uint16_t *)(pc - i + 2); + ins32 |= *(uint16_t *)(pc - i + 2); if (INSTR_IS(ins32, T_STMDB)) { frame = __builtin_popcount(ins32 & 0xfff) + 1; - ins16 = *(FAR uint16_t *)(pc - i - 2); + ins16 = *(uint16_t *)(pc - i - 2); if (INSTR_IS(ins16, T_PUSH_LO)) { offset += __builtin_popcount(ins16 & 0xff); @@ -238,7 +237,7 @@ static FAR void *backtrace_push_internal(FAR void **psp, for (i = 0; i < INSTR_LIMIT && base + i < pc; ) { - ins16 = *(FAR uint16_t *)(base + i); + ins16 = *(uint16_t *)(base + i); if (INSTR_IS(ins16, T_SUB_SP_16)) { frame += (ins16 & 0x7f); @@ -246,7 +245,7 @@ static FAR void *backtrace_push_internal(FAR void **psp, } ins32 = ins16 << 16; - ins32 |= *(FAR uint16_t *)(base + i + 2); + ins32 |= *(uint16_t *)(base + i + 2); if (INSTR_IS(ins32, T_SUB_SP_32)) { uint32_t shift = ins32 >> 24 & 0x4; @@ -286,7 +285,7 @@ static FAR void *backtrace_push_internal(FAR void **psp, i += ((ins16 & 0xf800) >= 0xe800) ? 4 : 2; } - lr = (FAR uint8_t *)*((FAR uint32_t *)sp + frame - offset); + lr = (uint8_t *)*((uint32_t *)sp + frame - offset); if (!in_code_region(lr)) { return NULL; @@ -298,7 +297,7 @@ static FAR void *backtrace_push_internal(FAR void **psp, return NULL; } - *psp = (FAR uint32_t *)sp + frame; + *psp = (uint32_t *)sp + frame; *ppc = lr - offset; return *ppc; @@ -315,8 +314,8 @@ static FAR void *backtrace_push_internal(FAR void **psp, #ifdef CONFIG_MM_KASAN __attribute__((no_sanitize_address)) #endif -static int backtrace_push(FAR void *limit, FAR void **sp, FAR void *pc, - FAR void **buffer, int size, FAR int *skip) +static int backtrace_push(void *limit, void **sp, void *pc, + void **buffer, int size, int *skip) { int i = 0; @@ -325,7 +324,7 @@ static int backtrace_push(FAR void *limit, FAR void **sp, FAR void *pc, return 0; } - pc = (FAR void *)((uintptr_t)pc & 0xfffffffe); + pc = (void *)((uintptr_t)pc & 0xfffffffe); if ((*skip)-- <= 0) { @@ -365,8 +364,8 @@ static int backtrace_push(FAR void *limit, FAR void **sp, FAR void *pc, #ifdef CONFIG_MM_KASAN __attribute__((no_sanitize_address)) #endif -static int backtrace_branch(FAR void *limit, FAR void *sp, - FAR void **buffer, int size, FAR int *skip) +static int backtrace_branch(void *limit, void *sp, + void **buffer, int size, int *skip) { uint16_t ins16; uint32_t addr; @@ -374,19 +373,19 @@ static int backtrace_branch(FAR void *limit, FAR void *sp, for (i = 0; i < size && sp < limit; sp += sizeof(uint32_t)) { - addr = *(FAR uint32_t *)sp; - if (!in_code_region((FAR void *)addr)) + addr = *(uint32_t *)sp; + if (!in_code_region((void *)addr)) { continue; } addr = (addr & ~1) - 2; - ins16 = *(FAR uint16_t *)addr; + ins16 = *(uint16_t *)addr; if (INSTR_IS(ins16, T_BLX)) { if ((*skip)-- <= 0) { - buffer[i++] = (FAR void *)addr; + buffer[i++] = (void *)addr; } } @@ -400,12 +399,12 @@ static int backtrace_branch(FAR void *limit, FAR void *sp, else if ((ins16 & 0xd000) == 0xd000) { addr -= 2; - ins16 = *(FAR uint16_t *)addr; + ins16 = *(uint16_t *)addr; if (INSTR_IS(ins16, T_BL)) { if ((*skip)-- <= 0) { - buffer[i++] = (FAR void *)addr; + buffer[i++] = (void *)addr; } } } @@ -449,7 +448,7 @@ static int backtrace_branch(FAR void *limit, FAR void *sp, #ifdef CONFIG_MM_KASAN __attribute__((no_sanitize_address)) #endif -void up_backtrace_init_code_regions(FAR void **regions) +void up_backtrace_init_code_regions(void **regions) { g_backtrace_code_regions = regions; } @@ -481,12 +480,12 @@ void up_backtrace_init_code_regions(FAR void **regions) #ifdef CONFIG_MM_KASAN __attribute__((no_sanitize_address)) #endif -int up_backtrace(FAR struct tcb_s *tcb, - FAR void **buffer, int size, FAR int skip) +int up_backtrace(struct tcb_s *tcb, + void **buffer, int size, int skip) { - FAR struct tcb_s *rtcb = running_task(); + struct tcb_s *rtcb = running_task(); irqstate_t flags; - FAR void *sp; + void *sp; int ret; if (size <= 0 || !buffer) @@ -501,7 +500,7 @@ int up_backtrace(FAR struct tcb_s *tcb, if (tcb == rtcb) { - sp = (FAR void *)up_getsp(); + sp = (void *)up_getsp(); if (up_interrupt_context()) { @@ -512,20 +511,20 @@ int up_backtrace(FAR struct tcb_s *tcb, # else &g_intstacktop, # endif /* CONFIG_SMP */ - &sp, (FAR void *)up_backtrace + 10, + &sp, (void *)up_backtrace + 10, buffer, size, &skip); #else ret = backtrace_push(rtcb->stack_base_ptr + rtcb->adj_stack_size, - &sp, (FAR void *)up_backtrace + 10, + &sp, (void *)up_backtrace + 10, buffer, size, &skip); #endif if (ret < size) { - sp = (FAR void *)CURRENT_REGS[REG_SP]; + sp = (void *)CURRENT_REGS[REG_SP]; ret += backtrace_push(rtcb->stack_base_ptr + rtcb->adj_stack_size, &sp, - (FAR void *)CURRENT_REGS[REG_PC], + (void *)CURRENT_REGS[REG_PC], &buffer[ret], size - ret, &skip); } } @@ -533,7 +532,7 @@ int up_backtrace(FAR struct tcb_s *tcb, { ret = backtrace_push(rtcb->stack_base_ptr + rtcb->adj_stack_size, &sp, - (FAR void *)up_backtrace + 10, + (void *)up_backtrace + 10, buffer, size, &skip); } @@ -550,14 +549,14 @@ int up_backtrace(FAR struct tcb_s *tcb, flags = enter_critical_section(); - buffer[ret++] = (FAR void *)tcb->xcp.regs[REG_PC]; + buffer[ret++] = (void *)tcb->xcp.regs[REG_PC]; if (ret < size) { - sp = (FAR void *)tcb->xcp.regs[REG_SP]; + sp = (void *)tcb->xcp.regs[REG_SP]; ret += backtrace_push(tcb->stack_base_ptr + tcb->adj_stack_size, &sp, - (FAR void *)tcb->xcp.regs[REG_LR], + (void *)tcb->xcp.regs[REG_LR], &buffer[ret], size - ret, &skip); if (ret < size) diff --git a/arch/arm/src/common/arm_blocktask.c b/arch/arm/src/common/arm_blocktask.c index 46986634c00e5..dd8cb365a1022 100644 --- a/arch/arm/src/common/arm_blocktask.c +++ b/arch/arm/src/common/arm_blocktask.c @@ -131,15 +131,6 @@ void up_block_task(struct tcb_s *tcb, tstate_t task_state) { struct tcb_s *nexttcb = this_task(); -#ifdef CONFIG_ARCH_ADDRENV - /* Make sure that the address environment for the previously - * running task is closed down gracefully (data caches dump, - * MMU flushed) and set up the address environment for the new - * thread at the head of the ready-to-run list. - */ - - group_addrenv(nexttcb); -#endif /* Reset scheduler parameters */ nxsched_resume_scheduler(nexttcb); diff --git a/arch/arm/src/common/arm_checkstack.c b/arch/arm/src/common/arm_checkstack.c index 87384c56e742b..a762ec6f7913e 100644 --- a/arch/arm/src/common/arm_checkstack.c +++ b/arch/arm/src/common/arm_checkstack.c @@ -38,22 +38,6 @@ #ifdef CONFIG_STACK_COLORATION -/**************************************************************************** - * Pre-processor Macros - ****************************************************************************/ - -/* 32bit alignment macros */ - -#define INT32_ALIGN_MASK (3) -#define INT32_ALIGN_DOWN(a) ((a) & ~INT32_ALIGN_MASK) -#define INT32_ALIGN_UP(a) (((a) + INT32_ALIGN_MASK) & ~INT32_ALIGN_MASK) - -/**************************************************************************** - * Private Function Prototypes - ****************************************************************************/ - -static size_t do_stackcheck(FAR void *stackbase, size_t nbytes); - /**************************************************************************** * Private Functions ****************************************************************************/ @@ -75,11 +59,11 @@ static size_t do_stackcheck(FAR void *stackbase, size_t nbytes); * ****************************************************************************/ -static size_t do_stackcheck(FAR void *stackbase, size_t nbytes) +static size_t do_stackcheck(void *stackbase, size_t nbytes) { uintptr_t start; uintptr_t end; - FAR uint32_t *ptr; + uint32_t *ptr; size_t mark; if (nbytes == 0) @@ -89,8 +73,8 @@ static size_t do_stackcheck(FAR void *stackbase, size_t nbytes) /* Take extra care that we do not check outside the stack boundaries */ - start = INT32_ALIGN_UP((uintptr_t)stackbase); - end = INT32_ALIGN_DOWN((uintptr_t)stackbase + nbytes); + start = STACK_ALIGN_UP((uintptr_t)stackbase); + end = STACK_ALIGN_DOWN((uintptr_t)stackbase + nbytes); /* Get the adjusted size based on the top and bottom of the stack */ @@ -102,7 +86,7 @@ static size_t do_stackcheck(FAR void *stackbase, size_t nbytes) * that does not have the magic value is the high water mark. */ - for (ptr = (FAR uint32_t *)start, mark = (nbytes >> 2); + for (ptr = (uint32_t *)start, mark = (nbytes >> 2); *ptr == STACK_COLOR && mark > 0; ptr++, mark--); @@ -122,7 +106,7 @@ static size_t do_stackcheck(FAR void *stackbase, size_t nbytes) int i; int j; - ptr = (FAR uint32_t *)start; + ptr = (uint32_t *)start; for (i = 0; i < nbytes; i += 4 * 64) { for (j = 0; j < 64; j++) @@ -162,29 +146,38 @@ static size_t do_stackcheck(FAR void *stackbase, size_t nbytes) * ****************************************************************************/ -void arm_stack_color(FAR void *stackbase, size_t nbytes) +void arm_stack_color(void *stackbase, size_t nbytes) { - uintptr_t start; - uintptr_t end; - size_t nwords; - FAR uint32_t *ptr; + uint32_t *stkptr; + uintptr_t stkend; + size_t nwords; + uintptr_t sp; /* Take extra care that we do not write outside the stack boundaries */ - start = INT32_ALIGN_UP((uintptr_t)stackbase); - end = nbytes ? INT32_ALIGN_DOWN((uintptr_t)stackbase + nbytes) : - up_getsp(); /* 0: colorize the running stack */ + stkptr = (uint32_t *)STACK_ALIGN_UP((uintptr_t)stackbase); - /* Get the adjusted size based on the top and bottom of the stack */ + if (nbytes == 0) /* 0: colorize the running stack */ + { + stkend = up_getsp(); + if (stkend > (uintptr_t)&sp) + { + stkend = (uintptr_t)&sp; + } + } + else + { + stkend = (uintptr_t)stackbase + nbytes; + } - nwords = (end - start) >> 2; - ptr = (FAR uint32_t *)start; + stkend = STACK_ALIGN_DOWN(stkend); + nwords = (stkend - (uintptr_t)stackbase) >> 2; /* Set the entire stack to the coloration value */ while (nwords-- > 0) { - *ptr++ = STACK_COLOR; + *stkptr++ = STACK_COLOR; } } @@ -204,12 +197,12 @@ void arm_stack_color(FAR void *stackbase, size_t nbytes) * ****************************************************************************/ -size_t up_check_tcbstack(FAR struct tcb_s *tcb) +size_t up_check_tcbstack(struct tcb_s *tcb) { return do_stackcheck(tcb->stack_base_ptr, tcb->adj_stack_size); } -ssize_t up_check_tcbstack_remain(FAR struct tcb_s *tcb) +ssize_t up_check_tcbstack_remain(struct tcb_s *tcb) { return tcb->adj_stack_size - up_check_tcbstack(tcb); } @@ -228,17 +221,17 @@ ssize_t up_check_stack_remain(void) size_t up_check_intstack(void) { #ifdef CONFIG_SMP - return do_stackcheck((FAR void *)arm_intstack_alloc(), - INT32_ALIGN_DOWN(CONFIG_ARCH_INTERRUPTSTACK)); + return do_stackcheck((void *)arm_intstack_alloc(), + STACK_ALIGN_DOWN(CONFIG_ARCH_INTERRUPTSTACK)); #else - return do_stackcheck((FAR void *)&g_intstackalloc, - INT32_ALIGN_DOWN(CONFIG_ARCH_INTERRUPTSTACK)); + return do_stackcheck((void *)&g_intstackalloc, + STACK_ALIGN_DOWN(CONFIG_ARCH_INTERRUPTSTACK)); #endif } size_t up_check_intstack_remain(void) { - return INT32_ALIGN_DOWN(CONFIG_ARCH_INTERRUPTSTACK) - up_check_intstack(); + return STACK_ALIGN_DOWN(CONFIG_ARCH_INTERRUPTSTACK) - up_check_intstack(); } #endif diff --git a/arch/arm/src/common/arm_createstack.c b/arch/arm/src/common/arm_createstack.c index 3a1c467b80cd4..1fb3c7abe12c4 100644 --- a/arch/arm/src/common/arm_createstack.c +++ b/arch/arm/src/common/arm_createstack.c @@ -81,7 +81,7 @@ * ****************************************************************************/ -int up_create_stack(FAR struct tcb_s *tcb, size_t stack_size, uint8_t ttype) +int up_create_stack(struct tcb_s *tcb, size_t stack_size, uint8_t ttype) { #ifdef CONFIG_TLS_ALIGNED /* The allocated stack size must not exceed the maximum possible for the diff --git a/arch/arm/src/common/arm_etherstub.c b/arch/arm/src/common/arm_etherstub.c index 205387754f327..d46699ea80844 100644 --- a/arch/arm/src/common/arm_etherstub.c +++ b/arch/arm/src/common/arm_etherstub.c @@ -50,6 +50,8 @@ * ****************************************************************************/ +#if defined(CONFIG_NET) && !defined(CONFIG_NETDEV_LATEINIT) void arm_netinitialize(void) { } +#endif diff --git a/arch/arm/src/common/arm_exit.c b/arch/arm/src/common/arm_exit.c index dfe2f3fb8f38c..972db8d265587 100644 --- a/arch/arm/src/common/arm_exit.c +++ b/arch/arm/src/common/arm_exit.c @@ -62,16 +62,16 @@ ****************************************************************************/ #ifdef CONFIG_DUMP_ON_EXIT -static void _up_dumponexit(FAR struct tcb_s *tcb, FAR void *arg) +static void _up_dumponexit(struct tcb_s *tcb, void *arg) { - FAR struct filelist *filelist; + struct filelist *filelist; int i; int j; sinfo(" TCB=%p name=%s pid=%d\n", tcb, tcb->name, tcb->pid); sinfo(" priority=%d state=%d\n", tcb->sched_priority, tcb->task_state); - filelist = tcb->group->tg_filelist; + filelist = &tcb->group->tg_filelist; for (i = 0; i < filelist->fl_rows; i++) { for (j = 0; j < CONFIG_NFILE_DESCRIPTORS_PER_BLOCK; j++) @@ -115,15 +115,15 @@ void up_exit(int status) sinfo("TCB=%p exiting\n", tcb); + /* Destroy the task at the head of the ready to run list. */ + + nxtask_exit(); + #ifdef CONFIG_DUMP_ON_EXIT sinfo("Other tasks:\n"); nxsched_foreach(_up_dumponexit, NULL); #endif - /* Destroy the task at the head of the ready to run list. */ - - nxtask_exit(); - /* Now, perform the context switch to the new ready-to-run task at the * head of the list. */ @@ -136,16 +136,6 @@ void up_exit(int status) nxsched_resume_scheduler(tcb); -#ifdef CONFIG_ARCH_ADDRENV - /* Make sure that the address environment for the previously running - * task is closed down gracefully (data caches dump, MMU flushed) and - * set up the address environment for the new thread at the head of - * the ready-to-run list. - */ - - group_addrenv(tcb); -#endif - /* Then switch contexts */ arm_fullcontextrestore(tcb->xcp.regs); diff --git a/arch/xtensa/src/common/xtensa_switchcontext.c b/arch/arm/src/common/arm_fullcontextrestore.c similarity index 81% rename from arch/xtensa/src/common/xtensa_switchcontext.c rename to arch/arm/src/common/arm_fullcontextrestore.c index 3aecda2a9986b..4ed95305b941c 100644 --- a/arch/xtensa/src/common/xtensa_switchcontext.c +++ b/arch/arm/src/common/arm_fullcontextrestore.c @@ -1,5 +1,5 @@ /**************************************************************************** - * arch/xtensa/src/common/xtensa_switchcontext.c + * arch/arm/src/common/arm_fullcontextrestore.c * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with @@ -24,24 +24,26 @@ #include -#include "syscall.h" +#include /**************************************************************************** * Public Functions ****************************************************************************/ /**************************************************************************** - * Name: xtensa_switchcontext + * Name: arm_fullcontextrestore * * Description: - * Save the current thread context and restore the specified context. + * Restore the current thread context. Full prototype is: + * + * void arm_fullcontextrestore(uint32_t *restoreregs) noreturn_function; * * Returned Value: * None * ****************************************************************************/ -void xtensa_switchcontext(uint32_t *saveregs, uint32_t *restoreregs) +void arm_fullcontextrestore(uint32_t *restoreregs) { - sys_call2(SYS_switch_context, (uintptr_t)saveregs, (uintptr_t)restoreregs); + sys_call1(SYS_restore_context, (uintptr_t)restoreregs); } diff --git a/arch/arm/src/common/arm_internal.h b/arch/arm/src/common/arm_internal.h index b78707f32a974..4bd18f6772236 100644 --- a/arch/arm/src/common/arm_internal.h +++ b/arch/arm/src/common/arm_internal.h @@ -89,67 +89,10 @@ #define INTSTACK_SIZE (CONFIG_ARCH_INTERRUPTSTACK & ~STACK_ALIGN_MASK) -/* Macros to handle saving and restoring interrupt state. In the current ARM - * model, the state is always copied to and from the stack and TCB. In the - * Cortex-M0/3 model, the state is copied from the stack to the TCB, but only - * a referenced is passed to get the state from the TCB. Cortex-M4 is the - * same, but may have additional complexity for floating point support in - * some configurations. - */ - -#if defined(CONFIG_ARCH_ARMV6M) || defined(CONFIG_ARCH_ARMV7M) || \ - defined(CONFIG_ARCH_ARMV8M) - - /* If the floating point unit is present and enabled, then save the - * floating point registers as well as normal ARM registers. This only - * applies if "lazy" floating point register save/restore is used - */ - -# if defined(CONFIG_ARCH_FPU) && (defined(CONFIG_ARMV7M_LAZYFPU) || \ - defined(CONFIG_ARMV8M_LAZYFPU)) -# define arm_savestate(regs) (regs = (FAR uint32_t *)CURRENT_REGS, arm_savefpu(regs)) -# else -# define arm_savestate(regs) (regs = (FAR uint32_t *)CURRENT_REGS) -# endif -# define arm_restorestate(regs) (CURRENT_REGS = regs) - -/* The Cortex-A and Cortex-R support the same mechanism, but only lazy - * floating point register save/restore. - */ - -#elif defined(CONFIG_ARCH_ARMV7A) || defined(CONFIG_ARCH_ARMV7R) - - /* If the floating point unit is present and enabled, then save the - * floating point registers as well as normal ARM registers. - */ +/* Macros to handle saving and restoring interrupt state. */ -# if defined(CONFIG_ARCH_FPU) -# define arm_savestate(regs) (regs = (FAR uint32_t *)CURRENT_REGS, arm_savefpu(regs)) -# else -# define arm_savestate(regs) (regs = (FAR uint32_t *)CURRENT_REGS) -# endif -# define arm_restorestate(regs) (CURRENT_REGS = regs) - -/* Otherwise, for the ARM7 and ARM9. The state is copied in full from stack - * to stack. This is not very efficient and should be fixed to match - * Cortex-A5. - */ - -#else - - /* If the floating point unit is present and enabled, then save the - * floating point registers as well as normal ARM registers. Only "lazy" - * floating point save/restore is supported. - */ - -# if defined(CONFIG_ARCH_FPU) -# define arm_savestate(regs) (regs = (FAR uint32_t *)CURRENT_REGS, arm_savefpu(regs)) -# else -# define arm_savestate(regs) (regs = (FAR uint32_t *)CURRENT_REGS) -# endif -# define arm_restorestate(regs) (CURRENT_REGS = regs) - -#endif +#define arm_savestate(regs) (regs = (uint32_t *)CURRENT_REGS) +#define arm_restorestate(regs) (CURRENT_REGS = regs) /* Toolchain dependent, linker defined section addresses */ @@ -328,7 +271,6 @@ void arm_boot(void); /* Context switching */ uint32_t *arm_decodeirq(uint32_t *regs); -int arm_saveusercontext(uint32_t *saveregs); void arm_fullcontextrestore(uint32_t *restoreregs) noreturn_function; void arm_switchcontext(uint32_t **saveregs, uint32_t *restoreregs); @@ -363,15 +305,15 @@ uint32_t *arm_doirq(int irq, uint32_t *regs); /* Exception Handlers */ -int arm_svcall(int irq, FAR void *context, FAR void *arg); -int arm_hardfault(int irq, FAR void *context, FAR void *arg); +int arm_svcall(int irq, void *context, void *arg); +int arm_hardfault(int irq, void *context, void *arg); # if defined(CONFIG_ARCH_ARMV7M) || defined(CONFIG_ARCH_ARMV8M) -int arm_memfault(int irq, FAR void *context, FAR void *arg); -int arm_busfault(int irq, FAR void *context, FAR void *arg); -int arm_usagefault(int irq, FAR void *context, FAR void *arg); -int arm_securefault(int irq, FAR void *context, FAR void *arg); +int arm_memfault(int irq, void *context, void *arg); +int arm_busfault(int irq, void *context, void *arg); +int arm_usagefault(int irq, void *context, void *arg); +int arm_securefault(int irq, void *context, void *arg); # endif /* CONFIG_ARCH_CORTEXM3,4,7 */ @@ -440,11 +382,9 @@ void arm_vectorfiq(void); /* Floating point unit ******************************************************/ #ifdef CONFIG_ARCH_FPU -void arm_savefpu(uint32_t *regs); -void arm_restorefpu(const uint32_t *regs); +void arm_fpuconfig(void); #else -# define arm_savefpu(regs) -# define arm_restorefpu(regs) +# define arm_fpuconfig() #endif /* Low level serial output **************************************************/ @@ -513,7 +453,7 @@ void arm_usbuninitialize(void); /* Debug ********************************************************************/ #ifdef CONFIG_STACK_COLORATION -void arm_stack_color(FAR void *stackbase, size_t nbytes); +void arm_stack_color(void *stackbase, size_t nbytes); #endif #undef EXTERN diff --git a/arch/arm/src/common/arm_releasepending.c b/arch/arm/src/common/arm_releasepending.c index 6a50f3f9993de..8cccae80c94e3 100644 --- a/arch/arm/src/common/arm_releasepending.c +++ b/arch/arm/src/common/arm_releasepending.c @@ -98,15 +98,6 @@ void up_release_pending(void) { struct tcb_s *nexttcb = this_task(); -#ifdef CONFIG_ARCH_ADDRENV - /* Make sure that the address environment for the previously - * running task is closed down gracefully (data caches dump, - * MMU flushed) and set up the address environment for the new - * thread at the head of the ready-to-run list. - */ - - group_addrenv(nexttcb); -#endif /* Update scheduler parameters */ nxsched_resume_scheduler(nexttcb); diff --git a/arch/arm/src/common/arm_releasestack.c b/arch/arm/src/common/arm_releasestack.c index 34e095967cfcf..4a23cb561479f 100644 --- a/arch/arm/src/common/arm_releasestack.c +++ b/arch/arm/src/common/arm_releasestack.c @@ -67,7 +67,7 @@ * ****************************************************************************/ -void up_release_stack(FAR struct tcb_s *dtcb, uint8_t ttype) +void up_release_stack(struct tcb_s *dtcb, uint8_t ttype) { /* Is there a stack allocated? */ diff --git a/arch/arm/src/common/arm_reprioritizertr.c b/arch/arm/src/common/arm_reprioritizertr.c index 3f223b72cc13f..d019d9dee76e6 100644 --- a/arch/arm/src/common/arm_reprioritizertr.c +++ b/arch/arm/src/common/arm_reprioritizertr.c @@ -153,15 +153,6 @@ void up_reprioritize_rtr(struct tcb_s *tcb, uint8_t priority) { struct tcb_s *nexttcb = this_task(); -#ifdef CONFIG_ARCH_ADDRENV - /* Make sure that the address environment for the previously - * running task is closed down gracefully (data caches dump, - * MMU flushed) and set up the address environment for the new - * thread at the head of the ready-to-run list. - */ - - group_addrenv(nexttcb); -#endif /* Update scheduler parameters */ nxsched_resume_scheduler(nexttcb); diff --git a/arch/xtensa/src/common/xtensa_copystate.c b/arch/arm/src/common/arm_saveusercontext.c similarity index 71% rename from arch/xtensa/src/common/xtensa_copystate.c rename to arch/arm/src/common/arm_saveusercontext.c index e746b4759faa3..87359c2c96fc8 100644 --- a/arch/xtensa/src/common/xtensa_copystate.c +++ b/arch/arm/src/common/arm_saveusercontext.c @@ -1,5 +1,5 @@ /**************************************************************************** - * arch/xtensa/src/common/xtensa_copystate.c + * arch/arm/src/common/arm_saveusercontext.c * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with @@ -24,35 +24,27 @@ #include -#include -#include - -#include "xtensa.h" +#include /**************************************************************************** * Public Functions ****************************************************************************/ /**************************************************************************** - * Name: xtensa_copystate + * Name: up_saveusercontext + * + * Description: + * Save the current thread context. Full prototype is: + * + * int up_saveusercontext(void *saveregs); + * + * Returned Value: + * 0: Normal return + * 1: Context switch return + * ****************************************************************************/ -/* A little faster than most memcpy's */ - -void xtensa_copystate(uint32_t *dest, uint32_t *src) +int up_saveusercontext(void *saveregs) { - int i; - - /* In the XTENSA model, the state is copied from the stack to the TCB, - * but only a reference is passed to get the state from the TCB. So the - * following check avoids copying the TCB save area onto itself: - */ - - if (src != dest) - { - for (i = 0; i < XCPTCONTEXT_REGS; i++) - { - *dest++ = *src++; - } - } + return sys_call1(SYS_save_context, (uintptr_t)saveregs); } diff --git a/arch/arm/src/common/arm_semi_syslog.c b/arch/arm/src/common/arm_semi_syslog.c index 9dc81d2d9399f..36f6477ec9cf4 100644 --- a/arch/arm/src/common/arm_semi_syslog.c +++ b/arch/arm/src/common/arm_semi_syslog.c @@ -61,7 +61,7 @@ int up_putc(int ch) * ****************************************************************************/ -void up_puts(FAR const char *str) +void up_puts(const char *str) { smh_call(SEMI_SYSLOG_WRITE0, (char *)str); } diff --git a/arch/arm/src/armv7-m/arm_signal_dispatch.c b/arch/arm/src/common/arm_signal_dispatch.c similarity index 94% rename from arch/arm/src/armv7-m/arm_signal_dispatch.c rename to arch/arm/src/common/arm_signal_dispatch.c index 4b6b4720d13fa..df8c443249c16 100644 --- a/arch/arm/src/armv7-m/arm_signal_dispatch.c +++ b/arch/arm/src/common/arm_signal_dispatch.c @@ -1,5 +1,5 @@ /**************************************************************************** - * arch/arm/src/armv7-m/arm_signal_dispatch.c + * arch/arm/src/common/arm_signal_dispatch.c * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with @@ -47,7 +47,7 @@ * * Normally the user-mode signaling handling stub will also execute * before the ultimate signal handler is called. See - * arch/arm/src/armv7-m/gnu/arm_signal_handler.S. This function is the + * arch/arm/src/armvx-y/arm_signal_handler.S. This function is the * user-space, signal handler trampoline function. It is called from * up_signal_dispatch() in user-mode. * @@ -65,7 +65,7 @@ ****************************************************************************/ void up_signal_dispatch(_sa_sigaction_t sighand, int signo, - FAR siginfo_t *info, FAR void *ucontext) + siginfo_t *info, void *ucontext) { /* Let sys_call4() do all of the work */ diff --git a/arch/arm/src/common/arm_stackframe.c b/arch/arm/src/common/arm_stackframe.c index a92ebce5ab968..a2bf931c9e94e 100644 --- a/arch/arm/src/common/arm_stackframe.c +++ b/arch/arm/src/common/arm_stackframe.c @@ -69,9 +69,9 @@ * ****************************************************************************/ -FAR void *up_stack_frame(FAR struct tcb_s *tcb, size_t frame_size) +void *up_stack_frame(struct tcb_s *tcb, size_t frame_size) { - FAR void *ret; + void *ret; /* Align the frame_size */ @@ -89,7 +89,7 @@ FAR void *up_stack_frame(FAR struct tcb_s *tcb, size_t frame_size) /* Save the adjusted stack values in the struct tcb_s */ - tcb->stack_base_ptr = (FAR uint8_t *)tcb->stack_base_ptr + frame_size; + tcb->stack_base_ptr = (uint8_t *)tcb->stack_base_ptr + frame_size; tcb->adj_stack_size -= frame_size; /* And return the pointer to the allocated region */ diff --git a/arch/arm/src/common/arm_task_start.c b/arch/arm/src/common/arm_task_start.c index 3c7e9ec0292f5..43ee01d5aaf02 100644 --- a/arch/arm/src/common/arm_task_start.c +++ b/arch/arm/src/common/arm_task_start.c @@ -62,7 +62,7 @@ * ****************************************************************************/ -void up_task_start(main_t taskentry, int argc, FAR char *argv[]) +void up_task_start(main_t taskentry, int argc, char *argv[]) { /* Let sys_call3() do all of the work */ diff --git a/arch/arm/src/common/arm_tls.c b/arch/arm/src/common/arm_tls.c index 664f74f48a964..250e9b21ad651 100644 --- a/arch/arm/src/common/arm_tls.c +++ b/arch/arm/src/common/arm_tls.c @@ -63,9 +63,9 @@ int up_tls_size(void) * ****************************************************************************/ -void up_tls_initialize(FAR struct tls_info_s *info) +void up_tls_initialize(struct tls_info_s *info) { - FAR uint8_t *tls_data = (FAR uint8_t *)(info + 1); + uint8_t *tls_data = (uint8_t *)(info + 1); uint32_t tdata_len = sizeof(uint32_t) * (_END_TDATA - _START_TDATA); uint32_t tbss_len = sizeof(uint32_t) * (_END_TBSS - _START_TBSS); diff --git a/arch/arm/src/common/arm_unblocktask.c b/arch/arm/src/common/arm_unblocktask.c index 47357f253aaa6..5b347c0dfc19d 100644 --- a/arch/arm/src/common/arm_unblocktask.c +++ b/arch/arm/src/common/arm_unblocktask.c @@ -115,15 +115,6 @@ void up_unblock_task(struct tcb_s *tcb) { struct tcb_s *nexttcb = this_task(); -#ifdef CONFIG_ARCH_ADDRENV - /* Make sure that the address environment for the previously - * running task is closed down gracefully (data caches dump, - * MMU flushed) and set up the address environment for the new - * thread at the head of the ready-to-run list. - */ - - group_addrenv(nexttcb); -#endif /* Update scheduler parameters */ nxsched_resume_scheduler(nexttcb); diff --git a/arch/arm/src/armv8-m/arm_fetchadd.S b/arch/arm/src/common/gnu/arm_fetchadd.S similarity index 99% rename from arch/arm/src/armv8-m/arm_fetchadd.S rename to arch/arm/src/common/gnu/arm_fetchadd.S index ca7a6a6397b8d..6d4fb3df06586 100644 --- a/arch/arm/src/armv8-m/arm_fetchadd.S +++ b/arch/arm/src/common/gnu/arm_fetchadd.S @@ -1,5 +1,5 @@ /**************************************************************************** - * arch/arm/src/armv8-m/arm_fetchadd.S + * arch/arm/src/common/gnu/arm_fetchadd.S * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with @@ -25,7 +25,6 @@ #include .syntax unified - .thumb .file "arm_fetchadd.S" /**************************************************************************** diff --git a/arch/arm/src/armv8-m/arm_signal_handler.S b/arch/arm/src/common/gnu/arm_signal_handler.S similarity index 98% rename from arch/arm/src/armv8-m/arm_signal_handler.S rename to arch/arm/src/common/gnu/arm_signal_handler.S index b2bac1a090957..c2666f9cb9394 100644 --- a/arch/arm/src/armv8-m/arm_signal_handler.S +++ b/arch/arm/src/common/gnu/arm_signal_handler.S @@ -1,5 +1,5 @@ /**************************************************************************** - * arch/arm/src/armv8-m/arm_signal_handler.S + * arch/arm/src/common/gnu/arm_signal_handler.S * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with @@ -33,7 +33,6 @@ ****************************************************************************/ .syntax unified - .thumb .file "arm_signal_handler.S" /**************************************************************************** diff --git a/arch/arm/src/armv8-m/arm_testset.S b/arch/arm/src/common/gnu/arm_testset.S similarity index 98% rename from arch/arm/src/armv8-m/arm_testset.S rename to arch/arm/src/common/gnu/arm_testset.S index 45e2c273f8a58..544a96f4bd6ab 100644 --- a/arch/arm/src/armv8-m/arm_testset.S +++ b/arch/arm/src/common/gnu/arm_testset.S @@ -1,5 +1,5 @@ /**************************************************************************** - * arch/arm/src/armv8-m/arm_testset.S + * arch/arm/src/common/gnu/arm_testset.S * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with @@ -26,7 +26,6 @@ #include .syntax unified - .thumb .file "arm_testset.S" /**************************************************************************** diff --git a/arch/arm/src/armv6-m/vfork.S b/arch/arm/src/common/gnu/vfork.S similarity index 90% rename from arch/arm/src/armv6-m/vfork.S rename to arch/arm/src/common/gnu/vfork.S index 624134d893ae2..e4c4c4929f1a3 100644 --- a/arch/arm/src/armv6-m/vfork.S +++ b/arch/arm/src/common/gnu/vfork.S @@ -1,5 +1,5 @@ /**************************************************************************** - * arch/arm/src/armv6-m/vfork.S + * arch/arm/src/common/vfork.S * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with @@ -26,16 +26,8 @@ #include "arm_vfork.h" -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -/**************************************************************************** - * Public Symbols - ****************************************************************************/ - + .syntax unified .file "vfork.S" - .globl up_vfork /**************************************************************************** * Public Functions @@ -83,11 +75,9 @@ * ****************************************************************************/ - .align 2 - .code 16 - .thumb_func .globl vfork .type vfork, function + vfork: /* Create a stack frame */ @@ -123,5 +113,6 @@ vfork: mov r14, r1 add sp, sp, #VFORK_SIZEOF bx lr + .size vfork, .-vfork .end diff --git a/arch/arm/src/armv7-m/iar/arm_fetchadd.S b/arch/arm/src/common/iar/arm_fetchadd.S similarity index 99% rename from arch/arm/src/armv7-m/iar/arm_fetchadd.S rename to arch/arm/src/common/iar/arm_fetchadd.S index d78479c4c71ad..c2ada73216335 100644 --- a/arch/arm/src/armv7-m/iar/arm_fetchadd.S +++ b/arch/arm/src/common/iar/arm_fetchadd.S @@ -1,5 +1,5 @@ /**************************************************************************** - * arch/arm/src/armv7-m/iar/arm_fetchadd.S + * arch/arm/src/common/iar/arm_fetchadd.S * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with diff --git a/arch/arm/src/armv7-m/iar/arm_testset.S b/arch/arm/src/common/iar/arm_testset.S similarity index 98% rename from arch/arm/src/armv7-m/iar/arm_testset.S rename to arch/arm/src/common/iar/arm_testset.S index 8ad50f937469a..e48f2d1dabd69 100644 --- a/arch/arm/src/armv7-m/iar/arm_testset.S +++ b/arch/arm/src/common/iar/arm_testset.S @@ -1,5 +1,5 @@ /**************************************************************************** - * arch/arm/src/armv7-m/iar/arm_testset.S + * arch/arm/src/common/iar/arm_testset.S * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with diff --git a/arch/arm/src/armv7-m/iar/vfork.S b/arch/arm/src/common/iar/vfork.S similarity index 99% rename from arch/arm/src/armv7-m/iar/vfork.S rename to arch/arm/src/common/iar/vfork.S index 305e74728fb45..24d469279e1d1 100644 --- a/arch/arm/src/armv7-m/iar/vfork.S +++ b/arch/arm/src/common/iar/vfork.S @@ -1,5 +1,5 @@ /**************************************************************************** - * arch/arm/src/armv7-m/iar/vfork.S + * arch/arm/src/common/iar/vfork.S * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with diff --git a/arch/arm/src/cxd56xx/Make.defs b/arch/arm/src/cxd56xx/Make.defs index 2a02b164757b5..262705c81bc1f 100644 --- a/arch/arm/src/cxd56xx/Make.defs +++ b/arch/arm/src/cxd56xx/Make.defs @@ -18,55 +18,7 @@ # ############################################################################ -CMN_ASRCS = arm_saveusercontext.S arm_fullcontextrestore.S -CMN_ASRCS += vfork.S - -ifneq ($(CONFIG_CXD56_TESTSET),y) -CMN_ASRCS += arm_testset.S -endif - -CMN_CSRCS = arm_assert.c arm_blocktask.c -CMN_CSRCS += arm_createstack.c arm_exit.c -CMN_CSRCS += arm_initialize.c arm_initialstate.c arm_interruptcontext.c -CMN_CSRCS += arm_memfault.c arm_modifyreg8.c arm_modifyreg16.c arm_modifyreg32.c -CMN_CSRCS += arm_releasepending.c arm_releasestack.c arm_reprioritizertr.c -CMN_CSRCS += arm_schedulesigaction.c arm_sigdeliver.c arm_stackframe.c -CMN_CSRCS += arm_unblocktask.c arm_usestack.c arm_doirq.c arm_hardfault.c -CMN_CSRCS += arm_svcall.c arm_vfork.c arm_switchcontext.c arm_puts.c -CMN_CSRCS += arm_tcbinfo.c - -ifeq ($(CONFIG_ARMV7M_LAZYFPU),y) -CMN_ASRCS += arm_lazyexception.S -else -CMN_ASRCS += arm_exception.S -endif -CMN_CSRCS += arm_vectors.c - -ifeq ($(CONFIG_ARCH_RAMVECTORS),y) -CMN_CSRCS += arm_ramvec_initialize.c arm_ramvec_attach.c -endif - -ifeq ($(CONFIG_ARCH_MEMCPY),y) -CMN_ASRCS += up_memcpy.S -endif - -ifeq ($(CONFIG_BUILD_PROTECTED),y) -CMN_CSRCS += arm_mpu.c arm_task_start.c arm_pthread_start.c -CMN_CSRCS += arm_signal_dispatch.c -CMN_UASRCS += arm_signal_handler.S -endif - -ifeq ($(CONFIG_STACK_COLORATION),y) -CMN_CSRCS += arm_checkstack.c -endif - -ifeq ($(CONFIG_ARCH_FPU),y) -CMN_ASRCS += arm_fpu.S -endif - -ifeq ($(CONFIG_ARMV7M_ITMSYSLOG),y) -CMN_CSRCS += arm_itm_syslog.c -endif +include armv7-m/Make.defs CHIP_ASRCS += cxd56_farapistub.S @@ -93,6 +45,7 @@ CHIP_CSRCS += cxd56_cpupause.c CHIP_CSRCS += cxd56_cpustart.c ifeq ($(CONFIG_CXD56_TESTSET),y) CHIP_CSRCS += cxd56_testset.c +CMN_ASRCS := $(filter-out arm_testset.S,$(CMN_ASRCS)) endif endif diff --git a/arch/arm/src/cxd56xx/cxd56_charger.c b/arch/arm/src/cxd56xx/cxd56_charger.c index 527f8dfdd2ed0..7b30ae4bb661c 100644 --- a/arch/arm/src/cxd56xx/cxd56_charger.c +++ b/arch/arm/src/cxd56xx/cxd56_charger.c @@ -77,8 +77,6 @@ static int charger_online(FAR bool *online); static int charger_get_temptable(FAR struct battery_temp_table_s *table); static int charger_set_temptable(FAR struct battery_temp_table_s *table); -static int charger_open(FAR struct file *filep); -static int charger_close(FAR struct file *filep); static ssize_t charger_read(FAR struct file *filep, FAR char *buffer, size_t buflen); static ssize_t charger_write(FAR struct file *filep, @@ -92,8 +90,8 @@ static int charger_ioctl(FAR struct file *filep, int cmd, static const struct file_operations g_chargerops = { - charger_open, /* open */ - charger_close, /* close */ + NULL, /* open */ + NULL, /* close */ charger_read, /* read */ charger_write, /* write */ NULL, /* seek */ @@ -419,32 +417,6 @@ static int charger_set_temptable(FAR struct battery_temp_table_s *table) return cxd56_pmic_settemptable(&buf); } -/**************************************************************************** - * Name: charger_open - * - * Description: - * This function is called whenever the battery device is opened. - * - ****************************************************************************/ - -static int charger_open(FAR struct file *filep) -{ - return OK; -} - -/**************************************************************************** - * Name: charger_close - * - * Description: - * This routine is called when the battery device is closed. - * - ****************************************************************************/ - -static int charger_close(FAR struct file *filep) -{ - return OK; -} - /**************************************************************************** * Name: charger_read ****************************************************************************/ diff --git a/arch/arm/src/cxd56xx/cxd56_cpustart.c b/arch/arm/src/cxd56xx/cxd56_cpustart.c index 6c0bf94aa9689..649ba67caa859 100644 --- a/arch/arm/src/cxd56xx/cxd56_cpustart.c +++ b/arch/arm/src/cxd56xx/cxd56_cpustart.c @@ -73,7 +73,6 @@ volatile static spinlock_t g_appdsp_boot; extern int arm_pause_handler(int irq, void *c, FAR void *arg); -extern void fpuconfig(void); /**************************************************************************** * Private Functions @@ -104,7 +103,7 @@ static void appdsp_boot(void) /* Setup FPU */ - fpuconfig(); + arm_fpuconfig(); /* Clear SW_INT for APP_DSP(cpu) */ diff --git a/arch/arm/src/cxd56xx/cxd56_emmc.c b/arch/arm/src/cxd56xx/cxd56_emmc.c index f74857492d463..8d3bb18c6fdf8 100644 --- a/arch/arm/src/cxd56xx/cxd56_emmc.c +++ b/arch/arm/src/cxd56xx/cxd56_emmc.c @@ -28,6 +28,7 @@ #include #include #include +#include #include #include diff --git a/arch/arm/src/cxd56xx/cxd56_farapistub.h b/arch/arm/src/cxd56xx/cxd56_farapistub.h index 3e12f7551e527..a58e2eca953a7 100644 --- a/arch/arm/src/cxd56xx/cxd56_farapistub.h +++ b/arch/arm/src/cxd56xx/cxd56_farapistub.h @@ -21,6 +21,6 @@ #ifndef __ARCH_ARM_SRC_CXD56XX_CXD56_FARAPISTUB_H #define __ARCH_ARM_SRC_CXD56XX_CXD56_FARAPISTUB_H -#define FARAPISTUB_VERSION 20175 +#define FARAPISTUB_VERSION 20585 #endif /* __ARCH_ARM_SRC_CXD56XX_CXD56_FARAPISTUB_H */ diff --git a/arch/arm/src/cxd56xx/cxd56_gauge.c b/arch/arm/src/cxd56xx/cxd56_gauge.c index 35cbd26be56d5..e65ebdd47e84a 100644 --- a/arch/arm/src/cxd56xx/cxd56_gauge.c +++ b/arch/arm/src/cxd56xx/cxd56_gauge.c @@ -62,14 +62,12 @@ struct bat_gauge_dev_s * Private Function Prototypes ****************************************************************************/ -static int gauge_open(FAR struct file *filep); -static int gauge_close(FAR struct file *filep); static ssize_t gauge_read(FAR struct file *filep, FAR char *buffer, size_t buflen); static ssize_t gauge_write(FAR struct file *filep, FAR const char *buffer, size_t buflen); static int gauge_ioctl(FAR struct file *filep, int cmd, - unsigned long arg); + unsigned long arg); /**************************************************************************** * Private Data @@ -77,8 +75,8 @@ static int gauge_ioctl(FAR struct file *filep, int cmd, static const struct file_operations g_gaugeops = { - gauge_open, /* open */ - gauge_close, /* close */ + NULL, /* open */ + NULL, /* close */ gauge_read, /* read */ gauge_write, /* write */ NULL, /* seek */ @@ -247,32 +245,6 @@ static int gauge_online(FAR bool *online) return OK; } -/**************************************************************************** - * Name: gauge_open - * - * Description: - * This function is called whenever the battery device is opened. - * - ****************************************************************************/ - -static int gauge_open(FAR struct file *filep) -{ - return OK; -} - -/**************************************************************************** - * Name: gauge_close - * - * Description: - * This routine is called when the battery device is closed. - * - ****************************************************************************/ - -static int gauge_close(FAR struct file *filep) -{ - return OK; -} - /**************************************************************************** * Name: gauge_read ****************************************************************************/ diff --git a/arch/arm/src/cxd56xx/cxd56_ge2d.c b/arch/arm/src/cxd56xx/cxd56_ge2d.c index b7f379b95db85..5bc240e93bb8a 100644 --- a/arch/arm/src/cxd56xx/cxd56_ge2d.c +++ b/arch/arm/src/cxd56xx/cxd56_ge2d.c @@ -46,8 +46,6 @@ * Private Function Prototypes ****************************************************************************/ -static int ge2d_open(FAR struct file *filep); -static int ge2d_close(FAR struct file *filep); static ssize_t ge2d_read(FAR struct file *filep, FAR char *buffer, size_t len); static ssize_t ge2d_write(FAR struct file *filep, FAR const char *buffer, @@ -63,12 +61,9 @@ static int ge2d_irqhandler(int irq, FAR void *context, FAR void *arg); static const struct file_operations g_ge2dfops = { - .open = ge2d_open, - .close = ge2d_close, .read = ge2d_read, .write = ge2d_write, - .seek = NULL, - .ioctl = ge2d_ioctl, + .ioctl = ge2d_ioctl }; static sem_t g_wait; @@ -96,24 +91,6 @@ static void ge2d_semgive(sem_t *id) nxsem_post(id); } -/**************************************************************************** - * Name: ge2d_open - ****************************************************************************/ - -static int ge2d_open(FAR struct file *filep) -{ - return 0; -} - -/**************************************************************************** - * Name: ge2d_close - ****************************************************************************/ - -static int ge2d_close(FAR struct file *filep) -{ - return 0; -} - /**************************************************************************** * Name: ge2d_read ****************************************************************************/ @@ -129,8 +106,7 @@ static ssize_t ge2d_read(FAR struct file *filep, * Name: ge2d_write ****************************************************************************/ -static ssize_t ge2d_write(FAR struct file *filep, - FAR const char *buffer, +static ssize_t ge2d_write(FAR struct file *filep, FAR const char *buffer, size_t len) { uint32_t bits; diff --git a/arch/arm/src/cxd56xx/cxd56_geofence.c b/arch/arm/src/cxd56xx/cxd56_geofence.c index b9c0447859d27..ae51ec5bf0cb0 100644 --- a/arch/arm/src/cxd56xx/cxd56_geofence.c +++ b/arch/arm/src/cxd56xx/cxd56_geofence.c @@ -68,8 +68,6 @@ struct cxd56_geofence_dev_s /* file operation functions */ -static int cxd56_geofence_open(FAR struct file *filep); -static int cxd56_geofence_close(FAR struct file *filep); static ssize_t cxd56_geofence_read(FAR struct file *filep, FAR char *buffer, size_t len); @@ -101,8 +99,8 @@ static int cxd56_geofence_set_mode(unsigned long arg); static const struct file_operations g_geofencefops = { - cxd56_geofence_open, /* open */ - cxd56_geofence_close, /* close */ + NULL, /* open */ + NULL, /* close */ cxd56_geofence_read, /* read */ NULL, /* write */ NULL, /* seek */ @@ -450,7 +448,7 @@ static void cxd56_geofence_sighandler(uint32_t data, FAR void *userdata) if (fds) { fds->revents |= POLLIN; - gnssinfo("Report events: %02x\n", fds->revents); + gnssinfo("Report events: %08" PRIx32 "\n", fds->revents); nxsem_post(fds->sem); } } @@ -478,48 +476,6 @@ static int cxd56_geofence_initialize(FAR struct cxd56_geofence_dev_s *dev) return ret; } -/**************************************************************************** - * Name: cxd56_geofence_open - * - * Description: - * Standard character driver open method. - * - * Input Parameters: - * filep - File structure pointer - * - * Returned Value: - * Zero (OK) on success; a negated errno value on failure. - * - ****************************************************************************/ - -static int cxd56_geofence_open(FAR struct file *filep) -{ - int32_t ret = 0; - - return ret; -} - -/**************************************************************************** - * Name: cxd56_geofence_close - * - * Description: - * Standard character driver close method. - * - * Input Parameters: - * filep - File structure pointer - * - * Returned Value: - * Zero (OK) on success; a negated errno value on failure. - * - ****************************************************************************/ - -static int cxd56_geofence_close(FAR struct file *filep) -{ - int32_t ret = 0; - - return ret; -} - /**************************************************************************** * Name: cxd56_geofence_read * diff --git a/arch/arm/src/cxd56xx/cxd56_gnss.c b/arch/arm/src/cxd56xx/cxd56_gnss.c index ade0ec24d4bd6..a5dc074074279 100644 --- a/arch/arm/src/cxd56xx/cxd56_gnss.c +++ b/arch/arm/src/cxd56xx/cxd56_gnss.c @@ -2402,7 +2402,7 @@ static void cxd56_gnss_default_sighandler(uint32_t data, FAR void *userdata) if (fds) { fds->revents |= POLLIN; - gnssinfo("Report events: %02x\n", fds->revents); + gnssinfo("Report events: %08" PRIx32 "\n", fds->revents); nxsem_post(fds->sem); } } @@ -2438,8 +2438,6 @@ static void cxd56_gnss_cpufifoapi_signalhandler(uint32_t data, priv->apiret = CXD56_CPU1_GET_DATA((int)data); nxsem_post(&priv->apiwait); - - return; } /**************************************************************************** diff --git a/arch/arm/src/cxd56xx/cxd56_hostif.c b/arch/arm/src/cxd56xx/cxd56_hostif.c index efac07f0c05ec..7fce69d979643 100644 --- a/arch/arm/src/cxd56xx/cxd56_hostif.c +++ b/arch/arm/src/cxd56xx/cxd56_hostif.c @@ -141,8 +141,10 @@ static const struct file_operations g_hif_fops = hif_write, /* write */ hif_seek, /* seek */ hif_ioctl, /* ioctl */ - hif_poll, /* poll */ - hif_unlink /* unlink */ + hif_poll /* poll */ +#ifndef CONFIG_DISABLE_PSEUDOFS_OPERATIONS + , hif_unlink /* unlink */ +#endif }; /**************************************************************************** @@ -343,10 +345,12 @@ static int hif_poll(FAR struct file *filep, return OK; } +#ifndef CONFIG_DISABLE_PSEUDOFS_OPERATIONS static int hif_unlink(FAR struct inode *inode) { return OK; } +#endif static int hif_rxhandler(int cpuid, int protoid, uint32_t pdata, uint32_t data, diff --git a/arch/arm/src/cxd56xx/cxd56_pwm.c b/arch/arm/src/cxd56xx/cxd56_pwm.c index 3574089cfc733..60dde8a18d8db 100644 --- a/arch/arm/src/cxd56xx/cxd56_pwm.c +++ b/arch/arm/src/cxd56xx/cxd56_pwm.c @@ -496,8 +496,6 @@ FAR struct pwm_lowerhalf_s *cxd56_pwminitialize(uint32_t channel) { FAR struct cxd56_pwm_chan_s *pwmch; - (void)g_pwmops; - switch (channel) { #ifdef CONFIG_CXD56_PWM0 diff --git a/arch/arm/src/cxd56xx/cxd56_scu.c b/arch/arm/src/cxd56xx/cxd56_scu.c index f84e7a4cb04a4..dd605b2ae3e1a 100644 --- a/arch/arm/src/cxd56xx/cxd56_scu.c +++ b/arch/arm/src/cxd56xx/cxd56_scu.c @@ -939,8 +939,11 @@ static void seq_setstartphase(int sid, int phase) static void seq_startseq(int sid) { uint32_t val; + irqstate_t flags; + flags = enter_critical_section(); val = getreg32(SCU_START_MODE0); putreg32(val | (1 << sid), SCU_START_MODE0); + leave_critical_section(flags); } /**************************************************************************** @@ -957,8 +960,11 @@ static void seq_startseq(int sid) static void seq_stopseq(int sid) { uint32_t val; + irqstate_t flags; + flags = enter_critical_section(); val = getreg32(SCU_START_MODE0); putreg32(val & ~(1 << sid), SCU_START_MODE0); + leave_critical_section(flags); } /**************************************************************************** diff --git a/arch/arm/src/cxd56xx/cxd56_sdhci.c b/arch/arm/src/cxd56xx/cxd56_sdhci.c index 7b6ed58352e06..423f51bd1888b 100644 --- a/arch/arm/src/cxd56xx/cxd56_sdhci.c +++ b/arch/arm/src/cxd56xx/cxd56_sdhci.c @@ -3163,7 +3163,7 @@ static void cxd56_sdio_callback(void *arg) mcinfo("Queuing callback to %p(%p)\n", priv->callback, priv->cbarg); - work_queue(HPWORK, &priv->cbwork, (worker_t)priv->callback, + work_queue(HPWORK, &priv->cbwork, priv->callback, priv->cbarg, delay); } else diff --git a/arch/arm/src/cxd56xx/cxd56_sph.c b/arch/arm/src/cxd56xx/cxd56_sph.c index 21b9cb3fba4fb..c5cb6e324c435 100644 --- a/arch/arm/src/cxd56xx/cxd56_sph.c +++ b/arch/arm/src/cxd56xx/cxd56_sph.c @@ -92,11 +92,7 @@ static int cxd56_sphirqhandler(int irq, FAR void *context, FAR void *arg); static const struct file_operations sph_fops = { .open = sph_open, - .close = NULL, - .read = NULL, - .write = NULL, - .seek = NULL, - .ioctl = sph_ioctl, + .ioctl = sph_ioctl }; static struct sph_dev_s g_sphdev[NR_HSEMS]; diff --git a/arch/arm/src/cxd56xx/cxd56_start.c b/arch/arm/src/cxd56xx/cxd56_start.c index 2794f96045de7..b20564aa854c8 100644 --- a/arch/arm/src/cxd56xx/cxd56_start.c +++ b/arch/arm/src/cxd56xx/cxd56_start.c @@ -110,97 +110,6 @@ extern uint32_t _vectors[]; * Public Functions ****************************************************************************/ -/**************************************************************************** - * Name: fpuconfig - * - * Description: - * Configure the FPU. Relative bit settings: - * - * CPACR: Enables access to CP10 and CP11 - * CONTROL.FPCA: Determines whether the FP extension is active in the - * current context: - * FPCCR.ASPEN: Enables automatic FP state preservation, then the - * processor sets this bit to 1 on successful completion of any FP - * instruction. - * FPCCR.LSPEN: Enables lazy context save of FP state. When this is - * done, the processor reserves space on the stack for the FP state, - * but does not save that state information to the stack. - * - * Software must not change the value of the ASPEN bit or LSPEN bit while - * either: - * - the CPACR permits access to CP10 and CP11, that give access to the FP - * extension, or - * - the CONTROL.FPCA bit is set to 1 - * - ****************************************************************************/ - -#ifdef CONFIG_ARCH_FPU -# ifndef CONFIG_ARMV7M_LAZYFPU - -void fpuconfig(void) -{ - uint32_t regval; - - /* Set CONTROL.FPCA so that we always get the extended context frame - * with the volatile FP registers stacked above the basic context. - */ - - regval = getcontrol(); - regval |= CONTROL_FPCA; - setcontrol(regval); - - /* Ensure that FPCCR.LSPEN is disabled, so that we don't have to contend - * with the lazy FP context save behaviour. Clear FPCCR.ASPEN since we - * are going to turn on CONTROL.FPCA for all contexts. - */ - - regval = getreg32(NVIC_FPCCR); - regval &= ~(NVIC_FPCCR_ASPEN | NVIC_FPCCR_LSPEN); - putreg32(regval, NVIC_FPCCR); - - /* Enable full access to CP10 and CP11 */ - - regval = getreg32(NVIC_CPACR); - regval |= NVIC_CPACR_CP_FULL(10) | NVIC_CPACR_CP_FULL(11); - putreg32(regval, NVIC_CPACR); -} - -# else - -void fpuconfig(void) -{ - uint32_t regval; - - /* Clear CONTROL.FPCA so that we do not get the extended context frame - * with the volatile FP registers stacked in the saved context. - */ - - regval = getcontrol(); - regval &= ~CONTROL_FPCA; - setcontrol(regval); - - /* Ensure that FPCCR.LSPEN is disabled, so that we don't have to contend - * with the lazy FP context save behaviour. Clear FPCCR.ASPEN since we - * are going to keep CONTROL.FPCA off for all contexts. - */ - - regval = getreg32(NVIC_FPCCR); - regval &= ~(NVIC_FPCCR_ASPEN | NVIC_FPCCR_LSPEN); - putreg32(regval, NVIC_FPCCR); - - /* Enable full access to CP10 and CP11 */ - - regval = getreg32(NVIC_CPACR); - regval |= NVIC_CPACR_CP_FULL(10) | NVIC_CPACR_CP_FULL(11); - putreg32(regval, NVIC_CPACR); -} - -# endif - -#else -# define fpuconfig() -#endif - /**************************************************************************** * Name: _start * @@ -269,7 +178,7 @@ void __start(void) /* Initialize the FPU (if configured) */ - fpuconfig(); + arm_fpuconfig(); #ifdef CONFIG_ARMV7M_ITMSYSLOG /* Perform ARMv7-M ITM SYSLOG initialization */ diff --git a/arch/arm/src/cxd56xx/cxd56_sysctl.c b/arch/arm/src/cxd56xx/cxd56_sysctl.c index 20da9e57d5f93..94aab38d009b2 100644 --- a/arch/arm/src/cxd56xx/cxd56_sysctl.c +++ b/arch/arm/src/cxd56xx/cxd56_sysctl.c @@ -73,7 +73,7 @@ static int g_errcode = 0; static const struct file_operations g_sysctlfops = { - .ioctl = sysctl_ioctl, + .ioctl = sysctl_ioctl }; /**************************************************************************** diff --git a/arch/arm/src/cxd56xx/cxd56_uart0.c b/arch/arm/src/cxd56xx/cxd56_uart0.c index f259804b68c96..77e9cd6418e28 100644 --- a/arch/arm/src/cxd56xx/cxd56_uart0.c +++ b/arch/arm/src/cxd56xx/cxd56_uart0.c @@ -72,7 +72,6 @@ static ssize_t uart0_read(FAR struct file *filep, FAR char *buffer, size_t len); static ssize_t uart0_write(FAR struct file *filep, FAR const char *buffer, size_t len); -static int uart0_ioctl(FAR struct file *filep, int cmd, unsigned long arg); static int uart0_semtake(sem_t *id); static void uart0_semgive(sem_t *id); @@ -98,9 +97,7 @@ static const struct file_operations g_uart0fops = .open = uart0_open, .close = uart0_close, .read = uart0_read, - .write = uart0_write, - .seek = NULL, - .ioctl = uart0_ioctl, + .write = uart0_write }; static sem_t g_lock; @@ -251,15 +248,6 @@ static ssize_t uart0_write(FAR struct file *filep, return (ssize_t)ret; } -/**************************************************************************** - * Name: uart0_ioctl - ****************************************************************************/ - -static int uart0_ioctl(FAR struct file *filep, int cmd, unsigned long arg) -{ - return -ENOTTY; -} - /**************************************************************************** * Name: cxd56_uart0initialize ****************************************************************************/ diff --git a/arch/arm/src/cxd56xx/hardware/cxd5602_isop.h b/arch/arm/src/cxd56xx/hardware/cxd5602_isop.h index 28347203da460..d25b0ecc73d36 100644 --- a/arch/arm/src/cxd56xx/hardware/cxd5602_isop.h +++ b/arch/arm/src/cxd56xx/hardware/cxd5602_isop.h @@ -1,3 +1,23 @@ +/**************************************************************************** + * arch/arm/src/cxd56xx/hardware/cxd5602_isop.h + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + /* This file is generated at Dec 14 2020 13:28:30 */ /**************************************************************************** diff --git a/arch/arm/src/cxd56xx/hardware/cxd5602_isop_hadc0_highspeed.h b/arch/arm/src/cxd56xx/hardware/cxd5602_isop_hadc0_highspeed.h index 7f575cb47d482..53a006882a1d5 100644 --- a/arch/arm/src/cxd56xx/hardware/cxd5602_isop_hadc0_highspeed.h +++ b/arch/arm/src/cxd56xx/hardware/cxd5602_isop_hadc0_highspeed.h @@ -1,3 +1,23 @@ +/**************************************************************************** + * arch/arm/src/cxd56xx/hardware/cxd5602_isop_hadc0_highspeed.h + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + /* This file is generated at Mar 27 2020 12:00:17 */ /**************************************************************************** diff --git a/arch/arm/src/dm320/Make.defs b/arch/arm/src/dm320/Make.defs index 186980c2c0e48..349f9ef3abac3 100644 --- a/arch/arm/src/dm320/Make.defs +++ b/arch/arm/src/dm320/Make.defs @@ -18,27 +18,7 @@ # ############################################################################ -HEAD_ASRC = arm_head.S - -CMN_ASRCS = arm_cache.S arm_fullcontextrestore.S arm_saveusercontext.S -CMN_ASRCS += arm_vectors.S arm_vectoraddrexcptn.S arm_vectortab.S vfork.S - -CMN_CSRCS = arm_assert.c arm_blocktask.c arm_createstack.c -CMN_CSRCS += arm_dataabort.c arm_mdelay.c arm_udelay.c arm_exit.c -CMN_CSRCS += arm_initialize.c arm_initialstate.c arm_interruptcontext.c -CMN_CSRCS += arm_prefetchabort.c arm_releasepending.c arm_releasestack.c -CMN_CSRCS += arm_reprioritizertr.c arm_schedulesigaction.c -CMN_CSRCS += arm_sigdeliver.c arm_stackframe.c arm_syscall.c arm_unblocktask.c -CMN_CSRCS += arm_undefinedinsn.c arm_usestack.c arm_vfork.c arm_puts.c -CMN_CSRCS += arm_tcbinfo.c arm_switchcontext.c - -ifneq ($(CONFIG_ARCH_IDLE_CUSTOM),y) -CMN_CSRCS += arm_idle.c -endif - -ifeq ($(CONFIG_STACK_COLORATION),y) -CMN_CSRCS += arm_checkstack.c -endif +include arm/Make.defs CHIP_ASRCS = dm320_lowputc.S dm320_restart.S diff --git a/arch/arm/src/dm320/dm320_decodeirq.c b/arch/arm/src/dm320/dm320_decodeirq.c index 0745770f9e730..8e48ad2c565ca 100644 --- a/arch/arm/src/dm320/dm320_decodeirq.c +++ b/arch/arm/src/dm320/dm320_decodeirq.c @@ -83,23 +83,16 @@ uint32_t *arm_decodeirq(uint32_t *regs) irq_dispatch(irq, regs); -#if defined(CONFIG_ARCH_FPU) || defined(CONFIG_ARCH_ADDRENV) +#ifdef CONFIG_ARCH_ADDRENV /* Check for a context switch. If a context switch occurred, then * CURRENT_REGS will have a different value than it did on entry. - * If an interrupt level context switch has occurred, then restore - * the floating point state and the establish the correct address - * environment before returning from the interrupt. + * If an interrupt level context switch has occurred, then + * establish the correct address environment before returning + * from the interrupt. */ if (regs != CURRENT_REGS) { -#ifdef CONFIG_ARCH_FPU - /* Restore floating point registers */ - - arm_restorefpu((uint32_t *)CURRENT_REGS); -#endif - -#ifdef CONFIG_ARCH_ADDRENV /* Make sure that the address environment for the previously * running task is closed down gracefully (data caches dump, * MMU flushed) and set up the address environment for the new @@ -107,7 +100,6 @@ uint32_t *arm_decodeirq(uint32_t *regs) */ group_addrenv(NULL); -#endif } #endif diff --git a/arch/arm/src/efm32/Make.defs b/arch/arm/src/efm32/Make.defs index 9e5d6828e4599..3998938f1bbab 100644 --- a/arch/arm/src/efm32/Make.defs +++ b/arch/arm/src/efm32/Make.defs @@ -18,47 +18,7 @@ # ############################################################################ -CMN_ASRCS = arm_saveusercontext.S arm_fullcontextrestore.S -CMN_ASRCS += arm_testset.S arm_fetchadd.S vfork.S - -CMN_CSRCS = arm_allocateheap.c arm_assert.c arm_blocktask.c -CMN_CSRCS += arm_createstack.c arm_doirq.c arm_exit.c arm_hardfault.c -CMN_CSRCS += arm_initialize.c arm_initialstate.c arm_interruptcontext.c -CMN_CSRCS += arm_itm.c arm_mdelay.c arm_memfault.c arm_modifyreg8.c -CMN_CSRCS += arm_modifyreg16.c arm_modifyreg32.c arm_releasepending.c -CMN_CSRCS += arm_releasestack.c arm_reprioritizertr.c arm_schedulesigaction.c -CMN_CSRCS += arm_sigdeliver.c arm_stackframe.c arm_svcall.c arm_systemreset.c -CMN_CSRCS += arm_trigger_irq.c arm_udelay.c arm_unblocktask.c arm_usestack.c arm_vfork.c -CMN_CSRCS += arm_switchcontext.c arm_puts.c arm_tcbinfo.c - -ifeq ($(CONFIG_ARMV7M_LAZYFPU),y) -CMN_ASRCS += arm_lazyexception.S -else -CMN_ASRCS += arm_exception.S -endif -CMN_CSRCS += arm_vectors.c - -ifeq ($(CONFIG_ARCH_RAMVECTORS),y) -CMN_CSRCS += arm_ramvec_initialize.c arm_ramvec_attach.c -endif - -ifeq ($(CONFIG_BUILD_PROTECTED),y) -CMN_CSRCS += arm_mpu.c arm_task_start.c arm_pthread_start.c -CMN_CSRCS += arm_signal_dispatch.c -CMN_UASRCS += arm_signal_handler.S -endif - -ifeq ($(CONFIG_STACK_COLORATION),y) -CMN_CSRCS += arm_checkstack.c -endif - -ifeq ($(CONFIG_ARCH_FPU),y) -CMN_ASRCS += arm_fpu.S -endif - -ifeq ($(CONFIG_ARMV7M_ITMSYSLOG),y) -CMN_CSRCS += arm_itm_syslog.c -endif +include armv7-m/Make.defs CHIP_CSRCS = efm32_start.c efm32_clockconfig.c efm32_irq.c efm32_timerisr.c CHIP_CSRCS += efm32_gpio.c efm32_lowputc.c efm32_timer.c efm32_i2c.c diff --git a/arch/arm/src/efm32/efm32_start.c b/arch/arm/src/efm32/efm32_start.c index 14d47ef566c43..56af0be53a52f 100644 --- a/arch/arm/src/efm32/efm32_start.c +++ b/arch/arm/src/efm32/efm32_start.c @@ -70,14 +70,6 @@ const uintptr_t g_idle_topstack = HEAP_BASE; -/**************************************************************************** - * Private Function prototypes - ****************************************************************************/ - -#ifdef CONFIG_ARCH_FPU -static inline void efm32_fpuconfig(void); -#endif - /**************************************************************************** * Private Functions ****************************************************************************/ @@ -92,7 +84,7 @@ static inline void efm32_fpuconfig(void); #ifdef CONFIG_DEBUG_FEATURES # if defined(CONFIG_ARMV7M_ITMSYSLOG) -# define showprogress(c) (void)syslog_putc(c) +# define showprogress(c) syslog_putc(c) # elif defined(HAVE_UART_CONSOLE) || defined(HAVE_LEUART_CONSOLE) # define showprogress(c) efm32_lowputc(c) # else @@ -102,96 +94,6 @@ static inline void efm32_fpuconfig(void); # define showprogress(c) #endif -/**************************************************************************** - * Name: efm32_fpuconfig - * - * Description: - * Configure the FPU. Relative bit settings: - * - * CPACR: Enables access to CP10 and CP11 - * CONTROL.FPCA: Determines whether the FP extension is active in the - * current context: - * FPCCR.ASPEN: Enables automatic FP state preservation, then the - * processor sets this bit to 1 on successful completion of any FP - * instruction. - * FPCCR.LSPEN: Enables lazy context save of FP state. When this is - * done, the processor reserves space on the stack for the FP state, - * but does not save that state information to the stack. - * - * Software must not change the value of the ASPEN bit or LSPEN bit either: - * - the CPACR permits access to CP10 and CP11, that give access to the FP - * extension, or - * - the CONTROL.FPCA bit is set to 1 - * - ****************************************************************************/ - -#ifdef CONFIG_ARCH_FPU -#ifndef CONFIG_ARMV7M_LAZYFPU - -static inline void efm32_fpuconfig(void) -{ - uint32_t regval; - - /* Set CONTROL.FPCA so that we always get the extended context frame - * with the volatile FP registers stacked above the basic context. - */ - - regval = getcontrol(); - regval |= CONTROL_FPCA; - setcontrol(regval); - - /* Ensure that FPCCR.LSPEN is disabled, so that we don't have to contend - * with the lazy FP context save behaviour. Clear FPCCR.ASPEN since we - * are going to turn on CONTROL.FPCA for all contexts. - */ - - regval = getreg32(NVIC_FPCCR); - regval &= ~(NVIC_FPCCR_ASPEN | NVIC_FPCCR_LSPEN); - putreg32(regval, NVIC_FPCCR); - - /* Enable full access to CP10 and CP11 */ - - regval = getreg32(NVIC_CPACR); - regval |= NVIC_CPACR_CP_FULL(10) | NVIC_CPACR_CP_FULL(11); - putreg32(regval, NVIC_CPACR); -} - -#else - -static inline void efm32_fpuconfig(void) -{ - uint32_t regval; - - /* Clear CONTROL.FPCA so that we do not get the extended context frame - * with the volatile FP registers stacked in the saved context. - */ - - regval = getcontrol(); - regval &= ~CONTROL_FPCA; - setcontrol(regval); - - /* Ensure that FPCCR.LSPEN is disabled, so that we don't have to contend - * with the lazy FP context save behaviour. Clear FPCCR.ASPEN since we - * are going to keep CONTROL.FPCA off for all contexts. - */ - - regval = getreg32(NVIC_FPCCR); - regval &= ~(NVIC_FPCCR_ASPEN | NVIC_FPCCR_LSPEN); - putreg32(regval, NVIC_FPCCR); - - /* Enable full access to CP10 and CP11 */ - - regval = getreg32(NVIC_CPACR); - regval |= NVIC_CPACR_CP_FULL(10) | NVIC_CPACR_CP_FULL(11); - putreg32(regval, NVIC_CPACR); -} - -#endif - -#else -# define efm32_fpuconfig() -#endif - /**************************************************************************** * Public Functions ****************************************************************************/ @@ -212,7 +114,7 @@ void __start(void) /* Configure the uart so that we can get debug output as soon as possible */ efm32_clockconfig(); - efm32_fpuconfig(); + arm_fpuconfig(); efm32_lowsetup(); showprogress('A'); diff --git a/arch/arm/src/efm32/efm32_usbhost.c b/arch/arm/src/efm32/efm32_usbhost.c index a53020f4daa60..1f24bde56e3e4 100644 --- a/arch/arm/src/efm32/efm32_usbhost.c +++ b/arch/arm/src/efm32/efm32_usbhost.c @@ -341,8 +341,8 @@ static int efm32_ctrlep_alloc(FAR struct efm32_usbhost_s *priv, FAR const struct usbhost_epdesc_s *epdesc, FAR usbhost_ep_t *ep); static int efm32_xfrep_alloc(FAR struct efm32_usbhost_s *priv, - FAR const struct usbhost_epdesc_s *epdesc, - FAR usbhost_ep_t *ep); + FAR const struct usbhost_epdesc_s *epdesc, + FAR usbhost_ep_t *ep); /* Control/data transfer logic **********************************************/ @@ -434,7 +434,7 @@ static int efm32_ep0configure(FAR struct usbhost_driver_s *drvr, usbhost_ep_t ep0, uint8_t funcaddr, uint8_t speed, uint16_t maxpacketsize); static int efm32_epalloc(FAR struct usbhost_driver_s *drvr, - FAR const FAR struct usbhost_epdesc_s *epdesc, + FAR const struct usbhost_epdesc_s *epdesc, FAR usbhost_ep_t *ep); static int efm32_epfree(FAR struct usbhost_driver_s *drvr, usbhost_ep_t ep); static int efm32_alloc(FAR struct usbhost_driver_s *drvr, @@ -1444,8 +1444,8 @@ static int efm32_ctrlep_alloc(FAR struct efm32_usbhost_s *priv, ****************************************************************************/ static int efm32_xfrep_alloc(FAR struct efm32_usbhost_s *priv, - FAR const struct usbhost_epdesc_s *epdesc, - FAR usbhost_ep_t *ep) + FAR const struct usbhost_epdesc_s *epdesc, + FAR usbhost_ep_t *ep) { struct usbhost_hubport_s *hport; FAR struct efm32_chan_s *chan; diff --git a/arch/arm/src/eoss3/Make.defs b/arch/arm/src/eoss3/Make.defs index 70abc1f0066f0..f210879f64922 100644 --- a/arch/arm/src/eoss3/Make.defs +++ b/arch/arm/src/eoss3/Make.defs @@ -18,39 +18,7 @@ # ############################################################################ -CMN_ASRCS = arm_saveusercontext.S arm_fullcontextrestore.S -CMN_ASRCS += arm_testset.S arm_fetchadd.S vfork.S - -CMN_CSRCS = arm_allocateheap.c arm_assert.c arm_blocktask.c -CMN_CSRCS += arm_createstack.c arm_doirq.c arm_exit.c arm_hardfault.c -CMN_CSRCS += arm_initialize.c arm_initialstate.c arm_interruptcontext.c -CMN_CSRCS += arm_itm.c arm_mdelay.c arm_memfault.c arm_modifyreg8.c -CMN_CSRCS += arm_modifyreg16.c arm_modifyreg32.c arm_releasepending.c -CMN_CSRCS += arm_releasestack.c arm_reprioritizertr.c arm_schedulesigaction.c -CMN_CSRCS += arm_sigdeliver.c arm_stackframe.c arm_svcall.c arm_systemreset.c -CMN_CSRCS += arm_trigger_irq.c arm_udelay.c arm_unblocktask.c arm_usestack.c arm_vfork.c -CMN_CSRCS += arm_switchcontext.c arm_puts.c arm_tcbinfo.c - -ifeq ($(CONFIG_ARMV7M_LAZYFPU),y) -CMN_ASRCS += arm_lazyexception.S -else -CMN_ASRCS += arm_exception.S -endif -CMN_CSRCS += arm_vectors.c - -ifeq ($(CONFIG_ARCH_RAMVECTORS),y) -CMN_CSRCS += arm_ramvec_initialize.c arm_ramvec_attach.c -endif - -ifeq ($(CONFIG_BUILD_PROTECTED),y) -CMN_CSRCS += arm_task_start.c arm_pthread_start.c -CMN_CSRCS += arm_signal_dispatch.c -CMN_UASRCS += arm_signal_handler.S -endif - -ifeq ($(CONFIG_STACK_COLORATION),y) -CMN_CSRCS += arm_checkstack.c -endif +include armv7-m/Make.defs CHIP_CSRCS = eoss3_start.c eoss3_gpio.c eoss3_lowputc.c eoss3_clockconfig.c CHIP_CSRCS += eoss3_irq.c diff --git a/arch/arm/src/eoss3/eoss3_start.c b/arch/arm/src/eoss3/eoss3_start.c index 81511e0215f5b..f9634e33d13ce 100644 --- a/arch/arm/src/eoss3/eoss3_start.c +++ b/arch/arm/src/eoss3/eoss3_start.c @@ -64,14 +64,6 @@ const uintptr_t g_idle_topstack = HEAP_BASE; -/**************************************************************************** - * Private Function prototypes - ****************************************************************************/ - -#ifdef CONFIG_ARCH_FPU -static inline void eoss3_fpuconfig(void); -#endif - /**************************************************************************** * Private Functions ****************************************************************************/ @@ -100,97 +92,6 @@ static inline void eoss3_fpuconfig(void); void __start(void) noinstrument_function; #endif -/**************************************************************************** - * Name: eoss3_fpuconfig - * - * Description: - * Configure the FPU. Relative bit settings: - * - * CPACR: Enables access to CP10 and CP11 - * CONTROL.FPCA: Determines whether the FP extension is active in the - * current context: - * FPCCR.ASPEN: Enables automatic FP state preservation, then the - * processor sets this bit to 1 on successful completion of any FP - * instruction. - * FPCCR.LSPEN: Enables lazy context save of FP state. When this is - * done, the processor reserves space on the stack for the FP state, - * but does not save that state information to the stack. - * - * Software must not change the value of the ASPEN bit or LSPEN bit while - * either: - * - the CPACR permits access to CP10 and CP11, that give access to the FP - * extension, or - * - the CONTROL.FPCA bit is set to 1 - * - ****************************************************************************/ - -#ifdef CONFIG_ARCH_FPU -#ifndef CONFIG_ARMV7M_LAZYFPU - -static inline void eoss3_fpuconfig(void) -{ - uint32_t regval; - - /* Set CONTROL.FPCA so that we always get the extended context frame - * with the volatile FP registers stacked above the basic context. - */ - - regval = getcontrol(); - regval |= CONTROL_FPCA; - setcontrol(regval); - - /* Ensure that FPCCR.LSPEN is disabled, so that we don't have to contend - * with the lazy FP context save behaviour. Clear FPCCR.ASPEN since we - * are going to turn on CONTROL.FPCA for all contexts. - */ - - regval = getreg32(NVIC_FPCCR); - regval &= ~(NVIC_FPCCR_ASPEN | NVIC_FPCCR_LSPEN); - putreg32(regval, NVIC_FPCCR); - - /* Enable full access to CP10 and CP11 */ - - regval = getreg32(NVIC_CPACR); - regval |= NVIC_CPACR_CP_FULL(10) | NVIC_CPACR_CP_FULL(11); - putreg32(regval, NVIC_CPACR); -} - -#else - -static inline void eoss3_fpuconfig(void) -{ - uint32_t regval; - - /* Clear CONTROL.FPCA so that we do not get the extended context frame - * with the volatile FP registers stacked in the saved context. - */ - - regval = getcontrol(); - regval &= ~CONTROL_FPCA; - setcontrol(regval); - - /* Ensure that FPCCR.LSPEN is disabled, so that we don't have to contend - * with the lazy FP context save behaviour. Clear FPCCR.ASPEN since we - * are going to keep CONTROL.FPCA off for all contexts. - */ - - regval = getreg32(NVIC_FPCCR); - regval &= ~(NVIC_FPCCR_ASPEN | NVIC_FPCCR_LSPEN); - putreg32(regval, NVIC_FPCCR); - - /* Enable full access to CP10 and CP11 */ - - regval = getreg32(NVIC_CPACR); - regval |= NVIC_CPACR_CP_FULL(10) | NVIC_CPACR_CP_FULL(11); - putreg32(regval, NVIC_CPACR); -} - -#endif - -#else -# define eoss3_fpuconfig() -#endif - /**************************************************************************** * Public Functions ****************************************************************************/ @@ -219,10 +120,7 @@ void __start(void) eoss3_clockconfig(); - /* Unclear what needs to happen here to make RENODE happy. */ -#if 1 - eoss3_fpuconfig(); -#endif + arm_fpuconfig(); eoss3_lowsetup(); diff --git a/arch/arm/src/imx1/Make.defs b/arch/arm/src/imx1/Make.defs index 965a4a075d4d5..7ba3a87868f66 100644 --- a/arch/arm/src/imx1/Make.defs +++ b/arch/arm/src/imx1/Make.defs @@ -18,26 +18,7 @@ # ############################################################################ -HEAD_ASRC = arm_head.S - -CMN_ASRCS = arm_cache.S arm_fullcontextrestore.S arm_saveusercontext.S -CMN_ASRCS += arm_vectors.S arm_vectoraddrexcptn.S arm_vectortab.S vfork.S -CMN_CSRCS = arm_assert.c arm_blocktask.c arm_createstack.c -CMN_CSRCS += arm_dataabort.c arm_mdelay.c arm_udelay.c arm_exit.c -CMN_CSRCS += arm_initialize.c arm_initialstate.c arm_interruptcontext.c -CMN_CSRCS += arm_prefetchabort.c arm_releasepending.c arm_releasestack.c -CMN_CSRCS += arm_reprioritizertr.c arm_schedulesigaction.c -CMN_CSRCS += arm_sigdeliver.c arm_stackframe.c arm_syscall.c arm_unblocktask.c -CMN_CSRCS += arm_undefinedinsn.c arm_usestack.c arm_vfork.c arm_puts.c -CMN_CSRCS += arm_tcbinfo.c arm_switchcontext.c - -ifneq ($(CONFIG_ARCH_IDLE_CUSTOM),y) -CMN_CSRCS += arm_idle.c -endif - -ifeq ($(CONFIG_STACK_COLORATION),y) -CMN_CSRCS += arm_checkstack.c -endif +include arm/Make.defs CHIP_ASRCS = imx_lowputc.S CHIP_CSRCS = imx_boot.c imx_gpio.c imx_allocateheap.c imx_irq.c diff --git a/arch/arm/src/imx1/imx_decodeirq.c b/arch/arm/src/imx1/imx_decodeirq.c index 74b355b5c2eab..3f634cb9a9878 100644 --- a/arch/arm/src/imx1/imx_decodeirq.c +++ b/arch/arm/src/imx1/imx_decodeirq.c @@ -99,23 +99,16 @@ uint32_t *arm_decodeirq(uint32_t *regs) irq_dispatch(irq, regs); -#if defined(CONFIG_ARCH_FPU) || defined(CONFIG_ARCH_ADDRENV) +#ifdef CONFIG_ARCH_ADDRENV /* Check for a context switch. If a context switch occurred, then * CURRENT_REGS will have a different value than it did on entry. - * If an interrupt level context switch has occurred, then restore - * the floating point state and the establish the correct address - * environment before returning from the interrupt. + * If an interrupt level context switch has occurred, then + * establish the correct address environment before returning + * from the interrupt. */ if (regs != CURRENT_REGS) { -#ifdef CONFIG_ARCH_FPU - /* Restore floating point registers */ - - arm_restorefpu((uint32_t *)CURRENT_REGS); -#endif - -#ifdef CONFIG_ARCH_ADDRENV /* Make sure that the address environment for the previously * running task is closed down gracefully (data caches dump, * MMU flushed) and set up the address environment for the new @@ -123,7 +116,6 @@ uint32_t *arm_decodeirq(uint32_t *regs) */ group_addrenv(NULL); -#endif } #endif } diff --git a/arch/arm/src/imx6/Make.defs b/arch/arm/src/imx6/Make.defs index deccf72e33250..6ec10ee4467d2 100644 --- a/arch/arm/src/imx6/Make.defs +++ b/arch/arm/src/imx6/Make.defs @@ -18,118 +18,7 @@ # ############################################################################ -# The vector table is the "head" object, i.e., the one that must forced into -# the link in order to draw in all of the other components - -HEAD_ASRC = arm_vectortab.S - -ifeq ($(CONFIG_BUILD_KERNEL),y) -crt0$(OBJEXT): crt0.c - $(CC) $(CFLAGS) -c armv7-a$(DELIM)crt0.c -o crt0$(OBJEXT) - -STARTUP_OBJS = crt0$(OBJEXT) -endif - -# Force the start-up logic to be at the beginning of the .text to simplify -# debug. - -ifeq ($(CONFIG_PAGING),y) -CMN_ASRCS = arm_pghead.S -else -CMN_ASRCS = arm_head.S -ifeq ($(CONFIG_SMP),y) -CMN_ASRCS += arm_cpuhead.S -endif -endif - -# Common assembly language files - -CMN_ASRCS += arm_vectors.S arm_fpuconfig.S arm_fullcontextrestore.S -CMN_ASRCS += arm_saveusercontext.S arm_vectoraddrexcptn.S -CMN_ASRCS += arm_testset.S arm_fetchadd.S vfork.S -CMN_ASRCS += cp15_coherent_dcache.S cp15_invalidate_dcache.S -CMN_ASRCS += cp15_clean_dcache.S cp15_flush_dcache.S cp15_invalidate_dcache_all.S -CMN_ASRCS += cp15_clean_dcache_all.S cp15_flush_dcache_all.S cp15_cache_size.S - -# Common C source files - -CMN_CSRCS = arm_initialize.c arm_interruptcontext.c arm_exit.c arm_createstack.c -CMN_CSRCS += arm_releasestack.c arm_usestack.c arm_vfork.c arm_puts.c arm_mdelay.c -CMN_CSRCS += arm_stackframe.c arm_udelay.c arm_modifyreg8.c arm_modifyreg16.c -CMN_CSRCS += arm_modifyreg32.c - -CMN_CSRCS += arm_assert.c arm_blocktask.c arm_dataabort.c -CMN_CSRCS += arm_doirq.c arm_gicv2.c arm_initialstate.c arm_mmu.c -CMN_CSRCS += arm_prefetchabort.c arm_releasepending.c arm_reprioritizertr.c -CMN_CSRCS += arm_schedulesigaction.c arm_sigdeliver.c arm_syscall.c -CMN_CSRCS += arm_unblocktask.c arm_undefinedinsn.c arm_tcbinfo.c -CMN_CSRCS += arm_switchcontext.c - -ifeq ($(CONFIG_ARM_SEMIHOSTING_HOSTFS),y) -CMN_CSRCS += arm_hostfs.c -endif - -ifneq ($(CONFIG_ARCH_IDLE_CUSTOM),y) -CMN_CSRCS += imx_idle.c -endif - -ifeq ($(CONFIG_SMP),y) -CMN_CSRCS += arm_cpuindex.c arm_cpustart.c arm_cpupause.c arm_cpuidlestack.c -CMN_CSRCS += arm_scu.c -endif - -ifeq ($(CONFIG_DEBUG_IRQ_INFO),y) -CMN_CSRCS += arm_gicv2_dump.c -endif - -# Use common heap allocation for now (may need to be customized later) - -CMN_CSRCS += arm_allocateheap.c - -# Configuration dependent C and assembly language files - -ifeq ($(CONFIG_PAGING),y) -CMN_CSRCS += arm_allocpage.c arm_checkmapping.c arm_pginitialize.c -CMN_CSRCS += arm_va2pte.c -endif - -ifeq ($(CONFIG_BUILD_KERNEL),y) -CMN_CSRCS += arm_task_start.c arm_pthread_start.c arm_signal_dispatch.c -endif - -ifeq ($(CONFIG_ARCH_ADDRENV),y) -CMN_CSRCS += arm_addrenv.c arm_addrenv_utils.c arm_pgalloc.c -ifeq ($(CONFIG_ARCH_STACK_DYNAMIC),y) -CMN_CSRCS += arm_addrenv_ustack.c -endif -ifeq ($(CONFIG_ARCH_KERNEL_STACK),y) -CMN_CSRCS += arm_addrenv_kstack.c -endif -ifeq ($(CONFIG_MM_SHM),y) -CMN_CSRCS += arm_addrenv_shm.c -endif -endif - -ifeq ($(CONFIG_MM_PGALLOC),y) -CMN_CSRCS += arm_physpgaddr.c -ifeq ($(CONFIG_ARCH_PGPOOL_MAPPING),y) -CMN_CSRCS += arm_virtpgaddr.c -endif -endif - -CMN_CSRCS += arm_cache.c - -ifeq ($(CONFIG_ARCH_L2CACHE),y) -CMN_CSRCS += arm_l2cc_pl310.c -endif - -ifeq ($(CONFIG_ARCH_FPU),y) -CMN_ASRCS += arm_savefpu.S arm_restorefpu.S -endif - -ifeq ($(CONFIG_STACK_COLORATION),y) -CMN_CSRCS += arm_checkstack.c -endif +include armv7-a/Make.defs # i.MX6-specific C source files diff --git a/arch/arm/src/imx6/imx_boot.c b/arch/arm/src/imx6/imx_boot.c index 9b8d2ed9b6177..9a2fc74d3adaa 100644 --- a/arch/arm/src/imx6/imx_boot.c +++ b/arch/arm/src/imx6/imx_boot.c @@ -39,7 +39,6 @@ #include "arm.h" #include "mmu.h" #include "scu.h" -#include "fpu.h" #include "arm_internal.h" #include "imx_config.h" #include "imx_clockconfig.h" @@ -443,12 +442,10 @@ void arm_boot(void) imx_clockconfig(); PROGRESS('I'); -#ifdef CONFIG_ARCH_FPU /* Initialize the FPU */ arm_fpuconfig(); PROGRESS('J'); -#endif /* Perform board-specific memory initialization, This must include * initialization of board-specific memory resources (e.g., SDRAM) diff --git a/arch/arm/src/imx6/imx_cpuboot.c b/arch/arm/src/imx6/imx_cpuboot.c index 85dbfb0617587..cec8cff8eee37 100644 --- a/arch/arm/src/imx6/imx_cpuboot.c +++ b/arch/arm/src/imx6/imx_cpuboot.c @@ -35,7 +35,6 @@ #include "sctlr.h" #include "smp.h" #include "scu.h" -#include "fpu.h" #include "gic.h" #ifdef CONFIG_SMP @@ -247,11 +246,9 @@ void arm_cpu_boot(int cpu) arm_enable_smp(cpu); -#ifdef CONFIG_ARCH_FPU /* Initialize the FPU */ arm_fpuconfig(); -#endif /* Initialize the Generic Interrupt Controller (GIC) for CPUn (n != 0) */ diff --git a/arch/arm/src/imxrt/Make.defs b/arch/arm/src/imxrt/Make.defs index dffb42187a9c9..f67aa27b9ce0b 100644 --- a/arch/arm/src/imxrt/Make.defs +++ b/arch/arm/src/imxrt/Make.defs @@ -20,55 +20,7 @@ # Common ARM and Cortex-M7 files -CMN_ASRCS = arm_saveusercontext.S arm_fullcontextrestore.S -CMN_ASRCS += arm_testset.S arm_fetchadd.S vfork.S - -CMN_CSRCS = arm_assert.c arm_blocktask.c -CMN_CSRCS += arm_createstack.c arm_mdelay.c arm_udelay.c arm_exit.c -CMN_CSRCS += arm_initialize.c arm_initialstate.c arm_interruptcontext.c -CMN_CSRCS += arm_memfault.c arm_modifyreg8.c arm_modifyreg16.c arm_modifyreg32.c -CMN_CSRCS += arm_releasepending.c arm_releasestack.c arm_reprioritizertr.c -CMN_CSRCS += arm_schedulesigaction.c arm_sigdeliver.c arm_stackframe.c -CMN_CSRCS += arm_unblocktask.c arm_usestack.c arm_doirq.c arm_hardfault.c -CMN_CSRCS += arm_svcall.c arm_vfork.c arm_trigger_irq.c arm_systemreset.c -CMN_CSRCS += arm_switchcontext.c arm_puts.c arm_tcbinfo.c - -ifeq ($(CONFIG_ARMV7M_STACKCHECK),y) -CMN_CSRCS += arm_stackcheck.c -endif - -# Configuration-dependent common files - -ifeq ($(CONFIG_ARMV7M_LAZYFPU),y) -CMN_ASRCS += arm_lazyexception.S -else -CMN_ASRCS += arm_exception.S -endif -CMN_CSRCS += arm_vectors.c - -ifeq ($(CONFIG_ARCH_RAMVECTORS),y) -CMN_CSRCS += arm_ramvec_initialize.c arm_ramvec_attach.c -endif - -ifeq ($(CONFIG_ARM_MPU),y) -CMN_CSRCS += arm_mpu.c -endif - -ifeq ($(CONFIG_BUILD_PROTECTED),y) -CMN_CSRCS += arm_task_start.c arm_pthread_start.c -CMN_CSRCS += arm_signal_dispatch.c -CMN_UASRCS += arm_signal_handler.S -endif - -ifeq ($(CONFIG_STACK_COLORATION),y) -CMN_CSRCS += arm_checkstack.c -endif - -CMN_CSRCS += arm_cache.c - -ifeq ($(CONFIG_ARCH_FPU),y) -CMN_ASRCS += arm_fpu.S -endif +include armv7-m/Make.defs # Required i.MX RT files diff --git a/arch/arm/src/imxrt/hardware/rt102x/imxrt102x_xbar.h b/arch/arm/src/imxrt/hardware/rt102x/imxrt102x_xbar.h index 8de712949e585..12f3a658ce347 100644 --- a/arch/arm/src/imxrt/hardware/rt102x/imxrt102x_xbar.h +++ b/arch/arm/src/imxrt/hardware/rt102x/imxrt102x_xbar.h @@ -1,3 +1,23 @@ +/**************************************************************************** + * arch/arm/src/imxrt/hardware/rt102x/imxrt102x_xbar.h + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + /* XBAR Defines for IMXRT102x */ /* XBARA1 Mux inputs (I values) *********************************************/ diff --git a/arch/arm/src/imxrt/hardware/rt105x/imxrt105x_xbar.h b/arch/arm/src/imxrt/hardware/rt105x/imxrt105x_xbar.h index 56b35c1939fbb..061040ac7bf46 100644 --- a/arch/arm/src/imxrt/hardware/rt105x/imxrt105x_xbar.h +++ b/arch/arm/src/imxrt/hardware/rt105x/imxrt105x_xbar.h @@ -1,3 +1,23 @@ +/**************************************************************************** + * arch/arm/src/imxrt/hardware/rt105x/imxrt105x_xbar.h + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + /* XBAR Defines for IMXRT1050 */ /* XBARA1 Mux inputs (I values) *********************************************/ diff --git a/arch/arm/src/imxrt/hardware/rt106x/imxrt106x_xbar.h b/arch/arm/src/imxrt/hardware/rt106x/imxrt106x_xbar.h index b997fe05fb3de..92f65e4a38856 100644 --- a/arch/arm/src/imxrt/hardware/rt106x/imxrt106x_xbar.h +++ b/arch/arm/src/imxrt/hardware/rt106x/imxrt106x_xbar.h @@ -1,3 +1,23 @@ +/**************************************************************************** + * arch/arm/src/imxrt/hardware/rt106x/imxrt106x_xbar.h + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + /* XBAR Defines for IMXRT1060 */ /* XBARA1 Mux inputs (I values) *********************************************/ diff --git a/arch/arm/src/imxrt/imxrt_ehci.c b/arch/arm/src/imxrt/imxrt_ehci.c index 2e68d013aac16..1bf8bb6aaa7d5 100644 --- a/arch/arm/src/imxrt/imxrt_ehci.c +++ b/arch/arm/src/imxrt/imxrt_ehci.c @@ -515,41 +515,46 @@ static int imxrt_ehci_interrupt(int irq, FAR void *context, FAR void *arg); /* USB Host Controller Operations *******************************************/ static int imxrt_wait(FAR struct usbhost_connection_s *conn, - FAR struct usbhost_hubport_s **hport); + FAR struct usbhost_hubport_s **hport); static int imxrt_rh_enumerate(FAR struct usbhost_connection_s *conn, - FAR struct usbhost_hubport_s *hport); + FAR struct usbhost_hubport_s *hport); static int imxrt_enumerate(FAR struct usbhost_connection_s *conn, - FAR struct usbhost_hubport_s *hport); + FAR struct usbhost_hubport_s *hport); static int imxrt_ep0configure(FAR struct usbhost_driver_s *drvr, - usbhost_ep_t ep0, uint8_t funcaddr, uint8_t speed, - uint16_t maxpacketsize); + usbhost_ep_t ep0, uint8_t funcaddr, + uint8_t speed, uint16_t maxpacketsize); static int imxrt_epalloc(FAR struct usbhost_driver_s *drvr, - const FAR struct usbhost_epdesc_s *epdesc, usbhost_ep_t *ep); + FAR const struct usbhost_epdesc_s *epdesc, + FAR usbhost_ep_t *ep); static int imxrt_epfree(FAR struct usbhost_driver_s *drvr, usbhost_ep_t ep); static int imxrt_alloc(FAR struct usbhost_driver_s *drvr, - FAR uint8_t **buffer, FAR size_t *maxlen); + FAR uint8_t **buffer, FAR size_t *maxlen); static int imxrt_free(FAR struct usbhost_driver_s *drvr, - FAR uint8_t *buffer); + FAR uint8_t *buffer); static int imxrt_ioalloc(FAR struct usbhost_driver_s *drvr, - FAR uint8_t **buffer, size_t buflen); + FAR uint8_t **buffer, size_t buflen); static int imxrt_iofree(FAR struct usbhost_driver_s *drvr, - FAR uint8_t *buffer); + FAR uint8_t *buffer); static int imxrt_ctrlin(FAR struct usbhost_driver_s *drvr, usbhost_ep_t ep0, - FAR const struct usb_ctrlreq_s *req, FAR uint8_t *buffer); + FAR const struct usb_ctrlreq_s *req, + FAR uint8_t *buffer); static int imxrt_ctrlout(FAR struct usbhost_driver_s *drvr, usbhost_ep_t ep0, - FAR const struct usb_ctrlreq_s *req, FAR const uint8_t *buffer); + FAR const struct usb_ctrlreq_s *req, + FAR const uint8_t *buffer); static ssize_t imxrt_transfer(FAR struct usbhost_driver_s *drvr, - usbhost_ep_t ep, FAR uint8_t *buffer, size_t buflen); + usbhost_ep_t ep, FAR uint8_t *buffer, + size_t buflen); #ifdef CONFIG_USBHOST_ASYNCH static int imxrt_asynch(FAR struct usbhost_driver_s *drvr, usbhost_ep_t ep, - FAR uint8_t *buffer, size_t buflen, usbhost_asynch_t callback, - FAR void *arg); + FAR uint8_t *buffer, size_t buflen, + usbhost_asynch_t callback, FAR void *arg); #endif static int imxrt_cancel(FAR struct usbhost_driver_s *drvr, usbhost_ep_t ep); #ifdef CONFIG_USBHOST_HUB static int imxrt_connect(FAR struct usbhost_driver_s *drvr, - FAR struct usbhost_hubport_s *hport, bool connected); + FAR struct usbhost_hubport_s *hport, + bool connected); #endif static void imxrt_disconnect(FAR struct usbhost_driver_s *drvr, FAR struct usbhost_hubport_s *hport); @@ -3968,8 +3973,8 @@ static int imxrt_ep0configure(FAR struct usbhost_driver_s *drvr, ****************************************************************************/ static int imxrt_epalloc(FAR struct usbhost_driver_s *drvr, - const FAR struct usbhost_epdesc_s *epdesc, - usbhost_ep_t *ep) + FAR const struct usbhost_epdesc_s *epdesc, + FAR usbhost_ep_t *ep) { struct imxrt_epinfo_s *epinfo; struct usbhost_hubport_s *hport; diff --git a/arch/arm/src/imxrt/imxrt_flexspi.c b/arch/arm/src/imxrt/imxrt_flexspi.c index a36f84f4550e0..10a4256a7af3f 100644 --- a/arch/arm/src/imxrt/imxrt_flexspi.c +++ b/arch/arm/src/imxrt/imxrt_flexspi.c @@ -581,7 +581,7 @@ void imxrt_flexspi_get_default_config(struct flexspi_config_s *config) { /* Initializes the configure structure to zero */ - (void)memset(config, 0, sizeof(*config)); + memset(config, 0, sizeof(*config)); config->rx_sample_clock = FLEXSPI_READ_SAMPLE_CLK_LOOPBACK_FROM_DQS_PAD; config->enable_sck_free_running = false; @@ -606,8 +606,8 @@ void imxrt_flexspi_get_default_config(struct flexspi_config_s *config) config->ahb_config.ahb_grant_timeout_cycle = 0xff; config->ahb_config.ahb_bus_timeout_cycle = 0xffff; config->ahb_config.resume_wait_cycle = 0x20; - (void)memset(config->ahb_config.buffer, 0, - sizeof(config->ahb_config.buffer)); + memset(config->ahb_config.buffer, 0, + sizeof(config->ahb_config.buffer)); /* Use invalid master ID 0xF and buffer size 0 for the first several * buffers. diff --git a/arch/arm/src/imxrt/imxrt_start.c b/arch/arm/src/imxrt/imxrt_start.c index f462f694d4aa8..346d8936b2a9a 100644 --- a/arch/arm/src/imxrt/imxrt_start.c +++ b/arch/arm/src/imxrt/imxrt_start.c @@ -65,14 +65,6 @@ * here. */ -/**************************************************************************** - * Private Function prototypes - ****************************************************************************/ - -#ifdef CONFIG_ARCH_FPU -static inline void imxrt_fpuconfig(void); -#endif - /**************************************************************************** * Private Functions ****************************************************************************/ @@ -83,98 +75,6 @@ static inline void imxrt_fpuconfig(void); void __start(void) noinstrument_function; #endif -/**************************************************************************** - * Name: imxrt_fpuconfig - * - * Description: - * Configure the FPU. Relative bit settings: - * - * CPACR: Enables access to CP10 and CP11 - * CONTROL.FPCA: Determines whether the FP extension is active in the - * current context: - * FPCCR.ASPEN: Enables automatic FP state preservation, then the - * processor sets this bit to 1 on successful completion of any FP - * instruction. - * FPCCR.LSPEN: Enables lazy context save of FP state. When this is - * done, the processor reserves space on the stack for the FP state, - * but does not save that state information to the stack. - * - * Software must not change the value of the ASPEN bit or LSPEN bit while - * either: - * - * - the CPACR permits access to CP10 and CP11, that give access to the FP - * extension, or - * - the CONTROL.FPCA bit is set to 1 - * - ****************************************************************************/ - -#ifdef CONFIG_ARCH_FPU -#ifndef CONFIG_ARMV7M_LAZYFPU - -static inline void imxrt_fpuconfig(void) -{ - uint32_t regval; - - /* Set CONTROL.FPCA so that we always get the extended context frame - * with the volatile FP registers stacked above the basic context. - */ - - regval = getcontrol(); - regval |= CONTROL_FPCA; - setcontrol(regval); - - /* Ensure that FPCCR.LSPEN is disabled, so that we don't have to contend - * with the lazy FP context save behavior. Clear FPCCR.ASPEN since we - * are going to turn on CONTROL.FPCA for all contexts. - */ - - regval = getreg32(NVIC_FPCCR); - regval &= ~(NVIC_FPCCR_ASPEN | NVIC_FPCCR_LSPEN); - putreg32(regval, NVIC_FPCCR); - - /* Enable full access to CP10 and CP11 */ - - regval = getreg32(NVIC_CPACR); - regval |= NVIC_CPACR_CP_FULL(10) | NVIC_CPACR_CP_FULL(11); - putreg32(regval, NVIC_CPACR); -} - -#else - -static inline void imxrt_fpuconfig(void) -{ - uint32_t regval; - - /* Clear CONTROL.FPCA so that we do not get the extended context frame - * with the volatile FP registers stacked in the saved context. - */ - - regval = getcontrol(); - regval &= ~CONTROL_FPCA; - setcontrol(regval); - - /* Ensure that FPCCR.LSPEN is disabled, so that we don't have to contend - * with the lazy FP context save behavior. Clear FPCCR.ASPEN since we - * are going to keep CONTROL.FPCA off for all contexts. - */ - - regval = getreg32(NVIC_FPCCR); - regval &= ~(NVIC_FPCCR_ASPEN | NVIC_FPCCR_LSPEN); - putreg32(regval, NVIC_FPCCR); - - /* Enable full access to CP10 and CP11 */ - - regval = getreg32(NVIC_CPACR); - regval |= NVIC_CPACR_CP_FULL(10) | NVIC_CPACR_CP_FULL(11); - putreg32(regval, NVIC_CPACR); -} - -#endif - -#else -# define imxrt_fpuconfig() -#endif - /**************************************************************************** * Name: imxrt_tcmenable * @@ -286,7 +186,7 @@ void __start(void) /* Configure the UART so that we can get debug output as soon as possible */ imxrt_clockconfig(); - imxrt_fpuconfig(); + arm_fpuconfig(); imxrt_lowsetup(); /* Enable/disable tightly coupled memories */ diff --git a/arch/arm/src/imxrt/imxrt_usdhc.c b/arch/arm/src/imxrt/imxrt_usdhc.c index 950eceda02001..466a731ab6d56 100644 --- a/arch/arm/src/imxrt/imxrt_usdhc.c +++ b/arch/arm/src/imxrt/imxrt_usdhc.c @@ -1330,8 +1330,8 @@ static int imxrt_interrupt(int irq, void *context, FAR void *arg) mcinfo("Queuing callback to %p(%p)\n", priv->callback, priv->cbarg); - (void)work_queue(HPWORK, &priv->cbwork, (worker_t)priv->callback, - priv->cbarg, 0); + work_queue(HPWORK, &priv->cbwork, priv->callback, + priv->cbarg, 0); } else { @@ -3148,7 +3148,7 @@ static void imxrt_callback(void *arg) mcinfo("Queuing callback to %p(%p)\n", priv->callback, priv->cbarg); - work_queue(HPWORK, &priv->cbwork, (worker_t)priv->callback, + work_queue(HPWORK, &priv->cbwork, priv->callback, priv->cbarg, 0); } else diff --git a/arch/arm/src/kinetis/Make.defs b/arch/arm/src/kinetis/Make.defs index 659a0220b99c9..3cf29b248d322 100644 --- a/arch/arm/src/kinetis/Make.defs +++ b/arch/arm/src/kinetis/Make.defs @@ -18,65 +18,7 @@ # ############################################################################ -CMN_ASRCS = arm_saveusercontext.S arm_fullcontextrestore.S -CMN_ASRCS += arm_testset.S arm_fetchadd.S vfork.S - -CMN_CSRCS = arm_assert.c arm_blocktask.c arm_createstack.c -CMN_CSRCS += arm_mdelay.c arm_udelay.c arm_exit.c arm_initialize.c arm_memfault.c -CMN_CSRCS += arm_initialstate.c arm_interruptcontext.c arm_modifyreg8.c -CMN_CSRCS += arm_modifyreg16.c arm_modifyreg32.c arm_releasestack.c -CMN_CSRCS += arm_reprioritizertr.c arm_schedulesigaction.c arm_releasepending.c -CMN_CSRCS += arm_sigdeliver.c arm_stackframe.c arm_unblocktask.c arm_usestack.c -CMN_CSRCS += arm_doirq.c arm_hardfault.c arm_svcall.c arm_vfork.c -CMN_CSRCS += arm_systemreset.c arm_trigger_irq.c arm_switchcontext.c arm_puts.c -CMN_CSRCS += arm_tcbinfo.c - -ifeq ($(CONFIG_ARMV7M_STACKCHECK),y) -CMN_CSRCS += arm_stackcheck.c -endif - -ifeq ($(CONFIG_ARMV7M_LAZYFPU),y) -CMN_ASRCS += arm_lazyexception.S -else -CMN_ASRCS += arm_exception.S -endif -CMN_CSRCS += arm_vectors.c - -ifeq ($(CONFIG_ARCH_RAMVECTORS),y) -CMN_CSRCS += arm_ramvec_initialize.c arm_ramvec_attach.c -endif - -ifeq ($(CONFIG_ARM_MPU),y) -CMN_CSRCS += arm_mpu.c -endif - -ifeq ($(CONFIG_BUILD_PROTECTED),y) -CMN_CSRCS += arm_task_start.c arm_pthread_start.c -CMN_CSRCS += arm_signal_dispatch.c -CMN_UASRCS += arm_signal_handler.S -endif - -ifeq ($(CONFIG_STACK_COLORATION),y) -CMN_CSRCS += arm_checkstack.c -endif - -# Use of common/arm_etherstub.c is deprecated. The preferred mechanism is to -# use CONFIG_NETDEV_LATEINIT=y to suppress the call to arm_netinitialize() in -# up_initialize(). Then this stub would not be needed. - -ifeq ($(CONFIG_NET),y) -ifneq ($(CONFIG_KINETIS_ENET),y) -CMN_CSRCS += arm_etherstub.c -endif -endif - -ifeq ($(CONFIG_ARCH_FPU),y) -CMN_ASRCS += arm_fpu.S -endif - -ifeq ($(CONFIG_ARMV7M_ITMSYSLOG),y) -CMN_CSRCS += arm_itm_syslog.c -endif +include armv7-m/Make.defs # Required Kinetis files diff --git a/arch/arm/src/kinetis/kinetis_sdhc.c b/arch/arm/src/kinetis/kinetis_sdhc.c index e3058f716d34b..3b3ffe012b2bc 100644 --- a/arch/arm/src/kinetis/kinetis_sdhc.c +++ b/arch/arm/src/kinetis/kinetis_sdhc.c @@ -2831,7 +2831,7 @@ static void kinetis_callback(void *arg) mcinfo("Queuing callback to %p(%p)\n", priv->callback, priv->cbarg); - work_queue(HPWORK, &priv->cbwork, (worker_t)priv->callback, + work_queue(HPWORK, &priv->cbwork, priv->callback, priv->cbarg, 0); } else diff --git a/arch/arm/src/kinetis/kinetis_start.c b/arch/arm/src/kinetis/kinetis_start.c index 62dbc08aa9680..8d0cadd9b4da3 100644 --- a/arch/arm/src/kinetis/kinetis_start.c +++ b/arch/arm/src/kinetis/kinetis_start.c @@ -40,14 +40,6 @@ #include "kinetis_start.h" -/**************************************************************************** - * Private Function prototypes - ****************************************************************************/ - -#ifdef CONFIG_ARCH_FPU -static inline void kinetis_fpuconfig(void); -#endif - /**************************************************************************** * Pre-processor Definitions ****************************************************************************/ @@ -96,96 +88,6 @@ const uintptr_t g_idle_topstack = HEAP_BASE; void __start(void) noinstrument_function; #endif -/**************************************************************************** - * Name: kinetis_fpuconfig - * - * Description: - * Configure the FPU. Relative bit settings: - * - * CPACR: Enables access to CP10 and CP11 - * CONTROL.FPCA: Determines whether the FP extension is active in the - * current context: - * FPCCR.ASPEN: Enables automatic FP state preservation, then the - * processor sets this bit to 1 on successful completion of any FP - * instruction. - * FPCCR.LSPEN: Enables lazy context save of FP state. When this is - * done, the processor reserves space on the stack for the FP state, - * but does not save that state information to the stack. - * - * Software must not change the value of the ASPEN bit or LSPEN bit either: - * - the CPACR permits access to CP10 and CP11, that give access to the FP - * extension, or - * - the CONTROL.FPCA bit is set to 1 - * - ****************************************************************************/ - -#ifdef CONFIG_ARCH_FPU -#ifndef CONFIG_ARMV7M_LAZYFPU - -static inline void kinetis_fpuconfig(void) -{ - uint32_t regval; - - /* Set CONTROL.FPCA so that we always get the extended context frame - * with the volatile FP registers stacked above the basic context. - */ - - regval = getcontrol(); - regval |= CONTROL_FPCA; - setcontrol(regval); - - /* Ensure that FPCCR.LSPEN is disabled, so that we don't have to contend - * with the lazy FP context save behavior. Clear FPCCR.ASPEN since we - * are going to turn on CONTROL.FPCA for all contexts. - */ - - regval = getreg32(NVIC_FPCCR); - regval &= ~(NVIC_FPCCR_ASPEN | NVIC_FPCCR_LSPEN); - putreg32(regval, NVIC_FPCCR); - - /* Enable full access to CP10 and CP11 */ - - regval = getreg32(NVIC_CPACR); - regval |= NVIC_CPACR_CP_FULL(10) | NVIC_CPACR_CP_FULL(11); - putreg32(regval, NVIC_CPACR); -} - -#else - -static inline void kinetis_fpuconfig(void) -{ - uint32_t regval; - - /* Clear CONTROL.FPCA so that we do not get the extended context frame - * with the volatile FP registers stacked in the saved context. - */ - - regval = getcontrol(); - regval &= ~CONTROL_FPCA; - setcontrol(regval); - - /* Ensure that FPCCR.LSPEN is disabled, so that we don't have to contend - * with the lazy FP context save behavior. Clear FPCCR.ASPEN since we - * are going to keep CONTROL.FPCA off for all contexts. - */ - - regval = getreg32(NVIC_FPCCR); - regval &= ~(NVIC_FPCCR_ASPEN | NVIC_FPCCR_LSPEN); - putreg32(regval, NVIC_FPCCR); - - /* Enable full access to CP10 and CP11 */ - - regval = getreg32(NVIC_CPACR); - regval |= NVIC_CPACR_CP_FULL(10) | NVIC_CPACR_CP_FULL(11); - putreg32(regval, NVIC_CPACR); -} - -#endif - -#else -# define kinetis_fpuconfig() -#endif - /**************************************************************************** * Public Functions ****************************************************************************/ @@ -258,7 +160,7 @@ void __start(void) * configuration). */ - kinetis_fpuconfig(); + arm_fpuconfig(); kinetis_lowsetup(); #ifdef USE_EARLYSERIALINIT kinetis_earlyserialinit(); diff --git a/arch/arm/src/kinetis/kinetis_usbhshost.c b/arch/arm/src/kinetis/kinetis_usbhshost.c index 962e48b21bbf7..9a69c3ab6de82 100644 --- a/arch/arm/src/kinetis/kinetis_usbhshost.c +++ b/arch/arm/src/kinetis/kinetis_usbhshost.c @@ -533,27 +533,27 @@ static int kinetis_ehci_interrupt(int irq, /* USB Host Controller Operations *******************************************/ static int kinetis_wait(FAR struct usbhost_connection_s *conn, - FAR struct usbhost_hubport_s **hport); + FAR struct usbhost_hubport_s **hport); static int kinetis_rh_enumerate(FAR struct usbhost_connection_s *conn, - FAR struct usbhost_hubport_s *hport); + FAR struct usbhost_hubport_s *hport); static int kinetis_enumerate(FAR struct usbhost_connection_s *conn, - FAR struct usbhost_hubport_s *hport); - + FAR struct usbhost_hubport_s *hport); static int kinetis_ep0configure(FAR struct usbhost_driver_s *drvr, - usbhost_ep_t ep0, uint8_t funcaddr, uint8_t speed, - uint16_t maxpacketsize); + usbhost_ep_t ep0, uint8_t funcaddr, + uint8_t speed, uint16_t maxpacketsize); static int kinetis_epalloc(FAR struct usbhost_driver_s *drvr, - const FAR struct usbhost_epdesc_s *epdesc, usbhost_ep_t *ep); + FAR const struct usbhost_epdesc_s *epdesc, + FAR usbhost_ep_t *ep); static int kinetis_epfree(FAR struct usbhost_driver_s *drvr, usbhost_ep_t ep); static int kinetis_alloc(FAR struct usbhost_driver_s *drvr, - FAR uint8_t **buffer, FAR size_t *maxlen); + FAR uint8_t **buffer, FAR size_t *maxlen); static int kinetis_free(FAR struct usbhost_driver_s *drvr, - FAR uint8_t *buffer); + FAR uint8_t *buffer); static int kinetis_ioalloc(FAR struct usbhost_driver_s *drvr, - FAR uint8_t **buffer, size_t buflen); + FAR uint8_t **buffer, size_t buflen); static int kinetis_iofree(FAR struct usbhost_driver_s *drvr, - FAR uint8_t *buffer); + FAR uint8_t *buffer); static int kinetis_ctrlin(FAR struct usbhost_driver_s *drvr, usbhost_ep_t ep0, FAR const struct usb_ctrlreq_s *req, @@ -563,23 +563,22 @@ static int kinetis_ctrlout(FAR struct usbhost_driver_s *drvr, FAR const struct usb_ctrlreq_s *req, FAR const uint8_t *buffer); static ssize_t kinetis_transfer(FAR struct usbhost_driver_s *drvr, - usbhost_ep_t ep, FAR uint8_t *buffer, size_t buflen); + usbhost_ep_t ep, FAR uint8_t *buffer, + size_t buflen); #ifdef CONFIG_USBHOST_ASYNCH -static int kinetis_asynch(FAR struct usbhost_driver_s *drvr, - usbhost_ep_t ep, - FAR uint8_t *buffer, - size_t buflen, - usbhost_asynch_t callback, - FAR void *arg); +static int kinetis_asynch(FAR struct usbhost_driver_s *drvr, usbhost_ep_t ep, + FAR uint8_t *buffer, size_t buflen, + usbhost_asynch_t callback, FAR void *arg); #endif static int kinetis_cancel(FAR struct usbhost_driver_s *drvr, usbhost_ep_t ep); #ifdef CONFIG_USBHOST_HUB static int kinetis_connect(FAR struct usbhost_driver_s *drvr, - FAR struct usbhost_hubport_s *hport, bool connected); + FAR struct usbhost_hubport_s *hport, + bool connected); #endif static void kinetis_disconnect(FAR struct usbhost_driver_s *drvr, - FAR struct usbhost_hubport_s *hport); + FAR struct usbhost_hubport_s *hport); /* Initialization ***********************************************************/ @@ -4043,8 +4042,8 @@ static int kinetis_ep0configure(FAR struct usbhost_driver_s *drvr, ****************************************************************************/ static int kinetis_epalloc(FAR struct usbhost_driver_s *drvr, - const FAR struct usbhost_epdesc_s *epdesc, - usbhost_ep_t *ep) + FAR const struct usbhost_epdesc_s *epdesc, + FAR usbhost_ep_t *ep) { struct kinetis_epinfo_s *epinfo; struct usbhost_hubport_s *hport; diff --git a/arch/arm/src/kl/Make.defs b/arch/arm/src/kl/Make.defs index 4d009bbea45db..80046d2395098 100644 --- a/arch/arm/src/kl/Make.defs +++ b/arch/arm/src/kl/Make.defs @@ -18,32 +18,7 @@ # ############################################################################ -CMN_ASRCS = arm_exception.S arm_saveusercontext.S arm_fullcontextrestore.S -CMN_ASRCS += vfork.S - -CMN_CSRCS = arm_allocateheap.c arm_assert.c arm_blocktask.c -CMN_CSRCS += arm_createstack.c arm_mdelay.c arm_udelay.c arm_exit.c -CMN_CSRCS += arm_initialize.c arm_initialstate.c arm_interruptcontext.c -CMN_CSRCS += arm_puts.c arm_modifyreg8.c arm_modifyreg16.c arm_modifyreg32.c -CMN_CSRCS += arm_releasepending.c arm_releasestack.c arm_reprioritizertr.c -CMN_CSRCS += arm_schedulesigaction.c arm_sigdeliver.c arm_stackframe.c -CMN_CSRCS += arm_systemreset.c arm_unblocktask.c arm_usestack.c arm_doirq.c -CMN_CSRCS += arm_hardfault.c arm_svcall.c arm_vectors.c arm_vfork.c -CMN_CSRCS += arm_switchcontext.c arm_tcbinfo.c - -ifeq ($(CONFIG_BUILD_PROTECTED),y) -CMN_CSRCS += arm_task_start.c arm_pthread_start.c -CMN_CSRCS += arm_signal_dispatch.c -CMN_UASRCS += arm_signal_handler.S -endif - -ifeq ($(CONFIG_STACK_COLORATION),y) -CMN_CSRCS += arm_checkstack.c -endif - -ifeq ($(CONFIG_DEBUG_FEATURES),y) -CMN_CSRCS += arm_dumpnvic.c -endif +include armv6-m/Make.defs CHIP_CSRCS = kl_clockconfig.c kl_gpio.c kl_irq.c kl_lowputc.c CHIP_CSRCS += kl_serial.c kl_start.c kl_cfmconfig.c diff --git a/arch/arm/src/lc823450/Make.defs b/arch/arm/src/lc823450/Make.defs index de798bf0d66a1..905f3a1786dc3 100644 --- a/arch/arm/src/lc823450/Make.defs +++ b/arch/arm/src/lc823450/Make.defs @@ -18,46 +18,7 @@ # ############################################################################ -CMN_ASRCS = arm_saveusercontext.S arm_fullcontextrestore.S -CMN_ASRCS += vfork.S - -CMN_CSRCS = arm_assert.c arm_blocktask.c -CMN_CSRCS += arm_createstack.c arm_mdelay.c arm_udelay.c arm_exit.c -CMN_CSRCS += arm_initialize.c arm_initialstate.c arm_interruptcontext.c -CMN_CSRCS += arm_memfault.c arm_modifyreg8.c arm_modifyreg16.c arm_modifyreg32.c -CMN_CSRCS += arm_releasepending.c arm_releasestack.c arm_reprioritizertr.c -CMN_CSRCS += arm_schedulesigaction.c arm_sigdeliver.c arm_systemreset.c -CMN_CSRCS += arm_unblocktask.c arm_usestack.c arm_doirq.c arm_hardfault.c -CMN_CSRCS += arm_svcall.c arm_vfork.c arm_trigger_irq.c arm_switchcontext.c -CMN_CSRCS += arm_puts.c arm_tcbinfo.c - -# CMN_CSRCS += up_dwt.c - -CMN_CSRCS += arm_stackframe.c -CMN_ASRCS += arm_exception.S -CMN_CSRCS += arm_vectors.c - -ifeq ($(CONFIG_ARCH_RAMVECTORS),y) -CMN_CSRCS += arm_ramvec_initialize.c arm_ramvec_attach.c -endif - -ifeq ($(CONFIG_BUILD_PROTECTED),y) -CMN_CSRCS += arm_task_start.c arm_pthread_start.c -CMN_CSRCS += arm_signal_dispatch.c -CMN_UASRCS += arm_signal_handler.S -endif - -ifeq ($(CONFIG_ARCH_MEMCPY),y) -CMN_ASRCS += memcpy-armv7m.S -endif - -ifeq ($(CONFIG_ARCH_MEMMOVE),y) -CMN_CSRCS += up_memmove.c -endif - -ifeq ($(CONFIG_STACK_COLORATION),y) -CMN_CSRCS += arm_checkstack.c -endif +include armv7-m/Make.defs CHIP_CSRCS = lc823450_allocateheap2.c lc823450_start.c lc823450_irq.c lc823450_timer.c CHIP_CSRCS += lc823450_lowputc.c lc823450_serial.c lc823450_clockconfig.c @@ -95,7 +56,7 @@ CHIP_CSRCS += lc823450_spi.c endif ifeq ($(CONFIG_ARCH_DMA), y) -CMN_CSRCS += lc823450_dma.c +CHIP_CSRCS += lc823450_dma.c endif ifeq ($(CONFIG_RTC),y) @@ -134,6 +95,7 @@ CHIP_CSRCS += lc823450_cpuindex.c CHIP_CSRCS += lc823450_cpupause.c CHIP_CSRCS += lc823450_cpustart.c CHIP_CSRCS += lc823450_testset.c +CMN_ASRCS := $(filter-out arm_testset.S,$(CMN_ASRCS)) endif ifeq ($(CONFIG_LC823450_SDRAM), y) @@ -154,6 +116,5 @@ CHIP_CSRCS += lc823450_userspace.c endif ifeq ($(CONFIG_ARM_MPU),y) -CMN_CSRCS += arm_mpu.c CHIP_CSRCS += lc823450_mpuinit2.c endif diff --git a/arch/arm/src/lpc17xx_40xx/Make.defs b/arch/arm/src/lpc17xx_40xx/Make.defs index 2b6aabd4ec114..79c96c8a01be3 100644 --- a/arch/arm/src/lpc17xx_40xx/Make.defs +++ b/arch/arm/src/lpc17xx_40xx/Make.defs @@ -20,57 +20,7 @@ # Common ARM and Cortex-M3 files -CMN_ASRCS = arm_saveusercontext.S arm_fullcontextrestore.S -CMN_ASRCS += arm_testset.S arm_fetchadd.S vfork.S - -CMN_CSRCS = arm_assert.c arm_blocktask.c arm_createstack.c -CMN_CSRCS += arm_mdelay.c arm_udelay.c arm_exit.c arm_initialize.c arm_memfault.c -CMN_CSRCS += arm_initialstate.c arm_interruptcontext.c arm_modifyreg8.c -CMN_CSRCS += arm_modifyreg16.c arm_modifyreg32.c arm_releasepending.c -CMN_CSRCS += arm_releasestack.c arm_reprioritizertr.c arm_schedulesigaction.c -CMN_CSRCS += arm_sigdeliver.c arm_stackframe.c arm_trigger_irq.c -CMN_CSRCS += arm_unblocktask.c arm_usestack.c arm_doirq.c arm_hardfault.c -CMN_CSRCS += arm_svcall.c arm_checkstack.c arm_vfork.c arm_switchcontext.c -CMN_CSRCS += arm_systemreset.c arm_puts.c arm_tcbinfo.c - -ifeq ($(CONFIG_ARMV7M_STACKCHECK),y) -CMN_CSRCS += arm_stackcheck.c -endif - -ifeq ($(CONFIG_ARMV7M_LAZYFPU),y) -CMN_ASRCS += arm_lazyexception.S -else -CMN_ASRCS += arm_exception.S -endif -CMN_CSRCS += arm_vectors.c - -ifeq ($(CONFIG_ARCH_RAMVECTORS),y) -CMN_CSRCS += arm_ramvec_initialize.c arm_ramvec_attach.c -endif - -ifeq ($(CONFIG_ARM_MPU),y) -CMN_CSRCS += arm_mpu.c -endif - -ifeq ($(CONFIG_BUILD_PROTECTED),y) -CMN_CSRCS += arm_task_start.c arm_pthread_start.c -CMN_CSRCS += arm_signal_dispatch.c -CMN_UASRCS += arm_signal_handler.S -endif - -# Use of common/arm_etherstub.c is deprecated. The preferred mechanism is to -# use CONFIG_NETDEV_LATEINIT=y to suppress the call to arm_netinitialize() in -# up_initialize(). Then this stub would not be needed. - -ifeq ($(CONFIG_NET),y) -ifneq ($(CONFIG_LPC17_40_ETHERNET),y) -CMN_CSRCS += arm_etherstub.c -endif -endif - -ifeq ($(CONFIG_ARCH_FPU),y) -CMN_ASRCS += arm_fpu.S -endif +include armv7-m/Make.defs # Required LPC17xx files diff --git a/arch/arm/src/lpc17xx_40xx/lpc17_40_adc.c b/arch/arm/src/lpc17xx_40xx/lpc17_40_adc.c index e21b25c45d234..da106ef420f71 100644 --- a/arch/arm/src/lpc17xx_40xx/lpc17_40_adc.c +++ b/arch/arm/src/lpc17xx_40xx/lpc17_40_adc.c @@ -615,7 +615,7 @@ static int adc_interrupt(int irq, void *context, FAR void *arg) #ifdef CONFIG_ADC_WORKER_THREAD if (adc0_int_done == 1) { - work_queue(HPWORK, &priv->irqwork, (worker_t)adc_irqworker, + work_queue(HPWORK, &priv->irqwork, adc_irqworker, (FAR void *)priv, 0); } diff --git a/arch/arm/src/lpc17xx_40xx/lpc17_40_ethernet.c b/arch/arm/src/lpc17xx_40xx/lpc17_40_ethernet.c index 00ba8ce03b984..3d7684f71d9d8 100644 --- a/arch/arm/src/lpc17xx_40xx/lpc17_40_ethernet.c +++ b/arch/arm/src/lpc17xx_40xx/lpc17_40_ethernet.c @@ -1277,7 +1277,7 @@ static int lpc17_40_interrupt(int irq, void *context, FAR void *arg) */ work_queue(ETHWORK, &priv->lp_rxwork, - (worker_t)lpc17_40_rxdone_work, priv, 0); + lpc17_40_rxdone_work, priv, 0); } /* Check for Tx events ********************************************/ @@ -1339,7 +1339,7 @@ static int lpc17_40_interrupt(int irq, void *context, FAR void *arg) */ work_queue(ETHWORK, &priv->lp_txwork, - (worker_t)lpc17_40_txdone_work, priv, 0); + lpc17_40_txdone_work, priv, 0); } } } @@ -1489,7 +1489,7 @@ static void lpc17_40_poll_work(FAR void *arg) if (considx != prodidx) { - work_queue(ETHWORK, &priv->lp_rxwork, (worker_t)lpc17_40_rxdone_work, + work_queue(ETHWORK, &priv->lp_rxwork, lpc17_40_rxdone_work, priv, 0); } diff --git a/arch/arm/src/lpc17xx_40xx/lpc17_40_sdcard.c b/arch/arm/src/lpc17xx_40xx/lpc17_40_sdcard.c index 1c75f22a5a400..87fde5773bfef 100644 --- a/arch/arm/src/lpc17xx_40xx/lpc17_40_sdcard.c +++ b/arch/arm/src/lpc17xx_40xx/lpc17_40_sdcard.c @@ -2697,8 +2697,8 @@ static void lpc17_40_callback(void *arg) mcinfo("Queuing callback to %p(%p)\n", priv->callback, priv->cbarg); - work_queue(HPWORK, &priv->cbwork, (worker_t)priv->callback, - priv->cbarg, 0); + work_queue(HPWORK, &priv->cbwork, priv->callback, + priv->cbarg, 0); } else { diff --git a/arch/arm/src/lpc17xx_40xx/lpc17_40_start.c b/arch/arm/src/lpc17xx_40xx/lpc17_40_start.c index 7983ae65d9321..0edc1eaf26059 100644 --- a/arch/arm/src/lpc17xx_40xx/lpc17_40_start.c +++ b/arch/arm/src/lpc17xx_40xx/lpc17_40_start.c @@ -86,96 +86,6 @@ const uintptr_t g_idle_topstack = HEAP_BASE; # define showprogress(c) #endif -/**************************************************************************** - * Name: lpc17_40_fpuconfig - * - * Description: - * Configure the FPU. Relative bit settings: - * - * CPACR: Enables access to CP10 and CP11 - * CONTROL.FPCA: Determines whether the FP extension is active in the - * current context: - * FPCCR.ASPEN: Enables automatic FP state preservation, then the - * processor sets this bit to 1 on successful completion of any FP - * instruction. - * FPCCR.LSPEN: Enables lazy context save of FP state. When this is - * done, the processor reserves space on the stack for the FP state, - * but does not save that state information to the stack. - * - * Software must not change the value of the ASPEN bit or LSPEN bit either: - * - the CPACR permits access to CP10 and CP11, that give access to the FP - * extension, or - * - the CONTROL.FPCA bit is set to 1 - * - ****************************************************************************/ - -#ifdef CONFIG_ARCH_FPU -#ifndef CONFIG_ARMV7M_LAZYFPU - -static inline void lpc17_40_fpuconfig(void) -{ - uint32_t regval; - - /* Set CONTROL.FPCA so that we always get the extended context frame - * with the volatile FP registers stacked above the basic context. - */ - - regval = getcontrol(); - regval |= CONTROL_FPCA; - setcontrol(regval); - - /* Ensure that FPCCR.LSPEN is disabled, so that we don't have to contend - * with the lazy FP context save behaviour. Clear FPCCR.ASPEN since we - * are going to turn on CONTROL.FPCA for all contexts. - */ - - regval = getreg32(NVIC_FPCCR); - regval &= ~(NVIC_FPCCR_ASPEN | NVIC_FPCCR_LSPEN); - putreg32(regval, NVIC_FPCCR); - - /* Enable full access to CP10 and CP11 */ - - regval = getreg32(NVIC_CPACR); - regval |= NVIC_CPACR_CP_FULL(10) | NVIC_CPACR_CP_FULL(11); - putreg32(regval, NVIC_CPACR); -} - -#else - -static inline void lpc17_40_fpuconfig(void) -{ - uint32_t regval; - - /* Clear CONTROL.FPCA so that we do not get the extended context frame - * with the volatile FP registers stacked in the saved context. - */ - - regval = getcontrol(); - regval &= ~CONTROL_FPCA; - setcontrol(regval); - - /* Ensure that FPCCR.LSPEN is disabled, so that we don't have to contend - * with the lazy FP context save behaviour. Clear FPCCR.ASPEN since we - * are going to keep CONTROL.FPCA off for all contexts. - */ - - regval = getreg32(NVIC_FPCCR); - regval &= ~(NVIC_FPCCR_ASPEN | NVIC_FPCCR_LSPEN); - putreg32(regval, NVIC_FPCCR); - - /* Enable full access to CP10 and CP11 */ - - regval = getreg32(NVIC_CPACR); - regval |= NVIC_CPACR_CP_FULL(10) | NVIC_CPACR_CP_FULL(11); - putreg32(regval, NVIC_CPACR); -} - -#endif - -#else -# define lpc17_40_fpuconfig() -#endif - /**************************************************************************** * Public Functions ****************************************************************************/ @@ -213,7 +123,7 @@ void __start(void) /* Configure the uart so that we can get debug output as soon as possible */ lpc17_40_clockconfig(); - lpc17_40_fpuconfig(); + arm_fpuconfig(); lpc17_40_lowsetup(); showprogress('A'); diff --git a/arch/arm/src/lpc214x/Make.defs b/arch/arm/src/lpc214x/Make.defs index 3769326f9a643..887e288a69caa 100644 --- a/arch/arm/src/lpc214x/Make.defs +++ b/arch/arm/src/lpc214x/Make.defs @@ -18,28 +18,9 @@ # ############################################################################## -HEAD_ASRC = lpc214x_head.S +include arm/Make.defs -CMN_ASRCS = arm_saveusercontext.S arm_fullcontextrestore.S arm_vectors.S -CMN_ASRCS += vfork.S - -CMN_CSRCS = arm_allocateheap.c arm_assert.c arm_blocktask.c -CMN_CSRCS += arm_createstack.c arm_dataabort.c arm_mdelay.c arm_udelay.c -CMN_CSRCS += arm_exit.c arm_initialize.c arm_initialstate.c -CMN_CSRCS += arm_interruptcontext.c arm_prefetchabort.c arm_releasepending.c -CMN_CSRCS += arm_releasestack.c arm_reprioritizertr.c arm_stackframe.c -CMN_CSRCS += arm_syscall.c arm_unblocktask.c arm_undefinedinsn.c arm_usestack.c -CMN_CSRCS += arm_schedulesigaction.c arm_sigdeliver.c -CMN_CSRCS += arm_lowputs.c arm_vfork.c arm_puts.c arm_tcbinfo.c -CMN_CSRCS += arm_switchcontext.c - -ifneq ($(CONFIG_ARCH_IDLE_CUSTOM),y) -CMN_CSRCS += arm_idle.c -endif - -ifeq ($(CONFIG_STACK_COLORATION),y) -CMN_CSRCS += arm_checkstack.c -endif +HEAD_ASRC = lpc214x_head.S CHIP_ASRCS = lpc214x_lowputc.S CHIP_CSRCS = lpc214x_decodeirq.c lpc214x_irq.c lpc214x_serial.c diff --git a/arch/arm/src/lpc2378/Make.defs b/arch/arm/src/lpc2378/Make.defs index 24ae5dd5e3ca4..b95622df2c6de 100644 --- a/arch/arm/src/lpc2378/Make.defs +++ b/arch/arm/src/lpc2378/Make.defs @@ -18,27 +18,9 @@ # ############################################################################## -HEAD_ASRC = lpc23xx_head.S +include arm/Make.defs -CMN_ASRCS = arm_saveusercontext.S arm_fullcontextrestore.S arm_vectors.S -CMN_ASRCS += vfork.S -CMN_CSRCS = arm_allocateheap.c arm_assert.c arm_blocktask.c -CMN_CSRCS += arm_createstack.c arm_dataabort.c arm_mdelay.c arm_udelay.c -CMN_CSRCS += arm_exit.c arm_initialize.c arm_initialstate.c -CMN_CSRCS += arm_interruptcontext.c arm_prefetchabort.c arm_releasepending.c -CMN_CSRCS += arm_releasestack.c arm_reprioritizertr.c arm_stackframe.c -CMN_CSRCS += arm_syscall.c arm_unblocktask.c arm_undefinedinsn.c -CMN_CSRCS += arm_usestack.c arm_lowputs.c arm_vfork.c -CMN_CSRCS += arm_schedulesigaction.c arm_sigdeliver.c arm_puts.c arm_tcbinfo.c -CMN_CSRCS += arm_switchcontext.c - -ifneq ($(CONFIG_ARCH_IDLE_CUSTOM),y) -CMN_CSRCS += arm_idle.c -endif - -ifeq ($(CONFIG_STACK_COLORATION),y) -CMN_CSRCS += arm_checkstack.c -endif +HEAD_ASRC = lpc23xx_head.S CHIP_ASRCS = lpc23xx_lowputc.S CHIP_CSRCS += lpc23xx_pllsetup.c lpc23xx_decodeirq.c lpc23xx_irq.c diff --git a/arch/arm/src/lpc31xx/Make.defs b/arch/arm/src/lpc31xx/Make.defs index ae31963b37aed..93d02ce3c8b0f 100644 --- a/arch/arm/src/lpc31xx/Make.defs +++ b/arch/arm/src/lpc31xx/Make.defs @@ -18,32 +18,7 @@ # ############################################################################ -HEAD_ASRC = arm_head.S - -CMN_ASRCS = arm_cache.S arm_fullcontextrestore.S arm_saveusercontext.S -CMN_ASRCS += arm_vectors.S arm_vectoraddrexcptn.S arm_vectortab.S vfork.S - -CMN_CSRCS = arm_assert.c arm_blocktask.c arm_createstack.c -CMN_CSRCS += arm_dataabort.c arm_mdelay.c arm_udelay.c arm_exit.c -CMN_CSRCS += arm_initialize.c arm_initialstate.c arm_interruptcontext.c -CMN_CSRCS += arm_modifyreg8.c arm_modifyreg16.c arm_modifyreg32.c -CMN_CSRCS += arm_prefetchabort.c arm_releasepending.c arm_releasestack.c -CMN_CSRCS += arm_reprioritizertr.c arm_schedulesigaction.c -CMN_CSRCS += arm_sigdeliver.c arm_stackframe.c arm_syscall.c arm_unblocktask.c -CMN_CSRCS += arm_undefinedinsn.c arm_usestack.c arm_vfork.c arm_puts.c -CMN_CSRCS += arm_tcbinfo.c arm_switchcontext.c - -ifneq ($(CONFIG_ARCH_IDLE_CUSTOM),y) -CMN_CSRCS += arm_idle.c -endif - -ifeq ($(CONFIG_PAGING),y) -CMN_CSRCS += arm_pginitialize.c arm_checkmapping.c arm_allocpage.c arm_va2pte.c -endif - -ifeq ($(CONFIG_STACK_COLORATION),y) -CMN_CSRCS += arm_checkstack.c -endif +include arm/Make.defs CGU_CSRCS = lpc31_bcrndx.c lpc31_clkdomain.c lpc31_clkexten.c CGU_CSRCS += lpc31_clkfreq.c lpc31_clkinit.c lpc31_defclk.c diff --git a/arch/arm/src/lpc31xx/lpc31_decodeirq.c b/arch/arm/src/lpc31xx/lpc31_decodeirq.c index 712071463608c..8a504fd675785 100644 --- a/arch/arm/src/lpc31xx/lpc31_decodeirq.c +++ b/arch/arm/src/lpc31xx/lpc31_decodeirq.c @@ -89,23 +89,16 @@ uint32_t *arm_decodeirq(uint32_t *regs) irq_dispatch(irq, regs); -#if defined(CONFIG_ARCH_FPU) || defined(CONFIG_ARCH_ADDRENV) +#ifdef CONFIG_ARCH_ADDRENV /* Check for a context switch. If a context switch occurred, then * CURRENT_REGS will have a different value than it did on entry. - * If an interrupt level context switch has occurred, then restore - * the floating point state and the establish the correct address - * environment before returning from the interrupt. + * If an interrupt level context switch has occurred, then + * establish the correct address environment before returning + * from the interrupt. */ if (regs != CURRENT_REGS) { -#ifdef CONFIG_ARCH_FPU - /* Restore floating point registers */ - - arm_restorefpu((uint32_t *)CURRENT_REGS); -#endif - -#ifdef CONFIG_ARCH_ADDRENV /* Make sure that the address environment for the previously * running task is closed down gracefully (data caches dump, * MMU flushed) and set up the address environment for the new @@ -113,7 +106,6 @@ uint32_t *arm_decodeirq(uint32_t *regs) */ group_addrenv(NULL); -#endif } #endif diff --git a/arch/arm/src/lpc31xx/lpc31_ehci.c b/arch/arm/src/lpc31xx/lpc31_ehci.c index 7afeddcf7429a..504e71200f443 100644 --- a/arch/arm/src/lpc31xx/lpc31_ehci.c +++ b/arch/arm/src/lpc31xx/lpc31_ehci.c @@ -528,7 +528,8 @@ static int lpc31_ep0configure(FAR struct usbhost_driver_s *drvr, usbhost_ep_t ep0, uint8_t funcaddr, uint8_t speed, uint16_t maxpacketsize); static int lpc31_epalloc(FAR struct usbhost_driver_s *drvr, - const FAR struct usbhost_epdesc_s *epdesc, usbhost_ep_t *ep); + FAR const struct usbhost_epdesc_s *epdesc, + FAR usbhost_ep_t *ep); static int lpc31_epfree(FAR struct usbhost_driver_s *drvr, usbhost_ep_t ep); static int lpc31_alloc(FAR struct usbhost_driver_s *drvr, FAR uint8_t **buffer, FAR size_t *maxlen); @@ -3992,8 +3993,8 @@ static int lpc31_ep0configure(FAR struct usbhost_driver_s *drvr, ****************************************************************************/ static int lpc31_epalloc(FAR struct usbhost_driver_s *drvr, - const FAR struct usbhost_epdesc_s *epdesc, - usbhost_ep_t *ep) + FAR const struct usbhost_epdesc_s *epdesc, + FAR usbhost_ep_t *ep) { struct lpc31_epinfo_s *epinfo; struct usbhost_hubport_s *hport; diff --git a/arch/arm/src/lpc43xx/Make.defs b/arch/arm/src/lpc43xx/Make.defs index 206eda081399c..ab3c658702768 100644 --- a/arch/arm/src/lpc43xx/Make.defs +++ b/arch/arm/src/lpc43xx/Make.defs @@ -18,47 +18,7 @@ # ############################################################################ -CMN_ASRCS = arm_saveusercontext.S arm_fullcontextrestore.S -CMN_ASRCS += arm_testset.S arm_fetchadd.S vfork.S - -CMN_CSRCS = arm_assert.c arm_blocktask.c arm_createstack.c -CMN_CSRCS += arm_doirq.c arm_exit.c arm_hardfault.c arm_initialize.c -CMN_CSRCS += arm_initialstate.c arm_interruptcontext.c arm_mdelay.c -CMN_CSRCS += arm_memfault.c arm_modifyreg8.c arm_modifyreg16.c arm_modifyreg32.c -CMN_CSRCS += arm_releasepending.c arm_releasestack.c arm_reprioritizertr.c -CMN_CSRCS += arm_schedulesigaction.c arm_sigdeliver.c arm_stackframe.c -CMN_CSRCS += arm_svcall.c arm_trigger_irq.c arm_unblocktask.c arm_udelay.c -CMN_CSRCS += arm_usestack.c arm_vfork.c arm_switchcontext.c arm_puts.c -CMN_CSRCS += arm_tcbinfo.c - -ifeq ($(CONFIG_ARMV7M_LAZYFPU),y) -CMN_ASRCS += arm_lazyexception.S -else -CMN_ASRCS += arm_exception.S -endif -CMN_CSRCS += arm_vectors.c - -ifeq ($(CONFIG_ARCH_RAMVECTORS),y) -CMN_CSRCS += arm_ramvec_initialize.c arm_ramvec_attach.c -endif - -ifeq ($(CONFIG_ARM_MPU),y) -CMN_CSRCS += arm_mpu.c -endif - -ifeq ($(CONFIG_BUILD_PROTECTED),y) -CMN_CSRCS += arm_task_start.c arm_pthread_start.c -CMN_CSRCS += arm_signal_dispatch.c -CMN_UASRCS += arm_signal_handler.S -endif - -ifeq ($(CONFIG_STACK_COLORATION),y) -CMN_CSRCS += arm_checkstack.c -endif - -ifeq ($(CONFIG_ARCH_FPU),y) -CMN_ASRCS += arm_fpu.S -endif +include armv7-m/Make.defs CHIP_CSRCS = lpc43_allocateheap.c lpc43_cgu.c lpc43_clrpend.c lpc43_gpio.c CHIP_CSRCS += lpc43_irq.c lpc43_pinconfig.c lpc43_rgu.c lpc43_serial.c diff --git a/arch/arm/src/lpc43xx/lpc43_ehci.c b/arch/arm/src/lpc43xx/lpc43_ehci.c index 25bae0b071175..6e9a80234b372 100644 --- a/arch/arm/src/lpc43xx/lpc43_ehci.c +++ b/arch/arm/src/lpc43xx/lpc43_ehci.c @@ -517,7 +517,8 @@ static int lpc43_ep0configure(FAR struct usbhost_driver_s *drvr, usbhost_ep_t ep0, uint8_t funcaddr, uint8_t speed, uint16_t maxpacketsize); static int lpc43_epalloc(FAR struct usbhost_driver_s *drvr, - const FAR struct usbhost_epdesc_s *epdesc, usbhost_ep_t *ep); + FAR const struct usbhost_epdesc_s *epdesc, + FAR usbhost_ep_t *ep); static int lpc43_epfree(FAR struct usbhost_driver_s *drvr, usbhost_ep_t ep); static int lpc43_alloc(FAR struct usbhost_driver_s *drvr, FAR uint8_t **buffer, FAR size_t *maxlen); @@ -3829,8 +3830,8 @@ static int lpc43_ep0configure(FAR struct usbhost_driver_s *drvr, ****************************************************************************/ static int lpc43_epalloc(FAR struct usbhost_driver_s *drvr, - const FAR struct usbhost_epdesc_s *epdesc, - usbhost_ep_t *ep) + FAR const struct usbhost_epdesc_s *epdesc, + FAR usbhost_ep_t *ep) { struct lpc43_epinfo_s *epinfo; struct usbhost_hubport_s *hport; diff --git a/arch/arm/src/lpc43xx/lpc43_emc.c b/arch/arm/src/lpc43xx/lpc43_emc.c index df1c862b5c31c..32327a5b53bb5 100644 --- a/arch/arm/src/lpc43xx/lpc43_emc.c +++ b/arch/arm/src/lpc43xx/lpc43_emc.c @@ -1,6 +1,21 @@ /**************************************************************************** * arch/arm/src/lpc43xx/lpc43_emc.c * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * ****************************************************************************/ /**************************************************************************** diff --git a/arch/arm/src/lpc43xx/lpc43_rtc.h b/arch/arm/src/lpc43xx/lpc43_rtc.h index d90d22a5ae996..e1764bc275562 100644 --- a/arch/arm/src/lpc43xx/lpc43_rtc.h +++ b/arch/arm/src/lpc43xx/lpc43_rtc.h @@ -1,37 +1,20 @@ /**************************************************************************** * arch/arm/src/lpc43xx/lpc43_rtc.h * - * Copyright (C) 2012, 2017 Gregory Nutt. All rights reserved. - * Author: Brandon Warhurst + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at * - * Adapted from the similar LCP17xx RTC by Gintaras Drukteinis. + * http://www.apache.org/licenses/LICENSE-2.0 * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * 3. Neither the name NuttX nor the names of its contributors may be - * used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. * ****************************************************************************/ diff --git a/arch/arm/src/lpc43xx/lpc43_sdmmc.c b/arch/arm/src/lpc43xx/lpc43_sdmmc.c index b23bcbadbc416..7076638bfdcf5 100644 --- a/arch/arm/src/lpc43xx/lpc43_sdmmc.c +++ b/arch/arm/src/lpc43xx/lpc43_sdmmc.c @@ -2787,7 +2787,7 @@ static void lpc43_callback(struct lpc43_dev_s *priv) mcinfo("Queuing callback to %p(%p)\n", priv->callback, priv->cbarg); - work_queue(HPWORK, &priv->cbwork, (worker_t)priv->callback, + work_queue(HPWORK, &priv->cbwork, priv->callback, priv->cbarg, 0); } else diff --git a/arch/arm/src/lpc43xx/lpc43_start.c b/arch/arm/src/lpc43xx/lpc43_start.c index c59e3364448c5..4fbe63e51194b 100644 --- a/arch/arm/src/lpc43xx/lpc43_start.c +++ b/arch/arm/src/lpc43xx/lpc43_start.c @@ -83,7 +83,7 @@ #endif /**************************************************************************** - * Public Functions + * Private Functions ****************************************************************************/ /**************************************************************************** @@ -153,97 +153,6 @@ static inline void lpc43_enabuffering(void) # define lpc43_enabuffering() #endif -/**************************************************************************** - * Name: lpc43_fpuconfig - * - * Description: - * Configure the FPU. Relative bit settings: - * - * CPACR: Enables access to CP10 and CP11 - * CONTROL.FPCA: Determines whether the FP extension is active in the - * current context: - * FPCCR.ASPEN: Enables automatic FP state preservation, then the - * processor sets this bit to 1 on successful completion of any FP - * instruction. - * FPCCR.LSPEN: Enables lazy context save of FP state. When this is - * done, the processor reserves space on the stack for the FP state, - * but does not save that state information to the stack. - * - * Software must not change the value of the ASPEN bit or LSPEN bit while - * either: - * - the CPACR permits access to CP10 and CP11, that give access to the FP - * extension, or - * - the CONTROL.FPCA bit is set to 1 - * - ****************************************************************************/ - -#ifdef CONFIG_ARCH_FPU -#ifndef CONFIG_ARMV7M_LAZYFPU - -static inline void lpc43_fpuconfig(void) -{ - uint32_t regval; - - /* Set CONTROL.FPCA so that we always get the extended context frame - * with the volatile FP registers stacked above the basic context. - */ - - regval = getcontrol(); - regval |= CONTROL_FPCA; - setcontrol(regval); - - /* Ensure that FPCCR.LSPEN is disabled, so that we don't have to contend - * with the lazy FP context save behaviour. Clear FPCCR.ASPEN since we - * are going to turn on CONTROL.FPCA for all contexts. - */ - - regval = getreg32(NVIC_FPCCR); - regval &= ~(NVIC_FPCCR_ASPEN | NVIC_FPCCR_LSPEN); - putreg32(regval, NVIC_FPCCR); - - /* Enable full access to CP10 and CP11 */ - - regval = getreg32(NVIC_CPACR); - regval |= NVIC_CPACR_CP_FULL(10) | NVIC_CPACR_CP_FULL(11); - putreg32(regval, NVIC_CPACR); -} - -#else - -static inline void lpc43_fpuconfig(void) -{ - uint32_t regval; - - /* Clear CONTROL.FPCA so that we do not get the extended context frame - * with the volatile FP registers stacked in the saved context. - */ - - regval = getcontrol(); - regval &= ~CONTROL_FPCA; - setcontrol(regval); - - /* Ensure that FPCCR.LSPEN is disabled, so that we don't have to contend - * with the lazy FP context save behaviour. Clear FPCCR.ASPEN since we - * are going to keep CONTROL.FPCA off for all contexts. - */ - - regval = getreg32(NVIC_FPCCR); - regval &= ~(NVIC_FPCCR_ASPEN | NVIC_FPCCR_LSPEN); - putreg32(regval, NVIC_FPCCR); - - /* Enable full access to CP10 and CP11 */ - - regval = getreg32(NVIC_CPACR); - regval |= NVIC_CPACR_CP_FULL(10) | NVIC_CPACR_CP_FULL(11); - putreg32(regval, NVIC_CPACR); -} - -#endif - -#else -# define lpc43_fpuconfig() -#endif - /**************************************************************************** * Public Functions ****************************************************************************/ @@ -316,7 +225,7 @@ void __start(void) /* Initialize the FPU (if configured) */ - lpc43_fpuconfig(); + arm_fpuconfig(); showprogress('D'); /* Perform early serial initialization */ diff --git a/arch/arm/src/lpc54xx/Make.defs b/arch/arm/src/lpc54xx/Make.defs index 7ed81e4eca9ad..a9edb18d49362 100644 --- a/arch/arm/src/lpc54xx/Make.defs +++ b/arch/arm/src/lpc54xx/Make.defs @@ -18,47 +18,7 @@ # ############################################################################ -CMN_ASRCS = arm_saveusercontext.S arm_fullcontextrestore.S -CMN_ASRCS += arm_testset.S arm_fetchadd.S vfork.S - -CMN_CSRCS = arm_assert.c arm_blocktask.c arm_createstack.c -CMN_CSRCS += arm_doirq.c arm_exit.c arm_hardfault.c arm_initialize.c -CMN_CSRCS += arm_initialstate.c arm_interruptcontext.c arm_mdelay.c -CMN_CSRCS += arm_memfault.c arm_modifyreg8.c arm_modifyreg16.c arm_modifyreg32.c -CMN_CSRCS += arm_releasepending.c arm_releasestack.c arm_reprioritizertr.c -CMN_CSRCS += arm_schedulesigaction.c arm_sigdeliver.c arm_stackframe.c -CMN_CSRCS += arm_svcall.c arm_trigger_irq.c arm_unblocktask.c arm_udelay.c -CMN_CSRCS += arm_usestack.c arm_vfork.c arm_switchcontext.c arm_puts.c -CMN_CSRCS += arm_tcbinfo.c - -ifeq ($(CONFIG_ARMV7M_LAZYFPU),y) -CMN_ASRCS += arm_lazyexception.S -else -CMN_ASRCS += arm_exception.S -endif -CMN_CSRCS += arm_vectors.c - -ifeq ($(CONFIG_ARCH_RAMVECTORS),y) -CMN_CSRCS += arm_ramvec_initialize.c arm_ramvec_attach.c -endif - -ifeq ($(CONFIG_ARM_MPU),y) -CMN_CSRCS += arm_mpu.c -endif - -ifeq ($(CONFIG_BUILD_PROTECTED),y) -CMN_CSRCS += arm_task_start.c arm_pthread_start.c -CMN_CSRCS += arm_signal_dispatch.c -CMN_UASRCS += arm_signal_handler.S -endif - -ifeq ($(CONFIG_STACK_COLORATION),y) -CMN_CSRCS += arm_checkstack.c -endif - -ifeq ($(CONFIG_ARCH_FPU),y) -CMN_ASRCS += arm_fpu.S -endif +include armv7-m/Make.defs CHIP_CSRCS = lpc54_start.c lpc54_clockconfig.c lpc54_irq.c lpc54_clrpend.c CHIP_CSRCS += lpc54_allocateheap.c lpc54_lowputc.c lpc54_gpio.c lpc54_reset.c diff --git a/arch/arm/src/lpc54xx/lpc54_sdmmc.c b/arch/arm/src/lpc54xx/lpc54_sdmmc.c index edb088d329fb4..fe608c5056399 100644 --- a/arch/arm/src/lpc54xx/lpc54_sdmmc.c +++ b/arch/arm/src/lpc54xx/lpc54_sdmmc.c @@ -2783,7 +2783,7 @@ static void lpc54_callback(struct lpc54_dev_s *priv) mcinfo("Queuing callback to %p(%p)\n", priv->callback, priv->cbarg); - work_queue(HPWORK, &priv->cbwork, (worker_t)priv->callback, + work_queue(HPWORK, &priv->cbwork, priv->callback, priv->cbarg, 0); } else diff --git a/arch/arm/src/lpc54xx/lpc54_start.c b/arch/arm/src/lpc54xx/lpc54_start.c index 09d55239bbe5f..14c0d80f1cde7 100644 --- a/arch/arm/src/lpc54xx/lpc54_start.c +++ b/arch/arm/src/lpc54xx/lpc54_start.c @@ -80,97 +80,6 @@ static const struct pll_setup_s g_initial_pll_setup = .ahbdiv = SYSCON_AHBCLKDIV_DIV(BOARD_AHBCLKDIV) }; -/**************************************************************************** - * Private Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: lpc54_fpuconfig - * - * Description: - * Configure the FPU. Relative bit settings: - * - * CPACR: Enables access to CP10 and CP11 - * CONTROL.FPCA: Determines whether the FP extension is active in the - * current context: - * FPCCR.ASPEN: Enables automatic FP state preservation, then the - * processor sets this bit to 1 on successful completion of any FP - * instruction. - * FPCCR.LSPEN: Enables lazy context save of FP state. When this is - * done, the processor reserves space on the stack for the FP state, - * but does not save that state information to the stack. - * - * Software must not change the value of the ASPEN bit or LSPEN bit while - * either: - * - the CPACR permits access to CP10 and CP11, that give access to the FP - * extension, or - * - the CONTROL.FPCA bit is set to 1 - * - ****************************************************************************/ - -#ifdef CONFIG_ARCH_FPU -#ifndef CONFIG_ARMV7M_LAZYFPU -static inline void lpc54_fpuconfig(void) -{ - uint32_t regval; - - /* Set CONTROL.FPCA so that we always get the extended context frame - * with the volatile FP registers stacked above the basic context. - */ - - regval = getcontrol(); - regval |= CONTROL_FPCA; - setcontrol(regval); - - /* Ensure that FPCCR.LSPEN is disabled, so that we don't have to contend - * with the lazy FP context save behaviour. Clear FPCCR.ASPEN since we - * are going to turn on CONTROL.FPCA for all contexts. - */ - - regval = getreg32(NVIC_FPCCR); - regval &= ~(NVIC_FPCCR_ASPEN | NVIC_FPCCR_LSPEN); - putreg32(regval, NVIC_FPCCR); - - /* Enable full access to CP10 and CP11 */ - - regval = getreg32(NVIC_CPACR); - regval |= NVIC_CPACR_CP_FULL(10) | NVIC_CPACR_CP_FULL(11); - putreg32(regval, NVIC_CPACR); -} -#else -static inline void lpc54_fpuconfig(void) -{ - uint32_t regval; - - /* Clear CONTROL.FPCA so that we do not get the extended context frame - * with the volatile FP registers stacked in the saved context. - */ - - regval = getcontrol(); - regval &= ~CONTROL_FPCA; - setcontrol(regval); - - /* Ensure that FPCCR.LSPEN is disabled, so that we don't have to contend - * with the lazy FP context save behaviour. Clear FPCCR.ASPEN since we - * are going to keep CONTROL.FPCA off for all contexts. - */ - - regval = getreg32(NVIC_FPCCR); - regval &= ~(NVIC_FPCCR_ASPEN | NVIC_FPCCR_LSPEN); - putreg32(regval, NVIC_FPCCR); - - /* Enable full access to CP10 and CP11 */ - - regval = getreg32(NVIC_CPACR); - regval |= NVIC_CPACR_CP_FULL(10) | NVIC_CPACR_CP_FULL(11); - putreg32(regval, NVIC_CPACR); -} -#endif - -#else -# define lpc54_fpuconfig() -#endif - /**************************************************************************** * Public Functions ****************************************************************************/ @@ -234,7 +143,7 @@ void __start(void) /* Initialize the FPU (if configured) */ - lpc54_fpuconfig(); + arm_fpuconfig(); showprogress('D'); /* Perform early serial initialization */ diff --git a/arch/arm/src/max326xx/Make.defs b/arch/arm/src/max326xx/Make.defs index 96d9826726ffc..02efb42e08037 100644 --- a/arch/arm/src/max326xx/Make.defs +++ b/arch/arm/src/max326xx/Make.defs @@ -20,43 +20,7 @@ # Common ARMv7-M Source Files -CMN_ASRCS = arm_saveusercontext.S arm_fullcontextrestore.S -CMN_ASRCS += arm_testset.S arm_fetchadd.S vfork.S - -CMN_CSRCS = arm_allocateheap.c arm_assert.c arm_blocktask.c -CMN_CSRCS += arm_createstack.c arm_doirq.c arm_exit.c arm_hardfault.c -CMN_CSRCS += arm_initialize.c arm_initialstate.c arm_interruptcontext.c -CMN_CSRCS += arm_mdelay.c arm_memfault.c arm_modifyreg8.c arm_modifyreg16.c -CMN_CSRCS += arm_modifyreg32.c arm_releasepending.c arm_releasestack.c -CMN_CSRCS += arm_reprioritizertr.c arm_schedulesigaction.c arm_sigdeliver.c -CMN_CSRCS += arm_stackframe.c arm_svcall.c arm_trigger_irq.c arm_unblocktask.c -CMN_CSRCS += arm_udelay.c arm_usestack.c arm_vfork.c arm_switchcontext.c -CMN_CSRCS += arm_puts.c arm_tcbinfo.c - -ifeq ($(CONFIG_ARMV7M_LAZYFPU),y) -CMN_ASRCS += arm_lazyexception.S -else -CMN_ASRCS += arm_exception.S -endif -CMN_CSRCS += arm_vectors.c - -ifeq ($(CONFIG_ARCH_RAMVECTORS),y) -CMN_CSRCS += arm_ramvec_initialize.c arm_ramvec_attach.c -endif - -ifeq ($(CONFIG_BUILD_PROTECTED),y) -CMN_CSRCS += arm_mpu.c arm_task_start.c arm_pthread_start.c -CMN_CSRCS += arm_signal_dispatch.c -CMN_UASRCS += arm_signal_handler.S -endif - -ifeq ($(CONFIG_STACK_COLORATION),y) -CMN_CSRCS += arm_checkstack.c -endif - -ifeq ($(CONFIG_ARCH_FPU),y) -CMN_ASRCS += arm_fpu.S -endif +include armv7-m/Make.defs # Common MAX326XX Source Files diff --git a/arch/arm/src/max326xx/common/max326_start.c b/arch/arm/src/max326xx/common/max326_start.c index cde8e2800854c..9d8d8192acb6d 100644 --- a/arch/arm/src/max326xx/common/max326_start.c +++ b/arch/arm/src/max326xx/common/max326_start.c @@ -80,97 +80,6 @@ const uintptr_t g_idle_topstack = IDLE_STACK; -/**************************************************************************** - * Private Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: max326_fpuconfig - * - * Description: - * Configure the FPU. Relative bit settings: - * - * CPACR: Enables access to CP10 and CP11 - * CONTROL.FPCA: Determines whether the FP extension is active in the - * current context: - * FPCCR.ASPEN: Enables automatic FP state preservation, then the - * processor sets this bit to 1 on successful completion of any FP - * instruction. - * FPCCR.LSPEN: Enables lazy context save of FP state. When this is - * done, the processor reserves space on the stack for the FP state, - * but does not save that state information to the stack. - * - * Software must not change the value of the ASPEN bit or LSPEN bit while - * either: - * - the CPACR permits access to CP10 and CP11, that give access to the FP - * extension, or - * - the CONTROL.FPCA bit is set to 1 - * - ****************************************************************************/ - -#ifdef CONFIG_ARCH_FPU -#ifndef CONFIG_ARMV7M_LAZYFPU -static inline void max326_fpuconfig(void) -{ - uint32_t regval; - - /* Set CONTROL.FPCA so that we always get the extended context frame - * with the volatile FP registers stacked above the basic context. - */ - - regval = getcontrol(); - regval |= CONTROL_FPCA; - setcontrol(regval); - - /* Ensure that FPCCR.LSPEN is disabled, so that we don't have to contend - * with the lazy FP context save behavior. Clear FPCCR.ASPEN since we - * are going to turn on CONTROL.FPCA for all contexts. - */ - - regval = getreg32(NVIC_FPCCR); - regval &= ~(NVIC_FPCCR_ASPEN | NVIC_FPCCR_LSPEN); - putreg32(regval, NVIC_FPCCR); - - /* Enable full access to CP10 and CP11 */ - - regval = getreg32(NVIC_CPACR); - regval |= NVIC_CPACR_CP_FULL(10) | NVIC_CPACR_CP_FULL(11); - putreg32(regval, NVIC_CPACR); -} -#else -static inline void max326_fpuconfig(void) -{ - uint32_t regval; - - /* Clear CONTROL.FPCA so that we do not get the extended context frame - * with the volatile FP registers stacked in the saved context. - */ - - regval = getcontrol(); - regval &= ~CONTROL_FPCA; - setcontrol(regval); - - /* Ensure that FPCCR.LSPEN is disabled, so that we don't have to contend - * with the lazy FP context save behavior. Clear FPCCR.ASPEN since we - * are going to keep CONTROL.FPCA off for all contexts. - */ - - regval = getreg32(NVIC_FPCCR); - regval &= ~(NVIC_FPCCR_ASPEN | NVIC_FPCCR_LSPEN); - putreg32(regval, NVIC_FPCCR); - - /* Enable full access to CP10 and CP11 */ - - regval = getreg32(NVIC_CPACR); - regval |= NVIC_CPACR_CP_FULL(10) | NVIC_CPACR_CP_FULL(11); - putreg32(regval, NVIC_CPACR); -} -#endif - -#else -# define max326_fpuconfig() -#endif - /**************************************************************************** * Public Functions ****************************************************************************/ @@ -239,7 +148,7 @@ void __start(void) /* Initialize the FPU (if configured) */ - max326_fpuconfig(); + arm_fpuconfig(); showprogress('E'); /* Perform early serial initialization */ diff --git a/arch/arm/src/moxart/Make.defs b/arch/arm/src/moxart/Make.defs index d7756df676183..b431414868fc9 100644 --- a/arch/arm/src/moxart/Make.defs +++ b/arch/arm/src/moxart/Make.defs @@ -18,22 +18,13 @@ # ############################################################################ -HEAD_ASRC = moxart_head.S +include arm/Make.defs -CMN_ASRCS = arm_saveusercontext.S arm_fullcontextrestore.S arm_vectors.S -CMN_ASRCS += arm_nommuhead.S vfork.S -CMN_CSRCS = arm_allocateheap.c arm_assert.c arm_blocktask.c -CMN_CSRCS += arm_createstack.c arm_dataabort.c arm_mdelay.c arm_udelay.c -CMN_CSRCS += arm_exit.c arm_initialstate.c arm_initialize.c -CMN_CSRCS += arm_interruptcontext.c arm_prefetchabort.c arm_releasepending.c -CMN_CSRCS += arm_releasestack.c arm_reprioritizertr.c arm_schedulesigaction.c -CMN_CSRCS += arm_sigdeliver.c arm_stackframe.c arm_syscall.c arm_unblocktask.c -CMN_CSRCS += arm_undefinedinsn.c arm_usestack.c arm_vfork.c arm_etherstub.c -CMN_CSRCS += arm_puts.c arm_tcbinfo.c arm_switchcontext.c +HEAD_ASRC = moxart_head.S -CHIP_ASRCS = moxart_lowputc.S +CHIP_ASRCS = moxart_lowputc.S -CHIP_CSRCS = moxart_16550.c moxart_irq.c moxart_timer.c moxart_systemreset.c +CHIP_CSRCS = moxart_16550.c moxart_irq.c moxart_timer.c moxart_systemreset.c # Configuration-dependent Kinetis K files diff --git a/arch/arm/src/nrf52/Make.defs b/arch/arm/src/nrf52/Make.defs index fbddfac60795d..282976f9d779d 100644 --- a/arch/arm/src/nrf52/Make.defs +++ b/arch/arm/src/nrf52/Make.defs @@ -18,57 +18,17 @@ # ############################################################################ -CMN_ASRCS = arm_saveusercontext.S arm_fullcontextrestore.S -CMN_ASRCS += arm_testset.S vfork.S - -CMN_CSRCS = arm_assert.c arm_blocktask.c -CMN_CSRCS += arm_createstack.c arm_doirq.c arm_exit.c arm_hardfault.c -CMN_CSRCS += arm_initialize.c arm_initialstate.c arm_interruptcontext.c -CMN_CSRCS += arm_memfault.c arm_modifyreg8.c arm_modifyreg16.c -CMN_CSRCS += arm_modifyreg32.c arm_releasepending.c arm_releasestack.c -CMN_CSRCS += arm_reprioritizertr.c arm_schedulesigaction.c arm_sigdeliver.c -CMN_CSRCS += arm_stackframe.c arm_svcall.c arm_trigger_irq.c arm_udelay.c -CMN_CSRCS += arm_unblocktask.c arm_usestack.c arm_vfork.c arm_systemreset.c -CMN_CSRCS += arm_switchcontext.c arm_puts.c arm_tcbinfo.c +include armv7-m/Make.defs ifeq ($(CONFIG_NRF52_SYSTIMER_SYSTICK),y) -CMN_CSRCS += arm_systick.c nrf52_systick.c +CHIP_CSRCS += nrf52_systick.c else ifeq ($(CONFIG_NRF52_SYSTIMER_RTC),y) -CMN_CSRCS += nrf52_tickless_rtc.c arm_mdelay.c +CHIP_CSRCS += nrf52_tickless_rtc.c endif endif -ifeq ($(CONFIG_ARMV7M_LAZYFPU),y) -CMN_ASRCS += arm_lazyexception.S -else -CMN_ASRCS += arm_exception.S -endif -CMN_CSRCS += arm_vectors.c - -ifeq ($(CONFIG_ARCH_RAMVECTORS),y) -CMN_CSRCS += arm_ramvec_initialize.c arm_ramvec_attach.c -endif - -ifeq ($(CONFIG_BUILD_PROTECTED),y) -CMN_CSRCS += arm_mpu.c arm_task_start.c arm_pthread_start.c -CMN_CSRCS += arm_signal_dispatch.c -CMN_UASRCS += arm_signal_handler.S -endif - -ifeq ($(CONFIG_STACK_COLORATION),y) -CMN_CSRCS += arm_checkstack.c -endif - -ifeq ($(CONFIG_ARMV7M_STACKCHECK),y) -CMN_CSRCS += arm_stackcheck.c -endif - -ifeq ($(CONFIG_ARCH_FPU),y) -CMN_ASRCS += arm_fpu.S -endif - -CHIP_CSRCS = nrf52_start.c nrf52_clockconfig.c nrf52_irq.c nrf52_utils.c +CHIP_CSRCS += nrf52_start.c nrf52_clockconfig.c nrf52_irq.c nrf52_utils.c CHIP_CSRCS += nrf52_allocateheap.c nrf52_lowputc.c nrf52_gpio.c nrf52_nvmc.c CHIP_CSRCS += nrf52_uid.c diff --git a/arch/arm/src/nrf52/nrf52_pminitialize.c b/arch/arm/src/nrf52/nrf52_pminitialize.c index 08246d0cdcc53..02388aa9ab6f1 100644 --- a/arch/arm/src/nrf52/nrf52_pminitialize.c +++ b/arch/arm/src/nrf52/nrf52_pminitialize.c @@ -23,6 +23,7 @@ ****************************************************************************/ #include +#include #include "arm_internal.h" @@ -50,4 +51,7 @@ void arm_pminitialize(void) { + /* Initialize the NuttX power management subsystem proper */ + + pm_initialize(); } diff --git a/arch/arm/src/nrf52/nrf52_start.c b/arch/arm/src/nrf52/nrf52_start.c index 8553696474d52..397be68eb5b31 100644 --- a/arch/arm/src/nrf52/nrf52_start.c +++ b/arch/arm/src/nrf52/nrf52_start.c @@ -71,93 +71,6 @@ void __start(void) noinstrument_function; #endif -/**************************************************************************** - * Name: nrf52_fpuconfig - * - * Description: - * Configure the FPU. Relative bit settings: - * - * CPACR: Enables access to CP10 and CP11 - * CONTROL.FPCA: Determines whether the FP extension is active in the - * current context: - * FPCCR.ASPEN: Enables automatic FP state preservation, then the - * processor sets this bit to 1 on successful completion of any FP - * instruction. - * FPCCR.LSPEN: Enables lazy context save of FP state. When this is - * done, the processor reserves space on the stack for the FP state, - * but does not save that state information to the stack. - * - * Software must not change the value of the ASPEN bit or LSPEN bit while - * either: - * - the CPACR permits access to CP10 and CP11, that give access to the FP - * extension, or - * - the CONTROL.FPCA bit is set to 1 - * - ****************************************************************************/ - -#ifdef CONFIG_ARCH_FPU -#ifndef CONFIG_ARMV7M_LAZYFPU -static inline void nrf52_fpuconfig(void) -{ - uint32_t regval; - - /* Set CONTROL.FPCA so that we always get the extended context frame - * with the volatile FP registers stacked above the basic context. - */ - - regval = getcontrol(); - regval |= CONTROL_FPCA; - setcontrol(regval); - - /* Ensure that FPCCR.LSPEN is disabled, so that we don't have to contend - * with the lazy FP context save behaviour. Clear FPCCR.ASPEN since we - * are going to turn on CONTROL.FPCA for all contexts. - */ - - regval = getreg32(NVIC_FPCCR); - regval &= ~(NVIC_FPCCR_ASPEN | NVIC_FPCCR_LSPEN); - putreg32(regval, NVIC_FPCCR); - - /* Enable full access to CP10 and CP11 */ - - regval = getreg32(NVIC_CPACR); - regval |= NVIC_CPACR_CP_FULL(10) | NVIC_CPACR_CP_FULL(11); - putreg32(regval, NVIC_CPACR); -} -#else -static inline void nrf52_fpuconfig(void) -{ - uint32_t regval; - - /* Clear CONTROL.FPCA so that we do not get the extended context frame - * with the volatile FP registers stacked in the saved context. - */ - - regval = getcontrol(); - regval &= ~CONTROL_FPCA; - setcontrol(regval); - - /* Ensure that FPCCR.LSPEN is disabled, so that we don't have to contend - * with the lazy FP context save behaviour. Clear FPCCR.ASPEN since we - * are going to keep CONTROL.FPCA off for all contexts. - */ - - regval = getreg32(NVIC_FPCCR); - regval &= ~(NVIC_FPCCR_ASPEN | NVIC_FPCCR_LSPEN); - putreg32(regval, NVIC_FPCCR); - - /* Enable full access to CP10 and CP11 */ - - regval = getreg32(NVIC_CPACR); - regval |= NVIC_CPACR_CP_FULL(10) | NVIC_CPACR_CP_FULL(11); - putreg32(regval, NVIC_CPACR); -} -#endif - -#else -# define nrf52_fpuconfig() -#endif - /**************************************************************************** * Public Functions ****************************************************************************/ @@ -227,7 +140,7 @@ void __start(void) /* Initialize the FPU (if configured) */ - nrf52_fpuconfig(); + arm_fpuconfig(); #ifdef CONFIG_NRF52_FLASH_PREFETCH nrf_nvmc_enable_icache(true); diff --git a/arch/arm/src/nuc1xx/Make.defs b/arch/arm/src/nuc1xx/Make.defs index caa86d683b87c..44df844801754 100644 --- a/arch/arm/src/nuc1xx/Make.defs +++ b/arch/arm/src/nuc1xx/Make.defs @@ -18,32 +18,7 @@ # ############################################################################ -CMN_ASRCS = arm_exception.S arm_saveusercontext.S arm_fullcontextrestore.S -CMN_ASRCS += vfork.S - -CMN_CSRCS = arm_allocateheap.c arm_assert.c arm_blocktask.c -CMN_CSRCS += arm_createstack.c arm_mdelay.c arm_udelay.c arm_exit.c -CMN_CSRCS += arm_initialize.c arm_initialstate.c arm_interruptcontext.c -CMN_CSRCS += arm_modifyreg8.c arm_modifyreg16.c arm_modifyreg32.c -CMN_CSRCS += arm_releasepending.c arm_releasestack.c arm_reprioritizertr.c -CMN_CSRCS += arm_schedulesigaction.c arm_sigdeliver.c arm_stackframe.c -CMN_CSRCS += arm_systemreset.c arm_unblocktask.c arm_usestack.c arm_doirq.c -CMN_CSRCS += arm_hardfault.c arm_svcall.c arm_vectors.c arm_vfork.c -CMN_CSRCS += arm_switchcontext.c arm_puts.c arm_tcbinfo.c - -ifeq ($(CONFIG_BUILD_PROTECTED),y) -CMN_CSRCS += arm_task_start.c arm_pthread_start.c -CMN_CSRCS += arm_signal_dispatch.c -CMN_UASRCS += arm_signal_handler.S -endif - -ifeq ($(CONFIG_STACK_COLORATION),y) -CMN_CSRCS += arm_checkstack.c -endif - -ifeq ($(CONFIG_DEBUG_FEATURES),y) -CMN_CSRCS += arm_dumpnvic.c -endif +include armv6-m/Make.defs CHIP_CSRCS = nuc_clockconfig.c nuc_gpio.c nuc_irq.c nuc_lowputc.c CHIP_CSRCS += nuc_serial.c nuc_start.c diff --git a/arch/arm/src/phy62xx/Make.defs b/arch/arm/src/phy62xx/Make.defs index 1d28be466b8c6..846f005da945c 100644 --- a/arch/arm/src/phy62xx/Make.defs +++ b/arch/arm/src/phy62xx/Make.defs @@ -18,40 +18,11 @@ # ############################################################################ -CMN_ASRCS = phy62xx_exception.S phy62xx_start.S arm_saveusercontext.S arm_fullcontextrestore.S -#CMN_ASRCS += arm_switchcontext.S vfork.S -CMN_ASRCS += vfork.S - -CMN_CSRCS = arm_allocateheap.c arm_assert.c arm_blocktask.c -CMN_CSRCS += arm_createstack.c arm_mdelay.c arm_udelay.c arm_exit.c -CMN_CSRCS += arm_initialize.c arm_initialstate.c arm_interruptcontext.c -CMN_CSRCS += arm_puts.c arm_modifyreg8.c arm_modifyreg16.c arm_modifyreg32.c -CMN_CSRCS += arm_releasepending.c arm_releasestack.c arm_reprioritizertr.c -CMN_CSRCS += arm_schedulesigaction.c arm_sigdeliver.c arm_stackframe.c -CMN_CSRCS += arm_systemreset.c arm_unblocktask.c arm_usestack.c arm_doirq.c -#CMN_CSRCS += arm_hardfault.c arm_svcall.c arm_vectors.c arm_vfork.c -CMN_CSRCS += phy62xx_hardfault.c arm_svcall.c arm_vectors.c arm_vfork.c -#CMN_CSRCS += arm_etherstub.c -CMN_CSRCS += arm_switchcontext.c arm_tcbinfo.c - -ifeq ($(CONFIG_ARCH_HAVE_BACKTRACE),y) -CMN_CSRCS += arm_backtrace_thumb.c -endif - -ifeq ($(CONFIG_BUILD_PROTECTED),y) -CMN_CSRCS += arm_task_start.c arm_pthread_start.c -CMN_CSRCS += arm_pthread_exit.c -CMN_CSRCS += arm_signal_dispatch.c -CMN_UASRCS += arm_signal_handler.S -endif +include armv6-m/Make.defs -ifeq ($(CONFIG_STACK_COLORATION),y) -CMN_CSRCS += arm_checkstack.c -endif +CMN_ASRCS := $(filter-out arm_exception.S,$(CMN_ASRCS)) -ifeq ($(CONFIG_DEBUG_FEATURES),y) -CMN_CSRCS += arm_dumpnvic.c -endif +CMN_ASRCS += phy62xx_exception.S phy62xx_start.S CHIP_CSRCS = start.c gpio.c irq.c timer.c uart.c pwrmgr.c idle.c my_printf.c #CHIP_CSRCS = start.c gpio.c irq.c timer.c clock.c uart.c pwrmgr.c idle.c my_printf.c flash.c @@ -89,7 +60,6 @@ INCLUDES += $(shell $(INCDIR) "$(CC)" $(ARCH_SRCDIR)$(DELIM)chip$(DELIM)ble) #INCLUDES += $(shell $(INCDIR) "$(CC)" $(ARCH_SRCDIR)$(DELIM)chip$(DELIM)ble$(DELIM)include) #INCLUDES += $(shell $(INCDIR) "$(CC)" $(ARCH_SRCDIR)$(DELIM)chip$(DELIM)osal$(DELIM)include) -CFLAGS += -ffunction-sections CFLAGS += -DCFG_CP CFLAGS += -DPHY_MCU_TYPE=MCU_BUMBEE_M0 CFLAGS += -DHOST_CONFIG=4 @@ -125,8 +95,6 @@ LDFLAGS += "$(ARCH_SRCDIR)$(DELIM)chip$(DELIM)bb_rom_sym_m0.gdbsym" context:: .buildlib -LDFLAGS += -Map="../../../phyplus_build.map" - ifndef CONFIG_PHY6222_SDK EXTRA_LIBPATHS += -L$(TOPDIR)/arch/arm/src/chip EXTRA_LIBS += -lphy62xxble diff --git a/arch/arm/src/phy62xx/phy62xx_exception.S b/arch/arm/src/phy62xx/phy62xx_exception.S index 6b8416f7a9b25..12b5f98924cd8 100644 --- a/arch/arm/src/phy62xx/phy62xx_exception.S +++ b/arch/arm/src/phy62xx/phy62xx_exception.S @@ -1,3 +1,22 @@ +/*************************************************************************** + * arch/arm/src/phy62xx/phy62xx_exception.S + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ***************************************************************************/ /**************************************************************************** * Included Files diff --git a/arch/arm/src/phy62xx/phy62xx_start.S b/arch/arm/src/phy62xx/phy62xx_start.S index de1090c88628a..cb1ca67ebb628 100644 --- a/arch/arm/src/phy62xx/phy62xx_start.S +++ b/arch/arm/src/phy62xx/phy62xx_start.S @@ -1,3 +1,22 @@ +/*************************************************************************** + * arch/arm/src/phy62xx/phy62xx_start.S + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ***************************************************************************/ /**************************************************************************** * Included Files diff --git a/arch/arm/src/phy62xx/phyplus_stub.c b/arch/arm/src/phy62xx/phyplus_stub.c index c2e70cd1f3f22..6b0f059df7e30 100644 --- a/arch/arm/src/phy62xx/phyplus_stub.c +++ b/arch/arm/src/phy62xx/phyplus_stub.c @@ -52,8 +52,6 @@ * Private Function Prototypes ****************************************************************************/ -static int phyplus_stub_open(FAR struct file *filep); -static int phyplus_stub_close(FAR struct file *filep); static ssize_t phyplus_stub_read( FAR struct file *filep, FAR char *buffer, size_t buflen); static ssize_t phyplus_stub_write( @@ -70,15 +68,15 @@ static int phyplus_stub_ioctl( static const struct file_operations g_stub_drvrops = { - phyplus_stub_open, /* open */ - phyplus_stub_close, /* close */ + NULL, /* open */ + NULL, /* close */ phyplus_stub_read, /* read */ phyplus_stub_write, /* write */ phyplus_stub_seek, /* seek */ phyplus_stub_ioctl, /* ioctl */ NULL /* poll */ #ifndef CONFIG_DISABLE_PSEUDOFS_OPERATIONS - , NULL /* unlink */ + , NULL /* unlink */ #endif }; @@ -566,33 +564,6 @@ static int phyplus_parse_params_and_action(char *buff) return 0; } -/**************************************************************************** - * Name: phyplus_stub_open - * - * Description: - * Standard character driver open method. - * - ****************************************************************************/ - -static int phyplus_stub_open(FAR struct file *filep) -{ - filep->f_pos = 0; - return OK; -} - -/**************************************************************************** - * Name: phyplus_stub_close - * - * Description: - * Standard character driver close method. - * - ****************************************************************************/ - -static int phyplus_stub_close(FAR struct file *filep) -{ - return OK; -} - /**************************************************************************** * Name: phyplus_gpio_read * @@ -633,7 +604,7 @@ static ssize_t phyplus_stub_read( static char phyplus_cmd[CMD_LEN]; static ssize_t phyplus_stub_write(FAR struct file *filep, - FAR const char *buffer, size_t buflen) + FAR const char *buffer, size_t buflen) { FAR struct inode *inode; @@ -686,8 +657,8 @@ static ssize_t phyplus_stub_write(FAR struct file *filep, * ****************************************************************************/ -static off_t phyplus_stub_seek(FAR struct file *filep, - off_t offset, int whence) +static off_t phyplus_stub_seek(FAR struct file *filep, off_t offset, + int whence) { /* Only SEEK_SET is supported, return ENOSYS for other valid options */ @@ -717,8 +688,8 @@ static off_t phyplus_stub_seek(FAR struct file *filep, * ****************************************************************************/ -static int phyplus_stub_ioctl(FAR struct file *filep, - int cmd, unsigned long arg) +static int phyplus_stub_ioctl(FAR struct file *filep, int cmd, + unsigned long arg) { FAR struct inode *inode; int ret = 0; diff --git a/arch/arm/src/phy62xx/uart.c b/arch/arm/src/phy62xx/uart.c index 7fb35383f49f1..07cdb44943648 100644 --- a/arch/arm/src/phy62xx/uart.c +++ b/arch/arm/src/phy62xx/uart.c @@ -756,7 +756,7 @@ static int pplus_uart_interrupt(int irq, void *context, FAR void *arg) break; case BUSY_IRQ: - (void)priv->reg->USR; + priv->reg->USR; break; default: @@ -1202,7 +1202,7 @@ static int h4uart_interrupt(int irq, void *context, FAR void *arg) break; case RLS_IRQ: case BUSY_IRQ: - (void)preg->USR; + preg->USR; break; default: break; diff --git a/arch/arm/src/rp2040/Make.defs b/arch/arm/src/rp2040/Make.defs index 82c4efc1ef26a..95fe8d1d24f94 100644 --- a/arch/arm/src/rp2040/Make.defs +++ b/arch/arm/src/rp2040/Make.defs @@ -18,36 +18,7 @@ # ############################################################################ -CMN_ASRCS = arm_exception.S arm_saveusercontext.S arm_fullcontextrestore.S -CMN_ASRCS += vfork.S - -CMN_CSRCS = arm_allocateheap.c arm_assert.c arm_blocktask.c -CMN_CSRCS += arm_createstack.c arm_mdelay.c arm_udelay.c arm_exit.c -CMN_CSRCS += arm_initialize.c arm_initialstate.c arm_interruptcontext.c -CMN_CSRCS += arm_modifyreg8.c arm_modifyreg16.c arm_modifyreg32.c -CMN_CSRCS += arm_releasepending.c arm_releasestack.c arm_reprioritizertr.c -CMN_CSRCS += arm_schedulesigaction.c arm_sigdeliver.c arm_stackframe.c -CMN_CSRCS += arm_systemreset.c arm_unblocktask.c arm_usestack.c arm_doirq.c -CMN_CSRCS += arm_hardfault.c arm_svcall.c arm_vectors.c arm_vfork.c -CMN_CSRCS += arm_switchcontext.c arm_puts.c arm_tcbinfo.c - -ifeq ($(CONFIG_ARCH_RAMVECTORS),y) -CMN_CSRCS += arm_ramvec_initialize.c arm_ramvec_attach.c -endif - -ifeq ($(CONFIG_BUILD_PROTECTED),y) -CMN_CSRCS += arm_task_start.c arm_pthread_start.c -CMN_CSRCS += arm_signal_dispatch.c -CMN_UASRCS += arm_signal_handler.S -endif - -ifeq ($(CONFIG_STACK_COLORATION),y) -CMN_CSRCS += arm_checkstack.c -endif - -ifeq ($(CONFIG_DEBUG_FEATURES),y) -CMN_CSRCS += arm_dumpnvic.c -endif +include armv6-m/Make.defs CHIP_CSRCS += rp2040_idle.c CHIP_CSRCS += rp2040_irq.c @@ -67,6 +38,7 @@ CHIP_CSRCS += rp2040_cpustart.c CHIP_CSRCS += rp2040_cpupause.c CHIP_CSRCS += rp2040_cpuidlestack.c CHIP_CSRCS += rp2040_testset.c +CMN_ASRCS := $(filter-out arm_testset.S,$(CMN_ASRCS)) endif ifeq ($(CONFIG_RP2040_DMAC),y) diff --git a/arch/arm/src/rtl8720c/Make.defs b/arch/arm/src/rtl8720c/Make.defs index 78e019925ee1c..b816787078b0d 100644 --- a/arch/arm/src/rtl8720c/Make.defs +++ b/arch/arm/src/rtl8720c/Make.defs @@ -18,36 +18,12 @@ # ############################################################################ -# arch/arm/src/common -# -CMN_CSRCS += arm_checkstack.c arm_createstack.c arm_exit.c arm_hostfs.c -CMN_CSRCS += arm_initialize.c arm_interruptcontext.c arm_modifyreg8.c -CMN_CSRCS += arm_modifyreg16.c arm_modifyreg32.c arm_pthread_start.c -CMN_CSRCS += arm_puts.c arm_releasestack.c arm_semi_syslog.c -CMN_CSRCS += arm_stackframe.c arm_task_start.c arm_usestack.c arm_vfork.c - -CMN_ASRCS += arm_exception.S - -# arch/arm/src/armv8-m -# -CMN_ASRCS += arm_fetchadd.S arm_fpu.S arm_setjmp.S -CMN_ASRCS += arm_fullcontextrestore.S arm_saveusercontext.S -CMN_ASRCS += arm_testset.S vfork.S - -CMN_UASRCS += arm_signal_handler.S - -CMN_CSRCS += arm_assert.c arm_blocktask.c arm_cache.c -CMN_CSRCS += arm_doirq.c arm_hardfault.c arm_initialstate.c -CMN_CSRCS += arm_itm_syslog.c arm_memfault.c arm_mpu.c arm_ramvec_attach.c -CMN_CSRCS += arm_ramvec_initialize.c arm_releasepending.c arm_reprioritizertr.c -CMN_CSRCS += arm_schedulesigaction.c arm_sigdeliver.c arm_signal_dispatch.c -CMN_CSRCS += arm_stackcheck.c arm_svcall.c arm_systick.c arm_unblocktask.c -CMN_CSRCS += arm_switchcontext.c arm_tcbinfo.c +include armv8-m/Make.defs # arch/arm/src/rtl8720c # -CHIP_CSRCS += ameba_nvic.c ameba_heap.c ameba_idle.c ameba_uart.c ameba_start.c ameba_vectors.c -CHIP_CSRCS += ameba_efuse.c ameba_flash.c ameba_wdt.c ameba_hci.c +CHIP_CSRCS += ameba_nvic.c ameba_heap.c ameba_idle.c ameba_uart.c ameba_start.c +CHIP_CSRCS += ameba_vectors.c ameba_efuse.c ameba_flash.c ameba_wdt.c ameba_hci.c CHIP_ASRCS += ameba_lto.S diff --git a/arch/arm/src/rtl8720c/ameba_hci.c b/arch/arm/src/rtl8720c/ameba_hci.c index f1c383f41e0f8..9a3fb192622ab 100644 --- a/arch/arm/src/rtl8720c/ameba_hci.c +++ b/arch/arm/src/rtl8720c/ameba_hci.c @@ -26,7 +26,7 @@ #include #include #include -#include <../../../../net/netdev/netdev.h> +#include #include "amebaz_hci_board.h" /**************************************************************************** diff --git a/arch/arm/src/rtl8720c/ameba_nvic.c b/arch/arm/src/rtl8720c/ameba_nvic.c index 060d3d5f0e5e8..5dd1287f4f4cb 100644 --- a/arch/arm/src/rtl8720c/ameba_nvic.c +++ b/arch/arm/src/rtl8720c/ameba_nvic.c @@ -82,21 +82,6 @@ static int (* __vectors[NR_IRQS - NVIC_IRQ_FIRST])(void); * Private Functions ****************************************************************************/ -/**************************************************************************** - * Name: up_getsp - ****************************************************************************/ - -static inline uint32_t up_getsp(void) -{ - uint32_t sp; - __asm__ - ( - "\tmov %0, sp\n\t" - : "=r"(sp) - ); - return sp; -} - /**************************************************************************** * Name: nvic_irqinfo * diff --git a/arch/arm/src/rtl8720c/ameba_uart.c b/arch/arm/src/rtl8720c/ameba_uart.c index 377b60f3a10ce..77ccc5127c9c2 100644 --- a/arch/arm/src/rtl8720c/ameba_uart.c +++ b/arch/arm/src/rtl8720c/ameba_uart.c @@ -1051,19 +1051,19 @@ void arm_earlyserialinit(void) void arm_serialinit(void) { #ifdef CONSOLE_DEV - (void)uart_register("/dev/console", &CONSOLE_DEV); + uart_register("/dev/console", &CONSOLE_DEV); #endif #ifdef TTYS0_DEV - (void)uart_register("/dev/ttyS0", &TTYS0_DEV); + uart_register("/dev/ttyS0", &TTYS0_DEV); #endif #ifdef TTYS1_DEV - (void)uart_register("/dev/ttyS1", &TTYS1_DEV); + uart_register("/dev/ttyS1", &TTYS1_DEV); #endif #ifdef TTYS2_DEV - (void)uart_register("/dev/ttyS2", &TTYS2_DEV); + uart_register("/dev/ttyS2", &TTYS2_DEV); #endif #ifdef TTYS3_DEV - (void)uart_register("/dev/ttyS3", &TTYS3_DEV); + uart_register("/dev/ttyS3", &TTYS3_DEV); #endif } diff --git a/arch/arm/src/rtl8720c/ameba_wdt.c b/arch/arm/src/rtl8720c/ameba_wdt.c index 969a7070b3363..7fd08a05506b4 100644 --- a/arch/arm/src/rtl8720c/ameba_wdt.c +++ b/arch/arm/src/rtl8720c/ameba_wdt.c @@ -286,8 +286,8 @@ void ameba_wdt_initialize(void) /* Initialize the driver state structure. */ priv->ops = &g_wdgops; - (void)watchdog_register(CONFIG_WATCHDOG_DEVPATH, - (FAR struct watchdog_lowerhalf_s *)priv); + watchdog_register(CONFIG_WATCHDOG_DEVPATH, + (FAR struct watchdog_lowerhalf_s *)priv); } #endif /* CONFIG_WATCHDOG */ diff --git a/arch/arm/src/rtl8720c/amebaz_coex.c b/arch/arm/src/rtl8720c/amebaz_coex.c index 5ff7613e6d732..a61c3391d3387 100644 --- a/arch/arm/src/rtl8720c/amebaz_coex.c +++ b/arch/arm/src/rtl8720c/amebaz_coex.c @@ -86,12 +86,10 @@ static void rtk_notify_info_to_wifi(uint8_t length, uint8_t *report_info) } void bt_coex_handle_cmd_complete_evt(uint16_t opcode, uint16_t cause, - uint8_t total_len, uint8_t *p) + uint8_t total_len, uint8_t *p) { - (void)cause; if (opcode == HCI_VENDOR_MAILBOX_CMD) { - uint8_t status; status = *p++; /* jump the double subcmd */ total_len--; @@ -101,7 +99,6 @@ void bt_coex_handle_cmd_complete_evt(uint16_t opcode, uint16_t cause, return ; } - (void)status; rltk_coex_mailbox_to_wifi(p, total_len); /* rtk_parse_vendor_mailbox_cmd_evt(p, total_len, status); */ @@ -149,10 +146,10 @@ static void bt_coex_dump_buf(net_buf_simple *tmp_buf) static int bt_coex_unpack_xiaomi_vendor_cmd(net_buf_simple *tmp_buf) { - if (tmp_buf-> data[0] == 0x25 && tmp_buf-> data[1] == 0x00) + if (tmp_buf->data[0] == 0x25 && tmp_buf->data[1] == 0x00) { - tmp_buf -> data += 2; - tmp_buf -> len -= 2; + tmp_buf->data += 2; + tmp_buf->len -= 2; return 1; } diff --git a/arch/arm/src/s32k1xx/Make.defs b/arch/arm/src/s32k1xx/Make.defs index 71fbd59a2bc44..83d6d92a19823 100644 --- a/arch/arm/src/s32k1xx/Make.defs +++ b/arch/arm/src/s32k1xx/Make.defs @@ -18,22 +18,6 @@ # ############################################################################ -# Common ARM source files - -CMN_CSRCS = arm_allocateheap.c arm_exit.c arm_initialize.c arm_interruptcontext.c -CMN_CSRCS += arm_lowputs.c arm_mdelay.c arm_modifyreg8.c arm_modifyreg16.c -CMN_CSRCS += arm_modifyreg32.c arm_puts.c arm_releasestack.c arm_stackframe.c -CMN_CSRCS += arm_task_start.c arm_udelay.c arm_usestack.c arm_vfork.c -CMN_CSRCS += arm_tcbinfo.c - -ifeq ($(CONFIG_STACK_COLORATION),y) -CMN_CSRCS += arm_checkstack.c -endif - -ifeq ($(CONFIG_BUILD_PROTECTED),y) -CMN_CSRCS += arm_pthread_start.c -endif - # Source files common to all S32K1xx chip families. CHIP_CSRCS = s32k1xx_start.c s32k1xx_lowputc.c s32k1xx_clockconfig.c diff --git a/arch/arm/src/s32k1xx/s32k11x/Make.defs b/arch/arm/src/s32k1xx/s32k11x/Make.defs index 6c86a673e784d..15d41d08d37a8 100644 --- a/arch/arm/src/s32k1xx/s32k11x/Make.defs +++ b/arch/arm/src/s32k1xx/s32k11x/Make.defs @@ -20,23 +20,7 @@ # Source files specific to the Cortex-M0+ -CMN_ASRCS += arm_exception.S arm_saveusercontext.S arm_fullcontextrestore.S -CMN_ASRCS += vfork.S - -CMN_CSRCS += arm_assert.c arm_blocktask.c arm_createstack.c -CMN_CSRCS += arm_initialstate.c arm_releasepending.c arm_reprioritizertr.c -CMN_CSRCS += arm_schedulesigaction.c arm_sigdeliver.c arm_systemreset.c -CMN_CSRCS += arm_unblocktask.c arm_doirq.c arm_hardfault.c arm_svcall.c -CMN_CSRCS += arm_vectors.c arm_switchcontext.c - -ifeq ($(CONFIG_BUILD_PROTECTED),y) -CMN_CSRCS += arm_signal_dispatch.c -CMN_UASRCS += arm_signal_handler.S -endif - -ifeq ($(CONFIG_DEBUG_FEATURES),y) -CMN_CSRCS += arm_dumpnvic.c -endif +include armv6-m/Make.defs # Source file specific to the S32k11x family diff --git a/arch/arm/src/s32k1xx/s32k14x/Make.defs b/arch/arm/src/s32k1xx/s32k14x/Make.defs index e54d78855a69f..54cc9975430d4 100644 --- a/arch/arm/src/s32k1xx/s32k14x/Make.defs +++ b/arch/arm/src/s32k1xx/s32k14x/Make.defs @@ -20,34 +20,7 @@ # Source files specific to the Cortex-M4F -CMN_ASRCS += arm_saveusercontext.S arm_fullcontextrestore.S -CMN_ASRCS += arm_testset.S arm_fetchadd.S vfork.S - -CMN_CSRCS += arm_assert.c arm_blocktask.c arm_createstack.c -CMN_CSRCS += arm_doirq.c arm_hardfault.c arm_initialstate.c arm_memfault.c -CMN_CSRCS += arm_releasepending.c arm_reprioritizertr.c arm_schedulesigaction.c -CMN_CSRCS += arm_sigdeliver.c arm_svcall.c arm_trigger_irq.c arm_unblocktask.c -CMN_CSRCS += arm_systemreset.c arm_switchcontext.c - -ifeq ($(CONFIG_ARMV7M_LAZYFPU),y) -CMN_ASRCS += arm_lazyexception.S -else -CMN_ASRCS += arm_exception.S -endif -CMN_CSRCS += arm_vectors.c - -ifeq ($(CONFIG_ARCH_RAMVECTORS),y) -CMN_CSRCS += arm_ramvec_initialize.c arm_ramvec_attach.c -endif - -ifeq ($(CONFIG_BUILD_PROTECTED),y) -CMN_CSRCS += arm_mpu.c arm_signal_dispatch.c -CMN_UASRCS += arm_signal_handler.S -endif - -ifeq ($(CONFIG_ARCH_FPU),y) -CMN_ASRCS += arm_fpu.S -endif +include armv7-m/Make.defs # Source file specific to the S32k11x family diff --git a/arch/arm/src/s32k1xx/s32k1xx_pminitialize.c b/arch/arm/src/s32k1xx/s32k1xx_pminitialize.c index 173bb524a606c..99278d24e5376 100644 --- a/arch/arm/src/s32k1xx/s32k1xx_pminitialize.c +++ b/arch/arm/src/s32k1xx/s32k1xx_pminitialize.c @@ -23,6 +23,7 @@ ****************************************************************************/ #include +#include #include "arm_internal.h" @@ -52,6 +53,9 @@ void arm_pminitialize(void) { + /* Initialize the NuttX power management subsystem proper */ + + pm_initialize(); } #endif /* CONFIG_PM */ diff --git a/arch/arm/src/s32k1xx/s32k1xx_start.c b/arch/arm/src/s32k1xx/s32k1xx_start.c index 34e241f66888f..85cd09d323f6f 100644 --- a/arch/arm/src/s32k1xx/s32k1xx_start.c +++ b/arch/arm/src/s32k1xx/s32k1xx_start.c @@ -124,93 +124,6 @@ const uintptr_t g_idle_topstack = HEAP_BASE; * Private Functions ****************************************************************************/ -/**************************************************************************** - * Name: s32k1xx_fpu_config - * - * Description: - * Configure the FPU. Relative bit settings: - * - * CPACR: Enables access to CP10 and CP11 - * CONTROL.FPCA: Determines whether the FP extension is active in the - * current context: - * FPCCR.ASPEN: Enables automatic FP state preservation, then the - * processor sets this bit to 1 on successful completion of any FP - * instruction. - * FPCCR.LSPEN: Enables lazy context save of FP state. When this is - * done, the processor reserves space on the stack for the FP state, - * but does not save that state information to the stack. - * - * Software must not change the value of the ASPEN bit or LSPEN bit while - * either: - * - the CPACR permits access to CP10 and CP11, that give access to the FP - * extension, or - * - the CONTROL.FPCA bit is set to 1 - * - ****************************************************************************/ - -#ifdef CONFIG_ARCH_FPU -#ifndef CONFIG_ARMV7M_LAZYFPU -static inline void s32k1xx_fpu_config(void) -{ - uint32_t regval; - - /* Set CONTROL.FPCA so that we always get the extended context frame - * with the volatile FP registers stacked above the basic context. - */ - - regval = getcontrol(); - regval |= CONTROL_FPCA; - setcontrol(regval); - - /* Ensure that FPCCR.LSPEN is disabled, so that we don't have to contend - * with the lazy FP context save behavior. Clear FPCCR.ASPEN since we - * are going to turn on CONTROL.FPCA for all contexts. - */ - - regval = getreg32(NVIC_FPCCR); - regval &= ~(NVIC_FPCCR_ASPEN | NVIC_FPCCR_LSPEN); - putreg32(regval, NVIC_FPCCR); - - /* Enable full access to CP10 and CP11 */ - - regval = getreg32(NVIC_CPACR); - regval |= NVIC_CPACR_CP_FULL(10) | NVIC_CPACR_CP_FULL(11); - putreg32(regval, NVIC_CPACR); -} -#else -static inline void s32k1xx_fpu_config(void) -{ - uint32_t regval; - - /* Clear CONTROL.FPCA so that we do not get the extended context frame - * with the volatile FP registers stacked in the saved context. - */ - - regval = getcontrol(); - regval &= ~CONTROL_FPCA; - setcontrol(regval); - - /* Ensure that FPCCR.LSPEN is disabled, so that we don't have to contend - * with the lazy FP context save behavior. Clear FPCCR.ASPEN since we - * are going to keep CONTROL.FPCA off for all contexts. - */ - - regval = getreg32(NVIC_FPCCR); - regval &= ~(NVIC_FPCCR_ASPEN | NVIC_FPCCR_LSPEN); - putreg32(regval, NVIC_FPCCR); - - /* Enable full access to CP10 and CP11 */ - - regval = getreg32(NVIC_CPACR); - regval |= NVIC_CPACR_CP_FULL(10) | NVIC_CPACR_CP_FULL(11); - putreg32(regval, NVIC_CPACR); -} -#endif - -#else -# define s32k1xx_fpu_config() -#endif - /**************************************************************************** * Name: s32k1xx_cache_config * @@ -339,7 +252,7 @@ void __start(void) /* Initialize the FPU (if configured) */ - s32k1xx_fpu_config(); + arm_fpuconfig(); showprogress('C'); #if defined(CONFIG_ARCH_USE_MPU) && defined(CONFIG_S32K1XX_ENET) diff --git a/arch/arm/src/sam34/Kconfig b/arch/arm/src/sam34/Kconfig index 62144d3e9976e..87d52336083ba 100644 --- a/arch/arm/src/sam34/Kconfig +++ b/arch/arm/src/sam34/Kconfig @@ -41,7 +41,7 @@ config ARCH_CHIP_ATSAM3U1C select ARCH_CHIP_SAM3U config ARCH_CHIP_ATSAM3X8E - bool "ATSAMSAM3X8E" + bool "ATSAM3X8E" select ARCH_CORTEXM3 select ARCH_CHIP_SAM3X select SAM34_HAVE_EXTNOR diff --git a/arch/arm/src/sam34/Make.defs b/arch/arm/src/sam34/Make.defs index e7a07d9bb405f..9bda3fdcbfe88 100644 --- a/arch/arm/src/sam34/Make.defs +++ b/arch/arm/src/sam34/Make.defs @@ -22,55 +22,7 @@ # Common ARM and Cortex-M3 files -CMN_ASRCS = arm_saveusercontext.S arm_fullcontextrestore.S -CMN_ASRCS += arm_testset.S arm_fetchadd.S vfork.S - -CMN_CSRCS = arm_assert.c arm_blocktask.c arm_createstack.c -CMN_CSRCS += arm_doirq.c arm_exit.c arm_hardfault.c arm_initialize.c -CMN_CSRCS += arm_initialstate.c arm_interruptcontext.c arm_mdelay.c -CMN_CSRCS += arm_memfault.c arm_modifyreg8.c arm_modifyreg16.c arm_modifyreg32.c -CMN_CSRCS += arm_releasepending.c arm_releasestack.c arm_reprioritizertr.c -CMN_CSRCS += arm_schedulesigaction.c arm_sigdeliver.c arm_stackframe.c -CMN_CSRCS += arm_svcall.c arm_trigger_irq.c arm_unblocktask.c arm_udelay.c -CMN_CSRCS += arm_usestack.c arm_vfork.c arm_switchcontext.c arm_puts.c -CMN_CSRCS += arm_tcbinfo.c - -ifneq ($(CONFIG_SMP),y) -ifneq ($(CONFIG_ARCH_IDLE_CUSTOM),y) -CMN_CSRCS += arm_idle.c -endif -endif - -# Configuration-dependent common files - -ifeq ($(CONFIG_ARMV7M_LAZYFPU),y) -CMN_ASRCS += arm_lazyexception.S -else -CMN_ASRCS += arm_exception.S -endif -CMN_CSRCS += arm_vectors.c - -ifeq ($(CONFIG_ARCH_RAMVECTORS),y) -CMN_CSRCS += arm_ramvec_initialize.c arm_ramvec_attach.c -endif - -ifeq ($(CONFIG_ARM_MPU),y) -CMN_CSRCS += arm_mpu.c -endif - -ifeq ($(CONFIG_BUILD_PROTECTED),y) -CMN_CSRCS += arm_task_start.c arm_pthread_start.c -CMN_CSRCS += arm_signal_dispatch.c -CMN_UASRCS += arm_signal_handler.S -endif - -ifeq ($(CONFIG_ARCH_FPU),y) -CMN_ASRCS += arm_fpu.S -endif - -ifeq ($(CONFIG_STACK_COLORATION),y) -CMN_CSRCS += arm_checkstack.c -endif +include armv7-m/Make.defs # Required SAM3/4 files diff --git a/arch/arm/src/sam34/hardware/sam_hsmci.h b/arch/arm/src/sam34/hardware/sam_hsmci.h index 006446ace9c25..b58b09dc5545c 100644 --- a/arch/arm/src/sam34/hardware/sam_hsmci.h +++ b/arch/arm/src/sam34/hardware/sam_hsmci.h @@ -57,7 +57,7 @@ #define SAM_HSMCI_IDR_OFFSET 0x0048 /* Interrupt Disable Register */ #define SAM_HSMCI_IMR_OFFSET 0x004c /* Interrupt Mask Register */ -#if defined(CONFIG_ARCH_CHIP_SAM3U) +#if defined(CONFIG_ARCH_CHIP_SAM3U) || defined(CONFIG_ARCH_CHIP_SAM3X) # define SAM_HSMCI_DMA_OFFSET 0x0050 /* DMA Configuration Register */ #endif @@ -90,7 +90,7 @@ #define SAM_HSMCI_IDR (SAM_HSMCI_BASE+SAM_HSMCI_IDR_OFFSET) #define SAM_HSMCI_IMR (SAM_HSMCI_BASE+SAM_HSMCI_IMR_OFFSET) -#if defined(CONFIG_ARCH_CHIP_SAM3U) +#if defined(CONFIG_ARCH_CHIP_SAM3U) || defined(CONFIG_ARCH_CHIP_SAM3X) # define SAM_HSMCI_DMA (SAM_HSMCI_BASE+SAM_HSMCI_DMA_OFFSET) #endif @@ -140,7 +140,7 @@ # define HSMCI_MR_PDCMODE (1 << 15) /* Bit 15: PDC-oriented Mode */ #endif -#if defined(CONFIG_ARCH_CHIP_SAM3U) +#if defined(CONFIG_ARCH_CHIP_SAM3U) || defined(CONFIG_ARCH_CHIP_SAM3X) # define HSMCI_MR_BLKLEN_SHIFT (16) /* Bits 16-31: Data Block Length */ # define HSMCI_MR_BLKLEN_MASK (0xffff << HSMCI_MR_BLKLEN_SHIFT) #endif @@ -297,7 +297,7 @@ #define HSMCI_INT_DTOE (1 << 22) /* Bit 22: Data Time-out Error */ #define HSMCI_INT_CSTOE (1 << 23) /* Bit 23: Completion Signal Time-out Error */ -#if defined(CONFIG_ARCH_CHIP_SAM3U) +#if defined(CONFIG_ARCH_CHIP_SAM3U) || defined(CONFIG_ARCH_CHIP_SAM3X) # define HSMCI_INT_BLKOVRE (1 << 24) /* Bit 24: DMA Block Overrun Error */ # define HSMCI_INT_DMADONE (1 << 25) /* Bit 25: DMA Transfer done */ #endif @@ -311,7 +311,7 @@ /* HSMCI DMA Configuration Register */ -#if defined(CONFIG_ARCH_CHIP_SAM3U) +#if defined(CONFIG_ARCH_CHIP_SAM3U) || defined(CONFIG_ARCH_CHIP_SAM3X) # define HSMCI_DMA_OFFSET_SHIFT (0) /* Bits 0-1: DMA Write Buffer Offset */ # define HSMCI_DMA_OFFSET_MASK (3 << HSMCI_DMA_OFFSET_SHIFT) # define HSMCI_DMA_CHKSIZE (1 << 4) /* Bit 4: DMA Channel Read and Write Chunk Size */ diff --git a/arch/arm/src/sam34/sam_gpioirq.c b/arch/arm/src/sam34/sam_gpioirq.c index d32f14553172d..5f44da216b95f 100644 --- a/arch/arm/src/sam34/sam_gpioirq.c +++ b/arch/arm/src/sam34/sam_gpioirq.c @@ -433,7 +433,7 @@ void sam_gpioirqenable(int irq) { /* Clear (all) pending interrupts and enable this pin interrupt */ - /* (void)getreg32(base + SAM_PIO_ISR_OFFSET); */ + /* getreg32(base + SAM_PIO_ISR_OFFSET); */ putreg32((1 << pin), base + SAM_PIO_IER_OFFSET); } diff --git a/arch/arm/src/sam34/sam_hsmci.c b/arch/arm/src/sam34/sam_hsmci.c index 8cc0f95ea1f00..971e8e0d4abb4 100644 --- a/arch/arm/src/sam34/sam_hsmci.c +++ b/arch/arm/src/sam34/sam_hsmci.c @@ -41,6 +41,7 @@ #include #include +#include #include #include "chip.h" @@ -186,7 +187,7 @@ */ #ifdef CONFIG_SAM34_DMAC0 -# if defined(CONFIG_ARCH_CHIP_SAM3U) +# if defined(CONFIG_ARCH_CHIP_SAM3U) || defined(CONFIG_ARCH_CHIP_SAM3X) # define HSMCI_DATA_ERRORS \ (HSMCI_INT_UNRE | HSMCI_INT_OVRE | HSMCI_INT_BLKOVRE | HSMCI_INT_CSTOE | \ HSMCI_INT_DTOE | HSMCI_INT_DCRCE) @@ -205,7 +206,7 @@ (HSMCI_INT_CSTOE | HSMCI_INT_DTOE) #ifdef CONFIG_SAM34_DMAC0 -# if defined(CONFIG_ARCH_CHIP_SAM3U) +# if defined(CONFIG_ARCH_CHIP_SAM3U) || defined(CONFIG_ARCH_CHIP_SAM3X) # define HSMCI_DATA_DMARECV_ERRORS \ (HSMCI_INT_OVRE | HSMCI_INT_BLKOVRE | HSMCI_INT_CSTOE | HSMCI_INT_DTOE | \ HSMCI_INT_DCRCE) @@ -354,7 +355,7 @@ struct sam_hsmciregs_s uint32_t rsp3; /* Response Register 3 */ uint32_t sr; /* Status Register */ uint32_t imr; /* Interrupt Mask Register */ -#if defined(CONFIG_ARCH_CHIP_SAM3U) +#if defined(CONFIG_ARCH_CHIP_SAM3U) || defined(CONFIG_ARCH_CHIP_SAM3X) uint32_t dma; /* DMA Configuration Register */ #endif uint32_t cfg; /* Configuration Register */ @@ -783,7 +784,7 @@ static void sam_hsmcisample(struct sam_hsmciregs_s *regs) regs->rsp3 = getreg32(SAM_HSMCI_RSPR3); regs->sr = getreg32(SAM_HSMCI_SR); regs->imr = getreg32(SAM_HSMCI_IMR); -#if defined(CONFIG_ARCH_CHIP_SAM3U) +#if defined(CONFIG_ARCH_CHIP_SAM3U) || defined(CONFIG_ARCH_CHIP_SAM3X) regs->dma = getreg32(SAM_HSMCI_DMA); #endif regs->cfg = getreg32(SAM_HSMCI_CFG); @@ -843,7 +844,7 @@ static void sam_hsmcidump(struct sam_hsmciregs_s *regs, const char *msg) SAM_HSMCI_SR, regs->sr); mcinfo(" IMR[%08x]: %08x\n", SAM_HSMCI_IMR, regs->imr); -#if defined(CONFIG_ARCH_CHIP_SAM3U) +#if defined(CONFIG_ARCH_CHIP_SAM3U) || defined(CONFIG_ARCH_CHIP_SAM3X) mcinfo(" DMA[%08x]: %08x\n", SAM_HSMCI_DMA, regs->dma); #endif @@ -1181,7 +1182,7 @@ static void sam_endtransfer(struct sam_dev_s *priv, sam_dmastop(priv->dma); priv->dmabusy = false; -#if defined(CONFIG_ARCH_CHIP_SAM3U) +#if defined(CONFIG_ARCH_CHIP_SAM3U) || defined(CONFIG_ARCH_CHIP_SAM3X) /* Disable the DMA handshaking */ putreg32(0, SAM_HSMCI_DMA); @@ -1224,7 +1225,7 @@ static void sam_notransfer(struct sam_dev_s *priv) regval = getreg32(SAM_HSMCI_MR); -#if defined(CONFIG_ARCH_CHIP_SAM3U) +#if defined(CONFIG_ARCH_CHIP_SAM3U) || defined(CONFIG_ARCH_CHIP_SAM3X) regval &= ~(HSMCI_MR_RDPROOF | HSMCI_MR_WRPROOF | HSMCI_MR_BLKLEN_MASK); #else regval &= ~(HSMCI_MR_RDPROOF | HSMCI_MR_WRPROOF); @@ -1436,7 +1437,7 @@ static void sam_reset(FAR struct sdio_dev_s *dev) /* Disable the DMA interface */ -#if defined(CONFIG_ARCH_CHIP_SAM3U) +#if defined(CONFIG_ARCH_CHIP_SAM3U) || defined(CONFIG_ARCH_CHIP_SAM3X) putreg32(0, SAM_HSMCI_DMA); #endif @@ -1493,6 +1494,7 @@ static sdio_capset_t sam_capabilities(FAR struct sdio_dev_s *dev) #ifdef CONFIG_SAM34_HSMCI_DMA caps |= SDIO_CAPS_DMASUPPORTED; + caps |= SDIO_CAPS_DMABEFOREWRITE; #endif return caps; @@ -1800,6 +1802,19 @@ static int sam_sendcmd(FAR struct sdio_dev_s *dev, cmd, arg, regval); putreg32(regval, SAM_HSMCI_CMDR); sam_cmdsample1(SAMPLENDX_AFTER_CMDR); + + /* Card initialisation is unsuccessful without the following delay. + * + * It appears the timing from writing SAM_HSMCI_CMDR to calling + * sam_waitresponse is too short. + * + * For now the simplest solution is to add this delay. + * Further investigation is required to find the root cause and + * correct solution. + */ + + nxsig_usleep(10); + return OK; } @@ -1834,7 +1849,7 @@ static void sam_blocksetup(FAR struct sdio_dev_s *dev, unsigned int blocklen, regval = getreg32(SAM_HSMCI_MR); -#if defined(CONFIG_ARCH_CHIP_SAM3U) +#if defined(CONFIG_ARCH_CHIP_SAM3U) || defined(CONFIG_ARCH_CHIP_SAM3X) regval &= ~(HSMCI_MR_RDPROOF | HSMCI_MR_WRPROOF | HSMCI_MR_BLKLEN_MASK); regval |= HSMCU_PROOF_BITS; regval |= (blocklen << HSMCI_MR_BLKLEN_SHIFT); @@ -1901,7 +1916,7 @@ static int sam_cancel(FAR struct sdio_dev_s *dev) priv->dmabusy = false; #endif -#if defined(CONFIG_ARCH_CHIP_SAM3U) +#if defined(CONFIG_ARCH_CHIP_SAM3U) || defined(CONFIG_ARCH_CHIP_SAM3X) /* Disable the DMA handshaking */ putreg32(0, SAM_HSMCI_DMA); @@ -2495,7 +2510,7 @@ static int sam_dmarecvsetup(FAR struct sdio_dev_s *dev, FAR uint8_t *buffer, sam_cmcc_invalidate((uintptr_t)buffer, (uintptr_t)buffer + buflen); -#if defined(CONFIG_ARCH_CHIP_SAM3U) +#if defined(CONFIG_ARCH_CHIP_SAM3U) || defined(CONFIG_ARCH_CHIP_SAM3X) /* Enable DMA handshaking */ putreg32(HSMCI_DMA_DMAEN, SAM_HSMCI_DMA); @@ -2565,7 +2580,7 @@ static int sam_dmasendsetup(FAR struct sdio_dev_s *dev, sam_dmatxsetup(priv->dma, SAM_HSMCI_TDR, (uint32_t)buffer, buflen); -#if defined(CONFIG_ARCH_CHIP_SAM3U) +#if defined(CONFIG_ARCH_CHIP_SAM3U) || defined(CONFIG_ARCH_CHIP_SAM3X) /* Enable DMA handshaking */ putreg32(HSMCI_DMA_DMAEN, SAM_HSMCI_DMA); @@ -2667,7 +2682,7 @@ static void sam_callback(void *arg) priv->callback, priv->cbarg); work_queue(LPWORK, &priv->cbwork, - (worker_t)priv->callback, priv->cbarg, 0); + priv->callback, priv->cbarg, 0); } else { @@ -2730,6 +2745,18 @@ FAR struct sdio_dev_s *sdio_initialize(int slotno) * any card detection GPIOs must be set up in board-specific logic. */ +#if defined(CONFIG_ARCH_CHIP_SAM3X) + sam_configgpio(GPIO_HSMCIA_DAT0); /* Data 0 of Slot A - PA21 */ + sam_configgpio(GPIO_HSMCIA_DAT1); /* Data 1 of Slot A - PA22 */ + sam_configgpio(GPIO_HSMCIA_DAT2); /* Data 2 of Slot A - PA23 */ + sam_configgpio(GPIO_HSMCIA_DAT3); /* Data 3 of Slot A - PA24 */ + sam_configgpio(GPIO_HSMCI_CK); /* SD clock - PA19 */ + sam_configgpio(GPIO_HSMCIA_CD); /* Command/Response - PA20 */ + +#ifdef CONFIG_DEBUG_FS + sam_dumpgpio(GPIO_PORT_PIOA, "Pins: 19-24"); +#endif +#else sam_configgpio(GPIO_HSMCI_DAT0); /* Data 0 of Slot A */ sam_configgpio(GPIO_HSMCI_DAT1); /* Data 1 of Slot A */ sam_configgpio(GPIO_HSMCI_DAT2); /* Data 2 of Slot A */ @@ -2740,6 +2767,7 @@ FAR struct sdio_dev_s *sdio_initialize(int slotno) #ifdef CONFIG_DEBUG_FS sam_dumpgpio(GPIO_PORT_PIOA, "Pins: 3-8"); sam_dumpgpio(GPIO_PORT_PIOB, "Pins: 28-31"); +#endif #endif /* Reset the card and assure that it is in the initial, unconfigured diff --git a/arch/arm/src/sam34/sam_start.c b/arch/arm/src/sam34/sam_start.c index c264328e49b8d..76c037a38a436 100644 --- a/arch/arm/src/sam34/sam_start.c +++ b/arch/arm/src/sam34/sam_start.c @@ -71,10 +71,6 @@ const uintptr_t g_idle_topstack = HEAP_BASE; * Private Function prototypes ****************************************************************************/ -#ifdef CONFIG_ARCH_FPU -static inline void sam_fpuconfig(void); -#endif - #ifdef CONFIG_ARMV7M_STACKCHECK /* We need to get r10 set before we can allow instrumentation calls */ @@ -99,96 +95,6 @@ void __start(void) noinstrument_function; # define showprogress(c) #endif -/**************************************************************************** - * Name: sam_fpuconfig - * - * Description: - * Configure the FPU. Relative bit settings: - * - * CPACR: Enables access to CP10 and CP11 - * CONTROL.FPCA: Determines whether the FP extension is active in the - * current context: - * FPCCR.ASPEN: Enables automatic FP state preservation, then the - * processor sets this bit to 1 on successful completion of any FP - * instruction. - * FPCCR.LSPEN: Enables lazy context save of FP state. When this is - * done, the processor reserves space on the stack for the FP state, - * but does not save that state information to the stack. - * - * Software must not change the value of the ASPEN bit or LSPEN bit either: - * - the CPACR permits access to CP10 and CP11, that give access to the FP - * extension, or - * - the CONTROL.FPCA bit is set to 1 - * - ****************************************************************************/ - -#ifdef CONFIG_ARCH_FPU -#ifndef CONFIG_ARMV7M_LAZYFPU - -static inline void sam_fpuconfig(void) -{ - uint32_t regval; - - /* Set CONTROL.FPCA so that we always get the extended context frame - * with the volatile FP registers stacked above the basic context. - */ - - regval = getcontrol(); - regval |= CONTROL_FPCA; - setcontrol(regval); - - /* Ensure that FPCCR.LSPEN is disabled, so that we don't have to contend - * with the lazy FP context save behaviour. Clear FPCCR.ASPEN since we - * are going to turn on CONTROL.FPCA for all contexts. - */ - - regval = getreg32(NVIC_FPCCR); - regval &= ~(NVIC_FPCCR_ASPEN | NVIC_FPCCR_LSPEN); - putreg32(regval, NVIC_FPCCR); - - /* Enable full access to CP10 and CP11 */ - - regval = getreg32(NVIC_CPACR); - regval |= NVIC_CPACR_CP_FULL(10) | NVIC_CPACR_CP_FULL(11); - putreg32(regval, NVIC_CPACR); -} - -#else - -static inline void sam_fpuconfig(void) -{ - uint32_t regval; - - /* Clear CONTROL.FPCA so that we do not get the extended context frame - * with the volatile FP registers stacked in the saved context. - */ - - regval = getcontrol(); - regval &= ~CONTROL_FPCA; - setcontrol(regval); - - /* Ensure that FPCCR.LSPEN is disabled, so that we don't have to contend - * with the lazy FP context save behaviour. Clear FPCCR.ASPEN since we - * are going to keep CONTROL.FPCA off for all contexts. - */ - - regval = getreg32(NVIC_FPCCR); - regval &= ~(NVIC_FPCCR_ASPEN | NVIC_FPCCR_LSPEN); - putreg32(regval, NVIC_FPCCR); - - /* Enable full access to CP10 and CP11 */ - - regval = getreg32(NVIC_CPACR); - regval |= NVIC_CPACR_CP_FULL(10) | NVIC_CPACR_CP_FULL(11); - putreg32(regval, NVIC_CPACR); -} - -#endif - -#else -# define sam_fpuconfig() -#endif - /**************************************************************************** * Public Functions ****************************************************************************/ @@ -257,7 +163,7 @@ void __start(void) /* Configure the UART so that we can get debug output as soon as possible */ sam_clockconfig(); - sam_fpuconfig(); + arm_fpuconfig(); sam_lowsetup(); showprogress('A'); diff --git a/arch/arm/src/sama5/Make.defs b/arch/arm/src/sama5/Make.defs index 1aca3b593994b..24ac6fbba3c83 100644 --- a/arch/arm/src/sama5/Make.defs +++ b/arch/arm/src/sama5/Make.defs @@ -18,100 +18,7 @@ # ############################################################################ -# The vector table is the "head" object, i.e., the one that must forced into -# the link in order to draw in all of the other components - -HEAD_ASRC = arm_vectortab.S - -ifeq ($(CONFIG_BUILD_KERNEL),y) -crt0$(OBJEXT): crt0.c - $(CC) $(CFLAGS) -c armv7-a$(DELIM)crt0.c -o crt0$(OBJEXT) - -STARTUP_OBJS = crt0$(OBJEXT) -endif - -# Force the start-up logic to be at the beginning of the .text to simplify -# debug. - -ifeq ($(CONFIG_PAGING),y) -CMN_ASRCS = arm_pghead.S -else -CMN_ASRCS = arm_head.S -endif - -# Common assembly language files - -CMN_ASRCS += arm_vectors.S arm_fpuconfig.S arm_fullcontextrestore.S -CMN_ASRCS += arm_saveusercontext.S arm_vectoraddrexcptn.S -CMN_ASRCS += arm_testset.S arm_fetchadd.S vfork.S -CMN_ASRCS += cp15_coherent_dcache.S cp15_invalidate_dcache.S -CMN_ASRCS += cp15_clean_dcache.S cp15_flush_dcache.S cp15_invalidate_dcache_all.S -CMN_ASRCS += cp15_clean_dcache_all.S cp15_flush_dcache_all.S cp15_cache_size.S - -# Configuration dependent assembly language files - -# Common C source files - -CMN_CSRCS = arm_initialize.c arm_interruptcontext.c arm_exit.c arm_createstack.c -CMN_CSRCS += arm_releasestack.c arm_usestack.c arm_vfork.c arm_puts.c arm_mdelay.c -CMN_CSRCS += arm_stackframe.c arm_udelay.c arm_modifyreg8.c arm_modifyreg16.c -CMN_CSRCS += arm_modifyreg32.c - -CMN_CSRCS += arm_assert.c arm_blocktask.c arm_dataabort.c -CMN_CSRCS += arm_doirq.c arm_initialstate.c arm_mmu.c arm_prefetchabort.c -CMN_CSRCS += arm_releasepending.c arm_reprioritizertr.c -CMN_CSRCS += arm_schedulesigaction.c arm_sigdeliver.c arm_syscall.c -CMN_CSRCS += arm_unblocktask.c arm_undefinedinsn.c arm_tcbinfo.c -CMN_CSRCS += arm_switchcontext.c - -# Configuration dependent C files - -ifneq ($(CONFIG_ARCH_IDLE_CUSTOM),y) -CMN_CSRCS += arm_idle.c -endif - -ifeq ($(CONFIG_ARMV7A_L2CC_PL310),y) -CMN_CSRCS += arm_l2cc_pl310.c -endif - -ifeq ($(CONFIG_PAGING),y) -CMN_CSRCS += arm_allocpage.c arm_checkmapping.c arm_pginitialize.c -CMN_CSRCS += arm_va2pte.c -endif - -ifeq ($(CONFIG_BUILD_KERNEL),y) -CMN_CSRCS += arm_task_start.c arm_pthread_start.c arm_signal_dispatch.c -endif - -ifeq ($(CONFIG_ARCH_ADDRENV),y) -CMN_CSRCS += arm_addrenv.c arm_addrenv_utils.c arm_pgalloc.c -ifeq ($(CONFIG_ARCH_STACK_DYNAMIC),y) -CMN_CSRCS += arm_addrenv_ustack.c -endif -ifeq ($(CONFIG_ARCH_KERNEL_STACK),y) -CMN_CSRCS += arm_addrenv_kstack.c -endif -ifeq ($(CONFIG_MM_SHM),y) -CMN_CSRCS += arm_addrenv_shm.c -endif -endif - -ifeq ($(CONFIG_MM_PGALLOC),y) -CMN_CSRCS += arm_physpgaddr.c -ifeq ($(CONFIG_ARCH_PGPOOL_MAPPING),y) -CMN_CSRCS += arm_virtpgaddr.c -endif -endif - -CMN_CSRCS += arm_cache.c - -ifeq ($(CONFIG_ARCH_FPU),y) -CMN_ASRCS += arm_savefpu.S arm_restorefpu.S -endif - -ifeq ($(CONFIG_STACK_COLORATION),y) -CMN_CSRCS += arm_checkstack.c -endif +include armv7-a/Make.defs # SAMA5-specific C source files diff --git a/arch/arm/src/sama5/sam_boot.c b/arch/arm/src/sama5/sam_boot.c index d01e7857ab0f7..42951b75f6847 100644 --- a/arch/arm/src/sama5/sam_boot.c +++ b/arch/arm/src/sama5/sam_boot.c @@ -38,7 +38,6 @@ #include "chip.h" #include "arm.h" #include "mmu.h" -#include "fpu.h" #include "arm_internal.h" #include "hardware/sam_wdt.h" #include "hardware/sam_aximx.h" @@ -445,11 +444,9 @@ void arm_boot(void) sam_clockconfig(); -#ifdef CONFIG_ARCH_FPU /* Initialize the FPU */ arm_fpuconfig(); -#endif /* Perform board-specific initialization, This must include: * diff --git a/arch/arm/src/sama5/sam_ehci.c b/arch/arm/src/sama5/sam_ehci.c index c305e01f7db84..ed0ab69d7b71c 100644 --- a/arch/arm/src/sama5/sam_ehci.c +++ b/arch/arm/src/sama5/sam_ehci.c @@ -398,7 +398,8 @@ static int sam_ep0configure(FAR struct usbhost_driver_s *drvr, usbhost_ep_t ep0, uint8_t funcaddr, uint8_t speed, uint16_t maxpacketsize); static int sam_epalloc(FAR struct usbhost_driver_s *drvr, - const FAR struct usbhost_epdesc_s *epdesc, usbhost_ep_t *ep); + FAR const struct usbhost_epdesc_s *epdesc, + FAR usbhost_ep_t *ep); static int sam_epfree(FAR struct usbhost_driver_s *drvr, usbhost_ep_t ep); static int sam_alloc(FAR struct usbhost_driver_s *drvr, FAR uint8_t **buffer, FAR size_t *maxlen); @@ -3751,8 +3752,8 @@ static int sam_ep0configure(FAR struct usbhost_driver_s *drvr, ****************************************************************************/ static int sam_epalloc(FAR struct usbhost_driver_s *drvr, - const FAR struct usbhost_epdesc_s *epdesc, - usbhost_ep_t *ep) + FAR const struct usbhost_epdesc_s *epdesc, + FAR usbhost_ep_t *ep) { struct sam_epinfo_s *epinfo; struct usbhost_hubport_s *hport; diff --git a/arch/arm/src/sama5/sam_hsmci.c b/arch/arm/src/sama5/sam_hsmci.c index 4684dd05b6b41..225806573287d 100644 --- a/arch/arm/src/sama5/sam_hsmci.c +++ b/arch/arm/src/sama5/sam_hsmci.c @@ -3162,7 +3162,7 @@ static void sam_callback(void *arg) } mcinfo("Queuing callback to %p(%p)\n", priv->callback, priv->cbarg); - ret = work_queue(LPWORK, &priv->cbwork, (worker_t)priv->callback, + ret = work_queue(LPWORK, &priv->cbwork, priv->callback, priv->cbarg, 0); if (ret < 0) { diff --git a/arch/arm/src/sama5/sam_pioirq.c b/arch/arm/src/sama5/sam_pioirq.c index e87bb64584062..9bc9b43dfd538 100644 --- a/arch/arm/src/sama5/sam_pioirq.c +++ b/arch/arm/src/sama5/sam_pioirq.c @@ -479,7 +479,7 @@ void sam_pioirqenable(int irq) { /* Clear (all) pending interrupts and enable this pin interrupt */ - (void)getreg32(base + SAM_PIO_ISR_OFFSET); + getreg32(base + SAM_PIO_ISR_OFFSET); putreg32((1 << pin), base + SAM_PIO_IER_OFFSET); } } diff --git a/arch/arm/src/sama5/sam_sdmmc.c b/arch/arm/src/sama5/sam_sdmmc.c index 545320961e137..241707dfb0453 100644 --- a/arch/arm/src/sama5/sam_sdmmc.c +++ b/arch/arm/src/sama5/sam_sdmmc.c @@ -1427,8 +1427,8 @@ static int sam_interrupt(int irq, void *context, FAR void *arg) mcinfo("Queuing callback to %p(%p)\n", priv->callback, priv->cbarg); - (void)work_queue(HPWORK, &priv->cbwork, (worker_t)priv->callback, - priv->cbarg, 0); + work_queue(HPWORK, &priv->cbwork, priv->callback, + priv->cbarg, 0); } else { @@ -3242,7 +3242,7 @@ static void sam_callback(void *arg) mcinfo("Queuing callback to %p(%p)\n", priv->callback, priv->cbarg); - work_queue(HPWORK, &priv->cbwork, (worker_t)priv->callback, + work_queue(HPWORK, &priv->cbwork, priv->callback, priv->cbarg, 0); } else diff --git a/arch/arm/src/sama5/sam_tsd.c b/arch/arm/src/sama5/sam_tsd.c index 9540f01287ebf..d3edeca39a078 100644 --- a/arch/arm/src/sama5/sam_tsd.c +++ b/arch/arm/src/sama5/sam_tsd.c @@ -271,7 +271,7 @@ static void sam_tsd_notify(struct sam_tsd_s *priv) if (fds) { fds->revents |= POLLIN; - iinfo("Report events: %02x\n", fds->revents); + iinfo("Report events: %08" PRIx32 "\n", fds->revents); nxsem_post(fds->sem); } } @@ -1675,7 +1675,7 @@ int sam_tsd_register(struct sam_adc_s *adc, int minor) /* Register the device as an input device */ - snprintf(devname, DEV_NAMELEN, DEV_FORMAT, minor); + snprintf(devname, sizeof(devname), DEV_FORMAT, minor); iinfo("Registering %s\n", devname); ret = register_driver(devname, &g_tsdops, 0666, priv); diff --git a/arch/arm/src/samd2l2/Make.defs b/arch/arm/src/samd2l2/Make.defs index e92c7c9fe1626..67645899a55c8 100644 --- a/arch/arm/src/samd2l2/Make.defs +++ b/arch/arm/src/samd2l2/Make.defs @@ -18,32 +18,7 @@ # ############################################################################ -CMN_ASRCS = arm_exception.S arm_saveusercontext.S arm_fullcontextrestore.S -CMN_ASRCS += vfork.S - -CMN_CSRCS = arm_allocateheap.c arm_assert.c arm_blocktask.c -CMN_CSRCS += arm_createstack.c arm_mdelay.c arm_udelay.c arm_exit.c -CMN_CSRCS += arm_initialize.c arm_initialstate.c arm_interruptcontext.c -CMN_CSRCS += arm_modifyreg8.c arm_modifyreg16.c arm_modifyreg32.c -CMN_CSRCS += arm_releasepending.c arm_releasestack.c arm_reprioritizertr.c -CMN_CSRCS += arm_schedulesigaction.c arm_sigdeliver.c arm_stackframe.c -CMN_CSRCS += arm_systemreset.c arm_unblocktask.c arm_usestack.c arm_doirq.c -CMN_CSRCS += arm_hardfault.c arm_svcall.c arm_vectors.c arm_vfork.c -CMN_CSRCS += arm_switchcontext.c arm_puts.c arm_tcbinfo.c - -ifeq ($(CONFIG_BUILD_PROTECTED),y) -CMN_CSRCS += arm_task_start.c arm_pthread_start.c -CMN_CSRCS += arm_signal_dispatch.c -CMN_UASRCS += arm_signal_handler.S -endif - -ifeq ($(CONFIG_STACK_COLORATION),y) -CMN_CSRCS += arm_checkstack.c -endif - -ifeq ($(CONFIG_DEBUG_FEATURES),y) -CMN_CSRCS += arm_dumpnvic.c -endif +include armv6-m/Make.defs CHIP_CSRCS = sam_irq.c sam_lowputc.c sam_port.c sam_sercom.c sam_serial.c CHIP_CSRCS += sam_start.c sam_usart.c diff --git a/arch/arm/src/samd5e5/Make.defs b/arch/arm/src/samd5e5/Make.defs index 10f7f9a60179b..295e69804c739 100644 --- a/arch/arm/src/samd5e5/Make.defs +++ b/arch/arm/src/samd5e5/Make.defs @@ -22,45 +22,7 @@ # Common ARM and Cortex-M4 files -CMN_ASRCS = arm_saveusercontext.S arm_fullcontextrestore.S -CMN_ASRCS += arm_testset.S arm_fetchadd.S vfork.S - -CMN_CSRCS = arm_allocateheap.c arm_assert.c arm_blocktask.c -CMN_CSRCS += arm_createstack.c arm_exit.c arm_initialize.c arm_initialstate.c -CMN_CSRCS += arm_interruptcontext.c arm_mdelay.c arm_memfault.c arm_modifyreg8.c -CMN_CSRCS += arm_modifyreg16.c arm_modifyreg32.c arm_releasepending.c -CMN_CSRCS += arm_releasestack.c arm_reprioritizertr.c arm_schedulesigaction.c -CMN_CSRCS += arm_sigdeliver.c arm_stackframe.c arm_svcall.c arm_trigger_irq.c -CMN_CSRCS += arm_unblocktask.c arm_udelay.c arm_usestack.c arm_doirq.c -CMN_CSRCS += arm_hardfault.c arm_vfork.c arm_switchcontext.c arm_puts.c -CMN_CSRCS += arm_tcbinfo.c - -# Configuration-dependent common files - -ifeq ($(CONFIG_ARMV7M_LAZYFPU),y) -CMN_ASRCS += arm_lazyexception.S -else -CMN_ASRCS += arm_exception.S -endif -CMN_CSRCS += arm_vectors.c - -ifeq ($(CONFIG_ARCH_RAMVECTORS),y) -CMN_CSRCS += arm_ramvec_initialize.c arm_ramvec_attach.c -endif - -ifeq ($(CONFIG_BUILD_PROTECTED),y) -CMN_CSRCS += arm_mpu.c arm_task_start.c arm_pthread_start.c -CMN_CSRCS += arm_signal_dispatch.c -CMN_UASRCS += arm_signal_handler.S -endif - -ifeq ($(CONFIG_ARCH_FPU),y) -CMN_ASRCS += arm_fpu.S -endif - -ifeq ($(CONFIG_STACK_COLORATION),y) -CMN_CSRCS += arm_checkstack.c -endif +include armv7-m/Make.defs # Required SAMD5x/E5x files diff --git a/arch/arm/src/samd5e5/sam_oneshot.c b/arch/arm/src/samd5e5/sam_oneshot.c index b5ebf70d82ae0..769a5ea6f1beb 100644 --- a/arch/arm/src/samd5e5/sam_oneshot.c +++ b/arch/arm/src/samd5e5/sam_oneshot.c @@ -221,7 +221,7 @@ int sam_oneshot_start(struct sam_oneshot_s *oneshot, /* Yes.. then cancel it */ tmrinfo("Already running... cancelling\n"); - (void)sam_oneshot_cancel(oneshot, freerun, NULL); + sam_oneshot_cancel(oneshot, freerun, NULL); } /* Save the new handler and its argument */ diff --git a/arch/arm/src/samd5e5/sam_progmem.c b/arch/arm/src/samd5e5/sam_progmem.c index e3f612d770186..a5c3047b12d6f 100644 --- a/arch/arm/src/samd5e5/sam_progmem.c +++ b/arch/arm/src/samd5e5/sam_progmem.c @@ -541,7 +541,7 @@ ssize_t up_progmem_eraseblock(size_t cluster) /* Erase all pages in the cluster */ #ifdef USE_UNLOCK - (void)nvm_unlock(page, SAMD5E5_PAGE_PER_CLUSTER); + nvm_unlock(page, SAMD5E5_PAGE_PER_CLUSTER); #endif finfo("INFO: erase block=%d address=0x%x\n", @@ -549,7 +549,7 @@ ssize_t up_progmem_eraseblock(size_t cluster) ret = nvm_command(NVMCTRL_CTRLB_CMD_EB, SAMD5E5_PAGE2BYTE(page)); #ifdef USE_LOCK - (void)nvm_lock(page, SAMD5E5_PAGE_PER_CLUSTER); + nvm_lock(page, SAMD5E5_PAGE_PER_CLUSTER); #endif if (ret < 0) @@ -698,7 +698,7 @@ ssize_t up_progmem_write(size_t address, const void *buffer, size_t buflen) #ifdef USE_UNLOCK /* Make sure that the FLASH is unlocked */ lock = page; locksize = SAMD5E5_BYTE2PAGE(buflen); - (void)nvm_unlock(lock, locksize); + nvm_unlock(lock, locksize); #endif flags = enter_critical_section(); @@ -860,7 +860,7 @@ ssize_t up_progmem_write(size_t address, const void *buffer, size_t buflen) } #ifdef USE_LOCK - (void)nvm_lock(lock, locksize); + nvm_lock(lock, locksize); #endif leave_critical_section(flags); diff --git a/arch/arm/src/samd5e5/sam_start.c b/arch/arm/src/samd5e5/sam_start.c index f2814f6fabd9f..fbe5aac4e2498 100644 --- a/arch/arm/src/samd5e5/sam_start.c +++ b/arch/arm/src/samd5e5/sam_start.c @@ -101,96 +101,6 @@ void __start(void) noinstrument_function; # define showprogress(c) #endif -/**************************************************************************** - * Name: sam_fpu_configure - * - * Description: - * Configure the FPU. Relative bit settings: - * - * CPACR: Enables access to CP10 and CP11 - * CONTROL.FPCA: Determines whether the FP extension is active in the - * current context: - * FPCCR.ASPEN: Enables automatic FP state preservation, then the - * processor sets this bit to 1 on successful completion of any FP - * instruction. - * FPCCR.LSPEN: Enables lazy context save of FP state. When this is - * done, the processor reserves space on the stack for the FP state, - * but does not save that state information to the stack. - * - * Software must not change the value of the ASPEN bit or LSPEN bit either: - * - the CPACR permits access to CP10 and CP11, that give access to the FP - * extension, or - * - the CONTROL.FPCA bit is set to 1 - * - ****************************************************************************/ - -#ifdef CONFIG_ARCH_FPU -#ifndef CONFIG_ARMV7M_LAZYFPU - -static inline void sam_fpu_configure(void) -{ - uint32_t regval; - - /* Set CONTROL.FPCA so that we always get the extended context frame - * with the volatile FP registers stacked above the basic context. - */ - - regval = getcontrol(); - regval |= CONTROL_FPCA; - setcontrol(regval); - - /* Ensure that FPCCR.LSPEN is disabled, so that we don't have to contend - * with the lazy FP context save behaviour. Clear FPCCR.ASPEN since we - * are going to turn on CONTROL.FPCA for all contexts. - */ - - regval = getreg32(NVIC_FPCCR); - regval &= ~(NVIC_FPCCR_ASPEN | NVIC_FPCCR_LSPEN); - putreg32(regval, NVIC_FPCCR); - - /* Enable full access to CP10 and CP11 */ - - regval = getreg32(NVIC_CPACR); - regval |= NVIC_CPACR_CP_FULL(10) | NVIC_CPACR_CP_FULL(11); - putreg32(regval, NVIC_CPACR); -} - -#else - -static inline void sam_fpu_configure(void) -{ - uint32_t regval; - - /* Clear CONTROL.FPCA so that we do not get the extended context frame - * with the volatile FP registers stacked in the saved context. - */ - - regval = getcontrol(); - regval &= ~CONTROL_FPCA; - setcontrol(regval); - - /* Ensure that FPCCR.LSPEN is disabled, so that we don't have to contend - * with the lazy FP context save behaviour. Clear FPCCR.ASPEN since we - * are going to keep CONTROL.FPCA off for all contexts. - */ - - regval = getreg32(NVIC_FPCCR); - regval &= ~(NVIC_FPCCR_ASPEN | NVIC_FPCCR_LSPEN); - putreg32(regval, NVIC_FPCCR); - - /* Enable full access to CP10 and CP11 */ - - regval = getreg32(NVIC_CPACR); - regval |= NVIC_CPACR_CP_FULL(10) | NVIC_CPACR_CP_FULL(11); - putreg32(regval, NVIC_CPACR); -} - -#endif - -#else -# define sam_fpu_configure() -#endif - /**************************************************************************** * Public Functions ****************************************************************************/ @@ -258,7 +168,7 @@ void __start(void) */ sam_clock_initialize(); - sam_fpu_configure(); + arm_fpuconfig(); sam_lowsetup(); showprogress('A'); diff --git a/arch/arm/src/samd5e5/sam_tc.c b/arch/arm/src/samd5e5/sam_tc.c index 21073923d3478..bcb81e1773465 100644 --- a/arch/arm/src/samd5e5/sam_tc.c +++ b/arch/arm/src/samd5e5/sam_tc.c @@ -657,7 +657,7 @@ TC_HANDLE sam_tc_allocate(int tc, int frequency) /* Initialize the TC driver structure */ priv->flags = 0; - (void)nxsem_init(&priv->exclsem, 0, 1); + nxsem_init(&priv->exclsem, 0, 1); /* Enable clocking to the TC module in PCHCTRL */ diff --git a/arch/arm/src/samd5e5/sam_timerisr.c b/arch/arm/src/samd5e5/sam_timerisr.c index 2d51c5ead1971..f540a6cf8ae90 100644 --- a/arch/arm/src/samd5e5/sam_timerisr.c +++ b/arch/arm/src/samd5e5/sam_timerisr.c @@ -113,7 +113,7 @@ void up_timer_initialize(void) /* Attach the timer interrupt vector */ - (void)irq_attach(SAM_IRQ_SYSTICK, (xcpt_t)sam_timerisr, NULL); + irq_attach(SAM_IRQ_SYSTICK, (xcpt_t)sam_timerisr, NULL); /* Enable SysTick interrupts using the processor clock source. */ diff --git a/arch/arm/src/samd5e5/sam_usb.c b/arch/arm/src/samd5e5/sam_usb.c index 308d6a1c65f32..b916b3f41b5e5 100644 --- a/arch/arm/src/samd5e5/sam_usb.c +++ b/arch/arm/src/samd5e5/sam_usb.c @@ -957,7 +957,7 @@ static int sam_ep0configure(FAR struct usbhost_driver_s *drvr, uint8_t speed, uint16_t maxpacketsize); static int sam_epalloc(FAR struct usbhost_driver_s *drvr, - FAR const FAR struct usbhost_epdesc_s *epdesc, + FAR const struct usbhost_epdesc_s *epdesc, FAR usbhost_ep_t *ep); static int sam_epfree(FAR struct usbhost_driver_s *drvr, usbhost_ep_t ep); static int sam_alloc(FAR struct usbhost_driver_s *drvr, diff --git a/arch/arm/src/samd5e5/sam_wdt.c b/arch/arm/src/samd5e5/sam_wdt.c index f337a2d2ecea6..cbbd79c32c3b6 100644 --- a/arch/arm/src/samd5e5/sam_wdt.c +++ b/arch/arm/src/samd5e5/sam_wdt.c @@ -457,7 +457,7 @@ void sam_wdt_initialize(FAR const char *devpath) priv->started = false; sam_settimeout((FAR struct watchdog_lowerhalf_s *)priv, BOARD_SCLK_FREQUENCY / 2); - (void)watchdog_register(devpath, (FAR struct watchdog_lowerhalf_s *)priv); + watchdog_register(devpath, (FAR struct watchdog_lowerhalf_s *)priv); } #endif /* CONFIG_WATCHDOG && CONFIG__WDT */ diff --git a/arch/arm/src/samv7/Make.defs b/arch/arm/src/samv7/Make.defs index 1c7f8b6def33a..e57e17a7aad49 100644 --- a/arch/arm/src/samv7/Make.defs +++ b/arch/arm/src/samv7/Make.defs @@ -23,58 +23,7 @@ # Common ARM and Cortex-M7 files -CMN_ASRCS = arm_saveusercontext.S arm_fullcontextrestore.S -CMN_ASRCS += arm_testset.S arm_fetchadd.S vfork.S - -CMN_CSRCS = arm_assert.c arm_blocktask.c arm_createstack.c -CMN_CSRCS += arm_exit.c arm_hardfault.c arm_initialize.c arm_initialstate.c -CMN_CSRCS += arm_interruptcontext.c arm_mdelay.c arm_udelay.c arm_systemreset.c -CMN_CSRCS += arm_memfault.c arm_modifyreg8.c arm_modifyreg16.c arm_modifyreg32.c -CMN_CSRCS += arm_releasepending.c arm_releasestack.c arm_reprioritizertr.c -CMN_CSRCS += arm_schedulesigaction.c arm_sigdeliver.c arm_stackframe.c -CMN_CSRCS += arm_svcall.c arm_trigger_irq.c arm_unblocktask.c arm_usestack.c -CMN_CSRCS += arm_doirq.c arm_vfork.c arm_switchcontext.c arm_puts.c -CMN_CSRCS += arm_tcbinfo.c - -# Configuration-dependent common files - -ifneq ($(CONFIG_ARCH_IDLE_CUSTOM),y) -CMN_CSRCS += arm_idle.c -endif - -ifeq ($(CONFIG_ARMV7M_STACKCHECK),y) -CMN_CSRCS += arm_stackcheck.c -endif - -ifeq ($(CONFIG_ARMV7M_LAZYFPU),y) -CMN_ASRCS += arm_lazyexception.S -else -CMN_ASRCS += arm_exception.S -endif -CMN_CSRCS += arm_vectors.c - -CMN_CSRCS += arm_cache.c - -ifeq ($(CONFIG_ARCH_FPU),y) -CMN_ASRCS += arm_fpu.S -endif - -ifeq ($(CONFIG_ARCH_RAMVECTORS),y) -CMN_CSRCS += arm_ramvec_initialize.c arm_ramvec_attach.c -endif - -ifeq ($(CONFIG_ARM_MPU),y) -CMN_CSRCS += arm_mpu.c -ifeq ($(CONFIG_BUILD_PROTECTED),y) -CMN_CSRCS += arm_task_start.c arm_pthread_start.c -CMN_CSRCS += arm_signal_dispatch.c -CMN_UASRCS += arm_signal_handler.S -endif -endif - -ifeq ($(CONFIG_STACK_COLORATION),y) -CMN_CSRCS += arm_checkstack.c -endif +include armv7-m/Make.defs # Required SAMV7 files diff --git a/arch/arm/src/samv7/sam_gpioirq.c b/arch/arm/src/samv7/sam_gpioirq.c index edbab38f3ae65..31d09a7d1a44a 100644 --- a/arch/arm/src/samv7/sam_gpioirq.c +++ b/arch/arm/src/samv7/sam_gpioirq.c @@ -389,7 +389,7 @@ void sam_gpioirqenable(int irq) { /* Clear (all) pending interrupts and enable this pin interrupt */ - /* (void)getreg32(base + SAM_PIO_ISR_OFFSET); */ + /* getreg32(base + SAM_PIO_ISR_OFFSET); */ putreg32((1 << pin), base + SAM_PIO_IER_OFFSET); } diff --git a/arch/arm/src/samv7/sam_hsmci.c b/arch/arm/src/samv7/sam_hsmci.c index e79e2218e91bd..a094c4afb0ac9 100644 --- a/arch/arm/src/samv7/sam_hsmci.c +++ b/arch/arm/src/samv7/sam_hsmci.c @@ -3228,7 +3228,7 @@ static void sam_callback(void *arg) } mcinfo("Queuing callback to %p(%p)\n", priv->callback, priv->cbarg); - ret = work_queue(LPWORK, &priv->cbwork, (worker_t)priv->callback, + ret = work_queue(LPWORK, &priv->cbwork, priv->callback, priv->cbarg, 0); if (ret < 0) { diff --git a/arch/arm/src/samv7/sam_mcan.c b/arch/arm/src/samv7/sam_mcan.c index 49fdd06da8cb2..f61cbfb027ed6 100644 --- a/arch/arm/src/samv7/sam_mcan.c +++ b/arch/arm/src/samv7/sam_mcan.c @@ -777,7 +777,8 @@ MCAN_INT_TEFL) #define MCAN_TXDEDBUF_INTS MCAN_TXCOMMON_INTS -#define MCAN_TXERR_INTS (MCAN_INT_TEFL | MCAN_INT_PEA | MCAN_INT_PED) +#define MCAN_TXERR_INTS (MCAN_INT_TEFL | MCAN_INT_PEA | MCAN_INT_PED | \ + MCAN_INT_ACKE) /* Common-, TX- and RX-Error-Mask */ diff --git a/arch/arm/src/samv7/sam_start.c b/arch/arm/src/samv7/sam_start.c index b22b2b8cff509..221b117db890d 100644 --- a/arch/arm/src/samv7/sam_start.c +++ b/arch/arm/src/samv7/sam_start.c @@ -78,14 +78,6 @@ const uintptr_t g_idle_topstack = HEAP_BASE; -/**************************************************************************** - * Private Function prototypes - ****************************************************************************/ - -#ifdef CONFIG_ARCH_FPU -static inline void sam_fpuconfig(void); -#endif - /**************************************************************************** * Private Functions ****************************************************************************/ @@ -96,96 +88,6 @@ static inline void sam_fpuconfig(void); void __start(void) noinstrument_function; #endif -/**************************************************************************** - * Name: sam_fpuconfig - * - * Description: - * Configure the FPU. Relative bit settings: - * - * CPACR: Enables access to CP10 and CP11 - * CONTROL.FPCA: Determines whether the FP extension is active in the - * current context: - * FPCCR.ASPEN: Enables automatic FP state preservation, then the - * processor sets this bit to 1 on successful completion of any FP - * instruction. - * FPCCR.LSPEN: Enables lazy context save of FP state. When this is - * done, the processor reserves space on the stack for the FP state, - * but does not save that state information to the stack. - * - * Software must not change the value of the ASPEN bit or LSPEN bit either: - * - the CPACR permits access to CP10 and CP11, that give access to the FP - * extension, or - * - the CONTROL.FPCA bit is set to 1 - * - ****************************************************************************/ - -#ifdef CONFIG_ARCH_FPU -#ifndef CONFIG_ARMV7M_LAZYFPU - -static inline void sam_fpuconfig(void) -{ - uint32_t regval; - - /* Set CONTROL.FPCA so that we always get the extended context frame - * with the volatile FP registers stacked above the basic context. - */ - - regval = getcontrol(); - regval |= CONTROL_FPCA; - setcontrol(regval); - - /* Ensure that FPCCR.LSPEN is disabled, so that we don't have to contend - * with the lazy FP context save behaviour. Clear FPCCR.ASPEN since we - * are going to turn on CONTROL.FPCA for all contexts. - */ - - regval = getreg32(NVIC_FPCCR); - regval &= ~(NVIC_FPCCR_ASPEN | NVIC_FPCCR_LSPEN); - putreg32(regval, NVIC_FPCCR); - - /* Enable full access to CP10 and CP11 */ - - regval = getreg32(NVIC_CPACR); - regval |= NVIC_CPACR_CP_FULL(10) | NVIC_CPACR_CP_FULL(11); - putreg32(regval, NVIC_CPACR); -} - -#else - -static inline void sam_fpuconfig(void) -{ - uint32_t regval; - - /* Clear CONTROL.FPCA so that we do not get the extended context frame - * with the volatile FP registers stacked in the saved context. - */ - - regval = getcontrol(); - regval &= ~CONTROL_FPCA; - setcontrol(regval); - - /* Ensure that FPCCR.LSPEN is disabled, so that we don't have to contend - * with the lazy FP context save behaviour. Clear FPCCR.ASPEN since we - * are going to keep CONTROL.FPCA off for all contexts. - */ - - regval = getreg32(NVIC_FPCCR); - regval &= ~(NVIC_FPCCR_ASPEN | NVIC_FPCCR_LSPEN); - putreg32(regval, NVIC_FPCCR); - - /* Enable full access to CP10 and CP11 */ - - regval = getreg32(NVIC_CPACR); - regval |= NVIC_CPACR_CP_FULL(10) | NVIC_CPACR_CP_FULL(11); - putreg32(regval, NVIC_CPACR); -} - -#endif - -#else -# define sam_fpuconfig() -#endif - /**************************************************************************** * Name: sam_tcmenable * @@ -296,7 +198,7 @@ void __start(void) /* Configure the UART so that we can get debug output as soon as possible */ sam_clockconfig(); - sam_fpuconfig(); + arm_fpuconfig(); sam_gpioinit(); sam_lowsetup(); diff --git a/arch/arm/src/stm32/Make.defs b/arch/arm/src/stm32/Make.defs index c80705c687ab0..b58ebd8149d2f 100644 --- a/arch/arm/src/stm32/Make.defs +++ b/arch/arm/src/stm32/Make.defs @@ -18,63 +18,7 @@ # ############################################################################ -CMN_ASRCS = arm_saveusercontext.S arm_fullcontextrestore.S -CMN_ASRCS += arm_testset.S arm_fetchadd.S vfork.S - -CMN_CSRCS = arm_assert.c arm_blocktask.c arm_createstack.c -CMN_CSRCS += arm_exit.c arm_hardfault.c arm_initialize.c arm_initialstate.c -CMN_CSRCS += arm_interruptcontext.c arm_memfault.c arm_modifyreg8.c arm_mdelay.c -CMN_CSRCS += arm_modifyreg16.c arm_modifyreg32.c arm_releasepending.c -CMN_CSRCS += arm_releasestack.c arm_reprioritizertr.c arm_schedulesigaction.c -CMN_CSRCS += arm_sigdeliver.c arm_stackframe.c arm_svcall.c arm_systemreset.c -CMN_CSRCS += arm_trigger_irq.c arm_unblocktask.c arm_udelay.c arm_usestack.c -CMN_CSRCS += arm_doirq.c arm_vfork.c arm_switchcontext.c arm_puts.c -CMN_CSRCS += arm_tcbinfo.c - -ifeq ($(CONFIG_STM32_TICKLESS_SYSTICK),y) -CMN_CSRCS += arm_systick.c -endif - -ifeq ($(CONFIG_ARMV7M_STACKCHECK),y) -CMN_CSRCS += arm_stackcheck.c -endif - -ifeq ($(CONFIG_ARMV7M_LAZYFPU),y) -CMN_ASRCS += arm_lazyexception.S -else -CMN_ASRCS += arm_exception.S -endif -CMN_CSRCS += arm_vectors.c - -ifeq ($(CONFIG_ARCH_RAMVECTORS),y) -CMN_CSRCS += arm_ramvec_initialize.c arm_ramvec_attach.c -endif - -ifneq ($(filter y,$(CONFIG_ARM_MPU) $(CONFIG_ARM_MPU_EARLY_RESET)),) -CMN_CSRCS += arm_mpu.c -endif - -ifeq ($(CONFIG_BUILD_PROTECTED),y) -CMN_CSRCS += arm_task_start.c arm_pthread_start.c -CMN_CSRCS += arm_signal_dispatch.c -CMN_UASRCS += arm_signal_handler.S -endif - -ifeq ($(CONFIG_STACK_COLORATION),y) -CMN_CSRCS += arm_checkstack.c -endif - -ifeq ($(CONFIG_ARCH_FPU),y) -CMN_ASRCS += arm_fpu.S -endif - -ifeq ($(CONFIG_ARMV7M_ITMSYSLOG),y) -CMN_CSRCS += arm_itm_syslog.c -endif - -ifeq ($(CONFIG_SCHED_THREAD_LOCAL),y) -CMN_CSRCS += arm_tls.c -endif +include armv7-m/Make.defs CHIP_CSRCS = stm32_allocateheap.c stm32_start.c stm32_rcc.c stm32_lse.c CHIP_CSRCS += stm32_lsi.c stm32_gpio.c stm32_exti_gpio.c stm32_flash.c diff --git a/arch/arm/src/stm32/stm32_bbsram.c b/arch/arm/src/stm32/stm32_bbsram.c index c8306be7f170d..56cb71ee1b0f6 100644 --- a/arch/arm/src/stm32/stm32_bbsram.c +++ b/arch/arm/src/stm32/stm32_bbsram.c @@ -140,7 +140,7 @@ static const struct file_operations stm32_bbsram_fops = .ioctl = stm32_bbsram_ioctl, .poll = stm32_bbsram_poll, #ifndef CONFIG_DISABLE_PSEUDOFS_OPERATIONS - .unlink = stm32_bbsram_unlink, + .unlink = stm32_bbsram_unlink #endif }; diff --git a/arch/arm/src/stm32/stm32_otgfshost.c b/arch/arm/src/stm32/stm32_otgfshost.c index afda392928d58..654569d9c793c 100644 --- a/arch/arm/src/stm32/stm32_otgfshost.c +++ b/arch/arm/src/stm32/stm32_otgfshost.c @@ -425,7 +425,7 @@ static int stm32_ep0configure(FAR struct usbhost_driver_s *drvr, usbhost_ep_t ep0, uint8_t funcaddr, uint8_t speed, uint16_t maxpacketsize); static int stm32_epalloc(FAR struct usbhost_driver_s *drvr, - FAR const FAR struct usbhost_epdesc_s *epdesc, + FAR const struct usbhost_epdesc_s *epdesc, FAR usbhost_ep_t *ep); static int stm32_epfree(FAR struct usbhost_driver_s *drvr, usbhost_ep_t ep); static int stm32_alloc(FAR struct usbhost_driver_s *drvr, diff --git a/arch/arm/src/stm32/stm32_otghshost.c b/arch/arm/src/stm32/stm32_otghshost.c index a76c41dbbaa7f..000c6a7317faf 100644 --- a/arch/arm/src/stm32/stm32_otghshost.c +++ b/arch/arm/src/stm32/stm32_otghshost.c @@ -430,7 +430,7 @@ static int stm32_ep0configure(FAR struct usbhost_driver_s *drvr, usbhost_ep_t ep0, uint8_t funcaddr, uint8_t speed, uint16_t maxpacketsize); static int stm32_epalloc(FAR struct usbhost_driver_s *drvr, - FAR const FAR struct usbhost_epdesc_s *epdesc, + FAR const struct usbhost_epdesc_s *epdesc, FAR usbhost_ep_t *ep); static int stm32_epfree(FAR struct usbhost_driver_s *drvr, usbhost_ep_t ep); static int stm32_alloc(FAR struct usbhost_driver_s *drvr, diff --git a/arch/arm/src/stm32/stm32_pminitialize.c b/arch/arm/src/stm32/stm32_pminitialize.c index 2e46ab7bd71d8..93be5677a4752 100644 --- a/arch/arm/src/stm32/stm32_pminitialize.c +++ b/arch/arm/src/stm32/stm32_pminitialize.c @@ -23,6 +23,7 @@ ****************************************************************************/ #include +#include #include "arm_internal.h" #include "stm32_pm.h" @@ -53,6 +54,9 @@ void arm_pminitialize(void) { + /* Initialize the NuttX power management subsystem proper */ + + pm_initialize(); } #endif /* CONFIG_PM */ diff --git a/arch/arm/src/stm32/stm32_sdio.c b/arch/arm/src/stm32/stm32_sdio.c index c25dddcb6c286..fbf68cee39b22 100644 --- a/arch/arm/src/stm32/stm32_sdio.c +++ b/arch/arm/src/stm32/stm32_sdio.c @@ -3006,7 +3006,7 @@ static void stm32_callback(void *arg) mcinfo("Queuing callback to %p(%p)\n", priv->callback, priv->cbarg); - work_queue(HPWORK, &priv->cbwork, (worker_t)priv->callback, + work_queue(HPWORK, &priv->cbwork, priv->callback, priv->cbarg, 0); } else diff --git a/arch/arm/src/stm32/stm32_start.c b/arch/arm/src/stm32/stm32_start.c index 7e0b52543a1db..a49f84af2448b 100644 --- a/arch/arm/src/stm32/stm32_start.c +++ b/arch/arm/src/stm32/stm32_start.c @@ -67,14 +67,6 @@ const uintptr_t g_idle_topstack = HEAP_BASE; -/**************************************************************************** - * Private Function prototypes - ****************************************************************************/ - -#ifdef CONFIG_ARCH_FPU -static inline void stm32_fpuconfig(void); -#endif - /**************************************************************************** * Private Functions ****************************************************************************/ @@ -103,96 +95,6 @@ static inline void stm32_fpuconfig(void); void __start(void) noinstrument_function; #endif -/**************************************************************************** - * Name: stm32_fpuconfig - * - * Description: - * Configure the FPU. Relative bit settings: - * - * CPACR: Enables access to CP10 and CP11 - * CONTROL.FPCA: Determines whether the FP extension is active in the - * current context: - * FPCCR.ASPEN: Enables automatic FP state preservation, then the - * processor sets this bit to 1 on successful completion of any FP - * instruction. - * FPCCR.LSPEN: Enables lazy context save of FP state. When this is - * done, the processor reserves space on the stack for the FP state, - * but does not save that state information to the stack. - * - * Software must not change the value of the ASPEN bit or LSPEN bit either: - * - the CPACR permits access to CP10 and CP11, that give access to the FP - * extension, or - * - the CONTROL.FPCA bit is set to 1 - * - ****************************************************************************/ - -#ifdef CONFIG_ARCH_FPU -#ifndef CONFIG_ARMV7M_LAZYFPU - -static inline void stm32_fpuconfig(void) -{ - uint32_t regval; - - /* Set CONTROL.FPCA so that we always get the extended context frame - * with the volatile FP registers stacked above the basic context. - */ - - regval = getcontrol(); - regval |= CONTROL_FPCA; - setcontrol(regval); - - /* Ensure that FPCCR.LSPEN is disabled, so that we don't have to contend - * with the lazy FP context save behaviour. Clear FPCCR.ASPEN since we - * are going to turn on CONTROL.FPCA for all contexts. - */ - - regval = getreg32(NVIC_FPCCR); - regval &= ~(NVIC_FPCCR_ASPEN | NVIC_FPCCR_LSPEN); - putreg32(regval, NVIC_FPCCR); - - /* Enable full access to CP10 and CP11 */ - - regval = getreg32(NVIC_CPACR); - regval |= NVIC_CPACR_CP_FULL(10) | NVIC_CPACR_CP_FULL(11); - putreg32(regval, NVIC_CPACR); -} - -#else - -static inline void stm32_fpuconfig(void) -{ - uint32_t regval; - - /* Clear CONTROL.FPCA so that we do not get the extended context frame - * with the volatile FP registers stacked in the saved context. - */ - - regval = getcontrol(); - regval &= ~CONTROL_FPCA; - setcontrol(regval); - - /* Ensure that FPCCR.LSPEN is disabled, so that we don't have to contend - * with the lazy FP context save behaviour. Clear FPCCR.ASPEN since we - * are going to keep CONTROL.FPCA off for all contexts. - */ - - regval = getreg32(NVIC_FPCCR); - regval &= ~(NVIC_FPCCR_ASPEN | NVIC_FPCCR_LSPEN); - putreg32(regval, NVIC_FPCCR); - - /* Enable full access to CP10 and CP11 */ - - regval = getreg32(NVIC_CPACR); - regval |= NVIC_CPACR_CP_FULL(10) | NVIC_CPACR_CP_FULL(11); - putreg32(regval, NVIC_CPACR); -} - -#endif - -#else -# define stm32_fpuconfig() -#endif - /**************************************************************************** * Public Functions ****************************************************************************/ @@ -224,7 +126,7 @@ void __start(void) /* Configure the UART so that we can get debug output as soon as possible */ stm32_clockconfig(); - stm32_fpuconfig(); + arm_fpuconfig(); stm32_lowsetup(); stm32_gpioinit(); showprogress('A'); diff --git a/arch/arm/src/stm32f0l0g0/Make.defs b/arch/arm/src/stm32f0l0g0/Make.defs index 5319822710e36..2b63457ada06b 100644 --- a/arch/arm/src/stm32f0l0g0/Make.defs +++ b/arch/arm/src/stm32f0l0g0/Make.defs @@ -18,32 +18,7 @@ # ############################################################################ -CMN_ASRCS = arm_exception.S arm_saveusercontext.S arm_fullcontextrestore.S -CMN_ASRCS += vfork.S - -CMN_CSRCS = arm_allocateheap.c arm_assert.c arm_blocktask.c -CMN_CSRCS += arm_createstack.c arm_mdelay.c arm_udelay.c arm_exit.c -CMN_CSRCS += arm_initialize.c arm_initialstate.c arm_interruptcontext.c -CMN_CSRCS += arm_puts.c arm_modifyreg8.c arm_modifyreg16.c arm_modifyreg32.c -CMN_CSRCS += arm_releasepending.c arm_releasestack.c arm_reprioritizertr.c -CMN_CSRCS += arm_schedulesigaction.c arm_sigdeliver.c arm_stackframe.c -CMN_CSRCS += arm_systemreset.c arm_unblocktask.c arm_usestack.c arm_doirq.c -CMN_CSRCS += arm_hardfault.c arm_svcall.c arm_vectors.c arm_vfork.c -CMN_CSRCS += arm_switchcontext.c arm_tcbinfo.c - -ifeq ($(CONFIG_BUILD_PROTECTED),y) -CMN_CSRCS += arm_task_start.c arm_pthread_start.c -CMN_CSRCS += arm_signal_dispatch.c -CMN_UASRCS += arm_signal_handler.S -endif - -ifeq ($(CONFIG_STACK_COLORATION),y) -CMN_CSRCS += arm_checkstack.c -endif - -ifeq ($(CONFIG_DEBUG_FEATURES),y) -CMN_CSRCS += arm_dumpnvic.c -endif +include armv6-m/Make.defs CHIP_CSRCS = stm32_start.c stm32_gpio.c stm32_exti_gpio.c stm32_irq.c CHIP_CSRCS += stm32_lse.c stm32_lowputc.c stm32_serial.c stm32_rcc.c diff --git a/arch/arm/src/stm32f7/Make.defs b/arch/arm/src/stm32f7/Make.defs index 77fe10a15a09d..7addd28371a27 100644 --- a/arch/arm/src/stm32f7/Make.defs +++ b/arch/arm/src/stm32f7/Make.defs @@ -23,63 +23,7 @@ # Common ARM and Cortex-M7 files -CMN_ASRCS = arm_saveusercontext.S arm_fullcontextrestore.S -CMN_ASRCS += arm_testset.S arm_fetchadd.S vfork.S - -CMN_CSRCS = arm_assert.c arm_blocktask.c arm_createstack.c -CMN_CSRCS += arm_doirq.c arm_exit.c arm_hardfault.c arm_initialize.c -CMN_CSRCS += arm_initialstate.c arm_interruptcontext.c arm_mdelay.c -CMN_CSRCS += arm_memfault.c arm_modifyreg8.c arm_modifyreg16.c arm_modifyreg32.c -CMN_CSRCS += arm_releasepending.c arm_releasestack.c arm_reprioritizertr.c -CMN_CSRCS += arm_schedulesigaction.c arm_sigdeliver.c arm_stackframe.c -CMN_CSRCS += arm_svcall.c arm_systemreset.c arm_trigger_irq.c arm_unblocktask.c -CMN_CSRCS += arm_udelay.c arm_usestack.c arm_vfork.c arm_switchcontext.c arm_puts.c -CMN_CSRCS += arm_tcbinfo.c - -ifneq ($(CONFIG_ARCH_IDLE_CUSTOM),y) -CMN_CSRCS += arm_idle.c -endif - -ifeq ($(CONFIG_ARMV7M_STACKCHECK),y) -CMN_CSRCS += arm_stackcheck.c -endif - -# Configuration-dependent common files - -ifeq ($(CONFIG_ARMV7M_LAZYFPU),y) -CMN_ASRCS += arm_lazyexception.S -else -CMN_ASRCS += arm_exception.S -endif -CMN_CSRCS += arm_vectors.c - -CMN_CSRCS += arm_cache.c - -ifeq ($(CONFIG_ARCH_FPU),y) -CMN_ASRCS += arm_fpu.S -endif - -ifeq ($(CONFIG_ARCH_RAMVECTORS),y) -CMN_CSRCS += arm_ramvec_initialize.c arm_ramvec_attach.c -endif - -ifeq ($(CONFIG_ARMV7M_ITMSYSLOG),y) -CMN_CSRCS += arm_itm_syslog.c -endif - -ifneq ($(filter y,$(CONFIG_ARM_MPU) $(CONFIG_ARM_MPU_EARLY_RESET)),) -CMN_CSRCS += arm_mpu.c -endif - -ifeq ($(CONFIG_BUILD_PROTECTED),y) -CMN_CSRCS += arm_task_start.c arm_pthread_start.c -CMN_CSRCS += arm_signal_dispatch.c -CMN_UASRCS += arm_signal_handler.S -endif - -ifeq ($(CONFIG_STACK_COLORATION),y) -CMN_CSRCS += arm_checkstack.c -endif +include armv7-m/Make.defs # Required STM32F7 files diff --git a/arch/arm/src/stm32f7/stm32_bbsram.c b/arch/arm/src/stm32f7/stm32_bbsram.c index 1239ae5c049e4..9c6bb80914ccb 100644 --- a/arch/arm/src/stm32f7/stm32_bbsram.c +++ b/arch/arm/src/stm32f7/stm32_bbsram.c @@ -140,7 +140,7 @@ static const struct file_operations stm32_bbsram_fops = .ioctl = stm32_bbsram_ioctl, .poll = stm32_bbsram_poll, #ifndef CONFIG_DISABLE_PSEUDOFS_OPERATIONS - .unlink = stm32_bbsram_unlink, + .unlink = stm32_bbsram_unlink #endif }; diff --git a/arch/arm/src/stm32f7/stm32_ltdc.c b/arch/arm/src/stm32f7/stm32_ltdc.c index 890318689d240..16b6f4b530875 100644 --- a/arch/arm/src/stm32f7/stm32_ltdc.c +++ b/arch/arm/src/stm32f7/stm32_ltdc.c @@ -1283,9 +1283,11 @@ static void stm32_ltdc_periphconfig(void) reginfo("configured RCC_PLLSAI=%08x\n", getreg32(STM32_RCC_PLLSAICFGR)); - /* Configure dedicated clock external */ + /* Configure dedicated clock external. + * Division factor for LCD_CLK in DCKCFGR1 + */ - reginfo("configured RCC_DCKCFGR=%08x\n", getreg32(STM32_RCC_DCKCFGR)); + reginfo("configured RCC_DCKCFGR1=%08x\n", getreg32(STM32_RCC_DCKCFGR1)); /* Configure LTDC_SSCR */ diff --git a/arch/arm/src/stm32f7/stm32_otghost.c b/arch/arm/src/stm32f7/stm32_otghost.c index e19fb9bbdad49..2eb621b36d7ff 100644 --- a/arch/arm/src/stm32f7/stm32_otghost.c +++ b/arch/arm/src/stm32f7/stm32_otghost.c @@ -423,7 +423,7 @@ static int stm32_ep0configure(FAR struct usbhost_driver_s *drvr, usbhost_ep_t ep0, uint8_t funcaddr, uint8_t speed, uint16_t maxpacketsize); static int stm32_epalloc(FAR struct usbhost_driver_s *drvr, - FAR const FAR struct usbhost_epdesc_s *epdesc, + FAR const struct usbhost_epdesc_s *epdesc, FAR usbhost_ep_t *ep); static int stm32_epfree(FAR struct usbhost_driver_s *drvr, usbhost_ep_t ep); static int stm32_alloc(FAR struct usbhost_driver_s *drvr, diff --git a/arch/arm/src/stm32f7/stm32_pminitialize.c b/arch/arm/src/stm32f7/stm32_pminitialize.c index 90d44f1a38b99..ac9bd0dc58349 100644 --- a/arch/arm/src/stm32f7/stm32_pminitialize.c +++ b/arch/arm/src/stm32f7/stm32_pminitialize.c @@ -23,6 +23,7 @@ ****************************************************************************/ #include +#include #include "arm_internal.h" #include "stm32_pm.h" @@ -53,6 +54,9 @@ void arm_pminitialize(void) { + /* Initialize the NuttX power management subsystem proper */ + + pm_initialize(); } #endif /* CONFIG_PM */ diff --git a/arch/arm/src/stm32f7/stm32_sdmmc.c b/arch/arm/src/stm32f7/stm32_sdmmc.c index 7237a8d347ef1..21bbb9e6d2822 100644 --- a/arch/arm/src/stm32f7/stm32_sdmmc.c +++ b/arch/arm/src/stm32f7/stm32_sdmmc.c @@ -3294,7 +3294,7 @@ static void stm32_callback(void *arg) mcinfo("Queuing callback to %p(%p)\n", priv->callback, priv->cbarg); - work_queue(HPWORK, &priv->cbwork, (worker_t)priv->callback, + work_queue(HPWORK, &priv->cbwork, priv->callback, priv->cbarg, 0); } else diff --git a/arch/arm/src/stm32f7/stm32_start.c b/arch/arm/src/stm32f7/stm32_start.c index 159e2d2eca9a5..f52fd3ea6f3de 100644 --- a/arch/arm/src/stm32f7/stm32_start.c +++ b/arch/arm/src/stm32f7/stm32_start.c @@ -79,14 +79,6 @@ const uintptr_t g_idle_topstack = HEAP_BASE; -/**************************************************************************** - * Private Function prototypes - ****************************************************************************/ - -#ifdef CONFIG_ARCH_FPU -static inline void stm32_fpuconfig(void); -#endif - /**************************************************************************** * Private Functions ****************************************************************************/ @@ -97,96 +89,6 @@ static inline void stm32_fpuconfig(void); void __start(void) noinstrument_function; #endif -/**************************************************************************** - * Name: stm32_fpuconfig - * - * Description: - * Configure the FPU. Relative bit settings: - * - * CPACR: Enables access to CP10 and CP11 - * CONTROL.FPCA: Determines whether the FP extension is active in the - * current context: - * FPCCR.ASPEN: Enables automatic FP state preservation, then the - * processor sets this bit to 1 on successful completion of any FP - * instruction. - * FPCCR.LSPEN: Enables lazy context save of FP state. When this is - * done, the processor reserves space on the stack for the FP state, - * but does not save that state information to the stack. - * - * Software must not change the value of the ASPEN bit or LSPEN bit either: - * - the CPACR permits access to CP10 and CP11, that give access to the FP - * extension, or - * - the CONTROL.FPCA bit is set to 1 - * - ****************************************************************************/ - -#ifdef CONFIG_ARCH_FPU -#ifndef CONFIG_ARMV7M_LAZYFPU - -static inline void stm32_fpuconfig(void) -{ - uint32_t regval; - - /* Set CONTROL.FPCA so that we always get the extended context frame - * with the volatile FP registers stacked above the basic context. - */ - - regval = getcontrol(); - regval |= CONTROL_FPCA; - setcontrol(regval); - - /* Ensure that FPCCR.LSPEN is disabled, so that we don't have to contend - * with the lazy FP context save behaviour. Clear FPCCR.ASPEN since we - * are going to turn on CONTROL.FPCA for all contexts. - */ - - regval = getreg32(NVIC_FPCCR); - regval &= ~(NVIC_FPCCR_ASPEN | NVIC_FPCCR_LSPEN); - putreg32(regval, NVIC_FPCCR); - - /* Enable full access to CP10 and CP11 */ - - regval = getreg32(NVIC_CPACR); - regval |= NVIC_CPACR_CP_FULL(10) | NVIC_CPACR_CP_FULL(11); - putreg32(regval, NVIC_CPACR); -} - -#else - -static inline void stm32_fpuconfig(void) -{ - uint32_t regval; - - /* Clear CONTROL.FPCA so that we do not get the extended context frame - * with the volatile FP registers stacked in the saved context. - */ - - regval = getcontrol(); - regval &= ~CONTROL_FPCA; - setcontrol(regval); - - /* Ensure that FPCCR.LSPEN is disabled, so that we don't have to contend - * with the lazy FP context save behaviour. Clear FPCCR.ASPEN since we - * are going to keep CONTROL.FPCA off for all contexts. - */ - - regval = getreg32(NVIC_FPCCR); - regval &= ~(NVIC_FPCCR_ASPEN | NVIC_FPCCR_LSPEN); - putreg32(regval, NVIC_FPCCR); - - /* Enable full access to CP10 and CP11 */ - - regval = getreg32(NVIC_CPACR); - regval |= NVIC_CPACR_CP_FULL(10) | NVIC_CPACR_CP_FULL(11); - putreg32(regval, NVIC_CPACR); -} - -#endif - -#else -# define stm32_fpuconfig() -#endif - /**************************************************************************** * Name: stm32_tcmenable * @@ -302,7 +204,7 @@ void __start(void) /* Configure the UART so that we can get debug output as soon as possible */ stm32_clockconfig(); - stm32_fpuconfig(); + arm_fpuconfig(); stm32_lowsetup(); /* Enable/disable tightly coupled memories */ diff --git a/arch/arm/src/stm32h7/Make.defs b/arch/arm/src/stm32h7/Make.defs index 2092016cbe068..643f8c2e150c6 100644 --- a/arch/arm/src/stm32h7/Make.defs +++ b/arch/arm/src/stm32h7/Make.defs @@ -23,70 +23,15 @@ # Common ARM and Cortex-M7 files -CMN_ASRCS = arm_saveusercontext.S arm_fullcontextrestore.S -CMN_ASRCS += arm_testset.S vfork.S - -CMN_CSRCS = arm_assert.c arm_blocktask.c arm_createstack.c -CMN_CSRCS += arm_doirq.c arm_exit.c arm_hardfault.c arm_initialize.c -CMN_CSRCS += arm_initialstate.c arm_interruptcontext.c arm_mdelay.c arm_memfault.c -CMN_CSRCS += arm_modifyreg8.c arm_modifyreg16.c arm_modifyreg32.c -CMN_CSRCS += arm_releasepending.c arm_releasestack.c arm_reprioritizertr.c -CMN_CSRCS += arm_schedulesigaction.c arm_sigdeliver.c arm_stackframe.c arm_svcall.c -CMN_CSRCS += arm_systemreset.c arm_trigger_irq.c arm_udelay.c arm_unblocktask.c -CMN_CSRCS += arm_usestack.c arm_vfork.c arm_switchcontext.c arm_puts.c -CMN_CSRCS += arm_tcbinfo.c - -ifeq ($(CONFIG_ARMV7M_SYSTICK),y) -CMN_CSRCS += arm_systick.c -endif - -# Configuration-dependent common files - -ifeq ($(CONFIG_ARMV7M_STACKCHECK),y) -CMN_CSRCS += arm_stackcheck.c -endif - -ifeq ($(CONFIG_ARMV7M_LAZYFPU),y) -CMN_ASRCS += arm_lazyexception.S -else -CMN_ASRCS += arm_exception.S -endif -CMN_CSRCS += arm_vectors.c - -CMN_CSRCS += arm_cache.c -ifeq ($(CONFIG_ARCH_FPU),y) -CMN_ASRCS += arm_fpu.S -endif - -ifneq ($(CONFIG_ARCH_IDLE_CUSTOM),y) -CMN_CSRCS += arm_idle.c -endif - -ifeq ($(CONFIG_ARCH_RAMVECTORS),y) -CMN_CSRCS += arm_ramvec_initialize.c arm_ramvec_attach.c -endif +include armv7-m/Make.defs ifeq ($(CONFIG_STM32H7_PROGMEM),y) -CMN_CSRCS += stm32_flash.c -endif - -ifneq ($(filter y,$(CONFIG_ARM_MPU) $(CONFIG_ARM_MPU_EARLY_RESET)),) -CMN_CSRCS += arm_mpu.c -endif - -ifeq ($(CONFIG_BUILD_PROTECTED),y) -CMN_CSRCS += arm_task_start.c arm_pthread_start.c -CMN_CSRCS += arm_signal_dispatch.c -CMN_UASRCS += arm_signal_handler.S -endif - -ifeq ($(CONFIG_STACK_COLORATION),y) -CMN_CSRCS += arm_checkstack.c +CHIP_CSRCS += stm32_flash.c endif # Required STM32H7 files -CHIP_CSRCS = stm32_allocateheap.c stm32_exti_gpio.c stm32_gpio.c stm32_irq.c +CHIP_CSRCS += stm32_allocateheap.c stm32_exti_gpio.c stm32_gpio.c stm32_irq.c CHIP_CSRCS += stm32_start.c stm32_rcc.c stm32_lowputc.c stm32_serial.c CHIP_CSRCS += stm32_uid.c diff --git a/arch/arm/src/stm32h7/stm32_bbsram.c b/arch/arm/src/stm32h7/stm32_bbsram.c index f25557bd624c1..4491abd35748d 100644 --- a/arch/arm/src/stm32h7/stm32_bbsram.c +++ b/arch/arm/src/stm32h7/stm32_bbsram.c @@ -161,7 +161,7 @@ static const struct file_operations stm32_bbsram_fops = .ioctl = stm32_bbsram_ioctl, .poll = stm32_bbsram_poll, #ifndef CONFIG_DISABLE_PSEUDOFS_OPERATIONS - .unlink = stm32_bbsram_unlink, + .unlink = stm32_bbsram_unlink #endif }; diff --git a/arch/arm/src/stm32h7/stm32_otghost.c b/arch/arm/src/stm32h7/stm32_otghost.c index fcee622b15797..a0f5c2ffcdbb4 100644 --- a/arch/arm/src/stm32h7/stm32_otghost.c +++ b/arch/arm/src/stm32h7/stm32_otghost.c @@ -426,7 +426,7 @@ static int stm32_ep0configure(FAR struct usbhost_driver_s *drvr, usbhost_ep_t ep0, uint8_t funcaddr, uint8_t speed, uint16_t maxpacketsize); static int stm32_epalloc(FAR struct usbhost_driver_s *drvr, - FAR const FAR struct usbhost_epdesc_s *epdesc, + FAR const struct usbhost_epdesc_s *epdesc, FAR usbhost_ep_t *ep); static int stm32_epfree(FAR struct usbhost_driver_s *drvr, usbhost_ep_t ep); static int stm32_alloc(FAR struct usbhost_driver_s *drvr, diff --git a/arch/arm/src/stm32h7/stm32_pminitialize.c b/arch/arm/src/stm32h7/stm32_pminitialize.c index b0a8b110ca0dd..a457e72a0b39d 100644 --- a/arch/arm/src/stm32h7/stm32_pminitialize.c +++ b/arch/arm/src/stm32h7/stm32_pminitialize.c @@ -23,6 +23,7 @@ ****************************************************************************/ #include +#include #include "arm_internal.h" #include "stm32_pm.h" @@ -53,6 +54,9 @@ void arm_pminitialize(void) { + /* Initialize the NuttX power management subsystem proper */ + + pm_initialize(); } #endif /* CONFIG_PM */ diff --git a/arch/arm/src/stm32h7/stm32_qspi.c b/arch/arm/src/stm32h7/stm32_qspi.c index db08782c064d3..34f4a0a7ddc1f 100644 --- a/arch/arm/src/stm32h7/stm32_qspi.c +++ b/arch/arm/src/stm32h7/stm32_qspi.c @@ -497,10 +497,11 @@ static inline void qspi_putreg(struct stm32h7_qspidev_s *priv, #ifdef CONFIG_DEBUG_SPI_INFO static void qspi_dumpregs(struct stm32h7_qspidev_s *priv, const char *msg) { - uint32_t regval; spiinfo("%s:\n", msg); #if 0 + uint32_t regval; + /* this extra verbose output may be helpful in some cases; you'll need * to make sure your syslog is large enough to accommodate extra output. */ @@ -575,7 +576,6 @@ static void qspi_dumpregs(struct stm32h7_qspidev_s *priv, const char *msg) spiinfo(" PIR:%08x LPTR:%08x\n", getreg32(priv->base + STM32_QUADSPI_PIR_OFFSET), /* Polling Interval Register */ getreg32(priv->base + STM32_QUADSPI_LPTR_OFFSET)); /* Low-Power Timeout Register */ - (void)regval; #endif } #endif diff --git a/arch/arm/src/stm32h7/stm32_sdmmc.c b/arch/arm/src/stm32h7/stm32_sdmmc.c index 1f81d5605ad1c..929c720f59d7e 100644 --- a/arch/arm/src/stm32h7/stm32_sdmmc.c +++ b/arch/arm/src/stm32h7/stm32_sdmmc.c @@ -1609,7 +1609,7 @@ static void stm32_sdmmc_fifo_monitor(FAR void *arg) STM32_SDMMC_STA_DPSMACT) { work_queue(HPWORK, &priv->cbfifo, - (worker_t)stm32_sdmmc_fifo_monitor, arg, 1); + stm32_sdmmc_fifo_monitor, arg, 1); } } #endif @@ -1696,7 +1696,7 @@ static int stm32_sdmmc_interrupt(int irq, void *context, void *arg) stm32_recvfifo(priv); work_queue(HPWORK, &priv->cbfifo, - (worker_t)stm32_sdmmc_fifo_monitor, arg, 1); + stm32_sdmmc_fifo_monitor, arg, 1); } /* Otherwise, Is the transmit FIFO half empty or less? If so @@ -3402,7 +3402,7 @@ static void stm32_callback(void *arg) mcinfo("Queuing callback to %p(%p)\n", priv->callback, priv->cbarg); - work_queue(HPWORK, &priv->cbwork, (worker_t)priv->callback, + work_queue(HPWORK, &priv->cbwork, priv->callback, priv->cbarg, 0); } else diff --git a/arch/arm/src/stm32h7/stm32_spi_slave.c b/arch/arm/src/stm32h7/stm32_spi_slave.c index 1a5b3c3fe90ef..ff6a6e5d29b0a 100644 --- a/arch/arm/src/stm32h7/stm32_spi_slave.c +++ b/arch/arm/src/stm32h7/stm32_spi_slave.c @@ -921,7 +921,7 @@ static int spi_lock(FAR struct spi_slave_ctrlr_s *ctrlr, bool lock) } else { - (void)nxsem_post(&priv->exclsem); + nxsem_post(&priv->exclsem); ret = OK; } @@ -1156,8 +1156,8 @@ static void spi_bind(struct spi_slave_ctrlr_s *ctrlr, /* Bind to NSS interrupt */ - (void)stm32_gpiosetevent(priv->nss_pin, false, true, false, - spi_nssinterrupt, priv); + stm32_gpiosetevent(priv->nss_pin, false, true, false, + spi_nssinterrupt, priv); #ifdef CONFIG_PM /* Register to receive power management callbacks */ @@ -1196,15 +1196,15 @@ static int spi_nssinterrupt(int irq, void *context, void *arg) { /* Bind to NSS rising edge interrupt */ - (void)stm32_gpiosetevent(priv->nss_pin, true, false, false, - spi_nssinterrupt, priv); + stm32_gpiosetevent(priv->nss_pin, true, false, false, + spi_nssinterrupt, priv); return OK; } /* Disable NSS interrupt */ - (void)stm32_gpiosetevent(priv->nss_pin, false, false, false, - NULL, priv); + stm32_gpiosetevent(priv->nss_pin, false, false, false, + NULL, priv); /* Re-configure nss pin */ diff --git a/arch/arm/src/stm32h7/stm32_start.c b/arch/arm/src/stm32h7/stm32_start.c index a8732f7eda921..b94529447357f 100644 --- a/arch/arm/src/stm32h7/stm32_start.c +++ b/arch/arm/src/stm32h7/stm32_start.c @@ -84,10 +84,6 @@ const uintptr_t g_idle_topstack = HEAP_BASE; * Private Function prototypes ****************************************************************************/ -#ifdef CONFIG_ARCH_FPU -static inline void stm32_fpuconfig(void); -#endif - /**************************************************************************** * Name: showprogress * @@ -112,96 +108,6 @@ static inline void stm32_fpuconfig(void); void __start(void) noinstrument_function; #endif -/**************************************************************************** - * Name: stm32_fpuconfig - * - * Description: - * Configure the FPU. Relative bit settings: - * - * CPACR: Enables access to CP10 and CP11 - * CONTROL.FPCA: Determines whether the FP extension is active in the - * current context: - * FPCCR.ASPEN: Enables automatic FP state preservation, then the - * processor sets this bit to 1 on successful completion of any FP - * instruction. - * FPCCR.LSPEN: Enables lazy context save of FP state. When this is - * done, the processor reserves space on the stack for the FP state, - * but does not save that state information to the stack. - * - * Software must not change the value of the ASPEN bit or LSPEN bit either: - * - the CPACR permits access to CP10 and CP11, that give access to the FP - * extension, or - * - the CONTROL.FPCA bit is set to 1 - * - ****************************************************************************/ - -#ifdef CONFIG_ARCH_FPU -#ifndef CONFIG_ARMV7M_LAZYFPU - -static inline void stm32_fpuconfig(void) -{ - uint32_t regval; - - /* Set CONTROL.FPCA so that we always get the extended context frame - * with the volatile FP registers stacked above the basic context. - */ - - regval = getcontrol(); - regval |= CONTROL_FPCA; - setcontrol(regval); - - /* Ensure that FPCCR.LSPEN is disabled, so that we don't have to contend - * with the lazy FP context save behaviour. Clear FPCCR.ASPEN since we - * are going to turn on CONTROL.FPCA for all contexts. - */ - - regval = getreg32(NVIC_FPCCR); - regval &= ~(NVIC_FPCCR_ASPEN | NVIC_FPCCR_LSPEN); - putreg32(regval, NVIC_FPCCR); - - /* Enable full access to CP10 and CP11 */ - - regval = getreg32(NVIC_CPACR); - regval |= NVIC_CPACR_CP_FULL(10) | NVIC_CPACR_CP_FULL(11); - putreg32(regval, NVIC_CPACR); -} - -#else - -static inline void stm32_fpuconfig(void) -{ - uint32_t regval; - - /* Clear CONTROL.FPCA so that we do not get the extended context frame - * with the volatile FP registers stacked in the saved context. - */ - - regval = getcontrol(); - regval &= ~CONTROL_FPCA; - setcontrol(regval); - - /* Ensure that FPCCR.LSPEN is disabled, so that we don't have to contend - * with the lazy FP context save behaviour. Clear FPCCR.ASPEN since we - * are going to keep CONTROL.FPCA off for all contexts. - */ - - regval = getreg32(NVIC_FPCCR); - regval &= ~(NVIC_FPCCR_ASPEN | NVIC_FPCCR_LSPEN); - putreg32(regval, NVIC_FPCCR); - - /* Enable full access to CP10 and CP11 */ - - regval = getreg32(NVIC_CPACR); - regval |= NVIC_CPACR_CP_FULL(10) | NVIC_CPACR_CP_FULL(11); - putreg32(regval, NVIC_CPACR); -} - -#endif - -#else -# define stm32_fpuconfig() -#endif - /**************************************************************************** * Name: stm32_tcmenable * @@ -317,7 +223,7 @@ void __start(void) /* Configure the UART so that we can get debug output as soon as possible */ stm32_clockconfig(); - stm32_fpuconfig(); + arm_fpuconfig(); stm32_lowsetup(); showprogress('A'); diff --git a/arch/arm/src/stm32l4/Make.defs b/arch/arm/src/stm32l4/Make.defs index 6ab6da421a6b5..72120d951d8bd 100644 --- a/arch/arm/src/stm32l4/Make.defs +++ b/arch/arm/src/stm32l4/Make.defs @@ -23,53 +23,7 @@ # Common ARM and Cortex-M4 files (copied from stm32/Make.defs) -CMN_ASRCS = arm_saveusercontext.S arm_fullcontextrestore.S -CMN_ASRCS += arm_testset.S arm_fetchadd.S vfork.S - -CMN_CSRCS = arm_assert.c arm_blocktask.c arm_createstack.c -CMN_CSRCS += arm_doirq.c arm_exit.c arm_hardfault.c arm_initialize.c -CMN_CSRCS += arm_initialstate.c arm_interruptcontext.c arm_mdelay.c arm_memfault.c -CMN_CSRCS += arm_modifyreg8.c arm_modifyreg16.c arm_modifyreg32.c -CMN_CSRCS += arm_releasepending.c arm_releasestack.c arm_reprioritizertr.c -CMN_CSRCS += arm_schedulesigaction.c arm_sigdeliver.c arm_stackframe.c -CMN_CSRCS += arm_svcall.c arm_systemreset.c arm_trigger_irq.c arm_udelay.c -CMN_CSRCS += arm_unblocktask.c arm_usestack.c arm_vfork.c arm_switchcontext.c -CMN_CSRCS += arm_puts.c arm_tcbinfo.c - -# Configuration-dependent common files - -ifeq ($(CONFIG_ARMV7M_STACKCHECK),y) -CMN_CSRCS += arm_stackcheck.c -endif - -ifeq ($(CONFIG_ARMV7M_LAZYFPU),y) -CMN_ASRCS += arm_lazyexception.S -else -CMN_ASRCS += arm_exception.S -endif -CMN_CSRCS += arm_vectors.c - -ifeq ($(CONFIG_ARCH_FPU),y) -CMN_ASRCS += arm_fpu.S -endif - -ifeq ($(CONFIG_ARCH_RAMVECTORS),y) -CMN_CSRCS += arm_ramvec_initialize.c arm_ramvec_attach.c -endif - -ifeq ($(CONFIG_ARM_MPU),y) -CMN_CSRCS += arm_mpu.c -endif - -ifeq ($(CONFIG_BUILD_PROTECTED),y) -CMN_CSRCS += arm_task_start.c arm_pthread_start.c -CMN_CSRCS += arm_signal_dispatch.c -CMN_UASRCS += arm_signal_handler.S -endif - -ifeq ($(CONFIG_STACK_COLORATION),y) -CMN_CSRCS += arm_checkstack.c -endif +include armv7-m/Make.defs # Required STM32L4 files diff --git a/arch/arm/src/stm32l4/hardware/stm32l4_flash.h b/arch/arm/src/stm32l4/hardware/stm32l4_flash.h index 22973a5003ef0..64cb63516fb59 100644 --- a/arch/arm/src/stm32l4/hardware/stm32l4_flash.h +++ b/arch/arm/src/stm32l4/hardware/stm32l4_flash.h @@ -243,7 +243,7 @@ #endif #define FLASH_CR_START (1 << 16) /* Bit 16: Start Erase */ #define FLASH_CR_OPTSTRT (1 << 17) /* Bit 17: Options modification Start */ -#define FLASH_CR_FSTPG (1 << 23) /* Bit 23: Fast programming */ +#define FLASH_CR_FSTPG (1 << 18) /* Bit 18: Fast programming */ #define FLASH_CR_EOPIE (1 << 24) /* Bit 24: End of operation interrupt enable */ #define FLASH_CR_ERRIE (1 << 25) /* Bit 25: Error interrupt enable */ #define FLASH_CR_RDERRIE (1 << 26) /* Bit 26: PCROP read error interrupt enable */ @@ -253,7 +253,7 @@ /* Flash ECC Register (ECCR) */ -#define FLASH_ECCR_ADDR_ECC_SHIFT (0) /* Bits 8-15: Read protect */ +#define FLASH_ECCR_ADDR_ECC_SHIFT (0) /* Bits 0-18: ECC fail address */ #define FLASH_ECCR_ADDR_ECC_MASK (0x07ffff << FLASH_ECCR_ADDR_ECC_SHIFT) #if defined(CONFIG_STM32L4_STM32L4X5) || defined(CONFIG_STM32L4_STM32L4X6) || \ defined(CONFIG_STM32L4_STM32L4XR) diff --git a/arch/arm/src/stm32l4/hardware/stm32l4_rtcc.h b/arch/arm/src/stm32l4/hardware/stm32l4_rtcc.h index aa04f2ad7df63..9c10c13539095 100644 --- a/arch/arm/src/stm32l4/hardware/stm32l4_rtcc.h +++ b/arch/arm/src/stm32l4/hardware/stm32l4_rtcc.h @@ -366,7 +366,7 @@ #define RTC_TAMPCR_TAMPPUDIS (1 << 15) /* Bit 15: RTC_TAMPx pull-up disable */ #define RTC_TAMPCR_TAMP1IE (1 << 16) /* Bit 16: RTC_TAMP1 interrupt enable */ #define RTC_TAMPCR_TAMP1NOERASE (1 << 17) /* Bit 17: RTC_TAMP1 no erase */ -#define RTC_TAMPCR_TAMP1F (1 << 18) /* Bit 18: RTC_TAMP1 mask flag */ +#define RTC_TAMPCR_TAMP1MF (1 << 18) /* Bit 18: RTC_TAMP1 mask flag */ #define RTC_TAMPCR_TAMP2IE (1 << 19) /* Bit 19: RTC_TAMP2 interrupt enable */ #define RTC_TAMPCR_TAMP2NOERASE (1 << 20) /* Bit 20: RTC_TAMP2 no erase */ #define RTC_TAMPCR_TAMP2MF (1 << 21) /* Bit 21: RTC_TAMP2 mask flag */ @@ -383,7 +383,7 @@ /* RTC option register */ -#define RTC_OR_ALARMTYPE (1 << 0) /* Bit 0: RTC alarm type on PC13/PB14, pushpull/OD */ -#define RTC_OR_OUTRMP (1 << 1) /* Bit 1: remap output to PB14 */ +#define RTC_OR_ALARMTYPE (1 << 0) /* Bit 0: RTC alarm type on PC13, pushpull/OD */ +#define RTC_OR_OUTRMP (1 << 1) /* Bit 1: remap output to PB2 */ #endif /* __ARCH_ARM_SRC_STM32L4_HARDWARE_STM32L4_RTCC_H */ diff --git a/arch/arm/src/stm32l4/hardware/stm32l4_tim.h b/arch/arm/src/stm32l4/hardware/stm32l4_tim.h index 022f85b46a0ef..2e6e20c8158e8 100644 --- a/arch/arm/src/stm32l4/hardware/stm32l4_tim.h +++ b/arch/arm/src/stm32l4/hardware/stm32l4_tim.h @@ -362,14 +362,14 @@ #define ATIM_CR2_OIS3 (1 << 12) /* Bit 12: Output Idle state 3 (OC3 output) */ #define ATIM_CR2_OIS3N (1 << 13) /* Bit 13: Output Idle state 3 (OC3N output) */ #define ATIM_CR2_OIS4 (1 << 14) /* Bit 14: Output Idle state 4 (OC4 output) */ -#define ATIM_CR2_OIS5 (1 << 16) /* Bit 16: OOutput Idle state 5 (OC5 output) */ +#define ATIM_CR2_OIS5 (1 << 16) /* Bit 16: Output Idle state 5 (OC5 output) */ #define ATIM_CR2_OIS6 (1 << 18) /* Bit 18: Output Idle state 6 (OC6 output) */ #define ATIM_CR2_MMS2_SHIFT (20) /* Bits 20-23: Master Mode Selection 2 */ #define ATIM_CR2_MMS2_MASK (15 << ATIM_CR2_MMS2_SHIFT) # define ATIM_CR2_MMS2_RESET (0 << ATIM_CR2_MMS2_SHIFT) /* 0000: Reset - TIMx_EGR UG bit is TRG9 */ # define ATIM_CR2_MMS2_ENABLE (1 << ATIM_CR2_MMS2_SHIFT) /* 0001: Enable - CNT_EN is TRGO2 */ -# define ATIM_CR2_MMS2_UPDATE (2 << ATIM_CR2_MMS2_SHIFT) /* 0010: Update event is TRGH0*/ -# define ATIM_CR2_MMS2_COMPP (3 << ATIM_CR2_MMS2_SHIFT) /* 0010: Compare Pulse - CC1IF flag */ +# define ATIM_CR2_MMS2_UPDATE (2 << ATIM_CR2_MMS2_SHIFT) /* 0010: Update event is TRGO2 */ +# define ATIM_CR2_MMS2_COMPP (3 << ATIM_CR2_MMS2_SHIFT) /* 0011: Compare Pulse - CC1IF flag */ # define ATIM_CR2_MMS2_OC1REF (4 << ATIM_CR2_MMS2_SHIFT) /* 0100: Compare OC1REF is TRGO2 */ # define ATIM_CR2_MMS2_OC2REF (5 << ATIM_CR2_MMS2_SHIFT) /* 0101: Compare OC2REF is TRGO2 */ # define ATIM_CR2_MMS2_OC3REF (6 << ATIM_CR2_MMS2_SHIFT) /* 0110: Compare OC3REF is TRGO2 */ @@ -498,7 +498,7 @@ #define ATIM_CCMR1_OC1M_SHIFT (4) /* Bits 6-4: Output Compare 1 Mode */ #define ATIM_CCMR1_OC1M_MASK (7 << ATIM_CCMR1_OC1M_SHIFT) /* (See common (unshifted) bit field definitions below) */ -#define ATIM_CCMR1_OC1CE (1 << 7) /* Bit 7: Output Compare 1Clear Enable */ +#define ATIM_CCMR1_OC1CE (1 << 7) /* Bit 7: Output Compare 1 Clear Enable */ #define ATIM_CCMR1_CC2S_SHIFT (8) /* Bits 8-9: Capture/Compare 2 Selection */ #define ATIM_CCMR1_CC2S_MASK (3 << ATIM_CCMR1_CC2S_SHIFT) /* (See common (unshifted) bit field definitions below) */ @@ -528,6 +528,8 @@ #define ATIM_CCMR_MODE_OCREFHI (5) /* 101: OCxREF forced high */ #define ATIM_CCMR_MODE_PWM1 (6) /* 110: PWM mode 1 */ #define ATIM_CCMR_MODE_PWM2 (7) /* 111: PWM mode 2 */ +#define ATIM_CCMR_MODE_OPM1 (8) /* 1000: OPM mode 1 */ +#define ATIM_CCMR_MODE_OPM2 (9) /* 1001: OPM mode 2 */ #define ATIM_CCMR_MODE_COMBINED1 (12) /* 1100: Combined PWM mode 1 */ #define ATIM_CCMR_MODE_COMBINED2 (13) /* 1101: Combined PWM mode 2 */ #define ATIM_CCMR_MODE_ASYMMETRIC1 (14) /* 1110: Asymmetric PWM mode 1 */ @@ -705,8 +707,8 @@ # define ATIM_BDTR_BKF_FCKINT8 (3 << ATIM_BDTR_BKF_SHIFT) /* 0011: fSAMPLING=fCK_INT, N=8 */ # define ATIM_BDTR_BKF_FDTSd26 (4 << ATIM_BDTR_BKF_SHIFT) /* 0100: fSAMPLING=fDTS/2, N=6 */ # define ATIM_BDTR_BKF_FDTSd28 (5 << ATIM_BDTR_BKF_SHIFT) /* 0101: fSAMPLING=fDTS/2, N=8 */ -# define ATIM_BDTR_BKF_FDTSd36 (6 << ATIM_BDTR_BKF_SHIFT) /* 0110: fSAMPLING=fDTS/4, N=6 */ -# define ATIM_BDTR_BKF_FDTSd38 (7 << ATIM_BDTR_BKF_SHIFT) /* 0111: fSAMPLING=fDTS/4, N=8 */ +# define ATIM_BDTR_BKF_FDTSd46 (6 << ATIM_BDTR_BKF_SHIFT) /* 0110: fSAMPLING=fDTS/4, N=6 */ +# define ATIM_BDTR_BKF_FDTSd48 (7 << ATIM_BDTR_BKF_SHIFT) /* 0111: fSAMPLING=fDTS/4, N=8 */ # define ATIM_BDTR_BKF_FDTSd86 (8 << ATIM_BDTR_BKF_SHIFT) /* 1000: fSAMPLING=fDTS/8, N=6 */ # define ATIM_BDTR_BKF_FDTSd88 (9 << ATIM_BDTR_BKF_SHIFT) /* 1001: fSAMPLING=fDTS/8, N=8 */ # define ATIM_BDTR_BKF_FDTSd165 (10 << ATIM_BDTR_BKF_SHIFT) /* 1010: fSAMPLING=fDTS/16, N=5 */ @@ -724,8 +726,8 @@ # define ATIM_BDTR_BK2F_FCKINT8 (3 << ATIM_BDTR_BK2F_SHIFT) /* 0011: fSAMPLING=fCK_INT, N=8 */ # define ATIM_BDTR_BK2F_FDTSd26 (4 << ATIM_BDTR_BK2F_SHIFT) /* 0100: fSAMPLING=fDTS/2, N=6 */ # define ATIM_BDTR_BK2F_FDTSd28 (5 << ATIM_BDTR_BK2F_SHIFT) /* 0101: fSAMPLING=fDTS/2, N=8 */ -# define ATIM_BDTR_BK2F_FDTSd36 (6 << ATIM_BDTR_BK2F_SHIFT) /* 0110: fSAMPLING=fDTS/4, N=6 */ -# define ATIM_BDTR_BK2F_FDTSd38 (7 << ATIM_BDTR_BK2F_SHIFT) /* 0111: fSAMPLING=fDTS/4, N=8 */ +# define ATIM_BDTR_BK2F_FDTSd46 (6 << ATIM_BDTR_BK2F_SHIFT) /* 0110: fSAMPLING=fDTS/4, N=6 */ +# define ATIM_BDTR_BK2F_FDTSd48 (7 << ATIM_BDTR_BK2F_SHIFT) /* 0111: fSAMPLING=fDTS/4, N=8 */ # define ATIM_BDTR_BK2F_FDTSd86 (8 << ATIM_BDTR_BK2F_SHIFT) /* 1000: fSAMPLING=fDTS/8, N=6 */ # define ATIM_BDTR_BK2F_FDTSd88 (9 << ATIM_BDTR_BK2F_SHIFT) /* 1001: fSAMPLING=fDTS/8, N=8 */ # define ATIM_BDTR_BK2F_FDTSd165 (10 << ATIM_BDTR_BK2F_SHIFT) /* 1010: fSAMPLING=fDTS/16, N=5 */ @@ -735,8 +737,8 @@ # define ATIM_BDTR_BK2F_FDTSd326 (14 << ATIM_BDTR_BK2F_SHIFT) /* 1110: fSAMPLING=fDTS/32, N=6 */ # define ATIM_BDTR_BK2F_FDTSd328 (15 << ATIM_BDTR_BK2F_SHIFT) /* 1111: fSAMPLING=fDTS/32, N=8 */ -#define ATIM_BDTR_BK2E (1 << 24) /* Bit 24: Break 2 enable */ -#define ATIM_BDTR_BK2P (1 << 1525 /* Bit 25:Break 2 polarity */ +#define ATIM_BDTR_BK2E (1 << 24) /* Bit 24: Break 2 enable */ +#define ATIM_BDTR_BK2P (1 << 25) /* Bit 25: Break 2 polarity */ /* DMA control register */ @@ -823,8 +825,8 @@ # define GTIM_SMCR_FCKINT8 (3 << GTIM_SMCR_ETF_SHIFT) /* 0011: fSAMPLING=fCK_INT, N=8 */ # define GTIM_SMCR_FDTSd26 (4 << GTIM_SMCR_ETF_SHIFT) /* 0100: fSAMPLING=fDTS/2, N=6 */ # define GTIM_SMCR_FDTSd28 (5 << GTIM_SMCR_ETF_SHIFT) /* 0101: fSAMPLING=fDTS/2, N=8 */ -# define GTIM_SMCR_FDTSd36 (6 << GTIM_SMCR_ETF_SHIFT) /* 0110: fSAMPLING=fDTS/4, N=6 */ -# define GTIM_SMCR_FDTSd38 (7 << GTIM_SMCR_ETF_SHIFT) /* 0111: fSAMPLING=fDTS/4, N=8 */ +# define GTIM_SMCR_FDTSd46 (6 << GTIM_SMCR_ETF_SHIFT) /* 0110: fSAMPLING=fDTS/4, N=6 */ +# define GTIM_SMCR_FDTSd48 (7 << GTIM_SMCR_ETF_SHIFT) /* 0111: fSAMPLING=fDTS/4, N=8 */ # define GTIM_SMCR_FDTSd86 (8 << GTIM_SMCR_ETF_SHIFT) /* 1000: fSAMPLING=fDTS/8, N=6 */ # define GTIM_SMCR_FDTSd88 (9 << GTIM_SMCR_ETF_SHIFT) /* 1001: fSAMPLING=fDTS/8, N=8 */ # define GTIM_SMCR_FDTSd165 (10 << GTIM_SMCR_ETF_SHIFT) /* 1010: fSAMPLING=fDTS/16, N=5 */ @@ -1073,8 +1075,8 @@ # define GTIM_BDTR_BKF_FCKINT8 (3 << GTIM_BDTR_BKF_SHIFT) /* 0011: fSAMPLING=fCK_INT, N=8 */ # define GTIM_BDTR_BKF_FDTSd26 (4 << GTIM_BDTR_BKF_SHIFT) /* 0100: fSAMPLING=fDTS/2, N=6 */ # define GTIM_BDTR_BKF_FDTSd28 (5 << GTIM_BDTR_BKF_SHIFT) /* 0101: fSAMPLING=fDTS/2, N=8 */ -# define GTIM_BDTR_BKF_FDTSd36 (6 << GTIM_BDTR_BKF_SHIFT) /* 0110: fSAMPLING=fDTS/4, N=6 */ -# define GTIM_BDTR_BKF_FDTSd38 (7 << GTIM_BDTR_BKF_SHIFT) /* 0111: fSAMPLING=fDTS/4, N=8 */ +# define GTIM_BDTR_BKF_FDTSd46 (6 << GTIM_BDTR_BKF_SHIFT) /* 0110: fSAMPLING=fDTS/4, N=6 */ +# define GTIM_BDTR_BKF_FDTSd48 (7 << GTIM_BDTR_BKF_SHIFT) /* 0111: fSAMPLING=fDTS/4, N=8 */ # define GTIM_BDTR_BKF_FDTSd86 (8 << GTIM_BDTR_BKF_SHIFT) /* 1000: fSAMPLING=fDTS/8, N=6 */ # define GTIM_BDTR_BKF_FDTSd88 (9 << GTIM_BDTR_BKF_SHIFT) /* 1001: fSAMPLING=fDTS/8, N=8 */ # define GTIM_BDTR_BKF_FDTSd165 (10 << GTIM_BDTR_BKF_SHIFT) /* 1010: fSAMPLING=fDTS/16, N=5 */ diff --git a/arch/arm/src/stm32l4/hardware/stm32l4x3xx_rcc.h b/arch/arm/src/stm32l4/hardware/stm32l4x3xx_rcc.h index ac8e85913d762..2eab55f609cb2 100644 --- a/arch/arm/src/stm32l4/hardware/stm32l4x3xx_rcc.h +++ b/arch/arm/src/stm32l4/hardware/stm32l4x3xx_rcc.h @@ -157,17 +157,17 @@ #define RCC_CFGR_SW_SHIFT (0) /* Bits 0-1: System clock Switch */ #define RCC_CFGR_SW_MASK (3 << RCC_CFGR_SW_SHIFT) -# define RCC_CFGR_SW_MSI (0 << RCC_CFGR_SW_SHIFT) /* 00: HSI selected as system clock */ -# define RCC_CFGR_SW_HSI (1 << RCC_CFGR_SW_SHIFT) /* 00: HSI selected as system clock */ -# define RCC_CFGR_SW_HSE (2 << RCC_CFGR_SW_SHIFT) /* 01: HSE selected as system clock */ -# define RCC_CFGR_SW_PLL (3 << RCC_CFGR_SW_SHIFT) /* 10: PLL selected as system clock */ +# define RCC_CFGR_SW_MSI (0 << RCC_CFGR_SW_SHIFT) /* 00: MSI selected as system clock */ +# define RCC_CFGR_SW_HSI (1 << RCC_CFGR_SW_SHIFT) /* 01: HSI selected as system clock */ +# define RCC_CFGR_SW_HSE (2 << RCC_CFGR_SW_SHIFT) /* 10: HSE selected as system clock */ +# define RCC_CFGR_SW_PLL (3 << RCC_CFGR_SW_SHIFT) /* 11: PLL selected as system clock */ #define RCC_CFGR_SWS_SHIFT (2) /* Bits 2-3: System Clock Switch Status */ #define RCC_CFGR_SWS_MASK (3 << RCC_CFGR_SWS_SHIFT) -# define RCC_CFGR_SWS_MSI (0 << RCC_CFGR_SWS_SHIFT) /* 00: HSI oscillator used as system clock */ -# define RCC_CFGR_SWS_HSI (1 << RCC_CFGR_SWS_SHIFT) /* 00: HSI oscillator used as system clock */ -# define RCC_CFGR_SWS_HSE (2 << RCC_CFGR_SWS_SHIFT) /* 01: HSE oscillator used as system clock */ -# define RCC_CFGR_SWS_PLL (3 << RCC_CFGR_SWS_SHIFT) /* 10: PLL used as system clock */ +# define RCC_CFGR_SWS_MSI (0 << RCC_CFGR_SWS_SHIFT) /* 00: MSI oscillator used as system clock */ +# define RCC_CFGR_SWS_HSI (1 << RCC_CFGR_SWS_SHIFT) /* 01: HSI oscillator used as system clock */ +# define RCC_CFGR_SWS_HSE (2 << RCC_CFGR_SWS_SHIFT) /* 10: HSE oscillator used as system clock */ +# define RCC_CFGR_SWS_PLL (3 << RCC_CFGR_SWS_SHIFT) /* 11: PLL used as system clock */ #define RCC_CFGR_HPRE_SHIFT (4) /* Bits 4-7: AHB prescaler */ #define RCC_CFGR_HPRE_MASK (0x0f << RCC_CFGR_HPRE_SHIFT) diff --git a/arch/arm/src/stm32l4/hardware/stm32l4x5xx_rcc.h b/arch/arm/src/stm32l4/hardware/stm32l4x5xx_rcc.h index 1b2f4ed91d602..29e87eb505c21 100644 --- a/arch/arm/src/stm32l4/hardware/stm32l4x5xx_rcc.h +++ b/arch/arm/src/stm32l4/hardware/stm32l4x5xx_rcc.h @@ -152,17 +152,17 @@ #define RCC_CFGR_SW_SHIFT (0) /* Bits 0-1: System clock Switch */ #define RCC_CFGR_SW_MASK (3 << RCC_CFGR_SW_SHIFT) -# define RCC_CFGR_SW_MSI (0 << RCC_CFGR_SW_SHIFT) /* 00: HSI selected as system clock */ -# define RCC_CFGR_SW_HSI (1 << RCC_CFGR_SW_SHIFT) /* 00: HSI selected as system clock */ -# define RCC_CFGR_SW_HSE (2 << RCC_CFGR_SW_SHIFT) /* 01: HSE selected as system clock */ -# define RCC_CFGR_SW_PLL (3 << RCC_CFGR_SW_SHIFT) /* 10: PLL selected as system clock */ +# define RCC_CFGR_SW_MSI (0 << RCC_CFGR_SW_SHIFT) /* 00: MSI selected as system clock */ +# define RCC_CFGR_SW_HSI (1 << RCC_CFGR_SW_SHIFT) /* 01: HSI selected as system clock */ +# define RCC_CFGR_SW_HSE (2 << RCC_CFGR_SW_SHIFT) /* 10: HSE selected as system clock */ +# define RCC_CFGR_SW_PLL (3 << RCC_CFGR_SW_SHIFT) /* 11: PLL selected as system clock */ #define RCC_CFGR_SWS_SHIFT (2) /* Bits 2-3: System Clock Switch Status */ #define RCC_CFGR_SWS_MASK (3 << RCC_CFGR_SWS_SHIFT) -# define RCC_CFGR_SWS_MSI (0 << RCC_CFGR_SWS_SHIFT) /* 00: HSI oscillator used as system clock */ -# define RCC_CFGR_SWS_HSI (1 << RCC_CFGR_SWS_SHIFT) /* 00: HSI oscillator used as system clock */ -# define RCC_CFGR_SWS_HSE (2 << RCC_CFGR_SWS_SHIFT) /* 01: HSE oscillator used as system clock */ -# define RCC_CFGR_SWS_PLL (3 << RCC_CFGR_SWS_SHIFT) /* 10: PLL used as system clock */ +# define RCC_CFGR_SWS_MSI (0 << RCC_CFGR_SWS_SHIFT) /* 00: MSI oscillator used as system clock */ +# define RCC_CFGR_SWS_HSI (1 << RCC_CFGR_SWS_SHIFT) /* 01: HSI oscillator used as system clock */ +# define RCC_CFGR_SWS_HSE (2 << RCC_CFGR_SWS_SHIFT) /* 10: HSE oscillator used as system clock */ +# define RCC_CFGR_SWS_PLL (3 << RCC_CFGR_SWS_SHIFT) /* 11: PLL used as system clock */ #define RCC_CFGR_HPRE_SHIFT (4) /* Bits 4-7: AHB prescaler */ #define RCC_CFGR_HPRE_MASK (0x0f << RCC_CFGR_HPRE_SHIFT) diff --git a/arch/arm/src/stm32l4/hardware/stm32l4x6xx_rcc.h b/arch/arm/src/stm32l4/hardware/stm32l4x6xx_rcc.h index 45a0c7fdb202d..07ada5ba219eb 100644 --- a/arch/arm/src/stm32l4/hardware/stm32l4x6xx_rcc.h +++ b/arch/arm/src/stm32l4/hardware/stm32l4x6xx_rcc.h @@ -157,17 +157,17 @@ #define RCC_CFGR_SW_SHIFT (0) /* Bits 0-1: System clock Switch */ #define RCC_CFGR_SW_MASK (3 << RCC_CFGR_SW_SHIFT) -# define RCC_CFGR_SW_MSI (0 << RCC_CFGR_SW_SHIFT) /* 00: HSI selected as system clock */ -# define RCC_CFGR_SW_HSI (1 << RCC_CFGR_SW_SHIFT) /* 00: HSI selected as system clock */ -# define RCC_CFGR_SW_HSE (2 << RCC_CFGR_SW_SHIFT) /* 01: HSE selected as system clock */ -# define RCC_CFGR_SW_PLL (3 << RCC_CFGR_SW_SHIFT) /* 10: PLL selected as system clock */ +# define RCC_CFGR_SW_MSI (0 << RCC_CFGR_SW_SHIFT) /* 00: MSI selected as system clock */ +# define RCC_CFGR_SW_HSI (1 << RCC_CFGR_SW_SHIFT) /* 01: HSI selected as system clock */ +# define RCC_CFGR_SW_HSE (2 << RCC_CFGR_SW_SHIFT) /* 10: HSE selected as system clock */ +# define RCC_CFGR_SW_PLL (3 << RCC_CFGR_SW_SHIFT) /* 11: PLL selected as system clock */ #define RCC_CFGR_SWS_SHIFT (2) /* Bits 2-3: System Clock Switch Status */ #define RCC_CFGR_SWS_MASK (3 << RCC_CFGR_SWS_SHIFT) -# define RCC_CFGR_SWS_MSI (0 << RCC_CFGR_SWS_SHIFT) /* 00: HSI oscillator used as system clock */ -# define RCC_CFGR_SWS_HSI (1 << RCC_CFGR_SWS_SHIFT) /* 00: HSI oscillator used as system clock */ -# define RCC_CFGR_SWS_HSE (2 << RCC_CFGR_SWS_SHIFT) /* 01: HSE oscillator used as system clock */ -# define RCC_CFGR_SWS_PLL (3 << RCC_CFGR_SWS_SHIFT) /* 10: PLL used as system clock */ +# define RCC_CFGR_SWS_MSI (0 << RCC_CFGR_SWS_SHIFT) /* 00: MSI oscillator used as system clock */ +# define RCC_CFGR_SWS_HSI (1 << RCC_CFGR_SWS_SHIFT) /* 01: HSI oscillator used as system clock */ +# define RCC_CFGR_SWS_HSE (2 << RCC_CFGR_SWS_SHIFT) /* 10: HSE oscillator used as system clock */ +# define RCC_CFGR_SWS_PLL (3 << RCC_CFGR_SWS_SHIFT) /* 11: PLL used as system clock */ #define RCC_CFGR_HPRE_SHIFT (4) /* Bits 4-7: AHB prescaler */ #define RCC_CFGR_HPRE_MASK (0x0f << RCC_CFGR_HPRE_SHIFT) diff --git a/arch/arm/src/stm32l4/hardware/stm32l4xrxx_dmamux.h b/arch/arm/src/stm32l4/hardware/stm32l4xrxx_dmamux.h index 32d5c32b3d96c..9e91506ba9688 100644 --- a/arch/arm/src/stm32l4/hardware/stm32l4xrxx_dmamux.h +++ b/arch/arm/src/stm32l4/hardware/stm32l4xrxx_dmamux.h @@ -82,7 +82,7 @@ #define STM32L4_DMAMUX1_C10CR (STM32L4_DMAMUX1_BASE+STM32L4_DMAMUX_C10CR_OFFSET) #define STM32L4_DMAMUX1_C11CR (STM32L4_DMAMUX1_BASE+STM32L4_DMAMUX_C11CR_OFFSET) #define STM32L4_DMAMUX1_C12CR (STM32L4_DMAMUX1_BASE+STM32L4_DMAMUX_C12CR_OFFSET) -#define STM32L4_DMAMUX1_C13CR (STM32L4_DMAMUX1_BASE+STM32L4_DMAMUX_C12CR_OFFSET) +#define STM32L4_DMAMUX1_C13CR (STM32L4_DMAMUX1_BASE+STM32L4_DMAMUX_C13CR_OFFSET) #define STM32L4_DMAMUX1_CSR (STM32L4_DMAMUX1_BASE+STM32L4_DMAMUX_CSR_OFFSET) #define STM32L4_DMAMUX1_CFR (STM32L4_DMAMUX1_BASE+STM32L4_DMAMUX_CFR_OFFSET) @@ -106,7 +106,7 @@ #define DMAMUX_CCR_EGE (9) /* Bit 9: Event generation enable */ #define DMAMUX_CCR_SE (16) /* Bit 16: Synchronization enable */ #define DMAMUX_CCR_SPOL_SHIFT (17) /* Bits 17-18: Synchronization polarity */ -#define DMAMUX_CCR_SPOL_MASK (3 << DMAMUX_CCR_SPOL_SHIFT) +#define DMAMUX_CCR_SPOL_MASK (0x3 << DMAMUX_CCR_SPOL_SHIFT) #define DMAMUX_CCR_NBREQ_SHIFT (19) /* Bits 19-23: Number of DMA request - 1 to forward */ #define DMAMUX_CCR_NBREQ_MASK (0x1f << DMAMUX_CCR_NBREQ_SHIFT) #define DMAMUX_CCR_SYNCID_SHIFT (24) /* Bits 24-28: Synchronization identification */ @@ -127,9 +127,9 @@ #define DMAMUX_RGCR_OIE (8) /* Bit 8: Trigger overrun interrupt enable */ #define DMAMUX_RGCR_GE (16) /* Bit 16: DMA request generator channel X enable*/ #define DMAMUX_RGCR_GPOL_SHIFT (17) /* Bits 17-18: DMA request generator trigger polarity */ -#define DMAMUX_RGCR_GPOL_MASK (7 << DMAMUX_RGCR_GPOL_SHIFT) -#define DMAMUX_RGCR_GNBREQ_SHIFT (17) /* Bits 19-23: Number of DMA requests to be generated -1 */ -#define DMAMUX_RGCR_GNBREQL_MASK (7 << DMAMUX_RGCR_GNBREQ_SHIFT) +#define DMAMUX_RGCR_GPOL_MASK (0x3 << DMAMUX_RGCR_GPOL_SHIFT) +#define DMAMUX_RGCR_GNBREQ_SHIFT (19) /* Bits 19-23: Number of DMA requests to be generated -1 */ +#define DMAMUX_RGCR_GNBREQ_MASK (0x1f << DMAMUX_RGCR_GNBREQ_SHIFT) /* DMAMUX1 request generator interrupt status register */ diff --git a/arch/arm/src/stm32l4/hardware/stm32l4xrxx_rcc.h b/arch/arm/src/stm32l4/hardware/stm32l4xrxx_rcc.h index e0fb5350400c8..9a2598f6a1c59 100644 --- a/arch/arm/src/stm32l4/hardware/stm32l4xrxx_rcc.h +++ b/arch/arm/src/stm32l4/hardware/stm32l4xrxx_rcc.h @@ -157,17 +157,17 @@ #define RCC_CFGR_SW_SHIFT (0) /* Bits 0-1: System clock Switch */ #define RCC_CFGR_SW_MASK (3 << RCC_CFGR_SW_SHIFT) -# define RCC_CFGR_SW_MSI (0 << RCC_CFGR_SW_SHIFT) /* 00: HSI selected as system clock */ -# define RCC_CFGR_SW_HSI (1 << RCC_CFGR_SW_SHIFT) /* 00: HSI selected as system clock */ -# define RCC_CFGR_SW_HSE (2 << RCC_CFGR_SW_SHIFT) /* 01: HSE selected as system clock */ -# define RCC_CFGR_SW_PLL (3 << RCC_CFGR_SW_SHIFT) /* 10: PLL selected as system clock */ +# define RCC_CFGR_SW_MSI (0 << RCC_CFGR_SW_SHIFT) /* 00: MSI selected as system clock */ +# define RCC_CFGR_SW_HSI (1 << RCC_CFGR_SW_SHIFT) /* 01: HSI selected as system clock */ +# define RCC_CFGR_SW_HSE (2 << RCC_CFGR_SW_SHIFT) /* 10: HSE selected as system clock */ +# define RCC_CFGR_SW_PLL (3 << RCC_CFGR_SW_SHIFT) /* 11: PLL selected as system clock */ #define RCC_CFGR_SWS_SHIFT (2) /* Bits 2-3: System Clock Switch Status */ #define RCC_CFGR_SWS_MASK (3 << RCC_CFGR_SWS_SHIFT) -# define RCC_CFGR_SWS_MSI (0 << RCC_CFGR_SWS_SHIFT) /* 00: HSI oscillator used as system clock */ -# define RCC_CFGR_SWS_HSI (1 << RCC_CFGR_SWS_SHIFT) /* 00: HSI oscillator used as system clock */ -# define RCC_CFGR_SWS_HSE (2 << RCC_CFGR_SWS_SHIFT) /* 01: HSE oscillator used as system clock */ -# define RCC_CFGR_SWS_PLL (3 << RCC_CFGR_SWS_SHIFT) /* 10: PLL used as system clock */ +# define RCC_CFGR_SWS_MSI (0 << RCC_CFGR_SWS_SHIFT) /* 00: MSI oscillator used as system clock */ +# define RCC_CFGR_SWS_HSI (1 << RCC_CFGR_SWS_SHIFT) /* 01: HSI oscillator used as system clock */ +# define RCC_CFGR_SWS_HSE (2 << RCC_CFGR_SWS_SHIFT) /* 10: HSE oscillator used as system clock */ +# define RCC_CFGR_SWS_PLL (3 << RCC_CFGR_SWS_SHIFT) /* 11: PLL used as system clock */ #define RCC_CFGR_HPRE_SHIFT (4) /* Bits 4-7: AHB prescaler */ #define RCC_CFGR_HPRE_MASK (0x0f << RCC_CFGR_HPRE_SHIFT) diff --git a/arch/arm/src/stm32l4/stm32l4.h b/arch/arm/src/stm32l4/stm32l4.h index 887cbb453211d..c512277c1b1a1 100644 --- a/arch/arm/src/stm32l4/stm32l4.h +++ b/arch/arm/src/stm32l4/stm32l4.h @@ -43,10 +43,8 @@ #include "stm32l4_dma.h" #include "stm32l4_exti.h" #include "stm32l4_flash.h" -#include "stm32l4_fsmc.h" #include "stm32l4_gpio.h" #include "stm32l4_i2c.h" -#include "stm32l4_lcd.h" #include "stm32l4_pwr.h" #include "stm32l4_rcc.h" #include "stm32l4_rtc.h" diff --git a/arch/arm/src/stm32l4/stm32l4_fsmc.h b/arch/arm/src/stm32l4/stm32l4_fsmc.h deleted file mode 100644 index 8b137891791fe..0000000000000 --- a/arch/arm/src/stm32l4/stm32l4_fsmc.h +++ /dev/null @@ -1 +0,0 @@ - diff --git a/arch/arm/src/stm32l4/stm32l4_lcd.h b/arch/arm/src/stm32l4/stm32l4_lcd.h deleted file mode 100644 index 8b137891791fe..0000000000000 --- a/arch/arm/src/stm32l4/stm32l4_lcd.h +++ /dev/null @@ -1 +0,0 @@ - diff --git a/arch/arm/src/stm32l4/stm32l4_otgfshost.c b/arch/arm/src/stm32l4/stm32l4_otgfshost.c index d5376e2ac03ca..8381a7c3c7f21 100644 --- a/arch/arm/src/stm32l4/stm32l4_otgfshost.c +++ b/arch/arm/src/stm32l4/stm32l4_otgfshost.c @@ -429,7 +429,7 @@ static int stm32l4_ep0configure(FAR struct usbhost_driver_s *drvr, usbhost_ep_t ep0, uint8_t funcaddr, uint8_t speed, uint16_t maxpacketsize); static int stm32l4_epalloc(FAR struct usbhost_driver_s *drvr, - FAR const FAR struct usbhost_epdesc_s *epdesc, + FAR const struct usbhost_epdesc_s *epdesc, FAR usbhost_ep_t *ep); static int stm32l4_epfree(FAR struct usbhost_driver_s *drvr, usbhost_ep_t ep); diff --git a/arch/arm/src/stm32l4/stm32l4_pminitialize.c b/arch/arm/src/stm32l4/stm32l4_pminitialize.c index 77d78f7e73153..84ac58717c397 100644 --- a/arch/arm/src/stm32l4/stm32l4_pminitialize.c +++ b/arch/arm/src/stm32l4/stm32l4_pminitialize.c @@ -23,6 +23,7 @@ ****************************************************************************/ #include +#include #include "arm_internal.h" #include "stm32l4_pm.h" @@ -53,6 +54,9 @@ void arm_pminitialize(void) { + /* Initialize the NuttX power management subsystem proper */ + + pm_initialize(); } #endif /* CONFIG_PM */ diff --git a/arch/arm/src/stm32l4/stm32l4_sdmmc.c b/arch/arm/src/stm32l4/stm32l4_sdmmc.c index 32c43865371d5..88cf056717460 100644 --- a/arch/arm/src/stm32l4/stm32l4_sdmmc.c +++ b/arch/arm/src/stm32l4/stm32l4_sdmmc.c @@ -3002,7 +3002,7 @@ static void stm32_callback(void *arg) mcinfo("Queuing callback to %p(%p)\n", priv->callback, priv->cbarg); - work_queue(HPWORK, &priv->cbwork, (worker_t)priv->callback, + work_queue(HPWORK, &priv->cbwork, priv->callback, priv->cbarg, 0); } else diff --git a/arch/arm/src/stm32l4/stm32l4_start.c b/arch/arm/src/stm32l4/stm32l4_start.c index 400844ae8a1fd..7a2eb391bb623 100644 --- a/arch/arm/src/stm32l4/stm32l4_start.c +++ b/arch/arm/src/stm32l4/stm32l4_start.c @@ -75,14 +75,6 @@ const uintptr_t g_idle_topstack = HEAP_BASE; -/**************************************************************************** - * Private Function prototypes - ****************************************************************************/ - -#ifdef CONFIG_ARCH_FPU -static inline void stm32l4_fpuconfig(void); -#endif - /**************************************************************************** * Private Functions ****************************************************************************/ @@ -111,96 +103,6 @@ static inline void stm32l4_fpuconfig(void); void __start(void) noinstrument_function; #endif -/**************************************************************************** - * Name: stm32l4_fpuconfig - * - * Description: - * Configure the FPU. Relative bit settings: - * - * CPACR: Enables access to CP10 and CP11 - * CONTROL.FPCA: Determines whether the FP extension is active in the - * current context: - * FPCCR.ASPEN: Enables automatic FP state preservation, then the - * processor sets this bit to 1 on successful completion of any FP - * instruction. - * FPCCR.LSPEN: Enables lazy context save of FP state. When this is - * done, the processor reserves space on the stack for the FP state, - * but does not save that state information to the stack. - * - * Software must not change the value of the ASPEN bit or LSPEN bit either: - * - the CPACR permits access to CP10 and CP11, that give access to the FP - * extension, or - * - the CONTROL.FPCA bit is set to 1 - * - ****************************************************************************/ - -#ifdef CONFIG_ARCH_FPU -#ifndef CONFIG_ARMV7M_LAZYFPU - -static inline void stm32l4_fpuconfig(void) -{ - uint32_t regval; - - /* Set CONTROL.FPCA so that we always get the extended context frame - * with the volatile FP registers stacked above the basic context. - */ - - regval = getcontrol(); - regval |= CONTROL_FPCA; - setcontrol(regval); - - /* Ensure that FPCCR.LSPEN is disabled, so that we don't have to contend - * with the lazy FP context save behaviour. Clear FPCCR.ASPEN since we - * are going to turn on CONTROL.FPCA for all contexts. - */ - - regval = getreg32(NVIC_FPCCR); - regval &= ~(NVIC_FPCCR_ASPEN | NVIC_FPCCR_LSPEN); - putreg32(regval, NVIC_FPCCR); - - /* Enable full access to CP10 and CP11 */ - - regval = getreg32(NVIC_CPACR); - regval |= NVIC_CPACR_CP_FULL(10) | NVIC_CPACR_CP_FULL(11); - putreg32(regval, NVIC_CPACR); -} - -#else - -static inline void stm32l4_fpuconfig(void) -{ - uint32_t regval; - - /* Clear CONTROL.FPCA so that we do not get the extended context frame - * with the volatile FP registers stacked in the saved context. - */ - - regval = getcontrol(); - regval &= ~CONTROL_FPCA; - setcontrol(regval); - - /* Ensure that FPCCR.LSPEN is disabled, so that we don't have to contend - * with the lazy FP context save behaviour. Clear FPCCR.ASPEN since we - * are going to keep CONTROL.FPCA off for all contexts. - */ - - regval = getreg32(NVIC_FPCCR); - regval &= ~(NVIC_FPCCR_ASPEN | NVIC_FPCCR_LSPEN); - putreg32(regval, NVIC_FPCCR); - - /* Enable full access to CP10 and CP11 */ - - regval = getreg32(NVIC_CPACR); - regval |= NVIC_CPACR_CP_FULL(10) | NVIC_CPACR_CP_FULL(11); - putreg32(regval, NVIC_CPACR); -} - -#endif - -#else -# define stm32l4_fpuconfig() -#endif - /**************************************************************************** * Public Functions ****************************************************************************/ @@ -246,7 +148,7 @@ void __start(void) /* Configure the UART so that we can get debug output as soon as possible */ stm32l4_clockconfig(); - stm32l4_fpuconfig(); + arm_fpuconfig(); stm32l4_lowsetup(); stm32l4_gpioinit(); showprogress('A'); diff --git a/arch/arm/src/stm32l4/stm32l4_tim.c b/arch/arm/src/stm32l4/stm32l4_tim.c index d3bb3a55bdad3..0349482a4802f 100644 --- a/arch/arm/src/stm32l4/stm32l4_tim.c +++ b/arch/arm/src/stm32l4/stm32l4_tim.c @@ -1127,7 +1127,7 @@ static int stm32l4_tim_setchannel(FAR struct stm32l4_tim_dev_s *dev, /* Further we use range as 0..3; if channel=0 it will also overflow here */ - if (--channel > 4) + if (--channel > 3) { return -EINVAL; } diff --git a/arch/arm/src/stm32l4/stm32l4x3xx_rcc.c b/arch/arm/src/stm32l4/stm32l4x3xx_rcc.c index 88265af5016f1..b9ae1891eb977 100644 --- a/arch/arm/src/stm32l4/stm32l4x3xx_rcc.c +++ b/arch/arm/src/stm32l4/stm32l4x3xx_rcc.c @@ -46,10 +46,6 @@ #define HSIRDY_TIMEOUT HSERDY_TIMEOUT #define MSIRDY_TIMEOUT HSERDY_TIMEOUT -/* HSE divisor to yield ~1MHz RTC clock */ - -#define HSE_DIVISOR (STM32L4_HSE_FREQUENCY + 500000) / 1000000 - /* Determine if board wants to use HSI48 as 48 MHz oscillator. */ #if defined(CONFIG_STM32L4_HAVE_HSI48) && defined(STM32L4_USE_CLK48) @@ -121,7 +117,7 @@ static inline void rcc_enableahb1(void) { uint32_t regval; - /* Set the appropriate bits in the AHB1ENR register to enabled the + /* Set the appropriate bits in the AHB1ENR register to enable the * selected AHB1 peripherals. */ @@ -166,7 +162,7 @@ static inline void rcc_enableahb2(void) { uint32_t regval; - /* Set the appropriate bits in the AHB2ENR register to enable the + /* Set the appropriate bits in the AHB2ENR register to enabled the * selected AHB2 peripherals. */ @@ -523,16 +519,19 @@ static inline void rcc_enableccip(void) #ifdef CONFIG_STM32L4_I2C1 /* Select HSI16 as I2C1 clock source. */ + regval &= ~RCC_CCIPR_I2C1SEL_MASK; regval |= RCC_CCIPR_I2C1SEL_HSI; #endif #ifdef CONFIG_STM32L4_I2C2 /* Select HSI16 as I2C2 clock source. */ + regval &= ~RCC_CCIPR_I2C2SEL_MASK; regval |= RCC_CCIPR_I2C2SEL_HSI; #endif #ifdef CONFIG_STM32L4_I2C3 /* Select HSI16 as I2C3 clock source. */ + regval &= ~RCC_CCIPR_I2C3SEL_MASK; regval |= RCC_CCIPR_I2C3SEL_HSI; #endif #endif /* STM32L4_I2C_USE_HSI16 */ @@ -543,12 +542,14 @@ static inline void rcc_enableccip(void) * warning messages. */ + regval &= ~RCC_CCIPR_CLK48SEL_MASK; regval |= STM32L4_CLK48_SEL; #endif #if defined(CONFIG_STM32L4_ADC1) /* Select SYSCLK as ADC clock source */ + regval &= ~RCC_CCIPR_ADCSEL_MASK; regval |= RCC_CCIPR_ADCSEL_SYSCLK; #endif @@ -574,7 +575,8 @@ static inline void rcc_enableccip(void) /* Select HSI16 as I2C4 clock source. */ - regval |= RCC_CCIPR_I2C4SEL_HSI; + regval &= ~RCC_CCIPR2_I2C4SEL_MASK; + regval |= RCC_CCIPR2_I2C4SEL_HSI; putreg32(regval, STM32L4_RCC_CCIPR2); #endif @@ -641,6 +643,7 @@ static void stm32l4_stdclockconfig(void) /* setting MSIRANGE */ regval = getreg32(STM32L4_RCC_CR); + regval &= ~RCC_CR_MSIRANGE_MASK; regval |= (STM32L4_BOARD_MSIRANGE | RCC_CR_MSION); /* Enable MSI and frequency */ putreg32(regval, STM32L4_RCC_CR); @@ -695,9 +698,9 @@ static void stm32l4_stdclockconfig(void) #if 0 /* Ensure Power control is enabled before modifying it. */ - regval = getreg32(STM32L4_RCC_APB1ENR); - regval |= RCC_APB1ENR_PWREN; - putreg32(regval, STM32L4_RCC_APB1ENR); + regval = getreg32(STM32L4_RCC_APB1ENR1); + regval |= RCC_APB1ENR1_PWREN; + putreg32(regval, STM32L4_RCC_APB1ENR1); /* Select regulator voltage output Scale 1 mode to support system * frequencies up to 168 MHz. @@ -730,15 +733,6 @@ static void stm32l4_stdclockconfig(void) regval |= STM32L4_RCC_CFGR_PPRE1; putreg32(regval, STM32L4_RCC_CFGR); -#ifdef CONFIG_STM32L4_RTC_HSECLOCK - /* Set the RTC clock divisor */ - - regval = getreg32(STM32L4_RCC_CFGR); - regval &= ~RCC_CFGR_RTCPRE_MASK; - regval |= RCC_CFGR_RTCPRE(HSE_DIVISOR); - putreg32(regval, STM32L4_RCC_CFGR); -#endif - /* Set the PLL source and main divider */ regval = getreg32(STM32L4_RCC_PLLCFG); diff --git a/arch/arm/src/stm32l4/stm32l4x5xx_rcc.c b/arch/arm/src/stm32l4/stm32l4x5xx_rcc.c index 8b2178ebf8252..3317109edb414 100644 --- a/arch/arm/src/stm32l4/stm32l4x5xx_rcc.c +++ b/arch/arm/src/stm32l4/stm32l4x5xx_rcc.c @@ -45,10 +45,6 @@ #define HSIRDY_TIMEOUT HSERDY_TIMEOUT #define MSIRDY_TIMEOUT HSERDY_TIMEOUT -/* HSE divisor to yield ~1MHz RTC clock */ - -#define HSE_DIVISOR (STM32L4_HSE_FREQUENCY + 500000) / 1000000 - /**************************************************************************** * Private Data ****************************************************************************/ @@ -534,16 +530,19 @@ static inline void rcc_enableccip(void) #ifdef CONFIG_STM32L4_I2C1 /* Select HSI16 as I2C1 clock source. */ + regval &= ~RCC_CCIPR_I2C1SEL_MASK; regval |= RCC_CCIPR_I2C1SEL_HSI; #endif #ifdef CONFIG_STM32L4_I2C2 /* Select HSI16 as I2C2 clock source. */ + regval &= ~RCC_CCIPR_I2C2SEL_MASK; regval |= RCC_CCIPR_I2C2SEL_HSI; #endif #ifdef CONFIG_STM32L4_I2C3 /* Select HSI16 as I2C3 clock source. */ + regval &= ~RCC_CCIPR_I2C3SEL_MASK; regval |= RCC_CCIPR_I2C3SEL_HSI; #endif #endif /* STM32L4_I2C_USE_HSI16 */ @@ -554,12 +553,14 @@ static inline void rcc_enableccip(void) * warning messages. */ + regval &= ~RCC_CCIPR_CLK48SEL_MASK; regval |= STM32L4_CLK48_SEL; #endif #if defined(CONFIG_STM32L4_ADC1) || defined(CONFIG_STM32L4_ADC2) || defined(CONFIG_STM32L4_ADC3) /* Select SYSCLK as ADC clock source */ + regval &= ~RCC_CCIPR_ADCSEL_MASK; regval |= RCC_CCIPR_ADCSEL_SYSCLK; #endif @@ -632,6 +633,7 @@ static void stm32l4_stdclockconfig(void) /* setting MSIRANGE */ regval = getreg32(STM32L4_RCC_CR); + regval &= ~RCC_CR_MSIRANGE_MASK; regval |= (STM32L4_BOARD_MSIRANGE | RCC_CR_MSION); /* Enable MSI and frequency */ putreg32(regval, STM32L4_RCC_CR); @@ -686,9 +688,9 @@ static void stm32l4_stdclockconfig(void) #if 0 /* Ensure Power control is enabled before modifying it. */ - regval = getreg32(STM32L4_RCC_APB1ENR); - regval |= RCC_APB1ENR_PWREN; - putreg32(regval, STM32L4_RCC_APB1ENR); + regval = getreg32(STM32L4_RCC_APB1ENR1); + regval |= RCC_APB1ENR1_PWREN; + putreg32(regval, STM32L4_RCC_APB1ENR1); /* Select regulator voltage output Scale 1 mode to support system * frequencies up to 168 MHz. @@ -721,15 +723,6 @@ static void stm32l4_stdclockconfig(void) regval |= STM32L4_RCC_CFGR_PPRE1; putreg32(regval, STM32L4_RCC_CFGR); -#ifdef CONFIG_STM32L4_RTC_HSECLOCK - /* Set the RTC clock divisor */ - - regval = getreg32(STM32L4_RCC_CFGR); - regval &= ~RCC_CFGR_RTCPRE_MASK; - regval |= RCC_CFGR_RTCPRE(HSE_DIVISOR); - putreg32(regval, STM32L4_RCC_CFGR); -#endif - /* Set the PLL source and main divider */ regval = getreg32(STM32L4_RCC_PLLCFG); diff --git a/arch/arm/src/stm32l4/stm32l4x6xx_rcc.c b/arch/arm/src/stm32l4/stm32l4x6xx_rcc.c index 2120c65efa4c6..66b8cd6f6430a 100644 --- a/arch/arm/src/stm32l4/stm32l4x6xx_rcc.c +++ b/arch/arm/src/stm32l4/stm32l4x6xx_rcc.c @@ -46,10 +46,6 @@ #define HSIRDY_TIMEOUT HSERDY_TIMEOUT #define MSIRDY_TIMEOUT HSERDY_TIMEOUT -/* HSE divisor to yield ~1MHz RTC clock */ - -#define HSE_DIVISOR (STM32L4_HSE_FREQUENCY + 500000) / 1000000 - /* Determine if board wants to use HSI48 as 48 MHz oscillator. */ #if defined(CONFIG_STM32L4_HAVE_HSI48) && defined(STM32L4_USE_CLK48) @@ -597,16 +593,19 @@ static inline void rcc_enableccip(void) #ifdef CONFIG_STM32L4_I2C1 /* Select HSI16 as I2C1 clock source. */ + regval &= ~RCC_CCIPR_I2C1SEL_MASK; regval |= RCC_CCIPR_I2C1SEL_HSI; #endif #ifdef CONFIG_STM32L4_I2C2 /* Select HSI16 as I2C2 clock source. */ + regval &= ~RCC_CCIPR_I2C2SEL_MASK; regval |= RCC_CCIPR_I2C2SEL_HSI; #endif #ifdef CONFIG_STM32L4_I2C3 /* Select HSI16 as I2C3 clock source. */ + regval &= ~RCC_CCIPR_I2C3SEL_MASK; regval |= RCC_CCIPR_I2C3SEL_HSI; #endif #endif /* STM32L4_I2C_USE_HSI16 */ @@ -617,12 +616,14 @@ static inline void rcc_enableccip(void) * warning messages. */ + regval &= ~RCC_CCIPR_CLK48SEL_MASK; regval |= STM32L4_CLK48_SEL; #endif #if defined(CONFIG_STM32L4_ADC1) || defined(CONFIG_STM32L4_ADC2) || defined(CONFIG_STM32L4_ADC3) /* Select SYSCLK as ADC clock source */ + regval &= ~RCC_CCIPR_ADCSEL_MASK; regval |= RCC_CCIPR_ADCSEL_SYSCLK; #endif @@ -642,7 +643,8 @@ static inline void rcc_enableccip(void) /* Select HSI16 as I2C4 clock source. */ - regval |= RCC_CCIPR_I2C4SEL_HSI; + regval &= ~RCC_CCIPR2_I2C4SEL_MASK; + regval |= RCC_CCIPR2_I2C4SEL_HSI; putreg32(regval, STM32L4_RCC_CCIPR2); #endif @@ -838,15 +840,6 @@ static void stm32l4_stdclockconfig(void) regval |= STM32L4_RCC_CFGR_PPRE1; putreg32(regval, STM32L4_RCC_CFGR); -#ifdef CONFIG_STM32L4_RTC_HSECLOCK - /* Set the RTC clock divisor */ - - regval = getreg32(STM32L4_RCC_CFGR); - regval &= ~RCC_CFGR_RTCPRE_MASK; - regval |= RCC_CFGR_RTCPRE(HSE_DIVISOR); - putreg32(regval, STM32L4_RCC_CFGR); -#endif - #ifndef STM32L4_BOARD_NOPLL /* Set the PLL source and main divider */ diff --git a/arch/arm/src/stm32l4/stm32l4xrxx_rcc.c b/arch/arm/src/stm32l4/stm32l4xrxx_rcc.c index 027ac9b257587..433f63eb048c3 100644 --- a/arch/arm/src/stm32l4/stm32l4xrxx_rcc.c +++ b/arch/arm/src/stm32l4/stm32l4xrxx_rcc.c @@ -46,10 +46,6 @@ #define HSIRDY_TIMEOUT HSERDY_TIMEOUT #define MSIRDY_TIMEOUT HSERDY_TIMEOUT -/* HSE divisor to yield ~1MHz RTC clock */ - -#define HSE_DIVISOR (STM32L4_HSE_FREQUENCY + 500000) / 1000000 - /* Determine if board wants to use HSI48 as 48 MHz oscillator. */ #if defined(CONFIG_STM32L4_HAVE_HSI48) && defined(STM32L4_USE_CLK48) @@ -579,16 +575,19 @@ static inline void rcc_enableccip(void) #ifdef CONFIG_STM32L4_I2C1 /* Select HSI16 as I2C1 clock source. */ + regval &= ~RCC_CCIPR_I2C1SEL_MASK; regval |= RCC_CCIPR_I2C1SEL_HSI; #endif #ifdef CONFIG_STM32L4_I2C2 /* Select HSI16 as I2C2 clock source. */ + regval &= ~RCC_CCIPR_I2C2SEL_MASK; regval |= RCC_CCIPR_I2C2SEL_HSI; #endif #ifdef CONFIG_STM32L4_I2C3 /* Select HSI16 as I2C3 clock source. */ + regval &= ~RCC_CCIPR_I2C3SEL_MASK; regval |= RCC_CCIPR_I2C3SEL_HSI; #endif #endif /* STM32L4_I2C_USE_HSI16 */ @@ -599,12 +598,14 @@ static inline void rcc_enableccip(void) * warning messages. */ + regval &= ~RCC_CCIPR_CLK48SEL_MASK; regval |= STM32L4_CLK48_SEL; #endif #if defined(CONFIG_STM32L4_ADC1) /* Select SYSCLK as ADC clock source */ + regval &= ~RCC_CCIPR_ADCSEL_MASK; regval |= RCC_CCIPR_ADCSEL_SYSCLK; #endif @@ -618,6 +619,7 @@ static inline void rcc_enableccip(void) #ifdef CONFIG_STM32L4_I2C4 /* Select HSI16 as I2C4 clock source. */ + regval &= ~RCC_CCIPR2_I2C4SEL_MASK; regval |= RCC_CCIPR2_I2C4SEL_HSI; #endif #endif @@ -625,6 +627,7 @@ static inline void rcc_enableccip(void) #ifdef CONFIG_STM32L4_DFSDM1 /* Select SAI1 as DFSDM audio clock source. */ + regval &= ~RCC_CCIPR2_ADFSDMSEL_MASK; regval |= RCC_CCIPR2_ADFSDMSEL_SAI1; /* Select SYSCLK as DFSDM kernel clock source. */ @@ -696,6 +699,7 @@ static void stm32l4_stdclockconfig(void) /* setting MSIRANGE */ regval = getreg32(STM32L4_RCC_CR); + regval &= ~RCC_CR_MSIRANGE_MASK; regval |= (STM32L4_BOARD_MSIRANGE | RCC_CR_MSION); /* Enable MSI and frequency */ putreg32(regval, STM32L4_RCC_CR); @@ -789,15 +793,6 @@ static void stm32l4_stdclockconfig(void) regval |= STM32L4_RCC_CFGR_PPRE1; putreg32(regval, STM32L4_RCC_CFGR); -#ifdef CONFIG_STM32L4_RTC_HSECLOCK - /* Set the RTC clock divisor */ - - regval = getreg32(STM32L4_RCC_CFGR); - regval &= ~RCC_CFGR_RTCPRE_MASK; - regval |= RCC_CFGR_RTCPRE(HSE_DIVISOR); - putreg32(regval, STM32L4_RCC_CFGR); -#endif - /* Set the PLL source and main divider */ regval = getreg32(STM32L4_RCC_PLLCFG); diff --git a/arch/arm/src/stm32l5/Make.defs b/arch/arm/src/stm32l5/Make.defs index f3774978222a9..e31d3004adc89 100644 --- a/arch/arm/src/stm32l5/Make.defs +++ b/arch/arm/src/stm32l5/Make.defs @@ -25,52 +25,7 @@ HEAD_ASRC = # Common ARM and Cortex-M4 files (copied from stm32/Make.defs) -CMN_UASRCS = -CMN_UCSRCS = - -CMN_ASRCS = arm_saveusercontext.S arm_fullcontextrestore.S -CMN_ASRCS += arm_testset.S arm_fetchadd.S vfork.S - -CMN_CSRCS = arm_assert.c arm_blocktask.c arm_createstack.c -CMN_CSRCS += arm_doirq.c arm_exit.c arm_hardfault.c arm_initialize.c -CMN_CSRCS += arm_initialstate.c arm_interruptcontext.c arm_mdelay.c arm_memfault.c -CMN_CSRCS += arm_modifyreg8.c arm_modifyreg16.c arm_modifyreg32.c -CMN_CSRCS += arm_releasepending.c arm_releasestack.c arm_reprioritizertr.c -CMN_CSRCS += arm_schedulesigaction.c arm_sigdeliver.c arm_stackframe.c -CMN_CSRCS += arm_svcall.c arm_systemreset.c arm_trigger_irq.c arm_udelay.c -CMN_CSRCS += arm_unblocktask.c arm_usestack.c arm_vfork.c arm_switchcontext.c -CMN_CSRCS += arm_puts.c arm_tcbinfo.c - -# Configuration-dependent common files - -ifeq ($(CONFIG_ARMV8M_STACKCHECK),y) -CMN_CSRCS += arm_stackcheck.c -endif - -ifeq ($(CONFIG_ARMV8M_LAZYFPU),y) -CMN_ASRCS += arm_lazyexception.S -else -CMN_ASRCS += arm_exception.S -endif -CMN_CSRCS += arm_vectors.c - -ifeq ($(CONFIG_ARCH_FPU),y) -CMN_ASRCS += arm_fpu.S -endif - -ifeq ($(CONFIG_ARCH_RAMVECTORS),y) -CMN_CSRCS += arm_ramvec_initialize.c arm_ramvec_attach.c -endif - -ifeq ($(CONFIG_BUILD_PROTECTED),y) -CMN_CSRCS += arm_mpu.c arm_task_start.c arm_pthread_start.c -CMN_CSRCS += arm_signal_dispatch.c -CMN_UASRCS += arm_signal_handler.S -endif - -ifeq ($(CONFIG_STACK_COLORATION),y) -CMN_CSRCS += arm_checkstack.c -endif +include armv8-m/Make.defs # Required STM32L5 files diff --git a/arch/arm/src/stm32l5/stm32l5_irq.c b/arch/arm/src/stm32l5/stm32l5_irq.c index ca543dad77c6b..1398dea56508c 100644 --- a/arch/arm/src/stm32l5/stm32l5_irq.c +++ b/arch/arm/src/stm32l5/stm32l5_irq.c @@ -141,7 +141,7 @@ static void stm32l5_dumpnvic(const char *msg, int irq) #ifdef CONFIG_DEBUG_FEATURES static int stm32l5_nmi(int irq, FAR void *context, FAR void *arg) { - (void)up_irq_save(); + up_irq_save(); _err("PANIC!!! NMI received\n"); PANIC(); return 0; @@ -149,7 +149,7 @@ static int stm32l5_nmi(int irq, FAR void *context, FAR void *arg) static int stm32l5_busfault(int irq, FAR void *context, FAR void *arg) { - (void)up_irq_save(); + up_irq_save(); _err("PANIC!!! Bus fault received: %08x\n", getreg32(NVIC_CFAULTS)); PANIC(); return 0; @@ -157,7 +157,7 @@ static int stm32l5_busfault(int irq, FAR void *context, FAR void *arg) static int stm32l5_usagefault(int irq, FAR void *context, FAR void *arg) { - (void)up_irq_save(); + up_irq_save(); _err("PANIC!!! Usage fault received: %08x\n", getreg32(NVIC_CFAULTS)); PANIC(); return 0; @@ -165,7 +165,7 @@ static int stm32l5_usagefault(int irq, FAR void *context, FAR void *arg) static int stm32l5_pendsv(int irq, FAR void *context, FAR void *arg) { - (void)up_irq_save(); + up_irq_save(); _err("PANIC!!! PendSV received\n"); PANIC(); return 0; @@ -173,7 +173,7 @@ static int stm32l5_pendsv(int irq, FAR void *context, FAR void *arg) static int stm32l5_dbgmonitor(int irq, FAR void *context, FAR void *arg) { - (void)up_irq_save(); + up_irq_save(); _err("PANIC!!! Debug Monitor received\n"); PANIC(); return 0; @@ -181,7 +181,7 @@ static int stm32l5_dbgmonitor(int irq, FAR void *context, FAR void *arg) static int stm32l5_reserved(int irq, FAR void *context, FAR void *arg) { - (void)up_irq_save(); + up_irq_save(); _err("PANIC!!! Reserved interrupt\n"); PANIC(); return 0; diff --git a/arch/arm/src/stm32l5/stm32l5_lse.c b/arch/arm/src/stm32l5/stm32l5_lse.c index ff754ba52e654..3bc595b30526d 100644 --- a/arch/arm/src/stm32l5/stm32l5_lse.c +++ b/arch/arm/src/stm32l5/stm32l5_lse.c @@ -181,6 +181,6 @@ void stm32l5_rcc_enablelse(void) /* Disable backup domain access if it was disabled on entry */ - (void)stm32l5_pwr_enablebkp(writable); + stm32l5_pwr_enablebkp(writable); } } diff --git a/arch/arm/src/stm32l5/stm32l5_rcc.c b/arch/arm/src/stm32l5/stm32l5_rcc.c index f214ba7770eb3..86fb78a5674f1 100644 --- a/arch/arm/src/stm32l5/stm32l5_rcc.c +++ b/arch/arm/src/stm32l5/stm32l5_rcc.c @@ -102,7 +102,7 @@ static inline void rcc_resetbkp(void) * backup data registers and backup SRAM). */ - (void)stm32l5_pwr_enablebkp(true); + stm32l5_pwr_enablebkp(true); /* We might be changing RTCSEL - to ensure such changes work, we must * reset the backup domain (having backed up the RTC_MAGIC token) @@ -123,7 +123,7 @@ static inline void rcc_resetbkp(void) putreg32(bkregs[i], STM32L5_RTC_BKR(i)); } - (void)stm32l5_pwr_enablebkp(false); + stm32l5_pwr_enablebkp(false); } } #else diff --git a/arch/arm/src/stm32l5/stm32l5_serial.c b/arch/arm/src/stm32l5/stm32l5_serial.c index ecf4a3da9647d..50d667122bebf 100644 --- a/arch/arm/src/stm32l5/stm32l5_serial.c +++ b/arch/arm/src/stm32l5/stm32l5_serial.c @@ -1209,7 +1209,7 @@ static void stm32l5serial_setsuspend(struct uart_dev_s *dev, bool suspend) #ifdef CONFIG_SERIAL_IFLOWCONTROL if (priv->iflow) { - (void)stm32l5serial_dmaiflowrestart(priv); + stm32l5serial_dmaiflowrestart(priv); } else #endif @@ -2644,7 +2644,7 @@ static void stm32l5serial_dmarxint(FAR struct uart_dev_s *dev, bool enable) { /* Re-enable RX DMA. */ - (void)stm32l5serial_dmaiflowrestart(priv); + stm32l5serial_dmaiflowrestart(priv); } #endif } @@ -2805,7 +2805,7 @@ static void stm32l5serial_dmarxcallback(DMA_HANDLE handle, uint8_t status, { /* Re-enable RX DMA. */ - (void)stm32l5serial_dmaiflowrestart(priv); + stm32l5serial_dmaiflowrestart(priv); } #endif } @@ -3076,14 +3076,14 @@ void arm_serialinit(void) /* Register the console */ #if CONSOLE_UART > 0 - (void)uart_register("/dev/console", &g_uart_devs[CONSOLE_UART - 1]->dev); + uart_register("/dev/console", &g_uart_devs[CONSOLE_UART - 1]->dev); #ifndef CONFIG_STM32L5_SERIAL_DISABLE_REORDERING /* If not disabled, register the console UART to ttyS0 and exclude * it from initializing it further down */ - (void)uart_register("/dev/ttyS0", &g_uart_devs[CONSOLE_UART - 1]->dev); + uart_register("/dev/ttyS0", &g_uart_devs[CONSOLE_UART - 1]->dev); minor = 1; #endif @@ -3119,7 +3119,7 @@ void arm_serialinit(void) /* Register USARTs as devices in increasing order */ devname[9] = '0' + minor++; - (void)uart_register(devname, &g_uart_devs[i]->dev); + uart_register(devname, &g_uart_devs[i]->dev); } #endif /* HAVE UART */ } diff --git a/arch/arm/src/stm32l5/stm32l5_spi.c b/arch/arm/src/stm32l5/stm32l5_spi.c index 3097820324760..84fa3db5ad934 100644 --- a/arch/arm/src/stm32l5/stm32l5_spi.c +++ b/arch/arm/src/stm32l5/stm32l5_spi.c @@ -689,7 +689,7 @@ static void spi_dmatxwait(FAR struct stm32l5_spidev_s *priv) #ifdef CONFIG_STM32L5_SPI_DMA static inline void spi_dmarxwakeup(FAR struct stm32l5_spidev_s *priv) { - (void)nxsem_post(&priv->rxsem); + nxsem_post(&priv->rxsem); } #endif @@ -704,7 +704,7 @@ static inline void spi_dmarxwakeup(FAR struct stm32l5_spidev_s *priv) #ifdef CONFIG_STM32L5_SPI_DMA static inline void spi_dmatxwakeup(FAR struct stm32l5_spidev_s *priv) { - (void)nxsem_post(&priv->txsem); + nxsem_post(&priv->txsem); } #endif @@ -953,7 +953,7 @@ static int spi_lock(FAR struct spi_dev_s *dev, bool lock) } else { - (void)nxsem_post(&priv->exclsem); + nxsem_post(&priv->exclsem); ret = OK; } diff --git a/arch/arm/src/stm32l5/stm32l5_start.c b/arch/arm/src/stm32l5/stm32l5_start.c index 28d55790bb995..c672b65b534ff 100644 --- a/arch/arm/src/stm32l5/stm32l5_start.c +++ b/arch/arm/src/stm32l5/stm32l5_start.c @@ -77,14 +77,6 @@ const uintptr_t g_idle_topstack = HEAP_BASE; -/**************************************************************************** - * Private Function prototypes - ****************************************************************************/ - -#ifdef CONFIG_ARCH_FPU -static inline void stm32l5_fpuconfig(void); -#endif - /**************************************************************************** * Private Functions ****************************************************************************/ @@ -113,97 +105,6 @@ static inline void stm32l5_fpuconfig(void); void __start(void) noinstrument_function; #endif -/**************************************************************************** - * Name: stm32l5_fpuconfig - * - * Description: - * Configure the FPU. Relative bit settings: - * - * CPACR: Enables access to CP10 and CP11 - * CONTROL.FPCA: Determines whether the FP extension is active in the - * current context: - * FPCCR.ASPEN: Enables automatic FP state preservation, then the - * processor sets this bit to 1 on successful completion of any FP - * instruction. - * FPCCR.LSPEN: Enables lazy context save of FP state. When this is - * done, the processor reserves space on the stack for the FP state, - * but does not save that state information to the stack. - * - * Software must not change the value of the ASPEN bit or LSPEN bit while - * either: - * - the CPACR permits access to CP10 and CP11, that give access to the FP - * extension, or - * - the CONTROL.FPCA bit is set to 1 - * - ****************************************************************************/ - -#ifdef CONFIG_ARCH_FPU -#ifndef CONFIG_ARMV8M_LAZYFPU - -static inline void stm32l5_fpuconfig(void) -{ - uint32_t regval; - - /* Set CONTROL.FPCA so that we always get the extended context frame - * with the volatile FP registers stacked above the basic context. - */ - - regval = getcontrol(); - regval |= CONTROL_FPCA; - setcontrol(regval); - - /* Ensure that FPCCR.LSPEN is disabled, so that we don't have to contend - * with the lazy FP context save behaviour. Clear FPCCR.ASPEN since we - * are going to turn on CONTROL.FPCA for all contexts. - */ - - regval = getreg32(NVIC_FPCCR); - regval &= ~(NVIC_FPCCR_ASPEN | NVIC_FPCCR_LSPEN); - putreg32(regval, NVIC_FPCCR); - - /* Enable full access to CP10 and CP11 */ - - regval = getreg32(NVIC_CPACR); - regval |= NVIC_CPACR_CP_FULL(10) | NVIC_CPACR_CP_FULL(11); - putreg32(regval, NVIC_CPACR); -} - -#else - -static inline void stm32l5_fpuconfig(void) -{ - uint32_t regval; - - /* Clear CONTROL.FPCA so that we do not get the extended context frame - * with the volatile FP registers stacked in the saved context. - */ - - regval = getcontrol(); - regval &= ~CONTROL_FPCA; - setcontrol(regval); - - /* Ensure that FPCCR.LSPEN is disabled, so that we don't have to contend - * with the lazy FP context save behaviour. Clear FPCCR.ASPEN since we - * are going to keep CONTROL.FPCA off for all contexts. - */ - - regval = getreg32(NVIC_FPCCR); - regval &= ~(NVIC_FPCCR_ASPEN | NVIC_FPCCR_LSPEN); - putreg32(regval, NVIC_FPCCR); - - /* Enable full access to CP10 and CP11 */ - - regval = getreg32(NVIC_CPACR); - regval |= NVIC_CPACR_CP_FULL(10) | NVIC_CPACR_CP_FULL(11); - putreg32(regval, NVIC_CPACR); -} - -#endif - -#else -# define stm32l5_fpuconfig() -#endif - /**************************************************************************** * Public Functions ****************************************************************************/ @@ -249,7 +150,7 @@ void __start(void) /* Configure the UART so that we can get debug output as soon as possible */ stm32l5_clockconfig(); - stm32l5_fpuconfig(); + arm_fpuconfig(); stm32l5_lowsetup(); stm32l5_gpioinit(); showprogress('A'); diff --git a/arch/arm/src/stm32l5/stm32l5_timerisr.c b/arch/arm/src/stm32l5/stm32l5_timerisr.c index 28720a21d1aa7..bd05e580b18dc 100644 --- a/arch/arm/src/stm32l5/stm32l5_timerisr.c +++ b/arch/arm/src/stm32l5/stm32l5_timerisr.c @@ -134,7 +134,7 @@ void up_timer_initialize(void) /* Attach the timer interrupt vector */ - (void)irq_attach(STM32L5_IRQ_SYSTICK, (xcpt_t)stm32l5_timerisr, NULL); + irq_attach(STM32L5_IRQ_SYSTICK, (xcpt_t)stm32l5_timerisr, NULL); /* Enable SysTick interrupts */ diff --git a/arch/arm/src/stm32u5/Make.defs b/arch/arm/src/stm32u5/Make.defs index fe83656baea71..c72ebb14232bf 100644 --- a/arch/arm/src/stm32u5/Make.defs +++ b/arch/arm/src/stm32u5/Make.defs @@ -25,53 +25,7 @@ HEAD_ASRC = # Common ARM and Cortex-M4 files (copied from stm32/Make.defs) -CMN_UASRCS = -CMN_UCSRCS = - -CMN_ASRCS = arm_saveusercontext.S arm_fullcontextrestore.S -CMN_ASRCS += arm_testset.S arm_fetchadd.S vfork.S - -CMN_CSRCS = arm_assert.c arm_blocktask.c arm_createstack.c -CMN_CSRCS += arm_doirq.c arm_exit.c arm_hardfault.c arm_initialize.c -CMN_CSRCS += arm_initialstate.c arm_interruptcontext.c arm_mdelay.c arm_memfault.c -CMN_CSRCS += arm_modifyreg8.c arm_modifyreg16.c arm_modifyreg32.c arm_puts.c -CMN_CSRCS += arm_releasepending.c arm_releasestack.c arm_reprioritizertr.c -CMN_CSRCS += arm_schedulesigaction.c arm_sigdeliver.c arm_stackframe.c -CMN_CSRCS += arm_svcall.c arm_switchcontext.c arm_systemreset.c arm_tcbinfo.c -CMN_CSRCS += arm_trigger_irq.c arm_udelay.c arm_unblocktask.c arm_usestack.c -CMN_CSRCS += arm_vfork.c - -# Configuration-dependent common files - -ifeq ($(CONFIG_ARMV8M_STACKCHECK),y) -CMN_CSRCS += arm_stackcheck.c -endif - -ifeq ($(CONFIG_ARMV8M_LAZYFPU),y) -CMN_ASRCS += arm_lazyexception.S -else -CMN_ASRCS += arm_exception.S -endif -CMN_CSRCS += arm_vectors.c - -ifeq ($(CONFIG_ARCH_FPU),y) -CMN_ASRCS += arm_fpu.S -endif - -ifeq ($(CONFIG_ARCH_RAMVECTORS),y) -CMN_CSRCS += arm_ramvec_initialize.c arm_ramvec_attach.c -endif - -ifeq ($(CONFIG_BUILD_PROTECTED),y) -CMN_CSRCS += arm_mpu.c arm_task_start.c arm_pthread_start.c -CMN_CSRCS += arm_pthread_exit.c -CMN_CSRCS += arm_signal_dispatch.c -CMN_UASRCS += arm_signal_handler.S -endif - -ifeq ($(CONFIG_STACK_COLORATION),y) -CMN_CSRCS += arm_checkstack.c -endif +include armv8-m/Make.defs # Required STM32U5 files diff --git a/arch/arm/src/stm32u5/hardware/stm32u585xx_rcc.h b/arch/arm/src/stm32u5/hardware/stm32u585xx_rcc.h index 7f7c200ad171f..d299821624da6 100644 --- a/arch/arm/src/stm32u5/hardware/stm32u585xx_rcc.h +++ b/arch/arm/src/stm32u5/hardware/stm32u585xx_rcc.h @@ -278,6 +278,55 @@ # define RCC_CFGR1_MCOPRE_DIV8 (3 << RCC_CFGR1_MCOPRE_SHIFT) /* 011: division by 8 */ # define RCC_CFGR1_MCOPRE_DIV16 (4 << RCC_CFGR1_MCOPRE_SHIFT) /* 100: division by 16 */ +/* RCC clock configuration register 2 */ + +#define RCC_CFGR2_HPRE_SHIFT (0) /* Bits 0-3: AHB prescaler */ +#define RCC_CFGR2_HPRE_MASK (0xf << RCC_CFGR2_HPRE_SHIFT) +# define RCC_CFGR2_HPRE_SYSCLK ( 0 << RCC_CFGR2_HPRE_SHIFT) /* 0xxx: SYSCLK not divided */ +# define RCC_CFGR2_HPRE_SYSCLK_DIV2 ( 8 << RCC_CFGR2_HPRE_SHIFT) /* 1000: SYSCLK divided by 2 */ +# define RCC_CFGR2_HPRE_SYSCLK_DIV4 ( 9 << RCC_CFGR2_HPRE_SHIFT) /* 1001: SYSCLK divided by 4 */ +# define RCC_CFGR2_HPRE_SYSCLK_DIV8 (10 << RCC_CFGR2_HPRE_SHIFT) /* 1010: SYSCLK divided by 8 */ +# define RCC_CFGR2_HPRE_SYSCLK_DIV16 (11 << RCC_CFGR2_HPRE_SHIFT) /* 1011: SYSCLK divided by 16 */ +# define RCC_CFGR2_HPRE_SYSCLK_DIV64 (12 << RCC_CFGR2_HPRE_SHIFT) /* 1100: SYSCLK divided by 64 */ +# define RCC_CFGR2_HPRE_SYSCLK_DIV128 (13 << RCC_CFGR2_HPRE_SHIFT) /* 1101: SYSCLK divided by 128 */ +# define RCC_CFGR2_HPRE_SYSCLK_DIV256 (14 << RCC_CFGR2_HPRE_SHIFT) /* 1110: SYSCLK divided by 256 */ +# define RCC_CFGR2_HPRE_SYSCLK_DIV512 (15 << RCC_CFGR2_HPRE_SHIFT) /* 1111: SYSCLK divided by 512 */ + +#define RCC_CFGR2_PPRE1_SHIFT (4) /* Bits 4-6: APB1 prescaler */ +#define RCC_CFGR2_PPRE1_MASK (0x7 << RCC_CFGR2_HPRE_SHIFT) +# define RCC_CFGR2_PPRE1_HCLK (0 << RCC_CFGR2_HPRE_SHIFT) /* 0xxx: HCLK not divided */ +# define RCC_CFGR2_PPRE1_HCLK_DIV2 (4 << RCC_CFGR2_HPRE_SHIFT) /* 1000: HCLK divided by 2 */ +# define RCC_CFGR2_PPRE1_HCLK_DIV4 (5 << RCC_CFGR2_HPRE_SHIFT) /* 1001: HCLK divided by 4 */ +# define RCC_CFGR2_PPRE1_HCLK_DIV8 (6 << RCC_CFGR2_HPRE_SHIFT) /* 1010: HCLK divided by 8 */ +# define RCC_CFGR2_PPRE1_HCLK_DIV16 (7 << RCC_CFGR2_HPRE_SHIFT) /* 1011: HCLK divided by 16 */ + +#define RCC_CFGR2_PPRE2_SHIFT (8) /* Bits 8-10: APB2 prescaler */ +#define RCC_CFGR2_PPRE2_MASK (0x7 << RCC_CFGR2_PPRE2_SHIFT) +# define RCC_CFGR2_PPRE2_HCLK (0 << RCC_CFGR2_PPRE2_SHIFT) /* 0xxx: HCLK not divided */ +# define RCC_CFGR2_PPRE2_HCLK_DIV2 (4 << RCC_CFGR2_PPRE2_SHIFT) /* 1000: HCLK divided by 2 */ +# define RCC_CFGR2_PPRE2_HCLK_DIV4 (5 << RCC_CFGR2_PPRE2_SHIFT) /* 1001: HCLK divided by 4 */ +# define RCC_CFGR2_PPRE2_HCLK_DIV8 (6 << RCC_CFGR2_PPRE2_SHIFT) /* 1010: HCLK divided by 8 */ +# define RCC_CFGR2_PPRE2_HCLK_DIV16 (7 << RCC_CFGR2_PPRE2_SHIFT) /* 1011: HCLK divided by 16 */ + +#define RCC_CFGR2_AHB1DIS (1 << 16) /* Bit 16: AHB1 clock disable */ +#define RCC_CFGR2_AHB2DIS1 (1 << 17) /* Bit 17: AHB2_1 clock disable */ +#define RCC_CFGR2_AHB2DIS2 (1 << 18) /* Bit 18: AHB2_2 clock disable */ +#define RCC_CFGR2_APB1DIS (1 << 19) /* Bit 19: APB1 clock disable */ +#define RCC_CFGR2_APB2DIS (1 << 20) /* Bit 20: APB2 clock disable */ + +/* RCC clock configuration register 3 */ + +#define RCC_CFGR3_PPRE3_SHIFT (4) /* Bits 4-6: APB3 prescaler */ +#define RCC_CFGR3_PPRE3_MASK (0x7 << RCC_CFGR3_PPRE3_SHIFT) +# define RCC_CFGR3_PPRE3_HCLK (0 << RCC_CFGR3_PPRE3_SHIFT) /* 0xxx: HCLK not divided */ +# define RCC_CFGR3_PPRE3_HCLK_DIV2 (4 << RCC_CFGR3_PPRE3_SHIFT) /* 1000: HCLK divided by 2 */ +# define RCC_CFGR3_PPRE3_HCLK_DIV4 (5 << RCC_CFGR3_PPRE3_SHIFT) /* 1001: HCLK divided by 4 */ +# define RCC_CFGR3_PPRE3_HCLK_DIV8 (6 << RCC_CFGR3_PPRE3_SHIFT) /* 1010: HCLK divided by 8 */ +# define RCC_CFGR3_PPRE3_HCLK_DIV16 (7 << RCC_CFGR3_PPRE3_SHIFT) /* 1011: HCLK divided by 16 */ + +#define RCC_CFGR3_AHB3DIS (1 << 16) /* Bit 16: AHB3 clock disable */ +#define RCC_CFGR3_APB3DIS (1 << 17) /* Bit 17: APB3 clock disable */ + /* RCC PLL1 configuration register */ #define RCC_PLL1CFGR_PLL1SRC_SHIFT (0) /* Bits 0-1: PLL1 entry clock source */ diff --git a/arch/arm/src/stm32u5/stm32_irq.c b/arch/arm/src/stm32u5/stm32_irq.c index 4d375b11d795c..aa03270de32cd 100644 --- a/arch/arm/src/stm32u5/stm32_irq.c +++ b/arch/arm/src/stm32u5/stm32_irq.c @@ -141,7 +141,7 @@ static void stm32_dumpnvic(const char *msg, int irq) #ifdef CONFIG_DEBUG_FEATURES static int stm32_nmi(int irq, FAR void *context, FAR void *arg) { - (void)up_irq_save(); + up_irq_save(); _err("PANIC!!! NMI received\n"); PANIC(); return 0; @@ -149,7 +149,7 @@ static int stm32_nmi(int irq, FAR void *context, FAR void *arg) static int stm32_busfault(int irq, FAR void *context, FAR void *arg) { - (void)up_irq_save(); + up_irq_save(); _err("PANIC!!! Bus fault received: %08x\n", getreg32(NVIC_CFAULTS)); PANIC(); return 0; @@ -157,7 +157,7 @@ static int stm32_busfault(int irq, FAR void *context, FAR void *arg) static int stm32_usagefault(int irq, FAR void *context, FAR void *arg) { - (void)up_irq_save(); + up_irq_save(); _err("PANIC!!! Usage fault received: %08x\n", getreg32(NVIC_CFAULTS)); PANIC(); return 0; @@ -165,7 +165,7 @@ static int stm32_usagefault(int irq, FAR void *context, FAR void *arg) static int stm32_pendsv(int irq, FAR void *context, FAR void *arg) { - (void)up_irq_save(); + up_irq_save(); _err("PANIC!!! PendSV received\n"); PANIC(); return 0; @@ -173,7 +173,7 @@ static int stm32_pendsv(int irq, FAR void *context, FAR void *arg) static int stm32_dbgmonitor(int irq, FAR void *context, FAR void *arg) { - (void)up_irq_save(); + up_irq_save(); _err("PANIC!!! Debug Monitor received\n"); PANIC(); return 0; @@ -181,7 +181,7 @@ static int stm32_dbgmonitor(int irq, FAR void *context, FAR void *arg) static int stm32_reserved(int irq, FAR void *context, FAR void *arg) { - (void)up_irq_save(); + up_irq_save(); _err("PANIC!!! Reserved interrupt\n"); PANIC(); return 0; diff --git a/arch/arm/src/stm32u5/stm32_lse.c b/arch/arm/src/stm32u5/stm32_lse.c index ed22eeae13971..938bdaf85d3bb 100644 --- a/arch/arm/src/stm32u5/stm32_lse.c +++ b/arch/arm/src/stm32u5/stm32_lse.c @@ -181,6 +181,6 @@ void stm32_rcc_enablelse(void) /* Disable backup domain access if it was disabled on entry */ - (void)stm32_pwr_enablebkp(writable); + stm32_pwr_enablebkp(writable); } } diff --git a/arch/arm/src/stm32u5/stm32_rcc.c b/arch/arm/src/stm32u5/stm32_rcc.c index 18fb91b391e54..e7f2067ffe62b 100644 --- a/arch/arm/src/stm32u5/stm32_rcc.c +++ b/arch/arm/src/stm32u5/stm32_rcc.c @@ -102,7 +102,7 @@ static inline void rcc_resetbkp(void) * backup data registers and backup SRAM). */ - (void)stm32_pwr_enablebkp(true); + stm32_pwr_enablebkp(true); /* We might be changing RTCSEL - to ensure such changes work, we must * reset the backup domain (having backed up the RTC_MAGIC token) @@ -123,7 +123,7 @@ static inline void rcc_resetbkp(void) putreg32(bkregs[i], STM32U5_RTC_BKR(i)); } - (void)stm32_pwr_enablebkp(false); + stm32_pwr_enablebkp(false); } } #else diff --git a/arch/arm/src/stm32u5/stm32_serial.c b/arch/arm/src/stm32u5/stm32_serial.c index a2e0ff36611d0..4bd823bda15ef 100644 --- a/arch/arm/src/stm32u5/stm32_serial.c +++ b/arch/arm/src/stm32u5/stm32_serial.c @@ -1209,7 +1209,7 @@ static void stm32serial_setsuspend(struct uart_dev_s *dev, bool suspend) #ifdef CONFIG_SERIAL_IFLOWCONTROL if (priv->iflow) { - (void)stm32serial_dmaiflowrestart(priv); + stm32serial_dmaiflowrestart(priv); } else #endif @@ -2644,7 +2644,7 @@ static void stm32serial_dmarxint(FAR struct uart_dev_s *dev, bool enable) { /* Re-enable RX DMA. */ - (void)stm32serial_dmaiflowrestart(priv); + stm32serial_dmaiflowrestart(priv); } #endif } @@ -2804,7 +2804,7 @@ static void stm32serial_dmarxcallback(DMA_HANDLE handle, uint8_t status, { /* Re-enable RX DMA. */ - (void)stm32serial_dmaiflowrestart(priv); + stm32serial_dmaiflowrestart(priv); } #endif } @@ -3075,14 +3075,14 @@ void arm_serialinit(void) /* Register the console */ #if CONSOLE_UART > 0 - (void)uart_register("/dev/console", &g_uart_devs[CONSOLE_UART - 1]->dev); + uart_register("/dev/console", &g_uart_devs[CONSOLE_UART - 1]->dev); #ifndef CONFIG_STM32U5_SERIAL_DISABLE_REORDERING /* If not disabled, register the console UART to ttyS0 and exclude * it from initializing it further down */ - (void)uart_register("/dev/ttyS0", &g_uart_devs[CONSOLE_UART - 1]->dev); + uart_register("/dev/ttyS0", &g_uart_devs[CONSOLE_UART - 1]->dev); minor = 1; #endif @@ -3118,7 +3118,7 @@ void arm_serialinit(void) /* Register USARTs as devices in increasing order */ devname[9] = '0' + minor++; - (void)uart_register(devname, &g_uart_devs[i]->dev); + uart_register(devname, &g_uart_devs[i]->dev); } #endif /* HAVE UART */ } diff --git a/arch/arm/src/stm32u5/stm32_start.c b/arch/arm/src/stm32u5/stm32_start.c index 3a91c9e467af1..e230c91f812de 100644 --- a/arch/arm/src/stm32u5/stm32_start.c +++ b/arch/arm/src/stm32u5/stm32_start.c @@ -77,14 +77,6 @@ const uintptr_t g_idle_topstack = HEAP_BASE; -/**************************************************************************** - * Private Function prototypes - ****************************************************************************/ - -#ifdef CONFIG_ARCH_FPU -static inline void stm32_fpuconfig(void); -#endif - /**************************************************************************** * Private Functions ****************************************************************************/ @@ -113,97 +105,6 @@ static inline void stm32_fpuconfig(void); void __start(void) noinstrument_function; #endif -/**************************************************************************** - * Name: stm32_fpuconfig - * - * Description: - * Configure the FPU. Relative bit settings: - * - * CPACR: Enables access to CP10 and CP11 - * CONTROL.FPCA: Determines whether the FP extension is active in the - * current context: - * FPCCR.ASPEN: Enables automatic FP state preservation, then the - * processor sets this bit to 1 on successful completion of any FP - * instruction. - * FPCCR.LSPEN: Enables lazy context save of FP state. When this is - * done, the processor reserves space on the stack for the FP state, - * but does not save that state information to the stack. - * - * Software must not change the value of the ASPEN bit or LSPEN bit while - * either: - * - the CPACR permits access to CP10 and CP11, that give access to the FP - * extension, or - * - the CONTROL.FPCA bit is set to 1 - * - ****************************************************************************/ - -#ifdef CONFIG_ARCH_FPU -#ifndef CONFIG_ARMV8M_LAZYFPU - -static inline void stm32_fpuconfig(void) -{ - uint32_t regval; - - /* Set CONTROL.FPCA so that we always get the extended context frame - * with the volatile FP registers stacked above the basic context. - */ - - regval = getcontrol(); - regval |= CONTROL_FPCA; - setcontrol(regval); - - /* Ensure that FPCCR.LSPEN is disabled, so that we don't have to contend - * with the lazy FP context save behaviour. Clear FPCCR.ASPEN since we - * are going to turn on CONTROL.FPCA for all contexts. - */ - - regval = getreg32(NVIC_FPCCR); - regval &= ~(NVIC_FPCCR_ASPEN | NVIC_FPCCR_LSPEN); - putreg32(regval, NVIC_FPCCR); - - /* Enable full access to CP10 and CP11 */ - - regval = getreg32(NVIC_CPACR); - regval |= NVIC_CPACR_CP_FULL(10) | NVIC_CPACR_CP_FULL(11); - putreg32(regval, NVIC_CPACR); -} - -#else - -static inline void stm32_fpuconfig(void) -{ - uint32_t regval; - - /* Clear CONTROL.FPCA so that we do not get the extended context frame - * with the volatile FP registers stacked in the saved context. - */ - - regval = getcontrol(); - regval &= ~CONTROL_FPCA; - setcontrol(regval); - - /* Ensure that FPCCR.LSPEN is disabled, so that we don't have to contend - * with the lazy FP context save behaviour. Clear FPCCR.ASPEN since we - * are going to keep CONTROL.FPCA off for all contexts. - */ - - regval = getreg32(NVIC_FPCCR); - regval &= ~(NVIC_FPCCR_ASPEN | NVIC_FPCCR_LSPEN); - putreg32(regval, NVIC_FPCCR); - - /* Enable full access to CP10 and CP11 */ - - regval = getreg32(NVIC_CPACR); - regval |= NVIC_CPACR_CP_FULL(10) | NVIC_CPACR_CP_FULL(11); - putreg32(regval, NVIC_CPACR); -} - -#endif - -#else -# define stm32_fpuconfig() -#endif - /**************************************************************************** * Public Functions ****************************************************************************/ @@ -249,7 +150,7 @@ void __start(void) /* Configure the UART so that we can get debug output as soon as possible */ stm32_clockconfig(); - stm32_fpuconfig(); + arm_fpuconfig(); stm32_lowsetup(); stm32_gpioinit(); showprogress('A'); diff --git a/arch/arm/src/stm32u5/stm32_timerisr.c b/arch/arm/src/stm32u5/stm32_timerisr.c index 55585c6a1a177..3722db768278a 100644 --- a/arch/arm/src/stm32u5/stm32_timerisr.c +++ b/arch/arm/src/stm32u5/stm32_timerisr.c @@ -134,7 +134,7 @@ void up_timer_initialize(void) /* Attach the timer interrupt vector */ - (void)irq_attach(STM32_IRQ_SYSTICK, (xcpt_t)stm32_timerisr, NULL); + irq_attach(STM32_IRQ_SYSTICK, (xcpt_t)stm32_timerisr, NULL); /* Enable SysTick interrupts */ diff --git a/arch/arm/src/stm32u5/stm32u585xx_rcc.c b/arch/arm/src/stm32u5/stm32u585xx_rcc.c index 68a25ceec20c2..ea988b07e06e6 100644 --- a/arch/arm/src/stm32u5/stm32u585xx_rcc.c +++ b/arch/arm/src/stm32u5/stm32u585xx_rcc.c @@ -45,7 +45,7 @@ /* Same for HSI and MSI */ #define HSIRDY_TIMEOUT HSERDY_TIMEOUT -#define MSIRDY_TIMEOUT HSERDY_TIMEOUT +#define MSISRDY_TIMEOUT HSERDY_TIMEOUT /* HSE divisor to yield ~1MHz RTC clock */ @@ -595,42 +595,15 @@ void stm32_stdclockconfig(void) uint32_t regval; volatile int32_t timeout; - /* Enable Internal Multi-Speed System (MSIS) and Kernel (MSIK) Clock */ +#if defined(STM32_BOARD_USEMSIS) + /* Enable Internal Multi-Speed Clock (MSIS) */ -#if defined(STM32_BOARD_USEHSI) || defined(STM32_I2C_USE_HSI16) - /* Enable Internal High-Speed Clock (HSI) */ + /* Wait until the MSIS is either off or ready (or until timeout elapses) */ - regval = getreg32(STM32_RCC_CR); - regval |= RCC_CR_HSION; /* Enable HSI */ - putreg32(regval, STM32_RCC_CR); - - /* Wait until the HSI is ready (or until a timeout elapsed) */ - - for (timeout = HSIRDY_TIMEOUT; timeout > 0; timeout--) - { - /* Check if the HSIRDY flag is the set in the CR */ - - if ((getreg32(STM32_RCC_CR) & RCC_CR_HSIRDY) != 0) - { - /* If so, then break-out with timeout > 0 */ - - break; - } - } -#endif - -#if defined(STM32_BOARD_USEHSI) - /* Already set above */ - -#elif defined(STM32_BOARD_USEMSI) - /* Enable Internal Multi-Speed Clock (MSI) */ - - /* Wait until the MSI is either off or ready (or until a timeout elapsed) */ - - for (timeout = MSIRDY_TIMEOUT; timeout > 0; timeout--) + for (timeout = MSISRDY_TIMEOUT; timeout > 0; timeout--) { if ((regval = getreg32(STM32_RCC_CR)), - (regval & RCC_CR_MSIRDY) || ~(regval & RCC_CR_MSION)) + (regval & RCC_CR_MSISRDY) || ~(regval & RCC_CR_MSISON)) { /* If so, then break-out with timeout > 0 */ @@ -638,19 +611,24 @@ void stm32_stdclockconfig(void) } } - /* setting MSIRANGE */ + /* setting MSISRANGE */ + + putreg32((STM32_BOARD_MSISRANGE | + STM32_BOARD_MSIKRANGE | + RCC_ICSCR1_MSIRGSEL_ICSCR1), + STM32_RCC_ICSCR1); regval = getreg32(STM32_RCC_CR); - regval |= (STM32_BOARD_MSIRANGE | RCC_CR_MSION); /* Enable MSI and frequency */ + regval |= RCC_CR_MSISON; putreg32(regval, STM32_RCC_CR); /* Wait until the MSI is ready (or until a timeout elapsed) */ - for (timeout = MSIRDY_TIMEOUT; timeout > 0; timeout--) + for (timeout = MSISRDY_TIMEOUT; timeout > 0; timeout--) { /* Check if the MSIRDY flag is the set in the CR */ - if ((getreg32(STM32_RCC_CR) & RCC_CR_MSIRDY) != 0) + if ((getreg32(STM32_RCC_CR) & RCC_CR_MSISRDY) != 0) { /* If so, then break-out with timeout > 0 */ @@ -658,29 +636,9 @@ void stm32_stdclockconfig(void) } } -#elif defined(STM32_BOARD_USEHSE) - /* Enable External High-Speed Clock (HSE) */ - - regval = getreg32(STM32_RCC_CR); - regval |= RCC_CR_HSEON; /* Enable HSE */ - putreg32(regval, STM32_RCC_CR); - - /* Wait until the HSE is ready (or until a timeout elapsed) */ - - for (timeout = HSERDY_TIMEOUT; timeout > 0; timeout--) - { - /* Check if the HSERDY flag is the set in the CR */ - - if ((getreg32(STM32_RCC_CR) & RCC_CR_HSERDY) != 0) - { - /* If so, then break-out with timeout > 0 */ - - break; - } - } #else -# error stm32_stdclockconfig(), must have one of STM32_BOARD_USEHSI, STM32_BOARD_USEMSI, STM32_BOARD_USEHSE defined +# error stm32_stdclockconfig() currently only supports STM32_BOARD_USEMSIS #endif @@ -699,195 +657,130 @@ void stm32_stdclockconfig(void) stm32_pwr_enableclk(true); + /* Generate an EPOD booster clock frequency of 4 MHz. FIXME: This must + * be computed based on the MSIS clock to yield a frequency between 4 + * and 16 MHz. Also, the EPOD booster clock is required only for + * SYSCLK frequencies greater than 55MHz. + */ + + regval = getreg32(STM32_RCC_PLL1CFGR); + regval &= ~(RCC_PLL1CFGR_PLL1SRC_MASK | RCC_PLL1CFGR_PLL1MBOOST_MASK); + regval |= RCC_PLL1CFGR_PLL1SRC_MSIS | RCC_PLL1CFGR_PLL1MBOOST_DIV_1; + putreg32(regval, STM32_RCC_PLL1CFGR); + /* Select correct main regulator range */ - regval = getreg32(STM32_PWR_CR1); - regval &= ~PWR_CR1_VOS_MASK; + regval = getreg32(STM32_PWR_VOSR); + regval &= ~PWR_VOSR_VOS_MASK; - if (STM32_SYSCLK_FREQUENCY > 80000000) + if (STM32_SYSCLK_FREQUENCY > 110000000) + { + regval |= PWR_VOSR_VOS_RANGE1; + } + else if (STM32_SYSCLK_FREQUENCY > 55000000) { - regval |= PWR_CR1_VOS_RANGE0; + regval |= PWR_VOSR_VOS_RANGE2; } - else if (STM32_SYSCLK_FREQUENCY > 26000000) + else if (STM32_SYSCLK_FREQUENCY > 25000000) { - regval |= PWR_CR1_VOS_RANGE1; + regval |= PWR_VOSR_VOS_RANGE3; } else { - regval |= PWR_CR1_VOS_RANGE0; + regval |= PWR_VOSR_VOS_RANGE4; } - putreg32(regval, STM32_PWR_CR1); + regval |= PWR_VOSR_BOOSTEN; + + putreg32(regval, STM32_PWR_VOSR); /* Wait for voltage regulator to stabilize */ - while (getreg32(STM32_PWR_SR2) & PWR_SR2_VOSF) + while ((getreg32(STM32_PWR_VOSR) & + (PWR_VOSR_VOSRDY | PWR_VOSR_BOOSTRDY)) != + (PWR_VOSR_VOSRDY | PWR_VOSR_BOOSTRDY)) { } - /* Set the HCLK source/divider */ - - regval = getreg32(STM32_RCC_CFGR); - regval &= ~RCC_CFGR_HPRE_MASK; - regval |= STM32_RCC_CFGR_HPRE; - putreg32(regval, STM32_RCC_CFGR); - - /* Set the PCLK2 divider */ - - regval = getreg32(STM32_RCC_CFGR); - regval &= ~RCC_CFGR_PPRE2_MASK; - regval |= STM32_RCC_CFGR_PPRE2; - putreg32(regval, STM32_RCC_CFGR); - - /* Set the PCLK1 divider */ - - regval = getreg32(STM32_RCC_CFGR); - regval &= ~RCC_CFGR_PPRE1_MASK; - regval |= STM32_RCC_CFGR_PPRE1; - putreg32(regval, STM32_RCC_CFGR); - -#ifdef CONFIG_STM32U5_RTC_HSECLOCK - /* Set the RTC clock divisor */ - - regval = getreg32(STM32_RCC_CFGR); - regval &= ~RCC_CFGR_RTCPRE_MASK; - regval |= RCC_CFGR_RTCPRE(HSE_DIVISOR); - putreg32(regval, STM32_RCC_CFGR); -#endif - - /* Set the PLL source and main divider */ - - regval = getreg32(STM32_RCC_PLLCFG); - - /* Configure Main PLL */ - - /* Set the PLL dividers and multipliers to configure the main PLL */ - - regval = (STM32_PLLCFG_PLLM | STM32_PLLCFG_PLLN | - STM32_PLLCFG_PLLP | STM32_PLLCFG_PLLQ | - STM32_PLLCFG_PLLR); - -#ifdef STM32_PLLCFG_PLLP_ENABLED - regval |= RCC_PLLCFG_PLLPEN; -#endif -#ifdef STM32_PLLCFG_PLLQ_ENABLED - regval |= RCC_PLLCFG_PLLQEN; -#endif -#ifdef STM32_PLLCFG_PLLR_ENABLED - regval |= RCC_PLLCFG_PLLREN; -#endif - - /* XXX The choice of clock source to PLL (all three) is independent - * of the sys clock source choice, review the STM32_BOARD_USEHSI - * name; probably split it into two, one for PLL source and one - * for sys clock source. + /* Configure 4 wait states and prefetch for FLASH access. FIXME: Flash + * wait states must be computed based on SYSCLK frequency. */ -#ifdef STM32_BOARD_USEHSI - regval |= RCC_PLLCFG_PLLSRC_HSI16; -#elif defined(STM32_BOARD_USEMSI) - regval |= RCC_PLLCFG_PLLSRC_MSI; -#else /* if STM32_BOARD_USEHSE */ - regval |= RCC_PLLCFG_PLLSRC_HSE; -#endif - - putreg32(regval, STM32_RCC_PLLCFG); - - /* Enable the main PLL */ - - regval = getreg32(STM32_RCC_CR); - regval |= RCC_CR_PLLON; - putreg32(regval, STM32_RCC_CR); + regval = FLASH_ACR_LATENCY_4 | FLASH_ACR_PRFTEN; + putreg32(regval, STM32_FLASH_ACR); - /* Wait until the PLL is ready */ + /* Set the HCLK, PCLK1 and PCLK2 dividers */ - while ((getreg32(STM32_RCC_CR) & RCC_CR_PLLRDY) == 0) - { - } + regval = getreg32(STM32_RCC_CFGR2); + regval &= ~(RCC_CFGR2_HPRE_MASK | + RCC_CFGR2_PPRE1_MASK | + RCC_CFGR2_PPRE2_MASK); + regval |= STM32_RCC_CFGR2_HPRE | + STM32_RCC_CFGR2_PPRE1 | + STM32_RCC_CFGR2_PPRE2; + putreg32(regval, STM32_RCC_CFGR2); -#ifdef CONFIG_STM32U5_SAI1PLL - /* Configure SAI1 PLL */ + /* Set the PCLK3 divider */ - regval = getreg32(STM32_RCC_PLLSAI1CFG); + regval = getreg32(STM32_RCC_CFGR3); + regval &= ~RCC_CFGR3_PPRE3_MASK; + regval |= STM32_RCC_CFGR3_PPRE3; + putreg32(regval, STM32_RCC_CFGR3); - /* Set the PLL dividers and multipliers to configure the SAI1 PLL */ +#ifdef CONFIG_STM32U5_RTC_HSECLOCK - regval = (STM32_PLLSAI1CFG_PLLN | STM32_PLLSAI1CFG_PLLP - | STM32_PLLSAI1CFG_PLLQ | STM32_PLLSAI1CFG_PLLR); +# error stm32_stdclockconfig() currently doesn not support CONFIG_STM32U5_RTC_HSECLOCK -#ifdef STM32_PLLSAI1CFG_PLLP_ENABLED - regval |= RCC_PLLSAI1CFG_PLLPEN; -#endif -#ifdef STM32_PLLSAI1CFG_PLLQ_ENABLED - regval |= RCC_PLLSAI1CFG_PLLQEN; -#endif -#ifdef STM32_PLLSAI1CFG_PLLR_ENABLED - regval |= RCC_PLLSAI1CFG_PLLREN; #endif - putreg32(regval, STM32_RCC_PLLSAI1CFG); + /* Set the PLL1 source, dividers and multipliers */ - /* Enable the SAI1 PLL */ + regval = STM32_RCC_PLL1DIVR_PLL1N | + STM32_RCC_PLL1DIVR_PLL1P | + STM32_RCC_PLL1DIVR_PLL1Q | + STM32_RCC_PLL1DIVR_PLL1R; - regval = getreg32(STM32_RCC_CR); - regval |= RCC_CR_PLLSAI1ON; - putreg32(regval, STM32_RCC_CR); + putreg32(regval, STM32_RCC_PLL1DIVR); - /* Wait until the PLL is ready */ - - while ((getreg32(STM32_RCC_CR) & RCC_CR_PLLSAI1RDY) == 0) - { - } + regval = RCC_PLL1CFGR_PLL1SRC_MSIS | + RCC_PLL1CFGR_PLL1RGE_4_TO_8MHZ | + STM32_RCC_PLL1CFGR_PLL1M | + RCC_PLL1CFGR_PLL1MBOOST_DIV_1; +#ifdef STM32_RCC_PLL1CFGR_PLL1P_ENABLED + regval |= RCC_PLL1CFGR_PLL1PEN; #endif - -#ifdef CONFIG_STM32U5_SAI2PLL - /* Configure SAI2 PLL */ - - regval = getreg32(STM32_RCC_PLLSAI2CFG); - - /* Set the PLL dividers and multipliers to configure the SAI2 PLL */ - - regval = (STM32_PLLSAI2CFG_PLLN | STM32_PLLSAI2CFG_PLLP | - STM32_PLLSAI2CFG_PLLR); - -#ifdef STM32_PLLSAI2CFG_PLLP_ENABLED - regval |= RCC_PLLSAI2CFG_PLLPEN; +#ifdef STM32_RCC_PLL1CFGR_PLL1Q_ENABLED + regval |= RCC_PLL1CFGR_PLL1QEN; #endif -#ifdef STM32_PLLSAI2CFG_PLLR_ENABLED - regval |= RCC_PLLSAI2CFG_PLLREN; +#ifdef STM32_RCC_PLL1CFGR_PLL1R_ENABLED + regval |= RCC_PLL1CFGR_PLL1REN; #endif - putreg32(regval, STM32_RCC_PLLSAI2CFG); + putreg32(regval, STM32_RCC_PLL1CFGR); - /* Enable the SAI2 PLL */ + /* Enable PLL1 */ regval = getreg32(STM32_RCC_CR); - regval |= RCC_CR_PLLSAI2ON; + regval |= RCC_CR_PLL1ON; putreg32(regval, STM32_RCC_CR); - /* Wait until the PLL is ready */ + /* Wait until PLL1 is ready */ - while ((getreg32(STM32_RCC_CR) & RCC_CR_PLLSAI2RDY) == 0) + while ((getreg32(STM32_RCC_CR) & RCC_CR_PLL1RDY) == 0) { } -#endif - - /* Enable FLASH 5 wait states */ - - regval = FLASH_ACR_LATENCY_5; - putreg32(regval, STM32_FLASH_ACR); - /* Select the main PLL as system clock source */ + /* Select the PLL1 as system clock source */ - regval = getreg32(STM32_RCC_CFGR); - regval &= ~RCC_CFGR_SW_MASK; - regval |= RCC_CFGR_SW_PLL; - putreg32(regval, STM32_RCC_CFGR); + regval = getreg32(STM32_RCC_CFGR1); + regval &= ~RCC_CFGR1_SW_MASK; + regval |= RCC_CFGR1_SW_PLL; + putreg32(regval, STM32_RCC_CFGR1); - /* Wait until the PLL source is used as the system clock source */ + /* Wait until PLL1 source is used as the system clock source */ - while ((getreg32(STM32_RCC_CFGR) & RCC_CFGR_SWS_MASK) != - RCC_CFGR_SWS_PLL) + while ((getreg32(STM32_RCC_CFGR1) & RCC_CFGR1_SWS_MASK) != + RCC_CFGR1_SWS_PLL) { } diff --git a/arch/arm/src/str71x/Make.defs b/arch/arm/src/str71x/Make.defs index 29dacbc5d4342..4d38b40360bb8 100644 --- a/arch/arm/src/str71x/Make.defs +++ b/arch/arm/src/str71x/Make.defs @@ -18,28 +18,9 @@ # ############################################################################## -HEAD_ASRC = str71x_head.S - -CMN_ASRCS = arm_saveusercontext.S arm_fullcontextrestore.S arm_vectors.S -CMN_ASRCS += vfork.S +include arm/Make.defs -CMN_CSRCS = arm_allocateheap.c arm_assert.c arm_blocktask.c -CMN_CSRCS += arm_createstack.c arm_dataabort.c arm_mdelay.c arm_udelay.c -CMN_CSRCS += arm_exit.c arm_initialize.c arm_initialstate.c -CMN_CSRCS += arm_interruptcontext.c arm_prefetchabort.c arm_releasepending.c -CMN_CSRCS += arm_releasestack.c arm_reprioritizertr.c arm_stackframe.c -CMN_CSRCS += arm_syscall.c arm_unblocktask.c arm_undefinedinsn.c arm_usestack.c -CMN_CSRCS += arm_schedulesigaction.c arm_sigdeliver.c -CMN_CSRCS += arm_lowputs.c arm_vfork.c arm_puts.c arm_tcbinfo.c -CMN_CSRCS += arm_switchcontext.c - -ifneq ($(CONFIG_ARCH_IDLE_CUSTOM),y) -CMN_CSRCS += arm_idle.c -endif - -ifeq ($(CONFIG_STACK_COLORATION),y) -CMN_CSRCS += arm_checkstack.c -endif +HEAD_ASRC = str71x_head.S CHIP_CSRCS = str71x_prccu.c str71x_lowputc.c str71x_decodeirq.c str71x_irq.c CHIP_CSRCS += str71x_serial.c diff --git a/arch/arm/src/tiva/Make.defs b/arch/arm/src/tiva/Make.defs index 692e6a07b38cd..3c4b66324d2a7 100644 --- a/arch/arm/src/tiva/Make.defs +++ b/arch/arm/src/tiva/Make.defs @@ -18,60 +18,13 @@ # ############################################################################ -CMN_ASRCS = arm_saveusercontext.S arm_fullcontextrestore.S -CMN_ASRCS += arm_testset.S arm_fetchadd.S vfork.S - -CMN_CSRCS = arm_assert.c arm_blocktask.c arm_createstack.c -CMN_CSRCS += arm_doirq.c arm_exit.c arm_hardfault.c arm_initialize.c -CMN_CSRCS += arm_initialstate.c arm_interruptcontext.c arm_mdelay.c -CMN_CSRCS += arm_memfault.c arm_modifyreg8.c arm_modifyreg16.c arm_modifyreg32.c -CMN_CSRCS += arm_releasepending.c arm_releasestack.c arm_reprioritizertr.c -CMN_CSRCS += arm_schedulesigaction.c arm_sigdeliver.c arm_stackframe.c -CMN_CSRCS += arm_svcall.c arm_trigger_irq.c arm_unblocktask.c arm_udelay.c -CMN_CSRCS += arm_usestack.c arm_vfork.c arm_switchcontext.c arm_puts.c -CMN_CSRCS += arm_tcbinfo.c - -ifeq ($(CONFIG_ARM_SEMIHOSTING_HOSTFS),y) - CMN_CSRCS += arm_hostfs.c -endif +include armv7-m/Make.defs ifneq ($(CONFIG_ARCH_IDLE_CUSTOM),y) - CMN_CSRCS += tiva_idle.c -endif - -ifeq ($(CONFIG_ARMV7M_LAZYFPU),y) - CMN_ASRCS += arm_lazyexception.S -else - CMN_ASRCS += arm_exception.S -endif - -CMN_CSRCS += arm_vectors.c - -ifeq ($(CONFIG_ARCH_FPU),y) - CMN_ASRCS += arm_fpu.S -endif - -ifeq ($(CONFIG_ARCH_RAMVECTORS),y) - CMN_CSRCS += arm_ramvec_initialize.c arm_ramvec_attach.c -endif - -ifeq ($(CONFIG_STACK_COLORATION),y) - CMN_CSRCS += arm_checkstack.c -endif - -ifeq ($(CONFIG_ARM_MPU),y) -CMN_CSRCS += arm_mpu.c -endif - -ifeq ($(CONFIG_BUILD_PROTECTED),y) - CMN_CSRCS += arm_task_start.c arm_pthread_start.c - CMN_CSRCS += arm_signal_dispatch.c - CMN_UASRCS += arm_signal_handler.S -else - CMN_CSRCS += arm_allocateheap.c + CHIP_CSRCS += tiva_idle.c endif -CHIP_CSRCS = tiva_allocateheap.c tiva_irq.c tiva_lowputc.c tiva_serial.c +CHIP_CSRCS += tiva_allocateheap.c tiva_irq.c tiva_lowputc.c tiva_serial.c CHIP_CSRCS += tiva_ssi.c ifeq ($(CONFIG_ARCH_CHIP_LM3S),y) diff --git a/arch/arm/src/tiva/cc13xx/cc13xx_start.c b/arch/arm/src/tiva/cc13xx/cc13xx_start.c index f077e90693dd8..7770af4180db8 100644 --- a/arch/arm/src/tiva/cc13xx/cc13xx_start.c +++ b/arch/arm/src/tiva/cc13xx/cc13xx_start.c @@ -96,97 +96,6 @@ void cc13xx_trim_device(void); # define showprogress(c) #endif -/**************************************************************************** - * Name: tiva_fpuconfig - * - * Description: - * Configure the FPU. Relative bit settings: - * - * CPACR: Enables access to CP10 and CP11 - * CONTROL.FPCA: Determines whether the FP extension is active in the - * current context: - * FPCCR.ASPEN: Enables automatic FP state preservation, then the - * processor sets this bit to 1 on successful completion of any FP - * instruction. - * FPCCR.LSPEN: Enables lazy context save of FP state. When this is - * done, the processor reserves space on the stack for the FP state, - * but does not save that state information to the stack. - * - * Software must not change the value of the ASPEN bit or LSPEN bit while - * either: - * - the CPACR permits access to CP10 and CP11, that give access to the FP - * extension, or - * - the CONTROL.FPCA bit is set to 1 - * - ****************************************************************************/ - -#ifdef CONFIG_ARCH_FPU -#ifndef CONFIG_ARMV7M_LAZYFPU - -static inline void tiva_fpuconfig(void) -{ - uint32_t regval; - - /* Set CONTROL.FPCA so that we always get the extended context frame - * with the volatile FP registers stacked above the basic context. - */ - - regval = getcontrol(); - regval |= CONTROL_FPCA; - setcontrol(regval); - - /* Ensure that FPCCR.LSPEN is disabled, so that we don't have to contend - * with the lazy FP context save behaviour. Clear FPCCR.ASPEN since we - * are going to turn on CONTROL.FPCA for all contexts. - */ - - regval = getreg32(NVIC_FPCCR); - regval &= ~(NVIC_FPCCR_ASPEN | NVIC_FPCCR_LSPEN); - putreg32(regval, NVIC_FPCCR); - - /* Enable full access to CP10 and CP11 */ - - regval = getreg32(NVIC_CPACR); - regval |= NVIC_CPACR_CP_FULL(10) | NVIC_CPACR_CP_FULL(11); - putreg32(regval, NVIC_CPACR); -} - -#else - -static inline void tiva_fpuconfig(void) -{ - uint32_t regval; - - /* Clear CONTROL.FPCA so that we do not get the extended context frame - * with the volatile FP registers stacked in the saved context. - */ - - regval = getcontrol(); - regval &= ~CONTROL_FPCA; - setcontrol(regval); - - /* Ensure that FPCCR.LSPEN is disabled, so that we don't have to contend - * with the lazy FP context save behavior. Clear FPCCR.ASPEN since we - * are going to keep CONTROL.FPCA off for all contexts. - */ - - regval = getreg32(NVIC_FPCCR); - regval &= ~(NVIC_FPCCR_ASPEN | NVIC_FPCCR_LSPEN); - putreg32(regval, NVIC_FPCCR); - - /* Enable full access to CP10 and CP11 */ - - regval = getreg32(NVIC_CPACR); - regval |= NVIC_CPACR_CP_FULL(10) | NVIC_CPACR_CP_FULL(11); - putreg32(regval, NVIC_CPACR); -} - -#endif - -#else -# define tiva_fpuconfig() -#endif - /**************************************************************************** * Public Functions ****************************************************************************/ @@ -231,7 +140,7 @@ void __start(void) */ tiva_lowsetup(); - tiva_fpuconfig(); + arm_fpuconfig(); showprogress('A'); #ifdef CONFIG_BOOT_RUNFROMFLASH diff --git a/arch/arm/src/tiva/common/lmxx_tm4c_start.c b/arch/arm/src/tiva/common/lmxx_tm4c_start.c index 716856ee6c5b1..aa3730e78bc3c 100644 --- a/arch/arm/src/tiva/common/lmxx_tm4c_start.c +++ b/arch/arm/src/tiva/common/lmxx_tm4c_start.c @@ -87,97 +87,6 @@ const uintptr_t g_idle_topstack = HEAP_BASE; # define showprogress(c) #endif -/**************************************************************************** - * Name: tiva_fpuconfig - * - * Description: - * Configure the FPU. Relative bit settings: - * - * CPACR: Enables access to CP10 and CP11 - * CONTROL.FPCA: Determines whether the FP extension is active in the - * current context: - * FPCCR.ASPEN: Enables automatic FP state preservation, then the - * processor sets this bit to 1 on successful completion of any FP - * instruction. - * FPCCR.LSPEN: Enables lazy context save of FP state. When this is - * done, the processor reserves space on the stack for the FP state, - * but does not save that state information to the stack. - * - * Software must not change the value of the ASPEN bit or LSPEN bit while - * either: - * - the CPACR permits access to CP10 and CP11, that give access to the FP - * extension, or - * - the CONTROL.FPCA bit is set to 1 - * - ****************************************************************************/ - -#ifdef CONFIG_ARCH_FPU -#ifndef CONFIG_ARMV7M_LAZYFPU - -static inline void tiva_fpuconfig(void) -{ - uint32_t regval; - - /* Set CONTROL.FPCA so that we always get the extended context frame - * with the volatile FP registers stacked above the basic context. - */ - - regval = getcontrol(); - regval |= CONTROL_FPCA; - setcontrol(regval); - - /* Ensure that FPCCR.LSPEN is disabled, so that we don't have to contend - * with the lazy FP context save behaviour. Clear FPCCR.ASPEN since we - * are going to turn on CONTROL.FPCA for all contexts. - */ - - regval = getreg32(NVIC_FPCCR); - regval &= ~(NVIC_FPCCR_ASPEN | NVIC_FPCCR_LSPEN); - putreg32(regval, NVIC_FPCCR); - - /* Enable full access to CP10 and CP11 */ - - regval = getreg32(NVIC_CPACR); - regval |= NVIC_CPACR_CP_FULL(10) | NVIC_CPACR_CP_FULL(11); - putreg32(regval, NVIC_CPACR); -} - -#else - -static inline void tiva_fpuconfig(void) -{ - uint32_t regval; - - /* Clear CONTROL.FPCA so that we do not get the extended context frame - * with the volatile FP registers stacked in the saved context. - */ - - regval = getcontrol(); - regval &= ~CONTROL_FPCA; - setcontrol(regval); - - /* Ensure that FPCCR.LSPEN is disabled, so that we don't have to contend - * with the lazy FP context save behavior. Clear FPCCR.ASPEN since we - * are going to keep CONTROL.FPCA off for all contexts. - */ - - regval = getreg32(NVIC_FPCCR); - regval &= ~(NVIC_FPCCR_ASPEN | NVIC_FPCCR_LSPEN); - putreg32(regval, NVIC_FPCCR); - - /* Enable full access to CP10 and CP11 */ - - regval = getreg32(NVIC_CPACR); - regval |= NVIC_CPACR_CP_FULL(10) | NVIC_CPACR_CP_FULL(11); - putreg32(regval, NVIC_CPACR); -} - -#endif - -#else -# define tiva_fpuconfig() -#endif - /**************************************************************************** * Public Functions ****************************************************************************/ @@ -201,7 +110,7 @@ void __start(void) tiva_clock_configure(); tiva_lowsetup(); - tiva_fpuconfig(); + arm_fpuconfig(); showprogress('A'); /* Clear .bss. We'll do this inline (vs. calling memset) just to be diff --git a/arch/arm/src/tms570/Make.defs b/arch/arm/src/tms570/Make.defs index 3df1b7ea76969..3abfbef8227a9 100644 --- a/arch/arm/src/tms570/Make.defs +++ b/arch/arm/src/tms570/Make.defs @@ -18,66 +18,7 @@ # ############################################################################ -# The vector table is the "head" object, i.e., the one that must forced into -# the link in order to draw in all of the other components - -HEAD_ASRC = arm_vectortab.S - -# Common assembly language files - -CMN_ASRCS += arm_vectortab.S arm_vectors.S arm_head.S arm_fullcontextrestore.S -CMN_ASRCS += arm_saveusercontext.S arm_vectoraddrexcptn.S -CMN_ASRCS += arm_testset.S arm_fetchadd.S vfork.S -CMN_ASRCS += cp15_coherent_dcache.S cp15_invalidate_dcache.S -CMN_ASRCS += cp15_clean_dcache.S cp15_flush_dcache.S -CMN_ASRCS += cp15_clean_dcache_all.S cp15_flush_dcache_all.S -CMN_ASRCS += cp15_invalidate_dcache_all.S cp15_cache_size.S arm_tcbinfo.c - -# Configuration dependent assembly language files - -ifeq ($(CONFIG_ARCH_FPU),y) -CMN_ASRCS += arm_fpuconfig.S -endif - -# Common C source files - -CMN_CSRCS = arm_allocateheap.c arm_initialize.c arm_interruptcontext.c -CMN_CSRCS += arm_exit.c arm_createstack.c arm_releasestack.c arm_usestack.c -CMN_CSRCS += arm_vfork.c arm_puts.c arm_mdelay.c arm_stackframe.c arm_udelay.c -CMN_CSRCS += arm_modifyreg8.c arm_modifyreg16.c arm_modifyreg32.c - -CMN_CSRCS += arm_assert.c arm_blocktask.c arm_dataabort.c -CMN_CSRCS += arm_doirq.c arm_initialstate.c arm_prefetchabort.c -CMN_CSRCS += arm_releasepending.c arm_reprioritizertr.c -CMN_CSRCS += arm_schedulesigaction.c arm_sigdeliver.c arm_syscall.c -CMN_CSRCS += arm_unblocktask.c arm_undefinedinsn.c -CMN_CSRCS += arm_switchcontext.c - -# Configuration dependent C files - -ifneq ($(CONFIG_ARCH_IDLE_CUSTOM),y) -CMN_CSRCS += arm_idle.c -endif - -ifeq ($(CONFIG_BUILD_PROTECTED),y) -CMN_CSRCS += arm_mpu.c arm_task_start.c arm_pthread_start.c -CMN_CSRCS += arm_signal_dispatch.c -CMN_UASRCS += arm_signal_handler.S -endif - -ifeq ($(CONFIG_ARMV7R_L2CC_PL310),y) -CMN_CSRCS += arm_l2cc_pl310.c -endif - -CMN_CSRCS += arm_cache.c - -ifeq ($(CONFIG_ARCH_FPU),y) -CMN_ASRCS += arm_savefpu.S arm_restorefpu.S -endif - -ifeq ($(CONFIG_STACK_COLORATION),y) -CMN_CSRCS += arm_checkstack.c -endif +include armv7-r/Make.defs # SAMA5-specific C source files diff --git a/arch/arm/src/tms570/tms570_boot.c b/arch/arm/src/tms570/tms570_boot.c index c9e7958b37355..dfdadd8dd7c91 100644 --- a/arch/arm/src/tms570/tms570_boot.c +++ b/arch/arm/src/tms570/tms570_boot.c @@ -54,7 +54,6 @@ #include "chip.h" #include "arm.h" -#include "fpu.h" #include "sctlr.h" #include "arm_internal.h" @@ -375,11 +374,9 @@ void arm_boot(void) tms570_esm_initialize(); -#ifdef CONFIG_ARCH_FPU /* Initialize the FPU */ arm_fpuconfig(); -#endif #ifdef CONFIG_ARMV7R_MEMINIT /* Initialize the .bss and .data sections as well as RAM functions diff --git a/arch/arm/src/xmc4/Make.defs b/arch/arm/src/xmc4/Make.defs index 3e0a6f4072953..20604841612b9 100644 --- a/arch/arm/src/xmc4/Make.defs +++ b/arch/arm/src/xmc4/Make.defs @@ -18,64 +18,7 @@ # ############################################################################ -CMN_ASRCS = arm_saveusercontext.S arm_fullcontextrestore.S -CMN_ASRCS += arm_testset.S arm_fetchadd.S vfork.S - -CMN_CSRCS = arm_assert.c arm_blocktask.c arm_createstack.c -CMN_CSRCS += arm_doirq.c arm_exit.c arm_initialize.c arm_initialstate.c -CMN_CSRCS += arm_hardfault.c arm_interruptcontext.c arm_memfault.c arm_mdelay.c -CMN_CSRCS += arm_modifyreg8.c arm_modifyreg16.c arm_modifyreg32.c -CMN_CSRCS += arm_releasestack.c arm_reprioritizertr.c arm_schedulesigaction.c -CMN_CSRCS += arm_releasepending.c arm_sigdeliver.c arm_stackframe.c arm_svcall.c -CMN_CSRCS += arm_systemreset.c arm_udelay.c arm_unblocktask.c arm_usestack.c -CMN_CSRCS += arm_vfork.c arm_switchcontext.c arm_puts.c arm_tcbinfo.c - -ifeq ($(CONFIG_ARMV7M_STACKCHECK),y) -CMN_CSRCS += arm_stackcheck.c -endif - -ifeq ($(CONFIG_ARMV7M_LAZYFPU),y) -CMN_ASRCS += arm_lazyexception.S -else -CMN_ASRCS += arm_exception.S -endif -CMN_CSRCS += arm_vectors.c - -ifeq ($(CONFIG_ARCH_RAMVECTORS),y) -CMN_CSRCS += arm_ramvec_initialize.c arm_ramvec_attach.c -endif - -ifeq ($(CONFIG_ARM_MPU),y) -CMN_CSRCS += arm_mpu.c -endif - -ifeq ($(CONFIG_BUILD_PROTECTED),y) -CMN_CSRCS += arm_task_start.c arm_pthread_start.c -CMN_CSRCS += arm_signal_dispatch.c -CMN_UASRCS += arm_signal_handler.S -endif - -ifeq ($(CONFIG_STACK_COLORATION),y) -CMN_CSRCS += arm_checkstack.c -endif - -# Use of common/arm_etherstub.c is deprecated. The preferred mechanism is to -# use CONFIG_NETDEV_LATEINIT=y to suppress the call to arm_netinitialize() in -# up_initialize(). Then this stub would not be needed. - -ifeq ($(CONFIG_NET),y) -ifneq ($(CONFIG_XMC4_ENET),y) -CMN_CSRCS += arm_etherstub.c -endif -endif - -ifeq ($(CONFIG_ARCH_FPU),y) -CMN_ASRCS += arm_fpu.S -endif - -ifeq ($(CONFIG_ARMV7M_ITMSYSLOG),y) -CMN_CSRCS += arm_itm_syslog.c -endif +include armv7-m/Make.defs # Required XMC4xxx files diff --git a/arch/arm/src/xmc4/xmc4_start.c b/arch/arm/src/xmc4/xmc4_start.c index 11d3968e751d6..d36870a84240c 100644 --- a/arch/arm/src/xmc4/xmc4_start.c +++ b/arch/arm/src/xmc4/xmc4_start.c @@ -44,9 +44,6 @@ * Private Function prototypes ****************************************************************************/ -#ifdef CONFIG_ARCH_FPU -static inline void xmc4_fpu_config(void); -#endif static inline void xmc4_unaligned(void); static inline void xmc4_flash_waitstates(void); @@ -119,97 +116,6 @@ const uintptr_t g_idle_topstack = HEAP_BASE; void __start(void) noinstrument_function; #endif -/**************************************************************************** - * Name: xmc4_fpu_config - * - * Description: - * Configure the FPU. Relative bit settings: - * - * CPACR: Enables access to CP10 and CP11 - * CONTROL.FPCA: Determines whether the FP extension is active in the - * current context: - * FPCCR.ASPEN: Enables automatic FP state preservation, then the - * processor sets this bit to 1 on successful completion of any FP - * instruction. - * FPCCR.LSPEN: Enables lazy context save of FP state. When this is - * done, the processor reserves space on the stack for the FP state, - * but does not save that state information to the stack. - * - * Software must not change the value of the ASPEN bit or LSPEN bit while - * either: - * - the CPACR permits access to CP10 and CP11, that give access to the FP - * extension, or - * - the CONTROL.FPCA bit is set to 1 - * - ****************************************************************************/ - -#ifdef CONFIG_ARCH_FPU -#ifndef CONFIG_ARMV7M_LAZYFPU - -static inline void xmc4_fpu_config(void) -{ - uint32_t regval; - - /* Set CONTROL.FPCA so that we always get the extended context frame - * with the volatile FP registers stacked above the basic context. - */ - - regval = getcontrol(); - regval |= CONTROL_FPCA; - setcontrol(regval); - - /* Ensure that FPCCR.LSPEN is disabled, so that we don't have to contend - * with the lazy FP context save behaviour. Clear FPCCR.ASPEN since we - * are going to turn on CONTROL.FPCA for all contexts. - */ - - regval = getreg32(NVIC_FPCCR); - regval &= ~(NVIC_FPCCR_ASPEN | NVIC_FPCCR_LSPEN); - putreg32(regval, NVIC_FPCCR); - - /* Enable full access to CP10 and CP11 */ - - regval = getreg32(NVIC_CPACR); - regval |= NVIC_CPACR_CP_FULL(10) | NVIC_CPACR_CP_FULL(11); - putreg32(regval, NVIC_CPACR); -} - -#else - -static inline void xmc4_fpu_config(void) -{ - uint32_t regval; - - /* Clear CONTROL.FPCA so that we do not get the extended context frame - * with the volatile FP registers stacked in the saved context. - */ - - regval = getcontrol(); - regval &= ~CONTROL_FPCA; - setcontrol(regval); - - /* Ensure that FPCCR.LSPEN is disabled, so that we don't have to contend - * with the lazy FP context save behaviour. Clear FPCCR.ASPEN since we - * are going to keep CONTROL.FPCA off for all contexts. - */ - - regval = getreg32(NVIC_FPCCR); - regval &= ~(NVIC_FPCCR_ASPEN | NVIC_FPCCR_LSPEN); - putreg32(regval, NVIC_FPCCR); - - /* Enable full access to CP10 and CP11 */ - - regval = getreg32(NVIC_CPACR); - regval |= NVIC_CPACR_CP_FULL(10) | NVIC_CPACR_CP_FULL(11); - putreg32(regval, NVIC_CPACR); -} - -#endif - -#else -# define xmc4_fpu_config() -#endif - /**************************************************************************** * Name: xmc4_unaligned * @@ -330,7 +236,7 @@ void __start(void) /* Initialize the FPU (if configured) */ - xmc4_fpu_config(); + arm_fpuconfig(); showprogress('B'); #ifdef USE_EARLYSERIALINIT diff --git a/arch/avr/src/at90usb/at90usb_serial.c b/arch/avr/src/at90usb/at90usb_serial.c index 4f9cdc9cba9b1..44b353297b419 100644 --- a/arch/avr/src/at90usb/at90usb_serial.c +++ b/arch/avr/src/at90usb/at90usb_serial.c @@ -232,7 +232,7 @@ static int usart1_attach(struct uart_dev_s *dev) irq_attach(AT90USB_IRQ_U1RX, usart1_rxinterrupt, NULL); irq_attach(AT90USB_IRQ_U1DRE, usart1_txinterrupt, NULL); - /* (void)irq_attach(AT90USB_IRQ_U1TX, usart1_txinterrupt, NULL); */ + /* irq_attach(AT90USB_IRQ_U1TX, usart1_txinterrupt, NULL); */ return OK; } @@ -258,7 +258,7 @@ static void usart1_detach(struct uart_dev_s *dev) irq_detach(AT90USB_IRQ_U1RX); irq_detach(AT90USB_IRQ_U1DRE); - /* (void)irq_detach(AT90USB_IRQ_U1TX); */ + /* irq_detach(AT90USB_IRQ_U1TX); */ } /**************************************************************************** diff --git a/arch/avr/src/atmega/atmega_serial.c b/arch/avr/src/atmega/atmega_serial.c index 3f36b22076319..94ff3dc955dc6 100644 --- a/arch/avr/src/atmega/atmega_serial.c +++ b/arch/avr/src/atmega/atmega_serial.c @@ -371,7 +371,7 @@ static int usart0_attach(struct uart_dev_s *dev) irq_attach(ATMEGA_IRQ_U0RX, usart0_rxinterrupt, NULL); irq_attach(ATMEGA_IRQ_U0DRE, usart0_txinterrupt, NULL); - /* (void)irq_attach(ATMEGA_IRQ_U0TX, usart0_txinterrupt, NULL); */ + /* irq_attach(ATMEGA_IRQ_U0TX, usart0_txinterrupt, NULL); */ return OK; } @@ -395,7 +395,7 @@ static int usart1_attach(struct uart_dev_s *dev) irq_attach(ATMEGA_IRQ_U1RX, usart1_rxinterrupt, NULL); irq_attach(ATMEGA_IRQ_U1DRE, usart1_txinterrupt, NULL); - /* (void)irq_attach(ATMEGA_IRQ_U1TX, usart1_txinterrupt, NULL); */ + /* irq_attach(ATMEGA_IRQ_U1TX, usart1_txinterrupt, NULL); */ return OK; } @@ -423,7 +423,7 @@ static void usart0_detach(struct uart_dev_s *dev) irq_detach(ATMEGA_IRQ_U0RX); irq_detach(ATMEGA_IRQ_U0DRE); - /* (void)irq_detach(ATMEGA_IRQ_U0TX); */ + /* irq_detach(ATMEGA_IRQ_U0TX); */ } #endif @@ -439,7 +439,7 @@ static void usart1_detach(struct uart_dev_s *dev) irq_detach(ATMEGA_IRQ_U1RX); irq_detach(ATMEGA_IRQ_U1DRE); - /* (void)irq_detach(ATMEGA_IRQ_U1TX); */ + /* irq_detach(ATMEGA_IRQ_U1TX); */ } #endif diff --git a/arch/avr/src/avr/Toolchain.defs b/arch/avr/src/avr/Toolchain.defs index bed4f32ea5033..eecf86ca79d8a 100644 --- a/arch/avr/src/avr/Toolchain.defs +++ b/arch/avr/src/avr/Toolchain.defs @@ -80,14 +80,33 @@ else ifeq ($(CONFIG_ARCH_CHIP_AT90USB1287),y) else ifeq ($(CONFIG_ARCH_CHIP_ATMEGA2560),y) ARCHCPUFLAGS += -mmcu=atmega2560 LDFLAGS += -mavr6 -else - $(error "No valid CONFIG_ARCH_CHIP_ set in the configuration") endif ifeq ($(CONFIG_DEBUG_CUSTOMOPT),y) - MAXOPTIMIZATION := $(CONFIG_DEBUG_OPTLEVEL) + ARCHOPTIMIZATION += $(CONFIG_DEBUG_OPTLEVEL) +else ifeq ($(CONFIG_DEBUG_FULLOPT),y) + ARCHOPTIMIZATION += -O2 +endif + +ifneq ($(CONFIG_DEBUG_NOOPT),y) + ARCHOPTIMIZATION += -fno-strict-aliasing +endif + +ifeq ($(CONFIG_FRAME_POINTER),y) + ARCHOPTIMIZATION += -fno-omit-frame-pointer -fno-optimize-sibling-calls else - MAXOPTIMIZATION ?= -O2 + ARCHOPTIMIZATION += -fomit-frame-pointer +endif + +ARCHCFLAGS += -fno-common +ARCHCXXFLAGS += -fno-common -nostdinc++ + +ifneq ($(CONFIG_CXX_EXCEPTION),y) + ARCHCXXFLAGS += -fno-exceptions -fcheck-new +endif + +ifneq ($(CONFIG_CXX_RTTI),y) + ARCHCXXFLAGS += -fno-rtti endif # NuttX buildroot GCC toolchain under Linux or Cygwin @@ -126,12 +145,12 @@ OBJDUMP = $(CROSSDEV)objdump # Add the builtin library -EXTRA_LIBS += ${wildcard ${shell $(CC) $(ARCHCPUFLAGS) --print-libgcc-file-name}} +EXTRA_LIBS += $(wildcard $(shell $(CC) $(ARCHCPUFLAGS) --print-libgcc-file-name)) ifneq ($(CONFIG_LIBM),y) - EXTRA_LIBS += ${wildcard ${shell $(CC) $(ARCHCPUFLAGS) --print-file-name=libm.a}} + EXTRA_LIBS += $(wildcard $(shell $(CC) $(ARCHCPUFLAGS) --print-file-name=libm.a)) endif ifeq ($(CONFIG_LIBSUPCXX),y) - EXTRA_LIBS += ${wildcard ${shell $(CC) $(ARCHCPUFLAGS) --print-file-name=libsupc++.a}} + EXTRA_LIBS += $(wildcard $(shell $(CC) $(ARCHCPUFLAGS) --print-file-name=libsupc++.a)) endif diff --git a/arch/avr/src/avr32/Toolchain.defs b/arch/avr/src/avr32/Toolchain.defs index 87b61352b96d8..789ba07d27348 100644 --- a/arch/avr/src/avr32/Toolchain.defs +++ b/arch/avr/src/avr32/Toolchain.defs @@ -31,6 +31,32 @@ # GNU, not AVRTOOLSW. # +ifneq ($(CONFIG_DEBUG_NOOPT),y) + ARCHOPTIMIZATION += -fno-strict-aliasing +endif + +ifeq ($(CONFIG_DEBUG_SYMBOLS),y) + LDFLAGS += -g + ARCHOPTIMIZATION += -g +endif + +ifeq ($(CONFIG_FRAME_POINTER),y) + ARCHOPTIMIZATION += -fno-omit-frame-pointer -fno-optimize-sibling-calls +else + ARCHOPTIMIZATION += -fomit-frame-pointer +endif + +ARCHCFLAGS += -fno-common +ARCHCXXFLAGS += -fno-common -nostdinc++ + +ifneq ($(CONFIG_CXX_EXCEPTION),y) + ARCHCXXFLAGS += -fno-exceptions -fcheck-new +endif + +ifneq ($(CONFIG_CXX_RTTI),y) + ARCHCXXFLAGS += -fno-rtti +endif + CROSSDEV = avr32- ARCHCPUFLAGS = -mpart=uc3b0256 @@ -50,12 +76,12 @@ OBJDUMP = $(CROSSDEV)objdump # Add the builtin library -EXTRA_LIBS += ${wildcard ${shell $(CC) $(ARCHCPUFLAGS) --print-libgcc-file-name}} +EXTRA_LIBS += $(wildcard $(shell $(CC) $(ARCHCPUFLAGS) --print-libgcc-file-name)) ifneq ($(CONFIG_LIBM),y) - EXTRA_LIBS += ${wildcard ${shell $(CC) $(ARCHCPUFLAGS) --print-file-name=libm.a}} + EXTRA_LIBS += $(wildcard $(shell $(CC) $(ARCHCPUFLAGS) --print-file-name=libm.a)) endif ifeq ($(CONFIG_LIBSUPCXX),y) - EXTRA_LIBS += ${wildcard ${shell $(CC) $(ARCHCPUFLAGS) --print-file-name=libsupc++.a}} + EXTRA_LIBS += $(wildcard $(shell $(CC) $(ARCHCPUFLAGS) --print-file-name=libsupc++.a)) endif diff --git a/arch/avr/src/common/up_exit.c b/arch/avr/src/common/up_exit.c index 7dd1e69f7e35d..e0c9664e7a633 100644 --- a/arch/avr/src/common/up_exit.c +++ b/arch/avr/src/common/up_exit.c @@ -70,7 +70,7 @@ static void _up_dumponexit(FAR struct tcb_s *tcb, FAR void *arg) sinfo(" TCB=%p name=%s pid=%d\n", tcb, tcb->name, tcb->pid); sinfo(" priority=%d state=%d\n", tcb->sched_priority, tcb->task_state); - filelist = tcb->group->tg_filelist; + filelist = &tcb->group->tg_filelist; for (i = 0; i < filelist->fl_rows; i++) { for (j = 0; j < CONFIG_NFILE_DESCRIPTORS_PER_BLOCK; j++) @@ -114,15 +114,15 @@ void up_exit(int status) sinfo("TCB=%p exiting\n", tcb); + /* Destroy the task at the head of the ready to run list. */ + + nxtask_exit(); + #ifdef CONFIG_DUMP_ON_EXIT sinfo("Other tasks:\n"); nxsched_foreach(_up_dumponexit, NULL); #endif - /* Destroy the task at the head of the ready to run list. */ - - nxtask_exit(); - /* Now, perform the context switch to the new ready-to-run task at the * head of the list. */ diff --git a/arch/ceva/include/syscall.h b/arch/ceva/include/syscall.h index 7fc3c672b2174..f22102fd40476 100644 --- a/arch/ceva/include/syscall.h +++ b/arch/ceva/include/syscall.h @@ -58,7 +58,7 @@ /* SYS call 0: * - * int up_saveusercontext(uint32_t *saveregs); + * int up_saveusercontext(void *saveregs); */ #define SYS_save_context 0x00 @@ -89,7 +89,7 @@ #ifndef CONFIG_BUILD_FLAT /* SYS call 4: * - * void up_task_start(main_t taskentry, int argc, FAR char *argv[]) + * void up_task_start(main_t taskentry, int argc, char *argv[]) * noreturn_function; */ @@ -106,7 +106,7 @@ /* SYS call 6: * * void signal_handler(_sa_sigaction_t sighand, int signo, - * FAR siginfo_t *info, FAR void *ucontext); + * siginfo_t *info, void *ucontext); */ #define SYS_signal_handler 0x06 diff --git a/arch/ceva/include/xc5/irq.h b/arch/ceva/include/xc5/irq.h index e086774f1e5d8..7c40b8d413fac 100644 --- a/arch/ceva/include/xc5/irq.h +++ b/arch/ceva/include/xc5/irq.h @@ -131,7 +131,7 @@ struct xcptcontext * are pending signals to be processed. */ - FAR void *sigdeliver; /* Actual type is sig_deliver_t */ + void *sigdeliver; /* Actual type is sig_deliver_t */ /* These are saved copies of the context used during * signal processing. diff --git a/arch/ceva/include/xm6/irq.h b/arch/ceva/include/xm6/irq.h index 69a73b19d7bfd..41101a626da8a 100644 --- a/arch/ceva/include/xm6/irq.h +++ b/arch/ceva/include/xm6/irq.h @@ -134,7 +134,7 @@ struct xcptcontext * are pending signals to be processed. */ - FAR void *sigdeliver; /* Actual type is sig_deliver_t */ + void *sigdeliver; /* Actual type is sig_deliver_t */ /* These are saved copies of the context used during * signal processing. diff --git a/arch/ceva/include/xm6/spinlock.h b/arch/ceva/include/xm6/spinlock.h index ed48770643367..2080689f2e0b1 100644 --- a/arch/ceva/include/xm6/spinlock.h +++ b/arch/ceva/include/xm6/spinlock.h @@ -95,7 +95,7 @@ static inline void up_dmb(void) * ****************************************************************************/ -static inline spinlock_t up_testset(volatile FAR spinlock_t *lock) +static inline spinlock_t up_testset(volatile spinlock_t *lock) { irqstate_t flags; spinlock_t old; diff --git a/arch/ceva/src/common/up_assert.c b/arch/ceva/src/common/up_assert.c index c5a5d233a507b..a587fe92794c7 100644 --- a/arch/ceva/src/common/up_assert.c +++ b/arch/ceva/src/common/up_assert.c @@ -87,7 +87,7 @@ static void up_stackdump(uint32_t sp, uint32_t stack_base) ****************************************************************************/ #ifdef CONFIG_STACK_COLORATION -static void up_taskdump(FAR struct tcb_s *tcb, FAR void *arg) +static void up_taskdump(struct tcb_s *tcb, void *arg) { /* Dump interesting properties of this task */ @@ -156,7 +156,7 @@ static inline void up_registerdump(void) ****************************************************************************/ #ifdef CONFIG_ARCH_USBDUMP -static int usbtrace_syslog(FAR const char *fmt, ...) +static int usbtrace_syslog(const char *fmt, ...) { va_list ap; @@ -168,7 +168,7 @@ static int usbtrace_syslog(FAR const char *fmt, ...) return 0; } -static int assert_tracecallback(FAR struct usbtrace_s *trace, FAR void *arg) +static int assert_tracecallback(struct usbtrace_s *trace, void *arg) { usbtrace_trprintf(usbtrace_syslog, trace->event, trace->value); return 0; diff --git a/arch/ceva/src/common/up_checkstack.c b/arch/ceva/src/common/up_checkstack.c index c3f5c782b3d15..e58c20c91748b 100644 --- a/arch/ceva/src/common/up_checkstack.c +++ b/arch/ceva/src/common/up_checkstack.c @@ -59,7 +59,7 @@ static size_t do_stackcheck(uintptr_t alloc, size_t size); static size_t do_stackcheck(uintptr_t alloc, size_t size) { - FAR uint32_t *ptr; + uint32_t *ptr; size_t nwords; size_t mark; @@ -71,7 +71,7 @@ static size_t do_stackcheck(uintptr_t alloc, size_t size) * that does not have the magic value is the high water mark. */ - for (ptr = (FAR uint32_t *)alloc, mark = nwords; + for (ptr = (uint32_t *)alloc, mark = nwords; *ptr == STACK_COLOR && mark > 0; ptr++, mark--); @@ -91,7 +91,7 @@ static size_t do_stackcheck(uintptr_t alloc, size_t size) int i; int j; - ptr = (FAR uint32_t *)start; + ptr = (uint32_t *)start; for (i = 0; i < nwords; i += 64) { for (j = 0; j < 64; j++) @@ -139,13 +139,13 @@ static size_t do_stackcheck(uintptr_t alloc, size_t size) * ****************************************************************************/ -size_t up_check_tcbstack(FAR struct tcb_s *tcb) +size_t up_check_tcbstack(struct tcb_s *tcb) { return do_stackcheck((uintptr_t)tcb->stack_alloc_ptr, tcb->adj_stack_size); } -ssize_t up_check_tcbstack_remain(FAR struct tcb_s *tcb) +ssize_t up_check_tcbstack_remain(struct tcb_s *tcb) { return tcb->adj_stack_size - up_check_tcbstack(tcb); } diff --git a/arch/ceva/src/common/up_createstack.c b/arch/ceva/src/common/up_createstack.c index 1eab7ad0d9c29..f2e9a6fdf37e0 100644 --- a/arch/ceva/src/common/up_createstack.c +++ b/arch/ceva/src/common/up_createstack.c @@ -89,7 +89,7 @@ * ****************************************************************************/ -int up_create_stack(FAR struct tcb_s *tcb, size_t stack_size, uint8_t ttype) +int up_create_stack(struct tcb_s *tcb, size_t stack_size, uint8_t ttype) { #ifdef CONFIG_TLS /* The allocated stack size must not exceed the maximum possible for the @@ -228,14 +228,32 @@ int up_create_stack(FAR struct tcb_s *tcb, size_t stack_size, uint8_t ttype) ****************************************************************************/ #ifdef CONFIG_STACK_COLORATION -void up_stack_color(FAR void *stackbase, size_t nbytes) +void up_stack_color(void *stackbase, size_t nbytes) { - /* Take extra care that we do not write outsize the stack boundaries */ + uint32_t *stkptr; + uintptr_t stkend; + size_t nwords; + uintptr_t sp; - uint32_t *stkptr = (uint32_t *)(((uintptr_t)stackbase + 3) & ~3); - uintptr_t stkend = nbytes ? (((uintptr_t)stackbase + nbytes) & ~3) : - up_getsp(); /* 0: colorize the running stack */ - size_t nwords = (stkend - (uintptr_t)stackbase) >> 2; + /* Take extra care that we do not write outside the stack boundaries */ + + stkptr = (uint32_t *)STACK_ALIGN_UP((uintptr_t)stackbase); + + if (nbytes == 0) /* 0: colorize the running stack */ + { + stkend = up_getsp(); + if (stkend > (uintptr_t)&sp) + { + stkend = (uintptr_t)&sp; + } + } + else + { + stkend = (uintptr_t)stackbase + nbytes; + } + + stkend = STACK_ALIGN_DOWN(stkend); + nwords = (stkend - (uintptr_t)stackbase) >> 2; /* Set the entire stack to the coloration value */ diff --git a/arch/ceva/src/common/up_heap.c b/arch/ceva/src/common/up_heap.c index 20c2fb39c308c..53cd4b5ccaf8a 100644 --- a/arch/ceva/src/common/up_heap.c +++ b/arch/ceva/src/common/up_heap.c @@ -171,7 +171,7 @@ void *g_idle_topstack = _START_HEAP; * ****************************************************************************/ -void up_allocate_heap(FAR void **heap_start, size_t *heap_size) +void up_allocate_heap(void **heap_start, size_t *heap_size) { int i; @@ -240,7 +240,7 @@ void up_allocate_heap(FAR void **heap_start, size_t *heap_size) ****************************************************************************/ #ifdef CONFIG_MM_KERNEL_HEAP -void up_allocate_kheap(FAR void **heap_start, size_t *heap_size) +void up_allocate_kheap(void **heap_start, size_t *heap_size) { int i; diff --git a/arch/ceva/src/common/up_idle.c b/arch/ceva/src/common/up_idle.c index 21f65e1141a0d..16d4d8a7e6d5e 100644 --- a/arch/ceva/src/common/up_idle.c +++ b/arch/ceva/src/common/up_idle.c @@ -163,5 +163,8 @@ void weak_function up_cpu_normal(void) #ifdef CONFIG_PM void up_pminitialize(void) { + /* Initialize the NuttX power management subsystem proper */ + + pm_initialize(); } #endif diff --git a/arch/ceva/src/common/up_internal.h b/arch/ceva/src/common/up_internal.h index 2e14a400054b1..c00e5802947be 100644 --- a/arch/ceva/src/common/up_internal.h +++ b/arch/ceva/src/common/up_internal.h @@ -228,7 +228,6 @@ void modifyreg32(unsigned int addr, uint32_t clearbits, uint32_t setbits); /* Context switching */ -int up_saveusercontext(uint32_t *saveregs); void up_fullcontextrestore(uint32_t *restoreregs) noreturn_function; void up_switchcontext(uint32_t **saveregs, uint32_t *restoreregs); @@ -266,8 +265,8 @@ uint32_t *up_doirq(int irq, uint32_t *regs); /* Exception Handlers */ -int up_svcall(int irq, FAR void *context, FAR void *arg); -int up_hardfault(int irq, FAR void *context, FAR void *arg); +int up_svcall(int irq, void *context, void *arg); +int up_hardfault(int irq, void *context, void *arg); void up_svcall_handler(void); @@ -325,7 +324,7 @@ void up_usbuninitialize(void); #endif #ifdef CONFIG_STACK_COLORATION -void up_stack_color(FAR void *stackbase, size_t nbytes); +void up_stack_color(void *stackbase, size_t nbytes); #endif #undef EXTERN diff --git a/arch/ceva/src/common/up_releasestack.c b/arch/ceva/src/common/up_releasestack.c index a58939c8a6d7d..509ba49b4b561 100644 --- a/arch/ceva/src/common/up_releasestack.c +++ b/arch/ceva/src/common/up_releasestack.c @@ -79,7 +79,7 @@ * ****************************************************************************/ -void up_release_stack(FAR struct tcb_s *dtcb, uint8_t ttype) +void up_release_stack(struct tcb_s *dtcb, uint8_t ttype) { /* Is there a stack allocated? */ diff --git a/arch/ceva/src/common/up_saveusercontext.c b/arch/ceva/src/common/up_saveusercontext.c index 0d101e872a680..a1d0bffca1808 100644 --- a/arch/ceva/src/common/up_saveusercontext.c +++ b/arch/ceva/src/common/up_saveusercontext.c @@ -39,7 +39,7 @@ * Description: * Save the current thread context. Full prototype is: * - * int up_saveusercontext(uint32_t *saveregs); + * int up_saveusercontext(void *saveregs); * * Return: * 0: Normal return @@ -47,7 +47,7 @@ * ****************************************************************************/ -int up_saveusercontext(uint32_t *saveregs) +int up_saveusercontext(void *saveregs) { int ret; diff --git a/arch/ceva/src/common/up_schedulesigaction.c b/arch/ceva/src/common/up_schedulesigaction.c index d2129bb9c7e57..13bb89983bac7 100644 --- a/arch/ceva/src/common/up_schedulesigaction.c +++ b/arch/ceva/src/common/up_schedulesigaction.c @@ -141,7 +141,7 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver) /* Save the current register context location */ tcb->xcp.saved_regs = g_current_regs[cpu]; - tcb->xcp.sigdeliver = (FAR void *)sigdeliver; + tcb->xcp.sigdeliver = (void *)sigdeliver; /* Duplicate the register context. These will be * restored by the signal trampoline after the signal has been @@ -186,7 +186,7 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver) /* Save the current register context location */ tcb->xcp.saved_regs = tcb->xcp.regs; - tcb->xcp.sigdeliver = (FAR void *)sigdeliver; + tcb->xcp.sigdeliver = (void *)sigdeliver; /* Duplicate the register context. These will be restored * by the signal trampoline after the signal has been delivered. diff --git a/arch/ceva/src/common/up_signal_dispatch.c b/arch/ceva/src/common/up_signal_dispatch.c index 9f6e709b2145e..4a3d345a64bb6 100644 --- a/arch/ceva/src/common/up_signal_dispatch.c +++ b/arch/ceva/src/common/up_signal_dispatch.c @@ -64,7 +64,7 @@ ****************************************************************************/ void up_signal_dispatch(_sa_sigaction_t sighand, int signo, - FAR siginfo_t *info, FAR void *ucontext) + siginfo_t *info, void *ucontext) { /* Let sys_call4() do all of the work */ diff --git a/arch/ceva/src/common/up_stackframe.c b/arch/ceva/src/common/up_stackframe.c index 9c142b4711398..4f598f638e779 100644 --- a/arch/ceva/src/common/up_stackframe.c +++ b/arch/ceva/src/common/up_stackframe.c @@ -65,9 +65,9 @@ * ****************************************************************************/ -FAR void *up_stack_frame(FAR struct tcb_s *tcb, size_t frame_size) +void *up_stack_frame(struct tcb_s *tcb, size_t frame_size) { - FAR void *ret; + void *ret; /* Align the frame_size */ @@ -87,7 +87,7 @@ FAR void *up_stack_frame(FAR struct tcb_s *tcb, size_t frame_size) /* Save the adjusted stack values in the struct tcb_s */ - tcb->stack_base_ptr = (FAR uint8_t *)tcb->stack_base_ptr + frame_size; + tcb->stack_base_ptr = (uint8_t *)tcb->stack_base_ptr + frame_size; tcb->adj_stack_size -= frame_size; /* And return the pointer to the allocated region */ diff --git a/arch/ceva/src/common/up_svcall.c b/arch/ceva/src/common/up_svcall.c index 1635bdbac34fe..2b2115275a52d 100644 --- a/arch/ceva/src/common/up_svcall.c +++ b/arch/ceva/src/common/up_svcall.c @@ -47,7 +47,7 @@ * ****************************************************************************/ -int up_svcall(int irq, FAR void *context, FAR void *arg) +int up_svcall(int irq, void *context, void *arg) { uint32_t *regs = (uint32_t *)context; uint32_t cmd; @@ -85,7 +85,7 @@ int up_svcall(int irq, FAR void *context, FAR void *arg) { /* A0=SYS_save_context: This is a save context command: * - * int up_saveusercontext(uint32_t *saveregs); + * int up_saveusercontext(void *saveregs); * * At this point, the following values are saved in context: * @@ -192,7 +192,7 @@ int up_svcall(int irq, FAR void *context, FAR void *arg) /* A0=SYS_task_start: This a user task start * - * void up_task_start(main_t taskentry, int argc, FAR char *argv[]); + * void up_task_start(main_t taskentry, int argc, char *argv[]); * * At this point, the following values are saved in context: * @@ -264,7 +264,7 @@ int up_svcall(int irq, FAR void *context, FAR void *arg) /* A0=SYS_signal_handler: This a user signal handler callback * * void signal_handler(_sa_sigaction_t sighand, int signo, - * FAR siginfo_t *info, FAR void *ucontext); + * siginfo_t *info, void *ucontext); * * At this point, the following values are saved in context: * @@ -343,7 +343,7 @@ int up_svcall(int irq, FAR void *context, FAR void *arg) default: { #ifdef CONFIG_LIB_SYSCALL - FAR struct tcb_s *rtcb = sched_self(); + struct tcb_s *rtcb = sched_self(); int index = rtcb->xcp.nsyscalls; /* Verify that the SYS call number is within range */ diff --git a/arch/ceva/src/common/up_task_start.c b/arch/ceva/src/common/up_task_start.c index 11bf102baa209..5a0bf81ea0050 100644 --- a/arch/ceva/src/common/up_task_start.c +++ b/arch/ceva/src/common/up_task_start.c @@ -58,7 +58,7 @@ * ****************************************************************************/ -void up_task_start(main_t taskentry, int argc, FAR char *argv[]) +void up_task_start(main_t taskentry, int argc, char *argv[]) { /* Let sys_call3() do all of the work */ diff --git a/arch/ceva/src/common/up_usestack.c b/arch/ceva/src/common/up_usestack.c index 0be0d51353a36..b6f477431109b 100644 --- a/arch/ceva/src/common/up_usestack.c +++ b/arch/ceva/src/common/up_usestack.c @@ -64,7 +64,7 @@ * ****************************************************************************/ -int up_use_stack(FAR struct tcb_s *tcb, FAR void *stack, size_t stack_size) +int up_use_stack(struct tcb_s *tcb, void *stack, size_t stack_size) { uintptr_t top_of_stack; size_t size_of_stack; diff --git a/arch/ceva/src/common/up_vfork.c b/arch/ceva/src/common/up_vfork.c index b57ba8db2508b..8dd33a25e9af0 100644 --- a/arch/ceva/src/common/up_vfork.c +++ b/arch/ceva/src/common/up_vfork.c @@ -111,7 +111,7 @@ pid_t up_vfork(const uint32_t *regs) /* Allocate the stack for the TCB */ - ret = up_create_stack((FAR struct tcb_s *)child, stacksize + argsize, + ret = up_create_stack((struct tcb_s *)child, stacksize + argsize, parent->flags & TCB_FLAG_TTYPE_MASK); if (ret != OK) { @@ -122,7 +122,7 @@ pid_t up_vfork(const uint32_t *regs) /* Allocate the memory and copy argument from parent task */ - argv = up_stack_frame((FAR struct tcb_s *)child, argsize); + argv = up_stack_frame((struct tcb_s *)child, argsize); memcpy(argv, parent->stack_base_ptr, argsize); /* How much of the parent's stack was utilized? The CEVA uses diff --git a/arch/ceva/src/xc5/Toolchain.defs b/arch/ceva/src/xc5/Toolchain.defs index 45c6917e9e8bd..f140e7115f144 100644 --- a/arch/ceva/src/xc5/Toolchain.defs +++ b/arch/ceva/src/xc5/Toolchain.defs @@ -33,7 +33,7 @@ DTCM_KB := $(shell expr $(CONFIG_ARCH_DTCM_SIZE) / 1024) # invoking ar and nm. # ARCHCPUFLAGS CPU-specific flags selecting the instruction set # FPU options, etc. -# MAXOPTIMIZATION The maximum optimization level that results in +# ARCHOPTIMIZATION The optimization level that results in # reliable code generation. # @@ -45,15 +45,33 @@ ifneq ($(CROSSDEV),) endif ifeq ($(CONFIG_DEBUG_CUSTOMOPT),y) - MAXOPTIMIZATION := $(CONFIG_DEBUG_OPTLEVEL) + ARCHOPTIMIZATION += $(CONFIG_DEBUG_OPTLEVEL) else ifeq ($(CONFIG_DEBUG_FULLOPT),y) - MAXOPTIMIZATION := -O3 -Os3 + ARCHOPTIMIZATION += -O3 -Os3 endif +ifneq ($(CONFIG_DEBUG_NOOPT),y) + ARCHOPTIMIZATION += -fno-strict-aliasing +endif + +ifeq ($(CONFIG_FRAME_POINTER),y) + ARCHOPTIMIZATION += -fno-omit-frame-pointer -fno-optimize-sibling-calls +else + ARCHOPTIMIZATION += -fomit-frame-pointer +endif + +ifeq ($(CONFIG_DEBUG_SYMBOLS),y) + LDFLAGS += -g + ARCHOPTIMIZATION += -g +endif + +ARCHCFLAGS += -fno-common +ARCHCXXFLAGS += -fno-common -nostdinc++ + ARCHCPUFLAGS = -mrtl-version-$(RTL_VERSION) -Wa,-rtl$(RTL_VERSION) ARCHCPUFLAGS += -Wa,-p -mmsg-full-path -TARG:arch=cevaxc5 -Wa,-vdiv4 -Wno-unused -LDFLAGS = -alignAllSections,c:0x20,d:0x4 -cevaxc5 -removeUnRefFunc +LDFLAGS += -alignAllSections,c:0x20,d:0x4 -cevaxc5 -removeUnRefFunc LDFLAGS += -internalCode$(ITCM_KB) -internalData$(DTCM_KB) LIBGCC = $(CROSSDEV)libs/xc5/cevaxclib.lib diff --git a/arch/ceva/src/xc5/up_hardfault.c b/arch/ceva/src/xc5/up_hardfault.c index e944109a7ddb3..82e15f916411c 100644 --- a/arch/ceva/src/xc5/up_hardfault.c +++ b/arch/ceva/src/xc5/up_hardfault.c @@ -80,7 +80,7 @@ * ****************************************************************************/ -int up_hardfault(int irq, FAR void *context, FAR void *arg) +int up_hardfault(int irq, void *context, void *arg) { /* Dump some hard fault info */ diff --git a/arch/ceva/src/xm6/Toolchain.defs b/arch/ceva/src/xm6/Toolchain.defs index 7b43e8b86fcad..ccae8442c5aa7 100644 --- a/arch/ceva/src/xm6/Toolchain.defs +++ b/arch/ceva/src/xm6/Toolchain.defs @@ -33,7 +33,7 @@ DTCM_KB := $(shell expr $(CONFIG_ARCH_DTCM_SIZE) / 1024) # invoking ar and nm. # ARCHCPUFLAGS CPU-specific flags selecting the instruction set # FPU options, etc. -# MAXOPTIMIZATION The maximum optimization level that results in +# ARCHOPTIMIZATION The optimization level that results in # reliable code generation. # @@ -45,15 +45,33 @@ ifneq ($(CROSSDEV),) endif ifeq ($(CONFIG_DEBUG_CUSTOMOPT),y) - MAXOPTIMIZATION := $(CONFIG_DEBUG_OPTLEVEL) + ARCHOPTIMIZATION += $(CONFIG_DEBUG_OPTLEVEL) else ifeq ($(CONFIG_DEBUG_FULLOPT),y) - MAXOPTIMIZATION := -O3 -Os3 + ARCHOPTIMIZATION += -O3 -Os3 endif +ifneq ($(CONFIG_DEBUG_NOOPT),y) + ARCHOPTIMIZATION += -fno-strict-aliasing +endif + +ifeq ($(CONFIG_FRAME_POINTER),y) + ARCHOPTIMIZATION += -fno-omit-frame-pointer -fno-optimize-sibling-calls +else + ARCHOPTIMIZATION += -fomit-frame-pointer +endif + +ifeq ($(CONFIG_DEBUG_SYMBOLS),y) + LDFLAGS += -g + ARCHOPTIMIZATION += -g +endif + +ARCHCFLAGS += -fno-common +ARCHCXXFLAGS += -fno-common -nostdinc++ + ARCHCPUFLAGS = -mrtl-version-$(RTL_VERSION) -Wa,-rtl$(RTL_VERSION) ARCHCPUFLAGS += -Wa,-p -LDFLAGS = -alignAllSections,c:0x20,d:0x20 +LDFLAGS += -alignAllSections,c:0x20,d:0x20 LDFLAGS += -internalCode$(ITCM_KB) -internalData$(DTCM_KB) LIBGCC = $(CROSSDEV)libs/cevaxm6/cevaxm6lib.lib diff --git a/arch/ceva/src/xm6/up_hardfault.c b/arch/ceva/src/xm6/up_hardfault.c index 367b2f16ec3d1..a20f8890fe76c 100644 --- a/arch/ceva/src/xm6/up_hardfault.c +++ b/arch/ceva/src/xm6/up_hardfault.c @@ -95,7 +95,7 @@ * ****************************************************************************/ -int up_hardfault(int irq, FAR void *context, FAR void *arg) +int up_hardfault(int irq, void *context, void *arg) { /* Dump some hard fault info */ diff --git a/arch/hc/src/common/up_exit.c b/arch/hc/src/common/up_exit.c index 6027f4f8bc0d2..3e92f8936b34e 100644 --- a/arch/hc/src/common/up_exit.c +++ b/arch/hc/src/common/up_exit.c @@ -70,7 +70,7 @@ static void _up_dumponexit(FAR struct tcb_s *tcb, FAR void *arg) sinfo(" TCB=%p name=%s pid=%d\n", tcb, tcb->name, tcb->pid); sinfo(" priority=%d state=%d\n", tcb->sched_priority, tcb->task_state); - filelist = tcb->group->tg_filelist; + filelist = &tcb->group->tg_filelist; for (i = 0; i < filelist->fl_rows; i++) { for (j = 0; j < CONFIG_NFILE_DESCRIPTORS_PER_BLOCK; j++) @@ -114,15 +114,15 @@ void up_exit(int status) sinfo("TCB=%p exiting\n", tcb); + /* Destroy the task at the head of the ready to run list. */ + + nxtask_exit(); + #ifdef CONFIG_DUMP_ON_EXIT sinfo("Other tasks:\n"); nxsched_foreach(_up_dumponexit, NULL); #endif - /* Destroy the task at the head of the ready to run list. */ - - nxtask_exit(); - /* Now, perform the context switch to the new ready-to-run task at the * head of the list. */ diff --git a/arch/hc/src/common/up_internal.h b/arch/hc/src/common/up_internal.h index 8daeda9775b58..4d55d3b8727b8 100644 --- a/arch/hc/src/common/up_internal.h +++ b/arch/hc/src/common/up_internal.h @@ -148,7 +148,6 @@ void modifyreg32(unsigned int addr, uint32_t clearbits, uint32_t setbits); void up_copystate(uint8_t *dest, uint8_t *src); void up_decodeirq(uint8_t *regs); -int up_saveusercontext(uint8_t *saveregs); void up_fullcontextrestore(uint8_t *restoreregs) noreturn_function; void up_switchcontext(uint8_t *saveregs, uint8_t *restoreregs); diff --git a/arch/mips/include/syscall.h b/arch/mips/include/syscall.h index 18039c76932ef..38022ece2a272 100644 --- a/arch/mips/include/syscall.h +++ b/arch/mips/include/syscall.h @@ -163,7 +163,7 @@ */ #define SYS_syscall_return (3) -#define up_syscall_return() (void)sys_call0(SYS_syscall_return) +#define up_syscall_return() sys_call0(SYS_syscall_return) #endif #endif /* __ASSEMBLY__ */ diff --git a/arch/mips/src/common/mips_allocateheap.c b/arch/mips/src/common/mips_allocateheap.c index bf09120c23d75..9db939b58d75a 100644 --- a/arch/mips/src/common/mips_allocateheap.c +++ b/arch/mips/src/common/mips_allocateheap.c @@ -64,9 +64,9 @@ * ****************************************************************************/ -void up_allocate_heap(FAR void **heap_start, size_t *heap_size) +void up_allocate_heap(void **heap_start, size_t *heap_size) { board_autoled_on(LED_HEAPALLOCATE); - *heap_start = (FAR void *)g_idle_topstack; + *heap_start = (void *)g_idle_topstack; *heap_size = CONFIG_RAM_END - g_idle_topstack; } diff --git a/arch/mips/src/common/mips_createstack.c b/arch/mips/src/common/mips_createstack.c index eab5cf76fd632..595e66ad665f0 100644 --- a/arch/mips/src/common/mips_createstack.c +++ b/arch/mips/src/common/mips_createstack.c @@ -79,7 +79,7 @@ * ****************************************************************************/ -int up_create_stack(FAR struct tcb_s *tcb, size_t stack_size, uint8_t ttype) +int up_create_stack(struct tcb_s *tcb, size_t stack_size, uint8_t ttype) { #ifdef CONFIG_TLS_ALIGNED /* The allocated stack size must not exceed the maximum possible for the diff --git a/arch/mips/src/common/mips_exit.c b/arch/mips/src/common/mips_exit.c index efa0d4fe3977f..c516cf137a34c 100644 --- a/arch/mips/src/common/mips_exit.c +++ b/arch/mips/src/common/mips_exit.c @@ -63,16 +63,16 @@ ****************************************************************************/ #ifdef CONFIG_DUMP_ON_EXIT -static void _up_dumponexit(FAR struct tcb_s *tcb, FAR void *arg) +static void _up_dumponexit(struct tcb_s *tcb, void *arg) { - FAR struct filelist *filelist; + struct filelist *filelist; int i; int j; sinfo(" TCB=%p name=%s pid=%d\n", tcb, tcb->name, tcb->pid); sinfo(" priority=%d state=%d\n", tcb->sched_priority, tcb->task_state); - filelist = tcb->group->tg_filelist; + filelist = &tcb->group->tg_filelist; for (i = 0; i < filelist->fl_rows; i++) { for (j = 0; j < CONFIG_NFILE_DESCRIPTORS_PER_BLOCK; j++) @@ -116,15 +116,15 @@ void up_exit(int status) sinfo("TCB=%p exiting\n", tcb); + /* Destroy the task at the head of the ready to run list. */ + + nxtask_exit(); + #ifdef CONFIG_DUMP_ON_EXIT sinfo("Other tasks:\n"); nxsched_foreach(_up_dumponexit, NULL); #endif - /* Destroy the task at the head of the ready to run list. */ - - nxtask_exit(); - /* Now, perform the context switch to the new ready-to-run task at the * head of the list. */ @@ -137,16 +137,6 @@ void up_exit(int status) nxsched_resume_scheduler(tcb); -#ifdef CONFIG_ARCH_ADDRENV - /* Make sure that the address environment for the previously running - * task is closed down gracefully (data caches dump, MMU flushed) and - * set up the address environment for the new thread at the head of - * the ready-to-run list. - */ - - group_addrenv(tcb); -#endif - /* Then switch contexts */ up_fullcontextrestore(tcb->xcp.regs); diff --git a/arch/mips/src/common/mips_internal.h b/arch/mips/src/common/mips_internal.h index 9452b0eb50401..05fe2594d5526 100644 --- a/arch/mips/src/common/mips_internal.h +++ b/arch/mips/src/common/mips_internal.h @@ -215,7 +215,7 @@ uint32_t *up_doirq(int irq, uint32_t *regs); /* Software interrupt 0 handler */ -int up_swint0(int irq, FAR void *context, FAR void *arg); +int up_swint0(int irq, void *context, void *arg); /* Signals */ diff --git a/arch/mips/src/common/mips_releasestack.c b/arch/mips/src/common/mips_releasestack.c index 79bfdb3fe0e24..fe991ec1f25ad 100644 --- a/arch/mips/src/common/mips_releasestack.c +++ b/arch/mips/src/common/mips_releasestack.c @@ -75,7 +75,7 @@ * ****************************************************************************/ -void up_release_stack(FAR struct tcb_s *dtcb, uint8_t ttype) +void up_release_stack(struct tcb_s *dtcb, uint8_t ttype) { /* Is there a stack allocated? */ diff --git a/arch/mips/src/common/mips_stackframe.c b/arch/mips/src/common/mips_stackframe.c index 743ca2d61af67..bb23964b1dc18 100644 --- a/arch/mips/src/common/mips_stackframe.c +++ b/arch/mips/src/common/mips_stackframe.c @@ -68,9 +68,9 @@ * ****************************************************************************/ -FAR void *up_stack_frame(FAR struct tcb_s *tcb, size_t frame_size) +void *up_stack_frame(struct tcb_s *tcb, size_t frame_size) { - FAR void *ret; + void *ret; /* Align the frame_size */ @@ -88,7 +88,7 @@ FAR void *up_stack_frame(FAR struct tcb_s *tcb, size_t frame_size) /* Save the adjusted stack values in the struct tcb_s */ - tcb->stack_base_ptr = (FAR uint8_t *)tcb->stack_base_ptr + frame_size; + tcb->stack_base_ptr = (uint8_t *)tcb->stack_base_ptr + frame_size; tcb->adj_stack_size -= frame_size; /* And return the pointer to the allocated region */ diff --git a/arch/mips/src/mips32/Toolchain.defs b/arch/mips/src/mips32/Toolchain.defs index 5a89a868d62d8..27365dfb08f03 100644 --- a/arch/mips/src/mips32/Toolchain.defs +++ b/arch/mips/src/mips32/Toolchain.defs @@ -101,12 +101,18 @@ endif # CROSSDEV The GNU toolchain triple (command prefix) # ARCHCPUFLAGS CPU-specific flags selecting the instruction set # FPU options, etc. -# MAXOPTIMIZATION The maximum optimization level that results in +# ARCHOPTIMIZATION The optimization level that results in # reliable code generation. # ifeq ($(CONFIG_DEBUG_CUSTOMOPT),y) - MAXOPTIMIZATION := $(CONFIG_DEBUG_OPTLEVEL) + ARCHOPTIMIZATION += $(CONFIG_DEBUG_OPTLEVEL) +else ifeq ($(CONFIG_DEBUG_FULLOPT),y) + ARCHOPTIMIZATION += -O2 +endif + +ifneq ($(CONFIG_DEBUG_NOOPT),y) + ARCHOPTIMIZATION += -fno-strict-aliasing endif # Pick correct MIPS architecture selection @@ -137,7 +143,6 @@ endif ifeq ($(CONFIG_MIPS32_TOOLCHAIN),GNU_ELF) CROSSDEV ?= mips-elf- - MAXOPTIMIZATION ?= -O2 ARCHCPUFLAGS = -mlong32 -membedded-data -msoft-float -march=$(MIPS_MARCH) $(MIPS_MICROMIPS) -EL ARCHPICFLAGS = -fpic -membedded-pic LDFLAGS += -nostartfiles -nodefaultlibs @@ -148,7 +153,6 @@ endif ifeq ($(CONFIG_MIPS32_TOOLCHAIN),PINGUINOL) CROSSDEV ?= p32- - MAXOPTIMIZATION ?= -O2 ARCHCPUFLAGS = -mlong32 -membedded-data -msoft-float -march=$(MIPS_MARCH) $(MIPS_MICROMIPS) -EL ARCHPICFLAGS = -fpic -membedded-pic LDFLAGS += -nostartfiles -nodefaultlibs @@ -159,7 +163,6 @@ endif ifeq ($(CONFIG_MIPS32_TOOLCHAIN),SOURCERY_CODEBENCH_LITE) CROSSDEV ?= mips-sde-elf- - MAXOPTIMIZATION ?= -O2 ARCHCPUFLAGS = -mlong32 -membedded-data -msoft-float -march=$(MIPS_MARCH) $(MIPS_MICROMIPS) -EL ARCHPICFLAGS = -fpic -membedded-pic LDFLAGS += -nostartfiles -nodefaultlibs @@ -170,9 +173,6 @@ endif ifeq ($(CONFIG_MIPS32_TOOLCHAIN),MICROCHIPL_XC32) CROSSDEV ?= xc32- -ifeq ($(CONFIG_MIPS32_TOOLCHAIN_MICROCHIP_XC32_LICENSED),y) - MAXOPTIMIZATION ?= -O2 -endif ARCHCPUFLAGS = -mprocessor=$(MIPS_MPROCESSOR) -march=$(MIPS_MARCH) -EL $(MIPS_MICROMIPS) -msmart-io=0 LDFLAGS += -nostartfiles -nodefaultlibs LDSCRIPT = xc32-debug.ld @@ -182,8 +182,6 @@ endif ifeq ($(CONFIG_MIPS32_TOOLCHAIN),MICROCHIPL) CROSSDEV ?= pic32- - # CROSSDEV ?= xc32- - MAXOPTIMIZATION ?= -O2 ARCHCPUFLAGS = -mprocessor=$(MIPS_MPROCESSOR) $(MIPS_MICROMIPS) -mno-float -mlong32 -membedded-data ARCHPICFLAGS = -fpic -membedded-pic LDFLAGS += -nostartfiles -nodefaultlibs @@ -194,9 +192,6 @@ endif ifeq ($(CONFIG_MIPS32_TOOLCHAIN),MICROCHIPW_XC32) CROSSDEV ?= xc32- -ifeq ($(CONFIG_MIPS32_TOOLCHAIN_MICROCHIP_XC32_LICENSED),y) - MAXOPTIMIZATION ?= -O2 -endif ARCHCPUFLAGS = -mprocessor=$(MIPS_MPROCESSOR) -march=$(MIPS_MARCH) -EL $(MIPS_MICROMIPS) -msmart-io=0 LDFLAGS += -nostartfiles -nodefaultlibs LDSCRIPT = xc32-debug.ld @@ -206,7 +201,6 @@ endif ifeq ($(CONFIG_MIPS32_TOOLCHAIN),MICROCHIPW) CROSSDEV ?= pic32- - MAXOPTIMIZATION ?= -O2 ARCHCPUFLAGS = -mprocessor=$(MIPS_MPROCESSOR) $(MIPS_MICROMIPS) -mno-float -mlong32 -membedded-data ARCHPICFLAGS = -fpic -membedded-pic LDFLAGS += -nostartfiles -nodefaultlibs @@ -217,7 +211,6 @@ endif ifeq ($(CONFIG_MIPS32_TOOLCHAIN),MICROCHIPL_LITE) CROSSDEV ?= pic32- - # MAXOPTIMIZATION ?= -O2 ARCHCPUFLAGS = -mprocessor=$(MIPS_MPROCESSOR) $(MIPS_MICROMIPS) -mno-float -mlong32 -membedded-data ARCHPICFLAGS = -fpic -membedded-pic LDFLAGS += -nostartfiles -nodefaultlibs @@ -228,8 +221,6 @@ endif ifeq ($(CONFIG_MIPS32_TOOLCHAIN),MICROCHIPW_LITE) CROSSDEV ?= pic32- - # CROSSDEV ?= xc32- - # MAXOPTIMIZATION ?= -O2 ARCHCPUFLAGS = -mprocessor=$(MIPS_MPROCESSOR) $(MIPS_MICROMIPS) -mno-float -mlong32 -membedded-data ARCHPICFLAGS = -fpic -membedded-pic LDFLAGS += -nostartfiles -nodefaultlibs @@ -240,7 +231,6 @@ endif ifeq ($(CONFIG_MIPS32_TOOLCHAIN),MICROCHIPOPENL) CROSSDEV ?= mypic32- - # MAXOPTIMIZATION ?= -O2 ARCHCPUFLAGS = -mprocessor=$(MIPS_MPROCESSOR) $(MIPS_MICROMIPS) -mno-float -mlong32 -membedded-data ARCHPICFLAGS = -fpic -membedded-pic LDFLAGS += -nostartfiles -nodefaultlibs @@ -250,9 +240,7 @@ endif # Pinguino mips-elf toolchain under Windows ifeq ($(CONFIG_MIPS32_TOOLCHAIN),PINGUINOW) - #CROSSDEV ?= mips- CROSSDEV ?= p32- - MAXOPTIMIZATION ?= -O2 ARCHCPUFLAGS = -mlong32 -membedded-data -msoft-float -march=$(MIPS_MARCH) $(MIPS_MICROMIPS) -EL ARCHPICFLAGS = -fpic -membedded-pic LDFLAGS += -nostartfiles -nodefaultlibs @@ -260,9 +248,38 @@ ifeq ($(CONFIG_MIPS32_TOOLCHAIN),PINGUINOW) endif ifeq ($(CONFIG_FRAME_POINTER),y) - MAXOPTIMIZATION += -fno-omit-frame-pointer -fno-optimize-sibling-calls + ARCHOPTIMIZATION += -fno-omit-frame-pointer -fno-optimize-sibling-calls else - MAXOPTIMIZATION += -fomit-frame-pointer + ARCHOPTIMIZATION += -fomit-frame-pointer +endif + +# Optimization of unused sections + +ifeq ($(CONFIG_DEBUG_OPT_UNUSED_SECTIONS),y) + LDFLAGS += --gc-sections + ARCHOPTIMIZATION += -ffunction-sections -fdata-sections +endif + +# Debug link map + +ifeq ($(CONFIG_DEBUG_LINK_MAP),y) + LDFLAGS += --cref -Map=$(call CONVERT_PATH,$(TOPDIR)$(DELIM)nuttx.map) +endif + +ifeq ($(CONFIG_DEBUG_SYMBOLS),y) + LDFLAGS += -g + ARCHOPTIMIZATION += -g +endif + +ARCHCFLAGS += -fno-common +ARCHCXXFLAGS += -fno-common -nostdinc++ + +ifneq ($(CONFIG_CXX_EXCEPTION),y) + ARCHCXXFLAGS += -fno-exceptions -fcheck-new +endif + +ifneq ($(CONFIG_CXX_RTTI),y) + ARCHCXXFLAGS += -fno-rtti endif # Default toolchain @@ -279,12 +296,12 @@ OBJDUMP = $(CROSSDEV)objdump # Add the builtin library -EXTRA_LIBS += ${wildcard ${shell $(CC) $(ARCHCPUFLAGS) --print-libgcc-file-name}} +EXTRA_LIBS += $(wildcard $(shell $(CC) $(ARCHCPUFLAGS) --print-libgcc-file-name)) ifneq ($(CONFIG_LIBM),y) - EXTRA_LIBS += ${wildcard ${shell $(CC) $(ARCHCPUFLAGS) --print-file-name=libm.a}} + EXTRA_LIBS += $(wildcard $(shell $(CC) $(ARCHCPUFLAGS) --print-file-name=libm.a)) endif ifeq ($(CONFIG_LIBSUPCXX),y) - EXTRA_LIBS += ${wildcard ${shell $(CC) $(ARCHCPUFLAGS) --print-file-name=libsupc++.a}} + EXTRA_LIBS += $(wildcard $(shell $(CC) $(ARCHCPUFLAGS) --print-file-name=libsupc++.a)) endif diff --git a/arch/mips/src/mips32/mips_assert.c b/arch/mips/src/mips32/mips_assert.c index f273b8139e8b2..5469bc18f67c7 100644 --- a/arch/mips/src/mips32/mips_assert.c +++ b/arch/mips/src/mips32/mips_assert.c @@ -99,7 +99,7 @@ static void _up_assert(void) ****************************************************************************/ #ifdef CONFIG_ARCH_USBDUMP -static int usbtrace_syslog(FAR const char *fmt, ...) +static int usbtrace_syslog(const char *fmt, ...) { va_list ap; @@ -111,7 +111,7 @@ static int usbtrace_syslog(FAR const char *fmt, ...) return OK; } -static int assert_tracecallback(FAR struct usbtrace_s *trace, FAR void *arg) +static int assert_tracecallback(struct usbtrace_s *trace, void *arg) { usbtrace_trprintf(usbtrace_syslog, trace->event, trace->value); return 0; diff --git a/arch/mips/src/mips32/mips_blocktask.c b/arch/mips/src/mips32/mips_blocktask.c index 24496ab9f76e3..5971f02137d1c 100644 --- a/arch/mips/src/mips32/mips_blocktask.c +++ b/arch/mips/src/mips32/mips_blocktask.c @@ -136,15 +136,6 @@ void up_block_task(struct tcb_s *tcb, tstate_t task_state) struct tcb_s *nexttcb = this_task(); -#ifdef CONFIG_ARCH_ADDRENV - /* Make sure that the address environment for the previously - * running task is closed down gracefully (data caches dump, - * MMU flushed) and set up the address environment for the new - * thread at the head of the ready-to-run list. - */ - - group_addrenv(nexttcb); -#endif /* Reset scheduler parameters */ nxsched_resume_scheduler(nexttcb); diff --git a/arch/mips/src/mips32/mips_dumpstate.c b/arch/mips/src/mips32/mips_dumpstate.c index 19f212c55c723..779f07d11cb5b 100644 --- a/arch/mips/src/mips32/mips_dumpstate.c +++ b/arch/mips/src/mips32/mips_dumpstate.c @@ -128,7 +128,7 @@ static inline void mips_registerdump(void) void up_dumpstate(void) { - FAR struct tcb_s *rtcb = running_task(); + struct tcb_s *rtcb = running_task(); uint32_t sp = up_getsp(); uint32_t ustackbase; uint32_t ustacksize; diff --git a/arch/mips/src/mips32/mips_releasepending.c b/arch/mips/src/mips32/mips_releasepending.c index 33fa8081c4813..4c061e5bd41d5 100644 --- a/arch/mips/src/mips32/mips_releasepending.c +++ b/arch/mips/src/mips32/mips_releasepending.c @@ -107,15 +107,6 @@ void up_release_pending(void) struct tcb_s *nexttcb = this_task(); -#ifdef CONFIG_ARCH_ADDRENV - /* Make sure that the address environment for the previously - * running task is closed down gracefully (data caches dump, - * MMU flushed) and set up the address environment for the new - * thread at the head of the ready-to-run list. - */ - - group_addrenv(nexttcb); -#endif /* Update scheduler parameters */ nxsched_resume_scheduler(nexttcb); diff --git a/arch/mips/src/mips32/mips_reprioritizertr.c b/arch/mips/src/mips32/mips_reprioritizertr.c index 5d04a58638805..7a99968d9c207 100644 --- a/arch/mips/src/mips32/mips_reprioritizertr.c +++ b/arch/mips/src/mips32/mips_reprioritizertr.c @@ -159,15 +159,6 @@ void up_reprioritize_rtr(struct tcb_s *tcb, uint8_t priority) struct tcb_s *nexttcb = this_task(); -#ifdef CONFIG_ARCH_ADDRENV - /* Make sure that the address environment for the previously - * running task is closed down gracefully (data caches dump, - * MMU flushed) and set up the address environment for the new - * thread at the head of the ready-to-run list. - */ - - group_addrenv(nexttcb); -#endif /* Update scheduler parameters */ nxsched_resume_scheduler(nexttcb); diff --git a/arch/mips/src/mips32/mips_swint0.c b/arch/mips/src/mips32/mips_swint0.c index 9cca35bcd3d2f..191025bb62861 100644 --- a/arch/mips/src/mips32/mips_swint0.c +++ b/arch/mips/src/mips32/mips_swint0.c @@ -127,7 +127,7 @@ static void dispatch_syscall(void) * ****************************************************************************/ -int up_swint0(int irq, FAR void *context, FAR void *arg) +int up_swint0(int irq, void *context, void *arg) { uint32_t *regs = (uint32_t *)context; uint32_t cause; @@ -230,7 +230,7 @@ int up_swint0(int irq, FAR void *context, FAR void *arg) */ rtcb->flags &= ~TCB_FLAG_SYSCALL; - (void)nxsig_unmask_pendingsignal(); + nxsig_unmask_pendingsignal(); } break; #endif @@ -243,7 +243,7 @@ int up_swint0(int irq, FAR void *context, FAR void *arg) default: { #ifdef CONFIG_BUILD_KERNEL - FAR struct tcb_s *rtcb = nxsched_self(); + struct tcb_s *rtcb = nxsched_self(); int index = rtcb->xcp.nsyscalls; /* Verify that the SYS call number is within range */ diff --git a/arch/mips/src/mips32/mips_unblocktask.c b/arch/mips/src/mips32/mips_unblocktask.c index c822d2ee0ca4f..586fb4b226b5f 100644 --- a/arch/mips/src/mips32/mips_unblocktask.c +++ b/arch/mips/src/mips32/mips_unblocktask.c @@ -122,15 +122,6 @@ void up_unblock_task(struct tcb_s *tcb) struct tcb_s *nexttcb = this_task(); -#ifdef CONFIG_ARCH_ADDRENV - /* Make sure that the address environment for the previously - * running task is closed down gracefully (data caches dump, - * MMU flushed) and set up the address environment for the new - * thread at the head of the ready-to-run list. - */ - - group_addrenv(nexttcb); -#endif /* Update scheduler parameters */ nxsched_resume_scheduler(nexttcb); diff --git a/arch/mips/src/pic32mx/pic32mx.h b/arch/mips/src/pic32mx/pic32mx.h index ca5e8bcbc0033..34b977fb4fc8e 100644 --- a/arch/mips/src/pic32mx/pic32mx.h +++ b/arch/mips/src/pic32mx/pic32mx.h @@ -111,7 +111,7 @@ * Public Types ************************************************************************************/ -typedef FAR void *DMA_HANDLE; +typedef void *DMA_HANDLE; typedef void (*dma_callback_t)(DMA_HANDLE handle, void *arg, int result); /* The following is used for sampling DMA registers when CONFIG DEBUG_DMA @@ -388,7 +388,7 @@ void pic32mx_dumpgpio(uint32_t pinset, const char *msg); ************************************************************************************/ struct spi_dev_s; /* Forward reference */ -FAR struct spi_dev_s *pic32mx_spibus_initialize(int port); +struct spi_dev_s *pic32mx_spibus_initialize(int port); /************************************************************************************ * Name: pic32mx_spiNselect, pic32mx_spiNstatus, and pic32mx_spiNcmddata @@ -419,38 +419,38 @@ FAR struct spi_dev_s *pic32mx_spibus_initialize(int port); ************************************************************************************/ #ifdef CONFIG_PIC32MX_SPI1 -void pic32mx_spi1select(FAR struct spi_dev_s *dev, uint32_t devid, +void pic32mx_spi1select(struct spi_dev_s *dev, uint32_t devid, bool selected); -uint8_t pic32mx_spi1status(FAR struct spi_dev_s *dev, uint32_t devid); +uint8_t pic32mx_spi1status(struct spi_dev_s *dev, uint32_t devid); #ifdef CONFIG_SPI_CMDDATA -int pic32mx_spi1cmddata(FAR struct spi_dev_s *dev, uint32_t devid, bool cmd); +int pic32mx_spi1cmddata(struct spi_dev_s *dev, uint32_t devid, bool cmd); #endif #endif #ifdef CONFIG_PIC32MX_SPI2 -void pic32mx_spi2select(FAR struct spi_dev_s *dev, uint32_t devid, +void pic32mx_spi2select(struct spi_dev_s *dev, uint32_t devid, bool selected); -uint8_t pic32mx_spi2status(FAR struct spi_dev_s *dev, uint32_t devid); +uint8_t pic32mx_spi2status(struct spi_dev_s *dev, uint32_t devid); #ifdef CONFIG_SPI_CMDDATA -int pic32mx_spi2cmddata(FAR struct spi_dev_s *dev, uint32_t devid, bool cmd); +int pic32mx_spi2cmddata(struct spi_dev_s *dev, uint32_t devid, bool cmd); #endif #endif #ifdef CONFIG_PIC32MX_SPI3 -void pic32mx_spi3select(FAR struct spi_dev_s *dev, uint32_t devid, +void pic32mx_spi3select(struct spi_dev_s *dev, uint32_t devid, bool selected); -uint8_t pic32mx_spi3status(FAR struct spi_dev_s *dev, uint32_t devid); +uint8_t pic32mx_spi3status(struct spi_dev_s *dev, uint32_t devid); #ifdef CONFIG_SPI_CMDDATA -int pic32mx_spi3cmddata(FAR struct spi_dev_s *dev, uint32_t devid, bool cmd); +int pic32mx_spi3cmddata(struct spi_dev_s *dev, uint32_t devid, bool cmd); #endif #endif #ifdef CONFIG_PIC32MX_SPI3 -void pic32mx_spi3select(FAR struct spi_dev_s *dev, uint32_t devid, +void pic32mx_spi3select(struct spi_dev_s *dev, uint32_t devid, bool selected); -uint8_t pic32mx_spi3status(FAR struct spi_dev_s *dev, uint32_t devid); +uint8_t pic32mx_spi3status(struct spi_dev_s *dev, uint32_t devid); #ifdef CONFIG_SPI_CMDDATA -int pic32mx_spi3cmddata(FAR struct spi_dev_s *dev, uint32_t devid, bool cmd); +int pic32mx_spi3cmddata(struct spi_dev_s *dev, uint32_t devid, bool cmd); #endif #endif @@ -589,7 +589,7 @@ void pic32mx_dmadump(DMA_HANDLE handle, const struct pic32mx_dmaregs_s *regs, #ifdef CONFIG_PIC32MX_USBDEV struct usbdev_s; -int pic32mx_usbpullup(FAR struct usbdev_s *dev, bool enable); +int pic32mx_usbpullup(struct usbdev_s *dev, bool enable); #endif /************************************************************************************ @@ -604,7 +604,7 @@ int pic32mx_usbpullup(FAR struct usbdev_s *dev, bool enable); ************************************************************************************/ #ifdef CONFIG_PIC32MX_USBDEV -void pic32mx_usbsuspend(FAR struct usbdev_s *dev, bool resume); +void pic32mx_usbsuspend(struct usbdev_s *dev, bool resume); #endif /************************************************************************************ diff --git a/arch/mips/src/pic32mx/pic32mx_ethernet.c b/arch/mips/src/pic32mx/pic32mx_ethernet.c index 26d5734c7ad6f..3a2df1d3ed8ba 100644 --- a/arch/mips/src/pic32mx/pic32mx_ethernet.c +++ b/arch/mips/src/pic32mx/pic32mx_ethernet.c @@ -215,7 +215,7 @@ * header */ -#define BUF ((FAR struct eth_hdr_s *)priv->pd_dev.d_buf) +#define BUF ((struct eth_hdr_s *)priv->pd_dev.d_buf) /* PHYs *********************************************************************/ @@ -1889,7 +1889,7 @@ static void pic32mx_interrupt_work(void *arg) * ****************************************************************************/ -static int pic32mx_interrupt(int irq, void *context, FAR void *arg) +static int pic32mx_interrupt(int irq, void *context, void *arg) { struct pic32mx_driver_s *priv; uint32_t status; diff --git a/arch/mips/src/pic32mx/pic32mx_gpioirq.c b/arch/mips/src/pic32mx/pic32mx_gpioirq.c index 2c23f90c49c0b..cb8584aa39918 100644 --- a/arch/mips/src/pic32mx/pic32mx_gpioirq.c +++ b/arch/mips/src/pic32mx/pic32mx_gpioirq.c @@ -84,7 +84,7 @@ static inline bool pic32mx_pullup(uint16_t pinset) * ****************************************************************************/ -static int pic32mx_cninterrupt(int irq, FAR void *context) +static int pic32mx_cninterrupt(int irq, void *context) { int status; int ret = OK; diff --git a/arch/mips/src/pic32mx/pic32mx_spi.c b/arch/mips/src/pic32mx/pic32mx_spi.c index 52c62ac1d2c54..c937ac14ac90d 100644 --- a/arch/mips/src/pic32mx/pic32mx_spi.c +++ b/arch/mips/src/pic32mx/pic32mx_spi.c @@ -87,22 +87,22 @@ struct pic32mx_dev_s /* Low-level register access */ -static uint32_t spi_getreg(FAR struct pic32mx_dev_s *priv, +static uint32_t spi_getreg(struct pic32mx_dev_s *priv, unsigned int offset); -static void spi_putreg(FAR struct pic32mx_dev_s *priv, +static void spi_putreg(struct pic32mx_dev_s *priv, unsigned int offset, uint32_t value); /* SPI methods */ -static int spi_lock(FAR struct spi_dev_s *dev, bool lock); -static uint32_t spi_setfrequency(FAR struct spi_dev_s *dev, +static int spi_lock(struct spi_dev_s *dev, bool lock); +static uint32_t spi_setfrequency(struct spi_dev_s *dev, uint32_t frequency); -static void spi_setmode(FAR struct spi_dev_s *dev, enum spi_mode_e mode); -static void spi_setbits(FAR struct spi_dev_s *dev, int nbits); -static uint32_t spi_send(FAR struct spi_dev_s *dev, uint32_t wd); -static void spi_sndblock(FAR struct spi_dev_s *dev, - FAR const void *buffer, size_t nwords); -static void spi_recvblock(FAR struct spi_dev_s *dev, FAR void *buffer, +static void spi_setmode(struct spi_dev_s *dev, enum spi_mode_e mode); +static void spi_setbits(struct spi_dev_s *dev, int nbits); +static uint32_t spi_send(struct spi_dev_s *dev, uint32_t wd); +static void spi_sndblock(struct spi_dev_s *dev, + const void *buffer, size_t nwords); +static void spi_recvblock(struct spi_dev_s *dev, void *buffer, size_t nwords); /**************************************************************************** @@ -288,7 +288,7 @@ static struct pic32mx_dev_s g_spi4dev = ****************************************************************************/ #ifdef CONFIG_PIC32MX_SPI_REGDEBUG -static uint32_t spi_getreg(FAR struct pic32mx_dev_s *priv, +static uint32_t spi_getreg(struct pic32mx_dev_s *priv, unsigned int offset) { /* Last address, value, and count */ @@ -350,7 +350,7 @@ static uint32_t spi_getreg(FAR struct pic32mx_dev_s *priv, return value; } #else -static uint32_t spi_getreg(FAR struct pic32mx_dev_s *priv, +static uint32_t spi_getreg(struct pic32mx_dev_s *priv, unsigned int offset) { return getreg32(priv->base + offset); @@ -374,7 +374,7 @@ static uint32_t spi_getreg(FAR struct pic32mx_dev_s *priv, ****************************************************************************/ #ifdef CONFIG_PIC32MX_SPI_REGDEBUG -static void spi_putreg(FAR struct pic32mx_dev_s *priv, unsigned int offset, +static void spi_putreg(struct pic32mx_dev_s *priv, unsigned int offset, uint32_t value) { uint32_t addr; @@ -392,7 +392,7 @@ static void spi_putreg(FAR struct pic32mx_dev_s *priv, unsigned int offset, putreg32(value, addr); } #else -static void spi_putreg(FAR struct pic32mx_dev_s *priv, unsigned int offset, +static void spi_putreg(struct pic32mx_dev_s *priv, unsigned int offset, uint32_t value) { putreg32(value, priv->base + offset); @@ -420,9 +420,9 @@ static void spi_putreg(FAR struct pic32mx_dev_s *priv, unsigned int offset, * ****************************************************************************/ -static int spi_lock(FAR struct spi_dev_s *dev, bool lock) +static int spi_lock(struct spi_dev_s *dev, bool lock) { - FAR struct pic32mx_dev_s *priv = (FAR struct pic32mx_dev_s *)dev; + struct pic32mx_dev_s *priv = (struct pic32mx_dev_s *)dev; int ret; if (lock) @@ -452,10 +452,10 @@ static int spi_lock(FAR struct spi_dev_s *dev, bool lock) * ****************************************************************************/ -static uint32_t spi_setfrequency(FAR struct spi_dev_s *dev, +static uint32_t spi_setfrequency(struct spi_dev_s *dev, uint32_t frequency) { - FAR struct pic32mx_dev_s *priv = (FAR struct pic32mx_dev_s *)dev; + struct pic32mx_dev_s *priv = (struct pic32mx_dev_s *)dev; uint32_t divisor; uint32_t actual; uint32_t regval; @@ -534,9 +534,9 @@ static uint32_t spi_setfrequency(FAR struct spi_dev_s *dev, * ****************************************************************************/ -static void spi_setmode(FAR struct spi_dev_s *dev, enum spi_mode_e mode) +static void spi_setmode(struct spi_dev_s *dev, enum spi_mode_e mode) { - FAR struct pic32mx_dev_s *priv = (FAR struct pic32mx_dev_s *)dev; + struct pic32mx_dev_s *priv = (struct pic32mx_dev_s *)dev; uint32_t regval; spiinfo("Old mode: %d New mode: %d\n", priv->mode, mode); @@ -624,9 +624,9 @@ static void spi_setmode(FAR struct spi_dev_s *dev, enum spi_mode_e mode) * ****************************************************************************/ -static void spi_setbits(FAR struct spi_dev_s *dev, int nbits) +static void spi_setbits(struct spi_dev_s *dev, int nbits) { - FAR struct pic32mx_dev_s *priv = (FAR struct pic32mx_dev_s *)dev; + struct pic32mx_dev_s *priv = (struct pic32mx_dev_s *)dev; uint32_t setting; uint32_t regval; @@ -688,9 +688,9 @@ static void spi_setbits(FAR struct spi_dev_s *dev, int nbits) * ****************************************************************************/ -static uint32_t spi_send(FAR struct spi_dev_s *dev, uint32_t wd) +static uint32_t spi_send(struct spi_dev_s *dev, uint32_t wd) { - FAR struct pic32mx_dev_s *priv = (FAR struct pic32mx_dev_s *)dev; + struct pic32mx_dev_s *priv = (struct pic32mx_dev_s *)dev; spiinfo("wd: %04" PRIx32 "\n", wd); @@ -739,11 +739,11 @@ static uint32_t spi_send(FAR struct spi_dev_s *dev, uint32_t wd) * ****************************************************************************/ -static void spi_sndblock(FAR struct spi_dev_s *dev, FAR const void *buffer, +static void spi_sndblock(struct spi_dev_s *dev, const void *buffer, size_t nwords) { - FAR struct pic32mx_dev_s *priv = (FAR struct pic32mx_dev_s *)dev; - FAR uint8_t *ptr = (FAR uint8_t *)buffer; + struct pic32mx_dev_s *priv = (struct pic32mx_dev_s *)dev; + uint8_t *ptr = (uint8_t *)buffer; uint32_t regval; uint8_t data; @@ -801,11 +801,11 @@ static void spi_sndblock(FAR struct spi_dev_s *dev, FAR const void *buffer, * ****************************************************************************/ -static void spi_recvblock(FAR struct spi_dev_s *dev, FAR void *buffer, +static void spi_recvblock(struct spi_dev_s *dev, void *buffer, size_t nwords) { - FAR struct pic32mx_dev_s *priv = (FAR struct pic32mx_dev_s *)dev; - FAR uint8_t *ptr = (FAR uint8_t *)buffer; + struct pic32mx_dev_s *priv = (struct pic32mx_dev_s *)dev; + uint8_t *ptr = (uint8_t *)buffer; spiinfo("nwords: %d\n", nwords); while (nwords) @@ -859,9 +859,9 @@ static void spi_recvblock(FAR struct spi_dev_s *dev, FAR void *buffer, * ****************************************************************************/ -FAR struct spi_dev_s *pic32mx_spibus_initialize(int port) +struct spi_dev_s *pic32mx_spibus_initialize(int port) { - FAR struct pic32mx_dev_s *priv; + struct pic32mx_dev_s *priv; irqstate_t flags; uint32_t regval; @@ -937,7 +937,7 @@ FAR struct spi_dev_s *pic32mx_spibus_initialize(int port) /* Select a default frequency of approx. 400KHz */ - spi_setfrequency((FAR struct spi_dev_s *)priv, 400000); + spi_setfrequency((struct spi_dev_s *)priv, 400000); /* Clear the SPIROV overflow bit (SPIxSTAT:6). */ diff --git a/arch/mips/src/pic32mx/pic32mx_usbdev.c b/arch/mips/src/pic32mx/pic32mx_usbdev.c index 14d85ccecd7b4..ef292c00e9ec3 100644 --- a/arch/mips/src/pic32mx/pic32mx_usbdev.c +++ b/arch/mips/src/pic32mx/pic32mx_usbdev.c @@ -484,7 +484,7 @@ static void pic32mx_ep0outcomplete(struct pic32mx_usbdev_s *priv); static void pic32mx_ep0incomplete(struct pic32mx_usbdev_s *priv); static void pic32mx_ep0transfer(struct pic32mx_usbdev_s *priv, uint16_t ustat); -static int pic32mx_interrupt(int irq, void *context, FAR void *arg); +static int pic32mx_interrupt(int irq, void *context, void *arg); /* Endpoint helpers *********************************************************/ @@ -2697,7 +2697,7 @@ static void pic32mx_ep0transfer(struct pic32mx_usbdev_s *priv, * Name: pic32mx_interrupt ****************************************************************************/ -static int pic32mx_interrupt(int irq, void *context, FAR void *arg) +static int pic32mx_interrupt(int irq, void *context, void *arg) { /* For now there is only one USB controller, but we will always refer to * it using a pointer to make any future ports to multiple USB controllers diff --git a/arch/mips/src/pic32mz/pic32mz_dma.c b/arch/mips/src/pic32mz/pic32mz_dma.c index 3fc8cf2173114..596cddf761cf7 100644 --- a/arch/mips/src/pic32mz/pic32mz_dma.c +++ b/arch/mips/src/pic32mz/pic32mz_dma.c @@ -86,46 +86,46 @@ struct pic32mz_dmac_s static int pic32mz_dma_takesem(struct pic32mz_dmac_s *dmac); static inline void pic32mz_dma_givesem(struct pic32mz_dmac_s *dmac); -static inline uint32_t pic32mz_dma_getreg(FAR struct pic32mz_dmach_s *dmach, +static inline uint32_t pic32mz_dma_getreg(struct pic32mz_dmach_s *dmach, uint8_t offset); -static inline void pic32mz_dma_putreg(FAR struct pic32mz_dmach_s *dmach, +static inline void pic32mz_dma_putreg(struct pic32mz_dmach_s *dmach, uint8_t offset, uint32_t value); -static inline void pic32mz_dma_modifyreg(FAR struct pic32mz_dmach_s *dmach, +static inline void pic32mz_dma_modifyreg(struct pic32mz_dmach_s *dmach, uint8_t offset, uint32_t clrbits, uint32_t setbits); static inline uint32_t pic32mz_dma_getglobal(uint8_t offset); static inline void pic32mz_dma_putglobal(uint8_t offset, uint32_t value); -static inline void pic32mz_dma_enable(FAR struct pic32mz_dmach_s *dmach); -static inline void pic32mz_dma_disable(FAR struct pic32mz_dmach_s *dmach); -static inline void pic32mz_dma_priority(FAR struct pic32mz_dmach_s *dmach, +static inline void pic32mz_dma_enable(struct pic32mz_dmach_s *dmach); +static inline void pic32mz_dma_disable(struct pic32mz_dmach_s *dmach); +static inline void pic32mz_dma_priority(struct pic32mz_dmach_s *dmach, uint8_t priority); -static inline void pic32mz_dma_srcaddr(FAR struct pic32mz_dmach_s *dmach, +static inline void pic32mz_dma_srcaddr(struct pic32mz_dmach_s *dmach, uint32_t addr); -static inline void pic32mz_dma_destaddr(FAR struct pic32mz_dmach_s *dmach, +static inline void pic32mz_dma_destaddr(struct pic32mz_dmach_s *dmach, uint32_t addr); -static inline void pic32mz_dma_srcsize(FAR struct pic32mz_dmach_s *dmach, +static inline void pic32mz_dma_srcsize(struct pic32mz_dmach_s *dmach, uint16_t size); -static inline void pic32mz_dma_destsize(FAR struct pic32mz_dmach_s *dmach, +static inline void pic32mz_dma_destsize(struct pic32mz_dmach_s *dmach, uint16_t size); -static inline void pic32mz_dma_cellsize(FAR struct pic32mz_dmach_s *dmach, +static inline void pic32mz_dma_cellsize(struct pic32mz_dmach_s *dmach, uint16_t size); -static inline void pic32mz_dma_startirq(FAR struct pic32mz_dmach_s *dmach, +static inline void pic32mz_dma_startirq(struct pic32mz_dmach_s *dmach, int irq); -static inline void pic32mz_dma_forcestart(FAR struct pic32mz_dmach_s *dmach); -static inline void pic32mz_dma_abortirq(FAR struct pic32mz_dmach_s *dmach, +static inline void pic32mz_dma_forcestart(struct pic32mz_dmach_s *dmach); +static inline void pic32mz_dma_abortirq(struct pic32mz_dmach_s *dmach, int irq); -static inline void pic32mz_dma_forceabort(FAR struct pic32mz_dmach_s *dmach); +static inline void pic32mz_dma_forceabort(struct pic32mz_dmach_s *dmach); -static inline void pic32mz_dma_intctrl(FAR struct pic32mz_dmach_s *dmach, +static inline void pic32mz_dma_intctrl(struct pic32mz_dmach_s *dmach, uint8_t cfg); -static inline void pic32mz_dma_intclr(FAR struct pic32mz_dmach_s *dmach); -static int pic32mz_dma_interrupt(int irq, void *context, FAR void *arg); +static inline void pic32mz_dma_intclr(struct pic32mz_dmach_s *dmach); +static int pic32mz_dma_interrupt(int irq, void *context, void *arg); -static void pic32mz_dma_mode(FAR struct pic32mz_dmach_s *dmach, +static void pic32mz_dma_mode(struct pic32mz_dmach_s *dmach, uint8_t mode); -static void pic32mz_dma_config(FAR struct pic32mz_dmach_s *dmach, - FAR const struct pic32mz_dma_chcfg_s *cfg); +static void pic32mz_dma_config(struct pic32mz_dmach_s *dmach, + const struct pic32mz_dma_chcfg_s *cfg); /**************************************************************************** * Private Data @@ -218,7 +218,7 @@ static inline void pic32mz_dma_givesem(struct pic32mz_dmac_s *dmac) * ****************************************************************************/ -static inline uint32_t pic32mz_dma_getreg(FAR struct pic32mz_dmach_s *dmach, +static inline uint32_t pic32mz_dma_getreg(struct pic32mz_dmach_s *dmach, uint8_t offset) { return getreg32(dmach->base + offset); @@ -232,7 +232,7 @@ static inline uint32_t pic32mz_dma_getreg(FAR struct pic32mz_dmach_s *dmach, * ****************************************************************************/ -static inline void pic32mz_dma_putreg(FAR struct pic32mz_dmach_s *dmach, +static inline void pic32mz_dma_putreg(struct pic32mz_dmach_s *dmach, uint8_t offset, uint32_t value) { putreg32(value, dmach->base + offset); @@ -246,7 +246,7 @@ static inline void pic32mz_dma_putreg(FAR struct pic32mz_dmach_s *dmach, * ****************************************************************************/ -static inline void pic32mz_dma_modifyreg(FAR struct pic32mz_dmach_s *dmach, +static inline void pic32mz_dma_modifyreg(struct pic32mz_dmach_s *dmach, uint8_t offset, uint32_t clrbits, uint32_t setbits) { @@ -287,7 +287,7 @@ static inline void pic32mz_dma_putglobal(uint8_t offset, uint32_t value) * ****************************************************************************/ -static inline void pic32mz_dma_enable(FAR struct pic32mz_dmach_s *dmach) +static inline void pic32mz_dma_enable(struct pic32mz_dmach_s *dmach) { pic32mz_dma_putreg(dmach, PIC32MZ_DMA_CONSET_OFFSET, DMACH_CON_CHEN); } @@ -300,7 +300,7 @@ static inline void pic32mz_dma_enable(FAR struct pic32mz_dmach_s *dmach) * ****************************************************************************/ -static inline void pic32mz_dma_disable(FAR struct pic32mz_dmach_s *dmach) +static inline void pic32mz_dma_disable(struct pic32mz_dmach_s *dmach) { pic32mz_dma_putreg(dmach, PIC32MZ_DMA_CONCLR_OFFSET, DMACH_CON_CHEN); } @@ -313,7 +313,7 @@ static inline void pic32mz_dma_disable(FAR struct pic32mz_dmach_s *dmach) * ****************************************************************************/ -static inline void pic32mz_dma_priority(FAR struct pic32mz_dmach_s *dmach, +static inline void pic32mz_dma_priority(struct pic32mz_dmach_s *dmach, uint8_t priority) { /* Highest priority is 3. */ @@ -334,7 +334,7 @@ static inline void pic32mz_dma_priority(FAR struct pic32mz_dmach_s *dmach, * ****************************************************************************/ -static inline void pic32mz_dma_srcaddr(FAR struct pic32mz_dmach_s *dmach, +static inline void pic32mz_dma_srcaddr(struct pic32mz_dmach_s *dmach, uint32_t addr) { pic32mz_dma_putreg(dmach, PIC32MZ_DMACH_SSA_OFFSET, PHYS_ADDR(addr)); @@ -348,7 +348,7 @@ static inline void pic32mz_dma_srcaddr(FAR struct pic32mz_dmach_s *dmach, * ****************************************************************************/ -static inline void pic32mz_dma_destaddr(FAR struct pic32mz_dmach_s *dmach, +static inline void pic32mz_dma_destaddr(struct pic32mz_dmach_s *dmach, uint32_t addr) { pic32mz_dma_putreg(dmach, PIC32MZ_DMACH_DSA_OFFSET, PHYS_ADDR(addr)); @@ -362,7 +362,7 @@ static inline void pic32mz_dma_destaddr(FAR struct pic32mz_dmach_s *dmach, * ****************************************************************************/ -static inline void pic32mz_dma_srcsize(FAR struct pic32mz_dmach_s *dmach, +static inline void pic32mz_dma_srcsize(struct pic32mz_dmach_s *dmach, uint16_t size) { pic32mz_dma_putreg(dmach, PIC32MZ_DMACH_SSIZ_OFFSET, size); @@ -376,7 +376,7 @@ static inline void pic32mz_dma_srcsize(FAR struct pic32mz_dmach_s *dmach, * ****************************************************************************/ -static inline void pic32mz_dma_destsize(FAR struct pic32mz_dmach_s *dmach, +static inline void pic32mz_dma_destsize(struct pic32mz_dmach_s *dmach, uint16_t size) { pic32mz_dma_putreg(dmach, PIC32MZ_DMACH_DSIZ_OFFSET, size); @@ -390,7 +390,7 @@ static inline void pic32mz_dma_destsize(FAR struct pic32mz_dmach_s *dmach, * ****************************************************************************/ -static inline void pic32mz_dma_cellsize(FAR struct pic32mz_dmach_s *dmach, +static inline void pic32mz_dma_cellsize(struct pic32mz_dmach_s *dmach, uint16_t size) { pic32mz_dma_putreg(dmach, PIC32MZ_DMACH_CSIZ_OFFSET, size); @@ -404,7 +404,7 @@ static inline void pic32mz_dma_cellsize(FAR struct pic32mz_dmach_s *dmach, * ****************************************************************************/ -static inline void pic32mz_dma_startirq(FAR struct pic32mz_dmach_s *dmach, +static inline void pic32mz_dma_startirq(struct pic32mz_dmach_s *dmach, int irq) { /* Enable start irq matching. */ @@ -426,7 +426,7 @@ static inline void pic32mz_dma_startirq(FAR struct pic32mz_dmach_s *dmach, * ****************************************************************************/ -static inline void pic32mz_dma_forcestart(FAR struct pic32mz_dmach_s *dmach) +static inline void pic32mz_dma_forcestart(struct pic32mz_dmach_s *dmach) { pic32mz_dma_putreg(dmach, PIC32MZ_DMACH_ECONSET_OFFSET, DMACH_ECON_CFORCE); } @@ -439,7 +439,7 @@ static inline void pic32mz_dma_forcestart(FAR struct pic32mz_dmach_s *dmach) * ****************************************************************************/ -static inline void pic32mz_dma_abortirq(FAR struct pic32mz_dmach_s *dmach, +static inline void pic32mz_dma_abortirq(struct pic32mz_dmach_s *dmach, int irq) { /* Enable abort irq matching. */ @@ -461,7 +461,7 @@ static inline void pic32mz_dma_abortirq(FAR struct pic32mz_dmach_s *dmach, * ****************************************************************************/ -static inline void pic32mz_dma_forceabort(FAR struct pic32mz_dmach_s *dmach) +static inline void pic32mz_dma_forceabort(struct pic32mz_dmach_s *dmach) { pic32mz_dma_putreg(dmach, PIC32MZ_DMACH_ECONSET_OFFSET, DMACH_ECON_CABORT); } @@ -474,7 +474,7 @@ static inline void pic32mz_dma_forceabort(FAR struct pic32mz_dmach_s *dmach) * ****************************************************************************/ -static inline void pic32mz_dma_intclr(FAR struct pic32mz_dmach_s *dmach) +static inline void pic32mz_dma_intclr(struct pic32mz_dmach_s *dmach) { pic32mz_dma_putreg(dmach, PIC32MZ_DMACH_INTCLR_OFFSET, DMACH_INT_FLAGS_MASK); @@ -488,7 +488,7 @@ static inline void pic32mz_dma_intclr(FAR struct pic32mz_dmach_s *dmach) * ****************************************************************************/ -static inline void pic32mz_dma_intctrl(FAR struct pic32mz_dmach_s *dmach, +static inline void pic32mz_dma_intctrl(struct pic32mz_dmach_s *dmach, uint8_t cfg) { /* Clear all interrupts flags */ @@ -514,7 +514,7 @@ static inline void pic32mz_dma_intctrl(FAR struct pic32mz_dmach_s *dmach, * ****************************************************************************/ -static int pic32mz_dma_interrupt(int irq, void *context, FAR void *arg) +static int pic32mz_dma_interrupt(int irq, void *context, void *arg) { struct pic32mz_dmach_s *dmach; uint8_t status; @@ -553,7 +553,7 @@ static int pic32mz_dma_interrupt(int irq, void *context, FAR void *arg) * ****************************************************************************/ -static void pic32mz_dma_mode(FAR struct pic32mz_dmach_s *dmach, +static void pic32mz_dma_mode(struct pic32mz_dmach_s *dmach, uint8_t mode) { if (mode & PIC32MZ_DMA_MODE_BASIC) @@ -576,8 +576,8 @@ static void pic32mz_dma_mode(FAR struct pic32mz_dmach_s *dmach, * ****************************************************************************/ -static void pic32mz_dma_config(FAR struct pic32mz_dmach_s *dmach, - FAR const struct pic32mz_dma_chcfg_s *cfg) +static void pic32mz_dma_config(struct pic32mz_dmach_s *dmach, + const struct pic32mz_dma_chcfg_s *cfg) { /* Set the channel's priority */ @@ -888,7 +888,7 @@ void pic32mz_dma_free(DMA_HANDLE handle) ****************************************************************************/ int pic32mz_dma_chcfg(DMA_HANDLE handle, - FAR const struct pic32mz_dma_chcfg_s *cfg) + const struct pic32mz_dma_chcfg_s *cfg) { struct pic32mz_dmach_s *dmach = (struct pic32mz_dmach_s *)handle; @@ -908,7 +908,7 @@ int pic32mz_dma_chcfg(DMA_HANDLE handle, ****************************************************************************/ int pic32mz_dma_xfrsetup(DMA_HANDLE handle, - FAR const struct pic32mz_dma_xfrcfg_s *cfg) + const struct pic32mz_dma_xfrcfg_s *cfg) { struct pic32mz_dmach_s *dmach = (struct pic32mz_dmach_s *)handle; diff --git a/arch/mips/src/pic32mz/pic32mz_dma.h b/arch/mips/src/pic32mz/pic32mz_dma.h index eea67b8b1be3d..fe00b82779a4f 100644 --- a/arch/mips/src/pic32mz/pic32mz_dma.h +++ b/arch/mips/src/pic32mz/pic32mz_dma.h @@ -80,7 +80,7 @@ #ifndef __ASSEMBLY__ -typedef FAR void *DMA_HANDLE; +typedef void *DMA_HANDLE; typedef void (*dma_callback_t)(DMA_HANDLE handle, uint8_t status, void *arg); /* DMA channel modes, arguments for pic32mz_dma_mode. */ @@ -247,7 +247,7 @@ void pic32mz_dma_free(DMA_HANDLE handle); ****************************************************************************/ int pic32mz_dma_chcfg(DMA_HANDLE handle, - FAR const struct pic32mz_dma_chcfg_s *cfg); + const struct pic32mz_dma_chcfg_s *cfg); /**************************************************************************** * Name: pic32mz_dma_xfrsetup @@ -258,7 +258,7 @@ int pic32mz_dma_chcfg(DMA_HANDLE handle, ****************************************************************************/ int pic32mz_dma_xfrsetup(DMA_HANDLE handle, - FAR const struct pic32mz_dma_xfrcfg_s *cfg); + const struct pic32mz_dma_xfrcfg_s *cfg); /**************************************************************************** * Name: pic32mz_dma_start diff --git a/arch/mips/src/pic32mz/pic32mz_ethernet.c b/arch/mips/src/pic32mz/pic32mz_ethernet.c index 15f60d4f6fd7e..7c8745f34befe 100644 --- a/arch/mips/src/pic32mz/pic32mz_ethernet.c +++ b/arch/mips/src/pic32mz/pic32mz_ethernet.c @@ -252,7 +252,7 @@ * header */ -#define BUF ((FAR struct eth_hdr_s *)priv->pd_dev.d_buf) +#define BUF ((struct eth_hdr_s *)priv->pd_dev.d_buf) /* PHYs *********************************************************************/ @@ -454,7 +454,7 @@ static void pic32mz_rxdone(struct pic32mz_driver_s *priv); static void pic32mz_txdone(struct pic32mz_driver_s *priv); static void pic32mz_interrupt_work(void *arg); -static int pic32mz_interrupt(int irq, void *context, FAR void *arg); +static int pic32mz_interrupt(int irq, void *context, void *arg); /* Watchdog timer expirations */ @@ -2019,7 +2019,7 @@ static void pic32mz_interrupt_work(void *arg) * ****************************************************************************/ -static int pic32mz_interrupt(int irq, void *context, FAR void *arg) +static int pic32mz_interrupt(int irq, void *context, void *arg) { struct pic32mz_driver_s *priv; uint32_t status; diff --git a/arch/mips/src/pic32mz/pic32mz_freerun.h b/arch/mips/src/pic32mz/pic32mz_freerun.h index 6aaa122500921..6b94d0e9687d9 100644 --- a/arch/mips/src/pic32mz/pic32mz_freerun.h +++ b/arch/mips/src/pic32mz/pic32mz_freerun.h @@ -47,13 +47,13 @@ struct pic32mz_freerun_s { - uint8_t chan; /* The timer in use */ - uint8_t width; /* Width of timer (16- or 32) */ - FAR struct pic32mz_timer_dev_s *timer; /* PIC32MZ timer driver */ - uint32_t freq; /* Timer's frequency (Hz) */ + uint8_t chan; /* The timer in use */ + uint8_t width; /* Width of timer (16- or 32) */ + struct pic32mz_timer_dev_s *timer; /* PIC32MZ timer driver */ + uint32_t freq; /* Timer's frequency (Hz) */ #ifndef CONFIG_CLOCK_TIMEKEEPING - uint32_t overflow; /* Timer's counter overflow */ + uint32_t overflow; /* Timer's counter overflow */ #endif #ifdef CONFIG_CLOCK_TIMEKEEPING diff --git a/arch/mips/src/pic32mz/pic32mz_gpioirq.c b/arch/mips/src/pic32mz/pic32mz_gpioirq.c index 1ca378917fa1a..03e47c7aed3b8 100644 --- a/arch/mips/src/pic32mz/pic32mz_gpioirq.c +++ b/arch/mips/src/pic32mz/pic32mz_gpioirq.c @@ -58,7 +58,7 @@ static inline bool pic32mz_edgedetect(pinset_t pinset); static inline unsigned int pic32mz_edgemode(pinset_t pinset); static inline bool pic32mz_pullup(pinset_t pinset); static inline bool pic32mz_pulldown(pinset_t pinset); -static int pic32mz_cninterrupt(int irq, FAR void *context, FAR void *arg); +static int pic32mz_cninterrupt(int irq, void *context, void *arg); /**************************************************************************** * Public Data @@ -206,7 +206,7 @@ static inline unsigned int pic32mz_pin(pinset_t pinset) * ****************************************************************************/ -static int pic32mz_cninterrupt(int irq, FAR void *context, FAR void *arg) +static int pic32mz_cninterrupt(int irq, void *context, void *arg) { struct ioport_level2_s *handlers; xcpt_t handler; diff --git a/arch/mips/src/pic32mz/pic32mz_i2c.c b/arch/mips/src/pic32mz/pic32mz_i2c.c index 823e2dbc9450e..01530ed9a4b27 100644 --- a/arch/mips/src/pic32mz/pic32mz_i2c.c +++ b/arch/mips/src/pic32mz/pic32mz_i2c.c @@ -219,47 +219,47 @@ struct pic32mz_i2c_priv_s ****************************************************************************/ static inline uint32_t - pic32mz_i2c_getreg(FAR struct pic32mz_i2c_priv_s *priv, + pic32mz_i2c_getreg(struct pic32mz_i2c_priv_s *priv, uint8_t offset); -static inline void pic32mz_i2c_putreg(FAR struct pic32mz_i2c_priv_s *priv, +static inline void pic32mz_i2c_putreg(struct pic32mz_i2c_priv_s *priv, uint8_t offset, uint32_t value); -static inline void pic32mz_i2c_modifyreg(FAR struct pic32mz_i2c_priv_s *priv, +static inline void pic32mz_i2c_modifyreg(struct pic32mz_i2c_priv_s *priv, uint8_t offset, uint32_t clearbits, uint32_t setbits); #ifdef CONFIG_PICM32MZ_I2C_DYNTIMEO -static useconds_t pic32mz_i2c_tousecs(int msgc, FAR struct i2c_msg_s *msgs); +static useconds_t pic32mz_i2c_tousecs(int msgc, struct i2c_msg_s *msgs); #endif /* CONFIG_PIC32MZ_I2C_DYNTIMEO */ static inline int - pic32mz_i2c_sem_waitdone(FAR struct pic32mz_i2c_priv_s *priv); + pic32mz_i2c_sem_waitdone(struct pic32mz_i2c_priv_s *priv); static inline void - pic32mz_i2c_sem_waitidle(FAR struct pic32mz_i2c_priv_s *priv); -static inline void pic32mz_i2c_sem_post(FAR struct pic32mz_i2c_priv_s *priv); -static inline void pic32mz_i2c_sem_init(FAR struct pic32mz_i2c_priv_s *priv); + pic32mz_i2c_sem_waitidle(struct pic32mz_i2c_priv_s *priv); +static inline void pic32mz_i2c_sem_post(struct pic32mz_i2c_priv_s *priv); +static inline void pic32mz_i2c_sem_init(struct pic32mz_i2c_priv_s *priv); static inline void - pic32mz_i2c_sem_destroy(FAR struct pic32mz_i2c_priv_s *priv); + pic32mz_i2c_sem_destroy(struct pic32mz_i2c_priv_s *priv); #ifdef CONFIG_I2C_TRACE -static void pic32mz_i2c_tracereset(FAR struct pic32mz_i2c_priv_s *priv); -static void pic32mz_i2c_tracenew(FAR struct pic32mz_i2c_priv_s *priv, +static void pic32mz_i2c_tracereset(struct pic32mz_i2c_priv_s *priv); +static void pic32mz_i2c_tracenew(struct pic32mz_i2c_priv_s *priv, uint32_t status); static void - pic32mz_i2c_traceevent(FAR struct pic32mz_i2c_priv_s *priv, + pic32mz_i2c_traceevent(struct pic32mz_i2c_priv_s *priv, enum pic32mz_trace_e event, uint32_t parm); -static void pic32mz_i2c_tracedump(FAR struct pic32mz_i2c_priv_s *priv); +static void pic32mz_i2c_tracedump(struct pic32mz_i2c_priv_s *priv); #endif /* CONFIG_I2C_TRACE */ static inline int - pic32mz_i2c_setbaudrate(FAR struct pic32mz_i2c_priv_s *priv, + pic32mz_i2c_setbaudrate(struct pic32mz_i2c_priv_s *priv, uint32_t frequency); static inline void - pic32mz_i2c_send_start(FAR struct pic32mz_i2c_priv_s *priv); + pic32mz_i2c_send_start(struct pic32mz_i2c_priv_s *priv); static inline void - pic32mz_i2c_send_stop(FAR struct pic32mz_i2c_priv_s *priv); + pic32mz_i2c_send_stop(struct pic32mz_i2c_priv_s *priv); static inline void - pic32mz_i2c_send_repeatedstart(FAR struct pic32mz_i2c_priv_s *priv); -static inline void pic32mz_i2c_send_ack(FAR struct pic32mz_i2c_priv_s *priv, + pic32mz_i2c_send_repeatedstart(struct pic32mz_i2c_priv_s *priv); +static inline void pic32mz_i2c_send_ack(struct pic32mz_i2c_priv_s *priv, bool ack); static inline void pic32mz_i2c_transmitbyte(struct pic32mz_i2c_priv_s *priv, uint8_t data); @@ -267,23 +267,23 @@ static inline uint32_t pic32mz_i2c_receivebyte(struct pic32mz_i2c_priv_s *priv); static inline uint32_t - pic32mz_i2c_getstatus(FAR struct pic32mz_i2c_priv_s *priv); + pic32mz_i2c_getstatus(struct pic32mz_i2c_priv_s *priv); static inline bool - pic32mz_i2c_master_inactive(FAR struct pic32mz_i2c_priv_s *priv); + pic32mz_i2c_master_inactive(struct pic32mz_i2c_priv_s *priv); static int pic32mz_i2c_isr_process(struct pic32mz_i2c_priv_s * priv); #ifndef CONFIG_I2C_POLLED -static int pic32mz_i2c_isr(int irq, void *context, FAR void *arg); +static int pic32mz_i2c_isr(int irq, void *context, void *arg); #endif /* !CONFIG_I2C_POLLED */ -static int pic32mz_i2c_init(FAR struct pic32mz_i2c_priv_s *priv); -static int pic32mz_i2c_deinit(FAR struct pic32mz_i2c_priv_s *priv); +static int pic32mz_i2c_init(struct pic32mz_i2c_priv_s *priv); +static int pic32mz_i2c_deinit(struct pic32mz_i2c_priv_s *priv); -static int pic32mz_i2c_transfer(FAR struct i2c_master_s *dev, - FAR struct i2c_msg_s *msgs, int count); +static int pic32mz_i2c_transfer(struct i2c_master_s *dev, + struct i2c_msg_s *msgs, int count); #ifdef CONFIG_I2C_RESET -static int pic32mz_i2c_reset(FAR struct i2c_master_s *dev); +static int pic32mz_i2c_reset(struct i2c_master_s *dev); #endif /**************************************************************************** @@ -465,7 +465,7 @@ static struct pic32mz_i2c_priv_s pic32mz_i2c5_priv = ****************************************************************************/ #ifdef CONFIG_I2C_TRACE -static void pic32mz_i2c_traceclear(FAR struct pic32mz_i2c_priv_s *priv) +static void pic32mz_i2c_traceclear(struct pic32mz_i2c_priv_s *priv) { struct pic32mz_trace_s *trace = &priv->trace[priv->tndx]; @@ -476,7 +476,7 @@ static void pic32mz_i2c_traceclear(FAR struct pic32mz_i2c_priv_s *priv) trace->time = 0; /* Time of first status or event */ } -static void pic32mz_i2c_tracereset(FAR struct pic32mz_i2c_priv_s *priv) +static void pic32mz_i2c_tracereset(struct pic32mz_i2c_priv_s *priv) { /* Reset the trace info for a new data collection */ @@ -485,7 +485,7 @@ static void pic32mz_i2c_tracereset(FAR struct pic32mz_i2c_priv_s *priv) pic32mz_i2c_traceclear(priv); } -static void pic32mz_i2c_tracenew(FAR struct pic32mz_i2c_priv_s *priv, +static void pic32mz_i2c_tracenew(struct pic32mz_i2c_priv_s *priv, uint32_t status) { struct pic32mz_trace_s *trace = &priv->trace[priv->tndx]; @@ -525,7 +525,7 @@ static void pic32mz_i2c_tracenew(FAR struct pic32mz_i2c_priv_s *priv, } } -static void pic32mz_i2c_traceevent(FAR struct pic32mz_i2c_priv_s *priv, +static void pic32mz_i2c_traceevent(struct pic32mz_i2c_priv_s *priv, enum pic32mz_trace_e event, uint32_t parm) { struct pic32mz_trace_s *trace; @@ -552,7 +552,7 @@ static void pic32mz_i2c_traceevent(FAR struct pic32mz_i2c_priv_s *priv, } } -static void pic32mz_i2c_tracedump(FAR struct pic32mz_i2c_priv_s *priv) +static void pic32mz_i2c_tracedump(struct pic32mz_i2c_priv_s *priv) { struct pic32mz_trace_s *trace; int i; @@ -581,7 +581,7 @@ static void pic32mz_i2c_tracedump(FAR struct pic32mz_i2c_priv_s *priv) ****************************************************************************/ static inline uint32_t - pic32mz_i2c_getreg(FAR struct pic32mz_i2c_priv_s *priv, uint8_t offset) + pic32mz_i2c_getreg(struct pic32mz_i2c_priv_s *priv, uint8_t offset) { return getreg32(priv->config->base + offset); } @@ -594,7 +594,7 @@ static inline uint32_t * ****************************************************************************/ -static inline void pic32mz_i2c_putreg(FAR struct pic32mz_i2c_priv_s *priv, +static inline void pic32mz_i2c_putreg(struct pic32mz_i2c_priv_s *priv, uint8_t offset, uint32_t value) { putreg32(value, priv->config->base + offset); @@ -608,7 +608,7 @@ static inline void pic32mz_i2c_putreg(FAR struct pic32mz_i2c_priv_s *priv, * ****************************************************************************/ -static inline void pic32mz_i2c_modifyreg(FAR struct pic32mz_i2c_priv_s *priv, +static inline void pic32mz_i2c_modifyreg(struct pic32mz_i2c_priv_s *priv, uint8_t offset, uint32_t clearbits, uint32_t setbits) { @@ -625,7 +625,7 @@ static inline void pic32mz_i2c_modifyreg(FAR struct pic32mz_i2c_priv_s *priv, ****************************************************************************/ #ifdef CONFIG_PIC32MZ_I2C_DYNTIMEO -static useconds_t pic32mz_i2c_tousecs(int msgc, FAR struct i2c_msg_s *msgs) +static useconds_t pic32mz_i2c_tousecs(int msgc, struct i2c_msg_s *msgs) { size_t bytecount = 0; int i; @@ -658,7 +658,7 @@ static useconds_t pic32mz_i2c_tousecs(int msgc, FAR struct i2c_msg_s *msgs) #ifndef CONFIG_I2C_POLLED static inline int - pic32mz_i2c_sem_waitdone(FAR struct pic32mz_i2c_priv_s *priv) + pic32mz_i2c_sem_waitdone(struct pic32mz_i2c_priv_s *priv) { struct timespec abstime; irqstate_t flags; @@ -731,7 +731,7 @@ static inline int } #else static inline int - pic32mz_i2c_sem_waitdone(FAR struct pic32mz_i2c_priv_s *priv) + pic32mz_i2c_sem_waitdone(struct pic32mz_i2c_priv_s *priv) { clock_t timeout; clock_t start; @@ -791,7 +791,7 @@ static inline int ****************************************************************************/ static inline void - pic32mz_i2c_sem_waitidle(FAR struct pic32mz_i2c_priv_s *priv) + pic32mz_i2c_sem_waitidle(struct pic32mz_i2c_priv_s *priv) { uint32_t timeout; uint32_t start; @@ -838,7 +838,7 @@ static inline void * ****************************************************************************/ -static inline void pic32mz_i2c_sem_post(FAR struct pic32mz_i2c_priv_s *priv) +static inline void pic32mz_i2c_sem_post(struct pic32mz_i2c_priv_s *priv) { nxsem_post(&priv->sem_excl); } @@ -851,7 +851,7 @@ static inline void pic32mz_i2c_sem_post(FAR struct pic32mz_i2c_priv_s *priv) * ****************************************************************************/ -static inline void pic32mz_i2c_sem_init(FAR struct pic32mz_i2c_priv_s *priv) +static inline void pic32mz_i2c_sem_init(struct pic32mz_i2c_priv_s *priv) { nxsem_init(&priv->sem_excl, 0, 1); @@ -874,7 +874,7 @@ static inline void pic32mz_i2c_sem_init(FAR struct pic32mz_i2c_priv_s *priv) ****************************************************************************/ static inline void - pic32mz_i2c_sem_destroy(FAR struct pic32mz_i2c_priv_s *priv) + pic32mz_i2c_sem_destroy(struct pic32mz_i2c_priv_s *priv) { nxsem_destroy(&priv->sem_excl); #ifndef CONFIG_I2C_POLLED @@ -1279,7 +1279,7 @@ static int pic32mz_i2c_isr_process(struct pic32mz_i2c_priv_s *priv) ****************************************************************************/ #ifndef CONFIG_I2C_POLLED -static int pic32mz_i2c_isr(int irq, void *context, FAR void *arg) +static int pic32mz_i2c_isr(int irq, void *context, void *arg) { struct pic32mz_i2c_priv_s *priv = (struct pic32mz_i2c_priv_s *)arg; @@ -1297,7 +1297,7 @@ static int pic32mz_i2c_isr(int irq, void *context, FAR void *arg) ****************************************************************************/ static inline int - pic32mz_i2c_setbaudrate(FAR struct pic32mz_i2c_priv_s *priv, + pic32mz_i2c_setbaudrate(struct pic32mz_i2c_priv_s *priv, uint32_t frequency) { uint32_t baudrate; @@ -1347,7 +1347,7 @@ static inline int ****************************************************************************/ static inline void - pic32mz_i2c_send_start(FAR struct pic32mz_i2c_priv_s *priv) + pic32mz_i2c_send_start(struct pic32mz_i2c_priv_s *priv) { pic32mz_i2c_putreg(priv, PIC32MZ_I2C_CONSET_OFFSET, I2C_CON_SEN); @@ -1367,7 +1367,7 @@ static inline void * ****************************************************************************/ -static inline void pic32mz_i2c_send_stop(FAR struct pic32mz_i2c_priv_s *priv) +static inline void pic32mz_i2c_send_stop(struct pic32mz_i2c_priv_s *priv) { pic32mz_i2c_putreg(priv, PIC32MZ_I2C_CONSET_OFFSET, I2C_CON_PEN); @@ -1388,7 +1388,7 @@ static inline void pic32mz_i2c_send_stop(FAR struct pic32mz_i2c_priv_s *priv) ****************************************************************************/ static inline void - pic32mz_i2c_send_repeatedstart(FAR struct pic32mz_i2c_priv_s *priv) + pic32mz_i2c_send_repeatedstart(struct pic32mz_i2c_priv_s *priv) { pic32mz_i2c_putreg(priv, PIC32MZ_I2C_CONSET_OFFSET, I2C_CON_RSEN); @@ -1408,7 +1408,7 @@ static inline void * ****************************************************************************/ -static inline void pic32mz_i2c_send_ack(FAR struct pic32mz_i2c_priv_s *priv, +static inline void pic32mz_i2c_send_ack(struct pic32mz_i2c_priv_s *priv, bool ack) { if (ack) @@ -1486,7 +1486,7 @@ static inline uint32_t ****************************************************************************/ static inline bool - pic32mz_i2c_master_inactive(FAR struct pic32mz_i2c_priv_s *priv) + pic32mz_i2c_master_inactive(struct pic32mz_i2c_priv_s *priv) { uint32_t con; @@ -1504,7 +1504,7 @@ static inline bool ****************************************************************************/ static inline uint32_t - pic32mz_i2c_getstatus(FAR struct pic32mz_i2c_priv_s *priv) + pic32mz_i2c_getstatus(struct pic32mz_i2c_priv_s *priv) { return pic32mz_i2c_getreg(priv, PIC32MZ_I2C_STAT_OFFSET); } @@ -1517,7 +1517,7 @@ static inline uint32_t * ****************************************************************************/ -static int pic32mz_i2c_init(FAR struct pic32mz_i2c_priv_s *priv) +static int pic32mz_i2c_init(struct pic32mz_i2c_priv_s *priv) { /* Force a frequency update */ @@ -1550,7 +1550,7 @@ static int pic32mz_i2c_init(FAR struct pic32mz_i2c_priv_s *priv) * ****************************************************************************/ -static int pic32mz_i2c_deinit(FAR struct pic32mz_i2c_priv_s *priv) +static int pic32mz_i2c_deinit(struct pic32mz_i2c_priv_s *priv) { /* Disable I2C */ @@ -1580,10 +1580,10 @@ static int pic32mz_i2c_deinit(FAR struct pic32mz_i2c_priv_s *priv) * ****************************************************************************/ -static int pic32mz_i2c_transfer(FAR struct i2c_master_s *dev, - FAR struct i2c_msg_s *msgs, int count) +static int pic32mz_i2c_transfer(struct i2c_master_s *dev, + struct i2c_msg_s *msgs, int count) { - FAR struct pic32mz_i2c_priv_s *priv = (struct pic32mz_i2c_priv_s *)dev; + struct pic32mz_i2c_priv_s *priv = (struct pic32mz_i2c_priv_s *)dev; uint32_t status = 0; int ret; @@ -1702,9 +1702,9 @@ static int pic32mz_i2c_transfer(FAR struct i2c_master_s *dev, ****************************************************************************/ #ifdef CONFIG_I2C_RESET -static int pic32mz_i2c_reset(FAR struct i2c_master_s *dev) +static int pic32mz_i2c_reset(struct i2c_master_s *dev) { - FAR struct pic32mz_i2c_priv_s *priv = (struct pic32mz_i2c_priv_s *)dev; + struct pic32mz_i2c_priv_s *priv = (struct pic32mz_i2c_priv_s *)dev; unsigned int clock_count; unsigned int stretch_count; uint32_t frequency; @@ -1829,7 +1829,7 @@ static int pic32mz_i2c_reset(FAR struct i2c_master_s *dev) * ****************************************************************************/ -FAR struct i2c_master_s *pic32mz_i2cbus_initialize(int port) +struct i2c_master_s *pic32mz_i2cbus_initialize(int port) { struct pic32mz_i2c_priv_s * priv = NULL; irqstate_t flags; @@ -1895,9 +1895,9 @@ FAR struct i2c_master_s *pic32mz_i2cbus_initialize(int port) * ****************************************************************************/ -int pic32mz_i2cbus_uninitialize(FAR struct i2c_master_s *dev) +int pic32mz_i2cbus_uninitialize(struct i2c_master_s *dev) { - FAR struct pic32mz_i2c_priv_s *priv = (struct pic32mz_i2c_priv_s *)dev; + struct pic32mz_i2c_priv_s *priv = (struct pic32mz_i2c_priv_s *)dev; irqstate_t flags; DEBUGASSERT(dev); diff --git a/arch/mips/src/pic32mz/pic32mz_i2c.h b/arch/mips/src/pic32mz/pic32mz_i2c.h index 575fb7a63b5d3..89f125ee8863b 100644 --- a/arch/mips/src/pic32mz/pic32mz_i2c.h +++ b/arch/mips/src/pic32mz/pic32mz_i2c.h @@ -53,7 +53,7 @@ * ****************************************************************************/ -FAR struct i2c_master_s *pic32mz_i2cbus_initialize(int port); +struct i2c_master_s *pic32mz_i2cbus_initialize(int port); /**************************************************************************** * Name: pic32mz_i2cbus_uninitialize @@ -70,6 +70,6 @@ FAR struct i2c_master_s *pic32mz_i2cbus_initialize(int port); * ****************************************************************************/ -int pic32mz_i2cbus_uninitialize(FAR struct i2c_master_s *dev); +int pic32mz_i2cbus_uninitialize(struct i2c_master_s *dev); #endif /* __ARCH_MIPS_SRC_PIC32MZ_PIC32MZ_I2C_H */ diff --git a/arch/mips/src/pic32mz/pic32mz_oneshot.h b/arch/mips/src/pic32mz/pic32mz_oneshot.h index 22300a37fef05..71131fec84016 100644 --- a/arch/mips/src/pic32mz/pic32mz_oneshot.h +++ b/arch/mips/src/pic32mz/pic32mz_oneshot.h @@ -66,17 +66,17 @@ typedef void (*oneshot_handler_t)(void *arg); struct pic32mz_oneshot_s { - uint8_t chan; /* The timer/counter in use */ + uint8_t chan; /* The timer/counter in use */ #if CONFIG_PIC32MZ_ONESHOT_MAXTIMERS > 1 - uint8_t cbndx; /* Timer callback handler index */ + uint8_t cbndx; /* Timer callback handler index */ #endif - volatile bool running; /* True: the timer is running */ - FAR struct pic32mz_timer_dev_s *timer; /* PIC32MZ timer driver */ - volatile oneshot_handler_t handler; /* Oneshot expiration callback */ - volatile void *arg; /* Callback's argument */ - uint32_t freq; /* Timer's frequency */ - uint32_t period; /* Timer's period */ - uint8_t width; /* Timer's width */ + volatile bool running; /* True: the timer is running */ + struct pic32mz_timer_dev_s *timer; /* PIC32MZ timer driver */ + volatile oneshot_handler_t handler; /* Oneshot expiration callback */ + volatile void *arg; /* Callback's argument */ + uint32_t freq; /* Timer's frequency */ + uint32_t period; /* Timer's period */ + uint8_t width; /* Timer's width */ }; /**************************************************************************** diff --git a/arch/mips/src/pic32mz/pic32mz_oneshot_lowerhalf.c b/arch/mips/src/pic32mz/pic32mz_oneshot_lowerhalf.c index e40d2a00ff1d4..b82068285d375 100644 --- a/arch/mips/src/pic32mz/pic32mz_oneshot_lowerhalf.c +++ b/arch/mips/src/pic32mz/pic32mz_oneshot_lowerhalf.c @@ -55,7 +55,7 @@ struct pic32mz_oneshot_lowerhalf_s struct pic32mz_oneshot_s oneshot; /* PIC32MZ-specific oneshot state */ oneshot_callback_t callback; /* Handler that receives callback */ - FAR void *arg; /* Argument passed to the handler */ + void *arg; /* Argument passed to the handler */ }; /**************************************************************************** @@ -64,13 +64,13 @@ struct pic32mz_oneshot_lowerhalf_s static void pic32mz_oneshot_handler(void *arg); -static int pic32mz_max_delay(FAR struct oneshot_lowerhalf_s *lower, - FAR struct timespec *ts); -static int pic32mz_start(FAR struct oneshot_lowerhalf_s *lower, - oneshot_callback_t callback, FAR void *arg, - FAR const struct timespec *ts); -static int pic32mz_cancel(FAR struct oneshot_lowerhalf_s *lower, - FAR struct timespec *ts); +static int pic32mz_max_delay(struct oneshot_lowerhalf_s *lower, + struct timespec *ts); +static int pic32mz_start(struct oneshot_lowerhalf_s *lower, + oneshot_callback_t callback, void *arg, + const struct timespec *ts); +static int pic32mz_cancel(struct oneshot_lowerhalf_s *lower, + struct timespec *ts); /**************************************************************************** * Private Data @@ -106,10 +106,10 @@ static const struct oneshot_operations_s g_oneshot_ops = static void pic32mz_oneshot_handler(void *arg) { - FAR struct pic32mz_oneshot_lowerhalf_s *priv = - (FAR struct pic32mz_oneshot_lowerhalf_s *)arg; + struct pic32mz_oneshot_lowerhalf_s *priv = + (struct pic32mz_oneshot_lowerhalf_s *)arg; oneshot_callback_t callback; - FAR void *cbarg; + void *cbarg; DEBUGASSERT(priv != NULL); @@ -152,11 +152,11 @@ static void pic32mz_oneshot_handler(void *arg) * ****************************************************************************/ -static int pic32mz_max_delay(FAR struct oneshot_lowerhalf_s *lower, - FAR struct timespec *ts) +static int pic32mz_max_delay(struct oneshot_lowerhalf_s *lower, + struct timespec *ts) { - FAR struct pic32mz_oneshot_lowerhalf_s *priv = - (FAR struct pic32mz_oneshot_lowerhalf_s *)lower; + struct pic32mz_oneshot_lowerhalf_s *priv = + (struct pic32mz_oneshot_lowerhalf_s *)lower; uint64_t usecs; int ret; @@ -197,12 +197,12 @@ static int pic32mz_max_delay(FAR struct oneshot_lowerhalf_s *lower, * ****************************************************************************/ -static int pic32mz_start(FAR struct oneshot_lowerhalf_s *lower, - oneshot_callback_t callback, FAR void *arg, - FAR const struct timespec *ts) +static int pic32mz_start(struct oneshot_lowerhalf_s *lower, + oneshot_callback_t callback, void *arg, + const struct timespec *ts) { - FAR struct pic32mz_oneshot_lowerhalf_s *priv = - (FAR struct pic32mz_oneshot_lowerhalf_s *)lower; + struct pic32mz_oneshot_lowerhalf_s *priv = + (struct pic32mz_oneshot_lowerhalf_s *)lower; irqstate_t flags; int ret; @@ -250,11 +250,11 @@ static int pic32mz_start(FAR struct oneshot_lowerhalf_s *lower, * ****************************************************************************/ -static int pic32mz_cancel(FAR struct oneshot_lowerhalf_s *lower, - FAR struct timespec *ts) +static int pic32mz_cancel(struct oneshot_lowerhalf_s *lower, + struct timespec *ts) { - FAR struct pic32mz_oneshot_lowerhalf_s *priv = - (FAR struct pic32mz_oneshot_lowerhalf_s *)lower; + struct pic32mz_oneshot_lowerhalf_s *priv = + (struct pic32mz_oneshot_lowerhalf_s *)lower; irqstate_t flags; int ret; @@ -299,15 +299,15 @@ static int pic32mz_cancel(FAR struct oneshot_lowerhalf_s *lower, * ****************************************************************************/ -FAR struct oneshot_lowerhalf_s *oneshot_initialize(int chan, - uint16_t resolution) +struct oneshot_lowerhalf_s *oneshot_initialize(int chan, + uint16_t resolution) { - FAR struct pic32mz_oneshot_lowerhalf_s *priv; + struct pic32mz_oneshot_lowerhalf_s *priv; int ret; /* Allocate an instance of the lower half driver */ - priv = (FAR struct pic32mz_oneshot_lowerhalf_s *) + priv = (struct pic32mz_oneshot_lowerhalf_s *) kmm_zalloc(sizeof(struct pic32mz_oneshot_lowerhalf_s)); if (priv == NULL) diff --git a/arch/mips/src/pic32mz/pic32mz_serial.c b/arch/mips/src/pic32mz/pic32mz_serial.c index 1a163baaad9d8..def3106ceeb28 100644 --- a/arch/mips/src/pic32mz/pic32mz_serial.c +++ b/arch/mips/src/pic32mz/pic32mz_serial.c @@ -260,7 +260,7 @@ static int up_setup(struct uart_dev_s *dev); static void up_shutdown(struct uart_dev_s *dev); static int up_attach(struct uart_dev_s *dev); static void up_detach(struct uart_dev_s *dev); -static int up_interrupt(int irq, void *context, FAR void *arg); +static int up_interrupt(int irq, void *context, void *arg); static int up_ioctl(struct file *filep, int cmd, unsigned long arg); static int up_receive(struct uart_dev_s *dev, unsigned int *status); static void up_rxint(struct uart_dev_s *dev, bool enable); @@ -692,7 +692,7 @@ static void up_detach(struct uart_dev_s *dev) * ****************************************************************************/ -static int up_interrupt(int irq, void *context, FAR void *arg) +static int up_interrupt(int irq, void *context, void *arg) { struct uart_dev_s *dev = (struct uart_dev_s *)arg; struct up_dev_s *priv; diff --git a/arch/mips/src/pic32mz/pic32mz_spi.c b/arch/mips/src/pic32mz/pic32mz_spi.c index 7340b47399e86..e2e43f45b5f39 100644 --- a/arch/mips/src/pic32mz/pic32mz_spi.c +++ b/arch/mips/src/pic32mz/pic32mz_spi.c @@ -126,7 +126,7 @@ struct pic32mz_config_s struct pic32mz_dev_s { struct spi_dev_s spidev; /* Externally visible part of the SPI interface */ - FAR const struct pic32mz_config_s *config; + const struct pic32mz_config_s *config; sem_t exclsem; /* Held while chip is selected for mutual exclusion */ uint32_t frequency; /* Requested clock frequency */ uint32_t actual; /* Actual clock frequency */ @@ -161,27 +161,27 @@ struct pic32mz_dev_s /* Low-level register access */ #ifdef CONFIG_PIC32MZ_SPI_REGDEBUG -static bool spi_checkreg(FAR struct pic32mz_dev_s *priv, +static bool spi_checkreg(struct pic32mz_dev_s *priv, uintptr_t regaddr, uint32_t regvaql, bool wr); -static uint32_t spi_getreg(FAR struct pic32mz_dev_s *priv, +static uint32_t spi_getreg(struct pic32mz_dev_s *priv, unsigned int offset); -static void spi_putaddr(FAR struct pic32mz_dev_s *priv, +static void spi_putaddr(struct pic32mz_dev_s *priv, uintptr_t regaddr, uint32_t value); #else -static inline uint32_t spi_getreg(FAR struct pic32mz_dev_s *priv, +static inline uint32_t spi_getreg(struct pic32mz_dev_s *priv, unsigned int offset); -static inline void spi_putaddr(FAR struct pic32mz_dev_s *priv, +static inline void spi_putaddr(struct pic32mz_dev_s *priv, uintptr_t regaddr, uint32_t value); #endif -static inline void spi_putreg(FAR struct pic32mz_dev_s *priv, +static inline void spi_putreg(struct pic32mz_dev_s *priv, unsigned int offset, uint32_t value); -static inline void spi_flush(FAR struct pic32mz_dev_s *priv); +static inline void spi_flush(struct pic32mz_dev_s *priv); -static void spi_exchange16(FAR struct pic32mz_dev_s *priv, - FAR const uint16_t *txbuffer, FAR uint16_t *rxbuffer, +static void spi_exchange16(struct pic32mz_dev_s *priv, + const uint16_t *txbuffer, uint16_t *rxbuffer, size_t nwords); -static void spi_exchange8(FAR struct pic32mz_dev_s *priv, - FAR const uint8_t *txbuffer, FAR uint8_t *rxbuffer, +static void spi_exchange8(struct pic32mz_dev_s *priv, + const uint8_t *txbuffer, uint8_t *rxbuffer, size_t nbytes); /* DMA Support */ @@ -192,8 +192,8 @@ static void spi_exchange8(FAR struct pic32mz_dev_s *priv, &(s)->rxdmaregs[i]) # define spi_txdma_sample(s,i) pic32mz_dma_sample((s)->txdma,\ &(s)->txdmaregs[i]) -static void spi_dma_sampleinit(FAR struct pic32mz_dev_s *priv); -static void spi_dma_sampledone(FAR struct pic32mz_dev_s *priv); +static void spi_dma_sampleinit(struct pic32mz_dev_s *priv); +static void spi_dma_sampledone(struct pic32mz_dev_s *priv); # else # define spi_rxdma_sample(s,i) # define spi_txdma_sample(s,i) @@ -207,26 +207,26 @@ static void spi_dmatimeout(wdparm_t arg); /* SPI methods */ -static int spi_lock(FAR struct spi_dev_s *dev, bool lock); -static uint32_t spi_setfrequency(FAR struct spi_dev_s *dev, +static int spi_lock(struct spi_dev_s *dev, bool lock); +static uint32_t spi_setfrequency(struct spi_dev_s *dev, uint32_t frequency); -static void spi_setmode(FAR struct spi_dev_s *dev, enum spi_mode_e mode); -static void spi_setbits(FAR struct spi_dev_s *dev, int nbits); -static uint32_t spi_send(FAR struct spi_dev_s *dev, uint32_t wd); -static void spi_exchange(FAR struct spi_dev_s *dev, - FAR const void *txbuffer, FAR void *rxbuffer, +static void spi_setmode(struct spi_dev_s *dev, enum spi_mode_e mode); +static void spi_setbits(struct spi_dev_s *dev, int nbits); +static uint32_t spi_send(struct spi_dev_s *dev, uint32_t wd); +static void spi_exchange(struct spi_dev_s *dev, + const void *txbuffer, void *rxbuffer, size_t nwords); #ifdef CONFIG_PIC32MZ_SPI_DMA -static void spi_exchange_nodma(FAR struct spi_dev_s *dev, - FAR const void *txbuffer, - FAR void *rxbuffer, +static void spi_exchange_nodma(struct spi_dev_s *dev, + const void *txbuffer, + void *rxbuffer, size_t nwords); #endif #ifndef CONFIG_SPI_EXCHANGE -static void spi_sndblock(FAR struct spi_dev_s *dev, - FAR const void *buffer, size_t nwords); -static void spi_recvblock(FAR struct spi_dev_s *dev, FAR void *buffer, +static void spi_sndblock(struct spi_dev_s *dev, + const void *buffer, size_t nwords); +static void spi_recvblock(struct spi_dev_s *dev, void *buffer, size_t nwords); #endif @@ -612,7 +612,7 @@ static bool spi_checkreg(struct pic32mz_dev_s *priv, uintptr_t regaddr, ****************************************************************************/ #ifdef CONFIG_PIC32MZ_SPI_REGDEBUG -static uint32_t spi_getreg(FAR struct pic32mz_dev_s *priv, +static uint32_t spi_getreg(struct pic32mz_dev_s *priv, unsigned int offset) { uintptr_t regaddr; @@ -638,7 +638,7 @@ static uint32_t spi_getreg(FAR struct pic32mz_dev_s *priv, return regval; } #else -static inline uint32_t spi_getreg(FAR struct pic32mz_dev_s *priv, +static inline uint32_t spi_getreg(struct pic32mz_dev_s *priv, unsigned int offset) { return getreg32(priv->config->base + offset); @@ -662,7 +662,7 @@ static inline uint32_t spi_getreg(FAR struct pic32mz_dev_s *priv, ****************************************************************************/ #ifdef CONFIG_PIC32MZ_SPI_REGDEBUG -static void spi_putaddr(FAR struct pic32mz_dev_s *priv, uintptr_t regaddr, +static void spi_putaddr(struct pic32mz_dev_s *priv, uintptr_t regaddr, uint32_t regval) { /* Should we print something? */ @@ -680,7 +680,7 @@ static void spi_putaddr(FAR struct pic32mz_dev_s *priv, uintptr_t regaddr, putreg32(regval, regaddr); } #else -static inline void spi_putaddr(FAR struct pic32mz_dev_s *priv, +static inline void spi_putaddr(struct pic32mz_dev_s *priv, uintptr_t regaddr, uint32_t regval) { /* Write the value to the register */ @@ -705,7 +705,7 @@ static inline void spi_putaddr(FAR struct pic32mz_dev_s *priv, * ****************************************************************************/ -static inline void spi_putreg(FAR struct pic32mz_dev_s *priv, +static inline void spi_putreg(struct pic32mz_dev_s *priv, unsigned int offset, uint32_t regval) { spi_putaddr(priv, priv->config->base + offset, regval); @@ -725,7 +725,7 @@ static inline void spi_putreg(FAR struct pic32mz_dev_s *priv, * ****************************************************************************/ -static inline void spi_flush(FAR struct pic32mz_dev_s *priv) +static inline void spi_flush(struct pic32mz_dev_s *priv) { /* Make sure that no TX activity is in progress... waiting if necessary */ @@ -756,7 +756,7 @@ static inline void spi_flush(FAR struct pic32mz_dev_s *priv) ****************************************************************************/ #ifdef CONFIG_PIC32MZ_SPI_DMADEBUG -static void spi_dma_sampleinit(FAR struct pic32mz_dev_s *priv) +static void spi_dma_sampleinit(struct pic32mz_dev_s *priv) { /* Put contents of register samples into a known state */ @@ -787,7 +787,7 @@ static void spi_dma_sampleinit(FAR struct pic32mz_dev_s *priv) ****************************************************************************/ #ifdef CONFIG_PIC32MZ_SPI_DMADEBUG -static void spi_dma_sampledone(FAR struct pic32mz_dev_s *priv) +static void spi_dma_sampledone(struct pic32mz_dev_s *priv) { /* Sample the final registers */ @@ -1016,8 +1016,8 @@ static void spi_dmatimeout(wdparm_t arg) * ****************************************************************************/ -static void spi_exchange8(FAR struct pic32mz_dev_s *priv, - FAR const uint8_t *txbuffer, FAR uint8_t *rxbuffer, +static void spi_exchange8(struct pic32mz_dev_s *priv, + const uint8_t *txbuffer, uint8_t *rxbuffer, size_t nbytes) { uint32_t regval; @@ -1091,9 +1091,9 @@ static void spi_exchange8(FAR struct pic32mz_dev_s *priv, * ****************************************************************************/ -static void spi_exchange16(FAR struct pic32mz_dev_s *priv, - FAR const uint16_t *txbuffer, - FAR uint16_t *rxbuffer, size_t nwords) +static void spi_exchange16(struct pic32mz_dev_s *priv, + const uint16_t *txbuffer, + uint16_t *rxbuffer, size_t nwords) { uint32_t regval; uint16_t data; @@ -1169,9 +1169,9 @@ static void spi_exchange16(FAR struct pic32mz_dev_s *priv, * ****************************************************************************/ -static int spi_lock(FAR struct spi_dev_s *dev, bool lock) +static int spi_lock(struct spi_dev_s *dev, bool lock) { - FAR struct pic32mz_dev_s *priv = (FAR struct pic32mz_dev_s *)dev; + struct pic32mz_dev_s *priv = (struct pic32mz_dev_s *)dev; int ret; if (lock) @@ -1201,10 +1201,10 @@ static int spi_lock(FAR struct spi_dev_s *dev, bool lock) * ****************************************************************************/ -static uint32_t spi_setfrequency(FAR struct spi_dev_s *dev, +static uint32_t spi_setfrequency(struct spi_dev_s *dev, uint32_t frequency) { - FAR struct pic32mz_dev_s *priv = (FAR struct pic32mz_dev_s *)dev; + struct pic32mz_dev_s *priv = (struct pic32mz_dev_s *)dev; uint32_t divisor; uint32_t actual; uint32_t regval; @@ -1273,9 +1273,9 @@ static uint32_t spi_setfrequency(FAR struct spi_dev_s *dev, * ****************************************************************************/ -static void spi_setmode(FAR struct spi_dev_s *dev, enum spi_mode_e mode) +static void spi_setmode(struct spi_dev_s *dev, enum spi_mode_e mode) { - FAR struct pic32mz_dev_s *priv = (FAR struct pic32mz_dev_s *)dev; + struct pic32mz_dev_s *priv = (struct pic32mz_dev_s *)dev; /* Has the mode changed? */ @@ -1359,9 +1359,9 @@ static void spi_setmode(FAR struct spi_dev_s *dev, enum spi_mode_e mode) * ****************************************************************************/ -static void spi_setbits(FAR struct spi_dev_s *dev, int nbits) +static void spi_setbits(struct spi_dev_s *dev, int nbits) { - FAR struct pic32mz_dev_s *priv = (FAR struct pic32mz_dev_s *)dev; + struct pic32mz_dev_s *priv = (struct pic32mz_dev_s *)dev; uint32_t setting; uint32_t regval; @@ -1419,9 +1419,9 @@ static void spi_setbits(FAR struct spi_dev_s *dev, int nbits) * ****************************************************************************/ -static uint32_t spi_send(FAR struct spi_dev_s *dev, uint32_t wd) +static uint32_t spi_send(struct spi_dev_s *dev, uint32_t wd) { - FAR struct pic32mz_dev_s *priv = (FAR struct pic32mz_dev_s *)dev; + struct pic32mz_dev_s *priv = (struct pic32mz_dev_s *)dev; DEBUGASSERT(priv); @@ -1489,15 +1489,15 @@ static uint32_t spi_send(FAR struct spi_dev_s *dev, uint32_t wd) ****************************************************************************/ #ifdef CONFIG_PIC32MZ_SPI_DMA -static void spi_exchange_nodma(FAR struct spi_dev_s *dev, - FAR const void *txbuffer, - FAR void *rxbuffer, size_t nwords) +static void spi_exchange_nodma(struct spi_dev_s *dev, + const void *txbuffer, + void *rxbuffer, size_t nwords) #else -static void spi_exchange(FAR struct spi_dev_s *dev, FAR const void *txbuffer, - FAR void *rxbuffer, size_t nwords) +static void spi_exchange(struct spi_dev_s *dev, const void *txbuffer, + void *rxbuffer, size_t nwords) #endif { - FAR struct pic32mz_dev_s *priv = (FAR struct pic32mz_dev_s *)dev; + struct pic32mz_dev_s *priv = (struct pic32mz_dev_s *)dev; DEBUGASSERT(priv); @@ -1509,23 +1509,23 @@ static void spi_exchange(FAR struct spi_dev_s *dev, FAR const void *txbuffer, { /* spi_exchange16() can do this. */ - spi_exchange16(priv, (FAR const uint16_t *)txbuffer, - (FAR uint16_t *)rxbuffer, nwords); + spi_exchange16(priv, (const uint16_t *)txbuffer, + (uint16_t *)rxbuffer, nwords); } else { /* spi_exchange8() can do this. */ - spi_exchange8(priv, (FAR const uint8_t *)txbuffer, - (FAR uint8_t *)rxbuffer, nwords); + spi_exchange8(priv, (const uint8_t *)txbuffer, + (uint8_t *)rxbuffer, nwords); } } #ifdef CONFIG_PIC32MZ_SPI_DMA -static void spi_exchange(FAR struct spi_dev_s *dev, FAR const void *txbuffer, - FAR void *rxbuffer, size_t nwords) +static void spi_exchange(struct spi_dev_s *dev, const void *txbuffer, + void *rxbuffer, size_t nwords) { - FAR struct pic32mz_dev_s *priv = (FAR struct pic32mz_dev_s *)dev; + struct pic32mz_dev_s *priv = (struct pic32mz_dev_s *)dev; struct pic32mz_dma_chcfg_s rxcfg; struct pic32mz_dma_chcfg_s txcfg; struct pic32mz_dma_xfrcfg_s rxxfr; @@ -1850,7 +1850,7 @@ static void spi_exchange(FAR struct spi_dev_s *dev, FAR const void *txbuffer, ****************************************************************************/ #ifndef CONFIG_SPI_EXCHANGE -static void spi_sndblock(FAR struct spi_dev_s *dev, FAR const void *buffer, +static void spi_sndblock(struct spi_dev_s *dev, const void *buffer, size_t nwords) { /* spi_exchange() can do this. */ @@ -1881,7 +1881,7 @@ static void spi_sndblock(FAR struct spi_dev_s *dev, FAR const void *buffer, ****************************************************************************/ #ifndef CONFIG_SPI_EXCHANGE -static void spi_recvblock(FAR struct spi_dev_s *dev, FAR void *buffer, +static void spi_recvblock(struct spi_dev_s *dev, void *buffer, size_t nwords) { /* spi_exchange() can do this. */ @@ -1908,9 +1908,9 @@ static void spi_recvblock(FAR struct spi_dev_s *dev, FAR void *buffer, * ****************************************************************************/ -FAR struct spi_dev_s *pic32mz_spibus_initialize(int port) +struct spi_dev_s *pic32mz_spibus_initialize(int port) { - FAR struct pic32mz_dev_s *priv; + struct pic32mz_dev_s *priv; uintptr_t regaddr; irqstate_t flags; uint32_t regval; @@ -2056,7 +2056,7 @@ FAR struct spi_dev_s *pic32mz_spibus_initialize(int port) /* Select a default frequency of approx. 400KHz */ - spi_setfrequency((FAR struct spi_dev_s *)priv, 400000); + spi_setfrequency((struct spi_dev_s *)priv, 400000); /* Clear the SPIROV overflow bit (SPIxSTAT:6). */ diff --git a/arch/mips/src/pic32mz/pic32mz_spi.h b/arch/mips/src/pic32mz/pic32mz_spi.h index 5ad3ae15bd24f..e656eb2529954 100644 --- a/arch/mips/src/pic32mz/pic32mz_spi.h +++ b/arch/mips/src/pic32mz/pic32mz_spi.h @@ -71,7 +71,7 @@ struct spi_dev_s; /* Forward reference */ * ****************************************************************************/ -FAR struct spi_dev_s *pic32mz_spibus_initialize(int port); +struct spi_dev_s *pic32mz_spibus_initialize(int port); /**************************************************************************** * Name: pic32mz_spiNselect, pic32mz_spiNstatus, and pic32mz_spiNcmddata @@ -103,56 +103,56 @@ FAR struct spi_dev_s *pic32mz_spibus_initialize(int port); ****************************************************************************/ #ifdef CONFIG_PIC32MZ_SPI1 -void pic32mz_spi1select(FAR struct spi_dev_s *dev, uint32_t devid, +void pic32mz_spi1select(struct spi_dev_s *dev, uint32_t devid, bool selected); -uint8_t pic32mz_spi1status(FAR struct spi_dev_s *dev, uint32_t devid); +uint8_t pic32mz_spi1status(struct spi_dev_s *dev, uint32_t devid); #ifdef CONFIG_SPI_CMDDATA -int pic32mz_spi1cmddata(FAR struct spi_dev_s *dev, uint32_t devid, bool cmd); +int pic32mz_spi1cmddata(struct spi_dev_s *dev, uint32_t devid, bool cmd); #endif #endif #ifdef CONFIG_PIC32MZ_SPI2 -void pic32mz_spi2select(FAR struct spi_dev_s *dev, uint32_t devid, +void pic32mz_spi2select(struct spi_dev_s *dev, uint32_t devid, bool selected); -uint8_t pic32mz_spi2status(FAR struct spi_dev_s *dev, uint32_t devid); +uint8_t pic32mz_spi2status(struct spi_dev_s *dev, uint32_t devid); #ifdef CONFIG_SPI_CMDDATA -int pic32mz_spi2cmddata(FAR struct spi_dev_s *dev, uint32_t devid, bool cmd); +int pic32mz_spi2cmddata(struct spi_dev_s *dev, uint32_t devid, bool cmd); #endif #endif #ifdef CONFIG_PIC32MZ_SPI3 -void pic32mz_spi3select(FAR struct spi_dev_s *dev, uint32_t devid, +void pic32mz_spi3select(struct spi_dev_s *dev, uint32_t devid, bool selected); -uint8_t pic32mz_spi3status(FAR struct spi_dev_s *dev, uint32_t devid); +uint8_t pic32mz_spi3status(struct spi_dev_s *dev, uint32_t devid); #ifdef CONFIG_SPI_CMDDATA -int pic32mz_spi3cmddata(FAR struct spi_dev_s *dev, uint32_t devid, bool cmd); +int pic32mz_spi3cmddata(struct spi_dev_s *dev, uint32_t devid, bool cmd); #endif #endif #ifdef CONFIG_PIC32MZ_SPI4 -void pic32mz_spi4select(FAR struct spi_dev_s *dev, uint32_t devid, +void pic32mz_spi4select(struct spi_dev_s *dev, uint32_t devid, bool selected); -uint8_t pic32mz_spi4status(FAR struct spi_dev_s *dev, uint32_t devid); +uint8_t pic32mz_spi4status(struct spi_dev_s *dev, uint32_t devid); #ifdef CONFIG_SPI_CMDDATA -int pic32mz_spi4cmddata(FAR struct spi_dev_s *dev, uint32_t devid, bool cmd); +int pic32mz_spi4cmddata(struct spi_dev_s *dev, uint32_t devid, bool cmd); #endif #endif #ifdef CONFIG_PIC32MZ_SPI5 -void pic32mz_spi5select(FAR struct spi_dev_s *dev, uint32_t devid, +void pic32mz_spi5select(struct spi_dev_s *dev, uint32_t devid, bool selected); -uint8_t pic32mz_spi5status(FAR struct spi_dev_s *dev, uint32_t devid); +uint8_t pic32mz_spi5status(struct spi_dev_s *dev, uint32_t devid); #ifdef CONFIG_SPI_CMDDATA -int pic32mz_spi5cmddata(FAR struct spi_dev_s *dev, uint32_t devid, bool cmd); +int pic32mz_spi5cmddata(struct spi_dev_s *dev, uint32_t devid, bool cmd); #endif #endif #ifdef CONFIG_PIC32MZ_SPI6 -void pic32mz_spi6select(FAR struct spi_dev_s *dev, uint32_t devid, +void pic32mz_spi6select(struct spi_dev_s *dev, uint32_t devid, bool selected); -uint8_t pic32mz_spi6status(FAR struct spi_dev_s *dev, uint32_t devid); +uint8_t pic32mz_spi6status(struct spi_dev_s *dev, uint32_t devid); #ifdef CONFIG_SPI_CMDDATA -int pic32mz_spi6cmddata(FAR struct spi_dev_s *dev, uint32_t devid, bool cmd); +int pic32mz_spi6cmddata(struct spi_dev_s *dev, uint32_t devid, bool cmd); #endif #endif @@ -178,39 +178,39 @@ int pic32mz_spi6cmddata(FAR struct spi_dev_s *dev, uint32_t devid, bool cmd); #ifdef CONFIG_SPI_CALLBACK #ifdef CONFIG_PIC32MZ_SPI1 -int pic32mz_spi1register(FAR struct spi_dev_s *dev, +int pic32mz_spi1register(struct spi_dev_s *dev, spi_mediachange_t callback, - FAR void *arg); + void *arg); #endif #ifdef CONFIG_PIC32MZ_SPI2 -int pic32mz_spi2register(FAR struct spi_dev_s *dev, +int pic32mz_spi2register(struct spi_dev_s *dev, spi_mediachange_t callback, - FAR void *arg); + void *arg); #endif #ifdef CONFIG_PIC32MZ_SPI3 -int pic32mz_spi3register(FAR struct spi_dev_s *dev, +int pic32mz_spi3register(struct spi_dev_s *dev, spi_mediachange_t callback, - FAR void *arg); + void *arg); #endif #ifdef CONFIG_PIC32MZ_SPI4 -int pic32mz_spi4register(FAR struct spi_dev_s *dev, +int pic32mz_spi4register(struct spi_dev_s *dev, spi_mediachange_t callback, - FAR void *arg); + void *arg); #endif #ifdef CONFIG_PIC32MZ_SPI5 -int pic32mz_spi5register(FAR struct spi_dev_s *dev, +int pic32mz_spi5register(struct spi_dev_s *dev, spi_mediachange_t callback, - FAR void *arg); + void *arg); #endif #ifdef CONFIG_PIC32MZ_SPI6 -int pic32mz_spi6register(FAR struct spi_dev_s *dev, +int pic32mz_spi6register(struct spi_dev_s *dev, spi_mediachange_t callback, - FAR void *arg); + void *arg); #endif #endif /* CONFIG_SPI_CALLBACK */ diff --git a/arch/mips/src/pic32mz/pic32mz_timer.c b/arch/mips/src/pic32mz/pic32mz_timer.c index 3342d5d2109a4..cd703f0c97312 100644 --- a/arch/mips/src/pic32mz/pic32mz_timer.c +++ b/arch/mips/src/pic32mz/pic32mz_timer.c @@ -126,46 +126,46 @@ struct pic32mz_timer_priv_s /* Helpers */ -static inline uint32_t pic32mz_getreg(FAR struct pic32mz_timer_dev_s *dev, +static inline uint32_t pic32mz_getreg(struct pic32mz_timer_dev_s *dev, uint16_t offset); -static inline void pic32mz_putreg(FAR struct pic32mz_timer_dev_s *dev, +static inline void pic32mz_putreg(struct pic32mz_timer_dev_s *dev, uint16_t offset, uint32_t value); -static inline bool pic32mz_timer_mode32(FAR struct pic32mz_timer_dev_s *dev); +static inline bool pic32mz_timer_mode32(struct pic32mz_timer_dev_s *dev); static inline uint32_t pic32mz_timer_oddoffset(uint32_t evenoffset); static inline uint32_t - pic32mz_timer_nextirq(FAR struct pic32mz_timer_dev_s *dev); + pic32mz_timer_nextirq(struct pic32mz_timer_dev_s *dev); -static void pic32mz_timer_stopinidle(FAR struct pic32mz_timer_dev_s *dev, +static void pic32mz_timer_stopinidle(struct pic32mz_timer_dev_s *dev, bool stop); -static void pic32mz_timer_enablegate(FAR struct pic32mz_timer_dev_s *dev, +static void pic32mz_timer_enablegate(struct pic32mz_timer_dev_s *dev, bool enable); -static void pic32mz_timer_setprescale(FAR struct pic32mz_timer_dev_s *dev, +static void pic32mz_timer_setprescale(struct pic32mz_timer_dev_s *dev, uint8_t prescale); -static void pic32mz_timer_setmode32(FAR struct pic32mz_timer_dev_s *dev, +static void pic32mz_timer_setmode32(struct pic32mz_timer_dev_s *dev, bool enable); -static void pic32mz_timer_extclocksource(FAR struct pic32mz_timer_dev_s *dev, +static void pic32mz_timer_extclocksource(struct pic32mz_timer_dev_s *dev, bool enable); -static void pic32mz_timer_inithardware(FAR struct pic32mz_timer_dev_s *dev); +static void pic32mz_timer_inithardware(struct pic32mz_timer_dev_s *dev); /* Timer's methods */ -static void pic32mz_timer_start(FAR struct pic32mz_timer_dev_s *dev); -static void pic32mz_timer_stop(FAR struct pic32mz_timer_dev_s *dev); -static void pic32mz_timer_setperiod(FAR struct pic32mz_timer_dev_s *dev, +static void pic32mz_timer_start(struct pic32mz_timer_dev_s *dev); +static void pic32mz_timer_stop(struct pic32mz_timer_dev_s *dev); +static void pic32mz_timer_setperiod(struct pic32mz_timer_dev_s *dev, uint32_t period); static -uint32_t pic32mz_timer_getcounter(FAR struct pic32mz_timer_dev_s *dev); -static void pic32mz_timer_setcounter(FAR struct pic32mz_timer_dev_s *dev, +uint32_t pic32mz_timer_getcounter(struct pic32mz_timer_dev_s *dev); +static void pic32mz_timer_setcounter(struct pic32mz_timer_dev_s *dev, uint32_t count); -static uint32_t pic32mz_timer_getfreq(FAR struct pic32mz_timer_dev_s *dev); -static bool pic32mz_timer_setfreq(FAR struct pic32mz_timer_dev_s *dev, +static uint32_t pic32mz_timer_getfreq(struct pic32mz_timer_dev_s *dev); +static bool pic32mz_timer_setfreq(struct pic32mz_timer_dev_s *dev, uint32_t freq); -static uint8_t pic32mz_timer_getwidth(FAR struct pic32mz_timer_dev_s *dev); +static uint8_t pic32mz_timer_getwidth(struct pic32mz_timer_dev_s *dev); -static int pic32mz_timer_setisr(FAR struct pic32mz_timer_dev_s *dev, +static int pic32mz_timer_setisr(struct pic32mz_timer_dev_s *dev, xcpt_t handler, void *arg); -static void pic32mz_timer_ackint(FAR struct pic32mz_timer_dev_s *dev); -static bool pic32mz_timer_checkint(FAR struct pic32mz_timer_dev_s *dev); +static void pic32mz_timer_ackint(struct pic32mz_timer_dev_s *dev); +static bool pic32mz_timer_checkint(struct pic32mz_timer_dev_s *dev); /**************************************************************************** * Private Data @@ -519,11 +519,11 @@ static struct pic32mz_timer_priv_s pic32mz_t9_priv = * ****************************************************************************/ -static inline uint32_t pic32mz_getreg(FAR struct pic32mz_timer_dev_s *dev, +static inline uint32_t pic32mz_getreg(struct pic32mz_timer_dev_s *dev, uint16_t offset) { - FAR struct pic32mz_timer_priv_s *priv = - (FAR struct pic32mz_timer_priv_s *)dev; + struct pic32mz_timer_priv_s *priv = + (struct pic32mz_timer_priv_s *)dev; return getreg32(priv->config->base + offset); } @@ -536,11 +536,11 @@ static inline uint32_t pic32mz_getreg(FAR struct pic32mz_timer_dev_s *dev, * ****************************************************************************/ -static inline void pic32mz_putreg(FAR struct pic32mz_timer_dev_s *dev, +static inline void pic32mz_putreg(struct pic32mz_timer_dev_s *dev, uint16_t offset, uint32_t value) { - FAR struct pic32mz_timer_priv_s *priv = - (FAR struct pic32mz_timer_priv_s *)dev; + struct pic32mz_timer_priv_s *priv = + (struct pic32mz_timer_priv_s *)dev; putreg32(value, priv->config->base + offset); } @@ -553,9 +553,9 @@ static inline void pic32mz_putreg(FAR struct pic32mz_timer_dev_s *dev, * ****************************************************************************/ -static inline bool pic32mz_timer_mode32(FAR struct pic32mz_timer_dev_s *dev) +static inline bool pic32mz_timer_mode32(struct pic32mz_timer_dev_s *dev) { - return ((FAR struct pic32mz_timer_priv_s *)dev)->config->mode32; + return ((struct pic32mz_timer_priv_s *)dev)->config->mode32; } /**************************************************************************** @@ -588,11 +588,11 @@ static inline uint32_t pic32mz_timer_oddoffset(uint32_t evenoffset) ****************************************************************************/ static inline uint32_t - pic32mz_timer_nextirq(FAR struct pic32mz_timer_dev_s *dev) + pic32mz_timer_nextirq(struct pic32mz_timer_dev_s *dev) { uint32_t irq; - irq = ((FAR struct pic32mz_timer_priv_s *)dev)->config->irq; + irq = ((struct pic32mz_timer_priv_s *)dev)->config->irq; /* The irq offsets between odd and even timers * are not always the same. @@ -616,7 +616,7 @@ static inline uint32_t * ****************************************************************************/ -static void pic32mz_timer_start(FAR struct pic32mz_timer_dev_s *dev) +static void pic32mz_timer_start(struct pic32mz_timer_dev_s *dev) { pic32mz_putreg(dev, PIC32MZ_TIMER_CONSET_OFFSET, TIMER_CON_ON); } @@ -629,7 +629,7 @@ static void pic32mz_timer_start(FAR struct pic32mz_timer_dev_s *dev) * ****************************************************************************/ -static void pic32mz_timer_stop(FAR struct pic32mz_timer_dev_s *dev) +static void pic32mz_timer_stop(struct pic32mz_timer_dev_s *dev) { pic32mz_putreg(dev, PIC32MZ_TIMER_CONCLR_OFFSET, TIMER_CON_ON); } @@ -642,7 +642,7 @@ static void pic32mz_timer_stop(FAR struct pic32mz_timer_dev_s *dev) * ****************************************************************************/ -static void pic32mz_timer_stopinidle(FAR struct pic32mz_timer_dev_s *dev, +static void pic32mz_timer_stopinidle(struct pic32mz_timer_dev_s *dev, bool stop) { if (stop) @@ -665,7 +665,7 @@ static void pic32mz_timer_stopinidle(FAR struct pic32mz_timer_dev_s *dev, } } - ((FAR struct pic32mz_timer_priv_s *)dev)->config->stopinidle = stop; + ((struct pic32mz_timer_priv_s *)dev)->config->stopinidle = stop; } /**************************************************************************** @@ -677,11 +677,11 @@ static void pic32mz_timer_stopinidle(FAR struct pic32mz_timer_dev_s *dev, * ****************************************************************************/ -static void pic32mz_timer_enablegate(FAR struct pic32mz_timer_dev_s *dev, +static void pic32mz_timer_enablegate(struct pic32mz_timer_dev_s *dev, bool enable) { - FAR struct pic32mz_timer_priv_s *priv = - (FAR struct pic32mz_timer_priv_s *)dev; + struct pic32mz_timer_priv_s *priv = + (struct pic32mz_timer_priv_s *)dev; if (enable) { @@ -708,13 +708,13 @@ static void pic32mz_timer_enablegate(FAR struct pic32mz_timer_dev_s *dev, * ****************************************************************************/ -static void pic32mz_timer_setprescale(FAR struct pic32mz_timer_dev_s *dev, +static void pic32mz_timer_setprescale(struct pic32mz_timer_dev_s *dev, uint8_t prescale) { pic32mz_putreg(dev, PIC32MZ_TIMER_CONSET_OFFSET, (prescale << TIMER_CON_TCKPS_SHIFT)); - ((FAR struct pic32mz_timer_priv_s *)dev)->config->prescale = prescale; + ((struct pic32mz_timer_priv_s *)dev)->config->prescale = prescale; } /**************************************************************************** @@ -726,7 +726,7 @@ static void pic32mz_timer_setprescale(FAR struct pic32mz_timer_dev_s *dev, * ****************************************************************************/ -static void pic32mz_timer_setmode32(FAR struct pic32mz_timer_dev_s *dev, +static void pic32mz_timer_setmode32(struct pic32mz_timer_dev_s *dev, bool enable) { /* Only even timers have the TIMER_CON_T32 bit. */ @@ -740,7 +740,7 @@ static void pic32mz_timer_setmode32(FAR struct pic32mz_timer_dev_s *dev, pic32mz_putreg(dev, PIC32MZ_TIMER_CONCLR_OFFSET, TIMER_CON_T32); } - ((FAR struct pic32mz_timer_priv_s *)dev)->config->mode32 = enable; + ((struct pic32mz_timer_priv_s *)dev)->config->mode32 = enable; } /**************************************************************************** @@ -751,11 +751,11 @@ static void pic32mz_timer_setmode32(FAR struct pic32mz_timer_dev_s *dev, * ****************************************************************************/ -static void pic32mz_timer_extclocksource(FAR struct pic32mz_timer_dev_s *dev, +static void pic32mz_timer_extclocksource(struct pic32mz_timer_dev_s *dev, bool enable) { - FAR struct pic32mz_timer_priv_s *priv = - (FAR struct pic32mz_timer_priv_s *)dev; + struct pic32mz_timer_priv_s *priv = + (struct pic32mz_timer_priv_s *)dev; if (enable) { @@ -784,10 +784,10 @@ static void pic32mz_timer_extclocksource(FAR struct pic32mz_timer_dev_s *dev, * ****************************************************************************/ -static void pic32mz_timer_inithardware(FAR struct pic32mz_timer_dev_s *dev) +static void pic32mz_timer_inithardware(struct pic32mz_timer_dev_s *dev) { - FAR struct pic32mz_timer_priv_s *priv = - (FAR struct pic32mz_timer_priv_s *)dev; + struct pic32mz_timer_priv_s *priv = + (struct pic32mz_timer_priv_s *)dev; /* Initialize the hardware using the startup configuration. * @@ -828,7 +828,7 @@ static void pic32mz_timer_inithardware(FAR struct pic32mz_timer_dev_s *dev) * ****************************************************************************/ -static void pic32mz_timer_setperiod(FAR struct pic32mz_timer_dev_s *dev, +static void pic32mz_timer_setperiod(struct pic32mz_timer_dev_s *dev, uint32_t period) { /* In 32bit mode: @@ -857,7 +857,7 @@ static void pic32mz_timer_setperiod(FAR struct pic32mz_timer_dev_s *dev, * ****************************************************************************/ -static uint32_t pic32mz_timer_getcounter(FAR struct pic32mz_timer_dev_s *dev) +static uint32_t pic32mz_timer_getcounter(struct pic32mz_timer_dev_s *dev) { /* In 32bit mode: * - even timers represent the least significant half words. @@ -890,7 +890,7 @@ static uint32_t pic32mz_timer_getcounter(FAR struct pic32mz_timer_dev_s *dev) * ****************************************************************************/ -static void pic32mz_timer_setcounter(FAR struct pic32mz_timer_dev_s *dev, +static void pic32mz_timer_setcounter(struct pic32mz_timer_dev_s *dev, uint32_t count) { /* In 32bit mode: @@ -919,12 +919,12 @@ static void pic32mz_timer_setcounter(FAR struct pic32mz_timer_dev_s *dev, * ****************************************************************************/ -static uint32_t pic32mz_timer_getfreq(FAR struct pic32mz_timer_dev_s *dev) +static uint32_t pic32mz_timer_getfreq(struct pic32mz_timer_dev_s *dev) { uint8_t prescale; uint32_t freq; - prescale = ((FAR struct pic32mz_timer_priv_s *)dev)->config->prescale; + prescale = ((struct pic32mz_timer_priv_s *)dev)->config->prescale; /* The prescale values are not a continuous power of 2. * There is a gap between 64 and 256 (the 128 is skipped). @@ -950,7 +950,7 @@ static uint32_t pic32mz_timer_getfreq(FAR struct pic32mz_timer_dev_s *dev) * ****************************************************************************/ -static bool pic32mz_timer_setfreq(FAR struct pic32mz_timer_dev_s *dev, +static bool pic32mz_timer_setfreq(struct pic32mz_timer_dev_s *dev, uint32_t freq) { uint16_t prescale; @@ -1038,7 +1038,7 @@ static bool pic32mz_timer_setfreq(FAR struct pic32mz_timer_dev_s *dev, * ****************************************************************************/ -static uint8_t pic32mz_timer_getwidth(FAR struct pic32mz_timer_dev_s *dev) +static uint8_t pic32mz_timer_getwidth(struct pic32mz_timer_dev_s *dev) { return pic32mz_timer_mode32(dev) ? 32 : 16; } @@ -1051,11 +1051,11 @@ static uint8_t pic32mz_timer_getwidth(FAR struct pic32mz_timer_dev_s *dev) * ****************************************************************************/ -static int pic32mz_timer_setisr(FAR struct pic32mz_timer_dev_s *dev, - xcpt_t handler, FAR void *arg) +static int pic32mz_timer_setisr(struct pic32mz_timer_dev_s *dev, + xcpt_t handler, void *arg) { - FAR struct pic32mz_timer_priv_s *priv = - (FAR struct pic32mz_timer_priv_s *)dev; + struct pic32mz_timer_priv_s *priv = + (struct pic32mz_timer_priv_s *)dev; /* Disable interrupt when callback is removed */ @@ -1108,9 +1108,9 @@ static int pic32mz_timer_setisr(FAR struct pic32mz_timer_dev_s *dev, * ****************************************************************************/ -static void pic32mz_timer_ackint(FAR struct pic32mz_timer_dev_s *dev) +static void pic32mz_timer_ackint(struct pic32mz_timer_dev_s *dev) { - up_clrpend_irq(((FAR struct pic32mz_timer_priv_s *)dev)->config->irq); + up_clrpend_irq(((struct pic32mz_timer_priv_s *)dev)->config->irq); if (pic32mz_timer_mode32(dev)) { @@ -1128,7 +1128,7 @@ static void pic32mz_timer_ackint(FAR struct pic32mz_timer_dev_s *dev) * ****************************************************************************/ -static bool pic32mz_timer_checkint(FAR struct pic32mz_timer_dev_s *dev) +static bool pic32mz_timer_checkint(struct pic32mz_timer_dev_s *dev) { if (pic32mz_timer_mode32(dev)) { @@ -1138,8 +1138,8 @@ static bool pic32mz_timer_checkint(FAR struct pic32mz_timer_dev_s *dev) } else { - FAR struct pic32mz_timer_priv_s *priv = - (FAR struct pic32mz_timer_priv_s *)dev; + struct pic32mz_timer_priv_s *priv = + (struct pic32mz_timer_priv_s *)dev; return up_pending_irq(priv->config->irq); } @@ -1153,7 +1153,7 @@ static bool pic32mz_timer_checkint(FAR struct pic32mz_timer_dev_s *dev) * Name: pic32mz_timer_init ****************************************************************************/ -FAR struct pic32mz_timer_dev_s *pic32mz_timer_init(int timer) +struct pic32mz_timer_dev_s *pic32mz_timer_init(int timer) { struct pic32mz_timer_dev_s *dev = NULL; @@ -1161,49 +1161,49 @@ FAR struct pic32mz_timer_dev_s *pic32mz_timer_init(int timer) { #ifdef CONFIG_PIC32MZ_T2 case 2: - dev = (FAR struct pic32mz_timer_dev_s *)&pic32mz_t2_priv; + dev = (struct pic32mz_timer_dev_s *)&pic32mz_t2_priv; break; #endif #ifdef CONFIG_PIC32MZ_T3 case 3: - dev = (FAR struct pic32mz_timer_dev_s *)&pic32mz_t3_priv; + dev = (struct pic32mz_timer_dev_s *)&pic32mz_t3_priv; break; #endif #ifdef CONFIG_PIC32MZ_T4 case 4: - dev = (FAR struct pic32mz_timer_dev_s *)&pic32mz_t4_priv; + dev = (struct pic32mz_timer_dev_s *)&pic32mz_t4_priv; break; #endif #ifdef CONFIG_PIC32MZ_T5 case 5: - dev = (FAR struct pic32mz_timer_dev_s *)&pic32mz_t5_priv; + dev = (struct pic32mz_timer_dev_s *)&pic32mz_t5_priv; break; #endif #ifdef CONFIG_PIC32MZ_T6 case 6: - dev = (FAR struct pic32mz_timer_dev_s *)&pic32mz_t6_priv; + dev = (struct pic32mz_timer_dev_s *)&pic32mz_t6_priv; break; #endif #ifdef CONFIG_PIC32MZ_T7 case 7: - dev = (FAR struct pic32mz_timer_dev_s *)&pic32mz_t7_priv; + dev = (struct pic32mz_timer_dev_s *)&pic32mz_t7_priv; break; #endif #ifdef CONFIG_PIC32MZ_T8 case 8: - dev = (FAR struct pic32mz_timer_dev_s *)&pic32mz_t8_priv; + dev = (struct pic32mz_timer_dev_s *)&pic32mz_t8_priv; break; #endif #ifdef CONFIG_PIC32MZ_T9 case 9: - dev = (FAR struct pic32mz_timer_dev_s *)&pic32mz_t9_priv; + dev = (struct pic32mz_timer_dev_s *)&pic32mz_t9_priv; break; #endif default: return NULL; } - if (((FAR struct pic32mz_timer_priv_s *)dev)->inuse) + if (((struct pic32mz_timer_priv_s *)dev)->inuse) { return NULL; } @@ -1213,20 +1213,20 @@ FAR struct pic32mz_timer_dev_s *pic32mz_timer_init(int timer) pic32mz_timer_inithardware(dev); - ((FAR struct pic32mz_timer_priv_s *)dev)->inuse = true; + ((struct pic32mz_timer_priv_s *)dev)->inuse = true; return dev; } } -int pic32mz_timer_deinit(FAR struct pic32mz_timer_dev_s *dev) +int pic32mz_timer_deinit(struct pic32mz_timer_dev_s *dev) { /* Stop the timer in case it was still running * and mark it as unused. */ pic32mz_timer_stop(dev); - ((FAR struct pic32mz_timer_priv_s *)dev)->inuse = false; + ((struct pic32mz_timer_priv_s *)dev)->inuse = false; return OK; } diff --git a/arch/mips/src/pic32mz/pic32mz_timer.h b/arch/mips/src/pic32mz/pic32mz_timer.h index ee710a4e847f9..28c7fd8143844 100644 --- a/arch/mips/src/pic32mz/pic32mz_timer.h +++ b/arch/mips/src/pic32mz/pic32mz_timer.h @@ -69,28 +69,28 @@ struct pic32mz_timer_ops_s { /* Timer's methods */ - void (*start)(FAR struct pic32mz_timer_dev_s *dev); - void (*stop)(FAR struct pic32mz_timer_dev_s *dev); - void (*setperiod)(FAR struct pic32mz_timer_dev_s *dev, uint32_t p); - uint32_t (*getcounter)(FAR struct pic32mz_timer_dev_s *dev); - void (*setcounter)(FAR struct pic32mz_timer_dev_s *dev, uint32_t c); - uint32_t (*getfreq)(FAR struct pic32mz_timer_dev_s *dev); - bool (*setfreq)(FAR struct pic32mz_timer_dev_s *dev, uint32_t freq); - uint8_t (*getwidth)(FAR struct pic32mz_timer_dev_s *dev); + void (*start)(struct pic32mz_timer_dev_s *dev); + void (*stop)(struct pic32mz_timer_dev_s *dev); + void (*setperiod)(struct pic32mz_timer_dev_s *dev, uint32_t p); + uint32_t (*getcounter)(struct pic32mz_timer_dev_s *dev); + void (*setcounter)(struct pic32mz_timer_dev_s *dev, uint32_t c); + uint32_t (*getfreq)(struct pic32mz_timer_dev_s *dev); + bool (*setfreq)(struct pic32mz_timer_dev_s *dev, uint32_t freq); + uint8_t (*getwidth)(struct pic32mz_timer_dev_s *dev); /* Timer's interrupts */ - int (*setisr)(FAR struct pic32mz_timer_dev_s *dev, xcpt_t handler, + int (*setisr)(struct pic32mz_timer_dev_s *dev, xcpt_t handler, void * arg); - void (*ackint)(FAR struct pic32mz_timer_dev_s *dev); - bool (*checkint)(FAR struct pic32mz_timer_dev_s *dev); + void (*ackint)(struct pic32mz_timer_dev_s *dev); + bool (*checkint)(struct pic32mz_timer_dev_s *dev); }; /* Timer's Device Structure */ struct pic32mz_timer_dev_s { - FAR struct pic32mz_timer_ops_s *ops; + struct pic32mz_timer_ops_s *ops; }; /**************************************************************************** @@ -105,7 +105,7 @@ struct pic32mz_timer_dev_s * ****************************************************************************/ -FAR struct pic32mz_timer_dev_s *pic32mz_timer_init(int timer); +struct pic32mz_timer_dev_s *pic32mz_timer_init(int timer); /**************************************************************************** * Name: pic32mz_timer_deinit @@ -115,7 +115,7 @@ FAR struct pic32mz_timer_dev_s *pic32mz_timer_init(int timer); * ****************************************************************************/ -int pic32mz_timer_deinit(FAR struct pic32mz_timer_dev_s *dev); +int pic32mz_timer_deinit(struct pic32mz_timer_dev_s *dev); /**************************************************************************** * Name: pic32mz_timer_initialize @@ -136,7 +136,7 @@ int pic32mz_timer_deinit(FAR struct pic32mz_timer_dev_s *dev); ****************************************************************************/ #ifdef CONFIG_TIMER -int pic32mz_timer_initialize(FAR const char *devpath, int timer); +int pic32mz_timer_initialize(const char *devpath, int timer); #endif #undef EXTERN diff --git a/arch/mips/src/pic32mz/pic32mz_timer_lowerhalf.c b/arch/mips/src/pic32mz/pic32mz_timer_lowerhalf.c index 0945280f19b77..b012477c305e4 100644 --- a/arch/mips/src/pic32mz/pic32mz_timer_lowerhalf.c +++ b/arch/mips/src/pic32mz/pic32mz_timer_lowerhalf.c @@ -58,16 +58,16 @@ struct pic32mz_lowerhalf_s { - FAR const struct timer_ops_s *ops; /* Lower half operations */ - FAR struct pic32mz_timer_dev_s *timer; /* pic32mz timer driver */ - tccb_t callback; /* Current user interrupt cb */ - FAR void *arg; /* Argument to upper half cb */ - uint32_t timeout; /* Current timeout value (us) */ - uint32_t ticks; /* Timeout converted in ticks */ - uint32_t freq; /* Timer's frequency (Hz) */ - uint8_t width; /* Timer's width */ - uint32_t maxticks; /* Maximum ticks for this timer */ - bool started; /* True: Timer has been started */ + const struct timer_ops_s *ops; /* Lower half operations */ + struct pic32mz_timer_dev_s *timer; /* pic32mz timer driver */ + tccb_t callback; /* Current user interrupt cb */ + void *arg; /* Argument to upper half cb */ + uint32_t timeout; /* Current timeout value (us) */ + uint32_t ticks; /* Timeout converted in ticks */ + uint32_t freq; /* Timer's frequency (Hz) */ + uint8_t width; /* Timer's width */ + uint32_t maxticks; /* Maximum ticks for this timer */ + bool started; /* True: Timer has been started */ }; /**************************************************************************** @@ -87,18 +87,18 @@ static int pic32mz_timer_handler(int irq, void * context, void * arg); /* "Lower half" driver methods **********************************************/ -static int pic32mz_start(FAR struct timer_lowerhalf_s *lower); -static int pic32mz_stop(FAR struct timer_lowerhalf_s *lower); +static int pic32mz_start(struct timer_lowerhalf_s *lower); +static int pic32mz_stop(struct timer_lowerhalf_s *lower); static int pic32mz_getstatus(struct timer_lowerhalf_s *lower, struct timer_status_s *status); -static int pic32mz_settimeout(FAR struct timer_lowerhalf_s *lower, +static int pic32mz_settimeout(struct timer_lowerhalf_s *lower, uint32_t timeout); -static void pic32mz_setcallback(FAR struct timer_lowerhalf_s *lower, - tccb_t callback, FAR void *arg); +static void pic32mz_setcallback(struct timer_lowerhalf_s *lower, + tccb_t callback, void *arg); static int pic32mz_ioctl(struct timer_lowerhalf_s *lower, int cmd, unsigned long arg); -static int pic32mz_maxtimeout(FAR struct timer_lowerhalf_s *lower, - FAR uint32_t *maxtimeout); +static int pic32mz_maxtimeout(struct timer_lowerhalf_s *lower, + uint32_t *maxtimeout); /**************************************************************************** * Private Data @@ -192,7 +192,7 @@ static struct pic32mz_lowerhalf_s g_t9_lowerhalf = * ****************************************************************************/ -static uint32_t pic32mz_usec2ticks(FAR struct pic32mz_lowerhalf_s *priv, +static uint32_t pic32mz_usec2ticks(struct pic32mz_lowerhalf_s *priv, uint32_t usecs) { uint64_t bigticks; @@ -222,7 +222,7 @@ static uint32_t pic32mz_usec2ticks(FAR struct pic32mz_lowerhalf_s *priv, * ****************************************************************************/ -static uint32_t pic32mz_ticks2usec(FAR struct pic32mz_lowerhalf_s *priv, +static uint32_t pic32mz_ticks2usec(struct pic32mz_lowerhalf_s *priv, uint32_t ticks) { uint64_t bigusec; @@ -248,10 +248,10 @@ static uint32_t pic32mz_ticks2usec(FAR struct pic32mz_lowerhalf_s *priv, * ****************************************************************************/ -static int pic32mz_timer_handler(int irq, FAR void *context, FAR void *arg) +static int pic32mz_timer_handler(int irq, void *context, void *arg) { - FAR struct pic32mz_lowerhalf_s *lower = - (FAR struct pic32mz_lowerhalf_s *)arg; + struct pic32mz_lowerhalf_s *lower = + (struct pic32mz_lowerhalf_s *)arg; uint32_t next_interval_us = 0; PIC32MZ_TIMER_ACKINT(lower->timer); @@ -294,10 +294,10 @@ static int pic32mz_timer_handler(int irq, FAR void *context, FAR void *arg) * ****************************************************************************/ -static int pic32mz_start(FAR struct timer_lowerhalf_s *lower) +static int pic32mz_start(struct timer_lowerhalf_s *lower) { - FAR struct pic32mz_lowerhalf_s *priv = - (FAR struct pic32mz_lowerhalf_s *)lower; + struct pic32mz_lowerhalf_s *priv = + (struct pic32mz_lowerhalf_s *)lower; if (!priv->started) { @@ -333,10 +333,10 @@ static int pic32mz_start(FAR struct timer_lowerhalf_s *lower) * ****************************************************************************/ -static int pic32mz_stop(FAR struct timer_lowerhalf_s *lower) +static int pic32mz_stop(struct timer_lowerhalf_s *lower) { - FAR struct pic32mz_lowerhalf_s *priv = - (FAR struct pic32mz_lowerhalf_s *)lower; + struct pic32mz_lowerhalf_s *priv = + (struct pic32mz_lowerhalf_s *)lower; if (priv->started) { @@ -368,11 +368,11 @@ static int pic32mz_stop(FAR struct timer_lowerhalf_s *lower) * ****************************************************************************/ -static int pic32mz_getstatus(FAR struct timer_lowerhalf_s *lower, - FAR struct timer_status_s *status) +static int pic32mz_getstatus(struct timer_lowerhalf_s *lower, + struct timer_status_s *status) { - FAR struct pic32mz_lowerhalf_s *priv = - (FAR struct pic32mz_lowerhalf_s *)lower; + struct pic32mz_lowerhalf_s *priv = + (struct pic32mz_lowerhalf_s *)lower; uint32_t remainingticks; DEBUGASSERT(priv); @@ -421,11 +421,11 @@ static int pic32mz_getstatus(FAR struct timer_lowerhalf_s *lower, * ****************************************************************************/ -static int pic32mz_settimeout(FAR struct timer_lowerhalf_s *lower, +static int pic32mz_settimeout(struct timer_lowerhalf_s *lower, uint32_t timeout) { - FAR struct pic32mz_lowerhalf_s *priv = - (FAR struct pic32mz_lowerhalf_s *)lower; + struct pic32mz_lowerhalf_s *priv = + (struct pic32mz_lowerhalf_s *)lower; DEBUGASSERT(priv); @@ -492,11 +492,11 @@ static int pic32mz_settimeout(FAR struct timer_lowerhalf_s *lower, * ****************************************************************************/ -static void pic32mz_setcallback(FAR struct timer_lowerhalf_s *lower, - tccb_t callback, FAR void *arg) +static void pic32mz_setcallback(struct timer_lowerhalf_s *lower, + tccb_t callback, void *arg) { - FAR struct pic32mz_lowerhalf_s *priv = - (FAR struct pic32mz_lowerhalf_s *)lower; + struct pic32mz_lowerhalf_s *priv = + (struct pic32mz_lowerhalf_s *)lower; irqstate_t flags = enter_critical_section(); @@ -530,7 +530,7 @@ static void pic32mz_setcallback(FAR struct timer_lowerhalf_s *lower, * ****************************************************************************/ -static int pic32mz_ioctl(FAR struct timer_lowerhalf_s *lower, int cmd, +static int pic32mz_ioctl(struct timer_lowerhalf_s *lower, int cmd, unsigned long arg) { int ret = -ENOTTY; @@ -557,11 +557,11 @@ static int pic32mz_ioctl(FAR struct timer_lowerhalf_s *lower, int cmd, * ****************************************************************************/ -static int pic32mz_maxtimeout(FAR struct timer_lowerhalf_s *lower, - FAR uint32_t *maxtimeout) +static int pic32mz_maxtimeout(struct timer_lowerhalf_s *lower, + uint32_t *maxtimeout) { - FAR struct pic32mz_lowerhalf_s *priv = - (FAR struct pic32mz_lowerhalf_s *)lower; + struct pic32mz_lowerhalf_s *priv = + (struct pic32mz_lowerhalf_s *)lower; DEBUGASSERT(priv); @@ -594,10 +594,10 @@ static int pic32mz_maxtimeout(FAR struct timer_lowerhalf_s *lower, * ****************************************************************************/ -int pic32mz_timer_initialize(FAR const char *devpath, int timer) +int pic32mz_timer_initialize(const char *devpath, int timer) { - FAR struct pic32mz_lowerhalf_s *lower; - FAR void *drvr; + struct pic32mz_lowerhalf_s *lower; + void *drvr; tmrinfo("Initializing %s - timer %d\n", devpath, timer); diff --git a/arch/mips/src/pic32mz/pic32mz_usbdev.h b/arch/mips/src/pic32mz/pic32mz_usbdev.h index d8861bffe930e..4e42b90b6e96a 100644 --- a/arch/mips/src/pic32mz/pic32mz_usbdev.h +++ b/arch/mips/src/pic32mz/pic32mz_usbdev.h @@ -71,7 +71,7 @@ extern "C" #ifdef CONFIG_PIC32MZ_USBDEV struct usbdev_s; -int pic32mz_usbpullup(FAR struct usbdev_s *dev, bool enable); +int pic32mz_usbpullup(struct usbdev_s *dev, bool enable); #endif /************************************************************************************ @@ -86,7 +86,7 @@ int pic32mz_usbpullup(FAR struct usbdev_s *dev, bool enable); ************************************************************************************/ #ifdef CONFIG_PIC32MZ_USBDEV -void pic32mz_usbsuspend(FAR struct usbdev_s *dev, bool resume); +void pic32mz_usbsuspend(struct usbdev_s *dev, bool resume); #endif /************************************************************************************ diff --git a/arch/misoc/include/syscall.h b/arch/misoc/include/syscall.h index 8125775643219..bbea8797cb1f5 100644 --- a/arch/misoc/include/syscall.h +++ b/arch/misoc/include/syscall.h @@ -90,7 +90,7 @@ */ #define SYS_syscall_return (3) -#define up_syscall_return() (void)sys_call0(SYS_syscall_return) +#define up_syscall_return() sys_call0(SYS_syscall_return) #endif diff --git a/arch/misoc/src/common/misoc_net.c b/arch/misoc/src/common/misoc_net.c index d715e2c728aef..832b98c9bc666 100644 --- a/arch/misoc/src/common/misoc_net.c +++ b/arch/misoc/src/common/misoc_net.c @@ -88,7 +88,7 @@ /* This is a helper pointer for accessing the contents of Ethernet header */ -#define BUF ((FAR struct eth_hdr_s *)priv->misoc_net_dev.d_buf) +#define BUF ((struct eth_hdr_s *)priv->misoc_net_dev.d_buf) /**************************************************************************** * Private Types @@ -135,42 +135,42 @@ static struct misoc_net_driver_s g_misoc_net[CONFIG_MISOC_NET_NINTERFACES]; /* Common TX logic */ -static int misoc_net_transmit(FAR struct misoc_net_driver_s *priv); -static int misoc_net_txpoll(FAR struct net_driver_s *dev); +static int misoc_net_transmit(struct misoc_net_driver_s *priv); +static int misoc_net_txpoll(struct net_driver_s *dev); /* Interrupt handling */ -static void misoc_net_receive(FAR struct misoc_net_driver_s *priv); -static void misoc_net_txdone(FAR struct misoc_net_driver_s *priv); +static void misoc_net_receive(struct misoc_net_driver_s *priv); +static void misoc_net_txdone(struct misoc_net_driver_s *priv); -static void misoc_net_interrupt_work(FAR void *arg); -static int misoc_net_interrupt(int irq, FAR void *context, FAR void *arg); +static void misoc_net_interrupt_work(void *arg); +static int misoc_net_interrupt(int irq, void *context, void *arg); /* Watchdog timer expirations */ -static void misoc_net_txtimeout_work(FAR void *arg); +static void misoc_net_txtimeout_work(void *arg); static void misoc_net_txtimeout_expiry(wdparm_t arg); -static void misoc_net_poll_work(FAR void *arg); +static void misoc_net_poll_work(void *arg); static void misoc_net_poll_expiry(wdparm_t arg); /* NuttX callback functions */ -static int misoc_net_ifup(FAR struct net_driver_s *dev); -static int misoc_net_ifdown(FAR struct net_driver_s *dev); +static int misoc_net_ifup(struct net_driver_s *dev); +static int misoc_net_ifdown(struct net_driver_s *dev); -static void misoc_net_txavail_work(FAR void *arg); -static int misoc_net_txavail(FAR struct net_driver_s *dev); +static void misoc_net_txavail_work(void *arg); +static int misoc_net_txavail(struct net_driver_s *dev); #if defined(CONFIG_NET_MCASTGROUP) || defined(CONFIG_NET_ICMPv6) -static int misoc_net_addmac(FAR struct net_driver_s *dev, - FAR const uint8_t *mac); +static int misoc_net_addmac(struct net_driver_s *dev, + const uint8_t *mac); #ifdef CONFIG_NET_MCASTGROUP -static int misoc_net_rmmac(FAR struct net_driver_s *dev, - FAR const uint8_t *mac); +static int misoc_net_rmmac(struct net_driver_s *dev, + const uint8_t *mac); #endif #ifdef CONFIG_NET_ICMPv6 -static void misoc_net_ipv6multicast(FAR struct misoc_net_driver_s *priv); +static void misoc_net_ipv6multicast(struct misoc_net_driver_s *priv); #endif #endif @@ -197,7 +197,7 @@ static void misoc_net_ipv6multicast(FAR struct misoc_net_driver_s *priv); * ****************************************************************************/ -static int misoc_net_transmit(FAR struct misoc_net_driver_s *priv) +static int misoc_net_transmit(struct misoc_net_driver_s *priv) { /* Verify that the hardware is ready to send another packet. If we get * here, then we are committed to sending a packet; Higher level logic @@ -286,10 +286,10 @@ static int misoc_net_transmit(FAR struct misoc_net_driver_s *priv) * ****************************************************************************/ -static int misoc_net_txpoll(FAR struct net_driver_s *dev) +static int misoc_net_txpoll(struct net_driver_s *dev) { - FAR struct misoc_net_driver_s *priv = - (FAR struct misoc_net_driver_s *)dev->d_private; + struct misoc_net_driver_s *priv = + (struct misoc_net_driver_s *)dev->d_private; /* If the polling resulted in data that should be sent out on the network, * the field d_len is set to a value > 0. @@ -355,7 +355,7 @@ static int misoc_net_txpoll(FAR struct net_driver_s *dev) * ****************************************************************************/ -static void misoc_net_receive(FAR struct misoc_net_driver_s *priv) +static void misoc_net_receive(struct misoc_net_driver_s *priv) { uint8_t rxslot; uint32_t rxlen; @@ -529,7 +529,7 @@ static void misoc_net_receive(FAR struct misoc_net_driver_s *priv) * ****************************************************************************/ -static void misoc_net_txdone(FAR struct misoc_net_driver_s *priv) +static void misoc_net_txdone(struct misoc_net_driver_s *priv) { /* Check for errors and update statistics */ @@ -569,9 +569,9 @@ static void misoc_net_txdone(FAR struct misoc_net_driver_s *priv) * ****************************************************************************/ -static void misoc_net_interrupt_work(FAR void *arg) +static void misoc_net_interrupt_work(void *arg) { - FAR struct misoc_net_driver_s *priv = (FAR struct misoc_net_driver_s *)arg; + struct misoc_net_driver_s *priv = (struct misoc_net_driver_s *)arg; /* Process pending Ethernet interrupts */ @@ -624,9 +624,9 @@ static void misoc_net_interrupt_work(FAR void *arg) * ****************************************************************************/ -static int misoc_net_interrupt(int irq, FAR void *context, FAR void *arg) +static int misoc_net_interrupt(int irq, void *context, void *arg) { - FAR struct misoc_net_driver_s *priv = &g_misoc_net[0]; + struct misoc_net_driver_s *priv = &g_misoc_net[0]; /* Disable further Ethernet interrupts. Because Ethernet interrupts are * also disabled if the TX timeout event occurs, there can be no race @@ -672,9 +672,9 @@ static int misoc_net_interrupt(int irq, FAR void *context, FAR void *arg) * ****************************************************************************/ -static void misoc_net_txtimeout_work(FAR void *arg) +static void misoc_net_txtimeout_work(void *arg) { - FAR struct misoc_net_driver_s *priv = (FAR struct misoc_net_driver_s *)arg; + struct misoc_net_driver_s *priv = (struct misoc_net_driver_s *)arg; /* Increment statistics and dump debug info */ @@ -709,7 +709,7 @@ static void misoc_net_txtimeout_work(FAR void *arg) static void misoc_net_txtimeout_expiry(wdparm_t arg) { - FAR struct misoc_net_driver_s *priv = (FAR struct misoc_net_driver_s *)arg; + struct misoc_net_driver_s *priv = (struct misoc_net_driver_s *)arg; #if 0 /* REVISIT */ /* Disable further Ethernet interrupts. This will prevent some race @@ -743,9 +743,9 @@ static void misoc_net_txtimeout_expiry(wdparm_t arg) * ****************************************************************************/ -static void misoc_net_poll_work(FAR void *arg) +static void misoc_net_poll_work(void *arg) { - FAR struct misoc_net_driver_s *priv = (FAR struct misoc_net_driver_s *)arg; + struct misoc_net_driver_s *priv = (struct misoc_net_driver_s *)arg; /* Perform the poll */ @@ -789,7 +789,7 @@ static void misoc_net_poll_work(FAR void *arg) static void misoc_net_poll_expiry(wdparm_t arg) { - FAR struct misoc_net_driver_s *priv = (FAR struct misoc_net_driver_s *)arg; + struct misoc_net_driver_s *priv = (struct misoc_net_driver_s *)arg; /* Schedule to perform the interrupt processing on the worker thread. */ @@ -814,11 +814,11 @@ static void misoc_net_poll_expiry(wdparm_t arg) * ****************************************************************************/ -static int misoc_net_ifup(FAR struct net_driver_s *dev) +static int misoc_net_ifup(struct net_driver_s *dev) { irqstate_t flags; - FAR struct misoc_net_driver_s *priv = - (FAR struct misoc_net_driver_s *)dev->d_private; + struct misoc_net_driver_s *priv = + (struct misoc_net_driver_s *)dev->d_private; #ifdef CONFIG_NET_IPv4 ninfo("Bringing up: %d.%d.%d.%d\n", @@ -877,10 +877,10 @@ static int misoc_net_ifup(FAR struct net_driver_s *dev) * ****************************************************************************/ -static int misoc_net_ifdown(FAR struct net_driver_s *dev) +static int misoc_net_ifdown(struct net_driver_s *dev) { - FAR struct misoc_net_driver_s *priv = - (FAR struct misoc_net_driver_s *)dev->d_private; + struct misoc_net_driver_s *priv = + (struct misoc_net_driver_s *)dev->d_private; irqstate_t flags; /* Disable the Ethernet interrupt */ @@ -925,10 +925,10 @@ static int misoc_net_ifdown(FAR struct net_driver_s *dev) * ****************************************************************************/ -static void misoc_net_txavail_work(FAR void *arg) +static void misoc_net_txavail_work(void *arg) { - FAR struct misoc_net_driver_s *priv = - (FAR struct misoc_net_driver_s *)arg; + struct misoc_net_driver_s *priv = + (struct misoc_net_driver_s *)arg; /* Ignore the notification if the interface is not yet up */ @@ -967,10 +967,10 @@ static void misoc_net_txavail_work(FAR void *arg) * ****************************************************************************/ -static int misoc_net_txavail(FAR struct net_driver_s *dev) +static int misoc_net_txavail(struct net_driver_s *dev) { - FAR struct misoc_net_driver_s *priv = - (FAR struct misoc_net_driver_s *)dev->d_private; + struct misoc_net_driver_s *priv = + (struct misoc_net_driver_s *)dev->d_private; /* Is our single work structure available? It may not be if there are * pending interrupt actions and we will have to ignore the Tx @@ -1007,11 +1007,11 @@ static int misoc_net_txavail(FAR struct net_driver_s *dev) ****************************************************************************/ #if defined(CONFIG_NET_MCASTGROUP) || defined(CONFIG_NET_ICMPv6) -static int misoc_net_addmac(FAR struct net_driver_s *dev, - FAR const uint8_t *mac) +static int misoc_net_addmac(struct net_driver_s *dev, + const uint8_t *mac) { - FAR struct misoc_net_driver_s *priv = - (FAR struct misoc_net_driver_s *)dev->d_private; + struct misoc_net_driver_s *priv = + (struct misoc_net_driver_s *)dev->d_private; /* Add the MAC address to the hardware multicast routing table */ @@ -1038,11 +1038,11 @@ static int misoc_net_addmac(FAR struct net_driver_s *dev, ****************************************************************************/ #ifdef CONFIG_NET_MCASTGROUP -static int misoc_net_rmmac(FAR struct net_driver_s *dev, - FAR const uint8_t *mac) +static int misoc_net_rmmac(struct net_driver_s *dev, + const uint8_t *mac) { - FAR struct misoc_net_driver_s *priv = - (FAR struct misoc_net_driver_s *)dev->d_private; + struct misoc_net_driver_s *priv = + (struct misoc_net_driver_s *)dev->d_private; /* Add the MAC address to the hardware multicast routing table */ @@ -1067,9 +1067,9 @@ static int misoc_net_rmmac(FAR struct net_driver_s *dev, ****************************************************************************/ #ifdef CONFIG_NET_ICMPv6 -static void misoc_net_ipv6multicast(FAR struct misoc_net_driver_s *priv) +static void misoc_net_ipv6multicast(struct misoc_net_driver_s *priv) { - FAR struct net_driver_s *dev; + struct net_driver_s *dev; uint16_t tmp16; uint8_t mac[6]; @@ -1146,7 +1146,7 @@ static void misoc_net_ipv6multicast(FAR struct misoc_net_driver_s *priv) int misoc_net_initialize(int intf) { - FAR struct misoc_net_driver_s *priv; + struct misoc_net_driver_s *priv; /* Get the interface structure associated with this interface number. */ diff --git a/arch/misoc/src/common/misoc_serial.c b/arch/misoc/src/common/misoc_serial.c index 7db014df2c0bb..632e209bc4788 100644 --- a/arch/misoc/src/common/misoc_serial.c +++ b/arch/misoc/src/common/misoc_serial.c @@ -141,7 +141,7 @@ static int misoc_setup(struct uart_dev_s *dev); static void misoc_shutdown(struct uart_dev_s *dev); static int misoc_attach(struct uart_dev_s *dev); static void misoc_detach(struct uart_dev_s *dev); -static int misoc_uart_interrupt(int irq, void *context, FAR void *arg); +static int misoc_uart_interrupt(int irq, void *context, void *arg); static int misoc_ioctl(struct file *filep, int cmd, unsigned long arg); static int misoc_receive(struct uart_dev_s *dev, uint32_t *status); static void misoc_rxint(struct uart_dev_s *dev, bool enable); @@ -335,7 +335,7 @@ static void misoc_detach(struct uart_dev_s *dev) * ****************************************************************************/ -static int misoc_uart_interrupt(int irq, void *context, FAR void *arg) +static int misoc_uart_interrupt(int irq, void *context, void *arg) { struct uart_dev_s *dev = (struct uart_dev_s *)arg; uint32_t stat; diff --git a/arch/misoc/src/lm32/Kconfig b/arch/misoc/src/lm32/Kconfig index 83ce834dcee13..b4c3e858d85fa 100644 --- a/arch/misoc/src/lm32/Kconfig +++ b/arch/misoc/src/lm32/Kconfig @@ -7,25 +7,15 @@ if ARCH_CHIP_LM32 choice prompt "Toolchain Selection" - default LM32_TOOLCHAIN_GNUW if TOOLCHAIN_WINDOWS - default LM32_TOOLCHAIN_GNUL if !TOOLCHAIN_WINDOWS + default LM32_TOOLCHAIN_GNU config LM32_TOOLCHAIN_BUILDROOT bool "Buildroot (Cygwin or Linux)" depends on !WINDOWS_NATIVE select ARCH_TOOLCHAIN_GNU -config LM32_TOOLCHAIN_GNUL - bool "Generic GNU toolchain under Linux (or other POSIX environment)" - select ARCH_TOOLCHAIN_GNU - ---help--- - This option should work for any modern GNU toolchain (GCC 4.5 or newer) - configured for lm32-elf-. - -config LM32_TOOLCHAIN_GNUW - bool "Generic GNU toolchain under Windows" - depends on TOOLCHAIN_WINDOWS - select CYGWIN_WINTOOL if WINDOWS_CYGWIN +config LM32_TOOLCHAIN_GNU + bool "Generic GNU toolchain" select ARCH_TOOLCHAIN_GNU ---help--- This option should work for any modern GNU toolchain (GCC 4.5 or newer) diff --git a/arch/misoc/src/lm32/Toolchain.defs b/arch/misoc/src/lm32/Toolchain.defs index 72071809652f8..c24a671541a09 100644 --- a/arch/misoc/src/lm32/Toolchain.defs +++ b/arch/misoc/src/lm32/Toolchain.defs @@ -32,13 +32,7 @@ ifeq ($(filter y, \ endif ifeq ($(filter y, \ - $(CONFIG_LM32_TOOLCHAIN_GNUL) \ - ),y) - CONFIG_LM32_TOOLCHAIN ?= GNU -endif - -ifeq ($(filter y, \ - $(CONFIG_LM32_TOOLCHAIN_GNUW) \ + $(CONFIG_LM32_TOOLCHAIN_GNU) \ ),y) CONFIG_LM32_TOOLCHAIN ?= GNU endif @@ -51,14 +45,40 @@ endif # CROSSDEV The GNU toolchain triple (command prefix) # ARCHCPUFLAGS CPU-specific flags selecting the instruction set # FPU options, etc. -# MAXOPTIMIZATION The maximum optimization level that results in +# ARCHOPTIMIZATION The optimization level that results in # reliable code generation. # ifeq ($(CONFIG_DEBUG_CUSTOMOPT),y) - MAXOPTIMIZATION := $(CONFIG_DEBUG_OPTLEVEL) + ARCHOPTIMIZATION += $(CONFIG_DEBUG_OPTLEVEL) +else ifeq ($(CONFIG_DEBUG_FULLOPT),y) + ARCHOPTIMIZATION += -Os +endif + +ifneq ($(CONFIG_DEBUG_NOOPT),y) + ARCHOPTIMIZATION += -fno-strict-aliasing +endif + +ifeq ($(CONFIG_FRAME_POINTER),y) + ARCHOPTIMIZATION += -fno-omit-frame-pointer -fno-optimize-sibling-calls else - MAXOPTIMIZATION ?= -Os + ARCHOPTIMIZATION += -fomit-frame-pointer +endif + +ifeq ($(CONFIG_DEBUG_SYMBOLS),y) + LDFLAGS += -g + ARCHOPTIMIZATION += -g +endif + +ARCHCFLAGS += -fno-common +ARCHCXXFLAGS += -fno-common -nostdinc++ + +ifneq ($(CONFIG_CXX_EXCEPTION),y) + ARCHCXXFLAGS += -fno-exceptions -fcheck-new +endif + +ifneq ($(CONFIG_CXX_RTTI),y) + ARCHCXXFLAGS += -fno-rtti endif # NuttX buildroot under Linux or Cygwin @@ -87,12 +107,12 @@ OBJDUMP = $(CROSSDEV)objdump # Add the builtin library -EXTRA_LIBS += ${wildcard ${shell $(CC) $(ARCHCPUFLAGS) --print-libgcc-file-name}} +EXTRA_LIBS += $(wildcard $(shell $(CC) $(ARCHCPUFLAGS) --print-libgcc-file-name)) ifneq ($(CONFIG_LIBM),y) - EXTRA_LIBS += ${wildcard ${shell $(CC) $(ARCHCPUFLAGS) --print-file-name=libm.a}} + EXTRA_LIBS += $(wildcard $(shell $(CC) $(ARCHCPUFLAGS) --print-file-name=libm.a)) endif ifeq ($(CONFIG_LIBSUPCXX),y) - EXTRA_LIBS += ${wildcard ${shell $(CC) $(ARCHCPUFLAGS) --print-file-name=libsupc++.a}} + EXTRA_LIBS += $(wildcard $(shell $(CC) $(ARCHCPUFLAGS) --print-file-name=libsupc++.a)) endif diff --git a/arch/misoc/src/lm32/lm32.h b/arch/misoc/src/lm32/lm32.h index e21b6515a9155..9d5439fe002d9 100644 --- a/arch/misoc/src/lm32/lm32.h +++ b/arch/misoc/src/lm32/lm32.h @@ -115,7 +115,7 @@ uint32_t *lm32_doirq(int irq, uint32_t *regs); /* Software interrupts ******************************************************/ -int lm32_swint(int irq, FAR void *context, FAR void *arg); +int lm32_swint(int irq, void *context, void *arg); /* Signal handling **********************************************************/ diff --git a/arch/misoc/src/lm32/lm32_allocateheap.c b/arch/misoc/src/lm32/lm32_allocateheap.c index 84b4e0494c5c2..8356351808953 100644 --- a/arch/misoc/src/lm32/lm32_allocateheap.c +++ b/arch/misoc/src/lm32/lm32_allocateheap.c @@ -64,9 +64,9 @@ * ****************************************************************************/ -void up_allocate_heap(FAR void **heap_start, size_t *heap_size) +void up_allocate_heap(void **heap_start, size_t *heap_size) { board_autoled_on(LED_HEAPALLOCATE); - *heap_start = (FAR void *)g_idle_topstack; + *heap_start = (void *)g_idle_topstack; *heap_size = CONFIG_RAM_END - g_idle_topstack; } diff --git a/arch/misoc/src/lm32/lm32_assert.c b/arch/misoc/src/lm32/lm32_assert.c index 93eab92fe5345..f0e8c6c279e84 100644 --- a/arch/misoc/src/lm32/lm32_assert.c +++ b/arch/misoc/src/lm32/lm32_assert.c @@ -104,7 +104,7 @@ static void _up_assert(void) ****************************************************************************/ #ifdef CONFIG_ARCH_USBDUMP -static int usbtrace_syslog(FAR const char *fmt, ...) +static int usbtrace_syslog(const char *fmt, ...) { va_list ap; @@ -116,7 +116,7 @@ static int usbtrace_syslog(FAR const char *fmt, ...) return OK; } -static int assert_tracecallback(FAR struct usbtrace_s *trace, FAR void *arg) +static int assert_tracecallback(struct usbtrace_s *trace, void *arg) { usbtrace_trprintf(usbtrace_syslog, trace->event, trace->value); return 0; diff --git a/arch/misoc/src/lm32/lm32_blocktask.c b/arch/misoc/src/lm32/lm32_blocktask.c index 97f3d5a4ff077..9bed1c020123b 100644 --- a/arch/misoc/src/lm32/lm32_blocktask.c +++ b/arch/misoc/src/lm32/lm32_blocktask.c @@ -136,15 +136,6 @@ void up_block_task(struct tcb_s *tcb, tstate_t task_state) struct tcb_s *nexttcb = this_task(); -#ifdef CONFIG_ARCH_ADDRENV - /* Make sure that the address environment for the previously - * running task is closed down gracefully (data caches dump, - * MMU flushed) and set up the address environment for the new - * thread at the head of the ready-to-run list. - */ - - group_addrenv(nexttcb); -#endif /* Reset scheduler parameters */ nxsched_resume_scheduler(nexttcb); diff --git a/arch/misoc/src/lm32/lm32_createstack.c b/arch/misoc/src/lm32/lm32_createstack.c index f8c674b940366..a1024437b3418 100644 --- a/arch/misoc/src/lm32/lm32_createstack.c +++ b/arch/misoc/src/lm32/lm32_createstack.c @@ -79,7 +79,7 @@ * ****************************************************************************/ -int up_create_stack(FAR struct tcb_s *tcb, size_t stack_size, uint8_t ttype) +int up_create_stack(struct tcb_s *tcb, size_t stack_size, uint8_t ttype) { #ifdef CONFIG_TLS_ALIGNED /* The allocated stack size must not exceed the maximum possible for the diff --git a/arch/misoc/src/lm32/lm32_dumpstate.c b/arch/misoc/src/lm32/lm32_dumpstate.c index a303490742e85..520e9f396f317 100644 --- a/arch/misoc/src/lm32/lm32_dumpstate.c +++ b/arch/misoc/src/lm32/lm32_dumpstate.c @@ -114,7 +114,7 @@ static inline void lm32_registerdump(void) void lm32_dumpstate(void) { - FAR struct tcb_s *rtcb = running_task(); + struct tcb_s *rtcb = running_task(); uint32_t sp = up_getsp(); uint32_t ustackbase; uint32_t ustacksize; diff --git a/arch/misoc/src/lm32/lm32_exit.c b/arch/misoc/src/lm32/lm32_exit.c index 9cb130783b0ca..08ff71cfb5e93 100644 --- a/arch/misoc/src/lm32/lm32_exit.c +++ b/arch/misoc/src/lm32/lm32_exit.c @@ -55,16 +55,16 @@ ****************************************************************************/ #ifdef CONFIG_DUMP_ON_EXIT -static void _up_dumponexit(FAR struct tcb_s *tcb, FAR void *arg) +static void _up_dumponexit(struct tcb_s *tcb, void *arg) { - FAR struct filelist *filelist; + struct filelist *filelist; int i; int j; sinfo(" TCB=%p name=%s pid=%d\n", tcb, tcb->name, tcb->pid); sinfo(" priority=%d state=%d\n", tcb->sched_priority, tcb->task_state); - filelist = tcb->group->tg_filelist; + filelist = &tcb->group->tg_filelist; for (i = 0; i < filelist->fl_rows; i++) { for (j = 0; j < CONFIG_NFILE_DESCRIPTORS_PER_BLOCK; j++) @@ -108,15 +108,15 @@ void up_exit(int status) sinfo("TCB=%p exiting\n", tcb); + /* Destroy the task at the head of the ready to run list. */ + + nxtask_exit(); + #ifdef CONFIG_DUMP_ON_EXIT sinfo("Other tasks:\n"); nxsched_foreach(_up_dumponexit, NULL); #endif - /* Destroy the task at the head of the ready to run list. */ - - nxtask_exit(); - /* Now, perform the context switch to the new ready-to-run task at the * head of the list. */ @@ -127,16 +127,6 @@ void up_exit(int status) nxsched_resume_scheduler(tcb); -#ifdef CONFIG_ARCH_ADDRENV - /* Make sure that the address environment for the previously running - * task is closed down gracefully (data caches dump, MMU flushed) and - * set up the address environment for the new thread at the head of - * the ready-to-run list. - */ - - group_addrenv(tcb); -#endif - /* Then switch contexts */ up_fullcontextrestore(tcb->xcp.regs); diff --git a/arch/misoc/src/lm32/lm32_releasepending.c b/arch/misoc/src/lm32/lm32_releasepending.c index f36f46ab58f12..75f88a0bfe70c 100644 --- a/arch/misoc/src/lm32/lm32_releasepending.c +++ b/arch/misoc/src/lm32/lm32_releasepending.c @@ -105,15 +105,6 @@ void up_release_pending(void) struct tcb_s *nexttcb = this_task(); -#ifdef CONFIG_ARCH_ADDRENV - /* Make sure that the address environment for the previously - * running task is closed down gracefully (data caches dump, - * MMU flushed) and set up the address environment for the new - * thread at the head of the ready-to-run list. - */ - - group_addrenv(nexttcb); -#endif /* Update scheduler parameters */ nxsched_resume_scheduler(nexttcb); diff --git a/arch/misoc/src/lm32/lm32_releasestack.c b/arch/misoc/src/lm32/lm32_releasestack.c index 64af00eb34ed7..31489d781450c 100644 --- a/arch/misoc/src/lm32/lm32_releasestack.c +++ b/arch/misoc/src/lm32/lm32_releasestack.c @@ -67,7 +67,7 @@ * ****************************************************************************/ -void up_release_stack(FAR struct tcb_s *dtcb, uint8_t ttype) +void up_release_stack(struct tcb_s *dtcb, uint8_t ttype) { /* Is there a stack allocated? */ diff --git a/arch/misoc/src/lm32/lm32_reprioritizertr.c b/arch/misoc/src/lm32/lm32_reprioritizertr.c index 5203abe962cd8..97a2568b8afbe 100644 --- a/arch/misoc/src/lm32/lm32_reprioritizertr.c +++ b/arch/misoc/src/lm32/lm32_reprioritizertr.c @@ -159,15 +159,6 @@ void up_reprioritize_rtr(struct tcb_s *tcb, uint8_t priority) struct tcb_s *nexttcb = this_task(); -#ifdef CONFIG_ARCH_ADDRENV - /* Make sure that the address environment for the previously - * running task is closed down gracefully (data caches dump, - * MMU flushed) and set up the address environment for the new - * thread at the head of the ready-to-run list. - */ - - group_addrenv(nexttcb); -#endif /* Update scheduler parameters */ nxsched_resume_scheduler(nexttcb); diff --git a/arch/misoc/src/lm32/lm32_stackframe.c b/arch/misoc/src/lm32/lm32_stackframe.c index bbcceb0432783..cbc2a51593373 100644 --- a/arch/misoc/src/lm32/lm32_stackframe.c +++ b/arch/misoc/src/lm32/lm32_stackframe.c @@ -68,9 +68,9 @@ * ****************************************************************************/ -FAR void *up_stack_frame(FAR struct tcb_s *tcb, size_t frame_size) +void *up_stack_frame(struct tcb_s *tcb, size_t frame_size) { - FAR void *ret; + void *ret; /* Align the frame_size */ @@ -88,7 +88,7 @@ FAR void *up_stack_frame(FAR struct tcb_s *tcb, size_t frame_size) /* Save the adjusted stack values in the struct tcb_s */ - tcb->stack_base_ptr = (FAR uint8_t *)tcb->stack_base_ptr + frame_size; + tcb->stack_base_ptr = (uint8_t *)tcb->stack_base_ptr + frame_size; tcb->adj_stack_size -= frame_size; /* And return the pointer to the allocated region */ diff --git a/arch/misoc/src/lm32/lm32_swint.c b/arch/misoc/src/lm32/lm32_swint.c index 1d7454c7bd09d..b54336eb00634 100644 --- a/arch/misoc/src/lm32/lm32_swint.c +++ b/arch/misoc/src/lm32/lm32_swint.c @@ -127,7 +127,7 @@ static void dispatch_syscall(void) * ****************************************************************************/ -int lm32_swint(int irq, FAR void *context, FAR void *arg) +int lm32_swint(int irq, void *context, void *arg) { uint32_t *regs = (uint32_t *)context; @@ -244,7 +244,7 @@ int lm32_swint(int irq, FAR void *context, FAR void *arg) default: { #ifdef CONFIG_BUILD_KERNEL - FAR struct tcb_s *rtcb = nxsched_self(); + struct tcb_s *rtcb = nxsched_self(); int index = rtcb->xcp.nsyscalls; /* Verify that the SYS call number is within range */ @@ -296,33 +296,5 @@ int lm32_swint(int irq, FAR void *context, FAR void *arg) } #endif -#if defined(CONFIG_ARCH_FPU) || defined(CONFIG_ARCH_ADDRENV) - /* Check for a context switch. If a context switch occurred, then - * g_current_regs will have a different value than it did on entry. If an - * interrupt level context switch has occurred, then restore the floating - * point state and the establish the correct address environment before - * returning from the interrupt. - */ - - if (regs != g_current_regs) - { -#ifdef CONFIG_ARCH_FPU - /* Restore floating point registers */ - - up_restorefpu((uint32_t *)g_current_regs); -#endif - -#ifdef CONFIG_ARCH_ADDRENV - /* Make sure that the address environment for the previously - * running task is closed down gracefully (data caches dump, - * MMU flushed) and set up the address environment for the new - * thread at the head of the ready-to-run list. - */ - - group_addrenv(NULL); -#endif - } -#endif - return OK; } diff --git a/arch/misoc/src/lm32/lm32_unblocktask.c b/arch/misoc/src/lm32/lm32_unblocktask.c index bdd6ade3bdd8e..4a6e69decb95c 100644 --- a/arch/misoc/src/lm32/lm32_unblocktask.c +++ b/arch/misoc/src/lm32/lm32_unblocktask.c @@ -122,15 +122,6 @@ void up_unblock_task(struct tcb_s *tcb) struct tcb_s *nexttcb = this_task(); -#ifdef CONFIG_ARCH_ADDRENV - /* Make sure that the address environment for the previously - * running task is closed down gracefully (data caches dump, - * MMU flushed) and set up the address environment for the new - * thread at the head of the ready-to-run list. - */ - - group_addrenv(nexttcb); -#endif /* Update scheduler parameters */ nxsched_resume_scheduler(nexttcb); diff --git a/arch/misoc/src/minerva/Kconfig b/arch/misoc/src/minerva/Kconfig index 3be1b36d5868f..df536bc7a3f27 100644 --- a/arch/misoc/src/minerva/Kconfig +++ b/arch/misoc/src/minerva/Kconfig @@ -7,25 +7,15 @@ if ARCH_CHIP_MINERVA choice prompt "Toolchain Selection" - default MINERVA_TOOLCHAIN_GNUW if TOOLCHAIN_WINDOWS - default MINERVA_TOOLCHAIN_GNUL if !TOOLCHAIN_WINDOWS + default MINERVA_TOOLCHAIN_GNU config MINERVA_TOOLCHAIN_BUILDROOT bool "Buildroot (Cygwin or Linux)" depends on !WINDOWS_NATIVE select ARCH_TOOLCHAIN_GNU -config MINERVA_TOOLCHAIN_GNUL - bool "Generic GNU toolchain under Linux (or other POSIX environment)" - select ARCH_TOOLCHAIN_GNU - ---help--- - This option should work for any modern GNU toolchain (GCC 4.5 or newer) - configured for risc64-elf-. - -config MINERVA_TOOLCHAIN_GNUW - bool "Generic GNU toolchain under Windows" - depends on TOOLCHAIN_WINDOWS - select CYGWIN_WINTOOL if WINDOWS_CYGWIN +config MINERVA_TOOLCHAIN_GNU + bool "Generic GNU toolchain" select ARCH_TOOLCHAIN_GNU ---help--- This option should work for any modern GNU toolchain (GCC 4.5 or newer) diff --git a/arch/misoc/src/minerva/Toolchain.defs b/arch/misoc/src/minerva/Toolchain.defs index a75c4468b2875..d5e4ed88d42e7 100644 --- a/arch/misoc/src/minerva/Toolchain.defs +++ b/arch/misoc/src/minerva/Toolchain.defs @@ -22,11 +22,29 @@ CROSSDEV = riscv32-unknown-elf- ARCHCPUFLAGS = -march=rv32i ifeq ($(CONFIG_DEBUG_CUSTOMOPT),y) - MAXOPTIMIZATION := $(CONFIG_DEBUG_OPTLEVEL) + ARCHOPTIMIZATION += $(CONFIG_DEBUG_OPTLEVEL) +else ifeq ($(CONFIG_DEBUG_FULLOPT),y) + ARCHOPTIMIZATION += -Os +endif + +ifneq ($(CONFIG_DEBUG_NOOPT),y) + ARCHOPTIMIZATION += -fno-strict-aliasing +endif + +ifeq ($(CONFIG_FRAME_POINTER),y) + ARCHOPTIMIZATION += -fno-omit-frame-pointer -fno-optimize-sibling-calls else - MAXOPTIMIZATION ?= -Os + ARCHOPTIMIZATION += -fomit-frame-pointer endif +ifeq ($(CONFIG_DEBUG_SYMBOLS),y) + LDFLAGS += -g + ARCHOPTIMIZATION += -g +endif + +ARCHCFLAGS += -fno-common +ARCHCXXFLAGS += -fno-common -nostdinc++ + # Default toolchain CC = $(CROSSDEV)gcc @@ -41,12 +59,12 @@ OBJDUMP = $(CROSSDEV)objdump # Add the builtin library -EXTRA_LIBS += ${wildcard ${shell $(CC) $(ARCHCPUFLAGS) --print-libgcc-file-name}} +EXTRA_LIBS += $(wildcard $(shell $(CC) $(ARCHCPUFLAGS) --print-libgcc-file-name)) ifneq ($(CONFIG_LIBM),y) - EXTRA_LIBS += ${wildcard ${shell $(CC) $(ARCHCPUFLAGS) --print-file-name=libm.a}} + EXTRA_LIBS += $(wildcard $(shell $(CC) $(ARCHCPUFLAGS) --print-file-name=libm.a)) endif ifeq ($(CONFIG_LIBSUPCXX),y) - EXTRA_LIBS += ${wildcard ${shell $(CC) $(ARCHCPUFLAGS) --print-file-name=libsupc++.a}} + EXTRA_LIBS += $(wildcard $(shell $(CC) $(ARCHCPUFLAGS) --print-file-name=libsupc++.a)) endif diff --git a/arch/misoc/src/minerva/minerva.h b/arch/misoc/src/minerva/minerva.h index ad17d2d36fa19..e310ccc783cc3 100644 --- a/arch/misoc/src/minerva/minerva.h +++ b/arch/misoc/src/minerva/minerva.h @@ -115,7 +115,7 @@ uint32_t *minerva_doirq(int irq, uint32_t * regs); /* Software interrupts ******************************************************/ -int minerva_swint(int irq, FAR void *context, FAR void *arg); +int minerva_swint(int irq, void *context, void *arg); /* Signal handling **********************************************************/ diff --git a/arch/misoc/src/minerva/minerva_allocateheap.c b/arch/misoc/src/minerva/minerva_allocateheap.c index b33040386fb87..433e8317e9eef 100644 --- a/arch/misoc/src/minerva/minerva_allocateheap.c +++ b/arch/misoc/src/minerva/minerva_allocateheap.c @@ -52,9 +52,9 @@ * ****************************************************************************/ -void up_allocate_heap(FAR void **heap_start, size_t * heap_size) +void up_allocate_heap(void **heap_start, size_t * heap_size) { board_autoled_on(LED_HEAPALLOCATE); - *heap_start = (FAR void *)g_idle_topstack; + *heap_start = (void *)g_idle_topstack; *heap_size = CONFIG_RAM_END - g_idle_topstack; } diff --git a/arch/misoc/src/minerva/minerva_assert.c b/arch/misoc/src/minerva/minerva_assert.c index 50553328309d5..3e713305a29b2 100644 --- a/arch/misoc/src/minerva/minerva_assert.c +++ b/arch/misoc/src/minerva/minerva_assert.c @@ -104,7 +104,7 @@ static void _up_assert(void) ****************************************************************************/ #ifdef CONFIG_ARCH_USBDUMP -static int usbtrace_syslog(FAR const char *fmt, ...) +static int usbtrace_syslog(const char *fmt, ...) { va_list ap; @@ -116,7 +116,7 @@ static int usbtrace_syslog(FAR const char *fmt, ...) return OK; } -static int assert_tracecallback(FAR struct usbtrace_s *trace, FAR void *arg) +static int assert_tracecallback(struct usbtrace_s *trace, void *arg) { usbtrace_trprintf(usbtrace_syslog, trace->event, trace->value); return 0; diff --git a/arch/misoc/src/minerva/minerva_blocktask.c b/arch/misoc/src/minerva/minerva_blocktask.c index 8390b00c2bfc6..6c6349af405be 100644 --- a/arch/misoc/src/minerva/minerva_blocktask.c +++ b/arch/misoc/src/minerva/minerva_blocktask.c @@ -136,15 +136,6 @@ void up_block_task(struct tcb_s *tcb, tstate_t task_state) struct tcb_s *nexttcb = this_task(); -#ifdef CONFIG_ARCH_ADDRENV - /* Make sure that the address environment for the previously - * running task is closed down gracefully (data caches dump, MMU - * flushed) and set up the address environment for the new thread - * at the head of the ready-to-run list. - */ - - group_addrenv(nexttcb); -#endif /* Reset scheduler parameters */ nxsched_resume_scheduler(nexttcb); diff --git a/arch/misoc/src/minerva/minerva_createstack.c b/arch/misoc/src/minerva/minerva_createstack.c index 6121fc07047e3..d92b57640ea72 100644 --- a/arch/misoc/src/minerva/minerva_createstack.c +++ b/arch/misoc/src/minerva/minerva_createstack.c @@ -79,7 +79,7 @@ * ****************************************************************************/ -int up_create_stack(FAR struct tcb_s *tcb, size_t stack_size, uint8_t ttype) +int up_create_stack(struct tcb_s *tcb, size_t stack_size, uint8_t ttype) { #ifdef CONFIG_TLS_ALIGNED /* The allocated stack size must not exceed the maximum possible for the diff --git a/arch/misoc/src/minerva/minerva_dumpstate.c b/arch/misoc/src/minerva/minerva_dumpstate.c index 7f90cb5d2f366..0750733b3d447 100644 --- a/arch/misoc/src/minerva/minerva_dumpstate.c +++ b/arch/misoc/src/minerva/minerva_dumpstate.c @@ -113,7 +113,7 @@ static inline void mineva_registerdump(void) void minerva_dumpstate(void) { - FAR struct tcb_s *rtcb = running_task(); + struct tcb_s *rtcb = running_task(); uint32_t sp = up_getsp(); uint32_t ustackbase; uint32_t ustacksize; diff --git a/arch/misoc/src/minerva/minerva_exit.c b/arch/misoc/src/minerva/minerva_exit.c index d888bb9189b9c..90fd7c61c4337 100644 --- a/arch/misoc/src/minerva/minerva_exit.c +++ b/arch/misoc/src/minerva/minerva_exit.c @@ -55,16 +55,16 @@ ****************************************************************************/ #ifdef CONFIG_DUMP_ON_EXIT -static void _up_dumponexit(FAR struct tcb_s *tcb, FAR void *arg) +static void _up_dumponexit(struct tcb_s *tcb, void *arg) { - FAR struct filelist *filelist; + struct filelist *filelist; int i; int j; sinfo(" TCB=%p name=%s pid=%d\n", tcb, tcb->name, tcb->pid); sinfo(" priority=%d state=%d\n", tcb->sched_priority, tcb->task_state); - filelist = tcb->group->tg_filelist; + filelist = &tcb->group->tg_filelist; for (i = 0; i < filelist->fl_rows; i++) { for (j = 0; j < CONFIG_NFILE_DESCRIPTORS_PER_BLOCK; j++) @@ -108,15 +108,15 @@ void up_exit(int status) sinfo("TCB=%p exiting\n", tcb); + /* Destroy the task at the head of the ready to run list. */ + + nxtask_exit(); + #ifdef CONFIG_DUMP_ON_EXIT sinfo("Other tasks:\n"); nxsched_foreach(_up_dumponexit, NULL); #endif - /* Destroy the task at the head of the ready to run list. */ - - nxtask_exit(); - /* Now, perform the context switch to the new ready-to-run task at the head * of the list. */ @@ -127,16 +127,6 @@ void up_exit(int status) nxsched_resume_scheduler(tcb); -#ifdef CONFIG_ARCH_ADDRENV - /* Make sure that the address environment for the previously running task - * is closed down gracefully (data caches dump, MMU flushed) and set up the - * address environment for the new thread at the head of the ready-to-run - * list. - */ - - group_addrenv(tcb); -#endif - /* Then switch contexts */ up_fullcontextrestore(tcb->xcp.regs); diff --git a/arch/misoc/src/minerva/minerva_releasepending.c b/arch/misoc/src/minerva/minerva_releasepending.c index 5623831c91839..56c1441a80c87 100644 --- a/arch/misoc/src/minerva/minerva_releasepending.c +++ b/arch/misoc/src/minerva/minerva_releasepending.c @@ -105,15 +105,6 @@ void up_release_pending(void) struct tcb_s *nexttcb = this_task(); -#ifdef CONFIG_ARCH_ADDRENV - /* Make sure that the address environment for the previously - * running task is closed down gracefully (data caches dump, MMU - * flushed) and set up the address environment for the new thread - * at the head of the ready-to-run list. - */ - - group_addrenv(nexttcb); -#endif /* Update scheduler parameters */ nxsched_resume_scheduler(nexttcb); diff --git a/arch/misoc/src/minerva/minerva_releasestack.c b/arch/misoc/src/minerva/minerva_releasestack.c index d43f76efc4263..e99d8c143e445 100644 --- a/arch/misoc/src/minerva/minerva_releasestack.c +++ b/arch/misoc/src/minerva/minerva_releasestack.c @@ -67,7 +67,7 @@ * ****************************************************************************/ -void up_release_stack(FAR struct tcb_s *dtcb, uint8_t ttype) +void up_release_stack(struct tcb_s *dtcb, uint8_t ttype) { /* Is there a stack allocated? */ diff --git a/arch/misoc/src/minerva/minerva_reprioritizertr.c b/arch/misoc/src/minerva/minerva_reprioritizertr.c index fcd1b0d3ab160..00edf65419425 100644 --- a/arch/misoc/src/minerva/minerva_reprioritizertr.c +++ b/arch/misoc/src/minerva/minerva_reprioritizertr.c @@ -158,15 +158,6 @@ void up_reprioritize_rtr(struct tcb_s *tcb, uint8_t priority) struct tcb_s *nexttcb = this_task(); -#ifdef CONFIG_ARCH_ADDRENV - /* Make sure that the address environment for the previously - * running task is closed down gracefully (data caches dump, - * MMU flushed) and set up the address environment for the - * new thread at the head of the ready-to-run list. - */ - - group_addrenv(nexttcb); -#endif /* Update scheduler parameters */ nxsched_resume_scheduler(nexttcb); diff --git a/arch/misoc/src/minerva/minerva_stackframe.c b/arch/misoc/src/minerva/minerva_stackframe.c index f11472fec74e0..dc379a305fa94 100644 --- a/arch/misoc/src/minerva/minerva_stackframe.c +++ b/arch/misoc/src/minerva/minerva_stackframe.c @@ -68,9 +68,9 @@ * ****************************************************************************/ -FAR void *up_stack_frame(FAR struct tcb_s *tcb, size_t frame_size) +void *up_stack_frame(struct tcb_s *tcb, size_t frame_size) { - FAR void *ret; + void *ret; /* Align the frame_size */ @@ -88,7 +88,7 @@ FAR void *up_stack_frame(FAR struct tcb_s *tcb, size_t frame_size) /* Save the adjusted stack values in the struct tcb_s */ - tcb->stack_base_ptr = (FAR uint8_t *)tcb->stack_base_ptr + frame_size; + tcb->stack_base_ptr = (uint8_t *)tcb->stack_base_ptr + frame_size; tcb->adj_stack_size -= frame_size; /* And return the pointer to the allocated region */ diff --git a/arch/misoc/src/minerva/minerva_swint.c b/arch/misoc/src/minerva/minerva_swint.c index d6c5b19ae490d..4b4b2f071142b 100644 --- a/arch/misoc/src/minerva/minerva_swint.c +++ b/arch/misoc/src/minerva/minerva_swint.c @@ -124,7 +124,7 @@ static void dispatch_syscall(void) naked_function; * ****************************************************************************/ -int minerva_swint(int irq, FAR void *context, FAR void *arg) +int minerva_swint(int irq, void *context, void *arg) { uint32_t *regs = (uint32_t *) context; @@ -220,7 +220,7 @@ int minerva_swint(int irq, FAR void *context, FAR void *arg) default: { #ifdef CONFIG_BUILD_KERNEL - FAR struct tcb_s *rtcb = nxsched_self(); + struct tcb_s *rtcb = nxsched_self(); int index = rtcb->xcp.nsyscalls; /* Verify that the SYS call number is within range */ @@ -273,33 +273,5 @@ int minerva_swint(int irq, FAR void *context, FAR void *arg) } #endif -#if defined(CONFIG_ARCH_FPU) || defined(CONFIG_ARCH_ADDRENV) - /* Check for a context switch. If a context switch occurred, then - * g_current_regs will have a different value than it did on entry. If an - * interrupt level context switch has occurred, then restore the floating - * point state and the establish the correct address environment before - * returning from the interrupt. - */ - - if (regs != g_current_regs) - { -#ifdef CONFIG_ARCH_FPU - /* Restore floating point registers */ - - up_restorefpu((uint32_t *) g_current_regs); -#endif - -#ifdef CONFIG_ARCH_ADDRENV - /* Make sure that the address environment for the previously running - * task is closed down gracefully (data caches dump, MMU flushed) and - * set up the address environment for the new thread at the head of - * the ready-to-run list. - */ - - group_addrenv(NULL); -#endif - } -#endif - return OK; } diff --git a/arch/misoc/src/minerva/minerva_unblocktask.c b/arch/misoc/src/minerva/minerva_unblocktask.c index 44916489c6859..69c4e0a340db0 100644 --- a/arch/misoc/src/minerva/minerva_unblocktask.c +++ b/arch/misoc/src/minerva/minerva_unblocktask.c @@ -122,15 +122,6 @@ void up_unblock_task(struct tcb_s *tcb) struct tcb_s *nexttcb = this_task(); -#ifdef CONFIG_ARCH_ADDRENV - /* Make sure that the address environment for the previously - * running task is closed down gracefully (data caches dump, MMU - * flushed) and set up the address environment for the new thread - * at the head of the ready-to-run list. - */ - - group_addrenv(nexttcb); -#endif /* Update scheduler parameters */ nxsched_resume_scheduler(nexttcb); diff --git a/arch/or1k/include/arch.h b/arch/or1k/include/arch.h index c98c4bf58ff08..f27eaf522d2b1 100644 --- a/arch/or1k/include/arch.h +++ b/arch/or1k/include/arch.h @@ -106,12 +106,12 @@ struct group_addrenv_s { /* Level 1 page table entries for each group section */ - FAR uintptr_t *text[ARCH_TEXT_NSECTS]; - FAR uintptr_t *data[ARCH_DATA_NSECTS]; + uintptr_t *text[ARCH_TEXT_NSECTS]; + uintptr_t *data[ARCH_DATA_NSECTS]; #ifdef CONFIG_BUILD_KERNEL - FAR uintptr_t *heap[ARCH_HEAP_NSECTS]; + uintptr_t *heap[ARCH_HEAP_NSECTS]; #ifdef CONFIG_MM_SHM - FAR uintptr_t *shm[ARCH_SHM_NSECTS]; + uintptr_t *shm[ARCH_SHM_NSECTS]; #endif /* Initial heap allocation (in bytes). This exists only provide an @@ -137,12 +137,12 @@ typedef struct group_addrenv_s group_addrenv_t; struct save_addrenv_s { - FAR uint32_t text[ARCH_TEXT_NSECTS]; - FAR uint32_t data[ARCH_DATA_NSECTS]; + uint32_t text[ARCH_TEXT_NSECTS]; + uint32_t data[ARCH_DATA_NSECTS]; #ifdef CONFIG_BUILD_KERNEL - FAR uint32_t heap[ARCH_HEAP_NSECTS]; + uint32_t heap[ARCH_HEAP_NSECTS]; #ifdef CONFIG_MM_SHM - FAR uint32_t shm[ARCH_SHM_NSECTS]; + uint32_t shm[ARCH_SHM_NSECTS]; #endif #endif }; diff --git a/arch/or1k/src/common/up_allocateheap.c b/arch/or1k/src/common/up_allocateheap.c index c501967ef11e0..52b316d019453 100644 --- a/arch/or1k/src/common/up_allocateheap.c +++ b/arch/or1k/src/common/up_allocateheap.c @@ -97,9 +97,9 @@ ****************************************************************************/ #ifdef CONFIG_BUILD_KERNEL -void up_allocate_kheap(FAR void **heap_start, size_t *heap_size) +void up_allocate_kheap(void **heap_start, size_t *heap_size) #else -void up_allocate_heap(FAR void **heap_start, size_t *heap_size) +void up_allocate_heap(void **heap_start, size_t *heap_size) #endif { #if defined(CONFIG_BUILD_PROTECTED) && defined(CONFIG_MM_KERNEL_HEAP) @@ -117,13 +117,13 @@ void up_allocate_heap(FAR void **heap_start, size_t *heap_size) /* Return the user-space heap settings */ board_autoled_on(LED_HEAPALLOCATE); - *heap_start = (FAR void *)ubase; + *heap_start = (void *)ubase; *heap_size = usize; #else /* Return the heap settings */ - *heap_start = (FAR void *)g_idle_topstack; + *heap_start = (void *)g_idle_topstack; *heap_size = CONFIG_RAM_END - *(uint32_t *)heap_start; board_autoled_on(LED_HEAPALLOCATE); @@ -142,7 +142,7 @@ void up_allocate_heap(FAR void **heap_start, size_t *heap_size) ****************************************************************************/ #if defined(CONFIG_BUILD_PROTECTED) && defined(CONFIG_MM_KERNEL_HEAP) -void up_allocate_kheap(FAR void **heap_start, size_t *heap_size) +void up_allocate_kheap(void **heap_start, size_t *heap_size) { /* Get the unaligned size and position of the user-space heap. * This heap begins after the user-space .bss section at an offset @@ -157,7 +157,7 @@ void up_allocate_kheap(FAR void **heap_start, size_t *heap_size) * that was not dedicated to the user heap). */ - *heap_start = (FAR void *)USERSPACE->us_bssend; + *heap_start = (void *)USERSPACE->us_bssend; *heap_size = ubase - (uintptr_t)USERSPACE->us_bssend; } #endif diff --git a/arch/or1k/src/common/up_assert.c b/arch/or1k/src/common/up_assert.c index 9f016407e1a11..c7d3865b19c16 100644 --- a/arch/or1k/src/common/up_assert.c +++ b/arch/or1k/src/common/up_assert.c @@ -94,7 +94,7 @@ static void or1k_stackdump(uint32_t sp, uint32_t stack_top) ****************************************************************************/ #ifdef CONFIG_STACK_COLORATION -static void up_taskdump(FAR struct tcb_s *tcb, FAR void *arg) +static void up_taskdump(struct tcb_s *tcb, void *arg) { /* Dump interesting properties of this task */ @@ -167,7 +167,7 @@ static inline void or1k_registerdump(void) ****************************************************************************/ #ifdef CONFIG_ARCH_USBDUMP -static int usbtrace_syslog(FAR const char *fmt, ...) +static int usbtrace_syslog(const char *fmt, ...) { va_list ap; int ret; @@ -180,7 +180,7 @@ static int usbtrace_syslog(FAR const char *fmt, ...) return ret; } -static int assert_tracecallback(FAR struct usbtrace_s *trace, FAR void *arg) +static int assert_tracecallback(struct usbtrace_s *trace, void *arg) { usbtrace_trprintf(usbtrace_syslog, trace->event, trace->value); return 0; @@ -194,7 +194,7 @@ static int assert_tracecallback(FAR struct usbtrace_s *trace, FAR void *arg) #ifdef CONFIG_ARCH_STACKDUMP static void up_dumpstate(void) { - FAR struct tcb_s *rtcb = running_task(); + struct tcb_s *rtcb = running_task(); uint32_t sp = up_getsp(); uint32_t ustackbase; uint32_t ustacksize; diff --git a/arch/or1k/src/common/up_checkstack.c b/arch/or1k/src/common/up_checkstack.c index 2562ae5359a3e..7bd4ba14ee0af 100644 --- a/arch/or1k/src/common/up_checkstack.c +++ b/arch/or1k/src/common/up_checkstack.c @@ -67,9 +67,9 @@ static size_t do_stackcheck(uintptr_t alloc, size_t size); static size_t do_stackcheck(uintptr_t alloc, size_t size) { - FAR uintptr_t start; - FAR uintptr_t end; - FAR uint32_t *ptr; + uintptr_t start; + uintptr_t end; + uint32_t *ptr; size_t mark; if (size == 0) @@ -86,7 +86,7 @@ static size_t do_stackcheck(uintptr_t alloc, size_t size) size = end - start; - for (ptr = (FAR uint32_t *)start, mark = (size >> 2); + for (ptr = (uint32_t *)start, mark = (size >> 2); *ptr == STACK_COLOR && mark > 0; ptr++, mark--); @@ -115,12 +115,12 @@ static size_t do_stackcheck(uintptr_t alloc, size_t size) * ****************************************************************************/ -size_t up_check_tcbstack(FAR struct tcb_s *tcb) +size_t up_check_tcbstack(struct tcb_s *tcb) { return do_stackcheck((uintptr_t)tcb->stack_base_ptr, tcb->adj_stack_size); } -ssize_t up_check_tcbstack_remain(FAR struct tcb_s *tcb) +ssize_t up_check_tcbstack_remain(struct tcb_s *tcb) { return tcb->adj_stack_size - up_check_tcbstack(tcb); } diff --git a/arch/or1k/src/common/up_createstack.c b/arch/or1k/src/common/up_createstack.c index b65531b760c9b..5c12822807477 100644 --- a/arch/or1k/src/common/up_createstack.c +++ b/arch/or1k/src/common/up_createstack.c @@ -81,7 +81,7 @@ * ****************************************************************************/ -int up_create_stack(FAR struct tcb_s *tcb, size_t stack_size, uint8_t ttype) +int up_create_stack(struct tcb_s *tcb, size_t stack_size, uint8_t ttype) { #ifdef CONFIG_TLS_ALIGNED /* The allocated stack size must not exceed the maximum possible for the @@ -201,14 +201,32 @@ int up_create_stack(FAR struct tcb_s *tcb, size_t stack_size, uint8_t ttype) ****************************************************************************/ #ifdef CONFIG_STACK_COLORATION -void up_stack_color(FAR void *stackbase, size_t nbytes) +void up_stack_color(void *stackbase, size_t nbytes) { - /* Take extra care that we do not write outsize the stack boundaries */ + uint32_t *stkptr; + uintptr_t stkend; + size_t nwords; + uintptr_t sp; - uint32_t *stkptr = (uint32_t *)(((uintptr_t)stackbase + 3) & ~3); - uintptr_t stkend = nbytes ? (((uintptr_t)stackbase + nbytes) & ~3) : - up_getsp(); /* 0: colorize the running stack */ - size_t nwords = (stkend - (uintptr_t)stackbase) >> 2; + /* Take extra care that we do not write outside the stack boundaries */ + + stkptr = (uint32_t *)STACK_ALIGN_UP((uintptr_t)stackbase); + + if (nbytes == 0) /* 0: colorize the running stack */ + { + stkend = up_getsp(); + if (stkend > (uintptr_t)&sp) + { + stkend = (uintptr_t)&sp; + } + } + else + { + stkend = (uintptr_t)stackbase + nbytes; + } + + stkend = STACK_ALIGN_DOWN(stkend); + nwords = (stkend - (uintptr_t)stackbase) >> 2; /* Set the entire stack to the coloration value */ diff --git a/arch/or1k/src/common/up_exit.c b/arch/or1k/src/common/up_exit.c index a303c65115ea8..05fa24e10e737 100644 --- a/arch/or1k/src/common/up_exit.c +++ b/arch/or1k/src/common/up_exit.c @@ -62,16 +62,16 @@ ****************************************************************************/ #ifdef CONFIG_DUMP_ON_EXIT -static void _up_dumponexit(FAR struct tcb_s *tcb, FAR void *arg) +static void _up_dumponexit(struct tcb_s *tcb, void *arg) { - FAR struct filelist *filelist; + struct filelist *filelist; int i; int j; sinfo(" TCB=%p name=%s pid=%d\n", tcb, tcb->name, tcb->pid); sinfo(" priority=%d state=%d\n", tcb->sched_priority, tcb->task_state); - filelist = tcb->group->tg_filelist; + filelist = &tcb->group->tg_filelist; for (i = 0; i < filelist->fl_rows; i++) { for (j = 0; j < CONFIG_NFILE_DESCRIPTORS_PER_BLOCK; j++) @@ -115,15 +115,15 @@ void up_exit(int status) sinfo("TCB=%p exiting\n", tcb); + /* Destroy the task at the head of the ready to run list. */ + + nxtask_exit(); + #ifdef CONFIG_DUMP_ON_EXIT sinfo("Other tasks:\n"); nxsched_foreach(_up_dumponexit, NULL); #endif - /* Destroy the task at the head of the ready to run list. */ - - nxtask_exit(); - /* Now, perform the context switch to the new ready-to-run task at the * head of the list. */ diff --git a/arch/or1k/src/common/up_internal.h b/arch/or1k/src/common/up_internal.h index 01f18e5091812..9ccf6376e050e 100644 --- a/arch/or1k/src/common/up_internal.h +++ b/arch/or1k/src/common/up_internal.h @@ -240,7 +240,6 @@ int or1k_print_cpuinfo(void); void up_copyfullstate(uint32_t *dest, uint32_t *src); void up_decodeirq(uint32_t *regs); -int up_saveusercontext(uint32_t *saveregs); void up_fullcontextrestore(uint32_t *restoreregs) noreturn_function; void up_switchcontext(uint32_t *saveregs, uint32_t *restoreregs); @@ -267,8 +266,8 @@ uint32_t *up_doirq(int irq, uint32_t *regs); /* Exception Handlers */ -int up_hardfault(int irq, FAR void *context, FAR void *arg); -int up_memfault(int irq, FAR void *context, FAR void *arg); +int up_hardfault(int irq, void *context, void *arg); +int up_memfault(int irq, void *context, void *arg); /* Interrupt acknowledge and dispatch */ @@ -343,7 +342,7 @@ void up_usbuninitialize(void); /* Debug ********************************************************************/ #ifdef CONFIG_STACK_COLORATION -void up_stack_color(FAR void *stackbase, size_t nbytes); +void up_stack_color(void *stackbase, size_t nbytes); #endif #undef EXTERN diff --git a/arch/or1k/src/common/up_releasestack.c b/arch/or1k/src/common/up_releasestack.c index ba85410f8c3a3..eaad0c1461fb8 100644 --- a/arch/or1k/src/common/up_releasestack.c +++ b/arch/or1k/src/common/up_releasestack.c @@ -71,7 +71,7 @@ * ****************************************************************************/ -void up_release_stack(FAR struct tcb_s *dtcb, uint8_t ttype) +void up_release_stack(struct tcb_s *dtcb, uint8_t ttype) { /* Is there a stack allocated? */ diff --git a/arch/or1k/src/common/up_stackframe.c b/arch/or1k/src/common/up_stackframe.c index 13dbff8ec1023..c848de353d3e3 100644 --- a/arch/or1k/src/common/up_stackframe.c +++ b/arch/or1k/src/common/up_stackframe.c @@ -69,9 +69,9 @@ * ****************************************************************************/ -FAR void *up_stack_frame(FAR struct tcb_s *tcb, size_t frame_size) +void *up_stack_frame(struct tcb_s *tcb, size_t frame_size) { - FAR void *ret; + void *ret; /* Align the frame_size */ @@ -89,7 +89,7 @@ FAR void *up_stack_frame(FAR struct tcb_s *tcb, size_t frame_size) /* Save the adjusted stack values in the struct tcb_s */ - tcb->stack_base_ptr = (FAR uint8_t *)tcb->stack_base_ptr + frame_size; + tcb->stack_base_ptr = (uint8_t *)tcb->stack_base_ptr + frame_size; tcb->adj_stack_size -= frame_size; /* And return the pointer to the allocated region */ diff --git a/arch/or1k/src/common/up_task_start.c b/arch/or1k/src/common/up_task_start.c index 6e5149decb0be..b57064803df9d 100644 --- a/arch/or1k/src/common/up_task_start.c +++ b/arch/or1k/src/common/up_task_start.c @@ -61,7 +61,7 @@ * ****************************************************************************/ -void up_task_start(main_t taskentry, int argc, FAR char *argv[]) +void up_task_start(main_t taskentry, int argc, char *argv[]) { /* Let sys_call3() do all of the work */ diff --git a/arch/or1k/src/mor1kx/Toolchain.defs b/arch/or1k/src/mor1kx/Toolchain.defs index 43320d7a09437..28906ef6631fd 100644 --- a/arch/or1k/src/mor1kx/Toolchain.defs +++ b/arch/or1k/src/mor1kx/Toolchain.defs @@ -28,14 +28,40 @@ # CROSSDEV The GNU toolchain triple (command prefix) # ARCHCPUFLAGS CPU-specific flags selecting the instruction set # FPU options, etc. -# MAXOPTIMIZATION The maximum optimization level that results in +# ARCHOPTIMIZATION The optimization level that results in # reliable code generation. # ifeq ($(CONFIG_DEBUG_CUSTOMOPT),y) - MAXOPTIMIZATION := $(CONFIG_DEBUG_OPTLEVEL) + ARCHOPTIMIZATION += $(CONFIG_DEBUG_OPTLEVEL) +else ifeq ($(CONFIG_DEBUG_FULLOPT),y) + ARCHOPTIMIZATION += -O2 +endif + +ifneq ($(CONFIG_DEBUG_NOOPT),y) + ARCHOPTIMIZATION += -fno-strict-aliasing +endif + +ifeq ($(CONFIG_FRAME_POINTER),y) + ARCHOPTIMIZATION += -fno-omit-frame-pointer -fno-optimize-sibling-calls else - MAXOPTIMIZATION ?= -O2 + ARCHOPTIMIZATION += -fomit-frame-pointer +endif + +ifeq ($(CONFIG_DEBUG_SYMBOLS),y) + LDFLAGS += -g + ARCHOPTIMIZATION += -g +endif + +ARCHCFLAGS += -fno-common +ARCHCXXFLAGS += -fno-common -nostdinc++ + +ifneq ($(CONFIG_CXX_EXCEPTION),y) + ARCHCXXFLAGS += -fno-exceptions -fcheck-new +endif + +ifneq ($(CONFIG_CXX_RTTI),y) + ARCHCXXFLAGS += -fno-rtti endif # Pick correct or1k architecture selection @@ -68,12 +94,12 @@ OBJDUMP = $(CROSSDEV)objdump # Add the builtin library -EXTRA_LIBS += ${wildcard ${shell $(CC) $(ARCHCPUFLAGS) --print-libgcc-file-name}} +EXTRA_LIBS += $(wildcard $(shell $(CC) $(ARCHCPUFLAGS) --print-libgcc-file-name)) ifneq ($(CONFIG_LIBM),y) - EXTRA_LIBS += ${wildcard ${shell $(CC) $(ARCHCPUFLAGS) --print-file-name=libm.a}} + EXTRA_LIBS += $(wildcard $(shell $(CC) $(ARCHCPUFLAGS) --print-file-name=libm.a)) endif ifeq ($(CONFIG_LIBSUPCXX),y) - EXTRA_LIBS += ${wildcard ${shell $(CC) $(ARCHCPUFLAGS) --print-file-name=libsupc++.a}} + EXTRA_LIBS += $(wildcard $(shell $(CC) $(ARCHCPUFLAGS) --print-file-name=libsupc++.a)) endif diff --git a/arch/or1k/src/mor1kx/hardware/irq.h b/arch/or1k/src/mor1kx/hardware/irq.h deleted file mode 100644 index 8b137891791fe..0000000000000 --- a/arch/or1k/src/mor1kx/hardware/irq.h +++ /dev/null @@ -1 +0,0 @@ - diff --git a/arch/renesas/src/common/up_exit.c b/arch/renesas/src/common/up_exit.c index dcdcde3b71884..6d78ba4dccde8 100644 --- a/arch/renesas/src/common/up_exit.c +++ b/arch/renesas/src/common/up_exit.c @@ -70,7 +70,7 @@ static void _up_dumponexit(FAR struct tcb_s *tcb, FAR void *arg) sinfo(" TCB=%p name=%s\n", tcb, tcb->name); sinfo(" priority=%d state=%d\n", tcb->sched_priority, tcb->task_state); - filelist = tcb->group->tg_filelist; + filelist = &tcb->group->tg_filelist; for (i = 0; i < filelist->fl_rows; i++) { for (j = 0; j < CONFIG_NFILE_DESCRIPTORS_PER_BLOCK; j++) @@ -114,15 +114,15 @@ void up_exit(int status) sinfo("TCB=%p exiting\n", tcb); + /* Destroy the task at the head of the ready to run list. */ + + nxtask_exit(); + #ifdef CONFIG_DUMP_ON_EXIT sinfo("Other tasks:\n"); nxsched_foreach(_up_dumponexit, NULL); #endif - /* Destroy the task at the head of the ready to run list. */ - - nxtask_exit(); - /* Now, perform the context switch to the new ready-to-run task at the * head of the list. */ diff --git a/arch/renesas/src/common/up_internal.h b/arch/renesas/src/common/up_internal.h index d18741a6423ca..91e6c63a4e775 100644 --- a/arch/renesas/src/common/up_internal.h +++ b/arch/renesas/src/common/up_internal.h @@ -143,7 +143,6 @@ void up_decodeirq(uint32_t *regs); uint32_t *up_doirq(int irq, uint32_t *regs); void up_fullcontextrestore(uint32_t *regs) noreturn_function; void up_prefetchabort(uint32_t *regs); -int up_saveusercontext(uint32_t *regs); void up_sigdeliver(void); void up_syscall(uint32_t *regs); void up_undefinedinsn(uint32_t *regs); diff --git a/arch/renesas/src/m16c/m16c_vectors.S b/arch/renesas/src/m16c/m16c_vectors.S index 72546c607306d..d1f3f926a4b40 100644 --- a/arch/renesas/src/m16c/m16c_vectors.S +++ b/arch/renesas/src/m16c/m16c_vectors.S @@ -374,7 +374,7 @@ _m16c_commonvector: reit /* Return from interrupt */ /************************************************************************************ - * Name: int up_saveusercontext(uint32_t *regs) + * Name: int up_saveusercontext(void *regs) * * Description: * Save the context of the calling function at the point of the return from the diff --git a/arch/renesas/src/rx65n/rx65n_riic.c b/arch/renesas/src/rx65n/rx65n_riic.c index 6baff6cb72eeb..03362993164c8 100644 --- a/arch/renesas/src/rx65n/rx65n_riic.c +++ b/arch/renesas/src/rx65n/rx65n_riic.c @@ -2008,7 +2008,7 @@ static void rx65n_riic_pre_end_set(FAR struct rx65n_i2c_priv_s *priv) RIIC0.ICMR3.BIT.ACKBT = 1; RIIC0.ICMR3.BIT.ACKWP = 0; - (void)rx65n_getreg(RX65N_RIIC0_ICMR3); + rx65n_getreg(RX65N_RIIC0_ICMR3); } else if (1 == priv->bus) @@ -2020,7 +2020,7 @@ static void rx65n_riic_pre_end_set(FAR struct rx65n_i2c_priv_s *priv) RIIC1.ICMR3.BIT.ACKBT = 1; RIIC1.ICMR3.BIT.ACKWP = 0; - (void)rx65n_getreg(RX65N_RIIC1_ICMR3); + rx65n_getreg(RX65N_RIIC1_ICMR3); } else @@ -2032,7 +2032,7 @@ static void rx65n_riic_pre_end_set(FAR struct rx65n_i2c_priv_s *priv) RIIC2.ICMR3.BIT.ACKBT = 1; RIIC2.ICMR3.BIT.ACKWP = 0; - (void)rx65n_getreg(RX65N_RIIC2_ICMR3); + rx65n_getreg(RX65N_RIIC2_ICMR3); } } diff --git a/arch/renesas/src/rx65n/rx65n_rtc.c b/arch/renesas/src/rx65n/rx65n_rtc.c index 7f000609c601c..2f7db40e07785 100644 --- a/arch/renesas/src/rx65n/rx65n_rtc.c +++ b/arch/renesas/src/rx65n/rx65n_rtc.c @@ -553,7 +553,7 @@ int rx65n_rtc_setdatetime(FAR const struct tm *tp) * seconds) */ - /* (void)gmtime_r(&tp->tv_sec, &tp); */ + /* gmtime_r(&tp->tv_sec, &tp); */ rtc_dumptime(&tp, "Setting time"); @@ -706,7 +706,7 @@ int up_rtc_settime(FAR const struct timespec *tp) * seconds) */ - (void)gmtime_r(&tp->tv_sec, &newtime); + gmtime_r(&tp->tv_sec, &newtime); rtc_dumptime(&newtime, "Setting time"); /* Then write the broken out values to the RTC */ diff --git a/arch/renesas/src/rx65n/rx65n_rtc_lowerhalf.c b/arch/renesas/src/rx65n/rx65n_rtc_lowerhalf.c index cab2a382a7c6f..3f3d44604ab94 100644 --- a/arch/renesas/src/rx65n/rx65n_rtc_lowerhalf.c +++ b/arch/renesas/src/rx65n/rx65n_rtc_lowerhalf.c @@ -467,7 +467,7 @@ static int rx65n_setrelative(FAR struct rtc_lowerhalf_s *lower, /* And convert the time back to broken out format */ - (void)gmtime_r(&seconds, (FAR struct tm *)&setalarm.time); + gmtime_r(&seconds, (FAR struct tm *)&setalarm.time); /* The set the alarm using this absolute time */ diff --git a/arch/renesas/src/rx65n/rx65n_sbram.c b/arch/renesas/src/rx65n/rx65n_sbram.c index a8c62235dd2a6..f47887ef9900d 100644 --- a/arch/renesas/src/rx65n/rx65n_sbram.c +++ b/arch/renesas/src/rx65n/rx65n_sbram.c @@ -135,7 +135,7 @@ static const struct file_operations rx65n_sbram_fops = .ioctl = rx65n_sbram_ioctl, .poll = rx65n_sbram_poll, #ifndef CONFIG_DISABLE_PSEUDOFS_OPERATIONS - .unlink = rx65n_sbram_unlink, + .unlink = rx65n_sbram_unlink #endif }; @@ -278,7 +278,7 @@ static int rx65n_sbram_open(FAR struct file *filep) static int rx65n_sbram_internal_close(FAR struct sbramfh_s *bbf) { bbf->dirty = 0; - (void)clock_gettime(CLOCK_REALTIME, &bbf->lastwrite); + clock_gettime(CLOCK_REALTIME, &bbf->lastwrite); bbf->crc = rx65n_sbram_crc(bbf); SBRAM_DUMP(bbf, "close done"); diff --git a/arch/renesas/src/rx65n/rx65n_usbhost.c b/arch/renesas/src/rx65n/rx65n_usbhost.c index a7976b9307cc0..367a60c55d52e 100644 --- a/arch/renesas/src/rx65n/rx65n_usbhost.c +++ b/arch/renesas/src/rx65n/rx65n_usbhost.c @@ -3925,7 +3925,7 @@ static uint16_t usb_cstd_is_set_frdy (uint16_t pipe, uint16_t fifosel, buffer = hw_usb_read_syscfg(); buffer = hw_usb_read_syssts(); - (void)nxsig_usleep(1); + nxsig_usleep(1); } return (RX65N_USB_FIFO_ERROR); @@ -6322,7 +6322,7 @@ static void rx65n_usbhost_bottomhalf (void *arg) else { - (void)nxsig_usleep(100); + nxsig_usleep(100); uwarn("WARNING: un known bottomhalf. Value is %d\n", bottom_half_processing); syslog (LOG_INFO, "WARNING: un known bottomhalf. Value is %d\n", @@ -6480,13 +6480,13 @@ static int rx65n_usbhost_rh_enumerate(struct usbhost_connection_s *conn, /* USB 2.0 spec says at least 50ms delay before port reset */ - (void)nxsig_usleep(100 * 1000); + nxsig_usleep(100 * 1000); /* Put RH port 1 in reset. * Currently supporting only single downstream port) */ - (void)nxsig_usleep(200 * 1000); + nxsig_usleep(200 * 1000); return OK; } diff --git a/arch/renesas/src/rx65n/rx65n_vector.S b/arch/renesas/src/rx65n/rx65n_vector.S index 0eff9d9fc4a70..5f7d7e9e7f94d 100644 --- a/arch/renesas/src/rx65n/rx65n_vector.S +++ b/arch/renesas/src/rx65n/rx65n_vector.S @@ -218,7 +218,7 @@ _up_vector: .size _up_vector, . - _up_vector /**************************************************************************** - * Name: int up_saveusercontext(uint32_t *regs) + * Name: int up_saveusercontext(void *regs) * * Description: * Save the context of the calling function at the point of the return from diff --git a/arch/risc-v/Kconfig b/arch/risc-v/Kconfig index b199d393e9691..43d28a97879fd 100644 --- a/arch/risc-v/Kconfig +++ b/arch/risc-v/Kconfig @@ -16,6 +16,8 @@ config ARCH_CHIP_FE310 select ARCH_RV_ISA_M select ARCH_RV_ISA_A select ARCH_RV_ISA_C + select ONESHOT + select ALARM_ARCH ---help--- SiFive FE310 processor (E31 RISC-V Core with MAC extensions). @@ -25,9 +27,14 @@ config ARCH_CHIP_K210 select ARCH_RV_ISA_M select ARCH_RV_ISA_A select ARCH_RV_ISA_C + select ARCH_HAVE_FPU if !K210_WITH_QEMU + select ARCH_HAVE_DPFPU if !K210_WITH_QEMU select ARCH_HAVE_MPU select ARCH_HAVE_TESTSET select ARCH_HAVE_MULTICPU + select ARCH_HAVE_MISALIGN_EXCEPTION + select ONESHOT + select ALARM_ARCH ---help--- Kendryte K210 processor (RISC-V 64bit core with GC extensions) @@ -36,6 +43,7 @@ config ARCH_CHIP_LITEX select ARCH_RV32 select ARCH_RV_ISA_M select ARCH_RV_ISA_A + select ARCH_DCACHE ---help--- Enjoy Digital LITEX VEXRISCV softcore processor (RV32IMA). @@ -47,6 +55,9 @@ config ARCH_CHIP_BL602 select ARCH_RV_ISA_C select ARCH_HAVE_FPU select ARCH_HAVE_RESET + select ARCH_HAVE_MISALIGN_EXCEPTION + select ONESHOT + select ALARM_ARCH ---help--- BouffaloLab BL602(rv32imfc) @@ -84,6 +95,8 @@ config ARCH_CHIP_C906 select ARCH_HAVE_FPU select ARCH_HAVE_DPFPU select ARCH_HAVE_MPU + select ONESHOT + select ALARM_ARCH ---help--- THEAD C906 processor (RISC-V 64bit core with GCVX extensions). @@ -98,10 +111,15 @@ config ARCH_CHIP_MPFS select ARCH_HAVE_MPU select ARCH_HAVE_MMU select ARCH_MMU_TYPE_SV39 + select ARCH_HAVE_ADDRENV + select ARCH_NEED_ADDRENV_MAPPING select ARCH_HAVE_RESET select ARCH_HAVE_SPI_CS_CONTROL select ARCH_HAVE_PWM_MULTICHAN + select ARCH_HAVE_S_MODE select PMP_HAS_LIMITED_FEATURES + select ONESHOT + select ALARM_ARCH ---help--- MicroChip Polarfire processor (RISC-V 64bit core with GCVX extensions). @@ -118,6 +136,8 @@ config ARCH_CHIP_QEMU_RV select ARCH_HAVE_FPU select ARCH_HAVE_DPFPU select ARCH_HAVE_MULTICPU + select ONESHOT + select ALARM_ARCH ---help--- QEMU Generic RV32/RV64 processor @@ -188,6 +208,38 @@ config ARCH_MMU_TYPE_SV39 bool default n +config ARCH_HAVE_S_MODE + bool + default n + +config ARCH_HAVE_MISALIGN_EXCEPTION + bool + default n + ---help--- + The chip will raise a exception while misaligned memory access. + +config RISCV_MISALIGNED_HANDLER + bool "Software misaligned memory access handler" + depends on ARCH_HAVE_MISALIGN_EXCEPTION + default y + +# Option to run NuttX in supervisor mode. This is obviously not usable in +# flat mode, is questionable in protected mode, but is mandatory in kernel +# mode. +# +# Kernel mode requires this as M-mode uses flat addressing and the kernel +# memory must be mapped in order to share memory between the kernel and +# different user tasks which reside in virtual memory. + +config ARCH_USE_S_MODE + bool "Run the NuttX kernel in S-mode" + default n + depends on ARCH_HAVE_S_MODE && BUILD_KERNEL && ARCH_USE_MMU + ---help--- + Most of the RISC-V implementations run in M-mode (flat addressing) + and/or U-mode (in case of separate kernel-/userspaces). This provides + an option to run the kernel in S-mode, if the target supports it. + # MPU has certain architecture dependent configurations, which are presented # here. Default is that the full RISC-V PMP specification is supported. @@ -211,8 +263,39 @@ config ARCH_MPU_HAS_NAPOT bool "PMP supports NAPOT" default y if !PMP_HAS_LIMITED_FEATURES +choice + prompt "Toolchain Selection" + default RISCV_TOOLCHAIN_GNU_RVG + +config RISCV_TOOLCHAIN_GNU_RVG + bool "Generic GNU RVG toolchain" + select ARCH_TOOLCHAIN_GNU + ---help--- + This option should work for any modern GNU toolchain (GCC 5.2 or newer) + configured for riscv64-unknown-elf. + +endchoice + +config RISCV_SEMIHOSTING_HOSTFS + bool "Semihosting HostFS" + depends on FS_HOSTFS + ---help--- + Mount HostFS through semihosting. + + This doesn't support some directory operations like readdir because + of the limitations of semihosting mechanism. + +if RISCV_SEMIHOSTING_HOSTFS + +config RISCV_SEMIHOSTING_HOSTFS_CACHE_COHERENCE + bool "Cache coherence in semihosting hostfs" + depends on ARCH_DCACHE + ---help--- + Flush & Invalidte cache before & after bkpt instruction. + +endif + source "arch/risc-v/src/opensbi/Kconfig" -source "arch/risc-v/src/common/Kconfig" if ARCH_CHIP_FE310 source "arch/risc-v/src/fe310/Kconfig" diff --git a/arch/risc-v/include/arch.h b/arch/risc-v/include/arch.h index 92b1f6667949b..1f75b49ac618b 100644 --- a/arch/risc-v/include/arch.h +++ b/arch/risc-v/include/arch.h @@ -33,18 +33,57 @@ #ifndef __ASSEMBLY__ # include +# include #endif -#include - /**************************************************************************** * Pre-processor Definitions ****************************************************************************/ +#ifdef __ASSEMBLY__ +# define __STR(s) s +#else +# define __STR(s) #s +#endif +#define __XSTR(s) __STR(s) + +#if defined(CONFIG_ARCH_QPFPU) +# define FLOAD __STR(flq) +# define FSTORE __STR(fsq) +#elif defined(CONFIG_ARCH_DPFPU) +# define FLOAD __STR(fld) +# define FSTORE __STR(fsd) +#else +# define FLOAD __STR(flw) +# define FSTORE __STR(fsw) +#endif + +#ifdef CONFIG_ARCH_RV32 +# define REGLOAD __STR(lw) +# define REGSTORE __STR(sw) +#else +# define REGLOAD __STR(ld) +# define REGSTORE __STR(sd) +#endif + +/* Provide the maximum amount of page table levels per MMU type */ + +#ifdef CONFIG_ARCH_MMU_TYPE_SV39 +# define ARCH_PGT_MAX_LEVELS (3) +#endif + +/* Amount of static page tables allocated for an address environment */ + +#ifdef CONFIG_ARCH_ADDRENV +# define ARCH_SPGTS (ARCH_PGT_MAX_LEVELS - 1) +#endif + /**************************************************************************** * Inline functions ****************************************************************************/ +#ifndef __ASSEMBLY__ + /**************************************************************************** * Name: up_getsp ****************************************************************************/ @@ -60,10 +99,66 @@ static inline uintptr_t up_getsp(void) return sp; } +#endif + /**************************************************************************** * Public Types ****************************************************************************/ +#ifdef CONFIG_ARCH_ADDRENV +#ifndef __ASSEMBLY__ + +/* A task group must have its L1 table in memory always, and the rest can + * be dynamically committed to memory (and even swapped). + * + * In this implementation every level tables besides the final level N are + * kept in memory always, while the level N tables are dynamically allocated. + * + * The implications ? They depend on the MMU type. + * + * For Sv39 this means that: + * - A task can not have more than 1GB of memory allocated. This should be + * plenty enough... + * - The minimum amount of memory needed for page tables per task is 12K, + * which gives access to 2MB of memory. This is plenty for many tasks. + */ + +struct group_addrenv_s +{ + /* Pointers to MAX_LEVELS-1 tables here, one of each are allocated for the + * task when it is created. + */ + + uintptr_t spgtables[ARCH_SPGTS]; + + /* For convenience store the text base here */ + + uintptr_t textvbase; + + /* For convenience store the data base here */ + + uintptr_t datavbase; + + /* For convenience store the heap base and initial size here */ + + uintptr_t heapvbase; + size_t heapsize; + + /* For convenience store the satp value here */ + + uintptr_t satp; +}; + +typedef struct group_addrenv_s group_addrenv_t; + +/* If an address environment needs to be saved, saving the satp register + * will suffice. The register width is architecture dependent + */ + +typedef uintptr_t save_addrenv_t; +#endif /* __ASSEMBLY__ */ +#endif /* CONFIG_ARCH_ADDRENV */ + /**************************************************************************** * Public Function Prototypes ****************************************************************************/ diff --git a/arch/risc-v/include/csr.h b/arch/risc-v/include/csr.h index a5cb948b0c82b..e719b2a29f996 100644 --- a/arch/risc-v/include/csr.h +++ b/arch/risc-v/include/csr.h @@ -299,75 +299,89 @@ /* In mstatus register */ -#define MSTATUS_MIE (0x1 << 3) /* Machine Interrupt Enable */ -#define MSTATUS_MPIE (0x1 << 7) /* Machine Previous Interrupt Enable */ -#define MSTATUS_MPPM (0x3 << 11) /* Machine Previous Privilege (m-mode) */ -#define MSTATUS_FS (0x3 << 13) /* Machine Floating-point Status */ -#define MSTATUS_FS_INIT (0x1 << 13) -#define MSTATUS_FS_CLEAN (0x2 << 13) -#define MSTATUS_FS_DIRTY (0x3 << 13) +#define MSTATUS_UIE (0x1 << 0) /* User Interrupt Enable */ +#define MSTATUS_SIE (0x1 << 1) /* Supervisor Interrupt Enable */ +#define MSTATUS_MIE (0x1 << 3) /* Machine Interrupt Enable */ +#define MSTATUS_SPIE (0x1 << 5) /* Supervisor Previous Interrupt Enable */ +#define MSTATUS_MPIE (0x1 << 7) /* Machine Previous Interrupt Enable */ +#define MSTATUS_SPPU (0x0 << 8) /* Supervisor Previous Privilege (u-mode) */ +#define MSTATUS_SPPS (0x1 << 8) /* Supervisor Previous Privilege (s-mode) */ +#define MSTATUS_MPPU (0x0 << 11) /* Machine Previous Privilege (u-mode) */ +#define MSTATUS_MPPS (0x1 << 11) /* Machine Previous Privilege (s-mode) */ +#define MSTATUS_MPPM (0x3 << 11) /* Machine Previous Privilege (m-mode) */ +#define MSTATUS_MPP_MASK (0x3 << 11) +#define MSTATUS_FS (0x3 << 13) /* Machine Floating-point Status */ +#define MSTATUS_FS_INIT (0x1 << 13) +#define MSTATUS_FS_CLEAN (0x2 << 13) +#define MSTATUS_FS_DIRTY (0x3 << 13) +#define MSTATUS_MPRV (0x1 << 17) /* Modify Privilege */ +#define MSTATUS_SUM (0x1 << 18) /* S mode access to U mode memory */ +#define MSTATUS_MXR (0x1 << 19) /* Make executable / readable */ +#define MSTATUS_TVM (0x1 << 20) /* Trap access to satp from S mode */ +#define MSTATUS_TW (0x1 << 21) /* Trap WFI instruction from S mode */ +#define MSTATUS_TSR (0x1 << 22) /* Trap supervisor return (sret) */ /* Mask of preserved bits for mstatus */ #ifdef CONFIG_ARCH_RV32 -#define MSTATUS_WPRI (0xff << 23 | 0x15) +#define MSTATUS_WPRI (0xff << 23 | 0x15) #else -#define MSTATUS_WPRI (UINT64_C(0x1ffffff) << 38 | UINT64_C(0x1ff) << 23 | 0x15) +#define MSTATUS_WPRI (UINT64_C(0x1ffffff) << 38 | UINT64_C(0x1ff) << 23 | 0x15) #endif /* In mie (machine interrupt enable) register */ -#define MIE_MSIE (0x1 << 3) /* Machine Software Interrupt Enable */ -#define MIE_MTIE (0x1 << 7) /* Machine Timer Interrupt Enable */ -#define MIE_MEIE (0x1 << 11) /* Machine External Interrupt Enable */ +#define MIE_SSIE (0x1 << 1) /* Supervisor Software Interrupt Enable */ +#define MIE_MSIE (0x1 << 3) /* Machine Software Interrupt Enable */ +#define MIE_STIE (0x1 << 5) /* Supervisor Timer Interrupt Enable */ +#define MIE_MTIE (0x1 << 7) /* Machine Timer Interrupt Enable */ +#define MIE_SEIE (0x1 << 9) /* Supervisor External Interrupt Enable */ +#define MIE_MEIE (0x1 << 11) /* Machine External Interrupt Enable */ /* In mip (machine interrupt pending) register */ -#define MIP_MTIP (0x1 << 7) +#define MIP_SSIP (0x1 << 1) +#define MIP_STIP (0x1 << 5) +#define MIP_MTIP (0x1 << 7) +#define MIP_SEIP (0x1 << 9) -#define CSR_STR(csr) #csr +/* In sstatus register (which is a view of mstatus) */ -#define READ_CSR(reg) \ - ({ \ - unsigned long tmp; \ - asm volatile("csrr %0, " CSR_STR(reg) : "=r"(tmp)); \ - tmp; \ - }) +#define SSTATUS_SIE MSTATUS_SIE +#define SSTATUS_SPIE MSTATUS_SPIE +#define SSTATUS_SPPU MSTATUS_SPPU +#define SSTATUS_SPPS MSTATUS_SPPS +#define SSTATUS_FS MSTATUS_FS +#define SSTATUS_FS_INIT MSTATUS_FS_INIT +#define SSTATUS_FS_CLEAN MSTATUS_FS_CLEAN +#define SSTATUS_FS_DIRTY MSTATUS_FS_DIRTY +#define SSTATUS_SUM MSTATUS_SUM +#define SSTATUS_MXR MSTATUS_MXR -#define READ_AND_SET_CSR(reg, bits) \ - ({ \ - unsigned long tmp; \ - asm volatile("csrrs %0, " CSR_STR(reg) ", %1": "=r"(tmp) : "rK"(bits)); \ - tmp; \ - }) +/* In sie register (which is a view of mie) */ -#define WRITE_CSR(reg, val) \ - ({ \ - asm volatile("csrw " CSR_STR(reg) ", %0" :: "rK"(val)); \ - }) +#define SIE_SSIE MIE_SSIE +#define SIE_STIE MIE_STIE +#define SIE_SEIE MIE_SEIE -#define SET_CSR(reg, bits) \ - ({ \ - asm volatile("csrs " CSR_STR(reg) ", %0" :: "rK"(bits)); \ - }) +/* In sip register (which is a view of mip) */ -#define CLEAR_CSR(reg, bits) \ - ({ \ - asm volatile("csrc " CSR_STR(reg) ", %0" :: "rK"(bits)); \ - }) +#define SIP_SSIP MIP_SSIP +#define SIP_STIP MIP_STIP +#define SIP_SEIP MIP_SEIP /* In pmpcfg (PMP configuration) register */ -#define PMPCFG_R (1 << 0) /* readable ? */ -#define PMPCFG_W (1 << 1) /* writeable ? */ -#define PMPCFG_X (1 << 2) /* excutable ? */ -#define PMPCFG_RWX_MASK (7 << 0) /* access rights mask */ -#define PMPCFG_A_OFF (0 << 3) /* null region (disabled) */ -#define PMPCFG_A_TOR (1 << 3) /* top of range */ -#define PMPCFG_A_NA4 (2 << 3) /* naturally aligned four-byte region */ -#define PMPCFG_A_NAPOT (3 << 3) /* naturally aligned power-of-two region */ -#define PMPCFG_A_MASK (3 << 3) /* address-matching mode mask */ -#define PMPCFG_L (1 << 7) /* locked ? */ +#define PMPCFG_R (1 << 0) /* readable ? */ +#define PMPCFG_W (1 << 1) /* writable ? */ +#define PMPCFG_X (1 << 2) /* executable ? */ +#define PMPCFG_RWX_MASK (7 << 0) /* access rights mask */ +#define PMPCFG_A_OFF (0 << 3) /* null region (disabled) */ +#define PMPCFG_A_TOR (1 << 3) /* top of range */ +#define PMPCFG_A_NA4 (2 << 3) /* naturally aligned four-byte region */ +#define PMPCFG_A_NAPOT (3 << 3) /* naturally aligned power-of-two region */ +#define PMPCFG_A_MASK (3 << 3) /* address-matching mode mask */ +#define PMPCFG_L (1 << 7) /* locked ? */ /**************************************************************************** * Public Types diff --git a/arch/risc-v/include/esp32c3/irq.h b/arch/risc-v/include/esp32c3/irq.h index 1b4475872a252..60262d8ea6ca8 100644 --- a/arch/risc-v/include/esp32c3/irq.h +++ b/arch/risc-v/include/esp32c3/irq.h @@ -140,9 +140,8 @@ /* ecall is dispatched like normal interrupts. It occupies an IRQ number. */ -#define ESP32C3_IRQ_ECALL_M 0 -#define RISCV_NIRQ_INTERRUPTS 1 /* Number of RISC-V dispatched interrupts. */ -#define ESP32C3_IRQ_FIRSTPERIPH 1 /* First peripheral IRQ number */ +#define RISCV_NIRQ_INTERRUPTS 16 /* Number of RISC-V dispatched interrupts. */ +#define ESP32C3_IRQ_FIRSTPERIPH 16 /* First peripheral IRQ number */ /* Peripheral IRQs */ diff --git a/arch/risc-v/include/irq.h b/arch/risc-v/include/irq.h index 4ae804c5b9df6..34f49dc00c493 100644 --- a/arch/risc-v/include/irq.h +++ b/arch/risc-v/include/irq.h @@ -32,14 +32,13 @@ /* Include chip-specific IRQ definitions (including IRQ numbers) */ #include + #include -#ifndef __ASSEMBLY__ -#include -#include +#include #include #include -#endif +#include /**************************************************************************** * Pre-processor Definitions @@ -50,7 +49,7 @@ /* IRQ 0-15 : (exception:interrupt=0) */ #define RISCV_IRQ_IAMISALIGNED (0) /* Instruction Address Misaligned */ -#define RISCV_IRQ_IAFAULT (1) /* Instruction Address Fault */ +#define RISCV_IRQ_IAFAULT (1) /* Instruction Access Fault */ #define RISCV_IRQ_IINSTRUCTION (2) /* Illegal Instruction */ #define RISCV_IRQ_BPOINT (3) /* Break Point */ #define RISCV_IRQ_LAMISALIGNED (4) /* Load Address Misaligned */ @@ -64,7 +63,7 @@ #define RISCV_IRQ_INSTRUCTIONPF (12) /* Instruction page fault */ #define RISCV_IRQ_LOADPF (13) /* Load page fault */ #define RISCV_IRQ_RESERVED (14) /* Reserved */ -#define RISCV_IRQ_SROREPF (15) /* Store/AMO page fault */ +#define RISCV_IRQ_STOREPF (15) /* Store/AMO page fault */ #define RISCV_MAX_EXCEPTION (15) @@ -472,7 +471,7 @@ struct xcpt_syscall_s { uintptr_t sysreturn; /* The return PC */ #ifndef CONFIG_BUILD_FLAT - uintptr_t int_ctx; /* Interrupt context (i.e. mstatus) */ + uintptr_t int_ctx; /* Interrupt context (i.e. m-/sstatus) */ #endif }; #endif @@ -580,9 +579,9 @@ static inline irqstate_t up_irq_save(void) __asm__ __volatile__ ( - "csrrc %0, mstatus, %1\n" + "csrrc %0, " __XSTR(CSR_STATUS) ", %1\n" : "=r" (flags) - : "r"(MSTATUS_MIE) + : "r"(STATUS_IE) : "memory" ); @@ -605,7 +604,7 @@ static inline void up_irq_restore(irqstate_t flags) { __asm__ __volatile__ ( - "csrw mstatus, %0\n" + "csrw " __XSTR(CSR_STATUS) ", %0\n" : /* no output */ : "r" (flags) : "memory" diff --git a/arch/risc-v/include/litex/irq.h b/arch/risc-v/include/litex/irq.h index 02713e29d44e5..7056877776a47 100644 --- a/arch/risc-v/include/litex/irq.h +++ b/arch/risc-v/include/litex/irq.h @@ -35,9 +35,10 @@ #define LITEX_IRQ_UART0 (RISCV_IRQ_MEXT + 1) #define LITEX_IRQ_TIMER0 (RISCV_IRQ_MEXT + 2) +#define LITEX_IRQ_SDCARD (RISCV_IRQ_MEXT + 3) /* Total number of IRQs */ -#define NR_IRQS (LITEX_IRQ_TIMER0 + 1) +#define NR_IRQS (LITEX_IRQ_SDCARD + 1) #endif /* __ARCH_RISCV_INCLUDE_LITEX_IRQ_H */ diff --git a/arch/risc-v/include/mode.h b/arch/risc-v/include/mode.h new file mode 100644 index 0000000000000..e4b3c40894dea --- /dev/null +++ b/arch/risc-v/include/mode.h @@ -0,0 +1,103 @@ +/**************************************************************************** + * arch/risc-v/include/mode.h + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +#ifndef __ARCH_RISCV_INCLUDE_MODE_H +#define __ARCH_RISCV_INCLUDE_MODE_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include +#include + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +#ifdef CONFIG_ARCH_USE_S_MODE + +/* CSR definitions */ + +# define CSR_STATUS sstatus /* Global status register */ +# define CSR_SCRATCH sscratch /* Scratch register */ +# define CSR_EPC sepc /* Exception program counter */ +# define CSR_IE sie /* Interrupt enable register */ +# define CSR_CAUSE scause /* Interrupt cause register */ + +/* In status register */ + +# define STATUS_IE SSTATUS_SIE /* Global interrupt enable */ +# define STATUS_PIE SSTATUS_SPIE /* Previous interrupt enable */ +# define STATUS_PPP SSTATUS_SPPS /* Previous privilege */ +# define STATUS_SUM SSTATUS_SUM /* Access to user memory */ + +/* Interrupt bits */ + +# define IE_EIE SIE_SEIE /* External interrupt enable */ +# define IE_SIE SIE_SSIE /* Software interrupt enable */ +# define IE_TIE SIE_STIE /* Timer interrupt enable */ + +/* External, timer and software interrupt */ + +# define RISCV_IRQ_EXT RISCV_IRQ_SEXT /* PLIC IRQ */ +# define RISCV_IRQ_TIMER RISCV_IRQ_STIMER /* Timer IRQ */ +# define RISCV_IRQ_SOFT RISCV_IRQ_SSOFT /* SW IRQ */ + +/* Define return from exception */ + +# define ERET sret + +#else + +/* CSR definitions */ + +# define CSR_STATUS mstatus /* Global status register */ +# define CSR_SCRATCH mscratch /* Scratch register */ +# define CSR_EPC mepc /* Exception program counter */ +# define CSR_IE mie /* Interrupt enable register */ +# define CSR_CAUSE mcause /* Interrupt cause register */ + +/* In status register */ + +# define STATUS_IE MSTATUS_MIE /* Global interrupt enable */ +# define STATUS_PIE MSTATUS_MPIE /* Previous interrupt enable */ +# define STATUS_PPP MSTATUS_MPPM /* Previous privilege */ +# define STATUS_SUM 0 /* Not needed in M-mode */ + +/* Interrupt bits */ + +# define IE_EIE MIE_MEIE /* External interrupt enable */ +# define IE_SIE MIE_MSIE /* Software interrupt enable */ +# define IE_TIE MIE_MTIE /* Timer interrupt enable */ + +/* External, timer and software interrupt */ + +# define RISCV_IRQ_EXT RISCV_IRQ_MEXT /* PLIC IRQ */ +# define RISCV_IRQ_TIMER RISCV_IRQ_MTIMER /* Timer IRQ */ +# define RISCV_IRQ_SOFT RISCV_IRQ_MSOFT /* SW IRQ */ + +/* Define return from exception */ + +# define ERET mret + +#endif + +#endif /* __ARCH_RISCV_INCLUDE_MODE_H */ diff --git a/arch/risc-v/include/syscall.h b/arch/risc-v/include/syscall.h index a357d1d84d169..ccb751fb0736d 100644 --- a/arch/risc-v/include/syscall.h +++ b/arch/risc-v/include/syscall.h @@ -31,6 +31,8 @@ #include +#include + #ifndef __ASSEMBLY__ # include #endif @@ -122,51 +124,6 @@ #define SYS_signal_handler_return (7) #endif /* !CONFIG_BUILD_FLAT */ -/* sys_call macros **********************************************************/ - -#ifndef __ASSEMBLY__ - -/* Context switching system calls *******************************************/ - -/* SYS call 0: - * - * int riscv_saveusercontext(uintptr_t *saveregs); - * - * Return: - * 0: Normal Return - * 1: Context Switch Return - */ - -#define riscv_saveusercontext(saveregs) \ - (int)sys_call1(SYS_save_context, (uintptr_t)(saveregs)) - -/* SYS call 1: - * - * void riscv_fullcontextrestore(uintptr_t *restoreregs) noreturn_function; - */ - -#define riscv_fullcontextrestore(restoreregs) \ - sys_call1(SYS_restore_context, (uintptr_t)(restoreregs)) - -/* SYS call 2: - * - * void riscv_switchcontext(uintptr_t **saveregs, uintptr_t *restoreregs); - */ - -#define riscv_switchcontext(saveregs, restoreregs) \ - sys_call2(SYS_switch_context, (uintptr_t)(saveregs), (uintptr_t)(restoreregs)) - -#ifdef CONFIG_BUILD_KERNEL -/* SYS call 3: - * - * void riscv_syscall_return(void); - */ - -#define riscv_syscall_return() sys_call0(SYS_syscall_return) - -#endif -#endif /* __ASSEMBLY__ */ - /**************************************************************************** * Public Types ****************************************************************************/ @@ -193,6 +150,22 @@ extern "C" #define EXTERN extern #endif +long smh_call(unsigned int nbr, void *parm); + +#if defined(CONFIG_ARCH_USE_S_MODE) && defined(__KERNEL__) +uintptr_t sys_call0(unsigned int nbr); +uintptr_t sys_call1(unsigned int nbr, uintptr_t parm1); +uintptr_t sys_call2(unsigned int nbr, uintptr_t parm1, uintptr_t parm2); +uintptr_t sys_call3(unsigned int nbr, uintptr_t parm1, uintptr_t parm2, + uintptr_t parm3); +uintptr_t sys_call4(unsigned int nbr, uintptr_t parm1, uintptr_t parm2, + uintptr_t parm3, uintptr_t parm4); +uintptr_t sys_call5(unsigned int nbr, uintptr_t parm1, uintptr_t parm2, + uintptr_t parm3, uintptr_t parm4, uintptr_t parm5); +uintptr_t sys_call6(unsigned int nbr, uintptr_t parm1, uintptr_t parm2, + uintptr_t parm3, uintptr_t parm4, uintptr_t parm5, + uintptr_t parm6); +#else /**************************************************************************** * Name: sys_call0 * @@ -390,6 +363,7 @@ static inline uintptr_t sys_call6(unsigned int nbr, uintptr_t parm1, return r0; } +#endif #undef EXTERN #ifdef __cplusplus diff --git a/arch/risc-v/src/Makefile b/arch/risc-v/src/Makefile index f598c6fd2e30f..d65a0a8aa94a3 100644 --- a/arch/risc-v/src/Makefile +++ b/arch/risc-v/src/Makefile @@ -24,6 +24,12 @@ ifeq ($(CONFIG_OPENSBI),y) include opensbi/Make.defs endif +# Kernel runs in supervisor mode or machine mode ? + +ifeq ($(CONFIG_ARCH_USE_S_MODE),y) +include common/supervisor/Make.defs +endif + ARCH_SRCDIR = $(TOPDIR)$(DELIM)arch$(DELIM)$(CONFIG_ARCH)$(DELIM)src INCLUDES += ${shell $(INCDIR) "$(CC)" $(ARCH_SRCDIR)$(DELIM)chip} @@ -84,8 +90,15 @@ BIN = libarch$(LIBEXT) LDFLAGS += $(addprefix -T,$(call CONVERT_PATH,$(ARCHSCRIPT))) $(EXTRALINKCMDS) -LDSTARTGROUP ?= --start-group -LDENDGROUP ?= --end-group +ifeq ($(LD),$(CC)) + LDSTARTGROUP ?= -Wl,--start-group + LDENDGROUP ?= -Wl,--end-group + LDFLAGS := $(addprefix -Xlinker ,$(LDFLAGS)) + LDFLAGS += $(CFLAGS) +else + LDSTARTGROUP ?= --start-group + LDENDGROUP ?= --end-group +endif BOARDMAKE = $(if $(wildcard board$(DELIM)Makefile),y,) @@ -117,6 +130,9 @@ $(AOBJS) $(UAOBJS) $(HEAD_OBJ): %$(OBJEXT): %.S $(COBJS) $(UCOBJS): %$(OBJEXT): %.c $(call COMPILE, $<, $@) +crt0$(OBJEXT): %$(OBJEXT): %.c + $(call COMPILE, $<, $@) + ifeq ($(CONFIG_BUILD_FLAT),y) $(BIN): $(OBJS) $(call ARCHIVE, $@, $(OBJS)) @@ -207,9 +223,4 @@ endif $(call DELFILE, Make.dep) $(call DELFILE, .depend) -info: - @echo $(HEAD_OBJ) - @echo $(ASRCS) - @echo $(CONFIG_ARCH_CHIP) - -include Make.dep diff --git a/arch/risc-v/src/bl602/Make.defs b/arch/risc-v/src/bl602/Make.defs index f4d78cd39a6eb..205af29f2647b 100644 --- a/arch/risc-v/src/bl602/Make.defs +++ b/arch/risc-v/src/bl602/Make.defs @@ -33,7 +33,9 @@ CMN_CSRCS += riscv_interruptcontext.c riscv_modifyreg32.c riscv_puts.c riscv_mde CMN_CSRCS += riscv_releasepending.c riscv_reprioritizertr.c CMN_CSRCS += riscv_releasestack.c riscv_stackframe.c riscv_schedulesigaction.c CMN_CSRCS += riscv_sigdeliver.c riscv_udelay.c riscv_unblocktask.c riscv_usestack.c -CMN_CSRCS += riscv_idle.c riscv_tcbinfo.c riscv_getnewintctx.c +CMN_CSRCS += riscv_idle.c riscv_tcbinfo.c riscv_getnewintctx.c riscv_doirq.c +CMN_CSRCS += riscv_exception.c riscv_mtimer.c riscv_misaligned.c +CMN_CSRCS += riscv_saveusercontext.c ifeq ($(CONFIG_SCHED_BACKTRACE),y) CMN_CSRCS += riscv_backtrace.c @@ -45,9 +47,11 @@ endif ifeq ($(CONFIG_ARCH_FPU),y) CMN_ASRCS += riscv_fpu.S +CMN_CSRCS += riscv_fpucmp.c endif ifeq ($(CONFIG_ARCH_HAVE_VFORK),y) +CMN_ASRCS += vfork.S CMN_CSRCS += riscv_vfork.c endif @@ -116,11 +120,6 @@ CHIP_CSRCS += bl602_netdev.c EXTRA_LIBPATHS += -L $(ARCH_SRCDIR)$(DELIM)chip$(DELIM)$(WIRELESS_DRV_UNPACK)$(DELIM)libs$(DELIM)BL602$(DELIM)nuttx EXTRA_LIBS += -lbl602_wifi -lbl602_wifi_manage -lblecontroller -# Due to some Wi-Fi related libraries, the option is need to avoid linking too much -# unused functions. - -LDFLAGS += --gc-sections - ifeq ($(CONFIG_BL602_WIRELESS_DEBUG),y) LDFLAGS += -defsym _wifi_log_flag=1 endif diff --git a/arch/risc-v/src/bl602/bl602_head.S b/arch/risc-v/src/bl602/bl602_head.S index 07115b193efd2..758304c16c4aa 100644 --- a/arch/risc-v/src/bl602/bl602_head.S +++ b/arch/risc-v/src/bl602/bl602_head.S @@ -23,7 +23,7 @@ ****************************************************************************/ #include -#include +#include .section .init .globl bl602_start @@ -126,20 +126,6 @@ bl602_entry_zero_wifi_bss_loop: bltu a0, a1, bl602_entry_zero_wifi_bss_loop bl602_entry_zero_wifi_bss_end: -#ifndef __riscv_float_abi_soft - - /* Enable FPU */ - - li t0, MSTATUS_FS - csrs mstatus, t0 - csrr t1, mstatus - and t1, t1, t0 - beqz t1, bl602_entry_enable_fpu_end - fssr x0 - -bl602_entry_enable_fpu_end: -#endif - auipc ra, 0 addi sp, sp, -16 sw ra, 8(sp) diff --git a/arch/risc-v/src/bl602/bl602_irq.c b/arch/risc-v/src/bl602/bl602_irq.c index 09472a4a8b659..1a03725f40308 100644 --- a/arch/risc-v/src/bl602/bl602_irq.c +++ b/arch/risc-v/src/bl602/bl602_irq.c @@ -30,10 +30,7 @@ #include #include -#include -#include -#include -#include +#include #include "riscv_internal.h" #include "hardware/bl602_clic.h" @@ -95,9 +92,9 @@ void up_irqinitialize(void) CURRENT_REGS = NULL; - /* Attach the ecall interrupt handler */ + /* Attach the common interrupt handler */ - irq_attach(RISCV_IRQ_ECALLM, riscv_swint, NULL); + riscv_exception_attach(); #ifndef CONFIG_SUPPRESS_INTERRUPTS diff --git a/arch/risc-v/src/bl602/bl602_irq_dispatch.c b/arch/risc-v/src/bl602/bl602_irq_dispatch.c index 5a3c086b9e6c8..602b597117968 100644 --- a/arch/risc-v/src/bl602/bl602_irq_dispatch.c +++ b/arch/risc-v/src/bl602/bl602_irq_dispatch.c @@ -29,8 +29,6 @@ #include #include -#include -#include #include "riscv_internal.h" #include "chip.h" @@ -46,7 +44,6 @@ void *riscv_dispatch_irq(uintptr_t vector, uintptr_t *regs) { int irq = vector & 0x3ff; /* E24 [9:0] */ - uintptr_t *mepc = regs; /* If current is interrupt */ @@ -55,63 +52,13 @@ void *riscv_dispatch_irq(uintptr_t vector, uintptr_t *regs) irq += RISCV_IRQ_ASYNC; } - /* NOTE: In case of ecall, we need to adjust mepc in the context */ - - if (RISCV_IRQ_ECALLM == irq) - { - *mepc += 4; - } - /* Acknowledge the interrupt */ riscv_ack_irq(irq); -#ifdef CONFIG_SUPPRESS_INTERRUPTS - PANIC(); -#else - /* Current regs non-zero indicates that we are processing an interrupt; - * CURRENT_REGS is also used to manage interrupt level context switches. - * - * Nested interrupts are not supported - */ - - DEBUGASSERT(CURRENT_REGS == NULL); - CURRENT_REGS = regs; - /* Deliver the IRQ */ - irq_dispatch(irq, regs); - - /* Check for a context switch. If a context switch occurred, then - * CURRENT_REGS will have a different value than it did on entry. If an - * interrupt level context switch has occurred, then restore the floating - * point state and the establish the correct address environment before - * returning from the interrupt. - */ - - if (regs != CURRENT_REGS) - { -#ifdef CONFIG_ARCH_ADDRENV - /* Make sure that the address environment for the previously - * running task is closed down gracefully (data caches dump, - * MMU flushed) and set up the address environment for the new - * thread at the head of the ready-to-run list. - */ - - group_addrenv(NULL); -#endif - } - -#endif /* CONFIG_SUPPRESS_INTERRUPTS */ - - /* If a context switch occurred while processing the interrupt then - * CURRENT_REGS may have change value. If we return any value different - * from the input regs, then the lower level will know that a context - * switch occurred during interrupt processing. - */ - - regs = (uintptr_t *)CURRENT_REGS; - CURRENT_REGS = NULL; + regs = riscv_doirq(irq, regs); return regs; } diff --git a/arch/risc-v/src/bl602/bl602_oneshot_lowerhalf.c b/arch/risc-v/src/bl602/bl602_oneshot_lowerhalf.c index a1a3ee5e14bab..77ec201fad719 100644 --- a/arch/risc-v/src/bl602/bl602_oneshot_lowerhalf.c +++ b/arch/risc-v/src/bl602/bl602_oneshot_lowerhalf.c @@ -359,7 +359,7 @@ static int bl602_cancel(struct oneshot_lowerhalf_s *lower, ****************************************************************************/ struct oneshot_lowerhalf_s *oneshot_initialize(int chan, - uint16_t resolution) + uint16_t resolution) { struct bl602_oneshot_lowerhalf_s *priv; struct timer_cfg_s timstr; diff --git a/arch/risc-v/src/bl602/bl602_os_hal.c b/arch/risc-v/src/bl602/bl602_os_hal.c index e2c3fdb9669b7..8b32067f39386 100644 --- a/arch/risc-v/src/bl602/bl602_os_hal.c +++ b/arch/risc-v/src/bl602/bl602_os_hal.c @@ -1103,7 +1103,7 @@ int bl_os_workqueue_submit_hpwork(void *work, return -EINVAL; } - return work_queue(OS_HPWORK, work, (worker_t)worker, argv, tick); + return work_queue(OS_HPWORK, work, worker, argv, tick); } /**************************************************************************** @@ -1132,7 +1132,7 @@ int bl_os_workqueue_submit_lpwork(void *work, return -EINVAL; } - return work_queue(OS_LPWORK, work, (worker_t)worker, argv, tick); + return work_queue(OS_LPWORK, work, worker, argv, tick); } /**************************************************************************** diff --git a/arch/risc-v/src/bl602/bl602_pwm_lowerhalf.c b/arch/risc-v/src/bl602/bl602_pwm_lowerhalf.c index 2a7128eb5f59b..cbf144fe252df 100644 --- a/arch/risc-v/src/bl602/bl602_pwm_lowerhalf.c +++ b/arch/risc-v/src/bl602/bl602_pwm_lowerhalf.c @@ -362,8 +362,8 @@ static int bl602_pwm_start(struct pwm_lowerhalf_s *dev, const struct pwm_info_s *info) { struct bl602_pwm_s *priv = (struct bl602_pwm_s *)dev; - int ret = OK; - int i; + int ret = OK; + int i; UNUSED(i); diff --git a/arch/risc-v/src/bl602/bl602_serial.c b/arch/risc-v/src/bl602/bl602_serial.c index 9991492ee3b1c..4787a6852cd76 100644 --- a/arch/risc-v/src/bl602/bl602_serial.c +++ b/arch/risc-v/src/bl602/bl602_serial.c @@ -391,7 +391,7 @@ static void bl602_shutdown(struct uart_dev_s *dev) static int bl602_attach(struct uart_dev_s *dev) { - int ret; + int ret; struct bl602_uart_s *priv = (struct bl602_uart_s *)dev->priv; ret = irq_attach(priv->irq, __uart_interrupt, (void *)dev); @@ -888,9 +888,6 @@ void riscv_serialinit(void) int up_putc(int ch) { #ifdef HAVE_SERIAL_CONSOLE - struct bl602_uart_s *priv = (struct bl602_uart_s *)CONSOLE_DEV.priv; - (void)priv; - irqstate_t flags = enter_critical_section(); /* Check for LF */ diff --git a/arch/risc-v/src/bl602/bl602_spi.c b/arch/risc-v/src/bl602/bl602_spi.c index 4726ed1f720bd..c2d9faa3b36cd 100644 --- a/arch/risc-v/src/bl602/bl602_spi.c +++ b/arch/risc-v/src/bl602/bl602_spi.c @@ -441,6 +441,15 @@ static void bl602_spi_select(struct spi_dev_s *dev, uint32_t devid, /* we used hardware CS */ spiinfo("devid: %lu, CS: %s\n", devid, selected ? "select" : "free"); + +#ifdef CONFIG_SPI_CMDDATA + /* revert MISO from GPIO Pin to SPI Pin */ + + if (!selected) + { + bl602_configgpio(BOARD_SPI_MISO); + } +#endif } /**************************************************************************** @@ -681,6 +690,11 @@ static uint8_t bl602_spi_status(struct spi_dev_s *dev, uint32_t devid) * method is required if CONFIG_SPI_CMDDATA is selected in the NuttX * configuration * + * This function reconfigures MISO from SPI Pin to GPIO Pin, and sets + * MISO to high (data) or low (command). bl602_spi_select() will revert + * MISO back from GPIO Pin to SPI Pin. We must revert because the SPI Bus + * may be used by other drivers. + * * Input Parameters: * dev - Device-specific state data * cmd - TRUE: The following word is a command; FALSE: the following words @@ -695,10 +709,38 @@ static uint8_t bl602_spi_status(struct spi_dev_s *dev, uint32_t devid) static int bl602_spi_cmddata(struct spi_dev_s *dev, uint32_t devid, bool cmd) { + spiinfo("devid: %" PRIu32 " CMD: %s\n", devid, cmd ? "command" : + "data"); + + if (devid == SPIDEV_DISPLAY(0)) + { + gpio_pinset_t gpio; + int ret; + + /* reconfigure MISO from SPI Pin to GPIO Pin */ + + gpio = (BOARD_SPI_MISO & GPIO_PIN_MASK) + | GPIO_OUTPUT | GPIO_PULLUP | GPIO_FUNC_SWGPIO; + ret = bl602_configgpio(gpio); + if (ret < 0) + { + spierr("Failed to configure MISO as GPIO\n"); + DEBUGPANIC(); + + return ret; + } + + /* set MISO to high (data) or low (command) */ + + bl602_gpiowrite(gpio, !cmd); + + return OK; + } + spierr("SPI cmddata not supported\n"); DEBUGPANIC(); - return -1; + return -ENODEV; } #endif diff --git a/arch/risc-v/src/bl602/bl602_start.c b/arch/risc-v/src/bl602/bl602_start.c index f90bf8ed10932..9bad097c07ec1 100644 --- a/arch/risc-v/src/bl602/bl602_start.c +++ b/arch/risc-v/src/bl602/bl602_start.c @@ -160,6 +160,10 @@ __cyg_profile_func_exit(void *this_fn, void *call_site) void bfl_main(void) { + /* Configure FPU */ + + riscv_fpuconfig(); + /* set interrupt vector */ asm volatile("csrw mtvec, %0" ::"r"((uintptr_t)exception_common + 2)); diff --git a/arch/risc-v/src/bl602/bl602_timerisr.c b/arch/risc-v/src/bl602/bl602_timerisr.c index 6d8d680877aa0..3eed8180eb627 100644 --- a/arch/risc-v/src/bl602/bl602_timerisr.c +++ b/arch/risc-v/src/bl602/bl602_timerisr.c @@ -24,6 +24,7 @@ #include +#include #include #include #include @@ -31,95 +32,23 @@ #include #include #include +#include #include #include "hardware/bl602_clic.h" #include "riscv_internal.h" +#include "riscv_mtimer.h" #include "chip.h" /**************************************************************************** * Pre-processor Definitions ****************************************************************************/ -/* Private definetions: mtimer frequency */ -#define TICK_COUNT (10 * 1000 * 1000 / TICK_PER_SEC) +#define MTIMER_FREQ 10000000 /**************************************************************************** * Private Data ****************************************************************************/ -static bool g_b_tick_started = false; - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - -/* bl602 mmio registers are a bit odd, by default they are byte-wide - * registers that are on 32-bit word boundaries. So a "32-bit" registers - * is actually broken into four bytes spanning a total address space of - * 16 bytes. - */ - -static inline uint64_t bl602_clint_time_read(void) -{ - uint64_t r = getreg32(BL602_CLIC_MTIME + 4); - r <<= 32; - r |= getreg32(BL602_CLIC_MTIME); - - return r; -} - -static inline uint64_t bl602_clint_time_cmp_read(void) -{ - return getreg64(BL602_CLIC_MTIMECMP); -} - -static inline void bl602_clint_time_cmp_write(uint64_t v) -{ - putreg64(v, BL602_CLIC_MTIMECMP); -} - -/**************************************************************************** - * Name: bl602_reload_mtimecmp - ****************************************************************************/ - -static void bl602_reload_mtimecmp(void) -{ - irqstate_t flags = spin_lock_irqsave(NULL); - - uint64_t current; - uint64_t next; - - if (!g_b_tick_started) - { - g_b_tick_started = true; - current = bl602_clint_time_read(); - } - else - { - current = bl602_clint_time_cmp_read(); - } - - next = current + TICK_COUNT; - - bl602_clint_time_cmp_write(next); - - spin_unlock_irqrestore(NULL, flags); -} - -/**************************************************************************** - * Name: bl602_timerisr - ****************************************************************************/ - -static int bl602_timerisr(int irq, void *context, void *arg) -{ - bl602_reload_mtimecmp(); - - /* Process timer interrupt */ - - nxsched_process_timer(); - return 0; -} - /**************************************************************************** * Public Functions ****************************************************************************/ @@ -135,15 +64,11 @@ static int bl602_timerisr(int irq, void *context, void *arg) void up_timer_initialize(void) { - /* Attach timer interrupt handler */ - - irq_attach(RISCV_IRQ_MTIMER, bl602_timerisr, NULL); - - /* Reload CLINT mtimecmp */ - - bl602_reload_mtimecmp(); + struct oneshot_lowerhalf_s *lower = riscv_mtimer_initialize( + BL602_CLIC_MTIME, BL602_CLIC_MTIMECMP, + RISCV_IRQ_MTIMER, MTIMER_FREQ); - /* And enable the timer interrupt */ + DEBUGASSERT(lower); - up_enable_irq(RISCV_IRQ_MTIMER); + up_alarm_set_lowerhalf(lower); } diff --git a/arch/risc-v/src/bl602/chip.h b/arch/risc-v/src/bl602/chip.h index 4af65547e840d..970d2080ba151 100644 --- a/arch/risc-v/src/bl602/chip.h +++ b/arch/risc-v/src/bl602/chip.h @@ -26,9 +26,12 @@ ****************************************************************************/ #include -#include -#include -#include + +#ifndef __ASSEMBLY__ +# include +# include +# include +#endif /* __ASSEMBLY__ */ #include diff --git a/arch/risc-v/src/c906/Make.defs b/arch/risc-v/src/c906/Make.defs index 2dc5e775547c8..075b739e1671c 100644 --- a/arch/risc-v/src/c906/Make.defs +++ b/arch/risc-v/src/c906/Make.defs @@ -27,14 +27,15 @@ CMN_ASRCS += riscv_vectors.S riscv_testset.S riscv_exception_common.S # Specify C code within the common directory to be included CMN_CSRCS += riscv_initialize.c riscv_swint.c -CMN_CSRCS += riscv_createstack.c riscv_exit.c riscv_fault.c +CMN_CSRCS += riscv_createstack.c riscv_exit.c riscv_exception.c CMN_CSRCS += riscv_assert.c riscv_blocktask.c riscv_copystate.c riscv_initialstate.c CMN_CSRCS += riscv_interruptcontext.c riscv_modifyreg32.c riscv_puts.c CMN_CSRCS += riscv_releasepending.c riscv_reprioritizertr.c CMN_CSRCS += riscv_releasestack.c riscv_stackframe.c riscv_schedulesigaction.c CMN_CSRCS += riscv_sigdeliver.c riscv_unblocktask.c riscv_usestack.c -CMN_CSRCS += riscv_mdelay.c riscv_idle.c +CMN_CSRCS += riscv_mdelay.c riscv_idle.c riscv_doirq.c riscv_mtimer.c CMN_CSRCS += riscv_tcbinfo.c riscv_getnewintctx.c +CMN_CSRCS += riscv_saveusercontext.c ifeq ($(CONFIG_SCHED_BACKTRACE),y) CMN_CSRCS += riscv_backtrace.c @@ -46,9 +47,11 @@ endif ifeq ($(CONFIG_ARCH_FPU),y) CMN_ASRCS += riscv_fpu.S +CMN_CSRCS += riscv_fpucmp.c endif ifeq ($(CONFIG_ARCH_HAVE_VFORK),y) +CMN_ASRCS += vfork.S CMN_CSRCS += riscv_vfork.c endif diff --git a/arch/risc-v/src/c906/c906_allocateheap.c b/arch/risc-v/src/c906/c906_allocateheap.c index 95407246cc003..cc28eda59a5e4 100644 --- a/arch/risc-v/src/c906/c906_allocateheap.c +++ b/arch/risc-v/src/c906/c906_allocateheap.c @@ -28,8 +28,6 @@ #include #include -#include -#include #include "c906.h" diff --git a/arch/risc-v/src/c906/c906_head.S b/arch/risc-v/src/c906/c906_head.S index 4bc4999de85f9..a5ad86eadcbc0 100644 --- a/arch/risc-v/src/c906/c906_head.S +++ b/arch/risc-v/src/c906/c906_head.S @@ -23,8 +23,8 @@ ****************************************************************************/ #include -#include -#include + +#include #include "chip.h" #include "c906_memorymap.h" @@ -52,13 +52,6 @@ __start: sfence.vma x0,x0 - /* enable FPU if CFLAGS has 'f' or 'd' in -march */ - -#ifdef __riscv_flen - li a0, MSTATUS_FS_INIT - csrs mstatus, a0 -#endif - /* enable thead ISA extension: * BIT22: enable the THEAD ISA extensions. * BIT21: enable extended attributes in PTE. diff --git a/arch/risc-v/src/c906/c906_irq.c b/arch/risc-v/src/c906/c906_irq.c index c7059be753ad0..dfdae80765518 100644 --- a/arch/risc-v/src/c906/c906_irq.c +++ b/arch/risc-v/src/c906/c906_irq.c @@ -30,8 +30,7 @@ #include #include -#include -#include +#include #include "riscv_internal.h" #include "c906.h" @@ -94,13 +93,9 @@ void up_irqinitialize(void) CURRENT_REGS = NULL; - /* Attach the ecall interrupt handler */ + /* Attach the common interrupt handler */ - irq_attach(RISCV_IRQ_ECALLM, riscv_swint, NULL); - -#ifdef CONFIG_BUILD_PROTECTED - irq_attach(RISCV_IRQ_ECALLU, riscv_swint, NULL); -#endif + riscv_exception_attach(); #ifndef CONFIG_SUPPRESS_INTERRUPTS diff --git a/arch/risc-v/src/c906/c906_irq_dispatch.c b/arch/risc-v/src/c906/c906_irq_dispatch.c index ec1eac0283700..6167ea0d09c2d 100644 --- a/arch/risc-v/src/c906/c906_irq_dispatch.c +++ b/arch/risc-v/src/c906/c906_irq_dispatch.c @@ -29,12 +29,12 @@ #include #include -#include -#include #include "riscv_internal.h" #include "group/group.h" +#include "c906_memorymap.h" + /**************************************************************************** * Pre-processor Definitions ****************************************************************************/ @@ -52,14 +52,6 @@ void *riscv_dispatch_irq(uintptr_t vector, uintptr_t *regs) { int irq = (vector >> RV_IRQ_MASK) | (vector & 0xf); - uintptr_t *mepc = regs; - - /* Check if fault happened */ - - if (vector < RISCV_IRQ_ECALLU) - { - riscv_fault(irq, regs); - } /* Firstly, check if the irq is machine external interrupt */ @@ -72,36 +64,17 @@ void *riscv_dispatch_irq(uintptr_t vector, uintptr_t *regs) irq = val + C906_IRQ_PERI_START; } - /* NOTE: In case of ecall, we need to adjust mepc in the context */ - - if (RISCV_IRQ_ECALLM == irq || RISCV_IRQ_ECALLU == irq) - { - *mepc += 4; - } - /* Acknowledge the interrupt */ riscv_ack_irq(irq); -#ifdef CONFIG_SUPPRESS_INTERRUPTS - PANIC(); -#else - /* Current regs non-zero indicates that we are processing an interrupt; - * CURRENT_REGS is also used to manage interrupt level context switches. - * - * Nested interrupts are not supported - */ - - ASSERT(CURRENT_REGS == NULL); - CURRENT_REGS = regs; - /* MEXT means no interrupt */ if (RISCV_IRQ_MEXT != irq) { /* Deliver the IRQ */ - irq_dispatch(irq, regs); + regs = riscv_doirq(irq, regs); } if (C906_IRQ_PERI_START <= irq) @@ -111,36 +84,5 @@ void *riscv_dispatch_irq(uintptr_t vector, uintptr_t *regs) putreg32(irq - C906_IRQ_PERI_START, C906_PLIC_MCLAIM); } - /* Check for a context switch. If a context switch occurred, then - * CURRENT_REGS will have a different value than it did on entry. If an - * interrupt level context switch has occurred, then restore the floating - * point state and the establish the correct address environment before - * returning from the interrupt. - */ - - if (regs != CURRENT_REGS) - { -#ifdef CONFIG_ARCH_ADDRENV - /* Make sure that the address environment for the previously - * running task is closed down gracefully (data caches dump, - * MMU flushed) and set up the address environment for the new - * thread at the head of the ready-to-run list. - */ - - group_addrenv(NULL); -#endif - } - -#endif /* CONFIG_SUPPRESS_INTERRUPTS */ - - /* If a context switch occurred while processing the interrupt then - * CURRENT_REGS may have change value. If we return any value different - * from the input regs, then the lower level will know that a context - * switch occurred during interrupt processing. - */ - - regs = (uintptr_t *)CURRENT_REGS; - CURRENT_REGS = NULL; - return regs; } diff --git a/arch/risc-v/src/c906/c906_start.c b/arch/risc-v/src/c906/c906_start.c index 6f2868320c399..3d53297e049dc 100644 --- a/arch/risc-v/src/c906/c906_start.c +++ b/arch/risc-v/src/c906/c906_start.c @@ -73,6 +73,10 @@ void __c906_start(uint32_t mhartid) const uint32_t *src; uint32_t *dest; + /* Configure FPU */ + + riscv_fpuconfig(); + if (0 != mhartid) { while (true); diff --git a/arch/risc-v/src/c906/c906_timerisr.c b/arch/risc-v/src/c906/c906_timerisr.c index 8fb9ce57a5ed6..81905a033dc5a 100644 --- a/arch/risc-v/src/c906/c906_timerisr.c +++ b/arch/risc-v/src/c906/c906_timerisr.c @@ -24,15 +24,19 @@ #include +#include #include #include #include #include #include +#include #include +#include "hardware/c906_clint.h" #include "riscv_internal.h" +#include "riscv_mtimer.h" #include "c906.h" #include "c906_clockconfig.h" @@ -40,68 +44,12 @@ * Pre-processor Definitions ****************************************************************************/ -#define getreg64(a) (*(volatile uint64_t *)(a)) -#define putreg64(v,a) (*(volatile uint64_t *)(a) = (v)) - #ifdef CONFIG_C906_WITH_QEMU -#define TICK_COUNT (10000000UL / TICK_PER_SEC) +#define MTIMER_FREQ 10000000UL #else -#define TICK_COUNT ((c906_get_cpuclk()) / TICK_PER_SEC) +#define MTIMER_FREQ c906_get_cpuclk() #endif -/**************************************************************************** - * Private Data - ****************************************************************************/ - -static bool _b_tick_started = false; - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: c906_reload_mtimecmp - ****************************************************************************/ - -static void c906_reload_mtimecmp(void) -{ - irqstate_t flags = spin_lock_irqsave(NULL); - - uint64_t current; - uint64_t next; - - if (!_b_tick_started) - { - _b_tick_started = true; - current = getreg64(C906_CLINT_MTIME); - } - else - { - current = getreg64(C906_CLINT_MTIMECMP); - } - - uint64_t tick = TICK_COUNT; - next = current + tick; - - putreg64(next, C906_CLINT_MTIMECMP); - - spin_unlock_irqrestore(NULL, flags); -} - -/**************************************************************************** - * Name: c906_timerisr - ****************************************************************************/ - -static int c906_timerisr(int irq, void *context, void *arg) -{ - c906_reload_mtimecmp(); - - /* Process timer interrupt */ - - nxsched_process_timer(); - return 0; -} - /**************************************************************************** * Public Functions ****************************************************************************/ @@ -117,15 +65,11 @@ static int c906_timerisr(int irq, void *context, void *arg) void up_timer_initialize(void) { - /* Attach timer interrupt handler */ - - irq_attach(RISCV_IRQ_MTIMER, c906_timerisr, NULL); - - /* Reload CLINT mtimecmp */ - - c906_reload_mtimecmp(); + struct oneshot_lowerhalf_s *lower = riscv_mtimer_initialize( + C906_CLINT_MTIME, C906_CLINT_MTIMECMP, + RISCV_IRQ_MTIMER, MTIMER_FREQ); - /* And enable the timer interrupt */ + DEBUGASSERT(lower); - up_enable_irq(RISCV_IRQ_MTIMER); + up_alarm_set_lowerhalf(lower); } diff --git a/arch/risc-v/src/common/Kconfig b/arch/risc-v/src/common/Kconfig deleted file mode 100644 index 44843f453f56f..0000000000000 --- a/arch/risc-v/src/common/Kconfig +++ /dev/null @@ -1,29 +0,0 @@ -# -# For a description of the syntax of this configuration file, -# see the file kconfig-language.txt in the NuttX tools repository. -# - -comment "RISC-V Common Options" - -choice - prompt "Toolchain Selection" - default RISCV_TOOLCHAIN_GNU_RVGW if TOOLCHAIN_WINDOWS - default RISCV_TOOLCHAIN_GNU_RVGL if !TOOLCHAIN_WINDOWS - -config RISCV_TOOLCHAIN_GNU_RVGL - bool "Generic GNU RVG toolchain under Linux (or other POSIX environment)" - select ARCH_TOOLCHAIN_GNU - ---help--- - This option should work for any modern GNU toolchain (GCC 5.2 or newer) - configured for riscv64-unknown-elf. - -config RISCV_TOOLCHAIN_GNU_RVGW - bool "Generic GNU RVG toolchain under Windows" - depends on TOOLCHAIN_WINDOWS - select CYGWIN_WINTOOL if WINDOWS_CYGWIN - select ARCH_TOOLCHAIN_GNU - ---help--- - This option should work for any modern GNU toolchain (GCC 5.2 or newer) - configured for riscv64-unknown-elf. - -endchoice diff --git a/arch/risc-v/src/common/Toolchain.defs b/arch/risc-v/src/common/Toolchain.defs index 1c871110dd0f1..174a20d44b58a 100644 --- a/arch/risc-v/src/common/Toolchain.defs +++ b/arch/risc-v/src/common/Toolchain.defs @@ -27,11 +27,7 @@ # command-line selection. # -ifeq ($(filter y, $(CONFIG_RISCV_TOOLCHAIN_GNU_RVGL)),y) - CONFIG_RISCV_TOOLCHAIN ?= GNU_RVG -endif - -ifeq ($(filter y, $(CONFIG_RISCV_TOOLCHAIN_GNU_RVGW)),y) +ifeq ($(filter y, $(CONFIG_RISCV_TOOLCHAIN_GNU_RVG)),y) CONFIG_RISCV_TOOLCHAIN ?= GNU_RVG endif @@ -43,20 +39,57 @@ endif # CROSSDEV The GNU toolchain triple (command prefix) # ARCHCPUFLAGS CPU-specific flags selecting the instruction set # options, etc. -# MAXOPTIMIZATION The maximum optimization level that results in +# ARCHOPTIMIZATION The optimization level that results in # reliable code generation. # ifeq ($(CONFIG_DEBUG_CUSTOMOPT),y) - MAXOPTIMIZATION := $(CONFIG_DEBUG_OPTLEVEL) -else - MAXOPTIMIZATION ?= -Os + ARCHOPTIMIZATION += $(CONFIG_DEBUG_OPTLEVEL) +else ifeq ($(CONFIG_DEBUG_FULLOPT),y) + ARCHOPTIMIZATION += -Os +endif + +ifneq ($(CONFIG_DEBUG_NOOPT),y) + ARCHOPTIMIZATION += -fno-strict-aliasing endif ifeq ($(CONFIG_FRAME_POINTER),y) - MAXOPTIMIZATION += -fno-omit-frame-pointer -fno-optimize-sibling-calls + ARCHOPTIMIZATION += -fno-omit-frame-pointer -fno-optimize-sibling-calls else - MAXOPTIMIZATION += -fomit-frame-pointer + ARCHOPTIMIZATION += -fomit-frame-pointer +endif + +ifeq ($(CONFIG_STACK_CANARIES),y) + ARCHOPTIMIZATION += -fstack-protector-all +endif + +ARCHCFLAGS += -fno-common +ARCHCXXFLAGS += -fno-common -nostdinc++ + +ifneq ($(CONFIG_CXX_EXCEPTION),y) + ARCHCXXFLAGS += -fno-exceptions -fcheck-new +endif + +ifneq ($(CONFIG_CXX_RTTI),y) + ARCHCXXFLAGS += -fno-rtti +endif + +# Optimization of unused sections + +ifeq ($(CONFIG_DEBUG_OPT_UNUSED_SECTIONS),y) + LDFLAGS += --gc-sections + ARCHOPTIMIZATION += -ffunction-sections -fdata-sections +endif + +# Debug link map + +ifeq ($(CONFIG_DEBUG_LINK_MAP),y) + LDFLAGS += --cref -Map=$(call CONVERT_PATH,$(TOPDIR)$(DELIM)nuttx.map) +endif + +ifeq ($(CONFIG_DEBUG_SYMBOLS),y) + LDFLAGS += -g + ARCHOPTIMIZATION += -g endif # Generic GNU RVG toolchain @@ -121,24 +154,38 @@ endif # Default toolchain -CC = $(CROSSDEV)gcc -CXX = $(CROSSDEV)g++ -CPP = $(CROSSDEV)gcc -E -P -x c -LD = $(CROSSDEV)ld -STRIP = $(CROSSDEV)strip --strip-unneeded -AR = $(CROSSDEV)ar rcs -NM = $(CROSSDEV)nm +CC = $(CROSSDEV)gcc +CXX = $(CROSSDEV)g++ +CPP = $(CROSSDEV)gcc -E -P -x c +STRIP = $(CROSSDEV)strip --strip-unneeded OBJCOPY = $(CROSSDEV)objcopy OBJDUMP = $(CROSSDEV)objdump +LD = $(CROSSDEV)ld +AR = $(CROSSDEV)ar rcs +NM = $(CROSSDEV)nm + +# Link Time Optimization + +ifeq ($(CONFIG_LTO_FULL),y) + ARCHOPTIMIZATION += -flto + ifeq ($(CONFIG_RISCV_TOOLCHAIN),GNU_RVG) + LD := $(CROSSDEV)gcc + AR := $(CROSSDEV)gcc-ar rcs + NM := $(CROSSDEV)gcc-nm + ARCHOPTIMIZATION += -fuse-linker-plugin + ARCHOPTIMIZATION += -fno-builtin + ARCHOPTIMIZATION += -nodefaultlibs + endif +endif # Add the builtin library -EXTRA_LIBS += ${wildcard ${shell $(CC) $(ARCHCPUFLAGS) --print-libgcc-file-name}} +EXTRA_LIBS += $(wildcard $(shell $(CC) $(ARCHCPUFLAGS) --print-libgcc-file-name)) ifneq ($(CONFIG_LIBM),y) - EXTRA_LIBS += ${wildcard ${shell $(CC) $(ARCHCPUFLAGS) --print-file-name=libm.a}} + EXTRA_LIBS += $(wildcard $(shell $(CC) $(ARCHCPUFLAGS) --print-file-name=libm.a)) endif ifeq ($(CONFIG_LIBSUPCXX),y) - EXTRA_LIBS += ${wildcard ${shell $(CC) $(ARCHCPUFLAGS) --print-file-name=libsupc++.a}} + EXTRA_LIBS += $(wildcard $(shell $(CC) $(ARCHCPUFLAGS) --print-file-name=libsupc++.a)) endif diff --git a/arch/risc-v/src/common/crt0.c b/arch/risc-v/src/common/crt0.c new file mode 100644 index 0000000000000..0ca5815d683f5 --- /dev/null +++ b/arch/risc-v/src/common/crt0.c @@ -0,0 +1,140 @@ +/**************************************************************************** + * arch/risc-v/src/common/crt0.c + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include +#include + +#include +#include +#include + +#include +#include + +#include "riscv_internal.h" + +#ifdef CONFIG_BUILD_KERNEL + +/**************************************************************************** + * Public Function Prototypes + ****************************************************************************/ + +int main(int argc, char *argv[]); + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: up_signal_handler + * + * Description: + * This function is the user-space, signal handler trampoline function. It + * is called from up_signal_dispatch() in user-mode. + * + * Input Parameters: + * a0 = sighand + * The address user-space signal handling function + * a1-a3 = signo, info, and ucontext + * Standard arguments to be passed to the signal handling function. + * + * Returned Value: + * None. This function does not return in the normal sense. It returns + * via the SYS_signal_handler_return (see syscall.h) + * + ****************************************************************************/ + +static void sig_trampoline(void) naked_function; +static void sig_trampoline(void) +{ + __asm__ __volatile__ + ( + " addi sp, sp, -" STACK_FRAME_SIZE "\n" /* Save ra on the stack */ + REGSTORE " ra, 0(sp)\n" + " mv t0, a0\n" /* t0=sighand */ + " mv a0, a1\n" /* a0=signo */ + " mv a1, a2\n" /* a1=info */ + " mv a2, a3\n" /* a2=ucontext */ + " jalr t0\n" /* Call the signal handler (modifies ra) */ + REGLOAD " ra, 0(sp)\n" /* Recover ra in sp */ + " addi sp, sp, " STACK_FRAME_SIZE "\n" + " li a0, %0\n" /* SYS_signal_handler_return */ + " ecall\n" /* Return from the SYSCALL */ + " nop\n" + : + : "i" (SYS_signal_handler_return) + : + ); +} + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: _start + * + * Description: + * This function is the low level entry point into the main thread of + * execution of a task. It receives initial control when the task is + * started and calls main entry point of the newly started task. + * + * Input Parameters: + * argc - The number of parameters being passed. + * argv - The parameters being passed. These lie in kernel-space memory + * and will have to be reallocated in user-space memory. + * + * Returned Value: + * This function should not return. It should call the user-mode start-up + * main() function. If that function returns, this function will call + * exit. + * + ****************************************************************************/ + +void _start(int argc, char *argv[]) +{ + int ret; + + /* Initialize the reserved area at the beginning of the .bss/.data region + * that is visible to the RTOS. + */ + + ARCH_DATA_RESERVE->ar_sigtramp = (addrenv_sigtramp_t)sig_trampoline; + + /* Call C++ constructors */ + + /* Setup so that C++ destructors called on task exit */ + + /* REVISIT: Missing logic */ + + /* Call the main() entry point passing argc and argv. */ + + ret = main(argc, argv); + + /* Call exit() if/when the main() returns */ + + exit(ret); +} + +#endif /* CONFIG_BUILD_KERNEL */ diff --git a/arch/arm/src/armv7-a/arm_savefpu.S b/arch/risc-v/src/common/pgalloc.h similarity index 55% rename from arch/arm/src/armv7-a/arm_savefpu.S rename to arch/risc-v/src/common/pgalloc.h index caf8e7e455c4a..db31a247aa493 100644 --- a/arch/arm/src/armv7-a/arm_savefpu.S +++ b/arch/risc-v/src/common/pgalloc.h @@ -1,5 +1,5 @@ /**************************************************************************** - * arch/arm/src/armv7-a/arm_savefpu.S + * arch/risc-v/src/common/pgalloc.h * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with @@ -18,79 +18,82 @@ * ****************************************************************************/ +#ifndef __ARCH_RISC_V_SRC_COMMON_PGALLOC_H +#define __ARCH_RISC_V_SRC_COMMON_PGALLOC_H + +#ifdef CONFIG_MM_PGALLOC + /**************************************************************************** * Included Files ****************************************************************************/ #include -#include - -#ifdef CONFIG_ARCH_FPU - - .file "arm_savefpu.S" +#include +#include /**************************************************************************** * Pre-processor Definitions ****************************************************************************/ -/**************************************************************************** - * Public Symbols - ****************************************************************************/ - - .globl arm_savefpu +#ifndef CONFIG_ARCH_PGPOOL_MAPPING +# error "RISC-V needs CONFIG_ARCH_PGPOOL_MAPPING" +#endif /**************************************************************************** - * Public Functions + * Public Functions Prototypes ****************************************************************************/ - .text - /**************************************************************************** - * Name: arm_savefpu + * Name: riscv_pgvaddr * * Description: - * Given the pointer to a register save area (in R0), save the state of the - * floating point registers. + * Get virtual address for pgpool physical address. Note: this function + * is minimalistic and is only usable for kernel mappings and only tests + * if the paddr is in the pgpool. For user mapped addresses this does not + * work. * - * C Function Prototype: - * void arm_savefpu(uint32_t *regs); + * Note: + * To get it to work with user addresses, a manual table walk needs to be + * implemented. Not too complex, but not needed for anything -> not + * implemented. * * Input Parameters: - * regs - A pointer to the register save area in which to save the floating point - * registers + * paddr - Physical pgpool address * - * Returned Value: - * None + * Return: + * vaddr - Virtual address for physical address * ****************************************************************************/ - .globl arm_savefpu - .type arm_savefpu, function - -arm_savefpu: +#ifdef CONFIG_ARCH_PGPOOL_MAPPING +static inline uintptr_t riscv_pgvaddr(uintptr_t paddr) +{ + if (paddr >= CONFIG_ARCH_PGPOOL_PBASE && paddr < CONFIG_ARCH_PGPOOL_PEND) + { + return paddr - CONFIG_ARCH_PGPOOL_PBASE + CONFIG_ARCH_PGPOOL_VBASE; + } - add r1, r0, #(4*REG_S0) /* R1=Address of FP register storage */ + return 0; +} +#endif /* CONFIG_ARCH_PGPOOL_MAPPING */ - /* Store all floating point registers. Registers are stored in numeric order, - * s0, s1, ... in increasing address order. - */ - -#ifdef CONFIG_ARM_DPFPU32 - vstmia.64 r1!, {d0-d15} /* Save the full FP context */ - vstmia.64 r1!, {d16-d31} -#else - vstmia r1!, {s0-s31} /* Save the full FP context */ -#endif - - /* Store the floating point control and status register. At the end of the - * vstmia, r1 will point to the FPSCR storage location. - */ +/**************************************************************************** + * Name: riscv_pgwipe + * + * Description: + * Wipe a page of physical memory, first mapping it into virtual memory. + * + * Input Parameters: + * paddr - Physical address of page + * + ****************************************************************************/ - vmrs r2, fpscr /* Fetch the FPSCR */ - str r2, [r1], #4 /* Save the floating point control and status register */ - bx lr +static inline void riscv_pgwipe(uintptr_t paddr) +{ + uintptr_t vaddr = riscv_pgvaddr(paddr); + memset((void *)vaddr, 0, MM_PGSIZE); +} - .size arm_savefpu, .-arm_savefpu -#endif /* CONFIG_ARCH_FPU */ - .end +#endif /* CONFIG_MM_PGALLOC */ +#endif /* __ARCH_RISC_V_SRC_COMMON_PGALLOC_H */ diff --git a/arch/risc-v/src/common/riscv_addrenv.c b/arch/risc-v/src/common/riscv_addrenv.c new file mode 100644 index 0000000000000..df981d1660b82 --- /dev/null +++ b/arch/risc-v/src/common/riscv_addrenv.c @@ -0,0 +1,815 @@ +/**************************************************************************** + * arch/risc-v/src/common/riscv_addrenv.c + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +/**************************************************************************** + * Address Environment Interfaces + * + * Low-level interfaces used in binfmt/ to instantiate tasks with address + * environments. These interfaces all operate on type group_addrenv_t which + * is an abstract representation of a task group's address environment and + * must be defined in arch/arch.h if CONFIG_ARCH_ADDRENV is defined. + * + * up_addrenv_create - Create an address environment + * up_addrenv_destroy - Destroy an address environment. + * up_addrenv_vtext - Returns the virtual base address of the .text + * address environment + * up_addrenv_vdata - Returns the virtual base address of the .bss/.data + * address environment + * up_addrenv_heapsize - Returns the size of the initial heap allocation. + * up_addrenv_select - Instantiate an address environment + * up_addrenv_restore - Restore an address environment + * up_addrenv_clone - Copy an address environment from one location to + * another. + * + * Higher-level interfaces used by the tasking logic. These interfaces are + * used by the functions in sched/ and all operate on the thread which whose + * group been assigned an address environment by up_addrenv_clone(). + * + * up_addrenv_attach - Clone the address environment assigned to one TCB + * to another. This operation is done when a pthread + * is created that share's the same address + * environment. + * up_addrenv_detach - Release the threads reference to an address + * environment when a task/thread exits. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include +#include +#include + +#include +#include +#include +#include + +#include + +#include "pgalloc.h" +#include "riscv_mmu.h" + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/* Only CONFIG_BUILD_KERNEL is supported (i.e. tested) */ + +#ifndef CONFIG_BUILD_KERNEL +# error "This module is intended to be used with CONFIG_BUILD_KERNEL" +#endif + +/* Entries per PGT */ + +#define ENTRIES_PER_PGT (RV_MMU_PAGE_ENTRIES) + +/* Base address for address environment */ + +#define ADDRENV_VBASE (CONFIG_ARCH_DATA_VBASE) + +/**************************************************************************** + * Public Data + ****************************************************************************/ + +extern uintptr_t g_kernel_mappings; + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: map_spgtables + * + * Description: + * Map vaddr to the static page tables. + * + * Input Parameters: + * addrenv - Describes the address environment + * + ****************************************************************************/ + +static void map_spgtables(group_addrenv_t *addrenv, uintptr_t vaddr) +{ + int i; + uintptr_t prev; + + /* Start from L1, and connect until max level - 1 */ + + prev = riscv_pgvaddr(addrenv->spgtables[0]); + + /* Check if the mapping already exists */ + + if (mmu_ln_getentry(1, prev, vaddr) != 0) + { + return; + } + + /* No mapping yet, create it */ + + for (i = 0; i < (ARCH_SPGTS - 1); i++) + { + uintptr_t next = riscv_pgvaddr(addrenv->spgtables[i + 1]); + mmu_ln_setentry(i + 1, prev, next, vaddr, MMU_UPGT_FLAGS); + prev = next; + } +} + +/**************************************************************************** + * Name: create_spgtables + * + * Description: + * Create the static page tables. Allocate memory for them and connect them + * together. + * + * Input Parameters: + * addrenv - Describes the address environment + * + * Returned value: + * Amount of pages created on success; a negated errno value on failure + * + ****************************************************************************/ + +static int create_spgtables(group_addrenv_t *addrenv) +{ + int i; + uintptr_t paddr; + + for (i = 0; i < ARCH_SPGTS; i++) + { + paddr = mm_pgalloc(1); + if (!paddr) + { + return -ENOMEM; + } + + /* Wipe the memory and assign it */ + + riscv_pgwipe(paddr); + addrenv->spgtables[i] = paddr; + } + + /* Flush the data cache, so the changes are committed to memory */ + + __DMB(); + + return i; +} + +/**************************************************************************** + * Name: copy_kernel_mappings + * + * Description: + * Copy kernel mappings to address environment. Expects that the user page + * table does not contain any mappings yet (as they will be wiped). + * + * Input Parameters: + * addrenv - Describes the address environment. The page tables must exist + * at this point. + * + * Returned value: + * OK on success, ERROR on failure + * + ****************************************************************************/ + +static int copy_kernel_mappings(group_addrenv_t *addrenv) +{ + uintptr_t user_mappings = riscv_pgvaddr(addrenv->spgtables[0]); + + /* Copy the L1 references */ + + if (user_mappings == 0) + { + return -EINVAL; + } + + memcpy((void *)user_mappings, (void *)g_kernel_mappings, RV_MMU_PAGE_SIZE); + + return OK; +} + +/**************************************************************************** + * Name: create_region + * + * Description: + * Map a single region of memory to MMU. Assumes that the static page + * tables exist. Allocates the final level page tables and commits the + * region memory to physical memory. + * + * Input Parameters: + * addrenv - Describes the address environment + * vaddr - Base virtual address for the mapping + * size - Size of the region in bytes + * mmuflags - MMU flags to use + * + * Returned value: + * Amount of pages created on success; a negated errno value on failure + * + ****************************************************************************/ + +static int create_region(group_addrenv_t *addrenv, uintptr_t vaddr, + size_t size, uint32_t mmuflags) +{ + uintptr_t ptlast; + uintptr_t ptprev; + uintptr_t paddr; + uint32_t ptlevel; + int npages; + int nmapped; + int i; + int j; + + nmapped = 0; + npages = MM_NPAGES(size); + ptprev = riscv_pgvaddr(addrenv->spgtables[ARCH_SPGTS - 1]); + ptlevel = ARCH_SPGTS; + + /* Create mappings for the lower level tables */ + + map_spgtables(addrenv, vaddr); + + /* Begin allocating memory for the page tables */ + + for (i = 0; i < npages; i += ENTRIES_PER_PGT) + { + /* Get the current final level entry corresponding to this vaddr */ + + paddr = mmu_pte_to_paddr(mmu_ln_getentry(ptlevel, ptprev, vaddr)); + + if (!paddr) + { + /* Nothing yet, allocate one page for final level page table */ + + paddr = mm_pgalloc(1); + if (!paddr) + { + return -ENOMEM; + } + + /* Map the page table to the prior level */ + + mmu_ln_setentry(ptlevel, ptprev, paddr, vaddr, MMU_UPGT_FLAGS); + + /* This is then used to map the final level */ + + riscv_pgwipe(paddr); + } + + ptlast = riscv_pgvaddr(paddr); + + /* Then allocate memory for the region data */ + + for (j = 0; j < ENTRIES_PER_PGT && nmapped < size; j++) + { + paddr = mm_pgalloc(1); + if (!paddr) + { + return -ENOMEM; + } + + /* Wipe the physical page memory */ + + riscv_pgwipe(paddr); + + /* Then map the virtual address to the physical address */ + + mmu_ln_setentry(ptlevel + 1, ptlast, paddr, vaddr, mmuflags); + nmapped += MM_PGSIZE; + vaddr += MM_PGSIZE; + } + } + + /* Flush the data cache, so the changes are committed to memory */ + + __DMB(); + + return npages; +} + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: up_addrenv_create + * + * Description: + * This function is called when a new task is created in order to + * instantiate an address environment for the new task group. + * up_addrenv_create() is essentially the allocator of the physical + * memory for the new task. + * + * Input Parameters: + * textsize - The size (in bytes) of the .text address environment needed + * by the task. This region may be read/execute only. + * datasize - The size (in bytes) of the .data/.bss address environment + * needed by the task. This region may be read/write only. NOTE: The + * actual size of the data region that is allocated will include a + * OS private reserved region at the beginning. The size of the + * private, reserved region is give by ARCH_DATA_RESERVE_SIZE. + * heapsize - The initial size (in bytes) of the heap address environment + * needed by the task. This region may be read/write only. + * addrenv - The location to return the representation of the task address + * environment. + * + * Returned Value: + * Zero (OK) on success; a negated errno value on failure. + * + ****************************************************************************/ + +int up_addrenv_create(size_t textsize, size_t datasize, size_t heapsize, + group_addrenv_t *addrenv) +{ + int ret; + uintptr_t resvbase; + uintptr_t resvsize; + uintptr_t textbase; + uintptr_t database; + uintptr_t heapbase; + + DEBUGASSERT(addrenv); + DEBUGASSERT(MM_ISALIGNED(ADDRENV_VBASE)); + + /* Make sure the address environment is wiped before doing anything */ + + memset(addrenv, 0, sizeof(group_addrenv_t)); + + /* Create the static page tables */ + + ret = create_spgtables(addrenv); + + if (ret < 0) + { + serr("ERROR: Failed to create static page tables\n"); + goto errout; + } + + /* Map the kernel memory for the user */ + + ret = copy_kernel_mappings(addrenv); + + if (ret < 0) + { + serr("ERROR: Failed to copy kernel mappings to new environment"); + goto errout; + } + + /* Calculate the base addresses for convenience */ + + resvbase = ADDRENV_VBASE; + resvsize = ARCH_DATA_RESERVE_SIZE; + textbase = resvbase + MM_PGALIGNUP(resvsize); + database = textbase + MM_PGALIGNUP(textsize); + heapbase = database + MM_PGALIGNUP(datasize); + + /* Allocate 1 extra page for heap, temporary fix for #5811 */ + + heapsize = heapsize + MM_PGALIGNUP(1); + + /* Map the reserved area */ + + ret = create_region(addrenv, resvbase, resvsize, MMU_UDATA_FLAGS); + + if (ret < 0) + { + berr("ERROR: Failed to create reserved region: %d\n", ret); + goto errout; + } + + /* Map each region in turn */ + + ret = create_region(addrenv, textbase, textsize, MMU_UTEXT_FLAGS); + + if (ret < 0) + { + berr("ERROR: Failed to create .text region: %d\n", ret); + goto errout; + } + + ret = create_region(addrenv, database, datasize, MMU_UDATA_FLAGS); + + if (ret < 0) + { + berr("ERROR: Failed to create .bss/.data region: %d\n", ret); + goto errout; + } + + ret = create_region(addrenv, heapbase, heapsize, MMU_UDATA_FLAGS); + + if (ret < 0) + { + berr("ERROR: Failed to create heap region: %d\n", ret); + goto errout; + } + + /* Save the heap base and initial size allocated. These will be needed when + * the heap data structures are initialized. + */ + + addrenv->heapvbase = heapbase; + addrenv->heapsize = (size_t)ret << MM_PGSHIFT; + + /* Save the text base */ + + addrenv->textvbase = textbase; + + /* Save the data base */ + + addrenv->datavbase = database; + + /* Provide the satp value for context switch */ + + addrenv->satp = mmu_satp_reg(addrenv->spgtables[0], 0); + + /* When all is set and done, flush the data caches */ + + __ISB(); + __DMB(); + + return OK; + +errout: + up_addrenv_destroy(addrenv); + return ret; +} + +/**************************************************************************** + * Name: up_addrenv_destroy + * + * Description: + * This function is called when a final thread leaves the task group and + * the task group is destroyed. This function then destroys the defunct + * address environment, releasing the underlying physical memory. + * + * Input Parameters: + * addrenv - The address environment to be destroyed. + * + * Returned Value: + * Zero (OK) on success; a negated errno value on failure. + * + ****************************************************************************/ + +int up_addrenv_destroy(group_addrenv_t *addrenv) +{ + /* Recursively destroy it all, need to table walk */ + + uintptr_t *ptprev; + uintptr_t *ptlast; + uintptr_t paddr; + int i; + int j; + + DEBUGASSERT(addrenv); + + /* Make sure the caches are flushed before doing this */ + + __ISB(); + __DMB(); + + /* First destroy the allocated memory and the final level page table */ + + ptprev = (uintptr_t *)riscv_pgvaddr(addrenv->spgtables[ARCH_SPGTS - 1]); + if (ptprev) + { + for (i = 0; i < ENTRIES_PER_PGT; i++) + { + ptlast = (uintptr_t *)riscv_pgvaddr(mmu_pte_to_paddr(ptprev[i])); + if (ptlast) + { + /* Page table allocated, free any allocated memory */ + + for (j = 0; j < ENTRIES_PER_PGT; j++) + { + paddr = mmu_pte_to_paddr(ptlast[j]); + if (paddr) + { + mm_pgfree(paddr, 1); + } + } + + /* Then free the page table itself */ + + mm_pgfree((uintptr_t)ptlast, 1); + } + } + } + + /* Then destroy the static tables */ + + for (i = 0; i < ARCH_SPGTS; i++) + { + paddr = addrenv->spgtables[i]; + if (paddr) + { + mm_pgfree(paddr, 1); + } + } + + /* When all is set and done, flush the caches */ + + __ISB(); + __DMB(); + + memset(addrenv, 0, sizeof(group_addrenv_t)); + return OK; +} + +/**************************************************************************** + * Name: up_addrenv_vtext + * + * Description: + * Return the virtual address associated with the newly create .text + * address environment. This function is used by the binary loaders in + * order get an address that can be used to initialize the new task. + * + * Input Parameters: + * addrenv - The representation of the task address environment previously + * returned by up_addrenv_create. + * vtext - The location to return the virtual address. + * + * Returned Value: + * Zero (OK) on success; a negated errno value on failure. + * + ****************************************************************************/ + +int up_addrenv_vtext(group_addrenv_t *addrenv, void **vtext) +{ + DEBUGASSERT(addrenv && vtext); + *vtext = (void *)addrenv->textvbase; + return OK; +} + +/**************************************************************************** + * Name: up_addrenv_vdata + * + * Description: + * Return the virtual address associated with the newly create .text + * address environment. This function is used by the binary loaders in + * order get an address that can be used to initialize the new task. + * + * Input Parameters: + * addrenv - The representation of the task address environment previously + * returned by up_addrenv_create. + * textsize - For some implementations, the text and data will be saved + * in the same memory region (read/write/execute) and, in this case, + * the virtual address of the data just lies at this offset into the + * common region. + * vdata - The location to return the virtual address. + * + * Returned Value: + * Zero (OK) on success; a negated errno value on failure. + * + ****************************************************************************/ + +int up_addrenv_vdata(group_addrenv_t *addrenv, uintptr_t textsize, + void **vdata) +{ + DEBUGASSERT(addrenv && vdata); + *vdata = (void *)addrenv->datavbase; + return OK; +} + +/**************************************************************************** + * Name: up_addrenv_vheap + * + * Description: + * Return the heap virtual address associated with the newly created + * address environment. This function is used by the binary loaders in + * order get an address that can be used to initialize the new task. + * + * Input Parameters: + * addrenv - The representation of the task address environment previously + * returned by up_addrenv_create. + * vheap - The location to return the virtual address. + * + * Returned Value: + * Zero (OK) on success; a negated errno value on failure. + * + ****************************************************************************/ + +#ifdef CONFIG_BUILD_KERNEL +int up_addrenv_vheap(const group_addrenv_t *addrenv, void **vheap) +{ + DEBUGASSERT(addrenv && vheap); + *vheap = (void *)addrenv->heapvbase; + return OK; +} +#endif + +/**************************************************************************** + * Name: up_addrenv_heapsize + * + * Description: + * Return the initial heap allocation size. That is the amount of memory + * allocated by up_addrenv_create() when the heap memory region was first + * created. This may or may not differ from the heapsize parameter that + * was passed to up_addrenv_create() + * + * Input Parameters: + * addrenv - The representation of the task address environment previously + * returned by up_addrenv_create. + * + * Returned Value: + * The initial heap size allocated is returned on success; a negated + * errno value on failure. + * + ****************************************************************************/ + +#ifdef CONFIG_BUILD_KERNEL +ssize_t up_addrenv_heapsize(const group_addrenv_t *addrenv) +{ + DEBUGASSERT(addrenv); + return (ssize_t)addrenv->heapsize; +} +#endif + +/**************************************************************************** + * Name: up_addrenv_select + * + * Description: + * After an address environment has been established for a task (via + * up_addrenv_create()), this function may be called to instantiate + * that address environment in the virtual address space. This might be + * necessary, for example, to load the code for the task from a file or + * to access address environment private data. + * + * Input Parameters: + * addrenv - The representation of the task address environment previously + * returned by up_addrenv_create. + * oldenv + * The address environment that was in place before up_addrenv_select(). + * This may be used with up_addrenv_restore() to restore the original + * address environment that was in place before up_addrenv_select() was + * called. Note that this may be a task agnostic, hardware + * representation that is different from group_addrenv_t. + * + * Returned Value: + * Zero (OK) on success; a negated errno value on failure. + * + ****************************************************************************/ + +int up_addrenv_select(const group_addrenv_t *addrenv, + save_addrenv_t *oldenv) +{ + DEBUGASSERT(addrenv); + if (oldenv) + { + /* Save the old environment */ + + uintptr_t satp_reg = mmu_read_satp(); + *oldenv = (save_addrenv_t)satp_reg; + } + + mmu_write_satp(addrenv->satp); + return OK; +} + +/**************************************************************************** + * Name: up_addrenv_restore + * + * Description: + * After an address environment has been temporarily instantiated by + * up_addrenv_select, this function may be called to restore the + * original address environment. + * + * Input Parameters: + * oldenv - The hardware representation of the address environment + * previously returned by up_addrenv_select. + * + * Returned Value: + * Zero (OK) on success; a negated errno value on failure. + * + ****************************************************************************/ + +int up_addrenv_restore(const save_addrenv_t *oldenv) +{ + DEBUGASSERT(oldenv); + mmu_write_satp((uintptr_t)*oldenv); + return OK; +} + +/**************************************************************************** + * Name: up_addrenv_coherent + * + * Description: + * Flush D-Cache and invalidate I-Cache in preparation for a change in + * address environments. This should immediately precede a call to + * up_addrenv_select(); + * + * Input Parameters: + * addrenv - Describes the address environment to be made coherent. + * + * Returned Value: + * Zero (OK) on success; a negated errno value on failure. + * + ****************************************************************************/ + +int up_addrenv_coherent(const group_addrenv_t *addrenv) +{ + /* Flush the instruction and data caches */ + + __ISB(); + __DMB(); + return OK; +} + +/**************************************************************************** + * Name: up_addrenv_clone + * + * Description: + * Duplicate an address environment. This does not copy the underlying + * memory, only the representation that can be used to instantiate that + * memory as an address environment. + * + * Input Parameters: + * src - The address environment to be copied. + * dest - The location to receive the copied address environment. + * + * Returned Value: + * Zero (OK) on success; a negated errno value on failure. + * + ****************************************************************************/ + +int up_addrenv_clone(const group_addrenv_t *src, + group_addrenv_t *dest) +{ + DEBUGASSERT(src && dest); + memcpy(dest, src, sizeof(group_addrenv_t)); + return OK; +} + +/**************************************************************************** + * Name: up_addrenv_attach + * + * Description: + * This function is called from the core scheduler logic when a thread + * is created that needs to share the address environment of its task + * group. + * + * Input Parameters: + * group - The task group to which the new thread belongs. + * tcb - The tcb of the thread needing the address environment. + * + * Returned Value: + * Zero (OK) on success; a negated errno value on failure. + * + ****************************************************************************/ + +int up_addrenv_attach(struct task_group_s *group, struct tcb_s *tcb) +{ + /* There is nothing that needs to be done */ + + return OK; +} + +/**************************************************************************** + * Name: up_addrenv_detach + * + * Description: + * This function is called when a task or thread exits in order to release + * its reference to an address environment. The address environment, + * however, should persist until up_addrenv_destroy() is called when the + * task group is itself destroyed. Any resources unique to this thread + * may be destroyed now. + * + * NOTE: In some platforms, nothing will need to be done in this case. + * Simply being a member of the group that has the address environment + * may be sufficient. + * + * Input Parameters: + * group - The group to which the thread belonged. + * tcb - The TCB of the task or thread whose the address environment will + * be released. + * + * Returned Value: + * Zero (OK) on success; a negated errno value on failure. + * + ****************************************************************************/ + +int up_addrenv_detach(struct task_group_s *group, struct tcb_s *tcb) +{ + /* There is nothing that needs to be done */ + + return OK; +} diff --git a/arch/risc-v/src/common/riscv_addrenv_kstack.c b/arch/risc-v/src/common/riscv_addrenv_kstack.c index c0fd0f0a1556e..357e035f791d1 100644 --- a/arch/risc-v/src/common/riscv_addrenv_kstack.c +++ b/arch/risc-v/src/common/riscv_addrenv_kstack.c @@ -59,7 +59,7 @@ * ****************************************************************************/ -int up_addrenv_kstackalloc(FAR struct tcb_s *tcb) +int up_addrenv_kstackalloc(struct tcb_s *tcb) { DEBUGASSERT(tcb && tcb->xcp.kstack == NULL); @@ -91,7 +91,7 @@ int up_addrenv_kstackalloc(FAR struct tcb_s *tcb) * ****************************************************************************/ -int up_addrenv_kstackfree(FAR struct tcb_s *tcb) +int up_addrenv_kstackfree(struct tcb_s *tcb) { DEBUGASSERT(tcb); diff --git a/arch/risc-v/src/common/riscv_addrenv_perms.c b/arch/risc-v/src/common/riscv_addrenv_perms.c new file mode 100644 index 0000000000000..a234b647a61b3 --- /dev/null +++ b/arch/risc-v/src/common/riscv_addrenv_perms.c @@ -0,0 +1,151 @@ +/**************************************************************************** + * arch/risc-v/src/common/riscv_addrenv_perms.c + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include +#include + +#include +#include +#include + +#include + +#include "pgalloc.h" +#include "riscv_mmu.h" + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +static int modify_region(uintptr_t vstart, uintptr_t vend, uintptr_t setmask, + uintptr_t clrmask) +{ + uintptr_t l1vaddr; + uintptr_t lnvaddr; + uintptr_t entry; + uintptr_t paddr; + uintptr_t vaddr; + uint32_t ptlevel; + + /* Must perform a reverse table walk */ + + l1vaddr = riscv_pgvaddr(mmu_get_satp_pgbase()); + + if (!l1vaddr) + { + /* Oops, there is no address environment to modify at all ? */ + + return -EINVAL; + } + + for (vaddr = vstart; vaddr < vend; vaddr += MM_PGSIZE) + { + for (ptlevel = 1, lnvaddr = l1vaddr; + ptlevel < RV_MMU_PT_LEVELS; + ptlevel++) + { + paddr = mmu_pte_to_paddr(mmu_ln_getentry(ptlevel, lnvaddr, vaddr)); + lnvaddr = riscv_pgvaddr(paddr); + if (!lnvaddr) + { + return -EINVAL; + } + } + + /* Get entry and modify the flags */ + + entry = mmu_ln_getentry(ptlevel, lnvaddr, vaddr); + entry &= ~clrmask; + entry |= setmask; + + /* Restore the entry */ + + mmu_ln_restore(ptlevel, lnvaddr, vaddr, entry); + } + + /* When all is set and done, flush the data caches */ + + __ISB(); + __DMB(); + + return OK; +} + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: up_addrenv_text_enable_write + * + * Description: + * Temporarily enable write access to the .text section. This must be + * called prior to loading the process code into memory. + * + * Input Parameters: + * addrenv - The address environment to be modified. + * + * Returned Value: + * Zero (OK) on success; a negated errno value on failure. + * + ****************************************************************************/ + +int up_addrenv_text_enable_write(group_addrenv_t *addrenv) +{ + /* Sanity checks */ + + DEBUGASSERT(addrenv); + DEBUGASSERT(MM_ISALIGNED(addrenv->textvbase)); + DEBUGASSERT(MM_ISALIGNED(addrenv->datavbase)); + + return modify_region(addrenv->textvbase, addrenv->datavbase, PTE_W, 0); +} + +/**************************************************************************** + * Name: up_addrenv_text_disable_write + * + * Description: + * Disable write access to the .text section. This must be called after the + * process code is loaded into memory. + * + * Input Parameters: + * addrenv - The address environment to be modified. + * + * Returned Value: + * Zero (OK) on success; a negated errno value on failure. + * + ****************************************************************************/ + +int up_addrenv_text_disable_write(group_addrenv_t *addrenv) +{ + /* Sanity checks */ + + DEBUGASSERT(addrenv); + DEBUGASSERT(MM_ISALIGNED(addrenv->textvbase)); + DEBUGASSERT(MM_ISALIGNED(addrenv->datavbase)); + + return modify_region(addrenv->textvbase, addrenv->datavbase, 0, PTE_W); +} diff --git a/arch/risc-v/src/common/riscv_assert.c b/arch/risc-v/src/common/riscv_assert.c index 39b6a2b49321f..3844823ce43b8 100644 --- a/arch/risc-v/src/common/riscv_assert.c +++ b/arch/risc-v/src/common/riscv_assert.c @@ -332,12 +332,11 @@ static void riscv_dumpstate(void) if (CURRENT_REGS) { - memcpy(rtcb->xcp.regs, - (uintptr_t *)CURRENT_REGS, XCPTCONTEXT_SIZE); + rtcb->xcp.regs = (uintptr_t *)CURRENT_REGS; } else { - riscv_saveusercontext(rtcb->xcp.regs); + up_saveusercontext(rtcb->xcp.regs); } /* Dump the registers (if available) */ diff --git a/arch/risc-v/src/common/riscv_blocktask.c b/arch/risc-v/src/common/riscv_blocktask.c index 00fa65d0ab66c..b3833c225a4bc 100644 --- a/arch/risc-v/src/common/riscv_blocktask.c +++ b/arch/risc-v/src/common/riscv_blocktask.c @@ -136,15 +136,6 @@ void up_block_task(struct tcb_s *tcb, tstate_t task_state) struct tcb_s *nexttcb = this_task(); -#ifdef CONFIG_ARCH_ADDRENV - /* Make sure that the address environment for the previously - * running task is closed down gracefully (data caches dump, - * MMU flushed) and set up the address environment for the new - * thread at the head of the ready-to-run list. - */ - - (void)group_addrenv(nexttcb); -#endif /* Reset scheduler parameters */ nxsched_resume_scheduler(nexttcb); diff --git a/arch/risc-v/src/common/riscv_checkstack.c b/arch/risc-v/src/common/riscv_checkstack.c index b384f95267532..2f8e0a0580961 100644 --- a/arch/risc-v/src/common/riscv_checkstack.c +++ b/arch/risc-v/src/common/riscv_checkstack.c @@ -31,7 +31,6 @@ #include #include -#include #include "sched/sched.h" #include "riscv_internal.h" diff --git a/arch/risc-v/src/common/riscv_copystate.c b/arch/risc-v/src/common/riscv_copystate.c index 004aa15dd76cd..064e1af522690 100644 --- a/arch/risc-v/src/common/riscv_copystate.c +++ b/arch/risc-v/src/common/riscv_copystate.c @@ -55,10 +55,6 @@ void riscv_copystate(uintptr_t *dest, uintptr_t *src) { int i; -#ifdef CONFIG_ARCH_FPU - uintptr_t *regs = dest; -#endif - /* In the RISC-V model, the state is copied from the stack to the TCB, * but only a reference is passed to get the state from the TCB. So the * following check avoids copying the TCB save area onto itself: @@ -68,18 +64,9 @@ void riscv_copystate(uintptr_t *dest, uintptr_t *src) { /* save integer registers first */ - for (i = 0; i < INT_XCPT_REGS; i++) + for (i = 0; i < XCPTCONTEXT_REGS; i++) { *dest++ = *src++; } - - /* Save the floating point registers: This will initialize the floating - * registers at indices INT_XCPT_REGS through (XCPTCONTEXT_REGS-1). - * Do this after saving REG_INT_CTX with the ORIGINAL context pointer. - */ - -#ifdef CONFIG_ARCH_FPU - riscv_savefpu(regs); -#endif } } diff --git a/arch/risc-v/src/common/riscv_cpuindex.c b/arch/risc-v/src/common/riscv_cpuindex.c index fbf4e9face411..c3ce34118b7ed 100644 --- a/arch/risc-v/src/common/riscv_cpuindex.c +++ b/arch/risc-v/src/common/riscv_cpuindex.c @@ -23,10 +23,11 @@ ****************************************************************************/ #include + #include -#include -#include +#include +#include #include "riscv_internal.h" @@ -34,22 +35,6 @@ * Public Functions ****************************************************************************/ -/**************************************************************************** - * Name: riscv_mhartid - * - * Description: - * Context aware way to query hart id - * - * Returned Value: - * Hart id - * - ****************************************************************************/ - -uintptr_t riscv_mhartid(void) -{ - return READ_CSR(mhartid); -} - /**************************************************************************** * Name: up_cpu_index * diff --git a/arch/risc-v/src/common/riscv_createstack.c b/arch/risc-v/src/common/riscv_createstack.c index 29dd8b96a6897..c15e1b0e8113c 100644 --- a/arch/risc-v/src/common/riscv_createstack.c +++ b/arch/risc-v/src/common/riscv_createstack.c @@ -213,27 +213,36 @@ int up_create_stack(struct tcb_s *tcb, size_t stack_size, uint8_t ttype) #ifdef CONFIG_STACK_COLORATION void riscv_stack_color(void *stackbase, size_t nbytes) { - uintptr_t start; - uintptr_t end; - size_t nwords; - uint32_t *ptr; + uint32_t *stkptr; + uintptr_t stkend; + size_t nwords; + uintptr_t sp; /* Take extra care that we do not write outside the stack boundaries */ - start = STACK_ALIGN_UP((uintptr_t)stackbase); - end = nbytes ? STACK_ALIGN_DOWN((uintptr_t)stackbase + nbytes) : - up_getsp(); /* 0: colorize the running stack */ + stkptr = (uint32_t *)STACK_ALIGN_UP((uintptr_t)stackbase); - /* Get the adjusted size based on the top and bottom of the stack */ + if (nbytes == 0) /* 0: colorize the running stack */ + { + stkend = up_getsp(); + if (stkend > (uintptr_t)&sp) + { + stkend = (uintptr_t)&sp; + } + } + else + { + stkend = (uintptr_t)stackbase + nbytes; + } - nwords = (end - start) >> 2; - ptr = (uint32_t *)start; + stkend = STACK_ALIGN_DOWN(stkend); + nwords = (stkend - (uintptr_t)stackbase) >> 2; /* Set the entire stack to the coloration value */ while (nwords-- > 0) { - *ptr++ = STACK_COLOR; + *stkptr++ = STACK_COLOR; } } #endif diff --git a/arch/risc-v/src/common/riscv_doirq.c b/arch/risc-v/src/common/riscv_doirq.c index 7e73a2b7403a8..2792ef46d3a58 100644 --- a/arch/risc-v/src/common/riscv_doirq.c +++ b/arch/risc-v/src/common/riscv_doirq.c @@ -55,12 +55,20 @@ * Public Functions ****************************************************************************/ -uintptr_t *up_doirq(int irq, uintptr_t *regs) +uintptr_t *riscv_doirq(int irq, uintptr_t *regs) { board_autoled_on(LED_INIRQ); #ifdef CONFIG_SUPPRESS_INTERRUPTS PANIC(); #else + + /* NOTE: In case of ecall, we need to adjust mepc in the context */ + + if (irq >= RISCV_IRQ_ECALLU && irq <= RISCV_IRQ_ECALLM) + { + regs[REG_EPC] += 4; + } + /* Current regs non-zero indicates that we are processing an interrupt; * CURRENT_REGS is also used to manage interrupt level context switches. * @@ -70,17 +78,10 @@ uintptr_t *up_doirq(int irq, uintptr_t *regs) DEBUGASSERT(CURRENT_REGS == NULL); CURRENT_REGS = regs; - /* Disable further occurrences of this interrupt (until the interrupt - * sources have been clear by the driver). - */ - - up_disable_irq(irq); - /* Deliver the IRQ */ irq_dispatch(irq, regs); -#if defined(CONFIG_ARCH_FPU) || defined(CONFIG_ARCH_ADDRENV) /* Check for a context switch. If a context switch occurred, then * CURRENT_REGS will have a different value than it did on entry. If an * interrupt level context switch has occurred, then restore the floating @@ -88,15 +89,9 @@ uintptr_t *up_doirq(int irq, uintptr_t *regs) * returning from the interrupt. */ +#ifdef CONFIG_ARCH_ADDRENV if (regs != CURRENT_REGS) { -#ifdef CONFIG_ARCH_FPU - /* Restore floating point registers */ - - riscv_restorefpu((uintptr_t *)CURRENT_REGS); -#endif - -#ifdef CONFIG_ARCH_ADDRENV /* Make sure that the address environment for the previously * running task is closed down gracefully (data caches dump, * MMU flushed) and set up the address environment for the new @@ -104,7 +99,6 @@ uintptr_t *up_doirq(int irq, uintptr_t *regs) */ group_addrenv(NULL); -#endif } #endif @@ -122,9 +116,6 @@ uintptr_t *up_doirq(int irq, uintptr_t *regs) CURRENT_REGS = NULL; - /* Unmask the last interrupt (global interrupts are still disabled) */ - - up_enable_irq(irq); #endif board_autoled_off(LED_INIRQ); return regs; diff --git a/arch/risc-v/src/common/riscv_exception.c b/arch/risc-v/src/common/riscv_exception.c index 1ffb3e2a1a2c8..256625ddeebc8 100644 --- a/arch/risc-v/src/common/riscv_exception.c +++ b/arch/risc-v/src/common/riscv_exception.c @@ -25,18 +25,18 @@ #include #include -#include #include #include #include #include -#include -#include -#include #include "riscv_internal.h" +/**************************************************************************** + * Private Data + ****************************************************************************/ + static const char *g_reasons_str[RISCV_MAX_EXCEPTION + 1] = { "Instruction address misaligned", @@ -49,7 +49,7 @@ static const char *g_reasons_str[RISCV_MAX_EXCEPTION + 1] = "Store/AMO access fault", "Environment call from U-mode", "Environment call from S-mode", - "Reserved", + "Environment call from H-mode", "Environment call from M-mode", "Instruction page fault", "Load page fault", @@ -69,7 +69,7 @@ static const char *g_reasons_str[RISCV_MAX_EXCEPTION + 1] = * ****************************************************************************/ -void riscv_exception(uintptr_t mcause, uintptr_t *regs) +int riscv_exception(int mcause, void *regs, void *args) { uintptr_t cause = mcause & RISCV_IRQ_MASK; @@ -87,5 +87,60 @@ void riscv_exception(uintptr_t mcause, uintptr_t *regs) up_irq_save(); CURRENT_REGS = regs; PANIC(); + + return 0; } +/**************************************************************************** + * Name: riscv_exception_attach + * + * Description: + * Attach standard exception with suitable handler + * + ****************************************************************************/ + +void riscv_exception_attach(void) +{ + irq_attach(RISCV_IRQ_IAMISALIGNED, riscv_exception, NULL); + irq_attach(RISCV_IRQ_IAFAULT, riscv_exception, NULL); + irq_attach(RISCV_IRQ_IINSTRUCTION, riscv_exception, NULL); + irq_attach(RISCV_IRQ_BPOINT, riscv_exception, NULL); + irq_attach(RISCV_IRQ_LAFAULT, riscv_exception, NULL); + irq_attach(RISCV_IRQ_SAFAULT, riscv_exception, NULL); + +#ifdef CONFIG_RISCV_MISALIGNED_HANDLER + irq_attach(RISCV_IRQ_LAMISALIGNED, riscv_misaligned, NULL); + irq_attach(RISCV_IRQ_SAMISALIGNED, riscv_misaligned, NULL); +#else + irq_attach(RISCV_IRQ_LAMISALIGNED, riscv_exception, NULL); + irq_attach(RISCV_IRQ_SAMISALIGNED, riscv_exception, NULL); +#endif + + /* Attach the ecall interrupt handler */ + +#ifndef CONFIG_BUILD_FLAT + irq_attach(RISCV_IRQ_ECALLU, riscv_swint, NULL); +#else + irq_attach(RISCV_IRQ_ECALLU, riscv_exception, NULL); +#endif + + irq_attach(RISCV_IRQ_ECALLS, riscv_exception, NULL); + irq_attach(RISCV_IRQ_ECALLH, riscv_exception, NULL); + +#ifndef CONFIG_ARCH_USE_S_MODE + irq_attach(RISCV_IRQ_ECALLM, riscv_swint, NULL); +#else + irq_attach(RISCV_IRQ_ECALLM, riscv_exception, NULL); +#endif + + irq_attach(RISCV_IRQ_INSTRUCTIONPF, riscv_exception, NULL); + irq_attach(RISCV_IRQ_LOADPF, riscv_exception, NULL); + irq_attach(RISCV_IRQ_RESERVED, riscv_exception, NULL); + irq_attach(RISCV_IRQ_STOREPF, riscv_exception, NULL); + +#ifdef CONFIG_SMP + irq_attach(RISCV_IRQ_MSOFT, riscv_pause_handler, NULL); +#else + irq_attach(RISCV_IRQ_MSOFT, riscv_exception, NULL); +#endif +} diff --git a/arch/risc-v/src/common/riscv_exception_common.S b/arch/risc-v/src/common/riscv_exception_common.S index 4d5665ac2dc4a..0bf0f74f094e9 100644 --- a/arch/risc-v/src/common/riscv_exception_common.S +++ b/arch/risc-v/src/common/riscv_exception_common.S @@ -23,101 +23,87 @@ ****************************************************************************/ #include + +#include #include +#include + +#include + +#include "chip.h" + +#include "riscv_macros.S" + +#include "riscv_internal.h" /**************************************************************************** - * Public Symbols + * Pre-processor Definitions ****************************************************************************/ -#ifdef CONFIG_ARCH_RV32 -# define REGLOAD lw -# define REGSTORE sw -#else -# define REGLOAD ld -# define REGSTORE sd +/* Using address environments currently require that a common interrupt stack + * is in place. This is needed because during context switch the procedure + * that swaps the active address environment is dependent on a stack, which + * must be a 'neutral' stack. + * + * Another option would be to use a per-process kernel stack, but full + * support for this is not yet in place, so use the common IRQ stack instead. + */ + +#ifdef CONFIG_ARCH_ADDRENV +# if CONFIG_ARCH_INTERRUPTSTACK == 0 && !defined(CONFIG_ARCH_KERNEL_STACK) +# error "IRQ or kernel stack is needed for swapping address environments" +# endif #endif -#ifdef CONFIG_IRQ_NSTACKS -# define IRQ_NSTACKS CONFIG_IRQ_NSTACKS -#elif defined CONFIG_SMP -# define IRQ_NSTACKS CONFIG_SMP_NCPUS -#else -# define IRQ_NSTACKS 1 +/* Provide a default section for the exeception handler. */ + +#ifndef EXCEPTION_SECTION +# define EXCEPTION_SECTION .text #endif +/**************************************************************************** + * Public Symbols + ****************************************************************************/ + /**************************************************************************** * Name: exception_common + * + * Description: + * Handles interrupts. If kernel is in S-mode, handles delegated interrupts + * in S-mode interrupt handler. + * ****************************************************************************/ - .section .text + .section EXCEPTION_SECTION .global exception_common .align 8 exception_common: addi sp, sp, -XCPTCONTEXT_SIZE + save_ctx sp - REGSTORE x1, REG_X1(sp) /* ra */ -#ifdef RISCV_SAVE_GP - REGSTORE x3, REG_X3(sp) /* gp */ -#endif - REGSTORE x4, REG_X4(sp) /* tp */ - REGSTORE x5, REG_X5(sp) /* t0 */ - REGSTORE x6, REG_X6(sp) /* t1 */ - REGSTORE x7, REG_X7(sp) /* t2 */ - REGSTORE x8, REG_X8(sp) /* s0 */ - REGSTORE x9, REG_X9(sp) /* s1 */ - REGSTORE x10, REG_X10(sp) /* a0 */ - REGSTORE x11, REG_X11(sp) /* a1 */ - REGSTORE x12, REG_X12(sp) /* a2 */ - REGSTORE x13, REG_X13(sp) /* a3 */ - REGSTORE x14, REG_X14(sp) /* a4 */ - REGSTORE x15, REG_X15(sp) /* a5 */ - REGSTORE x16, REG_X16(sp) /* a6 */ - REGSTORE x17, REG_X17(sp) /* a7 */ - REGSTORE x18, REG_X18(sp) /* s2 */ - REGSTORE x19, REG_X19(sp) /* s3 */ - REGSTORE x20, REG_X20(sp) /* s4 */ - REGSTORE x21, REG_X21(sp) /* s5 */ - REGSTORE x22, REG_X22(sp) /* s6 */ - REGSTORE x23, REG_X23(sp) /* s7 */ - REGSTORE x24, REG_X24(sp) /* s8 */ - REGSTORE x25, REG_X25(sp) /* s9 */ - REGSTORE x26, REG_X26(sp) /* s10 */ - REGSTORE x27, REG_X27(sp) /* s11 */ - REGSTORE x28, REG_X28(sp) /* t3 */ - REGSTORE x29, REG_X29(sp) /* t4 */ - REGSTORE x30, REG_X30(sp) /* t5 */ - REGSTORE x31, REG_X31(sp) /* t6 */ - - csrr s0, mstatus - REGSTORE s0, REG_INT_CTX(sp) /* mstatus */ + csrr s0, CSR_STATUS + REGSTORE s0, REG_INT_CTX(sp) /* status */ addi s0, sp, XCPTCONTEXT_SIZE - REGSTORE s0, REG_X2(sp) /* original SP */ + REGSTORE s0, REG_X2(sp) /* original SP */ - /* Setup arg0(exception cause), arg1(context) */ + csrr s0, CSR_EPC + REGSTORE s0, REG_EPC(sp) /* exception PC */ - csrr a0, mcause /* exception cause */ - csrr s0, mepc - REGSTORE s0, REG_EPC(sp) /* exception PC */ + riscv_savefpu sp - mv a1, sp /* context = sp */ + /* Setup arg0(exception cause), arg1(context) */ -#if CONFIG_ARCH_INTERRUPTSTACK > 15 - /* Load mhartid (cpuid) */ + csrr a0, CSR_CAUSE /* exception cause */ + mv a1, sp /* context = sp */ - csrr s0, mhartid +#if CONFIG_ARCH_INTERRUPTSTACK > 15 /* Switch to interrupt stack */ -#if IRQ_NSTACKS > 1 - li t0, (CONFIG_ARCH_INTERRUPTSTACK & ~15) - mul t0, s0, t0 - la s0, g_intstacktop - sub sp, s0, t0 -#else - la sp, g_intstacktop -#endif + + setintstack t0, t1 /* Call interrupt handler in C */ @@ -137,63 +123,33 @@ exception_common: addi sp, sp, XCPTCONTEXT_SIZE #endif - - /* If context switch is needed, return a new sp */ + /* If context switch is needed, return a new sp */ mv sp, a0 - REGLOAD s0, REG_EPC(sp) /* restore mepc */ - csrw mepc, s0 - REGLOAD s0, REG_INT_CTX(sp) /* restore mstatus */ - csrw mstatus, s0 + riscv_loadfpu sp -#ifdef RISCV_SAVE_GP - REGLOAD x3, REG_X3(sp) /* gp */ -#endif - REGLOAD x4, REG_X4(sp) /* tp */ - REGLOAD x5, REG_X5(sp) /* t0 */ - REGLOAD x6, REG_X6(sp) /* t1 */ - REGLOAD x7, REG_X7(sp) /* t2 */ - REGLOAD x8, REG_X8(sp) /* s0 */ - REGLOAD x9, REG_X9(sp) /* s1 */ - REGLOAD x10, REG_X10(sp) /* a0 */ - REGLOAD x11, REG_X11(sp) /* a1 */ - REGLOAD x12, REG_X12(sp) /* a2 */ - REGLOAD x13, REG_X13(sp) /* a3 */ - REGLOAD x14, REG_X14(sp) /* a4 */ - REGLOAD x15, REG_X15(sp) /* a5 */ - REGLOAD x16, REG_X16(sp) /* a6 */ - REGLOAD x17, REG_X17(sp) /* a7 */ - REGLOAD x18, REG_X18(sp) /* s2 */ - REGLOAD x19, REG_X19(sp) /* s3 */ - REGLOAD x20, REG_X20(sp) /* s4 */ - REGLOAD x21, REG_X21(sp) /* s5 */ - REGLOAD x22, REG_X22(sp) /* s6 */ - REGLOAD x23, REG_X23(sp) /* s7 */ - REGLOAD x24, REG_X24(sp) /* s8 */ - REGLOAD x25, REG_X25(sp) /* s9 */ - REGLOAD x26, REG_X26(sp) /* s10 */ - REGLOAD x27, REG_X27(sp) /* s11 */ - REGLOAD x28, REG_X28(sp) /* t3 */ - REGLOAD x29, REG_X29(sp) /* t4 */ - REGLOAD x30, REG_X30(sp) /* t5 */ - REGLOAD x31, REG_X31(sp) /* t6 */ - - REGLOAD x1, REG_X1(sp) /* ra */ - - REGLOAD sp, REG_X2(sp) /* restore original sp */ - - /* Return from Machine Interrupt */ - - mret - -/************************************************************************************ - * Name: g_intstackalloc and g_intstacktop - ************************************************************************************/ + REGLOAD s0, REG_EPC(sp) /* restore sepc */ + csrw CSR_EPC, s0 -/************************************************************************************ + REGLOAD s0, REG_INT_CTX(sp) /* restore sstatus */ + csrw CSR_STATUS, s0 + + load_ctx sp + + REGLOAD sp, REG_SP(sp) /* restore original sp */ + + /* Return from exception */ + + ERET + +/***************************************************************************** * Name: g_intstackalloc and g_intstacktop - ************************************************************************************/ + ****************************************************************************/ + +/* Total required interrupt stack size */ + +#define STACK_ALLOC_SIZE (CONFIG_ARCH_INTERRUPTSTACK * CONFIG_SMP_NCPUS) #if CONFIG_ARCH_INTERRUPTSTACK > 15 .bss @@ -203,8 +159,8 @@ exception_common: .type g_intstackalloc, object .type g_intstacktop, object g_intstackalloc: - .skip (((CONFIG_ARCH_INTERRUPTSTACK * IRQ_NSTACKS) + 8) & ~15) + .skip STACK_ALIGN_UP(STACK_ALLOC_SIZE) g_intstacktop: .size g_intstacktop, 0 - .size g_intstackalloc, ((CONFIG_ARCH_INTERRUPTSTACK * IRQ_NSTACKS) & ~15) + .size g_intstackalloc, STACK_ALIGN_DOWN(STACK_ALLOC_SIZE) #endif diff --git a/arch/risc-v/src/common/riscv_exit.c b/arch/risc-v/src/common/riscv_exit.c index f8647beb12f01..c6177f29b7e22 100644 --- a/arch/risc-v/src/common/riscv_exit.c +++ b/arch/risc-v/src/common/riscv_exit.c @@ -72,7 +72,7 @@ static void _up_dumponexit(struct tcb_s *tcb, void *arg) sinfo(" TCB=%p name=%s pid=%d\n", tcb, tcb->name, tcb->pid); sinfo(" priority=%d state=%d\n", tcb->sched_priority, tcb->task_state); - filelist = tcb->group->tg_filelist; + filelist = &tcb->group->tg_filelist; for (i = 0; i < filelist->fl_rows; i++) { for (j = 0; j < CONFIG_NFILE_DESCRIPTORS_PER_BLOCK; j++) @@ -116,15 +116,15 @@ void up_exit(int status) sinfo("TCB=%p exiting\n", tcb); + /* Destroy the task at the head of the ready to run list. */ + + nxtask_exit(); + #ifdef CONFIG_DUMP_ON_EXIT sinfo("Other tasks:\n"); nxsched_foreach(_up_dumponexit, NULL); #endif - /* Destroy the task at the head of the ready to run list. */ - - nxtask_exit(); - /* Now, perform the context switch to the new ready-to-run task at the * head of the list. */ @@ -137,16 +137,6 @@ void up_exit(int status) nxsched_resume_scheduler(tcb); -#ifdef CONFIG_ARCH_ADDRENV - /* Make sure that the address environment for the previously running - * task is closed down gracefully (data caches dump, MMU flushed) and - * set up the address environment for the new thread at the head of - * the ready-to-run list. - */ - - group_addrenv(tcb); -#endif - /* Then switch contexts */ riscv_fullcontextrestore(tcb->xcp.regs); diff --git a/arch/risc-v/src/common/riscv_fault.c b/arch/risc-v/src/common/riscv_fault.c deleted file mode 100644 index 86afecd9ecc7d..0000000000000 --- a/arch/risc-v/src/common/riscv_fault.c +++ /dev/null @@ -1,115 +0,0 @@ -/**************************************************************************** - * arch/risc-v/src/common/riscv_fault.c - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. The - * ASF licenses this file to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance with the - * License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - ****************************************************************************/ - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include - -#include -#include -#include -#include - -#include -#include -#include -#include - -#include - -#include "sched/sched.h" -#include "irq/irq.h" -#include "riscv_internal.h" - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: riscv_fault - * - * Description: - * This is Fault exception handler. - * - ****************************************************************************/ - -void riscv_fault(int irq, uintptr_t *regs) -{ - CURRENT_REGS = regs; - - _alert("EPC: %" PRIxREG "\n", - CURRENT_REGS[REG_EPC]); - - _alert("Fault IRQ=%d\n", irq); - - /* Dump register info */ - - _alert("A0: %" PRIxREG " A1: %" PRIxREG " A2: %" PRIxREG - " A3: %" PRIxREG "\n", - CURRENT_REGS[REG_A0], CURRENT_REGS[REG_A1], - CURRENT_REGS[REG_A2], CURRENT_REGS[REG_A3]); - - _alert("A4: %" PRIxREG " A5: %" PRIxREG " A6: %" PRIxREG - " A7: %" PRIxREG "\n", - CURRENT_REGS[REG_A4], CURRENT_REGS[REG_A5], - CURRENT_REGS[REG_A6], CURRENT_REGS[REG_A7]); - - _alert("T0: %" PRIxREG " T1: %" PRIxREG " T2: %" PRIxREG - " T3: %" PRIxREG "\n", - CURRENT_REGS[REG_T0], CURRENT_REGS[REG_T1], - CURRENT_REGS[REG_T2], CURRENT_REGS[REG_T3]); - - _alert("T4: %" PRIxREG " T5: %" PRIxREG - " T6: %" PRIxREG "\n", - CURRENT_REGS[REG_T4], CURRENT_REGS[REG_T5], - CURRENT_REGS[REG_T6]); - - _alert("S0: %" PRIxREG " S1: %" PRIxREG " S2: %" PRIxREG - " S3: %" PRIxREG "\n", - CURRENT_REGS[REG_S0], CURRENT_REGS[REG_S1], - CURRENT_REGS[REG_S2], CURRENT_REGS[REG_S3]); - - _alert("S4: %" PRIxREG " S5: %" PRIxREG " S6: %" PRIxREG - " S7: %" PRIxREG "\n", - CURRENT_REGS[REG_S4], CURRENT_REGS[REG_S5], - CURRENT_REGS[REG_S6], CURRENT_REGS[REG_S7]); - - _alert("S8: %" PRIxREG " S9: %" PRIxREG " S10: %" PRIxREG - " S11: %" PRIxREG "\n", - CURRENT_REGS[REG_S8], CURRENT_REGS[REG_S9], - CURRENT_REGS[REG_S10], CURRENT_REGS[REG_S11]); - -#ifdef RISCV_SAVE_GP - _alert("GP: %" PRIxREG " SP: %" PRIxREG " FP: %" PRIxREG - " TP: %" PRIxREG "RA: %" PRIxREG "\n", - CURRENT_REGS[REG_GP], CURRENT_REGS[REG_SP], - CURRENT_REGS[REG_FP], CURRENT_REGS[REG_TP], - CURRENT_REGS[REG_RA]); -#else - _alert("SP: %" PRIxREG " FP: %" PRIxREG " TP: %" PRIxREG - " RA: %" PRIxREG "\n", - CURRENT_REGS[REG_SP], CURRENT_REGS[REG_FP], - CURRENT_REGS[REG_TP], CURRENT_REGS[REG_RA]); -#endif - - up_irq_save(); -} diff --git a/arch/risc-v/src/common/riscv_fpu.S b/arch/risc-v/src/common/riscv_fpu.S index ba35db263f21f..84989ccbf3a45 100644 --- a/arch/risc-v/src/common/riscv_fpu.S +++ b/arch/risc-v/src/common/riscv_fpu.S @@ -24,61 +24,32 @@ #include +#include +#include #include +#include #ifdef CONFIG_ARCH_FPU -/************************************************************************************ - * Pre-processor Definitions - ************************************************************************************/ - /************************************************************************************ * Public Symbols ************************************************************************************/ - .globl up_fpuconfig - .globl riscv_savefpu - .globl riscv_restorefpu - + .globl riscv_fpuconfig .file "riscv_fpu.S" -#define FS_MASK 0x6000 -#define FS_OFF 0x0000 -#define FS_INITIAL 0x2000 -#define FS_CLEAN 0x4000 -#define FS_DIRTY 0x6000 - -#if defined(CONFIG_ARCH_QPFPU) -# define FLOAD flq -# define FSTORE fsq -#elif defined(CONFIG_ARCH_DPFPU) -# define FLOAD fld -# define FSTORE fsd -#else -# define FLOAD flw -# define FSTORE fsw -#endif - -#ifdef CONFIG_ARCH_RV32 -# define REGLOAD lw -# define REGSTORE sw -#else -# define REGLOAD ld -# define REGSTORE sd -#endif - /************************************************************************************ * Public Functions ************************************************************************************/ /************************************************************************************ - * Name: up_fpuconfig + * Name: riscv_fpuconfig * * Description: * init fpu * * C Function Prototype: - * void up_fpuconfig(void); + * void riscv_fpuconfig(void); * * Input Parameters: * None @@ -88,158 +59,16 @@ * ************************************************************************************/ - .type up_fpuconfig, function - -up_fpuconfig: - li a0, FS_INITIAL - csrs mstatus, a0 - csrwi fcsr, 0 - ret - -/************************************************************************************ - * Name: riscv_savefpu - * - * Description: - * Given the pointer to a register save area (in A0), save the state of the - * floating point registers. - * - * C Function Prototype: - * void riscv_savefpu(uintptr_t *regs); - * - * Input Parameters: - * regs - A pointer to the register save area in which to save the floating point - * registers - * - * Returned Value: - * None - * - ************************************************************************************/ - - .type riscv_savefpu, function - -riscv_savefpu: - REGLOAD t0, REG_INT_CTX(a0) - li t1, FS_MASK - and t2, t0, t1 - li t1, FS_DIRTY - bne t2, t1, 1f - li t1, ~FS_MASK - and t0, t0, t1 - li t1, FS_CLEAN - or t0, t0, t1 - REGSTORE t0, REG_INT_CTX(a0) - - /* Store all floating point registers */ - - FSTORE f0, REG_F0(a0) - FSTORE f1, REG_F1(a0) - FSTORE f2, REG_F2(a0) - FSTORE f3, REG_F3(a0) - FSTORE f4, REG_F4(a0) - FSTORE f5, REG_F5(a0) - FSTORE f6, REG_F6(a0) - FSTORE f7, REG_F7(a0) - FSTORE f8, REG_F8(a0) - FSTORE f9, REG_F9(a0) - FSTORE f10, REG_F10(a0) - FSTORE f11, REG_F11(a0) - FSTORE f12, REG_F12(a0) - FSTORE f13, REG_F13(a0) - FSTORE f14, REG_F14(a0) - FSTORE f15, REG_F15(a0) - FSTORE f16, REG_F16(a0) - FSTORE f17, REG_F17(a0) - FSTORE f18, REG_F18(a0) - FSTORE f19, REG_F19(a0) - FSTORE f20, REG_F20(a0) - FSTORE f21, REG_F21(a0) - FSTORE f22, REG_F22(a0) - FSTORE f23, REG_F23(a0) - FSTORE f24, REG_F24(a0) - FSTORE f25, REG_F25(a0) - FSTORE f26, REG_F26(a0) - FSTORE f27, REG_F27(a0) - FSTORE f28, REG_F28(a0) - FSTORE f29, REG_F29(a0) - FSTORE f30, REG_F30(a0) - FSTORE f31, REG_F31(a0) - - frcsr t0 - REGSTORE t0, REG_FCSR(a0) - -1: - ret - -/************************************************************************************ - * Name: riscv_restorefpu - * - * Description: - * Given the pointer to a register save area (in A0), restore the state of the - * floating point registers. - * - * C Function Prototype: - * void riscv_restorefpu(const uintptr_t *regs); - * - * Input Parameters: - * regs - A pointer to the register save area containing the floating point - * registers. - * - * Returned Value: - * This function does not return anything explicitly. However, it is called from - * interrupt level assembly logic that assumes that r0 is preserved. - * - ************************************************************************************/ - - .type riscv_restorefpu, function - -riscv_restorefpu: - REGLOAD t0, REG_INT_CTX(a0) - li t1, FS_MASK - and t2, t0, t1 - li t1, FS_INITIAL - ble t2, t1, 1f - - /* Load all floating point registers */ - - FLOAD f0, REG_F0(a0) - FLOAD f1, REG_F1(a0) - FLOAD f2, REG_F2(a0) - FLOAD f3, REG_F3(a0) - FLOAD f4, REG_F4(a0) - FLOAD f5, REG_F5(a0) - FLOAD f6, REG_F6(a0) - FLOAD f7, REG_F7(a0) - FLOAD f8, REG_F8(a0) - FLOAD f9, REG_F9(a0) - FLOAD f10, REG_F10(a0) - FLOAD f11, REG_F11(a0) - FLOAD f12, REG_F12(a0) - FLOAD f13, REG_F13(a0) - FLOAD f14, REG_F14(a0) - FLOAD f15, REG_F15(a0) - FLOAD f16, REG_F16(a0) - FLOAD f17, REG_F17(a0) - FLOAD f18, REG_F18(a0) - FLOAD f19, REG_F19(a0) - FLOAD f20, REG_F20(a0) - FLOAD f21, REG_F21(a0) - FLOAD f22, REG_F22(a0) - FLOAD f23, REG_F23(a0) - FLOAD f24, REG_F24(a0) - FLOAD f25, REG_F25(a0) - FLOAD f26, REG_F26(a0) - FLOAD f27, REG_F27(a0) - FLOAD f28, REG_F28(a0) - FLOAD f29, REG_F29(a0) - FLOAD f30, REG_F30(a0) - FLOAD f31, REG_F31(a0) + .type riscv_fpuconfig, function - /* Store the floating point control and status register */ +riscv_fpuconfig: + li a0, MSTATUS_FS_INIT + csrs CSR_STATUS, a0 - REGLOAD t0, REG_FCSR(a0) - fscsr t0 + fsflags zero + fsrm zero -1: + fence.i ret #endif /* CONFIG_ARCH_FPU */ diff --git a/arch/risc-v/src/common/riscv_fpucmp.c b/arch/risc-v/src/common/riscv_fpucmp.c new file mode 100644 index 0000000000000..d37faefe91085 --- /dev/null +++ b/arch/risc-v/src/common/riscv_fpucmp.c @@ -0,0 +1,59 @@ +/**************************************************************************** + * arch/risc-v/src/common/riscv_fpucmp.c + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include +#include +#include + +#include "riscv_internal.h" + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +#ifdef CONFIG_ARCH_FPU + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: up_fpucmp + * + * Description: + * compare FPU areas from thread context + * + ****************************************************************************/ + +bool up_fpucmp(const void *saveregs1, const void *saveregs2) +{ + const uintptr_t *regs1 = saveregs1; + const uintptr_t *regs2 = saveregs2; + + return memcmp(®s1[INT_XCPT_REGS], ®s2[INT_XCPT_REGS], + INT_REG_SIZE * FPU_XCPT_REGS) == 0; +} +#endif /* CONFIG_ARCH_FPU */ diff --git a/arch/risc-v/src/common/riscv_getnewintctx.c b/arch/risc-v/src/common/riscv_getnewintctx.c index 04180f7abb713..f1fa4cf3ded61 100644 --- a/arch/risc-v/src/common/riscv_getnewintctx.c +++ b/arch/risc-v/src/common/riscv_getnewintctx.c @@ -30,8 +30,9 @@ #include #include -#include -#include +#include + +#include #include "riscv_internal.h" @@ -49,23 +50,23 @@ uintptr_t riscv_get_newintctx(void) { - /* Set machine previous privilege mode to machine mode. Reegardless of + /* Set machine previous privilege mode to privileged mode. Regardless of * how NuttX is configured and of what kind of thread is being started. * That is because all threads, even user-mode threads will start in * kernel trampoline at nxtask_start() or pthread_start(). * The thread's privileges will be dropped before transitioning to - * user code. Also set machine previous interrupt enable. + * user code. Also set machine / supervisor previous interrupt enable. * * Mask the bits which should be preserved (from ISA spec) */ - uintptr_t mstatus = READ_CSR(mstatus); + uintptr_t status = READ_CSR(CSR_STATUS); - mstatus &= MSTATUS_WPRI; + status &= MSTATUS_WPRI; - return (mstatus | MSTATUS_MPPM | MSTATUS_MPIE + return (status | STATUS_PPP | STATUS_SUM | STATUS_PIE #ifdef CONFIG_ARCH_FPU - | MSTATUS_FS_INIT + | MSTATUS_FS_INIT #endif ); } diff --git a/arch/risc-v/src/common/riscv_hostfs.c b/arch/risc-v/src/common/riscv_hostfs.c new file mode 100644 index 0000000000000..d5786e22a2865 --- /dev/null +++ b/arch/risc-v/src/common/riscv_hostfs.c @@ -0,0 +1,359 @@ +/**************************************************************************** + * arch/risc-v/src/common/riscv_hostfs.c + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include +#include +#include + +#include +#include +#include +#include +#include + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +#define HOST_OPEN 0x01 +#define HOST_CLOSE 0x02 +#define HOST_WRITE 0x05 +#define HOST_READ 0x06 +#define HOST_SEEK 0x0a +#define HOST_FLEN 0x0c +#define HOST_REMOVE 0x0e +#define HOST_RENAME 0x0f +#define HOST_ERROR 0x13 + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +static long host_call(unsigned int nbr, void *parm, size_t size) +{ +#ifdef CONFIG_RISCV_SEMIHOSTING_HOSTFS_CACHE_COHERENCE + up_clean_dcache(parm, parm + size); +#endif + + long ret = smh_call(nbr, parm); + if (ret < 0) + { + long err = smh_call(HOST_ERROR, NULL); + if (err > 0) + { + ret = -err; + } + } + + return ret; +} + +static ssize_t host_flen(long fd) +{ + return host_call(HOST_FLEN, &fd, sizeof(long)); +} + +static int host_flags_to_mode(int flags) +{ + static const int modeflags[] = + { + O_RDONLY, + O_RDONLY | O_BINARY, + O_RDWR, + O_RDWR | O_BINARY, + O_WRONLY | O_CREAT | O_TRUNC, + O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, + O_RDWR | O_CREAT | O_TRUNC, + O_RDWR | O_CREAT | O_TRUNC | O_BINARY, + O_WRONLY | O_CREAT | O_APPEND, + O_WRONLY | O_CREAT | O_APPEND | O_BINARY, + O_RDWR | O_CREAT | O_APPEND, + O_RDWR | O_CREAT | O_APPEND | O_BINARY, + 0, + }; + + int i; + for (i = 0; modeflags[i] != 0; i++) + { + if (modeflags[i] == flags) + { + return i; + } + } + + return -EINVAL; +} + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +int host_open(const char *pathname, int flags, int mode) +{ + struct + { + const char *pathname; + long mode; + size_t len; + } open = + { + .pathname = pathname, + .mode = host_flags_to_mode(flags), + .len = strlen(pathname), + }; + +#ifdef CONFIG_RISCV_SEMIHOSTING_HOSTFS_CACHE_COHERENCE + up_clean_dcache(pathname, pathname + open.len + 1); +#endif + + return host_call(HOST_OPEN, &open, sizeof(open)); +} + +int host_close(int fd_) +{ + long fd = fd_; + return host_call(HOST_CLOSE, &fd, sizeof(long)); +} + +ssize_t host_read(int fd, void *buf, size_t count) +{ + struct + { + long fd; + void *buf; + size_t count; + } read = + { + .fd = fd, + .buf = buf, + .count = count, + }; + + ssize_t ret; + +#ifdef CONFIG_RISCV_SEMIHOSTING_HOSTFS_CACHE_COHERENCE + up_invalidate_dcache(buf, buf + count); +#endif + + ret = host_call(HOST_READ, &read, sizeof(read)); + + return ret < 0 ? ret : count - ret; +} + +ssize_t host_write(int fd, const void *buf, size_t count) +{ + struct + { + long fd; + const void *buf; + size_t count; + } write = + { + .fd = fd, + .buf = buf, + .count = count, + }; + + ssize_t ret; + +#ifdef CONFIG_RISCV_SEMIHOSTING_HOSTFS_CACHE_COHERENCE + up_clean_dcache(buf, buf + count); +#endif + + ret = host_call(HOST_WRITE, &write, sizeof(write)); + return ret < 0 ? ret : count - ret; +} + +off_t host_lseek(int fd, off_t offset, int whence) +{ + off_t ret = -ENOSYS; + + if (whence == SEEK_END) + { + ret = host_flen(fd); + if (ret >= 0) + { + offset += ret; + whence = SEEK_SET; + } + } + + if (whence == SEEK_SET) + { + struct + { + long fd; + size_t pos; + } seek = + { + .fd = fd, + .pos = offset, + }; + + ret = host_call(HOST_SEEK, &seek, sizeof(seek)); + if (ret >= 0) + { + ret = offset; + } + } + + return ret; +} + +int host_ioctl(int fd, int request, unsigned long arg) +{ + return -ENOSYS; +} + +void host_sync(int fd) +{ +} + +int host_dup(int fd) +{ + return -ENOSYS; +} + +int host_fstat(int fd, struct stat *buf) +{ + memset(buf, 0, sizeof(*buf)); + buf->st_mode = S_IFREG | 0777; + buf->st_size = host_flen(fd); + return buf->st_size < 0 ? buf->st_size : 0; +} + +int host_fchstat(int fd, const struct stat *buf, int flags) +{ + return -ENOSYS; +} + +int host_ftruncate(int fd, off_t length) +{ + return -ENOSYS; +} + +void *host_opendir(const char *name) +{ + return NULL; +} + +int host_readdir(void *dirp, struct dirent *entry) +{ + return -ENOSYS; +} + +void host_rewinddir(void *dirp) +{ +} + +int host_closedir(void *dirp) +{ + return -ENOSYS; +} + +int host_statfs(const char *path, struct statfs *buf) +{ + return 0; +} + +int host_unlink(const char *pathname) +{ + struct + { + const char *pathname; + size_t pathname_len; + } remove = + { + .pathname = pathname, + .pathname_len = strlen(pathname), + }; + +#ifdef CONFIG_RISCV_SEMIHOSTING_HOSTFS_CACHE_COHERENCE + up_clean_dcache(pathname, pathname + + remove.pathname_len + 1); +#endif + + return host_call(HOST_REMOVE, &remove, sizeof(remove)); +} + +int host_mkdir(const char *pathname, mode_t mode) +{ + return -ENOSYS; +} + +int host_rmdir(const char *pathname) +{ + return host_unlink(pathname); +} + +int host_rename(const char *oldpath, const char *newpath) +{ + struct + { + const char *oldpath; + size_t oldpath_len; + const char *newpath; + size_t newpath_len; + } rename = + { + .oldpath = oldpath, + .oldpath_len = strlen(oldpath), + .newpath = newpath, + .newpath_len = strlen(newpath), + }; + +#ifdef CONFIG_RISCV_SEMIHOSTING_HOSTFS_CACHE_COHERENCE + up_clean_dcache(oldpath, oldpath + rename.oldpath_len + 1); + up_clean_dcache(newpath, newpath + rename.newpath_len + 1); +#endif + + return host_call(HOST_RENAME, &rename, sizeof(rename)); +} + +int host_stat(const char *path, struct stat *buf) +{ + int ret = host_open(path, O_RDONLY, 0); + if (ret >= 0) + { + int fd = ret; + ret = host_fstat(fd, buf); + host_close(fd); + } + + if (ret < 0) + { + /* Since semihosting doesn't support directory yet, */ + + ret = 0; /* we have to assume it's a directory here. */ + memset(buf, 0, sizeof(*buf)); + buf->st_mode = S_IFDIR | 0777; + } + + return ret; +} + +int host_chstat(const char *path, const struct stat *buf, int flags) +{ + return -ENOSYS; +} diff --git a/arch/risc-v/src/common/riscv_internal.h b/arch/risc-v/src/common/riscv_internal.h index be7967e8ecb21..22b19f359ab7b 100644 --- a/arch/risc-v/src/common/riscv_internal.h +++ b/arch/risc-v/src/common/riscv_internal.h @@ -32,6 +32,7 @@ # include # include # include +# include #endif /**************************************************************************** @@ -49,6 +50,7 @@ /* RISC-V requires a 16-byte stack alignment. */ #define STACK_ALIGNMENT 16 +#define STACK_FRAME_SIZE __XSTR(STACK_ALIGNMENT) /* Stack alignment macros */ @@ -68,13 +70,8 @@ * only a reference stored in TCB. */ -#ifdef CONFIG_ARCH_FPU -#define riscv_savestate(regs) (regs = (uintptr_t *)CURRENT_REGS, riscv_savefpu(regs)) -#define riscv_restorestate(regs) (CURRENT_REGS = regs, riscv_restorefpu((uintptr_t *)CURRENT_REGS)) -#else #define riscv_savestate(regs) (regs = (uintptr_t *)CURRENT_REGS) #define riscv_restorestate(regs) (CURRENT_REGS = regs) -#endif #define _START_TEXT &_stext #define _END_TEXT &_etext @@ -112,6 +109,8 @@ #define PMP_ACCESS_DENIED (-1) /* Access set and denied */ #define PMP_ACCESS_FULL (1) /* Access set and allowed */ +#ifndef __ASSEMBLY__ + #define getreg8(a) (*(volatile uint8_t *)(a)) #define putreg8(v,a) (*(volatile uint8_t *)(a) = (v)) #define getreg16(a) (*(volatile uint16_t *)(a)) @@ -121,6 +120,37 @@ #define getreg64(a) (*(volatile uint64_t *)(a)) #define putreg64(v,a) (*(volatile uint64_t *)(a) = (v)) +#define READ_CSR(reg) \ + ({ \ + uintptr_t reg##_val; \ + __asm__ __volatile__("csrr %0, " __STR(reg) : "=r"(reg##_val)); \ + reg##_val; \ + }) + +#define READ_AND_SET_CSR(reg, bits) \ + ({ \ + uintptr_t reg##_val; \ + __asm__ __volatile__("csrrs %0, " __STR(reg) ", %1": "=r"(reg##_val) : "rK"(bits)); \ + reg##_val; \ + }) + +#define WRITE_CSR(reg, val) \ + ({ \ + __asm__ __volatile__("csrw " __STR(reg) ", %0" :: "rK"(val)); \ + }) + +#define SET_CSR(reg, bits) \ + ({ \ + __asm__ __volatile__("csrs " __STR(reg) ", %0" :: "rK"(bits)); \ + }) + +#define CLEAR_CSR(reg, bits) \ + ({ \ + __asm__ __volatile__("csrc " __STR(reg) ", %0" :: "rK"(bits)); \ + }) + +#endif + /**************************************************************************** * Public Types ****************************************************************************/ @@ -202,13 +232,12 @@ void riscv_copystate(uintptr_t *dest, uintptr_t *src); void riscv_sigdeliver(void); int riscv_swint(int irq, void *context, void *arg); uintptr_t riscv_get_newintctx(void); +void riscv_exception_attach(void); #ifdef CONFIG_ARCH_FPU -void riscv_savefpu(uintptr_t *regs); -void riscv_restorefpu(const uintptr_t *regs); +void riscv_fpuconfig(void); #else -# define riscv_savefpu(regs) -# define riscv_restorefpu(regs) +# define riscv_fpuconfig() #endif /* RISC-V PMP Config ********************************************************/ @@ -220,6 +249,13 @@ int riscv_check_pmp_access(uintptr_t attr, uintptr_t base, uintptr_t size); int riscv_configured_pmp_regions(void); int riscv_next_free_pmp_region(void); +/* RISC-V SBI wrappers ******************************************************/ + +#ifdef CONFIG_ARCH_USE_S_MODE +void riscv_sbi_set_timer(uint64_t stime_value); +uint64_t riscv_sbi_get_time(void); +#endif + /* Power management *********************************************************/ #ifdef CONFIG_PM @@ -256,8 +292,9 @@ void riscv_netinitialize(void); /* Exception Handler ********************************************************/ -void riscv_fault(int irq, uintptr_t *regs); -void riscv_exception(uintptr_t mcause, uintptr_t *regs); +uintptr_t *riscv_doirq(int irq, uintptr_t *regs); +int riscv_exception(int mcause, void *regs, void *args); +int riscv_misaligned(int irq, void *context, void *arg); /* Debug ********************************************************************/ @@ -283,6 +320,40 @@ int riscv_pause_handler(int irq, void *c, void *arg); uintptr_t riscv_mhartid(void); +/* If kernel runs in Supervisor mode, a system call trampoline is needed */ + +#ifdef CONFIG_ARCH_USE_S_MODE +void *riscv_perform_syscall(uintptr_t *regs); +#endif + +/* Context switching via system calls ***************************************/ + +/* SYS call 1: + * + * void riscv_fullcontextrestore(uintptr_t *restoreregs) noreturn_function; + */ + +#define riscv_fullcontextrestore(restoreregs) \ + sys_call1(SYS_restore_context, (uintptr_t)restoreregs) + +/* SYS call 2: + * + * void riscv_switchcontext(uintptr_t *saveregs, uintptr_t *restoreregs); + */ + +#define riscv_switchcontext(saveregs, restoreregs) \ + sys_call2(SYS_switch_context, (uintptr_t)saveregs, (uintptr_t)restoreregs) + +#ifdef CONFIG_BUILD_KERNEL +/* SYS call 3: + * + * void riscv_syscall_return(void); + */ + +#define riscv_syscall_return() sys_call0(SYS_syscall_return) + +#endif /* CONFIG_BUILD_KERNEL */ + #undef EXTERN #ifdef __cplusplus } diff --git a/arch/risc-v/src/common/riscv_macros.S b/arch/risc-v/src/common/riscv_macros.S new file mode 100644 index 0000000000000..0d43449ff8ce2 --- /dev/null +++ b/arch/risc-v/src/common/riscv_macros.S @@ -0,0 +1,310 @@ +/**************************************************************************** + * arch/risc-v/src/common/riscv_macros.S + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +.file "riscv_macros.S" + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include +#include +#include + +#include + +#include "riscv_internal.h" +#include "riscv_percpu.h" + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/**************************************************************************** + * Name: save_ctx + * + * Parameter: + * in - Pointer to where the save is performed (e.g. sp) + * + * Description: + * Save the common context registers (i.e. work / temp / etc). + * + ****************************************************************************/ + +.macro save_ctx in + + REGSTORE x1, REG_X1(\in) /* ra */ +#ifdef RISCV_SAVE_GP + REGSTORE x3, REG_X3(\in) /* gp */ +#endif + REGSTORE x4, REG_X4(\in) /* tp */ + REGSTORE x5, REG_X5(\in) /* t0 */ + REGSTORE x6, REG_X6(\in) /* t1 */ + REGSTORE x7, REG_X7(\in) /* t2 */ + REGSTORE x8, REG_X8(\in) /* s0 */ + REGSTORE x9, REG_X9(\in) /* s1 */ + REGSTORE x10, REG_X10(\in) /* a0 */ + REGSTORE x11, REG_X11(\in) /* a1 */ + REGSTORE x12, REG_X12(\in) /* a2 */ + REGSTORE x13, REG_X13(\in) /* a3 */ + REGSTORE x14, REG_X14(\in) /* a4 */ + REGSTORE x15, REG_X15(\in) /* a5 */ + REGSTORE x16, REG_X16(\in) /* a6 */ + REGSTORE x17, REG_X17(\in) /* a7 */ + REGSTORE x18, REG_X18(\in) /* s2 */ + REGSTORE x19, REG_X19(\in) /* s3 */ + REGSTORE x20, REG_X20(\in) /* s4 */ + REGSTORE x21, REG_X21(\in) /* s5 */ + REGSTORE x22, REG_X22(\in) /* s6 */ + REGSTORE x23, REG_X23(\in) /* s7 */ + REGSTORE x24, REG_X24(\in) /* s8 */ + REGSTORE x25, REG_X25(\in) /* s9 */ + REGSTORE x26, REG_X26(\in) /* s10 */ + REGSTORE x27, REG_X27(\in) /* s11 */ + REGSTORE x28, REG_X28(\in) /* t3 */ + REGSTORE x29, REG_X29(\in) /* t4 */ + REGSTORE x30, REG_X30(\in) /* t5 */ + REGSTORE x31, REG_X31(\in) /* t6 */ + +.endm + +/**************************************************************************** + * Name: riscv_savefpu + * + * Parameter: + * in - Pointer to where the save is performed (e.g. sp) + * + * Description: + * Save the FPU context registers (i.e. work / temp / etc). + * + ****************************************************************************/ + +.macro riscv_savefpu in + +#ifdef CONFIG_ARCH_FPU + REGLOAD t0, REG_INT_CTX(\in) + li t1, MSTATUS_FS + and t2, t0, t1 + li t1, MSTATUS_FS_DIRTY + bne t2, t1, skip_save_fpu + li t1, ~MSTATUS_FS + and t0, t0, t1 + li t1, MSTATUS_FS_CLEAN + or t0, t0, t1 + REGSTORE t0, REG_INT_CTX(\in) + + /* Store all floating point registers */ + + FSTORE f0, REG_F0(\in) + FSTORE f1, REG_F1(\in) + FSTORE f2, REG_F2(\in) + FSTORE f3, REG_F3(\in) + FSTORE f4, REG_F4(\in) + FSTORE f5, REG_F5(\in) + FSTORE f6, REG_F6(\in) + FSTORE f7, REG_F7(\in) + FSTORE f8, REG_F8(\in) + FSTORE f9, REG_F9(\in) + FSTORE f10, REG_F10(\in) + FSTORE f11, REG_F11(\in) + FSTORE f12, REG_F12(\in) + FSTORE f13, REG_F13(\in) + FSTORE f14, REG_F14(\in) + FSTORE f15, REG_F15(\in) + FSTORE f16, REG_F16(\in) + FSTORE f17, REG_F17(\in) + FSTORE f18, REG_F18(\in) + FSTORE f19, REG_F19(\in) + FSTORE f20, REG_F20(\in) + FSTORE f21, REG_F21(\in) + FSTORE f22, REG_F22(\in) + FSTORE f23, REG_F23(\in) + FSTORE f24, REG_F24(\in) + FSTORE f25, REG_F25(\in) + FSTORE f26, REG_F26(\in) + FSTORE f27, REG_F27(\in) + FSTORE f28, REG_F28(\in) + FSTORE f29, REG_F29(\in) + FSTORE f30, REG_F30(\in) + FSTORE f31, REG_F31(\in) + + frcsr t0 + REGSTORE t0, REG_FCSR(\in) + +skip_save_fpu: + +#endif + +.endm + +/**************************************************************************** + * Name: load_ctx + * + * Parameter: + * out - Pointer to where the load is performed (e.g. sp) + * + * Description: + * Load the common context registers (i.e. work / temp / etc). + * + ****************************************************************************/ + +.macro load_ctx out + + REGLOAD x1, REG_X1(\out) /* ra */ +#ifdef RISCV_SAVE_GP + REGLOAD x3, REG_X3(\out) /* gp */ +#endif + REGLOAD x4, REG_X4(\out) /* tp */ + REGLOAD x5, REG_X5(\out) /* t0 */ + REGLOAD x6, REG_X6(\out) /* t1 */ + REGLOAD x7, REG_X7(\out) /* t2 */ + REGLOAD x8, REG_X8(\out) /* s0 */ + REGLOAD x9, REG_X9(\out) /* s1 */ + REGLOAD x10, REG_X10(\out) /* a0 */ + REGLOAD x11, REG_X11(\out) /* a1 */ + REGLOAD x12, REG_X12(\out) /* a2 */ + REGLOAD x13, REG_X13(\out) /* a3 */ + REGLOAD x14, REG_X14(\out) /* a4 */ + REGLOAD x15, REG_X15(\out) /* a5 */ + REGLOAD x16, REG_X16(\out) /* a6 */ + REGLOAD x17, REG_X17(\out) /* a7 */ + REGLOAD x18, REG_X18(\out) /* s2 */ + REGLOAD x19, REG_X19(\out) /* s3 */ + REGLOAD x20, REG_X20(\out) /* s4 */ + REGLOAD x21, REG_X21(\out) /* s5 */ + REGLOAD x22, REG_X22(\out) /* s6 */ + REGLOAD x23, REG_X23(\out) /* s7 */ + REGLOAD x24, REG_X24(\out) /* s8 */ + REGLOAD x25, REG_X25(\out) /* s9 */ + REGLOAD x26, REG_X26(\out) /* s10 */ + REGLOAD x27, REG_X27(\out) /* s11 */ + REGLOAD x28, REG_X28(\out) /* t3 */ + REGLOAD x29, REG_X29(\out) /* t4 */ + REGLOAD x30, REG_X30(\out) /* t5 */ + REGLOAD x31, REG_X31(\out) /* t6 */ + +.endm + +/**************************************************************************** + * Name: riscv_loadfpu + * + * Parameter: + * out - Pointer to where the load is performed (e.g. sp) + * + * Description: + * Load the FPU context registers (i.e. work / temp / etc). + * + ****************************************************************************/ + +.macro riscv_loadfpu out + +#ifdef CONFIG_ARCH_FPU + REGLOAD t0, REG_INT_CTX(\out) + li t1, MSTATUS_FS + and t2, t0, t1 + li t1, MSTATUS_FS_INIT + ble t2, t1, skip_load_fpu + + /* Load all floating point registers */ + + FLOAD f0, REG_F0(\out) + FLOAD f1, REG_F1(\out) + FLOAD f2, REG_F2(\out) + FLOAD f3, REG_F3(\out) + FLOAD f4, REG_F4(\out) + FLOAD f5, REG_F5(\out) + FLOAD f6, REG_F6(\out) + FLOAD f7, REG_F7(\out) + FLOAD f8, REG_F8(\out) + FLOAD f9, REG_F9(\out) + FLOAD f10, REG_F10(\out) + FLOAD f11, REG_F11(\out) + FLOAD f12, REG_F12(\out) + FLOAD f13, REG_F13(\out) + FLOAD f14, REG_F14(\out) + FLOAD f15, REG_F15(\out) + FLOAD f16, REG_F16(\out) + FLOAD f17, REG_F17(\out) + FLOAD f18, REG_F18(\out) + FLOAD f19, REG_F19(\out) + FLOAD f20, REG_F20(\out) + FLOAD f21, REG_F21(\out) + FLOAD f22, REG_F22(\out) + FLOAD f23, REG_F23(\out) + FLOAD f24, REG_F24(\out) + FLOAD f25, REG_F25(\out) + FLOAD f26, REG_F26(\out) + FLOAD f27, REG_F27(\out) + FLOAD f28, REG_F28(\out) + FLOAD f29, REG_F29(\out) + FLOAD f30, REG_F30(\out) + FLOAD f31, REG_F31(\out) + + /* Store the floating point control and status register */ + + REGLOAD t0, REG_FCSR(\out) + fscsr t0 + +skip_load_fpu: + +#endif + +.endm + +/**************************************************************************** + * Name: setintstack + * + * Description: + * Set the current stack pointer to the "top" the interrupt stack. Works + * for single CPU case in flat mode. + * Must be provided by MCU-specific logic in the SMP case, or the kernel + * runs in supervisor mode (S-mode). + * + ****************************************************************************/ + +#if CONFIG_ARCH_INTERRUPTSTACK > 15 +#if !defined(CONFIG_SMP) && !defined(CONFIG_ARCH_USE_S_MODE) +.macro setintstack tmp0, tmp1 + la sp, g_intstacktop +.endm +#endif /* !defined(CONFIG_SMP) && !defined(CONFIG_ARCH_USE_S_MODE) */ +#endif /* CONFIG_ARCH_INTERRUPTSTACK > 15 */ + +/**************************************************************************** + * Name: riscv_mhartid + * + * Description: + * Context aware way to query hart id + * + * Returned Value: + * Hart id + * + ****************************************************************************/ + +.macro riscv_mhartid out +#ifdef CONFIG_ARCH_USE_S_MODE + csrr \out, CSR_SCRATCH + REGLOAD \out, RISCV_PERCPU_HARTID(\out) +#else + csrr \out, mhartid +#endif +.endm diff --git a/arch/risc-v/src/common/riscv_mhartid.S b/arch/risc-v/src/common/riscv_mhartid.S new file mode 100644 index 0000000000000..0cfcfc256c785 --- /dev/null +++ b/arch/risc-v/src/common/riscv_mhartid.S @@ -0,0 +1,53 @@ +/**************************************************************************** + * arch/risc-v/src/common/riscv_mhartid.S + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +.file "riscv_mhartid.S" + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include "riscv_macros.S" + +/**************************************************************************** + * Public Symbols + ****************************************************************************/ + + .globl riscv_mhartid + +/**************************************************************************** + * Name: riscv_mhartid + * + * Description: + * Context aware way to query hart id + * + * Returned Value: + * Hart id + * + ****************************************************************************/ + +.type riscv_mhartid, function + +riscv_mhartid: + + riscv_mhartid a0 + ret diff --git a/arch/risc-v/src/common/riscv_misaligned.c b/arch/risc-v/src/common/riscv_misaligned.c new file mode 100644 index 0000000000000..d92e50bfb712b --- /dev/null +++ b/arch/risc-v/src/common/riscv_misaligned.c @@ -0,0 +1,616 @@ +/**************************************************************************** + * arch/risc-v/src/common/riscv_misaligned.c + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include + +#include +#include +#include +#include +#include +#include + +#include "riscv_internal.h" + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/* Instruction mask for load/store */ + +#define INSN_MASK 0x707f +#define INSN_C_MASK 0xe003 + +/* Load instruction opcode */ + +#define INSN_LB 0x0003 +#define INSN_LH 0x1003 +#define INSN_LW 0x2003 +#define INSN_LD 0x3003 +#define INSN_LBU 0x4003 +#define INSN_LHU 0x5003 +#define INSN_LWU 0x6003 + +#define INSN_C_LW 0x4000 +#define INSN_C_LWSP 0x4002 +#define INSN_C_LD 0x6000 +#define INSN_C_LDSP 0x6002 + +/* Store instruction opcode */ + +#define INSN_SB 0x0023 +#define INSN_SH 0x1023 +#define INSN_SW 0x2023 +#define INSN_SD 0x3023 + +#define INSN_C_SW 0xc000 +#define INSN_C_SWSP 0xc002 +#define INSN_C_SD 0xe000 +#define INSN_C_SDSP 0xe002 + +/* Float load instruction opcode */ + +#define INSN_FLW 0x2007 +#define INSN_FLD 0x3007 + +#define INSN_C_FLW 0x6000 +#define INSN_C_FLWSP 0x6002 +#define INSN_C_FLD 0x2000 +#define INSN_C_FLDSP 0x2002 + +/* Float store instruction opcode */ + +#define INSN_FSW 0x2027 +#define INSN_FSD 0x3027 + +#define INSN_C_FSW 0xe000 +#define INSN_C_FSWSP 0xe002 +#define INSN_C_FSD 0xa000 +#define INSN_C_FSDSP 0xa002 + +/**************************************************************************** + * Private Type Definitions + ****************************************************************************/ + +/* Compressed instruction encoding */ + +typedef union +{ + uint16_t insn; + + /* Load */ + + struct + { + uint16_t op : 2; + uint16_t rd : 3; + uint16_t imm6 : 1; /* IMM bit [6] */ + uint16_t imm2 : 1; /* IMM bit [2] */ + uint16_t rs1 : 3; + uint16_t imm53 : 3; /* IMM bit [5:3] */ + uint16_t funct3 : 3; + } lw; + + struct + { + uint16_t op : 2; + uint16_t imm76 : 2; /* IMM bit [7:6] */ + uint16_t imm42 : 3; /* IMM bit [4:2] */ + uint16_t rd : 5; + uint16_t imm5 : 1; /* IMM bit [5] */ + uint16_t funct3 : 3; + } lwsp; + + struct + { + uint16_t op : 2; + uint16_t rd : 3; + uint16_t imm76 : 2; /* IMM bit [7:6] */ + uint16_t rs1 : 3; + uint16_t imm53 : 3; /* IMM bit [5:3] */ + uint16_t funct3 : 3; + } ld; + + struct + { + uint16_t op : 2; + uint16_t imm86 : 3; /* IMM bit [6:6] */ + uint16_t imm43 : 2; /* IMM bit [4:3] */ + uint16_t rd : 5; + uint16_t imm5 : 1; /* IMM bit [5] */ + uint16_t funct3 : 3; + } ldsp; + + /* Store */ + + struct + { + uint16_t op : 2; + uint16_t rs2 : 3; + uint16_t imm6 : 1; /* IMM bit [6] */ + uint16_t imm2 : 1; /* IMM bit [2] */ + uint16_t rs1 : 3; + uint16_t imm53 : 3; /* IMM bit [5:3] */ + uint16_t funct3 : 3; + } sw; + + struct + { + uint16_t op : 2; + uint16_t rs2 : 5; + uint16_t imm76 : 2; /* IMM bit [7:6] */ + uint16_t imm52 : 4; /* IMM bit [5:2] */ + uint16_t funct3 : 3; + } swsp; + + struct + { + uint16_t op : 2; + uint16_t rs2 : 3; + uint16_t imm76 : 2; /* IMM bit [7:6] */ + uint16_t rs1 : 3; + uint16_t imm53 : 3; /* IMM bit [5:3] */ + uint16_t funct3 : 3; + } sd; + + struct + { + uint16_t op : 2; + uint16_t rs2 : 5; + uint16_t imm86 : 3; /* IMM bit [8:6] */ + uint16_t imm53 : 3; /* IMM bit [5:3] */ + uint16_t funct3 : 3; + } sdsp; +} riscv_insn_c_t; + +/* Normal instruction encoding */ + +typedef union +{ + uint32_t insn; + + /* Load */ + + struct + { + uint32_t op : 7; + uint32_t rd : 5; + uint32_t funct3 : 3; + uint32_t rs1 : 5; + uint32_t imm : 12; + } l; + + /* Store */ + + struct + { + uint32_t op : 7; + uint32_t imm2 : 5; + uint32_t funct3 : 3; + uint32_t rs1 : 5; + uint32_t rs2 : 5; + uint32_t imm1 : 7; + } s; +} riscv_insn_t; + +typedef struct +{ + uint8_t *dest; + uint8_t *src; + int len; + bool sext; +} riscv_insn_ctx_t; + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: sext + * + * Description: + * Sign extension a given bit width data + * + ****************************************************************************/ + +static intptr_t sext(intptr_t v, uint32_t w) +{ + w = 8 * sizeof(intptr_t) - w; + return v << w >> w; +} + +/**************************************************************************** + * Name: decode_insn_compressed + * + * Description: + * Try to decode a compressed instruction + * + ****************************************************************************/ + +static bool decode_insn_compressed(uintptr_t *regs, riscv_insn_ctx_t *ctx) +{ +#ifdef CONFIG_ARCH_RV_ISA_C + uint16_t in; + uint32_t imm; + riscv_insn_c_t insn; + + /* Fetch instruction */ + + memcpy(&insn.insn, (void *)regs[REG_EPC], 2); + + in = insn.insn & INSN_C_MASK; + + switch (in) + { + /* Always need sign extension for c.lw/c.lwsp */ + + case INSN_C_LW: + imm = insn.lw.imm2 << 2 | insn.lw.imm53 << 3 | insn.lw.imm6 << 6; + ctx->dest = (uint8_t *)®s[REG_X8 + insn.lw.rd]; + ctx->src = (uint8_t *)regs[REG_X8 + insn.lw.rs1] + imm; + ctx->len = 4; + ctx->sext = true; + break; + + case INSN_C_LWSP: + imm = insn.lwsp.imm42 << 2 | insn.lwsp.imm5 << 5 | + insn.lwsp.imm76 << 6; + ctx->dest = (uint8_t *)®s[insn.lwsp.rd]; + ctx->src = (uint8_t *)regs[REG_SP] + imm; + ctx->len = 4; + ctx->sext = true; + break; + +# ifdef CONFIG_ARCH_RV64 + case INSN_C_LD: + imm = insn.ld.imm53 << 3 | insn.ld.imm76 << 6; + ctx->dest = (uint8_t *)®s[REG_X8 + insn.ld.rd]; + ctx->src = (uint8_t *)regs[REG_X8 + insn.ld.rs1] + imm; + ctx->len = 8; + break; + + case INSN_C_LDSP: + imm = insn.ldsp.imm43 << 3 | insn.ldsp.imm5 << 5 | + insn.ldsp.imm86 << 6; + ctx->dest = (uint8_t *)®s[insn.ld.rd]; + ctx->src = (uint8_t *)regs[REG_SP] + imm; + ctx->len = 8; + break; + + case INSN_C_SD: + imm = insn.sd.imm53 << 3 | insn.sd.imm76 << 6; + ctx->dest = (uint8_t *)regs[REG_X8 + insn.sd.rs1] + imm; + ctx->src = (uint8_t *)®s[REG_X8 + insn.sd.rs2]; + ctx->len = 8; + break; + + case INSN_C_SDSP: + imm = insn.sdsp.imm53 << 3 | insn.sdsp.imm86 << 6; + ctx->dest = (uint8_t *)regs[REG_SP] + imm; + ctx->src = (uint8_t *)®s[insn.sdsp.rs2]; + ctx->len = 8; + break; +# endif + + case INSN_C_SW: + imm = insn.sw.imm2 << 2 | insn.sw.imm53 << 3 | insn.sw.imm6 << 6; + ctx->dest = (uint8_t *)regs[REG_X8 + insn.sw.rs1] + imm; + ctx->src = (uint8_t *)®s[REG_X8 + insn.sd.rs2]; + ctx->len = 4; + break; + + case INSN_C_SWSP: + imm = insn.swsp.imm52 << 2 | insn.swsp.imm76 << 6; + ctx->dest = (uint8_t *)regs[REG_SP] + imm; + ctx->src = (uint8_t *)®s[insn.swsp.rs2]; + ctx->len = 4; + break; + +# ifdef CONFIG_ARCH_FPU +# ifdef CONFIG_ARCH_RV32 + case INSN_C_FLW: + + /* flw share the same encoding layout with lw */ + + imm = insn.lw.imm2 << 2 | insn.lw.imm53 << 3 | insn.lw.imm6 << 6; + ctx->dest = (uint8_t *)®s[REG_F8 + insn.lw.rd]; + ctx->src = (uint8_t *)regs[REG_X8 + insn.lw.rs1] + imm; + ctx->len = 4; + break; + + case INSN_C_FLWSP: + + /* flwsp share the same encoding layout with lwsp */ + + imm = insn.lwsp.imm42 << 2 | insn.lwsp.imm5 << 5 | + insn.lwsp.imm76 << 6; + ctx->dest = (uint8_t *)®s[REG_F0 + insn.lwsp.rd]; + ctx->src = (uint8_t *)regs[REG_SP] + imm; + ctx->len = 4; + break; + + case INSN_C_FSW: + + /* fsw share the same encoding layout with sw */ + + imm = insn.sw.imm2 << 2 | insn.sw.imm53 << 3 | insn.sw.imm6 << 6; + ctx->dest = (uint8_t *)regs[REG_X8 + insn.sw.rs1] + imm; + ctx->src = (uint8_t *)®s[REG_F8 + insn.sd.rs2]; + ctx->len = 4; + break; + + case INSN_C_FSWSP: + + /* fswsp share the same encoding layout with swsp */ + + imm = insn.swsp.imm52 << 2 | insn.swsp.imm76 << 6; + ctx->dest = (uint8_t *)regs[REG_SP] + imm; + ctx->src = (uint8_t *)®s[REG_F0 + insn.swsp.rs2]; + ctx->len = 4; + break; + +# endif + case INSN_C_FLD: + + /* fld share the same encoding layout with ld */ + + imm = insn.ld.imm53 << 3 | insn.ld.imm76 << 6; + ctx->dest = (uint8_t *)®s[REG_F8 + insn.ld.rd]; + ctx->src = (uint8_t *)regs[REG_X8 + insn.ld.rs1] + imm; + ctx->len = 8; + break; + + case INSN_C_FLDSP: + + /* fldsp share the same encoding layout with ldsp */ + + imm = insn.ldsp.imm43 << 3 | insn.ldsp.imm5 << 5 | + insn.ldsp.imm86 << 6; + ctx->dest = (uint8_t *)®s[REG_F0 + insn.ld.rd]; + ctx->src = (uint8_t *)regs[REG_SP] + imm; + ctx->len = 8; + break; + + case INSN_C_FSD: + + /* fsd share the same encoding layout with sd */ + + imm = insn.sd.imm53 << 3 | insn.sd.imm76 << 6; + ctx->dest = (uint8_t *)regs[REG_X8 + insn.sd.rs1] + imm; + ctx->src = (uint8_t *)®s[REG_F8 + insn.sd.rs2]; + ctx->len = 8; + break; + + case INSN_C_FSDSP: + + /* fsdsp share the same encoding layout with sdsp */ + + imm = insn.sdsp.imm53 << 3 | insn.sdsp.imm86 << 6; + ctx->dest = (uint8_t *)regs[REG_SP] + imm; + ctx->src = (uint8_t *)®s[REG_F0 + insn.sdsp.rs2]; + ctx->len = 8; + break; + +# endif + default: + _alert("Compressed: %x\n", insn.insn); + return false; + } + + regs[REG_EPC] += 2; + + return true; +#else + return false; +#endif +} + +/**************************************************************************** + * Name: decode_insn + * + * Description: + * Try to decode a normal encoding + * + ****************************************************************************/ + +static bool decode_insn(uintptr_t *regs, riscv_insn_ctx_t *ctx) +{ + static const uintptr_t x0; + uint32_t in; + int32_t imm; + riscv_insn_t insn; + + /* Fetch instruction */ + + memcpy(&insn.insn, (void *)regs[REG_EPC], 4); + + /* Get load/store instruction encoding */ + + in = insn.insn & INSN_MASK; + + switch (in) + { + case INSN_LH: + case INSN_LW: + + ctx->sext = true; + +#ifdef CONFIG_ARCH_RV64 + case INSN_LD: +#endif + + case INSN_LHU: + case INSN_LWU: + + /* Load a value from memory to register */ + + ctx->dest = (uint8_t *)®s[insn.l.rd]; + ctx->src = (uint8_t *)regs[insn.l.rs1] + + sext(insn.l.imm, 12); + + /* Zero the target register, no effect for sign extension */ + + *(uintptr_t *)ctx->dest = 0; + + /* Get data wide bit */ + + in &= ~0x4000; + in >>= 12; + ctx->len = 1 << in; + + break; + + case INSN_SH: + case INSN_SW: + +#ifdef CONFIG_ARCH_RV64 + case INSN_SD: +#endif + /* Fetch signed imm */ + + imm = sext(insn.s.imm2 | insn.s.imm1 << 5, 12); + + ctx->dest = (uint8_t *)regs[insn.s.rs1] + imm; + + /* If source register is x0, target it to constant register */ + + if (insn.s.rs2 == 0) + { + ctx->src = (uint8_t *)&x0; + } + else + { + ctx->src = (uint8_t *)®s[insn.s.rs2]; + } + + /* Get data wide bit */ + + in &= ~0x4000; + in >>= 12; + ctx->len = 1 << in; + + break; + +#ifdef CONFIG_ARCH_FPU + case INSN_FLW: + case INSN_FLD: + + ctx->dest = (uint8_t *)®s[REG_F0 + insn.l.rd]; + ctx->src = (uint8_t *)regs[insn.l.rs1] + + sext(insn.l.imm, 12); + + /* Is instruction flw or fld ? */ + + ctx->len = insn.l.funct3 == 0x2 ? 4 : 8; + break; + + case INSN_FSW: + case INSN_FSD: + + /* Fetch signed imm */ + + imm = sext(insn.s.imm2 | insn.s.imm1 << 5, 12); + + ctx->dest = (uint8_t *)regs[insn.s.rs1] + imm; + ctx->src = (uint8_t *)®s[REG_F0 + insn.s.rs2]; + + /* Is instruction fsw or fsd ? */ + + ctx->len = insn.s.funct3 == 0x2 ? 4 : 8; + + break; +#endif + default: + _alert("Uncompressed: %x\n", insn.insn); + return false; + } + + /* Adjust EPC */ + + regs[REG_EPC] += 4; + + return true; +} + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: riscv_misaligned + * + * Description: + * This is software interrupt exception handler that handle load/store + * address misaligned exception. + * + * Input Parameters: + * regs - The current exception context + * + ****************************************************************************/ + +int riscv_misaligned(int irq, void *context, void *arg) +{ + bool ret; + + riscv_insn_ctx_t ctx = + { + NULL, NULL, 0, false + }; + + /* Try to decode compressed instruction if it is */ + + ret = decode_insn_compressed(context, &ctx); + + /* Decode instruction context */ + + if (ret == false) + { + if (decode_insn(context, &ctx) == false) + { + /* Decode failed, we can't handle a invalid instruction */ + + PANIC(); + } + } + + /* Byte copy */ + + memcpy(ctx.dest, ctx.src, ctx.len); + + /* Do sign extension on need */ + + if (ctx.sext) + { + /* Note: Only load instruction need sext, so we can ensure the dest + * pointed to a register, and we do sext to the read out value of this + * register context and then write back. + */ + + *(intptr_t *)ctx.dest = sext(*(intptr_t *)ctx.dest, ctx.len * 8); + } + + return 0; +} diff --git a/arch/risc-v/src/common/riscv_mmu.c b/arch/risc-v/src/common/riscv_mmu.c index 4d92de0012f00..de94f0358df22 100644 --- a/arch/risc-v/src/common/riscv_mmu.c +++ b/arch/risc-v/src/common/riscv_mmu.c @@ -26,7 +26,7 @@ #include #include -#include +#include #include "riscv_internal.h" #include "riscv_mmu.h" @@ -113,6 +113,23 @@ uintptr_t mmu_ln_getentry(uint32_t ptlevel, uintptr_t lnvaddr, return lntable[index]; } +void mmu_ln_restore(uint32_t ptlevel, uintptr_t lnvaddr, uintptr_t vaddr, + uintptr_t entry) +{ + uintptr_t *lntable = (uintptr_t *)lnvaddr; + uint32_t index; + + DEBUGASSERT(ptlevel > 0 && ptlevel <= RV_MMU_PT_LEVELS); + + index = (vaddr >> RV_MMU_VADDR_SHIFT(ptlevel)) & RV_MMU_VPN_MASK; + + lntable[index] = entry; + + /* Update with memory by flushing the cache(s) */ + + mmu_invalidate_tlb_by_vaddr(vaddr); +} + void mmu_ln_map_region(uint32_t ptlevel, uintptr_t lnvaddr, uintptr_t paddr, uintptr_t vaddr, size_t size, uint32_t mmuflags) { diff --git a/arch/risc-v/src/common/riscv_mmu.h b/arch/risc-v/src/common/riscv_mmu.h index 461837f73a69e..4eae21645f55d 100644 --- a/arch/risc-v/src/common/riscv_mmu.h +++ b/arch/risc-v/src/common/riscv_mmu.h @@ -26,6 +26,10 @@ #define RV_MMU_PAGE_SHIFT (12) #define RV_MMU_PAGE_SIZE (1 << RV_MMU_PAGE_SHIFT) /* 4K pages */ +/* Entries per PGT */ + +#define RV_MMU_PAGE_ENTRIES (RV_MMU_PAGE_SIZE / sizeof(uintptr_t)) + /* Supervisor Address Translation and Protection (satp) */ #define SATP_PPN_SHIFT (0) @@ -45,6 +49,7 @@ /* satp address to PPN translation */ #define SATP_ADDR_TO_PPN(_addr) ((_addr) >> RV_MMU_PAGE_SHIFT) +#define SATP_PPN_TO_ADDR(_ppn) ((_ppn) << RV_MMU_PAGE_SHIFT) /* Common Page Table Entry (PTE) bits */ @@ -90,10 +95,10 @@ #ifdef CONFIG_ARCH_MMU_TYPE_SV39 #define RV_MMU_PTE_PADDR_SHIFT (10) -#define RV_MMU_PTE_PPN_MASK ((1 << RV_MMU_PTE_PADDR_SHIFT) - 1) +#define RV_MMU_PTE_PPN_MASK (((1ul << 44) - 1) << RV_MMU_PTE_PADDR_SHIFT) #define RV_MMU_PTE_PPN_SHIFT (2) #define RV_MMU_VPN_WIDTH (9) -#define RV_MMU_VPN_MASK ((1 << RV_MMU_VPN_WIDTH) - 1) +#define RV_MMU_VPN_MASK ((1ul << RV_MMU_VPN_WIDTH) - 1) #define RV_MMU_PT_LEVELS (3) #define RV_MMU_VADDR_SHIFT(_n) (RV_MMU_PAGE_SHIFT + RV_MMU_VPN_WIDTH * \ (RV_MMU_PT_LEVELS - (_n))) @@ -244,6 +249,47 @@ static inline void mmu_enable(uintptr_t pgbase, uint16_t asid) mmu_write_satp(reg); } +/**************************************************************************** + * Name: mmu_pte_to_paddr + * + * Description: + * Extract physical address from PTE + * + * Input Parameters: + * pte - Page table entry + * + * Returned Value: + * Physical address from PTE + * + ****************************************************************************/ + +static inline uintptr_t mmu_pte_to_paddr(uintptr_t pte) +{ + uintptr_t paddr = pte; + paddr &= RV_MMU_PTE_PPN_MASK; /* Remove flags */ + paddr <<= RV_MMU_PTE_PPN_SHIFT; /* Move to correct position */ + return paddr; +} + +/**************************************************************************** + * Name: mmu_get_satp_pgbase + * + * Description: + * Utility function to read the base page table physical address + * + * Returned Value: + * Physical address of the current base page table + * + ****************************************************************************/ + +static inline uintptr_t mmu_get_satp_pgbase(void) +{ + uintptr_t ppn; + ppn = mmu_read_satp(); + ppn = ((ppn >> SATP_PPN_SHIFT) & SATP_PPN_MASK); + return SATP_PPN_TO_ADDR(ppn); +} + /**************************************************************************** * Name: mmu_ln_setentry * @@ -279,11 +325,32 @@ void mmu_ln_setentry(uint32_t ptlevel, uintptr_t lnvaddr, uintptr_t paddr, * level n * vaddr - The virtual address to get pte for. Must be aligned to a PPN * address boundary which is dependent on the level of the entry + * ****************************************************************************/ uintptr_t mmu_ln_getentry(uint32_t ptlevel, uintptr_t lnvaddr, uintptr_t vaddr); +/**************************************************************************** + * Name: mmu_ln_restore + * + * Description: + * Restore a level n translation table entry. + * + * Input Parameters: + * ptlevel - The translation table level, amount of levels is + * MMU implementation specific + * lnvaddr - The virtual address of the beginning of the page table at + * level n + * vaddr - The virtual address to get pte for. Must be aligned to a PPN + * address boundary which is dependent on the level of the entry + * entry - Entry to restore, previously obtained by mmu_ln_getentry + * + ****************************************************************************/ + +void mmu_ln_restore(uint32_t ptlevel, uintptr_t lnvaddr, uintptr_t vaddr, + uintptr_t entry); + /**************************************************************************** * Name: mmu_ln_map_region * diff --git a/arch/risc-v/src/common/riscv_mtimer.c b/arch/risc-v/src/common/riscv_mtimer.c new file mode 100644 index 0000000000000..ff0c167364cd9 --- /dev/null +++ b/arch/risc-v/src/common/riscv_mtimer.c @@ -0,0 +1,338 @@ +/**************************************************************************** + * arch/risc-v/src/common/riscv_mtimer.c + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include +#include + +#include + +#include "riscv_mtimer.h" +#include "riscv_internal.h" + +/**************************************************************************** + * Private Types + ****************************************************************************/ + +/* This structure provides the private representation of the "lower-half" + * driver state structure. This structure must be cast-compatible with the + * oneshot_lowerhalf_s structure. + */ + +struct riscv_mtimer_lowerhalf_s +{ + struct oneshot_lowerhalf_s lower; + uintptr_t mtime; + uintptr_t mtimecmp; + uint64_t freq; + uint64_t alarm; + oneshot_callback_t callback; + void *arg; +}; + +/**************************************************************************** + * Private Function Prototypes + ****************************************************************************/ + +static int riscv_mtimer_max_delay(struct oneshot_lowerhalf_s *lower, + struct timespec *ts); +static int riscv_mtimer_start(struct oneshot_lowerhalf_s *lower, + oneshot_callback_t callback, void *arg, + const struct timespec *ts); +static int riscv_mtimer_cancel(struct oneshot_lowerhalf_s *lower, + struct timespec *ts); +static int riscv_mtimer_current(struct oneshot_lowerhalf_s *lower, + struct timespec *ts); + +/**************************************************************************** + * Private Data + ****************************************************************************/ + +static const struct oneshot_operations_s g_riscv_mtimer_ops = +{ + .max_delay = riscv_mtimer_max_delay, + .start = riscv_mtimer_start, + .cancel = riscv_mtimer_cancel, + .current = riscv_mtimer_current, +}; + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +#ifndef CONFIG_ARCH_USE_S_MODE +static uint64_t riscv_mtimer_get_mtime(struct riscv_mtimer_lowerhalf_s *priv) +{ +#ifdef CONFIG_ARCH_RV64 + /* priv->mtime is -1, means this SoC: + * 1. does NOT support 64bit/DWORD write for the mtimer compare value regs, + * 2. has NO memory mapped regs which hold the value of mtimer counter, + * it could be read from the CSR "time". + */ + + return -1 == priv->mtime ? READ_CSR(time) : getreg64(priv->mtime); +#else + uint32_t hi; + uint32_t lo; + + do + { + hi = getreg32(priv->mtime + 4); + lo = getreg32(priv->mtime); + } + while (getreg32(priv->mtime + 4) != hi); + + return ((uint64_t)hi << 32) | lo; +#endif +} + +static void riscv_mtimer_set_mtimecmp(struct riscv_mtimer_lowerhalf_s *priv, + uint64_t value) +{ +#ifdef CONFIG_ARCH_RV64 + if (-1 != priv->mtime) + { + putreg64(value, priv->mtimecmp); + } + else +#endif + { + putreg32(UINT32_MAX, priv->mtimecmp + 4); + putreg32(value, priv->mtimecmp); + putreg32(value >> 32, priv->mtimecmp + 4); + } + + /* Make sure it sticks */ + + __DMB(); +} +#else +static uint64_t riscv_mtimer_get_mtime(struct riscv_mtimer_lowerhalf_s *priv) +{ + UNUSED(priv); + return riscv_sbi_get_time(); +} + +static void riscv_mtimer_set_mtimecmp(struct riscv_mtimer_lowerhalf_s *priv, + uint64_t value) +{ + UNUSED(priv); + riscv_sbi_set_timer(value); +} +#endif + +/**************************************************************************** + * Name: riscv_mtimer_max_delay + * + * Description: + * Determine the maximum delay of the one-shot timer + * + * Input Parameters: + * lower An instance of the lower-half oneshot state structure. This + * structure must have been previously initialized via a call to + * oneshot_initialize(); + * ts The location in which to return the maximum delay. + * + * Returned Value: + * Zero (OK) is returned on success; a negated errno value is returned + * on failure. + * + ****************************************************************************/ + +static int riscv_mtimer_max_delay(struct oneshot_lowerhalf_s *lower, + struct timespec *ts) +{ + ts->tv_sec = UINT32_MAX; + ts->tv_nsec = NSEC_PER_SEC - 1; + + return 0; +} + +/**************************************************************************** + * Name: riscv_mtimer_start + * + * Description: + * Start the oneshot timer + * + * Input Parameters: + * lower An instance of the lower-half oneshot state structure. This + * structure must have been previously initialized via a call to + * oneshot_initialize(); + * handler The function to call when when the oneshot timer expires. + * arg An opaque argument that will accompany the callback. + * ts Provides the duration of the one shot timer. + * + * Returned Value: + * Zero (OK) is returned on success; a negated errno value is returned + * on failure. + * + ****************************************************************************/ + +static int riscv_mtimer_start(struct oneshot_lowerhalf_s *lower, + oneshot_callback_t callback, void *arg, + const struct timespec *ts) +{ + struct riscv_mtimer_lowerhalf_s *priv = + (struct riscv_mtimer_lowerhalf_s *)lower; + uint64_t mtime = riscv_mtimer_get_mtime(priv); + + priv->alarm = mtime + ts->tv_sec * priv->freq + + ts->tv_nsec * priv->freq / NSEC_PER_SEC; + if (priv->alarm < mtime) + { + priv->alarm = UINT64_MAX; + } + + priv->callback = callback; + priv->arg = arg; + + riscv_mtimer_set_mtimecmp(priv, priv->alarm); + return 0; +} + +/**************************************************************************** + * Name: riscv_mtimer_cancel + * + * Description: + * Cancel the oneshot timer and return the time remaining on the timer. + * + * NOTE: This function may execute at a high rate with no timer running (as + * when pre-emption is enabled and disabled). + * + * Input Parameters: + * lower Caller allocated instance of the oneshot state structure. This + * structure must have been previously initialized via a call to + * oneshot_initialize(); + * ts The location in which to return the time remaining on the + * oneshot timer. A time of zero is returned if the timer is + * not running. + * + * Returned Value: + * Zero (OK) is returned on success. A call to up_timer_cancel() when + * the timer is not active should also return success; a negated errno + * value is returned on any failure. + * + ****************************************************************************/ + +static int riscv_mtimer_cancel(struct oneshot_lowerhalf_s *lower, + struct timespec *ts) +{ + struct riscv_mtimer_lowerhalf_s *priv = + (struct riscv_mtimer_lowerhalf_s *)lower; + uint64_t mtime; + + riscv_mtimer_set_mtimecmp(priv, UINT64_MAX); + + mtime = riscv_mtimer_get_mtime(priv); + if (priv->alarm > mtime) + { + uint64_t nsec = (priv->alarm - mtime) * + NSEC_PER_SEC / priv->freq; + + ts->tv_sec = nsec / NSEC_PER_SEC; + ts->tv_nsec = nsec % NSEC_PER_SEC; + } + else + { + ts->tv_sec = 0; + ts->tv_nsec = 0; + } + + priv->alarm = 0; + priv->callback = NULL; + priv->arg = NULL; + + return 0; +} + +/**************************************************************************** + * Name: riscv_mtimer_current + * + * Description: + * Get the current time. + * + * Input Parameters: + * lower Caller allocated instance of the oneshot state structure. This + * structure must have been previously initialized via a call to + * oneshot_initialize(); + * ts The location in which to return the current time. A time of zero + * is returned for the initialization moment. + * + * Returned Value: + * Zero (OK) is returned on success, a negated errno value is returned on + * any failure. + * + ****************************************************************************/ + +static int riscv_mtimer_current(struct oneshot_lowerhalf_s *lower, + struct timespec *ts) +{ + struct riscv_mtimer_lowerhalf_s *priv = + (struct riscv_mtimer_lowerhalf_s *)lower; + uint64_t mtime = riscv_mtimer_get_mtime(priv); + uint64_t nsec = mtime * NSEC_PER_SEC / priv->freq; + + ts->tv_sec = nsec / NSEC_PER_SEC; + ts->tv_nsec = nsec % NSEC_PER_SEC; + + return 0; +} + +static int riscv_mtimer_interrupt(int irq, void *context, void *arg) +{ + struct riscv_mtimer_lowerhalf_s *priv = arg; + + riscv_mtimer_set_mtimecmp(priv, UINT64_MAX); + if (priv->callback != NULL) + { + priv->callback(&priv->lower, priv->arg); + } + + return 0; +} + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +struct oneshot_lowerhalf_s * +riscv_mtimer_initialize(uintptr_t mtime, uintptr_t mtimecmp, + int irq, uint64_t freq) +{ + struct riscv_mtimer_lowerhalf_s *priv; + + priv = kmm_zalloc(sizeof(*priv)); + if (priv != NULL) + { + priv->lower.ops = &g_riscv_mtimer_ops; + priv->mtime = mtime; + priv->mtimecmp = mtimecmp; + priv->freq = freq; + + riscv_mtimer_set_mtimecmp(priv, UINT64_MAX); + irq_attach(irq, riscv_mtimer_interrupt, priv); + up_enable_irq(irq); + } + + return (struct oneshot_lowerhalf_s *)priv; +} diff --git a/arch/risc-v/src/common/riscv_mtimer.h b/arch/risc-v/src/common/riscv_mtimer.h new file mode 100644 index 0000000000000..ce3339cec9af3 --- /dev/null +++ b/arch/risc-v/src/common/riscv_mtimer.h @@ -0,0 +1,51 @@ +/**************************************************************************** + * arch/risc-v/src/common/riscv_mtimer.h + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +#ifndef __ARCH_RISCV_SRC_COMMON_RISCV_MTIMER_H +#define __ARCH_RISCV_SRC_COMMON_RISCV_MTIMER_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +/**************************************************************************** + * Public Function Prototypes + ****************************************************************************/ + +#ifdef __cplusplus +#define EXTERN extern "C" +extern "C" +{ +#else +#define EXTERN extern +#endif + +struct oneshot_lowerhalf_s * +riscv_mtimer_initialize(uintptr_t mtime, uintptr_t mtimecmp, + int irq, uint64_t freq); + +#undef EXTERN +#ifdef __cplusplus +} +#endif + +#endif /* __ARCH_RISCV_SRC_COMMON_RISCV_MTIMER_H */ diff --git a/arch/risc-v/src/common/riscv_percpu.c b/arch/risc-v/src/common/riscv_percpu.c new file mode 100644 index 0000000000000..82c6fb0333493 --- /dev/null +++ b/arch/risc-v/src/common/riscv_percpu.c @@ -0,0 +1,194 @@ +/**************************************************************************** + * arch/risc-v/src/common/riscv_percpu.c + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include +#include +#include + +#include +#include + +#include +#include + +#include + +#include "riscv_internal.h" +#include "riscv_percpu.h" + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +#define HART_CNT (CONFIG_SMP_NCPUS) +#define STACK_SIZE (STACK_ALIGN_DOWN(CONFIG_ARCH_INTERRUPTSTACK)) + +static_assert(RISCV_PERCPU_HARTID == offsetof(riscv_percpu_t, hartid), + "RISCV_PERCPU_HARTID offset is wrong"); +static_assert(RISCV_PERCPU_IRQSTACK == offsetof(riscv_percpu_t, irq_stack), + "RISCV_PERCPU_IRQSTACK offset is wrong"); + +/**************************************************************************** + * Private Data + ****************************************************************************/ + +static riscv_percpu_t g_percpu[HART_CNT]; +static sq_queue_t g_freelist; +static uintptr_t g_initialized; + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: riscv_percpu_init + * + * Description: + * Initialize the per CPU structures, the first to get here does the init. + * + ****************************************************************************/ + +static void riscv_percpu_init(void) +{ + uintptr_t i; + uintptr_t initialized; + irqstate_t flags; + + /* Need to lock access during configuration */ + + flags = spin_lock_irqsave(NULL); + + /* Initialize if not done so already */ + + initialized = g_initialized; + g_initialized = 1; + + if (initialized == 1) + { + goto out_with_lock; + } + + sq_init(&g_freelist); + + for (i = 0; i < HART_CNT; i++) + { + /* Set interrupt stack (if any) */ + +#if CONFIG_ARCH_INTERRUPTSTACK > 15 + g_percpu[i].irq_stack = (uintptr_t)&g_intstacktop - i * STACK_SIZE; +#endif + + sq_addlast((struct sq_entry_s *) &g_percpu[i], &g_freelist); + } + +out_with_lock: + spin_unlock_irqrestore(NULL, flags); +} + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: riscv_percpu_add_hart + * + * Description: + * Get add a hart to the per CPU area + * + * Input Parameters: + * hartid - Hart number + * + ****************************************************************************/ + +void riscv_percpu_add_hart(uintptr_t hartid) +{ + riscv_percpu_t *percpu; + irqstate_t flags; + + /* Make sure we are initialized */ + + riscv_percpu_init(); + + /* Get free entry for this hart, this must not fail */ + + flags = spin_lock_irqsave(NULL); + percpu = (riscv_percpu_t *)sq_remfirst(&g_freelist); + spin_unlock_irqrestore(NULL, flags); + DEBUGASSERT(percpu); + + /* Assign hartid, stack has already been assigned */ + + percpu->hartid = hartid; + + /* Set the scratch register value to point to the scratch area */ + + WRITE_CSR(CSR_SCRATCH, percpu); + + /* Make sure it sticks */ + + __DMB(); +} + +/**************************************************************************** + * Name: riscv_percpu_get_hartid + * + * Description: + * Get harts own hartid by reading it from the per CPU area. This is safe + * to use from lower privilege modes (than M-mode). + * + * Returned Value: + * Hart id + * + ****************************************************************************/ + +uintptr_t riscv_percpu_get_hartid(void) +{ + uintptr_t scratch = READ_CSR(CSR_SCRATCH); + + DEBUGASSERT(scratch >= (uintptr_t) &g_percpu && + scratch < (uintptr_t) &g_percpu + sizeof(g_percpu)); + + return ((riscv_percpu_t *)scratch)->hartid; +} + +/**************************************************************************** + * Name: riscv_percpu_get_irqstack + * + * Description: + * Get harts own IRQ stack by reading it from the per CPU area. + * + * Returned Value: + * IRQ stack, or 0 if no IRQ stack is assigned + * + ****************************************************************************/ + +uintptr_t riscv_percpu_get_irqstack(void) +{ + uintptr_t scratch = READ_CSR(CSR_SCRATCH); + + DEBUGASSERT(scratch >= (uintptr_t) &g_percpu && + scratch < (uintptr_t) &g_percpu + sizeof(g_percpu)); + + return ((riscv_percpu_t *)scratch)->irq_stack; +} diff --git a/arch/arm/src/armv7-r/arm_testset.S b/arch/risc-v/src/common/riscv_percpu.h similarity index 54% rename from arch/arm/src/armv7-r/arm_testset.S rename to arch/risc-v/src/common/riscv_percpu.h index d8b1aeaad6f8a..61e1ea66b1a46 100644 --- a/arch/arm/src/armv7-r/arm_testset.S +++ b/arch/risc-v/src/common/riscv_percpu.h @@ -1,5 +1,5 @@ /**************************************************************************** - * arch/arm/src/armv7-r/arm_testset.S + * arch/risc-v/src/common/riscv_percpu.h * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with @@ -18,89 +18,103 @@ * ****************************************************************************/ +#ifndef __ARCH_RISC_V_SRC_COMMON_RISCV_PERCPU_H +#define __ARCH_RISC_V_SRC_COMMON_RISCV_PERCPU_H + /**************************************************************************** * Included Files ****************************************************************************/ #include -#include - .file "arm_testset.S" +#include + +#ifndef __ASSEMBLY__ +# include +# include +#endif /* __ASSEMBLY__ */ /**************************************************************************** * Pre-processor Definitions ****************************************************************************/ -/**************************************************************************** - * Public Symbols - ****************************************************************************/ +/* Can be used by assembly code to access the structure, example: + * + * Get percpu structure: + * 1: csrr a0, CSR_SCRATCH + * + * Get hartid: + * 2: REGLOAD a0, RISCV_PERCPU_HARTID(a0) + */ - .globl up_testset +#define RISCV_PERCPU_LIST (0 * INT_REG_SIZE) +#define RISCV_PERCPU_HARTID (1 * INT_REG_SIZE) +#define RISCV_PERCPU_IRQSTACK (2 * INT_REG_SIZE) -/**************************************************************************** - * Assembly Macros - ****************************************************************************/ +#ifndef __ASSEMBLY__ /**************************************************************************** - * Private Functions + * Public Types ****************************************************************************/ - .text +/* Per CPU save area. Access to this structure can be gained via the scratch + * ([m/s]scratch) register. Prior to this, every CPU that + * wishes to access this information must call riscv_percpu_add_hart() which + * will set up [m/s]scratch to point to the CPUs own area + */ + +struct riscv_percpu_s +{ + struct riscv_percpu_s *next; /* For sl list linkage */ + uintptr_t hartid; /* Hart ID */ + uintptr_t irq_stack; /* Interrupt stack */ +}; + +typedef struct riscv_percpu_s riscv_percpu_t; /**************************************************************************** - * Public Functions + * Public Function Prototypes ****************************************************************************/ /**************************************************************************** - * Name: up_testset + * Name: riscv_percpu_add_hart * * Description: - * Perform an atomic test and set operation on the provided spinlock. - * - * This function must be provided via the architecture-specific logic. + * Get add a hart to the per CPU area * * Input Parameters: - * lock - A reference to the spinlock object. - * - * Returned Value: - * The spinlock is always locked upon return. The previous value of the - * spinlock variable is returned, either SP_LOCKED if the spinlock was - * previously locked (meaning that the test-and-set operation failed to - * obtain the lock) or SP_UNLOCKED if the spinlock was previously unlocked - * (meaning that we successfully obtained the lock). + * hartid - Hart number * ****************************************************************************/ - .globl up_testset - .type up_testset, %function - -up_testset: - - mov r1, #SP_LOCKED - - /* Test if the spinlock is locked or not */ +void riscv_percpu_add_hart(uintptr_t hartid); -1: - ldrexb r2, [r0] /* Test if spinlock is locked or not */ - cmp r2, r1 /* Already locked? */ - beq 2f /* If already locked, return SP_LOCKED */ - - /* Not locked ... attempt to lock it */ - - strexb r2, r1, [r0] /* Attempt to set the locked state */ - cmp r2, r1 /* r2 will be 1 is strexb failed */ - beq 1b /* Failed to lock... try again */ +/**************************************************************************** + * Name: riscv_percpu_get_hartid + * + * Description: + * Get harts own hartid by reading it from the per CPU area. This is safe + * to use from lower privilege modes than M-mode. + * + * Returned Value: + * Hart id + * + ****************************************************************************/ - /* Lock acquired -- return SP_UNLOCKED */ +uintptr_t riscv_percpu_get_hartid(void); - dmb /* Required before accessing protected resource */ - mov r0, #SP_UNLOCKED - bx lr +/**************************************************************************** + * Name: riscv_percpu_get_irqstack + * + * Description: + * Get harts own IRQ stack by reading it from the per CPU area. + * + * Returned Value: + * IRQ stack, or 0 if no IRQ stack is assigned + * + ****************************************************************************/ - /* Lock not acquired -- return SP_LOCKED */ +uintptr_t riscv_percpu_get_irqstack(void); -2: - mov r0, #SP_LOCKED - bx lr - .size up_testset, . - up_testset - .end +#endif /* __ASSEMBLY__ */ +#endif /* __ARCH_RISC_V_SRC_COMMON_RISCV_PERCPU_H */ diff --git a/arch/risc-v/src/common/riscv_pgalloc.c b/arch/risc-v/src/common/riscv_pgalloc.c new file mode 100644 index 0000000000000..643d77dcd871b --- /dev/null +++ b/arch/risc-v/src/common/riscv_pgalloc.c @@ -0,0 +1,206 @@ +/**************************************************************************** + * arch/risc-v/src/common/riscv_pgalloc.c + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include + +#include "pgalloc.h" +#include "riscv_mmu.h" + +#ifdef CONFIG_BUILD_KERNEL + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/* Last PGT level */ + +#define PGT_LAST (RV_MMU_PT_LEVELS) + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: get_pgtable + * + * Description: + * Get the physical address of the last page table level corresponding to + * 'vaddr' + * + ****************************************************************************/ + +static uintptr_t get_pgtable(group_addrenv_t *addrenv, uintptr_t vaddr) +{ + uintptr_t paddr; + uintptr_t ptprev; + uint32_t ptlevel; + + /* Get the current level MAX_LEVELS-1 entry corresponding to this vaddr */ + + ptlevel = ARCH_SPGTS; + ptprev = riscv_pgvaddr(addrenv->spgtables[ARCH_SPGTS - 1]); + paddr = mmu_pte_to_paddr(mmu_ln_getentry(ptlevel, ptprev, vaddr)); + + if (!paddr) + { + /* No page table has been allocated... allocate one now */ + + paddr = mm_pgalloc(1); + if (paddr) + { + /* Wipe the page and assign it */ + + riscv_pgwipe(paddr); + mmu_ln_setentry(ptlevel, ptprev, paddr, vaddr, MMU_UPGT_FLAGS); + } + } + + /* Flush the data cache, so the changes are committed to memory */ + + __DMB(); + + return paddr; +} + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: pgalloc + * + * Description: + * If there is a page allocator in the configuration and if and MMU is + * available to map physical addresses to virtual address, then function + * must be provided by the platform-specific code. This is part of the + * implementation of sbrk(). This function will allocate the requested + * number of pages using the page allocator and map them into consecutive + * virtual addresses beginning with 'brkaddr' + * + * NOTE: This function does not use the up_ naming standard because it + * is indirectly callable from user-space code via a system trap. + * Therefore, it is a system interface and follows a different naming + * convention. + * + * Input Parameters: + * brkaddr - The heap break address. The next page will be allocated and + * mapped to this address. Must be page aligned. If the memory manager + * has not yet been initialized and this is the first block requested for + * the heap, then brkaddr should be zero. pgalloc will then assigned the + * well-known virtual address of the beginning of the heap. + * npages - The number of pages to allocate and map. Mapping of pages + * will be contiguous beginning beginning at 'brkaddr' + * + * Returned Value: + * The (virtual) base address of the mapped page will returned on success. + * Normally this will be the same as the 'brkaddr' input. However, if + * the 'brkaddr' input was zero, this will be the virtual address of the + * beginning of the heap. Zero is returned on any failure. + * + ****************************************************************************/ + +uintptr_t pgalloc(uintptr_t brkaddr, unsigned int npages) +{ + struct tcb_s *tcb = nxsched_self(); + struct task_group_s *group; + uintptr_t ptlast; + uintptr_t paddr; + uintptr_t vaddr; + + DEBUGASSERT(tcb && tcb->group); + group = tcb->group; + + /* The current implementation only supports extending the user heap + * region as part of the implementation of user sbrk(). This function + * needs to be expanded to also handle (1) extending the user stack + * space and (2) extending the kernel memory regions as well. + */ + + DEBUGASSERT((group->tg_flags & GROUP_FLAG_ADDRENV) != 0); + + /* brkaddr = 0 means that no heap has yet been allocated */ + + if (!brkaddr) + { + brkaddr = group->tg_addrenv.heapvbase; + } + + /* Start mapping from the old heap break address */ + + vaddr = brkaddr; + + /* Sanity checks */ + + DEBUGASSERT(brkaddr >= group->tg_addrenv.heapvbase); + DEBUGASSERT(MM_ISALIGNED(brkaddr)); + + for (; npages > 0; npages--) + { + /* Get the address of the last level page table */ + + ptlast = riscv_pgvaddr(get_pgtable(&group->tg_addrenv, vaddr)); + if (!ptlast) + { + return 0; + } + + /* Allocate physical memory for the new heap */ + + paddr = mm_pgalloc(1); + if (!paddr) + { + return 0; + } + + /* Wipe the memory */ + + riscv_pgwipe(paddr); + + /* Then add the reference */ + + mmu_ln_setentry(PGT_LAST, ptlast, paddr, vaddr, MMU_UDATA_FLAGS); + vaddr += MM_PGSIZE; + } + + /* Flush the data cache, so the changes are committed to memory */ + + __DMB(); + + return brkaddr; +} + +#endif /* CONFIG_BUILD_KERNEL */ diff --git a/arch/risc-v/src/common/riscv_pmp.c b/arch/risc-v/src/common/riscv_pmp.c index afa6a5e95f291..e9786aa9c4490 100644 --- a/arch/risc-v/src/common/riscv_pmp.c +++ b/arch/risc-v/src/common/riscv_pmp.c @@ -22,13 +22,14 @@ * Included Files ****************************************************************************/ +#include + #include #include #include -#include #include -#include +#include #include "riscv_internal.h" @@ -70,10 +71,10 @@ #define PMP_READ_REGION_FROM_REG(region, reg) \ ({ \ - uintptr_t tmp = READ_CSR(reg); \ - tmp >>= ((region % PMP_CFG_CNT_IN_REG) * PMP_CFG_BITS_CNT); \ - tmp &= PMP_CFG_FLAG_MASK; \ - tmp; \ + uintptr_t region##_val = READ_CSR(reg); \ + region##_val >>= ((region % PMP_CFG_CNT_IN_REG) * PMP_CFG_BITS_CNT); \ + region##_val &= PMP_CFG_FLAG_MASK; \ + region##_val; \ }) #ifndef min @@ -599,9 +600,14 @@ int riscv_config_pmp_region(uintptr_t region, uintptr_t attr, # error "XLEN of risc-v not supported" # endif - /* fence is needed when page-based virtual memory is implemented */ +#ifdef CONFIG_ARCH_USE_S_MODE + /* Fence is needed when page-based virtual memory is implemented. + * If page-based virtual memory is not implemented, memory accesses check + * the PMP settings synchronously, so no SFENCE.VMA is needed. + */ __asm volatile("sfence.vma x0, x0" : : : "memory"); +#endif return OK; } diff --git a/arch/risc-v/src/common/riscv_releasepending.c b/arch/risc-v/src/common/riscv_releasepending.c index 234c660c6b6a6..37978f13638c9 100644 --- a/arch/risc-v/src/common/riscv_releasepending.c +++ b/arch/risc-v/src/common/riscv_releasepending.c @@ -107,15 +107,6 @@ void up_release_pending(void) struct tcb_s *nexttcb = this_task(); -#ifdef CONFIG_ARCH_ADDRENV - /* Make sure that the address environment for the previously - * running task is closed down gracefully (data caches dump, - * MMU flushed) and set up the address environment for the new - * thread at the head of the ready-to-run list. - */ - - (void)group_addrenv(nexttcb); -#endif /* Update scheduler parameters */ nxsched_resume_scheduler(nexttcb); diff --git a/arch/risc-v/src/common/riscv_reprioritizertr.c b/arch/risc-v/src/common/riscv_reprioritizertr.c index c9d42232e5f0b..02c6e9f2e0289 100644 --- a/arch/risc-v/src/common/riscv_reprioritizertr.c +++ b/arch/risc-v/src/common/riscv_reprioritizertr.c @@ -159,15 +159,6 @@ void up_reprioritize_rtr(struct tcb_s *tcb, uint8_t priority) struct tcb_s *nexttcb = this_task(); -#ifdef CONFIG_ARCH_ADDRENV - /* Make sure that the address environment for the previously - * running task is closed down gracefully (data caches dump, - * MMU flushed) and set up the address environment for the new - * thread at the head of the ready-to-run list. - */ - - (void)group_addrenv(nexttcb); -#endif /* Update scheduler parameters */ nxsched_resume_scheduler(nexttcb); diff --git a/arch/risc-v/src/common/riscv_saveusercontext.c b/arch/risc-v/src/common/riscv_saveusercontext.c new file mode 100644 index 0000000000000..b5431d8290093 --- /dev/null +++ b/arch/risc-v/src/common/riscv_saveusercontext.c @@ -0,0 +1,50 @@ +/**************************************************************************** + * arch/risc-v/src/common/riscv_saveusercontext.c + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: up_saveusercontext + * + * Description: + * Save the current thread context. Full prototype is: + * + * int up_saveusercontext(void *saveregs); + * + * Returned Value: + * 0: Normal return + * 1: Context switch return + * + ****************************************************************************/ + +int up_saveusercontext(void *saveregs) +{ + return sys_call1(SYS_save_context, (uintptr_t)saveregs); +} diff --git a/arch/risc-v/src/common/riscv_schedulesigaction.c b/arch/risc-v/src/common/riscv_schedulesigaction.c index e8c5eab946a45..d9d25bc6c998c 100644 --- a/arch/risc-v/src/common/riscv_schedulesigaction.c +++ b/arch/risc-v/src/common/riscv_schedulesigaction.c @@ -126,8 +126,6 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver) * been delivered. */ - tcb->xcp.saved_regs = (uintptr_t *)CURRENT_REGS; - riscv_savestate(tcb->xcp.saved_regs); /* Duplicate the register context. These will be @@ -146,12 +144,13 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver) * privileged thread mode. */ - tcb->xcp.sigdeliver = sigdeliver; - CURRENT_REGS[REG_EPC] = (uintptr_t)riscv_sigdeliver; - int_ctx = CURRENT_REGS[REG_INT_CTX]; - int_ctx &= ~MSTATUS_MPIE; + tcb->xcp.sigdeliver = sigdeliver; + CURRENT_REGS[REG_EPC] = (uintptr_t)riscv_sigdeliver; + + int_ctx = CURRENT_REGS[REG_INT_CTX]; + int_ctx &= ~STATUS_PIE; #ifndef CONFIG_BUILD_FLAT - int_ctx |= MSTATUS_MPPM; + int_ctx |= STATUS_PPP; #endif CURRENT_REGS[REG_INT_CTX] = int_ctx; @@ -201,7 +200,7 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver) tcb->xcp.regs[REG_EPC] = (uintptr_t)riscv_sigdeliver; int_ctx = tcb->xcp.regs[REG_INT_CTX]; - int_ctx &= ~MSTATUS_MPIE; + int_ctx &= ~STATUS_PIE; tcb->xcp.regs[REG_INT_CTX] = int_ctx; @@ -312,9 +311,9 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver) tcb->xcp.regs[REG_EPC] = (uintptr_t)riscv_sigdeliver; int_ctx = tcb->xcp.regs[REG_INT_CTX]; - int_ctx &= ~MSTATUS_MPIE; -#ifdef CONFIG_BUILD_PROTECTED - int_ctx |= MSTATUS_MPPM; + int_ctx &= ~STATUS_PIE; +#ifndef CONFIG_BUILD_FLAT + int_ctx |= STATUS_PPP; #endif tcb->xcp.regs[REG_INT_CTX] = int_ctx; } @@ -353,9 +352,9 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver) CURRENT_REGS[REG_EPC] = (uintptr_t)riscv_sigdeliver; int_ctx = CURRENT_REGS[REG_INT_CTX]; - int_ctx &= ~MSTATUS_MPIE; + int_ctx &= ~STATUS_PIE; #ifndef CONFIG_BUILD_FLAT - int_ctx |= MSTATUS_MPPM; + int_ctx |= STATUS_PPP; #endif CURRENT_REGS[REG_INT_CTX] = int_ctx; @@ -429,7 +428,7 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver) tcb->xcp.regs[REG_EPC] = (uintptr_t)riscv_sigdeliver; int_ctx = tcb->xcp.regs[REG_INT_CTX]; - int_ctx &= ~MSTATUS_MPIE; + int_ctx &= ~STATUS_PIE; tcb->xcp.regs[REG_INT_CTX] = int_ctx; } diff --git a/arch/risc-v/src/common/riscv_semihost.S b/arch/risc-v/src/common/riscv_semihost.S new file mode 100644 index 0000000000000..0bd9db2f819bb --- /dev/null +++ b/arch/risc-v/src/common/riscv_semihost.S @@ -0,0 +1,40 @@ +/**************************************************************************** + * arch/risc-v/src/common/riscv_semihost.S + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +/**************************************************************************** + * Name: smh_call + * + * Description: + * Semihosting call with call number and one parameter + * + ****************************************************************************/ + + .option norvc + .text + .balign 16 + .global smh_call + .type smh_call @function + +smh_call: + + slli zero, zero, 0x1f + ebreak + srai zero, zero, 0x7 + ret diff --git a/arch/risc-v/src/common/riscv_sigdeliver.c b/arch/risc-v/src/common/riscv_sigdeliver.c index ac817be55ac57..ded797a405cea 100644 --- a/arch/risc-v/src/common/riscv_sigdeliver.c +++ b/arch/risc-v/src/common/riscv_sigdeliver.c @@ -120,7 +120,7 @@ void riscv_sigdeliver(void) DEBUGASSERT(rtcb->irqcount == 0); while (rtcb->irqcount < saved_irqcount) { - (void)enter_critical_section(); + enter_critical_section(); } #endif diff --git a/arch/risc-v/src/common/riscv_signal_handler.S b/arch/risc-v/src/common/riscv_signal_handler.S index 52d47042f8042..cd3e66302dcc6 100644 --- a/arch/risc-v/src/common/riscv_signal_handler.S +++ b/arch/risc-v/src/common/riscv_signal_handler.S @@ -24,8 +24,11 @@ #include +#include #include +#include "riscv_internal.h" + #if defined(CONFIG_BUILD_PROTECTED) && !defined(__KERNEL__) /**************************************************************************** @@ -69,8 +72,8 @@ up_signal_handler: /* Save ra on the stack */ - addi sp, sp, -16 - sd ra, 8(sp) + addi sp, sp, -STACK_FRAME_SIZE + REGSTORE ra, 8(sp) /* Call the signal handler */ @@ -82,8 +85,8 @@ up_signal_handler: /* Restore the register */ - ld ra, 8(sp) /* Restore ra in sp */ - addi sp, sp, 16 + REGLOAD ra, 8(sp) /* Restore ra in sp */ + addi sp, sp, STACK_FRAME_SIZE /* Execute the SYS_signal_handler_return SVCall (will not return) */ diff --git a/arch/risc-v/src/common/riscv_swint.c b/arch/risc-v/src/common/riscv_swint.c index 7d14148e1ca1d..a3d81adbcf714 100644 --- a/arch/risc-v/src/common/riscv_swint.c +++ b/arch/risc-v/src/common/riscv_swint.c @@ -32,6 +32,7 @@ #include #include +#include #include #include @@ -109,46 +110,33 @@ static void riscv_registerdump(const uintptr_t *regs) #ifdef CONFIG_LIB_SYSCALL static void dispatch_syscall(void) naked_function; -#ifdef CONFIG_ARCH_RV64 static void dispatch_syscall(void) { asm volatile ( - " addi sp, sp, -8\n" /* Create a stack frame to hold ra */ - " sd ra, 0(sp)\n" /* Save ra in the stack frame */ - " la t0, g_stublookup\n" /* t0=The base of the stub lookup table */ - " slli a0, a0, 3\n" /* a0=Offset for the stub lookup table */ - " add t0, t0, a0\n" /* t0=The address in the table */ - " ld t0, 0(t0)\n" /* t0=The address of the stub for this syscall */ - " jalr ra, t0\n" /* Call the stub (modifies ra) */ - " ld ra, 0(sp)\n" /* Restore ra */ - " addi sp, sp, 8\n" /* Destroy the stack frame */ - " mv a2, a0\n" /* a2=Save return value in a0 */ - " li a0, 3\n" /* a0=SYS_syscall_return (3) */ - " ecall" /* Return from the syscall */ - ); -} + "addi sp, sp, -" STACK_FRAME_SIZE "\n" /* Create a stack frame to hold ra */ + REGSTORE " ra, 0(sp)\n" /* Save ra in the stack frame */ + "la t0, g_stublookup\n" /* t0=The base of the stub lookup table */ +#ifdef CONFIG_ARCH_RV32 + "slli a0, a0, 2\n" /* a0=Offset for the stub lookup table */ #else -static void dispatch_syscall(void) -{ - asm volatile - ( - " addi sp, sp, -4\n" /* Create a stack frame to hold ra */ - " sw ra, 0(sp)\n" /* Save ra in the stack frame */ - " la t0, g_stublookup\n" /* t0=The base of the stub lookup table */ - " slli a0, a0, 3\n" /* a0=Offset for the stub lookup table */ - " add t0, t0, a0\n" /* t0=The address in the table */ - " lw t0, 0(t0)\n" /* t0=The address of the stub for this syscall */ - " jalr ra, t0\n" /* Call the stub (modifies ra) */ - " lw ra, 0(sp)\n" /* Restore ra */ - " addi sp, sp, 4\n" /* Destroy the stack frame */ - " mv a2, a0\n" /* a2=Save return value in a0 */ - " li a0, 3\n" /* a0=SYS_syscall_return (3) */ - " ecall" /* Return from the syscall */ + "slli a0, a0, 3\n" /* a0=Offset for the stub lookup table */ +#endif + "add t0, t0, a0\n" /* t0=The address in the table */ + REGLOAD " t0, 0(t0)\n" /* t0=The address of the stub for this syscall */ + "jalr ra, t0\n" /* Call the stub (modifies ra) */ + REGLOAD " ra, 0(sp)\n" /* Restore ra */ + "addi sp, sp, " STACK_FRAME_SIZE "\n" /* Destroy the stack frame */ + "mv a2, a0\n" /* a2=Save return value in a0 */ + "li a0, 3\n" /* a0=SYS_syscall_return (3) */ +#ifdef CONFIG_ARCH_USE_S_MODE + "j sys_call2" /* Return from the syscall */ +#else + "ecall" /* Return from the syscall */ +#endif ); } #endif -#endif /**************************************************************************** * Public Functions @@ -185,7 +173,7 @@ int riscv_swint(int irq, void *context, void *arg) { /* A0=SYS_save_context: This is a save context command: * - * int riscv_saveusercontext(uintptr saveregs); + * int up_saveusercontext(void *saveregs); * * At this point, the following values are saved in context: * @@ -223,7 +211,6 @@ int riscv_swint(int irq, void *context, void *arg) { DEBUGASSERT(regs[REG_A1] != 0); CURRENT_REGS = (uintptr_t *)regs[REG_A1]; - riscv_restorefpu((uintptr_t *)CURRENT_REGS); } break; @@ -247,8 +234,6 @@ int riscv_swint(int irq, void *context, void *arg) case SYS_switch_context: { DEBUGASSERT(regs[REG_A1] != 0 && regs[REG_A2] != 0); - riscv_savefpu(regs); - riscv_restorefpu((uintptr_t *)regs[REG_A2]); *(uintptr_t **)regs[REG_A1] = (uintptr_t *)regs; CURRENT_REGS = (uintptr_t *)regs[REG_A2]; } @@ -313,7 +298,7 @@ int riscv_swint(int irq, void *context, void *arg) */ rtcb->flags &= ~TCB_FLAG_SYSCALL; - (void)nxsig_unmask_pendingsignal(); + nxsig_unmask_pendingsignal(); } break; #endif @@ -352,7 +337,7 @@ int riscv_swint(int irq, void *context, void *arg) regs[REG_A0] = regs[REG_A2]; /* argc */ regs[REG_A1] = regs[REG_A3]; /* argv */ #endif - regs[REG_INT_CTX] &= ~MSTATUS_MPPM; /* User mode */ + regs[REG_INT_CTX] &= ~STATUS_PPP; /* User mode */ } break; #endif @@ -384,7 +369,7 @@ int riscv_swint(int irq, void *context, void *arg) regs[REG_A0] = regs[REG_A2]; /* pthread entry */ regs[REG_A1] = regs[REG_A3]; /* arg */ - regs[REG_INT_CTX] &= ~MSTATUS_MPPM; /* User mode */ + regs[REG_INT_CTX] &= ~STATUS_PPP; /* User mode */ } break; #endif @@ -423,7 +408,7 @@ int riscv_swint(int irq, void *context, void *arg) regs[REG_EPC] = (uintptr_t)ARCH_DATA_RESERVE->ar_sigtramp & ~1; #endif - regs[REG_INT_CTX] &= ~MSTATUS_MPPM; /* User mode */ + regs[REG_INT_CTX] &= ~STATUS_PPP; /* User mode */ /* Change the parameter ordering to match the expectation of struct * userpace_s signal_handler. @@ -473,7 +458,7 @@ int riscv_swint(int irq, void *context, void *arg) DEBUGASSERT(rtcb->xcp.sigreturn != 0); regs[REG_EPC] = rtcb->xcp.sigreturn & ~1; - regs[REG_INT_CTX] |= MSTATUS_MPPM; /* Machine mode */ + regs[REG_INT_CTX] |= STATUS_PPP; /* Privileged mode */ rtcb->xcp.sigreturn = 0; @@ -521,7 +506,7 @@ int riscv_swint(int irq, void *context, void *arg) rtcb->xcp.syscall[index].sysreturn = regs[REG_EPC]; #ifndef CONFIG_BUILD_FLAT - rtcb->xcp.syscall[index].int_ctx = regs[REG_INT_CTX]; + rtcb->xcp.syscall[index].int_ctx = regs[REG_INT_CTX]; #endif rtcb->xcp.nsyscalls = index + 1; @@ -529,7 +514,7 @@ int riscv_swint(int irq, void *context, void *arg) regs[REG_EPC] = (uintptr_t)dispatch_syscall & ~1; #ifndef CONFIG_BUILD_FLAT - regs[REG_INT_CTX] |= MSTATUS_MPPM; /* Machine mode */ + regs[REG_INT_CTX] |= STATUS_PPP; /* Privileged mode */ #endif /* Offset A0 to account for the reserved values */ @@ -571,7 +556,7 @@ int riscv_swint(int irq, void *context, void *arg) } else { - svcinfo("SWInt Return: %d\n", regs[REG_A0]); + svcinfo("SWInt Return: %" PRIxPTR "\n", regs[REG_A0]); } #endif diff --git a/arch/risc-v/src/common/riscv_tcbinfo.c b/arch/risc-v/src/common/riscv_tcbinfo.c index bca8cff149fee..72183bd27facd 100644 --- a/arch/risc-v/src/common/riscv_tcbinfo.c +++ b/arch/risc-v/src/common/riscv_tcbinfo.c @@ -35,7 +35,7 @@ static const uint16_t g_reg_offs[] = { - 0, /* x0 */ + UINT16_MAX, /* x0 */ TCB_REG_OFF(REG_X1_NDX), TCB_REG_OFF(REG_X2_NDX), TCB_REG_OFF(REG_X3_NDX), @@ -102,8 +102,8 @@ static const uint16_t g_reg_offs[] = TCB_REG_OFF(REG_F29_NDX), TCB_REG_OFF(REG_F30_NDX), TCB_REG_OFF(REG_F31_NDX), - 0, /* fflags */ - 0, /* frm */ + UINT16_MAX, /* fflags */ + UINT16_MAX, /* frm */ TCB_REG_OFF(REG_FCSR_NDX), #endif }; @@ -114,11 +114,13 @@ static const uint16_t g_reg_offs[] = const struct tcbinfo_s g_tcbinfo = { - TCB_PID_OFF, - TCB_STATE_OFF, - TCB_PRI_OFF, - TCB_NAME_OFF, - XCPTCONTEXT_REGS, + .pid_off = TCB_PID_OFF, + .state_off = TCB_STATE_OFF, + .pri_off = TCB_PRI_OFF, + .name_off = TCB_NAME_OFF, + .regs_off = TCB_REGS_OFF, + .basic_num = 33, + .total_num = XCPTCONTEXT_REGS, { .p = g_reg_offs, }, diff --git a/arch/risc-v/src/common/riscv_unblocktask.c b/arch/risc-v/src/common/riscv_unblocktask.c index 678f895871253..c72360dadcfd7 100644 --- a/arch/risc-v/src/common/riscv_unblocktask.c +++ b/arch/risc-v/src/common/riscv_unblocktask.c @@ -122,15 +122,6 @@ void up_unblock_task(struct tcb_s *tcb) struct tcb_s *nexttcb = this_task(); -#ifdef CONFIG_ARCH_ADDRENV - /* Make sure that the address environment for the previously - * running task is closed down gracefully (data caches dump, - * MMU flushed) and set up the address environment for the new - * thread at the head of the ready-to-run list. - */ - - (void)group_addrenv(nexttcb); -#endif /* Update scheduler parameters */ nxsched_resume_scheduler(nexttcb); diff --git a/arch/risc-v/src/common/riscv_vectors.S b/arch/risc-v/src/common/riscv_vectors.S index d7f0163d4412f..8f68edaf1b949 100644 --- a/arch/risc-v/src/common/riscv_vectors.S +++ b/arch/risc-v/src/common/riscv_vectors.S @@ -23,11 +23,16 @@ ****************************************************************************/ .section .text - .balign 4 + .balign 8 .global __trap_vec /**************************************************************************** - * Name: exception_common + * Name: __trap_vec + * + * Description: + * All M-mode exceptions and interrupts will be handled from here. If + * kernel is in S-mode delegated exceptions and interrupts are handled. + * ****************************************************************************/ __trap_vec: diff --git a/arch/risc-v/src/common/riscv_vfork.c b/arch/risc-v/src/common/riscv_vfork.c index 29e091b03f58b..7403b946701c7 100644 --- a/arch/risc-v/src/common/riscv_vfork.c +++ b/arch/risc-v/src/common/riscv_vfork.c @@ -1,5 +1,5 @@ /**************************************************************************** - * arch/risc-v/src/rv32im/riscv_vfork.c + * arch/risc-v/src/common/riscv_vfork.c * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with @@ -35,6 +35,8 @@ #include #include "riscv_vfork.h" +#include "riscv_internal.h" + #include "sched/sched.h" /**************************************************************************** @@ -95,40 +97,39 @@ #ifdef CONFIG_ARCH_HAVE_VFORK -#error This part of the port is not done yet!! - pid_t up_vfork(const struct vfork_s *context) { struct tcb_s *parent = this_task(); struct task_tcb_s *child; - uint32_t newsp; + uintptr_t newsp; #ifdef CONFIG_RISCV_FRAMEPOINTER - uint32_t newfp; + uintptr_t newfp; #endif - uint32_t newtop; - uint32_t stacktop; - uint32_t stackutil; + uintptr_t newtop; + uintptr_t stacktop; + uintptr_t stackutil; - sinfo("s0:%08x s1:%08x s2:%08x s3:%08x s4:%08x\n", + sinfo("s0:%" PRIxREG " s1:%" PRIxREG " s2:%" PRIxREG " s3:%" PRIxREG "" + " s4:%" PRIxREG "\n", context->s0, context->s1, context->s2, context->s3, context->s4); #ifdef CONFIG_RISCV_FRAMEPOINTER - sinfo("s5:%08x s6:%08x s7:%08x\n", + sinfo("s5:%" PRIxREG " s6:%" PRIxREG " s7:%" PRIxREG "\n", context->s5, context->s6, context->s7); #ifdef RISCV_SAVE_GP - sinfo("fp:%08x sp:%08x ra:%08x gp:%08x\n", + sinfo("fp:%" PRIxREG " sp:%" PRIxREG " ra:%" PRIxREG " gp:%" PRIxREG "\n", context->fp, context->sp, context->ra, context->gp); #else - sinfo("fp:%08x sp:%08x ra:%08x\n", + sinfo("fp:%" PRIxREG " sp:%" PRIxREG " ra:%" PRIxREG "\n", context->fp context->sp, context->ra); #endif #else - sinfo("s5:%08x s6:%08x s7:%08x s8:%08x\n", + sinfo("s5:%" PRIxREG " s6:%" PRIxREG " s7:%" PRIxREG " s8:%" PRIxREG "\n", context->s5, context->s6, context->s7, context->s8); #ifdef RISCV_SAVE_GP - sinfo("sp:%08x ra:%08x gp:%08x\n", + sinfo("sp:%" PRIxREG " ra:%" PRIxREG " gp:%" PRIxREG "\n", context->sp, context->ra, context->gp); #else - sinfo("sp:%08x ra:%08x\n", + sinfo("sp:%" PRIxREG " ra:%" PRIxREG "\n", context->sp, context->ra); #endif #endif @@ -150,12 +151,11 @@ pid_t up_vfork(const struct vfork_s *context) * stack usage should be the difference between those two. */ - stacktop = (uint32_t)parent->stack_base_ptr + - parent->adj_stack_size; + stacktop = (uintptr_t)parent->stack_base_ptr + parent->adj_stack_size; DEBUGASSERT(stacktop > context->sp); stackutil = stacktop - context->sp; - sinfo("Parent: stackutil:%" PRIu32 "\n", stackutil); + sinfo("Parent: stackutil:%" PRIxREG "\n", stackutil); /* Make some feeble effort to preserve the stack contents. This is * feeble because the stack surely contains invalid pointers and other @@ -164,9 +164,15 @@ pid_t up_vfork(const struct vfork_s *context) * effort is overkill. */ - newtop = (uint32_t)child->cmn.stack_base_ptr + - child->cmn.adj_stack_size; + newtop = (uintptr_t)child->cmn.stack_base_ptr + child->cmn.adj_stack_size; newsp = newtop - stackutil; + + /* Set up frame for context */ + + memcpy((void *)(newsp - XCPTCONTEXT_SIZE), + child->cmn.xcp.regs, XCPTCONTEXT_SIZE); + + child->cmn.xcp.regs = (void *)(newsp - XCPTCONTEXT_SIZE); memcpy((void *)newsp, (const void *)context->sp, stackutil); /* Was there a frame pointer in place before? */ @@ -174,7 +180,7 @@ pid_t up_vfork(const struct vfork_s *context) #ifdef CONFIG_RISCV_FRAMEPOINTER if (context->fp >= context->sp && context->fp < stacktop) { - uint32_t frameutil = stacktop - context->fp; + uintptr_t frameutil = stacktop - context->fp; newfp = newtop - frameutil; } else @@ -182,14 +188,14 @@ pid_t up_vfork(const struct vfork_s *context) newfp = context->fp; } - sinfo("Old stack top:%08x SP:%08x FP:%08x\n", + sinfo("Old stack top:%" PRIxREG " SP:%" PRIxREG " FP:%" PRIxREG "\n", stacktop, context->sp, context->fp); - sinfo("New stack top:%08x SP:%08x FP:%08x\n", + sinfo("New stack top:%" PRIxREG " SP:%" PRIxREG " FP:%" PRIxREG "\n", newtop, newsp, newfp); #else - sinfo("Old stack top:%08x SP:%08x\n", + sinfo("Old stack top:%" PRIxREG " SP:%" PRIxREG "\n", stacktop, context->sp); - sinfo("New stack top:%08x SP:%08x\n", + sinfo("New stack top:%" PRIxREG " SP:%" PRIxREG "\n", newtop, newsp); #endif @@ -218,6 +224,29 @@ pid_t up_vfork(const struct vfork_s *context) child->cmn.xcp.regs[REG_GP] = newsp; /* Global pointer */ #endif +#ifdef CONFIG_LIB_SYSCALL + /* If we got here via a syscall, then we are going to have to setup some + * syscall return information as well. + */ + + if (parent->xcp.nsyscalls > 0) + { + int index; + for (index = 0; index < parent->xcp.nsyscalls; index++) + { + child->cmn.xcp.syscall[index].sysreturn = + parent->xcp.syscall[index].sysreturn; + +#ifndef CONFIG_BUILD_FLAT + child->cmn.xcp.syscall[index].int_ctx = + parent->xcp.syscall[index].int_ctx; +#endif + } + + child->cmn.xcp.nsyscalls = parent->xcp.nsyscalls; + } +#endif /* CONFIG_LIB_SYSCALL */ + /* And, finally, start the child task. On a failure, nxtask_start_vfork() * will discard the TCB by calling nxtask_abort_vfork(). */ diff --git a/arch/risc-v/src/common/riscv_vfork.h b/arch/risc-v/src/common/riscv_vfork.h index cf07984b47e83..24fed6942b5aa 100644 --- a/arch/risc-v/src/common/riscv_vfork.h +++ b/arch/risc-v/src/common/riscv_vfork.h @@ -26,7 +26,7 @@ ****************************************************************************/ #include -#include +#include /**************************************************************************** * Pre-processor Definitions @@ -60,28 +60,28 @@ * r31 ra Return address. */ -#define VFORK_S0_OFFSET (0*4) /* Saved register s0 */ -#define VFORK_S1_OFFSET (1*4) /* Saved register s1 */ -#define VFORK_S2_OFFSET (2*4) /* Saved register s2 */ -#define VFORK_S3_OFFSET (3*4) /* Saved register s3 */ -#define VFORK_S4_OFFSET (4*4) /* Saved register s4 */ -#define VFORK_S5_OFFSET (5*4) /* Saved register s5 */ -#define VFORK_S6_OFFSET (6*4) /* Saved register s6 */ -#define VFORK_S7_OFFSET (7*4) /* Saved register s7 */ +#define VFORK_S0_OFFSET (0*INT_REG_SIZE) /* Saved register s0 */ +#define VFORK_S1_OFFSET (1*INT_REG_SIZE) /* Saved register s1 */ +#define VFORK_S2_OFFSET (2*INT_REG_SIZE) /* Saved register s2 */ +#define VFORK_S3_OFFSET (3*INT_REG_SIZE) /* Saved register s3 */ +#define VFORK_S4_OFFSET (4*INT_REG_SIZE) /* Saved register s4 */ +#define VFORK_S5_OFFSET (5*INT_REG_SIZE) /* Saved register s5 */ +#define VFORK_S6_OFFSET (6*INT_REG_SIZE) /* Saved register s6 */ +#define VFORK_S7_OFFSET (7*INT_REG_SIZE) /* Saved register s7 */ #ifdef CONFIG_RISCV_FRAMEPOINTER -# define VFORK_FP_OFFSET (8*4) /* Frame pointer */ +# define VFORK_FP_OFFSET (8*INT_REG_SIZE) /* Frame pointer */ #else -# define VFORK_S8_OFFSET (8*4) /* Saved register s8 */ +# define VFORK_S8_OFFSET (8*INT_REG_SIZE) /* Saved register s8 */ #endif -#define VFORK_SP_OFFSET (9*4) /* Stack pointer*/ -#define VFORK_RA_OFFSET (10*4) /* Return address*/ +#define VFORK_SP_OFFSET (9*INT_REG_SIZE) /* Stack pointer*/ +#define VFORK_RA_OFFSET (10*INT_REG_SIZE) /* Return address*/ #ifdef RISCV_SAVE_GP -# define VFORK_GP_OFFSET (11*4) /* Global pointer */ -# define VFORK_SIZEOF (12*4) +# define VFORK_GP_OFFSET (11*INT_REG_SIZE) /* Global pointer */ +# define VFORK_SIZEOF (12*INT_REG_SIZE) #else -# define VFORK_SIZEOF (11*4) +# define VFORK_SIZEOF (11*INT_REG_SIZE) #endif /**************************************************************************** @@ -93,23 +93,23 @@ struct vfork_s { /* CPU registers */ - uint32_t s0; /* Saved register s0 */ - uint32_t s1; /* Saved register s1 */ - uint32_t s2; /* Saved register s2 */ - uint32_t s3; /* Saved register s3 */ - uint32_t s4; /* Saved register s4 */ - uint32_t s5; /* Saved register s5 */ - uint32_t s6; /* Saved register s6 */ - uint32_t s7; /* Saved register s7 */ + uintptr_t s0; /* Saved register s0 */ + uintptr_t s1; /* Saved register s1 */ + uintptr_t s2; /* Saved register s2 */ + uintptr_t s3; /* Saved register s3 */ + uintptr_t s4; /* Saved register s4 */ + uintptr_t s5; /* Saved register s5 */ + uintptr_t s6; /* Saved register s6 */ + uintptr_t s7; /* Saved register s7 */ #ifdef CONFIG_RISCV_FRAMEPOINTER - uint32_t fp; /* Frame pointer */ + uintptr_t fp; /* Frame pointer */ #else - uint32_t s8; /* Saved register s8 */ + uintptr_t s8; /* Saved register s8 */ #endif - uint32_t sp; /* Stack pointer */ - uint32_t ra; /* Return address */ + uintptr_t sp; /* Stack pointer */ + uintptr_t ra; /* Return address */ #ifdef RISCV_SAVE_GP - uint32_t gp; /* Global pointer */ + uintptr_t gp; /* Global pointer */ #endif /* Floating point registers (not yet) */ diff --git a/arch/risc-v/src/common/supervisor/Make.defs b/arch/risc-v/src/common/supervisor/Make.defs new file mode 100644 index 0000000000000..3fbca963e97f3 --- /dev/null +++ b/arch/risc-v/src/common/supervisor/Make.defs @@ -0,0 +1,28 @@ +############################################################################ +# arch/risc-v/src/common/supervisor/Make.defs +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. The +# ASF licenses this file to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance with the +# License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +# +############################################################################ + +# If the NuttX kernel runs in S-mode + +CMN_ASRCS += riscv_syscall.S +CMN_CSRCS += riscv_perform_syscall.c +CMN_CSRCS += riscv_percpu.c riscv_sbi.c + +INCLUDES += ${shell $(INCDIR) "$(CC)" $(ARCH_SRCDIR)$(DELIM)common$(DELIM)supervisor} +VPATH += common$(DELIM)supervisor diff --git a/arch/risc-v/src/common/supervisor/riscv_perform_syscall.c b/arch/risc-v/src/common/supervisor/riscv_perform_syscall.c new file mode 100644 index 0000000000000..af32ec2cef8d0 --- /dev/null +++ b/arch/risc-v/src/common/supervisor/riscv_perform_syscall.c @@ -0,0 +1,65 @@ +/**************************************************************************** + * arch/risc-v/src/common/supervisor/riscv_perform_syscall.c + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include + +#include "riscv_internal.h" +#include "group/group.h" + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +void *riscv_perform_syscall(uintptr_t *regs) +{ + /* Set up the interrupt register set needed by swint() */ + + CURRENT_REGS = regs; + + /* Run the system call handler (swint) */ + + riscv_swint(0, regs, NULL); + +#ifdef CONFIG_ARCH_ADDRENV + if (regs != CURRENT_REGS) + { + /* Make sure that the address environment for the previously + * running task is closed down gracefully (data caches dump, + * MMU flushed) and set up the address environment for the new + * thread at the head of the ready-to-run list. + */ + + group_addrenv(NULL); + } +#endif + + /* Set new context */ + + regs = (uintptr_t *)CURRENT_REGS; + CURRENT_REGS = NULL; + + return regs; +} diff --git a/arch/risc-v/src/common/supervisor/riscv_sbi.c b/arch/risc-v/src/common/supervisor/riscv_sbi.c new file mode 100644 index 0000000000000..a3fc990ac9167 --- /dev/null +++ b/arch/risc-v/src/common/supervisor/riscv_sbi.c @@ -0,0 +1,91 @@ +/**************************************************************************** + * arch/risc-v/src/common/supervisor/riscv_sbi.c + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include +#include + +#include + +#include "riscv_internal.h" + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +#ifdef CONFIG_ARCH_RV64 +static inline uint64_t rdtime(void) +{ + uint32_t hi; + uint32_t lo; + + do + { + hi = READ_CSR(timeh); + lo = READ_CSR(time); + } + while (hi != READ_CSR(timeh)); + + return (((uint64_t) hi) << 32) | lo; +} +#else +#define rdtime() READ_CSR(time) +#endif /* CONFIG_ARCH_RV64 */ + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: riscv_sbi_set_timer + * + * Description: + * Set new compare match value for timer + * + * Input Parameters: + * stime_value - Value to set + * + ****************************************************************************/ + +void riscv_sbi_set_timer(uint64_t stime_value) +{ +#if 0 +#error "Missing functionality..." +#endif +} + +/**************************************************************************** + * Name: riscv_sbi_get_time + * + * Description: + * Get value of mtime + * + * Return: + * Value of mtime + * + ****************************************************************************/ + +uint64_t riscv_sbi_get_time(void) +{ + return rdtime(); +} diff --git a/arch/risc-v/src/common/supervisor/riscv_syscall.S b/arch/risc-v/src/common/supervisor/riscv_syscall.S new file mode 100644 index 0000000000000..309896c4c06c7 --- /dev/null +++ b/arch/risc-v/src/common/supervisor/riscv_syscall.S @@ -0,0 +1,165 @@ +/**************************************************************************** + * arch/risc-v/src/common/supervisor/riscv_syscall.S + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +.file "riscv_syscall.S" + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include +#include + +#include "chip.h" + +#include "riscv_macros.S" + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/**************************************************************************** + * Public Symbols + ****************************************************************************/ + + .globl sys_call0 + .globl sys_call1 + .globl sys_call2 + .globl sys_call3 + .globl sys_call4 + .globl sys_call5 + .globl sys_call6 + +/**************************************************************************** + * Name: sys_callx + * + * Description: + * Dispatch syscall from kernel + * + * C Function Prototype: + * uintptr_t sys_callx(unsigned int nbr, ...); + * + * Input Parameters: + * Assumes the context to return is already set up + * + * Returned Value: + * Return value of system call is returned into contex + * + * Assumptions: + * Task is running in privileged mode + * + ****************************************************************************/ + +.type sys_call0, function +.type sys_call1, function +.type sys_call2, function +.type sys_call3, function +.type sys_call4, function +.type sys_call5, function +.type sys_call6, function + +sys_call0: +sys_call1: +sys_call2: +sys_call3: +sys_call4: +sys_call5: +sys_call6: + + addi sp, sp, -XCPTCONTEXT_SIZE /* make room */ + save_ctx sp /* save current context */ + + /* Mask interrupts and store the status register to context */ + + li s1, STATUS_IE /* move IE -> PIE */ + csrrc s0, CSR_STATUS, s1 + and s1, s0, s1 /* if (STATUS & IE) */ + beqz s1, 1f + li s1, ~STATUS_IE /* clear IE */ + and s0, s0, s1 + li s1, STATUS_PIE /* set PIE */ + or s0, s0, s1 + + 1: + /* Set previous privilege, we are in privileged mode now */ + + li s1, STATUS_PPP /* set previous privilege */ + or s0, s0, s1 + REGSTORE s0, REG_INT_CTX(sp) /* store status to context */ + + REGSTORE x1, REG_EPC(sp) /* save ra to epc */ + + addi s0, sp, XCPTCONTEXT_SIZE + REGSTORE s0, REG_SP(sp) /* original SP */ + + riscv_savefpu sp + + mv a0, sp /* a0 = context */ + +#if CONFIG_ARCH_INTERRUPTSTACK > 15 + /* Switch to interrupt stack */ + + setintstack t0, t1 +#endif + + /* Run the handler */ + + jal x1, riscv_perform_syscall + + /* Restore (potentially new) context */ + + mv sp, a0 /* use sp, as a0 gets wiped */ + + riscv_loadfpu sp + + REGLOAD s0, REG_EPC(sp) /* restore epc */ + csrw CSR_EPC, s0 + + /* Restore status register, but don't enable interrupts yet */ + + REGLOAD s0, REG_INT_CTX(sp) /* restore status */ + li s1, STATUS_IE /* move IE -> PIE */ + and s1, s0, s1 /* if (STATUS & IE) */ + beqz s1, 1f + li s1, ~STATUS_IE /* clear IE */ + and s0, s0, s1 + li s1, STATUS_PIE /* set PIE */ + or s0, s0, s1 + +1: + csrw CSR_STATUS, s0 + + load_ctx sp + + REGLOAD sp, REG_SP(sp) /* restore original sp */ + + /* return from exception, which updates the status register */ + + ERET + + .size sys_call0, .-sys_call0 + .size sys_call1, .-sys_call1 + .size sys_call2, .-sys_call2 + .size sys_call3, .-sys_call3 + .size sys_call4, .-sys_call4 + .size sys_call5, .-sys_call5 + .size sys_call6, .-sys_call6 + + .end diff --git a/arch/arm/src/armv7-m/gnu/vfork.S b/arch/risc-v/src/common/vfork.S similarity index 76% rename from arch/arm/src/armv7-m/gnu/vfork.S rename to arch/risc-v/src/common/vfork.S index b5b6dd2142142..379f5fa3bf70a 100644 --- a/arch/arm/src/armv7-m/gnu/vfork.S +++ b/arch/risc-v/src/common/vfork.S @@ -1,5 +1,5 @@ /**************************************************************************** - * arch/arm/src/armv7-m/gnu/vfork.S + * arch/risc-v/src/common/vfork.S * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with @@ -18,13 +18,14 @@ * ****************************************************************************/ + /**************************************************************************** * Included Files ****************************************************************************/ #include -#include "arm_vfork.h" +#include "riscv_vfork.h" /**************************************************************************** * Pre-processor Definitions @@ -34,10 +35,9 @@ * Public Symbols ****************************************************************************/ - .syntax unified - .thumb - .file "vfork.S" - .globl up_vfork + .file "vfork.S" + .globl up_vfork + .globl vfork /**************************************************************************** * Public Functions @@ -85,43 +85,46 @@ * ****************************************************************************/ - .thumb_func - .globl vfork - .type vfork, function +.type vfork, function + vfork: - /* Create a stack frame */ + /* Create a stack frame */ + + addi sp, sp, -VFORK_SIZEOF - mov r0, sp /* Save the value of the stack on entry */ - sub sp, sp, #VFORK_SIZEOF /* Allocate the structure on the stack */ + /* CPU registers */ + /* Save the volatile registers */ - /* CPU registers */ - /* Save the volatile registers */ + REGSTORE s0, VFORK_S0_OFFSET(sp) + REGSTORE s1, VFORK_S1_OFFSET(sp) + REGSTORE s2, VFORK_S2_OFFSET(sp) + REGSTORE s3, VFORK_S3_OFFSET(sp) + REGSTORE s4, VFORK_S4_OFFSET(sp) + REGSTORE s5, VFORK_S5_OFFSET(sp) + REGSTORE s6, VFORK_S6_OFFSET(sp) + REGSTORE s7, VFORK_S7_OFFSET(sp) - str r4, [sp, #VFORK_R4_OFFSET] - str r5, [sp, #VFORK_R5_OFFSET] - str r6, [sp, #VFORK_R6_OFFSET] - str r7, [sp, #VFORK_R7_OFFSET] - str r8, [sp, #VFORK_R8_OFFSET] - str r9, [sp, #VFORK_R9_OFFSET] - str r10, [sp, #VFORK_R10_OFFSET] + /* Save the frame pointer, stack pointer, and return address */ - /* Save the frame pointer, stack pointer, and return address */ +#ifdef CONFIG_RISCV_FRAMEPOINTER + REGSTORE fp, VFORK_FP_OFFSET(sp) +#endif + addi s0, sp, VFORK_SIZEOF + REGSTORE s0, VFORK_SP_OFFSET(sp) /* original SP */ + REGSTORE x1, VFORK_RA_OFFSET(sp) /* return address */ - str fp, [sp, #VFORK_FP_OFFSET] - str r0, [sp, #VFORK_SP_OFFSET] - str lr, [sp, #VFORK_LR_OFFSET] + /* Floating point registers (not yet) */ - /* Floating point registers (not yet) */ + /* Then, call up_vfork(), passing it a pointer to the stack frame */ - /* Then, call up_vfork(), passing it a pointer to the stack structure */ + mv a0, sp + jal x1, up_vfork - mov r0, sp - bl up_vfork + /* Release the stack frame and return the value returned by up_vfork */ - /* Release the stack data and return the value returned by up_vfork */ + REGLOAD x1, VFORK_RA_OFFSET(sp) + addi sp, sp, VFORK_SIZEOF + ret - ldr lr, [sp, #VFORK_LR_OFFSET] - add sp, sp, #VFORK_SIZEOF - bx lr - .size vfork, .-vfork - .end + .size vfork, .-vfork + .end diff --git a/arch/risc-v/src/esp32c3/Kconfig b/arch/risc-v/src/esp32c3/Kconfig index 9ce6bf95c86d4..92b9e1cba6780 100644 --- a/arch/risc-v/src/esp32c3/Kconfig +++ b/arch/risc-v/src/esp32c3/Kconfig @@ -197,6 +197,11 @@ config ESP32C3_I2C bool default n +config ESP32C3_TWAI + bool + default n + select CAN + config ESP32C3_TIMER bool default n @@ -252,6 +257,11 @@ config ESP32C3_I2C0 default n select ESP32C3_I2C +config ESP32C3_TWAI0 + bool "TWAI (CAN) 0" + default n + select ESP32C3_TWAI + config ESP32C3_RNG bool "Random Number Generator (RNG)" default n @@ -408,6 +418,58 @@ config ESP32C3_I2CTIMEOMS endmenu # I2C configuration +menu "TWAI driver options" + depends on ESP32C3_TWAI + +if ESP32C3_TWAI0 + +config ESP32C3_TWAI0_TXPIN + int "TWAI0 TX Pin" + default 2 + +config ESP32C3_TWAI0_RXPIN + int "TWAI0 RX Pin" + default 3 + +config ESP32C3_TWAI0_BITRATE + int "TWAI0 bitrate" + default 1000000 + ---help--- + TWAI0 bit rate. Required if ESP32C3_TWAI0 is defined. + +config ESP32C3_TWAI0_SAMPLEP + int "TWAI0 sample point" + default 80 + ---help--- + TWAI0 sample point location as a percent value. Required + if ESP32C3_TWAI0 is defined. + +config ESP32C3_TWAI0_SJW + int "TWAI0 synchronization jump width" + default 3 + ---help--- + SJW limits the number of Time Quanta corrections during bit + Resynchronization. Default: 3 + +config ESP32C3_TWAI0_SAM + bool "TWAI0 sampling" + default n + ---help--- + The bus is sampled 3 times (recommended for low to medium speed buses + to spikes on the bus-line). + +endif # ESP32C3_TWAI0 + +config ESP32C3_TWAI_REGDEBUG + bool "TWAI register level debug" + depends on DEBUG_CAN_INFO + default n + ---help--- + Output detailed register-level TWAI debug information. Requires also + CONFIG_DEBUG_CAN_INFO. + +endmenu #ESP32C3_TWAI + menu "SPI configuration" depends on ESP32C3_SPI diff --git a/arch/risc-v/src/esp32c3/Make.defs b/arch/risc-v/src/esp32c3/Make.defs index 7bc2fbb61e3a6..db2ff2b8126d1 100644 --- a/arch/risc-v/src/esp32c3/Make.defs +++ b/arch/risc-v/src/esp32c3/Make.defs @@ -25,7 +25,11 @@ include chip/Bootloader.mk HEAD_ASRC = esp32c3_head.S -CHIP_ASRCS = esp32c3_vectors.S esp32c3_interrupt.S +CHIP_ASRCS = esp32c3_vectors.S + +# Specify our general Assembly files + +CMN_ASRCS = riscv_exception_common.S # Specify C code within the common directory to be included @@ -36,7 +40,8 @@ CMN_CSRCS += riscv_interruptcontext.c riscv_modifyreg32.c riscv_puts.c riscv_mde CMN_CSRCS += riscv_releasepending.c riscv_reprioritizertr.c CMN_CSRCS += riscv_releasestack.c riscv_stackframe.c riscv_schedulesigaction.c CMN_CSRCS += riscv_sigdeliver.c riscv_udelay.c riscv_unblocktask.c riscv_usestack.c -CMN_CSRCS += riscv_tcbinfo.c riscv_getnewintctx.c +CMN_CSRCS += riscv_tcbinfo.c riscv_getnewintctx.c riscv_doirq.c +CMN_CSRCS += riscv_saveusercontext.c ifeq ($(CONFIG_SCHED_BACKTRACE),y) CMN_CSRCS += riscv_backtrace.c @@ -47,7 +52,8 @@ CMN_CSRCS += riscv_checkstack.c endif ifeq ($(CONFIG_ARCH_HAVE_VFORK),y) -CMN_CSRCS += riscv_vfork.c +CMN_ASRCS += vfork.S +CMN_CSRCS += riscv_vfork.c endif # Specify our C code within this directory to be included @@ -77,6 +83,10 @@ ifeq ($(CONFIG_ESP32C3_I2C),y) CHIP_CSRCS += esp32c3_i2c.c endif +ifeq ($(CONFIG_ESP32C3_TWAI),y) +CHIP_CSRCS += esp32c3_twai.c +endif + ifeq ($(CONFIG_ESP32C3_SPI),y) CHIP_CSRCS += esp32c3_spi.c ifeq ($(CONFIG_SPI_SLAVE),y) @@ -212,11 +222,6 @@ INCLUDES += $(shell $(INCDIR) "$(CC)" $(ARCH_SRCDIR)$(DELIM)chip$(DELIM)esp-wire EXTRA_LIBPATHS += -L $(ARCH_SRCDIR)$(DELIM)chip$(DELIM)esp-wireless-drivers-3rdparty$(DELIM)libs$(DELIM)esp32c3 EXTRA_LIBS += -lphy -# Due to some Wi-Fi related libraries, the option is need to avoid linking too much -# unused functions. - -LDFLAGS += --gc-sections - # Wireless interfaces. CHIP_CSRCS += esp32c3_wireless.c diff --git a/arch/risc-v/src/esp32c3/chip.h b/arch/risc-v/src/esp32c3/chip.h index 67a6bcf3034fd..2ae947ddaea0e 100644 --- a/arch/risc-v/src/esp32c3/chip.h +++ b/arch/risc-v/src/esp32c3/chip.h @@ -28,4 +28,12 @@ #include #include "esp32c3_memorymap.h" +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/* Section for exception handler. */ + +#define EXCEPTION_SECTION .iram1 + #endif /* __ARCH_RISCV_SRC_ESP32C3_CHIP_H */ diff --git a/arch/risc-v/src/esp32c3/esp32c3_interrupt.S b/arch/risc-v/src/esp32c3/esp32c3_interrupt.S deleted file mode 100644 index d86c61944ded2..0000000000000 --- a/arch/risc-v/src/esp32c3/esp32c3_interrupt.S +++ /dev/null @@ -1,179 +0,0 @@ -/**************************************************************************** - * arch/risc-v/src/esp32c3/esp32c3_interrupt.S - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. The - * ASF licenses this file to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance with the - * License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - ****************************************************************************/ - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include -#include - -#include "chip.h" - -/**************************************************************************** - * Public Symbols - ****************************************************************************/ - - .global _interrupt_handler - .global _exception_handler - .global g_intstackalloc - .global g_intstacktop - -/**************************************************************************** - * Section: .noinit - ****************************************************************************/ - - .section .noinit - -#if CONFIG_ARCH_INTERRUPTSTACK > 15 - .balign 16 - .type g_intstackalloc, @object - .type g_intstacktop, @object -g_intstackalloc: - .skip ((CONFIG_ARCH_INTERRUPTSTACK + 8) & ~15) -g_intstacktop: - .size g_intstackalloc, (CONFIG_ARCH_INTERRUPTSTACK & ~15) -#endif - -/**************************************************************************** - * Section: .iram1 - ****************************************************************************/ - - .section .iram1 - -/**************************************************************************** - * Name: _interrupt_handler - ****************************************************************************/ - - .type _interrupt_handler, @function - -_exception_handler: -_interrupt_handler: - addi sp, sp, -XCPTCONTEXT_SIZE - - sw x1, 1*4(sp) /* ra */ - sw x3, 3*4(sp) /* gp (For register dumping on exception handler) */ - sw x4, 4*4(sp) /* tp */ - sw x5, 5*4(sp) /* t0 */ - sw x6, 6*4(sp) /* t1 */ - sw x7, 7*4(sp) /* t2 */ - sw x8, 8*4(sp) /* s0 */ - sw x9, 9*4(sp) /* s1 */ - sw x10, 10*4(sp) /* a0 */ - sw x11, 11*4(sp) /* a1 */ - sw x12, 12*4(sp) /* a2 */ - sw x13, 13*4(sp) /* a3 */ - sw x14, 14*4(sp) /* a4 */ - sw x15, 15*4(sp) /* a5 */ - sw x16, 16*4(sp) /* a6 */ - sw x17, 17*4(sp) /* a7 */ - sw x18, 18*4(sp) /* s2 */ - sw x19, 19*4(sp) /* s3 */ - sw x20, 20*4(sp) /* s4 */ - sw x21, 21*4(sp) /* s5 */ - sw x22, 22*4(sp) /* s6 */ - sw x23, 23*4(sp) /* s7 */ - sw x24, 24*4(sp) /* s8 */ - sw x25, 25*4(sp) /* s9 */ - sw x26, 26*4(sp) /* s10 */ - sw x27, 27*4(sp) /* s11 */ - sw x28, 28*4(sp) /* t3 */ - sw x29, 29*4(sp) /* t4 */ - sw x30, 30*4(sp) /* t5 */ - sw x31, 31*4(sp) /* t6 */ - - addi s0, sp, XCPTCONTEXT_SIZE - sw s0, 2*4(sp) /* Save original SP */ - - /* Save MSTATUS (Machine Status Register) */ - - csrr s0, mstatus - sw s0, 32*4(sp) - - /* Save MEPC (Machine Exception Program Counter) */ - - csrr s0, mepc - sw s0, 0(sp) - - csrr a0, mcause /* Handler arg0: Exception cause */ - mv a1, sp /* Handler arg1: Context (saved registers on stack) */ - -#if CONFIG_ARCH_INTERRUPTSTACK > 15 - lui sp, %hi(g_intstacktop) - addi sp, sp, %lo(g_intstacktop) -#endif - - /* Call interrupt/exception handler in C */ - - jal x1, esp32c3_dispatch_irq - - /* If context switch is needed, return a new SP */ - - mv sp, a0 - - /* Restore MEPC (Machine Exception Program Counter) */ - - lw s0, 0(sp) - csrw mepc, s0 - - /* Restore MSTATUS (Machine Status Register) */ - - lw s0, 32*4(sp) - csrw mstatus, s0 - - lw x1, 1*4(sp) /* ra */ - - /* GP must not be changed after start-up due to relaxing optimization */ - - lw x4, 4*4(sp) /* tp */ - lw x5, 5*4(sp) /* t0 */ - lw x6, 6*4(sp) /* t1 */ - lw x7, 7*4(sp) /* t2 */ - lw x8, 8*4(sp) /* s0 */ - lw x9, 9*4(sp) /* s1 */ - lw x10, 10*4(sp) /* a0 */ - lw x11, 11*4(sp) /* a1 */ - lw x12, 12*4(sp) /* a2 */ - lw x13, 13*4(sp) /* a3 */ - lw x14, 14*4(sp) /* a4 */ - lw x15, 15*4(sp) /* a5 */ - lw x16, 16*4(sp) /* a6 */ - lw x17, 17*4(sp) /* a7 */ - lw x18, 18*4(sp) /* s2 */ - lw x19, 19*4(sp) /* s3 */ - lw x20, 20*4(sp) /* s4 */ - lw x21, 21*4(sp) /* s5 */ - lw x22, 22*4(sp) /* s6 */ - lw x23, 23*4(sp) /* s7 */ - lw x24, 24*4(sp) /* s8 */ - lw x25, 25*4(sp) /* s9 */ - lw x26, 26*4(sp) /* s10 */ - lw x27, 27*4(sp) /* s11 */ - lw x28, 28*4(sp) /* t3 */ - lw x29, 29*4(sp) /* t4 */ - lw x30, 30*4(sp) /* t5 */ - lw x31, 31*4(sp) /* t6 */ - - lw sp, 2*4(sp) /* Restore original SP */ - - /* Return from Machine Interrupt */ - - mret - diff --git a/arch/risc-v/src/esp32c3/esp32c3_irq.c b/arch/risc-v/src/esp32c3/esp32c3_irq.c index ad247d0e8a76c..63530261ee0f9 100644 --- a/arch/risc-v/src/esp32c3/esp32c3_irq.c +++ b/arch/risc-v/src/esp32c3/esp32c3_irq.c @@ -24,18 +24,14 @@ #include +#include +#include #include #include #include #include #include -#include -#include - -#include -#include -#include #include "riscv_internal.h" #include "hardware/esp32c3_interrupt.h" @@ -116,9 +112,9 @@ void up_irqinitialize(void) putreg32(ESP32C3_DEFAULT_INT_THRESHOLD, INTERRUPT_CPU_INT_THRESH_REG); - /* Attach the ECALL interrupt. */ + /* Attach the common interrupt handler */ - irq_attach(ESP32C3_IRQ_ECALL_M, riscv_swint, NULL); + riscv_exception_attach(); #ifdef CONFIG_ESP32C3_GPIO_IRQ /* Initialize GPIO interrupt support */ @@ -343,7 +339,7 @@ void esp32c3_free_cpuint(uint8_t periphid) } /**************************************************************************** - * Name: esp32c3_dispatch_irq + * Name: riscv_dispatch_irq * * Description: * Process interrupt and its callback function. @@ -357,81 +353,52 @@ void esp32c3_free_cpuint(uint8_t periphid) * ****************************************************************************/ -IRAM_ATTR uintptr_t *esp32c3_dispatch_irq(uintptr_t mcause, uintptr_t *regs) +IRAM_ATTR uintptr_t *riscv_dispatch_irq(uintptr_t mcause, uintptr_t *regs) { int irq; - uintptr_t *mepc = regs; + uint8_t cpuint = mcause & RISCV_IRQ_MASK; + bool is_irq = (RISCV_IRQ_BIT & mcause) != 0; - if (((RISCV_IRQ_BIT & mcause) == 0) && +#ifdef CONFIG_ESP32C3_EXCEPTION_ENABLE_CACHE + if (!is_irq && (mcause != RISCV_IRQ_ECALLM)) { -#ifdef CONFIG_ESP32C3_EXCEPTION_ENABLE_CACHE if (!spi_flash_cache_enabled()) { spi_flash_enable_cache(0); _err("ERROR: Cache was disabled and re-enabled\n"); } -#endif } - else - { - /* Check "CURRENT_REGS" only in interrupt or ecall */ - - DEBUGASSERT(CURRENT_REGS == NULL); - } - - CURRENT_REGS = regs; +#endif irqinfo("INFO: mcause=%08" PRIXPTR "\n", mcause); - /* If the board supports LEDs, turn on an LED now to indicate that we are - * processing an interrupt. - */ + DEBUGASSERT(cpuint <= ESP32C3_CPUINT_MAX); - board_autoled_on(LED_INIRQ); + irqinfo("INFO: cpuint=%" PRIu8 "\n", cpuint); - if ((RISCV_IRQ_BIT & mcause) != 0) + if (is_irq) { - uint8_t cpuint = mcause & RISCV_IRQ_MASK; - - DEBUGASSERT(cpuint <= ESP32C3_CPUINT_MAX); - - irqinfo("INFO: cpuint=%" PRIu8 "\n", cpuint); - /* Clear edge interrupts. */ putreg32(1 << cpuint, INTERRUPT_CPU_INT_CLEAR_REG); - irq = g_cpuint_map[cpuint] + ESP32C3_IRQ_FIRSTPERIPH; - irq_dispatch(irq, regs); - - /* Toggle the bit back to zero. */ - - putreg32(0, INTERRUPT_CPU_INT_CLEAR_REG); } else { - if (mcause == RISCV_IRQ_ECALLM) - { - *mepc += 4; - irq_dispatch(ESP32C3_IRQ_ECALL_M, regs); - } - else - { - riscv_exception(mcause, regs); - } + /* It's exception */ + + irq = mcause; } - /* If a context switch occurred while processing the interrupt then - * CURRENT_REGS may have change value. If we return any value different - * from the input regs, then the lower level will know that a context - * switch occurred during interrupt processing. - */ + regs = riscv_doirq(irq, regs); - regs = (uintptr_t *)CURRENT_REGS; - CURRENT_REGS = NULL; + /* Toggle the bit back to zero. */ - board_autoled_off(LED_INIRQ); + if (is_irq) + { + putreg32(0, INTERRUPT_CPU_INT_CLEAR_REG); + } return regs; } diff --git a/arch/risc-v/src/esp32c3/esp32c3_irq.h b/arch/risc-v/src/esp32c3/esp32c3_irq.h index 54cd41003c1bc..3290fbf9d514e 100644 --- a/arch/risc-v/src/esp32c3/esp32c3_irq.h +++ b/arch/risc-v/src/esp32c3/esp32c3_irq.h @@ -95,21 +95,4 @@ int esp32c3_request_irq(uint8_t periphid, uint8_t prio, uint32_t flags); void esp32c3_free_cpuint(uint8_t periphid); -/**************************************************************************** - * Name: esp32c3_dispatch_irq - * - * Description: - * Process interrupt and its callback function. - * - * Input Parameters: - * mcause - RISC-V "mcause" register value - * regs - Saved register value array - * - * Returned Value: - * None. - * - ****************************************************************************/ - -uintptr_t *esp32c3_dispatch_irq(uintptr_t mcause, uintptr_t *regs); - #endif /* __ARCH_RISCV_SRC_ESP32C3_ESP32C3_IRQ_H */ diff --git a/arch/risc-v/src/esp32c3/esp32c3_oneshot_lowerhalf.c b/arch/risc-v/src/esp32c3/esp32c3_oneshot_lowerhalf.c index 9ed59372e2efb..e3d2d68c7b6ca 100644 --- a/arch/risc-v/src/esp32c3/esp32c3_oneshot_lowerhalf.c +++ b/arch/risc-v/src/esp32c3/esp32c3_oneshot_lowerhalf.c @@ -115,7 +115,7 @@ static void esp32c3_oneshot_lh_handler(void *arg) struct esp32c3_oneshot_lowerhalf_s *priv = (struct esp32c3_oneshot_lowerhalf_s *)arg; oneshot_callback_t callback; - FAR void *cb_arg; + void *cb_arg; DEBUGASSERT(priv != NULL); DEBUGASSERT(priv->callback != NULL); @@ -341,7 +341,7 @@ static int oneshot_lh_current(struct oneshot_lowerhalf_s *lower, ****************************************************************************/ struct oneshot_lowerhalf_s *oneshot_initialize(int chan, - uint16_t resolution) + uint16_t resolution) { struct esp32c3_oneshot_lowerhalf_s *priv; int ret; diff --git a/arch/risc-v/src/esp32c3/esp32c3_pminitialize.c b/arch/risc-v/src/esp32c3/esp32c3_pminitialize.c index ee25f78114c00..68fffcb8bb824 100644 --- a/arch/risc-v/src/esp32c3/esp32c3_pminitialize.c +++ b/arch/risc-v/src/esp32c3/esp32c3_pminitialize.c @@ -23,6 +23,7 @@ ****************************************************************************/ #include +#include #include "esp32c3_pm.h" @@ -33,7 +34,7 @@ ****************************************************************************/ /**************************************************************************** - * Name: xtensa_pminitialize + * Name: riscv_pminitialize * * Description: * Initialize the power management subsystem. @@ -42,6 +43,9 @@ void riscv_pminitialize(void) { + /* Initialize the NuttX power management subsystem proper */ + + pm_initialize(); } #endif /* CONFIG_PM */ diff --git a/arch/risc-v/src/esp32c3/esp32c3_resetcause.c b/arch/risc-v/src/esp32c3/esp32c3_resetcause.c index 86b8ebe83ddf5..00ede72ff48c9 100644 --- a/arch/risc-v/src/esp32c3/esp32c3_resetcause.c +++ b/arch/risc-v/src/esp32c3/esp32c3_resetcause.c @@ -27,7 +27,6 @@ #include #include -#include #include "hardware/esp32c3_rtccntl.h" diff --git a/arch/risc-v/src/esp32c3/esp32c3_systemreset.c b/arch/risc-v/src/esp32c3/esp32c3_systemreset.c index 88b0d74d99824..219f5735cceb9 100644 --- a/arch/risc-v/src/esp32c3/esp32c3_systemreset.c +++ b/arch/risc-v/src/esp32c3/esp32c3_systemreset.c @@ -27,7 +27,6 @@ #include #include -#include #include "hardware/esp32c3_rtccntl.h" #include "esp32c3.h" diff --git a/arch/risc-v/src/esp32c3/esp32c3_twai.c b/arch/risc-v/src/esp32c3/esp32c3_twai.c new file mode 100644 index 0000000000000..585befe37714e --- /dev/null +++ b/arch/risc-v/src/esp32c3/esp32c3_twai.c @@ -0,0 +1,1252 @@ +/**************************************************************************** + * arch/risc-v/src/esp32c3/esp32c3_twai.c + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include "riscv_internal.h" + +#include "esp32c3_gpio.h" +#include "esp32c3_twai.h" +#include "esp32c3_irq.h" +#include "esp32c3_clockconfig.h" + +#include "hardware/esp32c3_system.h" +#include "hardware/esp32c3_gpio_sigmap.h" + +#if defined(CONFIG_ESP32C3_TWAI) + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/* Configuration ************************************************************/ + +/* Default values written to various registers on initialization */ +#define TWAI_INIT_TEC 0 +#define TWAI_INIT_REC 0 +#define TWAI_INIT_EWL 96 + +#define TWAI_DEFAULT_INTERRUPTS 0xe7 /* Exclude data overrun (bit[3]) and brp_div (bit[4]) */ + +#define TWAI_ACCEPTANCE_CODE 0x0 /* 32-bit address to match */ +#define TWAI_ACCEPTANCE_MASK 0xffffffff /* 32-bit address mask */ + +#ifdef CONFIG_ESP32C3_TWAI0 + +/* A TWAI bit rate must be provided */ + +# ifndef CONFIG_ESP32C3_TWAI0_BITRATE +# error "CONFIG_ESP32C3_TWAI0_BITRATE is not defined" +# endif + +/* If no sample point is provided, use a sample point of 80 */ + +# ifndef CONFIG_ESP32C3_TWAI0_SAMPLEP +# define CONFIG_ESP32C3_TWAI0_SAMPLEP 80 +# endif +#endif + +/* If no Synchronization Jump Width is provided, use a SJW of 3 */ + +#ifndef CONFIG_ESP32C3_TWAI0_SJW +# define CONFIG_ESP32C3_TWAI0_SJW 3 +#endif + +/* Debug ********************************************************************/ + +/* Non-standard debug that may be enabled just for testing TWAI */ + +#ifndef CONFIG_DEBUG_CAN_INFO +# undef CONFIG_ESP32C3_TWAI_REGDEBUG +#endif + +/**************************************************************************** + * Private Types + ****************************************************************************/ + +/* CAN hardware-dependent bit-timing constant + * Used for calculating and checking bit-timing parameters + */ + +struct can_bittiming_const +{ + uint32_t tseg1_min; /* Time segment 1 */ + uint32_t tseg1_max; + uint32_t tseg2_min; /* Time segment 2 */ + uint32_t tseg2_max; + uint32_t sjw_min; /* Synchronization jump width */ + uint32_t sjw_max; + uint32_t brp_min; /* Bit-rate prescaler */ + uint32_t brp_max; + uint32_t brp_inc; +}; + +struct twai_dev_s +{ + /* Device configuration */ + + const struct can_bittiming_const *bittiming_const; + uint8_t port; /* TWAI port number */ + uint8_t periph; /* Peripheral ID */ + uint8_t irq; /* IRQ associated with this TWAI */ + int8_t cpuint; /* CPU interrupt assigned to this TWAI */ + uint32_t bitrate; /* Configured bit rate */ + uint32_t samplep; /* Configured sample point */ + uint32_t sjw; /* Synchronization jump width */ + uint32_t base; /* TWAI register base address */ +}; + +/**************************************************************************** + * Private Function Prototypes + ****************************************************************************/ + +/* TWAI Register access */ + +#ifdef CONFIG_ESP32C3_TWAI_REGDEBUG +static void twai_printreg(uint32_t addr, uint32_t value); +#endif + +static uint32_t twai_getreg(uint32_t addr); +static void twai_putreg(uint32_t addr, uint32_t value); + +/* TWAI methods */ + +static void esp32c3twai_reset(struct can_dev_s *dev); +static int esp32c3twai_setup(struct can_dev_s *dev); +static void esp32c3twai_shutdown(struct can_dev_s *dev); +static void esp32c3twai_rxint(struct can_dev_s *dev, bool enable); +static void esp32c3twai_txint(struct can_dev_s *dev, bool enable); +static int esp32c3twai_ioctl(struct can_dev_s *dev, int cmd, + unsigned long arg); +static int esp32c3twai_remoterequest(struct can_dev_s *dev, + uint16_t id); +static int esp32c3twai_send(struct can_dev_s *dev, + struct can_msg_s *msg); +static bool esp32c3twai_txready(struct can_dev_s *dev); +static bool esp32c3twai_txempty(struct can_dev_s *dev); + +/* TWAI interrupts */ + +static int esp32c3twai_interrupt(int irq, void *context, void *arg); + +/* TWAI acceptance filter */ + +static void esp32c3twai_set_acc_filter(uint32_t code, uint32_t mask, + bool single_filter); + +/* TWAI bit-timing initialization */ + +static int twai_baud_rate(struct twai_dev_s *priv, int rate, int clock, + int sjw, int sampl_pt, int flags); + +/**************************************************************************** + * Private Data + ****************************************************************************/ + +static const struct can_bittiming_const esp32c3_twai_bittiming_const = +{ + .tseg1_min = 1, + .tseg1_max = 16, + .tseg2_min = 1, + .tseg2_max = 8, + .sjw_min = 1, + .sjw_max = 3, + .brp_min = 1, + .brp_max = 64, + .brp_inc = 1, +}; + +static const struct can_ops_s g_twaiops = +{ + .co_reset = esp32c3twai_reset, + .co_setup = esp32c3twai_setup, + .co_shutdown = esp32c3twai_shutdown, + .co_rxint = esp32c3twai_rxint, + .co_txint = esp32c3twai_txint, + .co_ioctl = esp32c3twai_ioctl, + .co_remoterequest = esp32c3twai_remoterequest, + .co_send = esp32c3twai_send, + .co_txready = esp32c3twai_txready, + .co_txempty = esp32c3twai_txempty, +}; + +#ifdef CONFIG_ESP32C3_TWAI0 +static struct twai_dev_s g_twai0priv = +{ + .bittiming_const = &esp32c3_twai_bittiming_const, + .port = 0, + .periph = ESP32C3_PERIPH_TWAI, + .irq = ESP32C3_IRQ_TWAI, + .cpuint = -ENOMEM, + .bitrate = CONFIG_ESP32C3_TWAI0_BITRATE, + .samplep = CONFIG_ESP32C3_TWAI0_SAMPLEP, + .sjw = CONFIG_ESP32C3_TWAI0_SJW, + .base = DR_REG_TWAI_BASE, +}; + +static struct can_dev_s g_twai0dev = +{ + .cd_ops = &g_twaiops, + .cd_priv = &g_twai0priv, +}; +#endif + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: twai_printreg + * + * Description: + * Print the value read from a register. + * + * Input Parameters: + * addr - The register address + * value - The register value + * + * Returned Value: + * None + * + ****************************************************************************/ + +#ifdef CONFIG_ESP32C3_TWAI_REGDEBUG +static void twai_printreg(uint32_t addr, uint32_t value) +{ + static uint32_t prevaddr; + static uint32_t preval; + static uint32_t count; + + /* Is this the same value that we read from the same register last time? + * Are we polling the register? If so, suppress some of the output. + */ + + if (addr == prevaddr && value == preval) + { + if (count == 0xffffffff || ++count > 3) + { + if (count == 4) + { + caninfo("...\n"); + } + + return; + } + } + + /* No this is a new address or value */ + + else + { + /* Did we print "..." for the previous value? */ + + if (count > 3) + { + /* Yes.. then show how many times the value repeated */ + + caninfo("[repeats %d more times]\n", count - 3); + } + + /* Save the new address, value, and count */ + + prevaddr = addr; + preval = value; + count = 1; + } + + /* Show the register value read */ + + caninfo("%08" PRIx32 "<-%08" PRIx32 "\n", addr, value); +} +#endif + +/**************************************************************************** + * Name: twai_getreg + * + * Description: + * Read the value of an TWAI register. + * + * Input Parameters: + * addr - The address to the register to read + * + * Returned Value: + * + ****************************************************************************/ + +static uint32_t twai_getreg(uint32_t addr) +{ + uint32_t value; + + /* Read the value from the register */ + + value = getreg32(addr); +#ifdef CONFIG_ESP32C3_TWAI_REGDEBUG + twai_printreg(addr, value); +#endif + return value; +} + +/**************************************************************************** + * Name: twai_putreg + * + * Description: + * Set the value of an TWAI register. + * + * Input Parameters: + * addr - The address to the register to write + * value - The value to write to the register + * + * Returned Value: + * None + * + ****************************************************************************/ + +static void twai_putreg(uint32_t addr, uint32_t value) +{ +#ifdef CONFIG_ESP32C3_TWAI_REGDEBUG + /* Show the register value being written */ + + caninfo("%08" PRIx32 "<-%08" PRIx32 "\n", addr, value); +#endif + + /* Write the value */ + + putreg32(value, addr); +} + +/**************************************************************************** + * Name: esp32c3twai_reset + * + * Description: + * Reset the TWAI device. Called early to initialize the hardware. This + * function is called, before esp32_twai_setup() and on error conditions. + * + * Input Parameters: + * dev - An instance of the "upper half" CAN driver state structure. + * + * Returned Value: + * None + * + ****************************************************************************/ + +static void esp32c3twai_reset(struct can_dev_s *dev) +{ + struct twai_dev_s *priv = (struct twai_dev_s *)dev->cd_priv; + irqstate_t flags; + int ret; + + caninfo("TWAI%" PRIu8 "\n", priv->port); + + flags = enter_critical_section(); + + /* Disable the TWAI and stop ongoing transmissions */ + + uint32_t mode_value = TWAI_RESET_MODE_M | TWAI_LISTEN_ONLY_MODE_M; + twai_putreg(TWAI_MODE_REG, mode_value); /* Enter Reset Mode */ + + twai_putreg(TWAI_INT_ENA_REG, 0); /* Disable interrupts */ + twai_getreg(TWAI_STATUS_REG); /* Clear status bits */ + + twai_putreg(TWAI_TX_ERR_CNT_REG, TWAI_INIT_TEC); /* TEC */ + twai_putreg(TWAI_RX_ERR_CNT_REG, TWAI_INIT_REC); /* REC */ + twai_putreg(TWAI_ERR_WARNING_LIMIT_REG, TWAI_INIT_EWL); /* EWL */ + + esp32c3twai_set_acc_filter(TWAI_ACCEPTANCE_CODE, + TWAI_ACCEPTANCE_MASK, true); + + /* Set bit timing */ + + ret = twai_baud_rate(priv, priv->bitrate, esp32c3_clk_apb_freq(), + priv->sjw, priv->samplep, 0); + + if (ret != OK) + { + canerr("ERROR: Failed to set bit timing: %d\n", ret); + } + + /* Restart the TWAI */ + +#ifdef CONFIG_CAN_LOOPBACK + twai_putreg(TWAI_MODE_REG, TWAI_SELF_TEST_MODE_M); /* Leave Reset Mode, enter Test Mode */ +#else + twai_putreg(TWAI_MODE_REG, 0); /* Leave Reset Mode */ +#endif + + /* Abort transmission, release RX buffer and clear overrun. + * Command register can only be modified when in Operation Mode. + */ + + twai_putreg(TWAI_CMD_REG, TWAI_ABORT_TX_M | TWAI_RELEASE_BUF_M | + TWAI_CLR_OVERRUN_M); + + leave_critical_section(flags); +} + +/**************************************************************************** + * Name: esp32c3twai_setup + * + * Description: + * Configure the TWAI. This method is called the first time that the TWAI + * device is opened. This will occur when the port is first opened. + * This setup includes configuring and attaching TWAI interrupts. + * + * Input Parameters: + * dev - An instance of the "upper half" CAN driver state structure. + * + * Returned Value: + * Zero on success; a negated errno on failure + * + ****************************************************************************/ + +static int esp32c3twai_setup(struct can_dev_s *dev) +{ + struct twai_dev_s *priv = (struct twai_dev_s *)dev->cd_priv; + irqstate_t flags; + int ret = OK; + + caninfo("TWAI%" PRIu8 "\n", priv->port); + + flags = enter_critical_section(); + + twai_putreg(TWAI_INT_ENA_REG, TWAI_DEFAULT_INTERRUPTS); + + twai_getreg(TWAI_INT_RAW_REG); /* clear latched interrupts */ + + if (priv->cpuint != -ENOMEM) + { + /* Disable the provided CPU Interrupt to configure it. */ + + up_disable_irq(priv->cpuint); + } + + priv->cpuint = esp32c3_request_irq(priv->periph, + ESP32C3_INT_PRIO_DEF, + ESP32C3_INT_LEVEL); + if (priv->cpuint < 0) + { + /* Failed to allocate a CPU interrupt of this type. */ + + ret = priv->cpuint; + leave_critical_section(flags); + + return ret; + } + + ret = irq_attach(priv->irq, esp32c3twai_interrupt, dev); + if (ret != OK) + { + /* Failed to attach IRQ, so CPU interrupt must be freed. */ + + esp32c3_free_cpuint(priv->periph); + priv->cpuint = -ENOMEM; + leave_critical_section(flags); + + return ret; + } + + /* Enable the CPU interrupt that is linked to the TWAI device. */ + + up_enable_irq(priv->cpuint); + + leave_critical_section(flags); + + return ret; +} + +/**************************************************************************** + * Name: esp32c3twai_shutdown + * + * Description: + * Disable the TWAI. This method is called when the TWAI device is closed. + * This method reverses the operation the setup method. + * + * Input Parameters: + * dev - An instance of the "upper half" CAN driver state structure. + * + * Returned Value: + * None + * + ****************************************************************************/ + +static void esp32c3twai_shutdown(struct can_dev_s *dev) +{ + struct twai_dev_s *priv = (struct twai_dev_s *)dev->cd_priv; + +#ifdef CONFIG_DEBUG_CAN_INFO + caninfo("shutdown TWAI%" PRIu8 "\n", priv->port); +#endif + + if (priv->cpuint != -ENOMEM) + { + /* Disable cpu interrupt */ + + up_disable_irq(priv->cpuint); + + /* Dissociate the IRQ from the ISR */ + + irq_detach(priv->irq); + + /* Free cpu interrupt that is attached to this peripheral */ + + esp32c3_free_cpuint(priv->periph); + priv->cpuint = -ENOMEM; + } +} + +/**************************************************************************** + * Name: esp32c3twai_rxint + * + * Description: + * Call to enable or disable RX interrupts. + * + * Input Parameters: + * dev - An instance of the "upper half" CAN driver state structure. + * enable - Enable or disable receive interrupt. + * + * Returned Value: + * None + * + ****************************************************************************/ + +static void esp32c3twai_rxint(struct can_dev_s *dev, bool enable) +{ + struct twai_dev_s *priv = (struct twai_dev_s *)dev->cd_priv; + uint32_t regval; + irqstate_t flags; + + caninfo("TWAI%" PRIu8 " enable: %d\n", priv->port, enable); + + /* The INT_ENA register is also modified from the interrupt handler, + * so we have to protect this code section. + */ + + flags = enter_critical_section(); + regval = twai_getreg(TWAI_INT_ENA_REG); + if (enable) + { + regval |= TWAI_RX_INT_ENA_M; + } + else + { + regval &= ~TWAI_RX_INT_ENA_M; + } + + twai_putreg(TWAI_INT_ENA_REG, regval); + leave_critical_section(flags); +} + +/**************************************************************************** + * Name: esp32c3twai_txint + * + * Description: + * Call to enable or disable TX interrupts. + * + * Input Parameters: + * dev - An instance of the "upper half" CAN driver state structure. + * enable - Enable or disable transmit interrupt. + * + * Returned Value: + * None + * + ****************************************************************************/ + +static void esp32c3twai_txint(struct can_dev_s *dev, bool enable) +{ + struct twai_dev_s *priv = (struct twai_dev_s *)dev->cd_priv; + uint32_t regval; + irqstate_t flags; + + caninfo("TWAI%" PRIu8 " enable: %d\n", priv->port, enable); + + /* Only disabling of the TX interrupt is supported here. The TX interrupt + * is automatically enabled just before a message is sent in order to avoid + * lost TX interrupts. + */ + + if (!enable) + { + /* TX interrupts are also disabled from the interrupt handler, so we + * have to protect this code section. + */ + + flags = enter_critical_section(); + + /* Disable all TX interrupts */ + + regval = twai_getreg(TWAI_INT_ENA_REG); + regval &= ~(TWAI_TX_INT_ENA_M); + twai_putreg(TWAI_INT_ENA_REG, regval); + leave_critical_section(flags); + } +} + +/**************************************************************************** + * Name: esp32c3twai_ioctl + * + * Description: + * All ioctl calls will be routed through this method + * + * Input Parameters: + * dev - An instance of the "upper half" CAN driver state structure. + * cmd - A ioctl command. + * arg - A ioctl argument. + * + * Returned Value: + * Zero on success; a negated errno on failure + * + ****************************************************************************/ + +static int esp32c3twai_ioctl(struct can_dev_s *dev, int cmd, + unsigned long arg) +{ + struct twai_dev_s *priv = (struct twai_dev_s *)dev->cd_priv; + int ret = -ENOTTY; + + caninfo("TWAI%" PRIu8 " cmd=%04x arg=%lu\n", priv->port, cmd, arg); + + /* Handle the command */ + + switch (cmd) + { + /* CANIOC_GET_BITTIMING: + * Description: Return the current bit timing settings + * Argument: A pointer to a write-able instance of struct + * canioc_bittiming_s in which current bit timing + * values will be returned. + * Returned Value: Zero (OK) is returned on success. Otherwise -1 + * (ERROR) is returned with the errno variable set + * to indicate the nature of the error. + * Dependencies: None + */ + + case CANIOC_GET_BITTIMING: + { + struct canioc_bittiming_s *bt = + (struct canioc_bittiming_s *)arg; + uint32_t timing0; + uint32_t timing1; + uint32_t brp; + + DEBUGASSERT(bt != NULL); + + timing0 = twai_getreg(TWAI_BUS_TIMING_0_REG); + timing1 = twai_getreg(TWAI_BUS_TIMING_1_REG); + + brp = ((timing0 & TWAI_BAUD_PRESC_M) + 1) * 2; + bt->bt_sjw = ((timing0 & TWAI_SYNC_JUMP_WIDTH_M) >> + TWAI_SYNC_JUMP_WIDTH_S) + 1; + + bt->bt_tseg1 = ((timing1 & TWAI_TIME_SEG1_M) >> + TWAI_TIME_SEG1_S) + 1; + bt->bt_tseg2 = ((timing1 & TWAI_TIME_SEG2_M) >> + TWAI_TIME_SEG2_S)+ 1; + bt->bt_baud = esp32c3_clk_apb_freq() / + (brp * (bt->bt_tseg1 + bt->bt_tseg2 + 1)); + + ret = OK; + } + break; + + /* Unsupported/unrecognized command */ + + default: + canerr("ERROR: Unrecognized command: %04x\n", cmd); + break; + } + + return ret; +} + +static int esp32c3twai_remoterequest(struct can_dev_s *dev, uint16_t id) +{ + canwarn("Remote request not implemented\n"); + return -ENOSYS; +} + +/**************************************************************************** + * Name: esp32c3twai_send + * + * Description: + * Send one TWAI message. + * + * One TWAI-message consists of a maximum of 10 bytes. A message is + * composed of at least the first 2 bytes (when there are no data bytes). + * + * Byte 0: Bits 0-7: Bits 3-10 of the 11-bit TWAI identifier + * Byte 1: Bits 5-7: Bits 0-2 of the 11-bit TWAI identifier + * Bit 4: Remote Transmission Request (RTR) + * Bits 0-3: Data Length Code (DLC) + * Bytes 2-10: TWAI data + * + * Input Parameters: + * dev - An instance of the "upper half" CAN driver state structure. + * msg - A message to send. + * + * Returned Value: + * Zero on success; a negated errno on failure + * + ****************************************************************************/ + +static int esp32c3twai_send(struct can_dev_s *dev, + struct can_msg_s *msg) +{ + struct twai_dev_s *priv = (struct twai_dev_s *)dev->cd_priv; + uint32_t regval; + uint32_t i; + uint32_t len; + uint32_t id; + uint32_t frame_info; + irqstate_t flags; + int ret = OK; + + caninfo("TWAI%" PRIu8 " ID: %" PRIu32 " DLC: %" PRIu8 "\n", + priv->port, (uint32_t)msg->cm_hdr.ch_id, msg->cm_hdr.ch_dlc); + + len = (uint32_t)msg->cm_hdr.ch_dlc; + if (len > CAN_MAXDATALEN) + { + len = CAN_MAXDATALEN; + } + + frame_info = len; + + if (msg->cm_hdr.ch_rtr) + { + frame_info |= (1 << 6); + } + + flags = enter_critical_section(); + + /* Make sure that TX interrupts are enabled BEFORE sending the + * message. + * + * NOTE: The INT_ENA is also modified from the interrupt handler, but the + * following is safe because interrupts are disabled here. + */ + + regval = twai_getreg(TWAI_INT_ENA_REG); + regval |= TWAI_TX_INT_ENA_M; + twai_putreg(TWAI_INT_ENA_REG, regval); + + /* Set up the transfer */ + +#ifdef CONFIG_CAN_EXTID + if (msg->cm_hdr.ch_extid) + { + /* The provided ID should be 29 bits */ + + id = (uint32_t)msg->cm_hdr.ch_id; + DEBUGASSERT((id & ~CAN_MAX_EXTMSGID) == 0); + frame_info |= (1 << 7); + twai_putreg(TWAI_DATA_0_REG, frame_info); + + id <<= 3; + twai_putreg(TWAI_DATA_4_REG, id & 0xff); + id >>= 8; + twai_putreg(TWAI_DATA_3_REG, id & 0xff); + id >>= 8; + twai_putreg(TWAI_DATA_2_REG, id & 0xff); + id >>= 8; + twai_putreg(TWAI_DATA_1_REG, id & 0xff); + for (i = 0; i < len; i++) + { + twai_putreg(TWAI_DATA_5_REG + (i * 4), msg->cm_data[i]); + } + } + else +#endif + { + /* The provided ID should be 11 bits */ + + id = (uint32_t)msg->cm_hdr.ch_id; + DEBUGASSERT((id & ~CAN_MAX_STDMSGID) == 0); + twai_putreg(TWAI_DATA_0_REG, frame_info); + id <<= 5; + twai_putreg(TWAI_DATA_1_REG, (id >> 8) & 0xff); + twai_putreg(TWAI_DATA_2_REG, id & 0xff); + for (i = 0; i < len; i++) + { + twai_putreg(TWAI_DATA_3_REG + (i * 4), msg->cm_data[i]); + } + } + + /* Send the message */ + +#ifdef CONFIG_CAN_LOOPBACK + twai_putreg(TWAI_CMD_REG, TWAI_SELF_RX_REQ_M | TWAI_ABORT_TX_M); +#else + twai_putreg(TWAI_CMD_REG, TWAI_TX_REQ_M); +#endif + + leave_critical_section(flags); + + return ret; +} + +/**************************************************************************** + * Name: esp32c3twai_txready + * + * Description: + * Return true if the TWAI hardware can accept another TX message. + * + * Input Parameters: + * dev - An instance of the "upper half" CAN driver state structure. + * + * Returned Value: + * True if the TWAI hardware is ready to accept another TX message. + * + ****************************************************************************/ + +static bool esp32c3twai_txready(struct can_dev_s *dev) +{ + struct twai_dev_s *priv = dev->cd_priv; + uint32_t regval = twai_getreg(TWAI_STATUS_REG); + + caninfo("TWAI%" PRIu8 " txready: %d\n", priv->port, + ((regval & TWAI_TX_BUF_ST_M) != 0)); + return ((regval & TWAI_TX_BUF_ST_M) != 0); +} + +/**************************************************************************** + * Name: esp32c3twai_txempty + * + * Description: + * Return true if all message have been sent. If for example, the TWAI + * hardware implements FIFOs, then this would mean the transmit FIFO is + * empty. This method is called when the driver needs to make sure that + * all characters are "drained" from the TX hardware before calling + * co_shutdown(). + * + * Input Parameters: + * dev - An instance of the "upper half" CAN driver state structure. + * + * Returned Value: + * True if there are no pending TX transfers in the TWAI hardware. + * + ****************************************************************************/ + +static bool esp32c3twai_txempty(struct can_dev_s *dev) +{ + struct twai_dev_s *priv = dev->cd_priv; + uint32_t regval = twai_getreg(TWAI_STATUS_REG); + + caninfo("TWAI%" PRIu8 " txempty: %d\n", priv->port, + ((regval & TWAI_TX_BUF_ST_M) != 0)); + return ((regval & TWAI_TX_BUF_ST_M) != 0); +} + +/**************************************************************************** + * Name: esp32c3twai_interrupt + * + * Description: + * TWAI0 RX/TX interrupt handler + * + * Input Parameters: + * irq - The IRQ number of the interrupt. + * context - The register state save array at the time of the interrupt. + * arg - The pointer to driver structure. + * + * Returned Value: + * Zero on success; a negated errno on failure + * + ****************************************************************************/ + +static int esp32c3twai_interrupt(int irq, void *context, void *arg) +{ +#ifdef CONFIG_ESP32C3_TWAI0 + struct can_dev_s *dev = (struct can_dev_s *)arg; + struct can_hdr_s hdr; + uint8_t data[8]; + uint32_t frame_info; + uint32_t len; + uint32_t datastart; + uint32_t regval; + uint32_t i; + + /* Read the interrupt register results in clearing bits */ + + regval = twai_getreg(TWAI_INT_RAW_REG); + + /* Check for a receive interrupt */ + + if ((regval & TWAI_RX_INT_ST_M) != 0) + { + memset(&hdr, 0, sizeof(hdr)); + memset(data, 0, sizeof(data)); + + frame_info = twai_getreg(TWAI_DATA_0_REG); + + /* Construct the TWAI header */ + + if (frame_info & (1 << 6)) + { + hdr.ch_rtr = 1; + } + +#ifdef CONFIG_CAN_EXTID + if (frame_info & (1 << 7)) + { + /* The provided ID should be 29 bits */ + + hdr.ch_extid = 1; + hdr.ch_id = + (twai_getreg(TWAI_DATA_1_REG) << 21) + + (twai_getreg(TWAI_DATA_2_REG) << 13) + + (twai_getreg(TWAI_DATA_3_REG) << 5) + + (twai_getreg(TWAI_DATA_4_REG) >> 3); + datastart = TWAI_DATA_5_REG; + } + else +#endif + { + /* The provided ID should be 11 bits */ + + hdr.ch_id = + (twai_getreg(TWAI_DATA_1_REG) << 3) + + (twai_getreg(TWAI_DATA_2_REG) >> 5); + datastart = TWAI_DATA_3_REG; + } + + len = frame_info & 0xf; + if (len > CAN_MAXDATALEN) + { + len = CAN_MAXDATALEN; + } + + hdr.ch_dlc = len; + + for (i = 0; i < len; i++) + { + data[i] = twai_getreg(datastart + (i * 4)); + } + + /* Release the receive buffer */ + + twai_putreg(TWAI_CMD_REG, TWAI_RELEASE_BUF_M); + +#ifdef CONFIG_CAN_ERRORS + hdr.ch_error = 0; /* Error reporting not supported */ +#endif + can_receive(dev, &hdr, data); + } + + /* Check for TX buffer complete */ + + if ((regval & TWAI_TX_INT_ST_M) != 0) + { + /* Disable all further TX buffer interrupts */ + + regval = twai_getreg(TWAI_INT_ENA_REG); + regval &= ~TWAI_TX_INT_ENA_M; + twai_putreg(TWAI_INT_ENA_REG, regval); + + /* Indicate that the TX is done and a new TX buffer is available */ + + can_txdone(dev); + } + +#endif + return OK; +} + +/**************************************************************************** + * Name: esp32c3twai_set_acc_filter + * + * Description: + * Call to set acceptance filter. + * Must be called in reset mode. + * + * Input Parameters: + * code - Acceptance Code. + * mask - Acceptance Mask. + * single_filter - Whether to enable single filter mode. + * + * Returned Value: + * None + * + ****************************************************************************/ + +static void esp32c3twai_set_acc_filter(uint32_t code, uint32_t mask, + bool single_filter) +{ + uint32_t regval; + uint32_t code_swapped = __builtin_bswap32(code); + uint32_t mask_swapped = __builtin_bswap32(mask); + + regval = twai_getreg(TWAI_MODE_REG); + if (single_filter) + { + regval |= TWAI_RX_FILTER_MODE_M; + } + else + { + regval &= ~(TWAI_RX_FILTER_MODE_M); + } + + twai_putreg(TWAI_MODE_REG, regval); + + for (int i = 0; i < 4; i++) + { + twai_putreg(TWAI_DATA_0_REG + (i * 4), + ((code_swapped >> (i * 8)) & 0xff)); + twai_putreg(TWAI_DATA_4_REG + (i * 4), + ((mask_swapped >> (i * 8)) & 0xff)); + } +} + +/**************************************************************************** + * Name: twai_baud_rate + * + * Description: + * Set the CAN bus timing registers based on the configured bit-rate and + * sample point position. + * + * The bit timing logic monitors the serial bus-line and performs sampling + * and adjustment of the sample point by synchronizing on the start-bit edge + * and resynchronizing on the following edges. + * + * Its operation may be explained simply by splitting nominal bit time into + * three segments as follows: + * + * 1. Synchronization segment (SYNC_SEG): a bit change is expected to occur + * within this time segment. It has a fixed length of one time quantum + * (1 x tCAN). + * 2. Bit segment 1 (BS1): defines the location of the sample point. It + * includes the PROP_SEG and PHASE_SEG1 of the CAN standard. Its duration + * is programmable between 1 and 16 time quanta but may be automatically + * lengthened to compensate for positive phase drifts due to differences + * in the frequency of the various nodes of the network. + * 3. Bit segment 2 (BS2): defines the location of the transmit point. It + * represents the PHASE_SEG2 of the CAN standard. Its duration is + * programmable between 1 and 8 time quanta but may also be automatically + * shortened to compensate for negative phase drifts. + * + * Pictorially: + * + * |<----------------- NOMINAL BIT TIME ----------------->| + * |<- SYNC_SEG ->|<------ BS1 ------>|<------ BS2 ------>| + * |<---- Tq ---->|<----- Tbs1 ------>|<----- Tbs2 ------>| + * + * Where + * Tbs1 is the duration of the BS1 segment + * Tbs2 is the duration of the BS2 segment + * Tq is the "Time Quantum" + * + * Relationships: + * + * baud = 1 / bit_time + * bit_time = Tq + Tbs1 + Tbs2 + * Tbs1 = Tq * ts1 + * Tbs2 = Tq * ts2 + * Tq = brp * Tcan + * + * Where: + * Tcan is the period of the APB clock + * + * Input Parameters: + * priv - A reference to the CAN block status + * + * Returned Value: + * Zero on success; a negated errno on failure + * + ****************************************************************************/ + +static int twai_baud_rate(struct twai_dev_s *priv, int rate, int clock, + int sjw, int sampl_pt, int flags) +{ + const struct can_bittiming_const *timing = + &esp32c3_twai_bittiming_const; + int best_error = 1000000000; + int error; + int best_tseg = 0; + int best_brp = 0; + int best_rate = 0; + int brp = 0; + int tseg = 0; + int tseg1 = 0; + int tseg2 = 0; + uint32_t timing0; + uint32_t timing1; + + /* tseg even = round down, odd = round up */ + + for (tseg = (0 + 0 + 2) * 2; + tseg <= (timing->tseg2_max + timing->tseg1_max + 2) * 2 + 1; tseg++) + { + brp = clock / ((1 + tseg / 2) * rate) + tseg % 2; + if (brp == 0 || brp > 64) + { + continue; + } + + error = rate - clock / (brp * (1 + tseg / 2)); + if (error < 0) + { + error = -error; + } + + if (error <= best_error) + { + best_error = error; + best_tseg = tseg / 2; + best_brp = brp; + best_rate = clock / (brp * (1 + tseg / 2)); + } + } + + if (best_error && (rate / best_error < 10)) + { + caninfo("baud rate %d is not possible with %d Hz clock\n", + rate, clock); + caninfo("%d bps. brp=%d, best_tseg=%d, tseg1=%d, tseg2=%d\n", + best_rate, best_brp, best_tseg, tseg1, tseg2); + return -EINVAL; + } + + tseg2 = best_tseg - (sampl_pt * (best_tseg + 1)) / 100 + 1; + if (tseg2 < 0) + { + tseg2 = 0; + } + + if (tseg2 > timing->tseg2_max) + { + tseg2 = timing->tseg2_max; + } + + tseg1 = best_tseg - tseg2; + if (tseg1 > timing->tseg1_max) + { + tseg1 = timing->tseg1_max; + tseg2 = best_tseg - tseg1; + } + + caninfo("TS1: %d TS2: %d BRP: %d\n", tseg1, tseg2, best_brp); + + /* Configure bit timing */ + + timing0 = (best_brp - 1) / 2; + timing0 |= (sjw - 1) << TWAI_SYNC_JUMP_WIDTH_S; + + timing1 = tseg1 - 1; + timing1 |= (tseg2 - 1) << TWAI_TIME_SEG2_S; + + #ifdef CONFIG_ESP32C3_TWAI0_SAM + /* The bus is sampled 3 times (recommended for low to medium speed buses + * to spikes on the bus-line). + */ + + timing1 |= CONFIG_ESP32C3_TWAI0_SAM << TWAI_TIME_SAMP_S; + #endif + + twai_putreg(TWAI_BUS_TIMING_0_REG, timing0); + twai_putreg(TWAI_BUS_TIMING_1_REG, timing1); + + return OK; +} + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: esp32c3_twaiinitialize + * + * Description: + * Initialize the selected TWAI port + * + * Input Parameters: + * Port number (for hardware that has multiple TWAI interfaces) + * + * Returned Value: + * Valid TWAI device structure reference on success; a NULL on failure + * + ****************************************************************************/ + +struct can_dev_s *esp32c3_twaiinitialize(int port) +{ + struct can_dev_s *twaidev; + irqstate_t flags; + + caninfo("TWAI%" PRIu8 "\n", port); + + flags = enter_critical_section(); + +#ifdef CONFIG_ESP32C3_TWAI0 + if (port == 0) + { + /* Enable power to the TWAI module and + * Enable clocking to the TWAI module + */ + + modifyreg32(SYSTEM_PERIP_RST_EN0_REG, 0, SYSTEM_TWAI_RST_M); + modifyreg32(SYSTEM_PERIP_CLK_EN0_REG, SYSTEM_TWAI_CLK_EN_M, 0); + + usleep(1); + + modifyreg32(SYSTEM_PERIP_CLK_EN0_REG, 0, SYSTEM_TWAI_CLK_EN_M); + modifyreg32(SYSTEM_PERIP_RST_EN0_REG, SYSTEM_TWAI_RST_M, 0); + + /* Configure CAN GPIO pins */ + + esp32c3_gpio_matrix_out(CONFIG_ESP32C3_TWAI0_TXPIN, TWAI_TX_IDX, 0, 0); + esp32c3_configgpio(CONFIG_ESP32C3_TWAI0_TXPIN, OUTPUT_FUNCTION_1); + + esp32c3_configgpio(CONFIG_ESP32C3_TWAI0_RXPIN, INPUT_FUNCTION_1); + esp32c3_gpio_matrix_in(CONFIG_ESP32C3_TWAI0_RXPIN, TWAI_RX_IDX, 0); + + twaidev = &g_twai0dev; + } + else +#endif + + { + canerr("ERROR: Unsupported port: %d\n", port); + leave_critical_section(flags); + return NULL; + } + + /* Then just perform a TWAI reset operation */ + + esp32c3twai_reset(twaidev); + + leave_critical_section(flags); + + return twaidev; +} +#endif diff --git a/arch/arm/src/armv7-m/iar/arm_fullcontextrestore.S b/arch/risc-v/src/esp32c3/esp32c3_twai.h similarity index 72% rename from arch/arm/src/armv7-m/iar/arm_fullcontextrestore.S rename to arch/risc-v/src/esp32c3/esp32c3_twai.h index 7f0ad6502d619..d844426a61658 100644 --- a/arch/arm/src/armv7-m/iar/arm_fullcontextrestore.S +++ b/arch/risc-v/src/esp32c3/esp32c3_twai.h @@ -1,5 +1,5 @@ /**************************************************************************** - * arch/arm/src/armv7-m/iar/arm_fullcontextrestore.S + * arch/risc-v/src/esp32c3/esp32c3_twai.h * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with @@ -18,62 +18,60 @@ * ****************************************************************************/ +#ifndef __ARCH_RISCV_SRC_ESP32C3_ESP32C3_TWAI_H +#define __ARCH_RISCV_SRC_ESP32C3_ESP32C3_TWAI_H + /**************************************************************************** * Included Files ****************************************************************************/ #include -#include -#include - -#include "nvic.h" - - MODULE arm_fullcontextrestore - SECTION .text:CODE:NOROOT(2) +#include "hardware/esp32c3_twai.h" /**************************************************************************** * Pre-processor Definitions ****************************************************************************/ /**************************************************************************** - * Public Symbols + * Public Types ****************************************************************************/ - PUBLIC arm_fullcontextrestore - /**************************************************************************** - * Macros + * Public Data ****************************************************************************/ +#ifndef __ASSEMBLY__ +#ifdef __cplusplus +extern "C" +{ +#endif + /**************************************************************************** - * Public Functions + * Public Functions Prototypes ****************************************************************************/ /**************************************************************************** - * Name: arm_fullcontextrestore + * Name: esp32c3_twaiinitialize * * Description: - * Restore the current thread context. Full prototype is: + * Initialize the selected CAN port * - * void arm_fullcontextrestore(uint32_t *restoreregs) noreturn_function; + * Input Parameters: + * Port number (for hardware that has multiple TWAI interfaces) * * Returned Value: - * None + * Valid TWAI device structure reference on success; a NULL on failure * ****************************************************************************/ - THUMB - -arm_fullcontextrestore: - - /* Perform the System call with R0=1 and R1=regs */ - - mov r1, r0 /* R1: regs */ - mov r0, #SYS_restore_context /* R0: restore context */ - svc #SYS_syscall /* Force synchronous SVCall (or Hard Fault) */ - - /* This call should not return */ +#if defined(CONFIG_CAN) && defined(CONFIG_ESP32C3_TWAI) +struct can_dev_s; +struct can_dev_s *esp32c3_twaiinitialize(int port); +#endif - bx lr /* Unnecessary ... will not return */ +#ifdef __cplusplus +} +#endif +#endif /* __ASSEMBLY__ */ - END +#endif /* __ARCH_RISCV_SRC_ESP32C3_ESP32C3_TWAI_H */ diff --git a/arch/risc-v/src/esp32c3/esp32c3_uid.c b/arch/risc-v/src/esp32c3/esp32c3_uid.c index 71da0b6bb40c7..e823d05628500 100644 --- a/arch/risc-v/src/esp32c3/esp32c3_uid.c +++ b/arch/risc-v/src/esp32c3/esp32c3_uid.c @@ -26,9 +26,6 @@ #include -#include -#include - #include "hardware/esp32c3_efuse.h" #include "esp32c3.h" diff --git a/arch/risc-v/src/esp32c3/esp32c3_usbserial.c b/arch/risc-v/src/esp32c3/esp32c3_usbserial.c index 340a0b7684351..84702daa04ffd 100644 --- a/arch/risc-v/src/esp32c3/esp32c3_usbserial.c +++ b/arch/risc-v/src/esp32c3/esp32c3_usbserial.c @@ -402,7 +402,7 @@ static int esp32c3_ioctl(struct file *filep, int cmd, unsigned long arg) struct inode *inode = filep->f_inode; struct uart_dev_s *dev = inode->i_private; #endif - int ret = OK; + int ret = OK; switch (cmd) { diff --git a/arch/risc-v/src/esp32c3/esp32c3_vectors.S b/arch/risc-v/src/esp32c3/esp32c3_vectors.S index d26632c64feed..25e16206099ed 100644 --- a/arch/risc-v/src/esp32c3/esp32c3_vectors.S +++ b/arch/risc-v/src/esp32c3/esp32c3_vectors.S @@ -51,13 +51,7 @@ _vector_table: .option push .option norvc - /* exception handler, entry 0 */ - - j _exception_handler - - /* 31 identical entries, all pointing to the interrupt handler */ - - .rept (31) - j _interrupt_handler + .rept (32) + j exception_common .endr diff --git a/arch/risc-v/src/esp32c3/esp32c3_wifi_adapter.c b/arch/risc-v/src/esp32c3/esp32c3_wifi_adapter.c index 321d196e363f7..42483bdac7de6 100644 --- a/arch/risc-v/src/esp32c3/esp32c3_wifi_adapter.c +++ b/arch/risc-v/src/esp32c3/esp32c3_wifi_adapter.c @@ -50,10 +50,14 @@ #include #include #include + +#include "riscv_internal.h" + #include "hardware/esp32c3_system.h" #include "hardware/wdev_reg.h" #include "hardware/esp32c3_rtccntl.h" #include "hardware/esp32c3_syscon.h" + #include "esp32c3.h" #include "esp32c3_attr.h" #include "esp32c3_irq.h" diff --git a/arch/risc-v/src/esp32c3/hardware/esp32c3_twai.h b/arch/risc-v/src/esp32c3/hardware/esp32c3_twai.h new file mode 100644 index 0000000000000..2aa56b84dd28a --- /dev/null +++ b/arch/risc-v/src/esp32c3/hardware/esp32c3_twai.h @@ -0,0 +1,856 @@ +/**************************************************************************** + * arch/risc-v/src/esp32c3/hardware/esp32c3_twai.h + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +#ifndef __ARCH_RISCV_SRC_ESP32C3_HARDWARE_ESP32C3_TWAI_H +#define __ARCH_RISCV_SRC_ESP32C3_HARDWARE_ESP32C3_TWAI_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include "esp32c3_soc.h" + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/* TWAI_MODE_REG register + * Mode Register + */ + +#define TWAI_MODE_REG (DR_REG_TWAI_BASE + 0x0) + +/* TWAI_RX_FILTER_MODE : R/W; bitpos: [3]; default: 0; + * This bit is used to configure the filter mode. 0: Dual filter mode; 1: + * Single filter mode. + */ + +#define TWAI_RX_FILTER_MODE (BIT(3)) +#define TWAI_RX_FILTER_MODE_M (TWAI_RX_FILTER_MODE_V << TWAI_RX_FILTER_MODE_S) +#define TWAI_RX_FILTER_MODE_V 0x00000001 +#define TWAI_RX_FILTER_MODE_S 3 + +/* TWAI_SELF_TEST_MODE : R/W; bitpos: [2]; default: 0; + * 1: Self test mode. In this mode the TX nodes can perform a successful + * transmission without receiving the acknowledge signal. This mode is often + * used to test a single node with the self reception request command. + */ + +#define TWAI_SELF_TEST_MODE (BIT(2)) +#define TWAI_SELF_TEST_MODE_M (TWAI_SELF_TEST_MODE_V << TWAI_SELF_TEST_MODE_S) +#define TWAI_SELF_TEST_MODE_V 0x00000001 +#define TWAI_SELF_TEST_MODE_S 2 + +/* TWAI_LISTEN_ONLY_MODE : R/W; bitpos: [1]; default: 0; + * 1: Listen only mode. In this mode the nodes will only receive messages + * from the bus, without generating the acknowledge signal nor updating the + * RX error counter. + */ + +#define TWAI_LISTEN_ONLY_MODE (BIT(1)) +#define TWAI_LISTEN_ONLY_MODE_M (TWAI_LISTEN_ONLY_MODE_V << TWAI_LISTEN_ONLY_MODE_S) +#define TWAI_LISTEN_ONLY_MODE_V 0x00000001 +#define TWAI_LISTEN_ONLY_MODE_S 1 + +/* TWAI_RESET_MODE : R/W; bitpos: [0]; default: 1; + * This bit is used to configure the operating mode of the TWAI Controller. + * 1: Reset mode; 0: Operating mode. + */ + +#define TWAI_RESET_MODE (BIT(0)) +#define TWAI_RESET_MODE_M (TWAI_RESET_MODE_V << TWAI_RESET_MODE_S) +#define TWAI_RESET_MODE_V 0x00000001 +#define TWAI_RESET_MODE_S 0 + +/* TWAI_CMD_REG register + * Command Register + */ + +#define TWAI_CMD_REG (DR_REG_TWAI_BASE + 0x4) + +/* TWAI_SELF_RX_REQ : WO; bitpos: [4]; default: 0; + * Self reception request command. Set the bit to 1 to allow a message be + * transmitted and received simultaneously. + */ + +#define TWAI_SELF_RX_REQ (BIT(4)) +#define TWAI_SELF_RX_REQ_M (TWAI_SELF_RX_REQ_V << TWAI_SELF_RX_REQ_S) +#define TWAI_SELF_RX_REQ_V 0x00000001 +#define TWAI_SELF_RX_REQ_S 4 + +/* TWAI_CLR_OVERRUN : WO; bitpos: [3]; default: 0; + * Set the bit to 1 to clear the data overrun status bit. + */ + +#define TWAI_CLR_OVERRUN (BIT(3)) +#define TWAI_CLR_OVERRUN_M (TWAI_CLR_OVERRUN_V << TWAI_CLR_OVERRUN_S) +#define TWAI_CLR_OVERRUN_V 0x00000001 +#define TWAI_CLR_OVERRUN_S 3 + +/* TWAI_RELEASE_BUF : WO; bitpos: [2]; default: 0; + * Set the bit to 1 to release the RX buffer. + */ + +#define TWAI_RELEASE_BUF (BIT(2)) +#define TWAI_RELEASE_BUF_M (TWAI_RELEASE_BUF_V << TWAI_RELEASE_BUF_S) +#define TWAI_RELEASE_BUF_V 0x00000001 +#define TWAI_RELEASE_BUF_S 2 + +/* TWAI_ABORT_TX : WO; bitpos: [1]; default: 0; + * Set the bit to 1 to cancel a pending transmission request. + */ + +#define TWAI_ABORT_TX (BIT(1)) +#define TWAI_ABORT_TX_M (TWAI_ABORT_TX_V << TWAI_ABORT_TX_S) +#define TWAI_ABORT_TX_V 0x00000001 +#define TWAI_ABORT_TX_S 1 + +/* TWAI_TX_REQ : WO; bitpos: [0]; default: 0; + * Set the bit to 1 to allow the driving nodes start transmission. + */ + +#define TWAI_TX_REQ (BIT(0)) +#define TWAI_TX_REQ_M (TWAI_TX_REQ_V << TWAI_TX_REQ_S) +#define TWAI_TX_REQ_V 0x00000001 +#define TWAI_TX_REQ_S 0 + +/* TWAI_STATUS_REG register + * Status register + */ + +#define TWAI_STATUS_REG (DR_REG_TWAI_BASE + 0x8) + +/* TWAI_MISS_ST : RO; bitpos: [8]; default: 0; + * This bit reflects whether the data packet in the RX FIFO is complete. 1: + * The current packet is missing; 0: The current packet is complete + */ + +#define TWAI_MISS_ST (BIT(8)) +#define TWAI_MISS_ST_M (TWAI_MISS_ST_V << TWAI_MISS_ST_S) +#define TWAI_MISS_ST_V 0x00000001 +#define TWAI_MISS_ST_S 8 + +/* TWAI_BUS_OFF_ST : RO; bitpos: [7]; default: 0; + * 1: In bus-off status, the TWAI Controller is no longer involved in bus + * activities. + */ + +#define TWAI_BUS_OFF_ST (BIT(7)) +#define TWAI_BUS_OFF_ST_M (TWAI_BUS_OFF_ST_V << TWAI_BUS_OFF_ST_S) +#define TWAI_BUS_OFF_ST_V 0x00000001 +#define TWAI_BUS_OFF_ST_S 7 + +/* TWAI_ERR_ST : RO; bitpos: [6]; default: 0; + * 1: At least one of the RX/TX error counter has reached or exceeded the + * value set in register TWAI_ERR_WARNING_LIMIT_REG. + */ + +#define TWAI_ERR_ST (BIT(6)) +#define TWAI_ERR_ST_M (TWAI_ERR_ST_V << TWAI_ERR_ST_S) +#define TWAI_ERR_ST_V 0x00000001 +#define TWAI_ERR_ST_S 6 + +/* TWAI_TX_ST : RO; bitpos: [5]; default: 0; + * 1: The TWAI Controller is transmitting a message to the bus. + */ + +#define TWAI_TX_ST (BIT(5)) +#define TWAI_TX_ST_M (TWAI_TX_ST_V << TWAI_TX_ST_S) +#define TWAI_TX_ST_V 0x00000001 +#define TWAI_TX_ST_S 5 + +/* TWAI_RX_ST : RO; bitpos: [4]; default: 0; + * 1: The TWAI Controller is receiving a message from the bus. + */ + +#define TWAI_RX_ST (BIT(4)) +#define TWAI_RX_ST_M (TWAI_RX_ST_V << TWAI_RX_ST_S) +#define TWAI_RX_ST_V 0x00000001 +#define TWAI_RX_ST_S 4 + +/* TWAI_TX_COMPLETE : RO; bitpos: [3]; default: 0; + * 1: The TWAI controller has successfully received a packet from the bus. + */ + +#define TWAI_TX_COMPLETE (BIT(3)) +#define TWAI_TX_COMPLETE_M (TWAI_TX_COMPLETE_V << TWAI_TX_COMPLETE_S) +#define TWAI_TX_COMPLETE_V 0x00000001 +#define TWAI_TX_COMPLETE_S 3 + +/* TWAI_TX_BUF_ST : RO; bitpos: [2]; default: 0; + * 1: The TX buffer is empty, the CPU may write a message into it. + */ + +#define TWAI_TX_BUF_ST (BIT(2)) +#define TWAI_TX_BUF_ST_M (TWAI_TX_BUF_ST_V << TWAI_TX_BUF_ST_S) +#define TWAI_TX_BUF_ST_V 0x00000001 +#define TWAI_TX_BUF_ST_S 2 + +/* TWAI_OVERRUN_ST : RO; bitpos: [1]; default: 0; + * 1: The RX FIFO is full and data overrun has occurred. + */ + +#define TWAI_OVERRUN_ST (BIT(1)) +#define TWAI_OVERRUN_ST_M (TWAI_OVERRUN_ST_V << TWAI_OVERRUN_ST_S) +#define TWAI_OVERRUN_ST_V 0x00000001 +#define TWAI_OVERRUN_ST_S 1 + +/* TWAI_RX_BUF_ST : RO; bitpos: [0]; default: 0; + * 1: The data in the RX buffer is not empty, with at least one received + * data packet. + */ + +#define TWAI_RX_BUF_ST (BIT(0)) +#define TWAI_RX_BUF_ST_M (TWAI_RX_BUF_ST_V << TWAI_RX_BUF_ST_S) +#define TWAI_RX_BUF_ST_V 0x00000001 +#define TWAI_RX_BUF_ST_S 0 + +/* TWAI_INT_RAW_REG register + * Interrupt Register + */ + +#define TWAI_INT_RAW_REG (DR_REG_TWAI_BASE + 0xc) + +/* TWAI_BUS_ERR_INT_ST : RO; bitpos: [7]; default: 0; + * Error interrupt. If this bit is set to 1, it indicates an error is + * detected on the bus. + */ + +#define TWAI_BUS_ERR_INT_ST (BIT(7)) +#define TWAI_BUS_ERR_INT_ST_M (TWAI_BUS_ERR_INT_ST_V << TWAI_BUS_ERR_INT_ST_S) +#define TWAI_BUS_ERR_INT_ST_V 0x00000001 +#define TWAI_BUS_ERR_INT_ST_S 7 + +/* TWAI_ARB_LOST_INT_ST : RO; bitpos: [6]; default: 0; + * Arbitration lost interrupt. If this bit is set to 1, it indicates an + * arbitration lost interrupt is generated. + */ + +#define TWAI_ARB_LOST_INT_ST (BIT(6)) +#define TWAI_ARB_LOST_INT_ST_M (TWAI_ARB_LOST_INT_ST_V << TWAI_ARB_LOST_INT_ST_S) +#define TWAI_ARB_LOST_INT_ST_V 0x00000001 +#define TWAI_ARB_LOST_INT_ST_S 6 + +/* TWAI_ERR_PASSIVE_INT_ST : RO; bitpos: [5]; default: 0; + * Error passive interrupt. If this bit is set to 1, it indicates the TWAI + * Controller is switched between error active status and error passive + * status due to the change of error counters. + */ + +#define TWAI_ERR_PASSIVE_INT_ST (BIT(5)) +#define TWAI_ERR_PASSIVE_INT_ST_M (TWAI_ERR_PASSIVE_INT_ST_V << TWAI_ERR_PASSIVE_INT_ST_S) +#define TWAI_ERR_PASSIVE_INT_ST_V 0x00000001 +#define TWAI_ERR_PASSIVE_INT_ST_S 5 + +/* TWAI_OVERRUN_INT_ST : RO; bitpos: [3]; default: 0; + * Data overrun interrupt. If this bit is set to 1, it indicates a data + * overrun interrupt is generated in the RX FIFO. + */ + +#define TWAI_OVERRUN_INT_ST (BIT(3)) +#define TWAI_OVERRUN_INT_ST_M (TWAI_OVERRUN_INT_ST_V << TWAI_OVERRUN_INT_ST_S) +#define TWAI_OVERRUN_INT_ST_V 0x00000001 +#define TWAI_OVERRUN_INT_ST_S 3 + +/* TWAI_ERR_WARN_INT_ST : RO; bitpos: [2]; default: 0; + * Error warning interrupt. If this bit is set to 1, it indicates the error + * status signal and the bus-off status signal of Status register have + * changed (e.g., switched from 0 to 1 or from 1 to 0). + */ + +#define TWAI_ERR_WARN_INT_ST (BIT(2)) +#define TWAI_ERR_WARN_INT_ST_M (TWAI_ERR_WARN_INT_ST_V << TWAI_ERR_WARN_INT_ST_S) +#define TWAI_ERR_WARN_INT_ST_V 0x00000001 +#define TWAI_ERR_WARN_INT_ST_S 2 + +/* TWAI_TX_INT_ST : RO; bitpos: [1]; default: 0; + * Transmit interrupt. If this bit is set to 1, it indicates the message + * transmitting mis- sion is finished and a new transmission is able to + * execute. + */ + +#define TWAI_TX_INT_ST (BIT(1)) +#define TWAI_TX_INT_ST_M (TWAI_TX_INT_ST_V << TWAI_TX_INT_ST_S) +#define TWAI_TX_INT_ST_V 0x00000001 +#define TWAI_TX_INT_ST_S 1 + +/* TWAI_RX_INT_ST : RO; bitpos: [0]; default: 0; + * Receive interrupt. If this bit is set to 1, it indicates there are + * messages to be handled in the RX FIFO. + */ + +#define TWAI_RX_INT_ST (BIT(0)) +#define TWAI_RX_INT_ST_M (TWAI_RX_INT_ST_V << TWAI_RX_INT_ST_S) +#define TWAI_RX_INT_ST_V 0x00000001 +#define TWAI_RX_INT_ST_S 0 + +/* TWAI_INT_ENA_REG register + * Interrupt Enable Register + */ + +#define TWAI_INT_ENA_REG (DR_REG_TWAI_BASE + 0x10) + +/* TWAI_BUS_ERR_INT_ENA : R/W; bitpos: [7]; default: 0; + * Set this bit to 1 to enable error interrupt. + */ + +#define TWAI_BUS_ERR_INT_ENA (BIT(7)) +#define TWAI_BUS_ERR_INT_ENA_M (TWAI_BUS_ERR_INT_ENA_V << TWAI_BUS_ERR_INT_ENA_S) +#define TWAI_BUS_ERR_INT_ENA_V 0x00000001 +#define TWAI_BUS_ERR_INT_ENA_S 7 + +/* TWAI_ARB_LOST_INT_ENA : R/W; bitpos: [6]; default: 0; + * Set this bit to 1 to enable arbitration lost interrupt. + */ + +#define TWAI_ARB_LOST_INT_ENA (BIT(6)) +#define TWAI_ARB_LOST_INT_ENA_M (TWAI_ARB_LOST_INT_ENA_V << TWAI_ARB_LOST_INT_ENA_S) +#define TWAI_ARB_LOST_INT_ENA_V 0x00000001 +#define TWAI_ARB_LOST_INT_ENA_S 6 + +/* TWAI_ERR_PASSIVE_INT_ENA : R/W; bitpos: [5]; default: 0; + * Set this bit to 1 to enable error passive interrupt. + */ + +#define TWAI_ERR_PASSIVE_INT_ENA (BIT(5)) +#define TWAI_ERR_PASSIVE_INT_ENA_M (TWAI_ERR_PASSIVE_INT_ENA_V << TWAI_ERR_PASSIVE_INT_ENA_S) +#define TWAI_ERR_PASSIVE_INT_ENA_V 0x00000001 +#define TWAI_ERR_PASSIVE_INT_ENA_S 5 + +/* TWAI_OVERRUN_INT_ENA : R/W; bitpos: [3]; default: 0; + * Set this bit to 1 to enable data overrun interrupt. + */ + +#define TWAI_OVERRUN_INT_ENA (BIT(3)) +#define TWAI_OVERRUN_INT_ENA_M (TWAI_OVERRUN_INT_ENA_V << TWAI_OVERRUN_INT_ENA_S) +#define TWAI_OVERRUN_INT_ENA_V 0x00000001 +#define TWAI_OVERRUN_INT_ENA_S 3 + +/* TWAI_ERR_WARN_INT_ENA : R/W; bitpos: [2]; default: 0; + * Set this bit to 1 to enable error warning interrupt. + */ + +#define TWAI_ERR_WARN_INT_ENA (BIT(2)) +#define TWAI_ERR_WARN_INT_ENA_M (TWAI_ERR_WARN_INT_ENA_V << TWAI_ERR_WARN_INT_ENA_S) +#define TWAI_ERR_WARN_INT_ENA_V 0x00000001 +#define TWAI_ERR_WARN_INT_ENA_S 2 + +/* TWAI_TX_INT_ENA : R/W; bitpos: [1]; default: 0; + * Set this bit to 1 to enable transmit interrupt. + */ + +#define TWAI_TX_INT_ENA (BIT(1)) +#define TWAI_TX_INT_ENA_M (TWAI_TX_INT_ENA_V << TWAI_TX_INT_ENA_S) +#define TWAI_TX_INT_ENA_V 0x00000001 +#define TWAI_TX_INT_ENA_S 1 + +/* TWAI_RX_INT_ENA : R/W; bitpos: [0]; default: 0; + * Set this bit to 1 to enable receive interrupt. + */ + +#define TWAI_RX_INT_ENA (BIT(0)) +#define TWAI_RX_INT_ENA_M (TWAI_RX_INT_ENA_V << TWAI_RX_INT_ENA_S) +#define TWAI_RX_INT_ENA_V 0x00000001 +#define TWAI_RX_INT_ENA_S 0 + +/* TWAI_BUS_TIMING_0_REG register + * Bus Timing Register 0 + */ + +#define TWAI_BUS_TIMING_0_REG (DR_REG_TWAI_BASE + 0x18) + +/* TWAI_SYNC_JUMP_WIDTH : RO | R/W; bitpos: [15:14]; default: 0; + * Synchronization Jump Width (SJW), 1 \verb+~+ 14 Tq wide. + */ + +#define TWAI_SYNC_JUMP_WIDTH 0x00000003 +#define TWAI_SYNC_JUMP_WIDTH_M (TWAI_SYNC_JUMP_WIDTH_V << TWAI_SYNC_JUMP_WIDTH_S) +#define TWAI_SYNC_JUMP_WIDTH_V 0x00000003 +#define TWAI_SYNC_JUMP_WIDTH_S 14 + +/* TWAI_BAUD_PRESC : RO | R/W; bitpos: [13:0]; default: 0; + * Baud Rate Prescaler, determines the frequency dividing ratio. + */ + +#define TWAI_BAUD_PRESC 0x00003FFF +#define TWAI_BAUD_PRESC_M (TWAI_BAUD_PRESC_V << TWAI_BAUD_PRESC_S) +#define TWAI_BAUD_PRESC_V 0x00003FFF +#define TWAI_BAUD_PRESC_S 0 + +/* TWAI_BUS_TIMING_1_REG register + * Bus Timing Register 1 + */ + +#define TWAI_BUS_TIMING_1_REG (DR_REG_TWAI_BASE + 0x1c) + +/* TWAI_TIME_SAMP : RO | R/W; bitpos: [7]; default: 0; + * The number of sample points. 0: the bus is sampled once; 1: the bus is + * sampled three times + */ + +#define TWAI_TIME_SAMP (BIT(7)) +#define TWAI_TIME_SAMP_M (TWAI_TIME_SAMP_V << TWAI_TIME_SAMP_S) +#define TWAI_TIME_SAMP_V 0x00000001 +#define TWAI_TIME_SAMP_S 7 + +/* TWAI_TIME_SEG2 : RO | R/W; bitpos: [6:4]; default: 0; + * The width of PBS2. + */ + +#define TWAI_TIME_SEG2 0x00000007 +#define TWAI_TIME_SEG2_M (TWAI_TIME_SEG2_V << TWAI_TIME_SEG2_S) +#define TWAI_TIME_SEG2_V 0x00000007 +#define TWAI_TIME_SEG2_S 4 + +/* TWAI_TIME_SEG1 : RO | R/W; bitpos: [3:0]; default: 0; + * The width of PBS1. + */ + +#define TWAI_TIME_SEG1 0x0000000F +#define TWAI_TIME_SEG1_M (TWAI_TIME_SEG1_V << TWAI_TIME_SEG1_S) +#define TWAI_TIME_SEG1_V 0x0000000F +#define TWAI_TIME_SEG1_S 0 + +/* TWAI_ARB_LOST_CAP_REG register + * Arbitration Lost Capture Register + */ + +#define TWAI_ARB_LOST_CAP_REG (DR_REG_TWAI_BASE + 0x2c) + +/* TWAI_ARB_LOST_CAP : RO; bitpos: [4:0]; default: 0; + * This register contains information about the bit position of lost + * arbitration. + */ + +#define TWAI_ARB_LOST_CAP 0x0000001F +#define TWAI_ARB_LOST_CAP_M (TWAI_ARB_LOST_CAP_V << TWAI_ARB_LOST_CAP_S) +#define TWAI_ARB_LOST_CAP_V 0x0000001F +#define TWAI_ARB_LOST_CAP_S 0 + +/* TWAI_ERR_CODE_CAP_REG register + * Error Code Capture Register + */ + +#define TWAI_ERR_CODE_CAP_REG (DR_REG_TWAI_BASE + 0x30) + +/* TWAI_ECC_TYPE : RO; bitpos: [7:6]; default: 0; + * This register contains information about error types: 00: bit error; 01: + * form error; 10: stuff error; 11: other type of error + */ + +#define TWAI_ECC_TYPE 0x00000003 +#define TWAI_ECC_TYPE_M (TWAI_ECC_TYPE_V << TWAI_ECC_TYPE_S) +#define TWAI_ECC_TYPE_V 0x00000003 +#define TWAI_ECC_TYPE_S 6 + +/* TWAI_ECC_DIRECTION : RO; bitpos: [5]; default: 0; + * This register contains information about transmission direction of the + * node when error occurs. 1: Error occurs when receiving a message; 0: + * Error occurs when transmitting a message + */ + +#define TWAI_ECC_DIRECTION (BIT(5)) +#define TWAI_ECC_DIRECTION_M (TWAI_ECC_DIRECTION_V << TWAI_ECC_DIRECTION_S) +#define TWAI_ECC_DIRECTION_V 0x00000001 +#define TWAI_ECC_DIRECTION_S 5 + +/* TWAI_ECC_SEGMENT : RO; bitpos: [4:0]; default: 0; + * This register contains information about the location of errors, see + * Table 181 for details. + */ + +#define TWAI_ECC_SEGMENT 0x0000001F +#define TWAI_ECC_SEGMENT_M (TWAI_ECC_SEGMENT_V << TWAI_ECC_SEGMENT_S) +#define TWAI_ECC_SEGMENT_V 0x0000001F +#define TWAI_ECC_SEGMENT_S 0 + +/* TWAI_ERR_WARNING_LIMIT_REG register + * Error Warning Limit Register + */ + +#define TWAI_ERR_WARNING_LIMIT_REG (DR_REG_TWAI_BASE + 0x34) + +/* TWAI_ERR_WARNING_LIMIT : RO | R/W; bitpos: [7:0]; default: 96; + * Error warning threshold. In the case when any of a error counter value + * exceeds the threshold, or all the error counter values are below the + * threshold, an error warning interrupt will be triggered (given the enable + * signal is valid). + */ + +#define TWAI_ERR_WARNING_LIMIT 0x000000FF +#define TWAI_ERR_WARNING_LIMIT_M (TWAI_ERR_WARNING_LIMIT_V << TWAI_ERR_WARNING_LIMIT_S) +#define TWAI_ERR_WARNING_LIMIT_V 0x000000FF +#define TWAI_ERR_WARNING_LIMIT_S 0 + +/* TWAI_RX_ERR_CNT_REG register + * Receive Error Counter Register + */ + +#define TWAI_RX_ERR_CNT_REG (DR_REG_TWAI_BASE + 0x38) + +/* TWAI_RX_ERR_CNT : RO | R/W; bitpos: [7:0]; default: 0; + * The RX error counter register, reflects value changes under reception + * status. + */ + +#define TWAI_RX_ERR_CNT 0x000000FF +#define TWAI_RX_ERR_CNT_M (TWAI_RX_ERR_CNT_V << TWAI_RX_ERR_CNT_S) +#define TWAI_RX_ERR_CNT_V 0x000000FF +#define TWAI_RX_ERR_CNT_S 0 + +/* TWAI_TX_ERR_CNT_REG register + * Transmit Error Counter Register + */ + +#define TWAI_TX_ERR_CNT_REG (DR_REG_TWAI_BASE + 0x3c) + +/* TWAI_TX_ERR_CNT : RO | R/W; bitpos: [7:0]; default: 0; + * The TX error counter register, reflects value changes under transmission + * status. + */ + +#define TWAI_TX_ERR_CNT 0x000000FF +#define TWAI_TX_ERR_CNT_M (TWAI_TX_ERR_CNT_V << TWAI_TX_ERR_CNT_S) +#define TWAI_TX_ERR_CNT_V 0x000000FF +#define TWAI_TX_ERR_CNT_S 0 + +/* TWAI_DATA_0_REG register + * Data register 0 + */ + +#define TWAI_DATA_0_REG (DR_REG_TWAI_BASE + 0x40) + +/* TWAI_TX_BYTE_0 : WO; bitpos: [7:0]; default: 0; + * Stored the 0th byte information of the data to be transmitted under + * operating mode. + */ + +#define TWAI_TX_BYTE_0 0x000000FF +#define TWAI_TX_BYTE_0_M (TWAI_TX_BYTE_0_V << TWAI_TX_BYTE_0_S) +#define TWAI_TX_BYTE_0_V 0x000000FF +#define TWAI_TX_BYTE_0_S 0 + +/* TWAI_ACCEPTANCE_CODE_0 : WO; bitpos: [7:0]; default: 0; + * Stored the 0th byte of the filter code in reset mode. + */ + +#define TWAI_ACCEPTANCE_CODE_0 0x000000FF +#define TWAI_ACCEPTANCE_CODE_0_M (TWAI_ACCEPTANCE_CODE_0_V << TWAI_ACCEPTANCE_CODE_0_S) +#define TWAI_ACCEPTANCE_CODE_0_V 0x000000FF +#define TWAI_ACCEPTANCE_CODE_0_S 0 + +/* TWAI_DATA_1_REG register + * Data register 1 + */ + +#define TWAI_DATA_1_REG (DR_REG_TWAI_BASE + 0x44) + +/* TWAI_TX_BYTE_1 : WO; bitpos: [7:0]; default: 0; + * Stored the 1st byte information of the data to be transmitted under + * operating mode. + */ + +#define TWAI_TX_BYTE_1 0x000000FF +#define TWAI_TX_BYTE_1_M (TWAI_TX_BYTE_1_V << TWAI_TX_BYTE_1_S) +#define TWAI_TX_BYTE_1_V 0x000000FF +#define TWAI_TX_BYTE_1_S 0 + +/* TWAI_ACCEPTANCE_CODE_1 : WO; bitpos: [7:0]; default: 0; + * Stored the 1st byte of the filter code in reset mode. + */ + +#define TWAI_ACCEPTANCE_CODE_1 0x000000FF +#define TWAI_ACCEPTANCE_CODE_1_M (TWAI_ACCEPTANCE_CODE_1_V << TWAI_ACCEPTANCE_CODE_1_S) +#define TWAI_ACCEPTANCE_CODE_1_V 0x000000FF +#define TWAI_ACCEPTANCE_CODE_1_S 0 + +/* TWAI_DATA_2_REG register + * Data register 2 + */ + +#define TWAI_DATA_2_REG (DR_REG_TWAI_BASE + 0x48) + +/* TWAI_TX_BYTE_2 : WO; bitpos: [7:0]; default: 0; + * Stored the 2nd byte information of the data to be transmitted under + * operating mode. + */ + +#define TWAI_TX_BYTE_2 0x000000FF +#define TWAI_TX_BYTE_2_M (TWAI_TX_BYTE_2_V << TWAI_TX_BYTE_2_S) +#define TWAI_TX_BYTE_2_V 0x000000FF +#define TWAI_TX_BYTE_2_S 0 + +/* TWAI_ACCEPTANCE_CODE_2 : WO; bitpos: [7:0]; default: 0; + * Stored the 2nd byte of the filter code in reset mode. + */ + +#define TWAI_ACCEPTANCE_CODE_2 0x000000FF +#define TWAI_ACCEPTANCE_CODE_2_M (TWAI_ACCEPTANCE_CODE_2_V << TWAI_ACCEPTANCE_CODE_2_S) +#define TWAI_ACCEPTANCE_CODE_2_V 0x000000FF +#define TWAI_ACCEPTANCE_CODE_2_S 0 + +/* TWAI_DATA_3_REG register + * Data register 3 + */ + +#define TWAI_DATA_3_REG (DR_REG_TWAI_BASE + 0x4c) + +/* TWAI_TX_BYTE_3 : WO; bitpos: [7:0]; default: 0; + * Stored the 3rd byte information of the data to be transmitted under + * operating mode. + */ + +#define TWAI_TX_BYTE_3 0x000000FF +#define TWAI_TX_BYTE_3_M (TWAI_TX_BYTE_3_V << TWAI_TX_BYTE_3_S) +#define TWAI_TX_BYTE_3_V 0x000000FF +#define TWAI_TX_BYTE_3_S 0 + +/* TWAI_ACCEPTANCE_CODE_3 : WO; bitpos: [7:0]; default: 0; + * Stored the 3rd byte of the filter code in reset mode. + */ + +#define TWAI_ACCEPTANCE_CODE_3 0x000000FF +#define TWAI_ACCEPTANCE_CODE_3_M (TWAI_ACCEPTANCE_CODE_3_V << TWAI_ACCEPTANCE_CODE_3_S) +#define TWAI_ACCEPTANCE_CODE_3_V 0x000000FF +#define TWAI_ACCEPTANCE_CODE_3_S 0 + +/* TWAI_DATA_4_REG register + * Data register 4 + */ + +#define TWAI_DATA_4_REG (DR_REG_TWAI_BASE + 0x50) + +/* TWAI_TX_BYTE_4 : WO; bitpos: [7:0]; default: 0; + * Stored the 4th byte information of the data to be transmitted under + * operating mode. + */ + +#define TWAI_TX_BYTE_4 0x000000FF +#define TWAI_TX_BYTE_4_M (TWAI_TX_BYTE_4_V << TWAI_TX_BYTE_4_S) +#define TWAI_TX_BYTE_4_V 0x000000FF +#define TWAI_TX_BYTE_4_S 0 + +/* TWAI_ACCEPTANCE_MASK_0 : WO; bitpos: [7:0]; default: 0; + * Stored the 0th byte of the filter code in reset mode. + */ + +#define TWAI_ACCEPTANCE_MASK_0 0x000000FF +#define TWAI_ACCEPTANCE_MASK_0_M (TWAI_ACCEPTANCE_MASK_0_V << TWAI_ACCEPTANCE_MASK_0_S) +#define TWAI_ACCEPTANCE_MASK_0_V 0x000000FF +#define TWAI_ACCEPTANCE_MASK_0_S 0 + +/* TWAI_DATA_5_REG register + * Data register 5 + */ + +#define TWAI_DATA_5_REG (DR_REG_TWAI_BASE + 0x54) + +/* TWAI_TX_BYTE_5 : WO; bitpos: [7:0]; default: 0; + * Stored the 5th byte information of the data to be transmitted under + * operating mode. + */ + +#define TWAI_TX_BYTE_5 0x000000FF +#define TWAI_TX_BYTE_5_M (TWAI_TX_BYTE_5_V << TWAI_TX_BYTE_5_S) +#define TWAI_TX_BYTE_5_V 0x000000FF +#define TWAI_TX_BYTE_5_S 0 + +/* TWAI_ACCEPTANCE_MASK_1 : WO; bitpos: [7:0]; default: 0; + * Stored the 1st byte of the filter code in reset mode. + */ + +#define TWAI_ACCEPTANCE_MASK_1 0x000000FF +#define TWAI_ACCEPTANCE_MASK_1_M (TWAI_ACCEPTANCE_MASK_1_V << TWAI_ACCEPTANCE_MASK_1_S) +#define TWAI_ACCEPTANCE_MASK_1_V 0x000000FF +#define TWAI_ACCEPTANCE_MASK_1_S 0 + +/* TWAI_DATA_6_REG register + * Data register 6 + */ + +#define TWAI_DATA_6_REG (DR_REG_TWAI_BASE + 0x58) + +/* TWAI_TX_BYTE_6 : WO; bitpos: [7:0]; default: 0; + * Stored the 6th byte information of the data to be transmitted under + * operating mode. + */ + +#define TWAI_TX_BYTE_6 0x000000FF +#define TWAI_TX_BYTE_6_M (TWAI_TX_BYTE_6_V << TWAI_TX_BYTE_6_S) +#define TWAI_TX_BYTE_6_V 0x000000FF +#define TWAI_TX_BYTE_6_S 0 + +/* TWAI_ACCEPTANCE_MASK_2 : WO; bitpos: [7:0]; default: 0; + * Stored the 2nd byte of the filter code in reset mode. + */ + +#define TWAI_ACCEPTANCE_MASK_2 0x000000FF +#define TWAI_ACCEPTANCE_MASK_2_M (TWAI_ACCEPTANCE_MASK_2_V << TWAI_ACCEPTANCE_MASK_2_S) +#define TWAI_ACCEPTANCE_MASK_2_V 0x000000FF +#define TWAI_ACCEPTANCE_MASK_2_S 0 + +/* TWAI_DATA_7_REG register + * Data register 7 + */ + +#define TWAI_DATA_7_REG (DR_REG_TWAI_BASE + 0x5c) + +/* TWAI_TX_BYTE_7 : WO; bitpos: [7:0]; default: 0; + * Stored the 7th byte information of the data to be transmitted under + * operating mode. + */ + +#define TWAI_TX_BYTE_7 0x000000FF +#define TWAI_TX_BYTE_7_M (TWAI_TX_BYTE_7_V << TWAI_TX_BYTE_7_S) +#define TWAI_TX_BYTE_7_V 0x000000FF +#define TWAI_TX_BYTE_7_S 0 + +/* TWAI_ACCEPTANCE_MASK_3 : WO; bitpos: [7:0]; default: 0; + * Stored the 3th byte of the filter code in reset mode. + */ + +#define TWAI_ACCEPTANCE_MASK_3 0x000000FF +#define TWAI_ACCEPTANCE_MASK_3_M (TWAI_ACCEPTANCE_MASK_3_V << TWAI_ACCEPTANCE_MASK_3_S) +#define TWAI_ACCEPTANCE_MASK_3_V 0x000000FF +#define TWAI_ACCEPTANCE_MASK_3_S 0 + +/* TWAI_DATA_8_REG register + * Data register 8 + */ + +#define TWAI_DATA_8_REG (DR_REG_TWAI_BASE + 0x60) + +/* TWAI_TX_BYTE_8 : WO; bitpos: [7:0]; default: 0; + * Stored the 8th byte information of the data to be transmitted under + * operating mode. + */ + +#define TWAI_TX_BYTE_8 0x000000FF +#define TWAI_TX_BYTE_8_M (TWAI_TX_BYTE_8_V << TWAI_TX_BYTE_8_S) +#define TWAI_TX_BYTE_8_V 0x000000FF +#define TWAI_TX_BYTE_8_S 0 + +/* TWAI_DATA_9_REG register + * Data register 9 + */ + +#define TWAI_DATA_9_REG (DR_REG_TWAI_BASE + 0x64) + +/* TWAI_TX_BYTE_9 : WO; bitpos: [7:0]; default: 0; + * Stored the 9th byte information of the data to be transmitted under + * operating mode. + */ + +#define TWAI_TX_BYTE_9 0x000000FF +#define TWAI_TX_BYTE_9_M (TWAI_TX_BYTE_9_V << TWAI_TX_BYTE_9_S) +#define TWAI_TX_BYTE_9_V 0x000000FF +#define TWAI_TX_BYTE_9_S 0 + +/* TWAI_DATA_10_REG register + * Data register 10 + */ + +#define TWAI_DATA_10_REG (DR_REG_TWAI_BASE + 0x68) + +/* TWAI_TX_BYTE_10 : WO; bitpos: [7:0]; default: 0; + * Stored the 10th byte information of the data to be transmitted under + * operating mode. + */ + +#define TWAI_TX_BYTE_10 0x000000FF +#define TWAI_TX_BYTE_10_M (TWAI_TX_BYTE_10_V << TWAI_TX_BYTE_10_S) +#define TWAI_TX_BYTE_10_V 0x000000FF +#define TWAI_TX_BYTE_10_S 0 + +/* TWAI_DATA_11_REG register + * Data register 11 + */ + +#define TWAI_DATA_11_REG (DR_REG_TWAI_BASE + 0x6c) + +/* TWAI_TX_BYTE_11 : WO; bitpos: [7:0]; default: 0; + * Stored the 11th byte information of the data to be transmitted under + * operating mode. + */ + +#define TWAI_TX_BYTE_11 0x000000FF +#define TWAI_TX_BYTE_11_M (TWAI_TX_BYTE_11_V << TWAI_TX_BYTE_11_S) +#define TWAI_TX_BYTE_11_V 0x000000FF +#define TWAI_TX_BYTE_11_S 0 + +/* TWAI_DATA_12_REG register + * Data register 12 + */ + +#define TWAI_DATA_12_REG (DR_REG_TWAI_BASE + 0x70) + +/* TWAI_TX_BYTE_12 : WO; bitpos: [7:0]; default: 0; + * Stored the 12th byte information of the data to be transmitted under + * operating mode. + */ + +#define TWAI_TX_BYTE_12 0x000000FF +#define TWAI_TX_BYTE_12_M (TWAI_TX_BYTE_12_V << TWAI_TX_BYTE_12_S) +#define TWAI_TX_BYTE_12_V 0x000000FF +#define TWAI_TX_BYTE_12_S 0 + +/* TWAI_RX_MESSAGE_CNT_REG register + * Receive Message Counter Register + */ + +#define TWAI_RX_MESSAGE_CNT_REG (DR_REG_TWAI_BASE + 0x74) + +/* TWAI_RX_MESSAGE_COUNTER : RO; bitpos: [6:0]; default: 0; + * This register reflects the number of messages available within the RX + * FIFO. + */ + +#define TWAI_RX_MESSAGE_COUNTER 0x0000007F +#define TWAI_RX_MESSAGE_COUNTER_M (TWAI_RX_MESSAGE_COUNTER_V << TWAI_RX_MESSAGE_COUNTER_S) +#define TWAI_RX_MESSAGE_COUNTER_V 0x0000007F +#define TWAI_RX_MESSAGE_COUNTER_S 0 + +/* TWAI_CLOCK_DIVIDER_REG register + * Clock Divider register + */ + +#define TWAI_CLOCK_DIVIDER_REG (DR_REG_TWAI_BASE + 0x7c) + +/* TWAI_CLOCK_OFF : RO | R/W; bitpos: [8]; default: 0; + * This bit can be configured under reset mode. 1: Disable the external + * CLKOUT pin; 0: Enable the external CLKOUT pin + */ + +#define TWAI_CLOCK_OFF (BIT(8)) +#define TWAI_CLOCK_OFF_M (TWAI_CLOCK_OFF_V << TWAI_CLOCK_OFF_S) +#define TWAI_CLOCK_OFF_V 0x00000001 +#define TWAI_CLOCK_OFF_S 8 + +/* TWAI_CD : R/W; bitpos: [7:0]; default: 0; + * These bits are used to configure frequency dividing coefficients of the + * external CLKOUT pin. + */ + +#define TWAI_CD 0x000000FF +#define TWAI_CD_M (TWAI_CD_V << TWAI_CD_S) +#define TWAI_CD_V 0x000000FF +#define TWAI_CD_S 0 + +#endif /* __ARCH_RISCV_SRC_ESP32C3_HARDWARE_ESP32C3_TWAI_H */ diff --git a/arch/risc-v/src/fe310/Make.defs b/arch/risc-v/src/fe310/Make.defs index 4e91ca053b277..0d865f393b54d 100644 --- a/arch/risc-v/src/fe310/Make.defs +++ b/arch/risc-v/src/fe310/Make.defs @@ -26,14 +26,15 @@ HEAD_ASRC = fe310_head.S CMN_ASRCS += riscv_vectors.S riscv_testset.S riscv_exception_common.S # Specify C code within the common directory to be included -CMN_CSRCS += riscv_initialize.c riscv_swint.c +CMN_CSRCS += riscv_initialize.c riscv_swint.c riscv_exception.c riscv_mtimer.c CMN_CSRCS += riscv_allocateheap.c riscv_createstack.c riscv_exit.c CMN_CSRCS += riscv_assert.c riscv_blocktask.c riscv_copystate.c riscv_initialstate.c CMN_CSRCS += riscv_interruptcontext.c riscv_modifyreg32.c riscv_puts.c riscv_mdelay.c CMN_CSRCS += riscv_releasepending.c riscv_reprioritizertr.c CMN_CSRCS += riscv_releasestack.c riscv_stackframe.c riscv_schedulesigaction.c CMN_CSRCS += riscv_sigdeliver.c riscv_udelay.c riscv_unblocktask.c riscv_usestack.c -CMN_CSRCS += riscv_idle.c riscv_tcbinfo.c riscv_getnewintctx.c +CMN_CSRCS += riscv_idle.c riscv_tcbinfo.c riscv_getnewintctx.c riscv_doirq.c +CMN_CSRCS += riscv_saveusercontext.c ifeq ($(CONFIG_SCHED_BACKTRACE),y) CMN_CSRCS += riscv_backtrace.c @@ -44,6 +45,7 @@ CMN_CSRCS += riscv_checkstack.c endif ifeq ($(CONFIG_ARCH_HAVE_VFORK),y) +CMN_ASRCS += vfork.S CMN_CSRCS += riscv_vfork.c endif diff --git a/arch/risc-v/src/fe310/fe310_irq.c b/arch/risc-v/src/fe310/fe310_irq.c index 1a44ccf4bb508..62e2406812de6 100644 --- a/arch/risc-v/src/fe310/fe310_irq.c +++ b/arch/risc-v/src/fe310/fe310_irq.c @@ -31,9 +31,8 @@ #include #include -#include +#include #include -#include #include "riscv_internal.h" #include "fe310.h" @@ -87,9 +86,9 @@ void up_irqinitialize(void) CURRENT_REGS = NULL; - /* Attach the ecall interrupt handler */ + /* Attach the common interrupt handler */ - irq_attach(RISCV_IRQ_ECALLM, riscv_swint, NULL); + riscv_exception_attach(); #ifndef CONFIG_SUPPRESS_INTERRUPTS diff --git a/arch/risc-v/src/fe310/fe310_irq_dispatch.c b/arch/risc-v/src/fe310/fe310_irq_dispatch.c index 898f1c3157a71..4ec3c8dead779 100644 --- a/arch/risc-v/src/fe310/fe310_irq_dispatch.c +++ b/arch/risc-v/src/fe310/fe310_irq_dispatch.c @@ -29,8 +29,6 @@ #include #include -#include -#include #include "riscv_internal.h" #include "fe310_gpio.h" @@ -53,7 +51,6 @@ void *riscv_dispatch_irq(uintptr_t vector, uintptr_t *regs) { int irq = (vector >> RV_IRQ_MASK) | (vector & 0xf); - uintptr_t *mepc = regs; /* Firstly, check if the irq is machine external interrupt */ @@ -66,32 +63,13 @@ void *riscv_dispatch_irq(uintptr_t vector, uintptr_t *regs) irq += val; } - /* NOTE: In case of ecall, we need to adjust mepc in the context */ - - if (RISCV_IRQ_ECALLM == irq) - { - *mepc += 4; - } - /* Acknowledge the interrupt */ riscv_ack_irq(irq); -#ifdef CONFIG_SUPPRESS_INTERRUPTS - PANIC(); -#else - /* Current regs non-zero indicates that we are processing an interrupt; - * CURRENT_REGS is also used to manage interrupt level context switches. - * - * Nested interrupts are not supported - */ - - DEBUGASSERT(CURRENT_REGS == NULL); - CURRENT_REGS = regs; - /* Deliver the IRQ */ - irq_dispatch(irq, regs); + regs = riscv_doirq(irq, regs); if (RISCV_IRQ_MEXT <= irq) { @@ -106,16 +84,6 @@ void *riscv_dispatch_irq(uintptr_t vector, uintptr_t *regs) putreg32(irq - RISCV_IRQ_MEXT, FE310_PLIC_CLAIM); } -#endif - - /* If a context switch occurred while processing the interrupt then - * CURRENT_REGS may have change value. If we return any value different - * from the input regs, then the lower level will know that a context - * switch occurred during interrupt processing. - */ - - regs = (uintptr_t *)CURRENT_REGS; - CURRENT_REGS = NULL; return regs; } diff --git a/arch/risc-v/src/fe310/fe310_timerisr.c b/arch/risc-v/src/fe310/fe310_timerisr.c index 5d198fc7aee06..142d9628d6b66 100644 --- a/arch/risc-v/src/fe310/fe310_timerisr.c +++ b/arch/risc-v/src/fe310/fe310_timerisr.c @@ -24,6 +24,7 @@ #include +#include #include #include #include @@ -31,9 +32,12 @@ #include #include #include +#include #include +#include "hardware/fe310_clint.h" #include "riscv_internal.h" +#include "riscv_mtimer.h" #include "fe310.h" /**************************************************************************** @@ -44,62 +48,11 @@ #define putreg64(v,a) (*(volatile uint64_t *)(a) = (v)) #ifdef CONFIG_ARCH_CHIP_FE310_QEMU -#define TICK_COUNT (10000000 / TICK_PER_SEC) +#define MTIMER_FREQ 10000000 #else -#define TICK_COUNT (32768 / TICK_PER_SEC) +#define MTIMER_FREQ 32768 #endif -/**************************************************************************** - * Private Data - ****************************************************************************/ - -static bool _b_tick_started = false; - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: fe310_reload_mtimecmp - ****************************************************************************/ - -static void fe310_reload_mtimecmp(void) -{ - irqstate_t flags = spin_lock_irqsave(NULL); - - uint64_t current; - uint64_t next; - - if (!_b_tick_started) - { - _b_tick_started = true; - current = getreg64(FE310_CLINT_MTIME); - } - else - { - current = getreg64(FE310_CLINT_MTIMECMP); - } - - next = current + TICK_COUNT; - putreg64(next, FE310_CLINT_MTIMECMP); - - spin_unlock_irqrestore(NULL, flags); -} - -/**************************************************************************** - * Name: fe310_timerisr - ****************************************************************************/ - -static int fe310_timerisr(int irq, void *context, void *arg) -{ - fe310_reload_mtimecmp(); - - /* Process timer interrupt */ - - nxsched_process_timer(); - return 0; -} - /**************************************************************************** * Public Functions ****************************************************************************/ @@ -115,15 +68,11 @@ static int fe310_timerisr(int irq, void *context, void *arg) void up_timer_initialize(void) { - /* Attach timer interrupt handler */ - - irq_attach(RISCV_IRQ_MTIMER, fe310_timerisr, NULL); - - /* Reload CLINT mtimecmp */ - - fe310_reload_mtimecmp(); + struct oneshot_lowerhalf_s *lower = riscv_mtimer_initialize( + FE310_CLINT_MTIME, FE310_CLINT_MTIMECMP, + RISCV_IRQ_MTIMER, MTIMER_FREQ); - /* And enable the timer interrupt */ + DEBUGASSERT(lower); - up_enable_irq(RISCV_IRQ_MTIMER); + up_alarm_set_lowerhalf(lower); } diff --git a/arch/risc-v/src/k210/Make.defs b/arch/risc-v/src/k210/Make.defs index 7f22688893f51..8912c37960c97 100644 --- a/arch/risc-v/src/k210/Make.defs +++ b/arch/risc-v/src/k210/Make.defs @@ -26,18 +26,20 @@ HEAD_ASRC = k210_head.S CMN_ASRCS += riscv_vectors.S riscv_testset.S riscv_exception_common.S # Specify C code within the common directory to be included -CMN_CSRCS += riscv_initialize.c riscv_swint.c -CMN_CSRCS += riscv_createstack.c riscv_exit.c riscv_fault.c +CMN_CSRCS += riscv_initialize.c riscv_swint.c riscv_mtimer.c +CMN_CSRCS += riscv_createstack.c riscv_exit.c riscv_exception.c CMN_CSRCS += riscv_assert.c riscv_blocktask.c riscv_copystate.c riscv_initialstate.c CMN_CSRCS += riscv_interruptcontext.c riscv_modifyreg32.c riscv_puts.c CMN_CSRCS += riscv_releasepending.c riscv_reprioritizertr.c CMN_CSRCS += riscv_releasestack.c riscv_stackframe.c riscv_schedulesigaction.c CMN_CSRCS += riscv_sigdeliver.c riscv_unblocktask.c riscv_usestack.c -CMN_CSRCS += riscv_mdelay.c riscv_idle.c +CMN_CSRCS += riscv_mdelay.c riscv_idle.c riscv_doirq.c CMN_CSRCS += riscv_tcbinfo.c riscv_cpuidlestack.c riscv_getnewintctx.c +CMN_CSRCS += riscv_misaligned.c riscv_saveusercontext.c ifeq ($(CONFIG_SMP), y) CMN_CSRCS += riscv_cpuindex.c riscv_cpupause.c riscv_cpustart.c +CMN_ASRCS += riscv_mhartid.S endif ifeq ($(CONFIG_SCHED_BACKTRACE),y) @@ -49,9 +51,15 @@ CMN_CSRCS += riscv_checkstack.c endif ifeq ($(CONFIG_ARCH_HAVE_VFORK),y) +CMN_ASRCS += vfork.S CMN_CSRCS += riscv_vfork.c endif +ifeq ($(CONFIG_ARCH_FPU),y) +CMN_ASRCS += riscv_fpu.S +CMN_CSRCS += riscv_fpucmp.c +endif + # Specify our C code within this directory to be included CHIP_CSRCS = k210_allocateheap.c k210_clockconfig.c CHIP_CSRCS += k210_irq.c k210_irq_dispatch.c diff --git a/arch/risc-v/src/k210/chip.h b/arch/risc-v/src/k210/chip.h index 69a7db77ab603..9592bb54ce619 100644 --- a/arch/risc-v/src/k210/chip.h +++ b/arch/risc-v/src/k210/chip.h @@ -29,4 +29,32 @@ #include "k210_memorymap.h" +#include "riscv_internal.h" + +/**************************************************************************** + * Macro Definitions + ****************************************************************************/ + +#ifdef __ASSEMBLY__ + +/**************************************************************************** + * Name: setintstack + * + * Description: + * Set the current stack pointer to the "top" the correct interrupt stack + * for the current CPU. + * + ****************************************************************************/ + +#if defined(CONFIG_SMP) && CONFIG_ARCH_INTERRUPTSTACK > 15 +.macro setintstack tmp0, tmp1 + csrr \tmp0, mhartid + li \tmp1, STACK_ALIGN_DOWN(CONFIG_ARCH_INTERRUPTSTACK) + mul \tmp1, \tmp0, \tmp1 + la \tmp0, g_intstacktop + sub sp, \tmp0, \tmp1 +.endm +#endif /* CONFIG_SMP && CONFIG_ARCH_INTERRUPTSTACK > 15 */ + +#endif /* __ASSEMBLY__ */ #endif /* __ARCH_RISCV_SRC_K210_CHIP_H */ diff --git a/arch/risc-v/src/k210/k210_irq.c b/arch/risc-v/src/k210/k210_irq.c index b01ee914fdd76..d09b304ce7504 100644 --- a/arch/risc-v/src/k210/k210_irq.c +++ b/arch/risc-v/src/k210/k210_irq.c @@ -30,8 +30,7 @@ #include #include -#include -#include +#include #include "riscv_internal.h" #include "k210.h" @@ -91,22 +90,15 @@ void up_irqinitialize(void) CURRENT_REGS = NULL; - /* Attach the ecall interrupt handler */ + /* Attach the common interrupt handler */ - irq_attach(RISCV_IRQ_ECALLM, riscv_swint, NULL); - -#ifdef CONFIG_BUILD_PROTECTED - irq_attach(RISCV_IRQ_ECALLU, riscv_swint, NULL); -#endif + riscv_exception_attach(); #ifdef CONFIG_SMP /* Clear MSOFT for CPU0 */ putreg32(0, K210_CLINT_MSIP); - /* Setup MSOFT for CPU0 with pause handler */ - - irq_attach(RISCV_IRQ_MSOFT, riscv_pause_handler, NULL); up_enable_irq(RISCV_IRQ_MSOFT); #endif diff --git a/arch/risc-v/src/k210/k210_irq_dispatch.c b/arch/risc-v/src/k210/k210_irq_dispatch.c index 7879891b6b619..e2ccbdd92bc11 100644 --- a/arch/risc-v/src/k210/k210_irq_dispatch.c +++ b/arch/risc-v/src/k210/k210_irq_dispatch.c @@ -29,12 +29,13 @@ #include #include -#include -#include +#include #include "riscv_internal.h" #include "group/group.h" +#include "k210_memorymap.h" + /**************************************************************************** * Pre-processor Definitions ****************************************************************************/ @@ -52,14 +53,6 @@ void *riscv_dispatch_irq(uintptr_t vector, uintptr_t *regs) { int irq = (vector >> RV_IRQ_MASK) | (vector & 0xf); - uintptr_t *mepc = regs; - - /* Check if fault happened */ - - if (vector < RISCV_IRQ_ECALLU) - { - riscv_fault(irq, regs); - } /* Firstly, check if the irq is machine external interrupt */ @@ -72,36 +65,17 @@ void *riscv_dispatch_irq(uintptr_t vector, uintptr_t *regs) irq += val; } - /* NOTE: In case of ecall, we need to adjust mepc in the context */ - - if (RISCV_IRQ_ECALLM == irq || RISCV_IRQ_ECALLU == irq) - { - *mepc += 4; - } - /* Acknowledge the interrupt */ riscv_ack_irq(irq); -#ifdef CONFIG_SUPPRESS_INTERRUPTS - PANIC(); -#else - /* Current regs non-zero indicates that we are processing an interrupt; - * CURRENT_REGS is also used to manage interrupt level context switches. - * - * Nested interrupts are not supported - */ - - ASSERT(CURRENT_REGS == NULL); - CURRENT_REGS = regs; - /* MEXT means no interrupt */ if (RISCV_IRQ_MEXT != irq) { /* Deliver the IRQ */ - irq_dispatch(irq, regs); + regs = riscv_doirq(irq, regs); } if (RISCV_IRQ_MEXT <= irq) @@ -110,16 +84,6 @@ void *riscv_dispatch_irq(uintptr_t vector, uintptr_t *regs) putreg32(irq - RISCV_IRQ_MEXT, K210_PLIC_CLAIM); } -#endif - - /* If a context switch occurred while processing the interrupt then - * CURRENT_REGS may have change value. If we return any value different - * from the input regs, then the lower level will know that a context - * switch occurred during interrupt processing. - */ - - regs = (uintptr_t *)CURRENT_REGS; - CURRENT_REGS = NULL; return regs; } diff --git a/arch/risc-v/src/k210/k210_start.c b/arch/risc-v/src/k210/k210_start.c index 4f4093fd7b004..b373ab5969f06 100644 --- a/arch/risc-v/src/k210/k210_start.c +++ b/arch/risc-v/src/k210/k210_start.c @@ -67,6 +67,10 @@ void __k210_start(uint32_t mhartid) const uint32_t *src; uint32_t *dest; + /* Configure FPU */ + + riscv_fpuconfig(); + if (0 < mhartid) { goto cpu1; diff --git a/arch/risc-v/src/k210/k210_timerisr.c b/arch/risc-v/src/k210/k210_timerisr.c index a5577c53b3b9d..661873de54d4d 100644 --- a/arch/risc-v/src/k210/k210_timerisr.c +++ b/arch/risc-v/src/k210/k210_timerisr.c @@ -24,15 +24,19 @@ #include +#include #include #include #include #include #include +#include #include +#include "hardware/k210_clint.h" #include "riscv_internal.h" +#include "riscv_mtimer.h" #include "k210.h" #include "k210_clockconfig.h" @@ -40,68 +44,12 @@ * Pre-processor Definitions ****************************************************************************/ -#define getreg64(a) (*(volatile uint64_t *)(a)) -#define putreg64(v,a) (*(volatile uint64_t *)(a) = (v)) - #ifdef CONFIG_K210_WITH_QEMU -#define TICK_COUNT (10000000 / TICK_PER_SEC) +#define MTIMER_FREQ 10000000 #else -#define TICK_COUNT ((k210_get_cpuclk() / 50) / TICK_PER_SEC) +#define MTIMER_FREQ (k210_get_cpuclk() / 50) #endif -/**************************************************************************** - * Private Data - ****************************************************************************/ - -static bool _b_tick_started = false; - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: k210_reload_mtimecmp - ****************************************************************************/ - -static void k210_reload_mtimecmp(void) -{ - irqstate_t flags = spin_lock_irqsave(NULL); - - uint64_t current; - uint64_t next; - - if (!_b_tick_started) - { - _b_tick_started = true; - current = getreg64(K210_CLINT_MTIME); - } - else - { - current = getreg64(K210_CLINT_MTIMECMP); - } - - uint64_t tick = TICK_COUNT; - next = current + tick; - - putreg64(next, K210_CLINT_MTIMECMP); - - spin_unlock_irqrestore(NULL, flags); -} - -/**************************************************************************** - * Name: k210_timerisr - ****************************************************************************/ - -static int k210_timerisr(int irq, void *context, void *arg) -{ - k210_reload_mtimecmp(); - - /* Process timer interrupt */ - - nxsched_process_timer(); - return 0; -} - /**************************************************************************** * Public Functions ****************************************************************************/ @@ -117,17 +65,11 @@ static int k210_timerisr(int irq, void *context, void *arg) void up_timer_initialize(void) { -#if 1 - /* Attach timer interrupt handler */ - - irq_attach(RISCV_IRQ_MTIMER, k210_timerisr, NULL); + struct oneshot_lowerhalf_s *lower = riscv_mtimer_initialize( + K210_CLINT_MTIME, K210_CLINT_MTIMECMP, + RISCV_IRQ_MTIMER, MTIMER_FREQ); - /* Reload CLINT mtimecmp */ + DEBUGASSERT(lower); - k210_reload_mtimecmp(); - - /* And enable the timer interrupt */ - - up_enable_irq(RISCV_IRQ_MTIMER); -#endif + up_alarm_set_lowerhalf(lower); } diff --git a/arch/risc-v/src/litex/Kconfig b/arch/risc-v/src/litex/Kconfig index 674e74928ee70..45f5bf3d365ab 100644 --- a/arch/risc-v/src/litex/Kconfig +++ b/arch/risc-v/src/litex/Kconfig @@ -25,4 +25,42 @@ config LITEX_UART0 select ARCH_HAVE_SERIAL_TERMIOS select LITEX_UART +config LITEX_SDIO + bool "SDIO" + default n + select SCHED_WORKQUEUE + select SCHED_HPWORK + select MMCSD + select MMCSD_SDIO + select SDIO_BLOCKSETUP + select ARCH_HAVE_SDIO + select SDIO_DMA + +config LITEX_SDIO1 + bool "Enable SDIO1" + default y if LITEX_SDIO + select LITEX_SDIO_DMA + depends on LITEX_SDIO + +if LITEX_SDIO1 + +config LITEX_IDMODE_FREQ + int "ID mode frequency" + default 400000 + ---help--- + Initial, ID mode SD frequency + +config LITEX_MMCXFR_FREQ + int "MMC transfer frequency" + default 25000000 + ---help--- + Frequency to use for transferring data to/from an MMC card + +config LITEX_SD4BIT_FREQ + int "SD 4-bit transfer frequency" + default 50000000 + ---help--- + Frequency to use for transferring data to/from an SD card using all four data lines. + +endif endmenu diff --git a/arch/risc-v/src/litex/Make.defs b/arch/risc-v/src/litex/Make.defs index 13754a65bcc31..f4230c03b1dac 100644 --- a/arch/risc-v/src/litex/Make.defs +++ b/arch/risc-v/src/litex/Make.defs @@ -26,7 +26,7 @@ HEAD_ASRC = litex_head.S CMN_ASRCS += riscv_vectors.S riscv_testset.S riscv_exception_common.S # Specify C code within the common directory to be included -CMN_CSRCS += riscv_initialize.c riscv_swint.c +CMN_CSRCS += riscv_initialize.c riscv_swint.c riscv_doirq.c riscv_exception.c CMN_CSRCS += riscv_allocateheap.c riscv_createstack.c riscv_exit.c CMN_CSRCS += riscv_assert.c riscv_blocktask.c riscv_copystate.c riscv_initialstate.c CMN_CSRCS += riscv_interruptcontext.c riscv_modifyreg32.c riscv_puts.c riscv_mdelay.c @@ -34,6 +34,7 @@ CMN_CSRCS += riscv_releasepending.c riscv_reprioritizertr.c CMN_CSRCS += riscv_releasestack.c riscv_stackframe.c riscv_schedulesigaction.c CMN_CSRCS += riscv_sigdeliver.c riscv_udelay.c riscv_unblocktask.c riscv_usestack.c CMN_CSRCS += riscv_idle.c riscv_tcbinfo.c riscv_getnewintctx.c +CMN_CSRCS += riscv_saveusercontext.c ifeq ($(CONFIG_SCHED_BACKTRACE),y) CMN_CSRCS += riscv_backtrace.c @@ -44,6 +45,7 @@ CMN_CSRCS += riscv_checkstack.c endif ifeq ($(CONFIG_ARCH_HAVE_VFORK),y) +CMN_ASRCS += vfork.S CMN_CSRCS += riscv_vfork.c endif @@ -52,3 +54,8 @@ CHIP_CSRCS = litex_allocateheap.c litex_clockconfig.c CHIP_CSRCS += litex_irq.c litex_irq_dispatch.c CHIP_CSRCS += litex_lowputc.c litex_serial.c CHIP_CSRCS += litex_start.c litex_timerisr.c +CHIP_ASRCS += litex_cache.S + +ifeq ($(CONFIG_LITEX_SDIO),y) +CHIP_CSRCS += litex_sdio.c +endif diff --git a/arch/risc-v/src/litex/hardware/litex_memorymap.h b/arch/risc-v/src/litex/hardware/litex_memorymap.h index 042047452958b..0587fa429ed11 100644 --- a/arch/risc-v/src/litex/hardware/litex_memorymap.h +++ b/arch/risc-v/src/litex/hardware/litex_memorymap.h @@ -31,8 +31,13 @@ * uses two additional CSRs: mask and pending. */ -#define LITEX_CPUTIMER_BASE 0xf0000800 /* riscv clint timer */ -#define LITEX_TIMER0_BASE 0xf0002800 -#define LITEX_UART0_BASE 0xf0002000 /* 0xf0002000 - : UART0 */ +#define LITEX_CPUTIMER_BASE 0xf0000800 +#define LITEX_SDBLOCK2MEM_BASE 0xf0002000 +#define LITEX_SDCORE_BASE 0xf0002800 +#define LITEX_SDIRQ_BASE 0xf0003000 +#define LITEX_SDMEM2BLOCK_BASE 0xf0003800 +#define LITEX_SDPHY_BASE 0xf0004000 +#define LITEX_TIMER0_BASE 0xf0005000 +#define LITEX_UART0_BASE 0xf0005800 #endif /* __ARCH_RISCV_SRC_LITEX_HARDWARE_LITEX_MEMORYMAP_H */ diff --git a/arch/risc-v/src/litex/hardware/litex_sdio.h b/arch/risc-v/src/litex/hardware/litex_sdio.h new file mode 100644 index 0000000000000..bdd8ef1e2704a --- /dev/null +++ b/arch/risc-v/src/litex/hardware/litex_sdio.h @@ -0,0 +1,104 @@ +/**************************************************************************** + * arch/risc-v/src/litex/hardware/litex_sdio.h + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +#ifndef __ARCH_RISCV_SRC_LITEX_HARDWARE_LITEX_SDIO_H +#define __ARCH_RISCV_SRC_LITEX_HARDWARE_LITEX_SDIO_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include "hardware/litex_memorymap.h" + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/* LITEX_SDIO register offsets **********************************************/ + +#define LITEX_SDBLOCK2MEM_DMA_BASE_OFFSET 0x0000 +#define LITEX_SDBLOCK2MEM_DMA_LENGTH_OFFSET 0x0008 +#define LITEX_SDBLOCK2MEM_DMA_ENABLE_OFFSET 0x000C +#define LITEX_SDBLOCK2MEM_DMA_DONE_OFFSET 0x0010 +#define LITEX_SDBLOCK2MEM_DMA_LOOP_OFFSET 0x0014 +#define LITEX_SDBLOCK2MEM_DMA_OFFSET_OFFSET 0x0018 + +#define LITEX_SDCORE_CMD_ARGUMENT_OFFSET 0x0000 +#define LITEX_SDCORE_CMD_COMMAND_OFFSET 0x0004 +#define LITEX_SDCORE_CMD_SEND_OFFSET 0x0008 +#define LITEX_SDCORE_CMD_RESPONSE_OFFSET 0x000C +#define LITEX_SDCORE_CMD_EVENT_OFFSET 0x001C +#define LITEX_SDCORE_DATA_EVENT_OFFSET 0x0020 +#define LITEX_SDCORE_BLOCK_LENGTH_OFFSET 0x0024 +#define LITEX_SDCORE_BLOCK_COUNT_OFFSET 0x0028 + +#define LITEX_SDIRQ_STATUS_OFFSET 0x0000 +#define LITEX_SDIRQ_PENDING_OFFSET 0x0004 +#define LITEX_SDIRQ_ENABLE_OFFSET 0x0008 + +#define LITEX_SDMEM2BLOCK_DMA_BASE_OFFSET 0x0000 +#define LITEX_SDMEM2BLOCK_DMA_LENGTH_OFFSET 0x0008 +#define LITEX_SDMEM2BLOCK_DMA_ENABLE_OFFSET 0x000C +#define LITEX_SDMEM2BLOCK_DMA_DONE_OFFSET 0x0010 +#define LITEX_SDMEM2BLOCK_DMA_LOOP_OFFSET 0x0014 +#define LITEX_SDMEM2BLOCK_DMA_OFFSET_OFFSET 0x0018 + +#define LITEX_SDPHY_CARD_DETECT_OFFSET 0x0000 +#define LITEX_SDPHY_CLOCKER_DIVIDER_OFFSET 0x0004 +#define LITEX_SDPHY_INIT_INITIALIZE_OFFSET 0x0008 +#define LITEX_SDPHY_DATAW_STATUS_OFFSET 0x000C + +/* LITEX_SDIO register addresses ********************************************/ + +#define LITEX_SDBLOCK2MEM_DMA_BASE (LITEX_SDBLOCK2MEM_BASE+LITEX_SDBLOCK2MEM_DMA_BASE_OFFSET) +#define LITEX_SDBLOCK2MEM_DMA_LENGTH (LITEX_SDBLOCK2MEM_BASE+LITEX_SDBLOCK2MEM_DMA_LENGTH_OFFSET) +#define LITEX_SDBLOCK2MEM_DMA_ENABLE (LITEX_SDBLOCK2MEM_BASE+LITEX_SDBLOCK2MEM_DMA_ENABLE_OFFSET) +#define LITEX_SDBLOCK2MEM_DMA_DONE (LITEX_SDBLOCK2MEM_BASE+LITEX_SDBLOCK2MEM_DMA_DONE_OFFSET) +#define LITEX_SDBLOCK2MEM_DMA_LOOP (LITEX_SDBLOCK2MEM_BASE+LITEX_SDBLOCK2MEM_DMA_LOOP_OFFSET) +#define LITEX_SDBLOCK2MEM_DMA_OFFSET (LITEX_SDBLOCK2MEM_BASE+LITEX_SDBLOCK2MEM_DMA_OFFSET_OFFSET) + +#define LITEX_SDCORE_CMD_ARGUMENT (LITEX_SDCORE_BASE+LITEX_SDCORE_CMD_ARGUMENT_OFFSET) +#define LITEX_SDCORE_CMD_COMMAND (LITEX_SDCORE_BASE+LITEX_SDCORE_CMD_COMMAND_OFFSET) +#define LITEX_SDCORE_CMD_SEND (LITEX_SDCORE_BASE+LITEX_SDCORE_CMD_SEND_OFFSET) +#define LITEX_SDCORE_CMD_RESPONSE (LITEX_SDCORE_BASE+LITEX_SDCORE_CMD_RESPONSE_OFFSET) +#define LITEX_SDCORE_CMD_EVENT (LITEX_SDCORE_BASE+LITEX_SDCORE_CMD_EVENT_OFFSET) +#define LITEX_SDCORE_DATA_EVENT (LITEX_SDCORE_BASE+LITEX_SDCORE_DATA_EVENT_OFFSET) +#define LITEX_SDCORE_BLOCK_LENGTH (LITEX_SDCORE_BASE+LITEX_SDCORE_BLOCK_LENGTH_OFFSET) +#define LITEX_SDCORE_BLOCK_COUNT (LITEX_SDCORE_BASE+LITEX_SDCORE_BLOCK_COUNT_OFFSET) + +#define LITEX_SDIRQ_STATUS (LITEX_SDIRQ_BASE+LITEX_SDIRQ_STATUS_OFFSET) +#define LITEX_SDIRQ_PENDING (LITEX_SDIRQ_BASE+LITEX_SDIRQ_PENDING_OFFSET) +#define LITEX_SDIRQ_ENABLE (LITEX_SDIRQ_BASE+LITEX_SDIRQ_ENABLE_OFFSET) + +#define LITEX_SDMEM2BLOCK_DMA_BASE (LITEX_SDMEM2BLOCK_BASE+LITEX_SDMEM2BLOCK_DMA_BASE_OFFSET) +#define LITEX_SDMEM2BLOCK_DMA_LENGTH (LITEX_SDMEM2BLOCK_BASE+LITEX_SDMEM2BLOCK_DMA_LENGTH_OFFSET) +#define LITEX_SDMEM2BLOCK_DMA_ENABLE (LITEX_SDMEM2BLOCK_BASE+LITEX_SDMEM2BLOCK_DMA_ENABLE_OFFSET) +#define LITEX_SDMEM2BLOCK_DMA_DONE (LITEX_SDMEM2BLOCK_BASE+LITEX_SDMEM2BLOCK_DMA_DONE_OFFSET) +#define LITEX_SDMEM2BLOCK_DMA_LOOP (LITEX_SDMEM2BLOCK_BASE+LITEX_SDMEM2BLOCK_DMA_LOOP_OFFSET) +#define LITEX_SDMEM2BLOCK_DMA_OFFSET (LITEX_SDMEM2BLOCK_BASE+LITEX_SDMEM2BLOCK_DMA_OFFSET_OFFSET) + +#define LITEX_SDPHY_CARD_DETECT (LITEX_SDPHY_BASE+LITEX_SDPHY_CARD_DETECT_OFFSET) +#define LITEX_SDPHY_CLOCKER_DIVIDER (LITEX_SDPHY_BASE+LITEX_SDPHY_CLOCKER_DIVIDER_OFFSET) +#define LITEX_SDPHY_INIT_INITIALIZER (LITEX_SDPHY_BASE+LITEX_SDPHY_INIT_INITIALIZE_OFFSET) +#define LITEX_SDPHY_DATAW_STATUS (LITEX_SDPHY_BASE+LITEX_SDPHY_DATAW_STATUS_OFFSET) + +/* LITEX_SDIO register bit definitions **************************************/ + +#endif /* __ARCH_RISCV_SRC_LITEX_HARDWARE_LITEX_SDIO_H */ diff --git a/arch/risc-v/src/litex/litex_cache.S b/arch/risc-v/src/litex/litex_cache.S new file mode 100644 index 0000000000000..33acb5043013a --- /dev/null +++ b/arch/risc-v/src/litex/litex_cache.S @@ -0,0 +1,82 @@ +/**************************************************************************** + * arch/risc-v/src/litex/litex_cache.S + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + + .file "litex_cache.S" + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +/**************************************************************************** + * Cache Operations + ****************************************************************************/ + + .text + +/**************************************************************************** + * Name: up_invalidate_dcache_all + * + * Description: + * Invalidate the entire contents of D cache. + * + * Input Parameters: + * None + * + * Returned Value: + * None + * + ****************************************************************************/ + +#ifdef CONFIG_ARCH_DCACHE + .globl up_invalidate_dcache_all + .type up_invalidate_dcache_all, function + +up_invalidate_dcache_all: + .word 0x500F +#endif + +/**************************************************************************** + * Name: up_invalidate_icache_all + * + * Description: + * Invalidate the entire contents of I cache. + * + * Input Parameters: + * None + * + * Returned Value: + * None + * + ****************************************************************************/ + +#ifdef CONFIG_ARCH_ICACHE + .globl up_invalidate_icache_all + .type up_invalidate_icache_all, function + +up_invalidate_dcaup_invalidate_icache_allhe_all: + .word 0x100F + nop + nop + nop + nop + nop +#endif diff --git a/arch/risc-v/src/litex/litex_irq.c b/arch/risc-v/src/litex/litex_irq.c index 7f8978f0bd7ba..c4c1b2968aaa1 100644 --- a/arch/risc-v/src/litex/litex_irq.c +++ b/arch/risc-v/src/litex/litex_irq.c @@ -30,10 +30,7 @@ #include #include -#include -#include -#include -#include +#include #include "riscv_internal.h" #include "litex.h" @@ -75,9 +72,9 @@ void up_irqinitialize(void) CURRENT_REGS = NULL; - /* Attach the ecall interrupt handler */ + /* Attach the common interrupt handler */ - irq_attach(RISCV_IRQ_ECALLM, riscv_swint, NULL); + riscv_exception_attach(); #ifndef CONFIG_SUPPRESS_INTERRUPTS diff --git a/arch/risc-v/src/litex/litex_irq_dispatch.c b/arch/risc-v/src/litex/litex_irq_dispatch.c index 309ade1f4c173..825a4f137a719 100644 --- a/arch/risc-v/src/litex/litex_irq_dispatch.c +++ b/arch/risc-v/src/litex/litex_irq_dispatch.c @@ -29,8 +29,6 @@ #include #include -#include -#include #include "riscv_internal.h" #include "litex.h" @@ -52,7 +50,6 @@ void *riscv_dispatch_irq(uintptr_t vector, uintptr_t *regs) { int irq = (vector >> RV_IRQ_MASK) | (vector & 0xf); - uintptr_t *mepc = regs; int i; /* Firstly, check if the irq is machine external interrupt */ @@ -82,43 +79,13 @@ void *riscv_dispatch_irq(uintptr_t vector, uintptr_t *regs) irq += val; } - /* NOTE: In case of ecall, we need to adjust mepc in the context */ - - if (RISCV_IRQ_ECALLM == irq) - { - *mepc += 4; - } - /* Acknowledge the interrupt */ riscv_ack_irq(irq); -#ifdef CONFIG_SUPPRESS_INTERRUPTS - PANIC(); -#else - /* Current regs non-zero indicates that we are processing an interrupt; - * CURRENT_REGS is also used to manage interrupt level context switches. - * - * Nested interrupts are not supported - */ - - DEBUGASSERT(CURRENT_REGS == NULL); - CURRENT_REGS = regs; - /* Deliver the IRQ */ - irq_dispatch(irq, regs); - -#endif - - /* If a context switch occurred while processing the interrupt then - * CURRENT_REGS may have change value. If we return any value different - * from the input regs, then the lower level will know that a context - * switch occurred during interrupt processing. - */ - - regs = (uintptr_t *)CURRENT_REGS; - CURRENT_REGS = NULL; + regs = riscv_doirq(irq, regs); return regs; } diff --git a/arch/risc-v/src/litex/litex_sdio.c b/arch/risc-v/src/litex/litex_sdio.c new file mode 100644 index 0000000000000..82e605de2ccbd --- /dev/null +++ b/arch/risc-v/src/litex/litex_sdio.c @@ -0,0 +1,1497 @@ +/**************************************************************************** + * arch/risc-v/src/litex/litex_sdio.c + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include "chip.h" +#include "riscv_internal.h" + +#include "litex_sdio.h" +#include "litex_clockconfig.h" +#include "hardware/litex_sdio.h" + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +#define SD_CTL_DATA_XFER_NONE 0 +#define SD_CTL_DATA_XFER_READ 1 +#define SD_CTL_DATA_XFER_WRITE 2 + +#define SDCARD_CTRL_RESPONSE_NONE 0 +#define SDCARD_CTRL_RESPONSE_SHORT 1 +#define SDCARD_CTRL_RESPONSE_LONG 2 + +#define LITEX_INT_CARDDETECT (1 << 0) +#define LITEX_INT_BLOCK2MEM (1 << 1) +#define LITEX_INT_MEM2BLOCK (1 << 2) +#define LITEX_INT_CMDDONE (1 << 3) + +#define LITEX_EV_CMDDONE (1 << 0) +#define LITEX_EV_WRERROR (1 << 1) +#define LITEX_EV_TIMEOUT (1 << 2) +#define LITEX_EV_CRCERROR (1 << 3) + +#define MAX_DIVIDER 256 + +#ifndef CONFIG_LITEX_IDMODE_FREQ +# define CONFIG_LITEX_IDMODE_FREQ 400000 /* 400 KHz, ID mode */ +#endif + +#ifndef CONFIG_LITEX_MMCXFR_FREQ +# define CONFIG_LITEX_MMCXFR_FREQ 25000000 /* 25MHz MMC, normal clocking */ +#endif + +#ifndef CONFIG_LITEX_SD4BIT_FREQ +# define CONFIG_LITEX_SD4BIT_FREQ 50000000 /* 25MHz SD 4-bit, normal clocking */ +#endif + +#define max(x, y) (((x) > (y)) ? (x) : (y)) +#define min(x, y) (((x) < (y)) ? (x) : (y)) + +/**************************************************************************** + * Private Types + ****************************************************************************/ + +struct litex_dev_s +{ + struct sdio_dev_s dev; /* Standard, base SDIO interface */ + + /* Event support */ + + sem_t waitsem; /* Implements event waiting */ + sdio_eventset_t waitevents; /* Set of events to be waited for */ + uint32_t waitints; /* Interrupt enables for event waiting */ + volatile sdio_eventset_t wkupevent; /* The event that caused the wakeup */ + struct wdog_s waitwdog; /* Watchdog that handles event timeouts */ + + /* Callback support */ + + sdio_statset_t cdstatus; /* Card status */ + sdio_eventset_t cbevents; /* Set of events to be cause callbacks */ + worker_t callback; /* Registered callback function */ + void *cbarg; /* Registered callback argument */ + struct work_s cbwork; /* Callback work queue structure */ + + /* Interrupt mode data transfer support */ + + uint32_t xfrints; /* Interrupt enables for data transfer */ + + /* Card interrupt support for SDIO */ + + uint32_t cintints; /* Interrupt enables for card ints */ + void (*do_sdio_card)(void *); /* SDIO card ISR */ + void *do_sdio_arg; /* arg for SDIO card ISR */ + + /* Fixed transfer block size support */ + + uint8_t block_size; +}; + +/**************************************************************************** + * Private Function Prototypes + ****************************************************************************/ + +static int litex_interrupt(int irq, void *context, void *arg); + +static void litex_reset(struct sdio_dev_s *dev); +static sdio_capset_t litex_capabilities(struct sdio_dev_s *dev); +static sdio_statset_t litex_status(struct sdio_dev_s *dev); +static void litex_widebus(struct sdio_dev_s *dev, + bool enable); +static void litex_clock(struct sdio_dev_s *dev, + enum sdio_clock_e rate); +static int litex_attach(struct sdio_dev_s *dev); +static int litex_sendcmd(struct sdio_dev_s *dev, + uint32_t cmd, uint32_t arg); +static void litex_blocksetup(struct sdio_dev_s *dev, + unsigned int blocklen, unsigned int nblocks); +static int litex_cancel(struct sdio_dev_s *dev); +static int litex_recvsetup(struct sdio_dev_s *dev, + uint8_t *buffer, size_t nbytes); +static int litex_sendsetup(struct sdio_dev_s *dev, + const uint8_t *buffer, size_t buflen); +static int litex_waitresponse(struct sdio_dev_s *dev, + uint32_t cmd); +static void litex_callbackenable(struct sdio_dev_s *dev, + sdio_eventset_t eventset); +static int litex_registercallback(struct sdio_dev_s *dev, + worker_t callback, void *arg); +static int litex_recvlong(struct sdio_dev_s *dev, + uint32_t cmd, uint32_t rlong[4]); +static int litex_recvshort(struct sdio_dev_s *dev, + uint32_t cmd, uint32_t *rshort); +static void litex_waitenable(struct sdio_dev_s *dev, + sdio_eventset_t eventset, uint32_t timeout); +static sdio_eventset_t litex_eventwait(struct sdio_dev_s *dev); +static void litex_configwaitints(struct litex_dev_s *priv, uint32_t waitmask, + sdio_eventset_t waitevents, sdio_eventset_t wkupevents); +static void litex_configxfrints(struct litex_dev_s *priv, + uint32_t xfrints); + +/* Data Transfer Helpers ****************************************************/ + +static void litex_eventtimeout(wdparm_t arg); +static void litex_endwait(struct litex_dev_s *priv, + sdio_eventset_t wkupevent); +static void litex_callback(void *arg); + +/**************************************************************************** + * Private Data + ****************************************************************************/ + +struct litex_dev_s g_sdiodev = +{ + .dev = + { + .reset = litex_reset, + .capabilities = litex_capabilities, + .status = litex_status, + .widebus = litex_widebus, + .clock = litex_clock, + .attach = litex_attach, + .sendcmd = litex_sendcmd, + .blocksetup = litex_blocksetup, + .recvsetup = litex_recvsetup, + .sendsetup = litex_sendsetup, + .cancel = litex_cancel, + .dmarecvsetup = litex_recvsetup, + .dmasendsetup = litex_sendsetup, + .waitresponse = litex_waitresponse, + .recv_r1 = litex_recvshort, + .recv_r2 = litex_recvlong, + .recv_r3 = litex_recvshort, + .recv_r4 = litex_recvshort, + .recv_r5 = litex_recvshort, + .recv_r6 = litex_recvshort, + .recv_r7 = litex_recvshort, + .waitenable = litex_waitenable, + .eventwait = litex_eventwait, + .callbackenable = litex_callbackenable, + .registercallback = litex_registercallback, + }, +}; + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: litex_pow2roundup + * + * Description: + * + ****************************************************************************/ + +static inline uint32_t litex_pow2roundup(uint32_t r) +{ + r--; + r |= r >> 1; + r |= r >> 2; + r |= r >> 4; + r |= r >> 8; + r |= r >> 16; + r++; + return r; +} + +/**************************************************************************** + * Name: litex_configwaitints + * + * Description: + * Enable/disable SDIO interrupts needed to support the wait function + * + * Input Parameters: + * priv - A reference to the SDIO device state structure + * waitmask - The set of bits in the SDIO MASK register to set + * waitevents - Waited for events + * wkupevent - Wake-up events + * + * Returned Value: + * None + * + ****************************************************************************/ + +static void litex_configwaitints(struct litex_dev_s *priv, uint32_t waitints, + sdio_eventset_t waitevents, + sdio_eventset_t wkupevent) +{ + irqstate_t flags; + + flags = enter_critical_section(); + priv->waitevents = waitevents; + priv->wkupevent = wkupevent; + priv->waitints = waitints; + + putreg32(priv->xfrints | priv->waitints | priv->cintints, + LITEX_SDIRQ_ENABLE); + + mcinfo("pending irq: %08" PRIx32 " enabled irq: %08" PRIx32 "\n", + getreg32(LITEX_SDIRQ_PENDING), + getreg32(LITEX_SDIRQ_ENABLE)); + + leave_critical_section(flags); +} + +/**************************************************************************** + * Name: litex_configxfrints + * + * Description: + * Enable SDIO interrupts needed to support the data transfer event + * + * Input Parameters: + * priv - A reference to the SDIO device state structure + * xfrints - The set of bits in the SDIO MASK register to set + * + * Returned Value: + * None + * + ****************************************************************************/ + +static void litex_configxfrints(struct litex_dev_s *priv, uint32_t xfrints) +{ + irqstate_t flags; + + flags = enter_critical_section(); + priv->xfrints = xfrints; + + putreg32(priv->xfrints | priv->waitints | priv->cintints, + LITEX_SDIRQ_ENABLE); + + mcinfo("pending irq: %08" PRIx32 " enabled irq: %08" PRIx32 "\n", + getreg32(LITEX_SDIRQ_PENDING), + getreg32(LITEX_SDIRQ_ENABLE)); + + leave_critical_section(flags); +} + +/**************************************************************************** + * Name: litex_interrupt + * + * Description: + * SDIO interrupt handler + * + * Input Parameters: + * dev - An instance of the SDIO device interface + * + * Returned Value: + * None + * + ****************************************************************************/ + +static int litex_interrupt(int irq, void *context, void *arg) +{ + struct litex_dev_s *priv = &g_sdiodev; + uint32_t pending; + + mcinfo("pending irq: %08" PRIx32 " enabled irq: %08" PRIx32 "\n", + getreg32(LITEX_SDIRQ_PENDING), + getreg32(LITEX_SDIRQ_ENABLE)); + + pending = getreg32(LITEX_SDIRQ_PENDING) & getreg32(LITEX_SDIRQ_ENABLE); + putreg32(pending, LITEX_SDIRQ_PENDING); + + mcinfo("pending irq: %08" PRIx32 " enabled irq: %08" PRIx32 "\n", + getreg32(LITEX_SDIRQ_PENDING), + getreg32(LITEX_SDIRQ_ENABLE)); + + /* check for card change interrupt */ + + if ((pending & LITEX_INT_CARDDETECT) != 0) + { + mcinfo("Card Detect State: %lu\n", getreg32(LITEX_SDPHY_CARD_DETECT)); + + /* Perform callback */ + + if (priv->do_sdio_card != NULL) + { + priv->do_sdio_card(priv->do_sdio_arg); + } + } + + /* check for DMA write interrupt */ + + if ((pending & LITEX_INT_BLOCK2MEM) != 0) + { + if ((priv->waitevents & SDIOWAIT_TRANSFERDONE) != 0) + { + litex_configxfrints(priv, 0); + + /* Yes.. wake up any waiting threads */ + + litex_endwait(priv, SDIOWAIT_TRANSFERDONE); + } + } + + /* check for DMA read interrupt */ + + if ((pending & LITEX_INT_MEM2BLOCK) != 0) + { + if ((priv->waitevents & SDIOWAIT_TRANSFERDONE) != 0) + { + litex_configxfrints(priv, 0); + + /* Yes.. wake up any waiting threads */ + + litex_endwait(priv, SDIOWAIT_TRANSFERDONE); + } + } + +#if 0 /* Not used */ + /* check for command complete interrupt */ + + if ((pending & LITEX_INT_CMDDONE) != 0) + { + if ((priv->waitevents & + (SDIOWAIT_CMDDONE | SDIOWAIT_RESPONSEDONE)) != 0) + { + /* Yes.. wake the thread up */ + + litex_endwait(priv, SDIOWAIT_CMDDONE); + } + } +#endif + + return OK; +} + +/**************************************************************************** + * Name: litex_eventtimeout + * + * Description: + * The watchdog timeout setup when the event wait start has expired without + * any other waited-for event occurring. + * + * Input Parameters: + * arg - The argument + * + * Returned Value: + * None + * + * Assumptions: + * Always called from the interrupt level with interrupts disabled. + * + ****************************************************************************/ + +static void litex_eventtimeout(wdparm_t arg) +{ + struct litex_dev_s *priv = (struct litex_dev_s *)arg; + + DEBUGASSERT((priv->waitevents & SDIOWAIT_TIMEOUT) != 0 || + priv->wkupevent != 0); + + mcinfo("pending irq: %08" PRIx32 " enabled irq: %08" PRIx32 "\n", + getreg32(LITEX_SDIRQ_PENDING), + getreg32(LITEX_SDIRQ_ENABLE)); + + if ((priv->waitevents & SDIOWAIT_TIMEOUT) != 0) + { + litex_endwait(priv, SDIOWAIT_TIMEOUT); + mcerr("Timeout\n"); + } +} + +/**************************************************************************** + * Name: litex_endwait + * + * Description: + * Wake up a waiting thread if the waited-for event has occurred. + * + * Input Parameters: + * priv - An instance of the SDIO device interface + * wkupevent - The event that caused the wait to end + * + * Returned Value: + * None + * + * Assumptions: + * Always called from the interrupt level with interrupts disabled. + * + ****************************************************************************/ + +static void litex_endwait(struct litex_dev_s *priv, + sdio_eventset_t wkupevent) +{ + /* Cancel the watchdog timeout */ + + wd_cancel(&priv->waitwdog); + + /* Disable event-related interrupts */ + + litex_configwaitints(priv, 0, 0, wkupevent); + + /* Wake up the waiting thread */ + + nxsem_post(&priv->waitsem); +} + +/**************************************************************************** + * Name: litex_reset + * + * Description: + * Reset the SDIO controller. Undo all setup and initialization. + * + * Input Parameters: + * dev - An instance of the SDIO device interface + * + * Returned Value: + * None + * + ****************************************************************************/ + +static void litex_reset(struct sdio_dev_s *dev) +{ + struct litex_dev_s *priv = (struct litex_dev_s *)dev; + irqstate_t flags; + + flags = enter_critical_section(); + + priv->waitevents = 0; + priv->waitints = 0; + priv->wkupevent = 0; + + wd_cancel(&priv->waitwdog); + + priv->xfrints = 0; + + leave_critical_section(flags); +} + +/**************************************************************************** + * Name: litex_capabilities + * + * Description: + * Get capabilities (and limitations) of the SDIO driver (optional) + * + * Input Parameters: + * dev - Device-specific state data + * + * Returned Value: + * Returns a bitset of status values (see SDIO_CAPS_* defines) + * + ****************************************************************************/ + +static sdio_capset_t litex_capabilities(struct sdio_dev_s *dev) +{ + sdio_capset_t caps = 0; + + /* LiteSDCard only supports 4-bit bus width */ + + caps |= SDIO_CAPS_4BIT_ONLY; + caps |= SDIO_CAPS_DMASUPPORTED; + caps |= SDIO_CAPS_DMABEFOREWRITE; + + return caps; +} + +/**************************************************************************** + * Name: litex_status + * + * Description: + * Get SDIO status. + * + * Input Parameters: + * dev - Device-specific state data + * + * Returned Value: + * Returns a bitset of status values (see litex_dev_s* defines) + * + ****************************************************************************/ + +static sdio_statset_t litex_status(struct sdio_dev_s *dev) +{ + struct litex_dev_s *priv = (struct litex_dev_s *)dev; + + sdio_statset_t cd = priv->cdstatus; + mcinfo("CD Status: %u\n", cd); + + return cd; +} + +/**************************************************************************** + * Name: litex_widebus + * + * Description: + * Called after change in Bus width has been selected (via ACMD6). Most + * controllers will need to perform some special operations to work + * correctly in the new bus mode. + * + * Input Parameters: + * dev - An instance of the SDIO device interface + * wide - true: wide bus (4-bit) bus mode enabled + * + * Returned Value: + * None + * + ****************************************************************************/ + +static void litex_widebus(struct sdio_dev_s *dev, bool wide) +{ + /* LiteSDCard only supports 4-bit bus width. + * Nothing to do here. + */ +} + +/**************************************************************************** + * Name: litex_clock + * + * Description: + * Enable/disable SDIO clocking + * + * Input Parameters: + * dev - An instance of the SDIO device interface + * rate - Specifies the clocking to use (see enum sdio_clock_e) + * + * Returned Value: + * None + * + ****************************************************************************/ + +static void litex_clock(struct sdio_dev_s *dev, enum sdio_clock_e rate) +{ + uint32_t clk_freq; + + switch (rate) + { + /* Return early - SDPHY doesnt support clock disabling */ + + default: + case CLOCK_SDIO_DISABLED: + return; + + /* Enable in initial ID mode clocking (<400KHz) */ + + case CLOCK_IDMODE: + clk_freq = CONFIG_LITEX_IDMODE_FREQ; + break; + + /* Enable in MMC normal operation clocking */ + + case CLOCK_MMC_TRANSFER: + clk_freq = CONFIG_LITEX_MMCXFR_FREQ; + break; + + /* SD normal operation clocking (wide 4-bit mode) */ + + case CLOCK_SD_TRANSFER_4BIT: + clk_freq = CONFIG_LITEX_SD4BIT_FREQ; + break; + } + + /* Set the new clock frequency along with the clock enable/disable bit */ + + uint32_t divider; + divider = clk_freq ? litex_get_hfclk() / clk_freq : MAX_DIVIDER; + divider = litex_pow2roundup(divider); + divider = min(max(divider, 2), MAX_DIVIDER); + + /* this is the *effective* new clk_freq */ + + clk_freq = litex_get_hfclk() / divider; + if (clk_freq > 1000000) + { + mcinfo("Setting SDCard clk freq to %ld MHz\n", clk_freq / 1000000); + } + else + { + mcinfo("Setting SDCard clk freq to %ld KHz\n", clk_freq / 1000); + } + + putreg32(divider, LITEX_SDPHY_CLOCKER_DIVIDER); +} + +/**************************************************************************** + * Name: litex_attach + * + * Description: + * Attach and prepare interrupts + * + * Input Parameters: + * dev - An instance of the SDIO device interface + * + * Returned Value: + * OK on success; A negated errno on failure. + * + ****************************************************************************/ + +static int litex_attach(struct sdio_dev_s *dev) +{ + int ret; + + /* Attach the SDIO interrupt handler */ + + ret = irq_attach(LITEX_IRQ_SDCARD, litex_interrupt, NULL); + if (ret == OK) + { + putreg32(0xffffffff, LITEX_SDIRQ_PENDING); + putreg32(0, LITEX_SDIRQ_ENABLE); + up_enable_irq(LITEX_IRQ_SDCARD); + } + + return ret; +} + +/**************************************************************************** + * Name: litex_sendcmd + * + * Description: + * Send the SDIO command + * + * Input Parameters: + * dev - An instance of the SDIO device interface + * cmd - The command to send (32-bits, encoded) + * arg - 32-bit argument required with some commands + * + * Returned Value: + * None + * + ****************************************************************************/ + +static int litex_sendcmd(struct sdio_dev_s *dev, uint32_t cmd, + uint32_t arg) +{ + uint32_t transfer = 0; + uint32_t resplen = 0; + uint32_t regval = 0; + uint32_t cmdidx = 0; + + irqstate_t flags; + flags = enter_critical_section(); + + /* Set WAITRESP bits */ + + switch (cmd & MMCSD_RESPONSE_MASK) + { + case MMCSD_NO_RESPONSE: + resplen = SDCARD_CTRL_RESPONSE_NONE; + break; + + case MMCSD_R1_RESPONSE: + case MMCSD_R1B_RESPONSE: + case MMCSD_R3_RESPONSE: + case MMCSD_R4_RESPONSE: + case MMCSD_R5_RESPONSE: + case MMCSD_R6_RESPONSE: + case MMCSD_R7_RESPONSE: + resplen = SDCARD_CTRL_RESPONSE_SHORT; + break; + + case MMCSD_R2_RESPONSE: + resplen = SDCARD_CTRL_RESPONSE_LONG; + break; + } + + switch (cmd & MMCSD_DATAXFR_MASK) + { + case MMCSD_NODATAXFR: + transfer = SD_CTL_DATA_XFER_NONE; + break; + + case MMCSD_RDSTREAM: + transfer = SD_CTL_DATA_XFER_READ; + break; + + case MMCSD_WRSTREAM: + transfer = SD_CTL_DATA_XFER_WRITE; + break; + + case MMCSD_RDDATAXFR: + transfer = SD_CTL_DATA_XFER_READ; + break; + + case MMCSD_WRDATAXFR: + transfer = SD_CTL_DATA_XFER_WRITE; + break; + } + + /* Write the SDIO CMD */ + + cmdidx = (cmd & MMCSD_CMDIDX_MASK) >> MMCSD_CMDIDX_SHIFT; + regval = (cmdidx << 8) | (transfer << 5) | resplen; + putreg32(arg, LITEX_SDCORE_CMD_ARGUMENT); + putreg32(regval, LITEX_SDCORE_CMD_COMMAND); + putreg32(1, LITEX_SDCORE_CMD_SEND); + + mcinfo("cmd: %" PRIu32 " cmdid: %" PRIu32 " arg: %08" PRIx32 + " regval: %08" PRIx32 "\n", + cmd, cmdidx, arg, regval); + + leave_critical_section(flags); + + return OK; +} + +/**************************************************************************** + * Name: litex_blocksetup + * + * Description: + * Configure block size and the number of blocks for next transfer + * + * Input Parameters: + * dev - An instance of the SDIO device interface + * blocklen - The selected block size. + * nblocklen - The number of blocks to transfer + * + * Returned Value: + * None + * + ****************************************************************************/ + +static void litex_blocksetup(struct sdio_dev_s *dev, + unsigned int blocklen, unsigned int nblocks) +{ + struct litex_dev_s *priv = (struct litex_dev_s *)dev; + + mcinfo("blocklen=%d, total transfer=%d (%d blocks)\n", blocklen, + blocklen * nblocks, nblocks); + + /* Configure block size for next transfer */ + + priv->block_size = blocklen; + + putreg32(blocklen, LITEX_SDCORE_BLOCK_LENGTH); + putreg32(nblocks, LITEX_SDCORE_BLOCK_COUNT); +} + +/**************************************************************************** + * Name: litex_cancel + * + * Description: + * Cancel the data transfer setup of SDIO_RECVSETUP, SDIO_SENDSETUP, + * SDIO_DMARECVSETUP or SDIO_DMASENDSETUP. This must be called to cancel + * the data transfer setup if, for some reason, you cannot perform the + * transfer. + * + * Input Parameters: + * dev - An instance of the SDIO device interface + * + * Returned Value: + * OK is success; a negated errno on failure + * + ****************************************************************************/ + +static int litex_cancel(struct sdio_dev_s *dev) +{ + struct litex_dev_s *priv = (struct litex_dev_s *)dev; + + /* Cancel any watchdog timeout */ + + wd_cancel(&priv->waitwdog); + + /* Stop DMA transfers */ + + putreg32(0, LITEX_SDBLOCK2MEM_DMA_ENABLE); + putreg32(0, LITEX_SDMEM2BLOCK_DMA_ENABLE); + + return OK; +} + +/**************************************************************************** + * Name: litex_dmarecvsetup + * + * Description: + * Setup to perform a read DMA. If the processor supports a data cache, + * then this method will also make sure that the contents of the DMA memory + * and the data cache are coherent. For read transfers this may mean + * invalidating the data cache. + * + * Input Parameters: + * dev - An instance of the SDIO device interface + * buffer - The memory to DMA from + * buflen - The size of the DMA transfer in bytes + * + * Returned Value: + * OK on success; a negated errno on failure + * + ****************************************************************************/ + +static int litex_recvsetup(struct sdio_dev_s *dev, uint8_t *buffer, + size_t nbytes) +{ + struct litex_dev_s *priv = (struct litex_dev_s *)dev; + DEBUGASSERT(priv != NULL && buffer != NULL && nbytes > 0); + DEBUGASSERT(((uint32_t)buffer & 3) == 0); + + mcinfo("buffer: %p bytes: %u\n", buffer, nbytes); + + litex_configxfrints(priv, LITEX_INT_BLOCK2MEM); + + /* flush CPU d-cache */ + + up_invalidate_dcache_all(); + + putreg32(0, LITEX_SDBLOCK2MEM_DMA_ENABLE); + putreg32((uintptr_t)buffer >> 32, LITEX_SDBLOCK2MEM_DMA_BASE); + putreg32((uintptr_t)buffer, LITEX_SDBLOCK2MEM_DMA_BASE + 0x04); + putreg32(nbytes, LITEX_SDBLOCK2MEM_DMA_LENGTH); + putreg32(1, LITEX_SDBLOCK2MEM_DMA_ENABLE); + + return OK; +} + +/**************************************************************************** + * Name: litex_sendsetup + * + * Description: + * Setup to perform a write DMA. If the processor supports a data cache, + * then this method will also make sure that the contents of the DMA memory + * and the data cache are coherent. For write transfers, this may mean + * flushing the data cache. + * + * Input Parameters: + * dev - An instance of the SDIO device interface + * buffer - The memory to DMA into + * nbytes - The size of the DMA transfer in bytes + * + * Returned Value: + * OK on success; a negated errno on failure + * + ****************************************************************************/ + +static int litex_sendsetup(struct sdio_dev_s *dev, + const uint8_t *buffer, size_t nbytes) +{ + struct litex_dev_s *priv = (struct litex_dev_s *)dev; + DEBUGASSERT(priv != NULL && buffer != NULL && nbytes > 0); + DEBUGASSERT(((uint32_t)buffer & 3) == 0); + + mcinfo("buffer: %p bytes: %u\n", buffer, nbytes); + + litex_configxfrints(priv, LITEX_INT_MEM2BLOCK); + + /* flush CPU d-cache */ + + up_invalidate_dcache_all(); + + putreg32(0, LITEX_SDMEM2BLOCK_DMA_ENABLE); + putreg32((uintptr_t)buffer >> 32, LITEX_SDMEM2BLOCK_DMA_BASE); + putreg32((uintptr_t)buffer, LITEX_SDMEM2BLOCK_DMA_BASE + 0x04); + putreg32(nbytes, LITEX_SDMEM2BLOCK_DMA_LENGTH); + putreg32(1, LITEX_SDMEM2BLOCK_DMA_ENABLE); + + return OK; +} + +/**************************************************************************** + * Name: litex_waitresponse + * + * Description: + * Poll-wait for the response to the last command to be ready. + * + * Input Parameters: + * dev - An instance of the SDIO device interface + * cmd - The command that was sent. See 32-bit command definitions above. + * + * Returned Value: + * OK is success; a negated errno on failure + * + ****************************************************************************/ + +static int litex_waitresponse(struct sdio_dev_s *dev, uint32_t cmd) +{ + uint32_t ev; + + for (; ; ) + { + if ((cmd & MMCSD_DATAXFR_MASK) == 0) + { + ev = getreg32(LITEX_SDCORE_CMD_EVENT); + } + else + { + ev = getreg32(LITEX_SDCORE_DATA_EVENT); + } + + mcinfo("%lu\n", ev); + + if (ev & LITEX_EV_CMDDONE) + break; + + nxsig_usleep(10); + } + + if (ev & LITEX_EV_WRERROR) + { + return -EIO; + } + + if (ev & LITEX_EV_TIMEOUT) + { + return -ETIMEDOUT; + } + + if (ev & LITEX_EV_CRCERROR) + { + return -EILSEQ; + } + + return OK; +} + +static int litex_recvlong(struct sdio_dev_s *dev, uint32_t cmd, + uint32_t rlong[4]) +{ + uint32_t regval; + int ret = OK; + + /* R3 OCR (48-bit) + * 47 0 Start bit + * 46 0 Transmission bit (0=from card) + * 45:40 bit5 - bit0 Reserved + * 39:8 bit31 - bit0 32-bit OCR register + * 7:1 bit6 - bit0 Reserved + * 0 1 End bit + */ + + /* Check that this is the correct response to this command */ + +#ifdef CONFIG_DEBUG_MEMCARD_INFO + if ((cmd & MMCSD_RESPONSE_MASK) != MMCSD_R2_RESPONSE) + { + mcerr("ERROR: Wrong response CMD=%08x\n", cmd); + ret = -EINVAL; + } + else +#endif + { + /* Check if a timeout or CRC error occurred */ + + regval = getreg32(LITEX_SDCORE_CMD_EVENT); + if ((regval & LITEX_EV_TIMEOUT) != 0) + { + mcerr("ERROR: Command timeout: %08" PRIx32 "\n", regval); + ret = -ETIMEDOUT; + } + else if ((regval & LITEX_EV_CRCERROR) != 0) + { + mcerr("ERROR: CRC failure: %08" PRIx32 "\n", regval); + ret = -EIO; + } + } + + if (rlong != NULL) + { + rlong[0] = getreg32(LITEX_SDCORE_CMD_RESPONSE + 0x00); + rlong[1] = getreg32(LITEX_SDCORE_CMD_RESPONSE + 0x04); + rlong[2] = getreg32(LITEX_SDCORE_CMD_RESPONSE + 0x08); + rlong[3] = getreg32(LITEX_SDCORE_CMD_RESPONSE + 0x0c); + } + + return ret; +} + +static int litex_recvshort(struct sdio_dev_s *dev, uint32_t cmd, + uint32_t *rshort) +{ + uint32_t regval; + int ret = OK; + + /* R3 OCR (48-bit) + * 47 0 Start bit + * 46 0 Transmission bit (0=from card) + * 45:40 bit5 - bit0 Reserved + * 39:8 bit31 - bit0 32-bit OCR register + * 7:1 bit6 - bit0 Reserved + * 0 1 End bit + */ + + /* Check that this is the correct response to this command */ + +#ifdef CONFIG_DEBUG_MEMCARD_INFO + if ((cmd & MMCSD_RESPONSE_MASK) != MMCSD_R1_RESPONSE && + (cmd & MMCSD_RESPONSE_MASK) != MMCSD_R1B_RESPONSE && + (cmd & MMCSD_RESPONSE_MASK) != MMCSD_R3_RESPONSE && + (cmd & MMCSD_RESPONSE_MASK) != MMCSD_R4_RESPONSE && + (cmd & MMCSD_RESPONSE_MASK) != MMCSD_R5_RESPONSE && + (cmd & MMCSD_RESPONSE_MASK) != MMCSD_R6_RESPONSE && + (cmd & MMCSD_RESPONSE_MASK) != MMCSD_R7_RESPONSE) + { + mcerr("ERROR: Wrong response CMD=%08x\n", cmd); + ret = -EINVAL; + } + else +#endif + { + /* Check if a timeout or CRC error occurred */ + + regval = getreg32(LITEX_SDCORE_CMD_EVENT); + if ((regval & LITEX_EV_TIMEOUT) != 0) + { + mcerr("ERROR: Command timeout: %08" PRIx32 "\n", regval); + ret = -ETIMEDOUT; + } + else if ((regval & LITEX_EV_CRCERROR) != 0) + { + mcerr("ERROR: CRC failure: %08" PRIx32 "\n", regval); + ret = -EIO; + } + } + + if (rshort != NULL) + { + *rshort = getreg32(LITEX_SDCORE_CMD_RESPONSE + 0x0c); + } + + return ret; +} + +/**************************************************************************** + * Name: litex_waitenable + * + * Description: + * Enable/disable of a set of SDIO wait events. This is part of the + * the SDIO_WAITEVENT sequence. The set of to-be-waited-for events is + * configured before calling litex_eventwait. This is done in this way + * to help the driver to eliminate race conditions between the command + * setup and the subsequent events. + * + * The enabled events persist until either (1) SDIO_WAITENABLE is called + * again specifying a different set of wait events, or (2) SDIO_EVENTWAIT + * returns. + * + * Input Parameters: + * dev - An instance of the SDIO device interface + * eventset - A bitset of events to enable or disable (see SDIOWAIT_* + * definitions). 0=disable; 1=enable. + * + * Returned Value: + * None + * + ****************************************************************************/ + +static void litex_waitenable(struct sdio_dev_s *dev, + sdio_eventset_t eventset, uint32_t timeout) +{ + struct litex_dev_s *priv = (struct litex_dev_s *)dev; + + DEBUGASSERT(priv != NULL); + + litex_configwaitints(priv, 0, eventset, 0); + + /* Check if the timeout event is specified in the event set */ + + if ((priv->waitevents & SDIOWAIT_TIMEOUT) != 0) + { + int delay; + int ret; + + /* Yes.. Handle a cornercase: The user requested a timeout event but + * with timeout == 0? + */ + + if (timeout == 0) + { + priv->wkupevent = SDIOWAIT_TIMEOUT; + return; + } + + /* Start the watchdog timer */ + + delay = MSEC2TICK(timeout); + ret = wd_start(&priv->waitwdog, delay, + litex_eventtimeout, (wdparm_t)priv); + if (ret < 0) + { + mcerr("ERROR: wd_start failed: %d\n", ret); + } + } +} + +/**************************************************************************** + * Name: litex_eventwait + * + * Description: + * Wait for one of the enabled events to occur (or a timeout). Note that + * all events enabled by SDIO_WAITEVENTS are disabled when litex_eventwait + * returns. SDIO_WAITEVENTS must be called again before litex_eventwait + * can be used again. + * + * Input Parameters: + * dev - An instance of the SDIO device interface + * timeout - Maximum time in milliseconds to wait. Zero means immediate + * timeout with no wait. The timeout value is ignored if + * SDIOWAIT_TIMEOUT is not included in the waited-for eventset. + * + * Returned Value: + * Event set containing the event(s) that ended the wait. Should always + * be non-zero. All events are disabled after the wait concludes. + * + ****************************************************************************/ + +static sdio_eventset_t litex_eventwait(struct sdio_dev_s *dev) +{ + struct litex_dev_s *priv = (struct litex_dev_s *)dev; + sdio_eventset_t wkupevent = 0; + int ret; + + DEBUGASSERT((priv->waitevents != 0 && priv->wkupevent == 0) || + (priv->waitevents == 0 && priv->wkupevent != 0)); + for (; ; ) + { + ret = nxsem_wait_uninterruptible(&priv->waitsem); + if (ret < 0) + { + litex_configwaitints(priv, 0, 0, 0); + wd_cancel(&priv->waitwdog); + return SDIOWAIT_ERROR; + } + + wkupevent = priv->wkupevent; + if (wkupevent != 0) + { + break; + } + } + + litex_configwaitints(priv, 0, 0, 0); + return wkupevent; +} + +/**************************************************************************** + * Name: litex_registercallback + * + * Description: + * Register a callback that that will be invoked on any media status + * change. Callbacks should not be made from interrupt handlers, rather + * interrupt level events should be handled by calling back on the work + * thread. + * + * When this method is called, all callbacks should be disabled until they + * are enabled via a call to SDIO_CALLBACKENABLE + * + * Input Parameters: + * dev - Device-specific state data + * callback - The function to call on the media change + * arg - A caller provided value to return with the callback + * + * Returned Value: + * 0 on success; negated errno on failure. + * + ****************************************************************************/ + +static int litex_registercallback(struct sdio_dev_s *dev, + worker_t callback, void *arg) +{ + struct litex_dev_s *priv = (struct litex_dev_s *)dev; + + /* Disable callbacks and register this callback and is argument */ + + mcinfo("Register %p(%p)\n", callback, arg); + DEBUGASSERT(priv != NULL); + + priv->cbevents = 0; + priv->cbarg = arg; + priv->callback = callback; + + return OK; +} + +/**************************************************************************** + * Name: litex_callbackenable + * + * Description: + * Enable/disable of a set of SDIO callback events. This is part of the + * the SDIO callback sequence. The set of events is configured to enabled + * callbacks to the function provided in litex_registercallback. + * + * Events are automatically disabled once the callback is performed and no + * further callback events will occur until they are again enabled by + * calling this method. + * + * Input Parameters: + * dev - An instance of the SDIO device interface + * eventset - A bitset of events to enable or disable (see SDIOMEDIA_* + * definitions). 0=disable; 1=enable. + * + * Returned Value: + * None + * + ****************************************************************************/ + +static void litex_callbackenable(struct sdio_dev_s *dev, + sdio_eventset_t eventset) +{ + struct litex_dev_s *priv = (struct litex_dev_s *)dev; + + mcinfo("eventset: %02x\n", eventset); + DEBUGASSERT(priv != NULL); + + priv->cbevents = eventset; + litex_callback(priv); +} + +/**************************************************************************** + * Name: litex_callback + * + * Description: + * Perform callback. + * + * Assumptions: + * This function does not execute in the context of an interrupt handler. + * It may be invoked on any user thread or scheduled on the work thread + * from an interrupt handler. + * + ****************************************************************************/ + +static void litex_callback(void *arg) +{ + struct litex_dev_s *priv = (struct litex_dev_s *)arg; + + /* Is a callback registered? */ + + DEBUGASSERT(priv != NULL); + mcinfo("Callback %p(%p) cbevents: %02x cdstatus: %02x\n", + priv->callback, priv->cbarg, priv->cbevents, priv->cdstatus); + + if (priv->callback) + { + /* Yes.. Check for enabled callback events */ + + if ((priv->cdstatus & SDIO_STATUS_PRESENT) != 0) + { + /* Media is present. Is the media inserted event enabled? */ + + if ((priv->cbevents & SDIOMEDIA_INSERTED) == 0) + { + /* No... return without performing the callback */ + + return; + } + } + else + { + /* Media is not present. Is the media eject event enabled? */ + + if ((priv->cbevents & SDIOMEDIA_EJECTED) == 0) + { + /* No... return without performing the callback */ + + return; + } + } + + /* Perform the callback, disabling further callbacks. Of course, the + * the callback can (and probably should) re-enable callbacks. + */ + + priv->cbevents = 0; + + /* Callbacks cannot be performed in the context of an interrupt + * handler. If we are in an interrupt handler, then queue the + * callback to be performed later on the work thread. + */ + + if (up_interrupt_context()) + { + /* Yes.. queue it */ + + mcinfo("Queuing callback to %p(%p)\n", + priv->callback, priv->cbarg); + work_queue(HPWORK, &priv->cbwork, priv->callback, + priv->cbarg, 0); + } + else + { + /* No.. then just call the callback here */ + + mcinfo("Callback to %p(%p)\n", priv->callback, priv->cbarg); + priv->callback(priv->cbarg); + } + } +} + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: litex_sdio_get_card_detect + * + * Description: + * Get the card detection state determined by the peripheral. + * + * Input Parameters: + * None + * + * Returned Value: + * Card detected state. + * True when a card is present. + * + ****************************************************************************/ + +bool litex_sdio_get_card_detect(void) +{ + return getreg32(LITEX_SDPHY_CARD_DETECT) == 0; +} + +/**************************************************************************** + * Name: litex_sdio_set_card_isr + * + * Description: + * SDIO card generates interrupt via SDIO_DATA_1 pin. + * Called by board-specific logic to register an ISR for SDIO card. + * + * Input Parameters: + * func - callback function. + * arg - arg to be passed to the function. + * + * Returned Value: + * None + * + ****************************************************************************/ + +void litex_sdio_set_card_isr(struct sdio_dev_s *dev, + void (*func)(void *), void *arg) +{ + irqstate_t flags; + uint32_t regval; + struct litex_dev_s *priv = (struct litex_dev_s *)dev; + + mcinfo("Enable Card Detect ISR\n"); + + mcinfo("pending irq: %08" PRIx32 " enabled irq: %08" PRIx32 "\n", + getreg32(LITEX_SDIRQ_PENDING), + getreg32(LITEX_SDIRQ_ENABLE)); + + priv->do_sdio_card = func; + priv->do_sdio_arg = arg; + + if (priv->do_sdio_card != NULL) + { + priv->cintints = LITEX_INT_CARDDETECT; + } + else + { + priv->cintints = 0; + } + + flags = enter_critical_section(); + regval = getreg32(LITEX_SDIRQ_ENABLE); + regval = (regval & ~LITEX_INT_CARDDETECT) | priv->cintints; + putreg32(regval, LITEX_SDIRQ_ENABLE); + + mcinfo("pending irq: %08" PRIx32 " enabled irq: %08" PRIx32 "\n", + getreg32(LITEX_SDIRQ_PENDING), + getreg32(LITEX_SDIRQ_ENABLE)); + + mcinfo("Card Detect State: %lu\n", getreg32(LITEX_SDPHY_CARD_DETECT)); + + leave_critical_section(flags); +} + +/**************************************************************************** + * Name: sdio_initialize + * + * Description: + * Initialize SDIO for operation. + * + * Input Parameters: + * slotno - Not used. + * + * Returned Value: + * A reference to an SDIO interface structure. NULL is returned on + * failures. + * + ****************************************************************************/ + +struct sdio_dev_s *sdio_initialize(int slotno) +{ + struct litex_dev_s *priv = &g_sdiodev; + + mcinfo("slotno: %d\n", slotno); + + nxsem_init(&priv->waitsem, 0, 0); + nxsem_set_protocol(&priv->waitsem, SEM_PRIO_NONE); + + litex_reset(&priv->dev); + return &g_sdiodev.dev; +} + +/**************************************************************************** + * Name: sdio_mediachange + * + * Description: + * Called by board-specific logic -- possibly from an interrupt handler -- + * in order to signal to the driver that a card has been inserted or + * removed from the slot + * + * Input Parameters: + * dev - An instance of the SDIO driver device state structure. + * cardinslot - true is a card has been detected in the slot; false if a + * card has been removed from the slot. Only transitions + * (inserted->removed or removed->inserted should be reported) + * + * Returned Value: + * None + * + ****************************************************************************/ + +void sdio_mediachange(struct sdio_dev_s *dev, bool cardinslot) +{ + struct litex_dev_s *priv = (struct litex_dev_s *)dev; + sdio_statset_t cdstatus; + irqstate_t flags; + + flags = enter_critical_section(); + + cdstatus = priv->cdstatus; + if (cardinslot) + { + priv->cdstatus |= SDIO_STATUS_PRESENT; + } + else + { + priv->cdstatus &= ~SDIO_STATUS_PRESENT; + } + + leave_critical_section(flags); + + mcinfo("cdstatus OLD: %02x NEW: %02x\n", cdstatus, priv->cdstatus); + + if (cdstatus != priv->cdstatus) + { + litex_callback(priv); + } +} diff --git a/arch/risc-v/src/litex/litex_sdio.h b/arch/risc-v/src/litex/litex_sdio.h new file mode 100644 index 0000000000000..745f7ca948cbf --- /dev/null +++ b/arch/risc-v/src/litex/litex_sdio.h @@ -0,0 +1,120 @@ +/**************************************************************************** + * arch/risc-v/src/litex/litex_sdio.h + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +#ifndef __ARCH_RISCV_SRC_LITEX_LITEX_SDIO_H +#define __ARCH_RISCV_SRC_LITEX_LITEX_SDIO_H + +/**************************************************************************** + * Public Function Prototypes + ****************************************************************************/ + +#ifndef __ASSEMBLY__ + +#undef EXTERN +#if defined(__cplusplus) +#define EXTERN extern "C" +extern "C" +{ +#else +#define EXTERN extern +#endif + +/**************************************************************************** + * Name: litex_sdio_get_card_detect + * + * Description: + * Get the card detection state determined by the peripheral. + * + * Input Parameters: + * None + * + * Returned Value: + * Card detected state. + * True when a card is present. + * + ****************************************************************************/ + +bool litex_sdio_get_card_detect(void); + +/**************************************************************************** + * Name: litex_sdio_set_card_isr + * + * Description: + * SDIO card generates interrupt via SDIO_DATA_1 pin. + * Called by board-specific logic to register an ISR for SDIO card. + * + * Input Parameters: + * func - callback function. + * arg - arg to be passed to the function. + * + * Returned Value: + * None + * + ****************************************************************************/ + +void litex_sdio_set_card_isr(struct sdio_dev_s *dev, + void (*func)(void *), void *arg); + +/**************************************************************************** + * Name: sdio_initialize + * + * Description: + * Initialize SDIO for operation. + * + * Input Parameters: + * slotno - Not used. + * + * Returned Value: + * A reference to an SDIO interface structure. NULL is returned on + * failures. + * + ****************************************************************************/ + +struct sdio_dev_s; /* See include/nuttx/sdio.h */ +struct sdio_dev_s *sdio_initialize(int slotno); + +/**************************************************************************** + * Name: sdio_mediachange + * + * Description: + * Called by board-specific logic -- possibly from an interrupt handler -- + * in order to signal to the driver that a card has been inserted or + * removed from the slot + * + * Input Parameters: + * dev - An instance of the SDIO driver device state structure. + * cardinslot - true is a card has been detected in the slot; false if a + * card has been removed from the slot. Only transitions + * (inserted->removed or removed->inserted should be reported) + * + * Returned Value: + * None + * + ****************************************************************************/ + +void sdio_mediachange(struct sdio_dev_s *dev, bool cardinslot); + +#undef EXTERN +#if defined(__cplusplus) +} +#endif + +#endif /* __ASSEMBLY__ */ +#endif /* __ARCH_RISCV_SRC_LITEX_LITEX_SDIO_H */ diff --git a/arch/risc-v/src/mpfs/Kconfig b/arch/risc-v/src/mpfs/Kconfig index 14898d3045d47..d269a8b82820e 100755 --- a/arch/risc-v/src/mpfs/Kconfig +++ b/arch/risc-v/src/mpfs/Kconfig @@ -46,17 +46,12 @@ config MPFS_BOOTLOADER ---help--- This NuttX image is used as a bootloader, which will boot only on one hart, putting the others in WFI -config IRQ_NSTACKS - int - depends on MPFS_BOOTLOADER - default 5 - config MPFS_OPENSBI - bool "Use OpenSBI" - depends on MPFS_BOOTLOADER && OPENSBI - default n - ---help--- - This uses a ld-envm-opensbi.script linker script and the mpfs_opensbi.c code to use external OpenSBI. + bool "Use OpenSBI" + depends on MPFS_BOOTLOADER && OPENSBI + default n + ---help--- + This uses a ld-envm-opensbi.script linker script and the mpfs_opensbi.c code to use external OpenSBI. config MPFS_HART0_SBI bool "HART0 boots via SBI" diff --git a/arch/risc-v/src/mpfs/Make.defs b/arch/risc-v/src/mpfs/Make.defs index 435b628cb4446..77c55914a4571 100755 --- a/arch/risc-v/src/mpfs/Make.defs +++ b/arch/risc-v/src/mpfs/Make.defs @@ -22,9 +22,13 @@ CMN_ASRCS += mpfs_head.S riscv_vectors.S riscv_exception_common.S riscv_testset.S +ifeq ($(CONFIG_BUILD_KERNEL),y) +STARTUP_OBJS = crt0$(OBJEXT) +endif + # Specify C code within the common directory to be included CMN_CSRCS += riscv_initialize.c riscv_swint.c -CMN_CSRCS += riscv_createstack.c riscv_exit.c riscv_fault.c +CMN_CSRCS += riscv_createstack.c riscv_exit.c riscv_exception.c CMN_CSRCS += riscv_assert.c riscv_blocktask.c riscv_copystate.c riscv_initialstate.c CMN_CSRCS += riscv_interruptcontext.c riscv_modifyreg32.c riscv_puts.c CMN_CSRCS += riscv_releasepending.c riscv_reprioritizertr.c @@ -32,7 +36,11 @@ CMN_CSRCS += riscv_releasestack.c riscv_stackframe.c riscv_schedulesigaction.c CMN_CSRCS += riscv_sigdeliver.c riscv_unblocktask.c riscv_usestack.c CMN_CSRCS += riscv_mdelay.c riscv_udelay.c CMN_CSRCS += riscv_idle.c riscv_tcbinfo.c riscv_getnewintctx.c -CMN_CSRCS += riscv_cpuindex.c +CMN_CSRCS += riscv_doirq.c riscv_mtimer.c +CMN_CSRCS += riscv_saveusercontext.c + +# Specify ASM code within the common directory to be included +CMN_ASRCS += riscv_mhartid.S ifeq ($(CONFIG_SCHED_BACKTRACE),y) CMN_CSRCS += riscv_backtrace.c @@ -44,9 +52,11 @@ endif ifeq ($(CONFIG_ARCH_FPU),y) CMN_ASRCS += riscv_fpu.S +CMN_CSRCS += riscv_fpucmp.c endif ifeq ($(CONFIG_ARCH_HAVE_VFORK),y) +CMN_ASRCS += vfork.S CMN_CSRCS += riscv_vfork.c endif @@ -67,6 +77,10 @@ CHIP_CSRCS += mpfs_userspace.c CMN_UASRCS += riscv_signal_handler.S endif +ifeq ($(CONFIG_BUILD_KERNEL),y) +CHIP_CSRCS += mpfs_mm_init.c +endif + ifneq ($(CONFIG_BUILD_FLAT),y) CMN_CSRCS += riscv_task_start.c CMN_CSRCS += riscv_pthread_start.c @@ -85,6 +99,14 @@ ifeq ($(CONFIG_ARCH_KERNEL_STACK),y) CMN_CSRCS += riscv_addrenv_kstack.c endif +ifeq ($(CONFIG_ARCH_ADDRENV),y) +CMN_CSRCS += riscv_addrenv.c riscv_pgalloc.c riscv_addrenv_perms.c +endif + +ifeq ($(CONFIG_MM_PGALLOC),y) +CHIP_CSRCS += mpfs_pgalloc.c +endif + ifeq ($(CONFIG_SPI),y) CHIP_CSRCS += mpfs_spi.c endif diff --git a/arch/risc-v/src/mpfs/chip.h b/arch/risc-v/src/mpfs/chip.h index 960c76b8f23b1..6c9d32e1fffd6 100755 --- a/arch/risc-v/src/mpfs/chip.h +++ b/arch/risc-v/src/mpfs/chip.h @@ -29,4 +29,31 @@ #include "mpfs_memorymap.h" +#include "riscv_percpu.h" + +/**************************************************************************** + * Macro Definitions + ****************************************************************************/ + +#ifdef __ASSEMBLY__ + +/**************************************************************************** + * Name: setintstack + * + * Description: + * Set the current stack pointer to the "top" the correct interrupt stack + * for the current CPU. + * + ****************************************************************************/ + +#if CONFIG_ARCH_INTERRUPTSTACK > 15 +#if defined(CONFIG_SMP) || defined(CONFIG_ARCH_USE_S_MODE) +.macro setintstack tmp0, tmp1 + csrr \tmp0, CSR_SCRATCH + REGLOAD sp, RISCV_PERCPU_IRQSTACK(\tmp0) +.endm +#endif /* defined(CONFIG_SMP) || defined(CONFIG_ARCH_USE_S_MODE) */ +#endif /* CONFIG_ARCH_INTERRUPTSTACK > 15 */ + +#endif /* __ASSEMBLY__ */ #endif /* __ARCH_RISCV_SRC_MPFS_CHIP_H */ diff --git a/arch/risc-v/src/mpfs/hardware/mpfs_plic.h b/arch/risc-v/src/mpfs/hardware/mpfs_plic.h index 11513b716105f..67223d14b4d03 100755 --- a/arch/risc-v/src/mpfs/hardware/mpfs_plic.h +++ b/arch/risc-v/src/mpfs/hardware/mpfs_plic.h @@ -102,7 +102,9 @@ #define MPFS_PLIC_MTHRESHOLD_OFFSET (0x0000) #define MPFS_PLIC_MCLAIM_OFFSET (0x0004) #define MPFS_PLIC_STHRESHOLD_OFFSET (0x1000) -#define MPFS_PLIC_SCLAIM_OFFSET (0x1004) +#define MPFS_PLIC_SCLAIM_OFFSET (0x1004) /* From hart base */ +#define MPFS_PLIC_CLAIM_S_OFFSET (0x1000) /* From mclaim to sclaim */ +#define MPFS_PLIC_THRESHOLD_S_OFFSET (0x1000) /* From mthresh to sthresh */ #define MPFS_PLIC_H0_MTHRESHOLD (MPFS_PLIC_BASE + 0x200000) #define MPFS_PLIC_H0_MCLAIM (MPFS_PLIC_BASE + 0x200004) diff --git a/arch/risc-v/src/mpfs/mpfs_allocateheap.c b/arch/risc-v/src/mpfs/mpfs_allocateheap.c index 8a27c4cd5799e..1af53b4be49de 100755 --- a/arch/risc-v/src/mpfs/mpfs_allocateheap.c +++ b/arch/risc-v/src/mpfs/mpfs_allocateheap.c @@ -28,8 +28,6 @@ #include #include -#include -#include #ifdef CONFIG_MM_KERNEL_HEAP #include @@ -89,9 +87,9 @@ ****************************************************************************/ #ifdef CONFIG_BUILD_KERNEL -void up_allocate_kheap(FAR void **heap_start, size_t *heap_size) +void up_allocate_kheap(void **heap_start, size_t *heap_size) #else -void up_allocate_heap(FAR void **heap_start, size_t *heap_size) +void up_allocate_heap(void **heap_start, size_t *heap_size) #endif /* CONFIG_BUILD_KERNEL */ { #if defined(CONFIG_BUILD_PROTECTED) && defined(CONFIG_MM_KERNEL_HEAP) diff --git a/arch/risc-v/src/mpfs/mpfs_emmcsd.c b/arch/risc-v/src/mpfs/mpfs_emmcsd.c index 684f91c37f0f1..10a72ec34b58f 100755 --- a/arch/risc-v/src/mpfs/mpfs_emmcsd.c +++ b/arch/risc-v/src/mpfs/mpfs_emmcsd.c @@ -2892,7 +2892,7 @@ static void mpfs_callback(void *arg) mcinfo("Queuing callback to %p(%p)\n", priv->callback, priv->cbarg); - work_queue(HPWORK, &priv->cbwork, (worker_t)priv->callback, + work_queue(HPWORK, &priv->cbwork, priv->callback, priv->cbarg, 0); } else diff --git a/arch/risc-v/src/mpfs/mpfs_ethernet.c b/arch/risc-v/src/mpfs/mpfs_ethernet.c index 30f75f84e8654..1c687a6bd093a 100644 --- a/arch/risc-v/src/mpfs/mpfs_ethernet.c +++ b/arch/risc-v/src/mpfs/mpfs_ethernet.c @@ -468,7 +468,7 @@ static int mpfs_interrupt_0(int irq, void *context, void *arg) return OK; } -static int mpfs_interrupt_1(int irq, void *context, FAR void *arg) +static int mpfs_interrupt_1(int irq, void *context, void *arg) { struct mpfs_ethmac_s *priv = (struct mpfs_ethmac_s *)arg; UNUSED(priv); @@ -479,7 +479,7 @@ static int mpfs_interrupt_1(int irq, void *context, FAR void *arg) return 0; } -static int mpfs_interrupt_2(int irq, void *context, FAR void *arg) +static int mpfs_interrupt_2(int irq, void *context, void *arg) { struct mpfs_ethmac_s *priv = (struct mpfs_ethmac_s *)arg; UNUSED(priv); @@ -490,7 +490,7 @@ static int mpfs_interrupt_2(int irq, void *context, FAR void *arg) return 0; } -static int mpfs_interrupt_3(int irq, void *context, FAR void *arg) +static int mpfs_interrupt_3(int irq, void *context, void *arg) { struct mpfs_ethmac_s *priv = (struct mpfs_ethmac_s *)arg; UNUSED(priv); diff --git a/arch/risc-v/src/mpfs/mpfs_head.S b/arch/risc-v/src/mpfs/mpfs_head.S index 94baa804d5e63..30c94f513e899 100755 --- a/arch/risc-v/src/mpfs/mpfs_head.S +++ b/arch/risc-v/src/mpfs/mpfs_head.S @@ -23,8 +23,8 @@ ****************************************************************************/ #include -#include -#include + +#include #include "chip.h" #include "mpfs_memorymap.h" @@ -100,6 +100,17 @@ __start: csrr a0, mhartid beqz a0, .skip_e51 + /* Clear sscratch if u54 */ + + csrw sscratch, zero + csrw scause, zero + csrw sepc, zero + + /* Disable all interrupts in sie */ + + csrw sie, zero + csrw sip, zero + /* Init delegation registers, mideleg, medeleg, if a U54 * These are not initialised by the hardware and come up in a random state */ @@ -116,20 +127,6 @@ __start: sfence.vma x0, x0 - /* enable FPU and accelerator if present, setting ignored on E51 - * 15,16 = MSTATUS_XS, 17,18 = MSTATUS_MPRV - * not defined on riscv-v/include/csr.h - */ - - /* li t0, MSTATUS_FS_DIRTY | (1 << 15) | (1 << 16) | (1 << 17) | (1 << 18) */ - li t0, 0x00006000 | 0x00018000 /* MSTATUS_FS | MSTATUS_XS */ - csrs mstatus, t0 - - /* Init floating point control register to zero */ -#ifdef __riscv_flen - fscsr x0 -#endif - .skip_e51: /* initialize global pointer, global data diff --git a/arch/risc-v/src/mpfs/mpfs_irq.c b/arch/risc-v/src/mpfs/mpfs_irq.c index c99574a77a2da..cff60f6d90d96 100755 --- a/arch/risc-v/src/mpfs/mpfs_irq.c +++ b/arch/risc-v/src/mpfs/mpfs_irq.c @@ -30,8 +30,7 @@ #include #include -#include -#include +#include #include "riscv_internal.h" #include "mpfs.h" @@ -57,10 +56,6 @@ void up_irqinitialize(void) up_irq_save(); - /* Disable timer interrupt (in case of hotloading with debugger) */ - - up_disable_irq(RISCV_IRQ_MTIMER); - /* Disable all global interrupts for current hart */ uintptr_t iebase = mpfs_plic_get_iebase(); @@ -103,13 +98,9 @@ void up_irqinitialize(void) CURRENT_REGS = NULL; - /* Attach the ecall interrupt handler */ + /* Attach the common interrupt handler */ - irq_attach(RISCV_IRQ_ECALLM, riscv_swint, NULL); - -#ifndef CONFIG_BUILD_FLAT - irq_attach(RISCV_IRQ_ECALLU, riscv_swint, NULL); -#endif + riscv_exception_attach(); #ifndef CONFIG_SUPPRESS_INTERRUPTS @@ -131,17 +122,17 @@ void up_disable_irq(int irq) { int extirq = 0; - if (irq == RISCV_IRQ_MSOFT) + if (irq == RISCV_IRQ_SOFT) { - /* Read mstatus & clear machine software interrupt enable in mie */ + /* Read m/sstatus & clear machine software interrupt enable in m/sie */ - CLEAR_CSR(mie, MIE_MSIE); + CLEAR_CSR(CSR_IE, IE_SIE); } - else if (irq == RISCV_IRQ_MTIMER) + else if (irq == RISCV_IRQ_TIMER) { - /* Read mstatus & clear machine timer interrupt enable in mie */ + /* Read m/sstatus & clear timer interrupt enable in m/sie */ - CLEAR_CSR(mie, MIE_MTIE); + CLEAR_CSR(CSR_IE, IE_TIE); } else if (irq >= MPFS_IRQ_EXT_START) { @@ -174,17 +165,17 @@ void up_enable_irq(int irq) { int extirq; - if (irq == RISCV_IRQ_MSOFT) + if (irq == RISCV_IRQ_SOFT) { - /* Read mstatus & set machine software interrupt enable in mie */ + /* Read m/sstatus & set machine software interrupt enable in m/sie */ - SET_CSR(mie, MIE_MSIE); + SET_CSR(CSR_IE, IE_SIE); } - else if (irq == RISCV_IRQ_MTIMER) + else if (irq == RISCV_IRQ_TIMER) { - /* Read mstatus & set machine timer interrupt enable in mie */ + /* Read m/sstatus & set timer interrupt enable in m/sie */ - SET_CSR(mie, MIE_MTIE); + SET_CSR(CSR_IE, IE_TIE); } else if (irq >= MPFS_IRQ_EXT_START) { @@ -229,12 +220,13 @@ irqstate_t up_irq_enable(void) { irqstate_t oldstat; - /* Enable MEIE (machine external interrupt enable) */ + /* Enable external interrupts (mie/sie) */ + + SET_CSR(CSR_IE, IE_EIE); - SET_CSR(mie, MIE_MEIE); + /* Read and enable global interrupts (M/SIE) in m/sstatus */ - /* Read mstatus & set machine interrupt enable (MIE) in mstatus */ + oldstat = READ_AND_SET_CSR(CSR_STATUS, STATUS_IE); - oldstat = READ_AND_SET_CSR(mstatus, MSTATUS_MIE); return oldstat; } diff --git a/arch/risc-v/src/mpfs/mpfs_irq_dispatch.c b/arch/risc-v/src/mpfs/mpfs_irq_dispatch.c index 1e420c0c78cbc..961fd0c701706 100755 --- a/arch/risc-v/src/mpfs/mpfs_irq_dispatch.c +++ b/arch/risc-v/src/mpfs/mpfs_irq_dispatch.c @@ -29,8 +29,7 @@ #include #include -#include -#include +#include #include "riscv_internal.h" @@ -51,20 +50,6 @@ void *riscv_dispatch_irq(uintptr_t vector, uintptr_t *regs) { int irq = (vector & 0x3f); - uintptr_t *mepc = regs; - - board_autoled_on(LED_INIRQ); - - /* Check if fault happened */ - - if (vector < RISCV_IRQ_ECALLU || - vector == RISCV_IRQ_INSTRUCTIONPF || - vector == RISCV_IRQ_LOADPF || - vector == RISCV_IRQ_SROREPF || - vector == RISCV_IRQ_RESERVED) - { - riscv_fault(irq, regs); - } if ((vector & RISCV_IRQ_BIT) != 0) { @@ -75,45 +60,26 @@ void *riscv_dispatch_irq(uintptr_t vector, uintptr_t *regs) uintptr_t claim_address = mpfs_plic_get_claimbase(); - if (irq == RISCV_IRQ_MEXT) + if (irq == RISCV_IRQ_EXT) { uint32_t ext = getreg32(claim_address); - /* Add the value to nuttx irq which is offset to the mext */ + /* Add the value to nuttx irq which is offset to the ext */ irq = MPFS_IRQ_EXT_START + ext; } - /* NOTE: In case of ecall, we need to adjust mepc in the context */ - - if (irq == RISCV_IRQ_ECALLM || irq == RISCV_IRQ_ECALLU) - { - *mepc += 4; - } - /* Acknowledge the interrupt */ riscv_ack_irq(irq); -#ifdef CONFIG_SUPPRESS_INTERRUPTS - PANIC(); -#else - /* Current regs non-zero indicates that we are processing an interrupt; - * CURRENT_REGS is also used to manage interrupt level context switches. - * - * Nested interrupts are not supported - */ - - ASSERT(CURRENT_REGS == NULL); - CURRENT_REGS = regs; - - /* MEXT means no interrupt */ + /* EXT means no interrupt */ - if (irq != RISCV_IRQ_MEXT && irq != MPFS_IRQ_INVALID) + if (irq != RISCV_IRQ_EXT && irq != MPFS_IRQ_INVALID) { /* Deliver the IRQ */ - irq_dispatch(irq, regs); + regs = riscv_doirq(irq, regs); } if (irq > MPFS_IRQ_EXT_START) @@ -123,46 +89,5 @@ void *riscv_dispatch_irq(uintptr_t vector, uintptr_t *regs) putreg32(irq - MPFS_IRQ_EXT_START, claim_address); } -#if defined(CONFIG_ARCH_FPU) || defined(CONFIG_ARCH_ADDRENV) - /* Check for a context switch. If a context switch occurred, then - * CURRENT_REGS will have a different value than it did on entry. If an - * interrupt level context switch has occurred, then restore the floating - * point state and the establish the correct address environment before - * returning from the interrupt. - */ - - if (regs != CURRENT_REGS) - { -#ifdef CONFIG_ARCH_FPU - /* Restore floating point registers */ - - riscv_restorefpu((uintptr_t *)CURRENT_REGS); -#endif - -#ifdef CONFIG_ARCH_ADDRENV - /* Make sure that the address environment for the previously - * running task is closed down gracefully (data caches dump, - * MMU flushed) and set up the address environment for the new - * thread at the head of the ready-to-run list. - */ - - group_addrenv(NULL); -#endif - } -#endif - -#endif - - /* If a context switch occurred while processing the interrupt then - * CURRENT_REGS may have change value. If we return any value different - * from the input regs, then the lower level will know that a context - * switch occurred during interrupt processing. - */ - - regs = (uintptr_t *)CURRENT_REGS; - CURRENT_REGS = NULL; - - board_autoled_off(LED_INIRQ); - return regs; } diff --git a/arch/risc-v/src/mpfs/mpfs_mm_init.c b/arch/risc-v/src/mpfs/mpfs_mm_init.c new file mode 100644 index 0000000000000..8a35df4b6c0b6 --- /dev/null +++ b/arch/risc-v/src/mpfs/mpfs_mm_init.c @@ -0,0 +1,144 @@ +/**************************************************************************** + * arch/risc-v/src/mpfs/mpfs_mm_init.c + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include +#include + +#include +#include +#include + +#include + +#include "mpfs_memorymap.h" + +#include "riscv_internal.h" +#include "riscv_mmu.h" + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/* Map the whole I/O memory with vaddr = paddr mappings */ + +#define MMU_IO_BASE (0x00000000) +#define MMU_IO_SIZE (0x80000000) + +/* Physical and virtual addresses to page tables (vaddr = paddr mapping) */ + +#define PGT_L1_PBASE (uintptr_t)&m_l1_pgtable +#define PGT_L2_PBASE (uintptr_t)&m_l2_pgtable +#define PGT_L3_PBASE (uintptr_t)&m_l3_pgtable +#define PGT_L1_VBASE PGT_L1_PBASE +#define PGT_L2_VBASE PGT_L2_PBASE +#define PGT_L3_VBASE PGT_L3_PBASE + +#define PGT_L1_SIZE (512) /* Enough to map 512 GiB */ +#define PGT_L2_SIZE (512) /* Enough to map 1 GiB */ +#define PGT_L3_SIZE (1024) /* Enough to map 4 MiB */ + +/**************************************************************************** + * Private Data + ****************************************************************************/ + +/* Kernel mappings simply here, mapping is vaddr=paddr */ + +static uint64_t m_l1_pgtable[PGT_L1_SIZE] locate_data(".pgtables"); +static uint64_t m_l2_pgtable[PGT_L2_SIZE] locate_data(".pgtables"); +static uint64_t m_l3_pgtable[PGT_L3_SIZE] locate_data(".pgtables"); + +/* Kernel mappings (L1 base) */ + +uintptr_t g_kernel_mappings = PGT_L1_VBASE; +uintptr_t g_kernel_pgt_pbase = PGT_L1_PBASE; + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +static void map_region(uintptr_t paddr, uintptr_t vaddr, size_t size, + uint32_t mmuflags) +{ + uintptr_t l3base; + uintptr_t end_vaddr; + + /* Start index for the L3 table, kernel flash is always first */ + + l3base = PGT_L3_PBASE + ((paddr - KFLASH_START) / RV_MMU_PAGE_ENTRIES); + + /* Map the region to the L3 table as a whole */ + + mmu_ln_map_region(3, l3base, paddr, vaddr, size, mmuflags); + + /* Connect to L2 table */ + + end_vaddr = vaddr + size; + while (vaddr < end_vaddr) + { + mmu_ln_setentry(2, PGT_L2_VBASE, l3base, vaddr, PTE_G); + l3base += RV_MMU_L3_PAGE_SIZE; + vaddr += RV_MMU_L2_PAGE_SIZE; + } +} + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: mpfs_kernel_mappings + * + * Description: + * Setup kernel mappings when usinc CONFIG_BUILD_KERNEL. Sets up the kernel + * MMU mappings. + * + ****************************************************************************/ + +void mpfs_kernel_mappings(void) +{ + /* Begin mapping memory to MMU; note that at this point the MMU is not yet + * active, so the page table virtual addresses are actually physical + * addresses and so forth. M-mode does not perform translations anyhow, so + * this mapping is quite simple to do + */ + + /* Map I/O region, use 2 gigapages for this */ + + mmu_ln_map_region(1, PGT_L1_VBASE, MMU_IO_BASE, MMU_IO_BASE, + MMU_IO_SIZE, MMU_IO_FLAGS); + + /* Map the kernel text and data */ + + map_region(KFLASH_START, KFLASH_START, KFLASH_SIZE, MMU_KTEXT_FLAGS); + map_region(KSRAM_START, KSRAM_START, KSRAM_SIZE, MMU_KDATA_FLAGS); + + /* Connect the L1 and L2 page tables */ + + mmu_ln_setentry(1, PGT_L1_VBASE, PGT_L2_PBASE, KFLASH_START, PTE_G); + + /* Map the page pool */ + + mmu_ln_map_region(2, PGT_L2_VBASE, PGPOOL_START, PGPOOL_START, PGPOOL_SIZE, + MMU_KDATA_FLAGS); +} diff --git a/arch/risc-v/src/mpfs/mpfs_mm_init.h b/arch/risc-v/src/mpfs/mpfs_mm_init.h new file mode 100644 index 0000000000000..5fa67f6290968 --- /dev/null +++ b/arch/risc-v/src/mpfs/mpfs_mm_init.h @@ -0,0 +1,81 @@ +/**************************************************************************** + * arch/risc-v/src/mpfs/mpfs_mm_init.h + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +#ifndef __ARCH_RISC_V_SRC_MPFS_MPFS_MM_INIT_H +#define __ARCH_RISC_V_SRC_MPFS_MPFS_MM_INIT_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include "riscv_mmu.h" + +/**************************************************************************** + * Public Data + ****************************************************************************/ + +extern uintptr_t g_kernel_pgt_pbase; + +/**************************************************************************** + * Public Functions Prototypes + ****************************************************************************/ + +/**************************************************************************** + * Name: mpfs_kernel_mappings + * + * Description: + * Setup kernel mappings when using CONFIG_BUILD_KERNEL. Sets up the kernel + * MMU mappings. + * + ****************************************************************************/ + +#ifdef CONFIG_BUILD_KERNEL +void mpfs_kernel_mappings(void); +#endif + +/**************************************************************************** + * Name: mpfs_mm_init + * + * Description: + * Setup kernel mappings when using CONFIG_BUILD_KERNEL. Sets up kernel MMU + * mappings. Function also sets the first address environment (satp value). + * + ****************************************************************************/ + +#ifdef CONFIG_BUILD_KERNEL +static inline void mpfs_mm_init(void) +{ + /* Setup the kernel mappings */ + + mpfs_kernel_mappings(); + + /* Allow satp writes from S-mode */ + + CLEAR_CSR(mstatus, MSTATUS_TVM); + + /* Enable MMU (note: system is still in M-mode) */ + + mmu_enable(g_kernel_pgt_pbase, 0); +} +#endif + +#endif /* __ARCH_RISC_V_SRC_MPFS_MPFS_MM_INIT_H */ diff --git a/arch/arm/src/armv7-r/arm_fullcontextrestore.S b/arch/risc-v/src/mpfs/mpfs_pgalloc.c similarity index 71% rename from arch/arm/src/armv7-r/arm_fullcontextrestore.S rename to arch/risc-v/src/mpfs/mpfs_pgalloc.c index 16ccc60d4c44a..d48dd19b7c3a3 100644 --- a/arch/arm/src/armv7-r/arm_fullcontextrestore.S +++ b/arch/risc-v/src/mpfs/mpfs_pgalloc.c @@ -1,5 +1,5 @@ /**************************************************************************** - * arch/arm/src/armv7-r/arm_fullcontextrestore.S + * arch/risc-v/src/mpfs/mpfs_pgalloc.c * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with @@ -22,22 +22,25 @@ * Included Files ****************************************************************************/ +#include #include -#include -#include +#include + +#include +#include + +#include /**************************************************************************** * Pre-processor Definitions ****************************************************************************/ /**************************************************************************** - * Public Symbols + * Private Data ****************************************************************************/ - .file "arm_fullcontextrestore.S" - /**************************************************************************** - * Macros + * Public Data ****************************************************************************/ /**************************************************************************** @@ -45,30 +48,20 @@ ****************************************************************************/ /**************************************************************************** - * Name: arm_fullcontextrestore + * Name: up_allocate_pgheap * * Description: - * Restore the current thread context. Full prototype is: - * - * void arm_fullcontextrestore(uint32_t *restoreregs) noreturn_function; - * - * Returned Value: - * None + * If there is a page allocator in the configuration, then this function + * must be provided by the platform-specific code. The OS initialization + * logic will call this function early in the initialization sequence to + * get the page heap information needed to configure the page allocator. * ****************************************************************************/ - .globl arm_fullcontextrestore - .type arm_fullcontextrestore, function -arm_fullcontextrestore: - - /* Perform the System call with R0=1 and R1=regs */ - - mov r1, r0 /* R1: regs */ - mov r0, #SYS_restore_context /* R0: restore context */ - svc #SYS_syscall /* Force synchronous SVCall (or Hard Fault) */ - - /* This call should not return */ +void up_allocate_pgheap(void **heap_start, size_t *heap_size) +{ + DEBUGASSERT(heap_start && heap_size); - bx lr /* Unnecessary ... will not return */ - .size arm_fullcontextrestore, .-arm_fullcontextrestore - .end + *heap_start = (void *)PGPOOL_START; + *heap_size = (size_t)PGPOOL_SIZE; +} diff --git a/arch/risc-v/src/mpfs/mpfs_plic.c b/arch/risc-v/src/mpfs/mpfs_plic.c index 98277ae05bd2b..3de194c2e1c35 100644 --- a/arch/risc-v/src/mpfs/mpfs_plic.c +++ b/arch/risc-v/src/mpfs/mpfs_plic.c @@ -39,6 +39,18 @@ * Pre-processor Definitions ****************************************************************************/ +/* Offset to privilege mode, note that hart0 does not have S-mode */ + +#ifdef CONFIG_ARCH_USE_S_MODE +# define MPFS_PLIC_IEPRIV_OFFSET (MPFS_HART_SIE_OFFSET) +# define MPFS_PLIC_CLAIMPRIV_OFFSET (MPFS_PLIC_CLAIM_S_OFFSET) +# define MPFS_PLIC_THRESHOLDPRIV_OFFSET (MPFS_PLIC_THRESHOLD_S_OFFSET) +#else +# define MPFS_PLIC_IEPRIV_OFFSET (0) +# define MPFS_PLIC_CLAIMPRIV_OFFSET (0) +# define MPFS_PLIC_THRESHOLDPRIV_OFFSET (0) +#endif + /**************************************************************************** * Public Functions ****************************************************************************/ @@ -65,7 +77,8 @@ uintptr_t mpfs_plic_get_iebase(void) } else { - iebase = MPFS_PLIC_H1_MIE0 + (hart_id - 1) * MPFS_HART_MIE_OFFSET; + iebase = MPFS_PLIC_H1_MIE0 + MPFS_PLIC_IEPRIV_OFFSET + + (hart_id - 1) * MPFS_HART_MIE_OFFSET; } return iebase; @@ -93,7 +106,7 @@ uintptr_t mpfs_plic_get_claimbase(void) } else { - claim_address = MPFS_PLIC_H1_MCLAIM + + claim_address = MPFS_PLIC_H1_MCLAIM + MPFS_PLIC_CLAIMPRIV_OFFSET + (hart_id - 1) * MPFS_PLIC_NEXTHART_OFFSET; } @@ -123,7 +136,8 @@ uintptr_t mpfs_plic_get_thresholdbase(void) else { threshold_address = MPFS_PLIC_H1_MTHRESHOLD + - (hart_id - 1) * MPFS_PLIC_NEXTHART_OFFSET; + MPFS_PLIC_THRESHOLDPRIV_OFFSET + + (hart_id - 1) * MPFS_PLIC_NEXTHART_OFFSET; } return threshold_address; diff --git a/arch/risc-v/src/mpfs/mpfs_start.c b/arch/risc-v/src/mpfs/mpfs_start.c index d197c0156d4d5..cf73953451197 100755 --- a/arch/risc-v/src/mpfs/mpfs_start.c +++ b/arch/risc-v/src/mpfs/mpfs_start.c @@ -33,8 +33,11 @@ #include "mpfs_clockconfig.h" #include "mpfs_ddr.h" #include "mpfs_cache.h" +#include "mpfs_mm_init.h" #include "mpfs_userspace.h" + #include "riscv_internal.h" +#include "riscv_percpu.h" /**************************************************************************** * Pre-processor Definitions @@ -46,6 +49,10 @@ # define showprogress(c) #endif +#if defined (CONFIG_BUILD_KERNEL) && !defined (CONFIG_ARCH_USE_S_MODE) +# error "Target requires kernel in S-mode, enable CONFIG_ARCH_USE_S_MODE" +#endif + /**************************************************************************** * Public Data ****************************************************************************/ @@ -116,6 +123,13 @@ void __mpfs_start(uint64_t mhartid) const uint32_t *src; uint32_t *dest; + /* Configure FPU (hart 0 don't have an FPU) */ + + if (mhartid != 0) + { + riscv_fpuconfig(); + } + /* Clear .bss. We'll do this inline (vs. calling memset) just to be * certain that there are no issues with the state of global variables. */ @@ -162,6 +176,15 @@ void __mpfs_start(uint64_t mhartid) mpfs_boardinitialize(); +#ifdef CONFIG_ARCH_USE_S_MODE + /* Initialize the per CPU areas */ + + if (mhartid != 0) + { + riscv_percpu_add_hart(mhartid); + } +#endif /* CONFIG_ARCH_USE_S_MODE */ + /* Initialize the caches. Should only be executed from E51 (hart 0) to be * functional. Consider the caches already configured if running without * the CONFIG_MPFS_BOOTLOADER -option. @@ -187,6 +210,10 @@ void __mpfs_start(uint64_t mhartid) showprogress('D'); #endif +#ifdef CONFIG_BUILD_KERNEL + mpfs_mm_init(); +#endif + /* Call nx_start() */ nx_start(); diff --git a/arch/risc-v/src/mpfs/mpfs_systemreset.c b/arch/risc-v/src/mpfs/mpfs_systemreset.c index 26478a519d952..38fd7143673c9 100644 --- a/arch/risc-v/src/mpfs/mpfs_systemreset.c +++ b/arch/risc-v/src/mpfs/mpfs_systemreset.c @@ -27,7 +27,6 @@ #include #include -#include #include "riscv_internal.h" #include "hardware/mpfs_memorymap.h" diff --git a/arch/risc-v/src/mpfs/mpfs_timerisr.c b/arch/risc-v/src/mpfs/mpfs_timerisr.c index b9db1e760d23c..3a43fa278f18e 100755 --- a/arch/risc-v/src/mpfs/mpfs_timerisr.c +++ b/arch/risc-v/src/mpfs/mpfs_timerisr.c @@ -24,6 +24,7 @@ #include +#include #include #include #include @@ -31,8 +32,11 @@ #include #include #include +#include +#include "hardware/mpfs_clint.h" #include "riscv_internal.h" +#include "riscv_mtimer.h" #include "mpfs.h" #include "mpfs_clockconfig.h" @@ -41,62 +45,7 @@ * Pre-processor Definitions ****************************************************************************/ -#define TICK_COUNT (MPFS_MSS_RTC_TOGGLE_CLK / TICK_PER_SEC) - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -static bool _b_tick_started; -static uint64_t *_mtime_cmp; - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: mpfs_reload_mtimecmp - ****************************************************************************/ - -static void mpfs_reload_mtimecmp(void) -{ - irqstate_t flags = spin_lock_irqsave(NULL); - - uint64_t current; - uint64_t next; - - if (!_b_tick_started) - { - _b_tick_started = true; - current = getreg64(MPFS_CLINT_MTIME); - } - else - { - current = getreg64(_mtime_cmp); - } - - uint64_t tick = TICK_COUNT; - next = current + tick; - - putreg64(next, _mtime_cmp); - - spin_unlock_irqrestore(NULL, flags); -} - -/**************************************************************************** - * Name: mpfs_timerisr - ****************************************************************************/ - -static int mpfs_timerisr(int irq, void *context, void *arg) -{ - mpfs_reload_mtimecmp(); - - /* Process timer interrupt */ - - nxsched_process_timer(); - - return 0; -} +#define MTIMER_FREQ MPFS_MSS_RTC_TOGGLE_CLK /**************************************************************************** * Public Functions @@ -116,17 +65,12 @@ void up_timer_initialize(void) /* what is our timecmp address for this hart */ uintptr_t hart_id = riscv_mhartid(); - _mtime_cmp = (uint64_t *)MPFS_CLINT_MTIMECMP0 + hart_id; - - /* Attach timer interrupt handler */ - - irq_attach(RISCV_IRQ_MTIMER, mpfs_timerisr, NULL); - - /* Reload CLINT mtimecmp */ - mpfs_reload_mtimecmp(); + struct oneshot_lowerhalf_s *lower = riscv_mtimer_initialize( + MPFS_CLINT_MTIME, MPFS_CLINT_MTIMECMP0 + hart_id * sizeof(uintptr_t), + RISCV_IRQ_TIMER, MTIMER_FREQ); - /* And enable the timer interrupt */ + DEBUGASSERT(lower); - up_enable_irq(RISCV_IRQ_MTIMER); + up_alarm_set_lowerhalf(lower); } diff --git a/arch/risc-v/src/mpfs/mpfs_usb.c b/arch/risc-v/src/mpfs/mpfs_usb.c index b82951d1eba69..1e47fbbf2c8d5 100755 --- a/arch/risc-v/src/mpfs/mpfs_usb.c +++ b/arch/risc-v/src/mpfs/mpfs_usb.c @@ -2098,7 +2098,7 @@ static int mpfs_getframe(struct usbdev_s *dev) return frameno; } -void mpfs_usb_suspend(FAR struct usbdev_s *dev, bool resume) +void mpfs_usb_suspend(struct usbdev_s *dev, bool resume) { } diff --git a/arch/risc-v/src/opensbi/Make.defs b/arch/risc-v/src/opensbi/Make.defs index 27bd894b2f3bd..7afb7fd67dc42 100644 --- a/arch/risc-v/src/opensbi/Make.defs +++ b/arch/risc-v/src/opensbi/Make.defs @@ -30,6 +30,7 @@ OPENSBI_CSRCS += opensbi/opensbi-3rdparty/lib/utils/timer/aclint_mtimer.c OPENSBI_ASRCS += opensbi/opensbi-3rdparty/lib/sbi/sbi_expected_trap.S OPENSBI_ASRCS += opensbi/opensbi-3rdparty/lib/sbi/sbi_hfence.S +OPENSBI_ASRCS += opensbi/opensbi-3rdparty/lib/sbi/riscv_hardfp.S OPENSBI_UNPACK = opensbi-3rdparty OPENSBI_COMMIT = 4998a712b2ab504eff306110879ee05af6050177 diff --git a/arch/risc-v/src/qemu-rv/Make.defs b/arch/risc-v/src/qemu-rv/Make.defs index e4e9e3b05637c..74fc60a903805 100644 --- a/arch/risc-v/src/qemu-rv/Make.defs +++ b/arch/risc-v/src/qemu-rv/Make.defs @@ -26,7 +26,7 @@ HEAD_ASRC = qemu_rv_head.S CMN_ASRCS += riscv_vectors.S riscv_exception_common.S # Specify C code within the common directory to be included -CMN_CSRCS += riscv_initialize.c riscv_swint.c +CMN_CSRCS += riscv_initialize.c riscv_swint.c riscv_mtimer.c CMN_CSRCS += riscv_allocateheap.c riscv_createstack.c riscv_exit.c CMN_CSRCS += riscv_assert.c riscv_blocktask.c riscv_copystate.c riscv_initialstate.c CMN_CSRCS += riscv_interruptcontext.c riscv_modifyreg32.c riscv_puts.c @@ -34,10 +34,12 @@ CMN_CSRCS += riscv_releasepending.c riscv_reprioritizertr.c CMN_CSRCS += riscv_releasestack.c riscv_stackframe.c riscv_schedulesigaction.c CMN_CSRCS += riscv_sigdeliver.c riscv_unblocktask.c riscv_usestack.c CMN_CSRCS += riscv_idle.c riscv_tcbinfo.c riscv_cpuidlestack.c -CMN_CSRCS += riscv_fault.c riscv_getnewintctx.c +CMN_CSRCS += riscv_exception.c riscv_getnewintctx.c riscv_doirq.c +CMN_CSRCS += riscv_saveusercontext.c ifeq ($(CONFIG_SMP), y) CMN_CSRCS += riscv_cpuindex.c riscv_cpupause.c riscv_cpustart.c +CMN_ASRCS += riscv_mhartid.S endif ifeq ($(CONFIG_SCHED_BACKTRACE),y) @@ -49,6 +51,7 @@ CMN_CSRCS += riscv_checkstack.c endif ifeq ($(CONFIG_ARCH_HAVE_VFORK),y) +CMN_ASRCS += vfork.S CMN_CSRCS += riscv_vfork.c endif @@ -58,12 +61,18 @@ endif ifeq ($(CONFIG_ARCH_FPU),y) CMN_ASRCS += riscv_fpu.S +CMN_CSRCS += riscv_fpucmp.c endif ifeq ($(CONFIG_ARCH_RV_ISA_A),y) CMN_ASRCS += riscv_testset.S endif +ifeq ($(CONFIG_RISCV_SEMIHOSTING_HOSTFS),y) +CMN_ASRCS += riscv_semihost.S +CMN_CSRCS += riscv_hostfs.c +endif + # Specify our C code within this directory to be included CHIP_CSRCS = qemu_rv_start.c qemu_rv_irq_dispatch.c qemu_rv_irq.c CHIP_CSRCS += qemu_rv_timerisr.c diff --git a/arch/risc-v/src/qemu-rv/chip.h b/arch/risc-v/src/qemu-rv/chip.h index 6f9ea47380acc..3d8d05d75f3df 100644 --- a/arch/risc-v/src/qemu-rv/chip.h +++ b/arch/risc-v/src/qemu-rv/chip.h @@ -38,7 +38,7 @@ extern void up_earlyserialinit(void); extern void up_serialinit(void); -#endif +#endif /* __ASSEMBLY__ */ #include "qemu_rv_memorymap.h" @@ -46,4 +46,32 @@ extern void up_serialinit(void); #include "hardware/qemu_rv_memorymap.h" #include "hardware/qemu_rv_plic.h" +#include "riscv_internal.h" + +/**************************************************************************** + * Macro Definitions + ****************************************************************************/ + +#ifdef __ASSEMBLY__ + +/**************************************************************************** + * Name: setintstack + * + * Description: + * Set the current stack pointer to the "top" the correct interrupt stack + * for the current CPU. + * + ****************************************************************************/ + +#if defined(CONFIG_SMP) && CONFIG_ARCH_INTERRUPTSTACK > 15 +.macro setintstack tmp0, tmp1 + csrr \tmp0, mhartid + li \tmp1, STACK_ALIGN_DOWN(CONFIG_ARCH_INTERRUPTSTACK) + mul \tmp1, \tmp0, \tmp1 + la \tmp0, g_intstacktop + sub sp, \tmp0, \tmp1 +.endm +#endif /* CONFIG_SMP && CONFIG_ARCH_INTERRUPTSTACK > 15 */ + +#endif /* __ASSEMBLY__ */ #endif /* __ARCH_RISCV_SRC_QEMU_RV_CHIP_H */ diff --git a/arch/risc-v/src/qemu-rv/qemu_rv_head.S b/arch/risc-v/src/qemu-rv/qemu_rv_head.S index 3f217f5084edc..7c2bba94caad4 100644 --- a/arch/risc-v/src/qemu-rv/qemu_rv_head.S +++ b/arch/risc-v/src/qemu-rv/qemu_rv_head.S @@ -23,6 +23,8 @@ ****************************************************************************/ #include + +#include #include #include "chip.h" @@ -72,11 +74,7 @@ __start: /* Load idle stack base to sp */ -#ifdef CONFIG_ARCH_RV32 - lw sp, 0(t0) -#else - ld sp, 0(t0) -#endif + REGLOAD sp, 0(t0) /* * sp (stack top) = sp + idle stack size - XCPTCONTEXT_SIZE diff --git a/arch/risc-v/src/qemu-rv/qemu_rv_irq.c b/arch/risc-v/src/qemu-rv/qemu_rv_irq.c index 36c4e89d41bf2..4951ab6eab10b 100644 --- a/arch/risc-v/src/qemu-rv/qemu_rv_irq.c +++ b/arch/risc-v/src/qemu-rv/qemu_rv_irq.c @@ -30,10 +30,7 @@ #include #include -#include -#include -#include -#include +#include #include "riscv_internal.h" #include "chip.h" @@ -87,9 +84,9 @@ void up_irqinitialize(void) CURRENT_REGS = NULL; - /* Attach the ecall interrupt handler */ + /* Attach the common interrupt handler */ - irq_attach(RISCV_IRQ_ECALLM, riscv_swint, NULL); + riscv_exception_attach(); #ifdef CONFIG_SMP /* Clear MSOFT for CPU0 */ diff --git a/arch/risc-v/src/qemu-rv/qemu_rv_irq_dispatch.c b/arch/risc-v/src/qemu-rv/qemu_rv_irq_dispatch.c index d709ad9019542..37037fd06c3e4 100644 --- a/arch/risc-v/src/qemu-rv/qemu_rv_irq_dispatch.c +++ b/arch/risc-v/src/qemu-rv/qemu_rv_irq_dispatch.c @@ -29,8 +29,7 @@ #include #include -#include -#include +#include #include "riscv_internal.h" #include "hardware/qemu_rv_memorymap.h" @@ -57,12 +56,6 @@ void *riscv_dispatch_irq(uintptr_t vector, uintptr_t *regs) { int irq = (vector >> RV_IRQ_MASK) | (vector & 0xf); - uintptr_t *mepc = regs; - - if (vector < RISCV_IRQ_ECALLM) - { - riscv_fault(irq, regs); - } /* Firstly, check if the irq is machine external interrupt */ @@ -75,32 +68,13 @@ void *riscv_dispatch_irq(uintptr_t vector, uintptr_t *regs) irq += val; } - /* NOTE: In case of ecall, we need to adjust mepc in the context */ - - if (RISCV_IRQ_ECALLM == irq) - { - *mepc += 4; - } - -#ifdef CONFIG_SUPPRESS_INTERRUPTS - PANIC(); -#else - /* Current regs non-zero indicates that we are processing an interrupt; - * CURRENT_REGS is also used to manage interrupt level context switches. - * - * Nested interrupts are not supported - */ - - DEBUGASSERT(CURRENT_REGS == NULL); - CURRENT_REGS = regs; - /* MEXT means no interrupt */ if (RISCV_IRQ_MEXT != irq) { /* Deliver the IRQ */ - irq_dispatch(irq, regs); + regs = riscv_doirq(irq, regs); } if (RISCV_IRQ_MEXT <= irq) @@ -109,36 +83,6 @@ void *riscv_dispatch_irq(uintptr_t vector, uintptr_t *regs) putreg32(irq - RISCV_IRQ_MEXT, QEMU_RV_PLIC_CLAIM); } -#endif - - /* Check for a context switch. If a context switch occurred, then - * CURRENT_REGS will have a different value than it did on entry. If an - * interrupt level context switch has occurred, then restore the floating - * point state and the establish the correct address environment before - * returning from the interrupt. - */ - - if (regs != CURRENT_REGS) - { -#ifdef CONFIG_ARCH_ADDRENV - /* Make sure that the address environment for the previously - * running task is closed down gracefully (data caches dump, - * MMU flushed) and set up the address environment for the new - * thread at the head of the ready-to-run list. - */ - - group_addrenv(NULL); -#endif - } - - /* If a context switch occurred while processing the interrupt then - * CURRENT_REGS may have change value. If we return any value different - * from the input regs, then the lower level will know that a context - * switch occurred during interrupt processing. - */ - - regs = (uintptr_t *)CURRENT_REGS; - CURRENT_REGS = NULL; return regs; } diff --git a/arch/risc-v/src/qemu-rv/qemu_rv_start.c b/arch/risc-v/src/qemu-rv/qemu_rv_start.c index 9e612e51449a2..f1a9f4e73d780 100644 --- a/arch/risc-v/src/qemu-rv/qemu_rv_start.c +++ b/arch/risc-v/src/qemu-rv/qemu_rv_start.c @@ -63,6 +63,10 @@ void qemu_rv_start(int mhartid) { uint32_t *dest; + /* Configure FPU */ + + riscv_fpuconfig(); + if (mhartid > 0) { goto cpux; diff --git a/arch/risc-v/src/qemu-rv/qemu_rv_timerisr.c b/arch/risc-v/src/qemu-rv/qemu_rv_timerisr.c index a5bd062e6e986..ef1d6229804ea 100644 --- a/arch/risc-v/src/qemu-rv/qemu_rv_timerisr.c +++ b/arch/risc-v/src/qemu-rv/qemu_rv_timerisr.c @@ -24,6 +24,7 @@ #include +#include #include #include #include @@ -31,9 +32,11 @@ #include #include #include +#include #include #include "riscv_internal.h" +#include "riscv_mtimer.h" #include "hardware/qemu_rv_memorymap.h" #include "hardware/qemu_rv_clint.h" @@ -41,61 +44,7 @@ * Pre-processor Definitions ****************************************************************************/ -#define getreg64(a) (*(volatile uint64_t *)(a)) -#define putreg64(v,a) (*(volatile uint64_t *)(a) = (v)) - -#define TICK_COUNT (10000000 / TICK_PER_SEC) - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -static bool _b_tick_started = false; - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: qemu_rv_reload_mtimecmp - ****************************************************************************/ - -static void qemu_rv_reload_mtimecmp(void) -{ - irqstate_t flags = spin_lock_irqsave(NULL); - - uint64_t current; - uint64_t next; - - if (!_b_tick_started) - { - _b_tick_started = true; - current = getreg64(QEMU_RV_CLINT_MTIME); - } - else - { - current = getreg64(QEMU_RV_CLINT_MTIMECMP); - } - - next = current + TICK_COUNT; - putreg64(next, QEMU_RV_CLINT_MTIMECMP); - - spin_unlock_irqrestore(NULL, flags); -} - -/**************************************************************************** - * Name: qemu_rv_timerisr - ****************************************************************************/ - -static int qemu_rv_timerisr(int irq, void *context, void *arg) -{ - qemu_rv_reload_mtimecmp(); - - /* Process timer interrupt */ - - nxsched_process_timer(); - return 0; -} +#define MTIMER_FREQ 10000000 /**************************************************************************** * Public Functions @@ -112,15 +61,11 @@ static int qemu_rv_timerisr(int irq, void *context, void *arg) void up_timer_initialize(void) { - /* Attach timer interrupt handler */ - - irq_attach(RISCV_IRQ_MTIMER, qemu_rv_timerisr, NULL); - - /* Reload CLINT mtimecmp */ - - qemu_rv_reload_mtimecmp(); + struct oneshot_lowerhalf_s *lower = riscv_mtimer_initialize( + QEMU_RV_CLINT_MTIME, QEMU_RV_CLINT_MTIMECMP, + RISCV_IRQ_MTIMER, MTIMER_FREQ); - /* And enable the timer interrupt */ + DEBUGASSERT(lower); - up_enable_irq(RISCV_IRQ_MTIMER); + up_alarm_set_lowerhalf(lower); } diff --git a/arch/risc-v/src/rv32m1/Make.defs b/arch/risc-v/src/rv32m1/Make.defs index 99f6d5b45f5ce..3fcacd53f19b2 100644 --- a/arch/risc-v/src/rv32m1/Make.defs +++ b/arch/risc-v/src/rv32m1/Make.defs @@ -26,7 +26,7 @@ HEAD_ASRC = rv32m1_head.S CMN_ASRCS = riscv_vectors.S # Specify C code within the common directory to be included -CMN_CSRCS += riscv_initialize.c riscv_swint.c +CMN_CSRCS += riscv_initialize.c riscv_swint.c riscv_doirq.c riscv_exception.c CMN_CSRCS += riscv_allocateheap.c riscv_createstack.c riscv_exit.c CMN_CSRCS += riscv_assert.c riscv_blocktask.c riscv_copystate.c riscv_initialstate.c CMN_CSRCS += riscv_interruptcontext.c riscv_modifyreg32.c riscv_puts.c @@ -34,6 +34,7 @@ CMN_CSRCS += riscv_releasepending.c riscv_reprioritizertr.c CMN_CSRCS += riscv_releasestack.c riscv_stackframe.c riscv_schedulesigaction.c CMN_CSRCS += riscv_sigdeliver.c riscv_unblocktask.c riscv_usestack.c CMN_CSRCS += riscv_idle.c riscv_tcbinfo.c riscv_getnewintctx.c +CMN_CSRCS += riscv_saveusercontext.c ifeq ($(CONFIG_SCHED_BACKTRACE),y) CMN_CSRCS += riscv_backtrace.c @@ -44,6 +45,7 @@ CMN_CSRCS += riscv_checkstack.c endif ifeq ($(CONFIG_ARCH_HAVE_VFORK),y) +CMN_ASRCS += vfork.S CMN_CSRCS += riscv_vfork.c endif diff --git a/arch/risc-v/src/rv32m1/rv32m1_irq.c b/arch/risc-v/src/rv32m1/rv32m1_irq.c index 2dc5d13e7969c..094db7a2da385 100644 --- a/arch/risc-v/src/rv32m1/rv32m1_irq.c +++ b/arch/risc-v/src/rv32m1/rv32m1_irq.c @@ -30,9 +30,8 @@ #include #include -#include +#include #include -#include #include "riscv_internal.h" #include "rv32m1.h" @@ -120,9 +119,9 @@ void up_irqinitialize(void) CURRENT_REGS = NULL; - /* Attach the ecall interrupt handler */ + /* Attach the common interrupt handler */ - irq_attach(RISCV_IRQ_ECALLM, riscv_swint, NULL); + riscv_exception_attach(); #ifndef CONFIG_SUPPRESS_INTERRUPTS @@ -215,7 +214,7 @@ void up_enable_irq(int irq) /* Read INTPTEN back to make it sure */ - (void)getreg32(RV32M1_EU_INTPTEN); + getreg32(RV32M1_EU_INTPTEN); } } diff --git a/arch/risc-v/src/rv32m1/rv32m1_irq_dispatch.c b/arch/risc-v/src/rv32m1/rv32m1_irq_dispatch.c index 077c78a2b254b..205b77a99dd0b 100644 --- a/arch/risc-v/src/rv32m1/rv32m1_irq_dispatch.c +++ b/arch/risc-v/src/rv32m1/rv32m1_irq_dispatch.c @@ -29,8 +29,6 @@ #include #include -#include -#include #include "riscv_internal.h" #include "rv32m1.h" @@ -55,16 +53,8 @@ void *rv32m1_dispatch_irq(uintptr_t vector, uintptr_t *regs) { uint32_t vec = vector & 0x1f; int irq = (vector >> RV_IRQ_MASK) + vec; - uintptr_t *mepc = regs; int irqofs = 0; - /* NOTE: In case of ecall, we need to adjust mepc in the context */ - - if (RISCV_IRQ_ECALLM == irq) - { - *mepc += 4; - } - if (RV32M1_IRQ_INTMUX0 <= irq) { uintptr_t chn = irq - RV32M1_IRQ_INTMUX0; @@ -102,21 +92,9 @@ void *rv32m1_dispatch_irq(uintptr_t vector, uintptr_t *regs) riscv_ack_irq(irq); -#ifdef CONFIG_SUPPRESS_INTERRUPTS - PANIC(); -#else - /* Current regs non-zero indicates that we are processing an interrupt; - * CURRENT_REGS is also used to manage interrupt level context switches. - * - * Nested interrupts are not supported - */ - - DEBUGASSERT(CURRENT_REGS == NULL); - CURRENT_REGS = regs; - /* Deliver the IRQ */ - irq_dispatch(irq, regs); + regs = riscv_doirq(irq, regs); if (RV32M1_IRQ_MEXT <= irq) { @@ -127,16 +105,5 @@ void *rv32m1_dispatch_irq(uintptr_t vector, uintptr_t *regs) putreg32(1 << vec, RV32M1_EU_INTPTPENDCLR); } -#endif - - /* If a context switch occurred while processing the interrupt then - * CURRENT_REGS may have change value. If we return any value different - * from the input regs, then the lower level will know that a context - * switch occurred during interrupt processing. - */ - - regs = (uintptr_t *)CURRENT_REGS; - CURRENT_REGS = NULL; - return regs; } diff --git a/arch/sim/Kconfig b/arch/sim/Kconfig index e4a821a23af7a..7df5c92654cbc 100644 --- a/arch/sim/Kconfig +++ b/arch/sim/Kconfig @@ -349,6 +349,21 @@ config SIM_NOINPUT bool "No input device" endchoice # Input Device + +config SIM_KEYBOARD + bool "X11 keyboard" + select INPUT_KEYBOARD + depends on SIM_X11FB + ---help--- + Support an X11 mouse-based keyboard emulation. Also needs INPUT=y + +config SIM_KEYBOARD_BUFFSIZE + int "sim keyboard buffer size" + default 64 + depends on SIM_KEYBOARD + ---help--- + Emulator keyboard buffer size + endif # if INPUT endmenu @@ -363,6 +378,14 @@ config SIM_HCISOCKET control of the device, but is abstracted from the physical interface which is still handled by Linux. +config SIM_HCISOCKET_DEVID + int "Bluetooth Device ID" + default 0 + depends on SIM_HCISOCKET + ---help--- + Attached the local bluetooth device use specific + Bluetooth HCI number id. + config SIM_I2CBUS bool "Simulated I2C Bus" default n diff --git a/arch/sim/src/Makefile b/arch/sim/src/Makefile index 4c0a0740b05b2..d49c1e53542f4 100644 --- a/arch/sim/src/Makefile +++ b/arch/sim/src/Makefile @@ -144,6 +144,10 @@ else ifeq ($(CONFIG_SIM_AJOYSTICK),y) else ifeq ($(CONFIG_SIM_BUTTONS),y) HOSTSRCS += up_x11eventloop.c endif + +ifeq ($(CONFIG_SIM_KEYBOARD),y) + CSRCS += up_keyboard.c +endif endif ifeq ($(CONFIG_FS_FAT),y) @@ -287,10 +291,13 @@ board/libboard$(LIBEXT): # So we have to skip the standard facilities and do the construction by ourself. # But how to achieve the goal? # 1.Command linker generate the default script(-verbose) -# 2.Replace __init_array_start/__init_array_end with _sinit/_einit -# 3.Append __init_array_start = .; __init_array_end = .; -# Step 2 let nxtask_startup find objects need to construct -# Step 3 cheat the host there is no object to construct +# 2.Move input sections out of .init_array/.fini_array into new .sinit/.einit +# output sections +# 3.Replace __init_array_start/__init_array_end with _sinit/_einit +# 4.Append __init_array_start = .; __init_array_end = .; +# Step 2 cheat the host there is no object to construct (glibc >= 2.34) +# Step 3 let nxtask_startup find objects need to construct +# Step 4 cheat the host there is no object to construct (glibc < 2.34) # Note: the destructor can be fixed in the same way. nuttx-names.dat: nuttx-names.in @@ -318,8 +325,11 @@ nuttx$(EXEEXT): libarch$(LIBEXT) board/libboard$(LIBEXT) $(HEADOBJ) $(LINKOBJS) ifneq ($(CONFIG_HOST_MACOS),y) $(Q) $(OBJCOPY) --redefine-syms=nuttx-names.dat nuttx.rel $(Q) $(CC) $(CFLAGS) -Wl,-verbose 2>&1 | \ - sed -e '/====/,/====/!d;//d' -e 's/__executable_start/_stext/g' -e 's/__init_array_start/_sinit/g' \ - -e 's/__init_array_end/_einit/g' -e 's/__fini_array_start/_sfini/g' -e 's/__fini_array_end/_efini/g' >nuttx.ld + sed -e '/====/,/====/!d;//d' -e 's/__executable_start/_stext/g' \ + -e 's/^\(\s\+\)\(\.init_array\)/\1\2 : { }\n\1.sinit/g' \ + -e 's/^\(\s\+\)\(\.fini_array\)/\1\2 : { }\n\1.einit/g' \ + -e 's/__init_array_start/_sinit/g' -e 's/__init_array_end/_einit/g' \ + -e 's/__fini_array_start/_sfini/g' -e 's/__fini_array_end/_efini/g' >nuttx.ld $(Q) echo "__init_array_start = .; __init_array_end = .; __fini_array_start = .; __fini_array_end = .;" >>nuttx.ld endif ifneq ($(CONFIG_ALLSYMS),y) diff --git a/arch/sim/src/sim/up_ajoystick.c b/arch/sim/src/sim/up_ajoystick.c index 3b4851cf276a8..574111e664094 100644 --- a/arch/sim/src/sim/up_ajoystick.c +++ b/arch/sim/src/sim/up_ajoystick.c @@ -47,14 +47,14 @@ ****************************************************************************/ static ajoy_buttonset_t ajoy_supported( - FAR const struct ajoy_lowerhalf_s *lower); -static int ajoy_sample(FAR const struct ajoy_lowerhalf_s *lower, - FAR struct ajoy_sample_s *sample); + const struct ajoy_lowerhalf_s *lower); +static int ajoy_sample(const struct ajoy_lowerhalf_s *lower, + struct ajoy_sample_s *sample); static ajoy_buttonset_t ajoy_buttons( - FAR const struct ajoy_lowerhalf_s *lower); -static void ajoy_enable(FAR const struct ajoy_lowerhalf_s *lower, - ajoy_buttonset_t press, ajoy_buttonset_t release, - ajoy_handler_t handler, FAR void *arg); + const struct ajoy_lowerhalf_s *lower); +static void ajoy_enable(const struct ajoy_lowerhalf_s *lower, + ajoy_buttonset_t press, ajoy_buttonset_t release, + ajoy_handler_t handler, void *arg); /**************************************************************************** * Private Data @@ -95,7 +95,7 @@ static ajoy_buttonset_t g_ajoy_rset; /* Set of releases waited for */ ****************************************************************************/ static ajoy_buttonset_t ajoy_supported( - FAR const struct ajoy_lowerhalf_s *lower) + const struct ajoy_lowerhalf_s *lower) { return (ajoy_buttonset_t)AJOY_SUPPORTED; } @@ -108,8 +108,8 @@ static ajoy_buttonset_t ajoy_supported( * ****************************************************************************/ -static int ajoy_sample(FAR const struct ajoy_lowerhalf_s *lower, - FAR struct ajoy_sample_s *sample) +static int ajoy_sample(const struct ajoy_lowerhalf_s *lower, + struct ajoy_sample_s *sample) { memcpy(sample, &g_ajoy_sample, sizeof(struct ajoy_sample_s)); g_ajoy_buttons = g_ajoy_sample.as_buttons; @@ -126,7 +126,7 @@ static int ajoy_sample(FAR const struct ajoy_lowerhalf_s *lower, ****************************************************************************/ static ajoy_buttonset_t ajoy_buttons( - FAR const struct ajoy_lowerhalf_s *lower) + const struct ajoy_lowerhalf_s *lower) { g_ajoy_valid = false; g_ajoy_buttons = g_ajoy_sample.as_buttons; @@ -142,9 +142,9 @@ static ajoy_buttonset_t ajoy_buttons( * ****************************************************************************/ -static void ajoy_enable(FAR const struct ajoy_lowerhalf_s *lower, +static void ajoy_enable(const struct ajoy_lowerhalf_s *lower, ajoy_buttonset_t press, ajoy_buttonset_t release, - ajoy_handler_t handler, FAR void *arg) + ajoy_handler_t handler, void *arg) { g_ajoy_handler = NULL; g_ajoy_pset = press; diff --git a/arch/sim/src/sim/up_alsa.c b/arch/sim/src/sim/up_alsa.c index 5f45b346bd0fb..d5cbabf1619f4 100644 --- a/arch/sim/src/sim/up_alsa.c +++ b/arch/sim/src/sim/up_alsa.c @@ -71,7 +71,7 @@ static int sim_audio_getcaps(struct audio_lowerhalf_s *dev, int type, struct audio_caps_s *caps); #ifdef CONFIG_AUDIO_MULTI_SESSION static int sim_audio_configure(struct audio_lowerhalf_s *dev, - FAR void *session, + void *session, const struct audio_caps_s *caps); #else static int sim_audio_configure(struct audio_lowerhalf_s *dev, @@ -362,7 +362,7 @@ static int sim_audio_getcaps(struct audio_lowerhalf_s *dev, int type, #ifdef CONFIG_AUDIO_MULTI_SESSION static int sim_audio_configure(struct audio_lowerhalf_s *dev, - FAR void *session, + void *session, const struct audio_caps_s *caps) #else static int sim_audio_configure(struct audio_lowerhalf_s *dev, diff --git a/arch/sim/src/sim/up_assert.c b/arch/sim/src/sim/up_assert.c index ed96ace282b12..30e62aeba6d50 100644 --- a/arch/sim/src/sim/up_assert.c +++ b/arch/sim/src/sim/up_assert.c @@ -73,7 +73,7 @@ void up_assert(const char *filename, int lineno) { - FAR struct tcb_s *rtcb = running_task(); + struct tcb_s *rtcb = running_task(); /* Flush any buffered SYSLOG data (prior to the assertion) */ diff --git a/arch/sim/src/sim/up_blockdevice.c b/arch/sim/src/sim/up_blockdevice.c index bff6adafd2d85..4e5b76bbcf3ce 100644 --- a/arch/sim/src/sim/up_blockdevice.c +++ b/arch/sim/src/sim/up_blockdevice.c @@ -53,6 +53,6 @@ void up_registerblockdevice(void) { - ramdisk_register(0, (FAR uint8_t *)up_deviceimage(), NSECTORS, + ramdisk_register(0, (uint8_t *)up_deviceimage(), NSECTORS, LOGICAL_SECTOR_SIZE, RDFLAG_WRENABLED | RDFLAG_FUNLINK); } diff --git a/arch/sim/src/sim/up_blocktask.c b/arch/sim/src/sim/up_blocktask.c index 2924c4c4dbf5f..5463099c7a5fb 100644 --- a/arch/sim/src/sim/up_blocktask.c +++ b/arch/sim/src/sim/up_blocktask.c @@ -60,7 +60,7 @@ void up_block_task(struct tcb_s *tcb, tstate_t task_state) { - FAR struct tcb_s *rtcb = this_task(); + struct tcb_s *rtcb = this_task(); bool switch_needed; /* Verify that the context switch can be performed */ diff --git a/arch/sim/src/sim/up_checkstack.c b/arch/sim/src/sim/up_checkstack.c index f9456eef2e89a..407717f8fe00a 100644 --- a/arch/sim/src/sim/up_checkstack.c +++ b/arch/sim/src/sim/up_checkstack.c @@ -61,9 +61,9 @@ static size_t do_stackcheck(uintptr_t alloc, size_t size); static size_t do_stackcheck(uintptr_t alloc, size_t size) { - FAR uintptr_t start; - FAR uintptr_t end; - FAR uint32_t *ptr; + uintptr_t start; + uintptr_t end; + uint32_t *ptr; size_t mark; if (size == 0) @@ -86,7 +86,7 @@ static size_t do_stackcheck(uintptr_t alloc, size_t size) * that does not have the magic value is the high water mark. */ - for (ptr = (FAR uint32_t *)start, mark = (size >> 2); + for (ptr = (uint32_t *)start, mark = (size >> 2); *ptr == STACK_COLOR && mark > 0; ptr++, mark--); @@ -106,7 +106,7 @@ static size_t do_stackcheck(uintptr_t alloc, size_t size) int i; int j; - ptr = (FAR uint32_t *)start; + ptr = (uint32_t *)start; for (i = 0; i < size; i += 4 * 64) { for (j = 0; j < 64; j++) @@ -154,12 +154,12 @@ static size_t do_stackcheck(uintptr_t alloc, size_t size) * ****************************************************************************/ -size_t up_check_tcbstack(FAR struct tcb_s *tcb) +size_t up_check_tcbstack(struct tcb_s *tcb) { return do_stackcheck((uintptr_t)tcb->stack_base_ptr, tcb->adj_stack_size); } -ssize_t up_check_tcbstack_remain(FAR struct tcb_s *tcb) +ssize_t up_check_tcbstack_remain(struct tcb_s *tcb) { return tcb->adj_stack_size - up_check_tcbstack(tcb); } diff --git a/arch/sim/src/sim/up_cpuidlestack.c b/arch/sim/src/sim/up_cpuidlestack.c index c9effa79f4d58..94ac4395f303a 100644 --- a/arch/sim/src/sim/up_cpuidlestack.c +++ b/arch/sim/src/sim/up_cpuidlestack.c @@ -76,7 +76,7 @@ * ****************************************************************************/ -int up_cpu_idlestack(int cpu, FAR struct tcb_s *tcb, size_t stack_size) +int up_cpu_idlestack(int cpu, struct tcb_s *tcb, size_t stack_size) { return up_create_stack(tcb, stack_size, TCB_FLAG_TTYPE_KERNEL); } diff --git a/arch/sim/src/sim/up_createstack.c b/arch/sim/src/sim/up_createstack.c index 6e540afd37696..6661dafa372ad 100644 --- a/arch/sim/src/sim/up_createstack.c +++ b/arch/sim/src/sim/up_createstack.c @@ -71,7 +71,7 @@ * ****************************************************************************/ -int up_create_stack(FAR struct tcb_s *tcb, size_t stack_size, uint8_t ttype) +int up_create_stack(struct tcb_s *tcb, size_t stack_size, uint8_t ttype) { stack_size += CONFIG_SIM_STACKSIZE_ADJUSTMENT; @@ -156,15 +156,33 @@ int up_create_stack(FAR struct tcb_s *tcb, size_t stack_size, uint8_t ttype) ****************************************************************************/ #ifdef CONFIG_STACK_COLORATION -void nostackprotect_function up_stack_color(FAR void *stackbase, +void nostackprotect_function up_stack_color(void *stackbase, size_t nbytes) { - /* Take extra care that we do not write outsize the stack boundaries */ + uint32_t *stkptr; + uintptr_t stkend; + size_t nwords; + uintptr_t sp; - uint32_t *stkptr = (uint32_t *)(((uintptr_t)stackbase + 3) & ~3); - uintptr_t stkend = nbytes ? (((uintptr_t)stackbase + nbytes) & ~3) : - up_getsp(); /* 0: colorize the running stack */ - size_t nwords = (stkend - (uintptr_t)stackbase) >> 2; + /* Take extra care that we do not write outside the stack boundaries */ + + stkptr = (uint32_t *)STACK_ALIGN_UP((uintptr_t)stackbase); + + if (nbytes == 0) /* 0: colorize the running stack */ + { + stkend = up_getsp(); + if (stkend > (uintptr_t)&sp) + { + stkend = (uintptr_t)&sp; + } + } + else + { + stkend = (uintptr_t)stackbase + nbytes; + } + + stkend = STACK_ALIGN_DOWN(stkend); + nwords = (stkend - (uintptr_t)stackbase) >> 2; /* Set the entire stack to the coloration value */ diff --git a/arch/sim/src/sim/up_exit.c b/arch/sim/src/sim/up_exit.c index ca15be3aefe34..3ea743a151ed0 100644 --- a/arch/sim/src/sim/up_exit.c +++ b/arch/sim/src/sim/up_exit.c @@ -49,7 +49,7 @@ void up_exit(int status) { - FAR struct tcb_s *tcb; + struct tcb_s *tcb; /* Make sure that we are in a critical section with local interrupts. * The IRQ state will be restored when the next task is started. diff --git a/arch/sim/src/sim/up_framebuffer.c b/arch/sim/src/sim/up_framebuffer.c index 8552c689151f1..84285c3f068b0 100644 --- a/arch/sim/src/sim/up_framebuffer.c +++ b/arch/sim/src/sim/up_framebuffer.c @@ -69,30 +69,30 @@ * configuration of each color plane. */ -static int up_getvideoinfo(FAR struct fb_vtable_s *vtable, - FAR struct fb_videoinfo_s *vinfo); -static int up_getplaneinfo(FAR struct fb_vtable_s *vtable, int planeno, - FAR struct fb_planeinfo_s *pinfo); +static int up_getvideoinfo(struct fb_vtable_s *vtable, + struct fb_videoinfo_s *vinfo); +static int up_getplaneinfo(struct fb_vtable_s *vtable, int planeno, + struct fb_planeinfo_s *pinfo); /* The following is provided only if the video hardware supports * RGB color mapping. */ #ifdef CONFIG_FB_CMAP -static int up_getcmap(FAR struct fb_vtable_s *vtable, - FAR struct fb_cmap_s *cmap); -static int up_putcmap(FAR struct fb_vtable_s *vtable, - FAR const struct fb_cmap_s *cmap); +static int up_getcmap(struct fb_vtable_s *vtable, + struct fb_cmap_s *cmap); +static int up_putcmap(struct fb_vtable_s *vtable, + const struct fb_cmap_s *cmap); #endif /* The following is provided only if the video hardware supports * a hardware cursor */ #ifdef CONFIG_FB_HWCURSOR -static int up_getcursor(FAR struct fb_vtable_s *vtable, - FAR struct fb_cursorattrib_s *attrib); -static int up_setcursor(FAR struct fb_vtable_s *vtable, - FAR struct fb_setcursor_s *settings); +static int up_getcursor(struct fb_vtable_s *vtable, + struct fb_cursorattrib_s *attrib); +static int up_setcursor(struct fb_vtable_s *vtable, + struct fb_setcursor_s *settings); #endif /**************************************************************************** @@ -120,7 +120,7 @@ static const struct fb_videoinfo_s g_videoinfo = static const struct fb_planeinfo_s g_planeinfo = { - .fbmem = (FAR void *)&g_fb, + .fbmem = (void *)&g_fb, .fblen = FB_SIZE, .stride = FB_WIDTH, .display = 0, @@ -172,8 +172,8 @@ struct fb_vtable_s g_fbobject = * Name: up_getvideoinfo ****************************************************************************/ -static int up_getvideoinfo(FAR struct fb_vtable_s *vtable, - FAR struct fb_videoinfo_s *vinfo) +static int up_getvideoinfo(struct fb_vtable_s *vtable, + struct fb_videoinfo_s *vinfo) { ginfo("vtable=%p vinfo=%p\n", vtable, vinfo); if (vtable && vinfo) @@ -190,8 +190,8 @@ static int up_getvideoinfo(FAR struct fb_vtable_s *vtable, * Name: up_getplaneinfo ****************************************************************************/ -static int up_getplaneinfo(FAR struct fb_vtable_s *vtable, int planeno, - FAR struct fb_planeinfo_s *pinfo) +static int up_getplaneinfo(struct fb_vtable_s *vtable, int planeno, + struct fb_planeinfo_s *pinfo) { ginfo("vtable=%p planeno=%d pinfo=%p\n", vtable, planeno, pinfo); if (vtable && planeno == 0 && pinfo) @@ -209,8 +209,8 @@ static int up_getplaneinfo(FAR struct fb_vtable_s *vtable, int planeno, ****************************************************************************/ #ifdef CONFIG_FB_CMAP -static int up_getcmap(FAR struct fb_vtable_s *vtable, - FAR struct fb_cmap_s *cmap) +static int up_getcmap(struct fb_vtable_s *vtable, + struct fb_cmap_s *cmap) { int len; int i; @@ -242,8 +242,8 @@ static int up_getcmap(FAR struct fb_vtable_s *vtable, ****************************************************************************/ #ifdef CONFIG_FB_CMAP -static int up_putcmap(FAR struct fb_vtable_s *vtable, - FAR const struct fb_cmap_s *cmap) +static int up_putcmap(struct fb_vtable_s *vtable, + const struct fb_cmap_s *cmap) { #ifdef CONFIG_SIM_X11FB return up_x11cmap(cmap->first, cmap->len, cmap->red, cmap->green, @@ -266,8 +266,8 @@ static int up_putcmap(FAR struct fb_vtable_s *vtable, ****************************************************************************/ #ifdef CONFIG_FB_HWCURSOR -static int up_getcursor(FAR struct fb_vtable_s *vtable, - FAR struct fb_cursorattrib_s *attrib) +static int up_getcursor(struct fb_vtable_s *vtable, + struct fb_cursorattrib_s *attrib) { ginfo("vtable=%p attrib=%p\n", vtable, attrib); if (vtable && attrib) @@ -296,8 +296,8 @@ static int up_getcursor(FAR struct fb_vtable_s *vtable, ****************************************************************************/ #ifdef CONFIG_FB_HWCURSOR -static int up_setcursor(FAR struct fb_vtable_s *vtable, - FAR struct fb_setcursor_s *settings) +static int up_setcursor(struct fb_vtable_s *vtable, + struct fb_setcursor_s *settings) { ginfo("vtable=%p settings=%p\n", vtable, settings); if (vtable && settings) @@ -339,7 +339,7 @@ static int up_setcursor(FAR struct fb_vtable_s *vtable, ****************************************************************************/ #ifdef CONFIG_SIM_X11FB -static void up_updatework(FAR void *arg) +static void up_updatework(void *arg) { work_queue(LPWORK, &g_updatework, up_updatework, NULL, MSEC2TICK(33)); up_x11update(); @@ -402,7 +402,7 @@ int up_fbinitialize(int display) * ****************************************************************************/ -FAR struct fb_vtable_s *up_fbgetvplane(int display, int vplane) +struct fb_vtable_s *up_fbgetvplane(int display, int vplane) { if (vplane == 0) { diff --git a/arch/sim/src/sim/up_hcisocket.c b/arch/sim/src/sim/up_hcisocket.c index 9159fe248f8eb..794c77db97c2c 100644 --- a/arch/sim/src/sim/up_hcisocket.c +++ b/arch/sim/src/sim/up_hcisocket.c @@ -57,7 +57,7 @@ struct bthcisock_s { - FAR struct bt_driver_s drv; + struct bt_driver_s drv; int id; int fd; sq_entry_t link; @@ -67,12 +67,12 @@ struct bthcisock_s * Private Function Prototypes ****************************************************************************/ -static int bthcisock_send(FAR struct bt_driver_s *drv, +static int bthcisock_send(struct bt_driver_s *drv, enum bt_buf_type_e type, - FAR void *data, size_t len); -static int bthcisock_open(FAR struct bt_driver_s *drv); -static void bthcisock_close(FAR struct bt_driver_s *drv); -static int bthcisock_receive(FAR struct bt_driver_s *drv); + void *data, size_t len); +static int bthcisock_open(struct bt_driver_s *drv); +static void bthcisock_close(struct bt_driver_s *drv); +static int bthcisock_receive(struct bt_driver_s *drv); /**************************************************************************** * Private Data @@ -84,12 +84,12 @@ static sq_queue_t g_bthcisock_list; * Private Functions ****************************************************************************/ -static int bthcisock_send(FAR struct bt_driver_s *drv, +static int bthcisock_send(struct bt_driver_s *drv, enum bt_buf_type_e type, - FAR void *data, size_t len) + void *data, size_t len) { - FAR struct bthcisock_s *dev = (FAR struct bthcisock_s *)drv; - FAR char *hdr = (FAR char *)data - drv->head_reserve; + struct bthcisock_s *dev = (struct bthcisock_s *)drv; + char *hdr = (char *)data - drv->head_reserve; int ret; if (type == BT_CMD) @@ -114,17 +114,17 @@ static int bthcisock_send(FAR struct bt_driver_s *drv, return ret < 0 ? ret : len; } -static void bthcisock_close(FAR struct bt_driver_s *drv) +static void bthcisock_close(struct bt_driver_s *drv) { - FAR struct bthcisock_s *dev = (FAR struct bthcisock_s *)drv; + struct bthcisock_s *dev = (struct bthcisock_s *)drv; bthcisock_host_close(dev->fd); dev->fd = -1; } -static int bthcisock_receive(FAR struct bt_driver_s *drv) +static int bthcisock_receive(struct bt_driver_s *drv) { - FAR struct bthcisock_s *dev = (FAR struct bthcisock_s *)drv; + struct bthcisock_s *dev = (struct bthcisock_s *)drv; char data[BLUETOOTH_RX_FRAMELEN]; enum bt_buf_type_e type; int ret; @@ -157,9 +157,9 @@ static int bthcisock_receive(FAR struct bt_driver_s *drv) ret - H4_HEADER_SIZE); } -static int bthcisock_open(FAR struct bt_driver_s *drv) +static int bthcisock_open(struct bt_driver_s *drv) { - FAR struct bthcisock_s *dev = (FAR struct bthcisock_s *)drv; + struct bthcisock_s *dev = (struct bthcisock_s *)drv; int fd; fd = bthcisock_host_open(dev->id); @@ -174,14 +174,14 @@ static int bthcisock_open(FAR struct bt_driver_s *drv) return OK; } -static FAR struct bthcisock_s *bthcisock_alloc(int dev_id) +static struct bthcisock_s *bthcisock_alloc(int dev_id) { /* Register the driver with the Bluetooth stack */ - FAR struct bthcisock_s *dev; - FAR struct bt_driver_s *drv; + struct bthcisock_s *dev; + struct bt_driver_s *drv; - dev = (FAR struct bthcisock_s *)kmm_zalloc(sizeof(*dev)); + dev = (struct bthcisock_s *)kmm_zalloc(sizeof(*dev)); if (dev == NULL) { return NULL; @@ -221,7 +221,7 @@ static FAR struct bthcisock_s *bthcisock_alloc(int dev_id) int bthcisock_register(int dev_id) { - FAR struct bthcisock_s *dev; + struct bthcisock_s *dev; #if defined(CONFIG_UART_BTH4) char name[32]; #endif @@ -264,8 +264,8 @@ int bthcisock_register(int dev_id) int bthcisock_loop(void) { - FAR struct bthcisock_s *dev; - FAR sq_entry_t *entry; + struct bthcisock_s *dev; + sq_entry_t *entry; for (entry = sq_peek(&g_bthcisock_list); entry; entry = sq_next(entry)) { diff --git a/arch/sim/src/sim/up_heap.c b/arch/sim/src/sim/up_heap.c index 4ed5fd2c4b77c..3c71a3009a578 100644 --- a/arch/sim/src/sim/up_heap.c +++ b/arch/sim/src/sim/up_heap.c @@ -45,7 +45,7 @@ struct mm_delaynode_s { - FAR struct mm_delaynode_s *flink; + struct mm_delaynode_s *flink; }; struct mm_heap_s @@ -61,10 +61,10 @@ struct mm_heap_s * Private Functions ****************************************************************************/ -static void mm_add_delaylist(FAR struct mm_heap_s *heap, FAR void *mem) +static void mm_add_delaylist(struct mm_heap_s *heap, void *mem) { #if defined(CONFIG_BUILD_FLAT) || defined(__KERNEL__) - FAR struct mm_delaynode_s *tmp = mem; + struct mm_delaynode_s *tmp = mem; irqstate_t flags; /* Delay the deallocation until a more appropriate time. */ @@ -78,10 +78,10 @@ static void mm_add_delaylist(FAR struct mm_heap_s *heap, FAR void *mem) #endif } -static void mm_free_delaylist(FAR struct mm_heap_s *heap) +static void mm_free_delaylist(struct mm_heap_s *heap) { #if defined(CONFIG_BUILD_FLAT) || defined(__KERNEL__) - FAR struct mm_delaynode_s *tmp; + struct mm_delaynode_s *tmp; irqstate_t flags; /* Move the delay list to local */ @@ -97,7 +97,7 @@ static void mm_free_delaylist(FAR struct mm_heap_s *heap) while (tmp) { - FAR void *address; + void *address; /* Get the first delayed deallocation */ @@ -136,12 +136,12 @@ static void mm_free_delaylist(FAR struct mm_heap_s *heap) * ****************************************************************************/ -FAR struct mm_heap_s *mm_initialize(FAR const char *name, - FAR void *heap_start, size_t heap_size) +struct mm_heap_s *mm_initialize(const char *name, + void *heap_start, size_t heap_size) { - FAR struct mm_heap_s *heap; + struct mm_heap_s *heap; - heap = host_memalign(sizeof(FAR void *), sizeof(*heap)); + heap = host_memalign(sizeof(void *), sizeof(*heap)); DEBUGASSERT(heap); memset(heap, 0, sizeof(struct mm_heap_s)); @@ -173,7 +173,7 @@ FAR struct mm_heap_s *mm_initialize(FAR const char *name, * ****************************************************************************/ -void mm_addregion(FAR struct mm_heap_s *heap, FAR void *heapstart, +void mm_addregion(struct mm_heap_s *heap, void *heapstart, size_t heapsize) { } @@ -189,7 +189,7 @@ void mm_addregion(FAR struct mm_heap_s *heap, FAR void *heapstart, * ****************************************************************************/ -FAR void *mm_malloc(FAR struct mm_heap_s *heap, size_t size) +void *mm_malloc(struct mm_heap_s *heap, size_t size) { return mm_realloc(heap, NULL, size); } @@ -203,7 +203,7 @@ FAR void *mm_malloc(FAR struct mm_heap_s *heap, size_t size) * ****************************************************************************/ -FAR void mm_free(FAR struct mm_heap_s *heap, FAR void *mem) +void mm_free(struct mm_heap_s *heap, void *mem) { #if defined(CONFIG_BUILD_FLAT) || defined(__KERNEL__) /* Check current environment */ @@ -255,7 +255,7 @@ FAR void mm_free(FAR struct mm_heap_s *heap, FAR void *mem) * ****************************************************************************/ -FAR void *mm_realloc(FAR struct mm_heap_s *heap, FAR void *oldmem, +void *mm_realloc(struct mm_heap_s *heap, void *oldmem, size_t size) { mm_free_delaylist(heap); @@ -270,7 +270,7 @@ FAR void *mm_realloc(FAR struct mm_heap_s *heap, FAR void *oldmem, * ****************************************************************************/ -FAR void *mm_calloc(FAR struct mm_heap_s *heap, size_t n, size_t elem_size) +void *mm_calloc(struct mm_heap_s *heap, size_t n, size_t elem_size) { size_t size = n * elem_size; @@ -290,9 +290,9 @@ FAR void *mm_calloc(FAR struct mm_heap_s *heap, size_t n, size_t elem_size) * ****************************************************************************/ -FAR void *mm_zalloc(FAR struct mm_heap_s *heap, size_t size) +void *mm_zalloc(struct mm_heap_s *heap, size_t size) { - FAR void *ptr; + void *ptr; ptr = mm_malloc(heap, size); if (ptr != NULL) @@ -316,7 +316,7 @@ FAR void *mm_zalloc(FAR struct mm_heap_s *heap, size_t size) * ****************************************************************************/ -FAR void *mm_memalign(FAR struct mm_heap_s *heap, size_t alignment, +void *mm_memalign(struct mm_heap_s *heap, size_t alignment, size_t size) { mm_free_delaylist(heap); @@ -340,7 +340,7 @@ FAR void *mm_memalign(FAR struct mm_heap_s *heap, size_t alignment, * ****************************************************************************/ -bool mm_heapmember(FAR struct mm_heap_s *heap, FAR void *mem) +bool mm_heapmember(struct mm_heap_s *heap, void *mem) { return true; } @@ -354,7 +354,7 @@ bool mm_heapmember(FAR struct mm_heap_s *heap, FAR void *mem) * ****************************************************************************/ -FAR void *mm_brkaddr(FAR struct mm_heap_s *heap, int region) +void *mm_brkaddr(struct mm_heap_s *heap, int region) { return NULL; } @@ -368,7 +368,7 @@ FAR void *mm_brkaddr(FAR struct mm_heap_s *heap, int region) * ****************************************************************************/ -void mm_extend(FAR struct mm_heap_s *heap, FAR void *mem, size_t size, +void mm_extend(struct mm_heap_s *heap, void *mem, size_t size, int region) { } @@ -381,7 +381,7 @@ void mm_extend(FAR struct mm_heap_s *heap, FAR void *mem, size_t size, * ****************************************************************************/ -int mm_mallinfo(FAR struct mm_heap_s *heap, FAR struct mallinfo *info) +int mm_mallinfo(struct mm_heap_s *heap, struct mallinfo *info) { memset(info, 0, sizeof(struct mallinfo)); host_mallinfo(&info->aordblks, &info->uordblks); @@ -396,7 +396,7 @@ int mm_mallinfo(FAR struct mm_heap_s *heap, FAR struct mallinfo *info) * ****************************************************************************/ -void mm_memdump(FAR struct mm_heap_s *heap, pid_t pid) +void mm_memdump(struct mm_heap_s *heap, pid_t pid) { } @@ -410,7 +410,7 @@ void mm_memdump(FAR struct mm_heap_s *heap, pid_t pid) * ****************************************************************************/ -void mm_checkcorruption(FAR struct mm_heap_s *heap) +void mm_checkcorruption(struct mm_heap_s *heap) { } @@ -420,7 +420,7 @@ void mm_checkcorruption(FAR struct mm_heap_s *heap) * Name: malloc_size ****************************************************************************/ -size_t mm_malloc_size(FAR void *mem) +size_t mm_malloc_size(void *mem) { return host_malloc_size(mem); } diff --git a/arch/sim/src/sim/up_hostfs.c b/arch/sim/src/sim/up_hostfs.c index 828f7e9803e75..151799e58fea4 100644 --- a/arch/sim/src/sim/up_hostfs.c +++ b/arch/sim/src/sim/up_hostfs.c @@ -348,6 +348,7 @@ int host_fchstat(int fd, const struct nuttx_stat_s *buf, int flags) } else { + times[0].tv_sec = 0; times[0].tv_nsec = UTIME_OMIT; } @@ -358,6 +359,7 @@ int host_fchstat(int fd, const struct nuttx_stat_s *buf, int flags) } else { + times[1].tv_sec = 0; times[1].tv_nsec = UTIME_OMIT; } @@ -634,6 +636,7 @@ int host_chstat(const char *path, const struct nuttx_stat_s *buf, int flags) } else { + times[0].tv_sec = 0; times[0].tv_nsec = UTIME_OMIT; } @@ -644,6 +647,7 @@ int host_chstat(const char *path, const struct nuttx_stat_s *buf, int flags) } else { + times[1].tv_sec = 0; times[1].tv_nsec = UTIME_OMIT; } diff --git a/arch/sim/src/sim/up_initialize.c b/arch/sim/src/sim/up_initialize.c index 7b64098aba78c..6255df8bd07b8 100644 --- a/arch/sim/src/sim/up_initialize.c +++ b/arch/sim/src/sim/up_initialize.c @@ -27,6 +27,7 @@ #include #include #include +#include #include #include @@ -50,12 +51,12 @@ static void up_init_smartfs(void) { #if defined(CONFIG_MTD_M25P) || defined(CONFIG_MTD_W25) || defined(CONFIG_MTD_SST26) - FAR struct mtd_dev_s *mtd; - FAR struct spi_dev_s *spi; + struct mtd_dev_s *mtd; + struct spi_dev_s *spi; int minor = 0; #endif #ifdef CONFIG_MTD_N25QXXX - FAR struct qspi_dev_s *qspi; + struct qspi_dev_s *qspi; #endif #ifdef CONFIG_SPI_FLASH @@ -138,7 +139,7 @@ static void up_init_smartfs(void) } #endif -static int up_loop_task(int argc, FAR char **argv) +static int up_loop_task(int argc, char **argv) { while (1) { @@ -215,6 +216,16 @@ static int up_loop_task(int argc, FAR char **argv) void up_initialize(void) { +#ifdef CONFIG_PM + /* Initialize the power management subsystem. This MCU-specific function + * must be called *very* early in the initialization sequence *before* any + * other device drivers are initialized (since they may attempt to register + * with the power management subsystem). + */ + + pm_initialize(); +#endif + /* Register some tty-port to access tty-port on sim platform */ up_uartinit(); diff --git a/arch/sim/src/sim/up_internal.h b/arch/sim/src/sim/up_internal.h index bdcf87bbf4487..1c1d21af17ebe 100644 --- a/arch/sim/src/sim/up_internal.h +++ b/arch/sim/src/sim/up_internal.h @@ -231,10 +231,17 @@ int sim_tsc_initialize(int minor); int sim_tsc_uninitialize(void); #endif +/* up_keyboard.c ************************************************************/ + +#ifdef CONFIG_SIM_KEYBOARD +int sim_kbd_initialize(void); +void up_kbdevent(uint32_t key, bool is_press); +#endif + /* up_eventloop.c ***********************************************************/ #if defined(CONFIG_SIM_TOUCHSCREEN) || defined(CONFIG_SIM_AJOYSTICK) || \ - defined(CONFIG_ARCH_BUTTONS) + defined(CONFIG_ARCH_BUTTONS) || defined(CONFING_SIM_KEYBOARD) void up_x11events(void); void up_buttonevent(int x, int y, int buttons); #endif diff --git a/arch/arm/src/armv7-a/arm_testset.S b/arch/sim/src/sim/up_keyboard.c similarity index 58% rename from arch/arm/src/armv7-a/arm_testset.S rename to arch/sim/src/sim/up_keyboard.c index 822c5d7c489bd..e2eb43679834e 100644 --- a/arch/arm/src/armv7-a/arm_testset.S +++ b/arch/sim/src/sim/up_keyboard.c @@ -1,5 +1,5 @@ /**************************************************************************** - * arch/arm/src/armv7-a/arm_testset.S + * arch/sim/src/sim/up_keyboard.c * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with @@ -23,84 +23,93 @@ ****************************************************************************/ #include -#include +#include - .file "arm_testset.S" +#include +#include +#include + +#include + +#include "up_internal.h" /**************************************************************************** * Pre-processor Definitions ****************************************************************************/ +#define DEVNAME "/dev/kbd" + /**************************************************************************** - * Public Symbols + * Private Types ****************************************************************************/ - .globl up_testset +struct up_dev_s +{ + int eventloop; + struct keyboard_lowerhalf_s lower; +}; /**************************************************************************** - * Assembly Macros + * Private Data ****************************************************************************/ -/**************************************************************************** - * Private Functions - ****************************************************************************/ +/* Only one simulated keyboard is supported so the driver state + * structure may as well be pre-allocated. + */ - .text +static struct up_dev_s g_simkeyboard; /**************************************************************************** * Public Functions ****************************************************************************/ /**************************************************************************** - * Name: up_testset - * - * Description: - * Perform an atomic test and set operation on the provided spinlock. - * - * This function must be provided via the architecture-specific logic. - * - * Input Parameters: - * lock - A reference to the spinlock object. - * - * Returned Value: - * The spinlock is always locked upon return. The previous value of the - * spinlock variable is returned, either SP_LOCKED if the spinlock was - * previously locked (meaning that the test-and-set operation failed to - * obtain the lock) or SP_UNLOCKED if the spinlock was previously unlocked - * (meaning that we successfully obtained the lock). - * + * Name: sim_kbd_initialize ****************************************************************************/ - .globl up_testset - .type up_testset, %function +int sim_kbd_initialize(void) +{ + int ret; + struct up_dev_s *priv = &g_simkeyboard; -up_testset: + memset(priv, 0, sizeof(*priv)); - mov r1, #SP_LOCKED + /* Register the device as an input device */ - /* Test if the spinlock is locked or not */ + ret = keyboard_register(&priv->lower, DEVNAME, + CONFIG_SIM_KEYBOARD_BUFFSIZE); + if (ret < 0) + { + ierr("ERROR: keyboard_register() failed: %d\n", ret); + return ret; + } -1: - ldrexb r2, [r0] /* Test if spinlock is locked or not */ - cmp r2, r1 /* Already locked? */ - beq 2f /* If already locked, return SP_LOCKED */ + /* Enable X11 event processing from the IDLE loop */ - /* Not locked ... attempt to lock it */ + priv->eventloop = 1; + return OK; +} + +/**************************************************************************** + * Name: up_kbdevent + ****************************************************************************/ - strexb r2, r1, [r0] /* Attempt to set the locked state */ - cmp r2, r1 /* r2 will be 1 is strexb failed */ - beq 1b /* Failed to lock... try again */ +void up_kbdevent(uint32_t key, bool is_press) +{ + struct up_dev_s *priv = (struct up_dev_s *) &g_simkeyboard; + uint32_t types[2] = + { + KEYBOARD_RELEASE, KEYBOARD_PRESS + }; - /* Lock acquired -- return SP_UNLOCKED */ + if (priv->eventloop == 0) + { + return; + } - dmb /* Required before accessing protected resource */ - mov r0, #SP_UNLOCKED - bx lr + iinfo("key=%04x\n", key); - /* Lock not acquired -- return SP_LOCKED */ + /* Report data changes */ -2: - mov r0, #SP_LOCKED - bx lr - .size up_testset, . - up_testset - .end + keyboard_event(&priv->lower, key, types[is_press]); +} diff --git a/arch/sim/src/sim/up_lcd.c b/arch/sim/src/sim/up_lcd.c index 812dfadd501d6..fa4cca758df40 100644 --- a/arch/sim/src/sim/up_lcd.c +++ b/arch/sim/src/sim/up_lcd.c @@ -103,19 +103,19 @@ struct sim_dev_s /* LCD Data Transfer Methods */ static int sim_putrun(fb_coord_t row, fb_coord_t col, - FAR const uint8_t *buffer, size_t npixels); + const uint8_t *buffer, size_t npixels); static int sim_putarea(fb_coord_t row_start, fb_coord_t row_end, fb_coord_t col_start, fb_coord_t col_end, - FAR const uint8_t *buffer); -static int sim_getrun(fb_coord_t row, fb_coord_t col, FAR uint8_t *buffer, + const uint8_t *buffer); +static int sim_getrun(fb_coord_t row, fb_coord_t col, uint8_t *buffer, size_t npixels); /* LCD Configuration */ -static int sim_getvideoinfo(FAR struct lcd_dev_s *dev, - FAR struct fb_videoinfo_s *vinfo); -static int sim_getplaneinfo(FAR struct lcd_dev_s *dev, unsigned int planeno, - FAR struct lcd_planeinfo_s *pinfo); +static int sim_getvideoinfo(struct lcd_dev_s *dev, + struct fb_videoinfo_s *vinfo); +static int sim_getplaneinfo(struct lcd_dev_s *dev, unsigned int planeno, + struct lcd_planeinfo_s *pinfo); /* LCD RGB Mapping */ @@ -178,7 +178,7 @@ static struct lcd_planeinfo_s g_planeinfo = .putarea = sim_putarea, /* Put a rectangular area to LCD */ .getrun = sim_getrun, /* Get a run from LCD memory */ #ifndef CONFIG_SIM_X11FB - .buffer = (FAR uint8_t *)g_runbuffer, /* Run scratch buffer */ + .buffer = (uint8_t *)g_runbuffer, /* Run scratch buffer */ #endif .bpp = CONFIG_SIM_FBBPP, /* Bits-per-pixel */ }; @@ -226,7 +226,7 @@ static struct sim_dev_s g_lcddev = ****************************************************************************/ static int sim_putrun(fb_coord_t row, fb_coord_t col, - FAR const uint8_t *buffer, size_t npixels) + const uint8_t *buffer, size_t npixels) { lcdinfo("row: %d col: %d npixels: %d\n", row, col, npixels); @@ -255,7 +255,7 @@ static int sim_putrun(fb_coord_t row, fb_coord_t col, static int sim_putarea(fb_coord_t row_start, fb_coord_t row_end, fb_coord_t col_start, fb_coord_t col_end, - FAR const uint8_t *buffer) + const uint8_t *buffer) { fb_coord_t row; size_t rows; @@ -309,7 +309,7 @@ static int sim_putarea(fb_coord_t row_start, fb_coord_t row_end, * ****************************************************************************/ -static int sim_getrun(fb_coord_t row, fb_coord_t col, FAR uint8_t *buffer, +static int sim_getrun(fb_coord_t row, fb_coord_t col, uint8_t *buffer, size_t npixels) { lcdinfo("row: %d col: %d npixels: %d\n", row, col, npixels); @@ -324,8 +324,8 @@ static int sim_getrun(fb_coord_t row, fb_coord_t col, FAR uint8_t *buffer, * ****************************************************************************/ -static int sim_getvideoinfo(FAR struct lcd_dev_s *dev, - FAR struct fb_videoinfo_s *vinfo) +static int sim_getvideoinfo(struct lcd_dev_s *dev, + struct fb_videoinfo_s *vinfo) { DEBUGASSERT(dev && vinfo); ginfo("fmt: %d xres: %d yres: %d nplanes: %d\n", @@ -344,8 +344,8 @@ static int sim_getvideoinfo(FAR struct lcd_dev_s *dev, * ****************************************************************************/ -static int sim_getplaneinfo(FAR struct lcd_dev_s *dev, unsigned int planeno, - FAR struct lcd_planeinfo_s *pinfo) +static int sim_getplaneinfo(struct lcd_dev_s *dev, unsigned int planeno, + struct lcd_planeinfo_s *pinfo) { DEBUGASSERT(dev && pinfo && planeno == 0); ginfo("planeno: %d bpp: %d\n", planeno, g_planeinfo.bpp); @@ -423,7 +423,7 @@ static int sim_setcontrast(struct lcd_dev_s *dev, unsigned int contrast) ****************************************************************************/ #ifdef CONFIG_SIM_X11FB -static void up_updatework(FAR void *arg) +static void up_updatework(void *arg) { work_queue(LPWORK, &g_updatework, up_updatework, NULL, MSEC2TICK(33)); up_x11update(); @@ -474,7 +474,7 @@ int board_lcd_initialize(void) * ****************************************************************************/ -FAR struct lcd_dev_s *board_lcd_getdev(int lcddev) +struct lcd_dev_s *board_lcd_getdev(int lcddev) { DEBUGASSERT(lcddev == 0); return &g_lcddev.dev; diff --git a/arch/sim/src/sim/up_macho_init.c b/arch/sim/src/sim/up_macho_init.c index 27c85d8325f69..fe02e72dd23fc 100644 --- a/arch/sim/src/sim/up_macho_init.c +++ b/arch/sim/src/sim/up_macho_init.c @@ -67,7 +67,7 @@ allow_write(const void *start, const void *end) * the OS version. */ - (void)mprotect(p, sz, PROT_READ | PROT_WRITE); + mprotect(p, sz, PROT_READ | PROT_WRITE); } __attribute__((constructor)) diff --git a/arch/sim/src/sim/up_netdriver.c b/arch/sim/src/sim/up_netdriver.c index ac7df12b7a7f3..728bd6a47925e 100644 --- a/arch/sim/src/sim/up_netdriver.c +++ b/arch/sim/src/sim/up_netdriver.c @@ -89,7 +89,7 @@ static struct net_driver_s g_sim_dev; * Private Functions ****************************************************************************/ -static void netdriver_reply(FAR struct net_driver_s *dev) +static void netdriver_reply(struct net_driver_s *dev) { /* If the receiving resulted in data that should be sent out on * the network, the field d_len is set to a value > 0. @@ -127,10 +127,10 @@ static void netdriver_reply(FAR struct net_driver_s *dev) } } -static void netdriver_recv_work(FAR void *arg) +static void netdriver_recv_work(void *arg) { - FAR struct net_driver_s *dev = arg; - FAR struct eth_hdr_s *eth; + struct net_driver_s *dev = arg; + struct eth_hdr_s *eth; net_lock(); @@ -144,7 +144,7 @@ static void netdriver_recv_work(FAR void *arg) * on a data received event */ - dev->d_len = netdev_read((FAR unsigned char *)dev->d_buf, + dev->d_len = netdev_read((unsigned char *)dev->d_buf, dev->d_pktsize); if (dev->d_len > 0) { @@ -154,7 +154,7 @@ static void netdriver_recv_work(FAR void *arg) * destination == our MAC address */ - eth = (FAR struct eth_hdr_s *)dev->d_buf; + eth = (struct eth_hdr_s *)dev->d_buf; if (dev->d_len > ETH_HDRLEN) { #ifdef CONFIG_NET_PKT @@ -240,7 +240,7 @@ static void netdriver_recv_work(FAR void *arg) net_unlock(); } -static int netdriver_txpoll(FAR struct net_driver_s *dev) +static int netdriver_txpoll(struct net_driver_s *dev) { /* If the polling resulted in data that should be sent out on the network, * the field d_len is set to a value > 0. @@ -287,9 +287,9 @@ static int netdriver_txpoll(FAR struct net_driver_s *dev) return 0; } -static void netdriver_timer_work(FAR void *arg) +static void netdriver_timer_work(void *arg) { - FAR struct net_driver_s *dev = arg; + struct net_driver_s *dev = arg; net_lock(); if (IFF_IS_UP(dev->d_flags)) @@ -301,7 +301,7 @@ static void netdriver_timer_work(FAR void *arg) net_unlock(); } -static int netdriver_ifup(FAR struct net_driver_s *dev) +static int netdriver_ifup(struct net_driver_s *dev) { netdev_ifup(dev->d_ipaddr); work_queue(LPWORK, &g_timer_work, netdriver_timer_work, dev, CLK_TCK); @@ -309,7 +309,7 @@ static int netdriver_ifup(FAR struct net_driver_s *dev) return OK; } -static int netdriver_ifdown(FAR struct net_driver_s *dev) +static int netdriver_ifdown(struct net_driver_s *dev) { netdev_carrier_off(dev); work_cancel(LPWORK, &g_timer_work); @@ -317,9 +317,9 @@ static int netdriver_ifdown(FAR struct net_driver_s *dev) return OK; } -static void netdriver_txavail_work(FAR void *arg) +static void netdriver_txavail_work(void *arg) { - FAR struct net_driver_s *dev = arg; + struct net_driver_s *dev = arg; net_lock(); if (IFF_IS_UP(dev->d_flags)) @@ -330,7 +330,7 @@ static void netdriver_txavail_work(FAR void *arg) net_unlock(); } -static int netdriver_txavail(FAR struct net_driver_s *dev) +static int netdriver_txavail(struct net_driver_s *dev) { if (work_available(&g_avail_work)) { @@ -340,20 +340,20 @@ static int netdriver_txavail(FAR struct net_driver_s *dev) return OK; } -static void netdriver_txdone_interrupt(FAR void *priv) +static void netdriver_txdone_interrupt(void *priv) { if (work_available(&g_avail_work)) { - FAR struct net_driver_s *dev = (FAR struct net_driver_s *)priv; + struct net_driver_s *dev = (struct net_driver_s *)priv; work_queue(LPWORK, &g_avail_work, netdriver_txavail_work, dev, 0); } } -static void netdriver_rxready_interrupt(FAR void *priv) +static void netdriver_rxready_interrupt(void *priv) { if (work_available(&g_recv_work)) { - FAR struct net_driver_s *dev = (FAR struct net_driver_s *)priv; + struct net_driver_s *dev = (struct net_driver_s *)priv; work_queue(LPWORK, &g_recv_work, netdriver_recv_work, dev, 0); } } @@ -364,7 +364,7 @@ static void netdriver_rxready_interrupt(FAR void *priv) int netdriver_init(void) { - FAR struct net_driver_s *dev = &g_sim_dev; + struct net_driver_s *dev = &g_sim_dev; void *pktbuf; int pktsize; diff --git a/arch/sim/src/sim/up_oneshot.c b/arch/sim/src/sim/up_oneshot.c index c0a8f2f5fdd4f..b642d031d8f81 100644 --- a/arch/sim/src/sim/up_oneshot.c +++ b/arch/sim/src/sim/up_oneshot.c @@ -61,8 +61,8 @@ struct sim_oneshot_lowerhalf_s sq_entry_t link; struct timespec alarm; - oneshot_callback_t callback; /* internal handler that receives callback */ - FAR void *arg; /* Argument that is passed to the handler */ + oneshot_callback_t callback; /* internal handler that receives callback */ + void *arg; /* Argument that is passed to the handler */ }; /**************************************************************************** @@ -71,15 +71,15 @@ struct sim_oneshot_lowerhalf_s static void sim_process_tick(sq_entry_t *entry); -static int sim_max_delay(FAR struct oneshot_lowerhalf_s *lower, - FAR struct timespec *ts); -static int sim_start(FAR struct oneshot_lowerhalf_s *lower, - oneshot_callback_t callback, FAR void *arg, - FAR const struct timespec *ts); -static int sim_cancel(FAR struct oneshot_lowerhalf_s *lower, - FAR struct timespec *ts); -static int sim_current(FAR struct oneshot_lowerhalf_s *lower, - FAR struct timespec *ts); +static int sim_max_delay(struct oneshot_lowerhalf_s *lower, + struct timespec *ts); +static int sim_start(struct oneshot_lowerhalf_s *lower, + oneshot_callback_t callback, void *arg, + const struct timespec *ts); +static int sim_cancel(struct oneshot_lowerhalf_s *lower, + struct timespec *ts); +static int sim_current(struct oneshot_lowerhalf_s *lower, + struct timespec *ts); /**************************************************************************** * Private Data @@ -109,7 +109,7 @@ static const struct oneshot_operations_s g_oneshot_ops = * ****************************************************************************/ -static inline void sim_timer_current(FAR struct timespec *ts) +static inline void sim_timer_current(struct timespec *ts) { uint64_t nsec; time_t sec; @@ -133,7 +133,7 @@ static inline void sim_timer_current(FAR struct timespec *ts) static void sim_timer_update(void) { - FAR sq_entry_t *entry; + sq_entry_t *entry; for (entry = sq_peek(&g_oneshot_list); entry; entry = sq_next(entry)) { @@ -157,10 +157,10 @@ static void sim_timer_update(void) static void sim_process_tick(sq_entry_t *entry) { - FAR struct sim_oneshot_lowerhalf_s *priv = + struct sim_oneshot_lowerhalf_s *priv = container_of(entry, struct sim_oneshot_lowerhalf_s, link); oneshot_callback_t callback; - FAR void *cbarg; + void *cbarg; DEBUGASSERT(priv != NULL); @@ -207,8 +207,8 @@ static void sim_process_tick(sq_entry_t *entry) * ****************************************************************************/ -static int sim_max_delay(FAR struct oneshot_lowerhalf_s *lower, - FAR struct timespec *ts) +static int sim_max_delay(struct oneshot_lowerhalf_s *lower, + struct timespec *ts) { DEBUGASSERT(ts != NULL); @@ -237,12 +237,12 @@ static int sim_max_delay(FAR struct oneshot_lowerhalf_s *lower, * ****************************************************************************/ -static int sim_start(FAR struct oneshot_lowerhalf_s *lower, - oneshot_callback_t callback, FAR void *arg, - FAR const struct timespec *ts) +static int sim_start(struct oneshot_lowerhalf_s *lower, + oneshot_callback_t callback, void *arg, + const struct timespec *ts) { - FAR struct sim_oneshot_lowerhalf_s *priv = - (FAR struct sim_oneshot_lowerhalf_s *)lower; + struct sim_oneshot_lowerhalf_s *priv = + (struct sim_oneshot_lowerhalf_s *)lower; struct timespec current; DEBUGASSERT(priv != NULL && callback != NULL && ts != NULL); @@ -280,11 +280,11 @@ static int sim_start(FAR struct oneshot_lowerhalf_s *lower, * ****************************************************************************/ -static int sim_cancel(FAR struct oneshot_lowerhalf_s *lower, - FAR struct timespec *ts) +static int sim_cancel(struct oneshot_lowerhalf_s *lower, + struct timespec *ts) { - FAR struct sim_oneshot_lowerhalf_s *priv = - (FAR struct sim_oneshot_lowerhalf_s *)lower; + struct sim_oneshot_lowerhalf_s *priv = + (struct sim_oneshot_lowerhalf_s *)lower; struct timespec current; DEBUGASSERT(priv != NULL && ts != NULL); @@ -317,8 +317,8 @@ static int sim_cancel(FAR struct oneshot_lowerhalf_s *lower, * ****************************************************************************/ -static int sim_current(FAR struct oneshot_lowerhalf_s *lower, - FAR struct timespec *ts) +static int sim_current(struct oneshot_lowerhalf_s *lower, + struct timespec *ts) { DEBUGASSERT(ts != NULL); @@ -342,7 +342,7 @@ static int sim_current(FAR struct oneshot_lowerhalf_s *lower, * ****************************************************************************/ -static int sim_alarm_handler(int irq, FAR void *context, FAR void *arg) +static int sim_alarm_handler(int irq, void *context, void *arg) { sim_timer_update(); return OK; @@ -372,14 +372,14 @@ static int sim_alarm_handler(int irq, FAR void *context, FAR void *arg) * ****************************************************************************/ -FAR struct oneshot_lowerhalf_s *oneshot_initialize(int chan, - uint16_t resolution) +struct oneshot_lowerhalf_s *oneshot_initialize(int chan, + uint16_t resolution) { - FAR struct sim_oneshot_lowerhalf_s *priv; + struct sim_oneshot_lowerhalf_s *priv; /* Allocate an instance of the lower half driver */ - priv = (FAR struct sim_oneshot_lowerhalf_s *) + priv = (struct sim_oneshot_lowerhalf_s *) kmm_zalloc(sizeof(struct sim_oneshot_lowerhalf_s)); if (priv == NULL) diff --git a/arch/sim/src/sim/up_releasepending.c b/arch/sim/src/sim/up_releasepending.c index 3f0ca8ec64859..1e1352d514166 100644 --- a/arch/sim/src/sim/up_releasepending.c +++ b/arch/sim/src/sim/up_releasepending.c @@ -50,7 +50,7 @@ void up_release_pending(void) { - FAR struct tcb_s *rtcb = this_task(); + struct tcb_s *rtcb = this_task(); sinfo("From TCB=%p\n", rtcb); diff --git a/arch/sim/src/sim/up_releasestack.c b/arch/sim/src/sim/up_releasestack.c index 1210e390c5d56..749cdd514be85 100644 --- a/arch/sim/src/sim/up_releasestack.c +++ b/arch/sim/src/sim/up_releasestack.c @@ -58,7 +58,7 @@ * ****************************************************************************/ -void up_release_stack(FAR struct tcb_s *dtcb, uint8_t ttype) +void up_release_stack(struct tcb_s *dtcb, uint8_t ttype) { /* Is there a stack allocated? */ diff --git a/arch/sim/src/sim/up_reprioritizertr.c b/arch/sim/src/sim/up_reprioritizertr.c index 5b3a23228a9e3..ca8858a0be6a4 100644 --- a/arch/sim/src/sim/up_reprioritizertr.c +++ b/arch/sim/src/sim/up_reprioritizertr.c @@ -77,7 +77,7 @@ void up_reprioritize_rtr(struct tcb_s *tcb, uint8_t priority) } else { - FAR struct tcb_s *rtcb = this_task(); + struct tcb_s *rtcb = this_task(); bool switch_needed; sinfo("TCB=%p PRI=%d\n", tcb, priority); diff --git a/arch/sim/src/sim/up_romgetc.c b/arch/sim/src/sim/up_romgetc.c index 01af4de2eb6e6..c4cc3b507056d 100644 --- a/arch/sim/src/sim/up_romgetc.c +++ b/arch/sim/src/sim/up_romgetc.c @@ -63,7 +63,7 @@ * ****************************************************************************/ -char up_romgetc(FAR const char *ptr) +char up_romgetc(const char *ptr) { /* This is basically a No-Op if enabled in the simulation environment */ diff --git a/arch/sim/src/sim/up_rtc.c b/arch/sim/src/sim/up_rtc.c index ac60b7f12ee2c..15723086e0af0 100644 --- a/arch/sim/src/sim/up_rtc.c +++ b/arch/sim/src/sim/up_rtc.c @@ -35,11 +35,11 @@ * Private Function Prototypes ****************************************************************************/ -static int sim_rtc_rdtime(FAR struct rtc_lowerhalf_s *lower, - FAR struct rtc_time *rtctime); -static int sim_rtc_settime(FAR struct rtc_lowerhalf_s *lower, - FAR const struct rtc_time *rtctime); -static bool sim_rtc_havesettime(FAR struct rtc_lowerhalf_s *lower); +static int sim_rtc_rdtime(struct rtc_lowerhalf_s *lower, + struct rtc_time *rtctime); +static int sim_rtc_settime(struct rtc_lowerhalf_s *lower, + const struct rtc_time *rtctime); +static bool sim_rtc_havesettime(struct rtc_lowerhalf_s *lower); /**************************************************************************** * Private Data @@ -63,8 +63,8 @@ static int64_t g_sim_delta; * Private Functions ****************************************************************************/ -static int sim_rtc_rdtime(FAR struct rtc_lowerhalf_s *lower, - FAR struct rtc_time *rtctime) +static int sim_rtc_rdtime(struct rtc_lowerhalf_s *lower, + struct rtc_time *rtctime) { uint64_t nsec; time_t sec; @@ -74,16 +74,16 @@ static int sim_rtc_rdtime(FAR struct rtc_lowerhalf_s *lower, sec = nsec / NSEC_PER_SEC; nsec -= sec * NSEC_PER_SEC; - gmtime_r(&sec, (FAR struct tm *)rtctime); + gmtime_r(&sec, (struct tm *)rtctime); rtctime->tm_nsec = nsec; return OK; } -static int sim_rtc_settime(FAR struct rtc_lowerhalf_s *lower, - FAR const struct rtc_time *rtctime) +static int sim_rtc_settime(struct rtc_lowerhalf_s *lower, + const struct rtc_time *rtctime) { - g_sim_delta = timegm((FAR struct tm *)rtctime); + g_sim_delta = timegm((struct tm *)rtctime); g_sim_delta *= NSEC_PER_SEC; g_sim_delta += rtctime->tm_nsec; g_sim_delta -= host_gettime(true); @@ -91,7 +91,7 @@ static int sim_rtc_settime(FAR struct rtc_lowerhalf_s *lower, return OK; } -static bool sim_rtc_havesettime(FAR struct rtc_lowerhalf_s *lower) +static bool sim_rtc_havesettime(struct rtc_lowerhalf_s *lower) { return true; } @@ -123,7 +123,7 @@ static bool sim_rtc_havesettime(FAR struct rtc_lowerhalf_s *lower) int up_rtc_initialize(void) { - FAR struct rtc_lowerhalf_s *rtc = &g_sim_rtc; + struct rtc_lowerhalf_s *rtc = &g_sim_rtc; bool sync = true; #ifdef CONFIG_RTC_RPMSG_SERVER diff --git a/arch/sim/src/sim/up_smpsignal.c b/arch/sim/src/sim/up_smpsignal.c index ad127303366ff..42c39b3a66bcf 100644 --- a/arch/sim/src/sim/up_smpsignal.c +++ b/arch/sim/src/sim/up_smpsignal.c @@ -71,7 +71,7 @@ static volatile spinlock_t g_cpu_paused[CONFIG_SMP_NCPUS]; * ****************************************************************************/ -static int sim_cpupause_handler(int irq, FAR void *context, FAR void *arg) +static int sim_cpupause_handler(int irq, void *context, void *arg) { int cpu = this_cpu(); @@ -221,7 +221,7 @@ __attribute__ ((visibility("default"))) void up_cpu_started(void) { #ifdef CONFIG_SCHED_INSTRUMENTATION - FAR struct tcb_s *tcb = this_task(); + struct tcb_s *tcb = this_task(); /* Notify that this CPU has started */ @@ -262,7 +262,7 @@ void up_cpu_started(void) int up_cpu_start(int cpu) { - FAR struct tcb_s *tcb = current_task(cpu); + struct tcb_s *tcb = current_task(cpu); #ifdef CONFIG_SCHED_INSTRUMENTATION /* Notify of the start event */ diff --git a/arch/sim/src/sim/up_stackframe.c b/arch/sim/src/sim/up_stackframe.c index 2640f16436a1a..850bfc9690e64 100644 --- a/arch/sim/src/sim/up_stackframe.c +++ b/arch/sim/src/sim/up_stackframe.c @@ -69,9 +69,9 @@ * ****************************************************************************/ -FAR void *up_stack_frame(FAR struct tcb_s *tcb, size_t frame_size) +void *up_stack_frame(struct tcb_s *tcb, size_t frame_size) { - FAR void *ret; + void *ret; /* Align the frame_size */ @@ -89,7 +89,7 @@ FAR void *up_stack_frame(FAR struct tcb_s *tcb, size_t frame_size) /* Save the adjusted stack values in the struct tcb_s */ - tcb->stack_base_ptr = (FAR uint8_t *)tcb->stack_base_ptr + frame_size; + tcb->stack_base_ptr = (uint8_t *)tcb->stack_base_ptr + frame_size; tcb->adj_stack_size -= frame_size; /* And return a pointer to the allocated memory */ diff --git a/arch/sim/src/sim/up_touchscreen.c b/arch/sim/src/sim/up_touchscreen.c index 962a8be72e137..c271d309eef66 100644 --- a/arch/sim/src/sim/up_touchscreen.c +++ b/arch/sim/src/sim/up_touchscreen.c @@ -96,7 +96,7 @@ static struct up_dev_s g_simtouchscreen; int sim_tsc_initialize(int minor) { - FAR struct up_dev_s *priv = (FAR struct up_dev_s *)&g_simtouchscreen; + struct up_dev_s *priv = (struct up_dev_s *)&g_simtouchscreen; char devname[DEV_NAMELEN]; int ret; @@ -115,7 +115,7 @@ int sim_tsc_initialize(int minor) /* Register the device as an input device */ - snprintf(devname, DEV_NAMELEN, DEV_FORMAT, minor); + snprintf(devname, sizeof(devname), DEV_FORMAT, minor); iinfo("Registering %s\n", devname); ret = touch_register(&priv->lower, devname, 1); @@ -150,7 +150,7 @@ int sim_tsc_initialize(int minor) int sim_tsc_uninitialize(void) { - FAR struct up_dev_s *priv = (FAR struct up_dev_s *)&g_simtouchscreen; + struct up_dev_s *priv = (struct up_dev_s *)&g_simtouchscreen; char devname[DEV_NAMELEN]; /* Stop the event loop (Hmm.. the caller must be sure that there are no @@ -162,7 +162,7 @@ int sim_tsc_uninitialize(void) /* Un-register the device */ - snprintf(devname, DEV_NAMELEN, DEV_FORMAT, priv->minor); + snprintf(devname, sizeof(devname), DEV_FORMAT, priv->minor); iinfo("Un-registering %s\n", devname); touch_unregister(&priv->lower, devname); @@ -176,7 +176,7 @@ int sim_tsc_uninitialize(void) void up_buttonevent(int x, int y, int buttons) { - FAR struct up_dev_s *priv = (FAR struct up_dev_s *)&g_simtouchscreen; + struct up_dev_s *priv = (struct up_dev_s *)&g_simtouchscreen; struct touch_sample_s sample; /* Sampled touch point data */ bool pendown; /* true: pen is down */ diff --git a/arch/sim/src/sim/up_uart.c b/arch/sim/src/sim/up_uart.c index 7b8d773d05d53..545e49a6e3627 100644 --- a/arch/sim/src/sim/up_uart.c +++ b/arch/sim/src/sim/up_uart.c @@ -48,7 +48,7 @@ struct tty_priv_s { /* tty-port path name */ - FAR const char *path; + const char *path; /* The file descriptor. It is returned by open */ @@ -59,21 +59,21 @@ struct tty_priv_s * Private Function Prototypes ****************************************************************************/ -static int tty_setup(FAR struct uart_dev_s *dev); -static void tty_shutdown(FAR struct uart_dev_s *dev); -static int tty_attach(FAR struct uart_dev_s *dev); -static void tty_detach(FAR struct uart_dev_s *dev); -static int tty_ioctl(FAR struct file *filep, int cmd, +static int tty_setup(struct uart_dev_s *dev); +static void tty_shutdown(struct uart_dev_s *dev); +static int tty_attach(struct uart_dev_s *dev); +static void tty_detach(struct uart_dev_s *dev); +static int tty_ioctl(struct file *filep, int cmd, unsigned long arg); -static int tty_receive(FAR struct uart_dev_s *dev, uint32_t *status); -static void tty_rxint(FAR struct uart_dev_s *dev, bool enable); -static bool tty_rxavailable(FAR struct uart_dev_s *dev); -static bool tty_rxflowcontrol(FAR struct uart_dev_s *dev, +static int tty_receive(struct uart_dev_s *dev, uint32_t *status); +static void tty_rxint(struct uart_dev_s *dev, bool enable); +static bool tty_rxavailable(struct uart_dev_s *dev); +static bool tty_rxflowcontrol(struct uart_dev_s *dev, unsigned int nbuffered, bool upper); -static void tty_send(FAR struct uart_dev_s *dev, int ch); -static void tty_txint(FAR struct uart_dev_s *dev, bool enable); -static bool tty_txready(FAR struct uart_dev_s *dev); -static bool tty_txempty(FAR struct uart_dev_s *dev); +static void tty_send(struct uart_dev_s *dev, int ch); +static void tty_txint(struct uart_dev_s *dev, bool enable); +static bool tty_txready(struct uart_dev_s *dev); +static bool tty_txempty(struct uart_dev_s *dev); /**************************************************************************** * Private Data @@ -251,9 +251,9 @@ static struct uart_dev_s g_tty3_dev = * ****************************************************************************/ -static int tty_setup(FAR struct uart_dev_s *dev) +static int tty_setup(struct uart_dev_s *dev) { - FAR struct tty_priv_s *priv = dev->priv; + struct tty_priv_s *priv = dev->priv; if (!dev->isconsole && priv->fd < 0) { @@ -278,7 +278,7 @@ static int tty_setup(FAR struct uart_dev_s *dev) static void tty_shutdown(struct uart_dev_s *dev) { - FAR struct tty_priv_s *priv = dev->priv; + struct tty_priv_s *priv = dev->priv; if (!dev->isconsole && priv->fd >= 0) { @@ -320,7 +320,7 @@ static int tty_attach(struct uart_dev_s *dev) * ****************************************************************************/ -static void tty_detach(FAR struct uart_dev_s *dev) +static void tty_detach(struct uart_dev_s *dev) { } @@ -335,10 +335,10 @@ static void tty_detach(FAR struct uart_dev_s *dev) static int tty_ioctl(struct file *filep, int cmd, unsigned long arg) { #ifdef CONFIG_SERIAL_TERMIOS - FAR struct inode *inode = filep->f_inode; - FAR struct uart_dev_s *dev = inode->i_private; - FAR struct tty_priv_s *priv = dev->priv; - FAR struct termios *termiosp = (FAR struct termios *)(uintptr_t)arg; + struct inode *inode = filep->f_inode; + struct uart_dev_s *dev = inode->i_private; + struct tty_priv_s *priv = dev->priv; + struct termios *termiosp = (struct termios *)(uintptr_t)arg; if (!termiosp) { @@ -372,7 +372,7 @@ static int tty_ioctl(struct file *filep, int cmd, unsigned long arg) static int tty_receive(struct uart_dev_s *dev, uint32_t *status) { - FAR struct tty_priv_s *priv = dev->priv; + struct tty_priv_s *priv = dev->priv; *status = 0; return simuart_getc(dev->isconsole ? 0 : priv->fd); @@ -400,7 +400,7 @@ static void tty_rxint(struct uart_dev_s *dev, bool enable) static bool tty_rxavailable(struct uart_dev_s *dev) { - FAR struct tty_priv_s *priv = dev->priv; + struct tty_priv_s *priv = dev->priv; return simuart_checkc(dev->isconsole ? 0 : priv->fd); } @@ -414,10 +414,10 @@ static bool tty_rxavailable(struct uart_dev_s *dev) * ****************************************************************************/ -static bool tty_rxflowcontrol(FAR struct uart_dev_s *dev, +static bool tty_rxflowcontrol(struct uart_dev_s *dev, unsigned int nbuffered, bool upper) { - FAR struct uart_buffer_s *rxbuf = &dev->recv; + struct uart_buffer_s *rxbuf = &dev->recv; if (nbuffered == rxbuf->size) { @@ -437,7 +437,7 @@ static bool tty_rxflowcontrol(FAR struct uart_dev_s *dev, static void tty_send(struct uart_dev_s *dev, int ch) { - FAR struct tty_priv_s *priv = dev->priv; + struct tty_priv_s *priv = dev->priv; /* For console device */ diff --git a/arch/sim/src/sim/up_unblocktask.c b/arch/sim/src/sim/up_unblocktask.c index 1c903b957ad5e..7f5474e23c4fc 100644 --- a/arch/sim/src/sim/up_unblocktask.c +++ b/arch/sim/src/sim/up_unblocktask.c @@ -54,9 +54,9 @@ * ****************************************************************************/ -void up_unblock_task(FAR struct tcb_s *tcb) +void up_unblock_task(struct tcb_s *tcb) { - FAR struct tcb_s *rtcb = this_task(); + struct tcb_s *rtcb = this_task(); /* Verify that the context switch can be performed */ diff --git a/arch/sim/src/sim/up_usestack.c b/arch/sim/src/sim/up_usestack.c index 1c23d4719a358..8d3ffa8889900 100644 --- a/arch/sim/src/sim/up_usestack.c +++ b/arch/sim/src/sim/up_usestack.c @@ -66,7 +66,7 @@ * ****************************************************************************/ -int up_use_stack(FAR struct tcb_s *tcb, FAR void *stack, size_t stack_size) +int up_use_stack(struct tcb_s *tcb, void *stack, size_t stack_size) { #if CONFIG_SIM_STACKSIZE_ADJUSTMENT == 0 uintptr_t top_of_stack; diff --git a/arch/sim/src/sim/up_usrsock.c b/arch/sim/src/sim/up_usrsock.c index 0d4121bc6ebbb..846f8f1d70554 100644 --- a/arch/sim/src/sim/up_usrsock.c +++ b/arch/sim/src/sim/up_usrsock.c @@ -56,8 +56,8 @@ struct usrsock_s * Private Function Prototypes ****************************************************************************/ -typedef int (*usrsock_handler_t)(FAR struct usrsock_s *usrsock, - FAR const void *data, size_t len); +typedef int (*usrsock_handler_t)(struct usrsock_s *usrsock, + const void *data, size_t len); /**************************************************************************** * Private Data @@ -69,10 +69,10 @@ static struct usrsock_s g_usrsock; * Private Functions ****************************************************************************/ -static int usrsock_send(FAR struct usrsock_s *usrsock, - FAR const void *buf, size_t len) +static int usrsock_send(struct usrsock_s *usrsock, + const void *buf, size_t len) { - FAR uint8_t *data = (FAR uint8_t *)buf; + uint8_t *data = (uint8_t *)buf; ssize_t ret; while (len > 0) @@ -90,7 +90,7 @@ static int usrsock_send(FAR struct usrsock_s *usrsock, return 0; } -static int usrsock_send_ack(FAR struct usrsock_s *usrsock, +static int usrsock_send_ack(struct usrsock_s *usrsock, uint64_t xid, int32_t result) { struct usrsock_message_req_ack_s ack; @@ -104,8 +104,8 @@ static int usrsock_send_ack(FAR struct usrsock_s *usrsock, return usrsock_send(usrsock, &ack, sizeof(ack)); } -static int usrsock_send_dack(FAR struct usrsock_s *usrsock, - FAR struct usrsock_message_datareq_ack_s *ack, +static int usrsock_send_dack(struct usrsock_s *usrsock, + struct usrsock_message_datareq_ack_s *ack, uint64_t xid, int32_t result, uint16_t valuelen, uint16_t valuelen_nontrunc) @@ -133,24 +133,24 @@ static int usrsock_send_dack(FAR struct usrsock_s *usrsock, return usrsock_send(usrsock, ack, sizeof(*ack) + valuelen + result); } -static int usrsock_send_event(FAR struct usrsock_s *usrsock, +static int usrsock_send_event(struct usrsock_s *usrsock, int16_t usockid, uint16_t events) { struct usrsock_message_socket_event_s event; - event.head.msgid = USRSOCK_MESSAGE_SOCKET_EVENT; - event.head.flags = USRSOCK_MESSAGE_FLAG_EVENT; + event.head.msgid = USRSOCK_MESSAGE_SOCKET_EVENT; + event.head.flags = USRSOCK_MESSAGE_FLAG_EVENT; + event.head.events = events; event.usockid = usockid; - event.events = events; return usrsock_send(usrsock, &event, sizeof(event)); } -static int usrsock_socket_handler(FAR struct usrsock_s *usrsock, - FAR const void *data, size_t len) +static int usrsock_socket_handler(struct usrsock_s *usrsock, + const void *data, size_t len) { - FAR const struct usrsock_request_socket_s *req = data; + const struct usrsock_request_socket_s *req = data; int fd = usrsock_host_socket(req->domain, req->type, req->protocol); int ret = usrsock_send_ack(usrsock, req->head.xid, fd); @@ -162,35 +162,35 @@ static int usrsock_socket_handler(FAR struct usrsock_s *usrsock, return ret; } -static int usrsock_close_handler(FAR struct usrsock_s *usrsock, - FAR const void *data, size_t len) +static int usrsock_close_handler(struct usrsock_s *usrsock, + const void *data, size_t len) { - FAR const struct usrsock_request_close_s *req = data; + const struct usrsock_request_close_s *req = data; int ret = usrsock_host_close(req->usockid); return usrsock_send_ack(usrsock, req->head.xid, ret); } -static int usrsock_connect_handler(FAR struct usrsock_s *usrsock, - FAR const void *data, size_t len) +static int usrsock_connect_handler(struct usrsock_s *usrsock, + const void *data, size_t len) { - FAR const struct usrsock_request_connect_s *req = data; + const struct usrsock_request_connect_s *req = data; int ret = usrsock_host_connect(req->usockid, - (FAR const struct sockaddr *)(req + 1), + (const struct sockaddr *)(req + 1), req->addrlen); return usrsock_send_ack(usrsock, req->head.xid, ret); } -static int usrsock_sendto_handler(FAR struct usrsock_s *usrsock, - FAR const void *data, size_t len) +static int usrsock_sendto_handler(struct usrsock_s *usrsock, + const void *data, size_t len) { - FAR const struct usrsock_request_sendto_s *req = data; + const struct usrsock_request_sendto_s *req = data; int ret = usrsock_host_sendto(req->usockid, - (FAR const void *)(req + 1) + req->addrlen, + (const void *)(req + 1) + req->addrlen, req->buflen, req->flags, req->addrlen ? - (FAR const struct sockaddr *)(req + 1) : + (const struct sockaddr *)(req + 1) : NULL, req->addrlen); bool sent = (ret > 0); @@ -204,11 +204,11 @@ static int usrsock_sendto_handler(FAR struct usrsock_s *usrsock, return ret; } -static int usrsock_recvfrom_handler(FAR struct usrsock_s *usrsock, - FAR const void *data, size_t len) +static int usrsock_recvfrom_handler(struct usrsock_s *usrsock, + const void *data, size_t len) { - FAR const struct usrsock_request_recvfrom_s *req = data; - FAR struct usrsock_message_datareq_ack_s *ack; + const struct usrsock_request_recvfrom_s *req = data; + struct usrsock_message_datareq_ack_s *ack; socklen_t outaddrlen = req->max_addrlen; socklen_t inaddrlen = req->max_addrlen; size_t buflen = req->max_buflen; @@ -221,40 +221,40 @@ static int usrsock_recvfrom_handler(FAR struct usrsock_s *usrsock, } ret = usrsock_host_recvfrom(req->usockid, - (FAR void *)(ack + 1) + inaddrlen, + (void *)(ack + 1) + inaddrlen, buflen, req->flags, outaddrlen ? - (FAR struct sockaddr *)(ack + 1) : NULL, + (struct sockaddr *)(ack + 1) : NULL, outaddrlen ? &outaddrlen : NULL); if (ret > 0 && outaddrlen < inaddrlen) { - memcpy((FAR void *)(ack + 1) + outaddrlen, - (FAR void *)(ack + 1) + inaddrlen, ret); + memcpy((void *)(ack + 1) + outaddrlen, + (void *)(ack + 1) + inaddrlen, ret); } return usrsock_send_dack(usrsock, ack, req->head.xid, ret, inaddrlen, outaddrlen); } -static int usrsock_setsockopt_handler(FAR struct usrsock_s *usrsock, - FAR const void *data, size_t len) +static int usrsock_setsockopt_handler(struct usrsock_s *usrsock, + const void *data, size_t len) { - FAR const struct usrsock_request_setsockopt_s *req = data; + const struct usrsock_request_setsockopt_s *req = data; int ret = usrsock_host_setsockopt(req->usockid, req->level, req->option, req + 1, req->valuelen); return usrsock_send_ack(usrsock, req->head.xid, ret); } -static int usrsock_getsockopt_handler(FAR struct usrsock_s *usrsock, - FAR const void *data, size_t len) +static int usrsock_getsockopt_handler(struct usrsock_s *usrsock, + const void *data, size_t len) { - FAR const struct usrsock_request_getsockopt_s *req = data; - FAR struct usrsock_message_datareq_ack_s *ack; + const struct usrsock_request_getsockopt_s *req = data; + struct usrsock_message_datareq_ack_s *ack; socklen_t optlen = req->max_valuelen; int ret; - ack = (FAR struct usrsock_message_datareq_ack_s *)usrsock->out; + ack = (struct usrsock_message_datareq_ack_s *)usrsock->out; ret = usrsock_host_getsockopt(req->usockid, req->level, req->option, ack + 1, &optlen); @@ -263,74 +263,74 @@ static int usrsock_getsockopt_handler(FAR struct usrsock_s *usrsock, ret, optlen, optlen); } -static int usrsock_getsockname_handler(FAR struct usrsock_s *usrsock, - FAR const void *data, size_t len) +static int usrsock_getsockname_handler(struct usrsock_s *usrsock, + const void *data, size_t len) { - FAR const struct usrsock_request_getsockname_s *req = data; - FAR struct usrsock_message_datareq_ack_s *ack; + const struct usrsock_request_getsockname_s *req = data; + struct usrsock_message_datareq_ack_s *ack; socklen_t outaddrlen = req->max_addrlen; socklen_t inaddrlen = req->max_addrlen; int ret; - ack = (FAR struct usrsock_message_datareq_ack_s *)usrsock->out; + ack = (struct usrsock_message_datareq_ack_s *)usrsock->out; ret = usrsock_host_getsockname(req->usockid, - (FAR struct sockaddr *)(ack + 1), &outaddrlen); + (struct sockaddr *)(ack + 1), &outaddrlen); return usrsock_send_dack(usrsock, ack, req->head.xid, ret, inaddrlen, outaddrlen); } -static int usrsock_getpeername_handler(FAR struct usrsock_s *usrsock, - FAR const void *data, size_t len) +static int usrsock_getpeername_handler(struct usrsock_s *usrsock, + const void *data, size_t len) { - FAR const struct usrsock_request_getpeername_s *req = data; - FAR struct usrsock_message_datareq_ack_s *ack; + const struct usrsock_request_getpeername_s *req = data; + struct usrsock_message_datareq_ack_s *ack; socklen_t outaddrlen = req->max_addrlen; socklen_t inaddrlen = req->max_addrlen; int ret; - ack = (FAR struct usrsock_message_datareq_ack_s *)usrsock->out; + ack = (struct usrsock_message_datareq_ack_s *)usrsock->out; ret = usrsock_host_getpeername(req->usockid, - (FAR struct sockaddr *)(ack + 1), &outaddrlen); + (struct sockaddr *)(ack + 1), &outaddrlen); return usrsock_send_dack(usrsock, ack, req->head.xid, ret, inaddrlen, outaddrlen); } -static int usrsock_bind_handler(FAR struct usrsock_s *usrsock, - FAR const void *data, size_t len) +static int usrsock_bind_handler(struct usrsock_s *usrsock, + const void *data, size_t len) { - FAR const struct usrsock_request_bind_s *req = data; + const struct usrsock_request_bind_s *req = data; int ret = usrsock_host_bind(req->usockid, - (FAR const struct sockaddr *)(req + 1), + (const struct sockaddr *)(req + 1), req->addrlen); return usrsock_send_ack(usrsock, req->head.xid, ret); } -static int usrsock_listen_handler(FAR struct usrsock_s *usrsock, - FAR const void *data, size_t len) +static int usrsock_listen_handler(struct usrsock_s *usrsock, + const void *data, size_t len) { - FAR const struct usrsock_request_listen_s *req = data; + const struct usrsock_request_listen_s *req = data; int ret = usrsock_host_listen(req->usockid, req->backlog); return usrsock_send_ack(usrsock, req->head.xid, ret); } -static int usrsock_accept_handler(FAR struct usrsock_s *usrsock, - FAR const void *data, size_t len) +static int usrsock_accept_handler(struct usrsock_s *usrsock, + const void *data, size_t len) { - FAR const struct usrsock_request_accept_s *req = data; - FAR struct usrsock_message_datareq_ack_s *ack; + const struct usrsock_request_accept_s *req = data; + struct usrsock_message_datareq_ack_s *ack; socklen_t outaddrlen = req->max_addrlen; socklen_t inaddrlen = req->max_addrlen; int sockfd; int ret; - ack = (FAR struct usrsock_message_datareq_ack_s *)usrsock->out; + ack = (struct usrsock_message_datareq_ack_s *)usrsock->out; sockfd = usrsock_host_accept(req->usockid, outaddrlen ? - (FAR struct sockaddr *)(ack + 1) : NULL, + (struct sockaddr *)(ack + 1) : NULL, outaddrlen ? &outaddrlen : NULL); if (sockfd >= 0) { @@ -338,11 +338,11 @@ static int usrsock_accept_handler(FAR struct usrsock_s *usrsock, if (outaddrlen <= inaddrlen) { - *(FAR int16_t *)((FAR void *)(ack + 1) + outaddrlen) = sockfd; + *(int16_t *)((void *)(ack + 1) + outaddrlen) = sockfd; } else { - *(FAR int16_t *)((FAR void *)(ack + 1) + inaddrlen) = sockfd; + *(int16_t *)((void *)(ack + 1) + inaddrlen) = sockfd; } ret = sizeof(int16_t); /* Return usockid size */ @@ -362,14 +362,14 @@ static int usrsock_accept_handler(FAR struct usrsock_s *usrsock, return ret; } -static int usrsock_ioctl_handler(FAR struct usrsock_s *usrsock, - FAR const void *data, size_t len) +static int usrsock_ioctl_handler(struct usrsock_s *usrsock, + const void *data, size_t len) { - FAR const struct usrsock_request_ioctl_s *req = data; - FAR struct usrsock_message_datareq_ack_s *ack; + const struct usrsock_request_ioctl_s *req = data; + struct usrsock_message_datareq_ack_s *ack; int ret; - ack = (FAR struct usrsock_message_datareq_ack_s *)usrsock->out; + ack = (struct usrsock_message_datareq_ack_s *)usrsock->out; memcpy(ack + 1, req + 1, req->arglen); ret = usrsock_host_ioctl(req->usockid, req->cmd, (unsigned long)(ack + 1)); @@ -412,7 +412,7 @@ int usrsock_init(void) void usrsock_loop(void) { - FAR struct usrsock_request_common_s *common; + struct usrsock_request_common_s *common; int ret; struct pollfd pfd = { @@ -426,7 +426,7 @@ void usrsock_loop(void) ret = file_read(&g_usrsock.usock, g_usrsock.in, sizeof(g_usrsock.in)); if (ret > 0) { - common = (FAR struct usrsock_request_common_s *)g_usrsock.in; + common = (struct usrsock_request_common_s *)g_usrsock.in; if (common->reqid >= 0 && common->reqid < USRSOCK_REQUEST__MAX) diff --git a/arch/sim/src/sim/up_x11eventloop.c b/arch/sim/src/sim/up_x11eventloop.c index bf90d6d00d491..4bf95ebf32206 100644 --- a/arch/sim/src/sim/up_x11eventloop.c +++ b/arch/sim/src/sim/up_x11eventloop.c @@ -24,6 +24,7 @@ #include #include +#include #include "up_internal.h" @@ -116,6 +117,15 @@ void up_x11events(void) switch (event.type) { + #ifdef CONFIG_SIM_KEYBOARD + case KeyPress: + up_kbdevent(XLookupKeysym(&event.xkey, 0), true); + break; + case KeyRelease: + up_kbdevent(XLookupKeysym(&event.xkey, 0), false); + break; + #endif + case MotionNotify : /* Enabled by ButtonMotionMask */ { up_buttonevent(event.xmotion.x, event.xmotion.y, diff --git a/arch/sim/src/sim/up_x11framebuffer.c b/arch/sim/src/sim/up_x11framebuffer.c index 9bd994eb81107..3ba4255ca0000 100644 --- a/arch/sim/src/sim/up_x11framebuffer.c +++ b/arch/sim/src/sim/up_x11framebuffer.c @@ -115,7 +115,7 @@ static inline int up_x11createframe(void) #else XSelectInput(g_display, g_window, ButtonPressMask | ButtonReleaseMask | PointerMotionMask | - KeyPressMask); + KeyPressMask | KeyReleaseMask); #endif /* Release queued events on the display */ diff --git a/arch/sparc/include/syscall.h b/arch/sparc/include/syscall.h index ade5ce1eb8643..e82f78956f943 100644 --- a/arch/sparc/include/syscall.h +++ b/arch/sparc/include/syscall.h @@ -70,7 +70,7 @@ #define SYS_restore_context (1) #define up_fullcontextrestore(restoreregs) \ - (void)sys_call1(SYS_restore_context, (uintptr_t)restoreregs) + sys_call1(SYS_restore_context, (uintptr_t)restoreregs) /* SYS call 2: * @@ -79,7 +79,7 @@ #define SYS_switch_context (2) #define up_switchcontext(saveregs, restoreregs) \ - (void)sys_call2(SYS_switch_context, (uintptr_t)saveregs, (uintptr_t)restoreregs) + sys_call2(SYS_switch_context, (uintptr_t)saveregs, (uintptr_t)restoreregs) #ifdef CONFIG_BUILD_KERNEL /* SYS call 3: @@ -88,7 +88,7 @@ */ #define SYS_syscall_return (3) -#define up_syscall_return() (void)sys_call0(SYS_syscall_return) +#define up_syscall_return() sys_call0(SYS_syscall_return) #endif #endif /* __ASSEMBLY__ */ diff --git a/arch/sparc/src/Makefile b/arch/sparc/src/Makefile index d53294ddf8fd0..37c80ed684b79 100644 --- a/arch/sparc/src/Makefile +++ b/arch/sparc/src/Makefile @@ -105,7 +105,7 @@ board/libboard$(LIBEXT): $(Q) $(MAKE) -C board TOPDIR="$(TOPDIR)" libboard$(LIBEXT) EXTRADEFINES=$(EXTRADEFINES) nuttx$(EXEEXT): $(HEAD_OBJ) board/libboard$(LIBEXT) $(ARCHSCRIPT) - @echo "LD: nuttx" + $(Q) echo "LD: nuttx" $(Q) $(LD) --entry=__start $(LDFLAGS) $(LIBPATHS) -o $(NUTTX) $(HEAD_OBJ) $(EXTRA_OBJS) \ $(LDSTARTGROUP) $(LDLIBS) $(EXTRA_LIBS) $(LIBGCC) $(LDENDGROUP) ifneq ($(CONFIG_WINDOWS_NATIVE),y) diff --git a/arch/sparc/src/bm3803/bm3803-serial.c b/arch/sparc/src/bm3803/bm3803-serial.c index c73bcb26790a5..b88d83cdd468b 100644 --- a/arch/sparc/src/bm3803/bm3803-serial.c +++ b/arch/sparc/src/bm3803/bm3803-serial.c @@ -855,14 +855,14 @@ void up_serialinit(void) /* Register the console */ #ifdef HAVE_SERIAL_CONSOLE - (void)uart_register("/dev/console", &CONSOLE_DEV); + uart_register("/dev/console", &CONSOLE_DEV); #endif /* Register all UARTs */ - (void)uart_register("/dev/ttyS0", &TTYS0_DEV); + uart_register("/dev/ttyS0", &TTYS0_DEV); #ifdef TTYS1_DEV - (void)uart_register("/dev/ttyS1", &TTYS1_DEV); + uart_register("/dev/ttyS1", &TTYS1_DEV); #endif } diff --git a/arch/sparc/src/bm3803/bm3803-timerisr.c b/arch/sparc/src/bm3803/bm3803-timerisr.c index f0c453efb0bca..fd0502a05f261 100644 --- a/arch/sparc/src/bm3803/bm3803-timerisr.c +++ b/arch/sparc/src/bm3803/bm3803-timerisr.c @@ -77,7 +77,7 @@ * ****************************************************************************/ -static int bm3803_timerisr(int irq, uint32_t *regs, FAR void *arg) +static int bm3803_timerisr(int irq, uint32_t *regs, void *arg) { /* Clear the pending timer interrupt */ @@ -123,12 +123,12 @@ void up_timer_initialize(void) up_clrpend_irq(BM3803_IRQ_TIMER1); #ifdef CONFIG_ARCH_IRQPRIO - (void)up_prioritize_irq(BM3803_IRQ_TIMER1, CONFIG_BM3803_TIMER1PRIO); + up_prioritize_irq(BM3803_IRQ_TIMER1, CONFIG_BM3803_TIMER1PRIO); #endif /* Attach the timer interrupt vector */ - (void)irq_attach(BM3803_IRQ_TIMER1, (xcpt_t)bm3803_timerisr, NULL); + irq_attach(BM3803_IRQ_TIMER1, (xcpt_t)bm3803_timerisr, NULL); /* And enable the timer interrupt */ diff --git a/arch/sparc/src/bm3803/bm3803_exti_gpio.c b/arch/sparc/src/bm3803/bm3803_exti_gpio.c index dea1eab06152f..5959d3a5ed493 100644 --- a/arch/sparc/src/bm3803/bm3803_exti_gpio.c +++ b/arch/sparc/src/bm3803/bm3803_exti_gpio.c @@ -173,7 +173,7 @@ static int bm3803_exti3_isr(int irq, void *context, void * arg) int bm3803_gpioset_irq(uint32_t pinset, bool enable, bool trig, bool edge, xcpt_t func, void *arg) { - FAR struct gpio_callback_s *shared_cbs; + struct gpio_callback_s *shared_cbs; uint32_t pin = pinset & 0x3; uint32_t en = 0x80 << (pin * 8); diff --git a/arch/sparc/src/bm3803/bm3803_freerun.c b/arch/sparc/src/bm3803/bm3803_freerun.c index a5db2d0260140..6eca005abbd55 100644 --- a/arch/sparc/src/bm3803/bm3803_freerun.c +++ b/arch/sparc/src/bm3803/bm3803_freerun.c @@ -59,9 +59,9 @@ * ****************************************************************************/ -static int bm3803_freerun_handler(int irq, FAR void *context, void *arg) +static int bm3803_freerun_handler(int irq, void *context, void *arg) { - FAR struct bm3803_freerun_s *freerun = (FAR struct bm3803_freerun_s *) arg; + struct bm3803_freerun_s *freerun = (struct bm3803_freerun_s *) arg; DEBUGASSERT(freerun != NULL && freerun->overflow < UINT24_MAX); freerun->overflow++; @@ -92,7 +92,7 @@ static int bm3803_freerun_handler(int irq, FAR void *context, void *arg) * ****************************************************************************/ -int bm3803_freerun_initialize(FAR struct bm3803_freerun_s *freerun, int chan, +int bm3803_freerun_initialize(struct bm3803_freerun_s *freerun, int chan, uint16_t resolution) { uint32_t frequency; @@ -156,8 +156,8 @@ int bm3803_freerun_initialize(FAR struct bm3803_freerun_s *freerun, int chan, * ****************************************************************************/ -int bm3803_freerun_counter(FAR struct bm3803_freerun_s *freerun, - FAR struct timespec *ts) +int bm3803_freerun_counter(struct bm3803_freerun_s *freerun, + struct timespec *ts) { uint64_t usec; uint32_t counter; @@ -253,7 +253,7 @@ int bm3803_freerun_counter(FAR struct bm3803_freerun_s *freerun, * ****************************************************************************/ -int bm3803_freerun_uninitialize(FAR struct bm3803_freerun_s *freerun) +int bm3803_freerun_uninitialize(struct bm3803_freerun_s *freerun) { DEBUGASSERT(freerun && freerun->tch); diff --git a/arch/sparc/src/bm3803/bm3803_freerun.h b/arch/sparc/src/bm3803/bm3803_freerun.h index 310cf2a6b71e1..68dfda721e5c3 100644 --- a/arch/sparc/src/bm3803/bm3803_freerun.h +++ b/arch/sparc/src/bm3803/bm3803_freerun.h @@ -47,10 +47,10 @@ struct bm3803_freerun_s { - uint8_t chan; /* The timer/counter in use */ - bool running; /* True: the timer is running */ - uint32_t overflow; /* Timer counter overflow */ - FAR struct bm3803_tim_dev_s *tch; /* Handle returned by bm3803_tim_init() */ + uint8_t chan; /* The timer/counter in use */ + bool running; /* True: the timer is running */ + uint32_t overflow; /* Timer counter overflow */ + struct bm3803_tim_dev_s *tch; /* Handle returned by bm3803_tim_init() */ uint32_t frequency; }; diff --git a/arch/sparc/src/bm3803/bm3803_oneshot.c b/arch/sparc/src/bm3803/bm3803_oneshot.c index abbbce189fea0..7a2c0e5ec5192 100644 --- a/arch/sparc/src/bm3803/bm3803_oneshot.c +++ b/arch/sparc/src/bm3803/bm3803_oneshot.c @@ -73,7 +73,7 @@ static int bm3803_oneshot_handler(int irq, void *context, void *arg) { struct bm3803_oneshot_s *oneshot = (struct bm3803_oneshot_s *) arg; oneshot_handler_t oneshot_handler; - FAR void *oneshot_arg; + void *oneshot_arg; tmrinfo("Expired...\n"); DEBUGASSERT(oneshot != NULL && oneshot->handler); @@ -124,7 +124,7 @@ static int bm3803_oneshot_handler(int irq, void *context, void *arg) * ****************************************************************************/ -int bm3803_oneshot_initialize(FAR struct bm3803_oneshot_s *oneshot, +int bm3803_oneshot_initialize(struct bm3803_oneshot_s *oneshot, int chan, uint16_t resolution) { uint32_t frequency; @@ -166,8 +166,8 @@ int bm3803_oneshot_initialize(FAR struct bm3803_oneshot_s *oneshot, * ****************************************************************************/ -int bm3803_oneshot_max_delay(FAR struct bm3803_oneshot_s *oneshot, - FAR uint64_t *usec) +int bm3803_oneshot_max_delay(struct bm3803_oneshot_s *oneshot, + uint64_t *usec) { DEBUGASSERT(oneshot != NULL && usec != NULL); @@ -196,9 +196,9 @@ int bm3803_oneshot_max_delay(FAR struct bm3803_oneshot_s *oneshot, * ****************************************************************************/ -int bm3803_oneshot_start(FAR struct bm3803_oneshot_s *oneshot, - oneshot_handler_t handler, FAR void *arg, - FAR const struct timespec *ts) +int bm3803_oneshot_start(struct bm3803_oneshot_s *oneshot, + oneshot_handler_t handler, void *arg, + const struct timespec *ts) { uint64_t usec; uint64_t period; @@ -217,7 +217,7 @@ int bm3803_oneshot_start(FAR struct bm3803_oneshot_s *oneshot, /* Yes.. then cancel it */ tmrinfo("Already running... cancelling\n"); - (void)bm3803_oneshot_cancel(oneshot, NULL); + bm3803_oneshot_cancel(oneshot, NULL); } /* Save the new handler and its argument */ @@ -292,8 +292,8 @@ int bm3803_oneshot_start(FAR struct bm3803_oneshot_s *oneshot, * ****************************************************************************/ -int bm3803_oneshot_cancel(FAR struct bm3803_oneshot_s *oneshot, - FAR struct timespec *ts) +int bm3803_oneshot_cancel(struct bm3803_oneshot_s *oneshot, + struct timespec *ts) { irqstate_t flags; uint64_t usec; diff --git a/arch/sparc/src/bm3803/bm3803_oneshot.h b/arch/sparc/src/bm3803/bm3803_oneshot.h index 6c80ebf865295..311340e2d1d4b 100644 --- a/arch/sparc/src/bm3803/bm3803_oneshot.h +++ b/arch/sparc/src/bm3803/bm3803_oneshot.h @@ -63,7 +63,7 @@ struct bm3803_oneshot_s uint8_t chan; /* The timer/counter in use */ volatile bool running; /* True: the timer is running */ - FAR struct bm3803_tim_dev_s *tch; /* Pointer returned by + struct bm3803_tim_dev_s *tch; /* Pointer returned by * bm3803_tim_init() */ volatile oneshot_handler_t handler; /* Oneshot expiration callback */ volatile void *arg; /* The argument that will accompany diff --git a/arch/sparc/src/bm3803/bm3803_oneshot_lowerhalf.c b/arch/sparc/src/bm3803/bm3803_oneshot_lowerhalf.c index b188c66b313ed..e68fba100e994 100644 --- a/arch/sparc/src/bm3803/bm3803_oneshot_lowerhalf.c +++ b/arch/sparc/src/bm3803/bm3803_oneshot_lowerhalf.c @@ -51,7 +51,7 @@ struct bm3803_oneshot_lowerhalf_s * compatible to struct bm3803_oneshot_lowerhalf_s and vice versa. */ - struct oneshot_lowerhalf_s lh; /* Common lower-half driver fields */ + struct oneshot_lowerhalf_s lh; /* Common lower-half driver fields */ /* Private lower half data follows */ @@ -59,7 +59,7 @@ struct bm3803_oneshot_lowerhalf_s struct bm3803_oneshot_s oneshot; oneshot_callback_t callback; /* internal handler that receives callback */ - FAR void *arg; /* Argument that is passed to the handler */ + void *arg; /* Argument that is passed to the handler */ }; /**************************************************************************** @@ -68,13 +68,13 @@ struct bm3803_oneshot_lowerhalf_s static void bm3803_oneshot_handler(void *arg); -static int bm3803_max_delay(FAR struct oneshot_lowerhalf_s *lower, - FAR struct timespec *ts); -static int bm3803_start(FAR struct oneshot_lowerhalf_s *lower, - oneshot_callback_t callback, FAR void *arg, - FAR const struct timespec *ts); -static int bm3803_cancel(FAR struct oneshot_lowerhalf_s *lower, - FAR struct timespec *ts); +static int bm3803_max_delay(struct oneshot_lowerhalf_s *lower, + struct timespec *ts); +static int bm3803_start(struct oneshot_lowerhalf_s *lower, + oneshot_callback_t callback, void *arg, + const struct timespec *ts); +static int bm3803_cancel(struct oneshot_lowerhalf_s *lower, + struct timespec *ts); /**************************************************************************** * Private Data @@ -110,10 +110,10 @@ static const struct oneshot_operations_s g_oneshot_ops = static void bm3803_oneshot_handler(void *arg) { - FAR struct bm3803_oneshot_lowerhalf_s *priv = - (FAR struct bm3803_oneshot_lowerhalf_s *)arg; + struct bm3803_oneshot_lowerhalf_s *priv = + (struct bm3803_oneshot_lowerhalf_s *)arg; oneshot_callback_t callback; - FAR void *cbarg; + void *cbarg; DEBUGASSERT(priv != NULL); @@ -156,11 +156,11 @@ static void bm3803_oneshot_handler(void *arg) * ****************************************************************************/ -static int bm3803_max_delay(FAR struct oneshot_lowerhalf_s *lower, - FAR struct timespec *ts) +static int bm3803_max_delay(struct oneshot_lowerhalf_s *lower, + struct timespec *ts) { - FAR struct bm3803_oneshot_lowerhalf_s *priv = - (FAR struct bm3803_oneshot_lowerhalf_s *)lower; + struct bm3803_oneshot_lowerhalf_s *priv = + (struct bm3803_oneshot_lowerhalf_s *)lower; uint64_t usecs; int ret; @@ -198,12 +198,12 @@ static int bm3803_max_delay(FAR struct oneshot_lowerhalf_s *lower, * ****************************************************************************/ -static int bm3803_start(FAR struct oneshot_lowerhalf_s *lower, - oneshot_callback_t callback, FAR void *arg, - FAR const struct timespec *ts) +static int bm3803_start(struct oneshot_lowerhalf_s *lower, + oneshot_callback_t callback, void *arg, + const struct timespec *ts) { - FAR struct bm3803_oneshot_lowerhalf_s *priv = - (FAR struct bm3803_oneshot_lowerhalf_s *)lower; + struct bm3803_oneshot_lowerhalf_s *priv = + (struct bm3803_oneshot_lowerhalf_s *)lower; irqstate_t flags; int ret; @@ -250,11 +250,11 @@ static int bm3803_start(FAR struct oneshot_lowerhalf_s *lower, * ****************************************************************************/ -static int bm3803_cancel(FAR struct oneshot_lowerhalf_s *lower, - FAR struct timespec *ts) +static int bm3803_cancel(struct oneshot_lowerhalf_s *lower, + struct timespec *ts) { - FAR struct bm3803_oneshot_lowerhalf_s *priv = - (FAR struct bm3803_oneshot_lowerhalf_s *)lower; + struct bm3803_oneshot_lowerhalf_s *priv = + (struct bm3803_oneshot_lowerhalf_s *)lower; irqstate_t flags; int ret; @@ -299,15 +299,15 @@ static int bm3803_cancel(FAR struct oneshot_lowerhalf_s *lower, * ****************************************************************************/ -FAR struct oneshot_lowerhalf_s *oneshot_initialize(int chan, - uint16_t resolution) +struct oneshot_lowerhalf_s *oneshot_initialize(int chan, + uint16_t resolution) { - FAR struct bm3803_oneshot_lowerhalf_s *priv; + struct bm3803_oneshot_lowerhalf_s *priv; int ret; /* Allocate an instance of the lower half driver */ - priv = (FAR struct bm3803_oneshot_lowerhalf_s *) + priv = (struct bm3803_oneshot_lowerhalf_s *) kmm_zalloc(sizeof(struct bm3803_oneshot_lowerhalf_s)); if (priv == NULL) diff --git a/arch/sparc/src/bm3803/bm3803_tickless.c b/arch/sparc/src/bm3803/bm3803_tickless.c index 25cfa43b58f3b..214f3d01657ef 100644 --- a/arch/sparc/src/bm3803/bm3803_tickless.c +++ b/arch/sparc/src/bm3803/bm3803_tickless.c @@ -27,10 +27,10 @@ * * void up_timer_initialize(void): Initializes the timer facilities. * Called early in the initialization sequence (by up_initialize()). - * int up_timer_gettime(FAR struct timespec *ts): Returns the current + * int up_timer_gettime(struct timespec *ts): Returns the current * time from the platform specific time source. * int up_timer_cancel(void): Cancels the interval timer. - * int up_timer_start(FAR const struct timespec *ts): Start (or re-starts) + * int up_timer_start(const struct timespec *ts): Start (or re-starts) * the interval timer. * * The RTOS will provide the following interfaces for use by the platform- @@ -139,7 +139,7 @@ static struct bm3803_tickless_s g_tickless; * ****************************************************************************/ -static void bm3803_oneshot_handler(FAR void *arg) +static void bm3803_oneshot_handler(void *arg) { tmrinfo("Expired...\n"); nxsched_timer_expiration(); @@ -235,7 +235,7 @@ void up_timer_initialize(void) * up_timer_initialize() was called). This function is functionally * equivalent to: * - * int clock_gettime(clockid_t clockid, FAR struct timespec *ts); + * int clock_gettime(clockid_t clockid, struct timespec *ts); * * when clockid is CLOCK_MONOTONIC. * @@ -260,7 +260,7 @@ void up_timer_initialize(void) * ****************************************************************************/ -int up_timer_gettime(FAR struct timespec *ts) +int up_timer_gettime(struct timespec *ts) { return bm3803_freerun_counter(&g_tickless.freerun, ts); } @@ -301,7 +301,7 @@ int up_timer_gettime(FAR struct timespec *ts) * ****************************************************************************/ -int up_timer_cancel(FAR struct timespec *ts) +int up_timer_cancel(struct timespec *ts) { return bm3803_oneshot_cancel(&g_tickless.oneshot, ts); } @@ -331,7 +331,7 @@ int up_timer_cancel(FAR struct timespec *ts) * ****************************************************************************/ -int up_timer_start(FAR const struct timespec *ts) +int up_timer_start(const struct timespec *ts) { return bm3803_oneshot_start(&g_tickless.oneshot, bm3803_oneshot_handler, NULL, ts); diff --git a/arch/sparc/src/bm3803/bm3803_tim.c b/arch/sparc/src/bm3803/bm3803_tim.c index 6d90e70bddda4..c608f2d5e7511 100644 --- a/arch/sparc/src/bm3803/bm3803_tim.c +++ b/arch/sparc/src/bm3803/bm3803_tim.c @@ -59,7 +59,7 @@ struct bm3803_tim_priv_s { - FAR const struct bm3803_tim_ops_s *ops; + const struct bm3803_tim_ops_s *ops; enum bm3803_tim_mode_e mode; uint32_t base; /* TIMn base address */ }; @@ -70,43 +70,43 @@ struct bm3803_tim_priv_s /* Register helpers */ -static inline uint16_t bm3803_getreg16(FAR struct bm3803_tim_dev_s *dev, +static inline uint16_t bm3803_getreg16(struct bm3803_tim_dev_s *dev, uint8_t offset); -static inline void bm3803_putreg16(FAR struct bm3803_tim_dev_s *dev, +static inline void bm3803_putreg16(struct bm3803_tim_dev_s *dev, uint8_t offset, uint16_t value); -static inline void bm3803_modifyreg32(FAR struct bm3803_tim_dev_s *dev, +static inline void bm3803_modifyreg32(struct bm3803_tim_dev_s *dev, uint8_t offset, uint32_t clearbits, uint32_t setbits); -static inline uint32_t bm3803_getreg32(FAR struct bm3803_tim_dev_s *dev, +static inline uint32_t bm3803_getreg32(struct bm3803_tim_dev_s *dev, uint8_t offset); -static inline void bm3803_putreg32(FAR struct bm3803_tim_dev_s *dev, +static inline void bm3803_putreg32(struct bm3803_tim_dev_s *dev, uint8_t offset, uint32_t value); /* Timer helpers */ -static void bm3803_tim_reload_counter(FAR struct bm3803_tim_dev_s *dev); -static void bm3803_tim_enable(FAR struct bm3803_tim_dev_s *dev); -static void bm3803_tim_disable(FAR struct bm3803_tim_dev_s *dev); -static void bm3803_tim_reset(FAR struct bm3803_tim_dev_s *dev); +static void bm3803_tim_reload_counter(struct bm3803_tim_dev_s *dev); +static void bm3803_tim_enable(struct bm3803_tim_dev_s *dev); +static void bm3803_tim_disable(struct bm3803_tim_dev_s *dev); +static void bm3803_tim_reset(struct bm3803_tim_dev_s *dev); /* Timer methods */ -static int bm3803_tim_setmode(FAR struct bm3803_tim_dev_s *dev, +static int bm3803_tim_setmode(struct bm3803_tim_dev_s *dev, enum bm3803_tim_mode_e mode); -static int bm3803_tim_setclock(FAR struct bm3803_tim_dev_s *dev, +static int bm3803_tim_setclock(struct bm3803_tim_dev_s *dev, uint32_t freq); -static uint32_t bm3803_tim_getclock(FAR struct bm3803_tim_dev_s *dev); -static void bm3803_tim_setperiod(FAR struct bm3803_tim_dev_s *dev, +static uint32_t bm3803_tim_getclock(struct bm3803_tim_dev_s *dev); +static void bm3803_tim_setperiod(struct bm3803_tim_dev_s *dev, uint32_t period); -static uint32_t bm3803_tim_getperiod(FAR struct bm3803_tim_dev_s *dev); -static uint32_t bm3803_tim_getcounter(FAR struct bm3803_tim_dev_s *dev); +static uint32_t bm3803_tim_getperiod(struct bm3803_tim_dev_s *dev); +static uint32_t bm3803_tim_getcounter(struct bm3803_tim_dev_s *dev); -static int bm3803_tim_setisr(FAR struct bm3803_tim_dev_s *dev, +static int bm3803_tim_setisr(struct bm3803_tim_dev_s *dev, xcpt_t handler, void *arg, int source); -static int bm3803_tim_checkint(FAR struct bm3803_tim_dev_s *dev, int source); -static void bm3803_tim_clrint(FAR struct bm3803_tim_dev_s *dev, int source); +static int bm3803_tim_checkint(struct bm3803_tim_dev_s *dev, int source); +static void bm3803_tim_clrint(struct bm3803_tim_dev_s *dev, int source); /**************************************************************************** * Private Data ****************************************************************************/ @@ -153,7 +153,7 @@ struct bm3803_tim_priv_s bm3803_tim2_priv = * ****************************************************************************/ -static inline uint16_t bm3803_getreg16(FAR struct bm3803_tim_dev_s *dev, +static inline uint16_t bm3803_getreg16(struct bm3803_tim_dev_s *dev, uint8_t offset) { return getreg16(((struct bm3803_tim_priv_s *)dev)->base + offset); @@ -167,7 +167,7 @@ static inline uint16_t bm3803_getreg16(FAR struct bm3803_tim_dev_s *dev, * ****************************************************************************/ -static inline void bm3803_putreg16(FAR struct bm3803_tim_dev_s *dev, +static inline void bm3803_putreg16(struct bm3803_tim_dev_s *dev, uint8_t offset, uint16_t value) { putreg16(value, ((struct bm3803_tim_priv_s *)dev)->base + offset); @@ -181,7 +181,7 @@ static inline void bm3803_putreg16(FAR struct bm3803_tim_dev_s *dev, * ****************************************************************************/ -static inline void bm3803_modifyreg32(FAR struct bm3803_tim_dev_s *dev, +static inline void bm3803_modifyreg32(struct bm3803_tim_dev_s *dev, uint8_t offset, uint32_t clearbits, uint32_t setbits) { @@ -198,7 +198,7 @@ static inline void bm3803_modifyreg32(FAR struct bm3803_tim_dev_s *dev, * ****************************************************************************/ -static inline uint32_t bm3803_getreg32(FAR struct bm3803_tim_dev_s *dev, +static inline uint32_t bm3803_getreg32(struct bm3803_tim_dev_s *dev, uint8_t offset) { return getreg32(((struct bm3803_tim_priv_s *)dev)->base + offset); @@ -213,7 +213,7 @@ static inline uint32_t bm3803_getreg32(FAR struct bm3803_tim_dev_s *dev, * ****************************************************************************/ -static inline void bm3803_putreg32(FAR struct bm3803_tim_dev_s *dev, +static inline void bm3803_putreg32(struct bm3803_tim_dev_s *dev, uint8_t offset, uint32_t value) { putreg32(value, ((struct bm3803_tim_priv_s *)dev)->base + offset); @@ -223,7 +223,7 @@ static inline void bm3803_putreg32(FAR struct bm3803_tim_dev_s *dev, * Name: bm3803_tim_reload_counter ****************************************************************************/ -static void bm3803_tim_reload_counter(FAR struct bm3803_tim_dev_s *dev) +static void bm3803_tim_reload_counter(struct bm3803_tim_dev_s *dev) { uint32_t val = bm3803_getreg32(dev, BM3803_TIM_CR_OFFSET); val |= TIMER_LOADCOUNT; @@ -234,7 +234,7 @@ static void bm3803_tim_reload_counter(FAR struct bm3803_tim_dev_s *dev) * Name: bm3803_tim_enable ****************************************************************************/ -static void bm3803_tim_enable(FAR struct bm3803_tim_dev_s *dev) +static void bm3803_tim_enable(struct bm3803_tim_dev_s *dev) { uint32_t val = bm3803_getreg32(dev, BM3803_TIM_CR_OFFSET); val |= TIMER_ENABLE | TIMER_RELOADCOUNT; @@ -246,7 +246,7 @@ static void bm3803_tim_enable(FAR struct bm3803_tim_dev_s *dev) * Name: bm3803_tim_disable ****************************************************************************/ -static void bm3803_tim_disable(FAR struct bm3803_tim_dev_s *dev) +static void bm3803_tim_disable(struct bm3803_tim_dev_s *dev) { uint32_t val = bm3803_getreg32(dev, BM3803_TIM_CR_OFFSET); val &= ~TIMER_ENABLE; @@ -261,7 +261,7 @@ static void bm3803_tim_disable(FAR struct bm3803_tim_dev_s *dev) * ****************************************************************************/ -static void bm3803_tim_reset(FAR struct bm3803_tim_dev_s *dev) +static void bm3803_tim_reset(struct bm3803_tim_dev_s *dev) { ((struct bm3803_tim_priv_s *)dev)->mode = BM3803_TIM_MODE_DISABLED; bm3803_tim_disable(dev); @@ -271,7 +271,7 @@ static void bm3803_tim_reset(FAR struct bm3803_tim_dev_s *dev) * Name: bm3803_tim_setmode ****************************************************************************/ -static int bm3803_tim_setmode(FAR struct bm3803_tim_dev_s *dev, +static int bm3803_tim_setmode(struct bm3803_tim_dev_s *dev, enum bm3803_tim_mode_e mode) { uint32_t val = bm3803_getreg32(dev, BM3803_TIM_CR_OFFSET); @@ -304,7 +304,7 @@ static int bm3803_tim_setmode(FAR struct bm3803_tim_dev_s *dev, * Name: bm3803_tim_setclock ****************************************************************************/ -static int bm3803_tim_setclock(FAR struct bm3803_tim_dev_s *dev, +static int bm3803_tim_setclock(struct bm3803_tim_dev_s *dev, uint32_t freq) { uint32_t freqin; @@ -377,7 +377,7 @@ static int bm3803_tim_setclock(FAR struct bm3803_tim_dev_s *dev, * Name: bm3803_tim_getclock ****************************************************************************/ -static uint32_t bm3803_tim_getclock(FAR struct bm3803_tim_dev_s *dev) +static uint32_t bm3803_tim_getclock(struct bm3803_tim_dev_s *dev) { uint32_t freqin; uint32_t clock; @@ -418,7 +418,7 @@ static uint32_t bm3803_tim_getclock(FAR struct bm3803_tim_dev_s *dev) * Name: bm3803_tim_setperiod ****************************************************************************/ -static void bm3803_tim_setperiod(FAR struct bm3803_tim_dev_s *dev, +static void bm3803_tim_setperiod(struct bm3803_tim_dev_s *dev, uint32_t period) { DEBUGASSERT(dev != NULL); @@ -430,7 +430,7 @@ static void bm3803_tim_setperiod(FAR struct bm3803_tim_dev_s *dev, * Name: bm3803_tim_getperiod ****************************************************************************/ -static uint32_t bm3803_tim_getperiod (FAR struct bm3803_tim_dev_s *dev) +static uint32_t bm3803_tim_getperiod (struct bm3803_tim_dev_s *dev) { DEBUGASSERT(dev != NULL); return 0xffffff & bm3803_getreg32(dev, BM3803_TIM_ARR_OFFSET); @@ -440,7 +440,7 @@ static uint32_t bm3803_tim_getperiod (FAR struct bm3803_tim_dev_s *dev) * Name: bm3803_tim_getcounter ****************************************************************************/ -static uint32_t bm3803_tim_getcounter(FAR struct bm3803_tim_dev_s *dev) +static uint32_t bm3803_tim_getcounter(struct bm3803_tim_dev_s *dev) { DEBUGASSERT(dev != NULL); uint32_t counter = bm3803_getreg32(dev, BM3803_TIM_CNT_OFFSET); @@ -452,7 +452,7 @@ static uint32_t bm3803_tim_getcounter(FAR struct bm3803_tim_dev_s *dev) * Name: bm3803_tim_setisr ****************************************************************************/ -static int bm3803_tim_setisr(FAR struct bm3803_tim_dev_s *dev, +static int bm3803_tim_setisr(struct bm3803_tim_dev_s *dev, xcpt_t handler, void *arg, int source) { int vectorno; @@ -500,7 +500,7 @@ static int bm3803_tim_setisr(FAR struct bm3803_tim_dev_s *dev, * Name: bm3803_tim_clrint ****************************************************************************/ -static void bm3803_tim_clrint(FAR struct bm3803_tim_dev_s *dev, int source) +static void bm3803_tim_clrint(struct bm3803_tim_dev_s *dev, int source) { int vectorno; @@ -532,7 +532,7 @@ static void bm3803_tim_clrint(FAR struct bm3803_tim_dev_s *dev, int source) * Name: bm3803_tim_checkint ****************************************************************************/ -static int bm3803_tim_checkint(FAR struct bm3803_tim_dev_s *dev, int source) +static int bm3803_tim_checkint(struct bm3803_tim_dev_s *dev, int source) { int vectorno; @@ -568,7 +568,7 @@ static int bm3803_tim_checkint(FAR struct bm3803_tim_dev_s *dev, int source) * Name: bm3803_tim_init ****************************************************************************/ -FAR struct bm3803_tim_dev_s *bm3803_tim_init(int timer) +struct bm3803_tim_dev_s *bm3803_tim_init(int timer) { struct bm3803_tim_dev_s *dev = NULL; @@ -613,7 +613,7 @@ FAR struct bm3803_tim_dev_s *bm3803_tim_init(int timer) * ****************************************************************************/ -int bm3803_tim_deinit(FAR struct bm3803_tim_dev_s *dev) +int bm3803_tim_deinit(struct bm3803_tim_dev_s *dev) { DEBUGASSERT(dev != NULL); diff --git a/arch/sparc/src/bm3803/bm3803_tim.h b/arch/sparc/src/bm3803/bm3803_tim.h index 449788c024c59..73529af05bbbc 100644 --- a/arch/sparc/src/bm3803/bm3803_tim.h +++ b/arch/sparc/src/bm3803/bm3803_tim.h @@ -99,29 +99,29 @@ struct bm3803_tim_ops_s { /* Basic Timers */ - int (*setmode)(FAR struct bm3803_tim_dev_s *dev, + int (*setmode)(struct bm3803_tim_dev_s *dev, enum bm3803_tim_mode_e mode); - int (*setclock)(FAR struct bm3803_tim_dev_s *dev, uint32_t freq); - uint32_t (*getclock)(FAR struct bm3803_tim_dev_s *dev); - void (*setperiod)(FAR struct bm3803_tim_dev_s *dev, uint32_t period); - uint32_t (*getperiod)(FAR struct bm3803_tim_dev_s *dev); - uint32_t (*getcounter)(FAR struct bm3803_tim_dev_s *dev); + int (*setclock)(struct bm3803_tim_dev_s *dev, uint32_t freq); + uint32_t (*getclock)(struct bm3803_tim_dev_s *dev); + void (*setperiod)(struct bm3803_tim_dev_s *dev, uint32_t period); + uint32_t (*getperiod)(struct bm3803_tim_dev_s *dev); + uint32_t (*getcounter)(struct bm3803_tim_dev_s *dev); /* Timer interrupts */ - int (*setisr)(FAR struct bm3803_tim_dev_s *dev, + int (*setisr)(struct bm3803_tim_dev_s *dev, xcpt_t handler, void *arg, int source); - void (*clrint)(FAR struct bm3803_tim_dev_s *dev, int source); - int (*checkint)(FAR struct bm3803_tim_dev_s *dev, int source); + void (*clrint)(struct bm3803_tim_dev_s *dev, int source); + int (*checkint)(struct bm3803_tim_dev_s *dev, int source); }; /* Power-up timer and get its structure */ -FAR struct bm3803_tim_dev_s *bm3803_tim_init(int timer); +struct bm3803_tim_dev_s *bm3803_tim_init(int timer); /* Power-down timer, mark it as unused */ -int bm3803_tim_deinit(FAR struct bm3803_tim_dev_s *dev); +int bm3803_tim_deinit(struct bm3803_tim_dev_s *dev); /**************************************************************************** * Name: bm3803_timer_initialize @@ -142,7 +142,7 @@ int bm3803_tim_deinit(FAR struct bm3803_tim_dev_s *dev); ****************************************************************************/ #ifdef CONFIG_TIMER -int bm3803_timer_initialize(FAR const char *devpath, int timer); +int bm3803_timer_initialize(const char *devpath, int timer); #endif #undef EXTERN diff --git a/arch/sparc/src/bm3803/bm3803_tim_lowerhalf.c b/arch/sparc/src/bm3803/bm3803_tim_lowerhalf.c index 2047f7be5d30a..6bb174d52b462 100644 --- a/arch/sparc/src/bm3803/bm3803_tim_lowerhalf.c +++ b/arch/sparc/src/bm3803/bm3803_tim_lowerhalf.c @@ -58,15 +58,15 @@ struct bm3803_lowerhalf_s { - FAR const struct timer_ops_s *ops; /* Lower half operations */ - FAR struct bm3803_tim_dev_s *tim; /* stm32 timer driver */ - tccb_t callback; /* Current upper half interrupt - * callback */ - FAR void *arg; /* Argument passed to upper half - * callback */ - bool started; /* True: Timer has been started */ - const uint8_t resolution; /* Number of bits in the timer - * (16 or 32 bits) */ + const struct timer_ops_s *ops; /* Lower half operations */ + struct bm3803_tim_dev_s *tim; /* stm32 timer driver */ + tccb_t callback; /* Current upper half interrupt + * callback */ + void *arg; /* Argument passed to upper half + * callback */ + bool started; /* True: Timer has been started */ + const uint8_t resolution; /* Number of bits in the timer + * (16 or 32 bits) */ }; /**************************************************************************** @@ -79,14 +79,14 @@ static int bm3803_timer_handler(int irq, void *context, void *arg); /* "Lower half" driver methods **********************************************/ -static int bm3803_start(FAR struct timer_lowerhalf_s *lower); -static int bm3803_stop(FAR struct timer_lowerhalf_s *lower); -static int bm3803_getstatus(FAR struct timer_lowerhalf_s *lower, - FAR struct timer_status_s *status); -static int bm3803_settimeout(FAR struct timer_lowerhalf_s *lower, +static int bm3803_start(struct timer_lowerhalf_s *lower); +static int bm3803_stop(struct timer_lowerhalf_s *lower); +static int bm3803_getstatus(struct timer_lowerhalf_s *lower, + struct timer_status_s *status); +static int bm3803_settimeout(struct timer_lowerhalf_s *lower, uint32_t timeout); -static void bm3803_setcallback(FAR struct timer_lowerhalf_s *lower, - tccb_t callback, FAR void *arg); +static void bm3803_setcallback(struct timer_lowerhalf_s *lower, + tccb_t callback, void *arg); /**************************************************************************** * Private Data @@ -138,8 +138,8 @@ static struct bm3803_lowerhalf_s g_tim2_lowerhalf = static int bm3803_timer_handler(int irq, void *context, void *arg) { - FAR struct bm3803_lowerhalf_s *lower = - (FAR struct bm3803_lowerhalf_s *)arg; + struct bm3803_lowerhalf_s *lower = + (struct bm3803_lowerhalf_s *)arg; uint32_t next_interval_us = 0; BM3803_TIM_ACKINT(lower->tim, 0); @@ -174,10 +174,10 @@ static int bm3803_timer_handler(int irq, void *context, void *arg) * ****************************************************************************/ -static int bm3803_start(FAR struct timer_lowerhalf_s *lower) +static int bm3803_start(struct timer_lowerhalf_s *lower) { - FAR struct bm3803_lowerhalf_s *priv = - (FAR struct bm3803_lowerhalf_s *)lower; + struct bm3803_lowerhalf_s *priv = + (struct bm3803_lowerhalf_s *)lower; if (!priv->started) { @@ -212,10 +212,10 @@ static int bm3803_start(FAR struct timer_lowerhalf_s *lower) * ****************************************************************************/ -static int bm3803_stop(FAR struct timer_lowerhalf_s *lower) +static int bm3803_stop(struct timer_lowerhalf_s *lower) { - FAR struct bm3803_lowerhalf_s *priv = - (FAR struct bm3803_lowerhalf_s *)lower; + struct bm3803_lowerhalf_s *priv = + (struct bm3803_lowerhalf_s *)lower; if (priv->started) { @@ -246,11 +246,11 @@ static int bm3803_stop(FAR struct timer_lowerhalf_s *lower) * ****************************************************************************/ -static int bm3803_getstatus(FAR struct timer_lowerhalf_s *lower, - FAR struct timer_status_s *status) +static int bm3803_getstatus(struct timer_lowerhalf_s *lower, + struct timer_status_s *status) { - FAR struct bm3803_lowerhalf_s *priv = - (FAR struct bm3803_lowerhalf_s *)lower; + struct bm3803_lowerhalf_s *priv = + (struct bm3803_lowerhalf_s *)lower; uint64_t maxtimeout; uint32_t timeout; uint32_t clock; @@ -313,11 +313,11 @@ static int bm3803_getstatus(FAR struct timer_lowerhalf_s *lower, * ****************************************************************************/ -static int bm3803_settimeout(FAR struct timer_lowerhalf_s *lower, +static int bm3803_settimeout(struct timer_lowerhalf_s *lower, uint32_t timeout) { - FAR struct bm3803_lowerhalf_s *priv = - (FAR struct bm3803_lowerhalf_s *)lower; + struct bm3803_lowerhalf_s *priv = + (struct bm3803_lowerhalf_s *)lower; uint64_t maxtimeout; if (priv->started) @@ -361,11 +361,11 @@ static int bm3803_settimeout(FAR struct timer_lowerhalf_s *lower, * ****************************************************************************/ -static void bm3803_setcallback(FAR struct timer_lowerhalf_s *lower, - tccb_t callback, FAR void *arg) +static void bm3803_setcallback(struct timer_lowerhalf_s *lower, + tccb_t callback, void *arg) { - FAR struct bm3803_lowerhalf_s *priv = - (FAR struct bm3803_lowerhalf_s *)lower; + struct bm3803_lowerhalf_s *priv = + (struct bm3803_lowerhalf_s *)lower; irqstate_t flags = enter_critical_section(); /* Save the new callback */ @@ -407,9 +407,9 @@ static void bm3803_setcallback(FAR struct timer_lowerhalf_s *lower, * ****************************************************************************/ -int bm3803_timer_initialize(FAR const char *devpath, int timer) +int bm3803_timer_initialize(const char *devpath, int timer) { - FAR struct bm3803_lowerhalf_s *lower; + struct bm3803_lowerhalf_s *lower; switch (timer) { @@ -445,8 +445,8 @@ int bm3803_timer_initialize(FAR const char *devpath, int timer) * REVISIT: The returned handle is discard here. */ - FAR void *drvr = timer_register(devpath, - (FAR struct timer_lowerhalf_s *)lower); + void *drvr = timer_register(devpath, + (struct timer_lowerhalf_s *)lower); if (drvr == NULL) { /* The actual cause of the failure may have been a failure to allocate diff --git a/arch/sparc/src/bm3803/bm3803_wdg.c b/arch/sparc/src/bm3803/bm3803_wdg.c index 459466f691e86..603a5a714c577 100644 --- a/arch/sparc/src/bm3803/bm3803_wdg.c +++ b/arch/sparc/src/bm3803/bm3803_wdg.c @@ -63,7 +63,7 @@ struct bm3803_lowerhalf_s { /* Lower half operations */ - FAR const struct watchdog_ops_s *ops; + const struct watchdog_ops_s *ops; uint32_t timeout; /* The (actual) selected timeout */ uint32_t lastreset; /* The last reset time */ bool started; /* true: The watchdog timer has been started */ @@ -80,16 +80,16 @@ struct bm3803_lowerhalf_s # define bm3803_getreg(addr) getreg32(addr) # define bm3803_putreg(val,addr) putreg32(val,addr) -static inline void bm3803_setreload(FAR struct bm3803_lowerhalf_s *priv); +static inline void bm3803_setreload(struct bm3803_lowerhalf_s *priv); /* "Lower half" driver methods **********************************************/ -static int bm3803_start(FAR struct watchdog_lowerhalf_s *lower); -static int bm3803_stop(FAR struct watchdog_lowerhalf_s *lower); -static int bm3803_keepalive(FAR struct watchdog_lowerhalf_s *lower); -static int bm3803_getstatus(FAR struct watchdog_lowerhalf_s *lower, - FAR struct watchdog_status_s *status); -static int bm3803_settimeout(FAR struct watchdog_lowerhalf_s *lower, +static int bm3803_start(struct watchdog_lowerhalf_s *lower); +static int bm3803_stop(struct watchdog_lowerhalf_s *lower); +static int bm3803_keepalive(struct watchdog_lowerhalf_s *lower); +static int bm3803_getstatus(struct watchdog_lowerhalf_s *lower, + struct watchdog_status_s *status); +static int bm3803_settimeout(struct watchdog_lowerhalf_s *lower, uint32_t timeout); /**************************************************************************** @@ -129,7 +129,7 @@ static struct bm3803_lowerhalf_s g_wdgdev; * ****************************************************************************/ -static inline void bm3803_setreload(FAR struct bm3803_lowerhalf_s *priv) +static inline void bm3803_setreload(struct bm3803_lowerhalf_s *priv) { /* Set the reload value */ @@ -151,10 +151,10 @@ static inline void bm3803_setreload(FAR struct bm3803_lowerhalf_s *priv) * ****************************************************************************/ -static int bm3803_start(FAR struct watchdog_lowerhalf_s *lower) +static int bm3803_start(struct watchdog_lowerhalf_s *lower) { - FAR struct bm3803_lowerhalf_s *priv = - (FAR struct bm3803_lowerhalf_s *)lower; + struct bm3803_lowerhalf_s *priv = + (struct bm3803_lowerhalf_s *)lower; irqstate_t flags; uint32_t val = bm3803_getreg(BM3803_TIM1_BASE + BM3803_TIM_CR_OFFSET); val |= TIMER_WDG; @@ -202,7 +202,7 @@ static int bm3803_start(FAR struct watchdog_lowerhalf_s *lower) * ****************************************************************************/ -static int bm3803_stop(FAR struct watchdog_lowerhalf_s *lower) +static int bm3803_stop(struct watchdog_lowerhalf_s *lower) { uint32_t val = bm3803_getreg(BM3803_TIM1_BASE + BM3803_TIM_CR_OFFSET); @@ -232,10 +232,10 @@ static int bm3803_stop(FAR struct watchdog_lowerhalf_s *lower) * ****************************************************************************/ -static int bm3803_keepalive(FAR struct watchdog_lowerhalf_s *lower) +static int bm3803_keepalive(struct watchdog_lowerhalf_s *lower) { - FAR struct bm3803_lowerhalf_s *priv = - (FAR struct bm3803_lowerhalf_s *)lower; + struct bm3803_lowerhalf_s *priv = + (struct bm3803_lowerhalf_s *)lower; irqstate_t flags; wdinfo("Entry\n"); @@ -266,11 +266,11 @@ static int bm3803_keepalive(FAR struct watchdog_lowerhalf_s *lower) * ****************************************************************************/ -static int bm3803_getstatus(FAR struct watchdog_lowerhalf_s *lower, - FAR struct watchdog_status_s *status) +static int bm3803_getstatus(struct watchdog_lowerhalf_s *lower, + struct watchdog_status_s *status) { - FAR struct bm3803_lowerhalf_s *priv = - (FAR struct bm3803_lowerhalf_s *)lower; + struct bm3803_lowerhalf_s *priv = + (struct bm3803_lowerhalf_s *)lower; uint32_t ticks; uint32_t elapsed; @@ -326,11 +326,11 @@ static int bm3803_getstatus(FAR struct watchdog_lowerhalf_s *lower, * ****************************************************************************/ -static int bm3803_settimeout(FAR struct watchdog_lowerhalf_s *lower, +static int bm3803_settimeout(struct watchdog_lowerhalf_s *lower, uint32_t timeout) { - FAR struct bm3803_lowerhalf_s *priv = - (FAR struct bm3803_lowerhalf_s *)lower; + struct bm3803_lowerhalf_s *priv = + (struct bm3803_lowerhalf_s *)lower; uint32_t reload; uint16_t prescaler; uint32_t freqin; @@ -402,9 +402,9 @@ static int bm3803_settimeout(FAR struct watchdog_lowerhalf_s *lower, * ****************************************************************************/ -void bm3803_wdginitialize(FAR const char *devpath) +void bm3803_wdginitialize(const char *devpath) { - FAR struct bm3803_lowerhalf_s *priv = &g_wdgdev; + struct bm3803_lowerhalf_s *priv = &g_wdgdev; wdinfo("Entry: devpath=%s \n", devpath); @@ -422,12 +422,12 @@ void bm3803_wdginitialize(FAR const char *devpath) * device option bits, the watchdog is automatically enabled at power-on. */ - bm3803_settimeout((FAR struct watchdog_lowerhalf_s *)priv, + bm3803_settimeout((struct watchdog_lowerhalf_s *)priv, CONFIG_BM3803_WDG_DEFTIMOUT); /* Register the watchdog driver as /dev/watchdog0 */ - (void)watchdog_register(devpath, (FAR struct watchdog_lowerhalf_s *)priv); + watchdog_register(devpath, (FAR struct watchdog_lowerhalf_s *)priv); } #endif /* CONFIG_WATCHDOG && CONFIG_BM3803_WDG */ diff --git a/arch/sparc/src/bm3803/bm3803_wdg.h b/arch/sparc/src/bm3803/bm3803_wdg.h index cb60b7a6f8292..27503b9fc03c5 100644 --- a/arch/sparc/src/bm3803/bm3803_wdg.h +++ b/arch/sparc/src/bm3803/bm3803_wdg.h @@ -65,7 +65,7 @@ extern "C" ****************************************************************************/ #ifdef CONFIG_BM3803_WDG -void bm3803_wdginitialize(FAR const char *devpath); +void bm3803_wdginitialize(const char *devpath); #endif #undef EXTERN diff --git a/arch/sparc/src/bm3823/bm3823-serial.c b/arch/sparc/src/bm3823/bm3823-serial.c index 11f1f787c5a23..5c737a2c8fb83 100644 --- a/arch/sparc/src/bm3823/bm3823-serial.c +++ b/arch/sparc/src/bm3823/bm3823-serial.c @@ -847,14 +847,14 @@ void up_serialinit(void) /* Register the console */ #ifdef HAVE_SERIAL_CONSOLE - (void)uart_register("/dev/console", &CONSOLE_DEV); + uart_register("/dev/console", &CONSOLE_DEV); #endif /* Register all UARTs */ - (void)uart_register("/dev/ttyS0", &TTYS0_DEV); + uart_register("/dev/ttyS0", &TTYS0_DEV); #ifdef TTYS1_DEV - (void)uart_register("/dev/ttyS1", &TTYS1_DEV); + uart_register("/dev/ttyS1", &TTYS1_DEV); #endif } diff --git a/arch/sparc/src/bm3823/bm3823-timerisr.c b/arch/sparc/src/bm3823/bm3823-timerisr.c index afa235ae72104..76fd5baae85e3 100644 --- a/arch/sparc/src/bm3823/bm3823-timerisr.c +++ b/arch/sparc/src/bm3823/bm3823-timerisr.c @@ -78,7 +78,7 @@ * ****************************************************************************/ -static int bm3823_timerisr(int irq, uint32_t *regs, FAR void *arg) +static int bm3823_timerisr(int irq, uint32_t *regs, void *arg) { /* Clear the pending timer interrupt */ @@ -124,12 +124,12 @@ void up_timer_initialize(void) up_clrpend_irq(BM3823_IRQ_TIMER1); #ifdef CONFIG_ARCH_IRQPRIO - (void)up_prioritize_irq(BM3823_IRQ_TIMER1, CONFIG_BM3823_TIMER1PRIO); + up_prioritize_irq(BM3823_IRQ_TIMER1, CONFIG_BM3823_TIMER1PRIO); #endif /* Attach the timer interrupt vector */ - (void)irq_attach(BM3823_IRQ_TIMER1, (xcpt_t)bm3823_timerisr, NULL); + irq_attach(BM3823_IRQ_TIMER1, (xcpt_t)bm3823_timerisr, NULL); /* And enable the timer interrupt */ diff --git a/arch/sparc/src/common/up_allocateheap.c b/arch/sparc/src/common/up_allocateheap.c index cf47939e5586c..1419c4c421f98 100644 --- a/arch/sparc/src/common/up_allocateheap.c +++ b/arch/sparc/src/common/up_allocateheap.c @@ -64,8 +64,8 @@ * ****************************************************************************/ -void up_allocate_heap(FAR void **heap_start, size_t *heap_size) +void up_allocate_heap(void **heap_start, size_t *heap_size) { - *heap_start = (FAR void *)g_idle_topstack; + *heap_start = (void *)g_idle_topstack; *heap_size = CONFIG_RAM_END - g_idle_topstack; } diff --git a/arch/sparc/src/common/up_assert.c b/arch/sparc/src/common/up_assert.c index a003b1effdc6e..9dde88df245e4 100644 --- a/arch/sparc/src/common/up_assert.c +++ b/arch/sparc/src/common/up_assert.c @@ -67,13 +67,13 @@ static void _up_assert(int errorcode) { /* Flush any buffered SYSLOG data */ - (void)syslog_flush(); + syslog_flush(); /* Are we in an interrupt handler or the idle task? */ if (g_current_regs || running_task()->flink == NULL) { - (void)up_irq_save(); + up_irq_save(); for (; ; ) { #if CONFIG_BOARD_RESET_ON_ASSERT >= 1 @@ -101,7 +101,7 @@ static void _up_assert(int errorcode) ****************************************************************************/ #ifdef CONFIG_ARCH_USBDUMP -static int usbtrace_syslog(FAR const char *fmt, ...) +static int usbtrace_syslog(const char *fmt, ...) { va_list ap; @@ -113,7 +113,7 @@ static int usbtrace_syslog(FAR const char *fmt, ...) return 0; } -static int assert_tracecallback(FAR struct usbtrace_s *trace, FAR void *arg) +static int assert_tracecallback(struct usbtrace_s *trace, void *arg) { usbtrace_trprintf(usbtrace_syslog, trace->event, trace->value); return 0; @@ -136,7 +136,7 @@ void up_assert(const char *filename, int lineno) /* Flush any buffered SYSLOG data (prior to the assertion) */ - (void)syslog_flush(); + syslog_flush(); #if CONFIG_TASK_NAME_SIZE > 0 _alert("Assertion failed at file:%s line: %d task: %s\n", @@ -150,7 +150,7 @@ void up_assert(const char *filename, int lineno) /* Flush any buffered SYSLOG data (from the above) */ - (void)syslog_flush(); + syslog_flush(); #ifdef CONFIG_BOARD_CRASHDUMP board_crashdump(up_getsp(), running_task(), filename, lineno); @@ -159,7 +159,7 @@ void up_assert(const char *filename, int lineno) #ifdef CONFIG_ARCH_USBDUMP /* Dump USB trace data */ - (void)usbtrace_enumerate(assert_tracecallback, NULL); + usbtrace_enumerate(assert_tracecallback, NULL); #endif _up_assert(EXIT_FAILURE); diff --git a/arch/sparc/src/common/up_checkstack.c b/arch/sparc/src/common/up_checkstack.c index b2302683e4bf1..03ba25d743944 100644 --- a/arch/sparc/src/common/up_checkstack.c +++ b/arch/sparc/src/common/up_checkstack.c @@ -39,22 +39,6 @@ #ifdef CONFIG_STACK_COLORATION -/**************************************************************************** - * Pre-processor Macros - ****************************************************************************/ - -/* 32bit alignment macros */ - -#define INT32_ALIGN_MASK (3) -#define INT32_ALIGN_DOWN(a) ((a) & ~INT32_ALIGN_MASK) -#define INT32_ALIGN_UP(a) (((a) + INT32_ALIGN_MASK) & ~INT32_ALIGN_MASK) - -/**************************************************************************** - * Private Function Prototypes - ****************************************************************************/ - -static size_t do_stackcheck(FAR void *stackbase, size_t nbytes); - /**************************************************************************** * Private Functions ****************************************************************************/ @@ -76,11 +60,11 @@ static size_t do_stackcheck(FAR void *stackbase, size_t nbytes); * ****************************************************************************/ -static size_t do_stackcheck(FAR void *stackbase, size_t nbytes) +static size_t do_stackcheck(void *stackbase, size_t nbytes) { uintptr_t start; uintptr_t end; - FAR uint32_t *ptr; + uint32_t *ptr; size_t mark; if (nbytes == 0) @@ -90,8 +74,8 @@ static size_t do_stackcheck(FAR void *stackbase, size_t nbytes) /* Take extra care that we do not check outside the stack boundaries */ - start = INT32_ALIGN_UP((uintptr_t)stackbase); - end = INT32_ALIGN_DOWN((uintptr_t)stackbase + nbytes); + start = STACK_ALIGN_UP((uintptr_t)stackbase); + end = STACK_ALIGN_DOWN((uintptr_t)stackbase + nbytes); /* Get the adjusted size based on the top and bottom of the stack */ @@ -103,7 +87,7 @@ static size_t do_stackcheck(FAR void *stackbase, size_t nbytes) * that does not have the magic value is the high water mark. */ - for (ptr = (FAR uint32_t *)start, mark = (nbytes >> 2); + for (ptr = (uint32_t *)start, mark = (nbytes >> 2); *ptr == STACK_COLOR && mark > 0; ptr++, mark--); @@ -123,7 +107,7 @@ static size_t do_stackcheck(FAR void *stackbase, size_t nbytes) int i; int j; - ptr = (FAR uint32_t *)start; + ptr = (uint32_t *)start; for (i = 0; i < size; i += 4 * 64) { for (j = 0; j < 64; j++) @@ -163,29 +147,38 @@ static size_t do_stackcheck(FAR void *stackbase, size_t nbytes) * ****************************************************************************/ -void up_stack_color(FAR void *stackbase, size_t nbytes) +void up_stack_color(void *stackbase, size_t nbytes) { - uintptr_t start; - uintptr_t end; - size_t nwords; - FAR uint32_t *ptr; + uint32_t *stkptr; + uintptr_t stkend; + size_t nwords; + uintptr_t sp; /* Take extra care that we do not write outside the stack boundaries */ - start = INT32_ALIGN_UP((uintptr_t)stackbase); - end = nbytes ? INT32_ALIGN_DOWN((uintptr_t)stackbase + nbytes) : - up_getsp(); /* 0: colorize the running stack */ + stkptr = (uint32_t *)STACK_ALIGN_UP((uintptr_t)stackbase); - /* Get the adjusted size based on the top and bottom of the stack */ + if (nbytes == 0) /* 0: colorize the running stack */ + { + stkend = up_getsp(); + if (stkend > (uintptr_t)&sp) + { + stkend = (uintptr_t)&sp; + } + } + else + { + stkend = (uintptr_t)stackbase + nbytes; + } - nwords = (end - start) >> 2; - ptr = (FAR uint32_t *)start; + stkend = STACK_ALIGN_DOWN(stkend); + nwords = (stkend - (uintptr_t)stackbase) >> 2; /* Set the entire stack to the coloration value */ while (nwords-- > 0) { - *ptr++ = STACK_COLOR; + *stkptr++ = STACK_COLOR; } } @@ -205,12 +198,12 @@ void up_stack_color(FAR void *stackbase, size_t nbytes) * ****************************************************************************/ -size_t up_check_tcbstack(FAR struct tcb_s *tcb) +size_t up_check_tcbstack(struct tcb_s *tcb) { return do_stackcheck(tcb->stack_base_ptr, tcb->adj_stack_size); } -ssize_t up_check_tcbstack_remain(FAR struct tcb_s *tcb) +ssize_t up_check_tcbstack_remain(struct tcb_s *tcb) { return tcb->adj_stack_size - up_check_tcbstack(tcb); } @@ -229,12 +222,12 @@ ssize_t up_check_stack_remain(void) size_t up_check_intstack(void) { return do_stackcheck((uintptr_t)&g_intstackalloc, - (CONFIG_ARCH_INTERRUPTSTACK & ~3)); + STACK_ALIGN_DOWN(CONFIG_ARCH_INTERRUPTSTACK)); } size_t up_check_intstack_remain(void) { - return (CONFIG_ARCH_INTERRUPTSTACK & ~3) - up_check_intstack(); + return STACK_ALIGN_DOWN(CONFIG_ARCH_INTERRUPTSTACK) - up_check_intstack(); } #endif diff --git a/arch/sparc/src/common/up_createstack.c b/arch/sparc/src/common/up_createstack.c index 17979a466fdef..6be87aa46b64b 100644 --- a/arch/sparc/src/common/up_createstack.c +++ b/arch/sparc/src/common/up_createstack.c @@ -77,7 +77,7 @@ * ****************************************************************************/ -int up_create_stack(FAR struct tcb_s *tcb, size_t stack_size, uint8_t ttype) +int up_create_stack(struct tcb_s *tcb, size_t stack_size, uint8_t ttype) { /* Is there already a stack allocated of a different size? Because of * alignment issues, stack_size might erroneously appear to be of a diff --git a/arch/sparc/src/common/up_exit.c b/arch/sparc/src/common/up_exit.c index c21f4da397d06..b622154a0de7d 100644 --- a/arch/sparc/src/common/up_exit.c +++ b/arch/sparc/src/common/up_exit.c @@ -63,18 +63,18 @@ ****************************************************************************/ #ifdef CONFIG_DUMP_ON_EXIT -static void _up_dumponexit(FAR struct tcb_s *tcb, FAR void *arg) +static void _up_dumponexit(struct tcb_s *tcb, void *arg) { - FAR struct filelist *filelist; + struct filelist *filelist; #if CONFIG_NFILE_STREAMS > 0 - FAR struct streamlist *streamlist; + struct streamlist *streamlist; #endif int i; sinfo(" TCB=%p name=%s pid=%d\n", tcb, tcb->argv[0], tcb->pid); sinfo(" priority=%d state=%d\n", tcb->sched_priority, tcb->task_state); - filelist = tcb->group->tg_filelist; + filelist = &tcb->group->tg_filelist; for (i = 0; i < CONFIG_NFILE_DESCRIPTORS; i++) { struct inode *inode = filelist->fl_files[i].f_inode; @@ -137,11 +137,6 @@ void up_exit(int status) sinfo("TCB=%p exiting\n", tcb); -#ifdef CONFIG_DUMP_ON_EXIT - sinfo("Other tasks:\n"); - sched_foreach(_up_dumponexit, NULL); -#endif - /* Update scheduler parameters */ nxsched_suspend_scheduler(tcb); @@ -150,22 +145,17 @@ void up_exit(int status) (void)nxtask_exit(); +#ifdef CONFIG_DUMP_ON_EXIT + sinfo("Other tasks:\n"); + sched_foreach(_up_dumponexit, NULL); +#endif + /* Now, perform the context switch to the new ready-to-run task at the * head of the list. */ tcb = this_task(); -#ifdef CONFIG_ARCH_ADDRENV - /* Make sure that the address environment for the previously running - * task is closed down gracefully (data caches dump, MMU flushed) and - * set up the address environment for the new thread at the head of - * the ready-to-run list. - */ - - (void)group_addrenv(tcb); -#endif - /* Reset scheduler parameters */ nxsched_resume_scheduler(tcb); diff --git a/arch/sparc/src/common/up_internal.h b/arch/sparc/src/common/up_internal.h index 7df75fbe43e2e..34534dd57de5d 100644 --- a/arch/sparc/src/common/up_internal.h +++ b/arch/sparc/src/common/up_internal.h @@ -206,11 +206,11 @@ void up_dumpstate(void); /* Software interrupt 0 handler */ -int up_swint0(int irq, FAR void *context, FAR void *arg); +int up_swint0(int irq, void *context, void *arg); /* Software interrupt 1 handler */ -int up_swint1(int irq, FAR void *context, FAR void *arg); +int up_swint1(int irq, void *context, void *arg); /* Signals */ @@ -265,7 +265,7 @@ void up_usbuninitialize(void); /* Debug ********************************************************************/ #ifdef CONFIG_STACK_COLORATION -void up_stack_color(FAR void *stackbase, size_t nbytes); +void up_stack_color(void *stackbase, size_t nbytes); #endif #endif /* __ASSEMBLY__ */ diff --git a/arch/sparc/src/common/up_releasestack.c b/arch/sparc/src/common/up_releasestack.c index 1d7f8f4e95b6d..c125ab3d1efe9 100644 --- a/arch/sparc/src/common/up_releasestack.c +++ b/arch/sparc/src/common/up_releasestack.c @@ -75,7 +75,7 @@ * ****************************************************************************/ -void up_release_stack(FAR struct tcb_s *dtcb, uint8_t ttype) +void up_release_stack(struct tcb_s *dtcb, uint8_t ttype) { /* Is there a stack allocated? */ diff --git a/arch/sparc/src/common/up_stackframe.c b/arch/sparc/src/common/up_stackframe.c index bb32556250e81..50ccf0b48979d 100644 --- a/arch/sparc/src/common/up_stackframe.c +++ b/arch/sparc/src/common/up_stackframe.c @@ -69,9 +69,9 @@ * ****************************************************************************/ -FAR void *up_stack_frame(FAR struct tcb_s *tcb, size_t frame_size) +void *up_stack_frame(struct tcb_s *tcb, size_t frame_size) { - FAR void *ret; + void *ret; /* Align the frame_size */ @@ -89,7 +89,7 @@ FAR void *up_stack_frame(FAR struct tcb_s *tcb, size_t frame_size) /* Save the adjusted stack values in the struct tcb_s */ - tcb->stack_base_ptr = (FAR uint8_t *)tcb->stack_base_ptr + frame_size; + tcb->stack_base_ptr = (uint8_t *)tcb->stack_base_ptr + frame_size; tcb->adj_stack_size -= frame_size; /* And return the pointer to the allocated region */ diff --git a/arch/sparc/src/sparc_v8/Toolchain.defs b/arch/sparc/src/sparc_v8/Toolchain.defs index 6feb9eb0abdaa..67a04686a0939 100644 --- a/arch/sparc/src/sparc_v8/Toolchain.defs +++ b/arch/sparc/src/sparc_v8/Toolchain.defs @@ -52,19 +52,44 @@ ifeq ($(CONFIG_ARCH_CHIP_BM3803),y) ARCHCPUFLAGS += -mcpu=leon else ifeq ($(CONFIG_ARCH_CHIP_BM3823),y) ARCHCPUFLAGS += -mcpu=leon -mflat -else - $(error "No valid CONFIG_ARCH_CHIP_ set in the configuration") endif ifeq ($(CONFIG_DEBUG_CUSTOMOPT),y) - MAXOPTIMIZATION := $(CONFIG_DEBUG_OPTLEVEL) + ARCHOPTIMIZATION += $(CONFIG_DEBUG_OPTLEVEL) +else ifeq ($(CONFIG_DEBUG_FULLOPT),y) + ARCHOPTIMIZATION += -O2 +endif + +ifneq ($(CONFIG_DEBUG_NOOPT),y) + ARCHOPTIMIZATION += -fno-strict-aliasing +endif + +ifeq ($(CONFIG_FRAME_POINTER),y) + ARCHOPTIMIZATION += -fno-omit-frame-pointer -fno-optimize-sibling-calls +else + ARCHOPTIMIZATION += -fomit-frame-pointer +endif + +ifeq ($(CONFIG_DEBUG_SYMBOLS),y) + LDFLAGS += -g + ARCHOPTIMIZATION += -g +endif + +ARCHCFLAGS += -fno-common +ARCHCXXFLAGS += -fno-common -nostdinc++ + +ifneq ($(CONFIG_CXX_EXCEPTION),y) + ARCHCXXFLAGS += -fno-exceptions -fcheck-new +endif + +ifneq ($(CONFIG_CXX_RTTI),y) + ARCHCXXFLAGS += -fno-rtti endif # NuttX buildroot GCC toolchain under Linux or Cygwin ifeq ($(CONFIG_SPARC_TOOLCHAIN),BUILDROOT) CROSSDEV ?= sparc-gaisler-elf- - MAXOPTIMIZATION ?= -O2 LDFLAGS += -nostartfiles -nodefaultlibs LDSCRIPT = sparc-gaisler-elf-debug.ld endif @@ -73,13 +98,6 @@ endif ifeq ($(CONFIG_SPARC_TOOLCHAIN),CODEREDW) CROSSDEV ?= sparc-elf- - MAXOPTIMIZATION ?= -O2 LDFLAGS += -nostartfiles -nodefaultlibs LDSCRIPT = sparc-elf-debug.ld endif - -ifeq ($(CONFIG_FRAME_POINTER),y) - MAXOPTIMIZATION += -fno-omit-frame-pointer -fno-optimize-sibling-calls -else - MAXOPTIMIZATION += -fomit-frame-pointer -endif diff --git a/arch/sparc/src/sparc_v8/up_blocktask.c b/arch/sparc/src/sparc_v8/up_blocktask.c index af9dcb4aa7706..dc3e7bb8b25f2 100644 --- a/arch/sparc/src/sparc_v8/up_blocktask.c +++ b/arch/sparc/src/sparc_v8/up_blocktask.c @@ -138,15 +138,6 @@ void up_block_task(struct tcb_s *tcb, tstate_t task_state) struct tcb_s *nexttcb = this_task(); -#ifdef CONFIG_ARCH_ADDRENV - /* Make sure that the address environment for the previously - * running task is closed down gracefully (data caches dump, - * MMU flushed) and set up the address environment for the new - * thread at the head of the ready-to-run list. - */ - - (void)group_addrenv(nexttcb); -#endif /* Reset scheduler parameters */ nxsched_resume_scheduler(nexttcb); diff --git a/arch/sparc/src/sparc_v8/up_doirq.c b/arch/sparc/src/sparc_v8/up_doirq.c index a6687b65b8d88..abfad3fd4ad4e 100644 --- a/arch/sparc/src/sparc_v8/up_doirq.c +++ b/arch/sparc/src/sparc_v8/up_doirq.c @@ -98,7 +98,7 @@ uint32_t *up_doirq(int irq, uint32_t *regs) * thread at the head of the ready-to-run list. */ - (void)group_addrenv(NULL); + group_addrenv(NULL); #endif } #endif diff --git a/arch/sparc/src/sparc_v8/up_romgetc.c b/arch/sparc/src/sparc_v8/up_romgetc.c index 572c379d2c9cb..f560808ff4770 100644 --- a/arch/sparc/src/sparc_v8/up_romgetc.c +++ b/arch/sparc/src/sparc_v8/up_romgetc.c @@ -84,7 +84,7 @@ * ****************************************************************************/ -char up_romgetc(FAR const char *ptr) +char up_romgetc(const char *ptr) { return pgm_read_byte_near(ptr); } diff --git a/arch/sparc/src/sparc_v8/up_sigdeliver.c b/arch/sparc/src/sparc_v8/up_sigdeliver.c index ea33cedc9fcfa..5e83b9c73f0bb 100644 --- a/arch/sparc/src/sparc_v8/up_sigdeliver.c +++ b/arch/sparc/src/sparc_v8/up_sigdeliver.c @@ -91,7 +91,7 @@ void up_sigdeliver(void) */ sinfo("Resuming\n"); - (void)up_irq_save(); + up_irq_save(); /* Modify the saved return state with the actual saved values in the * TCB. This depends on the fact that nested signal handling is diff --git a/arch/sparc/src/sparc_v8/up_swint1.c b/arch/sparc/src/sparc_v8/up_swint1.c index 57397099fd1c4..432d232f1da23 100644 --- a/arch/sparc/src/sparc_v8/up_swint1.c +++ b/arch/sparc/src/sparc_v8/up_swint1.c @@ -81,7 +81,7 @@ static void dispatch_syscall(void) * ****************************************************************************/ -int up_swint1(int irq, FAR void *context, FAR void *arg) +int up_swint1(int irq, void *context, void *arg) { uint32_t *regs = (uint32_t *)context; @@ -187,7 +187,7 @@ int up_swint1(int irq, FAR void *context, FAR void *arg) default: { #ifdef CONFIG_BUILD_KERNEL - FAR struct tcb_s *rtcb = sched_self(); + struct tcb_s *rtcb = sched_self(); int index = rtcb->xcp.nsyscalls; /* Verify that the SYS call number is within range */ diff --git a/arch/sparc/src/sparc_v8/up_unblocktask.c b/arch/sparc/src/sparc_v8/up_unblocktask.c index 6785d4c65d267..d09511bd1eb5d 100644 --- a/arch/sparc/src/sparc_v8/up_unblocktask.c +++ b/arch/sparc/src/sparc_v8/up_unblocktask.c @@ -122,15 +122,6 @@ void up_unblock_task(struct tcb_s *tcb) struct tcb_s *nexttcb = this_task(); -#ifdef CONFIG_ARCH_ADDRENV - /* Make sure that the address environment for the previously - * running task is closed down gracefully (data caches dump, - * MMU flushed) and set up the address environment for the new - * thread at the head of the ready-to-run list. - */ - - (void)group_addrenv(nexttcb); -#endif /* Update scheduler parameters */ nxsched_resume_scheduler(nexttcb); diff --git a/arch/x86/src/common/up_exit.c b/arch/x86/src/common/up_exit.c index 4871346c065f7..46864f2d5b01b 100644 --- a/arch/x86/src/common/up_exit.c +++ b/arch/x86/src/common/up_exit.c @@ -70,7 +70,7 @@ static void _up_dumponexit(FAR struct tcb_s *tcb, FAR void *arg) sinfo(" TCB=%p name=%s pid=%d\n", tcb, tcb->name, tcb->pid); sinfo(" priority=%d state=%d\n", tcb->sched_priority, tcb->task_state); - filelist = tcb->group->tg_filelist; + filelist = &tcb->group->tg_filelist; for (i = 0; i < filelist->fl_rows; i++) { for (j = 0; j < CONFIG_NFILE_DESCRIPTORS_PER_BLOCK; j++) @@ -114,15 +114,15 @@ void up_exit(int status) sinfo("TCB=%p exiting\n", tcb); + /* Destroy the task at the head of the ready to run list. */ + + nxtask_exit(); + #ifdef CONFIG_DUMP_ON_EXIT sinfo("Other tasks:\n"); nxsched_foreach(_up_dumponexit, NULL); #endif - /* Destroy the task at the head of the ready to run list. */ - - nxtask_exit(); - /* Now, perform the context switch to the new ready-to-run task at the * head of the list. */ diff --git a/arch/x86/src/common/up_internal.h b/arch/x86/src/common/up_internal.h index f7c6c01028d74..00647d3362990 100644 --- a/arch/x86/src/common/up_internal.h +++ b/arch/x86/src/common/up_internal.h @@ -186,7 +186,6 @@ void up_decodeirq(uint32_t *regs); #ifdef CONFIG_ARCH_DMA void weak_function up_dma_initialize(void); #endif -int up_saveusercontext(uint32_t *saveregs); void up_fullcontextrestore(uint32_t *restoreregs) noreturn_function; void up_switchcontext(uint32_t *saveregs, uint32_t *restoreregs); void up_sigdeliver(void); diff --git a/arch/x86/src/qemu/qemu_keypad.c b/arch/x86/src/qemu/qemu_keypad.c index 06fe112876c2b..8640342eb439e 100644 --- a/arch/x86/src/qemu/qemu_keypad.c +++ b/arch/x86/src/qemu/qemu_keypad.c @@ -203,8 +203,6 @@ typedef enum * Private Function Prototypes ****************************************************************************/ -static int keypad_open(struct file *filep); -static int keypad_close(struct file *filep); static ssize_t keypad_read(struct file *filep, FAR char *buf, size_t buflen); /**************************************************************************** @@ -253,15 +251,15 @@ static const unsigned char g_kdbus[128] = static const struct file_operations g_keypadops = { - keypad_open, /* open */ - keypad_close, /* close */ - keypad_read, /* read */ - NULL, /* write */ - NULL, /* seek */ - NULL, /* ioctl */ - NULL /* poll */ + NULL, /* open */ + NULL, /* close */ + keypad_read, /* read */ + NULL, /* write */ + NULL, /* seek */ + NULL, /* ioctl */ + NULL /* poll */ #ifndef CONFIG_DISABLE_PSEUDOFS_OPERATIONS - , NULL /* unlink */ + , NULL /* unlink */ #endif }; @@ -269,16 +267,6 @@ static const struct file_operations g_keypadops = * Private Functions ****************************************************************************/ -static int keypad_open(struct file *filep) -{ - return OK; -} - -static int keypad_close(struct file *filep) -{ - return OK; -} - static ssize_t keypad_read(struct file *filep, FAR char *buf, size_t buflen) { uint_fast8_t keycode = 0; diff --git a/arch/x86/src/qemu/qemu_saveusercontext.S b/arch/x86/src/qemu/qemu_saveusercontext.S index 0f7a931101e28..d3c9ab437bc7a 100644 --- a/arch/x86/src/qemu/qemu_saveusercontext.S +++ b/arch/x86/src/qemu/qemu_saveusercontext.S @@ -66,7 +66,7 @@ * Name: up_saveusercontext * * Full C prototype: - * int up_saveusercontext(uint32_t *regs); + * int up_saveusercontext(void *regs); * * Description: * Save the "user" context. It is not necessary to save all of the diff --git a/arch/x86/src/qemu/qemu_vga.c b/arch/x86/src/qemu/qemu_vga.c index 240a4bb3a5444..4b2c8d8ae2953 100644 --- a/arch/x86/src/qemu/qemu_vga.c +++ b/arch/x86/src/qemu/qemu_vga.c @@ -109,11 +109,9 @@ static int vga_getpower(struct lcd_dev_s *dev); static int vga_setpower(struct lcd_dev_s *dev, int power); static int vga_getcontrast(struct lcd_dev_s *dev); static int vga_setcontrast(struct lcd_dev_s *dev, unsigned int contrast); -static int vga_open(struct file *filep); -static int vga_close(struct file *filep); static ssize_t vga_read(struct file *filep, FAR char *buf, size_t buflen); -static ssize_t vga_write(struct file *filep, - FAR const char *buf, size_t buflen); +static ssize_t vga_write(struct file *filep, FAR const char *buf, + size_t buflen); static off_t vga_seek(FAR struct file *filp, off_t offset, int whence); /**************************************************************************** @@ -233,15 +231,15 @@ static struct lcd_dev_s g_lcddev = static const struct file_operations g_vgaops = { - vga_open, /* open */ - vga_close, /* close */ - vga_read, /* read */ - vga_write, /* write */ - vga_seek, /* seek */ - NULL, /* ioctl */ - NULL /* poll */ + NULL, /* open */ + NULL, /* close */ + vga_read, /* read */ + vga_write, /* write */ + vga_seek, /* seek */ + NULL, /* ioctl */ + NULL /* poll */ #ifndef CONFIG_DISABLE_PSEUDOFS_OPERATIONS - , NULL /* unlink */ + , NULL /* unlink */ #endif }; @@ -472,16 +470,6 @@ static int vga_setcontrast(struct lcd_dev_s *dev, unsigned int contrast) return -ENOSYS; } -static int vga_open(struct file * filep) -{ - return OK; -} - -static int vga_close(struct file * filep) -{ - return OK; -} - static ssize_t vga_read(struct file *filep, FAR char *buf, size_t buflen) { if (buf == NULL || buflen < 1) @@ -494,8 +482,8 @@ static ssize_t vga_read(struct file *filep, FAR char *buf, size_t buflen) return buflen; } -static ssize_t vga_write(struct file *filep, - FAR const char *buf, size_t buflen) +static ssize_t vga_write(struct file *filep, FAR const char *buf, + size_t buflen) { int i; int j; diff --git a/arch/x86_64/src/common/up_allocateheap.c b/arch/x86_64/src/common/up_allocateheap.c index b7fbbce4b26dc..88a0d1dc4069c 100644 --- a/arch/x86_64/src/common/up_allocateheap.c +++ b/arch/x86_64/src/common/up_allocateheap.c @@ -67,7 +67,7 @@ const uintptr_t g_idle_topstack = (uintptr_t)&_ebss + * ****************************************************************************/ -void up_allocate_heap(FAR void **heap_start, size_t *heap_size) +void up_allocate_heap(void **heap_start, size_t *heap_size) { board_autoled_on(LED_HEAPALLOCATE); diff --git a/arch/x86_64/src/common/up_assert.c b/arch/x86_64/src/common/up_assert.c index 410598a2ce019..93ec98c24fc9c 100644 --- a/arch/x86_64/src/common/up_assert.c +++ b/arch/x86_64/src/common/up_assert.c @@ -89,7 +89,7 @@ static void x86_64_stackdump(uint64_t sp, uint64_t stack_top) ****************************************************************************/ #ifdef CONFIG_ARCH_USBDUMP -static int usbtrace_syslog(FAR const char *fmt, ...) +static int usbtrace_syslog(const char *fmt, ...) { va_list ap; @@ -101,7 +101,7 @@ static int usbtrace_syslog(FAR const char *fmt, ...) return OK; } -static int assert_tracecallback(FAR struct usbtrace_s *trace, FAR void *arg) +static int assert_tracecallback(struct usbtrace_s *trace, void *arg) { usbtrace_trprintf(usbtrace_syslog, trace->event, trace->value); return 0; @@ -115,7 +115,7 @@ static int assert_tracecallback(FAR struct usbtrace_s *trace, FAR void *arg) #ifdef CONFIG_ARCH_STACKDUMP static void up_dumpstate(void) { - FAR struct tcb_s *rtcb = running_task(); + struct tcb_s *rtcb = running_task(); uint64_t sp = up_getsp(); uint64_t ustackbase; uint64_t ustacksize; @@ -200,7 +200,7 @@ static void up_dumpstate(void) #ifdef CONFIG_ARCH_USBDUMP /* Dump USB trace data */ - (void)usbtrace_enumerate(assert_tracecallback, NULL); + usbtrace_enumerate(assert_tracecallback, NULL); #endif } #else @@ -221,7 +221,7 @@ static void _up_assert(void) if (g_current_regs || (running_task())->flink == NULL) { - (void)up_irq_save(); + up_irq_save(); for (; ; ) { #if CONFIG_BOARD_RESET_ON_ASSERT >= 1 diff --git a/arch/x86_64/src/common/up_blocktask.c b/arch/x86_64/src/common/up_blocktask.c index b7ae8813f1fc8..f87c5e9a4652c 100644 --- a/arch/x86_64/src/common/up_blocktask.c +++ b/arch/x86_64/src/common/up_blocktask.c @@ -147,7 +147,7 @@ void up_block_task(struct tcb_s *tcb, tstate_t task_state) * thread at the head of the ready-to-run list. */ - (void)group_addrenv(rtcb); + group_addrenv(rtcb); #endif /* Reset scheduler parameters */ diff --git a/arch/x86_64/src/common/up_exit.c b/arch/x86_64/src/common/up_exit.c index 80bee07a96aaf..edb12220a2db8 100644 --- a/arch/x86_64/src/common/up_exit.c +++ b/arch/x86_64/src/common/up_exit.c @@ -61,16 +61,16 @@ ****************************************************************************/ #ifdef CONFIG_DUMP_ON_EXIT -static void _up_dumponexit(FAR struct tcb_s *tcb, FAR void *arg) +static void _up_dumponexit(struct tcb_s *tcb, void *arg) { - FAR struct filelist *filelist; + struct filelist *filelist; int i; int j; sinfo(" TCB=%p name=%s pid=%d\n", tcb, tcb->name, tcb->pid); sinfo(" priority=%d state=%d\n", tcb->sched_priority, tcb->task_state); - filelist = tcb->group->tg_filelist; + filelist = &tcb->group->tg_filelist; for (i = 0; i < filelist->fl_rows; i++) { for (j = 0; j < CONFIG_NFILE_DESCRIPTORS_PER_BLOCK; j++) @@ -114,15 +114,15 @@ void up_exit(int status) sinfo("TCB=%p exiting\n", this_task()); + /* Destroy the task at the head of the ready to run list. */ + + nxtask_exit(); + #ifdef CONFIG_DUMP_ON_EXIT sinfo("Other tasks:\n"); nxsched_foreach(_up_dumponexit, NULL); #endif - /* Destroy the task at the head of the ready to run list. */ - - nxtask_exit(); - /* Now, perform the context switch to the new ready-to-run task at the * head of the list. */ diff --git a/arch/x86_64/src/common/up_internal.h b/arch/x86_64/src/common/up_internal.h index 324b6eaf0e726..9552b6d29b394 100644 --- a/arch/x86_64/src/common/up_internal.h +++ b/arch/x86_64/src/common/up_internal.h @@ -205,7 +205,6 @@ void up_decodeirq(uint64_t *regs); #ifdef CONFIG_ARCH_DMA void weak_function up_dmainitialize(void); #endif -int up_saveusercontext(uint64_t *saveregs); void up_fullcontextrestore(uint64_t *restoreregs) noreturn_function; void up_switchcontext(uint64_t *saveregs, uint64_t *restoreregs); void up_sigdeliver(void); diff --git a/arch/x86_64/src/common/up_releasepending.c b/arch/x86_64/src/common/up_releasepending.c index 1c5689d7f07e8..0eba1577a4bf5 100644 --- a/arch/x86_64/src/common/up_releasepending.c +++ b/arch/x86_64/src/common/up_releasepending.c @@ -116,7 +116,7 @@ void up_release_pending(void) * thread at the head of the ready-to-run list. */ - (void)group_addrenv(rtcb); + group_addrenv(rtcb); #endif /* Update scheduler parameters */ diff --git a/arch/x86_64/src/common/up_reprioritizertr.c b/arch/x86_64/src/common/up_reprioritizertr.c index c9461a187c7fc..7b4f01da6aac2 100644 --- a/arch/x86_64/src/common/up_reprioritizertr.c +++ b/arch/x86_64/src/common/up_reprioritizertr.c @@ -170,7 +170,7 @@ void up_reprioritize_rtr(struct tcb_s *tcb, uint8_t priority) * thread at the head of the ready-to-run list. */ - (void)group_addrenv(rtcb); + group_addrenv(rtcb); #endif /* Update scheduler parameters */ diff --git a/arch/x86_64/src/common/up_unblocktask.c b/arch/x86_64/src/common/up_unblocktask.c index 519bdd7e4822e..cd3fff6db1ae4 100644 --- a/arch/x86_64/src/common/up_unblocktask.c +++ b/arch/x86_64/src/common/up_unblocktask.c @@ -134,7 +134,7 @@ void up_unblock_task(struct tcb_s *tcb) * thread at the head of the ready-to-run list. */ - (void)group_addrenv(rtcb); + group_addrenv(rtcb); #endif /* Update scheduler parameters */ diff --git a/arch/x86_64/src/intel64/intel64_handlers.c b/arch/x86_64/src/intel64/intel64_handlers.c index b0b870a5c5d0b..9367a705ce9d4 100644 --- a/arch/x86_64/src/intel64/intel64_handlers.c +++ b/arch/x86_64/src/intel64/intel64_handlers.c @@ -99,7 +99,7 @@ static uint64_t *common_handler(int irq, uint64_t *regs) * thread at the head of the ready-to-run list. */ - (void)group_addrenv(NULL); + group_addrenv(NULL); #endif } #endif diff --git a/arch/x86_64/src/intel64/intel64_rng.c b/arch/x86_64/src/intel64/intel64_rng.c index 0771be13a829e..f3113098f468f 100644 --- a/arch/x86_64/src/intel64/intel64_rng.c +++ b/arch/x86_64/src/intel64/intel64_rng.c @@ -173,7 +173,7 @@ static ssize_t x86_rngread(struct file *filep, char *buffer, size_t buflen) void devrandom_register(void) { x86_rng_initialize(); - (void)register_driver("/dev/random", &g_rngops, 0444, NULL); + register_driver("/dev/random", &g_rngops, 0444, NULL); } #endif @@ -197,7 +197,7 @@ void devurandom_register(void) #ifndef CONFIG_DEV_RANDOM x86_rng_initialize(); #endif - (void)register_driver("/dev/urandom", &g_rngops, 0444, NULL); + register_driver("/dev/urandom", &g_rngops, 0444, NULL); } #endif diff --git a/arch/x86_64/src/intel64/intel64_saveusercontext.S b/arch/x86_64/src/intel64/intel64_saveusercontext.S index fd51be0833263..4c8479e25f7ca 100644 --- a/arch/x86_64/src/intel64/intel64_saveusercontext.S +++ b/arch/x86_64/src/intel64/intel64_saveusercontext.S @@ -66,7 +66,7 @@ * Name: up_saveusercontext * * Full C prototype: - * int up_saveusercontext(uint32_t *regs); + * int up_saveusercontext(void *regs); * * Description: * Save the "user" context. It is not necessary to save all of the diff --git a/arch/x86_64/src/intel64/intel64_tickless.c b/arch/x86_64/src/intel64/intel64_tickless.c index 87bcd2297aab8..573a93db33d80 100644 --- a/arch/x86_64/src/intel64/intel64_tickless.c +++ b/arch/x86_64/src/intel64/intel64_tickless.c @@ -27,10 +27,10 @@ * * void sim_timer_initialize(void): Initializes the timer facilities. * Called early in the initialization sequence (by up_initialize()). - * int up_timer_gettime(FAR struct timespec *ts): Returns the current + * int up_timer_gettime(struct timespec *ts): Returns the current * time from the platform specific time source. * int up_timer_cancel(void): Cancels the interval timer. - * int up_timer_start(FAR const struct timespec *ts): Start (or re-starts) + * int up_timer_start(const struct timespec *ts): Start (or re-starts) * the interval timer. * * The RTOS will provide the following interfaces for use by the platform- @@ -129,22 +129,22 @@ void up_timer_initialize(void) g_last_stop_time = g_start_tsc = rdtsc(); #ifndef CONFIG_SCHED_TICKLESS_ALARM - (void)irq_attach(TMR_IRQ, (xcpt_t)up_timer_expire, NULL); + irq_attach(TMR_IRQ, (xcpt_t)up_timer_expire, NULL); #else - (void)irq_attach(TMR_IRQ, (xcpt_t)up_alarm_expire, NULL); + irq_attach(TMR_IRQ, (xcpt_t)up_alarm_expire, NULL); #endif return; } -static inline uint64_t up_ts2tick(FAR const struct timespec *ts) +static inline uint64_t up_ts2tick(const struct timespec *ts) { return ROUND_INT_DIV((uint64_t)ts->tv_nsec * x86_64_timer_freq, NS_PER_SEC) + (uint64_t)ts->tv_sec * x86_64_timer_freq; } -static inline void up_tick2ts(uint64_t tick, FAR struct timespec *ts) +static inline void up_tick2ts(uint64_t tick, struct timespec *ts) { ts->tv_sec = (tick / x86_64_timer_freq); ts->tv_nsec = (uint64_t)(ROUND_INT_DIV((tick % x86_64_timer_freq) * @@ -182,7 +182,7 @@ static inline void up_tmr_sync_down(void) * sim_timer_initialize() was called). This function is functionally * equivalent to: * - * int clock_gettime(clockid_t clockid, FAR struct timespec *ts); + * int clock_gettime(clockid_t clockid, struct timespec *ts); * * when clockid is CLOCK_MONOTONIC. * @@ -207,7 +207,7 @@ static inline void up_tmr_sync_down(void) * ****************************************************************************/ -int up_timer_gettime(FAR struct timespec *ts) +int up_timer_gettime(struct timespec *ts) { uint64_t diff = (rdtsc() - g_start_tsc); up_tick2ts(diff, ts); @@ -247,7 +247,7 @@ int up_timer_gettime(FAR struct timespec *ts) * ****************************************************************************/ -int up_timer_cancel(FAR struct timespec *ts) +int up_timer_cancel(struct timespec *ts) { up_tmr_sync_up(); @@ -298,7 +298,7 @@ int up_timer_cancel(FAR struct timespec *ts) * ****************************************************************************/ -int up_timer_start(FAR const struct timespec *ts) +int up_timer_start(const struct timespec *ts) { uint64_t ticks; @@ -375,7 +375,7 @@ void up_timer_expire(void) * ****************************************************************************/ -int up_alarm_cancel(FAR struct timespec *ts) +int up_alarm_cancel(struct timespec *ts) { up_tmr_sync_up(); @@ -418,7 +418,7 @@ int up_alarm_cancel(FAR struct timespec *ts) * ****************************************************************************/ -int up_alarm_start(FAR const struct timespec *ts) +int up_alarm_start(const struct timespec *ts) { uint64_t ticks; diff --git a/arch/x86_64/src/intel64/intel64_timerisr.c b/arch/x86_64/src/intel64/intel64_timerisr.c index ec6f4b4df8cc6..bb9b0b642d3e9 100644 --- a/arch/x86_64/src/intel64/intel64_timerisr.c +++ b/arch/x86_64/src/intel64/intel64_timerisr.c @@ -118,7 +118,7 @@ void up_timer_initialize(void) unsigned long ecx; uint32_t vector = IRQ0; - (void)irq_attach(IRQ0, (xcpt_t)intel64_timerisr, NULL); + irq_attach(IRQ0, (xcpt_t)intel64_timerisr, NULL); #ifdef CONFIG_ARCH_INTEL64_HAVE_TSC_DEADLINE vector |= MSR_X2APIC_LVTT_TSC_DEADLINE; diff --git a/arch/x86_64/src/intel64/up_createstack.c b/arch/x86_64/src/intel64/up_createstack.c index 80b997c0000ca..d3653f8df2dd0 100644 --- a/arch/x86_64/src/intel64/up_createstack.c +++ b/arch/x86_64/src/intel64/up_createstack.c @@ -88,7 +88,7 @@ * ****************************************************************************/ -int up_create_stack(FAR struct tcb_s *tcb, size_t stack_size, uint8_t ttype) +int up_create_stack(struct tcb_s *tcb, size_t stack_size, uint8_t ttype) { #ifdef CONFIG_TLS_ALIGNED /* The allocated stack size must not exceed the maximum possible for the diff --git a/arch/x86_64/src/intel64/up_releasestack.c b/arch/x86_64/src/intel64/up_releasestack.c index e14f9484378a9..6636a2f4a6c78 100644 --- a/arch/x86_64/src/intel64/up_releasestack.c +++ b/arch/x86_64/src/intel64/up_releasestack.c @@ -77,7 +77,7 @@ * ****************************************************************************/ -void up_release_stack(FAR struct tcb_s *dtcb, uint8_t ttype) +void up_release_stack(struct tcb_s *dtcb, uint8_t ttype) { /* Is there a stack allocated? */ diff --git a/arch/x86_64/src/intel64/up_rtc.c b/arch/x86_64/src/intel64/up_rtc.c index a7ef203bae977..195a93e47ec2a 100644 --- a/arch/x86_64/src/intel64/up_rtc.c +++ b/arch/x86_64/src/intel64/up_rtc.c @@ -139,7 +139,7 @@ int up_rtc_initialize(void) * ************************************************************************************/ -int up_rtc_gettime(FAR struct timespec *tp) +int up_rtc_gettime(struct timespec *tp) { uint64_t tmp; @@ -165,7 +165,7 @@ int up_rtc_gettime(FAR struct timespec *tp) * ************************************************************************************/ -int up_rtc_settime(FAR const struct timespec *tp) +int up_rtc_settime(const struct timespec *tp) { /* What so ever.. */ diff --git a/arch/x86_64/src/intel64/up_sigdeliver.c b/arch/x86_64/src/intel64/up_sigdeliver.c index f489d361b330e..dd79a48ed7f55 100644 --- a/arch/x86_64/src/intel64/up_sigdeliver.c +++ b/arch/x86_64/src/intel64/up_sigdeliver.c @@ -100,7 +100,7 @@ void up_sigdeliver(void) */ sinfo("Resuming\n"); - (void)up_irq_save(); + up_irq_save(); /* Modify the saved return state with the actual saved values in the * TCB. This depends on the fact that nested signal handling is diff --git a/arch/x86_64/src/intel64/up_stackframe.c b/arch/x86_64/src/intel64/up_stackframe.c index ad7f978e9ea10..60f7f544fc3a9 100644 --- a/arch/x86_64/src/intel64/up_stackframe.c +++ b/arch/x86_64/src/intel64/up_stackframe.c @@ -69,9 +69,9 @@ * ****************************************************************************/ -FAR void *up_stack_frame(FAR struct tcb_s *tcb, size_t frame_size) +void *up_stack_frame(struct tcb_s *tcb, size_t frame_size) { - FAR void *ret; + void *ret; /* Align the frame_size */ @@ -89,7 +89,7 @@ FAR void *up_stack_frame(FAR struct tcb_s *tcb, size_t frame_size) /* Save the adjusted stack values in the struct tcb_s */ - tcb->stack_base_ptr = (FAR uint8_t *)tcb->stack_base_ptr + frame_size; + tcb->stack_base_ptr = (uint8_t *)tcb->stack_base_ptr + frame_size; tcb->adj_stack_size -= frame_size; /* And return the pointer to the allocated region */ diff --git a/arch/xtensa/Kconfig b/arch/xtensa/Kconfig index a4d2985ac7481..e30b9c283203b 100644 --- a/arch/xtensa/Kconfig +++ b/arch/xtensa/Kconfig @@ -54,6 +54,7 @@ config ARCH_CHIP_ESP32S2 select ARCH_HAVE_BOOTLOADER select ARCH_HAVE_TESTSET select ARCH_VECNOTIRQ + select LIBC_ARCH_ATOMIC select LIBC_ARCH_MEMCPY select LIBC_ARCH_MEMCHR select LIBC_ARCH_MEMCMP diff --git a/arch/xtensa/include/esp32/irq.h b/arch/xtensa/include/esp32/irq.h index bd2a4fc35eadf..2ccb8fdcdcb4a 100644 --- a/arch/xtensa/include/esp32/irq.h +++ b/arch/xtensa/include/esp32/irq.h @@ -117,7 +117,8 @@ #define ESP32_PERIPH_PWM3 42 /* INTR_STATUS_REG_1, bit 10 */ #define ESP32_PERIPH_LEDC 43 /* INTR_STATUS_REG_1, bit 11 */ #define ESP32_PERIPH_EFUSE 44 /* INTR_STATUS_REG_1, bit 12 */ -#define ESP32_PERIPH_CAN 45 /* INTR_STATUS_REG_1, bit 13 */ +#define ESP32_PERIPH_TWAI 45 /* INTR_STATUS_REG_1, bit 13 */ +#define ESP32_PERIPH_CAN ESP32_PERIPH_TWAI #define ESP32_PERIPH_RTC_CORE 46 /* INTR_STATUS_REG_1, bit 14 */ #define ESP32_PERIPH_RMT 47 /* INTR_STATUS_REG_1, bit 15 */ #define ESP32_PERIPH_PCNT 48 /* INTR_STATUS_REG_1, bit 16 */ @@ -244,7 +245,8 @@ #define ESP32_IRQ_PWM3 (XTENSA_IRQ_FIRSTPERIPH+ESP32_PERIPH_PWM3) #define ESP32_IRQ_LEDC (XTENSA_IRQ_FIRSTPERIPH+ESP32_PERIPH_LEDC) #define ESP32_IRQ_EFUSE (XTENSA_IRQ_FIRSTPERIPH+ESP32_PERIPH_EFUSE) -#define ESP32_IRQ_CAN (XTENSA_IRQ_FIRSTPERIPH+ESP32_PERIPH_CAN) +#define ESP32_IRQ_TWAI (XTENSA_IRQ_FIRSTPERIPH+ESP32_PERIPH_CAN) +#define ESP32_IRQ_CAN ESP32_IRQ_TWAI #define ESP32_IRQ_RTC_CORE (XTENSA_IRQ_FIRSTPERIPH+ESP32_PERIPH_RTC_CORE) #define ESP32_IRQ_RMT (XTENSA_IRQ_FIRSTPERIPH+ESP32_PERIPH_RMT) #define ESP32_IRQ_PCNT (XTENSA_IRQ_FIRSTPERIPH+ESP32_PERIPH_PCNT) diff --git a/arch/xtensa/include/irq.h b/arch/xtensa/include/irq.h index d21539b35152d..d0a6f2b92ce71 100644 --- a/arch/xtensa/include/irq.h +++ b/arch/xtensa/include/irq.h @@ -149,12 +149,11 @@ struct xcptcontext * another signal handler is executing will be ignored! */ - uint32_t saved_pc; - uint32_t saved_ps; + uint32_t *saved_regs; /* Register save area */ - uint32_t regs[XCPTCONTEXT_REGS]; + uint32_t *regs; #if XCHAL_CP_NUM > 0 /* Co-processor save area */ diff --git a/arch/xtensa/include/syscall.h b/arch/xtensa/include/syscall.h index e2a328504d1e8..2e82543d32a86 100644 --- a/arch/xtensa/include/syscall.h +++ b/arch/xtensa/include/syscall.h @@ -30,6 +30,7 @@ ****************************************************************************/ #include + #ifndef __ASSEMBLY__ # include #endif @@ -37,12 +38,50 @@ # include #endif -#include "xtensa_swi.h" +#include +#include /**************************************************************************** * Pre-processor Definitions ****************************************************************************/ +/* Select software interrupt number for context-switch. + * The SW interrupt level must be greater than XCHAL_SYSCALL_LEVEL + * and less than XCHAL_EXCM_LEVEL. + * So that we can generate an interrupt when up_irq_save is called. + * and not generate interrupt when up_irq_disable is called. + * Return an error if no suitable software interrupt was found. + */ + +#ifndef XTENSA_SWINT +# ifdef XCHAL_SOFTWARE2_INTERRUPT +# if XCHAL_INT_LEVEL(XCHAL_SOFTWARE2_INTERRUPT) > XCHAL_SYSCALL_LEVEL && \ + XCHAL_INT_LEVEL(XCHAL_SOFTWARE2_INTERRUPT) <= XCHAL_EXCM_LEVEL +# undef XTENSA_SWINT +# define XTENSA_SWINT XCHAL_SOFTWARE2_INTERRUPT +# endif +# endif +# ifdef XCHAL_SOFTWARE1_INTERRUPT +# if XCHAL_INT_LEVEL(XCHAL_SOFTWARE1_INTERRUPT) > XCHAL_SYSCALL_LEVEL && \ + XCHAL_INT_LEVEL(XCHAL_SOFTWARE1_INTERRUPT) <= XCHAL_EXCM_LEVEL +# undef XTENSA_SWINT +# define XTENSA_SWINT XCHAL_SOFTWARE1_INTERRUPT +# endif +# endif +# ifdef XCHAL_SOFTWARE0_INTERRUPT +# if XCHAL_INT_LEVEL(XCHAL_SOFTWARE0_INTERRUPT) > XCHAL_SYSCALL_LEVEL && \ + XCHAL_INT_LEVEL(XCHAL_SOFTWARE0_INTERRUPT) <= XCHAL_EXCM_LEVEL +# undef XTENSA_SWINT +# define XTENSA_SWINT XCHAL_SOFTWARE0_INTERRUPT +# endif +# endif +#endif +#ifndef XTENSA_SWINT +# error "There is no suitable sw interrupt in this Xtensa configuration." +#endif + +#define XCHAL_SWINT_CALL (1 << XTENSA_SWINT) + #define SYS_syscall 0x00 /* This logic uses three system calls {0,1,2} for context switching and one @@ -61,21 +100,21 @@ /* SYS call 0: * - * int xtensa_saveusercontext(uint32_t *saveregs); + * int up_saveusercontext(void *saveregs); */ #define SYS_save_context (0) /* SYS call 1: * - * void xtensa_fullcontextrestore(uint32_t *restoreregs) noreturn_function; + * void xtensa_context_restore(uint32_t **restoreregs) noreturn_function; */ #define SYS_restore_context (1) /* SYS call 2: * - * void xtensa_switchcontext(uint32_t *saveregs, uint32_t *restoreregs); + * void xtensa_switchcontext(uint32_t **saveregs, uint32_t *restoreregs); */ #define SYS_switch_context (2) diff --git a/arch/xtensa/src/Makefile b/arch/xtensa/src/Makefile index 3db7774471cc4..9d76fa6053416 100644 --- a/arch/xtensa/src/Makefile +++ b/arch/xtensa/src/Makefile @@ -43,6 +43,12 @@ AFLAGS += $(INCLUDES) NUTTX = $(call CONVERT_PATH,$(TOPDIR)$(DELIM)nuttx$(EXEEXT)) +# Additional rules for system call wrapper + +ifeq ($(CONFIG_SCHED_INSTRUMENTATION_SYSCALL),y) + EXTRALINKCMDS += @$(TOPDIR)/syscall/syscall_wraps.ldcmd +endif + HEAD_AOBJ = $(HEAD_ASRC:.S=$(OBJEXT)) HEAD_COBJ = $(HEAD_CSRC:.c=$(OBJEXT)) STARTUP_OBJS ?= $(HEAD_AOBJ) $(HEAD_COBJ) @@ -60,7 +66,7 @@ OBJS = $(AOBJS) $(COBJS) LDSTARTGROUP ?= --start-group LDENDGROUP ?= --end-group -LDFLAGS += $(addprefix -T,$(call CONVERT_PATH,$(ARCHSCRIPT))) +LDFLAGS += $(addprefix -T,$(call CONVERT_PATH,$(ARCHSCRIPT))) $(EXTRALINKCMDS) BOARDMAKE = $(if $(wildcard board$(DELIM)Makefile),y,) @@ -102,7 +108,7 @@ define LINK_ALLSYMS endef nuttx$(EXEEXT): $(STARTUP_OBJS) board/libboard$(LIBEXT) $(ARCHSCRIPT) - @echo "LD: nuttx" + $(Q) echo "LD: nuttx" ifneq ($(CONFIG_ALLSYMS),y) $(Q) $(LD) --entry=__start $(LDFLAGS) $(LIBPATHS) $(EXTRA_LIBPATHS) \ -o $(NUTTX) $(STARTUP_OBJS) $(EXTRA_OBJS) \ diff --git a/arch/xtensa/src/common/xtensa.h b/arch/xtensa/src/common/xtensa.h index a984976ef048c..99bd28646b2ff 100644 --- a/arch/xtensa/src/common/xtensa.h +++ b/arch/xtensa/src/common/xtensa.h @@ -32,6 +32,7 @@ # include # include # include +# include #endif #include @@ -102,15 +103,20 @@ #define IDLETHREAD_STACKSIZE ((CONFIG_IDLETHREAD_STACKSIZE + 15) & ~15) #define IDLETHREAD_STACKWORDS (IDLETHREAD_STACKSIZE >> 2) -/* In the XTENSA model, the state is copied from the stack to the TCB, but - * only a referenced is passed to get the state from the TCB. - * - * REVISIT: It would not be too difficult to save only a pointer to the - * state save area in the TCB and thus avoid the copy. +/* In the Xtensa model, the state is saved in stack, + * only a reference stored in TCB. */ -#define xtensa_savestate(regs) xtensa_copystate(regs, (uint32_t*)CURRENT_REGS) -#define xtensa_restorestate(regs) do { CURRENT_REGS = regs; } while (0) +#define xtensa_savestate(regs) ((regs) = (uint32_t *)CURRENT_REGS) +#define xtensa_restorestate(regs) (CURRENT_REGS = (regs)) + +/* Context switching via system calls ***************************************/ + +#define xtensa_context_restore(regs)\ + sys_call1(SYS_restore_context, (uintptr_t)regs) + +#define xtensa_switchcontext(saveregs, restoreregs)\ + sys_call2(SYS_switch_context, (uintptr_t)saveregs, (uintptr_t)restoreregs) /* Interrupt codes from other CPUs: */ @@ -279,12 +285,6 @@ int xtensa_intercpu_interrupt(int tocpu, int intcode); void xtensa_pause_handler(void); #endif -/* Synchronous context switching */ - -int xtensa_context_save(uint32_t *regs); -void xtensa_context_restore(uint32_t *regs) noreturn_function; -void xtensa_switchcontext(uint32_t *saveregs, uint32_t *restoreregs); - #if XCHAL_CP_NUM > 0 void xtensa_coproc_savestate(struct xtensa_cpstate_s *cpstate); void xtensa_coproc_restorestate(struct xtensa_cpstate_s *cpstate); diff --git a/arch/xtensa/src/common/xtensa_backtrace.c b/arch/xtensa/src/common/xtensa_backtrace.c index dbb43f150912a..5096f0337e89b 100644 --- a/arch/xtensa/src/common/xtensa_backtrace.c +++ b/arch/xtensa/src/common/xtensa_backtrace.c @@ -233,7 +233,7 @@ int up_backtrace(struct tcb_s *tcb, void **buffer, int size, int skip) if (up_interrupt_context()) { #if CONFIG_ARCH_INTERRUPTSTACK > 15 - FAR void *istackbase; + void *istackbase; #ifdef CONFIG_SMP istackbase = xtensa_intstack_alloc(); #else diff --git a/arch/xtensa/src/common/xtensa_blocktask.c b/arch/xtensa/src/common/xtensa_blocktask.c index f090994136499..c62ad63064c1a 100644 --- a/arch/xtensa/src/common/xtensa_blocktask.c +++ b/arch/xtensa/src/common/xtensa_blocktask.c @@ -140,7 +140,7 @@ void up_block_task(struct tcb_s *tcb, tstate_t task_state) /* Then switch contexts */ - xtensa_switchcontext(rtcb->xcp.regs, nexttcb->xcp.regs); + xtensa_switchcontext(&rtcb->xcp.regs, nexttcb->xcp.regs); /* xtensa_switchcontext forces a context switch to the task at the * head of the ready-to-run list. It does not 'return' in the diff --git a/arch/xtensa/src/common/xtensa_context.S b/arch/xtensa/src/common/xtensa_context.S index ec78a44f9fcdd..1521b53b24c51 100644 --- a/arch/xtensa/src/common/xtensa_context.S +++ b/arch/xtensa/src/common/xtensa_context.S @@ -67,7 +67,6 @@ #include #include "syscall.h" -#include "xtensa_swi.h" #include "xtensa_asm_utils.h" /**************************************************************************** @@ -205,47 +204,6 @@ _xtensa_context_save: .size _xtensa_context_save, . - _xtensa_context_save -/**************************************************************************** - * Name: xtensa_context_save - * - * Description: - * - * This function implements the moral equivalent of setjmp(). It is - * called from user code (with interrupts disabled) to save the current - * state of the running thread. This function always returns zero. - * - * The counterpart to this function is xtensa_context_restore(). - * - * Input State: - * a0 = The true return value to the caller. - * a2 = The address of the register state structure - * - * Return state: - * a0, a2, and a3 modified. - * Returned value is in a2 - * - ****************************************************************************/ - - .global xtensa_context_save - .type xtensa_context_save, @function - - .align 4 - .literal_position - .align 4 - -xtensa_context_save: - ENTRY(16) - - mov a3, a2 - movi a2, SYS_save_context - movi a4, XCHAL_SWINT_CALL - wsr a4, intset - rsync - - RET(16) - - .size xtensa_context_save, . - xtensa_context_save - /**************************************************************************** * Name: _xtensa_context_restore * @@ -332,50 +290,3 @@ _xtensa_context_restore: .size _xtensa_context_restore, . - _xtensa_context_restore -/**************************************************************************** - * Name: xtensa_context_restore - * - * Description: - * - * This functions implements the moral equivalent of longjmp(). It is - * called from user code (with interrupts disabled) to restore the current - * state of the running thread. This function always appears to be a - * second return from xtensa_context_save except that that it returns the - * value 1 (because the saved value of A2 was set to 1 - * inxtensa_context_save()). - * - * The counterpart to this function is xtensa_context_save(). - * - * Entry Conditions: - * - A0 = Return address to caller. - * - A2 = Pointer to the processor state save area - * - * Exit conditions: - * NOTE: That this function does NOT return to the caller but rather - * to a new threading context. It is not necessary to save any of the - * caller's registers. - * - * Assumptions: - * - Interrupts are disabled. - * - ****************************************************************************/ - - .global xtensa_context_restore - .type xtensa_context_restore, @function - - .align 4 - .literal_position - .align 4 - -xtensa_context_restore: - ENTRY(16) - - mov a3, a2 - movi a2, SYS_restore_context - movi a4, XCHAL_SWINT_CALL - wsr a4, intset - rsync - - RET(16) - - .size xtensa_context_restore, . - xtensa_context_restore diff --git a/arch/xtensa/src/common/xtensa_createstack.c b/arch/xtensa/src/common/xtensa_createstack.c index 4dc601d227f58..d8a972ee08bf8 100644 --- a/arch/xtensa/src/common/xtensa_createstack.c +++ b/arch/xtensa/src/common/xtensa_createstack.c @@ -219,27 +219,36 @@ int up_create_stack(struct tcb_s *tcb, size_t stack_size, uint8_t ttype) #ifdef CONFIG_STACK_COLORATION void xtensa_stack_color(void *stackbase, size_t nbytes) { - uintptr_t start; - uintptr_t end; - size_t nwords; - uint32_t *ptr; + uint32_t *stkptr; + uintptr_t stkend; + size_t nwords; + uintptr_t sp; /* Take extra care that we do not write outside the stack boundaries */ - start = STACK_ALIGN_UP((uintptr_t)stackbase); - end = nbytes ? STACK_ALIGN_DOWN((uintptr_t)stackbase + nbytes) : - up_getsp(); /* 0: colorize the running stack */ + stkptr = (uint32_t *)STACK_ALIGN_UP((uintptr_t)stackbase); - /* Get the adjusted size based on the top and bottom of the stack */ + if (nbytes == 0) /* 0: colorize the running stack */ + { + stkend = up_getsp(); + if (stkend > (uintptr_t)&sp) + { + stkend = (uintptr_t)&sp; + } + } + else + { + stkend = (uintptr_t)stackbase + nbytes; + } - nwords = (end - start) >> 2; - ptr = (uint32_t *)start; + stkend = STACK_ALIGN_DOWN(stkend); + nwords = (stkend - (uintptr_t)stackbase) >> 2; /* Set the entire stack to the coloration value */ while (nwords-- > 0) { - *ptr++ = STACK_COLOR; + *stkptr++ = STACK_COLOR; } } #endif diff --git a/arch/xtensa/src/common/xtensa_dumpstate.c b/arch/xtensa/src/common/xtensa_dumpstate.c index 1b9e59fcd52f4..13dcf03123ed0 100644 --- a/arch/xtensa/src/common/xtensa_dumpstate.c +++ b/arch/xtensa/src/common/xtensa_dumpstate.c @@ -295,12 +295,11 @@ void xtensa_dumpstate(void) if (CURRENT_REGS) { - memcpy(rtcb->xcp.regs, - (uintptr_t *)CURRENT_REGS, XCPTCONTEXT_SIZE); + rtcb->xcp.regs = (uint32_t *)CURRENT_REGS; } else { - xtensa_context_save(rtcb->xcp.regs); + up_saveusercontext(&rtcb->xcp.regs); } /* Dump the registers (if available) */ diff --git a/arch/xtensa/src/common/xtensa_exit.c b/arch/xtensa/src/common/xtensa_exit.c index 6b03e13d6bcc0..f6e0ee34783a1 100644 --- a/arch/xtensa/src/common/xtensa_exit.c +++ b/arch/xtensa/src/common/xtensa_exit.c @@ -72,7 +72,7 @@ static void _xtensa_dumponexit(struct tcb_s *tcb, void *arg) sinfo(" TCB=%p name=%s pid=%d\n", tcb, tcb->name, tcb->pid); sinfo(" priority=%d state=%d\n", tcb->sched_priority, tcb->task_state); - filelist = tcb->group->tg_filelist; + filelist = &tcb->group->tg_filelist; for (i = 0; i < filelist->fl_rows; i++) { for (j = 0; j < CONFIG_NFILE_DESCRIPTORS_PER_BLOCK; j++) @@ -116,11 +116,6 @@ void up_exit(int status) sinfo("TCB=%p exiting\n", tcb); -#ifdef CONFIG_DUMP_ON_EXIT - sinfo("Other tasks:\n"); - nxsched_foreach(_xtensa_dumponexit, NULL); -#endif - #if XCHAL_CP_NUM > 0 /* Disable co-processor support for the task that is exit-ing. */ @@ -131,6 +126,11 @@ void up_exit(int status) nxtask_exit(); +#ifdef CONFIG_DUMP_ON_EXIT + sinfo("Other tasks:\n"); + nxsched_foreach(_xtensa_dumponexit, NULL); +#endif + /* Now, perform the context switch to the new ready-to-run task at the * head of the list. */ @@ -143,23 +143,13 @@ void up_exit(int status) nxsched_resume_scheduler(tcb); -#ifdef CONFIG_ARCH_ADDRENV - /* Make sure that the address environment for the previously running - * task is closed down gracefully (data caches dump, MMU flushed) and - * set up the address environment for the new thread at the head of - * the ready-to-run list. - */ - - group_addrenv(tcb); -#endif - /* Then switch contexts */ - xtensa_context_restore(tcb->xcp.regs); + xtensa_context_restore(&tcb->xcp.regs); /* xtensa_context_restore() should not return but could if the * software interrupts are disabled. */ - DEBUGPANIC(); + PANIC(); } diff --git a/arch/xtensa/src/common/xtensa_initialstate.c b/arch/xtensa/src/common/xtensa_initialstate.c index b059d62cbd434..554223ba15151 100644 --- a/arch/xtensa/src/common/xtensa_initialstate.c +++ b/arch/xtensa/src/common/xtensa_initialstate.c @@ -58,6 +58,10 @@ void up_initial_state(struct tcb_s *tcb) { struct xcptcontext *xcp = &tcb->xcp; + /* Initialize the initial exception register context structure */ + + memset(xcp, 0, sizeof(struct xcptcontext)); + /* Initialize the idle thread stack */ if (tcb->pid == IDLE_PROCESS_ID) @@ -74,11 +78,18 @@ void up_initial_state(struct tcb_s *tcb) xtensa_stack_color(tcb->stack_alloc_ptr, 0); #endif /* CONFIG_STACK_COLORATION */ + return; } - /* Initialize the initial exception register context structure */ + /* Initialize the context registers to stack top */ - memset(xcp, 0, sizeof(struct xcptcontext)); + xcp->regs = (void *)((uint32_t)tcb->stack_base_ptr + + tcb->adj_stack_size - + XCPTCONTEXT_SIZE); + + /* Initialize the xcp registers */ + + memset(xcp->regs, 0, XCPTCONTEXT_SIZE); /* Set initial values of registers */ diff --git a/arch/xtensa/src/common/xtensa_int_handlers.S b/arch/xtensa/src/common/xtensa_int_handlers.S index fbcf025baf058..c1d2d94850cc9 100644 --- a/arch/xtensa/src/common/xtensa_int_handlers.S +++ b/arch/xtensa/src/common/xtensa_int_handlers.S @@ -64,10 +64,16 @@ #include #include +#include "xtensa_macros.S" + #include "chip.h" #include "xtensa.h" #include "xtensa_timer.h" +/**************************************************************************** + * Public Symbols + ****************************************************************************/ + #if !defined(CONFIG_SMP) && CONFIG_ARCH_INTERRUPTSTACK > 15 .data .align 16 @@ -105,34 +111,13 @@ g_intstacktop: .endm /**************************************************************************** - * Name: setintstack - * - * Description: - * Set the current stack pointer to the "top" the interrupt stack. - * Single CPU case. - * Must be provided by MCU-specific logic in the SMP case. - * - ****************************************************************************/ - -#if !defined(CONFIG_SMP) && CONFIG_ARCH_INTERRUPTSTACK > 15 - .macro setintstack tmp1 tmp2 - movi a1, g_intstacktop - .endm -#endif - -/**************************************************************************** - * Macro dispatch_c_isr level mask + * Macro dispatch_c_isr level mask tmp * * Description: * - * This will dispatch to user handlers (if any) that are registered in the - * XTOS dispatch table (_xtos_interrupt_table). These handlers would have - * been registered by calling _xtos_set_interrupt_handler(). There is one - * exception - the timer interrupt used by the OS will not be dispatched - * to a user handler - this must be handled by the caller of this macro. - * - * Level triggered and software interrupts are automatically deasserted by - * this code. + * This macro will dispatch the set of pending and enabled interrupts to + * their handlers. It just does the necessary configuration and ends up + * calling xtensa_int_decode. * * Assumptions: * - PS.INTLEVEL is set to "level" at entry @@ -150,7 +135,20 @@ g_intstacktop: * ****************************************************************************/ - .macro dispatch_c_isr level mask + .macro dispatch_c_isr level mask tmp + + /* If the interrupt stack is disabled, reserve xcpcontext to ensure + * that signal processing can have a separate xcpcontext to handle + * signal context (ref: xtensa_schedulesigaction.c): + */ + +#if CONFIG_ARCH_INTERRUPTSTACK < 15 + addi sp, sp, -XCPTCONTEXT_SIZE +#endif + + /* Set up PS for C, enable interrupts above this level and clear EXCM. */ + + ps_setup \level \tmp #ifdef __XTENSA_CALL0_ABI__ /* Get mask of pending, enabled interrupts at this level into a2. */ @@ -188,27 +186,27 @@ g_intstacktop: and a6, a6, a3 /* a6 = Set of pending, enabled interrupts for this level */ beqz a6, 1f /* Nothing to do */ - /* At this point, the exception frame should have been allocated and filled, - * and current sp points to the interrupt stack (if enabled). Copy the - * pre-exception's base save area below the current SP. - */ + /* At this point, the exception frame should have been allocated and filled, + * and current sp points to the interrupt stack (if enabled). Copy the + * pre-exception's base save area below the current SP. We saved the SP in A12 + * before getting here. + */ #ifdef CONFIG_XTENSA_INTBACKTRACE - rsr a0, EXCSAVE_1 + \level - 1 /* Get exception frame pointer stored in EXCSAVE_x */ - l32i a3, a0, (4 * REG_A0) /* Copy pre-exception a0 (return address) */ - s32e a3, sp, -16 - l32i a3, a0, (4 * REG_A1) /* Copy pre-exception a1 (stack pointer) */ - s32e a3, sp, -12 - - /* Backtracing only needs a0 and a1, no need to create full base save area. - * Also need to change current frame's return address to point to pre-exception's - * last run instruction. - */ + l32i a3, a12, (4 * REG_A0) /* Copy pre-exception a0 (return address) */ + s32e a3, sp, -16 + l32i a3, a12, (4 * REG_A1) /* Copy pre-exception a1 (stack pointer) */ + s32e a3, sp, -12 + + /* Backtracing only needs a0 and a1, no need to create full base save area. + * Also need to change current frame's return address to point to pre-exception's + * last run instruction. + */ - rsr a0, EPC_1 + \level - 1 /* return address */ - movi a4, 0xc0000000 /* constant with top 2 bits set (call size) */ - or a0, a0, a4 /* set top 2 bits */ - addx2 a0, a4, a0 /* clear top bit -- simulating call4 size */ + rsr a0, EPC_1 + \level - 1 /* return address */ + movi a4, 0xc0000000 /* constant with top 2 bits set (call size) */ + or a0, a0, a4 /* set top 2 bits */ + addx2 a0, a4, a0 /* clear top bit -- simulating call4 size */ #endif /* Call xtensa_int_decode passing the address of the register save area @@ -228,54 +226,13 @@ g_intstacktop: mov a12, a6 /* Switch to the save area of the new thread */ #endif - /* Done */ - -1: - .endm - -/**************************************************************************** - * Macro: ps_setup - * - * Description: - * Set up PS for C, enable interrupts above this level and clear EXCM. - * - * Entry Conditions: - * level - interrupt level - * tmp - scratch register - * - * Side Effects: - * PS and scratch register modified - * - * Assumptions: - * - PS.EXCM = 1, C calling disabled - * - ****************************************************************************/ - - .macro ps_setup level tmp - -#if 0 /* Nested interrupts no yet supported */ -# ifdef __XTENSA_CALL0_ABI__ - /* Disable interrupts at level and below */ - - movi \tmp, PS_INTLEVEL(\level) | PS_UM -# else - movi \tmp, PS_INTLEVEL(\level) | PS_UM | PS_WOE -# endif -#else -# ifdef __XTENSA_CALL0_ABI__ - /* Disable all low- and medium-priority interrupts. Nested are not yet - * supported. - */ - - movi \tmp, PS_INTLEVEL(XCHAL_EXCM_LEVEL) | PS_UM -# else - movi \tmp, PS_INTLEVEL(XCHAL_EXCM_LEVEL) | PS_UM | PS_WOE -# endif +#if CONFIG_ARCH_INTERRUPTSTACK < 15 + addi sp, sp, XCPTCONTEXT_SIZE #endif - wsr \tmp, PS - rsync + /* Done */ +1: .endm /**************************************************************************** @@ -305,10 +262,6 @@ _xtensa_level1_handler: s32i a0, sp, (4 * REG_A0) s32i a2, sp, (4 * REG_A2) -#ifdef CONFIG_XTENSA_INTBACKTRACE - wsr sp, EXCSAVE_1 -#endif - /* Save rest of interrupt context. */ call0 _xtensa_context_save @@ -326,10 +279,6 @@ _xtensa_level1_handler: setintstack a13 a14 #endif - /* Set up PS for C, enable interrupts above this level and clear EXCM. */ - - ps_setup 1 a0 - /* Decode and dispatch the interrupt. In the event of an interrupt * level context dispatch_c_isr() will (1) switch stacks to the new * thread's and (2) provide the address of the register state save @@ -337,7 +286,7 @@ _xtensa_level1_handler: * in the new thread's stack. */ - dispatch_c_isr 1 XCHAL_INTLEVEL1_MASK + dispatch_c_isr 1 XCHAL_INTLEVEL1_MASK a0 /* Restore registers in preparation to return from interrupt */ @@ -407,10 +356,6 @@ _xtensa_level2_handler: s32i a0, sp, (4 * REG_A0) s32i a2, sp, (4 * REG_A2) -#ifdef CONFIG_XTENSA_INTBACKTRACE - wsr sp, EXCSAVE_2 -#endif - /* Save rest of interrupt context. */ call0 _xtensa_context_save @@ -428,10 +373,6 @@ _xtensa_level2_handler: setintstack a13 a14 #endif - /* Set up PS for C, enable interrupts above this level and clear EXCM. */ - - ps_setup 2 a0 - /* Decode and dispatch the interrupt. In the event of an interrupt * level context dispatch_c_isr() will (1) switch stacks to the new * thread's and (2) provide the address of the register state save @@ -439,7 +380,7 @@ _xtensa_level2_handler: * in the new thread's stack. */ - dispatch_c_isr 2 XCHAL_INTLEVEL2_MASK + dispatch_c_isr 2 XCHAL_INTLEVEL2_MASK a0 /* Restore registers in preparation to return from interrupt */ @@ -484,10 +425,6 @@ _xtensa_level3_handler: s32i a0, sp, (4 * REG_A0) s32i a2, sp, (4 * REG_A2) -#ifdef CONFIG_XTENSA_INTBACKTRACE - wsr sp, EXCSAVE_3 -#endif - /* Save rest of interrupt context. */ call0 _xtensa_context_save @@ -505,10 +442,6 @@ _xtensa_level3_handler: setintstack a13 a14 #endif - /* Set up PS for C, enable interrupts above this level and clear EXCM. */ - - ps_setup 3 a0 - /* Decode and dispatch the interrupt. In the event of an interrupt * level context dispatch_c_isr() will (1) switch stacks to the new * thread's and (2) provide the address of the register state save @@ -516,7 +449,7 @@ _xtensa_level3_handler: * in the new thread's stack. */ - dispatch_c_isr 3 XCHAL_INTLEVEL3_MASK + dispatch_c_isr 3 XCHAL_INTLEVEL3_MASK a0 /* Restore registers in preparation to return from interrupt */ @@ -561,10 +494,6 @@ _xtensa_level4_handler: s32i a0, sp, (4 * REG_A0) s32i a2, sp, (4 * REG_A2) -#ifdef CONFIG_XTENSA_INTBACKTRACE - wsr sp, EXCSAVE_4 -#endif - /* Save rest of interrupt context. */ call0 _xtensa_context_save @@ -582,10 +511,6 @@ _xtensa_level4_handler: setintstack a13 a14 #endif - /* Set up PS for C, enable interrupts above this level and clear EXCM. */ - - ps_setup 4 a0 - /* Decode and dispatch the interrupt. In the event of an interrupt * level context dispatch_c_isr() will (1) switch stacks to the new * thread's and (2) provide the address of the register state save @@ -593,7 +518,7 @@ _xtensa_level4_handler: * in the new thread's stack. */ - dispatch_c_isr 4 XCHAL_INTLEVEL4_MASK + dispatch_c_isr 4 XCHAL_INTLEVEL4_MASK a0 /* Restore registers in preparation to return from interrupt */ @@ -638,10 +563,6 @@ _xtensa_level5_handler: s32i a0, sp, (4 * REG_A0) s32i a2, sp, (4 * REG_A2) -#ifdef CONFIG_XTENSA_INTBACKTRACE - wsr sp, EXCSAVE_5 -#endif - /* Save rest of interrupt context. */ call0 _xtensa_context_save @@ -659,10 +580,6 @@ _xtensa_level5_handler: setintstack a13 a14 #endif - /* Set up PS for C, enable interrupts above this level and clear EXCM. */ - - ps_setup 5 a0 - /* Decode and dispatch the interrupt. In the event of an interrupt * level context dispatch_c_isr() will (1) switch stacks to the new * thread's and (2) provide the address of the register state save @@ -670,7 +587,7 @@ _xtensa_level5_handler: * in the new thread's stack. */ - dispatch_c_isr 5 XCHAL_INTLEVEL5_MASK + dispatch_c_isr 5 XCHAL_INTLEVEL5_MASK a0 /* Restore registers in preparation to return from interrupt */ @@ -715,10 +632,6 @@ _xtensa_level6_handler: s32i a0, sp, (4 * REG_A0) s32i a2, sp, (4 * REG_A2) -#ifdef CONFIG_XTENSA_INTBACKTRACE - wsr sp, EXCSAVE_6 -#endif - /* Save rest of interrupt context. */ call0 _xtensa_context_save /* Save full register state */ @@ -736,10 +649,6 @@ _xtensa_level6_handler: setintstack a13 a14 #endif - /* Set up PS for C, enable interrupts above this level and clear EXCM. */ - - ps_setup 6 a0 - /* Decode and dispatch the interrupt. In the event of an interrupt * level context dispatch_c_isr() will (1) switch stacks to the new * thread's and (2) provide the address of the register state save @@ -747,7 +656,7 @@ _xtensa_level6_handler: * in the new thread's stack. */ - dispatch_c_isr 6 XCHAL_INTLEVEL6_MASK + dispatch_c_isr 6 XCHAL_INTLEVEL6_MASK a0 /* Restore registers in preparation to return from interrupt */ diff --git a/arch/arm/src/arm/arm_fullcontextrestore.S b/arch/xtensa/src/common/xtensa_macros.S similarity index 53% rename from arch/arm/src/arm/arm_fullcontextrestore.S rename to arch/xtensa/src/common/xtensa_macros.S index 736829278bf69..cb57846d1c7ac 100644 --- a/arch/arm/src/arm/arm_fullcontextrestore.S +++ b/arch/xtensa/src/common/xtensa_macros.S @@ -1,5 +1,5 @@ /**************************************************************************** - * arch/arm/src/arm/arm_fullcontextrestore.S + * arch/xtensa/src/common/xtensa_macros.S * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with @@ -18,59 +18,77 @@ * ****************************************************************************/ +.file "xtensa_macros.S" + /**************************************************************************** * Included Files ****************************************************************************/ #include -#include -#include - -#include "arm.h" - -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -/**************************************************************************** - * Public Symbols - ****************************************************************************/ - .file "arm_fullcontextrestore.S" +#include +#include +#include +#include /**************************************************************************** - * Macros + * Name: setintstack + * + * Description: + * Set the current stack pointer to the "top" the interrupt stack. + * Single CPU case. + * Must be provided by MCU-specific logic in the SMP case. + * ****************************************************************************/ -/**************************************************************************** - * Public Functions - ****************************************************************************/ +#if !defined(CONFIG_SMP) && CONFIG_ARCH_INTERRUPTSTACK > 15 + .macro setintstack tmp1 tmp2 + movi a1, g_intstacktop + .endm +#endif /**************************************************************************** - * Name: arm_fullcontextrestore + * Macro: ps_setup * * Description: - * Restore the current thread context. Full prototype is: + * Set up PS for C, enable interrupts above this level and clear EXCM. + * + * Entry Conditions: + * level - interrupt level + * tmp - scratch register * - * void arm_fullcontextrestore(uint32_t *restoreregs) noreturn_function; + * Side Effects: + * PS and scratch register modified * - * Returned Value: - * None + * Assumptions: + * - PS.EXCM = 1, C calling disabled * ****************************************************************************/ - .globl arm_fullcontextrestore - .type arm_fullcontextrestore, function -arm_fullcontextrestore: + .macro ps_setup level tmp + +#if 0 /* Nested interrupts no yet supported */ +# ifdef __XTENSA_CALL0_ABI__ + /* Disable interrupts at level and below */ + + movi \tmp, PS_INTLEVEL(\level) | PS_UM +# else + movi \tmp, PS_INTLEVEL(\level) | PS_UM | PS_WOE +# endif +#else +# ifdef __XTENSA_CALL0_ABI__ + /* Disable all low- and medium-priority interrupts. Nested are not yet + * supported. + */ - /* Perform the System call with R0=1 and R1=regs */ + movi \tmp, PS_INTLEVEL(XCHAL_EXCM_LEVEL) | PS_UM +# else + movi \tmp, PS_INTLEVEL(XCHAL_EXCM_LEVEL) | PS_UM | PS_WOE +# endif +#endif - mov r1, r0 /* R1: regs */ - mov r0, #SYS_restore_context /* R0: restore context */ - svc #SYS_syscall /* Force synchronous SVCall (or Hard Fault) */ + wsr \tmp, PS + rsync - /* This call should not return */ + .endm - bx lr /* Unnecessary ... will not return */ - .size arm_fullcontextrestore, .-arm_fullcontextrestore - .end diff --git a/arch/xtensa/src/common/xtensa_panic.S b/arch/xtensa/src/common/xtensa_panic.S index f5ebd53801b63..dbd2ce7099753 100644 --- a/arch/xtensa/src/common/xtensa_panic.S +++ b/arch/xtensa/src/common/xtensa_panic.S @@ -64,27 +64,9 @@ #include #include -#include "chip.h" - -/**************************************************************************** - * Assembly Language Macros - ****************************************************************************/ - -/**************************************************************************** - * Name: setintstack - * - * Description: - * Set the current stack pointer to the "top" the interrupt stack. - * Single CPU case. - * Must be provided by MCU-specific logic in the SMP case. - * - ****************************************************************************/ +#include "xtensa_macros.S" -#if !defined(CONFIG_SMP) && CONFIG_ARCH_INTERRUPTSTACK > 15 - .macro setintstack tmp1 tmp2 - movi a1, g_intstacktop - .endm -#endif +#include "chip.h" /**************************************************************************** * Public Functions @@ -147,14 +129,7 @@ _xtensa_panic: /* Set up PS for C, re-enable hi-pri interrupts, and clear EXCM. */ -#ifdef __XTENSA_CALL0_ABI__ - movi a0, PS_INTLEVEL(XCHAL_EXCM_LEVEL) | PS_UM -#else - movi a0, PS_INTLEVEL(XCHAL_EXCM_LEVEL) | PS_UM | PS_WOE -#endif - - wsr a0, PS - rsync + ps_setup XCHAL_EXCM_LEVEL a0 /* Call C panic handler: Arg1 (A2) = Exception code; Arg 2 (A3) = start * of the register save area. diff --git a/arch/xtensa/src/common/xtensa_releasepending.c b/arch/xtensa/src/common/xtensa_releasepending.c index 3d8f9c801b8fe..f88e8051aa7c7 100644 --- a/arch/xtensa/src/common/xtensa_releasepending.c +++ b/arch/xtensa/src/common/xtensa_releasepending.c @@ -109,7 +109,7 @@ void up_release_pending(void) * ready to run list. */ - xtensa_switchcontext(rtcb->xcp.regs, nexttcb->xcp.regs); + xtensa_switchcontext(&rtcb->xcp.regs, nexttcb->xcp.regs); /* xtensa_switchcontext forces a context switch to the task at the * head of the ready-to-run list. It does not 'return' in the diff --git a/arch/xtensa/src/common/xtensa_reprioritizertr.c b/arch/xtensa/src/common/xtensa_reprioritizertr.c index 624b73e4e3bb7..5360f7fff4c06 100644 --- a/arch/xtensa/src/common/xtensa_reprioritizertr.c +++ b/arch/xtensa/src/common/xtensa_reprioritizertr.c @@ -163,7 +163,7 @@ void up_reprioritize_rtr(struct tcb_s *tcb, uint8_t priority) * ready to run list. */ - xtensa_switchcontext(rtcb->xcp.regs, nexttcb->xcp.regs); + xtensa_switchcontext(&rtcb->xcp.regs, nexttcb->xcp.regs); /* xtensa_switchcontext forces a context switch to the task at * the head of the ready-to-run list. It does not 'return' in diff --git a/arch/xtensa/src/common/xtensa_saveusercontext.c b/arch/xtensa/src/common/xtensa_saveusercontext.c new file mode 100644 index 0000000000000..5d436674eede5 --- /dev/null +++ b/arch/xtensa/src/common/xtensa_saveusercontext.c @@ -0,0 +1,50 @@ +/**************************************************************************** + * arch/xtensa/src/common/xtensa_saveusercontext.c + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: up_saveusercontext + * + * Description: + * Save the current thread context. Full prototype is: + * + * int up_saveusercontext(void *saveregs); + * + * Returned Value: + * 0: Normal return + * 1: Context switch return + * + ****************************************************************************/ + +int up_saveusercontext(void *saveregs) +{ + return sys_call1(SYS_save_context, (uintptr_t)saveregs); +} diff --git a/arch/xtensa/src/common/xtensa_schedsigaction.c b/arch/xtensa/src/common/xtensa_schedsigaction.c index fc5f399424c36..7b376e3c44027 100644 --- a/arch/xtensa/src/common/xtensa_schedsigaction.c +++ b/arch/xtensa/src/common/xtensa_schedsigaction.c @@ -81,6 +81,7 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver) { sinfo("tcb=0x%p sigdeliver=0x%p\n", tcb, sigdeliver); + DEBUGASSERT(tcb != NULL && sigdeliver != NULL); /* Refuse to handle nested signal actions */ @@ -121,20 +122,30 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver) else { - /* Save the return pc and ps. These will be restored by the + /* Save the context registers. These will be restored by the * signal trampoline after the signals have been delivered. * * NOTE: that hi-priority interrupts are not disabled. */ - tcb->xcp.sigdeliver = sigdeliver; - tcb->xcp.saved_pc = CURRENT_REGS[REG_PC]; - tcb->xcp.saved_ps = CURRENT_REGS[REG_PS]; + xtensa_savestate(tcb->xcp.saved_regs); + + /* Duplicate the register context. These will be + * restored by the signal trampoline after the signal has + * been delivered. + */ + + CURRENT_REGS = (void *)((uint32_t)CURRENT_REGS - + XCPTCONTEXT_SIZE); + + memcpy((uint32_t *)CURRENT_REGS, tcb->xcp.saved_regs, + XCPTCONTEXT_SIZE); /* Then set up to vector to the trampoline with interrupts * disabled */ + tcb->xcp.sigdeliver = sigdeliver; CURRENT_REGS[REG_PC] = (uint32_t)_xtensa_sig_trampoline; #ifdef __XTENSA_CALL0_ABI__ CURRENT_REGS[REG_PS] = (uint32_t) @@ -144,11 +155,8 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver) (PS_INTLEVEL(XCHAL_EXCM_LEVEL) | PS_UM | PS_WOE); #endif - /* And make sure that the saved context in the TCB is the same - * as the interrupt return context. - */ - - xtensa_savestate(tcb->xcp.regs); + CURRENT_REGS[REG_A1] = (uint32_t)CURRENT_REGS + + XCPTCONTEXT_SIZE; } } @@ -159,16 +167,26 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver) else { - /* Save the return pc and ps. These will be restored by the + /* Save the context registers. These will be restored by the * signal trampoline after the signals have been delivered. * * NOTE: that hi-priority interrupts are not disabled. */ tcb->xcp.sigdeliver = sigdeliver; - tcb->xcp.saved_pc = tcb->xcp.regs[REG_PC]; - tcb->xcp.saved_ps = tcb->xcp.regs[REG_PS]; + tcb->xcp.saved_regs = tcb->xcp.regs; + /* Duplicate the register context. These will be + * restored by the signal trampoline after the signal has been + * delivered. + */ + + tcb->xcp.regs = (void *)((uint32_t)tcb->xcp.regs - + XCPTCONTEXT_SIZE); + memcpy(tcb->xcp.regs, tcb->xcp.saved_regs, XCPTCONTEXT_SIZE); + + tcb->xcp.regs[REG_A1] = (uint32_t)tcb->xcp.regs + + XCPTCONTEXT_SIZE; /* Then set up to vector to the trampoline with interrupts * disabled */ @@ -250,7 +268,7 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver) /* Now tcb on the other CPU can be accessed safely */ - /* Copy tcb->xcp.regs to tcp.xcp.saved. These will be + /* Copy tcb->xcp.regs to tcp.xcp.saved_regs. These will be * restored by the signal trampoline after the signal has * been delivered. * @@ -258,8 +276,21 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver) */ tcb->xcp.sigdeliver = sigdeliver; - tcb->xcp.saved_pc = tcb->xcp.regs[REG_PC]; - tcb->xcp.saved_ps = tcb->xcp.regs[REG_PS]; + tcb->xcp.saved_regs = tcb->xcp.regs; + + /* Duplicate the register context. These will be + * restored by the signal trampoline after the signal has + * been delivered. + */ + + tcb->xcp.regs = (void *) + ((uint32_t)tcb->xcp.regs - + (uint32_t)XCPTCONTEXT_SIZE); + memcpy(tcb->xcp.regs, tcb->xcp.saved_regs, + XCPTCONTEXT_SIZE); + + tcb->xcp.regs[REG_A1] = (uint32_t)tcb->xcp.regs + + (uint32_t)XCPTCONTEXT_SIZE; /* Then set up to vector to the trampoline with interrupts * disabled @@ -278,7 +309,7 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver) { /* tcb is running on the same CPU */ - /* Copy tcb->xcp.regs to tcp.xcp.saved. These will be + /* Copy tcb->xcp.regs to tcp.xcp.saved_regs. These will be * restored by the signal trampoline after the signal has * been delivered. * @@ -286,8 +317,21 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver) */ tcb->xcp.sigdeliver = sigdeliver; - tcb->xcp.saved_pc = CURRENT_REGS[REG_PC]; - tcb->xcp.saved_ps = CURRENT_REGS[REG_PS]; + xtensa_savestate(tcb->xcp.saved_regs); + + /* Duplicate the register context. These will be + * restored by the signal trampoline after the signal has + * been delivered. + */ + + CURRENT_REGS = (void *) + ((uint32_t)CURRENT_REGS - + (uint32_t)XCPTCONTEXT_SIZE); + memcpy((uint32_t *)CURRENT_REGS, tcb->xcp.saved_regs, + XCPTCONTEXT_SIZE); + + CURRENT_REGS[REG_A1] = (uint32_t)CURRENT_REGS + + (uint32_t)XCPTCONTEXT_SIZE; /* Then set up to vector to the trampoline with interrupts * disabled @@ -301,11 +345,6 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver) CURRENT_REGS[REG_PS] = (uint32_t) (PS_INTLEVEL(XCHAL_EXCM_LEVEL) | PS_UM | PS_WOE); #endif - /* And make sure that the saved context in the TCB is the - * same as the interrupt return context. - */ - - xtensa_savestate(tcb->xcp.regs); } /* Increment the IRQ lock count so that when the task is @@ -338,15 +377,27 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver) else { - /* Save the return pc and ps. These will be restored by the + /* Save the context registers. These will be restored by the * signal trampoline after the signals have been delivered. * * NOTE: that hi-priority interrupts are not disabled. */ - tcb->xcp.sigdeliver = sigdeliver; - tcb->xcp.saved_pc = tcb->xcp.regs[REG_PC]; - tcb->xcp.saved_ps = tcb->xcp.regs[REG_PS]; + tcb->xcp.sigdeliver = sigdeliver; + tcb->xcp.saved_regs = tcb->xcp.regs; + + /* Duplicate the register context. These will be + * restored by the signal trampoline after the signal has been + * delivered. + */ + + tcb->xcp.regs = (void *) + ((uint32_t)tcb->xcp.regs - + (uint32_t)XCPTCONTEXT_SIZE); + memcpy(tcb->xcp.regs, tcb->xcp.saved_regs, XCPTCONTEXT_SIZE); + + tcb->xcp.regs[REG_A1] = (uint32_t)tcb->xcp.regs + + (uint32_t)XCPTCONTEXT_SIZE; /* Increment the IRQ lock count so that when the task is restarted, * it will hold the IRQ spinlock. diff --git a/arch/xtensa/src/common/xtensa_sigdeliver.c b/arch/xtensa/src/common/xtensa_sigdeliver.c index b07f4fd4b2bc8..9bc8013c30dfe 100644 --- a/arch/xtensa/src/common/xtensa_sigdeliver.c +++ b/arch/xtensa/src/common/xtensa_sigdeliver.c @@ -54,7 +54,7 @@ void xtensa_sig_deliver(void) { struct tcb_s *rtcb = this_task(); - uint32_t regs[XCPTCONTEXT_REGS]; + uint32_t *regs = rtcb->xcp.saved_regs; #ifdef CONFIG_SMP /* In the SMP case, we must terminate the critical section while the signal @@ -71,10 +71,6 @@ void xtensa_sig_deliver(void) rtcb, rtcb->xcp.sigdeliver, rtcb->sigpendactionq.head); DEBUGASSERT(rtcb->xcp.sigdeliver != NULL); - /* Save the return state on the stack. */ - - xtensa_copystate(regs, rtcb->xcp.regs); - #ifdef CONFIG_SMP /* In the SMP case, up_schedule_sigaction(0) will have incremented * 'irqcount' in order to force us into a critical section. Save the @@ -141,8 +137,6 @@ void xtensa_sig_deliver(void) * could be modified by a hostile program. */ - regs[REG_PC] = rtcb->xcp.saved_pc; - regs[REG_PS] = rtcb->xcp.saved_ps; rtcb->xcp.sigdeliver = NULL; /* Allows next handler to be scheduled */ /* Issue: @@ -184,5 +178,5 @@ void xtensa_sig_deliver(void) */ board_autoled_off(LED_SIGNAL); - xtensa_context_restore(regs); + xtensa_context_restore(®s); } diff --git a/arch/xtensa/src/common/xtensa_swi.h b/arch/xtensa/src/common/xtensa_swi.h deleted file mode 100644 index be73139253d60..0000000000000 --- a/arch/xtensa/src/common/xtensa_swi.h +++ /dev/null @@ -1,72 +0,0 @@ -/**************************************************************************** - * arch/xtensa/src/common/xtensa_swi.h - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. The - * ASF licenses this file to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance with the - * License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - ****************************************************************************/ - -#ifndef __ARCH_XTENSA_SRC_COMMON_XTENSA_SWI_H -#define __ARCH_XTENSA_SRC_COMMON_XTENSA_SWI_H - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include -#include - -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -/* Select software interrupt number for context-switch. - * The SW interrupt level must be greater than XCHAL_SYSCALL_LEVEL - * and less than XCHAL_EXCM_LEVEL. - * So that we can generate an interrupt when up_irq_save is called. - * and not generate interrupt when up_irq_disable is called. - * Return an error if no suitable software interrupt was found. - */ - -#ifndef XTENSA_SWINT -# ifdef XCHAL_SOFTWARE2_INTERRUPT -# if XCHAL_INT_LEVEL(XCHAL_SOFTWARE2_INTERRUPT) > XCHAL_SYSCALL_LEVEL && \ - XCHAL_INT_LEVEL(XCHAL_SOFTWARE2_INTERRUPT) <= XCHAL_EXCM_LEVEL -# undef XTENSA_SWINT -# define XTENSA_SWINT XCHAL_SOFTWARE2_INTERRUPT -# endif -# endif -# ifdef XCHAL_SOFTWARE1_INTERRUPT -# if XCHAL_INT_LEVEL(XCHAL_SOFTWARE1_INTERRUPT) > XCHAL_SYSCALL_LEVEL && \ - XCHAL_INT_LEVEL(XCHAL_SOFTWARE1_INTERRUPT) <= XCHAL_EXCM_LEVEL -# undef XTENSA_SWINT -# define XTENSA_SWINT XCHAL_SOFTWARE1_INTERRUPT -# endif -# endif -# ifdef XCHAL_SOFTWARE0_INTERRUPT -# if XCHAL_INT_LEVEL(XCHAL_SOFTWARE0_INTERRUPT) > XCHAL_SYSCALL_LEVEL && \ - XCHAL_INT_LEVEL(XCHAL_SOFTWARE0_INTERRUPT) <= XCHAL_EXCM_LEVEL -# undef XTENSA_SWINT -# define XTENSA_SWINT XCHAL_SOFTWARE0_INTERRUPT -# endif -# endif -#endif -#ifndef XTENSA_SWINT -# error "There is no suitable sw interrupt in this Xtensa configuration." -#endif - -#define XCHAL_SWINT_CALL (1 << XTENSA_SWINT) - -#endif /* __ARCH_XTENSA_SRC_COMMON_XTENSA_SWI_H */ diff --git a/arch/xtensa/src/common/xtensa_swint.c b/arch/xtensa/src/common/xtensa_swint.c index 42c0ef6aa7855..d9a69927d774a 100644 --- a/arch/xtensa/src/common/xtensa_swint.c +++ b/arch/xtensa/src/common/xtensa_swint.c @@ -103,7 +103,7 @@ int xtensa_swint(int irq, void *context, void *arg) case SYS_save_context: { DEBUGASSERT(regs[REG_A3] != 0); - memcpy((uint32_t *)regs[REG_A3], regs, (4 * XCPTCONTEXT_REGS)); + memcpy(*(uint32_t **)regs[REG_A3], regs, XCPTCONTEXT_SIZE); #if XCHAL_CP_NUM > 0 cpstate = (uintptr_t)regs[REG_A3] + cpstate_off; xtensa_coproc_savestate((struct xtensa_cpstate_s *)cpstate); @@ -132,7 +132,7 @@ int xtensa_swint(int irq, void *context, void *arg) case SYS_restore_context: { DEBUGASSERT(regs[REG_A3] != 0); - CURRENT_REGS = (uint32_t *)regs[REG_A3]; + CURRENT_REGS = *(uint32_t **)regs[REG_A3]; #if XCHAL_CP_NUM > 0 cpstate = (uintptr_t)regs[REG_A3] + cpstate_off; xtensa_coproc_restorestate((struct xtensa_cpstate_s *)cpstate); @@ -161,8 +161,7 @@ int xtensa_swint(int irq, void *context, void *arg) case SYS_switch_context: { DEBUGASSERT(regs[REG_A3] != 0 && regs[REG_A4] != 0); - - memcpy((uint32_t *)regs[REG_A3], regs, (4 * XCPTCONTEXT_REGS)); + *(uint32_t **)regs[REG_A3] = regs; CURRENT_REGS = (uint32_t *)regs[REG_A4]; } diff --git a/arch/xtensa/src/common/xtensa_tcbinfo.c b/arch/xtensa/src/common/xtensa_tcbinfo.c new file mode 100644 index 0000000000000..836930d5a3656 --- /dev/null +++ b/arch/xtensa/src/common/xtensa_tcbinfo.c @@ -0,0 +1,77 @@ +/**************************************************************************** + * arch/xtensa/src/common/xtensa_tcbinfo.c + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include +#include + +/**************************************************************************** + * Private Data + ****************************************************************************/ + +static const uint16_t g_reg_offs[] = +{ + TCB_REG_OFF(REG_PC), + TCB_REG_OFF(REG_PS), + TCB_REG_OFF(REG_A0), + TCB_REG_OFF(REG_A1), + TCB_REG_OFF(REG_A2), + TCB_REG_OFF(REG_A3), + TCB_REG_OFF(REG_A4), + TCB_REG_OFF(REG_A5), + TCB_REG_OFF(REG_A6), + TCB_REG_OFF(REG_A7), + TCB_REG_OFF(REG_A8), + TCB_REG_OFF(REG_A9), + TCB_REG_OFF(REG_A10), + TCB_REG_OFF(REG_A11), + TCB_REG_OFF(REG_A12), + TCB_REG_OFF(REG_A13), + TCB_REG_OFF(REG_A14), + TCB_REG_OFF(REG_A15), +}; + +/**************************************************************************** + * Public Data + ****************************************************************************/ + +const struct tcbinfo_s g_tcbinfo = +{ + .pid_off = TCB_PID_OFF, + .state_off = TCB_STATE_OFF, + .pri_off = TCB_PRI_OFF, + .name_off = TCB_NAME_OFF, + .regs_off = TCB_REGS_OFF, + .basic_num = XCPTCONTEXT_REGS, + .total_num = XCPTCONTEXT_REGS, + { + .p = g_reg_offs, + }, +}; + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + diff --git a/arch/xtensa/src/common/xtensa_unblocktask.c b/arch/xtensa/src/common/xtensa_unblocktask.c index 4d975fbbd1b56..c1bcf7afb5deb 100644 --- a/arch/xtensa/src/common/xtensa_unblocktask.c +++ b/arch/xtensa/src/common/xtensa_unblocktask.c @@ -125,7 +125,7 @@ void up_unblock_task(struct tcb_s *tcb) * ready to run list. */ - xtensa_switchcontext(rtcb->xcp.regs, nexttcb->xcp.regs); + xtensa_switchcontext(&rtcb->xcp.regs, nexttcb->xcp.regs); /* xtensa_switchcontext forces a context switch to the task at the * head of the ready-to-run list. It does not 'return' in the diff --git a/arch/xtensa/src/common/xtensa_user_handler.S b/arch/xtensa/src/common/xtensa_user_handler.S index 4cb256a066a16..10b787d6e49b2 100644 --- a/arch/xtensa/src/common/xtensa_user_handler.S +++ b/arch/xtensa/src/common/xtensa_user_handler.S @@ -64,72 +64,9 @@ #include #include -#include "chip.h" - -/**************************************************************************** - * Assembly Language Macros - ****************************************************************************/ - -/**************************************************************************** - * Name: setintstack - * - * Description: - * Set the current stack pointer to the "top" the interrupt stack. - * Single CPU case. - * Must be provided by MCU-specific logic in the SMP case. - * - ****************************************************************************/ - -#if !defined(CONFIG_SMP) && CONFIG_ARCH_INTERRUPTSTACK > 15 - .macro setintstack tmp1 tmp2 - movi a1, g_intstacktop - .endm -#endif - -/**************************************************************************** - * Macro: ps_setup - * - * Description: - * Set up PS for C, enable interrupts above this level and clear EXCM. - * - * Entry Conditions: - * level - interrupt level - * tmp - scratch register - * - * Side Effects: - * PS and scratch register modified - * - * Assumptions: - * - PS.EXCM = 1, C calling disabled - * - ****************************************************************************/ - - .macro ps_setup level tmp - -#if 0 /* Nested interrupts no yet supported */ -# ifdef __XTENSA_CALL0_ABI__ - /* Disable interrupts at level and below */ - - movi \tmp, PS_INTLEVEL(\level) | PS_UM -# else - movi \tmp, PS_INTLEVEL(\level) | PS_UM | PS_WOE -# endif -#else -# ifdef __XTENSA_CALL0_ABI__ - /* Disable all low- and medium-priority interrupts. Nested are not yet - * supported. - */ - - movi \tmp, PS_INTLEVEL(XCHAL_EXCM_LEVEL) | PS_UM -# else - movi \tmp, PS_INTLEVEL(XCHAL_EXCM_LEVEL) | PS_UM | PS_WOE -# endif -#endif - - wsr \tmp, PS - rsync +#include "xtensa_macros.S" - .endm +#include "chip.h" /**************************************************************************** * Waypoints @@ -245,29 +182,23 @@ _xtensa_user_handler: /* Set up PS for C, re-enable hi-pri interrupts, and clear EXCM. */ -#ifdef __XTENSA_CALL0_ABI__ - movi a0, PS_INTLEVEL(XCHAL_EXCM_LEVEL) | PS_UM -#else - movi a0, PS_INTLEVEL(XCHAL_EXCM_LEVEL) | PS_UM | PS_WOE -#endif - wsr a0, PS + ps_setup 1 a0 - /* Create pseudo base save area. At this point, sp is still pointing to the - * allocated and filled exception stack frame. - */ + /* Create pseudo base save area. At this point, a12 points to the + * allocated and filled exception stack frame (old value of SP in case of + * an interrupt stack). + */ #ifdef CONFIG_XTENSA_INTBACKTRACE - l32i a3, sp, (4 * REG_A0) /* Copy pre-exception a0 (return address) */ - s32e a3, sp, -16 - l32i a3, sp, (4 * REG_A1) /* Copy pre-exception a1 (stack pointer) */ - s32e a3, sp, -12 - rsr a0, EPC_1 /* return address for debug backtrace */ - movi a4, 0xc0000000 /* constant with top 2 bits set (call size) */ - rsync /* wait for WSR.PS to complete */ - or a0, a0, a4 /* set top 2 bits */ - addx2 a0, a4, a0 /* clear top bit -- thus simulating call4 size */ -#else - rsync /* wait for WSR.PS to complete */ + l32i a3, a12, (4 * REG_A0) /* Copy pre-exception a0 (return address) */ + s32e a3, sp, -16 + l32i a3, a12, (4 * REG_A1) /* Copy pre-exception a1 (stack pointer) */ + s32e a3, sp, -12 + + rsr a0, EPC_1 /* return address for debug backtrace */ + movi a4, 0xc0000000 /* constant with top 2 bits set (call size) */ + or a0, a0, a4 /* set top 2 bits */ + addx2 a0, a4, a0 /* clear top bit -- thus simulating call4 size */ #endif /* Call xtensa_user, passing both the EXCCAUSE and a pointer to the diff --git a/arch/xtensa/src/esp32/Kconfig b/arch/xtensa/src/esp32/Kconfig index 4c0d3b12f6bdb..b6032cae9fb45 100644 --- a/arch/xtensa/src/esp32/Kconfig +++ b/arch/xtensa/src/esp32/Kconfig @@ -309,6 +309,11 @@ config ESP32_I2C bool default n +config ESP32_TWAI + bool + default n + select CAN + config ESP32_I2S0 bool "I2S 0" default n @@ -527,6 +532,11 @@ config ESP32_I2C1 default n select ESP32_I2C +config ESP32_TWAI0 + bool "TWAI (CAN) 0" + default n + select ESP32_TWAI + config ESP32_AES_ACCELERATOR bool "AES Accelerator" default n @@ -830,6 +840,58 @@ config ESP32_I2CTIMEOMS endmenu # I2C configuration +menu "TWAI driver options" + depends on ESP32_TWAI + +if ESP32_TWAI0 + +config ESP32_TWAI0_TXPIN + int "TWAI0 TX Pin" + default 21 + +config ESP32_TWAI0_RXPIN + int "TWAI0 RX Pin" + default 22 + +config ESP32_TWAI0_BITRATE + int "TWAI0 bitrate" + default 1000000 + ---help--- + TWAI0 bit rate. Required if ESP32_TWAI0 is defined. + +config ESP32_TWAI0_SAMPLEP + int "TWAI0 sample point" + default 80 + ---help--- + TWAI0 sample point location as a percent value. Required + if ESP32_TWAI0 is defined. + +config ESP32_TWAI0_SJW + int "TWAI0 synchronization jump width" + default 3 + ---help--- + SJW limits the number of Time Quanta corrections during bit + Resynchronization. Default: 3 + +config ESP32_TWAI0_SAM + bool "TWAI0 sampling" + default n + ---help--- + The bus is sampled 3 times (recommended for low to medium speed buses + to spikes on the bus-line). + +endif # ESP32_TWAI0 + +config ESP32_TWAI_REGDEBUG + bool "TWAI register level debug" + depends on DEBUG_CAN_INFO + default n + ---help--- + Output detailed register-level TWAI debug information. Requires also + CONFIG_DEBUG_CAN_INFO. + +endmenu #ESP32_TWAI + menu "SPI configuration" depends on ESP32_SPI diff --git a/arch/xtensa/src/esp32/Make.defs b/arch/xtensa/src/esp32/Make.defs index 5e0b238a55ecc..1161e8bfe4801 100644 --- a/arch/xtensa/src/esp32/Make.defs +++ b/arch/xtensa/src/esp32/Make.defs @@ -31,7 +31,7 @@ HEAD_CSRC = esp32_start.c esp32_wdt.c CMN_ASRCS = xtensa_context.S xtensa_coproc.S xtensa_cpuint.S xtensa_panic.S CMN_ASRCS += xtensa_sigtramp.S -CMN_CSRCS = xtensa_assert.c xtensa_blocktask.c xtensa_copystate.c +CMN_CSRCS = xtensa_assert.c xtensa_blocktask.c CMN_CSRCS += xtensa_cpenable.c xtensa_createstack.c xtensa_exit.c CMN_CSRCS += xtensa_initialize.c xtensa_initialstate.c xtensa_interruptcontext.c CMN_CSRCS += xtensa_irqdispatch.c xtensa_lowputs.c xtensa_mdelay.c @@ -39,10 +39,15 @@ CMN_CSRCS += xtensa_modifyreg8.c xtensa_modifyreg16.c xtensa_modifyreg32.c CMN_CSRCS += xtensa_puts.c xtensa_releasepending.c xtensa_releasestack.c CMN_CSRCS += xtensa_reprioritizertr.c xtensa_schedsigaction.c CMN_CSRCS += xtensa_sigdeliver.c xtensa_stackframe.c xtensa_udelay.c -CMN_CSRCS += xtensa_unblocktask.c xtensa_usestack.c xtensa_swint.c xtensa_switchcontext.c +CMN_CSRCS += xtensa_unblocktask.c xtensa_usestack.c xtensa_swint.c +CMN_CSRCS += xtensa_saveusercontext.c # Configuration-dependent common XTENSA files +ifeq ($(CONFIG_DEBUG_TCBINFO),y) + CMN_CSRCS += xtensa_tcbinfo.c +endif + ifeq ($(CONFIG_DEBUG_ALERT),y) CMN_CSRCS += xtensa_dumpstate.c endif @@ -103,6 +108,10 @@ ifeq ($(CONFIG_ESP32_I2C),y) CHIP_CSRCS += esp32_i2c.c endif +ifeq ($(CONFIG_ESP32_TWAI),y) +CHIP_CSRCS += esp32_twai.c +endif + ifeq ($(CONFIG_ESP32_SPI),y) CHIP_CSRCS += esp32_spi.c ifeq ($(CONFIG_SPI_SLAVE),y) @@ -245,11 +254,6 @@ EXTRA_LIBS += -lbtdm_app endif endif -# Due to some Wi-Fi related libraries, the option is need to avoid linking too much -# unused functions. - -LDFLAGS += --gc-sections - # Wireless interfaces. CHIP_CSRCS += esp32_wireless.c diff --git a/arch/xtensa/src/esp32/esp32_cpuidlestack.c b/arch/xtensa/src/esp32/esp32_cpuidlestack.c index 7a79b40fd8528..164f0a020445a 100644 --- a/arch/xtensa/src/esp32/esp32_cpuidlestack.c +++ b/arch/xtensa/src/esp32/esp32_cpuidlestack.c @@ -34,11 +34,6 @@ * Public Data ****************************************************************************/ -/* Address of the CPU0 IDLE thread */ - -uint32_t g_cpu1_idlestack[CPU1_IDLETHREAD_STACKWORDS] - aligned_data(16) locate_data(".noinit"); - /**************************************************************************** * Public Functions ****************************************************************************/ @@ -81,24 +76,15 @@ uint32_t g_cpu1_idlestack[CPU1_IDLETHREAD_STACKWORDS] * being created for. * - tcb: The TCB of new CPU IDLE task * - stack_size: The requested stack size for the IDLE task. At least - * this much must be allocated. This should be - * CONFIG_IDLETHREAD_STACKSIZE. + * this much must be allocated. * ****************************************************************************/ int up_cpu_idlestack(int cpu, struct tcb_s *tcb, size_t stack_size) { - /* XTENSA uses a push-down stack: the stack grows toward lower* addresses - * in memory. The stack pointer register points to the lowest, valid - * working address (the "top" of the stack). Items on the stack are - * referenced as positive word offsets from sp. - */ - - /* Save information about pre-allocated IDLE thread stack */ - - tcb->stack_alloc_ptr = g_cpu1_idlestack; - tcb->adj_stack_size = CPU1_IDLETHREAD_STACKSIZE; - tcb->stack_base_ptr = tcb->stack_alloc_ptr; +#if CONFIG_SMP_NCPUS > 1 + up_create_stack(tcb, stack_size, TCB_FLAG_TTYPE_KERNEL); +#endif #if XCHAL_CP_NUM > 0 /* REVISIT: Does it make since to have co-processors enabled on the IDLE diff --git a/arch/xtensa/src/esp32/esp32_cpustart.c b/arch/xtensa/src/esp32/esp32_cpustart.c index 9c2ca772e1ad1..bc54defc0863f 100644 --- a/arch/xtensa/src/esp32/esp32_cpustart.c +++ b/arch/xtensa/src/esp32/esp32_cpustart.c @@ -129,31 +129,14 @@ void IRAM_ATTR xtensa_appcpu_start(void) struct tcb_s *tcb = this_task(); register uint32_t sp; -#ifdef CONFIG_STACK_COLORATION - { - register uint32_t *ptr; - register int i; - - /* If stack debug is enabled, then fill the stack with a recognizable - * value that we can use later to test for high water marks. - */ - - for (i = 0, ptr = (uint32_t *)tcb->stack_alloc_ptr; - i < tcb->adj_stack_size; - i += sizeof(uint32_t)) - { - *ptr++ = STACK_COLOR; - } - } -#endif - /* Move to the stack assigned to us by up_smp_start immediately. Although * we were give a stack pointer at start-up, we don't know where that stack * pointer is positioned respect to our memory map. The only safe option * is to switch to a well-known IDLE thread stack. */ - sp = (uint32_t)tcb->stack_base_ptr + tcb->adj_stack_size; + sp = (uint32_t)tcb->stack_base_ptr + tcb->adj_stack_size - + XCPTCONTEXT_SIZE; __asm__ __volatile__("mov sp, %0\n" : : "r"(sp)); sinfo("CPU%d Started\n", up_cpu_index()); @@ -226,7 +209,7 @@ void IRAM_ATTR xtensa_appcpu_start(void) * be the CPUs NULL task. */ - xtensa_context_restore(tcb->xcp.regs); + xtensa_context_restore(&tcb->xcp.regs); } /**************************************************************************** diff --git a/arch/xtensa/src/esp32/esp32_himem.c b/arch/xtensa/src/esp32/esp32_himem.c index 92501240d8613..c25eeadb9d864 100644 --- a/arch/xtensa/src/esp32/esp32_himem.c +++ b/arch/xtensa/src/esp32/esp32_himem.c @@ -103,8 +103,6 @@ /* Character driver methods */ -static int himem_open(struct file *filep); -static int himem_close(struct file *filep); static ssize_t himem_read(struct file *filep, char *buffer, size_t buflen); static ssize_t himem_write(struct file *filep, const char *buffer, @@ -151,8 +149,8 @@ irqstate_t spinlock_flags; static const struct file_operations g_himemfops = { - himem_open, /* open */ - himem_close, /* close */ + NULL, /* open */ + NULL, /* close */ himem_read, /* read */ himem_write, /* write */ NULL, /* seek */ @@ -647,32 +645,6 @@ int esp_himem_unmap(esp_himem_rangehandle_t range, void *ptr, return OK; } -/**************************************************************************** - * Name: himem_open - * - * Description: - * This function is called whenever the LM-75 device is opened. - * - ****************************************************************************/ - -static int himem_open(struct file *filep) -{ - return OK; -} - -/**************************************************************************** - * Name: himem_close - * - * Description: - * This routine is called when the LM-75 device is closed. - * - ****************************************************************************/ - -static int himem_close(struct file *filep) -{ - return OK; -} - /**************************************************************************** * Name: himem_read ****************************************************************************/ @@ -699,7 +671,7 @@ static ssize_t himem_write(struct file *filep, const char *buffer, static int himem_ioctl(struct file *filep, int cmd, unsigned long arg) { - int ret = OK; + int ret = OK; switch (cmd) { diff --git a/arch/xtensa/src/esp32/esp32_oneshot_lowerhalf.c b/arch/xtensa/src/esp32/esp32_oneshot_lowerhalf.c index 8cb8f0a7d2ebb..8a73d4607a146 100644 --- a/arch/xtensa/src/esp32/esp32_oneshot_lowerhalf.c +++ b/arch/xtensa/src/esp32/esp32_oneshot_lowerhalf.c @@ -118,7 +118,7 @@ static void esp32_oneshot_lh_handler(void *arg) struct esp32_oneshot_lowerhalf_s *priv = (struct esp32_oneshot_lowerhalf_s *)arg; oneshot_callback_t callback; - FAR void *cb_arg; + void *cb_arg; DEBUGASSERT(priv != NULL); DEBUGASSERT(priv->callback != NULL); @@ -342,7 +342,7 @@ static int esp32_lh_current(struct oneshot_lowerhalf_s *lower, ****************************************************************************/ struct oneshot_lowerhalf_s *oneshot_initialize(int chan, - uint16_t resolution) + uint16_t resolution) { struct esp32_oneshot_lowerhalf_s *priv; int ret; diff --git a/arch/xtensa/src/esp32/esp32_pminitialize.c b/arch/xtensa/src/esp32/esp32_pminitialize.c index 7b04937e47970..ab83241c1f492 100644 --- a/arch/xtensa/src/esp32/esp32_pminitialize.c +++ b/arch/xtensa/src/esp32/esp32_pminitialize.c @@ -23,6 +23,7 @@ ****************************************************************************/ #include +#include #include "xtensa.h" #include "esp32_pm.h" @@ -43,6 +44,10 @@ void xtensa_pminitialize(void) { + /* Initialize the NuttX power management subsystem proper */ + + pm_initialize(); + /* Initialize RTC parameters */ esp32_pminit(); diff --git a/arch/xtensa/src/esp32/esp32_smp.h b/arch/xtensa/src/esp32/esp32_smp.h index 3b1d142e22ca1..b8d560be14802 100644 --- a/arch/xtensa/src/esp32/esp32_smp.h +++ b/arch/xtensa/src/esp32/esp32_smp.h @@ -33,25 +33,10 @@ * Pre-procesor Definitions ****************************************************************************/ -/* An IDLE thread stack size for CPU0 must be defined */ - -#if !defined(CONFIG_IDLETHREAD_STACKSIZE) -# error CONFIG_IDLETHREAD_STACKSIZE is not defined -#elif CONFIG_IDLETHREAD_STACKSIZE < 16 -# error CONFIG_IDLETHREAD_STACKSIZE is to small -#endif - -#define CPU1_IDLETHREAD_STACKSIZE ((CONFIG_IDLETHREAD_STACKSIZE + 15) & ~15) -#define CPU1_IDLETHREAD_STACKWORDS (CPU1_IDLETHREAD_STACKSIZE >> 2) - /**************************************************************************** * Public Data ****************************************************************************/ -/* This is the CPU1 IDLE stack */ - -extern uint32_t g_cpu1_idlestack[CPU1_IDLETHREAD_STACKWORDS]; - /**************************************************************************** * Public Function Prototypes ****************************************************************************/ diff --git a/arch/xtensa/src/esp32/esp32_twai.c b/arch/xtensa/src/esp32/esp32_twai.c new file mode 100644 index 0000000000000..ac6c5905db7e4 --- /dev/null +++ b/arch/xtensa/src/esp32/esp32_twai.c @@ -0,0 +1,1257 @@ +/**************************************************************************** + * arch/xtensa/src/esp32/esp32_twai.c + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include "xtensa.h" + +#include "esp32_gpio.h" +#include "esp32_twai.h" +#include "esp32_irq.h" +#include "esp32_clockconfig.h" + +#include "hardware/esp32_dport.h" +#include "hardware/esp32_gpio_sigmap.h" + +#if defined(CONFIG_ESP32_TWAI) + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/* Configuration ************************************************************/ + +/* Default values written to various registers on initialization */ + +#define TWAI_INIT_TEC 0 +#define TWAI_INIT_REC 0 +#define TWAI_INIT_EWL 96 + +/* Exclude data overrun (bit[3]) and brp_div (bit[4]) */ + +#define TWAI_DEFAULT_INTERRUPTS 0xe7 + +#define TWAI_ACCEPTANCE_CODE 0x0 /* 32-bit address to match */ +#define TWAI_ACCEPTANCE_MASK 0xffffffff /* 32-bit address mask */ + +#ifdef CONFIG_ESP32_TWAI0 + +/* A TWAI bit rate must be provided */ + +# ifndef CONFIG_ESP32_TWAI0_BITRATE +# error "CONFIG_ESP32_TWAI0_BITRATE is not defined" +# endif + +/* If no sample point is provided, use a sample point of 80 */ + +# ifndef CONFIG_ESP32_TWAI0_SAMPLEP +# define CONFIG_ESP32_TWAI0_SAMPLEP 80 +# endif +#endif + +/* If no Synchronization Jump Width is provided, use a SJW of 3 */ + +#ifndef CONFIG_ESP32_TWAI0_SJW +# define CONFIG_ESP32_TWAI0_SJW 3 +#endif + +/* Debug ********************************************************************/ + +/* Non-standard debug that may be enabled just for testing TWAI */ + +#ifndef CONFIG_DEBUG_CAN_INFO +# undef CONFIG_ESP32_TWAI_REGDEBUG +#endif + +/**************************************************************************** + * Private Types + ****************************************************************************/ + +/* CAN hardware-dependent bit-timing constant + * Used for calculating and checking bit-timing parameters + */ + +struct can_bittiming_const +{ + uint32_t tseg1_min; /* Time segment 1 */ + uint32_t tseg1_max; + uint32_t tseg2_min; /* Time segment 2 */ + uint32_t tseg2_max; + uint32_t sjw_min; /* Synchronization jump width */ + uint32_t sjw_max; + uint32_t brp_min; /* Bit-rate prescaler */ + uint32_t brp_max; + uint32_t brp_inc; +}; + +struct twai_dev_s +{ + /* Device configuration */ + + const struct can_bittiming_const *bittiming_const; + uint8_t port; /* TWAI port number */ + uint8_t periph; /* Peripheral ID */ + uint8_t irq; /* IRQ associated with this TWAI */ + uint8_t cpu; /* CPU ID */ + uint8_t cpuint; /* CPU interrupt assigned to this TWAI */ + uint32_t bitrate; /* Configured bit rate */ + uint32_t samplep; /* Configured sample point */ + uint32_t sjw; /* Synchronization jump width */ + uint32_t base; /* TWAI register base address */ +}; + +/**************************************************************************** + * Private Function Prototypes + ****************************************************************************/ + +/* TWAI Register access */ + +#ifdef CONFIG_ESP32_TWAI_REGDEBUG +static void twai_printreg(uint32_t addr, uint32_t value); +#endif + +static uint32_t twai_getreg(uint32_t addr); +static void twai_putreg(uint32_t addr, uint32_t value); + +/* TWAI methods */ + +static void esp32twai_reset(struct can_dev_s *dev); +static int esp32twai_setup(struct can_dev_s *dev); +static void esp32twai_shutdown(struct can_dev_s *dev); +static void esp32twai_rxint(struct can_dev_s *dev, bool enable); +static void esp32twai_txint(struct can_dev_s *dev, bool enable); +static int esp32twai_ioctl(struct can_dev_s *dev, int cmd, + unsigned long arg); +static int esp32twai_remoterequest(struct can_dev_s *dev, + uint16_t id); +static int esp32twai_send(struct can_dev_s *dev, + struct can_msg_s *msg); +static bool esp32twai_txready(struct can_dev_s *dev); +static bool esp32twai_txempty(struct can_dev_s *dev); + +/* TWAI interrupts */ + +static int esp32twai_interrupt(int irq, void *context, void *arg); + +/* TWAI acceptance filter */ + +static void esp32twai_set_acc_filter(uint32_t code, uint32_t mask, + bool single_filter); + +/* TWAI bit-timing initialization */ + +static int twai_baud_rate(struct twai_dev_s *priv, int rate, int clock, + int sjw, int sampl_pt, int flags); + +/**************************************************************************** + * Private Data + ****************************************************************************/ + +static const struct can_bittiming_const esp32_twai_bittiming_const = +{ + .tseg1_min = 1, + .tseg1_max = 16, + .tseg2_min = 1, + .tseg2_max = 8, + .sjw_min = 1, + .sjw_max = 3, + .brp_min = 1, + .brp_max = 64, + .brp_inc = 1, +}; + +static const struct can_ops_s g_twaiops = +{ + .co_reset = esp32twai_reset, + .co_setup = esp32twai_setup, + .co_shutdown = esp32twai_shutdown, + .co_rxint = esp32twai_rxint, + .co_txint = esp32twai_txint, + .co_ioctl = esp32twai_ioctl, + .co_remoterequest = esp32twai_remoterequest, + .co_send = esp32twai_send, + .co_txready = esp32twai_txready, + .co_txempty = esp32twai_txempty, +}; + +#ifdef CONFIG_ESP32_TWAI0 +static struct twai_dev_s g_twai0priv = +{ + .bittiming_const = &esp32_twai_bittiming_const, + .port = 0, + .periph = ESP32_PERIPH_TWAI, + .irq = ESP32_IRQ_TWAI, + .cpuint = -ENOMEM, + .bitrate = CONFIG_ESP32_TWAI0_BITRATE, + .samplep = CONFIG_ESP32_TWAI0_SAMPLEP, + .sjw = CONFIG_ESP32_TWAI0_SJW, + .base = DR_REG_TWAI_BASE, +}; + +static struct can_dev_s g_twai0dev = +{ + .cd_ops = &g_twaiops, + .cd_priv = &g_twai0priv, +}; +#endif + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: twai_printreg + * + * Description: + * Print the value read from a register. + * + * Input Parameters: + * addr - The register address + * value - The register value + * + * Returned Value: + * None + * + ****************************************************************************/ + +#ifdef CONFIG_ESP32_TWAI_REGDEBUG +static void twai_printreg(uint32_t addr, uint32_t value) +{ + static uint32_t prevaddr = 0; + static uint32_t preval = 0; + static uint32_t count = 0; + + /* Is this the same value that we read from the same register last time? + * Are we polling the register? If so, suppress some of the output. + */ + + if (addr == prevaddr && value == preval) + { + if (count == 0xffffffff || ++count > 3) + { + if (count == 4) + { + caninfo("...\n"); + } + + return; + } + } + + /* No this is a new address or value */ + + else + { + /* Did we print "..." for the previous value? */ + + if (count > 3) + { + /* Yes.. then show how many times the value repeated */ + + caninfo("[repeats %d more times]\n", count - 3); + } + + /* Save the new address, value, and count */ + + prevaddr = addr; + preval = value; + count = 1; + } + + /* Show the register value read */ + + caninfo("%08x->%08x\n", addr, value); +} +#endif + +/**************************************************************************** + * Name: twai_getreg + * + * Description: + * Read the value of an TWAI register. + * + * Input Parameters: + * addr - The address to the register to read + * + * Returned Value: + * + ****************************************************************************/ + +#ifdef CONFIG_ESP32_TWAI_REGDEBUG +static uint32_t twai_getreg(uint32_t addr) +{ + uint32_t value; + + /* Read the value from the register */ + + value = getreg32(addr); + twai_printreg(addr, value); + return value; +} +#else +static uint32_t twai_getreg(uint32_t addr) +{ + return getreg32(addr); +} +#endif + +/**************************************************************************** + * Name: twai_putreg + * + * Description: + * Set the value of an TWAI register. + * + * Input Parameters: + * addr - The address to the register to write + * value - The value to write to the register + * + * Returned Value: + * None + * + ****************************************************************************/ + +#ifdef CONFIG_ESP32_TWAI_REGDEBUG +static void twai_putreg(uint32_t addr, uint32_t value) +{ + /* Show the register value being written */ + + caninfo("%08x<-%08x\n", addr, value); + + /* Write the value */ + + putreg32(value, addr); +} +#else +static void twai_putreg(uint32_t addr, uint32_t value) +{ + putreg32(value, addr); +} +#endif + +/**************************************************************************** + * Name: esp32twai_reset + * + * Description: + * Reset the TWAI device. Called early to initialize the hardware. This + * function is called, before esp32_twai_setup() and on error conditions. + * + * Input Parameters: + * dev - An instance of the "upper half" CAN driver state structure. + * + * Returned Value: + * None + * + ****************************************************************************/ + +static void esp32twai_reset(struct can_dev_s *dev) +{ + struct twai_dev_s *priv = (struct twai_dev_s *)dev->cd_priv; + irqstate_t flags; + int ret; + + caninfo("TWAI%" PRIu8 "\n", priv->port); + + flags = enter_critical_section(); + + /* Disable the TWAI and stop ongoing transmissions */ + + uint32_t mode_value = TWAI_RESET_MODE_M | TWAI_LISTEN_ONLY_MODE_M; + twai_putreg(TWAI_MODE_REG, mode_value); /* Enter Reset Mode */ + + twai_putreg(TWAI_INT_ENA_REG, 0); /* Disable interrupts */ + twai_getreg(TWAI_STATUS_REG); /* Clear status bits */ + + twai_putreg(TWAI_TX_ERR_CNT_REG, TWAI_INIT_TEC); /* TEC */ + twai_putreg(TWAI_RX_ERR_CNT_REG, TWAI_INIT_REC); /* REC */ + twai_putreg(TWAI_ERR_WARNING_LIMIT_REG, TWAI_INIT_EWL); /* EWL */ + + esp32twai_set_acc_filter(TWAI_ACCEPTANCE_CODE, + TWAI_ACCEPTANCE_MASK, true); + + /* Set bit timing */ + + ret = twai_baud_rate(priv, priv->bitrate, esp_clk_apb_freq(), + priv->sjw, priv->samplep, 0); + + if (ret != OK) + { + canerr("ERROR: Failed to set bit timing: %d\n", ret); + } + + /* Restart the TWAI */ + +#ifdef CONFIG_CAN_LOOPBACK + twai_putreg(TWAI_MODE_REG, TWAI_SELF_TEST_MODE_M); /* Leave Reset Mode, enter Test Mode */ +#else + twai_putreg(TWAI_MODE_REG, 0); /* Leave Reset Mode */ +#endif + + /* Abort transmission, release RX buffer and clear overrun. + * Command register can only be modified when in Operation Mode. + */ + + twai_putreg(TWAI_CMD_REG, TWAI_ABORT_TX_M | TWAI_RELEASE_BUF_M | + TWAI_CLR_OVERRUN_M); + + leave_critical_section(flags); +} + +/**************************************************************************** + * Name: esp32twai_setup + * + * Description: + * Configure the TWAI. This method is called the first time that the TWAI + * device is opened. This will occur when the port is first opened. + * This setup includes configuring and attaching TWAI interrupts. + * + * Input Parameters: + * dev - An instance of the "upper half" CAN driver state structure. + * + * Returned Value: + * Zero on success; a negated errno on failure + * + ****************************************************************************/ + +static int esp32twai_setup(struct can_dev_s *dev) +{ + struct twai_dev_s *priv = (struct twai_dev_s *)dev->cd_priv; + irqstate_t flags; + int ret = OK; + + caninfo("TWAI%" PRIu8 "\n", priv->port); + + flags = enter_critical_section(); + + twai_putreg(TWAI_INT_ENA_REG, TWAI_DEFAULT_INTERRUPTS); + + twai_getreg(TWAI_INT_RAW_REG); /* clear latched interrupts */ + + if (priv->cpuint != -ENOMEM) + { + /* Disable the provided CPU Interrupt to configure it. */ + + up_disable_irq(priv->cpuint); + } + + priv->cpu = up_cpu_index(); + priv->cpuint = esp32_setup_irq(priv->cpu, priv->periph, + 1, ESP32_CPUINT_LEVEL); + if (priv->cpuint < 0) + { + /* Failed to allocate a CPU interrupt of this type. */ + + ret = priv->cpuint; + leave_critical_section(flags); + + return ret; + } + + ret = irq_attach(priv->irq, esp32twai_interrupt, dev); + if (ret != OK) + { + /* Failed to attach IRQ, so CPU interrupt must be freed. */ + + esp32_teardown_irq(priv->cpu, priv->periph, priv->cpuint); + priv->cpuint = -ENOMEM; + leave_critical_section(flags); + + return ret; + } + + /* Enable the CPU interrupt that is linked to the TWAI device. */ + + up_enable_irq(priv->cpuint); + + leave_critical_section(flags); + + return ret; +} + +/**************************************************************************** + * Name: esp32twai_shutdown + * + * Description: + * Disable the TWAI. This method is called when the TWAI device is closed. + * This method reverses the operation the setup method. + * + * Input Parameters: + * dev - An instance of the "upper half" CAN driver state structure. + * + * Returned Value: + * None + * + ****************************************************************************/ + +static void esp32twai_shutdown(struct can_dev_s *dev) +{ + struct twai_dev_s *priv = (struct twai_dev_s *)dev->cd_priv; + +#ifdef CONFIG_DEBUG_CAN_INFO + caninfo("shutdown TWAI%" PRIu8 "\n", priv->port); +#endif + + if (priv->cpuint != -ENOMEM) + { + /* Disable cpu interrupt */ + + up_disable_irq(priv->cpuint); + + /* Dissociate the IRQ from the ISR */ + + irq_detach(priv->irq); + + /* Free cpu interrupt that is attached to this peripheral */ + + esp32_teardown_irq(priv->cpu, priv->periph, priv->cpuint); + priv->cpuint = -ENOMEM; + } + + return; +} + +/**************************************************************************** + * Name: esp32twai_rxint + * + * Description: + * Call to enable or disable RX interrupts. + * + * Input Parameters: + * dev - An instance of the "upper half" CAN driver state structure. + * enable - Enable or disable receive interrupt. + * + * Returned Value: + * None + * + ****************************************************************************/ + +static void esp32twai_rxint(struct can_dev_s *dev, bool enable) +{ + struct twai_dev_s *priv = (struct twai_dev_s *)dev->cd_priv; + uint32_t regval; + irqstate_t flags; + + caninfo("TWAI%" PRIu8 " enable: %d\n", priv->port, enable); + + /* The INT_ENA register is also modified from the interrupt handler, + * so we have to protect this code section. + */ + + flags = enter_critical_section(); + regval = twai_getreg(TWAI_INT_ENA_REG); + if (enable) + { + regval |= TWAI_RX_INT_ENA_M; + } + else + { + regval &= ~TWAI_RX_INT_ENA_M; + } + + twai_putreg(TWAI_INT_ENA_REG, regval); + leave_critical_section(flags); + return; +} + +/**************************************************************************** + * Name: esp32twai_txint + * + * Description: + * Call to enable or disable TX interrupts. + * + * Input Parameters: + * dev - An instance of the "upper half" CAN driver state structure. + * enable - Enable or disable transmit interrupt. + * + * Returned Value: + * None + * + ****************************************************************************/ + +static void esp32twai_txint(struct can_dev_s *dev, bool enable) +{ + struct twai_dev_s *priv = (struct twai_dev_s *)dev->cd_priv; + uint32_t regval; + irqstate_t flags; + + caninfo("TWAI%" PRIu8 " enable: %d\n", priv->port, enable); + + /* Only disabling of the TX interrupt is supported here. The TX interrupt + * is automatically enabled just before a message is sent in order to avoid + * lost TX interrupts. + */ + + if (!enable) + { + /* TX interrupts are also disabled from the interrupt handler, so we + * have to protect this code section. + */ + + flags = enter_critical_section(); + + /* Disable all TX interrupts */ + + regval = twai_getreg(TWAI_INT_ENA_REG); + regval &= ~(TWAI_TX_INT_ENA_M); + twai_putreg(TWAI_INT_ENA_REG, regval); + leave_critical_section(flags); + } +} + +/**************************************************************************** + * Name: esp32twai_ioctl + * + * Description: + * All ioctl calls will be routed through this method + * + * Input Parameters: + * dev - An instance of the "upper half" CAN driver state structure. + * cmd - A ioctl command. + * arg - A ioctl argument. + * + * Returned Value: + * Zero on success; a negated errno on failure + * + ****************************************************************************/ + +static int esp32twai_ioctl(struct can_dev_s *dev, int cmd, + unsigned long arg) +{ + struct twai_dev_s *priv = (struct twai_dev_s *)dev->cd_priv; + int ret = -ENOTTY; + + caninfo("TWAI%" PRIu8 " cmd=%04x arg=%lu\n", priv->port, cmd, arg); + + /* Handle the command */ + + switch (cmd) + { + /* CANIOC_GET_BITTIMING: + * Description: Return the current bit timing settings + * Argument: A pointer to a write-able instance of struct + * canioc_bittiming_s in which current bit timing + * values will be returned. + * Returned Value: Zero (OK) is returned on success. Otherwise -1 + * (ERROR) is returned with the errno variable set + * to indicate the nature of the error. + * Dependencies: None + */ + + case CANIOC_GET_BITTIMING: + { + struct canioc_bittiming_s *bt = + (struct canioc_bittiming_s *)arg; + uint32_t timing0; + uint32_t timing1; + uint32_t brp; + + DEBUGASSERT(bt != NULL); + + timing0 = twai_getreg(TWAI_BUS_TIMING_0_REG); + timing1 = twai_getreg(TWAI_BUS_TIMING_1_REG); + + brp = ((timing0 & TWAI_BAUD_PRESC_M) + 1) * 2; + bt->bt_sjw = ((timing0 & TWAI_SYNC_JUMP_WIDTH_M) >> + TWAI_SYNC_JUMP_WIDTH_S) + 1; + + bt->bt_tseg1 = ((timing1 & TWAI_TIME_SEG1_M) >> + TWAI_TIME_SEG1_S) + 1; + bt->bt_tseg2 = ((timing1 & TWAI_TIME_SEG2_M) >> + TWAI_TIME_SEG2_S)+ 1; + bt->bt_baud = esp_clk_apb_freq() / + (brp * (bt->bt_tseg1 + bt->bt_tseg2 + 1)); + + ret = OK; + } + break; + + /* Unsupported/unrecognized command */ + + default: + canerr("ERROR: Unrecognized command: %04x\n", cmd); + break; + } + + return ret; +} + +static int esp32twai_remoterequest(struct can_dev_s *dev, uint16_t id) +{ + canwarn("Remote request not implemented\n"); + return -ENOSYS; +} + +/**************************************************************************** + * Name: esp32twai_send + * + * Description: + * Send one TWAI message. + * + * One TWAI-message consists of a maximum of 10 bytes. A message is + * composed of at least the first 2 bytes (when there are no data bytes). + * + * Byte 0: Bits 0-7: Bits 3-10 of the 11-bit TWAI identifier + * Byte 1: Bits 5-7: Bits 0-2 of the 11-bit TWAI identifier + * Bit 4: Remote Transmission Request (RTR) + * Bits 0-3: Data Length Code (DLC) + * Bytes 2-10: TWAI data + * + * Input Parameters: + * dev - An instance of the "upper half" CAN driver state structure. + * msg - A message to send. + * + * Returned Value: + * Zero on success; a negated errno on failure + * + ****************************************************************************/ + +static int esp32twai_send(struct can_dev_s *dev, + struct can_msg_s *msg) +{ + struct twai_dev_s *priv = (struct twai_dev_s *)dev->cd_priv; + uint32_t regval; + uint32_t i; + uint32_t len; + uint32_t id; + uint32_t frame_info; + irqstate_t flags; + int ret = OK; + + caninfo("TWAI%" PRIu8 " ID: %" PRIu32 " DLC: %" PRIu8 "\n", + priv->port, (uint32_t)msg->cm_hdr.ch_id, msg->cm_hdr.ch_dlc); + + len = (uint32_t)msg->cm_hdr.ch_dlc; + if (len > CAN_MAXDATALEN) len = CAN_MAXDATALEN; + + frame_info = len; + + if (msg->cm_hdr.ch_rtr) + { + frame_info |= (1 << 6); + } + + flags = enter_critical_section(); + + /* Make sure that TX interrupts are enabled BEFORE sending the + * message. + * + * NOTE: The INT_ENA is also modified from the interrupt handler, but the + * following is safe because interrupts are disabled here. + */ + + regval = twai_getreg(TWAI_INT_ENA_REG); + regval |= TWAI_TX_INT_ENA_M; + twai_putreg(TWAI_INT_ENA_REG, regval); + + /* Set up the transfer */ + +#ifdef CONFIG_CAN_EXTID + if (msg->cm_hdr.ch_extid) + { + /* The provided ID should be 29 bits */ + + id = (uint32_t)msg->cm_hdr.ch_id; + DEBUGASSERT((id & ~CAN_MAX_EXTMSGID) == 0); + frame_info |= (1 << 7); + twai_putreg(TWAI_DATA_0_REG, frame_info); + + id <<= 3; + twai_putreg(TWAI_DATA_4_REG, id & 0xff); + id >>= 8; + twai_putreg(TWAI_DATA_3_REG, id & 0xff); + id >>= 8; + twai_putreg(TWAI_DATA_2_REG, id & 0xff); + id >>= 8; + twai_putreg(TWAI_DATA_1_REG, id & 0xff); + for (i = 0; i < len; i++) + { + twai_putreg(TWAI_DATA_5_REG + (i * 4), msg->cm_data[i]); + } + } + else +#endif + { + /* The provided ID should be 11 bits */ + + id = (uint32_t)msg->cm_hdr.ch_id; + DEBUGASSERT((id & ~CAN_MAX_STDMSGID) == 0); + twai_putreg(TWAI_DATA_0_REG, frame_info); + id <<= 5; + twai_putreg(TWAI_DATA_1_REG, (id >> 8) & 0xff); + twai_putreg(TWAI_DATA_2_REG, id & 0xff); + for (i = 0; i < len; i++) + { + twai_putreg(TWAI_DATA_3_REG + (i * 4), msg->cm_data[i]); + } + } + + /* Send the message */ + +#ifdef CONFIG_CAN_LOOPBACK + twai_putreg(TWAI_CMD_REG, TWAI_SELF_RX_REQ_M | TWAI_ABORT_TX_M); +#else + twai_putreg(TWAI_CMD_REG, TWAI_TX_REQ_M); +#endif + + leave_critical_section(flags); + + return ret; +} + +/**************************************************************************** + * Name: esp32twai_txready + * + * Description: + * Return true if the TWAI hardware can accept another TX message. + * + * Input Parameters: + * dev - An instance of the "upper half" CAN driver state structure. + * + * Returned Value: + * True if the TWAI hardware is ready to accept another TX message. + * + ****************************************************************************/ + +static bool esp32twai_txready(struct can_dev_s *dev) +{ + struct twai_dev_s *priv = dev->cd_priv; + uint32_t regval = twai_getreg(TWAI_STATUS_REG); + + caninfo("TWAI%" PRIu8 " txready: %d\n", priv->port, + ((regval & TWAI_TX_BUF_ST_M) != 0)); + return ((regval & TWAI_TX_BUF_ST_M) != 0); +} + +/**************************************************************************** + * Name: esp32twai_txempty + * + * Description: + * Return true if all message have been sent. If for example, the TWAI + * hardware implements FIFOs, then this would mean the transmit FIFO is + * empty. This method is called when the driver needs to make sure that + * all characters are "drained" from the TX hardware before calling + * co_shutdown(). + * + * Input Parameters: + * dev - An instance of the "upper half" CAN driver state structure. + * + * Returned Value: + * True if there are no pending TX transfers in the TWAI hardware. + * + ****************************************************************************/ + +static bool esp32twai_txempty(struct can_dev_s *dev) +{ + struct twai_dev_s *priv = dev->cd_priv; + uint32_t regval = twai_getreg(TWAI_STATUS_REG); + + caninfo("TWAI%" PRIu8 " txempty: %d\n", priv->port, + ((regval & TWAI_TX_BUF_ST_M) != 0)); + return ((regval & TWAI_TX_BUF_ST_M) != 0); +} + +/**************************************************************************** + * Name: esp32twai_interrupt + * + * Description: + * TWAI0 RX/TX interrupt handler + * + * Input Parameters: + * irq - The IRQ number of the interrupt. + * context - The register state save array at the time of the interrupt. + * arg - The pointer to driver structure. + * + * Returned Value: + * Zero on success; a negated errno on failure + * + ****************************************************************************/ + +static int esp32twai_interrupt(int irq, void *context, void *arg) +{ +#ifdef CONFIG_ESP32_TWAI0 + struct can_dev_s *dev = (struct can_dev_s *)arg; + struct can_hdr_s hdr; + uint8_t data[8]; + uint32_t frame_info; + uint32_t len; + uint32_t datastart; + uint32_t regval; + uint32_t i; + + /* Read the interrupt register results in clearing bits */ + + regval = twai_getreg(TWAI_INT_RAW_REG); + + /* Check for a receive interrupt */ + + if ((regval & TWAI_RX_INT_ST_M) != 0) + { + memset(&hdr, 0, sizeof(hdr)); + memset(data, 0, sizeof(data)); + + frame_info = twai_getreg(TWAI_DATA_0_REG); + + /* Construct the TWAI header */ + + if (frame_info & (1 << 6)) + { + hdr.ch_rtr = 1; + } + +#ifdef CONFIG_CAN_EXTID + if (frame_info & (1 << 7)) + { + /* The provided ID should be 29 bits */ + + hdr.ch_extid = 1; + hdr.ch_id = + (twai_getreg(TWAI_DATA_1_REG) << 21) + + (twai_getreg(TWAI_DATA_2_REG) << 13) + + (twai_getreg(TWAI_DATA_3_REG) << 5) + + (twai_getreg(TWAI_DATA_4_REG) >> 3); + datastart = TWAI_DATA_5_REG; + } + else +#endif + { + /* The provided ID should be 11 bits */ + + hdr.ch_id = + (twai_getreg(TWAI_DATA_1_REG) << 3) + + (twai_getreg(TWAI_DATA_2_REG) >> 5); + datastart = TWAI_DATA_3_REG; + } + + len = frame_info & 0xf; + if (len > CAN_MAXDATALEN) len = CAN_MAXDATALEN; + hdr.ch_dlc = len; + + for (i = 0; i < len; i++) + { + data[i] = twai_getreg(datastart + (i * 4)); + } + + /* Release the receive buffer */ + + twai_putreg(TWAI_CMD_REG, TWAI_RELEASE_BUF_M); + +#ifdef CONFIG_CAN_ERRORS + hdr.ch_error = 0; /* Error reporting not supported */ +#endif + can_receive(dev, &hdr, data); + } + + /* Check for TX buffer complete */ + + if ((regval & TWAI_TX_INT_ST_M) != 0) + { + /* Disable all further TX buffer interrupts */ + + regval = twai_getreg(TWAI_INT_ENA_REG); + regval &= ~TWAI_TX_INT_ENA_M; + twai_putreg(TWAI_INT_ENA_REG, regval); + + /* Indicate that the TX is done and a new TX buffer is available */ + + can_txdone(dev); + } + +#endif + return OK; +} + +/**************************************************************************** + * Name: esp32twai_set_acc_filter + * + * Description: + * Call to set acceptance filter. + * Must be called in reset mode. + * + * Input Parameters: + * code - Acceptance Code. + * mask - Acceptance Mask. + * single_filter - Whether to enable single filter mode. + * + * Returned Value: + * None + * + ****************************************************************************/ + +static void esp32twai_set_acc_filter(uint32_t code, uint32_t mask, + bool single_filter) +{ + uint32_t regval; + uint32_t code_swapped = __builtin_bswap32(code); + uint32_t mask_swapped = __builtin_bswap32(mask); + + regval = twai_getreg(TWAI_MODE_REG); + if (single_filter) + { + regval |= TWAI_RX_FILTER_MODE_M; + } + else + { + regval &= ~(TWAI_RX_FILTER_MODE_M); + } + + twai_putreg(TWAI_MODE_REG, regval); + + for (int i = 0; i < 4; i++) + { + twai_putreg(TWAI_DATA_0_REG + (i * 4), + ((code_swapped >> (i * 8)) & 0xff)); + twai_putreg(TWAI_DATA_4_REG + (i * 4), + ((mask_swapped >> (i * 8)) & 0xff)); + } +} + +/**************************************************************************** + * Name: twai_baud_rate + * + * Description: + * Set the CAN bus timing registers based on the configured bit-rate and + * sample point position. + * + * The bit timing logic monitors the serial bus-line and performs sampling + * and adjustment of the sample point by synchronizing on the start-bit edge + * and resynchronizing on the following edges. + * + * Its operation may be explained simply by splitting nominal bit time into + * three segments as follows: + * + * 1. Synchronization segment (SYNC_SEG): a bit change is expected to occur + * within this time segment. It has a fixed length of one time quantum + * (1 x tCAN). + * 2. Bit segment 1 (BS1): defines the location of the sample point. It + * includes the PROP_SEG and PHASE_SEG1 of the CAN standard. Its duration + * is programmable between 1 and 16 time quanta but may be automatically + * lengthened to compensate for positive phase drifts due to differences + * in the frequency of the various nodes of the network. + * 3. Bit segment 2 (BS2): defines the location of the transmit point. It + * represents the PHASE_SEG2 of the CAN standard. Its duration is + * programmable between 1 and 8 time quanta but may also be automatically + * shortened to compensate for negative phase drifts. + * + * Pictorially: + * + * |<----------------- NOMINAL BIT TIME ----------------->| + * |<- SYNC_SEG ->|<------ BS1 ------>|<------ BS2 ------>| + * |<---- Tq ---->|<----- Tbs1 ------>|<----- Tbs2 ------>| + * + * Where + * Tbs1 is the duration of the BS1 segment + * Tbs2 is the duration of the BS2 segment + * Tq is the "Time Quantum" + * + * Relationships: + * + * baud = 1 / bit_time + * bit_time = Tq + Tbs1 + Tbs2 + * Tbs1 = Tq * ts1 + * Tbs2 = Tq * ts2 + * Tq = brp * Tcan + * + * Where: + * Tcan is the period of the APB clock + * + * Input Parameters: + * priv - A reference to the CAN block status + * + * Returned Value: + * Zero on success; a negated errno on failure + * + ****************************************************************************/ + +static int twai_baud_rate(struct twai_dev_s *priv, int rate, int clock, + int sjw, int sampl_pt, int flags) +{ + const struct can_bittiming_const *timing = + &esp32_twai_bittiming_const; + int best_error = 1000000000; + int error; + int best_tseg = 0; + int best_brp = 0; + int best_rate = 0; + int brp = 0; + int tseg = 0; + int tseg1 = 0; + int tseg2 = 0; + uint32_t timing0; + uint32_t timing1; + + /* tseg even = round down, odd = round up */ + + for (tseg = (0 + 0 + 2) * 2; + tseg <= (timing->tseg2_max + timing->tseg1_max + 2) * 2 + 1; tseg++) + { + brp = clock / ((1 + tseg / 2) * rate) + tseg % 2; + if (brp == 0 || brp > 64) + { + continue; + } + + error = rate - clock / (brp * (1 + tseg / 2)); + if (error < 0) + { + error = -error; + } + + if (error <= best_error) + { + best_error = error; + best_tseg = tseg / 2; + best_brp = brp; + best_rate = clock / (brp * (1 + tseg / 2)); + } + } + + if (best_error && (rate / best_error < 10)) + { + canerr("baud rate %d is not possible with %d Hz clock\n", + rate, clock); + canerr("%d bps. brp=%d, best_tseg=%d, tseg1=%d, tseg2=%d\n", + best_rate, best_brp, best_tseg, tseg1, tseg2); + return -EINVAL; + } + + tseg2 = best_tseg - (sampl_pt * (best_tseg + 1)) / 100 + 1; + if (tseg2 < 0) + { + tseg2 = 0; + } + + if (tseg2 > timing->tseg2_max) + { + tseg2 = timing->tseg2_max; + } + + tseg1 = best_tseg - tseg2; + if (tseg1 > timing->tseg1_max) + { + tseg1 = timing->tseg1_max; + tseg2 = best_tseg - tseg1; + } + + caninfo("TS1: %d TS2: %d BRP: %d\n", tseg1, tseg2, best_brp); + + /* Configure bit timing */ + + timing0 = (best_brp - 1) / 2; + timing0 |= (sjw - 1) << TWAI_SYNC_JUMP_WIDTH_S; + + timing1 = tseg1 - 1; + timing1 |= (tseg2 - 1) << TWAI_TIME_SEG2_S; + +#ifdef CONFIG_ESP32_TWAI0_SAM + /* The bus is sampled 3 times (recommended for low to medium speed buses + * to spikes on the bus-line). + */ + + timing1 |= CONFIG_ESP32_TWAI0_SAM << TWAI_TIME_SAMP_S; +#endif + + twai_putreg(TWAI_BUS_TIMING_0_REG, timing0); + twai_putreg(TWAI_BUS_TIMING_1_REG, timing1); + + return OK; +} + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: esp32_twaiinitialize + * + * Description: + * Initialize the selected TWAI port + * + * Input Parameters: + * Port number (for hardware that has multiple TWAI interfaces) + * + * Returned Value: + * Valid TWAI device structure reference on success; a NULL on failure + * + ****************************************************************************/ + +struct can_dev_s *esp32_twaiinitialize(int port) +{ + struct can_dev_s *twaidev; + irqstate_t flags; + + caninfo("TWAI%" PRIu8 "\n", port); + + flags = enter_critical_section(); + +#ifdef CONFIG_ESP32_TWAI0 + if (port == 0) + { + /* Enable power to the TWAI module and + * Enable clocking to the TWAI module + */ + + modifyreg32(DPORT_PERIP_CLK_EN_REG, 0, DPORT_TWAI_CLK_EN); + modifyreg32(DPORT_PERIP_RST_EN_REG, DPORT_TWAI_RST, 0); + + /* Configure CAN GPIO pins */ + + esp32_gpio_matrix_out(CONFIG_ESP32_TWAI0_TXPIN, TWAI_TX_IDX, 0, 0); + esp32_configgpio(CONFIG_ESP32_TWAI0_TXPIN, OUTPUT_FUNCTION_1); + + esp32_configgpio(CONFIG_ESP32_TWAI0_RXPIN, INPUT_FUNCTION_1); + esp32_gpio_matrix_in(CONFIG_ESP32_TWAI0_RXPIN, TWAI_RX_IDX, 0); + + twaidev = &g_twai0dev; + } + else +#endif + + { + canerr("ERROR: Unsupported port: %d\n", port); + leave_critical_section(flags); + return NULL; + } + + /* Then just perform a TWAI reset operation */ + + esp32twai_reset(twaidev); + + leave_critical_section(flags); + + return twaidev; +} +#endif diff --git a/arch/arm/src/armv7-a/fpu.h b/arch/xtensa/src/esp32/esp32_twai.h similarity index 77% rename from arch/arm/src/armv7-a/fpu.h rename to arch/xtensa/src/esp32/esp32_twai.h index 134cce9680cd6..d1478906806b3 100644 --- a/arch/arm/src/armv7-a/fpu.h +++ b/arch/xtensa/src/esp32/esp32_twai.h @@ -1,5 +1,5 @@ /**************************************************************************** - * arch/arm/src/armv7-a/fpu.h + * arch/xtensa/src/esp32/esp32_twai.h * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with @@ -18,60 +18,60 @@ * ****************************************************************************/ -#ifndef __ARCH_ARM_SRC_ARMV7_A_FPU_H -#define __ARCH_ARM_SRC_ARMV7_A_FPU_H +#ifndef __ARCH_XTENSA_SRC_ESP32_ESP32_TWAI_H +#define __ARCH_XTENSA_SRC_ESP32_ESP32_TWAI_H /**************************************************************************** * Included Files ****************************************************************************/ #include +#include "hardware/esp32_twai.h" /**************************************************************************** * Pre-processor Definitions ****************************************************************************/ /**************************************************************************** - * Inline Functions + * Public Types ****************************************************************************/ -#ifndef __ASSEMBLY__ - -#endif /* __ASSEMBLY__ */ - /**************************************************************************** * Public Data ****************************************************************************/ #ifndef __ASSEMBLY__ #ifdef __cplusplus -#define EXTERN extern "C" extern "C" { -#else -#define EXTERN extern #endif /**************************************************************************** - * Public Function Prototypes + * Public Functions Prototypes ****************************************************************************/ /**************************************************************************** - * Name: arm_fpuconfig + * Name: esp32_twaiinitialize * * Description: - * Configure the FPU. Enables access to CP10 and CP11 + * Initialize the selected CAN port + * + * Input Parameters: + * Port number (for hardware that has multiple TWAI interfaces) + * + * Returned Value: + * Valid TWAI device structure reference on success; a NULL on failure * ****************************************************************************/ -#ifdef CONFIG_ARCH_FPU -void arm_fpuconfig(void); +#if defined(CONFIG_CAN) && defined(CONFIG_ESP32_TWAI) +struct can_dev_s; +struct can_dev_s *esp32_twaiinitialize(int port); #endif -#undef EXTERN #ifdef __cplusplus } #endif #endif /* __ASSEMBLY__ */ -#endif /* __ARCH_ARM_SRC_ARMV7_A_FPU_H */ +#endif /* __ARCH_XTENSA_SRC_ESP32_ESP32_TWAI_H */ diff --git a/arch/xtensa/src/esp32/hardware/esp32_dport.h b/arch/xtensa/src/esp32/hardware/esp32_dport.h index a545535d885cd..968efaac61e94 100644 --- a/arch/xtensa/src/esp32/hardware/esp32_dport.h +++ b/arch/xtensa/src/esp32/hardware/esp32_dport.h @@ -1099,7 +1099,8 @@ #define DPORT_SPI_DMA_CLK_EN (BIT(22)) #define DPORT_I2S1_CLK_EN (BIT(21)) #define DPORT_PWM1_CLK_EN (BIT(20)) -#define DPORT_CAN_CLK_EN (BIT(19)) +#define DPORT_TWAI_CLK_EN (BIT(19)) +#define DPORT_CAN_CLK_EN DPORT_TWAI_CLK_EN #define DPORT_I2C_EXT1_CLK_EN (BIT(18)) #define DPORT_PWM0_CLK_EN (BIT(17)) #define DPORT_SPI_CLK_EN (BIT(16)) @@ -1134,7 +1135,8 @@ #define DPORT_SPI_DMA_RST (BIT(22)) #define DPORT_I2S1_RST (BIT(21)) #define DPORT_PWM1_RST (BIT(20)) -#define DPORT_CAN_RST (BIT(19)) +#define DPORT_TWAI_RST (BIT(19)) +#define DPORT_CAN_RST DPORT_CAN_RST #define DPORT_I2C_EXT1_RST (BIT(18)) #define DPORT_PWM0_RST (BIT(17)) #define DPORT_SPI_RST (BIT(16)) diff --git a/arch/xtensa/src/esp32/hardware/esp32_gpio_sigmap.h b/arch/xtensa/src/esp32/hardware/esp32_gpio_sigmap.h index e86fb49515ab7..c83e9096744fb 100644 --- a/arch/xtensa/src/esp32/hardware/esp32_gpio_sigmap.h +++ b/arch/xtensa/src/esp32/hardware/esp32_gpio_sigmap.h @@ -205,7 +205,8 @@ #define RMT_SIG_OUT5_IDX 92 #define EXT_ADC_START_IDX 93 #define RMT_SIG_OUT6_IDX 93 -#define CAN_RX_IDX 94 +#define TWAI_RX_IDX 94 +#define CAN_RX_IDX TWAI_RX_IDX #define RMT_SIG_OUT7_IDX 94 #define I2CEXT1_SCL_IN_IDX 95 #define I2CEXT1_SCL_OUT_IDX 95 @@ -263,7 +264,8 @@ #define PWM2_OUT4L_IDX 121 #define PWM3_CAP1_IN_IDX 122 #define PWM3_CAP2_IN_IDX 123 -#define CAN_TX_IDX 123 +#define TWAI_TX_IDX 123 +#define CAN_TX_IDX TWAI_TX_IDX #define PWM3_CAP3_IN_IDX 124 #define CAN_BUS_OFF_ON_IDX 124 #define CAN_CLKOUT_IDX 125 diff --git a/arch/xtensa/src/esp32/hardware/esp32_soc.h b/arch/xtensa/src/esp32/hardware/esp32_soc.h index a57412d4e936a..f778795388560 100644 --- a/arch/xtensa/src/esp32/hardware/esp32_soc.h +++ b/arch/xtensa/src/esp32/hardware/esp32_soc.h @@ -245,6 +245,8 @@ #define DR_REG_I2C1_EXT_BASE 0x3ff67000 #define DR_REG_SDMMC_BASE 0x3ff68000 #define DR_REG_EMAC_BASE 0x3ff69000 +#define DR_REG_TWAI_BASE 0x3ff6b000 +#define DR_REG_CAN_BASE DR_REG_TWAI_BASE #define DR_REG_PWM1_BASE 0x3ff6c000 #define DR_REG_I2S1_BASE 0x3ff6d000 #define DR_REG_UART2_BASE 0x3ff6e000 diff --git a/arch/xtensa/src/esp32/hardware/esp32_twai.h b/arch/xtensa/src/esp32/hardware/esp32_twai.h new file mode 100644 index 0000000000000..c9811826e61a9 --- /dev/null +++ b/arch/xtensa/src/esp32/hardware/esp32_twai.h @@ -0,0 +1,856 @@ +/**************************************************************************** + * arch/xtensa/src/esp32/hardware/esp32_twai.h + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +#ifndef __ARCH_XTENSA_SRC_ESP32_HARDWARE_ESP32_TWAI_H +#define __ARCH_XTENSA_SRC_ESP32_HARDWARE_ESP32_TWAI_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include "esp32_soc.h" + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/* TWAI_MODE_REG register + * Mode Register + */ + +#define TWAI_MODE_REG (DR_REG_TWAI_BASE + 0x0) + +/* TWAI_RX_FILTER_MODE : R/W; bitpos: [3]; default: 0; + * This bit is used to configure the filter mode. 0: Dual filter mode; 1: + * Single filter mode. + */ + +#define TWAI_RX_FILTER_MODE (BIT(3)) +#define TWAI_RX_FILTER_MODE_M (TWAI_RX_FILTER_MODE_V << TWAI_RX_FILTER_MODE_S) +#define TWAI_RX_FILTER_MODE_V 0x00000001 +#define TWAI_RX_FILTER_MODE_S 3 + +/* TWAI_SELF_TEST_MODE : R/W; bitpos: [2]; default: 0; + * 1: Self test mode. In this mode the TX nodes can perform a successful + * transmission without receiving the acknowledge signal. This mode is often + * used to test a single node with the self reception request command. + */ + +#define TWAI_SELF_TEST_MODE (BIT(2)) +#define TWAI_SELF_TEST_MODE_M (TWAI_SELF_TEST_MODE_V << TWAI_SELF_TEST_MODE_S) +#define TWAI_SELF_TEST_MODE_V 0x00000001 +#define TWAI_SELF_TEST_MODE_S 2 + +/* TWAI_LISTEN_ONLY_MODE : R/W; bitpos: [1]; default: 0; + * 1: Listen only mode. In this mode the nodes will only receive messages + * from the bus, without generating the acknowledge signal nor updating the + * RX error counter. + */ + +#define TWAI_LISTEN_ONLY_MODE (BIT(1)) +#define TWAI_LISTEN_ONLY_MODE_M (TWAI_LISTEN_ONLY_MODE_V << TWAI_LISTEN_ONLY_MODE_S) +#define TWAI_LISTEN_ONLY_MODE_V 0x00000001 +#define TWAI_LISTEN_ONLY_MODE_S 1 + +/* TWAI_RESET_MODE : R/W; bitpos: [0]; default: 1; + * This bit is used to configure the operating mode of the TWAI Controller. + * 1: Reset mode; 0: Operating mode. + */ + +#define TWAI_RESET_MODE (BIT(0)) +#define TWAI_RESET_MODE_M (TWAI_RESET_MODE_V << TWAI_RESET_MODE_S) +#define TWAI_RESET_MODE_V 0x00000001 +#define TWAI_RESET_MODE_S 0 + +/* TWAI_CMD_REG register + * Command Register + */ + +#define TWAI_CMD_REG (DR_REG_TWAI_BASE + 0x4) + +/* TWAI_SELF_RX_REQ : WO; bitpos: [4]; default: 0; + * Self reception request command. Set the bit to 1 to allow a message be + * transmitted and received simultaneously. + */ + +#define TWAI_SELF_RX_REQ (BIT(4)) +#define TWAI_SELF_RX_REQ_M (TWAI_SELF_RX_REQ_V << TWAI_SELF_RX_REQ_S) +#define TWAI_SELF_RX_REQ_V 0x00000001 +#define TWAI_SELF_RX_REQ_S 4 + +/* TWAI_CLR_OVERRUN : WO; bitpos: [3]; default: 0; + * Set the bit to 1 to clear the data overrun status bit. + */ + +#define TWAI_CLR_OVERRUN (BIT(3)) +#define TWAI_CLR_OVERRUN_M (TWAI_CLR_OVERRUN_V << TWAI_CLR_OVERRUN_S) +#define TWAI_CLR_OVERRUN_V 0x00000001 +#define TWAI_CLR_OVERRUN_S 3 + +/* TWAI_RELEASE_BUF : WO; bitpos: [2]; default: 0; + * Set the bit to 1 to release the RX buffer. + */ + +#define TWAI_RELEASE_BUF (BIT(2)) +#define TWAI_RELEASE_BUF_M (TWAI_RELEASE_BUF_V << TWAI_RELEASE_BUF_S) +#define TWAI_RELEASE_BUF_V 0x00000001 +#define TWAI_RELEASE_BUF_S 2 + +/* TWAI_ABORT_TX : WO; bitpos: [1]; default: 0; + * Set the bit to 1 to cancel a pending transmission request. + */ + +#define TWAI_ABORT_TX (BIT(1)) +#define TWAI_ABORT_TX_M (TWAI_ABORT_TX_V << TWAI_ABORT_TX_S) +#define TWAI_ABORT_TX_V 0x00000001 +#define TWAI_ABORT_TX_S 1 + +/* TWAI_TX_REQ : WO; bitpos: [0]; default: 0; + * Set the bit to 1 to allow the driving nodes start transmission. + */ + +#define TWAI_TX_REQ (BIT(0)) +#define TWAI_TX_REQ_M (TWAI_TX_REQ_V << TWAI_TX_REQ_S) +#define TWAI_TX_REQ_V 0x00000001 +#define TWAI_TX_REQ_S 0 + +/* TWAI_STATUS_REG register + * Status register + */ + +#define TWAI_STATUS_REG (DR_REG_TWAI_BASE + 0x8) + +/* TWAI_MISS_ST : RO; bitpos: [8]; default: 0; + * This bit reflects whether the data packet in the RX FIFO is complete. 1: + * The current packet is missing; 0: The current packet is complete + */ + +#define TWAI_MISS_ST (BIT(8)) +#define TWAI_MISS_ST_M (TWAI_MISS_ST_V << TWAI_MISS_ST_S) +#define TWAI_MISS_ST_V 0x00000001 +#define TWAI_MISS_ST_S 8 + +/* TWAI_BUS_OFF_ST : RO; bitpos: [7]; default: 0; + * 1: In bus-off status, the TWAI Controller is no longer involved in bus + * activities. + */ + +#define TWAI_BUS_OFF_ST (BIT(7)) +#define TWAI_BUS_OFF_ST_M (TWAI_BUS_OFF_ST_V << TWAI_BUS_OFF_ST_S) +#define TWAI_BUS_OFF_ST_V 0x00000001 +#define TWAI_BUS_OFF_ST_S 7 + +/* TWAI_ERR_ST : RO; bitpos: [6]; default: 0; + * 1: At least one of the RX/TX error counter has reached or exceeded the + * value set in register TWAI_ERR_WARNING_LIMIT_REG. + */ + +#define TWAI_ERR_ST (BIT(6)) +#define TWAI_ERR_ST_M (TWAI_ERR_ST_V << TWAI_ERR_ST_S) +#define TWAI_ERR_ST_V 0x00000001 +#define TWAI_ERR_ST_S 6 + +/* TWAI_TX_ST : RO; bitpos: [5]; default: 0; + * 1: The TWAI Controller is transmitting a message to the bus. + */ + +#define TWAI_TX_ST (BIT(5)) +#define TWAI_TX_ST_M (TWAI_TX_ST_V << TWAI_TX_ST_S) +#define TWAI_TX_ST_V 0x00000001 +#define TWAI_TX_ST_S 5 + +/* TWAI_RX_ST : RO; bitpos: [4]; default: 0; + * 1: The TWAI Controller is receiving a message from the bus. + */ + +#define TWAI_RX_ST (BIT(4)) +#define TWAI_RX_ST_M (TWAI_RX_ST_V << TWAI_RX_ST_S) +#define TWAI_RX_ST_V 0x00000001 +#define TWAI_RX_ST_S 4 + +/* TWAI_TX_COMPLETE : RO; bitpos: [3]; default: 0; + * 1: The TWAI controller has successfully received a packet from the bus. + */ + +#define TWAI_TX_COMPLETE (BIT(3)) +#define TWAI_TX_COMPLETE_M (TWAI_TX_COMPLETE_V << TWAI_TX_COMPLETE_S) +#define TWAI_TX_COMPLETE_V 0x00000001 +#define TWAI_TX_COMPLETE_S 3 + +/* TWAI_TX_BUF_ST : RO; bitpos: [2]; default: 0; + * 1: The TX buffer is empty, the CPU may write a message into it. + */ + +#define TWAI_TX_BUF_ST (BIT(2)) +#define TWAI_TX_BUF_ST_M (TWAI_TX_BUF_ST_V << TWAI_TX_BUF_ST_S) +#define TWAI_TX_BUF_ST_V 0x00000001 +#define TWAI_TX_BUF_ST_S 2 + +/* TWAI_OVERRUN_ST : RO; bitpos: [1]; default: 0; + * 1: The RX FIFO is full and data overrun has occurred. + */ + +#define TWAI_OVERRUN_ST (BIT(1)) +#define TWAI_OVERRUN_ST_M (TWAI_OVERRUN_ST_V << TWAI_OVERRUN_ST_S) +#define TWAI_OVERRUN_ST_V 0x00000001 +#define TWAI_OVERRUN_ST_S 1 + +/* TWAI_RX_BUF_ST : RO; bitpos: [0]; default: 0; + * 1: The data in the RX buffer is not empty, with at least one received + * data packet. + */ + +#define TWAI_RX_BUF_ST (BIT(0)) +#define TWAI_RX_BUF_ST_M (TWAI_RX_BUF_ST_V << TWAI_RX_BUF_ST_S) +#define TWAI_RX_BUF_ST_V 0x00000001 +#define TWAI_RX_BUF_ST_S 0 + +/* TWAI_INT_RAW_REG register + * Interrupt Register + */ + +#define TWAI_INT_RAW_REG (DR_REG_TWAI_BASE + 0xc) + +/* TWAI_BUS_ERR_INT_ST : RO; bitpos: [7]; default: 0; + * Error interrupt. If this bit is set to 1, it indicates an error is + * detected on the bus. + */ + +#define TWAI_BUS_ERR_INT_ST (BIT(7)) +#define TWAI_BUS_ERR_INT_ST_M (TWAI_BUS_ERR_INT_ST_V << TWAI_BUS_ERR_INT_ST_S) +#define TWAI_BUS_ERR_INT_ST_V 0x00000001 +#define TWAI_BUS_ERR_INT_ST_S 7 + +/* TWAI_ARB_LOST_INT_ST : RO; bitpos: [6]; default: 0; + * Arbitration lost interrupt. If this bit is set to 1, it indicates an + * arbitration lost interrupt is generated. + */ + +#define TWAI_ARB_LOST_INT_ST (BIT(6)) +#define TWAI_ARB_LOST_INT_ST_M (TWAI_ARB_LOST_INT_ST_V << TWAI_ARB_LOST_INT_ST_S) +#define TWAI_ARB_LOST_INT_ST_V 0x00000001 +#define TWAI_ARB_LOST_INT_ST_S 6 + +/* TWAI_ERR_PASSIVE_INT_ST : RO; bitpos: [5]; default: 0; + * Error passive interrupt. If this bit is set to 1, it indicates the TWAI + * Controller is switched between error active status and error passive + * status due to the change of error counters. + */ + +#define TWAI_ERR_PASSIVE_INT_ST (BIT(5)) +#define TWAI_ERR_PASSIVE_INT_ST_M (TWAI_ERR_PASSIVE_INT_ST_V << TWAI_ERR_PASSIVE_INT_ST_S) +#define TWAI_ERR_PASSIVE_INT_ST_V 0x00000001 +#define TWAI_ERR_PASSIVE_INT_ST_S 5 + +/* TWAI_OVERRUN_INT_ST : RO; bitpos: [3]; default: 0; + * Data overrun interrupt. If this bit is set to 1, it indicates a data + * overrun interrupt is generated in the RX FIFO. + */ + +#define TWAI_OVERRUN_INT_ST (BIT(3)) +#define TWAI_OVERRUN_INT_ST_M (TWAI_OVERRUN_INT_ST_V << TWAI_OVERRUN_INT_ST_S) +#define TWAI_OVERRUN_INT_ST_V 0x00000001 +#define TWAI_OVERRUN_INT_ST_S 3 + +/* TWAI_ERR_WARN_INT_ST : RO; bitpos: [2]; default: 0; + * Error warning interrupt. If this bit is set to 1, it indicates the error + * status signal and the bus-off status signal of Status register have + * changed (e.g., switched from 0 to 1 or from 1 to 0). + */ + +#define TWAI_ERR_WARN_INT_ST (BIT(2)) +#define TWAI_ERR_WARN_INT_ST_M (TWAI_ERR_WARN_INT_ST_V << TWAI_ERR_WARN_INT_ST_S) +#define TWAI_ERR_WARN_INT_ST_V 0x00000001 +#define TWAI_ERR_WARN_INT_ST_S 2 + +/* TWAI_TX_INT_ST : RO; bitpos: [1]; default: 0; + * Transmit interrupt. If this bit is set to 1, it indicates the message + * transmitting mis- sion is finished and a new transmission is able to + * execute. + */ + +#define TWAI_TX_INT_ST (BIT(1)) +#define TWAI_TX_INT_ST_M (TWAI_TX_INT_ST_V << TWAI_TX_INT_ST_S) +#define TWAI_TX_INT_ST_V 0x00000001 +#define TWAI_TX_INT_ST_S 1 + +/* TWAI_RX_INT_ST : RO; bitpos: [0]; default: 0; + * Receive interrupt. If this bit is set to 1, it indicates there are + * messages to be handled in the RX FIFO. + */ + +#define TWAI_RX_INT_ST (BIT(0)) +#define TWAI_RX_INT_ST_M (TWAI_RX_INT_ST_V << TWAI_RX_INT_ST_S) +#define TWAI_RX_INT_ST_V 0x00000001 +#define TWAI_RX_INT_ST_S 0 + +/* TWAI_INT_ENA_REG register + * Interrupt Enable Register + */ + +#define TWAI_INT_ENA_REG (DR_REG_TWAI_BASE + 0x10) + +/* TWAI_BUS_ERR_INT_ENA : R/W; bitpos: [7]; default: 0; + * Set this bit to 1 to enable error interrupt. + */ + +#define TWAI_BUS_ERR_INT_ENA (BIT(7)) +#define TWAI_BUS_ERR_INT_ENA_M (TWAI_BUS_ERR_INT_ENA_V << TWAI_BUS_ERR_INT_ENA_S) +#define TWAI_BUS_ERR_INT_ENA_V 0x00000001 +#define TWAI_BUS_ERR_INT_ENA_S 7 + +/* TWAI_ARB_LOST_INT_ENA : R/W; bitpos: [6]; default: 0; + * Set this bit to 1 to enable arbitration lost interrupt. + */ + +#define TWAI_ARB_LOST_INT_ENA (BIT(6)) +#define TWAI_ARB_LOST_INT_ENA_M (TWAI_ARB_LOST_INT_ENA_V << TWAI_ARB_LOST_INT_ENA_S) +#define TWAI_ARB_LOST_INT_ENA_V 0x00000001 +#define TWAI_ARB_LOST_INT_ENA_S 6 + +/* TWAI_ERR_PASSIVE_INT_ENA : R/W; bitpos: [5]; default: 0; + * Set this bit to 1 to enable error passive interrupt. + */ + +#define TWAI_ERR_PASSIVE_INT_ENA (BIT(5)) +#define TWAI_ERR_PASSIVE_INT_ENA_M (TWAI_ERR_PASSIVE_INT_ENA_V << TWAI_ERR_PASSIVE_INT_ENA_S) +#define TWAI_ERR_PASSIVE_INT_ENA_V 0x00000001 +#define TWAI_ERR_PASSIVE_INT_ENA_S 5 + +/* TWAI_OVERRUN_INT_ENA : R/W; bitpos: [3]; default: 0; + * Set this bit to 1 to enable data overrun interrupt. + */ + +#define TWAI_OVERRUN_INT_ENA (BIT(3)) +#define TWAI_OVERRUN_INT_ENA_M (TWAI_OVERRUN_INT_ENA_V << TWAI_OVERRUN_INT_ENA_S) +#define TWAI_OVERRUN_INT_ENA_V 0x00000001 +#define TWAI_OVERRUN_INT_ENA_S 3 + +/* TWAI_ERR_WARN_INT_ENA : R/W; bitpos: [2]; default: 0; + * Set this bit to 1 to enable error warning interrupt. + */ + +#define TWAI_ERR_WARN_INT_ENA (BIT(2)) +#define TWAI_ERR_WARN_INT_ENA_M (TWAI_ERR_WARN_INT_ENA_V << TWAI_ERR_WARN_INT_ENA_S) +#define TWAI_ERR_WARN_INT_ENA_V 0x00000001 +#define TWAI_ERR_WARN_INT_ENA_S 2 + +/* TWAI_TX_INT_ENA : R/W; bitpos: [1]; default: 0; + * Set this bit to 1 to enable transmit interrupt. + */ + +#define TWAI_TX_INT_ENA (BIT(1)) +#define TWAI_TX_INT_ENA_M (TWAI_TX_INT_ENA_V << TWAI_TX_INT_ENA_S) +#define TWAI_TX_INT_ENA_V 0x00000001 +#define TWAI_TX_INT_ENA_S 1 + +/* TWAI_RX_INT_ENA : R/W; bitpos: [0]; default: 0; + * Set this bit to 1 to enable receive interrupt. + */ + +#define TWAI_RX_INT_ENA (BIT(0)) +#define TWAI_RX_INT_ENA_M (TWAI_RX_INT_ENA_V << TWAI_RX_INT_ENA_S) +#define TWAI_RX_INT_ENA_V 0x00000001 +#define TWAI_RX_INT_ENA_S 0 + +/* TWAI_BUS_TIMING_0_REG register + * Bus Timing Register 0 + */ + +#define TWAI_BUS_TIMING_0_REG (DR_REG_TWAI_BASE + 0x18) + +/* TWAI_SYNC_JUMP_WIDTH : RO | R/W; bitpos: [15:14]; default: 0; + * Synchronization Jump Width (SJW), 1 \verb+~+ 14 Tq wide. + */ + +#define TWAI_SYNC_JUMP_WIDTH 0x00000003 +#define TWAI_SYNC_JUMP_WIDTH_M (TWAI_SYNC_JUMP_WIDTH_V << TWAI_SYNC_JUMP_WIDTH_S) +#define TWAI_SYNC_JUMP_WIDTH_V 0x00000003 +#define TWAI_SYNC_JUMP_WIDTH_S 14 + +/* TWAI_BAUD_PRESC : RO | R/W; bitpos: [13:0]; default: 0; + * Baud Rate Prescaler, determines the frequency dividing ratio. + */ + +#define TWAI_BAUD_PRESC 0x00003FFF +#define TWAI_BAUD_PRESC_M (TWAI_BAUD_PRESC_V << TWAI_BAUD_PRESC_S) +#define TWAI_BAUD_PRESC_V 0x00003FFF +#define TWAI_BAUD_PRESC_S 0 + +/* TWAI_BUS_TIMING_1_REG register + * Bus Timing Register 1 + */ + +#define TWAI_BUS_TIMING_1_REG (DR_REG_TWAI_BASE + 0x1c) + +/* TWAI_TIME_SAMP : RO | R/W; bitpos: [7]; default: 0; + * The number of sample points. 0: the bus is sampled once; 1: the bus is + * sampled three times + */ + +#define TWAI_TIME_SAMP (BIT(7)) +#define TWAI_TIME_SAMP_M (TWAI_TIME_SAMP_V << TWAI_TIME_SAMP_S) +#define TWAI_TIME_SAMP_V 0x00000001 +#define TWAI_TIME_SAMP_S 7 + +/* TWAI_TIME_SEG2 : RO | R/W; bitpos: [6:4]; default: 0; + * The width of PBS2. + */ + +#define TWAI_TIME_SEG2 0x00000007 +#define TWAI_TIME_SEG2_M (TWAI_TIME_SEG2_V << TWAI_TIME_SEG2_S) +#define TWAI_TIME_SEG2_V 0x00000007 +#define TWAI_TIME_SEG2_S 4 + +/* TWAI_TIME_SEG1 : RO | R/W; bitpos: [3:0]; default: 0; + * The width of PBS1. + */ + +#define TWAI_TIME_SEG1 0x0000000F +#define TWAI_TIME_SEG1_M (TWAI_TIME_SEG1_V << TWAI_TIME_SEG1_S) +#define TWAI_TIME_SEG1_V 0x0000000F +#define TWAI_TIME_SEG1_S 0 + +/* TWAI_ARB_LOST_CAP_REG register + * Arbitration Lost Capture Register + */ + +#define TWAI_ARB_LOST_CAP_REG (DR_REG_TWAI_BASE + 0x2c) + +/* TWAI_ARB_LOST_CAP : RO; bitpos: [4:0]; default: 0; + * This register contains information about the bit position of lost + * arbitration. + */ + +#define TWAI_ARB_LOST_CAP 0x0000001F +#define TWAI_ARB_LOST_CAP_M (TWAI_ARB_LOST_CAP_V << TWAI_ARB_LOST_CAP_S) +#define TWAI_ARB_LOST_CAP_V 0x0000001F +#define TWAI_ARB_LOST_CAP_S 0 + +/* TWAI_ERR_CODE_CAP_REG register + * Error Code Capture Register + */ + +#define TWAI_ERR_CODE_CAP_REG (DR_REG_TWAI_BASE + 0x30) + +/* TWAI_ECC_TYPE : RO; bitpos: [7:6]; default: 0; + * This register contains information about error types: 00: bit error; 01: + * form error; 10: stuff error; 11: other type of error + */ + +#define TWAI_ECC_TYPE 0x00000003 +#define TWAI_ECC_TYPE_M (TWAI_ECC_TYPE_V << TWAI_ECC_TYPE_S) +#define TWAI_ECC_TYPE_V 0x00000003 +#define TWAI_ECC_TYPE_S 6 + +/* TWAI_ECC_DIRECTION : RO; bitpos: [5]; default: 0; + * This register contains information about transmission direction of the + * node when error occurs. 1: Error occurs when receiving a message; 0: + * Error occurs when transmitting a message + */ + +#define TWAI_ECC_DIRECTION (BIT(5)) +#define TWAI_ECC_DIRECTION_M (TWAI_ECC_DIRECTION_V << TWAI_ECC_DIRECTION_S) +#define TWAI_ECC_DIRECTION_V 0x00000001 +#define TWAI_ECC_DIRECTION_S 5 + +/* TWAI_ECC_SEGMENT : RO; bitpos: [4:0]; default: 0; + * This register contains information about the location of errors, see + * Table 181 for details. + */ + +#define TWAI_ECC_SEGMENT 0x0000001F +#define TWAI_ECC_SEGMENT_M (TWAI_ECC_SEGMENT_V << TWAI_ECC_SEGMENT_S) +#define TWAI_ECC_SEGMENT_V 0x0000001F +#define TWAI_ECC_SEGMENT_S 0 + +/* TWAI_ERR_WARNING_LIMIT_REG register + * Error Warning Limit Register + */ + +#define TWAI_ERR_WARNING_LIMIT_REG (DR_REG_TWAI_BASE + 0x34) + +/* TWAI_ERR_WARNING_LIMIT : RO | R/W; bitpos: [7:0]; default: 96; + * Error warning threshold. In the case when any of a error counter value + * exceeds the threshold, or all the error counter values are below the + * threshold, an error warning interrupt will be triggered (given the enable + * signal is valid). + */ + +#define TWAI_ERR_WARNING_LIMIT 0x000000FF +#define TWAI_ERR_WARNING_LIMIT_M (TWAI_ERR_WARNING_LIMIT_V << TWAI_ERR_WARNING_LIMIT_S) +#define TWAI_ERR_WARNING_LIMIT_V 0x000000FF +#define TWAI_ERR_WARNING_LIMIT_S 0 + +/* TWAI_RX_ERR_CNT_REG register + * Receive Error Counter Register + */ + +#define TWAI_RX_ERR_CNT_REG (DR_REG_TWAI_BASE + 0x38) + +/* TWAI_RX_ERR_CNT : RO | R/W; bitpos: [7:0]; default: 0; + * The RX error counter register, reflects value changes under reception + * status. + */ + +#define TWAI_RX_ERR_CNT 0x000000FF +#define TWAI_RX_ERR_CNT_M (TWAI_RX_ERR_CNT_V << TWAI_RX_ERR_CNT_S) +#define TWAI_RX_ERR_CNT_V 0x000000FF +#define TWAI_RX_ERR_CNT_S 0 + +/* TWAI_TX_ERR_CNT_REG register + * Transmit Error Counter Register + */ + +#define TWAI_TX_ERR_CNT_REG (DR_REG_TWAI_BASE + 0x3c) + +/* TWAI_TX_ERR_CNT : RO | R/W; bitpos: [7:0]; default: 0; + * The TX error counter register, reflects value changes under transmission + * status. + */ + +#define TWAI_TX_ERR_CNT 0x000000FF +#define TWAI_TX_ERR_CNT_M (TWAI_TX_ERR_CNT_V << TWAI_TX_ERR_CNT_S) +#define TWAI_TX_ERR_CNT_V 0x000000FF +#define TWAI_TX_ERR_CNT_S 0 + +/* TWAI_DATA_0_REG register + * Data register 0 + */ + +#define TWAI_DATA_0_REG (DR_REG_TWAI_BASE + 0x40) + +/* TWAI_TX_BYTE_0 : WO; bitpos: [7:0]; default: 0; + * Stored the 0th byte information of the data to be transmitted under + * operating mode. + */ + +#define TWAI_TX_BYTE_0 0x000000FF +#define TWAI_TX_BYTE_0_M (TWAI_TX_BYTE_0_V << TWAI_TX_BYTE_0_S) +#define TWAI_TX_BYTE_0_V 0x000000FF +#define TWAI_TX_BYTE_0_S 0 + +/* TWAI_ACCEPTANCE_CODE_0 : WO; bitpos: [7:0]; default: 0; + * Stored the 0th byte of the filter code in reset mode. + */ + +#define TWAI_ACCEPTANCE_CODE_0 0x000000FF +#define TWAI_ACCEPTANCE_CODE_0_M (TWAI_ACCEPTANCE_CODE_0_V << TWAI_ACCEPTANCE_CODE_0_S) +#define TWAI_ACCEPTANCE_CODE_0_V 0x000000FF +#define TWAI_ACCEPTANCE_CODE_0_S 0 + +/* TWAI_DATA_1_REG register + * Data register 1 + */ + +#define TWAI_DATA_1_REG (DR_REG_TWAI_BASE + 0x44) + +/* TWAI_TX_BYTE_1 : WO; bitpos: [7:0]; default: 0; + * Stored the 1st byte information of the data to be transmitted under + * operating mode. + */ + +#define TWAI_TX_BYTE_1 0x000000FF +#define TWAI_TX_BYTE_1_M (TWAI_TX_BYTE_1_V << TWAI_TX_BYTE_1_S) +#define TWAI_TX_BYTE_1_V 0x000000FF +#define TWAI_TX_BYTE_1_S 0 + +/* TWAI_ACCEPTANCE_CODE_1 : WO; bitpos: [7:0]; default: 0; + * Stored the 1st byte of the filter code in reset mode. + */ + +#define TWAI_ACCEPTANCE_CODE_1 0x000000FF +#define TWAI_ACCEPTANCE_CODE_1_M (TWAI_ACCEPTANCE_CODE_1_V << TWAI_ACCEPTANCE_CODE_1_S) +#define TWAI_ACCEPTANCE_CODE_1_V 0x000000FF +#define TWAI_ACCEPTANCE_CODE_1_S 0 + +/* TWAI_DATA_2_REG register + * Data register 2 + */ + +#define TWAI_DATA_2_REG (DR_REG_TWAI_BASE + 0x48) + +/* TWAI_TX_BYTE_2 : WO; bitpos: [7:0]; default: 0; + * Stored the 2nd byte information of the data to be transmitted under + * operating mode. + */ + +#define TWAI_TX_BYTE_2 0x000000FF +#define TWAI_TX_BYTE_2_M (TWAI_TX_BYTE_2_V << TWAI_TX_BYTE_2_S) +#define TWAI_TX_BYTE_2_V 0x000000FF +#define TWAI_TX_BYTE_2_S 0 + +/* TWAI_ACCEPTANCE_CODE_2 : WO; bitpos: [7:0]; default: 0; + * Stored the 2nd byte of the filter code in reset mode. + */ + +#define TWAI_ACCEPTANCE_CODE_2 0x000000FF +#define TWAI_ACCEPTANCE_CODE_2_M (TWAI_ACCEPTANCE_CODE_2_V << TWAI_ACCEPTANCE_CODE_2_S) +#define TWAI_ACCEPTANCE_CODE_2_V 0x000000FF +#define TWAI_ACCEPTANCE_CODE_2_S 0 + +/* TWAI_DATA_3_REG register + * Data register 3 + */ + +#define TWAI_DATA_3_REG (DR_REG_TWAI_BASE + 0x4c) + +/* TWAI_TX_BYTE_3 : WO; bitpos: [7:0]; default: 0; + * Stored the 3rd byte information of the data to be transmitted under + * operating mode. + */ + +#define TWAI_TX_BYTE_3 0x000000FF +#define TWAI_TX_BYTE_3_M (TWAI_TX_BYTE_3_V << TWAI_TX_BYTE_3_S) +#define TWAI_TX_BYTE_3_V 0x000000FF +#define TWAI_TX_BYTE_3_S 0 + +/* TWAI_ACCEPTANCE_CODE_3 : WO; bitpos: [7:0]; default: 0; + * Stored the 3rd byte of the filter code in reset mode. + */ + +#define TWAI_ACCEPTANCE_CODE_3 0x000000FF +#define TWAI_ACCEPTANCE_CODE_3_M (TWAI_ACCEPTANCE_CODE_3_V << TWAI_ACCEPTANCE_CODE_3_S) +#define TWAI_ACCEPTANCE_CODE_3_V 0x000000FF +#define TWAI_ACCEPTANCE_CODE_3_S 0 + +/* TWAI_DATA_4_REG register + * Data register 4 + */ + +#define TWAI_DATA_4_REG (DR_REG_TWAI_BASE + 0x50) + +/* TWAI_TX_BYTE_4 : WO; bitpos: [7:0]; default: 0; + * Stored the 4th byte information of the data to be transmitted under + * operating mode. + */ + +#define TWAI_TX_BYTE_4 0x000000FF +#define TWAI_TX_BYTE_4_M (TWAI_TX_BYTE_4_V << TWAI_TX_BYTE_4_S) +#define TWAI_TX_BYTE_4_V 0x000000FF +#define TWAI_TX_BYTE_4_S 0 + +/* TWAI_ACCEPTANCE_MASK_0 : WO; bitpos: [7:0]; default: 0; + * Stored the 0th byte of the filter code in reset mode. + */ + +#define TWAI_ACCEPTANCE_MASK_0 0x000000FF +#define TWAI_ACCEPTANCE_MASK_0_M (TWAI_ACCEPTANCE_MASK_0_V << TWAI_ACCEPTANCE_MASK_0_S) +#define TWAI_ACCEPTANCE_MASK_0_V 0x000000FF +#define TWAI_ACCEPTANCE_MASK_0_S 0 + +/* TWAI_DATA_5_REG register + * Data register 5 + */ + +#define TWAI_DATA_5_REG (DR_REG_TWAI_BASE + 0x54) + +/* TWAI_TX_BYTE_5 : WO; bitpos: [7:0]; default: 0; + * Stored the 5th byte information of the data to be transmitted under + * operating mode. + */ + +#define TWAI_TX_BYTE_5 0x000000FF +#define TWAI_TX_BYTE_5_M (TWAI_TX_BYTE_5_V << TWAI_TX_BYTE_5_S) +#define TWAI_TX_BYTE_5_V 0x000000FF +#define TWAI_TX_BYTE_5_S 0 + +/* TWAI_ACCEPTANCE_MASK_1 : WO; bitpos: [7:0]; default: 0; + * Stored the 1st byte of the filter code in reset mode. + */ + +#define TWAI_ACCEPTANCE_MASK_1 0x000000FF +#define TWAI_ACCEPTANCE_MASK_1_M (TWAI_ACCEPTANCE_MASK_1_V << TWAI_ACCEPTANCE_MASK_1_S) +#define TWAI_ACCEPTANCE_MASK_1_V 0x000000FF +#define TWAI_ACCEPTANCE_MASK_1_S 0 + +/* TWAI_DATA_6_REG register + * Data register 6 + */ + +#define TWAI_DATA_6_REG (DR_REG_TWAI_BASE + 0x58) + +/* TWAI_TX_BYTE_6 : WO; bitpos: [7:0]; default: 0; + * Stored the 6th byte information of the data to be transmitted under + * operating mode. + */ + +#define TWAI_TX_BYTE_6 0x000000FF +#define TWAI_TX_BYTE_6_M (TWAI_TX_BYTE_6_V << TWAI_TX_BYTE_6_S) +#define TWAI_TX_BYTE_6_V 0x000000FF +#define TWAI_TX_BYTE_6_S 0 + +/* TWAI_ACCEPTANCE_MASK_2 : WO; bitpos: [7:0]; default: 0; + * Stored the 2nd byte of the filter code in reset mode. + */ + +#define TWAI_ACCEPTANCE_MASK_2 0x000000FF +#define TWAI_ACCEPTANCE_MASK_2_M (TWAI_ACCEPTANCE_MASK_2_V << TWAI_ACCEPTANCE_MASK_2_S) +#define TWAI_ACCEPTANCE_MASK_2_V 0x000000FF +#define TWAI_ACCEPTANCE_MASK_2_S 0 + +/* TWAI_DATA_7_REG register + * Data register 7 + */ + +#define TWAI_DATA_7_REG (DR_REG_TWAI_BASE + 0x5c) + +/* TWAI_TX_BYTE_7 : WO; bitpos: [7:0]; default: 0; + * Stored the 7th byte information of the data to be transmitted under + * operating mode. + */ + +#define TWAI_TX_BYTE_7 0x000000FF +#define TWAI_TX_BYTE_7_M (TWAI_TX_BYTE_7_V << TWAI_TX_BYTE_7_S) +#define TWAI_TX_BYTE_7_V 0x000000FF +#define TWAI_TX_BYTE_7_S 0 + +/* TWAI_ACCEPTANCE_MASK_3 : WO; bitpos: [7:0]; default: 0; + * Stored the 3th byte of the filter code in reset mode. + */ + +#define TWAI_ACCEPTANCE_MASK_3 0x000000FF +#define TWAI_ACCEPTANCE_MASK_3_M (TWAI_ACCEPTANCE_MASK_3_V << TWAI_ACCEPTANCE_MASK_3_S) +#define TWAI_ACCEPTANCE_MASK_3_V 0x000000FF +#define TWAI_ACCEPTANCE_MASK_3_S 0 + +/* TWAI_DATA_8_REG register + * Data register 8 + */ + +#define TWAI_DATA_8_REG (DR_REG_TWAI_BASE + 0x60) + +/* TWAI_TX_BYTE_8 : WO; bitpos: [7:0]; default: 0; + * Stored the 8th byte information of the data to be transmitted under + * operating mode. + */ + +#define TWAI_TX_BYTE_8 0x000000FF +#define TWAI_TX_BYTE_8_M (TWAI_TX_BYTE_8_V << TWAI_TX_BYTE_8_S) +#define TWAI_TX_BYTE_8_V 0x000000FF +#define TWAI_TX_BYTE_8_S 0 + +/* TWAI_DATA_9_REG register + * Data register 9 + */ + +#define TWAI_DATA_9_REG (DR_REG_TWAI_BASE + 0x64) + +/* TWAI_TX_BYTE_9 : WO; bitpos: [7:0]; default: 0; + * Stored the 9th byte information of the data to be transmitted under + * operating mode. + */ + +#define TWAI_TX_BYTE_9 0x000000FF +#define TWAI_TX_BYTE_9_M (TWAI_TX_BYTE_9_V << TWAI_TX_BYTE_9_S) +#define TWAI_TX_BYTE_9_V 0x000000FF +#define TWAI_TX_BYTE_9_S 0 + +/* TWAI_DATA_10_REG register + * Data register 10 + */ + +#define TWAI_DATA_10_REG (DR_REG_TWAI_BASE + 0x68) + +/* TWAI_TX_BYTE_10 : WO; bitpos: [7:0]; default: 0; + * Stored the 10th byte information of the data to be transmitted under + * operating mode. + */ + +#define TWAI_TX_BYTE_10 0x000000FF +#define TWAI_TX_BYTE_10_M (TWAI_TX_BYTE_10_V << TWAI_TX_BYTE_10_S) +#define TWAI_TX_BYTE_10_V 0x000000FF +#define TWAI_TX_BYTE_10_S 0 + +/* TWAI_DATA_11_REG register + * Data register 11 + */ + +#define TWAI_DATA_11_REG (DR_REG_TWAI_BASE + 0x6c) + +/* TWAI_TX_BYTE_11 : WO; bitpos: [7:0]; default: 0; + * Stored the 11th byte information of the data to be transmitted under + * operating mode. + */ + +#define TWAI_TX_BYTE_11 0x000000FF +#define TWAI_TX_BYTE_11_M (TWAI_TX_BYTE_11_V << TWAI_TX_BYTE_11_S) +#define TWAI_TX_BYTE_11_V 0x000000FF +#define TWAI_TX_BYTE_11_S 0 + +/* TWAI_DATA_12_REG register + * Data register 12 + */ + +#define TWAI_DATA_12_REG (DR_REG_TWAI_BASE + 0x70) + +/* TWAI_TX_BYTE_12 : WO; bitpos: [7:0]; default: 0; + * Stored the 12th byte information of the data to be transmitted under + * operating mode. + */ + +#define TWAI_TX_BYTE_12 0x000000FF +#define TWAI_TX_BYTE_12_M (TWAI_TX_BYTE_12_V << TWAI_TX_BYTE_12_S) +#define TWAI_TX_BYTE_12_V 0x000000FF +#define TWAI_TX_BYTE_12_S 0 + +/* TWAI_RX_MESSAGE_CNT_REG register + * Receive Message Counter Register + */ + +#define TWAI_RX_MESSAGE_CNT_REG (DR_REG_TWAI_BASE + 0x74) + +/* TWAI_RX_MESSAGE_COUNTER : RO; bitpos: [6:0]; default: 0; + * This register reflects the number of messages available within the RX + * FIFO. + */ + +#define TWAI_RX_MESSAGE_COUNTER 0x0000007F +#define TWAI_RX_MESSAGE_COUNTER_M (TWAI_RX_MESSAGE_COUNTER_V << TWAI_RX_MESSAGE_COUNTER_S) +#define TWAI_RX_MESSAGE_COUNTER_V 0x0000007F +#define TWAI_RX_MESSAGE_COUNTER_S 0 + +/* TWAI_CLOCK_DIVIDER_REG register + * Clock Divider register + */ + +#define TWAI_CLOCK_DIVIDER_REG (DR_REG_TWAI_BASE + 0x7c) + +/* TWAI_CLOCK_OFF : RO | R/W; bitpos: [8]; default: 0; + * This bit can be configured under reset mode. 1: Disable the external + * CLKOUT pin; 0: Enable the external CLKOUT pin + */ + +#define TWAI_CLOCK_OFF (BIT(8)) +#define TWAI_CLOCK_OFF_M (TWAI_CLOCK_OFF_V << TWAI_CLOCK_OFF_S) +#define TWAI_CLOCK_OFF_V 0x00000001 +#define TWAI_CLOCK_OFF_S 8 + +/* TWAI_CD : R/W; bitpos: [7:0]; default: 0; + * These bits are used to configure frequency dividing coefficients of the + * external CLKOUT pin. + */ + +#define TWAI_CD 0x000000FF +#define TWAI_CD_M (TWAI_CD_V << TWAI_CD_S) +#define TWAI_CD_V 0x000000FF +#define TWAI_CD_S 0 + +#endif /* __ARCH_XTENSA_SRC_ESP32_HARDWARE_ESP32_TWAI_H */ diff --git a/arch/xtensa/src/esp32s2/Kconfig b/arch/xtensa/src/esp32s2/Kconfig index eabe497dbafd3..3f1de8c51ab96 100644 --- a/arch/xtensa/src/esp32s2/Kconfig +++ b/arch/xtensa/src/esp32s2/Kconfig @@ -92,7 +92,8 @@ config ESP32S2_INSTRUCTION_CACHE_LINE_SIZE choice ESP32S2_DATA_CACHE_SIZE prompt "Data cache size" - default ESP32S2_DATA_CACHE_0KB + default ESP32S2_DATA_CACHE_0KB if !ESP32S2_SPIRAM + default ESP32S2_DATA_CACHE_8KB if ESP32S2_SPIRAM ---help--- Data cache size to be set on application startup. If you use 0KB data cache, the other 16KB will be added to the heap. @@ -100,6 +101,7 @@ choice ESP32S2_DATA_CACHE_SIZE will be added to the heap. config ESP32S2_DATA_CACHE_0KB + depends on !ESP32S2_SPIRAM bool "No DATA CACHE" ---help--- Disable Data Cache @@ -442,6 +444,96 @@ endif endmenu # SPI Flash Configuration +menu "SPI RAM Configuration" + depends on ESP32S2_SPIRAM + +config ESP32S2_DEFAULT_PSRAM_CLK_IO + int "PSRAM CLK pin" + default 30 + +config ESP32S2_DEFAULT_PSRAM_CS_IO + int "PSRAM CS pin" + default 26 + +choice ESP32S2_SPIRAM_TYPE + prompt "Type of SPI RAM chip in use" + default ESP32S2_SPIRAM_TYPE_AUTO + +config ESP32S2_SPIRAM_TYPE_AUTO + bool "Auto-detect" + +config ESP32S2_SPIRAM_TYPE_ESPPSRAM32 + bool "ESP-PSRAM32 or IS25WP032" + +config ESP32S2_SPIRAM_TYPE_ESPPSRAM64 + bool "ESP-PSRAM64 or LY68L6400" + +endchoice # ESP32S2_SPIRAM_TYPE + +config ESP32S2_SPIRAM_SIZE + int + default -1 if ESP32S2_SPIRAM_TYPE_AUTO + default 4194304 if ESP32S2_SPIRAM_TYPE_ESPPSRAM32 + default 8388608 if ESP32S2_SPIRAM_TYPE_ESPPSRAM64 + default 0 + +config ESP32S2_SPIRAM_FETCH_INSTRUCTIONS + bool "Cache fetch instructions from SPI RAM" + default n + ---help--- + If enabled, instruction in flash will be copied into SPI RAM. + If ESP32S2_SPIRAM_RODATA is also enabled, you can run the instruction + when erasing or programming the flash. + +config ESP32S2_SPIRAM_RODATA + bool "Cache load read only data from SPI RAM" + default n + ---help--- + If enabled, rodata in flash will be copied into SPI RAM. + If ESP32S2_SPIRAM_FETCH_INSTRUCTIONS is also enabled, + you can run the instruction when erasing or programming the + flash. + +choice ESP32S2_SPIRAM_SPEED + prompt "Set RAM clock speed" + default ESP32S2_SPIRAM_SPEED_40M + ---help--- + Select the speed for the SPI RAM chip. + +config ESP32S2_SPIRAM_SPEED_40M + bool "40MHz clock speed" + +config ESP32S2_SPIRAM_SPEED_80M + bool "80MHz clock speed" + +endchoice # ESP32S2_SPIRAM_SPEED + +config ESP32S2_SPIRAM_SPEED + int + default 80 if ESP32S2_SPIRAM_SPEED_80M + default 40 if ESP32S2_SPIRAM_SPEED_40M + +config ESP32S2_SPIRAM_BOOT_INIT + bool "Initialize SPI RAM during startup" + default "y" + ---help--- + If this is enabled, the SPI RAM will be enabled during initial + boot. Unless you have specific requirements, you'll want to leave + this enabled so memory allocated during boot-up can also be + placed in SPI RAM. + +config ESP32S2_SPIRAM_IGNORE_NOTFOUND + bool "Ignore PSRAM when not found" + default "n" + depends on ESP32S2_SPIRAM_BOOT_INIT && !BOOT_SDRAM_DATA + ---help--- + Normally, if PSRAM initialization is enabled during compile time + but not found at runtime, it is seen as an error making the CPU + panic. If this is enabled, booting will complete but no PSRAM + will be available. + +endmenu # SPI RAM Configuration + menu "Real-Time Timer Configuration" depends on ESP32S2_RT_TIMER diff --git a/arch/xtensa/src/esp32s2/Make.defs b/arch/xtensa/src/esp32s2/Make.defs index 7f389613fb279..6e40fa7b4dc53 100644 --- a/arch/xtensa/src/esp32s2/Make.defs +++ b/arch/xtensa/src/esp32s2/Make.defs @@ -31,7 +31,7 @@ HEAD_CSRC = esp32s2_start.c esp32s2_wdt.c CMN_ASRCS = xtensa_context.S xtensa_coproc.S xtensa_cpuint.S xtensa_panic.S CMN_ASRCS += xtensa_sigtramp.S -CMN_CSRCS = xtensa_assert.c xtensa_blocktask.c xtensa_copystate.c +CMN_CSRCS = xtensa_assert.c xtensa_blocktask.c CMN_CSRCS += xtensa_cpenable.c xtensa_createstack.c xtensa_exit.c CMN_CSRCS += xtensa_initialize.c xtensa_initialstate.c xtensa_interruptcontext.c CMN_CSRCS += xtensa_irqdispatch.c xtensa_lowputs.c xtensa_mdelay.c @@ -40,10 +40,14 @@ CMN_CSRCS += xtensa_puts.c xtensa_releasepending.c xtensa_releasestack.c CMN_CSRCS += xtensa_reprioritizertr.c xtensa_schedsigaction.c CMN_CSRCS += xtensa_sigdeliver.c xtensa_stackframe.c xtensa_udelay.c CMN_CSRCS += xtensa_unblocktask.c xtensa_usestack.c xtensa_swint.c -CMN_CSRCS += xtensa_switchcontext.c +CMN_CSRCS += xtensa_saveusercontext.c # Configuration-dependent common XTENSA files +ifeq ($(CONFIG_DEBUG_TCBINFO),y) + CMN_CSRCS += xtensa_tcbinfo.c +endif + ifeq ($(CONFIG_DEBUG_ALERT),y) CMN_CSRCS += xtensa_dumpstate.c endif @@ -106,3 +110,8 @@ ifeq ($(CONFIG_ONESHOT),y) CHIP_CSRCS += esp32s2_oneshot_lowerhalf.c endif endif + +ifeq ($(CONFIG_ESP32S2_SPIRAM),y) +CHIP_CSRCS += esp32s2_spiram.c +CHIP_CSRCS += esp32s2_psram.c +endif diff --git a/arch/xtensa/src/esp32s2/esp32s2_oneshot_lowerhalf.c b/arch/xtensa/src/esp32s2/esp32s2_oneshot_lowerhalf.c index 78954b1001ba7..92d41c7da7664 100644 --- a/arch/xtensa/src/esp32s2/esp32s2_oneshot_lowerhalf.c +++ b/arch/xtensa/src/esp32s2/esp32s2_oneshot_lowerhalf.c @@ -115,7 +115,7 @@ static void esp32s2_oneshot_lh_handler(void *arg) struct esp32s2_oneshot_lowerhalf_s *priv = (struct esp32s2_oneshot_lowerhalf_s *)arg; oneshot_callback_t callback; - FAR void *cb_arg; + void *cb_arg; DEBUGASSERT(priv != NULL); DEBUGASSERT(priv->callback != NULL); @@ -341,7 +341,7 @@ static int oneshot_lh_current(struct oneshot_lowerhalf_s *lower, ****************************************************************************/ struct oneshot_lowerhalf_s *oneshot_initialize(int chan, - uint16_t resolution) + uint16_t resolution) { struct esp32s2_oneshot_lowerhalf_s *priv; int ret; diff --git a/arch/xtensa/src/esp32s2/esp32s2_psram.c b/arch/xtensa/src/esp32s2/esp32s2_psram.c new file mode 100644 index 0000000000000..aba01acbb0408 --- /dev/null +++ b/arch/xtensa/src/esp32s2/esp32s2_psram.c @@ -0,0 +1,725 @@ +/**************************************************************************** + * arch/xtensa/src/esp32s2/esp32s2_psram.c + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include +#include +#include +#include +#include + +#include "esp32s2_gpio.h" +#include "esp32s2_psram.h" + +#include "rom/esp32s2_spiflash.h" +#include "rom/esp32s2_opi_flash.h" +#include "hardware/esp32s2_efuse.h" +#include "hardware/esp32s2_spi.h" +#include "hardware/esp32s2_spi_mem_reg.h" +#include "hardware/esp32s2_iomux.h" +#include "hardware/esp32s2_gpio_sigmap.h" + +/**************************************************************************** + * Pre-processor Prototypes + ****************************************************************************/ + +/* EFUSE */ + +#define ESP_ROM_EFUSE_FLASH_DEFAULT_SPI (0) + +/* Commands for PSRAM chip */ + +#define PSRAM_READ 0x03 +#define PSRAM_FAST_READ 0x0B +#define PSRAM_FAST_READ_QUAD 0xEB +#define PSRAM_WRITE 0x02 +#define PSRAM_QUAD_WRITE 0x38 +#define PSRAM_ENTER_QMODE 0x35 +#define PSRAM_EXIT_QMODE 0xF5 +#define PSRAM_RESET_EN 0x66 +#define PSRAM_RESET 0x99 +#define PSRAM_SET_BURST_LEN 0xC0 +#define PSRAM_DEVICE_ID 0x9F + +#define PSRAM_FAST_READ_DUMMY 4 +#define PSRAM_FAST_READ_QUAD_DUMMY 6 + +/* ID */ + +#define PSRAM_ID_KGD_M 0xff +#define PSRAM_ID_KGD_S 8 +#define PSRAM_ID_KGD 0x5d +#define PSRAM_ID_EID_M 0xff +#define PSRAM_ID_EID_S 16 + +/* Use the [7:5](bit7~bit5) of EID to distinguish the psram size: + * + * BIT7 | BIT6 | BIT5 | SIZE(MBIT) + * ------------------------------------- + * 0 | 0 | 0 | 16 + * 0 | 0 | 1 | 32 + * 0 | 1 | 0 | 64 + */ + +#define PSRAM_EID_SIZE_M 0x07 +#define PSRAM_EID_SIZE_S 5 + +#define PSRAM_KGD(id) (((id) >> PSRAM_ID_KGD_S) & PSRAM_ID_KGD_M) +#define PSRAM_EID(id) (((id) >> PSRAM_ID_EID_S) & PSRAM_ID_EID_M) +#define PSRAM_SIZE_ID(id) ((PSRAM_EID(id) >> PSRAM_EID_SIZE_S) & PSRAM_EID_SIZE_M) +#define PSRAM_IS_VALID(id) (PSRAM_KGD(id) == PSRAM_ID_KGD) + +/* For the old version 32Mbit PSRAM, using the special driver */ + +#define PSRAM_IS_32MBIT_VER0(id) (PSRAM_EID(id) == 0x20) +#define PSRAM_IS_64MBIT_TRIAL(id) (PSRAM_EID(id) == 0x26) + +/* IO-pins for PSRAM. + * WARNING: PSRAM shares all but the CS and CLK pins with the flash, so + * these defines hardcode the flash pins as well, making this code + * incompatible with either a setup that has the flash on non-standard + * pins or ESP32S2s with built-in flash. + */ + +#define FLASH_CLK_IO SPI_CLK_GPIO_NUM +#define FLASH_CS_IO SPI_CS0_GPIO_NUM + +/* PSRAM clock and cs IO should be configured based on hardware design. */ + +#define PSRAM_CLK_IO CONFIG_ESP32S2_DEFAULT_PSRAM_CLK_IO /* Default value is 30 */ +#define PSRAM_CS_IO CONFIG_ESP32S2_DEFAULT_PSRAM_CS_IO /* Default value is 26 */ +#define PSRAM_SPIQ_SD0_IO SPI_Q_GPIO_NUM +#define PSRAM_SPID_SD1_IO SPI_D_GPIO_NUM +#define PSRAM_SPIWP_SD3_IO SPI_WP_GPIO_NUM +#define PSRAM_SPIHD_SD2_IO SPI_HD_GPIO_NUM + +#define CS_PSRAM_SEL SPI_MEM_CS1_DIS_M +#define CS_FLASH_SEL SPI_MEM_CS0_DIS_M + +#define PSRAM_IO_MATRIX_DUMMY_20M 0 +#define PSRAM_IO_MATRIX_DUMMY_40M 0 +#define PSRAM_IO_MATRIX_DUMMY_80M 0 +#define _SPI_CACHE_PORT 0 +#define _SPI_FLASH_PORT 1 +#define _SPI_80M_CLK_DIV 1 +#define _SPI_40M_CLK_DIV 2 +#define _SPI_20M_CLK_DIV 4 + +/**************************************************************************** + * Private Types + ****************************************************************************/ + +typedef enum +{ + PSRAM_CLK_MODE_NORM = 0, /* Normal SPI mode */ + PSRAM_CLK_MODE_A1C, /* ONE extra clock cycles after CS is set high level */ + PSRAM_CLK_MODE_A2C, /* Two extra clock cycles after CS is set high level */ + PSRAM_CLK_MODE_ALON, /* clock always on */ + PSRAM_CLK_MODE_MAX, +} psram_clk_mode_t; + +typedef enum +{ + PSRAM_EID_SIZE_16MBITS = 0, + PSRAM_EID_SIZE_32MBITS = 1, + PSRAM_EID_SIZE_64MBITS = 2, +} psram_eid_size_t; + +typedef struct +{ + uint8_t flash_clk_io; + uint8_t flash_cs_io; + uint8_t psram_clk_io; + uint8_t psram_cs_io; + uint8_t psram_spiq_sd0_io; + uint8_t psram_spid_sd1_io; + uint8_t psram_spiwp_sd3_io; + uint8_t psram_spihd_sd2_io; +} psram_io_t; + +#define PSRAM_IO_CONF_DEFAULT() { \ + .flash_clk_io = FLASH_CLK_IO, \ + .flash_cs_io = FLASH_CS_IO, \ + .psram_clk_io = PSRAM_CLK_IO, \ + .psram_cs_io = PSRAM_CS_IO, \ + .psram_spiq_sd0_io = PSRAM_SPIQ_SD0_IO, \ + .psram_spid_sd1_io = PSRAM_SPID_SD1_IO, \ + .psram_spiwp_sd3_io = PSRAM_SPIWP_SD3_IO, \ + .psram_spihd_sd2_io = PSRAM_SPIHD_SD2_IO, \ +} + +typedef enum +{ + PSRAM_SPI_1 = 0x1, + PSRAM_SPI_MAX , +} psram_spi_num_t; + +typedef enum +{ + PSRAM_CMD_QPI, + PSRAM_CMD_SPI, +} psram_cmd_mode_t; + +static uint32_t g_psram_id; + +static uint8_t g_psram_cs_io = UINT8_MAX; + +extern uint32_t esp_rom_efuse_get_flash_gpio_info(void); +extern uint32_t esp_rom_efuse_get_flash_wp_gpio(void); + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +static void IRAM_ATTR psram_cache_init(int psram_cache_mode, int vaddrmode); + +uint8_t psram_get_cs_io(void) +{ + return g_psram_cs_io; +} + +static void psram_set_op_mode(int spi_num, int mode) +{ + if (mode == PSRAM_CMD_QPI) + { + esp_rom_spi_set_op_mode(spi_num, ESP_ROM_SPIFLASH_QIO_MODE); + SET_PERI_REG_MASK(SPI_MEM_CTRL_REG(spi_num), SPI_MEM_FCMD_QUAD_M); + } + else if (mode == PSRAM_CMD_SPI) + { + esp_rom_spi_set_op_mode(spi_num, ESP_ROM_SPIFLASH_SLOWRD_MODE); + } +} + +static void _psram_exec_cmd(int spi_num, + uint32_t cmd, int cmd_bit_len, + uint32_t addr, int addr_bit_len, + int dummy_bits, uint8_t *mosi_data, + int mosi_bit_len, uint8_t *miso_data, + int miso_bit_len) +{ + esp_rom_spi_cmd_t conf; + uint32_t _addr = addr; + conf.addr = &_addr; + conf.addr_bit_len = addr_bit_len; + conf.cmd = cmd; + conf.cmd_bit_len = cmd_bit_len; + conf.dummy_bit_len = dummy_bits; /* There is a hw approach on chip723 */ + conf.tx_data = (uint32_t *)mosi_data; + conf.tx_data_bit_len = mosi_bit_len; + conf.rx_data = (uint32_t *)miso_data; + conf.rx_data_bit_len = miso_bit_len; + esp_rom_spi_cmd_config(spi_num, &conf); +} + +void psram_exec_cmd(int spi_num, int mode, + uint32_t cmd, int cmd_bit_len, + uint32_t addr, int addr_bit_len, + int dummy_bits, uint8_t *mosi_data, + int mosi_bit_len, uint8_t *miso_data, + int miso_bit_len, uint32_t cs_mask, + bool is_write_erase_operation) +{ + uint32_t backup_usr = READ_PERI_REG(SPI_MEM_USER_REG(spi_num)); + uint32_t backup_usr1 = READ_PERI_REG(SPI_MEM_USER1_REG(spi_num)); + uint32_t backup_usr2 = READ_PERI_REG(SPI_MEM_USER2_REG(spi_num)); + uint32_t backup_ctrl = READ_PERI_REG(SPI_MEM_CTRL_REG(spi_num)); + + psram_set_op_mode(spi_num, mode); + _psram_exec_cmd(spi_num, cmd, cmd_bit_len, addr, + addr_bit_len, dummy_bits, mosi_data, + mosi_bit_len, miso_data, miso_bit_len); + + esp_rom_spi_cmd_start(spi_num, miso_data, miso_bit_len / 8, + cs_mask, is_write_erase_operation); + + WRITE_PERI_REG(SPI_MEM_USER_REG(spi_num), backup_usr); + WRITE_PERI_REG(SPI_MEM_USER1_REG(spi_num), backup_usr1); + WRITE_PERI_REG(SPI_MEM_USER2_REG(spi_num), backup_usr2); + WRITE_PERI_REG(SPI_MEM_CTRL_REG(spi_num), backup_ctrl); +} + +/* exit QPI mode(set back to SPI mode) */ + +static void psram_disable_qio_mode(int spi_num) +{ + psram_exec_cmd(spi_num, PSRAM_CMD_QPI, + PSRAM_EXIT_QMODE, 8, /* command and command bit len */ + 0, 0, /* address and address bit len */ + 0, /* dummy bit len */ + NULL, 0, /* tx data and tx bit len */ + NULL, 0, /* rx data and rx bit len */ + CS_PSRAM_SEL, /* cs bit mask */ + false); /* if is program/erase operation */ +} + +/* switch psram burst length(32 bytes or 1024 bytes) + * datasheet says it should be 1024 bytes by default + */ + +static void psram_set_wrap_burst_length(int spi_num, psram_cmd_mode_t mode) +{ + psram_exec_cmd(spi_num, mode, + PSRAM_SET_BURST_LEN, 8, /* command and command bit len */ + 0, 0, /* address and address bit len */ + 0, /* dummy bit len */ + NULL, 0, /* tx data and tx bit len */ + NULL, 0, /* rx data and rx bit len */ + CS_PSRAM_SEL, /* cs bit mask */ + false); /* if is program/erase operation */ +} + +/* send reset command to psram, in spi mode */ + +static void psram_reset_mode(int spi_num) +{ + psram_exec_cmd(spi_num, PSRAM_CMD_SPI, + PSRAM_RESET_EN, 8, /* command and command bit len */ + 0, 0, /* address and address bit len */ + 0, /* dummy bit len */ + NULL, 0, /* tx data and tx bit len */ + NULL, 0, /* rx data and rx bit len */ + CS_PSRAM_SEL, /* cs bit mask */ + false); /* whether is program/erase operation */ + + psram_exec_cmd(spi_num, PSRAM_CMD_SPI, + PSRAM_RESET, 8, /* command and command bit len */ + 0, 0, /* address and address bit len */ + 0, /* dummy bit len */ + NULL, 0, /* tx data and tx bit len */ + NULL, 0, /* rx data and rx bit len */ + CS_PSRAM_SEL, /* cs bit mask */ + false); /* whether is program/erase operation */ +} + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +int psram_enable_wrap(uint32_t wrap_size) +{ + static uint32_t current_wrap_size; + + if (current_wrap_size == wrap_size) + { + return OK; + } + + switch (wrap_size) + { + case 0: + case 32: + psram_set_wrap_burst_length(PSRAM_SPI_1, PSRAM_CMD_QPI); + current_wrap_size = wrap_size; + return OK; + case 16: + case 64: + default: + return -EFAULT; + } +} + +bool psram_support_wrap_size(uint32_t wrap_size) +{ + switch (wrap_size) + { + case 0: + case 32: + return true; + case 16: + case 64: + default: + return false; + } +} + +/* Read ID operation only supports SPI CMD and mode, should issue + * `psram_disable_qio_mode` before calling this + */ + +static void psram_read_id(int spi_num, uint32_t *dev_id) +{ + psram_exec_cmd(spi_num, PSRAM_CMD_SPI, + PSRAM_DEVICE_ID, 8, /* command and command bit len */ + 0, 24, /* address and address bit len */ + 0, /* dummy bit len */ + NULL, 0, /* tx data and tx bit len */ + (uint8_t *) dev_id, 24, /* rx data and rx bit len */ + CS_PSRAM_SEL, /* cs bit mask */ + false); /* whether is program/erase operation */ +} + +/* enter QPI mode */ + +static void IRAM_ATTR psram_enable_qio_mode(int spi_num) +{ + psram_exec_cmd(spi_num, PSRAM_CMD_SPI, + PSRAM_ENTER_QMODE, 8, /* command and command bit len */ + 0, 0, /* address and address bit len */ + 0, /* dummy bit len */ + NULL, 0, /* tx data and tx bit len */ + NULL, 0, /* rx data and rx bit len */ + CS_PSRAM_SEL, /* cs bit mask */ + false); /* whether is program/erase operation */ +} + +static void psram_set_spi1_cmd_cs_timing(psram_clk_mode_t clk_mode) +{ + if (clk_mode == PSRAM_CLK_MODE_NORM) + { + /* SPI1 Flash Operation port */ + + SET_PERI_REG_BITS(SPI_MEM_CTRL2_REG(_SPI_FLASH_PORT), + SPI_MEM_CS_HOLD_TIME_V, 1, SPI_MEM_CS_HOLD_TIME_S); + + SET_PERI_REG_BITS(SPI_MEM_CTRL2_REG(_SPI_FLASH_PORT), + SPI_MEM_CS_SETUP_TIME_V, 0, + SPI_MEM_CS_SETUP_TIME_S); + + SET_PERI_REG_MASK(SPI_MEM_USER_REG(_SPI_FLASH_PORT), + SPI_MEM_CS_HOLD_M | SPI_MEM_CS_SETUP_M); + } + else + { + SET_PERI_REG_MASK(SPI_MEM_USER_REG(_SPI_FLASH_PORT), + SPI_MEM_CS_HOLD_M | SPI_MEM_CS_SETUP_M); + } +} + +static void psram_set_spi0_cache_cs_timing(psram_clk_mode_t clk_mode) +{ + if (clk_mode == PSRAM_CLK_MODE_NORM) + { + /* SPI0 SRAM Cache port */ + + SET_PERI_REG_BITS(SPI_MEM_SPI_SMEM_AC_REG(_SPI_CACHE_PORT), + SPI_MEM_SPI_SMEM_CS_HOLD_TIME_V, 1, + SPI_MEM_SPI_SMEM_CS_HOLD_TIME_S); + SET_PERI_REG_BITS(SPI_MEM_SPI_SMEM_AC_REG(_SPI_CACHE_PORT), + SPI_MEM_SPI_SMEM_CS_SETUP_TIME_V, 0, + SPI_MEM_SPI_SMEM_CS_SETUP_TIME_S); + SET_PERI_REG_MASK(SPI_MEM_SPI_SMEM_AC_REG(_SPI_CACHE_PORT), + SPI_MEM_SPI_SMEM_CS_HOLD_M | + SPI_MEM_SPI_SMEM_CS_SETUP_M); + + /* SPI0 Flash Cache port */ + + SET_PERI_REG_BITS(SPI_MEM_CTRL2_REG(_SPI_CACHE_PORT), + SPI_MEM_CS_HOLD_TIME_V, 0, SPI_MEM_CS_HOLD_TIME_S); + + SET_PERI_REG_BITS(SPI_MEM_CTRL2_REG(_SPI_CACHE_PORT), + SPI_MEM_CS_SETUP_TIME_V, 0, + SPI_MEM_CS_SETUP_TIME_S); + + SET_PERI_REG_MASK(SPI_MEM_USER_REG(_SPI_CACHE_PORT), + SPI_MEM_CS_HOLD_M | SPI_MEM_CS_SETUP_M); + } + else + { + CLEAR_PERI_REG_MASK(SPI_MEM_USER_REG(_SPI_CACHE_PORT), + SPI_CS_HOLD_M | SPI_CS_SETUP_M); + } +} + +/* psram gpio init, different working frequency we have different + * solutions + */ + +static void IRAM_ATTR psram_gpio_config(void) +{ + psram_io_t psram_io = PSRAM_IO_CONF_DEFAULT(); + const uint32_t spiconfig = esp_rom_efuse_get_flash_gpio_info(); + + if (spiconfig == ESP_ROM_EFUSE_FLASH_DEFAULT_SPI) + { + /* FLASH pins(except wp / hd) are all configured via IO_MUX in rom. */ + } + else + { + /* FLASH pins are all configured via GPIO matrix in ROM. */ + + psram_io.flash_clk_io = EFUSE_SPICONFIG_RET_SPICLK(spiconfig); + psram_io.flash_cs_io = EFUSE_SPICONFIG_RET_SPICS0(spiconfig); + psram_io.psram_spiq_sd0_io = EFUSE_SPICONFIG_RET_SPIQ(spiconfig); + psram_io.psram_spid_sd1_io = EFUSE_SPICONFIG_RET_SPID(spiconfig); + psram_io.psram_spihd_sd2_io = EFUSE_SPICONFIG_RET_SPIHD(spiconfig); + psram_io.psram_spiwp_sd3_io = esp_rom_efuse_get_flash_wp_gpio(); + } + + esp_rom_spiflash_select_qio_pins(psram_io.psram_spiwp_sd3_io, spiconfig); + g_psram_cs_io = psram_io.psram_cs_io; +} + +int psram_get_size(void) +{ + int psram_size = PSRAM_SIZE_ID(g_psram_id); + + if (PSRAM_IS_64MBIT_TRIAL(g_psram_id)) + { + return PSRAM_SIZE_8MB; + } + + switch (psram_size) + { + case PSRAM_EID_SIZE_64MBITS: + return PSRAM_SIZE_8MB; + + case PSRAM_EID_SIZE_32MBITS: + return PSRAM_SIZE_4MB; + + case PSRAM_EID_SIZE_16MBITS: + return PSRAM_SIZE_2MB; + + default: + return PSRAM_SIZE_16MB; + } +} + +/* used in UT only */ + +bool psram_is_32mbit_ver0(void) +{ + return PSRAM_IS_32MBIT_VER0(g_psram_id); +} + +static void psram_set_clk_mode(int spi_num, psram_clk_mode_t clk_mode) +{ + if (spi_num == _SPI_CACHE_PORT) + { + REG_SET_FIELD(SPI_MEM_SRAM_CMD_REG(0), SPI_MEM_SCLK_MODE, clk_mode); + } + else + if (spi_num == _SPI_FLASH_PORT) + { + REG_SET_FIELD(SPI_MEM_CTRL1_REG(1), SPI_MEM_CLK_MODE, clk_mode); + } +} + +/* PSRAM Mode init will overwrite original flash speed mode, so that it is + * possible to change psram and flash speed after OTA. + * Flash read mode(QIO/QOUT/DIO/DOUT) will not be changed in app bin. It is + * decided by bootloader, OTA can not change this mode. + */ + +int IRAM_ATTR psram_enable(int mode, int vaddrmode) +{ + int spi_num = PSRAM_SPI_1; + psram_clk_mode_t clk_mode = PSRAM_CLK_MODE_MAX; + + DEBUGASSERT(mode < PSRAM_CACHE_MAX); + + /* GPIO related settings */ + + psram_gpio_config(); + + /* SPI1: set spi1 clk mode, in order to send commands on SPI1 */ + + psram_set_clk_mode(_SPI_FLASH_PORT, PSRAM_CLK_MODE_A1C); + + /* SPI1: set cs timing(hold time) in order to send commands on SPI1 */ + + psram_set_spi1_cmd_cs_timing(PSRAM_CLK_MODE_A1C); + + psram_disable_qio_mode(spi_num); + psram_read_id(spi_num, &g_psram_id); + + if (!PSRAM_IS_VALID(g_psram_id)) + { + /* 16Mbit psram ID read error workaround: + * treat the first read id as a dummy one as the pre-condition, + * Send Read ID command again + */ + + psram_read_id(spi_num, &g_psram_id); + + if (!PSRAM_IS_VALID(g_psram_id)) + { + merr("PSRAM ID read error: 0x%08x", g_psram_id); + return -ENODEV; + } + } + + if (psram_is_32mbit_ver0()) + { + /* SPI1: keep clock mode and cs timing for spi1 */ + + clk_mode = PSRAM_CLK_MODE_A1C; + } + else + { + /* For other psram, we don't need any extra clock cycles after + * cs get back to high level + */ + + clk_mode = PSRAM_CLK_MODE_NORM; + + /* SPI1: set clock mode and cs timing to normal mode */ + + psram_set_clk_mode(_SPI_FLASH_PORT, PSRAM_CLK_MODE_NORM); + psram_set_spi1_cmd_cs_timing(PSRAM_CLK_MODE_NORM); + } + + /* SPI1: send psram reset command */ + + psram_reset_mode(PSRAM_SPI_1); + + /* SPI1: send QPI enable command */ + + psram_enable_qio_mode(PSRAM_SPI_1); + + /* after sending commands, set spi1 clock mode and cs timing to + * normal mode. Since all the operations are sent via SPI0 Cache + */ + + /* SPI1: set clock mode to normal mode. */ + + psram_set_clk_mode(_SPI_FLASH_PORT, PSRAM_CLK_MODE_NORM); + + /* SPI1: set cs timing to normal */ + + psram_set_spi1_cmd_cs_timing(PSRAM_CLK_MODE_NORM); + + /* SPI0: set spi0 clock mode */ + + psram_set_clk_mode(_SPI_CACHE_PORT, clk_mode); + + /* SPI0: set spi0 flash/cache cs timing */ + + psram_set_spi0_cache_cs_timing(clk_mode); + + /* SPI0: init SPI commands for Cache */ + + psram_cache_init(mode, vaddrmode); + + return OK; +} + +static void IRAM_ATTR psram_clock_set(int spi_num, int8_t freqdiv) +{ + uint32_t freqbits; + + if (1 >= freqdiv) + { + WRITE_PERI_REG(SPI_MEM_SRAM_CLK_REG(spi_num), SPI_MEM_SCLK_EQU_SYSCLK); + } + else + { + freqbits = (((freqdiv - 1) << SPI_MEM_SCLKCNT_N_S)) | + (((freqdiv / 2 - 1) << SPI_MEM_SCLKCNT_H_S)) | + (((freqdiv - 1) << SPI_MEM_SCLKCNT_L_S)); + + WRITE_PERI_REG(SPI_MEM_SRAM_CLK_REG(spi_num), freqbits); + } +} + +/* register initialization for sram cache params and r/w commands */ + +static void IRAM_ATTR psram_cache_init(int psram_cache_mode, + int vaddrmode) +{ + int extra_dummy = 0; + + switch (psram_cache_mode) + { + case PSRAM_CACHE_S80M: + psram_clock_set(0, 1); + extra_dummy = PSRAM_IO_MATRIX_DUMMY_80M; + break; + case PSRAM_CACHE_S40M: + psram_clock_set(0, 2); + extra_dummy = PSRAM_IO_MATRIX_DUMMY_40M; + break; + case PSRAM_CACHE_S26M: + psram_clock_set(0, 3); + extra_dummy = PSRAM_IO_MATRIX_DUMMY_20M; + break; + case PSRAM_CACHE_S20M: + psram_clock_set(0, 4); + extra_dummy = PSRAM_IO_MATRIX_DUMMY_20M; + break; + default: + psram_clock_set(0, 2); + break; + } + + /* disable dio mode for cache command */ + + CLEAR_PERI_REG_MASK(SPI_MEM_CACHE_SCTRL_REG(0), + SPI_MEM_USR_SRAM_DIO_M); + + /* enable qio mode for cache command */ + + SET_PERI_REG_MASK(SPI_MEM_CACHE_SCTRL_REG(0), SPI_MEM_USR_SRAM_QIO_M); + + /* enable cache read command */ + + SET_PERI_REG_MASK(SPI_MEM_CACHE_SCTRL_REG(0), + SPI_MEM_CACHE_SRAM_USR_RCMD_M); + + /* enable cache write command */ + + SET_PERI_REG_MASK(SPI_MEM_CACHE_SCTRL_REG(0), + SPI_MEM_CACHE_SRAM_USR_WCMD_M); + + /* write address for cache command */ + + SET_PERI_REG_BITS(SPI_MEM_CACHE_SCTRL_REG(0), + SPI_MEM_SRAM_ADDR_BITLEN_V, 23, + SPI_MEM_SRAM_ADDR_BITLEN_S); + + /* enable cache read dummy */ + + SET_PERI_REG_MASK(SPI_MEM_CACHE_SCTRL_REG(0), SPI_MEM_USR_RD_SRAM_DUMMY_M); + + /* config sram cache r/w command */ + + SET_PERI_REG_BITS(SPI_MEM_SRAM_DWR_CMD_REG(0), + SPI_MEM_CACHE_SRAM_USR_WR_CMD_BITLEN, 7, + SPI_MEM_CACHE_SRAM_USR_WR_CMD_BITLEN_S); + + SET_PERI_REG_BITS(SPI_MEM_SRAM_DWR_CMD_REG(0), + SPI_MEM_CACHE_SRAM_USR_WR_CMD_VALUE, PSRAM_QUAD_WRITE, + SPI_MEM_CACHE_SRAM_USR_WR_CMD_VALUE_S); /* 0x38 */ + + SET_PERI_REG_BITS(SPI_MEM_SRAM_DRD_CMD_REG(0), + SPI_MEM_CACHE_SRAM_USR_RD_CMD_BITLEN_V, 7, + SPI_MEM_CACHE_SRAM_USR_RD_CMD_BITLEN_S); + + SET_PERI_REG_BITS(SPI_MEM_SRAM_DRD_CMD_REG(0), + SPI_MEM_CACHE_SRAM_USR_RD_CMD_VALUE_V, + PSRAM_FAST_READ_QUAD, + SPI_MEM_CACHE_SRAM_USR_RD_CMD_VALUE_S); /* 0x0b */ + + /* dummy, psram cache : 40m--+1dummy,80m--+2dummy */ + + SET_PERI_REG_BITS(SPI_MEM_CACHE_SCTRL_REG(0), + SPI_MEM_SRAM_RDUMMY_CYCLELEN_V, + PSRAM_FAST_READ_QUAD_DUMMY + extra_dummy, + SPI_MEM_SRAM_RDUMMY_CYCLELEN_S); + + /* ENABLE SPI0 CS1 TO PSRAM(CS0--FLASH; CS1--SRAM) */ + + CLEAR_PERI_REG_MASK(SPI_MEM_MISC_REG(0), SPI_MEM_CS1_DIS_M); +} diff --git a/arch/xtensa/src/esp32s2/esp32s2_psram.h b/arch/xtensa/src/esp32s2/esp32s2_psram.h new file mode 100644 index 0000000000000..b56114a94229f --- /dev/null +++ b/arch/xtensa/src/esp32s2/esp32s2_psram.h @@ -0,0 +1,139 @@ +/**************************************************************************** + * arch/xtensa/src/esp32s2/esp32s2_psram.h + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#ifndef __ARCH_XTENSA_SRC_ESP32S2_ESP32S2_PSRAM_H +#define __ARCH_XTENSA_SRC_ESP32S2_ESP32S2_PSRAM_H + +#define PSRAM_SIZE_2MB (2 * 1024 * 1024) +#define PSRAM_SIZE_4MB (4 * 1024 * 1024) +#define PSRAM_SIZE_8MB (8 * 1024 * 1024) +#define PSRAM_SIZE_16MB (16 * 1024 * 1024) +#define PSRAM_SIZE_32MB (32 * 1024 * 1024) + +#define PSRAM_SIZE_16MBITS 0 +#define PSRAM_SIZE_32MBITS 1 +#define PSRAM_SIZE_64MBITS 2 +#define PSRAM_SIZE_MAX 3 + +#define PSRAM_CACHE_S80M 1 +#define PSRAM_CACHE_S40M 2 +#define PSRAM_CACHE_S26M 3 +#define PSRAM_CACHE_S20M 4 +#define PSRAM_CACHE_MAX 5 + +#define SPIRAM_WRAP_MODE_16B 0 +#define SPIRAM_WRAP_MODE_32B 1 +#define SPIRAM_WRAP_MODE_64B 2 +#define SPIRAM_WRAP_MODE_DISABLE 3 + +/* See the TRM, chapter PID/MPU/MMU, header 'External RAM' for the + * definitions of these modes. Important is that NORMAL works with the + * cache disabled. + */ + +#define PSRAM_VADDR_MODE_NORMAL 0 /* CPU use their own flash + * cache for external RAM access + */ + +/**************************************************************************** + * Public Functions Prototypes + ****************************************************************************/ + +/**************************************************************************** + * Name: psram_get_physical_size + * + * Description: + * Get the physical psram size in bytes. + * + ****************************************************************************/ + +int psram_get_physical_size(uint32_t *out_size_bytes); + +/**************************************************************************** + * Name: psram_get_available_size + * + * Description: + * Get the available physical psram size in bytes. + * + * If ECC is enabled, available PSRAM size will be 15/16 times its + * physical size. If not, it equals to the physical psram size. + * Note: For now ECC is only enabled on ESP32S2 Octal PSRAM + * + * Input Parameters: + * out_size_bytes - availabe physical psram size in bytes. + * + * Returned Value: + * 0 if success or a negative value if fail. + * + ****************************************************************************/ + +int psram_get_available_size(uint32_t *out_size_bytes); + +/**************************************************************************** + * Name: psram_get_available_size + * + * Description: + * Enable psram cache + * + * Esp-idf uses this to initialize cache for psram, mapping it into the + * main memory address space. + * + * Input Parameters: + * mode - SPI mode to access psram in. + * vaddrmode - Mode the psram cache works in. + * + * Returned Value: + * 0 if success or a negative value if fail. + * + ****************************************************************************/ + +int psram_enable(int mode, int vaddrmode); + +/**************************************************************************** + * Name: psram_get_cs_io + * + * Description: + * Get the psram CS IO + * + * Returned Value: + * The psram CS IO pin. + * + ****************************************************************************/ + +uint8_t psram_get_cs_io(void); + +/**************************************************************************** + * Name: psram_get_size + * + * Description: + * Return size of PSRAM in bytes + * + * Returned Value: + * PSRAM size in bytes + * + ****************************************************************************/ + +int psram_get_size(void); + +#endif /* __ARCH_XTENSA_SRC_ESP32S2_ESP32S2_PSRAM_H */ diff --git a/arch/xtensa/src/esp32s2/esp32s2_spiram.c b/arch/xtensa/src/esp32s2/esp32s2_spiram.c new file mode 100644 index 0000000000000..d76a636a52810 --- /dev/null +++ b/arch/xtensa/src/esp32s2/esp32s2_spiram.c @@ -0,0 +1,380 @@ +/**************************************************************************** + * arch/xtensa/src/esp32s2/esp32s2_spiram.c + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "xtensa.h" +#include "xtensa_attr.h" +#include "esp32s2_psram.h" +#include "esp32s2_spiram.h" +#include "hardware/esp32s2_soc.h" +#include "hardware/esp32s2_cache_memory.h" +#include "hardware/esp32s2_extmem.h" +#include "hardware/esp32s2_iomux.h" + +/**************************************************************************** + * Pre-processor Prototypes + ****************************************************************************/ + +#define PSRAM_MODE PSRAM_VADDR_MODE_NORMAL + +#if defined(CONFIG_ESP32S2_SPIRAM) + +#define MMU_PAGE_TO_BYTES(page_id) ((page_id) << 16) +#define BYTES_TO_MMU_PAGE(bytes) ((bytes) / MMU_PAGE_SIZE) + +#if defined(CONFIG_ESP32S2_SPIRAM_SPEED_40M) +# define PSRAM_SPEED PSRAM_CACHE_S40M +#else /* #if CONFIG_ESP32S2_SPIRAM_SPEED_80M */ +# define PSRAM_SPEED PSRAM_CACHE_S80M +#endif + +/**************************************************************************** + * Private Types + ****************************************************************************/ + +static bool g_spiram_inited; + +/* These variables are in bytes */ + +static uint32_t g_allocable_vaddr_start; +static uint32_t g_allocable_vaddr_end; +static DRAM_ATTR uint32_t g_mapped_vaddr_start; + +#if defined(CONFIG_ESP32S2_SPIRAM_FETCH_INSTRUCTIONS) +static int g_instr_flash2spiram_offs; +static uint32_t g_instr_start_page; +static uint32_t g_instr_end_page; +#endif + +#if defined(CONFIG_ESP32S2_SPIRAM_RODATA) +static int g_rodata_flash2spiram_offs; +static uint32_t g_rodata_start_page; +static uint32_t g_rodata_end_page; +#endif + +#if defined(CONFIG_ESP32S2_SPIRAM_FETCH_INSTRUCTIONS) || \ + defined(CONFIG_ESP32S2_SPIRAM_RODATA) +static uint32_t page0_mapped; +static uint32_t page0_page = INVALID_PHY_PAGE; +#endif + +/* Let's export g_mapped_size to export heap */ + +DRAM_ATTR uint32_t g_mapped_size; + +/**************************************************************************** + * ROM Function Prototypes + ****************************************************************************/ + +extern void cache_writeback_all(void); +extern uint32_t cache_suspend_dcache(void); +extern void cache_resume_dcache(uint32_t val); +extern int cache_dbus_mmu_set(uint32_t ext_ram, uint32_t vaddr, + uint32_t paddr, uint32_t psize, + uint32_t num, uint32_t fixed); + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: mmu_map_psram + * + * Description: + * Map the PSRAM to MMU + * + * Input Parameters: + * start_paddr - start of physical PSRAM address + * end_paddr - end of physical PSRAM address + * out_start_vaddr - start of virtual address + * + * Returned Value: + * Zero value (OK) on success or a negative error. + * + ****************************************************************************/ + +int mmu_map_psram(uint32_t start_paddr, uint32_t end_paddr, + uint32_t *out_start_vaddr) +{ + /* For now, this function should only run when virtual address is enough + * Decide these logics when there's a real PSRAM with larger size + */ + + uint32_t map_length = end_paddr - start_paddr; + + if (map_length > SOC_EXTRAM_DATA_SIZE) + { + /* Decide these logics when there's a real PSRAM with larger size */ + + merr("PSRAM physical size is too large, not support mapping it yet!"); + return -ENOMEM; + } + + /* should be MMU page aligned */ + + assert((start_paddr % MMU_PAGE_SIZE) == 0); + + uint32_t start_vaddr = DPORT_CACHE_ADDRESS_LOW; + uint32_t end_vaddr = start_vaddr + map_length; + uint32_t cache_bus_mask = 0; + + cache_bus_mask |= (end_vaddr > 0) ? EXTMEM_PRO_DCACHE_MASK_DPORT : 0; + cache_bus_mask |= (end_vaddr >= DPORT_ADDRESS_HIGH) ? + EXTMEM_PRO_DCACHE_MASK_DRAM1 : 0; + cache_bus_mask |= (end_vaddr >= DRAM1_ADDRESS_HIGH) ? + EXTMEM_PRO_DCACHE_MASK_DRAM0 : 0; + + assert(end_vaddr <= DRAM0_CACHE_ADDRESS_HIGH); + + minfo("start_paddr is %x, map_length is %xB, %d pages", + start_paddr, map_length, BYTES_TO_MMU_PAGE(map_length)); + + /* No need to disable cache, this file is put in Internal RAM */ + + cache_dbus_mmu_set(MMU_ACCESS_SPIRAM, start_vaddr, start_paddr, 64, + BYTES_TO_MMU_PAGE(map_length), 0); + + REG_CLR_BIT(EXTMEM_PRO_DCACHE_CTRL1_REG, cache_bus_mask); + + *out_start_vaddr = start_vaddr; + + return OK; +} + +/**************************************************************************** + * Name: mmu_map_psram + * + * Description: + * Initialize the CACHE to use with PSRAM + * + * Input Parameters: + * None + * + * Returned Value: + * None + * + ****************************************************************************/ + +void IRAM_ATTR esp_spiram_init_cache(void) +{ + int ret; + uint32_t start_page = 0; + + g_mapped_size = esp_spiram_get_size(); + + /* Map the PSRAM physical range to MMU */ + + ret = mmu_map_psram(MMU_PAGE_TO_BYTES(start_page), + MMU_PAGE_TO_BYTES(start_page) + + g_mapped_size, &g_mapped_vaddr_start); + if (ret < 0) + { + merr("MMU PSRAM mapping wrong!"); + abort(); + } + + /* After mapping, we DON'T care about the PSRAM PHYSICAL + * ADDRESSS ANYMORE! + */ + + g_allocable_vaddr_start = g_mapped_vaddr_start; + g_allocable_vaddr_end = g_mapped_vaddr_start + g_mapped_size; +} + +/**************************************************************************** + * Name: esp_spiram_test + * + * Description: + * Simple RAM test. Writes a word every 32 bytes. Takes about a second + * to complete for 4MiB. Returns true when RAM seems OK, false when test + * fails. WARNING: Do not run this before the 2nd cpu has been initialized + * (in a two-core system) or after the heap allocator has taken ownership + * of the memory. + * + * Input Parameters: + * None + * + * Returned Value: + * True on success or False on failure + * + ****************************************************************************/ + +bool esp_spiram_test(void) +{ + volatile int *spiram = (volatile int *)g_mapped_vaddr_start; + + size_t s = g_mapped_size; + size_t p; + int errct = 0; + int initial_err = -1; + + for (p = 0; p < (s / sizeof(int)); p += 8) + { + spiram[p] = p ^ 0xaaaaaaaa; + } + + for (p = 0; p < (s / sizeof(int)); p += 8) + { + if (spiram[p] != (p ^ 0xaaaaaaaa)) + { + errct++; + if (errct == 1) + { + initial_err = p * sizeof(int); + } + + if (errct < 4) + { + merr("SPI SRAM error @ %08x:%08x/%08x \n", &spiram[p], + spiram[p], p ^ 0xaaaaaaaa); + } + } + } + + if (errct != 0) + { + merr("SPI SRAM memory test fail. %d/%d writes failed, first @ %X\n", + errct, s / 32, initial_err + SOC_EXTRAM_DATA_LOW); + return false; + } + else + { + minfo("SPI SRAM memory test OK!"); + return true; + } +} + +#if defined(CONFIG_ESP32S2_SPIRAM_RODATA) +void rodata_flash_page_info_init(void) +{ + uint32_t rodata_page_cnt = ((uint32_t)&_rodata_reserved_end - + ((uint32_t)&_rodata_reserved_start & + ~ (MMU_PAGE_SIZE - 1)) + MMU_PAGE_SIZE - 1) / + MMU_PAGE_SIZE; + + g_rodata_start_page = *(volatile uint32_t *)(DR_REG_MMU_TABLE + + CACHE_DROM_MMU_START); + g_rodata_start_page &= MMU_ADDRESS_MASK; + g_rodata_end_page = g_rodata_start_page + rodata_page_cnt - 1; +} + +uint32_t IRAM_ATTR rodata_flash_start_page_get(void) +{ + return g_rodata_start_page; +} + +uint32_t IRAM_ATTR rodata_flash_end_page_get(void) +{ + return g_rodata_end_page; +} + +int IRAM_ATTR g_rodata_flash2spiram_offset(void) +{ + return g_rodata_flash2spiram_offs; +} +#endif + +int esp_spiram_init(void) +{ + int r; + size_t spiram_size; + + r = psram_enable(PSRAM_SPEED, PSRAM_MODE); + if (r != OK) + { + merr("SPI RAM enabled but initialization failed. Bailing out.\n"); + return r; + } + + g_spiram_inited = true; + + spiram_size = esp_spiram_get_size(); + +#if defined(CONFIG_ESP32S2_SPIRAM_SIZE) && (CONFIG_ESP32S2_SPIRAM_SIZE != -1) + if (spiram_size != CONFIG_ESP32S2_SPIRAM_SIZE) + { + merr("Expected %dMB chip but found %dMB chip. Bailing out..", + (CONFIG_ESP32S2_SPIRAM_SIZE / 1024 / 1024), + (spiram_size / 1024 / 1024)); + return; + } +#endif + + minfo("Found %dMB SPI RAM device\n", spiram_size / (1024 * 1024)); + minfo("Speed: %dMHz\n", CONFIG_ESP32S2_SPIRAM_SPEED); + minfo("Initialized, cache is in normal (1-core) mode.\n"); + return OK; +} + +size_t esp_spiram_get_size(void) +{ + if (!g_spiram_inited) + { + merr("SPI RAM not initialized"); + abort(); + } + + return psram_get_size(); +} + +/* Before flushing the cache, if psram is enabled as a memory-mapped thing, + * we need to write back the data in the cache to the psram first, otherwise + * it will get lost. For now, we just read 64/128K of random PSRAM memory to + * do this. + */ + +void IRAM_ATTR esp_spiram_writeback_cache(void) +{ + cache_writeback_all(); +} + +/** + * @brief If SPI RAM(PSRAM) has been initialized + * + * @return true SPI RAM has been initialized successfully + * @return false SPI RAM hasn't been initialized or initialized failed + */ + +bool esp_spiram_is_initialized(void) +{ + return g_spiram_inited; +} + +uint8_t esp_spiram_get_cs_io(void) +{ + return psram_get_cs_io(); +} + +#endif diff --git a/arch/xtensa/src/esp32s2/esp32s2_spiram.h b/arch/xtensa/src/esp32s2/esp32s2_spiram.h new file mode 100644 index 0000000000000..39b1af0f93825 --- /dev/null +++ b/arch/xtensa/src/esp32s2/esp32s2_spiram.h @@ -0,0 +1,206 @@ +/**************************************************************************** + * arch/xtensa/src/esp32s2/esp32s2_spiram.h + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#ifndef __ARCH_XTENSA_SRC_ESP32S2_ESP32S2_SPIRAM_H +#define __ARCH_XTENSA_SRC_ESP32S2_ESP32S2_SPIRAM_H + +#include +#include +#include + +#ifdef __cplusplus +extern "C" +{ +#endif + +/* @brief Initialize spiram interface/hardware. Normally called from + * cpu_start.c. + * + * @return ESP_OK on success + */ + +int esp_spiram_init(void); + +/** + * @brief Configure Cache/MMU for access to external SPI RAM. + * + * Normally this function is called from cpu_start, if + * CONFIG_SPIRAM_BOOT_INIT option is enabled. Applications which need to + * enable SPI RAM at run time can disable CONFIG_SPIRAM_BOOT_INIT, and + * call this function later. + * + * @attention this function must be called with flash cache disabled. + */ + +void esp_spiram_init_cache(void); + +/** + * @brief Memory test for SPI RAM. Should be called after SPI RAM is + * initialized and (in case of a dual-core system) the app CPU is online. + * This test overwrites the memory with crap, so do not call after e.g. the + * heap allocator has stored important stuff in SPI RAM. + * + * @return true on success, false on failed memory test + */ + +bool esp_spiram_test(void); + +/** + * @brief Add the initialized SPI RAM to the heap allocator. + */ + +int esp_spiram_add_to_heapalloc(void); + +/** + * @brief Get the available physical size of the attached SPI RAM chip + * + * @note If ECC is enabled, the available physical size would be smaller + * than the physical size. See `CONFIG_SPIRAM_ECC_ENABLE` + * + * @return Size in bytes, or 0 if no external RAM chip support compiled in. + */ + +size_t esp_spiram_get_size(void); + +/** + * @brief Force a writeback of the data in the SPI RAM cache. This is to be + * called whenever cache is disabled, because disabling cache on the ESP32 + * discards the data in the SPI RAM cache. + * + * This is meant for use from within the SPI flash code. + */ + +void esp_spiram_writeback_cache(void); + +/** + * @brief If SPI RAM(PSRAM) has been initialized + * + * @return + * - true SPI RAM has been initialized successfully + * - false SPI RAM hasn't been initialized or initialized failed + */ + +bool esp_spiram_is_initialized(void); + +/** + * @brief get psram CS IO + * + * This interface should be called after PSRAM is enabled, otherwise it will + * return an invalid value -1/0xff. + * + * @return psram CS IO or -1/0xff if psram not enabled + */ + +uint8_t esp_spiram_get_cs_io(void); + +/** + * @brief Reserve a pool of internal memory for specific DMA/internal + * allocations + * + * @param size Size of reserved pool in bytes + * + * @return + * - ESP_OK on success + * - ESP_ERR_NO_MEM when no memory available for pool + */ + +int esp_spiram_reserve_dma_pool(size_t size); + +/** + * @brief If SPI RAM(PSRAM) has been initialized + * + * @return + * - true SPI RAM has been initialized successfully + * - false SPI RAM hasn't been initialized or initialized failed + */ + +bool esp_spiram_is_initialized(void); + +#if defined(CONFIG_ESP32S2_SPIRAM_FETCH_INSTRUCTIONS) + +extern int _instruction_reserved_start; +extern int _instruction_reserved_end; + +/** + * @brief Get the start page number of the instruction in SPI flash + * + * @return start page number + */ + +uint32_t instruction_flash_start_page_get(void); + +/** + * @brief Get the end page number of the instruction in SPI flash + * + * @return end page number + */ + +uint32_t instruction_flash_end_page_get(void); + +/** + * @brief Get the offset of instruction from SPI flash to SPI RAM + * + * @return instruction offset + */ + +int instruction_flash2spiram_offset(void); + +#endif + +#if defined(CONFIG_SPIRAM_RODATA) + +extern int _rodata_reserved_start; +extern int _rodata_reserved_end; + +/** + * @brief Get the start page number of the rodata in SPI flash + * + * @return start page number + */ + +uint32_t rodata_flash_start_page_get(void); + +/** + * @brief Get the end page number of the rodata in SPI flash + * + * @return end page number + */ + +uint32_t rodata_flash_end_page_get(void); + +/** + * @brief Get the offset number of rodata from SPI flash to SPI RAM + * + * @return rodata offset + */ + +int rodata_flash2spiram_offset(void); + +#endif + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/arch/xtensa/src/esp32s2/esp32s2_start.c b/arch/xtensa/src/esp32s2/esp32s2_start.c index addf53a46cab0..eddd9fc3b4dfc 100644 --- a/arch/xtensa/src/esp32s2/esp32s2_start.c +++ b/arch/xtensa/src/esp32s2/esp32s2_start.c @@ -37,6 +37,7 @@ #include "hardware/esp32s2_extmem.h" #include "esp32s2_clockconfig.h" #include "esp32s2_region.h" +#include "esp32s2_spiram.h" #include "esp32s2_start.h" #include "esp32s2_lowputc.h" #include "esp32s2_wdt.h" @@ -110,6 +111,9 @@ typedef enum CACHE_LINE_SIZE_64B = 2, /* 64 Byte cache line size */ } cache_line_size_t; +#define CACHE_SIZE_8KB CACHE_SIZE_HALF +#define CACHE_SIZE_16KB CACHE_SIZE_FULL + /**************************************************************************** * ROM Function Prototypes ****************************************************************************/ @@ -123,13 +127,18 @@ extern int cache_ibus_mmu_set(uint32_t ext_ram, uint32_t vaddr, extern uint32_t cache_suspend_icache(void); extern void cache_resume_icache(uint32_t val); +extern void cache_invalidate_dcache_all(void); extern void cache_invalidate_icache_all(void); +extern void cache_set_dcache_mode(cache_size_t cache_size, cache_ways_t ways, + cache_line_size_t cache_line_size); extern void cache_set_icache_mode(cache_size_t cache_size, cache_ways_t ways, cache_line_size_t cache_line_size); extern void cache_allocate_sram(cache_layout_t sram0_layout, cache_layout_t sram1_layout, cache_layout_t sram2_layout, cache_layout_t sram3_layout); +extern void esp_config_data_cache_mode(void); +extern void cache_enable_dcache(uint32_t autoload); /**************************************************************************** * Private Function Prototypes @@ -160,6 +169,62 @@ uint32_t g_idlestack[IDLETHREAD_STACKWORDS] * Private Functions ****************************************************************************/ +/**************************************************************************** + * Name: esp_config_data_cache_mode + * + * Description: + * Configure the data cache mode to use with PSRAM. + * + * Input Parameters: + * None. + * + * Returned Value: + * None. + * + ****************************************************************************/ + +IRAM_ATTR void esp_config_data_cache_mode(void) +{ + cache_size_t cache_size; + cache_ways_t cache_ways; + cache_line_size_t cache_line_size; + +#if defined(CONFIG_ESP32S2_INSTRUCTION_CACHE_8KB) +#if defined(CONFIG_ESP32S2_DATA_CACHE_8KB) + cache_allocate_sram(CACHE_MEMORY_ICACHE_LOW, CACHE_MEMORY_DCACHE_LOW, + CACHE_MEMORY_INVALID, CACHE_MEMORY_INVALID); + cache_size = CACHE_SIZE_8KB; +#else + cache_allocate_sram(CACHE_MEMORY_ICACHE_LOW, CACHE_MEMORY_DCACHE_LOW, + CACHE_MEMORY_DCACHE_HIGH, CACHE_MEMORY_INVALID); + cache_size = CACHE_SIZE_16KB; +#endif +#else +#if defined(CONFIG_ESP32S2_DATA_CACHE_8KB) + cache_allocate_sram(CACHE_MEMORY_ICACHE_LOW, CACHE_MEMORY_ICACHE_HIGH, + CACHE_MEMORY_DCACHE_LOW, CACHE_MEMORY_INVALID); + cache_size = CACHE_SIZE_8KB; +#else + cache_allocate_sram(CACHE_MEMORY_ICACHE_LOW, CACHE_MEMORY_ICACHE_HIGH, + CACHE_MEMORY_DCACHE_LOW, CACHE_MEMORY_DCACHE_HIGH); + cache_size = CACHE_SIZE_16KB; +#endif +#endif + + cache_ways = CACHE_4WAYS_ASSOC; +#if defined(CONFIG_ESP32S2_DATA_CACHE_LINE_16B) + cache_line_size = CACHE_LINE_SIZE_16B; +#else + cache_line_size = CACHE_LINE_SIZE_32B; +#endif + merr("Data cache \t\t: size %dKB, %dWays, cache line size %dByte", + cache_size == CACHE_SIZE_8KB ? 8 : 16, 4, + cache_line_size == CACHE_LINE_SIZE_16B ? 16 : 32); + + cache_set_dcache_mode(cache_size, cache_ways, cache_line_size); + cache_invalidate_dcache_all(); +} + /**************************************************************************** * Name: configure_cpu_caches * @@ -196,7 +261,7 @@ static void IRAM_ATTR configure_cpu_caches(void) cache_ways = CACHE_4WAYS_ASSOC; -#ifdef CONFIG_ESP32S2_INSTRUCTION_CACHE_LINE_16B +#if defined(CONFIG_ESP32S2_INSTRUCTION_CACHE_LINE_16B) cache_line_size = CACHE_LINE_SIZE_16B; #else cache_line_size = CACHE_LINE_SIZE_32B; @@ -206,6 +271,11 @@ static void IRAM_ATTR configure_cpu_caches(void) cache_set_icache_mode(cache_size, cache_ways, cache_line_size); cache_invalidate_icache_all(); cache_resume_icache(0); + +#if defined(CONFIG_ESP32S2_SPIRAM_BOOT_INIT) + esp_config_data_cache_mode(); + cache_enable_dcache(0); +#endif } /**************************************************************************** @@ -285,6 +355,22 @@ static void noreturn_function IRAM_ATTR __esp32s2_start(void) showprogress('A'); +#if defined(CONFIG_ESP32S2_SPIRAM_BOOT_INIT) + if (esp_spiram_init() != OK) + { +# if defined(CONFIG_ESP32S2_SPIRAM_IGNORE_NOTFOUND) + mwarn("SPIRAM Initialization failed!\n"); +# else + PANIC(); +# endif + } + else + { + esp_spiram_init_cache(); + esp_spiram_test(); + } +#endif + /* Initialize onboard resources */ esp32s2_board_initialize(); diff --git a/arch/xtensa/src/esp32s2/hardware/esp32s2_efuse.h b/arch/xtensa/src/esp32s2/hardware/esp32s2_efuse.h index 0cc076b5d2cca..b02af55ef291e 100644 --- a/arch/xtensa/src/esp32s2/hardware/esp32s2_efuse.h +++ b/arch/xtensa/src/esp32s2/hardware/esp32s2_efuse.h @@ -3279,4 +3279,27 @@ #define EFUSE_EFUSE_DATE_V 0xFFFFFFFF #define EFUSE_EFUSE_DATE_S 0 +#define EFUSE_SPICONFIG_SPI_DEFAULTS 0 +#define EFUSE_SPICONFIG_HSPI_DEFAULTS 1 + +#define EFUSE_SPICONFIG_RET_SPICLK_MASK 0x3f +#define EFUSE_SPICONFIG_RET_SPICLK_SHIFT 0 +#define EFUSE_SPICONFIG_RET_SPICLK(ret) (((ret) >> EFUSE_SPICONFIG_RET_SPICLK_SHIFT) & EFUSE_SPICONFIG_RET_SPICLK_MASK) + +#define EFUSE_SPICONFIG_RET_SPIQ_MASK 0x3f +#define EFUSE_SPICONFIG_RET_SPIQ_SHIFT 6 +#define EFUSE_SPICONFIG_RET_SPIQ(ret) (((ret) >> EFUSE_SPICONFIG_RET_SPIQ_SHIFT) & EFUSE_SPICONFIG_RET_SPIQ_MASK) + +#define EFUSE_SPICONFIG_RET_SPID_MASK 0x3f +#define EFUSE_SPICONFIG_RET_SPID_SHIFT 12 +#define EFUSE_SPICONFIG_RET_SPID(ret) (((ret) >> EFUSE_SPICONFIG_RET_SPID_SHIFT) & EFUSE_SPICONFIG_RET_SPID_MASK) + +#define EFUSE_SPICONFIG_RET_SPICS0_MASK 0x3f +#define EFUSE_SPICONFIG_RET_SPICS0_SHIFT 18 +#define EFUSE_SPICONFIG_RET_SPICS0(ret) (((ret) >> EFUSE_SPICONFIG_RET_SPICS0_SHIFT) & EFUSE_SPICONFIG_RET_SPICS0_MASK) + +#define EFUSE_SPICONFIG_RET_SPIHD_MASK 0x3f +#define EFUSE_SPICONFIG_RET_SPIHD_SHIFT 24 +#define EFUSE_SPICONFIG_RET_SPIHD(ret) (((ret) >> EFUSE_SPICONFIG_RET_SPIHD_SHIFT) & EFUSE_SPICONFIG_RET_SPIHD_MASK) + #endif /* __ARCH_XTENSA_SRC_ESP32S2_HARDWARE_ESP32S2_EFUSE_H */ diff --git a/arch/xtensa/src/esp32s2/hardware/esp32s2_extmem.h b/arch/xtensa/src/esp32s2/hardware/esp32s2_extmem.h index 96873dc81e547..8c461c13dfc75 100644 --- a/arch/xtensa/src/esp32s2/hardware/esp32s2_extmem.h +++ b/arch/xtensa/src/esp32s2/hardware/esp32s2_extmem.h @@ -66,4 +66,36 @@ #define EXTMEM_PRO_ICACHE_MASK_IRAM1 EXTMEM_PRO_ICACHE_MASK_BUS1 #define EXTMEM_PRO_ICACHE_MASK_DROM0 EXTMEM_PRO_ICACHE_MASK_BUS2 +#define EXTMEM_PRO_DCACHE_CTRL1_REG (DR_REG_EXTMEM_BASE + 0x004) + +/* EXTMEM_PRO_DCACHE_MASK_BUS2 : R/W ;bitpos:[2] ;default: 1'b1 ; */ + +/* Description: The bit is used to disable dbus2 0: enable 1: disable */ + +#define EXTMEM_PRO_DCACHE_MASK_BUS2 (BIT(2)) +#define EXTMEM_PRO_DCACHE_MASK_BUS2_M (BIT(2)) +#define EXTMEM_PRO_DCACHE_MASK_BUS2_V 0x1 +#define EXTMEM_PRO_DCACHE_MASK_BUS2_S 2 + +/* EXTMEM_PRO_DCACHE_MASK_BUS1 : R/W ;bitpos:[1] ;default: 1'b1 ; */ + +/* Description: The bit is used to disable dbus1 0: enable 1: disable */ + +#define EXTMEM_PRO_DCACHE_MASK_BUS1 (BIT(1)) +#define EXTMEM_PRO_DCACHE_MASK_BUS1_M (BIT(1)) +#define EXTMEM_PRO_DCACHE_MASK_BUS1_V 0x1 +#define EXTMEM_PRO_DCACHE_MASK_BUS1_S 1 + +/* EXTMEM_PRO_DCACHE_MASK_BUS0 : R/W ;bitpos:[0] ;default: 1'b1 ; */ + +/* description: The bit is used to disable dbus0 0: enable 1: disable */ + +#define EXTMEM_PRO_DCACHE_MASK_BUS0 (BIT(0)) +#define EXTMEM_PRO_DCACHE_MASK_BUS0_M (BIT(0)) +#define EXTMEM_PRO_DCACHE_MASK_BUS0_V 0x1 +#define EXTMEM_PRO_DCACHE_MASK_BUS0_S 0 +#define EXTMEM_PRO_DCACHE_MASK_DRAM0 EXTMEM_PRO_DCACHE_MASK_BUS0 +#define EXTMEM_PRO_DCACHE_MASK_DRAM1 EXTMEM_PRO_DCACHE_MASK_BUS1 +#define EXTMEM_PRO_DCACHE_MASK_DPORT EXTMEM_PRO_DCACHE_MASK_BUS2 + #endif /* __ARCH_XTENSA_SRC_ESP32S2_HARDWARE_ESP32S2_EXTMEM_H */ diff --git a/arch/xtensa/src/esp32s2/hardware/esp32s2_soc.h b/arch/xtensa/src/esp32s2/hardware/esp32s2_soc.h index 819d2c348ffa2..4850a3a1289ca 100644 --- a/arch/xtensa/src/esp32s2/hardware/esp32s2_soc.h +++ b/arch/xtensa/src/esp32s2/hardware/esp32s2_soc.h @@ -299,6 +299,8 @@ #define SOC_EXTRAM_DATA_LOW 0x3f500000 #define SOC_EXTRAM_DATA_HIGH 0x3ff80000 +#define SOC_EXTRAM_DATA_SIZE (SOC_EXTRAM_DATA_HIGH - SOC_EXTRAM_DATA_LOW) + /* Virtual address 0 */ #define VADDR0_START_ADDR SOC_DROM_LOW diff --git a/arch/xtensa/src/esp32s2/hardware/esp32s2_spi_mem_reg.h b/arch/xtensa/src/esp32s2/hardware/esp32s2_spi_mem_reg.h new file mode 100644 index 0000000000000..ebf0f7bbebc25 --- /dev/null +++ b/arch/xtensa/src/esp32s2/hardware/esp32s2_spi_mem_reg.h @@ -0,0 +1,3165 @@ +/**************************************************************************** + * arch/xtensa/src/esp32s2/hardware/esp32s2_spi_mem_reg.h + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +#ifndef __ARCH_XTENSA_SRC_ESP32S2_HARDWARE_ESP32S2_SPI_MEM_REG_H +#define __ARCH_XTENSA_SRC_ESP32S2_HARDWARE_ESP32S2_SPI_MEM_REG_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include "esp32s2_soc.h" + +#ifdef __cplusplus +extern "C" +{ +#endif + +#define REG_SPI_MEM_BASE(i) (DR_REG_SPI0_BASE - (i) * 0x1000) + +/* SPI_MEM_FLASH_READ : R/W/SC ;bitpos:[31] ;default: 1'b0 ; */ + +/* Description: Read flash enable. Read flash operation will be triggered + * when the bit is set. The bit will be cleared once the operation done. + * 1: enable 0: disable. + */ + +#define SPI_MEM_FLASH_READ (BIT(31)) +#define SPI_MEM_FLASH_READ_M (BIT(31)) +#define SPI_MEM_FLASH_READ_V 0x1 +#define SPI_MEM_FLASH_READ_S 31 + +/* SPI_MEM_FLASH_WREN : R/W/SC ;bitpos:[30] ;default: 1'b0 ; */ + +/* Description: Write flash enable. Write enable command will be sent when + * the bit is set. The bit will be cleared once the operation done. + * 1: enable + * 0: disable. + */ + +#define SPI_MEM_FLASH_WREN (BIT(30)) +#define SPI_MEM_FLASH_WREN_M (BIT(30)) +#define SPI_MEM_FLASH_WREN_V 0x1 +#define SPI_MEM_FLASH_WREN_S 30 + +/* SPI_MEM_FLASH_WRDI : R/W/SC ;bitpos:[29] ;default: 1'b0 ; */ + +/* Description: Write flash disable. Write disable command will be sent when + * the bit is set. The bit will be cleared once the operation done. 1: enable + * 0: disable. + */ + +#define SPI_MEM_FLASH_WRDI (BIT(29)) +#define SPI_MEM_FLASH_WRDI_M (BIT(29)) +#define SPI_MEM_FLASH_WRDI_V 0x1 +#define SPI_MEM_FLASH_WRDI_S 29 + +/* SPI_MEM_FLASH_RDID : R/W/SC ;bitpos:[28] ;default: 1'b0 ; */ + +/* Description: Read JEDEC ID . Read ID command will be sent when the bit is + * set. The bit will be cleared once the operation done. + * 1: enable + * 0: disable. + */ + +#define SPI_MEM_FLASH_RDID (BIT(28)) +#define SPI_MEM_FLASH_RDID_M (BIT(28)) +#define SPI_MEM_FLASH_RDID_V 0x1 +#define SPI_MEM_FLASH_RDID_S 28 + +/* SPI_MEM_FLASH_RDSR : R/W/SC ;bitpos:[27] ;default: 1'b0 ; */ + +/* Description: Read status register-1. Read status operation will be + * triggered when the bit is set. The bit will be cleared once the operation + * done.1: enable 0: disable. + */ + +#define SPI_MEM_FLASH_RDSR (BIT(27)) +#define SPI_MEM_FLASH_RDSR_M (BIT(27)) +#define SPI_MEM_FLASH_RDSR_V 0x1 +#define SPI_MEM_FLASH_RDSR_S 27 + +/* SPI_MEM_FLASH_WRSR : R/W/SC ;bitpos:[26] ;default: 1'b0 ; */ + +/* Description: Write status register enable. Write status operation will + * be triggered when the bit is set. The bit will be cleared once the + * operation done. + * 1: enable + * 0:disable. + */ + +#define SPI_MEM_FLASH_WRSR (BIT(26)) +#define SPI_MEM_FLASH_WRSR_M (BIT(26)) +#define SPI_MEM_FLASH_WRSR_V 0x1 +#define SPI_MEM_FLASH_WRSR_S 26 + +/* SPI_MEM_FLASH_PP : R/W/SC ;bitpos:[25] ;default: 1'b0 ; */ + +/* Description: Page program enable(1 byte ~256 bytes data to be programmed). + * Page program operation will be triggered when the bit is set. The bit + * will be cleared once the operation done. + * 1: enable + * 0: disable. + */ + +#define SPI_MEM_FLASH_PP (BIT(25)) +#define SPI_MEM_FLASH_PP_M (BIT(25)) +#define SPI_MEM_FLASH_PP_V 0x1 +#define SPI_MEM_FLASH_PP_S 25 + +/* SPI_MEM_FLASH_SE : R/W/SC ;bitpos:[24] ;default: 1'b0 ; */ + +/* Description: Sector erase enable(4KB). Sector erase operation will be + * triggered when the bit is set. The bit will be cleared once the operation + * done.1: enable 0: disable. + */ + +#define SPI_MEM_FLASH_SE (BIT(24)) +#define SPI_MEM_FLASH_SE_M (BIT(24)) +#define SPI_MEM_FLASH_SE_V 0x1 +#define SPI_MEM_FLASH_SE_S 24 + +/* SPI_MEM_FLASH_BE : R/W/SC ;bitpos:[23] ;default: 1'b0 ; */ + +/* Description: Block erase enable(32KB) . Block erase operation will be + * triggered when the bit is set. The bit will be cleared once the operation + * done. + * 1: enable + * 0: disable. + */ + +#define SPI_MEM_FLASH_BE (BIT(23)) +#define SPI_MEM_FLASH_BE_M (BIT(23)) +#define SPI_MEM_FLASH_BE_V 0x1 +#define SPI_MEM_FLASH_BE_S 23 + +/* SPI_MEM_FLASH_CE : R/W/SC ;bitpos:[22] ;default: 1'b0 ; */ + +/* Description: Chip erase enable. Chip erase operation will be triggered + * when the bit is set. The bit will be cleared once the operation done. + * 1: enable + * 0: disable. + */ + +#define SPI_MEM_FLASH_CE (BIT(22)) +#define SPI_MEM_FLASH_CE_M (BIT(22)) +#define SPI_MEM_FLASH_CE_V 0x1 +#define SPI_MEM_FLASH_CE_S 22 + +/* SPI_MEM_FLASH_DP : R/W/SC ;bitpos:[21] ;default: 1'b0 ; */ + +/* Description: Drive Flash into power down. An operation will be triggered + * when the bit is set. The bit will be cleared once the operation done.1: + * enable 0: disable. + */ + +#define SPI_MEM_FLASH_DP (BIT(21)) +#define SPI_MEM_FLASH_DP_M (BIT(21)) +#define SPI_MEM_FLASH_DP_V 0x1 +#define SPI_MEM_FLASH_DP_S 21 + +/* SPI_MEM_FLASH_RES : R/W/SC ;bitpos:[20] ;default: 1'b0 ; */ + +/* Description: This bit combined with SPI_MEM_RESANDRES bit releases Flash + * from the power-down state or high performance mode and obtains the devices + * ID. The bit will be cleared once the operation done.1: enable 0: disable. + */ + +#define SPI_MEM_FLASH_RES (BIT(20)) +#define SPI_MEM_FLASH_RES_M (BIT(20)) +#define SPI_MEM_FLASH_RES_V 0x1 +#define SPI_MEM_FLASH_RES_S 20 + +/* SPI_MEM_FLASH_HPM : R/W/SC ;bitpos:[19] ;default: 1'b0 ; */ + +/* Description: Drive Flash into high performance mode. The bit will be + * cleared once the operation done.1: enable 0: disable. + */ + +#define SPI_MEM_FLASH_HPM (BIT(19)) +#define SPI_MEM_FLASH_HPM_M (BIT(19)) +#define SPI_MEM_FLASH_HPM_V 0x1 +#define SPI_MEM_FLASH_HPM_S 19 + +/* SPI_MEM_USR : R/W/SC ;bitpos:[18] ;default: 1'b0 ; */ + +/* Description: User define command enable. An operation will be triggered + * when the bit is set. The bit will be cleared once the operation done.1: + * enable 0: disable. + */ + +#define SPI_MEM_USR (BIT(18)) +#define SPI_MEM_USR_M (BIT(18)) +#define SPI_MEM_USR_V 0x1 +#define SPI_MEM_USR_S 18 + +/* SPI_MEM_FLASH_PE : R/W/SC ;bitpos:[17] ;default: 1'b0 ; */ + +/* Description: In user mode, it is set to indicate that program/erase + * operation will be triggered. The bit is combined with SPI_MEM_USR bit. The + * bit will be cleared once the operation done.1: enable 0: disable. + */ + +#define SPI_MEM_FLASH_PE (BIT(17)) +#define SPI_MEM_FLASH_PE_M (BIT(17)) +#define SPI_MEM_FLASH_PE_V 0x1 +#define SPI_MEM_FLASH_PE_S 17 + +#define SPI_MEM_ADDR_REG(i) (REG_SPI_MEM_BASE(i) + 0x4) + +/* SPI_MEM_USR_ADDR_VALUE : R/W ;bitpos:[31:0] ;default: 32'h0 ; */ + +/* Description: In user mode, it is the memory address. other then the + * bit0-bit23 is the memory address, the bit24-bit31 are the byte length of a + * transfer. + */ + +#define SPI_MEM_USR_ADDR_VALUE 0xFFFFFFFF +#define SPI_MEM_USR_ADDR_VALUE_M ((SPI_MEM_USR_ADDR_VALUE_V)<<(SPI_MEM_USR_ADDR_VALUE_S)) +#define SPI_MEM_USR_ADDR_VALUE_V 0xFFFFFFFF +#define SPI_MEM_USR_ADDR_VALUE_S 0 + +#define SPI_MEM_CTRL_REG(i) (REG_SPI_MEM_BASE(i) + 0x8) + +/* SPI_MEM_FREAD_QIO : R/W ;bitpos:[24] ;default: 1'b0 ; */ + +/* Description: In hardware 0xEB read operation, ADDR phase and DIN phase + * apply 4 signals(4-bit-mode). + * 1: enable + * 0: disable. + */ + +#define SPI_MEM_FREAD_QIO (BIT(24)) +#define SPI_MEM_FREAD_QIO_M (BIT(24)) +#define SPI_MEM_FREAD_QIO_V 0x1 +#define SPI_MEM_FREAD_QIO_S 24 + +/* SPI_MEM_FREAD_DIO : R/W ;bitpos:[23] ;default: 1'b0 ; */ + +/* Description: In hardware 0xBB read operation, ADDR phase and DIN phase + * apply 2 signals(2-bit-mode). + * 1: enable + * 0: disable. + */ + +#define SPI_MEM_FREAD_DIO (BIT(23)) +#define SPI_MEM_FREAD_DIO_M (BIT(23)) +#define SPI_MEM_FREAD_DIO_V 0x1 +#define SPI_MEM_FREAD_DIO_S 23 + +/* SPI_MEM_WRSR_2B : R/W ;bitpos:[22] ;default: 1'b0 ; */ + +/* Description: Two bytes data will be written to status register when it is + * set. + * 1: enable + * 0: disable. + */ + +#define SPI_MEM_WRSR_2B (BIT(22)) +#define SPI_MEM_WRSR_2B_M (BIT(22)) +#define SPI_MEM_WRSR_2B_V 0x1 +#define SPI_MEM_WRSR_2B_S 22 + +/* SPI_MEM_WP_REG : R/W ;bitpos:[21] ;default: 1'b1 ; */ + +/* Description: Write protect signal output when SPI is idle. + * 1: output high, + * 0: output low. + */ + +#define SPI_MEM_WP_REG (BIT(21)) +#define SPI_MEM_WP_REG_M (BIT(21)) +#define SPI_MEM_WP_REG_V 0x1 +#define SPI_MEM_WP_REG_S 21 + +/* SPI_MEM_FREAD_QUAD : R/W ;bitpos:[20] ;default: 1'b0 ; */ + +/* Description: In hardware 0x6B read operation, DIN phase apply 4 + * signals(4-bit-mode). + * 1: enable + * 0: disable. + */ + +#define SPI_MEM_FREAD_QUAD (BIT(20)) +#define SPI_MEM_FREAD_QUAD_M (BIT(20)) +#define SPI_MEM_FREAD_QUAD_V 0x1 +#define SPI_MEM_FREAD_QUAD_S 20 + +/* SPI_MEM_D_POL : R/W ;bitpos:[19] ;default: 1'b1 ; */ + +/* Description: The bit is used to set MOSI line polarity, + * 1: high + * 0: low + */ + +#define SPI_MEM_D_POL (BIT(19)) +#define SPI_MEM_D_POL_M (BIT(19)) +#define SPI_MEM_D_POL_V 0x1 +#define SPI_MEM_D_POL_S 19 + +/* SPI_MEM_Q_POL : R/W ;bitpos:[18] ;default: 1'b1 ; */ + +/* Description: The bit is used to set MISO line polarity + * 1: high + * 0: low + */ + +#define SPI_MEM_Q_POL (BIT(18)) +#define SPI_MEM_Q_POL_M (BIT(18)) +#define SPI_MEM_Q_POL_V 0x1 +#define SPI_MEM_Q_POL_S 18 + +/* SPI_MEM_RESANDRES : R/W ;bitpos:[15] ;default: 1'b1 ; */ + +/* Description: The Device ID is read out to SPI_MEM_RD_STATUS register, this + * bit combine with spi_mem_flash_res bit. + * 1: enable + * 0: disable. + */ + +#define SPI_MEM_RESANDRES (BIT(15)) +#define SPI_MEM_RESANDRES_M (BIT(15)) +#define SPI_MEM_RESANDRES_V 0x1 +#define SPI_MEM_RESANDRES_S 15 + +/* SPI_MEM_FREAD_DUAL : R/W ;bitpos:[14] ;default: 1'b0 ; */ + +/* Description: In hardware 0x3B read operation, DIN phase apply 2 signals. + * 1: enable + * 0: disable + */ + +#define SPI_MEM_FREAD_DUAL (BIT(14)) +#define SPI_MEM_FREAD_DUAL_M (BIT(14)) +#define SPI_MEM_FREAD_DUAL_V 0x1 +#define SPI_MEM_FREAD_DUAL_S 14 + +/* SPI_MEM_FASTRD_MODE : R/W ;bitpos:[13] ;default: 1'b1 ; */ + +/* Description: This bit should be set when SPI_MEM_FREAD_QIO, + * SPI_MEM_FREAD_DIO, SPI_MEM_FREAD_QUAD or SPI_MEM_FREAD_DUAL is set. + */ + +#define SPI_MEM_FASTRD_MODE (BIT(13)) +#define SPI_MEM_FASTRD_MODE_M (BIT(13)) +#define SPI_MEM_FASTRD_MODE_V 0x1 +#define SPI_MEM_FASTRD_MODE_S 13 + +/* SPI_MEM_TX_CRC_EN : R/W ;bitpos:[11] ;default: 1'b0 ; */ + +/* Description: For SPI1, enable crc32 when writing encrypted data to flash. + * 1: enable + * 0:disable + */ + +#define SPI_MEM_TX_CRC_EN (BIT(11)) +#define SPI_MEM_TX_CRC_EN_M (BIT(11)) +#define SPI_MEM_TX_CRC_EN_V 0x1 +#define SPI_MEM_TX_CRC_EN_S 11 + +/* SPI_MEM_FCS_CRC_EN : R/W ;bitpos:[10] ;default: 1'b0 ; */ + +/* Description: For SPI1, initialize crc32 module before writing encrypted + * data to flash. Active low. + */ + +#define SPI_MEM_FCS_CRC_EN (BIT(10)) +#define SPI_MEM_FCS_CRC_EN_M (BIT(10)) +#define SPI_MEM_FCS_CRC_EN_V 0x1 +#define SPI_MEM_FCS_CRC_EN_S 10 + +/* SPI_MEM_FCMD_OCT : R/W ;bitpos:[9] ;default: 1'b0 ; */ + +/* Description: Set this bit to enable 8-bit-mode(8-bm) in CMD phase. */ + +#define SPI_MEM_FCMD_OCT (BIT(9)) +#define SPI_MEM_FCMD_OCT_M (BIT(9)) +#define SPI_MEM_FCMD_OCT_V 0x1 +#define SPI_MEM_FCMD_OCT_S 9 + +/* SPI_MEM_FCMD_QUAD : R/W ;bitpos:[8] ;default: 1'b0 ; */ + +/* Description: Set this bit to enable 4-bit-mode(4-bm) in CMD phase. */ + +#define SPI_MEM_FCMD_QUAD (BIT(8)) +#define SPI_MEM_FCMD_QUAD_M (BIT(8)) +#define SPI_MEM_FCMD_QUAD_V 0x1 +#define SPI_MEM_FCMD_QUAD_S 8 + +/* SPI_MEM_FCMD_DUAL : R/W ;bitpos:[7] ;default: 1'b0 ; */ + +/* Description: Set this bit to enable 2-bit-mode(2-bm) in CMD phase. */ + +#define SPI_MEM_FCMD_DUAL (BIT(7)) +#define SPI_MEM_FCMD_DUAL_M (BIT(7)) +#define SPI_MEM_FCMD_DUAL_V 0x1 +#define SPI_MEM_FCMD_DUAL_S 7 + +/* SPI_MEM_FADDR_OCT : R/W ;bitpos:[6] ;default: 1'b0 ; */ + +/* Description: Set this bit to enable 8-bit-mode(8-bm) in ADDR phase. */ + +#define SPI_MEM_FADDR_OCT (BIT(6)) +#define SPI_MEM_FADDR_OCT_M (BIT(6)) +#define SPI_MEM_FADDR_OCT_V 0x1 +#define SPI_MEM_FADDR_OCT_S 6 + +/* SPI_MEM_FDIN_OCT : R/W ;bitpos:[5] ;default: 1'b0 ; */ + +/* Description: Set this bit to enable 8-bit-mode(8-bm) in DIN phase. */ + +#define SPI_MEM_FDIN_OCT (BIT(5)) +#define SPI_MEM_FDIN_OCT_M (BIT(5)) +#define SPI_MEM_FDIN_OCT_V 0x1 +#define SPI_MEM_FDIN_OCT_S 5 + +/* SPI_MEM_FDOUT_OCT : R/W ;bitpos:[4] ;default: 1'b0 ; */ + +/* Description: Set this bit to enable 8-bit-mode(8-bm) in DOUT phase. */ + +#define SPI_MEM_FDOUT_OCT (BIT(4)) +#define SPI_MEM_FDOUT_OCT_M (BIT(4)) +#define SPI_MEM_FDOUT_OCT_V 0x1 +#define SPI_MEM_FDOUT_OCT_S 4 + +/* SPI_MEM_FDUMMY_OUT : R/W ;bitpos:[3] ;default: 1'b0 ; */ + +/* Description: In the DUMMY phase the signal level of SPI bus is output by + * the SPI0 controller. + */ + +#define SPI_MEM_FDUMMY_OUT (BIT(3)) +#define SPI_MEM_FDUMMY_OUT_M (BIT(3)) +#define SPI_MEM_FDUMMY_OUT_V 0x1 +#define SPI_MEM_FDUMMY_OUT_S 3 + +#define SPI_MEM_CTRL1_REG(i) (REG_SPI_MEM_BASE(i) + 0xC) + +/* SPI_MEM_CS_DLY_EDGE : R/W ;bitpos:[31] ;default: 1'b0 ; */ + +/* Description: The bit is used to select the spi clock edge to modify + * CS line timing. + */ + +#define SPI_MEM_CS_DLY_EDGE (BIT(31)) +#define SPI_MEM_CS_DLY_EDGE_M (BIT(31)) +#define SPI_MEM_CS_DLY_EDGE_V 0x1 +#define SPI_MEM_CS_DLY_EDGE_S 31 + +/* SPI_MEM_CS_DLY_MODE : R/W ;bitpos:[30:28] ;default: 3'h0 ; */ + +/* Description: The cs signals are delayed by system clock cycles 0: output + * without delayed 1: output with the posedge of clk_apb 2 output with the + * negedge of clk_apb 3: output with the posedge of clk_160 4 output with + * the negedge of clk_160 5: output with the spi_clk + */ + +#define SPI_MEM_CS_DLY_MODE 0x00000007 +#define SPI_MEM_CS_DLY_MODE_M ((SPI_MEM_CS_DLY_MODE_V)<<(SPI_MEM_CS_DLY_MODE_S)) +#define SPI_MEM_CS_DLY_MODE_V 0x7 +#define SPI_MEM_CS_DLY_MODE_S 28 + +/* SPI_MEM_CS_DLY_NUM : R/W ;bitpos:[27:26] ;default: 2'h0 ; */ + +/* Description: spi_mem_cs signal is delayed by system clock cycles */ + +#define SPI_MEM_CS_DLY_NUM 0x00000003 +#define SPI_MEM_CS_DLY_NUM_M ((SPI_MEM_CS_DLY_NUM_V)<<(SPI_MEM_CS_DLY_NUM_S)) +#define SPI_MEM_CS_DLY_NUM_V 0x3 +#define SPI_MEM_CS_DLY_NUM_S 26 + +/* SPI_MEM_CS_HOLD_DLY : R/W ;bitpos:[25:14] ;default: 12'h1 ; */ + +/* Description: SPI fsm is delayed to idle by spi clock cycles. */ + +#define SPI_MEM_CS_HOLD_DLY 0x00000FFF +#define SPI_MEM_CS_HOLD_DLY_M ((SPI_MEM_CS_HOLD_DLY_V)<<(SPI_MEM_CS_HOLD_DLY_S)) +#define SPI_MEM_CS_HOLD_DLY_V 0xFFF +#define SPI_MEM_CS_HOLD_DLY_S 14 + +/* SPI_MEM_CS_HOLD_DLY_RES : R/W ;bitpos:[13:2] ;default: 12'hfff ; */ + +/* Description: Delay cycles of resume Flash when resume Flash from standby + * mode is enable by spi clock. + */ + +#define SPI_MEM_CS_HOLD_DLY_RES 0x00000FFF +#define SPI_MEM_CS_HOLD_DLY_RES_M ((SPI_MEM_CS_HOLD_DLY_RES_V)<<(SPI_MEM_CS_HOLD_DLY_RES_S)) +#define SPI_MEM_CS_HOLD_DLY_RES_V 0xFFF +#define SPI_MEM_CS_HOLD_DLY_RES_S 2 + +/* SPI_MEM_CLK_MODE : R/W ;bitpos:[1:0] ;default: 2'h0 ; */ + +/* Description: SPI Bus clock (SPI_CLK) mode bits. + * 0: SPI Bus clock (SPI_CLK) is off when CS inactive + * 1: SPI_CLK is delayed one cycle after SPI_CS inactive + * 2: SPI_CLK isdelayed two cycles after SPI_CS inactive + * 3: SPI_CLK is always on. + */ + +#define SPI_MEM_CLK_MODE 0x00000003 +#define SPI_MEM_CLK_MODE_M ((SPI_MEM_CLK_MODE_V)<<(SPI_MEM_CLK_MODE_S)) +#define SPI_MEM_CLK_MODE_V 0x3 +#define SPI_MEM_CLK_MODE_S 0 + +#define SPI_MEM_CTRL2_REG(i) (REG_SPI_MEM_BASE(i) + 0x10) + +/* SPI_MEM_SYNC_RESET : R/W/SC ;bitpos:[31] ;default: 1'b0 ; */ + +/* Description: The FSM will be reset. */ + +#define SPI_MEM_SYNC_RESET (BIT(31)) +#define SPI_MEM_SYNC_RESET_M (BIT(31)) +#define SPI_MEM_SYNC_RESET_V 0x1 +#define SPI_MEM_SYNC_RESET_S 31 + +/* SPI_MEM_CS_HOLD_TIME : R/W ;bitpos:[25:13] ;default: 13'h1 ; */ + +/* Description: SPI CS signal is delayed to inactive by SPI clock this bits + * are combined with spi_mem_cs_hold bit. + */ + +#define SPI_MEM_CS_HOLD_TIME 0x00001FFF +#define SPI_MEM_CS_HOLD_TIME_M ((SPI_MEM_CS_HOLD_TIME_V)<<(SPI_MEM_CS_HOLD_TIME_S)) +#define SPI_MEM_CS_HOLD_TIME_V 0x1FFF +#define SPI_MEM_CS_HOLD_TIME_S 13 + +/* SPI_MEM_CS_SETUP_TIME : R/W ;bitpos:[12:0] ;default: 13'h1 ; */ + +/* Description: (cycles-1) of prepare phase by spi clock this bits are + * combined with spi_mem_cs_setup bit. + */ + +#define SPI_MEM_CS_SETUP_TIME 0x00001FFF +#define SPI_MEM_CS_SETUP_TIME_M ((SPI_MEM_CS_SETUP_TIME_V)<<(SPI_MEM_CS_SETUP_TIME_S)) +#define SPI_MEM_CS_SETUP_TIME_V 0x1FFF +#define SPI_MEM_CS_SETUP_TIME_S 0 + +#define SPI_MEM_CLOCK_REG(i) (REG_SPI_MEM_BASE(i) + 0x14) + +/* SPI_MEM_CLK_EQU_SYSCLK : R/W ;bitpos:[31] ;default: 1'b0 ; */ + +/* Description: When SPI1 access to flash or Ext_RAM, set this bit in + * 1-division mode, f_SPI_CLK = f_MSPI_CORE_CLK. + */ + +#define SPI_MEM_CLK_EQU_SYSCLK (BIT(31)) +#define SPI_MEM_CLK_EQU_SYSCLK_M (BIT(31)) +#define SPI_MEM_CLK_EQU_SYSCLK_V 0x1 +#define SPI_MEM_CLK_EQU_SYSCLK_S 31 + +/* SPI_MEM_CLKCNT_N : R/W ;bitpos:[23:16] ;default: 8'h3 ; */ + +/* Description: When SPI1 accesses to flash or Ext_RAM, f_SPI_CLK = + * f_MSPI_CORE_CLK/(SPI_MEM_CLK_CNT_N + 1) + */ + +#define SPI_MEM_CLKCNT_N 0x000000FF +#define SPI_MEM_CLKCNT_N_M ((SPI_MEM_CLKCNT_N_V)<<(SPI_MEM_CLKCNT_N_S)) +#define SPI_MEM_CLKCNT_N_V 0xFF +#define SPI_MEM_CLKCNT_N_S 16 + +/* SPI_MEM_CLKCNT_H : R/W ;bitpos:[15:8] ;default: 8'h1 ; */ + +/* Description: It must be a floor value of ((SPI_MEM_CLKCNT_N+1)/2-1). */ + +#define SPI_MEM_CLKCNT_H 0x000000FF +#define SPI_MEM_CLKCNT_H_M ((SPI_MEM_CLKCNT_H_V)<<(SPI_MEM_CLKCNT_H_S)) +#define SPI_MEM_CLKCNT_H_V 0xFF +#define SPI_MEM_CLKCNT_H_S 8 + +/* SPI_MEM_CLKCNT_L : R/W ;bitpos:[7:0] ;default: 8'h3 ; */ + +/* Description: It must equal to the value of SPI_MEM_CLKCNT_N. */ + +#define SPI_MEM_CLKCNT_L 0x000000FF +#define SPI_MEM_CLKCNT_L_M ((SPI_MEM_CLKCNT_L_V)<<(SPI_MEM_CLKCNT_L_S)) +#define SPI_MEM_CLKCNT_L_V 0xFF +#define SPI_MEM_CLKCNT_L_S 0 + +#define SPI_MEM_USER_REG(i) (REG_SPI_MEM_BASE(i) + 0x18) + +/* SPI_MEM_USR_COMMAND : R/W ;bitpos:[31] ;default: 1'b1 ; */ + +/* Description: Set this bit to enable enable the CMD phase of an + * operation. + */ + +#define SPI_MEM_USR_COMMAND (BIT(31)) +#define SPI_MEM_USR_COMMAND_M (BIT(31)) +#define SPI_MEM_USR_COMMAND_V 0x1 +#define SPI_MEM_USR_COMMAND_S 31 + +/* SPI_MEM_USR_ADDR : R/W ;bitpos:[30] ;default: 1'b0 ; */ + +/* Description: Set this bit to enable enable the ADDR phase of an operation. + */ + +#define SPI_MEM_USR_ADDR (BIT(30)) +#define SPI_MEM_USR_ADDR_M (BIT(30)) +#define SPI_MEM_USR_ADDR_V 0x1 +#define SPI_MEM_USR_ADDR_S 30 + +/* SPI_MEM_USR_DUMMY : R/W ;bitpos:[29] ;default: 1'b0 ; */ + +/* Description: Set this bit to enable enable the DUMMY phase of an + * operation. + */ + +#define SPI_MEM_USR_DUMMY (BIT(29)) +#define SPI_MEM_USR_DUMMY_M (BIT(29)) +#define SPI_MEM_USR_DUMMY_V 0x1 +#define SPI_MEM_USR_DUMMY_S 29 + +/* SPI_MEM_USR_MISO : R/W ;bitpos:[28] ;default: 1'b0 ; */ + +/* Description: Set this bit to enable enable the DIN phase of a read-data + * operation. + */ + +#define SPI_MEM_USR_MISO (BIT(28)) +#define SPI_MEM_USR_MISO_M (BIT(28)) +#define SPI_MEM_USR_MISO_V 0x1 +#define SPI_MEM_USR_MISO_S 28 + +/* SPI_MEM_USR_MOSI : R/W ;bitpos:[27] ;default: 1'b0 ; */ + +/* Description: Set this bit to enable the DOUT phase of an write-data + * operation. + */ + +#define SPI_MEM_USR_MOSI (BIT(27)) +#define SPI_MEM_USR_MOSI_M (BIT(27)) +#define SPI_MEM_USR_MOSI_V 0x1 +#define SPI_MEM_USR_MOSI_S 27 + +/* SPI_MEM_USR_DUMMY_IDLE : R/W ;bitpos:[26] ;default: 1'b0 ; */ + +/* Description: SPI_CLK is disabled(No clock edges) in DUMMY phase when the + * bit is enable. + */ + +#define SPI_MEM_USR_DUMMY_IDLE (BIT(26)) +#define SPI_MEM_USR_DUMMY_IDLE_M (BIT(26)) +#define SPI_MEM_USR_DUMMY_IDLE_V 0x1 +#define SPI_MEM_USR_DUMMY_IDLE_S 26 + +/* SPI_MEM_USR_MOSI_HIGHPART : R/W ;bitpos:[25] ;default: 1'b0 ; */ + +/* Description: DOUT phase only access to high-part of the buffer + * SPI_MEM_W8_REG~SPI_MEM_W15_REG. + * 1: enable + * 0: disable. + */ + +#define SPI_MEM_USR_MOSI_HIGHPART (BIT(25)) +#define SPI_MEM_USR_MOSI_HIGHPART_M (BIT(25)) +#define SPI_MEM_USR_MOSI_HIGHPART_V 0x1 +#define SPI_MEM_USR_MOSI_HIGHPART_S 25 + +/* SPI_MEM_USR_MISO_HIGHPART : R/W ;bitpos:[24] ;default: 1'b0 ; */ + +/* Description: DIN phase only access to high-part of the buffer + * SPI_MEM_W8_REG~SPI_MEM_W15_REG. + * 1: enable + * 0: disable. + */ + +#define SPI_MEM_USR_MISO_HIGHPART (BIT(24)) +#define SPI_MEM_USR_MISO_HIGHPART_M (BIT(24)) +#define SPI_MEM_USR_MISO_HIGHPART_V 0x1 +#define SPI_MEM_USR_MISO_HIGHPART_S 24 + +/* SPI_MEM_FWRITE_QIO : R/W ;bitpos:[15] ;default: 1'b0 ; */ + +/* Description: Set this bit to enable 4-bit-mode(4-bm) in ADDR and DOUT + * phase in SPI1 write operation. + */ + +#define SPI_MEM_FWRITE_QIO (BIT(15)) +#define SPI_MEM_FWRITE_QIO_M (BIT(15)) +#define SPI_MEM_FWRITE_QIO_V 0x1 +#define SPI_MEM_FWRITE_QIO_S 15 + +/* SPI_MEM_FWRITE_DIO : R/W ;bitpos:[14] ;default: 1'b0 ; */ + +/* Description: Set this bit to enable 2-bm in ADDR and DOUT phase in SPI1 + * write operation. + */ + +#define SPI_MEM_FWRITE_DIO (BIT(14)) +#define SPI_MEM_FWRITE_DIO_M (BIT(14)) +#define SPI_MEM_FWRITE_DIO_V 0x1 +#define SPI_MEM_FWRITE_DIO_S 14 + +/* SPI_MEM_FWRITE_QUAD : R/W ;bitpos:[13] ;default: 1'b0 ; */ + +/* Description: Set this bit to enable 4-bm in DOUT phase in SPI1 write + * operation. + */ + +#define SPI_MEM_FWRITE_QUAD (BIT(13)) +#define SPI_MEM_FWRITE_QUAD_M (BIT(13)) +#define SPI_MEM_FWRITE_QUAD_V 0x1 +#define SPI_MEM_FWRITE_QUAD_S 13 + +/* SPI_MEM_FWRITE_DUAL : R/W ;bitpos:[12] ;default: 1'b0 ; */ + +/* Description: Set this bit to enable 2-bm in DOUT phase in SPI1 write + * operation. + */ + +#define SPI_MEM_FWRITE_DUAL (BIT(12)) +#define SPI_MEM_FWRITE_DUAL_M (BIT(12)) +#define SPI_MEM_FWRITE_DUAL_V 0x1 +#define SPI_MEM_FWRITE_DUAL_S 12 + +/* SPI_MEM_CK_OUT_EDGE : R/W ;bitpos:[9] ;default: 1'b0 ; */ + +/* Description: This bit, combined with SPI_MEM_CK_IDLE_EDGE bit, is used to + * change the clock mode 0~3 of SPI_CLK. + */ + +#define SPI_MEM_CK_OUT_EDGE (BIT(9)) +#define SPI_MEM_CK_OUT_EDGE_M (BIT(9)) +#define SPI_MEM_CK_OUT_EDGE_V 0x1 +#define SPI_MEM_CK_OUT_EDGE_S 9 + +/* SPI_MEM_CS_SETUP : R/W ;bitpos:[7] ;default: 1'b0 ; */ + +/* Description: Set this bit to keep SPI_CS low when MSPI is in PREP state. */ + +#define SPI_MEM_CS_SETUP (BIT(7)) +#define SPI_MEM_CS_SETUP_M (BIT(7)) +#define SPI_MEM_CS_SETUP_V 0x1 +#define SPI_MEM_CS_SETUP_S 7 + +/* SPI_MEM_CS_HOLD : R/W ;bitpos:[6] ;default: 1'b0 ; */ + +/* Description: Set this bit to keep SPI_CS low when MSPI is in DONE state. */ + +#define SPI_MEM_CS_HOLD (BIT(6)) +#define SPI_MEM_CS_HOLD_M (BIT(6)) +#define SPI_MEM_CS_HOLD_V 0x1 +#define SPI_MEM_CS_HOLD_S 6 + +#define SPI_MEM_USER1_REG(i) (REG_SPI_MEM_BASE(i) + 0x1C) + +/* SPI_MEM_USR_ADDR_BITLEN : R/W ;bitpos:[31:26] ;default: 6'd23 ; */ + +/* Description: The length in bits of ADDR phase. The register value shall be + * (bit_num-1). + */ + +#define SPI_MEM_USR_ADDR_BITLEN 0x0000003F +#define SPI_MEM_USR_ADDR_BITLEN_M ((SPI_MEM_USR_ADDR_BITLEN_V)<<(SPI_MEM_USR_ADDR_BITLEN_S)) +#define SPI_MEM_USR_ADDR_BITLEN_V 0x3F +#define SPI_MEM_USR_ADDR_BITLEN_S 26 + +/* SPI_MEM_USR_DUMMY_CYCLELEN : R/W ;bitpos:[5:0] ;default: 6'd7 ; */ + +/* Description: The SPI_CLK cycle length minus 1 of DUMMY phase. */ + +#define SPI_MEM_USR_DUMMY_CYCLELEN 0x000000FF +#define SPI_MEM_USR_DUMMY_CYCLELEN_M ((SPI_MEM_USR_DUMMY_CYCLELEN_V)<<(SPI_MEM_USR_DUMMY_CYCLELEN_S)) +#define SPI_MEM_USR_DUMMY_CYCLELEN_V 0xFF +#define SPI_MEM_USR_DUMMY_CYCLELEN_S 0 + +#define SPI_MEM_USER2_REG(i) (REG_SPI_MEM_BASE(i) + 0x20) + +/* SPI_MEM_USR_COMMAND_BITLEN : R/W ;bitpos:[31:28] ;default: 4'd7 ; */ + +/* Description: The length in bits of CMD phase. The register value shall be + * (bit_num-1) + */ + +#define SPI_MEM_USR_COMMAND_BITLEN 0x0000000F +#define SPI_MEM_USR_COMMAND_BITLEN_M ((SPI_MEM_USR_COMMAND_BITLEN_V)<<(SPI_MEM_USR_COMMAND_BITLEN_S)) +#define SPI_MEM_USR_COMMAND_BITLEN_V 0xF +#define SPI_MEM_USR_COMMAND_BITLEN_S 28 + +/* SPI_MEM_USR_COMMAND_VALUE : R/W ;bitpos:[15:0] ;default: 16'b0 ; */ + +/* Description: The value of user defined(USR) command. */ + +#define SPI_MEM_USR_COMMAND_VALUE 0x0000FFFF +#define SPI_MEM_USR_COMMAND_VALUE_M ((SPI_MEM_USR_COMMAND_VALUE_V)<<(SPI_MEM_USR_COMMAND_VALUE_S)) +#define SPI_MEM_USR_COMMAND_VALUE_V 0xFFFF +#define SPI_MEM_USR_COMMAND_VALUE_S 0 + +#define SPI_MEM_MOSI_DLEN_REG(i) (REG_SPI_MEM_BASE(i) + 0x24) + +/* SPI_MEM_USR_MOSI_DBITLEN : R/W ;bitpos:[9:0] ;default: 10'h0 ; */ + +/* Description: The length in bits of DOUT phase. The register value shall be + * (bit_num-1). + */ + +#define SPI_MEM_USR_MOSI_DBITLEN 0x000007FF +#define SPI_MEM_USR_MOSI_DBITLEN_M ((SPI_MEM_USR_MOSI_DBITLEN_V)<<(SPI_MEM_USR_MOSI_DBITLEN_S)) +#define SPI_MEM_USR_MOSI_DBITLEN_V 0x7FF +#define SPI_MEM_USR_MOSI_DBITLEN_S 0 + +#define SPI_MEM_MISO_DLEN_REG(i) (REG_SPI_MEM_BASE(i) + 0x28) + +/* SPI_MEM_USR_MISO_DBITLEN : R/W ;bitpos:[9:0] ;default: 10'h0 ; */ + +/* Description: The length in bits of DIN phase. The register value shall be + * (bit_num-1). + */ + +#define SPI_MEM_USR_MISO_DBITLEN 0x000007FF +#define SPI_MEM_USR_MISO_DBITLEN_M ((SPI_MEM_USR_MISO_DBITLEN_V)<<(SPI_MEM_USR_MISO_DBITLEN_S)) +#define SPI_MEM_USR_MISO_DBITLEN_V 0x7FF +#define SPI_MEM_USR_MISO_DBITLEN_S 0 + +#define SPI_MEM_RD_STATUS_REG(i) (REG_SPI_MEM_BASE(i) + 0x2C) + +/* SPI_MEM_WB_MODE : R/W ;bitpos:[23:16] ;default: 8'h00 ; */ + +/* Description: Mode bits in the flash fast read mode it is combined with + * SPI_MEM_FASTRD_MODE bit. + */ + +#define SPI_MEM_WB_MODE 0x000000FF +#define SPI_MEM_WB_MODE_M ((SPI_MEM_WB_MODE_V)<<(SPI_MEM_WB_MODE_S)) +#define SPI_MEM_WB_MODE_V 0xFF +#define SPI_MEM_WB_MODE_S 16 + +/* SPI_MEM_STATUS : R/W/SS ;bitpos:[15:0] ;default: 16'b0 ; */ + +/* Description: The value is stored when set SPI_MEM_FLASH_RDSR bit and + * SPI_MEM_FLASH_RES bit. + */ + +#define SPI_MEM_STATUS 0x0000FFFF +#define SPI_MEM_STATUS_M ((SPI_MEM_STATUS_V)<<(SPI_MEM_STATUS_S)) +#define SPI_MEM_STATUS_V 0xFFFF +#define SPI_MEM_STATUS_S 0 + +#define SPI_MEM_EXT_ADDR_REG(i) (REG_SPI_MEM_BASE(i) + 0x30) + +/* SPI_MEM_EXT_ADDR : R/W ;bitpos:[31:0] ;default: 32'b0 ; */ + +/* Description: The register are the higher 32bits in the 64 bits address + * mode. + */ + +#define SPI_MEM_EXT_ADDR 0xFFFFFFFF +#define SPI_MEM_EXT_ADDR_M ((SPI_MEM_EXT_ADDR_V)<<(SPI_MEM_EXT_ADDR_S)) +#define SPI_MEM_EXT_ADDR_V 0xFFFFFFFF +#define SPI_MEM_EXT_ADDR_S 0 + +#define SPI_MEM_MISC_REG(i) (REG_SPI_MEM_BASE(i) + 0x34) + +/* SPI_MEM_AUTO_PER : R/W ;bitpos:[11] ;default: 1'b0 ; */ + +/* Description: Set this bit to enable auto PER function. Hardware will sent + * out PER command if PES command is sent. + */ + +#define SPI_MEM_AUTO_PER (BIT(11)) +#define SPI_MEM_AUTO_PER_M (BIT(11)) +#define SPI_MEM_AUTO_PER_V 0x1 +#define SPI_MEM_AUTO_PER_S 11 + +/* SPI_MEM_CS_KEEP_ACTIVE : R/W ;bitpos:[10] ;default: 1'b0 ; */ + +/* Description: SPI_CS line keep low when the bit is set. */ + +#define SPI_MEM_CS_KEEP_ACTIVE (BIT(10)) +#define SPI_MEM_CS_KEEP_ACTIVE_M (BIT(10)) +#define SPI_MEM_CS_KEEP_ACTIVE_V 0x1 +#define SPI_MEM_CS_KEEP_ACTIVE_S 10 + +/* SPI_MEM_CK_IDLE_EDGE : R/W ;bitpos:[9] ;default: 1'b0 ; */ + +/* Description: + * 1: SPI_CLK line is high when MSPI is idle. + * 0: SPI_CLK line is low when MSPI is idle. + */ + +#define SPI_MEM_CK_IDLE_EDGE (BIT(9)) +#define SPI_MEM_CK_IDLE_EDGE_M (BIT(9)) +#define SPI_MEM_CK_IDLE_EDGE_V 0x1 +#define SPI_MEM_CK_IDLE_EDGE_S 9 + +/* SPI_MEM_SSUB_PIN : R/W ;bitpos:[8] ;default: 1'b0 ; */ + +/* Description: Ext_RAM is connected to SPI SUBPIN bus. */ + +#define SPI_MEM_SSUB_PIN (BIT(8)) +#define SPI_MEM_SSUB_PIN_M (BIT(8)) +#define SPI_MEM_SSUB_PIN_V 0x1 +#define SPI_MEM_SSUB_PIN_S 8 + +/* SPI_MEM_FSUB_PIN : R/W ;bitpos:[7] ;default: 1'b0 ; */ + +/* Description: Flash is connected to SPI SUBPIN bus. */ + +#define SPI_MEM_FSUB_PIN (BIT(7)) +#define SPI_MEM_FSUB_PIN_M (BIT(7)) +#define SPI_MEM_FSUB_PIN_V 0x1 +#define SPI_MEM_FSUB_PIN_S 7 + +/* SPI_MEM_CS_POL : R/W ;bitpos:[6:5] ;default: 2'b0 ; */ + +/* Description: In the master mode the bits are the polarity of spi cs line + * the value is equivalent to spi_mem_cs ^ spi_mem_master_cs_pol. + */ + +#define SPI_MEM_CS_POL 0x00000003 +#define SPI_MEM_CS_POL_M ((SPI_MEM_CS_POL_V)<<(SPI_MEM_CS_POL_S)) +#define SPI_MEM_CS_POL_V 0x3 +#define SPI_MEM_CS_POL_S 5 + +/* SPI_MEM_TRANS_END_INT_ENA : R/W ;bitpos:[4] ;default: 1'b0 ; */ + +/* Description: The bit is used to enable the intterrupt of SPI + * transmitting done. + */ + +#define SPI_MEM_TRANS_END_INT_ENA (BIT(4)) +#define SPI_MEM_TRANS_END_INT_ENA_M (BIT(4)) +#define SPI_MEM_TRANS_END_INT_ENA_V 0x1 +#define SPI_MEM_TRANS_END_INT_ENA_S 4 + +/* SPI_MEM_TRANS_END : R/W ;bitpos:[3] ;default: 1'b0 ; */ + +/* Description: The bit is used to indicate the transimitting is done. */ + +#define SPI_MEM_TRANS_END (BIT(3)) +#define SPI_MEM_TRANS_END_M (BIT(3)) +#define SPI_MEM_TRANS_END_V 0x1 +#define SPI_MEM_TRANS_END_S 3 + +/* SPI_MEM_CS1_DIS : R/W ;bitpos:[1] ;default: 1'b1 ; */ + +/* Description: SPI CS1 pin enable + * 1: disable CS1 + * 0: spi_mem_cs1 signal is from/to CS1 pin + */ + +#define SPI_MEM_CS1_DIS (BIT(1)) +#define SPI_MEM_CS1_DIS_M (BIT(1)) +#define SPI_MEM_CS1_DIS_V 0x1 +#define SPI_MEM_CS1_DIS_S 1 + +/* SPI_MEM_CS0_DIS : R/W ;bitpos:[0] ;default: 1'b0 ; */ + +/* Description: Set this bit to raise high SPI_CS pin, which means that the + * SPI device(flash) connected to SPI_CS is in low level when SPI1 transfer + * starts. + */ + +#define SPI_MEM_CS0_DIS (BIT(0)) +#define SPI_MEM_CS0_DIS_M (BIT(0)) +#define SPI_MEM_CS0_DIS_V 0x1 +#define SPI_MEM_CS0_DIS_S 0 + +#define SPI_MEM_TX_CRC_REG(i) (REG_SPI_MEM_BASE(i) + 0x38) + +/* SPI_MEM_TX_CRC_DATA : RO ;bitpos:[31:0] ;default: 32'hffffffff ; */ + +/* Description: For SPI1, the value of crc32. */ + +#define SPI_MEM_TX_CRC_DATA 0xFFFFFFFF +#define SPI_MEM_TX_CRC_DATA_M ((SPI_MEM_TX_CRC_DATA_V)<<(SPI_MEM_TX_CRC_DATA_S)) +#define SPI_MEM_TX_CRC_DATA_V 0xFFFFFFFF +#define SPI_MEM_TX_CRC_DATA_S 0 + +#define SPI_MEM_CACHE_FCTRL_REG(i) (REG_SPI_MEM_BASE(i) + 0x3C) + +/* SPI_MEM_FADDR_QUAD : R/W ;bitpos:[8] ;default: 1'b0 ; */ + +/* Description: When SPI1 accesses to flash or Ext_RAM, set this bit to + * enable 4-bm in ADDR phase. + */ + +#define SPI_MEM_FADDR_QUAD (BIT(8)) +#define SPI_MEM_FADDR_QUAD_M (BIT(8)) +#define SPI_MEM_FADDR_QUAD_V 0x1 +#define SPI_MEM_FADDR_QUAD_S 8 + +/* SPI_MEM_FDOUT_QUAD : R/W ;bitpos:[7] ;default: 1'b0 ; */ + +/* Description: When SPI1 accesses to flash or Ext_RAM, set this bit to + * enable 4-bm in DOUT phase. + */ + +#define SPI_MEM_FDOUT_QUAD (BIT(7)) +#define SPI_MEM_FDOUT_QUAD_M (BIT(7)) +#define SPI_MEM_FDOUT_QUAD_V 0x1 +#define SPI_MEM_FDOUT_QUAD_S 7 + +/* SPI_MEM_FDIN_QUAD : R/W ;bitpos:[6] ;default: 1'b0 ; */ + +/* Description: When SPI1 accesses to flash or Ext_RAM, set this bit to + * enable 4-bm in DIN phase. + */ + +#define SPI_MEM_FDIN_QUAD (BIT(6)) +#define SPI_MEM_FDIN_QUAD_M (BIT(6)) +#define SPI_MEM_FDIN_QUAD_V 0x1 +#define SPI_MEM_FDIN_QUAD_S 6 + +/* SPI_MEM_FADDR_DUAL : R/W ;bitpos:[5] ;default: 1'b0 ; */ + +/* Description: When SPI0 accesses to flash or Ext_RAM, set this bit to + * enable 2-bm in ADDR phase. + */ + +#define SPI_MEM_FADDR_DUAL (BIT(5)) +#define SPI_MEM_FADDR_DUAL_M (BIT(5)) +#define SPI_MEM_FADDR_DUAL_V 0x1 +#define SPI_MEM_FADDR_DUAL_S 5 + +/* SPI_MEM_FDOUT_DUAL : R/W ;bitpos:[4] ;default: 1'b0 ; */ + +/* Description: When SPI1 accesses to flash or Ext_RAM, set this bit to + * enable 2-bm in DOUT phase. + */ + +#define SPI_MEM_FDOUT_DUAL (BIT(4)) +#define SPI_MEM_FDOUT_DUAL_M (BIT(4)) +#define SPI_MEM_FDOUT_DUAL_V 0x1 +#define SPI_MEM_FDOUT_DUAL_S 4 + +/* SPI_MEM_FDIN_DUAL : R/W ;bitpos:[3] ;default: 1'b0 ; */ + +/* Description: When SPI0 accesses to flash or Ext_RAM, set this bit to + * enable 2-bm in DIN phase. + */ + +#define SPI_MEM_FDIN_DUAL (BIT(3)) +#define SPI_MEM_FDIN_DUAL_M (BIT(3)) +#define SPI_MEM_FDIN_DUAL_V 0x1 +#define SPI_MEM_FDIN_DUAL_S 3 + +/* SPI_MEM_CACHE_FLASH_USR_CMD : R/W ;bitpos:[2] ;default: 1'b0 ; */ + +/* Description: + * 1: The command value of SPI0 reads flash is SPI_MEM_USR_COMMAND_VALUE. + * 0: Hardware read command value, controlled by SPI_MEM_FREAD_QIO, + * SPI_MEM_FREAD_DIO, SPI_MEM_FREAD_QUAD, SPI_MEM_FREAD_DUAL and + * SPI_MEM_FASTRD_MODE bits. + */ + +#define SPI_MEM_CACHE_FLASH_USR_CMD (BIT(2)) +#define SPI_MEM_CACHE_FLASH_USR_CMD_M (BIT(2)) +#define SPI_MEM_CACHE_FLASH_USR_CMD_V 0x1 +#define SPI_MEM_CACHE_FLASH_USR_CMD_S 2 + +/* SPI_MEM_CACHE_USR_CMD_4BYTE : R/W ;bitpos:[1] ;default: 1'b0 ; */ + +/* Description: + * Set this bit to enable SPI0 transfer with 32 bits address. The value of + * SPI_MEM_USR_ADDR_BITLEN should be 31. + */ + +#define SPI_MEM_CACHE_USR_CMD_4BYTE (BIT(1)) +#define SPI_MEM_CACHE_USR_CMD_4BYTE_M (BIT(1)) +#define SPI_MEM_CACHE_USR_CMD_4BYTE_V 0x1 +#define SPI_MEM_CACHE_USR_CMD_4BYTE_S 1 + +/* SPI_MEM_CACHE_REQ_EN : R/W ;bitpos:[0] ;default: 1'b0 ; */ + +/* Description: Set this bit to enable Cache's access and SPI0's transfer. */ + +#define SPI_MEM_CACHE_REQ_EN (BIT(0)) +#define SPI_MEM_CACHE_REQ_EN_M (BIT(0)) +#define SPI_MEM_CACHE_REQ_EN_V 0x1 +#define SPI_MEM_CACHE_REQ_EN_S 0 + +#define SPI_MEM_CACHE_SCTRL_REG(i) (REG_SPI_MEM_BASE(i) + 0x40) + +/* SPI_MEM_SRAM_WDUMMY_CYCLELEN : R/W ;bitpos:[27:22] ;default: 6'b1 ; */ + +/* Description: When SPI0 accesses to Ext_RAM, it is the SPI_CLK cycles minus + * 1 of DUMMY phase in write data transfer. + */ + +#define SPI_MEM_SRAM_WDUMMY_CYCLELEN 0x000000FF +#define SPI_MEM_SRAM_WDUMMY_CYCLELEN_M ((SPI_MEM_SRAM_WDUMMY_CYCLELEN_V)<<(SPI_MEM_SRAM_WDUMMY_CYCLELEN_S)) +#define SPI_MEM_SRAM_WDUMMY_CYCLELEN_V 0xFF +#define SPI_MEM_SRAM_WDUMMY_CYCLELEN_S 22 + +/* SPI_MEM_SRAM_OCT : R/W ;bitpos:[21] ;default: 1'b0 ; */ + +/* Description: Set the bit to enable OPI mode in all SPI0 Ext_RAM + * transfer. + */ + +#define SPI_MEM_SRAM_OCT (BIT(21)) +#define SPI_MEM_SRAM_OCT_M (BIT(21)) +#define SPI_MEM_SRAM_OCT_V 0x1 +#define SPI_MEM_SRAM_OCT_S 21 + +/* SPI_MEM_CACHE_SRAM_USR_WCMD : R/W ;bitpos:[20] ;default: 1'b1 ; */ + +/* Description: + * 1: The command value of SPI0 write Ext_RAM is + * SPI_MEM_CACHE_SRAM_USR_RD_CMD_VALUE. + * 0: The value is 0x3. + */ + +#define SPI_MEM_CACHE_SRAM_USR_WCMD (BIT(20)) +#define SPI_MEM_CACHE_SRAM_USR_WCMD_M (BIT(20)) +#define SPI_MEM_CACHE_SRAM_USR_WCMD_V 0x1 +#define SPI_MEM_CACHE_SRAM_USR_WCMD_S 20 + +/* SPI_MEM_SRAM_ADDR_BITLEN : R/W ;bitpos:[19:14] ;default: 6'd23 ; */ + +/* Description: When SPI0 accesses to Ext_RAM, it is the length in bits of + * ADDR phase. The register value shall be (bit_num-1). + */ + +#define SPI_MEM_SRAM_ADDR_BITLEN 0x0000003F +#define SPI_MEM_SRAM_ADDR_BITLEN_M ((SPI_MEM_SRAM_ADDR_BITLEN_V)<<(SPI_MEM_SRAM_ADDR_BITLEN_S)) +#define SPI_MEM_SRAM_ADDR_BITLEN_V 0x3F +#define SPI_MEM_SRAM_ADDR_BITLEN_S 14 + +/* SPI_MEM_SRAM_RDUMMY_CYCLELEN : R/W ;bitpos:[11:6] ;default: 6'b1 ; */ + +/* Description: When SPI0 accesses to Ext_RAM, it is the SPI_CLK cycles minus + * 1 of DUMMY phase in read data transfer. + */ + +#define SPI_MEM_SRAM_RDUMMY_CYCLELEN 0x000000FF +#define SPI_MEM_SRAM_RDUMMY_CYCLELEN_M ((SPI_MEM_SRAM_RDUMMY_CYCLELEN_V)<<(SPI_MEM_SRAM_RDUMMY_CYCLELEN_S)) +#define SPI_MEM_SRAM_RDUMMY_CYCLELEN_V 0xFF +#define SPI_MEM_SRAM_RDUMMY_CYCLELEN_S 6 + +/* SPI_MEM_CACHE_SRAM_USR_RCMD : R/W ;bitpos:[5] ;default: 1'b1 ; */ + +/* Description: + * 1: The command value of SPI0 read Ext_RAM is + * SPI_MEM_CACHE_SRAM_USR_WR_CMD_VALUE. + * 0: The value is 0x2. + */ + +#define SPI_MEM_CACHE_SRAM_USR_RCMD (BIT(5)) +#define SPI_MEM_CACHE_SRAM_USR_RCMD_M (BIT(5)) +#define SPI_MEM_CACHE_SRAM_USR_RCMD_V 0x1 +#define SPI_MEM_CACHE_SRAM_USR_RCMD_S 5 + +/* SPI_MEM_USR_RD_SRAM_DUMMY : R/W ;bitpos:[4] ;default: 1'b1 ; */ + +/* Description: When SPI0 accesses to Ext_RAM, set this bit to enable DUMMY + * phase in read operations. + */ + +#define SPI_MEM_USR_RD_SRAM_DUMMY (BIT(4)) +#define SPI_MEM_USR_RD_SRAM_DUMMY_M (BIT(4)) +#define SPI_MEM_USR_RD_SRAM_DUMMY_V 0x1 +#define SPI_MEM_USR_RD_SRAM_DUMMY_S 4 + +/* SPI_MEM_USR_WR_SRAM_DUMMY : R/W ;bitpos:[3] ;default: 1'b0 ; */ + +/* Description: When SPI0 accesses to Ext_RAM, set this bit to enable DUMMY + * phase in write operations. + */ + +#define SPI_MEM_USR_WR_SRAM_DUMMY (BIT(3)) +#define SPI_MEM_USR_WR_SRAM_DUMMY_M (BIT(3)) +#define SPI_MEM_USR_WR_SRAM_DUMMY_V 0x1 +#define SPI_MEM_USR_WR_SRAM_DUMMY_S 3 + +/* SPI_MEM_USR_SRAM_QIO : R/W ;bitpos:[2] ;default: 1'b0 ; */ + +/* Description: Set the bit to enable QPI mode in all SPI0 Ext_RAM transfer. + */ + +#define SPI_MEM_USR_SRAM_QIO (BIT(2)) +#define SPI_MEM_USR_SRAM_QIO_M (BIT(2)) +#define SPI_MEM_USR_SRAM_QIO_V 0x1 +#define SPI_MEM_USR_SRAM_QIO_S 2 + +/* SPI_MEM_USR_SRAM_DIO : R/W ;bitpos:[1] ;default: 1'b0 ; */ + +/* Description: Set the bit to enable 2-bm in all the phases of SPI0 Ext_RAM + * transfer. + */ + +#define SPI_MEM_USR_SRAM_DIO (BIT(1)) +#define SPI_MEM_USR_SRAM_DIO_M (BIT(1)) +#define SPI_MEM_USR_SRAM_DIO_V 0x1 +#define SPI_MEM_USR_SRAM_DIO_S 1 + +/* SPI_MEM_CACHE_USR_SCMD_4BYTE : R/W ;bitpos:[0] ;default: 1'b0 ; */ + +/* Description: Set this bit to enable SPI0 read Ext_RAM with 32 bits + * address. The value of SPI_MEM_SRAM_ADDR_BITLEN should be 31. + */ + +#define SPI_MEM_CACHE_USR_SCMD_4BYTE (BIT(0)) +#define SPI_MEM_CACHE_USR_SCMD_4BYTE_M (BIT(0)) +#define SPI_MEM_CACHE_USR_SCMD_4BYTE_V 0x1 +#define SPI_MEM_CACHE_USR_SCMD_4BYTE_S 0 + +#define SPI_MEM_SRAM_CMD_REG(i) (REG_SPI_MEM_BASE(i) + 0x44) + +/* SPI_MEM_SDUMMY_OUT : R/W ;bitpos:[22] ;default: 1'b0 ; */ + +/* Description: When SPI0 accesses to Ext_RAM, in the DUMMY phase the signal + * level of SPI bus is output by the SPI0 controller. + */ + +#define SPI_MEM_SDUMMY_OUT (BIT(22)) +#define SPI_MEM_SDUMMY_OUT_M (BIT(22)) +#define SPI_MEM_SDUMMY_OUT_V 0x1 +#define SPI_MEM_SDUMMY_OUT_S 22 + +/* SPI_MEM_SCMD_OCT : R/W ;bitpos:[21] ;default: 1'b0 ; */ + +/* Description: When SPI0 accesses to Ext_RAM, set this bit to enable 8-bm in + * CMD phase. + */ + +#define SPI_MEM_SCMD_OCT (BIT(21)) +#define SPI_MEM_SCMD_OCT_M (BIT(21)) +#define SPI_MEM_SCMD_OCT_V 0x1 +#define SPI_MEM_SCMD_OCT_S 21 + +/* SPI_MEM_SADDR_OCT : R/W ;bitpos:[20] ;default: 1'b0 ; */ + +/* Description: When SPI0 accesses to Ext_RAM, set this bit to enable 8-bm in + * ADDR phase. + */ + +#define SPI_MEM_SADDR_OCT (BIT(20)) +#define SPI_MEM_SADDR_OCT_M (BIT(20)) +#define SPI_MEM_SADDR_OCT_V 0x1 +#define SPI_MEM_SADDR_OCT_S 20 + +/* SPI_MEM_SDOUT_OCT : R/W ;bitpos:[19] ;default: 1'b0 ; */ + +/* Description: When SPI0 accesses to Ext_RAM, set this bit to enable 8-bm in + * DOUT phase. + */ + +#define SPI_MEM_SDOUT_OCT (BIT(19)) +#define SPI_MEM_SDOUT_OCT_M (BIT(19)) +#define SPI_MEM_SDOUT_OCT_V 0x1 +#define SPI_MEM_SDOUT_OCT_S 19 + +/* SPI_MEM_SDIN_OCT : R/W ;bitpos:[18] ;default: 1'b0 ; */ + +/* Description: When SPI0 accesses to Ext_RAM, set this bit to enable 8-bm in + * DIN phase. + */ + +#define SPI_MEM_SDIN_OCT (BIT(18)) +#define SPI_MEM_SDIN_OCT_M (BIT(18)) +#define SPI_MEM_SDIN_OCT_V 0x1 +#define SPI_MEM_SDIN_OCT_S 18 + +/* SPI_MEM_SCMD_QUAD : R/W ;bitpos:[17] ;default: 1'b0 ; */ + +/* Description: When SPI0 accesses to Ext_RAM, set this bit to enable 4-bm in + * CMD phase. + */ + +#define SPI_MEM_SCMD_QUAD (BIT(17)) +#define SPI_MEM_SCMD_QUAD_M (BIT(17)) +#define SPI_MEM_SCMD_QUAD_V 0x1 +#define SPI_MEM_SCMD_QUAD_S 17 + +/* SPI_MEM_SADDR_QUAD : R/W ;bitpos:[16] ;default: 1'b0 ; */ + +/* Description: When SPI0 accesses to Ext_RAM, set this bit to enable 4-bm in + * ADDR phase. + */ + +#define SPI_MEM_SADDR_QUAD (BIT(16)) +#define SPI_MEM_SADDR_QUAD_M (BIT(16)) +#define SPI_MEM_SADDR_QUAD_V 0x1 +#define SPI_MEM_SADDR_QUAD_S 16 + +/* SPI_MEM_SDOUT_QUAD : R/W ;bitpos:[15] ;default: 1'b0 ; */ + +/* Description: When SPI0 accesses to Ext_RAM, set this bit to enable 4-bm in + * DOUT phase. + */ + +#define SPI_MEM_SDOUT_QUAD (BIT(15)) +#define SPI_MEM_SDOUT_QUAD_M (BIT(15)) +#define SPI_MEM_SDOUT_QUAD_V 0x1 +#define SPI_MEM_SDOUT_QUAD_S 15 + +/* SPI_MEM_SDIN_QUAD : R/W ;bitpos:[14] ;default: 1'b0 ; */ + +/* Description: When SPI0 accesses to Ext_RAM, set this bit to enable 4-bm in + * DIN phase. + */ + +#define SPI_MEM_SDIN_QUAD (BIT(14)) +#define SPI_MEM_SDIN_QUAD_M (BIT(14)) +#define SPI_MEM_SDIN_QUAD_V 0x1 +#define SPI_MEM_SDIN_QUAD_S 14 + +/* SPI_MEM_SCMD_DUAL : R/W ;bitpos:[13] ;default: 1'b0 ; */ + +/* Description: When SPI0 accesses to Ext_RAM, set this bit to enable 2-bm in + * CMD phase. + */ + +#define SPI_MEM_SCMD_DUAL (BIT(13)) +#define SPI_MEM_SCMD_DUAL_M (BIT(13)) +#define SPI_MEM_SCMD_DUAL_V 0x1 +#define SPI_MEM_SCMD_DUAL_S 13 + +/* SPI_MEM_SADDR_DUAL : R/W ;bitpos:[12] ;default: 1'b0 ; */ + +/* Description: When SPI0 accesses to Ext_RAM, set this bit to enable 2-bm in + * ADDR phase. + */ + +#define SPI_MEM_SADDR_DUAL (BIT(12)) +#define SPI_MEM_SADDR_DUAL_M (BIT(12)) +#define SPI_MEM_SADDR_DUAL_V 0x1 +#define SPI_MEM_SADDR_DUAL_S 12 + +/* SPI_MEM_SDOUT_DUAL : R/W ;bitpos:[11] ;default: 1'b0 ; */ + +/* Description: When SPI0 accesses to Ext_RAM, set this bit to enable 2-bm in + * DOUT phase. + */ + +#define SPI_MEM_SDOUT_DUAL (BIT(11)) +#define SPI_MEM_SDOUT_DUAL_M (BIT(11)) +#define SPI_MEM_SDOUT_DUAL_V 0x1 +#define SPI_MEM_SDOUT_DUAL_S 11 + +/* SPI_MEM_SDIN_DUAL : R/W ;bitpos:[10] ;default: 1'b0 ; */ + +/* Description: When SPI0 accesses to Ext_RAM, set this bit to enable 2-bm in + * DIN phase. + */ + +#define SPI_MEM_SDIN_DUAL (BIT(10)) +#define SPI_MEM_SDIN_DUAL_M (BIT(10)) +#define SPI_MEM_SDIN_DUAL_V 0x1 +#define SPI_MEM_SDIN_DUAL_S 10 + +/* SPI_MEM_SWB_MODE : R/W ;bitpos:[9:2] ;default: 8'b0 ; */ + +/* Description: Mode bits when SPI0 accesses to Ext_RAM. */ + +#define SPI_MEM_SWB_MODE 0x000000FF +#define SPI_MEM_SWB_MODE_M ((SPI_MEM_SWB_MODE_V)<<(SPI_MEM_SWB_MODE_S)) +#define SPI_MEM_SWB_MODE_V 0xFF +#define SPI_MEM_SWB_MODE_S 2 + +/* SPI_MEM_SCLK_MODE : R/W ;bitpos:[1:0] ;default: 2'd0 ; */ + +/* Description: SPI_CLK mode bits when SPI0 accesses to Ext_RAM. + * 0: SPI_CLK is off when CS inactive + * 1: SPI_CLK is delayed one cycle after CS inactive + * 2: SPI_CLK is delayed two cycles after CS inactive + * 3: SPI_CLK is always on. + */ + +#define SPI_MEM_SCLK_MODE 0x00000003 +#define SPI_MEM_SCLK_MODE_M ((SPI_MEM_SCLK_MODE_V)<<(SPI_MEM_SCLK_MODE_S)) +#define SPI_MEM_SCLK_MODE_V 0x3 +#define SPI_MEM_SCLK_MODE_S 0 + +#define SPI_MEM_SRAM_DRD_CMD_REG(i) (REG_SPI_MEM_BASE(i) + 0x48) + +/* SPI_MEM_CACHE_SRAM_USR_RD_CMD_BITLEN: R/W;bitpos:[31:28];default:4'h0; */ + +/* Description: When SPI0 reads Ext_RAM, it is the length in bits of CMD + * phase. The register value shall be (bit_num-1). + */ + +#define SPI_MEM_CACHE_SRAM_USR_RD_CMD_BITLEN 0x0000000F +#define SPI_MEM_CACHE_SRAM_USR_RD_CMD_BITLEN_M ((SPI_MEM_CACHE_SRAM_USR_RD_CMD_BITLEN_V)<<(SPI_MEM_CACHE_SRAM_USR_RD_CMD_BITLEN_S)) +#define SPI_MEM_CACHE_SRAM_USR_RD_CMD_BITLEN_V 0xF +#define SPI_MEM_CACHE_SRAM_USR_RD_CMD_BITLEN_S 28 + +/* SPI_MEM_CACHE_SRAM_USR_RD_CMD_VALUE: R/W;bitpos:[15:0];default:16'h0; */ + +/* Description: When SPI0 reads Ext_RAM, it is the command value of + * CMD phase. + */ + +#define SPI_MEM_CACHE_SRAM_USR_RD_CMD_VALUE 0x0000FFFF +#define SPI_MEM_CACHE_SRAM_USR_RD_CMD_VALUE_M ((SPI_MEM_CACHE_SRAM_USR_RD_CMD_VALUE_V)<<(SPI_MEM_CACHE_SRAM_USR_RD_CMD_VALUE_S)) +#define SPI_MEM_CACHE_SRAM_USR_RD_CMD_VALUE_V 0xFFFF +#define SPI_MEM_CACHE_SRAM_USR_RD_CMD_VALUE_S 0 + +#define SPI_MEM_SRAM_DWR_CMD_REG(i) (REG_SPI_MEM_BASE(i) + 0x4C) + +/* SPI_MEM_CACHE_SRAM_USR_WR_CMD_BITLEN: R/W;bitpos:[31:28];default:4'h0; */ + +/* Description: When SPI0 writes Ext_RAM, it is the length in bits of CMD + * phase. The register value shall be (bit_num-1). + */ + +#define SPI_MEM_CACHE_SRAM_USR_WR_CMD_BITLEN 0x0000000F +#define SPI_MEM_CACHE_SRAM_USR_WR_CMD_BITLEN_M ((SPI_MEM_CACHE_SRAM_USR_WR_CMD_BITLEN_V)<<(SPI_MEM_CACHE_SRAM_USR_WR_CMD_BITLEN_S)) +#define SPI_MEM_CACHE_SRAM_USR_WR_CMD_BITLEN_V 0xF +#define SPI_MEM_CACHE_SRAM_USR_WR_CMD_BITLEN_S 28 + +/* SPI_MEM_CACHE_SRAM_USR_WR_CMD_VALUE: R/W;bitpos:[15:0];default: 16'h0; */ + +/* Description: When SPI0 writes Ext_RAM, it is the command value of + * CMD phase. + */ + +#define SPI_MEM_CACHE_SRAM_USR_WR_CMD_VALUE 0x0000FFFF +#define SPI_MEM_CACHE_SRAM_USR_WR_CMD_VALUE_M ((SPI_MEM_CACHE_SRAM_USR_WR_CMD_VALUE_V)<<(SPI_MEM_CACHE_SRAM_USR_WR_CMD_VALUE_S)) +#define SPI_MEM_CACHE_SRAM_USR_WR_CMD_VALUE_V 0xFFFF +#define SPI_MEM_CACHE_SRAM_USR_WR_CMD_VALUE_S 0 + +#define SPI_MEM_SRAM_CLK_REG(i) (REG_SPI_MEM_BASE(i) + 0x50) + +/* SPI_MEM_SCLK_EQU_SYSCLK : R/W ;bitpos:[31] ;default: 1'b0 ; */ + +/* Description: When SPI0 accesses to Ext_RAM, set this bit in 1-division + * mode, f_SPI_CLK = f_MSPI_CORE_CLK. + */ + +#define SPI_MEM_SCLK_EQU_SYSCLK (BIT(31)) +#define SPI_MEM_SCLK_EQU_SYSCLK_M (BIT(31)) +#define SPI_MEM_SCLK_EQU_SYSCLK_V 0x1 +#define SPI_MEM_SCLK_EQU_SYSCLK_S 31 + +/* SPI_MEM_SCLKCNT_N : R/W ;bitpos:[23:16] ;default: 8'h3 ; */ + +/* Description: When SPI0 accesses to Ext_RAM, f_SPI_CLK = + * f_MSPI_CORE_CLK/(SPI_MEM_SCLKCNT_N+1) + */ + +#define SPI_MEM_SCLKCNT_N 0x000000FF +#define SPI_MEM_SCLKCNT_N_M ((SPI_MEM_SCLKCNT_N_V)<<(SPI_MEM_SCLKCNT_N_S)) +#define SPI_MEM_SCLKCNT_N_V 0xFF +#define SPI_MEM_SCLKCNT_N_S 16 + +/* SPI_MEM_SCLKCNT_H : R/W ;bitpos:[15:8] ;default: 8'h1 ; */ + +/* Description: It must be a floor value of ((SPI_MEM_SCLKCNT_N+1)/2-1). */ + +#define SPI_MEM_SCLKCNT_H 0x000000FF +#define SPI_MEM_SCLKCNT_H_M ((SPI_MEM_SCLKCNT_H_V)<<(SPI_MEM_SCLKCNT_H_S)) +#define SPI_MEM_SCLKCNT_H_V 0xFF +#define SPI_MEM_SCLKCNT_H_S 8 + +/* SPI_MEM_SCLKCNT_L : R/W ;bitpos:[7:0] ;default: 8'h3 ; */ + +/* Description: It must equal to the value of SPI_MEM_SCLKCNT_N. */ + +#define SPI_MEM_SCLKCNT_L 0x000000FF +#define SPI_MEM_SCLKCNT_L_M ((SPI_MEM_SCLKCNT_L_V)<<(SPI_MEM_SCLKCNT_L_S)) +#define SPI_MEM_SCLKCNT_L_V 0xFF +#define SPI_MEM_SCLKCNT_L_S 0 + +#define SPI_MEM_FSM_REG(i) (REG_SPI_MEM_BASE(i) + 0x54) + +/* SPI_MEM_ST : RO ;bitpos:[2:0] ;default: 3'b0 ; */ + +/* Description: The status of SPI1 state machine. + * 0: idle state(IDLE), + * 1: preparation state(PREP), + * 2: send command state(CMD), + * 3: send address state(ADDR), + * 4: red data state(DIN), + * 5:write data state(DOUT), + * 6: wait state(DUMMY), + * 7: done state(DONE). + */ + +#define SPI_MEM_ST 0x00000007 +#define SPI_MEM_ST_M ((SPI_MEM_ST_V)<<(SPI_MEM_ST_S)) +#define SPI_MEM_ST_V 0x7 +#define SPI_MEM_ST_S 0 + +#define SPI_MEM_W0_REG(i) (REG_SPI_MEM_BASE(i) + 0x58) + +/* SPI_MEM_BUF0 : R/W/SS ;bitpos:[31:0] ;default: 32'b0 ; */ + +/* Description: data buffer */ + +#define SPI_MEM_BUF0 0xFFFFFFFF +#define SPI_MEM_BUF0_M ((SPI_MEM_BUF0_V)<<(SPI_MEM_BUF0_S)) +#define SPI_MEM_BUF0_V 0xFFFFFFFF +#define SPI_MEM_BUF0_S 0 + +#define SPI_MEM_W1_REG(i) (REG_SPI_MEM_BASE(i) + 0x5C) + +/* SPI_MEM_BUF1 : R/W/SS ;bitpos:[31:0] ;default: 32'b0 ; */ + +/* Description: data buffer */ + +#define SPI_MEM_BUF1 0xFFFFFFFF +#define SPI_MEM_BUF1_M ((SPI_MEM_BUF1_V)<<(SPI_MEM_BUF1_S)) +#define SPI_MEM_BUF1_V 0xFFFFFFFF +#define SPI_MEM_BUF1_S 0 + +#define SPI_MEM_W2_REG(i) (REG_SPI_MEM_BASE(i) + 0x60) + +/* SPI_MEM_BUF2 : R/W/SS ;bitpos:[31:0] ;default: 32'b0 ; */ + +/* Description: data buffer */ + +#define SPI_MEM_BUF2 0xFFFFFFFF +#define SPI_MEM_BUF2_M ((SPI_MEM_BUF2_V)<<(SPI_MEM_BUF2_S)) +#define SPI_MEM_BUF2_V 0xFFFFFFFF +#define SPI_MEM_BUF2_S 0 + +#define SPI_MEM_W3_REG(i) (REG_SPI_MEM_BASE(i) + 0x64) + +/* SPI_MEM_BUF3 : R/W/SS ;bitpos:[31:0] ;default: 32'b0 ; */ + +/* Description: data buffer */ + +#define SPI_MEM_BUF3 0xFFFFFFFF +#define SPI_MEM_BUF3_M ((SPI_MEM_BUF3_V)<<(SPI_MEM_BUF3_S)) +#define SPI_MEM_BUF3_V 0xFFFFFFFF +#define SPI_MEM_BUF3_S 0 + +#define SPI_MEM_W4_REG(i) (REG_SPI_MEM_BASE(i) + 0x68) + +/* SPI_MEM_BUF4 : R/W/SS ;bitpos:[31:0] ;default: 32'b0 ; */ + +/* Description: data buffer */ + +#define SPI_MEM_BUF4 0xFFFFFFFF +#define SPI_MEM_BUF4_M ((SPI_MEM_BUF4_V)<<(SPI_MEM_BUF4_S)) +#define SPI_MEM_BUF4_V 0xFFFFFFFF +#define SPI_MEM_BUF4_S 0 + +#define SPI_MEM_W5_REG(i) (REG_SPI_MEM_BASE(i) + 0x6C) + +/* SPI_MEM_BUF5 : R/W/SS ;bitpos:[31:0] ;default: 32'b0 ; */ + +/* Description: data buffer */ + +#define SPI_MEM_BUF5 0xFFFFFFFF +#define SPI_MEM_BUF5_M ((SPI_MEM_BUF5_V)<<(SPI_MEM_BUF5_S)) +#define SPI_MEM_BUF5_V 0xFFFFFFFF +#define SPI_MEM_BUF5_S 0 + +#define SPI_MEM_W6_REG(i) (REG_SPI_MEM_BASE(i) + 0x70) + +/* SPI_MEM_BUF6 : R/W/SS ;bitpos:[31:0] ;default: 32'b0 ; */ + +/* Description: data buffer */ + +#define SPI_MEM_BUF6 0xFFFFFFFF +#define SPI_MEM_BUF6_M ((SPI_MEM_BUF6_V)<<(SPI_MEM_BUF6_S)) +#define SPI_MEM_BUF6_V 0xFFFFFFFF +#define SPI_MEM_BUF6_S 0 + +#define SPI_MEM_W7_REG(i) (REG_SPI_MEM_BASE(i) + 0x74) + +/* SPI_MEM_BUF7 : R/W/SS ;bitpos:[31:0] ;default: 32'b0 ; */ + +/* Description: data buffer */ + +#define SPI_MEM_BUF7 0xFFFFFFFF +#define SPI_MEM_BUF7_M ((SPI_MEM_BUF7_V)<<(SPI_MEM_BUF7_S)) +#define SPI_MEM_BUF7_V 0xFFFFFFFF +#define SPI_MEM_BUF7_S 0 + +#define SPI_MEM_W8_REG(i) (REG_SPI_MEM_BASE(i) + 0x78) + +/* SPI_MEM_BUF8 : R/W/SS ;bitpos:[31:0] ;default: 32'b0 ; */ + +/* Description: data buffer */ + +#define SPI_MEM_BUF8 0xFFFFFFFF +#define SPI_MEM_BUF8_M ((SPI_MEM_BUF8_V)<<(SPI_MEM_BUF8_S)) +#define SPI_MEM_BUF8_V 0xFFFFFFFF +#define SPI_MEM_BUF8_S 0 + +#define SPI_MEM_W9_REG(i) (REG_SPI_MEM_BASE(i) + 0x7C) + +/* SPI_MEM_BUF9 : R/W/SS ;bitpos:[31:0] ;default: 32'b0 ; */ + +/* Description: data buffer */ + +#define SPI_MEM_BUF9 0xFFFFFFFF +#define SPI_MEM_BUF9_M ((SPI_MEM_BUF9_V)<<(SPI_MEM_BUF9_S)) +#define SPI_MEM_BUF9_V 0xFFFFFFFF +#define SPI_MEM_BUF9_S 0 + +#define SPI_MEM_W10_REG(i) (REG_SPI_MEM_BASE(i) + 0x80) + +/* SPI_MEM_BUF10 : R/W/SS ;bitpos:[31:0] ;default: 32'b0 ; */ + +/* Description: data buffer */ + +#define SPI_MEM_BUF10 0xFFFFFFFF +#define SPI_MEM_BUF10_M ((SPI_MEM_BUF10_V)<<(SPI_MEM_BUF10_S)) +#define SPI_MEM_BUF10_V 0xFFFFFFFF +#define SPI_MEM_BUF10_S 0 + +#define SPI_MEM_W11_REG(i) (REG_SPI_MEM_BASE(i) + 0x84) + +/* SPI_MEM_BUF11 : R/W/SS ;bitpos:[31:0] ;default: 32'b0 ; */ + +/* Description: data buffer */ + +#define SPI_MEM_BUF11 0xFFFFFFFF +#define SPI_MEM_BUF11_M ((SPI_MEM_BUF11_V)<<(SPI_MEM_BUF11_S)) +#define SPI_MEM_BUF11_V 0xFFFFFFFF +#define SPI_MEM_BUF11_S 0 + +#define SPI_MEM_W12_REG(i) (REG_SPI_MEM_BASE(i) + 0x88) + +/* SPI_MEM_BUF12 : R/W/SS ;bitpos:[31:0] ;default: 32'b0 ; */ + +/* Description: data buffer */ + +#define SPI_MEM_BUF12 0xFFFFFFFF +#define SPI_MEM_BUF12_M ((SPI_MEM_BUF12_V)<<(SPI_MEM_BUF12_S)) +#define SPI_MEM_BUF12_V 0xFFFFFFFF +#define SPI_MEM_BUF12_S 0 + +#define SPI_MEM_W13_REG(i) (REG_SPI_MEM_BASE(i) + 0x8C) + +/* SPI_MEM_BUF13 : R/W/SS ;bitpos:[31:0] ;default: 32'b0 ; */ + +/* Description: data buffer */ + +#define SPI_MEM_BUF13 0xFFFFFFFF +#define SPI_MEM_BUF13_M ((SPI_MEM_BUF13_V)<<(SPI_MEM_BUF13_S)) +#define SPI_MEM_BUF13_V 0xFFFFFFFF +#define SPI_MEM_BUF13_S 0 + +#define SPI_MEM_W14_REG(i) (REG_SPI_MEM_BASE(i) + 0x90) + +/* SPI_MEM_BUF14 : R/W/SS ;bitpos:[31:0] ;default: 32'b0 ; */ + +/* Description: data buffer */ + +#define SPI_MEM_BUF14 0xFFFFFFFF +#define SPI_MEM_BUF14_M ((SPI_MEM_BUF14_V)<<(SPI_MEM_BUF14_S)) +#define SPI_MEM_BUF14_V 0xFFFFFFFF +#define SPI_MEM_BUF14_S 0 + +#define SPI_MEM_W15_REG(i) (REG_SPI_MEM_BASE(i) + 0x94) + +/* SPI_MEM_BUF15 : R/W/SS ;bitpos:[31:0] ;default: 32'b0 ; */ + +/* Description: data buffer */ + +#define SPI_MEM_BUF15 0xFFFFFFFF +#define SPI_MEM_BUF15_M ((SPI_MEM_BUF15_V)<<(SPI_MEM_BUF15_S)) +#define SPI_MEM_BUF15_V 0xFFFFFFFF +#define SPI_MEM_BUF15_S 0 + +#define SPI_MEM_FLASH_WAITI_CTRL_REG(i) (REG_SPI_MEM_BASE(i) + 0x98) + +/* SPI_MEM_WAITI_DUMMY_CYCLELEN : R/W ;bitpos:[15:10] ;default: 6'h0 ; */ + +/* Description: The dummy cycle length when wait flash idle(RDSR). */ + +#define SPI_MEM_WAITI_DUMMY_CYCLELEN 0x000000FF +#define SPI_MEM_WAITI_DUMMY_CYCLELEN_M ((SPI_MEM_WAITI_DUMMY_CYCLELEN_V)<<(SPI_MEM_WAITI_DUMMY_CYCLELEN_S)) +#define SPI_MEM_WAITI_DUMMY_CYCLELEN_V 0xFF +#define SPI_MEM_WAITI_DUMMY_CYCLELEN_S 10 + +/* SPI_MEM_WAITI_CMD : R/W ;bitpos:[9:2] ;default: 8'h05 ; */ + +/* Description: The command value of auto wait flash idle transfer(RDSR). */ + +#define SPI_MEM_WAITI_CMD 0x000000FF +#define SPI_MEM_WAITI_CMD_M ((SPI_MEM_WAITI_CMD_V)<<(SPI_MEM_WAITI_CMD_S)) +#define SPI_MEM_WAITI_CMD_V 0xFF +#define SPI_MEM_WAITI_CMD_S 2 + +/* SPI_MEM_WAITI_DUMMY : R/W ;bitpos:[1] ;default: 1'b0 ; */ + +/* Description: Set this bit to enable DUMMY phase in auto wait flash idle + * transfer(RDSR). + */ + +#define SPI_MEM_WAITI_DUMMY (BIT(1)) +#define SPI_MEM_WAITI_DUMMY_M (BIT(1)) +#define SPI_MEM_WAITI_DUMMY_V 0x1 +#define SPI_MEM_WAITI_DUMMY_S 1 + +/* SPI_MEM_WAITI_EN : R/W ;bitpos:[0] ;default: 1'b0 ; */ + +/* Description: Set this bit to enable auto-waiting flash idle operation when + * PP/SE/BE/CE/WRSR/PES command is sent. + */ + +#define SPI_MEM_WAITI_EN (BIT(0)) +#define SPI_MEM_WAITI_EN_M (BIT(0)) +#define SPI_MEM_WAITI_EN_V 0x1 +#define SPI_MEM_WAITI_EN_S 0 + +#define SPI_MEM_FLASH_SUS_CMD_REG(i) (REG_SPI_MEM_BASE(i) + 0x09C) + +/* Description: program erase suspend bit, program erase suspend operation + * will be triggered when the bit is set. The bit will be cleared once the + * operation done. + * 1: enable + * 0:disable. + */ + +#define SPI_MEM_FLASH_PES (BIT(1)) +#define SPI_MEM_FLASH_PES_M (BIT(1)) +#define SPI_MEM_FLASH_PES_V 0x1 +#define SPI_MEM_FLASH_PES_S 1 + +/* SPI_MEM_FLASH_PER : R/W/SS/SC ;bitpos:[0] ;default: 1'b0 ; */ + +/* Description: program erase resume bit, program erase suspend operation + * will be triggered when the bit is set. The bit will be cleared once the + * operation done. + * 1: enable + * 0: disable. + */ + +#define SPI_MEM_FLASH_PER (BIT(0)) +#define SPI_MEM_FLASH_PER_M (BIT(0)) +#define SPI_MEM_FLASH_PER_V 0x1 +#define SPI_MEM_FLASH_PER_S 0 + +#define SPI_MEM_FLASH_SUS_CTRL_REG(i) (REG_SPI_MEM_BASE(i) + 0xA0) + +/* SPI_MEM_FLASH_PES_COMMAND : R/W ;bitpos:[16:9] ;default: 8'h75 ; */ + +/* Description: Program/Erase suspend command value. */ + +#define SPI_MEM_FLASH_PES_COMMAND 0x000000FF +#define SPI_MEM_FLASH_PES_COMMAND_M ((SPI_MEM_FLASH_PES_COMMAND_V)<<(SPI_MEM_FLASH_PES_COMMAND_S)) +#define SPI_MEM_FLASH_PES_COMMAND_V 0xFF +#define SPI_MEM_FLASH_PES_COMMAND_S 9 + +/* SPI_MEM_FLASH_PER_COMMAND : R/W ;bitpos:[8:1] ;default: 8'h7a ; */ + +/* Description: Program/Erase resume command value. */ + +#define SPI_MEM_FLASH_PER_COMMAND 0x000000FF +#define SPI_MEM_FLASH_PER_COMMAND_M ((SPI_MEM_FLASH_PER_COMMAND_V)<<(SPI_MEM_FLASH_PER_COMMAND_S)) +#define SPI_MEM_FLASH_PER_COMMAND_V 0xFF +#define SPI_MEM_FLASH_PER_COMMAND_S 1 + +/* SPI_MEM_FLASH_PES_EN : R/W ;bitpos:[0] ;default: 1'b0 ; */ + +/* Description: Set this bit to enable auto-suspend function. */ + +#define SPI_MEM_FLASH_PES_EN (BIT(0)) +#define SPI_MEM_FLASH_PES_EN_M (BIT(0)) +#define SPI_MEM_FLASH_PES_EN_V 0x1 +#define SPI_MEM_FLASH_PES_EN_S 0 + +#define SPI_MEM_SUS_STATUS_REG(i) (REG_SPI_MEM_BASE(i) + 0x0A4) + +/* Description: The status of flash suspend. This bit is set when PES command + * is sent, and cleared when PER is sent. Only used in SPI1. + */ + +#define SPI_MEM_FLASH_SUS (BIT(0)) +#define SPI_MEM_FLASH_SUS_M (BIT(0)) +#define SPI_MEM_FLASH_SUS_V 0x1 +#define SPI_MEM_FLASH_SUS_S 0 + +#define SPI_MEM_TIMING_CALI_REG(i) (REG_SPI_MEM_BASE(i) + 0xA8) + +/* SPI_MEM_EXTRA_DUMMY_CYCLELEN : R/W ;bitpos:[4:2] ;default: 3'd0 ; */ + +/* Description: Extra SPI_CLK cycles added in DUMMY phase for timing + * compensation. Active when SPI_MEM_TIMING_CALI bit is set. + */ + +#define SPI_MEM_EXTRA_DUMMY_CYCLELEN 0x00000003 +#define SPI_MEM_EXTRA_DUMMY_CYCLELEN_M ((SPI_MEM_EXTRA_DUMMY_CYCLELEN_V)<<(SPI_MEM_EXTRA_DUMMY_CYCLELEN_S)) +#define SPI_MEM_EXTRA_DUMMY_CYCLELEN_V 0x3 +#define SPI_MEM_EXTRA_DUMMY_CYCLELEN_S 2 + +/* SPI_MEM_TIMING_CALI : R/W ;bitpos:[1] ;default: 1'b0 ; */ + +/* Description: Set this bit to add extra SPI_CLK cycles in DUMMY phase for + * all reading operations. + */ + +#define SPI_MEM_TIMING_CALI (BIT(1)) +#define SPI_MEM_TIMING_CALI_M (BIT(1)) +#define SPI_MEM_TIMING_CALI_V 0x1 +#define SPI_MEM_TIMING_CALI_S 1 + +/* SPI_MEM_TIMING_CLK_ENA : R/W ;bitpos:[0] ;default: 1'b0 ; */ + +/* Description: Set this bit to power on HCLK. When PLL is powered on, the + * frequency of HCLK equals to that of PLL. Otherwise, the frequency equals + * to that of XTAL. + */ + +#define SPI_MEM_TIMING_CLK_ENA (BIT(0)) +#define SPI_MEM_TIMING_CLK_ENA_M (BIT(0)) +#define SPI_MEM_TIMING_CLK_ENA_V 0x1 +#define SPI_MEM_TIMING_CLK_ENA_S 0 + +#define SPI_MEM_DIN_MODE_REG(i) (REG_SPI_MEM_BASE(i) + 0xAC) + +/* SPI_MEM_DINS_MODE : R/W ;bitpos:[26:24] ;default: 3'h0 ; */ + +/* Description: SPI_DQS input delay mode. + * 0: No delay. + * 1: Delay for (SPI_MEM_DINS_NUM+1) cycles at MSPI_CORE_CLK negative edge. + * 2: Delay for (SPI_MEM_DINS_NUM+1) cycles at HCLK positive edge and one + * cycle at MSPI_CORE_CLK positive edge. 3: Delay for (SPI_MEM_DINS_NUM+1) + * cycles at HCLK positive edge and one cycle at MSPI_CORE_CLK negative edge. + * 4: Delay for (SPI_MEM_DINS_NUM+1) cycles at HCLK negative edge and one + * cycle at MSPI_CORE_CLK positive edge. 5: Delay for (SPI_MEM_DINS_NUM+1) + * cycles at HCLK negative edge and one cycle at MSPI_CORE_CLK negative edge. + */ + +#define SPI_MEM_DINS_MODE 0x00000007 +#define SPI_MEM_DINS_MODE_M ((SPI_MEM_DINS_MODE_V)<<(SPI_MEM_DINS_MODE_S)) +#define SPI_MEM_DINS_MODE_V 0x7 +#define SPI_MEM_DINS_MODE_S 24 + +/* SPI_MEM_DIN7_MODE : R/W ;bitpos:[23:21] ;default: 3'h0 ; */ + +/* Description: SPI_IO7 input delay mode. + * 0: No delay. + * 1: Delay for (SPI_MEM_DIN$n_NUM+1) cycles at MSPI_CORE_CLK negative edge. + * 2: Delay for (SPI_MEM_DIN$n_NUM+1) cycles at HCLK positive edge and one + * cycle at MSPI_CORE_CLK positive edge. + * 3: Delay for (SPI_MEM_DIN$n_NUM+1) cycles at HCLK positive edge and one + * cycle at MSPI_CORE_CLK negative edge. + * 4: Delay for (SPI_MEM_DIN$n_NUM+1) cycles at HCLK negative edge and one + * cycle at MSPI_CORE_CLK positive edge. 5: Delay for (SPI_MEM_DIN$n_NUM+1) + * cycles at HCLK negative edge and one cycle at MSPI_CORE_CLK negative edge. + */ + +#define SPI_MEM_DIN7_MODE 0x00000007 +#define SPI_MEM_DIN7_MODE_M ((SPI_MEM_DIN7_MODE_V)<<(SPI_MEM_DIN7_MODE_S)) +#define SPI_MEM_DIN7_MODE_V 0x7 +#define SPI_MEM_DIN7_MODE_S 21 + +/* SPI_MEM_DIN6_MODE : R/W ;bitpos:[20:18] ;default: 3'h0 ; */ + +/* Description: SPI_IO6 input delay mode. + * 0: No delay. + * 1: Delay for (SPI_MEM_DIN$n_NUM+1) cycles at MSPI_CORE_CLK negative edge. + * 2: Delay for (SPI_MEM_DIN$n_NUM+1) cycles at HCLK positive edge and one + * cycle at MSPI_CORE_CLK positive edge. + * 3: Delay for (SPI_MEM_DIN$n_NUM+1) cycles at HCLK positive edge and one + * cycle at MSPI_CORE_CLK negative edge. + * 4: Delay for (SPI_MEM_DIN$n_NUM+1) cycles at HCLK negative edge and one + * cycle at MSPI_CORE_CLK positive edge. 5: Delay for (SPI_MEM_DIN$n_NUM+1) + * cycles at HCLK negative edge and one cycle at MSPI_CORE_CLK negative edge. + */ + +#define SPI_MEM_DIN6_MODE 0x00000007 +#define SPI_MEM_DIN6_MODE_M ((SPI_MEM_DIN6_MODE_V)<<(SPI_MEM_DIN6_MODE_S)) +#define SPI_MEM_DIN6_MODE_V 0x7 +#define SPI_MEM_DIN6_MODE_S 18 + +/* SPI_MEM_DIN5_MODE : R/W ;bitpos:[17:15] ;default: 3'h0 ; */ + +/* Description: SPI_IO5 input delay mode. + * 0: No delay. + * 1: Delay for (SPI_MEM_DIN$n_NUM+1) cycles at MSPI_CORE_CLK negative edge. + * 2: Delay for (SPI_MEM_DIN$n_NUM+1) cycles at HCLK positive edge and one + * cycle at MSPI_CORE_CLK positive edge. 3: Delay for + * (SPI_MEM_DIN$n_NUM+1) + * cycles at HCLK positive edge and one cycle at MSPI_CORE_CLK negative + * edge. + * 4: Delay for (SPI_MEM_DIN$n_NUM+1) cycles at HCLK negative edge and one + * cycle at MSPI_CORE_CLK positive edge. + * 5: Delay for (SPI_MEM_DIN$n_NUM+1) cycles at HCLK negative edge and one + * cycle at MSPI_CORE_CLK negative edge. + */ + +#define SPI_MEM_DIN5_MODE 0x00000007 +#define SPI_MEM_DIN5_MODE_M ((SPI_MEM_DIN5_MODE_V)<<(SPI_MEM_DIN5_MODE_S)) +#define SPI_MEM_DIN5_MODE_V 0x7 +#define SPI_MEM_DIN5_MODE_S 15 + +/* SPI_MEM_DIN4_MODE : R/W ;bitpos:[14:12] ;default: 3'h0 ; */ + +/* Description: SPI_IO4 input delay mode. + * 0: No delay. + * 1: Delay for (SPI_MEM_DIN$n_NUM+1) cycles at MSPI_CORE_CLK negative edge. + * 2: Delay for (SPI_MEM_DIN$n_NUM+1) cycles at HCLK positive edge and one + * cycle at MSPI_CORE_CLK positive edge. + * 3: Delay for (SPI_MEM_DIN$n_NUM+1) cycles at HCLK positive edge and one + * cycle at MSPI_CORE_CLK negative edge. + * 4: Delay for (SPI_MEM_DIN$n_NUM+1) cycles at HCLK negative edge and one + * cycle at MSPI_CORE_CLK positive edge. + * 5: Delay for (SPI_MEM_DIN$n_NUM+1) + * cycles at HCLK negative edge and one cycle at MSPI_CORE_CLK negative edge. + */ + +#define SPI_MEM_DIN4_MODE 0x00000007 +#define SPI_MEM_DIN4_MODE_M ((SPI_MEM_DIN4_MODE_V)<<(SPI_MEM_DIN4_MODE_S)) +#define SPI_MEM_DIN4_MODE_V 0x7 +#define SPI_MEM_DIN4_MODE_S 12 + +/* SPI_MEM_DIN3_MODE : R/W ;bitpos:[11:9] ;default: 3'h0 ; */ + +/* Description: SPI_HD input delay mode. + * 0: No delay. + * 1: Delay for (SPI_MEM_DIN$n_NUM+1) cycles at MSPI_CORE_CLK negative edge. + * 2: Delay for (SPI_MEM_DIN$n_NUM+1) cycles at HCLK positive edge and one + * cycle at MSPI_CORE_CLK positive edge. 3: Delay for (SPI_MEM_DIN$n_NUM+1) + * cycles at HCLK positive edge and one cycle at MSPI_CORE_CLK negative edge. + * 4: Delay for (SPI_MEM_DIN$n_NUM+1) cycles at HCLK negative edge and one + * cycle at MSPI_CORE_CLK positive edge. + * 5: Delay for (SPI_MEM_DIN$n_NUM+1) cycles at HCLK negative edge and one + * cycle at MSPI_CORE_CLK negative edge. + */ + +#define SPI_MEM_DIN3_MODE 0x00000007 +#define SPI_MEM_DIN3_MODE_M ((SPI_MEM_DIN3_MODE_V)<<(SPI_MEM_DIN3_MODE_S)) +#define SPI_MEM_DIN3_MODE_V 0x7 +#define SPI_MEM_DIN3_MODE_S 9 + +/* SPI_MEM_DIN2_MODE : R/W ;bitpos:[8:6] ;default: 3'h0 ; */ + +/* Description: SPI_WP input delay mode. + * 0: No delay. + * 1: Delay for (SPI_MEM_DIN$n_NUM+1) cycles at MSPI_CORE_CLK negative edge. + * 2: Delay for (SPI_MEM_DIN$n_NUM+1) cycles at HCLK positive edge and one + * cycle at MSPI_CORE_CLK positive edge. + * 3: Delay for (SPI_MEM_DIN$n_NUM+1) cycles at HCLK positive edge and one + * cycle at MSPI_CORE_CLK negative edge. + * 4: Delay for (SPI_MEM_DIN$n_NUM+1) cycles at HCLK negative edge and one + * cycle at MSPI_CORE_CLK positive edge. + * 5: Delay for (SPI_MEM_DIN$n_NUM+1) cycles at HCLK negative edge and one + * cycle at MSPI_CORE_CLK negative edge. + */ + +#define SPI_MEM_DIN2_MODE 0x00000007 +#define SPI_MEM_DIN2_MODE_M ((SPI_MEM_DIN2_MODE_V)<<(SPI_MEM_DIN2_MODE_S)) +#define SPI_MEM_DIN2_MODE_V 0x7 +#define SPI_MEM_DIN2_MODE_S 6 + +/* SPI_MEM_DIN1_MODE : R/W ;bitpos:[5:3] ;default: 3'h0 ; */ + +/* Description: SPI_Q input delay mode. + * 0: No delay. + * 1: Delay for (SPI_MEM_DIN$n_NUM+1) cycles at MSPI_CORE_CLK negative edge. + * 2: Delay for (SPI_MEM_DIN$n_NUM+1) cycles at HCLK positive edge and one + * cycle at MSPI_CORE_CLK positive edge. + * 3: Delay for (SPI_MEM_DIN$n_NUM+1) cycles at HCLK positive edge and one + * cycle at MSPI_CORE_CLK negative edge. + * 4: Delay for (SPI_MEM_DIN$n_NUM+1) cycles at HCLK negative edge and one + * cycle at MSPI_CORE_CLK positive edge. + * 5: Delay for (SPI_MEM_DIN$n_NUM+1) cycles at HCLK negative edge and one + * cycle at MSPI_CORE_CLK negative edge. + */ + +#define SPI_MEM_DIN1_MODE 0x00000007 +#define SPI_MEM_DIN1_MODE_M ((SPI_MEM_DIN1_MODE_V)<<(SPI_MEM_DIN1_MODE_S)) +#define SPI_MEM_DIN1_MODE_V 0x7 +#define SPI_MEM_DIN1_MODE_S 3 + +/* SPI_MEM_DIN0_MODE : R/W ;bitpos:[2:0] ;default: 3'h0 ; */ + +/* Description: SPI_D input delay mode. + * 0: No delay. + * 1: Delay for (SPI_MEM_DIN$n_NUM+1) cycles at MSPI_CORE_CLK negative edge. + * 2: Delay for (SPI_MEM_DIN$n_NUM+1) cycles at HCLK positive edge and one + * cycle at MSPI_CORE_CLK positive edge. + * 3: Delay for (SPI_MEM_DIN$n_NUM+1) cycles at HCLK positive edge and one + * cycle at MSPI_CORE_CLK nega tive edge. + * 4: Delay for (SPI_MEM_DIN$n_NUM+1) cycles at HCLK negative edge and o ne + * cycle at MSPI_CORE_CLK positive edge. + * 5: Delay for (SPI_MEM_DIN$n_NUM+1) cycles at HCLK negative edge and one + * cycle at MSPI_CORE_CLK negative edge. + */ + +#define SPI_MEM_DIN0_MODE 0x00000007 +#define SPI_MEM_DIN0_MODE_M ((SPI_MEM_DIN0_MODE_V)<<(SPI_MEM_DIN0_MODE_S)) +#define SPI_MEM_DIN0_MODE_V 0x7 +#define SPI_MEM_DIN0_MODE_S 0 + +#define SPI_MEM_DIN_NUM_REG(i) (REG_SPI_MEM_BASE(i) + 0xB0) + +/* SPI_MEM_DINS_NUM : R/W ;bitpos:[17:16] ;default: 2'h0 ; */ + +/* Description: SPI_DQS input delay number. */ + +#define SPI_MEM_DINS_NUM 0x00000003 +#define SPI_MEM_DINS_NUM_M ((SPI_MEM_DINS_NUM_V)<<(SPI_MEM_DINS_NUM_S)) +#define SPI_MEM_DINS_NUM_V 0x3 +#define SPI_MEM_DINS_NUM_S 16 + +/* SPI_MEM_DIN7_NUM : R/W ;bitpos:[15:14] ;default: 2'h0 ; */ + +/* Description: SPI_IO7 input delay number. */ + +#define SPI_MEM_DIN7_NUM 0x00000003 +#define SPI_MEM_DIN7_NUM_M ((SPI_MEM_DIN7_NUM_V)<<(SPI_MEM_DIN7_NUM_S)) +#define SPI_MEM_DIN7_NUM_V 0x3 +#define SPI_MEM_DIN7_NUM_S 14 + +/* SPI_MEM_DIN6_NUM : R/W ;bitpos:[13:12] ;default: 2'h0 ; */ + +/* Description: SPI_IO6 input delay number. */ + +#define SPI_MEM_DIN6_NUM 0x00000003 +#define SPI_MEM_DIN6_NUM_M ((SPI_MEM_DIN6_NUM_V)<<(SPI_MEM_DIN6_NUM_S)) +#define SPI_MEM_DIN6_NUM_V 0x3 +#define SPI_MEM_DIN6_NUM_S 12 + +/* SPI_MEM_DIN5_NUM : R/W ;bitpos:[11:10] ;default: 2'h0 ; */ + +/* Description: SPI_IO5 input delay number. */ + +#define SPI_MEM_DIN5_NUM 0x00000003 +#define SPI_MEM_DIN5_NUM_M ((SPI_MEM_DIN5_NUM_V)<<(SPI_MEM_DIN5_NUM_S)) +#define SPI_MEM_DIN5_NUM_V 0x3 +#define SPI_MEM_DIN5_NUM_S 10 + +/* SPI_MEM_DIN4_NUM : R/W ;bitpos:[9:8] ;default: 2'h0 ; */ + +/* Description: SPI_IO4 input delay number. */ + +#define SPI_MEM_DIN4_NUM 0x00000003 +#define SPI_MEM_DIN4_NUM_M ((SPI_MEM_DIN4_NUM_V)<<(SPI_MEM_DIN4_NUM_S)) +#define SPI_MEM_DIN4_NUM_V 0x3 +#define SPI_MEM_DIN4_NUM_S 8 + +/* SPI_MEM_DIN3_NUM : R/W ;bitpos:[7:6] ;default: 2'h0 ; */ + +/* Description: SPI_HD input delay number. */ + +#define SPI_MEM_DIN3_NUM 0x00000003 +#define SPI_MEM_DIN3_NUM_M ((SPI_MEM_DIN3_NUM_V)<<(SPI_MEM_DIN3_NUM_S)) +#define SPI_MEM_DIN3_NUM_V 0x3 +#define SPI_MEM_DIN3_NUM_S 6 + +/* SPI_MEM_DIN2_NUM : R/W ;bitpos:[5:4] ;default: 2'h0 ; */ + +/* Description: SPI_WP input delay number. */ + +#define SPI_MEM_DIN2_NUM 0x00000003 +#define SPI_MEM_DIN2_NUM_M ((SPI_MEM_DIN2_NUM_V)<<(SPI_MEM_DIN2_NUM_S)) +#define SPI_MEM_DIN2_NUM_V 0x3 +#define SPI_MEM_DIN2_NUM_S 4 + +/* SPI_MEM_DIN1_NUM : R/W ;bitpos:[3:2] ;default: 2'h0 ; */ + +/* Description: SPI_Q input delay number. */ + +#define SPI_MEM_DIN1_NUM 0x00000003 +#define SPI_MEM_DIN1_NUM_M ((SPI_MEM_DIN1_NUM_V)<<(SPI_MEM_DIN1_NUM_S)) +#define SPI_MEM_DIN1_NUM_V 0x3 +#define SPI_MEM_DIN1_NUM_S 2 + +/* SPI_MEM_DIN0_NUM : R/W ;bitpos:[1:0] ;default: 2'h0 ; */ + +/* Description: SPI_D input delay number. */ + +#define SPI_MEM_DIN0_NUM 0x00000003 +#define SPI_MEM_DIN0_NUM_M ((SPI_MEM_DIN0_NUM_V)<<(SPI_MEM_DIN0_NUM_S)) +#define SPI_MEM_DIN0_NUM_V 0x3 +#define SPI_MEM_DIN0_NUM_S 0 + +#define SPI_MEM_DOUT_MODE_REG(i) (REG_SPI_MEM_BASE(i) + 0xB4) + +/* SPI_MEM_DOUTS_MODE : R/W ;bitpos:[8] ;default: 3'h0 ; */ + +/* Description: the output signals are delayed by system clock cycles + * 0: output without delayed + * 1: output with the posedge of clk_apb 2 output with the negedge of clk_apb + * 3: output with the spi_clk + */ + +#define SPI_MEM_DOUTS_MODE 0x00000007 +#define SPI_MEM_DOUTS_MODE_M ((SPI_MEM_DOUTS_MODE_V)<<(SPI_MEM_DOUTS_MODE_S)) +#define SPI_MEM_DOUTS_MODE_V 0x7 +#define SPI_MEM_DOUTS_MODE_S 24 + +/* SPI_MEM_DOUT7_MODE : R/W ;bitpos:[23:21] ;default: 3'h0 ; */ + +/* Description: the output signals are delayed by system clock cycles + * 0: output without delayed + * 1: output with the posedge of clk_apb + * 2: output with the negedge of clk_apb + * 3: output with the spi_clk + */ + +#define SPI_MEM_DOUT7_MODE 0x00000007 +#define SPI_MEM_DOUT7_MODE_M ((SPI_MEM_DOUT7_MODE_V)<<(SPI_MEM_DOUT7_MODE_S)) +#define SPI_MEM_DOUT7_MODE_V 0x7 +#define SPI_MEM_DOUT7_MODE_S 21 + +/* SPI_MEM_DOUT6_MODE : R/W ;bitpos:[20:18] ;default: 3'h0 ; */ + +/* Description: the output signals are delayed by system clock cycles + * 0: output without delayed + * 1: output with the posedge of clk_apb + * 2: output with the negedge of clk_apb + * 3: output with the spi_clk + */ + +#define SPI_MEM_DOUT6_MODE 0x00000007 +#define SPI_MEM_DOUT6_MODE_M ((SPI_MEM_DOUT6_MODE_V)<<(SPI_MEM_DOUT6_MODE_S)) +#define SPI_MEM_DOUT6_MODE_V 0x7 +#define SPI_MEM_DOUT6_MODE_S 18 + +/* SPI_MEM_DOUT5_MODE : R/W ;bitpos:[17:15] ;default: 3'h0 ; */ + +/* Description: the output signals are delayed by system clock cycles + * 0: output without delayed + * 1: output with the posedge of clk_apb + * 2: output with the negedge of clk_apb + * 3: output with the spi_clk + */ + +#define SPI_MEM_DOUT5_MODE 0x00000007 +#define SPI_MEM_DOUT5_MODE_M ((SPI_MEM_DOUT5_MODE_V)<<(SPI_MEM_DOUT5_MODE_S)) +#define SPI_MEM_DOUT5_MODE_V 0x7 +#define SPI_MEM_DOUT5_MODE_S 15 + +/* SPI_MEM_DOUT4_MODE : R/W ;bitpos:[14:12] ;default: 3'h0 ; */ + +/* Description: the output signals are delayed by system clock cycles + * 0: output without delayed + * 1: output with the posedge of clk_apb + * 2: output with the negedge of clk_apb + * 3: output with the spi_clk + */ + +#define SPI_MEM_DOUT4_MODE 0x00000007 +#define SPI_MEM_DOUT4_MODE_M ((SPI_MEM_DOUT4_MODE_V)<<(SPI_MEM_DOUT4_MODE_S)) +#define SPI_MEM_DOUT4_MODE_V 0x7 +#define SPI_MEM_DOUT4_MODE_S 12 + +/* SPI_MEM_DOUT3_MODE : R/W ;bitpos:[11:9] ;default: 3'h0 ; */ + +/* Description: the output signals are delayed by system clock cycles + * 0: output without delayed + * 1: output with the posedge of clk_apb + * 2: output with the negedge of clk_apb + * 3: output with the posedge of clk_160 + * 4: output with the negedge of clk_160 + * 5: output with the spi_clk high edge + * 6: output with the spi_clk low edge + */ + +#define SPI_MEM_DOUT3_MODE 0x00000007 +#define SPI_MEM_DOUT3_MODE_M ((SPI_MEM_DOUT3_MODE_V)<<(SPI_MEM_DOUT3_MODE_S)) +#define SPI_MEM_DOUT3_MODE_V 0x7 +#define SPI_MEM_DOUT3_MODE_S 9 + +/* SPI_MEM_DOUT2_MODE : R/W ;bitpos:[8:6] ;default: 3'h0 ; */ + +/* Description: the output signals are delayed by system clock cycles + * 0: output without delayed + * 1: output with the posedge of clk_apb + * 2: output with the negedge of clk_apb + * 3: output with the posedge of clk_160 + * 4: output with the negedge of clk_160 + * 5: output with the spi_clk high edge + * 6: output with the spi_clk low edge + */ + +#define SPI_MEM_DOUT2_MODE 0x00000007 +#define SPI_MEM_DOUT2_MODE_M ((SPI_MEM_DOUT2_MODE_V)<<(SPI_MEM_DOUT2_MODE_S)) +#define SPI_MEM_DOUT2_MODE_V 0x7 +#define SPI_MEM_DOUT2_MODE_S 6 + +/* SPI_MEM_DOUT1_MODE : R/W ;bitpos:[5:3] ;default: 3'h0 ; */ + +/* Description: the output signals are delayed by system clock cycles + * 0: output without delayed + * 1: output with the posedge of clk_apb + * 2: output with the negedge of clk_apb + * 3: output with the posedge of clk_160 + * 4: output with the negedge of clk_160 + * 5: output with the spi_clk high edge + * 6: output with the spi_clk low edge + */ + +#define SPI_MEM_DOUT1_MODE 0x00000007 +#define SPI_MEM_DOUT1_MODE_M ((SPI_MEM_DOUT1_MODE_V)<<(SPI_MEM_DOUT1_MODE_S)) +#define SPI_MEM_DOUT1_MODE_V 0x7 +#define SPI_MEM_DOUT1_MODE_S 3 + +/* SPI_MEM_DOUT0_MODE : R/W ;bitpos:[2:0] ;default: 3'h0 ; */ + +/* Description: the output signals are delayed by system clock cycles + * 0: output without delayed + * 1: output with the posedge of clk_apb + * 2: output with the negedge of clk_apb + * 3: output with the posedge of clk_160 + * 4: output with the negedge of clk_160 + * 5: output with the spi_clk high edge + * 6: output with the spi_clk low edge + */ + +#define SPI_MEM_DOUT0_MODE 0x00000007 +#define SPI_MEM_DOUT0_MODE_M ((SPI_MEM_DOUT0_MODE_V)<<(SPI_MEM_DOUT0_MODE_S)) +#define SPI_MEM_DOUT0_MODE_V 0x7 +#define SPI_MEM_DOUT0_MODE_S 0 + +#define SPI_MEM_DOUT_NUM_REG(i) (REG_SPI_MEM_BASE(i) + 0x0B8) + +/* SPI_MEM_DOUTS_NUM : R/W ;bitpos:[17:16] ;default: 2'h0 ; */ + +/* Description: the output signals are delayed by system clock cycles + * 0: delayed by 1 cycle 1: delayed by 2 cycles ... + */ + +#define SPI_MEM_DOUTS_NUM 0x00000003 +#define SPI_MEM_DOUTS_NUM_M ((SPI_MEM_DOUTS_NUM_V)<<(SPI_MEM_DOUTS_NUM_S)) +#define SPI_MEM_DOUTS_NUM_V 0x3 +#define SPI_MEM_DOUTS_NUM_S 16 + +/* SPI_MEM_DOUT7_NUM : R/W ;bitpos:[15:14] ;default: 2'h0 ; */ + +/* Description: the output signals are delayed by system clock cycles + * 0: delayed by 1 cycle + * 1: delayed by 2 cycles ... + */ + +#define SPI_MEM_DOUT7_NUM 0x00000003 +#define SPI_MEM_DOUT7_NUM_M ((SPI_MEM_DOUT7_NUM_V)<<(SPI_MEM_DOUT7_NUM_S)) +#define SPI_MEM_DOUT7_NUM_V 0x3 +#define SPI_MEM_DOUT7_NUM_S 14 + +/* SPI_MEM_DOUT6_NUM : R/W ;bitpos:[13:12] ;default: 2'h0 ; */ + +/* Description: the output signals are delayed by system clock cycles + * 0: delayed by 1 cycle + * 1: delayed by 2 cycles ... + */ + +#define SPI_MEM_DOUT6_NUM 0x00000003 +#define SPI_MEM_DOUT6_NUM_M ((SPI_MEM_DOUT6_NUM_V)<<(SPI_MEM_DOUT6_NUM_S)) +#define SPI_MEM_DOUT6_NUM_V 0x3 +#define SPI_MEM_DOUT6_NUM_S 12 + +/* SPI_MEM_DOUT5_NUM : R/W ;bitpos:[11:10] ;default: 2'h0 ; */ + +/* Description: the output signals are delayed by system clock cycles + * 0: delayed by 1 cycle 1: delayed by 2 cycles ... + */ + +#define SPI_MEM_DOUT5_NUM 0x00000003 +#define SPI_MEM_DOUT5_NUM_M ((SPI_MEM_DOUT5_NUM_V)<<(SPI_MEM_DOUT5_NUM_S)) +#define SPI_MEM_DOUT5_NUM_V 0x3 +#define SPI_MEM_DOUT5_NUM_S 10 + +/* SPI_MEM_DOUT4_NUM : R/W ;bitpos:[9:8] ;default: 2'h0 ; */ + +/* Description: the output signals are delayed by system clock cycles + * 0: delayed by 1 cycle 1: delayed by 2 cycles ... + */ + +#define SPI_MEM_DOUT4_NUM 0x00000003 +#define SPI_MEM_DOUT4_NUM_M ((SPI_MEM_DOUT4_NUM_V)<<(SPI_MEM_DOUT4_NUM_S)) +#define SPI_MEM_DOUT4_NUM_V 0x3 +#define SPI_MEM_DOUT4_NUM_S 8 + +/* SPI_MEM_DOUT3_NUM : R/W ;bitpos:[7:6] ;default: 2'h0 ; */ + +/* Description: the output signals are delayed by system clock cycles + * 0: delayed by 1 cycle 1: delayed by 2 cycles ... + */ + +#define SPI_MEM_DOUT3_NUM 0x00000003 +#define SPI_MEM_DOUT3_NUM_M ((SPI_MEM_DOUT3_NUM_V)<<(SPI_MEM_DOUT3_NUM_S)) +#define SPI_MEM_DOUT3_NUM_V 0x3 +#define SPI_MEM_DOUT3_NUM_S 6 + +/* SPI_MEM_DOUT2_NUM : R/W ;bitpos:[5:4] ;default: 2'h0 ; */ + +/* Description: the output signals are delayed by system clock cycles + * 0: delayed by 1 cycle 1: delayed by 2 cycles ... + */ + +#define SPI_MEM_DOUT2_NUM 0x00000003 +#define SPI_MEM_DOUT2_NUM_M ((SPI_MEM_DOUT2_NUM_V)<<(SPI_MEM_DOUT2_NUM_S)) +#define SPI_MEM_DOUT2_NUM_V 0x3 +#define SPI_MEM_DOUT2_NUM_S 4 + +/* SPI_MEM_DOUT1_NUM : R/W ;bitpos:[3:2] ;default: 2'h0 ; */ + +/* Description: the output signals are delayed by system clock cycles + * 0: delayed by 1 cycle 1: delayed by 2 cycles ... + */ + +#define SPI_MEM_DOUT1_NUM 0x00000003 +#define SPI_MEM_DOUT1_NUM_M ((SPI_MEM_DOUT1_NUM_V)<<(SPI_MEM_DOUT1_NUM_S)) +#define SPI_MEM_DOUT1_NUM_V 0x3 +#define SPI_MEM_DOUT1_NUM_S 2 + +/* SPI_MEM_DOUT0_NUM : R/W ;bitpos:[1:0] ;default: 2'h0 ; */ + +/* Description: the output signals are delayed by system clock cycles + * 0: delayed by 1 cycle 1: delayed by 2 cycles ... + */ + +#define SPI_MEM_DOUT0_NUM 0x00000003 +#define SPI_MEM_DOUT0_NUM_M ((SPI_MEM_DOUT0_NUM_V)<<(SPI_MEM_DOUT0_NUM_S)) +#define SPI_MEM_DOUT0_NUM_V 0x3 +#define SPI_MEM_DOUT0_NUM_S 0 + +/* SPI_MEM_SPI_SMEM_EXTRA_DUMMY_CYCLELEN: R/W ;bitpos:[4:2]; default: 3'd0; */ + +/* Description: Extra SPI_CLK cycles added in DUMMY phase for timing + * compensation, when SPI0 accesses to Ext_RAM. Active when + * SPI_SMEM_TIMING_CALI bit is set. + */ + +#define SPI_MEM_SPI_SMEM_EXTRA_DUMMY_CYCLELEN 0x00000003 +#define SPI_MEM_SPI_SMEM_EXTRA_DUMMY_CYCLELEN_M ((SPI_MEM_SPI_SMEM_EXTRA_DUMMY_CYCLELEN_V)<<(SPI_MEM_SPI_SMEM_EXTRA_DUMMY_CYCLELEN_S)) +#define SPI_MEM_SPI_SMEM_EXTRA_DUMMY_CYCLELEN_V 0x3 +#define SPI_MEM_SPI_SMEM_EXTRA_DUMMY_CYCLELEN_S 2 + +/* SPI_MEM_SPI_SMEM_TIMING_CALI : R/W ;bitpos:[1] ;default: 1'b0 ; */ + +/* Description: Set this bit to add extra SPI_CLK cycles in DUMMY phase for + * all reading operations. + */ + +#define SPI_MEM_SPI_SMEM_TIMING_CALI (BIT(1)) +#define SPI_MEM_SPI_SMEM_TIMING_CALI_M (BIT(1)) +#define SPI_MEM_SPI_SMEM_TIMING_CALI_V 0x1 +#define SPI_MEM_SPI_SMEM_TIMING_CALI_S 1 + +/* SPI_MEM_SPI_SMEM_TIMING_CLK_ENA : R/W ;bitpos:[0] ;default: 1'b0 ; */ + +/* Description: Set this bit to power on HCLK. When PLL is powered on, the + * frequency of HCLK equals to that of PLL. Otherwise, the frequency equals + * to that of XTAL. + */ + +#define SPI_MEM_SPI_SMEM_TIMING_CLK_ENA (BIT(0)) +#define SPI_MEM_SPI_SMEM_TIMING_CLK_ENA_M (BIT(0)) +#define SPI_MEM_SPI_SMEM_TIMING_CLK_ENA_V 0x1 +#define SPI_MEM_SPI_SMEM_TIMING_CLK_ENA_S 0 + +#define SPI_MEM_SPI_SMEM_DIN_MODE_REG(i) (REG_SPI_MEM_BASE(i) + 0xC0) + +/* SPI_MEM_SPI_SMEM_DINS_MODE : R/W ;bitpos:[26:24] ;default: 3'h0 ; */ + +/* Description: SPI_DQS input delay mode. + * 0: No delay. + * 1: Delay for (SPI_SMEM_DINS_NUM+1) cycles at MSPI_CORE_CLK negative edge. + * 2: Delay for (SPI_SMEM_DINS_NUM+1) cycles at HCLK positive edge and one + * cycle at MSPI_CORE_CLK positive edge. + * 3: Delay for (SPI_SMEM_DINS_NUM+1) cycles at HCLK positive edge and one + * cycle at MSPI_CORE_CLK negative edge. + * 4: Delay for (SPI_SMEM_DINS_NUM+1) cycles at HCLK negative edge and one + * cycle at MSPI_CORE_CLK positive edge. + * 5: Delay for (SPI_SMEM_DINS_NUM+1) cycles at HCLK negative edge and one + * cycle at MSPI_CORE_CLK negative edge. + */ + +#define SPI_MEM_SPI_SMEM_DINS_MODE 0x00000007 +#define SPI_MEM_SPI_SMEM_DINS_MODE_M ((SPI_MEM_SPI_SMEM_DINS_MODE_V)<<(SPI_MEM_SPI_SMEM_DINS_MODE_S)) +#define SPI_MEM_SPI_SMEM_DINS_MODE_V 0x7 +#define SPI_MEM_SPI_SMEM_DINS_MODE_S 24 + +/* SPI_MEM_SPI_SMEM_DIN7_MODE : R/W ;bitpos:[23:21] ;default: 3'h0 ; */ + +/* Description: SPI_IO7 input delay mode. + * 0: No delay. + * 1: Delay for (SPI_SMEM_DIN$n_NUM+1) cycles at MSPI_CORE_CLK negative edge. + * 2: Delay for (SPI_SMEM_DIN$n_NUM+1) cycles at HCLK positive edge and one + * cycle at MSPI_CORE_CLK positive edge. + * 3: Delay for (SPI_SMEM_DIN$n_NUM+1) cycles at HCLK positive edge and one + * cycle at MSPI_CORE_CLK negative edge. + * 4: Delay for (SPI_SMEM_DIN$n_NUM+1) cycles at HCLK negative edge and one + * cycle at MSPI_CORE_CLK positive edge. + * 5: Delay for (SPI_SMEM_DIN$n_NUM+1) cycles at HCLK negative edge and one + * cycle at MSPI_CORE_CLK negative edge. + */ + +#define SPI_MEM_SPI_SMEM_DIN7_MODE 0x00000007 +#define SPI_MEM_SPI_SMEM_DIN7_MODE_M ((SPI_MEM_SPI_SMEM_DIN7_MODE_V)<<(SPI_MEM_SPI_SMEM_DIN7_MODE_S)) +#define SPI_MEM_SPI_SMEM_DIN7_MODE_V 0x7 +#define SPI_MEM_SPI_SMEM_DIN7_MODE_S 21 + +/* SPI_MEM_SPI_SMEM_DIN6_MODE : R/W ;bitpos:[20:18] ;default: 3'h0 ; */ + +/* Description: SPI_IO6 input delay mode. + * 0: No delay. + * 1: Delay for (SPI_SMEM_DIN$n_NUM+1) cycles at MSPI_CORE_CLK negative edge. + * 2: Delay for (SPI_SMEM_DIN$n_NUM+1) cycles at HCLK positive edge and one + * cycle at MSPI_CORE_CLK positive edge. + * 3: Delay for (S PI_SMEM_DIN$n_NUM+1) cycles at HCLK positive edge and one + * cycle at MSPI_CORE_CLK negative edge. + * 4: Delay for (SPI_SMEM_DIN$n_NUM+1) cycles at HCLK negative edge and one + * cycle at MSPI_CORE_CLK positive edge. + * 5: Delay for (SPI_SMEM_DIN$n_NUM+1) cycles at HCLK negative edge and one + * cycle at MSPI_CORE_CLK negative edge. + */ + +#define SPI_MEM_SPI_SMEM_DIN6_MODE 0x00000007 +#define SPI_MEM_SPI_SMEM_DIN6_MODE_M ((SPI_MEM_SPI_SMEM_DIN6_MODE_V)<<(SPI_MEM_SPI_SMEM_DIN6_MODE_S)) +#define SPI_MEM_SPI_SMEM_DIN6_MODE_V 0x7 +#define SPI_MEM_SPI_SMEM_DIN6_MODE_S 18 + +/* SPI_MEM_SPI_SMEM_DIN5_MODE : R/W ;bitpos:[17:15] ;default: 3'h0 ; */ + +/* Description: SPI_IO5 input delay mode. + * 0: No delay. + * 1: Delay for (SPI_SMEM_DIN$n_NUM+1) cycles at MSPI_CORE_CLK negative edge. + * 2: Delay for (SPI_SMEM_DIN$n_NUM+1) cycles at HCLK positive edge and one + * cycle at MSPI_CORE_CLK positive edge. + * 3: Delay for (SPI_SMEM_DIN$n_NUM+1) cycles at HCLK positive edge and one + * cycle at MSPI_CORE_CLK negative edge. + * 4: Delay for (SPI_SMEM_DIN$n_NUM+1) cycles at HCLK negative edge and one + * cycle at MSPI_CORE_CLK positive edge. + * 5: Delay for (SPI_SMEM_DIN$n_NUM+1) cycles at HCLK negative edge and one + * cycle at MSPI_CORE_CLK negative edge. + */ + +#define SPI_MEM_SPI_SMEM_DIN5_MODE 0x00000007 +#define SPI_MEM_SPI_SMEM_DIN5_MODE_M ((SPI_MEM_SPI_SMEM_DIN5_MODE_V)<<(SPI_MEM_SPI_SMEM_DIN5_MODE_S)) +#define SPI_MEM_SPI_SMEM_DIN5_MODE_V 0x7 +#define SPI_MEM_SPI_SMEM_DIN5_MODE_S 15 + +/* SPI_MEM_SPI_SMEM_DIN4_MODE : R/W ;bitpos:[14:12] ;default: 3'h0 ; */ + +/* Description: SPI_IO4 input delay mode. + * 0: No delay. + * 1: Delay for (SPI_SMEM_DIN$n_NUM+1) cycles at MSPI_CORE_CLK negative edge. + * 2: Delay for (SPI_SMEM_DIN$n_NUM+1) cycles at HCLK positive edge and one + * cycle at MSPI_CORE_CLK positive edge. + * 3: Delay for (SPI_SMEM_DIN$n_NUM+1) cycles at HCLK positive edge and one + * cycle at MSPI_CORE_CLK negative edge. + * 4: Delay for (SPI_SMEM_DIN$n_NUM+1) cycles at HCLK negative edge and one + * cycle at MSPI_CORE_CLK positive edge. + * 5: Delay for (SPI_SMEM_DIN$n_NUM+ 1) cycles at HCLK negative edge and one + * cycle at MSPI_CORE_CLK negative edge. + */ + +#define SPI_MEM_SPI_SMEM_DIN4_MODE 0x00000007 +#define SPI_MEM_SPI_SMEM_DIN4_MODE_M ((SPI_MEM_SPI_SMEM_DIN4_MODE_V)<<(SPI_MEM_SPI_SMEM_DIN4_MODE_S)) +#define SPI_MEM_SPI_SMEM_DIN4_MODE_V 0x7 +#define SPI_MEM_SPI_SMEM_DIN4_MODE_S 12 + +/* SPI_MEM_SPI_SMEM_DIN3_MODE : R/W ;bitpos:[11:9] ;default: 3'h0 ; */ + +/* Description: SPI_HD input delay mode. + * 0: No delay. + * 1: Delay for (SPI_SMEM_DIN$n_NUM+1) cycles at MSPI_CORE_CLK negative edge. + * 2: Delay for (SPI_SMEM_DIN$n_NUM+1) cycles at HCLK positive edge and one + * cycle at MSPI_CORE_CLK positive edge. + * 3: Delay for (SPI_SMEM_DIN$n_NUM+1) cycles at HCLK positive edge and one + * cycle at MSPI_CORE_CLK negative edge. + * 4: Delay for (SPI_SMEM_DIN$n_NUM+1) cycles at HCLK negative edge and one + * cycle at MSPI_CORE_CLK positive edge. + * 5: Delay for (SPI_SMEM_DIN$n_NUM+1) cycles at HCLK negative edge and one + * cycle at MSPI_CORE_CLK negative edge. + */ + +#define SPI_MEM_SPI_SMEM_DIN3_MODE 0x00000007 +#define SPI_MEM_SPI_SMEM_DIN3_MODE_M ((SPI_MEM_SPI_SMEM_DIN3_MODE_V)<<(SPI_MEM_SPI_SMEM_DIN3_MODE_S)) +#define SPI_MEM_SPI_SMEM_DIN3_MODE_V 0x7 +#define SPI_MEM_SPI_SMEM_DIN3_MODE_S 9 + +/* SPI_MEM_SPI_SMEM_DIN2_MODE : R/W ;bitpos:[8:6] ;default: 3'h0 ; */ + +/* Description: SPI_WP input delay mode. + * 0: No delay. + * 1: Delay for (SPI_SMEM_DIN$n_NUM+1) cycles at MSPI_CORE_CLK negative edge. + * 2: Delay for (SPI_SMEM_DIN$n_NUM+1) cycles at HCLK positive edge and one + * cycle at MSPI_CORE_CLK positive edge. + * 3: Delay for (SPI_SMEM_DIN$n_NUM+1) cycles at HCLK positive edge and one + * cycle at MSPI_CORE_CLK negative edge. + * 4: Delay for (SPI_SMEM_DIN$n_NUM+1) cycles at HCLK negative edge and one + * cycle at MSPI_CORE_CLK positive edge. + * 5: Delay for (SPI_SMEM_DIN$n_NUM+1) cycles at HCLK negative edge and one + * cycle at MSPI_CORE_CLK negative edge. + */ + +#define SPI_MEM_SPI_SMEM_DIN2_MODE 0x00000007 +#define SPI_MEM_SPI_SMEM_DIN2_MODE_M ((SPI_MEM_SPI_SMEM_DIN2_MODE_V)<<(SPI_MEM_SPI_SMEM_DIN2_MODE_S)) +#define SPI_MEM_SPI_SMEM_DIN2_MODE_V 0x7 +#define SPI_MEM_SPI_SMEM_DIN2_MODE_S 6 + +/* SPI_MEM_SPI_SMEM_DIN1_MODE : R/W ;bitpos:[5:3] ;default: 3'h0 ; */ + +/* Description: SPI_Q input delay mode. + * 0: No delay. + * 1: Delay for (SPI_SMEM_DIN$n_NUM+1) cycles at MSPI_CORE_CLK negative edge. + * 2: Delay for (SPI_SMEM_DIN$n_NUM+1) cycles at HCLK positive edge and one + * cycle at MSPI_CORE_CLK positive edge. + * 3: Delay for (SPI_SMEM_DIN$n_NUM+1) cycles at HCLK positive edge and one + * cycle at MSPI_CORE_CLK negative edge. + * 4: Delay for (SPI_SMEM_DIN$n_NUM+1) cycles at HCLK negative edge and one + * cycle at MSPI_CORE_CLK positive edge. + * 5: Delay for (SPI_SMEM_DIN$n_NUM+1) cycles at HCLK negative edge and one + * cycle at MSPI_CORE_CLK negative edge. + */ + +#define SPI_MEM_SPI_SMEM_DIN1_MODE 0x00000007 +#define SPI_MEM_SPI_SMEM_DIN1_MODE_M ((SPI_MEM_SPI_SMEM_DIN1_MODE_V)<<(SPI_MEM_SPI_SMEM_DIN1_MODE_S)) +#define SPI_MEM_SPI_SMEM_DIN1_MODE_V 0x7 +#define SPI_MEM_SPI_SMEM_DIN1_MODE_S 3 + +/* SPI_MEM_SPI_SMEM_DIN0_MODE : R/W ;bitpos:[2:0] ;default: 3'h0 ; */ + +/* Description: SPI_D input delay mode. + * 0: No delay. + * 1: Delay for (SPI_SMEM_DIN$n_NUM+1) cycles at MSPI_CORE_CLK negative edge. + * 2: Delay for (SPI_SMEM_DIN$n_NUM+1) cycles at HCLK positive edge and one + * cycle at MSPI_CORE_CLK positive edge. + * 3: Delay for (SPI_SMEM_DIN$n_NUM+1) cycles at HCLK positive edge and one + * cycle at MSPI_CORE_CLK negative edge. + * 4: Delay for (SPI_SMEM_DIN$n_NUM+1) cycles at HCLK negative edge and one + * cycle at MSPI_CORE_CLK positive edge. + * 5: Delay for (SPI_SMEM_DIN$n_NUM+1) cycles at HCLK negative edge and one + * cycle at MSPI_CORE_CLK negative edge. + */ + +#define SPI_MEM_SPI_SMEM_DIN0_MODE 0x00000007 +#define SPI_MEM_SPI_SMEM_DIN0_MODE_M ((SPI_MEM_SPI_SMEM_DIN0_MODE_V)<<(SPI_MEM_SPI_SMEM_DIN0_MODE_S)) +#define SPI_MEM_SPI_SMEM_DIN0_MODE_V 0x7 +#define SPI_MEM_SPI_SMEM_DIN0_MODE_S 0 + +#define SPI_MEM_SPI_SMEM_DIN_NUM_REG(i) (REG_SPI_MEM_BASE(i) + 0xC4) + +/* SPI_MEM_SPI_SMEM_DINS_NUM : R/W ;bitpos:[17:16] ;default: 2'h0 ; */ + +/* Description: SPI_DQS input delay number. */ + +#define SPI_MEM_SPI_SMEM_DINS_NUM 0x00000003 +#define SPI_MEM_SPI_SMEM_DINS_NUM_M ((SPI_MEM_SPI_SMEM_DINS_NUM_V)<<(SPI_MEM_SPI_SMEM_DINS_NUM_S)) +#define SPI_MEM_SPI_SMEM_DINS_NUM_V 0x3 +#define SPI_MEM_SPI_SMEM_DINS_NUM_S 16 + +/* SPI_MEM_SPI_SMEM_DIN7_NUM : R/W ;bitpos:[15:14] ;default: 2'h0 ; */ + +/* Description: SPI_IO7 input delay number. */ + +#define SPI_MEM_SPI_SMEM_DIN7_NUM 0x00000003 +#define SPI_MEM_SPI_SMEM_DIN7_NUM_M ((SPI_MEM_SPI_SMEM_DIN7_NUM_V)<<(SPI_MEM_SPI_SMEM_DIN7_NUM_S)) +#define SPI_MEM_SPI_SMEM_DIN7_NUM_V 0x3 +#define SPI_MEM_SPI_SMEM_DIN7_NUM_S 14 + +/* SPI_MEM_SPI_SMEM_DIN6_NUM : R/W ;bitpos:[13:12] ;default: 2'h0 ; */ + +/* Description: SPI_IO6 input delay number. */ + +#define SPI_MEM_SPI_SMEM_DIN6_NUM 0x00000003 +#define SPI_MEM_SPI_SMEM_DIN6_NUM_M ((SPI_MEM_SPI_SMEM_DIN6_NUM_V)<<(SPI_MEM_SPI_SMEM_DIN6_NUM_S)) +#define SPI_MEM_SPI_SMEM_DIN6_NUM_V 0x3 +#define SPI_MEM_SPI_SMEM_DIN6_NUM_S 12 + +/* SPI_MEM_SPI_SMEM_DIN5_NUM : R/W ;bitpos:[11:10] ;default: 2'h0 ; */ + +/* Description: SPI_IO5 input delay number. */ + +#define SPI_MEM_SPI_SMEM_DIN5_NUM 0x00000003 +#define SPI_MEM_SPI_SMEM_DIN5_NUM_M ((SPI_MEM_SPI_SMEM_DIN5_NUM_V)<<(SPI_MEM_SPI_SMEM_DIN5_NUM_S)) +#define SPI_MEM_SPI_SMEM_DIN5_NUM_V 0x3 +#define SPI_MEM_SPI_SMEM_DIN5_NUM_S 10 + +/* SPI_MEM_SPI_SMEM_DIN4_NUM : R/W ;bitpos:[9:8] ;default: 2'h0 ; */ + +/* Description: SPI_IO4 input delay number. */ + +#define SPI_MEM_SPI_SMEM_DIN4_NUM 0x00000003 +#define SPI_MEM_SPI_SMEM_DIN4_NUM_M ((SPI_MEM_SPI_SMEM_DIN4_NUM_V)<<(SPI_MEM_SPI_SMEM_DIN4_NUM_S)) +#define SPI_MEM_SPI_SMEM_DIN4_NUM_V 0x3 +#define SPI_MEM_SPI_SMEM_DIN4_NUM_S 8 + +/* SPI_MEM_SPI_SMEM_DIN3_NUM : R/W ;bitpos:[7:6] ;default: 2'h0 ; */ + +/* Description: SPI_HD input delay number. */ + +#define SPI_MEM_SPI_SMEM_DIN3_NUM 0x00000003 +#define SPI_MEM_SPI_SMEM_DIN3_NUM_M ((SPI_MEM_SPI_SMEM_DIN3_NUM_V)<<(SPI_MEM_SPI_SMEM_DIN3_NUM_S)) +#define SPI_MEM_SPI_SMEM_DIN3_NUM_V 0x3 +#define SPI_MEM_SPI_SMEM_DIN3_NUM_S 6 + +/* SPI_MEM_SPI_SMEM_DIN2_NUM : R/W ;bitpos:[5:4] ;default: 2'h0 ; */ + +/* Description: SPI_WP input delay number. */ + +#define SPI_MEM_SPI_SMEM_DIN2_NUM 0x00000003 +#define SPI_MEM_SPI_SMEM_DIN2_NUM_M ((SPI_MEM_SPI_SMEM_DIN2_NUM_V)<<(SPI_MEM_SPI_SMEM_DIN2_NUM_S)) +#define SPI_MEM_SPI_SMEM_DIN2_NUM_V 0x3 +#define SPI_MEM_SPI_SMEM_DIN2_NUM_S 4 + +/* SPI_MEM_SPI_SMEM_DIN1_NUM : R/W ;bitpos:[3:2] ;default: 2'h0 ; */ + +/* Description: SPI_Q input delay number. */ + +#define SPI_MEM_SPI_SMEM_DIN1_NUM 0x00000003 +#define SPI_MEM_SPI_SMEM_DIN1_NUM_M ((SPI_MEM_SPI_SMEM_DIN1_NUM_V)<<(SPI_MEM_SPI_SMEM_DIN1_NUM_S)) +#define SPI_MEM_SPI_SMEM_DIN1_NUM_V 0x3 +#define SPI_MEM_SPI_SMEM_DIN1_NUM_S 2 + +/* SPI_MEM_SPI_SMEM_DIN0_NUM : R/W ;bitpos:[1:0] ;default: 2'h0 ; */ + +/* Description: SPI_D input delay number. */ + +#define SPI_MEM_SPI_SMEM_DIN0_NUM 0x00000003 +#define SPI_MEM_SPI_SMEM_DIN0_NUM_M ((SPI_MEM_SPI_SMEM_DIN0_NUM_V)<<(SPI_MEM_SPI_SMEM_DIN0_NUM_S)) +#define SPI_MEM_SPI_SMEM_DIN0_NUM_V 0x3 +#define SPI_MEM_SPI_SMEM_DIN0_NUM_S 0 + +#define SPI_MEM_SPI_SMEM_DOUT_MODE_REG(i) (REG_SPI_MEM_BASE(i) + 0x0C8) + +/* SPI_MEM_SPI_SMEM_DOUTS_MODE : R/W ;bitpos:[26:24] ;default: 3'h0 ; */ + +/* Description: the output signals are delayed by system clock cycles + * 0: output without delayed + * 1: output with the posedge of clk_apb + * 2: output with the negedge of clk_apb + * 3: output with the posedge of clk_160 + * 4: output with the negedge of clk_160 + * 5: output with the spi_clk high edge + * 6: output with the spi_clk low edge + */ + +#define SPI_MEM_SPI_SMEM_DOUTS_MODE 0x00000007 +#define SPI_MEM_SPI_SMEM_DOUTS_MODE_M ((SPI_MEM_SPI_SMEM_DOUTS_MODE_V)<<(SPI_MEM_SPI_SMEM_DOUTS_MODE_S)) +#define SPI_MEM_SPI_SMEM_DOUTS_MODE_V 0x7 +#define SPI_MEM_SPI_SMEM_DOUTS_MODE_S 24 + +/* SPI_MEM_SPI_SMEM_DOUT7_MODE : R/W ;bitpos:[23:21] ;default: 3'h0 ; */ + +/* Description: the output signals are delayed by system clock cycles + * 0: output without delayed + * 1: output with the posedge of clk_apb + * 2: output with the negedge of clk_apb + * 3: output with the posedge of clk_160 + * 4: output with the negedge of clk_160 + * 5: output with the spi_clk high edge + * 6: output with the spi_clk low edge + */ + +#define SPI_MEM_SPI_SMEM_DOUT7_MODE 0x00000007 +#define SPI_MEM_SPI_SMEM_DOUT7_MODE_M ((SPI_MEM_SPI_SMEM_DOUT7_MODE_V)<<(SPI_MEM_SPI_SMEM_DOUT7_MODE_S)) +#define SPI_MEM_SPI_SMEM_DOUT7_MODE_V 0x7 +#define SPI_MEM_SPI_SMEM_DOUT7_MODE_S 21 + +/* SPI_MEM_SPI_SMEM_DOUT6_MODE : R/W ;bitpos:[20:18] ;default: 3'h0 ; */ + +/* Description: the output signals are delayed by system clock cycles + * 0: output without delayed + * 1: output with the posedge of clk_apb + * 2: output with the negedge of clk_apb + * 3: output with the posedge of clk_160 + * 4: output with the negedge of clk_160 + * 5: output with the spi_clk high edge + * 6: output with the spi_clk low edge + */ +#define SPI_MEM_SPI_SMEM_DOUT6_MODE 0x00000007 +#define SPI_MEM_SPI_SMEM_DOUT6_MODE_M ((SPI_MEM_SPI_SMEM_DOUT6_MODE_V)<<(SPI_MEM_SPI_SMEM_DOUT6_MODE_S)) +#define SPI_MEM_SPI_SMEM_DOUT6_MODE_V 0x7 +#define SPI_MEM_SPI_SMEM_DOUT6_MODE_S 18 + +/* SPI_MEM_SPI_SMEM_DOUT5_MODE : R/W ;bitpos:[17:15] ;default: 3'h0 ; */ + +/* Description: the output signals are delayed by system clock cycles + * 0: output without delayed + * 1: output with the posedge of clk_apb + * 2: output with the negedge of clk_apb + * 3: output with the posedge of clk_160 + * 4: output with the negedge of clk_160 + * 5: output with the spi_clk high edge + * 6: output with the spi_clk low edge + */ + +#define SPI_MEM_SPI_SMEM_DOUT5_MODE 0x00000007 +#define SPI_MEM_SPI_SMEM_DOUT5_MODE_M ((SPI_MEM_SPI_SMEM_DOUT5_MODE_V)<<(SPI_MEM_SPI_SMEM_DOUT5_MODE_S)) +#define SPI_MEM_SPI_SMEM_DOUT5_MODE_V 0x7 +#define SPI_MEM_SPI_SMEM_DOUT5_MODE_S 15 + +/* SPI_MEM_SPI_SMEM_DOUT4_MODE : R/W ;bitpos:[14:12] ;default: 3'h0 ; */ + +/* Description: the output signals are delayed by system clock cycles + * 0: output without delayed + * 1: output with the posedge of clk_apb + * 2: output with the negedge of clk_apb + * 3: output with the posedge of clk_160 + * 4: output with the negedge of clk_160 + * 5: output with the spi_clk high edge + * 6: output with the spi_clk low edge + */ + +#define SPI_MEM_SPI_SMEM_DOUT4_MODE 0x00000007 +#define SPI_MEM_SPI_SMEM_DOUT4_MODE_M ((SPI_MEM_SPI_SMEM_DOUT4_MODE_V)<<(SPI_MEM_SPI_SMEM_DOUT4_MODE_S)) +#define SPI_MEM_SPI_SMEM_DOUT4_MODE_V 0x7 +#define SPI_MEM_SPI_SMEM_DOUT4_MODE_S 12 + +/* SPI_MEM_SPI_SMEM_DOUT3_MODE : R/W ;bitpos:[11:9] ;default: 3'h0 ; */ + +/* Description: the output signals are delayed by system clock cycles + * 0: output without delayed + * 1: output with the posedge of clk_apb + * 2: output with the negedge of clk_apb + * 3: output with the posedge of clk_160 + * 4: output with the negedge of clk_160 + * 5: output with the spi_clk high edge + * 6: output with the spi_clk low edge + */ + +#define SPI_MEM_SPI_SMEM_DOUT3_MODE 0x00000007 +#define SPI_MEM_SPI_SMEM_DOUT3_MODE_M ((SPI_MEM_SPI_SMEM_DOUT3_MODE_V)<<(SPI_MEM_SPI_SMEM_DOUT3_MODE_S)) +#define SPI_MEM_SPI_SMEM_DOUT3_MODE_V 0x7 +#define SPI_MEM_SPI_SMEM_DOUT3_MODE_S 9 + +/* SPI_MEM_SPI_SMEM_DOUT2_MODE : R/W ;bitpos:[8:6] ;default: 3'h0 ; */ + +/* Description: the output signals are delayed by system clock cycles + * 0: output without delayed + * 1: output with the posedge of clk_apb + * 2: output with the negedge of clk_apb + * 3: output with the posedge of clk_160 + * 4 output with the negedge of clk_160 + * 5: output with the spi_clk high edge + * 6: output with the spi_clk low edge + */ + +#define SPI_MEM_SPI_SMEM_DOUT2_MODE 0x00000007 +#define SPI_MEM_SPI_SMEM_DOUT2_MODE_M ((SPI_MEM_SPI_SMEM_DOUT2_MODE_V)<<(SPI_MEM_SPI_SMEM_DOUT2_MODE_S)) +#define SPI_MEM_SPI_SMEM_DOUT2_MODE_V 0x7 +#define SPI_MEM_SPI_SMEM_DOUT2_MODE_S 6 + +/* SPI_MEM_SPI_SMEM_DOUT1_MODE : R/W ;bitpos:[5:3] ;default: 3'h0 ; */ + +/* Description: the output signals are delayed by system clock cycles + * 0: output without delayed + * 1: output with the posedge of clk_apb + * 2 output with the negedge of clk_apb + * 3: output with the posedge of clk_160 + * 4: output with the negedge of clk_160 + * 5: output with the spi_clk high edge + * 6: output with the spi_clk low edge + */ + +#define SPI_MEM_SPI_SMEM_DOUT1_MODE 0x00000007 +#define SPI_MEM_SPI_SMEM_DOUT1_MODE_M ((SPI_MEM_SPI_SMEM_DOUT1_MODE_V)<<(SPI_MEM_SPI_SMEM_DOUT1_MODE_S)) +#define SPI_MEM_SPI_SMEM_DOUT1_MODE_V 0x7 +#define SPI_MEM_SPI_SMEM_DOUT1_MODE_S 3 + +/* SPI_MEM_SPI_SMEM_DOUT0_MODE : R/W ;bitpos:[2:0] ;default: 3'h0 ; */ + +/* Description: the output signals are delayed by system clock cycles + * 0: output without delayed + * 1: output with the posedge of clk_apb + * 2: output with the negedge of clk_apb + * 3: output with the posedge of clk_160 + * 4: output with the negedge of clk_160 + * 5: output with the spi_clk high edge + * 6: output with the spi_clk low edge + */ + +#define SPI_MEM_SPI_SMEM_DOUT0_MODE 0x00000007 +#define SPI_MEM_SPI_SMEM_DOUT0_MODE_M ((SPI_MEM_SPI_SMEM_DOUT0_MODE_V)<<(SPI_MEM_SPI_SMEM_DOUT0_MODE_S)) +#define SPI_MEM_SPI_SMEM_DOUT0_MODE_V 0x7 +#define SPI_MEM_SPI_SMEM_DOUT0_MODE_S 0 + +#define SPI_MEM_SPI_SMEM_DOUT_NUM_REG(i) (REG_SPI_MEM_BASE(i) + 0x0CC) + +/* SPI_MEM_SPI_SMEM_DOUTS_NUM : R/W ;bitpos:[17:16] ;default: 2'h0 ; */ + +/* Description: the output signals are delayed by system clock cycles + * 0: output without delayed + * 1: output with the posedge of clk_apb + * 2: output with the negedge of clk_apb + * 3: output with the posedge of clk_160 + * 4: output with the negedge of clk_160 + * 5: output with the spi_clk high edge + * 6: output with the spi_clk low edge + */ + +#define SPI_MEM_SPI_SMEM_DOUTS_NUM 0x00000003 +#define SPI_MEM_SPI_SMEM_DOUTS_NUM_M ((SPI_MEM_SPI_SMEM_DOUTS_NUM_V)<<(SPI_MEM_SPI_SMEM_DOUTS_NUM_S)) +#define SPI_MEM_SPI_SMEM_DOUTS_NUM_V 0x3 +#define SPI_MEM_SPI_SMEM_DOUTS_NUM_S 16 + +/* SPI_MEM_SPI_SMEM_DOUT7_NUM : R/W ;bitpos:[15:14] ;default: 2'h0 ; */ + +/* Description: the output signals are delayed by system clock cycles + * 0: output without delayed + * 1: output with the posedge of clk_apb + * 2: output with the negedge of clk_apb + * 3: output with the posedge of clk_160 + * 4: output with the negedge of clk_160 + * 5: output with the spi_clk high edge + * 6: output with the spi_clk low edge + */ + +#define SPI_MEM_SPI_SMEM_DOUT7_NUM 0x00000003 +#define SPI_MEM_SPI_SMEM_DOUT7_NUM_M ((SPI_MEM_SPI_SMEM_DOUT7_NUM_V)<<(SPI_MEM_SPI_SMEM_DOUT7_NUM_S)) +#define SPI_MEM_SPI_SMEM_DOUT7_NUM_V 0x3 +#define SPI_MEM_SPI_SMEM_DOUT7_NUM_S 14 + +/* SPI_MEM_SPI_SMEM_DOUT6_NUM : R/W ;bitpos:[13:12] ;default: 2'h0 ; */ + +/* Description: the output signals are delayed by system clock cycles + * 0: output without delayed + * 1: output with the posedge of clk_apb + * 2 output with the negedge of clk_apb + * 3: output with the posedge of clk_160 + * 4 output with the negedge of clk_160 + * 5: output with the spi_clk high edge + * 6: output with the spi_clk low edge + */ + +#define SPI_MEM_SPI_SMEM_DOUT6_NUM 0x00000003 +#define SPI_MEM_SPI_SMEM_DOUT6_NUM_M ((SPI_MEM_SPI_SMEM_DOUT6_NUM_V)<<(SPI_MEM_SPI_SMEM_DOUT6_NUM_S)) +#define SPI_MEM_SPI_SMEM_DOUT6_NUM_V 0x3 +#define SPI_MEM_SPI_SMEM_DOUT6_NUM_S 12 + +/* SPI_MEM_SPI_SMEM_DOUT5_NUM : R/W ;bitpos:[11:10] ;default: 2'h0 ; */ + +/* Description: the output signals are delayed by system clock cycles + * 0: output without delayed + * 1: output with the posedge of clk_apb + * 2 output with the negedge of clk_apb + * 3: output with the posedge of clk_160 + * 4: output with the negedge of clk_160 + * 5: output with the spi_clk high edge + * 6: output with the spi_clk low edge + */ + +#define SPI_MEM_SPI_SMEM_DOUT5_NUM 0x00000003 +#define SPI_MEM_SPI_SMEM_DOUT5_NUM_M ((SPI_MEM_SPI_SMEM_DOUT5_NUM_V)<<(SPI_MEM_SPI_SMEM_DOUT5_NUM_S)) +#define SPI_MEM_SPI_SMEM_DOUT5_NUM_V 0x3 +#define SPI_MEM_SPI_SMEM_DOUT5_NUM_S 10 + +/* SPI_MEM_SPI_SMEM_DOUT4_NUM : R/W ;bitpos:[9:8] ;default: 2'h0 ; */ + +/* Description: the output signals are delayed by system clock cycles + * 0: output without delayed + * 1: output with the posedge of clk_apb + * 2: output with the negedge of clk_apb + * 3: output with the posedge of clk_160 + * 4: output with the negedge of clk_160 + * 5: output with the spi_clk high edge + * 6: output with the spi_clk low edge + */ + +#define SPI_MEM_SPI_SMEM_DOUT4_NUM 0x00000003 +#define SPI_MEM_SPI_SMEM_DOUT4_NUM_M ((SPI_MEM_SPI_SMEM_DOUT4_NUM_V)<<(SPI_MEM_SPI_SMEM_DOUT4_NUM_S)) +#define SPI_MEM_SPI_SMEM_DOUT4_NUM_V 0x3 +#define SPI_MEM_SPI_SMEM_DOUT4_NUM_S 8 + +/* SPI_MEM_SPI_SMEM_DOUT3_NUM : R/W ;bitpos:[7:6] ;default: 2'h0 ; */ + +/* Description: the output signals are delayed by system clock cycles + * 0: delayed by 1 cycle + * 1: delayed by 2 cycles ... + */ + +#define SPI_MEM_SPI_SMEM_DOUT3_NUM 0x00000003 +#define SPI_MEM_SPI_SMEM_DOUT3_NUM_M ((SPI_MEM_SPI_SMEM_DOUT3_NUM_V)<<(SPI_MEM_SPI_SMEM_DOUT3_NUM_S)) +#define SPI_MEM_SPI_SMEM_DOUT3_NUM_V 0x3 +#define SPI_MEM_SPI_SMEM_DOUT3_NUM_S 6 + +/* SPI_MEM_SPI_SMEM_DOUT2_NUM : R/W ;bitpos:[5:4] ;default: 2'h0 ; */ + +/* Description: the output signals are delayed by system clock cycles + * 0: delayed by 1 cycle + * 1: delayed by 2 cycles ... + */ + +#define SPI_MEM_SPI_SMEM_DOUT2_NUM 0x00000003 +#define SPI_MEM_SPI_SMEM_DOUT2_NUM_M ((SPI_MEM_SPI_SMEM_DOUT2_NUM_V)<<(SPI_MEM_SPI_SMEM_DOUT2_NUM_S)) +#define SPI_MEM_SPI_SMEM_DOUT2_NUM_V 0x3 +#define SPI_MEM_SPI_SMEM_DOUT2_NUM_S 4 + +/* SPI_MEM_SPI_SMEM_DOUT1_NUM : R/W ;bitpos:[3:2] ;default: 2'h0 ; */ + +/* Description: the output signals are delayed by system clock cycles + * 0: delayed by 1 cycle 1: delayed by 2 cycles ... + */ + +#define SPI_MEM_SPI_SMEM_DOUT1_NUM 0x00000003 +#define SPI_MEM_SPI_SMEM_DOUT1_NUM_M ((SPI_MEM_SPI_SMEM_DOUT1_NUM_V)<<(SPI_MEM_SPI_SMEM_DOUT1_NUM_S)) +#define SPI_MEM_SPI_SMEM_DOUT1_NUM_V 0x3 +#define SPI_MEM_SPI_SMEM_DOUT1_NUM_S 2 + +/* SPI_MEM_SPI_SMEM_DOUT0_NUM : R/W ;bitpos:[1:0] ;default: 2'h0 ; */ + +/* Description: the output signals are delayed by system clock cycles + * 0: delayed by 1 cycle 1: delayed by 2 cycles ... + */ + +#define SPI_MEM_SPI_SMEM_DOUT0_NUM 0x00000003 +#define SPI_MEM_SPI_SMEM_DOUT0_NUM_M ((SPI_MEM_SPI_SMEM_DOUT0_NUM_V)<<(SPI_MEM_SPI_SMEM_DOUT0_NUM_S)) +#define SPI_MEM_SPI_SMEM_DOUT0_NUM_V 0x3 +#define SPI_MEM_SPI_SMEM_DOUT0_NUM_S 0 + +#define SPI_MEM_SPI_SMEM_AC_REG(i) (REG_SPI_MEM_BASE(i) + 0x0D0) + +/* SPI_MEM_SPI_SMEM_CS_HOLD_TIME : R/W ;bitpos:[27:15] ;default: 13'h1 ; */ + +/* Description: For spi0 spi cs signal is delayed to inactive by spi clock + * this bits are combined with spi_mem_cs_hold bit. + */ + +#define SPI_MEM_SPI_SMEM_CS_HOLD_TIME 0x00001FFF +#define SPI_MEM_SPI_SMEM_CS_HOLD_TIME_M ((SPI_MEM_SPI_SMEM_CS_HOLD_TIME_V)<<(SPI_MEM_SPI_SMEM_CS_HOLD_TIME_S)) +#define SPI_MEM_SPI_SMEM_CS_HOLD_TIME_V 0x1FFF +#define SPI_MEM_SPI_SMEM_CS_HOLD_TIME_S 15 + +/* SPI_MEM_SPI_SMEM_CS_SETUP_TIME : R/W ;bitpos:[14:2] ;default: 13'h1 ; */ + +/* Description: For spi0 (cycles-1) of prepare phase by spi clock this bits + * are combined with spi_mem_cs_setup bit. + */ + +#define SPI_MEM_SPI_SMEM_CS_SETUP_TIME 0x00001FFF +#define SPI_MEM_SPI_SMEM_CS_SETUP_TIME_M ((SPI_MEM_SPI_SMEM_CS_SETUP_TIME_V)<<(SPI_MEM_SPI_SMEM_CS_SETUP_TIME_S)) +#define SPI_MEM_SPI_SMEM_CS_SETUP_TIME_V 0x1FFF +#define SPI_MEM_SPI_SMEM_CS_SETUP_TIME_S 2 + +/* SPI_MEM_SPI_SMEM_CS_HOLD : R/W ;bitpos:[1] ;default: 1'b0 ; */ + +/* Description: For spi0 spi cs keep low when spi is in done phase. + * 1: enable + * 0: disable. + */ + +#define SPI_MEM_SPI_SMEM_CS_HOLD (BIT(1)) +#define SPI_MEM_SPI_SMEM_CS_HOLD_M (BIT(1)) +#define SPI_MEM_SPI_SMEM_CS_HOLD_V 0x1 +#define SPI_MEM_SPI_SMEM_CS_HOLD_S 1 + +/* SPI_MEM_SPI_SMEM_CS_SETUP : R/W ;bitpos:[0] ;default: 1'b0 ; */ + +/* Description: Set this bit to keep SPI_CS low when MSPI is in PREP state. */ + +#define SPI_MEM_SPI_SMEM_CS_SETUP (BIT(0)) +#define SPI_MEM_SPI_SMEM_CS_SETUP_M (BIT(0)) +#define SPI_MEM_SPI_SMEM_CS_SETUP_V 0x1 +#define SPI_MEM_SPI_SMEM_CS_SETUP_S 0 + +#define SPI_MEM_DDR_REG(i) (REG_SPI_MEM_BASE(i) + 0x0D4) + +/* SPI_MEM_SPI_FMEM_DDR_DQS_LOOP_MODE: R/W;bitpos:[23:22];default: 2'b0 ; */ + +/* Description: the bits are combined with the bit spi_fmem_ddr_fdqs_loop + * which used to select data strobe generating mode in ddr mode. + */ + +#define SPI_MEM_SPI_FMEM_DDR_DQS_LOOP_MODE 0x00000003 +#define SPI_MEM_SPI_FMEM_DDR_DQS_LOOP_MODE_M ((SPI_MEM_SPI_FMEM_DDR_DQS_LOOP_MODE_V)<<(SPI_MEM_SPI_FMEM_DDR_DQS_LOOP_MODE_S)) +#define SPI_MEM_SPI_FMEM_DDR_DQS_LOOP_MODE_V 0x3 +#define SPI_MEM_SPI_FMEM_DDR_DQS_LOOP_MODE_S 22 + +/* SPI_MEM_SPI_FMEM_DDR_DQS_LOOP : R/W ;bitpos:[21] ;default: 1'b0 ; */ + +/* Description: + * 1: Use internal signal as data strobe, the strobe can not be delayed by + * input timing module. + * 0: Use input SPI_DQS signal from PAD as data strobe, the strobe can be + * delayed by input timing module + */ + +#define SPI_MEM_SPI_FMEM_DDR_DQS_LOOP (BIT(21)) +#define SPI_MEM_SPI_FMEM_DDR_DQS_LOOP_M (BIT(21)) +#define SPI_MEM_SPI_FMEM_DDR_DQS_LOOP_V 0x1 +#define SPI_MEM_SPI_FMEM_DDR_DQS_LOOP_S 21 + +/* SPI_MEM_SPI_FMEM_USR_DDR_DQS_THD : R/W ;bitpos:[20:14] ;default: 7'b0 ; */ + +/* Description: The delay number of data strobe which from memory based on + * SPI_CLK. + */ + +#define SPI_MEM_SPI_FMEM_USR_DDR_DQS_THD 0x000000FF +#define SPI_MEM_SPI_FMEM_USR_DDR_DQS_THD_M ((SPI_MEM_SPI_FMEM_USR_DDR_DQS_THD_V)<<(SPI_MEM_SPI_FMEM_USR_DDR_DQS_THD_S)) +#define SPI_MEM_SPI_FMEM_USR_DDR_DQS_THD_V 0xFF +#define SPI_MEM_SPI_FMEM_USR_DDR_DQS_THD_S 13 + +/* SPI_MEM_SPI_FMEM_OUTMINBYTELEN : R/W ;bitpos:[12:5] ;default: 8'b1 ; */ + +/* Description: It is the minimum output data length in the panda device. */ + +#define SPI_MEM_SPI_FMEM_OUTMINBYTELEN 0x000000FF +#define SPI_MEM_SPI_FMEM_OUTMINBYTELEN_M ((SPI_MEM_SPI_FMEM_OUTMINBYTELEN_V)<<(SPI_MEM_SPI_FMEM_OUTMINBYTELEN_S)) +#define SPI_MEM_SPI_FMEM_OUTMINBYTELEN_V 0xFF +#define SPI_MEM_SPI_FMEM_OUTMINBYTELEN_S 5 + +/* SPI_MEM_SPI_FMEM_DDR_CMD_DIS : R/W ;bitpos:[4] ;default: 1'b0 ; */ + +/* Description: the bit is used to disable dual edge in command phase when + * DDR mode. + */ + +#define SPI_MEM_SPI_FMEM_DDR_CMD_DIS (BIT(4)) +#define SPI_MEM_SPI_FMEM_DDR_CMD_DIS_M (BIT(4)) +#define SPI_MEM_SPI_FMEM_DDR_CMD_DIS_V 0x1 +#define SPI_MEM_SPI_FMEM_DDR_CMD_DIS_S 4 + +/* SPI_MEM_SPI_FMEM_DDR_WDAT_SWP : R/W ;bitpos:[3] ;default: 1'b0 ; */ + +/* Description: Set the bit to reorder TX data of the word in DDR mode. */ + +#define SPI_MEM_SPI_FMEM_DDR_WDAT_SWP (BIT(3)) +#define SPI_MEM_SPI_FMEM_DDR_WDAT_SWP_M (BIT(3)) +#define SPI_MEM_SPI_FMEM_DDR_WDAT_SWP_V 0x1 +#define SPI_MEM_SPI_FMEM_DDR_WDAT_SWP_S 3 + +/* SPI_MEM_SPI_FMEM_DDR_RDAT_SWP : R/W ;bitpos:[2] ;default: 1'b0 ; */ + +/* Description: Set the bit to reorder RX data of the word in DDR mode. */ + +#define SPI_MEM_SPI_FMEM_DDR_RDAT_SWP (BIT(2)) +#define SPI_MEM_SPI_FMEM_DDR_RDAT_SWP_M (BIT(2)) +#define SPI_MEM_SPI_FMEM_DDR_RDAT_SWP_V 0x1 +#define SPI_MEM_SPI_FMEM_DDR_RDAT_SWP_S 2 + +/* SPI_MEM_SPI_FMEM_VAR_DUMMY : R/W ;bitpos:[1] ;default: 1'b0 ; */ + +/* Description: Set the bit to enable variable dummy cycle in DDRmode. */ + +#define SPI_MEM_SPI_FMEM_VAR_DUMMY (BIT(1)) +#define SPI_MEM_SPI_FMEM_VAR_DUMMY_M (BIT(1)) +#define SPI_MEM_SPI_FMEM_VAR_DUMMY_V 0x1 +#define SPI_MEM_SPI_FMEM_VAR_DUMMY_S 1 + +/* SPI_MEM_SPI_FMEM_DDR_EN : R/W ;bitpos:[0] ;default: 1'b0 ; */ + +/* Description: 1: in DDR mode, 0: in SDR mode. */ + +#define SPI_MEM_SPI_FMEM_DDR_EN (BIT(0)) +#define SPI_MEM_SPI_FMEM_DDR_EN_M (BIT(0)) +#define SPI_MEM_SPI_FMEM_DDR_EN_V 0x1 +#define SPI_MEM_SPI_FMEM_DDR_EN_S 0 + +#define SPI_MEM_SPI_SMEM_DDR_REG(i) (REG_SPI_MEM_BASE(i) + 0x0D8) + +/* SPI_MEM_SPI_SMEM_DDR_DQS_LOOP_MODE: R/W;bitpos:[23:22];default: 2'b0; */ + +/* Description: the bits are combined with the bit spi_smem_ddr_fdqs_loop + * which used to select data strobe generating mode in ddr mode. + */ + +#define SPI_MEM_SPI_SMEM_DDR_DQS_LOOP_MODE 0x00000003 +#define SPI_MEM_SPI_SMEM_DDR_DQS_LOOP_MODE_M ((SPI_MEM_SPI_SMEM_DDR_DQS_LOOP_MODE_V)<<(SPI_MEM_SPI_SMEM_DDR_DQS_LOOP_MODE_S)) +#define SPI_MEM_SPI_SMEM_DDR_DQS_LOOP_MODE_V 0x3 +#define SPI_MEM_SPI_SMEM_DDR_DQS_LOOP_MODE_S 22 + +/* SPI_MEM_SPI_SMEM_DDR_DQS_LOOP : R/W ;bitpos:[21] ;default: 1'b0 ; */ + +/* Description: + * 1: Use internal signal as data strobe, the strobe can not be delayed by + * input timing module. + * 0: Use input SPI_DQS signal from PAD as data strobe, the strobe can be + * delayed by input timing module + */ + +#define SPI_MEM_SPI_SMEM_DDR_DQS_LOOP (BIT(21)) +#define SPI_MEM_SPI_SMEM_DDR_DQS_LOOP_M (BIT(21)) +#define SPI_MEM_SPI_SMEM_DDR_DQS_LOOP_V 0x1 +#define SPI_MEM_SPI_SMEM_DDR_DQS_LOOP_S 21 + +/* SPI_MEM_SPI_SMEM_USR_DDR_DQS_THD : R/W ;bitpos:[20:14] ;default: 7'b0 ; */ + +/* Description: The delay number of data strobe which from memory based on + * SPI_CLK. + */ + +#define SPI_MEM_SPI_SMEM_USR_DDR_DQS_THD 0x000000FF +#define SPI_MEM_SPI_SMEM_USR_DDR_DQS_THD_M ((SPI_MEM_SPI_SMEM_USR_DDR_DQS_THD_V)<<(SPI_MEM_SPI_SMEM_USR_DDR_DQS_THD_S)) +#define SPI_MEM_SPI_SMEM_USR_DDR_DQS_THD_V 0xFF +#define SPI_MEM_SPI_SMEM_USR_DDR_DQS_THD_S 13 + +/* SPI_MEM_SPI_SMEM_OUTMINBYTELEN : R/W ;bitpos:[12:5] ;default: 8'b1 ; */ + +/* Description: It is the minimum output data length in the ddr psram. */ + +#define SPI_MEM_SPI_SMEM_OUTMINBYTELEN 0x000000FF +#define SPI_MEM_SPI_SMEM_OUTMINBYTELEN_M ((SPI_MEM_SPI_SMEM_OUTMINBYTELEN_V)<<(SPI_MEM_SPI_SMEM_OUTMINBYTELEN_S)) +#define SPI_MEM_SPI_SMEM_OUTMINBYTELEN_V 0xFF +#define SPI_MEM_SPI_SMEM_OUTMINBYTELEN_S 5 +/* SPI_MEM_SPI_SMEM_DDR_CMD_DIS : R/W ;bitpos:[4] ;default: 1'b0 ; */ + +/* Description: the bit is used to disable dual edge in CMD phase when ddr + * mode. + */ + +#define SPI_MEM_SPI_SMEM_DDR_CMD_DIS (BIT(4)) +#define SPI_MEM_SPI_SMEM_DDR_CMD_DIS_M (BIT(4)) +#define SPI_MEM_SPI_SMEM_DDR_CMD_DIS_V 0x1 +#define SPI_MEM_SPI_SMEM_DDR_CMD_DIS_S 4 + +/* SPI_MEM_SPI_SMEM_DDR_WDAT_SWP : R/W ;bitpos:[3] ;default: 1'b0 ; */ + +/* Description: Set the bit to reorder tx data of the word in spi ddr mode. */ + +#define SPI_MEM_SPI_SMEM_DDR_WDAT_SWP (BIT(3)) +#define SPI_MEM_SPI_SMEM_DDR_WDAT_SWP_M (BIT(3)) +#define SPI_MEM_SPI_SMEM_DDR_WDAT_SWP_V 0x1 +#define SPI_MEM_SPI_SMEM_DDR_WDAT_SWP_S 3 + +/* SPI_MEM_SPI_SMEM_DDR_RDAT_SWP : R/W ;bitpos:[2] ;default: 1'b0 ; */ + +/* Description: Set the bit to reorder rx data of the word in spi ddr mode. */ + +#define SPI_MEM_SPI_SMEM_DDR_RDAT_SWP (BIT(2)) +#define SPI_MEM_SPI_SMEM_DDR_RDAT_SWP_M (BIT(2)) +#define SPI_MEM_SPI_SMEM_DDR_RDAT_SWP_V 0x1 +#define SPI_MEM_SPI_SMEM_DDR_RDAT_SWP_S 2 + +/* SPI_MEM_SPI_SMEM_VAR_DUMMY : R/W ;bitpos:[1] ;default: 1'b0 ; */ + +/* Description: Set the bit to enable variable dummy cycle in spi ddr mode. */ + +#define SPI_MEM_SPI_SMEM_VAR_DUMMY (BIT(1)) +#define SPI_MEM_SPI_SMEM_VAR_DUMMY_M (BIT(1)) +#define SPI_MEM_SPI_SMEM_VAR_DUMMY_V 0x1 +#define SPI_MEM_SPI_SMEM_VAR_DUMMY_S 1 + +/* SPI_MEM_SPI_SMEM_DDR_EN : R/W ;bitpos:[0] ;default: 1'b0 ; */ + +/* Description: 1: in ddr mode, 0 in sdr mode */ + +#define SPI_MEM_SPI_SMEM_DDR_EN (BIT(0)) +#define SPI_MEM_SPI_SMEM_DDR_EN_M (BIT(0)) +#define SPI_MEM_SPI_SMEM_DDR_EN_V 0x1 +#define SPI_MEM_SPI_SMEM_DDR_EN_S 0 + +#define SPI_MEM_CLOCK_GATE_REG(i) (REG_SPI_MEM_BASE(i) + 0xE8) + +/* SPI_MEM_CLK_EN : R/W ;bitpos:[0] ;default: 1'b1 ; */ + +/* Description: Register clock gate enable signal. 1: Enable. 0: Disable. */ + +#define SPI_MEM_CLK_EN (BIT(0)) +#define SPI_MEM_CLK_EN_M (BIT(0)) +#define SPI_MEM_CLK_EN_V 0x1 +#define SPI_MEM_CLK_EN_S 0 + +#define SPI_MEM_DATE_REG(i) (REG_SPI_MEM_BASE(i) + 0x3FC) + +/* SPI_MEM_DATE : R/W ;bitpos:[27:5] ;default: 23'h108082 ; */ + +/* Description: SPI register version. */ + +#define SPI_MEM_DATE 0x00FFFFFF +#define SPI_MEM_DATE_M ((SPI_MEM_DATE_V)<<(SPI_MEM_DATE_S)) +#define SPI_MEM_DATE_V 0xFFFFFFF +#define SPI_MEM_DATE_S 0 + +#ifdef __cplusplus +} +#endif + +#endif /* __ARCH_XTENSA_SRC_ESP32S3_HARDWARE_ESP32S3_SPI_MEM_REG_H */ diff --git a/arch/xtensa/src/esp32s2/rom/esp32s2_opi_flash.h b/arch/xtensa/src/esp32s2/rom/esp32s2_opi_flash.h new file mode 100644 index 0000000000000..f5526f0cd34d7 --- /dev/null +++ b/arch/xtensa/src/esp32s2/rom/esp32s2_opi_flash.h @@ -0,0 +1,367 @@ +/***************************************************************************** + * arch/xtensa/src/esp32s2/rom/esp32s2_opi_flash.h + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + *****************************************************************************/ + +#ifndef __ARCH_XTENSA_SRC_ESP32S2_ROM_ESP32S2_OPI_FLASH_H +#define __ARCH_XTENSA_SRC_ESP32S2_ROM_ESP32S2_OPI_FLASH_H + +/***************************************************************************** + * Included Files + *****************************************************************************/ + +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" +{ +#endif + +typedef struct +{ + uint16_t cmd; /* !< Command value */ + uint16_t cmd_bit_len; /* !< Command byte length */ + uint32_t *addr; /* !< Point to address value */ + uint32_t addr_bit_len; /* !< Address byte length */ + uint32_t *tx_data; /* !< Point to send data buffer */ + uint32_t tx_data_bit_len; /* !< Send data byte length. */ + uint32_t *rx_data; /* !< Point to recevie data buffer */ + uint32_t rx_data_bit_len; /* !< Recevie Data byte length. */ + uint32_t dummy_bit_len; +} esp_rom_spi_cmd_t; + +#define ESP_ROM_OPIFLASH_MUX_TAKE() +#define ESP_ROM_OPIFLASH_MUX_GIVE() +#define ESP_ROM_OPIFLASH_SEL_CS0 (BIT(0)) +#define ESP_ROM_OPIFLASH_SEL_CS1 (BIT(1)) + +/* Definition of MX25UM25645G Octa Flash + * SPI status register + */ + +#define ESP_ROM_SPIFLASH_BUSY_FLAG BIT0 +#define ESP_ROM_SPIFLASH_WRENABLE_FLAG BIT1 +#define ESP_ROM_SPIFLASH_BP0 BIT2 +#define ESP_ROM_SPIFLASH_BP1 BIT3 +#define ESP_ROM_SPIFLASH_BP2 BIT4 +#define ESP_ROM_SPIFLASH_QE BIT9 + +#define FLASH_OP_MODE_RDCMD_DOUT 0x3B +#define ESP_ROM_FLASH_SECTOR_SIZE 0x1000 +#define ESP_ROM_FLASH_BLOCK_SIZE_64K 0x10000 +#define ESP_ROM_FLASH_PAGE_SIZE 256 + +/* FLASH commands */ + +#define ROM_FLASH_CMD_RDID 0x9F +#define ROM_FLASH_CMD_WRSR 0x01 +#define ROM_FLASH_CMD_WRSR2 0x31 /* Not all SPI flash uses this command */ +#define ROM_FLASH_CMD_WREN 0x06 +#define ROM_FLASH_CMD_WRDI 0x04 +#define ROM_FLASH_CMD_RDSR 0x05 +#define ROM_FLASH_CMD_RDSR2 0x35 /* Not all SPI flash uses this command */ +#define ROM_FLASH_CMD_ERASE_SEC 0x20 +#define ROM_FLASH_CMD_ERASE_BLK_32K 0x52 +#define ROM_FLASH_CMD_ERASE_BLK_64K 0xD8 +#define ROM_FLASH_CMD_OTPEN 0x3A /* Enable OTP mode, not all SPI flash uses this command */ +#define ROM_FLASH_CMD_RSTEN 0x66 +#define ROM_FLASH_CMD_RST 0x99 + +#define ROM_FLASH_CMD_SE4B 0x21 +#define ROM_FLASH_CMD_SE4B_OCT 0xDE21 +#define ROM_FLASH_CMD_BE4B 0xDC +#define ROM_FLASH_CMD_BE4B_OCT 0x23DC +#define ROM_FLASH_CMD_RSTEN_OCT 0x9966 +#define ROM_FLASH_CMD_RST_OCT 0x6699 + +#define ROM_FLASH_CMD_FSTRD4B_STR 0x13EC +#define ROM_FLASH_CMD_FSTRD4B_DTR 0x11EE +#define ROM_FLASH_CMD_FSTRD4B 0x0C +#define ROM_FLASH_CMD_PP4B 0x12 +#define ROM_FLASH_CMD_PP4B_OCT 0xED12 + +#define ROM_FLASH_CMD_RDID_OCT 0x609F +#define ROM_FLASH_CMD_WREN_OCT 0xF906 +#define ROM_FLASH_CMD_RDSR_OCT 0xFA05 +#define ROM_FLASH_CMD_RDCR2 0x71 +#define ROM_FLASH_CMD_RDCR2_OCT 0x8E71 +#define ROM_FLASH_CMD_WRCR2 0x72 +#define ROM_FLASH_CMD_WRCR2_OCT 0x8D72 + +/* Definitions for GigaDevice GD25LX256E Flash */ + +#define ROM_FLASH_CMD_RDFSR_GD 0x70 +#define ROM_FLASH_CMD_RD_GD 0x03 +#define ROM_FLASH_CMD_RD4B_GD 0x13 +#define ROM_FLASH_CMD_FSTRD_GD 0x0B +#define ROM_FLASH_CMD_FSTRD4B_GD 0x0C +#define ROM_FLASH_CMD_FSTRD_OOUT_GD 0x8B +#define ROM_FLASH_CMD_FSTRD4B_OOUT_GD 0x7C +#define ROM_FLASH_CMD_FSTRD_OIOSTR_GD 0xCB +#define ROM_FLASH_CMD_FSTRD4B_OIOSTR_GD 0xCC +#define ROM_FLASH_CMD_FSTRD4B_OIODTR_GD 0xFD + +#define ROM_FLASH_CMD_PP_GD 0x02 +#define ROM_FLASH_CMD_PP4B_GD 0x12 +#define ROM_FLASH_CMD_PP_OOUT_GD 0x82 +#define ROM_FLASH_CMD_PP4B_OOUT_GD 0x84 +#define ROM_FLASH_CMD_PP_OIO_GD 0xC2 +#define ROM_FLASH_CMD_PP4B_OIOSTR_GD 0x8E + +#define ROM_FLASH_CMD_SE_GD 0x20 +#define ROM_FLASH_CMD_SE4B_GD 0x21 +#define ROM_FLASH_CMD_BE32K_GD 0x52 +#define ROM_FLASH_CMD_BE32K4B_GD 0x5C +#define ROM_FLASH_CMD_BE64K_GD 0xD8 +#define ROM_FLASH_CMD_BE64K4B_GD 0xDC + +#define ROM_FLASH_CMD_EN4B_GD 0xB7 +#define ROM_FLASH_CMD_DIS4B_GD 0xE9 + +/* spi user mode command config */ + +/** + * @brief Config the spi user command + * @param spi_num spi port + * @param pcmd pointer to accept the spi command struct + */ + +void esp_rom_spi_cmd_config(int spi_num, esp_rom_spi_cmd_t *pcmd); + +/** + * @brief Start a spi user command sequence + * @param spi_num spi port + * @param rx_buf buffer pointer to receive data + * @param rx_len receive data length in byte + * @param cs_en_mask decide which cs to use, 0 for cs0, 1 for cs1 + * @param is_write_erase to indicate whether this is a write or erase + * operation, since the CPU would check permission + */ + +void esp_rom_spi_cmd_start(int spi_num, uint8_t *rx_buf, uint16_t rx_len, + uint8_t cs_en_mask, bool is_write_erase); + +/** + * @brief Config opi flash pads according to efuse settings. + */ + +void esp_rom_opiflash_pin_config(void); + +/** + * @brief Set SPI operation mode + * @param spi_num spi port + * @param mode Flash Read Mode + */ + +void esp_rom_spi_set_op_mode(int spi_num, esp_rom_spiflash_read_mode_t mode); + +/** + * @brief Set data swap mode in DTR(DDR) mode + * @param spi_num spi port + * @param wr_swap to decide whether to swap fifo data in dtr write operation + * @param rd_swap to decide whether to swap fifo data in dtr read operation + */ + +void esp_rom_spi_set_dtr_swap_mode(int spi, bool wr_swap, bool rd_swap); + +/** + * @brief to send reset command in spi/opi-str/opi-dtr mode(for MX25UM25645G) + * @param spi_num spi port + */ + +void esp_rom_opiflash_mode_reset(int spi_num); + +#if 0 + +/* MX25UM25645G opi flash interface */ + +/** + * @brief To execute a flash operation command + * @param spi_num spi port + * @param mode Flash Read Mode + * @param cmd data to send in command field + * @param cmd_bit_len bit length of command field + * @param addr data to send in address field + * @param addr_bit_len bit length of address field + * @param dummy_bits bit length of dummy field + * @param mosi_data data buffer to be sent in mosi field + * @param mosi_bit_len bit length of data buffer to be sent in mosi field + * @param miso_data data buffer to accept data in miso field + * @param miso_bit_len bit length of data buffer to accept data in miso field + * @param cs_mark decide which cs pin to use. 0: cs0, 1: cs1 + * @param is_write_erase_operation to indicate whether this a write or erase + * flash operation + */ + +void esp_rom_opiflash_exec_cmd(int spi_num, esp_rom_spiflash_read_mode_t mode, + uint32_t cmd, int cmd_bit_len, + uint32_t addr, int addr_bit_len, + int dummy_bits, + uint8_t *mosi_data, int mosi_bit_len, + uint8_t *miso_data, int miso_bit_len, + uint32_t cs_mask, + bool is_write_erase_operation); + +/** + * @brief send reset command to opi flash + * @param spi_num spi port + * @param mode Flash Operation Mode + */ + +void esp_rom_opiflash_soft_reset(int spi_num, + esp_rom_spiflash_read_mode_t mode); + +/** + * @brief to read opi flash ID + * @note command format would be defined in initialization + * @param[out] out_id buffer to accept id + * @return flash operation result + */ + +uint32_t esp_rom_opiflash_read_id(int spi_num, + esp_rom_spiflash_read_mode_t mode); + +/** + * @brief to read opi flash status register(for MX25UM25645G) + * @param spi_num spi port + * @param mode Flash Operation Mode + * @return opi flash status value + */ + +uint8_t esp_rom_opiflash_rdsr(int spi_num, esp_rom_spiflash_read_mode_t mode); + +/** + * @brief wait opi flash status register to be idle + * @param spi_num spi port + * @param mode Flash Operation Mode + */ + +void esp_rom_opiflash_wait_idle(int spi_num, + esp_rom_spiflash_read_mode_t mode); + +/** + * @brief to read the config register2(for MX25UM25645G) + * @param spi_num spi port + * @param mode Flash Operation Mode + * @param addr the address of configure register + * @return value of config register2 + */ + +uint8_t esp_rom_opiflash_rdcr2(int spi_num, + esp_rom_spiflash_read_mode_t mode, + uint32_t addr); + +/** + * @brief to write the config register2(for MX25UM25645G) + * @param spi_num spi port + * @param mode Flash Operation Mode + * @param addr the address of config register + * @param val the value to write + */ + +void esp_rom_opiflash_wrcr2(int spi_num, esp_rom_spiflash_read_mode_t mode, + uint32_t addr, uint8_t val); + +/** + * @brief to erase flash sector(for MX25UM25645G) + * @param spi_num spi port + * @param address the sector address to be erased + * @param mode Flash operation mode + * @return flash operation result + */ + +esp_rom_spiflash_result_t +esp_rom_opiflash_erase_sector(int spi_num, uint32_t address, + esp_rom_spiflash_read_mode_t mode); + +/** + * @brief to erase flash block(for MX25UM25645G) + * @param spi_num spi port + * @param address the block address to be erased + * @param mode Flash operation mode + * @return flash operation result + */ + +esp_rom_spiflash_result_t +esp_rom_opiflash_erase_block_64k(int spi_num, uint32_t address, + esp_rom_spiflash_read_mode_t mode); + +/** + * @brief to erase a flash area define by start address and length + * (for MX25UM25645G) + * @param spi_num spi port + * @param start_addr the start address to be erased + * @param area_len the erea length to be erased + * @param mode flash operation mode + * @return flash operation result + */ + +esp_rom_spiflash_result_t +esp_rom_opiflash_erase_area(int spi_num, uint32_t start_addr, + uint32_t area_len, + esp_rom_spiflash_read_mode_t mode); + +/** + * @brief to read data from opi flash(for MX25UM25645G) + * @param spi_num spi port + * @param mode flash operation mode + * @param flash_addr flash address to read data from + * @param data_addr data buffer to accept the data + * @param len data length to be read + * @return flash operation result + */ + +esp_rom_spiflash_result_t +esp_rom_opiflash_read(int spi_num, esp_rom_spiflash_read_mode_t mode, + uint32_t flash_addr, uint8_t *data_addr, int len); + +/** + * @brief to write data to opi flash(for MX25UM25645G) + * @param spi_num spi port + * @param mode flash operation mode + * @param flash_addr flash address to write data to + * @param data_addr data buffer to write to flash + * @param len data length to write + * @return flash operation result + */ + +esp_rom_spiflash_result_t +esp_rom_opiflash_write(int spi_num, esp_rom_spiflash_read_mode_t mode, + uint32_t flash_addr, uint8_t *data_addr, + uint32_t len); + +/** + * @brief to set opi flash operation mode(for MX25UM25645G) + * @param spi_num spi port + * @param cur_mode current operation mode + * @param target the target operation mode to be set + */ + +void esp_rom_opiflash_set_mode(int spi_num, + esp_rom_spiflash_read_mode_t cur_mode, + esp_rom_spiflash_read_mode_t target_mode); +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* __ARCH_XTENSA_SRC_ESP32S2_ROM_ESP32S2_OPI_FLASH_H */ diff --git a/arch/xtensa/src/esp32s2/rom/esp32s2_spiflash.h b/arch/xtensa/src/esp32s2/rom/esp32s2_spiflash.h new file mode 100644 index 0000000000000..87d862214c9a2 --- /dev/null +++ b/arch/xtensa/src/esp32s2/rom/esp32s2_spiflash.h @@ -0,0 +1,1020 @@ +/***************************************************************************** + * arch/xtensa/src/esp32s2/rom/esp32s2_spiflash.h + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + *****************************************************************************/ + +#ifndef __ARCH_XTENSA_SRC_ESP32S2_ROM_ESP32S2_SPIFLASH_H +#define __ARCH_XTENSA_SRC_ESP32S2_ROM_ESP32S2_SPIFLASH_H + +/***************************************************************************** + * Included Files + *****************************************************************************/ + +#include +#include + +#ifdef __cplusplus +extern "C" +{ +#endif + +/***************************************************************************** + * Pre-processor Definitions + *****************************************************************************/ + +#define PERIPHS_SPI_FLASH_CMD SPI_CMD_REG(1) +#define PERIPHS_SPI_FLASH_ADDR SPI_ADDR_REG(1) +#define PERIPHS_SPI_FLASH_CTRL SPI_CTRL_REG(1) +#define PERIPHS_SPI_FLASH_CTRL1 SPI_CTRL1_REG(1) +#define PERIPHS_SPI_FLASH_STATUS SPI_RD_STATUS_REG(1) +#define PERIPHS_SPI_FLASH_USRREG SPI_USER_REG(1) +#define PERIPHS_SPI_FLASH_USRREG1 SPI_USER1_REG(1) +#define PERIPHS_SPI_FLASH_USRREG2 SPI_USER2_REG(1) +#define PERIPHS_SPI_FLASH_C0 SPI_W0_REG(1) +#define PERIPHS_SPI_FLASH_C1 SPI_W1_REG(1) +#define PERIPHS_SPI_FLASH_C2 SPI_W2_REG(1) +#define PERIPHS_SPI_FLASH_C3 SPI_W3_REG(1) +#define PERIPHS_SPI_FLASH_C4 SPI_W4_REG(1) +#define PERIPHS_SPI_FLASH_C5 SPI_W5_REG(1) +#define PERIPHS_SPI_FLASH_C6 SPI_W6_REG(1) +#define PERIPHS_SPI_FLASH_C7 SPI_W7_REG(1) +#define PERIPHS_SPI_FLASH_TX_CRC SPI_TX_CRC_REG(1) + +#define SPI0_R_QIO_DUMMY_CYCLELEN 3 +#define SPI0_R_QIO_ADDR_BITSLEN 31 +#define SPI0_R_FAST_DUMMY_CYCLELEN 7 +#define SPI0_R_DIO_DUMMY_CYCLELEN 1 +#define SPI0_R_DIO_ADDR_BITSLEN 27 +#define SPI0_R_FAST_ADDR_BITSLEN 23 +#define SPI0_R_SIO_ADDR_BITSLEN 23 + +#define SPI1_R_QIO_DUMMY_CYCLELEN 3 +#define SPI1_R_QIO_ADDR_BITSLEN 31 +#define SPI1_R_FAST_DUMMY_CYCLELEN 7 +#define SPI1_R_DIO_DUMMY_CYCLELEN 3 +#define SPI1_R_DIO_ADDR_BITSLEN 31 +#define SPI1_R_FAST_ADDR_BITSLEN 23 +#define SPI1_R_SIO_ADDR_BITSLEN 23 + +#define ESP_ROM_SPIFLASH_W_SIO_ADDR_BITSLEN 23 + +#define ESP_ROM_SPIFLASH_TWO_BYTE_STATUS_EN SPI_WRSR_2B + +/* SPI address register */ + +#define ESP_ROM_SPIFLASH_BYTES_LEN 24 +#define ESP_ROM_SPIFLASH_BUFF_BYTE_WRITE_NUM 32 +#define ESP_ROM_SPIFLASH_BUFF_BYTE_READ_NUM 64 +#define ESP_ROM_SPIFLASH_BUFF_BYTE_READ_BITS 0x3f + +/* SPI status register */ + +#define ESP_ROM_SPIFLASH_BUSY_FLAG BIT0 +#define ESP_ROM_SPIFLASH_WRENABLE_FLAG BIT1 +#define ESP_ROM_SPIFLASH_BP0 BIT2 +#define ESP_ROM_SPIFLASH_BP1 BIT3 +#define ESP_ROM_SPIFLASH_BP2 BIT4 +#define ESP_ROM_SPIFLASH_WR_PROTECT (ESP_ROM_SPIFLASH_BP0|\ + ESP_ROM_SPIFLASH_BP1|\ + ESP_ROM_SPIFLASH_BP2) +#define ESP_ROM_SPIFLASH_QE BIT9 + +/* Extra dummy for flash read */ + +#define ESP_ROM_SPIFLASH_DUMMY_LEN_PLUS_20M 0 +#define ESP_ROM_SPIFLASH_DUMMY_LEN_PLUS_40M 1 +#define ESP_ROM_SPIFLASH_DUMMY_LEN_PLUS_80M 2 + +#define FLASH_ID_GD25LQ32C 0xC86016 + +/***************************************************************************** + * Public Types + *****************************************************************************/ + +typedef enum +{ + ESP_ROM_SPIFLASH_QIO_MODE = 0, + ESP_ROM_SPIFLASH_QOUT_MODE, + ESP_ROM_SPIFLASH_DIO_MODE, + ESP_ROM_SPIFLASH_DOUT_MODE, + ESP_ROM_SPIFLASH_FASTRD_MODE, + ESP_ROM_SPIFLASH_SLOWRD_MODE +} esp_rom_spiflash_read_mode_t; + +typedef enum +{ + ESP_ROM_SPIFLASH_RESULT_OK, + ESP_ROM_SPIFLASH_RESULT_ERR, + ESP_ROM_SPIFLASH_RESULT_TIMEOUT +} esp_rom_spiflash_result_t; + +typedef struct +{ + uint32_t device_id; + uint32_t chip_size; /* chip size in bytes */ + uint32_t block_size; + uint32_t sector_size; + uint32_t page_size; + uint32_t status_mask; +} esp32s2_spiflash_chip_t; + +typedef struct +{ + uint8_t data_length; + uint8_t read_cmd0; + uint8_t read_cmd1; + uint8_t write_cmd; + uint16_t data_mask; + uint16_t data; +} esp_rom_spiflash_common_cmd_t; + +/** + * Global ROM spiflash data, as used by legacy SPI flash functions + */ + +struct spiflash_legacy_data_s +{ + esp32s2_spiflash_chip_t chip; + uint8_t dummy_len_plus[3]; + uint8_t sig_matrix; +}; + +/** + * Structure holding SPI flash access critical sections management functions. + * + * Flash API uses two types of functions for flash access management: + * 1) Functions which prepare/restore flash cache and interrupts before + * calling appropriate ROM functions (SPIWrite, SPIRead and + * SPIEraseBlock): + * - 'start' function should disable flash cache and non-IRAM interrupts + * and is invoked before the call to one of ROM functions from + * "struct spiflash_guard_funcs_s". + * - 'end' function should restore state of flash cache and non-IRAM + * interrupts and is invoked after the call to one of ROM + * functions from "struct spiflash_guard_funcs_s". + * These two functions are not reentrant. + * 2) Functions which synchronizes access to internal data used by flash API. + * These functions are mostly intended to synchronize access to flash API + * internal data in multithreaded environment and use OS primitives: + * - 'op_lock' locks access to flash API internal data. + * - 'op_unlock' unlocks access to flash API internal data. + * These two functions are reentrant and can be used around the outside of + * multiple calls to 'start' & 'end', in order to create atomic multi-part + * flash operations. + * + * Different versions of the guarding functions should be used depending on + * the context of execution (with or without functional OS). In normal + * conditions when flash API is called from task the functions use OS + * primitives. + * When there is no OS at all or when it is not guaranteed that OS is + * functional (accessing flash from exception handler) these functions cannot + * use OS primitives or even does not need them (multithreaded access is + * not possible). + * + * @note Structure and corresponding guard functions should not reside + * in flash. For example structure can be placed in DRAM and functions + * in IRAM sections. + */ + +struct spiflash_guard_funcs +{ + void (*start)(void); /* critical section start function */ + void (*end)(void); /* critical section end function */ + void (*op_lock)(void); /* flash access API lock function */ + void (*op_unlock)(void); /* flash access API unlock function */ + + /* checks flash write addresses */ + + bool (*address_is_safe)(size_t addr, size_t size); + + void (*yield)(void); /* yield to the OS during flash erase */ +}; + +/***************************************************************************** + * Public Function Prototypes + *****************************************************************************/ + +/***************************************************************************** + * Name: esp_rom_spiflash_fix_dummylen + * + * Description: + * Fix the bug in SPI hardware communication with Flash/Ext-SRAM in High + * Speed. + * + * Please do not call this function in SDK. + * + * Input Parameters: + * uint8_t spi: 0 for SPI0(Cache Access), 1 for SPI1(Flash read/write). + * + * uint8_t freqdiv: Pll is 80M, 4 for 20M, 3 for 26.7M, 2 for 40M, + * 1 for 80M. + * + * Returned Value: + * None + * + *****************************************************************************/ + +void esp_rom_spiflash_fix_dummylen(uint8_t spi, uint8_t freqdiv); + +/***************************************************************************** + * Name: esp_rom_spiflash_select_qiomode + * + * Description: + * Select SPI Flash to QIO mode when WP pad is read from Flash. + * + * Please do not call this function in SDK. + * + * Input Parameters: + * uint8_t wp_gpio_num: WP gpio number. + * + * uint32_t ishspi: 0 for spi, 1 for hspi, flash pad decided by strapping + * else, bit[5:0] spiclk, bit[11:6] spiq, bit[17:12] spid, + * bit[23:18] spics0, bit[29:24] spihd + * + * Returned Value: + * None + *****************************************************************************/ + +void esp_rom_spiflash_select_qiomode(uint8_t wp_gpio_num, + uint32_t ishspi); + +/***************************************************************************** + * Name: esp_rom_spiflash_set_drvs + * + * Description: + * Set SPI Flash pad drivers. + * + * Please do not call this function in SDK. + * + * Input Parameters: + * uint8_t wp_gpio_num: WP gpio number. + * + * uint32_t ishspi: 0 for spi, 1 for hspi, flash pad decided by strapping + * else, bit[5:0] spiclk, bit[11:6] spiq, bit[17:12] spid, + * bit[23:18] spics0, bit[29:24] spihd + * + * uint8_t *drvs: drvs[0]-bit[3:0] for cpiclk, bit[7:4] for spiq, + * drvs[1]-bit[3:0] for spid, drvs[1]-bit[7:4] for spid + * drvs[2]-bit[3:0] for spihd, drvs[2]-bit[7:4] for spiwp. + * Values usually read from flash by rom code, function + * usually callde by rom code. + * if value with bit(3) set, the value is valid, bit[2:0] + * is the real value. + * + * Returned Value: + * None + * + *****************************************************************************/ + +void esp_rom_spiflash_set_drvs(uint8_t wp_gpio_num, + uint32_t ishspi, + uint8_t *drvs); + +/***************************************************************************** + * Name: esp_rom_spiflash_select_padsfunc + * + * Description: + * Select SPI Flash function for pads. + * + * Please do not call this function in SDK. + * + * Input Parameters: + * uint32_t ishspi: 0 for spi, 1 for hspi, flash pad decided by strapping + * else, bit[5:0] spiclk, bit[11:6] spiq, bit[17:12] spid, + * bit[23:18] spics0, bit[29:24] spihd + * + * Returned Value: + * None + * + *****************************************************************************/ + +void esp_rom_spiflash_select_padsfunc(uint32_t ishspi); + +/***************************************************************************** + * Name: esp_rom_spiflash_attach + * + * Description: + * SPI Flash init, clock divisor is 4, use 1 line Slow read mode. + * + * Please do not call this function in SDK. + * + * Input Parameters: + * uint32_t ishspi: 0 for spi, 1 for hspi, flash pad decided by strapping + * else, bit[5:0] spiclk, bit[11:6] spiq, bit[17:12] spid, + * bit[23:18] spics0, bit[29:24] spihd + * + * uint8_t legacy: In legacy mode, more SPI command is used in line. + * + * Returned Value: + * None + * + *****************************************************************************/ + +void esp_rom_spiflash_attach(uint32_t ishspi, bool legacy); + +/***************************************************************************** + * Name: esp_rom_spiflash_read_status + * + * Description: + * SPI Read Flash status register. We use CMD 0x05 (RDSR). + * + * Please do not call this function in SDK. + * + * Input Parameters: + * esp32s2_spiflash_chip_t *spi : The information for Flash, which is + * exported from ld file. + * + * uint32_t *status : The pointer to which to return the Flash status value. + * + * Returned Value: + * ESP_ROM_SPIFLASH_RESULT_OK : read OK. + * ESP_ROM_SPIFLASH_RESULT_ERR : read error. + * ESP_ROM_SPIFLASH_RESULT_TIMEOUT : read timeout. + * + *****************************************************************************/ + +esp_rom_spiflash_result_t +esp_rom_spiflash_read_status(esp32s2_spiflash_chip_t *spi, + uint32_t *status); + +/***************************************************************************** + * Name: esp32s2_spiflash_read_statushigh + * + * Description: + * SPI Read Flash status register bits 8-15. We use CMD 0x35 (RDSR2). + * + * Please do not call this function in SDK. + * + * Input Parameters: + * esp32s2_spiflash_chip_t *spi : The information for Flash, which is + * exported from ld file. + * + * uint32_t *status : The pointer to which to return the Flash status value. + * + * Returned Value: + * ESP_ROM_SPIFLASH_RESULT_OK : read OK. + * ESP_ROM_SPIFLASH_RESULT_ERR : read error. + * ESP_ROM_SPIFLASH_RESULT_TIMEOUT : read timeout. + * + *****************************************************************************/ + +esp_rom_spiflash_result_t +esp32s2_spiflash_read_statushigh(esp32s2_spiflash_chip_t *spi, + uint32_t *status); + +/***************************************************************************** + * Name: esp32s2_spiflash_write_status + * + * Description: + * Write status to Falsh status register. + * + * Please do not call this function in SDK. + * + * Input Parameters: + * esp32s2_spiflash_chip_t *spi : The information for Flash, which is + * exported from ld file. + * + * uint32_t status_value : Value to . + * + * Returned Value: + * ESP_ROM_SPIFLASH_RESULT_OK : write OK. + * ESP_ROM_SPIFLASH_RESULT_ERR : write error. + * ESP_ROM_SPIFLASH_RESULT_TIMEOUT : write timeout. + * + *****************************************************************************/ + +esp_rom_spiflash_result_t +esp32s2_spiflash_write_status(esp32s2_spiflash_chip_t *spi, + uint32_t status_value); + +/***************************************************************************** + * Name: esp_rom_spiflash_read_user_cmd + * + * Description: + * Use a command to Read Flash status register. + * + * Please do not call this function in SDK. + * + * Input Parameters: + * esp32s2_spiflash_chip_t *spi : The information for Flash, which is + * exported from ld file. + * + * uint32_t*status : The pointer to which to return the Flash status value. + * + * Returned Value: + * ESP_ROM_SPIFLASH_RESULT_OK : read OK. + * ESP_ROM_SPIFLASH_RESULT_ERR : read error. + * ESP_ROM_SPIFLASH_RESULT_TIMEOUT : read timeout. + * + *****************************************************************************/ + +esp_rom_spiflash_result_t +esp_rom_spiflash_read_user_cmd(uint32_t *status, + uint8_t cmd); + +/***************************************************************************** + * Name: esp_rom_spiflash_config_readmode + * + * Description: + * Config SPI Flash read mode when init. + * + * Please do not call this function in SDK. + * + * Input Parameter: + * esp_rom_spiflash_read_mode_t mode : QIO/QOUT/DIO/DOUT/FastRD/SlowRD. + * + * This function does not try to set the QIO Enable bit in the status + * register, caller is responsible for this. + * + * Returned Value: + * ESP_ROM_SPIFLASH_RESULT_OK : config OK. + * ESP_ROM_SPIFLASH_RESULT_ERR : config error. + * ESP_ROM_SPIFLASH_RESULT_TIMEOUT : config timeout. + * + *****************************************************************************/ + +esp_rom_spiflash_result_t +esp_rom_spiflash_config_readmode(esp_rom_spiflash_read_mode_t mode); + +/***************************************************************************** + * Name: esp_rom_spiflash_config_clk + * + * Description: + * Config SPI Flash clock divisor. + * + * Please do not call this function in SDK. + * + * Input Parameters: + * uint8_t freqdiv: clock divisor. + * + * uint8_t spi: 0 for SPI0, 1 for SPI1. + * + * Returned Value: + * ESP_ROM_SPIFLASH_RESULT_OK : config OK. + * ESP_ROM_SPIFLASH_RESULT_ERR : config error. + * ESP_ROM_SPIFLASH_RESULT_TIMEOUT : config timeout. + * + *****************************************************************************/ + +esp_rom_spiflash_result_t +esp_rom_spiflash_config_clk(uint8_t freqdiv, + uint8_t spi); + +/***************************************************************************** + * Name: esp_rom_spiflash_common_cmd + * + * Description: + * Send CommonCmd to Flash so that is can go into QIO mode, some Flash use + * different CMD. + * + * Please do not call this function in SDK. + * + * Input Paramater: + * esp_rom_spiflash_common_cmd_t *cmd : A struct to show the action of a + * command. + * + * Returned Value: + * uint16_t 0 : do not send command any more. + * 1 : go to the next command. + * n > 1 : skip (n - 1) commands. + * + *****************************************************************************/ + +uint16_t esp_rom_spiflash_common_cmd(esp_rom_spiflash_common_cmd_t *cmd); + +/***************************************************************************** + * Name: esp_rom_spiflash_unlock + * + * Description: + * Unlock SPI write protect. + * + * Please do not call this function in SDK. + * + * Input Value: + * None. + * + * Returned Value: + * ESP_ROM_SPIFLASH_RESULT_OK : Unlock OK. + * ESP_ROM_SPIFLASH_RESULT_ERR : Unlock error. + * ESP_ROM_SPIFLASH_RESULT_TIMEOUT : Unlock timeout. + * + *****************************************************************************/ + +esp_rom_spiflash_result_t esp_rom_spiflash_unlock(void); + +/***************************************************************************** + * Name: esp_rom_spiflash_lock + * + * Description: + * SPI write protect. + * + * Please do not call this function in SDK. + * + * Input Parameter: + * None. + * + * Returned Value: + * ESP_ROM_SPIFLASH_RESULT_OK : Lock OK. + * ESP_ROM_SPIFLASH_RESULT_ERR : Lock error. + * ESP_ROM_SPIFLASH_RESULT_TIMEOUT : Lock timeout. + * + *****************************************************************************/ + +esp_rom_spiflash_result_t esp_rom_spiflash_lock(void); + +/***************************************************************************** + * Name: esp_rom_spiflash_config_param + * + * Description: + * Update SPI Flash parameter. + * + * Please do not call this function in SDK. + * + * Input Parameters: + * uint32_t deviceId : Device ID read from SPI, the low 32 bit. + * + * uint32_t chip_size : The Flash size. + * + * uint32_t block_size : The Flash block size. + * + * uint32_t sector_size : The Flash sector size. + * + * uint32_t page_size : The Flash page size. + * + * uint32_t status_mask : The Mask used when read status from Flash + * (use single CMD). + * + * Returned Value: + * ESP_ROM_SPIFLASH_RESULT_OK : Update OK. + * ESP_ROM_SPIFLASH_RESULT_ERR : Update error. + * ESP_ROM_SPIFLASH_RESULT_TIMEOUT : Update timeout. + * + *****************************************************************************/ + +esp_rom_spiflash_result_t +esp_rom_spiflash_config_param(uint32_t deviceid, + uint32_t chip_size, + uint32_t block_size, + uint32_t sector_size, + uint32_t page_size, + uint32_t status_mask); + +/***************************************************************************** + * Name: esp_rom_spiflash_erase_chip + * + * Description: + * Erase whole flash chip. + * + * Please do not call this function in SDK. + * + * Input Parameter: + * None + * + * Returned Value: + * ESP_ROM_SPIFLASH_RESULT_OK : Erase OK. + * ESP_ROM_SPIFLASH_RESULT_ERR : Erase error. + * ESP_ROM_SPIFLASH_RESULT_TIMEOUT : Erase timeout. + * + *****************************************************************************/ + +esp_rom_spiflash_result_t esp_rom_spiflash_erase_chip(void); + +/***************************************************************************** + * Name: esp_rom_spiflash_erase_block + * + * Description: + * Erase a 64KB block of flash + * Uses SPI flash command D8H. + * + * Please do not call this function in SDK. + * + * Input Parameter: + * uint32_t block_num : Which block to erase. + * + * Returned Value: + * ESP_ROM_SPIFLASH_RESULT_OK : Erase OK. + * ESP_ROM_SPIFLASH_RESULT_ERR : Erase error. + * ESP_ROM_SPIFLASH_RESULT_TIMEOUT : Erase timeout. + * + *****************************************************************************/ + +esp_rom_spiflash_result_t esp_rom_spiflash_erase_block(uint32_t block_num); + +/***************************************************************************** + * Name: esp_rom_spiflash_erase_sector + * + * Description: + * Erase a sector of flash. + * Uses SPI flash command 20H. + * + * Please do not call this function in SDK. + * + * Input Parameters: + * uint32_t sector_num : Which sector to erase. + * + * Returned Value: + * ESP_ROM_SPIFLASH_RESULT_OK : Erase OK. + * ESP_ROM_SPIFLASH_RESULT_ERR : Erase error. + * ESP_ROM_SPIFLASH_RESULT_TIMEOUT : Erase timeout. + * + *****************************************************************************/ + +esp_rom_spiflash_result_t esp_rom_spiflash_erase_sector(uint32_t sector_num); + +/***************************************************************************** + * Name: esp_rom_spiflash_erase_area + * + * Description: + * Erase some sectors. + * + * Please do not call this function in SDK. + * + * Input Parameters: + * uint32_t start_addr : Start addr to erase, should be sector aligned. + * + * uint32_t area_len : Length to erase, should be sector aligned. + * + * Returned Value: + * ESP_ROM_SPIFLASH_RESULT_OK : Erase OK. + * ESP_ROM_SPIFLASH_RESULT_ERR : Erase error. + * ESP_ROM_SPIFLASH_RESULT_TIMEOUT : Erase timeout. + * + *****************************************************************************/ + +esp_rom_spiflash_result_t +esp_rom_spiflash_erase_area(uint32_t start_addr, + uint32_t area_len); + +/***************************************************************************** + * Name: esp_rom_spiflash_write + * + * Description: + * Write Data to Flash, you should Erase it yourself if need. + * + * Please do not call this function in SDK. + * + * Input Parameters: + * uint32_t dest_addr : Address to write, should be 4 bytes aligned. + * + * const uint32_t *src : The pointer to data which is to write. + * + * uint32_t len : Length to write, should be 4 bytes aligned. + * + * Returned Value: + * ESP_ROM_SPIFLASH_RESULT_OK : Write OK. + * ESP_ROM_SPIFLASH_RESULT_ERR : Write error. + * ESP_ROM_SPIFLASH_RESULT_TIMEOUT : Write timeout. + * + *****************************************************************************/ + +esp_rom_spiflash_result_t +esp_rom_spiflash_write(uint32_t dest_addr, + const uint32_t *src, + int32_t len); + +/***************************************************************************** + * Name: esp_rom_spiflash_read + * + * Description: + * Read Data from Flash, you should Erase it yourself if need. + * + * Please do not call this function in SDK. + * + * Input Values: + * uint32_t src_addr : Address to read, should be 4 bytes aligned. + * + * uint32_t *dest : The buf to read the data. + * + * uint32_t len : Length to read, should be 4 bytes aligned. + * + * Returned Value: + * ESP_ROM_SPIFLASH_RESULT_OK : Read OK. + * ESP_ROM_SPIFLASH_RESULT_ERR : Read error. + * ESP_ROM_SPIFLASH_RESULT_TIMEOUT : Read timeout. + * + *****************************************************************************/ + +esp_rom_spiflash_result_t +esp_rom_spiflash_read(uint32_t src_addr, + uint32_t *dest, + int32_t len); + +/***************************************************************************** + * Name: esp_rom_spiflash_write_encrypted_enable + * + * Description: + * SPI1 go into encrypto mode. + * + * Please do not call this function in SDK. + * + *****************************************************************************/ + +void esp_rom_spiflash_write_encrypted_enable(void); + +/***************************************************************************** + * Name: esp_rom_spiflash_prepare_encrypted_data + * + * Description: + * Prepare 32 Bytes data to encrpto writing, you should Erase it yourself + * if need. + * + * Please do not call this function in SDK. + * + * Input Parameters: + * uint32_t flash_addr : Address to write, should be 32 bytes aligned. + * + * uint32_t *data : The pointer to data which is to write. + * + * Returned Value: + * ESP_ROM_SPIFLASH_RESULT_OK : Prepare OK. + * ESP_ROM_SPIFLASH_RESULT_ERR : Prepare error. + * ESP_ROM_SPIFLASH_RESULT_TIMEOUT : Prepare timeout. + * + *****************************************************************************/ + +esp_rom_spiflash_result_t +esp_rom_spiflash_prepare_encrypted_data(uint32_t flash_addr, + uint32_t *data); + +/***************************************************************************** + * Name: esp_rom_spiflash_write_encrypted_disable + * + * Description: + * SPI1 go out of encrypto mode. + * + * Please do not call this function in SDK. + * + *****************************************************************************/ + +void esp_rom_spiflash_write_encrypted_disable(void); + +/***************************************************************************** + * Name: esp_rom_spiflash_write_encrypted + * + * Description: + * Write data to flash with transparent encryption. + * Sectors to be written should already be erased. + * Please do not call this function in SDK. + * + * Input Parameters: + * uint32_t flash_addr : Address to write, should be 32 byte aligned. + * + * uint32_t *data : The pointer to data to write. Note, this pointer must + * be 32 bit aligned and the content of the data will be + * modified by the encryption function. + * + * uint32_t len : Length to write, should be 32 bytes aligned. + * + * Returned Value: + * ESP_ROM_SPIFLASH_RESULT_OK : Data written successfully. + * ESP_ROM_SPIFLASH_RESULT_ERR : Encryption write error. + * ESP_ROM_SPIFLASH_RESULT_TIMEOUT : Encrypto write timeout. + * + *****************************************************************************/ + +esp_rom_spiflash_result_t +esp_rom_spiflash_write_encrypted(uint32_t flash_addr, + uint32_t *data, + uint32_t len); + +/***************************************************************************** + * Name: esp_rom_spiflash_wait_idle + * + * Description: + * Wait until SPI flash write operation is complete + * + * Please do not call this function in SDK. + * + * Reads the Write In Progress bit of the SPI flash status register, + * repeats until this bit is zero (indicating write complete). + * + * Returned Value: + * ESP_ROM_SPIFLASH_RESULT_OK : Write is complete + * ESP_ROM_SPIFLASH_RESULT_ERR : Error while reading status. + * + *****************************************************************************/ + +esp_rom_spiflash_result_t esp_rom_spiflash_wait_idle(esp32s2_spiflash_chip_t + *spi); + +/***************************************************************************** + * Name: esp_rom_spiflash_select_qio_pins + * + * Description: + * Enable Quad I/O pin functions + * + * Please do not call this function in SDK. + * + * Sets the HD & WP pin functions for Quad I/O modes, based on the + * efuse SPI pin configuration. + * + * Input Parameters: + * wp_gpio_num - Number of the WP pin to reconfigure for quad I/O. + * spiconfig - Pin configuration, as returned from + * ets_efuse_get_spiconfig(). + * - If this parameter is 0, default SPI pins are used and + * wp_gpio_num parameter is ignored. + * - If this parameter is 1, default HSPI pins are used and + * wp_gpio_num parameter is ignored. + * - For other values, this parameter encodes the HD pin number + * and also the CLK pin number. CLK pin selection is used to + * determine if HSPI or SPI peripheral will be used (use HSPI + * if CLK pin is the HSPI clock pin, otherwise use SPI). + * Both HD & WP pins are configured via GPIO matrix to map to the selected + * peripheral. + * + *****************************************************************************/ + +void esp_rom_spiflash_select_qio_pins(uint8_t wp_gpio_num, + uint32_t spiconfig); + +/***************************************************************************** + * Name: spi_flash_guard_set + * + * Description: + * Sets guard functions to access flash. + * + * Input Parameters: + * funcs - funcs pointer to structure holding flash access guard functions + * + * Returned Value: + * None + * + *****************************************************************************/ + +void spi_flash_guard_set(const struct spiflash_guard_funcs *funcs); + +/***************************************************************************** + * Name: spi_flash_write_encrypted + * + * Description: + * Write data encrypted to Flash. + * + * Flash encryption must be enabled for this function to work. + * + * Flash encryption must be enabled when calling this function. + * If flash encryption is disabled, the function returns + * ESP_ERR_INVALID_STATE. Use esp_flash_encryption_enabled() + * function to determine if flash encryption is enabled. + * + * Both dest_addr and size must be multiples of 16 bytes. For + * absolute best performance, both dest_addr and size arguments should + * be multiples of 32 bytes. + * + * Input Parameters: + * dest_addr - Destination address in Flash. Must be a multiple of 16 + * bytes. + * src - Pointer to the source buffer. + * size - Length of data, in bytes. Must be a multiple of 16 bytes. + * + * Returned Values: + * Zero (OK) is returned or a negative error. + * + *****************************************************************************/ + +int spi_flash_write_encrypted(uint32_t dest_addr, const void *src, + uint32_t size); + +/***************************************************************************** + * Name: spi_flash_write + * + * Description: + * + * Write data to Flash. + * + * Note: For fastest write performance, write a 4 byte aligned size at a + * 4 byte aligned offset in flash from a source buffer in DRAM. Varying + * any of these parameters will still work, but will be slower due to + * buffering. + * + * Writing more than 8KB at a time will be split into multiple + * write operations to avoid disrupting other tasks in the system. + * + * Parameters: + * dest_addr - Destination address in Flash. + * src - Pointer to the source buffer. + * size - Length of data, in bytes. + * + * Returned Values: + * Zero (OK) is returned or a negative error. + * + *****************************************************************************/ + +int spi_flash_write(uint32_t dest_addr, const void *src, uint32_t size); + +/***************************************************************************** + * Name: spi_flash_read + * + * Description: + * Read data from Flash. + * + * Note: For fastest read performance, all parameters should be + * 4 byte aligned. If source address and read size are not 4 byte + * aligned, read may be split into multiple flash operations. If + * destination buffer is not 4 byte aligned, a temporary buffer will + * be allocated on the stack. + * + * Reading more than 16KB of data at a time will be split + * into multiple reads to avoid disruption to other tasks in the + * system. Consider using spi_flash_mmap() to read large amounts + * of data. + * + * Parameters: + * src_addr - source address of the data in Flash. + * dest - pointer to the destination buffer + * size - length of data + * + * Returned Values: + * Zero (OK) is returned or a negative error. + * + *****************************************************************************/ + +int spi_flash_read(uint32_t src_addr, void *dest, uint32_t size); + +/***************************************************************************** + * Name: spi_flash_erase_sector + * + * Description: + * Erase the Flash sector. + * + * Parameters: + * sector - Sector number, the count starts at sector 0, 4KB per sector. + * + * Returned Values: esp_err_t + * Zero (OK) is returned or a negative error. + * + *****************************************************************************/ + +int spi_flash_erase_sector(uint32_t sector); + +/***************************************************************************** + * Name: spi_flash_erase_range + * + * Description: + * Erase a range of flash sectors + * + * Parameters: + * start_address - Address where erase operation has to start. + * Must be 4kB-aligned + * size - Size of erased range, in bytes. Must be divisible by + * 4kB. + * + * Returned Values: + * Zero (OK) is returned or a negative error. + * + *****************************************************************************/ + +int spi_flash_erase_range(uint32_t start_address, uint32_t size); + +/***************************************************************************** + * Name: spi_flash_cache_enabled + * + * Description: + * Check at runtime if flash cache is enabled on both CPUs. + * + * Returned Values: + * Return true if both CPUs have flash cache enabled, false otherwise. + * + *****************************************************************************/ + +bool spi_flash_cache_enabled(void); + +/***************************************************************************** + * Name: spi_flash_enable_cache + * + * Description: + * Re-enable cache for the core defined as cpuid parameter. + * + * Parameters: + * cpuid - core number to enable instruction cache for. + * + *****************************************************************************/ + +void spi_flash_enable_cache(uint32_t cpuid); + +/***************************************************************************** + * Public Data + *****************************************************************************/ + +extern const struct spiflash_legacy_data_s *rom_spiflash_legacy_data; + +#ifdef __cplusplus +} +#endif + +#endif /* __ARCH_XTENSA_SRC_ESP32S2_ROM_ESP32S2_SPIFLASH_H */ diff --git a/arch/xtensa/src/esp32s3/Make.defs b/arch/xtensa/src/esp32s3/Make.defs index a703e77ce1e8c..8987a2b6b970b 100644 --- a/arch/xtensa/src/esp32s3/Make.defs +++ b/arch/xtensa/src/esp32s3/Make.defs @@ -31,7 +31,7 @@ HEAD_CSRC = esp32s3_start.c CMN_ASRCS = xtensa_context.S xtensa_coproc.S xtensa_cpuint.S xtensa_panic.S CMN_ASRCS += xtensa_sigtramp.S -CMN_CSRCS = xtensa_assert.c xtensa_blocktask.c xtensa_copystate.c +CMN_CSRCS = xtensa_assert.c xtensa_blocktask.c CMN_CSRCS += xtensa_cpenable.c xtensa_createstack.c xtensa_exit.c CMN_CSRCS += xtensa_initialize.c xtensa_initialstate.c xtensa_interruptcontext.c CMN_CSRCS += xtensa_irqdispatch.c xtensa_lowputs.c xtensa_mdelay.c @@ -40,10 +40,14 @@ CMN_CSRCS += xtensa_puts.c xtensa_releasepending.c xtensa_releasestack.c CMN_CSRCS += xtensa_reprioritizertr.c xtensa_schedsigaction.c CMN_CSRCS += xtensa_sigdeliver.c xtensa_stackframe.c xtensa_udelay.c CMN_CSRCS += xtensa_unblocktask.c xtensa_usestack.c xtensa_swint.c -CMN_CSRCS += xtensa_switchcontext.c +CMN_CSRCS += xtensa_saveusercontext.c # Configuration-dependent common XTENSA files +ifeq ($(CONFIG_DEBUG_TCBINFO),y) + CMN_CSRCS += xtensa_tcbinfo.c +endif + ifeq ($(CONFIG_DEBUG_ALERT),y) CMN_CSRCS += xtensa_dumpstate.c endif diff --git a/arch/xtensa/src/esp32s3/esp32s3_cpuidlestack.c b/arch/xtensa/src/esp32s3/esp32s3_cpuidlestack.c index 142b9d628cfc4..9af708ef78c67 100644 --- a/arch/xtensa/src/esp32s3/esp32s3_cpuidlestack.c +++ b/arch/xtensa/src/esp32s3/esp32s3_cpuidlestack.c @@ -34,11 +34,6 @@ * Public Data ****************************************************************************/ -/* Address of the CPU1 IDLE thread */ - -uint32_t g_cpu1_idlestack[CPU1_IDLETHREAD_STACKWORDS] - aligned_data(16) locate_data(".noinit"); - /**************************************************************************** * Public Functions ****************************************************************************/ @@ -81,24 +76,15 @@ uint32_t g_cpu1_idlestack[CPU1_IDLETHREAD_STACKWORDS] * being created for. * - tcb: The TCB of new CPU IDLE task * - stack_size: The requested stack size for the IDLE task. At least - * this much must be allocated. This should be - * CONFIG_IDLETHREAD_STACKSIZE. + * this much must be allocated. * ****************************************************************************/ int up_cpu_idlestack(int cpu, struct tcb_s *tcb, size_t stack_size) { - /* XTENSA uses a push-down stack: the stack grows toward lower* addresses - * in memory. The stack pointer register points to the lowest, valid - * working address (the "top" of the stack). Items on the stack are - * referenced as positive word offsets from sp. - */ - - /* Save information about pre-allocated IDLE thread stack */ - - tcb->stack_alloc_ptr = g_cpu1_idlestack; - tcb->adj_stack_size = CPU1_IDLETHREAD_STACKSIZE; - tcb->stack_base_ptr = tcb->stack_alloc_ptr; +#if CONFIG_SMP_NCPUS > 1 + up_create_stack(tcb, stack_size, TCB_FLAG_TTYPE_KERNEL); +#endif return OK; } diff --git a/arch/xtensa/src/esp32s3/esp32s3_cpustart.c b/arch/xtensa/src/esp32s3/esp32s3_cpustart.c index 8694f4b62075a..b907b0669242f 100644 --- a/arch/xtensa/src/esp32s3/esp32s3_cpustart.c +++ b/arch/xtensa/src/esp32s3/esp32s3_cpustart.c @@ -109,31 +109,14 @@ void xtensa_appcpu_start(void) struct tcb_s *tcb = this_task(); register uint32_t sp; -#ifdef CONFIG_STACK_COLORATION - { - register uint32_t *ptr; - register int i; - - /* If stack debug is enabled, then fill the stack with a recognizable - * value that we can use later to test for high water marks. - */ - - for (i = 0, ptr = (uint32_t *)tcb->stack_alloc_ptr; - i < tcb->adj_stack_size; - i += sizeof(uint32_t)) - { - *ptr++ = STACK_COLOR; - } - } -#endif - /* Move to the stack assigned to us by up_smp_start immediately. Although * we were give a stack pointer at start-up, we don't know where that stack * pointer is positioned respect to our memory map. The only safe option * is to switch to a well-known IDLE thread stack. */ - sp = (uint32_t)tcb->stack_base_ptr + tcb->adj_stack_size; + sp = (uint32_t)tcb->stack_base_ptr + tcb->adj_stack_size - + XCPTCONTEXT_SIZE; __asm__ __volatile__("mov sp, %0\n" : : "r"(sp)); sinfo("CPU%d Started\n", up_cpu_index()); @@ -186,7 +169,7 @@ void xtensa_appcpu_start(void) * be the CPUs NULL task. */ - xtensa_context_restore(tcb->xcp.regs); + xtensa_context_restore(&tcb->xcp.regs); } /**************************************************************************** diff --git a/arch/xtensa/src/esp32s3/esp32s3_oneshot_lowerhalf.c b/arch/xtensa/src/esp32s3/esp32s3_oneshot_lowerhalf.c index bf5fa2414e383..27a260ff2e38c 100644 --- a/arch/xtensa/src/esp32s3/esp32s3_oneshot_lowerhalf.c +++ b/arch/xtensa/src/esp32s3/esp32s3_oneshot_lowerhalf.c @@ -117,7 +117,7 @@ static void oneshot_lh_handler(void *arg) struct esp32s3_oneshot_lowerhalf_s *priv = (struct esp32s3_oneshot_lowerhalf_s *)arg; oneshot_callback_t callback; - FAR void *cb_arg; + void *cb_arg; DEBUGASSERT(priv != NULL); DEBUGASSERT(priv->callback != NULL); diff --git a/arch/xtensa/src/esp32s3/esp32s3_smp.h b/arch/xtensa/src/esp32s3/esp32s3_smp.h index 80a1cef55bd73..eb9aef2070901 100644 --- a/arch/xtensa/src/esp32s3/esp32s3_smp.h +++ b/arch/xtensa/src/esp32s3/esp32s3_smp.h @@ -33,25 +33,10 @@ * Pre-procesor Definitions ****************************************************************************/ -/* An IDLE thread stack size for CPU0 must be defined */ - -#if !defined(CONFIG_IDLETHREAD_STACKSIZE) -# error CONFIG_IDLETHREAD_STACKSIZE is not defined -#elif CONFIG_IDLETHREAD_STACKSIZE < 16 -# error CONFIG_IDLETHREAD_STACKSIZE is to small -#endif - -#define CPU1_IDLETHREAD_STACKSIZE ((CONFIG_IDLETHREAD_STACKSIZE + 15) & ~15) -#define CPU1_IDLETHREAD_STACKWORDS (CPU1_IDLETHREAD_STACKSIZE >> 2) - /**************************************************************************** * Public Data ****************************************************************************/ -/* This is the CPU1 IDLE stack */ - -extern uint32_t g_cpu1_idlestack[CPU1_IDLETHREAD_STACKWORDS]; - /**************************************************************************** * Public Function Prototypes ****************************************************************************/ diff --git a/arch/xtensa/src/lx6/Toolchain.defs b/arch/xtensa/src/lx6/Toolchain.defs index 4dc7236e9e5e7..5312e15056e94 100644 --- a/arch/xtensa/src/lx6/Toolchain.defs +++ b/arch/xtensa/src/lx6/Toolchain.defs @@ -25,7 +25,7 @@ # CROSSDEV The GNU toolchain triple (command prefix) # ARCHCPUFLAGS CPU-specific flags selecting the instruction set # FPU options, etc. -# MAXOPTIMIZATION The maximum optimization level that results in +# ARCHOPTIMIZATION The optimization level that results in # reliable code generation. # @@ -41,22 +41,59 @@ ifeq ($(CONFIG_XTENSA_TOOLCHAIN_ESP), y) CROSSDEV = xtensa-esp32-elf- endif -ARCHCPUFLAGS = +ARCHCPUFLAGS = -mlongcalls + +ifeq ($(CONFIG_MM_KASAN),y) + ARCHCPUFLAGS += -fsanitize=kernel-address +endif ifeq ($(CONFIG_DEBUG_CUSTOMOPT),y) - MAXOPTIMIZATION := $(CONFIG_DEBUG_OPTLEVEL) -else - MAXOPTIMIZATION ?= -Os + ARCHOPTIMIZATION += $(CONFIG_DEBUG_OPTLEVEL) +else ifeq ($(CONFIG_DEBUG_FULLOPT),y) + ARCHOPTIMIZATION += -Os +endif + +ifneq ($(CONFIG_DEBUG_NOOPT),y) + ARCHOPTIMIZATION += -fno-strict-aliasing endif ifeq ($(CONFIG_FRAME_POINTER),y) - MAXOPTIMIZATION += -fno-omit-frame-pointer -fno-optimize-sibling-calls + ARCHOPTIMIZATION += -fno-omit-frame-pointer -fno-optimize-sibling-calls else - MAXOPTIMIZATION += -fomit-frame-pointer + ARCHOPTIMIZATION += -fomit-frame-pointer endif -ifeq ($(CONFIG_MM_KASAN),y) - ARCHCPUFLAGS += -fsanitize=kernel-address +ifeq ($(CONFIG_STACK_CANARIES),y) + ARCHOPTIMIZATION += -fstack-protector-all +endif + +ARCHCFLAGS += -fno-common +ARCHCXXFLAGS += -fno-common -nostdinc++ + +ifneq ($(CONFIG_CXX_EXCEPTION),y) + ARCHCXXFLAGS += -fno-exceptions -fcheck-new +endif + +ifneq ($(CONFIG_CXX_RTTI),y) + ARCHCXXFLAGS += -fno-rtti +endif + +# Optimization of unused sections + +ifeq ($(CONFIG_DEBUG_OPT_UNUSED_SECTIONS),y) + LDFLAGS += --gc-sections + ARCHOPTIMIZATION += -ffunction-sections -fdata-sections +endif + +# Debug link map + +ifeq ($(CONFIG_DEBUG_LINK_MAP),y) + LDFLAGS += --cref -Map=$(call CONVERT_PATH,$(TOPDIR)$(DELIM)nuttx.map) +endif + +ifeq ($(CONFIG_DEBUG_SYMBOLS),y) + LDFLAGS += -g + ARCHOPTIMIZATION += -g endif # Default toolchain @@ -83,12 +120,12 @@ OBJDUMP = $(CROSSDEV)objdump # Add the builtin library -EXTRA_LIBS += ${wildcard ${shell $(CC) $(ARCHCPUFLAGS) --print-libgcc-file-name}} +EXTRA_LIBS += $(wildcard $(shell $(CC) $(ARCHCPUFLAGS) --print-libgcc-file-name)) ifneq ($(CONFIG_LIBM),y) - EXTRA_LIBS += ${wildcard ${shell $(CC) $(ARCHCPUFLAGS) --print-file-name=libm.a}} + EXTRA_LIBS += $(wildcard $(shell $(CC) $(ARCHCPUFLAGS) --print-file-name=libm.a)) endif ifeq ($(CONFIG_LIBSUPCXX),y) - EXTRA_LIBS += ${wildcard ${shell $(CC) $(ARCHCPUFLAGS) --print-file-name=libsupc++.a}} + EXTRA_LIBS += $(wildcard $(shell $(CC) $(ARCHCPUFLAGS) --print-file-name=libsupc++.a)) endif diff --git a/arch/xtensa/src/lx7/Toolchain.defs b/arch/xtensa/src/lx7/Toolchain.defs index 9f94f87cc7ed5..da9fb6f1d30dc 100644 --- a/arch/xtensa/src/lx7/Toolchain.defs +++ b/arch/xtensa/src/lx7/Toolchain.defs @@ -25,7 +25,7 @@ # CROSSDEV The GNU toolchain triple (command prefix) # ARCHCPUFLAGS CPU-specific flags selecting the instruction set # FPU options, etc. -# MAXOPTIMIZATION The maximum optimization level that results in +# ARCHOPTIMIZATION The optimization level that results in # reliable code generation. # @@ -41,22 +41,59 @@ ifeq ($(CONFIG_XTENSA_TOOLCHAIN_ESP), y) CROSSDEV = xtensa-$(CONFIG_ARCH_CHIP)-elf- endif -ARCHCPUFLAGS = +ARCHCPUFLAGS = -mlongcalls + +ifeq ($(CONFIG_MM_KASAN),y) + ARCHCPUFLAGS += -fsanitize=kernel-address +endif ifeq ($(CONFIG_DEBUG_CUSTOMOPT),y) - MAXOPTIMIZATION := $(CONFIG_DEBUG_OPTLEVEL) -else - MAXOPTIMIZATION := -Os + ARCHOPTIMIZATION += $(CONFIG_DEBUG_OPTLEVEL) +else ifeq ($(CONFIG_DEBUG_FULLOPT),y) + ARCHOPTIMIZATION += -Os +endif + +ifneq ($(CONFIG_DEBUG_NOOPT),y) + ARCHOPTIMIZATION += -fno-strict-aliasing endif ifeq ($(CONFIG_FRAME_POINTER),y) - MAXOPTIMIZATION += -fno-omit-frame-pointer -fno-optimize-sibling-calls + ARCHOPTIMIZATION += -fno-omit-frame-pointer -fno-optimize-sibling-calls else - MAXOPTIMIZATION += -fomit-frame-pointer + ARCHOPTIMIZATION += -fomit-frame-pointer endif -ifeq ($(CONFIG_MM_KASAN),y) - ARCHCPUFLAGS += -fsanitize=kernel-address +ifeq ($(CONFIG_STACK_CANARIES),y) + ARCHOPTIMIZATION += -fstack-protector-all +endif + +ARCHCFLAGS += -fno-common +ARCHCXXFLAGS += -fno-common -nostdinc++ + +ifneq ($(CONFIG_CXX_EXCEPTION),y) + ARCHCXXFLAGS += -fno-exceptions -fcheck-new +endif + +ifneq ($(CONFIG_CXX_RTTI),y) + ARCHCXXFLAGS += -fno-rtti +endif + +# Optimization of unused sections + +ifeq ($(CONFIG_DEBUG_OPT_UNUSED_SECTIONS),y) + LDFLAGS += --gc-sections + ARCHOPTIMIZATION += -ffunction-sections -fdata-sections +endif + +# Debug link map + +ifeq ($(CONFIG_DEBUG_LINK_MAP),y) + LDFLAGS += --cref -Map=$(call CONVERT_PATH,$(TOPDIR)$(DELIM)nuttx.map) +endif + +ifeq ($(CONFIG_DEBUG_SYMBOLS),y) + LDFLAGS += -g + ARCHOPTIMIZATION += -g endif # Default toolchain @@ -83,12 +120,12 @@ OBJDUMP = $(CROSSDEV)objdump # Add the builtin library -EXTRA_LIBS += ${wildcard ${shell $(CC) $(ARCHCPUFLAGS) --print-libgcc-file-name}} +EXTRA_LIBS += $(wildcard $(shell $(CC) $(ARCHCPUFLAGS) --print-libgcc-file-name)) ifneq ($(CONFIG_LIBM),y) - EXTRA_LIBS += ${wildcard ${shell $(CC) $(ARCHCPUFLAGS) --print-file-name=libm.a}} + EXTRA_LIBS += $(wildcard $(shell $(CC) $(ARCHCPUFLAGS) --print-file-name=libm.a)) endif ifeq ($(CONFIG_LIBSUPCXX),y) - EXTRA_LIBS += ${wildcard ${shell $(CC) $(ARCHCPUFLAGS) --print-file-name=libsupc++.a}} + EXTRA_LIBS += $(wildcard $(shell $(CC) $(ARCHCPUFLAGS) --print-file-name=libsupc++.a)) endif diff --git a/arch/z16/src/common/z16_exit.c b/arch/z16/src/common/z16_exit.c index 0936a8b36b15b..c7fc4d38b5968 100644 --- a/arch/z16/src/common/z16_exit.c +++ b/arch/z16/src/common/z16_exit.c @@ -70,7 +70,7 @@ static void _z16_dumponexit(FAR struct tcb_s *tcb, FAR void *arg) sinfo(" TCB=%p name=%s\n", tcb, tcb->name); sinfo(" priority=%d state=%d\n", tcb->sched_priority, tcb->task_state); - filelist = tcb->group->tg_filelist; + filelist = &tcb->group->tg_filelist; for (i = 0; i < filelist->fl_rows; i++) { for (j = 0; j < CONFIG_NFILE_DESCRIPTORS_PER_BLOCK; j++) @@ -114,15 +114,15 @@ void up_exit(int status) sinfo("TCB=%p exiting\n", tcb); + /* Destroy the task at the head of the ready to run list. */ + + nxtask_exit(); + #ifdef CONFIG_DUMP_ON_EXIT sinfo("Other tasks:\n"); nxsched_foreach(_z16_dumponexit, NULL); #endif - /* Destroy the task at the head of the ready to run list. */ - - nxtask_exit(); - /* Now, perform the context switch to the new ready-to-run task at the * head of the list. */ diff --git a/arch/z16/src/z16f/Toolchain.defs b/arch/z16/src/z16f/Toolchain.defs index 4b963f4a17fc4..e11e10e0d5763 100644 --- a/arch/z16/src/z16f/Toolchain.defs +++ b/arch/z16/src/z16f/Toolchain.defs @@ -43,7 +43,7 @@ endif ifeq ($(CONFIG_WINDOWS_NATIVE),y) ZDSINSTALLDIR = $(INSTALLROOT)/ZDSII_ZNEO_$(ZDSVERSION) - INSTALLDIR = ${shell echo $(ZDSINSTALLDIR)| sed -e "s/\//\\/g"} + INSTALLDIR = $(shell echo $(ZDSINSTALLDIR)| sed -e "s/\//\\/g") ZDSBINDIR = $(INSTALLDIR)\bin ZDSSTDINCDIR = $(INSTALLDIR)\include\std ZDSZILOGINCDIR = $(INSTALLDIR)\include\zilog @@ -51,7 +51,7 @@ ifeq ($(CONFIG_WINDOWS_NATIVE),y) ZDSZILOGLIBDIR = $(INSTALLDIR)\lib\zilog else ZDSINSTALLDIR = $(INSTALLROOT)/ZDSII_ZNEO_$(ZDSVERSION) - INSTALLDIR = ${shell cygpath -u "$(ZDSINSTALLDIR)"} + INSTALLDIR = $(shell cygpath -u "$(ZDSINSTALLDIR)") ZDSBINDIR = $(INSTALLDIR)/bin ZDSSTDINCDIR = $(INSTALLDIR)/include/std ZDSZILOGINCDIR = $(INSTALLDIR)/include/zilog @@ -61,17 +61,17 @@ else # These are the same directories but with the directory separator # character swapped as needed by the ZDS-II compiler - WTOPDIR = ${shell cygpath -w "$(TOPDIR)"} - WZDSSTDINCDIR = ${shell cygpath -w "$(ZDSSTDINCDIR)"} - WZDSZILOGINCDIR = ${shell cygpath -w "$(ZDSZILOGINCDIR)"} - WZDSSTDLIBDIR = ${shell cygpath -w "$(ZDSSTDLIBDIR)"} - WZDSZILOGLIBDIR = ${shell cygpath -w "$(ZDSZILOGLIBDIR)"} + WTOPDIR = $(shell cygpath -w "$(TOPDIR)") + WZDSSTDINCDIR = $(shell cygpath -w "$(ZDSSTDINCDIR)") + WZDSZILOGINCDIR = $(shell cygpath -w "$(ZDSZILOGINCDIR)") + WZDSSTDLIBDIR = $(shell cygpath -w "$(ZDSSTDLIBDIR)") + WZDSZILOGLIBDIR = $(shell cygpath -w "$(ZDSZILOGLIBDIR)") # Escaped versions - ETOPDIR = ${shell echo "$(WTOPDIR)" | sed -e "s/ /%20/g"} - EZDSSTDINCDIR = ${shell echo "$(WZDSSTDINCDIR)" | sed -e "s/ /%20/g"} - EZDSZILOGINCDIR = ${shell echo "$(WZDSZILOGINCDIR)" | sed -e "s/ /%20/g"} + ETOPDIR = $(shell echo "$(WTOPDIR)" | sed -e "s/ /%20/g") + EZDSSTDINCDIR = $(shell echo "$(WZDSSTDINCDIR)" | sed -e "s/ /%20/g") + EZDSZILOGINCDIR = $(shell echo "$(WZDSZILOGINCDIR)" | sed -e "s/ /%20/g") endif # CPU Identification diff --git a/arch/z80/src/Makefile.clang b/arch/z80/src/Makefile.clang index 5a8893cc2020b..94eac47022030 100644 --- a/arch/z80/src/Makefile.clang +++ b/arch/z80/src/Makefile.clang @@ -90,7 +90,7 @@ NUTTX = "$(TOPDIR)$(DELIM)nuttx$(EXEEXT)" nuttx$(EXEEXT): $(HEAD_OBJ) board$(DELIM)libboard$(LIBEXT) $(LINKCMD) $(Q) echo "LD: nuttx into $(NUTTX)" $(Q) "$(LD)" -o $(NUTTX) $(HEAD_OBJ) -T $(LINKCMD) --orphan-handling=error --print-memory-usage \ - $(LIBPATHS) "-(" $(LDLIBS) "-)" $(LDFLAGS) -Map="$(TOPDIR)$(DELIM)nuttx.map" + $(LIBPATHS) "-(" $(LDLIBS) "-)" $(LDFLAGS) .depend: Makefile chip$(DELIM)Make.defs $(DEPSRCS) $(TOPDIR)$(DELIM).config $(Q) if [ -e board$(DELIM)Makefile ]; then \ diff --git a/arch/z80/src/common/z80_exit.c b/arch/z80/src/common/z80_exit.c index bd7142c65ab20..6843ba0ae8dc9 100644 --- a/arch/z80/src/common/z80_exit.c +++ b/arch/z80/src/common/z80_exit.c @@ -72,7 +72,7 @@ static void _up_dumponexit(FAR struct tcb_s *tcb, FAR void *arg) sinfo(" TCB=%p name=%s\n", tcb, tcb->name); sinfo(" priority=%d state=%d\n", tcb->sched_priority, tcb->task_state); - filelist = tcb->group->tg_filelist; + filelist = &tcb->group->tg_filelist; for (i = 0; i < filelist->fl_rows; i++) { for (j = 0; j < CONFIG_NFILE_DESCRIPTORS_PER_BLOCK; j++) @@ -116,15 +116,15 @@ void up_exit(int status) sinfo("TCB=%p exiting\n", tcb); + /* Destroy the task at the head of the ready to run list. */ + + nxtask_exit(); + #ifdef CONFIG_DUMP_ON_EXIT sinfo("Other tasks:\n"); nxsched_foreach(_up_dumponexit, NULL); #endif - /* Destroy the task at the head of the ready to run list. */ - - nxtask_exit(); - /* Now, perform the context switch to the new ready-to-run task at the * head of the list. */ diff --git a/arch/z80/src/ez80/Toolchain.defs b/arch/z80/src/ez80/Toolchain.defs index 87c094eff06b3..27b189b78c06d 100644 --- a/arch/z80/src/ez80/Toolchain.defs +++ b/arch/z80/src/ez80/Toolchain.defs @@ -43,7 +43,7 @@ else endif ifeq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += -O0 + ARCHOPTIMIZATION += -O0 -fno-strict-aliasing else ARCHOPTIMIZATION += -Oz endif @@ -51,7 +51,7 @@ endif ARCHSTDINCLUDES = ARCHCPUFLAGS = -Dinterrupt="__attribute__((__interrupt__))" -ffreestanding -ARCHCPUFLAGS += -ffunction-sections -fdata-sections -Wa,-march=ez80 +ARCHCPUFLAGS += -Wa,-march=ez80 ARCHLIST = ARCHWARNINGS = -Wall -Wextra -Wno-incompatible-library-redeclaration ARCHWARNINGS += -Wno-main-return-type -Wno-unused-parameter @@ -64,7 +64,24 @@ ARCHASMINCLUDES = -include chip/clang-compat.asm ARCHASMLIST = ARCHASMWARNINGS = -W -LDFLAGS += --gc-sections +# Optimization of unused sections + +ifeq ($(CONFIG_FRAME_POINTER),y) + ARCHOPTIMIZATION += -fno-omit-frame-pointer -fno-optimize-sibling-calls +else + ARCHOPTIMIZATION += -fomit-frame-pointer +endif + +ifeq ($(CONFIG_DEBUG_OPT_UNUSED_SECTIONS),y) + LDFLAGS += --gc-sections + ARCHOPTIMIZATION += -ffunction-sections -fdata-sections +endif + +# Debug link map + +ifeq ($(CONFIG_DEBUG_LINK_MAP),y) + LDFLAGS += --cref -Map=$(call CONVERT_PATH,$(TOPDIR)$(DELIM)nuttx.map) +endif # Tool names/paths. @@ -114,14 +131,14 @@ endif ZDSINSTALLDIR := $(INSTALLROOT)/ZDSII_eZ80Acclaim!_$(ZDSVERSION) ifeq ($(CONFIG_WINDOWS_NATIVE),y) - INSTALLDIR = ${shell echo $(ZDSINSTALLDIR)| sed -e "s/\//\\/g"} + INSTALLDIR = $(shell echo $(ZDSINSTALLDIR)| sed -e "s/\//\\/g") ZDSBINDIR := $(INSTALLDIR)\bin ZDSSTDINCDIR := $(INSTALLDIR)\include\std ZDSZILOGINCDIR := $(INSTALLDIR)\include\zilog ZDSSTDLIBDIR := $(INSTALLDIR)\lib\std ZDSZILOGLIBDIR := $(INSTALLDIR)\lib\zilog else - INSTALLDIR = ${shell cygpath -u "$(ZDSINSTALLDIR)"} + INSTALLDIR = $(shell cygpath -u "$(ZDSINSTALLDIR)") ZDSBINDIR := $(INSTALLDIR)/bin ZDSSTDINCDIR := $(INSTALLDIR)/include/std ZDSZILOGINCDIR := $(INSTALLDIR)/include/zilog @@ -131,17 +148,17 @@ else # These are the same directories but with the directory separator # character swapped as needed by the ZDS-II compiler - WTOPDIR := ${shell cygpath -w "$(TOPDIR)"} - WZDSSTDINCDIR := ${shell cygpath -w "$(ZDSSTDINCDIR)"} - WZDSZILOGINCDIR := ${shell cygpath -w "$(ZDSZILOGINCDIR)"} - WZDSSTDLIBDIR := ${shell cygpath -w "$(ZDSSTDLIBDIR)"} - WZDSZILOGLIBDIR := ${shell cygpath -w "$(ZDSZILOGLIBDIR)"} + WTOPDIR := $(shell cygpath -w "$(TOPDIR)") + WZDSSTDINCDIR := $(shell cygpath -w "$(ZDSSTDINCDIR)") + WZDSZILOGINCDIR := $(shell cygpath -w "$(ZDSZILOGINCDIR)") + WZDSSTDLIBDIR := $(shell cygpath -w "$(ZDSSTDLIBDIR)") + WZDSZILOGLIBDIR := $(shell cygpath -w "$(ZDSZILOGLIBDIR)") # Escaped versions - ETOPDIR := ${shell echo $(WTOPDIR) | sed -e "s/ /%20/g"} - EZDSSTDINCDIR := ${shell echo "$(WZDSSTDINCDIR)" | sed -e "s/ /%20/g"} - EZDSZILOGINCDIR := ${shell echo "$(WZDSZILOGINCDIR)" | sed -e "s/ /%20/g"} + ETOPDIR := $(shell echo $(WTOPDIR) | sed -e "s/ /%20/g") + EZDSSTDINCDIR := $(shell echo "$(WZDSSTDINCDIR)" | sed -e "s/ /%20/g") + EZDSZILOGINCDIR := $(shell echo "$(WZDSZILOGINCDIR)" | sed -e "s/ /%20/g") endif # Optimization level diff --git a/arch/z80/src/z180/Kconfig b/arch/z80/src/z180/Kconfig index ab982aed8b9f8..6363f40a7e0a2 100644 --- a/arch/z80/src/z180/Kconfig +++ b/arch/z80/src/z180/Kconfig @@ -304,17 +304,10 @@ endchoice choice prompt "Toolchain Selection" - default Z180_TOOLCHAIN_SDCCW if TOOLCHAIN_WINDOWS - default Z180_TOOLCHAIN_SDCCL if !TOOLCHAIN_WINDOWS + default Z180_TOOLCHAIN_SDCC -config Z180_TOOLCHAIN_SDCCL - bool "SDCC for Linux, macOS, or Cygwin" - depends on !WINDOWS_NATIVE - -config Z180_TOOLCHAIN_SDCCW - bool "SDCC for Windows" - depends on TOOLCHAIN_WINDOWS - select CYGWIN_WINTOOL if WINDOWS_CYGWIN +config Z180_TOOLCHAIN_SDCC + bool "Win32, SDCC for Linux, macOS, or Cygwin" endchoice diff --git a/arch/z80/src/z180/Toolchain.defs b/arch/z80/src/z180/Toolchain.defs index cd8d16f7a5dea..2ba6b30768f0e 100644 --- a/arch/z80/src/z180/Toolchain.defs +++ b/arch/z80/src/z180/Toolchain.defs @@ -29,8 +29,7 @@ # built to run on Windows as a POSIX toolchain. The various SDCC options # are selected in the NuttX configuration with: # -# CONFIG_Z180_TOOLCHAIN_SDCCL=y : SDCC for Linux, macOS or Cygwin -# CONFIG_Z180_TOOLCHAIN_SDCCW=y : SDCC for Win32 +# CONFIG_Z180_TOOLCHAIN_SDCC=y : Win32, SDCC for Linux, macOS or Cygwin # # These are the directories where the SDCC toolchain is installed. NOTE diff --git a/arch/z80/src/z180/z180_mmu.c b/arch/z80/src/z180/z180_mmu.c index 29e5d31896507..970bd9be3c401 100644 --- a/arch/z80/src/z180/z180_mmu.c +++ b/arch/z80/src/z180/z180_mmu.c @@ -375,6 +375,33 @@ int up_addrenv_vdata(FAR group_addrenv_t *addrenv, uintptr_t textsize, return CONFIG_Z180_COMMON1AREA_VIRTBASE + textsize; } +/**************************************************************************** + * Name: up_addrenv_vheap + * + * Description: + * Return the heap virtual address associated with the newly created + * address environment. This function is used by the binary loaders in + * order get an address that can be used to initialize the new task. + * + * Input Parameters: + * addrenv - The representation of the task address environment previously + * returned by up_addrenv_create. + * vheap - The location to return the virtual address. + * + * Returned Value: + * Zero (OK) on success; a negated errno value on failure. + * + ****************************************************************************/ + +#ifdef CONFIG_BUILD_KERNEL +int up_addrenv_vheap(FAR const group_addrenv_t *addrenv, FAR void **vheap) +{ + /* Not implemented */ + + return -ENOSYS; +} +#endif + /**************************************************************************** * Name: up_addrenv_heapsize * diff --git a/arch/z80/src/z8/Toolchain.defs b/arch/z80/src/z8/Toolchain.defs index 5e0fbcb807951..3284769867dcb 100644 --- a/arch/z80/src/z8/Toolchain.defs +++ b/arch/z80/src/z8/Toolchain.defs @@ -35,7 +35,7 @@ endif ifeq ($(CONFIG_WINDOWS_NATIVE),y) ZDSINSTALLDIR = C:/PROGRA~2/ZiLOG/ZDSII_Z8Encore!_$(ZDSVERSION) - INSTALLDIR = ${shell echo $(ZDSINSTALLDIR)| sed -e "s/\//\\/g"} + INSTALLDIR = $(shell echo $(ZDSINSTALLDIR)| sed -e "s/\//\\/g") ZDSBINDIR = $(INSTALLDIR)\bin ZDSSTDINCDIR = $(INSTALLDIR)\include\std ZDSZILOGINCDIR = $(INSTALLDIR)\include\zilog @@ -49,7 +49,7 @@ endif ZDSZILOGLIBDIR = $(INSTALLDIR)\lib\zilog else ZDSINSTALLDIR = C:/PROGRA~2/ZiLOG/ZDSII_Z8Encore!_$(ZDSVERSION) - INSTALLDIR = ${shell cygpath -u "$(ZDSINSTALLDIR)"} + INSTALLDIR = $(shell cygpath -u "$(ZDSINSTALLDIR)") ZDSBINDIR = $(INSTALLDIR)/bin ZDSSTDINCDIR = $(INSTALLDIR)/include/std ZDSZILOGINCDIR = $(INSTALLDIR)/include/zilog @@ -65,18 +65,18 @@ endif # These are the same directories but with the directory separator # character swapped as needed by the ZDS-II compiler - WTOPDIR = ${shell cygpath -w "$(TOPDIR)"} - WZDSSTDINCDIR = ${shell cygpath -w "$(ZDSSTDINCDIR)"} - WZDSZILOGINCDIR = ${shell cygpath -w "$(ZDSZILOGINCDIR)"} - WZDSDEVINCDIR = ${shell cygpath -w "$(ZDSDEVINCDIR)"} - WZDSSTDLIBDIR = ${shell cygpath -w "$(ZDSSTDLIBDIR)"} - WZDSZILOGLIBDIR = ${shell cygpath -w "$(ZDSZILOGLIBDIR)"} + WTOPDIR = $(shell cygpath -w "$(TOPDIR)") + WZDSSTDINCDIR = $(shell cygpath -w "$(ZDSSTDINCDIR)") + WZDSZILOGINCDIR = $(shell cygpath -w "$(ZDSZILOGINCDIR)") + WZDSDEVINCDIR = $(shell cygpath -w "$(ZDSDEVINCDIR)") + WZDSSTDLIBDIR = $(shell cygpath -w "$(ZDSSTDLIBDIR)") + WZDSZILOGLIBDIR = $(shell cygpath -w "$(ZDSZILOGLIBDIR)") # Escaped versions - ETOPDIR = ${shell echo "$(WTOPDIR)" | sed -e "s/ /%20/g"} - EZDSSTDINCDIR = ${shell echo "$(WZDSSTDINCDIR)" | sed -e "s/ /%20/g"} - EZDSZILOGINCDIR = ${shell echo "$(WZDSZILOGINCDIR)" | sed -e "s/ /%20/g"} + ETOPDIR = $(shell echo "$(WTOPDIR)" | sed -e "s/ /%20/g") + EZDSSTDINCDIR = $(shell echo "$(WZDSSTDINCDIR)" | sed -e "s/ /%20/g") + EZDSZILOGINCDIR = $(shell echo "$(WZDSZILOGINCDIR)" | sed -e "s/ /%20/g") endif # CPU Identification diff --git a/arch/z80/src/z80/Kconfig b/arch/z80/src/z80/Kconfig index f97656ec59165..b5bfd1d37e646 100644 --- a/arch/z80/src/z80/Kconfig +++ b/arch/z80/src/z80/Kconfig @@ -7,17 +7,10 @@ if ARCH_CHIP_Z80 choice prompt "Toolchain Selection" - default Z80_TOOLCHAIN_SDCCW if TOOLCHAIN_WINDOWS - default Z80_TOOLCHAIN_SDCCL if !TOOLCHAIN_WINDOWS + default Z80_TOOLCHAIN_SDCC -config Z80_TOOLCHAIN_SDCCL - bool "SDCC for Linux, macOS, or Cygwin" - depends on !WINDOWS_NATIVE - -config Z80_TOOLCHAIN_SDCCW - bool "SDCC for Windows" - depends on TOOLCHAIN_WINDOWS - select CYGWIN_WINTOOL if WINDOWS_CYGWIN +config Z80_TOOLCHAIN_SDCC + bool "Win32, SDCC for Linux, macOS, or Cygwin" endchoice diff --git a/arch/z80/src/z80/Toolchain.defs b/arch/z80/src/z80/Toolchain.defs index e9a5ef421c7ca..fa74c9c414ab5 100644 --- a/arch/z80/src/z80/Toolchain.defs +++ b/arch/z80/src/z80/Toolchain.defs @@ -29,8 +29,7 @@ # built to run on Windows as a POSIX toolchain. The various SDCC options are # selected in the NuttX configuration with: # -# CONFIG_Z80_TOOLCHAIN_SDCCL=y : SDCC for Linux, macOS or Cygwin -# CONFIG_Z80_TOOLCHAIN_SDCCW=y : SDCC for Win32 +# CONFIG_Z80_TOOLCHAIN_SDCC=y : Win32, SDCC for Linux, macOS or Cygwin # # These are the directories where the SDCC toolchain is installed. NOTE diff --git a/audio/audio_comp.c b/audio/audio_comp.c index fd93121d30cb7..5af63994d2a82 100644 --- a/audio/audio_comp.c +++ b/audio/audio_comp.c @@ -919,14 +919,15 @@ static void audio_comp_callback(FAR void *arg, uint16_t reason, * ... - The list of the lower half audio driver. * * Returned Value: - * Zero on success; a negated errno value on failure. + * struct audio_lowerhalf_s* on success; NULL on failure. * * Note * The variable argument list must be NULL terminated. * ****************************************************************************/ -int audio_comp_initialize(FAR const char *name, ...) +FAR struct audio_lowerhalf_s *audio_comp_initialize(FAR const char *name, + ...) { FAR struct audio_comp_priv_s *priv; va_list ap; @@ -936,7 +937,7 @@ int audio_comp_initialize(FAR const char *name, ...) priv = kmm_zalloc(sizeof(struct audio_comp_priv_s)); if (priv == NULL) { - return ret; + return NULL; } priv->export.ops = &g_audio_comp_ops; @@ -968,17 +969,20 @@ int audio_comp_initialize(FAR const char *name, ...) } va_end(ap); - ret = audio_register(name, &priv->export); - if (ret < 0) + if (name != NULL) { - goto free_lower; + ret = audio_register(name, &priv->export); + if (ret < 0) + { + goto free_lower; + } } - return OK; + return &priv->export; free_lower: kmm_free(priv->lower); free_priv: kmm_free(priv); - return ret; + return NULL; } diff --git a/binfmt/binfmt.h b/binfmt/binfmt.h index 13fb13fa6c22b..f66f8fc58f60e 100644 --- a/binfmt/binfmt.h +++ b/binfmt/binfmt.h @@ -117,6 +117,50 @@ void binfmt_freeargv(FAR char * const *argv); # define binfmt_freeargv(argv) #endif +/**************************************************************************** + * Name: binfmt_copyenv + * + * Description: + * In the kernel build, the environment exists in the parent's address + * environment and, hence, will be inaccessible when we switch to the + * address environment of the new process. So we do not have any real + * option other than to copy the parents envp list into an intermediate + * buffer that resides in neutral kernel memory. + * + * Input Parameters: + * envp - Allocated environment strings + * + * Returned Value: + * A non-zero copy is returned on success. + * + ****************************************************************************/ + +#ifndef CONFIG_DISABLE_ENVIRON +# define binfmt_copyenv(envp) binfmt_copyargv(envp) +#else +# define binfmt_copyenv(envp) (envp) +#endif + +/**************************************************************************** + * Name: binfmt_freeenv + * + * Description: + * Release the copied envp[] list. + * + * Input Parameters: + * envp - Allocated environment strings + * + * Returned Value: + * None + * + ****************************************************************************/ + +#ifndef CONFIG_DISABLE_ENVIRON +# define binfmt_freeenv(envp) binfmt_freeargv(envp) +#else +# define binfmt_freeenv(envp) +#endif + /**************************************************************************** * Name: builtin_initialize * diff --git a/binfmt/binfmt_exec.c b/binfmt/binfmt_exec.c index 5bac3a5e7369b..222a7de72b0de 100644 --- a/binfmt/binfmt_exec.c +++ b/binfmt/binfmt_exec.c @@ -55,6 +55,8 @@ * program. * argv - A pointer to an array of string arguments. The end of the * array is indicated with a NULL entry. + * envp - A pointer to an array of environment strings. Terminated with + * a NULL entry. * exports - The address of the start of the caller-provided symbol * table. This symbol table contains the addresses of symbols * exported by the caller and made available for linking the @@ -69,8 +71,8 @@ ****************************************************************************/ int exec_spawn(FAR const char *filename, FAR char * const *argv, - FAR const struct symtab_s *exports, int nexports, - FAR const posix_spawnattr_t *attr) + FAR char * const *envp, FAR const struct symtab_s *exports, + int nexports, FAR const posix_spawnattr_t *attr) { FAR struct binary_s *bin; int pid; @@ -121,7 +123,7 @@ int exec_spawn(FAR const char *filename, FAR char * const *argv, /* Then start the module */ - pid = exec_module(bin, filename, argv); + pid = exec_module(bin, filename, argv, envp); if (pid < 0) { ret = pid; @@ -210,6 +212,9 @@ int exec_spawn(FAR const char *filename, FAR char * const *argv, * program. * argv - A pointer to an array of string arguments. The end of the * array is indicated with a NULL entry. + * envp - An array of character pointers to null-terminated strings + * that provide the environment for the new process image. + * The environment array is terminated by a null pointer. * exports - The address of the start of the caller-provided symbol * table. This symbol table contains the addresses of symbols * exported by the caller and made available for linking the @@ -224,11 +229,12 @@ int exec_spawn(FAR const char *filename, FAR char * const *argv, ****************************************************************************/ int exec(FAR const char *filename, FAR char * const *argv, - FAR const struct symtab_s *exports, int nexports) + FAR char * const *envp, FAR const struct symtab_s *exports, + int nexports) { int ret; - ret = exec_spawn(filename, argv, exports, nexports, NULL); + ret = exec_spawn(filename, argv, envp, exports, nexports, NULL); if (ret < 0) { set_errno(-ret); diff --git a/binfmt/binfmt_execmodule.c b/binfmt/binfmt_execmodule.c index 61b41cbf01d8b..c2ee6cea0d1d5 100644 --- a/binfmt/binfmt_execmodule.c +++ b/binfmt/binfmt_execmodule.c @@ -112,11 +112,13 @@ static void exec_ctors(FAR void *arg) ****************************************************************************/ int exec_module(FAR const struct binary_s *binp, - FAR const char *filename, FAR char * const *argv) + FAR const char *filename, FAR char * const *argv, + FAR char * const *envp) { FAR struct task_tcb_s *tcb; #if defined(CONFIG_ARCH_ADDRENV) && defined(CONFIG_BUILD_KERNEL) save_addrenv_t oldenv; + FAR void *vheap; #endif pid_t pid; int ret; @@ -150,6 +152,18 @@ int exec_module(FAR const struct binary_s *binp, } } + /* Make a copy of the environment here */ + + if (envp || (envp = environ)) + { + envp = binfmt_copyenv(envp); + if (!envp) + { + ret = -ENOMEM; + goto errout_with_args; + } + } + #if defined(CONFIG_ARCH_ADDRENV) && defined(CONFIG_BUILD_KERNEL) /* Instantiate the address environment containing the user heap */ @@ -157,12 +171,19 @@ int exec_module(FAR const struct binary_s *binp, if (ret < 0) { berr("ERROR: up_addrenv_select() failed: %d\n", ret); - binfmt_freeargv(argv); - goto errout_with_tcb; + goto errout_with_envp; } - binfo("Initialize the user heap (heapsize=%d)\n", binp->addrenv.heapsize); - umm_initialize((FAR void *)CONFIG_ARCH_HEAP_VBASE, binp->addrenv.heapsize); + ret = up_addrenv_vheap(&binp->addrenv, &vheap); + if (ret < 0) + { + berr("ERROR: up_addrenv_vheap() failed: %d\n", ret); + goto errout_with_addrenv; + } + + binfo("Initialize the user heap (heapsize=%zu)\n", + up_addrenv_heapsize(&binp->addrenv)); + umm_initialize(vheap, up_addrenv_heapsize(&binp->addrenv)); #endif /* Note that tcb->flags are not modified. 0=normal task */ @@ -174,21 +195,25 @@ int exec_module(FAR const struct binary_s *binp, if (argv && argv[0]) { ret = nxtask_init(tcb, argv[0], binp->priority, NULL, - binp->stacksize, binp->entrypt, &argv[1]); + binp->stacksize, binp->entrypt, &argv[1], envp); } else { ret = nxtask_init(tcb, filename, binp->priority, NULL, - binp->stacksize, binp->entrypt, argv); + binp->stacksize, binp->entrypt, argv, envp); } - binfmt_freeargv(argv); if (ret < 0) { berr("nxtask_init() failed: %d\n", ret); goto errout_with_addrenv; } + /* The copied argv and envp can now be released */ + + binfmt_freeargv(argv); + binfmt_freeenv(envp); + #if defined(CONFIG_ARCH_ADDRENV) && defined(CONFIG_ARCH_KERNEL_STACK) /* Allocate the kernel stack */ @@ -281,7 +306,11 @@ int exec_module(FAR const struct binary_s *binp, errout_with_addrenv: #if defined(CONFIG_ARCH_ADDRENV) && defined(CONFIG_BUILD_KERNEL) up_addrenv_restore(&oldenv); +errout_with_envp: #endif + binfmt_freeenv(envp); +errout_with_args: + binfmt_freeargv(argv); errout_with_tcb: kmm_free(tcb); return ret; diff --git a/binfmt/libelf/libelf.h b/binfmt/libelf/libelf.h index e5e4a5bba6c35..d2f7b6607e040 100644 --- a/binfmt/libelf/libelf.h +++ b/binfmt/libelf/libelf.h @@ -290,7 +290,7 @@ int elf_addrenv_alloc(FAR struct elf_loadinfo_s *loadinfo, size_t textsize, ****************************************************************************/ #ifdef CONFIG_ARCH_ADDRENV -# define elf_addrenv_select(l) up_addrenv_select(&(l)->addrenv, &(l)->oldenv) +int elf_addrenv_select(FAR struct elf_loadinfo_s *loadinfo); #endif /**************************************************************************** @@ -308,7 +308,7 @@ int elf_addrenv_alloc(FAR struct elf_loadinfo_s *loadinfo, size_t textsize, ****************************************************************************/ #ifdef CONFIG_ARCH_ADDRENV -# define elf_addrenv_restore(l) up_addrenv_restore(&(l)->oldenv) +int elf_addrenv_restore(FAR struct elf_loadinfo_s *loadinfo); #endif /**************************************************************************** diff --git a/binfmt/libelf/libelf_addrenv.c b/binfmt/libelf/libelf_addrenv.c index 9ede25a383ba4..cece78388eeec 100644 --- a/binfmt/libelf/libelf_addrenv.c +++ b/binfmt/libelf/libelf_addrenv.c @@ -145,6 +145,92 @@ int elf_addrenv_alloc(FAR struct elf_loadinfo_s *loadinfo, size_t textsize, #endif } +/**************************************************************************** + * Name: elf_addrenv_restore + * + * Description: + * Restore the address environment before elf_addrenv_select() was called.. + * + * Input Parameters: + * loadinfo - Load state information + * + * Returned Value: + * Zero (OK) on success; a negated errno value on failure. + * + ****************************************************************************/ + +#ifdef CONFIG_ARCH_ADDRENV +int elf_addrenv_select(FAR struct elf_loadinfo_s *loadinfo) +{ + int ret; + + /* Instantiate the new address environment */ + + ret = up_addrenv_select(&loadinfo->addrenv, &loadinfo->oldenv); + if (ret < 0) + { + berr("ERROR: up_addrenv_select failed: %d\n", ret); + return ret; + } + + /* Allow write access to .text */ + + ret = up_addrenv_text_enable_write(&loadinfo->addrenv); + if (ret < 0) + { + berr("ERROR: up_addrenv_text_enable_write failed: %d\n", ret); + return ret; + } + + return OK; +} +#endif + +/**************************************************************************** + * Name: elf_addrenv_free + * + * Description: + * Release the address environment previously created by + * elf_addrenv_alloc(). This function is called only under certain error + * conditions after the module has been loaded but not yet started. + * After the module has been started, the address environment will + * automatically be freed when the module exits. + * + * Input Parameters: + * loadinfo - Load state information + * + * Returned Value: + * None. + * + ****************************************************************************/ + +#ifdef CONFIG_ARCH_ADDRENV +int elf_addrenv_restore(FAR struct elf_loadinfo_s *loadinfo) +{ + int ret; + + /* Remove write access to .text */ + + ret = up_addrenv_text_disable_write(&loadinfo->addrenv); + if (ret < 0) + { + berr("ERROR: up_addrenv_text_disable_write failed: %d\n", ret); + return ret; + } + + /* Restore the old address environment */ + + ret = up_addrenv_restore(&loadinfo->oldenv); + if (ret < 0) + { + berr("ERROR: up_addrenv_restore failed: %d\n", ret); + return ret; + } + + return OK; +} +#endif + /**************************************************************************** * Name: elf_addrenv_free * diff --git a/boards/Kconfig b/boards/Kconfig index a571070007980..ce5ef17ecf402 100644 --- a/boards/Kconfig +++ b/boards/Kconfig @@ -3499,6 +3499,15 @@ config BOARD_ASSERT_RESET_VALUE implementations to handle the reset differently for the case of a crash. +config BOARDCTL_RESET_CAUSE + bool "Return reset cause" + default n + depends on ARCH_HAVE_RESET + ---help--- + Enables support for the BOARDIOC_RESET_CAUSE boardctl() command. + Architecture specific logic must provide the board_reset_cause() + interface. + config BOARDCTL_UNIQUEID bool "Return board unique ID" default n diff --git a/boards/arm/a1x/pcduino-a10/README.txt b/boards/arm/a1x/pcduino-a10/README.txt index 2069e2c2a8999..cd070e43b3011 100644 --- a/boards/arm/a1x/pcduino-a10/README.txt +++ b/boards/arm/a1x/pcduino-a10/README.txt @@ -367,7 +367,7 @@ Configurations CONFIG_WINDOWS_CYGWIN=y : Using Cygwin or other POSIX environment System Type -> Toolchain: - CONFIG_ARMV7A_TOOLCHAIN_GNU_EABIW=y : GNU EABI toolchain for Windows + CONFIG_ARMV7A_TOOLCHAIN_GNU_EABI=y : GNU EABI toolchain Configuration Sub-directories ----------------------------- diff --git a/boards/arm/a1x/pcduino-a10/configs/nsh/pcduino-140107.patch b/boards/arm/a1x/pcduino-a10/configs/nsh/pcduino-140107.patch index 8531d4cb58672..d0f52969c88a8 100644 --- a/boards/arm/a1x/pcduino-a10/configs/nsh/pcduino-140107.patch +++ b/boards/arm/a1x/pcduino-a10/configs/nsh/pcduino-140107.patch @@ -26,10 +26,8 @@ index 3cc6323..ad42790 100644 /* Initialize the FPU */ - #ifdef CONFIG_ARCH_FPU +syslog(LOG_INFO, "Calling arm_fpuconfig\n"); // REMOVE ME arm_fpuconfig(); - #endif /* Perform common, low-level chip initialization (might do nothing) */ diff --git a/boards/arm/a1x/pcduino-a10/scripts/Make.defs b/boards/arm/a1x/pcduino-a10/scripts/Make.defs index b0d996ed04928..39171e98de8d1 100644 --- a/boards/arm/a1x/pcduino-a10/scripts/Make.defs +++ b/boards/arm/a1x/pcduino-a10/scripts/Make.defs @@ -23,19 +23,8 @@ include $(TOPDIR)/tools/Config.mk include $(TOPDIR)/arch/arm/src/armv7-a/Toolchain.defs LDSCRIPT = sdram.ld - ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT) -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new -fno-rtti ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 @@ -50,7 +39,3 @@ AFLAGS := $(CFLAGS) -D__ASSEMBLY__ NXFLATLDFLAGS1 = -r -d -warn-common NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)$(DELIM)binfmt$(DELIM)libnxflat$(DELIM)gnu-nxflat-pcrel.ld -no-check-sections LDNXFLATFLAGS = -e main -s 2048 - -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - LDFLAGS += -g -endif diff --git a/boards/arm/am335x/beaglebone-black/README.txt b/boards/arm/am335x/beaglebone-black/README.txt index 07145fe3a45b4..ad6570e481b60 100644 --- a/boards/arm/am335x/beaglebone-black/README.txt +++ b/boards/arm/am335x/beaglebone-black/README.txt @@ -210,7 +210,7 @@ Configurations CONFIG_WINDOWS_CYGWIN=y : Using Cygwin or other POSIX environment System Type -> Toolchain: - CONFIG_ARMV7A_TOOLCHAIN_GNU_EABIW=y : GNU EABI toolchain for Windows + CONFIG_ARMV7A_TOOLCHAIN_GNU_EABI=y : GNU EABI toolchain Configuration Sub-directories ----------------------------- diff --git a/boards/arm/am335x/beaglebone-black/scripts/Make.defs b/boards/arm/am335x/beaglebone-black/scripts/Make.defs index 0fa21afa68874..fa6035458f6c7 100644 --- a/boards/arm/am335x/beaglebone-black/scripts/Make.defs +++ b/boards/arm/am335x/beaglebone-black/scripts/Make.defs @@ -25,19 +25,8 @@ include $(TOPDIR)/arch/arm/src/armv7-a/Toolchain.defs # Setup for the kind of memory that we are executing from LDSCRIPT = sdram.ld - ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT) -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new -fno-rtti ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 @@ -52,7 +41,3 @@ AFLAGS := $(CFLAGS) -D__ASSEMBLY__ NXFLATLDFLAGS1 = -r -d -warn-common NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-pcrel.ld -no-check-sections LDNXFLATFLAGS = -e main -s 2048 - -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - LDFLAGS += -g -endif diff --git a/boards/arm/c5471/c5471evm/scripts/Make.defs b/boards/arm/c5471/c5471evm/scripts/Make.defs index 94a3c1646e19b..8a8a03b4e3745 100644 --- a/boards/arm/c5471/c5471evm/scripts/Make.defs +++ b/boards/arm/c5471/c5471evm/scripts/Make.defs @@ -45,18 +45,12 @@ ifeq ("${CONFIG_DEBUG_FEATURES}","y") ARCHOPTIMIZATION = -g endif -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - ifeq ($(OLDGCC),n) ARCHCPUFLAGS = -mcpu=arm7tdmi -mfloat-abi=soft else ARCHCPUFLAGS = -mapcs-32 -mcpu=arm7tdmi -msoft-float endif -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef diff --git a/boards/arm/cxd56xx/common/src/Make.defs b/boards/arm/cxd56xx/common/src/Make.defs index 0dae76163789b..572a772536634 100644 --- a/boards/arm/cxd56xx/common/src/Make.defs +++ b/boards/arm/cxd56xx/common/src/Make.defs @@ -110,6 +110,10 @@ ifeq ($(CONFIG_SENSORS_RPR0521RS_SCU),y) CSRCS += cxd56_rpr0521rs_scu.c endif +ifeq ($(CONFIG_SENSORS_SCD41),y) +CSRCS += cxd56_scd41_i2c.c +endif + ifeq ($(CONFIG_NETDEVICES),y) CSRCS += cxd56_netinit.c endif diff --git a/boards/arm/cxd56xx/common/src/cxd56_i2cdev.c b/boards/arm/cxd56xx/common/src/cxd56_i2cdev.c index 38eb03956417a..4d3b1bd294965 100644 --- a/boards/arm/cxd56xx/common/src/cxd56_i2cdev.c +++ b/boards/arm/cxd56xx/common/src/cxd56_i2cdev.c @@ -62,6 +62,7 @@ int board_i2cdev_initialize(int port) if (ret < 0) { _err("ERROR: Failed to register i2c%d: %d\n", port, ret); + cxd56_i2cbus_uninitialize(i2c); } return ret; diff --git a/boards/arm/cxd56xx/common/src/cxd56_scd41_i2c.c b/boards/arm/cxd56xx/common/src/cxd56_scd41_i2c.c new file mode 100644 index 0000000000000..d3f0b15e232a8 --- /dev/null +++ b/boards/arm/cxd56xx/common/src/cxd56_scd41_i2c.c @@ -0,0 +1,72 @@ +/**************************************************************************** + * boards/arm/cxd56xx/common/src/cxd56_scd41_i2c.c + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include +#include +#include + +#include + +#include + +#include "cxd56_i2c.h" + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +#if defined(CONFIG_I2C) && defined(CONFIG_SENSORS_SCD41) + +int board_scd41_initialize(FAR const char *devpath, int bus) +{ + int ret; + FAR struct i2c_master_s *i2c; + + sninfo("Initializing SCD41...\n"); + + /* Initialize i2c device */ + + i2c = cxd56_i2cbus_initialize(bus); + if (!i2c) + { + snerr("ERROR: Failed to initialize i2c%d.\n", bus); + return -ENODEV; + } + + ret = scd41_register_i2c(devpath, i2c); + if (ret < 0) + { + snerr("Error registering SCD41.\n"); + } + + return ret; +} + +#endif diff --git a/boards/arm/cxd56xx/common/src/cxd56_sensors.c b/boards/arm/cxd56xx/common/src/cxd56_sensors.c index a01a6d634fba7..26fe4b58d89b5 100644 --- a/boards/arm/cxd56xx/common/src/cxd56_sensors.c +++ b/boards/arm/cxd56xx/common/src/cxd56_sensors.c @@ -216,6 +216,9 @@ static struct sensor_device_s sensor_device[] = #if defined(CONFIG_SENSORS_BH1745NUC) || defined(CONFIG_SENSORS_BH1745NUC_SCU) _I2C_DEVICE(bh1745nuc, "/dev/color"), /* Color */ #endif +#if defined(CONFIG_SENSORS_SCD41) + _I2C_DEVICE(scd41, "/dev/co2"), /* CO2 */ +#endif }; /**************************************************************************** diff --git a/boards/arm/cxd56xx/drivers/sensors/bmp280_scu.c b/boards/arm/cxd56xx/drivers/sensors/bmp280_scu.c index ceb272bdb136c..91f7b063a7957 100644 --- a/boards/arm/cxd56xx/drivers/sensors/bmp280_scu.c +++ b/boards/arm/cxd56xx/drivers/sensors/bmp280_scu.c @@ -175,9 +175,11 @@ static const struct file_operations g_bmp280pressfops = bmp280_close_press, /* close */ bmp280_read_press, /* read */ bmp280_write, /* write */ - 0, /* seek */ - bmp280_ioctl_press, /* ioctl */ - 0 /* unlink */ + NULL, /* seek */ + bmp280_ioctl_press /* ioctl */ +#ifndef CONFIG_DISABLE_PSEUDOFS_OPERATIONS + , NULL /* unlink */ +#endif }; static const struct file_operations g_bmp280tempfops = @@ -186,9 +188,11 @@ static const struct file_operations g_bmp280tempfops = bmp280_close_temp, /* close */ bmp280_read_temp, /* read */ bmp280_write, /* write */ - 0, /* seek */ - bmp280_ioctl_temp, /* ioctl */ - 0 /* unlink */ + NULL, /* seek */ + bmp280_ioctl_temp /* ioctl */ +#ifndef CONFIG_DISABLE_PSEUDOFS_OPERATIONS + , NULL /* unlink */ +#endif }; /* SCU instructions for pick pressure sensing data. */ diff --git a/boards/arm/cxd56xx/spresense/Kconfig b/boards/arm/cxd56xx/spresense/Kconfig index 57323d459ef4d..872b4004093da 100644 --- a/boards/arm/cxd56xx/spresense/Kconfig +++ b/boards/arm/cxd56xx/spresense/Kconfig @@ -514,6 +514,189 @@ config LCD_ON_MAIN_BOARD Display connected to main board. endchoice + +if LCD_ON_MAIN_BOARD + +choice + prompt "LCD ILI934x RST Pin selection" + default LCD_RSTPIN_I2S0_BCK + +config LCD_RSTPIN_UART2_TX + bool "UART2_TX (D01) PIN" + +config LCD_RSTPIN_UART2_RX + bool "UART2_RX (D00) PIN" + +config LCD_RSTPIN_UART2_RTS + bool "UART2_RTS (D28) PIN" + +config LCD_RSTPIN_UART2_CTS + bool "UART2_CTS (D27) PIN" + +config LCD_RSTPIN_I2S0_BCK + bool "I2S0_BCK (D26) PIN" + +config LCD_RSTPIN_I2S0_LRCK + bool "I2S0_LRCK (D25) PIN" + +config LCD_RSTPIN_SEN_IRQ_IN + bool "SEN_IRQ_IN (D22) PIN" + +config LCD_RSTPIN_EMMC_DATA3 + bool "EMMC_DATA3 (D21) PIN" + +config LCD_RSTPIN_EMMC_DATA2 + bool "EMMC_DATA2 (D20) PIN" + +config LCD_RSTPIN_I2S0_DATA_IN + bool "I2S0_DATA_IN (D19) PIN" + +config LCD_RSTPIN_I2S0_DATA_OUT + bool "I2S0_DATA_OUT (D18) PIN" + +config LCD_RSTPIN_I2C0_SCL + bool "I2C0_SCL (D15) PIN" + +config LCD_RSTPIN_I2C0_SDA + bool "I2C0_SDA (D14) PIN" + +endchoice + +choice + prompt "LCD ILI934x DC Pin selection" + default LCD_DCPIN_I2S0_LRCK + +config LCD_DCPIN_UART2_TX + bool "UART2_TX (D01) PIN" + +config LCD_DCPIN_UART2_RX + bool "UART2_RX (D00) PIN" + +config LCD_DCPIN_UART2_RTS + bool "UART2_RTS (D28) PIN" + +config LCD_DCPIN_UART2_CTS + bool "UART2_CTS (D27) PIN" + +config LCD_DCPIN_I2S0_BCK + bool "I2S0_BCK (D26) PIN" + +config LCD_DCPIN_I2S0_LRCK + bool "I2S0_LRCK (D25) PIN" + +config LCD_DCPIN_SEN_IRQ_IN + bool "SEN_IRQ_IN (D22) PIN" + +config LCD_DCPIN_EMMC_DATA3 + bool "EMMC_DATA3 (D21) PIN" + +config LCD_DCPIN_EMMC_DATA2 + bool "EMMC_DATA2 (D20) PIN" + +config LCD_DCPIN_I2S0_DATA_IN + bool "I2S0_DATA_IN (D19) PIN" + +config LCD_DCPIN_I2S0_DATA_OUT + bool "I2S0_DATA_OUT (D18) PIN" + +config LCD_DCPIN_I2C0_SCL + bool "I2C0_SCL (D15) PIN" + +config LCD_DCPIN_I2C0_SDA + bool "I2C0_SDA (D14) PIN" + +endchoice + +endif + +if LCD_ON_EXTENSION_BOARD + +choice + prompt "LCD ILI934x RST Pin selection" + default LCD_RSTPIN_SPI2_MISO + +config LCD_RSTPIN_I2C0_SCL_E + bool "I2C0_SCL (D15) PIN" + +config LCD_RSTPIN_I2C0_SDA_E + bool "I2C0_SDA (D14) PIN" + +config LCD_RSTPIN_PWM2 + bool "PWM2 (D09) PIN" + +config LCD_RSTPIN_SPI2_MISO + bool "SPI2_MISO (D08) PIN" + +config LCD_RSTPIN_SPI3_CS1_X + bool "SPI3_CS1_X (D07) PIN" + +config LCD_RSTPIN_PWM0 + bool "PWM0 (D06) PIN" + +config LCD_RSTPIN_PWM1 + bool "PWM1 (D05) PIN" + +config LCD_RSTPIN_SPI2_MOSI + bool "SPI2_MOSI (D04) PIN" + +config LCD_RSTPIN_PWM3 + bool "PWM3 (D03) PIN" + +config LCD_RSTPIN_HIF_IRQ_OUT + bool "HIF_IRQ_OUT (D02) PIN" + +config LCD_RSTPIN_UART2_TX_E + bool "UART2_TX (D01) PIN" + +config LCD_RSTPIN_UART2_RX_E + bool "UART2_RX (D00) PIN" + +endchoice + +choice + prompt "LCD ILI934x DC Pin selection" + default LCD_DCPIN_PWM2 + +config LCD_DCPIN_I2C0_SCL_E + bool "I2C0_SCL (D15) PIN" + +config LCD_DCPIN_I2C0_SDA_E + bool "I2C0_SDA (D14) PIN" + +config LCD_DCPIN_PWM2 + bool "PWM2 (D09) PIN" + +config LCD_DCPIN_SPI2_MISO + bool "SPI2_MISO (D08) PIN" + +config LCD_DCPIN_SPI3_CS1_X + bool "SPI3_CS1_X (D07) PIN" + +config LCD_DCPIN_PWM0 + bool "PWM0 (D06) PIN" + +config LCD_DCPIN_PWM1 + bool "PWM1 (D05) PIN" + +config LCD_DCPIN_SPI2_MOSI + bool "SPI2_MOSI (D04) PIN" + +config LCD_DCPIN_PWM3 + bool "PWM3 (D03) PIN" + +config LCD_DCPIN_HIF_IRQ_OUT + bool "HIF_IRQ_OUT (D02) PIN" + +config LCD_DCPIN_UART2_TX_E + bool "UART2_TX (D01) PIN" + +config LCD_DCPIN_UART2_RX_E + bool "UART2_RX (D00) PIN" + +endchoice + +endif + endif choice diff --git a/boards/arm/cxd56xx/spresense/configs/rndis/defconfig b/boards/arm/cxd56xx/spresense/configs/rndis/defconfig index 00e277734d069..da2c6be2d7aa8 100644 --- a/boards/arm/cxd56xx/spresense/configs/rndis/defconfig +++ b/boards/arm/cxd56xx/spresense/configs/rndis/defconfig @@ -152,7 +152,6 @@ CONFIG_SYSTEM_NXPLAYER=y CONFIG_SYSTEM_NXRECORDER=y CONFIG_SYSTEM_PING=y CONFIG_TESTING_OSTEST=y -CONFIG_TESTING_OSTEST_FPUSIZE=64 CONFIG_UART1_SERIAL_CONSOLE=y CONFIG_USBDEV=y CONFIG_USBDEV_DMA=y diff --git a/boards/arm/cxd56xx/spresense/configs/rndis_smp/defconfig b/boards/arm/cxd56xx/spresense/configs/rndis_smp/defconfig index 903de5f57d991..80f3d2e3d91d0 100644 --- a/boards/arm/cxd56xx/spresense/configs/rndis_smp/defconfig +++ b/boards/arm/cxd56xx/spresense/configs/rndis_smp/defconfig @@ -157,7 +157,6 @@ CONFIG_SYSTEM_SYSTEM=y CONFIG_SYSTEM_TASKSET=y CONFIG_TESTING_GETPRIME=y CONFIG_TESTING_OSTEST=y -CONFIG_TESTING_OSTEST_FPUSIZE=64 CONFIG_TESTING_SMP=y CONFIG_UART1_SERIAL_CONSOLE=y CONFIG_USBDEV=y diff --git a/boards/arm/cxd56xx/spresense/configs/smp/defconfig b/boards/arm/cxd56xx/spresense/configs/smp/defconfig index bbf2211f22544..4209329e9eaaa 100644 --- a/boards/arm/cxd56xx/spresense/configs/smp/defconfig +++ b/boards/arm/cxd56xx/spresense/configs/smp/defconfig @@ -57,6 +57,5 @@ CONFIG_SYSTEM_NSH=y CONFIG_SYSTEM_SYSTEM=y CONFIG_SYSTEM_TASKSET=y CONFIG_TESTING_OSTEST=y -CONFIG_TESTING_OSTEST_FPUSIZE=64 CONFIG_TESTING_SMP=y CONFIG_UART1_SERIAL_CONSOLE=y diff --git a/boards/arm/cxd56xx/spresense/configs/wifi/defconfig b/boards/arm/cxd56xx/spresense/configs/wifi/defconfig index 13e23908577da..2fd37f87490a1 100644 --- a/boards/arm/cxd56xx/spresense/configs/wifi/defconfig +++ b/boards/arm/cxd56xx/spresense/configs/wifi/defconfig @@ -159,7 +159,6 @@ CONFIG_SYSTEM_NXRECORDER=y CONFIG_SYSTEM_USBMSC=y CONFIG_TESTING_GETPRIME=y CONFIG_TESTING_OSTEST=y -CONFIG_TESTING_OSTEST_FPUSIZE=64 CONFIG_UART1_SERIAL_CONSOLE=y CONFIG_USBDEV=y CONFIG_USBDEV_DMA=y diff --git a/boards/arm/cxd56xx/spresense/configs/wifi_smp/defconfig b/boards/arm/cxd56xx/spresense/configs/wifi_smp/defconfig index 0151beabf2892..69f73e0a2a353 100644 --- a/boards/arm/cxd56xx/spresense/configs/wifi_smp/defconfig +++ b/boards/arm/cxd56xx/spresense/configs/wifi_smp/defconfig @@ -167,7 +167,6 @@ CONFIG_SYSTEM_TASKSET=y CONFIG_SYSTEM_USBMSC=y CONFIG_TESTING_GETPRIME=y CONFIG_TESTING_OSTEST=y -CONFIG_TESTING_OSTEST_FPUSIZE=64 CONFIG_TESTING_SMP=y CONFIG_UART1_SERIAL_CONSOLE=y CONFIG_USBDEV=y diff --git a/boards/arm/cxd56xx/spresense/include/board.h b/boards/arm/cxd56xx/spresense/include/board.h index 029ac60671438..fa720ca65c32f 100644 --- a/boards/arm/cxd56xx/spresense/include/board.h +++ b/boards/arm/cxd56xx/spresense/include/board.h @@ -30,6 +30,8 @@ #include #include +#include "board_lcdpins.h" + #include "cxd56_clock.h" #include "cxd56_power.h" #include "cxd56_flash.h" @@ -59,6 +61,7 @@ #include "cxd56_kx022.h" #include "cxd56_lt1pa01.h" #include "cxd56_rpr0521rs.h" +#include "cxd56_scd41.h" #include "cxd56_sensors.h" #include "cxd56_isx012.h" @@ -212,9 +215,6 @@ enum board_power_device #if defined(CONFIG_LCD_ON_MAIN_BOARD) /* Display connected to main board. */ -#define DISPLAY_RST PIN_I2S0_BCK -#define DISPLAY_DC PIN_I2S0_LRCK - #define DISPLAY_SPI 5 #define DISPLAY_DMA_TXCH (4) @@ -226,9 +226,6 @@ enum board_power_device #else /* Display is connected through extension board. */ -#define DISPLAY_RST PIN_SPI2_MISO -#define DISPLAY_DC PIN_PWM2 - #define DISPLAY_SPI 4 #define DISPLAY_DMA_TXCH (2) @@ -240,6 +237,9 @@ enum board_power_device #endif +#define DISPLAY_RST ILI934X_RST_PIN +#define DISPLAY_DC ILI934X_DC_PIN + /* Sensor device bus definitions ********************************************/ #define SENSOR_I2C 0 @@ -261,6 +261,10 @@ enum board_power_device #define BOARDIOC_USBDEV_SETNOTIFYSIG (BOARDIOC_USER+0x0001) +/* Set callback function pointer for notify SDCard state change *************/ + +#define BOARDIOC_SDCARD_SETNOTIFYCB (BOARDIOC_USER+0x0002) + /* Altair modem device pin definitions **************************************/ #define ALTMDM_SLAVE_REQ PIN_SPI2_SCK diff --git a/boards/arm/cxd56xx/spresense/include/board_lcdpins.h b/boards/arm/cxd56xx/spresense/include/board_lcdpins.h new file mode 100644 index 0000000000000..f17d394fe2320 --- /dev/null +++ b/boards/arm/cxd56xx/spresense/include/board_lcdpins.h @@ -0,0 +1,146 @@ +/**************************************************************************** + * boards/arm/cxd56xx/spresense/include/board_lcdpins.h + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +#ifndef __BOARDS_ARM_CXD56XX_SPRESENSE_INCLUDE_BOARD_LCDPINS_H +#define __BOARDS_ARM_CXD56XX_SPRESENSE_INCLUDE_BOARD_LCDPINS_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/* ILI934X RST pin definition */ + +#if defined(CONFIG_LCD_RSTPIN_UART2_TX) \ + || defined(CONFIG_LCD_RSTPIN_UART2_TX_E) +# define ILI934X_RST_PIN PIN_UART2_TXD +#elif defined(CONFIG_LCD_RSTPIN_UART2_RX) \ + || defined(CONFIG_LCD_RSTPIN_UART2_RX_E) +# define ILI934X_RST_PIN PIN_UART2_RXD +#elif defined(CONFIG_LCD_RSTPIN_UART2_RTS) +# define ILI934X_RST_PIN PIN_UART2_RTS +#elif defined(CONFIG_LCD_RSTPIN_UART2_CTS) +# define ILI934X_RST_PIN PIN_UART2_CTS +#elif defined(CONFIG_LCD_RSTPIN_I2S0_BCK) +# define ILI934X_RST_PIN PIN_I2S0_BCK +#elif defined(CONFIG_LCD_RSTPIN_I2S0_LRCK) +# define ILI934X_RST_PIN PIN_I2S0_LRCK +#elif defined(CONFIG_LCD_RSTPIN_SEN_IRQ_IN) +# define ILI934X_RST_PIN PIN_SEN_IRQ_IN +#elif defined(CONFIG_LCD_RSTPIN_EMMC_DATA3) +# define ILI934X_RST_PIN PIN_EMMC_DATA3 +#elif defined(CONFIG_LCD_RSTPIN_EMMC_DATA2) +# define ILI934X_RST_PIN PIN_EMMC_DATA2 +#elif defined(CONFIG_LCD_RSTPIN_I2S0_DATA_IN) +# define ILI934X_RST_PIN PIN_I2S0_DATA_IN +#elif defined(CONFIG_LCD_RSTPIN_I2S0_DATA_OUT) +# define ILI934X_RST_PIN PIN_I2S0_DATA_OUT +#elif defined(CONFIG_LCD_RSTPIN_I2C0_SCL) \ + || defined(CONFIG_LCD_RSTPIN_I2C0_SCL_E) +# define ILI934X_RST_PIN PIN_I2C0_BCK +#elif defined(CONFIG_LCD_RSTPIN_I2C0_SDA) \ + || defined(CONFIG_LCD_RSTPIN_I2C0_SDA_E) +# define ILI934X_RST_PIN PIN_I2C0_BDT +#elif defined(CONFIG_LCD_RSTPIN_PWM2) +# define ILI934X_RST_PIN PIN_PWM2 +#elif defined(CONFIG_LCD_RSTPIN_SPI2_MISO) +# define ILI934X_RST_PIN PIN_SPI2_MISO +#elif defined(CONFIG_LCD_RSTPIN_SPI3_CS1_X) +# define ILI934X_RST_PIN PIN_SPI3_CS1_X +#elif defined(CONFIG_LCD_RSTPIN_PWM0) +# define ILI934X_RST_PIN PIN_PWM0 +#elif defined(CONFIG_LCD_RSTPIN_PWM1) +# define ILI934X_RST_PIN PIN_PWM1 +#elif defined(CONFIG_LCD_RSTPIN_SPI2_MOSI) +# define ILI934X_RST_PIN PIN_SPI2_MOSI +#elif defined(CONFIG_LCD_RSTPIN_PWM3) +# define ILI934X_RST_PIN PIN_PWM3 +#elif defined(CONFIG_LCD_RSTPIN_HIF_IRQ_OUT) +# define ILI934X_RST_PIN PIN_HIF_IRQ_OUT +#endif + +/* ILI934X DC pin definition */ + +#if defined(CONFIG_LCD_DCPIN_UART2_TX) \ + || defined(CONFIG_LCD_DCPIN_UART2_TX_E) +# define ILI934X_DC_PIN PIN_UART2_TXD +#elif defined(CONFIG_LCD_DCPIN_UART2_RX) \ + || defined(CONFIG_LCD_DCPIN_UART2_RX_E) +# define ILI934X_DC_PIN PIN_UART2_RXD +#elif defined(CONFIG_LCD_DCPIN_UART2_RTS) +# define ILI934X_DC_PIN PIN_UART2_RTS +#elif defined(CONFIG_LCD_DCPIN_UART2_CTS) +# define ILI934X_DC_PIN PIN_UART2_CTS +#elif defined(CONFIG_LCD_DCPIN_I2S0_BCK) +# define ILI934X_DC_PIN PIN_I2S0_BCK +#elif defined(CONFIG_LCD_DCPIN_I2S0_LRCK) +# define ILI934X_DC_PIN PIN_I2S0_LRCK +#elif defined(CONFIG_LCD_DCPIN_SEN_IRQ_IN) +# define ILI934X_DC_PIN PIN_SEN_IRQ_IN +#elif defined(CONFIG_LCD_DCPIN_EMMC_DATA3) +# define ILI934X_DC_PIN PIN_EMMC_DATA3 +#elif defined(CONFIG_LCD_DCPIN_EMMC_DATA2) +# define ILI934X_DC_PIN PIN_EMMC_DATA2 +#elif defined(CONFIG_LCD_DCPIN_I2S0_DATA_IN) +# define ILI934X_DC_PIN PIN_I2S0_DATA_IN +#elif defined(CONFIG_LCD_DCPIN_I2S0_DATA_OUT) +# define ILI934X_DC_PIN PIN_I2S0_DATA_OUT +#elif defined(CONFIG_LCD_DCPIN_I2C0_SCL) \ + || defined(CONFIG_LCD_DCPIN_I2C0_SCL_E) +# define ILI934X_DC_PIN PIN_I2C0_BCK +#elif defined(CONFIG_LCD_DCPIN_I2C0_SDA) \ + || defined(CONFIG_LCD_DCPIN_I2C0_SDA_E) +# define ILI934X_DC_PIN PIN_I2C0_BDT +#elif defined(CONFIG_LCD_DCPIN_PWM2) +# define ILI934X_DC_PIN PIN_PWM2 +#elif defined(CONFIG_LCD_DCPIN_SPI2_MISO) +# define ILI934X_DC_PIN PIN_SPI2_MISO +#elif defined(CONFIG_LCD_DCPIN_SPI3_CS1_X) +# define ILI934X_DC_PIN PIN_SPI3_CS1_X +#elif defined(CONFIG_LCD_DCPIN_PWM0) +# define ILI934X_DC_PIN PIN_PWM0 +#elif defined(CONFIG_LCD_DCPIN_PWM1) +# define ILI934X_DC_PIN PIN_PWM1 +#elif defined(CONFIG_LCD_DCPIN_SPI2_MOSI) +# define ILI934X_DC_PIN PIN_SPI2_MOSI +#elif defined(CONFIG_LCD_DCPIN_PWM3) +# define ILI934X_DC_PIN PIN_PWM3 +#elif defined(CONFIG_LCD_DCPIN_HIF_IRQ_OUT) +# define ILI934X_DC_PIN PIN_HIF_IRQ_OUT +#endif + +#if !defined(CONFIG_LCD) + +# if !defined(ILI934X_RST_PIN) +# define ILI934X_RST_PIN 0 +# endif + +# if !defined(ILI934X_DC_PIN) +# define ILI934X_DC_PIN 0 +# endif + +#endif + +#endif /* __BOARDS_ARM_CXD56XX_SPRESENSE_INCLUDE_BOARD_LCDPINS_H */ diff --git a/arch/arm/src/armv7-r/fpu.h b/boards/arm/cxd56xx/spresense/include/cxd56_scd41.h similarity index 78% rename from arch/arm/src/armv7-r/fpu.h rename to boards/arm/cxd56xx/spresense/include/cxd56_scd41.h index a89380a9d24ec..4a7243a12d5b4 100644 --- a/arch/arm/src/armv7-r/fpu.h +++ b/boards/arm/cxd56xx/spresense/include/cxd56_scd41.h @@ -1,5 +1,5 @@ /**************************************************************************** - * arch/arm/src/armv7-r/fpu.h + * boards/arm/cxd56xx/spresense/include/cxd56_scd41.h * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with @@ -18,8 +18,8 @@ * ****************************************************************************/ -#ifndef __ARCH_ARM_SRC_ARMV7_R_FPU_H -#define __ARCH_ARM_SRC_ARMV7_R_FPU_H +#ifndef __BOARDS_ARM_CXD56XX_SPRESENSE_INCLUDE_CXD56_SCD41_H +#define __BOARDS_ARM_CXD56XX_SPRESENSE_INCLUDE_CXD56_SCD41_H /**************************************************************************** * Included Files @@ -28,23 +28,17 @@ #include /**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -/**************************************************************************** - * Inline Functions + * Public Types ****************************************************************************/ #ifndef __ASSEMBLY__ -#endif /* __ASSEMBLY__ */ - /**************************************************************************** * Public Data ****************************************************************************/ -#ifndef __ASSEMBLY__ -#ifdef __cplusplus +#undef EXTERN +#if defined(__cplusplus) #define EXTERN extern "C" extern "C" { @@ -57,21 +51,21 @@ extern "C" ****************************************************************************/ /**************************************************************************** - * Name: arm_fpuconfig + * Name: board_scd41_initialize * * Description: - * Configure the FPU. Enables access to CP10 and CP11 + * Initialize SCD41 i2c driver and register the SCD41 device. * ****************************************************************************/ -#ifdef CONFIG_ARCH_FPU -void arm_fpuconfig(void); +#if defined (CONFIG_SENSORS_SCD41) +int board_scd41_initialize(FAR const char *devpath, int bus); #endif #undef EXTERN -#ifdef __cplusplus +#if defined(__cplusplus) } #endif -#endif /* __ASSEMBLY__ */ -#endif /* __ARCH_ARM_SRC_ARMV7_R_FPU_H */ +#endif /* __ASSEMBLY__ */ +#endif /* __BOARDS_ARM_CXD56XX_SPRESENSE_INCLUDE_CXD56_SCD41_H */ diff --git a/boards/arm/cxd56xx/spresense/include/cxd56_sdcard.h b/boards/arm/cxd56xx/spresense/include/cxd56_sdcard.h index 1553af5e90da8..0b8a3f4ab7f08 100644 --- a/boards/arm/cxd56xx/spresense/include/cxd56_sdcard.h +++ b/boards/arm/cxd56xx/spresense/include/cxd56_sdcard.h @@ -26,6 +26,7 @@ ****************************************************************************/ #include +#include /**************************************************************************** * Public Types @@ -130,6 +131,18 @@ void board_sdcard_set_high_voltage(void); void board_sdcard_set_low_voltage(void); +/**************************************************************************** + * Name: board_sdcard_set_state_cb + * + * Description: + * Register callback function to notify state change of card slot. + * This function is called by board_ioctl() + * as BOARDIOC_SDCARD_SETNOTIFYCB command. + * + ****************************************************************************/ + +int board_sdcard_set_state_cb(uintptr_t cb); + #undef EXTERN #if defined(__cplusplus) } diff --git a/boards/arm/cxd56xx/spresense/scripts/Make.defs b/boards/arm/cxd56xx/spresense/scripts/Make.defs index 48b963c06f033..7552f26aaa152 100644 --- a/boards/arm/cxd56xx/spresense/scripts/Make.defs +++ b/boards/arm/cxd56xx/spresense/scripts/Make.defs @@ -36,16 +36,7 @@ ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT) MKNXFLAT = mknxflat LDNXFLAT = ldnxflat -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - -ARCHCFLAGS = -fno-common -mabi=aapcs -ffunction-sections -fdata-sections -ARCHCXXFLAGS = -fno-common -fno-exceptions -fno-rtti -std=c++11 +ARCHCFLAGS += -mabi=aapcs ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 @@ -74,19 +65,10 @@ CELFFLAGS = $(CFLAGS) CXXELFFLAGS = $(CXXFLAGS) LDELFFLAGS = -r -e main -LDELFFLAGS += -T $(call CONVERT_PATH,$(BOARD_DIR)$(DELIM)scripts$(DELIM)gnu-elf.ld) - -LDFLAGS += --gc-sections - -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - CFLAGS += -gdwarf-3 - CXXFLAGS += -gdwarf-3 - LDFLAGS += -g -endif +LDELFFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)/binfmt/libelf/gnu-elf.ld) # Output map file with cross reference table -LDFLAGS += -Map=$(call CONVERT_PATH,$(TOPDIR)/nuttx.map) --cref ifneq ($(CONFIG_ASMP_MEMSIZE),) LDFLAGS += --defsym=__reserved_ramsize=$(CONFIG_ASMP_MEMSIZE) endif diff --git a/boards/arm/cxd56xx/spresense/scripts/gnu-elf.ld b/boards/arm/cxd56xx/spresense/scripts/gnu-elf.ld deleted file mode 100644 index eae9ac4aff09f..0000000000000 --- a/boards/arm/cxd56xx/spresense/scripts/gnu-elf.ld +++ /dev/null @@ -1,125 +0,0 @@ -/**************************************************************************** - * boards/arm/cxd56xx/spresense/scripts/gnu-elf.ld - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. The - * ASF licenses this file to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance with the - * License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - ****************************************************************************/ - -SECTIONS -{ - .text 0x00000000 : - { - _stext = . ; - *(.text) - *(.text.*) - *(.gnu.warning) - *(.stub) - *(.glue_7) - *(.glue_7t) - *(.jcr) - - /* C++ support: The .init and .fini sections contain specific logic - * to manage static constructors and destructors. - */ - - *(.gnu.linkonce.t.*) - *(.init) /* Old ABI */ - *(.fini) /* Old ABI */ - _etext = . ; - } - - .ARM.extab : - { - *(.ARM.extab*) - } - - .ARM.exidx : - { - *(.ARM.exidx*) - } - - .rodata : - { - _srodata = . ; - *(.rodata) - *(.rodata1) - *(.rodata.*) - *(.gnu.linkonce.r*) - _erodata = . ; - } - - .data : - { - _sdata = . ; - *(.data) - *(.data1) - *(.data.*) - *(.gnu.linkonce.d*) - . = ALIGN(4); - _edata = . ; - } - - /* C++ support. For each global and static local C++ object, - * GCC creates a small subroutine to construct the object. Pointers - * to these routines (not the routines themselves) are stored as - * simple, linear arrays in the .ctors section of the object file. - * Similarly, pointers to global/static destructor routines are - * stored in .dtors. - */ - - .ctors : - { - _sctors = . ; - *(.ctors) /* Old ABI: Unallocated */ - *(.init_array) /* New ABI: Allocated */ - _edtors = . ; - } - - .dtors : - { - _sdtors = . ; - *(.dtors) /* Old ABI: Unallocated */ - *(.fini_array) /* New ABI: Allocated */ - _edtors = . ; - } - - .bss : - { - _sbss = . ; - *(.bss) - *(.bss.*) - *(.sbss) - *(.sbss.*) - *(.gnu.linkonce.b*) - *(COMMON) - _ebss = . ; - } - - /* Stabs debugging sections. */ - - .stab 0 : { *(.stab) } - .stabstr 0 : { *(.stabstr) } - .stab.excl 0 : { *(.stab.excl) } - .stab.exclstr 0 : { *(.stab.exclstr) } - .stab.index 0 : { *(.stab.index) } - .stab.indexstr 0 : { *(.stab.indexstr) } - .comment 0 : { *(.comment) } - .debug_abbrev 0 : { *(.debug_abbrev) } - .debug_info 0 : { *(.debug_info) } - .debug_line 0 : { *(.debug_line) } - .debug_pubnames 0 : { *(.debug_pubnames) } - .debug_aranges 0 : { *(.debug_aranges) } -} diff --git a/boards/arm/cxd56xx/spresense/src/Make.defs b/boards/arm/cxd56xx/spresense/src/Make.defs index 1bb84d5462b3d..ff4b0f4888638 100644 --- a/boards/arm/cxd56xx/spresense/src/Make.defs +++ b/boards/arm/cxd56xx/spresense/src/Make.defs @@ -31,10 +31,6 @@ ifeq ($(CONFIG_BOARDCTL_IOCTL),y) CSRCS += cxd56_ioctl.c endif -ifeq ($(CONFIG_ARCH_FPU),y) -CSRCS += cxd56_ostest.c -endif - ifeq ($(CONFIG_ARCH_LEDS),y) CSRCS += cxd56_leds.c else diff --git a/boards/arm/cxd56xx/spresense/src/cxd56_appinit.c b/boards/arm/cxd56xx/spresense/src/cxd56_appinit.c index eb0f656bdff34..d0b88ba21b3f2 100644 --- a/boards/arm/cxd56xx/spresense/src/cxd56_appinit.c +++ b/boards/arm/cxd56xx/spresense/src/cxd56_appinit.c @@ -23,6 +23,7 @@ ****************************************************************************/ #include +#include #include @@ -93,7 +94,7 @@ int board_app_initialize(uintptr_t arg) ****************************************************************************/ #ifdef CONFIG_BOARD_LATE_INITIALIZE -void board_late_initialize(void) +void weak_function board_late_initialize(void) { /* Perform board bring-up here instead of from the * board_app_initialize(). diff --git a/boards/arm/cxd56xx/spresense/src/cxd56_ioctl.c b/boards/arm/cxd56xx/spresense/src/cxd56_ioctl.c index 025ff6b67caac..b174d37aa242d 100644 --- a/boards/arm/cxd56xx/spresense/src/cxd56_ioctl.c +++ b/boards/arm/cxd56xx/spresense/src/cxd56_ioctl.c @@ -34,6 +34,7 @@ #include #include "cxd56_usbdev.h" +#include "arch/board/cxd56_sdcard.h" #ifdef CONFIG_BOARDCTL_IOCTL @@ -91,6 +92,22 @@ int board_ioctl(unsigned int cmd, uintptr_t arg) } break; #endif + +#ifdef CONFIG_CXD56_SDIO + /* CMD: BOARDIOC_SDCARD_SETNOTIFYCB + * DESCRIPTION: Set a callback function pointer to SDCard driver + * to notify when card status is changed. + * ARG: Callback function. + * CONFIGURATION: CONFIG_BOARDCTL & CONFIG_CXD56_SDIO + * DEPENDENCIES: Board logic must provide board_app_initialization + */ + + case BOARDIOC_SDCARD_SETNOTIFYCB: + { + ret = board_sdcard_set_state_cb(arg); + } + break; +#endif default: break; } diff --git a/boards/arm/cxd56xx/spresense/src/cxd56_ostest.c b/boards/arm/cxd56xx/spresense/src/cxd56_ostest.c deleted file mode 100644 index a0c7934498ffb..0000000000000 --- a/boards/arm/cxd56xx/spresense/src/cxd56_ostest.c +++ /dev/null @@ -1,97 +0,0 @@ -/**************************************************************************** - * boards/arm/cxd56xx/spresense/src/cxd56_ostest.c - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. The - * ASF licenses this file to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance with the - * License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - ****************************************************************************/ - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include - -#include -#include -#include -#include - -#include -#include - -#include "arm_internal.h" - -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -/* Configuration ************************************************************/ - -#undef HAVE_FPU -#if defined(CONFIG_ARCH_FPU) && defined(CONFIG_TESTING_OSTEST_FPUSIZE) && \ - defined(CONFIG_SCHED_WAITPID) -# define HAVE_FPU 1 -#endif - -#ifdef HAVE_FPU - -#if CONFIG_TESTING_OSTEST_FPUSIZE != (4*SW_FPU_REGS) -# error "CONFIG_TESTING_OSTEST_FPUSIZE has the wrong size" -#endif - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -static uint32_t g_saveregs[XCPTCONTEXT_REGS]; - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/* Given an array of size CONFIG_TESTING_OSTEST_FPUSIZE, this function will - * return the current FPU registers. - */ - -void arch_getfpu(FAR uint32_t *fpusave) -{ - irqstate_t flags; - - /* Take a snapshot of the thread context right now */ - - flags = enter_critical_section(); - arm_saveusercontext(g_saveregs); - - /* Return only the floating register values */ - - memcpy(fpusave, &g_saveregs[REG_S0], (4*SW_FPU_REGS)); - leave_critical_section(flags); -} - -/* Given two arrays of size CONFIG_TESTING_OSTEST_FPUSIZE this function - * will compare them and return true if they are identical. - */ - -bool arch_cmpfpu(FAR const uint32_t *fpusave1, FAR const uint32_t *fpusave2) -{ - return memcmp(fpusave1, fpusave2, (4*SW_FPU_REGS)) == 0; -} - -#endif /* HAVE_FPU */ diff --git a/boards/arm/cxd56xx/spresense/src/cxd56_sdcard.c b/boards/arm/cxd56xx/spresense/src/cxd56_sdcard.c index bfb88697a0159..7f6c75fe986fb 100644 --- a/boards/arm/cxd56xx/spresense/src/cxd56_sdcard.c +++ b/boards/arm/cxd56xx/spresense/src/cxd56_sdcard.c @@ -70,6 +70,7 @@ struct cxd56_sdhci_state_s struct sdio_dev_s *sdhci; /* R/W device handle */ bool initialized; /* TRUE: SDHCI block driver is initialized */ bool inserted; /* TRUE: card is inserted */ + void (*cb)(bool); /* Callback function pointer to application */ }; /**************************************************************************** @@ -165,6 +166,13 @@ static void board_sdcard_enable(FAR void *arg) } g_sdhci.initialized = true; + + /* Callback to application to notice card is inserted */ + + if (g_sdhci.cb != NULL) + { + g_sdhci.cb(true); + } } release_frequency_lock: @@ -203,6 +211,13 @@ static void board_sdcard_disable(FAR void *arg) cxd56_sdhci_finalize(0); g_sdhci.initialized = false; + + /* Callback to application to notice card is ejected */ + + if (g_sdhci.cb != NULL) + { + g_sdhci.cb(false); + } } } @@ -515,3 +530,24 @@ void board_sdcard_set_high_voltage(void) void board_sdcard_set_low_voltage(void) { } + +/**************************************************************************** + * Name: board_sdcard_set_state_cb + * + * Description: + * Register callback function to notify state change of card slot. + * This function is called by board_ioctl() + * as BOARDIOC_SDCARD_SETNOTIFYCB command. + * + ****************************************************************************/ + +int board_sdcard_set_state_cb(uintptr_t cb) +{ + if (g_sdhci.cb != NULL && cb != 0) + { + return -EBUSY; + } + + g_sdhci.cb = (void (*)(bool))cb; + return OK; +} diff --git a/boards/arm/dm320/ntosd-dm320/README.txt b/boards/arm/dm320/ntosd-dm320/README.txt index 1ac832def90b3..f6ce8284a3b52 100644 --- a/boards/arm/dm320/ntosd-dm320/README.txt +++ b/boards/arm/dm320/ntosd-dm320/README.txt @@ -59,7 +59,7 @@ GNU Toolchain Options a different toolchain, you simply need to modify the configuration. As an example: - CONFIG_ARM_TOOLCHAIN_GNU_EABIL : Generic arm-none-eabi toolchain + CONFIG_ARM_TOOLCHAIN_GNU_EABI : Generic arm-none-eabi toolchain Generic arm-none-eabi GNU Toolchain ----------------------------------- @@ -239,7 +239,7 @@ Common Configuration Notes Linux. This is easily reconfigured: CONFIG_HOST_LINUX=y - CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIL=y + CONFIG_ARMV7M_TOOLCHAIN_GNU_EABI=y Configuration Sub-Directories ----------------------------- diff --git a/boards/arm/dm320/ntosd-dm320/scripts/Make.defs b/boards/arm/dm320/ntosd-dm320/scripts/Make.defs index 2d1802dd062a3..cf58b89aa0499 100644 --- a/boards/arm/dm320/ntosd-dm320/scripts/Make.defs +++ b/boards/arm/dm320/ntosd-dm320/scripts/Make.defs @@ -38,22 +38,12 @@ else OLDGCC = n endif -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - ifeq ($(OLDGCC),n) ARCHCPUFLAGS = -mtune=arm9tdmi -march=armv5te -mfloat-abi=soft else ARCHCPUFLAGS = -mapcs-32 -mtune=arm9tdmi -march=armv5te -msoft-float endif -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef @@ -72,7 +62,3 @@ NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) \ -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-gotoff.ld \ -no-check-sections LDNXFLATFLAGS = -e main -s 2048 - -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - LDFLAGS += -g -endif diff --git a/boards/arm/efm32/efm32-g8xx-stk/README.txt b/boards/arm/efm32/efm32-g8xx-stk/README.txt index e27951c5637ba..f28a592e7950f 100644 --- a/boards/arm/efm32/efm32-g8xx-stk/README.txt +++ b/boards/arm/efm32/efm32-g8xx-stk/README.txt @@ -262,4 +262,4 @@ CONFIGURATIONS CONFIG_HOST_WINDOWS=y : Builds under Windows CONFIG_WINDOWS_CYGWIN=y : Using Cygwin - CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIW=y : GNU EABI toolchain for Windows + CONFIG_ARMV7M_TOOLCHAIN_GNU_EABI=y : GNU EABI toolchain for Windows diff --git a/boards/arm/efm32/efm32-g8xx-stk/scripts/Make.defs b/boards/arm/efm32/efm32-g8xx-stk/scripts/Make.defs index b33c4a2b847a6..4f0d91a70ccf6 100644 --- a/boards/arm/efm32/efm32-g8xx-stk/scripts/Make.defs +++ b/boards/arm/efm32/efm32-g8xx-stk/scripts/Make.defs @@ -23,19 +23,8 @@ include $(TOPDIR)/arch/arm/src/armv7-m/Toolchain.defs include $(TOPDIR)/tools/Config.mk LDSCRIPT = efm32-g8xx-stk.ld - ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT) -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new -fno-rtti ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 @@ -50,7 +39,3 @@ AFLAGS := $(CFLAGS) -D__ASSEMBLY__ NXFLATLDFLAGS1 = -r -d -warn-common NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-pcrel.ld -no-check-sections LDNXFLATFLAGS = -e main -s 2048 - -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - LDFLAGS += -g -endif diff --git a/boards/arm/efm32/efm32gg-stk3700/README.txt b/boards/arm/efm32/efm32gg-stk3700/README.txt index 29aed94c84f2f..a3af5ef44075e 100644 --- a/boards/arm/efm32/efm32gg-stk3700/README.txt +++ b/boards/arm/efm32/efm32gg-stk3700/README.txt @@ -214,4 +214,4 @@ Configurations CONFIG_HOST_WINDOWS=y : Builds under Windows CONFIG_WINDOWS_CYGWIN=y : Using Cygwin - CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIW=y : GNU EABI toolchain for Windows + CONFIG_ARMV7M_TOOLCHAIN_GNU_EABI=y : GNU EABI toolchain for Windows diff --git a/boards/arm/efm32/efm32gg-stk3700/scripts/Make.defs b/boards/arm/efm32/efm32gg-stk3700/scripts/Make.defs index 25f1556f7ab76..0e3bf3571a64c 100644 --- a/boards/arm/efm32/efm32gg-stk3700/scripts/Make.defs +++ b/boards/arm/efm32/efm32gg-stk3700/scripts/Make.defs @@ -23,19 +23,8 @@ include $(TOPDIR)/arch/arm/src/armv7-m/Toolchain.defs include $(TOPDIR)/tools/Config.mk LDSCRIPT = ld.script - ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT) -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new -fno-rtti ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 @@ -50,7 +39,3 @@ AFLAGS := $(CFLAGS) -D__ASSEMBLY__ NXFLATLDFLAGS1 = -r -d -warn-common NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-pcrel.ld -no-check-sections LDNXFLATFLAGS = -e main -s 2048 - -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - LDFLAGS += -g -endif diff --git a/boards/arm/efm32/olimex-efm32g880f128-stk/README.txt b/boards/arm/efm32/olimex-efm32g880f128-stk/README.txt index 09143771b1866..54df3df3badd5 100644 --- a/boards/arm/efm32/olimex-efm32g880f128-stk/README.txt +++ b/boards/arm/efm32/olimex-efm32g880f128-stk/README.txt @@ -162,5 +162,5 @@ Configurations CONFIG_HOST_WINDOWS=y : Builds under Windows CONFIG_WINDOWS_CYGWIN=y : Using Cygwin - CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIW=y : GNU EABI toolchain for Windows + CONFIG_ARMV7M_TOOLCHAIN_GNU_EABI=y : GNU EABI toolchain for Windows diff --git a/boards/arm/efm32/olimex-efm32g880f128-stk/scripts/Make.defs b/boards/arm/efm32/olimex-efm32g880f128-stk/scripts/Make.defs index 0fa7eda791408..dc0661d5d949c 100644 --- a/boards/arm/efm32/olimex-efm32g880f128-stk/scripts/Make.defs +++ b/boards/arm/efm32/olimex-efm32g880f128-stk/scripts/Make.defs @@ -23,19 +23,8 @@ include $(TOPDIR)/arch/arm/src/armv7-m/Toolchain.defs include $(TOPDIR)/tools/Config.mk LDSCRIPT = ld.script - ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT) -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new -fno-rtti ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 @@ -50,7 +39,3 @@ AFLAGS := $(CFLAGS) -D__ASSEMBLY__ NXFLATLDFLAGS1 = -r -d -warn-common NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-pcrel.ld -no-check-sections LDNXFLATFLAGS = -e main -s 2048 - -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - LDFLAGS += -g -endif diff --git a/boards/arm/eoss3/quickfeather/scripts/Make.defs b/boards/arm/eoss3/quickfeather/scripts/Make.defs index 60dace61bf06a..c906029873964 100644 --- a/boards/arm/eoss3/quickfeather/scripts/Make.defs +++ b/boards/arm/eoss3/quickfeather/scripts/Make.defs @@ -23,29 +23,18 @@ include $(TOPDIR)/tools/Config.mk include $(TOPDIR)/arch/arm/src/armv7-m/Toolchain.defs LDSCRIPT = ld.script - ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT) -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 -ifeq ($(CONFIG_ARMV7M_TOOLCHAIN_CLANGL),y) +ifeq ($(CONFIG_ARMV7M_TOOLCHAIN_CLANG),y) ARCHCFLAGS += -nostdlib -ffreestanding ARCHCXXFLAGS += -nostdlib -ffreestanding else ARCHCFLAGS += -funwind-tables - ARCHCXXFLAGS += -fno-rtti -funwind-tables + ARCHCXXFLAGS += -funwind-tables endif diff --git a/boards/arm/imx6/sabre-6quad/README.txt b/boards/arm/imx6/sabre-6quad/README.txt index f0e46812d49b7..0750903bdd7de 100644 --- a/boards/arm/imx6/sabre-6quad/README.txt +++ b/boards/arm/imx6/sabre-6quad/README.txt @@ -754,7 +754,7 @@ NOTES: CONFIG_WINDOWS_CYGWIN=y : Cywin under Windows System Type -> Toolchain: - CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIW=y : GNU ARM EABI toolchain + CONFIG_ARMV7M_TOOLCHAIN_GNU_EABI=y : GNU ARM EABI toolchain Configuration sub-directories ----------------------------- diff --git a/boards/arm/imx6/sabre-6quad/configs/libcxx/defconfig b/boards/arm/imx6/sabre-6quad/configs/libcxx/defconfig new file mode 100644 index 0000000000000..b080842b56e25 --- /dev/null +++ b/boards/arm/imx6/sabre-6quad/configs/libcxx/defconfig @@ -0,0 +1,68 @@ +# +# This file is autogenerated: PLEASE DO NOT EDIT IT. +# +# You can use "make menuconfig" to make any modifications to the installed .config file. +# You can then do "make savedefconfig" to generate a new defconfig file that includes your +# modifications. +# +# CONFIG_NSH_CMDOPT_HEXDUMP is not set +CONFIG_ARCH="arm" +CONFIG_ARCH_BOARD="sabre-6quad" +CONFIG_ARCH_BOARD_SABRE_6QUAD=y +CONFIG_ARCH_BUTTONS=y +CONFIG_ARCH_CHIP="imx6" +CONFIG_ARCH_CHIP_IMX6=y +CONFIG_ARCH_CHIP_IMX6_6QUAD=y +CONFIG_ARCH_INTERRUPTSTACK=2048 +CONFIG_ARCH_IRQBUTTONS=y +CONFIG_ARCH_LOWVECTORS=y +CONFIG_ARCH_SETJMP_H=y +CONFIG_ARCH_STACKDUMP=y +CONFIG_ARMV7A_ASSOCIATIVITY_16WAY=y +CONFIG_ARMV7A_L2CC_PL310=y +CONFIG_ARMV7A_WAYSIZE_64KB=y +CONFIG_BOARD_LOOPSPERMSEC=99369 +CONFIG_BOOT_RUNFROMSDRAM=y +CONFIG_BUILTIN=y +CONFIG_DEBUG_FULLOPT=y +CONFIG_DEBUG_SYMBOLS=y +CONFIG_DEV_ZERO=y +CONFIG_EXAMPLES_HELLO=y +CONFIG_EXAMPLES_HELLOXX=y +CONFIG_EXPERIMENTAL=y +CONFIG_FS_PROCFS=y +CONFIG_HAVE_CXX=y +CONFIG_IMX6_UART1=y +CONFIG_IMX_DDR_SIZE=1073741824 +CONFIG_INIT_ENTRYPOINT="nsh_main" +CONFIG_INTELHEX_BINARY=y +CONFIG_LIBCXX=y +CONFIG_LIBCXXABI=y +CONFIG_NSH_ARCHINIT=y +CONFIG_NSH_BUILTIN_APPS=y +CONFIG_NSH_FILEIOSIZE=512 +CONFIG_NSH_READLINE=y +CONFIG_PL310_LOCKDOWN_BY_LINE=y +CONFIG_PL310_LOCKDOWN_BY_MASTER=y +CONFIG_PREALLOC_TIMERS=4 +CONFIG_RAM_SIZE=1073741824 +CONFIG_RAM_START=0x10000000 +CONFIG_RAM_VSTART=0x10000000 +CONFIG_RAW_BINARY=y +CONFIG_READLINE_CMD_HISTORY=y +CONFIG_RR_INTERVAL=200 +CONFIG_SCHED_ATEXIT=y +CONFIG_SCHED_HPWORK=y +CONFIG_SCHED_HPWORKPRIORITY=192 +CONFIG_SCHED_WAITPID=y +CONFIG_STACK_COLORATION=y +CONFIG_START_DAY=2 +CONFIG_START_MONTH=5 +CONFIG_START_YEAR=2022 +CONFIG_SYMTAB_ORDEREDBYNAME=y +CONFIG_SYSTEM_NSH=y +CONFIG_TESTING_CXXTEST=y +CONFIG_TESTING_GETPRIME=y +CONFIG_TESTING_OSTEST=y +CONFIG_TESTING_OSTEST_FPUTESTDISABLE=y +CONFIG_UART1_SERIAL_CONSOLE=y diff --git a/boards/arm/imx6/sabre-6quad/scripts/Make.defs b/boards/arm/imx6/sabre-6quad/scripts/Make.defs index 66bf770c59956..c325d1aa92cf3 100644 --- a/boards/arm/imx6/sabre-6quad/scripts/Make.defs +++ b/boards/arm/imx6/sabre-6quad/scripts/Make.defs @@ -23,19 +23,8 @@ include $(TOPDIR)/tools/Config.mk include $(TOPDIR)/arch/arm/src/armv7-a/Toolchain.defs LDSCRIPT = dramboot.ld - ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT) -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - -ARCHCFLAGS = -fno-common -ffunction-sections -fdata-sections -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new -fno-rtti ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 @@ -59,10 +48,4 @@ CELFFLAGS = $(CFLAGS) -mlong-calls # --target1-abs CXXELFFLAGS = $(CXXFLAGS) -mlong-calls # --target1-abs LDELFFLAGS = -r -e main -LDELFFLAGS += -T $(call CONVERT_PATH,$(BOARD_DIR)$(DELIM)scripts$(DELIM)gnu-elf.ld) - -LDFLAGS += --gc-sections - -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - LDFLAGS += -g -endif +LDELFFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)/binfmt/libelf/gnu-elf.ld) diff --git a/boards/arm/imx6/sabre-6quad/scripts/dramboot.ld b/boards/arm/imx6/sabre-6quad/scripts/dramboot.ld index 334aacc04c4d5..fa6a730c9a2e0 100644 --- a/boards/arm/imx6/sabre-6quad/scripts/dramboot.ld +++ b/boards/arm/imx6/sabre-6quad/scripts/dramboot.ld @@ -60,7 +60,7 @@ SECTIONS .init_section : { _sinit = ABSOLUTE(.); - *(.init_array .init_array.*) + KEEP(*(.init_array .init_array.*)) _einit = ABSOLUTE(.); } > ddr3 diff --git a/boards/arm/imx6/sabre-6quad/scripts/gnu-elf.ld b/boards/arm/imx6/sabre-6quad/scripts/gnu-elf.ld deleted file mode 100644 index 47dbb028d102e..0000000000000 --- a/boards/arm/imx6/sabre-6quad/scripts/gnu-elf.ld +++ /dev/null @@ -1,125 +0,0 @@ -/**************************************************************************** - * boards/arm/imx6/sabre-6quad/scripts/gnu-elf.ld - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. The - * ASF licenses this file to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance with the - * License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - ****************************************************************************/ - -SECTIONS -{ - .text 0x00000000 : - { - _stext = . ; - *(.text) - *(.text.*) - *(.gnu.warning) - *(.stub) - *(.glue_7) - *(.glue_7t) - *(.jcr) - - /* C++ support: The .init and .fini sections contain specific logic - * to manage static constructors and destructors. - */ - - *(.gnu.linkonce.t.*) - *(.init) /* Old ABI */ - *(.fini) /* Old ABI */ - _etext = . ; - } - - .ARM.extab : - { - *(.ARM.extab*) - } - - .ARM.exidx : - { - *(.ARM.exidx*) - } - - .rodata : - { - _srodata = . ; - *(.rodata) - *(.rodata1) - *(.rodata.*) - *(.gnu.linkonce.r*) - _erodata = . ; - } - - .data : - { - _sdata = . ; - *(.data) - *(.data1) - *(.data.*) - *(.gnu.linkonce.d*) - . = ALIGN(4); - _edata = . ; - } - - /* C++ support. For each global and static local C++ object, - * GCC creates a small subroutine to construct the object. Pointers - * to these routines (not the routines themselves) are stored as - * simple, linear arrays in the .ctors section of the object file. - * Similarly, pointers to global/static destructor routines are - * stored in .dtors. - */ - - .ctors : - { - _sctors = . ; - *(.ctors) /* Old ABI: Unallocated */ - *(.init_array) /* New ABI: Allocated */ - _edtors = . ; - } - - .dtors : - { - _sdtors = . ; - *(.dtors) /* Old ABI: Unallocated */ - *(.fini_array) /* New ABI: Allocated */ - _edtors = . ; - } - - .bss : - { - _sbss = . ; - *(.bss) - *(.bss.*) - *(.sbss) - *(.sbss.*) - *(.gnu.linkonce.b*) - *(COMMON) - _ebss = . ; - } - - /* Stabs debugging sections. */ - - .stab 0 : { *(.stab) } - .stabstr 0 : { *(.stabstr) } - .stab.excl 0 : { *(.stab.excl) } - .stab.exclstr 0 : { *(.stab.exclstr) } - .stab.index 0 : { *(.stab.index) } - .stab.indexstr 0 : { *(.stab.indexstr) } - .comment 0 : { *(.comment) } - .debug_abbrev 0 : { *(.debug_abbrev) } - .debug_info 0 : { *(.debug_info) } - .debug_line 0 : { *(.debug_line) } - .debug_pubnames 0 : { *(.debug_pubnames) } - .debug_aranges 0 : { *(.debug_aranges) } -} diff --git a/boards/arm/imxrt/imxrt1020-evk/scripts/Make.defs b/boards/arm/imxrt/imxrt1020-evk/scripts/Make.defs index 927dfcdf53454..7cd2ea39cab89 100644 --- a/boards/arm/imxrt/imxrt1020-evk/scripts/Make.defs +++ b/boards/arm/imxrt/imxrt1020-evk/scripts/Make.defs @@ -30,17 +30,7 @@ endif ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT) -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -endif - -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new -fno-rtti -ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef -fno-strict-aliasing +ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 @@ -61,7 +51,3 @@ CMODULEFLAGS = $(CFLAGS) -mlong-calls # --target1-abs LDMODULEFLAGS = -r -e module_initialize LDMODULEFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)/libs/libc/modlib/gnu-elf.ld) - -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - LDFLAGS += -g -endif diff --git a/boards/arm/imxrt/imxrt1050-evk/configs/knsh/Make.defs b/boards/arm/imxrt/imxrt1050-evk/configs/knsh/Make.defs index 0e28b929e22b8..551315dbd08dc 100644 --- a/boards/arm/imxrt/imxrt1050-evk/configs/knsh/Make.defs +++ b/boards/arm/imxrt/imxrt1050-evk/configs/knsh/Make.defs @@ -28,17 +28,7 @@ LDSCRIPT2 = kernel-space.ld ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT1) ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT2) -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -endif - -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new -fno-rtti -ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef -fno-strict-aliasing +ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 @@ -59,7 +49,3 @@ CMODULEFLAGS = $(CFLAGS) -mlong-calls # --target1-abs LDMODULEFLAGS = -r -e module_initialize LDMODULEFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)/libs/libc/modlib/gnu-elf.ld) - -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - LDFLAGS += -g -endif diff --git a/boards/arm/imxrt/imxrt1050-evk/configs/knsh/defconfig b/boards/arm/imxrt/imxrt1050-evk/configs/knsh/defconfig index dc15959e0752f..386bc00b4a074 100644 --- a/boards/arm/imxrt/imxrt1050-evk/configs/knsh/defconfig +++ b/boards/arm/imxrt/imxrt1050-evk/configs/knsh/defconfig @@ -16,7 +16,6 @@ CONFIG_ARCH_STACKDUMP=y CONFIG_ARMV7M_DCACHE=y CONFIG_ARMV7M_DCACHE_WRITETHROUGH=y CONFIG_ARMV7M_ICACHE=y -CONFIG_ARMV7M_LAZYFPU=y CONFIG_ARMV7M_USEBASEPRI=y CONFIG_ARM_MPU=y CONFIG_BOARD_LOOPSPERMSEC=104926 diff --git a/boards/arm/imxrt/imxrt1050-evk/scripts/Make.defs b/boards/arm/imxrt/imxrt1050-evk/scripts/Make.defs index 7a911267cc638..f0afe34c3b526 100644 --- a/boards/arm/imxrt/imxrt1050-evk/scripts/Make.defs +++ b/boards/arm/imxrt/imxrt1050-evk/scripts/Make.defs @@ -30,22 +30,7 @@ endif ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT) -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -endif - -ARCHCFLAGS = -fno-common -ifeq ($(CONFIG_CXX_EXCEPTION),y) - ARCHCXXFLAGS = -fno-common -else - ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new -fno-rtti -endif - -ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef -fno-strict-aliasing +ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 @@ -66,7 +51,3 @@ CMODULEFLAGS = $(CFLAGS) -mlong-calls # --target1-abs LDMODULEFLAGS = -r -e module_initialize LDMODULEFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)/libs/libc/modlib/gnu-elf.ld) - -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - LDFLAGS += -g -endif diff --git a/boards/arm/imxrt/imxrt1060-evk/configs/knsh/Make.defs b/boards/arm/imxrt/imxrt1060-evk/configs/knsh/Make.defs index 02b8d1d12a8fb..90da12df51ca9 100644 --- a/boards/arm/imxrt/imxrt1060-evk/configs/knsh/Make.defs +++ b/boards/arm/imxrt/imxrt1060-evk/configs/knsh/Make.defs @@ -28,17 +28,7 @@ LDSCRIPT2 = kernel-space.ld ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT1) ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT2) -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -endif - -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new -fno-rtti -ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef -fno-strict-aliasing +ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 @@ -59,7 +49,3 @@ CMODULEFLAGS = $(CFLAGS) -mlong-calls # --target1-abs LDMODULEFLAGS = -r -e module_initialize LDMODULEFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)/libs/libc/modlib/gnu-elf.ld) - -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - LDFLAGS += -g -endif diff --git a/boards/arm/imxrt/imxrt1060-evk/configs/knsh/defconfig b/boards/arm/imxrt/imxrt1060-evk/configs/knsh/defconfig index 28fcf7248201a..ba97882d4456b 100644 --- a/boards/arm/imxrt/imxrt1060-evk/configs/knsh/defconfig +++ b/boards/arm/imxrt/imxrt1060-evk/configs/knsh/defconfig @@ -16,7 +16,6 @@ CONFIG_ARCH_STACKDUMP=y CONFIG_ARMV7M_DCACHE=y CONFIG_ARMV7M_DCACHE_WRITETHROUGH=y CONFIG_ARMV7M_ICACHE=y -CONFIG_ARMV7M_LAZYFPU=y CONFIG_ARMV7M_USEBASEPRI=y CONFIG_ARM_MPU=y CONFIG_BOARD_LOOPSPERMSEC=104926 diff --git a/boards/arm/imxrt/imxrt1060-evk/scripts/Make.defs b/boards/arm/imxrt/imxrt1060-evk/scripts/Make.defs index fb550ade0d741..68e2de4a997a5 100644 --- a/boards/arm/imxrt/imxrt1060-evk/scripts/Make.defs +++ b/boards/arm/imxrt/imxrt1060-evk/scripts/Make.defs @@ -30,22 +30,7 @@ endif ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT) -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -endif - -ARCHCFLAGS = -fno-common -ifeq ($(CONFIG_CXX_EXCEPTION),y) - ARCHCXXFLAGS = -fno-common -else - ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new -fno-rtti -endif - -ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef -fno-strict-aliasing +ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 @@ -66,8 +51,3 @@ CMODULEFLAGS = $(CFLAGS) -mlong-calls # --target1-abs LDMODULEFLAGS = -r -e module_initialize LDMODULEFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)/libs/libc/modlib/gnu-elf.ld) - -LDFLAGS += -Map=$(call CONVERT_PATH,$(TOPDIR)/nuttx.map) -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - LDFLAGS += -g -endif diff --git a/boards/arm/imxrt/imxrt1064-evk/configs/knsh/Make.defs b/boards/arm/imxrt/imxrt1064-evk/configs/knsh/Make.defs index 02b8d1d12a8fb..90da12df51ca9 100644 --- a/boards/arm/imxrt/imxrt1064-evk/configs/knsh/Make.defs +++ b/boards/arm/imxrt/imxrt1064-evk/configs/knsh/Make.defs @@ -28,17 +28,7 @@ LDSCRIPT2 = kernel-space.ld ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT1) ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT2) -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -endif - -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new -fno-rtti -ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef -fno-strict-aliasing +ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 @@ -59,7 +49,3 @@ CMODULEFLAGS = $(CFLAGS) -mlong-calls # --target1-abs LDMODULEFLAGS = -r -e module_initialize LDMODULEFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)/libs/libc/modlib/gnu-elf.ld) - -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - LDFLAGS += -g -endif diff --git a/boards/arm/imxrt/imxrt1064-evk/configs/knsh/defconfig b/boards/arm/imxrt/imxrt1064-evk/configs/knsh/defconfig index d44f5c937af3d..4a9e72fcad615 100644 --- a/boards/arm/imxrt/imxrt1064-evk/configs/knsh/defconfig +++ b/boards/arm/imxrt/imxrt1064-evk/configs/knsh/defconfig @@ -16,7 +16,6 @@ CONFIG_ARCH_STACKDUMP=y CONFIG_ARMV7M_DCACHE=y CONFIG_ARMV7M_DCACHE_WRITETHROUGH=y CONFIG_ARMV7M_ICACHE=y -CONFIG_ARMV7M_LAZYFPU=y CONFIG_ARMV7M_USEBASEPRI=y CONFIG_ARM_MPU=y CONFIG_BOARD_LOOPSPERMSEC=104926 diff --git a/boards/arm/imxrt/imxrt1064-evk/scripts/Make.defs b/boards/arm/imxrt/imxrt1064-evk/scripts/Make.defs index ad07a96680e7d..94bf94dc6874f 100644 --- a/boards/arm/imxrt/imxrt1064-evk/scripts/Make.defs +++ b/boards/arm/imxrt/imxrt1064-evk/scripts/Make.defs @@ -30,22 +30,7 @@ endif ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT) -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -endif - -ARCHCFLAGS = -fno-common -ifeq ($(CONFIG_CXX_EXCEPTION),y) - ARCHCXXFLAGS = -fno-common -else - ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new -fno-rtti -endif - -ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef -fno-strict-aliasing +ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 @@ -66,8 +51,3 @@ CMODULEFLAGS = $(CFLAGS) -mlong-calls # --target1-abs LDMODULEFLAGS = -r -e module_initialize LDMODULEFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)/libs/libc/modlib/gnu-elf.ld) - -LDFLAGS += -Map=$(call CONVERT_PATH,$(TOPDIR)/nuttx.map) -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - LDFLAGS += -g -endif diff --git a/boards/arm/imxrt/teensy-4.x/scripts/Make.defs b/boards/arm/imxrt/teensy-4.x/scripts/Make.defs index dfe8cb99aced6..819f50773be01 100644 --- a/boards/arm/imxrt/teensy-4.x/scripts/Make.defs +++ b/boards/arm/imxrt/teensy-4.x/scripts/Make.defs @@ -30,30 +30,7 @@ endif ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT) -CC = $(CROSSDEV)gcc -CXX = $(CROSSDEV)g++ -CPP = $(CROSSDEV)gcc -E -LD = $(CROSSDEV)ld -STRIP = $(CROSSDEV)strip --strip-unneeded -AR = $(CROSSDEV)ar rcs -NM = $(CROSSDEV)nm -OBJCOPY = $(CROSSDEV)objcopy -OBJDUMP = $(CROSSDEV)objdump - -ARCHCCVERSION = ${shell $(CC) -v 2>&1 | sed -n '/^gcc version/p' | sed -e 's/^gcc version \([0-9\.]\)/\1/g' -e 's/[-\ ].*//g' -e '1q'} -ARCHCCMAJOR = ${shell echo $(ARCHCCVERSION) | cut -d'.' -f1} - -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -endif - -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new -fno-rtti -ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef -fno-strict-aliasing +ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 @@ -74,7 +51,3 @@ CMODULEFLAGS = $(CFLAGS) -mlong-calls # --target1-abs LDMODULEFLAGS = -r -e module_initialize LDMODULEFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)/libs/libc/modlib/gnu-elf.ld) - -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - LDFLAGS += -g -endif diff --git a/boards/arm/kinetis/freedom-k28f/scripts/Make.defs b/boards/arm/kinetis/freedom-k28f/scripts/Make.defs index f7f6a19079f66..655f6097e7fd3 100644 --- a/boards/arm/kinetis/freedom-k28f/scripts/Make.defs +++ b/boards/arm/kinetis/freedom-k28f/scripts/Make.defs @@ -26,16 +26,6 @@ LDSCRIPT = flash.ld ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT) -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new -fno-rtti ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 @@ -50,7 +40,3 @@ AFLAGS := $(CFLAGS) -D__ASSEMBLY__ NXFLATLDFLAGS1 = -r -d -warn-common NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-pcrel.ld -no-check-sections LDNXFLATFLAGS = -e main -s 2048 - -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - LDFLAGS += -g -endif diff --git a/boards/arm/kinetis/freedom-k64f/README.txt b/boards/arm/kinetis/freedom-k64f/README.txt index cdc24147531ea..3df8c601299f2 100644 --- a/boards/arm/kinetis/freedom-k64f/README.txt +++ b/boards/arm/kinetis/freedom-k64f/README.txt @@ -810,7 +810,7 @@ Where is one of the following: CONFIG_HOST_WINDOWS=y : Cygwin under Windows CONFIG_WINDOWS_CYGWIN=y - CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIW=y : ARM/mbed toolcahin (arm-none-elf-gcc) + CONFIG_ARMV7M_TOOLCHAIN_GNU_EABI=y : ARM/mbed toolcahin (arm-none-elf-gcc) CONFIG_INTELHEX_BINARY=y : Output formats: Intel hex binary 3. The Serial Console is provided on UART3 with the correct pin @@ -860,7 +860,7 @@ Where is one of the following: CONFIG_HOST_WINDOWS=y : Cygwin under Windows CONFIG_WINDOWS_CYGWIN=y - CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIW=y : ARM/mbed toolcahin (arm-none-elf-gcc) + CONFIG_ARMV7M_TOOLCHAIN_GNU_EABI=y : ARM/mbed toolcahin (arm-none-elf-gcc) CONFIG_INTELHEX_BINARY=y : Output formats: Intel hex binary 3. The Serial Console is provided on UART0 with the correct pin diff --git a/boards/arm/kinetis/freedom-k64f/scripts/Make.defs b/boards/arm/kinetis/freedom-k64f/scripts/Make.defs index 945fcc1b425ff..89b1f13043043 100644 --- a/boards/arm/kinetis/freedom-k64f/scripts/Make.defs +++ b/boards/arm/kinetis/freedom-k64f/scripts/Make.defs @@ -24,16 +24,6 @@ include $(TOPDIR)/arch/arm/src/armv7-m/Toolchain.defs ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)flash.ld -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 @@ -48,7 +38,3 @@ AFLAGS := $(CFLAGS) -D__ASSEMBLY__ NXFLATLDFLAGS1 = -r -d -warn-common NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-pcrel.ld -no-check-sections LDNXFLATFLAGS = -e main -s 2048 - -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - LDFLAGS += -g -endif diff --git a/boards/arm/kinetis/freedom-k66f/README.txt b/boards/arm/kinetis/freedom-k66f/README.txt index 688f8c3333d41..8c78ccd96717a 100644 --- a/boards/arm/kinetis/freedom-k66f/README.txt +++ b/boards/arm/kinetis/freedom-k66f/README.txt @@ -814,7 +814,7 @@ Where is one of the following: CONFIG_HOST_WINDOWS=y : Cygwin under Windows CONFIG_WINDOWS_CYGWIN=y - CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIW=y : ARM/mbed toolcahin (arm-none-elf-gcc) + CONFIG_ARMV7M_TOOLCHAIN_GNU_EABI=y : ARM/mbed toolcahin (arm-none-elf-gcc) CONFIG_INTELHEX_BINARY=y : Output formats: Intel hex binary 3. The Serial Console is provided on UART1 with the correct pin @@ -864,7 +864,7 @@ Where is one of the following: CONFIG_HOST_WINDOWS=y : Cygwin under Windows CONFIG_WINDOWS_CYGWIN=y - CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIW=y : ARM/mbed toolcahin (arm-none-elf-gcc) + CONFIG_ARMV7M_TOOLCHAIN_GNU_EABI=y : ARM/mbed toolcahin (arm-none-elf-gcc) CONFIG_INTELHEX_BINARY=y : Output formats: Intel hex binary 3. The Serial Console is provided on UART1 with the correct pin diff --git a/boards/arm/kinetis/freedom-k66f/scripts/Make.defs b/boards/arm/kinetis/freedom-k66f/scripts/Make.defs index d41c9c87910cf..ccc886bb149f2 100644 --- a/boards/arm/kinetis/freedom-k66f/scripts/Make.defs +++ b/boards/arm/kinetis/freedom-k66f/scripts/Make.defs @@ -24,16 +24,6 @@ include $(TOPDIR)/arch/arm/src/armv7-m/Toolchain.defs ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)flash.ld -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 @@ -48,7 +38,3 @@ AFLAGS := $(CFLAGS) -D__ASSEMBLY__ NXFLATLDFLAGS1 = -r -d -warn-common NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-pcrel.ld -no-check-sections LDNXFLATFLAGS = -e main -s 2048 - -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - LDFLAGS += -g -endif diff --git a/boards/arm/kinetis/kwikstik-k40/scripts/Make.defs b/boards/arm/kinetis/kwikstik-k40/scripts/Make.defs index daefa6e907461..4a7db1b48e0f8 100644 --- a/boards/arm/kinetis/kwikstik-k40/scripts/Make.defs +++ b/boards/arm/kinetis/kwikstik-k40/scripts/Make.defs @@ -24,16 +24,6 @@ include $(TOPDIR)/arch/arm/src/armv7-m/Toolchain.defs ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)kwikstik-k40.ld -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 @@ -48,7 +38,3 @@ AFLAGS := $(CFLAGS) -D__ASSEMBLY__ NXFLATLDFLAGS1 = -r -d -warn-common NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-pcrel.ld -no-check-sections LDNXFLATFLAGS = -e main -s 2048 - -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - LDFLAGS += -g -endif diff --git a/boards/arm/kinetis/teensy-3.x/README.txt b/boards/arm/kinetis/teensy-3.x/README.txt index 40753db685c98..e30e3a3614cd5 100644 --- a/boards/arm/kinetis/teensy-3.x/README.txt +++ b/boards/arm/kinetis/teensy-3.x/README.txt @@ -266,7 +266,7 @@ NOTES: CONFIG_WINDOWS_CYGWIN=y : Cywin under Windows System Type -> Toolchain: - CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIW=y : GNU ARM EABI toolchain + CONFIG_ARMV7M_TOOLCHAIN_GNU_EABI=y : GNU ARM EABI toolchain NOTE: As of this writing, there are issues with using this tool at the -Os level of optimization. This has not been proven to be a @@ -298,7 +298,7 @@ NOTES: CONFIG_HOST_WINDOWS=y : Builds under Windows CONFIG_WINDOWS_CYGWIN=y : Using Cygwin - CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIW=y : GNU EABI toolchain for Windows + CONFIG_ARMV7M_TOOLCHAIN_GNU_EABI=y : GNU EABI toolchain for Windows Support for builtin applications is enabled, but in the base configuration diff --git a/boards/arm/kinetis/teensy-3.x/configs/nsh/defconfig b/boards/arm/kinetis/teensy-3.x/configs/nsh/defconfig index f0356ab26cd57..ff477b00dbbf3 100644 --- a/boards/arm/kinetis/teensy-3.x/configs/nsh/defconfig +++ b/boards/arm/kinetis/teensy-3.x/configs/nsh/defconfig @@ -18,7 +18,6 @@ CONFIG_ARCH_CHIP="kinetis" CONFIG_ARCH_CHIP_KINETIS=y CONFIG_ARCH_CHIP_MK20DX256VLH7=y CONFIG_ARCH_STACKDUMP=y -CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIL=y CONFIG_BOARD_LOOPSPERMSEC=6024 CONFIG_BUILTIN=y CONFIG_DEBUG_FULLOPT=y diff --git a/boards/arm/kinetis/teensy-3.x/scripts/Make.defs b/boards/arm/kinetis/teensy-3.x/scripts/Make.defs index 6a34b214fe8aa..788901f347dff 100644 --- a/boards/arm/kinetis/teensy-3.x/scripts/Make.defs +++ b/boards/arm/kinetis/teensy-3.x/scripts/Make.defs @@ -30,16 +30,6 @@ endif ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT) -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new -fno-rtti ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 @@ -54,7 +44,3 @@ AFLAGS := $(CFLAGS) -D__ASSEMBLY__ NXFLATLDFLAGS1 = -r -d -warn-common NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-pcrel.ld -no-check-sections LDNXFLATFLAGS = -e main -s 2048 - -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - LDFLAGS += -g -endif diff --git a/boards/arm/kinetis/twr-k60n512/scripts/Make.defs b/boards/arm/kinetis/twr-k60n512/scripts/Make.defs index dc0260386a856..a60db246412c2 100644 --- a/boards/arm/kinetis/twr-k60n512/scripts/Make.defs +++ b/boards/arm/kinetis/twr-k60n512/scripts/Make.defs @@ -24,16 +24,6 @@ include $(TOPDIR)/arch/arm/src/armv7-m/Toolchain.defs ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)twr-k60n512.ld -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 @@ -48,7 +38,3 @@ AFLAGS := $(CFLAGS) -D__ASSEMBLY__ NXFLATLDFLAGS1 = -r -d -warn-common NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-pcrel.ld -no-check-sections LDNXFLATFLAGS = -e main -s 2048 - -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - LDFLAGS += -g -endif diff --git a/boards/arm/kinetis/twr-k64f120m/scripts/Make.defs b/boards/arm/kinetis/twr-k64f120m/scripts/Make.defs index fa2a83e99c7c3..1b9925887de42 100644 --- a/boards/arm/kinetis/twr-k64f120m/scripts/Make.defs +++ b/boards/arm/kinetis/twr-k64f120m/scripts/Make.defs @@ -24,16 +24,6 @@ include $(TOPDIR)/arch/arm/src/armv7-m/Toolchain.defs ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)ld.script -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 @@ -48,7 +38,3 @@ AFLAGS := $(CFLAGS) -D__ASSEMBLY__ NXFLATLDFLAGS1 = -r -d -warn-common NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-pcrel.ld -no-check-sections LDNXFLATFLAGS = -e main -s 2048 - -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - LDFLAGS += -g -endif diff --git a/boards/arm/kl/freedom-kl25z/README.txt b/boards/arm/kl/freedom-kl25z/README.txt index cc89aace93d33..2297c7d68e0ff 100644 --- a/boards/arm/kl/freedom-kl25z/README.txt +++ b/boards/arm/kl/freedom-kl25z/README.txt @@ -306,7 +306,7 @@ Where is one of the following: CONFIG_HOST_WINDOWS=y : Builds under Windows CONFIG_WINDOWS_CYGWIN=y : Using Cygwin - CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIW=y : GNU EABI toolchain for Windows + CONFIG_ARMV7M_TOOLCHAIN_GNU_EABI=y : GNU EABI toolchain for Windows 3. Serial Console. A serial console is necessary to interrupt with NSH. The serial console is configured on UART0 which is available diff --git a/boards/arm/kl/freedom-kl25z/scripts/Make.defs b/boards/arm/kl/freedom-kl25z/scripts/Make.defs index 59c8a58e70b60..a546e8073172c 100644 --- a/boards/arm/kl/freedom-kl25z/scripts/Make.defs +++ b/boards/arm/kl/freedom-kl25z/scripts/Make.defs @@ -23,19 +23,8 @@ include $(TOPDIR)/tools/Config.mk include $(TOPDIR)/arch/arm/src/armv6-m/Toolchain.defs LDSCRIPT = freedom-kl25z.ld - ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT) -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new -fno-rtti ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 @@ -50,7 +39,3 @@ AFLAGS := $(CFLAGS) -D__ASSEMBLY__ NXFLATLDFLAGS1 = -r -d -warn-common NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-pcrel.ld -no-check-sections LDNXFLATFLAGS = -e main -s 2048 - -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - LDFLAGS += -g -endif diff --git a/boards/arm/kl/freedom-kl26z/README.txt b/boards/arm/kl/freedom-kl26z/README.txt index 92ebb292c0dac..ede757e5f319a 100644 --- a/boards/arm/kl/freedom-kl26z/README.txt +++ b/boards/arm/kl/freedom-kl26z/README.txt @@ -284,7 +284,7 @@ Where is one of the following: CONFIG_HOST_WINDOWS=y : Builds under Windows CONFIG_WINDOWS_CYGWIN=y : Using Cygwin - CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIW=y : GNU EABI toolchain for Windows + CONFIG_ARMV7M_TOOLCHAIN_GNU_EABI=y : GNU EABI toolchain for Windows 3. Serial Console. A serial console is necessary to interrupt with NSH. The serial console is configured on UART0 which is available diff --git a/boards/arm/kl/freedom-kl26z/scripts/Make.defs b/boards/arm/kl/freedom-kl26z/scripts/Make.defs index a50f8723d3b20..9ff6c714bca23 100644 --- a/boards/arm/kl/freedom-kl26z/scripts/Make.defs +++ b/boards/arm/kl/freedom-kl26z/scripts/Make.defs @@ -23,19 +23,8 @@ include $(TOPDIR)/tools/Config.mk include $(TOPDIR)/arch/arm/src/armv6-m/Toolchain.defs LDSCRIPT = freedom-kl26z.ld - ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT) -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new -fno-rtti ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 @@ -50,7 +39,3 @@ AFLAGS := $(CFLAGS) -D__ASSEMBLY__ NXFLATLDFLAGS1 = -r -d -warn-common NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-pcrel.ld -no-check-sections LDNXFLATFLAGS = -e main -s 2048 - -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - LDFLAGS += -g -endif diff --git a/boards/arm/kl/teensy-lc/scripts/Make.defs b/boards/arm/kl/teensy-lc/scripts/Make.defs index a231fadd88e93..71643c518a430 100644 --- a/boards/arm/kl/teensy-lc/scripts/Make.defs +++ b/boards/arm/kl/teensy-lc/scripts/Make.defs @@ -23,19 +23,8 @@ include $(TOPDIR)/tools/Config.mk include $(TOPDIR)/arch/arm/src/armv6-m/Toolchain.defs LDSCRIPT = teensy-lc.ld - ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT) -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new -fno-rtti ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 @@ -50,7 +39,3 @@ AFLAGS := $(CFLAGS) -D__ASSEMBLY__ NXFLATLDFLAGS1 = -r -d -warn-common NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-pcrel.ld -no-check-sections LDNXFLATFLAGS = -e main -s 2048 - -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - LDFLAGS += -g -endif diff --git a/boards/arm/lc823450/lc823450-xgevk/scripts/Make.defs b/boards/arm/lc823450/lc823450-xgevk/scripts/Make.defs index 58043f6b67fb7..0a75f5b28674d 100644 --- a/boards/arm/lc823450/lc823450-xgevk/scripts/Make.defs +++ b/boards/arm/lc823450/lc823450-xgevk/scripts/Make.defs @@ -24,26 +24,14 @@ include $(TOPDIR)/arch/arm/src/armv7-m/Toolchain.defs ifeq ($(CONFIG_LC823450_IPL2),y) LDSCRIPT = ld-ipl2.script -else -ifeq ($(CONFIG_LC823450_SPIFI_BOOT),y) +else ifeq ($(CONFIG_LC823450_SPIFI_BOOT),y) LDSCRIPT = ld-spif-boot.script else LDSCRIPT = ld.script endif -endif ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT) -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - -ARCHCFLAGS = -fno-common -ffunction-sections -fdata-sections -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new -fno-rtti -nostdinc++ ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 @@ -67,18 +55,12 @@ CELFFLAGS = $(CFLAGS) -mlong-calls # --target1-abs CXXELFFLAGS = $(CXXFLAGS) -mlong-calls # --target1-abs LDELFFLAGS = -r -e main -LDELFFLAGS += -T $(call CONVERT_PATH,$(BOARD_DIR)$(DELIM)scripts$(DELIM)gnu-elf.ld) +LDELFFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)/binfmt/libelf/gnu-elf.ld) # File extensions # Linker flags -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - LDFLAGS += -g -endif - -LDFLAGS += --gc-sections - ifeq ($(CONFIG_LC823450_SDIF_PATCH),y) ARCH_LIBS += -lSdDr_patch_es2 ARCH_LIBPATHS += -L"$(TOPDIR)/arch/arm/src/lc823450" diff --git a/boards/arm/lc823450/lc823450-xgevk/scripts/gnu-elf.ld b/boards/arm/lc823450/lc823450-xgevk/scripts/gnu-elf.ld deleted file mode 100644 index 922c2516a8023..0000000000000 --- a/boards/arm/lc823450/lc823450-xgevk/scripts/gnu-elf.ld +++ /dev/null @@ -1,125 +0,0 @@ -/**************************************************************************** - * boards/arm/lc823450/lc823450-xgevk/scripts/gnu-elf.ld - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. The - * ASF licenses this file to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance with the - * License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - ****************************************************************************/ - -SECTIONS -{ - .text 0x00000000 : - { - _stext = . ; - *(.text) - *(.text.*) - *(.gnu.warning) - *(.stub) - *(.glue_7) - *(.glue_7t) - *(.jcr) - - /* C++ support: The .init and .fini sections contain specific logic - * to manage static constructors and destructors. - */ - - *(.gnu.linkonce.t.*) - *(.init) /* Old ABI */ - *(.fini) /* Old ABI */ - _etext = . ; - } - - .ARM.extab : - { - *(.ARM.extab*) - } - - .ARM.exidx : - { - *(.ARM.exidx*) - } - - .rodata : - { - _srodata = . ; - *(.rodata) - *(.rodata1) - *(.rodata.*) - *(.gnu.linkonce.r*) - _erodata = . ; - } - - .data : - { - _sdata = . ; - *(.data) - *(.data1) - *(.data.*) - *(.gnu.linkonce.d*) - . = ALIGN(4); - _edata = . ; - } - - /* C++ support. For each global and static local C++ object, - * GCC creates a small subroutine to construct the object. Pointers - * to these routines (not the routines themselves) are stored as - * simple, linear arrays in the .ctors section of the object file. - * Similarly, pointers to global/static destructor routines are - * stored in .dtors. - */ - - .ctors : - { - _sctors = . ; - *(.ctors) /* Old ABI: Unallocated */ - *(.init_array) /* New ABI: Allocated */ - _edtors = . ; - } - - .dtors : - { - _sdtors = . ; - *(.dtors) /* Old ABI: Unallocated */ - *(.fini_array) /* New ABI: Allocated */ - _edtors = . ; - } - - .bss : - { - _sbss = . ; - *(.bss) - *(.bss.*) - *(.sbss) - *(.sbss.*) - *(.gnu.linkonce.b*) - *(COMMON) - _ebss = . ; - } - - /* Stabs debugging sections. */ - - .stab 0 : { *(.stab) } - .stabstr 0 : { *(.stabstr) } - .stab.excl 0 : { *(.stab.excl) } - .stab.exclstr 0 : { *(.stab.exclstr) } - .stab.index 0 : { *(.stab.index) } - .stab.indexstr 0 : { *(.stab.indexstr) } - .comment 0 : { *(.comment) } - .debug_abbrev 0 : { *(.debug_abbrev) } - .debug_info 0 : { *(.debug_info) } - .debug_line 0 : { *(.debug_line) } - .debug_pubnames 0 : { *(.debug_pubnames) } - .debug_aranges 0 : { *(.debug_aranges) } -} diff --git a/boards/arm/lpc17xx_40xx/lincoln60/README.txt b/boards/arm/lpc17xx_40xx/lincoln60/README.txt index 0a31b4f566206..c96f681da84b8 100644 --- a/boards/arm/lpc17xx_40xx/lincoln60/README.txt +++ b/boards/arm/lpc17xx_40xx/lincoln60/README.txt @@ -348,7 +348,7 @@ Where is one of the following: CONFIG_HOST_WINDOWS=y : Windows CONFIG_HOST_WINDOWS_CYGWIN=y : under Cygwin - CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIW=y : GNU EABI toolchain for Windows + CONFIG_ARMV7M_TOOLCHAIN_GNU_EABI=y : GNU EABI toolchain for Windows STATUS: 2015-06-06: The BINFS CGI files are seems to be running, but the diff --git a/boards/arm/lpc17xx_40xx/lincoln60/scripts/Make.defs b/boards/arm/lpc17xx_40xx/lincoln60/scripts/Make.defs index 8cb99d34591c5..f220708477cc8 100644 --- a/boards/arm/lpc17xx_40xx/lincoln60/scripts/Make.defs +++ b/boards/arm/lpc17xx_40xx/lincoln60/scripts/Make.defs @@ -24,16 +24,6 @@ include $(TOPDIR)/arch/arm/src/armv7-m/Toolchain.defs ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)ld.script -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 @@ -48,7 +38,3 @@ AFLAGS := $(CFLAGS) -D__ASSEMBLY__ NXFLATLDFLAGS1 = -r -d -warn-common NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-pcrel.ld -no-check-sections LDNXFLATFLAGS = -e main -s 2048 - -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - LDFLAGS += -g -endif diff --git a/boards/arm/lpc17xx_40xx/lpc4088-devkit/README.txt b/boards/arm/lpc17xx_40xx/lpc4088-devkit/README.txt index 600147573fa63..e23f3f95d294d 100644 --- a/boards/arm/lpc17xx_40xx/lpc4088-devkit/README.txt +++ b/boards/arm/lpc17xx_40xx/lpc4088-devkit/README.txt @@ -262,7 +262,7 @@ Information Common to All Configurations CONFIG_WINDOWS_CYGWIN=y : Cywin under Windows System Type -> Toolchain: - CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIW=y : GNU ARM EABI toolchain + CONFIG_ARMV7M_TOOLCHAIN_GNU_EABI=y : GNU ARM EABI toolchain 3. By Default, UART0 is used as the serial console in all configurations. This may be connected to your computer via an external RS-232 driver or diff --git a/boards/arm/lpc17xx_40xx/lpc4088-devkit/configs/knsh/Make.defs b/boards/arm/lpc17xx_40xx/lpc4088-devkit/configs/knsh/Make.defs index ff86a6e6c2171..80dd4b56b0420 100644 --- a/boards/arm/lpc17xx_40xx/lpc4088-devkit/configs/knsh/Make.defs +++ b/boards/arm/lpc17xx_40xx/lpc4088-devkit/configs/knsh/Make.defs @@ -25,16 +25,6 @@ include $(TOPDIR)/arch/arm/src/armv7-m/Toolchain.defs ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)memory.ld ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)kernel-space.ld -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 @@ -49,7 +39,3 @@ AFLAGS := $(CFLAGS) -D__ASSEMBLY__ NXFLATLDFLAGS1 = -r -d -warn-common NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)$(DELIM)binfmt$(DELIM)libnxflat$(DELIM)gnu-nxflat-pcrel.ld -no-check-sections LDNXFLATFLAGS = -e main -s 2048 - -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - LDFLAGS += -g -endif diff --git a/boards/arm/lpc17xx_40xx/lpc4088-devkit/scripts/Make.defs b/boards/arm/lpc17xx_40xx/lpc4088-devkit/scripts/Make.defs index 64635575fb70f..cd91098fccc10 100644 --- a/boards/arm/lpc17xx_40xx/lpc4088-devkit/scripts/Make.defs +++ b/boards/arm/lpc17xx_40xx/lpc4088-devkit/scripts/Make.defs @@ -24,16 +24,6 @@ include $(TOPDIR)/arch/arm/src/armv7-m/Toolchain.defs ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)ld.script -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 @@ -48,7 +38,3 @@ AFLAGS := $(CFLAGS) -D__ASSEMBLY__ NXFLATLDFLAGS1 = -r -d -warn-common NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)$(DELIM)binfmt$(DELIM)libnxflat$(DELIM)gnu-nxflat-pcrel.ld -no-check-sections LDNXFLATFLAGS = -e main -s 2048 - -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - LDFLAGS += -g -endif diff --git a/boards/arm/lpc17xx_40xx/lpc4088-quickstart/README.txt b/boards/arm/lpc17xx_40xx/lpc4088-quickstart/README.txt index 44d36da0f2f63..1fbeec6f6c5ad 100644 --- a/boards/arm/lpc17xx_40xx/lpc4088-quickstart/README.txt +++ b/boards/arm/lpc17xx_40xx/lpc4088-quickstart/README.txt @@ -247,7 +247,7 @@ Information Common to All Configurations CONFIG_WINDOWS_CYGWIN=y : Cywin under Windows System Type -> Toolchain: - CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIW=y : GNU ARM EABI toolchain + CONFIG_ARMV7M_TOOLCHAIN_GNU_EABI=y : GNU ARM EABI toolchain 3. By Default, UART0 is used as the serial console in all configurations. This may be connected to your computer via an external RS-232 driver or diff --git a/boards/arm/lpc17xx_40xx/lpc4088-quickstart/configs/knsh/Make.defs b/boards/arm/lpc17xx_40xx/lpc4088-quickstart/configs/knsh/Make.defs index 2e44409081d39..7214b1dc67145 100644 --- a/boards/arm/lpc17xx_40xx/lpc4088-quickstart/configs/knsh/Make.defs +++ b/boards/arm/lpc17xx_40xx/lpc4088-quickstart/configs/knsh/Make.defs @@ -25,16 +25,6 @@ include $(TOPDIR)/arch/arm/src/armv7-m/Toolchain.defs ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)memory.ld ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)kernel-space.ld -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 @@ -49,7 +39,3 @@ AFLAGS := $(CFLAGS) -D__ASSEMBLY__ NXFLATLDFLAGS1 = -r -d -warn-common NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)$(DELIM)binfmt$(DELIM)libnxflat$(DELIM)gnu-nxflat-pcrel.ld -no-check-sections LDNXFLATFLAGS = -e main -s 2048 - -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - LDFLAGS += -g -endif diff --git a/boards/arm/lpc17xx_40xx/lpc4088-quickstart/scripts/Make.defs b/boards/arm/lpc17xx_40xx/lpc4088-quickstart/scripts/Make.defs index 55d3ca993988f..9e833bf3d86a4 100644 --- a/boards/arm/lpc17xx_40xx/lpc4088-quickstart/scripts/Make.defs +++ b/boards/arm/lpc17xx_40xx/lpc4088-quickstart/scripts/Make.defs @@ -24,16 +24,6 @@ include $(TOPDIR)/arch/arm/src/armv7-m/Toolchain.defs ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)ld.script -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 @@ -48,7 +38,3 @@ AFLAGS := $(CFLAGS) -D__ASSEMBLY__ NXFLATLDFLAGS1 = -r -d -warn-common NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)$(DELIM)binfmt$(DELIM)libnxflat$(DELIM)gnu-nxflat-pcrel.ld -no-check-sections LDNXFLATFLAGS = -e main -s 2048 - -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - LDFLAGS += -g -endif diff --git a/boards/arm/lpc17xx_40xx/lpcxpresso-lpc1768/README.txt b/boards/arm/lpc17xx_40xx/lpcxpresso-lpc1768/README.txt index 006088e4729bd..486ec17f0ec8a 100644 --- a/boards/arm/lpc17xx_40xx/lpcxpresso-lpc1768/README.txt +++ b/boards/arm/lpc17xx_40xx/lpcxpresso-lpc1768/README.txt @@ -653,7 +653,7 @@ Where is one of the following: 3. Build setup (easily reconfigured): CONFIG_HOST_LINUX=y : Linux - CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIL=y : GNU EABI toolchain for Linux + CONFIG_ARMV7M_TOOLCHAIN_GNU_EABI=y : GNU EABI toolchain for Linux 4. Jumpers: Nothing special. Use the default base board jumper settings. diff --git a/boards/arm/lpc17xx_40xx/lpcxpresso-lpc1768/configs/thttpd/Make.defs b/boards/arm/lpc17xx_40xx/lpcxpresso-lpc1768/configs/thttpd/Make.defs index 6b1178317bffa..d59aa9dbae8f2 100644 --- a/boards/arm/lpc17xx_40xx/lpcxpresso-lpc1768/configs/thttpd/Make.defs +++ b/boards/arm/lpc17xx_40xx/lpcxpresso-lpc1768/configs/thttpd/Make.defs @@ -28,16 +28,6 @@ ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)ld.script MKNXFLAT = mknxflat LDNXFLAT = ldnxflat -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 @@ -52,7 +42,3 @@ AFLAGS := $(CFLAGS) -D__ASSEMBLY__ NXFLATLDFLAGS1 = -r -d -warn-common NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) $(NXFLATLDSCRIPT) -no-check-sections LDNXFLATFLAGS = -e main -s 2048 - -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - LDFLAGS += -g -endif diff --git a/boards/arm/lpc17xx_40xx/lpcxpresso-lpc1768/scripts/Make.defs b/boards/arm/lpc17xx_40xx/lpcxpresso-lpc1768/scripts/Make.defs index 88392bde24a07..16055a659a3a6 100644 --- a/boards/arm/lpc17xx_40xx/lpcxpresso-lpc1768/scripts/Make.defs +++ b/boards/arm/lpc17xx_40xx/lpcxpresso-lpc1768/scripts/Make.defs @@ -24,16 +24,6 @@ include $(TOPDIR)/arch/arm/src/armv7-m/Toolchain.defs ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)ld.script -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 @@ -48,7 +38,3 @@ AFLAGS := $(CFLAGS) -D__ASSEMBLY__ NXFLATLDFLAGS1 = -r -d -warn-common NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-pcrel.ld -no-check-sections LDNXFLATFLAGS = -e main -s 2048 - -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - LDFLAGS += -g -endif diff --git a/boards/arm/lpc17xx_40xx/lx_cpu/scripts/Make.defs b/boards/arm/lpc17xx_40xx/lx_cpu/scripts/Make.defs index 8a46c731c39d1..8bbb3c262b020 100644 --- a/boards/arm/lpc17xx_40xx/lx_cpu/scripts/Make.defs +++ b/boards/arm/lpc17xx_40xx/lx_cpu/scripts/Make.defs @@ -36,16 +36,6 @@ endif ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT) -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fno-rtti -fcheck-new ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 @@ -69,7 +59,7 @@ CELFFLAGS = $(CFLAGS) -mlong-calls # --target1-abs CXXELFFLAGS = $(CXXFLAGS) -mlong-calls # --target1-abs LDELFFLAGS = -r -e main -LDELFFLAGS += -T $(call CONVERT_PATH,$(BOARD_DIR)$(DELIM)scripts$(DELIM)gnu-elf.ld) +LDELFFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)/binfmt/libelf/gnu-elf.ld) # Loadable module definitions @@ -81,7 +71,3 @@ LDMODULEFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)/libs/libc/modlib/gnu-elf.ld) # File extensions # Linker flags - -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - LDFLAGS += -g -endif diff --git a/boards/arm/lpc17xx_40xx/lx_cpu/scripts/gnu-elf.ld b/boards/arm/lpc17xx_40xx/lx_cpu/scripts/gnu-elf.ld deleted file mode 100644 index 0b6c5007178cf..0000000000000 --- a/boards/arm/lpc17xx_40xx/lx_cpu/scripts/gnu-elf.ld +++ /dev/null @@ -1,125 +0,0 @@ -/**************************************************************************** - * boards/arm/lpc17xx_40xx/lx_cpu/scripts/gnu-elf.ld - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. The - * ASF licenses this file to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance with the - * License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - ****************************************************************************/ - -SECTIONS -{ - .text 0x00000000 : - { - _stext = . ; - *(.text) - *(.text.*) - *(.gnu.warning) - *(.stub) - *(.glue_7) - *(.glue_7t) - *(.jcr) - - /* C++ support: The .init and .fini sections contain specific logic - * to manage static constructors and destructors. - */ - - *(.gnu.linkonce.t.*) - *(.init) /* Old ABI */ - *(.fini) /* Old ABI */ - _etext = . ; - } - - .ARM.extab : - { - *(.ARM.extab*) - } - - .ARM.exidx : - { - *(.ARM.exidx*) - } - - .rodata : - { - _srodata = . ; - *(.rodata) - *(.rodata1) - *(.rodata.*) - *(.gnu.linkonce.r*) - _erodata = . ; - } - - .data : - { - _sdata = . ; - *(.data) - *(.data1) - *(.data.*) - *(.gnu.linkonce.d*) - . = ALIGN(4); - _edata = . ; - } - - /* C++ support. For each global and static local C++ object, - * GCC creates a small subroutine to construct the object. Pointers - * to these routines (not the routines themselves) are stored as - * simple, linear arrays in the .ctors section of the object file. - * Similarly, pointers to global/static destructor routines are - * stored in .dtors. - */ - - .ctors : - { - _sctors = . ; - *(.ctors) /* Old ABI: Unallocated */ - *(.init_array) /* New ABI: Allocated */ - _edtors = . ; - } - - .dtors : - { - _sdtors = . ; - *(.dtors) /* Old ABI: Unallocated */ - *(.fini_array) /* New ABI: Allocated */ - _edtors = . ; - } - - .bss : - { - _sbss = . ; - *(.bss) - *(.bss.*) - *(.sbss) - *(.sbss.*) - *(.gnu.linkonce.b*) - *(COMMON) - _ebss = . ; - } - - /* Stabs debugging sections. */ - - .stab 0 : { *(.stab) } - .stabstr 0 : { *(.stabstr) } - .stab.excl 0 : { *(.stab.excl) } - .stab.exclstr 0 : { *(.stab.exclstr) } - .stab.index 0 : { *(.stab.index) } - .stab.indexstr 0 : { *(.stab.indexstr) } - .comment 0 : { *(.comment) } - .debug_abbrev 0 : { *(.debug_abbrev) } - .debug_info 0 : { *(.debug_info) } - .debug_line 0 : { *(.debug_line) } - .debug_pubnames 0 : { *(.debug_pubnames) } - .debug_aranges 0 : { *(.debug_aranges) } -} diff --git a/boards/arm/lpc17xx_40xx/lx_cpu/src/lpc17_40_boardinitialize.c b/boards/arm/lpc17xx_40xx/lx_cpu/src/lpc17_40_boardinitialize.c index f0110c6b8548b..367bf6a41df8f 100644 --- a/boards/arm/lpc17xx_40xx/lx_cpu/src/lpc17_40_boardinitialize.c +++ b/boards/arm/lpc17xx_40xx/lx_cpu/src/lpc17_40_boardinitialize.c @@ -51,6 +51,10 @@ void lpc17_40_boardinitialize(void) { +#ifdef CONFIG_SCHED_IRQMONITOR + up_perf_init((FAR void *)LPC17_40_CCLK); +#endif + /* Initialize the EMC, and SDRAM */ #ifndef BOARD_EMC_CONFIG_BY_LOADER diff --git a/boards/arm/lpc17xx_40xx/mbed/scripts/Make.defs b/boards/arm/lpc17xx_40xx/mbed/scripts/Make.defs index 224143e4e3c19..781687d24e410 100644 --- a/boards/arm/lpc17xx_40xx/mbed/scripts/Make.defs +++ b/boards/arm/lpc17xx_40xx/mbed/scripts/Make.defs @@ -24,16 +24,6 @@ include $(TOPDIR)/arch/arm/src/armv7-m/Toolchain.defs ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)ld.script -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 @@ -48,7 +38,3 @@ AFLAGS := $(CFLAGS) -D__ASSEMBLY__ NXFLATLDFLAGS1 = -r -d -warn-common NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-pcrel.ld -no-check-sections LDNXFLATFLAGS = -e main -s 2048 - -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - LDFLAGS += -g -endif diff --git a/boards/arm/lpc17xx_40xx/mcb1700/scripts/Make.defs b/boards/arm/lpc17xx_40xx/mcb1700/scripts/Make.defs index ca4e4dc80ebc0..30ead2a06d703 100644 --- a/boards/arm/lpc17xx_40xx/mcb1700/scripts/Make.defs +++ b/boards/arm/lpc17xx_40xx/mcb1700/scripts/Make.defs @@ -24,16 +24,6 @@ include $(TOPDIR)/arch/arm/src/armv7-m/Toolchain.defs ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)ld.script -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 @@ -48,7 +38,3 @@ AFLAGS := $(CFLAGS) -D__ASSEMBLY__ NXFLATLDFLAGS1 = -r -d -warn-common NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-pcrel.ld -no-check-sections LDNXFLATFLAGS = -e main -s 2048 - -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - LDFLAGS += -g -endif diff --git a/boards/arm/lpc17xx_40xx/olimex-lpc1766stk/README.txt b/boards/arm/lpc17xx_40xx/olimex-lpc1766stk/README.txt index 6482ad0c1d340..db997f558adfe 100644 --- a/boards/arm/lpc17xx_40xx/olimex-lpc1766stk/README.txt +++ b/boards/arm/lpc17xx_40xx/olimex-lpc1766stk/README.txt @@ -737,7 +737,7 @@ Configuration Sub-Directories 2. This configuration targets Linux using a generic ARM EABI toolchain: CONFIG_LINUX=y - CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIL=y + CONFIG_ARMV7M_TOOLCHAIN_GNU_EABI=y But that can easily be re-configured. @@ -780,7 +780,7 @@ Configuration Sub-Directories CONFIG_HOST_WINDOWS=y : Windows CONFIG_WINDOWS_CYGWIN=y : Cygwin environment on Windows - CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIW=y : GNU EABI toolchain for Windows + CONFIG_ARMV7M_TOOLCHAIN_GNU_EABI=y : GNU EABI toolchain for Windows 2. The mouse is really useless with no display and no cursor. So this configuration is only suited for low-level testing. It is also awkward @@ -893,7 +893,7 @@ Configuration Sub-Directories CONFIG_HOST_WINDOWS=y : Windows CONFIG_HOST_WINDOWS_CYGWIN=y : under Cygwin - CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIW=y : GNU EABI toolchain for Windows + CONFIG_ARMV7M_TOOLCHAIN_GNU_EABI=y : GNU EABI toolchain for Windows STATUS: 2015-06-02. This configuration was added in an attempt to replace diff --git a/boards/arm/lpc17xx_40xx/olimex-lpc1766stk/configs/thttpd-binfs/Make.defs b/boards/arm/lpc17xx_40xx/olimex-lpc1766stk/configs/thttpd-binfs/Make.defs index b4422f5d4856e..094f17aac2444 100644 --- a/boards/arm/lpc17xx_40xx/olimex-lpc1766stk/configs/thttpd-binfs/Make.defs +++ b/boards/arm/lpc17xx_40xx/olimex-lpc1766stk/configs/thttpd-binfs/Make.defs @@ -27,16 +27,6 @@ ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)ld.script MKNXFLAT = mknxflat LDNXFLAT = ldnxflat -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 @@ -51,7 +41,3 @@ AFLAGS := $(CFLAGS) -D__ASSEMBLY__ NXFLATLDFLAGS1 = -r -d -warn-common NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-gotoff.ld -no-check-sections LDNXFLATFLAGS = -e main -s 2048 - -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - LDFLAGS += -g -endif diff --git a/boards/arm/lpc17xx_40xx/olimex-lpc1766stk/configs/thttpd-nxflat/Make.defs b/boards/arm/lpc17xx_40xx/olimex-lpc1766stk/configs/thttpd-nxflat/Make.defs index 7e55171469d74..bcc7dafc4b07f 100644 --- a/boards/arm/lpc17xx_40xx/olimex-lpc1766stk/configs/thttpd-nxflat/Make.defs +++ b/boards/arm/lpc17xx_40xx/olimex-lpc1766stk/configs/thttpd-nxflat/Make.defs @@ -27,16 +27,6 @@ ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)ld.script MKNXFLAT = mknxflat LDNXFLAT = ldnxflat -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 @@ -51,7 +41,3 @@ AFLAGS := $(CFLAGS) -D__ASSEMBLY__ NXFLATLDFLAGS1 = -r -d -warn-common NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-gotoff.ld -no-check-sections LDNXFLATFLAGS = -e main -s 2048 - -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - LDFLAGS += -g -endif diff --git a/boards/arm/lpc17xx_40xx/olimex-lpc1766stk/scripts/Make.defs b/boards/arm/lpc17xx_40xx/olimex-lpc1766stk/scripts/Make.defs index 1a3653f4f4144..a9996439131db 100644 --- a/boards/arm/lpc17xx_40xx/olimex-lpc1766stk/scripts/Make.defs +++ b/boards/arm/lpc17xx_40xx/olimex-lpc1766stk/scripts/Make.defs @@ -27,16 +27,6 @@ ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)ld.script MKNXFLAT = mknxflat LDNXFLAT = ldnxflat -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 @@ -51,7 +41,3 @@ AFLAGS := $(CFLAGS) -D__ASSEMBLY__ NXFLATLDFLAGS1 = -r -d -warn-common NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-pcrel.ld -no-check-sections LDNXFLATFLAGS = -e main -s 2048 - -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - LDFLAGS += -g -endif diff --git a/boards/arm/lpc17xx_40xx/open1788/README.txt b/boards/arm/lpc17xx_40xx/open1788/README.txt index 2d168f190663d..7d764bbb6e757 100644 --- a/boards/arm/lpc17xx_40xx/open1788/README.txt +++ b/boards/arm/lpc17xx_40xx/open1788/README.txt @@ -273,7 +273,7 @@ Information Common to All Configurations CONFIG_WINDOWS_CYGWIN=y : Cywin under Windows System Type -> Toolchain: - CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIW=y : GNU ARM EABI toolchain + CONFIG_ARMV7M_TOOLCHAIN_GNU_EABI=y : GNU ARM EABI toolchain 3. By Default, UART0 is used as the serial console in all configurations. This may be connected to your computer via an external RS-232 driver or diff --git a/boards/arm/lpc17xx_40xx/open1788/configs/knsh/Make.defs b/boards/arm/lpc17xx_40xx/open1788/configs/knsh/Make.defs index ed526bf16a959..2469e6c7af41f 100644 --- a/boards/arm/lpc17xx_40xx/open1788/configs/knsh/Make.defs +++ b/boards/arm/lpc17xx_40xx/open1788/configs/knsh/Make.defs @@ -25,16 +25,6 @@ include $(TOPDIR)/arch/arm/src/armv7-m/Toolchain.defs ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)memory.ld ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)kernel-space.ld -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 @@ -49,7 +39,3 @@ AFLAGS := $(CFLAGS) -D__ASSEMBLY__ NXFLATLDFLAGS1 = -r -d -warn-common NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)$(DELIM)binfmt$(DELIM)libnxflat$(DELIM)gnu-nxflat-pcrel.ld -no-check-sections LDNXFLATFLAGS = -e main -s 2048 - -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - LDFLAGS += -g -endif diff --git a/boards/arm/lpc17xx_40xx/open1788/configs/knxterm/Make.defs b/boards/arm/lpc17xx_40xx/open1788/configs/knxterm/Make.defs index 8859dec331799..a3d782201153d 100644 --- a/boards/arm/lpc17xx_40xx/open1788/configs/knxterm/Make.defs +++ b/boards/arm/lpc17xx_40xx/open1788/configs/knxterm/Make.defs @@ -25,16 +25,6 @@ include $(TOPDIR)/arch/arm/src/armv7-m/Toolchain.defs ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)memory.ld ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)kernel-space.ld -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 @@ -49,7 +39,3 @@ AFLAGS := $(CFLAGS) -D__ASSEMBLY__ NXFLATLDFLAGS1 = -r -d -warn-common NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)$(DELIM)binfmt$(DELIM)libnxflat$(DELIM)gnu-nxflat-pcrel.ld -no-check-sections LDNXFLATFLAGS = -e main -s 2048 - -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - LDFLAGS += -g -endif diff --git a/boards/arm/lpc17xx_40xx/open1788/scripts/Make.defs b/boards/arm/lpc17xx_40xx/open1788/scripts/Make.defs index 49b6443e2eb27..88bcbdad26b14 100644 --- a/boards/arm/lpc17xx_40xx/open1788/scripts/Make.defs +++ b/boards/arm/lpc17xx_40xx/open1788/scripts/Make.defs @@ -24,16 +24,6 @@ include $(TOPDIR)/arch/arm/src/armv7-m/Toolchain.defs ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)ld.script -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 @@ -48,7 +38,3 @@ AFLAGS := $(CFLAGS) -D__ASSEMBLY__ NXFLATLDFLAGS1 = -r -d -warn-common NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)$(DELIM)binfmt$(DELIM)libnxflat$(DELIM)gnu-nxflat-pcrel.ld -no-check-sections LDNXFLATFLAGS = -e main -s 2048 - -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - LDFLAGS += -g -endif diff --git a/boards/arm/lpc17xx_40xx/pnev5180b/configs/knsh/Make.defs b/boards/arm/lpc17xx_40xx/pnev5180b/configs/knsh/Make.defs index d6ecc2d7a1924..c90838a137fa1 100644 --- a/boards/arm/lpc17xx_40xx/pnev5180b/configs/knsh/Make.defs +++ b/boards/arm/lpc17xx_40xx/pnev5180b/configs/knsh/Make.defs @@ -25,28 +25,13 @@ include $(TOPDIR)/arch/arm/src/armv7-m/Toolchain.defs ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)memory.ld ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)kernel-space.ld -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - -# enable precise stack overflow tracking -ifeq ($(CONFIG_ARMV7M_STACKCHECK),y) - INSTRUMENTATIONDEFINES = -finstrument-functions -ffixed-r10 -endif - -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 -CFLAGS := $(ARCHCFLAGS) $(ARCHWARNINGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) $(INSTRUMENTATIONDEFINES) -pipe +CFLAGS := $(ARCHCFLAGS) $(ARCHWARNINGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) -pipe CPICFLAGS = $(ARCHPICFLAGS) $(CFLAGS) -CXXFLAGS := $(ARCHCXXFLAGS) $(ARCHWARNINGSXX) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHXXINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) $(INSTRUMENTATIONDEFINES) -pipe +CXXFLAGS := $(ARCHCXXFLAGS) $(ARCHWARNINGSXX) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHXXINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) -pipe CXXPICFLAGS = $(ARCHPICFLAGS) $(CXXFLAGS) CPPFLAGS := $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) AFLAGS := $(CFLAGS) -D__ASSEMBLY__ @@ -54,7 +39,3 @@ AFLAGS := $(CFLAGS) -D__ASSEMBLY__ NXFLATLDFLAGS1 = -r -d -warn-common NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)$(DELIM)binfmt$(DELIM)libnxflat$(DELIM)gnu-nxflat-pcrel.ld -no-check-sections LDNXFLATFLAGS = -e main -s 2048 - -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - LDFLAGS += -g -endif diff --git a/boards/arm/lpc17xx_40xx/pnev5180b/scripts/Make.defs b/boards/arm/lpc17xx_40xx/pnev5180b/scripts/Make.defs index d14d8c101d650..509b9474c3f93 100644 --- a/boards/arm/lpc17xx_40xx/pnev5180b/scripts/Make.defs +++ b/boards/arm/lpc17xx_40xx/pnev5180b/scripts/Make.defs @@ -24,28 +24,13 @@ include $(TOPDIR)/arch/arm/src/armv7-m/Toolchain.defs ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)flash.ld -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - -# enable precise stack overflow tracking -ifeq ($(CONFIG_ARMV7M_STACKCHECK),y) - INSTRUMENTATIONDEFINES = -finstrument-functions -ffixed-r10 -endif - -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 -CFLAGS := $(ARCHCFLAGS) $(ARCHWARNINGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) $(INSTRUMENTATIONDEFINES) -pipe +CFLAGS := $(ARCHCFLAGS) $(ARCHWARNINGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) -pipe CPICFLAGS = $(ARCHPICFLAGS) $(CFLAGS) -CXXFLAGS := $(ARCHCXXFLAGS) $(ARCHWARNINGSXX) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHXXINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) $(INSTRUMENTATIONDEFINES) -pipe +CXXFLAGS := $(ARCHCXXFLAGS) $(ARCHWARNINGSXX) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHXXINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) -pipe CXXPICFLAGS = $(ARCHPICFLAGS) $(CXXFLAGS) CPPFLAGS := $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) AFLAGS := $(CFLAGS) -D__ASSEMBLY__ @@ -53,7 +38,3 @@ AFLAGS := $(CFLAGS) -D__ASSEMBLY__ NXFLATLDFLAGS1 = -r -d -warn-common NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)$(DELIM)binfmt$(DELIM)libnxflat$(DELIM)gnu-nxflat-pcrel.ld -no-check-sections LDNXFLATFLAGS = -e main -s 2048 - -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - LDFLAGS += -g -endif diff --git a/boards/arm/lpc17xx_40xx/u-blox-c027/scripts/Make.defs b/boards/arm/lpc17xx_40xx/u-blox-c027/scripts/Make.defs index cd06c7054eb60..4f1fae42c2d85 100644 --- a/boards/arm/lpc17xx_40xx/u-blox-c027/scripts/Make.defs +++ b/boards/arm/lpc17xx_40xx/u-blox-c027/scripts/Make.defs @@ -24,16 +24,6 @@ include $(TOPDIR)/arch/arm/src/armv7-m/Toolchain.defs ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)u-blox-c027.ld -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 @@ -48,7 +38,3 @@ AFLAGS := $(CFLAGS) -D__ASSEMBLY__ NXFLATLDFLAGS1 = -r -d -warn-common NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-pcrel.ld -no-check-sections LDNXFLATFLAGS = -e main -s 2048 - -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - LDFLAGS += -g -endif diff --git a/boards/arm/lpc17xx_40xx/zkit-arm-1769/scripts/Make.defs b/boards/arm/lpc17xx_40xx/zkit-arm-1769/scripts/Make.defs index 044deb85d4bb7..540d2f1053378 100644 --- a/boards/arm/lpc17xx_40xx/zkit-arm-1769/scripts/Make.defs +++ b/boards/arm/lpc17xx_40xx/zkit-arm-1769/scripts/Make.defs @@ -28,16 +28,6 @@ ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)ld.script MKNXFLAT = mknxflat LDNXFLAT = ldnxflat -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 @@ -52,7 +42,3 @@ AFLAGS := $(CFLAGS) -D__ASSEMBLY__ NXFLATLDFLAGS1 = -r -d -warn-common NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) $(NXFLATLDSCRIPT) -no-check-sections LDNXFLATFLAGS = -e main -s 2048 - -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - LDFLAGS += -g -endif diff --git a/boards/arm/lpc214x/mcu123-lpc214x/scripts/Make.defs b/boards/arm/lpc214x/mcu123-lpc214x/scripts/Make.defs index 299ed332c2f9b..e91a6a0d148a9 100644 --- a/boards/arm/lpc214x/mcu123-lpc214x/scripts/Make.defs +++ b/boards/arm/lpc214x/mcu123-lpc214x/scripts/Make.defs @@ -45,18 +45,12 @@ ifeq ("${CONFIG_DEBUG_FEATURES}","y") ARCHOPTIMIZATION = -g endif -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - ifeq ($(OLDGCC),n) ARCHCPUFLAGS = -mcpu=arm7tdmi -mfloat-abi=soft else ARCHCPUFLAGS = -mapcs-32 -mcpu=arm7tdmi -msoft-float endif -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef diff --git a/boards/arm/lpc214x/zp214xpa/README.txt b/boards/arm/lpc214x/zp214xpa/README.txt index 22b8c3a390bb6..dc5e445296bc4 100644 --- a/boards/arm/lpc214x/zp214xpa/README.txt +++ b/boards/arm/lpc214x/zp214xpa/README.txt @@ -308,7 +308,7 @@ Configurations: 2. Default platform/toolchain: CONFIG_HOST_LINUX=y : Linux (Cygwin under Windows okay too). - CONFIG_ARM_TOOLCHAIN_GNU_EABIL=y : Buildroot (arm-nuttx-elf-gcc) + CONFIG_ARM_TOOLCHAIN_GNU_EABI=y : Buildroot (arm-nuttx-elf-gcc) CONFIG_RAW_BINARY=y : Output formats: ELF and raw binary nxlines: @@ -332,7 +332,7 @@ Configurations: 2. Default platform/toolchain: CONFIG_HOST_LINUX=y : Linux (Cygwin under Windows okay too). - CONFIG_ARM_TOOLCHAIN_GNU_EABIL=y : Buildroot (arm-nuttx-elf-gcc) + CONFIG_ARM_TOOLCHAIN_GNU_EABI=y : Buildroot (arm-nuttx-elf-gcc) CONFIG_RAW_BINARY=y : Output formats: ELF and raw binary STATUS: diff --git a/boards/arm/lpc214x/zp214xpa/scripts/Make.defs b/boards/arm/lpc214x/zp214xpa/scripts/Make.defs index b7baeffa5e2fe..42c4add794e7a 100644 --- a/boards/arm/lpc214x/zp214xpa/scripts/Make.defs +++ b/boards/arm/lpc214x/zp214xpa/scripts/Make.defs @@ -45,18 +45,12 @@ ifeq ("${CONFIG_DEBUG_FEATURES}","y") ARCHOPTIMIZATION = -g endif -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - ifeq ($(OLDGCC),n) ARCHCPUFLAGS = -mcpu=arm7tdmi -mfloat-abi=soft else ARCHCPUFLAGS = -mapcs-32 -mcpu=arm7tdmi -msoft-float endif -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef diff --git a/boards/arm/lpc2378/olimex-lpc2378/scripts/Make.defs b/boards/arm/lpc2378/olimex-lpc2378/scripts/Make.defs index af5f3ad6359af..5a7f201582c26 100644 --- a/boards/arm/lpc2378/olimex-lpc2378/scripts/Make.defs +++ b/boards/arm/lpc2378/olimex-lpc2378/scripts/Make.defs @@ -45,18 +45,12 @@ ifeq ("${CONFIG_DEBUG_FEATURES}","y") ARCHOPTIMIZATION = -g endif -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - ifeq ($(OLDGCC),n) ARCHCPUFLAGS = -mcpu=arm7tdmi -mfloat-abi=soft else ARCHCPUFLAGS = -mapcs-32 -mcpu=arm7tdmi -msoft-float endif -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef diff --git a/boards/arm/lpc31xx/ea3131/README.txt b/boards/arm/lpc31xx/ea3131/README.txt index 6611d0595c695..5b3b158dbebc9 100644 --- a/boards/arm/lpc31xx/ea3131/README.txt +++ b/boards/arm/lpc31xx/ea3131/README.txt @@ -39,7 +39,7 @@ GNU Toolchain Options a different toolchain, you simply need to modify the configuration. As an example: - CONFIG_ARM_TOOLCHAIN_GNU_EABIL : Generic arm-none-eabi toolchain + CONFIG_ARM_TOOLCHAIN_GNU_EABI : Generic arm-none-eabi toolchain Generic arm-none-eabi GNU Toolchain ----------------------------------- @@ -560,7 +560,7 @@ Common Configuration Notes CONFIG_HOST_WINDOWS=y CONFIG_WINDOWS_CYGWIN=y - CONFIG_ARM_TOOLCHAIN_GNU_EABIW=y + CONFIG_ARM_TOOLCHAIN_GNU_EABI=y Configuration Sub-Directories ----------------------------- diff --git a/boards/arm/lpc31xx/ea3131/configs/pgnsh/Make.defs b/boards/arm/lpc31xx/ea3131/configs/pgnsh/Make.defs index 4d626814837e4..cab21868eff4e 100644 --- a/boards/arm/lpc31xx/ea3131/configs/pgnsh/Make.defs +++ b/boards/arm/lpc31xx/ea3131/configs/pgnsh/Make.defs @@ -35,22 +35,12 @@ else OLDGCC = n endif -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - ifeq ($(OLDGCC),n) ARCHCPUFLAGS = -mtune=arm9tdmi -march=armv5te -mfloat-abi=soft else ARCHCPUFLAGS = -mapcs-32 -mtune=arm9tdmi -march=armv5te -msoft-float endif -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 @@ -65,7 +55,3 @@ AFLAGS := $(CFLAGS) -D__ASSEMBLY__ NXFLATLDFLAGS1 = -r -d -warn-common NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-gotoff.ld -no-check-sections LDNXFLATFLAGS = -e main -s 2048 - -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - LDFLAGS += -g -endif diff --git a/boards/arm/lpc31xx/ea3131/scripts/Make.defs b/boards/arm/lpc31xx/ea3131/scripts/Make.defs index 670a561bedded..2d1f6d142215b 100644 --- a/boards/arm/lpc31xx/ea3131/scripts/Make.defs +++ b/boards/arm/lpc31xx/ea3131/scripts/Make.defs @@ -35,22 +35,12 @@ else OLDGCC = n endif -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - ifeq ($(OLDGCC),n) ARCHCPUFLAGS = -mtune=arm9tdmi -march=armv5te -mfloat-abi=soft else ARCHCPUFLAGS = -mapcs-32 -mtune=arm9tdmi -march=armv5te -msoft-float endif -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 @@ -65,7 +55,3 @@ AFLAGS := $(CFLAGS) -D__ASSEMBLY__ NXFLATLDFLAGS1 = -r -d -warn-common NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-gotoff.ld -no-check-sections LDNXFLATFLAGS = -e main -s 2048 - -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - LDFLAGS += -g -endif diff --git a/boards/arm/lpc31xx/ea3152/README.txt b/boards/arm/lpc31xx/ea3152/README.txt index fc23d8f38fe68..cca794694c4fc 100644 --- a/boards/arm/lpc31xx/ea3152/README.txt +++ b/boards/arm/lpc31xx/ea3152/README.txt @@ -38,7 +38,7 @@ GNU Toolchain Options a different toolchain, you simply need to modify the configuration. As an example: - CONFIG_ARM_TOOLCHAIN_GNU_EABIL : Generic arm-none-eabi toolchain + CONFIG_ARM_TOOLCHAIN_GNU_EABI : Generic arm-none-eabi toolchain Generic arm-none-eabi GNU Toolchain ----------------------------------- diff --git a/boards/arm/lpc31xx/ea3152/scripts/Make.defs b/boards/arm/lpc31xx/ea3152/scripts/Make.defs index 9ecec2188b6a8..7b6b05803c27d 100644 --- a/boards/arm/lpc31xx/ea3152/scripts/Make.defs +++ b/boards/arm/lpc31xx/ea3152/scripts/Make.defs @@ -35,22 +35,12 @@ else OLDGCC = n endif -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - ifeq ($(OLDGCC),n) ARCHCPUFLAGS = -mtune=arm9tdmi -march=armv5te -mfloat-abi=soft else ARCHCPUFLAGS = -mapcs-32 -mtune=arm9tdmi -march=armv5te -msoft-float endif -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 @@ -65,7 +55,3 @@ AFLAGS := $(CFLAGS) -D__ASSEMBLY__ NXFLATLDFLAGS1 = -r -d -warn-common NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-gotoff.ld -no-check-sections LDNXFLATFLAGS = -e main -s 2048 - -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - LDFLAGS += -g -endif diff --git a/boards/arm/lpc31xx/olimex-lpc-h3131/README.txt b/boards/arm/lpc31xx/olimex-lpc-h3131/README.txt index cb0cef645aff3..2b1a411c863ed 100644 --- a/boards/arm/lpc31xx/olimex-lpc-h3131/README.txt +++ b/boards/arm/lpc31xx/olimex-lpc-h3131/README.txt @@ -43,7 +43,7 @@ GNU Toolchain Options a different toolchain, you simply need to modify the configuration. As an example: - CONFIG_ARM_TOOLCHAIN_GNU_EABIL : Generic arm-none-eabi toolchain + CONFIG_ARM_TOOLCHAIN_GNU_EABI : Generic arm-none-eabi toolchain Generic arm-none-eabi GNU Toolchain ----------------------------------- @@ -478,7 +478,7 @@ Configurations CONFIG_WINDOWS_CYGWIN=y : Using Cygwin or other POSIX environment System Type -> Toolchain: - CONFIG_ARM_TOOLCHAIN_GNU_EABIW=y : GNU EABI toolchain for windows + CONFIG_ARM_TOOLCHAIN_GNU_EABI=y : GNU EABI toolchain for windows Configuration sub-directories ----------------------------- diff --git a/boards/arm/lpc31xx/olimex-lpc-h3131/scripts/Make.defs b/boards/arm/lpc31xx/olimex-lpc-h3131/scripts/Make.defs index a0d25f979f782..e158b20e969ba 100644 --- a/boards/arm/lpc31xx/olimex-lpc-h3131/scripts/Make.defs +++ b/boards/arm/lpc31xx/olimex-lpc-h3131/scripts/Make.defs @@ -35,22 +35,12 @@ else OLDGCC = n endif -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - ifeq ($(OLDGCC),n) ARCHCPUFLAGS = -mtune=arm9tdmi -march=armv5te -mfloat-abi=soft else ARCHCPUFLAGS = -mapcs-32 -mtune=arm9tdmi -march=armv5te -msoft-float endif -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 @@ -65,7 +55,3 @@ AFLAGS := $(CFLAGS) -D__ASSEMBLY__ NXFLATLDFLAGS1 = -r -d -warn-common NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-gotoff.ld -no-check-sections LDNXFLATFLAGS = -e main -s 2048 - -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - LDFLAGS += -g -endif diff --git a/boards/arm/lpc43xx/bambino-200e/README.txt b/boards/arm/lpc43xx/bambino-200e/README.txt index a33fd3079e1ad..717cb258a65a2 100644 --- a/boards/arm/lpc43xx/bambino-200e/README.txt +++ b/boards/arm/lpc43xx/bambino-200e/README.txt @@ -109,7 +109,6 @@ ports. file: CONFIG_ARCH_FPU=y - CONFIG_ARMV7M_LAZYFPU=y Bambino-200e Configuration Options ================================== @@ -416,7 +415,7 @@ Where is one of the following: SRAM. CONFIG_LPC43_BOOT_SRAM=y : Executing in SRAM - CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIW=y : GNU EABI toolchain for Windows + CONFIG_ARMV7M_TOOLCHAIN_GNU_EABI=y : GNU EABI toolchain for Windows 3. To execute from SPIFI, you would need to set: diff --git a/boards/arm/lpc43xx/bambino-200e/scripts/Make.defs b/boards/arm/lpc43xx/bambino-200e/scripts/Make.defs index b25f7f9217ad6..5470efa3a8f48 100644 --- a/boards/arm/lpc43xx/bambino-200e/scripts/Make.defs +++ b/boards/arm/lpc43xx/bambino-200e/scripts/Make.defs @@ -42,16 +42,6 @@ endif ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT) -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new -fno-rtti ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 @@ -68,7 +58,3 @@ NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-pcrel LDNXFLATFLAGS = -e main -s 2048 EXEEXT = .elf - -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - LDFLAGS += -g -endif diff --git a/boards/arm/lpc43xx/bambino-200e/src/Makefile b/boards/arm/lpc43xx/bambino-200e/src/Makefile index 5f07e77ee2ad8..a38320c0298e5 100644 --- a/boards/arm/lpc43xx/bambino-200e/src/Makefile +++ b/boards/arm/lpc43xx/bambino-200e/src/Makefile @@ -30,10 +30,6 @@ ifeq ($(CONFIG_BOARDCTL),y) CSRCS += lpc43_appinit.c endif -ifeq ($(CONFIG_ARCH_FPU),y) -CSRCS += lpc43_ostest.c -endif - ifeq ($(CONFIG_ARCH_LEDS),y) CSRCS += lpc43_autoleds.c else diff --git a/boards/arm/lpc43xx/bambino-200e/src/lpc43_ostest.c b/boards/arm/lpc43xx/bambino-200e/src/lpc43_ostest.c deleted file mode 100644 index c0ef9b05a2b86..0000000000000 --- a/boards/arm/lpc43xx/bambino-200e/src/lpc43_ostest.c +++ /dev/null @@ -1,94 +0,0 @@ -/**************************************************************************** - * boards/arm/lpc43xx/bambino-200e/src/lpc43_ostest.c - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. The - * ASF licenses this file to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance with the - * License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - ****************************************************************************/ - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include - -#include -#include -#include -#include - -#include -#include - -#include "arm_internal.h" -#include "bambino-200e.h" - -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -/* Configuration ************************************************************/ - -#undef HAVE_FPU -#if defined(CONFIG_ARCH_FPU) && defined(CONFIG_TESTING_OSTEST_FPUSIZE) && \ - defined(CONFIG_SCHED_WAITPID) -# define HAVE_FPU 1 -#endif - -#ifdef HAVE_FPU - -#if CONFIG_TESTING_OSTEST_FPUSIZE != (4*SW_FPU_REGS) -# error "CONFIG_TESTING_OSTEST_FPUSIZE has the wrong size" -#endif - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -static uint32_t g_saveregs[XCPTCONTEXT_REGS]; - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/* Given an array of size CONFIG_TESTING_OSTEST_FPUSIZE, this function will - * return the current FPU registers. - */ - -void arch_getfpu(FAR uint32_t *fpusave) -{ - irqstate_t flags; - - /* Take a snapshot of the thread context right now */ - - flags = enter_critical_section(); - arm_saveusercontext(g_saveregs); - - /* Return only the floating register values */ - - memcpy(fpusave, &g_saveregs[REG_S0], (4*SW_FPU_REGS)); - leave_critical_section(flags); -} - -/* Given two arrays of size CONFIG_TESTING_OSTEST_FPUSIZE this function - * will compare them and return true if they are identical. - */ - -bool arch_cmpfpu(FAR const uint32_t *fpusave1, FAR const uint32_t *fpusave2) -{ - return memcmp(fpusave1, fpusave2, (4*SW_FPU_REGS)) == 0; -} - -#endif /* HAVE_FPU */ diff --git a/boards/arm/lpc43xx/lpc4330-xplorer/README.txt b/boards/arm/lpc43xx/lpc4330-xplorer/README.txt index 11ee94643e2e6..050e2883fa446 100644 --- a/boards/arm/lpc43xx/lpc4330-xplorer/README.txt +++ b/boards/arm/lpc43xx/lpc4330-xplorer/README.txt @@ -279,7 +279,7 @@ Code Red IDE/Tools from SRAM. CONFIG_LPC43_BOOT_SRAM=y : Executing in SRAM - CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIW=y : GNU EABI toolchain for Windows + CONFIG_ARMV7M_TOOLCHAIN_GNU_EABI=y : GNU EABI toolchain for Windows To execute from SPIFI, you would need to set: @@ -361,7 +361,6 @@ ports. file: CONFIG_ARCH_FPU=y - CONFIG_ARMV7M_LAZYFPU=y LPC4330-Xplorer Configuration Options ===================================== @@ -577,7 +576,7 @@ Where is one of the following: SRAM. CONFIG_LPC43_BOOT_SRAM=y : Executing in SRAM - CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIW=y : GNU EABI toolchain for Windows + CONFIG_ARMV7M_TOOLCHAIN_GNU_EABI=y : GNU EABI toolchain for Windows 3. To execute from SPIFI, you would need to set: diff --git a/boards/arm/lpc43xx/lpc4330-xplorer/scripts/Make.defs b/boards/arm/lpc43xx/lpc4330-xplorer/scripts/Make.defs index 878daecc209b8..ecfcc6e6584fb 100644 --- a/boards/arm/lpc43xx/lpc4330-xplorer/scripts/Make.defs +++ b/boards/arm/lpc43xx/lpc4330-xplorer/scripts/Make.defs @@ -42,16 +42,6 @@ endif ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT) -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new -fno-rtti ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 @@ -66,7 +56,3 @@ AFLAGS := $(CFLAGS) -D__ASSEMBLY__ NXFLATLDFLAGS1 = -r -d -warn-common NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-pcrel.ld -no-check-sections LDNXFLATFLAGS = -e main -s 2048 - -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - LDFLAGS += -g -endif diff --git a/boards/arm/lpc43xx/lpc4330-xplorer/src/Makefile b/boards/arm/lpc43xx/lpc4330-xplorer/src/Makefile index 8deabf2a3a2f0..4f02477a51fa3 100644 --- a/boards/arm/lpc43xx/lpc4330-xplorer/src/Makefile +++ b/boards/arm/lpc43xx/lpc4330-xplorer/src/Makefile @@ -26,10 +26,6 @@ ifeq ($(CONFIG_BOARDCTL),y) CSRCS += lpc43_appinit.c endif -ifeq ($(CONFIG_ARCH_FPU),y) -CSRCS += lpc43_ostest.c -endif - ifeq ($(CONFIG_ARCH_LEDS),y) CSRCS += lpc43_autoleds.c else diff --git a/boards/arm/lpc43xx/lpc4330-xplorer/src/lpc43_ostest.c b/boards/arm/lpc43xx/lpc4330-xplorer/src/lpc43_ostest.c deleted file mode 100644 index 9210a0a8daa65..0000000000000 --- a/boards/arm/lpc43xx/lpc4330-xplorer/src/lpc43_ostest.c +++ /dev/null @@ -1,98 +0,0 @@ -/**************************************************************************** - * boards/arm/lpc43xx/lpc4330-xplorer/src/lpc43_ostest.c - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. The - * ASF licenses this file to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance with the - * License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - ****************************************************************************/ - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include - -#include -#include -#include -#include - -#include -#include - -#include "arm_internal.h" -#include "lpc4330-xplorer.h" - -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -/* Configuration ************************************************************/ - -#undef HAVE_FPU -#if defined(CONFIG_ARCH_FPU) && defined(CONFIG_TESTING_OSTEST_FPUSIZE) && \ - defined(CONFIG_SCHED_WAITPID) -# define HAVE_FPU 1 -#endif - -#ifdef HAVE_FPU - -#if CONFIG_TESTING_OSTEST_FPUSIZE != (4*SW_FPU_REGS) -# error "CONFIG_TESTING_OSTEST_FPUSIZE has the wrong size" -#endif - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -static uint32_t g_saveregs[XCPTCONTEXT_REGS]; - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/* Given an array of size CONFIG_TESTING_OSTEST_FPUSIZE, this function will - * return the current FPU registers. - */ - -void arch_getfpu(FAR uint32_t *fpusave) -{ - irqstate_t flags; - - /* Take a snapshot of the thread context right now */ - - flags = enter_critical_section(); - arm_saveusercontext(g_saveregs); - - /* Return only the floating register values */ - - memcpy(fpusave, &g_saveregs[REG_S0], (4*SW_FPU_REGS)); - leave_critical_section(flags); -} - -/* Given two arrays of size CONFIG_TESTING_OSTEST_FPUSIZE this function - * will compare them and return true if they are identical. - */ - -bool arch_cmpfpu(FAR const uint32_t *fpusave1, FAR const uint32_t *fpusave2) -{ - return memcmp(fpusave1, fpusave2, (4*SW_FPU_REGS)) == 0; -} - -#endif /* HAVE_FPU */ diff --git a/boards/arm/lpc43xx/lpc4337-ws/README.txt b/boards/arm/lpc43xx/lpc4337-ws/README.txt index ed61251cfe189..ddc30d7a0506d 100644 --- a/boards/arm/lpc43xx/lpc4337-ws/README.txt +++ b/boards/arm/lpc43xx/lpc4337-ws/README.txt @@ -275,7 +275,7 @@ Code Red IDE/Tools from SRAM. CONFIG_LPC43_BOOT_SRAM=y : Executing in SRAM - CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIW=y : GNU EABI toolchain for Windows + CONFIG_ARMV7M_TOOLCHAIN_GNU_EABI=y : GNU EABI toolchain for Windows To execute from SPIFI, you would need to set: @@ -400,7 +400,6 @@ ports. file: CONFIG_ARCH_FPU=y - CONFIG_ARMV7M_LAZYFPU=y LPC4337-ws Configuration Options ===================================== @@ -616,7 +615,7 @@ Where is one of the following: by setting the following configuration options. CONFIG_LPC43_BOOT_SRAM=y : Executing in SRAM - CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIW=y : GNU EABI toolchain for Windows + CONFIG_ARMV7M_TOOLCHAIN_GNU_EABI=y : GNU EABI toolchain for Windows 3. To execute from SPIFI, you would need to set: diff --git a/boards/arm/lpc43xx/lpc4337-ws/scripts/Make.defs b/boards/arm/lpc43xx/lpc4337-ws/scripts/Make.defs index 9fd2d5b118759..ba5cb6702f254 100644 --- a/boards/arm/lpc43xx/lpc4337-ws/scripts/Make.defs +++ b/boards/arm/lpc43xx/lpc4337-ws/scripts/Make.defs @@ -42,16 +42,6 @@ endif ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT) -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new -fno-rtti ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 @@ -66,7 +56,3 @@ AFLAGS := $(CFLAGS) -D__ASSEMBLY__ NXFLATLDFLAGS1 = -r -d -warn-common NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-pcrel.ld -no-check-sections LDNXFLATFLAGS = -e main -s 2048 - -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - LDFLAGS += -g -endif diff --git a/boards/arm/lpc43xx/lpc4357-evb/README.txt b/boards/arm/lpc43xx/lpc4357-evb/README.txt index 72bdfca85c913..ab5c327ff9685 100644 --- a/boards/arm/lpc43xx/lpc4357-evb/README.txt +++ b/boards/arm/lpc43xx/lpc4357-evb/README.txt @@ -272,7 +272,7 @@ Code Red IDE/Tools from SRAM. CONFIG_LPC43_BOOT_SRAM=y : Executing in SRAM - CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIL=y : GNU EABI toolchain for Linux + CONFIG_ARMV7M_TOOLCHAIN_GNU_EABI=y : GNU EABI toolchain for Linux To execute from SPIFI, you would need to set: @@ -397,7 +397,6 @@ ports. file: CONFIG_ARCH_FPU=y - CONFIG_ARMV7M_LAZYFPU=y LPC4357-EVB Configuration Options ===================================== @@ -613,7 +612,7 @@ Where is one of the following: by setting the following configuration options. CONFIG_LPC43_BOOT_SRAM=y : Executing in SRAM - CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIW=y : GNU EABI toolchain for Windows + CONFIG_ARMV7M_TOOLCHAIN_GNU_EABI=y : GNU EABI toolchain for Windows 3. To execute from SPIFI, you would need to set: diff --git a/boards/arm/lpc43xx/lpc4357-evb/scripts/Make.defs b/boards/arm/lpc43xx/lpc4357-evb/scripts/Make.defs index 4bb6b4994b6b3..f484a9e860c70 100644 --- a/boards/arm/lpc43xx/lpc4357-evb/scripts/Make.defs +++ b/boards/arm/lpc43xx/lpc4357-evb/scripts/Make.defs @@ -42,16 +42,6 @@ endif ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT) -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new -fno-rtti ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 @@ -66,7 +56,3 @@ AFLAGS := $(CFLAGS) -D__ASSEMBLY__ NXFLATLDFLAGS1 = -r -d -warn-common NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-pcrel.ld -no-check-sections LDNXFLATFLAGS = -e main -s 2048 - -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - LDFLAGS += -g -endif diff --git a/boards/arm/lpc43xx/lpc4357-evb/src/Makefile b/boards/arm/lpc43xx/lpc4357-evb/src/Makefile index b669b3cde451c..5e7eed653673a 100644 --- a/boards/arm/lpc43xx/lpc4357-evb/src/Makefile +++ b/boards/arm/lpc43xx/lpc4357-evb/src/Makefile @@ -26,10 +26,6 @@ ifeq ($(CONFIG_BOARDCTL),y) CSRCS += lpc43_appinit.c endif -ifeq ($(CONFIG_ARCH_FPU),y) -CSRCS += lpc43_ostest.c -endif - ifeq ($(CONFIG_ARCH_LEDS),y) CSRCS += lpc43_autoleds.c else diff --git a/boards/arm/lpc43xx/lpc4357-evb/src/lpc43_ostest.c b/boards/arm/lpc43xx/lpc4357-evb/src/lpc43_ostest.c deleted file mode 100644 index a45ba6f2fde28..0000000000000 --- a/boards/arm/lpc43xx/lpc4357-evb/src/lpc43_ostest.c +++ /dev/null @@ -1,98 +0,0 @@ -/**************************************************************************** - * boards/arm/lpc43xx/lpc4357-evb/src/lpc43_ostest.c - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. The - * ASF licenses this file to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance with the - * License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - ****************************************************************************/ - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include - -#include -#include -#include -#include - -#include -#include - -#include "arm_internal.h" -#include "lpc4357-evb.h" - -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -/* Configuration ************************************************************/ - -#undef HAVE_FPU -#if defined(CONFIG_ARCH_FPU) && defined(CONFIG_TESTING_OSTEST_FPUSIZE) && \ - defined(CONFIG_SCHED_WAITPID) -# define HAVE_FPU 1 -#endif - -#ifdef HAVE_FPU - -#if CONFIG_TESTING_OSTEST_FPUSIZE != (4*SW_FPU_REGS) -# error "CONFIG_TESTING_OSTEST_FPUSIZE has the wrong size" -#endif - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -static uint32_t g_saveregs[XCPTCONTEXT_REGS]; - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/* Given an array of size CONFIG_TESTING_OSTEST_FPUSIZE, this function - * will return the current FPU registers. - */ - -void arch_getfpu(FAR uint32_t *fpusave) -{ - irqstate_t flags; - - /* Take a snapshot of the thread context right now */ - - flags = enter_critical_section(); - arm_saveusercontext(g_saveregs); - - /* Return only the floating register values */ - - memcpy(fpusave, &g_saveregs[REG_S0], (4*SW_FPU_REGS)); - leave_critical_section(flags); -} - -/* Given two arrays of size CONFIG_TESTING_OSTEST_FPUSIZE this function - * will compare them and return true if they are identical. - */ - -bool arch_cmpfpu(FAR const uint32_t *fpusave1, FAR const uint32_t *fpusave2) -{ - return memcmp(fpusave1, fpusave2, (4*SW_FPU_REGS)) == 0; -} - -#endif /* HAVE_FPU */ diff --git a/boards/arm/lpc43xx/lpc4370-link2/README.txt b/boards/arm/lpc43xx/lpc4370-link2/README.txt index d6fecc5d05312..ee24ae0fa5213 100644 --- a/boards/arm/lpc43xx/lpc4370-link2/README.txt +++ b/boards/arm/lpc43xx/lpc4370-link2/README.txt @@ -275,7 +275,7 @@ Code Red IDE/Tools from SRAM. CONFIG_LPC43_BOOT_SRAM=y : Executing in SRAM - CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIW=y : GNU EABI toolchain for Windows + CONFIG_ARMV7M_TOOLCHAIN_GNU_EABI=y : GNU EABI toolchain for Windows To execute from SPIFI, you would need to set: @@ -400,7 +400,6 @@ ports. file: CONFIG_ARCH_FPU=y - CONFIG_ARMV7M_LAZYFPU=y LPC4370-Link2 Configuration Options ===================================== @@ -616,7 +615,7 @@ Where is one of the following: by setting the following configuration options. CONFIG_LPC43_BOOT_SRAM=y : Executing in SRAM - CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIW=y : GNU EABI toolchain for Windows + CONFIG_ARMV7M_TOOLCHAIN_GNU_EABI=y : GNU EABI toolchain for Windows 3. To execute from SPIFI, you would need to set: diff --git a/boards/arm/lpc43xx/lpc4370-link2/scripts/Make.defs b/boards/arm/lpc43xx/lpc4370-link2/scripts/Make.defs index 27992a92ac112..11420448198bc 100644 --- a/boards/arm/lpc43xx/lpc4370-link2/scripts/Make.defs +++ b/boards/arm/lpc43xx/lpc4370-link2/scripts/Make.defs @@ -42,16 +42,6 @@ endif ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT) -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new -fno-rtti ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 @@ -66,7 +56,3 @@ AFLAGS := $(CFLAGS) -D__ASSEMBLY__ NXFLATLDFLAGS1 = -r -d -warn-common NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-pcrel.ld -no-check-sections LDNXFLATFLAGS = -e main -s 2048 - -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - LDFLAGS += -g -endif diff --git a/boards/arm/lpc43xx/lpc4370-link2/src/Makefile b/boards/arm/lpc43xx/lpc4370-link2/src/Makefile index e251651d6efae..0f20f8dcd5a9b 100644 --- a/boards/arm/lpc43xx/lpc4370-link2/src/Makefile +++ b/boards/arm/lpc43xx/lpc4370-link2/src/Makefile @@ -26,10 +26,6 @@ ifeq ($(CONFIG_BOARDCTL),y) CSRCS += lpc43_appinit.c endif -ifeq ($(CONFIG_ARCH_FPU),y) -CSRCS += lpc43_ostest.c -endif - ifeq ($(CONFIG_ARCH_LEDS),y) CSRCS += lpc43_autoleds.c else diff --git a/boards/arm/lpc43xx/lpc4370-link2/src/lpc43_ostest.c b/boards/arm/lpc43xx/lpc4370-link2/src/lpc43_ostest.c deleted file mode 100644 index ac1b6973aaafe..0000000000000 --- a/boards/arm/lpc43xx/lpc4370-link2/src/lpc43_ostest.c +++ /dev/null @@ -1,98 +0,0 @@ -/**************************************************************************** - * boards/arm/lpc43xx/lpc4370-link2/src/lpc43_ostest.c - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. The - * ASF licenses this file to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance with the - * License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - ****************************************************************************/ - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include - -#include -#include -#include -#include - -#include -#include - -#include "arm_internal.h" -#include "lpc4370-link2.h" - -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -/* Configuration ************************************************************/ - -#undef HAVE_FPU -#if defined(CONFIG_ARCH_FPU) && defined(CONFIG_TESTING_OSTEST_FPUSIZE) && \ - defined(CONFIG_SCHED_WAITPID) -# define HAVE_FPU 1 -#endif - -#ifdef HAVE_FPU - -#if CONFIG_TESTING_OSTEST_FPUSIZE != (4*SW_FPU_REGS) -# error "CONFIG_TESTING_OSTEST_FPUSIZE has the wrong size" -#endif - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -static uint32_t g_saveregs[XCPTCONTEXT_REGS]; - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/* Given an array of size CONFIG_TESTING_OSTEST_FPUSIZE, this function will - * return the current FPU registers. - */ - -void arch_getfpu(FAR uint32_t *fpusave) -{ - irqstate_t flags; - - /* Take a snapshot of the thread context right now */ - - flags = enter_critical_section(); - arm_saveusercontext(g_saveregs); - - /* Return only the floating register values */ - - memcpy(fpusave, &g_saveregs[REG_S0], (4*SW_FPU_REGS)); - leave_critical_section(flags); -} - -/* Given two arrays of size CONFIG_TESTING_OSTEST_FPUSIZE this function - * will compare them and return true if they are identical. - */ - -bool arch_cmpfpu(FAR const uint32_t *fpusave1, FAR const uint32_t *fpusave2) -{ - return memcmp(fpusave1, fpusave2, (4*SW_FPU_REGS)) == 0; -} - -#endif /* HAVE_FPU */ diff --git a/boards/arm/lpc54xx/lpcxpresso-lpc54628/README.txt b/boards/arm/lpc54xx/lpcxpresso-lpc54628/README.txt index 78b019ae70fc6..bcbb0cb973754 100644 --- a/boards/arm/lpc54xx/lpcxpresso-lpc54628/README.txt +++ b/boards/arm/lpc54xx/lpcxpresso-lpc54628/README.txt @@ -185,7 +185,7 @@ Configurations CONFIG_WINDOWS_CYGWIN=y : Cywin under Windows System Type -> Toolchain: - CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIW=y : GNU ARM EABI toolchain + CONFIG_ARMV7M_TOOLCHAIN_GNU_EABI=y : GNU ARM EABI toolchain Configuration Sub-directories ----------------------------- diff --git a/boards/arm/lpc54xx/lpcxpresso-lpc54628/scripts/Make.defs b/boards/arm/lpc54xx/lpcxpresso-lpc54628/scripts/Make.defs index cdb029f64dd83..b67cf9c9eb3ee 100644 --- a/boards/arm/lpc54xx/lpcxpresso-lpc54628/scripts/Make.defs +++ b/boards/arm/lpc54xx/lpcxpresso-lpc54628/scripts/Make.defs @@ -25,19 +25,8 @@ include $(TOPDIR)/arch/arm/src/armv7-m/Toolchain.defs # Setup for the kind of memory that we are executing from LDSCRIPT = flash.ld - ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT) -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new -fno-rtti ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 @@ -52,7 +41,3 @@ AFLAGS := $(CFLAGS) -D__ASSEMBLY__ NXFLATLDFLAGS1 = -r -d -warn-common NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-pcrel.ld -no-check-sections LDNXFLATFLAGS = -e main -s 2048 - -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - LDFLAGS += -g -endif diff --git a/boards/arm/max326xx/max32660-evsys/configs/nsh/defconfig b/boards/arm/max326xx/max32660-evsys/configs/nsh/defconfig index d0240f8fb3864..583bd750d3528 100644 --- a/boards/arm/max326xx/max32660-evsys/configs/nsh/defconfig +++ b/boards/arm/max326xx/max32660-evsys/configs/nsh/defconfig @@ -15,7 +15,6 @@ CONFIG_ARCH_CHIP_MAX326XX=y CONFIG_ARCH_INTERRUPTSTACK=2048 CONFIG_ARCH_IRQBUTTONS=y CONFIG_ARCH_STACKDUMP=y -CONFIG_ARMV7M_LAZYFPU=y CONFIG_ARMV7M_USEBASEPRI=y CONFIG_BOARD_LOOPSPERMSEC=8192 CONFIG_BUILTIN=y diff --git a/boards/arm/max326xx/max32660-evsys/scripts/Make.defs b/boards/arm/max326xx/max32660-evsys/scripts/Make.defs index a0b7ffa9b5aef..eb20fbb2a55fc 100644 --- a/boards/arm/max326xx/max32660-evsys/scripts/Make.defs +++ b/boards/arm/max326xx/max32660-evsys/scripts/Make.defs @@ -30,17 +30,7 @@ endif ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT) -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -endif - -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new -fno-rtti -ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef -fno-strict-aliasing +ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 @@ -61,7 +51,3 @@ CMODULEFLAGS = $(CFLAGS) -mlong-calls # --target1-abs LDMODULEFLAGS = -r -e module_initialize LDMODULEFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)/libs/libc/modlib/gnu-elf.ld) - -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - LDFLAGS += -g -endif diff --git a/boards/arm/moxart/moxa/scripts/Make.defs b/boards/arm/moxart/moxa/scripts/Make.defs index 8e4e28041e016..26b99bca5a98e 100644 --- a/boards/arm/moxart/moxa/scripts/Make.defs +++ b/boards/arm/moxart/moxa/scripts/Make.defs @@ -24,16 +24,8 @@ include $(TOPDIR)/arch/arm/src/armv7-m/Toolchain.defs ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)moxa.ld -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - -ARCHCFLAGS = -fno-common -mno-thumb-interwork -march=armv4 -Uarm -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new -mno-thumb-interwork -march=armv4 -Uarm +ARCHCFLAGS += -mno-thumb-interwork -march=armv4 -Uarm +ARCHCXXFLAGS += -mno-thumb-interwork -march=armv4 -Uarm ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 @@ -51,7 +43,3 @@ LDNXFLAT = ldnxflat NXFLATLDFLAGS1 = -r -d -warn-common NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-pcrel.ld -no-check-sections LDNXFLATFLAGS = -e main -s 2048 - -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - LDFLAGS += -g -endif diff --git a/boards/arm/nrf52/nrf52-feather/scripts/Make.defs b/boards/arm/nrf52/nrf52-feather/scripts/Make.defs index 46c70d0d9486e..28efa46eabedf 100644 --- a/boards/arm/nrf52/nrf52-feather/scripts/Make.defs +++ b/boards/arm/nrf52/nrf52-feather/scripts/Make.defs @@ -23,19 +23,8 @@ include $(TOPDIR)/tools/Config.mk include $(TOPDIR)/arch/arm/src/armv7-m/Toolchain.defs LDSCRIPT = flash_config.ld - ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT) -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new -fno-rtti ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 @@ -50,7 +39,3 @@ AFLAGS := $(CFLAGS) -D__ASSEMBLY__ NXFLATLDFLAGS1 = -r -d -warn-common NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-pcrel.ld -no-check-sections LDNXFLATFLAGS = -e main -s 2048 - -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - LDFLAGS += -g -endif diff --git a/boards/arm/nrf52/nrf52832-dk/scripts/Make.defs b/boards/arm/nrf52/nrf52832-dk/scripts/Make.defs index d5496d6615ac0..4f7cb77cbe560 100644 --- a/boards/arm/nrf52/nrf52832-dk/scripts/Make.defs +++ b/boards/arm/nrf52/nrf52832-dk/scripts/Make.defs @@ -23,19 +23,8 @@ include $(TOPDIR)/tools/Config.mk include $(TOPDIR)/arch/arm/src/armv7-m/Toolchain.defs LDSCRIPT = flash_config.ld - ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT) -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new -fno-rtti ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 @@ -50,7 +39,3 @@ AFLAGS := $(CFLAGS) -D__ASSEMBLY__ NXFLATLDFLAGS1 = -r -d -warn-common NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-pcrel.ld -no-check-sections LDNXFLATFLAGS = -e main -s 2048 - -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - LDFLAGS += -g -endif diff --git a/boards/arm/nrf52/nrf52832-dk/src/nrf52_boot.c b/boards/arm/nrf52/nrf52832-dk/src/nrf52_boot.c index 4472e2d2a244f..a23cf76ca90c1 100644 --- a/boards/arm/nrf52/nrf52832-dk/src/nrf52_boot.c +++ b/boards/arm/nrf52/nrf52832-dk/src/nrf52_boot.c @@ -74,6 +74,6 @@ void board_late_initialize(void) { /* Perform board-specific initialization */ - (void)nrf52_bringup(); + nrf52_bringup(); } #endif diff --git a/boards/arm/nrf52/nrf52832-mdk/scripts/Make.defs b/boards/arm/nrf52/nrf52832-mdk/scripts/Make.defs index cc92c6ef6cfaf..d4ef530d868ae 100644 --- a/boards/arm/nrf52/nrf52832-mdk/scripts/Make.defs +++ b/boards/arm/nrf52/nrf52832-mdk/scripts/Make.defs @@ -23,7 +23,6 @@ include $(TOPDIR)/tools/Config.mk include $(TOPDIR)/arch/arm/src/armv7-m/Toolchain.defs LDSCRIPT = flash_config.ld - ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT) CC = $(CROSSDEV)gcc @@ -39,16 +38,6 @@ OBJDUMP = $(CROSSDEV)objdump ARCHCCVERSION = ${shell $(CC) -v 2>&1 | sed -n '/^gcc version/p' | sed -e 's/^gcc version \([0-9\.]\)/\1/g' -e 's/[-\ ].*//g' -e '1q'} ARCHCCMAJOR = ${shell echo $(ARCHCCVERSION) | cut -d'.' -f1} -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new -fno-rtti ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 @@ -63,7 +52,3 @@ AFLAGS := $(CFLAGS) -D__ASSEMBLY__ NXFLATLDFLAGS1 = -r -d -warn-common NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-pcrel.ld -no-check-sections LDNXFLATFLAGS = -e main -s 2048 - -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - LDFLAGS += -g -endif diff --git a/boards/arm/nrf52/nrf52832-sparkfun/scripts/Make.defs b/boards/arm/nrf52/nrf52832-sparkfun/scripts/Make.defs index fa8be1f5ddc23..2cfb08e3a3fd0 100644 --- a/boards/arm/nrf52/nrf52832-sparkfun/scripts/Make.defs +++ b/boards/arm/nrf52/nrf52832-sparkfun/scripts/Make.defs @@ -23,7 +23,6 @@ include $(TOPDIR)/tools/Config.mk include $(TOPDIR)/arch/arm/src/armv7-m/Toolchain.defs LDSCRIPT = flash_config.ld - ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT) CC = $(CROSSDEV)gcc @@ -39,16 +38,6 @@ OBJDUMP = $(CROSSDEV)objdump ARCHCCVERSION = ${shell $(CC) -v 2>&1 | sed -n '/^gcc version/p' | sed -e 's/^gcc version \([0-9\.]\)/\1/g' -e 's/[-\ ].*//g' -e '1q'} ARCHCCMAJOR = ${shell echo $(ARCHCCVERSION) | cut -d'.' -f1} -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new -fno-rtti ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 @@ -63,7 +52,3 @@ AFLAGS := $(CFLAGS) -D__ASSEMBLY__ NXFLATLDFLAGS1 = -r -d -warn-common NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-pcrel.ld -no-check-sections LDNXFLATFLAGS = -e main -s 2048 - -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - LDFLAGS += -g -endif diff --git a/boards/arm/nrf52/nrf52840-dk/scripts/Make.defs b/boards/arm/nrf52/nrf52840-dk/scripts/Make.defs index 064781486e1da..bf2c2f5be1f6f 100644 --- a/boards/arm/nrf52/nrf52840-dk/scripts/Make.defs +++ b/boards/arm/nrf52/nrf52840-dk/scripts/Make.defs @@ -23,19 +23,8 @@ include $(TOPDIR)/tools/Config.mk include $(TOPDIR)/arch/arm/src/armv7-m/Toolchain.defs LDSCRIPT = flash_config.ld - ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT) -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new -fno-rtti ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 @@ -50,7 +39,3 @@ AFLAGS := $(CFLAGS) -D__ASSEMBLY__ NXFLATLDFLAGS1 = -r -d -warn-common NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-pcrel.ld -no-check-sections LDNXFLATFLAGS = -e main -s 2048 - -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - LDFLAGS += -g -endif diff --git a/boards/arm/nrf52/nrf52840-dk/src/nrf52_boot.c b/boards/arm/nrf52/nrf52840-dk/src/nrf52_boot.c index 5afb11b033c67..5be5ac107f73b 100644 --- a/boards/arm/nrf52/nrf52840-dk/src/nrf52_boot.c +++ b/boards/arm/nrf52/nrf52840-dk/src/nrf52_boot.c @@ -80,6 +80,6 @@ void board_late_initialize(void) { /* Perform board-specific initialization */ - (void)nrf52_bringup(); + nrf52_bringup(); } #endif diff --git a/boards/arm/nrf52/nrf52840-dongle/scripts/Make.defs b/boards/arm/nrf52/nrf52840-dongle/scripts/Make.defs index f12730dd33b40..7ad5d695f5601 100644 --- a/boards/arm/nrf52/nrf52840-dongle/scripts/Make.defs +++ b/boards/arm/nrf52/nrf52840-dongle/scripts/Make.defs @@ -23,19 +23,8 @@ include $(TOPDIR)/tools/Config.mk include $(TOPDIR)/arch/arm/src/armv7-m/Toolchain.defs LDSCRIPT = flash_config.ld - ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT) -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new -fno-rtti ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 @@ -50,7 +39,3 @@ AFLAGS := $(CFLAGS) -D__ASSEMBLY__ NXFLATLDFLAGS1 = -r -d -warn-common NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-pcrel.ld -no-check-sections LDNXFLATFLAGS = -e main -s 2048 - -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - LDFLAGS += -g -endif diff --git a/boards/arm/nrf52/nrf52840-dongle/src/nrf52_boot.c b/boards/arm/nrf52/nrf52840-dongle/src/nrf52_boot.c index a0230a1bd7496..46ccebde21b46 100644 --- a/boards/arm/nrf52/nrf52840-dongle/src/nrf52_boot.c +++ b/boards/arm/nrf52/nrf52840-dongle/src/nrf52_boot.c @@ -74,6 +74,6 @@ void board_late_initialize(void) { /* Perform board-specific initialization */ - (void)nrf52_bringup(); + nrf52_bringup(); } #endif diff --git a/boards/arm/nuc1xx/nutiny-nuc120/README.txt b/boards/arm/nuc1xx/nutiny-nuc120/README.txt index 34414f4d4866c..5d57da2ef6984 100644 --- a/boards/arm/nuc1xx/nutiny-nuc120/README.txt +++ b/boards/arm/nuc1xx/nutiny-nuc120/README.txt @@ -287,7 +287,7 @@ Where is one of the following: CONFIG_HOST_WINDOWS=y : Builds under Windows CONFIG_WINDOWS_CYGWIN=y : Using Cygwin - CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIW=y : GNU EABI toolchain for Windows + CONFIG_ARMV7M_TOOLCHAIN_GNU_EABI=y : GNU EABI toolchain for Windows 3. Serial Console. A serial console is necessary to interrupt with NSH. The serial console is configured on UART1 which is available diff --git a/boards/arm/nuc1xx/nutiny-nuc120/scripts/Make.defs b/boards/arm/nuc1xx/nutiny-nuc120/scripts/Make.defs index ce4fffb1e7b8a..cbde66be36e8d 100644 --- a/boards/arm/nuc1xx/nutiny-nuc120/scripts/Make.defs +++ b/boards/arm/nuc1xx/nutiny-nuc120/scripts/Make.defs @@ -23,19 +23,8 @@ include $(TOPDIR)/tools/Config.mk include $(TOPDIR)/arch/arm/src/armv6-m/Toolchain.defs LDSCRIPT = nutiny-nuc120.ld - ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT) -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new -fno-rtti ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 @@ -50,7 +39,3 @@ AFLAGS := $(CFLAGS) -D__ASSEMBLY__ NXFLATLDFLAGS1 = -r -d -warn-common NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-pcrel.ld -no-check-sections LDNXFLATFLAGS = -e main -s 2048 - -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - LDFLAGS += -g -endif diff --git a/boards/arm/phy62xx/phy6222/scripts/Make.defs b/boards/arm/phy62xx/phy6222/scripts/Make.defs index 47798d52ef146..fce54b60e09cc 100644 --- a/boards/arm/phy62xx/phy6222/scripts/Make.defs +++ b/boards/arm/phy62xx/phy6222/scripts/Make.defs @@ -23,19 +23,8 @@ include $(TOPDIR)/tools/Config.mk include $(TOPDIR)/arch/arm/src/armv6-m/Toolchain.defs LDSCRIPT = flash.ld - ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT) -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new -fno-rtti ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 @@ -47,14 +36,8 @@ CXXPICFLAGS = $(ARCHPICFLAGS) $(CXXFLAGS) CPPFLAGS := $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) AFLAGS := $(CFLAGS) -D__ASSEMBLY__ -CFLAGS += -ffunction-sections -fdata-sections +CFLAGS += NXFLATLDFLAGS1 = -r -Wl,-d -Wl,-warn-common NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-pcrel.ld -Wl,-no-check-sections LDNXFLATFLAGS = -e main -s 2048 - -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - LDFLAGS += -g -endif - -LDFLAGS += --gc-sections diff --git a/boards/arm/phy62xx/phy6222/scripts/gnu-elf.ld b/boards/arm/phy62xx/phy6222/scripts/gnu-elf.ld deleted file mode 100644 index b7371d8265fc6..0000000000000 --- a/boards/arm/phy62xx/phy6222/scripts/gnu-elf.ld +++ /dev/null @@ -1,116 +0,0 @@ -/**************************************************************************** - * boards/arm/stm32f0l0g0/stm32f051-discovery/scripts/gnu-elf.ld - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. The - * ASF licenses this file to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance with the - * License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - ****************************************************************************/ - -SECTIONS -{ - .text 0x00000000 : - { - _stext = . ; - *(.text) - *(.text.*) - *(.gnu.warning) - *(.stub) - *(.glue_7) - *(.glue_7t) - *(.jcr) - - /* C++ support: The .init and .fini sections contain specific logic - * to manage static constructors and destructors. - */ - - *(.gnu.linkonce.t.*) - *(.init) /* Old ABI */ - *(.fini) /* Old ABI */ - _etext = . ; - } - - .rodata : - { - _srodata = . ; - *(.rodata) - *(.rodata1) - *(.rodata.*) - *(.gnu.linkonce.r*) - _erodata = . ; - } - - .data : - { - _sdata = . ; - *(.data) - *(.data1) - *(.data.*) - *(.gnu.linkonce.d*) - . = ALIGN(4); - _edata = . ; - } - - /* C++ support. For each global and static local C++ object, - * GCC creates a small subroutine to construct the object. Pointers - * to these routines (not the routines themselves) are stored as - * simple, linear arrays in the .ctors section of the object file. - * Similarly, pointers to global/static destructor routines are - * stored in .dtors. - */ - - .ctors : - { - _sctors = . ; - *(.ctors) /* Old ABI: Unallocated */ - *(.init_array) /* New ABI: Allocated */ - _edtors = . ; - } - - .dtors : - { - _sdtors = . ; - *(.dtors) /* Old ABI: Unallocated */ - *(.fini_array) /* New ABI: Allocated */ - _edtors = . ; - } - - .bss : - { - _sbss = . ; - *(.bss) - *(.bss.*) - *(.sbss) - *(.sbss.*) - *(.gnu.linkonce.b*) - *(COMMON) - . = ALIGN(4); - _ebss = . ; - } - - /* Stabs debugging sections. */ - - .stab 0 : { *(.stab) } - .stabstr 0 : { *(.stabstr) } - .stab.excl 0 : { *(.stab.excl) } - .stab.exclstr 0 : { *(.stab.exclstr) } - .stab.index 0 : { *(.stab.index) } - .stab.indexstr 0 : { *(.stab.indexstr) } - .comment 0 : { *(.comment) } - .debug_abbrev 0 : { *(.debug_abbrev) } - .debug_info 0 : { *(.debug_info) } - .debug_line 0 : { *(.debug_line) } - .debug_pubnames 0 : { *(.debug_pubnames) } - .debug_aranges 0 : { *(.debug_aranges) } -} diff --git a/boards/arm/rp2040/pimoroni-tiny2040/scripts/Make.defs b/boards/arm/rp2040/pimoroni-tiny2040/scripts/Make.defs index 46ac0e8b8c8dd..a9423daedeab6 100644 --- a/boards/arm/rp2040/pimoroni-tiny2040/scripts/Make.defs +++ b/boards/arm/rp2040/pimoroni-tiny2040/scripts/Make.defs @@ -31,16 +31,6 @@ endif ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT) -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new -fno-rtti ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 @@ -55,7 +45,3 @@ AFLAGS := $(CFLAGS) -D__ASSEMBLY__ NXFLATLDFLAGS1 = -r -d -warn-common NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-pcrel.ld -no-check-sections LDNXFLATFLAGS = -e main -s 2048 - -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - LDFLAGS += -g -endif diff --git a/boards/arm/rp2040/raspberrypi-pico/scripts/Make.defs b/boards/arm/rp2040/raspberrypi-pico/scripts/Make.defs index 485d5c0c9a9a0..0daad7ed08333 100644 --- a/boards/arm/rp2040/raspberrypi-pico/scripts/Make.defs +++ b/boards/arm/rp2040/raspberrypi-pico/scripts/Make.defs @@ -31,16 +31,6 @@ endif ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT) -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new -fno-rtti ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 @@ -55,7 +45,3 @@ AFLAGS := $(CFLAGS) -D__ASSEMBLY__ NXFLATLDFLAGS1 = -r -d -warn-common NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-pcrel.ld -no-check-sections LDNXFLATFLAGS = -e main -s 2048 - -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - LDFLAGS += -g -endif diff --git a/boards/arm/s32k1xx/s32k118evb/scripts/Make.defs b/boards/arm/s32k1xx/s32k118evb/scripts/Make.defs index bbbadeb2a7ba9..bb1de6efaf532 100644 --- a/boards/arm/s32k1xx/s32k118evb/scripts/Make.defs +++ b/boards/arm/s32k1xx/s32k118evb/scripts/Make.defs @@ -23,19 +23,8 @@ include $(TOPDIR)/tools/Config.mk include $(TOPDIR)/arch/arm/src/armv6-m/Toolchain.defs LDSCRIPT = flash.ld - ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT) -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new -fno-rtti ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 @@ -50,7 +39,3 @@ AFLAGS := $(CFLAGS) -D__ASSEMBLY__ NXFLATLDFLAGS1 = -r -d -warn-common NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-pcrel.ld -no-check-sections LDNXFLATFLAGS = -e main -s 2048 - -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - LDFLAGS += -g -endif diff --git a/boards/arm/s32k1xx/s32k144evb/scripts/Make.defs b/boards/arm/s32k1xx/s32k144evb/scripts/Make.defs index a2820790f3a86..650dbbb078b55 100644 --- a/boards/arm/s32k1xx/s32k144evb/scripts/Make.defs +++ b/boards/arm/s32k1xx/s32k144evb/scripts/Make.defs @@ -33,16 +33,6 @@ ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT) $(warning, LDSCRIPT is $(LDSCRIPT)) $(warning, ARCHSCRIPT is $(ARCHSCRIPT)) -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new -fno-rtti ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 @@ -57,7 +47,3 @@ AFLAGS := $(CFLAGS) -D__ASSEMBLY__ NXFLATLDFLAGS1 = -r -d -warn-common NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-pcrel.ld -no-check-sections LDNXFLATFLAGS = -e main -s 2048 - -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - LDFLAGS += -g -endif diff --git a/boards/arm/s32k1xx/s32k146evb/scripts/Make.defs b/boards/arm/s32k1xx/s32k146evb/scripts/Make.defs index 602b4a59bd077..d5386d5d4d3a2 100644 --- a/boards/arm/s32k1xx/s32k146evb/scripts/Make.defs +++ b/boards/arm/s32k1xx/s32k146evb/scripts/Make.defs @@ -33,16 +33,6 @@ ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT) $(warning, LDSCRIPT is $(LDSCRIPT)) $(warning, ARCHSCRIPT is $(ARCHSCRIPT)) -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new -fno-rtti ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 @@ -57,7 +47,3 @@ AFLAGS := $(CFLAGS) -D__ASSEMBLY__ NXFLATLDFLAGS1 = -r -d -warn-common NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-pcrel.ld -no-check-sections LDNXFLATFLAGS = -e main -s 2048 - -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - LDFLAGS += -g -endif diff --git a/boards/arm/s32k1xx/s32k148evb/scripts/Make.defs b/boards/arm/s32k1xx/s32k148evb/scripts/Make.defs index e59bb776c5dac..641ec5ee14b06 100644 --- a/boards/arm/s32k1xx/s32k148evb/scripts/Make.defs +++ b/boards/arm/s32k1xx/s32k148evb/scripts/Make.defs @@ -33,16 +33,6 @@ ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT) $(warning, LDSCRIPT is $(LDSCRIPT)) $(warning, ARCHSCRIPT is $(ARCHSCRIPT)) -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new -fno-rtti ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 @@ -57,7 +47,3 @@ AFLAGS := $(CFLAGS) -D__ASSEMBLY__ NXFLATLDFLAGS1 = -r -d -warn-common NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-pcrel.ld -no-check-sections LDNXFLATFLAGS = -e main -s 2048 - -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - LDFLAGS += -g -endif diff --git a/boards/arm/s32k1xx/ucans32k146/scripts/Make.defs b/boards/arm/s32k1xx/ucans32k146/scripts/Make.defs index 985f35179f1d4..3dab858fc0266 100644 --- a/boards/arm/s32k1xx/ucans32k146/scripts/Make.defs +++ b/boards/arm/s32k1xx/ucans32k146/scripts/Make.defs @@ -33,16 +33,6 @@ ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT) $(warning, LDSCRIPT is $(LDSCRIPT)) $(warning, ARCHSCRIPT is $(ARCHSCRIPT)) -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new -fno-rtti ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 @@ -57,7 +47,3 @@ AFLAGS := $(CFLAGS) -D__ASSEMBLY__ NXFLATLDFLAGS1 = -r -d -warn-common NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-pcrel.ld -no-check-sections LDNXFLATFLAGS = -e main -s 2048 - -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - LDFLAGS += -g -endif diff --git a/boards/arm/sam34/arduino-due/README.txt b/boards/arm/sam34/arduino-due/README.txt index 957bbce6d5337..90dd165c91de9 100644 --- a/boards/arm/sam34/arduino-due/README.txt +++ b/boards/arm/sam34/arduino-due/README.txt @@ -710,7 +710,7 @@ Configurations CONFIG_HOST_CYGWIN=y : Using Cygwin or other POSIX environment System Type -> Toolchain: - CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIW=y : General GCC EABI toolchain under windows + CONFIG_ARMV7M_TOOLCHAIN_GNU_EABI=y : General GCC EABI toolchain under windows This re-configuration should be done before making NuttX or else the subsequent 'make' will fail. If you have already attempted building diff --git a/boards/arm/sam34/arduino-due/scripts/Make.defs b/boards/arm/sam34/arduino-due/scripts/Make.defs index 1aef29817b633..12af6df948d07 100644 --- a/boards/arm/sam34/arduino-due/scripts/Make.defs +++ b/boards/arm/sam34/arduino-due/scripts/Make.defs @@ -24,16 +24,6 @@ include $(TOPDIR)/arch/arm/src/armv7-m/Toolchain.defs ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)arduino-due.ld -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 @@ -48,7 +38,3 @@ AFLAGS := $(CFLAGS) -D__ASSEMBLY__ NXFLATLDFLAGS1 = -r -d -warn-common NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-pcrel.ld -no-check-sections LDNXFLATFLAGS = -e main -s 2048 - -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - LDFLAGS += -g -endif diff --git a/boards/arm/sam34/flipnclick-sam3x/README.txt b/boards/arm/sam34/flipnclick-sam3x/README.txt index 03871c3a05c79..42932a24a8c69 100644 --- a/boards/arm/sam34/flipnclick-sam3x/README.txt +++ b/boards/arm/sam34/flipnclick-sam3x/README.txt @@ -595,7 +595,7 @@ Configurations 'make menuconfig'. Here are the relevant current settings: System Type -> Toolchain: - CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIW=y : GNU ARM EABI toolchain for Windows + CONFIG_ARMV7M_TOOLCHAIN_GNU_EABI=y : GNU ARM EABI toolchain for Windows Configuration sub-directories ----------------------------- diff --git a/boards/arm/sam34/flipnclick-sam3x/scripts/Make.defs b/boards/arm/sam34/flipnclick-sam3x/scripts/Make.defs index 622d7d437b45b..f868fc2ff00a2 100644 --- a/boards/arm/sam34/flipnclick-sam3x/scripts/Make.defs +++ b/boards/arm/sam34/flipnclick-sam3x/scripts/Make.defs @@ -24,16 +24,6 @@ include $(TOPDIR)/arch/arm/src/armv7-m/Toolchain.defs ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)flash.ld -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 @@ -48,7 +38,3 @@ AFLAGS := $(CFLAGS) -D__ASSEMBLY__ NXFLATLDFLAGS1 = -r -d -warn-common NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-pcrel.ld -no-check-sections LDNXFLATFLAGS = -e main -s 2048 - -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - LDFLAGS += -g -endif diff --git a/boards/arm/sam34/sam3u-ek/README.txt b/boards/arm/sam34/sam3u-ek/README.txt index ede947c4c650e..f79123053e224 100644 --- a/boards/arm/sam34/sam3u-ek/README.txt +++ b/boards/arm/sam34/sam3u-ek/README.txt @@ -258,7 +258,7 @@ Configurations CONFIG_HOST_CYGWIN=y : Using Cygwin or other POSIX environment System Type -> Toolchain: - CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIW=y : General GCC EABI toolchain under windows + CONFIG_ARMV7M_TOOLCHAIN_GNU_EABI=y : General GCC EABI toolchain under windows Library Routines -> CONFIG_ARCH_SIZET_LONG=n : size_t is an unsigned int, not long diff --git a/boards/arm/sam34/sam3u-ek/configs/knsh/Make.defs b/boards/arm/sam34/sam3u-ek/configs/knsh/Make.defs index e1e5be1db32cd..1a4ac44ba4620 100644 --- a/boards/arm/sam34/sam3u-ek/configs/knsh/Make.defs +++ b/boards/arm/sam34/sam3u-ek/configs/knsh/Make.defs @@ -25,16 +25,6 @@ include $(TOPDIR)/arch/arm/src/armv7-m/Toolchain.defs ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)memory.ld ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)kernel-space.ld -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new -fno-rtti ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 @@ -49,7 +39,3 @@ AFLAGS := $(CFLAGS) -D__ASSEMBLY__ NXFLATLDFLAGS1 = -r -d -warn-common NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)$(DELIM)binfmt$(DELIM)libnxflat$(DELIM)gnu-nxflat-pcrel.ld -no-check-sections LDNXFLATFLAGS = -e main -s 2048 - -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - LDFLAGS += -g -endif diff --git a/boards/arm/sam34/sam3u-ek/scripts/Make.defs b/boards/arm/sam34/sam3u-ek/scripts/Make.defs index 44135f6b69719..b2f930effcb26 100644 --- a/boards/arm/sam34/sam3u-ek/scripts/Make.defs +++ b/boards/arm/sam34/sam3u-ek/scripts/Make.defs @@ -24,16 +24,6 @@ include $(TOPDIR)/arch/arm/src/armv7-m/Toolchain.defs ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)ld.script -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new -fno-rtti ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 @@ -48,7 +38,3 @@ AFLAGS := $(CFLAGS) -D__ASSEMBLY__ NXFLATLDFLAGS1 = -r -d -warn-common NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-pcrel.ld -no-check-sections LDNXFLATFLAGS = -e main -s 2048 - -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - LDFLAGS += -g -endif diff --git a/boards/arm/sam34/sam4cmp-db/scripts/Make.defs b/boards/arm/sam34/sam4cmp-db/scripts/Make.defs index bec03fa10f264..a01b6bcc20225 100644 --- a/boards/arm/sam34/sam4cmp-db/scripts/Make.defs +++ b/boards/arm/sam34/sam4cmp-db/scripts/Make.defs @@ -24,16 +24,6 @@ include $(TOPDIR)/arch/arm/src/armv7-m/Toolchain.defs ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)sam4cmp-db.ld -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 @@ -48,7 +38,3 @@ AFLAGS := $(CFLAGS) -D__ASSEMBLY__ NXFLATLDFLAGS1 = -r -d -warn-common NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-pcrel.ld -no-check-sections LDNXFLATFLAGS = -e main -s 2048 - -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - LDFLAGS += -g -endif diff --git a/boards/arm/sam34/sam4e-ek/README.txt b/boards/arm/sam34/sam4e-ek/README.txt index ff34a8da08bfd..213fc30966a33 100644 --- a/boards/arm/sam34/sam4e-ek/README.txt +++ b/boards/arm/sam34/sam4e-ek/README.txt @@ -1071,7 +1071,7 @@ Configurations CONFIG_HOST_CYGWIN=y : Using Cygwin or other POSIX environment System Type -> Toolchain: - CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIW=y : General GCC EABI toolchain under windows + CONFIG_ARMV7M_TOOLCHAIN_GNU_EABI=y : General GCC EABI toolchain under windows Library Routines -> CONFIG_ARCH_SIZET_LONG=n : size_t is an unsigned int, not long diff --git a/boards/arm/sam34/sam4e-ek/scripts/Make.defs b/boards/arm/sam34/sam4e-ek/scripts/Make.defs index aab2a56852666..5f832ba7a1895 100644 --- a/boards/arm/sam34/sam4e-ek/scripts/Make.defs +++ b/boards/arm/sam34/sam4e-ek/scripts/Make.defs @@ -24,17 +24,7 @@ include $(TOPDIR)/arch/arm/src/armv7-m/Toolchain.defs ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)flash.ld -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new -fno-rtti -ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef -fno-strict-aliasing +ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 @@ -48,7 +38,3 @@ AFLAGS := $(CFLAGS) -D__ASSEMBLY__ NXFLATLDFLAGS1 = -r -d -warn-common NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-pcrel.ld -no-check-sections LDNXFLATFLAGS = -e main -s 2048 - -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - LDFLAGS += -g -endif diff --git a/boards/arm/sam34/sam4l-xplained/README.txt b/boards/arm/sam34/sam4l-xplained/README.txt index 6d4e33f7bc706..9a0d168272a64 100644 --- a/boards/arm/sam34/sam4l-xplained/README.txt +++ b/boards/arm/sam34/sam4l-xplained/README.txt @@ -457,7 +457,7 @@ Configurations CONFIG_HOST_CYGWIN=y : Using Cygwin or other POSIX environment System Type -> Toolchain: - CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIW=y : General GCC EABI toolchain under windows + CONFIG_ARMV7M_TOOLCHAIN_GNU_EABI=y : General GCC EABI toolchain under windows This re-configuration should be done before making NuttX or else the subsequent 'make' will fail. If you have already attempted building diff --git a/boards/arm/sam34/sam4l-xplained/scripts/Make.defs b/boards/arm/sam34/sam4l-xplained/scripts/Make.defs index aa0883c1b143f..1eba3a76adfee 100644 --- a/boards/arm/sam34/sam4l-xplained/scripts/Make.defs +++ b/boards/arm/sam34/sam4l-xplained/scripts/Make.defs @@ -24,16 +24,6 @@ include $(TOPDIR)/arch/arm/src/armv7-m/Toolchain.defs ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)sam4l-xplained.ld -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 @@ -48,7 +38,3 @@ AFLAGS := $(CFLAGS) -D__ASSEMBLY__ NXFLATLDFLAGS1 = -r -d -warn-common NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-pcrel.ld -no-check-sections LDNXFLATFLAGS = -e main -s 2048 - -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - LDFLAGS += -g -endif diff --git a/boards/arm/sam34/sam4s-xplained-pro/README.txt b/boards/arm/sam34/sam4s-xplained-pro/README.txt index 9bd8de27bd6bc..74074c316cb45 100644 --- a/boards/arm/sam34/sam4s-xplained-pro/README.txt +++ b/boards/arm/sam34/sam4s-xplained-pro/README.txt @@ -339,7 +339,7 @@ Configurations CONFIG_HOST_CYGWIN=y : Using Cygwin or other POSIX environment System Type -> Toolchain: - CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIW=y : General GCC EABI toolchain under windows + CONFIG_ARMV7M_TOOLCHAIN_GNU_EABI=y : General GCC EABI toolchain under windows This re-configuration should be done before making NuttX or else the subsequent 'make' will fail. If you have already attempted building diff --git a/boards/arm/sam34/sam4s-xplained-pro/scripts/Make.defs b/boards/arm/sam34/sam4s-xplained-pro/scripts/Make.defs index 0478b8047b574..ebdc114885864 100644 --- a/boards/arm/sam34/sam4s-xplained-pro/scripts/Make.defs +++ b/boards/arm/sam34/sam4s-xplained-pro/scripts/Make.defs @@ -24,16 +24,6 @@ include $(TOPDIR)/arch/arm/src/armv7-m/Toolchain.defs ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)sam4s-xplained-pro.ld -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 @@ -48,7 +38,3 @@ AFLAGS := $(CFLAGS) -D__ASSEMBLY__ NXFLATLDFLAGS1 = -r -d -warn-common NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-pcrel.ld -no-check-sections LDNXFLATFLAGS = -e main -s 2048 - -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - LDFLAGS += -g -endif diff --git a/boards/arm/sam34/sam4s-xplained/README.txt b/boards/arm/sam34/sam4s-xplained/README.txt index 1693908331179..5a1a556b96bbc 100644 --- a/boards/arm/sam34/sam4s-xplained/README.txt +++ b/boards/arm/sam34/sam4s-xplained/README.txt @@ -334,7 +334,7 @@ Configurations CONFIG_HOST_CYGWIN=y : Using Cygwin or other POSIX environment System Type -> Toolchain: - CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIW=y : General GCC EABI toolchain under windows + CONFIG_ARMV7M_TOOLCHAIN_GNU_EABI=y : General GCC EABI toolchain under windows This re-configuration should be done before making NuttX or else the subsequent 'make' will fail. If you have already attempted building diff --git a/boards/arm/sam34/sam4s-xplained/scripts/Make.defs b/boards/arm/sam34/sam4s-xplained/scripts/Make.defs index 695a0b264dbad..db0be3dd99daa 100644 --- a/boards/arm/sam34/sam4s-xplained/scripts/Make.defs +++ b/boards/arm/sam34/sam4s-xplained/scripts/Make.defs @@ -24,16 +24,6 @@ include $(TOPDIR)/arch/arm/src/armv7-m/Toolchain.defs ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)sam4s-xplained.ld -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 @@ -48,7 +38,3 @@ AFLAGS := $(CFLAGS) -D__ASSEMBLY__ NXFLATLDFLAGS1 = -r -d -warn-common NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-pcrel.ld -no-check-sections LDNXFLATFLAGS = -e main -s 2048 - -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - LDFLAGS += -g -endif diff --git a/boards/arm/sama5/giant-board/README.md b/boards/arm/sama5/giant-board/README.md index 149411e2c2f5e..6e5c02b9d2874 100644 --- a/boards/arm/sama5/giant-board/README.md +++ b/boards/arm/sama5/giant-board/README.md @@ -453,7 +453,7 @@ NOTES: System Type -> Toolchain: - CONFIG_ARMV7A_TOOLCHAIN_GNU_EABIW=y : GNU EABI toolchain for windows + CONFIG_ARMV7A_TOOLCHAIN_GNU_EABI=y : GNU EABI toolchain 4. The SAMA5Dx is running at 528MHz by default in these configurations. diff --git a/boards/arm/sama5/giant-board/scripts/Make.defs b/boards/arm/sama5/giant-board/scripts/Make.defs index 82a21da0b5186..d1c0569c713f0 100644 --- a/boards/arm/sama5/giant-board/scripts/Make.defs +++ b/boards/arm/sama5/giant-board/scripts/Make.defs @@ -36,16 +36,6 @@ endif ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT) -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new -fno-rtti ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 @@ -69,8 +59,4 @@ CELFFLAGS = $(CFLAGS) -mlong-calls # --target1-abs CXXELFFLAGS = $(CXXFLAGS) -mlong-calls # --target1-abs LDELFFLAGS = -r -e main -LDELFFLAGS += -T $(call CONVERT_PATH,$(BOARD_DIR)$(DELIM)scripts$(DELIM)gnu-elf.ld) - -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - LDFLAGS += -g -endif +LDELFFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)/binfmt/libelf/gnu-elf.ld) diff --git a/boards/arm/sama5/giant-board/scripts/gnu-elf.ld b/boards/arm/sama5/giant-board/scripts/gnu-elf.ld deleted file mode 100644 index 57327491c2522..0000000000000 --- a/boards/arm/sama5/giant-board/scripts/gnu-elf.ld +++ /dev/null @@ -1,124 +0,0 @@ -/**************************************************************************** - * boards/arm/sama5/giant-board/scripts/gnu-elf.ld - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. The - * ASF licenses this file to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance with the - * License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - ****************************************************************************/ - -SECTIONS -{ - .text 0x00000000 : - { - _stext = . ; - *(.text) - *(.text.*) - *(.gnu.warning) - *(.stub) - *(.glue_7) - *(.glue_7t) - *(.jcr) - - /* C++ support: The .init and .fini sections contain specific logic - * to manage static constructors and destructors. - */ - - *(.gnu.linkonce.t.*) - *(.init) /* Old ABI */ - *(.fini) /* Old ABI */ - _etext = . ; - } - - .rodata : - { - _srodata = . ; - *(.rodata) - *(.rodata1) - *(.rodata.*) - *(.gnu.linkonce.r*) - _erodata = . ; - } - - .data : - { - _sdata = . ; - *(.data) - *(.data1) - *(.data.*) - *(.gnu.linkonce.d*) - . = ALIGN(4); - _edata = . ; - } - - /* Uninitialized data */ - - .noinit : - { - _snoinit = . ; - *(.noinit*) - _enoinit = . ; - } - - /* C++ support. For each global and static local C++ object, - * GCC creates a small subroutine to construct the object. Pointers - * to these routines (not the routines themselves) are stored as - * simple, linear arrays in the .ctors section of the object file. - * Similarly, pointers to global/static destructor routines are - * stored in .dtors. - */ - - .ctors : - { - _sctors = . ; - *(.ctors) /* Old ABI: Unallocated */ - *(.init_array) /* New ABI: Allocated */ - _edtors = . ; - } - - .dtors : - { - _sdtors = . ; - *(.dtors) /* Old ABI: Unallocated */ - *(.fini_array) /* New ABI: Allocated */ - _edtors = . ; - } - - .bss : - { - _sbss = . ; - *(.bss) - *(.bss.*) - *(.sbss) - *(.sbss.*) - *(.gnu.linkonce.b*) - *(COMMON) - _ebss = . ; - } - - /* Stabs debugging sections. */ - - .stab 0 : { *(.stab) } - .stabstr 0 : { *(.stabstr) } - .stab.excl 0 : { *(.stab.excl) } - .stab.exclstr 0 : { *(.stab.exclstr) } - .stab.index 0 : { *(.stab.index) } - .stab.indexstr 0 : { *(.stab.indexstr) } - .comment 0 : { *(.comment) } - .debug_abbrev 0 : { *(.debug_abbrev) } - .debug_info 0 : { *(.debug_info) } - .debug_line 0 : { *(.debug_line) } - .debug_pubnames 0 : { *(.debug_pubnames) } - .debug_aranges 0 : { *(.debug_aranges) } -} diff --git a/boards/arm/sama5/giant-board/src/Makefile b/boards/arm/sama5/giant-board/src/Makefile index 15ebdd1e83ed8..7ca4114987681 100644 --- a/boards/arm/sama5/giant-board/src/Makefile +++ b/boards/arm/sama5/giant-board/src/Makefile @@ -88,10 +88,6 @@ ifeq ($(CONFIG_USBMSC),y) CSRCS += sam_usbmsc.c endif -ifeq ($(CONFIG_ARCH_FPU),y) -CSRCS += sam_ostest.c -endif - ifeq ($(CONFIG_ARCH_LEDS),y) CSRCS += sam_autoleds.c else diff --git a/boards/arm/sama5/giant-board/src/sam_ostest.c b/boards/arm/sama5/giant-board/src/sam_ostest.c deleted file mode 100644 index 1c20304755a87..0000000000000 --- a/boards/arm/sama5/giant-board/src/sam_ostest.c +++ /dev/null @@ -1,94 +0,0 @@ -/**************************************************************************** - * boards/arm/sama5/giant-board/src/sam_ostest.c - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. The - * ASF licenses this file to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance with the - * License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - ****************************************************************************/ - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include - -#include -#include -#include -#include - -#include -#include - -#include "arm_internal.h" -#include "giant-board.h" - -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -/* Configuration ************************************************************/ - -#undef HAVE_FPU -#if defined(CONFIG_ARCH_FPU) && !defined(CONFIG_TESTING_OSTEST_FPUTESTDISABLE) && \ - defined(CONFIG_TESTING_OSTEST_FPUSIZE) && defined(CONFIG_SCHED_WAITPID) -# define HAVE_FPU 1 -#endif - -#ifdef HAVE_FPU - -#if CONFIG_TESTING_OSTEST_FPUSIZE != (4*FPU_CONTEXT_REGS) -# error "CONFIG_TESTING_OSTEST_FPUSIZE has the wrong size" -#endif - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -static uint32_t g_saveregs[XCPTCONTEXT_REGS]; - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/* Given an array of size CONFIG_TESTING_OSTEST_FPUSIZE, this function will - * return the current FPU registers. - */ - -void arch_getfpu(FAR uint32_t *fpusave) -{ - irqstate_t flags; - - /* Take a snapshot of the thread context right now */ - - flags = enter_critical_section(); - arm_saveusercontext(g_saveregs); - - /* Return only the floating register values */ - - memcpy(fpusave, &g_saveregs[REG_S0], (4*FPU_CONTEXT_REGS)); - leave_critical_section(flags); -} - -/* Given two arrays of size CONFIG_TESTING_OSTEST_FPUSIZE this function - * will compare them and return true if they are identical. - */ - -bool arch_cmpfpu(FAR const uint32_t *fpusave1, FAR const uint32_t *fpusave2) -{ - return memcmp(fpusave1, fpusave2, (4*FPU_CONTEXT_REGS)) == 0; -} - -#endif /* HAVE_FPU */ diff --git a/boards/arm/sama5/sama5d2-xult/README.txt b/boards/arm/sama5/sama5d2-xult/README.txt index bbe5453a0b9c6..c038600b7de68 100644 --- a/boards/arm/sama5/sama5d2-xult/README.txt +++ b/boards/arm/sama5/sama5d2-xult/README.txt @@ -757,7 +757,7 @@ Configurations CONFIG_WINDOWS_CYGWIN=y : Using Cygwin or other POSIX environment System Type -> Toolchain: - CONFIG_ARMV7A_TOOLCHAIN_GNU_EABIW=y : GNU EABI toolchain for windows + CONFIG_ARMV7A_TOOLCHAIN_GNU_EABI=y : GNU EABI toolchain 4. The SAMA5Dx is running at 528MHz by default in these configurations. diff --git a/boards/arm/sama5/sama5d2-xult/scripts/Make.defs b/boards/arm/sama5/sama5d2-xult/scripts/Make.defs index 785bca53af784..3bf01646343ff 100644 --- a/boards/arm/sama5/sama5d2-xult/scripts/Make.defs +++ b/boards/arm/sama5/sama5d2-xult/scripts/Make.defs @@ -36,16 +36,6 @@ endif ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT) -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new -fno-rtti ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 @@ -69,8 +59,4 @@ CELFFLAGS = $(CFLAGS) -mlong-calls # --target1-abs CXXELFFLAGS = $(CXXFLAGS) -mlong-calls # --target1-abs LDELFFLAGS = -r -e main -LDELFFLAGS += -T $(call CONVERT_PATH,$(BOARD_DIR)$(DELIM)scripts$(DELIM)gnu-elf.ld) - -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - LDFLAGS += -g -endif +LDELFFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)/binfmt/libelf/gnu-elf.ld) diff --git a/boards/arm/sama5/sama5d2-xult/scripts/gnu-elf.ld b/boards/arm/sama5/sama5d2-xult/scripts/gnu-elf.ld deleted file mode 100644 index 7c67e77b1540c..0000000000000 --- a/boards/arm/sama5/sama5d2-xult/scripts/gnu-elf.ld +++ /dev/null @@ -1,124 +0,0 @@ -/**************************************************************************** - * boards/arm/sama5/sama5d2-xult/scripts/gnu-elf.ld - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. The - * ASF licenses this file to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance with the - * License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - ****************************************************************************/ - -SECTIONS -{ - .text 0x00000000 : - { - _stext = . ; - *(.text) - *(.text.*) - *(.gnu.warning) - *(.stub) - *(.glue_7) - *(.glue_7t) - *(.jcr) - - /* C++ support: The .init and .fini sections contain specific logic - * to manage static constructors and destructors. - */ - - *(.gnu.linkonce.t.*) - *(.init) /* Old ABI */ - *(.fini) /* Old ABI */ - _etext = . ; - } - - .rodata : - { - _srodata = . ; - *(.rodata) - *(.rodata1) - *(.rodata.*) - *(.gnu.linkonce.r*) - _erodata = . ; - } - - .data : - { - _sdata = . ; - *(.data) - *(.data1) - *(.data.*) - *(.gnu.linkonce.d*) - . = ALIGN(4); - _edata = . ; - } - - /* Uninitialized data */ - - .noinit : - { - _snoinit = . ; - *(.noinit*) - _enoinit = . ; - } - - /* C++ support. For each global and static local C++ object, - * GCC creates a small subroutine to construct the object. Pointers - * to these routines (not the routines themselves) are stored as - * simple, linear arrays in the .ctors section of the object file. - * Similarly, pointers to global/static destructor routines are - * stored in .dtors. - */ - - .ctors : - { - _sctors = . ; - *(.ctors) /* Old ABI: Unallocated */ - *(.init_array) /* New ABI: Allocated */ - _edtors = . ; - } - - .dtors : - { - _sdtors = . ; - *(.dtors) /* Old ABI: Unallocated */ - *(.fini_array) /* New ABI: Allocated */ - _edtors = . ; - } - - .bss : - { - _sbss = . ; - *(.bss) - *(.bss.*) - *(.sbss) - *(.sbss.*) - *(.gnu.linkonce.b*) - *(COMMON) - _ebss = . ; - } - - /* Stabs debugging sections. */ - - .stab 0 : { *(.stab) } - .stabstr 0 : { *(.stabstr) } - .stab.excl 0 : { *(.stab.excl) } - .stab.exclstr 0 : { *(.stab.exclstr) } - .stab.index 0 : { *(.stab.index) } - .stab.indexstr 0 : { *(.stab.indexstr) } - .comment 0 : { *(.comment) } - .debug_abbrev 0 : { *(.debug_abbrev) } - .debug_info 0 : { *(.debug_info) } - .debug_line 0 : { *(.debug_line) } - .debug_pubnames 0 : { *(.debug_pubnames) } - .debug_aranges 0 : { *(.debug_aranges) } -} diff --git a/boards/arm/sama5/sama5d2-xult/src/Makefile b/boards/arm/sama5/sama5d2-xult/src/Makefile index d31528ac9f684..e1b01cef0513a 100644 --- a/boards/arm/sama5/sama5d2-xult/src/Makefile +++ b/boards/arm/sama5/sama5d2-xult/src/Makefile @@ -110,10 +110,6 @@ ifeq ($(CONFIG_USBMSC),y) CSRCS += sam_usbmsc.c endif -ifeq ($(CONFIG_ARCH_FPU),y) -CSRCS += sam_ostest.c -endif - ifeq ($(CONFIG_ARCH_LEDS),y) CSRCS += sam_autoleds.c else diff --git a/boards/arm/sama5/sama5d2-xult/src/sam_ostest.c b/boards/arm/sama5/sama5d2-xult/src/sam_ostest.c deleted file mode 100644 index caa668b54c9fa..0000000000000 --- a/boards/arm/sama5/sama5d2-xult/src/sam_ostest.c +++ /dev/null @@ -1,98 +0,0 @@ -/**************************************************************************** - * boards/arm/sama5/sama5d2-xult/src/sam_ostest.c - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. The - * ASF licenses this file to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance with the - * License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - ****************************************************************************/ - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include - -#include -#include -#include -#include - -#include -#include - -#include "arm_internal.h" -#include "sama5d2-xult.h" - -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -/* Configuration ************************************************************/ - -#undef HAVE_FPU -#if defined(CONFIG_ARCH_FPU) && !defined(CONFIG_TESTING_OSTEST_FPUTESTDISABLE) && \ - defined(CONFIG_TESTING_OSTEST_FPUSIZE) && defined(CONFIG_SCHED_WAITPID) -# define HAVE_FPU 1 -#endif - -#ifdef HAVE_FPU - -#if CONFIG_TESTING_OSTEST_FPUSIZE != (4*FPU_CONTEXT_REGS) -# error "CONFIG_TESTING_OSTEST_FPUSIZE has the wrong size" -#endif - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -static uint32_t g_saveregs[XCPTCONTEXT_REGS]; - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/* Given an array of size CONFIG_TESTING_OSTEST_FPUSIZE, this function will - * return the current FPU registers. - */ - -void arch_getfpu(FAR uint32_t *fpusave) -{ - irqstate_t flags; - - /* Take a snapshot of the thread context right now */ - - flags = enter_critical_section(); - arm_saveusercontext(g_saveregs); - - /* Return only the floating register values */ - - memcpy(fpusave, &g_saveregs[REG_S0], (4*FPU_CONTEXT_REGS)); - leave_critical_section(flags); -} - -/* Given two arrays of size CONFIG_TESTING_OSTEST_FPUSIZE this function - * will compare them and return true if they are identical. - */ - -bool arch_cmpfpu(FAR const uint32_t *fpusave1, FAR const uint32_t *fpusave2) -{ - return memcmp(fpusave1, fpusave2, (4*FPU_CONTEXT_REGS)) == 0; -} - -#endif /* HAVE_FPU */ diff --git a/boards/arm/sama5/sama5d3-xplained/README.txt b/boards/arm/sama5/sama5d3-xplained/README.txt index ac2c675044dcf..d58eb078e7eb3 100644 --- a/boards/arm/sama5/sama5d3-xplained/README.txt +++ b/boards/arm/sama5/sama5d3-xplained/README.txt @@ -109,8 +109,7 @@ GNU Toolchain Options configuration options to your .config (or defconfig) file: CONFIG_ARMV7A_TOOLCHAIN_BUILDROOT=y : NuttX buildroot under Linux or Cygwin (default) - CONFIG_ARMV7A_TOOLCHAIN_GNU_EABIL=y : Generic GCC ARM EABI toolchain for Linux - CONFIG_ARMV7A_TOOLCHAIN_GNU_EABIW=y : Generic GCC ARM EABI toolchain for Windows + CONFIG_ARMV7A_TOOLCHAIN_GNU_EABI=y : Generic GCC ARM EABI toolchain NOTE about Windows native toolchains ------------------------------------ @@ -3110,7 +3109,7 @@ Configurations CONFIG_WINDOWS_CYGWIN=y : Using Cygwin or other POSIX environment System Type -> Toolchain: - CONFIG_ARMV7A_TOOLCHAIN_GNU_EABIW=y : GNU EABI toolchain for windows + CONFIG_ARMV7A_TOOLCHAIN_GNU_EABI=y : GNU EABI toolchain 4. The SAMA5Dx is running at 396MHz by default in these configurations. This is because the original timing for the PLLs, NOR FLASH, and SDRAM @@ -3173,7 +3172,7 @@ Configurations CONFIG_HOST_WINDOWS=y : Windows operating system CONFIG_WINDOWS_CYGWIN=y : POSIX environment under Windows - CONFIG_ARMV7A_TOOLCHAIN_GNU_EABIW=y : GNU EABI toolchain for Windows + CONFIG_ARMV7A_TOOLCHAIN_GNU_EABI=y : GNU EABI toolchain If you are running on Linux, make *certain* that you have CONFIG_HOST_LINUX=y *before* the first make or you will create a @@ -3235,7 +3234,7 @@ Configurations CONFIG_HOST_WINDOWS=y : Windows operating system CONFIG_WINDOWS_CYGWIN=y : POSIX environment under windows - CONFIG_ARMV7A_TOOLCHAIN_GNU_EABIW=y : GNU EABI toolchain for Windows + CONFIG_ARMV7A_TOOLCHAIN_GNU_EABI=y : GNU EABI toolchain If you are running on Linux, make *certain* that you have CONFIG_HOST_LINUX=y *before* the first make or you will create a diff --git a/boards/arm/sama5/sama5d3-xplained/scripts/Make.defs b/boards/arm/sama5/sama5d3-xplained/scripts/Make.defs index 02a79520ca0ef..b78d14481e02c 100644 --- a/boards/arm/sama5/sama5d3-xplained/scripts/Make.defs +++ b/boards/arm/sama5/sama5d3-xplained/scripts/Make.defs @@ -32,16 +32,6 @@ endif ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT) -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new -fno-rtti ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 @@ -65,8 +55,4 @@ CELFFLAGS = $(CFLAGS) -mlong-calls # --target1-abs CXXELFFLAGS = $(CXXFLAGS) -mlong-calls # --target1-abs LDELFFLAGS = -r -e main -LDELFFLAGS += -T $(call CONVERT_PATH,$(BOARD_DIR)$(DELIM)scripts$(DELIM)gnu-elf.ld) - -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - LDFLAGS += -g -endif +LDELFFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)/binfmt/libelf/gnu-elf.ld) diff --git a/boards/arm/sama5/sama5d3-xplained/scripts/gnu-elf.ld b/boards/arm/sama5/sama5d3-xplained/scripts/gnu-elf.ld deleted file mode 100644 index a1d4da7b93960..0000000000000 --- a/boards/arm/sama5/sama5d3-xplained/scripts/gnu-elf.ld +++ /dev/null @@ -1,124 +0,0 @@ -/**************************************************************************** - * boards/arm/sama5/sama5d3-xplained/scripts/gnu-elf.ld - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. The - * ASF licenses this file to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance with the - * License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - ****************************************************************************/ - -SECTIONS -{ - .text 0x00000000 : - { - _stext = . ; - *(.text) - *(.text.*) - *(.gnu.warning) - *(.stub) - *(.glue_7) - *(.glue_7t) - *(.jcr) - - /* C++ support: The .init and .fini sections contain specific logic - * to manage static constructors and destructors. - */ - - *(.gnu.linkonce.t.*) - *(.init) /* Old ABI */ - *(.fini) /* Old ABI */ - _etext = . ; - } - - .rodata : - { - _srodata = . ; - *(.rodata) - *(.rodata1) - *(.rodata.*) - *(.gnu.linkonce.r*) - _erodata = . ; - } - - .data : - { - _sdata = . ; - *(.data) - *(.data1) - *(.data.*) - *(.gnu.linkonce.d*) - . = ALIGN(4); - _edata = . ; - } - - /* Uninitialized data */ - - .noinit : - { - _snoinit = . ; - *(.noinit*) - _enoinit = . ; - } - - /* C++ support. For each global and static local C++ object, - * GCC creates a small subroutine to construct the object. Pointers - * to these routines (not the routines themselves) are stored as - * simple, linear arrays in the .ctors section of the object file. - * Similarly, pointers to global/static destructor routines are - * stored in .dtors. - */ - - .ctors : - { - _sctors = . ; - *(.ctors) /* Old ABI: Unallocated */ - *(.init_array) /* New ABI: Allocated */ - _edtors = . ; - } - - .dtors : - { - _sdtors = . ; - *(.dtors) /* Old ABI: Unallocated */ - *(.fini_array) /* New ABI: Allocated */ - _edtors = . ; - } - - .bss : - { - _sbss = . ; - *(.bss) - *(.bss.*) - *(.sbss) - *(.sbss.*) - *(.gnu.linkonce.b*) - *(COMMON) - _ebss = . ; - } - - /* Stabs debugging sections. */ - - .stab 0 : { *(.stab) } - .stabstr 0 : { *(.stabstr) } - .stab.excl 0 : { *(.stab.excl) } - .stab.exclstr 0 : { *(.stab.exclstr) } - .stab.index 0 : { *(.stab.index) } - .stab.indexstr 0 : { *(.stab.indexstr) } - .comment 0 : { *(.comment) } - .debug_abbrev 0 : { *(.debug_abbrev) } - .debug_info 0 : { *(.debug_info) } - .debug_line 0 : { *(.debug_line) } - .debug_pubnames 0 : { *(.debug_pubnames) } - .debug_aranges 0 : { *(.debug_aranges) } -} diff --git a/boards/arm/sama5/sama5d3-xplained/src/Makefile b/boards/arm/sama5/sama5d3-xplained/src/Makefile index 74dd01f0de2ea..8a557aeba4062 100644 --- a/boards/arm/sama5/sama5d3-xplained/src/Makefile +++ b/boards/arm/sama5/sama5d3-xplained/src/Makefile @@ -102,10 +102,6 @@ ifeq ($(CONFIG_USBMSC),y) CSRCS += sam_usbmsc.c endif -ifeq ($(CONFIG_ARCH_FPU),y) -CSRCS += sam_ostest.c -endif - ifeq ($(CONFIG_ARCH_LEDS),y) CSRCS += sam_autoleds.c else diff --git a/boards/arm/sama5/sama5d3-xplained/src/sam_ostest.c b/boards/arm/sama5/sama5d3-xplained/src/sam_ostest.c deleted file mode 100644 index c603b3918e2f5..0000000000000 --- a/boards/arm/sama5/sama5d3-xplained/src/sam_ostest.c +++ /dev/null @@ -1,98 +0,0 @@ -/**************************************************************************** - * boards/arm/sama5/sama5d3-xplained/src/sam_ostest.c - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. The - * ASF licenses this file to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance with the - * License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - ****************************************************************************/ - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include - -#include -#include -#include -#include - -#include -#include - -#include "arm_internal.h" -#include "sama5d3-xplained.h" - -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -/* Configuration ************************************************************/ - -#undef HAVE_FPU -#if defined(CONFIG_ARCH_FPU) && !defined(CONFIG_TESTING_OSTEST_FPUTESTDISABLE) && \ - defined(CONFIG_TESTING_OSTEST_FPUSIZE) && defined(CONFIG_SCHED_WAITPID) -# define HAVE_FPU 1 -#endif - -#ifdef HAVE_FPU - -#if CONFIG_TESTING_OSTEST_FPUSIZE != (4*FPU_CONTEXT_REGS) -# error "CONFIG_TESTING_OSTEST_FPUSIZE has the wrong size" -#endif - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -static uint32_t g_saveregs[XCPTCONTEXT_REGS]; - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/* Given an array of size CONFIG_TESTING_OSTEST_FPUSIZE, this function will - * return the current FPU registers. - */ - -void arch_getfpu(FAR uint32_t *fpusave) -{ - irqstate_t flags; - - /* Take a snapshot of the thread context right now */ - - flags = enter_critical_section(); - arm_saveusercontext(g_saveregs); - - /* Return only the floating register values */ - - memcpy(fpusave, &g_saveregs[REG_S0], (4*FPU_CONTEXT_REGS)); - leave_critical_section(flags); -} - -/* Given two arrays of size CONFIG_TESTING_OSTEST_FPUSIZE this function - * will compare them and return true if they are identical. - */ - -bool arch_cmpfpu(FAR const uint32_t *fpusave1, FAR const uint32_t *fpusave2) -{ - return memcmp(fpusave1, fpusave2, (4*FPU_CONTEXT_REGS)) == 0; -} - -#endif /* HAVE_FPU */ diff --git a/boards/arm/sama5/sama5d3x-ek/README.txt b/boards/arm/sama5/sama5d3x-ek/README.txt index 9d81e348048c5..a84d8f403157b 100644 --- a/boards/arm/sama5/sama5d3x-ek/README.txt +++ b/boards/arm/sama5/sama5d3x-ek/README.txt @@ -131,8 +131,7 @@ GNU Toolchain Options configuration options to your .config (or defconfig) file: CONFIG_ARMV7A_TOOLCHAIN_BUILDROOT=y : NuttX buildroot under Linux or Cygwin (default) - CONFIG_ARMV7A_TOOLCHAIN_GNU_EABIL=y : Generic GCC ARM EABI toolchain for Linux - CONFIG_ARMV7A_TOOLCHAIN_GNU_EABIW=y : Generic GCC ARM EABI toolchain for Windows + CONFIG_ARMV7A_TOOLCHAIN_GNU_EABI=y : Generic GCC ARM EABI toolchain IDEs ==== @@ -3294,7 +3293,7 @@ Configurations CONFIG_WINDOWS_CYGWIN=y : Using Cygwin or other POSIX environment System Type -> Toolchain: - CONFIG_ARMV7A_TOOLCHAIN_GNU_EABIW=y : GNU EABI toolchain for windows + CONFIG_ARMV7A_TOOLCHAIN_GNU_EABI=y : GNU EABI toolchain 4. The SAMA5Dx is running at 396MHz by default in these configurations. This is because the original timing for the PLLs, NOR FLASH, and SDRAM @@ -3390,7 +3389,7 @@ Configurations CONFIG_HOST_WINDOWS=y : Windows operating system CONFIG_WINDOWS_CYGWIN=y : POSIX environment under Windows - CONFIG_ARMV7A_TOOLCHAIN_GNU_EABIW=y : GNU EABI toolchain for Windows + CONFIG_ARMV7A_TOOLCHAIN_GNU_EABI=y : GNU EABI toolchain If you are running on Linux, make *certain* that you have CONFIG_HOST_LINUX=y *before* the first make or you will create a @@ -3468,7 +3467,7 @@ Configurations CONFIG_HOST_WINDOWS=y : Windows operating system CONFIG_WINDOWS_CYGWIN=y : POSIX environment under Windows - CONFIG_ARMV7A_TOOLCHAIN_GNU_EABIW=y : GNU EABI toolchain for Windows + CONFIG_ARMV7A_TOOLCHAIN_GNU_EABI=y : GNU EABI toolchain If you are running on Linux, make *certain* that you have CONFIG_HOST_LINUX=y *before* the first make or you will create a @@ -3541,7 +3540,7 @@ Configurations CONFIG_HOST_WINDOWS=y : Windows operating system CONFIG_WINDOWS_CYGWIN=y : POSIX environment under Windows - CONFIG_ARMV7A_TOOLCHAIN_GNU_EABIW=y : GNU EABI toolchain for Windows + CONFIG_ARMV7A_TOOLCHAIN_GNU_EABI=y : GNU EABI toolchain If you are running on Linux, make *certain* that you have CONFIG_HOST_LINUX=y *before* the first make or you will create a diff --git a/boards/arm/sama5/sama5d3x-ek/scripts/Make.defs b/boards/arm/sama5/sama5d3x-ek/scripts/Make.defs index 39c7b68df597b..f828eff83dfea 100644 --- a/boards/arm/sama5/sama5d3x-ek/scripts/Make.defs +++ b/boards/arm/sama5/sama5d3x-ek/scripts/Make.defs @@ -52,16 +52,6 @@ endif ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT) -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new -fno-rtti ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 @@ -85,8 +75,4 @@ CELFFLAGS = $(CFLAGS) -mlong-calls # --target1-abs CXXELFFLAGS = $(CXXFLAGS) -mlong-calls # --target1-abs LDELFFLAGS = -r -e main -LDELFFLAGS += -T $(call CONVERT_PATH,$(BOARD_DIR)$(DELIM)scripts$(DELIM)gnu-elf.ld) - -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - LDFLAGS += -g -endif +LDELFFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)/binfmt/libelf/gnu-elf.ld) diff --git a/boards/arm/sama5/sama5d3x-ek/scripts/gnu-elf.ld b/boards/arm/sama5/sama5d3x-ek/scripts/gnu-elf.ld deleted file mode 100644 index 42d2d0b3d6669..0000000000000 --- a/boards/arm/sama5/sama5d3x-ek/scripts/gnu-elf.ld +++ /dev/null @@ -1,124 +0,0 @@ -/**************************************************************************** - * boards/arm/sama5/sama5d3x-ek/scripts/gnu-elf.ld - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. The - * ASF licenses this file to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance with the - * License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - ****************************************************************************/ - -SECTIONS -{ - .text 0x00000000 : - { - _stext = . ; - *(.text) - *(.text.*) - *(.gnu.warning) - *(.stub) - *(.glue_7) - *(.glue_7t) - *(.jcr) - - /* C++ support: The .init and .fini sections contain specific logic - * to manage static constructors and destructors. - */ - - *(.gnu.linkonce.t.*) - *(.init) /* Old ABI */ - *(.fini) /* Old ABI */ - _etext = . ; - } - - .rodata : - { - _srodata = . ; - *(.rodata) - *(.rodata1) - *(.rodata.*) - *(.gnu.linkonce.r*) - _erodata = . ; - } - - .data : - { - _sdata = . ; - *(.data) - *(.data1) - *(.data.*) - *(.gnu.linkonce.d*) - . = ALIGN(4); - _edata = . ; - } - - /* Uninitialized data */ - - .noinit : - { - _snoinit = . ; - *(.noinit*) - _enoinit = . ; - } - - /* C++ support. For each global and static local C++ object, - * GCC creates a small subroutine to construct the object. Pointers - * to these routines (not the routines themselves) are stored as - * simple, linear arrays in the .ctors section of the object file. - * Similarly, pointers to global/static destructor routines are - * stored in .dtors. - */ - - .ctors : - { - _sctors = . ; - *(.ctors) /* Old ABI: Unallocated */ - *(.init_array) /* New ABI: Allocated */ - _edtors = . ; - } - - .dtors : - { - _sdtors = . ; - *(.dtors) /* Old ABI: Unallocated */ - *(.fini_array) /* New ABI: Allocated */ - _edtors = . ; - } - - .bss : - { - _sbss = . ; - *(.bss) - *(.bss.*) - *(.sbss) - *(.sbss.*) - *(.gnu.linkonce.b*) - *(COMMON) - _ebss = . ; - } - - /* Stabs debugging sections. */ - - .stab 0 : { *(.stab) } - .stabstr 0 : { *(.stabstr) } - .stab.excl 0 : { *(.stab.excl) } - .stab.exclstr 0 : { *(.stab.exclstr) } - .stab.index 0 : { *(.stab.index) } - .stab.indexstr 0 : { *(.stab.indexstr) } - .comment 0 : { *(.comment) } - .debug_abbrev 0 : { *(.debug_abbrev) } - .debug_info 0 : { *(.debug_info) } - .debug_line 0 : { *(.debug_line) } - .debug_pubnames 0 : { *(.debug_pubnames) } - .debug_aranges 0 : { *(.debug_aranges) } -} diff --git a/boards/arm/sama5/sama5d3x-ek/src/Makefile b/boards/arm/sama5/sama5d3x-ek/src/Makefile index 6c6b035a282a8..71023e784e4a1 100644 --- a/boards/arm/sama5/sama5d3x-ek/src/Makefile +++ b/boards/arm/sama5/sama5d3x-ek/src/Makefile @@ -120,10 +120,6 @@ ifeq ($(CONFIG_USBMSC),y) CSRCS += sam_usbmsc.c endif -ifeq ($(CONFIG_ARCH_FPU),y) -CSRCS += sam_ostest.c -endif - ifeq ($(CONFIG_SAMA5_TSD),y) CSRCS += sam_touchscreen.c endif diff --git a/boards/arm/sama5/sama5d3x-ek/src/sam_ostest.c b/boards/arm/sama5/sama5d3x-ek/src/sam_ostest.c deleted file mode 100644 index c664cd21e76c3..0000000000000 --- a/boards/arm/sama5/sama5d3x-ek/src/sam_ostest.c +++ /dev/null @@ -1,98 +0,0 @@ -/**************************************************************************** - * boards/arm/sama5/sama5d3x-ek/src/sam_ostest.c - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. The - * ASF licenses this file to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance with the - * License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - ****************************************************************************/ - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include - -#include -#include -#include -#include - -#include -#include - -#include "arm_internal.h" -#include "sama5d3x-ek.h" - -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -/* Configuration ************************************************************/ - -#undef HAVE_FPU -#if defined(CONFIG_ARCH_FPU) && !defined(CONFIG_TESTING_OSTEST_FPUTESTDISABLE) && \ - defined(CONFIG_TESTING_OSTEST_FPUSIZE) && defined(CONFIG_SCHED_WAITPID) -# define HAVE_FPU 1 -#endif - -#ifdef HAVE_FPU - -#if CONFIG_TESTING_OSTEST_FPUSIZE != (4*FPU_CONTEXT_REGS) -# error "CONFIG_TESTING_OSTEST_FPUSIZE has the wrong size" -#endif - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -static uint32_t g_saveregs[XCPTCONTEXT_REGS]; - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/* Given an array of size CONFIG_TESTING_OSTEST_FPUSIZE, this function will - * return the current FPU registers. - */ - -void arch_getfpu(FAR uint32_t *fpusave) -{ - irqstate_t flags; - - /* Take a snapshot of the thread context right now */ - - flags = enter_critical_section(); - arm_saveusercontext(g_saveregs); - - /* Return only the floating register values */ - - memcpy(fpusave, &g_saveregs[REG_S0], (4*FPU_CONTEXT_REGS)); - leave_critical_section(flags); -} - -/* Given two arrays of size CONFIG_TESTING_OSTEST_FPUSIZE this function - * will compare them and return true if they are identical. - */ - -bool arch_cmpfpu(FAR const uint32_t *fpusave1, FAR const uint32_t *fpusave2) -{ - return memcmp(fpusave1, fpusave2, (4*FPU_CONTEXT_REGS)) == 0; -} - -#endif /* HAVE_FPU */ diff --git a/boards/arm/sama5/sama5d4-ek/README.txt b/boards/arm/sama5/sama5d4-ek/README.txt index bd63adb362803..dd3cd2f868a7d 100644 --- a/boards/arm/sama5/sama5d4-ek/README.txt +++ b/boards/arm/sama5/sama5d4-ek/README.txt @@ -125,8 +125,7 @@ GNU Toolchain Options configuration options to your .config (or defconfig) file: CONFIG_ARMV7A_TOOLCHAIN_BUILDROOT=y : NuttX buildroot under Linux or Cygwin (default) - CONFIG_ARMV7A_TOOLCHAIN_GNU_EABIL=y : Generic GCC ARM EABI toolchain for Linux - CONFIG_ARMV7A_TOOLCHAIN_GNU_EABIW=y : Generic GCC ARM EABI toolchain for Windows + CONFIG_ARMV7A_TOOLCHAIN_GNU_EABI=y : Generic GCC ARM EABI toolchain IDEs ==== @@ -3573,7 +3572,7 @@ Configurations CONFIG_WINDOWS_CYGWIN=y : Using Cygwin or other POSIX environment System Type -> Toolchain: - CONFIG_ARMV7A_TOOLCHAIN_GNU_EABIW=y : GNU EABI toolchain for windows + CONFIG_ARMV7A_TOOLCHAIN_GNU_EABI=y : GNU EABI toolchain 4. The SAMA5Dx is running at 528MHz by default in these configurations. @@ -3665,7 +3664,7 @@ Configurations CONFIG_HOST_WINDOWS=y : Windows operating system CONFIG_WINDOWS_CYGWIN=y : POSIX environment under Windows - CONFIG_ARMV7A_TOOLCHAIN_GNU_EABIW=y : GNU EABI toolchain for Windows + CONFIG_ARMV7A_TOOLCHAIN_GNU_EABI=y : GNU EABI toolchain If you are running on Linux, make *certain* that you have CONFIG_HOST_LINUX=y *before* the first make or you will create a @@ -3734,7 +3733,7 @@ Configurations CONFIG_HOST_WINDOWS=y : Windows operating system CONFIG_WINDOWS_CYGWIN=y : POSIX environment under Windows - CONFIG_ARMV7A_TOOLCHAIN_GNU_EABIW=y : GNU EABI toolchain for Windows + CONFIG_ARMV7A_TOOLCHAIN_GNU_EABI=y : GNU EABI toolchain If you are running on Linux, make *certain* that you have CONFIG_HOST_LINUX=y *before* the first make or you will create a @@ -3813,7 +3812,7 @@ Configurations CONFIG_HOST_WINDOWS=y : Windows operating system CONFIG_WINDOWS_CYGWIN=y : POSIX environment under windows - CONFIG_ARMV7A_TOOLCHAIN_GNU_EABIL=y : GNU EABI toolchain for Windows + CONFIG_ARMV7A_TOOLCHAIN_GNU_EABI=y : GNU EABI toolchain If you are running on Linux, make *certain* that you have CONFIG_HOST_LINUX=y *before* the first make or you will create a @@ -3982,7 +3981,7 @@ Configurations CONFIG_HOST_WINDOWS=y : Windows operating system CONFIG_WINDOWS_CYGWIN=y : POSIX environment under Windows - CONFIG_ARMV7A_TOOLCHAIN_GNU_EABIW=y : GNU EABI toolchain for Windows + CONFIG_ARMV7A_TOOLCHAIN_GNU_EABI=y : GNU EABI toolchain If you are running on Linux, make *certain* that you have CONFIG_HOST_LINUX=y *before* the first make or you will create a @@ -4228,7 +4227,7 @@ Configurations CONFIG_HOST_WINDOWS=y : Windows operating system CONFIG_WINDOWS_CYGWIN=y : POSIX environment under windows - CONFIG_ARMV7A_TOOLCHAIN_GNU_EABIW=y : GNU EABI toolchain for Windows + CONFIG_ARMV7A_TOOLCHAIN_GNU_EABI=y : GNU EABI toolchain If you are running on Linux, make *certain* that you have CONFIG_HOST_LINUX=y *before* the first make or you will create a @@ -4880,7 +4879,7 @@ Configurations CONFIG_HOST_WINDOWS=y : Windows operating system CONFIG_WINDOWS_CYGWIN=y : POSIX environment under Windows - CONFIG_ARMV7A_TOOLCHAIN_GNU_EABIW=y : GNU EABI toolchain for Windows + CONFIG_ARMV7A_TOOLCHAIN_GNU_EABI=y : GNU EABI toolchain If you are running on Linux, make *certain* that you have CONFIG_HOST_LINUX=y *before* the first make or you will create a diff --git a/boards/arm/sama5/sama5d4-ek/configs/knsh/Make.defs b/boards/arm/sama5/sama5d4-ek/configs/knsh/Make.defs index e30d9d8408eb1..08bdedad7dbd3 100644 --- a/boards/arm/sama5/sama5d4-ek/configs/knsh/Make.defs +++ b/boards/arm/sama5/sama5d4-ek/configs/knsh/Make.defs @@ -36,16 +36,6 @@ endif ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT) -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new -fno-rtti ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 @@ -69,8 +59,4 @@ CELFFLAGS = $(CFLAGS) -mlong-calls # --target1-abs CXXELFFLAGS = $(CXXFLAGS) -mlong-calls # --target1-abs LDELFFLAGS = -r -e main -LDELFFLAGS += -T $(call CONVERT_PATH,$(BOARD_DIR)$(DELIM)scripts$(DELIM)gnu-elf.ld) - -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - LDFLAGS += -g -endif +LDELFFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)/binfmt/libelf/gnu-elf.ld) diff --git a/boards/arm/sama5/sama5d4-ek/include/nsh_romfsimg.h b/boards/arm/sama5/sama5d4-ek/include/nsh_romfsimg.h index 8b78c03f72e88..38486878370e2 100644 --- a/boards/arm/sama5/sama5d4-ek/include/nsh_romfsimg.h +++ b/boards/arm/sama5/sama5d4-ek/include/nsh_romfsimg.h @@ -1,3 +1,23 @@ +/*************************************************************************** + * boards/arm/sama5/sama5d4-ek/include/nsh_romfsimg.h + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ***************************************************************************/ + unsigned char romfs_img[] = { 0x2d, 0x72, 0x6f, 0x6d, 0x31, 0x66, 0x73, 0x2d, 0x00, 0x00, 0x02, 0x00, 0xe7, 0x04, 0x63, 0xbd, 0x4e, 0x53, 0x48, 0x49, 0x6e, 0x69, 0x74, 0x56, diff --git a/boards/arm/sama5/sama5d4-ek/include/rc.sysinit.template b/boards/arm/sama5/sama5d4-ek/include/rc.sysinit.template new file mode 100644 index 0000000000000..9bdf99368eb9c --- /dev/null +++ b/boards/arm/sama5/sama5d4-ek/include/rc.sysinit.template @@ -0,0 +1,12 @@ +# Mount the procfs file system at /proc + +mount -t procfs /proc +echo "rc.sysinit: Mounted /proc" + +# Create a RAMDISK at /dev/ram1, size 0.5MiB, format it with a FAT +# file system and mount it at /tmp + +mkrd -m 1 -s 512 1024 +mkfatfs /dev/ram1 +mount -t vfat /dev/ram1 /tmp +echo "rc.sysinit: Mounted /tmp" diff --git a/boards/arm/sama5/sama5d4-ek/include/rcS.template b/boards/arm/sama5/sama5d4-ek/include/rcS.template index 077d99c3b40c0..e69de29bb2d1d 100644 --- a/boards/arm/sama5/sama5d4-ek/include/rcS.template +++ b/boards/arm/sama5/sama5d4-ek/include/rcS.template @@ -1,12 +0,0 @@ -# Mount the procfs file system at /proc - -mount -t procfs /proc -echo "rcS: Mounted /proc" - -# Create a RAMDISK at /dev/ram1, size 0.5MiB, format it with a FAT -# file system and mount it at /tmp - -mkrd -m 1 -s 512 1024 -mkfatfs /dev/ram1 -mount -t vfat /dev/ram1 /tmp -echo "rcS: Mounted /tmp" diff --git a/boards/arm/sama5/sama5d4-ek/scripts/Make.defs b/boards/arm/sama5/sama5d4-ek/scripts/Make.defs index c2f2553eb90b5..3319c071d357b 100644 --- a/boards/arm/sama5/sama5d4-ek/scripts/Make.defs +++ b/boards/arm/sama5/sama5d4-ek/scripts/Make.defs @@ -36,16 +36,6 @@ endif ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT) -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new -fno-rtti ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 @@ -69,8 +59,4 @@ CELFFLAGS = $(CFLAGS) -mlong-calls # --target1-abs CXXELFFLAGS = $(CXXFLAGS) -mlong-calls # --target1-abs LDELFFLAGS = -r -e main -LDELFFLAGS += -T $(call CONVERT_PATH,$(BOARD_DIR)$(DELIM)scripts$(DELIM)gnu-elf.ld) - -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - LDFLAGS += -g -endif +LDELFFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)/binfmt/libelf/gnu-elf.ld) diff --git a/boards/arm/sama5/sama5d4-ek/scripts/gnu-elf.ld b/boards/arm/sama5/sama5d4-ek/scripts/gnu-elf.ld deleted file mode 100644 index e2e1b1e9e2a14..0000000000000 --- a/boards/arm/sama5/sama5d4-ek/scripts/gnu-elf.ld +++ /dev/null @@ -1,125 +0,0 @@ -/**************************************************************************** - * boards/arm/sama5/sama5d4-ek/scripts/gnu-elf.ld - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. The - * ASF licenses this file to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance with the - * License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - ****************************************************************************/ - -SECTIONS -{ - .text 0x00000000 : - { - _stext = . ; - *(.text) - *(.text.*) - *(.gnu.warning) - *(.stub) - *(.glue_7) - *(.glue_7t) - *(.jcr) - - /* C++ support: The .init and .fini sections contain specific logic - * to manage static constructors and destructors. - */ - - *(.gnu.linkonce.t.*) - *(.init) /* Old ABI */ - *(.fini) /* Old ABI */ - _etext = . ; - } - - .rodata : - { - _srodata = . ; - *(.rodata) - *(.rodata1) - *(.rodata.*) - *(.gnu.linkonce.r*) - _erodata = . ; - } - - .data : - { - _sdata = . ; - *(.data) - *(.data1) - *(.data.*) - *(.gnu.linkonce.d*) - . = ALIGN(4); - _edata = . ; - } - - /* Uninitialized data */ - - .noinit : - { - _snoinit = . ; - *(.noinit*) - _enoinit = . ; - } - - /* C++ support. For each global and static local C++ object, - * GCC creates a small subroutine to construct the object. Pointers - * to these routines (not the routines themselves) are stored as - * simple, linear arrays in the .ctors section of the object file. - * Similarly, pointers to global/static destructor routines are - * stored in .dtors. - */ - - .ctors : - { - _sctors = . ; - *(.ctors) /* Old ABI: Unallocated */ - *(.init_array) /* New ABI: Allocated */ - _edtors = . ; - } - - .dtors : - { - _sdtors = . ; - *(.dtors) /* Old ABI: Unallocated */ - *(.fini_array) /* New ABI: Allocated */ - _edtors = . ; - } - - .bss : - { - _sbss = . ; - *(.bss) - *(.bss.*) - *(.sbss) - *(.sbss.*) - *(.gnu.linkonce.b*) - *(COMMON) - . = ALIGN(4); - _ebss = . ; - } - - /* Stabs debugging sections. */ - - .stab 0 : { *(.stab) } - .stabstr 0 : { *(.stabstr) } - .stab.excl 0 : { *(.stab.excl) } - .stab.exclstr 0 : { *(.stab.exclstr) } - .stab.index 0 : { *(.stab.index) } - .stab.indexstr 0 : { *(.stab.indexstr) } - .comment 0 : { *(.comment) } - .debug_abbrev 0 : { *(.debug_abbrev) } - .debug_info 0 : { *(.debug_info) } - .debug_line 0 : { *(.debug_line) } - .debug_pubnames 0 : { *(.debug_pubnames) } - .debug_aranges 0 : { *(.debug_aranges) } -} diff --git a/boards/arm/sama5/sama5d4-ek/src/Makefile b/boards/arm/sama5/sama5d4-ek/src/Makefile index 9388bb3fd374f..ee4f58cb8500d 100644 --- a/boards/arm/sama5/sama5d4-ek/src/Makefile +++ b/boards/arm/sama5/sama5d4-ek/src/Makefile @@ -116,10 +116,6 @@ ifeq ($(CONFIG_USBMSC),y) CSRCS += sam_usbmsc.c endif -ifeq ($(CONFIG_ARCH_FPU),y) -CSRCS += sam_ostest.c -endif - ifeq ($(CONFIG_ARCH_LEDS),y) CSRCS += sam_autoleds.c else diff --git a/boards/arm/sama5/sama5d4-ek/src/sam_ostest.c b/boards/arm/sama5/sama5d4-ek/src/sam_ostest.c deleted file mode 100644 index b0f9f3c1c289f..0000000000000 --- a/boards/arm/sama5/sama5d4-ek/src/sam_ostest.c +++ /dev/null @@ -1,98 +0,0 @@ -/**************************************************************************** - * boards/arm/sama5/sama5d4-ek/src/sam_ostest.c - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. The - * ASF licenses this file to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance with the - * License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - ****************************************************************************/ - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include - -#include -#include -#include -#include - -#include -#include - -#include "arm_internal.h" -#include "sama5d4-ek.h" - -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -/* Configuration ************************************************************/ - -#undef HAVE_FPU -#if defined(CONFIG_ARCH_FPU) && !defined(CONFIG_TESTING_OSTEST_FPUTESTDISABLE) && \ - defined(CONFIG_TESTING_OSTEST_FPUSIZE) && defined(CONFIG_SCHED_WAITPID) -# define HAVE_FPU 1 -#endif - -#ifdef HAVE_FPU - -#if CONFIG_TESTING_OSTEST_FPUSIZE != (4*FPU_CONTEXT_REGS) -# error "CONFIG_TESTING_OSTEST_FPUSIZE has the wrong size" -#endif - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -static uint32_t g_saveregs[XCPTCONTEXT_REGS]; - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/* Given an array of size CONFIG_TESTING_OSTEST_FPUSIZE, this function will - * return the current FPU registers. - */ - -void arch_getfpu(FAR uint32_t *fpusave) -{ - irqstate_t flags; - - /* Take a snapshot of the thread context right now */ - - flags = enter_critical_section(); - arm_saveusercontext(g_saveregs); - - /* Return only the floating register values */ - - memcpy(fpusave, &g_saveregs[REG_S0], (4*FPU_CONTEXT_REGS)); - leave_critical_section(flags); -} - -/* Given two arrays of size CONFIG_TESTING_OSTEST_FPUSIZE this function - * will compare them and return true if they are identical. - */ - -bool arch_cmpfpu(FAR const uint32_t *fpusave1, FAR const uint32_t *fpusave2) -{ - return memcmp(fpusave1, fpusave2, (4*FPU_CONTEXT_REGS)) == 0; -} - -#endif /* HAVE_FPU */ diff --git a/boards/arm/samd2l2/arduino-m0/scripts/Make.defs b/boards/arm/samd2l2/arduino-m0/scripts/Make.defs index 0b24d378cdf9d..7a107c9907e41 100644 --- a/boards/arm/samd2l2/arduino-m0/scripts/Make.defs +++ b/boards/arm/samd2l2/arduino-m0/scripts/Make.defs @@ -23,19 +23,8 @@ include $(TOPDIR)/tools/Config.mk include $(TOPDIR)/arch/arm/src/armv6-m/Toolchain.defs LDSCRIPT = flash.ld - ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT) -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new -fno-rtti ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 @@ -50,7 +39,3 @@ AFLAGS := $(CFLAGS) -D__ASSEMBLY__ NXFLATLDFLAGS1 = -r -d -warn-common NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-pcrel.ld -no-check-sections LDNXFLATFLAGS = -e main -s 2048 - -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - LDFLAGS += -g -endif diff --git a/boards/arm/samd2l2/arduino-m0/src/sam_boot.c b/boards/arm/samd2l2/arduino-m0/src/sam_boot.c index b8b7739e520ea..9642ad730647b 100644 --- a/boards/arm/samd2l2/arduino-m0/src/sam_boot.c +++ b/boards/arm/samd2l2/arduino-m0/src/sam_boot.c @@ -94,6 +94,6 @@ void board_late_initialize(void) { /* Perform board initialization */ - (void)sam_bringup(); + sam_bringup(); } #endif /* CONFIG_BOARD_LATE_INITIALIZE */ diff --git a/boards/arm/samd2l2/circuit-express/scripts/Make.defs b/boards/arm/samd2l2/circuit-express/scripts/Make.defs index b089d13a69096..19f08a974feb6 100644 --- a/boards/arm/samd2l2/circuit-express/scripts/Make.defs +++ b/boards/arm/samd2l2/circuit-express/scripts/Make.defs @@ -23,19 +23,8 @@ include $(TOPDIR)/tools/Config.mk include $(TOPDIR)/arch/arm/src/armv6-m/Toolchain.defs LDSCRIPT = flash.ld - ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT) -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new -fno-rtti ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 @@ -50,7 +39,3 @@ AFLAGS := $(CFLAGS) -D__ASSEMBLY__ NXFLATLDFLAGS1 = -r -d -warn-common NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-pcrel.ld -no-check-sections LDNXFLATFLAGS = -e main -s 2048 - -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - LDFLAGS += -g -endif diff --git a/boards/arm/samd2l2/circuit-express/src/sam_boot.c b/boards/arm/samd2l2/circuit-express/src/sam_boot.c index e45589e432dfb..2a5326e23ce9c 100644 --- a/boards/arm/samd2l2/circuit-express/src/sam_boot.c +++ b/boards/arm/samd2l2/circuit-express/src/sam_boot.c @@ -81,6 +81,6 @@ void board_late_initialize(void) { /* Perform board initialization */ - (void)sam_bringup(); + sam_bringup(); } #endif /* CONFIG_BOARD_LATE_INITIALIZE */ diff --git a/boards/arm/samd2l2/samd20-xplained/README.txt b/boards/arm/samd2l2/samd20-xplained/README.txt index d847ab4f747dc..56343d0b21317 100644 --- a/boards/arm/samd2l2/samd20-xplained/README.txt +++ b/boards/arm/samd2l2/samd20-xplained/README.txt @@ -283,8 +283,7 @@ GNU Toolchain Options the following configuration options to your .config (or defconfig) file: CONFIG_ARMV6M_TOOLCHAIN_BUILDROOT=y : NuttX buildroot under Linux or Cygwin (default) - CONFIG_ARMV6M_TOOLCHAIN_GNU_EABIL=y : Generic GCC ARM EABI toolchain for Linux - CONFIG_ARMV6M_TOOLCHAIN_GNU_EABIW=y : Generic GCC ARM EABI toolchain for Windows + CONFIG_ARMV6M_TOOLCHAIN_GNU_EABI=y : Generic GCC ARM EABI toolchain NOTE about Windows native toolchains ------------------------------------ @@ -664,7 +663,7 @@ Configurations that is easily reconfigured: System Type -> Toolchain: - CONFIG_ARMV6M_TOOLCHAIN_GNU_EABIW=y + CONFIG_ARMV6M_TOOLCHAIN_GNU_EABI=y Any re-configuration should be done before making NuttX or else the subsequent 'make' will fail. If you have already attempted building diff --git a/boards/arm/samd2l2/samd20-xplained/scripts/Make.defs b/boards/arm/samd2l2/samd20-xplained/scripts/Make.defs index 4664134927c29..1b2a43d97dd64 100644 --- a/boards/arm/samd2l2/samd20-xplained/scripts/Make.defs +++ b/boards/arm/samd2l2/samd20-xplained/scripts/Make.defs @@ -23,19 +23,8 @@ include $(TOPDIR)/tools/Config.mk include $(TOPDIR)/arch/arm/src/armv6-m/Toolchain.defs LDSCRIPT = flash.ld - ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT) -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new -fno-rtti ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 @@ -50,7 +39,3 @@ AFLAGS := $(CFLAGS) -D__ASSEMBLY__ NXFLATLDFLAGS1 = -r -d -warn-common NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-pcrel.ld -no-check-sections LDNXFLATFLAGS = -e main -s 2048 - -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - LDFLAGS += -g -endif diff --git a/boards/arm/samd2l2/samd21-xplained/README.txt b/boards/arm/samd2l2/samd21-xplained/README.txt index 295242201eb2a..be3accc83bef7 100644 --- a/boards/arm/samd2l2/samd21-xplained/README.txt +++ b/boards/arm/samd2l2/samd21-xplained/README.txt @@ -536,7 +536,7 @@ Configurations that is easily reconfigured: System Type -> Toolchain: - CONFIG_ARMV6M_TOOLCHAIN_GNU_EABIW=y + CONFIG_ARMV6M_TOOLCHAIN_GNU_EABI=y Any re-configuration should be done before making NuttX or else the subsequent 'make' will fail. If you have already attempted building diff --git a/boards/arm/samd2l2/samd21-xplained/scripts/Make.defs b/boards/arm/samd2l2/samd21-xplained/scripts/Make.defs index df127ba1edc34..904e255d53ca0 100644 --- a/boards/arm/samd2l2/samd21-xplained/scripts/Make.defs +++ b/boards/arm/samd2l2/samd21-xplained/scripts/Make.defs @@ -23,19 +23,8 @@ include $(TOPDIR)/tools/Config.mk include $(TOPDIR)/arch/arm/src/armv6-m/Toolchain.defs LDSCRIPT = flash.ld - ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT) -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new -fno-rtti ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 @@ -50,7 +39,3 @@ AFLAGS := $(CFLAGS) -D__ASSEMBLY__ NXFLATLDFLAGS1 = -r -d -warn-common NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-pcrel.ld -no-check-sections LDNXFLATFLAGS = -e main -s 2048 - -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - LDFLAGS += -g -endif diff --git a/boards/arm/samd2l2/saml21-xplained/README.txt b/boards/arm/samd2l2/saml21-xplained/README.txt index 7905048f40d1a..4c33b93745d19 100644 --- a/boards/arm/samd2l2/saml21-xplained/README.txt +++ b/boards/arm/samd2l2/saml21-xplained/README.txt @@ -265,8 +265,8 @@ GNU Toolchain Options the following configuration options to your .config (or defconfig) file: CONFIG_ARMV7M_TOOLCHAIN_BUILDROOT=y : NuttX buildroot under Linux or Cygwin (default) - CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIL=y : Generic GCC ARM EABI toolchain for Linux - CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIW=y : Generic GCC ARM EABI toolchain for Windows + CONFIG_ARMV7M_TOOLCHAIN_GNU_EABI=y : Generic GCC ARM EABI toolchain for Linux + CONFIG_ARMV7M_TOOLCHAIN_GNU_EABI=y : Generic GCC ARM EABI toolchain for Windows NOTE about Windows native toolchains ------------------------------------ @@ -694,7 +694,7 @@ Configurations that is easily reconfigured: System Type -> Toolchain: - CONFIG_ARMV6M_TOOLCHAIN_GNU_EABIW=y + CONFIG_ARMV6M_TOOLCHAIN_GNU_EABI=y Any re-configuration should be done before making NuttX or else the subsequent 'make' will fail. If you have already attempted building diff --git a/boards/arm/samd2l2/saml21-xplained/scripts/Make.defs b/boards/arm/samd2l2/saml21-xplained/scripts/Make.defs index 2b1a7d006d15b..9029cf3da5dac 100644 --- a/boards/arm/samd2l2/saml21-xplained/scripts/Make.defs +++ b/boards/arm/samd2l2/saml21-xplained/scripts/Make.defs @@ -23,19 +23,8 @@ include $(TOPDIR)/tools/Config.mk include $(TOPDIR)/arch/arm/src/armv6-m/Toolchain.defs LDSCRIPT = flash.ld - ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT) -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new -fno-rtti ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 @@ -50,7 +39,3 @@ AFLAGS := $(CFLAGS) -D__ASSEMBLY__ NXFLATLDFLAGS1 = -r -d -warn-common NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-pcrel.ld -no-check-sections LDNXFLATFLAGS = -e main -s 2048 - -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - LDFLAGS += -g -endif diff --git a/boards/arm/samd5e5/metro-m4/scripts/Make.defs b/boards/arm/samd5e5/metro-m4/scripts/Make.defs index 07bca2bf1fc76..e46dac47e8240 100644 --- a/boards/arm/samd5e5/metro-m4/scripts/Make.defs +++ b/boards/arm/samd5e5/metro-m4/scripts/Make.defs @@ -30,16 +30,6 @@ endif ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT) -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new -fno-rtti ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 @@ -61,7 +51,3 @@ CMODULEFLAGS = $(CFLAGS) -mlong-calls # --target1-abs LDMODULEFLAGS = -r -e module_initialize LDMODULEFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)/libs/libc/modlib/gnu-elf.ld) - -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - LDFLAGS += -g -endif diff --git a/boards/arm/samd5e5/metro-m4/src/sam_automount.c b/boards/arm/samd5e5/metro-m4/src/sam_automount.c index df7b3bb587fbf..7b8b77446d843 100644 --- a/boards/arm/samd5e5/metro-m4/src/sam_automount.c +++ b/boards/arm/samd5e5/metro-m4/src/sam_automount.c @@ -201,7 +201,7 @@ static void sam_enable(FAR const struct automount_lower_s *lower, if (state->handler) { - (void)state->handler(&config->lower, state->arg, true); + state->handler(&config->lower, state->arg, true); } state->pending = false; @@ -320,7 +320,7 @@ void sam_automount_event(bool inserted) { /* No.. forward the event to the handler */ - (void)state->handler(&config->lower, state->arg, state->inserted); + state->handler(&config->lower, state->arg, state->inserted); } } } diff --git a/boards/arm/samd5e5/metro-m4/src/sam_bringup.c b/boards/arm/samd5e5/metro-m4/src/sam_bringup.c index 6761d6c215291..fd052b772ed0d 100644 --- a/boards/arm/samd5e5/metro-m4/src/sam_bringup.c +++ b/boards/arm/samd5e5/metro-m4/src/sam_bringup.c @@ -95,7 +95,7 @@ int sam_bringup(void) #endif #if defined(CONFIG_SAMD5E5_WDT) && defined(CONFIG_WATCHDOG) - (void)sam_wdt_initialize(CONFIG_WATCHDOG_DEVPATH); + sam_wdt_initialize(CONFIG_WATCHDOG_DEVPATH); #endif #ifdef CONFIG_SAMD5E5_SERCOM5_ISI2C diff --git a/boards/arm/samd5e5/metro-m4/src/sam_gpio.c b/boards/arm/samd5e5/metro-m4/src/sam_gpio.c index c9a50d166d68c..1506bc9b05044 100644 --- a/boards/arm/samd5e5/metro-m4/src/sam_gpio.c +++ b/boards/arm/samd5e5/metro-m4/src/sam_gpio.c @@ -287,7 +287,7 @@ int sam_gpio_initialize(void) g_gpin[i].gpio.gp_pintype = GPIO_INPUT_PIN; g_gpin[i].gpio.gp_ops = &gpin_ops; g_gpin[i].id = i; - (void)gpio_pin_register(&g_gpin[i].gpio, pincount); + gpio_pin_register(&g_gpin[i].gpio, pincount); /* Configure the pin that will be used as input */ @@ -305,7 +305,7 @@ int sam_gpio_initialize(void) g_gpout[i].gpio.gp_pintype = GPIO_OUTPUT_PIN; g_gpout[i].gpio.gp_ops = &gpout_ops; g_gpout[i].id = i; - (void)gpio_pin_register(&g_gpout[i].gpio, pincount); + gpio_pin_register(&g_gpout[i].gpio, pincount); /* Configure the pin that will be used as output */ @@ -322,7 +322,7 @@ int sam_gpio_initialize(void) g_gpint[i].samgpio.gpio.gp_pintype = GPIO_INTERRUPT_PIN; g_gpint[i].samgpio.gpio.gp_ops = &gpint_ops; g_gpint[i].samgpio.id = i; - (void)gpio_pin_register(&g_gpint[i].samgpio.gpio, pincount); + gpio_pin_register(&g_gpint[i].samgpio.gpio, pincount); /* Configure the pin that will be used as interrupt input */ diff --git a/boards/arm/samd5e5/same54-xplained-pro/scripts/Make.defs b/boards/arm/samd5e5/same54-xplained-pro/scripts/Make.defs index 4ceaa8ea607cc..4abf269caa3f7 100644 --- a/boards/arm/samd5e5/same54-xplained-pro/scripts/Make.defs +++ b/boards/arm/samd5e5/same54-xplained-pro/scripts/Make.defs @@ -30,16 +30,6 @@ endif ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT) -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new -fno-rtti ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 @@ -61,7 +51,3 @@ CMODULEFLAGS = $(CFLAGS) -mlong-calls # --target1-abs LDMODULEFLAGS = -r -e module_initialize LDMODULEFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)/libs/libc/modlib/gnu-elf.ld) - -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - LDFLAGS += -g -endif diff --git a/boards/arm/samd5e5/same54-xplained-pro/src/sam_autoleds.c b/boards/arm/samd5e5/same54-xplained-pro/src/sam_autoleds.c index 4822189a24492..65a9e3b813cea 100644 --- a/boards/arm/samd5e5/same54-xplained-pro/src/sam_autoleds.c +++ b/boards/arm/samd5e5/same54-xplained-pro/src/sam_autoleds.c @@ -185,7 +185,7 @@ static int led_pm_prepare(struct pm_callback_s *cb, int domain, void board_autoled_initialize(void) { - (void)sam_portconfig(PORT_LED0); + sam_portconfig(PORT_LED0); } /**************************************************************************** diff --git a/boards/arm/samd5e5/same54-xplained-pro/src/sam_boot.c b/boards/arm/samd5e5/same54-xplained-pro/src/sam_boot.c index 0c64bcb117a88..0d90ea80a5904 100644 --- a/boards/arm/samd5e5/same54-xplained-pro/src/sam_boot.c +++ b/boards/arm/samd5e5/same54-xplained-pro/src/sam_boot.c @@ -74,6 +74,6 @@ void board_late_initialize(void) { /* Perform board-specific initialization */ - (void)sam_bringup(); + sam_bringup(); } #endif diff --git a/boards/arm/samv7/common/scripts/gnu-elf.ld b/boards/arm/samv7/common/scripts/gnu-elf.ld deleted file mode 100644 index bda1b9264ebd3..0000000000000 --- a/boards/arm/samv7/common/scripts/gnu-elf.ld +++ /dev/null @@ -1,116 +0,0 @@ -/**************************************************************************** - * boards/arm/samv7/common/scripts/gnu-elf.ld - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. The - * ASF licenses this file to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance with the - * License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - ****************************************************************************/ - -SECTIONS -{ - .text 0x00000000 : - { - _stext = . ; - *(.text) - *(.text.*) - *(.gnu.warning) - *(.stub) - *(.glue_7) - *(.glue_7t) - *(.jcr) - - /* C++ support: The .init and .fini sections contain specific logic - * to manage static constructors and destructors. - */ - - *(.gnu.linkonce.t.*) - *(.init) /* Old ABI */ - *(.fini) /* Old ABI */ - _etext = . ; - } - - .rodata : - { - _srodata = . ; - *(.rodata) - *(.rodata1) - *(.rodata.*) - *(.gnu.linkonce.r*) - _erodata = . ; - } - - .data : - { - _sdata = . ; - *(.data) - *(.data1) - *(.data.*) - *(.gnu.linkonce.d*) - . = ALIGN(4); - _edata = . ; - } - - /* C++ support. For each global and static local C++ object, - * GCC creates a small subroutine to construct the object. Pointers - * to these routines (not the routines themselves) are stored as - * simple, linear arrays in the .ctors section of the object file. - * Similarly, pointers to global/static destructor routines are - * stored in .dtors. - */ - - .ctors : - { - _sctors = . ; - *(.ctors) /* Old ABI: Unallocated */ - *(.init_array) /* New ABI: Allocated */ - _edtors = . ; - } - - .dtors : - { - _sdtors = . ; - *(.dtors) /* Old ABI: Unallocated */ - *(.fini_array) /* New ABI: Allocated */ - _edtors = . ; - } - - .bss : - { - _sbss = . ; - *(.bss) - *(.bss.*) - *(.sbss) - *(.sbss.*) - *(.gnu.linkonce.b*) - *(COMMON) - . = ALIGN(4); - _ebss = . ; - } - - /* Stabs debugging sections. */ - - .stab 0 : { *(.stab) } - .stabstr 0 : { *(.stabstr) } - .stab.excl 0 : { *(.stab.excl) } - .stab.exclstr 0 : { *(.stab.exclstr) } - .stab.index 0 : { *(.stab.index) } - .stab.indexstr 0 : { *(.stab.indexstr) } - .comment 0 : { *(.comment) } - .debug_abbrev 0 : { *(.debug_abbrev) } - .debug_info 0 : { *(.debug_info) } - .debug_line 0 : { *(.debug_line) } - .debug_pubnames 0 : { *(.debug_pubnames) } - .debug_aranges 0 : { *(.debug_aranges) } -} diff --git a/boards/arm/samv7/common/src/sam_automount.c b/boards/arm/samv7/common/src/sam_automount.c index f00b6aa996870..41199e1c6718a 100644 --- a/boards/arm/samv7/common/src/sam_automount.c +++ b/boards/arm/samv7/common/src/sam_automount.c @@ -190,7 +190,7 @@ static void sam_enable(FAR const struct automount_lower_s *lower, if (state->handler) { bool inserted = sam_cardinserted(config->hsmci); - (void)state->handler(&config->lower, state->arg, inserted); + state->handler(&config->lower, state->arg, inserted); } state->pending = false; @@ -324,7 +324,7 @@ void sam_automount_event(int slotno, bool inserted) { /* No.. forward the event to the handler */ - (void)state->handler(&config->lower, state->arg, inserted); + state->handler(&config->lower, state->arg, inserted); } } } diff --git a/boards/arm/samv7/same70-qmtech/README.txt b/boards/arm/samv7/same70-qmtech/README.txt index cebc7522bd1ee..fc0403a861224 100644 --- a/boards/arm/samv7/same70-qmtech/README.txt +++ b/boards/arm/samv7/same70-qmtech/README.txt @@ -700,7 +700,7 @@ NOTES: CONFIG_WINDOWS_CYGWIN=y : Cywin under Windows System Type -> Toolchain: - CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIW=y : GNU ARM EABI toolchain + CONFIG_ARMV7M_TOOLCHAIN_GNU_EABI=y : GNU ARM EABI toolchain NOTE: As of this writing, there are issues with using this tool at the -Os level of optimization. This has not been proven to be a diff --git a/boards/arm/samv7/same70-qmtech/configs/mcuboot-loader/defconfig b/boards/arm/samv7/same70-qmtech/configs/mcuboot-loader/defconfig index 81b43d28361d1..3ecef2333f10a 100644 --- a/boards/arm/samv7/same70-qmtech/configs/mcuboot-loader/defconfig +++ b/boards/arm/samv7/same70-qmtech/configs/mcuboot-loader/defconfig @@ -23,7 +23,6 @@ CONFIG_ARCH_INTERRUPTSTACK=2048 CONFIG_ARCH_STACKDUMP=y CONFIG_ARMV7M_DCACHE=y CONFIG_ARMV7M_ICACHE=y -CONFIG_ARMV7M_LAZYFPU=y CONFIG_BOARD_LATE_INITIALIZE=y CONFIG_BOARD_LOOPSPERMSEC=51262 CONFIG_BOOT_MCUBOOT=y diff --git a/boards/arm/samv7/same70-qmtech/configs/mcuboot-slot-confirm/defconfig b/boards/arm/samv7/same70-qmtech/configs/mcuboot-slot-confirm/defconfig index 4fe7e2a845a1f..62b49bd646241 100644 --- a/boards/arm/samv7/same70-qmtech/configs/mcuboot-slot-confirm/defconfig +++ b/boards/arm/samv7/same70-qmtech/configs/mcuboot-slot-confirm/defconfig @@ -23,7 +23,6 @@ CONFIG_ARCH_INTERRUPTSTACK=2048 CONFIG_ARCH_STACKDUMP=y CONFIG_ARMV7M_DCACHE=y CONFIG_ARMV7M_ICACHE=y -CONFIG_ARMV7M_LAZYFPU=y CONFIG_BOARD_LATE_INITIALIZE=y CONFIG_BOARD_LOOPSPERMSEC=51262 CONFIG_BUILTIN=y diff --git a/boards/arm/samv7/same70-qmtech/configs/nsh/defconfig b/boards/arm/samv7/same70-qmtech/configs/nsh/defconfig index 8b4dc914d97ed..29c7d78d190c1 100644 --- a/boards/arm/samv7/same70-qmtech/configs/nsh/defconfig +++ b/boards/arm/samv7/same70-qmtech/configs/nsh/defconfig @@ -26,7 +26,6 @@ CONFIG_ARCH_IRQBUTTONS=y CONFIG_ARCH_STACKDUMP=y CONFIG_ARMV7M_DCACHE=y CONFIG_ARMV7M_ICACHE=y -CONFIG_ARMV7M_LAZYFPU=y CONFIG_BOARD_LOOPSPERMSEC=51262 CONFIG_BUILTIN=y CONFIG_FAT_LCNAMES=y diff --git a/boards/arm/samv7/same70-qmtech/scripts/Make.defs b/boards/arm/samv7/same70-qmtech/scripts/Make.defs index 6ad009013e1d8..d7053cadd7765 100644 --- a/boards/arm/samv7/same70-qmtech/scripts/Make.defs +++ b/boards/arm/samv7/same70-qmtech/scripts/Make.defs @@ -35,17 +35,7 @@ else LDSCRIPT_TEMPLATE = $(BOARD_COMMON_DIR)$(DELIM)scripts$(DELIM)$(notdir $(SCRIPTOUT).template) endif -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -endif - -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new -fno-rtti -ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef -fno-strict-aliasing +ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 @@ -66,8 +56,3 @@ CMODULEFLAGS = $(CFLAGS) -mlong-calls # --target1-abs LDMODULEFLAGS = -r -e module_initialize LDMODULEFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)/libs/libc/modlib/gnu-elf.ld) - -LDFLAGS += -Map=$(call CONVERT_PATH,$(TOPDIR)/nuttx.map) --cref -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - LDFLAGS += -g -endif diff --git a/boards/arm/samv7/same70-xplained/README.txt b/boards/arm/samv7/same70-xplained/README.txt index 8111050c6b2c4..00a939aaeae07 100644 --- a/boards/arm/samv7/same70-xplained/README.txt +++ b/boards/arm/samv7/same70-xplained/README.txt @@ -1300,7 +1300,7 @@ NOTES: CONFIG_WINDOWS_CYGWIN=y : Cywin under Windows System Type -> Toolchain: - CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIW=y : GNU ARM EABI toolchain + CONFIG_ARMV7M_TOOLCHAIN_GNU_EABI=y : GNU ARM EABI toolchain NOTE: As of this writing, there are issues with using this tool at the -Os level of optimization. This has not been proven to be a diff --git a/boards/arm/samv7/same70-xplained/configs/adc/defconfig b/boards/arm/samv7/same70-xplained/configs/adc/defconfig index 43c01122a7425..4c10f6ee9b835 100644 --- a/boards/arm/samv7/same70-xplained/configs/adc/defconfig +++ b/boards/arm/samv7/same70-xplained/configs/adc/defconfig @@ -31,7 +31,6 @@ CONFIG_ARCH_IRQBUTTONS=y CONFIG_ARCH_STACKDUMP=y CONFIG_ARMV7M_DCACHE=y CONFIG_ARMV7M_ICACHE=y -CONFIG_ARMV7M_LAZYFPU=y CONFIG_AT24XX_ADDR=0x57 CONFIG_AT24XX_EXTENDED=y CONFIG_AT24XX_EXTSIZE=160 diff --git a/boards/arm/samv7/same70-xplained/configs/mcuboot-loader/defconfig b/boards/arm/samv7/same70-xplained/configs/mcuboot-loader/defconfig index 1c5570a36d410..f583c7647c9cd 100644 --- a/boards/arm/samv7/same70-xplained/configs/mcuboot-loader/defconfig +++ b/boards/arm/samv7/same70-xplained/configs/mcuboot-loader/defconfig @@ -28,7 +28,6 @@ CONFIG_ARCH_IRQBUTTONS=y CONFIG_ARCH_STACKDUMP=y CONFIG_ARMV7M_DCACHE=y CONFIG_ARMV7M_ICACHE=y -CONFIG_ARMV7M_LAZYFPU=y CONFIG_AT24XX_ADDR=0x57 CONFIG_AT24XX_EXTENDED=y CONFIG_AT24XX_EXTSIZE=160 diff --git a/boards/arm/samv7/same70-xplained/configs/mcuboot-slot-confirm/defconfig b/boards/arm/samv7/same70-xplained/configs/mcuboot-slot-confirm/defconfig index 12cc258f6e9bd..477eaa40bac20 100644 --- a/boards/arm/samv7/same70-xplained/configs/mcuboot-slot-confirm/defconfig +++ b/boards/arm/samv7/same70-xplained/configs/mcuboot-slot-confirm/defconfig @@ -28,7 +28,6 @@ CONFIG_ARCH_IRQBUTTONS=y CONFIG_ARCH_STACKDUMP=y CONFIG_ARMV7M_DCACHE=y CONFIG_ARMV7M_ICACHE=y -CONFIG_ARMV7M_LAZYFPU=y CONFIG_AT24XX_ADDR=0x57 CONFIG_AT24XX_EXTENDED=y CONFIG_AT24XX_EXTSIZE=160 diff --git a/boards/arm/samv7/same70-xplained/configs/mrf24j40-starhub/defconfig b/boards/arm/samv7/same70-xplained/configs/mrf24j40-starhub/defconfig index 0d408fc55cfab..27496368d11d7 100644 --- a/boards/arm/samv7/same70-xplained/configs/mrf24j40-starhub/defconfig +++ b/boards/arm/samv7/same70-xplained/configs/mrf24j40-starhub/defconfig @@ -26,7 +26,6 @@ CONFIG_ARCH_IRQBUTTONS=y CONFIG_ARCH_STACKDUMP=y CONFIG_ARMV7M_DCACHE=y CONFIG_ARMV7M_ICACHE=y -CONFIG_ARMV7M_LAZYFPU=y CONFIG_AT24XX_ADDR=0x57 CONFIG_AT24XX_EXTENDED=y CONFIG_AT24XX_EXTSIZE=160 diff --git a/boards/arm/samv7/same70-xplained/configs/netnsh/defconfig b/boards/arm/samv7/same70-xplained/configs/netnsh/defconfig index 0f89b0a0bb363..d04c2718b5e0d 100644 --- a/boards/arm/samv7/same70-xplained/configs/netnsh/defconfig +++ b/boards/arm/samv7/same70-xplained/configs/netnsh/defconfig @@ -28,7 +28,6 @@ CONFIG_ARCH_IRQBUTTONS=y CONFIG_ARCH_STACKDUMP=y CONFIG_ARMV7M_DCACHE=y CONFIG_ARMV7M_ICACHE=y -CONFIG_ARMV7M_LAZYFPU=y CONFIG_AT24XX_ADDR=0x57 CONFIG_AT24XX_EXTENDED=y CONFIG_AT24XX_EXTSIZE=160 diff --git a/boards/arm/samv7/same70-xplained/configs/nsh/defconfig b/boards/arm/samv7/same70-xplained/configs/nsh/defconfig index 9a51409932566..af72bda2e6525 100644 --- a/boards/arm/samv7/same70-xplained/configs/nsh/defconfig +++ b/boards/arm/samv7/same70-xplained/configs/nsh/defconfig @@ -29,7 +29,6 @@ CONFIG_ARCH_IRQBUTTONS=y CONFIG_ARCH_STACKDUMP=y CONFIG_ARMV7M_DCACHE=y CONFIG_ARMV7M_ICACHE=y -CONFIG_ARMV7M_LAZYFPU=y CONFIG_AT24XX_ADDR=0x57 CONFIG_AT24XX_EXTENDED=y CONFIG_AT24XX_EXTSIZE=160 diff --git a/boards/arm/samv7/same70-xplained/configs/pwm/defconfig b/boards/arm/samv7/same70-xplained/configs/pwm/defconfig index f2cc60be7e15a..a8a1bd34de0d6 100644 --- a/boards/arm/samv7/same70-xplained/configs/pwm/defconfig +++ b/boards/arm/samv7/same70-xplained/configs/pwm/defconfig @@ -29,7 +29,6 @@ CONFIG_ARCH_IRQBUTTONS=y CONFIG_ARCH_STACKDUMP=y CONFIG_ARMV7M_DCACHE=y CONFIG_ARMV7M_ICACHE=y -CONFIG_ARMV7M_LAZYFPU=y CONFIG_AT24XX_ADDR=0x57 CONFIG_AT24XX_EXTENDED=y CONFIG_AT24XX_EXTSIZE=160 diff --git a/boards/arm/samv7/same70-xplained/configs/pysim/defconfig b/boards/arm/samv7/same70-xplained/configs/pysim/defconfig index 5fcceda26b121..69f728c69a63c 100644 --- a/boards/arm/samv7/same70-xplained/configs/pysim/defconfig +++ b/boards/arm/samv7/same70-xplained/configs/pysim/defconfig @@ -31,7 +31,6 @@ CONFIG_ARCH_RAMVECTORS=y CONFIG_ARCH_STACKDUMP=y CONFIG_ARMV7M_DCACHE=y CONFIG_ARMV7M_ICACHE=y -CONFIG_ARMV7M_LAZYFPU=y CONFIG_AT24XX_ADDR=0x57 CONFIG_AT24XX_EXTENDED=y CONFIG_AT24XX_EXTSIZE=160 diff --git a/boards/arm/samv7/same70-xplained/configs/twm4nx/defconfig b/boards/arm/samv7/same70-xplained/configs/twm4nx/defconfig index af4e782e15611..5a3dfb7ebc11b 100644 --- a/boards/arm/samv7/same70-xplained/configs/twm4nx/defconfig +++ b/boards/arm/samv7/same70-xplained/configs/twm4nx/defconfig @@ -30,7 +30,6 @@ CONFIG_ARCH_STACKDUMP=y CONFIG_ARCH_STDARG_H=y CONFIG_ARMV7M_DCACHE=y CONFIG_ARMV7M_ICACHE=y -CONFIG_ARMV7M_LAZYFPU=y CONFIG_AT24XX_ADDR=0x57 CONFIG_AT24XX_EXTENDED=y CONFIG_AT24XX_EXTSIZE=160 diff --git a/boards/arm/samv7/same70-xplained/scripts/Make.defs b/boards/arm/samv7/same70-xplained/scripts/Make.defs index 72768d7c3cd01..51bda97795ba3 100644 --- a/boards/arm/samv7/same70-xplained/scripts/Make.defs +++ b/boards/arm/samv7/same70-xplained/scripts/Make.defs @@ -35,17 +35,7 @@ else LDSCRIPT_TEMPLATE = $(BOARD_COMMON_DIR)$(DELIM)scripts$(DELIM)$(notdir $(SCRIPTOUT).template) endif -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -endif - -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new -fno-rtti -ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef -fno-strict-aliasing +ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 @@ -67,8 +57,3 @@ CMODULEFLAGS = $(CFLAGS) -mlong-calls # --target1-abs LDMODULEFLAGS = -r -e module_initialize LDMODULEFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)/libs/libc/modlib/gnu-elf.ld) -LDFLAGS += -Map=$(call CONVERT_PATH,$(TOPDIR)/nuttx.map) --cref -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - LDFLAGS += -g -endif - diff --git a/boards/arm/samv7/samv71-xult/README.txt b/boards/arm/samv7/samv71-xult/README.txt index 1b9183e5f5245..501be46d8bb4c 100644 --- a/boards/arm/samv7/samv71-xult/README.txt +++ b/boards/arm/samv7/samv71-xult/README.txt @@ -1699,7 +1699,7 @@ NOTES: CONFIG_WINDOWS_CYGWIN=y : Cywin under Windows System Type -> Toolchain: - CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIW=y : GNU ARM EABI toolchain + CONFIG_ARMV7M_TOOLCHAIN_GNU_EABI=y : GNU ARM EABI toolchain Configuration sub-directories ----------------------------- diff --git a/boards/arm/samv7/samv71-xult/configs/knsh/Make.defs b/boards/arm/samv7/samv71-xult/configs/knsh/Make.defs index 1a0ab92abb168..a4989f71d5846 100644 --- a/boards/arm/samv7/samv71-xult/configs/knsh/Make.defs +++ b/boards/arm/samv7/samv71-xult/configs/knsh/Make.defs @@ -41,17 +41,7 @@ else ARCHSCRIPT += $(BOARD_COMMON_DIR)$(DELIM)scripts$(DELIM)kernel-space.ld endif -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -endif - -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new -fno-rtti -ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef -fno-strict-aliasing +ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 @@ -72,8 +62,3 @@ CMODULEFLAGS = $(CFLAGS) -mlong-calls # --target1-abs LDMODULEFLAGS = -r -e module_initialize LDMODULEFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)/libs/libc/modlib/gnu-elf.ld) - -LDFLAGS += -Map=$(call CONVERT_PATH,$(TOPDIR)/nuttx.map) --cref -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - LDFLAGS += -g -endif diff --git a/boards/arm/samv7/samv71-xult/configs/knsh/defconfig b/boards/arm/samv7/samv71-xult/configs/knsh/defconfig index 87a699b484577..6876ef56cdd45 100644 --- a/boards/arm/samv7/samv71-xult/configs/knsh/defconfig +++ b/boards/arm/samv7/samv71-xult/configs/knsh/defconfig @@ -29,7 +29,6 @@ CONFIG_ARCH_IRQBUTTONS=y CONFIG_ARCH_STACKDUMP=y CONFIG_ARMV7M_DCACHE=y CONFIG_ARMV7M_ICACHE=y -CONFIG_ARMV7M_LAZYFPU=y CONFIG_ARM_MPU=y CONFIG_AT24XX_ADDR=0x57 CONFIG_AT24XX_EXTENDED=y diff --git a/boards/arm/samv7/samv71-xult/configs/mcuboot-loader/defconfig b/boards/arm/samv7/samv71-xult/configs/mcuboot-loader/defconfig index 0f7a9afecf4f0..139c3301213dd 100644 --- a/boards/arm/samv7/samv71-xult/configs/mcuboot-loader/defconfig +++ b/boards/arm/samv7/samv71-xult/configs/mcuboot-loader/defconfig @@ -25,7 +25,6 @@ CONFIG_ARCH_IRQBUTTONS=y CONFIG_ARCH_STACKDUMP=y CONFIG_ARMV7M_DCACHE=y CONFIG_ARMV7M_ICACHE=y -CONFIG_ARMV7M_LAZYFPU=y CONFIG_BOARDCTL_RESET=y CONFIG_BOARD_LATE_INITIALIZE=y CONFIG_BOARD_LOOPSPERMSEC=51262 diff --git a/boards/arm/samv7/samv71-xult/configs/mcuboot-slot-confirm/defconfig b/boards/arm/samv7/samv71-xult/configs/mcuboot-slot-confirm/defconfig index 91665a2115f9a..efb7d6c7bad6f 100644 --- a/boards/arm/samv7/samv71-xult/configs/mcuboot-slot-confirm/defconfig +++ b/boards/arm/samv7/samv71-xult/configs/mcuboot-slot-confirm/defconfig @@ -25,7 +25,6 @@ CONFIG_ARCH_IRQBUTTONS=y CONFIG_ARCH_STACKDUMP=y CONFIG_ARMV7M_DCACHE=y CONFIG_ARMV7M_ICACHE=y -CONFIG_ARMV7M_LAZYFPU=y CONFIG_BOARDCTL_RESET=y CONFIG_BOARD_LATE_INITIALIZE=y CONFIG_BOARD_LOOPSPERMSEC=51262 diff --git a/boards/arm/samv7/samv71-xult/configs/mcuboot-swap-test/defconfig b/boards/arm/samv7/samv71-xult/configs/mcuboot-swap-test/defconfig index 80521525d2c57..e489c7eb0337c 100644 --- a/boards/arm/samv7/samv71-xult/configs/mcuboot-swap-test/defconfig +++ b/boards/arm/samv7/samv71-xult/configs/mcuboot-swap-test/defconfig @@ -25,7 +25,6 @@ CONFIG_ARCH_IRQBUTTONS=y CONFIG_ARCH_STACKDUMP=y CONFIG_ARMV7M_DCACHE=y CONFIG_ARMV7M_ICACHE=y -CONFIG_ARMV7M_LAZYFPU=y CONFIG_BOARDCTL_RESET=y CONFIG_BOARD_LATE_INITIALIZE=y CONFIG_BOARD_LOOPSPERMSEC=51262 diff --git a/boards/arm/samv7/samv71-xult/configs/mcuboot-update-agent/defconfig b/boards/arm/samv7/samv71-xult/configs/mcuboot-update-agent/defconfig index 22562d645a603..ad3d801a6b3bf 100644 --- a/boards/arm/samv7/samv71-xult/configs/mcuboot-update-agent/defconfig +++ b/boards/arm/samv7/samv71-xult/configs/mcuboot-update-agent/defconfig @@ -27,7 +27,6 @@ CONFIG_ARCH_IRQBUTTONS=y CONFIG_ARCH_STACKDUMP=y CONFIG_ARMV7M_DCACHE=y CONFIG_ARMV7M_ICACHE=y -CONFIG_ARMV7M_LAZYFPU=y CONFIG_AT24XX_ADDR=0x57 CONFIG_AT24XX_EXTENDED=y CONFIG_AT24XX_EXTSIZE=160 diff --git a/boards/arm/samv7/samv71-xult/configs/module/defconfig b/boards/arm/samv7/samv71-xult/configs/module/defconfig index d7b5985580e56..ce8d367614fb5 100644 --- a/boards/arm/samv7/samv71-xult/configs/module/defconfig +++ b/boards/arm/samv7/samv71-xult/configs/module/defconfig @@ -26,7 +26,6 @@ CONFIG_ARCH_STACKDUMP=y CONFIG_ARMV7M_DCACHE=y CONFIG_ARMV7M_DCACHE_WRITETHROUGH=y CONFIG_ARMV7M_ICACHE=y -CONFIG_ARMV7M_LAZYFPU=y CONFIG_ARMV7M_USEBASEPRI=y CONFIG_BOARDCTL_ROMDISK=y CONFIG_BOARD_LOOPSPERMSEC=51262 diff --git a/boards/arm/samv7/samv71-xult/configs/mrf24j40-starhub/defconfig b/boards/arm/samv7/samv71-xult/configs/mrf24j40-starhub/defconfig index 52a906f81952b..ae6f2e58c4d79 100644 --- a/boards/arm/samv7/samv71-xult/configs/mrf24j40-starhub/defconfig +++ b/boards/arm/samv7/samv71-xult/configs/mrf24j40-starhub/defconfig @@ -27,7 +27,6 @@ CONFIG_ARCH_IRQBUTTONS=y CONFIG_ARCH_STACKDUMP=y CONFIG_ARMV7M_DCACHE=y CONFIG_ARMV7M_ICACHE=y -CONFIG_ARMV7M_LAZYFPU=y CONFIG_AT24XX_ADDR=0x57 CONFIG_AT24XX_EXTENDED=y CONFIG_AT24XX_EXTSIZE=160 diff --git a/boards/arm/samv7/samv71-xult/configs/mxtxplnd/defconfig b/boards/arm/samv7/samv71-xult/configs/mxtxplnd/defconfig index 65d0fb8812fce..492d5ce145ef8 100644 --- a/boards/arm/samv7/samv71-xult/configs/mxtxplnd/defconfig +++ b/boards/arm/samv7/samv71-xult/configs/mxtxplnd/defconfig @@ -30,7 +30,6 @@ CONFIG_ARCH_IRQBUTTONS=y CONFIG_ARCH_STACKDUMP=y CONFIG_ARMV7M_DCACHE=y CONFIG_ARMV7M_ICACHE=y -CONFIG_ARMV7M_LAZYFPU=y CONFIG_AT24XX_ADDR=0x57 CONFIG_AT24XX_EXTENDED=y CONFIG_AT24XX_EXTSIZE=160 diff --git a/boards/arm/samv7/samv71-xult/configs/netnsh/defconfig b/boards/arm/samv7/samv71-xult/configs/netnsh/defconfig index 09990555e0b68..b3a22cbef520e 100644 --- a/boards/arm/samv7/samv71-xult/configs/netnsh/defconfig +++ b/boards/arm/samv7/samv71-xult/configs/netnsh/defconfig @@ -28,7 +28,6 @@ CONFIG_ARCH_IRQBUTTONS=y CONFIG_ARCH_STACKDUMP=y CONFIG_ARMV7M_DCACHE=y CONFIG_ARMV7M_ICACHE=y -CONFIG_ARMV7M_LAZYFPU=y CONFIG_AT24XX_ADDR=0x57 CONFIG_AT24XX_EXTENDED=y CONFIG_AT24XX_EXTSIZE=160 diff --git a/boards/arm/samv7/samv71-xult/configs/nsh/defconfig b/boards/arm/samv7/samv71-xult/configs/nsh/defconfig index 81d946ad04bf4..1e4391969d5ca 100644 --- a/boards/arm/samv7/samv71-xult/configs/nsh/defconfig +++ b/boards/arm/samv7/samv71-xult/configs/nsh/defconfig @@ -29,7 +29,6 @@ CONFIG_ARCH_IRQBUTTONS=y CONFIG_ARCH_STACKDUMP=y CONFIG_ARMV7M_DCACHE=y CONFIG_ARMV7M_ICACHE=y -CONFIG_ARMV7M_LAZYFPU=y CONFIG_AT24XX_ADDR=0x57 CONFIG_AT24XX_EXTENDED=y CONFIG_AT24XX_EXTSIZE=160 diff --git a/boards/arm/samv7/samv71-xult/configs/nxwm/defconfig b/boards/arm/samv7/samv71-xult/configs/nxwm/defconfig index ba00d20ffadc3..99be08f1f9c3a 100644 --- a/boards/arm/samv7/samv71-xult/configs/nxwm/defconfig +++ b/boards/arm/samv7/samv71-xult/configs/nxwm/defconfig @@ -32,7 +32,6 @@ CONFIG_ARCH_IRQBUTTONS=y CONFIG_ARCH_STACKDUMP=y CONFIG_ARMV7M_DCACHE=y CONFIG_ARMV7M_ICACHE=y -CONFIG_ARMV7M_LAZYFPU=y CONFIG_AT24XX_ADDR=0x57 CONFIG_AT24XX_EXTENDED=y CONFIG_AT24XX_EXTSIZE=160 diff --git a/boards/arm/samv7/samv71-xult/configs/vnc/defconfig b/boards/arm/samv7/samv71-xult/configs/vnc/defconfig index 46f1328c57814..8aa2fa8388f7a 100644 --- a/boards/arm/samv7/samv71-xult/configs/vnc/defconfig +++ b/boards/arm/samv7/samv71-xult/configs/vnc/defconfig @@ -29,7 +29,6 @@ CONFIG_ARCH_IRQBUTTONS=y CONFIG_ARCH_STACKDUMP=y CONFIG_ARMV7M_DCACHE=y CONFIG_ARMV7M_ICACHE=y -CONFIG_ARMV7M_LAZYFPU=y CONFIG_AT24XX_ADDR=0x57 CONFIG_AT24XX_EXTENDED=y CONFIG_AT24XX_EXTSIZE=160 diff --git a/boards/arm/samv7/samv71-xult/configs/vnxwm/defconfig b/boards/arm/samv7/samv71-xult/configs/vnxwm/defconfig index 6337925e9ac70..dd6d4544785b5 100644 --- a/boards/arm/samv7/samv71-xult/configs/vnxwm/defconfig +++ b/boards/arm/samv7/samv71-xult/configs/vnxwm/defconfig @@ -29,7 +29,6 @@ CONFIG_ARCH_IRQBUTTONS=y CONFIG_ARCH_STACKDUMP=y CONFIG_ARMV7M_DCACHE=y CONFIG_ARMV7M_ICACHE=y -CONFIG_ARMV7M_LAZYFPU=y CONFIG_AT24XX_ADDR=0x57 CONFIG_AT24XX_EXTENDED=y CONFIG_AT24XX_EXTSIZE=160 diff --git a/boards/arm/samv7/samv71-xult/scripts/Make.defs b/boards/arm/samv7/samv71-xult/scripts/Make.defs index b3afb2060deae..d3474fcd278dd 100644 --- a/boards/arm/samv7/samv71-xult/scripts/Make.defs +++ b/boards/arm/samv7/samv71-xult/scripts/Make.defs @@ -35,17 +35,7 @@ else LDSCRIPT_TEMPLATE = $(BOARD_COMMON_DIR)$(DELIM)scripts$(DELIM)$(notdir $(SCRIPTOUT).template) endif -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -endif - -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new -fno-rtti -ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef -fno-strict-aliasing +ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 @@ -67,8 +57,3 @@ CMODULEFLAGS = $(CFLAGS) -mlong-calls # --target1-abs LDMODULEFLAGS = -r -e module_initialize LDMODULEFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)/libs/libc/modlib/gnu-elf.ld) -LDFLAGS += -Map=$(call CONVERT_PATH,$(TOPDIR)/nuttx.map) --cref -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - LDFLAGS += -g -endif - diff --git a/boards/arm/stm32/axoloti/scripts/Make.defs b/boards/arm/stm32/axoloti/scripts/Make.defs index 60120eabbbf19..b087541c7bec2 100644 --- a/boards/arm/stm32/axoloti/scripts/Make.defs +++ b/boards/arm/stm32/axoloti/scripts/Make.defs @@ -23,19 +23,8 @@ include $(TOPDIR)/tools/Config.mk include $(TOPDIR)/arch/arm/src/armv7-m/Toolchain.defs LDSCRIPT = ld.script - ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT) -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new -fno-rtti ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 @@ -64,8 +53,4 @@ CELFFLAGS = $(CFLAGS) -mlong-calls # --target1-abs CXXELFFLAGS = $(CXXFLAGS) -mlong-calls # --target1-abs LDELFFLAGS = -r -e main -LDELFFLAGS += -T $(call CONVERT_PATH,$(BOARD_DIR)$(DELIM)scripts$(DELIM)gnu-elf.ld) - -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - LDFLAGS += -g -endif +LDELFFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)/binfmt/libelf/gnu-elf.ld) diff --git a/boards/arm/stm32/axoloti/scripts/gnu-elf.ld b/boards/arm/stm32/axoloti/scripts/gnu-elf.ld deleted file mode 100644 index afd759791cf5b..0000000000000 --- a/boards/arm/stm32/axoloti/scripts/gnu-elf.ld +++ /dev/null @@ -1,126 +0,0 @@ -/**************************************************************************** - * boards/arm/stm32/axoloti/scripts/gnu-elf.ld - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. The - * ASF licenses this file to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance with the - * License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - ****************************************************************************/ - -SECTIONS -{ - .text 0x00000000 : - { - _stext = . ; - *(.text) - *(.text.*) - *(.gnu.warning) - *(.stub) - *(.glue_7) - *(.glue_7t) - *(.jcr) - - /* C++ support: The .init and .fini sections contain specific logic - * to manage static constructors and destructors. - */ - - *(.gnu.linkonce.t.*) - *(.init) /* Old ABI */ - *(.fini) /* Old ABI */ - _etext = . ; - } - - .ARM.extab : - { - *(.ARM.extab*) - } - - .ARM.exidx : - { - *(.ARM.exidx*) - } - - .rodata : - { - _srodata = . ; - *(.rodata) - *(.rodata1) - *(.rodata.*) - *(.gnu.linkonce.r*) - _erodata = . ; - } - - .data : - { - _sdata = . ; - *(.data) - *(.data1) - *(.data.*) - *(.gnu.linkonce.d*) - . = ALIGN(4); - _edata = . ; - } - - /* C++ support. For each global and static local C++ object, - * GCC creates a small subroutine to construct the object. Pointers - * to these routines (not the routines themselves) are stored as - * simple, linear arrays in the .ctors section of the object file. - * Similarly, pointers to global/static destructor routines are - * stored in .dtors. - */ - - .ctors : - { - _sctors = . ; - *(.ctors) /* Old ABI: Unallocated */ - *(.init_array) /* New ABI: Allocated */ - _edtors = . ; - } - - .dtors : - { - _sdtors = . ; - *(.dtors) /* Old ABI: Unallocated */ - *(.fini_array) /* New ABI: Allocated */ - _edtors = . ; - } - - .bss : - { - _sbss = . ; - *(.bss) - *(.bss.*) - *(.sbss) - *(.sbss.*) - *(.gnu.linkonce.b*) - *(COMMON) - . = ALIGN(4); - _ebss = . ; - } - - /* Stabs debugging sections. */ - - .stab 0 : { *(.stab) } - .stabstr 0 : { *(.stabstr) } - .stab.excl 0 : { *(.stab.excl) } - .stab.exclstr 0 : { *(.stab.exclstr) } - .stab.index 0 : { *(.stab.index) } - .stab.indexstr 0 : { *(.stab.indexstr) } - .comment 0 : { *(.comment) } - .debug_abbrev 0 : { *(.debug_abbrev) } - .debug_info 0 : { *(.debug_info) } - .debug_line 0 : { *(.debug_line) } - .debug_pubnames 0 : { *(.debug_pubnames) } - .debug_aranges 0 : { *(.debug_aranges) } -} diff --git a/boards/arm/stm32/b-g431b-esc1/scripts/Make.defs b/boards/arm/stm32/b-g431b-esc1/scripts/Make.defs index c805749cc8c4e..605dba9fe706c 100644 --- a/boards/arm/stm32/b-g431b-esc1/scripts/Make.defs +++ b/boards/arm/stm32/b-g431b-esc1/scripts/Make.defs @@ -30,23 +30,15 @@ endif ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT) -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - -ARCHCFLAGS = -fno-common -funwind-tables -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new -funwind-tables +ARCHCFLAGS += -funwind-tables +ARCHCXXFLAGS += -funwind-tables ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 -CFLAGS := $(ARCHCFLAGS) $(ARCHWARNINGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) -ffunction-sections -fdata-sections -pipe +CFLAGS := $(ARCHCFLAGS) $(ARCHWARNINGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) -pipe CPICFLAGS = $(ARCHPICFLAGS) $(CFLAGS) -CXXFLAGS := $(ARCHCXXFLAGS) $(ARCHWARNINGSXX) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHXXINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) -ffunction-sections -fdata-sections -pipe +CXXFLAGS := $(ARCHCXXFLAGS) $(ARCHWARNINGSXX) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHXXINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) -pipe CXXPICFLAGS = $(ARCHPICFLAGS) $(CXXFLAGS) CPPFLAGS := $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) AFLAGS := $(CFLAGS) -D__ASSEMBLY__ @@ -55,13 +47,6 @@ NXFLATLDFLAGS1 = -r -d -warn-common NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-pcrel.ld -no-check-sections LDNXFLATFLAGS = -e main -s 2048 -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - LDFLAGS += -g -endif - -# Provide map file needed by the "Memory Allocation" view in Eclipse: -LDFLAGS += -Map=$(TOPDIR)/NuttX.map --gc-sections - # Embed absolute path to source file in debug information so that Eclipse # source level debugging won't get confused. See: # https://stackoverflow.com/questions/1275476/gcc-gdb-how-to-embed-absolute-path-to-source-file-in-debug-information diff --git a/boards/arm/stm32/b-g474e-dpow1/configs/nsh/defconfig b/boards/arm/stm32/b-g474e-dpow1/configs/nsh/defconfig index dfcf89ac1371a..cbe3d8ec1c098 100644 --- a/boards/arm/stm32/b-g474e-dpow1/configs/nsh/defconfig +++ b/boards/arm/stm32/b-g474e-dpow1/configs/nsh/defconfig @@ -17,7 +17,6 @@ CONFIG_ARCH_CHIP_STM32G474R=y CONFIG_ARCH_HIPRI_INTERRUPT=y CONFIG_ARCH_RAMVECTORS=y CONFIG_ARCH_STACKDUMP=y -CONFIG_ARMV7M_LAZYFPU=y CONFIG_ARMV7M_LIBM=y CONFIG_ARMV7M_MEMCPY=y CONFIG_DEBUG_FEATURES=y diff --git a/boards/arm/stm32/b-g474e-dpow1/scripts/Make.defs b/boards/arm/stm32/b-g474e-dpow1/scripts/Make.defs index 16c279de4d3ef..6a1e0bf9317fc 100644 --- a/boards/arm/stm32/b-g474e-dpow1/scripts/Make.defs +++ b/boards/arm/stm32/b-g474e-dpow1/scripts/Make.defs @@ -30,23 +30,15 @@ endif ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT) -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - -ARCHCFLAGS = -fno-common -funwind-tables -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new -funwind-tables +ARCHCFLAGS += -funwind-tables +ARCHCXXFLAGS += -funwind-tables ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 -CFLAGS := $(ARCHCFLAGS) $(ARCHWARNINGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) -ffunction-sections -fdata-sections -pipe +CFLAGS := $(ARCHCFLAGS) $(ARCHWARNINGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) -pipe CPICFLAGS = $(ARCHPICFLAGS) $(CFLAGS) -CXXFLAGS := $(ARCHCXXFLAGS) $(ARCHWARNINGSXX) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHXXINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) -ffunction-sections -fdata-sections -pipe +CXXFLAGS := $(ARCHCXXFLAGS) $(ARCHWARNINGSXX) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHXXINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) -pipe CXXPICFLAGS = $(ARCHPICFLAGS) $(CXXFLAGS) CPPFLAGS := $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) AFLAGS := $(CFLAGS) -D__ASSEMBLY__ @@ -55,13 +47,6 @@ NXFLATLDFLAGS1 = -r -d -warn-common NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-pcrel.ld -no-check-sections LDNXFLATFLAGS = -e main -s 2048 -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - LDFLAGS += -g -endif - -# Provide map file needed by the "Memory Allocation" view in Eclipse: -LDFLAGS += -Map=$(TOPDIR)/NuttX.map --gc-sections - # Embed absolute path to source file in debug information so that Eclipse # source level debugging won't get confused. See: # https://stackoverflow.com/questions/1275476/gcc-gdb-how-to-embed-absolute-path-to-source-file-in-debug-information diff --git a/boards/arm/stm32/clicker2-stm32/README.txt b/boards/arm/stm32/clicker2-stm32/README.txt index 6cf7505d2a8b5..c53cc225f5452 100644 --- a/boards/arm/stm32/clicker2-stm32/README.txt +++ b/boards/arm/stm32/clicker2-stm32/README.txt @@ -216,7 +216,7 @@ Configurations CONFIG_HOST_LINUX =y : Linux environment System Type -> Toolchain: - CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIL=y : GNU ARM EABI toolchain + CONFIG_ARMV7M_TOOLCHAIN_GNU_EABI=y : GNU ARM EABI toolchain Configuration sub-directories ----------------------------- diff --git a/boards/arm/stm32/clicker2-stm32/scripts/Make.defs b/boards/arm/stm32/clicker2-stm32/scripts/Make.defs index 1d30f89e7d2ec..dc1178226429a 100644 --- a/boards/arm/stm32/clicker2-stm32/scripts/Make.defs +++ b/boards/arm/stm32/clicker2-stm32/scripts/Make.defs @@ -23,31 +23,15 @@ include $(TOPDIR)/tools/Config.mk include $(TOPDIR)/arch/arm/src/armv7-m/Toolchain.defs LDSCRIPT = flash.ld - ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT) -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - -# enable precise stack overflow tracking -ifeq ($(CONFIG_ARMV7M_STACKCHECK),y) - INSTRUMENTATIONDEFINES = -finstrument-functions -ffixed-r10 -endif - -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new -fno-rtti ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 -CFLAGS := $(ARCHCFLAGS) $(ARCHWARNINGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) $(INSTRUMENTATIONDEFINES) -pipe +CFLAGS := $(ARCHCFLAGS) $(ARCHWARNINGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) -pipe CPICFLAGS = $(ARCHPICFLAGS) $(CFLAGS) -CXXFLAGS := $(ARCHCXXFLAGS) $(ARCHWARNINGSXX) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHXXINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) $(INSTRUMENTATIONDEFINES) -pipe +CXXFLAGS := $(ARCHCXXFLAGS) $(ARCHWARNINGSXX) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHXXINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) -pipe CXXPICFLAGS = $(ARCHPICFLAGS) $(CXXFLAGS) CPPFLAGS := $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) AFLAGS := $(CFLAGS) -D__ASSEMBLY__ @@ -62,7 +46,3 @@ CMODULEFLAGS = $(CFLAGS) -mlong-calls # --target1-abs LDMODULEFLAGS = -r -e module_initialize LDMODULEFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)/libs/libc/modlib/gnu-elf.ld) - -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - LDFLAGS += -g -endif diff --git a/boards/arm/stm32/clicker2-stm32/scripts/gnu-elf.ld b/boards/arm/stm32/clicker2-stm32/scripts/gnu-elf.ld deleted file mode 100644 index a04736f672eba..0000000000000 --- a/boards/arm/stm32/clicker2-stm32/scripts/gnu-elf.ld +++ /dev/null @@ -1,126 +0,0 @@ -/**************************************************************************** - * boards/arm/stm32/clicker2-stm32/scripts/gnu-elf.ld - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. The - * ASF licenses this file to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance with the - * License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - ****************************************************************************/ - -SECTIONS -{ - .text 0x00000000 : - { - _stext = . ; - *(.text) - *(.text.*) - *(.gnu.warning) - *(.stub) - *(.glue_7) - *(.glue_7t) - *(.jcr) - - /* C++ support: The .init and .fini sections contain specific logic - * to manage static constructors and destructors. - */ - - *(.gnu.linkonce.t.*) - *(.init) /* Old ABI */ - *(.fini) /* Old ABI */ - _etext = . ; - } - - .ARM.extab : - { - *(.ARM.extab*) - } - - .ARM.exidx : - { - *(.ARM.exidx*) - } - - .rodata : - { - _srodata = . ; - *(.rodata) - *(.rodata1) - *(.rodata.*) - *(.gnu.linkonce.r*) - _erodata = . ; - } - - .data : - { - _sdata = . ; - *(.data) - *(.data1) - *(.data.*) - *(.gnu.linkonce.d*) - . = ALIGN(4); - _edata = . ; - } - - /* C++ support. For each global and static local C++ object, - * GCC creates a small subroutine to construct the object. Pointers - * to these routines (not the routines themselves) are stored as - * simple, linear arrays in the .ctors section of the object file. - * Similarly, pointers to global/static destructor routines are - * stored in .dtors. - */ - - .ctors : - { - _sctors = . ; - *(.ctors) /* Old ABI: Unallocated */ - *(.init_array) /* New ABI: Allocated */ - _edtors = . ; - } - - .dtors : - { - _sdtors = . ; - *(.dtors) /* Old ABI: Unallocated */ - *(.fini_array) /* New ABI: Allocated */ - _edtors = . ; - } - - .bss : - { - _sbss = . ; - *(.bss) - *(.bss.*) - *(.sbss) - *(.sbss.*) - *(.gnu.linkonce.b*) - *(COMMON) - . = ALIGN(4); - _ebss = . ; - } - - /* Stabs debugging sections. */ - - .stab 0 : { *(.stab) } - .stabstr 0 : { *(.stabstr) } - .stab.excl 0 : { *(.stab.excl) } - .stab.exclstr 0 : { *(.stab.exclstr) } - .stab.index 0 : { *(.stab.index) } - .stab.indexstr 0 : { *(.stab.indexstr) } - .comment 0 : { *(.comment) } - .debug_abbrev 0 : { *(.debug_abbrev) } - .debug_info 0 : { *(.debug_info) } - .debug_line 0 : { *(.debug_line) } - .debug_pubnames 0 : { *(.debug_pubnames) } - .debug_aranges 0 : { *(.debug_aranges) } -} diff --git a/boards/arm/stm32/cloudctrl/README.txt b/boards/arm/stm32/cloudctrl/README.txt index 848b045b5e805..daf95bf982ef7 100644 --- a/boards/arm/stm32/cloudctrl/README.txt +++ b/boards/arm/stm32/cloudctrl/README.txt @@ -474,7 +474,7 @@ Where is one of the following: Configures the NuttShell (nsh) located at apps/examples/nsh. The Configuration enables both the serial and telnet NSH interfaces. - CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIW=y : GNU EABI toolchain for Windows + CONFIG_ARMV7M_TOOLCHAIN_GNU_EABI=y : GNU EABI toolchain for Windows CONFIG_NSH_DHCPC=n : DHCP is disabled CONFIG_NSH_IPADDR=0x0a000002 : Target IP address 10.0.0.2 CONFIG_NSH_DRIPADDR=0x0a000001 : Host IP address 10.0.0.1 diff --git a/boards/arm/stm32/cloudctrl/scripts/Make.defs b/boards/arm/stm32/cloudctrl/scripts/Make.defs index 6e64d206b1d9e..c1cd4ae56db90 100644 --- a/boards/arm/stm32/cloudctrl/scripts/Make.defs +++ b/boards/arm/stm32/cloudctrl/scripts/Make.defs @@ -32,16 +32,6 @@ endif ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT) -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new -fno-rtti ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 @@ -56,7 +46,3 @@ AFLAGS := $(CFLAGS) -D__ASSEMBLY__ NXFLATLDFLAGS1 = -r -d -warn-common NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-gotoff.ld -no-check-sections LDNXFLATFLAGS = -e main -s 2048 - -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - LDFLAGS += -g -endif diff --git a/boards/arm/stm32/emw3162/scripts/Make.defs b/boards/arm/stm32/emw3162/scripts/Make.defs index 8f158314d3bd7..7c95fe92a1876 100644 --- a/boards/arm/stm32/emw3162/scripts/Make.defs +++ b/boards/arm/stm32/emw3162/scripts/Make.defs @@ -23,19 +23,8 @@ include $(TOPDIR)/tools/Config.mk include $(TOPDIR)/arch/arm/src/armv7-m/Toolchain.defs LDSCRIPT = ld.script - ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT) -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new -fno-rtti ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 @@ -50,7 +39,3 @@ AFLAGS := $(CFLAGS) -D__ASSEMBLY__ NXFLATLDFLAGS1 = -r -Wl,-d -Wl,-warn-common NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-pcrel.ld -Wl,-no-check-sections LDNXFLATFLAGS = -e main -s 2048 - -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - LDFLAGS += -g -endif diff --git a/boards/arm/stm32/et-stm32-stamp/scripts/Make.defs b/boards/arm/stm32/et-stm32-stamp/scripts/Make.defs index 5b5ef207cf64a..f9fab0a8797f9 100644 --- a/boards/arm/stm32/et-stm32-stamp/scripts/Make.defs +++ b/boards/arm/stm32/et-stm32-stamp/scripts/Make.defs @@ -23,19 +23,8 @@ include $(TOPDIR)/tools/Config.mk include $(TOPDIR)/arch/arm/src/armv7-m/Toolchain.defs LDSCRIPT = ld.script - ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT) -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION += -g -endif - -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 @@ -50,7 +39,3 @@ AFLAGS := $(CFLAGS) -D__ASSEMBLY__ NXFLATLDFLAGS1 = -r -d -warn-common NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-pcrel.ld -no-check-sections LDNXFLATFLAGS = -e main -s 2048 - -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - LDFLAGS += -g -endif diff --git a/boards/arm/stm32/fire-stm32v2/scripts/Make.defs b/boards/arm/stm32/fire-stm32v2/scripts/Make.defs index 1aa170a4d648f..27fe890064a61 100644 --- a/boards/arm/stm32/fire-stm32v2/scripts/Make.defs +++ b/boards/arm/stm32/fire-stm32v2/scripts/Make.defs @@ -32,16 +32,6 @@ endif ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT) -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new -fno-rtti ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 @@ -56,7 +46,3 @@ AFLAGS := $(CFLAGS) -D__ASSEMBLY__ NXFLATLDFLAGS1 = -r -d -warn-common NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-pcrel.ld -no-check-sections LDNXFLATFLAGS = -e main -s 2048 - -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - LDFLAGS += -g -endif diff --git a/boards/arm/stm32/hymini-stm32v/README.txt b/boards/arm/stm32/hymini-stm32v/README.txt index da16decad51fc..bc798d1e82973 100644 --- a/boards/arm/stm32/hymini-stm32v/README.txt +++ b/boards/arm/stm32/hymini-stm32v/README.txt @@ -482,7 +482,7 @@ Where is one of the following: more information. CONFIG_HOST_LINUX=y : Linux host - CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIL=y : GNU EABI toolchain for Linux + CONFIG_ARMV7M_TOOLCHAIN_GNU_EABI=y : GNU EABI toolchain for Linux USB debug output can be enabled as by changing the following settings in the configuration file: diff --git a/boards/arm/stm32/hymini-stm32v/scripts/Make.defs b/boards/arm/stm32/hymini-stm32v/scripts/Make.defs index dc6285e16f02c..621aae3bb09c8 100644 --- a/boards/arm/stm32/hymini-stm32v/scripts/Make.defs +++ b/boards/arm/stm32/hymini-stm32v/scripts/Make.defs @@ -30,16 +30,6 @@ endif ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT) -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 @@ -54,7 +44,3 @@ AFLAGS := $(CFLAGS) -D__ASSEMBLY__ NXFLATLDFLAGS1 = -r -d -warn-common NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-pcrel.ld -no-check-sections LDNXFLATFLAGS = -e main -s 2048 - -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - LDFLAGS += -g -endif diff --git a/boards/arm/stm32/maple/scripts/Make.defs b/boards/arm/stm32/maple/scripts/Make.defs index 092b39326c8bd..55c9cb11f40d6 100644 --- a/boards/arm/stm32/maple/scripts/Make.defs +++ b/boards/arm/stm32/maple/scripts/Make.defs @@ -30,16 +30,6 @@ endif ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT) -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION += -g -endif - -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 @@ -54,7 +44,3 @@ AFLAGS := $(CFLAGS) -D__ASSEMBLY__ NXFLATLDFLAGS1 = -r -d -warn-common NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-pcrel.ld -no-check-sections LDNXFLATFLAGS = -e main -s 2048 - -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - LDFLAGS += -g -endif diff --git a/boards/arm/stm32/mikroe-stm32f4/README.txt b/boards/arm/stm32/mikroe-stm32f4/README.txt index ec7985e0e9f69..be61fc414bdae 100644 --- a/boards/arm/stm32/mikroe-stm32f4/README.txt +++ b/boards/arm/stm32/mikroe-stm32f4/README.txt @@ -150,7 +150,6 @@ There are two version of the FPU support built into the STM32 port. file: CONFIG_ARCH_FPU=y - CONFIG_ARMV7M_LAZYFPU=y MIO283QT-2/MIO283QT-9A ====================== @@ -480,7 +479,7 @@ Where is one of the following: CONFIG_HOST_WINDOWS=y : Windows CONFIG_WINDOWS_CYGWIN=y : Cygwin environment on Windows - CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIW=y : GNU EABI toolchain for Windows + CONFIG_ARMV7M_TOOLCHAIN_GNU_EABI=y : GNU EABI toolchain for Windows This is easily changed by modifying the configuration. @@ -613,7 +612,7 @@ Where is one of the following: CONFIG_HOST_WINDOWS=y : Builds under Windows CONFIG_WINDOWS_CYGWIN=y : Using Cygwin - CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIW=y : GNU EABI toolchain for Windows + CONFIG_ARMV7M_TOOLCHAIN_GNU_EABI=y : GNU EABI toolchain for Windows 3. This configuration does have UART2 output enabled and set up as the system logging device: diff --git a/boards/arm/stm32/mikroe-stm32f4/scripts/Make.defs b/boards/arm/stm32/mikroe-stm32f4/scripts/Make.defs index eda89a2ddc3c9..c24431ef18526 100644 --- a/boards/arm/stm32/mikroe-stm32f4/scripts/Make.defs +++ b/boards/arm/stm32/mikroe-stm32f4/scripts/Make.defs @@ -23,19 +23,8 @@ include $(TOPDIR)/tools/Config.mk include $(TOPDIR)/arch/arm/src/armv7-m/Toolchain.defs LDSCRIPT = ld.script - ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT) -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new -fno-rtti ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 @@ -50,7 +39,3 @@ AFLAGS := $(CFLAGS) -D__ASSEMBLY__ NXFLATLDFLAGS1 = -r -d -warn-common NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-pcrel.ld -no-check-sections LDNXFLATFLAGS = -e main -s 2048 - -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - LDFLAGS += -g -endif diff --git a/boards/arm/stm32/mikroe-stm32f4/scripts/gnu-elf.ld b/boards/arm/stm32/mikroe-stm32f4/scripts/gnu-elf.ld deleted file mode 100644 index 41072ff720b76..0000000000000 --- a/boards/arm/stm32/mikroe-stm32f4/scripts/gnu-elf.ld +++ /dev/null @@ -1,116 +0,0 @@ -/**************************************************************************** - * boards/arm/stm32/mikroe-stm32f4/scripts/gnu-elf.ld - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. The - * ASF licenses this file to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance with the - * License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - ****************************************************************************/ - -SECTIONS -{ - .text 0x00000000 : - { - _stext = . ; - *(.text) - *(.text.*) - *(.gnu.warning) - *(.stub) - *(.glue_7) - *(.glue_7t) - *(.jcr) - - /* C++ support: The .init and .fini sections contain specific logic - * to manage static constructors and destructors. - */ - - *(.gnu.linkonce.t.*) - *(.init) /* Old ABI */ - *(.fini) /* Old ABI */ - _etext = . ; - } - - .rodata : - { - _srodata = . ; - *(.rodata) - *(.rodata1) - *(.rodata.*) - *(.gnu.linkonce.r*) - _erodata = . ; - } - - .data : - { - _sdata = . ; - *(.data) - *(.data1) - *(.data.*) - *(.gnu.linkonce.d*) - . = ALIGN(4); - _edata = . ; - } - - /* C++ support. For each global and static local C++ object, - * GCC creates a small subroutine to construct the object. Pointers - * to these routines (not the routines themselves) are stored as - * simple, linear arrays in the .ctors section of the object file. - * Similarly, pointers to global/static destructor routines are - * stored in .dtors. - */ - - .ctors : - { - _sctors = . ; - *(.ctors) /* Old ABI: Unallocated */ - *(.init_array) /* New ABI: Allocated */ - _edtors = . ; - } - - .dtors : - { - _sdtors = . ; - *(.dtors) /* Old ABI: Unallocated */ - *(.fini_array) /* New ABI: Allocated */ - _edtors = . ; - } - - .bss : - { - _sbss = . ; - *(.bss) - *(.bss.*) - *(.sbss) - *(.sbss.*) - *(.gnu.linkonce.b*) - *(COMMON) - . = ALIGN(4); - _ebss = . ; - } - - /* Stabs debugging sections. */ - - .stab 0 : { *(.stab) } - .stabstr 0 : { *(.stabstr) } - .stab.excl 0 : { *(.stab.excl) } - .stab.exclstr 0 : { *(.stab.exclstr) } - .stab.index 0 : { *(.stab.index) } - .stab.indexstr 0 : { *(.stab.indexstr) } - .comment 0 : { *(.comment) } - .debug_abbrev 0 : { *(.debug_abbrev) } - .debug_info 0 : { *(.debug_info) } - .debug_line 0 : { *(.debug_line) } - .debug_pubnames 0 : { *(.debug_pubnames) } - .debug_aranges 0 : { *(.debug_aranges) } -} diff --git a/boards/arm/stm32/mikroe-stm32f4/src/stm32_pm.c b/boards/arm/stm32/mikroe-stm32f4/src/stm32_pm.c index 3606f2b5d2d99..d242f5e858135 100644 --- a/boards/arm/stm32/mikroe-stm32f4/src/stm32_pm.c +++ b/boards/arm/stm32/mikroe-stm32f4/src/stm32_pm.c @@ -23,6 +23,7 @@ ****************************************************************************/ #include +#include #include "arm_internal.h" #include "stm32_pm.h" @@ -54,6 +55,10 @@ void arm_pminitialize(void) { + /* Initialize the NuttX power management subsystem proper */ + + pm_initialize(); + #if defined(CONFIG_ARCH_IDLE_CUSTOM) && defined(CONFIG_PM_BUTTONS) /* Initialize the buttons to wake up the system from low power modes */ diff --git a/boards/arm/stm32/mikroe-stm32f4/src/stm32_touchscreen.c b/boards/arm/stm32/mikroe-stm32f4/src/stm32_touchscreen.c index 1969cf7c12e8d..04fcce067cd21 100644 --- a/boards/arm/stm32/mikroe-stm32f4/src/stm32_touchscreen.c +++ b/boards/arm/stm32/mikroe-stm32f4/src/stm32_touchscreen.c @@ -601,7 +601,7 @@ static void tc_notify(FAR struct tc_dev_s *priv) if (fds) { fds->revents |= POLLIN; - iinfo("Report events: %02x\n", fds->revents); + iinfo("Report events: %08" PRIx32 "\n", fds->revents); nxsem_post(fds->sem); } } @@ -1385,7 +1385,8 @@ static int tc_poll(FAR struct file *filep, FAR struct pollfd *fds, if ((fds->events & POLLIN) == 0) { - ierr("ERROR: Missing POLLIN: revents: %08x\n", fds->revents); + ierr("ERROR: Missing POLLIN: revents: %08" PRIx32 "\n", + fds->revents); ret = -EDEADLK; goto errout; } @@ -1516,7 +1517,7 @@ int stm32_tsc_setup(int minor) /* Register the device as an input device */ - snprintf(devname, DEV_NAMELEN, DEV_FORMAT, minor); + snprintf(devname, sizeof(devname), DEV_FORMAT, minor); iinfo("Registering %s\n", devname); ret = register_driver(devname, &tc_fops, 0666, priv); diff --git a/boards/arm/stm32/mikroe-stm32f4/src/stm32_vs1053.c b/boards/arm/stm32/mikroe-stm32f4/src/stm32_vs1053.c index d20d5f3bed279..e1fd639400d3f 100644 --- a/boards/arm/stm32/mikroe-stm32f4/src/stm32_vs1053.c +++ b/boards/arm/stm32/mikroe-stm32f4/src/stm32_vs1053.c @@ -170,7 +170,7 @@ void up_vs1053initialize(FAR struct spi_dev_s * spi) * until the RST line is asserted. */ - /* (void)stm32_configgpio(GPIO_VS1053_RST); */ + /* stm32_configgpio(GPIO_VS1053_RST); */ /* Initialize the VS1053 DREQ GPIO line */ diff --git a/boards/arm/stm32/nucleo-f103rb/scripts/Make.defs b/boards/arm/stm32/nucleo-f103rb/scripts/Make.defs index 0fbb668cee496..066f670a5dd81 100644 --- a/boards/arm/stm32/nucleo-f103rb/scripts/Make.defs +++ b/boards/arm/stm32/nucleo-f103rb/scripts/Make.defs @@ -23,19 +23,8 @@ include $(TOPDIR)/tools/Config.mk include $(TOPDIR)/arch/arm/src/armv7-m/Toolchain.defs LDSCRIPT = ld.script - ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT) -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new -fno-rtti ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 @@ -50,7 +39,3 @@ AFLAGS := $(CFLAGS) -D__ASSEMBLY__ NXFLATLDFLAGS1 = -r -d -warn-common NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-pcrel.ld -no-check-sections LDNXFLATFLAGS = -e main -s 2048 - -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - LDFLAGS += -g -endif diff --git a/boards/arm/stm32/nucleo-f207zg/scripts/Make.defs b/boards/arm/stm32/nucleo-f207zg/scripts/Make.defs index 28279b3911ede..d0c734ee56d1f 100644 --- a/boards/arm/stm32/nucleo-f207zg/scripts/Make.defs +++ b/boards/arm/stm32/nucleo-f207zg/scripts/Make.defs @@ -23,19 +23,8 @@ include $(TOPDIR)/tools/Config.mk include $(TOPDIR)/arch/arm/src/armv7-m/Toolchain.defs LDSCRIPT = ld.script - ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT) -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new -fno-rtti ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 @@ -50,7 +39,3 @@ AFLAGS := $(CFLAGS) -D__ASSEMBLY__ NXFLATLDFLAGS1 = -r -d -warn-common NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-pcrel.ld -no-check-sections LDNXFLATFLAGS = -e main -s 2048 - -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - LDFLAGS += -g -endif diff --git a/boards/arm/stm32/nucleo-f302r8/scripts/Make.defs b/boards/arm/stm32/nucleo-f302r8/scripts/Make.defs index 16b867358d49b..b075cd7a8bdaa 100644 --- a/boards/arm/stm32/nucleo-f302r8/scripts/Make.defs +++ b/boards/arm/stm32/nucleo-f302r8/scripts/Make.defs @@ -23,19 +23,8 @@ include $(TOPDIR)/tools/Config.mk include $(TOPDIR)/arch/arm/src/armv7-m/Toolchain.defs LDSCRIPT = ld.script - ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT) -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new -fno-rtti ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 @@ -50,7 +39,3 @@ AFLAGS := $(CFLAGS) -D__ASSEMBLY__ NXFLATLDFLAGS1 = -r -d -warn-common NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-pcrel.ld -no-check-sections LDNXFLATFLAGS = -e main -s 2048 - -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - LDFLAGS += -g -endif diff --git a/boards/arm/stm32/nucleo-f303re/scripts/Make.defs b/boards/arm/stm32/nucleo-f303re/scripts/Make.defs index eda7a7cd357c0..8762395c869ca 100644 --- a/boards/arm/stm32/nucleo-f303re/scripts/Make.defs +++ b/boards/arm/stm32/nucleo-f303re/scripts/Make.defs @@ -23,19 +23,8 @@ include $(TOPDIR)/tools/Config.mk include $(TOPDIR)/arch/arm/src/armv7-m/Toolchain.defs LDSCRIPT = ld.script - ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT) -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new -fno-rtti ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 @@ -50,7 +39,3 @@ AFLAGS := $(CFLAGS) -D__ASSEMBLY__ NXFLATLDFLAGS1 = -r -d -warn-common NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-pcrel.ld -no-check-sections LDNXFLATFLAGS = -e main -s 2048 - -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - LDFLAGS += -g -endif diff --git a/boards/arm/stm32/nucleo-f303ze/scripts/Make.defs b/boards/arm/stm32/nucleo-f303ze/scripts/Make.defs index f4b1ae4b567ce..0abb6a17c2d48 100644 --- a/boards/arm/stm32/nucleo-f303ze/scripts/Make.defs +++ b/boards/arm/stm32/nucleo-f303ze/scripts/Make.defs @@ -23,19 +23,8 @@ include $(TOPDIR)/tools/Config.mk include $(TOPDIR)/arch/arm/src/armv7-m/Toolchain.defs LDSCRIPT = ld.script - ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT) -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new -fno-rtti ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 @@ -50,7 +39,3 @@ AFLAGS := $(CFLAGS) -D__ASSEMBLY__ NXFLATLDFLAGS1 = -r -d -warn-common NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-pcrel.ld -no-check-sections LDNXFLATFLAGS = -e main -s 2048 - -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - LDFLAGS += -g -endif diff --git a/boards/arm/stm32/nucleo-f334r8/scripts/Make.defs b/boards/arm/stm32/nucleo-f334r8/scripts/Make.defs index b841316cc43f7..d030d3adac474 100644 --- a/boards/arm/stm32/nucleo-f334r8/scripts/Make.defs +++ b/boards/arm/stm32/nucleo-f334r8/scripts/Make.defs @@ -23,19 +23,8 @@ include $(TOPDIR)/tools/Config.mk include $(TOPDIR)/arch/arm/src/armv7-m/Toolchain.defs LDSCRIPT = ld.script - ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT) -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new -fno-rtti ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 @@ -50,7 +39,3 @@ AFLAGS := $(CFLAGS) -D__ASSEMBLY__ NXFLATLDFLAGS1 = -r -d -warn-common NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-pcrel.ld -no-check-sections LDNXFLATFLAGS = -e main -s 2048 - -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - LDFLAGS += -g -endif diff --git a/boards/arm/stm32/nucleo-f410rb/scripts/Make.defs b/boards/arm/stm32/nucleo-f410rb/scripts/Make.defs index f482db48f5439..02bb80ba0aa7d 100644 --- a/boards/arm/stm32/nucleo-f410rb/scripts/Make.defs +++ b/boards/arm/stm32/nucleo-f410rb/scripts/Make.defs @@ -23,19 +23,8 @@ include $(TOPDIR)/tools/Config.mk include $(TOPDIR)/arch/arm/src/armv7-m/Toolchain.defs LDSCRIPT = f410rb.ld - ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT) -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new -fno-rtti ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 @@ -50,7 +39,3 @@ AFLAGS := $(CFLAGS) -D__ASSEMBLY__ NXFLATLDFLAGS1 = -r -d -warn-common NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-pcrel.ld -no-check-sections LDNXFLATFLAGS = -e main -s 2048 - -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - LDFLAGS += -g -endif diff --git a/boards/arm/stm32/nucleo-f412zg/scripts/Make.defs b/boards/arm/stm32/nucleo-f412zg/scripts/Make.defs index d7f38fcbaeab6..823ae146ba5a5 100644 --- a/boards/arm/stm32/nucleo-f412zg/scripts/Make.defs +++ b/boards/arm/stm32/nucleo-f412zg/scripts/Make.defs @@ -23,19 +23,8 @@ include ${TOPDIR}/tools/Config.mk include ${TOPDIR}/arch/arm/src/armv7-m/Toolchain.defs LDSCRIPT = f412zg.ld - ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT) -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new -fno-rtti ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHDEFINES = @@ -51,7 +40,3 @@ AFLAGS := $(CFLAGS) -D__ASSEMBLY__ NXFLATLDFLAGS1 = -r -d -warn-common NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-pcrel.ld -no-check-sections LDNXFLATFLAGS = -e main -s 2048 - -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - LDFLAGS += -g -endif diff --git a/boards/arm/stm32/nucleo-f429zi/scripts/Make.defs b/boards/arm/stm32/nucleo-f429zi/scripts/Make.defs index 3495eef6462b9..bd9157fc8819d 100644 --- a/boards/arm/stm32/nucleo-f429zi/scripts/Make.defs +++ b/boards/arm/stm32/nucleo-f429zi/scripts/Make.defs @@ -23,19 +23,8 @@ include $(TOPDIR)/tools/Config.mk include $(TOPDIR)/arch/arm/src/armv7-m/Toolchain.defs LDSCRIPT = ld.script - ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT) -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new -fno-rtti ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 @@ -50,7 +39,3 @@ AFLAGS := $(CFLAGS) -D__ASSEMBLY__ NXFLATLDFLAGS1 = -r -d -warn-common NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-pcrel.ld -no-check-sections LDNXFLATFLAGS = -e main -s 2048 - -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - LDFLAGS += -g -endif diff --git a/boards/arm/stm32/nucleo-f429zi/scripts/gnu-elf.ld b/boards/arm/stm32/nucleo-f429zi/scripts/gnu-elf.ld deleted file mode 100644 index f1bd4bfdeae16..0000000000000 --- a/boards/arm/stm32/nucleo-f429zi/scripts/gnu-elf.ld +++ /dev/null @@ -1,116 +0,0 @@ -/**************************************************************************** - * boards/arm/stm32/nucleo-f429zi/scripts/gnu-elf.ld - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. The - * ASF licenses this file to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance with the - * License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - ****************************************************************************/ - -SECTIONS -{ - .text 0x00000000 : - { - _stext = . ; - *(.text) - *(.text.*) - *(.gnu.warning) - *(.stub) - *(.glue_7) - *(.glue_7t) - *(.jcr) - - /* C++ support: The .init and .fini sections contain specific logic - * to manage static constructors and destructors. - */ - - *(.gnu.linkonce.t.*) - *(.init) /* Old ABI */ - *(.fini) /* Old ABI */ - _etext = . ; - } - - .rodata : - { - _srodata = . ; - *(.rodata) - *(.rodata1) - *(.rodata.*) - *(.gnu.linkonce.r*) - _erodata = . ; - } - - .data : - { - _sdata = . ; - *(.data) - *(.data1) - *(.data.*) - *(.gnu.linkonce.d*) - . = ALIGN(4); - _edata = . ; - } - - /* C++ support. For each global and static local C++ object, - * GCC creates a small subroutine to construct the object. Pointers - * to these routines (not the routines themselves) are stored as - * simple, linear arrays in the .ctors section of the object file. - * Similarly, pointers to global/static destructor routines are - * stored in .dtors. - */ - - .ctors : - { - _sctors = . ; - *(.ctors) /* Old ABI: Unallocated */ - *(.init_array) /* New ABI: Allocated */ - _edtors = . ; - } - - .dtors : - { - _sdtors = . ; - *(.dtors) /* Old ABI: Unallocated */ - *(.fini_array) /* New ABI: Allocated */ - _edtors = . ; - } - - .bss : - { - _sbss = . ; - *(.bss) - *(.bss.*) - *(.sbss) - *(.sbss.*) - *(.gnu.linkonce.b*) - *(COMMON) - . = ALIGN(4); - _ebss = . ; - } - - /* Stabs debugging sections. */ - - .stab 0 : { *(.stab) } - .stabstr 0 : { *(.stabstr) } - .stab.excl 0 : { *(.stab.excl) } - .stab.exclstr 0 : { *(.stab.exclstr) } - .stab.index 0 : { *(.stab.index) } - .stab.indexstr 0 : { *(.stab.indexstr) } - .comment 0 : { *(.comment) } - .debug_abbrev 0 : { *(.debug_abbrev) } - .debug_info 0 : { *(.debug_info) } - .debug_line 0 : { *(.debug_line) } - .debug_pubnames 0 : { *(.debug_pubnames) } - .debug_aranges 0 : { *(.debug_aranges) } -} diff --git a/boards/arm/stm32/nucleo-f446re/README.txt b/boards/arm/stm32/nucleo-f446re/README.txt index e4fe895dd7382..8ec543e4ae4f3 100644 --- a/boards/arm/stm32/nucleo-f446re/README.txt +++ b/boards/arm/stm32/nucleo-f446re/README.txt @@ -106,7 +106,7 @@ GNU Toolchain Options a different toolchain, you simply need to modify the configuration. As an example: - CONFIG_ARM_TOOLCHAIN_GNU_EABIL : Generic arm-none-eabi toolchain + CONFIG_ARM_TOOLCHAIN_GNU_EABI : Generic arm-none-eabi toolchain IDEs ==== @@ -535,7 +535,7 @@ Configurations for Linux. That can easily be reconfigured, of course. CONFIG_HOST_LINUX=y : Builds under Linux - CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIL=y : GNU EABI toolchain for Linux + CONFIG_ARMV7M_TOOLCHAIN_GNU_EABI=y : GNU EABI toolchain for Linux 3. Although the default console is USART2 (which would correspond to the Virtual COM port) I have done all testing with the console diff --git a/boards/arm/stm32/nucleo-f446re/scripts/Make.defs b/boards/arm/stm32/nucleo-f446re/scripts/Make.defs index c7eac4f8f4406..1b3a041ff47c3 100644 --- a/boards/arm/stm32/nucleo-f446re/scripts/Make.defs +++ b/boards/arm/stm32/nucleo-f446re/scripts/Make.defs @@ -23,26 +23,12 @@ include $(TOPDIR)/tools/Config.mk include $(TOPDIR)/arch/arm/src/armv7-m/Toolchain.defs LDSCRIPT = f446re.ld - ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT) -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g - LDFLAGS += -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new -ifeq ($(CONFIG_ARMV7M_TOOLCHAIN_CLANGL),y) +ifeq ($(CONFIG_ARMV7M_TOOLCHAIN_CLANG),y) ARCHCFLAGS += -nostdlib -ffreestanding ARCHCXXFLAGS += -nostdlib -ffreestanding -else - ARCHCXXFLAGS += -fno-rtti endif ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef diff --git a/boards/arm/stm32/nucleo-f446re/src/stm32_boot.c b/boards/arm/stm32/nucleo-f446re/src/stm32_boot.c index 456de69d990ae..67c07f8d88d44 100644 --- a/boards/arm/stm32/nucleo-f446re/src/stm32_boot.c +++ b/boards/arm/stm32/nucleo-f446re/src/stm32_boot.c @@ -52,6 +52,10 @@ void stm32_boardinitialize(void) { +#ifdef CONFIG_SEGGER_SYSVIEW + up_perf_init((FAR void *)STM32_SYSCLK_FREQUENCY); +#endif + #ifdef CONFIG_ARCH_LEDS /* Configure on-board LEDs if LED support has been selected. */ diff --git a/boards/arm/stm32/nucleo-f4x1re/README.txt b/boards/arm/stm32/nucleo-f4x1re/README.txt index e6082f050a10b..1b65abb162750 100644 --- a/boards/arm/stm32/nucleo-f4x1re/README.txt +++ b/boards/arm/stm32/nucleo-f4x1re/README.txt @@ -129,7 +129,7 @@ GNU Toolchain Options a different toolchain, you simply need to modify the configuration. As an example: - CONFIG_ARM_TOOLCHAIN_GNU_EABIL : Generic arm-none-eabi toolchain + CONFIG_ARM_TOOLCHAIN_GNU_EABI : Generic arm-none-eabi toolchain IDEs ==== @@ -560,7 +560,7 @@ Configurations for Linux. That can easily be reconfigured, of course. CONFIG_HOST_LINUX=y : Builds under Linux - CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIL=y : GNU EABI toolchain for Linux + CONFIG_ARMV7M_TOOLCHAIN_GNU_EABI=y : GNU EABI toolchain for Linux 3. Although the default console is USART2 (which would correspond to the Virtual COM port) I have done all testing with the console diff --git a/boards/arm/stm32/nucleo-f4x1re/scripts/Make.defs b/boards/arm/stm32/nucleo-f4x1re/scripts/Make.defs index 733b70eedd8d4..9813125a6de4b 100644 --- a/boards/arm/stm32/nucleo-f4x1re/scripts/Make.defs +++ b/boards/arm/stm32/nucleo-f4x1re/scripts/Make.defs @@ -24,31 +24,16 @@ include $(TOPDIR)/arch/arm/src/armv7-m/Toolchain.defs ifeq ($(CONFIG_ARCH_CHIP_STM32F401RE),y) LDSCRIPT = f401re.ld -else -ifeq ($(CONFIG_ARCH_CHIP_STM32F411RE),y) +else ifeq ($(CONFIG_ARCH_CHIP_STM32F411RE),y) LDSCRIPT = f411re.ld endif -endif ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT) -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g - LDFLAGS += -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new -ifeq ($(CONFIG_ARMV7M_TOOLCHAIN_CLANGL),y) +ifeq ($(CONFIG_ARMV7M_TOOLCHAIN_CLANG),y) ARCHCFLAGS += -nostdlib -ffreestanding ARCHCXXFLAGS += -nostdlib -ffreestanding -else - ARCHCXXFLAGS += -fno-rtti endif ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef diff --git a/boards/arm/stm32/nucleo-g431kb/scripts/Make.defs b/boards/arm/stm32/nucleo-g431kb/scripts/Make.defs index 5d62f5367a192..2160c4d3e9ff4 100755 --- a/boards/arm/stm32/nucleo-g431kb/scripts/Make.defs +++ b/boards/arm/stm32/nucleo-g431kb/scripts/Make.defs @@ -30,23 +30,15 @@ endif ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT) -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - -ARCHCFLAGS = -fno-common -funwind-tables -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new -funwind-tables +ARCHCFLAGS += -funwind-tables +ARCHCXXFLAGS += -funwind-tables ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 -CFLAGS := $(ARCHCFLAGS) $(ARCHWARNINGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) -ffunction-sections -fdata-sections -pipe +CFLAGS := $(ARCHCFLAGS) $(ARCHWARNINGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) -pipe CPICFLAGS = $(ARCHPICFLAGS) $(CFLAGS) -CXXFLAGS := $(ARCHCXXFLAGS) $(ARCHWARNINGSXX) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHXXINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) -ffunction-sections -fdata-sections -pipe +CXXFLAGS := $(ARCHCXXFLAGS) $(ARCHWARNINGSXX) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHXXINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) -pipe CXXPICFLAGS = $(ARCHPICFLAGS) $(CXXFLAGS) CPPFLAGS := $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) AFLAGS := $(CFLAGS) -D__ASSEMBLY__ @@ -55,13 +47,6 @@ NXFLATLDFLAGS1 = -r -d -warn-common NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-pcrel.ld -no-check-sections LDNXFLATFLAGS = -e main -s 2048 -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - LDFLAGS += -g -endif - -# Provide map file needed by the "Memory Allocation" view in Eclipse: -LDFLAGS += -Map=$(TOPDIR)/NuttX.map --gc-sections - # Embed absolute path to source file in debug information so that Eclipse # source level debugging won't get confused. See: # https://stackoverflow.com/questions/1275476/gcc-gdb-how-to-embed-absolute-path-to-source-file-in-debug-information diff --git a/boards/arm/stm32/nucleo-g431rb/scripts/Make.defs b/boards/arm/stm32/nucleo-g431rb/scripts/Make.defs index 82ca2d4d6828e..49af1ff7726f6 100644 --- a/boards/arm/stm32/nucleo-g431rb/scripts/Make.defs +++ b/boards/arm/stm32/nucleo-g431rb/scripts/Make.defs @@ -30,23 +30,15 @@ endif ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT) -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - -ARCHCFLAGS = -fno-common -funwind-tables -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new -funwind-tables +ARCHCFLAGS += -funwind-tables +ARCHCXXFLAGS += -funwind-tables ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 -CFLAGS := $(ARCHCFLAGS) $(ARCHWARNINGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) -ffunction-sections -fdata-sections -pipe +CFLAGS := $(ARCHCFLAGS) $(ARCHWARNINGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) -pipe CPICFLAGS = $(ARCHPICFLAGS) $(CFLAGS) -CXXFLAGS := $(ARCHCXXFLAGS) $(ARCHWARNINGSXX) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHXXINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) -ffunction-sections -fdata-sections -pipe +CXXFLAGS := $(ARCHCXXFLAGS) $(ARCHWARNINGSXX) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHXXINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) -pipe CXXPICFLAGS = $(ARCHPICFLAGS) $(CXXFLAGS) CPPFLAGS := $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) AFLAGS := $(CFLAGS) -D__ASSEMBLY__ @@ -55,13 +47,6 @@ NXFLATLDFLAGS1 = -r -d -warn-common NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-pcrel.ld -no-check-sections LDNXFLATFLAGS = -e main -s 2048 -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - LDFLAGS += -g -endif - -# Provide map file needed by the "Memory Allocation" view in Eclipse: -LDFLAGS += -Map=$(TOPDIR)/NuttX.map --gc-sections - # Embed absolute path to source file in debug information so that Eclipse # source level debugging won't get confused. See: # https://stackoverflow.com/questions/1275476/gcc-gdb-how-to-embed-absolute-path-to-source-file-in-debug-information diff --git a/boards/arm/stm32/nucleo-l152re/scripts/Make.defs b/boards/arm/stm32/nucleo-l152re/scripts/Make.defs index 41824294eb5a9..55c24e00e4821 100644 --- a/boards/arm/stm32/nucleo-l152re/scripts/Make.defs +++ b/boards/arm/stm32/nucleo-l152re/scripts/Make.defs @@ -23,19 +23,8 @@ include $(TOPDIR)/tools/Config.mk include $(TOPDIR)/arch/arm/src/armv7-m/Toolchain.defs LDSCRIPT = ld.script - ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT) -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new -fno-rtti ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 @@ -50,7 +39,3 @@ AFLAGS := $(CFLAGS) -D__ASSEMBLY__ NXFLATLDFLAGS1 = -r -d -warn-common NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-pcrel.ld -no-check-sections LDNXFLATFLAGS = -e main -s 2048 - -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - LDFLAGS += -g -endif diff --git a/boards/arm/stm32/olimex-stm32-e407/scripts/Make.defs b/boards/arm/stm32/olimex-stm32-e407/scripts/Make.defs index ed7d2f995078e..a0552afdf1280 100644 --- a/boards/arm/stm32/olimex-stm32-e407/scripts/Make.defs +++ b/boards/arm/stm32/olimex-stm32-e407/scripts/Make.defs @@ -24,24 +24,12 @@ include $(TOPDIR)/arch/arm/src/armv7-m/Toolchain.defs ifeq ($(CONFIG_ARCH_CHIP_STM32F407ZE),y) LDSCRIPT = f407ze.ld -else -ifeq ($(CONFIG_ARCH_CHIP_STM32F407ZG),y) +else ifeq ($(CONFIG_ARCH_CHIP_STM32F407ZG),y) LDSCRIPT = f407zg.ld endif -endif ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT) -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new -fno-rtti ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 @@ -56,7 +44,3 @@ AFLAGS := $(CFLAGS) -D__ASSEMBLY__ NXFLATLDFLAGS1 = -r -d -warn-common NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-pcrel.ld -no-check-sections LDNXFLATFLAGS = -e main -s 2048 - -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - LDFLAGS += -g -endif diff --git a/boards/arm/stm32/olimex-stm32-e407/src/Make.defs b/boards/arm/stm32/olimex-stm32-e407/src/Make.defs index a7bb9d375bb16..69f09fd6df5a0 100644 --- a/boards/arm/stm32/olimex-stm32-e407/src/Make.defs +++ b/boards/arm/stm32/olimex-stm32-e407/src/Make.defs @@ -60,10 +60,6 @@ ifeq ($(CONFIG_CAN),y) CSRCS += stm32_can.c endif -ifeq ($(CONFIG_ARCH_FPU),y) -CSRCS += stm32_ostest.c -endif - ifeq ($(CONFIG_DAC),y) CSRCS += stm32_dac.c endif diff --git a/boards/arm/stm32/olimex-stm32-h405/scripts/Make.defs b/boards/arm/stm32/olimex-stm32-h405/scripts/Make.defs index 1861e84e6cf20..f8492ae33574e 100644 --- a/boards/arm/stm32/olimex-stm32-h405/scripts/Make.defs +++ b/boards/arm/stm32/olimex-stm32-h405/scripts/Make.defs @@ -23,19 +23,8 @@ include $(TOPDIR)/tools/Config.mk include $(TOPDIR)/arch/arm/src/armv7-m/Toolchain.defs LDSCRIPT = ld.script - ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT) -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -gdwarf-2 -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new -fno-rtti ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 @@ -50,7 +39,3 @@ AFLAGS := $(CFLAGS) -D__ASSEMBLY__ NXFLATLDFLAGS1 = -r -d -warn-common NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-gotoff.ld -no-check-sections LDNXFLATFLAGS = -e main -s 2048 - -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - LDFLAGS += -g -endif diff --git a/boards/arm/stm32/olimex-stm32-h407/scripts/Make.defs b/boards/arm/stm32/olimex-stm32-h407/scripts/Make.defs index 3073daf890916..3df01f9a8e09a 100644 --- a/boards/arm/stm32/olimex-stm32-h407/scripts/Make.defs +++ b/boards/arm/stm32/olimex-stm32-h407/scripts/Make.defs @@ -23,19 +23,8 @@ include $(TOPDIR)/tools/Config.mk include $(TOPDIR)/arch/arm/src/armv7-m/Toolchain.defs LDSCRIPT = ld.script - ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT) -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new -fno-rtti ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 @@ -50,7 +39,3 @@ AFLAGS := $(CFLAGS) -D__ASSEMBLY__ NXFLATLDFLAGS1 = -r -d -warn-common NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-pcrel.ld -no-check-sections LDNXFLATFLAGS = -e main -s 2048 - -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - LDFLAGS += -g -endif diff --git a/boards/arm/stm32/olimex-stm32-h407/src/Make.defs b/boards/arm/stm32/olimex-stm32-h407/src/Make.defs index 941b2adcfd630..1d83f6ebe90eb 100644 --- a/boards/arm/stm32/olimex-stm32-h407/src/Make.defs +++ b/boards/arm/stm32/olimex-stm32-h407/src/Make.defs @@ -64,10 +64,6 @@ ifeq ($(CONFIG_STM32_SDIO),y) CSRCS += stm32_sdio.c endif -ifeq ($(CONFIG_ARCH_FPU),y) -CSRCS += stm32_ostest.c -endif - DEPPATH += --dep-path board VPATH += :board CFLAGS += $(shell $(INCDIR) "$(CC)" $(TOPDIR)$(DELIM)arch$(DELIM)$(CONFIG_ARCH)$(DELIM)src$(DELIM)board$(DELIM)board) diff --git a/boards/arm/stm32/olimex-stm32-p107/scripts/Make.defs b/boards/arm/stm32/olimex-stm32-p107/scripts/Make.defs index b9785c96a66e7..4fae12bfa7199 100644 --- a/boards/arm/stm32/olimex-stm32-p107/scripts/Make.defs +++ b/boards/arm/stm32/olimex-stm32-p107/scripts/Make.defs @@ -30,16 +30,6 @@ endif ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT) -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new -fno-rtti ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 @@ -54,7 +44,3 @@ AFLAGS := $(CFLAGS) -D__ASSEMBLY__ NXFLATLDFLAGS1 = -r -d -warn-common NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-gotoff.ld -no-check-sections LDNXFLATFLAGS = -e main -s 2048 - -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - LDFLAGS += -g -endif diff --git a/boards/arm/stm32/olimex-stm32-p207/scripts/Make.defs b/boards/arm/stm32/olimex-stm32-p207/scripts/Make.defs index 0fa694210ef4f..53191292c0aac 100644 --- a/boards/arm/stm32/olimex-stm32-p207/scripts/Make.defs +++ b/boards/arm/stm32/olimex-stm32-p207/scripts/Make.defs @@ -23,19 +23,8 @@ include $(TOPDIR)/tools/Config.mk include $(TOPDIR)/arch/arm/src/armv7-m/Toolchain.defs LDSCRIPT = ld.script - ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT) -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new -fno-rtti ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 @@ -50,7 +39,3 @@ AFLAGS := $(CFLAGS) -D__ASSEMBLY__ NXFLATLDFLAGS1 = -r -d -warn-common NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-gotoff.ld -no-check-sections LDNXFLATFLAGS = -e main -s 2048 - -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - LDFLAGS += -g -endif diff --git a/boards/arm/stm32/olimex-stm32-p407/configs/kelf/Make.defs b/boards/arm/stm32/olimex-stm32-p407/configs/kelf/Make.defs index 18a097722c7ac..8fe44bdb7b8f9 100644 --- a/boards/arm/stm32/olimex-stm32-p407/configs/kelf/Make.defs +++ b/boards/arm/stm32/olimex-stm32-p407/configs/kelf/Make.defs @@ -25,16 +25,6 @@ include $(TOPDIR)/arch/arm/src/armv7-m/Toolchain.defs ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)memory.ld ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)kernel-space.ld -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new -fno-rtti ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 @@ -70,7 +60,3 @@ LDELFFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)$(DELIM)libs$(DELIM)libc$(DELIM)mo # File extensions # Linker flags - -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - LDFLAGS += -g -endif diff --git a/boards/arm/stm32/olimex-stm32-p407/configs/kmodule/Make.defs b/boards/arm/stm32/olimex-stm32-p407/configs/kmodule/Make.defs index 69eea2cec3593..6b6b532f507b5 100644 --- a/boards/arm/stm32/olimex-stm32-p407/configs/kmodule/Make.defs +++ b/boards/arm/stm32/olimex-stm32-p407/configs/kmodule/Make.defs @@ -25,16 +25,6 @@ include $(TOPDIR)/arch/arm/src/armv7-m/Toolchain.defs ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)memory.ld ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)kernel-space.ld -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new -fno-rtti ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 @@ -70,7 +60,3 @@ LDELFFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)$(DELIM)libs$(DELIM)libc$(DELIM)mo # File extensions # Linker flags - -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - LDFLAGS += -g -endif diff --git a/boards/arm/stm32/olimex-stm32-p407/configs/knsh/Make.defs b/boards/arm/stm32/olimex-stm32-p407/configs/knsh/Make.defs index 461f3a9db2c95..1ce30bfab677b 100644 --- a/boards/arm/stm32/olimex-stm32-p407/configs/knsh/Make.defs +++ b/boards/arm/stm32/olimex-stm32-p407/configs/knsh/Make.defs @@ -28,16 +28,6 @@ LDSCRIPT2 = kernel-space.ld ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT1) ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT2) -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new -fno-rtti ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 @@ -59,7 +49,3 @@ CMODULEFLAGS = $(CFLAGS) -mlong-calls # --target1-abs LDMODULEFLAGS = -r -e module_initialize LDMODULEFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)/libs/libc/modlib/gnu-elf.ld) - -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - LDFLAGS += -g -endif diff --git a/boards/arm/stm32/olimex-stm32-p407/scripts/Make.defs b/boards/arm/stm32/olimex-stm32-p407/scripts/Make.defs index a3416a0dd30fa..c40662c4f687e 100644 --- a/boards/arm/stm32/olimex-stm32-p407/scripts/Make.defs +++ b/boards/arm/stm32/olimex-stm32-p407/scripts/Make.defs @@ -23,19 +23,8 @@ include $(TOPDIR)/tools/Config.mk include $(TOPDIR)/arch/arm/src/armv7-m/Toolchain.defs LDSCRIPT = flash.ld - ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT) -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new -fno-rtti ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 @@ -57,7 +46,3 @@ CMODULEFLAGS = $(CFLAGS) -mlong-calls # --target1-abs LDMODULEFLAGS = -r -e module_initialize LDMODULEFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)/libs/libc/modlib/gnu-elf.ld) - -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - LDFLAGS += -g -endif diff --git a/boards/arm/stm32/olimexino-stm32/scripts/Make.defs b/boards/arm/stm32/olimexino-stm32/scripts/Make.defs index 872295e2a2c61..e1d7c13b04076 100644 --- a/boards/arm/stm32/olimexino-stm32/scripts/Make.defs +++ b/boards/arm/stm32/olimexino-stm32/scripts/Make.defs @@ -30,16 +30,6 @@ endif ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT) -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new -fno-rtti ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 @@ -54,7 +44,3 @@ AFLAGS := $(CFLAGS) -D__ASSEMBLY__ NXFLATLDFLAGS1 = -r -d -warn-common NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-gotoff.ld -no-check-sections LDNXFLATFLAGS = -e main -s 2048 - -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - LDFLAGS += -g -endif diff --git a/boards/arm/stm32/omnibusf4/configs/nsh/defconfig b/boards/arm/stm32/omnibusf4/configs/nsh/defconfig index 481b710b82dc8..aaf47bfcd5559 100644 --- a/boards/arm/stm32/omnibusf4/configs/nsh/defconfig +++ b/boards/arm/stm32/omnibusf4/configs/nsh/defconfig @@ -19,7 +19,6 @@ CONFIG_ARCH_CHIP="stm32" CONFIG_ARCH_CHIP_STM32=y CONFIG_ARCH_CHIP_STM32F405RG=y CONFIG_ARCH_STACKDUMP=y -CONFIG_ARMV7M_LAZYFPU=y CONFIG_BOARDCTL_IOCTL=y CONFIG_BOARDCTL_RESET=y CONFIG_BOARDCTL_USBDEVCTRL=y diff --git a/boards/arm/stm32/omnibusf4/scripts/Make.defs b/boards/arm/stm32/omnibusf4/scripts/Make.defs index 5abd58399c28a..261b7c7726a02 100644 --- a/boards/arm/stm32/omnibusf4/scripts/Make.defs +++ b/boards/arm/stm32/omnibusf4/scripts/Make.defs @@ -23,19 +23,8 @@ include $(TOPDIR)/tools/Config.mk include $(TOPDIR)/arch/arm/src/armv7-m/Toolchain.defs LDSCRIPT = ld.script - ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT) -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new -fno-rtti ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 @@ -64,8 +53,4 @@ CELFFLAGS = $(CFLAGS) -mlong-calls # --target1-abs CXXELFFLAGS = $(CXXFLAGS) -mlong-calls # --target1-abs LDELFFLAGS = -r -e main -LDELFFLAGS += -T $(call CONVERT_PATH,$(BOARD_DIR)$(DELIM)scripts$(DELIM)gnu-elf.ld) - -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - LDFLAGS += -g -endif +LDELFFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)/binfmt/libelf/gnu-elf.ld) diff --git a/boards/arm/stm32/omnibusf4/scripts/gnu-elf.ld b/boards/arm/stm32/omnibusf4/scripts/gnu-elf.ld deleted file mode 100644 index f97f39cd2fff8..0000000000000 --- a/boards/arm/stm32/omnibusf4/scripts/gnu-elf.ld +++ /dev/null @@ -1,126 +0,0 @@ -/**************************************************************************** - * boards/arm/stm32/omnibusf4/scripts/gnu-elf.ld - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. The - * ASF licenses this file to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance with the - * License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - ****************************************************************************/ - -SECTIONS -{ - .text 0x00000000 : - { - _stext = . ; - *(.text) - *(.text.*) - *(.gnu.warning) - *(.stub) - *(.glue_7) - *(.glue_7t) - *(.jcr) - - /* C++ support: The .init and .fini sections contain specific logic - * to manage static constructors and destructors. - */ - - *(.gnu.linkonce.t.*) - *(.init) /* Old ABI */ - *(.fini) /* Old ABI */ - _etext = . ; - } - - .ARM.extab : - { - *(.ARM.extab*) - } - - .ARM.exidx : - { - *(.ARM.exidx*) - } - - .rodata : - { - _srodata = . ; - *(.rodata) - *(.rodata1) - *(.rodata.*) - *(.gnu.linkonce.r*) - _erodata = . ; - } - - .data : - { - _sdata = . ; - *(.data) - *(.data1) - *(.data.*) - *(.gnu.linkonce.d*) - . = ALIGN(4); - _edata = . ; - } - - /* C++ support. For each global and static local C++ object, - * GCC creates a small subroutine to construct the object. Pointers - * to these routines (not the routines themselves) are stored as - * simple, linear arrays in the .ctors section of the object file. - * Similarly, pointers to global/static destructor routines are - * stored in .dtors. - */ - - .ctors : - { - _sctors = . ; - *(.ctors) /* Old ABI: Unallocated */ - *(.init_array) /* New ABI: Allocated */ - _edtors = . ; - } - - .dtors : - { - _sdtors = . ; - *(.dtors) /* Old ABI: Unallocated */ - *(.fini_array) /* New ABI: Allocated */ - _edtors = . ; - } - - .bss : - { - _sbss = . ; - *(.bss) - *(.bss.*) - *(.sbss) - *(.sbss.*) - *(.gnu.linkonce.b*) - *(COMMON) - . = ALIGN(4); - _ebss = . ; - } - - /* Stabs debugging sections. */ - - .stab 0 : { *(.stab) } - .stabstr 0 : { *(.stabstr) } - .stab.excl 0 : { *(.stab.excl) } - .stab.exclstr 0 : { *(.stab.exclstr) } - .stab.index 0 : { *(.stab.index) } - .stab.indexstr 0 : { *(.stab.indexstr) } - .comment 0 : { *(.comment) } - .debug_abbrev 0 : { *(.debug_abbrev) } - .debug_info 0 : { *(.debug_info) } - .debug_line 0 : { *(.debug_line) } - .debug_pubnames 0 : { *(.debug_pubnames) } - .debug_aranges 0 : { *(.debug_aranges) } -} diff --git a/boards/arm/stm32/omnibusf4/src/Make.defs b/boards/arm/stm32/omnibusf4/src/Make.defs index 3e7e821550bfc..405c979ccaa6f 100644 --- a/boards/arm/stm32/omnibusf4/src/Make.defs +++ b/boards/arm/stm32/omnibusf4/src/Make.defs @@ -60,10 +60,6 @@ ifeq ($(CONFIG_ARCH_IDLE_CUSTOM),y) CSRCS += stm32_idle.c endif -ifeq ($(CONFIG_TESTING_OSTEST),y) -CSRCS += stm32_ostest.c -endif - ifeq ($(CONFIG_TIMER),y) CSRCS += stm32_timer.c endif diff --git a/boards/arm/stm32/omnibusf4/src/stm32_ostest.c b/boards/arm/stm32/omnibusf4/src/stm32_ostest.c deleted file mode 100644 index d5688371514e5..0000000000000 --- a/boards/arm/stm32/omnibusf4/src/stm32_ostest.c +++ /dev/null @@ -1,96 +0,0 @@ -/**************************************************************************** - * boards/arm/stm32/omnibusf4/src/stm32_ostest.c - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. The - * ASF licenses this file to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance with the - * License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - ****************************************************************************/ - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include - -#include -#include -#include -#include - -#include -#include - -#include "arm_internal.h" -#include "omnibusf4.h" - -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -/* Configuration ************************************************************/ - -#undef HAVE_FPU -#if defined(CONFIG_ARCH_FPU) && \ - !defined(CONFIG_TESTING_OSTEST_FPUTESTDISABLE) && \ - defined(CONFIG_TESTING_OSTEST_FPUSIZE) && \ - defined(CONFIG_SCHED_WAITPID) -# define HAVE_FPU 1 -#endif - -#ifdef HAVE_FPU - -#if CONFIG_TESTING_OSTEST_FPUSIZE != (4 * SW_FPU_REGS) -# error "CONFIG_TESTING_OSTEST_FPUSIZE has the wrong size" -#endif - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -static uint32_t g_saveregs[XCPTCONTEXT_REGS]; - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/* Given an array of size CONFIG_TESTING_OSTEST_FPUSIZE, this function will - * return the current FPU registers. - */ - -void arch_getfpu(FAR uint32_t *fpusave) -{ - irqstate_t flags; - - /* Take a snapshot of the thread context right now */ - - flags = enter_critical_section(); - arm_saveusercontext(g_saveregs); - - /* Return only the floating register values */ - - memcpy(fpusave, &g_saveregs[REG_S0], (4*SW_FPU_REGS)); - leave_critical_section(flags); -} - -/* Given two arrays of size CONFIG_TESTING_OSTEST_FPUSIZE this function - * will compare them and return true if they are identical. - */ - -bool arch_cmpfpu(FAR const uint32_t *fpusave1, FAR const uint32_t *fpusave2) -{ - return memcmp(fpusave1, fpusave2, (4*SW_FPU_REGS)) == 0; -} - -#endif /* HAVE_FPU */ diff --git a/boards/arm/stm32/omnibusf4/src/stm32_pm.c b/boards/arm/stm32/omnibusf4/src/stm32_pm.c index 2d6e8ef2a39fb..10a30accee2b0 100644 --- a/boards/arm/stm32/omnibusf4/src/stm32_pm.c +++ b/boards/arm/stm32/omnibusf4/src/stm32_pm.c @@ -23,6 +23,7 @@ ****************************************************************************/ #include +#include #include "arm_internal.h" #include "stm32_pm.h" @@ -54,6 +55,10 @@ void arm_pminitialize(void) { + /* Initialize the NuttX power management subsystem proper */ + + pm_initialize(); + #if defined(CONFIG_ARCH_IDLE_CUSTOM) && defined(CONFIG_PM_BUTTONS) /* Initialize the buttons to wake up the system from low power modes */ diff --git a/boards/arm/stm32/photon/scripts/Make.defs b/boards/arm/stm32/photon/scripts/Make.defs index c5d9fc70da95f..ddb9965b5de7f 100644 --- a/boards/arm/stm32/photon/scripts/Make.defs +++ b/boards/arm/stm32/photon/scripts/Make.defs @@ -35,16 +35,6 @@ ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT) DFUSUFFIX = dfu-suffix DFUUTIL = dfu-util -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - -ARCHCFLAGS = -fno-common -ffunction-sections -fdata-sections -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new -fno-rtti -ffunction-sections -fdata-sections ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 @@ -60,12 +50,6 @@ NXFLATLDFLAGS1 = -r -d -warn-common NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-pcrel.ld -no-check-sections LDNXFLATFLAGS = -e main -s 2048 -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - LDFLAGS += -g -endif - -LDFLAGS += --gc-sections - ifeq ($(CONFIG_DFU_BINARY),y) define FLASH diff --git a/boards/arm/stm32/photon/src/stm32_wlan_firmware.c b/boards/arm/stm32/photon/src/stm32_wlan_firmware.c index 7f7866aa80747..fedacb77d197e 100644 --- a/boards/arm/stm32/photon/src/stm32_wlan_firmware.c +++ b/boards/arm/stm32/photon/src/stm32_wlan_firmware.c @@ -1,39 +1,20 @@ /**************************************************************************** * boards/arm/stm32/photon/src/stm32_wlan_firmware.c - * All rights reserved. * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. + * http://www.apache.org/licenses/LICENSE-2.0 * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * 3. Neither the name of Broadcom nor the names of other contributors to - * this software may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * 4. This software may not be used as a standalone product, and may only be - * used as incorporated in your product or device that incorporates Broadcom - * wireless connectivity products and solely for the purpose of enabling the - * functionalities of such Broadcom products. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY WARRANTIES OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING, - * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR - * A PARTICULAR PURPOSE AND NON-INFRINGEMENT, ARE DISCLAIMED. IN NO EVENT - * SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. * ****************************************************************************/ diff --git a/boards/arm/stm32/shenzhou/README.txt b/boards/arm/stm32/shenzhou/README.txt index f64982d0c4cde..f321c1b9f5b26 100644 --- a/boards/arm/stm32/shenzhou/README.txt +++ b/boards/arm/stm32/shenzhou/README.txt @@ -491,7 +491,7 @@ Where is one of the following: Configures the NuttShell (nsh) located at apps/examples/nsh. The Configuration enables both the serial and telnet NSH interfaces. - CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIW=y : GNU EABI toolchain for Windows + CONFIG_ARMV7M_TOOLCHAIN_GNU_EABI=y : GNU EABI toolchain for Windows CONFIG_NSH_DHCPC=n : DHCP is disabled CONFIG_NSH_IPADDR=0x0a000002 : Target IP address 10.0.0.2 CONFIG_NSH_DRIPADDR=0x0a000001 : Host IP address 10.0.0.1 diff --git a/boards/arm/stm32/shenzhou/scripts/Make.defs b/boards/arm/stm32/shenzhou/scripts/Make.defs index 66588df9ee9fe..8bde29085d462 100644 --- a/boards/arm/stm32/shenzhou/scripts/Make.defs +++ b/boards/arm/stm32/shenzhou/scripts/Make.defs @@ -35,16 +35,6 @@ ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT) MKNXFLAT = mknxflat LDNXFLAT = ldnxflat -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new -fno-rtti ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 @@ -61,7 +51,3 @@ NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-gotof #NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-pcrel.ld -no-check-sections LDNXFLATFLAGS = -e main -s 2048 - -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - LDFLAGS += -g -endif diff --git a/boards/arm/stm32/stm3210e-eval/README.txt b/boards/arm/stm32/stm3210e-eval/README.txt index a0fbef318a620..80ec3bc3635b4 100644 --- a/boards/arm/stm32/stm3210e-eval/README.txt +++ b/boards/arm/stm32/stm3210e-eval/README.txt @@ -606,7 +606,7 @@ Where is one of the following: focuses on general window controls, movement, mouse and keyboard input. - CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIW=y : GNU EABI toolchain for Windows + CONFIG_ARMV7M_TOOLCHAIN_GNU_EABI=y : GNU EABI toolchain for Windows CONFIG_LCD_RPORTRAIT=y : 240x320 reverse portrait NOTES: @@ -800,7 +800,7 @@ Where is one of the following: CONFIG_HOST_WINDOWS=y : Windows CONFIG_WINDOWS_CYGWIN=y : Cygwin - CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIW=y : GNU EABI toolchain for Windows + CONFIG_ARMV7M_TOOLCHAIN_GNU_EABI=y : GNU EABI toolchain for Windows 3. CONFIG_ARCH_CUSTOM_PMINIT and CONFIG_ARCH_IDLE_CUSTOM are necessary parts of the PM configuration: diff --git a/boards/arm/stm32/stm3210e-eval/scripts/Make.defs b/boards/arm/stm32/stm3210e-eval/scripts/Make.defs index 78b01bb3c3d02..20772398d4de2 100644 --- a/boards/arm/stm32/stm3210e-eval/scripts/Make.defs +++ b/boards/arm/stm32/stm3210e-eval/scripts/Make.defs @@ -30,16 +30,6 @@ endif ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT) -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new -fno-rtti ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 @@ -54,7 +44,3 @@ AFLAGS := $(CFLAGS) -D__ASSEMBLY__ NXFLATLDFLAGS1 = -r -d -warn-common NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-pcrel.ld -no-check-sections LDNXFLATFLAGS = -e main -s 2048 - -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - LDFLAGS += -g -endif diff --git a/boards/arm/stm32/stm3210e-eval/src/stm32_pm.c b/boards/arm/stm32/stm3210e-eval/src/stm32_pm.c index e01ff24d0a4ed..f99da35747336 100644 --- a/boards/arm/stm32/stm3210e-eval/src/stm32_pm.c +++ b/boards/arm/stm32/stm3210e-eval/src/stm32_pm.c @@ -23,6 +23,7 @@ ****************************************************************************/ #include +#include #include "arm_internal.h" #include "stm32_pm.h" @@ -54,6 +55,10 @@ void arm_pminitialize(void) { + /* Initialize the NuttX power management subsystem proper */ + + pm_initialize(); + #if defined(CONFIG_ARCH_IDLE_CUSTOM) && defined(CONFIG_PM_BUTTONS) /* Initialize the buttons to wake up the system from low power modes */ diff --git a/boards/arm/stm32/stm3220g-eval/README.txt b/boards/arm/stm32/stm3220g-eval/README.txt index d0ba1c7e6fc6f..3cada360f4942 100644 --- a/boards/arm/stm32/stm3220g-eval/README.txt +++ b/boards/arm/stm32/stm3220g-eval/README.txt @@ -534,7 +534,7 @@ Where is one of the following: CONFIG_HOST_WINDOWS=y CONFIG_WINDOWS_CYGWIN=y - CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIW=y + CONFIG_ARMV7M_TOOLCHAIN_GNU_EABI=y nettest: ------- @@ -564,7 +564,7 @@ Where is one of the following: CONFIG_HOST_WINDOWS=y : Windows CONFIG_WINDOWS_CYGWIN=y : Under Cygwin - CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIW=y : GNU EABI toolchain for Windows + CONFIG_ARMV7M_TOOLCHAIN_GNU_EABI=y : GNU EABI toolchain for Windows Than can, of course, be easily changes by reconfiguring per Note 1. @@ -573,7 +573,7 @@ Where is one of the following: Configures the NuttShell (nsh) located at apps/examples/nsh. The Configuration enables both the serial and telnet NSH interfaces. - CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIW=y : GNU EABI toolchain for Windows + CONFIG_ARMV7M_TOOLCHAIN_GNU_EABI=y : GNU EABI toolchain for Windows CONFIG_NSH_DHCPC=n : DHCP is disabled CONFIG_NSH_IPADDR=(192<<24|168<<16|13<<8|161) : Target IP address 192.168.8.161 CONFIG_NSH_DRIPADDR=(192<<24|168<<16|13<<8|1) : Host IP address 192.168.8.1 @@ -843,4 +843,4 @@ Where is one of the following: CONFIG_HOST_WINDOWS=y CONFIG_WINDOWS_CYGWIN=y - CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIW=y + CONFIG_ARMV7M_TOOLCHAIN_GNU_EABI=y diff --git a/boards/arm/stm32/stm3220g-eval/scripts/Make.defs b/boards/arm/stm32/stm3220g-eval/scripts/Make.defs index 121a7501415cf..429fea22ab7f7 100644 --- a/boards/arm/stm32/stm3220g-eval/scripts/Make.defs +++ b/boards/arm/stm32/stm3220g-eval/scripts/Make.defs @@ -23,19 +23,8 @@ include $(TOPDIR)/tools/Config.mk include $(TOPDIR)/arch/arm/src/armv7-m/Toolchain.defs LDSCRIPT = ld.script - ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT) -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new -fno-rtti ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 @@ -50,7 +39,3 @@ AFLAGS := $(CFLAGS) -D__ASSEMBLY__ NXFLATLDFLAGS1 = -r -d -warn-common NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-pcrel.ld -no-check-sections LDNXFLATFLAGS = -e main -s 2048 - -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - LDFLAGS += -g -endif diff --git a/boards/arm/stm32/stm3240g-eval/README.txt b/boards/arm/stm32/stm3240g-eval/README.txt index a11ca8ac40f26..e9c71f7e79d7f 100644 --- a/boards/arm/stm32/stm3240g-eval/README.txt +++ b/boards/arm/stm32/stm3240g-eval/README.txt @@ -176,7 +176,6 @@ There are two version of the FPU support built into the STM32 port. file: CONFIG_ARCH_FPU=y - CONFIG_ARMV7M_LAZYFPU=y FSMC SRAM ========= @@ -631,7 +630,7 @@ Where is one of the following: CONFIG_HOST_WINDOWS=y CONFIG_WINDOWS_CYGWIN=y - CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIW=y + CONFIG_ARMV7M_TOOLCHAIN_GNU_EABI=y discover: -------- @@ -646,7 +645,7 @@ Where is one of the following: Configuration settings that you may need to change for your environment: - CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIL=y - GNU EABI toolchain for Linux + CONFIG_ARMV7M_TOOLCHAIN_GNU_EABI=y - GNU EABI toolchain for Linux CONFIG_EXAMPLES_DISCOVER_DHCPC=y - DHCP Client CONFIG_EXAMPLES_DISCOVER_IPADDR - (not defined) CONFIG_EXAMPLES_DISCOVER_DRIPADDR - Router IP address @@ -810,7 +809,7 @@ Where is one of the following: using the STM32's Ethernet controller. It uses apps/examples/nettest to exercise the TCP/IP network. - CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIW=y : GNU EABI toolchain for Windows + CONFIG_ARMV7M_TOOLCHAIN_GNU_EABI=y : GNU EABI toolchain for Windows CONFIG_EXAMPLES_NETTEST_SERVER=n : Target is configured as the client CONFIG_EXAMPLES_NETTEST_PERFORMANCE=y : Only network performance is verified. CONFIG_EXAMPLES_NETTEST_IPADDR=(10<<24|0<<16|0<<8|2) : Target side is IP: 10.0.0.2 @@ -833,7 +832,7 @@ Where is one of the following: Configures the NuttShell (nsh) located at apps/examples/nsh. The Configuration enables both the serial and telnet NSH interfaces. - CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIW=y : GNU EABI toolchain for Windows + CONFIG_ARMV7M_TOOLCHAIN_GNU_EABI=y : GNU EABI toolchain for Windows CONFIG_NSH_DHCPC=n : DHCP is disabled CONFIG_NSH_IPADDR=(10<<24|0<<16|0<<8|2) : Target IP address 10.0.0.2 CONFIG_NSH_DRIPADDR=(10<<24|0<<16|0<<8|1) : Host IP address 10.0.0.1 @@ -1169,7 +1168,7 @@ Where is one of the following: CONFIG_HOST_WINDOWS=y : Windows CONFIG_WINDOWS_CYGWIN=y : With Cygwin - CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIW=y : GNU EABI toolchain for Windows + CONFIG_ARMV7M_TOOLCHAIN_GNU_EABI=y : GNU EABI toolchain for Windows nxwm ---- @@ -1207,7 +1206,7 @@ Where is one of the following: CONFIG_HOST_WINDOWS=y CONFIG_WINDOWS_CYGWIN=y - CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIW=y + CONFIG_ARMV7M_TOOLCHAIN_GNU_EABI=y xmlrpc ------ diff --git a/boards/arm/stm32/stm3240g-eval/configs/knxwm/Make.defs b/boards/arm/stm32/stm3240g-eval/configs/knxwm/Make.defs index ed761561052ae..c95f0767508f7 100644 --- a/boards/arm/stm32/stm3240g-eval/configs/knxwm/Make.defs +++ b/boards/arm/stm32/stm3240g-eval/configs/knxwm/Make.defs @@ -25,16 +25,7 @@ include $(TOPDIR)/arch/arm/src/armv7-m/Toolchain.defs ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)memory.ld ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)kernel-space.ld -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new -fno-rtti -fpermissive +ARCHCXXFLAGS += -fpermissive ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 @@ -49,7 +40,3 @@ AFLAGS := $(CFLAGS) -D__ASSEMBLY__ NXFLATLDFLAGS1 = -r -d -warn-common NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-pcrel.ld -no-check-sections LDNXFLATFLAGS = -e main -s 2048 - -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - LDFLAGS += -g -endif diff --git a/boards/arm/stm32/stm3240g-eval/scripts/Make.defs b/boards/arm/stm32/stm3240g-eval/scripts/Make.defs index e9a9df1319723..ac05cf4785de2 100644 --- a/boards/arm/stm32/stm3240g-eval/scripts/Make.defs +++ b/boards/arm/stm32/stm3240g-eval/scripts/Make.defs @@ -23,19 +23,8 @@ include $(TOPDIR)/tools/Config.mk include $(TOPDIR)/arch/arm/src/armv7-m/Toolchain.defs LDSCRIPT = ld.script - ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT) -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new -fno-rtti ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 @@ -50,7 +39,3 @@ AFLAGS := $(CFLAGS) -D__ASSEMBLY__ NXFLATLDFLAGS1 = -r -d -warn-common NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-pcrel.ld -no-check-sections LDNXFLATFLAGS = -e main -s 2048 - -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - LDFLAGS += -g -endif diff --git a/boards/arm/stm32/stm3240g-eval/src/Make.defs b/boards/arm/stm32/stm3240g-eval/src/Make.defs index bb1822e029bde..a235b8112cb6c 100644 --- a/boards/arm/stm32/stm3240g-eval/src/Make.defs +++ b/boards/arm/stm32/stm3240g-eval/src/Make.defs @@ -57,10 +57,6 @@ ifeq ($(CONFIG_BOARDCTL),y) CSRCS += stm32_appinit.c endif -ifeq ($(CONFIG_ARCH_FPU),y) -CSRCS += stm32_ostest.c -endif - ifeq ($(CONFIG_INPUT_STMPE811),y) CSRCS += stm32_stmpe811.c endif diff --git a/boards/arm/stm32/stm3240g-eval/src/stm32_ostest.c b/boards/arm/stm32/stm3240g-eval/src/stm32_ostest.c deleted file mode 100644 index 6a7a06c9b2a16..0000000000000 --- a/boards/arm/stm32/stm3240g-eval/src/stm32_ostest.c +++ /dev/null @@ -1,98 +0,0 @@ -/**************************************************************************** - * boards/arm/stm32/stm3240g-eval/src/stm32_ostest.c - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. The - * ASF licenses this file to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance with the - * License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - ****************************************************************************/ - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include - -#include -#include -#include -#include - -#include -#include - -#include "arm_internal.h" -#include "stm3240g-eval.h" - -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -/* Configuration ************************************************************/ - -#undef HAVE_FPU -#if defined(CONFIG_ARCH_FPU) && defined(CONFIG_TESTING_OSTEST_FPUSIZE) && \ - defined(CONFIG_SCHED_WAITPID) -# define HAVE_FPU 1 -#endif - -#ifdef HAVE_FPU - -#if CONFIG_TESTING_OSTEST_FPUSIZE != (4*SW_FPU_REGS) -# error "CONFIG_TESTING_OSTEST_FPUSIZE has the wrong size" -#endif - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -static uint32_t g_saveregs[XCPTCONTEXT_REGS]; - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/* Given an array of size CONFIG_TESTING_OSTEST_FPUSIZE, this function will - * return the current FPU registers. - */ - -void arch_getfpu(FAR uint32_t *fpusave) -{ - irqstate_t flags; - - /* Take a snapshot of the thread context right now */ - - flags = enter_critical_section(); - arm_saveusercontext(g_saveregs); - - /* Return only the floating register values */ - - memcpy(fpusave, &g_saveregs[REG_S0], (4*SW_FPU_REGS)); - leave_critical_section(flags); -} - -/* Given two arrays of size CONFIG_TESTING_OSTEST_FPUSIZE this function - * will compare them and return true if they are identical. - */ - -bool arch_cmpfpu(FAR const uint32_t *fpusave1, FAR const uint32_t *fpusave2) -{ - return memcmp(fpusave1, fpusave2, (4*SW_FPU_REGS)) == 0; -} - -#endif /* HAVE_FPU */ diff --git a/boards/arm/stm32/stm32_tiny/README.txt b/boards/arm/stm32/stm32_tiny/README.txt index d3a0441bd135e..b2aadadd0b814 100644 --- a/boards/arm/stm32/stm32_tiny/README.txt +++ b/boards/arm/stm32/stm32_tiny/README.txt @@ -294,7 +294,7 @@ Where is one of the following: CONFIG_HOST_WINDOWS=y : Builds under Windows CONFIG_WINDOWS_CYGWIN=y : Using Cygwin - CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIW=y : GNU EABI toolchain for Windows + CONFIG_ARMV7M_TOOLCHAIN_GNU_EABI=y : GNU EABI toolchain for Windows 3. This example supports the PWM test (apps/examples/pwm) but this must be manually enabled by selecting: @@ -400,7 +400,7 @@ Where is one of the following: CONFIG_HOST_WINDOWS=y : Builds under Windows CONFIG_WINDOWS_CYGWIN=y : Using Cygwin - CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIW=y : GNU EABI toolchain for Windows + CONFIG_ARMV7M_TOOLCHAIN_GNU_EABI=y : GNU EABI toolchain for Windows 3. This configuration does have UART2 output enabled and set up as the system logging device: diff --git a/boards/arm/stm32/stm32_tiny/scripts/Make.defs b/boards/arm/stm32/stm32_tiny/scripts/Make.defs index 06155ba524219..5c7bd3970cc97 100644 --- a/boards/arm/stm32/stm32_tiny/scripts/Make.defs +++ b/boards/arm/stm32/stm32_tiny/scripts/Make.defs @@ -23,19 +23,8 @@ include $(TOPDIR)/tools/Config.mk include $(TOPDIR)/arch/arm/src/armv7-m/Toolchain.defs LDSCRIPT = ld.script - ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT) -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 @@ -50,7 +39,3 @@ AFLAGS := $(CFLAGS) -D__ASSEMBLY__ NXFLATLDFLAGS1 = -r -d -warn-common NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-pcrel.ld -no-check-sections LDNXFLATFLAGS = -e main -s 2048 - -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - LDFLAGS += -g -endif diff --git a/boards/arm/stm32/stm32butterfly2/scripts/Make.defs b/boards/arm/stm32/stm32butterfly2/scripts/Make.defs index a5414f966b5a0..90a2427f6b797 100644 --- a/boards/arm/stm32/stm32butterfly2/scripts/Make.defs +++ b/boards/arm/stm32/stm32butterfly2/scripts/Make.defs @@ -30,16 +30,6 @@ endif ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT) -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new -fno-rtti ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 @@ -54,7 +44,3 @@ AFLAGS := $(CFLAGS) -D__ASSEMBLY__ NXFLATLDFLAGS1 = -r -d -warn-common NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-gotoff.ld -no-check-sections LDNXFLATFLAGS = -e main -s 2048 - -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - LDFLAGS += -g -endif diff --git a/boards/arm/stm32/stm32butterfly2/src/stm32_butterfly2.h b/boards/arm/stm32/stm32butterfly2/src/stm32_butterfly2.h index 0842271a164e3..a871027fddafd 100644 --- a/boards/arm/stm32/stm32butterfly2/src/stm32_butterfly2.h +++ b/boards/arm/stm32/stm32butterfly2/src/stm32_butterfly2.h @@ -88,8 +88,6 @@ int stm32_mmcsd_initialize(int minor); #else static inline int stm32_mmcsd_initialize(int minor) { - (void)minor; - return 0; } #endif diff --git a/boards/arm/stm32/stm32f103-minimum/README.txt b/boards/arm/stm32/stm32f103-minimum/README.txt index 435f69f0f6dd0..ae1508965fbdf 100644 --- a/boards/arm/stm32/stm32f103-minimum/README.txt +++ b/boards/arm/stm32/stm32f103-minimum/README.txt @@ -833,7 +833,7 @@ Configurations CONFIG_HOST_WINDOWS=y : Builds under Windows CONFIG_WINDOWS_CYGWIN=y : Using Cygwin - CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIW=y : GNU EABI toolchain for Windows + CONFIG_ARMV7M_TOOLCHAIN_GNU_EABI=y : GNU EABI toolchain for Windows 3. This configuration does have UART2 output enabled and set up as the system logging device: diff --git a/boards/arm/stm32/stm32f103-minimum/scripts/Make.defs b/boards/arm/stm32/stm32f103-minimum/scripts/Make.defs index 4bb44000ee9cd..ed5c3c928fcf0 100644 --- a/boards/arm/stm32/stm32f103-minimum/scripts/Make.defs +++ b/boards/arm/stm32/stm32f103-minimum/scripts/Make.defs @@ -30,21 +30,11 @@ endif ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT) -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 -CFLAGS := $(ARCHCFLAGS) $(ARCHWARNINGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) -ffunction-sections -fdata-sections -pipe +CFLAGS := $(ARCHCFLAGS) $(ARCHWARNINGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) -pipe CPICFLAGS = $(ARCHPICFLAGS) $(CFLAGS) CXXFLAGS := $(ARCHCXXFLAGS) $(ARCHWARNINGSXX) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHXXINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) -pipe CXXPICFLAGS = $(ARCHPICFLAGS) $(CXXFLAGS) @@ -54,9 +44,3 @@ AFLAGS := $(CFLAGS) -D__ASSEMBLY__ NXFLATLDFLAGS1 = -r -d -warn-common NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-pcrel.ld -no-check-sections LDNXFLATFLAGS = -e main -s 2048 - -LDFLAGS += --gc-sections - -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - LDFLAGS += -g -endif diff --git a/boards/arm/stm32/stm32f334-disco/scripts/Make.defs b/boards/arm/stm32/stm32f334-disco/scripts/Make.defs index 41efe8d3c24dc..4fca9868bc8eb 100644 --- a/boards/arm/stm32/stm32f334-disco/scripts/Make.defs +++ b/boards/arm/stm32/stm32f334-disco/scripts/Make.defs @@ -23,19 +23,8 @@ include $(TOPDIR)/tools/Config.mk include $(TOPDIR)/arch/arm/src/armv7-m/Toolchain.defs LDSCRIPT = ld.script - ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT) -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new -fno-rtti ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 @@ -50,7 +39,3 @@ AFLAGS := $(CFLAGS) -D__ASSEMBLY__ NXFLATLDFLAGS1 = -r -d -warn-common NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-pcrel.ld -no-check-sections LDNXFLATFLAGS = -e main -s 2048 - -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - LDFLAGS += -g -endif diff --git a/boards/arm/stm32/stm32f3discovery/README.txt b/boards/arm/stm32/stm32f3discovery/README.txt index b5ccd2238b6bd..0fc7ba02de885 100644 --- a/boards/arm/stm32/stm32f3discovery/README.txt +++ b/boards/arm/stm32/stm32f3discovery/README.txt @@ -110,7 +110,6 @@ There are two version of the FPU support built into the STM32 port. file: CONFIG_ARCH_FPU=y - CONFIG_ARMV7M_LAZYFPU=y Debugging ========= @@ -394,7 +393,7 @@ Where is one of the following: CONFIG_HOST_WINDOWS=y : Builds under Windows CONFIG_WINDOWS_CYGWIN=y : Using Cygwin - CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIW=y : GNU EABI toolchain for Windows + CONFIG_ARMV7M_TOOLCHAIN_GNU_EABI=y : GNU EABI toolchain for Windows 3. This configuration includes USB Support (CDC/ACM device) @@ -476,7 +475,7 @@ Where is one of the following: CONFIG_WINDOWS_CYGWIN=y : Using Cygwin System Type: - CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIW=y : GNU EABI toolchain for Windows + CONFIG_ARMV7M_TOOLCHAIN_GNU_EABI=y : GNU EABI toolchain for Windows 3. This configuration does have USART2 output enabled and set up as the system logging device: diff --git a/boards/arm/stm32/stm32f3discovery/scripts/Make.defs b/boards/arm/stm32/stm32f3discovery/scripts/Make.defs index 0c68a569dcb32..2f88377f77573 100644 --- a/boards/arm/stm32/stm32f3discovery/scripts/Make.defs +++ b/boards/arm/stm32/stm32f3discovery/scripts/Make.defs @@ -23,19 +23,8 @@ include $(TOPDIR)/tools/Config.mk include $(TOPDIR)/arch/arm/src/armv7-m/Toolchain.defs LDSCRIPT = ld.script - ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT) -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new -fno-rtti ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 @@ -50,7 +39,3 @@ AFLAGS := $(CFLAGS) -D__ASSEMBLY__ NXFLATLDFLAGS1 = -r -d -warn-common NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-pcrel.ld -no-check-sections LDNXFLATFLAGS = -e main -s 2048 - -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - LDFLAGS += -g -endif diff --git a/boards/arm/stm32/stm32f3discovery/scripts/gnu-elf.ld b/boards/arm/stm32/stm32f3discovery/scripts/gnu-elf.ld deleted file mode 100644 index d270ba1494fa8..0000000000000 --- a/boards/arm/stm32/stm32f3discovery/scripts/gnu-elf.ld +++ /dev/null @@ -1,115 +0,0 @@ -/**************************************************************************** - * boards/arm/stm32/stm32f3discovery/scripts/gnu-elf.ld - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. The - * ASF licenses this file to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance with the - * License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - ****************************************************************************/ - -SECTIONS -{ - .text 0x00000000 : - { - _stext = . ; - *(.text) - *(.text.*) - *(.gnu.warning) - *(.stub) - *(.glue_7) - *(.glue_7t) - *(.jcr) - - /* C++ support: The .init and .fini sections contain specific logic - * to manage static constructors and destructors. - */ - - *(.gnu.linkonce.t.*) - *(.init) /* Old ABI */ - *(.fini) /* Old ABI */ - _etext = . ; - } - - .rodata : - { - _srodata = . ; - *(.rodata) - *(.rodata1) - *(.rodata.*) - *(.gnu.linkonce.r*) - _erodata = . ; - } - - .data : - { - _sdata = . ; - *(.data) - *(.data1) - *(.data.*) - *(.gnu.linkonce.d*) - . = ALIGN(4); - _edata = . ; - } - - /* C++ support. For each global and static local C++ object, - * GCC creates a small subroutine to construct the object. Pointers - * to these routines (not the routines themselves) are stored as - * simple, linear arrays in the .ctors section of the object file. - * Similarly, pointers to global/static destructor routines are - * stored in .dtors. - */ - - .ctors : - { - _sctors = . ; - *(.ctors) /* Old ABI: Unallocated */ - *(.init_array) /* New ABI: Allocated */ - _edtors = . ; - } - - .dtors : - { - _sdtors = . ; - *(.dtors) /* Old ABI: Unallocated */ - *(.fini_array) /* New ABI: Allocated */ - _edtors = . ; - } - - .bss : - { - _sbss = . ; - *(.bss) - *(.bss.*) - *(.sbss) - *(.sbss.*) - *(.gnu.linkonce.b*) - *(COMMON) - _ebss = . ; - } - - /* Stabs debugging sections. */ - - .stab 0 : { *(.stab) } - .stabstr 0 : { *(.stabstr) } - .stab.excl 0 : { *(.stab.excl) } - .stab.exclstr 0 : { *(.stab.exclstr) } - .stab.index 0 : { *(.stab.index) } - .stab.indexstr 0 : { *(.stab.indexstr) } - .comment 0 : { *(.comment) } - .debug_abbrev 0 : { *(.debug_abbrev) } - .debug_info 0 : { *(.debug_info) } - .debug_line 0 : { *(.debug_line) } - .debug_pubnames 0 : { *(.debug_pubnames) } - .debug_aranges 0 : { *(.debug_aranges) } -} diff --git a/boards/arm/stm32/stm32f411-minimum/scripts/Make.defs b/boards/arm/stm32/stm32f411-minimum/scripts/Make.defs index f2dea21a5d27b..3a598dccfd9cb 100644 --- a/boards/arm/stm32/stm32f411-minimum/scripts/Make.defs +++ b/boards/arm/stm32/stm32f411-minimum/scripts/Make.defs @@ -23,19 +23,8 @@ include $(TOPDIR)/tools/Config.mk include $(TOPDIR)/arch/arm/src/armv7-m/Toolchain.defs LDSCRIPT = stm32f411ce.ld - ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT) -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new -fno-rtti ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 @@ -50,7 +39,3 @@ AFLAGS := $(CFLAGS) -D__ASSEMBLY__ NXFLATLDFLAGS1 = -r -d -warn-common NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-pcrel.ld -no-check-sections LDNXFLATFLAGS = -e main -s 2048 - -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - LDFLAGS += -g -endif diff --git a/boards/arm/stm32/stm32f411e-disco/scripts/Make.defs b/boards/arm/stm32/stm32f411e-disco/scripts/Make.defs index 1d3be4e7f69e9..37beea5f73d0c 100644 --- a/boards/arm/stm32/stm32f411e-disco/scripts/Make.defs +++ b/boards/arm/stm32/stm32f411e-disco/scripts/Make.defs @@ -23,19 +23,8 @@ include $(TOPDIR)/tools/Config.mk include $(TOPDIR)/arch/arm/src/armv7-m/Toolchain.defs LDSCRIPT = f411ve.ld - ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT) -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new -fno-rtti ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 @@ -50,7 +39,3 @@ AFLAGS := $(CFLAGS) -D__ASSEMBLY__ NXFLATLDFLAGS1 = -r -d -warn-common NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-pcrel.ld -no-check-sections LDNXFLATFLAGS = -e main -s 2048 - -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - LDFLAGS += -g -endif diff --git a/boards/arm/stm32/stm32f429i-disco/README.txt b/boards/arm/stm32/stm32f429i-disco/README.txt index 4d212578d2723..fb64b791a51d6 100644 --- a/boards/arm/stm32/stm32f429i-disco/README.txt +++ b/boards/arm/stm32/stm32f429i-disco/README.txt @@ -281,7 +281,6 @@ There are two version of the FPU support built into the STM32 port. file: CONFIG_ARCH_FPU=y - CONFIG_ARMV7M_LAZYFPU=y FMC SDRAM ========= @@ -702,7 +701,7 @@ Where is one of the following: CONFIG_HOST_WINDOWS=y : Builds under Windows CONFIG_WINDOWS_CYGWIN=y : Using Cygwin - CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIW=y : GNU EABI toolchain for Windows + CONFIG_ARMV7M_TOOLCHAIN_GNU_EABI=y : GNU EABI toolchain for Windows 3. This example supports the PWM test (apps/examples/pwm) but this must be manually enabled by selecting: diff --git a/boards/arm/stm32/stm32f429i-disco/scripts/Make.defs b/boards/arm/stm32/stm32f429i-disco/scripts/Make.defs index 83892ed82ac24..fbd8da7d11a96 100644 --- a/boards/arm/stm32/stm32f429i-disco/scripts/Make.defs +++ b/boards/arm/stm32/stm32f429i-disco/scripts/Make.defs @@ -23,19 +23,8 @@ include $(TOPDIR)/tools/Config.mk include $(TOPDIR)/arch/arm/src/armv7-m/Toolchain.defs LDSCRIPT = ld.script - ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT) -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new -fno-rtti ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 @@ -50,7 +39,3 @@ AFLAGS := $(CFLAGS) -D__ASSEMBLY__ NXFLATLDFLAGS1 = -r -d -warn-common NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-pcrel.ld -no-check-sections LDNXFLATFLAGS = -e main -s 2048 - -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - LDFLAGS += -g -endif diff --git a/boards/arm/stm32/stm32f429i-disco/scripts/gnu-elf.ld b/boards/arm/stm32/stm32f429i-disco/scripts/gnu-elf.ld deleted file mode 100644 index 02130ef20cfc9..0000000000000 --- a/boards/arm/stm32/stm32f429i-disco/scripts/gnu-elf.ld +++ /dev/null @@ -1,116 +0,0 @@ -/**************************************************************************** - * boards/arm/stm32/stm32f429i-disco/scripts/gnu-elf.ld - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. The - * ASF licenses this file to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance with the - * License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - ****************************************************************************/ - -SECTIONS -{ - .text 0x00000000 : - { - _stext = . ; - *(.text) - *(.text.*) - *(.gnu.warning) - *(.stub) - *(.glue_7) - *(.glue_7t) - *(.jcr) - - /* C++ support: The .init and .fini sections contain specific logic - * to manage static constructors and destructors. - */ - - *(.gnu.linkonce.t.*) - *(.init) /* Old ABI */ - *(.fini) /* Old ABI */ - _etext = . ; - } - - .rodata : - { - _srodata = . ; - *(.rodata) - *(.rodata1) - *(.rodata.*) - *(.gnu.linkonce.r*) - _erodata = . ; - } - - .data : - { - _sdata = . ; - *(.data) - *(.data1) - *(.data.*) - *(.gnu.linkonce.d*) - . = ALIGN(4); - _edata = . ; - } - - /* C++ support. For each global and static local C++ object, - * GCC creates a small subroutine to construct the object. Pointers - * to these routines (not the routines themselves) are stored as - * simple, linear arrays in the .ctors section of the object file. - * Similarly, pointers to global/static destructor routines are - * stored in .dtors. - */ - - .ctors : - { - _sctors = . ; - *(.ctors) /* Old ABI: Unallocated */ - *(.init_array) /* New ABI: Allocated */ - _edtors = . ; - } - - .dtors : - { - _sdtors = . ; - *(.dtors) /* Old ABI: Unallocated */ - *(.fini_array) /* New ABI: Allocated */ - _edtors = . ; - } - - .bss : - { - _sbss = . ; - *(.bss) - *(.bss.*) - *(.sbss) - *(.sbss.*) - *(.gnu.linkonce.b*) - *(COMMON) - . = ALIGN(4); - _ebss = . ; - } - - /* Stabs debugging sections. */ - - .stab 0 : { *(.stab) } - .stabstr 0 : { *(.stabstr) } - .stab.excl 0 : { *(.stab.excl) } - .stab.exclstr 0 : { *(.stab.exclstr) } - .stab.index 0 : { *(.stab.index) } - .stab.indexstr 0 : { *(.stab.indexstr) } - .comment 0 : { *(.comment) } - .debug_abbrev 0 : { *(.debug_abbrev) } - .debug_info 0 : { *(.debug_info) } - .debug_line 0 : { *(.debug_line) } - .debug_pubnames 0 : { *(.debug_pubnames) } - .debug_aranges 0 : { *(.debug_aranges) } -} diff --git a/boards/arm/stm32/stm32f429i-disco/src/Make.defs b/boards/arm/stm32/stm32f429i-disco/src/Make.defs index 9d15d35b6c441..6ce6c93cb71e3 100644 --- a/boards/arm/stm32/stm32f429i-disco/src/Make.defs +++ b/boards/arm/stm32/stm32f429i-disco/src/Make.defs @@ -63,10 +63,6 @@ ifeq ($(and \ CSRCS += stm32_lcd.c endif -ifeq ($(CONFIG_ARCH_FPU),y) -CSRCS += stm32_ostest.c -endif - ifeq ($(CONFIG_PWM),y) CSRCS += stm32_pwm.c endif diff --git a/boards/arm/stm32/stm32f429i-disco/src/stm32_ostest.c b/boards/arm/stm32/stm32f429i-disco/src/stm32_ostest.c deleted file mode 100644 index 12c6f91e9a3c8..0000000000000 --- a/boards/arm/stm32/stm32f429i-disco/src/stm32_ostest.c +++ /dev/null @@ -1,98 +0,0 @@ -/**************************************************************************** - * boards/arm/stm32/stm32f429i-disco/src/stm32_ostest.c - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. The - * ASF licenses this file to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance with the - * License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - ****************************************************************************/ - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include - -#include -#include -#include -#include - -#include -#include - -#include "arm_internal.h" -#include "stm32f429i-disco.h" - -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -/* Configuration ************************************************************/ - -#undef HAVE_FPU -#if defined(CONFIG_ARCH_FPU) && !defined(CONFIG_TESTING_OSTEST_FPUTESTDISABLE) && \ - defined(CONFIG_TESTING_OSTEST_FPUSIZE) && defined(CONFIG_SCHED_WAITPID) -# define HAVE_FPU 1 -#endif - -#ifdef HAVE_FPU - -#if CONFIG_TESTING_OSTEST_FPUSIZE != (4*SW_FPU_REGS) -# error "CONFIG_TESTING_OSTEST_FPUSIZE has the wrong size" -#endif - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -static uint32_t g_saveregs[XCPTCONTEXT_REGS]; - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/* Given an array of size CONFIG_TESTING_OSTEST_FPUSIZE, this function will - * return the current FPU registers. - */ - -void arch_getfpu(FAR uint32_t *fpusave) -{ - irqstate_t flags; - - /* Take a snapshot of the thread context right now */ - - flags = enter_critical_section(); - arm_saveusercontext(g_saveregs); - - /* Return only the floating register values */ - - memcpy(fpusave, &g_saveregs[REG_S0], (4*SW_FPU_REGS)); - leave_critical_section(flags); -} - -/* Given two arrays of size CONFIG_TESTING_OSTEST_FPUSIZE this function - * will compare them and return true if they are identical. - */ - -bool arch_cmpfpu(FAR const uint32_t *fpusave1, FAR const uint32_t *fpusave2) -{ - return memcmp(fpusave1, fpusave2, (4*SW_FPU_REGS)) == 0; -} - -#endif /* HAVE_FPU */ diff --git a/boards/arm/stm32/stm32f4discovery/README.txt b/boards/arm/stm32/stm32f4discovery/README.txt index 9c5cd218583f8..b366f74213ceb 100644 --- a/boards/arm/stm32/stm32f4discovery/README.txt +++ b/boards/arm/stm32/stm32f4discovery/README.txt @@ -334,7 +334,6 @@ There are two version of the FPU support built into the STM32 port. file: CONFIG_ARCH_FPU=y - CONFIG_ARMV7M_LAZYFPU=y STM32F4DIS-BB ============= @@ -1358,7 +1357,7 @@ Configuration Sub-directories CONFIG_HOST_WINDOWS=y : Windows CONFIG_WINDOWS_CYGWIN=y : Cygwin environment on Windows - CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIW=y : GNU EABI toolchain for Windows + CONFIG_ARMV7M_TOOLCHAIN_GNU_EABI=y : GNU EABI toolchain for Windows 2. By default, this project assumes that you are *NOT* using the DFU bootloader. @@ -1610,7 +1609,7 @@ Configuration Sub-directories CONFIG_HOST_WINDOWS=y : Windows CONFIG_WINDOWS_CYGWIN=y : Cygwin environment on Windows - CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIW=y : GNU EABI toolchain for Windows + CONFIG_ARMV7M_TOOLCHAIN_GNU_EABI=y : GNU EABI toolchain for Windows This is easily changed by modifying the configuration. @@ -1770,7 +1769,7 @@ Configuration Sub-directories CONFIG_HOST_WINDOWS=y : Builds under Windows CONFIG_WINDOWS_CYGWIN=y : Using Cygwin - CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIW=y : GNU EABI toolchain for Windows + CONFIG_ARMV7M_TOOLCHAIN_GNU_EABI=y : GNU EABI toolchain for Windows 2. To use this configuration with the STM32F4DIS-BB baseboard you should: @@ -2072,7 +2071,7 @@ Configuration Sub-directories An example using the NuttX graphics system (NX). This example focuses on placing lines on the background in various orientations. - CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIW=y : GNU EABI toolchain for Windows + CONFIG_ARMV7M_TOOLCHAIN_GNU_EABI=y : GNU EABI toolchain for Windows CONFIG_LCD_LANDSCAPE=y : 320x240 landscape orientation The STM32F4Discovery board does not have any graphics capability. This @@ -2148,7 +2147,7 @@ Configuration Sub-directories CONFIG_HOST_WINDOWS=y : Windows CONFIG_WINDOWS_CYGWIN=y : Cygwin - CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIW=y : GNU EABI toolchain for Windows + CONFIG_ARMV7M_TOOLCHAIN_GNU_EABI=y : GNU EABI toolchain for Windows 2. CONFIG_ARCH_CUSTOM_PMINIT and CONFIG_ARCH_IDLE_CUSTOM are necessary parts of the PM configuration: @@ -2198,7 +2197,7 @@ Configuration Sub-directories CONFIG_HOST_WINDOWS=y : Builds under windows CONFIG_WINDOWS_CYGWIN=y : Using Cygwin and - CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIW=y : Generic ARM EABI toolchain for Windows + CONFIG_ARMV7M_TOOLCHAIN_GNU_EABI=y : Generic ARM EABI toolchain for Windows 2. By default, this project assumes that you are *NOT* using the DFU bootloader. @@ -2338,7 +2337,7 @@ Configuration Sub-directories CONFIG_HOST_WINDOWS=y : Builds under Windows CONFIG_WINDOWS_CYGWIN=y : Using Cygwin - CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIW=y : GNU EABI toolchain for Windows + CONFIG_ARMV7M_TOOLCHAIN_GNU_EABI=y : GNU EABI toolchain for Windows 2. This configuration does have USART2 output enabled and set up as the system logging device: @@ -2417,7 +2416,7 @@ Configuration Sub-directories CONFIG_HOST_WINDOWS=y : Windows CONFIG_WINDOWS_NATIVE=y : Native Windows environment - CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIW=y : GNU EABI toolchain for Windows + CONFIG_ARMV7M_TOOLCHAIN_GNU_EABI=y : GNU EABI toolchain for Windows Build Tools. The build still relies on some Unix-like commands. I use the GNUWin32 tools that can be downloaded from http://gnuwin32.sourceforge.net/. diff --git a/boards/arm/stm32/stm32f4discovery/configs/testlibcxx/defconfig b/boards/arm/stm32/stm32f4discovery/configs/testlibcxx/defconfig index 78e5761701efc..ee3874bbe2874 100644 --- a/boards/arm/stm32/stm32f4discovery/configs/testlibcxx/defconfig +++ b/boards/arm/stm32/stm32f4discovery/configs/testlibcxx/defconfig @@ -13,7 +13,6 @@ CONFIG_ARCH_CHIP="stm32" CONFIG_ARCH_CHIP_STM32=y CONFIG_ARCH_CHIP_STM32F407VG=y CONFIG_ARCH_STACKDUMP=y -CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIL=y CONFIG_BOARD_LOOPSPERMSEC=16717 CONFIG_BUILTIN=y CONFIG_C99_BOOL8=y diff --git a/boards/arm/stm32/stm32f4discovery/configs/wifi/defconfig b/boards/arm/stm32/stm32f4discovery/configs/wifi/defconfig index f82dda52b097b..8d23b40d5a648 100644 --- a/boards/arm/stm32/stm32f4discovery/configs/wifi/defconfig +++ b/boards/arm/stm32/stm32f4discovery/configs/wifi/defconfig @@ -20,7 +20,6 @@ CONFIG_ARCH_CHIP_STM32=y CONFIG_ARCH_CHIP_STM32F407VG=y CONFIG_ARCH_INTERRUPTSTACK=2048 CONFIG_ARCH_STACKDUMP=y -CONFIG_ARMV7M_LAZYFPU=y CONFIG_BOARDCTL_RESET=y CONFIG_BOARD_LOOPSPERMSEC=16717 CONFIG_BUILTIN=y @@ -100,7 +99,6 @@ CONFIG_SYSTEM_NSH_SYMTAB_ARRAYNAME="g_symtab" CONFIG_SYSTEM_NSH_SYMTAB_COUNTNAME="g_nsymbols" CONFIG_SYSTEM_NTPC=y CONFIG_TESTING_OSTEST=y -CONFIG_TESTING_OSTEST_FPUSIZE=132 CONFIG_USART2_RXBUFSIZE=128 CONFIG_USART2_SERIAL_CONSOLE=y CONFIG_USART2_TXBUFSIZE=128 diff --git a/boards/arm/stm32/stm32f4discovery/scripts/Make.defs b/boards/arm/stm32/stm32f4discovery/scripts/Make.defs index 8bfc318ebcc0b..88c26568981d8 100644 --- a/boards/arm/stm32/stm32f4discovery/scripts/Make.defs +++ b/boards/arm/stm32/stm32f4discovery/scripts/Make.defs @@ -23,33 +23,18 @@ include $(TOPDIR)/tools/Config.mk include $(TOPDIR)/arch/arm/src/armv7-m/Toolchain.defs LDSCRIPT = ld.script - ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT) -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - -ARCHCFLAGS = -fno-common -ffunction-sections -fdata-sections -ARCHCXXFLAGS = -fno-common -ffunction-sections -fdata-sections -ifneq ($(CONFIG_CXX_EXCEPTION),y) - ARCHCXXFLAGS = -fno-exceptions -fcheck-new -endif - ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 -ifeq ($(CONFIG_ARMV7M_TOOLCHAIN_CLANGL),y) +ifeq ($(CONFIG_ARMV7M_TOOLCHAIN_CLANG),y) ARCHCFLAGS += -nostdlib -ffreestanding ARCHCXXFLAGS += -nostdlib -ffreestanding else ARCHCFLAGS += -funwind-tables - ARCHCXXFLAGS += -fno-rtti -funwind-tables + ARCHCXXFLAGS += -funwind-tables endif @@ -64,8 +49,6 @@ NXFLATLDFLAGS1 = -r -d -warn-common NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-pcrel.ld -no-check-sections LDNXFLATFLAGS = -e main -s 2048 -LDFLAGS += --gc-sections - # Loadable module definitions CMODULEFLAGS = $(CFLAGS) -mlong-calls # --target1-abs @@ -79,8 +62,4 @@ CELFFLAGS = $(CFLAGS) -mlong-calls # --target1-abs CXXELFFLAGS = $(CXXFLAGS) -mlong-calls # --target1-abs LDELFFLAGS = -r -e main -LDELFFLAGS += -T $(call CONVERT_PATH,$(BOARD_DIR)$(DELIM)scripts$(DELIM)gnu-elf.ld) - -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - LDFLAGS += -g -endif +LDELFFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)/binfmt/libelf/gnu-elf.ld) diff --git a/boards/arm/stm32/stm32f4discovery/scripts/gnu-elf.ld b/boards/arm/stm32/stm32f4discovery/scripts/gnu-elf.ld deleted file mode 100644 index 46ab302e95032..0000000000000 --- a/boards/arm/stm32/stm32f4discovery/scripts/gnu-elf.ld +++ /dev/null @@ -1,126 +0,0 @@ -/**************************************************************************** - * boards/arm/stm32/stm32f4discovery/scripts/gnu-elf.ld - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. The - * ASF licenses this file to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance with the - * License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - ****************************************************************************/ - -SECTIONS -{ - .text 0x00000000 : - { - _stext = . ; - *(.text) - *(.text.*) - *(.gnu.warning) - *(.stub) - *(.glue_7) - *(.glue_7t) - *(.jcr) - - /* C++ support: The .init and .fini sections contain specific logic - * to manage static constructors and destructors. - */ - - *(.gnu.linkonce.t.*) - *(.init) /* Old ABI */ - *(.fini) /* Old ABI */ - _etext = . ; - } - - .ARM.extab : - { - *(.ARM.extab*) - } - - .ARM.exidx : - { - *(.ARM.exidx*) - } - - .rodata : - { - _srodata = . ; - *(.rodata) - *(.rodata1) - *(.rodata.*) - *(.gnu.linkonce.r*) - _erodata = . ; - } - - .data : - { - _sdata = . ; - *(.data) - *(.data1) - *(.data.*) - *(.gnu.linkonce.d*) - . = ALIGN(4); - _edata = . ; - } - - /* C++ support. For each global and static local C++ object, - * GCC creates a small subroutine to construct the object. Pointers - * to these routines (not the routines themselves) are stored as - * simple, linear arrays in the .ctors section of the object file. - * Similarly, pointers to global/static destructor routines are - * stored in .dtors. - */ - - .ctors : - { - _sctors = . ; - *(.ctors) /* Old ABI: Unallocated */ - *(.init_array) /* New ABI: Allocated */ - _edtors = . ; - } - - .dtors : - { - _sdtors = . ; - *(.dtors) /* Old ABI: Unallocated */ - *(.fini_array) /* New ABI: Allocated */ - _edtors = . ; - } - - .bss : - { - _sbss = . ; - *(.bss) - *(.bss.*) - *(.sbss) - *(.sbss.*) - *(.gnu.linkonce.b*) - *(COMMON) - . = ALIGN(4); - _ebss = . ; - } - - /* Stabs debugging sections. */ - - .stab 0 : { *(.stab) } - .stabstr 0 : { *(.stabstr) } - .stab.excl 0 : { *(.stab.excl) } - .stab.exclstr 0 : { *(.stab.exclstr) } - .stab.index 0 : { *(.stab.index) } - .stab.indexstr 0 : { *(.stab.indexstr) } - .comment 0 : { *(.comment) } - .debug_abbrev 0 : { *(.debug_abbrev) } - .debug_info 0 : { *(.debug_info) } - .debug_line 0 : { *(.debug_line) } - .debug_pubnames 0 : { *(.debug_pubnames) } - .debug_aranges 0 : { *(.debug_aranges) } -} diff --git a/boards/arm/stm32/stm32f4discovery/src/Make.defs b/boards/arm/stm32/stm32f4discovery/src/Make.defs index d0e06dc9da951..89fb34f1547d4 100644 --- a/boards/arm/stm32/stm32f4discovery/src/Make.defs +++ b/boards/arm/stm32/stm32f4discovery/src/Make.defs @@ -131,10 +131,6 @@ ifeq ($(CONFIG_LCD_UG2864HSWEG01),y) CSRCS += stm32_ug2864hsweg01.c endif -ifeq ($(CONFIG_TESTING_OSTEST),y) -CSRCS += stm32_ostest.c -endif - ifeq ($(CONFIG_TIMER),y) CSRCS += stm32_timer.c endif diff --git a/boards/arm/stm32/stm32f4discovery/src/stm32_cs43l22.c b/boards/arm/stm32/stm32f4discovery/src/stm32_cs43l22.c index 0122f7e4a1f6b..5f0fa4f799441 100644 --- a/boards/arm/stm32/stm32f4discovery/src/stm32_cs43l22.c +++ b/boards/arm/stm32/stm32f4discovery/src/stm32_cs43l22.c @@ -277,7 +277,7 @@ int stm32_cs43l22_initialize(int minor) /* Configure the CS43L22 interrupt pin */ - /* TODO: (void)stm32_configgpio(PIO_INT_CS43L22); */ + /* TODO: stm32_configgpio(PIO_INT_CS43L22); */ /* Get an instance of the I2C interface for the CS43L22 chip select */ diff --git a/boards/arm/stm32/stm32f4discovery/src/stm32_ostest.c b/boards/arm/stm32/stm32f4discovery/src/stm32_ostest.c deleted file mode 100644 index 5a24458fc50b2..0000000000000 --- a/boards/arm/stm32/stm32f4discovery/src/stm32_ostest.c +++ /dev/null @@ -1,94 +0,0 @@ -/**************************************************************************** - * boards/arm/stm32/stm32f4discovery/src/stm32_ostest.c - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. The - * ASF licenses this file to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance with the - * License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - ****************************************************************************/ - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include - -#include -#include -#include -#include - -#include -#include - -#include "arm_internal.h" -#include "stm32f4discovery.h" - -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -/* Configuration ************************************************************/ - -#undef HAVE_FPU -#if defined(CONFIG_ARCH_FPU) && !defined(CONFIG_TESTING_OSTEST_FPUTESTDISABLE) && \ - defined(CONFIG_TESTING_OSTEST_FPUSIZE) && defined(CONFIG_SCHED_WAITPID) -# define HAVE_FPU 1 -#endif - -#ifdef HAVE_FPU - -#if CONFIG_TESTING_OSTEST_FPUSIZE != (4*SW_FPU_REGS) -# error "CONFIG_TESTING_OSTEST_FPUSIZE has the wrong size" -#endif - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -static uint32_t g_saveregs[XCPTCONTEXT_REGS]; - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/* Given an array of size CONFIG_TESTING_OSTEST_FPUSIZE, this function will - * return the current FPU registers. - */ - -void arch_getfpu(FAR uint32_t *fpusave) -{ - irqstate_t flags; - - /* Take a snapshot of the thread context right now */ - - flags = enter_critical_section(); - arm_saveusercontext(g_saveregs); - - /* Return only the floating register values */ - - memcpy(fpusave, &g_saveregs[REG_S0], (4*SW_FPU_REGS)); - leave_critical_section(flags); -} - -/* Given two arrays of size CONFIG_TESTING_OSTEST_FPUSIZE this function - * will compare them and return true if they are identical. - */ - -bool arch_cmpfpu(FAR const uint32_t *fpusave1, FAR const uint32_t *fpusave2) -{ - return memcmp(fpusave1, fpusave2, (4*SW_FPU_REGS)) == 0; -} - -#endif /* HAVE_FPU */ diff --git a/boards/arm/stm32/stm32f4discovery/src/stm32_pm.c b/boards/arm/stm32/stm32f4discovery/src/stm32_pm.c index 5e41b42a0630d..37a0235137749 100644 --- a/boards/arm/stm32/stm32f4discovery/src/stm32_pm.c +++ b/boards/arm/stm32/stm32f4discovery/src/stm32_pm.c @@ -23,6 +23,7 @@ ****************************************************************************/ #include +#include #include "arm_internal.h" #include "stm32_pm.h" @@ -54,6 +55,10 @@ void arm_pminitialize(void) { + /* Initialize the NuttX power management subsystem proper */ + + pm_initialize(); + #if defined(CONFIG_ARCH_IDLE_CUSTOM) && defined(CONFIG_PM_BUTTONS) /* Initialize the buttons to wake up the system from low power modes */ diff --git a/boards/arm/stm32/stm32ldiscovery/README.txt b/boards/arm/stm32/stm32ldiscovery/README.txt index 74a968ec61586..cddaea555dfb7 100644 --- a/boards/arm/stm32/stm32ldiscovery/README.txt +++ b/boards/arm/stm32/stm32ldiscovery/README.txt @@ -519,7 +519,7 @@ Configuration sub-directories CONFIG_WINDOWS_CYGWIN=y : Using Cygwin System Type: - CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIW=y : GNU EABI toolchain for Windows + CONFIG_ARMV7M_TOOLCHAIN_GNU_EABI=y : GNU EABI toolchain for Windows 4. To enable SLCD support: diff --git a/boards/arm/stm32/stm32ldiscovery/scripts/Make.defs b/boards/arm/stm32/stm32ldiscovery/scripts/Make.defs index 15ffeb8411df5..004dd2c86ebf0 100644 --- a/boards/arm/stm32/stm32ldiscovery/scripts/Make.defs +++ b/boards/arm/stm32/stm32ldiscovery/scripts/Make.defs @@ -30,16 +30,6 @@ endif ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT) -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new -fno-rtti ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 @@ -54,7 +44,3 @@ AFLAGS := $(CFLAGS) -D__ASSEMBLY__ NXFLATLDFLAGS1 = -r -d -warn-common NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-pcrel.ld -no-check-sections LDNXFLATFLAGS = -e main -s 2048 - -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - LDFLAGS += -g -endif diff --git a/boards/arm/stm32/stm32ldiscovery/scripts/gnu-elf.ld b/boards/arm/stm32/stm32ldiscovery/scripts/gnu-elf.ld deleted file mode 100644 index f81e96c4ddf80..0000000000000 --- a/boards/arm/stm32/stm32ldiscovery/scripts/gnu-elf.ld +++ /dev/null @@ -1,116 +0,0 @@ -/**************************************************************************** - * boards/arm/stm32/stm32ldiscovery/scripts/gnu-elf.ld - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. The - * ASF licenses this file to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance with the - * License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - ****************************************************************************/ - -SECTIONS -{ - .text 0x00000000 : - { - _stext = . ; - *(.text) - *(.text.*) - *(.gnu.warning) - *(.stub) - *(.glue_7) - *(.glue_7t) - *(.jcr) - - /* C++ support: The .init and .fini sections contain specific logic - * to manage static constructors and destructors. - */ - - *(.gnu.linkonce.t.*) - *(.init) /* Old ABI */ - *(.fini) /* Old ABI */ - _etext = . ; - } - - .rodata : - { - _srodata = . ; - *(.rodata) - *(.rodata1) - *(.rodata.*) - *(.gnu.linkonce.r*) - _erodata = . ; - } - - .data : - { - _sdata = . ; - *(.data) - *(.data1) - *(.data.*) - *(.gnu.linkonce.d*) - . = ALIGN(4); - _edata = . ; - } - - /* C++ support. For each global and static local C++ object, - * GCC creates a small subroutine to construct the object. Pointers - * to these routines (not the routines themselves) are stored as - * simple, linear arrays in the .ctors section of the object file. - * Similarly, pointers to global/static destructor routines are - * stored in .dtors. - */ - - .ctors : - { - _sctors = . ; - *(.ctors) /* Old ABI: Unallocated */ - *(.init_array) /* New ABI: Allocated */ - _edtors = . ; - } - - .dtors : - { - _sdtors = . ; - *(.dtors) /* Old ABI: Unallocated */ - *(.fini_array) /* New ABI: Allocated */ - _edtors = . ; - } - - .bss : - { - _sbss = . ; - *(.bss) - *(.bss.*) - *(.sbss) - *(.sbss.*) - *(.gnu.linkonce.b*) - *(COMMON) - . = ALIGN(4); - _ebss = . ; - } - - /* Stabs debugging sections. */ - - .stab 0 : { *(.stab) } - .stabstr 0 : { *(.stabstr) } - .stab.excl 0 : { *(.stab.excl) } - .stab.exclstr 0 : { *(.stab.exclstr) } - .stab.index 0 : { *(.stab.index) } - .stab.indexstr 0 : { *(.stab.indexstr) } - .comment 0 : { *(.comment) } - .debug_abbrev 0 : { *(.debug_abbrev) } - .debug_info 0 : { *(.debug_info) } - .debug_line 0 : { *(.debug_line) } - .debug_pubnames 0 : { *(.debug_pubnames) } - .debug_aranges 0 : { *(.debug_aranges) } -} diff --git a/boards/arm/stm32/stm32vldiscovery/README.txt b/boards/arm/stm32/stm32vldiscovery/README.txt index b819f7b9b4e5e..fb1d093c8ae8c 100644 --- a/boards/arm/stm32/stm32vldiscovery/README.txt +++ b/boards/arm/stm32/stm32vldiscovery/README.txt @@ -215,4 +215,4 @@ Where is one of the following: Default toolchain: - CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIL=y : GNU EABI toolchain for Linux + CONFIG_ARMV7M_TOOLCHAIN_GNU_EABI=y : GNU EABI toolchain for Linux diff --git a/boards/arm/stm32/stm32vldiscovery/scripts/Make.defs b/boards/arm/stm32/stm32vldiscovery/scripts/Make.defs index ba044744bfa99..fc1289354a93b 100644 --- a/boards/arm/stm32/stm32vldiscovery/scripts/Make.defs +++ b/boards/arm/stm32/stm32vldiscovery/scripts/Make.defs @@ -23,19 +23,8 @@ include $(TOPDIR)/tools/Config.mk include $(TOPDIR)/arch/arm/src/armv7-m/Toolchain.defs LDSCRIPT = stm32vldiscovery.ld - ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT) -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new -fno-rtti ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 @@ -50,7 +39,3 @@ AFLAGS := $(CFLAGS) -D__ASSEMBLY__ NXFLATLDFLAGS1 = -r -d -warn-common NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-pcrel.ld -no-check-sections LDNXFLATFLAGS = -e main -s 2048 - -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - LDFLAGS = -g -endif diff --git a/boards/arm/stm32/viewtool-stm32f107/README.txt b/boards/arm/stm32/viewtool-stm32f107/README.txt index a6cee000353e5..f62fbac6c38ae 100644 --- a/boards/arm/stm32/viewtool-stm32f107/README.txt +++ b/boards/arm/stm32/viewtool-stm32f107/README.txt @@ -852,7 +852,7 @@ Configurations Here are the relevant current settings: System Type -> Toolchain: - CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIW=y : GNU EABI toolchain for Windows + CONFIG_ARMV7M_TOOLCHAIN_GNU_EABI=y : GNU EABI toolchain for Windows See also the "NOTE about Windows native toolchains" in the section call "GNU Toolchain Options" above. @@ -938,7 +938,7 @@ Configurations CONFIG_HOST_WINDOWS=y : Windows operating system CONFIG_WINDOWS_CYGWIN=y : POSIX environment under Windows - CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIW=y : GNU EABI toolchain for Windows + CONFIG_ARMV7M_TOOLCHAIN_GNU_EABI=y : GNU EABI toolchain for Windows 6. USB support is disabled by default. See the section above entitled, "USB Interface" @@ -970,7 +970,7 @@ Configurations CONFIG_HOST_WINDOWS=y : Windows operating system CONFIG_WINDOWS_CYGWIN=y : POSIX environment under Windows - CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIW=y : GNU EABI toolchain for Windows + CONFIG_ARMV7M_TOOLCHAIN_GNU_EABI=y : GNU EABI toolchain for Windows 4. USB support is disabled by default. See the section above entitled, "USB Interface" diff --git a/boards/arm/stm32/viewtool-stm32f107/scripts/Make.defs b/boards/arm/stm32/viewtool-stm32f107/scripts/Make.defs index 22f263a01a554..a505034524e3b 100644 --- a/boards/arm/stm32/viewtool-stm32f107/scripts/Make.defs +++ b/boards/arm/stm32/viewtool-stm32f107/scripts/Make.defs @@ -30,16 +30,6 @@ endif ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT) -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new -fno-rtti ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 @@ -54,7 +44,3 @@ AFLAGS := $(CFLAGS) -D__ASSEMBLY__ NXFLATLDFLAGS1 = -r -d -warn-common NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-gotoff.ld -no-check-sections LDNXFLATFLAGS = -e main -s 2048 - -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - LDFLAGS += -g -endif diff --git a/boards/arm/stm32f0l0g0/b-l072z-lrwan1/scripts/Make.defs b/boards/arm/stm32f0l0g0/b-l072z-lrwan1/scripts/Make.defs index f6a2b7b5cc4c1..a59931bdb77c7 100644 --- a/boards/arm/stm32f0l0g0/b-l072z-lrwan1/scripts/Make.defs +++ b/boards/arm/stm32f0l0g0/b-l072z-lrwan1/scripts/Make.defs @@ -23,19 +23,8 @@ include $(TOPDIR)/tools/Config.mk include $(TOPDIR)/arch/arm/src/armv6-m/Toolchain.defs LDSCRIPT = ld.script - ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT) -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new -fno-rtti ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 @@ -50,7 +39,3 @@ AFLAGS := $(CFLAGS) -D__ASSEMBLY__ NXFLATLDFLAGS1 = -r -d -warn-common NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-pcrel.ld -no-check-sections LDNXFLATFLAGS = -e main -s 2048 - -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - LDFLAGS += -g -endif diff --git a/boards/arm/stm32f0l0g0/nucleo-f072rb/README.txt b/boards/arm/stm32f0l0g0/nucleo-f072rb/README.txt index d4ec1b91f2acd..7c5f7e04bf9fe 100644 --- a/boards/arm/stm32f0l0g0/nucleo-f072rb/README.txt +++ b/boards/arm/stm32f0l0g0/nucleo-f072rb/README.txt @@ -265,7 +265,7 @@ Configurations CONFIG_HOST_LINUX=y : Linux environment System Type -> Toolchain: - CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIL=y : GNU ARM EABI toolchain + CONFIG_ARMV7M_TOOLCHAIN_GNU_EABI=y : GNU ARM EABI toolchain Configuration sub-directories ----------------------------- diff --git a/boards/arm/stm32f0l0g0/nucleo-f072rb/scripts/Make.defs b/boards/arm/stm32f0l0g0/nucleo-f072rb/scripts/Make.defs index 25a191a7a6567..f0fa5451a298f 100644 --- a/boards/arm/stm32f0l0g0/nucleo-f072rb/scripts/Make.defs +++ b/boards/arm/stm32f0l0g0/nucleo-f072rb/scripts/Make.defs @@ -23,19 +23,8 @@ include $(TOPDIR)/tools/Config.mk include $(TOPDIR)/arch/arm/src/armv6-m/Toolchain.defs LDSCRIPT = flash.ld - ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT) -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new -fno-rtti ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 @@ -50,7 +39,3 @@ AFLAGS := $(CFLAGS) -D__ASSEMBLY__ NXFLATLDFLAGS1 = -r -d -warn-common NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-pcrel.ld -no-check-sections LDNXFLATFLAGS = -e main -s 2048 - -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - LDFLAGS += -g -endif diff --git a/boards/arm/stm32f0l0g0/nucleo-f091rc/README.txt b/boards/arm/stm32f0l0g0/nucleo-f091rc/README.txt index 4284ea7d5a46f..27ab23492eca0 100644 --- a/boards/arm/stm32f0l0g0/nucleo-f091rc/README.txt +++ b/boards/arm/stm32f0l0g0/nucleo-f091rc/README.txt @@ -251,7 +251,7 @@ Configurations CONFIG_HOST_LINUX=y : Linux environment System Type -> Toolchain: - CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIL=y : GNU ARM EABI toolchain + CONFIG_ARMV7M_TOOLCHAIN_GNU_EABI=y : GNU ARM EABI toolchain Configuration sub-directories ----------------------------- diff --git a/boards/arm/stm32f0l0g0/nucleo-f091rc/scripts/Make.defs b/boards/arm/stm32f0l0g0/nucleo-f091rc/scripts/Make.defs index 747b1b9615789..0bccab5815749 100644 --- a/boards/arm/stm32f0l0g0/nucleo-f091rc/scripts/Make.defs +++ b/boards/arm/stm32f0l0g0/nucleo-f091rc/scripts/Make.defs @@ -23,19 +23,8 @@ include $(TOPDIR)/tools/Config.mk include $(TOPDIR)/arch/arm/src/armv6-m/Toolchain.defs LDSCRIPT = flash.ld - ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT) -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new -fno-rtti ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 @@ -50,7 +39,3 @@ AFLAGS := $(CFLAGS) -D__ASSEMBLY__ NXFLATLDFLAGS1 = -r -d -warn-common NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-pcrel.ld -no-check-sections LDNXFLATFLAGS = -e main -s 2048 - -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - LDFLAGS += -g -endif diff --git a/boards/arm/stm32f0l0g0/nucleo-g070rb/scripts/Make.defs b/boards/arm/stm32f0l0g0/nucleo-g070rb/scripts/Make.defs index bb6126f35bfe6..e5ddbd1a218a6 100644 --- a/boards/arm/stm32f0l0g0/nucleo-g070rb/scripts/Make.defs +++ b/boards/arm/stm32f0l0g0/nucleo-g070rb/scripts/Make.defs @@ -23,19 +23,8 @@ include $(TOPDIR)/tools/Config.mk include $(TOPDIR)/arch/arm/src/armv6-m/Toolchain.defs LDSCRIPT = ld.script - ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT) -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new -fno-rtti ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 @@ -50,7 +39,3 @@ AFLAGS := $(CFLAGS) -D__ASSEMBLY__ NXFLATLDFLAGS1 = -r -d -warn-common NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-pcrel.ld -no-check-sections LDNXFLATFLAGS = -e main -s 2048 - -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - LDFLAGS += -g -endif diff --git a/boards/arm/stm32f0l0g0/nucleo-g071rb/scripts/Make.defs b/boards/arm/stm32f0l0g0/nucleo-g071rb/scripts/Make.defs index f028064d7f627..c0bcac8d99df4 100644 --- a/boards/arm/stm32f0l0g0/nucleo-g071rb/scripts/Make.defs +++ b/boards/arm/stm32f0l0g0/nucleo-g071rb/scripts/Make.defs @@ -23,19 +23,8 @@ include $(TOPDIR)/tools/Config.mk include $(TOPDIR)/arch/arm/src/armv6-m/Toolchain.defs LDSCRIPT = ld.script - ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT) -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new -fno-rtti ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 @@ -50,7 +39,3 @@ AFLAGS := $(CFLAGS) -D__ASSEMBLY__ NXFLATLDFLAGS1 = -r -d -warn-common NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-pcrel.ld -no-check-sections LDNXFLATFLAGS = -e main -s 2048 - -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - LDFLAGS += -g -endif diff --git a/boards/arm/stm32f0l0g0/nucleo-l073rz/scripts/Make.defs b/boards/arm/stm32f0l0g0/nucleo-l073rz/scripts/Make.defs index b5fda61bef008..7e3edd9e2242b 100644 --- a/boards/arm/stm32f0l0g0/nucleo-l073rz/scripts/Make.defs +++ b/boards/arm/stm32f0l0g0/nucleo-l073rz/scripts/Make.defs @@ -23,19 +23,8 @@ include $(TOPDIR)/tools/Config.mk include $(TOPDIR)/arch/arm/src/armv6-m/Toolchain.defs LDSCRIPT = ld.script - ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT) -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new -fno-rtti ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 @@ -50,7 +39,3 @@ AFLAGS := $(CFLAGS) -D__ASSEMBLY__ NXFLATLDFLAGS1 = -r -d -warn-common NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-pcrel.ld -no-check-sections LDNXFLATFLAGS = -e main -s 2048 - -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - LDFLAGS += -g -endif diff --git a/boards/arm/stm32f0l0g0/stm32f051-discovery/scripts/Make.defs b/boards/arm/stm32f0l0g0/stm32f051-discovery/scripts/Make.defs index faa3bdac65dd6..a9016f41015a3 100644 --- a/boards/arm/stm32f0l0g0/stm32f051-discovery/scripts/Make.defs +++ b/boards/arm/stm32f0l0g0/stm32f051-discovery/scripts/Make.defs @@ -23,19 +23,8 @@ include $(TOPDIR)/tools/Config.mk include $(TOPDIR)/arch/arm/src/armv6-m/Toolchain.defs LDSCRIPT = flash.ld - ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT) -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new -fno-rtti ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 @@ -50,7 +39,3 @@ AFLAGS := $(CFLAGS) -D__ASSEMBLY__ NXFLATLDFLAGS1 = -r -d -warn-common NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-pcrel.ld -no-check-sections LDNXFLATFLAGS = -e main -s 2048 - -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - LDFLAGS += -g -endif diff --git a/boards/arm/stm32f0l0g0/stm32f051-discovery/scripts/gnu-elf.ld b/boards/arm/stm32f0l0g0/stm32f051-discovery/scripts/gnu-elf.ld deleted file mode 100644 index b7371d8265fc6..0000000000000 --- a/boards/arm/stm32f0l0g0/stm32f051-discovery/scripts/gnu-elf.ld +++ /dev/null @@ -1,116 +0,0 @@ -/**************************************************************************** - * boards/arm/stm32f0l0g0/stm32f051-discovery/scripts/gnu-elf.ld - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. The - * ASF licenses this file to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance with the - * License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - ****************************************************************************/ - -SECTIONS -{ - .text 0x00000000 : - { - _stext = . ; - *(.text) - *(.text.*) - *(.gnu.warning) - *(.stub) - *(.glue_7) - *(.glue_7t) - *(.jcr) - - /* C++ support: The .init and .fini sections contain specific logic - * to manage static constructors and destructors. - */ - - *(.gnu.linkonce.t.*) - *(.init) /* Old ABI */ - *(.fini) /* Old ABI */ - _etext = . ; - } - - .rodata : - { - _srodata = . ; - *(.rodata) - *(.rodata1) - *(.rodata.*) - *(.gnu.linkonce.r*) - _erodata = . ; - } - - .data : - { - _sdata = . ; - *(.data) - *(.data1) - *(.data.*) - *(.gnu.linkonce.d*) - . = ALIGN(4); - _edata = . ; - } - - /* C++ support. For each global and static local C++ object, - * GCC creates a small subroutine to construct the object. Pointers - * to these routines (not the routines themselves) are stored as - * simple, linear arrays in the .ctors section of the object file. - * Similarly, pointers to global/static destructor routines are - * stored in .dtors. - */ - - .ctors : - { - _sctors = . ; - *(.ctors) /* Old ABI: Unallocated */ - *(.init_array) /* New ABI: Allocated */ - _edtors = . ; - } - - .dtors : - { - _sdtors = . ; - *(.dtors) /* Old ABI: Unallocated */ - *(.fini_array) /* New ABI: Allocated */ - _edtors = . ; - } - - .bss : - { - _sbss = . ; - *(.bss) - *(.bss.*) - *(.sbss) - *(.sbss.*) - *(.gnu.linkonce.b*) - *(COMMON) - . = ALIGN(4); - _ebss = . ; - } - - /* Stabs debugging sections. */ - - .stab 0 : { *(.stab) } - .stabstr 0 : { *(.stabstr) } - .stab.excl 0 : { *(.stab.excl) } - .stab.exclstr 0 : { *(.stab.exclstr) } - .stab.index 0 : { *(.stab.index) } - .stab.indexstr 0 : { *(.stab.indexstr) } - .comment 0 : { *(.comment) } - .debug_abbrev 0 : { *(.debug_abbrev) } - .debug_info 0 : { *(.debug_info) } - .debug_line 0 : { *(.debug_line) } - .debug_pubnames 0 : { *(.debug_pubnames) } - .debug_aranges 0 : { *(.debug_aranges) } -} diff --git a/boards/arm/stm32f0l0g0/stm32f072-discovery/scripts/Make.defs b/boards/arm/stm32f0l0g0/stm32f072-discovery/scripts/Make.defs index 3b8c6252848f5..28b42fa4036a5 100644 --- a/boards/arm/stm32f0l0g0/stm32f072-discovery/scripts/Make.defs +++ b/boards/arm/stm32f0l0g0/stm32f072-discovery/scripts/Make.defs @@ -23,19 +23,8 @@ include $(TOPDIR)/tools/Config.mk include $(TOPDIR)/arch/arm/src/armv6-m/Toolchain.defs LDSCRIPT = flash.ld - ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT) -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new -fno-rtti ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 @@ -50,7 +39,3 @@ AFLAGS := $(CFLAGS) -D__ASSEMBLY__ NXFLATLDFLAGS1 = -r -d -warn-common NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-pcrel.ld -no-check-sections LDNXFLATFLAGS = -e main -s 2048 - -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - LDFLAGS += -g -endif diff --git a/boards/arm/stm32f0l0g0/stm32f072-discovery/scripts/gnu-elf.ld b/boards/arm/stm32f0l0g0/stm32f072-discovery/scripts/gnu-elf.ld deleted file mode 100644 index 11771a81ac609..0000000000000 --- a/boards/arm/stm32f0l0g0/stm32f072-discovery/scripts/gnu-elf.ld +++ /dev/null @@ -1,116 +0,0 @@ -/**************************************************************************** - * boards/arm/stm32f0l0g0/stm32f072-discovery/scripts/gnu-elf.ld - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. The - * ASF licenses this file to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance with the - * License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - ****************************************************************************/ - -SECTIONS -{ - .text 0x00000000 : - { - _stext = . ; - *(.text) - *(.text.*) - *(.gnu.warning) - *(.stub) - *(.glue_7) - *(.glue_7t) - *(.jcr) - - /* C++ support: The .init and .fini sections contain specific logic - * to manage static constructors and destructors. - */ - - *(.gnu.linkonce.t.*) - *(.init) /* Old ABI */ - *(.fini) /* Old ABI */ - _etext = . ; - } - - .rodata : - { - _srodata = . ; - *(.rodata) - *(.rodata1) - *(.rodata.*) - *(.gnu.linkonce.r*) - _erodata = . ; - } - - .data : - { - _sdata = . ; - *(.data) - *(.data1) - *(.data.*) - *(.gnu.linkonce.d*) - . = ALIGN(4); - _edata = . ; - } - - /* C++ support. For each global and static local C++ object, - * GCC creates a small subroutine to construct the object. Pointers - * to these routines (not the routines themselves) are stored as - * simple, linear arrays in the .ctors section of the object file. - * Similarly, pointers to global/static destructor routines are - * stored in .dtors. - */ - - .ctors : - { - _sctors = . ; - *(.ctors) /* Old ABI: Unallocated */ - *(.init_array) /* New ABI: Allocated */ - _edtors = . ; - } - - .dtors : - { - _sdtors = . ; - *(.dtors) /* Old ABI: Unallocated */ - *(.fini_array) /* New ABI: Allocated */ - _edtors = . ; - } - - .bss : - { - _sbss = . ; - *(.bss) - *(.bss.*) - *(.sbss) - *(.sbss.*) - *(.gnu.linkonce.b*) - *(COMMON) - . = ALIGN(4); - _ebss = . ; - } - - /* Stabs debugging sections. */ - - .stab 0 : { *(.stab) } - .stabstr 0 : { *(.stabstr) } - .stab.excl 0 : { *(.stab.excl) } - .stab.exclstr 0 : { *(.stab.exclstr) } - .stab.index 0 : { *(.stab.index) } - .stab.indexstr 0 : { *(.stab.indexstr) } - .comment 0 : { *(.comment) } - .debug_abbrev 0 : { *(.debug_abbrev) } - .debug_info 0 : { *(.debug_info) } - .debug_line 0 : { *(.debug_line) } - .debug_pubnames 0 : { *(.debug_pubnames) } - .debug_aranges 0 : { *(.debug_aranges) } -} diff --git a/boards/arm/stm32f7/nucleo-144/README.txt b/boards/arm/stm32f7/nucleo-144/README.txt index 0c55f6a6905a0..98a48aac5d828 100644 --- a/boards/arm/stm32f7/nucleo-144/README.txt +++ b/boards/arm/stm32f7/nucleo-144/README.txt @@ -533,7 +533,7 @@ f7xx-nsh: for Linux. That can easily be reconfigured, of course. CONFIG_HOST_LINUX=y : Builds under Linux - CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIL=y : ARM GNU for Linux + CONFIG_ARMV7M_TOOLCHAIN_GNU_EABI=y : ARM GNU for Linux 3. The serial console may be configured to use either USART3 (which would correspond to the Virtual COM port) or with the console device @@ -600,4 +600,4 @@ f7xx-evalos: for Linux. That can easily be reconfigured, of course. CONFIG_HOST_LINUX=y : Builds under Linux - CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIL=y : ARM GNU for Linux + CONFIG_ARMV7M_TOOLCHAIN_GNU_EABI=y : ARM GNU for Linux diff --git a/boards/arm/stm32f7/nucleo-144/configs/f722-nsh/Make.defs b/boards/arm/stm32f7/nucleo-144/configs/f722-nsh/Make.defs index 7ac3d4730d7bb..b69c8bd18adae 100644 --- a/boards/arm/stm32f7/nucleo-144/configs/f722-nsh/Make.defs +++ b/boards/arm/stm32f7/nucleo-144/configs/f722-nsh/Make.defs @@ -23,19 +23,8 @@ include $(TOPDIR)/tools/Config.mk include $(TOPDIR)/arch/arm/src/armv7-m/Toolchain.defs LDSCRIPT = f722-flash.ld - ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT) -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new -fno-rtti ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 @@ -50,7 +39,3 @@ AFLAGS := $(CFLAGS) -D__ASSEMBLY__ NXFLATLDFLAGS1 = -r -d -warn-common NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-pcrel.ld -no-check-sections LDNXFLATFLAGS = -e main -s 2048 - -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - LDFLAGS += -g -endif diff --git a/boards/arm/stm32f7/nucleo-144/configs/f746-evalos/Make.defs b/boards/arm/stm32f7/nucleo-144/configs/f746-evalos/Make.defs index ec2ed3a86b4a9..d27ba222fed0d 100644 --- a/boards/arm/stm32f7/nucleo-144/configs/f746-evalos/Make.defs +++ b/boards/arm/stm32f7/nucleo-144/configs/f746-evalos/Make.defs @@ -23,19 +23,8 @@ include $(TOPDIR)/tools/Config.mk include $(TOPDIR)/arch/arm/src/armv7-m/Toolchain.defs LDSCRIPT = f746-flash.ld - ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT) -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new -fno-rtti ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 @@ -50,7 +39,3 @@ AFLAGS := $(CFLAGS) -D__ASSEMBLY__ NXFLATLDFLAGS1 = -r -d -warn-common NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-pcrel.ld -no-check-sections LDNXFLATFLAGS = -e main -s 2048 - -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - LDFLAGS += -g -endif diff --git a/boards/arm/stm32f7/nucleo-144/configs/f746-nsh/Make.defs b/boards/arm/stm32f7/nucleo-144/configs/f746-nsh/Make.defs index db0be455cbe9f..10c7ce1e95cd0 100644 --- a/boards/arm/stm32f7/nucleo-144/configs/f746-nsh/Make.defs +++ b/boards/arm/stm32f7/nucleo-144/configs/f746-nsh/Make.defs @@ -23,19 +23,8 @@ include $(TOPDIR)/tools/Config.mk include $(TOPDIR)/arch/arm/src/armv7-m/Toolchain.defs LDSCRIPT = f746-flash.ld - ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT) -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new -fno-rtti ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 @@ -50,7 +39,3 @@ AFLAGS := $(CFLAGS) -D__ASSEMBLY__ NXFLATLDFLAGS1 = -r -d -warn-common NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-pcrel.ld -no-check-sections LDNXFLATFLAGS = -e main -s 2048 - -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - LDFLAGS += -g -endif diff --git a/boards/arm/stm32f7/nucleo-144/configs/f746-pysim/Make.defs b/boards/arm/stm32f7/nucleo-144/configs/f746-pysim/Make.defs index ddf2c1af3c294..d03c6031e1d2d 100644 --- a/boards/arm/stm32f7/nucleo-144/configs/f746-pysim/Make.defs +++ b/boards/arm/stm32f7/nucleo-144/configs/f746-pysim/Make.defs @@ -23,19 +23,8 @@ include $(TOPDIR)/tools/Config.mk include $(TOPDIR)/arch/arm/src/armv7-m/Toolchain.defs LDSCRIPT = f746-flash.ld - ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT) -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new -fno-rtti ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 @@ -50,7 +39,3 @@ AFLAGS := $(CFLAGS) -D__ASSEMBLY__ NXFLATLDFLAGS1 = -r -d -warn-common NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-pcrel.ld -no-check-sections LDNXFLATFLAGS = -e main -s 2048 - -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - LDFLAGS += -g -endif diff --git a/boards/arm/stm32f7/nucleo-144/configs/f767-evalos/Make.defs b/boards/arm/stm32f7/nucleo-144/configs/f767-evalos/Make.defs index 42ab0d8fc0ed3..81caa44067676 100644 --- a/boards/arm/stm32f7/nucleo-144/configs/f767-evalos/Make.defs +++ b/boards/arm/stm32f7/nucleo-144/configs/f767-evalos/Make.defs @@ -23,19 +23,8 @@ include $(TOPDIR)/tools/Config.mk include $(TOPDIR)/arch/arm/src/armv7-m/Toolchain.defs LDSCRIPT = f767-flash.ld - ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT) -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new -fno-rtti ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 @@ -50,7 +39,3 @@ AFLAGS := $(CFLAGS) -D__ASSEMBLY__ NXFLATLDFLAGS1 = -r -d -warn-common NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-pcrel.ld -no-check-sections LDNXFLATFLAGS = -e main -s 2048 - -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - LDFLAGS += -g -endif diff --git a/boards/arm/stm32f7/nucleo-144/configs/f767-netnsh/Make.defs b/boards/arm/stm32f7/nucleo-144/configs/f767-netnsh/Make.defs index 7a8e623372f74..ae2b1cf698b27 100644 --- a/boards/arm/stm32f7/nucleo-144/configs/f767-netnsh/Make.defs +++ b/boards/arm/stm32f7/nucleo-144/configs/f767-netnsh/Make.defs @@ -23,19 +23,8 @@ include $(TOPDIR)/tools/Config.mk include $(TOPDIR)/arch/arm/src/armv7-m/Toolchain.defs LDSCRIPT = f767-flash.ld - ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT) -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new -fno-rtti ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 @@ -50,7 +39,3 @@ AFLAGS := $(CFLAGS) -D__ASSEMBLY__ NXFLATLDFLAGS1 = -r -d -warn-common NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-pcrel.ld -no-check-sections LDNXFLATFLAGS = -e main -s 2048 - -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - LDFLAGS += -g -endif diff --git a/boards/arm/stm32f7/nucleo-144/configs/f767-nsh/Make.defs b/boards/arm/stm32f7/nucleo-144/configs/f767-nsh/Make.defs index 6ce7f76982051..ec927d2413531 100644 --- a/boards/arm/stm32f7/nucleo-144/configs/f767-nsh/Make.defs +++ b/boards/arm/stm32f7/nucleo-144/configs/f767-nsh/Make.defs @@ -23,19 +23,8 @@ include $(TOPDIR)/tools/Config.mk include $(TOPDIR)/arch/arm/src/armv7-m/Toolchain.defs LDSCRIPT = f767-flash.ld - ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT) -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new -fno-rtti ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 @@ -50,7 +39,3 @@ AFLAGS := $(CFLAGS) -D__ASSEMBLY__ NXFLATLDFLAGS1 = -r -d -warn-common NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-pcrel.ld -no-check-sections LDNXFLATFLAGS = -e main -s 2048 - -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - LDFLAGS += -g -endif diff --git a/boards/arm/stm32f7/stm32f746-ws/scripts/Make.defs b/boards/arm/stm32f7/stm32f746-ws/scripts/Make.defs index 26f4b85bf54a5..f0fc020e86ef0 100644 --- a/boards/arm/stm32f7/stm32f746-ws/scripts/Make.defs +++ b/boards/arm/stm32f7/stm32f746-ws/scripts/Make.defs @@ -23,19 +23,8 @@ include $(TOPDIR)/tools/Config.mk include $(TOPDIR)/arch/arm/src/armv7-m/Toolchain.defs LDSCRIPT = flash.ld - ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT) -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new -fno-rtti ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 @@ -50,7 +39,3 @@ AFLAGS := $(CFLAGS) -D__ASSEMBLY__ NXFLATLDFLAGS1 = -r -d -warn-common NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-pcrel.ld -no-check-sections LDNXFLATFLAGS = -e main -s 2048 - -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - LDFLAGS += -g -endif diff --git a/boards/arm/stm32f7/stm32f746g-disco/README.txt b/boards/arm/stm32f7/stm32f746g-disco/README.txt index 51f1c89d851a6..2aac635d38205 100644 --- a/boards/arm/stm32f7/stm32f746g-disco/README.txt +++ b/boards/arm/stm32f7/stm32f746g-disco/README.txt @@ -172,7 +172,6 @@ There are two version of the FPU support built into the STM32 port. file: CONFIG_ARCH_FPU=y - CONFIG_ARMV7M_LAZYFPU=y STM32F746G-DISCO-specific Configuration Options =============================================== @@ -495,7 +494,7 @@ Configurations CONFIG_WINDOWS_CYGWIN=y : Cywin under Windows System Type -> Toolchain: - CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIW=y : GNU ARM EABI toolchain + CONFIG_ARMV7M_TOOLCHAIN_GNU_EABI=y : GNU ARM EABI toolchain NOTE: As of this writing, there are issues with using this tool at the -Os level of optimization. This has not been proven to be a diff --git a/boards/arm/stm32f7/stm32f746g-disco/configs/fb/defconfig b/boards/arm/stm32f7/stm32f746g-disco/configs/fb/defconfig index 1d3f3d6839045..2578dc05ff1ea 100644 --- a/boards/arm/stm32f7/stm32f746g-disco/configs/fb/defconfig +++ b/boards/arm/stm32f7/stm32f746g-disco/configs/fb/defconfig @@ -22,7 +22,6 @@ CONFIG_ARMV7M_DCACHE=y CONFIG_ARMV7M_DCACHE_WRITETHROUGH=y CONFIG_ARMV7M_DTCM=y CONFIG_ARMV7M_ICACHE=y -CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIL=y CONFIG_BOARD_LATE_INITIALIZE=y CONFIG_BOARD_LOOPSPERMSEC=43103 CONFIG_BUILTIN=y diff --git a/boards/arm/stm32f7/stm32f746g-disco/configs/nsh/defconfig b/boards/arm/stm32f7/stm32f746g-disco/configs/nsh/defconfig index 08d02c5425193..bf50f1d7ea213 100644 --- a/boards/arm/stm32f7/stm32f746g-disco/configs/nsh/defconfig +++ b/boards/arm/stm32f7/stm32f746g-disco/configs/nsh/defconfig @@ -20,7 +20,6 @@ CONFIG_ARMV7M_DCACHE=y CONFIG_ARMV7M_DCACHE_WRITETHROUGH=y CONFIG_ARMV7M_DTCM=y CONFIG_ARMV7M_ICACHE=y -CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIL=y CONFIG_BOARD_LOOPSPERMSEC=43103 CONFIG_BUILTIN=y CONFIG_DEBUG_SYMBOLS=y diff --git a/boards/arm/stm32f7/stm32f746g-disco/scripts/Make.defs b/boards/arm/stm32f7/stm32f746g-disco/scripts/Make.defs index 90d73bd5f6eaa..79402f13e2804 100644 --- a/boards/arm/stm32f7/stm32f746g-disco/scripts/Make.defs +++ b/boards/arm/stm32f7/stm32f746g-disco/scripts/Make.defs @@ -23,25 +23,11 @@ include $(TOPDIR)/tools/Config.mk include $(TOPDIR)/arch/arm/src/armv7-m/Toolchain.defs LDSCRIPT = flash.ld - ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT) -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new - -ifeq ($(CONFIG_ARMV7M_TOOLCHAIN_CLANGL),y) +ifeq ($(CONFIG_ARMV7M_TOOLCHAIN_CLANG),y) ARCHCFLAGS += -nostdlib -ffreestanding ARCHCXXFLAGS += -nostdlib -ffreestanding -else - ARCHCXXFLAGS += -fno-rtti -endif - -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g endif ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef @@ -59,10 +45,6 @@ NXFLATLDFLAGS1 = -r -d -warn-common NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-pcrel.ld -no-check-sections LDNXFLATFLAGS = -e main -s 2048 -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - LDFLAGS += -g -endif - define FLASH $(Q) st-flash write nuttx.bin 0x8000000 endef diff --git a/boards/arm/stm32f7/stm32f746g-disco/src/Makefile b/boards/arm/stm32f7/stm32f746g-disco/src/Makefile index 7ce6fed1dad18..142e3d97295a8 100644 --- a/boards/arm/stm32f7/stm32f746g-disco/src/Makefile +++ b/boards/arm/stm32f7/stm32f746g-disco/src/Makefile @@ -40,10 +40,6 @@ ifeq ($(CONFIG_ADC),y) CSRCS += stm32_adc.c endif -ifeq ($(CONFIG_ARCH_FPU),y) -CSRCS += stm32_ostest.c -endif - ifeq ($(CONFIG_SPORADIC_INSTRUMENTATION),y) CSRCS += stm32_sporadic.c endif diff --git a/boards/arm/stm32f7/stm32f746g-disco/src/stm32_ostest.c b/boards/arm/stm32f7/stm32f746g-disco/src/stm32_ostest.c deleted file mode 100644 index 46d1762d66f86..0000000000000 --- a/boards/arm/stm32f7/stm32f746g-disco/src/stm32_ostest.c +++ /dev/null @@ -1,98 +0,0 @@ -/**************************************************************************** - * boards/arm/stm32f7/stm32f746g-disco/src/stm32_ostest.c - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. The - * ASF licenses this file to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance with the - * License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - ****************************************************************************/ - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include - -#include -#include -#include -#include - -#include -#include - -#include "arm_internal.h" -#include "stm32f746g-disco.h" - -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -/* Configuration ************************************************************/ - -#undef HAVE_FPU -#if defined(CONFIG_ARCH_FPU) && !defined(CONFIG_TESTING_OSTEST_FPUTESTDISABLE) && \ - defined(CONFIG_TESTING_OSTEST_FPUSIZE) && defined(CONFIG_SCHED_WAITPID) -# define HAVE_FPU 1 -#endif - -#ifdef HAVE_FPU - -#if CONFIG_TESTING_OSTEST_FPUSIZE != (4*SW_FPU_REGS) -# error "CONFIG_TESTING_OSTEST_FPUSIZE has the wrong size" -#endif - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -static uint32_t g_saveregs[XCPTCONTEXT_REGS]; - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/* Given an array of size CONFIG_TESTING_OSTEST_FPUSIZE, this function will - * return the current FPU registers. - */ - -void arch_getfpu(FAR uint32_t *fpusave) -{ - irqstate_t flags; - - /* Take a snapshot of the thread context right now */ - - flags = enter_critical_section(); - arm_saveusercontext(g_saveregs); - - /* Return only the floating register values */ - - memcpy(fpusave, &g_saveregs[REG_S0], (4*SW_FPU_REGS)); - leave_critical_section(flags); -} - -/* Given two arrays of size CONFIG_TESTING_OSTEST_FPUSIZE this function - * will compare them and return true if they are identical. - */ - -bool arch_cmpfpu(FAR const uint32_t *fpusave1, FAR const uint32_t *fpusave2) -{ - return memcmp(fpusave1, fpusave2, (4*SW_FPU_REGS)) == 0; -} - -#endif /* HAVE_FPU */ diff --git a/boards/arm/stm32f7/stm32f746g-disco/src/stm32_sdmmc.c b/boards/arm/stm32f7/stm32f746g-disco/src/stm32_sdmmc.c index cb44bae93f48b..39a282b0b90db 100644 --- a/boards/arm/stm32f7/stm32f746g-disco/src/stm32_sdmmc.c +++ b/boards/arm/stm32f7/stm32f746g-disco/src/stm32_sdmmc.c @@ -113,8 +113,8 @@ int stm32_sdio_initialize(void) /* Register an interrupt handler for the card detect pin */ - (void)stm32_gpiosetevent(GPIO_SDIO_NCD, true, true, true, - stm32_ncd_interrupt, NULL); + stm32_gpiosetevent(GPIO_SDIO_NCD, true, true, true, + stm32_ncd_interrupt, NULL); #endif /* Mount the SDIO-based MMC/SD block driver */ diff --git a/boards/arm/stm32f7/stm32f769i-disco/configs/netnsh/defconfig b/boards/arm/stm32f7/stm32f769i-disco/configs/netnsh/defconfig index 6dbb80fe75580..13d117306761f 100644 --- a/boards/arm/stm32f7/stm32f769i-disco/configs/netnsh/defconfig +++ b/boards/arm/stm32f7/stm32f769i-disco/configs/netnsh/defconfig @@ -18,7 +18,6 @@ CONFIG_ARMV7M_DCACHE=y CONFIG_ARMV7M_DCACHE_WRITETHROUGH=y CONFIG_ARMV7M_DTCM=y CONFIG_ARMV7M_ICACHE=y -CONFIG_ARMV7M_LAZYFPU=y CONFIG_BOARD_LATE_INITIALIZE=y CONFIG_BOARD_LOOPSPERMSEC=43103 CONFIG_BUILTIN=y diff --git a/boards/arm/stm32f7/stm32f769i-disco/configs/nsh/defconfig b/boards/arm/stm32f7/stm32f769i-disco/configs/nsh/defconfig index b3bd22898aabb..b51030055023d 100644 --- a/boards/arm/stm32f7/stm32f769i-disco/configs/nsh/defconfig +++ b/boards/arm/stm32f7/stm32f769i-disco/configs/nsh/defconfig @@ -19,7 +19,6 @@ CONFIG_ARMV7M_DCACHE=y CONFIG_ARMV7M_DCACHE_WRITETHROUGH=y CONFIG_ARMV7M_DTCM=y CONFIG_ARMV7M_ICACHE=y -CONFIG_ARMV7M_LAZYFPU=y CONFIG_BOARD_LOOPSPERMSEC=43103 CONFIG_BUILTIN=y CONFIG_HAVE_CXX=y diff --git a/boards/arm/stm32f7/stm32f769i-disco/scripts/Make.defs b/boards/arm/stm32f7/stm32f769i-disco/scripts/Make.defs index 803683ca765d1..0128e8a8cb240 100644 --- a/boards/arm/stm32f7/stm32f769i-disco/scripts/Make.defs +++ b/boards/arm/stm32f7/stm32f769i-disco/scripts/Make.defs @@ -23,19 +23,8 @@ include $(TOPDIR)/tools/Config.mk include $(TOPDIR)/arch/arm/src/armv7-m/Toolchain.defs LDSCRIPT = flash.ld - ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT) -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new -fno-rtti ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 @@ -50,7 +39,3 @@ AFLAGS := $(CFLAGS) -D__ASSEMBLY__ NXFLATLDFLAGS1 = -r -d -warn-common NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-pcrel.ld -no-check-sections LDNXFLATFLAGS = -e main -s 2048 - -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - LDFLAGS += -g -endif diff --git a/boards/arm/stm32f7/stm32f769i-disco/src/Makefile b/boards/arm/stm32f7/stm32f769i-disco/src/Makefile index 7df48a10a90b1..2c1888268f42b 100644 --- a/boards/arm/stm32f7/stm32f769i-disco/src/Makefile +++ b/boards/arm/stm32f7/stm32f769i-disco/src/Makefile @@ -36,10 +36,6 @@ ifeq ($(CONFIG_BOARDCTL),y) CSRCS += stm32_appinitialize.c endif -ifeq ($(CONFIG_ARCH_FPU),y) -CSRCS += stm32_ostest.c -endif - ifeq ($(CONFIG_PWM),y) CSRCS += stm32_pwm.c endif diff --git a/boards/arm/stm32f7/stm32f769i-disco/src/stm32_ostest.c b/boards/arm/stm32f7/stm32f769i-disco/src/stm32_ostest.c deleted file mode 100644 index 92b490faad666..0000000000000 --- a/boards/arm/stm32f7/stm32f769i-disco/src/stm32_ostest.c +++ /dev/null @@ -1,98 +0,0 @@ -/**************************************************************************** - * boards/arm/stm32f7/stm32f769i-disco/src/stm32_ostest.c - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. The - * ASF licenses this file to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance with the - * License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - ****************************************************************************/ - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include - -#include -#include -#include -#include - -#include -#include - -#include "arm_internal.h" -#include "stm32f769i-disco.h" - -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -/* Configuration ************************************************************/ - -#undef HAVE_FPU -#if defined(CONFIG_ARCH_FPU) && !defined(CONFIG_TESTING_OSTEST_FPUTESTDISABLE) && \ - defined(CONFIG_TESTING_OSTEST_FPUSIZE) && defined(CONFIG_SCHED_WAITPID) -# define HAVE_FPU 1 -#endif - -#ifdef HAVE_FPU - -#if CONFIG_TESTING_OSTEST_FPUSIZE != (4*SW_FPU_REGS) -# error "CONFIG_TESTING_OSTEST_FPUSIZE has the wrong size" -#endif - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -static uint32_t g_saveregs[XCPTCONTEXT_REGS]; - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/* Given an array of size CONFIG_TESTING_OSTEST_FPUSIZE, this function will - * return the current FPU registers. - */ - -void arch_getfpu(FAR uint32_t *fpusave) -{ - irqstate_t flags; - - /* Take a snapshot of the thread context right now */ - - flags = enter_critical_section(); - arm_saveusercontext(g_saveregs); - - /* Return only the floating register values */ - - memcpy(fpusave, &g_saveregs[REG_S0], (4 * SW_FPU_REGS)); - leave_critical_section(flags); -} - -/* Given two arrays of size CONFIG_TESTING_OSTEST_FPUSIZE this function - * will compare them and return true if they are identical. - */ - -bool arch_cmpfpu(FAR const uint32_t *fpusave1, FAR const uint32_t *fpusave2) -{ - return memcmp(fpusave1, fpusave2, (4*SW_FPU_REGS)) == 0; -} - -#endif /* HAVE_FPU */ diff --git a/boards/arm/stm32h7/nucleo-h743zi/scripts/Make.defs b/boards/arm/stm32h7/nucleo-h743zi/scripts/Make.defs index bbf58014d62b4..4cc50d447b241 100644 --- a/boards/arm/stm32h7/nucleo-h743zi/scripts/Make.defs +++ b/boards/arm/stm32h7/nucleo-h743zi/scripts/Make.defs @@ -23,19 +23,8 @@ include $(TOPDIR)/tools/Config.mk include $(TOPDIR)/arch/arm/src/armv7-m/Toolchain.defs LDSCRIPT = flash.ld - ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT) -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new -fno-rtti ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 @@ -57,8 +46,4 @@ CELFFLAGS = $(CFLAGS) -mlong-calls # --target1-abs CXXELFFLAGS = $(CXXFLAGS) -mlong-calls # --target1-abs LDELFFLAGS = -r -e main -LDELFFLAGS += -T $(call CONVERT_PATH,$(BOARD_DIR)$(DELIM)scripts$(DELIM)gnu-elf.ld) - -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - LDFLAGS += -g -endif +LDELFFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)/binfmt/libelf/gnu-elf.ld) diff --git a/boards/arm/stm32h7/nucleo-h743zi/scripts/gnu-elf.ld b/boards/arm/stm32h7/nucleo-h743zi/scripts/gnu-elf.ld deleted file mode 100644 index 6175e44d400c2..0000000000000 --- a/boards/arm/stm32h7/nucleo-h743zi/scripts/gnu-elf.ld +++ /dev/null @@ -1,126 +0,0 @@ -/**************************************************************************** - * boards/arm/stm32h7/nucleo-h743zi/scripts/gnu-elf.ld - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. The - * ASF licenses this file to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance with the - * License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - ****************************************************************************/ - -SECTIONS -{ - .text 0x00000000 : - { - _stext = . ; - *(.text) - *(.text.*) - *(.gnu.warning) - *(.stub) - *(.glue_7) - *(.glue_7t) - *(.jcr) - - /* C++ support: The .init and .fini sections contain specific logic - * to manage static constructors and destructors. - */ - - *(.gnu.linkonce.t.*) - *(.init) /* Old ABI */ - *(.fini) /* Old ABI */ - _etext = . ; - } - - .ARM.extab : - { - *(.ARM.extab*) - } - - .ARM.exidx : - { - *(.ARM.exidx*) - } - - .rodata : - { - _srodata = . ; - *(.rodata) - *(.rodata1) - *(.rodata.*) - *(.gnu.linkonce.r*) - _erodata = . ; - } - - .data : - { - _sdata = . ; - *(.data) - *(.data1) - *(.data.*) - *(.gnu.linkonce.d*) - . = ALIGN(4); - _edata = . ; - } - - /* C++ support. For each global and static local C++ object, - * GCC creates a small subroutine to construct the object. Pointers - * to these routines (not the routines themselves) are stored as - * simple, linear arrays in the .ctors section of the object file. - * Similarly, pointers to global/static destructor routines are - * stored in .dtors. - */ - - .ctors : - { - _sctors = . ; - *(.ctors) /* Old ABI: Unallocated */ - *(.init_array) /* New ABI: Allocated */ - _edtors = . ; - } - - .dtors : - { - _sdtors = . ; - *(.dtors) /* Old ABI: Unallocated */ - *(.fini_array) /* New ABI: Allocated */ - _edtors = . ; - } - - .bss : - { - _sbss = . ; - *(.bss) - *(.bss.*) - *(.sbss) - *(.sbss.*) - *(.gnu.linkonce.b*) - *(COMMON) - . = ALIGN(4); - _ebss = . ; - } - - /* Stabs debugging sections. */ - - .stab 0 : { *(.stab) } - .stabstr 0 : { *(.stabstr) } - .stab.excl 0 : { *(.stab.excl) } - .stab.exclstr 0 : { *(.stab.exclstr) } - .stab.index 0 : { *(.stab.index) } - .stab.indexstr 0 : { *(.stab.indexstr) } - .comment 0 : { *(.comment) } - .debug_abbrev 0 : { *(.debug_abbrev) } - .debug_info 0 : { *(.debug_info) } - .debug_line 0 : { *(.debug_line) } - .debug_pubnames 0 : { *(.debug_pubnames) } - .debug_aranges 0 : { *(.debug_aranges) } -} diff --git a/boards/arm/stm32h7/nucleo-h743zi2/configs/jumbo/defconfig b/boards/arm/stm32h7/nucleo-h743zi2/configs/jumbo/defconfig index b631fe000e19a..9f41d573d6528 100644 --- a/boards/arm/stm32h7/nucleo-h743zi2/configs/jumbo/defconfig +++ b/boards/arm/stm32h7/nucleo-h743zi2/configs/jumbo/defconfig @@ -19,7 +19,6 @@ CONFIG_ARMV7M_DCACHE=y CONFIG_ARMV7M_DCACHE_WRITETHROUGH=y CONFIG_ARMV7M_DTCM=y CONFIG_ARMV7M_ICACHE=y -CONFIG_ARMV7M_LAZYFPU=y CONFIG_BOARDCTL_RESET=y CONFIG_BOARD_LOOPSPERMSEC=43103 CONFIG_BUILTIN=y @@ -130,7 +129,6 @@ CONFIG_TESTING_FSTEST_STACKSIZE=2048 CONFIG_TESTING_GETPRIME=y CONFIG_TESTING_GETPRIME_STACKSIZE=2048 CONFIG_TESTING_OSTEST=y -CONFIG_TESTING_OSTEST_FPUSIZE=132 CONFIG_TESTING_OSTEST_FPUSTACKSIZE=2048 CONFIG_USART3_SERIAL_CONSOLE=y CONFIG_USBHOST=y diff --git a/boards/arm/stm32h7/nucleo-h743zi2/scripts/Make.defs b/boards/arm/stm32h7/nucleo-h743zi2/scripts/Make.defs index 5d2b8d8348b1a..0ca8ddc29ea0a 100644 --- a/boards/arm/stm32h7/nucleo-h743zi2/scripts/Make.defs +++ b/boards/arm/stm32h7/nucleo-h743zi2/scripts/Make.defs @@ -23,19 +23,8 @@ include $(TOPDIR)/tools/Config.mk include $(TOPDIR)/arch/arm/src/armv7-m/Toolchain.defs LDSCRIPT = flash.ld - ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT) -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new -fno-rtti ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 @@ -57,8 +46,4 @@ CELFFLAGS = $(CFLAGS) -mlong-calls # --target1-abs CXXELFFLAGS = $(CXXFLAGS) -mlong-calls # --target1-abs LDELFFLAGS = -r -e main -LDELFFLAGS += -T $(call CONVERT_PATH,$(BOARD_DIR)$(DELIM)scripts$(DELIM)gnu-elf.ld) - -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - LDFLAGS += -g -endif +LDELFFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)/binfmt/libelf/gnu-elf.ld) diff --git a/boards/arm/stm32h7/nucleo-h743zi2/scripts/gnu-elf.ld b/boards/arm/stm32h7/nucleo-h743zi2/scripts/gnu-elf.ld deleted file mode 100644 index 153acc069565a..0000000000000 --- a/boards/arm/stm32h7/nucleo-h743zi2/scripts/gnu-elf.ld +++ /dev/null @@ -1,126 +0,0 @@ -/**************************************************************************** - * boards/arm/stm32h7/nucleo-h743zi2/scripts/gnu-elf.ld - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. The - * ASF licenses this file to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance with the - * License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - ****************************************************************************/ - -SECTIONS -{ - .text 0x00000000 : - { - _stext = . ; - *(.text) - *(.text.*) - *(.gnu.warning) - *(.stub) - *(.glue_7) - *(.glue_7t) - *(.jcr) - - /* C++ support: The .init and .fini sections contain specific logic - * to manage static constructors and destructors. - */ - - *(.gnu.linkonce.t.*) - *(.init) /* Old ABI */ - *(.fini) /* Old ABI */ - _etext = . ; - } - - .ARM.extab : - { - *(.ARM.extab*) - } - - .ARM.exidx : - { - *(.ARM.exidx*) - } - - .rodata : - { - _srodata = . ; - *(.rodata) - *(.rodata1) - *(.rodata.*) - *(.gnu.linkonce.r*) - _erodata = . ; - } - - .data : - { - _sdata = . ; - *(.data) - *(.data1) - *(.data.*) - *(.gnu.linkonce.d*) - . = ALIGN(4); - _edata = . ; - } - - /* C++ support. For each global and static local C++ object, - * GCC creates a small subroutine to construct the object. Pointers - * to these routines (not the routines themselves) are stored as - * simple, linear arrays in the .ctors section of the object file. - * Similarly, pointers to global/static destructor routines are - * stored in .dtors. - */ - - .ctors : - { - _sctors = . ; - *(.ctors) /* Old ABI: Unallocated */ - *(.init_array) /* New ABI: Allocated */ - _edtors = . ; - } - - .dtors : - { - _sdtors = . ; - *(.dtors) /* Old ABI: Unallocated */ - *(.fini_array) /* New ABI: Allocated */ - _edtors = . ; - } - - .bss : - { - _sbss = . ; - *(.bss) - *(.bss.*) - *(.sbss) - *(.sbss.*) - *(.gnu.linkonce.b*) - *(COMMON) - . = ALIGN(4); - _ebss = . ; - } - - /* Stabs debugging sections. */ - - .stab 0 : { *(.stab) } - .stabstr 0 : { *(.stabstr) } - .stab.excl 0 : { *(.stab.excl) } - .stab.exclstr 0 : { *(.stab.exclstr) } - .stab.index 0 : { *(.stab.index) } - .stab.indexstr 0 : { *(.stab.indexstr) } - .comment 0 : { *(.comment) } - .debug_abbrev 0 : { *(.debug_abbrev) } - .debug_info 0 : { *(.debug_info) } - .debug_line 0 : { *(.debug_line) } - .debug_pubnames 0 : { *(.debug_pubnames) } - .debug_aranges 0 : { *(.debug_aranges) } -} diff --git a/boards/arm/stm32h7/nucleo-h743zi2/src/Makefile b/boards/arm/stm32h7/nucleo-h743zi2/src/Makefile index 609fd1701f3e2..222e9f41c85d2 100644 --- a/boards/arm/stm32h7/nucleo-h743zi2/src/Makefile +++ b/boards/arm/stm32h7/nucleo-h743zi2/src/Makefile @@ -36,10 +36,6 @@ ifeq ($(CONFIG_BOARDCTL),y) CSRCS += stm32_appinitialize.c endif -ifeq ($(CONFIG_TESTING_OSTEST),y) -CSRCS += stm32_ostest.c -endif - ifeq ($(CONFIG_BOARDCTL_RESET),y) CSRCS += stm32_reset.c endif diff --git a/boards/arm/stm32h7/nucleo-h743zi2/src/stm32_boot.c b/boards/arm/stm32h7/nucleo-h743zi2/src/stm32_boot.c index eea8065eebeb9..31b642fa784a1 100644 --- a/boards/arm/stm32h7/nucleo-h743zi2/src/stm32_boot.c +++ b/boards/arm/stm32h7/nucleo-h743zi2/src/stm32_boot.c @@ -50,6 +50,10 @@ void stm32_boardinitialize(void) { +#ifdef CONFIG_SCHED_IRQMONITOR + up_perf_init((FAR void *)STM32_SYSCLK_FREQUENCY); +#endif + #ifdef CONFIG_ARCH_LEDS /* Configure on-board LEDs if LED support has been selected. */ diff --git a/boards/arm/stm32h7/nucleo-h743zi2/src/stm32_ostest.c b/boards/arm/stm32h7/nucleo-h743zi2/src/stm32_ostest.c deleted file mode 100644 index e058a38514000..0000000000000 --- a/boards/arm/stm32h7/nucleo-h743zi2/src/stm32_ostest.c +++ /dev/null @@ -1,94 +0,0 @@ -/**************************************************************************** - * boards/arm/stm32h7/nucleo-h743zi2/src/stm32_ostest.c - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. The - * ASF licenses this file to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance with the - * License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - ****************************************************************************/ - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include - -#include -#include -#include -#include - -#include -#include - -#include "arm_internal.h" -#include "nucleo-h743zi2.h" - -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -/* Configuration ************************************************************/ - -#undef HAVE_FPU -#if defined(CONFIG_ARCH_FPU) && !defined(CONFIG_TESTING_OSTEST_FPUTESTDISABLE) && \ - defined(CONFIG_TESTING_OSTEST_FPUSIZE) && defined(CONFIG_SCHED_WAITPID) -# define HAVE_FPU 1 -#endif - -#ifdef HAVE_FPU - -#if CONFIG_TESTING_OSTEST_FPUSIZE != (4*SW_FPU_REGS) -# error "CONFIG_TESTING_OSTEST_FPUSIZE has the wrong size" -#endif - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -static uint32_t g_saveregs[XCPTCONTEXT_REGS]; - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/* Given an array of size CONFIG_TESTING_OSTEST_FPUSIZE, this function will - * return the current FPU registers. - */ - -void arch_getfpu(FAR uint32_t *fpusave) -{ - irqstate_t flags; - - /* Take a snapshot of the thread context right now */ - - flags = enter_critical_section(); - arm_saveusercontext(g_saveregs); - - /* Return only the floating register values */ - - memcpy(fpusave, &g_saveregs[REG_S0], (4*SW_FPU_REGS)); - leave_critical_section(flags); -} - -/* Given two arrays of size CONFIG_TESTING_OSTEST_FPUSIZE this function - * will compare them and return true if they are identical. - */ - -bool arch_cmpfpu(FAR const uint32_t *fpusave1, FAR const uint32_t *fpusave2) -{ - return memcmp(fpusave1, fpusave2, (4*SW_FPU_REGS)) == 0; -} - -#endif /* HAVE_FPU */ diff --git a/boards/arm/stm32h7/stm32h747i-disco/scripts/Make.defs b/boards/arm/stm32h7/stm32h747i-disco/scripts/Make.defs index 12135d781fc08..928b2e96d7bbb 100644 --- a/boards/arm/stm32h7/stm32h747i-disco/scripts/Make.defs +++ b/boards/arm/stm32h7/stm32h747i-disco/scripts/Make.defs @@ -23,19 +23,8 @@ include $(TOPDIR)/tools/Config.mk include $(TOPDIR)/arch/arm/src/armv7-m/Toolchain.defs LDSCRIPT = flash.ld - ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT) -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new -fno-rtti ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 @@ -50,7 +39,3 @@ AFLAGS := $(CFLAGS) -D__ASSEMBLY__ NXFLATLDFLAGS1 = -r -d -warn-common NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-pcrel.ld -no-check-sections LDNXFLATFLAGS = -e main -s 2048 - -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - LDFLAGS += -g -endif diff --git a/boards/arm/stm32h7/stm32h747i-disco/src/stm32_boot.c b/boards/arm/stm32h7/stm32h747i-disco/src/stm32_boot.c index 596df355eb282..fef6b5eed0c42 100644 --- a/boards/arm/stm32h7/stm32h747i-disco/src/stm32_boot.c +++ b/boards/arm/stm32h7/stm32h747i-disco/src/stm32_boot.c @@ -91,7 +91,7 @@ void board_late_initialize(void) * board_app_initialize(). */ - (void)stm32_bringup(); + stm32_bringup(); #endif } #endif diff --git a/boards/arm/stm32l4/b-l475e-iot01a/README.txt b/boards/arm/stm32l4/b-l475e-iot01a/README.txt index 0d147f41aafea..082791102de87 100644 --- a/boards/arm/stm32l4/b-l475e-iot01a/README.txt +++ b/boards/arm/stm32l4/b-l475e-iot01a/README.txt @@ -259,7 +259,7 @@ Configurations CONFIG_WINDOWS_CYGWIN=y : Cywin under Windows System Type -> Toolchain: - CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIW=y : GNU ARM EABI toolchain + CONFIG_ARMV7M_TOOLCHAIN_GNU_EABI=y : GNU ARM EABI toolchain Configuration sub-directories ----------------------------- diff --git a/boards/arm/stm32l4/b-l475e-iot01a/scripts/Make.defs b/boards/arm/stm32l4/b-l475e-iot01a/scripts/Make.defs index de5b9b358e706..5004ed0854406 100644 --- a/boards/arm/stm32l4/b-l475e-iot01a/scripts/Make.defs +++ b/boards/arm/stm32l4/b-l475e-iot01a/scripts/Make.defs @@ -23,22 +23,12 @@ include $(TOPDIR)/tools/Config.mk include $(TOPDIR)/arch/arm/src/armv7-m/Toolchain.defs # TODO add stm32 bootloader support -LDSCRIPT = flash.ld +LDSCRIPT = flash.ld ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT) # See http://dfu-util.sourceforge.net/ -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new -fno-rtti ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 @@ -54,10 +44,6 @@ NXFLATLDFLAGS1 = -r -d -warn-common NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-pcrel.ld -no-check-sections LDNXFLATFLAGS = -e main -s 2048 -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - LDFLAGS += -g -endif - define FLASH $(Q) echo "Download firmware $(1).bin" $(Q) st-flash write $(1).bin 0x08000000 diff --git a/boards/arm/stm32l4/nucleo-l432kc/README.txt b/boards/arm/stm32l4/nucleo-l432kc/README.txt index 19487b0c2d13b..740a17e9c9262 100644 --- a/boards/arm/stm32l4/nucleo-l432kc/README.txt +++ b/boards/arm/stm32l4/nucleo-l432kc/README.txt @@ -93,7 +93,7 @@ GNU Toolchain Options a different toolchain, you simply need to modify the configuration. As an example: - CONFIG_ARM_TOOLCHAIN_GNU_EABIL : Generic arm-none-eabi toolchain + CONFIG_ARM_TOOLCHAIN_GNU_EABI : Generic arm-none-eabi toolchain IDEs ==== @@ -442,7 +442,7 @@ Configurations for Linux. That can easily be reconfigured, of course. CONFIG_HOST_LINUX=y : Builds under Linux - CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIL=y : GNU EABI toolchain for Linux + CONFIG_ARMV7M_TOOLCHAIN_GNU_EABI=y : GNU EABI toolchain for Linux 3. Although the default console is USART2 (which would correspond to the Virtual COM port) I have done all testing with the console diff --git a/boards/arm/stm32l4/nucleo-l432kc/scripts/Make.defs b/boards/arm/stm32l4/nucleo-l432kc/scripts/Make.defs index 439607e9f1a73..c27a511b9b3e9 100644 --- a/boards/arm/stm32l4/nucleo-l432kc/scripts/Make.defs +++ b/boards/arm/stm32l4/nucleo-l432kc/scripts/Make.defs @@ -23,19 +23,8 @@ include $(TOPDIR)/tools/Config.mk include $(TOPDIR)/arch/arm/src/armv7-m/Toolchain.defs LDSCRIPT = l432kc.ld - ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT) -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new -fno-rtti ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 @@ -50,7 +39,3 @@ AFLAGS := $(CFLAGS) -D__ASSEMBLY__ NXFLATLDFLAGS1 = -r -d -warn-common NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-pcrel.ld -no-check-sections LDNXFLATFLAGS = -e main -s 2048 - -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - LDFLAGS += -g -endif diff --git a/boards/arm/stm32l4/nucleo-l452re/README.txt b/boards/arm/stm32l4/nucleo-l452re/README.txt index 03dc121890ed8..412d789c1281e 100644 --- a/boards/arm/stm32l4/nucleo-l452re/README.txt +++ b/boards/arm/stm32l4/nucleo-l452re/README.txt @@ -257,7 +257,7 @@ Configurations CONFIG_HOST_LINUX=y : Linux environment System Type -> Toolchain: - CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIL=y : GNU ARM EABI toolchain + CONFIG_ARMV7M_TOOLCHAIN_GNU_EABI=y : GNU ARM EABI toolchain Configuration sub-directories ----------------------------- diff --git a/boards/arm/stm32l4/nucleo-l452re/scripts/Make.defs b/boards/arm/stm32l4/nucleo-l452re/scripts/Make.defs index a81f3c25aca5e..cbbab356ff3df 100644 --- a/boards/arm/stm32l4/nucleo-l452re/scripts/Make.defs +++ b/boards/arm/stm32l4/nucleo-l452re/scripts/Make.defs @@ -23,19 +23,8 @@ include $(TOPDIR)/tools/Config.mk include $(TOPDIR)/arch/arm/src/armv7-m/Toolchain.defs LDSCRIPT = l452re-flash.ld - ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT) -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new -fno-rtti ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 @@ -50,7 +39,3 @@ AFLAGS := $(CFLAGS) -D__ASSEMBLY__ NXFLATLDFLAGS1 = -r -d -warn-common NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-pcrel.ld -no-check-sections LDNXFLATFLAGS = -e main -s 2048 - -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - LDFLAGS += -g -endif diff --git a/boards/arm/stm32l4/nucleo-l476rg/README.txt b/boards/arm/stm32l4/nucleo-l476rg/README.txt index be6df33f17ba0..846b91b32bb9d 100644 --- a/boards/arm/stm32l4/nucleo-l476rg/README.txt +++ b/boards/arm/stm32l4/nucleo-l476rg/README.txt @@ -106,7 +106,7 @@ GNU Toolchain Options a different toolchain, you simply need to modify the configuration. As an example: - CONFIG_ARM_TOOLCHAIN_GNU_EABIL : Generic arm-none-eabi toolchain + CONFIG_ARM_TOOLCHAIN_GNU_EABI : Generic arm-none-eabi toolchain IDEs ==== @@ -565,7 +565,7 @@ Configurations for Linux. That can easily be reconfigured, of course. CONFIG_HOST_LINUX=y : Builds under Linux - CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIL=y : GNU EABI toolchain for Linux + CONFIG_ARMV7M_TOOLCHAIN_GNU_EABI=y : GNU EABI toolchain for Linux 3. Although the default console is USART2 (which would correspond to the Virtual COM port) I have done all testing with the console diff --git a/boards/arm/stm32l4/nucleo-l476rg/scripts/Make.defs b/boards/arm/stm32l4/nucleo-l476rg/scripts/Make.defs index f2de70ccf9d73..5c68be47a638e 100644 --- a/boards/arm/stm32l4/nucleo-l476rg/scripts/Make.defs +++ b/boards/arm/stm32l4/nucleo-l476rg/scripts/Make.defs @@ -23,19 +23,8 @@ include $(TOPDIR)/tools/Config.mk include $(TOPDIR)/arch/arm/src/armv7-m/Toolchain.defs LDSCRIPT = l476rg.ld - ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT) -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new -fno-rtti ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 @@ -47,19 +36,6 @@ CXXPICFLAGS = $(ARCHPICFLAGS) $(CXXFLAGS) CPPFLAGS := $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) AFLAGS := $(CFLAGS) -D__ASSEMBLY__ -ifeq ($(CONFIG_LIBCXX),y) - CXXFLAGS += -std=c++14 -D__GLIBCXX__ -DMB_LEN_MAX=8 -DHAVE_DEPENDENT_EH_ABI=0 \ - -D_DEBUG -D_LIBCPP_BUILD_STATIC -D_LIBCPP_STD_VER=14 - - ifneq ($(CONFIG_CXX_EXCEPTION),y) - CXXFLAGS += -fno-exceptions -fno-rtti -fcheck-new -D_LIBCPP_NO_EXCEPTIONS - endif -endif - NXFLATLDFLAGS1 = -r -d -warn-common NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-pcrel.ld -no-check-sections LDNXFLATFLAGS = -e main -s 2048 - -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - LDFLAGS += -g -endif diff --git a/boards/arm/stm32l4/nucleo-l496zg/README.txt b/boards/arm/stm32l4/nucleo-l496zg/README.txt index b7e2648dd4f78..f97a2b0ecd10f 100644 --- a/boards/arm/stm32l4/nucleo-l496zg/README.txt +++ b/boards/arm/stm32l4/nucleo-l496zg/README.txt @@ -291,7 +291,7 @@ nsh: for Linux. That can easily be reconfigured, of course. CONFIG_HOST_LINUX=y : Builds under Linux - CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIL=y : ARM GNU for Linux + CONFIG_ARMV7M_TOOLCHAIN_GNU_EABI=y : ARM GNU for Linux 3. Although the default console is LPUART1 (which would correspond to the Virtual COM port) I have done all testing with the console diff --git a/boards/arm/stm32l4/nucleo-l496zg/scripts/Make.defs b/boards/arm/stm32l4/nucleo-l496zg/scripts/Make.defs index b9e3e2d644a47..0800f9adccaaf 100644 --- a/boards/arm/stm32l4/nucleo-l496zg/scripts/Make.defs +++ b/boards/arm/stm32l4/nucleo-l496zg/scripts/Make.defs @@ -23,19 +23,8 @@ include $(TOPDIR)/tools/Config.mk include $(TOPDIR)/arch/arm/src/armv7-m/Toolchain.defs LDSCRIPT = l496zg-flash.ld - ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT) -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new -fno-rtti ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 @@ -50,7 +39,3 @@ AFLAGS := $(CFLAGS) -D__ASSEMBLY__ NXFLATLDFLAGS1 = -r -d -warn-common NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-pcrel.ld -no-check-sections LDNXFLATFLAGS = -e main -s 2048 - -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - LDFLAGS += -g -endif diff --git a/boards/arm/stm32l4/stm32l476-mdk/scripts/Make.defs b/boards/arm/stm32l4/stm32l476-mdk/scripts/Make.defs index dba145617f240..4ce7b14fb16bf 100644 --- a/boards/arm/stm32l4/stm32l476-mdk/scripts/Make.defs +++ b/boards/arm/stm32l4/stm32l476-mdk/scripts/Make.defs @@ -23,19 +23,8 @@ include $(TOPDIR)/tools/Config.mk include $(TOPDIR)/arch/arm/src/armv7-m/Toolchain.defs LDSCRIPT = stm32l476-mdk.ld - ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT) -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fno-rtti ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 @@ -50,7 +39,3 @@ AFLAGS := $(CFLAGS) -D__ASSEMBLY__ NXFLATLDFLAGS1 = -r -d -warn-common NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-pcrel.ld -no-check-sections LDNXFLATFLAGS = -e main -s 2048 - -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - LDFLAGS += -g -endif diff --git a/boards/arm/stm32l4/stm32l476vg-disco/README.txt b/boards/arm/stm32l4/stm32l476vg-disco/README.txt index ba86388a64f04..550fddcd2acb2 100644 --- a/boards/arm/stm32l4/stm32l476vg-disco/README.txt +++ b/boards/arm/stm32l4/stm32l476vg-disco/README.txt @@ -443,7 +443,7 @@ Configurations for Linux. That can easily be reconfigured, of course. CONFIG_HOST_LINUX=y : Builds under Linux - CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIL=y : Generic EABI toolchain for Linux + CONFIG_ARMV7M_TOOLCHAIN_GNU_EABI=y : Generic EABI toolchain for Linux 3. Although the default console is USART2 (which would correspond to the Virtual COM port) I have done all testing with the console diff --git a/boards/arm/stm32l4/stm32l476vg-disco/configs/knsh/Make.defs b/boards/arm/stm32l4/stm32l476vg-disco/configs/knsh/Make.defs index b1cab6884b580..34e5accd53209 100644 --- a/boards/arm/stm32l4/stm32l476vg-disco/configs/knsh/Make.defs +++ b/boards/arm/stm32l4/stm32l476vg-disco/configs/knsh/Make.defs @@ -28,16 +28,6 @@ LDSCRIPT2 = kernel-space.ld ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT1) ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT2) -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new -fno-rtti ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 @@ -53,10 +43,5 @@ NXFLATLDFLAGS1 = -r -d -warn-common NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-pcrel.ld -no-check-sections LDNXFLATFLAGS = -e main -s 2048 -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - LDFLAGS += -g -endif - -#LDFLAGS += -Map=$(TOPDIR)/nuttx.map #CFLAGS += -Wa,-adhln #CXXFLAGS += -Wa,-adhln diff --git a/boards/arm/stm32l4/stm32l476vg-disco/include/nsh_romfsimg.h b/boards/arm/stm32l4/stm32l476vg-disco/include/nsh_romfsimg.h index 6bf0d908f08c0..4d375809edeb2 100644 --- a/boards/arm/stm32l4/stm32l476vg-disco/include/nsh_romfsimg.h +++ b/boards/arm/stm32l4/stm32l476vg-disco/include/nsh_romfsimg.h @@ -1,3 +1,23 @@ +/*************************************************************************** + * boards/arm/stm32l4/stm32l476vg-disco/include/nsh_romfsimg.h + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ***************************************************************************/ + unsigned char romfs_img[] = { 0x2d, 0x72, 0x6f, 0x6d, 0x31, 0x66, 0x73, 0x2d, 0x00, 0x00, 0x01, 0x80, 0x42, 0x56, 0x48, 0x93, 0x4e, 0x53, 0x48, 0x49, 0x6e, 0x69, 0x74, 0x56, diff --git a/boards/arm/stm32l4/stm32l476vg-disco/include/rc.sysinit.template b/boards/arm/stm32l4/stm32l476vg-disco/include/rc.sysinit.template new file mode 100644 index 0000000000000..acbbe6da1ef6a --- /dev/null +++ b/boards/arm/stm32l4/stm32l476vg-disco/include/rc.sysinit.template @@ -0,0 +1,2 @@ +# sample rc.sysinit file; you must run tools/genromfs from within this +# location to convert this file to nsh_romfsimg.h for inclusion in the build diff --git a/boards/arm/stm32l4/stm32l476vg-disco/scripts/Make.defs b/boards/arm/stm32l4/stm32l476vg-disco/scripts/Make.defs index 1ace1d34bfb17..bcff8593533a7 100644 --- a/boards/arm/stm32l4/stm32l476vg-disco/scripts/Make.defs +++ b/boards/arm/stm32l4/stm32l476vg-disco/scripts/Make.defs @@ -23,19 +23,8 @@ include $(TOPDIR)/tools/Config.mk include $(TOPDIR)/arch/arm/src/armv7-m/Toolchain.defs LDSCRIPT = stm32l476vg-disco.ld - ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT) -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new -fno-rtti ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 @@ -51,10 +40,5 @@ NXFLATLDFLAGS1 = -r -d -warn-common NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-pcrel.ld -no-check-sections LDNXFLATFLAGS = -e main -s 2048 -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - LDFLAGS += -g -endif - -LDFLAGS += -Map=$(TOPDIR)/nuttx.map #CFLAGS += -Wa,-adhln #CXXFLAGS += -Wa,-adhln diff --git a/boards/arm/stm32l4/stm32l4r9ai-disco/README.txt b/boards/arm/stm32l4/stm32l4r9ai-disco/README.txt index fa6ddf1c6b364..e62c6727b93b8 100644 --- a/boards/arm/stm32l4/stm32l4r9ai-disco/README.txt +++ b/boards/arm/stm32l4/stm32l4r9ai-disco/README.txt @@ -340,7 +340,7 @@ Configurations for Linux. That can easily be reconfigured, of course. CONFIG_HOST_LINUX=y : Builds under Linux - CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIL=y : Generic EABI toolchain for Linux + CONFIG_ARMV7M_TOOLCHAIN_GNU_EABI=y : Generic EABI toolchain for Linux 3. The default console is UART4 diff --git a/boards/arm/stm32l4/stm32l4r9ai-disco/configs/knsh/Make.defs b/boards/arm/stm32l4/stm32l4r9ai-disco/configs/knsh/Make.defs index 6ceb65b9dbaa3..19cc22a2bed84 100644 --- a/boards/arm/stm32l4/stm32l4r9ai-disco/configs/knsh/Make.defs +++ b/boards/arm/stm32l4/stm32l4r9ai-disco/configs/knsh/Make.defs @@ -28,16 +28,6 @@ LDSCRIPT2 = kernel-space.ld ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT1) ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT2) -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new -fno-rtti ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 @@ -53,10 +43,5 @@ NXFLATLDFLAGS1 = -r -d -warn-common NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-pcrel.ld -no-check-sections LDNXFLATFLAGS = -e main -s 2048 -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - LDFLAGS += -g -endif - -#LDFLAGS += -Map=$(TOPDIR)/nuttx.map #CFLAGS += -Wa,-adhln #CXXFLAGS += -Wa,-adhln diff --git a/boards/arm/stm32l4/stm32l4r9ai-disco/include/nsh_romfsimg.h b/boards/arm/stm32l4/stm32l4r9ai-disco/include/nsh_romfsimg.h index 6bf0d908f08c0..edb2dc8a56721 100644 --- a/boards/arm/stm32l4/stm32l4r9ai-disco/include/nsh_romfsimg.h +++ b/boards/arm/stm32l4/stm32l4r9ai-disco/include/nsh_romfsimg.h @@ -1,3 +1,23 @@ +/*************************************************************************** + * boards/arm/stm32l4/stm32l4r9ai-disco/include/nsh_romfsimg.h + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ***************************************************************************/ + unsigned char romfs_img[] = { 0x2d, 0x72, 0x6f, 0x6d, 0x31, 0x66, 0x73, 0x2d, 0x00, 0x00, 0x01, 0x80, 0x42, 0x56, 0x48, 0x93, 0x4e, 0x53, 0x48, 0x49, 0x6e, 0x69, 0x74, 0x56, diff --git a/boards/arm/stm32l4/stm32l4r9ai-disco/include/rc.sysinit.template b/boards/arm/stm32l4/stm32l4r9ai-disco/include/rc.sysinit.template new file mode 100644 index 0000000000000..acbbe6da1ef6a --- /dev/null +++ b/boards/arm/stm32l4/stm32l4r9ai-disco/include/rc.sysinit.template @@ -0,0 +1,2 @@ +# sample rc.sysinit file; you must run tools/genromfs from within this +# location to convert this file to nsh_romfsimg.h for inclusion in the build diff --git a/boards/arm/stm32l4/stm32l4r9ai-disco/scripts/Make.defs b/boards/arm/stm32l4/stm32l4r9ai-disco/scripts/Make.defs index 0fbea74ddae50..a97063eb1267f 100644 --- a/boards/arm/stm32l4/stm32l4r9ai-disco/scripts/Make.defs +++ b/boards/arm/stm32l4/stm32l4r9ai-disco/scripts/Make.defs @@ -23,19 +23,8 @@ include $(TOPDIR)/tools/Config.mk include $(TOPDIR)/arch/arm/src/armv7-m/Toolchain.defs LDSCRIPT = stm32l4r9ai-disco.ld - ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT) -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new -fno-rtti ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 @@ -51,10 +40,5 @@ NXFLATLDFLAGS1 = -r -d -warn-common NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-pcrel.ld -no-check-sections LDNXFLATFLAGS = -e main -s 2048 -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - LDFLAGS += -g -endif - -LDFLAGS += -Map=$(TOPDIR)/nuttx.map #CFLAGS += -Wa,-adhln #CXXFLAGS += -Wa,-adhln diff --git a/boards/arm/stm32l5/nucleo-l552ze/README.txt b/boards/arm/stm32l5/nucleo-l552ze/README.txt index e5c7f9ee9ed45..b2df324f81c48 100644 --- a/boards/arm/stm32l5/nucleo-l552ze/README.txt +++ b/boards/arm/stm32l5/nucleo-l552ze/README.txt @@ -202,7 +202,7 @@ Configurations CONFIG_HOST_LINUX=y : Linux environment System Type -> Toolchain: - CONFIG_ARMV8M_TOOLCHAIN_GNU_EABIL=y : GNU ARM EABI toolchain + CONFIG_ARMV8M_TOOLCHAIN_GNU_EABI=y : GNU ARM EABI toolchain Configuration sub-directories ----------------------------- diff --git a/boards/arm/stm32l5/nucleo-l552ze/scripts/Make.defs b/boards/arm/stm32l5/nucleo-l552ze/scripts/Make.defs index d79d8a7fd7624..f4972c389eb50 100644 --- a/boards/arm/stm32l5/nucleo-l552ze/scripts/Make.defs +++ b/boards/arm/stm32l5/nucleo-l552ze/scripts/Make.defs @@ -24,28 +24,13 @@ include ${TOPDIR}/arch/arm/src/armv8-m/Toolchain.defs ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)flash.ld -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - -# enable precise stack overflow tracking -ifeq ($(CONFIG_ARMV8M_STACKCHECK),y) - INSTRUMENTATIONDEFINES = -finstrument-functions -ffixed-r10 -endif - -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 -CFLAGS := $(ARCHCFLAGS) $(ARCHWARNINGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) $(INSTRUMENTATIONDEFINES) -pipe +CFLAGS := $(ARCHCFLAGS) $(ARCHWARNINGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) -pipe CPICFLAGS = $(ARCHPICFLAGS) $(CFLAGS) -CXXFLAGS := $(ARCHCXXFLAGS) $(ARCHWARNINGSXX) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHXXINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) $(INSTRUMENTATIONDEFINES) -pipe +CXXFLAGS := $(ARCHCXXFLAGS) $(ARCHWARNINGSXX) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHXXINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) -pipe CXXPICFLAGS = $(ARCHPICFLAGS) $(CXXFLAGS) CPPFLAGS := $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) AFLAGS := $(CFLAGS) -D__ASSEMBLY__ @@ -53,7 +38,3 @@ AFLAGS := $(CFLAGS) -D__ASSEMBLY__ NXFLATLDFLAGS1 = -r -d -warn-common NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)$(DELIM)binfmt$(DELIM)libnxflat$(DELIM)gnu-nxflat-pcrel.ld -no-check-sections LDNXFLATFLAGS = -e main -s 2048 - -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - LDFLAGS += -g -endif diff --git a/boards/arm/stm32l5/nucleo-l552ze/src/stm32_boot.c b/boards/arm/stm32l5/nucleo-l552ze/src/stm32_boot.c index 5197c89083794..4efde9a0171d0 100644 --- a/boards/arm/stm32l5/nucleo-l552ze/src/stm32_boot.c +++ b/boards/arm/stm32l5/nucleo-l552ze/src/stm32_boot.c @@ -76,6 +76,6 @@ void board_late_initialize(void) { /* Perform board-specific initialization here if so configured */ - (void)stm32_bringup(); + stm32_bringup(); } #endif diff --git a/boards/arm/stm32l5/stm32l562e-dk/README.txt b/boards/arm/stm32l5/stm32l562e-dk/README.txt index ad1e2c7c01162..2b0065f0e0337 100644 --- a/boards/arm/stm32l5/stm32l562e-dk/README.txt +++ b/boards/arm/stm32l5/stm32l562e-dk/README.txt @@ -235,7 +235,7 @@ Configurations CONFIG_HOST_LINUX=y : Linux environment System Type -> Toolchain: - CONFIG_ARMV8M_TOOLCHAIN_GNU_EABIL=y : GNU ARM EABI toolchain + CONFIG_ARMV8M_TOOLCHAIN_GNU_EABI=y : GNU ARM EABI toolchain Configuration sub-directories ----------------------------- diff --git a/boards/arm/stm32l5/stm32l562e-dk/scripts/Make.defs b/boards/arm/stm32l5/stm32l562e-dk/scripts/Make.defs index b348d046788c2..e19dbc41d2396 100644 --- a/boards/arm/stm32l5/stm32l562e-dk/scripts/Make.defs +++ b/boards/arm/stm32l5/stm32l562e-dk/scripts/Make.defs @@ -24,28 +24,13 @@ include ${TOPDIR}/arch/arm/src/armv8-m/Toolchain.defs ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)tfm-ns.ld -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - -# enable precise stack overflow tracking -ifeq ($(CONFIG_ARMV8M_STACKCHECK),y) - INSTRUMENTATIONDEFINES = -finstrument-functions -ffixed-r10 -endif - -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 -CFLAGS := $(ARCHCFLAGS) $(ARCHWARNINGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) $(INSTRUMENTATIONDEFINES) -pipe +CFLAGS := $(ARCHCFLAGS) $(ARCHWARNINGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) -pipe CPICFLAGS = $(ARCHPICFLAGS) $(CFLAGS) -CXXFLAGS := $(ARCHCXXFLAGS) $(ARCHWARNINGSXX) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHXXINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) $(INSTRUMENTATIONDEFINES) -pipe +CXXFLAGS := $(ARCHCXXFLAGS) $(ARCHWARNINGSXX) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHXXINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) -pipe CXXPICFLAGS = $(ARCHPICFLAGS) $(CXXFLAGS) CPPFLAGS := $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) AFLAGS := $(CFLAGS) -D__ASSEMBLY__ @@ -53,7 +38,3 @@ AFLAGS := $(CFLAGS) -D__ASSEMBLY__ NXFLATLDFLAGS1 = -r -d -warn-common NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)$(DELIM)binfmt$(DELIM)libnxflat$(DELIM)gnu-nxflat-pcrel.ld -no-check-sections LDNXFLATFLAGS = -e main -s 2048 - -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - LDFLAGS += -g -endif diff --git a/boards/arm/stm32l5/stm32l562e-dk/src/stm32_boot.c b/boards/arm/stm32l5/stm32l562e-dk/src/stm32_boot.c index 14c71f414dea1..d9cf8c820e7ff 100644 --- a/boards/arm/stm32l5/stm32l562e-dk/src/stm32_boot.c +++ b/boards/arm/stm32l5/stm32l562e-dk/src/stm32_boot.c @@ -85,6 +85,6 @@ void board_late_initialize(void) { /* Perform board-specific initialization here if so configured */ - (void)stm32_bringup(); + stm32_bringup(); } #endif diff --git a/boards/arm/stm32u5/b-u585i-iot02a/README.txt b/boards/arm/stm32u5/b-u585i-iot02a/README.txt index 8a3765951f5e5..d6d220e8c2864 100644 --- a/boards/arm/stm32u5/b-u585i-iot02a/README.txt +++ b/boards/arm/stm32u5/b-u585i-iot02a/README.txt @@ -5,10 +5,6 @@ B-U585I-IOT02A README B-U585I-IOT02A board. That board features the STM32U585AII6QU MCU with 2MiB of Flash and 768KiB of SRAM. - This port is a proof-of-concept to demonstrate running NuttX in the Non- - Secure TrustZone domain as a companion to TrustedFirmware-M (TFM). Running - NuttX on the B-U585I-IOT02A without TFM is currently not supported. - Contents ======== @@ -23,6 +19,9 @@ Status basic NSH configuration works with Apache NuttX as the OS running in the non-secure world. + 2022-04-03: The dependency on TrustedFirmware-M was dropped. I.e. the + b-u585i-iot02a:nsh configuration now runs standalone. + Clock Source ============ @@ -131,7 +130,7 @@ Configurations CONFIG_HOST_LINUX=y : Linux environment System Type -> Toolchain: - CONFIG_ARMV8M_TOOLCHAIN_GNU_EABIL=y : GNU ARM EABI toolchain + CONFIG_ARMV8M_TOOLCHAIN_GNU_EABI=y : GNU ARM EABI toolchain Configuration sub-directories ----------------------------- diff --git a/boards/arm/stm32u5/b-u585i-iot02a/configs/nsh/defconfig b/boards/arm/stm32u5/b-u585i-iot02a/configs/nsh/defconfig index 7a6f93ff28b8e..500885637a1e8 100644 --- a/boards/arm/stm32u5/b-u585i-iot02a/configs/nsh/defconfig +++ b/boards/arm/stm32u5/b-u585i-iot02a/configs/nsh/defconfig @@ -5,21 +5,19 @@ # You can then do "make savedefconfig" to generate a new defconfig file that includes your # modifications. # +# CONFIG_ARCH_LEDS is not set # CONFIG_NSH_ARGCAT is not set # CONFIG_NSH_CMDPARMS is not set # CONFIG_STANDARD_SERIAL is not set CONFIG_ARCH="arm" CONFIG_ARCH_BOARD="b-u585i-iot02a" CONFIG_ARCH_BOARD_B_U585I_IOT02A=y -CONFIG_ARCH_BOARD_STM32U5_CUSTOM_CLOCKCONFIG=y CONFIG_ARCH_CHIP="stm32u5" CONFIG_ARCH_CHIP_STM32U585AI=y CONFIG_ARCH_CHIP_STM32U5=y CONFIG_ARCH_INTERRUPTSTACK=2048 CONFIG_ARCH_STACKDUMP=y CONFIG_ARCH_TRUSTZONE_NONSECURE=y -CONFIG_ARMV8M_LAZYFPU=y -CONFIG_ARMV8M_TOOLCHAIN_BUILDROOT=y CONFIG_ARMV8M_USEBASEPRI=y CONFIG_BOARD_LOOPSPERMSEC=4230 CONFIG_BUILTIN=y diff --git a/boards/arm/stm32u5/b-u585i-iot02a/include/board.h b/boards/arm/stm32u5/b-u585i-iot02a/include/board.h index 81a6972498449..3882eb0b48364 100644 --- a/boards/arm/stm32u5/b-u585i-iot02a/include/board.h +++ b/boards/arm/stm32u5/b-u585i-iot02a/include/board.h @@ -43,14 +43,14 @@ * * System Clock source : PLL (MSIS) * SYSCLK(Hz) : 160000000 Determined by PLL configuration - * HCLK(Hz) : 160000000 (STM32_RCC_CFGR_HPRE) (Max 160MHz) - * AHB Prescaler : 1 (STM32_RCC_CFGR_HPRE) (Max 160MHz) - * APB1 Prescaler : 1 (STM32_RCC_CFGR_PPRE1) (Max 160MHz) - * APB2 Prescaler : 1 (STM32_RCC_CFGR_PPRE2) (Max 160MHz) - * APB3 Prescaler : 1 (STM32_RCC_CFGR_PPRE2) (Max 160MHz) + * HCLK(Hz) : 160000000 + * AHB Prescaler : 1 (STM32_RCC_CFGR2_HPRE) (160MHz) + * APB1 Prescaler : 1 (STM32_RCC_CFGR2_PPRE1) (160MHz) + * APB2 Prescaler : 1 (STM32_RCC_CFGR2_PPRE2) (160MHz) + * APB3 Prescaler : 1 (STM32_RCC_CFGR3_PPRE3) (160MHz) * MSIS Frequency(Hz) : 4000000 (nominal) * MSIK Frequency(Hz) : 4000000 (nominal) - * PLL_MBOOST : 1 + * PLL_MBOOST : 1 (Embedded power distribution booster) * PLLM : 1 (STM32_PLLCFG_PLLM) * PLLN : 80 (STM32_PLLCFG_PLLN) * PLLP : 2 (STM32_PLLCFG_PLLP) @@ -70,63 +70,35 @@ #define STM32_LSI_FREQUENCY 32000 #define STM32_LSE_FREQUENCY 32768 -#define STM32_BOARD_USEMSI 1 -#define STM32_BOARD_MSIRANGE RCC_CR_MSIRANGE_4M +#define STM32_BOARD_USEMSIS 1 +#define STM32_BOARD_MSISRANGE RCC_ICSCR1_MSISRANGE_4MHZ +#define STM32_BOARD_MSIKRANGE RCC_ICSCR1_MSIKRANGE_4MHZ -/* prescaler common to all PLL inputs */ +/* PLL1 config; we use this to generate our system clock */ -#define STM32_PLLCFG_PLLM RCC_PLLCFG_PLLM(1) - -/* 'main' PLL config; we use this to generate our system clock */ - -#define STM32_PLLCFG_PLLN RCC_PLLCFG_PLLN(55) -#define STM32_PLLCFG_PLLP 0 -#undef STM32_PLLCFG_PLLP_ENABLED -#define STM32_PLLCFG_PLLQ 0 -#undef STM32_PLLCFG_PLLQ_ENABLED -#define STM32_PLLCFG_PLLR RCC_PLLCFG_PLLR_2 -#define STM32_PLLCFG_PLLR_ENABLED - -/* 'SAIPLL1' is not used in this application */ - -#define STM32_PLLSAI1CFG_PLLN RCC_PLLSAI1CFG_PLLN(24) -#define STM32_PLLSAI1CFG_PLLP 0 -#undef STM32_PLLSAI1CFG_PLLP_ENABLED -#define STM32_PLLSAI1CFG_PLLQ 0 -#undef STM32_PLLSAI1CFG_PLLQ_ENABLED -#define STM32_PLLSAI1CFG_PLLR 0 -#undef STM32_PLLSAI1CFG_PLLR_ENABLED - -/* 'SAIPLL2' is not used in this application */ - -#define STM32_PLLSAI2CFG_PLLN RCC_PLLSAI2CFG_PLLN(8) -#define STM32_PLLSAI2CFG_PLLP 0 -#undef STM32_PLLSAI2CFG_PLLP_ENABLED -#define STM32_PLLSAI2CFG_PLLR 0 -#undef STM32_PLLSAI2CFG_PLLR_ENABLED +#define STM32_RCC_PLL1CFGR_PLL1M RCC_PLL1CFGR_PLL1M(1) +#define STM32_RCC_PLL1DIVR_PLL1N RCC_PLL1DIVR_PLL1N(80) +#define STM32_RCC_PLL1DIVR_PLL1P 0 +#undef STM32_RCC_PLL1CFGR_PLL1P_ENABLED +#define STM32_RCC_PLL1DIVR_PLL1Q 0 +#undef STM32_RCC_PLL1CFGR_PLL1Q_ENABLED +#define STM32_RCC_PLL1DIVR_PLL1R RCC_PLL1DIVR_PLL1R(2) +#define STM32_RCC_PLL1CFGR_PLL1R_ENABLED #define STM32_SYSCLK_FREQUENCY 160000000ul -/* Enable CLK48; get it from HSI48 */ - -#if defined(CONFIG_STM32U5_USBFS) || defined(CONFIG_STM32U5_RNG) -# define STM32_USE_CLK48 1 -# define STM32_CLK48_SEL RCC_CCIPR_CLK48SEL_HSI48 -# define STM32_HSI48_SYNCSRC SYNCSRC_NONE -#endif - -/* Enable LSE (for the RTC and for MSI autotrimming) */ +/* Enable LSE (for the RTC and for MSIS autotrimming) */ #define STM32_USE_LSE 1 /* Configure the HCLK divisor (for the AHB bus, core, memory, and DMA */ -#define STM32_RCC_CFGR_HPRE RCC_CFGR_HPRE_SYSCLK /* HCLK = SYSCLK / 1 */ +#define STM32_RCC_CFGR2_HPRE RCC_CFGR2_HPRE_SYSCLK /* HCLK = SYSCLK / 1 */ #define STM32_HCLK_FREQUENCY STM32_SYSCLK_FREQUENCY /* Configure the APB1 prescaler */ -#define STM32_RCC_CFGR_PPRE1 RCC_CFGR_PPRE1_HCLK /* PCLK1 = HCLK / 1 */ +#define STM32_RCC_CFGR2_PPRE1 RCC_CFGR2_PPRE1_HCLK /* PCLK1 = HCLK / 1 */ #define STM32_PCLK1_FREQUENCY (STM32_HCLK_FREQUENCY / 1) #define STM32_APB1_TIM2_CLKIN (STM32_PCLK1_FREQUENCY) @@ -138,13 +110,18 @@ /* Configure the APB2 prescaler */ -#define STM32_RCC_CFGR_PPRE2 RCC_CFGR_PPRE2_HCLK /* PCLK2 = HCLK / 1 */ +#define STM32_RCC_CFGR2_PPRE2 RCC_CFGR2_PPRE2_HCLK /* PCLK2 = HCLK / 1 */ #define STM32_PCLK2_FREQUENCY (STM32_HCLK_FREQUENCY / 1) #define STM32_APB2_TIM1_CLKIN (STM32_PCLK2_FREQUENCY) #define STM32_APB2_TIM15_CLKIN (STM32_PCLK2_FREQUENCY) #define STM32_APB2_TIM16_CLKIN (STM32_PCLK2_FREQUENCY) +/* Configure the APB3 prescaler */ + +#define STM32_RCC_CFGR3_PPRE3 RCC_CFGR3_PPRE3_HCLK /* PCLK3 = HCLK / 1 */ +#define STM32_PCLK3_FREQUENCY (STM32_HCLK_FREQUENCY / 1) + /* The timer clock frequencies are automatically defined by hardware. If the * APB prescaler equals 1, the timer clock frequencies are set to the same * frequency as that of the APB domain. Otherwise they are set to twice. diff --git a/boards/arm/stm32u5/b-u585i-iot02a/scripts/Make.defs b/boards/arm/stm32u5/b-u585i-iot02a/scripts/Make.defs index 3d9e158a78c68..748f2114e7b31 100644 --- a/boards/arm/stm32u5/b-u585i-iot02a/scripts/Make.defs +++ b/boards/arm/stm32u5/b-u585i-iot02a/scripts/Make.defs @@ -22,30 +22,15 @@ include ${TOPDIR}/.config include ${TOPDIR}/tools/Config.mk include ${TOPDIR}/arch/arm/src/armv8-m/Toolchain.defs -ARCHSCRIPT = $(BOARD_DIR)$(DELIM)scripts$(DELIM)tfm-ns.ld +ARCHSCRIPT = $(BOARD_DIR)$(DELIM)scripts$(DELIM)flash.ld -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -fno-strength-reduce -fomit-frame-pointer -endif - -# enable precise stack overflow tracking -ifeq ($(CONFIG_ARMV8M_STACKCHECK),y) - INSTRUMENTATIONDEFINES = -finstrument-functions -ffixed-r10 -endif - -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 -CFLAGS := $(ARCHCFLAGS) $(ARCHWARNINGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) $(INSTRUMENTATIONDEFINES) -pipe +CFLAGS := $(ARCHCFLAGS) $(ARCHWARNINGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) -pipe CPICFLAGS = $(ARCHPICFLAGS) $(CFLAGS) -CXXFLAGS := $(ARCHCXXFLAGS) $(ARCHWARNINGSXX) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHXXINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) $(INSTRUMENTATIONDEFINES) -pipe +CXXFLAGS := $(ARCHCXXFLAGS) $(ARCHWARNINGSXX) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHXXINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) -pipe CXXPICFLAGS = $(ARCHPICFLAGS) $(CXXFLAGS) CPPFLAGS := $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) AFLAGS := $(CFLAGS) -D__ASSEMBLY__ @@ -53,7 +38,3 @@ AFLAGS := $(CFLAGS) -D__ASSEMBLY__ NXFLATLDFLAGS1 = -r -d -warn-common NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)$(DELIM)binfmt$(DELIM)libnxflat$(DELIM)gnu-nxflat-pcrel.ld -no-check-sections LDNXFLATFLAGS = -e main -s 2048 - -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - LDFLAGS += -g -endif diff --git a/boards/arm/stm32u5/b-u585i-iot02a/scripts/flash.ld b/boards/arm/stm32u5/b-u585i-iot02a/scripts/flash.ld new file mode 100644 index 0000000000000..a211bc4f4b0fe --- /dev/null +++ b/boards/arm/stm32u5/b-u585i-iot02a/scripts/flash.ld @@ -0,0 +1,103 @@ +/**************************************************************************** + * boards/arm/stm32u5/b-u585i-iot02a/scripts/flash.ld + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +/* The STM32Uxx has 2 MiB of FLASH beginning at address 0x0800:0000 and + * 192 KiB of SRAM beginning at address 0x2000:0000. When booting from + * FLASH, FLASH memory is aliased to address 0x0000:0000 where the code + * expects to begin execution by jumping to the entry point in the + * 0x0800:0000 address range. + */ + +MEMORY +{ + flash (rx) : ORIGIN = 0x08000000, LENGTH = 2048K + sram (rwx) : ORIGIN = 0x20000000, LENGTH = 192K +} + +OUTPUT_ARCH(arm) +ENTRY(_stext) +SECTIONS +{ + .text : { + _stext = ABSOLUTE(.); + *(.vectors) + *(.text .text.*) + *(.fixup) + *(.gnu.warning) + *(.rodata .rodata.*) + *(.gnu.linkonce.t.*) + *(.glue_7) + *(.glue_7t) + *(.got) + *(.gcc_except_table) + *(.gnu.linkonce.r.*) + _etext = ABSOLUTE(.); + } > flash + + .init_section : { + _sinit = ABSOLUTE(.); + *(.init_array .init_array.*) + _einit = ABSOLUTE(.); + } > flash + + .ARM.extab : { + *(.ARM.extab*) + } > flash + + __exidx_start = ABSOLUTE(.); + .ARM.exidx : { + *(.ARM.exidx*) + } > flash + __exidx_end = ABSOLUTE(.); + + _eronly = ABSOLUTE(.); + + .data : { + _sdata = ABSOLUTE(.); + *(.data .data.*) + *(.gnu.linkonce.d.*) + CONSTRUCTORS + . = ALIGN(4); + _edata = ABSOLUTE(.); + } > sram AT > flash + + .bss : { + _sbss = ABSOLUTE(.); + *(.bss .bss.*) + *(.gnu.linkonce.b.*) + *(COMMON) + . = ALIGN(4); + _ebss = ABSOLUTE(.); + } > sram + + /* Stabs debugging sections. */ + .stab 0 : { *(.stab) } + .stabstr 0 : { *(.stabstr) } + .stab.excl 0 : { *(.stab.excl) } + .stab.exclstr 0 : { *(.stab.exclstr) } + .stab.index 0 : { *(.stab.index) } + .stab.indexstr 0 : { *(.stab.indexstr) } + .comment 0 : { *(.comment) } + .debug_abbrev 0 : { *(.debug_abbrev) } + .debug_info 0 : { *(.debug_info) } + .debug_line 0 : { *(.debug_line) } + .debug_pubnames 0 : { *(.debug_pubnames) } + .debug_aranges 0 : { *(.debug_aranges) } +} diff --git a/boards/arm/stm32u5/b-u585i-iot02a/src/stm32_boot.c b/boards/arm/stm32u5/b-u585i-iot02a/src/stm32_boot.c index 71b7e5a074ea7..57655ee758cf1 100644 --- a/boards/arm/stm32u5/b-u585i-iot02a/src/stm32_boot.c +++ b/boards/arm/stm32u5/b-u585i-iot02a/src/stm32_boot.c @@ -76,6 +76,6 @@ void board_late_initialize(void) { /* Perform board-specific initialization here if so configured */ - (void)stm32_bringup(); + stm32_bringup(); } #endif diff --git a/boards/arm/str71x/olimex-strp711/scripts/Make.defs b/boards/arm/str71x/olimex-strp711/scripts/Make.defs index 65bc6e506468a..7ad509b633bd0 100644 --- a/boards/arm/str71x/olimex-strp711/scripts/Make.defs +++ b/boards/arm/str71x/olimex-strp711/scripts/Make.defs @@ -45,18 +45,12 @@ ifeq ("${CONFIG_DEBUG_FEATURES}","y") ARCHOPTIMIZATION = -g endif -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - ifeq ($(OLDGCC),n) ARCHCPUFLAGS = -mcpu=arm7tdmi -mfloat-abi=soft else ARCHCPUFLAGS = -mapcs-32 -mcpu=arm7tdmi -msoft-float endif -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef diff --git a/boards/arm/tiva/dk-tm4c129x/README.txt b/boards/arm/tiva/dk-tm4c129x/README.txt index b94d670d01d9c..34b4a926a93bf 100644 --- a/boards/arm/tiva/dk-tm4c129x/README.txt +++ b/boards/arm/tiva/dk-tm4c129x/README.txt @@ -673,7 +673,7 @@ Where is one of the following: CONFIG_HOST_WINDOWS=y : Windows :CONFIG_WINDOWS_CYGWIN=y : Cygwin under Windows - CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIW=y : GNU EABI toolchain for Windows + CONFIG_ARMV7M_TOOLCHAIN_GNU_EABI=y : GNU EABI toolchain for Windows CONFIG_RAW_BINARY=y : Output formats: ELF and raw binary 3. Default stack sizes are large and should really be tuned to reduce diff --git a/boards/arm/tiva/dk-tm4c129x/scripts/Make.defs b/boards/arm/tiva/dk-tm4c129x/scripts/Make.defs index 131536419e03b..dd6e062edb22e 100644 --- a/boards/arm/tiva/dk-tm4c129x/scripts/Make.defs +++ b/boards/arm/tiva/dk-tm4c129x/scripts/Make.defs @@ -24,16 +24,6 @@ include $(TOPDIR)/arch/arm/src/armv7-m/Toolchain.defs ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)ld.script -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 @@ -48,7 +38,3 @@ AFLAGS := $(CFLAGS) -D__ASSEMBLY__ NXFLATLDFLAGS1 = -r -d -warn-common NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-pcrel.ld -no-check-sections LDNXFLATFLAGS = -e main -s 2048 - -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - LDFLAGS += -g -endif diff --git a/boards/arm/tiva/eagle100/README.txt b/boards/arm/tiva/eagle100/README.txt index b10774b587f75..afd5c767a4ff3 100644 --- a/boards/arm/tiva/eagle100/README.txt +++ b/boards/arm/tiva/eagle100/README.txt @@ -215,7 +215,7 @@ Configuration Sub-Directories CONFIG_HOST_WINDOWS=y CONFIG_WINDOWS_CYGWIN=y - CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIW=y + CONFIG_ARMV7M_TOOLCHAIN_GNU_EABI=y httpd: This builds the uIP web server example using the examples/webserver application @@ -228,8 +228,7 @@ Configuration Sub-Directories CONFIG_HOST_WINDOWS=y CONFIG_WINDOWS_CYGWIN=y - CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIW=y - CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIW=y + CONFIG_ARMV7M_TOOLCHAIN_GNU_EABI=y This example can only be built using the buildroot toolchain with NXFLAT support diff --git a/boards/arm/tiva/eagle100/scripts/Make.defs b/boards/arm/tiva/eagle100/scripts/Make.defs index de6c1e7f44cd6..f002df91c5550 100644 --- a/boards/arm/tiva/eagle100/scripts/Make.defs +++ b/boards/arm/tiva/eagle100/scripts/Make.defs @@ -24,16 +24,6 @@ include $(TOPDIR)/arch/arm/src/armv7-m/Toolchain.defs ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)ld.script -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 @@ -51,7 +41,3 @@ LDNXFLAT = ldnxflat NXFLATLDFLAGS1 = -r -d -warn-common NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-pcrel.ld -no-check-sections LDNXFLATFLAGS = -e main -s 2048 - -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - LDFLAGS += -g -endif diff --git a/boards/arm/tiva/ekk-lm3s9b96/scripts/Make.defs b/boards/arm/tiva/ekk-lm3s9b96/scripts/Make.defs index 8e436d8eebe45..92f25105824b5 100644 --- a/boards/arm/tiva/ekk-lm3s9b96/scripts/Make.defs +++ b/boards/arm/tiva/ekk-lm3s9b96/scripts/Make.defs @@ -24,16 +24,6 @@ include $(TOPDIR)/arch/arm/src/armv7-m/Toolchain.defs ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)ekk-lm3s9b96.ld -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 @@ -48,7 +38,3 @@ AFLAGS := $(CFLAGS) -D__ASSEMBLY__ NXFLATLDFLAGS1 = -r -d -warn-common NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-pcrel.ld -no-check-sections LDNXFLATFLAGS = -e main -s 2048 - -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - LDFLAGS += -g -endif diff --git a/boards/arm/tiva/launchxl-cc1310/scripts/Make.defs b/boards/arm/tiva/launchxl-cc1310/scripts/Make.defs index 3c4aaa16b25fc..37bdc8688be47 100644 --- a/boards/arm/tiva/launchxl-cc1310/scripts/Make.defs +++ b/boards/arm/tiva/launchxl-cc1310/scripts/Make.defs @@ -23,20 +23,9 @@ include $(TOPDIR)/tools/Config.mk include $(TOPDIR)/arch/arm/src/armv7-m/Toolchain.defs LDSCRIPT = flash.ld - ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT) -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -endif - -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new -fno-rtti -ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef -fno-strict-aliasing +ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 @@ -57,7 +46,3 @@ CMODULEFLAGS = $(CFLAGS) -mlong-calls # --target1-abs LDMODULEFLAGS = -r -e module_initialize LDMODULEFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)/libs/libc/modlib/gnu-elf.ld) - -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - LDFLAGS += -g -endif diff --git a/boards/arm/tiva/launchxl-cc1312r1/configs/nsh/defconfig b/boards/arm/tiva/launchxl-cc1312r1/configs/nsh/defconfig index 445bec41fb988..b87a526d1f37f 100644 --- a/boards/arm/tiva/launchxl-cc1312r1/configs/nsh/defconfig +++ b/boards/arm/tiva/launchxl-cc1312r1/configs/nsh/defconfig @@ -17,7 +17,6 @@ CONFIG_ARCH_CHIP_SIMPLELINK=y CONFIG_ARCH_INTERRUPTSTACK=2048 CONFIG_ARCH_IRQBUTTONS=y CONFIG_ARCH_STACKDUMP=y -CONFIG_ARMV7M_LAZYFPU=y CONFIG_ARMV7M_USEBASEPRI=y CONFIG_BOARD_LOOPSPERMSEC=8192 CONFIG_BUILTIN=y diff --git a/boards/arm/tiva/launchxl-cc1312r1/scripts/Make.defs b/boards/arm/tiva/launchxl-cc1312r1/scripts/Make.defs index dc87a4bd19116..9e7bacf8d022c 100644 --- a/boards/arm/tiva/launchxl-cc1312r1/scripts/Make.defs +++ b/boards/arm/tiva/launchxl-cc1312r1/scripts/Make.defs @@ -30,17 +30,7 @@ endif ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT) -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -endif - -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new -fno-rtti -ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef -fno-strict-aliasing +ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 @@ -61,7 +51,3 @@ CMODULEFLAGS = $(CFLAGS) -mlong-calls # --target1-abs LDMODULEFLAGS = -r -e module_initialize LDMODULEFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)/libs/libc/modlib/gnu-elf.ld) - -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - LDFLAGS += -g -endif diff --git a/boards/arm/tiva/lm3s6432-s2e/scripts/Make.defs b/boards/arm/tiva/lm3s6432-s2e/scripts/Make.defs index ce0af29ddffbc..e3a095b1cce56 100644 --- a/boards/arm/tiva/lm3s6432-s2e/scripts/Make.defs +++ b/boards/arm/tiva/lm3s6432-s2e/scripts/Make.defs @@ -24,16 +24,6 @@ include $(TOPDIR)/arch/arm/src/armv7-m/Toolchain.defs ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)lm3s6432-s2e.ld -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 @@ -48,7 +38,3 @@ AFLAGS := $(CFLAGS) -D__ASSEMBLY__ NXFLATLDFLAGS1 = -r -d -warn-common NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-pcrel.ld -no-check-sections LDNXFLATFLAGS = -e main -s 2048 - -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - LDFLAGS += -g -endif diff --git a/boards/arm/tiva/lm3s6965-ek/README.txt b/boards/arm/tiva/lm3s6965-ek/README.txt index 3b680ead72b2a..b16b42e95962a 100644 --- a/boards/arm/tiva/lm3s6965-ek/README.txt +++ b/boards/arm/tiva/lm3s6965-ek/README.txt @@ -468,7 +468,7 @@ Where is one of the following: 2. Default platform/toolchain: CONFIG_HOST_LINUX=y : Linux - CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIL=y : GNU EABI toolchain for Linux + CONFIG_ARMV7M_TOOLCHAIN_GNU_EABI=y : GNU EABI toolchain for Linux CONFIG_RAW_BINARY=y : Output formats: ELF and raw binary 3. As it is configured now, you MUST have a network connected. diff --git a/boards/arm/tiva/lm3s6965-ek/scripts/Make.defs b/boards/arm/tiva/lm3s6965-ek/scripts/Make.defs index ed34c1c4c2e6e..5df736fb0792b 100644 --- a/boards/arm/tiva/lm3s6965-ek/scripts/Make.defs +++ b/boards/arm/tiva/lm3s6965-ek/scripts/Make.defs @@ -24,16 +24,6 @@ include $(TOPDIR)/arch/arm/src/armv7-m/Toolchain.defs ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)ld.script -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 @@ -73,8 +63,4 @@ CELFFLAGS = $(CFLAGS) -mlong-calls CXXELFFLAGS = $(CXXFLAGS) -mlong-calls LDELFFLAGS = -r -e main -LDELFFLAGS += -T $(call CONVERT_PATH,$(BOARD_DIR)$(DELIM)scripts$(DELIM)gnu-elf.ld) - -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - LDFLAGS += -g -endif +LDELFFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)/binfmt/libelf/gnu-elf.ld) diff --git a/boards/arm/tiva/lm3s6965-ek/scripts/gnu-elf.ld b/boards/arm/tiva/lm3s6965-ek/scripts/gnu-elf.ld deleted file mode 100644 index cbf5a9814b4dd..0000000000000 --- a/boards/arm/tiva/lm3s6965-ek/scripts/gnu-elf.ld +++ /dev/null @@ -1,126 +0,0 @@ -/**************************************************************************** - * boards/arm/tiva/lm3s6965-ek/scripts/gnu-elf.ld - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. The - * ASF licenses this file to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance with the - * License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - ****************************************************************************/ - -SECTIONS -{ - .text 0x00000000 : - { - _stext = . ; - *(.text) - *(.text.*) - *(.gnu.warning) - *(.stub) - *(.glue_7) - *(.glue_7t) - *(.jcr) - - /* C++ support: The .init and .fini sections contain specific logic - * to manage static constructors and destructors. - */ - - *(.gnu.linkonce.t.*) - *(.init) /* Old ABI */ - *(.fini) /* Old ABI */ - _etext = . ; - } - - .ARM.extab : - { - *(.ARM.extab*) - } - - .ARM.exidx : - { - *(.ARM.exidx*) - } - - .rodata : - { - _srodata = . ; - *(.rodata) - *(.rodata1) - *(.rodata.*) - *(.gnu.linkonce.r*) - _erodata = . ; - } - - .data : - { - _sdata = . ; - *(.data) - *(.data1) - *(.data.*) - *(.gnu.linkonce.d*) - . = ALIGN(4); - _edata = . ; - } - - /* C++ support. For each global and static local C++ object, - * GCC creates a small subroutine to construct the object. Pointers - * to these routines (not the routines themselves) are stored as - * simple, linear arrays in the .ctors section of the object file. - * Similarly, pointers to global/static destructor routines are - * stored in .dtors. - */ - - .ctors : - { - _sctors = . ; - *(.ctors) /* Old ABI: Unallocated */ - *(.init_array) /* New ABI: Allocated */ - _edtors = . ; - } - - .dtors : - { - _sdtors = . ; - *(.dtors) /* Old ABI: Unallocated */ - *(.fini_array) /* New ABI: Allocated */ - _edtors = . ; - } - - .bss : - { - _sbss = . ; - *(.bss) - *(.bss.*) - *(.sbss) - *(.sbss.*) - *(.gnu.linkonce.b*) - *(COMMON) - . = ALIGN(4); - _ebss = . ; - } - - /* Stabs debugging sections. */ - - .stab 0 : { *(.stab) } - .stabstr 0 : { *(.stabstr) } - .stab.excl 0 : { *(.stab.excl) } - .stab.exclstr 0 : { *(.stab.exclstr) } - .stab.index 0 : { *(.stab.index) } - .stab.indexstr 0 : { *(.stab.indexstr) } - .comment 0 : { *(.comment) } - .debug_abbrev 0 : { *(.debug_abbrev) } - .debug_info 0 : { *(.debug_info) } - .debug_line 0 : { *(.debug_line) } - .debug_pubnames 0 : { *(.debug_pubnames) } - .debug_aranges 0 : { *(.debug_aranges) } -} diff --git a/boards/arm/tiva/lm3s8962-ek/scripts/Make.defs b/boards/arm/tiva/lm3s8962-ek/scripts/Make.defs index 223d280ee1edb..7d3b5dc61dc7c 100644 --- a/boards/arm/tiva/lm3s8962-ek/scripts/Make.defs +++ b/boards/arm/tiva/lm3s8962-ek/scripts/Make.defs @@ -24,16 +24,6 @@ include $(TOPDIR)/arch/arm/src/armv7-m/Toolchain.defs ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)ld.script -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 @@ -48,7 +38,3 @@ AFLAGS := $(CFLAGS) -D__ASSEMBLY__ NXFLATLDFLAGS1 = -r -d -warn-common NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-pcrel.ld -no-check-sections LDNXFLATFLAGS = -e main -s 2048 - -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - LDFLAGS += -g -endif diff --git a/boards/arm/tiva/lm4f120-launchpad/scripts/Make.defs b/boards/arm/tiva/lm4f120-launchpad/scripts/Make.defs index dc7af0aa77510..6239e69e2e478 100644 --- a/boards/arm/tiva/lm4f120-launchpad/scripts/Make.defs +++ b/boards/arm/tiva/lm4f120-launchpad/scripts/Make.defs @@ -24,16 +24,6 @@ include $(TOPDIR)/arch/arm/src/armv7-m/Toolchain.defs ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)lm4f120-launchpad.ld -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 @@ -48,7 +38,3 @@ AFLAGS := $(CFLAGS) -D__ASSEMBLY__ NXFLATLDFLAGS1 = -r -d -warn-common NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-pcrel.ld -no-check-sections LDNXFLATFLAGS = -e main -s 2048 - -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - LDFLAGS += -g -endif diff --git a/boards/arm/tiva/tm4c123g-launchpad/scripts/Make.defs b/boards/arm/tiva/tm4c123g-launchpad/scripts/Make.defs index 9a4ca24d79003..067e362aeed15 100644 --- a/boards/arm/tiva/tm4c123g-launchpad/scripts/Make.defs +++ b/boards/arm/tiva/tm4c123g-launchpad/scripts/Make.defs @@ -24,16 +24,6 @@ include $(TOPDIR)/arch/arm/src/armv7-m/Toolchain.defs ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)tm4c123g-launchpad.ld -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 @@ -48,7 +38,3 @@ AFLAGS := $(CFLAGS) -D__ASSEMBLY__ NXFLATLDFLAGS1 = -r -d -warn-common NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-pcrel.ld -no-check-sections LDNXFLATFLAGS = -e main -s 2048 - -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - LDFLAGS += -g -endif diff --git a/boards/arm/tiva/tm4c1294-launchpad/scripts/Make.defs b/boards/arm/tiva/tm4c1294-launchpad/scripts/Make.defs index 3babbfc447425..ab356b9dccf27 100644 --- a/boards/arm/tiva/tm4c1294-launchpad/scripts/Make.defs +++ b/boards/arm/tiva/tm4c1294-launchpad/scripts/Make.defs @@ -24,16 +24,6 @@ include $(TOPDIR)/arch/arm/src/armv7-m/Toolchain.defs ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)ld.script -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 @@ -48,7 +38,3 @@ AFLAGS := $(CFLAGS) -D__ASSEMBLY__ NXFLATLDFLAGS1 = -r -d -warn-common NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-pcrel.ld -no-check-sections LDNXFLATFLAGS = -e main -s 2048 - -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - LDFLAGS += -g -endif diff --git a/boards/arm/tms570/launchxl-tms57004/README.txt b/boards/arm/tms570/launchxl-tms57004/README.txt index 79fdf2970fe2d..179f8f1382e64 100644 --- a/boards/arm/tms570/launchxl-tms57004/README.txt +++ b/boards/arm/tms570/launchxl-tms57004/README.txt @@ -83,7 +83,7 @@ Toolchain CONFIG_WINDOWS_CYGWIN=y : Cywin under Windows System Type -> Toolchain: - CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIW=y : GNU ARM EABI toolchain + CONFIG_ARMV7M_TOOLCHAIN_GNU_EABI=y : GNU ARM EABI toolchain LEDs and Buttons ================ @@ -211,7 +211,7 @@ Configurations CONFIG_WINDOWS_CYGWIN=y : Cywin under Windows System Type -> Toolchain: - CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIW=y : GNU ARM EABI toolchain + CONFIG_ARMV7M_TOOLCHAIN_GNU_EABI=y : GNU ARM EABI toolchain Configuration sub-directories ----------------------------- diff --git a/boards/arm/tms570/launchxl-tms57004/scripts/Make.defs b/boards/arm/tms570/launchxl-tms57004/scripts/Make.defs index ff7b6d61a4e1b..e75a77ca8bf2b 100644 --- a/boards/arm/tms570/launchxl-tms57004/scripts/Make.defs +++ b/boards/arm/tms570/launchxl-tms57004/scripts/Make.defs @@ -23,20 +23,9 @@ include $(TOPDIR)/tools/Config.mk include $(TOPDIR)/arch/arm/src/armv7-r/Toolchain.defs LDSCRIPT = flash-sram.ld - ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT) -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - ARCHCPUFLAGS = -mcpu=cortex-r4 -mbig-endian -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new -fno-rtti ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 @@ -60,8 +49,4 @@ CELFFLAGS = $(CFLAGS) -mlong-calls # --target1-abs CXXELFFLAGS = $(CXXFLAGS) -mlong-calls # --target1-abs LDELFFLAGS = -r -e main -LDELFFLAGS += -T $(call CONVERT_PATH,$(BOARD_DIR)$(DELIM)scripts$(DELIM)gnu-elf.ld) - -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - LDFLAGS += -g -endif +LDELFFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)/binfmt/libelf/gnu-elf.ld) diff --git a/boards/arm/tms570/tms570ls31x-usb-kit/scripts/Make.defs b/boards/arm/tms570/tms570ls31x-usb-kit/scripts/Make.defs index 74f926203a488..364ff23c7a92d 100644 --- a/boards/arm/tms570/tms570ls31x-usb-kit/scripts/Make.defs +++ b/boards/arm/tms570/tms570ls31x-usb-kit/scripts/Make.defs @@ -23,19 +23,8 @@ include $(TOPDIR)/tools/Config.mk include $(TOPDIR)/arch/arm/src/armv7-r/Toolchain.defs LDSCRIPT = flash-sram.ld - ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT) -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new -fno-rtti ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 @@ -59,8 +48,4 @@ CELFFLAGS = $(CFLAGS) -mlong-calls # --target1-abs CXXELFFLAGS = $(CXXFLAGS) -mlong-calls # --target1-abs LDELFFLAGS = -r -e main -LDELFFLAGS += -T $(call CONVERT_PATH,$(BOARD_DIR)$(DELIM)scripts$(DELIM)gnu-elf.ld) - -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - LDFLAGS += -g -endif +LDELFFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)/binfmt/libelf/gnu-elf.ld) diff --git a/boards/arm/xmc4/xmc4500-relax/README.txt b/boards/arm/xmc4/xmc4500-relax/README.txt index 9db54a70beb99..f1c15a583a418 100644 --- a/boards/arm/xmc4/xmc4500-relax/README.txt +++ b/boards/arm/xmc4/xmc4500-relax/README.txt @@ -141,7 +141,7 @@ Configurations CONFIG_WINDOWS_CYGWIN=y : Cywin under Windows System Type -> Toolchain: - CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIW=y : GNU ARM EABI toolchain + CONFIG_ARMV7M_TOOLCHAIN_GNU_EABI=y : GNU ARM EABI toolchain Configuration sub-directories ----------------------------- diff --git a/boards/arm/xmc4/xmc4500-relax/configs/nsh/defconfig b/boards/arm/xmc4/xmc4500-relax/configs/nsh/defconfig index 7597a3f2b789f..df4306cdf6bf7 100644 --- a/boards/arm/xmc4/xmc4500-relax/configs/nsh/defconfig +++ b/boards/arm/xmc4/xmc4500-relax/configs/nsh/defconfig @@ -18,7 +18,6 @@ CONFIG_ARCH_CHIP_XMC4=y CONFIG_ARCH_INTERRUPTSTACK=2048 CONFIG_ARCH_IRQBUTTONS=y CONFIG_ARCH_STACKDUMP=y -CONFIG_ARMV7M_LAZYFPU=y CONFIG_AT24XX_ADDR=0x57 CONFIG_AT24XX_EXTENDED=y CONFIG_AT24XX_EXTSIZE=160 diff --git a/boards/arm/xmc4/xmc4500-relax/scripts/Make.defs b/boards/arm/xmc4/xmc4500-relax/scripts/Make.defs index 345d18e58123a..9e63a47ee4063 100644 --- a/boards/arm/xmc4/xmc4500-relax/scripts/Make.defs +++ b/boards/arm/xmc4/xmc4500-relax/scripts/Make.defs @@ -23,20 +23,9 @@ include $(TOPDIR)/tools/Config.mk include $(TOPDIR)/arch/arm/src/armv7-m/Toolchain.defs LDSCRIPT = flash.ld - ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT) -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -endif - -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new -fno-rtti -ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef -fno-strict-aliasing +ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 @@ -57,7 +46,3 @@ CMODULEFLAGS = $(CFLAGS) -mlong-calls # --target1-abs LDMODULEFLAGS = -r -e module_initialize LDMODULEFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)/libs/libc/modlib/gnu-elf.ld) - -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - LDFLAGS += -g -endif diff --git a/boards/arm/xmc4/xmc4500-relax/src/Makefile b/boards/arm/xmc4/xmc4500-relax/src/Makefile index 463afc99a6ee7..05d500d715a45 100644 --- a/boards/arm/xmc4/xmc4500-relax/src/Makefile +++ b/boards/arm/xmc4/xmc4500-relax/src/Makefile @@ -44,8 +44,4 @@ ifeq ($(CONFIG_BOARDCTL),y) CSRCS += xmc4_appinit.c endif -ifeq ($(CONFIG_TESTING_OSTEST),y) -CSRCS += xmc4_ostest.c -endif - include $(TOPDIR)/boards/Board.mk diff --git a/boards/arm/xmc4/xmc4500-relax/src/xmc4_ostest.c b/boards/arm/xmc4/xmc4500-relax/src/xmc4_ostest.c deleted file mode 100644 index f3e566c9b9952..0000000000000 --- a/boards/arm/xmc4/xmc4500-relax/src/xmc4_ostest.c +++ /dev/null @@ -1,94 +0,0 @@ -/**************************************************************************** - * boards/arm/xmc4/xmc4500-relax/src/xmc4_ostest.c - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. The - * ASF licenses this file to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance with the - * License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - ****************************************************************************/ - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include - -#include -#include -#include -#include - -#include -#include - -#include "arm_internal.h" -#include "xmc4500-relax.h" - -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -/* Configuration ************************************************************/ - -#undef HAVE_FPU -#if defined(CONFIG_ARCH_FPU) && !defined(CONFIG_TESTING_OSTEST_FPUTESTDISABLE) && \ - defined(CONFIG_TESTING_OSTEST_FPUSIZE) && defined(CONFIG_SCHED_WAITPID) -# define HAVE_FPU 1 -#endif - -#ifdef HAVE_FPU - -#if CONFIG_TESTING_OSTEST_FPUSIZE != (4*SW_FPU_REGS) -# error "CONFIG_TESTING_OSTEST_FPUSIZE has the wrong size" -#endif - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -static uint32_t g_saveregs[XCPTCONTEXT_REGS]; - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/* Given an array of size CONFIG_TESTING_OSTEST_FPUSIZE, this function will - * return the current FPU registers. - */ - -void arch_getfpu(FAR uint32_t *fpusave) -{ - irqstate_t flags; - - /* Take a snapshot of the thread context right now */ - - flags = enter_critical_section(); - arm_saveusercontext(g_saveregs); - - /* Return only the floating register values */ - - memcpy(fpusave, &g_saveregs[REG_S0], (4*SW_FPU_REGS)); - leave_critical_section(flags); -} - -/* Given two arrays of size CONFIG_TESTING_OSTEST_FPUSIZE this function - * will compare them and return true if they are identical. - */ - -bool arch_cmpfpu(FAR const uint32_t *fpusave1, FAR const uint32_t *fpusave2) -{ - return memcmp(fpusave1, fpusave2, (4*SW_FPU_REGS)) == 0; -} - -#endif /* HAVE_FPU */ diff --git a/boards/arm/xmc4/xmc4700-relax/configs/nsh/defconfig b/boards/arm/xmc4/xmc4700-relax/configs/nsh/defconfig index 0e666f42f26f3..4d37e9a730fed 100644 --- a/boards/arm/xmc4/xmc4700-relax/configs/nsh/defconfig +++ b/boards/arm/xmc4/xmc4700-relax/configs/nsh/defconfig @@ -16,7 +16,6 @@ CONFIG_ARCH_CHIP_XMC4=y CONFIG_ARCH_INTERRUPTSTACK=2048 CONFIG_ARCH_IRQBUTTONS=y CONFIG_ARCH_STACKDUMP=y -CONFIG_ARMV7M_LAZYFPU=y CONFIG_BOARD_LOOPSPERMSEC=8000 CONFIG_BUILTIN=y CONFIG_DEBUG_NOOPT=y diff --git a/boards/arm/xmc4/xmc4700-relax/scripts/Make.defs b/boards/arm/xmc4/xmc4700-relax/scripts/Make.defs index e8a2750b58ae7..e42a9a1dc6dae 100644 --- a/boards/arm/xmc4/xmc4700-relax/scripts/Make.defs +++ b/boards/arm/xmc4/xmc4700-relax/scripts/Make.defs @@ -23,20 +23,9 @@ include $(TOPDIR)/tools/Config.mk include $(TOPDIR)/arch/arm/src/armv7-m/Toolchain.defs LDSCRIPT = flash.ld - ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT) -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -endif - -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new -fno-rtti -ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef -fno-strict-aliasing +ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 @@ -57,7 +46,3 @@ CMODULEFLAGS = $(CFLAGS) -mlong-calls # --target1-abs LDMODULEFLAGS = -r -e module_initialize LDMODULEFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)/libs/libc/modlib/gnu-elf.ld) - -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - LDFLAGS += -g -endif diff --git a/boards/arm/xmc4/xmc4700-relax/src/Makefile b/boards/arm/xmc4/xmc4700-relax/src/Makefile index 38ec1525a3dcc..ea8d4fb4af532 100644 --- a/boards/arm/xmc4/xmc4700-relax/src/Makefile +++ b/boards/arm/xmc4/xmc4700-relax/src/Makefile @@ -36,8 +36,4 @@ ifeq ($(CONFIG_BOARDCTL),y) CSRCS += xmc4_appinit.c endif -ifeq ($(CONFIG_TESTING_OSTEST),y) -CSRCS += xmc4_ostest.c -endif - include $(TOPDIR)/boards/Board.mk diff --git a/boards/arm/xmc4/xmc4700-relax/src/xmc4_ostest.c b/boards/arm/xmc4/xmc4700-relax/src/xmc4_ostest.c deleted file mode 100644 index ef3f59bc4eeb8..0000000000000 --- a/boards/arm/xmc4/xmc4700-relax/src/xmc4_ostest.c +++ /dev/null @@ -1,94 +0,0 @@ -/**************************************************************************** - * boards/arm/xmc4/xmc4700-relax/src/xmc4_ostest.c - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. The - * ASF licenses this file to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance with the - * License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - ****************************************************************************/ - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include - -#include -#include -#include -#include - -#include -#include - -#include "arm_internal.h" -#include "xmc4700-relax.h" - -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -/* Configuration ************************************************************/ - -#undef HAVE_FPU -#if defined(CONFIG_ARCH_FPU) && !defined(CONFIG_TESTING_OSTEST_FPUTESTDISABLE) && \ - defined(CONFIG_TESTING_OSTEST_FPUSIZE) && defined(CONFIG_SCHED_WAITPID) -# define HAVE_FPU 1 -#endif - -#ifdef HAVE_FPU - -#if CONFIG_TESTING_OSTEST_FPUSIZE != (4*SW_FPU_REGS) -# error "CONFIG_TESTING_OSTEST_FPUSIZE has the wrong size" -#endif - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -static uint32_t g_saveregs[XCPTCONTEXT_REGS]; - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/* Given an array of size CONFIG_TESTING_OSTEST_FPUSIZE, this function will - * return the current FPU registers. - */ - -void arch_getfpu(FAR uint32_t *fpusave) -{ - irqstate_t flags; - - /* Take a snapshot of the thread context right now */ - - flags = enter_critical_section(); - arm_saveusercontext(g_saveregs); - - /* Return only the floating register values */ - - memcpy(fpusave, &g_saveregs[REG_S0], (4*SW_FPU_REGS)); - leave_critical_section(flags); -} - -/* Given two arrays of size CONFIG_TESTING_OSTEST_FPUSIZE this function - * will compare them and return true if they are identical. - */ - -bool arch_cmpfpu(FAR const uint32_t *fpusave1, FAR const uint32_t *fpusave2) -{ - return memcmp(fpusave1, fpusave2, (4*SW_FPU_REGS)) == 0; -} - -#endif /* HAVE_FPU */ diff --git a/boards/avr/at32uc3/avr32dev1/scripts/Make.defs b/boards/avr/at32uc3/avr32dev1/scripts/Make.defs index 932946bda2fcb..b0e56e54ee6bf 100644 --- a/boards/avr/at32uc3/avr32dev1/scripts/Make.defs +++ b/boards/avr/at32uc3/avr32dev1/scripts/Make.defs @@ -24,16 +24,7 @@ include $(TOPDIR)/arch/avr/src/avr32/Toolchain.defs ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)avr32dev1.ld -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -ffunction-sections -fdata-sections -fno-strict-aliasing -endif - -ARCHCFLAGS = -fno-common -muse-rodata-section -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new +ARCHCFLAGS = -muse-rodata-section ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHNOPICFLAGS = -fno-pic @@ -47,7 +38,3 @@ CXXFLAGS := $(ARCHNOPICFLAGS) $(ARCHALLCXXFLAGS) CXXPICFLAGS = $(ARCHPICFLAGS) $(ARCHALLCXXFLAGS) CPPFLAGS := $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) AFLAGS := $(ARCHALLCFLAGS) -D__ASSEMBLY__ - -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - LDFLAGS += -g -endif diff --git a/boards/avr/at90usb/micropendous3/scripts/Make.defs b/boards/avr/at90usb/micropendous3/scripts/Make.defs index e6ad87264e1f4..cf766964b4d43 100644 --- a/boards/avr/at90usb/micropendous3/scripts/Make.defs +++ b/boards/avr/at90usb/micropendous3/scripts/Make.defs @@ -24,16 +24,6 @@ include $(TOPDIR)/arch/avr/src/avr/Toolchain.defs ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)micropendous3.ld -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -fomit-frame-pointer -endif - -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef diff --git a/boards/avr/at90usb/teensy-2.0/scripts/Make.defs b/boards/avr/at90usb/teensy-2.0/scripts/Make.defs index d99390f0b567c..f42850c406cd4 100644 --- a/boards/avr/at90usb/teensy-2.0/scripts/Make.defs +++ b/boards/avr/at90usb/teensy-2.0/scripts/Make.defs @@ -23,19 +23,8 @@ include $(TOPDIR)/tools/Config.mk include $(TOPDIR)/arch/avr/src/avr/Toolchain.defs LDSCRIPT = flash.ld - ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT) -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -fomit-frame-pointer -endif - -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef diff --git a/boards/avr/atmega/amber/scripts/Make.defs b/boards/avr/atmega/amber/scripts/Make.defs index 327c6788c7985..4573658b9036d 100644 --- a/boards/avr/atmega/amber/scripts/Make.defs +++ b/boards/avr/atmega/amber/scripts/Make.defs @@ -24,16 +24,6 @@ include $(TOPDIR)/arch/avr/src/avr/Toolchain.defs ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)amber.ld -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -fomit-frame-pointer -endif - -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef diff --git a/boards/avr/atmega/amber/scripts/gnu-elf.ld b/boards/avr/atmega/amber/scripts/gnu-elf.ld deleted file mode 100644 index 9abb436ae153e..0000000000000 --- a/boards/avr/atmega/amber/scripts/gnu-elf.ld +++ /dev/null @@ -1,124 +0,0 @@ -/**************************************************************************** - * boards/avr/atmega/amber/scripts/gnu-elf.ld - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. The - * ASF licenses this file to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance with the - * License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - ****************************************************************************/ - -SECTIONS -{ - .text 0x00000000 : - { - _stext = . ; - *(.text) - *(.text.*) - *(.gnu.warning) - *(.stub) - *(.glue_7) - *(.glue_7t) - *(.jcr) - - /* C++ support: The .init and .fini sections contain specific logic - * to manage static constructors and destructors. - */ - - *(.gnu.linkonce.t.*) - *(.init) /* Old ABI */ - *(.fini) /* Old ABI */ - _etext = . ; - } - - .ARM.extab : - { - *(.ARM.extab*) - } - - .ARM.exidx : - { - *(.ARM.exidx*) - } - - .rodata : - { - _srodata = . ; - *(.rodata) - *(.rodata1) - *(.rodata.*) - *(.gnu.linkonce.r*) - _erodata = . ; - } - - .data : - { - _sdata = . ; - *(.data) - *(.data1) - *(.data.*) - *(.gnu.linkonce.d*) - _edata = . ; - } - - /* C++ support. For each global and static local C++ object, - * GCC creates a small subroutine to construct the object. Pointers - * to these routines (not the routines themselves) are stored as - * simple, linear arrays in the .ctors section of the object file. - * Similarly, pointers to global/static destructor routines are - * stored in .dtors. - */ - - .ctors : - { - _sctors = . ; - *(.ctors) /* Old ABI: Unallocated */ - *(.init_array) /* New ABI: Allocated */ - _edtors = . ; - } - - .dtors : - { - _sdtors = . ; - *(.dtors) /* Old ABI: Unallocated */ - *(.fini_array) /* New ABI: Allocated */ - _edtors = . ; - } - - .bss : - { - _sbss = . ; - *(.bss) - *(.bss.*) - *(.sbss) - *(.sbss.*) - *(.gnu.linkonce.b*) - *(COMMON) - _ebss = . ; - } - - /* Stabs debugging sections. */ - - .stab 0 : { *(.stab) } - .stabstr 0 : { *(.stabstr) } - .stab.excl 0 : { *(.stab.excl) } - .stab.exclstr 0 : { *(.stab.exclstr) } - .stab.index 0 : { *(.stab.index) } - .stab.indexstr 0 : { *(.stab.indexstr) } - .comment 0 : { *(.comment) } - .debug_abbrev 0 : { *(.debug_abbrev) } - .debug_info 0 : { *(.debug_info) } - .debug_line 0 : { *(.debug_line) } - .debug_pubnames 0 : { *(.debug_pubnames) } - .debug_aranges 0 : { *(.debug_aranges) } -} diff --git a/boards/avr/atmega/arduino-mega2560/scripts/Make.defs b/boards/avr/atmega/arduino-mega2560/scripts/Make.defs index 8351fbf7e61fc..1d433ffd5cae1 100644 --- a/boards/avr/atmega/arduino-mega2560/scripts/Make.defs +++ b/boards/avr/atmega/arduino-mega2560/scripts/Make.defs @@ -23,19 +23,8 @@ include $(TOPDIR)/tools/Config.mk include $(TOPDIR)/arch/avr/src/avr/Toolchain.defs LDSCRIPT = flash.ld - ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT) -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g3 -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -fomit-frame-pointer -endif - -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef diff --git a/boards/avr/atmega/moteino-mega/scripts/Make.defs b/boards/avr/atmega/moteino-mega/scripts/Make.defs index ac992b92ad1c7..c9df44a9e4fe0 100644 --- a/boards/avr/atmega/moteino-mega/scripts/Make.defs +++ b/boards/avr/atmega/moteino-mega/scripts/Make.defs @@ -24,16 +24,6 @@ include $(TOPDIR)/arch/avr/src/avr/Toolchain.defs ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)ld.script -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -fomit-frame-pointer -endif - -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef diff --git a/boards/boardctl.c b/boards/boardctl.c index 0a44c31758ebf..d01cf0467ab13 100644 --- a/boards/boardctl.c +++ b/boards/boardctl.c @@ -777,6 +777,27 @@ int boardctl(unsigned int cmd, uintptr_t arg) break; #endif +#ifdef CONFIG_BOARDCTL_RESET_CAUSE + /* CMD: BOARDIOC_RESET_CAUSE + * DESCRIPTION: Get the cause of last-time board reset + * ARG: A pointer to an instance of struct + * boardioc_reset_cause_s + * CONFIGURATION: CONFIG_BOARDCTL_RESET_CAUSE + * DEPENDENCIES: Board logic must provide the + * board_reset_cause() interface. + */ + + case BOARDIOC_RESET_CAUSE: + { + FAR struct boardioc_reset_cause_s *cause = + (FAR struct boardioc_reset_cause_s *)arg; + + DEBUGASSERT(cause != NULL); + ret = board_reset_cause(cause); + } + break; +#endif + default: { #ifdef CONFIG_BOARDCTL_IOCTL @@ -802,7 +823,7 @@ int boardctl(unsigned int cmd, uintptr_t arg) return ERROR; } - return OK; + return ret; } #endif /* CONFIG_BOARDCTL */ diff --git a/boards/hc/m9s12/demo9s12ne64/scripts/Make.defs b/boards/hc/m9s12/demo9s12ne64/scripts/Make.defs index 739dfadd75daf..d8286cecccf2a 100644 --- a/boards/hc/m9s12/demo9s12ne64/scripts/Make.defs +++ b/boards/hc/m9s12/demo9s12ne64/scripts/Make.defs @@ -25,7 +25,6 @@ include $(TOPDIR)/tools/Config.mk # NuttX buildroot under Linux or Cygwin CROSSDEV = m9s12x-nuttx-elf- -MAXOPTIMIZATION = -Os ifeq ($(CONFIG_HCS12_NONBANKED),y) ARCHCPUFLAGS = -m9s12x -mshort -mnolong-calls @@ -46,7 +45,7 @@ ifeq ($(CONFIG_DEBUG_SYMBOLS),y) endif ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -fomit-frame-pointer + ARCHOPTIMIZATION += -Os -fno-strict-aliasing -fomit-frame-pointer endif ARCHCFLAGS = -fno-common diff --git a/boards/hc/m9s12/ne64badge/scripts/Make.defs b/boards/hc/m9s12/ne64badge/scripts/Make.defs index fcd2fcb30816f..0b077b6337a8a 100644 --- a/boards/hc/m9s12/ne64badge/scripts/Make.defs +++ b/boards/hc/m9s12/ne64badge/scripts/Make.defs @@ -25,7 +25,6 @@ include $(TOPDIR)/tools/Config.mk # NuttX buildroot under Linux or Cygwin CROSSDEV = m9s12x-nuttx-elf- -MAXOPTIMIZATION = -Os ifeq ($(CONFIG_HCS12_NONBANKED),y) ARCHCPUFLAGS = -m9s12x -mshort -mnolong-calls @@ -46,7 +45,7 @@ ifeq ($(CONFIG_DEBUG_SYMBOLS),y) endif ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -fomit-frame-pointer + ARCHOPTIMIZATION += -Os -fno-strict-aliasing -fomit-frame-pointer endif ARCHCFLAGS = -fno-common diff --git a/boards/mips/pic32mx/mirtoo/README.txt b/boards/mips/pic32mx/mirtoo/README.txt index dce54b47e1ebd..44d8c67f78434 100644 --- a/boards/mips/pic32mx/mirtoo/README.txt +++ b/boards/mips/pic32mx/mirtoo/README.txt @@ -583,7 +583,7 @@ Analog Input #include #include - FAR struct spi_dev_s *spi; + struct spi_dev_s *spi; PGA11X_HANDLE handle; /* Get the SPI port */ diff --git a/boards/mips/pic32mx/mirtoo/scripts/Make.defs b/boards/mips/pic32mx/mirtoo/scripts/Make.defs index 61336276ac6c6..ff890a5db4f5b 100644 --- a/boards/mips/pic32mx/mirtoo/scripts/Make.defs +++ b/boards/mips/pic32mx/mirtoo/scripts/Make.defs @@ -25,16 +25,6 @@ include $(TOPDIR)/arch/mips/src/mips32/Toolchain.defs ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT) -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef diff --git a/boards/mips/pic32mx/mirtoo/src/pic32_appinit.c b/boards/mips/pic32mx/mirtoo/src/pic32_appinit.c index 54c7dabca827e..9d69fab569b0f 100644 --- a/boards/mips/pic32mx/mirtoo/src/pic32_appinit.c +++ b/boards/mips/pic32mx/mirtoo/src/pic32_appinit.c @@ -101,8 +101,8 @@ int board_app_initialize(uintptr_t arg) { #ifdef HAVE_SST25 - FAR struct spi_dev_s *spi; - FAR struct mtd_dev_s *mtd; + struct spi_dev_s *spi; + struct mtd_dev_s *mtd; int ret; /* Get the SPI port */ diff --git a/boards/mips/pic32mx/mirtoo/src/pic32_leds.c b/boards/mips/pic32mx/mirtoo/src/pic32_leds.c index 58e735c66aa53..3dd7773c69652 100644 --- a/boards/mips/pic32mx/mirtoo/src/pic32_leds.c +++ b/boards/mips/pic32mx/mirtoo/src/pic32_leds.c @@ -139,7 +139,7 @@ static const uint16_t g_ledpincfg[PIC32MX_MIRTOO_NLEDS] = ****************************************************************************/ #ifdef CONFIG_ARCH_LEDS -static void pic32mx_setleds(FAR const struct led_setting_s *setting) +static void pic32mx_setleds(const struct led_setting_s *setting) { /* LEDs are pulled up so writing a low value (false) illuminates them */ diff --git a/boards/mips/pic32mx/mirtoo/src/pic32_spi2.c b/boards/mips/pic32mx/mirtoo/src/pic32_spi2.c index f1b5168c5dac1..dcfc9a40b3d9e 100644 --- a/boards/mips/pic32mx/mirtoo/src/pic32_spi2.c +++ b/boards/mips/pic32mx/mirtoo/src/pic32_spi2.c @@ -146,7 +146,7 @@ void weak_function pic32mx_spi2initialize(void) struct spi_dev_s; -void pic32mx_spi2select(FAR struct spi_dev_s *dev, uint32_t devid, +void pic32mx_spi2select(struct spi_dev_s *dev, uint32_t devid, bool selected) { spiinfo("devid: %d CS: %s\n", (int)devid, @@ -162,13 +162,13 @@ void pic32mx_spi2select(FAR struct spi_dev_s *dev, uint32_t devid, } } -uint8_t pic32mx_spi2status(FAR struct spi_dev_s *dev, uint32_t devid) +uint8_t pic32mx_spi2status(struct spi_dev_s *dev, uint32_t devid) { return 0; } #ifdef CONFIG_SPI_CMDDATA -int pic32mx_spi2cmddata(FAR struct spi_dev_s *dev, uint32_t devid, bool cmd) +int pic32mx_spi2cmddata(struct spi_dev_s *dev, uint32_t devid, bool cmd) { return 0; } diff --git a/boards/mips/pic32mx/pic32mx-starterkit/scripts/Make.defs b/boards/mips/pic32mx/pic32mx-starterkit/scripts/Make.defs index bd98939af1b21..11295e7b7671e 100644 --- a/boards/mips/pic32mx/pic32mx-starterkit/scripts/Make.defs +++ b/boards/mips/pic32mx/pic32mx-starterkit/scripts/Make.defs @@ -41,16 +41,6 @@ endif ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT) -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef diff --git a/boards/mips/pic32mx/pic32mx-starterkit/src/pic32mx_appinit.c b/boards/mips/pic32mx/pic32mx-starterkit/src/pic32mx_appinit.c index 43068ff902eb4..7d5dcdf0c1e9b 100644 --- a/boards/mips/pic32mx/pic32mx-starterkit/src/pic32mx_appinit.c +++ b/boards/mips/pic32mx/pic32mx-starterkit/src/pic32mx_appinit.c @@ -206,7 +206,7 @@ static int nsh_waiter(int argc, char *argv[]) #ifdef NSH_HAVEMMCSD static int nsh_sdinitialize(void) { - FAR struct spi_dev_s *spi; + struct spi_dev_s *spi; int ret; /* Get the SPI port */ @@ -302,7 +302,7 @@ static int nsh_usbhostinitialize(void) ret = kthread_create("usbhost", CONFIG_USBHOST_DEFPRIO, CONFIG_USBHOST_STACKSIZE, - (main_t)nsh_waiter, (FAR char * const *)NULL); + (main_t)nsh_waiter, (char * const *)NULL); return ret < 0 ? -ENOEXEC : OK; } diff --git a/boards/mips/pic32mx/pic32mx-starterkit/src/pic32mx_leds.c b/boards/mips/pic32mx/pic32mx-starterkit/src/pic32mx_leds.c index fc98670665bb2..3d2fe7a980af9 100644 --- a/boards/mips/pic32mx/pic32mx-starterkit/src/pic32mx_leds.c +++ b/boards/mips/pic32mx/pic32mx-starterkit/src/pic32mx_leds.c @@ -144,7 +144,7 @@ static const uint16_t g_ledpincfg[PIC32MX_STARTERKIT_NLEDS] = ****************************************************************************/ #ifdef CONFIG_ARCH_LEDS -static void pic32mx_setleds(FAR const struct led_setting_s *setting) +static void pic32mx_setleds(const struct led_setting_s *setting) { if (setting->led1 != LED_NC) { diff --git a/boards/mips/pic32mx/pic32mx-starterkit/src/pic32mx_spi.c b/boards/mips/pic32mx/pic32mx-starterkit/src/pic32mx_spi.c index bb698365896b7..ec5bbd38737ea 100644 --- a/boards/mips/pic32mx/pic32mx-starterkit/src/pic32mx_spi.c +++ b/boards/mips/pic32mx/pic32mx-starterkit/src/pic32mx_spi.c @@ -93,7 +93,7 @@ void weak_function pic32mx_spidev_initialize(void) struct spi_dev_s; #ifdef CONFIG_PIC32MX_SPI1 -void pic32mx_spi1select(FAR struct spi_dev_s *dev, uint32_t devid, +void pic32mx_spi1select(struct spi_dev_s *dev, uint32_t devid, bool selected) { spiinfo("devid: %d CS: %s\n", @@ -101,7 +101,7 @@ void pic32mx_spi1select(FAR struct spi_dev_s *dev, uint32_t devid, #warning "Missing logic" } -uint8_t pic32mx_spi1status(FAR struct spi_dev_s *dev, uint32_t devid) +uint8_t pic32mx_spi1status(struct spi_dev_s *dev, uint32_t devid) { spiinfo("Returning nothing\n"); #warning "Missing logic" @@ -109,7 +109,7 @@ uint8_t pic32mx_spi1status(FAR struct spi_dev_s *dev, uint32_t devid) } #ifdef CONFIG_SPI_CMDDATA -int pic32mx_spi1cmddata(FAR struct spi_dev_s *dev, +int pic32mx_spi1cmddata(struct spi_dev_s *dev, uint32_t devid, bool cmd) { #warning "Missing logic" @@ -119,7 +119,7 @@ int pic32mx_spi1cmddata(FAR struct spi_dev_s *dev, #endif #ifdef CONFIG_PIC32MX_SPI1 -void pic32mx_spi1select(FAR struct spi_dev_s *dev, uint32_t devid, +void pic32mx_spi1select(struct spi_dev_s *dev, uint32_t devid, bool selected) { spiinfo("devid: %d CS: %s\n", (int)devid, @@ -127,7 +127,7 @@ void pic32mx_spi1select(FAR struct spi_dev_s *dev, uint32_t devid, #warning "Missing logic" } -uint8_t pic32mx_spi1status(FAR struct spi_dev_s *dev, uint32_t devid) +uint8_t pic32mx_spi1status(struct spi_dev_s *dev, uint32_t devid) { spiinfo("Returning nothing\n"); #warning "Missing logic" @@ -135,7 +135,7 @@ uint8_t pic32mx_spi1status(FAR struct spi_dev_s *dev, uint32_t devid) } #ifdef CONFIG_SPI_CMDDATA -int pic32mx_spi1cmddata(FAR struct spi_dev_s *dev, uint32_t devid, bool cmd) +int pic32mx_spi1cmddata(struct spi_dev_s *dev, uint32_t devid, bool cmd) { #warning "Missing logic" return 0; @@ -144,7 +144,7 @@ int pic32mx_spi1cmddata(FAR struct spi_dev_s *dev, uint32_t devid, bool cmd) #endif #ifdef CONFIG_PIC32MX_SPI3 -void pic32mx_spi3select(FAR struct spi_dev_s *dev, uint32_t devid, +void pic32mx_spi3select(struct spi_dev_s *dev, uint32_t devid, bool selected) { spiinfo("devid: %d CS: %s\n", (int)devid, @@ -152,7 +152,7 @@ void pic32mx_spi3select(FAR struct spi_dev_s *dev, uint32_t devid, #warning "Missing logic" } -uint8_t pic32mx_spi3status(FAR struct spi_dev_s *dev, uint32_t devid) +uint8_t pic32mx_spi3status(struct spi_dev_s *dev, uint32_t devid) { spiinfo("Returning nothing\n"); #warning "Missing logic" @@ -160,7 +160,7 @@ uint8_t pic32mx_spi3status(FAR struct spi_dev_s *dev, uint32_t devid) } #ifdef CONFIG_SPI_CMDDATA -int pic32mx_spi3cmddata(FAR struct spi_dev_s *dev, uint32_t devid, bool cmd) +int pic32mx_spi3cmddata(struct spi_dev_s *dev, uint32_t devid, bool cmd) { #warning "Missing logic" return 0; @@ -169,7 +169,7 @@ int pic32mx_spi3cmddata(FAR struct spi_dev_s *dev, uint32_t devid, bool cmd) #endif #ifdef CONFIG_PIC32MX_SPI4 -void pic32mx_spi4select(FAR struct spi_dev_s *dev, uint32_t devid, +void pic32mx_spi4select(struct spi_dev_s *dev, uint32_t devid, bool selected) { spiinfo("devid: %d CS: %s\n", (int)devid, @@ -177,7 +177,7 @@ void pic32mx_spi4select(FAR struct spi_dev_s *dev, uint32_t devid, #warning "Missing logic" } -uint8_t pic32mx_spi4status(FAR struct spi_dev_s *dev, uint32_t devid) +uint8_t pic32mx_spi4status(struct spi_dev_s *dev, uint32_t devid) { spiinfo("Returning nothing\n"); #warning "Missing logic" @@ -185,7 +185,7 @@ uint8_t pic32mx_spi4status(FAR struct spi_dev_s *dev, uint32_t devid) } #ifdef CONFIG_SPI_CMDDATA -int pic32mx_spi4cmddata(FAR struct spi_dev_s *dev, uint32_t devid, bool cmd) +int pic32mx_spi4cmddata(struct spi_dev_s *dev, uint32_t devid, bool cmd) { #warning "Missing logic" return 0; diff --git a/boards/mips/pic32mx/pic32mx-starterkit/src/pic32mx_usbdev.c b/boards/mips/pic32mx/pic32mx-starterkit/src/pic32mx_usbdev.c index bee932198a1c2..91bc9544f254c 100644 --- a/boards/mips/pic32mx/pic32mx-starterkit/src/pic32mx_usbdev.c +++ b/boards/mips/pic32mx/pic32mx-starterkit/src/pic32mx_usbdev.c @@ -130,7 +130,7 @@ void weak_function pic32mx_usbdevinitialize(void) * ****************************************************************************/ -int pic32mx_usbpullup(FAR struct usbdev_s *dev, bool enable) +int pic32mx_usbpullup(struct usbdev_s *dev, bool enable) { /* The PIC32 Ethernet Starter Kit does not have a USB pull-up */ @@ -148,7 +148,7 @@ int pic32mx_usbpullup(FAR struct usbdev_s *dev, bool enable) * ****************************************************************************/ -void pic32mx_usbsuspend(FAR struct usbdev_s *dev, bool resume) +void pic32mx_usbsuspend(struct usbdev_s *dev, bool resume) { /* Do nothing */ } diff --git a/boards/mips/pic32mx/pic32mx7mmb/scripts/Make.defs b/boards/mips/pic32mx/pic32mx7mmb/scripts/Make.defs index 0873924cfa147..aecfd5fa9ed74 100644 --- a/boards/mips/pic32mx/pic32mx7mmb/scripts/Make.defs +++ b/boards/mips/pic32mx/pic32mx7mmb/scripts/Make.defs @@ -41,16 +41,6 @@ endif ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT) -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef diff --git a/boards/mips/pic32mx/pic32mx7mmb/src/pic32_bringup.c b/boards/mips/pic32mx/pic32mx7mmb/src/pic32_bringup.c index 7ed6ac7b8a9a3..024a04bea596a 100644 --- a/boards/mips/pic32mx/pic32mx7mmb/src/pic32_bringup.c +++ b/boards/mips/pic32mx/pic32mx7mmb/src/pic32_bringup.c @@ -208,7 +208,7 @@ static int nsh_waiter(int argc, char *argv[]) #ifdef NSH_HAVEMMCSD static int nsh_sdinitialize(void) { - FAR struct spi_dev_s *spi; + struct spi_dev_s *spi; int ret; /* Get the SPI port */ @@ -315,7 +315,7 @@ static int nsh_usbhostinitialize(void) ret = kthread_create("usbhost", CONFIG_USBHOST_DEFPRIO, CONFIG_USBHOST_STACKSIZE, - (main_t)nsh_waiter, (FAR char * const *)NULL); + (main_t)nsh_waiter, (char * const *)NULL); return ret < 0 ? -ENOEXEC : OK; } diff --git a/boards/mips/pic32mx/pic32mx7mmb/src/pic32_leds.c b/boards/mips/pic32mx/pic32mx7mmb/src/pic32_leds.c index 58a39de26f5f3..27e1136d82f7c 100644 --- a/boards/mips/pic32mx/pic32mx7mmb/src/pic32_leds.c +++ b/boards/mips/pic32mx/pic32mx7mmb/src/pic32_leds.c @@ -149,7 +149,7 @@ static const uint16_t g_ledpincfg[PIC32MX_PIC32MX7MMB_NLEDS] = ****************************************************************************/ #ifdef CONFIG_ARCH_LEDS -static void pic32mx_setleds(FAR const struct led_setting_s *setting) +static void pic32mx_setleds(const struct led_setting_s *setting) { /* LEDs are pulled up so writing a low value (false) illuminates them */ diff --git a/boards/mips/pic32mx/pic32mx7mmb/src/pic32_mio283qt2.c b/boards/mips/pic32mx/pic32mx7mmb/src/pic32_mio283qt2.c index 756d22f15c8ec..51d60a7652946 100644 --- a/boards/mips/pic32mx/pic32mx7mmb/src/pic32_mio283qt2.c +++ b/boards/mips/pic32mx/pic32mx7mmb/src/pic32_mio283qt2.c @@ -125,7 +125,7 @@ struct pic32mx7mmb_dev_s bool data; /* true=data selected */ bool selected; /* true=LCD selected */ bool reading; /* true=We are in a read sequence */ - FAR struct lcd_dev_s *drvr; /* The saved instance of the LCD driver */ + struct lcd_dev_s *drvr; /* The saved instance of the LCD driver */ }; /**************************************************************************** @@ -134,14 +134,14 @@ struct pic32mx7mmb_dev_s /* Low Level LCD access */ -static void pic32mx_select(FAR struct mio283qt2_lcd_s *dev); -static void pic32mx_deselect(FAR struct mio283qt2_lcd_s *dev); -static void pic32mx_index(FAR struct mio283qt2_lcd_s *dev, uint8_t index); +static void pic32mx_select(struct mio283qt2_lcd_s *dev); +static void pic32mx_deselect(struct mio283qt2_lcd_s *dev); +static void pic32mx_index(struct mio283qt2_lcd_s *dev, uint8_t index); #ifndef CONFIG_MIO283QT2_WRONLY -static uint16_t pic32mx_read(FAR struct mio283qt2_lcd_s *dev); +static uint16_t pic32mx_read(struct mio283qt2_lcd_s *dev); #endif -static void pic32mx_write(FAR struct mio283qt2_lcd_s *dev, uint16_t data); -static void pic32mx_backlight(FAR struct mio283qt2_lcd_s *dev, int power); +static void pic32mx_write(struct mio283qt2_lcd_s *dev, uint16_t data); +static void pic32mx_backlight(struct mio283qt2_lcd_s *dev, int power); /**************************************************************************** * Private Data @@ -177,7 +177,7 @@ static struct pic32mx7mmb_dev_s g_pic32mx7mmb_lcd = * ****************************************************************************/ -static void pic32mx_command(FAR struct pic32mx7mmb_dev_s *priv) +static void pic32mx_command(struct pic32mx7mmb_dev_s *priv) { /* Low selects command */ @@ -198,7 +198,7 @@ static void pic32mx_command(FAR struct pic32mx7mmb_dev_s *priv) * ****************************************************************************/ -static void pic32mx_data(FAR struct pic32mx7mmb_dev_s *priv) +static void pic32mx_data(struct pic32mx7mmb_dev_s *priv) { /* Hi selects data */ @@ -232,9 +232,9 @@ static void pic32mx_busywait(void) * ****************************************************************************/ -static void pic32mx_select(FAR struct mio283qt2_lcd_s *dev) +static void pic32mx_select(struct mio283qt2_lcd_s *dev) { - FAR struct pic32mx7mmb_dev_s *priv = (FAR struct pic32mx7mmb_dev_s *)dev; + struct pic32mx7mmb_dev_s *priv = (struct pic32mx7mmb_dev_s *)dev; /* CS low selects */ @@ -255,9 +255,9 @@ static void pic32mx_select(FAR struct mio283qt2_lcd_s *dev) * ****************************************************************************/ -static void pic32mx_deselect(FAR struct mio283qt2_lcd_s *dev) +static void pic32mx_deselect(struct mio283qt2_lcd_s *dev) { - FAR struct pic32mx7mmb_dev_s *priv = (FAR struct pic32mx7mmb_dev_s *)dev; + struct pic32mx7mmb_dev_s *priv = (struct pic32mx7mmb_dev_s *)dev; /* CS high de-selects */ @@ -278,9 +278,9 @@ static void pic32mx_deselect(FAR struct mio283qt2_lcd_s *dev) * ****************************************************************************/ -static void pic32mx_index(FAR struct mio283qt2_lcd_s *dev, uint8_t index) +static void pic32mx_index(struct mio283qt2_lcd_s *dev, uint8_t index) { - FAR struct pic32mx7mmb_dev_s *priv = (FAR struct pic32mx7mmb_dev_s *)dev; + struct pic32mx7mmb_dev_s *priv = (struct pic32mx7mmb_dev_s *)dev; /* Make sure that the PMP is not busy from the last transaction. * Read data is not available until the busy bit becomes zero. @@ -303,9 +303,9 @@ static void pic32mx_index(FAR struct mio283qt2_lcd_s *dev, uint8_t index) ****************************************************************************/ #ifndef CONFIG_MIO283QT2_WRONLY -static uint16_t pic32mx_read(FAR struct mio283qt2_lcd_s *dev) +static uint16_t pic32mx_read(struct mio283qt2_lcd_s *dev) { - FAR struct pic32mx7mmb_dev_s *priv = (FAR struct pic32mx7mmb_dev_s *)dev; + struct pic32mx7mmb_dev_s *priv = (struct pic32mx7mmb_dev_s *)dev; uint16_t data; /* Make sure that the PMP is not busy from the last transaction. @@ -340,9 +340,9 @@ static uint16_t pic32mx_read(FAR struct mio283qt2_lcd_s *dev) * ****************************************************************************/ -static void pic32mx_write(FAR struct mio283qt2_lcd_s *dev, uint16_t data) +static void pic32mx_write(struct mio283qt2_lcd_s *dev, uint16_t data) { - FAR struct pic32mx7mmb_dev_s *priv = (FAR struct pic32mx7mmb_dev_s *)dev; + struct pic32mx7mmb_dev_s *priv = (struct pic32mx7mmb_dev_s *)dev; /* Make sure that the PMP is not busy from the last transaction */ @@ -366,7 +366,7 @@ static void pic32mx_write(FAR struct mio283qt2_lcd_s *dev, uint16_t data) * ****************************************************************************/ -static void pic32mx_backlight(FAR struct mio283qt2_lcd_s *dev, int power) +static void pic32mx_backlight(struct mio283qt2_lcd_s *dev, int power) { /* For now, we just control the backlight as a discrete. * Pulse width modulation would be required to vary the backlight level. @@ -469,7 +469,7 @@ int board_lcd_initialize(void) * ****************************************************************************/ -FAR struct lcd_dev_s *board_lcd_getdev(int lcddev) +struct lcd_dev_s *board_lcd_getdev(int lcddev) { DEBUGASSERT(lcddev == 0); return g_pic32mx7mmb_lcd.drvr; diff --git a/boards/mips/pic32mx/pic32mx7mmb/src/pic32_spi.c b/boards/mips/pic32mx/pic32mx7mmb/src/pic32_spi.c index 520901267a4a7..ba8d4a34872d8 100644 --- a/boards/mips/pic32mx/pic32mx7mmb/src/pic32_spi.c +++ b/boards/mips/pic32mx/pic32mx7mmb/src/pic32_spi.c @@ -119,7 +119,7 @@ void weak_function pic32mx_spidev_initialize(void) struct spi_dev_s; #ifdef CONFIG_PIC32MX_SPI1 -void pic32mx_spi1select(FAR struct spi_dev_s *dev, uint32_t devid, +void pic32mx_spi1select(struct spi_dev_s *dev, uint32_t devid, bool selected) { spiinfo("devid: %d CS: %s\n", (int)devid, @@ -131,7 +131,7 @@ void pic32mx_spi1select(FAR struct spi_dev_s *dev, uint32_t devid, } } -uint8_t pic32mx_spi1status(FAR struct spi_dev_s *dev, uint32_t devid) +uint8_t pic32mx_spi1status(struct spi_dev_s *dev, uint32_t devid) { uint8_t ret = 0; @@ -157,7 +157,7 @@ uint8_t pic32mx_spi1status(FAR struct spi_dev_s *dev, uint32_t devid) } #ifdef CONFIG_SPI_CMDDATA -int pic32mx_spi1cmddata(FAR struct spi_dev_s *dev, uint32_t devid, bool cmd) +int pic32mx_spi1cmddata(struct spi_dev_s *dev, uint32_t devid, bool cmd) { #warning "Missing logic" return 0; @@ -166,7 +166,7 @@ int pic32mx_spi1cmddata(FAR struct spi_dev_s *dev, uint32_t devid, bool cmd) #endif #ifdef CONFIG_PIC32MX_SPI2 -void pic31mx_spi2select(FAR struct spi_dev_s *dev, uint32_t devid, +void pic31mx_spi2select(struct spi_dev_s *dev, uint32_t devid, bool selected) { spiinfo("devid: %d CS: %s\n", (int)devid, @@ -174,7 +174,7 @@ void pic31mx_spi2select(FAR struct spi_dev_s *dev, uint32_t devid, #warning "Missing logic" } -uint8_t pic31mx_spi2status(FAR struct spi_dev_s *dev, uint32_t devid) +uint8_t pic31mx_spi2status(struct spi_dev_s *dev, uint32_t devid) { spiinfo("Returning nothing\n"); #warning "Missing logic" @@ -182,7 +182,7 @@ uint8_t pic31mx_spi2status(FAR struct spi_dev_s *dev, uint32_t devid) } #ifdef CONFIG_SPI_CMDDATA -int pic31mx_spi2cmddata(FAR struct spi_dev_s *dev, uint32_t devid, bool cmd) +int pic31mx_spi2cmddata(struct spi_dev_s *dev, uint32_t devid, bool cmd) { #warning "Missing logic" return 0; @@ -191,7 +191,7 @@ int pic31mx_spi2cmddata(FAR struct spi_dev_s *dev, uint32_t devid, bool cmd) #endif #ifdef CONFIG_PIC32MX_SPI3 -void pic32mx_spi3select(FAR struct spi_dev_s *dev, uint32_t devid, +void pic32mx_spi3select(struct spi_dev_s *dev, uint32_t devid, bool selected) { spiinfo("devid: %d CS: %s\n", (int)devid, @@ -199,7 +199,7 @@ void pic32mx_spi3select(FAR struct spi_dev_s *dev, uint32_t devid, #warning "Missing logic" } -uint8_t pic32mx_spi3status(FAR struct spi_dev_s *dev, uint32_t devid) +uint8_t pic32mx_spi3status(struct spi_dev_s *dev, uint32_t devid) { spiinfo("Returning nothing\n"); #warning "Missing logic" @@ -207,7 +207,7 @@ uint8_t pic32mx_spi3status(FAR struct spi_dev_s *dev, uint32_t devid) } #ifdef CONFIG_SPI_CMDDATA -int pic32mx_spi3cmddata(FAR struct spi_dev_s *dev, uint32_t devid, bool cmd) +int pic32mx_spi3cmddata(struct spi_dev_s *dev, uint32_t devid, bool cmd) { #warning "Missing logic" return 0; @@ -216,7 +216,7 @@ int pic32mx_spi3cmddata(FAR struct spi_dev_s *dev, uint32_t devid, bool cmd) #endif #ifdef CONFIG_PIC32MX_SPI4 -void pic32mx_spi4select(FAR struct spi_dev_s *dev, uint32_t devid, +void pic32mx_spi4select(struct spi_dev_s *dev, uint32_t devid, bool selected) { spiinfo("devid: %d CS: %s\n", (int)devid, @@ -224,7 +224,7 @@ void pic32mx_spi4select(FAR struct spi_dev_s *dev, uint32_t devid, #warning "Missing logic" } -uint8_t pic32mx_spi4status(FAR struct spi_dev_s *dev, uint32_t devid) +uint8_t pic32mx_spi4status(struct spi_dev_s *dev, uint32_t devid) { spiinfo("Returning nothing\n"); #warning "Missing logic" @@ -232,7 +232,7 @@ uint8_t pic32mx_spi4status(FAR struct spi_dev_s *dev, uint32_t devid) } #ifdef CONFIG_SPI_CMDDATA -int pic32mx_spi4cmddata(FAR struct spi_dev_s *dev, uint32_t devid, bool cmd) +int pic32mx_spi4cmddata(struct spi_dev_s *dev, uint32_t devid, bool cmd) { #warning "Missing logic" return 0; diff --git a/boards/mips/pic32mx/pic32mx7mmb/src/pic32_touchscreen.c b/boards/mips/pic32mx/pic32mx7mmb/src/pic32_touchscreen.c index efb3a2bcd2398..d36dee946d3bd 100644 --- a/boards/mips/pic32mx/pic32mx7mmb/src/pic32_touchscreen.c +++ b/boards/mips/pic32mx/pic32mx7mmb/src/pic32_touchscreen.c @@ -218,20 +218,20 @@ static void tc_xplus_sample(void); static void tc_xminus_sample(void); static inline bool tc_valid_sample(uint16_t sample); -static void tc_notify(FAR struct tc_dev_s *priv); -static int tc_sample(FAR struct tc_dev_s *priv, - FAR struct tc_sample_s *sample); -static int tc_waitsample(FAR struct tc_dev_s *priv, - FAR struct tc_sample_s *sample); -static void tc_worker(FAR void *arg); +static void tc_notify(struct tc_dev_s *priv); +static int tc_sample(struct tc_dev_s *priv, + struct tc_sample_s *sample); +static int tc_waitsample(struct tc_dev_s *priv, + struct tc_sample_s *sample); +static void tc_worker(void *arg); /* Character driver methods */ -static int tc_open(FAR struct file *filep); -static int tc_close(FAR struct file *filep); -static ssize_t tc_read(FAR struct file *filep, FAR char *buffer, size_t len); -static int tc_ioctl(FAR struct file *filep, int cmd, unsigned long arg); -static int tc_poll(FAR struct file *filep, struct pollfd *fds, bool setup); +static int tc_open(struct file *filep); +static int tc_close(struct file *filep); +static ssize_t tc_read(struct file *filep, char *buffer, size_t len); +static int tc_ioctl(struct file *filep, int cmd, unsigned long arg); +static int tc_poll(struct file *filep, struct pollfd *fds, bool setup); /**************************************************************************** * Private Data @@ -473,7 +473,7 @@ static inline bool tc_valid_sample(uint16_t sample) * Name: tc_notify ****************************************************************************/ -static void tc_notify(FAR struct tc_dev_s *priv) +static void tc_notify(struct tc_dev_s *priv) { int i; @@ -490,7 +490,7 @@ static void tc_notify(FAR struct tc_dev_s *priv) if (fds) { fds->revents |= POLLIN; - iinfo("Report events: %02x\n", fds->revents); + iinfo("Report events: %08" PRIx32 "\n", fds->revents); nxsem_post(fds->sem); } } @@ -516,8 +516,8 @@ static void tc_notify(FAR struct tc_dev_s *priv) * ****************************************************************************/ -static int tc_sample(FAR struct tc_dev_s *priv, - FAR struct tc_sample_s *sample) +static int tc_sample(struct tc_dev_s *priv, + struct tc_sample_s *sample) { int ret = -EAGAIN; @@ -561,8 +561,8 @@ static int tc_sample(FAR struct tc_dev_s *priv, * Name: tc_waitsample ****************************************************************************/ -static int tc_waitsample(FAR struct tc_dev_s *priv, - FAR struct tc_sample_s *sample) +static int tc_waitsample(struct tc_dev_s *priv, + struct tc_sample_s *sample) { int ret; @@ -619,9 +619,9 @@ static int tc_waitsample(FAR struct tc_dev_s *priv, * Name: tc_worker ****************************************************************************/ -static void tc_worker(FAR void *arg) +static void tc_worker(void *arg) { - FAR struct tc_dev_s *priv = (FAR struct tc_dev_s *)arg; + struct tc_dev_s *priv = (struct tc_dev_s *)arg; uint32_t delay; uint16_t value; uint16_t newx; @@ -974,19 +974,19 @@ static void tc_worker(FAR void *arg) * Name: tc_open ****************************************************************************/ -static int tc_open(FAR struct file *filep) +static int tc_open(struct file *filep) { #ifdef CONFIG_TOUCHSCREEN_REFCNT - FAR struct inode *inode; - FAR struct tc_dev_s *priv; - uint8_t tmp; - int ret; + struct inode *inode; + struct tc_dev_s *priv; + uint8_t tmp; + int ret; DEBUGASSERT(filep); inode = filep->f_inode; DEBUGASSERT(inode && inode->i_private); - priv = (FAR struct tc_dev_s *)inode->i_private; + priv = (struct tc_dev_s *)inode->i_private; /* Get exclusive access to the driver data structure */ @@ -1027,18 +1027,18 @@ static int tc_open(FAR struct file *filep) * Name: tc_close ****************************************************************************/ -static int tc_close(FAR struct file *filep) +static int tc_close(struct file *filep) { #ifdef CONFIG_TOUCHSCREEN_REFCNT - FAR struct inode *inode; - FAR struct tc_dev_s *priv; - int ret; + struct inode *inode; + struct tc_dev_s *priv; + int ret; DEBUGASSERT(filep); inode = filep->f_inode; DEBUGASSERT(inode && inode->i_private); - priv = (FAR struct tc_dev_s *)inode->i_private; + priv = (struct tc_dev_s *)inode->i_private; /* Get exclusive access to the driver data structure */ @@ -1067,19 +1067,19 @@ static int tc_close(FAR struct file *filep) * Name: tc_read ****************************************************************************/ -static ssize_t tc_read(FAR struct file *filep, FAR char *buffer, size_t len) +static ssize_t tc_read(struct file *filep, char *buffer, size_t len) { - FAR struct inode *inode; - FAR struct tc_dev_s *priv; - FAR struct touch_sample_s *report; + struct inode *inode; + struct tc_dev_s *priv; + struct touch_sample_s *report; struct tc_sample_s sample; - int ret; + int ret; DEBUGASSERT(filep); inode = filep->f_inode; DEBUGASSERT(inode && inode->i_private); - priv = (FAR struct tc_dev_s *)inode->i_private; + priv = (struct tc_dev_s *)inode->i_private; /* Verify that the caller has provided a buffer large enough to receive * the touch data. @@ -1133,7 +1133,7 @@ static ssize_t tc_read(FAR struct file *filep, FAR char *buffer, size_t len) * to the caller. */ - report = (FAR struct touch_sample_s *)buffer; + report = (struct touch_sample_s *)buffer; memset(report, 0, SIZEOF_TOUCH_SAMPLE_S(1)); report->npoints = 1; report->point[0].id = sample.id; @@ -1188,22 +1188,22 @@ static ssize_t tc_read(FAR struct file *filep, FAR char *buffer, size_t len) * Name: tc_ioctl ****************************************************************************/ -static int tc_ioctl(FAR struct file *filep, int cmd, unsigned long arg) +static int tc_ioctl(struct file *filep, int cmd, unsigned long arg) { #if 1 iinfo("cmd: %d arg: %ld\n", cmd, arg); return -ENOTTY; /* None yet supported */ #else - FAR struct inode *inode; - FAR struct tc_dev_s *priv; - int ret; + struct inode *inode; + struct tc_dev_s *priv; + int ret; iinfo("cmd: %d arg: %ld\n", cmd, arg); DEBUGASSERT(filep); inode = filep->f_inode; DEBUGASSERT(inode && inode->i_private); - priv = (FAR struct tc_dev_s *)inode->i_private; + priv = (struct tc_dev_s *)inode->i_private; /* Get exclusive access to the driver data structure */ @@ -1233,20 +1233,20 @@ static int tc_ioctl(FAR struct file *filep, int cmd, unsigned long arg) * Name: tc_poll ****************************************************************************/ -static int tc_poll(FAR struct file *filep, FAR struct pollfd *fds, +static int tc_poll(struct file *filep, struct pollfd *fds, bool setup) { - FAR struct inode *inode; - FAR struct tc_dev_s *priv; - int ret; - int i; + struct inode *inode; + struct tc_dev_s *priv; + int ret; + int i; iinfo("setup: %d\n", (int)setup); DEBUGASSERT(filep && fds); inode = filep->f_inode; DEBUGASSERT(inode && inode->i_private); - priv = (FAR struct tc_dev_s *)inode->i_private; + priv = (struct tc_dev_s *)inode->i_private; /* Are we setting up the poll? Or tearing it down? */ @@ -1262,7 +1262,8 @@ static int tc_poll(FAR struct file *filep, FAR struct pollfd *fds, if ((fds->events & POLLIN) == 0) { - ierr("ERROR: Missing POLLIN: revents: %08x\n", fds->revents); + ierr("ERROR: Missing POLLIN: revents: %08" PRIx32 "\n", + fds->revents); ret = -EDEADLK; goto errout; } @@ -1341,7 +1342,7 @@ static int tc_poll(FAR struct file *filep, FAR struct pollfd *fds, int pic32mx_tsc_setup(int minor) { - FAR struct tc_dev_s *priv; + struct tc_dev_s *priv; char devname[DEV_NAMELEN]; int ret; @@ -1364,7 +1365,7 @@ int pic32mx_tsc_setup(int minor) #ifndef CONFIG_TOUCHSCREEN_MULTIPLE priv = &g_touchscreen; #else - priv = (FAR struct tc_dev_s *)kmm_malloc(sizeof(struct tc_dev_s)); + priv = (struct tc_dev_s *)kmm_malloc(sizeof(struct tc_dev_s)); if (!priv) { ierr("ERROR: kmm_malloc(%d) failed\n", sizeof(struct tc_dev_s)); @@ -1380,7 +1381,7 @@ int pic32mx_tsc_setup(int minor) /* Register the device as an input device */ - snprintf(devname, DEV_NAMELEN, DEV_FORMAT, minor); + snprintf(devname, sizeof(devname), DEV_FORMAT, minor); iinfo("Registering %s\n", devname); ret = register_driver(devname, &tc_fops, 0666, priv); diff --git a/boards/mips/pic32mx/pic32mx7mmb/src/pic32_usbdev.c b/boards/mips/pic32mx/pic32mx7mmb/src/pic32_usbdev.c index 884dbbd80b75e..5c0af99c10022 100644 --- a/boards/mips/pic32mx/pic32mx7mmb/src/pic32_usbdev.c +++ b/boards/mips/pic32mx/pic32mx7mmb/src/pic32_usbdev.c @@ -130,7 +130,7 @@ void weak_function pic32mx_usbdevinitialize(void) * ****************************************************************************/ -int pic32mx_usbpullup(FAR struct usbdev_s *dev, bool enable) +int pic32mx_usbpullup(struct usbdev_s *dev, bool enable) { /* The Mikroelektronika PIC32MX7 MMB does not have a USB pull-up */ @@ -149,7 +149,7 @@ int pic32mx_usbpullup(FAR struct usbdev_s *dev, bool enable) * ****************************************************************************/ -void pic32mx_usbsuspend(FAR struct usbdev_s *dev, bool resume) +void pic32mx_usbsuspend(struct usbdev_s *dev, bool resume) { /* Do nothing */ } diff --git a/boards/mips/pic32mx/sure-pic32mx/scripts/Make.defs b/boards/mips/pic32mx/sure-pic32mx/scripts/Make.defs index 6e4a4434aab12..e3ab690e56383 100644 --- a/boards/mips/pic32mx/sure-pic32mx/scripts/Make.defs +++ b/boards/mips/pic32mx/sure-pic32mx/scripts/Make.defs @@ -41,16 +41,6 @@ endif ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT) -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef diff --git a/boards/mips/pic32mx/sure-pic32mx/src/pic32mx_appinit.c b/boards/mips/pic32mx/sure-pic32mx/src/pic32mx_appinit.c index de02be7648e4c..3b75010daa6f9 100644 --- a/boards/mips/pic32mx/sure-pic32mx/src/pic32mx_appinit.c +++ b/boards/mips/pic32mx/sure-pic32mx/src/pic32mx_appinit.c @@ -209,7 +209,7 @@ static int nsh_waiter(int argc, char *argv[]) #ifdef NSH_HAVE_MMCSD static int nsh_sdinitialize(void) { - FAR struct spi_dev_s *spi; + struct spi_dev_s *spi; int ret; /* Get the SPI port */ @@ -315,7 +315,7 @@ static int nsh_usbhostinitialize(void) ret = kthread_create("usbhost", CONFIG_USBHOST_DEFPRIO, CONFIG_USBHOST_STACKSIZE, - (main_t)nsh_waiter, (FAR char * const *)NULL); + (main_t)nsh_waiter, (char * const *)NULL); return ret < 0 ? -ENOEXEC : OK; } diff --git a/boards/mips/pic32mx/sure-pic32mx/src/pic32mx_autoleds.c b/boards/mips/pic32mx/sure-pic32mx/src/pic32mx_autoleds.c index 9fcbca599ff03..3a59d5be9315e 100644 --- a/boards/mips/pic32mx/sure-pic32mx/src/pic32mx_autoleds.c +++ b/boards/mips/pic32mx/sure-pic32mx/src/pic32mx_autoleds.c @@ -115,7 +115,7 @@ static const struct led_setting_s g_ledoffvalues[LED_NVALUES] = * Name: pic32mx_setleds ****************************************************************************/ -static void pic32mx_setleds(FAR const struct led_setting_s *setting) +static void pic32mx_setleds(const struct led_setting_s *setting) { if (setting->usb != LED_NC) { diff --git a/boards/mips/pic32mx/sure-pic32mx/src/pic32mx_buttons.c b/boards/mips/pic32mx/sure-pic32mx/src/pic32mx_buttons.c index 636774f1c2f98..d0ed9d4ba2350 100644 --- a/boards/mips/pic32mx/sure-pic32mx/src/pic32mx_buttons.c +++ b/boards/mips/pic32mx/sure-pic32mx/src/pic32mx_buttons.c @@ -193,7 +193,7 @@ uint32_t board_buttons(void) ****************************************************************************/ #ifdef CONFIG_ARCH_IRQBUTTONS -int board_button_irq(int id, xcpt_t irqhandler, FAR void *arg) +int board_button_irq(int id, xcpt_t irqhandler, void *arg) { int ret = -EINVAL; diff --git a/boards/mips/pic32mx/sure-pic32mx/src/pic32mx_lcd1602.c b/boards/mips/pic32mx/sure-pic32mx/src/pic32mx_lcd1602.c index 51c12c6cbbeb0..d9e8208345b52 100644 --- a/boards/mips/pic32mx/sure-pic32mx/src/pic32mx_lcd1602.c +++ b/boards/mips/pic32mx/sure-pic32mx/src/pic32mx_lcd1602.c @@ -124,7 +124,7 @@ struct lcd_instream_s { struct lib_instream_s stream; - FAR const char *buffer; + const char *buffer; ssize_t nbytes; }; @@ -145,9 +145,9 @@ struct lcd1602_2 /* Debug */ #ifdef CONFIG_DEBUG_LCD_INFO -static void lcd_dumpstate(FAR const char *msg); -static void lcd_dumpstream(FAR const char *msg, - FAR const struct lcd_instream_s *stream); +static void lcd_dumpstate(const char *msg); +static void lcd_dumpstream(const char *msg, + const struct lcd_instream_s *stream); #else # define lcd_dumpstate(msg) # define lcd_dumpstream(msg, stream) @@ -155,7 +155,7 @@ static void lcd_dumpstream(FAR const char *msg, /* Internal functions */ -static int lcd_getstream(FAR struct lib_instream_s *instream); +static int lcd_getstream(struct lib_instream_s *instream); static void lcd_brightness(uint8_t brightness); static void lcd_shortdelay(int delay); static void lcd_wrcommand(uint8_t cmd); @@ -170,10 +170,10 @@ static void lcd_action(enum slcdcode_e code, uint8_t count); /* Character driver operations */ -static ssize_t lcd_read(FAR struct file *, FAR char *, size_t); -static ssize_t lcd_write(FAR struct file *, FAR const char *, size_t); -static int lcd_ioctl(FAR struct file *filep, int cmd, unsigned long arg); -static int lcd_poll(FAR struct file *filep, FAR struct pollfd *fds, +static ssize_t lcd_read(struct file *, char *, size_t); +static ssize_t lcd_write(struct file *, const char *, size_t); +static int lcd_ioctl(struct file *filep, int cmd, unsigned long arg); +static int lcd_poll(struct file *filep, struct pollfd *fds, bool setup); /**************************************************************************** @@ -209,7 +209,7 @@ static struct lcd1602_2 g_lcd1602; ****************************************************************************/ #ifdef CONFIG_DEBUG_LCD_INFO -static void lcd_dumpstate(FAR const char *msg) +static void lcd_dumpstate(const char *msg) { uint8_t buffer[LCD_NCOLUMNS]; uint8_t ch; @@ -244,8 +244,8 @@ static void lcd_dumpstate(FAR const char *msg) ****************************************************************************/ #ifdef CONFIG_DEBUG_LCD_INFO -static void lcd_dumpstream(FAR const char *msg, - FAR const struct lcd_instream_s *stream) +static void lcd_dumpstream(const char *msg, + const struct lcd_instream_s *stream) { lcdinfo("%s:\n", msg); lcdinfo(" nget: %d nbytes: %d\n", @@ -262,10 +262,10 @@ static void lcd_dumpstream(FAR const char *msg, * ****************************************************************************/ -static int lcd_getstream(FAR struct lib_instream_s *instream) +static int lcd_getstream(struct lib_instream_s *instream) { - FAR struct lcd_instream_s *lcdstream = - (FAR struct lcd_instream_s *)instream; + struct lcd_instream_s *lcdstream = + (struct lcd_instream_s *)instream; DEBUGASSERT(lcdstream && lcdstream->buffer); if (lcdstream->nbytes > 0) @@ -792,7 +792,7 @@ static void lcd_action(enum slcdcode_e code, uint8_t count) * Name: lcd_read ****************************************************************************/ -static ssize_t lcd_read(FAR struct file *filep, FAR char *buffer, size_t len) +static ssize_t lcd_read(struct file *filep, char *buffer, size_t len) { uint8_t row; uint8_t column; @@ -826,7 +826,7 @@ static ssize_t lcd_read(FAR struct file *filep, FAR char *buffer, size_t len) * Name: lcd_write ****************************************************************************/ -static ssize_t lcd_write(FAR struct file *filep, FAR const char *buffer, +static ssize_t lcd_write(struct file *filep, const char *buffer, size_t len) { struct lcd_instream_s instream; @@ -912,7 +912,7 @@ static ssize_t lcd_write(FAR struct file *filep, FAR const char *buffer, * Name: lcd_ioctl ****************************************************************************/ -static int lcd_ioctl(FAR struct file *filep, int cmd, unsigned long arg) +static int lcd_ioctl(struct file *filep, int cmd, unsigned long arg) { switch (cmd) { @@ -924,8 +924,8 @@ static int lcd_ioctl(FAR struct file *filep, int cmd, unsigned long arg) case SLCDIOC_GETATTRIBUTES: { - FAR struct slcd_attributes_s *attr = - (FAR struct slcd_attributes_s *)((uintptr_t)arg); + struct slcd_attributes_s *attr = + (struct slcd_attributes_s *)((uintptr_t)arg); lcdinfo("SLCDIOC_GETATTRIBUTES:\n"); @@ -950,8 +950,8 @@ static int lcd_ioctl(FAR struct file *filep, int cmd, unsigned long arg) case SLCDIOC_CURPOS: { - FAR struct slcd_curpos_s *curpos = - (FAR struct slcd_curpos_s *)((uintptr_t)arg); + struct slcd_curpos_s *curpos = + (struct slcd_curpos_s *)((uintptr_t)arg); lcdinfo("SLCDIOC_CURPOS: row=%d column=%d\n", g_lcd1602.currow, g_lcd1602.curcol); @@ -974,7 +974,7 @@ static int lcd_ioctl(FAR struct file *filep, int cmd, unsigned long arg) case SLCDIOC_GETBRIGHTNESS: { - FAR int *brightness = (FAR int *)((uintptr_t)arg); + int *brightness = (int *)((uintptr_t)arg); if (!brightness) { return -EINVAL; @@ -1017,7 +1017,7 @@ static int lcd_ioctl(FAR struct file *filep, int cmd, unsigned long arg) * Name: lcd_poll ****************************************************************************/ -static int lcd_poll(FAR struct file *filep, FAR struct pollfd *fds, +static int lcd_poll(struct file *filep, struct pollfd *fds, bool setup) { if (setup) diff --git a/boards/mips/pic32mx/sure-pic32mx/src/pic32mx_spi.c b/boards/mips/pic32mx/sure-pic32mx/src/pic32mx_spi.c index 8a6bcb84c26a6..f7c22dca7b6a5 100644 --- a/boards/mips/pic32mx/sure-pic32mx/src/pic32mx_spi.c +++ b/boards/mips/pic32mx/sure-pic32mx/src/pic32mx_spi.c @@ -163,7 +163,7 @@ void weak_function pic32mx_spidev_initialize(void) ****************************************************************************/ #ifdef CONFIG_PIC32MX_SPI2 -void pic32mx_spi2select(FAR struct spi_dev_s *dev, uint32_t devid, +void pic32mx_spi2select(struct spi_dev_s *dev, uint32_t devid, bool selected) { spiinfo("devid: %d CS: %s\n", @@ -186,7 +186,7 @@ void pic32mx_spi2select(FAR struct spi_dev_s *dev, uint32_t devid, #endif } -uint8_t pic32mx_spi2status(FAR struct spi_dev_s *dev, uint32_t devid) +uint8_t pic32mx_spi2status(struct spi_dev_s *dev, uint32_t devid) { uint8_t ret = 0; diff --git a/boards/mips/pic32mx/sure-pic32mx/src/pic32mx_usbdev.c b/boards/mips/pic32mx/sure-pic32mx/src/pic32mx_usbdev.c index 63a35c882f70a..bd1a930b5de05 100644 --- a/boards/mips/pic32mx/sure-pic32mx/src/pic32mx_usbdev.c +++ b/boards/mips/pic32mx/sure-pic32mx/src/pic32mx_usbdev.c @@ -140,7 +140,7 @@ void weak_function pic32mx_usbdevinitialize(void) * ****************************************************************************/ -int pic32mx_usbpullup(FAR struct usbdev_s *dev, bool enable) +int pic32mx_usbpullup(struct usbdev_s *dev, bool enable) { /* The Sure PIC32MX does not have a USB pull-up */ @@ -158,7 +158,7 @@ int pic32mx_usbpullup(FAR struct usbdev_s *dev, bool enable) * ****************************************************************************/ -void pic32mx_usbsuspend(FAR struct usbdev_s *dev, bool resume) +void pic32mx_usbsuspend(struct usbdev_s *dev, bool resume) { /* Do nothing */ } diff --git a/boards/mips/pic32mx/ubw32/scripts/Make.defs b/boards/mips/pic32mx/ubw32/scripts/Make.defs index 996555ae54dbe..9c78bb65f925e 100644 --- a/boards/mips/pic32mx/ubw32/scripts/Make.defs +++ b/boards/mips/pic32mx/ubw32/scripts/Make.defs @@ -41,16 +41,6 @@ endif ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT) -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef diff --git a/boards/mips/pic32mx/ubw32/src/pic32_buttons.c b/boards/mips/pic32mx/ubw32/src/pic32_buttons.c index c5e5caceef515..8bb936d81cfc6 100644 --- a/boards/mips/pic32mx/ubw32/src/pic32_buttons.c +++ b/boards/mips/pic32mx/ubw32/src/pic32_buttons.c @@ -168,7 +168,7 @@ uint32_t board_buttons(void) ****************************************************************************/ #ifdef CONFIG_ARCH_IRQBUTTONS -int board_button_irq(int id, xcpt_t irqhandler, FAR void *arg) +int board_button_irq(int id, xcpt_t irqhandler, void *arg) { int ret = -EINVAL; diff --git a/boards/mips/pic32mx/ubw32/src/pic32_leds.c b/boards/mips/pic32mx/ubw32/src/pic32_leds.c index b73009ca48ed0..fae433edebd34 100644 --- a/boards/mips/pic32mx/ubw32/src/pic32_leds.c +++ b/boards/mips/pic32mx/ubw32/src/pic32_leds.c @@ -145,7 +145,7 @@ static const uint16_t g_ledpincfg[PIC32MX_UBW32_NLEDS] = ****************************************************************************/ #ifdef CONFIG_ARCH_LEDS -static void pic32mx_setleds(FAR const struct led_setting_s *setting) +static void pic32mx_setleds(const struct led_setting_s *setting) { if (setting->led1 != LED_NC) { diff --git a/boards/mips/pic32mx/ubw32/src/pic32_usbdev.c b/boards/mips/pic32mx/ubw32/src/pic32_usbdev.c index b3ef4c4402cf9..3ad908f656cfc 100644 --- a/boards/mips/pic32mx/ubw32/src/pic32_usbdev.c +++ b/boards/mips/pic32mx/ubw32/src/pic32_usbdev.c @@ -111,7 +111,7 @@ void weak_function pic32mx_usbdevinitialize(void) * ****************************************************************************/ -int pic32mx_usbpullup(FAR struct usbdev_s *dev, bool enable) +int pic32mx_usbpullup(struct usbdev_s *dev, bool enable) { /* The UBW32 does not have a USB pull-up */ @@ -129,7 +129,7 @@ int pic32mx_usbpullup(FAR struct usbdev_s *dev, bool enable) * ****************************************************************************/ -void pic32mx_usbsuspend(FAR struct usbdev_s *dev, bool resume) +void pic32mx_usbsuspend(struct usbdev_s *dev, bool resume) { /* Do nothing */ } diff --git a/boards/mips/pic32mz/chipkit-wifire/scripts/Make.defs b/boards/mips/pic32mz/chipkit-wifire/scripts/Make.defs index 45daea2dbda56..f08977a579816 100644 --- a/boards/mips/pic32mz/chipkit-wifire/scripts/Make.defs +++ b/boards/mips/pic32mz/chipkit-wifire/scripts/Make.defs @@ -51,16 +51,6 @@ endif ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT) -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef @@ -78,7 +68,7 @@ CPPFLAGS := $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) AFLAGS := $(CFLAGS) -D__ASSEMBLY__ ifeq ($(CONFIG_MIPS32_TOOLCHAIN_MICROCHIPL_XC32),y) - LDFLAGS = -nostdlib --defsym=__MPLAB_BUILD=1 --defsym=__MPLAB_DEBUG=1 --defsym=__DEBUG=1 --defsym=__MPLAB_DEBUGGER_PK3=1 --defsym=_min_heap_size=0 --gc-sections + LDFLAGS = -nostdlib --defsym=__MPLAB_BUILD=1 --defsym=__MPLAB_DEBUG=1 --defsym=__DEBUG=1 --defsym=__MPLAB_DEBUGGER_PK3=1 --defsym=_min_heap_size=0 else LDFLAGS = # -no-isn32 --relax endif diff --git a/boards/mips/pic32mz/chipkit-wifire/src/pic32mz_buttons.c b/boards/mips/pic32mz/chipkit-wifire/src/pic32mz_buttons.c index 565becccebb4b..79993eec067a3 100644 --- a/boards/mips/pic32mz/chipkit-wifire/src/pic32mz_buttons.c +++ b/boards/mips/pic32mz/chipkit-wifire/src/pic32mz_buttons.c @@ -131,7 +131,7 @@ uint32_t board_buttons(void) ****************************************************************************/ #ifdef CONFIG_ARCH_IRQBUTTONS -int board_button_irq(int id, xcpt_t irqhandler, FAR void *arg) +int board_button_irq(int id, xcpt_t irqhandler, void *arg) { #ifdef CONFIG_PIC32MZ_GPIOIRQ_PORTA int ret = OK; diff --git a/boards/mips/pic32mz/chipkit-wifire/src/pic32mz_spi.c b/boards/mips/pic32mz/chipkit-wifire/src/pic32mz_spi.c index fd7dbabdeebbc..7645dd521d249 100644 --- a/boards/mips/pic32mz/chipkit-wifire/src/pic32mz_spi.c +++ b/boards/mips/pic32mz/chipkit-wifire/src/pic32mz_spi.c @@ -89,21 +89,21 @@ void weak_function pic32mz_spidev_initialize(void) struct spi_dev_s; #ifdef CONFIG_PIC32MZ_SPI1 -void pic32mz_spi1select(FAR struct spi_dev_s *dev, uint32_t devid, +void pic32mz_spi1select(struct spi_dev_s *dev, uint32_t devid, bool selected) { spiinfo("devid: %d CS: %s\n", (int)devid, selected ? "assert" : "de-assert"); } -uint8_t pic32mz_spi1status(FAR struct spi_dev_s *dev, uint32_t devid) +uint8_t pic32mz_spi1status(struct spi_dev_s *dev, uint32_t devid) { spiinfo("Returning nothing\n"); return 0; } #ifdef CONFIG_SPI_CMDDATA -int pic32mz_spi1cmddata(FAR struct spi_dev_s *dev, uint32_t devid, bool cmd) +int pic32mz_spi1cmddata(struct spi_dev_s *dev, uint32_t devid, bool cmd) { return 0; } @@ -111,21 +111,21 @@ int pic32mz_spi1cmddata(FAR struct spi_dev_s *dev, uint32_t devid, bool cmd) #endif /* CONFIG_PIC32MZ_SPI1 */ #ifdef CONFIG_PIC32MZ_SPI2 -void pic32mz_spi2select(FAR struct spi_dev_s *dev, uint32_t devid, +void pic32mz_spi2select(struct spi_dev_s *dev, uint32_t devid, bool selected) { spiinfo("devid: %d CS: %s\n", (int)devid, selected ? "assert" : "de-assert"); } -uint8_t pic32mz_spi2status(FAR struct spi_dev_s *dev, uint32_t devid) +uint8_t pic32mz_spi2status(struct spi_dev_s *dev, uint32_t devid) { spiinfo("Returning nothing\n"); return 0; } #ifdef CONFIG_SPI_CMDDATA -int pic32mz_spi2cmddata(FAR struct spi_dev_s *dev, uint32_t devid, bool cmd) +int pic32mz_spi2cmddata(struct spi_dev_s *dev, uint32_t devid, bool cmd) { return 0; } @@ -133,21 +133,21 @@ int pic32mz_spi2cmddata(FAR struct spi_dev_s *dev, uint32_t devid, bool cmd) #endif /* CONFIG_PIC32MZ_SPI2 */ #ifdef CONFIG_PIC32MZ_SPI3 -void pic32mz_spi3select(FAR struct spi_dev_s *dev, uint32_t devid, +void pic32mz_spi3select(struct spi_dev_s *dev, uint32_t devid, bool selected) { spiinfo("devid: %d CS: %s\n", (int)devid, selected ? "assert" : "de-assert"); } -uint8_t pic32mz_spi3status(FAR struct spi_dev_s *dev, uint32_t devid) +uint8_t pic32mz_spi3status(struct spi_dev_s *dev, uint32_t devid) { spiinfo("Returning nothing\n"); return 0; } #ifdef CONFIG_SPI_CMDDATA -int pic32mz_spi3cmddata(FAR struct spi_dev_s *dev, uint32_t devid, bool cmd) +int pic32mz_spi3cmddata(struct spi_dev_s *dev, uint32_t devid, bool cmd) { return 0; } @@ -155,21 +155,21 @@ int pic32mz_spi3cmddata(FAR struct spi_dev_s *dev, uint32_t devid, bool cmd) #endif /* CONFIG_PIC32MZ_SPI3 */ #ifdef CONFIG_PIC32MZ_SPI4 -void pic32mz_spi4select(FAR struct spi_dev_s *dev, uint32_t devid, +void pic32mz_spi4select(struct spi_dev_s *dev, uint32_t devid, bool selected) { spiinfo("devid: %d CS: %s\n", (int)devid, selected ? "assert" : "de-assert"); } -uint8_t pic32mz_spi4status(FAR struct spi_dev_s *dev, uint32_t devid) +uint8_t pic32mz_spi4status(struct spi_dev_s *dev, uint32_t devid) { spiinfo("Returning nothing\n"); return 0; } #ifdef CONFIG_SPI_CMDDATA -int pic32mz_spi4cmddata(FAR struct spi_dev_s *dev, uint32_t devid, bool cmd) +int pic32mz_spi4cmddata(struct spi_dev_s *dev, uint32_t devid, bool cmd) { return 0; } @@ -177,14 +177,14 @@ int pic32mz_spi4cmddata(FAR struct spi_dev_s *dev, uint32_t devid, bool cmd) #endif /* CONFIG_PIC32MZ_SPI4 */ #ifdef CONFIG_PIC32MZ_SPI5 -void pic32mz_spi5select(FAR struct spi_dev_s *dev, uint32_t devid, +void pic32mz_spi5select(struct spi_dev_s *dev, uint32_t devid, bool selected) { spiinfo("devid: %d CS: %s\n", (int)devid, selected ? "assert" : "de-assert"); } -uint8_t pic32mz_spi5status(FAR struct spi_dev_s *dev, uint32_t devid) +uint8_t pic32mz_spi5status(struct spi_dev_s *dev, uint32_t devid) { spiinfo("Returning nothing\n"); #warning "Missing logic" @@ -192,7 +192,7 @@ uint8_t pic32mz_spi5status(FAR struct spi_dev_s *dev, uint32_t devid) } #ifdef CONFIG_SPI_CMDDATA -int pic32mz_spi5cmddata(FAR struct spi_dev_s *dev, uint32_t devid, bool cmd) +int pic32mz_spi5cmddata(struct spi_dev_s *dev, uint32_t devid, bool cmd) { #warning "Missing logic" return 0; @@ -201,7 +201,7 @@ int pic32mz_spi5cmddata(FAR struct spi_dev_s *dev, uint32_t devid, bool cmd) #endif /* CONFIG_PIC32MZ_SPI5 */ #ifdef CONFIG_PIC32MZ_SPI6 -void pic32mz_spi6select(FAR struct spi_dev_s *dev, uint32_t devid, +void pic32mz_spi6select(struct spi_dev_s *dev, uint32_t devid, bool selected) { spiinfo("devid: %d CS: %s\n", (int)devid, @@ -209,7 +209,7 @@ void pic32mz_spi6select(FAR struct spi_dev_s *dev, uint32_t devid, #warning "Missing logic" } -uint8_t pic32mz_spi6status(FAR struct spi_dev_s *dev, uint32_t devid) +uint8_t pic32mz_spi6status(struct spi_dev_s *dev, uint32_t devid) { spiinfo("Returning nothing\n"); #warning "Missing logic" @@ -217,7 +217,7 @@ uint8_t pic32mz_spi6status(FAR struct spi_dev_s *dev, uint32_t devid) } #ifdef CONFIG_SPI_CMDDATA -int pic32mz_spi6cmddata(FAR struct spi_dev_s *dev, uint32_t devid, bool cmd) +int pic32mz_spi6cmddata(struct spi_dev_s *dev, uint32_t devid, bool cmd) { #warning "Missing logic" return 0; @@ -247,8 +247,8 @@ int pic32mz_spi6cmddata(FAR struct spi_dev_s *dev, uint32_t devid, bool cmd) #ifdef CONFIG_SPI_CALLBACK #ifdef CONFIG_PIC32MZ_SPI1 -int pic32mz_spi1register(FAR struct spi_dev_s *dev, - spi_mediachange_t callback, FAR void *arg) +int pic32mz_spi1register(struct spi_dev_s *dev, + spi_mediachange_t callback, void *arg) { #warning Missing logic return -ENOSYS; @@ -256,8 +256,8 @@ int pic32mz_spi1register(FAR struct spi_dev_s *dev, #endif /* CONFIG_PIC32MZ_SPI1 */ #ifdef CONFIG_PIC32MZ_SPI2 -int pic32mz_spi2register(FAR struct spi_dev_s *dev, - spi_mediachange_t callback, FAR void *arg) +int pic32mz_spi2register(struct spi_dev_s *dev, + spi_mediachange_t callback, void *arg) { #warning Missing logic return -ENOSYS; @@ -265,8 +265,8 @@ int pic32mz_spi2register(FAR struct spi_dev_s *dev, #endif /* CONFIG_PIC32MZ_SPI2 */ #ifdef CONFIG_PIC32MZ_SPI3 -int pic32mz_spi3register(FAR struct spi_dev_s *dev, - spi_mediachange_t callback, FAR void *arg) +int pic32mz_spi3register(struct spi_dev_s *dev, + spi_mediachange_t callback, void *arg) { #warning Missing logic return -ENOSYS; @@ -274,8 +274,8 @@ int pic32mz_spi3register(FAR struct spi_dev_s *dev, #endif /* CONFIG_PIC32MZ_SPI3 */ #ifdef CONFIG_PIC32MZ_SPI4 -int pic32mz_spi4register(FAR struct spi_dev_s *dev, - spi_mediachange_t callback, FAR void *arg) +int pic32mz_spi4register(struct spi_dev_s *dev, + spi_mediachange_t callback, void *arg) { #warning Missing logic return -ENOSYS; @@ -283,8 +283,8 @@ int pic32mz_spi4register(FAR struct spi_dev_s *dev, #endif /* CONFIG_PIC32MZ_SPI4 */ #ifdef CONFIG_PIC32MZ_SPI5 -int pic32mz_spi5register(FAR struct spi_dev_s *dev, - spi_mediachange_t callback, FAR void *arg) +int pic32mz_spi5register(struct spi_dev_s *dev, + spi_mediachange_t callback, void *arg) { #warning Missing logic return -ENOSYS; @@ -292,8 +292,8 @@ int pic32mz_spi5register(FAR struct spi_dev_s *dev, #endif /* CONFIG_PIC32MZ_SPI5 */ #ifdef CONFIG_PIC32MZ_SPI6 -int pic32mz_spi6register(FAR struct spi_dev_s *dev, - spi_mediachange_t callback, FAR void *arg) +int pic32mz_spi6register(struct spi_dev_s *dev, + spi_mediachange_t callback, void *arg) { #warning Missing logic return -ENOSYS; diff --git a/boards/mips/pic32mz/flipnclick-pic32mz/scripts/Make.defs b/boards/mips/pic32mz/flipnclick-pic32mz/scripts/Make.defs index 4af862cbb2c03..b35a3901c88db 100644 --- a/boards/mips/pic32mz/flipnclick-pic32mz/scripts/Make.defs +++ b/boards/mips/pic32mz/flipnclick-pic32mz/scripts/Make.defs @@ -51,16 +51,6 @@ endif ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT) -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef @@ -78,7 +68,7 @@ CPPFLAGS := $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) AFLAGS := $(CFLAGS) -D__ASSEMBLY__ ifeq ($(CONFIG_MIPS32_TOOLCHAIN_MICROCHIPL_XC32),y) - LDFLAGS = -nostdlib --defsym=__MPLAB_BUILD=1 --defsym=__MPLAB_DEBUG=1 --defsym=__DEBUG=1 --defsym=__MPLAB_DEBUGGER_PK3=1 --defsym=_min_heap_size=0 --gc-sections + LDFLAGS = -nostdlib --defsym=__MPLAB_BUILD=1 --defsym=__MPLAB_DEBUG=1 --defsym=__DEBUG=1 --defsym=__MPLAB_DEBUGGER_PK3=1 --defsym=_min_heap_size=0 else LDFLAGS = # -no-isn32 --relax endif diff --git a/boards/mips/pic32mz/flipnclick-pic32mz/src/flipnclick-pic32mz.h b/boards/mips/pic32mz/flipnclick-pic32mz/src/flipnclick-pic32mz.h index 8fbeec2444e55..bd81970829530 100644 --- a/boards/mips/pic32mz/flipnclick-pic32mz/src/flipnclick-pic32mz.h +++ b/boards/mips/pic32mz/flipnclick-pic32mz/src/flipnclick-pic32mz.h @@ -269,7 +269,7 @@ int pic32mz_bringup(void); #ifdef HAVE_SSD1306 struct lcd_dev_s; /* Forward reference */ -FAR struct lcd_dev_s *pic32mz_graphics_setup(unsigned int devno); +struct lcd_dev_s *pic32mz_graphics_setup(unsigned int devno); #endif #undef EXTERN diff --git a/boards/mips/pic32mz/flipnclick-pic32mz/src/pic32mz_buttons.c b/boards/mips/pic32mz/flipnclick-pic32mz/src/pic32mz_buttons.c index 416705aa058a5..359b8bf1626e9 100644 --- a/boards/mips/pic32mz/flipnclick-pic32mz/src/pic32mz_buttons.c +++ b/boards/mips/pic32mz/flipnclick-pic32mz/src/pic32mz_buttons.c @@ -131,7 +131,7 @@ uint32_t board_buttons(void) ****************************************************************************/ #ifdef CONFIG_ARCH_IRQBUTTONS -int board_button_irq(int id, xcpt_t irqhandler, FAR void *arg) +int board_button_irq(int id, xcpt_t irqhandler, void *arg) { #ifdef CONFIG_PIC32MZ_GPIOIRQ_PORTD int ret = OK; diff --git a/boards/mips/pic32mz/flipnclick-pic32mz/src/pic32mz_spi.c b/boards/mips/pic32mz/flipnclick-pic32mz/src/pic32mz_spi.c index 1d2f1fe3fb65b..df3af5c1490fa 100644 --- a/boards/mips/pic32mz/flipnclick-pic32mz/src/pic32mz_spi.c +++ b/boards/mips/pic32mz/flipnclick-pic32mz/src/pic32mz_spi.c @@ -96,7 +96,7 @@ void weak_function pic32mz_spidev_initialize(void) struct spi_dev_s; #ifdef CONFIG_PIC32MZ_SPI1 -void pic32mz_spi1select(FAR struct spi_dev_s *dev, uint32_t devid, +void pic32mz_spi1select(struct spi_dev_s *dev, uint32_t devid, bool selected) { spiinfo("devid: %d CS: %s\n", (int)devid, @@ -115,14 +115,14 @@ void pic32mz_spi1select(FAR struct spi_dev_s *dev, uint32_t devid, #endif } -uint8_t pic32mz_spi1status(FAR struct spi_dev_s *dev, uint32_t devid) +uint8_t pic32mz_spi1status(struct spi_dev_s *dev, uint32_t devid) { spiinfo("Returning nothing\n"); return 0; } #ifdef CONFIG_SPI_CMDDATA -int pic32mz_spi1cmddata(FAR struct spi_dev_s *dev, uint32_t devid, bool cmd) +int pic32mz_spi1cmddata(struct spi_dev_s *dev, uint32_t devid, bool cmd) { #if defined(CONFIG_FLIPNCLICK_PIC32MZ_SSD1306_MBC) || \ defined(CONFIG_FLIPNCLICK_PIC32MZ_SSD1306_MBD) @@ -142,7 +142,7 @@ int pic32mz_spi1cmddata(FAR struct spi_dev_s *dev, uint32_t devid, bool cmd) #endif /* CONFIG_PIC32MZ_SPI1 */ #ifdef CONFIG_PIC32MZ_SPI2 -void pic32mz_spi2select(FAR struct spi_dev_s *dev, uint32_t devid, +void pic32mz_spi2select(struct spi_dev_s *dev, uint32_t devid, bool selected) { spiinfo("devid: %d CS: %s\n", (int)devid, @@ -161,14 +161,14 @@ void pic32mz_spi2select(FAR struct spi_dev_s *dev, uint32_t devid, #endif } -uint8_t pic32mz_spi2status(FAR struct spi_dev_s *dev, uint32_t devid) +uint8_t pic32mz_spi2status(struct spi_dev_s *dev, uint32_t devid) { spiinfo("Returning nothing\n"); return 0; } #ifdef CONFIG_SPI_CMDDATA -int pic32mz_spi2cmddata(FAR struct spi_dev_s *dev, uint32_t devid, bool cmd) +int pic32mz_spi2cmddata(struct spi_dev_s *dev, uint32_t devid, bool cmd) { #if defined(CONFIG_FLIPNCLICK_PIC32MZ_SSD1306_MBA) || \ defined(CONFIG_FLIPNCLICK_PIC32MZ_SSD1306_MBB) @@ -188,21 +188,21 @@ int pic32mz_spi2cmddata(FAR struct spi_dev_s *dev, uint32_t devid, bool cmd) #endif /* CONFIG_PIC32MZ_SPI2 */ #ifdef CONFIG_PIC32MZ_SPI3 -void pic32mz_spi3select(FAR struct spi_dev_s *dev, uint32_t devid, +void pic32mz_spi3select(struct spi_dev_s *dev, uint32_t devid, bool selected) { spiinfo("devid: %d CS: %s\n", (int)devid, selected ? "assert" : "de-assert"); } -uint8_t pic32mz_spi3status(FAR struct spi_dev_s *dev, uint32_t devid) +uint8_t pic32mz_spi3status(struct spi_dev_s *dev, uint32_t devid) { spiinfo("Returning nothing\n"); return 0; } #ifdef CONFIG_SPI_CMDDATA -int pic32mz_spi3cmddata(FAR struct spi_dev_s *dev, uint32_t devid, bool cmd) +int pic32mz_spi3cmddata(struct spi_dev_s *dev, uint32_t devid, bool cmd) { return 0; } @@ -210,21 +210,21 @@ int pic32mz_spi3cmddata(FAR struct spi_dev_s *dev, uint32_t devid, bool cmd) #endif /* CONFIG_PIC32MZ_SPI3 */ #ifdef CONFIG_PIC32MZ_SPI4 -void pic32mz_spi4select(FAR struct spi_dev_s *dev, uint32_t devid, +void pic32mz_spi4select(struct spi_dev_s *dev, uint32_t devid, bool selected) { spiinfo("devid: %d CS: %s\n", (int)devid, selected ? "assert" : "de-assert"); } -uint8_t pic32mz_spi4status(FAR struct spi_dev_s *dev, uint32_t devid) +uint8_t pic32mz_spi4status(struct spi_dev_s *dev, uint32_t devid) { spiinfo("Returning nothing\n"); return 0; } #ifdef CONFIG_SPI_CMDDATA -int pic32mz_spi4cmddata(FAR struct spi_dev_s *dev, uint32_t devid, bool cmd) +int pic32mz_spi4cmddata(struct spi_dev_s *dev, uint32_t devid, bool cmd) { return 0; } @@ -232,14 +232,14 @@ int pic32mz_spi4cmddata(FAR struct spi_dev_s *dev, uint32_t devid, bool cmd) #endif /* CONFIG_PIC32MZ_SPI4 */ #ifdef CONFIG_PIC32MZ_SPI5 -void pic32mz_spi5select(FAR struct spi_dev_s *dev, uint32_t devid, +void pic32mz_spi5select(struct spi_dev_s *dev, uint32_t devid, bool selected) { spiinfo("devid: %d CS: %s\n", (int)devid, selected ? "assert" : "de-assert"); } -uint8_t pic32mz_spi5status(FAR struct spi_dev_s *dev, uint32_t devid) +uint8_t pic32mz_spi5status(struct spi_dev_s *dev, uint32_t devid) { spiinfo("Returning nothing\n"); #warning "Missing logic" @@ -247,7 +247,7 @@ uint8_t pic32mz_spi5status(FAR struct spi_dev_s *dev, uint32_t devid) } #ifdef CONFIG_SPI_CMDDATA -int pic32mz_spi5cmddata(FAR struct spi_dev_s *dev, uint32_t devid, bool cmd) +int pic32mz_spi5cmddata(struct spi_dev_s *dev, uint32_t devid, bool cmd) { #warning "Missing logic" return 0; @@ -256,7 +256,7 @@ int pic32mz_spi5cmddata(FAR struct spi_dev_s *dev, uint32_t devid, bool cmd) #endif /* CONFIG_PIC32MZ_SPI5 */ #ifdef CONFIG_PIC32MZ_SPI6 -void pic32mz_spi6select(FAR struct spi_dev_s *dev, uint32_t devid, +void pic32mz_spi6select(struct spi_dev_s *dev, uint32_t devid, bool selected) { spiinfo("devid: %d CS: %s\n", (int)devid, @@ -264,7 +264,7 @@ void pic32mz_spi6select(FAR struct spi_dev_s *dev, uint32_t devid, #warning "Missing logic" } -uint8_t pic32mz_spi6status(FAR struct spi_dev_s *dev, uint32_t devid) +uint8_t pic32mz_spi6status(struct spi_dev_s *dev, uint32_t devid) { spiinfo("Returning nothing\n"); #warning "Missing logic" @@ -272,7 +272,7 @@ uint8_t pic32mz_spi6status(FAR struct spi_dev_s *dev, uint32_t devid) } #ifdef CONFIG_SPI_CMDDATA -int pic32mz_spi6cmddata(FAR struct spi_dev_s *dev, uint32_t devid, bool cmd) +int pic32mz_spi6cmddata(struct spi_dev_s *dev, uint32_t devid, bool cmd) { #warning "Missing logic" return 0; @@ -302,8 +302,8 @@ int pic32mz_spi6cmddata(FAR struct spi_dev_s *dev, uint32_t devid, bool cmd) #ifdef CONFIG_SPI_CALLBACK #ifdef CONFIG_PIC32MZ_SPI1 -int pic32mz_spi1register(FAR struct spi_dev_s *dev, - spi_mediachange_t callback, FAR void *arg) +int pic32mz_spi1register(struct spi_dev_s *dev, + spi_mediachange_t callback, void *arg) { #warning Missing logic return -ENOSYS; @@ -311,8 +311,8 @@ int pic32mz_spi1register(FAR struct spi_dev_s *dev, #endif /* CONFIG_PIC32MZ_SPI1 */ #ifdef CONFIG_PIC32MZ_SPI2 -int pic32mz_spi2register(FAR struct spi_dev_s *dev, - spi_mediachange_t callback, FAR void *arg) +int pic32mz_spi2register(struct spi_dev_s *dev, + spi_mediachange_t callback, void *arg) { #warning Missing logic return -ENOSYS; @@ -320,8 +320,8 @@ int pic32mz_spi2register(FAR struct spi_dev_s *dev, #endif /* CONFIG_PIC32MZ_SPI2 */ #ifdef CONFIG_PIC32MZ_SPI3 -int pic32mz_spi3register(FAR struct spi_dev_s *dev, - spi_mediachange_t callback, FAR void *arg) +int pic32mz_spi3register(struct spi_dev_s *dev, + spi_mediachange_t callback, void *arg) { #warning Missing logic return -ENOSYS; @@ -329,8 +329,8 @@ int pic32mz_spi3register(FAR struct spi_dev_s *dev, #endif /* CONFIG_PIC32MZ_SPI3 */ #ifdef CONFIG_PIC32MZ_SPI4 -int pic32mz_spi4register(FAR struct spi_dev_s *dev, - spi_mediachange_t callback, FAR void *arg) +int pic32mz_spi4register(struct spi_dev_s *dev, + spi_mediachange_t callback, void *arg) { #warning Missing logic return -ENOSYS; @@ -338,8 +338,8 @@ int pic32mz_spi4register(FAR struct spi_dev_s *dev, #endif /* CONFIG_PIC32MZ_SPI4 */ #ifdef CONFIG_PIC32MZ_SPI5 -int pic32mz_spi5register(FAR struct spi_dev_s *dev, - spi_mediachange_t callback, FAR void *arg) +int pic32mz_spi5register(struct spi_dev_s *dev, + spi_mediachange_t callback, void *arg) { #warning Missing logic return -ENOSYS; @@ -347,8 +347,8 @@ int pic32mz_spi5register(FAR struct spi_dev_s *dev, #endif /* CONFIG_PIC32MZ_SPI5 */ #ifdef CONFIG_PIC32MZ_SPI6 -int pic32mz_spi6register(FAR struct spi_dev_s *dev, - spi_mediachange_t callback, FAR void *arg) +int pic32mz_spi6register(struct spi_dev_s *dev, + spi_mediachange_t callback, void *arg) { #warning Missing logic return -ENOSYS; diff --git a/boards/mips/pic32mz/flipnclick-pic32mz/src/pic32mz_ssd1306.c b/boards/mips/pic32mz/flipnclick-pic32mz/src/pic32mz_ssd1306.c index 68a38cd978b6e..ddadc30422032 100644 --- a/boards/mips/pic32mz/flipnclick-pic32mz/src/pic32mz_ssd1306.c +++ b/boards/mips/pic32mz/flipnclick-pic32mz/src/pic32mz_ssd1306.c @@ -83,10 +83,10 @@ * ****************************************************************************/ -FAR struct lcd_dev_s *pic32mz_graphics_setup(unsigned int devno) +struct lcd_dev_s *pic32mz_graphics_setup(unsigned int devno) { - FAR struct spi_dev_s *spi; - FAR struct lcd_dev_s *dev; + struct spi_dev_s *spi; + struct lcd_dev_s *dev; /* Configure the OLED GPIOs. This initial configuration is RESET low, * putting the OLED into reset state. @@ -149,7 +149,7 @@ FAR struct lcd_dev_s *pic32mz_graphics_setup(unsigned int devno) ****************************************************************************/ #ifdef CONFIG_NXSTART_EXTERNINIT -FAR struct lcd_dev_s *board_graphics_setup(unsigned int devno) +struct lcd_dev_s *board_graphics_setup(unsigned int devno) { return pic32mz_graphics_setup(devno); } diff --git a/boards/mips/pic32mz/pic32mz-starterkit/scripts/Make.defs b/boards/mips/pic32mz/pic32mz-starterkit/scripts/Make.defs index db611e57c5502..f8d4c2d20ee5a 100644 --- a/boards/mips/pic32mz/pic32mz-starterkit/scripts/Make.defs +++ b/boards/mips/pic32mz/pic32mz-starterkit/scripts/Make.defs @@ -51,16 +51,6 @@ endif ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT) -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef @@ -78,7 +68,7 @@ CPPFLAGS := $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) AFLAGS := $(CFLAGS) -D__ASSEMBLY__ ifeq ($(CONFIG_MIPS32_TOOLCHAIN_MICROCHIPL_XC32),y) - LDFLAGS = -nostdlib --defsym=__MPLAB_BUILD=1 --defsym=__MPLAB_DEBUG=1 --defsym=__DEBUG=1 --defsym=__MPLAB_DEBUGGER_PK3=1 --defsym=_min_heap_size=0 --gc-sections + LDFLAGS = -nostdlib --defsym=__MPLAB_BUILD=1 --defsym=__MPLAB_DEBUG=1 --defsym=__DEBUG=1 --defsym=__MPLAB_DEBUGGER_PK3=1 --defsym=_min_heap_size=0 else LDFLAGS = # -no-isn32 --relax endif diff --git a/boards/mips/pic32mz/pic32mz-starterkit/src/pic32mz_autoleds.c b/boards/mips/pic32mz/pic32mz-starterkit/src/pic32mz_autoleds.c index 8d165bb8fdd00..9b034bd0456a6 100644 --- a/boards/mips/pic32mz/pic32mz-starterkit/src/pic32mz_autoleds.c +++ b/boards/mips/pic32mz/pic32mz-starterkit/src/pic32mz_autoleds.c @@ -124,7 +124,7 @@ static const struct led_setting_s g_ledoffvalues[LED_NVALUES] = * Name: pic32mz_setleds ****************************************************************************/ -static void pic32mz_setleds(FAR const struct led_setting_s *setting) +static void pic32mz_setleds(const struct led_setting_s *setting) { if (setting->led1 != LED_NC) { diff --git a/boards/mips/pic32mz/pic32mz-starterkit/src/pic32mz_bringup.c b/boards/mips/pic32mz/pic32mz-starterkit/src/pic32mz_bringup.c index 49e2565d44431..f3f14fc9511b4 100644 --- a/boards/mips/pic32mz/pic32mz-starterkit/src/pic32mz_bringup.c +++ b/boards/mips/pic32mz/pic32mz-starterkit/src/pic32mz_bringup.c @@ -53,7 +53,7 @@ #ifdef PIC32MZ_HAVE_MMCSD static int nsh_sdinitialize(void) { - FAR struct spi_dev_s *spi; + struct spi_dev_s *spi; int ret; /* Get the SPI port */ diff --git a/boards/mips/pic32mz/pic32mz-starterkit/src/pic32mz_buttons.c b/boards/mips/pic32mz/pic32mz-starterkit/src/pic32mz_buttons.c index 83e4639c0f6ed..a96d5878d4aab 100644 --- a/boards/mips/pic32mz/pic32mz-starterkit/src/pic32mz_buttons.c +++ b/boards/mips/pic32mz/pic32mz-starterkit/src/pic32mz_buttons.c @@ -139,7 +139,7 @@ uint32_t board_buttons(void) ****************************************************************************/ #ifdef CONFIG_ARCH_IRQBUTTONS -int board_button_irq(int id, xcpt_t irqhandler, FAR void *arg) +int board_button_irq(int id, xcpt_t irqhandler, void *arg) { #ifdef CONFIG_PIC32MZ_GPIOIRQ_PORTB int ret = OK; diff --git a/boards/mips/pic32mz/pic32mz-starterkit/src/pic32mz_spi.c b/boards/mips/pic32mz/pic32mz-starterkit/src/pic32mz_spi.c index af057a600c54f..e0d8b47c16747 100644 --- a/boards/mips/pic32mz/pic32mz-starterkit/src/pic32mz_spi.c +++ b/boards/mips/pic32mz/pic32mz-starterkit/src/pic32mz_spi.c @@ -90,7 +90,7 @@ void weak_function pic32mz_spidev_initialize(void) struct spi_dev_s; #ifdef CONFIG_PIC32MZ_SPI1 -void pic32mz_spi1select(FAR struct spi_dev_s *dev, uint32_t devid, +void pic32mz_spi1select(struct spi_dev_s *dev, uint32_t devid, bool selected) { spiinfo("devid: %d CS: %s\n", @@ -98,7 +98,7 @@ void pic32mz_spi1select(FAR struct spi_dev_s *dev, uint32_t devid, #warning "Missing logic" } -uint8_t pic32mz_spi1status(FAR struct spi_dev_s *dev, uint32_t devid) +uint8_t pic32mz_spi1status(struct spi_dev_s *dev, uint32_t devid) { spiinfo("Returning nothing\n"); #warning "Missing logic" @@ -106,7 +106,7 @@ uint8_t pic32mz_spi1status(FAR struct spi_dev_s *dev, uint32_t devid) } #ifdef CONFIG_SPI_CMDDATA -int pic32mz_spi1cmddata(FAR struct spi_dev_s *dev, uint32_t devid, bool cmd) +int pic32mz_spi1cmddata(struct spi_dev_s *dev, uint32_t devid, bool cmd) { #warning "Missing logic" return 0; @@ -115,7 +115,7 @@ int pic32mz_spi1cmddata(FAR struct spi_dev_s *dev, uint32_t devid, bool cmd) #endif #ifdef CONFIG_PIC32MZ_SPI2 -void pic32mz_spi2select(FAR struct spi_dev_s *dev, uint32_t devid, +void pic32mz_spi2select(struct spi_dev_s *dev, uint32_t devid, bool selected) { spiinfo("devid: %d CS: %s\n", @@ -123,7 +123,7 @@ void pic32mz_spi2select(FAR struct spi_dev_s *dev, uint32_t devid, #warning "Missing logic" } -uint8_t pic32mz_spi2status(FAR struct spi_dev_s *dev, uint32_t devid) +uint8_t pic32mz_spi2status(struct spi_dev_s *dev, uint32_t devid) { spiinfo("Returning nothing\n"); #warning "Missing logic" @@ -131,7 +131,7 @@ uint8_t pic32mz_spi2status(FAR struct spi_dev_s *dev, uint32_t devid) } #ifdef CONFIG_SPI_CMDDATA -int pic32mz_spi2cmddata(FAR struct spi_dev_s *dev, uint32_t devid, bool cmd) +int pic32mz_spi2cmddata(struct spi_dev_s *dev, uint32_t devid, bool cmd) { #warning "Missing logic" return 0; @@ -140,7 +140,7 @@ int pic32mz_spi2cmddata(FAR struct spi_dev_s *dev, uint32_t devid, bool cmd) #endif #ifdef CONFIG_PIC32MZ_SPI3 -void pic32mz_spi3select(FAR struct spi_dev_s *dev, uint32_t devid, +void pic32mz_spi3select(struct spi_dev_s *dev, uint32_t devid, bool selected) { spiinfo("devid: %d CS: %s\n", @@ -148,7 +148,7 @@ void pic32mz_spi3select(FAR struct spi_dev_s *dev, uint32_t devid, #warning "Missing logic" } -uint8_t pic32mz_spi3status(FAR struct spi_dev_s *dev, uint32_t devid) +uint8_t pic32mz_spi3status(struct spi_dev_s *dev, uint32_t devid) { spiinfo("Returning nothing\n"); #warning "Missing logic" @@ -156,7 +156,7 @@ uint8_t pic32mz_spi3status(FAR struct spi_dev_s *dev, uint32_t devid) } #ifdef CONFIG_SPI_CMDDATA -int pic32mz_spi3cmddata(FAR struct spi_dev_s *dev, uint32_t devid, bool cmd) +int pic32mz_spi3cmddata(struct spi_dev_s *dev, uint32_t devid, bool cmd) { #warning "Missing logic" return 0; @@ -165,7 +165,7 @@ int pic32mz_spi3cmddata(FAR struct spi_dev_s *dev, uint32_t devid, bool cmd) #endif #ifdef CONFIG_PIC32MZ_SPI4 -void pic32mz_spi4select(FAR struct spi_dev_s *dev, uint32_t devid, +void pic32mz_spi4select(struct spi_dev_s *dev, uint32_t devid, bool selected) { spiinfo("devid: %d CS: %s\n", @@ -173,7 +173,7 @@ void pic32mz_spi4select(FAR struct spi_dev_s *dev, uint32_t devid, #warning "Missing logic" } -uint8_t pic32mz_spi4status(FAR struct spi_dev_s *dev, uint32_t devid) +uint8_t pic32mz_spi4status(struct spi_dev_s *dev, uint32_t devid) { spiinfo("Returning nothing\n"); #warning "Missing logic" @@ -181,7 +181,7 @@ uint8_t pic32mz_spi4status(FAR struct spi_dev_s *dev, uint32_t devid) } #ifdef CONFIG_SPI_CMDDATA -int pic32mz_spi4cmddata(FAR struct spi_dev_s *dev, uint32_t devid, bool cmd) +int pic32mz_spi4cmddata(struct spi_dev_s *dev, uint32_t devid, bool cmd) { #warning "Missing logic" return 0; @@ -190,7 +190,7 @@ int pic32mz_spi4cmddata(FAR struct spi_dev_s *dev, uint32_t devid, bool cmd) #endif #ifdef CONFIG_PIC32MZ_SPI5 -void pic32mz_spi5select(FAR struct spi_dev_s *dev, uint32_t devid, +void pic32mz_spi5select(struct spi_dev_s *dev, uint32_t devid, bool selected) { spiinfo("devid: %d CS: %s\n", @@ -198,7 +198,7 @@ void pic32mz_spi5select(FAR struct spi_dev_s *dev, uint32_t devid, #warning "Missing logic" } -uint8_t pic32mz_spi5status(FAR struct spi_dev_s *dev, uint32_t devid) +uint8_t pic32mz_spi5status(struct spi_dev_s *dev, uint32_t devid) { spiinfo("Returning nothing\n"); #warning "Missing logic" @@ -206,7 +206,7 @@ uint8_t pic32mz_spi5status(FAR struct spi_dev_s *dev, uint32_t devid) } #ifdef CONFIG_SPI_CMDDATA -int pic32mz_spi5cmddata(FAR struct spi_dev_s *dev, uint32_t devid, +int pic32mz_spi5cmddata(struct spi_dev_s *dev, uint32_t devid, bool cmd) { #warning "Missing logic" @@ -216,7 +216,7 @@ int pic32mz_spi5cmddata(FAR struct spi_dev_s *dev, uint32_t devid, #endif #ifdef CONFIG_PIC32MZ_SPI6 -void pic32mz_spi6select(FAR struct spi_dev_s *dev, uint32_t devid, +void pic32mz_spi6select(struct spi_dev_s *dev, uint32_t devid, bool selected) { spiinfo("devid: %d CS: %s\n", (int)devid, @@ -224,7 +224,7 @@ void pic32mz_spi6select(FAR struct spi_dev_s *dev, uint32_t devid, #warning "Missing logic" } -uint8_t pic32mz_spi6status(FAR struct spi_dev_s *dev, uint32_t devid) +uint8_t pic32mz_spi6status(struct spi_dev_s *dev, uint32_t devid) { spiinfo("Returning nothing\n"); #warning "Missing logic" @@ -232,7 +232,7 @@ uint8_t pic32mz_spi6status(FAR struct spi_dev_s *dev, uint32_t devid) } #ifdef CONFIG_SPI_CMDDATA -int pic32mz_spi6cmddata(FAR struct spi_dev_s *dev, uint32_t devid, bool cmd) +int pic32mz_spi6cmddata(struct spi_dev_s *dev, uint32_t devid, bool cmd) { #warning "Missing logic" return 0; diff --git a/boards/misoc/lm32/misoc/scripts/Make.defs b/boards/misoc/lm32/misoc/scripts/Make.defs index 7dc98982c6d83..0b0ca1cf1dbc0 100644 --- a/boards/misoc/lm32/misoc/scripts/Make.defs +++ b/boards/misoc/lm32/misoc/scripts/Make.defs @@ -32,16 +32,6 @@ endif ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT) -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -fomit-frame-pointer -endif - -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef diff --git a/boards/or1k/mor1kx/or1k/scripts/Make.defs b/boards/or1k/mor1kx/or1k/scripts/Make.defs index d9f28eea8ea97..fa7ca11f366b8 100644 --- a/boards/or1k/mor1kx/or1k/scripts/Make.defs +++ b/boards/or1k/mor1kx/or1k/scripts/Make.defs @@ -23,19 +23,8 @@ include $(TOPDIR)/tools/Config.mk include $(TOPDIR)/arch/or1k/src/mor1kx/Toolchain.defs LDSCRIPT = flash.ld - ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT) -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -fomit-frame-pointer -endif - -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new -fno-rtti ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 @@ -46,7 +35,3 @@ CXXFLAGS := $(ARCHCXXFLAGS) $(ARCHWARNINGSXX) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS CXXPICFLAGS = $(ARCHPICFLAGS) $(CXXFLAGS) CPPFLAGS := $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) AFLAGS := $(CFLAGS) -D__ASSEMBLY__ - -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - LDFLAGS += -g -endif diff --git a/boards/renesas/rx65n/rx65n-grrose/include/README.TXT b/boards/renesas/rx65n/rx65n-grrose/include/README.TXT index 997bb9f7dbc72..b40fe3eba845e 100644 --- a/boards/renesas/rx65n/rx65n-grrose/include/README.TXT +++ b/boards/renesas/rx65n/rx65n-grrose/include/README.TXT @@ -3,13 +3,13 @@ README Overview -------- - This directory contains logic to support a custom ROMFS start-up script. - This startup script is used by by the NSH when it starts provided that - CONFIG_NSH_ARCHROMFS=y. The script provides a ROMFS volume that will be - mounted at /etc and will look like this at run-time: + This directory contains logic to support a custom ROMFS system-init script + and start-up script. These scripts are used by by the NSH when it starts + provided that CONFIG_NSH_ARCHROMFS=y. These scripts provide a ROMFS volume + that will be mounted at /etc and will look like this at run-time: NuttShell (NSH) NuttX-8.2 - nsh> ls -l /etc + nsh> ls -Rl /etc /etc: dr-xr-xr-x 0 . -r--r--r-- 20 group @@ -18,10 +18,11 @@ README /etc/init.d: dr-xr-xr-x 0 .. -r--r--r-- 110 rcS + -r--r--r-- 110 rc.sysinit nsh> - /etc/init.d/rcS is the start-up script; /etc/passwd is a the password - file. It supports a single user: + /etc/init.d/rc.sysinit is system init script; /etc/init.d/rcS is the start-up + script; /etc/passwd is a the password file. It supports a single user: USERNAME: admin PASSWORD: Adminstrator diff --git a/boards/renesas/rx65n/rx65n-grrose/src/rx65n_bringup.c b/boards/renesas/rx65n/rx65n-grrose/src/rx65n_bringup.c index bc7262168a548..88c7021203890 100644 --- a/boards/renesas/rx65n/rx65n-grrose/src/rx65n_bringup.c +++ b/boards/renesas/rx65n/rx65n-grrose/src/rx65n_bringup.c @@ -382,13 +382,13 @@ int rx65n_bringup(void) #ifdef CONFIG_RX65N_SBRAM /* Initialize battery-backed RAM */ - (void)rx65n_sbram_int(); + rx65n_sbram_int(); #endif #ifdef HAVE_DTC_DRIVER /* Initialize DTC */ - (void)rx65n_dtc_initialize(); + rx65n_dtc_initialize(); #endif #if defined(CONFIG_USBHOST) @@ -396,7 +396,7 @@ int rx65n_bringup(void) #endif #ifdef CONFIG_RX65N_RSPI - (void)rx65n_rspi_initialize(); + rx65n_rspi_initialize(); #endif #if defined(CONFIG_CDCACM) && !defined(CONFIG_CDCACM_CONSOLE) diff --git a/boards/renesas/rx65n/rx65n-grrose/src/rx65n_sbram.c b/boards/renesas/rx65n/rx65n-grrose/src/rx65n_sbram.c index a5c2382a48442..158052ee44a1e 100644 --- a/boards/renesas/rx65n/rx65n-grrose/src/rx65n_sbram.c +++ b/boards/renesas/rx65n/rx65n-grrose/src/rx65n_sbram.c @@ -242,7 +242,7 @@ static int hardfault_get_desc(struct sbramd_s *desc) { ret = file_ioctl(&filestruct, RX65N_SBRAM_GETDESC_IOCTL, (unsigned long)((uintptr_t)desc)); - (void)file_close(&filestruct); + file_close(&filestruct); if (ret < 0) { @@ -340,7 +340,7 @@ void board_crashdump(uintptr_t currentsp, FAR void *tcb, FAR struct tcb_s *rtcb; int rv; - (void)enter_critical_section(); + enter_critical_section(); rtcb = (FAR struct tcb_s *)tcb; diff --git a/boards/renesas/rx65n/rx65n-rsk2mb/include/README.TXT b/boards/renesas/rx65n/rx65n-rsk2mb/include/README.TXT index 7d9eff1293209..1587eda1c1820 100644 --- a/boards/renesas/rx65n/rx65n-rsk2mb/include/README.TXT +++ b/boards/renesas/rx65n/rx65n-rsk2mb/include/README.TXT @@ -3,10 +3,10 @@ README Overview -------- - This directory contains logic to support a custom ROMFS start-up script. - This startup script is used by by the NSH when it starts provided that - CONFIG_NSH_ARCHROMFS=y. The script provides a ROMFS volume that will be - mounted at /etc and will look like this at run-time: + This directory contains logic to support a custom ROMFS system-init script + and start-up script. These scripts are used by by the NSH when it starts + provided that CONFIG_NSH_ARCHROMFS=y. These scripts provide a ROMFS volume + that will be mounted at /etc and will look like this at run-time: NuttShell (NSH) NuttX-8.2 nsh> ls -l /etc @@ -18,10 +18,11 @@ README /etc/init.d: dr-xr-xr-x 0 .. -r--r--r-- 110 rcS + -r--r--r-- 110 rc.sysinit nsh> - /etc/init.d/rcS is the start-up script; /etc/passwd is a the password - file. It supports a single user: + /etc/init.d/rc.sysinit is system init script; /etc/init.d/rcS is the start-up + script; /etc/passwd is a the password file. It supports a single user: USERNAME: admin PASSWORD: Adminstrator diff --git a/boards/renesas/rx65n/rx65n-rsk2mb/src/rx65n_bringup.c b/boards/renesas/rx65n/rx65n-rsk2mb/src/rx65n_bringup.c index cd43344b50f7c..aaff33d9ad5ad 100644 --- a/boards/renesas/rx65n/rx65n-rsk2mb/src/rx65n_bringup.c +++ b/boards/renesas/rx65n/rx65n-rsk2mb/src/rx65n_bringup.c @@ -377,17 +377,17 @@ int rx65n_bringup(void) #ifdef CONFIG_RX65N_SBRAM /* Initialize standby RAM */ - (void)rx65n_sbram_int(); + rx65n_sbram_int(); #endif #ifdef HAVE_DTC_DRIVER /* Initialize DTC */ - (void)rx65n_dtc_initialize(); + rx65n_dtc_initialize(); #endif #ifdef CONFIG_RX65N_RSPI - (void)rx65n_rspi_initialize(); + rx65n_rspi_initialize(); #endif #if defined(CONFIG_USBHOST) diff --git a/boards/renesas/rx65n/rx65n-rsk2mb/src/rx65n_sbram.c b/boards/renesas/rx65n/rx65n-rsk2mb/src/rx65n_sbram.c index 98bf5a52555a5..ab63ccfbf574a 100644 --- a/boards/renesas/rx65n/rx65n-rsk2mb/src/rx65n_sbram.c +++ b/boards/renesas/rx65n/rx65n-rsk2mb/src/rx65n_sbram.c @@ -240,7 +240,7 @@ static int hardfault_get_desc(struct sbramd_s *desc) { ret = file_ioctl(&filestruct, RX65N_SBRAM_GETDESC_IOCTL, (unsigned long)((uintptr_t)desc)); - (void)file_close(&filestruct); + file_close(&filestruct); if (ret < 0) { @@ -338,7 +338,7 @@ void board_crashdump(uintptr_t currentsp, FAR void *tcb, FAR struct tcb_s *rtcb; int rv; - (void)enter_critical_section(); + enter_critical_section(); rtcb = (FAR struct tcb_s *)tcb; diff --git a/boards/risc-v/bl602/bl602evb/configs/elf/defconfig b/boards/risc-v/bl602/bl602evb/configs/elf/defconfig index 89e0f7906b3fd..a04e406f288b9 100644 --- a/boards/risc-v/bl602/bl602evb/configs/elf/defconfig +++ b/boards/risc-v/bl602/bl602evb/configs/elf/defconfig @@ -66,7 +66,6 @@ CONFIG_TASK_NAME_SIZE=12 CONFIG_TASK_SPAWN_DEFAULT_STACKSIZE=8192 CONFIG_TESTING_GETPRIME=y CONFIG_TESTING_OSTEST=y -CONFIG_TESTING_OSTEST_FPUSIZE=132 CONFIG_TIMER=y CONFIG_TIMER_ARCH=y CONFIG_UART0_BAUD=2000000 diff --git a/boards/risc-v/bl602/bl602evb/configs/fpu/defconfig b/boards/risc-v/bl602/bl602evb/configs/fpu/defconfig index 664023349b343..37583ab44a6b1 100644 --- a/boards/risc-v/bl602/bl602evb/configs/fpu/defconfig +++ b/boards/risc-v/bl602/bl602evb/configs/fpu/defconfig @@ -59,7 +59,6 @@ CONFIG_TASK_NAME_SIZE=12 CONFIG_TASK_SPAWN_DEFAULT_STACKSIZE=8192 CONFIG_TESTING_GETPRIME=y CONFIG_TESTING_OSTEST=y -CONFIG_TESTING_OSTEST_FPUSIZE=132 CONFIG_TIMER=y CONFIG_TIMER_ARCH=y CONFIG_UART0_BAUD=2000000 diff --git a/boards/risc-v/bl602/bl602evb/configs/timer/defconfig b/boards/risc-v/bl602/bl602evb/configs/timer/defconfig index 33669a3ffc117..6b96cb60c6234 100644 --- a/boards/risc-v/bl602/bl602evb/configs/timer/defconfig +++ b/boards/risc-v/bl602/bl602evb/configs/timer/defconfig @@ -45,7 +45,6 @@ CONFIG_NSH_ARCHINIT=y CONFIG_NSH_BUILTIN_APPS=y CONFIG_NSH_FILEIOSIZE=64 CONFIG_NSH_STRERROR=y -CONFIG_ONESHOT=y CONFIG_PREALLOC_TIMERS=0 CONFIG_PTHREAD_STACK_DEFAULT=8192 CONFIG_PWM=y diff --git a/boards/risc-v/bl602/bl602evb/configs/wifi/defconfig b/boards/risc-v/bl602/bl602evb/configs/wifi/defconfig index c9f1a05033a3c..e5fa4e03804df 100644 --- a/boards/risc-v/bl602/bl602evb/configs/wifi/defconfig +++ b/boards/risc-v/bl602/bl602evb/configs/wifi/defconfig @@ -128,7 +128,6 @@ CONFIG_TASK_NAME_SIZE=12 CONFIG_TASK_SPAWN_DEFAULT_STACKSIZE=8192 CONFIG_TESTING_MM=y CONFIG_TESTING_OSTEST=y -CONFIG_TESTING_OSTEST_FPUSIZE=132 CONFIG_UART0_BAUD=2000000 CONFIG_UART0_RXBUFSIZE=128 CONFIG_UART0_SERIAL_CONSOLE=y diff --git a/boards/risc-v/bl602/bl602evb/scripts/Make.defs b/boards/risc-v/bl602/bl602evb/scripts/Make.defs index 084ac04693112..398e34cf0531f 100644 --- a/boards/risc-v/bl602/bl602evb/scripts/Make.defs +++ b/boards/risc-v/bl602/bl602evb/scripts/Make.defs @@ -26,23 +26,10 @@ ARCH_SRCDIR = $(TOPDIR)$(DELIM)arch$(DELIM)$(CONFIG_ARCH)$(DELIM)src ARCH_INCDIR = $(TOPDIR)$(DELIM)arch$(DELIM)$(CONFIG_ARCH)$(DELIM)include LDSCRIPT = ld.script - ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT) -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g - ASARCHCPUFLAGS += -Wa,-g -endif - -MAXOPTIMIZATION = -Os - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - ARCHCPUFLAGS += -mno-relax -ARCHCFLAGS = -fno-common -ffunction-sections -fdata-sections -ARCHCXXFLAGS = -fno-common -ffunction-sections -fdata-sections -fno-exceptions -fcheck-new -std=c++17 -pipe -nostdinc++ +ARCHCXXFLAGS += -pipe ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 @@ -58,7 +45,7 @@ CPICFLAGS = $(ARCHPICFLAGS) $(CFLAGS) CXXFLAGS := $(ARCHCXXFLAGS) $(ARCHWARNINGSXX) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHXXINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) CXXPICFLAGS = $(ARCHPICFLAGS) $(CXXFLAGS) CPPFLAGS = $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) -AFLAGS += $(CFLAGS) -D__ASSEMBLY__ $(ASARCHCPUFLAGS) +AFLAGS += $(CFLAGS) -D__ASSEMBLY__ # ELF module definitions @@ -66,8 +53,7 @@ CELFFLAGS = $(CFLAGS) CXXELFFLAGS = $(CXXFLAGS) LDELFFLAGS = -melf32lriscv -r -e main -LDELFFLAGS += -T $(call CONVERT_PATH,$(BOARD_DIR)$(DELIM)scripts$(DELIM)gnu-elf.ld) +LDELFFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)/binfmt/libelf/gnu-elf.ld) -LDFLAGS += --gc-sections -melf32lriscv --cref -LDFLAGS += -Map=$(TOPDIR)/nuttx.map +LDFLAGS += -melf32lriscv diff --git a/boards/risc-v/bl602/bl602evb/scripts/gnu-elf.ld b/boards/risc-v/bl602/bl602evb/scripts/gnu-elf.ld deleted file mode 100644 index 8bce6c2f1a7ca..0000000000000 --- a/boards/risc-v/bl602/bl602evb/scripts/gnu-elf.ld +++ /dev/null @@ -1,115 +0,0 @@ -/**************************************************************************** - * boards/risc-v/bl602/bl602evb/scripts/gnu-elf.ld - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. The - * ASF licenses this file to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance with the - * License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - ****************************************************************************/ - -SECTIONS -{ - .text 0x00000000 : - { - _stext = . ; - *(.text) - *(.text.*) - *(.gnu.warning) - *(.stub) - *(.glue_7) - *(.glue_7t) - *(.jcr) - - /* C++ support: The .init and .fini sections contain specific logic - * to manage static constructors and destructors. - */ - - *(.gnu.linkonce.t.*) - *(.init) /* Old ABI */ - *(.fini) /* Old ABI */ - _etext = . ; - } - - .rodata : - { - _srodata = . ; - *(.rodata) - *(.rodata1) - *(.rodata.*) - *(.gnu.linkonce.r*) - _erodata = . ; - } - - .data : - { - _sdata = . ; - *(.data) - *(.data1) - *(.data.*) - *(.gnu.linkonce.d*) - . = ALIGN(4); - _edata = . ; - } - - /* C++ support. For each global and static local C++ object, - * GCC creates a small subroutine to construct the object. Pointers - * to these routines (not the routines themselves) are stored as - * simple, linear arrays in the .ctors section of the object file. - * Similarly, pointers to global/static destructor routines are - * stored in .dtors. - */ - - .ctors : - { - _sctors = . ; - *(.ctors) /* Old ABI: Unallocated */ - *(.init_array) /* New ABI: Allocated */ - _edtors = . ; - } - - .dtors : - { - _sdtors = . ; - *(.dtors) /* Old ABI: Unallocated */ - *(.fini_array) /* New ABI: Allocated */ - _edtors = . ; - } - - .bss : - { - _sbss = . ; - *(.bss) - *(.bss.*) - *(.sbss) - *(.sbss.*) - *(.gnu.linkonce.b*) - *(COMMON) - _ebss = . ; - } - - /* Stabs debugging sections. */ - - .stab 0 : { *(.stab) } - .stabstr 0 : { *(.stabstr) } - .stab.excl 0 : { *(.stab.excl) } - .stab.exclstr 0 : { *(.stab.exclstr) } - .stab.index 0 : { *(.stab.index) } - .stab.indexstr 0 : { *(.stab.indexstr) } - .comment 0 : { *(.comment) } - .debug_abbrev 0 : { *(.debug_abbrev) } - .debug_info 0 : { *(.debug_info) } - .debug_line 0 : { *(.debug_line) } - .debug_pubnames 0 : { *(.debug_pubnames) } - .debug_aranges 0 : { *(.debug_aranges) } -} diff --git a/boards/risc-v/bl602/bl602evb/src/Makefile b/boards/risc-v/bl602/bl602evb/src/Makefile index 0fd6eb4275186..8cfa6cee6375c 100644 --- a/boards/risc-v/bl602/bl602evb/src/Makefile +++ b/boards/risc-v/bl602/bl602evb/src/Makefile @@ -33,8 +33,4 @@ ifeq ($(CONFIG_DEV_GPIO),y) CSRCS += bl602_gpio.c endif -ifeq ($(CONFIG_ARCH_FPU),y) -CSRCS += bl602_ostest.c -endif - include $(TOPDIR)/boards/Board.mk diff --git a/boards/risc-v/bl602/bl602evb/src/bl602_bringup.c b/boards/risc-v/bl602/bl602evb/src/bl602_bringup.c index 0902541f76434..7e5ac4e8e735b 100644 --- a/boards/risc-v/bl602/bl602evb/src/bl602_bringup.c +++ b/boards/risc-v/bl602/bl602evb/src/bl602_bringup.c @@ -96,7 +96,7 @@ extern int bl602_net_initialize(void); #if defined(CONFIG_BL602_BLE_CONTROLLER) struct bthci_s { - FAR struct bt_driver_s drv; + struct bt_driver_s drv; int id; int fd; sq_entry_t link; @@ -115,16 +115,16 @@ struct uart_env_tag struct uart_rxchannel rx; }; -static FAR struct bthci_s *hci_dev; -static FAR struct circbuf_s circbuf_rd; +static struct bthci_s *hci_dev; +static struct circbuf_s circbuf_rd; static struct uart_env_tag uart_env; -static int bthci_send(FAR struct bt_driver_s *drv, +static int bthci_send(struct bt_driver_s *drv, enum bt_buf_type_e type, - FAR void *data, + void *data, size_t len); -static int bthci_open(FAR struct bt_driver_s *drv); -static void bthci_close(FAR struct bt_driver_s *drv); +static int bthci_open(struct bt_driver_s *drv); +static void bthci_close(struct bt_driver_s *drv); static int bthci_receive(uint8_t *data, uint32_t len); static int bthci_register(void); @@ -180,12 +180,12 @@ static void ble_uart_write(const uint8_t *bufptr, return; } -static int bthci_send(FAR struct bt_driver_s *drv, +static int bthci_send(struct bt_driver_s *drv, enum bt_buf_type_e type, - FAR void *data, + void *data, size_t len) { - FAR char *hdr = (FAR char *)data - drv->head_reserve; + char *hdr = (char *)data - drv->head_reserve; void (*callback)(void *, uint8_t) = NULL; void *dummy = NULL; int nlen; @@ -247,7 +247,7 @@ static int bthci_send(FAR struct bt_driver_s *drv, return nlen; } -static void bthci_close(FAR struct bt_driver_s *drv) +static void bthci_close(struct bt_driver_s *drv) { } @@ -283,19 +283,19 @@ static int bthci_receive(uint8_t *data, uint32_t len) len - H4_HEADER_SIZE); } -static int bthci_open(FAR struct bt_driver_s *drv) +static int bthci_open(struct bt_driver_s *drv) { return OK; } -static FAR struct bthci_s *bthci_alloc(void) +static struct bthci_s *bthci_alloc(void) { /* Register the driver with the Bluetooth stack */ - FAR struct bthci_s *dev; - FAR struct bt_driver_s *drv; + struct bthci_s *dev; + struct bt_driver_s *drv; - dev = (FAR struct bthci_s *)kmm_zalloc(sizeof(*dev)); + dev = (struct bthci_s *)kmm_zalloc(sizeof(*dev)); if (dev == NULL) { return NULL; @@ -371,7 +371,7 @@ int bl602_bringup(void) struct oneshot_lowerhalf_s *os = NULL; #endif #if defined(CONFIG_BL602_SPIFLASH) - FAR struct mtd_dev_s *mtd_part = NULL; + struct mtd_dev_s *mtd_part = NULL; const char *path = "/dev/mtdflash"; #endif #ifdef CONFIG_I2C @@ -538,7 +538,7 @@ int bl602_bringup(void) #ifdef CONFIG_RTC_DRIVER /* Instantiate the BL602 lower-half RTC driver */ - FAR struct rtc_lowerhalf_s *lower; + struct rtc_lowerhalf_s *lower; lower = bl602_rtc_lowerhalf_initialize(); if (!lower) diff --git a/boards/risc-v/bl602/bl602evb/src/bl602_gpio.c b/boards/risc-v/bl602/bl602evb/src/bl602_gpio.c index a0129f7746045..285d6ae4063e4 100644 --- a/boards/risc-v/bl602/bl602evb/src/bl602_gpio.c +++ b/boards/risc-v/bl602/bl602evb/src/bl602_gpio.c @@ -62,14 +62,14 @@ struct bl602_gpint_dev_s * Private Function Prototypes ****************************************************************************/ -static int gpin_read(FAR struct gpio_dev_s *dev, FAR bool *value); -static int gpout_read(FAR struct gpio_dev_s *dev, FAR bool *value); -static int gpout_write(FAR struct gpio_dev_s *dev, bool value); -static int gpint_read(FAR struct gpio_dev_s *dev, FAR bool *value); -static int gpint_attach(FAR struct gpio_dev_s *dev, +static int gpin_read(struct gpio_dev_s *dev, bool *value); +static int gpout_read(struct gpio_dev_s *dev, bool *value); +static int gpout_write(struct gpio_dev_s *dev, bool value); +static int gpint_read(struct gpio_dev_s *dev, bool *value); +static int gpint_attach(struct gpio_dev_s *dev, pin_interrupt_t callback); -static int gpint_enable(FAR struct gpio_dev_s *dev, bool enable); -static int gpio_setpintype(FAR struct gpio_dev_s *dev, +static int gpint_enable(struct gpio_dev_s *dev, bool enable); +static int gpio_setpintype(struct gpio_dev_s *dev, enum gpio_pintype_e gp_pintype); /**************************************************************************** @@ -262,8 +262,8 @@ static void bl602_gpio_intclear(uint8_t gpio_pin, uint8_t int_clear) static int bl602_gpio_interrupt(int irq, void *context, void *arg) { - FAR struct bl602_gpint_dev_s *bl602xgpint = - (FAR struct bl602_gpint_dev_s *)arg; + struct bl602_gpint_dev_s *bl602xgpint = + (struct bl602_gpint_dev_s *)arg; uint32_t time_out = 0; uint8_t gpio_pin; @@ -310,11 +310,11 @@ static int bl602_gpio_interrupt(int irq, void *context, void *arg) * ****************************************************************************/ -static int gpio_setpintype(FAR struct gpio_dev_s *dev, +static int gpio_setpintype(struct gpio_dev_s *dev, enum gpio_pintype_e gp_pintype) { - FAR struct bl602_gpint_dev_s *bl602xgpint = - (FAR struct bl602_gpint_dev_s *)dev; + struct bl602_gpint_dev_s *bl602xgpint = + (struct bl602_gpint_dev_s *)dev; uint8_t gpio_pin; uint8_t pintype = bl602xgpint->bl602gpio.gpio.gp_pintype; @@ -392,10 +392,10 @@ static int gpio_setpintype(FAR struct gpio_dev_s *dev, * ****************************************************************************/ -static int gpin_read(FAR struct gpio_dev_s *dev, FAR bool *value) +static int gpin_read(struct gpio_dev_s *dev, bool *value) { - FAR struct bl602_gpio_dev_s *bl602xgpio = - (FAR struct bl602_gpio_dev_s *)dev; + struct bl602_gpio_dev_s *bl602xgpio = + (struct bl602_gpio_dev_s *)dev; DEBUGASSERT(bl602xgpio != NULL && value != NULL); gpioinfo("Reading...\n"); @@ -412,10 +412,10 @@ static int gpin_read(FAR struct gpio_dev_s *dev, FAR bool *value) * ****************************************************************************/ -static int gpout_read(FAR struct gpio_dev_s *dev, FAR bool *value) +static int gpout_read(struct gpio_dev_s *dev, bool *value) { - FAR struct bl602_gpio_dev_s *bl602xgpio = - (FAR struct bl602_gpio_dev_s *)dev; + struct bl602_gpio_dev_s *bl602xgpio = + (struct bl602_gpio_dev_s *)dev; DEBUGASSERT(bl602xgpio != NULL && value != NULL); DEBUGASSERT(bl602xgpio->id < BOARD_NGPIOOUT); @@ -437,10 +437,10 @@ static int gpout_read(FAR struct gpio_dev_s *dev, FAR bool *value) * ****************************************************************************/ -static int gpout_write(FAR struct gpio_dev_s *dev, bool value) +static int gpout_write(struct gpio_dev_s *dev, bool value) { - FAR struct bl602_gpio_dev_s *bl602xgpio = - (FAR struct bl602_gpio_dev_s *)dev; + struct bl602_gpio_dev_s *bl602xgpio = + (struct bl602_gpio_dev_s *)dev; DEBUGASSERT(bl602xgpio != NULL); DEBUGASSERT(bl602xgpio->id < BOARD_NGPIOOUT); @@ -459,10 +459,10 @@ static int gpout_write(FAR struct gpio_dev_s *dev, bool value) * ****************************************************************************/ -static int gpint_read(FAR struct gpio_dev_s *dev, FAR bool *value) +static int gpint_read(struct gpio_dev_s *dev, bool *value) { - FAR struct bl602_gpint_dev_s *bl602xgpint = - (FAR struct bl602_gpint_dev_s *)dev; + struct bl602_gpint_dev_s *bl602xgpint = + (struct bl602_gpint_dev_s *)dev; DEBUGASSERT(bl602xgpint != NULL && value != NULL); DEBUGASSERT(bl602xgpint->bl602gpio.id < BOARD_NGPIOINT); @@ -481,10 +481,10 @@ static int gpint_read(FAR struct gpio_dev_s *dev, FAR bool *value) * ****************************************************************************/ -static int gpint_attach(FAR struct gpio_dev_s *dev, pin_interrupt_t callback) +static int gpint_attach(struct gpio_dev_s *dev, pin_interrupt_t callback) { - FAR struct bl602_gpint_dev_s *bl602xgpint = - (FAR struct bl602_gpint_dev_s *)dev; + struct bl602_gpint_dev_s *bl602xgpint = + (struct bl602_gpint_dev_s *)dev; uint8_t gpio_pin = (g_gpiointinputs[bl602xgpint->bl602gpio.id] & GPIO_PIN_MASK) >> @@ -511,10 +511,10 @@ static int gpint_attach(FAR struct gpio_dev_s *dev, pin_interrupt_t callback) * ****************************************************************************/ -static int gpint_enable(FAR struct gpio_dev_s *dev, bool enable) +static int gpint_enable(struct gpio_dev_s *dev, bool enable) { - FAR struct bl602_gpint_dev_s *bl602xgpint = - (FAR struct bl602_gpint_dev_s *)dev; + struct bl602_gpint_dev_s *bl602xgpint = + (struct bl602_gpint_dev_s *)dev; if (enable) { diff --git a/boards/risc-v/bl602/bl602evb/src/bl602_ostest.c b/boards/risc-v/bl602/bl602evb/src/bl602_ostest.c deleted file mode 100644 index 3d3f02993867e..0000000000000 --- a/boards/risc-v/bl602/bl602evb/src/bl602_ostest.c +++ /dev/null @@ -1,92 +0,0 @@ -/**************************************************************************** - * boards/risc-v/bl602/bl602evb/src/bl602_ostest.c - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. The - * ASF licenses this file to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance with the - * License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - ****************************************************************************/ - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include - -#include -#include -#include -#include - -#include - -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -/* Configuration ************************************************************/ - -#undef HAVE_FPU -#if defined(CONFIG_ARCH_FPU) && \ - !defined(CONFIG_TESTING_OSTEST_FPUTESTDISABLE) && \ - defined(CONFIG_TESTING_OSTEST_FPUSIZE) && \ - defined(CONFIG_SCHED_WAITPID) -# define HAVE_FPU 1 -#endif - -#ifdef HAVE_FPU - -#if CONFIG_TESTING_OSTEST_FPUSIZE != (4 * FPU_XCPT_REGS) -# error "CONFIG_TESTING_OSTEST_FPUSIZE has the wrong size" -#endif - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -static uint32_t g_saveregs[XCPTCONTEXT_REGS]; - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/* Given an array of size CONFIG_TESTING_OSTEST_FPUSIZE, this function will - * return the current FPU registers. - */ - -void arch_getfpu(FAR uint32_t *fpusave) -{ - irqstate_t flags; - - /* Take a snapshot of the thread context right now */ - - flags = enter_critical_section(); - riscv_saveusercontext(g_saveregs); - - /* Return only the floating register values */ - - memcpy(fpusave, &g_saveregs[INT_XCPT_REGS], (4*FPU_XCPT_REGS)); - leave_critical_section(flags); -} - -/* Given two arrays of size CONFIG_TESTING_OSTEST_FPUSIZE this function - * will compare them and return true if they are identical. - */ - -bool arch_cmpfpu(FAR const uint32_t *fpusave1, FAR const uint32_t *fpusave2) -{ - return memcmp(fpusave1, fpusave2, (4*FPU_XCPT_REGS)) == 0; -} - -#endif /* HAVE_FPU */ diff --git a/boards/risc-v/c906/smartl-c906/configs/elf/defconfig b/boards/risc-v/c906/smartl-c906/configs/elf/defconfig index 62d7a1cbd458e..a75a2cfa7c5ac 100644 --- a/boards/risc-v/c906/smartl-c906/configs/elf/defconfig +++ b/boards/risc-v/c906/smartl-c906/configs/elf/defconfig @@ -63,5 +63,4 @@ CONFIG_SYSTEM_NSH=y CONFIG_TASK_NAME_SIZE=20 CONFIG_TESTING_GETPRIME=y CONFIG_TESTING_OSTEST=y -CONFIG_TESTING_OSTEST_FPUSIZE=264 CONFIG_UART0_SERIAL_CONSOLE=y diff --git a/boards/risc-v/c906/smartl-c906/configs/fpu/defconfig b/boards/risc-v/c906/smartl-c906/configs/fpu/defconfig index d10e626689ba3..0bee31ed59a39 100644 --- a/boards/risc-v/c906/smartl-c906/configs/fpu/defconfig +++ b/boards/risc-v/c906/smartl-c906/configs/fpu/defconfig @@ -57,5 +57,4 @@ CONFIG_SYSTEM_NSH=y CONFIG_TASK_NAME_SIZE=20 CONFIG_TESTING_GETPRIME=y CONFIG_TESTING_OSTEST=y -CONFIG_TESTING_OSTEST_FPUSIZE=264 CONFIG_UART0_SERIAL_CONSOLE=y diff --git a/boards/risc-v/c906/smartl-c906/configs/knsh/defconfig b/boards/risc-v/c906/smartl-c906/configs/knsh/defconfig index 441d885080b7d..48ef0eaca1536 100644 --- a/boards/risc-v/c906/smartl-c906/configs/knsh/defconfig +++ b/boards/risc-v/c906/smartl-c906/configs/knsh/defconfig @@ -61,5 +61,4 @@ CONFIG_SYSTEM_NSH=y CONFIG_TASK_NAME_SIZE=20 CONFIG_TESTING_GETPRIME=y CONFIG_TESTING_OSTEST=y -CONFIG_TESTING_OSTEST_FPUSIZE=264 CONFIG_UART0_SERIAL_CONSOLE=y diff --git a/boards/risc-v/c906/smartl-c906/configs/module/defconfig b/boards/risc-v/c906/smartl-c906/configs/module/defconfig index 7f7238ef2037b..c4bd41717ea54 100644 --- a/boards/risc-v/c906/smartl-c906/configs/module/defconfig +++ b/boards/risc-v/c906/smartl-c906/configs/module/defconfig @@ -65,5 +65,4 @@ CONFIG_SYSTEM_NSH=y CONFIG_TASK_NAME_SIZE=20 CONFIG_TESTING_GETPRIME=y CONFIG_TESTING_OSTEST=y -CONFIG_TESTING_OSTEST_FPUSIZE=264 CONFIG_UART0_SERIAL_CONSOLE=y diff --git a/boards/risc-v/c906/smartl-c906/configs/nsh/defconfig b/boards/risc-v/c906/smartl-c906/configs/nsh/defconfig index 8cbacfd62e1ae..193335211f5e2 100644 --- a/boards/risc-v/c906/smartl-c906/configs/nsh/defconfig +++ b/boards/risc-v/c906/smartl-c906/configs/nsh/defconfig @@ -56,5 +56,4 @@ CONFIG_SYSTEM_NSH=y CONFIG_TASK_NAME_SIZE=20 CONFIG_TESTING_GETPRIME=y CONFIG_TESTING_OSTEST=y -CONFIG_TESTING_OSTEST_FPUSIZE=264 CONFIG_UART0_SERIAL_CONSOLE=y diff --git a/boards/risc-v/c906/smartl-c906/configs/sotest/defconfig b/boards/risc-v/c906/smartl-c906/configs/sotest/defconfig index 1327054682859..fb24a30245b28 100644 --- a/boards/risc-v/c906/smartl-c906/configs/sotest/defconfig +++ b/boards/risc-v/c906/smartl-c906/configs/sotest/defconfig @@ -63,5 +63,4 @@ CONFIG_SYSTEM_NSH=y CONFIG_TASK_NAME_SIZE=20 CONFIG_TESTING_GETPRIME=y CONFIG_TESTING_OSTEST=y -CONFIG_TESTING_OSTEST_FPUSIZE=264 CONFIG_UART0_SERIAL_CONSOLE=y diff --git a/boards/risc-v/c906/smartl-c906/scripts/Make.defs b/boards/risc-v/c906/smartl-c906/scripts/Make.defs index deb6d4c002e91..2dbbcfedcf6ec 100644 --- a/boards/risc-v/c906/smartl-c906/scripts/Make.defs +++ b/boards/risc-v/c906/smartl-c906/scripts/Make.defs @@ -30,17 +30,6 @@ endif ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT) -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g - ASARCHCPUFLAGS += -Wa,-g -endif - -MAXOPTIMIZATION = -Os - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - # The following options are for the toolchain from T-HEAD. # For more info ahout the T-HEAD ISA extensions, please refer to the C906 user guide. # ARCHCPUFLAGS = -march=rv64gcxthead -mabi=lp64d -mtune=c906 -mcmodel=medany @@ -48,8 +37,6 @@ endif ARCHCPUFLAGS += -mcmodel=medany -ARCHCFLAGS = -fno-common -ffunction-sections -fdata-sections -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new -fno-rtti ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef @@ -58,7 +45,7 @@ CPICFLAGS = $(ARCHPICFLAGS) $(CFLAGS) CXXFLAGS = $(ARCHCXXFLAGS) $(ARCHWARNINGSXX) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHXXINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) -pipe CXXPICFLAGS = $(ARCHPICFLAGS) $(CXXFLAGS) CPPFLAGS = $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) -AFLAGS += $(CFLAGS) -D__ASSEMBLY__ $(ASARCHCPUFLAGS) +AFLAGS += $(CFLAGS) -D__ASSEMBLY__ # Loadable module definitions @@ -73,8 +60,8 @@ CELFFLAGS = $(CFLAGS) CXXELFFLAGS = $(CXXFLAGS) LDELFFLAGS = -r -e main -LDELFFLAGS += -T $(call CONVERT_PATH,$(BOARD_DIR)$(DELIM)scripts$(DELIM)gnu-elf.ld) +LDELFFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)/binfmt/libelf/gnu-elf.ld) # File extensions -LDFLAGS += --gc-sections -melf64lriscv +LDFLAGS += -melf64lriscv diff --git a/boards/risc-v/c906/smartl-c906/scripts/gnu-elf.ld b/boards/risc-v/c906/smartl-c906/scripts/gnu-elf.ld deleted file mode 100644 index bc6180c021c48..0000000000000 --- a/boards/risc-v/c906/smartl-c906/scripts/gnu-elf.ld +++ /dev/null @@ -1,115 +0,0 @@ -/**************************************************************************** - * boards/risc-v/c906/smartl-c906/scripts/gnu-elf.ld - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. The - * ASF licenses this file to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance with the - * License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - ****************************************************************************/ - -SECTIONS -{ - .text 0x00000000 : - { - _stext = . ; - *(.text) - *(.text.*) - *(.gnu.warning) - *(.stub) - *(.glue_7) - *(.glue_7t) - *(.jcr) - - /* C++ support: The .init and .fini sections contain specific logic - * to manage static constructors and destructors. - */ - - *(.gnu.linkonce.t.*) - *(.init) /* Old ABI */ - *(.fini) /* Old ABI */ - _etext = . ; - } - - .rodata : - { - _srodata = . ; - *(.rodata) - *(.rodata1) - *(.rodata.*) - *(.gnu.linkonce.r*) - _erodata = . ; - } - - .data : - { - _sdata = . ; - *(.data) - *(.data1) - *(.data.*) - *(.gnu.linkonce.d*) - . = ALIGN(4); - _edata = . ; - } - - /* C++ support. For each global and static local C++ object, - * GCC creates a small subroutine to construct the object. Pointers - * to these routines (not the routines themselves) are stored as - * simple, linear arrays in the .ctors section of the object file. - * Similarly, pointers to global/static destructor routines are - * stored in .dtors. - */ - - .ctors : - { - _sctors = . ; - *(.ctors) /* Old ABI: Unallocated */ - *(.init_array) /* New ABI: Allocated */ - _edtors = . ; - } - - .dtors : - { - _sdtors = . ; - *(.dtors) /* Old ABI: Unallocated */ - *(.fini_array) /* New ABI: Allocated */ - _edtors = . ; - } - - .bss : - { - _sbss = . ; - *(.bss) - *(.bss.*) - *(.sbss) - *(.sbss.*) - *(.gnu.linkonce.b*) - *(COMMON) - _ebss = . ; - } - - /* Stabs debugging sections. */ - - .stab 0 : { *(.stab) } - .stabstr 0 : { *(.stabstr) } - .stab.excl 0 : { *(.stab.excl) } - .stab.exclstr 0 : { *(.stab.exclstr) } - .stab.index 0 : { *(.stab.index) } - .stab.indexstr 0 : { *(.stab.indexstr) } - .comment 0 : { *(.comment) } - .debug_abbrev 0 : { *(.debug_abbrev) } - .debug_info 0 : { *(.debug_info) } - .debug_line 0 : { *(.debug_line) } - .debug_pubnames 0 : { *(.debug_pubnames) } - .debug_aranges 0 : { *(.debug_aranges) } -} diff --git a/boards/risc-v/c906/smartl-c906/src/Makefile b/boards/risc-v/c906/smartl-c906/src/Makefile index 86dffec6b37fc..78c59d08eec82 100644 --- a/boards/risc-v/c906/smartl-c906/src/Makefile +++ b/boards/risc-v/c906/smartl-c906/src/Makefile @@ -30,8 +30,4 @@ ifeq ($(CONFIG_ARCH_LEDS),y) CSRCS += c906_leds.c endif -ifeq ($(CONFIG_ARCH_FPU),y) -CSRCS += c906_ostest.c -endif - include $(TOPDIR)/boards/Board.mk diff --git a/boards/risc-v/c906/smartl-c906/src/c906_ostest.c b/boards/risc-v/c906/smartl-c906/src/c906_ostest.c deleted file mode 100644 index f3a5c8a6e4981..0000000000000 --- a/boards/risc-v/c906/smartl-c906/src/c906_ostest.c +++ /dev/null @@ -1,92 +0,0 @@ -/**************************************************************************** - * boards/risc-v/c906/smartl-c906/src/c906_ostest.c - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. The - * ASF licenses this file to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance with the - * License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - ****************************************************************************/ - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include - -#include -#include -#include -#include - -#include - -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -/* Configuration ************************************************************/ - -#undef HAVE_FPU -#if defined(CONFIG_ARCH_FPU) && \ - !defined(CONFIG_TESTING_OSTEST_FPUTESTDISABLE) && \ - defined(CONFIG_TESTING_OSTEST_FPUSIZE) && \ - defined(CONFIG_SCHED_WAITPID) -# define HAVE_FPU 1 -#endif - -#ifdef HAVE_FPU - -#if CONFIG_TESTING_OSTEST_FPUSIZE != (8 * FPU_XCPT_REGS) -# error "CONFIG_TESTING_OSTEST_FPUSIZE has the wrong size" -#endif - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -static uintptr_t g_saveregs[XCPTCONTEXT_REGS]; - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/* Given an array of size CONFIG_TESTING_OSTEST_FPUSIZE, this function will - * return the current FPU registers. - */ - -void arch_getfpu(FAR uint32_t *fpusave) -{ - irqstate_t flags; - - /* Take a snapshot of the thread context right now */ - - flags = enter_critical_section(); - riscv_saveusercontext(g_saveregs); - - /* Return only the floating register values */ - - memcpy(fpusave, &g_saveregs[INT_XCPT_REGS], INT_REG_SIZE * FPU_XCPT_REGS); - leave_critical_section(flags); -} - -/* Given two arrays of size CONFIG_TESTING_OSTEST_FPUSIZE this function - * will compare them and return true if they are identical. - */ - -bool arch_cmpfpu(FAR const uint32_t *fpusave1, FAR const uint32_t *fpusave2) -{ - return memcmp(fpusave1, fpusave2, INT_REG_SIZE * FPU_XCPT_REGS) == 0; -} - -#endif /* HAVE_FPU */ diff --git a/boards/risc-v/esp32c3/esp32c3-devkit/configs/cxx/defconfig b/boards/risc-v/esp32c3/esp32c3-devkit/configs/cxx/defconfig new file mode 100644 index 0000000000000..6b8729b3c4d1e --- /dev/null +++ b/boards/risc-v/esp32c3/esp32c3-devkit/configs/cxx/defconfig @@ -0,0 +1,49 @@ +# +# This file is autogenerated: PLEASE DO NOT EDIT IT. +# +# You can use "make menuconfig" to make any modifications to the installed .config file. +# You can then do "make savedefconfig" to generate a new defconfig file that includes your +# modifications. +# +# CONFIG_NSH_ARGCAT is not set +# CONFIG_NSH_CMDOPT_HEXDUMP is not set +# CONFIG_NSH_CMDPARMS is not set +CONFIG_ARCH="risc-v" +CONFIG_ARCH_BOARD="esp32c3-devkit" +CONFIG_ARCH_BOARD_ESP32C3_DEVKIT=y +CONFIG_ARCH_CHIP="esp32c3" +CONFIG_ARCH_CHIP_ESP32C3=y +CONFIG_ARCH_CHIP_ESP32C3WROOM02=y +CONFIG_ARCH_INTERRUPTSTACK=1536 +CONFIG_ARCH_RISCV=y +CONFIG_ARCH_STACKDUMP=y +CONFIG_BOARD_LOOPSPERMSEC=15000 +CONFIG_BUILTIN=y +CONFIG_DEV_ZERO=y +CONFIG_FS_PROCFS=y +CONFIG_HAVE_CXX=y +CONFIG_IDLETHREAD_STACKSIZE=2048 +CONFIG_INIT_ENTRYPOINT="nsh_main" +CONFIG_INTELHEX_BINARY=y +CONFIG_LIBCXX=y +CONFIG_LIBCXXABI=y +CONFIG_LIBC_PERROR_STDOUT=y +CONFIG_LIBC_STRERROR=y +CONFIG_LIBM=y +CONFIG_NFILE_DESCRIPTORS_PER_BLOCK=6 +CONFIG_NSH_ARCHINIT=y +CONFIG_NSH_BUILTIN_APPS=y +CONFIG_NSH_FILEIOSIZE=512 +CONFIG_NSH_READLINE=y +CONFIG_NSH_STRERROR=y +CONFIG_PREALLOC_TIMERS=0 +CONFIG_RAW_BINARY=y +CONFIG_RR_INTERVAL=200 +CONFIG_SCHED_ATEXIT=y +CONFIG_SCHED_WAITPID=y +CONFIG_START_DAY=29 +CONFIG_START_MONTH=11 +CONFIG_START_YEAR=2019 +CONFIG_SYSTEM_NSH=y +CONFIG_TESTING_CXXTEST=y +CONFIG_UART0_SERIAL_CONSOLE=y diff --git a/boards/risc-v/esp32c3/esp32c3-devkit/configs/twai/defconfig b/boards/risc-v/esp32c3/esp32c3-devkit/configs/twai/defconfig new file mode 100644 index 0000000000000..8defe06c69d74 --- /dev/null +++ b/boards/risc-v/esp32c3/esp32c3-devkit/configs/twai/defconfig @@ -0,0 +1,48 @@ +# +# This file is autogenerated: PLEASE DO NOT EDIT IT. +# +# You can use "make menuconfig" to make any modifications to the installed .config file. +# You can then do "make savedefconfig" to generate a new defconfig file that includes your +# modifications. +# +# CONFIG_NSH_ARGCAT is not set +# CONFIG_NSH_CMDOPT_HEXDUMP is not set +# CONFIG_NSH_CMDPARMS is not set +CONFIG_ARCH="risc-v" +CONFIG_ARCH_BOARD="esp32c3-devkit" +CONFIG_ARCH_BOARD_ESP32C3_DEVKIT=y +CONFIG_ARCH_CHIP="esp32c3" +CONFIG_ARCH_CHIP_ESP32C3=y +CONFIG_ARCH_CHIP_ESP32C3MINI1=y +CONFIG_ARCH_INTERRUPTSTACK=1536 +CONFIG_ARCH_RISCV=y +CONFIG_ARCH_STACKDUMP=y +CONFIG_BOARD_LOOPSPERMSEC=15000 +CONFIG_BUILTIN=y +CONFIG_DEV_ZERO=y +CONFIG_ESP32C3_TWAI0=y +CONFIG_EXAMPLES_CAN=y +CONFIG_FS_PROCFS=y +CONFIG_FS_ROMFS=y +CONFIG_IDLETHREAD_STACKSIZE=2048 +CONFIG_INIT_ENTRYPOINT="nsh_main" +CONFIG_INTELHEX_BINARY=y +CONFIG_LIBC_PERROR_STDOUT=y +CONFIG_LIBC_STRERROR=y +CONFIG_NFILE_DESCRIPTORS_PER_BLOCK=6 +CONFIG_NSH_ARCHINIT=y +CONFIG_NSH_BUILTIN_APPS=y +CONFIG_NSH_FILEIOSIZE=512 +CONFIG_NSH_READLINE=y +CONFIG_NSH_ROMFSETC=y +CONFIG_NSH_STRERROR=y +CONFIG_PREALLOC_TIMERS=0 +CONFIG_PRIORITY_INHERITANCE=y +CONFIG_RAW_BINARY=y +CONFIG_RR_INTERVAL=200 +CONFIG_SCHED_WAITPID=y +CONFIG_START_DAY=29 +CONFIG_START_MONTH=11 +CONFIG_START_YEAR=2019 +CONFIG_SYSTEM_NSH=y +CONFIG_UART0_SERIAL_CONSOLE=y diff --git a/boards/risc-v/esp32c3/esp32c3-devkit/scripts/Make.defs b/boards/risc-v/esp32c3/esp32c3-devkit/scripts/Make.defs index f15e33a7cf734..db7f6e5eda768 100644 --- a/boards/risc-v/esp32c3/esp32c3-devkit/scripts/Make.defs +++ b/boards/risc-v/esp32c3/esp32c3-devkit/scripts/Make.defs @@ -33,16 +33,8 @@ endif ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)esp32c3_rom.ld -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - -ARCHCFLAGS = -fno-common -ffunction-sections -fdata-sections -msmall-data-limit=0 -ARCHCXXFLAGS = $(ARCHCFLAGS) -fno-exceptions -fcheck-new -fno-rtti +ARCHCFLAGS += -msmall-data-limit=0 +ARCHCXXFLAGS += -msmall-data-limit=0 ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic @@ -63,11 +55,10 @@ LDMODULEFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)/libs/libc/modlib/gnu-elf.ld) # ELF module definitions -CELFFLAGS = $(CFLAGS) -fno-common -CXXELFFLAGS = $(CXXFLAGS) -fno-common +CELFFLAGS = $(CFLAGS) +CXXELFFLAGS = $(CXXFLAGS) LDELFFLAGS = -melf32lriscv -r -e main LDELFFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)$(DELIM)binfmt$(DELIM)libelf$(DELIM)gnu-elf.ld) -LDFLAGS += -Map=$(call CONVERT_PATH,$(TOPDIR)/nuttx.map) --cref -LDFLAGS += --gc-sections -melf32lriscv +LDFLAGS += -melf32lriscv diff --git a/boards/risc-v/esp32c3/esp32c3-devkit/scripts/esp32c3.ld b/boards/risc-v/esp32c3/esp32c3-devkit/scripts/esp32c3.ld index 8910d4c5dc751..f5f48fa678a56 100644 --- a/boards/risc-v/esp32c3/esp32c3-devkit/scripts/esp32c3.ld +++ b/boards/risc-v/esp32c3/esp32c3-devkit/scripts/esp32c3.ld @@ -161,13 +161,14 @@ SECTIONS KEEP(*(.eh_frame)) . = (. + 7) & ~ 3; - /* C++ constructor and destructor tables: */ + /* C++ constructor and destructor tables: + * RISC-V GCC is configured with --enable-initfini-array so it emits an + * .init_array section instead. + */ _sinit = ABSOLUTE(.); - KEEP (*crtbegin.o(.ctors)) - KEEP (*(EXCLUDE_FILE (*crtend.o) .ctors)) - KEEP (*(SORT(.ctors.*))) - KEEP (*(.ctors)) + KEEP (*(EXCLUDE_FILE (*crtend.* *crtbegin.*) .init_array.*)) + KEEP (*(EXCLUDE_FILE (*crtend.* *crtbegin.*) .init_array)) _einit = ABSOLUTE(.); KEEP (*crtbegin.o(.dtors)) KEEP (*(EXCLUDE_FILE (*crtend.o) .dtors)) diff --git a/boards/risc-v/esp32c3/esp32c3-devkit/src/Makefile b/boards/risc-v/esp32c3/esp32c3-devkit/src/Makefile index 61ae8cff6f589..8b0e0bbf40707 100644 --- a/boards/risc-v/esp32c3/esp32c3-devkit/src/Makefile +++ b/boards/risc-v/esp32c3/esp32c3-devkit/src/Makefile @@ -62,6 +62,10 @@ ifeq ($(CONFIG_I2C_DRIVER),y) CSRCS += esp32c3_i2c.c endif +ifeq ($(CONFIG_CAN),y) +CSRCS += esp32c3_twai.c +endif + ifeq ($(CONFIG_SENSORS_BMP180),y) CSRCS += esp32c3_bmp180.c endif @@ -104,7 +108,7 @@ endif ifeq ($(CONFIG_NSH_ROMFSETC),y) ifneq ($(CONFIG_NSH_CUSTOMROMFS),y) - RCSRCS = etc/init.d/rcS + RCSRCS = etc/init.d/rc.sysinit etc/init.d/rcS RCRAWS = etc/group etc/passwd endif endif diff --git a/boards/risc-v/esp32c3/esp32c3-devkit/src/README.txt b/boards/risc-v/esp32c3/esp32c3-devkit/src/README.txt index 209f760b46a55..e9af7c48e60c6 100644 --- a/boards/risc-v/esp32c3/esp32c3-devkit/src/README.txt +++ b/boards/risc-v/esp32c3/esp32c3-devkit/src/README.txt @@ -3,10 +3,10 @@ README Overview -------- - This directory contains logic to support a custom ROMFS start-up script. - This startup script is used by by the NSH when it starts provided that - CONFIG_NSH_ARCHROMFS=y. The script provides a ROMFS volume that will be - mounted at /etc and will look like this at run-time: + This directory contains logic to support a custom ROMFS system-init script + and start-up script. These scripts are used by by the NSH when it starts + provided that CONFIG_NSH_ARCHROMFS=y. These scripts provide a ROMFS volume + that will be mounted at /etc and will look like this at run-time: NuttShell (NSH) NuttX-10.1.0-RC1 MOTD: username=admin password=Administrator @@ -19,10 +19,11 @@ README /etc/init.d: dr-xr-xr-x 0 .. -r--r--r-- 110 rcS + -r--r--r-- 110 rc.sysinit nsh> - /etc/init.d/rcS is the start-up script; /etc/passwd is a the password - file. It supports a single user: + /etc/init.d/rc.sysinit is system init script; /etc/init.d/rcS is the start-up + script; /etc/passwd is a the password file. It supports a single user: USERNAME: admin PASSWORD: Administrator diff --git a/boards/risc-v/esp32c3/esp32c3-devkit/src/esp32c3-devkit.h b/boards/risc-v/esp32c3/esp32c3-devkit/src/esp32c3-devkit.h index a58b8e4e26d60..582eba795c7b9 100644 --- a/boards/risc-v/esp32c3/esp32c3-devkit/src/esp32c3-devkit.h +++ b/boards/risc-v/esp32c3/esp32c3-devkit/src/esp32c3-devkit.h @@ -149,6 +149,22 @@ int board_spislavedev_initialize(int bus); int board_i2c_init(void); #endif +/**************************************************************************** + * Name: board_twai_setup + * + * Description: + * Configure the TWAI driver. + * + * Returned Value: + * Zero (OK) is returned on success; A negated errno value is returned + * to indicate the nature of any failure. + * + ****************************************************************************/ + +#ifdef CONFIG_CAN +int esp32c3_twai_setup(void); +#endif + /**************************************************************************** * Name: board_oneshot_init * diff --git a/boards/risc-v/esp32c3/esp32c3-devkit/src/esp32c3_board_spi.c b/boards/risc-v/esp32c3/esp32c3-devkit/src/esp32c3_board_spi.c index a5c336da31176..9030f6c9fd93e 100644 --- a/boards/risc-v/esp32c3/esp32c3-devkit/src/esp32c3_board_spi.c +++ b/boards/risc-v/esp32c3/esp32c3-devkit/src/esp32c3_board_spi.c @@ -46,7 +46,7 @@ #ifdef CONFIG_ESP32C3_SPI2 -uint8_t esp32c3_spi2_status(FAR struct spi_dev_s *dev, uint32_t devid) +uint8_t esp32c3_spi2_status(struct spi_dev_s *dev, uint32_t devid) { uint8_t status = 0; @@ -61,10 +61,8 @@ uint8_t esp32c3_spi2_status(FAR struct spi_dev_s *dev, uint32_t devid) #if defined(CONFIG_ESP32C3_SPI2) && defined(CONFIG_SPI_CMDDATA) -int esp32c3_spi2_cmddata(FAR struct spi_dev_s *dev, uint32_t devid, bool cmd) +int esp32c3_spi2_cmddata(struct spi_dev_s *dev, uint32_t devid, bool cmd) { -#if defined(CONFIG_LCD_ST7735) || defined(CONFIG_LCD_ST7789) || \ - defined(CONFIG_LCD_GC9A01) if (devid == SPIDEV_DISPLAY(0)) { /* This is the Data/Command control pad which determines whether the @@ -76,7 +74,6 @@ int esp32c3_spi2_cmddata(FAR struct spi_dev_s *dev, uint32_t devid, bool cmd) return OK; } -#endif spiinfo("devid: %" PRIu32 " CMD: %s\n", devid, cmd ? "command" : "data"); diff --git a/boards/risc-v/esp32c3/esp32c3-devkit/src/esp32c3_board_spidev.c b/boards/risc-v/esp32c3/esp32c3-devkit/src/esp32c3_board_spidev.c index 2320a039650f6..f55215d01bc36 100644 --- a/boards/risc-v/esp32c3/esp32c3-devkit/src/esp32c3_board_spidev.c +++ b/boards/risc-v/esp32c3/esp32c3-devkit/src/esp32c3_board_spidev.c @@ -47,7 +47,7 @@ int board_spidev_initialize(int port) { int ret; - FAR struct spi_dev_s *spi; + struct spi_dev_s *spi; syslog(LOG_INFO, "Initializing /dev/spi%d...\n", port); diff --git a/boards/risc-v/esp32c3/esp32c3-devkit/src/esp32c3_board_spislavedev.c b/boards/risc-v/esp32c3/esp32c3-devkit/src/esp32c3_board_spislavedev.c index 69bf48e60cea0..3869f9f5686d2 100644 --- a/boards/risc-v/esp32c3/esp32c3-devkit/src/esp32c3_board_spislavedev.c +++ b/boards/risc-v/esp32c3/esp32c3-devkit/src/esp32c3_board_spislavedev.c @@ -55,7 +55,7 @@ int board_spislavedev_initialize(int bus) { int ret; - FAR struct spi_slave_ctrlr_s *ctrlr; + struct spi_slave_ctrlr_s *ctrlr; spiinfo("Initializing /dev/spislv%d...\n", bus); diff --git a/boards/risc-v/esp32c3/esp32c3-devkit/src/esp32c3_bringup.c b/boards/risc-v/esp32c3/esp32c3-devkit/src/esp32c3_bringup.c index 0ecca7b81ae6d..b7b5f5e8fef2d 100644 --- a/boards/risc-v/esp32c3/esp32c3-devkit/src/esp32c3_bringup.c +++ b/boards/risc-v/esp32c3/esp32c3-devkit/src/esp32c3_bringup.c @@ -220,6 +220,17 @@ int esp32c3_bringup(void) } #endif +#ifdef CONFIG_CAN + + /* Initialize TWAI and register the TWAI driver. */ + + ret = esp32c3_twai_setup(); + if (ret < 0) + { + syslog(LOG_ERR, "ERROR: esp32c3_twai_setup failed: %d\n", ret); + } +#endif + #ifdef CONFIG_SENSORS_BMP180 /* Try to register BMP180 device in I2C0 */ diff --git a/boards/risc-v/esp32c3/esp32c3-devkit/src/esp32c3_gc9a01.c b/boards/risc-v/esp32c3/esp32c3-devkit/src/esp32c3_gc9a01.c index 06d3435dea36b..74381f6ea3eb8 100644 --- a/boards/risc-v/esp32c3/esp32c3-devkit/src/esp32c3_gc9a01.c +++ b/boards/risc-v/esp32c3/esp32c3-devkit/src/esp32c3_gc9a01.c @@ -115,7 +115,7 @@ int board_lcd_initialize(void) * ****************************************************************************/ -FAR struct lcd_dev_s *board_lcd_getdev(int devno) +struct lcd_dev_s *board_lcd_getdev(int devno) { g_lcd = gc9a01_lcdinitialize(g_spidev); if (!g_lcd) diff --git a/boards/risc-v/esp32c3/esp32c3-devkit/src/esp32c3_gpio.c b/boards/risc-v/esp32c3/esp32c3-devkit/src/esp32c3_gpio.c index 2fdb5cb06347f..13576e6f1fc55 100644 --- a/boards/risc-v/esp32c3/esp32c3-devkit/src/esp32c3_gpio.c +++ b/boards/risc-v/esp32c3/esp32c3-devkit/src/esp32c3_gpio.c @@ -82,15 +82,15 @@ struct esp32c3gpint_dev_s ****************************************************************************/ #if BOARD_NGPIOOUT > 0 -static int gpout_read(FAR struct gpio_dev_s *dev, FAR bool *value); -static int gpout_write(FAR struct gpio_dev_s *dev, bool value); +static int gpout_read(struct gpio_dev_s *dev, bool *value); +static int gpout_write(struct gpio_dev_s *dev, bool value); #endif #if BOARD_NGPIOINT > 0 -static int gpint_read(FAR struct gpio_dev_s *dev, FAR bool *value); -static int gpint_attach(FAR struct gpio_dev_s *dev, +static int gpint_read(struct gpio_dev_s *dev, bool *value); +static int gpint_attach(struct gpio_dev_s *dev, pin_interrupt_t callback); -static int gpint_enable(FAR struct gpio_dev_s *dev, bool enable); +static int gpint_enable(struct gpio_dev_s *dev, bool enable); #endif /**************************************************************************** @@ -144,10 +144,10 @@ static struct esp32c3gpint_dev_s g_gpint[BOARD_NGPIOINT]; ****************************************************************************/ #if BOARD_NGPIOOUT > 0 -static int gpout_read(FAR struct gpio_dev_s *dev, FAR bool *value) +static int gpout_read(struct gpio_dev_s *dev, bool *value) { - FAR struct esp32c3gpio_dev_s *esp32c3gpio = - (FAR struct esp32c3gpio_dev_s *)dev; + struct esp32c3gpio_dev_s *esp32c3gpio = + (struct esp32c3gpio_dev_s *)dev; DEBUGASSERT(esp32c3gpio != NULL && value != NULL); DEBUGASSERT(esp32c3gpio->id < BOARD_NGPIOOUT); @@ -161,10 +161,10 @@ static int gpout_read(FAR struct gpio_dev_s *dev, FAR bool *value) * Name: gpout_write ****************************************************************************/ -static int gpout_write(FAR struct gpio_dev_s *dev, bool value) +static int gpout_write(struct gpio_dev_s *dev, bool value) { - FAR struct esp32c3gpio_dev_s *esp32c3gpio = - (FAR struct esp32c3gpio_dev_s *)dev; + struct esp32c3gpio_dev_s *esp32c3gpio = + (struct esp32c3gpio_dev_s *)dev; DEBUGASSERT(esp32c3gpio != NULL); DEBUGASSERT(esp32c3gpio->id < BOARD_NGPIOOUT); @@ -182,8 +182,8 @@ static int gpout_write(FAR struct gpio_dev_s *dev, bool value) #if BOARD_NGPIOINT > 0 static int esp32c3gpio_interrupt(int irq, void *context, void *arg) { - FAR struct esp32c3gpint_dev_s *esp32c3gpint = - (FAR struct esp32c3gpint_dev_s *)arg; + struct esp32c3gpint_dev_s *esp32c3gpint = + (struct esp32c3gpint_dev_s *)arg; DEBUGASSERT(esp32c3gpint != NULL && esp32c3gpint->callback != NULL); gpioinfo("Interrupt! callback=%p\n", esp32c3gpint->callback); @@ -197,10 +197,10 @@ static int esp32c3gpio_interrupt(int irq, void *context, void *arg) * Name: gpint_read ****************************************************************************/ -static int gpint_read(FAR struct gpio_dev_s *dev, FAR bool *value) +static int gpint_read(struct gpio_dev_s *dev, bool *value) { - FAR struct esp32c3gpint_dev_s *esp32c3gpint = - (FAR struct esp32c3gpint_dev_s *)dev; + struct esp32c3gpint_dev_s *esp32c3gpint = + (struct esp32c3gpint_dev_s *)dev; DEBUGASSERT(esp32c3gpint != NULL && value != NULL); DEBUGASSERT(esp32c3gpint->esp32c3gpio.id < BOARD_NGPIOINT); @@ -214,11 +214,11 @@ static int gpint_read(FAR struct gpio_dev_s *dev, FAR bool *value) * Name: gpint_attach ****************************************************************************/ -static int gpint_attach(FAR struct gpio_dev_s *dev, +static int gpint_attach(struct gpio_dev_s *dev, pin_interrupt_t callback) { - FAR struct esp32c3gpint_dev_s *esp32c3gpint = - (FAR struct esp32c3gpint_dev_s *)dev; + struct esp32c3gpint_dev_s *esp32c3gpint = + (struct esp32c3gpint_dev_s *)dev; int irq = ESP32C3_PIN2IRQ(g_gpiointinputs[esp32c3gpint->esp32c3gpio.id]); int ret; @@ -245,10 +245,10 @@ static int gpint_attach(FAR struct gpio_dev_s *dev, * Name: gpint_enable ****************************************************************************/ -static int gpint_enable(FAR struct gpio_dev_s *dev, bool enable) +static int gpint_enable(struct gpio_dev_s *dev, bool enable) { - FAR struct esp32c3gpint_dev_s *esp32c3gpint = - (FAR struct esp32c3gpint_dev_s *)dev; + struct esp32c3gpint_dev_s *esp32c3gpint = + (struct esp32c3gpint_dev_s *)dev; int irq = ESP32C3_PIN2IRQ(g_gpiointinputs[esp32c3gpint->esp32c3gpio.id]); if (enable) diff --git a/boards/risc-v/esp32c3/esp32c3-devkit/src/esp32c3_i2c.c b/boards/risc-v/esp32c3/esp32c3-devkit/src/esp32c3_i2c.c index b7db9698e4448..6896c019172fd 100644 --- a/boards/risc-v/esp32c3/esp32c3-devkit/src/esp32c3_i2c.c +++ b/boards/risc-v/esp32c3/esp32c3-devkit/src/esp32c3_i2c.c @@ -53,7 +53,7 @@ int board_i2c_init(void) int ret = OK; #ifdef CONFIG_ESP32C3_I2C0 - FAR struct i2c_master_s *i2c; + struct i2c_master_s *i2c; i2c = esp32c3_i2cbus_initialize(0); diff --git a/boards/risc-v/esp32c3/esp32c3-devkit/src/esp32c3_oneshot.c b/boards/risc-v/esp32c3/esp32c3-devkit/src/esp32c3_oneshot.c index 60a40c573752a..3ac14d0b8e7aa 100644 --- a/boards/risc-v/esp32c3/esp32c3-devkit/src/esp32c3_oneshot.c +++ b/boards/risc-v/esp32c3/esp32c3-devkit/src/esp32c3_oneshot.c @@ -54,7 +54,7 @@ int board_oneshot_init(int timer, uint16_t resolution) { int ret = OK; - FAR struct oneshot_lowerhalf_s *os_lower = NULL; + struct oneshot_lowerhalf_s *os_lower = NULL; os_lower = oneshot_initialize(timer, resolution); if (os_lower != NULL) diff --git a/boards/risc-v/esp32c3/esp32c3-devkit/src/esp32c3_spiflash.c b/boards/risc-v/esp32c3/esp32c3-devkit/src/esp32c3_spiflash.c index 0c244bd7741a5..8d40796925280 100644 --- a/boards/risc-v/esp32c3/esp32c3-devkit/src/esp32c3_spiflash.c +++ b/boards/risc-v/esp32c3/esp32c3-devkit/src/esp32c3_spiflash.c @@ -139,7 +139,7 @@ static const struct ota_partition_s g_ota_partition_table[] = #ifdef CONFIG_ESP32C3_HAVE_OTA_PARTITION static int init_ota_partitions(void) { - FAR struct mtd_dev_s *mtd; + struct mtd_dev_s *mtd; #ifdef CONFIG_BCH char blockdev[18]; #endif @@ -193,7 +193,7 @@ static int init_ota_partitions(void) ****************************************************************************/ #if defined (CONFIG_ESP32C3_SPIFLASH_SMARTFS) -static int setup_smartfs(int smartn, FAR struct mtd_dev_s *mtd, +static int setup_smartfs(int smartn, struct mtd_dev_s *mtd, const char *mnt_pt) { int ret = OK; @@ -254,7 +254,7 @@ static int setup_smartfs(int smartn, FAR struct mtd_dev_s *mtd, ****************************************************************************/ #if defined (CONFIG_ESP32C3_SPIFLASH_LITTLEFS) -static int setup_littlefs(const char *path, FAR struct mtd_dev_s *mtd, +static int setup_littlefs(const char *path, struct mtd_dev_s *mtd, const char *mnt_pt, int priv) { int ret = OK; @@ -303,7 +303,7 @@ static int setup_littlefs(const char *path, FAR struct mtd_dev_s *mtd, ****************************************************************************/ #if defined (CONFIG_ESP32C3_SPIFLASH_SPIFFS) -static int setup_spiffs(const char *path, FAR struct mtd_dev_s *mtd, +static int setup_spiffs(const char *path, struct mtd_dev_s *mtd, const char *mnt_pt, int priv) { int ret = OK; @@ -346,7 +346,7 @@ static int setup_spiffs(const char *path, FAR struct mtd_dev_s *mtd, ****************************************************************************/ #if defined (CONFIG_ESP32C3_SPIFLASH_NXFFS) -static int setup_nxffs(FAR struct mtd_dev_s *mtd, const char *mnt_pt) +static int setup_nxffs(struct mtd_dev_s *mtd, const char *mnt_pt) { int ret = OK; @@ -386,7 +386,7 @@ static int setup_nxffs(FAR struct mtd_dev_s *mtd, const char *mnt_pt) static int init_wifi_partition(void) { int ret = OK; - FAR struct mtd_dev_s *mtd; + struct mtd_dev_s *mtd; mtd = esp32c3_spiflash_alloc_mtdpart(CONFIG_ESP32C3_WIFI_MTD_OFFSET, CONFIG_ESP32C3_WIFI_MTD_SIZE, @@ -451,7 +451,7 @@ static int init_wifi_partition(void) static int init_storage_partition(void) { int ret = OK; - FAR struct mtd_dev_s *mtd; + struct mtd_dev_s *mtd; mtd = esp32c3_spiflash_alloc_mtdpart(CONFIG_ESP32C3_STORAGE_MTD_OFFSET, CONFIG_ESP32C3_STORAGE_MTD_SIZE, diff --git a/boards/risc-v/esp32c3/esp32c3-devkit/src/esp32c3_st7735.c b/boards/risc-v/esp32c3/esp32c3-devkit/src/esp32c3_st7735.c index b12b928f8e1c0..3e191f223da52 100644 --- a/boards/risc-v/esp32c3/esp32c3-devkit/src/esp32c3_st7735.c +++ b/boards/risc-v/esp32c3/esp32c3-devkit/src/esp32c3_st7735.c @@ -115,7 +115,7 @@ int board_lcd_initialize(void) * ****************************************************************************/ -FAR struct lcd_dev_s *board_lcd_getdev(int devno) +struct lcd_dev_s *board_lcd_getdev(int devno) { g_lcd = st7735_lcdinitialize(g_spidev); if (!g_lcd) diff --git a/boards/risc-v/esp32c3/esp32c3-devkit/src/esp32c3_st7789.c b/boards/risc-v/esp32c3/esp32c3-devkit/src/esp32c3_st7789.c index de5b92c9bdfb4..0c8588a0bc4ca 100644 --- a/boards/risc-v/esp32c3/esp32c3-devkit/src/esp32c3_st7789.c +++ b/boards/risc-v/esp32c3/esp32c3-devkit/src/esp32c3_st7789.c @@ -115,7 +115,7 @@ int board_lcd_initialize(void) * ****************************************************************************/ -FAR struct lcd_dev_s *board_lcd_getdev(int devno) +struct lcd_dev_s *board_lcd_getdev(int devno) { g_lcd = st7789_lcdinitialize(g_spidev); if (!g_lcd) diff --git a/boards/risc-v/esp32c3/esp32c3-devkit/src/esp32c3_twai.c b/boards/risc-v/esp32c3/esp32c3-devkit/src/esp32c3_twai.c new file mode 100644 index 0000000000000..6c284b63cb554 --- /dev/null +++ b/boards/risc-v/esp32c3/esp32c3-devkit/src/esp32c3_twai.c @@ -0,0 +1,93 @@ +/**************************************************************************** + * boards/risc-v/esp32c3/esp32c3-devkit/src/esp32c3_twai.c + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include +#include + +#include +#include + +#include "chip.h" +/* #include "arm_arch.h" */ + +#include "esp32c3_twai.h" +#include "esp32c3-devkit.h" + +#ifdef CONFIG_CAN + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/* Configuration ************************************************************/ + +#define TWAI_PORT0 0 + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: esp32c3_twai_setup + * + * Description: + * Initialize TWAI and register the TWAI device + * + ****************************************************************************/ + +int esp32c3_twai_setup(void) +{ +#ifdef CONFIG_ESP32C3_TWAI0 + struct can_dev_s *twai; + int ret; + + /* Call esp32c3_twaiinitialize() to get an instance of the TWAI0 + * interface + * */ + + twai = esp32c3_twaiinitialize(TWAI_PORT0); + if (twai == NULL) + { + canerr("ERROR: Failed to get TWAI0 interface\n"); + return -ENODEV; + } + + /* Register the TWAI0 driver at "/dev/can0" */ + + ret = can_register("/dev/can0", twai); + if (ret < 0) + { + canerr("ERROR: TWAI0 register failed: %d\n", ret); + return ret; + } + + return OK; +#else + return -ENODEV; +#endif +} + +#endif /* CONFIG_CAN */ diff --git a/boards/risc-v/esp32c3/esp32c3-devkit/src/etc/init.d/rc.sysinit b/boards/risc-v/esp32c3/esp32c3-devkit/src/etc/init.d/rc.sysinit new file mode 100644 index 0000000000000..044f5b69509c1 --- /dev/null +++ b/boards/risc-v/esp32c3/esp32c3-devkit/src/etc/init.d/rc.sysinit @@ -0,0 +1,36 @@ +/**************************************************************************** + * boards/risc-v/esp32c3/esp32c3-devkit/src/etc/init.d/rc.sysinit + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +#include + +#define CONCAT_(x, y) x##y +#define CONCAT(x, y) CONCAT_(x, y) + +#ifdef CONFIG_NSH_ROMFSETC +#ifdef CONFIG_FS_FAT + +/* Create a RAMDISK and mount it at /tmp */ + +mkrd -m CONFIG_NSH_FATDEVNO -s CONFIG_NSH_FATSECTSIZE CONFIG_NSH_FATNSECTORS +mkfatfs CONCAT(/dev/ram, CONFIG_NSH_FATDEVNO) +mount -t vfat CONCAT(/dev/ram, CONFIG_NSH_FATDEVNO) CONFIG_NSH_FATMOUNTPT + +#endif /* CONFIG_FS_FAT */ +#endif /* CONFIG_NSH_ROMFSETC */ diff --git a/boards/risc-v/esp32c3/esp32c3-devkit/src/etc/init.d/rcS b/boards/risc-v/esp32c3/esp32c3-devkit/src/etc/init.d/rcS index 964d268c6785d..516a7cf649da4 100644 --- a/boards/risc-v/esp32c3/esp32c3-devkit/src/etc/init.d/rcS +++ b/boards/risc-v/esp32c3/esp32c3-devkit/src/etc/init.d/rcS @@ -17,20 +17,3 @@ * under the License. * ****************************************************************************/ - -#include - -#define CONCAT_(x, y) x##y -#define CONCAT(x, y) CONCAT_(x, y) - -#ifdef CONFIG_NSH_ROMFSETC -#ifdef CONFIG_FS_FAT - -/* Create a RAMDISK and mount it at /tmp */ - -mkrd -m CONFIG_NSH_FATDEVNO -s CONFIG_NSH_FATSECTSIZE CONFIG_NSH_FATNSECTORS -mkfatfs CONCAT(/dev/ram, CONFIG_NSH_FATDEVNO) -mount -t vfat CONCAT(/dev/ram, CONFIG_NSH_FATDEVNO) CONFIG_NSH_FATMOUNTPT - -#endif /* CONFIG_FS_FAT */ -#endif /* CONFIG_NSH_ROMFSETC */ diff --git a/boards/risc-v/fe310/hifive1-revb/scripts/Make.defs b/boards/risc-v/fe310/hifive1-revb/scripts/Make.defs index 729a499e6bb30..31711ff732489 100644 --- a/boards/risc-v/fe310/hifive1-revb/scripts/Make.defs +++ b/boards/risc-v/fe310/hifive1-revb/scripts/Make.defs @@ -30,19 +30,6 @@ endif ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT) -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g - ASARCHCPUFLAGS += -Wa,-g -endif - -MAXOPTIMIZATION = -Os - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - -ARCHCFLAGS = -fno-common -ffunction-sections -fdata-sections -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new -fno-rtti ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 @@ -52,6 +39,6 @@ CPICFLAGS = $(ARCHPICFLAGS) $(CFLAGS) CXXFLAGS := $(ARCHCXXFLAGS) $(ARCHWARNINGSXX) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHXXINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) -pipe CXXPICFLAGS = $(ARCHPICFLAGS) $(CXXFLAGS) CPPFLAGS := $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) -AFLAGS += $(CFLAGS) -D__ASSEMBLY__ $(ASARCHCPUFLAGS) +AFLAGS += $(CFLAGS) -D__ASSEMBLY__ -LDFLAGS += --gc-sections -melf32lriscv +LDFLAGS += -melf32lriscv diff --git a/boards/risc-v/fe310/hifive1-revb/src/fe310_buttons.c b/boards/risc-v/fe310/hifive1-revb/src/fe310_buttons.c index 1ea7043f862ef..384ea75a19ce4 100644 --- a/boards/risc-v/fe310/hifive1-revb/src/fe310_buttons.c +++ b/boards/risc-v/fe310/hifive1-revb/src/fe310_buttons.c @@ -131,7 +131,7 @@ uint32_t board_buttons(void) ****************************************************************************/ #ifdef CONFIG_ARCH_IRQBUTTONS -int board_button_irq(int id, xcpt_t irqhandler, FAR void *arg) +int board_button_irq(int id, xcpt_t irqhandler, void *arg) { int ret = -EINVAL; ASSERT(id == 0); diff --git a/boards/risc-v/k210/maix-bit/scripts/Make.defs b/boards/risc-v/k210/maix-bit/scripts/Make.defs index 44309653e722b..5caf91685c034 100644 --- a/boards/risc-v/k210/maix-bit/scripts/Make.defs +++ b/boards/risc-v/k210/maix-bit/scripts/Make.defs @@ -23,23 +23,9 @@ include $(TOPDIR)/tools/Config.mk include $(TOPDIR)/arch/risc-v/src/common/Toolchain.defs LDSCRIPT = ld.script - ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT) -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g - ASARCHCPUFLAGS += -Wa,-g -endif - -MAXOPTIMIZATION = -Os - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - ARCHCPUFLAGS += -mcmodel=medany -mstrict-align -ARCHCFLAGS = -fno-common -ffunction-sections -fdata-sections -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new -fno-rtti ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef @@ -48,7 +34,7 @@ CPICFLAGS = $(ARCHPICFLAGS) $(CFLAGS) CXXFLAGS := $(ARCHCXXFLAGS) $(ARCHWARNINGSXX) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHXXINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) -pipe CXXPICFLAGS = $(ARCHPICFLAGS) $(CXXFLAGS) CPPFLAGS := $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) -AFLAGS += $(CFLAGS) -D__ASSEMBLY__ $(ASARCHCPUFLAGS) +AFLAGS += $(CFLAGS) -D__ASSEMBLY__ # Loadable module definitions @@ -63,8 +49,8 @@ CELFFLAGS = $(CFLAGS) CXXELFFLAGS = $(CXXFLAGS) LDELFFLAGS = -r -e main -LDELFFLAGS += -T $(call CONVERT_PATH,$(BOARD_DIR)$(DELIM)scripts$(DELIM)gnu-elf.ld) +LDELFFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)/binfmt/libelf/gnu-elf.ld) # File extensions -LDFLAGS += --gc-sections -melf64lriscv +LDFLAGS += -melf64lriscv diff --git a/boards/risc-v/k210/maix-bit/scripts/gnu-elf.ld b/boards/risc-v/k210/maix-bit/scripts/gnu-elf.ld deleted file mode 100644 index 8e24692df2d5c..0000000000000 --- a/boards/risc-v/k210/maix-bit/scripts/gnu-elf.ld +++ /dev/null @@ -1,115 +0,0 @@ -/**************************************************************************** - * boards/risc-v/k210/maix-bit/scripts/gnu-elf.ld - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. The - * ASF licenses this file to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance with the - * License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - ****************************************************************************/ - -SECTIONS -{ - .text 0x00000000 : - { - _stext = . ; - *(.text) - *(.text.*) - *(.gnu.warning) - *(.stub) - *(.glue_7) - *(.glue_7t) - *(.jcr) - - /* C++ support: The .init and .fini sections contain specific logic - * to manage static constructors and destructors. - */ - - *(.gnu.linkonce.t.*) - *(.init) /* Old ABI */ - *(.fini) /* Old ABI */ - _etext = . ; - } - - .rodata : - { - _srodata = . ; - *(.rodata) - *(.rodata1) - *(.rodata.*) - *(.gnu.linkonce.r*) - _erodata = . ; - } - - .data : - { - _sdata = . ; - *(.data) - *(.data1) - *(.data.*) - *(.gnu.linkonce.d*) - . = ALIGN(4); - _edata = . ; - } - - /* C++ support. For each global and static local C++ object, - * GCC creates a small subroutine to construct the object. Pointers - * to these routines (not the routines themselves) are stored as - * simple, linear arrays in the .ctors section of the object file. - * Similarly, pointers to global/static destructor routines are - * stored in .dtors. - */ - - .ctors : - { - _sctors = . ; - *(.ctors) /* Old ABI: Unallocated */ - *(.init_array) /* New ABI: Allocated */ - _edtors = . ; - } - - .dtors : - { - _sdtors = . ; - *(.dtors) /* Old ABI: Unallocated */ - *(.fini_array) /* New ABI: Allocated */ - _edtors = . ; - } - - .bss : - { - _sbss = . ; - *(.bss) - *(.bss.*) - *(.sbss) - *(.sbss.*) - *(.gnu.linkonce.b*) - *(COMMON) - _ebss = . ; - } - - /* Stabs debugging sections. */ - - .stab 0 : { *(.stab) } - .stabstr 0 : { *(.stabstr) } - .stab.excl 0 : { *(.stab.excl) } - .stab.exclstr 0 : { *(.stab.exclstr) } - .stab.index 0 : { *(.stab.index) } - .stab.indexstr 0 : { *(.stab.indexstr) } - .comment 0 : { *(.comment) } - .debug_abbrev 0 : { *(.debug_abbrev) } - .debug_info 0 : { *(.debug_info) } - .debug_line 0 : { *(.debug_line) } - .debug_pubnames 0 : { *(.debug_pubnames) } - .debug_aranges 0 : { *(.debug_aranges) } -} diff --git a/boards/risc-v/k210/maix-bit/src/k210_gpio.c b/boards/risc-v/k210/maix-bit/src/k210_gpio.c index 0e631dc491afc..6ccc5b441ad29 100644 --- a/boards/risc-v/k210/maix-bit/src/k210_gpio.c +++ b/boards/risc-v/k210/maix-bit/src/k210_gpio.c @@ -66,8 +66,8 @@ struct k210gpio_dev_s ****************************************************************************/ #if BOARD_NGPIOOUT > 0 -static int gpout_read(FAR struct gpio_dev_s *dev, FAR bool *value); -static int gpout_write(FAR struct gpio_dev_s *dev, bool value); +static int gpout_read(struct gpio_dev_s *dev, bool *value); +static int gpout_write(struct gpio_dev_s *dev, bool value); #endif /**************************************************************************** @@ -102,10 +102,10 @@ static struct k210gpio_dev_s g_gpout[BOARD_NGPIOOUT]; ****************************************************************************/ #if BOARD_NGPIOOUT > 0 -static int gpout_read(FAR struct gpio_dev_s *dev, FAR bool *value) +static int gpout_read(struct gpio_dev_s *dev, bool *value) { - FAR struct k210gpio_dev_s *k210gpio = - (FAR struct k210gpio_dev_s *)dev; + struct k210gpio_dev_s *k210gpio = + (struct k210gpio_dev_s *)dev; DEBUGASSERT(k210gpio != NULL && value != NULL); DEBUGASSERT(k210gpio->id < BOARD_NGPIOOUT); @@ -119,10 +119,10 @@ static int gpout_read(FAR struct gpio_dev_s *dev, FAR bool *value) * Name: gpout_write ****************************************************************************/ -static int gpout_write(FAR struct gpio_dev_s *dev, bool value) +static int gpout_write(struct gpio_dev_s *dev, bool value) { - FAR struct k210gpio_dev_s *k210gpio = - (FAR struct k210gpio_dev_s *)dev; + struct k210gpio_dev_s *k210gpio = + (struct k210gpio_dev_s *)dev; DEBUGASSERT(k210gpio != NULL); DEBUGASSERT(k210gpio->id < BOARD_NGPIOOUT); diff --git a/boards/risc-v/litex/arty_a7/Kconfig b/boards/risc-v/litex/arty_a7/Kconfig index cedc8e45a4780..61584068d37d9 100644 --- a/boards/risc-v/litex/arty_a7/Kconfig +++ b/boards/risc-v/litex/arty_a7/Kconfig @@ -5,4 +5,24 @@ if ARCH_BOARD_ARTY_A7 +config LITEX_SDIO_MOUNT + bool "Mount SDIO at startup" + default n + depends on LITEX_SDIO + +config LITEX_SDIO_MOUNT_BLKDEV + string "SDIO block device name" + default "/dev/mmcsd0" + depends on LITEX_SDIO + +config LITEX_SDIO_MOUNT_MOUNTPOINT + string "SDIO mountpoint" + default "/mnt" + depends on LITEX_SDIO + +config LITEX_SDIO_MOUNT_FSTYPE + string "SDIO file system type" + default "vfat" + depends on LITEX_SDIO + endif diff --git a/boards/risc-v/litex/arty_a7/README.txt b/boards/risc-v/litex/arty_a7/README.txt index 03d5540390c65..1e20876b71cbb 100644 --- a/boards/risc-v/litex/arty_a7/README.txt +++ b/boards/risc-v/litex/arty_a7/README.txt @@ -5,6 +5,9 @@ 2. Follow instruction on https://github.com/enjoy-digital/litex to build the vexriscv softcore fpga gateware and flash to arty_a7 board + $ cd litex-boards/litex_boards/targets + $ ./digilent_arty.py --with-sdcard --uart-baudrate 1000000 --cpu-type=vexriscv --cpu-variant=secure --build --load --flash + 3. Configure and build NuttX $ mkdir ./nuttx; cd ./nuttx diff --git a/boards/risc-v/litex/arty_a7/scripts/Make.defs b/boards/risc-v/litex/arty_a7/scripts/Make.defs index cd0211df97cab..aedc497d5a31d 100644 --- a/boards/risc-v/litex/arty_a7/scripts/Make.defs +++ b/boards/risc-v/litex/arty_a7/scripts/Make.defs @@ -23,22 +23,8 @@ include $(TOPDIR)/tools/Config.mk include $(TOPDIR)/arch/risc-v/src/common/Toolchain.defs LDSCRIPT = ld.script - ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT) -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g - ASARCHCPUFLAGS += -Wa,-g -endif - -MAXOPTIMIZATION = -Os - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - -ARCHCFLAGS = -fno-common -ffunction-sections -fdata-sections -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new -fno-rtti ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 @@ -48,6 +34,6 @@ CPICFLAGS = $(ARCHPICFLAGS) $(CFLAGS) CXXFLAGS := $(ARCHCXXFLAGS) $(ARCHWARNINGSXX) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHXXINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) -pipe CXXPICFLAGS = $(ARCHPICFLAGS) $(CXXFLAGS) CPPFLAGS := $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) -AFLAGS += $(CFLAGS) -D__ASSEMBLY__ $(ASARCHCPUFLAGS) +AFLAGS += $(CFLAGS) -D__ASSEMBLY__ -LDFLAGS += --gc-sections -melf32lriscv +LDFLAGS += -melf32lriscv diff --git a/boards/risc-v/litex/arty_a7/src/Makefile b/boards/risc-v/litex/arty_a7/src/Makefile index 7b9f5bfbbd7ab..511f8a84c997a 100644 --- a/boards/risc-v/litex/arty_a7/src/Makefile +++ b/boards/risc-v/litex/arty_a7/src/Makefile @@ -26,4 +26,12 @@ ifeq ($(CONFIG_BOARDCTL),y) CSRCS += litex_appinit.c endif +ifeq ($(CONFIG_LITEX_SDIO),y) +CSRCS += litex_sdio.c +endif + +ifeq ($(CONFIG_FS_AUTOMOUNTER),y) +CSRCS += litex_automount.c +endif + include $(TOPDIR)/boards/Board.mk diff --git a/boards/risc-v/litex/arty_a7/src/arty_a7.h b/boards/risc-v/litex/arty_a7/src/arty_a7.h index 00e564bbcdad8..1eab373aea58a 100644 --- a/boards/risc-v/litex/arty_a7/src/arty_a7.h +++ b/boards/risc-v/litex/arty_a7/src/arty_a7.h @@ -27,6 +27,121 @@ #include +/**************************************************************************** + * configuration + */ + +#define HAVE_SDMMC 1 +#define HAVE_AUTOMOUNTER 1 + +/**************************************************************************** + * SDIO Configuration + */ + +#define SDIO_MINOR CONFIG_NSH_MMCSDMINOR +#define SDIO_SLOTNO CONFIG_NSH_MMCSDSLOTNO + +/* Can't support MMC/SD if the card interface(s) are not enable */ + +#if !defined(CONFIG_LITEX_SDIO) && !defined(CONFIG_LITEX_SDIO1) +# undef HAVE_SDMMC +#endif + +#if !defined(CONFIG_FS_AUTOMOUNTER) +# undef HAVE_AUTOMOUNTER +#endif + +/**************************************************************************** + * PROC File System Configuration + */ + +#ifdef CONFIG_FS_PROCFS +# ifdef CONFIG_NSH_PROC_MOUNTPOINT +# define LITEX_PROCFS_MOUNTPOINT CONFIG_NSH_PROC_MOUNTPOINT +# else +# define LITEX_PROCFS_MOUNTPOINT "/proc" +# endif +#endif + +/**************************************************************************** + * Public Function Prototypes + ****************************************************************************/ + +/**************************************************************************** + * Name: litex_bringup + * + * Description: + * Bring up board features + * + ****************************************************************************/ + int litex_bringup(void); +/**************************************************************************** + * Name: litex_sdio_initialize + * + * Description: + * Initialize SDIO-based MMC/SD card support + * + ****************************************************************************/ + +#ifdef HAVE_SDMMC +int litex_sdio_initialize(void); +#endif + +/**************************************************************************** + * Name: litex_automount_initialize + * + * Description: + * Configure auto-mounters for each enabled MikroBus MMCSD + * + * Input Parameters: + * None + * + * Returned Value: + * None + * + ****************************************************************************/ + +#ifdef HAVE_AUTOMOUNTER +int litex_automount_initialize(void); +#endif + +/**************************************************************************** + * Name: litex_automount_event + * + * Description: + * The MMCSD card detection logic has detected an insertion or removal + * event. It has already scheduled the MMC/SD block driver operations. + * Now we need to schedule the auto-mount event which will occur with a + * substantial delay to make sure that everything has settle down. + * + * Input Parameters: + * slotno - Identifies the MB slot: MB1_MMCSD_SLOTNO or MB2_MMCSD_SLOTNO. + * inserted - True if the card is inserted in the slot. False otherwise. + * + * Returned Value: + * None + * + * Assumptions: + * Interrupts are disabled. + * + ****************************************************************************/ + +#ifdef HAVE_AUTOMOUNTER +void litex_automount_event(int slotno, bool inserted); +#endif + +/**************************************************************************** + * Name: litex_cardinserted + * + * Description: + * Check if a card is inserted into the selected MMCSD slot + * + ****************************************************************************/ + +#ifdef HAVE_SDMMC +bool litex_cardinserted(int slotno); +#endif + #endif /* __BOARDS_RISCV_LITEX_ARTY_A7_SRC_ARTY_A7_H */ diff --git a/boards/risc-v/litex/arty_a7/src/litex_automount.c b/boards/risc-v/litex/arty_a7/src/litex_automount.c new file mode 100644 index 0000000000000..4abdce06b87e1 --- /dev/null +++ b/boards/risc-v/litex/arty_a7/src/litex_automount.c @@ -0,0 +1,336 @@ +/**************************************************************************** + * boards/risc-v/litex/arty_a7/src/litex_automount.c + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#if defined(CONFIG_FS_AUTOMOUNTER_DEBUG) && !defined(CONFIG_DEBUG_FS) +# define CONFIG_DEBUG_FS 1 +#endif + +#include +#include + +#include +#include +#include + +#include "arty_a7.h" + +#ifdef HAVE_AUTOMOUNTER + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/**************************************************************************** + * Private Types + ****************************************************************************/ + +/* This structure represents the changeable state of the automounter */ + +struct litex_automount_state_s +{ + volatile automount_handler_t handler; /* Upper half handler */ + void *arg; /* Handler argument */ + bool enable; /* Fake interrupt enable */ + bool pending; /* Set if there an event while disabled */ +}; + +/* This structure represents the static configuration of an automounter */ + +struct litex_automount_config_s +{ + /* This must be first thing in structure so that we can simply cast from + * struct automount_lower_s to struct litex_automount_config_s + */ + + struct automount_lower_s lower; /* Publicly visible part */ + uint8_t mmcsd; /* MB1_MMCSD_SLOTNO or MB2_MMCSD_SLOTNO */ + struct litex_automount_state_s *state; /* Changeable state */ +}; + +/**************************************************************************** + * Private Function Prototypes + ****************************************************************************/ + +static int litex_attach(const struct automount_lower_s *lower, + automount_handler_t isr, void *arg); +static void litex_enable(const struct automount_lower_s *lower, + bool enable); +static bool litex_inserted(const struct automount_lower_s *lower); + +/**************************************************************************** + * Private Data + ****************************************************************************/ + +#ifdef CONFIG_LITEX_SDIO_MOUNT_MOUNTPOINT +static struct litex_automount_state_s g_mb1_mmcsdstate; +static const struct litex_automount_config_s g_mb1_mmcsdconfig = +{ + .lower = + { + .fstype = CONFIG_LITEX_SDIO_MOUNT_FSTYPE, + .blockdev = CONFIG_LITEX_SDIO_MOUNT_BLKDEV, + .mountpoint = CONFIG_LITEX_SDIO_MOUNT_MOUNTPOINT, + .ddelay = MSEC2TICK( + 100), + .udelay = MSEC2TICK( + 100), + .attach = litex_attach, + .enable = litex_enable, + .inserted = litex_inserted + }, + .mmcsd = SDIO_SLOTNO, + .state = &g_mb1_mmcsdstate +}; +#endif + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: litex_attach + * + * Description: + * Attach a new MMCSD event handler + * + * Input Parameters: + * lower - An instance of the auto-mounter lower half state structure + * isr - The new event handler to be attach + * arg - Client data to be provided when the event handler is invoked. + * + * Returned Value: + * Always returns OK + * + ****************************************************************************/ + +static int litex_attach(const struct automount_lower_s *lower, + automount_handler_t isr, void *arg) +{ + const struct litex_automount_config_s *config; + struct litex_automount_state_s *state; + + /* Recover references to our structure */ + + config = (struct litex_automount_config_s *)lower; + DEBUGASSERT(config && config->state); + + state = config->state; + + /* Save the new handler info (clearing the handler first to eliminate race + * conditions). + */ + + state->handler = NULL; + state->pending = false; + state->arg = arg; + state->handler = isr; + return OK; +} + +/**************************************************************************** + * Name: litex_enable + * + * Description: + * Enable card insertion/removal event detection + * + * Input Parameters: + * lower - An instance of the auto-mounter lower half state structure + * enable - True: enable event detection; False: disable + * + * Returned Value: + * None + * + ****************************************************************************/ + +static void litex_enable(const struct automount_lower_s *lower, + bool enable) +{ + const struct litex_automount_config_s *config; + struct litex_automount_state_s *state; + irqstate_t flags; + + /* Recover references to our structure */ + + config = (struct litex_automount_config_s *)lower; + DEBUGASSERT(config && config->state); + + state = config->state; + + /* Save the fake enable setting */ + + flags = enter_critical_section(); + state->enable = enable; + + /* Did an interrupt occur while interrupts were disabled? */ + + if (enable && state->pending) + { + /* Yes.. perform the fake interrupt if the interrupt is attached */ + + if (state->handler) + { + bool inserted = litex_cardinserted(config->mmcsd); + state->handler(&config->lower, state->arg, inserted); + } + + state->pending = false; + } + + leave_critical_section(flags); +} + +/**************************************************************************** + * Name: litex_inserted + * + * Description: + * Check if a card is inserted into the slot. + * + * Input Parameters: + * lower - An instance of the auto-mounter lower half state structure + * + * Returned Value: + * True if the card is inserted; False otherwise + * + ****************************************************************************/ + +static bool litex_inserted(const struct automount_lower_s *lower) +{ + const struct litex_automount_config_s *config; + + config = (struct litex_automount_config_s *)lower; + DEBUGASSERT(config && config->state); + + return litex_cardinserted(config->mmcsd); +} + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: litex_automount_initialize + * + * Description: + * Configure auto-mounters for each enabled MMCSD MikroBus slot + * + * Input Parameters: + * None + * + * Returned Value: + * None + * + ****************************************************************************/ + +int litex_automount_initialize(void) +{ + void *handle; + + finfo("Initializing automounter(s)\n"); + +#ifdef CONFIG_LITEX_SDIO_MOUNT_MOUNTPOINT + /* Initialize the MB1 MMCSD auto-mounter */ + + handle = automount_initialize(&g_mb1_mmcsdconfig.lower); + if (!handle) + { + ferr("ERROR: Failed to initialize auto-mounter for MB1 MMCSD\n"); + return ERROR; + } +#endif + + return OK; +} + +/**************************************************************************** + * Name: litex_automount_event + * + * Description: + * The HSMCI card detection logic has detected an insertion or removal + * event. It has already scheduled the MMC/SD block driver operations. + * Now we need to schedule the auto-mount event which will occur with a + * substantial delay to make sure that everything has settle down. + * + * Input Parameters: + * slotno - Identifies the MB slot: MB1_MMCSD_SLOTNO or MB2_MMCSD_SLOTNO. + * There is a terminology problem here: Each HSMCI supports two slots, + * slot A and slot B. Only slot A is used. So this is not a really a + * slot, but an HSCMI peripheral number. + * inserted - True if the card is inserted in the slot. False otherwise. + * + * Returned Value: + * None + * + * Assumptions: + * Interrupts are disabled. + * + ****************************************************************************/ + +void litex_automount_event(int slotno, bool inserted) +{ + const struct litex_automount_config_s *config; + struct litex_automount_state_s *state; + +#ifdef CONFIG_LITEX_SDIO_MOUNT_MOUNTPOINT + /* Is this a change in the MB1 MMCSD slot insertion state? */ + + if (slotno == SDIO_SLOTNO) + { + /* Yes.. Select the MB1 MMCSD automounter */ + + config = &g_mb1_mmcsdconfig; + state = &g_mb1_mmcsdstate; + } + else +#endif + { + ferr("ERROR: Unsupported MMCSD%d\n", slotno); + return; + } + + /* Is the auto-mounter interrupt attached? */ + + if (state->handler) + { + /* Yes.. Have we been asked to hold off interrupts? */ + + if (!state->enable) + { + /* Yes.. just remember that there is a pending interrupt. We will + * deliver the interrupt when interrupts are "re-enabled." + */ + + state->pending = true; + } + else + { + /* No.. forward the event to the handler */ + + state->handler(&config->lower, state->arg, inserted); + } + } +} + +#endif /* HAVE_AUTOMOUNTER */ diff --git a/boards/risc-v/litex/arty_a7/src/litex_bringup.c b/boards/risc-v/litex/arty_a7/src/litex_bringup.c index a1f8b1ab9427e..826d2eb4f2e55 100644 --- a/boards/risc-v/litex/arty_a7/src/litex_bringup.c +++ b/boards/risc-v/litex/arty_a7/src/litex_bringup.c @@ -31,9 +31,9 @@ #include #include -#include #include "litex.h" +#include "arty_a7.h" /**************************************************************************** * Public Functions @@ -50,12 +50,57 @@ int litex_bringup(void) #ifdef CONFIG_FS_PROCFS /* Mount the procfs file system */ - ret = nx_mount(NULL, "/proc", "procfs", 0, NULL); + ret = nx_mount(NULL, LITEX_PROCFS_MOUNTPOINT, "procfs", 0, NULL); if (ret < 0) { - serr("ERROR: Failed to mount procfs at %s: %d\n", "/proc", ret); + syslog(LOG_ERR, "failed to mount procfs at %s %d\n", + LITEX_PROCFS_MOUNTPOINT, ret); } #endif +#ifdef CONFIG_FS_AUTOMOUNTER + /* Configure uSD automounter */ + + ret = litex_automount_initialize(); + if (ret < 0) + { + syslog(LOG_ERR, "ERROR: litex_automount_initialize() failed: %d\n", + ret); + } +#endif + +#ifdef CONFIG_LITEX_SDIO + /* Initialize the SDIO block driver */ + + ret = litex_sdio_initialize(); + if (ret != OK) + { + syslog(LOG_ERR, "litex_sdio_initialize() failed %d\n", ret); + return ret; + } + + /* If automount not configured, force a mount point. + * Assumes the card is always present. + */ + +#ifndef CONFIG_FS_AUTOMOUNTER +#ifdef CONFIG_LITEX_SDIO_MOUNT + /* Mount the volume on SDMMC0 */ + + ret = nx_mount(CONFIG_LITEX_SDIO_MOUNT_BLKDEV, + CONFIG_LITEX_SDIO_MOUNT_MOUNTPOINT, + CONFIG_LITEX_SDIO_MOUNT_FSTYPE, + 0, NULL); + + if (ret != OK) + { + syslog(LOG_ERR, "ERROR: Failed to mount %s: %d\n", + CONFIG_LITEX_SDIO_MOUNT_MOUNTPOINT, ret); + } +#endif /* CONFIG_LITEX_SDIO_MOUNT */ +#endif + +#endif /* CONFIG_LITEX_SDIO */ + return ret; } diff --git a/arch/arm/src/armv7-m/gnu/arm_testset.S b/boards/risc-v/litex/arty_a7/src/litex_sdio.c similarity index 54% rename from arch/arm/src/armv7-m/gnu/arm_testset.S rename to boards/risc-v/litex/arty_a7/src/litex_sdio.c index 36e039d0ba69e..1b731e9cce70a 100644 --- a/arch/arm/src/armv7-m/gnu/arm_testset.S +++ b/boards/risc-v/litex/arty_a7/src/litex_sdio.c @@ -1,5 +1,5 @@ /**************************************************************************** - * arch/arm/src/armv7-m/gnu/arm_testset.S + * boards/risc-v/litex/arty_a7/src/litex_sdio.c * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with @@ -23,86 +23,109 @@ ****************************************************************************/ #include -#include - .syntax unified - .thumb - .file "arm_testset.S" +#include +#include +#include +#include -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ +#include +#include -/**************************************************************************** - * Public Symbols - ****************************************************************************/ +#include "litex.h" +#include "arty_a7.h" +#include "litex_sdio.h" - .globl up_testset +#ifdef HAVE_SDMMC /**************************************************************************** - * Assembly Macros + * Private Data ****************************************************************************/ /**************************************************************************** * Private Functions ****************************************************************************/ - .text +/**************************************************************************** + * Name: litex_sdio_card_isr_callback + * + * Description: + * Check if a card is inserted into the selected MMCSD slot + * + ****************************************************************************/ + +static void litex_sdio_card_isr_callback(void *arg) +{ + bool cd; + + cd = litex_cardinserted(SDIO_SLOTNO); + finfo("Card detect: %d\n", cd); + sdio_mediachange(arg, cd); + +#ifdef HAVE_AUTOMOUNTER + /* Let the automounter know about the insertion event */ + + litex_automount_event(SDIO_SLOTNO, cd); +#endif +} /**************************************************************************** * Public Functions ****************************************************************************/ /**************************************************************************** - * Name: up_testset + * Name: litex_cardinserted * * Description: - * Perform an atomic test and set operation on the provided spinlock. - * - * This function must be provided via the architecture-specific logic. - * - * Input Parameters: - * lock - A reference to the spinlock object. - * - * Returned Value: - * The spinlock is always locked upon return. The previous value of the - * spinlock variable is returned, either SP_LOCKED if the spinlock was - * previously locked (meaning that the test-and-set operation failed to - * obtain the lock) or SP_UNLOCKED if the spinlock was previously unlocked - * (meaning that we successfully obtained the lock). + * Check if a card is inserted into the selected MMCSD slot * ****************************************************************************/ - .globl up_testset - .type up_testset, %function +bool litex_cardinserted(int slotno) +{ + return litex_sdio_get_card_detect(); +} -up_testset: +/**************************************************************************** + * Name: litex_sdio_initialize + * + * Description: + * Initialize SDIO-based MMC/SD card support + * + ****************************************************************************/ - mov r1, #SP_LOCKED +int litex_sdio_initialize(void) +{ + int ret = 0; + struct sdio_dev_s *sdio_dev; - /* Test if the spinlock is locked or not */ + finfo("Initializing SDIO slot %d\n", SDIO_SLOTNO); + sdio_dev = sdio_initialize(SDIO_SLOTNO); + if (sdio_dev == NULL) + { + ferr("ERROR: Failed to initialize SDIO slot %d\n", SDIO_SLOTNO); + return -ENODEV; + } -1: - ldrexb r2, [r0] /* Test if spinlock is locked or not */ - cmp r2, r1 /* Already locked? */ - beq 2f /* If already locked, return SP_LOCKED */ + finfo("Bind SDIO to the MMC/SD driver, minor=%d\n", SDIO_MINOR); + ret = mmcsd_slotinitialize(SDIO_MINOR, sdio_dev); + if (ret != OK) + { + ferr("ERROR: Failed to bind SDIO to the MMC/SD driver: %d\n", ret); + return ret; + } - /* Not locked ... attempt to lock it */ + litex_sdio_set_card_isr(sdio_dev, &litex_sdio_card_isr_callback, sdio_dev); - strexb r2, r1, [r0] /* Attempt to set the locked state */ - cmp r2, r1 /* r2 will be 1 is strexb failed */ - beq 1b /* Failed to lock... try again */ + finfo("Successfully bound SDIO to the MMC/SD driver\n"); - /* Lock acquired -- return SP_UNLOCKED */ + /* Assume that the SD card is inserted. + * The Arty A7 board doesnt have the CD pin wired. + */ - dmb /* Required before accessing protected resource */ - mov r0, #SP_UNLOCKED - bx lr + sdio_mediachange(sdio_dev, litex_sdio_get_card_detect()); - /* Lock not acquired -- return SP_LOCKED */ + return OK; +} -2: - mov r0, #SP_LOCKED - bx lr - .size up_testset, . - up_testset - .end +#endif /* HAVE_SDMMC */ diff --git a/boards/risc-v/mpfs/common/src/Make.defs b/boards/risc-v/mpfs/common/src/Make.defs index 2d9465b58a7f0..6505f67246780 100755 --- a/boards/risc-v/mpfs/common/src/Make.defs +++ b/boards/risc-v/mpfs/common/src/Make.defs @@ -26,10 +26,6 @@ ifeq ($(CONFIG_I2C),y) CSRCS += mpfs_i2c.c endif -ifeq ($(CONFIG_ARCH_FPU),y) -CSRCS += mpfs_ostest.c -endif - ifeq ($(CONFIG_SPI),y) CSRCS += mpfs_board_spi.c endif diff --git a/boards/risc-v/mpfs/common/src/mpfs_emmcsd.c b/boards/risc-v/mpfs/common/src/mpfs_emmcsd.c index b6fea4e7723d2..25a0ed09d6638 100644 --- a/boards/risc-v/mpfs/common/src/mpfs_emmcsd.c +++ b/boards/risc-v/mpfs/common/src/mpfs_emmcsd.c @@ -35,7 +35,7 @@ * Private Data ****************************************************************************/ -static FAR struct sdio_dev_s *g_sdio_dev; +static struct sdio_dev_s *g_sdio_dev; /**************************************************************************** * Public Functions diff --git a/boards/risc-v/mpfs/common/src/mpfs_i2c.c b/boards/risc-v/mpfs/common/src/mpfs_i2c.c index 4fa701a1a75e9..22aa84a433523 100644 --- a/boards/risc-v/mpfs/common/src/mpfs_i2c.c +++ b/boards/risc-v/mpfs/common/src/mpfs_i2c.c @@ -55,7 +55,7 @@ int mpfs_board_i2c_init(void) #ifdef CONFIG_I2C_DRIVER int bus = 0; #endif - FAR struct i2c_master_s *i2c; + struct i2c_master_s *i2c; #endif #ifdef CONFIG_MPFS_I2C0 diff --git a/boards/risc-v/mpfs/common/src/mpfs_ostest.c b/boards/risc-v/mpfs/common/src/mpfs_ostest.c deleted file mode 100755 index 587b4415131ae..0000000000000 --- a/boards/risc-v/mpfs/common/src/mpfs_ostest.c +++ /dev/null @@ -1,92 +0,0 @@ -/**************************************************************************** - * boards/risc-v/mpfs/common/src/mpfs_ostest.c - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. The - * ASF licenses this file to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance with the - * License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - ****************************************************************************/ - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include - -#include -#include -#include -#include - -#include - -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -/* Configuration ************************************************************/ - -#undef HAVE_FPU -#if defined(CONFIG_ARCH_FPU) && \ - !defined(CONFIG_TESTING_OSTEST_FPUTESTDISABLE) && \ - defined(CONFIG_TESTING_OSTEST_FPUSIZE) && \ - defined(CONFIG_SCHED_WAITPID) -# define HAVE_FPU 1 -#endif - -#ifdef HAVE_FPU - -#if CONFIG_TESTING_OSTEST_FPUSIZE != (8 * FPU_XCPT_REGS) -# error "CONFIG_TESTING_OSTEST_FPUSIZE has the wrong size" -#endif - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -static uint64_t g_saveregs[XCPTCONTEXT_REGS]; - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/* Given an array of size CONFIG_TESTING_OSTEST_FPUSIZE, this function will - * return the current FPU registers. - */ - -void arch_getfpu(FAR uint32_t *fpusave) -{ - irqstate_t flags; - - /* Take a snapshot of the thread context right now */ - - flags = enter_critical_section(); - riscv_saveusercontext(g_saveregs); - - /* Return only the floating register values */ - - memcpy(fpusave, &g_saveregs[INT_XCPT_REGS], (8 * FPU_XCPT_REGS)); - leave_critical_section(flags); -} - -/* Given two arrays of size CONFIG_TESTING_OSTEST_FPUSIZE this function - * will compare them and return true if they are identical. - */ - -bool arch_cmpfpu(FAR const uint32_t *fpusave1, FAR const uint32_t *fpusave2) -{ - return memcmp(fpusave1, fpusave2, (8 * FPU_XCPT_REGS)) == 0; -} - -#endif /* HAVE_FPU */ diff --git a/boards/risc-v/mpfs/icicle/configs/hwtest/defconfig b/boards/risc-v/mpfs/icicle/configs/hwtest/defconfig index 4f6dc139a1abb..8111c05b3623b 100644 --- a/boards/risc-v/mpfs/icicle/configs/hwtest/defconfig +++ b/boards/risc-v/mpfs/icicle/configs/hwtest/defconfig @@ -5,7 +5,6 @@ # You can then do "make savedefconfig" to generate a new defconfig file that includes your # modifications. # -# CONFIG_ARCH_FPU is not set # CONFIG_DISABLE_OS_API is not set # CONFIG_NSH_DISABLE_LOSMART is not set # CONFIG_SPI_CALLBACK is not set diff --git a/boards/risc-v/mpfs/icicle/configs/knsh/defconfig b/boards/risc-v/mpfs/icicle/configs/knsh/defconfig index e53d5639d9cbc..b024092042bd1 100644 --- a/boards/risc-v/mpfs/icicle/configs/knsh/defconfig +++ b/boards/risc-v/mpfs/icicle/configs/knsh/defconfig @@ -7,21 +7,34 @@ # # CONFIG_DISABLE_OS_API is not set # CONFIG_NSH_DISABLE_LOSMART is not set +# CONFIG_TLS_ALIGNED is not set CONFIG_ARCH="risc-v" +CONFIG_ARCH_ADDRENV=y CONFIG_ARCH_BOARD="icicle" CONFIG_ARCH_BOARD_COMMON=y CONFIG_ARCH_BOARD_ICICLE_MPFS=y CONFIG_ARCH_CHIP="mpfs" CONFIG_ARCH_CHIP_MPFS250T_FCVG484=y CONFIG_ARCH_CHIP_MPFS=y +CONFIG_ARCH_DATA_NPAGES=0 +CONFIG_ARCH_DATA_VBASE=0xC0000000 +CONFIG_ARCH_HEAP_NPAGES=0 +CONFIG_ARCH_HEAP_VBASE=0x00000000 CONFIG_ARCH_INTERRUPTSTACK=2048 +CONFIG_ARCH_PGPOOL_MAPPING=y +CONFIG_ARCH_PGPOOL_PBASE=0x80200000 +CONFIG_ARCH_PGPOOL_SIZE=4194304 +CONFIG_ARCH_PGPOOL_VBASE=0x80200000 CONFIG_ARCH_RISCV=y CONFIG_ARCH_STACKDUMP=y +CONFIG_ARCH_TEXT_NPAGES=0 +CONFIG_ARCH_TEXT_VBASE=0x00000000 CONFIG_ARCH_USE_MMU=y CONFIG_ARCH_USE_MPU=y +CONFIG_ARCH_USE_S_MODE=y +CONFIG_BOARD_LATE_INITIALIZE=y CONFIG_BOARD_LOOPSPERMSEC=54000 -CONFIG_BUILD_PROTECTED=y -CONFIG_BUILTIN=y +CONFIG_BUILD_KERNEL=y CONFIG_DEBUG_ASSERTIONS=y CONFIG_DEBUG_ERROR=y CONFIG_DEBUG_FEATURES=y @@ -30,53 +43,53 @@ CONFIG_DEBUG_INFO=y CONFIG_DEBUG_SYMBOLS=y CONFIG_DEBUG_WARN=y CONFIG_DEV_ZERO=y +CONFIG_ELF=y +CONFIG_ELF_STACKSIZE=4096 +CONFIG_EXAMPLES_HELLO=y CONFIG_EXPERIMENTAL=y CONFIG_FS_PROCFS=y CONFIG_FS_ROMFS=y CONFIG_IDLETHREAD_STACKSIZE=2048 -CONFIG_INIT_ENTRYPOINT="nsh_main" CONFIG_INIT_STACKSIZE=3072 CONFIG_INTELHEX_BINARY=y +CONFIG_LIBC_EXECFUNCS=y CONFIG_LIBC_FLOATINGPOINT=y CONFIG_LIBC_HOSTNAME="icicle" CONFIG_LIBC_PERROR_STDOUT=y CONFIG_LIBC_STRERROR=y CONFIG_MEMSET_64BIT=y CONFIG_MEMSET_OPTSPEED=y +CONFIG_MM_PGALLOC=y CONFIG_MPFS_ENABLE_DPFPU=y +CONFIG_MPFS_ROMFS_MOUNT=y CONFIG_MPFS_UART1=y CONFIG_NSH_ARCHINIT=y -CONFIG_NSH_BUILTIN_APPS=y CONFIG_NSH_DISABLE_IFUPDOWN=y CONFIG_NSH_DISABLE_MKDIR=y CONFIG_NSH_DISABLE_RM=y CONFIG_NSH_DISABLE_RMDIR=y CONFIG_NSH_DISABLE_UMOUNT=y +CONFIG_NSH_FILE_APPS=y CONFIG_NSH_LINELEN=160 CONFIG_NSH_STRERROR=y -CONFIG_NUTTX_USERSPACE=0x80040000 -CONFIG_PASS1_BUILDIR="boards/risc-v/mpfs/common/kernel" CONFIG_PREALLOC_TIMERS=4 -CONFIG_RAM_SIZE=262144 -CONFIG_RAM_START=0x80080000 +CONFIG_RAM_SIZE=1048576 +CONFIG_RAM_START=0x80100000 CONFIG_RAW_BINARY=y CONFIG_READLINE_CMD_HISTORY=y -CONFIG_READLINE_TABCOMPLETION=y CONFIG_RR_INTERVAL=200 +CONFIG_SCHED_HAVE_PARENT=y CONFIG_SCHED_HPWORK=y CONFIG_SCHED_LPWORK=y +CONFIG_SCHED_ONEXIT=y +CONFIG_SCHED_ONEXIT_MAX=2 CONFIG_SCHED_WAITPID=y CONFIG_SERIAL_NPOLLWAITERS=2 CONFIG_STACK_COLORATION=y CONFIG_START_MONTH=4 CONFIG_START_YEAR=2021 -CONFIG_SYSLOG_COLOR_OUTPUT=y CONFIG_SYSTEM_CLE_CMD_HISTORY=y -CONFIG_SYSTEM_COLOR_CLE=y CONFIG_SYSTEM_NSH=y +CONFIG_SYSTEM_NSH_PROGNAME="init" CONFIG_SYSTEM_TIME64=y -CONFIG_TASK_NAME_SIZE=20 -CONFIG_TESTING_GETPRIME=y -CONFIG_TESTING_OSTEST=y -CONFIG_TESTING_OSTEST_FPUSIZE=264 CONFIG_UART1_SERIAL_CONSOLE=y diff --git a/boards/risc-v/mpfs/icicle/configs/network/defconfig b/boards/risc-v/mpfs/icicle/configs/network/defconfig index c429e8ad3e075..f9190878bb74b 100644 --- a/boards/risc-v/mpfs/icicle/configs/network/defconfig +++ b/boards/risc-v/mpfs/icicle/configs/network/defconfig @@ -5,7 +5,6 @@ # You can then do "make savedefconfig" to generate a new defconfig file that includes your # modifications. # -# CONFIG_ARCH_FPU is not set # CONFIG_DISABLE_OS_API is not set # CONFIG_NDEBUG is not set # CONFIG_NSH_DISABLE_LOSMART is not set diff --git a/boards/risc-v/mpfs/icicle/configs/nsh/defconfig b/boards/risc-v/mpfs/icicle/configs/nsh/defconfig index 0940f456773cb..11ccb45acf77b 100644 --- a/boards/risc-v/mpfs/icicle/configs/nsh/defconfig +++ b/boards/risc-v/mpfs/icicle/configs/nsh/defconfig @@ -5,7 +5,6 @@ # You can then do "make savedefconfig" to generate a new defconfig file that includes your # modifications. # -# CONFIG_ARCH_FPU is not set # CONFIG_DISABLE_OS_API is not set # CONFIG_NSH_DISABLE_LOSMART is not set CONFIG_ARCH="risc-v" diff --git a/boards/risc-v/mpfs/icicle/configs/opensbi/defconfig b/boards/risc-v/mpfs/icicle/configs/opensbi/defconfig index 5699b659c5425..addd139f26d41 100644 --- a/boards/risc-v/mpfs/icicle/configs/opensbi/defconfig +++ b/boards/risc-v/mpfs/icicle/configs/opensbi/defconfig @@ -5,7 +5,6 @@ # You can then do "make savedefconfig" to generate a new defconfig file that includes your # modifications. # -# CONFIG_ARCH_FPU is not set # CONFIG_DISABLE_OS_API is not set CONFIG_ARCH="risc-v" CONFIG_ARCH_BOARD="icicle" diff --git a/boards/risc-v/mpfs/icicle/configs/pnsh/defconfig b/boards/risc-v/mpfs/icicle/configs/pnsh/defconfig new file mode 100644 index 0000000000000..6b48e335e1d4a --- /dev/null +++ b/boards/risc-v/mpfs/icicle/configs/pnsh/defconfig @@ -0,0 +1,80 @@ +# +# This file is autogenerated: PLEASE DO NOT EDIT IT. +# +# You can use "make menuconfig" to make any modifications to the installed .config file. +# You can then do "make savedefconfig" to generate a new defconfig file that includes your +# modifications. +# +# CONFIG_DISABLE_OS_API is not set +# CONFIG_NSH_DISABLE_LOSMART is not set +CONFIG_ARCH="risc-v" +CONFIG_ARCH_BOARD="icicle" +CONFIG_ARCH_BOARD_COMMON=y +CONFIG_ARCH_BOARD_ICICLE_MPFS=y +CONFIG_ARCH_CHIP="mpfs" +CONFIG_ARCH_CHIP_MPFS250T_FCVG484=y +CONFIG_ARCH_CHIP_MPFS=y +CONFIG_ARCH_INTERRUPTSTACK=2048 +CONFIG_ARCH_RISCV=y +CONFIG_ARCH_STACKDUMP=y +CONFIG_ARCH_USE_MMU=y +CONFIG_ARCH_USE_MPU=y +CONFIG_BOARD_LOOPSPERMSEC=54000 +CONFIG_BUILD_PROTECTED=y +CONFIG_BUILTIN=y +CONFIG_DEBUG_ASSERTIONS=y +CONFIG_DEBUG_ERROR=y +CONFIG_DEBUG_FEATURES=y +CONFIG_DEBUG_FULLOPT=y +CONFIG_DEBUG_INFO=y +CONFIG_DEBUG_SYMBOLS=y +CONFIG_DEBUG_WARN=y +CONFIG_DEV_ZERO=y +CONFIG_EXAMPLES_HELLO=y +CONFIG_EXPERIMENTAL=y +CONFIG_FS_PROCFS=y +CONFIG_FS_ROMFS=y +CONFIG_IDLETHREAD_STACKSIZE=2048 +CONFIG_INIT_ENTRYPOINT="nsh_main" +CONFIG_INIT_STACKSIZE=3072 +CONFIG_INTELHEX_BINARY=y +CONFIG_LIBC_FLOATINGPOINT=y +CONFIG_LIBC_HOSTNAME="icicle" +CONFIG_LIBC_PERROR_STDOUT=y +CONFIG_LIBC_STRERROR=y +CONFIG_MEMSET_64BIT=y +CONFIG_MEMSET_OPTSPEED=y +CONFIG_MPFS_ENABLE_DPFPU=y +CONFIG_MPFS_UART1=y +CONFIG_NSH_ARCHINIT=y +CONFIG_NSH_BUILTIN_APPS=y +CONFIG_NSH_DISABLE_IFUPDOWN=y +CONFIG_NSH_DISABLE_MKDIR=y +CONFIG_NSH_DISABLE_RM=y +CONFIG_NSH_DISABLE_RMDIR=y +CONFIG_NSH_DISABLE_UMOUNT=y +CONFIG_NSH_LINELEN=160 +CONFIG_NSH_STRERROR=y +CONFIG_NUTTX_USERSPACE=0x80040000 +CONFIG_PASS1_BUILDIR="boards/risc-v/mpfs/common/kernel" +CONFIG_PREALLOC_TIMERS=4 +CONFIG_RAM_SIZE=262144 +CONFIG_RAM_START=0x80080000 +CONFIG_RAW_BINARY=y +CONFIG_READLINE_CMD_HISTORY=y +CONFIG_READLINE_TABCOMPLETION=y +CONFIG_RR_INTERVAL=200 +CONFIG_SCHED_HPWORK=y +CONFIG_SCHED_LPWORK=y +CONFIG_SCHED_WAITPID=y +CONFIG_SERIAL_NPOLLWAITERS=2 +CONFIG_STACK_COLORATION=y +CONFIG_START_MONTH=4 +CONFIG_START_YEAR=2021 +CONFIG_SYSTEM_CLE_CMD_HISTORY=y +CONFIG_SYSTEM_NSH=y +CONFIG_SYSTEM_TIME64=y +CONFIG_TASK_NAME_SIZE=20 +CONFIG_TESTING_GETPRIME=y +CONFIG_TESTING_OSTEST=y +CONFIG_UART1_SERIAL_CONSOLE=y diff --git a/boards/risc-v/mpfs/icicle/include/.gitignore b/boards/risc-v/mpfs/icicle/include/.gitignore new file mode 100644 index 0000000000000..be6c25e34444f --- /dev/null +++ b/boards/risc-v/mpfs/icicle/include/.gitignore @@ -0,0 +1,2 @@ +/*_romfsimg.h + diff --git a/boards/risc-v/mpfs/icicle/include/board_memorymap.h b/boards/risc-v/mpfs/icicle/include/board_memorymap.h index 6afed97646eb1..1dc7356e2b8ec 100644 --- a/boards/risc-v/mpfs/icicle/include/board_memorymap.h +++ b/boards/risc-v/mpfs/icicle/include/board_memorymap.h @@ -31,6 +31,11 @@ * Pre-processor Definitions ****************************************************************************/ +/* DDR start address */ + +#define MPFS_DDR_BASE (0x80000000) +#define MPFS_DDR_SIZE (0x40000000) + /* Kernel code memory (RX) */ #define KFLASH_START (uintptr_t)&__kflash_start diff --git a/boards/risc-v/mpfs/icicle/include/boot_romfsimg.h b/boards/risc-v/mpfs/icicle/include/boot_romfsimg.h new file mode 100644 index 0000000000000..863dd2440d1f9 --- /dev/null +++ b/boards/risc-v/mpfs/icicle/include/boot_romfsimg.h @@ -0,0 +1,35 @@ +/**************************************************************************** + * boards/risc-v/mpfs/icicle/include/boot_romfsimg.h + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +#ifndef __BOARDS_RISC_V_MPFS_ICICLE_INCLUDE_BOOT_ROMFSIMG_H +#define __BOARDS_RISC_V_MPFS_ICICLE_INCLUDE_BOOT_ROMFSIMG_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include +const unsigned char aligned_data(4) romfs_img[] = +{ + 0x00 +}; +unsigned int romfs_img_len = 1; + +#endif /* __BOARDS_RISC_V_MPFS_ICICLE_INCLUDE_BOOT_ROMFSIMG_H */ diff --git a/boards/risc-v/mpfs/icicle/scripts/Make.defs b/boards/risc-v/mpfs/icicle/scripts/Make.defs index 778944f119943..228f2f8032ceb 100755 --- a/boards/risc-v/mpfs/icicle/scripts/Make.defs +++ b/boards/risc-v/mpfs/icicle/scripts/Make.defs @@ -45,17 +45,6 @@ ifneq ($(LDMEMORY),) endif ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT) -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g - ASARCHCPUFLAGS += -Wa,-g -endif - -MAXOPTIMIZATION = -Os - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - # The following options are for the toolchain from T-HEAD. # For more info ahout the T-HEAD ISA extensions, please refer to the MPFS user guide. # ARCHCPUFLAGS = -march=rv64gcxthead -mabi=lp64d -mcmodel=medany @@ -63,8 +52,6 @@ endif ARCHCPUFLAGS += -mcmodel=medany -ARCHCFLAGS = -fno-common -ffunction-sections -fdata-sections -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new -fno-rtti ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef @@ -73,7 +60,7 @@ CPICFLAGS = $(ARCHPICFLAGS) $(CFLAGS) CXXFLAGS = $(ARCHCXXFLAGS) $(ARCHWARNINGSXX) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHXXINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) -pipe CXXPICFLAGS = $(ARCHPICFLAGS) $(CXXFLAGS) CPPFLAGS = $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) -AFLAGS += $(CFLAGS) -D__ASSEMBLY__ $(ASARCHCPUFLAGS) +AFLAGS += $(CFLAGS) -D__ASSEMBLY__ # Loadable module definitions @@ -88,8 +75,8 @@ CELFFLAGS = $(CFLAGS) CXXELFFLAGS = $(CXXFLAGS) LDELFFLAGS = -r -e main -LDELFFLAGS += -T $(call CONVERT_PATH,$(BOARD_DIR)$(DELIM)scripts$(DELIM)gnu-elf.ld) +LDELFFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)/binfmt/libelf/gnu-elf.ld) # File extensions -LDFLAGS += --gc-sections -melf64lriscv +LDFLAGS += -melf64lriscv diff --git a/boards/risc-v/mpfs/icicle/scripts/gnu-elf.ld b/boards/risc-v/mpfs/icicle/scripts/gnu-elf.ld deleted file mode 100755 index b513bc6063d24..0000000000000 --- a/boards/risc-v/mpfs/icicle/scripts/gnu-elf.ld +++ /dev/null @@ -1,115 +0,0 @@ -/**************************************************************************** - * boards/risc-v/mpfs/icicle/scripts/gnu-elf.ld - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. The - * ASF licenses this file to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance with the - * License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - ****************************************************************************/ - -SECTIONS -{ - .text 0x00000000 : - { - _stext = . ; - *(.text) - *(.text.*) - *(.gnu.warning) - *(.stub) - *(.glue_7) - *(.glue_7t) - *(.jcr) - - /* C++ support: The .init and .fini sections contain specific logic - * to manage static constructors and destructors. - */ - - *(.gnu.linkonce.t.*) - *(.init) /* Old ABI */ - *(.fini) /* Old ABI */ - _etext = . ; - } - - .rodata : - { - _srodata = . ; - *(.rodata) - *(.rodata1) - *(.rodata.*) - *(.gnu.linkonce.r*) - _erodata = . ; - } - - .data : - { - _sdata = . ; - *(.data) - *(.data1) - *(.data.*) - *(.gnu.linkonce.d*) - . = ALIGN(4); - _edata = . ; - } - - /* C++ support. For each global and static local C++ object, - * GCC creates a small subroutine to construct the object. Pointers - * to these routines (not the routines themselves) are stored as - * simple, linear arrays in the .ctors section of the object file. - * Similarly, pointers to global/static destructor routines are - * stored in .dtors. - */ - - .ctors : - { - _sctors = . ; - *(.ctors) /* Old ABI: Unallocated */ - *(.init_array) /* New ABI: Allocated */ - _edtors = . ; - } - - .dtors : - { - _sdtors = . ; - *(.dtors) /* Old ABI: Unallocated */ - *(.fini_array) /* New ABI: Allocated */ - _edtors = . ; - } - - .bss : - { - _sbss = . ; - *(.bss) - *(.bss.*) - *(.sbss) - *(.sbss.*) - *(.gnu.linkonce.b*) - *(COMMON) - _ebss = . ; - } - - /* Stabs debugging sections. */ - - .stab 0 : { *(.stab) } - .stabstr 0 : { *(.stabstr) } - .stab.excl 0 : { *(.stab.excl) } - .stab.exclstr 0 : { *(.stab.exclstr) } - .stab.index 0 : { *(.stab.index) } - .stab.indexstr 0 : { *(.stab.indexstr) } - .comment 0 : { *(.comment) } - .debug_abbrev 0 : { *(.debug_abbrev) } - .debug_info 0 : { *(.debug_info) } - .debug_line 0 : { *(.debug_line) } - .debug_pubnames 0 : { *(.debug_pubnames) } - .debug_aranges 0 : { *(.debug_aranges) } -} diff --git a/boards/risc-v/mpfs/icicle/scripts/ld-kernel.script b/boards/risc-v/mpfs/icicle/scripts/ld-kernel.script index ab81ad1bc7967..910bc255c130c 100755 --- a/boards/risc-v/mpfs/icicle/scripts/ld-kernel.script +++ b/boards/risc-v/mpfs/icicle/scripts/ld-kernel.script @@ -1,5 +1,5 @@ /**************************************************************************** - * boards/risc-v/mpfs/icicle/scripts/ld.script + * boards/risc-v/mpfs/icicle/scripts/ld-kernel.script * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with @@ -93,15 +93,20 @@ SECTIONS *(.gnu.linkonce.b.*) *(.gnu.linkonce.sb.*) *(COMMON) + } > ksram + + /* Page tables here, align to 4K boundary */ + + .pgtables : ALIGN(0x1000) { + *(.pgtables) . = ALIGN(4); - _ebss = ABSOLUTE(.); } > ksram /* Stack top */ .stack_top : { . = ALIGN(32); - _default_stack_limit = ABSOLUTE(.); + _ebss = ABSOLUTE(.); } > ksram /* Stabs debugging sections. */ diff --git a/boards/risc-v/mpfs/m100pfsevp/configs/nsh/defconfig b/boards/risc-v/mpfs/m100pfsevp/configs/nsh/defconfig index 0940f456773cb..11ccb45acf77b 100644 --- a/boards/risc-v/mpfs/m100pfsevp/configs/nsh/defconfig +++ b/boards/risc-v/mpfs/m100pfsevp/configs/nsh/defconfig @@ -5,7 +5,6 @@ # You can then do "make savedefconfig" to generate a new defconfig file that includes your # modifications. # -# CONFIG_ARCH_FPU is not set # CONFIG_DISABLE_OS_API is not set # CONFIG_NSH_DISABLE_LOSMART is not set CONFIG_ARCH="risc-v" diff --git a/boards/risc-v/mpfs/m100pfsevp/scripts/Make.defs b/boards/risc-v/mpfs/m100pfsevp/scripts/Make.defs index 535499c6a28c8..5c2cd0a703fa3 100755 --- a/boards/risc-v/mpfs/m100pfsevp/scripts/Make.defs +++ b/boards/risc-v/mpfs/m100pfsevp/scripts/Make.defs @@ -30,17 +30,6 @@ endif ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT) -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g - ASARCHCPUFLAGS += -Wa,-g -endif - -MAXOPTIMIZATION = -Os - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - # The following options are for the toolchain from T-HEAD. # For more info ahout the T-HEAD ISA extensions, please refer to the MPFS user guide. # ARCHCPUFLAGS = -march=rv64gcxthead -mabi=lp64d -mcmodel=medany @@ -48,8 +37,6 @@ endif ARCHCPUFLAGS += -mcmodel=medany -ARCHCFLAGS = -fno-common -ffunction-sections -fdata-sections -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new -fno-rtti ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef @@ -58,7 +45,7 @@ CPICFLAGS = $(ARCHPICFLAGS) $(CFLAGS) CXXFLAGS = $(ARCHCXXFLAGS) $(ARCHWARNINGSXX) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHXXINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) -pipe CXXPICFLAGS = $(ARCHPICFLAGS) $(CXXFLAGS) CPPFLAGS = $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) -AFLAGS += $(CFLAGS) -D__ASSEMBLY__ $(ASARCHCPUFLAGS) +AFLAGS += $(CFLAGS) -D__ASSEMBLY__ # Loadable module definitions @@ -73,8 +60,8 @@ CELFFLAGS = $(CFLAGS) CXXELFFLAGS = $(CXXFLAGS) LDELFFLAGS = -r -e main -LDELFFLAGS += -T $(call CONVERT_PATH,$(BOARD_DIR)$(DELIM)scripts$(DELIM)gnu-elf.ld) +LDELFFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)/binfmt/libelf/gnu-elf.ld) # File extensions -LDFLAGS += --gc-sections -melf64lriscv +LDFLAGS += -melf64lriscv diff --git a/boards/risc-v/mpfs/m100pfsevp/scripts/gnu-elf.ld b/boards/risc-v/mpfs/m100pfsevp/scripts/gnu-elf.ld deleted file mode 100755 index a31737ff41299..0000000000000 --- a/boards/risc-v/mpfs/m100pfsevp/scripts/gnu-elf.ld +++ /dev/null @@ -1,115 +0,0 @@ -/**************************************************************************** - * boards/risc-v/mpfs/m100pfsevp/scripts/gnu-elf.ld - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. The - * ASF licenses this file to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance with the - * License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - ****************************************************************************/ - -SECTIONS -{ - .text 0x00000000 : - { - _stext = . ; - *(.text) - *(.text.*) - *(.gnu.warning) - *(.stub) - *(.glue_7) - *(.glue_7t) - *(.jcr) - - /* C++ support: The .init and .fini sections contain specific logic - * to manage static constructors and destructors. - */ - - *(.gnu.linkonce.t.*) - *(.init) /* Old ABI */ - *(.fini) /* Old ABI */ - _etext = . ; - } - - .rodata : - { - _srodata = . ; - *(.rodata) - *(.rodata1) - *(.rodata.*) - *(.gnu.linkonce.r*) - _erodata = . ; - } - - .data : - { - _sdata = . ; - *(.data) - *(.data1) - *(.data.*) - *(.gnu.linkonce.d*) - . = ALIGN(4); - _edata = . ; - } - - /* C++ support. For each global and static local C++ object, - * GCC creates a small subroutine to construct the object. Pointers - * to these routines (not the routines themselves) are stored as - * simple, linear arrays in the .ctors section of the object file. - * Similarly, pointers to global/static destructor routines are - * stored in .dtors. - */ - - .ctors : - { - _sctors = . ; - *(.ctors) /* Old ABI: Unallocated */ - *(.init_array) /* New ABI: Allocated */ - _edtors = . ; - } - - .dtors : - { - _sdtors = . ; - *(.dtors) /* Old ABI: Unallocated */ - *(.fini_array) /* New ABI: Allocated */ - _edtors = . ; - } - - .bss : - { - _sbss = . ; - *(.bss) - *(.bss.*) - *(.sbss) - *(.sbss.*) - *(.gnu.linkonce.b*) - *(COMMON) - _ebss = . ; - } - - /* Stabs debugging sections. */ - - .stab 0 : { *(.stab) } - .stabstr 0 : { *(.stabstr) } - .stab.excl 0 : { *(.stab.excl) } - .stab.exclstr 0 : { *(.stab.exclstr) } - .stab.index 0 : { *(.stab.index) } - .stab.indexstr 0 : { *(.stab.indexstr) } - .comment 0 : { *(.comment) } - .debug_abbrev 0 : { *(.debug_abbrev) } - .debug_info 0 : { *(.debug_info) } - .debug_line 0 : { *(.debug_line) } - .debug_pubnames 0 : { *(.debug_pubnames) } - .debug_aranges 0 : { *(.debug_aranges) } -} diff --git a/boards/risc-v/qemu-rv/rv-virt/README.txt b/boards/risc-v/qemu-rv/rv-virt/README.txt index f9d2388f7fe81..738fc27f7701a 100644 --- a/boards/risc-v/qemu-rv/rv-virt/README.txt +++ b/boards/risc-v/qemu-rv/rv-virt/README.txt @@ -22,11 +22,22 @@ 4. Run the nuttx with qemu - $ qemu-system-riscv32 -M virt -cpu rv32 -smp 8 -bios none -kernel nuttx -nographic + $ qemu-system-riscv32 -semihosting -M virt -cpu rv32 -smp 8 -bios none -kernel nuttx -nographic or - $ qemu-system-riscv64 -M virt -cpu rv64 -smp 8-bios none -kernel nuttx -nographic + $ qemu-system-riscv64 -semihosting -M virt -cpu rv64 -smp 8 -bios none -kernel nuttx -nographic + + NuttShell (NSH) NuttX-10.3.0-RC1 + nsh> mount -t hostfs -o fs=. /host + nsh> cat /host/AUTHORS + This is a list of all the contributors that have submitted ICLA, SGA + If you are not on this list and believe you should be, please inform us. + + ICLA + ==== + ... + nsh> 5. TODO diff --git a/boards/risc-v/qemu-rv/rv-virt/configs/nsh/defconfig b/boards/risc-v/qemu-rv/rv-virt/configs/nsh/defconfig index b4544075c37be..53d6647db8f7a 100644 --- a/boards/risc-v/qemu-rv/rv-virt/configs/nsh/defconfig +++ b/boards/risc-v/qemu-rv/rv-virt/configs/nsh/defconfig @@ -6,18 +6,7 @@ # modifications. # # CONFIG_DISABLE_OS_API is not set -# CONFIG_DISABLE_PSEUDOFS_OPERATIONS is not set -# CONFIG_NSH_DISABLEBG is not set -# CONFIG_NSH_DISABLE_CAT is not set -# CONFIG_NSH_DISABLE_CD is not set -# CONFIG_NSH_DISABLE_FREE is not set -# CONFIG_NSH_DISABLE_HELP is not set # CONFIG_NSH_DISABLE_LOSMART is not set -# CONFIG_NSH_DISABLE_LS is not set -# CONFIG_NSH_DISABLE_MOUNT is not set -# CONFIG_NSH_DISABLE_PS is not set -# CONFIG_NSH_DISABLE_PSSTACKUSAGE is not set -# CONFIG_NSH_DISABLE_UNAME is not set CONFIG_16550_ADDRWIDTH=0 CONFIG_16550_UART0=y CONFIG_16550_UART0_BASE=0x10000000 @@ -37,34 +26,43 @@ CONFIG_ARCH_CHIP_QEMU_RV_ISA_M=y CONFIG_ARCH_INTERRUPTSTACK=2048 CONFIG_ARCH_RISCV=y CONFIG_ARCH_STACKDUMP=y -CONFIG_BINFMT_DISABLE=y CONFIG_BOARD_LOOPSPERMSEC=6366 CONFIG_BUILTIN=y CONFIG_DEBUG_FULLOPT=y CONFIG_DEBUG_SYMBOLS=y -CONFIG_DEFAULT_SMALL=y CONFIG_DEV_ZERO=y +CONFIG_ELF=y +CONFIG_EXAMPLES_HELLO=m +CONFIG_FS_HOSTFS=y CONFIG_FS_PROCFS=y CONFIG_IDLETHREAD_STACKSIZE=2048 CONFIG_INIT_ENTRYPOINT="nsh_main" CONFIG_INTELHEX_BINARY=y +CONFIG_LIBC_ENVPATH=y +CONFIG_LIBC_EXECFUNCS=y CONFIG_LIBC_FLOATINGPOINT=y CONFIG_LIBC_PERROR_STDOUT=y CONFIG_LIBC_STRERROR=y CONFIG_NFILE_DESCRIPTORS_PER_BLOCK=6 CONFIG_NSH_ARCHINIT=y CONFIG_NSH_BUILTIN_APPS=y -CONFIG_NSH_FILEIOSIZE=64 +CONFIG_NSH_FILEIOSIZE=512 +CONFIG_NSH_READLINE=y +CONFIG_PATH_INITIAL="/system/bin" CONFIG_PREALLOC_TIMERS=0 CONFIG_RAM_SIZE=33554432 CONFIG_RAM_START=0x80000000 +CONFIG_READLINE_CMD_HISTORY=y +CONFIG_RISCV_SEMIHOSTING_HOSTFS=y CONFIG_RR_INTERVAL=200 CONFIG_SCHED_WAITPID=y CONFIG_SERIAL_UART_ARCH_MMIO=y CONFIG_STACK_COLORATION=y CONFIG_START_MONTH=12 CONFIG_START_YEAR=2021 +CONFIG_SYMTAB_ORDEREDBYNAME=y CONFIG_SYSTEM_NSH=y +CONFIG_SYSTEM_NSH_SYMTAB=y +CONFIG_SYSTEM_NSH_SYMTAB_ARRAYNAME="g_symtab" CONFIG_TESTING_OSTEST=y -CONFIG_TESTING_OSTEST_FPUSIZE=528 CONFIG_USEC_PER_TICK=1000 diff --git a/boards/risc-v/qemu-rv/rv-virt/configs/nsh64/defconfig b/boards/risc-v/qemu-rv/rv-virt/configs/nsh64/defconfig index f621901598b59..ee1c89c4d0f3e 100644 --- a/boards/risc-v/qemu-rv/rv-virt/configs/nsh64/defconfig +++ b/boards/risc-v/qemu-rv/rv-virt/configs/nsh64/defconfig @@ -6,18 +6,7 @@ # modifications. # # CONFIG_DISABLE_OS_API is not set -# CONFIG_DISABLE_PSEUDOFS_OPERATIONS is not set -# CONFIG_NSH_DISABLEBG is not set -# CONFIG_NSH_DISABLE_CAT is not set -# CONFIG_NSH_DISABLE_CD is not set -# CONFIG_NSH_DISABLE_FREE is not set -# CONFIG_NSH_DISABLE_HELP is not set # CONFIG_NSH_DISABLE_LOSMART is not set -# CONFIG_NSH_DISABLE_LS is not set -# CONFIG_NSH_DISABLE_MOUNT is not set -# CONFIG_NSH_DISABLE_PS is not set -# CONFIG_NSH_DISABLE_PSSTACKUSAGE is not set -# CONFIG_NSH_DISABLE_UNAME is not set CONFIG_16550_ADDRWIDTH=0 CONFIG_16550_UART0=y CONFIG_16550_UART0_BASE=0x10000000 @@ -37,36 +26,46 @@ CONFIG_ARCH_CHIP_QEMU_RV_ISA_M=y CONFIG_ARCH_INTERRUPTSTACK=2048 CONFIG_ARCH_RISCV=y CONFIG_ARCH_STACKDUMP=y -CONFIG_BINFMT_DISABLE=y CONFIG_BOARD_LOOPSPERMSEC=6366 CONFIG_BUILTIN=y CONFIG_DEBUG_FULLOPT=y CONFIG_DEBUG_SYMBOLS=y -CONFIG_DEFAULT_SMALL=y CONFIG_DEV_ZERO=y +CONFIG_ELF=y +CONFIG_EXAMPLES_HELLO=m +CONFIG_FS_HOSTFS=y CONFIG_FS_PROCFS=y CONFIG_IDLETHREAD_STACKSIZE=2048 CONFIG_INIT_ENTRYPOINT="nsh_main" CONFIG_INIT_STACKSIZE=3072 CONFIG_INTELHEX_BINARY=y +CONFIG_LIBC_ENVPATH=y +CONFIG_LIBC_EXECFUNCS=y CONFIG_LIBC_FLOATINGPOINT=y CONFIG_LIBC_PERROR_STDOUT=y CONFIG_LIBC_STRERROR=y CONFIG_NFILE_DESCRIPTORS_PER_BLOCK=6 CONFIG_NSH_ARCHINIT=y CONFIG_NSH_BUILTIN_APPS=y -CONFIG_NSH_FILEIOSIZE=64 +CONFIG_NSH_FILEIOSIZE=512 +CONFIG_NSH_READLINE=y +CONFIG_PATH_INITIAL="/system/bin" CONFIG_PREALLOC_TIMERS=0 CONFIG_RAM_SIZE=33554432 CONFIG_RAM_START=0x80000000 +CONFIG_READLINE_CMD_HISTORY=y +CONFIG_RISCV_SEMIHOSTING_HOSTFS=y CONFIG_RR_INTERVAL=200 CONFIG_SCHED_WAITPID=y CONFIG_SERIAL_UART_ARCH_MMIO=y CONFIG_STACK_COLORATION=y CONFIG_START_MONTH=12 CONFIG_START_YEAR=2021 +CONFIG_SYMTAB_ORDEREDBYNAME=y CONFIG_SYSTEM_NSH=y CONFIG_SYSTEM_NSH_STACKSIZE=3072 +CONFIG_SYSTEM_NSH_SYMTAB=y +CONFIG_SYSTEM_NSH_SYMTAB_ARRAYNAME="g_symtab" +CONFIG_SYSTEM_NSH_SYMTAB_COUNTNAME="g_nsymbols" CONFIG_TESTING_OSTEST=y -CONFIG_TESTING_OSTEST_FPUSIZE=264 CONFIG_USEC_PER_TICK=1000 diff --git a/boards/risc-v/qemu-rv/rv-virt/configs/smp/defconfig b/boards/risc-v/qemu-rv/rv-virt/configs/smp/defconfig index 6830e95321c24..09cbeb05033f9 100644 --- a/boards/risc-v/qemu-rv/rv-virt/configs/smp/defconfig +++ b/boards/risc-v/qemu-rv/rv-virt/configs/smp/defconfig @@ -68,6 +68,5 @@ CONFIG_START_MONTH=12 CONFIG_START_YEAR=2021 CONFIG_SYSTEM_NSH=y CONFIG_TESTING_OSTEST=y -CONFIG_TESTING_OSTEST_FPUSIZE=528 CONFIG_TESTING_SMP=y CONFIG_USEC_PER_TICK=1000 diff --git a/boards/risc-v/qemu-rv/rv-virt/configs/smp64/defconfig b/boards/risc-v/qemu-rv/rv-virt/configs/smp64/defconfig index e9a7d67d2b959..3b5cd2ddce2cb 100644 --- a/boards/risc-v/qemu-rv/rv-virt/configs/smp64/defconfig +++ b/boards/risc-v/qemu-rv/rv-virt/configs/smp64/defconfig @@ -70,6 +70,5 @@ CONFIG_START_YEAR=2021 CONFIG_SYSTEM_NSH=y CONFIG_SYSTEM_NSH_STACKSIZE=3072 CONFIG_TESTING_OSTEST=y -CONFIG_TESTING_OSTEST_FPUSIZE=264 CONFIG_TESTING_SMP=y CONFIG_USEC_PER_TICK=1000 diff --git a/boards/risc-v/qemu-rv/rv-virt/scripts/Make.defs b/boards/risc-v/qemu-rv/rv-virt/scripts/Make.defs index a65f885dd281e..596a800bbbe10 100644 --- a/boards/risc-v/qemu-rv/rv-virt/scripts/Make.defs +++ b/boards/risc-v/qemu-rv/rv-virt/scripts/Make.defs @@ -28,20 +28,7 @@ endif ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT) -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g - ASARCHCPUFLAGS += -Wa,-g -endif - -MAXOPTIMIZATION = -Os - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - ARCHCPUFLAGS += -mcmodel=medany -ARCHCFLAGS = -fno-common -ffunction-sections -fdata-sections -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new -fno-rtti ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic -msingle-pic-base @@ -51,10 +38,26 @@ CPICFLAGS = $(ARCHPICFLAGS) $(CFLAGS) CXXFLAGS := $(ARCHCXXFLAGS) $(ARCHWARNINGSXX) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHXXINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) -pipe CXXPICFLAGS = $(ARCHPICFLAGS) $(CXXFLAGS) CPPFLAGS := $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) -AFLAGS += $(CFLAGS) -D__ASSEMBLY__ $(ASARCHCPUFLAGS) +AFLAGS += $(CFLAGS) -D__ASSEMBLY__ + +# ELF module definitions + +CELFFLAGS = $(CFLAGS) +CXXELFFLAGS = $(CXXFLAGS) + +ifeq ($(CONFIG_ARCH_RV32),y) + LDELFFLAGS = --oformat elf32-littleriscv +else + LDELFFLAGS = --oformat elf64-littleriscv +endif + +LDELFFLAGS += -r -e main +LDELFFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)/binfmt/libelf/gnu-elf.ld) + +# File extensions ifeq ($(CONFIG_ARCH_RV32),y) -LDFLAGS += --gc-sections -melf32lriscv +LDFLAGS += -melf32lriscv else -LDFLAGS += --gc-sections -melf64lriscv +LDFLAGS += -melf64lriscv endif diff --git a/boards/risc-v/qemu-rv/rv-virt/src/Makefile b/boards/risc-v/qemu-rv/rv-virt/src/Makefile index d8a56d84cc52a..dc09f91be700c 100644 --- a/boards/risc-v/qemu-rv/rv-virt/src/Makefile +++ b/boards/risc-v/qemu-rv/rv-virt/src/Makefile @@ -20,8 +20,8 @@ include $(TOPDIR)/Make.defs -RCSRCS = etc/init.d/rcS +RCSRCS = etc/init.d/rc.sysinit etc/init.d/rcS -CSRCS = qemu_rv_appinit.c qemu_rv_ostest.c +CSRCS = qemu_rv_appinit.c include $(TOPDIR)/boards/Board.mk diff --git a/boards/risc-v/qemu-rv/rv-virt/src/etc/init.d/rc.sysinit b/boards/risc-v/qemu-rv/rv-virt/src/etc/init.d/rc.sysinit new file mode 100644 index 0000000000000..2f750bb614700 --- /dev/null +++ b/boards/risc-v/qemu-rv/rv-virt/src/etc/init.d/rc.sysinit @@ -0,0 +1,19 @@ +/**************************************************************************** + * boards/risc-v/qemu-rv/rv-virt/src/etc/init.d/rc.sysinit + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ diff --git a/boards/risc-v/qemu-rv/rv-virt/src/etc/init.d/rcS b/boards/risc-v/qemu-rv/rv-virt/src/etc/init.d/rcS index e69de29bb2d1d..08a25f93ff5c5 100644 --- a/boards/risc-v/qemu-rv/rv-virt/src/etc/init.d/rcS +++ b/boards/risc-v/qemu-rv/rv-virt/src/etc/init.d/rcS @@ -0,0 +1,19 @@ +/**************************************************************************** + * boards/risc-v/qemu-rv/rv-virt/src/etc/init.d/rcS + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ diff --git a/boards/risc-v/qemu-rv/rv-virt/src/qemu_rv_ostest.c b/boards/risc-v/qemu-rv/rv-virt/src/qemu_rv_ostest.c deleted file mode 100644 index d06f3e1cd9a16..0000000000000 --- a/boards/risc-v/qemu-rv/rv-virt/src/qemu_rv_ostest.c +++ /dev/null @@ -1,92 +0,0 @@ -/**************************************************************************** - * boards/risc-v/qemu-rv/rv-virt/src/qemu_rv_ostest.c - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. The - * ASF licenses this file to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance with the - * License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - ****************************************************************************/ - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include - -#include -#include -#include -#include - -#include - -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -/* Configuration ************************************************************/ - -#undef HAVE_FPU -#if defined(CONFIG_ARCH_FPU) && \ - !defined(CONFIG_TESTING_OSTEST_FPUTESTDISABLE) && \ - defined(CONFIG_TESTING_OSTEST_FPUSIZE) && \ - defined(CONFIG_SCHED_WAITPID) -# define HAVE_FPU 1 -#endif - -#ifdef HAVE_FPU - -#if CONFIG_TESTING_OSTEST_FPUSIZE != (8 * FPU_XCPT_REGS) -# error "CONFIG_TESTING_OSTEST_FPUSIZE has the wrong size" -#endif - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -static uintptr_t g_saveregs[XCPTCONTEXT_REGS]; - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/* Given an array of size CONFIG_TESTING_OSTEST_FPUSIZE, this function will - * return the current FPU registers. - */ - -void arch_getfpu(FAR uint32_t *fpusave) -{ - irqstate_t flags; - - /* Take a snapshot of the thread context right now */ - - flags = enter_critical_section(); - riscv_saveusercontext(g_saveregs); - - /* Return only the floating register values */ - - memcpy(fpusave, &g_saveregs[INT_XCPT_REGS], INT_REG_SIZE * FPU_XCPT_REGS); - leave_critical_section(flags); -} - -/* Given two arrays of size CONFIG_TESTING_OSTEST_FPUSIZE this function - * will compare them and return true if they are identical. - */ - -bool arch_cmpfpu(FAR const uint32_t *fpusave1, FAR const uint32_t *fpusave2) -{ - return memcmp(fpusave1, fpusave2, INT_REG_SIZE * FPU_XCPT_REGS) == 0; -} - -#endif /* HAVE_FPU */ diff --git a/boards/risc-v/rv32m1/rv32m1-vega/scripts/Make.defs b/boards/risc-v/rv32m1/rv32m1-vega/scripts/Make.defs index 7e3bb3817402d..31038e3ebdc9d 100644 --- a/boards/risc-v/rv32m1/rv32m1-vega/scripts/Make.defs +++ b/boards/risc-v/rv32m1/rv32m1-vega/scripts/Make.defs @@ -34,17 +34,6 @@ endif ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT) -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g - ASARCHCPUFLAGS += -Wa,-g -endif - -MAXOPTIMIZATION = -Os - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - ifeq ($(CONFIG_RV32M1_OPENISA_TOOLCHAIN),y) ifdef CONFIG_ARCH_RISCV_INTXCPT_EXTREGS ifeq ($(filter 0 1 2 3 4 5 , $(CONFIG_ARCH_RISCV_INTXCPT_EXTREGS)),) @@ -53,8 +42,6 @@ ifeq ($(CONFIG_RV32M1_OPENISA_TOOLCHAIN),y) endif endif -ARCHCFLAGS = -fno-common -ffunction-sections -fdata-sections -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new -fno-rtti ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 @@ -64,6 +51,6 @@ CPICFLAGS = $(ARCHPICFLAGS) $(CFLAGS) CXXFLAGS := $(ARCHCXXFLAGS) $(ARCHWARNINGSXX) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHXXINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) -pipe CXXPICFLAGS = $(ARCHPICFLAGS) $(CXXFLAGS) CPPFLAGS := $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) -AFLAGS += $(CFLAGS) -D__ASSEMBLY__ $(ASARCHCPUFLAGS) +AFLAGS += $(CFLAGS) -D__ASSEMBLY__ -LDFLAGS += --gc-sections -melf32lriscv +LDFLAGS += -melf32lriscv diff --git a/boards/risc-v/rv32m1/rv32m1-vega/src/rv32m1_buttons.c b/boards/risc-v/rv32m1/rv32m1-vega/src/rv32m1_buttons.c index 542b3ea197306..3471c6fddd3a3 100644 --- a/boards/risc-v/rv32m1/rv32m1-vega/src/rv32m1_buttons.c +++ b/boards/risc-v/rv32m1/rv32m1-vega/src/rv32m1_buttons.c @@ -120,7 +120,7 @@ uint32_t board_buttons(void) ****************************************************************************/ #ifdef CONFIG_ARCH_IRQBUTTONS -int board_button_irq(int id, xcpt_t irqhandler, FAR void *arg) +int board_button_irq(int id, xcpt_t irqhandler, void *arg) { int ret = -EINVAL; diff --git a/boards/sim/sim/sim/README.txt b/boards/sim/sim/sim/README.txt index eebd532efb357..ef5642f65368b 100644 --- a/boards/sim/sim/sim/README.txt +++ b/boards/sim/sim/sim/README.txt @@ -955,9 +955,9 @@ nxwm /* Execute the startup script */ #ifdef CONFIG_NSH_ROMFSETC - - (void)nsh_script(&pstate->cn_vtbl, "init", NSH_INITPATH); + - nsh_script(&pstate->cn_vtbl, "init", NSH_INITPATH); +// REMOVE ME - +// (void)nsh_script(&pstate->cn_vtbl, "init", NSH_INITPATH); + +// nsh_script(&pstate->cn_vtbl, "init", NSH_INITPATH); #endif /* Then enter the command line parsing loop */ diff --git a/boards/sim/sim/sim/include/board.h b/boards/sim/sim/sim/include/board.h index 6c490b25aee1d..fde01bb2761ab 100644 --- a/boards/sim/sim/sim/include/board.h +++ b/boards/sim/sim/sim/include/board.h @@ -1,3 +1,19 @@ /**************************************************************************** * boards/sim/sim/sim/include/board.h + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * ****************************************************************************/ diff --git a/boards/sim/sim/sim/scripts/Make.defs b/boards/sim/sim/sim/scripts/Make.defs index fb6bad3a97d30..1ff305e56796f 100644 --- a/boards/sim/sim/sim/scripts/Make.defs +++ b/boards/sim/sim/sim/scripts/Make.defs @@ -41,22 +41,28 @@ ARCHDEFINES += -U__NetBSD__ -U__linux__ -U__sun__ -U__unix__ ARCHDEFINES += -U__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g - ARCHOPTIMIZATIONRUST = -g + ARCHOPTIMIZATION += -g + ARCHOPTIMIZATIONRUST += -g endif ifeq ($(CONFIG_DEBUG_CUSTOMOPT),y) - MAXOPTIMIZATION := $(CONFIG_DEBUG_OPTLEVEL) -else - MAXOPTIMIZATION ?= -O2 + ARCHOPTIMIZATION += $(CONFIG_DEBUG_OPTLEVEL) +else ifeq ($(CONFIG_DEBUG_FULLOPT),y) + ARCHOPTIMIZATION += -O2 endif ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing + ARCHOPTIMIZATION += -fno-strict-aliasing else ARCHOPTIMIZATIONRUST += -C opt-level=0 endif +ifeq ($(CONFIG_FRAME_POINTER),y) + ARCHOPTIMIZATION += -fno-omit-frame-pointer -fno-optimize-sibling-calls +else + ARCHOPTIMIZATION += -fomit-frame-pointer +endif + ifeq ($(CONFIG_STACK_CANARIES),y) ARCHOPTIMIZATION += -fstack-protector-all endif @@ -116,16 +122,6 @@ AFLAGS := $(CFLAGS) -D__ASSEMBLY__ RUSTFLAGS := $(ARCHOPTIMIZATIONRUST) ifeq ($(CONFIG_LIBCXX),y) - # Why c++17? - # * libcxx seems to require c++11. - # * The compiler defaults varies: - # clang/macOS (from xcode): 199711L - # gcc/ubuntu: 201402L - # * There is a precedent to use c++14. - # (boards/arm/stm32l4/nucleo-l476rg/scripts/Make.defs) - # * libs/libxx/libcxx/src/barrier.cpp depends on aligned new - CXXFLAGS += -std=c++17 - ifeq ($(CONFIG_HOST_MACOS),y) # macOS uses libc++abi CXXFLAGS += -DLIBCXX_BUILDING_LIBCXXABI @@ -158,14 +154,6 @@ ifeq ($(CONFIG_SIM_UBSAN),y) CXXFLAGS += -fsanitize=undefined endif -ifeq ($(CONFIG_FRAME_POINTER),y) - CFLAGS += -fno-omit-frame-pointer -fno-optimize-sibling-calls - CXXFLAGS += -fno-omit-frame-pointer -fno-optimize-sibling-calls -else - CFLAGS += -fomit-frame-pointer - CXXFLAGS += -fomit-frame-pointer -endif - # Loadable module definitions CMODULEFLAGS = $(CFLAGS) @@ -211,7 +199,7 @@ ifeq ($(CONFIG_LIBC_ARCH_ELF_64BIT),y) endif LDELFFLAGS = -r -e main --gc-sections -LDELFFLAGS += -T $(call CONVERT_PATH,$(BOARD_DIR)$(DELIM)scripts$(DELIM)gnu-elf.ld) +LDELFFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)/binfmt/libelf/gnu-elf.ld) ifeq ($(CONFIG_HOST_MACOS),y) LDFLAGS += -Wl,-dead_strip diff --git a/boards/sim/sim/sim/scripts/gnu-elf.ld b/boards/sim/sim/sim/scripts/gnu-elf.ld deleted file mode 100644 index 47cd5c7d50643..0000000000000 --- a/boards/sim/sim/sim/scripts/gnu-elf.ld +++ /dev/null @@ -1,117 +0,0 @@ -/**************************************************************************** - * boards/sim/sim/sim/scripts/gnu-elf.ld - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. The - * ASF licenses this file to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance with the - * License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - ****************************************************************************/ - -ENTRY(main) -SECTIONS -{ - .text 0x00000000 : - { - _stext = . ; - *(.text) - *(.text.*) - *(.gnu.warning) - *(.stub) - *(.glue_7) - *(.glue_7t) - *(.jcr) - - /* C++ support: The .init and .fini sections contain specific logic - * to manage static constructors and destructors. - */ - - *(.gnu.linkonce.t.*) - *(.init) /* Old ABI */ - *(.fini) /* Old ABI */ - _etext = . ; - } - - .rodata : - { - _srodata = . ; - *(.rodata) - *(.rodata1) - *(.rodata.*) - *(.gnu.linkonce.r*) - _erodata = . ; - } - - .data : - { - _sdata = . ; - *(.data) - *(.data1) - *(.data.*) - *(.gnu.linkonce.d*) - . = ALIGN(4); - _edata = . ; - } - - /* C++ support. For each global and static local C++ object, - * GCC creates a small subroutine to construct the object. Pointers - * to these routines (not the routines themselves) are stored as - * simple, linear arrays in the .ctors section of the object file. - * Similarly, pointers to global/static destructor routines are - * stored in .dtors. - */ - - .ctors : - { - _sctors = . ; - *(.ctors) /* Old ABI: Unallocated */ - *(.init_array) /* New ABI: Allocated */ - _edtors = . ; - } - - .dtors : - { - _sdtors = . ; - *(.dtors) /* Old ABI: Unallocated */ - *(.fini_array) /* New ABI: Allocated */ - _edtors = . ; - } - - .bss : - { - _sbss = . ; - *(.bss) - *(.bss.*) - *(.sbss) - *(.sbss.*) - *(.gnu.linkonce.b*) - *(COMMON) - . = ALIGN(4); - _ebss = . ; - } - - /* Stabs debugging sections. */ - - .stab 0 : { *(.stab) } - .stabstr 0 : { *(.stabstr) } - .stab.excl 0 : { *(.stab.excl) } - .stab.exclstr 0 : { *(.stab.exclstr) } - .stab.index 0 : { *(.stab.index) } - .stab.indexstr 0 : { *(.stab.indexstr) } - .comment 0 : { *(.comment) } - .debug_abbrev 0 : { *(.debug_abbrev) } - .debug_info 0 : { *(.debug_info) } - .debug_line 0 : { *(.debug_line) } - .debug_pubnames 0 : { *(.debug_pubnames) } - .debug_aranges 0 : { *(.debug_aranges) } -} diff --git a/boards/sim/sim/sim/src/Makefile b/boards/sim/sim/sim/src/Makefile index 413605456deb2..a249ae8afaf44 100644 --- a/boards/sim/sim/sim/src/Makefile +++ b/boards/sim/sim/sim/src/Makefile @@ -54,7 +54,7 @@ endif ifeq ($(CONFIG_NSH_ROMFSETC),y) ifneq ($(CONFIG_NSH_CUSTOMROMFS),y) - RCSRCS = etc/init.d/rcS + RCSRCS = etc/init.d/rc.sysinit etc/init.d/rcS RCRAWS = etc/group etc/passwd endif endif diff --git a/boards/sim/sim/sim/src/README.txt b/boards/sim/sim/sim/src/README.txt index 6c906d5b26ed1..317699de68ed6 100644 --- a/boards/sim/sim/sim/src/README.txt +++ b/boards/sim/sim/sim/src/README.txt @@ -3,10 +3,10 @@ README Overview -------- - This directory contains logic to support a custom ROMFS start-up script. - This startup script is used by by the NSH when it starts provided that - CONFIG_NSH_ARCHROMFS=y. The script provides a ROMFS volume that will be - mounted at /etc and will look like this at run-time: + This directory contains logic to support a custom ROMFS system-init script + and start-up script. These scripts are used by by the NSH when it starts + provided that CONFIG_NSH_ARCHROMFS=y. These scripts provide a ROMFS volume + that will be mounted at /etc and will look like this at run-time: NuttShell (NSH) NuttX-7.31 MOTD: username=admin password=Administrator @@ -19,10 +19,11 @@ README /etc/init.d: dr-xr-xr-x 0 .. -r--r--r-- 110 rcS + -r--r--r-- 110 rc.sysinit nsh> - /etc/init.d/rcS is the start-up script; /etc/passwd is a the password - file. It supports a single user: + /etc/init.d/rc.sysinit is system init script; /etc/init.d/rcS is the start-up + script; /etc/passwd is a the password file. It supports a single user: USERNAME: admin PASSWORD: Administrator diff --git a/boards/sim/sim/sim/src/dummy.c b/boards/sim/sim/sim/src/dummy.c index 8b137891791fe..6110f32d1be18 100644 --- a/boards/sim/sim/sim/src/dummy.c +++ b/boards/sim/sim/sim/src/dummy.c @@ -1 +1,19 @@ - +/*************************************************************************** + * boards/sim/sim/sim/src/dummy.c + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ***************************************************************************/ diff --git a/boards/sim/sim/sim/src/etc/init.d/rc.sysinit b/boards/sim/sim/sim/src/etc/init.d/rc.sysinit new file mode 100644 index 0000000000000..1d2f23dc31aaf --- /dev/null +++ b/boards/sim/sim/sim/src/etc/init.d/rc.sysinit @@ -0,0 +1,36 @@ +/**************************************************************************** + * boards/sim/sim/sim/src/etc/init.d/rc.sysinit + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +#include + +#define CONCAT_(x, y) x##y +#define CONCAT(x, y) CONCAT_(x, y) + +#ifdef CONFIG_NSH_ROMFSETC +#ifdef CONFIG_FS_FAT + +/* Create a RAMDISK and mount it at /tmp */ + +mkrd -m CONFIG_NSH_FATDEVNO -s CONFIG_NSH_FATSECTSIZE CONFIG_NSH_FATNSECTORS +mkfatfs CONCAT(/dev/ram, CONFIG_NSH_FATDEVNO) +mount -t vfat CONCAT(/dev/ram, CONFIG_NSH_FATDEVNO) CONFIG_NSH_FATMOUNTPT + +#endif /* CONFIG_FS_FAT */ +#endif /* CONFIG_NSH_ROMFSETC */ diff --git a/boards/sim/sim/sim/src/etc/init.d/rcS b/boards/sim/sim/sim/src/etc/init.d/rcS index 29ae0dd696cec..2cc08c80b4bac 100644 --- a/boards/sim/sim/sim/src/etc/init.d/rcS +++ b/boards/sim/sim/sim/src/etc/init.d/rcS @@ -17,20 +17,3 @@ * under the License. * ****************************************************************************/ - -#include - -#define CONCAT_(x, y) x##y -#define CONCAT(x, y) CONCAT_(x, y) - -#ifdef CONFIG_NSH_ROMFSETC -#ifdef CONFIG_FS_FAT - -/* Create a RAMDISK and mount it at /tmp */ - -mkrd -m CONFIG_NSH_FATDEVNO -s CONFIG_NSH_FATSECTSIZE CONFIG_NSH_FATNSECTORS -mkfatfs CONCAT(/dev/ram, CONFIG_NSH_FATDEVNO) -mount -t vfat CONCAT(/dev/ram, CONFIG_NSH_FATDEVNO) CONFIG_NSH_FATMOUNTPT - -#endif /* CONFIG_FS_FAT */ -#endif /* CONFIG_NSH_ROMFSETC */ diff --git a/boards/sim/sim/sim/src/sim_bringup.c b/boards/sim/sim/sim/src/sim_bringup.c index c6404ee1d77aa..0643277664bf5 100644 --- a/boards/sim/sim/sim/src/sim_bringup.c +++ b/boards/sim/sim/sim/src/sim_bringup.c @@ -89,19 +89,19 @@ void rpmsg_serialinit(void) int sim_bringup(void) { #ifdef CONFIG_ONESHOT - FAR struct oneshot_lowerhalf_s *oneshot; + struct oneshot_lowerhalf_s *oneshot; #endif #ifdef CONFIG_RAMMTD - FAR uint8_t *ramstart; + uint8_t *ramstart; #endif #ifdef CONFIG_SIM_I2CBUS - FAR struct i2c_master_s *i2cbus; + struct i2c_master_s *i2cbus; #endif #ifdef CONFIG_MPU60X0_I2C - FAR struct mpu_config_s *mpu_config; + struct mpu_config_s *mpu_config; #endif #ifdef CONFIG_SIM_SPI - FAR struct spi_dev_s *spidev; + struct spi_dev_s *spidev; #endif int ret = OK; @@ -152,7 +152,7 @@ int sim_bringup(void) #ifdef CONFIG_RAMMTD /* Create a RAM MTD device if configured */ - ramstart = (FAR uint8_t *)kmm_malloc(128 * 1024); + ramstart = (uint8_t *)kmm_malloc(128 * 1024); if (ramstart == NULL) { syslog(LOG_ERR, "ERROR: Allocation for RAM MTD failed\n"); @@ -161,7 +161,7 @@ int sim_bringup(void) { /* Initialized the RAM MTD */ - FAR struct mtd_dev_s *mtd = rammtd_initialize(ramstart, 128 * 1024); + struct mtd_dev_s *mtd = rammtd_initialize(ramstart, 128 * 1024); if (mtd == NULL) { syslog(LOG_ERR, "ERROR: rammtd_initialize failed\n"); @@ -318,6 +318,16 @@ int sim_bringup(void) } #endif +#ifdef CONFIG_SIM_KEYBOARD + /* Initialize the keyboard */ + + ret = sim_kbd_initialize(); + if (ret < 0) + { + syslog(LOG_ERR, "ERROR: sim_kbd_initialize failed: %d\n", ret); + } +#endif + #ifdef CONFIG_IEEE802154_LOOPBACK /* Initialize and register the IEEE802.15.4 MAC network loop device */ @@ -351,7 +361,7 @@ int sim_bringup(void) #ifdef CONFIG_SIM_HCISOCKET /* Register the Host Bluetooth network device via HCI socket */ - ret = bthcisock_register(0); /* Use HCI0 */ + ret = bthcisock_register(CONFIG_SIM_HCISOCKET_DEVID); if (ret < 0) { syslog(LOG_ERR, "ERROR: bthcisock_register() failed: %d\n", ret); diff --git a/boards/sim/sim/sim/src/sim_buttons.c b/boards/sim/sim/sim/src/sim_buttons.c index d59303d484cab..478f8e7d6f436 100644 --- a/boards/sim/sim/sim/src/sim_buttons.c +++ b/boards/sim/sim/sim/src/sim_buttons.c @@ -46,7 +46,7 @@ uint32_t g_buttons = 0; xcpt_t g_handler = NULL; -FAR void *g_arg = 0; +void *g_arg = 0; /**************************************************************************** * Public Data @@ -111,7 +111,7 @@ uint32_t board_buttons(void) ****************************************************************************/ #ifdef CONFIG_ARCH_IRQBUTTONS -int board_button_irq(int id, xcpt_t irqhandler, FAR void *arg) +int board_button_irq(int id, xcpt_t irqhandler, void *arg) { int ret = -EINVAL; diff --git a/boards/sim/sim/sim/src/sim_foc.c b/boards/sim/sim/sim/src/sim_foc.c index 36080555f4c3c..bc3c820321111 100644 --- a/boards/sim/sim/sim/src/sim_foc.c +++ b/boards/sim/sim/sim/src/sim_foc.c @@ -56,7 +56,7 @@ int sim_foc_setup(void) { - FAR struct foc_dev_s *foc[CONFIG_MOTOR_FOC_INST]; + struct foc_dev_s *foc[CONFIG_MOTOR_FOC_INST]; static bool initialized = false; int ret = OK; int i = 0; diff --git a/boards/sim/sim/sim/src/sim_gpio.c b/boards/sim/sim/sim/src/sim_gpio.c index 4cdb76ad64ffb..dd0a3dfe0a36d 100644 --- a/boards/sim/sim/sim/src/sim_gpio.c +++ b/boards/sim/sim/sim/src/sim_gpio.c @@ -58,11 +58,11 @@ struct simgpint_dev_s * Private Function Prototypes ****************************************************************************/ -static int gpin_read(FAR struct gpio_dev_s *dev, FAR bool *value); -static int gpout_write(FAR struct gpio_dev_s *dev, bool value); -static int gpint_attach(FAR struct gpio_dev_s *dev, +static int gpin_read(struct gpio_dev_s *dev, bool *value); +static int gpout_write(struct gpio_dev_s *dev, bool value); +static int gpint_attach(struct gpio_dev_s *dev, pin_interrupt_t callback); -static int gpint_enable(FAR struct gpio_dev_s *dev, bool enable); +static int gpint_enable(struct gpio_dev_s *dev, bool enable); /**************************************************************************** * Private Data @@ -131,7 +131,7 @@ static struct simgpint_dev_s g_gpint = static int sim_interrupt(wdparm_t arg) { - FAR struct simgpint_dev_s *simgpint = (FAR struct simgpint_dev_s *)arg; + struct simgpint_dev_s *simgpint = (struct simgpint_dev_s *)arg; DEBUGASSERT(simgpint != NULL && simgpint->callback != NULL); gpioinfo("Interrupt! callback=%p\n", simgpint->callback); @@ -140,9 +140,9 @@ static int sim_interrupt(wdparm_t arg) return OK; } -static int gpin_read(FAR struct gpio_dev_s *dev, FAR bool *value) +static int gpin_read(struct gpio_dev_s *dev, bool *value) { - FAR struct simgpio_dev_s *simgpio = (FAR struct simgpio_dev_s *)dev; + struct simgpio_dev_s *simgpio = (struct simgpio_dev_s *)dev; DEBUGASSERT(simgpio != NULL && value != NULL); gpioinfo("Reading %d (next=%d)\n", @@ -153,9 +153,9 @@ static int gpin_read(FAR struct gpio_dev_s *dev, FAR bool *value) return OK; } -static int gpout_write(FAR struct gpio_dev_s *dev, bool value) +static int gpout_write(struct gpio_dev_s *dev, bool value) { - FAR struct simgpio_dev_s *simgpio = (FAR struct simgpio_dev_s *)dev; + struct simgpio_dev_s *simgpio = (struct simgpio_dev_s *)dev; DEBUGASSERT(simgpio != NULL); gpioinfo("Writing %d\n", (int)value); @@ -164,10 +164,10 @@ static int gpout_write(FAR struct gpio_dev_s *dev, bool value) return OK; } -static int gpint_attach(FAR struct gpio_dev_s *dev, +static int gpint_attach(struct gpio_dev_s *dev, pin_interrupt_t callback) { - FAR struct simgpint_dev_s *simgpint = (FAR struct simgpint_dev_s *)dev; + struct simgpint_dev_s *simgpint = (struct simgpint_dev_s *)dev; gpioinfo("Cancel 1 second timer\n"); wd_cancel(&simgpint->wdog); @@ -177,9 +177,9 @@ static int gpint_attach(FAR struct gpio_dev_s *dev, return OK; } -static int gpint_enable(FAR struct gpio_dev_s *dev, bool enable) +static int gpint_enable(struct gpio_dev_s *dev, bool enable) { - FAR struct simgpint_dev_s *simgpint = (FAR struct simgpint_dev_s *)dev; + struct simgpint_dev_s *simgpint = (struct simgpint_dev_s *)dev; if (enable) { diff --git a/boards/sim/sim/sim/src/sim_ioexpander.c b/boards/sim/sim/sim/src/sim_ioexpander.c index 4014597f373f5..ad71041305dd3 100644 --- a/boards/sim/sim/sim/src/sim_ioexpander.c +++ b/boards/sim/sim/sim/src/sim_ioexpander.c @@ -50,7 +50,7 @@ int sim_gpio_initialize(void) { /* Get an instance of the simulated I/O expander */ - FAR struct ioexpander_dev_s *ioe = ioe_dummy_initialize(); + struct ioexpander_dev_s *ioe = ioe_dummy_initialize(); if (ioe == NULL) { gpioerr("ERROR: ioe_dummy_initialize failed\n"); @@ -63,36 +63,36 @@ int sim_gpio_initialize(void) IOEXP_SETDIRECTION(ioe, 0, IOEXPANDER_DIRECTION_IN); IOEXP_SETOPTION(ioe, 0, IOEXPANDER_OPTION_INVERT, - (FAR void *)IOEXPANDER_VAL_NORMAL); + (void *)IOEXPANDER_VAL_NORMAL); IOEXP_SETOPTION(ioe, 0, IOEXPANDER_OPTION_INTCFG, - (FAR void *)IOEXPANDER_VAL_DISABLE); + (void *)IOEXPANDER_VAL_DISABLE); gpio_lower_half(ioe, 0, GPIO_INPUT_PIN, 0); /* Pin 1: an non-inverted, output pin */ IOEXP_SETDIRECTION(ioe, 1, IOEXPANDER_DIRECTION_OUT); IOEXP_SETOPTION(ioe, 1, IOEXPANDER_OPTION_INVERT, - (FAR void *)IOEXPANDER_VAL_NORMAL); + (void *)IOEXPANDER_VAL_NORMAL); IOEXP_SETOPTION(ioe, 2, IOEXPANDER_OPTION_INTCFG, - (FAR void *)IOEXPANDER_VAL_DISABLE); + (void *)IOEXPANDER_VAL_DISABLE); gpio_lower_half(ioe, 1, GPIO_OUTPUT_PIN, 1); /* Pin 2: an non-inverted, edge interrupting pin */ IOEXP_SETDIRECTION(ioe, 2, IOEXPANDER_DIRECTION_IN); IOEXP_SETOPTION(ioe, 2, IOEXPANDER_OPTION_INVERT, - (FAR void *)IOEXPANDER_VAL_NORMAL); + (void *)IOEXPANDER_VAL_NORMAL); IOEXP_SETOPTION(ioe, 2, IOEXPANDER_OPTION_INTCFG, - (FAR void *)IOEXPANDER_VAL_BOTH); + (void *)IOEXPANDER_VAL_BOTH); gpio_lower_half(ioe, 2, GPIO_INTERRUPT_PIN, 2); /* Pin 3: a non-inverted, level interrupting pin */ IOEXP_SETDIRECTION(ioe, 3, IOEXPANDER_DIRECTION_IN); IOEXP_SETOPTION(ioe, 3, IOEXPANDER_OPTION_INVERT, - (FAR void *)IOEXPANDER_VAL_NORMAL); + (void *)IOEXPANDER_VAL_NORMAL); IOEXP_SETOPTION(ioe, 3, IOEXPANDER_OPTION_INTCFG, - (FAR void *)IOEXPANDER_VAL_HIGH); + (void *)IOEXPANDER_VAL_HIGH); gpio_lower_half(ioe, 3, GPIO_INTERRUPT_PIN, 3); return 0; diff --git a/boards/sparc/bm3803/xx3803/scripts/Make.defs b/boards/sparc/bm3803/xx3803/scripts/Make.defs index b2e5cbc2941d1..ebb9f81a85a8f 100644 --- a/boards/sparc/bm3803/xx3803/scripts/Make.defs +++ b/boards/sparc/bm3803/xx3803/scripts/Make.defs @@ -23,10 +23,10 @@ include ${TOPDIR}/tools/Config.mk include ${TOPDIR}/arch/sparc/src/sparc_v8/Toolchain.defs LDSCRIPT = linksparc.ld +ARCHSCRIPT += $(TOPDIR)/boards/$(CONFIG_ARCH)/$(CONFIG_ARCH_CHIP)/$(CONFIG_ARCH_BOARD)/scripts/$(LDSCRIPT) ARCHINCLUDES = -I. -isystem $(call CONVERT_PATH,$(TOPDIR)/include) ARCHXXINCLUDES = $(ARCHINCLUDES) -isystem $(call CONVERT_PATH,$(TOPDIR)/include/cxx) -ARCHSCRIPT += $(TOPDIR)/boards/$(CONFIG_ARCH)/$(CONFIG_ARCH_CHIP)/$(CONFIG_ARCH_BOARD)/scripts/$(LDSCRIPT) CC = $(CROSSDEV)gcc CXX = $(CROSSDEV)g++ @@ -38,21 +38,11 @@ NM = $(CROSSDEV)nm OBJCOPY = $(CROSSDEV)objcopy OBJDUMP = $(CROSSDEV)objdump -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - # ARCHOPTIMIZATION += -fno-zero-initialized-in-bss # 20210818 zouboan ARCHOPTIMIZATION += -fno-delete-null-pointer-checks -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHDEFINES = @@ -71,18 +61,8 @@ CXXELFFLAGS = $(CXXFLAGS) LDELFFLAGS = -r -e main LDELFFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)/boards/$(CONFIG_ARCH)/$(CONFIG_ARCH_CHIP)/$(CONFIG_ARCH_BOARD)/scripts/gnu-elf.ld) -# File extensions - -ASMEXT = .S -OBJEXT = .o -LIBEXT = .a -EXEEXT = .elf - # Linker flags ifneq ($(CROSSDEV),sparc-nuttx-elf-) LDFLAGS += -nostartfiles -nodefaultlibs -endif -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - LDFLAGS += -g -endif +endif \ No newline at end of file diff --git a/boards/sparc/bm3803/xx3803/scripts/gnu-elf.ld b/boards/sparc/bm3803/xx3803/scripts/gnu-elf.ld deleted file mode 100644 index 71f7620e89e36..0000000000000 --- a/boards/sparc/bm3803/xx3803/scripts/gnu-elf.ld +++ /dev/null @@ -1,84 +0,0 @@ -/**************************************************************************** - * boards/sparc/bm3803/xx3803/scripts/gnu-elf.ld - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. The - * ASF licenses this file to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance with the - * License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - ****************************************************************************/ - -SECTIONS -{ - .text 0x00000000 : - { - _stext = . ; - *(.text) - *(.text.*) - *(.gnu.warning) - *(.stub) - *(.jcr) - _etext = . ; - } - - .rodata : - { - _srodata = . ; - *(.rodata) - *(.rodata1) - *(.rodata.*) - *(.gnu.linkonce.r*) - _erodata = . ; - } - - - .data : - { - _sdata = . ; - *(.data) - *(.data1) - *(.data.*) - *(.gnu.linkonce.d*) - . = ALIGN(4); - _edata = . ; - } - - .bss : - { - _sbss = . ; - *(.bss) - *(.bss.*) - *(.sbss) - *(.sbss.*) - *(.gnu.linkonce.b*) - *(COMMON) - . = ALIGN(4); - _ebss = . ; - } - - /* Stabs debugging sections. */ - - .stab 0 : { *(.stab) } - .stabstr 0 : { *(.stabstr) } - .stab.excl 0 : { *(.stab.excl) } - .stab.exclstr 0 : { *(.stab.exclstr) } - .stab.index 0 : { *(.stab.index) } - .stab.indexstr 0 : { *(.stab.indexstr) } - .comment 0 : { *(.comment) } - .debug_abbrev 0 : { *(.debug_abbrev) } - .debug_info 0 : { *(.debug_info) } - .debug_line 0 : { *(.debug_line) } - .debug_pubnames 0 : { *(.debug_pubnames) } - .debug_aranges 0 : { *(.debug_aranges) } - -} diff --git a/boards/sparc/bm3803/xx3803/src/bm3803_am29lv.c b/boards/sparc/bm3803/xx3803/src/bm3803_am29lv.c index 93a8375832f65..ffa70603a4e38 100644 --- a/boards/sparc/bm3803/xx3803/src/bm3803_am29lv.c +++ b/boards/sparc/bm3803/xx3803/src/bm3803_am29lv.c @@ -81,9 +81,9 @@ int bm3803_am29lv_initialize(int minor) { int ret; #ifdef HAVE_AM29LV - FAR struct mtd_dev_s *mtd; + struct mtd_dev_s *mtd; #if defined(CONFIG_MTD_PARTITION_NAMES) - FAR const char *partname = CONFIG_XX3803_FLASH_PART_NAMES; + const char *partname = CONFIG_XX3803_FLASH_PART_NAMES; #endif /* Now bind the SPI interface to the W25 SPI FLASH driver */ diff --git a/boards/sparc/bm3803/xx3803/src/bm3803_wdt.c b/boards/sparc/bm3803/xx3803/src/bm3803_wdt.c index 352e2502663eb..b51d185f1e545 100644 --- a/boards/sparc/bm3803/xx3803/src/bm3803_wdt.c +++ b/boards/sparc/bm3803/xx3803/src/bm3803_wdt.c @@ -51,7 +51,7 @@ static int wdog_daemon(int argc, char *argv[]) { - FAR struct file filestruct; + struct file filestruct; int ret; /* Open watchdog device */ @@ -108,7 +108,7 @@ static int wdog_daemon(int argc, char *argv[]) int xx3803_watchdog_initialize(void) { - FAR struct file filestruct; + struct file filestruct; int ret = 0; /* Open the watchdog device */ @@ -132,7 +132,7 @@ int xx3803_watchdog_initialize(void) /* Close watchdog as it is not needed here anymore */ - (void)file_close(&filestruct); + file_close(&filestruct); if (ret < 0) { @@ -149,7 +149,7 @@ int xx3803_watchdog_initialize(void) int taskid = kthread_create(CONFIG_XX3803_WDG_THREAD_NAME, CONFIG_XX3803_WDG_THREAD_PRIORITY, CONFIG_XX3803_WDG_THREAD_STACKSIZE, - (main_t)wdog_daemon, (FAR char * const *)NULL); + (main_t)wdog_daemon, (char * const *)NULL); DEBUGASSERT(taskid > 0); UNUSED(taskid); diff --git a/boards/sparc/bm3823/xx3823/configs/nsh/defconfig b/boards/sparc/bm3823/xx3823/configs/nsh/defconfig index c0c436f6e73d3..a2ad673e1e3c5 100644 --- a/boards/sparc/bm3823/xx3823/configs/nsh/defconfig +++ b/boards/sparc/bm3823/xx3823/configs/nsh/defconfig @@ -25,29 +25,21 @@ CONFIG_DEBUG_SYMBOLS=y CONFIG_DEBUG_WARN=y CONFIG_DEFAULT_SMALL=y CONFIG_DISABLE_MOUNTPOINT=y -CONFIG_DISABLE_MQUEUE=y CONFIG_ELF=y CONFIG_ENDIAN_BIG=y CONFIG_EXAMPLES_HELLO=y CONFIG_EXAMPLES_HELLO_STACKSIZE=4096 CONFIG_EXAMPLES_NULL=y -CONFIG_FS_WRITABLE=y CONFIG_INIT_ENTRYPOINT="nsh_main" CONFIG_INIT_STACKSIZE=4096 CONFIG_INTELHEX_BINARY=y CONFIG_LIBC_EXECFUNCS=y -CONFIG_MAX_TASKS=16 -CONFIG_MAX_WDOGPARMS=2 -CONFIG_NFILE_DESCRIPTORS=8 -CONFIG_NFILE_STREAMS=8 -CONFIG_NPTHREAD_KEYS=4 CONFIG_NSH_ARCHINIT=y CONFIG_NSH_BUILTIN_APPS=y CONFIG_NSH_FILE_APPS=y CONFIG_NUNGET_CHARS=0 CONFIG_POSIX_SPAWN_PROXY_STACKSIZE=512 CONFIG_PREALLOC_TIMERS=0 -CONFIG_PREALLOC_WDOGS=4 CONFIG_RAM_SIZE=524288 CONFIG_RAM_START=0x20000000 CONFIG_RAW_BINARY=y @@ -62,4 +54,3 @@ CONFIG_TASK_SPAWN_DEFAULT_STACKSIZE=768 CONFIG_UART1_BAUD=9600 CONFIG_UART1_SERIAL_CONSOLE=y CONFIG_UART2_BAUD=9600 -CONFIG_WDOG_INTRESERVE=0 diff --git a/boards/sparc/bm3823/xx3823/scripts/Make.defs b/boards/sparc/bm3823/xx3823/scripts/Make.defs index 225e95968d993..15507a38533dd 100644 --- a/boards/sparc/bm3823/xx3823/scripts/Make.defs +++ b/boards/sparc/bm3823/xx3823/scripts/Make.defs @@ -23,10 +23,10 @@ include ${TOPDIR}/tools/Config.mk include ${TOPDIR}/arch/sparc/src/sparc_v8/Toolchain.defs LDSCRIPT = linksparc.ld +ARCHSCRIPT += $(TOPDIR)/boards/$(CONFIG_ARCH)/$(CONFIG_ARCH_CHIP)/$(CONFIG_ARCH_BOARD)/scripts/$(LDSCRIPT) ARCHINCLUDES = -I. -isystem $(call CONVERT_PATH,$(TOPDIR)/include) ARCHXXINCLUDES = $(ARCHINCLUDES) -isystem $(call CONVERT_PATH,$(TOPDIR)/include/cxx) -ARCHSCRIPT += $(TOPDIR)/boards/$(CONFIG_ARCH)/$(CONFIG_ARCH_CHIP)/$(CONFIG_ARCH_BOARD)/scripts/$(LDSCRIPT) CC = $(CROSSDEV)gcc CXX = $(CROSSDEV)g++ @@ -38,18 +38,8 @@ NM = $(CROSSDEV)nm OBJCOPY = $(CROSSDEV)objcopy OBJDUMP = $(CROSSDEV)objdump -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - # ARCHOPTIMIZATION += -fno-zero-initialized-in-bss -ARCHCFLAGS = -fno-common -ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHDEFINES = @@ -59,8 +49,3 @@ CXXFLAGS = $(ARCHCXXFLAGS) $(ARCHWARNINGSXX) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) CXXPICFLAGS = $(ARCHPICFLAGS) $(CXXFLAGS) CPPFLAGS = $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) AFLAGS = $(CFLAGS) -D__ASSEMBLY__ - -ASMEXT = .S -OBJEXT = .o -LIBEXT = .a -EXEEXT = .elf diff --git a/boards/sparc/bm3823/xx3823/src/bm3823_am29lv.c b/boards/sparc/bm3823/xx3823/src/bm3823_am29lv.c index ea658604511b8..fb198adb6a98e 100644 --- a/boards/sparc/bm3823/xx3823/src/bm3823_am29lv.c +++ b/boards/sparc/bm3823/xx3823/src/bm3823_am29lv.c @@ -81,10 +81,10 @@ int bm3823_am29lv_initialize(int minor) { int ret; #ifdef HAVE_AM29LV - FAR struct mtd_dev_s *mtd; - FAR struct mtd_geometry_s geo; + struct mtd_dev_s *mtd; + struct mtd_geometry_s geo; #if defined(CONFIG_MTD_PARTITION_NAMES) - FAR const char *partname = CONFIG_XX3823_FLASH_PART_NAMES; + const char *partname = CONFIG_XX3823_FLASH_PART_NAMES; #endif /* Now bind the SPI interface to the W25 SPI FLASH driver */ diff --git a/boards/xtensa/esp32/common/src/esp32_board_i2c.c b/boards/xtensa/esp32/common/src/esp32_board_i2c.c index 155aa03598765..7e7a543261d94 100644 --- a/boards/xtensa/esp32/common/src/esp32_board_i2c.c +++ b/boards/xtensa/esp32/common/src/esp32_board_i2c.c @@ -49,7 +49,7 @@ int esp32_i2c_register(int bus) { - FAR struct i2c_master_s *i2c; + struct i2c_master_s *i2c; int ret; i2c = esp32_i2cbus_initialize(bus); diff --git a/boards/xtensa/esp32/common/src/esp32_board_spi.c b/boards/xtensa/esp32/common/src/esp32_board_spi.c index a9024473c6bc8..5412b8edef7be 100644 --- a/boards/xtensa/esp32/common/src/esp32_board_spi.c +++ b/boards/xtensa/esp32/common/src/esp32_board_spi.c @@ -41,7 +41,7 @@ * Name: spi_status ****************************************************************************/ -static inline uint8_t spi_status(FAR struct spi_dev_s *dev, uint32_t devid) +static inline uint8_t spi_status(struct spi_dev_s *dev, uint32_t devid) { uint8_t status = 0; @@ -68,7 +68,7 @@ static inline uint8_t spi_status(FAR struct spi_dev_s *dev, uint32_t devid) #ifdef CONFIG_SPI_CMDDATA -static inline int spi_cmddata(FAR struct spi_dev_s *dev, uint32_t devid, +static inline int spi_cmddata(struct spi_dev_s *dev, uint32_t devid, bool cmd) { #ifdef CONFIG_LCD_ILI9341 @@ -99,7 +99,7 @@ static inline int spi_cmddata(FAR struct spi_dev_s *dev, uint32_t devid, #ifdef CONFIG_ESP32_SPI2 -uint8_t esp32_spi2_status(FAR struct spi_dev_s *dev, uint32_t devid) +uint8_t esp32_spi2_status(struct spi_dev_s *dev, uint32_t devid) { return spi_status(dev, devid); } @@ -112,7 +112,7 @@ uint8_t esp32_spi2_status(FAR struct spi_dev_s *dev, uint32_t devid) #if defined(CONFIG_ESP32_SPI2) && defined(CONFIG_SPI_CMDDATA) -int esp32_spi2_cmddata(FAR struct spi_dev_s *dev, uint32_t devid, bool cmd) +int esp32_spi2_cmddata(struct spi_dev_s *dev, uint32_t devid, bool cmd) { spiinfo("devid: %" PRIu32 " CMD: %s\n", devid, cmd ? "command" : "data"); @@ -128,7 +128,7 @@ int esp32_spi2_cmddata(FAR struct spi_dev_s *dev, uint32_t devid, bool cmd) #ifdef CONFIG_ESP32_SPI3 -uint8_t esp32_spi3_status(FAR struct spi_dev_s *dev, uint32_t devid) +uint8_t esp32_spi3_status(struct spi_dev_s *dev, uint32_t devid) { return spi_status(dev, devid); } @@ -141,7 +141,7 @@ uint8_t esp32_spi3_status(FAR struct spi_dev_s *dev, uint32_t devid) #if defined(CONFIG_ESP32_SPI3) && defined(CONFIG_SPI_CMDDATA) -int esp32_spi3_cmddata(FAR struct spi_dev_s *dev, uint32_t devid, bool cmd) +int esp32_spi3_cmddata(struct spi_dev_s *dev, uint32_t devid, bool cmd) { spiinfo("devid: %" PRIu32 " CMD: %s\n", devid, cmd ? "command" : "data"); diff --git a/boards/xtensa/esp32/common/src/esp32_board_spidev.c b/boards/xtensa/esp32/common/src/esp32_board_spidev.c index 1dad836adad8d..0d7a5c2f94f6a 100644 --- a/boards/xtensa/esp32/common/src/esp32_board_spidev.c +++ b/boards/xtensa/esp32/common/src/esp32_board_spidev.c @@ -47,7 +47,7 @@ int board_spidev_initialize(int port) { int ret; - FAR struct spi_dev_s *spi; + struct spi_dev_s *spi; spiinfo("Initializing /dev/spi%d...\n", port); diff --git a/boards/xtensa/esp32/common/src/esp32_board_spiflash.c b/boards/xtensa/esp32/common/src/esp32_board_spiflash.c index 5259cae63d29d..66bfcc031749f 100644 --- a/boards/xtensa/esp32/common/src/esp32_board_spiflash.c +++ b/boards/xtensa/esp32/common/src/esp32_board_spiflash.c @@ -122,7 +122,7 @@ static const struct ota_partition_s g_ota_partition_table[] = #ifdef CONFIG_ESP32_HAVE_OTA_PARTITION static int init_ota_partitions(void) { - FAR struct mtd_dev_s *mtd; + struct mtd_dev_s *mtd; #ifdef CONFIG_BCH char blockdev[18]; #endif @@ -176,7 +176,7 @@ static int init_ota_partitions(void) ****************************************************************************/ #ifdef CONFIG_ESP32_SPIFLASH_SMARTFS -static int setup_smartfs(int smartn, FAR struct mtd_dev_s *mtd, +static int setup_smartfs(int smartn, struct mtd_dev_s *mtd, const char *mnt_pt) { int ret = OK; @@ -236,7 +236,7 @@ static int setup_smartfs(int smartn, FAR struct mtd_dev_s *mtd, ****************************************************************************/ #ifdef CONFIG_ESP32_SPIFLASH_LITTLEFS -static int setup_littlefs(const char *path, FAR struct mtd_dev_s *mtd, +static int setup_littlefs(const char *path, struct mtd_dev_s *mtd, const char *mnt_pt, int priv) { int ret = OK; @@ -284,7 +284,7 @@ static int setup_littlefs(const char *path, FAR struct mtd_dev_s *mtd, ****************************************************************************/ #ifdef CONFIG_ESP32_SPIFLASH_SPIFFS -static int setup_spiffs(const char *path, FAR struct mtd_dev_s *mtd, +static int setup_spiffs(const char *path, struct mtd_dev_s *mtd, const char *mnt_pt, int priv) { int ret = OK; @@ -326,7 +326,7 @@ static int setup_spiffs(const char *path, FAR struct mtd_dev_s *mtd, ****************************************************************************/ #ifdef CONFIG_ESP32_SPIFLASH_NXFFS -static int setup_nxffs(FAR struct mtd_dev_s *mtd, const char *mnt_pt) +static int setup_nxffs(struct mtd_dev_s *mtd, const char *mnt_pt) { int ret = OK; @@ -366,7 +366,7 @@ static int setup_nxffs(FAR struct mtd_dev_s *mtd, const char *mnt_pt) static int init_wifi_partition(void) { int ret = OK; - FAR struct mtd_dev_s *mtd; + struct mtd_dev_s *mtd; mtd = esp32_spiflash_alloc_mtdpart(CONFIG_ESP32_WIFI_MTD_OFFSET, CONFIG_ESP32_WIFI_MTD_SIZE, @@ -431,7 +431,7 @@ static int init_wifi_partition(void) static int init_storage_partition(void) { int ret = OK; - FAR struct mtd_dev_s *mtd; + struct mtd_dev_s *mtd; mtd = esp32_spiflash_alloc_mtdpart(CONFIG_ESP32_STORAGE_MTD_OFFSET, CONFIG_ESP32_STORAGE_MTD_SIZE, diff --git a/boards/xtensa/esp32/common/src/esp32_ili9341.c b/boards/xtensa/esp32/common/src/esp32_ili9341.c index 995f055be10d8..ad92988397f94 100644 --- a/boards/xtensa/esp32/common/src/esp32_ili9341.c +++ b/boards/xtensa/esp32/common/src/esp32_ili9341.c @@ -82,19 +82,19 @@ struct ili93414ws_lcd_s * Private Function Protototypes ****************************************************************************/ -static void esp32_ili93414ws_select(FAR struct ili9341_lcd_s *lcd); -static void esp32_ili93414ws_deselect(FAR struct ili9341_lcd_s *lcd); -static int esp32_ili93414ws_backlight(FAR struct ili9341_lcd_s *lcd, +static void esp32_ili93414ws_select(struct ili9341_lcd_s *lcd); +static void esp32_ili93414ws_deselect(struct ili9341_lcd_s *lcd); +static int esp32_ili93414ws_backlight(struct ili9341_lcd_s *lcd, int level); -static int esp32_ili93414ws_sendcmd(FAR struct ili9341_lcd_s *lcd, +static int esp32_ili93414ws_sendcmd(struct ili9341_lcd_s *lcd, const uint8_t cmd); -static int esp32_ili93414ws_sendparam(FAR struct ili9341_lcd_s *lcd, +static int esp32_ili93414ws_sendparam(struct ili9341_lcd_s *lcd, const uint8_t param); -static int esp32_ili93414ws_sendgram(FAR struct ili9341_lcd_s *lcd, +static int esp32_ili93414ws_sendgram(struct ili9341_lcd_s *lcd, const uint16_t *wd, uint32_t nwords); -static int esp32_ili93414ws_recvparam(FAR struct ili9341_lcd_s *lcd, +static int esp32_ili93414ws_recvparam(struct ili9341_lcd_s *lcd, uint8_t *param); -static int esp32_ili93414ws_recvgram(FAR struct ili9341_lcd_s *lcd, +static int esp32_ili93414ws_recvgram(struct ili9341_lcd_s *lcd, uint16_t *wd, uint32_t nwords); /**************************************************************************** @@ -119,9 +119,9 @@ static struct lcd_dev_s *g_lcd = NULL; * ****************************************************************************/ -static void esp32_ili93414ws_select(FAR struct ili9341_lcd_s *lcd) +static void esp32_ili93414ws_select(struct ili9341_lcd_s *lcd) { - FAR struct ili93414ws_lcd_s *priv = (FAR struct ili93414ws_lcd_s *)lcd; + struct ili93414ws_lcd_s *priv = (struct ili93414ws_lcd_s *)lcd; SPI_LOCK(priv->spi, true); SPI_SELECT(priv->spi, SPIDEV_DISPLAY(0), true); @@ -138,9 +138,9 @@ static void esp32_ili93414ws_select(FAR struct ili9341_lcd_s *lcd) * ****************************************************************************/ -static void esp32_ili93414ws_deselect(FAR struct ili9341_lcd_s *lcd) +static void esp32_ili93414ws_deselect(struct ili9341_lcd_s *lcd) { - FAR struct ili93414ws_lcd_s *priv = (FAR struct ili93414ws_lcd_s *)lcd; + struct ili93414ws_lcd_s *priv = (struct ili93414ws_lcd_s *)lcd; SPI_SELECT(priv->spi, SPIDEV_DISPLAY(0), false); SPI_LOCK(priv->spi, false); @@ -168,7 +168,7 @@ static void esp32_ili93414ws_deselect(FAR struct ili9341_lcd_s *lcd) * ****************************************************************************/ -static int esp32_ili93414ws_backlight(FAR struct ili9341_lcd_s *lcd, +static int esp32_ili93414ws_backlight(struct ili9341_lcd_s *lcd, int level) { if (level > 0) @@ -200,10 +200,10 @@ static int esp32_ili93414ws_backlight(FAR struct ili9341_lcd_s *lcd, * ****************************************************************************/ -static int esp32_ili93414ws_sendcmd(FAR struct ili9341_lcd_s *lcd, +static int esp32_ili93414ws_sendcmd(struct ili9341_lcd_s *lcd, const uint8_t cmd) { - FAR struct ili93414ws_lcd_s *priv = (FAR struct ili93414ws_lcd_s *)lcd; + struct ili93414ws_lcd_s *priv = (struct ili93414ws_lcd_s *)lcd; lcdinfo("%02x\n", cmd); @@ -231,10 +231,10 @@ static int esp32_ili93414ws_sendcmd(FAR struct ili9341_lcd_s *lcd, * ****************************************************************************/ -static int esp32_ili93414ws_sendparam(FAR struct ili9341_lcd_s *lcd, +static int esp32_ili93414ws_sendparam(struct ili9341_lcd_s *lcd, const uint8_t param) { - FAR struct ili93414ws_lcd_s *priv = (FAR struct ili93414ws_lcd_s *)lcd; + struct ili93414ws_lcd_s *priv = (struct ili93414ws_lcd_s *)lcd; lcdinfo("param=%04x\n", param); @@ -262,10 +262,10 @@ static int esp32_ili93414ws_sendparam(FAR struct ili9341_lcd_s *lcd, * ****************************************************************************/ -static int esp32_ili93414ws_sendgram(FAR struct ili9341_lcd_s *lcd, +static int esp32_ili93414ws_sendgram(struct ili9341_lcd_s *lcd, const uint16_t *wd, uint32_t nwords) { - FAR struct ili93414ws_lcd_s *priv = (FAR struct ili93414ws_lcd_s *)lcd; + struct ili93414ws_lcd_s *priv = (struct ili93414ws_lcd_s *)lcd; lcdinfo("lcd:%p, wd=%p, nwords=%" PRIu32 "\n", lcd, wd, nwords); @@ -290,10 +290,10 @@ static int esp32_ili93414ws_sendgram(FAR struct ili9341_lcd_s *lcd, * ****************************************************************************/ -static int esp32_ili93414ws_recvparam(FAR struct ili9341_lcd_s *lcd, +static int esp32_ili93414ws_recvparam(struct ili9341_lcd_s *lcd, uint8_t *param) { - FAR struct ili93414ws_lcd_s *priv = (FAR struct ili93414ws_lcd_s *)lcd; + struct ili93414ws_lcd_s *priv = (struct ili93414ws_lcd_s *)lcd; SPI_SETBITS(priv->spi, 8); @@ -320,10 +320,10 @@ static int esp32_ili93414ws_recvparam(FAR struct ili9341_lcd_s *lcd, * ****************************************************************************/ -static int esp32_ili93414ws_recvgram(FAR struct ili9341_lcd_s *lcd, +static int esp32_ili93414ws_recvgram(struct ili9341_lcd_s *lcd, uint16_t *wd, uint32_t nwords) { - FAR struct ili93414ws_lcd_s *priv = (FAR struct ili93414ws_lcd_s *)lcd; + struct ili93414ws_lcd_s *priv = (struct ili93414ws_lcd_s *)lcd; lcdinfo("wd=%p, nwords=%" PRIu32 "\n", wd, nwords); @@ -349,8 +349,8 @@ static int esp32_ili93414ws_recvgram(FAR struct ili9341_lcd_s *lcd, int board_lcd_initialize(void) { - FAR struct ili93414ws_lcd_s *priv = &g_lcddev; - FAR struct spi_dev_s *spi; + struct ili93414ws_lcd_s *priv = &g_lcddev; + struct spi_dev_s *spi; lcdinfo("Initializing LCD\n"); if (g_lcd == NULL) @@ -423,7 +423,7 @@ int board_lcd_initialize(void) * ****************************************************************************/ -FAR struct lcd_dev_s *board_lcd_getdev(int lcddev) +struct lcd_dev_s *board_lcd_getdev(int lcddev) { if (lcddev == 0) { diff --git a/boards/xtensa/esp32/common/src/esp32_lcd_backpack.c b/boards/xtensa/esp32/common/src/esp32_lcd_backpack.c index 137165ba047a0..88d802084b905 100644 --- a/boards/xtensa/esp32/common/src/esp32_lcd_backpack.c +++ b/boards/xtensa/esp32/common/src/esp32_lcd_backpack.c @@ -59,9 +59,9 @@ int board_lcd_backpack_init(int devno, int busno, int rows, int cols) { - FAR struct pcf8574_lcd_backpack_config_s cfg = + struct pcf8574_lcd_backpack_config_s cfg = LCD_I2C_BACKPACK_CFG_SAINSMART; - FAR struct i2c_master_s *i2c; + struct i2c_master_s *i2c; char devpath[12]; int ret; diff --git a/boards/xtensa/esp32/common/src/esp32_mcp2515.c b/boards/xtensa/esp32/common/src/esp32_mcp2515.c index b8bba2ef066d5..ef4677301bdf8 100644 --- a/boards/xtensa/esp32/common/src/esp32_mcp2515.c +++ b/boards/xtensa/esp32/common/src/esp32_mcp2515.c @@ -62,9 +62,9 @@ struct esp32_mcp2515config_s /* Additional private definitions only known to this driver */ - FAR struct mcp2515_can_s *handle; /* The MCP2515 driver handle */ - mcp2515_handler_t handler; /* The MCP2515 interrupt handler */ - FAR void *arg; /* Argument to pass to the interrupt handler */ + struct mcp2515_can_s *handle; /* The MCP2515 driver handle */ + mcp2515_handler_t handler; /* The MCP2515 interrupt handler */ + void *arg; /* Argument to pass to the interrupt handler */ }; /**************************************************************************** @@ -78,8 +78,8 @@ struct esp32_mcp2515config_s * attach - Attach the MCP2515 interrupt handler to the GPIO interrupt */ -static int mcp2515_attach(FAR struct mcp2515_config_s *state, - mcp2515_handler_t handler, FAR void *arg); +static int mcp2515_attach(struct mcp2515_config_s *state, + mcp2515_handler_t handler, void *arg); /**************************************************************************** * Private Data @@ -118,10 +118,10 @@ static struct esp32_mcp2515config_s g_mcp2515config = /* This is the MCP2515 Interrupt handler */ -int mcp2515_interrupt(int irq, FAR void *context, FAR void *arg) +int mcp2515_interrupt(int irq, void *context, void *arg) { - FAR struct esp32_mcp2515config_s *priv = - (FAR struct esp32_mcp2515config_s *)arg; + struct esp32_mcp2515config_s *priv = + (struct esp32_mcp2515config_s *)arg; DEBUGASSERT(priv != NULL); @@ -137,11 +137,11 @@ int mcp2515_interrupt(int irq, FAR void *context, FAR void *arg) return OK; } -static int mcp2515_attach(FAR struct mcp2515_config_s *state, - mcp2515_handler_t handler, FAR void *arg) +static int mcp2515_attach(struct mcp2515_config_s *state, + mcp2515_handler_t handler, void *arg) { - FAR struct esp32_mcp2515config_s *priv = - (FAR struct esp32_mcp2515config_s *)state; + struct esp32_mcp2515config_s *priv = + (struct esp32_mcp2515config_s *)state; irqstate_t flags; int irq = ESP32_PIN2IRQ(GPIO_MCP2515_IRQ); int ret; @@ -192,9 +192,9 @@ static int mcp2515_attach(FAR struct mcp2515_config_s *state, int board_mcp2515_initialize(int devno) { - FAR struct spi_dev_s *spi; - FAR struct can_dev_s *can; - FAR struct mcp2515_can_s *mcp2515; + struct spi_dev_s *spi; + struct can_dev_s *can; + struct mcp2515_can_s *mcp2515; char devpath[10]; int ret; diff --git a/boards/xtensa/esp32/common/src/esp32_oneshot.c b/boards/xtensa/esp32/common/src/esp32_oneshot.c index c55e4ecfcb9f5..fc0b6ccc2b152 100644 --- a/boards/xtensa/esp32/common/src/esp32_oneshot.c +++ b/boards/xtensa/esp32/common/src/esp32_oneshot.c @@ -54,7 +54,7 @@ int esp32_oneshot_init(int timer, uint16_t resolution) { int ret = OK; - FAR struct oneshot_lowerhalf_s *os_lower = NULL; + struct oneshot_lowerhalf_s *os_lower = NULL; os_lower = oneshot_initialize(timer, resolution); if (os_lower != NULL) diff --git a/boards/xtensa/esp32/common/src/esp32_ssd1306.c b/boards/xtensa/esp32/common/src/esp32_ssd1306.c index 7cb8b7feb9a8e..7582421eb7175 100644 --- a/boards/xtensa/esp32/common/src/esp32_ssd1306.c +++ b/boards/xtensa/esp32/common/src/esp32_ssd1306.c @@ -55,7 +55,7 @@ * Private Data ****************************************************************************/ -static FAR struct lcd_dev_s *g_lcddev; +static struct lcd_dev_s *g_lcddev; /* Configuration ************************************************************/ @@ -69,7 +69,7 @@ static FAR struct lcd_dev_s *g_lcddev; int board_lcd_initialize(void) { - FAR struct i2c_master_s *i2c; + struct i2c_master_s *i2c; const int busno = OLED_I2C_PORT; const int devno = 0; int ret = OK; @@ -130,7 +130,7 @@ int board_lcd_initialize(void) * Name: board_lcd_getdev ****************************************************************************/ -FAR struct lcd_dev_s *board_lcd_getdev(int lcddev) +struct lcd_dev_s *board_lcd_getdev(int lcddev) { if (lcddev == 0) { diff --git a/boards/xtensa/esp32/esp32-devkitc/configs/cxx/defconfig b/boards/xtensa/esp32/esp32-devkitc/configs/cxx/defconfig new file mode 100644 index 0000000000000..f4718c7feaea8 --- /dev/null +++ b/boards/xtensa/esp32/esp32-devkitc/configs/cxx/defconfig @@ -0,0 +1,50 @@ +# +# This file is autogenerated: PLEASE DO NOT EDIT IT. +# +# You can use "make menuconfig" to make any modifications to the installed .config file. +# You can then do "make savedefconfig" to generate a new defconfig file that includes your +# modifications. +# +# CONFIG_ARCH_LEDS is not set +# CONFIG_NSH_ARGCAT is not set +# CONFIG_NSH_CMDOPT_HEXDUMP is not set +# CONFIG_NSH_CMDPARMS is not set +CONFIG_ARCH="xtensa" +CONFIG_ARCH_BOARD="esp32-devkitc" +CONFIG_ARCH_BOARD_COMMON=y +CONFIG_ARCH_BOARD_ESP32_DEVKITC=y +CONFIG_ARCH_CHIP="esp32" +CONFIG_ARCH_CHIP_ESP32=y +CONFIG_ARCH_CHIP_ESP32WROVER=y +CONFIG_ARCH_STACKDUMP=y +CONFIG_ARCH_XTENSA=y +CONFIG_BOARD_LOOPSPERMSEC=16717 +CONFIG_BUILTIN=y +CONFIG_ESP32_UART0=y +CONFIG_FS_PROCFS=y +CONFIG_HAVE_CXX=y +CONFIG_IDLETHREAD_STACKSIZE=3072 +CONFIG_INIT_ENTRYPOINT="nsh_main" +CONFIG_INTELHEX_BINARY=y +CONFIG_LIBCXX=y +CONFIG_LIBCXXABI=y +CONFIG_LIBM=y +CONFIG_MM_REGIONS=3 +CONFIG_NSH_ARCHINIT=y +CONFIG_NSH_BUILTIN_APPS=y +CONFIG_NSH_FILEIOSIZE=512 +CONFIG_NSH_LINELEN=64 +CONFIG_NSH_READLINE=y +CONFIG_PREALLOC_TIMERS=4 +CONFIG_RAM_SIZE=114688 +CONFIG_RAM_START=0x20000000 +CONFIG_RAW_BINARY=y +CONFIG_RR_INTERVAL=200 +CONFIG_SCHED_ATEXIT=y +CONFIG_SCHED_WAITPID=y +CONFIG_START_DAY=6 +CONFIG_START_MONTH=12 +CONFIG_START_YEAR=2011 +CONFIG_SYSTEM_NSH=y +CONFIG_TESTING_CXXTEST=y +CONFIG_UART0_SERIAL_CONSOLE=y diff --git a/boards/xtensa/esp32/esp32-devkitc/scripts/Make.defs b/boards/xtensa/esp32/esp32-devkitc/scripts/Make.defs index 439b75942b5db..a0e33e781deea 100644 --- a/boards/xtensa/esp32/esp32-devkitc/scripts/Make.defs +++ b/boards/xtensa/esp32/esp32-devkitc/scripts/Make.defs @@ -53,20 +53,6 @@ else LDSCRIPT_TEMPLATE = $(BOARD_COMMON_DIR)$(DELIM)scripts$(DELIM)esp32.template.ld endif -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifeq ($(CONFIG_STACK_CANARIES),y) - ARCHOPTIMIZATION += -fstack-protector-all -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - -ARCHCFLAGS = -fno-common -ffunction-sections -fdata-sections -mlongcalls -ARCHCXXFLAGS = $(ARCHCFLAGS) -fno-exceptions -fcheck-new -fno-rtti ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic @@ -98,8 +84,3 @@ CXXELFFLAGS = $(CXXFLAGS) -mtext-section-literals LDELFFLAGS = -r -e main LDELFFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)$(DELIM)binfmt$(DELIM)libelf$(DELIM)gnu-elf.ld) - -LDFLAGS += -Map=$(call CONVERT_PATH,$(TOPDIR)/nuttx.map) --cref -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - LDFLAGS += -g -endif diff --git a/boards/xtensa/esp32/esp32-devkitc/src/Make.defs b/boards/xtensa/esp32/esp32-devkitc/src/Make.defs index dcc7c6b43cb41..61a924829bdfc 100644 --- a/boards/xtensa/esp32/esp32-devkitc/src/Make.defs +++ b/boards/xtensa/esp32/esp32-devkitc/src/Make.defs @@ -51,6 +51,10 @@ ifeq ($(CONFIG_ARCH_BUTTONS),y) CSRCS += esp32_buttons.c endif +ifeq ($(CONFIG_ESP32_TWAI),y) +CSRCS += esp32_twai.c +endif + SCRIPTOUT = $(BOARD_DIR)$(DELIM)scripts$(DELIM)esp32_out.ld .PHONY = context distclean diff --git a/boards/xtensa/esp32/esp32-devkitc/src/esp32_boot.c b/boards/xtensa/esp32/esp32-devkitc/src/esp32_boot.c index 740c89c9fbf65..645c6f354e712 100644 --- a/boards/xtensa/esp32/esp32-devkitc/src/esp32_boot.c +++ b/boards/xtensa/esp32/esp32-devkitc/src/esp32_boot.c @@ -89,7 +89,7 @@ void board_late_initialize(void) * SMP bringup is complete. */ - umm_addregion((FAR void *)HEAP_REGION_ROMAPP_START, + umm_addregion((void *)HEAP_REGION_ROMAPP_START, (size_t)(HEAP_REGION_ROMAPP_END - HEAP_REGION_ROMAPP_START)); #endif } diff --git a/boards/xtensa/esp32/esp32-devkitc/src/esp32_bringup.c b/boards/xtensa/esp32/esp32-devkitc/src/esp32_bringup.c index 4021306a3c6bc..e7810072384f1 100644 --- a/boards/xtensa/esp32/esp32-devkitc/src/esp32_bringup.c +++ b/boards/xtensa/esp32/esp32-devkitc/src/esp32_bringup.c @@ -245,6 +245,17 @@ int esp32_bringup(void) } #endif /* CONFIG_ESP32_LEDC */ +#ifdef CONFIG_ESP32_TWAI + + /* Initialize TWAI and register the TWAI driver. */ + + ret = esp32_twai_setup(); + if (ret < 0) + { + syslog(LOG_ERR, "ERROR: esp32_twai_setup failed: %d\n", ret); + } +#endif + #ifdef CONFIG_ESP32_RT_TIMER ret = esp32_rt_timer_init(); if (ret < 0) diff --git a/boards/xtensa/esp32/esp32-devkitc/src/esp32_buttons.c b/boards/xtensa/esp32/esp32-devkitc/src/esp32_buttons.c index 0c3995edf0fb8..0bfc102c25f37 100644 --- a/boards/xtensa/esp32/esp32-devkitc/src/esp32_buttons.c +++ b/boards/xtensa/esp32/esp32-devkitc/src/esp32_buttons.c @@ -127,7 +127,7 @@ uint32_t board_buttons(void) ****************************************************************************/ #ifdef CONFIG_ARCH_IRQBUTTONS -int board_button_irq(int id, xcpt_t irqhandler, FAR void *arg) +int board_button_irq(int id, xcpt_t irqhandler, void *arg) { int ret; DEBUGASSERT(id == BUTTON_BOOT); diff --git a/boards/xtensa/esp32/esp32-devkitc/src/esp32_gpio.c b/boards/xtensa/esp32/esp32-devkitc/src/esp32_gpio.c index e1fd26c976cfc..58b0d74dbe45a 100644 --- a/boards/xtensa/esp32/esp32-devkitc/src/esp32_gpio.c +++ b/boards/xtensa/esp32/esp32-devkitc/src/esp32_gpio.c @@ -87,19 +87,19 @@ struct esp32gpint_dev_s ****************************************************************************/ #if BOARD_NGPIOOUT > 0 -static int gpout_read(FAR struct gpio_dev_s *dev, FAR bool *value); -static int gpout_write(FAR struct gpio_dev_s *dev, bool value); +static int gpout_read(struct gpio_dev_s *dev, bool *value); +static int gpout_write(struct gpio_dev_s *dev, bool value); #endif #if BOARD_NGPIOIN > 0 -static int gpin_read(FAR struct gpio_dev_s *dev, FAR bool *value); +static int gpin_read(struct gpio_dev_s *dev, bool *value); #endif #if BOARD_NGPIOINT > 0 -static int gpint_read(FAR struct gpio_dev_s *dev, FAR bool *value); -static int gpint_attach(FAR struct gpio_dev_s *dev, +static int gpint_read(struct gpio_dev_s *dev, bool *value); +static int gpint_attach(struct gpio_dev_s *dev, pin_interrupt_t callback); -static int gpint_enable(FAR struct gpio_dev_s *dev, bool enable); +static int gpint_enable(struct gpio_dev_s *dev, bool enable); #endif /**************************************************************************** @@ -172,9 +172,9 @@ static struct esp32gpint_dev_s g_gpint[BOARD_NGPIOINT]; ****************************************************************************/ #if BOARD_NGPIOOUT > 0 -static int gpout_read(FAR struct gpio_dev_s *dev, FAR bool *value) +static int gpout_read(struct gpio_dev_s *dev, bool *value) { - FAR struct esp32gpio_dev_s *esp32gpio = (FAR struct esp32gpio_dev_s *)dev; + struct esp32gpio_dev_s *esp32gpio = (struct esp32gpio_dev_s *)dev; DEBUGASSERT(esp32gpio != NULL && value != NULL); DEBUGASSERT(esp32gpio->id < BOARD_NGPIOOUT); @@ -188,9 +188,9 @@ static int gpout_read(FAR struct gpio_dev_s *dev, FAR bool *value) * Name: gpout_write ****************************************************************************/ -static int gpout_write(FAR struct gpio_dev_s *dev, bool value) +static int gpout_write(struct gpio_dev_s *dev, bool value) { - FAR struct esp32gpio_dev_s *esp32gpio = (FAR struct esp32gpio_dev_s *)dev; + struct esp32gpio_dev_s *esp32gpio = (struct esp32gpio_dev_s *)dev; DEBUGASSERT(esp32gpio != NULL); DEBUGASSERT(esp32gpio->id < BOARD_NGPIOOUT); @@ -206,9 +206,9 @@ static int gpout_write(FAR struct gpio_dev_s *dev, bool value) ****************************************************************************/ #if BOARD_NGPIOIN > 0 -static int gpin_read(FAR struct gpio_dev_s *dev, FAR bool *value) +static int gpin_read(struct gpio_dev_s *dev, bool *value) { - FAR struct esp32gpio_dev_s *esp32gpio = (FAR struct esp32gpio_dev_s *)dev; + struct esp32gpio_dev_s *esp32gpio = (struct esp32gpio_dev_s *)dev; DEBUGASSERT(esp32gpio != NULL && value != NULL); DEBUGASSERT(esp32gpio->id < BOARD_NGPIOIN); @@ -226,8 +226,8 @@ static int gpin_read(FAR struct gpio_dev_s *dev, FAR bool *value) #if BOARD_NGPIOINT > 0 static int esp32gpio_interrupt(int irq, void *context, void *arg) { - FAR struct esp32gpint_dev_s *esp32gpint = - (FAR struct esp32gpint_dev_s *)arg; + struct esp32gpint_dev_s *esp32gpint = + (struct esp32gpint_dev_s *)arg; DEBUGASSERT(esp32gpint != NULL && esp32gpint->callback != NULL); gpioinfo("Interrupt! callback=%p\n", esp32gpint->callback); @@ -241,10 +241,10 @@ static int esp32gpio_interrupt(int irq, void *context, void *arg) * Name: gpint_read ****************************************************************************/ -static int gpint_read(FAR struct gpio_dev_s *dev, FAR bool *value) +static int gpint_read(struct gpio_dev_s *dev, bool *value) { - FAR struct esp32gpint_dev_s *esp32gpint = - (FAR struct esp32gpint_dev_s *)dev; + struct esp32gpint_dev_s *esp32gpint = + (struct esp32gpint_dev_s *)dev; DEBUGASSERT(esp32gpint != NULL && value != NULL); DEBUGASSERT(esp32gpint->esp32gpio.id < BOARD_NGPIOINT); @@ -258,11 +258,11 @@ static int gpint_read(FAR struct gpio_dev_s *dev, FAR bool *value) * Name: gpint_attach ****************************************************************************/ -static int gpint_attach(FAR struct gpio_dev_s *dev, +static int gpint_attach(struct gpio_dev_s *dev, pin_interrupt_t callback) { - FAR struct esp32gpint_dev_s *esp32gpint = - (FAR struct esp32gpint_dev_s *)dev; + struct esp32gpint_dev_s *esp32gpint = + (struct esp32gpint_dev_s *)dev; int irq = ESP32_PIN2IRQ(g_gpiointinputs[esp32gpint->esp32gpio.id]); int ret; @@ -289,10 +289,10 @@ static int gpint_attach(FAR struct gpio_dev_s *dev, * Name: gpint_enable ****************************************************************************/ -static int gpint_enable(FAR struct gpio_dev_s *dev, bool enable) +static int gpint_enable(struct gpio_dev_s *dev, bool enable) { - FAR struct esp32gpint_dev_s *esp32gpint = - (FAR struct esp32gpint_dev_s *)dev; + struct esp32gpint_dev_s *esp32gpint = + (struct esp32gpint_dev_s *)dev; int irq = ESP32_PIN2IRQ(g_gpiointinputs[esp32gpint->esp32gpio.id]); if (enable) diff --git a/boards/xtensa/esp32/esp32-devkitc/src/esp32_twai.c b/boards/xtensa/esp32/esp32-devkitc/src/esp32_twai.c new file mode 100644 index 0000000000000..59cfc6b7876a6 --- /dev/null +++ b/boards/xtensa/esp32/esp32-devkitc/src/esp32_twai.c @@ -0,0 +1,92 @@ +/**************************************************************************** + * boards/xtensa/esp32/esp32-devkitc/src/esp32_twai.c + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include +#include + +#include +#include + +#include "chip.h" + +#include "esp32_twai.h" +#include "esp32-devkitc.h" + +#ifdef CONFIG_CAN + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/* Configuration ************************************************************/ + +#define TWAI_PORT0 0 + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: esp32_twai_setup + * + * Description: + * Initialize TWAI and register the TWAI device + * + ****************************************************************************/ + +int esp32_twai_setup(void) +{ +#ifdef CONFIG_ESP32_TWAI0 + struct can_dev_s *twai; + int ret; + + /* Call esp32_twaiinitialize() to get an instance of the TWAI0 + * interface + * */ + + twai = esp32_twaiinitialize(TWAI_PORT0); + if (twai == NULL) + { + canerr("ERROR: Failed to get TWAI0 interface\n"); + return -ENODEV; + } + + /* Register the TWAI0 driver at "/dev/can0" */ + + ret = can_register("/dev/can0", twai); + if (ret < 0) + { + canerr("ERROR: TWAI1 register failed: %d\n", ret); + return ret; + } + + return OK; +#else + return -ENODEV; +#endif +} + +#endif /* CONFIG_CAN */ diff --git a/boards/xtensa/esp32/esp32-ethernet-kit/scripts/Make.defs b/boards/xtensa/esp32/esp32-ethernet-kit/scripts/Make.defs index 0f0d2cb1780de..fb6b793fd5140 100644 --- a/boards/xtensa/esp32/esp32-ethernet-kit/scripts/Make.defs +++ b/boards/xtensa/esp32/esp32-ethernet-kit/scripts/Make.defs @@ -53,20 +53,6 @@ else LDSCRIPT_TEMPLATE = $(BOARD_COMMON_DIR)$(DELIM)scripts$(DELIM)esp32.template.ld endif -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifeq ($(CONFIG_STACK_CANARIES),y) - ARCHOPTIMIZATION += -fstack-protector-all -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - -ARCHCFLAGS = -fno-common -ffunction-sections -fdata-sections -mlongcalls -ARCHCXXFLAGS = $(ARCHCFLAGS) -fno-exceptions -fcheck-new -fno-rtti ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic @@ -98,8 +84,3 @@ CXXELFFLAGS = $(CXXFLAGS) -mtext-section-literals LDELFFLAGS = -r -e main LDELFFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)$(DELIM)binfmt$(DELIM)libelf$(DELIM)gnu-elf.ld) - -LDFLAGS += -Map=$(call CONVERT_PATH,$(TOPDIR)/nuttx.map) --cref -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - LDFLAGS += -g -endif diff --git a/boards/xtensa/esp32/esp32-ethernet-kit/src/esp32_boot.c b/boards/xtensa/esp32/esp32-ethernet-kit/src/esp32_boot.c index e173894e03f6c..01a16ae8cf15b 100644 --- a/boards/xtensa/esp32/esp32-ethernet-kit/src/esp32_boot.c +++ b/boards/xtensa/esp32/esp32-ethernet-kit/src/esp32_boot.c @@ -89,7 +89,7 @@ void board_late_initialize(void) * SMP bringup is complete. */ - umm_addregion((FAR void *)HEAP_REGION_ROMAPP_START, + umm_addregion((void *)HEAP_REGION_ROMAPP_START, (size_t)(HEAP_REGION_ROMAPP_END - HEAP_REGION_ROMAPP_START)); #endif } diff --git a/boards/xtensa/esp32/esp32-ethernet-kit/src/esp32_buttons.c b/boards/xtensa/esp32/esp32-ethernet-kit/src/esp32_buttons.c index 9b84eb76aaf0b..274d35c2c16da 100644 --- a/boards/xtensa/esp32/esp32-ethernet-kit/src/esp32_buttons.c +++ b/boards/xtensa/esp32/esp32-ethernet-kit/src/esp32_buttons.c @@ -127,7 +127,7 @@ uint32_t board_buttons(void) ****************************************************************************/ #ifdef CONFIG_ARCH_IRQBUTTONS -int board_button_irq(int id, xcpt_t irqhandler, FAR void *arg) +int board_button_irq(int id, xcpt_t irqhandler, void *arg) { int ret; DEBUGASSERT(id == BUTTON_BOOT); diff --git a/boards/xtensa/esp32/esp32-wrover-kit/scripts/Make.defs b/boards/xtensa/esp32/esp32-wrover-kit/scripts/Make.defs index 32614cccf4c65..564067a1bf937 100644 --- a/boards/xtensa/esp32/esp32-wrover-kit/scripts/Make.defs +++ b/boards/xtensa/esp32/esp32-wrover-kit/scripts/Make.defs @@ -53,20 +53,6 @@ else LDSCRIPT_TEMPLATE = $(BOARD_COMMON_DIR)$(DELIM)scripts$(DELIM)esp32.template.ld endif -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifeq ($(CONFIG_STACK_CANARIES),y) - ARCHOPTIMIZATION += -fstack-protector-all -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - -ARCHCFLAGS = -fno-common -ffunction-sections -fdata-sections -mlongcalls -ARCHCXXFLAGS = $(ARCHCFLAGS) -fno-exceptions -fcheck-new -fno-rtti ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic @@ -98,8 +84,3 @@ CXXELFFLAGS = $(CXXFLAGS) -mtext-section-literals LDELFFLAGS = -r -e main LDELFFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)$(DELIM)binfmt$(DELIM)libelf$(DELIM)gnu-elf.ld) - -LDFLAGS += -Map=$(call CONVERT_PATH,$(TOPDIR)/nuttx.map) --cref -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - LDFLAGS += -g -endif diff --git a/boards/xtensa/esp32/esp32-wrover-kit/src/esp32_boot.c b/boards/xtensa/esp32/esp32-wrover-kit/src/esp32_boot.c index 25f7de63a21f3..6e1ef0700ac91 100644 --- a/boards/xtensa/esp32/esp32-wrover-kit/src/esp32_boot.c +++ b/boards/xtensa/esp32/esp32-wrover-kit/src/esp32_boot.c @@ -94,7 +94,7 @@ void board_late_initialize(void) * SMP bringup is complete. */ - umm_addregion((FAR void *)HEAP_REGION_ROMAPP_START, + umm_addregion((void *)HEAP_REGION_ROMAPP_START, (size_t)(HEAP_REGION_ROMAPP_END - HEAP_REGION_ROMAPP_START)); #endif } diff --git a/boards/xtensa/esp32/esp32-wrover-kit/src/esp32_buttons.c b/boards/xtensa/esp32/esp32-wrover-kit/src/esp32_buttons.c index 0249bacb6571f..0f028f6cc39eb 100644 --- a/boards/xtensa/esp32/esp32-wrover-kit/src/esp32_buttons.c +++ b/boards/xtensa/esp32/esp32-wrover-kit/src/esp32_buttons.c @@ -127,7 +127,7 @@ uint32_t board_buttons(void) ****************************************************************************/ #ifdef CONFIG_ARCH_IRQBUTTONS -int board_button_irq(int id, xcpt_t irqhandler, FAR void *arg) +int board_button_irq(int id, xcpt_t irqhandler, void *arg) { int ret; DEBUGASSERT(id == BUTTON_BOOT); diff --git a/boards/xtensa/esp32/esp32-wrover-kit/src/esp32_gpio.c b/boards/xtensa/esp32/esp32-wrover-kit/src/esp32_gpio.c index 5bbb7b4cf9ea4..e7ed75cb700be 100644 --- a/boards/xtensa/esp32/esp32-wrover-kit/src/esp32_gpio.c +++ b/boards/xtensa/esp32/esp32-wrover-kit/src/esp32_gpio.c @@ -87,19 +87,19 @@ struct esp32gpint_dev_s ****************************************************************************/ #if BOARD_NGPIOOUT > 0 -static int gpout_read(FAR struct gpio_dev_s *dev, FAR bool *value); -static int gpout_write(FAR struct gpio_dev_s *dev, bool value); +static int gpout_read(struct gpio_dev_s *dev, bool *value); +static int gpout_write(struct gpio_dev_s *dev, bool value); #endif #if BOARD_NGPIOIN > 0 -static int gpin_read(FAR struct gpio_dev_s *dev, FAR bool *value); +static int gpin_read(struct gpio_dev_s *dev, bool *value); #endif #if BOARD_NGPIOINT > 0 -static int gpint_read(FAR struct gpio_dev_s *dev, FAR bool *value); -static int gpint_attach(FAR struct gpio_dev_s *dev, +static int gpint_read(struct gpio_dev_s *dev, bool *value); +static int gpint_attach(struct gpio_dev_s *dev, pin_interrupt_t callback); -static int gpint_enable(FAR struct gpio_dev_s *dev, bool enable); +static int gpint_enable(struct gpio_dev_s *dev, bool enable); #endif /**************************************************************************** @@ -172,9 +172,9 @@ static struct esp32gpint_dev_s g_gpint[BOARD_NGPIOINT]; ****************************************************************************/ #if BOARD_NGPIOOUT > 0 -static int gpout_read(FAR struct gpio_dev_s *dev, FAR bool *value) +static int gpout_read(struct gpio_dev_s *dev, bool *value) { - FAR struct esp32gpio_dev_s *esp32gpio = (FAR struct esp32gpio_dev_s *)dev; + struct esp32gpio_dev_s *esp32gpio = (struct esp32gpio_dev_s *)dev; DEBUGASSERT(esp32gpio != NULL && value != NULL); DEBUGASSERT(esp32gpio->id < BOARD_NGPIOOUT); @@ -188,9 +188,9 @@ static int gpout_read(FAR struct gpio_dev_s *dev, FAR bool *value) * Name: gpout_write ****************************************************************************/ -static int gpout_write(FAR struct gpio_dev_s *dev, bool value) +static int gpout_write(struct gpio_dev_s *dev, bool value) { - FAR struct esp32gpio_dev_s *esp32gpio = (FAR struct esp32gpio_dev_s *)dev; + struct esp32gpio_dev_s *esp32gpio = (struct esp32gpio_dev_s *)dev; DEBUGASSERT(esp32gpio != NULL); DEBUGASSERT(esp32gpio->id < BOARD_NGPIOOUT); @@ -206,9 +206,9 @@ static int gpout_write(FAR struct gpio_dev_s *dev, bool value) ****************************************************************************/ #if BOARD_NGPIOIN > 0 -static int gpin_read(FAR struct gpio_dev_s *dev, FAR bool *value) +static int gpin_read(struct gpio_dev_s *dev, bool *value) { - FAR struct esp32gpio_dev_s *esp32gpio = (FAR struct esp32gpio_dev_s *)dev; + struct esp32gpio_dev_s *esp32gpio = (struct esp32gpio_dev_s *)dev; DEBUGASSERT(esp32gpio != NULL && value != NULL); DEBUGASSERT(esp32gpio->id < BOARD_NGPIOIN); @@ -226,8 +226,8 @@ static int gpin_read(FAR struct gpio_dev_s *dev, FAR bool *value) #if BOARD_NGPIOINT > 0 static int esp32gpio_interrupt(int irq, void *context, void *arg) { - FAR struct esp32gpint_dev_s *esp32gpint = - (FAR struct esp32gpint_dev_s *)arg; + struct esp32gpint_dev_s *esp32gpint = + (struct esp32gpint_dev_s *)arg; DEBUGASSERT(esp32gpint != NULL && esp32gpint->callback != NULL); gpioinfo("Interrupt! callback=%p\n", esp32gpint->callback); @@ -241,10 +241,10 @@ static int esp32gpio_interrupt(int irq, void *context, void *arg) * Name: gpint_read ****************************************************************************/ -static int gpint_read(FAR struct gpio_dev_s *dev, FAR bool *value) +static int gpint_read(struct gpio_dev_s *dev, bool *value) { - FAR struct esp32gpint_dev_s *esp32gpint = - (FAR struct esp32gpint_dev_s *)dev; + struct esp32gpint_dev_s *esp32gpint = + (struct esp32gpint_dev_s *)dev; DEBUGASSERT(esp32gpint != NULL && value != NULL); DEBUGASSERT(esp32gpint->esp32gpio.id < BOARD_NGPIOINT); @@ -258,11 +258,11 @@ static int gpint_read(FAR struct gpio_dev_s *dev, FAR bool *value) * Name: gpint_attach ****************************************************************************/ -static int gpint_attach(FAR struct gpio_dev_s *dev, +static int gpint_attach(struct gpio_dev_s *dev, pin_interrupt_t callback) { - FAR struct esp32gpint_dev_s *esp32gpint = - (FAR struct esp32gpint_dev_s *)dev; + struct esp32gpint_dev_s *esp32gpint = + (struct esp32gpint_dev_s *)dev; int irq = ESP32_PIN2IRQ(g_gpiointinputs[esp32gpint->esp32gpio.id]); int ret; @@ -289,10 +289,10 @@ static int gpint_attach(FAR struct gpio_dev_s *dev, * Name: gpint_enable ****************************************************************************/ -static int gpint_enable(FAR struct gpio_dev_s *dev, bool enable) +static int gpint_enable(struct gpio_dev_s *dev, bool enable) { - FAR struct esp32gpint_dev_s *esp32gpint = - (FAR struct esp32gpint_dev_s *)dev; + struct esp32gpint_dev_s *esp32gpint = + (struct esp32gpint_dev_s *)dev; int irq = ESP32_PIN2IRQ(g_gpiointinputs[esp32gpint->esp32gpio.id]); if (enable) diff --git a/boards/xtensa/esp32/ttgo_lora_esp32/scripts/Make.defs b/boards/xtensa/esp32/ttgo_lora_esp32/scripts/Make.defs index 11ea913c2bed6..5a250bece1e13 100644 --- a/boards/xtensa/esp32/ttgo_lora_esp32/scripts/Make.defs +++ b/boards/xtensa/esp32/ttgo_lora_esp32/scripts/Make.defs @@ -53,20 +53,6 @@ else LDSCRIPT_TEMPLATE = $(BOARD_COMMON_DIR)$(DELIM)scripts$(DELIM)esp32.template.ld endif -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifeq ($(CONFIG_STACK_CANARIES),y) - ARCHOPTIMIZATION += -fstack-protector-all -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - -ARCHCFLAGS = -fno-common -ffunction-sections -fdata-sections -mlongcalls -ARCHCXXFLAGS = $(ARCHCFLAGS) -fno-exceptions -fcheck-new -fno-rtti ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic @@ -98,8 +84,3 @@ CXXELFFLAGS = $(CXXFLAGS) -mtext-section-literals LDELFFLAGS = -r -e main LDELFFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)$(DELIM)binfmt$(DELIM)libelf$(DELIM)gnu-elf.ld) - -LDFLAGS += -Map=$(call CONVERT_PATH,$(TOPDIR)/nuttx.map) --cref -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - LDFLAGS += -g -endif diff --git a/boards/xtensa/esp32/ttgo_lora_esp32/src/esp32_boot.c b/boards/xtensa/esp32/ttgo_lora_esp32/src/esp32_boot.c index 982411a9252af..afa316c8abbc5 100644 --- a/boards/xtensa/esp32/ttgo_lora_esp32/src/esp32_boot.c +++ b/boards/xtensa/esp32/ttgo_lora_esp32/src/esp32_boot.c @@ -89,7 +89,7 @@ void board_late_initialize(void) * SMP bringup is complete. */ - umm_addregion((FAR void *)HEAP_REGION_ROMAPP_START, + umm_addregion((void *)HEAP_REGION_ROMAPP_START, (size_t)(HEAP_REGION_ROMAPP_END - HEAP_REGION_ROMAPP_START)); #endif } diff --git a/boards/xtensa/esp32/ttgo_lora_esp32/src/esp32_buttons.c b/boards/xtensa/esp32/ttgo_lora_esp32/src/esp32_buttons.c index 3dc4a41d54f67..ae63ad80bfc5f 100644 --- a/boards/xtensa/esp32/ttgo_lora_esp32/src/esp32_buttons.c +++ b/boards/xtensa/esp32/ttgo_lora_esp32/src/esp32_buttons.c @@ -127,7 +127,7 @@ uint32_t board_buttons(void) ****************************************************************************/ #ifdef CONFIG_ARCH_IRQBUTTONS -int board_button_irq(int id, xcpt_t irqhandler, FAR void *arg) +int board_button_irq(int id, xcpt_t irqhandler, void *arg) { int ret; DEBUGASSERT(id == BUTTON_BOOT); diff --git a/boards/xtensa/esp32/ttgo_lora_esp32/src/esp32_gpio.c b/boards/xtensa/esp32/ttgo_lora_esp32/src/esp32_gpio.c index 572de73fedc40..4269a7f0a9ce4 100644 --- a/boards/xtensa/esp32/ttgo_lora_esp32/src/esp32_gpio.c +++ b/boards/xtensa/esp32/ttgo_lora_esp32/src/esp32_gpio.c @@ -87,19 +87,19 @@ struct esp32gpint_dev_s ****************************************************************************/ #if BOARD_NGPIOOUT > 0 -static int gpout_read(FAR struct gpio_dev_s *dev, FAR bool *value); -static int gpout_write(FAR struct gpio_dev_s *dev, bool value); +static int gpout_read(struct gpio_dev_s *dev, bool *value); +static int gpout_write(struct gpio_dev_s *dev, bool value); #endif #if BOARD_NGPIOIN > 0 -static int gpin_read(FAR struct gpio_dev_s *dev, FAR bool *value); +static int gpin_read(struct gpio_dev_s *dev, bool *value); #endif #if BOARD_NGPIOINT > 0 -static int gpint_read(FAR struct gpio_dev_s *dev, FAR bool *value); -static int gpint_attach(FAR struct gpio_dev_s *dev, +static int gpint_read(struct gpio_dev_s *dev, bool *value); +static int gpint_attach(struct gpio_dev_s *dev, pin_interrupt_t callback); -static int gpint_enable(FAR struct gpio_dev_s *dev, bool enable); +static int gpint_enable(struct gpio_dev_s *dev, bool enable); #endif /**************************************************************************** @@ -172,9 +172,9 @@ static struct esp32gpint_dev_s g_gpint[BOARD_NGPIOINT]; ****************************************************************************/ #if BOARD_NGPIOOUT > 0 -static int gpout_read(FAR struct gpio_dev_s *dev, FAR bool *value) +static int gpout_read(struct gpio_dev_s *dev, bool *value) { - FAR struct esp32gpio_dev_s *esp32gpio = (FAR struct esp32gpio_dev_s *)dev; + struct esp32gpio_dev_s *esp32gpio = (struct esp32gpio_dev_s *)dev; DEBUGASSERT(esp32gpio != NULL && value != NULL); DEBUGASSERT(esp32gpio->id < BOARD_NGPIOOUT); @@ -188,9 +188,9 @@ static int gpout_read(FAR struct gpio_dev_s *dev, FAR bool *value) * Name: gpout_write ****************************************************************************/ -static int gpout_write(FAR struct gpio_dev_s *dev, bool value) +static int gpout_write(struct gpio_dev_s *dev, bool value) { - FAR struct esp32gpio_dev_s *esp32gpio = (FAR struct esp32gpio_dev_s *)dev; + struct esp32gpio_dev_s *esp32gpio = (struct esp32gpio_dev_s *)dev; DEBUGASSERT(esp32gpio != NULL); DEBUGASSERT(esp32gpio->id < BOARD_NGPIOOUT); @@ -206,9 +206,9 @@ static int gpout_write(FAR struct gpio_dev_s *dev, bool value) ****************************************************************************/ #if BOARD_NGPIOIN > 0 -static int gpin_read(FAR struct gpio_dev_s *dev, FAR bool *value) +static int gpin_read(struct gpio_dev_s *dev, bool *value) { - FAR struct esp32gpio_dev_s *esp32gpio = (FAR struct esp32gpio_dev_s *)dev; + struct esp32gpio_dev_s *esp32gpio = (struct esp32gpio_dev_s *)dev; DEBUGASSERT(esp32gpio != NULL && value != NULL); DEBUGASSERT(esp32gpio->id < BOARD_NGPIOIN); @@ -226,8 +226,8 @@ static int gpin_read(FAR struct gpio_dev_s *dev, FAR bool *value) #if BOARD_NGPIOINT > 0 static int esp32gpio_interrupt(int irq, void *context, void *arg) { - FAR struct esp32gpint_dev_s *esp32gpint = - (FAR struct esp32gpint_dev_s *)arg; + struct esp32gpint_dev_s *esp32gpint = + (struct esp32gpint_dev_s *)arg; DEBUGASSERT(esp32gpint != NULL && esp32gpint->callback != NULL); gpioinfo("Interrupt! callback=%p\n", esp32gpint->callback); @@ -241,10 +241,10 @@ static int esp32gpio_interrupt(int irq, void *context, void *arg) * Name: gpint_read ****************************************************************************/ -static int gpint_read(FAR struct gpio_dev_s *dev, FAR bool *value) +static int gpint_read(struct gpio_dev_s *dev, bool *value) { - FAR struct esp32gpint_dev_s *esp32gpint = - (FAR struct esp32gpint_dev_s *)dev; + struct esp32gpint_dev_s *esp32gpint = + (struct esp32gpint_dev_s *)dev; DEBUGASSERT(esp32gpint != NULL && value != NULL); DEBUGASSERT(esp32gpint->esp32gpio.id < BOARD_NGPIOINT); @@ -258,11 +258,11 @@ static int gpint_read(FAR struct gpio_dev_s *dev, FAR bool *value) * Name: gpint_attach ****************************************************************************/ -static int gpint_attach(FAR struct gpio_dev_s *dev, +static int gpint_attach(struct gpio_dev_s *dev, pin_interrupt_t callback) { - FAR struct esp32gpint_dev_s *esp32gpint = - (FAR struct esp32gpint_dev_s *)dev; + struct esp32gpint_dev_s *esp32gpint = + (struct esp32gpint_dev_s *)dev; int irq = ESP32_PIN2IRQ(g_gpiointinputs[esp32gpint->esp32gpio.id]); int ret; @@ -289,10 +289,10 @@ static int gpint_attach(FAR struct gpio_dev_s *dev, * Name: gpint_enable ****************************************************************************/ -static int gpint_enable(FAR struct gpio_dev_s *dev, bool enable) +static int gpint_enable(struct gpio_dev_s *dev, bool enable) { - FAR struct esp32gpint_dev_s *esp32gpint = - (FAR struct esp32gpint_dev_s *)dev; + struct esp32gpint_dev_s *esp32gpint = + (struct esp32gpint_dev_s *)dev; int irq = ESP32_PIN2IRQ(g_gpiointinputs[esp32gpint->esp32gpio.id]); if (enable) diff --git a/boards/xtensa/esp32s2/esp32s2-saola-1/configs/cxx/defconfig b/boards/xtensa/esp32s2/esp32s2-saola-1/configs/cxx/defconfig new file mode 100644 index 0000000000000..d3987bd9dfd08 --- /dev/null +++ b/boards/xtensa/esp32s2/esp32s2-saola-1/configs/cxx/defconfig @@ -0,0 +1,49 @@ +# +# This file is autogenerated: PLEASE DO NOT EDIT IT. +# +# You can use "make menuconfig" to make any modifications to the installed .config file. +# You can then do "make savedefconfig" to generate a new defconfig file that includes your +# modifications. +# +# CONFIG_ARCH_LEDS is not set +# CONFIG_NSH_ARGCAT is not set +# CONFIG_NSH_CMDOPT_HEXDUMP is not set +# CONFIG_NSH_CMDPARMS is not set +CONFIG_ARCH="xtensa" +CONFIG_ARCH_BOARD="esp32s2-saola-1" +CONFIG_ARCH_BOARD_COMMON=y +CONFIG_ARCH_BOARD_ESP32S2_SAOLA_1=y +CONFIG_ARCH_CHIP="esp32s2" +CONFIG_ARCH_CHIP_ESP32S2=y +CONFIG_ARCH_CHIP_ESP32S2WROVER=y +CONFIG_ARCH_STACKDUMP=y +CONFIG_ARCH_XTENSA=y +CONFIG_BOARD_LOOPSPERMSEC=16717 +CONFIG_BUILTIN=y +CONFIG_ESP32S2_UART0=y +CONFIG_FS_PROCFS=y +CONFIG_HAVE_CXX=y +CONFIG_IDLETHREAD_STACKSIZE=3072 +CONFIG_INIT_ENTRYPOINT="nsh_main" +CONFIG_INTELHEX_BINARY=y +CONFIG_LIBCXX=y +CONFIG_LIBCXXABI=y +CONFIG_LIBM=y +CONFIG_NSH_ARCHINIT=y +CONFIG_NSH_BUILTIN_APPS=y +CONFIG_NSH_FILEIOSIZE=512 +CONFIG_NSH_LINELEN=64 +CONFIG_NSH_READLINE=y +CONFIG_PREALLOC_TIMERS=4 +CONFIG_RAM_SIZE=114688 +CONFIG_RAM_START=0x20000000 +CONFIG_RAW_BINARY=y +CONFIG_RR_INTERVAL=200 +CONFIG_SCHED_ATEXIT=y +CONFIG_SCHED_WAITPID=y +CONFIG_START_DAY=6 +CONFIG_START_MONTH=12 +CONFIG_START_YEAR=2011 +CONFIG_SYSTEM_NSH=y +CONFIG_TESTING_CXXTEST=y +CONFIG_UART0_SERIAL_CONSOLE=y diff --git a/boards/xtensa/esp32s2/esp32s2-saola-1/scripts/Make.defs b/boards/xtensa/esp32s2/esp32s2-saola-1/scripts/Make.defs index 39aaf66e9bfde..250960ef20bfb 100644 --- a/boards/xtensa/esp32s2/esp32s2-saola-1/scripts/Make.defs +++ b/boards/xtensa/esp32s2/esp32s2-saola-1/scripts/Make.defs @@ -38,26 +38,10 @@ endif ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)esp32s2_rom.ld ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)esp32s2_peripherals.ld -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - -ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -endif - -ARCHCFLAGS = -fno-common -ffunction-sections -fdata-sections -mlongcalls -ARCHCXXFLAGS = $(ARCHCFLAGS) -fno-exceptions -fcheck-new -fno-rtti ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic -# if SPIRAM/PSRAM is used then we need to include a workaround - -ifeq ($(CONFIG_ESP32S2_SPIRAM),y) - ARCHCFLAGS += -mfix-esp32s2-psram-cache-issue -endif - CFLAGS := $(ARCHCFLAGS) $(ARCHWARNINGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) -pipe CPICFLAGS = $(ARCHPICFLAGS) $(CFLAGS) CXXFLAGS := $(ARCHCXXFLAGS) $(ARCHWARNINGSXX) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHXXINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) -pipe @@ -78,9 +62,4 @@ CELFFLAGS = $(CFLAGS) -mtext-section-literals CXXELFFLAGS = $(CXXFLAGS) -mtext-section-literals LDELFFLAGS = -r -e main -LDELFFLAGS += -T $(call CONVERT_PATH,$(BOARD_DIR)$(DELIM)scripts$(DELIM)gnu-elf.ld) - -LDFLAGS += -Map=$(call CONVERT_PATH,$(TOPDIR)/nuttx.map) --cref -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - LDFLAGS += -g -endif +LDELFFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)/binfmt/libelf/gnu-elf.ld) diff --git a/boards/xtensa/esp32s2/esp32s2-saola-1/scripts/esp32s2_rom.ld b/boards/xtensa/esp32s2/esp32s2-saola-1/scripts/esp32s2_rom.ld index ec17e1d4841da..25db27c30b1db 100644 --- a/boards/xtensa/esp32s2/esp32s2-saola-1/scripts/esp32s2_rom.ld +++ b/boards/xtensa/esp32s2/esp32s2-saola-1/scripts/esp32s2_rom.ld @@ -18,7 +18,7 @@ PROVIDE ( Cache_Clean_Items = 0x40018250 ); PROVIDE ( Cache_Config_DCache_Autoload = 0x40018794 ); PROVIDE ( Cache_Config_ICache_Autoload = 0x40018664 ); PROVIDE ( Cache_Count_Flash_Pages = 0x40018f70 ); -PROVIDE ( Cache_Dbus_MMU_Set = 0x40018eb0 ); +PROVIDE ( cache_dbus_mmu_set = 0x40018eb0 ); PROVIDE ( Cache_DCache_Preload_Done = 0x40018630 ); PROVIDE ( Cache_Disable_DCache = 0x40018c68 ); PROVIDE ( Cache_Disable_DCache_Autoload = 0x4001888c ); @@ -26,7 +26,7 @@ PROVIDE ( Cache_Disable_DCache_PreLock = 0x40018a5c ); PROVIDE ( Cache_Disable_ICache = 0x40018c2c ); PROVIDE ( Cache_Disable_ICache_Autoload = 0x4001875c ); PROVIDE ( Cache_Disable_ICache_PreLock = 0x4001892c ); -PROVIDE ( Cache_Enable_DCache = 0x40018d58 ); +PROVIDE ( cache_enable_dcache = 0x40018d58 ); PROVIDE ( Cache_Enable_DCache_Autoload = 0x40018874 ); PROVIDE ( Cache_Enable_DCache_PreLock = 0x400189f0 ); PROVIDE ( Cache_Enable_Defalut_DCache_Mode = 0x40018170 ); @@ -46,7 +46,7 @@ PROVIDE ( Cache_Get_Virtual_Addr = 0x40019210 ); PROVIDE ( cache_ibus_mmu_set = 0x40018df4 ); PROVIDE ( Cache_ICache_Preload_Done = 0x4001859c ); PROVIDE ( cache_invalidate_addr = 0x400182e4 ); -PROVIDE ( Cache_Invalidate_DCache_All = 0x4001842c ); +PROVIDE ( cache_invalidate_dcache_all = 0x4001842c ); PROVIDE ( Cache_Invalidate_DCache_Items = 0x40018208 ); PROVIDE ( cache_invalidate_icache_all = 0x40018420 ); PROVIDE ( Cache_Invalidate_ICache_Items = 0x400181b8 ); @@ -60,7 +60,7 @@ PROVIDE ( Cache_Resume_DCache = 0x40018d3c ); PROVIDE ( Cache_Resume_DCache_Autoload = 0x4001850c ); PROVIDE ( cache_resume_icache = 0x40018cdc ); PROVIDE ( Cache_Resume_ICache_Autoload = 0x400184c4 ); -PROVIDE ( Cache_Set_DCache_Mode = 0x40018074 ); +PROVIDE ( cache_set_dcache_mode = 0x40018074 ); PROVIDE ( Cache_Set_Default_Mode = 0x4001810c ); PROVIDE ( cache_set_icache_mode = 0x4001803c ); PROVIDE ( Cache_Start_DCache_Preload = 0x400185c4 ); @@ -74,8 +74,8 @@ PROVIDE ( Cache_Unlock_Addr = 0x40018b9c ); PROVIDE ( Cache_Unlock_DCache_Items = 0x40018ac8 ); PROVIDE ( Cache_Unlock_ICache_Items = 0x40018998 ); PROVIDE ( Cache_UnMask_Drom0 = 0x40018480 ); -PROVIDE ( Cache_WriteBack_Addr = 0x400183c8 ); -PROVIDE ( Cache_WriteBack_All = 0x40018444 ); +PROVIDE ( cache_writeback_addr = 0x400183c8 ); +PROVIDE ( cache_writeback_all = 0x40018444 ); PROVIDE ( Cache_WriteBack_Items = 0x40018298 ); PROVIDE ( cacl_rtc_memory_crc = 0x4000ffa0 ); PROVIDE ( cdc_acm_class_handle_req = 0x40013050 ); @@ -211,6 +211,9 @@ PROVIDE ( esp_rom_spi_flash_update_id = 0x40016e44 ); PROVIDE ( esp_rom_spi_reset_rw_mode = 0x40017984 ); PROVIDE ( esp_rom_spi_set_dtr_swap_mode = 0x40017b60 ); PROVIDE ( esp_rom_spi_set_op_mode = 0x400179e8 ); +PROVIDE ( esp_rom_efuse_get_flash_gpio_info = ets_efuse_get_spiconfig ); +PROVIDE ( esp_rom_efuse_get_flash_wp_gpio = ets_efuse_get_wp_pad ); +PROVIDE ( esp_rom_spiflash_select_qio_pins = SelectSpiQIO ); PROVIDE ( _etext = 0x4001bed0 ); PROVIDE ( ets_aes_block = 0x4000d610 ); PROVIDE ( ets_aes_disable = 0x4000d4f8 ); diff --git a/boards/xtensa/esp32s2/esp32s2-saola-1/src/esp32s2_gpio.c b/boards/xtensa/esp32s2/esp32s2-saola-1/src/esp32s2_gpio.c index 69423f5ed27c8..10e18f703f2f1 100644 --- a/boards/xtensa/esp32s2/esp32s2-saola-1/src/esp32s2_gpio.c +++ b/boards/xtensa/esp32s2/esp32s2-saola-1/src/esp32s2_gpio.c @@ -83,19 +83,19 @@ struct esp32s2gpint_dev_s ****************************************************************************/ #if BOARD_NGPIOOUT > 0 -static int gpout_read(FAR struct gpio_dev_s *dev, FAR bool *value); -static int gpout_write(FAR struct gpio_dev_s *dev, bool value); +static int gpout_read(struct gpio_dev_s *dev, bool *value); +static int gpout_write(struct gpio_dev_s *dev, bool value); #endif #if BOARD_NGPIOIN > 0 -static int gpin_read(FAR struct gpio_dev_s *dev, FAR bool *value); +static int gpin_read(struct gpio_dev_s *dev, bool *value); #endif #if BOARD_NGPIOINT > 0 -static int gpint_read(FAR struct gpio_dev_s *dev, FAR bool *value); -static int gpint_attach(FAR struct gpio_dev_s *dev, +static int gpint_read(struct gpio_dev_s *dev, bool *value); +static int gpint_attach(struct gpio_dev_s *dev, pin_interrupt_t callback); -static int gpint_enable(FAR struct gpio_dev_s *dev, bool enable); +static int gpint_enable(struct gpio_dev_s *dev, bool enable); #endif /**************************************************************************** @@ -179,10 +179,10 @@ static struct esp32s2gpint_dev_s g_gpint[BOARD_NGPIOINT]; ****************************************************************************/ #if BOARD_NGPIOOUT > 0 -static int gpout_read(FAR struct gpio_dev_s *dev, FAR bool *value) +static int gpout_read(struct gpio_dev_s *dev, bool *value) { - FAR struct esp32s2gpio_dev_s *esp32s2gpio = - (FAR struct esp32s2gpio_dev_s *)dev; + struct esp32s2gpio_dev_s *esp32s2gpio = + (struct esp32s2gpio_dev_s *)dev; DEBUGASSERT(esp32s2gpio != NULL && value != NULL); DEBUGASSERT(esp32s2gpio->id < BOARD_NGPIOOUT); @@ -207,10 +207,10 @@ static int gpout_read(FAR struct gpio_dev_s *dev, FAR bool *value) * ****************************************************************************/ -static int gpout_write(FAR struct gpio_dev_s *dev, bool value) +static int gpout_write(struct gpio_dev_s *dev, bool value) { - FAR struct esp32s2gpio_dev_s *esp32s2gpio = - (FAR struct esp32s2gpio_dev_s *)dev; + struct esp32s2gpio_dev_s *esp32s2gpio = + (struct esp32s2gpio_dev_s *)dev; DEBUGASSERT(esp32s2gpio != NULL); DEBUGASSERT(esp32s2gpio->id < BOARD_NGPIOOUT); @@ -237,10 +237,10 @@ static int gpout_write(FAR struct gpio_dev_s *dev, bool value) ****************************************************************************/ #if BOARD_NGPIOIN > 0 -static int gpin_read(FAR struct gpio_dev_s *dev, FAR bool *value) +static int gpin_read(struct gpio_dev_s *dev, bool *value) { - FAR struct esp32s2gpio_dev_s *esp32s2gpio = - (FAR struct esp32s2gpio_dev_s *)dev; + struct esp32s2gpio_dev_s *esp32s2gpio = + (struct esp32s2gpio_dev_s *)dev; DEBUGASSERT(esp32s2gpio != NULL && value != NULL); DEBUGASSERT(esp32s2gpio->id < BOARD_NGPIOIN); @@ -262,8 +262,8 @@ static int gpin_read(FAR struct gpio_dev_s *dev, FAR bool *value) #if BOARD_NGPIOINT > 0 static int esp32s2gpio_interrupt(int irq, void *context, void *arg) { - FAR struct esp32s2gpint_dev_s *esp32s2gpint = - (FAR struct esp32s2gpint_dev_s *)arg; + struct esp32s2gpint_dev_s *esp32s2gpint = + (struct esp32s2gpint_dev_s *)arg; DEBUGASSERT(esp32s2gpint != NULL && esp32s2gpint->callback != NULL); gpioinfo("Interrupt! callback=%p\n", esp32s2gpint->callback); @@ -288,10 +288,10 @@ static int esp32s2gpio_interrupt(int irq, void *context, void *arg) * ****************************************************************************/ -static int gpint_read(FAR struct gpio_dev_s *dev, FAR bool *value) +static int gpint_read(struct gpio_dev_s *dev, bool *value) { - FAR struct esp32s2gpint_dev_s *esp32s2gpint = - (FAR struct esp32s2gpint_dev_s *)dev; + struct esp32s2gpint_dev_s *esp32s2gpint = + (struct esp32s2gpint_dev_s *)dev; DEBUGASSERT(esp32s2gpint != NULL && value != NULL); DEBUGASSERT(esp32s2gpint->esp32s2gpio.id < BOARD_NGPIOINT); @@ -318,11 +318,11 @@ static int gpint_read(FAR struct gpio_dev_s *dev, FAR bool *value) * ****************************************************************************/ -static int gpint_attach(FAR struct gpio_dev_s *dev, +static int gpint_attach(struct gpio_dev_s *dev, pin_interrupt_t callback) { - FAR struct esp32s2gpint_dev_s *esp32s2gpint = - (FAR struct esp32s2gpint_dev_s *)dev; + struct esp32s2gpint_dev_s *esp32s2gpint = + (struct esp32s2gpint_dev_s *)dev; int irq = ESP32S2_PIN2IRQ(g_gpiointinputs[esp32s2gpint->esp32s2gpio.id]); int ret; @@ -360,10 +360,10 @@ static int gpint_attach(FAR struct gpio_dev_s *dev, * ****************************************************************************/ -static int gpint_enable(FAR struct gpio_dev_s *dev, bool enable) +static int gpint_enable(struct gpio_dev_s *dev, bool enable) { - FAR struct esp32s2gpint_dev_s *esp32s2gpint = - (FAR struct esp32s2gpint_dev_s *)dev; + struct esp32s2gpint_dev_s *esp32s2gpint = + (struct esp32s2gpint_dev_s *)dev; int irq = ESP32S2_PIN2IRQ(g_gpiointinputs[esp32s2gpint->esp32s2gpio.id]); if (enable) diff --git a/boards/xtensa/esp32s3/common/src/esp32s3_board_spiflash.c b/boards/xtensa/esp32s3/common/src/esp32s3_board_spiflash.c index f74748ea8b203..75e266b9570e1 100644 --- a/boards/xtensa/esp32s3/common/src/esp32s3_board_spiflash.c +++ b/boards/xtensa/esp32s3/common/src/esp32s3_board_spiflash.c @@ -69,7 +69,7 @@ ****************************************************************************/ #if defined (CONFIG_ESP32S3_SPIFLASH_SMARTFS) -static int setup_smartfs(int smartn, FAR struct mtd_dev_s *mtd, +static int setup_smartfs(int smartn, struct mtd_dev_s *mtd, const char *mnt_pt) { int ret = OK; @@ -130,7 +130,7 @@ static int setup_smartfs(int smartn, FAR struct mtd_dev_s *mtd, ****************************************************************************/ #if defined (CONFIG_ESP32S3_SPIFLASH_LITTLEFS) -static int setup_littlefs(const char *path, FAR struct mtd_dev_s *mtd, +static int setup_littlefs(const char *path, struct mtd_dev_s *mtd, const char *mnt_pt, int priv) { int ret = OK; @@ -178,7 +178,7 @@ static int setup_littlefs(const char *path, FAR struct mtd_dev_s *mtd, ****************************************************************************/ #if defined (CONFIG_ESP32S3_SPIFLASH_SPIFFS) -static int setup_spiffs(const char *path, FAR struct mtd_dev_s *mtd, +static int setup_spiffs(const char *path, struct mtd_dev_s *mtd, const char *mnt_pt, int priv) { int ret = OK; @@ -220,7 +220,7 @@ static int setup_spiffs(const char *path, FAR struct mtd_dev_s *mtd, ****************************************************************************/ #if defined (CONFIG_ESP32S3_SPIFLASH_NXFFS) -static int setup_nxffs(FAR struct mtd_dev_s *mtd, const char *mnt_pt) +static int setup_nxffs(struct mtd_dev_s *mtd, const char *mnt_pt) { int ret = OK; @@ -259,7 +259,7 @@ static int setup_nxffs(FAR struct mtd_dev_s *mtd, const char *mnt_pt) static int init_storage_partition(void) { int ret = OK; - FAR struct mtd_dev_s *mtd; + struct mtd_dev_s *mtd; mtd = esp32s3_spiflash_alloc_mtdpart(CONFIG_ESP32S3_STORAGE_MTD_OFFSET, CONFIG_ESP32S3_STORAGE_MTD_SIZE, diff --git a/boards/xtensa/esp32s3/esp32s3-devkit/configs/cxx/defconfig b/boards/xtensa/esp32s3/esp32s3-devkit/configs/cxx/defconfig new file mode 100644 index 0000000000000..92d6386b4ecc3 --- /dev/null +++ b/boards/xtensa/esp32s3/esp32s3-devkit/configs/cxx/defconfig @@ -0,0 +1,51 @@ +# +# This file is autogenerated: PLEASE DO NOT EDIT IT. +# +# You can use "make menuconfig" to make any modifications to the installed .config file. +# You can then do "make savedefconfig" to generate a new defconfig file that includes your +# modifications. +# +# CONFIG_ARCH_LEDS is not set +# CONFIG_NSH_ARGCAT is not set +# CONFIG_NSH_CMDOPT_HEXDUMP is not set +# CONFIG_NSH_CMDPARMS is not set +CONFIG_ARCH="xtensa" +CONFIG_ARCH_BOARD="esp32s3-devkit" +CONFIG_ARCH_BOARD_COMMON=y +CONFIG_ARCH_BOARD_ESP32S3_DEVKIT=y +CONFIG_ARCH_CHIP="esp32s3" +CONFIG_ARCH_CHIP_ESP32S3=y +CONFIG_ARCH_CHIP_ESP32S3WROOM1=y +CONFIG_ARCH_STACKDUMP=y +CONFIG_ARCH_XTENSA=y +CONFIG_BOARD_LOOPSPERMSEC=16717 +CONFIG_BUILTIN=y +CONFIG_DEBUG_FULLOPT=y +CONFIG_DEBUG_SYMBOLS=y +CONFIG_ESP32S3_UART0=y +CONFIG_FS_PROCFS=y +CONFIG_HAVE_CXX=y +CONFIG_IDLETHREAD_STACKSIZE=3072 +CONFIG_INIT_ENTRYPOINT="nsh_main" +CONFIG_INTELHEX_BINARY=y +CONFIG_LIBCXX=y +CONFIG_LIBCXXABI=y +CONFIG_LIBM=y +CONFIG_NSH_ARCHINIT=y +CONFIG_NSH_BUILTIN_APPS=y +CONFIG_NSH_FILEIOSIZE=512 +CONFIG_NSH_LINELEN=64 +CONFIG_NSH_READLINE=y +CONFIG_PREALLOC_TIMERS=4 +CONFIG_RAM_SIZE=114688 +CONFIG_RAM_START=0x20000000 +CONFIG_RAW_BINARY=y +CONFIG_RR_INTERVAL=200 +CONFIG_SCHED_ATEXIT=y +CONFIG_SCHED_WAITPID=y +CONFIG_START_DAY=6 +CONFIG_START_MONTH=12 +CONFIG_START_YEAR=2011 +CONFIG_SYSTEM_NSH=y +CONFIG_TESTING_CXXTEST=y +CONFIG_UART0_SERIAL_CONSOLE=y diff --git a/boards/xtensa/esp32s3/esp32s3-devkit/scripts/Make.defs b/boards/xtensa/esp32s3/esp32s3-devkit/scripts/Make.defs index da8f4552c3ba0..10c8510543d17 100644 --- a/boards/xtensa/esp32s3/esp32s3-devkit/scripts/Make.defs +++ b/boards/xtensa/esp32s3/esp32s3-devkit/scripts/Make.defs @@ -28,16 +28,10 @@ ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)esp32s3.ld ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)esp32s3_rom.ld ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)esp32s3_peripherals.ld -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = -g -endif - ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -fno-strength-reduce + ARCHOPTIMIZATION += -fno-strength-reduce endif -ARCHCFLAGS = -fno-common -ffunction-sections -fdata-sections -fstrict-volatile-bitfields -mlongcalls -ARCHCXXFLAGS = $(ARCHCFLAGS) -fno-exceptions -fcheck-new -fno-rtti ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHPICFLAGS = -fpic @@ -62,9 +56,4 @@ CELFFLAGS = $(CFLAGS) -mtext-section-literals CXXELFFLAGS = $(CXXFLAGS) -mtext-section-literals LDELFFLAGS = -r -e main -LDELFFLAGS += -T $(call CONVERT_PATH,$(BOARD_DIR)$(DELIM)scripts$(DELIM)gnu-elf.ld) - -LDFLAGS += -Map=$(call CONVERT_PATH,$(TOPDIR)/nuttx.map) --cref -ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - LDFLAGS += -g -endif +LDELFFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)/binfmt/libelf/gnu-elf.ld) diff --git a/boards/xtensa/esp32s3/esp32s3-devkit/src/esp32s3_buttons.c b/boards/xtensa/esp32s3/esp32s3-devkit/src/esp32s3_buttons.c index b8be81c95a3fc..9dabe6097c6ab 100644 --- a/boards/xtensa/esp32s3/esp32s3-devkit/src/esp32s3_buttons.c +++ b/boards/xtensa/esp32s3/esp32s3-devkit/src/esp32s3_buttons.c @@ -125,7 +125,7 @@ uint32_t board_buttons(void) ****************************************************************************/ #ifdef CONFIG_ARCH_IRQBUTTONS -int board_button_irq(int id, xcpt_t irqhandler, FAR void *arg) +int board_button_irq(int id, xcpt_t irqhandler, void *arg) { int ret; DEBUGASSERT(id == BUTTON_BOOT); diff --git a/boards/z80/z80/z80sim/README.txt b/boards/z80/z80/z80sim/README.txt index c98546b7cbe5e..84ac69bc58de1 100644 --- a/boards/z80/z80/z80sim/README.txt +++ b/boards/z80/z80/z80sim/README.txt @@ -124,9 +124,6 @@ and the following changes to the configuration file: +CONFIG_HOST_WINDOWS=y +CONFIG_WINDOWS_NATIVE=y - -CONFIG_Z80_TOOLCHAIN_SDCCL=y - +CONFIG_Z80_TOOLCHAIN_SDCCW=y - You may need to first manually change the CONFIG_APPS_DIR="../apps" definition in the .config file because the forward slash may upset some Windows-based tools. @@ -151,8 +148,7 @@ site: http://sourceforge.net/projects/sdcc/files/ . Pre-built binaries are available for Linux, macOS, and for Win32. Various SDCC options can be selected with: - CONFIG_Z80_TOOLCHAIN_SDCCL=y : SDCC for Linux, macOS or Cygwin (see below) - CONFIG_Z80_TOOLCHAIN_SDCCW=y : SDCC for Win32 + CONFIG_Z80_TOOLCHAIN_SDCC=y : SDCC for Win32, Linux, macOS or Cygwin SDCC versions 3.2.0 or higher are recommended. diff --git a/drivers/analog/comp.c b/drivers/analog/comp.c index 580a18c105230..74908d93aa89c 100644 --- a/drivers/analog/comp.c +++ b/drivers/analog/comp.c @@ -115,7 +115,7 @@ static void comp_pollnotify(FAR struct comp_dev_s *dev, if (fds->revents != 0) { - ainfo("Report events: %02x\n", fds->revents); + ainfo("Report events: %08" PRIx32 "\n", fds->revents); nxsem_post(fds->sem); } } diff --git a/drivers/analog/dac.c b/drivers/analog/dac.c index 46b7484cf8cba..f6c849b3500ce 100644 --- a/drivers/analog/dac.c +++ b/drivers/analog/dac.c @@ -54,7 +54,7 @@ static int dac_open(FAR struct file *filep); static int dac_close(FAR struct file *filep); static ssize_t dac_write(FAR struct file *filep, FAR const char *buffer, - size_t buflen); + size_t buflen); static int dac_ioctl(FAR struct file *filep, int cmd, unsigned long arg); /**************************************************************************** diff --git a/drivers/audio/cs43l22.h b/drivers/audio/cs43l22.h index 0e4385416f1cf..eb82c95ca9c3c 100644 --- a/drivers/audio/cs43l22.h +++ b/drivers/audio/cs43l22.h @@ -321,7 +321,7 @@ struct cs43l22_dev_s /* Our specific driver data goes here */ - const FAR struct cs43l22_lower_s *lower; /* Pointer to the board lower functions */ + FAR const struct cs43l22_lower_s *lower; /* Pointer to the board lower functions */ FAR struct i2c_master_s *i2c; /* I2C driver to use */ FAR struct i2s_dev_s *i2s; /* I2S driver to use */ struct dq_queue_s pendq; /* Queue of pending buffers to be sent */ diff --git a/drivers/audio/cxd56.c b/drivers/audio/cxd56.c index 2bf83659d75af..1aaf6a1ec9b79 100644 --- a/drivers/audio/cxd56.c +++ b/drivers/audio/cxd56.c @@ -62,8 +62,8 @@ #define CXD56_IRQ1_BIT_MIC (1 << 6) /* AU0 */ #define CXD56_IRQ1_BIT_I2S1 (1 << 7) /* AU1 */ -#define CXD56_VOL_MIN -1020 -#define CXD56_VOL_MAX 120 +#define CXD56_VOL_MIN (-1020) +#define CXD56_VOL_MAX (-30) #define CXD56_VOL_MUTE (CXD56_VOL_MIN - 1) #define CXD56_VOL_RANGE ((CXD56_VOL_MAX - CXD56_VOL_MIN) / 2) #define CXD56_VOL_NX_TO_CXD56(v) ((int)((float)((v) / 1000.0) * CXD56_VOL_RANGE) \ @@ -2733,8 +2733,8 @@ static int cxd56_configure(FAR struct audio_lowerhalf_s *lower, priv->volume = CXD56_VOL_NX_TO_CXD56(volume); cxd56_set_volume(CXD56_AUDIO_VOLID_MIXER_OUT, priv->volume); - cxd56_set_volume(CXD56_AUDIO_VOLID_MIXER_IN1, priv->volume); - cxd56_set_volume(CXD56_AUDIO_VOLID_MIXER_IN2, priv->volume); + cxd56_set_volume(CXD56_AUDIO_VOLID_MIXER_IN1, 0); + cxd56_set_volume(CXD56_AUDIO_VOLID_MIXER_IN2, 0); } else { @@ -2762,8 +2762,8 @@ static int cxd56_configure(FAR struct audio_lowerhalf_s *lower, else { cxd56_set_volume(CXD56_AUDIO_VOLID_MIXER_OUT, priv->volume); - cxd56_set_volume(CXD56_AUDIO_VOLID_MIXER_IN1, priv->volume); - cxd56_set_volume(CXD56_AUDIO_VOLID_MIXER_IN2, priv->volume); + cxd56_set_volume(CXD56_AUDIO_VOLID_MIXER_IN1, 0); + cxd56_set_volume(CXD56_AUDIO_VOLID_MIXER_IN2, 0); } if (CXD56_AUDIO_ECODE_OK != ret) @@ -3683,9 +3683,9 @@ static int cxd56_init_worker(FAR struct audio_lowerhalf_s *dev) pthread_attr_init(&t_attr); sparam.sched_priority = sched_get_priority_max(SCHED_FIFO) - 3; - (void)pthread_attr_setschedparam(&t_attr, &sparam); - (void)pthread_attr_setstacksize(&t_attr, - CONFIG_CXD56_AUDIO_WORKER_STACKSIZE); + pthread_attr_setschedparam(&t_attr, &sparam); + pthread_attr_setstacksize(&t_attr, + CONFIG_CXD56_AUDIO_WORKER_STACKSIZE); ret = pthread_create(&priv->threadid, &t_attr, cxd56_workerthread, (pthread_addr_t)priv); diff --git a/drivers/audio/cxd56.h b/drivers/audio/cxd56.h index b4b1a7b857e9c..c75491547a142 100644 --- a/drivers/audio/cxd56.h +++ b/drivers/audio/cxd56.h @@ -263,7 +263,7 @@ struct cxd56_dev_s /* Our specific driver data goes here */ - const FAR struct cxd56_lower_s *lower; /* Pointer to the board lower functions */ + FAR const struct cxd56_lower_s *lower; /* Pointer to the board lower functions */ enum cxd56_devstate_e state; /* Driver state */ enum cxd56_dmahandle_e dma_handle; /* DMA handle */ struct file mq; /* Message queue for receiving messages */ diff --git a/drivers/audio/cxd56_src.c b/drivers/audio/cxd56_src.c index 88b20315b79eb..5e9b84f299f35 100644 --- a/drivers/audio/cxd56_src.c +++ b/drivers/audio/cxd56_src.c @@ -462,9 +462,9 @@ int cxd56_src_init(FAR struct cxd56_dev_s *dev, pthread_attr_init(&t_attr); sparam.sched_priority = sched_get_priority_max(SCHED_FIFO) - 3; - (void)pthread_attr_setschedparam(&t_attr, &sparam); - (void)pthread_attr_setstacksize(&t_attr, - CONFIG_CXD56_AUDIO_SRC_STACKSIZE); + pthread_attr_setschedparam(&t_attr, &sparam); + pthread_attr_setstacksize(&t_attr, + CONFIG_CXD56_AUDIO_SRC_STACKSIZE); ret = pthread_create(&g_src.threadid, &t_attr, cxd56_src_thread, (pthread_addr_t)&g_src); diff --git a/drivers/audio/vs1053.c b/drivers/audio/vs1053.c index 37cbd3e1918d4..782069b8d24a5 100644 --- a/drivers/audio/vs1053.c +++ b/drivers/audio/vs1053.c @@ -97,7 +97,7 @@ struct vs1053_struct_s /* Our specific driver data goes here */ - const FAR struct vs1053_lower_s *hw_lower; /* Pointer to the hardware lower functions */ + FAR const struct vs1053_lower_s *hw_lower; /* Pointer to the hardware lower functions */ FAR struct spi_dev_s *spi; /* Pointer to the SPI bus */ FAR struct ap_buffer_s *apb; /* Pointer to the buffer we are processing */ struct dq_queue_s apbq; /* Our queue for enqueued buffers */ diff --git a/drivers/audio/wm8776.h b/drivers/audio/wm8776.h index b4e178e60f930..83b325bc3d339 100644 --- a/drivers/audio/wm8776.h +++ b/drivers/audio/wm8776.h @@ -76,7 +76,7 @@ struct wm8776_dev_s struct audio_lowerhalf_s dev; /* WM8776 audio lower half (this device) */ - const FAR struct wm8776_lower_s *lower; /* Pointer to the board lower functions */ + FAR const struct wm8776_lower_s *lower; /* Pointer to the board lower functions */ FAR struct i2c_master_s *i2c; /* I2C driver to use */ FAR struct i2s_dev_s *i2s; /* I2S driver to use */ struct dq_queue_s pendq; /* Queue of pending buffers to be sent */ diff --git a/drivers/audio/wm8904.c b/drivers/audio/wm8904.c index baec14523c691..0f974c7f3c005 100644 --- a/drivers/audio/wm8904.c +++ b/drivers/audio/wm8904.c @@ -480,22 +480,27 @@ static void wm8904_setvolume(FAR struct wm8904_dev_s *priv, uint16_t volume, #ifndef CONFIG_AUDIO_EXCLUDE_BALANCE /* Calculate the left channel volume level {0..1000} */ - if (priv->balance <= 500) + if (priv->balance <= (b16HALF - 1)) { leftlevel = volume; } - else if (priv->balance == 1000) + else if (priv->balance == (b16ONE - 1)) { leftlevel = 0; } else { - leftlevel = wm8904_scalevolume(volume, b16ONE - (b16_t)priv->balance); + /* Note: b16ONE - balance goes from 0 to 0.5. + * Hence need to multiply volume by 2! + */ + + leftlevel = wm8904_scalevolume(2 * volume, + b16ONE - (b16_t)priv->balance); } /* Calculate the right channel volume level {0..1000} */ - if (priv->balance >= 500) + if (priv->balance >= (b16HALF - 1)) { rightlevel = volume; } @@ -505,7 +510,12 @@ static void wm8904_setvolume(FAR struct wm8904_dev_s *priv, uint16_t volume, } else { - rightlevel = wm8904_scalevolume(volume, (b16_t)priv->balance); + /* Note: b16ONE - balance goes from 0 to 0.5. + * Hence need to multiply volume by 2! + */ + + rightlevel = wm8904_scalevolume(2 * volume, + (b16_t)priv->balance); } #else leftlevel = priv->volume; @@ -1210,6 +1220,31 @@ static int wm8904_configure(FAR struct audio_lowerhalf_s *dev, break; #endif /* CONFIG_AUDIO_EXCLUDE_VOLUME */ +#ifndef CONFIG_AUDIO_EXCLUDE_BALANCE + case AUDIO_FU_BALANCE: + { + /* Set the balance. The percentage level * 10 (0-1000) is in the + * ac_controls.b[0] parameter. + */ + + uint16_t balance = caps->ac_controls.hw[0]; + audinfo(" Balance: %d\n", balance); + + if (balance >= 0 && balance <= 1000) + { + /* Scale the balance setting to the range {0..(b16ONE - 1)} */ + + priv->balance = (balance * (b16ONE - 1)) / 1000; + wm8904_setvolume(priv, priv->volume, priv->mute); + } + else + { + ret = -EDOM; + } + } + break; +#endif /* CONFIG_AUDIO_EXCLUDE_BALANCE */ + #ifndef CONFIG_AUDIO_EXCLUDE_TONE case AUDIO_FU_BASS: { @@ -2492,7 +2527,7 @@ static void wm8904_hw_reset(FAR struct wm8904_dev_s *priv) priv->nchannels = WM8904_DEFAULT_NCHANNELS; priv->bpsamp = WM8904_DEFAULT_BPSAMP; #if !defined(CONFIG_AUDIO_EXCLUDE_VOLUME) && !defined(CONFIG_AUDIO_EXCLUDE_BALANCE) - priv->balance = b16HALF; /* Center balance */ + priv->balance = b16HALF - 1; /* Center balance */ #endif /* Software reset. This puts all WM8904 registers back in their diff --git a/drivers/audio/wm8904.h b/drivers/audio/wm8904.h index 8d3bbbfa08ee3..4acfb4a7e8b87 100644 --- a/drivers/audio/wm8904.h +++ b/drivers/audio/wm8904.h @@ -1082,7 +1082,7 @@ struct wm8904_dev_s /* Our specific driver data goes here */ - const FAR struct wm8904_lower_s *lower; /* Pointer to the board lower functions */ + FAR const struct wm8904_lower_s *lower; /* Pointer to the board lower functions */ FAR struct i2c_master_s *i2c; /* I2C driver to use */ FAR struct i2s_dev_s *i2s; /* I2S driver to use */ struct dq_queue_s pendq; /* Queue of pending buffers to be sent */ diff --git a/drivers/audio/wm8994.c b/drivers/audio/wm8994.c index 75764fb7cf60c..ad756afebcca3 100644 --- a/drivers/audio/wm8994.c +++ b/drivers/audio/wm8994.c @@ -796,8 +796,8 @@ static int wm8994_start(FAR struct audio_lowerhalf_s *dev) pthread_attr_init(&tattr); sparam.sched_priority = sched_get_priority_max(SCHED_FIFO) - 3; - (void)pthread_attr_setschedparam(&tattr, &sparam); - (void)pthread_attr_setstacksize(&tattr, CONFIG_WM8994_WORKER_STACKSIZE); + pthread_attr_setschedparam(&tattr, &sparam); + pthread_attr_setstacksize(&tattr, CONFIG_WM8994_WORKER_STACKSIZE); audinfo("Starting worker thread\n"); ret = pthread_create(&priv->threadid, &tattr, wm8994_workerthread, @@ -837,9 +837,9 @@ static int wm8994_stop(FAR struct audio_lowerhalf_s *dev) term_msg.msg_id = AUDIO_MSG_STOP; term_msg.u.data = 0; - (void)file_mq_send(&priv->mq, (FAR const char *)&term_msg, - sizeof(term_msg), - CONFIG_WM8994_MSG_PRIO); + file_mq_send(&priv->mq, (FAR const char *)&term_msg, + sizeof(term_msg), + CONFIG_WM8994_MSG_PRIO); /* Join the worker thread */ diff --git a/drivers/audio/wm8994.h b/drivers/audio/wm8994.h index 42864982ae9a0..6f0fbc7d92a43 100644 --- a/drivers/audio/wm8994.h +++ b/drivers/audio/wm8994.h @@ -1568,7 +1568,7 @@ struct wm8994_dev_s /* Our specific driver data goes here */ - const FAR struct wm8994_lower_s *lower; /* Pointer to the board lower functions */ + FAR const struct wm8994_lower_s *lower; /* Pointer to the board lower functions */ FAR struct i2c_master_s *i2c; /* I2C driver to use */ FAR struct i2s_dev_s *i2s; /* I2S driver to use */ struct dq_queue_s pendq; /* Queue of pending buffers to be sent */ diff --git a/drivers/can/can.c b/drivers/can/can.c index cca1ce80ae40c..bebc59b777948 100644 --- a/drivers/can/can.c +++ b/drivers/can/can.c @@ -186,7 +186,7 @@ static void can_pollnotify(FAR struct can_dev_s *dev, pollevent_t eventset) fds->revents |= fds->events & eventset; if (fds->revents != 0) { - caninfo("Report events: %02x\n", fds->revents); + caninfo("Report events: %08" PRIx32 "\n", fds->revents); nxsem_post(fds->sem); } } diff --git a/drivers/clk/Kconfig b/drivers/clk/Kconfig index 32c90198a9011..bd50daea17dd9 100644 --- a/drivers/clk/Kconfig +++ b/drivers/clk/Kconfig @@ -10,7 +10,7 @@ if CLK config CLK_RPMSG bool "rpmsg clk driver" default n - depends on OPENAMP + depends on RPTUN ---help--- Rpmsg clk are proxy/master pairs clock that operate clks between client and server processor. diff --git a/drivers/drivers_initialize.c b/drivers/drivers_initialize.c index 3225c35ce368f..bb62e23f8870d 100644 --- a/drivers/drivers_initialize.c +++ b/drivers/drivers_initialize.c @@ -54,12 +54,6 @@ void drivers_initialize(void) { -#ifdef CONFIG_PM - /* Initialize power management subsystem proper */ - - pm_initialize(); -#endif - /* Register devices */ syslog_initialize(); diff --git a/drivers/efuse/efuse.c b/drivers/efuse/efuse.c index ffb57b75dad2a..2f58fa975a21a 100644 --- a/drivers/efuse/efuse.c +++ b/drivers/efuse/efuse.c @@ -65,8 +65,6 @@ struct efuse_upperhalf_s * Private Function Prototypes ****************************************************************************/ -static int efuse_open(FAR struct file *filep); -static int efuse_close(FAR struct file *filep); static ssize_t efuse_read(FAR struct file *filep, FAR char *buffer, size_t buflen); static ssize_t efuse_write(FAR struct file *filep, FAR const char *buffer, @@ -80,8 +78,8 @@ static int efuse_ioctl(FAR struct file *filep, int cmd, static const struct file_operations g_efuseops = { - efuse_open, /* open */ - efuse_close, /* close */ + NULL, /* open */ + NULL, /* close */ efuse_read, /* read */ efuse_write, /* write */ NULL, /* seek */ @@ -96,32 +94,6 @@ static const struct file_operations g_efuseops = * Private Functions ****************************************************************************/ -/**************************************************************************** - * Name: efuse_open - * - * Description: - * This function is called whenever the efuse timer device is opened. - * - ****************************************************************************/ - -static int efuse_open(FAR struct file *filep) -{ - return OK; -} - -/**************************************************************************** - * Name: efuse_close - * - * Description: - * This function is called when the efuse timer device is closed. - * - ****************************************************************************/ - -static int efuse_close(FAR struct file *filep) -{ - return OK; -} - /**************************************************************************** * Name: efuse_read * diff --git a/drivers/input/ads7843e.c b/drivers/input/ads7843e.c index 2df8be1987a1c..e7e204bb1221a 100644 --- a/drivers/input/ads7843e.c +++ b/drivers/input/ads7843e.c @@ -85,15 +85,15 @@ static void ads7843e_lock(FAR struct spi_dev_s *spi); static void ads7843e_unlock(FAR struct spi_dev_s *spi); static uint16_t ads7843e_sendcmd(FAR struct ads7843e_dev_s *priv, - uint8_t cmd); + uint8_t cmd); /* Interrupts and data sampling */ static void ads7843e_notify(FAR struct ads7843e_dev_s *priv); static int ads7843e_sample(FAR struct ads7843e_dev_s *priv, - FAR struct ads7843e_sample_s *sample); + FAR struct ads7843e_sample_s *sample); static int ads7843e_waitsample(FAR struct ads7843e_dev_s *priv, - FAR struct ads7843e_sample_s *sample); + FAR struct ads7843e_sample_s *sample); static void ads7843e_worker(FAR void *arg); static int ads7843e_interrupt(int irq, FAR void *context, FAR void *arg); @@ -102,11 +102,11 @@ static int ads7843e_interrupt(int irq, FAR void *context, FAR void *arg); static int ads7843e_open(FAR struct file *filep); static int ads7843e_close(FAR struct file *filep); static ssize_t ads7843e_read(FAR struct file *filep, FAR char *buffer, - size_t len); + size_t len); static int ads7843e_ioctl(FAR struct file *filep, int cmd, - unsigned long arg); + unsigned long arg); static int ads7843e_poll(FAR struct file *filep, struct pollfd *fds, - bool setup); + bool setup); /**************************************************************************** * Private Data @@ -293,7 +293,7 @@ static void ads7843e_notify(FAR struct ads7843e_dev_s *priv) if (fds) { fds->revents |= POLLIN; - iinfo("Report events: %02x\n", fds->revents); + iinfo("Report events: %08" PRIx32 "\n", fds->revents); nxsem_post(fds->sem); } } @@ -317,7 +317,7 @@ static void ads7843e_notify(FAR struct ads7843e_dev_s *priv) ****************************************************************************/ static int ads7843e_sample(FAR struct ads7843e_dev_s *priv, - FAR struct ads7843e_sample_s *sample) + FAR struct ads7843e_sample_s *sample) { irqstate_t flags; int ret = -EAGAIN; @@ -1018,7 +1018,7 @@ static int ads7843e_ioctl(FAR struct file *filep, int cmd, unsigned long arg) ****************************************************************************/ static int ads7843e_poll(FAR struct file *filep, FAR struct pollfd *fds, - bool setup) + bool setup) { FAR struct inode *inode; FAR struct ads7843e_dev_s *priv; @@ -1203,7 +1203,7 @@ int ads7843e_register(FAR struct spi_dev_s *spi, /* Register the device as an input device */ - snprintf(devname, DEV_NAMELEN, DEV_FORMAT, minor); + snprintf(devname, sizeof(devname), DEV_FORMAT, minor); iinfo("Registering %s\n", devname); ret = register_driver(devname, &ads7843e_fops, 0666, priv); diff --git a/drivers/input/ajoystick.c b/drivers/input/ajoystick.c index 43dc85968380a..a0f04597cc68b 100644 --- a/drivers/input/ajoystick.c +++ b/drivers/input/ajoystick.c @@ -273,7 +273,7 @@ static void ajoy_sample(FAR struct ajoy_upperhalf_s *priv) fds->revents |= (fds->events & POLLIN); if (fds->revents != 0) { - iinfo("Report events: %02x\n", fds->revents); + iinfo("Report events: %08" PRIx32 "\n", fds->revents); nxsem_post(fds->sem); } } @@ -638,7 +638,7 @@ static int ajoy_poll(FAR struct file *filep, FAR struct pollfd *fds, fds->revents |= (fds->events & POLLIN); if (fds->revents != 0) { - iinfo("Report events: %02x\n", fds->revents); + iinfo("Report events: %08" PRIx32 "\n", fds->revents); nxsem_post(fds->sem); } } diff --git a/drivers/input/button_upper.c b/drivers/input/button_upper.c index 6fefdb306b260..0b572e4633655 100644 --- a/drivers/input/button_upper.c +++ b/drivers/input/button_upper.c @@ -275,7 +275,7 @@ static void btn_sample(FAR struct btn_upperhalf_s *priv) fds->revents |= (fds->events & POLLIN); if (fds->revents != 0) { - iinfo("Report events: %02x\n", fds->revents); + iinfo("Report events: %08" PRIx32 "\n", fds->revents); nxsem_post(fds->sem); } } @@ -690,7 +690,7 @@ static int btn_poll(FAR struct file *filep, FAR struct pollfd *fds, fds->revents |= (fds->events & POLLIN); if (fds->revents != 0) { - iinfo("Report events: %02x\n", fds->revents); + iinfo("Report events: %08" PRIx32 "\n", fds->revents); nxsem_post(fds->sem); } } diff --git a/drivers/input/cypress_mbr3108.c b/drivers/input/cypress_mbr3108.c index 6e86e784ab443..26073fbfa7bf2 100644 --- a/drivers/input/cypress_mbr3108.c +++ b/drivers/input/cypress_mbr3108.c @@ -992,7 +992,7 @@ static void mbr3108_poll_notify(FAR struct mbr3108_dev_s *priv) struct pollfd *fds = priv->fds[i]; if (fds) { - mbr3108_dbg("Report events: %02x\n", fds->revents); + mbr3108_dbg("Report events: %08" PRIx32 "\n", fds->revents); fds->revents |= POLLIN; nxsem_post(fds->sem); diff --git a/drivers/input/djoystick.c b/drivers/input/djoystick.c index ce114fe0aa8b8..a62a411016b5e 100644 --- a/drivers/input/djoystick.c +++ b/drivers/input/djoystick.c @@ -273,7 +273,7 @@ static void djoy_sample(FAR struct djoy_upperhalf_s *priv) fds->revents |= (fds->events & POLLIN); if (fds->revents != 0) { - iinfo("Report events: %02x\n", fds->revents); + iinfo("Report events: %08" PRIx32 "\n", fds->revents); nxsem_post(fds->sem); } } @@ -632,7 +632,7 @@ static int djoy_poll(FAR struct file *filep, FAR struct pollfd *fds, fds->revents |= (fds->events & POLLIN); if (fds->revents != 0) { - iinfo("Report events: %02x\n", fds->revents); + iinfo("Report events: %08" PRIx32 "\n", fds->revents); nxsem_post(fds->sem); } } diff --git a/drivers/input/ft5x06.c b/drivers/input/ft5x06.c index 1fc3eda880975..f278bc3f9c126 100644 --- a/drivers/input/ft5x06.c +++ b/drivers/input/ft5x06.c @@ -215,7 +215,7 @@ static void ft5x06_notify(FAR struct ft5x06_dev_s *priv) if (fds) { fds->revents |= POLLIN; - iinfo("Report events: %02x\n", fds->revents); + iinfo("Report events: %08" PRIx32 "\n", fds->revents); nxsem_post(fds->sem); } } @@ -1024,7 +1024,8 @@ static int ft5x06_poll(FAR struct file *filep, FAR struct pollfd *fds, if ((fds->events & POLLIN) == 0) { - ierr("ERROR: Missing POLLIN: revents: %08x\n", fds->revents); + ierr("ERROR: Missing POLLIN: revents: %08" PRIx32 "\n", + fds->revents); ret = -EDEADLK; goto errout; } @@ -1174,7 +1175,7 @@ int ft5x06_register(FAR struct i2c_master_s *i2c, /* Register the device as an input device */ - snprintf(devname, DEV_NAMELEN, DEV_FORMAT, minor); + snprintf(devname, sizeof(devname), DEV_FORMAT, minor); iinfo("Registering %s\n", devname); ret = register_driver(devname, &ft5x06_fops, 0666, priv); diff --git a/drivers/input/max11802.c b/drivers/input/max11802.c index 579d97ae339e1..53fa899ba5c71 100644 --- a/drivers/input/max11802.c +++ b/drivers/input/max11802.c @@ -250,7 +250,7 @@ static void max11802_notify(FAR struct max11802_dev_s *priv) if (fds) { fds->revents |= POLLIN; - iinfo("Report events: %02x\n", fds->revents); + iinfo("Report events: %08" PRIx32 "\n", fds->revents); nxsem_post(fds->sem); } } @@ -1236,7 +1236,7 @@ int max11802_register(FAR struct spi_dev_s *spi, /* Register the device as an input device */ - snprintf(devname, DEV_NAMELEN, DEV_FORMAT, minor); + snprintf(devname, sizeof(devname), DEV_FORMAT, minor); iinfo("Registering %s\n", devname); ret = register_driver(devname, &max11802_fops, 0666, priv); diff --git a/drivers/input/mxt.c b/drivers/input/mxt.c index 0bd3a40dea538..d26721e0e5b00 100644 --- a/drivers/input/mxt.c +++ b/drivers/input/mxt.c @@ -598,7 +598,7 @@ static void mxt_notify(FAR struct mxt_dev_s *priv) if (fds) { fds->revents |= POLLIN; - iinfo("Report events: %02x\n", fds->revents); + iinfo("Report events: %08" PRIx32 "\n", fds->revents); nxsem_post(fds->sem); } } @@ -1569,7 +1569,8 @@ static int mxt_poll(FAR struct file *filep, FAR struct pollfd *fds, if ((fds->events & POLLIN) == 0) { - ierr("ERROR: Missing POLLIN: revents: %08x\n", fds->revents); + ierr("ERROR: Missing POLLIN: revents: %08" PRIx32 "\n", + fds->revents); ret = -EDEADLK; goto errout; } @@ -1914,7 +1915,7 @@ int mxt_register(FAR struct i2c_master_s *i2c, /* Register the device as an input device */ - snprintf(devname, DEV_NAMELEN, DEV_FORMAT, minor); + snprintf(devname, sizeof(devname), DEV_FORMAT, minor); iinfo("Registering %s\n", devname); ret = register_driver(devname, &mxt_fops, 0666, priv); diff --git a/drivers/input/nunchuck.c b/drivers/input/nunchuck.c index 4421f5939e4df..e9d23741b23da 100644 --- a/drivers/input/nunchuck.c +++ b/drivers/input/nunchuck.c @@ -97,16 +97,16 @@ static inline int nunchuck_takesem(sem_t *sem); static int nunchuck_open(FAR struct file *filep); static int nunchuck_close(FAR struct file *filep); static ssize_t nunchuck_read(FAR struct file *filep, FAR char *buffer, - size_t buflen); + size_t buflen); static int nunchuck_ioctl(FAR struct file *filep, int cmd, - unsigned long arg); + unsigned long arg); /* I2C Helpers */ static int nunchuck_i2c_read(FAR struct nunchuck_dev_s *priv, - FAR uint8_t *regval, int len); + FAR uint8_t *regval, int len); static int nunchuck_i2c_write(FAR struct nunchuck_dev_s *priv, - uint8_t const *data, int len); + uint8_t const *data, int len); static int nunchuck_sample(FAR struct nunchuck_dev_s *priv, FAR struct nunchuck_sample_s *buffer); diff --git a/drivers/input/spq10kbd.c b/drivers/input/spq10kbd.c index 6f13ba6a76e0c..cbde80cd703b2 100644 --- a/drivers/input/spq10kbd.c +++ b/drivers/input/spq10kbd.c @@ -456,7 +456,7 @@ static void spq10kbd_pollnotify(FAR struct spq10kbd_dev_s *priv) fds->revents |= (fds->events & POLLIN); if (fds->revents != 0) { - uinfo("Report events: %02x\n", fds->revents); + uinfo("Report events: %08" PRIx32 "\n", fds->revents); nxsem_post(fds->sem); } } @@ -1060,7 +1060,7 @@ int spq10kbd_register(FAR struct i2c_master_s *i2c, priv->config->enable(priv->config, true); - snprintf(kbddevname, DEV_NAMELEN, DEV_FORMAT, kbdminor); + snprintf(kbddevname, sizeof(kbddevname), DEV_FORMAT, kbdminor); iinfo("Registering %s\n", kbddevname); ret = register_driver(kbddevname, &g_hidkbd_fops, 0666, priv); diff --git a/drivers/input/stmpe811_tsc.c b/drivers/input/stmpe811_tsc.c index e48c9cb936234..ec68333632c2c 100644 --- a/drivers/input/stmpe811_tsc.c +++ b/drivers/input/stmpe811_tsc.c @@ -91,20 +91,20 @@ static void stmpe811_notify(FAR struct stmpe811_dev_s *priv); static int stmpe811_sample(FAR struct stmpe811_dev_s *priv, - FAR struct stmpe811_sample_s *sample); + FAR struct stmpe811_sample_s *sample); static inline int stmpe811_waitsample(FAR struct stmpe811_dev_s *priv, - FAR struct stmpe811_sample_s *sample); + FAR struct stmpe811_sample_s *sample); /* Character driver methods */ static int stmpe811_open(FAR struct file *filep); static int stmpe811_close(FAR struct file *filep); static ssize_t stmpe811_read(FAR struct file *filep, FAR char *buffer, - size_t len); + size_t len); static int stmpe811_ioctl(FAR struct file *filep, int cmd, - unsigned long arg); + unsigned long arg); static int stmpe811_poll(FAR struct file *filep, struct pollfd *fds, - bool setup); + bool setup); /* Initialization logic */ @@ -159,7 +159,7 @@ static void stmpe811_notify(FAR struct stmpe811_dev_s *priv) if (fds) { fds->revents |= POLLIN; - iinfo("Report events: %02x\n", fds->revents); + iinfo("Report events: %08" PRIx32 "\n", fds->revents); nxsem_post(fds->sem); } } @@ -634,7 +634,8 @@ static int stmpe811_poll(FAR struct file *filep, FAR struct pollfd *fds, if ((fds->events & POLLIN) == 0) { - ierr("ERROR: Missing POLLIN: revents: %08x\n", fds->revents); + ierr("ERROR: Missing POLLIN: revents: %08" PRIx32 "\n", + fds->revents); ret = -EDEADLK; goto errout; } @@ -885,7 +886,7 @@ int stmpe811_register(STMPE811_HANDLE handle, int minor) /* Register the character driver */ - snprintf(devname, DEV_NAMELEN, DEV_FORMAT, minor); + snprintf(devname, sizeof(devname), DEV_FORMAT, minor); ret = register_driver(devname, &g_stmpe811fops, 0666, priv); if (ret < 0) { diff --git a/drivers/input/touchscreen_upper.c b/drivers/input/touchscreen_upper.c index 6c260d905af1c..6740d24ac62d7 100644 --- a/drivers/input/touchscreen_upper.c +++ b/drivers/input/touchscreen_upper.c @@ -204,7 +204,7 @@ static int touch_close(FAR struct file *filep) ****************************************************************************/ static ssize_t touch_write(FAR struct file *filep, FAR const char *buffer, - size_t buflen) + size_t buflen) { FAR struct inode *inode = filep->f_inode; FAR struct touch_upperhalf_s *upper = inode->i_private; @@ -222,8 +222,8 @@ static ssize_t touch_write(FAR struct file *filep, FAR const char *buffer, * Name: touch_read ****************************************************************************/ -static ssize_t -touch_read(FAR struct file *filep, FAR char *buffer, size_t len) +static ssize_t touch_read(FAR struct file *filep, FAR char *buffer, + size_t len) { FAR struct touch_openpriv_s *openpriv = filep->f_priv; int ret; diff --git a/drivers/input/tsc2007.c b/drivers/input/tsc2007.c index 0a7089ad90ded..8ca4c8a3a1369 100644 --- a/drivers/input/tsc2007.c +++ b/drivers/input/tsc2007.c @@ -251,7 +251,7 @@ static void tsc2007_notify(FAR struct tsc2007_dev_s *priv) if (fds) { fds->revents |= POLLIN; - iinfo("Report events: %02x\n", fds->revents); + iinfo("Report events: %08" PRIx32 "\n", fds->revents); nxsem_post(fds->sem); } } @@ -1112,7 +1112,8 @@ static int tsc2007_poll(FAR struct file *filep, FAR struct pollfd *fds, if ((fds->events & POLLIN) == 0) { - ierr("ERROR: Missing POLLIN: revents: %08x\n", fds->revents); + ierr("ERROR: Missing POLLIN: revents: %08" PRIx32 "\n", + fds->revents); ret = -EDEADLK; goto errout; } @@ -1266,7 +1267,7 @@ int tsc2007_register(FAR struct i2c_master_s *dev, /* Register the device as an input device */ - snprintf(devname, DEV_NAMELEN, DEV_FORMAT, minor); + snprintf(devname, sizeof(devname), DEV_FORMAT, minor); iinfo("Registering %s\n", devname); ret = register_driver(devname, &tsc2007_fops, 0666, priv); diff --git a/drivers/input/uinput.c b/drivers/input/uinput.c index d298a1adbcf31..d8b84045d79c1 100644 --- a/drivers/input/uinput.c +++ b/drivers/input/uinput.c @@ -272,7 +272,7 @@ static void uinput_rpmsg_notify(FAR struct uinput_context_s *ctx, list_for_every_entry(&ctx->eptlist, ept, struct uinput_rpmsg_ept_s, node) { - if (is_rpmsg_ept_ready(&ept->ept) == 0) + if (is_rpmsg_ept_ready(&ept->ept)) { if (rpmsg_send(&ept->ept, buffer, buflen) < 0) { diff --git a/drivers/ioexpander/Kconfig b/drivers/ioexpander/Kconfig index 5c67c25313775..e7c2fa3a2fe62 100644 --- a/drivers/ioexpander/Kconfig +++ b/drivers/ioexpander/Kconfig @@ -16,6 +16,7 @@ if IOEXPANDER config IOEXPANDER_RPMSG bool "IO expander rpmsg server and client" + depends on RPTUN default n select IOEXPANDER_INT_ENABLE ---help--- diff --git a/drivers/ioexpander/gpio.c b/drivers/ioexpander/gpio.c index f7252ad77ea6d..c6313e170445b 100644 --- a/drivers/ioexpander/gpio.c +++ b/drivers/ioexpander/gpio.c @@ -44,8 +44,6 @@ ****************************************************************************/ static int gpio_handler(FAR struct gpio_dev_s *dev, uint8_t pin); -static int gpio_open(FAR struct file *filep); -static int gpio_close(FAR struct file *filep); static ssize_t gpio_read(FAR struct file *filep, FAR char *buffer, size_t buflen); static ssize_t gpio_write(FAR struct file *filep, FAR const char *buffer, @@ -60,8 +58,8 @@ static int gpio_ioctl(FAR struct file *filep, int cmd, static const struct file_operations g_gpio_drvrops = { - gpio_open, /* open */ - gpio_close, /* close */ + NULL, /* open */ + NULL, /* close */ gpio_read, /* read */ gpio_write, /* write */ gpio_seek, /* seek */ @@ -106,33 +104,6 @@ static int gpio_handler(FAR struct gpio_dev_s *dev, uint8_t pin) return OK; } -/**************************************************************************** - * Name: gpio_open - * - * Description: - * Standard character driver open method. - * - ****************************************************************************/ - -static int gpio_open(FAR struct file *filep) -{ - filep->f_pos = 0; - return OK; -} - -/**************************************************************************** - * Name: gpio_close - * - * Description: - * Standard character driver close method. - * - ****************************************************************************/ - -static int gpio_close(FAR struct file *filep) -{ - return OK; -} - /**************************************************************************** * Name: gpio_read * diff --git a/drivers/ioexpander/ioe_rpmsg.c b/drivers/ioexpander/ioe_rpmsg.c index 0f536ff9d9284..763a98630d1c1 100755 --- a/drivers/ioexpander/ioe_rpmsg.c +++ b/drivers/ioexpander/ioe_rpmsg.c @@ -237,13 +237,13 @@ static int ioe_rpmsg_wait_ready(FAR struct rpmsg_endpoint *ept) FAR struct ioe_rpmsg_client_s *priv = container_of(ept, struct ioe_rpmsg_client_s, ept); - ret = nxsem_wait_uninterruptible(&priv->sem); + ret = rpmsg_wait(ept, &priv->sem); if (ret < 0) { return ret; } - nxsem_post(&priv->sem); + rpmsg_post(ept, &priv->sem); } return ret; @@ -281,7 +281,7 @@ static int ioe_rpmsg_sendrecv(FAR struct rpmsg_endpoint *ept, return ret; } - ret = nxsem_wait_uninterruptible(&cookie.sem); + ret = rpmsg_wait(ept, &cookie.sem); if (ret < 0) { return ret; @@ -452,8 +452,9 @@ static void ioe_rpmsg_irqworker(FAR void *priv_) msg.cbfunc = cb->cbfunc; msg.cbarg = cb->cbarg; - ioe_rpmsg_sendrecv(cb->ept, IOE_RPMSG_IRQ, - (struct ioe_rpmsg_header_s *)&msg, sizeof(msg)); + msg.header.command = IOE_RPMSG_IRQ; + msg.header.response = 0; + rpmsg_send(cb->ept, &msg, sizeof(msg)); cb->pendset = 0; } @@ -550,7 +551,7 @@ static int ioe_rpmsg_ept_cb(FAR struct rpmsg_endpoint *ept, FAR void *data, if (msg->response && cookie) { cookie->result = msg->result; - nxsem_post(&cookie->sem); + rpmsg_post(ept, &cookie->sem); ret = 0; } else if (cmd < ARRAY_SIZE(g_ioe_rpmsg_handler) @@ -577,7 +578,7 @@ static void ioe_rpmsg_client_created(FAR struct rpmsg_device *rdev, rpmsg_create_ept(&priv->ept, rdev, eptname, RPMSG_ADDR_ANY, RPMSG_ADDR_ANY, ioe_rpmsg_ept_cb, NULL); - nxsem_post(&priv->sem); + rpmsg_post(&priv->ept, &priv->sem); } } @@ -588,7 +589,7 @@ static void ioe_rpmsg_client_destroy(FAR struct rpmsg_device *rdev, if (!strcmp(priv->cpuname, rpmsg_get_cpuname(rdev))) { - nxsem_wait(&priv->sem); + rpmsg_wait(&priv->ept, &priv->sem); rpmsg_destroy_ept(&priv->ept); } } diff --git a/drivers/lcd/ht16k33_14seg.c b/drivers/lcd/ht16k33_14seg.c index 375059770c19a..1a562214a4aab 100644 --- a/drivers/lcd/ht16k33_14seg.c +++ b/drivers/lcd/ht16k33_14seg.c @@ -137,8 +137,6 @@ static void ht16k33_clear_display(FAR struct ht16k33_dev_s *priv); /* Character driver methods */ -static int ht16k33_open(FAR struct file *filep); -static int ht16k33_close(FAR struct file *filep); static ssize_t ht16k33_read(FAR struct file *filep, FAR char *buffer, size_t buflen); static ssize_t ht16k33_write(FAR struct file *filep, FAR const char *buffer, @@ -146,7 +144,7 @@ static ssize_t ht16k33_write(FAR struct file *filep, FAR const char *buffer, static off_t ht16k33_seek(FAR struct file *filep, off_t offset, int whence); static int ht16k33_ioctl(FAR struct file *filep, int cmd, - unsigned long arg); + unsigned long arg); /**************************************************************************** * Private Data @@ -154,8 +152,8 @@ static int ht16k33_ioctl(FAR struct file *filep, int cmd, static const struct file_operations g_ht16k33fops = { - ht16k33_open, /* open */ - ht16k33_close, /* close */ + NULL, /* open */ + NULL, /* close */ ht16k33_read, /* read */ ht16k33_write, /* write */ ht16k33_seek, /* seek */ @@ -774,39 +772,13 @@ static void lcd_init(FAR struct ht16k33_dev_s *priv) ****************************************************************************/ static void lcd_curpos_to_fpos(FAR struct ht16k33_dev_s *priv, - uint8_t row, uint8_t col, FAR off_t *fpos) + uint8_t row, uint8_t col, FAR off_t *fpos) { /* the logical file position is the linear position plus any synthetic LF */ *fpos = (row * HT16K33_MAX_COL) + col + row; } -/**************************************************************************** - * Name: ht16k33_open - * - * Description: - * This function is called whenever the HT16K33 device is opened. - * - ****************************************************************************/ - -static int ht16k33_open(FAR struct file *filep) -{ - return OK; -} - -/**************************************************************************** - * Name: ht16k33_close - * - * Description: - * This routine is called when the LM-75 device is closed. - * - ****************************************************************************/ - -static int ht16k33_close(FAR struct file *filep) -{ - return OK; -} - /**************************************************************************** * Name: ht16k33_read ****************************************************************************/ @@ -822,7 +794,7 @@ static ssize_t ht16k33_read(FAR struct file *filep, FAR char *buffer, ****************************************************************************/ static ssize_t ht16k33_write(FAR struct file *filep, FAR const char *buffer, - size_t buflen) + size_t buflen) { FAR struct inode *inode = filep->f_inode; FAR struct ht16k33_dev_s *priv = inode->i_private; @@ -1031,7 +1003,7 @@ static off_t ht16k33_seek(FAR struct file *filep, off_t offset, int whence) ****************************************************************************/ static int ht16k33_ioctl(FAR struct file *filep, int cmd, - unsigned long arg) + unsigned long arg) { switch (cmd) { @@ -1155,7 +1127,7 @@ int ht16k33_register(int devno, FAR struct i2c_master_s *i2c) /* Create the character device name */ - snprintf(devname, DEVNAME_FMTLEN, DEVNAME_FMT, devno); + snprintf(devname, sizeof(devname), DEVNAME_FMT, devno); /* Register the driver */ diff --git a/drivers/lcd/lcd_dev.c b/drivers/lcd/lcd_dev.c index e2298966f3761..f06c53ab7fdb3 100644 --- a/drivers/lcd/lcd_dev.c +++ b/drivers/lcd/lcd_dev.c @@ -59,8 +59,6 @@ struct lcddev_dev_s /* Character driver methods */ -static int lcddev_open(FAR struct file *filep); -static int lcddev_close(FAR struct file *filep); static int lcddev_ioctl(FAR struct file *filep, int cmd, unsigned long arg); @@ -70,8 +68,8 @@ static int lcddev_ioctl(FAR struct file *filep, int cmd, static const struct file_operations lcddev_fops = { - lcddev_open, /* open */ - lcddev_close, /* close */ + NULL, /* open */ + NULL, /* close */ NULL, /* read */ NULL, /* write */ NULL, /* seek */ @@ -86,28 +84,6 @@ static const struct file_operations lcddev_fops = * Private Functions ****************************************************************************/ -/**************************************************************************** - * Name: lcddev_open - ****************************************************************************/ - -static int lcddev_open(FAR struct file *filep) -{ - /* Nothing to do */ - - return OK; -} - -/**************************************************************************** - * Name: lcddev_close - ****************************************************************************/ - -static int lcddev_close(FAR struct file *filep) -{ - /* Nothing to do */ - - return OK; -} - /**************************************************************************** * Name: lcddev_ioctl ****************************************************************************/ @@ -132,8 +108,8 @@ static int lcddev_ioctl(FAR struct file *filep, int cmd, unsigned long arg) break; case LCDDEVIO_PUTRUN: { - const FAR struct lcddev_run_s *lcd_run = - (const FAR struct lcddev_run_s *)arg; + FAR const struct lcddev_run_s *lcd_run = + (FAR const struct lcddev_run_s *)arg; ret = priv->planeinfo.putrun(lcd_run->row, lcd_run->col, lcd_run->data, lcd_run->npixels); @@ -176,8 +152,8 @@ static int lcddev_ioctl(FAR struct file *filep, int cmd, unsigned long arg) break; case LCDDEVIO_PUTAREA: { - const FAR struct lcddev_area_s *lcd_area = - (const FAR struct lcddev_area_s *)arg; + FAR const struct lcddev_area_s *lcd_area = + (FAR const struct lcddev_area_s *)arg; if (priv->planeinfo.putarea) { diff --git a/drivers/lcd/pcf8574_lcd_backpack.c b/drivers/lcd/pcf8574_lcd_backpack.c index a915483913fb5..ce589f428b596 100644 --- a/drivers/lcd/pcf8574_lcd_backpack.c +++ b/drivers/lcd/pcf8574_lcd_backpack.c @@ -105,8 +105,8 @@ static off_t pcf8574_lcd_seek(FAR struct file *filep, off_t offset, int whence); static int pcf8574_lcd_ioctl(FAR struct file *filep, int cmd, unsigned long arg); -static int pcf8574lcd_poll(FAR struct file *filep, FAR struct pollfd *fds, - bool setup); +static int pcf8574_lcd_poll(FAR struct file *filep, FAR struct pollfd *fds, + bool setup); #ifndef CONFIG_DISABLE_PSEUDOFS_OPERATIONS static int pcf8574_lcd_unlink(FAR struct inode *inode); #endif @@ -123,7 +123,7 @@ static const struct file_operations g_pcf8574_lcd_fops = pcf8574_lcd_write, /* write */ pcf8574_lcd_seek, /* seek */ pcf8574_lcd_ioctl, /* ioctl */ - pcf8574lcd_poll /* poll */ + pcf8574_lcd_poll /* poll */ #ifndef CONFIG_DISABLE_PSEUDOFS_OPERATIONS , pcf8574_lcd_unlink /* unlink */ #endif @@ -1548,11 +1548,11 @@ static int pcf8574_lcd_ioctl(FAR struct file *filep, int cmd, } /**************************************************************************** - * Name: pcf8574lcd_poll + * Name: pcf8574_lcd_poll ****************************************************************************/ -static int pcf8574lcd_poll(FAR struct file *filep, FAR struct pollfd *fds, - bool setup) +static int pcf8574_lcd_poll(FAR struct file *filep, FAR struct pollfd *fds, + bool setup) { if (setup) { diff --git a/drivers/lcd/st7032.c b/drivers/lcd/st7032.c index 42d72925dccf3..6d547d57a229d 100644 --- a/drivers/lcd/st7032.c +++ b/drivers/lcd/st7032.c @@ -94,8 +94,6 @@ static void lcd_scroll_up(FAR struct st7032_dev_s *priv); /* Character driver methods */ -static int st7032_open(FAR struct file *filep); -static int st7032_close(FAR struct file *filep); static ssize_t st7032_read(FAR struct file *filep, FAR char *buffer, size_t buflen); static ssize_t st7032_write(FAR struct file *filep, FAR const char *buffer, @@ -110,8 +108,8 @@ static int st7032_ioctl(FAR struct file *filep, int cmd, static const struct file_operations g_st7032fops = { - st7032_open, /* open */ - st7032_close, /* close */ + NULL, /* open */ + NULL, /* close */ st7032_read, /* read */ st7032_write, /* write */ st7032_seek, /* seek */ @@ -703,32 +701,6 @@ static void lcd_curpos_to_fpos(FAR struct st7032_dev_s *priv, *fpos = (row * ST7032_MAX_COL) + col + row; } -/**************************************************************************** - * Name: st7032_open - * - * Description: - * This function is called whenever the ST7032 device is opened. - * - ****************************************************************************/ - -static int st7032_open(FAR struct file *filep) -{ - return OK; -} - -/**************************************************************************** - * Name: st7032_close - * - * Description: - * This routine is called when the LM-75 device is closed. - * - ****************************************************************************/ - -static int st7032_close(FAR struct file *filep) -{ - return OK; -} - /**************************************************************************** * Name: st7032_read ****************************************************************************/ diff --git a/drivers/leds/apa102.c b/drivers/leds/apa102.c index 41acd59514ee7..0683dcfa58b1c 100644 --- a/drivers/leds/apa102.c +++ b/drivers/leds/apa102.c @@ -60,8 +60,6 @@ static inline void apa102_write32(FAR struct apa102_dev_s *priv, /* Character driver methods */ -static int apa102_open(FAR struct file *filep); -static int apa102_close(FAR struct file *filep); static ssize_t apa102_read(FAR struct file *filep, FAR char *buffer, size_t buflen); static ssize_t apa102_write(FAR struct file *filep, FAR const char *buffer, @@ -73,8 +71,8 @@ static ssize_t apa102_write(FAR struct file *filep, FAR const char *buffer, static const struct file_operations g_apa102fops = { - apa102_open, /* open */ - apa102_close, /* close */ + NULL, /* open */ + NULL, /* close */ apa102_read, /* read */ apa102_write, /* write */ NULL, /* seek */ @@ -138,32 +136,6 @@ static inline void apa102_write32(FAR struct apa102_dev_s *priv, SPI_LOCK(priv->spi, false); } -/**************************************************************************** - * Name: apa102_open - * - * Description: - * This function is called whenever the APA102 device is opened. - * - ****************************************************************************/ - -static int apa102_open(FAR struct file *filep) -{ - return OK; -} - -/**************************************************************************** - * Name: apa102_close - * - * Description: - * This routine is called when the APA102 device is closed. - * - ****************************************************************************/ - -static int apa102_close(FAR struct file *filep) -{ - return OK; -} - /**************************************************************************** * Name: apa102_read ****************************************************************************/ @@ -179,7 +151,7 @@ static ssize_t apa102_read(FAR struct file *filep, FAR char *buffer, ****************************************************************************/ static ssize_t apa102_write(FAR struct file *filep, FAR const char *buffer, - size_t buflen) + size_t buflen) { FAR struct inode *inode = filep->f_inode; FAR struct apa102_dev_s *priv = inode->i_private; diff --git a/drivers/leds/max7219.c b/drivers/leds/max7219.c index 2a5ed6035d5d0..b6a88f990a99c 100644 --- a/drivers/leds/max7219.c +++ b/drivers/leds/max7219.c @@ -70,12 +70,10 @@ static inline void max7219_write16(FAR struct max7219_dev_s *priv, /* Character driver methods */ -static int max7219_open(FAR struct file *filep); -static int max7219_close(FAR struct file *filep); static ssize_t max7219_read(FAR struct file *filep, FAR char *buffer, size_t buflen); static ssize_t max7219_write(FAR struct file *filep, FAR const char *buffer, - size_t buflen); + size_t buflen); /**************************************************************************** * Private Data @@ -83,8 +81,8 @@ static ssize_t max7219_write(FAR struct file *filep, FAR const char *buffer, static const struct file_operations g_max7219fops = { - max7219_open, /* open */ - max7219_close, /* close */ + NULL, /* open */ + NULL, /* close */ max7219_read, /* read */ max7219_write, /* write */ NULL, /* seek */ @@ -153,32 +151,6 @@ static inline void max7219_write16(FAR struct max7219_dev_s *priv, SPI_LOCK(priv->spi, false); } -/**************************************************************************** - * Name: max7219_open - * - * Description: - * This function is called whenever the MAX7219 device is opened. - * - ****************************************************************************/ - -static int max7219_open(FAR struct file *filep) -{ - return OK; -} - -/**************************************************************************** - * Name: max7219_close - * - * Description: - * This routine is called when the LM-75 device is closed. - * - ****************************************************************************/ - -static int max7219_close(FAR struct file *filep) -{ - return OK; -} - /**************************************************************************** * Name: max7219_read ****************************************************************************/ @@ -194,7 +166,7 @@ static ssize_t max7219_read(FAR struct file *filep, ****************************************************************************/ static ssize_t max7219_write(FAR struct file *filep, FAR const char *buffer, - size_t buflen) + size_t buflen) { FAR struct inode *inode = filep->f_inode; FAR struct max7219_dev_s *priv = inode->i_private; diff --git a/drivers/leds/ncp5623c.c b/drivers/leds/ncp5623c.c index 794aa3070b0fc..3fd16fc82ca9b 100644 --- a/drivers/leds/ncp5623c.c +++ b/drivers/leds/ncp5623c.c @@ -1,35 +1,20 @@ /**************************************************************************** * drivers/leds/ncp5623c.c - * based on drivers/leds/pca9635pw.c * - * Author: Konstantin Berzenko + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: + * http://www.apache.org/licenses/LICENSE-2.0 * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * 3. Neither the name NuttX nor the names of its contributors may be - * used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. * ****************************************************************************/ diff --git a/drivers/leds/ws2812.c b/drivers/leds/ws2812.c index 2e581321f7163..b80b1a7fa80ea 100644 --- a/drivers/leds/ws2812.c +++ b/drivers/leds/ws2812.c @@ -111,8 +111,6 @@ static void ws2812_pack(FAR uint8_t *buf, uint32_t rgb); /* Character driver methods */ -static int ws2812_open(FAR struct file *filep); -static int ws2812_close(FAR struct file *filep); static ssize_t ws2812_read(FAR struct file *filep, FAR char *buffer, size_t buflen); static ssize_t ws2812_write(FAR struct file *filep, FAR const char *buffer, @@ -125,8 +123,8 @@ static off_t ws2812_seek(FAR struct file *filep, off_t offset, int whence); static const struct file_operations g_ws2812fops = { - ws2812_open, /* open */ - ws2812_close, /* close */ + NULL, /* open */ + NULL, /* close */ ws2812_read, /* read */ ws2812_write, /* write */ ws2812_seek, /* seek */ @@ -206,32 +204,6 @@ static void ws2812_pack(FAR uint8_t *buf, uint32_t rgb) } } -/**************************************************************************** - * Name: ws2812_open - * - * Description: - * This function is called whenever the WS2812 device is opened. - * - ****************************************************************************/ - -static int ws2812_open(FAR struct file *filep) -{ - return OK; -} - -/**************************************************************************** - * Name: ws2812_close - * - * Description: - * This routine is called when the WS2812 device is closed. - * - ****************************************************************************/ - -static int ws2812_close(FAR struct file *filep) -{ - return OK; -} - /**************************************************************************** * Name: ws2812_read ****************************************************************************/ diff --git a/drivers/math/cordic.c b/drivers/math/cordic.c index 08943034ac2f9..628a2573769e4 100644 --- a/drivers/math/cordic.c +++ b/drivers/math/cordic.c @@ -60,8 +60,6 @@ struct cordic_upperhalf_s * Private Function Prototypes ****************************************************************************/ -static int cordic_open(FAR struct file *filep); -static int cordic_close(FAR struct file *filep); static ssize_t cordic_read(FAR struct file *filep, FAR char *buffer, size_t buflen); static ssize_t cordic_write(FAR struct file *filep, FAR const char *buffer, @@ -75,8 +73,8 @@ static int cordic_ioctl(FAR struct file *filep, int cmd, static const struct file_operations g_cordicops = { - cordic_open, /* open */ - cordic_close, /* close */ + NULL, /* open */ + NULL, /* close */ cordic_read, /* read */ cordic_write, /* write */ NULL, /* seek */ @@ -91,32 +89,6 @@ static const struct file_operations g_cordicops = * Private Functions ****************************************************************************/ -/**************************************************************************** - * Name: cordic_open - * - * Description: - * This function is called whenever the cordic timer device is opened. - * - ****************************************************************************/ - -static int cordic_open(FAR struct file *filep) -{ - return OK; -} - -/**************************************************************************** - * Name: cordic_close - * - * Description: - * This function is called when the cordic timer device is closed. - * - ****************************************************************************/ - -static int cordic_close(FAR struct file *filep) -{ - return OK; -} - /**************************************************************************** * Name: cordic_read * diff --git a/drivers/misc/lwl_console.c b/drivers/misc/lwl_console.c index 0a950fc08bf01..37308c692deb8 100644 --- a/drivers/misc/lwl_console.c +++ b/drivers/misc/lwl_console.c @@ -110,8 +110,6 @@ static ssize_t lwlconsole_read(FAR struct file *filep, FAR char *buffer, size_t buflen); static ssize_t lwlconsole_write(FAR struct file *filep, FAR const char *buffer, size_t buflen); -static int lwlconsole_ioctl(FAR struct file *filep, int cmd, - unsigned long arg); /**************************************************************************** * Private Data @@ -131,15 +129,15 @@ static struct lwl_entry_s g_d = static const struct file_operations g_consoleops = { - NULL, /* open */ - NULL, /* close */ - lwlconsole_read, /* read */ - lwlconsole_write, /* write */ - NULL, /* seek */ - lwlconsole_ioctl, /* ioctl */ - NULL /* poll */ + NULL, /* open */ + NULL, /* close */ + lwlconsole_read, /* read */ + lwlconsole_write, /* write */ + NULL, /* seek */ + NULL, /* ioctl */ + NULL /* poll */ #ifndef CONFIG_DISABLE_PSEUDOFS_OPERATIONS - , NULL /* unlink */ + , NULL /* unlink */ #endif }; @@ -227,16 +225,6 @@ static bool read8bits(uint8_t port, FAR uint8_t *store) return true; } -/**************************************************************************** - * Name: lwlconsole_ioctl - ****************************************************************************/ - -static int lwlconsole_ioctl(FAR struct file *filep, int cmd, - unsigned long arg) -{ - return -ENOTTY; -} - /**************************************************************************** * Name: lwlconsole_read ****************************************************************************/ diff --git a/drivers/mmcsd/mmcsd_sdio.c b/drivers/mmcsd/mmcsd_sdio.c index d0fa5c4ccf47f..c41877a80fc5e 100644 --- a/drivers/mmcsd/mmcsd_sdio.c +++ b/drivers/mmcsd/mmcsd_sdio.c @@ -145,10 +145,7 @@ struct mmcsd_state_s /* Misc Helpers *************************************************************/ static int mmcsd_takesem(FAR struct mmcsd_state_s *priv); - -#ifndef CONFIG_SDIO_MUXBUS -# define mmcsd_givesem(p) nxsem_post(&priv->sem); -#endif +static void mmcsd_givesem(FAR struct mmcsd_state_s *priv); /* Command/response helpers *************************************************/ @@ -259,35 +256,45 @@ static int mmcsd_takesem(FAR struct mmcsd_state_s *priv) * waiting) */ - ret = nxsem_wait_uninterruptible(&priv->sem); - if (ret < 0) + if (!up_interrupt_context() && !sched_idletask()) { - return ret; - } + ret = nxsem_wait_uninterruptible(&priv->sem); + if (ret < 0) + { + return ret; + } - /* Lock the bus if mutually exclusive access to the SDIO bus is required - * on this platform. - */ + /* Lock the bus if mutually exclusive access to the + * SDIO bus is required on this platform. + */ #ifdef CONFIG_SDIO_MUXBUS - SDIO_LOCK(priv->dev, TRUE); + SDIO_LOCK(priv->dev, TRUE); #endif + } + else + { + ret = OK; + } return ret; } -#ifdef CONFIG_SDIO_MUXBUS static void mmcsd_givesem(FAR struct mmcsd_state_s *priv) { - /* Release the SDIO bus lock, then the MMC/SD driver semaphore in the - * opposite order that they were taken to assure that no deadlock - * conditions will arise. - */ + if (!up_interrupt_context() && !sched_idletask()) + { + /* Release the SDIO bus lock, then the MMC/SD driver semaphore in the + * opposite order that they were taken to assure that no deadlock + * conditions will arise. + */ - SDIO_LOCK(priv->dev, FALSE); - nxsem_post(&priv->sem); -} +#ifdef CONFIG_SDIO_MUXBUS + SDIO_LOCK(priv->dev, FALSE); #endif + nxsem_post(&priv->sem); + } +} /**************************************************************************** * Command/Response Helpers @@ -2758,6 +2765,8 @@ static int mmcsd_read_csd(FAR struct mmcsd_state_s *priv) finfo("MMC ext CSD read succsesfully, number of block %" PRId32 "\n", priv->nblocks); + SDIO_GOTEXTCSD(priv->dev, buffer); + /* Return value: One sector read */ return OK; @@ -2881,6 +2890,22 @@ static int mmcsd_sdinitialize(FAR struct mmcsd_state_s *priv) SDIO_CLOCK(priv->dev, CLOCK_SD_TRANSFER_1BIT); nxsig_usleep(MMCSD_CLK_DELAY); + /* If the hardware only supports 4-bit transfer mode then we forced to + * attempt to setup the card in this mode before checking the SCR register. + */ + + if ((priv->caps & SDIO_CAPS_4BIT_ONLY) != 0) + { + /* Select width (4-bit) bus operation */ + + priv->buswidth = 4; + ret = mmcsd_widebus(priv); + if (ret != OK) + { + ferr("ERROR: Failed to set wide bus operation: %d\n", ret); + } + } + /* Get the SD card Configuration Register (SCR). We need this now because * that configuration register contains the indication whether or not * this card supports wide bus operation. @@ -2895,12 +2920,15 @@ static int mmcsd_sdinitialize(FAR struct mmcsd_state_s *priv) mmcsd_decode_scr(priv, scr); - /* Select width (4-bit) bus operation (if the card supports it) */ - - ret = mmcsd_widebus(priv); - if (ret != OK) + if ((priv->caps & SDIO_CAPS_4BIT_ONLY) == 0) { - ferr("ERROR: Failed to set wide bus operation: %d\n", ret); + /* Select width (4-bit) bus operation (if the card supports it) */ + + ret = mmcsd_widebus(priv); + if (ret != OK) + { + ferr("ERROR: Failed to set wide bus operation: %d\n", ret); + } } /* TODO: If wide-bus selected, then send CMD6 to see if the card supports @@ -3245,6 +3273,7 @@ static int mmcsd_cardidentify(FAR struct mmcsd_state_s *priv) if (elapsed >= TICK_PER_SEC || priv->type == MMCSD_CARDTYPE_UNKNOWN) { + priv->type = MMCSD_CARDTYPE_UNKNOWN; ferr("ERROR: Failed to identify card\n"); return -EIO; } diff --git a/drivers/modem/altair/altmdm.c b/drivers/modem/altair/altmdm.c index 84ecf26683792..d0dc862a308c3 100644 --- a/drivers/modem/altair/altmdm.c +++ b/drivers/modem/altair/altmdm.c @@ -42,8 +42,6 @@ /* Character driver methods. */ -static int altmdm_open(FAR struct file *filep); -static int altmdm_close(FAR struct file *filep); static ssize_t altmdm_read(FAR struct file *filep, FAR char *buffer, size_t len); static ssize_t altmdm_write(FAR struct file *filep, FAR const char *buffer, @@ -58,15 +56,15 @@ static int altmdm_ioctl(FAR struct file *filep, int cmd, unsigned long arg); static const struct file_operations g_altmdmfops = { - altmdm_open, /* open */ - altmdm_close, /* close */ - altmdm_read, /* read */ - altmdm_write, /* write */ - NULL, /* seek */ - altmdm_ioctl, /* ioctl */ - NULL /* poll */ + NULL, /* open */ + NULL, /* close */ + altmdm_read, /* read */ + altmdm_write, /* write */ + NULL, /* seek */ + altmdm_ioctl, /* ioctl */ + NULL /* poll */ #ifndef CONFIG_DISABLE_PSEUDOFS_OPERATIONS - , NULL /* unlink */ + , NULL /* unlink */ #endif }; @@ -147,32 +145,6 @@ static int altmdm_uninitialize(FAR struct altmdm_dev_s *priv) return ret; } -/**************************************************************************** - * Name: altmdm_open - * - * Description: - * Standard character driver open method. - * - ****************************************************************************/ - -static int altmdm_open(FAR struct file *filep) -{ - return OK; -} - -/**************************************************************************** - * Name: altmdm_close - * - * Description: - * Standard character driver close method. - * - ****************************************************************************/ - -static int altmdm_close(FAR struct file *filep) -{ - return OK; -} - /**************************************************************************** * Name: altmdm_read * diff --git a/drivers/mtd/at24xx.c b/drivers/mtd/at24xx.c index 68d8538d9a3de..2b37cea6461ca 100644 --- a/drivers/mtd/at24xx.c +++ b/drivers/mtd/at24xx.c @@ -1,18 +1,8 @@ /**************************************************************************** * drivers/mtd/at24xx.c - * Driver for I2C-based at24cxx EEPROM - * (at24c32,at24c64,at24c128,at24c256,at24c512) * * Copyright (C) 2011 Li Zhuoyi. All rights reserved. - * Author: Li Zhuoyi - * * Copyright (C) 2013, 2016 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt - * - * Derived from drivers/mtd/m25px.c - * - * Copyright (C) 2009-2011, 2013 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/drivers/mtd/gd5f.c b/drivers/mtd/gd5f.c index 7aa5d75dfc8e8..746269b83fb27 100644 --- a/drivers/mtd/gd5f.c +++ b/drivers/mtd/gd5f.c @@ -1,36 +1,20 @@ /**************************************************************************** * drivers/mtd/gd5f.c - * Driver for GigaDevice SPI nand flash. * - * Copyright (C) 2019 FishSemi Inc. All rights reserved. - * Author: zhuyanlin + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: + * http://www.apache.org/licenses/LICENSE-2.0 * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * 3. Neither the name NuttX nor the names of its contributors may be - * used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. * ****************************************************************************/ diff --git a/drivers/mtd/mtd_config.c b/drivers/mtd/mtd_config.c index 7a597dc9ecf76..6cf2218b1ccc1 100644 --- a/drivers/mtd/mtd_config.c +++ b/drivers/mtd/mtd_config.c @@ -1496,6 +1496,149 @@ static int mtdconfig_deleteconfig(FAR struct mtdconfig_struct_s *dev, return ret; } +/**************************************************************************** + * Name: mtdconfig_firstconfig + ****************************************************************************/ + +static int mtdconfig_firstconfig(FAR struct mtdconfig_struct_s *dev, + FAR struct config_data_s *pdata) +{ + int ret = -ENOENT; + off_t bytes_to_read; + struct mtdconfig_header_s hdr; + + /* Allocate a temp block buffer */ + + dev->buffer = (FAR uint8_t *)kmm_malloc(dev->blocksize); + if (dev->buffer == NULL) + { + return -ENOMEM; + } + + dev->readoff = mtdconfig_findfirstentry(dev, &hdr); + + /* Test if the config item is valid */ + +#ifdef CONFIG_MTD_CONFIG_NAMED + if (dev->readoff != 0 && + hdr.name[0] != CONFIG_MTD_CONFIG_ERASEDVALUE) +#else + if (dev->readoff != 0 && hdr.id != MTD_ERASED_ID) +#endif + { + /* Perform the read */ + + bytes_to_read = hdr.len; + if (bytes_to_read > pdata->len) + { + bytes_to_read = pdata->len; + } + + ret = mtdconfig_readbytes(dev, dev->readoff + sizeof(hdr), + pdata->configdata, bytes_to_read); + if (ret < 0) + { + goto errout; + } + + /* Set other return data items */ + +#ifdef CONFIG_MTD_CONFIG_NAMED + strcpy(pdata->name, hdr.name); +#else + pdata->id = hdr.id; + pdata->instance = hdr.instance; +#endif + pdata->len = bytes_to_read; + } + else + { + ret = -ENOENT; + } + +errout: + + /* Free the buffer */ + + kmm_free(dev->buffer); + return ret; +} + +/**************************************************************************** + * Name: mtdconfig_nextconfig + ****************************************************************************/ + +static int mtdconfig_nextconfig(FAR struct mtdconfig_struct_s *dev, + FAR struct config_data_s *pdata) +{ + int ret = -ENOENT; + off_t bytes_to_read; + struct mtdconfig_header_s hdr; + + /* Allocate a temp block buffer */ + + dev->buffer = (FAR uint8_t *)kmm_malloc(dev->blocksize); + if (dev->buffer == NULL) + { + return -ENOMEM; + } + + ret = mtdconfig_readbytes(dev, dev->readoff, (FAR uint8_t *)&hdr, + sizeof(hdr)); + if (ret < 0) + { + goto errout; + } + + dev->readoff = mtdconfig_findnextentry(dev, dev->readoff, &hdr, 0); + + /* Test if the config item is valid */ + +#ifdef CONFIG_MTD_CONFIG_NAMED + if (dev->readoff != 0 && + hdr.name[0] != CONFIG_MTD_CONFIG_ERASEDVALUE) +#else + if (dev->readoff != 0 && hdr.id != MTD_ERASED_ID) +#endif + { + /* Test if this is an empty slot */ + + bytes_to_read = hdr.len; + if (bytes_to_read > pdata->len) + { + bytes_to_read = pdata->len; + } + + /* Read the config item data */ + + ret = mtdconfig_readbytes(dev, dev->readoff + sizeof(hdr), + pdata->configdata, bytes_to_read); + if (ret < 0) + { + goto errout; + } + +#ifdef CONFIG_MTD_CONFIG_NAMED + strcpy(pdata->name, hdr.name); +#else + pdata->id = hdr.id; + pdata->instance = hdr.instance; +#endif + pdata->len = bytes_to_read; + } + else + { + ret = -ENOENT; + } + +errout: + + /* Free the buffer */ + + kmm_free(dev->buffer); + return ret; +} + /**************************************************************************** * Name: mtdconfig_ioctl ****************************************************************************/ @@ -1506,8 +1649,6 @@ static int mtdconfig_ioctl(FAR struct file *filep, int cmd, FAR struct inode *inode = filep->f_inode; FAR struct mtdconfig_struct_s *dev = inode->i_private; FAR struct config_data_s *pdata; - struct mtdconfig_header_s hdr; - off_t bytes_to_read; int ret = -ENOTTY; switch (cmd) @@ -1541,47 +1682,7 @@ static int mtdconfig_ioctl(FAR struct file *filep, int cmd, /* Get the the first config item */ pdata = (FAR struct config_data_s *)arg; - dev->readoff = mtdconfig_findfirstentry(dev, &hdr); - - /* Test if the config item is valid */ - -#ifdef CONFIG_MTD_CONFIG_NAMED - if (dev->readoff != 0 && - hdr.name[0] != CONFIG_MTD_CONFIG_ERASEDVALUE) -#else - if (dev->readoff != 0 && hdr.id != MTD_ERASED_ID) -#endif - { - /* Perform the read */ - - bytes_to_read = hdr.len; - if (bytes_to_read > pdata->len) - { - bytes_to_read = pdata->len; - } - - ret = mtdconfig_readbytes(dev, dev->readoff + sizeof(hdr), - pdata->configdata, bytes_to_read); - if (ret < 0) - { - break; - } - - /* Set other return data items */ - -#ifdef CONFIG_MTD_CONFIG_NAMED - strcpy(pdata->name, hdr.name); -#else - pdata->id = hdr.id; - pdata->instance = hdr.instance; -#endif - pdata->len = bytes_to_read; - } - else - { - ret = -ENOENT; - } - + ret = mtdconfig_firstconfig(dev, pdata); break; case CFGDIOC_NEXTCONFIG: @@ -1589,55 +1690,7 @@ static int mtdconfig_ioctl(FAR struct file *filep, int cmd, /* Get the next config item */ pdata = (FAR struct config_data_s *)arg; - - ret = mtdconfig_readbytes(dev, dev->readoff, (FAR uint8_t *)&hdr, - sizeof(hdr)); - if (ret < 0) - { - break; - } - - dev->readoff = mtdconfig_findnextentry(dev, dev->readoff, &hdr, 0); - - /* Test if the config item is valid */ - -#ifdef CONFIG_MTD_CONFIG_NAMED - if (dev->readoff != 0 && - hdr.name[0] != CONFIG_MTD_CONFIG_ERASEDVALUE) -#else - if (dev->readoff != 0 && hdr.id != MTD_ERASED_ID) -#endif - { - /* Test if this is an empty slot */ - - bytes_to_read = hdr.len; - if (bytes_to_read > pdata->len) - { - bytes_to_read = pdata->len; - } - - /* Read the config item data */ - - ret = mtdconfig_readbytes(dev, dev->readoff + sizeof(hdr), - pdata->configdata, bytes_to_read); - if (ret < 0) - { - break; - } - -#ifdef CONFIG_MTD_CONFIG_NAMED - strcpy(pdata->name, hdr.name); -#else - pdata->id = hdr.id; - pdata->instance = hdr.instance; -#endif - pdata->len = bytes_to_read; - } - else - { - ret = -ENOENT; - } - + ret = mtdconfig_nextconfig(dev, pdata); break; case MTDIOC_BULKERASE: diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig index 11fc3dcb7a950..26899f2522ead 100644 --- a/drivers/net/Kconfig +++ b/drivers/net/Kconfig @@ -25,7 +25,7 @@ comment "General Ethernet MAC Driver Options" config NET_RPMSG_DRV bool "RPMSG net driver" - depends on NET && OPENAMP + depends on RPTUN select ARCH_HAVE_NETDEV_STATISTICS ---help--- Use the rpmsg as net device, transfer packet between remoteproc. diff --git a/drivers/net/tun.c b/drivers/net/tun.c index 61ad6696d0e7e..f9c9150111aba 100644 --- a/drivers/net/tun.c +++ b/drivers/net/tun.c @@ -212,7 +212,6 @@ static void tun_dev_uninit(FAR struct tun_device_s *priv); /* File interface */ -static int tun_open(FAR struct file *filep); static int tun_close(FAR struct file *filep); static ssize_t tun_read(FAR struct file *filep, FAR char *buffer, size_t buflen); @@ -231,7 +230,7 @@ static struct tun_device_s g_tun_devices[CONFIG_TUN_NINTERFACES]; static const struct file_operations g_tun_file_ops = { - tun_open, /* open */ + NULL, /* open */ tun_close, /* close */ tun_read, /* read */ tun_write, /* write */ @@ -1151,16 +1150,6 @@ static void tun_dev_uninit(FAR struct tun_device_s *priv) nxsem_destroy(&priv->write_wait_sem); } -/**************************************************************************** - * Name: tun_open - ****************************************************************************/ - -static int tun_open(FAR struct file *filep) -{ - filep->f_priv = 0; - return OK; -} - /**************************************************************************** * Name: tun_close ****************************************************************************/ diff --git a/drivers/pipes/pipe_common.c b/drivers/pipes/pipe_common.c index ce9f23e89d0f5..9974dc3723596 100644 --- a/drivers/pipes/pipe_common.c +++ b/drivers/pipes/pipe_common.c @@ -104,7 +104,7 @@ static void pipecommon_pollnotify(FAR struct pipe_dev_s *dev, if (fds->revents != 0) { - finfo("Report events: %02x\n", fds->revents); + finfo("Report events: %08" PRIx32 "\n", fds->revents); nxsem_post(fds->sem); } } @@ -144,7 +144,7 @@ FAR struct pipe_dev_s *pipecommon_allocdev(size_t bufsize) nxsem_set_protocol(&dev->d_rdsem, SEM_PRIO_NONE); nxsem_set_protocol(&dev->d_wrsem, SEM_PRIO_NONE); - dev->d_bufsize = bufsize; + dev->d_bufsize = bufsize + 1; /* +1 to compensate the full indicator */ } return dev; diff --git a/drivers/power/Kconfig b/drivers/power/Kconfig index 77e56db784609..c944ef9e40507 100644 --- a/drivers/power/Kconfig +++ b/drivers/power/Kconfig @@ -337,7 +337,7 @@ config REGULATOR config REGULATOR_RPMSG bool "Regulator rpmsg driver support" - depends on OPENAMP + depends on RPTUN default n ---help--- The rpmsg regulator driver implements the common regulator APIs, inside which diff --git a/drivers/power/Make.defs b/drivers/power/Make.defs index e0125473321dc..7c1ecb0f430ae 100644 --- a/drivers/power/Make.defs +++ b/drivers/power/Make.defs @@ -23,7 +23,7 @@ ifeq ($(CONFIG_PM),y) CSRCS += pm_initialize.c pm_activity.c pm_changestate.c pm_checkstate.c -CSRCS += pm_register.c pm_unregister.c pm_autoupdate.c pm_governor.c +CSRCS += pm_register.c pm_unregister.c pm_autoupdate.c pm_governor.c pm_lock.c # Governor implementations diff --git a/drivers/power/activity_governor.c b/drivers/power/activity_governor.c index 05b40463c57c5..c124e52b9b1c1 100644 --- a/drivers/power/activity_governor.c +++ b/drivers/power/activity_governor.c @@ -188,7 +188,7 @@ struct pm_activity_governor_s g_pm_activity_governor = #endif }; -static struct pm_governor_s g_pmgovernor = +static const struct pm_governor_s g_pmgovernor = { governor_initialize, /* initialize */ NULL, /* deinitialize */ @@ -235,7 +235,7 @@ static void governor_activity(int domain, int count) { /* Add the activity count to the accumulated counts. */ - flags = enter_critical_section(); + flags = pm_lock(); accum = (uint32_t)pdomstate->accum + count; /* Make sure that we do not overflow the underlying representation */ @@ -275,7 +275,7 @@ static void governor_activity(int domain, int count) governor_update(domain, tmp); } - leave_critical_section(flags); + pm_unlock(flags); } } @@ -476,7 +476,7 @@ static enum pm_state_e governor_checkstate(int domain) * logic in governor_activity(). */ - flags = enter_critical_section(); + flags = pm_lock(); /* Check the elapsed time. In periods of low activity, time slicing is * controlled by IDLE loop polling; in periods of higher activity, time @@ -515,7 +515,7 @@ static enum pm_state_e governor_checkstate(int domain) } } - leave_critical_section(flags); + pm_unlock(flags); return pdomstate->recommended; } @@ -594,7 +594,7 @@ static void governor_timer(int domain) * Public Functions ****************************************************************************/ -FAR struct pm_governor_s *pm_activity_governor_initialize(void) +FAR const struct pm_governor_s *pm_activity_governor_initialize(void) { return &g_pmgovernor; } diff --git a/drivers/power/activity_governor.h b/drivers/power/activity_governor.h deleted file mode 100644 index b997834b92c88..0000000000000 --- a/drivers/power/activity_governor.h +++ /dev/null @@ -1,190 +0,0 @@ -/**************************************************************************** - * drivers/power/activity_governor.h - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. The - * ASF licenses this file to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance with the - * License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - ****************************************************************************/ - -#ifndef __DRIVERS_POWER_ACTIVITY_GOVERNER_H -#define __DRIVERS_POWER_ACTIVITY_GOVERNER_H - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include -#include - -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -/* CONFIG_PM_GOVERNOR_SLICEMS. The activity based governor collects activity - * counts in time slices. At the end of the time slice, the count - * accumulated during that interval is applied to an averaging algorithm to - * determine the activity level. - * - * CONFIG_PM_GOVERNOR_SLICEMS provides the duration of that time slice in - * milliseconds. Default: 100 Milliseconds - */ - -#ifndef CONFIG_PM_GOVERNOR_SLICEMS -# define CONFIG_PM_GOVERNOR_SLICEMS 100 /* Default is 100 msec */ -#endif - -#if CONFIG_PM_GOVERNOR_SLICEMS < 1 -# error CONFIG_PM_GOVERNOR_SLICEMS invalid -#endif - -/* The averaging algorithm is simply: Y = (An*X + SUM(Ai*Yi))/SUM(Aj), where - * i = 1..n-1 and j= 1..n, n is the length of the "memory", Ai is the - * weight applied to each value, and X is the current activity. These - * weights may be negative and a limited to the range of int16_t. - * - * CONFIG_PM_GOVERNOR_MEMORY: - * provides the memory for the algorithm. Default: 2 - * CONFIG_PM_GOVERNOR_COEFn: - * provides weight for each sample. Default: 1 - * - * Setting CONFIG_PM_GOVERNOR_MEMORY=1 disables all smoothing. - */ - -#ifndef CONFIG_PM_GOVERNOR_MEMORY -# define CONFIG_PM_GOVERNOR_MEMORY 2 -#endif - -#if CONFIG_PM_GOVERNOR_MEMORY < 1 -# error "CONFIG_PM_GOVERNOR_MEMORY must be >= 1" -#endif - -#ifndef CONFIG_PM_GOVERNOR_COEFN -# define CONFIG_PM_GOVERNOR_COEFN 1 -#endif - -#if CONFIG_PM_GOVERNOR_MEMORY > 1 && !defined(CONFIG_PM_GOVERNOR_COEF1) -# define CONFIG_PM_GOVERNOR_COEF1 1 -#endif - -#if CONFIG_PM_GOVERNOR_MEMORY > 2 && !defined(CONFIG_PM_GOVERNOR_COEF2) -# define CONFIG_PM_GOVERNOR_COEF2 1 -#endif - -#if CONFIG_PM_GOVERNOR_MEMORY > 3 && !defined(CONFIG_PM_GOVERNOR_COEF3) -# define CONFIG_PM_GOVERNOR_COEF3 1 -#endif - -#if CONFIG_PM_GOVERNOR_MEMORY > 4 && !defined(CONFIG_PM_GOVERNOR_COEF4) -# define CONFIG_PM_GOVERNOR_COEF4 1 -#endif - -#if CONFIG_PM_GOVERNOR_MEMORY > 5 && !defined(CONFIG_PM_GOVERNOR_COEF5) -# define CONFIG_PM_GOVERNOR_COEF5 1 -#endif - -#if CONFIG_PM_GOVERNOR_MEMORY > 6 -# warning "This logic needs to be extended" -#endif - -/* State changes then occur when the weight activity account crosses - * threshold values for certain periods of time (time slice count). - * - * CONFIG_PM_GOVERNOR_xxxENTER_THRESH is the threshold value for entering - * state xxx. - * CONFIG_PM_GOVERNOR_xxxENTER_COUNT is the count for entering state xxx. - * - * Resuming to normal state, on the other hand, is usually immediate and - * controlled by wakeup conditions established by the platform. The PM - * module only recommends reduced power states. - */ - -#ifndef CONFIG_PM_GOVERNOR_IDLEENTER_THRESH -# define CONFIG_PM_GOVERNOR_IDLEENTER_THRESH 1 /* <=1: Essentially no activity */ -#endif - -#ifndef CONFIG_PM_GOVERNOR_IDLEEXIT_THRESH -# define CONFIG_PM_GOVERNOR_IDLEEXIT_THRESH 2 /* >=2: Active */ -#endif - -#if CONFIG_PM_GOVERNOR_IDLEENTER_THRESH >= CONFIG_PM_GOVERNOR_IDLEEXIT_THRESH -# error "Must have CONFIG_PM_GOVERNOR_IDLEENTER_THRESH < CONFIG_PM_GOVERNOR_IDLEEXIT_THRESH" -#endif - -#ifndef CONFIG_PM_GOVERNOR_IDLEENTER_COUNT -# define CONFIG_PM_GOVERNOR_IDLEENTER_COUNT 30 /* Thirty IDLE slices to enter - * IDLE mode from normal - */ -#endif - -#ifndef CONFIG_PM_GOVERNOR_STANDBYENTER_THRESH -# define CONFIG_PM_GOVERNOR_STANDBYENTER_THRESH 1 /* <=1: Essentially no activity */ -#endif - -#ifndef CONFIG_PM_GOVERNOR_STANDBYEXIT_THRESH -# define CONFIG_PM_GOVERNOR_STANDBYEXIT_THRESH 2 /* >=2: Active */ -#endif - -#if CONFIG_PM_GOVERNOR_STANDBYENTER_THRESH >= CONFIG_PM_GOVERNOR_STANDBYEXIT_THRESH -# error "Must have CONFIG_PM_GOVERNOR_STANDBYENTER_THRESH < CONFIG_PM_GOVERNOR_STANDBYEXIT_THRESH" -#endif - -#ifndef CONFIG_PM_GOVERNOR_STANDBYENTER_COUNT -# define CONFIG_PM_GOVERNOR_STANDBYENTER_COUNT 50 /* Fifty IDLE slices to enter - * STANDBY mode from IDLE - */ -#endif - -#ifndef CONFIG_PM_GOVERNOR_SLEEPENTER_THRESH -# define CONFIG_PM_GOVERNOR_SLEEPENTER_THRESH 1 /* <=1: Essentially no activity */ -#endif - -#ifndef CONFIG_PM_GOVERNOR_SLEEPEXIT_THRESH -# define CONFIG_PM_GOVERNOR_SLEEPEXIT_THRESH 2 /* >=2: Active */ -#endif - -#if CONFIG_PM_GOVERNOR_SLEEPENTER_THRESH >= CONFIG_PM_GOVERNOR_SLEEPEXIT_THRESH -# error "Must have CONFIG_PM_GOVERNOR_SLEEPENTER_THRESH < CONFIG_PM_GOVERNOR_SLEEPEXIT_THRESH" -#endif - -#ifndef CONFIG_PM_GOVERNOR_SLEEPENTER_COUNT -# define CONFIG_PM_GOVERNOR_SLEEPENTER_COUNT 70 /* 70 IDLE slices to enter SLEEP - * mode from STANDBY - */ -#endif - -/**************************************************************************** - * Public Data - ****************************************************************************/ - -#ifdef __cplusplus -#define EXTERN extern "C" -extern "C" -{ -#else -#define EXTERN extern -#endif - -/**************************************************************************** - * Public Function Prototypes - ****************************************************************************/ - -FAR struct pm_governor_s *pm_activity_governor_initialize(void); - -#undef EXTERN -#ifdef __cplusplus -} -#endif - -#endif // __DRIVERS_POWER_ACTIVITY_GOVERNER_H diff --git a/drivers/power/greedy_governor.c b/drivers/power/greedy_governor.c index 09b35c01b2bd2..aa2225bf70613 100644 --- a/drivers/power/greedy_governor.c +++ b/drivers/power/greedy_governor.c @@ -40,7 +40,6 @@ #include -#include "greedy_governor.h" #include "pm.h" /**************************************************************************** @@ -62,7 +61,7 @@ static enum pm_state_e greedy_governor_checkstate(int domain); * Private Data ****************************************************************************/ -static struct pm_governor_s g_greedy_governor_ops = +static const struct pm_governor_s g_greedy_governor_ops = { greedy_governor_initialize, /* initialize */ NULL, /* deinitialize */ @@ -123,7 +122,7 @@ static enum pm_state_e greedy_governor_checkstate(int domain) * invoked, which modifies the stay count which we are about to read */ - flags = enter_critical_section(); + flags = pm_lock(); /* Find the lowest power-level which is not locked. */ @@ -132,7 +131,7 @@ static enum pm_state_e greedy_governor_checkstate(int domain) state++; } - leave_critical_section(flags); + pm_unlock(flags); /* Return the found state */ diff --git a/drivers/power/pm.h b/drivers/power/pm.h index 42821bf93b239..c3cdb67595244 100644 --- a/drivers/power/pm.h +++ b/drivers/power/pm.h @@ -41,27 +41,6 @@ * Pre-processor Definitions ****************************************************************************/ -/**************************************************************************** - * Name: pm_lock - * - * Description: - * Lock the power management registry. NOTE: This function may return - * an error if a signal is received while what (errno == EINTR). - * - ****************************************************************************/ - -#define pm_lock() nxsem_wait(&g_pmglobals.regsem); - -/**************************************************************************** - * Name: pm_unlock - * - * Description: - * Unlock the power management registry. - * - ****************************************************************************/ - -#define pm_unlock() nxsem_post(&g_pmglobals.regsem); - /**************************************************************************** * Public Types ****************************************************************************/ @@ -139,20 +118,24 @@ EXTERN struct pm_global_s g_pmglobals; ****************************************************************************/ /**************************************************************************** - * Name: pm_auto_updatestate + * Name: pm_lock * * Description: - * This function update the domain state and notify the power system. + * Lock the power management operation. * - * Input Parameters: - * domain - The PM domain to check + ****************************************************************************/ + +irqstate_t pm_lock(void); + +/**************************************************************************** + * Name: pm_unlock * - * Returned Value: - * None. + * Description: + * Unlock the power management operation. * ****************************************************************************/ -void pm_auto_updatestate(int domain); +void pm_unlock(irqstate_t flags); #undef EXTERN #if defined(__cplusplus) diff --git a/drivers/power/pm_activity.c b/drivers/power/pm_activity.c index d3c73dcb8efc3..e0f4a7f644d15 100644 --- a/drivers/power/pm_activity.c +++ b/drivers/power/pm_activity.c @@ -111,11 +111,11 @@ void pm_stay(int domain, enum pm_state_e state) DEBUGASSERT(domain >= 0 && domain < CONFIG_PM_NDOMAINS); pdom = &g_pmglobals.domain[domain]; - flags = enter_critical_section(); + flags = pm_lock(); DEBUGASSERT(state < PM_COUNT); DEBUGASSERT(pdom->stay[state] < UINT16_MAX); pdom->stay[state]++; - leave_critical_section(flags); + pm_unlock(flags); pm_auto_updatestate(domain); } @@ -151,11 +151,11 @@ void pm_relax(int domain, enum pm_state_e state) DEBUGASSERT(domain >= 0 && domain < CONFIG_PM_NDOMAINS); pdom = &g_pmglobals.domain[domain]; - flags = enter_critical_section(); + flags = pm_lock(); DEBUGASSERT(state < PM_COUNT); DEBUGASSERT(pdom->stay[state] > 0); pdom->stay[state]--; - leave_critical_section(flags); + pm_unlock(flags); pm_auto_updatestate(domain); } diff --git a/drivers/power/pm_autoupdate.c b/drivers/power/pm_autoupdate.c index b0d7601af7e7d..78463f0d4de7b 100644 --- a/drivers/power/pm_autoupdate.c +++ b/drivers/power/pm_autoupdate.c @@ -109,9 +109,9 @@ void pm_auto_update(int domain, bool auto_update) DEBUGASSERT(domain >= 0 && domain < CONFIG_PM_NDOMAINS); pdom = &g_pmglobals.domain[domain]; - flags = enter_critical_section(); + flags = pm_lock(); pdom->auto_update = auto_update; - leave_critical_section(flags); + pm_unlock(flags); } #endif /* CONFIG_PM */ diff --git a/drivers/power/pm_changestate.c b/drivers/power/pm_changestate.c index d38dd0d596bed..e9d804c4df05b 100644 --- a/drivers/power/pm_changestate.c +++ b/drivers/power/pm_changestate.c @@ -213,7 +213,7 @@ int pm_changestate(int domain, enum pm_state_e newstate) * re-enabled. */ - flags = enter_critical_section(); + flags = pm_lock(); /* First, prepare the drivers for the state change. In this phase, * drivers may refuse the state state change. @@ -249,7 +249,7 @@ int pm_changestate(int domain, enum pm_state_e newstate) /* Restore the interrupt state */ - leave_critical_section(flags); + pm_unlock(flags); return ret; } diff --git a/drivers/power/pm_initialize.c b/drivers/power/pm_initialize.c index fc458eb148963..0207bb79ffc55 100644 --- a/drivers/power/pm_initialize.c +++ b/drivers/power/pm_initialize.c @@ -28,12 +28,6 @@ #include "pm.h" -#if defined(CONFIG_PM_GOVERNOR_ACTIVITY) -# include "activity_governor.h" -#elif defined(CONFIG_PM_GOVERNOR_GREEDY) -# include "greedy_governor.h" -#endif - #ifdef CONFIG_PM /**************************************************************************** diff --git a/drivers/power/pm_lock.c b/drivers/power/pm_lock.c new file mode 100644 index 0000000000000..0e12224cbd8a0 --- /dev/null +++ b/drivers/power/pm_lock.c @@ -0,0 +1,75 @@ +/**************************************************************************** + * drivers/power/pm_lock.c + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include +#include +#include +#include +#include "pm.h" + +#if defined(CONFIG_PM) + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: pm_lock + * + * Description: + * Lock the power management operation. + * + ****************************************************************************/ + +irqstate_t pm_lock(void) +{ + if (!up_interrupt_context() && !sched_idletask()) + { + nxsem_wait_uninterruptible(&g_pmglobals.regsem); + } + + return enter_critical_section(); +} + +/**************************************************************************** + * Name: pm_unlock + * + * Description: + * Unlock the power management operation. + * + ****************************************************************************/ + +void pm_unlock(irqstate_t flags) +{ + leave_critical_section(flags); + + if (!up_interrupt_context() && !sched_idletask()) + { + nxsem_post(&g_pmglobals.regsem); + } +} + +#endif /* CONFIG_PM */ diff --git a/drivers/power/pm_register.c b/drivers/power/pm_register.c index fa95b8efa34ca..f676e8cb5c45c 100644 --- a/drivers/power/pm_register.c +++ b/drivers/power/pm_register.c @@ -56,20 +56,19 @@ int pm_register(FAR struct pm_callback_s *callbacks) { - int ret; + irqstate_t flags; DEBUGASSERT(callbacks); /* Add the new entry to the end of the list of registered callbacks */ - ret = pm_lock(); - if (ret == OK) - { - dq_addlast(&callbacks->entry, &g_pmglobals.registry); - pm_unlock(); - } + flags = pm_lock(); - return ret; + dq_addlast(&callbacks->entry, &g_pmglobals.registry); + + pm_unlock(flags); + + return 0; } #endif /* CONFIG_PM */ diff --git a/drivers/power/pm_unregister.c b/drivers/power/pm_unregister.c index bc9d0a61ed3e0..cf3a96393fbf0 100644 --- a/drivers/power/pm_unregister.c +++ b/drivers/power/pm_unregister.c @@ -55,20 +55,17 @@ int pm_unregister(FAR struct pm_callback_s *callbacks) { - int ret; + irqstate_t flags; DEBUGASSERT(callbacks); /* Remove entry from the list of registered callbacks. */ - ret = pm_lock(); - if (ret == OK) - { - dq_rem(&callbacks->entry, &g_pmglobals.registry); - pm_unlock(); - } + flags = pm_lock(); + dq_rem(&callbacks->entry, &g_pmglobals.registry); + pm_unlock(flags); - return ret; + return 0; } #endif /* CONFIG_PM */ diff --git a/drivers/power/powerled.c b/drivers/power/powerled.c index f181b181aa090..b288c0064eef4 100644 --- a/drivers/power/powerled.c +++ b/drivers/power/powerled.c @@ -44,10 +44,10 @@ * Private Function Prototypes ****************************************************************************/ -static int powerled_open(FAR struct file *filep); -static int powerled_close(FAR struct file *filep); -static int powerled_ioctl(FAR struct file *filep, int cmd, - unsigned long arg); +static int powerled_open(FAR struct file *filep); +static int powerled_close(FAR struct file *filep); +static int powerled_ioctl(FAR struct file *filep, int cmd, + unsigned long arg); /**************************************************************************** * Private Data diff --git a/drivers/power/regulator.c b/drivers/power/regulator.c index 8ccaa592145c3..fbe6899b4d5dd 100644 --- a/drivers/power/regulator.c +++ b/drivers/power/regulator.c @@ -724,9 +724,9 @@ int regulator_get_voltage(FAR struct regulator_s *regulator) ****************************************************************************/ FAR struct regulator_dev_s * -regulator_register(const FAR struct regulator_desc_s *regulator_desc, - const struct regulator_ops_s *regulator_ops, - void *priv) +regulator_register(FAR const struct regulator_desc_s *regulator_desc, + FAR const struct regulator_ops_s *regulator_ops, + FAR void *priv) { FAR struct regulator_dev_s *rdev; diff --git a/drivers/rc/lirc_dev.c b/drivers/rc/lirc_dev.c index dc5249378d868..ff747fe835d6f 100644 --- a/drivers/rc/lirc_dev.c +++ b/drivers/rc/lirc_dev.c @@ -124,7 +124,7 @@ static void lirc_pollnotify(FAR struct lirc_fh_s *fh, if (fh->fd->revents != 0) { - rcinfo("Report events: %02x\n", fh->fd->revents); + rcinfo("Report events: %08" PRIx32 "\n", fh->fd->revents); nxsem_get_value(fh->fd->sem, &semcount); if (semcount < 1) diff --git a/drivers/rf/dat-31r5-sp.c b/drivers/rf/dat-31r5-sp.c index 5c9aa9f786ade..9b5e890473316 100644 --- a/drivers/rf/dat-31r5-sp.c +++ b/drivers/rf/dat-31r5-sp.c @@ -64,8 +64,6 @@ struct dat31r5sp_dev_s /* Character driver methods */ -static int dat31r5sp_open(FAR struct file *filep); -static int dat31r5sp_close(FAR struct file *filep); static ssize_t dat31r5sp_read(FAR struct file *filep, FAR char *buffer, size_t buflen); static ssize_t dat31r5sp_write(FAR struct file *filep, @@ -79,8 +77,8 @@ static int dat31r5sp_ioctl(FAR struct file *filep, int cmd, static const struct file_operations g_dat31r5sp_fops = { - dat31r5sp_open, /* open */ - dat31r5sp_close, /* close */ + NULL, /* open */ + NULL, /* close */ dat31r5sp_read, /* read */ dat31r5sp_write, /* write */ NULL, /* seek */ @@ -142,34 +140,6 @@ static void dat31r5sp_set_attenuation(FAR struct dat31r5sp_dev_s *priv, SPI_LOCK(priv->spi, false); } -/**************************************************************************** - * Name: dat31r5sp_open - * - * Description: - * This function is called whenever the DAT-31R5-SP+ device is - * opened. - * - ****************************************************************************/ - -static int dat31r5sp_open(FAR struct file *filep) -{ - return OK; -} - -/**************************************************************************** - * Name: dat31r5sp_close - * - * Description: - * This function is called whenever the DAT-31R5-SP+ device is - * closed. - * - ****************************************************************************/ - -static int dat31r5sp_close(FAR struct file *filep) -{ - return OK; -} - /**************************************************************************** * Name: dat31r5sp_write * diff --git a/drivers/rptun/Kconfig b/drivers/rptun/Kconfig index b02afba8c5d71..327b20a5f028f 100644 --- a/drivers/rptun/Kconfig +++ b/drivers/rptun/Kconfig @@ -12,13 +12,27 @@ menuconfig RPTUN if RPTUN +choice + prompt "rptun dispatch method" + +config RPTUN_THREAD + bool "rptun thread" + +config RPTUN_WORKQUEUE + bool "rptun workqueue" + depends on SCHED_WORKQUEUE + +endchoice + config RPTUN_PRIORITY - int "rpturn thread priority" + int "rptun thread priority" + depends on RPTUN_THREAD default 224 config RPTUN_STACKSIZE int "rptun stack size" - default DEFAULT_TASK_STACKSIZE + depends on RPTUN_THREAD + default 4096 config RPTUN_LOADER bool "rptun loader support" @@ -28,4 +42,21 @@ config RPTUN_LOCAL_CPUNAME string "rptun local cpuname" default LIBC_HOSTNAME +config RPTUN_PM + bool "rptun power management" + depends on PM + default n + ---help--- + If TX/RX buffer is supplied and powered by each CPU. + And when one CPU in DEEP sleep, then it's buffer will + goto RAM-retention mode, can't access from another CPU. + So, we provide this method to resolve this. + +config RPTUN_PING + bool "rptun ping support" + default n + ---help--- + This is for rptun debugging & profiling, create ping rpmsg + channel, user can use it to get send/recv speed & latency. + endif # RPTUN diff --git a/drivers/rptun/Make.defs b/drivers/rptun/Make.defs index 00eacf432b7a9..03446ec9ace55 100644 --- a/drivers/rptun/Make.defs +++ b/drivers/rptun/Make.defs @@ -22,9 +22,14 @@ ifeq ($(CONFIG_RPTUN),y) -CSRCS += rptun.c +CSRCS += rptun.c rptun_dump.c + +ifeq ($(CONFIG_RPTUN_PING),y) +CSRCS += rptun_ping.c +endif DEPPATH += --dep-path rptun VPATH += :rptun CFLAGS += ${shell $(INCDIR) "$(CC)" $(TOPDIR)$(DELIM)drivers$(DELIM)rptun} +CFLAGS += ${shell $(INCDIR) "$(CC)" $(TOPDIR)$(DELIM)openamp$(DELIM)open-amp$(DELIM)lib} endif diff --git a/drivers/rptun/rptun.c b/drivers/rptun/rptun.c index 3186f7c3cf85c..3a6aae7773f76 100644 --- a/drivers/rptun/rptun.c +++ b/drivers/rptun/rptun.c @@ -29,27 +29,37 @@ #include #include +#include #include #include #include #include #include +#include +#include #include +#include "rptun.h" + /**************************************************************************** * Pre-processor Definitions ****************************************************************************/ #ifndef MAX -# define MAX(a,b) ((a) > (b) ? (a) : (b)) +# define MAX(a,b) ((a) > (b) ? (a) : (b)) #endif #ifndef ALIGN_UP -# define ALIGN_UP(s, a) (((s) + (a) - 1) & ~((a) - 1)) +# define ALIGN_UP(s, a) (((s) + (a) - 1) & ~((a) - 1)) #endif -#define RPTUNIOC_NONE 0 -#define NO_HOLDER (INVALID_PROCESS_ID) +#define RPTUNIOC_NONE 0 +#define NO_HOLDER (INVALID_PROCESS_ID) + +#define RPTUN_OPS_START 0 +#define RPTUN_OPS_DUMP 1 +#define RPTUN_OPS_RESET 2 +#define RPTUN_OPS_PANIC 3 /**************************************************************************** * Private Types @@ -59,13 +69,24 @@ struct rptun_priv_s { FAR struct rptun_dev_s *dev; struct remoteproc rproc; - struct rpmsg_virtio_device vdev; - struct rpmsg_virtio_shm_pool shm_pool; + struct rpmsg_virtio_device rvdev; + struct rpmsg_virtio_shm_pool tx_shpool; + struct rpmsg_virtio_shm_pool rx_shpool; struct metal_list bind; struct metal_list node; sem_t sem; - int tid; unsigned long cmd; +#ifdef CONFIG_RPTUN_WORKQUEUE + struct work_s work; +#else + pid_t tid; +#endif +#ifdef CONFIG_RPTUN_PM + bool stay; +#endif +#ifdef CONFIG_RPTUN_PING + struct rpmsg_endpoint ping; +#endif }; struct rptun_bind_s @@ -109,7 +130,7 @@ rptun_get_mem(FAR struct remoteproc *rproc, metal_phys_addr_t da, FAR void *va, size_t size, FAR struct remoteproc_mem *buf); -static int rptun_can_recursive(FAR struct remoteproc *rproc); +static int rptun_wait_tx_buffer(FAR struct remoteproc *rproc); static void rptun_ns_bind(FAR struct rpmsg_device *rdev, FAR const char *name, uint32_t dest); @@ -134,6 +155,7 @@ static metal_phys_addr_t rptun_pa_to_da(FAR struct rptun_dev_s *dev, metal_phys_addr_t pa); static metal_phys_addr_t rptun_da_to_pa(FAR struct rptun_dev_s *dev, metal_phys_addr_t da); +static int rptun_ops_foreach(FAR const char *cpuname, int ops, int value); /**************************************************************************** * Private Data @@ -141,14 +163,14 @@ static metal_phys_addr_t rptun_da_to_pa(FAR struct rptun_dev_s *dev, static struct remoteproc_ops g_rptun_ops = { - .init = rptun_init, - .remove = rptun_remove, - .config = rptun_config, - .start = rptun_start, - .stop = rptun_stop, - .notify = rptun_notify, - .get_mem = rptun_get_mem, - .can_recursive = rptun_can_recursive, + .init = rptun_init, + .remove = rptun_remove, + .config = rptun_config, + .start = rptun_start, + .stop = rptun_stop, + .notify = rptun_notify, + .get_mem = rptun_get_mem, + .wait_tx_buffer = rptun_wait_tx_buffer, }; static const struct file_operations g_rptun_devops = @@ -238,6 +260,91 @@ static void rptun_unlock(void) } } +#ifdef CONFIG_RPTUN_PM +static inline void rptun_pm_action(FAR struct rptun_priv_s *priv, + bool stay) +{ + irqstate_t flags; + + flags = enter_critical_section(); + + if (stay && !priv->stay) + { + pm_stay(0, PM_IDLE); + priv->stay = true; + } + + if (!stay && priv->stay && !rptun_buffer_nused(&priv->rvdev, false)) + { + pm_relax(0, PM_IDLE); + priv->stay = false; + } + + leave_critical_section(flags); +} + +#else +# define rptun_pm_action(priv, stay) +#endif + +static void rptun_worker(FAR void *arg) +{ + FAR struct rptun_priv_s *priv = arg; + + switch (priv->cmd) + { + case RPTUNIOC_START: + if (priv->rproc.state == RPROC_OFFLINE) + { + rptun_dev_start(&priv->rproc); + } + break; + + case RPTUNIOC_STOP: + if (priv->rproc.state != RPROC_OFFLINE) + { + rptun_dev_stop(&priv->rproc); + } + break; + } + + priv->cmd = RPTUNIOC_NONE; + remoteproc_get_notification(&priv->rproc, RPTUN_NOTIFY_ALL); + + rptun_pm_action(priv, false); +} + +static void rptun_post(FAR struct rptun_priv_s *priv) +{ + int semcount; + + nxsem_get_value(&priv->sem, &semcount); + while (semcount++ < 1) + { + nxsem_post(&priv->sem); + } +} + +#ifdef CONFIG_RPTUN_WORKQUEUE +static void rptun_wakeup(FAR struct rptun_priv_s *priv) +{ + work_queue(HPWORK, &priv->work, rptun_worker, priv, 0); + rptun_post(priv); +} + +static void rptun_in_recursive(int tid, FAR void *arg) +{ + *((FAR bool *)arg) = (gettid() == tid); +} + +static bool rptun_is_recursive(FAR struct rptun_priv_s *priv) +{ + bool in = false; + work_foreach(HPWORK, rptun_in_recursive, &in); + return in; +} + +#else static int rptun_thread(int argc, FAR char *argv[]) { FAR struct rptun_priv_s *priv; @@ -245,30 +352,10 @@ static int rptun_thread(int argc, FAR char *argv[]) priv = (FAR struct rptun_priv_s *)((uintptr_t)strtoul(argv[2], NULL, 0)); priv->tid = gettid(); - remoteproc_init(&priv->rproc, &g_rptun_ops, priv); - while (1) { nxsem_wait_uninterruptible(&priv->sem); - switch (priv->cmd) - { - case RPTUNIOC_START: - if (priv->rproc.state == RPROC_OFFLINE) - { - rptun_dev_start(&priv->rproc); - } - break; - - case RPTUNIOC_STOP: - if (priv->rproc.state != RPROC_OFFLINE) - { - rptun_dev_stop(&priv->rproc); - } - break; - } - - priv->cmd = RPTUNIOC_NONE; - remoteproc_get_notification(&priv->rproc, RPTUN_NOTIFY_ALL); + rptun_worker(priv); } return 0; @@ -276,14 +363,14 @@ static int rptun_thread(int argc, FAR char *argv[]) static void rptun_wakeup(FAR struct rptun_priv_s *priv) { - int semcount; + rptun_post(priv); +} - nxsem_get_value(&priv->sem, &semcount); - if (semcount < 1) - { - nxsem_post(&priv->sem); - } +static bool rptun_is_recursive(FAR struct rptun_priv_s *priv) +{ + return gettid() == priv->tid; } +#endif static int rptun_callback(FAR void *arg, uint32_t vqid) { @@ -345,9 +432,16 @@ static int rptun_stop(FAR struct remoteproc *rproc) static int rptun_notify(FAR struct remoteproc *rproc, uint32_t id) { FAR struct rptun_priv_s *priv = rproc->priv; + FAR struct rpmsg_virtio_device *rvdev = &priv->rvdev; + FAR struct virtqueue *vq = rvdev->svq; - RPTUN_NOTIFY(priv->dev, RPTUN_NOTIFY_ALL); + if (rvdev->vdev && vq && + rvdev->vdev->vrings_info[vq->vq_queue_index].notifyid == id) + { + rptun_pm_action(priv, true); + } + RPTUN_NOTIFY(priv->dev, RPTUN_NOTIFY_ALL); return 0; } @@ -390,11 +484,21 @@ rptun_get_mem(FAR struct remoteproc *rproc, return buf; } -static int rptun_can_recursive(FAR struct remoteproc *rproc) +static int rptun_wait_tx_buffer(FAR struct remoteproc *rproc) { FAR struct rptun_priv_s *priv = rproc->priv; - return gettid() == priv->tid; + if (!rptun_is_recursive(priv)) + { + return -EAGAIN; + } + + /* Wait to wakeup */ + + nxsem_wait(&priv->sem); + rptun_worker(priv); + + return 0; } static void *rptun_get_priv_by_rdev(FAR struct rpmsg_device *rdev) @@ -404,6 +508,11 @@ static void *rptun_get_priv_by_rdev(FAR struct rpmsg_device *rdev) struct remoteproc_virtio *rpvdev; struct remoteproc *rproc; + if (!rdev) + { + return NULL; + } + rvdev = metal_container_of(rdev, struct rpmsg_virtio_device, rdev); vdev = rvdev->vdev; if (!vdev) @@ -550,30 +659,48 @@ static int rptun_dev_start(FAR struct remoteproc *rproc) align0 = rsc->rpmsg_vring0.align; align1 = rsc->rpmsg_vring1.align; - tbsz = ALIGN_UP(sizeof(struct rptun_rsc_s), MAX(align0, align1)); v0sz = ALIGN_UP(vring_size(rsc->rpmsg_vring0.num, align0), align0); v1sz = ALIGN_UP(vring_size(rsc->rpmsg_vring1.num, align1), align1); - va0 = (FAR char *)rsc + tbsz; - va1 = (FAR char *)rsc + tbsz + v0sz; + if (rsc->rpmsg_vring0.da == 0 || rsc->rpmsg_vring1.da == 0) + { + tbsz = ALIGN_UP(sizeof(struct rptun_rsc_s), MAX(align0, align1)); - io = metal_io_get_region(); - pa0 = metal_io_virt_to_phys(io, va0); - pa1 = metal_io_virt_to_phys(io, va1); + va0 = (FAR char *)rsc + tbsz; + va1 = (FAR char *)rsc + tbsz + v0sz; - da0 = da1 = METAL_BAD_PHYS; + io = metal_io_get_region(); + pa0 = metal_io_virt_to_phys(io, va0); + pa1 = metal_io_virt_to_phys(io, va1); - remoteproc_mmap(rproc, &pa0, &da0, v0sz, 0, NULL); - remoteproc_mmap(rproc, &pa1, &da1, v1sz, 0, NULL); + da0 = da1 = METAL_BAD_PHYS; - rsc->rpmsg_vring0.da = da0; - rsc->rpmsg_vring1.da = da1; + remoteproc_mmap(rproc, &pa0, &da0, v0sz, 0, NULL); + remoteproc_mmap(rproc, &pa1, &da1, v1sz, 0, NULL); - shbuf = (FAR char *)rsc + tbsz + v0sz + v1sz; - shbufsz = rsc->config.txbuf_size * rsc->rpmsg_vring0.num + - rsc->config.rxbuf_size * rsc->rpmsg_vring1.num; + rsc->rpmsg_vring0.da = da0; + rsc->rpmsg_vring1.da = da1; - rpmsg_virtio_init_shm_pool(&priv->shm_pool, shbuf, shbufsz); + shbuf = (FAR char *)rsc + tbsz + v0sz + v1sz; + shbufsz = rsc->config.txbuf_size * rsc->rpmsg_vring0.num + + rsc->config.rxbuf_size * rsc->rpmsg_vring1.num; + + rpmsg_virtio_init_shm_pool(&priv->tx_shpool, shbuf, shbufsz); + } + else + { + da0 = rsc->rpmsg_vring0.da; + shbuf = (FAR char *)remoteproc_mmap(rproc, NULL, &da0, + v0sz, 0, NULL) + v0sz; + shbufsz = rsc->config.rxbuf_size * rsc->rpmsg_vring0.num; + rpmsg_virtio_init_shm_pool(&priv->rx_shpool, shbuf, shbufsz); + + da1 = rsc->rpmsg_vring1.da; + shbuf = (FAR char *)remoteproc_mmap(rproc, NULL, &da1, + v1sz, 0, NULL) + v1sz; + shbufsz = rsc->config.txbuf_size * rsc->rpmsg_vring1.num; + rpmsg_virtio_init_shm_pool(&priv->tx_shpool, shbuf, shbufsz); + } role = RPMSG_MASTER; } @@ -586,15 +713,25 @@ static int rptun_dev_start(FAR struct remoteproc *rproc) return -ENOMEM; } - ret = rpmsg_init_vdev(&priv->vdev, vdev, rptun_ns_bind, - metal_io_get_region(), &priv->shm_pool); + if (priv->rx_shpool.base) + { + ret = rpmsg_init_vdev_ext(&priv->rvdev, vdev, rptun_ns_bind, + metal_io_get_region(), + &priv->tx_shpool, &priv->rx_shpool); + } + else + { + ret = rpmsg_init_vdev(&priv->rvdev, vdev, rptun_ns_bind, + metal_io_get_region(), &priv->tx_shpool); + } + if (ret) { remoteproc_remove_virtio(rproc, vdev); return ret; } - priv->vdev.rdev.ns_unbind_cb = rptun_ns_unbind; + priv->rvdev.rdev.ns_unbind_cb = rptun_ns_unbind; /* Remote proc start */ @@ -607,6 +744,10 @@ static int rptun_dev_start(FAR struct remoteproc *rproc) rptun_lock(); + /* Register callback to mbox for receiving remote message */ + + RPTUN_REGISTER_CALLBACK(priv->dev, rptun_callback, priv); + /* Add priv to list */ metal_list_add_tail(&g_rptun_priv, &priv->node); @@ -618,16 +759,17 @@ static int rptun_dev_start(FAR struct remoteproc *rproc) cb = metal_container_of(node, struct rptun_cb_s, node); if (cb->device_created) { - cb->device_created(&priv->vdev.rdev, cb->priv); + cb->device_created(&priv->rvdev.rdev, cb->priv); } } rptun_unlock(); - /* Register callback to mbox for receiving remote message */ - - RPTUN_REGISTER_CALLBACK(priv->dev, rptun_callback, priv); + virtqueue_enable_cb(priv->rvdev.svq); +#ifdef CONFIG_RPTUN_PING + rptun_ping_init(&priv->rvdev, &priv->ping); +#endif return 0; } @@ -637,6 +779,10 @@ static int rptun_dev_stop(FAR struct remoteproc *rproc) FAR struct metal_list *node; FAR struct rptun_cb_s *cb; +#ifdef CONFIG_RPTUN_PING + rptun_ping_deinit(&priv->ping); +#endif + /* Unregister callback from mbox */ RPTUN_UNREGISTER_CALLBACK(priv->dev); @@ -654,7 +800,7 @@ static int rptun_dev_stop(FAR struct remoteproc *rproc) cb = metal_container_of(node, struct rptun_cb_s, node); if (cb->device_destroy) { - cb->device_destroy(&priv->vdev.rdev, cb->priv); + cb->device_destroy(&priv->rvdev.rdev, cb->priv); } } @@ -666,8 +812,8 @@ static int rptun_dev_stop(FAR struct remoteproc *rproc) /* Remote proc remove */ - remoteproc_remove_virtio(rproc, priv->vdev.vdev); - rpmsg_deinit_vdev(&priv->vdev); + remoteproc_remove_virtio(rproc, priv->rvdev.vdev); + rpmsg_deinit_vdev(&priv->rvdev); return 0; } @@ -686,7 +832,20 @@ static int rptun_dev_ioctl(FAR struct file *filep, int cmd, priv->cmd = cmd; rptun_wakeup(priv); break; - + case RPTUNIOC_RESET: + RPTUN_RESET(priv->dev, arg); + break; + case RPTUNIOC_PANIC: + RPTUN_PANIC(priv->dev); + break; + case RPTUNIOC_DUMP: + rptun_dump(&priv->rvdev); + break; +#ifdef CONFIG_RPTUN_PING + case RPTUNIOC_PING: + rptun_ping(&priv->ping, (FAR const struct rptun_ping_s *)arg); + break; +#endif default: ret = -ENOTTY; break; @@ -810,10 +969,100 @@ static metal_phys_addr_t rptun_da_to_pa(FAR struct rptun_dev_s *dev, return da; } +static int rptun_ops_foreach(FAR const char *cpuname, int ops, int value) +{ + FAR struct metal_list *node; + + metal_list_for_each(&g_rptun_priv, node) + { + FAR struct rptun_priv_s *priv; + + priv = metal_container_of(node, struct rptun_priv_s, node); + + if (!cpuname || !strcmp(RPTUN_GET_CPUNAME(priv->dev), cpuname)) + { + switch (ops) + { + case RPTUN_OPS_START: + priv->cmd = RPTUNIOC_START; + rptun_wakeup(priv); + break; + case RPTUN_OPS_DUMP: + rptun_dump(&priv->rvdev); + break; + case RPTUN_OPS_RESET: + RPTUN_RESET(priv->dev, value); + break; + case RPTUN_OPS_PANIC: + RPTUN_PANIC(priv->dev); + break; + default: + return -ENOTTY; + } + } + } + + return 0; +} + /**************************************************************************** * Public Functions ****************************************************************************/ +int rpmsg_wait(FAR struct rpmsg_endpoint *ept, FAR sem_t *sem) +{ + FAR struct rptun_priv_s *priv; + int ret; + + if (!ept || !sem) + { + return -EINVAL; + } + + priv = rptun_get_priv_by_rdev(ept->rdev); + if (!priv || !rptun_is_recursive(priv)) + { + return nxsem_wait_uninterruptible(sem); + } + + while (1) + { + ret = nxsem_trywait(sem); + if (ret >= 0) + { + break; + } + + nxsem_wait(&priv->sem); + rptun_worker(priv); + } + + return ret; +} + +int rpmsg_post(FAR struct rpmsg_endpoint *ept, FAR sem_t *sem) +{ + FAR struct rptun_priv_s *priv; + int semcount; + int ret; + + if (!ept || !sem) + { + return -EINVAL; + } + + nxsem_get_value(sem, &semcount); + ret = nxsem_post(sem); + + priv = rptun_get_priv_by_rdev(ept->rdev); + if (priv && semcount >= 0) + { + rptun_post(priv); + } + + return ret; +} + FAR const char *rpmsg_get_cpuname(FAR struct rpmsg_device *rdev) { FAR struct rptun_priv_s *priv = rptun_get_priv_by_rdev(rdev); @@ -847,12 +1096,12 @@ int rpmsg_register_callback(FAR void *priv_, metal_list_for_each(&g_rptun_priv, node) { - struct rptun_priv_s *priv; + FAR struct rptun_priv_s *priv; priv = metal_container_of(node, struct rptun_priv_s, node); if (device_created) { - device_created(&priv->vdev.rdev, priv_); + device_created(&priv->rvdev.rdev, priv_); } if (ns_bind) @@ -862,7 +1111,7 @@ int rpmsg_register_callback(FAR void *priv_, struct rptun_bind_s *bind; bind = metal_container_of(bnode, struct rptun_bind_s, node); - ns_bind(&priv->vdev.rdev, priv_, bind->name, bind->dest); + ns_bind(&priv->rvdev.rdev, priv_, bind->name, bind->dest); } } } @@ -900,7 +1149,7 @@ void rpmsg_unregister_callback(FAR void *priv_, priv = metal_container_of(pnode, struct rptun_priv_s, node); - device_destroy(&priv->vdev.rdev, priv_); + device_destroy(&priv->rvdev.rdev, priv_); } } @@ -918,8 +1167,10 @@ int rptun_initialize(FAR struct rptun_dev_s *dev) { struct metal_init_params params = METAL_INIT_DEFAULTS; FAR struct rptun_priv_s *priv; +#ifndef CONFIG_RPTUN_WORKQUEUE FAR char *argv[3]; char arg1[19]; +#endif char name[32]; int ret; @@ -937,14 +1188,9 @@ int rptun_initialize(FAR struct rptun_dev_s *dev) } priv->dev = dev; - if (RPTUN_IS_AUTOSTART(dev)) - { - priv->cmd = RPTUNIOC_START; - } + remoteproc_init(&priv->rproc, &g_rptun_ops, priv); metal_list_init(&priv->bind); - nxsem_init(&priv->sem, 0, RPTUN_IS_AUTOSTART(dev) ? 1 : 0); - nxsem_set_protocol(&priv->sem, SEM_PRIO_NONE); snprintf(name, sizeof(name), "/dev/rptun/%s", RPTUN_GET_CPUNAME(dev)); ret = register_driver(name, &g_rptun_devops, 0222, priv); @@ -953,6 +1199,25 @@ int rptun_initialize(FAR struct rptun_dev_s *dev) goto err_driver; } +#ifdef CONFIG_RPTUN_WORKQUEUE + if (RPTUN_IS_AUTOSTART(dev)) + { + priv->cmd = RPTUNIOC_START; + work_queue(HPWORK, &priv->work, rptun_worker, priv, 0); + } + + nxsem_init(&priv->sem, 0, 0); +#else + if (RPTUN_IS_AUTOSTART(dev)) + { + priv->cmd = RPTUNIOC_START; + nxsem_init(&priv->sem, 0, 1); + } + else + { + nxsem_init(&priv->sem, 0, 0); + } + snprintf(arg1, sizeof(arg1), "0x%" PRIxPTR, (uintptr_t)priv); argv[0] = (void *)RPTUN_GET_CPUNAME(dev); argv[1] = arg1; @@ -962,16 +1227,17 @@ int rptun_initialize(FAR struct rptun_dev_s *dev) CONFIG_RPTUN_STACKSIZE, rptun_thread, argv); if (ret < 0) { - goto err_thread; + unregister_driver(name); + nxsem_destroy(&priv->sem); + goto err_driver; } +#endif - return OK; + nxsem_set_protocol(&priv->sem, SEM_PRIO_NONE); -err_thread: - unregister_driver(name); + return OK; err_driver: - nxsem_destroy(&priv->sem); kmm_free(priv); err_mem: @@ -981,24 +1247,35 @@ int rptun_initialize(FAR struct rptun_dev_s *dev) int rptun_boot(FAR const char *cpuname) { - struct file file; - char name[32]; - int ret; + return rptun_ops_foreach(cpuname, RPTUN_OPS_START, 0); +} + +int rptun_reset(FAR const char *cpuname, int value) +{ + return rptun_ops_foreach(cpuname, RPTUN_OPS_RESET, value); +} + +int rptun_panic(FAR const char *cpuname) +{ + return rptun_ops_foreach(cpuname, RPTUN_OPS_PANIC, 0); +} + +int rptun_buffer_nused(FAR struct rpmsg_virtio_device *rvdev, bool rx) +{ + FAR struct virtqueue *vq = rx ? rvdev->rvq : rvdev->svq; - if (!cpuname) + if ((rpmsg_virtio_get_role(rvdev) == RPMSG_MASTER) ^ rx) { - return -EINVAL; + return vq->vq_ring.avail->idx - vq->vq_ring.used->idx; } - - snprintf(name, 32, "/dev/rptun/%s", cpuname); - ret = file_open(&file, name, 0, 0); - if (ret) + else { - return ret; + return vq->vq_nentries - + (vq->vq_ring.avail->idx - vq->vq_ring.used->idx); } +} - ret = file_ioctl(&file, RPTUNIOC_START, 0); - file_close(&file); - - return ret; +void rptun_dump_all(void) +{ + rptun_ops_foreach(NULL, RPTUN_OPS_DUMP, 0); } diff --git a/drivers/rptun/rptun.h b/drivers/rptun/rptun.h new file mode 100644 index 0000000000000..77038b6dfedf4 --- /dev/null +++ b/drivers/rptun/rptun.h @@ -0,0 +1,44 @@ +/**************************************************************************** + * drivers/rptun/rptun.h + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +#ifndef __DRIVERS_RPTUN_RPTUN_H +#define __DRIVERS_RPTUN_RPTUN_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include +#include + +/**************************************************************************** + * Public Function Prototypes + ****************************************************************************/ + +int rptun_buffer_nused(FAR struct rpmsg_virtio_device *rvdev, bool rx); +void rptun_dump(FAR struct rpmsg_virtio_device *rvdev); + +int rptun_ping_init(FAR struct rpmsg_virtio_device *rvdev, + FAR struct rpmsg_endpoint *ept); +void rptun_ping_deinit(FAR struct rpmsg_endpoint *ept); +int rptun_ping(FAR struct rpmsg_endpoint *ept, + FAR const struct rptun_ping_s *ping); + +#endif /* __DRIVERS_RPTUN_RPTUN_H */ diff --git a/drivers/rptun/rptun_dump.c b/drivers/rptun/rptun_dump.c new file mode 100644 index 0000000000000..cb041cf70e6d1 --- /dev/null +++ b/drivers/rptun/rptun_dump.c @@ -0,0 +1,123 @@ +/**************************************************************************** + * drivers/rptun/rptun_dump.c + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include +#include +#include + +#include + +#include "rptun.h" + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +static void rptun_dump_addr(FAR struct rpmsg_device *rdev, + FAR void *addr, bool rx) +{ + FAR struct rpmsg_hdr *hdr = addr; + FAR struct rpmsg_endpoint *ept; + + ept = rpmsg_get_ept_from_addr(rdev, rx ? hdr->dst : hdr->src); + if (ept) + { + metal_log(METAL_LOG_INFO, + " %s buffer %p hold by %s\n", + rx ? "RX" : "TX", hdr, ept->name); + } +} + +static void rptun_dump_buffer(FAR struct rpmsg_virtio_device *rvdev, + bool rx) +{ + FAR struct virtqueue *vq = rx ? rvdev->rvq : rvdev->svq; + FAR void *addr; + int desc_idx; + int num; + int i; + + num = rptun_buffer_nused(rvdev, rx); + metal_log(METAL_LOG_INFO, + " %s buffer, total %d, pending %d\n", + rx ? "RX" : "TX", vq->vq_nentries, num); + + for (i = 0; i < num; i++) + { + if ((rpmsg_virtio_get_role(rvdev) == RPMSG_MASTER) ^ rx) + { + desc_idx = (vq->vq_ring.used->idx + i) & (vq->vq_nentries - 1); + desc_idx = vq->vq_ring.avail->ring[desc_idx]; + } + else + { + desc_idx = (vq->vq_ring.avail->idx + i) & (vq->vq_nentries - 1); + desc_idx = vq->vq_ring.used->ring[desc_idx].id; + } + + addr = metal_io_phys_to_virt(vq->shm_io, + vq->vq_ring.desc[desc_idx].addr); + if (addr) + { + rptun_dump_addr(&rvdev->rdev, addr, rx); + } + } +} + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +void rptun_dump(FAR struct rpmsg_virtio_device *rvdev) +{ + FAR struct rpmsg_device *rdev = &rvdev->rdev; + FAR struct rpmsg_endpoint *ept; + FAR struct metal_list *node; + + if (!rvdev->vdev) + { + return; + } + + metal_mutex_acquire(&rdev->lock); + + metal_log(METAL_LOG_INFO, + "Dump rpmsg info between cpu %s <==> %s:\n", + CONFIG_RPTUN_LOCAL_CPUNAME, rpmsg_get_cpuname(rdev)); + + metal_log(METAL_LOG_INFO, " rpmsg ept list:\n"); + + metal_list_for_each(&rdev->endpoints, node) + { + ept = metal_container_of(node, struct rpmsg_endpoint, node); + metal_log(METAL_LOG_INFO, " ept %s\n", ept->name); + } + + metal_log(METAL_LOG_INFO, " rpmsg buffer list:\n"); + + rptun_dump_buffer(rvdev, true); + rptun_dump_buffer(rvdev, false); + + metal_mutex_release(&rdev->lock); +} diff --git a/drivers/rptun/rptun_ping.c b/drivers/rptun/rptun_ping.c new file mode 100644 index 0000000000000..60055cef37f80 --- /dev/null +++ b/drivers/rptun/rptun_ping.c @@ -0,0 +1,192 @@ +/**************************************************************************** + * drivers/rptun/rptun_ping.c + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include +#include + +#include +#include + +#include "rptun.h" + +/**************************************************************************** + * Pre-processor definitions + ****************************************************************************/ + +#ifndef MIN + #define MIN(n,m) (((n) < (m)) ? (n) : (m)) +#endif + +#ifndef MAX + #define MAX(n,m) (((n) < (m)) ? (m) : (n)) +#endif + +#define RPTUN_PING_EPT_NAME "rpmsg-ping" +#define RPTUN_PING_SEND 1 +#define RPTUN_PING_SEND_NOACK 2 +#define RPTUN_PING_ACK 3 + +/**************************************************************************** + * Private Types + ****************************************************************************/ + +begin_packed_struct struct rptun_ping_msg_s +{ + uint32_t cmd; + uint32_t len; + uint64_t cookie; +} end_packed_struct; + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +static int rptun_ping_ept_cb(FAR struct rpmsg_endpoint *ept, + FAR void *data, size_t len, uint32_t src, + FAR void *priv) +{ + FAR struct rptun_ping_msg_s *msg = data; + FAR sem_t *sem = (FAR sem_t *)(uintptr_t)msg->cookie; + + if (msg->cmd == RPTUN_PING_SEND) + { + msg->cmd = RPTUN_PING_ACK; + rpmsg_send(ept, msg, len); + } + else if (msg->cmd == RPTUN_PING_ACK) + { + nxsem_post(sem); + } + + return 0; +} + +static int rptun_ping_once(FAR struct rpmsg_endpoint *ept, + int len, bool ack) +{ + FAR struct rptun_ping_msg_s *msg; + uint32_t space; + int ret; + + msg = rpmsg_get_tx_payload_buffer(ept, &space, true); + if (!msg) + { + return -ENOMEM; + } + + len = MAX(len, sizeof(struct rptun_ping_msg_s)); + len = MIN(len, space); + + memset(msg, 0, len); + + if (ack) + { + sem_t sem; + + msg->cmd = RPTUN_PING_SEND; + msg->len = len; + msg->cookie = (uintptr_t)&sem; + + nxsem_init(&sem, 0, 0); + nxsem_set_protocol(&sem, SEM_PRIO_NONE); + + ret = rpmsg_send_nocopy(ept, msg, len); + if (ret >= 0) + { + nxsem_wait_uninterruptible(&sem); + } + + nxsem_destroy(&sem); + } + else + { + msg->cmd = RPTUN_PING_SEND_NOACK; + msg->len = len; + ret = rpmsg_send_nocopy(ept, msg, len); + } + + return ret; +} + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +int rptun_ping(FAR struct rpmsg_endpoint *ept, + FAR const struct rptun_ping_s *ping) +{ + uint32_t min = UINT32_MAX; + uint32_t max = 0; + uint64_t total = 0; + struct timespec ts; + int i; + + if (!ept || !ping || ping->times <= 0) + { + return -EINVAL; + } + + for (i = 0; i < ping->times; i++) + { + uint32_t tm = up_perf_gettime(); + + int ret = rptun_ping_once(ept, ping->len, ping->ack); + if (ret < 0) + { + return ret; + } + + tm = up_perf_gettime() - tm; + min = MIN(min, tm); + max = MAX(max, tm); + total += tm; + } + + syslog(LOG_INFO, "current CPU freq: %" PRIu32 ", ping times: %d\n", + up_perf_getfreq(), ping->times); + + up_perf_convert(total / ping->times, &ts); + syslog(LOG_INFO, "avg: s %" PRIu32 ", ns %ld\n", ts.tv_sec, ts.tv_nsec); + + up_perf_convert(min, &ts); + syslog(LOG_INFO, "min: s %" PRIu32 ", ns %ld\n", ts.tv_sec, ts.tv_nsec); + + up_perf_convert(max, &ts); + syslog(LOG_INFO, "max: s %" PRIu32 ", ns %ld\n", ts.tv_sec, ts.tv_nsec); + + return 0; +} + +int rptun_ping_init(FAR struct rpmsg_virtio_device *rvdev, + FAR struct rpmsg_endpoint *ept) +{ + return rpmsg_create_ept(ept, &rvdev->rdev, RPTUN_PING_EPT_NAME, + RPMSG_ADDR_ANY, RPMSG_ADDR_ANY, + rptun_ping_ept_cb, NULL); +} + +void rptun_ping_deinit(FAR struct rpmsg_endpoint *ept) +{ + rpmsg_destroy_ept(ept); +} diff --git a/drivers/segger/Make.defs b/drivers/segger/Make.defs index 66987408128ab..1dca76ae32a71 100644 --- a/drivers/segger/Make.defs +++ b/drivers/segger/Make.defs @@ -30,6 +30,7 @@ ifeq ($(CONFIG_SEGGER_RTT),y) CFLAGS += ${shell $(INCDIR) "$(CC)" segger$(DELIM)RTT$(DELIM)RTT} ifeq ($(CONFIG_ARCH_ARMV7M),y) + AFLAGS += ${shell $(INCDIR) "$(CC)" segger$(DELIM)config} ASRCS += segger/RTT/RTT/SEGGER_RTT_ASM_ARMv7M.S endif diff --git a/drivers/segger/config/SEGGER_RTT_Conf.h b/drivers/segger/config/SEGGER_RTT_Conf.h index 5de85b92120a1..a336ab0bda26f 100644 --- a/drivers/segger/config/SEGGER_RTT_Conf.h +++ b/drivers/segger/config/SEGGER_RTT_Conf.h @@ -27,7 +27,9 @@ #include -#include +#ifndef __ASSEMBLY__ +# include +#endif /**************************************************************************** * Pre-processor Definitions diff --git a/drivers/segger/note_sysview.c b/drivers/segger/note_sysview.c index be3b472ab9c01..1d2f20bce0e8e 100644 --- a/drivers/segger/note_sysview.c +++ b/drivers/segger/note_sysview.c @@ -83,7 +83,11 @@ static void sysview_send_taskinfo(FAR struct tcb_s *tcb) SEGGER_SYSVIEW_TASKINFO info; info.TaskID = tcb->pid; +#if CONFIG_TASK_NAME_SIZE > 0 info.sName = tcb->name; +#else + info.sName = ""; +#endif info.Prio = tcb->sched_priority; info.StackBase = (uintptr_t)tcb->stack_base_ptr; info.StackSize = tcb->adj_stack_size; @@ -474,7 +478,9 @@ int sysview_initialize(void) SEGGER_SYSVIEW_SetRAMBase(CONFIG_SEGGER_SYSVIEW_RAM_BASE); #endif +#ifdef CONFIG_SCHED_INSTRUMENTATION_FILTER if ((g_sysview.mode.flag & NOTE_FILTER_MODE_FLAG_ENABLE) != 0) +#endif { SEGGER_SYSVIEW_Start(); } diff --git a/drivers/sensors/Kconfig b/drivers/sensors/Kconfig index 38b77f81837db..07ef7184301bf 100644 --- a/drivers/sensors/Kconfig +++ b/drivers/sensors/Kconfig @@ -845,6 +845,37 @@ config SCD30_DEBUG endif # SENSORS_SCD30 +config SENSORS_SCD41 + bool "Sensirion SCD41 CO2, humidity and temperature sensor" + default n + ---help--- + Enable driver support for the Sensirion SCD41 CO₂, humidity and + temperature sensor. + +if SENSORS_SCD41 + +config SCD41_I2C + bool "Sensirion SCD41 I2C mode" + default y + select I2C + +config SCD41_I2C_FREQUENCY + int "SCD41 I2C frequency" + default 100000 + range 1 100000 + depends on SCD41_I2C + ---help--- + I2C frequency for SCD41. Note, maximum supported frequency for + this sensor is 100kHz. + +config SCD41_DEBUG + bool "Debug support for the SCD41" + default n + ---help--- + Enables debug features for the SCD41 + +endif # SENSORS_SCD41 + config SENSORS_SGP30 bool "Sensirion SGP30 Gas Platform sensor" default n diff --git a/drivers/sensors/Make.defs b/drivers/sensors/Make.defs index 96e0d59307360..54e87e46a580a 100644 --- a/drivers/sensors/Make.defs +++ b/drivers/sensors/Make.defs @@ -192,6 +192,10 @@ ifeq ($(CONFIG_SENSORS_SCD30),y) CSRCS += scd30.c endif +ifeq ($(CONFIG_SENSORS_SCD41),y) + CSRCS += scd41.c +endif + ifeq ($(CONFIG_SENSORS_SGP30),y) CSRCS += sgp30.c endif diff --git a/drivers/sensors/adt7320.c b/drivers/sensors/adt7320.c index fd0e8c77e04eb..1cb46b93113c2 100644 --- a/drivers/sensors/adt7320.c +++ b/drivers/sensors/adt7320.c @@ -88,7 +88,6 @@ static int adt7320_readtemp(FAR struct adt7320_dev_s *priv, FAR b16_t *temp); /* Character driver methods */ static int adt7320_open(FAR struct file *filep); -static int adt7320_close(FAR struct file *filep); static ssize_t adt7320_read(FAR struct file *filep, FAR char *buffer, size_t buflen); static ssize_t adt7320_write(FAR struct file *filep, FAR const char *buffer, @@ -102,7 +101,7 @@ static int adt7320_ioctl(FAR struct file *filep, int cmd, unsigned long arg); static const struct file_operations g_adt7320fops = { adt7320_open, /* open */ - adt7320_close, /* close */ + NULL, /* close */ adt7320_read, /* read */ adt7320_write, /* write */ NULL, /* seek */ @@ -336,19 +335,6 @@ static int adt7320_open(FAR struct file *filep) return OK; } -/**************************************************************************** - * Name: adt7320_close - * - * Description: - * This routine is called when the ADT7320 device is closed. - * - ****************************************************************************/ - -static int adt7320_close(FAR struct file *filep) -{ - return OK; -} - /**************************************************************************** * Name: adt7320_read ****************************************************************************/ diff --git a/drivers/sensors/adxl345_base.c b/drivers/sensors/adxl345_base.c index 6d1658904f4a8..8c499073a0310 100644 --- a/drivers/sensors/adxl345_base.c +++ b/drivers/sensors/adxl345_base.c @@ -49,8 +49,6 @@ /* Character driver methods */ -static int adxl345_open(FAR struct file *filep); -static int adxl345_close(FAR struct file *filep); static ssize_t adxl345_read(FAR struct file *filep, FAR char *buffer, size_t len); @@ -62,8 +60,8 @@ static ssize_t adxl345_read(FAR struct file *filep, FAR char *buffer, static const struct file_operations g_adxl345fops = { - adxl345_open, /* open */ - adxl345_close, /* close */ + NULL, /* open */ + NULL, /* close */ adxl345_read, /* read */ NULL, /* write */ NULL, /* seek */ @@ -74,32 +72,6 @@ static const struct file_operations g_adxl345fops = #endif }; -/**************************************************************************** - * Name: adxl345_open - * - * Description: - * Standard character driver open method. - * - ****************************************************************************/ - -static int adxl345_open(FAR struct file *filep) -{ - return OK; -} - -/**************************************************************************** - * Name: adxl345_close - * - * Description: - * Standard character driver close method. - * - ****************************************************************************/ - -static int adxl345_close(FAR struct file *filep) -{ - return OK; -} - /**************************************************************************** * Name: adxl345_read * @@ -210,7 +182,7 @@ int adxl345_register(ADXL345_HANDLE handle, int minor) /* Register the character driver */ - snprintf(devname, DEV_NAMELEN, DEV_FORMAT, minor); + snprintf(devname, sizeof(devname), DEV_FORMAT, minor); ret = register_driver(devname, &g_adxl345fops, 0444, priv); if (ret < 0) { diff --git a/drivers/sensors/apds9960.c b/drivers/sensors/apds9960.c index 7456b38f7a6ab..3d625b7149b88 100644 --- a/drivers/sensors/apds9960.c +++ b/drivers/sensors/apds9960.c @@ -104,20 +104,20 @@ static bool apds9960_isgestureavailable(FAR struct apds9960_dev_s *priv); /* I2C Helpers */ static int apds9960_i2c_read(FAR struct apds9960_dev_s *priv, - uint8_t const regaddr, FAR uint8_t *regval, int len); + uint8_t const regaddr, FAR uint8_t *regval, + int len); static int apds9960_i2c_read8(FAR struct apds9960_dev_s *priv, - uint8_t const regaddr, FAR uint8_t *regval); + uint8_t const regaddr, + FAR uint8_t *regval); static int apds9960_i2c_write(FAR struct apds9960_dev_s *priv, - uint8_t const *data, int len); + uint8_t const *data, int len); static int apds9960_i2c_write8(FAR struct apds9960_dev_s *priv, - uint8_t const regaddr, uint8_t regval); + uint8_t const regaddr, uint8_t regval); /* Character driver methods */ -static int apds9960_open(FAR struct file *filep); -static int apds9960_close(FAR struct file *filep); static ssize_t apds9960_read(FAR struct file *filep, FAR char *buffer, - size_t buflen); + size_t buflen); static ssize_t apds9960_write(FAR struct file *filep, FAR const char *buffer, size_t buflen); @@ -127,8 +127,8 @@ static ssize_t apds9960_write(FAR struct file *filep, static const struct file_operations g_apds9960_fops = { - apds9960_open, /* open */ - apds9960_close, /* close */ + NULL, /* open */ + NULL, /* close */ apds9960_read, /* read */ apds9960_write, /* write */ NULL, /* seek */ @@ -1129,32 +1129,6 @@ static int apds9960_readgesture(FAR struct apds9960_dev_s *priv) } } -/**************************************************************************** - * Name: apds9960_open - * - * Description: - * This function is called whenever the APDS9960 device is opened. - * - ****************************************************************************/ - -static int apds9960_open(FAR struct file *filep) -{ - return OK; -} - -/**************************************************************************** - * Name: apds9960_close - * - * Description: - * This routine is called when the APDS9960 device is closed. - * - ****************************************************************************/ - -static int apds9960_close(FAR struct file *filep) -{ - return OK; -} - /**************************************************************************** * Name: apds9960_read ****************************************************************************/ diff --git a/drivers/sensors/as726x.c b/drivers/sensors/as726x.c index 38b794ec67c2c..0d5b330b91a69 100644 --- a/drivers/sensors/as726x.c +++ b/drivers/sensors/as726x.c @@ -93,14 +93,12 @@ static int16_t as726x_getchannel(FAR struct as726x_dev_s *priv, static uint8_t read_register(FAR struct as726x_dev_s *priv, uint8_t addr); static uint8_t as726x_read8(FAR struct as726x_dev_s *priv, uint8_t regval); static void write_register(FAR struct as726x_dev_s *priv, uint8_t addr, - uint8_t val); + uint8_t val); static void as726x_write8(FAR struct as726x_dev_s *priv, uint8_t regaddr, uint8_t regval); /* Character driver methods */ -static int as726x_open(FAR struct file *filep); -static int as726x_close(FAR struct file *filep); static ssize_t as726x_read(FAR struct file *filep, FAR char *buffer, size_t buflen); static ssize_t as726x_write(FAR struct file *filep, @@ -112,8 +110,8 @@ static ssize_t as726x_write(FAR struct file *filep, static const struct file_operations g_as726x_fops = { - as726x_open, /* open */ - as726x_close, /* close */ + NULL, /* open */ + NULL, /* close */ as726x_read, /* read */ as726x_write, /* write */ NULL, /* seek */ @@ -331,32 +329,6 @@ static void as726x_write8(FAR struct as726x_dev_s *priv, uint8_t regaddr, write_register(priv, AS72XX_SLAVE_WRITE_REG, regval); } -/**************************************************************************** - * Name: as726x_open - * - * Description: - * This function is called whenever the AS726X device is opened. - * - ****************************************************************************/ - -static int as726x_open(FAR struct file *filep) -{ - return OK; -} - -/**************************************************************************** - * Name: as726x_close - * - * Description: - * This routine is called when the AS726X device is closed. - * - ****************************************************************************/ - -static int as726x_close(FAR struct file *filep) -{ - return OK; -} - /**************************************************************************** * Name: as726x_read ****************************************************************************/ @@ -445,7 +417,7 @@ int as726x_register(FAR const char *devpath, FAR struct i2c_master_s *i2c) /* Check HW version for AS7262 and AS7263 */ - _sensor_version = as726x_read8(priv, AS726x_HW_VERSION); + _sensor_version = as726x_read8(priv, AS726X_HW_VERSION); if (_sensor_version != 0x3e && _sensor_version != 0x3f) { snerr("ID (should be 0x3e or 0x3f): 0x %d\n", ret); @@ -455,7 +427,7 @@ int as726x_register(FAR const char *devpath, FAR struct i2c_master_s *i2c) * Read the register value toggle and disable led */ - ret = as726x_read8(priv, AS726x_LED_CONTROL); + ret = as726x_read8(priv, AS726X_LED_CONTROL); if (ret < 0) { snerr("ERROR: Failed to initialize the AS726X!\n"); @@ -465,16 +437,16 @@ int as726x_register(FAR const char *devpath, FAR struct i2c_master_s *i2c) value = ret; value &= ~(1 << 0); /* Clear the bit */ - as726x_write8(priv, AS726x_LED_CONTROL, value); + as726x_write8(priv, AS726X_LED_CONTROL, value); /* If you use Mode 2 or 3 (all the colors) then integration time is double. * 140*2 = 280ms between readings. * 50 * 2.8ms = 140ms. 0 to 255 is valid. */ - as726x_write8(priv, AS726x_INT_T, AS726X_INTEGRATION_TIME); + as726x_write8(priv, AS726X_INT_T, AS726X_INTEGRATION_TIME); - ret = as726x_read8(priv, AS726x_CONTROL_SETUP); + ret = as726x_read8(priv, AS726X_CONTROL_SETUP); if (ret < 0) { snerr("ERROR: Failed to initialize the AS726X!\n"); @@ -485,9 +457,9 @@ int as726x_register(FAR const char *devpath, FAR struct i2c_master_s *i2c) value &= 0b11001111; /* Clear GAIN bits */ value |= (AS726X_GAIN << 4); /* Set GAIN bits with user's choice */ - as726x_write8(priv, AS726x_CONTROL_SETUP, value); + as726x_write8(priv, AS726X_CONTROL_SETUP, value); - ret = as726x_read8(priv, AS726x_CONTROL_SETUP); + ret = as726x_read8(priv, AS726X_CONTROL_SETUP); if (ret < 0) { snerr("ERROR: Failed to initialize the AS726X!\n"); @@ -499,7 +471,7 @@ int as726x_register(FAR const char *devpath, FAR struct i2c_master_s *i2c) value |= (AS726X_MEASURMENT_MODE << 2); /* Set BANK bits with user's * choice */ - as726x_write8(priv, AS726x_CONTROL_SETUP, value); + as726x_write8(priv, AS726X_CONTROL_SETUP, value); /* Register the character driver */ diff --git a/drivers/sensors/bh1750fvi.c b/drivers/sensors/bh1750fvi.c index 65f8eedfb332e..b4a39a946e6b0 100644 --- a/drivers/sensors/bh1750fvi.c +++ b/drivers/sensors/bh1750fvi.c @@ -64,20 +64,20 @@ struct bh1750fvi_dev_s /* I2C Helpers */ static int bh1750fvi_read16(FAR struct bh1750fvi_dev_s *priv, - FAR uint16_t *regval); + FAR uint16_t *regval); static int bh1750fvi_write8(FAR struct bh1750fvi_dev_s *priv, - uint8_t regval); + uint8_t regval); /* Character driver methods */ static int bh1750fvi_open(FAR struct file *filep); static int bh1750fvi_close(FAR struct file *filep); static ssize_t bh1750fvi_read(FAR struct file *filep, FAR char *buffer, - size_t buflen); + size_t buflen); static ssize_t bh1750fvi_write(FAR struct file *filep, - FAR const char *buffer, size_t buflen); + FAR const char *buffer, size_t buflen); static int bh1750fvi_ioctl(FAR struct file *filep, int cmd, - unsigned long arg); + unsigned long arg); /**************************************************************************** * Private Data @@ -85,8 +85,8 @@ static int bh1750fvi_ioctl(FAR struct file *filep, int cmd, static const struct file_operations g_bh1750fvi_fops = { - bh1750fvi_open, /* open */ - bh1750fvi_close, /* close */ + NULL, /* open */ + NULL, /* close */ bh1750fvi_read, /* read */ bh1750fvi_write, /* write */ NULL, /* seek */ @@ -171,32 +171,6 @@ static int bh1750fvi_write8(FAR struct bh1750fvi_dev_s *priv, uint8_t regval) return ret; } -/**************************************************************************** - * Name: bh1750fvi_open - * - * Description: - * This function is called whenever the BH1750FVI device is opened. - * - ****************************************************************************/ - -static int bh1750fvi_open(FAR struct file *filep) -{ - return OK; -} - -/**************************************************************************** - * Name: bh1750fvi_close - * - * Description: - * This routine is called when the BH1750FVI device is closed. - * - ****************************************************************************/ - -static int bh1750fvi_close(FAR struct file *filep) -{ - return OK; -} - /**************************************************************************** * Name: bh1750fvi_read ****************************************************************************/ diff --git a/drivers/sensors/bmg160.c b/drivers/sensors/bmg160.c index 75005bbab783c..4abfe2adb8b9f 100644 --- a/drivers/sensors/bmg160.c +++ b/drivers/sensors/bmg160.c @@ -87,7 +87,6 @@ static int bmg160_close(FAR struct file *filep); static ssize_t bmg160_read(FAR struct file *, FAR char *, size_t); static ssize_t bmg160_write(FAR struct file *filep, FAR const char *buffer, size_t buflen); -static int bmg160_ioctl(FAR struct file *filep, int cmd, unsigned long arg); /**************************************************************************** * Private Data @@ -100,7 +99,7 @@ static const struct file_operations g_bmg160_fops = bmg160_read, /* read */ bmg160_write, /* write */ NULL, /* seek */ - bmg160_ioctl, /* ioctl */ + NULL, /* ioctl */ NULL /* poll */ #ifndef CONFIG_DISABLE_PSEUDOFS_OPERATIONS , NULL /* unlink */ @@ -482,27 +481,6 @@ static ssize_t bmg160_write(FAR struct file *filep, FAR const char *buffer, return -ENOSYS; } -/**************************************************************************** - * Name: bmg160_ioctl - ****************************************************************************/ - -static int bmg160_ioctl(FAR struct file *filep, int cmd, unsigned long arg) -{ - int ret = OK; - - switch (cmd) - { - /* Command was not recognized */ - - default: - snerr("ERROR: Unrecognized cmd: %d\n", cmd); - ret = -ENOTTY; - break; - } - - return ret; -} - /**************************************************************************** * Public Functions ****************************************************************************/ diff --git a/drivers/sensors/bmp180.c b/drivers/sensors/bmp180.c index 87d332edb62dc..5fd5764ebee26 100644 --- a/drivers/sensors/bmp180.c +++ b/drivers/sensors/bmp180.c @@ -131,8 +131,6 @@ static int bmp180_getpressure(FAR struct bmp180_dev_s *priv); /* Character driver methods */ -static int bmp180_open(FAR struct file *filep); -static int bmp180_close(FAR struct file *filep); static ssize_t bmp180_read(FAR struct file *filep, FAR char *buffer, size_t buflen); static ssize_t bmp180_write(FAR struct file *filep, FAR const char *buffer, @@ -144,8 +142,8 @@ static ssize_t bmp180_write(FAR struct file *filep, FAR const char *buffer, static const struct file_operations g_bmp180fops = { - bmp180_open, /* open */ - bmp180_close, /* close */ + NULL, /* open */ + NULL, /* close */ bmp180_read, /* read */ bmp180_write, /* write */ NULL, /* seek */ @@ -500,32 +498,6 @@ static int bmp180_getpressure(FAR struct bmp180_dev_s *priv) return press; } -/**************************************************************************** - * Name: bmp180_open - * - * Description: - * This function is called whenever the BMP1801 device is opened. - * - ****************************************************************************/ - -static int bmp180_open(FAR struct file *filep) -{ - return OK; -} - -/**************************************************************************** - * Name: bmp180_close - * - * Description: - * This routine is called when the BMP180 device is closed. - * - ****************************************************************************/ - -static int bmp180_close(FAR struct file *filep) -{ - return OK; -} - /**************************************************************************** * Name: bmp180_read ****************************************************************************/ diff --git a/drivers/sensors/dhtxx.c b/drivers/sensors/dhtxx.c index a6db97b829c8b..b65e3e0f16c32 100644 --- a/drivers/sensors/dhtxx.c +++ b/drivers/sensors/dhtxx.c @@ -93,18 +93,15 @@ static bool dht_check_data(FAR struct dhtxx_sensor_data_s *data, float min_hum, float max_hum, float min_temp, float max_temp); static int dht_parse_data(FAR struct dhtxx_dev_s *priv, - FAR struct dhtxx_sensor_data_s *data); + FAR struct dhtxx_sensor_data_s *data); /* Character driver methods */ static int dhtxx_open(FAR struct file *filep); -static int dhtxx_close(FAR struct file *filep); static ssize_t dhtxx_read(FAR struct file *filep, FAR char *buffer, size_t buflen); static ssize_t dhtxx_write(FAR struct file *filep, FAR const char *buffer, size_t buflen); -static int dhtxx_ioctl(FAR struct file *filep, int cmd, - unsigned long arg); /**************************************************************************** * Private Data @@ -113,11 +110,11 @@ static int dhtxx_ioctl(FAR struct file *filep, int cmd, static const struct file_operations g_dhtxxfops = { dhtxx_open, /* open */ - dhtxx_close, /* close */ + NULL, /* close */ dhtxx_read, /* read */ dhtxx_write, /* write */ NULL, /* seek */ - dhtxx_ioctl, /* ioctl */ + NULL, /* ioctl */ NULL /* poll */ #ifndef CONFIG_DISABLE_PSEUDOFS_OPERATIONS , NULL /* unlink */ @@ -352,7 +349,7 @@ static int dht_parse_data(FAR struct dhtxx_dev_s *priv, */ if (!dht_check_data(data, DHT11_MIN_HUM, DHT11_MAX_HUM, - DHT11_MIN_TEMP, DHT11_MAX_TEMP)) + DHT11_MIN_TEMP, DHT11_MAX_TEMP)) { ret = -1; } @@ -369,7 +366,7 @@ static int dht_parse_data(FAR struct dhtxx_dev_s *priv, } if (!dht_check_data(data, DHT12_MIN_HUM, DHT12_MAX_HUM, - DHT12_MIN_TEMP, DHT12_MAX_TEMP)) + DHT12_MIN_TEMP, DHT12_MAX_TEMP)) { ret = -1; } @@ -435,25 +432,12 @@ static int dhtxx_open(FAR struct file *filep) return OK; } -/**************************************************************************** - * Name: dhtxx_close - * - * Description: - * This routine is called when the Dhtxx device is closed. - * - ****************************************************************************/ - -static int dhtxx_close(FAR struct file *filep) -{ - return OK; -} - /**************************************************************************** * Name: dhtxx_read ****************************************************************************/ static ssize_t dhtxx_read(FAR struct file *filep, FAR char *buffer, - size_t buflen) + size_t buflen) { int ret = OK; FAR struct inode *inode = filep->f_inode; @@ -542,27 +526,6 @@ static ssize_t dhtxx_write(FAR struct file *filep, FAR const char *buffer, return -ENOSYS; } -/**************************************************************************** - * Name: dhtxx_ioctl - ****************************************************************************/ - -static int dhtxx_ioctl(FAR struct file *filep, int cmd, unsigned long arg) -{ - int ret = OK; - - switch (cmd) - { - /* Command was not recognized */ - - default: - snerr("ERROR: Unrecognized cmd: %d\n", cmd); - ret = -ENOTTY; - break; - } - - return ret; -} - /**************************************************************************** * Public Functions ****************************************************************************/ diff --git a/drivers/sensors/hc_sr04.c b/drivers/sensors/hc_sr04.c index 284856a4b5917..49313a86bccff 100644 --- a/drivers/sensors/hc_sr04.c +++ b/drivers/sensors/hc_sr04.c @@ -289,7 +289,7 @@ static void hcsr04_notify(FAR struct hcsr04_dev_s *priv) if (fds) { fds->revents |= POLLIN; - hcsr04_dbg("Report events: %02x\n", fds->revents); + hcsr04_dbg("Report events: %08" PRIx32 "\n", fds->revents); nxsem_post(fds->sem); } } diff --git a/drivers/sensors/hts221.c b/drivers/sensors/hts221.c index 1dc5cbf84ee81..d22c9aa5cfbea 100644 --- a/drivers/sensors/hts221.c +++ b/drivers/sensors/hts221.c @@ -1072,7 +1072,7 @@ static void hts221_notify(FAR struct hts221_dev_s *priv) if (fds) { fds->revents |= POLLIN; - hts221_dbg("Report events: %02x\n", fds->revents); + hts221_dbg("Report events: %08" PRIx32 "\n", fds->revents); nxsem_post(fds->sem); } } diff --git a/drivers/sensors/ina219.c b/drivers/sensors/ina219.c index dcda54add3fc9..90d84b646f99b 100644 --- a/drivers/sensors/ina219.c +++ b/drivers/sensors/ina219.c @@ -92,9 +92,9 @@ struct ina219_dev_s static int ina219_write16(FAR struct ina219_dev_s *priv, uint8_t regaddr, FAR uint16_t regvalue); static int ina219_read16(FAR struct ina219_dev_s *priv, uint8_t regaddr, - FAR uint16_t *regvalue); + FAR uint16_t *regvalue); static int ina219_readpower(FAR struct ina219_dev_s *priv, - FAR struct ina219_s *buffer); + FAR struct ina219_s *buffer); /* Character driver methods */ @@ -104,8 +104,6 @@ static ssize_t ina219_read(FAR struct file *filep, FAR char *buffer, size_t buflen); static ssize_t ina219_write(FAR struct file *filep, FAR const char *buffer, size_t buflen); -static int ina219_ioctl(FAR struct file *filep, int cmd, - unsigned long arg); /**************************************************************************** * Private Data @@ -118,7 +116,7 @@ static const struct file_operations g_ina219fops = ina219_read, /* read */ ina219_write, /* write */ NULL, /* seek */ - ina219_ioctl, /* ioctl */ + NULL, /* ioctl */ NULL /* poll */ #ifndef CONFIG_DISABLE_PSEUDOFS_OPERATIONS , NULL /* unlink */ @@ -339,15 +337,6 @@ static ssize_t ina219_write(FAR struct file *filep, FAR const char *buffer, return -ENOSYS; } -/**************************************************************************** - * Name: ina219_ioctl - ****************************************************************************/ - -static int ina219_ioctl(FAR struct file *filep, int cmd, unsigned long arg) -{ - return -ENOTTY; -} - /**************************************************************************** * Public Functions ****************************************************************************/ diff --git a/drivers/sensors/ina226.c b/drivers/sensors/ina226.c index 93d62b90e997b..d825b8e4e2da0 100644 --- a/drivers/sensors/ina226.c +++ b/drivers/sensors/ina226.c @@ -74,9 +74,9 @@ struct ina226_dev_s static int ina226_write16(FAR struct ina226_dev_s *priv, uint8_t regaddr, FAR uint16_t regvalue); static int ina226_read16(FAR struct ina226_dev_s *priv, uint8_t regaddr, - FAR uint16_t *regvalue); + FAR uint16_t *regvalue); static int ina226_readpower(FAR struct ina226_dev_s *priv, - FAR struct ina226_s *buffer); + FAR struct ina226_s *buffer); /* Character driver methods */ @@ -86,8 +86,6 @@ static ssize_t ina226_read(FAR struct file *filep, FAR char *buffer, size_t buflen); static ssize_t ina226_write(FAR struct file *filep, FAR const char *buffer, size_t buflen); -static int ina226_ioctl(FAR struct file *filep, int cmd, - unsigned long arg); /**************************************************************************** * Private Data @@ -100,7 +98,7 @@ static const struct file_operations g_ina226fops = ina226_read, /* read */ ina226_write, /* write */ NULL, /* seek */ - ina226_ioctl, /* ioctl */ + NULL, /* ioctl */ NULL /* poll */ #ifndef CONFIG_DISABLE_PSEUDOFS_OPERATIONS , NULL /* unlink */ @@ -318,15 +316,6 @@ static ssize_t ina226_write(FAR struct file *filep, FAR const char *buffer, return -ENOSYS; } -/**************************************************************************** - * Name: ina226_ioctl - ****************************************************************************/ - -static int ina226_ioctl(FAR struct file *filep, int cmd, unsigned long arg) -{ - return -ENOTTY; -} - /**************************************************************************** * Public Functions ****************************************************************************/ diff --git a/drivers/sensors/ina3221.c b/drivers/sensors/ina3221.c index 3064eab74c10e..3718b47d66994 100644 --- a/drivers/sensors/ina3221.c +++ b/drivers/sensors/ina3221.c @@ -103,14 +103,10 @@ static int ina3221_readpower(FAR struct ina3221_dev_s *priv, /* Character driver methods */ -static int ina3221_open(FAR struct file *filep); -static int ina3221_close(FAR struct file *filep); static ssize_t ina3221_read(FAR struct file *filep, FAR char *buffer, - size_t buflen); + size_t buflen); static ssize_t ina3221_write(FAR struct file *filep, FAR const char *buffer, size_t buflen); -static int ina3221_ioctl(FAR struct file *filep, int cmd, - unsigned long arg); /**************************************************************************** * Private Data @@ -118,12 +114,12 @@ static int ina3221_ioctl(FAR struct file *filep, int cmd, static const struct file_operations g_ina3221fops = { - ina3221_open, /* open */ - ina3221_close, /* close */ + NULL, /* open */ + NULL, /* close */ ina3221_read, /* read */ ina3221_write, /* write */ NULL, /* seek */ - ina3221_ioctl, /* ioctl */ + NULL, /* ioctl */ NULL /* poll */ #ifndef CONFIG_DISABLE_PSEUDOFS_OPERATIONS , NULL /* unlink */ @@ -274,40 +270,6 @@ static int ina3221_readpower(FAR struct ina3221_dev_s *priv, return OK; } -/**************************************************************************** - * Name: ina3221_open - * - * Description: - * This function is called whenever the INA3221 device is opened. - * - ****************************************************************************/ - -static int ina3221_open(FAR struct file *filep) -{ - FAR struct inode *inode = filep->f_inode; - FAR struct ina3221_dev_s *priv = inode->i_private; - - UNUSED(priv); - return OK; -} - -/**************************************************************************** - * Name: ina3221_close - * - * Description: - * This routine is called when the INA3221 device is closed. - * - ****************************************************************************/ - -static int ina3221_close(FAR struct file *filep) -{ - FAR struct inode *inode = filep->f_inode; - FAR struct ina3221_dev_s *priv = inode->i_private; - - UNUSED(priv); - return OK; -} - /**************************************************************************** * Name: ina3221_read ****************************************************************************/ @@ -362,15 +324,6 @@ static ssize_t ina3221_write(FAR struct file *filep, FAR const char *buffer, return -ENOSYS; } -/**************************************************************************** - * Name: ina3221_ioctl - ****************************************************************************/ - -static int ina3221_ioctl(FAR struct file *filep, int cmd, unsigned long arg) -{ - return -ENOTTY; -} - /**************************************************************************** * Public Functions ****************************************************************************/ diff --git a/drivers/sensors/isl29023.c b/drivers/sensors/isl29023.c index b1e145def4bb3..6d3af99a992f5 100644 --- a/drivers/sensors/isl29023.c +++ b/drivers/sensors/isl29023.c @@ -106,16 +106,13 @@ static int isl29023_set_range(FAR struct isl29023_dev_s *dev, /* Driver methods */ -static int isl29023_open(FAR struct file *filep); -static int isl29023_close(FAR struct file *filep); -static ssize_t isl29023_read(FAR struct file *filep, - FAR char *buffer, +static ssize_t isl29023_read(FAR struct file *filep, FAR char *buffer, size_t buflen); static ssize_t isl29023_write(FAR struct file *filep, FAR const char *buffer, size_t buflen); -static int isl29023_ioctl(FAR struct file *filep, - int cmd, unsigned long arg); +static int isl29023_ioctl(FAR struct file *filep, int cmd, + unsigned long arg); /**************************************************************************** * Private Data @@ -123,8 +120,8 @@ static int isl29023_ioctl(FAR struct file *filep, static const struct file_operations g_isl29023fops = { - isl29023_open, /* open */ - isl29023_close, /* close */ + NULL, /* open */ + NULL, /* close */ isl29023_read, /* read */ isl29023_write, /* write */ NULL, /* seek */ @@ -226,32 +223,6 @@ static int isl29023_read_reg(FAR struct isl29023_dev_s *dev, return ret; } -/**************************************************************************** - * Name: isl29023_open - * - * Description: - * This function is called whenever the ISL29023 device is opened. - * - ****************************************************************************/ - -static int isl29023_open(FAR struct file *filep) -{ - return OK; -} - -/**************************************************************************** - * Name: isl29023_close - * - * Description: - * This routine is called when the ISL29023 device is closed. - * - ****************************************************************************/ - -static int isl29023_close(FAR struct file *filep) -{ - return OK; -} - /**************************************************************************** * Name: isl29023_read ****************************************************************************/ diff --git a/drivers/sensors/kxtj9.c b/drivers/sensors/kxtj9.c index bc071bde267f5..ac000293646a7 100644 --- a/drivers/sensors/kxtj9.c +++ b/drivers/sensors/kxtj9.c @@ -131,9 +131,9 @@ struct kxtj9_dev_s /* I2C helpers */ static int kxtj9_reg_read(FAR struct kxtj9_dev_s *priv, uint8_t regaddr, - FAR uint8_t *regval, unsigned int len); + FAR uint8_t *regval, unsigned int len); static int kxtj9_reg_write(FAR struct kxtj9_dev_s *priv, - uint8_t regaddr, uint8_t regval); + uint8_t regaddr, uint8_t regval); /* KXTJ9 helpers */ @@ -146,14 +146,12 @@ static void kxtj9_set_mode_standby(FAR struct kxtj9_dev_s *priv); /* Character driver methods */ -static int kxtj9_open(FAR struct file *filep); -static int kxtj9_close(FAR struct file *filep); static ssize_t kxtj9_read(FAR struct file *filep, FAR char *buffer, - size_t buflen); + size_t buflen); static ssize_t kxtj9_write(FAR struct file *filep, FAR const char *buffer, size_t buflen); static int kxtj9_ioctl(FAR struct file *filep, int cmd, - unsigned long arg); + unsigned long arg); /**************************************************************************** * Private Data @@ -161,8 +159,8 @@ static int kxtj9_ioctl(FAR struct file *filep, int cmd, static const struct file_operations g_fops = { - kxtj9_open, /* open */ - kxtj9_close, /* close */ + NULL, /* open */ + NULL, /* close */ kxtj9_read, /* read */ kxtj9_write, /* write */ NULL, /* seek */ @@ -454,32 +452,6 @@ static int kxtj9_read_sensor_data(FAR struct kxtj9_dev_s *priv, return OK; } -/**************************************************************************** - * Name: kxtj9_open - * - * Description: - * This method is called when the device is opened. - * - ****************************************************************************/ - -static int kxtj9_open(FAR struct file *filep) -{ - return OK; -} - -/**************************************************************************** - * Name: kxtj9_close - * - * Description: - * This method is called when the device is closed. - * - ****************************************************************************/ - -static int kxtj9_close(FAR struct file *filep) -{ - return OK; -} - /**************************************************************************** * Name: kxtj9_read * diff --git a/drivers/sensors/lis2dh.c b/drivers/sensors/lis2dh.c index b379bea518647..fd10b9536e3f6 100644 --- a/drivers/sensors/lis2dh.c +++ b/drivers/sensors/lis2dh.c @@ -754,7 +754,7 @@ static void lis2dh_notify(FAR struct lis2dh_dev_s *priv) if (fds) { fds->revents |= POLLIN; - lis2dh_dbg("lis2dh: Report events: %02x\n", fds->revents); + lis2dh_dbg("lis2dh: Report events: %08" PRIx32 "\n", fds->revents); nxsem_post(fds->sem); } } diff --git a/drivers/sensors/lis3dsh.c b/drivers/sensors/lis3dsh.c index ca3e337dcc09d..c5a13bf29cf56 100644 --- a/drivers/sensors/lis3dsh.c +++ b/drivers/sensors/lis3dsh.c @@ -92,7 +92,6 @@ static ssize_t lis3dsh_read(FAR struct file *, FAR char *buffer, size_t buflen); static ssize_t lis3dsh_write(FAR struct file *filep, FAR const char *buffer, size_t buflen); -static int lis3dsh_ioctl(FAR struct file *filep, int cmd, unsigned long arg); /**************************************************************************** * Private Data @@ -105,7 +104,7 @@ static const struct file_operations g_lis3dsh_fops = lis3dsh_read, /* read */ lis3dsh_write, /* write */ NULL, /* seek */ - lis3dsh_ioctl, /* ioctl */ + NULL, /* ioctl */ NULL /* poll */ #ifndef CONFIG_DISABLE_PSEUDOFS_OPERATIONS , NULL /* unlink */ @@ -495,27 +494,6 @@ static ssize_t lis3dsh_write(FAR struct file *filep, FAR const char *buffer, return -ENOSYS; } -/**************************************************************************** - * Name: lis3dsh_ioctl - ****************************************************************************/ - -static int lis3dsh_ioctl(FAR struct file *filep, int cmd, unsigned long arg) -{ - int ret = OK; - - switch (cmd) - { - /* Command was not recognized */ - - default: - snerr("ERROR: Unrecognized cmd: %d\n", cmd); - ret = -ENOTTY; - break; - } - - return ret; -} - /**************************************************************************** * Public Functions ****************************************************************************/ diff --git a/drivers/sensors/lis3mdl.c b/drivers/sensors/lis3mdl.c index e28f72320777b..e172b8f7605aa 100644 --- a/drivers/sensors/lis3mdl.c +++ b/drivers/sensors/lis3mdl.c @@ -72,28 +72,27 @@ struct lis3mdl_dev_s static void lis3mdl_read_register(FAR struct lis3mdl_dev_s *dev, uint8_t const reg_addr, - uint8_t * reg_data); + uint8_t *reg_data); static void lis3mdl_write_register(FAR struct lis3mdl_dev_s *dev, uint8_t const reg_addr, uint8_t const reg_data); static void lis3mdl_reset(FAR struct lis3mdl_dev_s *dev); static void lis3mdl_read_measurement_data(FAR struct lis3mdl_dev_s *dev); static void lis3mdl_read_magnetic_data(FAR struct lis3mdl_dev_s *dev, - uint16_t * x_mag, uint16_t * y_mag, - uint16_t * z_mag); + uint16_t *x_mag, uint16_t *y_mag, + uint16_t *z_mag); static void lis3mdl_read_temperature(FAR struct lis3mdl_dev_s *dev, - uint16_t * temperature); + uint16_t *temperature); static int lis3mdl_interrupt_handler(int irq, FAR void *context); static void lis3mdl_worker(FAR void *arg); static int lis3mdl_open(FAR struct file *filep); static int lis3mdl_close(FAR struct file *filep); -static ssize_t lis3mdl_read(FAR struct file *, FAR char *, size_t); +static ssize_t lis3mdl_read(FAR struct file *filep, FAR char *buffer, + size_t buflen); static ssize_t lis3mdl_write(FAR struct file *filep, FAR const char *buffer, size_t buflen); -static int lis3mdl_ioctl(FAR struct file *filep, - int cmd, unsigned long arg); /**************************************************************************** * Private Data @@ -106,7 +105,7 @@ static const struct file_operations g_lis3mdl_fops = lis3mdl_read, /* read */ lis3mdl_write, /* write */ NULL, /* seek */ - lis3mdl_ioctl, /* ioctl */ + NULL, /* ioctl */ NULL /* poll */ #ifndef CONFIG_DISABLE_PSEUDOFS_OPERATIONS , NULL /* unlink */ @@ -539,27 +538,6 @@ static ssize_t lis3mdl_write(FAR struct file *filep, FAR const char *buffer, return -ENOSYS; } -/**************************************************************************** - * Name: lis3mdl_ioctl - ****************************************************************************/ - -static int lis3mdl_ioctl(FAR struct file *filep, int cmd, unsigned long arg) -{ - int ret = OK; - - switch (cmd) - { - /* Command was not recognized */ - - default: - snerr("ERROR: Unrecognized cmd: %d\n", cmd); - ret = -ENOTTY; - break; - } - - return ret; -} - /**************************************************************************** * Public Functions ****************************************************************************/ diff --git a/drivers/sensors/lm75.c b/drivers/sensors/lm75.c index f18b54a107c25..6930a0a4d66ab 100644 --- a/drivers/sensors/lm75.c +++ b/drivers/sensors/lm75.c @@ -83,8 +83,6 @@ static int lm75_writeconf(FAR struct lm75_dev_s *priv, uint8_t conf); /* Character driver methods */ -static int lm75_open(FAR struct file *filep); -static int lm75_close(FAR struct file *filep); static ssize_t lm75_read(FAR struct file *filep, FAR char *buffer, size_t buflen); static ssize_t lm75_write(FAR struct file *filep, FAR const char *buffer, @@ -98,8 +96,8 @@ static int lm75_ioctl(FAR struct file *filep, int cmd, static const struct file_operations g_lm75fops = { - lm75_open, /* open */ - lm75_close, /* close */ + NULL, /* open */ + NULL, /* close */ lm75_read, /* read */ lm75_write, /* write */ NULL, /* seek */ @@ -338,32 +336,6 @@ static int lm75_writeconf(FAR struct lm75_dev_s *priv, uint8_t conf) return lm75_i2c_write(priv, buffer, 2); } -/**************************************************************************** - * Name: lm75_open - * - * Description: - * This function is called whenever the LM-75 device is opened. - * - ****************************************************************************/ - -static int lm75_open(FAR struct file *filep) -{ - return OK; -} - -/**************************************************************************** - * Name: lm75_close - * - * Description: - * This routine is called when the LM-75 device is closed. - * - ****************************************************************************/ - -static int lm75_close(FAR struct file *filep) -{ - return OK; -} - /**************************************************************************** * Name: lm75_read ****************************************************************************/ diff --git a/drivers/sensors/lm92.c b/drivers/sensors/lm92.c index dc6cd75db1bd1..662b7e67aefa6 100644 --- a/drivers/sensors/lm92.c +++ b/drivers/sensors/lm92.c @@ -82,14 +82,12 @@ static int lm92_writeconf(FAR struct lm92_dev_s *priv, uint8_t conf); /* Character driver methods */ -static int lm92_open(FAR struct file *filep); -static int lm92_close(FAR struct file *filep); static ssize_t lm92_read(FAR struct file *filep, FAR char *buffer, size_t buflen); static ssize_t lm92_write(FAR struct file *filep, FAR const char *buffer, size_t buflen); -static int lm92_ioctl(FAR struct file *filep, - int cmd, unsigned long arg); +static int lm92_ioctl(FAR struct file *filep, int cmd, + unsigned long arg); /**************************************************************************** * Private Data @@ -97,8 +95,8 @@ static int lm92_ioctl(FAR struct file *filep, static const struct file_operations g_lm92fops = { - lm92_open, /* open */ - lm92_close, /* close */ + NULL, /* open */ + NULL, /* close */ lm92_read, /* read */ lm92_write, /* write */ NULL, /* seek */ @@ -377,32 +375,6 @@ static int lm92_readid(FAR struct lm92_dev_s *priv, FAR uint16_t *id) return OK; } -/**************************************************************************** - * Name: lm92_open - * - * Description: - * This function is called whenever the LM92 device is opened. - * - ****************************************************************************/ - -static int lm92_open(FAR struct file *filep) -{ - return OK; -} - -/**************************************************************************** - * Name: lm92_close - * - * Description: - * This function is called whenever the LM92 device is closed. - * - ****************************************************************************/ - -static int lm92_close(FAR struct file *filep) -{ - return OK; -} - /**************************************************************************** * Name: lm92_read ****************************************************************************/ diff --git a/drivers/sensors/lsm303agr.c b/drivers/sensors/lsm303agr.c index 19f9ecfbc20e6..2efc7a31dc6b6 100644 --- a/drivers/sensors/lsm303agr.c +++ b/drivers/sensors/lsm303agr.c @@ -99,10 +99,8 @@ static int lsm303agr_selftest(FAR struct lsm303agr_dev_s *priv, /* Character Driver Methods */ -static int lsm303agr_open(FAR struct file *filep); -static int lsm303agr_close(FAR struct file *filep); -static ssize_t lsm303agr_read(FAR struct file *filep, - FAR char *buffer, size_t buflen); +static ssize_t lsm303agr_read(FAR struct file *filep, FAR char *buffer, + size_t buflen); static ssize_t lsm303agr_write(FAR struct file *filep, FAR const char *buffer, size_t buflen); static int lsm303agr_ioctl(FAR struct file *filep, int cmd, @@ -126,8 +124,8 @@ static double g_magnetofactor = 0; static const struct file_operations g_fops = { - lsm303agr_open, /* open */ - lsm303agr_close, /* close */ + NULL, /* open */ + NULL, /* close */ lsm303agr_read, /* read */ lsm303agr_write, /* write */ NULL, /* seek */ @@ -933,33 +931,6 @@ static int lsm303agr_sensor_read(FAR struct lsm303agr_dev_s *priv, return OK; } -/**************************************************************************** - * Name: lsm303agr_open - * - * Description: - * This method is called when the device is opened. - * - ****************************************************************************/ - -static int lsm303agr_open(FAR struct file *filep) -{ - sninfo("Device LSM303AGR opened!!\n"); - return OK; -} - -/**************************************************************************** - * Name: lsm303agr_close - * - * Description: - * This method is called when the device is closed. - * - ****************************************************************************/ - -static int lsm303agr_close(FAR struct file *filep) -{ - return OK; -} - /**************************************************************************** * Name: lsm303agr_read * diff --git a/drivers/sensors/lsm6dsl.c b/drivers/sensors/lsm6dsl.c index adfde3659cc21..4db852ded15fe 100644 --- a/drivers/sensors/lsm6dsl.c +++ b/drivers/sensors/lsm6dsl.c @@ -107,10 +107,8 @@ static int lsm6dsl_selftest(FAR struct lsm6dsl_dev_s *priv, uint32_t mode); /* Character Driver Methods */ -static int lsm6dsl_open(FAR struct file *filep); -static int lsm6dsl_close(FAR struct file *filep); -static ssize_t lsm6dsl_read(FAR struct file *filep, - FAR char *buffer, size_t buflen); +static ssize_t lsm6dsl_read(FAR struct file *filep, FAR char *buffer, + size_t buflen); static ssize_t lsm6dsl_write(FAR struct file *filep, FAR const char *buffer, size_t buflen); static int lsm6dsl_ioctl(FAR struct file *filep, int cmd, @@ -134,8 +132,8 @@ static double g_gyrofactor = 0; static const struct file_operations g_fops = { - lsm6dsl_open, /* open */ - lsm6dsl_close, /* close */ + NULL, /* open */ + NULL, /* close */ lsm6dsl_read, /* read */ lsm6dsl_write, /* write */ NULL, /* seek */ @@ -956,33 +954,6 @@ static int lsm6dsl_sensor_read(FAR struct lsm6dsl_dev_s *priv, return OK; } -/**************************************************************************** - * Name: lsm6dsl_open - * - * Description: - * This method is called when the device is opened. - * - ****************************************************************************/ - -static int lsm6dsl_open(FAR struct file *filep) -{ - sninfo("Device LSM6DSL opened!!\n"); - return OK; -} - -/**************************************************************************** - * Name: lsm6dsl_close - * - * Description: - * This method is called when the device is closed. - * - ****************************************************************************/ - -static int lsm6dsl_close(FAR struct file *filep) -{ - return OK; -} - /**************************************************************************** * Name: lsm6dsl_read * diff --git a/drivers/sensors/lsm9ds1.c b/drivers/sensors/lsm9ds1.c index 2acb355368a6c..66d0d0b87ac4a 100644 --- a/drivers/sensors/lsm9ds1.c +++ b/drivers/sensors/lsm9ds1.c @@ -562,8 +562,6 @@ static int lsm9ds1mag_setsamplerate(FAR struct lsm9ds1_dev_s *priv, /* Character Driver Methods */ -static int lsm9ds1_open(FAR struct file *filep); -static int lsm9ds1_close(FAR struct file *filep); static ssize_t lsm9ds1_read(FAR struct file *filep, FAR char *buffer, size_t buflen); static ssize_t lsm9ds1_write(FAR struct file *filep, FAR const char *buffer, @@ -584,8 +582,8 @@ static int lsm9ds1_register(FAR const char *devpath, static const struct file_operations g_fops = { - lsm9ds1_open, /* open */ - lsm9ds1_close, /* close */ + NULL, /* open */ + NULL, /* close */ lsm9ds1_read, /* read */ lsm9ds1_write, /* write */ NULL, /* seek */ @@ -1195,32 +1193,6 @@ static int lsm9ds1mag_setsamplerate(FAR struct lsm9ds1_dev_s *priv, LSM9DS1_CTRL_REG1_M_DO_MASK, setbits); } -/**************************************************************************** - * Name: lsm9ds1_open - * - * Description: - * This method is called when the device is opened. - * - ****************************************************************************/ - -static int lsm9ds1_open(FAR struct file *filep) -{ - return OK; -} - -/**************************************************************************** - * Name: lsm9ds1_close - * - * Description: - * This method is called when the device is closed. - * - ****************************************************************************/ - -static int lsm9ds1_close(FAR struct file *filep) -{ - return OK; -} - /**************************************************************************** * Name: lsm9ds1_read * diff --git a/drivers/sensors/ltc4151.c b/drivers/sensors/ltc4151.c index b4f7d5d2eda96..879a9219489c2 100644 --- a/drivers/sensors/ltc4151.c +++ b/drivers/sensors/ltc4151.c @@ -74,14 +74,10 @@ static int ltc4151_readpower(FAR struct ltc4151_dev_s *priv, /* Character driver methods */ -static int ltc4151_open(FAR struct file *filep); -static int ltc4151_close(FAR struct file *filep); static ssize_t ltc4151_read(FAR struct file *filep, FAR char *buffer, size_t buflen); static ssize_t ltc4151_write(FAR struct file *filep, FAR const char *buffer, size_t buflen); -static int ltc4151_ioctl(FAR struct file *filep, int cmd, - unsigned long arg); /**************************************************************************** * Private Data @@ -89,12 +85,12 @@ static int ltc4151_ioctl(FAR struct file *filep, int cmd, static const struct file_operations g_ltc4151fops = { - ltc4151_open, /* open */ - ltc4151_close, /* close */ + NULL, /* open */ + NULL, /* close */ ltc4151_read, /* read */ ltc4151_write, /* write */ NULL, /* seek */ - ltc4151_ioctl, /* ioctl */ + NULL, /* ioctl */ NULL /* poll */ #ifndef CONFIG_DISABLE_PSEUDOFS_OPERATIONS , NULL /* unlink */ @@ -203,32 +199,6 @@ static int ltc4151_readpower(FAR struct ltc4151_dev_s *priv, return OK; } -/**************************************************************************** - * Name: ltc4151_open - * - * Description: - * This function is called whenever the LTC4151 device is opened. - * - ****************************************************************************/ - -static int ltc4151_open(FAR struct file *filep) -{ - return OK; -} - -/**************************************************************************** - * Name: ltc4151_close - * - * Description: - * This routine is called when the LTC4151 device is closed. - * - ****************************************************************************/ - -static int ltc4151_close(FAR struct file *filep) -{ - return OK; -} - /**************************************************************************** * Name: ltc4151_read ****************************************************************************/ @@ -283,15 +253,6 @@ static ssize_t ltc4151_write(FAR struct file *filep, FAR const char *buffer, return -ENOSYS; } -/**************************************************************************** - * Name: ltc4151_ioctl - ****************************************************************************/ - -static int ltc4151_ioctl(FAR struct file *filep, int cmd, unsigned long arg) -{ - return -ENOTTY; -} - /**************************************************************************** * Public Functions ****************************************************************************/ diff --git a/drivers/sensors/max31855.c b/drivers/sensors/max31855.c index c05a7aeb40e40..7a5a16487214c 100644 --- a/drivers/sensors/max31855.c +++ b/drivers/sensors/max31855.c @@ -77,8 +77,6 @@ static void max31855_unlock(FAR struct spi_dev_s *spi); /* Character driver methods */ -static int max31855_open(FAR struct file *filep); -static int max31855_close(FAR struct file *filep); static ssize_t max31855_read(FAR struct file *filep, FAR char *buffer, size_t buflen); static ssize_t max31855_write(FAR struct file *filep, FAR const char *buffer, @@ -90,8 +88,8 @@ static ssize_t max31855_write(FAR struct file *filep, FAR const char *buffer, static const struct file_operations g_max31855fops = { - max31855_open, /* open */ - max31855_close, /* close */ + NULL, /* open */ + NULL, /* close */ max31855_read, /* read */ max31855_write, /* write */ NULL, /* seek */ @@ -136,32 +134,6 @@ static void max31855_unlock(FAR struct spi_dev_s *spi) SPI_LOCK(spi, false); } -/**************************************************************************** - * Name: max31855_open - * - * Description: - * This function is called whenever the MAX31855 device is opened. - * - ****************************************************************************/ - -static int max31855_open(FAR struct file *filep) -{ - return OK; -} - -/**************************************************************************** - * Name: max31855_close - * - * Description: - * This routine is called when the MAX31855 device is closed. - * - ****************************************************************************/ - -static int max31855_close(FAR struct file *filep) -{ - return OK; -} - /**************************************************************************** * Name: max31855_read ****************************************************************************/ diff --git a/drivers/sensors/max44009.c b/drivers/sensors/max44009.c index 0744f11cc6733..fdb7babddfd0b 100644 --- a/drivers/sensors/max44009.c +++ b/drivers/sensors/max44009.c @@ -770,7 +770,7 @@ static void max44009_notify(FAR struct max44009_dev_s *priv) if (fds) { fds->revents |= POLLIN; - max44009_dbg("Report events: %02x\n", fds->revents); + max44009_dbg("Report events: %08" PRIx32 "\n", fds->revents); nxsem_post(fds->sem); priv->int_pending = false; } diff --git a/drivers/sensors/max6675.c b/drivers/sensors/max6675.c index 7e57d33bf6ee6..d2c2a0e0f17e7 100644 --- a/drivers/sensors/max6675.c +++ b/drivers/sensors/max6675.c @@ -73,9 +73,8 @@ static void max6675_unlock(FAR struct spi_dev_s *spi); /* Character driver methods */ -static int max6675_open(FAR struct file *filep); -static int max6675_close(FAR struct file *filep); -static ssize_t max6675_read(FAR struct file *, FAR char *, size_t); +static ssize_t max6675_read(FAR struct file *filep, FAR char *buffer, + size_t buflen); static ssize_t max6675_write(FAR struct file *filep, FAR const char *buffer, size_t buflen); @@ -85,8 +84,8 @@ static ssize_t max6675_write(FAR struct file *filep, FAR const char *buffer, static const struct file_operations g_max6675fops = { - max6675_open, /* open */ - max6675_close, /* close */ + NULL, /* open */ + NULL, /* close */ max6675_read, /* read */ max6675_write, /* write */ NULL, /* seek */ @@ -131,38 +130,12 @@ static void max6675_unlock(FAR struct spi_dev_s *spi) SPI_LOCK(spi, false); } -/**************************************************************************** - * Name: max6675_open - * - * Description: - * This function is called whenever the MAX6675 device is opened. - * - ****************************************************************************/ - -static int max6675_open(FAR struct file *filep) -{ - return OK; -} - -/**************************************************************************** - * Name: max6675_close - * - * Description: - * This routine is called when the MAX6675 device is closed. - * - ****************************************************************************/ - -static int max6675_close(FAR struct file *filep) -{ - return OK; -} - /**************************************************************************** * Name: max6675_read ****************************************************************************/ -static ssize_t max6675_read(FAR struct file *filep, - FAR char *buffer, size_t buflen) +static ssize_t max6675_read(FAR struct file *filep, FAR char *buffer, + size_t buflen) { FAR struct inode *inode = filep->f_inode; FAR struct max6675_dev_s *priv = inode->i_private; diff --git a/drivers/sensors/mb7040.c b/drivers/sensors/mb7040.c index 4bc22b01f3462..951ebc2c48fa6 100644 --- a/drivers/sensors/mb7040.c +++ b/drivers/sensors/mb7040.c @@ -68,8 +68,6 @@ static int mb7040_changeaddr(FAR struct mb7040_dev_s *priv, uint8_t addr); /* Character Driver Methods */ -static int mb7040_open(FAR struct file *filep); -static int mb7040_close(FAR struct file *filep); static ssize_t mb7040_read(FAR struct file *filep, FAR char *buffer, size_t buflen); static ssize_t mb7040_write(FAR struct file *filep, FAR const char *buffer, @@ -83,8 +81,8 @@ static int mb7040_ioctl(FAR struct file *filep, int cmd, static const struct file_operations g_fops = { - mb7040_open, /* open */ - mb7040_close, /* close */ + NULL, /* open */ + NULL, /* close */ mb7040_read, /* read */ mb7040_write, /* write */ NULL, /* seek */ @@ -215,32 +213,6 @@ static int mb7040_changeaddr(FAR struct mb7040_dev_s *priv, uint8_t addr) return ret; } -/**************************************************************************** - * Name: mb7040_open - * - * Description: - * This method is called when the device is opened. - * - ****************************************************************************/ - -static int mb7040_open(FAR struct file *filep) -{ - return OK; -} - -/**************************************************************************** - * Name: mb7040_close - * - * Description: - * This method is called when the device is closed. - * - ****************************************************************************/ - -static int mb7040_close(FAR struct file *filep) -{ - return OK; -} - /**************************************************************************** * Name: mb7040_read * diff --git a/drivers/sensors/mcp9844.c b/drivers/sensors/mcp9844.c index cfb990136b60b..9d0960b5a8be2 100644 --- a/drivers/sensors/mcp9844.c +++ b/drivers/sensors/mcp9844.c @@ -61,14 +61,13 @@ struct mcp9844_dev_s /* I2C helper functions */ static int mcp9844_read_u16(FAR struct mcp9844_dev_s *priv, - uint8_t const regaddr, FAR uint16_t *value); + uint8_t const regaddr, FAR uint16_t *value); static int mcp9844_write_u16(FAR struct mcp9844_dev_s *priv, - uint8_t const regaddr, uint16_t const regval); + uint8_t const regaddr, + uint16_t const regval); /* Character driver methods */ -static int mcp9844_open(FAR struct file *filep); -static int mcp9844_close(FAR struct file *filep); static ssize_t mcp9844_read(FAR struct file *filep, FAR char *buffer, size_t buflen); static ssize_t mcp9844_write(FAR struct file *filep, FAR const char *buffer, @@ -82,8 +81,8 @@ static int mcp9844_ioctl(FAR struct file *filep, int cmd, static const struct file_operations g_mcp9844_fops = { - mcp9844_open, /* open */ - mcp9844_close, /* close */ + NULL, /* open */ + NULL, /* close */ mcp9844_read, /* read */ mcp9844_write, /* write */ NULL, /* seek */ @@ -180,32 +179,6 @@ static int mcp9844_write_u16(FAR struct mcp9844_dev_s *priv, return i2c_write(priv->i2c, &config, buffer, BUFFER_SIZE); } -/**************************************************************************** - * Name: mcp9844_open - * - * Description: - * This function is called whenever the MCP9844 device is opened. - * - ****************************************************************************/ - -static int mcp9844_open(FAR struct file *filep) -{ - return OK; -} - -/**************************************************************************** - * Name: mcp9844_close - * - * Description: - * This routine is called when the MCP9844 device is closed. - * - ****************************************************************************/ - -static int mcp9844_close(FAR struct file *filep) -{ - return OK; -} - /**************************************************************************** * Name: mcp9844_read ****************************************************************************/ diff --git a/drivers/sensors/mlx90393.c b/drivers/sensors/mlx90393.c index bd94328e42d95..0eac05a9377e2 100644 --- a/drivers/sensors/mlx90393.c +++ b/drivers/sensors/mlx90393.c @@ -91,9 +91,6 @@ static ssize_t mlx90393_read(FAR struct file *, FAR char *, size_t); static ssize_t mlx90393_write(FAR struct file *filep, FAR const char *buffer, size_t buflen); -static int mlx90393_ioctl(FAR struct file *filep, - int cmd, - unsigned long arg); /**************************************************************************** * Private Data @@ -106,7 +103,7 @@ static const struct file_operations g_mlx90393_fops = mlx90393_read, /* read */ mlx90393_write, /* write */ NULL, /* seek */ - mlx90393_ioctl, /* ioctl */ + NULL, /* ioctl */ NULL /* poll */ #ifndef CONFIG_DISABLE_PSEUDOFS_OPERATIONS , NULL /* unlink */ @@ -519,27 +516,6 @@ static ssize_t mlx90393_write(FAR struct file *filep, FAR const char *buffer, return -ENOSYS; } -/**************************************************************************** - * Name: mlx90393_ioctl - ****************************************************************************/ - -static int mlx90393_ioctl(FAR struct file *filep, int cmd, unsigned long arg) -{ - int ret = OK; - - switch (cmd) - { - /* Command was not recognized */ - - default: - snerr("ERROR: Unrecognized cmd: %d\n", cmd); - ret = -ENOTTY; - break; - } - - return ret; -} - /**************************************************************************** * Public Functions ****************************************************************************/ diff --git a/drivers/sensors/mlx90614.c b/drivers/sensors/mlx90614.c index eef043a4b5286..154b03544fb7c 100644 --- a/drivers/sensors/mlx90614.c +++ b/drivers/sensors/mlx90614.c @@ -1,32 +1,20 @@ /**************************************************************************** * drivers/sensors/mlx90614.c * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * 3. Neither the name NuttX nor the names of its contributors may be - * used to endorse or promote products derived from this software - * without specific prior written permission. + * http://www.apache.org/licenses/LICENSE-2.0 * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. * ****************************************************************************/ @@ -78,20 +66,18 @@ struct mlx90614_dev_s /* I2C Helpers */ static int mlx90614_read_word(FAR struct mlx90614_dev_s *priv, - uint8_t cmd, FAR uint16_t *regval); + uint8_t cmd, FAR uint16_t *regval); static int mlx90614_write_word(FAR struct mlx90614_dev_s *priv, - uint8_t cmd, uint16_t regval); + uint8_t cmd, uint16_t regval); /* Character driver methods */ -static int mlx90614_open(FAR struct file *filep); -static int mlx90614_close(FAR struct file *filep); static ssize_t mlx90614_read(FAR struct file *filep, FAR char *buffer, - size_t buflen); + size_t buflen); static ssize_t mlx90614_write(FAR struct file *filep, FAR const char *buffer, size_t buflen); static int mlx90614_ioctl(FAR struct file *filep, int cmd, - unsigned long arg); + unsigned long arg); /**************************************************************************** * Private Data @@ -99,8 +85,8 @@ static int mlx90614_ioctl(FAR struct file *filep, int cmd, static const struct file_operations g_mlx90614_fops = { - mlx90614_open, /* open */ - mlx90614_close, /* close */ + NULL, /* open */ + NULL, /* close */ mlx90614_read, /* read */ mlx90614_write, /* write */ NULL, /* seek */ @@ -265,32 +251,6 @@ static int mlx90614_write_word(FAR struct mlx90614_dev_s *priv, uint8_t cmd, return OK; } -/**************************************************************************** - * Name: mlx90614_open - * - * Description: - * This function is called whenever the MLX90614 device is opened. - * - ****************************************************************************/ - -static int mlx90614_open(FAR struct file *filep) -{ - return OK; -} - -/**************************************************************************** - * Name: mlx90614_close - * - * Description: - * This routine is called when the MLX90614 device is closed. - * - ****************************************************************************/ - -static int mlx90614_close(FAR struct file *filep) -{ - return OK; -} - /**************************************************************************** * Name: mlx90614_read ****************************************************************************/ diff --git a/drivers/sensors/mpl115a.c b/drivers/sensors/mpl115a.c index b8593857261f1..1888fc14dd175 100644 --- a/drivers/sensors/mpl115a.c +++ b/drivers/sensors/mpl115a.c @@ -72,8 +72,6 @@ static int mpl115a_getpressure(FAR struct mpl115a_dev_s *priv); /* Character driver methods */ -static int mpl115a_open(FAR struct file *filep); -static int mpl115a_close(FAR struct file *filep); static ssize_t mpl115a_read(FAR struct file *filep, FAR char *buffer, size_t buflen); static ssize_t mpl115a_write(FAR struct file *filep, FAR const char *buffer, @@ -85,8 +83,8 @@ static ssize_t mpl115a_write(FAR struct file *filep, FAR const char *buffer, static const struct file_operations g_mpl115afops = { - mpl115a_open, /* open */ - mpl115a_close, /* close */ + NULL, /* open */ + NULL, /* close */ mpl115a_read, /* read */ mpl115a_write, /* write */ NULL, /* seek */ @@ -296,32 +294,6 @@ static int mpl115a_getpressure(FAR struct mpl115a_dev_s *priv) return pressure; } -/**************************************************************************** - * Name: mpl115a_open - * - * Description: - * This function is called whenever the MPL115A1 device is opened. - * - ****************************************************************************/ - -static int mpl115a_open(FAR struct file *filep) -{ - return OK; -} - -/**************************************************************************** - * Name: mpl115a_close - * - * Description: - * This routine is called when the LM-75 device is closed. - * - ****************************************************************************/ - -static int mpl115a_close(FAR struct file *filep) -{ - return OK; -} - /**************************************************************************** * Name: mpl115a_read ****************************************************************************/ diff --git a/drivers/sensors/mpu60x0.c b/drivers/sensors/mpu60x0.c index c0ed310cfffd6..134bee0a85f12 100644 --- a/drivers/sensors/mpu60x0.c +++ b/drivers/sensors/mpu60x0.c @@ -255,7 +255,6 @@ static ssize_t mpu_read(FAR struct file *filep, FAR char *buf, size_t len); static ssize_t mpu_write(FAR struct file *filep, FAR const char *buf, size_t len); static off_t mpu_seek(FAR struct file *filep, off_t offset, int whence); -static int mpu_ioctl(FAR struct file *filep, int cmd, unsigned long arg); /**************************************************************************** * Private Data @@ -268,7 +267,7 @@ static const struct file_operations g_mpu_fops = mpu_read, /* read */ mpu_write, /* write */ mpu_seek, /* seek */ - mpu_ioctl, /* ioctl */ + NULL, /* ioctl */ NULL /* poll */ #ifndef CONFIG_DISABLE_PSEUDOFS_OPERATIONS , NULL /* unlink */ @@ -913,25 +912,6 @@ static off_t mpu_seek(FAR struct file *filep, off_t offset, int whence) return 0; } -/**************************************************************************** - * Name: mpu60x0_ioctl - ****************************************************************************/ - -static int mpu_ioctl(FAR struct file *filep, int cmd, unsigned long arg) -{ - FAR struct inode *inode = filep->f_inode; - FAR struct mpu_dev_s *dev = inode->i_private; - - UNUSED(inode); - UNUSED(dev); - - snerr("ERROR: %p %p\n", inode, dev); - - /* ENOTTY is the standard return if an IOCTL command is not supported. */ - - return -ENOTTY; -} - /**************************************************************************** * Public Functions ****************************************************************************/ diff --git a/drivers/sensors/ms58xx.c b/drivers/sensors/ms58xx.c index 163c6625e3b73..76006b081e951 100644 --- a/drivers/sensors/ms58xx.c +++ b/drivers/sensors/ms58xx.c @@ -140,8 +140,6 @@ static int ms58xx_measure(FAR struct ms58xx_dev_s *priv); /* Character Driver Methods */ -static int ms58xx_open(FAR struct file *filep); -static int ms58xx_close(FAR struct file *filep); static ssize_t ms58xx_read(FAR struct file *filep, FAR char *buffer, size_t buflen); static ssize_t ms58xx_write(FAR struct file *filep, FAR const char *buffer, @@ -155,8 +153,8 @@ static int ms58xx_ioctl(FAR struct file *filep, int cmd, static const struct file_operations g_fops = { - ms58xx_open, /* open */ - ms58xx_close, /* close */ + NULL, /* open */ + NULL, /* close */ ms58xx_read, /* read */ ms58xx_write, /* write */ NULL, /* seek */ @@ -754,32 +752,6 @@ static int ms58xx_measure(FAR struct ms58xx_dev_s *priv) return ret; } -/**************************************************************************** - * Name: ms58xx_open - * - * Description: - * This method is called when the device is opened. - * - ****************************************************************************/ - -static int ms58xx_open(FAR struct file *filep) -{ - return OK; -} - -/**************************************************************************** - * Name: ms58xx_close - * - * Description: - * This method is called when the device is closed. - * - ****************************************************************************/ - -static int ms58xx_close(FAR struct file *filep) -{ - return OK; -} - /**************************************************************************** * Name: ms58xx_read * diff --git a/drivers/sensors/scd30.c b/drivers/sensors/scd30.c index 352c669f6cd77..6c273a9643c58 100644 --- a/drivers/sensors/scd30.c +++ b/drivers/sensors/scd30.c @@ -835,7 +835,7 @@ static int scd30_ioctl(FAR struct file *filep, int cmd, unsigned long arg) case SNIOC_SET_INTERVAL: { - if (arg < 2 && arg > 1800) + if (arg < 2 || arg > 1800) { ret = -EINVAL; break; @@ -851,7 +851,7 @@ static int scd30_ioctl(FAR struct file *filep, int cmd, unsigned long arg) case SNIOC_SET_TEMP_OFFSET: { - if (arg < 0 && arg > UINT16_MAX) + if (arg > UINT16_MAX) { ret = -EINVAL; break; @@ -867,7 +867,7 @@ static int scd30_ioctl(FAR struct file *filep, int cmd, unsigned long arg) case SNIOC_SET_PRESSURE_COMP: { - if (arg != 0 && arg < 700 && arg > 1200) + if (arg != 0 && (arg < 700 || arg > 1200)) { ret = -EINVAL; break; @@ -891,7 +891,7 @@ static int scd30_ioctl(FAR struct file *filep, int cmd, unsigned long arg) case SNIOC_SET_ALTITUDE_COMP: { - if (arg < 0 && arg > UINT16_MAX) + if (arg > UINT16_MAX) { ret = -EINVAL; break; @@ -908,7 +908,7 @@ static int scd30_ioctl(FAR struct file *filep, int cmd, unsigned long arg) case SNIOC_SET_FRC: { - if (arg < 0 && arg > UINT16_MAX) + if (arg > UINT16_MAX) { ret = -EINVAL; break; diff --git a/drivers/sensors/scd41.c b/drivers/sensors/scd41.c new file mode 100644 index 0000000000000..1009a765a2c3c --- /dev/null +++ b/drivers/sensors/scd41.c @@ -0,0 +1,1030 @@ +/**************************************************************************** + * drivers/sensors/scd41.c + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#if defined(CONFIG_SENSORS_SCD41) + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +#ifdef CONFIG_SCD41_DEBUG +# define scd41_dbg(x, ...) _info(x, ##__VA_ARGS__) +#else +# define scd41_dbg(x, ...) sninfo(x, ##__VA_ARGS__) +#endif + +#ifndef CONFIG_SCD41_I2C_FREQUENCY +# define CONFIG_SCD41_I2C_FREQUENCY 100000 +#endif + +#define SCD41_I2C_RETRIES 3 + +/* SCD41 command words */ + +#define SCD41_CMD_START_MEASUREMENT 0x21b1 +#define SCD41_CMD_STOP_MEASUREMENT 0x3f86 +#define SCD41_CMD_GET_DATA_READY 0xe4b8 +#define SCD41_CMD_READ_MEASUREMENT 0xec05 +#define SCD41_CMD_SET_ASC 0x2416 +#define SCD41_CMD_GET_ASC 0x2313 +#define SCD41_CMD_SET_FRC 0x362f +#define SCD41_CMD_SET_TEMP_OFFSET 0x241d +#define SCD41_CMD_GET_TEMP_OFFSET 0x2318 +#define SCD41_CMD_SET_ALT_COMPENSATION 0x2427 +#define SCD41_CMD_GET_ALT_COMPENSATION 0x2322 +#define SCD41_CMD_SET_PRESSURE_COMP 0xe000 +#define SCD41_CMD_SOFT_RESET 0x3646 +#define SCD41_CMD_LOWPOWER_MODE 0x21ac +#define SCD41_CMD_PERSIST_SETTINGS 0x3615 +#define SCD41_CMD_GET_SERIAL_NUMBER 0x3682 +#define SCD41_CMD_START_SELFTEST 0x3639 +#define SCD41_CMD_FACTORY_RESET 0x3632 +#define SCD41_CMD_ONESHOT_MEASUREMENT 0x219d +#define SCD41_CMD_ONESHOT_MEASURE_RHT 0x2196 + +#define SCD41_DEFAULT_MEASUREMENT_INTERVAL 5 /* seconds */ +#define SCD41_DEFAULT_PRESSURE_COMPENSATION 0 +#define SCD41_DEFAULT_ALTITUDE_COMPENSATION 0 +#define SCD41_DEFAULT_TEMPERATURE_OFFSET 0 + +/**************************************************************************** + * Private + ****************************************************************************/ + +struct scd41_dev_s +{ +#ifdef CONFIG_SCD41_I2C + FAR struct i2c_master_s *i2c; /* I2C interface */ + uint8_t addr; /* I2C address */ +#endif + bool valid; /* If cached readings are valid */ + bool started; /* If continuous measurement is enabled */ +#ifndef CONFIG_DISABLE_PSEUDOFS_OPERATIONS + bool unlinked; /* True, driver has been unlinked */ +#endif + struct timespec last_update; /* Last time when sensor was read */ + float co2; /* Cached CO₂ (PPM) */ + float temperature; /* Cached temperature (°C) */ + float humidity; /* Cached humidity (RH%) */ +#ifndef CONFIG_DISABLE_PSEUDOFS_OPERATIONS + int16_t crefs; /* Number of open references */ +#endif + sem_t devsem; + uint16_t pressure_comp; /* Pressure compensation in mbar (non-zero + * value overrides altitude compensation). */ + uint16_t altitude_comp; /* Altitude compensation in meters */ + uint16_t interval; /* Background measurement interval in + * seconds (2 to 1800). */ + uint16_t temperature_offset; /* Temperature offset in 0.01 Kelvin. */ +}; + +struct scd41_word_s +{ + uint8_t data[2]; + uint8_t crc; +}; + +/**************************************************************************** + * Private Function Prototypes + ****************************************************************************/ + +/* IO Helpers */ + +#ifdef CONFIG_SCD41_I2C +static int scd41_do_transfer(FAR struct i2c_master_s *i2c, + FAR struct i2c_msg_s *msgv, + size_t nmsg); +#endif +static int scd41_write_cmd(FAR struct scd41_dev_s *priv, uint16_t cmd, + FAR struct scd41_word_s *params, + unsigned int num_params); +static int scd41_read_words(FAR struct scd41_dev_s *priv, + FAR struct scd41_word_s *words, + unsigned int num_words); + +/* Data conversion */ + +static uint8_t scd41_crc_word(uint16_t word); +static void scd41_set_command_param(FAR struct scd41_word_s *param, + uint16_t value); +static int scd41_check_data_crc(FAR const struct scd41_word_s *words, + unsigned int num_words); +static uint16_t scd41_data_word2uint16(FAR const struct scd41_word_s *word); + +/* Driver features */ + +static int scd41_read_values(FAR struct scd41_dev_s *priv, FAR float *temp, + FAR float *rh, FAR float *co2, bool wait); +static int scd41_configure(FAR struct scd41_dev_s *priv, bool start); + +/* Character driver methods */ + +#ifndef CONFIG_DISABLE_PSEUDOFS_OPERATIONS +static int scd41_open(FAR struct file *filep); +static int scd41_close(FAR struct file *filep); +#endif +static ssize_t scd41_read(FAR struct file *filep, FAR char *buffer, + size_t buflen); +static ssize_t scd41_write(FAR struct file *filep, FAR const char *buffer, + size_t buflen); +static int scd41_ioctl(FAR struct file *filep, int cmd, + unsigned long arg); +#ifndef CONFIG_DISABLE_PSEUDOFS_OPERATIONS +static int scd41_unlink(FAR struct inode *inode); +#endif + +/**************************************************************************** + * Private Data + ****************************************************************************/ + +static const struct file_operations g_scd41fops = +{ +#ifndef CONFIG_DISABLE_PSEUDOFS_OPERATIONS + scd41_open, /* open */ + scd41_close, /* close */ +#else + NULL, /* open */ + NULL, /* close */ +#endif + scd41_read, /* read */ + scd41_write, /* write */ + NULL, /* seek */ + scd41_ioctl, /* ioctl */ + NULL /* poll */ +#ifndef CONFIG_DISABLE_PSEUDOFS_OPERATIONS + , scd41_unlink /* unlink */ +#endif +}; + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: scd41_do_transfer + ****************************************************************************/ + +#ifdef CONFIG_SCD41_I2C +static int scd41_do_transfer(FAR struct i2c_master_s *i2c, + FAR struct i2c_msg_s *msgv, + size_t nmsg) +{ + int ret = -EIO; + int retries; + + for (retries = 0; retries < SCD41_I2C_RETRIES; retries++) + { + ret = I2C_TRANSFER(i2c, msgv, nmsg); + if (ret >= 0) + { + return 0; + } + else + { + /* Some error. Try to reset I2C bus and keep trying. */ + +#ifdef CONFIG_I2C_RESET + if (retries == SCD41_I2C_RETRIES - 1) + { + break; + } + + ret = I2C_RESET(i2c); + if (ret < 0) + { + scd41_dbg("I2C_RESET failed: %d\n", ret); + return ret; + } +#endif + } + } + + scd41_dbg("xfer failed: %d\n", ret); + return ret; +} +#endif + +/**************************************************************************** + * Name: scd41_write_cmd + ****************************************************************************/ + +static int scd41_write_cmd(FAR struct scd41_dev_s *priv, uint16_t cmd, + FAR struct scd41_word_s *params, + unsigned int num_params) +{ +#ifdef CONFIG_SCD41_I2C + struct i2c_msg_s msg[2]; + uint8_t cmd_buf[2]; + int ret; + + cmd_buf[0] = cmd >> 8; + cmd_buf[1] = cmd >> 0; + + msg[0].frequency = CONFIG_SCD41_I2C_FREQUENCY; + msg[0].addr = priv->addr; + msg[0].flags = 0; + msg[0].buffer = cmd_buf; + msg[0].length = 2; + + if (num_params) + { + msg[1].frequency = CONFIG_SCD41_I2C_FREQUENCY; + msg[1].addr = priv->addr; + msg[1].flags = I2C_M_NOSTART; + msg[1].buffer = (FAR uint8_t *)params; + msg[1].length = num_params * sizeof(*params); + } + + ret = scd41_do_transfer(priv->i2c, msg, (num_params) ? 2 : 1); + + scd41_dbg("cmd: 0x%04X num_params: %d ret: %d\n", + cmd, num_params, ret); + return (ret >= 0) ? OK : ret; +#else + /* UART mode not implemented yet. */ + + return -ENODEV; +#endif +} + +/**************************************************************************** + * Name: scd41_read_words + ****************************************************************************/ + +static int scd41_read_words(FAR struct scd41_dev_s *priv, + FAR struct scd41_word_s *words, + unsigned int num_words) +{ +#ifdef CONFIG_SCD41_I2C + struct i2c_msg_s msg[1]; + int ret; + + msg[0].frequency = CONFIG_SCD41_I2C_FREQUENCY; + msg[0].addr = priv->addr; + msg[0].flags = I2C_M_READ; + msg[0].buffer = (FAR uint8_t *)words; + msg[0].length = num_words * sizeof(*words); + + ret = scd41_do_transfer(priv->i2c, msg, 1); + + scd41_dbg("num_words: %d ret: %d\n", num_words, ret); + return (ret >= 0) ? OK : ret; +#else + /* UART mode not implemented yet. */ + + return -ENODEV; +#endif +} + +/**************************************************************************** + * Name: scd41_crc_word + ****************************************************************************/ + +static uint8_t scd41_crc_word(uint16_t word) +{ + static const uint8_t crc_table[16] = + { + 0x00, 0x31, 0x62, 0x53, 0xc4, 0xf5, 0xa6, 0x97, + 0xb9, 0x88, 0xdb, 0xea, 0x7d, 0x4c, 0x1f, 0x2e + }; + + uint8_t crc = 0xff; + + crc ^= word >> 8; + crc = (crc << 4) ^ crc_table[crc >> 4]; + crc = (crc << 4) ^ crc_table[crc >> 4]; + crc ^= word >> 0; + crc = (crc << 4) ^ crc_table[crc >> 4]; + crc = (crc << 4) ^ crc_table[crc >> 4]; + + return crc; +} + +/**************************************************************************** + * Name: scd41_set_command_param + ****************************************************************************/ + +static void scd41_set_command_param(FAR struct scd41_word_s *param, + uint16_t value) +{ + param->data[0] = value >> 8; + param->data[1] = value >> 0; + param->crc = scd41_crc_word(value); +} + +/**************************************************************************** + * Name: scd41_data_word2uint16 + ****************************************************************************/ + +static uint16_t scd41_data_word2uint16(FAR const struct scd41_word_s *word) +{ + return (word[0].data[0] << 8) | (word[0].data[1]); +} + +/**************************************************************************** + * Name: scd41_crc_word + ****************************************************************************/ + +static int scd41_check_data_crc(FAR const struct scd41_word_s *words, + unsigned int num_words) +{ + while (num_words) + { + if (scd41_crc_word(scd41_data_word2uint16(words)) != words->crc) + { + return -1; + } + + num_words--; + words++; + } + + return 0; +} + +/**************************************************************************** + * Name: scd41_softreset + * + * Description: + * Reset the SCD41 sensor. This takes less than 2000 ms. + * + ****************************************************************************/ + +static int scd41_softreset(FAR struct scd41_dev_s *priv) +{ + int ret; + + ret = scd41_write_cmd(priv, SCD41_CMD_SOFT_RESET, NULL, 0); + if (ret < 0) + { + return ret; + } + + return 0; +} + +/**************************************************************************** + * Name: has_time_passed + * + * Description: + * Return true if curr >= start + secs_since_start + * + ****************************************************************************/ + +static bool has_time_passed(struct timespec curr, + struct timespec start, + unsigned int secs_since_start) +{ + if ((long)((start.tv_sec + secs_since_start) - curr.tv_sec) == 0) + { + return start.tv_nsec <= curr.tv_nsec; + } + + return (long)((start.tv_sec + secs_since_start) - curr.tv_sec) <= 0; +} + +/**************************************************************************** + * Name: scd41_read_values + ****************************************************************************/ + +static int scd41_read_values(FAR struct scd41_dev_s *priv, FAR float *temp, + FAR float *rh, FAR float *co2, bool wait) +{ + struct scd41_word_s data[3]; + struct timespec ts; + int ret; + + clock_systime_timespec(&ts); + + if (wait || !priv->valid || + has_time_passed(ts, priv->last_update, + SCD41_DEFAULT_MEASUREMENT_INTERVAL)) + { + while (1) + { + /* Wait data to be ready. */ + + ret = scd41_write_cmd(priv, SCD41_CMD_GET_DATA_READY, NULL, 0); + if (ret < 0) + { + scd41_dbg("ERROR: scd41_write_cmd failed: %d\n", ret); + return ret; + } + + ret = scd41_read_words(priv, data, 1); + if (ret < 0) + { + scd41_dbg("ERROR: scd41_read_words failed: %d\n", ret); + return ret; + } + + if (scd41_check_data_crc(data, 1) < 0) + { + scd41_dbg("ERROR: scd41_read_words crc failed\n"); + ret = -EIO; + return ret; + } + + if ((scd41_data_word2uint16(data) & 0x07ff) == 0x0000) + { + if (!wait) + { + scd41_dbg("ERROR: data not ready\n"); + ret = -EAGAIN; + return ret; + } + + ret = nxsig_usleep(500 * 1000); + if (ret == -EINTR) + { + return ret; + } + } + else + { + break; + } + } + + /* Read the raw data */ + + ret = scd41_write_cmd(priv, SCD41_CMD_READ_MEASUREMENT, NULL, 0); + if (ret < 0) + { + scd41_dbg("ERROR: scd41_write_cmd failed: %d\n", ret); + return ret; + } + + ret = scd41_read_words(priv, data, 3); + if (ret < 0) + { + scd41_dbg("ERROR: scd41_read_words failed: %d\n", ret); + return ret; + } + + if (scd41_check_data_crc(data, 3) < 0) + { + scd41_dbg("ERROR: scd41_read_words crc failed\n"); + ret = -EIO; + return ret; + } + + add_sensor_randomness((data[0].crc << 16) ^ (data[1].crc << 8) ^ + data[2].crc); + + priv->co2 = (float)scd41_data_word2uint16(data + 0); + uint16_t tval = scd41_data_word2uint16(data + 1); + priv->temperature = (float)((tval * 175.0) / 65536.0 - 45.0); + uint16_t hval = scd41_data_word2uint16(data + 2); + priv->humidity = (float)(hval * 100.0 / 65536.0); + priv->last_update = ts; + priv->valid = true; + } + + *temp = priv->temperature; + *rh = priv->humidity; + *co2 = priv->co2; + return OK; +} + +/**************************************************************************** + * Name: scd41_configure + ****************************************************************************/ + +static int scd41_configure(FAR struct scd41_dev_s *priv, bool start) +{ + struct scd41_word_s param; + int ret = OK; + + /* Set altitude compensation. */ + + scd41_set_command_param(¶m, priv->altitude_comp); + scd41_write_cmd(priv, SCD41_CMD_SET_ALT_COMPENSATION, ¶m, 1); + + /* Set temperature offset. */ + + scd41_set_command_param(¶m, priv->temperature_offset); + scd41_write_cmd(priv, SCD41_CMD_SET_TEMP_OFFSET, ¶m, 1); + + /* Set pressure compensation. */ + + scd41_set_command_param(¶m, priv->pressure_comp); + scd41_write_cmd(priv, SCD41_CMD_SET_PRESSURE_COMP, ¶m, 1); + + if (start) + { + /* Start measurements. */ + + ret = scd41_write_cmd(priv, SCD41_CMD_START_MEASUREMENT, NULL, 0); + if (ret >= 0) + { + priv->started = true; + } + } + + return ret; +} + +/**************************************************************************** + * Name: scd41_open + * + * Description: + * This function is called whenever the SCD41x device is opened. + * + ****************************************************************************/ + +#ifndef CONFIG_DISABLE_PSEUDOFS_OPERATIONS +static int scd41_open(FAR struct file *filep) +{ + FAR struct inode *inode = filep->f_inode; + FAR struct scd41_dev_s *priv = inode->i_private; + int ret = OK; + + /* Get exclusive access */ + + ret = nxsem_wait_uninterruptible(&priv->devsem); + if (ret < 0) + { + return ret; + } + + /* Increment the count of open references on the driver */ + + priv->crefs++; + DEBUGASSERT(priv->crefs > 0); + + if (priv->crefs == 1) + { + ret = scd41_configure(priv, true); + } + + if (ret < 0) + { + priv->crefs--; + } + + nxsem_post(&priv->devsem); + return ret; +} +#endif + +/**************************************************************************** + * Name: scd41_close + * + * Description: + * This routine is called when the SCD41 device is closed. + * + ****************************************************************************/ + +#ifndef CONFIG_DISABLE_PSEUDOFS_OPERATIONS +static int scd41_close(FAR struct file *filep) +{ + FAR struct inode *inode = filep->f_inode; + FAR struct scd41_dev_s *priv = inode->i_private; + int ret; + + /* Get exclusive access */ + + ret = nxsem_wait_uninterruptible(&priv->devsem); + if (ret < 0) + { + return ret; + } + + /* Decrement the count of open references on the driver */ + + DEBUGASSERT(priv->crefs > 0); + priv->crefs--; + + /* If the count has decremented to zero and the driver has been unlinked, + * then free memory now. + */ + + if (priv->crefs <= 0 && priv->unlinked) + { + nxsem_destroy(&priv->devsem); + kmm_free(priv); + return OK; + } + + nxsem_post(&priv->devsem); + return OK; +} +#endif + +/**************************************************************************** + * Name: scd41_read + ****************************************************************************/ + +static ssize_t scd41_read(FAR struct file *filep, FAR char *buffer, + size_t buflen) +{ + FAR struct inode *inode = filep->f_inode; + FAR struct scd41_dev_s *priv = inode->i_private; + ssize_t length = 0; + float temp; + float rh; + float co2; + unsigned int temp100; + unsigned int rh100; + unsigned int co2_100; + int ret; + + /* Get exclusive access */ + + ret = nxsem_wait_uninterruptible(&priv->devsem); + if (ret < 0) + { + return (ssize_t)ret; + } + +#ifndef CONFIG_DISABLE_PSEUDOFS_OPERATIONS + if (priv->unlinked) + { + /* Do not allow operations on unlinked sensors. This allows + * sensor use on hot swappable I2C bus. + */ + + nxsem_post(&priv->devsem); + return -ENODEV; + } +#endif + + if (!priv->started) + { + return -ENODATA; + } + + ret = scd41_read_values(priv, &temp, &rh, &co2, + !(filep->f_oflags & O_NONBLOCK)); + if (ret < 0) + { + scd41_dbg("cannot read data: %d\n", ret); + } + else + { + /* This interface is mainly intended for easy debugging in nsh. */ + + temp100 = abs(temp * 100); + rh100 = abs(rh * 100); + co2_100 = abs(co2 * 100); + + length = snprintf(buffer, buflen, "%s%u.%02u %s%u.%02u %s%u.%02u\n", + co2 < 0 ? "-" : "", co2_100 / 100, co2_100 % 100, + temp < 0 ? "-" : "", temp100 / 100, temp100 % 100, + rh < 0 ? "-" : "", rh100 / 100, rh100 % 100); + if (length > buflen) + { + length = buflen; + } + } + + nxsem_post(&priv->devsem); + return length; +} + +/**************************************************************************** + * Name: scd41_write + ****************************************************************************/ + +static ssize_t scd41_write(FAR struct file *filep, FAR const char *buffer, + size_t buflen) +{ + return -ENOSYS; +} + +/**************************************************************************** + * Name: scd41_ioctl + ****************************************************************************/ + +static int scd41_ioctl(FAR struct file *filep, int cmd, unsigned long arg) +{ + FAR struct inode *inode = filep->f_inode; + FAR struct scd41_dev_s *priv = inode->i_private; + struct scd41_word_s param; + int ret; + + /* Get exclusive access */ + + ret = nxsem_wait_uninterruptible(&priv->devsem); + if (ret < 0) + { + return ret; + } + +#ifndef CONFIG_DISABLE_PSEUDOFS_OPERATIONS + if (priv->unlinked) + { + /* Do not allow operations on unlinked sensors. This allows + * sensor use on hot swappable I2C bus. + */ + + nxsem_post(&priv->devsem); + return -ENODEV; + } +#endif + + switch (cmd) + { + /* Soft reset the SCD41, Arg: None */ + + case SNIOC_RESET: + { + priv->interval = SCD41_DEFAULT_MEASUREMENT_INTERVAL; + priv->pressure_comp = SCD41_DEFAULT_PRESSURE_COMPENSATION; + priv->altitude_comp = SCD41_DEFAULT_ALTITUDE_COMPENSATION; + priv->temperature_offset = SCD41_DEFAULT_TEMPERATURE_OFFSET; + + ret = scd41_softreset(priv); + scd41_dbg("softreset ret: %d\n", ret); + + scd41_configure(priv, priv->started); + } + break; + + /* Start background measurement, Arg: None */ + + case SNIOC_START: + { + /* Start measurements. */ + + ret = scd41_write_cmd(priv, SCD41_CMD_START_MEASUREMENT, NULL, 0); + if (ret >= 0) + { + priv->started = true; + } + } + break; + + /* Stop background measurement, Arg: None */ + + case SNIOC_STOP: + { + /* Stop measurements. */ + + ret = scd41_write_cmd(priv, SCD41_CMD_STOP_MEASUREMENT, NULL, 0); + if (ret >= 0) + { + priv->started = false; + } + } + break; + + /* Set temperature offset value, Arg: uint16_t */ + + case SNIOC_SET_TEMP_OFFSET: + { + if (arg > UINT16_MAX) + { + ret = -EINVAL; + break; + } + + /* Actual Toffset = temperature_offset * 175.0 / 2^16 */ + + priv->temperature_offset = arg; + scd41_set_command_param(¶m, priv->temperature_offset); + ret = scd41_write_cmd(priv, SCD41_CMD_SET_TEMP_OFFSET, ¶m, 1); + } + break; + + /* Set pressure compensation value, Arg: uint16_t */ + + case SNIOC_SET_PRESSURE_COMP: + { + if (arg > UINT16_MAX) + { + ret = -EINVAL; + break; + } + + priv->pressure_comp = arg; + scd41_set_command_param(¶m, priv->pressure_comp); + ret = scd41_write_cmd(priv, SCD41_CMD_SET_PRESSURE_COMP, + ¶m, 1); + } + break; + + /* Set altitude compensation value, Arg: uint16_t */ + + case SNIOC_SET_ALTITUDE_COMP: + { + if (arg > UINT16_MAX) + { + ret = -EINVAL; + break; + } + + priv->altitude_comp = arg; + scd41_set_command_param(¶m, priv->altitude_comp); + ret = scd41_write_cmd(priv, SCD41_CMD_SET_ALT_COMPENSATION, + ¶m, 1); + } + break; + + /* Set Forced Recalibration value (FRC), Arg: uint16_t */ + + case SNIOC_SET_FRC: + { + if (arg > UINT16_MAX) + { + ret = -EINVAL; + break; + } + + scd41_set_command_param(¶m, arg); + ret = scd41_write_cmd(priv, SCD41_CMD_SET_FRC, ¶m, 1); + } + break; + + /* (De-)Activate Automatic Self-Calibration (ASC), Arg: bool */ + + case SNIOC_ENABLE_ASC: + { + if (arg != !!arg) /* 0 or 1 */ + { + ret = -EINVAL; + break; + } + + scd41_set_command_param(¶m, arg); + ret = scd41_write_cmd(priv, SCD41_CMD_SET_ASC, ¶m, 1); + } + break; + + /* Read sensor data, Arg: struct scd41_conv_data_s *data */ + + case SNIOC_READ_CONVERT_DATA: + { + float temp; + float rh; + float co2; + + ret = scd41_read_values(priv, &temp, &rh, &co2, false); + if (ret < 0) + { + scd41_dbg("cannot read data: %d\n", ret); + } + else + { + FAR struct scd41_conv_data_s *data = + (FAR struct scd41_conv_data_s *)arg; + + data->temperature = temp; + data->humidity = rh; + data->co2 = co2; + } + } + break; + + default: + scd41_dbg("Unrecognized cmd: %d\n", cmd); + ret = -ENOTTY; + break; + } + + nxsem_post(&priv->devsem); + return ret; +} + +/**************************************************************************** + * Name: scd41_unlink + ****************************************************************************/ + +#ifndef CONFIG_DISABLE_PSEUDOFS_OPERATIONS +static int scd41_unlink(FAR struct inode *inode) +{ + FAR struct scd41_dev_s *priv; + int ret; + + DEBUGASSERT(inode != NULL && inode->i_private != NULL); + priv = (FAR struct scd41_dev_s *)inode->i_private; + + /* Get exclusive access */ + + ret = nxsem_wait_uninterruptible(&priv->devsem); + if (ret < 0) + { + return ret; + } + + /* Are there open references to the driver data structure? */ + + if (priv->crefs <= 0) + { + nxsem_destroy(&priv->devsem); + kmm_free(priv); + return OK; + } + + /* No... just mark the driver as unlinked and free the resources when + * the last client closes their reference to the driver. + */ + + priv->unlinked = true; + nxsem_post(&priv->devsem); + return OK; +} +#endif + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +#ifdef CONFIG_SCD41_I2C +/**************************************************************************** + * Name: scd41_register_i2c + * + * Description: + * Register the SCD41 character device as 'devpath' + * + * Input Parameters: + * devpath - The full path to the driver to register. E.g., "/dev/co2_0" + * i2c - An instance of the I2C interface to use to communicate with + * the SCD41 + * + * Returned Value: + * Zero (OK) on success; a negated errno value on failure. + * + ****************************************************************************/ + +int scd41_register_i2c(FAR const char *devpath, FAR struct i2c_master_s *i2c) +{ + FAR struct scd41_dev_s *priv; + int ret; + + DEBUGASSERT(i2c != NULL); + DEBUGASSERT(scd41_crc_word(0xbeef) == 0x92); + + /* Initialize the device structure */ + + priv = (FAR struct scd41_dev_s *)kmm_zalloc(sizeof(struct scd41_dev_s)); + if (priv == NULL) + { + scd41_dbg("ERROR: Failed to allocate instance\n"); + return -ENOMEM; + } + + priv->i2c = i2c; + priv->addr = CONFIG_SCD41_ADDR; + priv->started = false; + priv->interval = SCD41_DEFAULT_MEASUREMENT_INTERVAL; + priv->pressure_comp = SCD41_DEFAULT_PRESSURE_COMPENSATION; + priv->altitude_comp = SCD41_DEFAULT_ALTITUDE_COMPENSATION; + priv->temperature_offset = SCD41_DEFAULT_TEMPERATURE_OFFSET; + + nxsem_init(&priv->devsem, 0, 1); + + /* Register the character driver */ + + ret = register_driver(devpath, &g_scd41fops, 0666, priv); + if (ret < 0) + { + scd41_dbg("ERROR: Failed to register driver: %d\n", ret); + kmm_free(priv); + } + + return ret; +} +#endif /* CONFIG_SCD41_I2C */ + +#endif /* CONFIG_SENSORS_SCD41 */ diff --git a/drivers/sensors/sensor.c b/drivers/sensors/sensor.c index 651f669251203..984166e4765f1 100644 --- a/drivers/sensors/sensor.c +++ b/drivers/sensors/sensor.c @@ -167,7 +167,7 @@ static void sensor_pollnotify(FAR struct sensor_upperhalf_s *upper, if (fd->revents != 0) { - sninfo("Report events: %02x\n", fd->revents); + sninfo("Report events: %08" PRIx32 "\n", fd->revents); nxsem_get_value(fd->sem, &semcount); if (semcount < 1) diff --git a/drivers/sensors/sgp30.c b/drivers/sensors/sgp30.c index 1c345a38737a9..ab6cf1fb82856 100644 --- a/drivers/sensors/sgp30.c +++ b/drivers/sensors/sgp30.c @@ -897,7 +897,7 @@ static int sgp30_ioctl(FAR struct file *filep, int cmd, unsigned long arg) { /* Input is absolute humidity in unit "mg/m^3". */ - if (arg < 0 || arg >= 256000) + if (arg >= 256000) { ret = -EINVAL; break; diff --git a/drivers/sensors/t67xx.c b/drivers/sensors/t67xx.c index 1b35f4af40968..6535d597f65b8 100644 --- a/drivers/sensors/t67xx.c +++ b/drivers/sensors/t67xx.c @@ -136,10 +136,6 @@ static int t67xx_reset(FAR struct t67xx_dev_s *priv); /* Character driver methods */ -#ifndef CONFIG_DISABLE_PSEUDOFS_OPERATIONS -static int t67xx_open(FAR struct file *filep); -static int t67xx_close(FAR struct file *filep); -#endif static ssize_t t67xx_read(FAR struct file *filep, FAR char *buffer, size_t buflen); static ssize_t t67xx_write(FAR struct file *filep, FAR const char *buffer, @@ -153,13 +149,8 @@ static int t67xx_ioctl(FAR struct file *filep, int cmd, static const struct file_operations g_t67xxfops = { -#ifndef CONFIG_DISABLE_PSEUDOFS_OPERATIONS - t67xx_open, /* open */ - t67xx_close, /* close */ -#else NULL, /* open */ NULL, /* close */ -#endif t67xx_read, /* read */ t67xx_write, /* write */ NULL, /* seek */ @@ -567,44 +558,6 @@ static int t67xx_reset(FAR struct t67xx_dev_s *priv) return ret; } -/**************************************************************************** - * Name: t67xx_open - * - * Description: - * This function is called whenever the T67XX device is opened. - * - ****************************************************************************/ - -#ifndef CONFIG_DISABLE_PSEUDOFS_OPERATIONS -static int t67xx_open(FAR struct file *filep) -{ - FAR struct inode *inode = filep->f_inode; - FAR struct t67xx_dev_s *priv = inode->i_private; - - UNUSED(priv); - return OK; -} -#endif - -/**************************************************************************** - * Name: t67xx_close - * - * Description: - * This routine is called when the T67XX device is closed. - * - ****************************************************************************/ - -#ifndef CONFIG_DISABLE_PSEUDOFS_OPERATIONS -static int t67xx_close(FAR struct file *filep) -{ - FAR struct inode *inode = filep->f_inode; - FAR struct t67xx_dev_s *priv = inode->i_private; - - UNUSED(priv); - return OK; -} -#endif - /**************************************************************************** * Name: t67xx_read ****************************************************************************/ diff --git a/drivers/sensors/veml6070.c b/drivers/sensors/veml6070.c index 8b99270868347..d386c0aaa0dfc 100644 --- a/drivers/sensors/veml6070.c +++ b/drivers/sensors/veml6070.c @@ -65,16 +65,14 @@ struct veml6070_dev_s /* I2C Helpers */ static int veml6070_read8(FAR struct veml6070_dev_s *priv, int offset, - FAR uint8_t *regval); + FAR uint8_t *regval); static int veml6070_write8(FAR struct veml6070_dev_s *priv, - uint8_t regval); + uint8_t regval); /* Character driver methods */ -static int veml6070_open(FAR struct file *filep); -static int veml6070_close(FAR struct file *filep); static ssize_t veml6070_read(FAR struct file *filep, FAR char *buffer, - size_t buflen); + size_t buflen); static ssize_t veml6070_write(FAR struct file *filep, FAR const char *buffer, size_t buflen); @@ -84,8 +82,8 @@ static ssize_t veml6070_write(FAR struct file *filep, static const struct file_operations g_veml6070_fops = { - veml6070_open, /* open */ - veml6070_close, /* close */ + NULL, /* open */ + NULL, /* close */ veml6070_read, /* read */ veml6070_write, /* write */ NULL, /* seek */ @@ -170,32 +168,6 @@ static int veml6070_write8(FAR struct veml6070_dev_s *priv, uint8_t regval) return ret; } -/**************************************************************************** - * Name: veml6070_open - * - * Description: - * This function is called whenever the VEML6070 device is opened. - * - ****************************************************************************/ - -static int veml6070_open(FAR struct file *filep) -{ - return OK; -} - -/**************************************************************************** - * Name: veml6070_close - * - * Description: - * This routine is called when the VEML6070 device is closed. - * - ****************************************************************************/ - -static int veml6070_close(FAR struct file *filep) -{ - return OK; -} - /**************************************************************************** * Name: veml6070_read ****************************************************************************/ diff --git a/drivers/sensors/vl53l1x.c b/drivers/sensors/vl53l1x.c index 15205e500d986..c997d3c317d3e 100644 --- a/drivers/sensors/vl53l1x.c +++ b/drivers/sensors/vl53l1x.c @@ -230,8 +230,6 @@ static void vl53l1x_calibrateoffset(FAR struct vl53l1x_dev_s *priv, /* Character driver methods */ -static int vl53l1x_open(FAR struct file *filep); -static int vl53l1x_close(FAR struct file *filep); static void vl53l1x_read(FAR struct file *filep, FAR char *buffer, size_t buflen); static ssize_t vl53l1x_write(FAR struct file *filep, FAR const char *buffer, @@ -244,15 +242,15 @@ static void vl53l1x_ioctl(FAR struct file *filep, int cmd, uint16_t arg); static const struct file_operations g_vl53l1xfops = { - vl53l1x_open, /* open */ - vl53l1x_close, /* close */ - vl53l1x_read, /* read */ - vl53l1x_write, /* write */ - NULL, /* seek */ - vl53l1x_ioctl, /* ioctl */ - NULL /* poll */ + NULL, /* open */ + NULL, /* close */ + vl53l1x_read, /* read */ + vl53l1x_write, /* write */ + NULL, /* seek */ + vl53l1x_ioctl, /* ioctl */ + NULL /* poll */ #ifndef CONFIG_DISABLE_PSEUDOFS_OPERATIONS - , NULL /* unlink */ + , NULL /* unlink */ #endif }; @@ -1036,32 +1034,6 @@ static void vl53l1x_putreg32(FAR struct vl53l1x_dev_s *priv, return; } -/**************************************************************************** - * Name: vl53l1x_open - * - * Description: - * This function is called whenever the vl53l1x device is opened. - * - ****************************************************************************/ - -static int vl53l1x_open(FAR struct file *filep) -{ - return OK; -} - -/**************************************************************************** - * Name: vl53l1x_close - * - * Description: - * This routine is called when the vl53l1x device is closed. - * - ****************************************************************************/ - -static int vl53l1x_close(FAR struct file *filep) -{ - return OK; -} - /**************************************************************************** * Name: vl53l1x_read ****************************************************************************/ diff --git a/drivers/sensors/xen1210.c b/drivers/sensors/xen1210.c index 1854088ee3fa5..8ac5873a705bc 100644 --- a/drivers/sensors/xen1210.c +++ b/drivers/sensors/xen1210.c @@ -48,8 +48,6 @@ /* Character driver methods */ -static int xen1210_open(FAR struct file *filep); -static int xen1210_close(FAR struct file *filep); static ssize_t xen1210_read(FAR struct file *filep, FAR char *buffer, size_t len); @@ -61,8 +59,8 @@ static ssize_t xen1210_read(FAR struct file *filep, FAR char *buffer, static const struct file_operations g_xen1210fops = { - xen1210_open, /* open */ - xen1210_close, /* close */ + NULL, /* open */ + NULL, /* close */ xen1210_read, /* read */ NULL, /* write */ NULL, /* seek */ @@ -94,32 +92,6 @@ static inline void xen1210_configspi(FAR struct spi_dev_s *spi) SPI_SETFREQUENCY(spi, XEN1210_SPI_MAXFREQUENCY); } -/**************************************************************************** - * Name: xen1210_open - * - * Description: - * Standard character driver open method. - * - ****************************************************************************/ - -static int xen1210_open(FAR struct file *filep) -{ - return OK; -} - -/**************************************************************************** - * Name: xen1210_close - * - * Description: - * Standard character driver close method. - * - ****************************************************************************/ - -static int xen1210_close(FAR struct file *filep) -{ - return OK; -} - /**************************************************************************** * Name: xen1210_read * @@ -369,7 +341,7 @@ int xen1210_register(XEN1210_HANDLE handle, int minor) /* Register the character driver */ - snprintf(devname, DEV_NAMELEN, DEV_FORMAT, minor); + snprintf(devname, sizeof(devname), DEV_FORMAT, minor); ret = register_driver(devname, &g_xen1210fops, 0444, priv); if (ret < 0) { diff --git a/drivers/serial/Kconfig b/drivers/serial/Kconfig index c542c20a50db3..955c95048d1b5 100644 --- a/drivers/serial/Kconfig +++ b/drivers/serial/Kconfig @@ -66,7 +66,7 @@ config MCU_SERIAL config RPMSG_UART bool "UART rpmsg support" default n - depends on OPENAMP + depends on RPTUN select ARCH_HAVE_SERIAL_TERMIOS select SERIAL_RXDMA select SERIAL_TXDMA diff --git a/drivers/serial/pty.c b/drivers/serial/pty.c index 26f63762dfcc9..63edccfb759d5 100644 --- a/drivers/serial/pty.c +++ b/drivers/serial/pty.c @@ -105,12 +105,12 @@ static int pty_pipe(FAR struct pty_devpair_s *devpair); static int pty_open(FAR struct file *filep); static int pty_close(FAR struct file *filep); static ssize_t pty_read(FAR struct file *filep, FAR char *buffer, - size_t buflen); + size_t buflen); static ssize_t pty_write(FAR struct file *filep, FAR const char *buffer, - size_t buflen); + size_t buflen); static int pty_ioctl(FAR struct file *filep, int cmd, unsigned long arg); static int pty_poll(FAR struct file *filep, FAR struct pollfd *fds, - bool setup); + bool setup); #ifndef CONFIG_DISABLE_PSEUDOFS_OPERATIONS static int pty_unlink(FAR struct inode *inode); #endif diff --git a/drivers/serial/serial.c b/drivers/serial/serial.c index 30bc81da2f0c2..7b2c8b8622f51 100644 --- a/drivers/serial/serial.c +++ b/drivers/serial/serial.c @@ -163,7 +163,7 @@ static int uart_takesem(FAR sem_t *sem, bool errout) * Name: uart_givesem ****************************************************************************/ -#define uart_givesem(sem) (void)nxsem_post(sem) +#define uart_givesem(sem) nxsem_post(sem) /**************************************************************************** * Name: uart_pollnotify @@ -187,7 +187,7 @@ static void uart_pollnotify(FAR uart_dev_t *dev, pollevent_t eventset) { int semcount; - finfo("Report events: %02x\n", fds->revents); + finfo("Report events: %08" PRIx32 "\n", fds->revents); nxsem_get_value(fds->sem, &semcount); if (semcount < 1) diff --git a/drivers/serial/uart_bth4.c b/drivers/serial/uart_bth4.c index fd496dc3a5b87..c63af7e3efb54 100644 --- a/drivers/serial/uart_bth4.c +++ b/drivers/serial/uart_bth4.c @@ -66,16 +66,16 @@ struct uart_bth4_s * Private Function Prototypes ****************************************************************************/ -static int uart_bth4_open (FAR struct file *filep); +static int uart_bth4_open(FAR struct file *filep); static int uart_bth4_close(FAR struct file *filep); -static ssize_t uart_bth4_read (FAR struct file *filep, - FAR char *buffer, size_t buflen); +static ssize_t uart_bth4_read(FAR struct file *filep, + FAR char *buffer, size_t buflen); static ssize_t uart_bth4_write(FAR struct file *filep, FAR const char *buffer, size_t buflen); static int uart_bth4_ioctl(FAR struct file *filep, int cmd, unsigned long arg); -static int uart_bth4_poll (FAR struct file *filep, - FAR struct pollfd *fds, bool setup); +static int uart_bth4_poll(FAR struct file *filep, + FAR struct pollfd *fds, bool setup); /**************************************************************************** * Private Data @@ -84,7 +84,7 @@ static int uart_bth4_poll (FAR struct file *filep, static const struct file_operations g_uart_bth4_ops = { uart_bth4_open, /* open */ - uart_bth4_close, /* cose */ + uart_bth4_close, /* close */ uart_bth4_read, /* read */ uart_bth4_write, /* write */ NULL, /* seek */ @@ -344,14 +344,14 @@ static ssize_t uart_bth4_write(FAR struct file *filep, return ret < 0 ? ret : buflen; } -static int uart_bth4_ioctl(FAR struct file *filep, - int cmd, unsigned long arg) +static int uart_bth4_ioctl(FAR struct file *filep, int cmd, + unsigned long arg) { return OK; } -static int uart_bth4_poll(FAR struct file *filep, - FAR struct pollfd *fds, bool setup) +static int uart_bth4_poll(FAR struct file *filep, FAR struct pollfd *fds, + bool setup) { FAR struct inode *inode = filep->f_inode; FAR struct uart_bth4_s *dev = inode->i_private; diff --git a/drivers/spi/spi_slave_driver.c b/drivers/spi/spi_slave_driver.c index 6f9ae1e205435..914991ff21204 100644 --- a/drivers/spi/spi_slave_driver.c +++ b/drivers/spi/spi_slave_driver.c @@ -93,7 +93,7 @@ struct spi_slave_driver_s static int spi_slave_open(FAR struct file *filep); static int spi_slave_close(FAR struct file *filep); static ssize_t spi_slave_read(FAR struct file *filep, FAR char *buffer, - size_t buflen); + size_t buflen); static ssize_t spi_slave_write(FAR struct file *filep, FAR const char *buffer, size_t buflen); static int spi_slave_unlink(FAR struct inode *inode); @@ -105,9 +105,9 @@ static void spi_slave_select(FAR struct spi_slave_dev_s *sdev, static void spi_slave_cmddata(FAR struct spi_slave_dev_s *sdev, bool data); static size_t spi_slave_getdata(FAR struct spi_slave_dev_s *sdev, - FAR const void **data); + FAR const void **data); static size_t spi_slave_receive(FAR struct spi_slave_dev_s *sdev, - FAR const void *data, size_t nwords); + FAR const void *data, size_t nwords); /**************************************************************************** * Private Data @@ -609,7 +609,7 @@ int spi_slave_register(FAR struct spi_slave_ctrlr_s *ctrlr, int bus) /* Create the character device name */ - snprintf(devname, DEVNAME_FMTLEN, DEVNAME_FMT, bus); + snprintf(devname, sizeof(devname), DEVNAME_FMT, bus); /* Register the character driver */ diff --git a/drivers/syslog/Kconfig b/drivers/syslog/Kconfig index 9fd74e4e8017a..d0ee074e0f243 100644 --- a/drivers/syslog/Kconfig +++ b/drivers/syslog/Kconfig @@ -110,8 +110,7 @@ config SYSLOG_TIMESTAMP_REALTIME depends on SYSLOG_TIMESTAMP ---help--- Use wall-clock (CLOCK_REALTIME) for timestamp. By default, - CLOCK_MONOTONIC, if enabled, will be used or the system timer - is not. + CLOCK_MONOTONIC will be used. config SYSLOG_TIMESTAMP_FORMATTED bool "Formatted syslog time" @@ -137,6 +136,11 @@ config SYSLOG_TIMESTAMP_FORMAT Formatter string for syslog timestamp printing. Uses the standard "strftime" format specifiers. +config SYSLOG_TIMESTAMP_FORMAT_MICROSECOND + bool "Append microseconds after seconds" + default y + depends on SYSLOG_TIMESTAMP_FORMAT = "%e/%m/%y %H:%M:%S" + config SYSLOG_TIMESTAMP_BUFFER int "Formatted timestamp buffer size" default 64 @@ -203,7 +207,7 @@ config RAMLOG_SYSLOG config SYSLOG_RPMSG bool "Log to RPMSG" - depends on OPENAMP + depends on RPTUN depends on SCHED_WORKQUEUE default n ---help--- @@ -287,7 +291,7 @@ endif # SYSLOG_RPMSG config SYSLOG_RPMSG_SERVER bool "Enable RPMSG server for SYSLOG" default n - depends on OPENAMP + depends on RPTUN ---help--- Use rpmsg to receive message from remote proc. diff --git a/drivers/syslog/syslog_console.c b/drivers/syslog/syslog_console.c index c9edeb3ea20be..91e95899e3a5e 100644 --- a/drivers/syslog/syslog_console.c +++ b/drivers/syslog/syslog_console.c @@ -42,8 +42,6 @@ static ssize_t syslog_console_read(FAR struct file *filep, FAR char *buffer, size_t buflen); static ssize_t syslog_console_write(FAR struct file *filep, FAR const char *buffer, size_t buflen); -static int syslog_console_ioctl(FAR struct file *filep, int cmd, - unsigned long arg); /**************************************************************************** * Private Data @@ -56,7 +54,7 @@ static const struct file_operations g_consoleops = syslog_console_read, /* read */ syslog_console_write, /* write */ NULL, /* seek */ - syslog_console_ioctl, /* ioctl */ + NULL, /* ioctl */ NULL /* poll */ #ifndef CONFIG_DISABLE_PSEUDOFS_OPERATIONS , NULL /* unlink */ @@ -67,16 +65,6 @@ static const struct file_operations g_consoleops = * Private Functions ****************************************************************************/ -/**************************************************************************** - * Name: syslog_console_ioctl - ****************************************************************************/ - -static int syslog_console_ioctl(FAR struct file *filep, int cmd, - unsigned long arg) -{ - return -ENOTTY; -} - /**************************************************************************** * Name: syslog_console_read ****************************************************************************/ diff --git a/drivers/syslog/vsyslog.c b/drivers/syslog/vsyslog.c index 171966da9f633..95de17c568090 100644 --- a/drivers/syslog/vsyslog.c +++ b/drivers/syslog/vsyslog.c @@ -130,11 +130,16 @@ int nx_vsyslog(int priority, FAR const IPTR char *fmt, FAR va_list *ap) if (ret > 0) { +#if defined(CONFIG_SYSLOG_TIMESTAMP_FORMAT_MICROSECOND) + ret = lib_sprintf(&stream.public, "[%s.%06ld] ", + date_buf, ts.tv_nsec / NSEC_PER_USEC); +#else ret = lib_sprintf(&stream.public, "[%s] ", date_buf); +#endif } #else ret = lib_sprintf(&stream.public, "[%5jd.%06ld] ", - (uintmax_t)ts.tv_sec, ts.tv_nsec / 1000); + (uintmax_t)ts.tv_sec, ts.tv_nsec / NSEC_PER_USEC); #endif #endif diff --git a/drivers/timers/Kconfig b/drivers/timers/Kconfig index e5bab3d9d9ab2..8579a7a190496 100644 --- a/drivers/timers/Kconfig +++ b/drivers/timers/Kconfig @@ -312,12 +312,12 @@ endif # RTC_RX8010SJ config RTC_RPMSG bool "Rpmsg RTC Driver" default n - depends on OPENAMP + depends on RPTUN select ARCH_HAVE_RTC_SUBSECONDS config RTC_RPMSG_SERVER bool "The RTC Rpmsg Role" - depends on OPENAMP + depends on RPTUN config RTC_RPMSG_SERVER_NAME string "The name of RTC Rpmsg Server" diff --git a/drivers/timers/arch_timer.c b/drivers/timers/arch_timer.c index f9efdba2e27c3..650a108439cec 100644 --- a/drivers/timers/arch_timer.c +++ b/drivers/timers/arch_timer.c @@ -77,7 +77,7 @@ static inline void timespec_from_usec(FAR struct timespec *ts, } #ifdef CONFIG_SCHED_TICKLESS -static inline uint64_t timespec_to_usec(const FAR struct timespec *ts) +static inline uint64_t timespec_to_usec(FAR const struct timespec *ts) { return (uint64_t)ts->tv_sec * USEC_PER_SEC + ts->tv_nsec / NSEC_PER_USEC; } diff --git a/drivers/timers/oneshot.c b/drivers/timers/oneshot.c index 0bdb5acf40b0c..6e33c611918a4 100644 --- a/drivers/timers/oneshot.c +++ b/drivers/timers/oneshot.c @@ -61,8 +61,6 @@ struct oneshot_dev_s * Private Function Prototypes ****************************************************************************/ -static int oneshot_open(FAR struct file *filep); -static int oneshot_close(FAR struct file *filep); static ssize_t oneshot_read(FAR struct file *filep, FAR char *buffer, size_t buflen); static ssize_t oneshot_write(FAR struct file *filep, FAR const char *buffer, @@ -79,8 +77,8 @@ static void oneshot_callback(FAR struct oneshot_lowerhalf_s *lower, static const struct file_operations g_oneshot_ops = { - oneshot_open, /* open */ - oneshot_close, /* close */ + NULL, /* open */ + NULL, /* close */ oneshot_read, /* read */ oneshot_write, /* write */ NULL, /* seek */ @@ -108,38 +106,8 @@ static void oneshot_callback(FAR struct oneshot_lowerhalf_s *lower, /* Signal the waiter.. if there is one */ - nxsig_notification(priv->od_pid, &priv->od_event, - SI_QUEUE, &priv->od_work); -} - -/**************************************************************************** - * Name: oneshot_open - * - * Description: - * This function is called whenever the PWM device is opened. - * - ****************************************************************************/ - -static int oneshot_open(FAR struct file *filep) -{ - tmrinfo("Opening...\n"); - DEBUGASSERT(filep != NULL && filep->f_inode != NULL); - return OK; -} - -/**************************************************************************** - * Name: oneshot_close - * - * Description: - * This function is called when the PWM device is closed. - * - ****************************************************************************/ - -static int oneshot_close(FAR struct file *filep) -{ - tmrinfo("Closing...\n"); - DEBUGASSERT(filep != NULL && filep->f_inode != NULL); - return OK; + nxsig_notification(priv->od_pid, &priv->od_event, SI_QUEUE, + &priv->od_work); } /**************************************************************************** diff --git a/drivers/usbdev/adb.c b/drivers/usbdev/adb.c index 39166711627e2..c18b427284f11 100644 --- a/drivers/usbdev/adb.c +++ b/drivers/usbdev/adb.c @@ -221,8 +221,6 @@ static ssize_t adb_char_read(FAR struct file *filep, FAR char *buffer, size_t len); static ssize_t adb_char_write(FAR struct file *filep, FAR const char *buffer, size_t len); -static int adb_char_ioctl(FAR struct file *filep, int cmd, - unsigned long arg); static int adb_char_poll(FAR struct file *filep, FAR struct pollfd *fds, bool setup); @@ -257,7 +255,7 @@ static const struct file_operations g_adb_fops = adb_char_read, /* read */ adb_char_write, /* write */ NULL, /* seek */ - adb_char_ioctl, /* ioctl */ + NULL, /* ioctl */ adb_char_poll /* poll */ #ifndef CONFIG_DISABLE_PSEUDOFS_OPERATIONS , NULL /* unlink */ @@ -1964,12 +1962,6 @@ static ssize_t adb_char_write(FAR struct file *filep, return ret; } -static int adb_char_ioctl(FAR struct file *filep, int cmd, - unsigned long arg) -{ - return -EINVAL; -} - static int adb_char_poll(FAR struct file *filep, FAR struct pollfd *fds, bool setup) { diff --git a/drivers/usbdev/pl2303.c b/drivers/usbdev/pl2303.c index 956883ea14129..5ec9a27273cc9 100644 --- a/drivers/usbdev/pl2303.c +++ b/drivers/usbdev/pl2303.c @@ -904,7 +904,7 @@ static int usbclass_mkstrdesc(uint8_t id, FAR struct usb_strdesc_s *strdesc) #ifdef CONFIG_USBDEV_DUALSPEED static inline void usbclass_mkepbulkdesc( - const FAR struct usb_epdesc_s *indesc, + FAR const struct usb_epdesc_s *indesc, uint16_t mxpacket, FAR struct usb_epdesc_s *outdesc) { diff --git a/drivers/usbhost/usbhost_cdcacm.c b/drivers/usbhost/usbhost_cdcacm.c index 381420f6af5c7..22b0f593321bf 100644 --- a/drivers/usbhost/usbhost_cdcacm.c +++ b/drivers/usbhost/usbhost_cdcacm.c @@ -895,7 +895,7 @@ static void usbhost_notification_callback(FAR void *arg, ssize_t nbytes) if (work_available(&priv->ntwork)) { work_queue(HPWORK, &priv->ntwork, - (worker_t)usbhost_notification_work, + usbhost_notification_work, priv, delay); } } diff --git a/drivers/usbhost/usbhost_cdcmbim.c b/drivers/usbhost/usbhost_cdcmbim.c index 52b857c854629..7429dda266e05 100644 --- a/drivers/usbhost/usbhost_cdcmbim.c +++ b/drivers/usbhost/usbhost_cdcmbim.c @@ -418,7 +418,7 @@ static void usbhost_pollnotify(FAR struct usbhost_cdcmbim_s *priv) fds->revents |= (fds->events & POLLIN); if (fds->revents != 0) { - uinfo("Report events: %02x\n", fds->revents); + uinfo("Report events: %08" PRIx32 "\n", fds->revents); nxsem_post(fds->sem); } } @@ -499,9 +499,9 @@ static ssize_t cdcwdm_read(FAR struct file *filep, FAR char *buffer, uinfo("Reading next message\n"); if (work_available(&priv->comm_rxwork)) { - (void)work_queue(LPWORK, &priv->comm_rxwork, - (worker_t)usbhost_rxdata_work, - priv, 0); + work_queue(LPWORK, &priv->comm_rxwork, + (worker_t)usbhost_rxdata_work, + priv, 0); } } @@ -767,7 +767,7 @@ static void usbhost_freedevno(FAR struct usbhost_cdcmbim_s *priv) static inline void usbhost_mkdevname(FAR struct usbhost_cdcmbim_s *priv, FAR char *devname) { - (void)snprintf(devname, DEV_NAMELEN, DEV_FORMAT, priv->minor); + snprintf(devname, DEV_NAMELEN, DEV_FORMAT, priv->minor); } static void usbhost_bulkin_callback(FAR void *arg, ssize_t nbytes) @@ -796,8 +796,8 @@ static void usbhost_bulkin_callback(FAR void *arg, ssize_t nbytes) if (work_available(&priv->bulk_rxwork)) { - (void)work_queue(LPWORK, &priv->bulk_rxwork, - (worker_t)usbhost_bulkin_work, priv, delay); + work_queue(LPWORK, &priv->bulk_rxwork, + usbhost_bulkin_work, priv, delay); } } @@ -1021,9 +1021,9 @@ static void usbhost_notification_work(FAR void *arg) { if (work_available(&priv->comm_rxwork)) { - (void)work_queue(LPWORK, &priv->comm_rxwork, - (worker_t)usbhost_rxdata_work, - priv, 0); + work_queue(LPWORK, &priv->comm_rxwork, + usbhost_rxdata_work, + priv, 0); } } } @@ -1116,9 +1116,9 @@ static void usbhost_notification_callback(FAR void *arg, ssize_t nbytes) if (work_available(&priv->ntwork)) { - (void)work_queue(LPWORK, &priv->ntwork, - (worker_t)usbhost_notification_work, - priv, delay); + work_queue(LPWORK, &priv->ntwork, + usbhost_notification_work, + priv, delay); } } } @@ -1665,7 +1665,7 @@ static inline int usbhost_devinit(FAR struct usbhost_cdcmbim_s *priv) /* Register the network device */ - (void)netdev_register(&priv->netdev, NET_LL_MBIM); + netdev_register(&priv->netdev, NET_LL_MBIM); /* Check if we successfully initialized. We now have to be concerned * about asynchronous modification of crefs because the character @@ -2128,7 +2128,7 @@ static int usbhost_disconnected(struct usbhost_class_s *usbclass) uinfo("Queuing destruction: worker %p->%p\n", priv->destroywork.worker, usbhost_destroy); DEBUGASSERT(priv->destroywork.worker == NULL); - (void)work_queue(LPWORK, &priv->destroywork, + work_queue(LPWORK, &priv->destroywork, usbhost_destroy, priv, 0); } else @@ -2316,7 +2316,7 @@ static void cdcmbim_txpoll_work(void *arg) net_lock(); priv->netdev.d_buf = priv->txpktbuf; - (void)devif_timer(&priv->netdev, CDCMBIM_WDDELAY, cdcmbim_txpoll); + devif_timer(&priv->netdev, CDCMBIM_WDDELAY, cdcmbim_txpoll); /* setup the watchdog poll timer again */ @@ -2496,7 +2496,7 @@ static void cdcmbim_txavail_work(void *arg) if (priv->bifup) { - (void)devif_timer(&priv->netdev, 0, cdcmbim_txpoll); + devif_timer(&priv->netdev, 0, cdcmbim_txpoll); } net_unlock(); diff --git a/drivers/usbhost/usbhost_hidkbd.c b/drivers/usbhost/usbhost_hidkbd.c index c44d3783dc995..008547d771170 100644 --- a/drivers/usbhost/usbhost_hidkbd.c +++ b/drivers/usbhost/usbhost_hidkbd.c @@ -696,7 +696,7 @@ static void usbhost_pollnotify(FAR struct usbhost_state_s *priv) fds->revents |= (fds->events & POLLIN); if (fds->revents != 0) { - uinfo("Report events: %02x\n", fds->revents); + uinfo("Report events: %08" PRIx32 "\n", fds->revents); nxsem_post(fds->sem); } } diff --git a/drivers/usbhost/usbhost_hidmouse.c b/drivers/usbhost/usbhost_hidmouse.c index 84cfa00794462..0292197122c7f 100644 --- a/drivers/usbhost/usbhost_hidmouse.c +++ b/drivers/usbhost/usbhost_hidmouse.c @@ -483,7 +483,7 @@ static void usbhost_pollnotify(FAR struct usbhost_state_s *priv) fds->revents |= (fds->events & POLLIN); if (fds->revents != 0) { - uinfo("Report events: %02x\n", fds->revents); + uinfo("Report events: %08" PRIx32 "\n", fds->revents); nxsem_post(fds->sem); } } @@ -700,7 +700,7 @@ static void usbhost_notify(FAR struct usbhost_state_s *priv) if (fds) { fds->revents |= POLLIN; - iinfo("Report events: %02x\n", fds->revents); + iinfo("Report events: %08" PRIx32 "\n", fds->revents); nxsem_post(fds->sem); } } diff --git a/drivers/usbhost/usbhost_hub.c b/drivers/usbhost/usbhost_hub.c index 209ac561a70a2..d0eeb4fbef17b 100644 --- a/drivers/usbhost/usbhost_hub.c +++ b/drivers/usbhost/usbhost_hub.c @@ -1236,7 +1236,7 @@ static void usbhost_callback(FAR void *arg, ssize_t nbytes) if (work_available(&priv->work) && !priv->disconnected) { - work_queue(LPWORK, &priv->work, (worker_t)usbhost_hub_event, + work_queue(LPWORK, &priv->work, usbhost_hub_event, hubclass, delay); } } @@ -1496,7 +1496,7 @@ static int usbhost_disconnected(struct usbhost_class_s *hubclass) /* Schedule the disconnection work */ ret = work_queue(LPWORK, &priv->work, - (worker_t)usbhost_disconnect_event, hubclass, 0); + usbhost_disconnect_event, hubclass, 0); leave_critical_section(flags); return ret; } diff --git a/drivers/usbhost/usbhost_max3421e.c b/drivers/usbhost/usbhost_max3421e.c index 30ad9667b115a..cf72d6078f6c4 100644 --- a/drivers/usbhost/usbhost_max3421e.c +++ b/drivers/usbhost/usbhost_max3421e.c @@ -545,7 +545,7 @@ static int max3421e_ep0configure(FAR struct usbhost_driver_s *drvr, usbhost_ep_t ep0, uint8_t funcaddr, uint8_t speed, uint16_t maxpacketsize); static int max3421e_epalloc(FAR struct usbhost_driver_s *drvr, - FAR const FAR struct usbhost_epdesc_s *epdesc, + FAR const struct usbhost_epdesc_s *epdesc, FAR usbhost_ep_t *ep); static int max3421e_epfree(FAR struct usbhost_driver_s *drvr, usbhost_ep_t ep); diff --git a/drivers/usbhost/usbhost_xboxcontroller.c b/drivers/usbhost/usbhost_xboxcontroller.c index 87f51418f8db4..3f15e8f896fa5 100644 --- a/drivers/usbhost/usbhost_xboxcontroller.c +++ b/drivers/usbhost/usbhost_xboxcontroller.c @@ -584,7 +584,7 @@ static void usbhost_pollnotify(FAR struct usbhost_state_s *priv) if (fds) { fds->revents |= POLLIN; - iinfo("Report events: %02x\n", fds->revents); + iinfo("Report events: %08" PRIx32 "\n", fds->revents); nxsem_post(fds->sem); } } diff --git a/drivers/usbmisc/fusb301.c b/drivers/usbmisc/fusb301.c index 51a1fbf377dcb..57ecc85ff4214 100644 --- a/drivers/usbmisc/fusb301.c +++ b/drivers/usbmisc/fusb301.c @@ -755,7 +755,7 @@ static void fusb301_notify(FAR struct fusb301_dev_s *priv) if (fds) { fds->revents |= POLLIN; - fusb301_info("Report events: %02x\n", fds->revents); + fusb301_info("Report events: %08" PRIx32 "\n", fds->revents); nxsem_post(fds->sem); } } diff --git a/drivers/usbmisc/fusb303.c b/drivers/usbmisc/fusb303.c index 84d8a36df8c68..a61028a1a7c0d 100644 --- a/drivers/usbmisc/fusb303.c +++ b/drivers/usbmisc/fusb303.c @@ -943,7 +943,7 @@ static void fusb303_notify(FAR struct fusb303_dev_s *priv) if (fds) { fds->revents |= POLLIN; - fusb303_info("Report events: %02x\n", fds->revents); + fusb303_info("Report events: %08" PRIx32 "\n", fds->revents); nxsem_post(fds->sem); } } diff --git a/drivers/video/fb.c b/drivers/video/fb.c index 9da1474e54cbc..fec8c3be57af8 100644 --- a/drivers/video/fb.c +++ b/drivers/video/fb.c @@ -62,12 +62,10 @@ struct fb_chardev_s * Private Function Prototypes ****************************************************************************/ -static int fb_open(FAR struct file *filep); -static int fb_close(FAR struct file *filep); static ssize_t fb_read(FAR struct file *filep, FAR char *buffer, - size_t buflen); + size_t buflen); static ssize_t fb_write(FAR struct file *filep, FAR const char *buffer, - size_t buflen); + size_t buflen); static off_t fb_seek(FAR struct file *filep, off_t offset, int whence); static int fb_ioctl(FAR struct file *filep, int cmd, unsigned long arg); @@ -77,8 +75,8 @@ static int fb_ioctl(FAR struct file *filep, int cmd, unsigned long arg); static const struct file_operations fb_fops = { - fb_open, /* open */ - fb_close, /* close */ + NULL, /* open */ + NULL, /* close */ fb_read, /* read */ fb_write, /* write */ fb_seek, /* seek */ @@ -93,34 +91,6 @@ static const struct file_operations fb_fops = * Private Functions ****************************************************************************/ -/**************************************************************************** - * Name: fb_open - * - * Description: - * This function is called whenever the framebuffer device is opened. - * - ****************************************************************************/ - -static int fb_open(FAR struct file *filep) -{ - DEBUGASSERT(filep != NULL && filep->f_inode != NULL); - return OK; -} - -/**************************************************************************** - * Name: fb_close - * - * Description: - * This function is called when the framebuffer device is closed. - * - ****************************************************************************/ - -static int fb_close(FAR struct file *filep) -{ - DEBUGASSERT(filep != NULL && filep->f_inode != NULL); - return OK; -} - /**************************************************************************** * Name: fb_read ****************************************************************************/ diff --git a/drivers/video/max7456.c b/drivers/video/max7456.c index f04a983fa13cd..9c842d1c16c57 100644 --- a/drivers/video/max7456.c +++ b/drivers/video/max7456.c @@ -311,17 +311,12 @@ struct mx7_dev_s ****************************************************************************/ static int mx7_open(FAR struct file *filep); -static int mx7_close(FAR struct file *filep); static ssize_t mx7_read(FAR struct file *filep, FAR char *buf, size_t len); static ssize_t mx7_write(FAR struct file *filep, FAR const char *buf, size_t len); -static int mx7_ioctl(FAR struct file *filep, - int cmd, unsigned long arg); #if defined(DEBUG) -static int mx7_debug_open(FAR struct file *filep); -static int mx7_debug_close(FAR struct file *filep); static ssize_t mx7_debug_read(FAR struct file *filep, FAR char *buf, size_t len); static ssize_t mx7_debug_write(FAR struct file *filep, @@ -337,11 +332,11 @@ static ssize_t mx7_debug_write(FAR struct file *filep, static const struct file_operations g_mx7_fops = { mx7_open, /* open */ - mx7_close, /* close */ + NULL, /* close */ mx7_read, /* read */ mx7_write, /* write */ NULL, /* seek */ - mx7_ioctl, /* ioctl */ + NULL, /* ioctl */ NULL /* poll */ #ifndef CONFIG_DISABLE_PSEUDOFS_OPERATIONS , NULL /* unlink */ @@ -354,8 +349,8 @@ static const struct file_operations g_mx7_fops = static const struct file_operations g_mx7_debug_fops = { - mx7_debug_open, /* open */ - mx7_debug_close, /* close */ + NULL, /* open */ + NULL, /* close */ mx7_debug_read, /* read */ mx7_debug_write, /* write */ NULL, /* seek */ @@ -1287,19 +1282,6 @@ static int mx7_open(FAR struct file *filep) return 0; } -/**************************************************************************** - * Name: mx7_close - * - * Description: - * The usual file-operations close() method. - ****************************************************************************/ - -static int mx7_close(FAR struct file *filep) -{ - UNUSED(filep); - return 0; -} - /**************************************************************************** * Name: mx7_read_cm * @@ -1474,24 +1456,6 @@ static ssize_t mx7_write(FAR struct file *filep, return ret; } -/**************************************************************************** - * Name: mx7_ioctl - * - * Description: - * Does nothing, because I don't like ioctls. - * - ****************************************************************************/ - -static int mx7_ioctl(FAR struct file *filep, int cmd, unsigned long arg) -{ - FAR struct inode *inode = filep->f_inode; - FAR struct mx7_dev_s *dev = inode->i_private; - - UNUSED(inode); - UNUSED(dev); - return -ENOTTY; /* unsupported ioctl */ -} - #if defined(DEBUG) /**************************************************************************** @@ -1540,39 +1504,6 @@ static int hex_to_uint8(FAR const char *buf) return strtol(buf, NULL, 16); } -/**************************************************************************** - * Name: mx7_debug_open - * - * Description: - * Ordinary file-operations open() for debug-related interfaces. - * - ****************************************************************************/ - -static int mx7_debug_open(FAR struct file *filep) -{ - FAR struct inode *inode = filep->f_inode; - FAR struct mx7_dev_s *dev = inode->i_private; - FAR const char *name = inode->i_name; - - UNUSED(inode); - UNUSED(dev); - UNUSED(name); - return 0; -} - -/**************************************************************************** - * Name: mx7_debug_close - * - * Description: - * Ordinary file-operations close() for debug-related interfaces. - * - ****************************************************************************/ - -static int mx7_debug_close(FAR struct file *filep) -{ - return 0; -} - /**************************************************************************** * Name: mx7_debug_read * diff --git a/drivers/video/video.c b/drivers/video/video.c index a7b04d976d359..685c7465c2c5f 100644 --- a/drivers/video/video.c +++ b/drivers/video/video.c @@ -2985,12 +2985,12 @@ int video_uninitialize(void) return OK; } -void imgsensor_register(const FAR struct imgsensor_ops_s *ops) +void imgsensor_register(FAR const struct imgsensor_ops_s *ops) { g_video_sensor_ops = ops; } -void imgdata_register(const FAR struct imgdata_ops_s *ops) +void imgdata_register(FAR const struct imgdata_ops_s *ops) { g_video_data_ops = ops; } diff --git a/drivers/wireless/gs2200m.c b/drivers/wireless/gs2200m.c index 6cad12768033c..ccfcf2a5967f5 100644 --- a/drivers/wireless/gs2200m.c +++ b/drivers/wireless/gs2200m.c @@ -201,8 +201,6 @@ struct gs2200m_dev_s /* Character driver methods */ -static int gs2200m_open(FAR struct file *filep); -static int gs2200m_close(FAR struct file *filep); static ssize_t gs2200m_read(FAR struct file *filep, FAR char *buff, size_t len); static ssize_t gs2200m_write(FAR struct file *filep, FAR const char *buff, @@ -227,8 +225,8 @@ static void _remove_all_pkt(FAR struct gs2200m_dev_s *dev, uint8_t c); static const struct file_operations g_gs2200m_fops = { - gs2200m_open, /* open */ - gs2200m_close, /* close */ + NULL, /* open */ + NULL, /* close */ gs2200m_read, /* read */ gs2200m_write, /* write */ NULL, /* seek */ @@ -709,24 +707,6 @@ static void gs2200m_unlock(FAR struct gs2200m_dev_s *dev) nxsem_post(&dev->dev_sem); } -/**************************************************************************** - * Name: gs2200m_open - ****************************************************************************/ - -static int gs2200m_open(FAR struct file *filep) -{ - return OK; -} - -/**************************************************************************** - * Name: gs2200m_close - ****************************************************************************/ - -static int gs2200m_close(FAR struct file *filep) -{ - return OK; -} - /**************************************************************************** * Name: gs2200m_read ****************************************************************************/ diff --git a/drivers/wireless/nrf24l01.c b/drivers/wireless/nrf24l01.c index f7003e7acfeca..046d84e1ae5aa 100644 --- a/drivers/wireless/nrf24l01.c +++ b/drivers/wireless/nrf24l01.c @@ -172,39 +172,39 @@ static void nrf24l01_lock(FAR struct spi_dev_s *spi); static void nrf24l01_unlock(FAR struct spi_dev_s *spi); static uint8_t nrf24l01_access(FAR struct nrf24l01_dev_s *dev, - nrf24l01_access_mode_t mode, uint8_t cmd, FAR uint8_t *buf, - int length); + nrf24l01_access_mode_t mode, uint8_t cmd, + FAR uint8_t *buf, int length); static uint8_t nrf24l01_flush_rx(FAR struct nrf24l01_dev_s *dev); static uint8_t nrf24l01_flush_tx(FAR struct nrf24l01_dev_s *dev); /* Read register from nrf24 */ static uint8_t nrf24l01_readreg(FAR struct nrf24l01_dev_s *dev, uint8_t reg, - FAR uint8_t *value, int len); + FAR uint8_t *value, int len); /* Read single byte value from a register of nrf24 */ static uint8_t nrf24l01_readregbyte(FAR struct nrf24l01_dev_s *dev, - uint8_t reg); + uint8_t reg); static void nrf24l01_writeregbyte(FAR struct nrf24l01_dev_s *dev, - uint8_t reg, uint8_t value); + uint8_t reg, uint8_t value); static uint8_t nrf24l01_setregbit(FAR struct nrf24l01_dev_s *dev, - uint8_t reg, uint8_t value, bool set); + uint8_t reg, uint8_t value, bool set); static void nrf24l01_tostate(FAR struct nrf24l01_dev_s *dev, - nrf24l01_state_t state); + nrf24l01_state_t state); static int nrf24l01_irqhandler(FAR int irq, FAR void *context, - FAR void *arg); + FAR void *arg); static inline int nrf24l01_attachirq(FAR struct nrf24l01_dev_s *dev, - xcpt_t isr, FAR void *arg); + xcpt_t isr, FAR void *arg); static int dosend(FAR struct nrf24l01_dev_s *dev, FAR const uint8_t *data, - size_t datalen); + size_t datalen); static int nrf24l01_unregister(FAR struct nrf24l01_dev_s *dev); #ifdef CONFIG_WL_NRF24L01_RXSUPPORT static void fifoput(FAR struct nrf24l01_dev_s *dev, uint8_t pipeno, - FAR uint8_t *buffer, uint8_t buflen); + FAR uint8_t *buffer, uint8_t buflen); static uint8_t fifoget(FAR struct nrf24l01_dev_s *dev, FAR uint8_t *buffer, - uint8_t buflen, FAR uint8_t *pipeno); + uint8_t buflen, FAR uint8_t *pipeno); static void nrf24l01_worker(FAR void *arg); #endif @@ -218,13 +218,13 @@ static void binarycvt(FAR char *deststr, FAR const uint8_t *srcbin, static int nrf24l01_open(FAR struct file *filep); static int nrf24l01_close(FAR struct file *filep); static ssize_t nrf24l01_read(FAR struct file *filep, FAR char *buffer, - size_t buflen); + size_t buflen); static ssize_t nrf24l01_write(FAR struct file *filep, - FAR const char *buffer, size_t buflen); + FAR const char *buffer, size_t buflen); static int nrf24l01_ioctl(FAR struct file *filep, int cmd, - unsigned long arg); + unsigned long arg); static int nrf24l01_poll(FAR struct file *filep, FAR struct pollfd *fds, - bool setup); + bool setup); /**************************************************************************** * Private Data @@ -2120,6 +2120,6 @@ void nrf24l01_dumprxfifo(FAR struct nrf24l01_dev_s *dev) { syslog(LOG_INFO, "bytes count: %d\n", dev->fifo_len); syslog(LOG_INFO, "next read: %d, next write: %d\n", - dev->nxt_read, dev-> nxt_write); + dev->nxt_read, dev->nxt_write); } #endif /* CONFIG_DEBUG_WIRELESS && CONFIG_WL_NRF24L01_RXSUPPORT */ diff --git a/fs/aio/aio_initialize.c b/fs/aio/aio_initialize.c index d2381314063f9..968065a513f3e 100644 --- a/fs/aio/aio_initialize.c +++ b/fs/aio/aio_initialize.c @@ -50,7 +50,7 @@ static dq_queue_t g_aioc_free; /* This counting semaphore tracks the number of free AIO containers */ static sem_t g_aioc_freesem = NXSEM_INITIALIZER(CONFIG_FS_NAIOC, - SEM_PRIO_NONE); + PRIOINHERIT_FLAGS_DISABLE); /* This binary semaphore supports exclusive access to the list of pending * asynchronous I/O. g_aio_holder and a_aio_count support the reentrant diff --git a/fs/dirent/fs_opendir.c b/fs/dirent/fs_opendir.c index 354c49025a1e9..e41b46998f3e2 100644 --- a/fs/dirent/fs_opendir.c +++ b/fs/dirent/fs_opendir.c @@ -74,28 +74,11 @@ static inline int open_mountpoint(FAR struct inode *inode, return -ENOSYS; } - /* Take reference to the mountpoint inode. Note that we do not use - * inode_addref() because we already hold the tree semaphore. - */ - - inode->i_crefs++; - /* Perform the opendir() operation */ ret = inode->u.i_mops->opendir(inode, relpath, dir); if (ret < 0) { - /* We now need to back off our reference to the inode. We can't - * call inode_release() to do that unless we release the tree - * semaphore. The following should be safe because: (1) after the - * reference count was incremented above it should be >=1 so it should - * not decrement below zero, and (2) we hold the tree semaphore so no - * other thread should be able to change the reference count. - */ - - inode->i_crefs--; - DEBUGASSERT(inode->i_crefs >= 0); - /* Negate the error value so that it can be used to set errno */ return ret; @@ -126,11 +109,10 @@ static void open_pseudodir(FAR struct inode *inode, { /* We have a valid pseudo-filesystem node. Take two references on the * inode -- one for the parent (fd_root) and one for the child (fd_next). - * Note that we do not call inode_addref because we are holding the tree - * semaphore and that would result in deadlock. */ - inode->i_crefs += 2; + inode_addref(inode); + dir->fd_root = inode; /* Save the inode where we start */ dir->u.pseudo.fd_next = inode; /* This is the next node to use for readdir() */ @@ -224,33 +206,20 @@ FAR DIR *opendir(FAR const char *path) SETUP_SEARCH(&desc, path, false); - ret = inode_semtake(); + ret = inode_find(&desc); if (ret < 0) { - goto errout; + goto errout_with_search; } - /* Find the node matching the path. */ + /* Get the search results */ - ret = inode_search(&desc); - if (ret >= 0) - { - inode = desc.node; - DEBUGASSERT(inode != NULL); #ifndef CONFIG_DISABLE_MOUNTPOINT - relpath = desc.relpath; + relpath = desc.relpath; #endif - } - - /* Did we get an inode? */ - if (inode == NULL) - { - /* Inode for 'path' does not exist. */ - - ret = -ENOTDIR; - goto errout_with_semaphore; - } + inode = desc.node; + DEBUGASSERT(inode != NULL); /* Allocate a type DIR -- which is little more than an inode * container. @@ -262,7 +231,7 @@ FAR DIR *opendir(FAR const char *path) /* Insufficient memory to complete the operation. */ ret = -ENOMEM; - goto errout_with_semaphore; + goto errout_with_inode; } /* Populate the DIR structure and return it to the caller. The way that @@ -320,7 +289,6 @@ FAR DIR *opendir(FAR const char *path) } RELEASE_SEARCH(&desc); - inode_semgive(); return ((FAR DIR *)dir); /* Nasty goto's make error handling simpler */ @@ -328,11 +296,11 @@ FAR DIR *opendir(FAR const char *path) errout_with_direntry: kumm_free(dir); -errout_with_semaphore: - RELEASE_SEARCH(&desc); - inode_semgive(); +errout_with_inode: + inode_release(inode); -errout: +errout_with_search: + RELEASE_SEARCH(&desc); set_errno(-ret); return NULL; } diff --git a/fs/fat/fs_fat32dirent.c b/fs/fat/fs_fat32dirent.c index 4339228427c5e..5c29723ad56e3 100644 --- a/fs/fat/fs_fat32dirent.c +++ b/fs/fat/fs_fat32dirent.c @@ -339,7 +339,7 @@ static inline int fat_parsesfname(FAR const char **path, enum fat_case_e extcase = FATCASE_UNKNOWN; #endif #endif - const FAR char *node = *path; + FAR const char *node = *path; int endndx; uint8_t ch; int ndx = 0; diff --git a/fs/inode/fs_files.c b/fs/inode/fs_files.c index ba310176f42eb..a4cde7676fb85 100644 --- a/fs/inode/fs_files.c +++ b/fs/inode/fs_files.c @@ -71,6 +71,11 @@ static int files_extend(FAR struct filelist *list, size_t row) return 0; } + if (row * CONFIG_NFILE_DESCRIPTORS_PER_BLOCK > OPEN_MAX) + { + return -EMFILE; + } + tmp = kmm_realloc(list->fl_files, sizeof(FAR struct file *) * row); DEBUGASSERT(tmp); if (tmp == NULL) @@ -356,7 +361,7 @@ int fs_getfilep(int fd, FAR struct file **filep) return -EAGAIN; } - if ((unsigned int)fd >= CONFIG_NFILE_DESCRIPTORS_PER_BLOCK * list->fl_rows) + if (fd < 0 || fd >= list->fl_rows * CONFIG_NFILE_DESCRIPTORS_PER_BLOCK) { return -EBADF; } @@ -368,13 +373,24 @@ int fs_getfilep(int fd, FAR struct file **filep) /* And return the file pointer from the list */ ret = _files_semtake(list); - if (ret >= 0) + if (ret < 0) { - *filep = &list->fl_files[fd / CONFIG_NFILE_DESCRIPTORS_PER_BLOCK] - [fd % CONFIG_NFILE_DESCRIPTORS_PER_BLOCK]; - _files_semgive(list); + return ret; } + *filep = &list->fl_files[fd / CONFIG_NFILE_DESCRIPTORS_PER_BLOCK] + [fd % CONFIG_NFILE_DESCRIPTORS_PER_BLOCK]; + + /* if f_inode is NULL, fd was closed */ + + if (!(*filep)->f_inode) + { + *filep = (FAR struct file *)NULL; + ret = -EBADF; + } + + _files_semgive(list); + return ret; } diff --git a/fs/littlefs/lfs_vfs.c b/fs/littlefs/lfs_vfs.c index 2a6ff29927063..3850cdd9c6f3d 100644 --- a/fs/littlefs/lfs_vfs.c +++ b/fs/littlefs/lfs_vfs.c @@ -563,7 +563,14 @@ static int littlefs_ioctl(FAR struct file *filep, int cmd, unsigned long arg) } else { - return drv->u.i_bops->ioctl(drv, cmd, arg); + if (drv->u.i_bops->ioctl != NULL) + { + return drv->u.i_bops->ioctl(drv, cmd, arg); + } + else + { + return -ENOTTY; + } } } @@ -998,7 +1005,14 @@ static int littlefs_sync_block(FAR const struct lfs_config *c) } else { - ret = drv->u.i_bops->ioctl(drv, BIOC_FLUSH, 0); + if (drv->u.i_bops->ioctl != NULL) + { + ret = drv->u.i_bops->ioctl(drv, BIOC_FLUSH, 0); + } + else + { + ret = -ENOTTY; + } } return ret == -ENOTTY ? OK : ret; @@ -1053,8 +1067,16 @@ static int littlefs_bind(FAR struct inode *driver, FAR const void *data, { /* Try to get FLT MTD geometry first */ - ret = driver->u.i_bops->ioctl(driver, MTDIOC_GEOMETRY, - (unsigned long)&fs->geo); + if (driver->u.i_bops->ioctl != NULL) + { + ret = driver->u.i_bops->ioctl(driver, MTDIOC_GEOMETRY, + (unsigned long)&fs->geo); + } + else + { + ret = -ENOTTY; + } + if (ret < 0) { struct geometry geometry; diff --git a/fs/procfs/fs_procfstcbinfo.c b/fs/procfs/fs_procfstcbinfo.c index 4af35f9e5372c..3e70f955a687e 100644 --- a/fs/procfs/fs_procfstcbinfo.c +++ b/fs/procfs/fs_procfstcbinfo.c @@ -195,7 +195,7 @@ static ssize_t tcbinfo_read(FAR struct file *filep, FAR char *buffer, if (filep->f_pos == 0) { linesize = procfs_snprintf(attr->line, TCBINFO_LINELEN, - "pointer %p size %d\n", g_tcbinfo, + "pointer %p size %d\n", &g_tcbinfo, sizeof(struct tcbinfo_s)); /* Save the linesize in case we are re-entered with f_pos > 0 */ diff --git a/fs/romfs/fs_romfs.c b/fs/romfs/fs_romfs.c index 80d4c4210a5a3..ea773ed0044f2 100644 --- a/fs/romfs/fs_romfs.c +++ b/fs/romfs/fs_romfs.c @@ -870,7 +870,8 @@ static int romfs_readdir(FAR struct inode *mountpt, #ifdef CONFIG_FS_ROMFS_CACHE_NODE next = (*dir->u.romfs.fr_currnode)->rn_next; - strcpy(dir->fd_dir.d_name, (*dir->u.romfs.fr_currnode)->rn_name); + strlcpy(dir->fd_dir.d_name, (*dir->u.romfs.fr_currnode)->rn_name, + sizeof(dir->fd_dir.d_name)); dir->u.romfs.fr_currnode++; #else /* Parse the directory entry */ diff --git a/fs/romfs/fs_romfsutil.c b/fs/romfs/fs_romfsutil.c index 1d4d91c808ac0..0cb1038d4a17e 100644 --- a/fs/romfs/fs_romfsutil.c +++ b/fs/romfs/fs_romfsutil.c @@ -50,6 +50,16 @@ #define LINK_FOLLOWED 1 #define NODEINFO_NINCR 4 +/**************************************************************************** + * Private Types + ****************************************************************************/ + +struct romfs_entryname_s +{ + FAR const char *re_name; + size_t re_len; +}; + /**************************************************************************** * Private Functions ****************************************************************************/ @@ -268,17 +278,22 @@ static int romfs_followhardlinks(FAR struct romfs_mountpt_s *rm, static int romfs_nodeinfo_search(FAR const void *a, FAR const void *b) { FAR struct romfs_nodeinfo_s *nodeinfo = *(FAR struct romfs_nodeinfo_s **)b; + FAR const struct romfs_entryname_s *entry = a; FAR const char *name2 = nodeinfo->rn_name; - FAR const char *name1 = a; size_t len = nodeinfo->rn_namesize; int ret; - ret = strncmp(name1, name2, len); + if (len > entry->re_len) + { + len = entry->re_len; + } + + ret = strncmp(entry->re_name, name2, len); if (!ret) { - if (name1[len] == '/' || name1[len] == '\0') + if (entry->re_name[len] == '/' || entry->re_name[len] == '\0') { - return 0; + return name2[len] == '\0' ? 0 : -1; } else { @@ -291,9 +306,12 @@ static int romfs_nodeinfo_search(FAR const void *a, FAR const void *b) static int romfs_nodeinfo_compare(FAR const void *a, FAR const void *b) { - FAR const char *name = (*(FAR struct romfs_nodeinfo_s **)a)->rn_name; + FAR struct romfs_nodeinfo_s *nodeinfo = *(FAR struct romfs_nodeinfo_s **)a; + struct romfs_entryname_s entry; - return romfs_nodeinfo_search(name, b); + entry.re_name = nodeinfo->rn_name; + entry.re_len = nodeinfo->rn_namesize; + return romfs_nodeinfo_search(&entry, b); } #endif @@ -312,8 +330,11 @@ static inline int romfs_searchdir(FAR struct romfs_mountpt_s *rm, { #ifdef CONFIG_FS_ROMFS_CACHE_NODE FAR struct romfs_nodeinfo_s **cnodeinfo; + struct romfs_entryname_s entry; - cnodeinfo = bsearch(entryname, nodeinfo->rn_child, nodeinfo->rn_count, + entry.re_name = entryname; + entry.re_len = entrylen; + cnodeinfo = bsearch(&entry, nodeinfo->rn_child, nodeinfo->rn_count, sizeof(*nodeinfo->rn_child), romfs_nodeinfo_search); if (cnodeinfo) { diff --git a/fs/rpmsgfs/Kconfig b/fs/rpmsgfs/Kconfig index 30995a5f2d81d..d59a588eb3203 100644 --- a/fs/rpmsgfs/Kconfig +++ b/fs/rpmsgfs/Kconfig @@ -6,7 +6,7 @@ config FS_RPMSGFS bool "RPMSG File System" default n - depends on OPENAMP + depends on RPTUN ---help--- Use rpmsg file system to mount remote directories to local. This the method for user to use remote file like own core. diff --git a/fs/rpmsgfs/rpmsgfs.c b/fs/rpmsgfs/rpmsgfs.c index 5b737b36fee7f..36ef3fd90a7c1 100644 --- a/fs/rpmsgfs/rpmsgfs.c +++ b/fs/rpmsgfs/rpmsgfs.c @@ -44,6 +44,12 @@ #include "rpmsgfs.h" +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +#define RPMSGFS_RETRY_DELAY_MS 10 + /**************************************************************************** * Private Types ****************************************************************************/ @@ -71,6 +77,7 @@ struct rpmsgfs_mountpt_s FAR struct rpmsgfs_ofile_s *fs_head; /* Singly-linked list of open files */ char fs_root[PATH_MAX]; void *handle; + int timeout; /* Connect timeout */ }; /**************************************************************************** @@ -200,7 +207,7 @@ static void rpmsgfs_semgive(FAR struct rpmsgfs_mountpt_s *fs) * ****************************************************************************/ -static void rpmsgfs_mkpath(FAR struct rpmsgfs_mountpt_s *fs, +static void rpmsgfs_mkpath(FAR struct rpmsgfs_mountpt_s *fs, FAR const char *relpath, FAR char *path, int pathlen) { @@ -252,6 +259,21 @@ static void rpmsgfs_mkpath(FAR struct rpmsgfs_mountpt_s *fs, { strncat(path, &relpath[first], pathlen - strlen(path) - 1); } + + while (fs->timeout > 0) + { + struct stat buf; + int ret; + + ret = rpmsgfs_client_stat(fs->handle, fs->fs_root, &buf); + if (ret == 0) + { + break; + } + + usleep(RPMSGFS_RETRY_DELAY_MS * USEC_PER_MSEC); + fs->timeout -= RPMSGFS_RETRY_DELAY_MS; + } } /**************************************************************************** @@ -1055,6 +1077,7 @@ static int rpmsgfs_bind(FAR struct inode *blkdriver, FAR const void *data, /* The options we support are: * "fs=whatever,cpu=cpuname", remote dir + * "timeout=xx", connect timeout, unit (ms) */ options = strdup(data); @@ -1064,6 +1087,10 @@ static int rpmsgfs_bind(FAR struct inode *blkdriver, FAR const void *data, return -ENOMEM; } + /* Set timeout default value */ + + fs->timeout = INT_MAX; + ptr = strtok_r(options, ",", &saveptr); while (ptr != NULL) { @@ -1075,6 +1102,10 @@ static int rpmsgfs_bind(FAR struct inode *blkdriver, FAR const void *data, { cpuname = &ptr[4]; } + else if ((strncmp(ptr, "timeout=", 8) == 0)) + { + fs->timeout = atoi(&ptr[8]); + } ptr = strtok_r(NULL, ",", &saveptr); } diff --git a/fs/rpmsgfs/rpmsgfs.h b/fs/rpmsgfs/rpmsgfs.h index 59cc3ab15ec78..fe102c9d9de81 100644 --- a/fs/rpmsgfs/rpmsgfs.h +++ b/fs/rpmsgfs/rpmsgfs.h @@ -110,7 +110,9 @@ begin_packed_struct struct rpmsgfs_ioctl_s struct rpmsgfs_header_s header; int32_t fd; int32_t request; - int32_t arg; + uint64_t arg; + uint32_t arglen; + char buf[0]; } end_packed_struct; #define rpmsgfs_sync_s rpmsgfs_close_s diff --git a/fs/rpmsgfs/rpmsgfs_client.c b/fs/rpmsgfs/rpmsgfs_client.c index 29a1dd02dac37..97456ceb8ff8b 100644 --- a/fs/rpmsgfs/rpmsgfs_client.c +++ b/fs/rpmsgfs/rpmsgfs_client.c @@ -28,6 +28,7 @@ #include #include +#include #include #include #include @@ -42,6 +43,7 @@ struct rpmsgfs_s { struct rpmsg_endpoint ept; char cpuname[RPMSG_NAME_SIZE]; + sem_t wait; }; struct rpmsgfs_cookie_s @@ -61,6 +63,9 @@ static int rpmsgfs_default_handler(FAR struct rpmsg_endpoint *ept, static int rpmsgfs_read_handler(FAR struct rpmsg_endpoint *ept, FAR void *data, size_t len, uint32_t src, FAR void *priv); +static int rpmsgfs_ioctl_handler(FAR struct rpmsg_endpoint *ept, + FAR void *data, size_t len, + uint32_t src, FAR void *priv); static int rpmsgfs_readdir_handler(FAR struct rpmsg_endpoint *ept, FAR void *data, size_t len, uint32_t src, FAR void *priv); @@ -93,7 +98,7 @@ static const rpmsg_ept_cb g_rpmsgfs_handler[] = [RPMSGFS_READ] = rpmsgfs_read_handler, [RPMSGFS_WRITE] = rpmsgfs_default_handler, [RPMSGFS_LSEEK] = rpmsgfs_default_handler, - [RPMSGFS_IOCTL] = rpmsgfs_default_handler, + [RPMSGFS_IOCTL] = rpmsgfs_ioctl_handler, [RPMSGFS_SYNC] = rpmsgfs_default_handler, [RPMSGFS_DUP] = rpmsgfs_default_handler, [RPMSGFS_FSTAT] = rpmsgfs_stat_handler, @@ -130,7 +135,7 @@ static int rpmsgfs_default_handler(FAR struct rpmsg_endpoint *ept, memcpy(cookie->data, data, len); } - nxsem_post(&cookie->sem); + rpmsg_post(ept, &cookie->sem); return 0; } @@ -150,7 +155,26 @@ static int rpmsgfs_read_handler(FAR struct rpmsg_endpoint *ept, memcpy(cookie->data, rsp->buf, cookie->result); } - nxsem_post(&cookie->sem); + rpmsg_post(ept, &cookie->sem); + + return 0; +} + +static int rpmsgfs_ioctl_handler(FAR struct rpmsg_endpoint *ept, + FAR void *data, size_t len, + uint32_t src, FAR void *priv) +{ + FAR struct rpmsgfs_header_s *header = data; + FAR struct rpmsgfs_cookie_s *cookie = + (FAR struct rpmsgfs_cookie_s *)(uintptr_t)header->cookie; + FAR struct rpmsgfs_ioctl_s *rsp = data; + + if (cookie->result >= 0 && rsp->arglen > 0) + { + memcpy(cookie->data, (FAR void *)(uintptr_t)rsp->arg, rsp->arglen); + } + + rpmsg_post(ept, &cookie->sem); return 0; } @@ -172,7 +196,7 @@ static int rpmsgfs_readdir_handler(FAR struct rpmsg_endpoint *ept, entry->d_type = rsp->type; } - nxsem_post(&cookie->sem); + rpmsg_post(ept, &cookie->sem); return 0; } @@ -200,7 +224,7 @@ static int rpmsgfs_statfs_handler(FAR struct rpmsg_endpoint *ept, buf->f_ffree = rsp->buf.f_ffree; } - nxsem_post(&cookie->sem); + rpmsg_post(ept, &cookie->sem); return 0; } @@ -233,11 +257,32 @@ static int rpmsgfs_stat_handler(FAR struct rpmsg_endpoint *ept, buf->st_blocks = rsp->buf.st_blocks; } - nxsem_post(&cookie->sem); + rpmsg_post(ept, &cookie->sem); return 0; } +static FAR void *rpmsgfs_get_tx_payload_buffer(FAR struct rpmsgfs_s *priv, + FAR uint32_t *len) +{ + int sval; + + nxsem_get_value(&priv->wait, &sval); + if (sval <= 0) + { + rpmsg_wait(&priv->ept, &priv->wait); + rpmsg_post(&priv->ept, &priv->wait); + } + + return rpmsg_get_tx_payload_buffer(&priv->ept, len, true); +} + +static void rpmsgfs_ns_bound(struct rpmsg_endpoint *ept) +{ + FAR struct rpmsgfs_s *priv = ept->priv; + rpmsg_post(&priv->ept, &priv->wait); +} + static void rpmsgfs_device_created(FAR struct rpmsg_device *rdev, FAR void *priv_) { @@ -247,6 +292,7 @@ static void rpmsgfs_device_created(FAR struct rpmsg_device *rdev, if (strcmp(priv->cpuname, rpmsg_get_cpuname(rdev)) == 0) { priv->ept.priv = priv; + priv->ept.ns_bound_cb = rpmsgfs_ns_bound; snprintf(buf, sizeof(buf), "%s%p", RPMSGFS_NAME_PREFIX, priv); rpmsg_create_ept(&priv->ept, rdev, buf, RPMSG_ADDR_ANY, RPMSG_ADDR_ANY, @@ -319,7 +365,7 @@ static int rpmsgfs_send_recv(FAR struct rpmsgfs_s *priv, goto fail; } - ret = nxsem_wait_uninterruptible(&cookie.sem); + ret = rpmsg_wait(&priv->ept, &cookie.sem); if (ret == 0) { ret = cookie.result; @@ -330,6 +376,19 @@ static int rpmsgfs_send_recv(FAR struct rpmsgfs_s *priv, return ret; } +static size_t rpmsgfs_ioctl_arglen(int cmd) +{ + switch (cmd) + { + case FIONBIO: + case FIONWRITE: + case FIONREAD: + return sizeof(int); + default: + return 0; + } +} + /**************************************************************************** * Public Functions ****************************************************************************/ @@ -345,7 +404,7 @@ int rpmsgfs_client_open(FAR void *handle, FAR const char *pathname, len = sizeof(*msg); len += strlen(pathname) + 1; - msg = rpmsg_get_tx_payload_buffer(&priv->ept, &space, true); + msg = rpmsgfs_get_tx_payload_buffer(priv, &space); if (!msg) { return -ENOMEM; @@ -412,7 +471,7 @@ ssize_t rpmsgfs_client_write(FAR void *handle, int fd, FAR struct rpmsgfs_write_s *msg; uint32_t space; - msg = rpmsg_get_tx_payload_buffer(&priv->ept, &space, true); + msg = rpmsgfs_get_tx_payload_buffer(priv, &space); if (!msg) { ret = -ENOMEM; @@ -460,15 +519,34 @@ off_t rpmsgfs_client_lseek(FAR void *handle, int fd, int rpmsgfs_client_ioctl(FAR void *handle, int fd, int request, unsigned long arg) { - struct rpmsgfs_ioctl_s msg = - { - .fd = fd, - .request = request, - .arg = arg, - }; + size_t arglen = rpmsgfs_ioctl_arglen(request); + FAR struct rpmsgfs_s *priv = handle; + FAR struct rpmsgfs_ioctl_s *msg; + uint32_t space; + size_t len; - return rpmsgfs_send_recv(handle, RPMSGFS_IOCTL, true, - (struct rpmsgfs_header_s *)&msg, sizeof(msg), NULL); + len = sizeof(*msg) + arglen; + msg = rpmsgfs_get_tx_payload_buffer(priv, &space); + if (msg == NULL) + { + return -ENOMEM; + } + + DEBUGASSERT(len <= space); + + msg->fd = fd; + msg->request = request; + msg->arg = arg; + msg->arglen = arglen; + + if (arglen > 0) + { + memcpy(msg->buf, (FAR void *)(uintptr_t)arg, arglen); + } + + return rpmsgfs_send_recv(handle, RPMSGFS_IOCTL, false, + (FAR struct rpmsgfs_header_s *)msg, len, + arglen > 0 ? (FAR void *)arg : NULL); } void rpmsgfs_client_sync(FAR void *handle, int fd) @@ -527,7 +605,7 @@ FAR void *rpmsgfs_client_opendir(FAR void *handle, FAR const char *name) len = sizeof(*msg); len += strlen(name) + 1; - msg = rpmsg_get_tx_payload_buffer(&priv->ept, &space, true); + msg = rpmsgfs_get_tx_payload_buffer(priv, &space); if (!msg) { return NULL; @@ -593,6 +671,8 @@ int rpmsgfs_client_bind(FAR void **handle, FAR const char *cpuname) return ret; } + nxsem_init(&priv->wait, 0, 0); + nxsem_set_protocol(&priv->wait, SEM_PRIO_NONE); *handle = priv; return 0; @@ -607,6 +687,7 @@ int rpmsgfs_client_unbind(FAR void *handle) rpmsgfs_device_destroy, NULL); + nxsem_destroy(&priv->wait); kmm_free(priv); return 0; } @@ -633,7 +714,7 @@ int rpmsgfs_client_statfs(FAR void *handle, FAR const char *path, len = sizeof(*msg); len += strlen(path) + 1; - msg = rpmsg_get_tx_payload_buffer(&priv->ept, &space, true); + msg = rpmsgfs_get_tx_payload_buffer(priv, &space); if (!msg) { return -ENOMEM; @@ -657,7 +738,7 @@ int rpmsgfs_client_unlink(FAR void *handle, FAR const char *pathname) len = sizeof(*msg); len += strlen(pathname) + 1; - msg = rpmsg_get_tx_payload_buffer(&priv->ept, &space, true); + msg = rpmsgfs_get_tx_payload_buffer(priv, &space); if (!msg) { return -ENOMEM; @@ -682,7 +763,7 @@ int rpmsgfs_client_mkdir(FAR void *handle, FAR const char *pathname, len = sizeof(*msg); len += strlen(pathname) + 1; - msg = rpmsg_get_tx_payload_buffer(&priv->ept, &space, true); + msg = rpmsgfs_get_tx_payload_buffer(priv, &space); if (!msg) { return -ENOMEM; @@ -705,7 +786,7 @@ int rpmsgfs_client_rmdir(FAR void *handle, FAR const char *pathname) len = sizeof(*msg); len += strlen(pathname) + 1; - msg = rpmsg_get_tx_payload_buffer(&priv->ept, &space, true); + msg = rpmsgfs_get_tx_payload_buffer(priv, &space); if (!msg) { return -ENOMEM; @@ -735,7 +816,7 @@ int rpmsgfs_client_rename(FAR void *handle, FAR const char *oldpath, newlen = strlen(newpath) + 1; len = sizeof(*msg) + alignlen + newlen; - msg = rpmsg_get_tx_payload_buffer(&priv->ept, &space, true); + msg = rpmsgfs_get_tx_payload_buffer(priv, &space); if (!msg) { return -ENOMEM; @@ -761,7 +842,7 @@ int rpmsgfs_client_stat(FAR void *handle, FAR const char *path, len = sizeof(*msg); len += strlen(path) + 1; - msg = rpmsg_get_tx_payload_buffer(&priv->ept, &space, true); + msg = rpmsgfs_get_tx_payload_buffer(priv, &space); if (!msg) { return -ENOMEM; @@ -790,7 +871,7 @@ int rpmsgfs_client_fchstat(FAR void *handle, int fd, } int rpmsgfs_client_chstat(FAR void *handle, FAR const char *path, - const FAR struct stat *buf, int flags) + FAR const struct stat *buf, int flags) { FAR struct rpmsgfs_s *priv = handle; FAR struct rpmsgfs_chstat_s *msg; @@ -800,7 +881,7 @@ int rpmsgfs_client_chstat(FAR void *handle, FAR const char *path, len = sizeof(*msg); len += strlen(path) + 1; - msg = rpmsg_get_tx_payload_buffer(&priv->ept, &space, true); + msg = rpmsgfs_get_tx_payload_buffer(priv, &space); if (!msg) { return -ENOMEM; diff --git a/fs/rpmsgfs/rpmsgfs_server.c b/fs/rpmsgfs/rpmsgfs_server.c index 9a7b27b5a8420..6698be31bfded 100644 --- a/fs/rpmsgfs/rpmsgfs_server.c +++ b/fs/rpmsgfs/rpmsgfs_server.c @@ -443,7 +443,8 @@ static int rpmsgfs_ioctl_handler(FAR struct rpmsg_endpoint *ept, filep = rpmsgfs_get_file(priv, msg->fd); if (filep != NULL) { - ret = file_ioctl(filep, msg->request, msg->arg); + ret = file_ioctl(filep, msg->request, msg->arglen > 0 ? + (unsigned long)msg->buf : msg->arg); } msg->header.result = ret; @@ -768,6 +769,7 @@ static int rpmsgfs_chstat_handler(FAR struct rpmsg_endpoint *ept, } else { + times[0].tv_sec = 0; times[0].tv_nsec = UTIME_OMIT; } @@ -777,6 +779,7 @@ static int rpmsgfs_chstat_handler(FAR struct rpmsg_endpoint *ept, } else { + times[1].tv_sec = 0; times[1].tv_nsec = UTIME_OMIT; } diff --git a/fs/socket/socket.c b/fs/socket/socket.c index 1245c79a53ee3..4ca9f2a9a1f70 100644 --- a/fs/socket/socket.c +++ b/fs/socket/socket.c @@ -261,6 +261,11 @@ int socket(int domain, int type, int protocol) oflags |= O_CLOEXEC; } + if (type & SOCK_NONBLOCK) + { + oflags |= O_NONBLOCK; + } + psock = kmm_zalloc(sizeof(*psock)); if (psock == NULL) { diff --git a/fs/unionfs/fs_unionfs.c b/fs/unionfs/fs_unionfs.c index 23ae2d6a6d367..7c7ea37f54723 100644 --- a/fs/unionfs/fs_unionfs.c +++ b/fs/unionfs/fs_unionfs.c @@ -96,7 +96,7 @@ struct unionfs_file_s /* Helper functions */ static int unionfs_semtake(FAR struct unionfs_inode_s *ui, bool noint); -#define unionfs_semgive(ui) (void)nxsem_post(&(ui)->ui_exclsem) +#define unionfs_semgive(ui) nxsem_post(&(ui)->ui_exclsem) static FAR const char *unionfs_offsetpath(FAR const char *relpath, FAR const char *prefix); @@ -1001,12 +1001,15 @@ static int unionfs_close(FAR struct file *filep) { unionfs_destroy(ui); } + else + { + unionfs_semgive(ui); + } /* Free the open file container */ kmm_free(uf); filep->f_priv = NULL; - unionfs_semgive(ui); return ret; } @@ -1418,6 +1421,11 @@ static int unionfs_opendir(FAR struct inode *mountpt, finfo("relpath: \"%s\"\n", relpath ? relpath : "NULL"); + if (!relpath) + { + return -EINVAL; + } + /* Recover the filesystem data from the struct inode instance */ DEBUGASSERT(mountpt != NULL && mountpt->i_private != NULL); @@ -1438,7 +1446,7 @@ static int unionfs_opendir(FAR struct inode *mountpt, * omit duplicates on file system 1. */ - if (relpath && strlen(relpath) > 0) + if (strlen(relpath) > 0) { fu->fu_relpath = strdup(relpath); if (!fu->fu_relpath) @@ -1853,6 +1861,10 @@ static int unionfs_readdir(struct inode *mountpt, struct fs_dirent_s *dir) if (ops->rewinddir != NULL) { ret = ops->rewinddir(um->um_node, fu->fu_lower[1]); + if (ret < 0) + { + return ret; + } } /* Then try the read operation again */ diff --git a/fs/vfs/fs_chstat.c b/fs/vfs/fs_chstat.c index 93c4db7e60fcd..38c0fb44f8201 100644 --- a/fs/vfs/fs_chstat.c +++ b/fs/vfs/fs_chstat.c @@ -118,7 +118,7 @@ static int chstat(FAR const char *path, /* Adjust and check buf and flags */ - if ((flags & CH_STAT_MODE) && (buf->st_mode & ~07777)) + if ((flags & CH_STAT_MODE) && (buf->st_mode & ~0177777)) { goto errout; } diff --git a/fs/vfs/fs_fchstat.c b/fs/vfs/fs_fchstat.c index df9a6b87d1349..44d83069889e7 100644 --- a/fs/vfs/fs_fchstat.c +++ b/fs/vfs/fs_fchstat.c @@ -112,7 +112,7 @@ int file_fchstat(FAR struct file *filep, FAR struct stat *buf, int flags) /* Adjust and check buf and flags */ - if ((flags & CH_STAT_MODE) && (buf->st_mode & ~07777)) + if ((flags & CH_STAT_MODE) && (buf->st_mode & ~0177777)) { return -EINVAL; } diff --git a/fs/vfs/fs_fcntl.c b/fs/vfs/fs_fcntl.c index 1f6f425eede95..64c244970f5b3 100644 --- a/fs/vfs/fs_fcntl.c +++ b/fs/vfs/fs_fcntl.c @@ -150,6 +150,11 @@ static int file_vfcntl(FAR struct file *filep, int cmd, va_list ap) oflags &= (FFCNTL & ~O_NONBLOCK); filep->f_oflags &= ~(FFCNTL & ~O_NONBLOCK); filep->f_oflags |= oflags; + + if ((filep->f_oflags & O_APPEND) != 0) + { + file_seek(filep, 0, SEEK_END); + } } } break; diff --git a/fs/vfs/fs_truncate.c b/fs/vfs/fs_truncate.c index 4ecd06c13d41a..e67339a54b580 100644 --- a/fs/vfs/fs_truncate.c +++ b/fs/vfs/fs_truncate.c @@ -31,6 +31,7 @@ #include #include +#include #include "inode/inode.h" @@ -68,7 +69,19 @@ int file_truncate(FAR struct file *filep, off_t length) */ inode = filep->f_inode; - if (inode == NULL || !INODE_IS_MOUNTPT(inode) || inode->u.i_mops == NULL) + if (inode == NULL) + { + return -EINVAL; + } + + /* If inode is not mountpoint try ioctl first */ + + if (!INODE_IS_MOUNTPT(inode)) + { + return file_ioctl(filep, FIOC_TRUNCATE, length); + } + + if (inode->u.i_mops == NULL) { fwarn("WARNING: Not a (regular) file on a mounted file system.\n"); return -EINVAL; diff --git a/graphics/nxglib/cursor/nxglib_cursor_backup.c b/graphics/nxglib/cursor/nxglib_cursor_backup.c index 72a998d953743..c6efb56d1b354 100644 --- a/graphics/nxglib/cursor/nxglib_cursor_backup.c +++ b/graphics/nxglib/cursor/nxglib_cursor_backup.c @@ -68,7 +68,7 @@ void NXGL_FUNCNAME(nxglib_cursor_backup, NXGLIB_SUFFIX) FAR uint8_t *fbmem; FAR const uint8_t *sline; FAR uint8_t *dline; - FAR const FAR NXGL_PIXEL_T *src; + FAR const NXGL_PIXEL_T *src; FAR FAR NXGL_PIXEL_T *dest; nxgl_coord_t width; nxgl_coord_t height; diff --git a/graphics/nxterm/nxterm_driver.c b/graphics/nxterm/nxterm_driver.c index b7e5489b21dcc..082404826a627 100644 --- a/graphics/nxterm/nxterm_driver.c +++ b/graphics/nxterm/nxterm_driver.c @@ -43,7 +43,7 @@ static int nxterm_open(FAR struct file *filep); static int nxterm_close(FAR struct file *filep); static ssize_t nxterm_write(FAR struct file *filep, FAR const char *buffer, - size_t buflen); + size_t buflen); static int nxterm_ioctl(FAR struct file *filep, int cmd, unsigned long arg); #ifndef CONFIG_DISABLE_PSEUDOFS_OPERATIONS @@ -166,7 +166,9 @@ static int nxterm_close(FAR struct file *filep) { /* Yes.. Unregister the terminal device */ + nxterm_sempost(priv); nxterm_unregister(priv); + return OK; } else { @@ -346,7 +348,9 @@ static int nxterm_unlink(FAR struct inode *inode) { /* No.. Unregister the terminal device now */ + nxterm_sempost(priv); nxterm_unregister(priv); + return OK; } nxterm_sempost(priv); diff --git a/graphics/nxterm/nxterm_register.c b/graphics/nxterm/nxterm_register.c index 1c5a9a7515c2f..83b3e1c94a1c1 100644 --- a/graphics/nxterm/nxterm_register.c +++ b/graphics/nxterm/nxterm_register.c @@ -138,7 +138,7 @@ FAR struct nxterm_state_s * /* Register the driver */ - snprintf(devname, NX_DEVNAME_SIZE, NX_DEVNAME_FORMAT, minor); + snprintf(devname, sizeof(devname), NX_DEVNAME_FORMAT, minor); ret = register_driver(devname, &g_nxterm_drvrops, 0666, priv); if (ret < 0) { diff --git a/include/assert.h b/include/assert.h index b7098a906e6f7..51dae09542e5d 100644 --- a/include/assert.h +++ b/include/assert.h @@ -77,7 +77,13 @@ */ #ifndef __cplusplus -# define static_assert _Static_assert +# if defined(__STDC_VERSION__) && __STDC_VERSION__ > 199901L +# define static_assert _Static_assert +# else +# define static_assert(cond, msg) \ + extern int (*__static_assert_function (void)) \ + [!!sizeof (struct { int __error_if_negative: (cond) ? 2 : -1; })] +# endif #endif /**************************************************************************** diff --git a/include/cxx/cstdlib b/include/cxx/cstdlib index 980956301d8ff..8443f4f7b0d1f 100644 --- a/include/cxx/cstdlib +++ b/include/cxx/cstdlib @@ -42,7 +42,6 @@ namespace std // Environment variable support - using ::get_environ_ptr; using ::getenv; using ::putenv; using ::clearenv; diff --git a/include/limits.h b/include/limits.h index 59f14a8f0dc29..df8355b7877e8 100644 --- a/include/limits.h +++ b/include/limits.h @@ -203,7 +203,11 @@ #define NAME_MAX _POSIX_NAME_MAX #define TTY_NAME_MAX _POSIX_NAME_MAX #define NGROUPS_MAX _POSIX_NGROUPS_MAX -#define OPEN_MAX _POSIX_OPEN_MAX +#if CONFIG_LIBC_OPEN_MAX < _POSIX_OPEN_MAX +# define OPEN_MAX _POSIX_OPEN_MAX +#else +# define OPEN_MAX CONFIG_LIBC_OPEN_MAX +#endif #define PATH_MAX _POSIX_PATH_MAX #define PIPE_BUF _POSIX_PIPE_BUF #define SIZE_MAX _POSIX_SIZE_MAX diff --git a/include/nuttx/addrenv.h b/include/nuttx/addrenv.h index 7483a88ea8cef..1e5e2d4fe90b4 100644 --- a/include/nuttx/addrenv.h +++ b/include/nuttx/addrenv.h @@ -283,6 +283,8 @@ struct addrenv_reserve_s * address environment * up_addrenv_vdata - Returns the virtual base address of the .bss/.data * address environment + * up_addrenv_vheap - Returns the virtual base address of the heap + * address environment * up_addrenv_heapsize - Returns the size of the initial heap allocation. * up_addrenv_select - Instantiate an address environment * up_addrenv_restore - Restore an address environment diff --git a/include/nuttx/arch.h b/include/nuttx/arch.h index 1d0d8b8688cb0..7e64e434274c3 100644 --- a/include/nuttx/arch.h +++ b/include/nuttx/arch.h @@ -479,7 +479,7 @@ void up_reprioritize_rtr(FAR struct tcb_s *tcb, uint8_t priority); * ****************************************************************************/ -void up_exit() noreturn_function; +void up_exit(int status) noreturn_function; /* Prototype is in unistd.h */ @@ -831,6 +831,8 @@ void up_textheap_free(FAR void *p); * address environment * up_addrenv_vdata - Returns the virtual base address of the .bss/.data * address environment + * up_addrenv_vheap - Returns the virtual base address of the heap + * address environment * up_addrenv_heapsize - Returns the size of the initial heap allocation. * up_addrenv_select - Instantiate an address environment * up_addrenv_restore - Restore an address environment @@ -992,6 +994,28 @@ int up_addrenv_vdata(FAR group_addrenv_t *addrenv, uintptr_t textsize, FAR void **vdata); #endif +/**************************************************************************** + * Name: up_addrenv_vheap + * + * Description: + * Return the heap virtual address associated with the newly created + * address environment. This function is used by the binary loaders in + * order get an address that can be used to initialize the new task. + * + * Input Parameters: + * addrenv - The representation of the task address environment previously + * returned by up_addrenv_create. + * vheap - The location to return the virtual address. + * + * Returned Value: + * Zero (OK) on success; a negated errno value on failure. + * + ****************************************************************************/ + +#if defined(CONFIG_ARCH_ADDRENV) && defined(CONFIG_BUILD_KERNEL) +int up_addrenv_vheap(FAR const group_addrenv_t *addrenv, FAR void **vheap); +#endif + /**************************************************************************** * Name: up_addrenv_heapsize * @@ -1161,6 +1185,44 @@ int up_addrenv_attach(FAR struct task_group_s *group, FAR struct tcb_s *tcb); int up_addrenv_detach(FAR struct task_group_s *group, FAR struct tcb_s *tcb); #endif +/**************************************************************************** + * Name: up_addrenv_text_enable_write + * + * Description: + * Temporarily enable write access to the .text section. This must be + * called prior to loading the process code into memory. + * + * Input Parameters: + * addrenv - The address environment to be modified. + * + * Returned Value: + * Zero (OK) on success; a negated errno value on failure. + * + ****************************************************************************/ + +#ifdef CONFIG_ARCH_ADDRENV +int up_addrenv_text_enable_write(FAR group_addrenv_t *addrenv); +#endif + +/**************************************************************************** + * Name: up_addrenv_text_disable_write + * + * Description: + * Disable write access to the .text section. This must be called after the + * process code is loaded into memory. + * + * Input Parameters: + * addrenv - The address environment to be modified. + * + * Returned Value: + * Zero (OK) on success; a negated errno value on failure. + * + ****************************************************************************/ + +#ifdef CONFIG_ARCH_ADDRENV +int up_addrenv_text_disable_write(FAR group_addrenv_t *addrenv); +#endif + /**************************************************************************** * Name: up_addrenv_ustackalloc * @@ -2563,6 +2625,30 @@ uint32_t up_perf_gettime(void); uint32_t up_perf_getfreq(void); void up_perf_convert(uint32_t elapsed, FAR struct timespec *ts); +/**************************************************************************** + * Name: up_saveusercontext + * + * Description: + * Save the current thread context + * + ****************************************************************************/ + +int up_saveusercontext(FAR void *saveregs); + +/**************************************************************************** + * Name: up_fpucmp + * + * Description: + * compare FPU areas from thread context + * + ****************************************************************************/ + +#ifdef CONFIG_ARCH_FPU +bool up_fpucmp(FAR const void *saveregs1, FAR const void *saveregs2); +#else +#define up_fpucmp(r1, r2) (true) +#endif + #undef EXTERN #if defined(__cplusplus) } diff --git a/include/nuttx/audio/audio_comp.h b/include/nuttx/audio/audio_comp.h index 92650c6599e1e..4a98cb977e29c 100644 --- a/include/nuttx/audio/audio_comp.h +++ b/include/nuttx/audio/audio_comp.h @@ -65,14 +65,15 @@ extern "C" * ... - The list of the lower half audio driver. * * Returned Value: - * Zero on success; a negated errno value on failure. + * struct audio_lowerhalf_s* on success; NULL on failure. * * Note * The variable argument list must be NULL terminated. * ****************************************************************************/ -int audio_comp_initialize(FAR const char *name, ...); +FAR struct audio_lowerhalf_s *audio_comp_initialize(FAR const char *name, + ...); #undef EXTERN #ifdef __cplusplus diff --git a/include/nuttx/binfmt/binfmt.h b/include/nuttx/binfmt/binfmt.h index 416cc6c4a422a..8c17d8f53bf41 100644 --- a/include/nuttx/binfmt/binfmt.h +++ b/include/nuttx/binfmt/binfmt.h @@ -258,7 +258,8 @@ int unload_module(FAR struct binary_s *bin); ****************************************************************************/ int exec_module(FAR const struct binary_s *binp, - FAR const char *filename, FAR char * const *argv); + FAR const char *filename, FAR char * const *argv, + FAR char * const *envp); /**************************************************************************** * Name: exec @@ -308,6 +309,9 @@ int exec_module(FAR const struct binary_s *binp, * program. * argv - A pointer to an array of string arguments. The end of the * array is indicated with a NULL entry. + * envp - An array of character pointers to null-terminated strings + * that provide the environment for the new process image. + * The environment array is terminated by a null pointer. * exports - The address of the start of the caller-provided symbol * table. This symbol table contains the addresses of symbols * exported by the caller and made available for linking the @@ -321,7 +325,8 @@ int exec_module(FAR const struct binary_s *binp, ****************************************************************************/ int exec(FAR const char *filename, FAR char * const *argv, - FAR const struct symtab_s *exports, int nexports); + FAR char * const *envp, FAR const struct symtab_s *exports, + int nexports); /**************************************************************************** * Name: exec_spawn @@ -338,6 +343,8 @@ int exec(FAR const char *filename, FAR char * const *argv, * program. * argv - A pointer to an array of string arguments. The end of the * array is indicated with a NULL entry. + * envp - A pointer to an array of environment strings. Terminated with + * a NULL entry. * exports - The address of the start of the caller-provided symbol * table. This symbol table contains the addresses of symbols * exported by the caller and made available for linking the @@ -353,8 +360,8 @@ int exec(FAR const char *filename, FAR char * const *argv, ****************************************************************************/ int exec_spawn(FAR const char *filename, FAR char * const *argv, - FAR const struct symtab_s *exports, int nexports, - FAR const posix_spawnattr_t *attr); + FAR char * const *envp, FAR const struct symtab_s *exports, + int nexports, FAR const posix_spawnattr_t *attr); /**************************************************************************** * Name: binfmt_exit diff --git a/include/nuttx/board.h b/include/nuttx/board.h index 0f9d7eb8625c2..02887563d01bd 100644 --- a/include/nuttx/board.h +++ b/include/nuttx/board.h @@ -96,6 +96,10 @@ # include #endif +#ifdef CONFIG_BOARDCTL_RESET_CAUSE +# include +#endif + /**************************************************************************** * Public Function Prototypes * @@ -819,6 +823,20 @@ void board_crashdump(uintptr_t currentsp, FAR void *tcb, void board_init_rngseed(void); #endif +/**************************************************************************** + * Name: board_reset_cause + * + * Description: + * This interface may be used by application specific logic to get the + * cause of last reset. Support for this function is required by + * board-level logic if CONFIG_BOARDCTL_RESET is selected. + * + ****************************************************************************/ + +#ifdef CONFIG_BOARDCTL_RESET_CAUSE +int board_reset_cause(FAR struct boardioc_reset_cause_s *cause); +#endif + #undef EXTERN #ifdef __cplusplus } diff --git a/include/nuttx/clk/clk.h b/include/nuttx/clk/clk.h index f12a6fd527588..8412fa7833b28 100644 --- a/include/nuttx/clk/clk.h +++ b/include/nuttx/clk/clk.h @@ -74,7 +74,7 @@ int clk_set_phase(FAR struct clk_s *clk, int degrees); int clk_get_phase(FAR struct clk_s *clk); void clk_disable_unused(void); -FAR const char *clk_get_name(const FAR struct clk_s *clk); +FAR const char *clk_get_name(FAR const struct clk_s *clk); #undef EXTERN #ifdef __cplusplus diff --git a/include/nuttx/compiler.h b/include/nuttx/compiler.h index 6efefcdd24af3..3ba3936f2f29a 100644 --- a/include/nuttx/compiler.h +++ b/include/nuttx/compiler.h @@ -47,10 +47,6 @@ # define CONFIG_HAVE_FUNCTIONNAME 1 /* Has __FUNCTION__ */ # define CONFIG_HAVE_FILENAME 1 /* Has __FILE__ */ -/* Indicate that a local variable is not used */ - -# define UNUSED(a) ((void)(1 || (a))) - /* Built-in functions */ /* The header shall define the following macros: @@ -182,7 +178,7 @@ # if defined(__clang__) # define nostackprotect_function __attribute__ ((optnone)) # else -# define nostackprotect_function __attribute__ ((__optimize__ ("-fno-stack-protector"))) +# define nostackprotect_function __attribute__ ((__optimize__("-fno-stack-protector"))) # endif #endif @@ -381,6 +377,14 @@ # define UNUSED(a) ((void)(1 || (a))) +# if defined(__clang__) +# define no_builtin(n) __attribute__((no_builtin(n))) +# elif (__GNUC__ == 4 && __GNUC_MINOR__ >= 6) || (__GNUC__ > 4) +# define no_builtin(n) __attribute__((__optimize__("-fno-tree-loop-distribute-patterns"))) +# else +# define no_builtin(n) +# endif + /* SDCC-specific definitions ************************************************/ #elif defined(SDCC) || defined(__SDCC) @@ -531,12 +535,10 @@ # undef CONFIG_HAVE_DOUBLE # undef CONFIG_HAVE_LONG_DOUBLE -/* Indicate that a local variable is not used */ - -# define UNUSED(a) ((void)(1 || (a))) - # define offsetof(a, b) ((size_t)(&(((a *)(0))->b))) +# define no_builtin(n) + /* Zilog-specific definitions ***********************************************/ #elif defined(__ZILOG__) @@ -660,6 +662,10 @@ # undef CONFIG_HAVE_ANONYMOUS_STRUCT # undef CONFIG_HAVE_ANONYMOUS_UNION +/* Indicate that a local variable is not used */ + +# define UNUSED(a) ((void)(1 || (a))) + /* Older Zilog compilers support both types double and long long, but the * size is 32-bits (same as long and single precision) so it is safer to say * that they are not supported. Later versions are more ANSII compliant and @@ -671,24 +677,14 @@ # undef CONFIG_HAVE_DOUBLE # undef CONFIG_HAVE_LONG_DOUBLE -/* Indicate that a local variable is not used */ - -# define UNUSED(a) ((void)(1 || (a))) - # define offsetof(a, b) ((size_t)(&(((a *)(0))->b))) +# define no_builtin(n) + /* ICCARM-specific definitions **********************************************/ #elif defined(__ICCARM__) -# define CONFIG_CPP_HAVE_VARARGS 1 /* Supports variable argument macros */ -# define CONFIG_HAVE_FILENAME 1 /* Has __FILE__ */ -# define CONFIG_HAVE_FLOAT 1 - -/* Indicate that a local variable is not used */ - -# define UNUSED(a) ((void)(1 || (a))) - # define weak_alias(name, aliasname) # define weak_data __weak # define weak_function __weak @@ -744,8 +740,18 @@ # undef CONFIG_HAVE_ANONYMOUS_STRUCT # undef CONFIG_HAVE_ANONYMOUS_UNION +/* Indicate that a local variable is not used */ + +# define UNUSED(a) ((void)(1 || (a))) + +# define CONFIG_CPP_HAVE_VARARGS 1 /* Supports variable argument macros */ +# define CONFIG_HAVE_FILENAME 1 /* Has __FILE__ */ +# define CONFIG_HAVE_FLOAT 1 + # define offsetof(a, b) ((size_t)(&(((a *)(0))->b))) +# define no_builtin(n) + /* Unknown compiler *********************************************************/ #else @@ -755,7 +761,7 @@ # undef CONFIG_HAVE_FUNCTIONNAME # undef CONFIG_HAVE_FILENAME # undef CONFIG_HAVE_WEAKFUNCTIONS -# undef CONFIG_HAVE_CXX14 +# undef CONFIG_HAVE_CXX14 # define weak_alias(name, aliasname) # define weak_data # define weak_function @@ -803,6 +809,8 @@ # define offsetof(a, b) ((size_t)(&(((a *)(0))->b))) +# define no_builtin(n) + #endif /**************************************************************************** diff --git a/include/nuttx/fs/ioctl.h b/include/nuttx/fs/ioctl.h index 3c3038565b75f..469b0c615a1bb 100644 --- a/include/nuttx/fs/ioctl.h +++ b/include/nuttx/fs/ioctl.h @@ -182,6 +182,9 @@ * configuration * OUT: None */ +#define FIOC_TRUNCATE _FIOC(0x0010) /* IN: Length of the file after truncate + * OUT: None + */ /* NuttX file system ioctl definitions **************************************/ diff --git a/include/nuttx/himem/himem.h b/include/nuttx/himem/himem.h index 96e6569171132..cb7ffa4f3f9e2 100644 --- a/include/nuttx/himem/himem.h +++ b/include/nuttx/himem/himem.h @@ -1,6 +1,20 @@ /**************************************************************************** * include/nuttx/himem/himem.h * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. ****************************************************************************/ #ifndef __INCLUDE_NUTTX_HIMEM_HIMEM_H diff --git a/include/nuttx/leds/ncp5623c.h b/include/nuttx/leds/ncp5623c.h index 388414519fe80..def762c6e606a 100644 --- a/include/nuttx/leds/ncp5623c.h +++ b/include/nuttx/leds/ncp5623c.h @@ -1,35 +1,20 @@ /**************************************************************************** * include/nuttx/leds/ncp5623c.h - * based on include/nuttx/leds/pca9635pw.c * - * Author: Konstantin Berzenko + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: + * http://www.apache.org/licenses/LICENSE-2.0 * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * 3. Neither the name NuttX nor the names of its contributors may be - * used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. * ****************************************************************************/ diff --git a/include/nuttx/net/usrsock.h b/include/nuttx/net/usrsock.h index 540c2dcc7d986..49f295dd504e9 100644 --- a/include/nuttx/net/usrsock.h +++ b/include/nuttx/net/usrsock.h @@ -220,6 +220,7 @@ begin_packed_struct struct usrsock_message_common_s { int8_t msgid; int8_t flags; + uint16_t events; } end_packed_struct; /* Request acknowledgment/completion message */ @@ -228,7 +229,6 @@ begin_packed_struct struct usrsock_message_req_ack_s { struct usrsock_message_common_s head; - int16_t reserved; int32_t result; uint64_t xid; } end_packed_struct; @@ -253,7 +253,6 @@ begin_packed_struct struct usrsock_message_socket_event_s struct usrsock_message_common_s head; int16_t usockid; - uint16_t events; } end_packed_struct; #endif /* __INCLUDE_NUTTX_NET_USRSOCK_H */ diff --git a/include/nuttx/power/pm.h b/include/nuttx/power/pm.h index d3da7863788bb..29cc0cfb37cda 100644 --- a/include/nuttx/power/pm.h +++ b/include/nuttx/power/pm.h @@ -598,6 +598,22 @@ int pm_changestate(int domain, enum pm_state_e newstate); enum pm_state_e pm_querystate(int domain); +/**************************************************************************** + * Name: pm_auto_updatestate + * + * Description: + * This function update the domain state and notify the power system. + * + * Input Parameters: + * domain - The PM domain to check + * + * Returned Value: + * None. + * + ****************************************************************************/ + +void pm_auto_updatestate(int domain); + #undef EXTERN #ifdef __cplusplus } diff --git a/include/nuttx/rptun/openamp.h b/include/nuttx/rptun/openamp.h index 8a96b98889e5c..833c477a1a223 100644 --- a/include/nuttx/rptun/openamp.h +++ b/include/nuttx/rptun/openamp.h @@ -54,7 +54,11 @@ extern "C" #define EXTERN extern #endif +int rpmsg_wait(FAR struct rpmsg_endpoint *ept, FAR sem_t *sem); +int rpmsg_post(FAR struct rpmsg_endpoint *ept, FAR sem_t *sem); + const char *rpmsg_get_cpuname(FAR struct rpmsg_device *rdev); + int rpmsg_register_callback(FAR void *priv, rpmsg_dev_cb_t device_created, rpmsg_dev_cb_t device_destroy, diff --git a/include/nuttx/rptun/rptun.h b/include/nuttx/rptun/rptun.h index cb4f99126c369..2405ebe023acf 100644 --- a/include/nuttx/rptun/rptun.h +++ b/include/nuttx/rptun/rptun.h @@ -38,6 +38,10 @@ #define RPTUNIOC_START _RPTUNIOC(1) #define RPTUNIOC_STOP _RPTUNIOC(2) +#define RPTUNIOC_RESET _RPTUNIOC(3) +#define RPTUNIOC_PANIC _RPTUNIOC(4) +#define RPTUNIOC_DUMP _RPTUNIOC(5) +#define RPTUNIOC_PING _RPTUNIOC(6) #define RPTUN_NOTIFY_ALL (UINT32_MAX - 0) @@ -58,7 +62,7 @@ ****************************************************************************/ #define RPTUN_GET_CPUNAME(d) ((d)->ops->get_cpuname ? \ - (d)->ops->get_cpuname(d) : NULL) + (d)->ops->get_cpuname(d) : "") /**************************************************************************** * Name: RPTUN_GET_FIRMWARE @@ -250,6 +254,41 @@ #define RPTUN_UNREGISTER_CALLBACK(d) ((d)->ops->register_callback ? \ (d)->ops->register_callback(d,NULL,NULL) : -ENOSYS) +/**************************************************************************** + * Name: RPTUN_RESET + * + * Description: + * Reset remote cpu + * + * Input Parameters: + * dev - Device-specific state data + * value - reset value + * + * Returned Value: + * None + * + ****************************************************************************/ + +#define RPTUN_RESET(d,v) ((d)->ops->reset ? \ + (d)->ops->reset(d,v) : -ENOSYS) + +/**************************************************************************** + * Name: RPTUN_PANIC + * + * Description: + * Panic remote cpu + * + * Input Parameters: + * dev - Device-specific state data + * + * Returned Value: + * None + * + ****************************************************************************/ + +#define RPTUN_PANIC(d) ((d)->ops->panic ? \ + (d)->ops->panic(d) : -ENOSYS) + /**************************************************************************** * Public Types ****************************************************************************/ @@ -293,6 +332,9 @@ struct rptun_ops_s CODE int (*notify)(FAR struct rptun_dev_s *dev, uint32_t vqid); CODE int (*register_callback)(FAR struct rptun_dev_s *dev, rptun_callback_t callback, FAR void *arg); + + CODE void (*reset)(FAR struct rptun_dev_s *dev, int value); + CODE void (*panic)(FAR struct rptun_dev_s *dev); }; struct rptun_dev_s @@ -300,6 +342,15 @@ struct rptun_dev_s FAR const struct rptun_ops_s *ops; }; +/* used for ioctl RPTUNIOC_PING */ + +struct rptun_ping_s +{ + int times; + int len; + bool ack; +}; + /**************************************************************************** * Public Function Prototypes ****************************************************************************/ @@ -314,6 +365,9 @@ extern "C" int rptun_initialize(FAR struct rptun_dev_s *dev); int rptun_boot(FAR const char *cpuname); +int rptun_reset(FAR const char *cpuname, int value); +int rptun_panic(FAR const char *cpuname); +void rptun_dump_all(void); #ifdef __cplusplus } diff --git a/include/nuttx/sched.h b/include/nuttx/sched.h index 6c383138bdeb9..468b32dea31e7 100644 --- a/include/nuttx/sched.h +++ b/include/nuttx/sched.h @@ -193,7 +193,8 @@ #else # define TCB_NAME_OFF 0 #endif -# define TCB_REG_OFF(reg) offsetof(struct tcb_s, xcp.regs[reg]) +# define TCB_REGS_OFF offsetof(struct tcb_s, xcp.regs) +# define TCB_REG_OFF(reg) (reg * sizeof(uint32_t)) #endif /**************************************************************************** @@ -525,8 +526,7 @@ struct task_group_s #ifndef CONFIG_DISABLE_ENVIRON /* Environment variables **************************************************/ - size_t tg_envsize; /* Size of environment string allocation */ - FAR char *tg_envp; /* Allocated environment strings */ + FAR char **tg_envp; /* Allocated environment strings */ #endif #ifndef CONFIG_DISABLE_POSIX_TIMERS @@ -771,14 +771,16 @@ begin_packed_struct struct tcbinfo_s uint16_t state_off; /* Offset of tcb.task_state */ uint16_t pri_off; /* Offset of tcb.sched_priority */ uint16_t name_off; /* Offset of tcb.name */ - uint16_t reg_num; /* Num of regs in tcbinfo.reg_offs */ + uint16_t regs_off; /* Offset of tcb.regs */ + uint16_t basic_num; /* Num of genernal regs */ + uint16_t total_num; /* Num of regs in tcbinfo.reg_offs */ /* Offset pointer of xcp.regs, order in GDB org.gnu.gdb.xxx feature. * Please refer: * https://sourceware.org/gdb/current/onlinedocs/gdb/ARM-Features.html * https://sourceware.org/gdb/current/onlinedocs/gdb/RISC_002dV-Features * -.html - * value 0: This regsiter was not priovided by NuttX + * value UINT16_MAX: This regsiter was not priovided by NuttX */ begin_packed_struct @@ -931,6 +933,7 @@ FAR struct streamlist *nxsched_get_streams(void); * argv - A pointer to an array of input parameters. The array * should be terminated with a NULL argv[] value. If no * parameters are required, argv may be NULL. + * envp - A pointer to the program's environment, envp may be NULL * * Returned Value: * OK on success; negative error value on failure appropriately. (See @@ -943,7 +946,7 @@ FAR struct streamlist *nxsched_get_streams(void); int nxtask_init(FAR struct task_tcb_s *tcb, const char *name, int priority, FAR void *stack, uint32_t stack_size, main_t entry, - FAR char * const argv[]); + FAR char * const argv[], FAR char * const envp[]); /**************************************************************************** * Name: nxtask_uninit diff --git a/include/nuttx/sched_note.h b/include/nuttx/sched_note.h index 432feb4ee184a..ea9930dc7cdad 100644 --- a/include/nuttx/sched_note.h +++ b/include/nuttx/sched_note.h @@ -105,16 +105,38 @@ memset((s), 0, sizeof(struct note_filter_irq_s)) #endif -/* Note dump module tag definitions */ - #ifdef CONFIG_SCHED_INSTRUMENTATION_DUMP -# define NOTE_MODULE(a, b, c, d) \ - ((uint32_t)((a) & 0xff) | \ - ((uint32_t)((b) & 0xff) << 8) | \ - ((uint32_t)((c) & 0xff) << 16) | \ - ((uint32_t)((d) & 0xff) << 24)) +# define SCHED_NOTE_LABEL__(x, y) x ## y +# define SCHED_NOTE_LABEL_(x, y) SCHED_NOTE_LABEL__(x, y) +# define SCHED_NOTE_LABEL \ + SCHED_NOTE_LABEL_(sched_note_here, __LINE__) +# define SCHED_NOTE_IP \ + ({SCHED_NOTE_LABEL: (uintptr_t)&&SCHED_NOTE_LABEL;}) +# define SCHED_NOTE_STRING(buf) \ + sched_note_string(SCHED_NOTE_IP, buf) +# define SCHED_NOTE_DUMP(event, buf, len) \ + sched_note_dump(SCHED_NOTE_IP, event, buf, len) +# define SCHED_NOTE_VPRINTF(fmt, va) \ + sched_note_vprintf(SCHED_NOTE_IP, fmt, va) +# define SCHED_NOTE_VBPRINTF(event, fmt, va) \ + sched_note_vbprintf(SCHED_NOTE_IP, event, fmt, va) +# define SCHED_NOTE_PRINTF(fmt, args...) \ + sched_note_printf(SCHED_NOTE_IP, fmt, ##args) +# define SCHED_NOTE_BPRINTF(event, fmt, args...) \ + sched_note_bprintf(SCHED_NOTE_IP, event, fmt, ##args) +# define SCHED_NOTE_BEGIN() \ + sched_note_begin(SCHED_NOTE_IP, __FUNCTION__) +# define SCHED_NOTE_END() \ + sched_note_end(SCHED_NOTE_IP, __FUNCTION__) #else -# define NOTE_MODULE(a,b,c,d) +# define SCHED_NOTE_STRING(buf) +# define SCHED_NOTE_DUMP(event, buf, len) +# define SCHED_NOTE_VPRINTF(fmt, va) +# define SCHED_NOTE_VBPRINTF(event, fmt, va) +# define SCHED_NOTE_PRINTF(fmt, args...) +# define SCHED_NOTE_BPRINTF(event, fmt, args...) +# define SCHED_NOTE_BEGIN() +# define SCHED_NOTE_END() #endif /**************************************************************************** @@ -188,13 +210,13 @@ struct note_common_s #ifdef CONFIG_SMP uint8_t nc_cpu; /* CPU thread/task running on */ #endif - uint8_t nc_pid[2]; /* ID of the thread/task */ + uint8_t nc_pid[sizeof(pid_t)]; /* ID of the thread/task */ #ifdef CONFIG_SCHED_INSTRUMENTATION_HIRES - uint8_t nc_systime_sec[4]; /* Time when note was buffered (sec) */ - uint8_t nc_systime_nsec[4]; /* Time when note was buffered (nsec) */ + uint8_t nc_systime_sec[sizeof(time_t)]; /* Time when note was buffered (sec) */ + uint8_t nc_systime_nsec[sizeof(long)]; /* Time when note was buffered (nsec) */ #else - uint8_t nc_systime[4]; /* Time when note was buffered */ + uint8_t nc_systime[sizeof(clock_t)]; /* Time when note was buffered */ #endif }; @@ -354,8 +376,9 @@ struct note_irqhandler_s #ifdef CONFIG_SCHED_INSTRUMENTATION_DUMP struct note_string_s { - struct note_common_s nst_cmn; /* Common note parameters */ - char nst_data[1]; /* String data terminated by '\0' */ + struct note_common_s nst_cmn; /* Common note parameters */ + uint8_t nst_ip[sizeof(uintptr_t)]; /* Instruction pointer called from */ + char nst_data[1]; /* String data terminated by '\0' */ }; #define SIZEOF_NOTE_STRING(n) (sizeof(struct note_string_s) + \ @@ -363,10 +386,10 @@ struct note_string_s struct note_binary_s { - struct note_common_s nbi_cmn; /* Common note parameters */ - uint8_t nbi_module[4]; /* Module number */ - uint8_t nbi_event; /* Event number */ - uint8_t nbi_data[1]; /* Binary data */ + struct note_common_s nbi_cmn; /* Common note parameters */ + uint8_t nbi_ip[sizeof(uintptr_t)]; /* Instruction pointer called from */ + uint8_t nbi_event; /* Event number */ + uint8_t nbi_data[1]; /* Binary data */ }; #define SIZEOF_NOTE_BINARY(n) (sizeof(struct note_binary_s) + \ @@ -416,6 +439,15 @@ struct note_filter_irq_s * Public Function Prototypes ****************************************************************************/ +#undef EXTERN +#if defined(__cplusplus) +#define EXTERN extern "C" +extern "C" +{ +#else +#define EXTERN extern +#endif + /**************************************************************************** * Name: sched_note_* * @@ -509,22 +541,29 @@ void sched_note_irqhandler(int irq, FAR void *handler, bool enter); #endif #ifdef CONFIG_SCHED_INSTRUMENTATION_DUMP -void sched_note_string(FAR const char *buf); -void sched_note_dump(uint32_t module, uint8_t event, + +void sched_note_string(uintptr_t ip, FAR const char *buf); +void sched_note_dump(uintptr_t ip, uint8_t event, FAR const void *buf, size_t len); -void sched_note_vprintf(FAR const char *fmt, va_list va) printflike(1, 0); -void sched_note_vbprintf(uint32_t module, uint8_t event, +void sched_note_vprintf(uintptr_t ip, FAR const char *fmt, + va_list va) printflike(2, 0); +void sched_note_vbprintf(uintptr_t ip, uint8_t event, FAR const char *fmt, va_list va) printflike(3, 0); -void sched_note_printf(FAR const char *fmt, ...) printflike(1, 2); -void sched_note_bprintf(uint32_t module, uint8_t event, +void sched_note_printf(uintptr_t ip, + FAR const char *fmt, ...) printflike(2, 3); +void sched_note_bprintf(uintptr_t ip, uint8_t event, FAR const char *fmt, ...) printflike(3, 4); +void sched_note_begin(uintptr_t ip, FAR const char *buf); +void sched_note_end(uintptr_t ip, FAR const char *buf); #else -# define sched_note_string(b) -# define sched_note_dump(m,e,b,l) -# define sched_note_vprintf(f,v) -# define sched_note_vbprintf(m,e,f,v) -# define sched_note_printf(f...) -# define sched_note_bprintf(m,e,f...) +# define sched_note_string(ip,b) +# define sched_note_dump(ip,e,b,l) +# define sched_note_vprintf(ip,f,v) +# define sched_note_vbprintf(ip,e,f,v) +# define sched_note_printf(ip,f...) +# define sched_note_bprintf(ip,e,f...) +# define sched_note_begin(ip,f...) +# define sched_note_end(ip,f...) #endif /* CONFIG_SCHED_INSTRUMENTATION_DUMP */ #if defined(__KERNEL__) || defined(CONFIG_BUILD_FLAT) @@ -628,9 +667,22 @@ void sched_note_filter_irq(struct note_filter_irq_s *oldf, #endif /* defined(__KERNEL__) || defined(CONFIG_BUILD_FLAT) */ +#undef EXTERN +#if defined(__cplusplus) +} +#endif + #else /* CONFIG_SCHED_INSTRUMENTATION */ -# define NOTE_MODULE(a,b,c,d) +# define SCHED_NOTE_STRING(buf) +# define SCHED_NOTE_DUMP(event, buf, len) +# define SCHED_NOTE_VPRINTF(fmt, va) +# define SCHED_NOTE_VBPRINTF(event, fmt, va) +# define SCHED_NOTE_PRINTF(fmt, args...) +# define SCHED_NOTE_BPRINTF(event, fmt, args...) +# define SCHED_NOTE_BEGIN() +# define SCHED_NOTE_END() + # define sched_note_start(t) # define sched_note_stop(t) # define sched_note_suspend(t) @@ -650,12 +702,14 @@ void sched_note_filter_irq(struct note_filter_irq_s *oldf, # define sched_note_syscall_enter(n,a...) # define sched_note_syscall_leave(n,r) # define sched_note_irqhandler(i,h,e) -# define sched_note_string(b) -# define sched_note_dump(m,e,b,l) -# define sched_note_vprintf(f,v) -# define sched_note_vbprintf(m,e,f,v) -# define sched_note_printf(f...) -# define sched_note_bprintf(m,e,f...) +# define sched_note_string(ip,b) +# define sched_note_dump(ip,e,b,l) +# define sched_note_vprintf(ip,f,v) +# define sched_note_vbprintf(ip,e,f,v) +# define sched_note_printf(ip,f...) +# define sched_note_bprintf(ip,e,f...) +# define sched_note_begin(ip,f...) +# define sched_note_end(ip,f...) #endif /* CONFIG_SCHED_INSTRUMENTATION */ #endif /* __INCLUDE_NUTTX_SCHED_NOTE_H */ diff --git a/include/nuttx/sdio.h b/include/nuttx/sdio.h index 9fa97c84c6a13..fbf449cb9f73e 100644 --- a/include/nuttx/sdio.h +++ b/include/nuttx/sdio.h @@ -477,6 +477,7 @@ #define SDIO_CAPS_DMABEFOREWRITE 0x04 /* Bit 2=1: Executes DMA before write command */ #define SDIO_CAPS_4BIT 0x08 /* Bit 3=1: Supports 4 bit operation */ #define SDIO_CAPS_8BIT 0x10 /* Bit 4=1: Supports 8 bit operation */ +#define SDIO_CAPS_4BIT_ONLY 0x20 /* Bit 5=1: Supports 4-bit only operation */ /**************************************************************************** * Name: SDIO_STATUS @@ -895,6 +896,24 @@ # define SDIO_DMASENDSETUP(dev,buffer,len) (-ENOSYS) #endif +/**************************************************************************** + * Name: SDIO_GOTEXTCSD + * + * Description: + * Notify driver EXT CSD data + * + * Input Parameters: + * dev - An instance of the SDIO device interface + * buffer - Ext Csd data + * + * Returned Value: + * None. + * + ****************************************************************************/ + +#define SDIO_GOTEXTCSD(dev,buffer) \ + ((dev)->gotextcsd?(dev)->gotextcsd(dev,buffer):OK) + /**************************************************************************** * Public Types ****************************************************************************/ @@ -1007,6 +1026,7 @@ struct sdio_dev_s int (*dmasendsetup)(FAR struct sdio_dev_s *dev, FAR const uint8_t *buffer, size_t buflen); #endif /* CONFIG_SDIO_DMA */ + void (*gotextcsd)(FAR struct sdio_dev_s *dev, FAR const uint8_t *buffer); }; /**************************************************************************** diff --git a/include/nuttx/sensors/as726x.h b/include/nuttx/sensors/as726x.h index 63d841bc1a96a..9acd499d7070e 100644 --- a/include/nuttx/sensors/as726x.h +++ b/include/nuttx/sensors/as726x.h @@ -66,12 +66,12 @@ /* Register addresses */ -#define AS726x_DEVICE_TYPE 0x00 -#define AS726x_HW_VERSION 0x01 -#define AS726x_CONTROL_SETUP 0x04 -#define AS726x_INT_T 0x05 -#define AS726x_DEVICE_TEMP 0x06 -#define AS726x_LED_CONTROL 0x07 +#define AS726X_DEVICE_TYPE 0x00 +#define AS726X_HW_VERSION 0x01 +#define AS726X_CONTROL_SETUP 0x04 +#define AS726X_INT_T 0x05 +#define AS726X_DEVICE_TEMP 0x06 +#define AS726X_LED_CONTROL 0x07 #define AS72XX_SLAVE_STATUS_REG 0x00 #define AS72XX_SLAVE_WRITE_REG 0x01 diff --git a/include/nuttx/sensors/scd41.h b/include/nuttx/sensors/scd41.h new file mode 100644 index 0000000000000..f3831363f6622 --- /dev/null +++ b/include/nuttx/sensors/scd41.h @@ -0,0 +1,75 @@ +/**************************************************************************** + * include/nuttx/sensors/scd41.h + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +#ifndef __INCLUDE_NUTTX_SENSORS_SCD41_H +#define __INCLUDE_NUTTX_SENSORS_SCD41_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +#define CONFIG_SCD41_ADDR 0x62 + +/**************************************************************************** + * Public Types + ****************************************************************************/ + +struct i2c_master_s; /* Forward reference */ + +struct scd41_conv_data_s +{ + float temperature; /* Celsius */ + float humidity; /* RH-% */ + float co2; /* CO₂ PPM */ +}; + +/**************************************************************************** + * Public Function Prototypes + ****************************************************************************/ + +#ifdef CONFIG_SCD41_I2C +/**************************************************************************** + * Name: scd41_register_i2c + * + * Description: + * Register the SCD41 character device as 'devpath' + * + * Input Parameters: + * devpath - The full path to the driver to register. E.g., "/dev/co2_0" + * i2c - An instance of the I2C interface to use to communicate with + * the SCD41 + * + * Returned Value: + * Zero (OK) on success; a negated errno value on failure. + * + ****************************************************************************/ + +int scd41_register_i2c(FAR const char *devpath, + FAR struct i2c_master_s *i2c); + +#endif + +#endif /* __INCLUDE_NUTTX_SENSORS_SCD41_H */ diff --git a/include/nuttx/serial/tioctl.h b/include/nuttx/serial/tioctl.h index 4b527c10fa770..4faa0c18e5d29 100644 --- a/include/nuttx/serial/tioctl.h +++ b/include/nuttx/serial/tioctl.h @@ -29,6 +29,7 @@ * Included Files ****************************************************************************/ +#include #include /**************************************************************************** diff --git a/include/nuttx/streams.h b/include/nuttx/streams.h index 4d53114211392..98348019f38d8 100644 --- a/include/nuttx/streams.h +++ b/include/nuttx/streams.h @@ -29,6 +29,9 @@ #include #include +#ifndef CONFIG_DISABLE_MOUNTPOINT +#include +#endif /**************************************************************************** * Pre-processor Definitions @@ -197,6 +200,16 @@ struct lib_lzfoutstream_s }; #endif +#ifndef CONFIG_DISABLE_MOUNTPOINT +struct lib_blkoutstream_s +{ + struct lib_outstream_s public; + FAR struct inode *inode; + struct geometry geo; + FAR unsigned char *cache; +}; +#endif + /**************************************************************************** * Public Data ****************************************************************************/ @@ -374,6 +387,46 @@ void lib_lzfoutstream(FAR struct lib_lzfoutstream_s *stream, FAR struct lib_outstream_s *backend); #endif +/**************************************************************************** + * Name: lib_blkoutstream_open + * + * Description: + * open block driver stream backend + * + * Input Parameters: + * stream - User allocated, uninitialized instance of struct + * lib_blkoutstream_s to be initialized. + * name - The full path to the block driver to be opened. + * + * Returned Value: + * Returns zero on success or a negated errno on failure + * + ****************************************************************************/ + +#ifndef CONFIG_DISABLE_MOUNTPOINT +int lib_blkoutstream_open(FAR struct lib_blkoutstream_s *stream, + FAR const char *name); +#endif + +/**************************************************************************** + * Name: lib_blkoutstream_close + * + * Description: + * close block driver stream backend + * + * Input Parameters: + * stream - User allocated, uninitialized instance of struct + * lib_blkoutstream_s to be initialized. + * + * Returned Value: + * None (User allocated instance initialized). + * + ****************************************************************************/ + +#ifndef CONFIG_DISABLE_MOUNTPOINT +void lib_blkoutstream_close(FAR struct lib_blkoutstream_s *stream); +#endif + /**************************************************************************** * Name: lib_noflush * diff --git a/include/nuttx/video/imgdata.h b/include/nuttx/video/imgdata.h index 1847754fc1b1d..9484d88ee329b 100644 --- a/include/nuttx/video/imgdata.h +++ b/include/nuttx/video/imgdata.h @@ -98,7 +98,7 @@ extern "C" /* Register image data operations. */ -void imgdata_register(const FAR struct imgdata_ops_s *ops); +void imgdata_register(FAR const struct imgdata_ops_s *ops); #undef EXTERN #ifdef __cplusplus diff --git a/include/nuttx/video/imgsensor.h b/include/nuttx/video/imgsensor.h index 2545772c6cde1..e98759e55c3aa 100644 --- a/include/nuttx/video/imgsensor.h +++ b/include/nuttx/video/imgsensor.h @@ -340,7 +340,7 @@ extern "C" /* Register image sensor operations. */ -void imgsensor_register(const FAR struct imgsensor_ops_s *ops); +void imgsensor_register(FAR const struct imgsensor_ops_s *ops); #undef EXTERN #ifdef __cplusplus diff --git a/include/nuttx/wireless/bluetooth/bt_buf.h b/include/nuttx/wireless/bluetooth/bt_buf.h index eb4af7c94a9e6..71db258af498d 100644 --- a/include/nuttx/wireless/bluetooth/bt_buf.h +++ b/include/nuttx/wireless/bluetooth/bt_buf.h @@ -1,12 +1,5 @@ /**************************************************************************** * include/nuttx/wireless/bluetooth/bt_buf.h - * Bluetooth buffer management. - * - * Copyright (C) 2018 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt - * - * Ported from the Intel/Zephyr arduino101_firmware_source-v1.tar package - * where the code was released with a compatible 3-clause BSD license: * * Copyright (c) 2016, Intel Corporation * All rights reserved. diff --git a/include/nuttx/wireless/bluetooth/bt_core.h b/include/nuttx/wireless/bluetooth/bt_core.h index f4525e456744c..fadff5e76722d 100644 --- a/include/nuttx/wireless/bluetooth/bt_core.h +++ b/include/nuttx/wireless/bluetooth/bt_core.h @@ -1,12 +1,5 @@ /**************************************************************************** * include/nuttx/wireless/bluetooth/bt_core.h - * Bluetooth subsystem core APIs. - * - * Copyright (C) 2018 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt - * - * Ported from the Intel/Zephyr arduino101_firmware_source-v1.tar package - * where the code was released with a compatible 3-clause BSD license: * * Copyright (c) 2016, Intel Corporation * All rights reserved. diff --git a/include/nuttx/wireless/bluetooth/bt_driver.h b/include/nuttx/wireless/bluetooth/bt_driver.h index 3104ab5caab70..acea43bc3ce8c 100644 --- a/include/nuttx/wireless/bluetooth/bt_driver.h +++ b/include/nuttx/wireless/bluetooth/bt_driver.h @@ -1,12 +1,5 @@ /**************************************************************************** * include/nuttx/wireless/bluetooth/bt_driver.h - * Bluetooth HCI driver API. - * - * Copyright (C) 2018 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt - * - * Ported from the Intel/Zephyr arduino101_firmware_source-v1.tar package - * where the code was released with a compatible 3-clause BSD license: * * Copyright (c) 2016, Intel Corporation * All rights reserved. diff --git a/include/nuttx/wireless/bluetooth/bt_gatt.h b/include/nuttx/wireless/bluetooth/bt_gatt.h index e6c33d1bc9898..3dad20f4dfda6 100644 --- a/include/nuttx/wireless/bluetooth/bt_gatt.h +++ b/include/nuttx/wireless/bluetooth/bt_gatt.h @@ -1,12 +1,5 @@ /**************************************************************************** * include/nuttx/wireless/bluetooth/bt_gatt.h - * Generic Attribute Profile handling. - * - * Copyright (C) 2018 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt - * - * Ported from the Intel/Zephyr arduino101_firmware_source-v1.tar package - * where the code was released with a compatible 3-clause BSD license: * * Copyright (c) 2016, Intel Corporation * All rights reserved. diff --git a/include/nuttx/wireless/bluetooth/bt_hci.h b/include/nuttx/wireless/bluetooth/bt_hci.h index 88d16c00bfd14..e999b63c38ad9 100644 --- a/include/nuttx/wireless/bluetooth/bt_hci.h +++ b/include/nuttx/wireless/bluetooth/bt_hci.h @@ -1,12 +1,5 @@ /**************************************************************************** * include/nuttx/wireless/bluetooth/bt_hci.h - * Bluetooth Host Control Interface definitions. - * - * Copyright (C) 2018 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt - * - * Ported from the Intel/Zephyr arduino101_firmware_source-v1.tar package - * where the code was released with a compatible 3-clause BSD license: * * Copyright (c) 2016, Intel Corporation * All rights reserved. diff --git a/include/nuttx/wireless/bluetooth/bt_ioctl.h b/include/nuttx/wireless/bluetooth/bt_ioctl.h index 505d165c6f74e..a45b8784c4b0e 100644 --- a/include/nuttx/wireless/bluetooth/bt_ioctl.h +++ b/include/nuttx/wireless/bluetooth/bt_ioctl.h @@ -1,12 +1,5 @@ /**************************************************************************** * include/nuttx/wireless/bluetooth/bt_ioctl.h - * Bluetooth Network IOCTL commands. - * - * Copyright (C) 2018 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt - * - * Ported from the Intel/Zephyr arduino101_firmware_source-v1.tar package - * where the code was released with a compatible 3-clause BSD license: * * Copyright (c) 2016, Intel Corporation * All rights reserved. diff --git a/include/nuttx/wireless/bluetooth/bt_null.h b/include/nuttx/wireless/bluetooth/bt_null.h index 227083760884c..893e431f0da40 100644 --- a/include/nuttx/wireless/bluetooth/bt_null.h +++ b/include/nuttx/wireless/bluetooth/bt_null.h @@ -1,36 +1,20 @@ /**************************************************************************** * include/nuttx/wireless/bluetooth/bt_null.h - * NULL based Bluetooth driver - * - * Copyright (C) 2018 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * 3. Neither the name of the copyright holder nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS AS IS - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. * ****************************************************************************/ diff --git a/include/nuttx/wireless/bluetooth/bt_uart.h b/include/nuttx/wireless/bluetooth/bt_uart.h index c62445feaed46..98bdda78ee22c 100644 --- a/include/nuttx/wireless/bluetooth/bt_uart.h +++ b/include/nuttx/wireless/bluetooth/bt_uart.h @@ -1,12 +1,5 @@ /**************************************************************************** * include/nuttx/wireless/bluetooth/bt_uart.h - * UART based Bluetooth driver - * - * Copyright (C) 2018 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt - * - * Ported from the Intel/Zephyr arduino101_firmware_source-v1.tar package - * where the code was released with a compatible 3-clause BSD license: * * Copyright (c) 2016, Intel Corporation * All rights reserved. diff --git a/include/nuttx/wireless/bluetooth/bt_uuid.h b/include/nuttx/wireless/bluetooth/bt_uuid.h index 80038c55dd542..beb35b862ade8 100644 --- a/include/nuttx/wireless/bluetooth/bt_uuid.h +++ b/include/nuttx/wireless/bluetooth/bt_uuid.h @@ -1,12 +1,5 @@ /**************************************************************************** * include/nuttx/wireless/bluetooth/bt_uuid.h - * Bluetooth UUID handling. - * - * Copyright (C) 2018 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt - * - * Ported from the Intel/Zephyr arduino101_firmware_source-v1.tar package - * where the code was released with a compatible 3-clause BSD license: * * Copyright (c) 2016, Intel Corporation * All rights reserved. diff --git a/include/nuttx/wireless/ieee80211/ieee80211.h b/include/nuttx/wireless/ieee80211/ieee80211.h index 19623511580b5..b8414aa85a7bb 100644 --- a/include/nuttx/wireless/ieee80211/ieee80211.h +++ b/include/nuttx/wireless/ieee80211/ieee80211.h @@ -2,7 +2,7 @@ * include/nuttx/wireless/ieee80211/ieee80211.h * 802.11 protocol definitions. * - * Copyright (c) 2002, 2003 Sam Leffler, Errno Consulting + * Copyright (c) 2002-2009 Sam Leffler, Errno Consulting * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -42,13 +42,21 @@ * Pre-processor Definitions ****************************************************************************/ +/* 802.11 protocol definitions. */ + #define IEEE80211_ADDR_LEN 6 /* size of 802.11 address */ /* is 802.11 address multicast/broadcast? */ #define IEEE80211_IS_MULTICAST(_a) (*(_a) & 0x01) -/* htframe */ +#define IEEE80211_PLCP_SFD 0xF3A0 +#define IEEE80211_PLCP_SERVICE 0x00 +#define IEEE80211_PLCP_SERVICE_LOCKED 0x04 +#define IEEE80211_PLCL_SERVICE_PBCC 0x08 +#define IEEE80211_PLCP_SERVICE_LENEXT5 0x20 +#define IEEE80211_PLCP_SERVICE_LENEXT6 0x40 +#define IEEE80211_PLCP_SERVICE_LENEXT7 0x80 #define IEEE80211_FC0_VERSION_MASK 0x03 #define IEEE80211_FC0_VERSION_SHIFT 0 @@ -101,21 +109,41 @@ #define IEEE80211_FC0_SUBTYPE_CFPOLL 0x60 #define IEEE80211_FC0_SUBTYPE_CF_ACK_CF_ACK 0x70 #define IEEE80211_FC0_SUBTYPE_QOS 0x80 +#define IEEE80211_FC0_SUBTYPE_QOS_CFACK 0x90 +#define IEEE80211_FC0_SUBTYPE_QOS_CFPOLL 0xa0 +#define IEEE80211_FC0_SUBTYPE_QOS_CFACKPOLL 0xb0 +#define IEEE80211_FC0_SUBTYPE_QOS_NULL 0xc0 + +#define IEEE80211_IS_MGMT(wh) \ + (!! (((wh)->i_fc[0] & IEEE80211_FC0_TYPE_MASK) \ + == IEEE80211_FC0_TYPE_MGT)) +#define IEEE80211_IS_CTL(wh) \ + (!! (((wh)->i_fc[0] & IEEE80211_FC0_TYPE_MASK) \ + == IEEE80211_FC0_TYPE_CTL)) +#define IEEE80211_IS_DATA(wh) \ + (!! (((wh)->i_fc[0] & IEEE80211_FC0_TYPE_MASK) \ + == IEEE80211_FC0_TYPE_DATA)) + +#define IEEE80211_FC0_QOSDATA \ + (IEEE80211_FC0_TYPE_DATA|IEEE80211_FC0_SUBTYPE_QOS|IEEE80211_FC0_VERSION_0) + +#define IEEE80211_IS_QOSDATA(wh) \ + ((wh)->i_fc[0] == IEEE80211_FC0_QOSDATA) #define IEEE80211_FC1_DIR_MASK 0x03 -#define IEEE80211_FC1_DIR_NODS 0x00 /* STA->STA */ -#define IEEE80211_FC1_DIR_TODS 0x01 /* STA->AP */ -#define IEEE80211_FC1_DIR_FROMDS 0x02 - /* AP ->STA */ -#define IEEE80211_FC1_DIR_DSTODS 0x03 - /* AP ->AP */ +#define IEEE80211_FC1_DIR_NODS 0x00 /* STA->STA */ +#define IEEE80211_FC1_DIR_TODS 0x01 /* STA->AP */ +#define IEEE80211_FC1_DIR_FROMDS 0x02 /* AP ->STA */ +#define IEEE80211_FC1_DIR_DSTODS 0x03 /* AP ->AP */ + +#define IEEE80211_IS_DSTODS(wh) \ + (((wh)->i_fc[1] & IEEE80211_FC1_DIR_MASK) == IEEE80211_FC1_DIR_DSTODS) #define IEEE80211_FC1_MORE_FRAG 0x04 #define IEEE80211_FC1_RETRY 0x08 #define IEEE80211_FC1_PWR_MGT 0x10 #define IEEE80211_FC1_MORE_DATA 0x20 #define IEEE80211_FC1_PROTECTED 0x40 -#define IEEE80211_FC1_WEP 0x40 /* pre-RSNA compat */ #define IEEE80211_FC1_ORDER 0x80 #define IEEE80211_FC1_BITS \ "\20\03MORE_FRAG\04RETRY\05PWR_MGT\06MORE_DATA" \ @@ -123,28 +151,219 @@ /* Sequence Control field (see 7.1.3.4). */ -#define IEEE80211_SEQ_FRAG_MASK 0x000f -#define IEEE80211_SEQ_FRAG_SHIFT 0 -#define IEEE80211_SEQ_SEQ_MASK 0xfff0 -#define IEEE80211_SEQ_SEQ_SHIFT 4 +#define IEEE80211_HAS_SEQ(type, subtype) \ + ((type) != IEEE80211_FC0_TYPE_CTL && \ + !((type) == IEEE80211_FC0_TYPE_DATA && \ + ((subtype) & IEEE80211_FC0_SUBTYPE_QOS_NULL) == \ + IEEE80211_FC0_SUBTYPE_QOS_NULL)) + +#define IEEE80211_SEQ_FRAG_MASK 0x000f +#define IEEE80211_SEQ_FRAG_SHIFT 0 +#define IEEE80211_SEQ_SEQ_MASK 0xfff0 +#define IEEE80211_SEQ_SEQ_SHIFT 4 +#define IEEE80211_SEQ_RANGE 4096 + +#define IEEE80211_SEQ_ADD(seq, incr) \ + (((seq) + (incr)) & (IEEE80211_SEQ_RANGE - 1)) +#define IEEE80211_SEQ_INC(seq) IEEE80211_SEQ_ADD(seq,1) +#define IEEE80211_SEQ_SUB(a, b) \ + (((a) + IEEE80211_SEQ_RANGE - (b)) & (IEEE80211_SEQ_RANGE - 1)) -#define IEEE80211_NWID_LEN 32 -#define IEEE80211_MMIE_LEN 18 /* 11w */ +#define IEEE80211_SEQ_BA_RANGE 2048 /* 2^11 */ +#define IEEE80211_SEQ_BA_BEFORE(a, b) \ + (IEEE80211_SEQ_SUB(b, a + 1) < IEEE80211_SEQ_BA_RANGE - 1) + +#define IEEE80211_NWID_LEN 32 +#define IEEE80211_MMIE_LEN 18 /* 11w */ +#define IEEE80211_MESHID_LEN 32 /* QoS Control field (see 7.1.3.5). */ -#define IEEE80211_QOS_TXOP 0xff00 -#define IEEE80211_QOS_AMSDU 0x0080 /* 11n */ -#define IEEE80211_QOS_ACK_POLICY_NORMAL 0x0000 -#define IEEE80211_QOS_ACK_POLICY_NOACK 0x0020 -#define IEEE80211_QOS_ACK_POLICY_NOEXPLACK 0x0040 -#define IEEE80211_QOS_ACK_POLICY_BA 0x0060 -#define IEEE80211_QOS_ACK_POLICY_MASK 0x0060 -#define IEEE80211_QOS_ACK_POLICY_SHIFT 5 -#define IEEE80211_QOS_EOSP 0x0010 -#define IEEE80211_QOS_TID 0x000f +#define IEEE80211_QOS_CTL_LEN 2 + +#define IEEE80211_QOS_TXOP 0x00ff +/* bit 8 is reserved */ +#define IEEE80211_QOS_AMSDU 0x80 +#define IEEE80211_QOS_AMSDU_S 7 +#define IEEE80211_QOS_ACKPOLICY 0x60 +#define IEEE80211_QOS_ACKPOLICY_S 5 +#define IEEE80211_QOS_ACKPOLICY_NOACK 0x20 /* No ACK required */ +#define IEEE80211_QOS_ACKPOLICY_BA 0x60 /* Block ACK */ +#define IEEE80211_QOS_EOSP 0x10 /* EndOfService Period*/ +#define IEEE80211_QOS_EOSP_S 4 +#define IEEE80211_QOS_TID 0x0f + +/* qos[1] byte used for all frames sent by mesh STAs in a mesh BSS */ + +#define IEEE80211_QOS_MC 0x01 /* Mesh control */ + +/* Mesh power save level */ + +#define IEEE80211_QOS_MESH_PSL 0x02 + +/* Mesh Receiver Service Period Initiated */ + +#define IEEE80211_QOS_RSPI 0x04 + +/* bits 11 to 15 reserved */ + +/* does frame have QoS sequence control data */ +#define IEEE80211_QOS_HAS_SEQ(wh) \ + (((wh)->i_fc[0] & \ + (IEEE80211_FC0_TYPE_MASK | IEEE80211_FC0_SUBTYPE_QOS)) == \ + (IEEE80211_FC0_TYPE_DATA | IEEE80211_FC0_SUBTYPE_QOS)) + +#define WME_NUM_AC 4 /* 4 AC categories */ +#define WME_NUM_TID 16 /* 16 tids */ + +#define WME_PARAM_ACI 0x60 /* Mask for ACI field */ +#define WME_PARAM_ACI_S 5 /* Shift for ACI field */ +#define WME_PARAM_ACM 0x10 /* Mask for ACM bit */ +#define WME_PARAM_ACM_S 4 /* Shift for ACM bit */ +#define WME_PARAM_AIFSN 0x0f /* Mask for aifsn field */ +#define WME_PARAM_AIFSN_S 0 /* Shift for aifsn field */ +#define WME_PARAM_LOGCWMIN 0x0f /* Mask for CwMin field (in log) */ +#define WME_PARAM_LOGCWMIN_S 0 /* Shift for CwMin field */ +#define WME_PARAM_LOGCWMAX 0xf0 /* Mask for CwMax field (in log) */ +#define WME_PARAM_LOGCWMAX_S 4 /* Shift for CwMax field */ + +#define WME_AC_TO_TID(_ac) ( \ + ((_ac) == WME_AC_VO) ? 6 : \ + ((_ac) == WME_AC_VI) ? 5 : \ + ((_ac) == WME_AC_BK) ? 1 : \ + 0) + +#define TID_TO_WME_AC(_tid) ( \ + ((_tid) == 0 || (_tid) == 3) ? WME_AC_BE : \ + ((_tid) < 3) ? WME_AC_BK : \ + ((_tid) < 6) ? WME_AC_VI : \ + WME_AC_VO) + +/* WME Parameter Element */ + +#define WME_QOSINFO_COUNT 0x0f /* Mask for param count field */ + +/* WME U-APSD qos info field defines */ + +#define WME_CAPINFO_UAPSD_EN 0x00000080 +#define WME_CAPINFO_UAPSD_VO 0x00000001 +#define WME_CAPINFO_UAPSD_VI 0x00000002 +#define WME_CAPINFO_UAPSD_BK 0x00000004 +#define WME_CAPINFO_UAPSD_BE 0x00000008 +#define WME_CAPINFO_UAPSD_ACFLAGS_SHIFT 0 +#define WME_CAPINFO_UAPSD_ACFLAGS_MASK 0xF +#define WME_CAPINFO_UAPSD_MAXSP_SHIFT 5 +#define WME_CAPINFO_UAPSD_MAXSP_MASK 0x3 +#define WME_CAPINFO_IE_OFFSET 8 +#define WME_UAPSD_MAXSP(_qosinfo) \ + (((_qosinfo) >> WME_CAPINFO_UAPSD_MAXSP_SHIFT) & \ + WME_CAPINFO_UAPSD_MAXSP_MASK) +#define WME_UAPSD_AC_ENABLED(_ac, _qosinfo) \ + ((1 << (3 - (_ac))) & ( \ + ((_qosinfo) >> WME_CAPINFO_UAPSD_ACFLAGS_SHIFT) & \ + WME_CAPINFO_UAPSD_ACFLAGS_MASK)) + +/* Management Notification Frame */ + +#define MNF_SETUP_REQ 0 +#define MNF_SETUP_RESP 1 +#define MNF_TEARDOWN 2 + +/* 802.11n Management Action Frames */ + +#define IEEE80211_ACTION_CAT_SM 0 /* Spectrum Management */ +#define IEEE80211_ACTION_CAT_QOS 1 /* QoS */ +#define IEEE80211_ACTION_CAT_DLS 2 /* DLS */ +#define IEEE80211_ACTION_CAT_BA 3 /* BA */ +#define IEEE80211_ACTION_CAT_HT 7 /* HT */ +#define IEEE80211_ACTION_CAT_MESH 13 /* Mesh */ +#define IEEE80211_ACTION_CAT_SELF_PROT 15 /* Self-protected */ + +/* 16 - 125 reserved */ + +#define IEEE80211_ACTION_CAT_VHT 21 +#define IEEE80211_ACTION_CAT_VENDOR 127 /* Vendor Specific */ + +#define IEEE80211_ACTION_HT_TXCHWIDTH 0 /* recommended xmit chan width*/ +#define IEEE80211_ACTION_HT_MIMOPWRSAVE 1 /* MIMO power save */ -/* Capability Information field (see 7.3.1.4) */ +/* HT - recommended transmission channel width */ + +#define IEEE80211_A_HT_TXCHWIDTH_20 0 +#define IEEE80211_A_HT_TXCHWIDTH_2040 1 + +/* HT - MIMO Power Save (NB: D2.04) */ + +#define IEEE80211_A_HT_MIMOPWRSAVE_ENA 0x01 /* PS enabled */ +#define IEEE80211_A_HT_MIMOPWRSAVE_MODE 0x02 +#define IEEE80211_A_HT_MIMOPWRSAVE_MODE_S 1 +#define IEEE80211_A_HT_MIMOPWRSAVE_DYNAMIC 0x02 /* Dynamic Mode */ +#define IEEE80211_A_HT_MIMOPWRSAVE_STATIC 0x00 /* no SM packets */ + +/* bits 2-7 reserved */ + +/* Block Ack actions */ + +#define IEEE80211_ACTION_BA_ADDBA_REQUEST 0 /* ADDBA request */ +#define IEEE80211_ACTION_BA_ADDBA_RESPONSE 1 /* ADDBA response */ +#define IEEE80211_ACTION_BA_DELBA 2 /* DELBA */ + +/* Block Ack Parameter Set */ + +#define IEEE80211_BAPS_BUFSIZ 0xffc0 /* buffer size */ +#define IEEE80211_BAPS_BUFSIZ_S 6 +#define IEEE80211_BAPS_TID 0x003c /* TID */ +#define IEEE80211_BAPS_TID_S 2 +#define IEEE80211_BAPS_POLICY 0x0002 /* block ack policy */ +#define IEEE80211_BAPS_POLICY_S 1 +#define IEEE80211_BAPS_AMSDU 0x0001 /* A-MSDU permitted */ +#define IEEE80211_BAPS_AMSDU_S 0 + +#define IEEE80211_BAPS_POLICY_DELAYED (0<= \ + IEEE80211_VHTCAP_SUPP_CHAN_WIDTH_160MHZ) +#define IEEE80211_VHTCAP_SUPP_CHAN_WIDTH_IS_160_80P80MHZ(_vhtcaps) \ + (_IEEE80211_MASKSHIFT(_vhtcaps, IEEE80211_VHTCAP_SUPP_CHAN_WIDTH_MASK) == \ + IEEE80211_VHTCAP_SUPP_CHAN_WIDTH_160_80P80MHZ) + +#define IEEE80211_VHTCAP_RXLDPC 0x00000010 +#define IEEE80211_VHTCAP_RXLDPC_S 4 + +#define IEEE80211_VHTCAP_SHORT_GI_80 0x00000020 +#define IEEE80211_VHTCAP_SHORT_GI_80_S 5 + +#define IEEE80211_VHTCAP_SHORT_GI_160 0x00000040 +#define IEEE80211_VHTCAP_SHORT_GI_160_S 6 + +#define IEEE80211_VHTCAP_TXSTBC 0x00000080 +#define IEEE80211_VHTCAP_TXSTBC_S 7 + +#define IEEE80211_VHTCAP_RXSTBC_1 0x00000100 +#define IEEE80211_VHTCAP_RXSTBC_2 0x00000200 +#define IEEE80211_VHTCAP_RXSTBC_3 0x00000300 +#define IEEE80211_VHTCAP_RXSTBC_4 0x00000400 +#define IEEE80211_VHTCAP_RXSTBC_MASK 0x00000700 +#define IEEE80211_VHTCAP_RXSTBC_MASK_S 8 + +#define IEEE80211_VHTCAP_SU_BEAMFORMER_CAPABLE 0x00000800 +#define IEEE80211_VHTCAP_SU_BEAMFORMER_CAPABLE_S 11 + +#define IEEE80211_VHTCAP_SU_BEAMFORMEE_CAPABLE 0x00001000 +#define IEEE80211_VHTCAP_SU_BEAMFORMEE_CAPABLE_S 12 + +#define IEEE80211_VHTCAP_BEAMFORMEE_STS_SHIFT 13 +#define IEEE80211_VHTCAP_BEAMFORMEE_STS_MASK \ + (7 << IEEE80211_VHTCAP_BEAMFORMEE_STS_SHIFT) +#define IEEE80211_VHTCAP_BEAMFORMEE_STS_MASK_S 13 + +#define IEEE80211_VHTCAP_SOUNDING_DIMENSIONS_SHIFT 16 +#define IEEE80211_VHTCAP_SOUNDING_DIMENSIONS_MASK \ + (7 << IEEE80211_VHTCAP_SOUNDING_DIMENSIONS_SHIFT) +#define IEEE80211_VHTCAP_SOUNDING_DIMENSIONS_MASK_S 16 + +#define IEEE80211_VHTCAP_MU_BEAMFORMER_CAPABLE 0x00080000 +#define IEEE80211_VHTCAP_MU_BEAMFORMER_CAPABLE_S 19 +#define IEEE80211_VHTCAP_MU_BEAMFORMEE_CAPABLE 0x00100000 +#define IEEE80211_VHTCAP_MU_BEAMFORMEE_CAPABLE_S 20 +#define IEEE80211_VHTCAP_VHT_TXOP_PS 0x00200000 +#define IEEE80211_VHTCAP_VHT_TXOP_PS_S 21 +#define IEEE80211_VHTCAP_HTC_VHT 0x00400000 +#define IEEE80211_VHTCAP_HTC_VHT_S 22 + +#define IEEE80211_VHTCAP_MAX_A_MPDU_LENGTH_EXPONENT_SHIFT 23 +#define IEEE80211_VHTCAP_MAX_A_MPDU_LENGTH_EXPONENT_MASK \ + (7 << IEEE80211_VHTCAP_MAX_A_MPDU_LENGTH_EXPONENT_SHIFT) +#define IEEE80211_VHTCAP_MAX_A_MPDU_LENGTH_EXPONENT_MASK_S 23 + +#define IEEE80211_VHTCAP_VHT_LINK_ADAPTATION_VHT_MASK 0x0c000000 +#define IEEE80211_VHTCAP_VHT_LINK_ADAPTATION_VHT_UNSOL_MFB 0x08000000 +#define IEEE80211_VHTCAP_VHT_LINK_ADAPTATION_VHT_MRQ_MFB 0x0c000000 +#define IEEE80211_VHTCAP_VHT_LINK_ADAPTATION_VHT_MASK_S 26 + +#define IEEE80211_VHTCAP_RX_ANTENNA_PATTERN 0x10000000 +#define IEEE80211_VHTCAP_RX_ANTENNA_PATTERN_S 28 +#define IEEE80211_VHTCAP_TX_ANTENNA_PATTERN 0x20000000 +#define IEEE80211_VHTCAP_TX_ANTENNA_PATTERN_S 29 + +/* XXX TODO: add the rest of the bits */ + +#define IEEE80211_VHTCAP_BITS \ + "\20\1MPDU7991\2MPDU11454\3CHAN160\4CHAN8080\5RXLDPC\6SHORTGI80" \ + "\7SHORTGI160\10RXSTBC1\11RXSTBC2\12RXSTBC3\13RXSTBC4\14BFERCAP" \ + "\15BFEECAP\27VHT\37RXANTPTN\40TXANTPTN" + +/* VHT Transmit Power Envelope element - 802.11ac-2013 8.4.2.164 + * + * This defines the maximum transmit power for various bandwidths. + */ -/* Transmit Beamforming (TxBF) Capabilities (see 7.3.2.57.6). */ +/* Count is how many elements follow and what they're for: + * + * 0 - 20 MHz + * 1 - 20+40 MHz + * 2 - 20+40+80 MHz + * 3 - 20+40+80+(160, 80+80) MHz + */ -#define IEEE80211_TXBFCAP_IMPLICIT_RX 0x00000001 -#define IEEE80211_TXBFCAP_RSSC 0x00000002 -#define IEEE80211_TXBFCAP_TSSC 0x00000004 -#define IEEE80211_TXBFCAP_RNDP 0x00000008 -#define IEEE80211_TXBFCAP_TNDP 0x00000010 -#define IEEE80211_TXBFCAP_IMPLICIT_TX 0x00000020 -#define IEEE80211_TXBFCAP_CALIB_MASK 0x000000c0 -#define IEEE80211_TXBFCAP_CALIB_SHIFT 6 -#define IEEE80211_TXBFCAP_TX_CSI 0x00000100 +#define IEEE80211_VHT_TXPWRENV_INFO_COUNT_SHIFT 0 +#define IEEE80211_VHT_TXPWRENV_INFO_COUNT_MASK 0x07 -/* Antenna Selection (ASEL) Capability (see 7.3.2.57.7). */ +/* Unit is the tx power representation. It should be EIRP for now; + * other values are reserved. + */ -#define IEEE80211_ASELCAP_ASEL 0x01 -#define IEEE80211_ASELCAP_CSIFB 0x02 +#define IEEE80211_VHT_TXPWRENV_UNIT_MASK 0x38 +#define IEEE80211_VHT_TXPWRENV_UNIT_SHIFT 3 + +/* This value is within the unit mask/shift above */ +#define IEEE80211_VHT_TXPWRENV_UNIT_EIRP 0 + +/* VHT action codes */ +#define WLAN_ACTION_VHT_COMPRESSED_BF 0 +#define WLAN_ACTION_VHT_GROUPID_MGMT 1 +#define WLAN_ACTION_VHT_OPMODE_NOTIF 2 + +#define IEEE80211_COUNTRY_MAX_BANDS 84 /* max possible bands */ +#define IEEE80211_COUNTRY_MAX_SIZE \ + (sizeof(struct ieee80211_country_ie) + \ + 3 * (IEEE80211_COUNTRY_MAX_BANDS - 1)) + +#define IEEE80211_EXTCAP_CMS (1ULL << 0) /* 20/40 BSS coexistence management support */ +#define IEEE80211_EXTCAP_RSVD_1 (1ULL << 1) +#define IEEE80211_EXTCAP_ECS (1ULL << 2) /* extended channel switching */ +#define IEEE80211_EXTCAP_RSVD_3 (1ULL << 3) +#define IEEE80211_EXTCAP_PSMP_CAP (1ULL << 4) /* PSMP capability */ +#define IEEE80211_EXTCAP_RSVD_5 (1ULL << 5) +#define IEEE80211_EXTCAP_S_PSMP_SUPP (1ULL << 6) +#define IEEE80211_EXTCAP_EVENT (1ULL << 7) +#define IEEE80211_EXTCAP_DIAGNOSTICS (1ULL << 8) +#define IEEE80211_EXTCAP_MCAST_DIAG (1ULL << 9) +#define IEEE80211_EXTCAP_LOC_TRACKING (1ULL << 10) +#define IEEE80211_EXTCAP_FMS (1ULL << 11) +#define IEEE80211_EXTCAP_PROXY_ARP (1ULL << 12) +#define IEEE80211_EXTCAP_CIR (1ULL << 13) /* collocated interference reporting */ +#define IEEE80211_EXTCAP_CIVIC_LOC (1ULL << 14) +#define IEEE80211_EXTCAP_GEOSPATIAL_LOC (1ULL << 15) +#define IEEE80211_EXTCAP_TFS (1ULL << 16) +#define IEEE80211_EXTCAP_WNM_SLEEPMODE (1ULL << 17) +#define IEEE80211_EXTCAP_TIM_BROADCAST (1ULL << 18) +#define IEEE80211_EXTCAP_BSS_TRANSITION (1ULL << 19) +#define IEEE80211_EXTCAP_QOS_TRAF_CAP (1ULL << 20) +#define IEEE80211_EXTCAP_AC_STA_COUNT (1ULL << 21) +#define IEEE80211_EXTCAP_M_BSSID (1ULL << 22) /* multiple BSSID field */ +#define IEEE80211_EXTCAP_TIMING_MEAS (1ULL << 23) +#define IEEE80211_EXTCAP_CHAN_USAGE (1ULL << 24) +#define IEEE80211_EXTCAP_SSID_LIST (1ULL << 25) +#define IEEE80211_EXTCAP_DMS (1ULL << 26) +#define IEEE80211_EXTCAP_UTC_TSF_OFFSET (1ULL << 27) +#define IEEE80211_EXTCAP_TLDS_BUF_STA_SUPP (1ULL << 28) /* TDLS peer U-APSP buffer STA support */ +#define IEEE80211_EXTCAP_TLDS_PPSM_SUPP (1ULL << 29) /* TDLS peer PSM support */ +#define IEEE80211_EXTCAP_TLDS_CH_SW (1ULL << 30) /* TDLS channel switching */ +#define IEEE80211_EXTCAP_INTERWORKING (1ULL << 31) +#define IEEE80211_EXTCAP_QOSMAP (1ULL << 32) +#define IEEE80211_EXTCAP_EBR (1ULL << 33) +#define IEEE80211_EXTCAP_SSPN_IF (1ULL << 34) +#define IEEE80211_EXTCAP_RSVD_35 (1ULL << 35) +#define IEEE80211_EXTCAP_MSGCF_CAP (1ULL << 36) +#define IEEE80211_EXTCAP_TLDS_SUPP (1ULL << 37) +#define IEEE80211_EXTCAP_TLDS_PROHIB (1ULL << 38) +#define IEEE80211_EXTCAP_TLDS_CH_SW_PROHIB (1ULL << 39) /* TDLS channel switching prohibited */ +#define IEEE80211_EXTCAP_RUF (1ULL << 40) /* reject unadmitted frame */ + +/* service interval granularity */ +#define IEEE80211_EXTCAP_SIG ((1ULL << 41) | (1ULL << 42) | (1ULL << 43)) +#define IEEE80211_EXTCAP_ID_LOC (1ULL << 44) +#define IEEE80211_EXTCAP_U_APSD_COEX (1ULL << 45) +#define IEEE80211_EXTCAP_WNM_NOTIFICATION (1ULL << 46) +#define IEEE80211_EXTCAP_RSVD_47 (1ULL << 47) +#define IEEE80211_EXTCAP_SSID (1ULL << 48) /* UTF-8 SSID */ + +/* bits 49-n are reserved */ + +/* Note the min acceptable CSA count is used to guard against + * malicious CSA injection in station mode. Defining this value + * as other than 0 violates the 11h spec. + */ -/* Bit 7 is reserved. */ +#define IEEE80211_CSA_COUNT_MIN 2 +#define IEEE80211_CSA_COUNT_MAX 255 -/* HT Operation element (see 7.3.2.58). */ +/* rate set entries are in .5 Mb/s units, and potentially marked as basic */ +#define IEEE80211_RATE_BASIC 0x80 +#define IEEE80211_RATE_VAL 0x7f +#define IEEE80211_RV(v) ((v) & IEEE80211_RATE_VAL) -/* Byte 1. */ +/* ERP information element flags */ +#define IEEE80211_ERP_NON_ERP_PRESENT 0x01 +#define IEEE80211_ERP_USE_PROTECTION 0x02 +#define IEEE80211_ERP_LONG_PREAMBLE 0x04 -#define IEEE80211_HTOP0_SCO_MASK 0x03 -#define IEEE80211_HTOP0_SCO_SHIFT 0 -#define IEEE80211_HTOP0_SCO_SCN 0 -#define IEEE80211_HTOP0_SCO_SCA 1 -#define IEEE80211_HTOP0_SCO_SCB 3 -#define IEEE80211_HTOP0_CHW 0x04 -#define IEEE80211_HTOP0_RIFS 0x08 -#define IEEE80211_HTOP0_SPSMP 0x10 -#define IEEE80211_HTOP0_SIG_MASK 0xe0 -#define IEEE80211_HTOP0_SIG_SHIFT 5 +#define IEEE80211_ERP_BITS \ + "\20\1NON_ERP_PRESENT\2USE_PROTECTION\3LONG_PREAMBLE" -/* Bytes 2-3. */ - -#define IEEE80211_HTOP1_PROT_MASK 0x0003 -#define IEEE80211_HTOP1_PROT_SHIFT 0 -#define IEEE80211_HTOP1_NONGTSTA 0x0004 - -/* Bit 3 is reserved. */ - -#define IEEE80211_HTOP1_OBSS_NONHTSTA 0x0010 - -/* Bits 5-15 are reserved. */ +#define ATH_OUI 0x7f0300 /* Atheros OUI */ +#define ATH_OUI_TYPE 0x01 /* Atheros protocol ie */ -/* Bytes 4-5. */ +/* NB: Atheros allocated the OUI for this purpose ~2005 but beware ... */ +#define TDMA_OUI ATH_OUI +#define TDMA_OUI_TYPE 0x02 /* TDMA protocol ie */ -/* Bits 0-5 are reserved. */ +#define BCM_OUI 0x4c9000 /* Broadcom OUI */ +#define BCM_OUI_HTCAP 51 /* pre-draft HTCAP ie */ +#define BCM_OUI_HTINFO 52 /* pre-draft HTINFO ie */ -#define IEEE80211_HTOP2_DUALBEACON 0x0040 -#define IEEE80211_HTOP2_DUALCTSPROT 0x0080 -#define IEEE80211_HTOP2_STBCBEACON 0x0100 -#define IEEE80211_HTOP2_LSIGTXOP 0x0200 -#define IEEE80211_HTOP2_PCOACTIVE 0x0400 -#define IEEE80211_HTOP2_PCOPHASE40 0x0800 +#define WPA_OUI 0xf25000 +#define WPA_OUI_TYPE 0x01 +#define WPA_VERSION 1 /* current supported version */ -/* Bits 12-15 are reserved. */ +#define WPA_CSE_NULL 0x00 +#define WPA_CSE_WEP40 0x01 +#define WPA_CSE_TKIP 0x02 +#define WPA_CSE_CCMP 0x04 +#define WPA_CSE_WEP104 0x05 -/* EDCA Access Categories. */ +#define WPA_ASE_NONE 0x00 +#define WPA_ASE_8021X_UNSPEC 0x01 +#define WPA_ASE_8021X_PSK 0x02 -#define EDCA_NUM_AC 4 +#define WPS_OUI_TYPE 0x04 -/* Number of TID values (traffic identifier) */ +#define RSN_OUI 0xac0f00 +#define RSN_VERSION 1 /* current supported version */ -#define IEEE80211_NUM_TID 16 +#define RSN_CSE_NULL 0x00 +#define RSN_CSE_WEP40 0x01 +#define RSN_CSE_TKIP 0x02 +#define RSN_CSE_WRAP 0x03 +#define RSN_CSE_CCMP 0x04 +#define RSN_CSE_WEP104 0x05 -/* Atheros private advanced capabilities info */ +#define RSN_ASE_NONE 0x00 +#define RSN_ASE_8021X_UNSPEC 0x01 +#define RSN_ASE_8021X_PSK 0x02 -#define ATHEROS_CAP_TURBO_PRIME 0x01 -#define ATHEROS_CAP_COMPRESSION 0x02 -#define ATHEROS_CAP_FAST_FRAME 0x04 +#define RSN_CAP_PREAUTH 0x01 -/* bits 3-6 reserved */ +#define WME_OUI 0xf25000 +#define WME_OUI_TYPE 0x02 +#define WME_INFO_OUI_SUBTYPE 0x00 +#define WME_PARAM_OUI_SUBTYPE 0x01 +#define WME_VERSION 1 -#define ATHEROS_CAP_BOOST 0x80 +/* WME stream classes */ +#define WME_AC_BE 0 /* best effort */ +#define WME_AC_BK 1 /* background */ +#define WME_AC_VI 2 /* video */ +#define WME_AC_VO 3 /* voice */ -/* Organizationally Unique Identifiers. - * See http://standards.ieee.org/regauth/oui/oui.txt for a list. +/* AUTH management packets + * + * octet algo[2] + * octet seq[2] + * octet status[2] + * octet chal.id + * octet chal.length + * octet chal.text[253] NB: 1-253 bytes */ -#define ATHEROS_OUI ((const uint8_t[]){ 0x00, 0x03, 0x7f }) -#define BROADCOM_OUI ((const uint8_t[]){ 0x00, 0x90, 0x4c }) -#define IEEE80211_OUI ((const uint8_t[]){ 0x00, 0x0f, 0xac }) -#define MICROSOFT_OUI ((const uint8_t[]){ 0x00, 0x50, 0xf2 }) +/* challenge length for shared key auth */ +#define IEEE80211_CHALLENGE_LEN 128 -#define IEEE80211_AUTH_ALGORITHM(auth) \ - ((auth)[0] | ((auth)[1] << 8)) -#define IEEE80211_AUTH_TRANSACTION(auth) \ - ((auth)[2] | ((auth)[3] << 8)) -#define IEEE80211_AUTH_STATUS(auth) \ - ((auth)[4] | ((auth)[5] << 8)) +#define IEEE80211_AUTH_ALG_OPEN 0x0000 +#define IEEE80211_AUTH_ALG_SHARED 0x0001 +#define IEEE80211_AUTH_ALG_LEAP 0x0080 -/* Authentication Algorithm Number field (see 7.3.1.1). */ - -#define IEEE80211_AUTH_ALG_OPEN 0x0000 -#define IEEE80211_AUTH_ALG_SHARED 0x0001 -#define IEEE80211_AUTH_ALG_LEAP 0x0080 - -/* WEP */ - -#define IEEE80211_WEP_KEYLEN 5 /* 40bit */ -#define IEEE80211_WEP_NKID 4 /* number of key ids */ -#define IEEE80211_CHALLENGE_LEN 128 - -/* WEP header constants */ - -#define IEEE80211_WEP_IVLEN 3 /* 24bit */ -#define IEEE80211_WEP_KIDLEN 1 /* 1 octet */ -#define IEEE80211_WEP_CRCLEN 4 /* CRC-32 */ -#define IEEE80211_CRC_LEN 4 -#define IEEE80211_WEP_TOTLEN \ - (IEEE80211_WEP_IVLEN + IEEE80211_WEP_KIDLEN + IEEE80211_WEP_CRCLEN) +#define IEEE80211_WEP_KEYLEN 5 /* 40bit */ +#define IEEE80211_WEP_IVLEN 3 /* 24bit */ +#define IEEE80211_WEP_KIDLEN 1 /* 1 octet */ +#define IEEE80211_WEP_CRCLEN 4 /* CRC-32 */ +#define IEEE80211_WEP_TOTLEN (IEEE80211_WEP_IVLEN + \ + IEEE80211_WEP_KIDLEN + \ + IEEE80211_WEP_CRCLEN) +#define IEEE80211_WEP_NKID 4 /* number of key ids */ /* 802.11i defines an extended IV for use with non-WEP ciphers. * When the EXTIV bit is set in the key id byte an additional @@ -390,458 +822,778 @@ * EXTIV bit is likewise set but the 8 bytes represent the * CCMP header rather than IV+extended-IV. */ +#define IEEE80211_WEP_EXTIV 0x20 +#define IEEE80211_WEP_EXTIVLEN 4 /* extended IV length */ +#define IEEE80211_WEP_MICLEN 8 /* trailing MIC */ -#define IEEE80211_WEP_EXTIV 0x20 -#define IEEE80211_WEP_EXTIVLEN 4 /* extended IV length */ -#define IEEE80211_WEP_MICLEN 8 /* trailing MIC */ +#define IEEE80211_CRC_LEN 4 /* Maximum acceptable MTU is: - * IEEE80211_MAX_LEN - WEP overhead - CRC - - * QoS overhead - RSN/WPA overhead + * IEEE80211_MAX_LEN - WEP overhead - CRC - + * QoS overhead - RSN/WPA overhead * Min is arbitrarily chosen > IEEE80211_MIN_LEN. The default - * mtu is Ethernet-compatible. + * mtu is Ethernet-compatible; it's set by ether_ifattach. */ +#define IEEE80211_MTU_MAX 2290 +#define IEEE80211_MTU_MIN 32 -#define IEEE80211_MTU_MAX 2290 -#define IEEE80211_MTU_MIN 32 - -#define IEEE80211_MAX_LEN \ - (2300 + IEEE80211_CRC_LEN + \ - (IEEE80211_WEP_IVLEN + IEEE80211_WEP_KIDLEN + IEEE80211_WEP_CRCLEN)) +#define IEEE80211_MAX_LEN (2300 + IEEE80211_CRC_LEN + \ + (IEEE80211_WEP_IVLEN + IEEE80211_WEP_KIDLEN + IEEE80211_WEP_CRCLEN)) #define IEEE80211_ACK_LEN \ - (sizeof(struct ieee80211_frame_ack) + IEEE80211_CRC_LEN) + (sizeof(struct ieee80211_frame_ack) + IEEE80211_CRC_LEN) #define IEEE80211_MIN_LEN \ - (sizeof(struct ieee80211_frame_min) + IEEE80211_CRC_LEN) + (sizeof(struct ieee80211_frame_min) + IEEE80211_CRC_LEN) /* The 802.11 spec says at most 2007 stations may be * associated at once. For most AP's this is way more - * than is feasible so we use a default of 1800. This - * number may be overridden by the driver and/or by - * user configuration. + * than is feasible so we use a default of IEEE80211_AID_DEF. + * This number may be overridden by the driver and/or by + * user configuration but may not be less than IEEE80211_AID_MIN + * (see _ieee80211.h for implementation-specific settings). */ +#define IEEE80211_AID_MAX 2007 -#define IEEE80211_AID_MAX 2007 -#define IEEE80211_AID_DEF 1800 -#define IEEE80211_AID(b) ((b) &~ 0xc000) +#define IEEE80211_AID(b) ((b) &~ 0xc000) /* RTS frame length parameters. The default is specified in - * the 802.11 spec. The max may be wrong for jumbo frames. + * the 802.11 spec as 512; we treat it as implementation-dependent + * so it's defined in ieee80211_var.h. The max may be wrong + * for jumbo frames. */ +#define IEEE80211_RTS_MIN 1 +#define IEEE80211_RTS_MAX 2346 -#define IEEE80211_RTS_DEFAULT 512 -#define IEEE80211_RTS_MIN 1 -#define IEEE80211_RTS_MAX IEEE80211_MAX_LEN +/* TX fragmentation parameters. As above for RTS, we treat + * default as implementation-dependent so define it elsewhere. + */ +#define IEEE80211_FRAG_MIN 256 +#define IEEE80211_FRAG_MAX 2346 -#define IEEE80211_PLCP_SERVICE 0x00 -#define IEEE80211_PLCP_SERVICE_PBCC 0x08 /* PBCC encoded */ -#define IEEE80211_PLCP_SERVICE_LENEXT 0x80 /* length extension bit */ +/* Beacon interval (TU's). Min+max come from WiFi requirements. + * As above, we treat default as implementation-dependent so + * define it elsewhere. + */ +#define IEEE80211_BINTVAL_MAX 1000 /* max beacon interval (TU's) */ +#define IEEE80211_BINTVAL_MIN 25 /* min beacon interval (TU's) */ -/* One Time Unit (TU) is 1Kus = 1024 microseconds. */ +/* DTIM period (beacons). Min+max are not really defined + * by the protocol but we want them publicly visible so + * define them here. + */ +#define IEEE80211_DTIM_MAX 15 /* max DTIM period */ +#define IEEE80211_DTIM_MIN 1 /* min DTIM period */ -#define IEEE80211_DUR_TU 1024 +/* Beacon miss threshold (beacons). As for DTIM, we define + * them here to be publicly visible. Note the max may be + * clamped depending on device capabilities. + */ +#define IEEE80211_HWBMISS_MIN 1 +#define IEEE80211_HWBMISS_MAX 255 + +/* One Time Unit (TU) is 1Kus = 1024 microseconds. */ +#define IEEE80211_DUR_TU 1024 /* IEEE 802.11b durations for DSSS PHY in microseconds */ +#define IEEE80211_DUR_DS_LONG_PREAMBLE 144 +#define IEEE80211_DUR_DS_SHORT_PREAMBLE 72 + +#define IEEE80211_DUR_DS_SLOW_PLCPHDR 48 +#define IEEE80211_DUR_DS_FAST_PLCPHDR 24 +#define IEEE80211_DUR_DS_SLOW_ACK 112 +#define IEEE80211_DUR_DS_FAST_ACK 56 +#define IEEE80211_DUR_DS_SLOW_CTS 112 +#define IEEE80211_DUR_DS_FAST_CTS 56 + +#define IEEE80211_DUR_DS_SLOT 20 +#define IEEE80211_DUR_DS_SIFS 10 +#define IEEE80211_DUR_DS_PIFS (IEEE80211_DUR_DS_SIFS + IEEE80211_DUR_DS_SLOT) +#define IEEE80211_DUR_DS_DIFS (IEEE80211_DUR_DS_SIFS + \ + 2 * IEEE80211_DUR_DS_SLOT) +#define IEEE80211_DUR_DS_EIFS (IEEE80211_DUR_DS_SIFS + \ + IEEE80211_DUR_DS_SLOW_ACK + \ + IEEE80211_DUR_DS_LONG_PREAMBLE + \ + IEEE80211_DUR_DS_SLOW_PLCPHDR + \ + IEEE80211_DUR_DIFS) + +/**************************************************************************** + * Public Types + ****************************************************************************/ + +typedef uint16_t ieee80211_seq; + +/* AUTH management packets + * + * octet algo[2] + * octet seq[2] + * octet status[2] + * octet chal.id + * octet chal.length + * octet chal.text[253] NB: 1-253 bytes + */ + +enum +{ + IEEE80211_AUTH_OPEN_REQUEST = 1, + IEEE80211_AUTH_OPEN_RESPONSE = 2, +}; + +enum +{ + IEEE80211_AUTH_SHARED_REQUEST = 1, + IEEE80211_AUTH_SHARED_CHALLENGE = 2, + IEEE80211_AUTH_SHARED_RESPONSE = 3, + IEEE80211_AUTH_SHARED_PASS = 4, +}; -#define IEEE80211_DUR_DS_LONG_PREAMBLE 144 -#define IEEE80211_DUR_DS_SHORT_PREAMBLE 72 -#define IEEE80211_DUR_DS_PREAMBLE_DIFFERENCE \ - (IEEE80211_DUR_DS_LONG_PREAMBLE - IEEE80211_DUR_DS_SHORT_PREAMBLE) -#define IEEE80211_DUR_DS_FAST_PLCPHDR 24 -#define IEEE80211_DUR_DS_SLOW_PLCPHDR 48 -#define IEEE80211_DUR_DS_PLCPHDR_DIFFERENCE \ - (IEEE80211_DUR_DS_SLOW_PLCPHDR - IEEE80211_DUR_DS_FAST_PLCPHDR) -#define IEEE80211_DUR_DS_SLOW_ACK 112 -#define IEEE80211_DUR_DS_FAST_ACK 56 -#define IEEE80211_DUR_DS_SLOW_CTS 112 -#define IEEE80211_DUR_DS_FAST_CTS 56 -#define IEEE80211_DUR_DS_SLOT 20 -#define IEEE80211_DUR_DS_SIFS 10 -#define IEEE80211_DUR_DS_PIFS \ - (IEEE80211_DUR_DS_SIFS + IEEE80211_DUR_DS_SLOT) -#define IEEE80211_DUR_DS_DIFS \ - (IEEE80211_DUR_DS_SIFS + 2 * IEEE80211_DUR_DS_SLOT) -#define IEEE80211_DUR_DS_EIFS (IEEE80211_DUR_DS_SIFS + \ - IEEE80211_DUR_DS_SLOW_ACK + \ - IEEE80211_DUR_DS_LONG_PREAMBLE + \ - IEEE80211_DUR_DS_SLOW_PLCPHDR + \ - IEEE80211_DUR_DIFS) - -/* The RSNA key descriptor used by IEEE 802.11 does not use the IEEE 802.1X - * key descriptor. Instead, it uses the key descriptor described in 8.5.2. +/* Reason and status codes. + * + * Reason codes are used in management frames to indicate why an + * action took place (e.g. on disassociation). Status codes are + * used in management frames to indicate the result of an operation. + * + * Unlisted codes are reserved */ -#define EAPOL_KEY_NONCE_LEN 32 -#define EAPOL_KEY_IV_LEN 16 -#define EAPOL_KEY_MIC_LEN 16 +enum +{ + IEEE80211_REASON_UNSPECIFIED = 1, + IEEE80211_REASON_AUTH_EXPIRE = 2, + IEEE80211_REASON_AUTH_LEAVE = 3, + IEEE80211_REASON_ASSOC_EXPIRE = 4, + IEEE80211_REASON_ASSOC_TOOMANY = 5, + IEEE80211_REASON_NOT_AUTHED = 6, + IEEE80211_REASON_NOT_ASSOCED = 7, + IEEE80211_REASON_ASSOC_LEAVE = 8, + IEEE80211_REASON_ASSOC_NOT_AUTHED = 9, + IEEE80211_REASON_DISASSOC_PWRCAP_BAD = 10, /* 11h */ + IEEE80211_REASON_DISASSOC_SUPCHAN_BAD = 11, /* 11h */ + IEEE80211_REASON_IE_INVALID = 13, /* 11i */ + IEEE80211_REASON_MIC_FAILURE = 14, /* 11i */ + IEEE80211_REASON_4WAY_HANDSHAKE_TIMEOUT = 15, /* 11i */ + IEEE80211_REASON_GROUP_KEY_UPDATE_TIMEOUT = 16, /* 11i */ + IEEE80211_REASON_IE_IN_4WAY_DIFFERS = 17, /* 11i */ + IEEE80211_REASON_GROUP_CIPHER_INVALID = 18, /* 11i */ + IEEE80211_REASON_PAIRWISE_CIPHER_INVALID = 19, /* 11i */ + IEEE80211_REASON_AKMP_INVALID = 20, /* 11i */ + IEEE80211_REASON_UNSUPP_RSN_IE_VERSION = 21, /* 11i */ + IEEE80211_REASON_INVALID_RSN_IE_CAP = 22, /* 11i */ + IEEE80211_REASON_802_1X_AUTH_FAILED = 23, /* 11i */ + IEEE80211_REASON_CIPHER_SUITE_REJECTED = 24, /* 11i */ + IEEE80211_REASON_UNSPECIFIED_QOS = 32, /* 11e */ + IEEE80211_REASON_INSUFFICIENT_BW = 33, /* 11e */ + IEEE80211_REASON_TOOMANY_FRAMES = 34, /* 11e */ + IEEE80211_REASON_OUTSIDE_TXOP = 35, /* 11e */ + IEEE80211_REASON_LEAVING_QBSS = 36, /* 11e */ + IEEE80211_REASON_BAD_MECHANISM = 37, /* 11e */ + IEEE80211_REASON_SETUP_NEEDED = 38, /* 11e */ + IEEE80211_REASON_TIMEOUT = 39, /* 11e */ + + IEEE80211_REASON_PEER_LINK_CANCELED = 52, /* 11s */ + IEEE80211_REASON_MESH_MAX_PEERS = 53, /* 11s */ + IEEE80211_REASON_MESH_CPVIOLATION = 54, /* 11s */ + IEEE80211_REASON_MESH_CLOSE_RCVD = 55, /* 11s */ + IEEE80211_REASON_MESH_MAX_RETRIES = 56, /* 11s */ + IEEE80211_REASON_MESH_CONFIRM_TIMEOUT = 57, /* 11s */ + IEEE80211_REASON_MESH_INVALID_GTK = 58, /* 11s */ + IEEE80211_REASON_MESH_INCONS_PARAMS = 59, /* 11s */ + IEEE80211_REASON_MESH_INVALID_SECURITY = 60, /* 11s */ + IEEE80211_REASON_MESH_PERR_NO_PROXY = 61, /* 11s */ + IEEE80211_REASON_MESH_PERR_NO_FI = 62, /* 11s */ + IEEE80211_REASON_MESH_PERR_DEST_UNREACH = 63, /* 11s */ + IEEE80211_REASON_MESH_MAC_ALRDY_EXISTS_MBSS = 64, /* 11s */ + IEEE80211_REASON_MESH_CHAN_SWITCH_REG = 65, /* 11s */ + IEEE80211_REASON_MESH_CHAN_SWITCH_UNSPEC = 66, /* 11s */ + + IEEE80211_STATUS_SUCCESS = 0, + IEEE80211_STATUS_UNSPECIFIED = 1, + IEEE80211_STATUS_CAPINFO = 10, + IEEE80211_STATUS_NOT_ASSOCED = 11, + IEEE80211_STATUS_OTHER = 12, + IEEE80211_STATUS_ALG = 13, + IEEE80211_STATUS_SEQUENCE = 14, + IEEE80211_STATUS_CHALLENGE = 15, + IEEE80211_STATUS_TIMEOUT = 16, + IEEE80211_STATUS_TOOMANY = 17, + IEEE80211_STATUS_BASIC_RATE = 18, + IEEE80211_STATUS_SP_REQUIRED = 19, /* 11b */ + IEEE80211_STATUS_PBCC_REQUIRED = 20, /* 11b */ + IEEE80211_STATUS_CA_REQUIRED = 21, /* 11b */ + IEEE80211_STATUS_SPECMGMT_REQUIRED = 22, /* 11h */ + IEEE80211_STATUS_PWRCAP_REQUIRED = 23, /* 11h */ + IEEE80211_STATUS_SUPCHAN_REQUIRED = 24, /* 11h */ + IEEE80211_STATUS_SHORTSLOT_REQUIRED = 25, /* 11g */ + IEEE80211_STATUS_DSSSOFDM_REQUIRED = 26, /* 11g */ + IEEE80211_STATUS_MISSING_HT_CAPS = 27, /* 11n D3.0 */ + IEEE80211_STATUS_INVALID_IE = 40, /* 11i */ + IEEE80211_STATUS_GROUP_CIPHER_INVALID = 41, /* 11i */ + IEEE80211_STATUS_PAIRWISE_CIPHER_INVALID = 42, /* 11i */ + IEEE80211_STATUS_AKMP_INVALID = 43, /* 11i */ + IEEE80211_STATUS_UNSUPP_RSN_IE_VERSION = 44, /* 11i */ + IEEE80211_STATUS_INVALID_RSN_IE_CAP = 45, /* 11i */ + IEEE80211_STATUS_CIPHER_SUITE_REJECTED = 46, /* 11i */ +}; -/* Pairwise Transient Key (see 8.5.1.2) */ +/* Management information element payloads. */ -#define IEEE80211_PMKID_LEN 16 -#define IEEE80211_SMKID_LEN 16 +enum +{ + IEEE80211_ELEMID_SSID = 0, + IEEE80211_ELEMID_RATES = 1, + IEEE80211_ELEMID_FHPARMS = 2, + IEEE80211_ELEMID_DSPARMS = 3, + IEEE80211_ELEMID_CFPARMS = 4, + IEEE80211_ELEMID_TIM = 5, + IEEE80211_ELEMID_IBSSPARMS = 6, + IEEE80211_ELEMID_COUNTRY = 7, + IEEE80211_ELEMID_BSSLOAD = 11, + IEEE80211_ELEMID_TSPEC = 13, + IEEE80211_ELEMID_TCLAS = 14, + IEEE80211_ELEMID_CHALLENGE = 16, -/**************************************************************************** - * Public Types - ****************************************************************************/ + /* 17-31 reserved for challenge text extension */ + + IEEE80211_ELEMID_PWRCNSTR = 32, + IEEE80211_ELEMID_PWRCAP = 33, + IEEE80211_ELEMID_TPCREQ = 34, + IEEE80211_ELEMID_TPCREP = 35, + IEEE80211_ELEMID_SUPPCHAN = 36, + IEEE80211_ELEMID_CSA = 37, + IEEE80211_ELEMID_MEASREQ = 38, + IEEE80211_ELEMID_MEASREP = 39, + IEEE80211_ELEMID_QUIET = 40, + IEEE80211_ELEMID_IBSSDFS = 41, + IEEE80211_ELEMID_ERP = 42, + IEEE80211_ELEMID_HTCAP = 45, + IEEE80211_ELEMID_QOS = 46, + IEEE80211_ELEMID_RESERVED_47 = 47, + IEEE80211_ELEMID_RSN = 48, + IEEE80211_ELEMID_XRATES = 50, + IEEE80211_ELEMID_APCHANREP = 51, + IEEE80211_ELEMID_MOBILITY_DOMAIN = 54, + IEEE80211_ELEMID_HTINFO = 61, + IEEE80211_ELEMID_SECCHAN_OFFSET = 62, + IEEE80211_ELEMID_RRM_ENACAPS = 70, + IEEE80211_ELEMID_MULTIBSSID = 71, + IEEE80211_ELEMID_COEX_2040 = 72, + IEEE80211_ELEMID_INTOL_CHN_REPORT = 73, + IEEE80211_ELEMID_OVERLAP_BSS_SCAN_PARAM = 74, + IEEE80211_ELEMID_TSF_REQ = 91, + IEEE80211_ELEMID_TSF_RESP = 92, + IEEE80211_ELEMID_WNM_SLEEP_MODE = 93, + IEEE80211_ELEMID_TIM_BCAST_REQ = 94, + IEEE80211_ELEMID_TIM_BCAST_RESP = 95, + IEEE80211_ELEMID_TPC = 150, + IEEE80211_ELEMID_CCKM = 156, + IEEE80211_ELEMID_VENDOR = 221, /* vendor private */ + + /* 802.11s IEs + * NB: On vanilla Linux still IEEE80211_ELEMID_MESHPEER = 55, + * but they defined a new with id 117 called PEER_MGMT. + * NB: complies with open80211 + */ + + IEEE80211_ELEMID_MESHCONF = 113, + IEEE80211_ELEMID_MESHID = 114, + IEEE80211_ELEMID_MESHLINK = 115, + IEEE80211_ELEMID_MESHCNGST = 116, + IEEE80211_ELEMID_MESHPEER = 117, + IEEE80211_ELEMID_MESHCSA = 118, + IEEE80211_ELEMID_MESHTIM = 39, /* XXX: remove */ + IEEE80211_ELEMID_MESHAWAKEW = 119, + IEEE80211_ELEMID_MESHBEACONT = 120, + + /* 121-124 MMCAOP not implemented yet */ + + IEEE80211_ELEMID_MESHGANN = 125, + IEEE80211_ELEMID_MESHRANN = 126, + + /* 127 Extended Capabilities */ + + IEEE80211_ELEMID_EXTCAP = 127, + + /* 128-129 reserved */ + + IEEE80211_ELEMID_MESHPREQ = 130, + IEEE80211_ELEMID_MESHPREP = 131, + IEEE80211_ELEMID_MESHPERR = 132, + + /* 133-136 reserved */ + + IEEE80211_ELEMID_MESHPXU = 137, + IEEE80211_ELEMID_MESHPXUC = 138, + IEEE80211_ELEMID_MESHAH = 60, /* XXX: remove */ + + /* 802.11ac */ + + IEEE80211_ELEMID_VHT_CAP = 191, + IEEE80211_ELEMID_VHT_OPMODE = 192, + IEEE80211_ELEMID_VHT_PWR_ENV = 195, +}; + +/* IEEE 802.11 PLCP header */ -/* Generic definitions for IEEE 802.11 frames */ +begin_packed_struct struct ieee80211_plcp_hdr +{ + uint16_t i_sfd; + uint8_t i_signal; + uint8_t i_service; + uint16_t i_length; + uint16_t i_crc; +} end_packed_struct; + +/* generic definitions for IEEE 802.11 frames */ begin_packed_struct struct ieee80211_frame { - uint8_t i_fc[2]; - uint8_t i_dur[2]; - uint8_t i_addr1[IEEE80211_ADDR_LEN]; - uint8_t i_addr2[IEEE80211_ADDR_LEN]; - uint8_t i_addr3[IEEE80211_ADDR_LEN]; - uint8_t i_seq[2]; + uint8_t i_fc[2]; + uint8_t i_dur[2]; + uint8_t i_addr1[IEEE80211_ADDR_LEN]; + uint8_t i_addr2[IEEE80211_ADDR_LEN]; + uint8_t i_addr3[IEEE80211_ADDR_LEN]; + uint8_t i_seq[2]; + + /* possibly followed by addr4[IEEE80211_ADDR_LEN]; */ + + /* see below */ } end_packed_struct; begin_packed_struct struct ieee80211_qosframe { - uint8_t i_fc[2]; - uint8_t i_dur[2]; - uint8_t i_addr1[IEEE80211_ADDR_LEN]; - uint8_t i_addr2[IEEE80211_ADDR_LEN]; - uint8_t i_addr3[IEEE80211_ADDR_LEN]; - uint8_t i_seq[2]; - uint8_t i_qos[2]; + uint8_t i_fc[2]; + uint8_t i_dur[2]; + uint8_t i_addr1[IEEE80211_ADDR_LEN]; + uint8_t i_addr2[IEEE80211_ADDR_LEN]; + uint8_t i_addr3[IEEE80211_ADDR_LEN]; + uint8_t i_seq[2]; + uint8_t i_qos[2]; + + /* possibly followed by addr4[IEEE80211_ADDR_LEN]; */ + + /* see below */ } end_packed_struct; -begin_packed_struct struct ieee80211_htframe /* 11n */ +begin_packed_struct struct ieee80211_qoscntl { - uint8_t i_fc[2]; - uint8_t i_dur[2]; - uint8_t i_addr1[IEEE80211_ADDR_LEN]; - uint8_t i_addr2[IEEE80211_ADDR_LEN]; - uint8_t i_addr3[IEEE80211_ADDR_LEN]; - uint8_t i_seq[2]; - uint8_t i_qos[2]; - uint8_t i_ht[4]; -} end_packed_struct; + uint8_t i_qos[2]; +}; begin_packed_struct struct ieee80211_frame_addr4 { - uint8_t i_fc[2]; - uint8_t i_dur[2]; - uint8_t i_addr1[IEEE80211_ADDR_LEN]; - uint8_t i_addr2[IEEE80211_ADDR_LEN]; - uint8_t i_addr3[IEEE80211_ADDR_LEN]; - uint8_t i_seq[2]; - uint8_t i_addr4[IEEE80211_ADDR_LEN]; + uint8_t i_fc[2]; + uint8_t i_dur[2]; + uint8_t i_addr1[IEEE80211_ADDR_LEN]; + uint8_t i_addr2[IEEE80211_ADDR_LEN]; + uint8_t i_addr3[IEEE80211_ADDR_LEN]; + uint8_t i_seq[2]; + uint8_t i_addr4[IEEE80211_ADDR_LEN]; } end_packed_struct; begin_packed_struct struct ieee80211_qosframe_addr4 { - uint8_t i_fc[2]; - uint8_t i_dur[2]; - uint8_t i_addr1[IEEE80211_ADDR_LEN]; - uint8_t i_addr2[IEEE80211_ADDR_LEN]; - uint8_t i_addr3[IEEE80211_ADDR_LEN]; - uint8_t i_seq[2]; - uint8_t i_addr4[IEEE80211_ADDR_LEN]; - uint8_t i_qos[2]; + uint8_t i_fc[2]; + uint8_t i_dur[2]; + uint8_t i_addr1[IEEE80211_ADDR_LEN]; + uint8_t i_addr2[IEEE80211_ADDR_LEN]; + uint8_t i_addr3[IEEE80211_ADDR_LEN]; + uint8_t i_seq[2]; + uint8_t i_addr4[IEEE80211_ADDR_LEN]; + uint8_t i_qos[2]; } end_packed_struct; -begin_packed_struct struct ieee80211_htframe_addr4 /* 11n */ +/* WME/802.11e information element. */ + +begin_packed_struct struct ieee80211_wme_info { - uint8_t i_fc[2]; - uint8_t i_dur[2]; - uint8_t i_addr1[IEEE80211_ADDR_LEN]; - uint8_t i_addr2[IEEE80211_ADDR_LEN]; - uint8_t i_addr3[IEEE80211_ADDR_LEN]; - uint8_t i_seq[2]; - uint8_t i_addr4[IEEE80211_ADDR_LEN]; - uint8_t i_qos[2]; - uint8_t i_ht[4]; + uint8_t wme_id; /* IEEE80211_ELEMID_VENDOR */ + uint8_t wme_len; /* length in bytes */ + uint8_t wme_oui[3]; /* 0x00, 0x50, 0xf2 */ + uint8_t wme_type; /* OUI type */ + uint8_t wme_subtype; /* OUI subtype */ + uint8_t wme_version; /* spec revision */ + uint8_t wme_info; /* QoS info */ } end_packed_struct; -/* Control frames. */ +/* WME/802.11e Tspec Element */ -begin_packed_struct struct ieee80211_frame_min +begin_packed_struct struct ieee80211_wme_tspec { - uint8_t i_fc[2]; - uint8_t i_dur[2]; - uint8_t i_addr1[IEEE80211_ADDR_LEN]; - uint8_t i_addr2[IEEE80211_ADDR_LEN]; + uint8_t ts_id; + uint8_t ts_len; + uint8_t ts_oui[3]; + uint8_t ts_oui_type; + uint8_t ts_oui_subtype; + uint8_t ts_version; + uint8_t ts_tsinfo[3]; + uint8_t ts_nom_msdu[2]; + uint8_t ts_max_msdu[2]; + uint8_t ts_min_svc[4]; + uint8_t ts_max_svc[4]; + uint8_t ts_inactv_intv[4]; + uint8_t ts_susp_intv[4]; + uint8_t ts_start_svc[4]; + uint8_t ts_min_rate[4]; + uint8_t ts_mean_rate[4]; + uint8_t ts_max_burst[4]; + uint8_t ts_min_phy[4]; + uint8_t ts_peak_rate[4]; + uint8_t ts_delay[4]; + uint8_t ts_surplus[2]; + uint8_t ts_medium_time[2]; +} end_packed_struct; - /* FCS */ +/* WME AC parameter field */ +begin_packed_struct struct ieee80211_wme_acparams +{ + uint8_t acp_aci_aifsn; + uint8_t acp_logcwminmax; + uint16_t acp_txop; } end_packed_struct; -begin_packed_struct struct ieee80211_frame_rts +/* WME Parameter Element */ + +begin_packed_struct struct ieee80211_wme_param { - uint8_t i_fc[2]; - uint8_t i_dur[2]; - uint8_t i_ra[IEEE80211_ADDR_LEN]; - uint8_t i_ta[IEEE80211_ADDR_LEN]; + uint8_t param_id; + uint8_t param_len; + uint8_t param_oui[3]; + uint8_t param_oui_type; + uint8_t param_oui_subtype; + uint8_t param_version; + uint8_t param_qosinfo; + uint8_t param_reserved; + struct ieee80211_wme_acparams params_acparams[WME_NUM_AC]; +} end_packed_struct; - /* FCS */ +/* Management Notification Frame */ +begin_packed_struct struct ieee80211_mnf +{ + uint8_t mnf_category; + uint8_t mnf_action; + uint8_t mnf_dialog; + uint8_t mnf_status; } end_packed_struct; -struct ieee80211_frame_cts +/* 802.11n Management Action Frames */ + +/* generic frame format */ + +begin_packed_struct struct ieee80211_action { - uint8_t i_fc[2]; - uint8_t i_dur[2]; - uint8_t i_ra[IEEE80211_ADDR_LEN]; + uint8_t ia_category; + uint8_t ia_action; +} end_packed_struct; - /* FCS */ +/* HT - recommended transmission channel width */ +begin_packed_struct struct ieee80211_action_ht_txchwidth +{ + struct ieee80211_action at_header; + uint8_t at_chwidth; } end_packed_struct; -struct ieee80211_frame_ack +/* HT - MIMO Power Save (NB: D2.04) */ + +begin_packed_struct struct ieee80211_action_ht_mimopowersave { - uint8_t i_fc[2]; - uint8_t i_dur[2]; - uint8_t i_ra[IEEE80211_ADDR_LEN]; + struct ieee80211_action am_header; + uint8_t am_control; +} end_packed_struct; - /* FCS */ +/* BA - ADDBA request */ +begin_packed_struct struct ieee80211_action_ba_addbarequest +{ + struct ieee80211_action rq_header; + uint8_t rq_dialogtoken; + uint16_t rq_baparamset; + uint16_t rq_batimeout; /* in TUs */ + uint16_t rq_baseqctl; } end_packed_struct; -struct ieee80211_frame_pspoll +/* BA - ADDBA response */ + +begin_packed_struct struct ieee80211_action_ba_addbaresponse { - uint8_t i_fc[2]; - uint8_t i_aid[2]; - uint8_t i_bssid[IEEE80211_ADDR_LEN]; - uint8_t i_ta[IEEE80211_ADDR_LEN]; + struct ieee80211_action rs_header; + uint8_t rs_dialogtoken; + uint16_t rs_statuscode; + uint16_t rs_baparamset; + uint16_t rs_batimeout; /* in TUs */ +} end_packed_struct; - /* FCS */ +/* BA - DELBA */ +begin_packed_struct struct ieee80211_action_ba_delba +{ + struct ieee80211_action dl_header; + uint16_t dl_baparamset; + uint16_t dl_reasoncode; } end_packed_struct; -struct ieee80211_frame_cfend -{ /* NB: also CF-End+CF-Ack */ - uint8_t i_fc[2]; - uint8_t i_dur[2]; /* should be zero */ - uint8_t i_ra[IEEE80211_ADDR_LEN]; - uint8_t i_bssid[IEEE80211_ADDR_LEN]; +/* BAR Starting Sequence Control */ + +begin_packed_struct struct ieee80211_ba_request +{ + uint16_t rq_barctl; + uint16_t rq_barseqctl; +} end_packed_struct; + +/* Control frames. */ + +begin_packed_struct struct ieee80211_frame_min +{ + uint8_t i_fc[2]; + uint8_t i_dur[2]; + uint8_t i_addr1[IEEE80211_ADDR_LEN]; + uint8_t i_addr2[IEEE80211_ADDR_LEN]; /* FCS */ +} end_packed_struct; + +begin_packed_struct struct ieee80211_frame_rts +{ + uint8_t i_fc[2]; + uint8_t i_dur[2]; + uint8_t i_ra[IEEE80211_ADDR_LEN]; + uint8_t i_ta[IEEE80211_ADDR_LEN]; + /* FCS */ } end_packed_struct; -/* Information elements (see Table 7-26). */ +begin_packed_struct struct ieee80211_frame_cts +{ + uint8_t i_fc[2]; + uint8_t i_dur[2]; + uint8_t i_ra[IEEE80211_ADDR_LEN]; -enum + /* FCS */ +} end_packed_struct; + +begin_packed_struct struct ieee80211_frame_ack { - IEEE80211_ELEMID_SSID = 0, - IEEE80211_ELEMID_RATES = 1, - IEEE80211_ELEMID_FHPARMS = 2, - IEEE80211_ELEMID_DSPARMS = 3, - IEEE80211_ELEMID_CFPARMS = 4, - IEEE80211_ELEMID_TIM = 5, - IEEE80211_ELEMID_IBSSPARMS = 6, - IEEE80211_ELEMID_COUNTRY = 7, - IEEE80211_ELEMID_QBSS_LOAD = 11, - IEEE80211_ELEMID_EDCAPARMS = 12, - IEEE80211_ELEMID_CHALLENGE = 16, + uint8_t i_fc[2]; + uint8_t i_dur[2]; + uint8_t i_ra[IEEE80211_ADDR_LEN]; - /* 17-31 reserved for challenge text extension */ + /* FCS */ +} end_packed_struct; - IEEE80211_ELEMID_ERP = 42, - IEEE80211_ELEMID_HTCAPS = 45, /* 11n */ - IEEE80211_ELEMID_QOS_CAP = 46, - IEEE80211_ELEMID_RSN = 48, - IEEE80211_ELEMID_XRATES = 50, - IEEE80211_ELEMID_TIE = 56, /* 11r */ - IEEE80211_ELEMID_HTOP = 61, /* 11n */ - IEEE80211_ELEMID_MMIE = 76, /* 11w */ - IEEE80211_ELEMID_TPC = 150, - IEEE80211_ELEMID_CCKM = 156, - IEEE80211_ELEMID_VENDOR = 221 /* vendor private */ -}; +begin_packed_struct struct ieee80211_frame_pspoll +{ + uint8_t i_fc[2]; + uint8_t i_aid[2]; + uint8_t i_bssid[IEEE80211_ADDR_LEN]; + uint8_t i_ta[IEEE80211_ADDR_LEN]; -/* Action field category values (see Table 7-24). */ + /* FCS */ +} end_packed_struct; -enum +begin_packed_struct struct ieee80211_frame_cfend /* NB: also CF-End+CF-Ack */ { - IEEE80211_CATEG_SPECTRUM = 0, - IEEE80211_CATEG_QOS = 1, - IEEE80211_CATEG_DLS = 2, - IEEE80211_CATEG_BA = 3, - IEEE80211_CATEG_HT = 7, /* 11n */ - IEEE80211_CATEG_SA_QUERY = 8 /* 11w */ -}; + uint8_t i_fc[2]; + uint8_t i_dur[2]; /* should be zero */ + uint8_t i_ra[IEEE80211_ADDR_LEN]; + uint8_t i_bssid[IEEE80211_ADDR_LEN]; -/* EDCA Access Categories. */ + /* FCS */ +} end_packed_struct; -enum ieee80211_edca_ac +begin_packed_struct struct ieee80211_frame_bar { - EDCA_AC_BK = 1, /* Background */ - EDCA_AC_BE = 0, /* Best Effort */ - EDCA_AC_VI = 2, /* Video */ - EDCA_AC_VO = 3 /* Voice */ -}; + uint8_t i_fc[2]; + uint8_t i_dur[2]; + uint8_t i_ra[IEEE80211_ADDR_LEN]; + uint8_t i_ta[IEEE80211_ADDR_LEN]; + uint16_t i_ctl; + uint16_t i_seq; -/* Authentication Transaction Sequence Number field (see 7.3.1.2). */ + /* FCS */ +} end_packed_struct; -enum +/* 802.11i/WPA information element (maximally sized). */ + +begin_packed_struct struct ieee80211_ie_wpa { - IEEE80211_AUTH_OPEN_REQUEST = 1, - IEEE80211_AUTH_OPEN_RESPONSE = 2 -}; + uint8_t wpa_id; /* IEEE80211_ELEMID_VENDOR */ + uint8_t wpa_len; /* length in bytes */ + uint8_t wpa_oui[3]; /* 0x00, 0x50, 0xf2 */ + uint8_t wpa_type; /* OUI type */ + uint16_t wpa_version; /* spec revision */ + uint32_t wpa_mcipher[1]; /* multicast/group key cipher */ + uint16_t wpa_uciphercnt; /* # pairwise key ciphers */ + uint32_t wpa_uciphers[8]; /* ciphers */ + uint16_t wpa_authselcnt; /* authentication selector cnt */ + uint32_t wpa_authsels[8]; /* selectors */ + uint16_t wpa_caps; /* 802.11i capabilities */ + uint16_t wpa_pmkidcnt; /* 802.11i pmkid count */ + uint16_t wpa_pmkids[8]; /* 802.11i pmkids */ +} end_packed_struct; -enum +/* 802.11n HT Capability IE + * NB: these reflect D1.10 + */ + +begin_packed_struct struct ieee80211_ie_htcap { - IEEE80211_AUTH_SHARED_REQUEST = 1, - IEEE80211_AUTH_SHARED_CHALLENGE = 2, - IEEE80211_AUTH_SHARED_RESPONSE = 3, - IEEE80211_AUTH_SHARED_PASS = 4 -}; + uint8_t hc_id; /* element ID */ + uint8_t hc_len; /* length in bytes */ + uint16_t hc_cap; /* HT caps (see below) */ + uint8_t hc_param; /* HT params (see below) */ + uint8_t hc_mcsset[16]; /* supported MCS set */ + uint16_t hc_extcap; /* extended HT capabilities */ + uint32_t hc_txbf; /* txbf capabilities */ + uint8_t hc_antenna; /* antenna capabilities */ +} end_packed_struct; -/* Reason codes (see Table 22). */ +/* 802.11n HT Information IE */ -enum +begin_packed_struct struct ieee80211_ie_htinfo { - IEEE80211_REASON_UNSPECIFIED = 1, - IEEE80211_REASON_AUTH_EXPIRE = 2, - IEEE80211_REASON_AUTH_LEAVE = 3, - IEEE80211_REASON_ASSOC_EXPIRE = 4, - IEEE80211_REASON_ASSOC_TOOMANY = 5, - IEEE80211_REASON_NOT_AUTHED = 6, - IEEE80211_REASON_NOT_ASSOCED = 7, - IEEE80211_REASON_ASSOC_LEAVE = 8, - IEEE80211_REASON_ASSOC_NOT_AUTHED = 9, - - /* XXX the following two reason codes are not correct */ - - IEEE80211_REASON_RSN_REQUIRED = 11, - IEEE80211_REASON_RSN_INCONSISTENT = 12, - - IEEE80211_REASON_IE_INVALID = 13, - IEEE80211_REASON_MIC_FAILURE = 14, - IEEE80211_REASON_4WAY_TIMEOUT = 15, - IEEE80211_REASON_GROUP_TIMEOUT = 16, - IEEE80211_REASON_RSN_DIFFERENT_IE = 17, - IEEE80211_REASON_BAD_GROUP_CIPHER = 18, - IEEE80211_REASON_BAD_PAIRWISE_CIPHER = 19, - IEEE80211_REASON_BAD_AKMP = 20, - IEEE80211_REASON_RSN_IE_VER_UNSUP = 21, - IEEE80211_REASON_RSN_IE_BAD_CAP = 22, - - IEEE80211_REASON_CIPHER_REJ_POLICY = 24, - - IEEE80211_REASON_SETUP_REQUIRED = 38, - IEEE80211_REASON_TIMEOUT = 39 -}; + uint8_t hi_id; /* element ID */ + uint8_t hi_len; /* length in bytes */ + uint8_t hi_ctrlchannel; /* primary channel */ + uint8_t hi_byte1; /* ht ie byte 1 */ + uint8_t hi_byte2; /* ht ie byte 2 */ + uint8_t hi_byte3; /* ht ie byte 3 */ + uint16_t hi_byte45; /* ht ie bytes 4+5 */ + uint8_t hi_basicmcsset[16]; /* basic MCS set */ +} end_packed_struct; -/* Status codes (see Table 23). */ +/* VHT MCS information. + * + rx_highest/tx_highest: optional; maximum long GI VHT PPDU + * data rate. 1Mbit/sec units. + * + rx_mcs_map/tx_mcs_map: bitmap of per-stream supported MCS; + * 2 bits each. + */ -enum +begin_packed_struct struct ieee80211_vht_mcs_info { - IEEE80211_STATUS_SUCCESS = 0, - IEEE80211_STATUS_UNSPECIFIED = 1, - IEEE80211_STATUS_CAPINFO = 10, - IEEE80211_STATUS_NOT_ASSOCED = 11, - IEEE80211_STATUS_OTHER = 12, - IEEE80211_STATUS_ALG = 13, - IEEE80211_STATUS_SEQUENCE = 14, - IEEE80211_STATUS_CHALLENGE = 15, - IEEE80211_STATUS_TIMEOUT = 16, - IEEE80211_STATUS_TOOMANY = 17, - IEEE80211_STATUS_BASIC_RATE = 18, - IEEE80211_STATUS_SP_REQUIRED = 19, - IEEE80211_STATUS_PBCC_REQUIRED = 20, - IEEE80211_STATUS_CA_REQUIRED = 21, - IEEE80211_STATUS_TOO_MANY_STATIONS = 22, - IEEE80211_STATUS_RATES = 23, - IEEE80211_STATUS_SHORTSLOT_REQUIRED = 25, - IEEE80211_STATUS_DSSSOFDM_REQUIRED = 26, - - IEEE80211_STATUS_TRY_AGAIN_LATER = 30, - IEEE80211_STATUS_MFP_POLICY = 31, - - IEEE80211_STATUS_REFUSED = 37, - IEEE80211_STATUS_INVALID_PARAM = 38, - - IEEE80211_STATUS_IE_INVALID = 40, - IEEE80211_STATUS_BAD_GROUP_CIPHER = 41, - IEEE80211_STATUS_BAD_PAIRWISE_CIPHER = 42, - IEEE80211_STATUS_BAD_AKMP = 43, - IEEE80211_STATUS_RSN_IE_VER_UNSUP = 44, - - IEEE80211_STATUS_CIPHER_REJ_POLICY = 46, -}; + uint16_t rx_mcs_map; + uint16_t rx_highest; + uint16_t tx_mcs_map; + uint16_t tx_highest; +} end_packed_struct; + +/* VHT capabilities element: 802.11ac-2013 8.4.2.160 */ -struct ieee80211_eapol_key +begin_packed_struct struct ieee80211_ie_vhtcap { - uint8_t version; + uint8_t ie; + uint8_t len; + uint32_t vht_cap_info; + struct ieee80211_vht_mcs_info supp_mcs; +} end_packed_struct; -#define EAPOL_VERSION 1 +/* VHT operation IE - 802.11ac-2013 8.4.2.161 */ - uint8_t type; +begin_packed_struct struct ieee80211_ie_vht_operation +{ + uint8_t ie; + uint8_t len; + uint8_t chan_width; + uint8_t center_freq_seg1_idx; + uint8_t center_freq_seg2_idx; + uint16_t basic_mcs_set; +} end_packed_struct; -/* IEEE Std 802.1X-2004, 7.5.4 (only type EAPOL-Key is used here) */ +/* VHT Transmit Power Envelope element - 802.11ac-2013 8.4.2.164 + * + * This defines the maximum transmit power for various bandwidths. + */ + +begin_packed_struct struct ieee80211_ie_vht_txpwrenv +{ + uint8_t ie; + uint8_t len; + uint8_t tx_info; + int8_t tx_elem[0]; /* TX power elements, 1/2 dB, signed */ +} end_packed_struct; + +begin_packed_struct struct ieee80211_tim_ie +{ + uint8_t tim_ie; /* IEEE80211_ELEMID_TIM */ + uint8_t tim_len; + uint8_t tim_count; /* DTIM count */ + uint8_t tim_period; /* DTIM period */ + uint8_t tim_bitctl; /* bitmap control */ + uint8_t tim_bitmap[1]; /* variable-length bitmap */ +} end_packed_struct; -#define EAP_PACKET 0 -#define EAPOL_START 1 -#define EAPOL_LOGOFF 2 -#define EAPOL_KEY 3 -#define EAPOL_ASF_ALERT 4 +begin_packed_struct struct ieee80211_country_subbands +{ + uint8_t schan; /* starting channel */ + uint8_t nchan; /* number channels */ + uint8_t maxtxpwr; /* tx power cap */ +} end_packed_struct; /* sub bands (NB: var size) */ - uint8_t len[2]; - uint8_t desc; +begin_packed_struct struct ieee80211_country_ie +{ + uint8_t ie; /* IEEE80211_ELEMID_COUNTRY */ + uint8_t len; + uint8_t cc[3]; /* ISO CC+(I)ndoor/(O)utdoor */ + struct ieee80211_country_subbands band[1]; +} end_packed_struct; -/* IEEE Std 802.1X-2004, 7.6.1 */ +begin_packed_struct struct ieee80211_bss_load_ie +{ + uint8_t ie; + uint8_t len; + uint16_t sta_count; /* station count */ + uint8_t chan_load; /* channel utilization */ + uint8_t aac; /* available admission capacity */ +} end_packed_struct; -#define EAPOL_KEY_DESC_RC4 1 /* Deprecated */ -#define EAPOL_KEY_DESC_IEEE80211 2 -#define EAPOL_KEY_DESC_WPA 254 /* Non-standard WPA */ +begin_packed_struct struct ieee80211_ap_chan_report_ie +{ + uint8_t ie; + uint8_t len; + uint8_t i_class; /* operating class */ - uint8_t info[2]; + /* Annex E, E.1 Country information and operating classes */ -#define EAPOL_KEY_VERSION_MASK 0x7 -#define EAPOL_KEY_DESC_V1 1 -#define EAPOL_KEY_DESC_V2 2 -#define EAPOL_KEY_DESC_V3 3 /* 11r */ -#define EAPOL_KEY_PAIRWISE (1 << 3) -#define EAPOL_KEY_INSTALL (1 << 6) /* I */ -#define EAPOL_KEY_KEYACK (1 << 7) /* A */ -#define EAPOL_KEY_KEYMIC (1 << 8) /* M */ -#define EAPOL_KEY_SECURE (1 << 9) /* S */ -#define EAPOL_KEY_ERROR (1 << 10) -#define EAPOL_KEY_REQUEST (1 << 11) -#define EAPOL_KEY_ENCRYPTED (1 << 12) -#define EAPOL_KEY_SMK (1 << 13) + uint8_t chan_list[0]; +} end_packed_struct; -/* WPA compatibility */ +begin_packed_struct struct ieee80211_extcap_ie +{ + uint8_t ie; + uint8_t len; +} end_packed_struct; -#define EAPOL_KEY_WPA_KID_MASK 0x3 -#define EAPOL_KEY_WPA_KID_SHIFT 4 -#define EAPOL_KEY_WPA_TX EAPOL_KEY_INSTALL +/* 802.11h Quiet Time Element. */ - uint8_t keylen[2]; - uint8_t replaycnt[8]; - uint8_t nonce[EAPOL_KEY_NONCE_LEN]; - uint8_t iv[EAPOL_KEY_IV_LEN]; - uint8_t rsc[8]; - uint8_t reserved[8]; - uint8_t mic[EAPOL_KEY_MIC_LEN]; - uint8_t paylen[2]; +begin_packed_struct struct ieee80211_quiet_ie +{ + uint8_t quiet_ie; /* IEEE80211_ELEMID_QUIET */ + uint8_t len; + uint8_t tbttcount; /* quiet start */ + uint8_t period; /* beacon intervals between quiets */ + uint16_t duration; /* TUs of each quiet */ + uint16_t offset; /* TUs of from TBTT of quiet start */ } end_packed_struct; -/* Pairwise Transient Key (see 8.5.1.2) */ +/* 802.11h Channel Switch Announcement (CSA). */ -struct ieee80211_ptk +begin_packed_struct struct ieee80211_csa_ie { - uint8_t kck[16]; /* Key Confirmation Key */ - uint8_t kek[16]; /* Key Encryption Key */ - uint8_t tk[32]; /* Temporal Key */ + uint8_t csa_ie; /* IEEE80211_ELEMID_CHANSWITCHANN */ + uint8_t csa_len; + uint8_t csa_mode; /* Channel Switch Mode */ + uint8_t csa_newchan; /* New Channel Number */ + uint8_t csa_count; /* Channel Switch Count */ } end_packed_struct; -/* Key Data Encapsulation (see Table 62) */ +/* 802.11 frame duration definitions. */ -enum +begin_packed_struct struct ieee80211_duration { - IEEE80211_KDE_GTK = 1, - IEEE80211_KDE_MACADDR = 3, - IEEE80211_KDE_PMKID = 4, - IEEE80211_KDE_SMK = 5, - IEEE80211_KDE_NONCE = 6, - IEEE80211_KDE_LIFETIME = 7, - IEEE80211_KDE_ERROR = 8, - IEEE80211_KDE_IGTK = 9 /* 11w */ -}; + uint16_t d_rts_dur; + uint16_t d_data_dur; + uint16_t d_plcp_len; + uint8_t d_residue; /* unused octets in time slot */ +} end_packed_struct; /**************************************************************************** * Inline Functions @@ -857,21 +1609,24 @@ static inline int ieee80211_has_addr4(FAR const struct ieee80211_frame *wh) return (wh->i_fc[1] & IEEE80211_FC1_DIR_MASK) == IEEE80211_FC1_DIR_DSTODS; } -static inline int ieee80211_has_qos(FAR const struct ieee80211_frame *wh) +static inline int +ieee80211_has_qos(FAR const struct ieee80211_frame *wh) { return (wh->i_fc[0] & (IEEE80211_FC0_TYPE_MASK | IEEE80211_FC0_SUBTYPE_QOS)) == (IEEE80211_FC0_TYPE_DATA | IEEE80211_FC0_SUBTYPE_QOS); } -static inline int ieee80211_has_htc(FAR const struct ieee80211_frame *wh) +static inline int +ieee80211_has_htc(FAR const struct ieee80211_frame *wh) { return (wh->i_fc[1] & IEEE80211_FC1_ORDER) && (ieee80211_has_qos(wh) || (wh->i_fc[0] & IEEE80211_FC0_TYPE_MASK) == IEEE80211_FC0_TYPE_MGT); } -static inline uint16_t ieee80211_get_qos(FAR const struct ieee80211_frame *wh) +static inline uint16_t +ieee80211_get_qos(FAR const struct ieee80211_frame *wh) { FAR const uint8_t *frm; diff --git a/include/nuttx/wireless/wireless.h b/include/nuttx/wireless/wireless.h index 7b240db918416..ed4f5297dd07a 100644 --- a/include/nuttx/wireless/wireless.h +++ b/include/nuttx/wireless/wireless.h @@ -144,6 +144,15 @@ #define SIOCSIWCOUNTRY _WLIOC(0x0037) /* Country code extension */ +#define WL_IS80211POINTERCMD(cmd) ((cmd) == SIOCGIWSCAN || \ + (cmd) == SIOCSIWSCAN || \ + (cmd) == SIOCSIWCOUNTRY || \ + (cmd) == SIOCGIWRANGE || \ + (cmd) == SIOCSIWENCODEEXT || \ + (cmd) == SIOCGIWENCODEEXT || \ + (cmd) == SIOCGIWESSID || \ + (cmd) == SIOCSIWESSID) + /* Device-specific network IOCTL commands *******************************************/ #define WL_NETFIRST 0x0000 /* First network command */ diff --git a/include/nuttx/wqueue.h b/include/nuttx/wqueue.h index 659f1b8596aa6..7ab1e81e05173 100644 --- a/include/nuttx/wqueue.h +++ b/include/nuttx/wqueue.h @@ -292,6 +292,10 @@ struct work_notifier_s worker_t worker; /* The worker function to schedule */ }; +/* This is the callback type used by work_foreach() */ + +typedef CODE void (*work_foreach_t)(int tid, FAR void *arg); + /**************************************************************************** * Public Data ****************************************************************************/ @@ -381,6 +385,25 @@ int work_queue(int qid, FAR struct work_s *work, worker_t worker, int work_cancel(int qid, FAR struct work_s *work); +/**************************************************************************** + * Name: work_foreach + * + * Description: + * Enumerate over each work thread and provide the tid of each task to a + * user callback functions. + * + * Input Parameters: + * qid - The work queue ID + * handler - The function to be called with the pid of each task + * arg - The function callback + * + * Returned Value: + * None + * + ****************************************************************************/ + +void work_foreach(int qid, work_foreach_t handler, FAR void *arg); + /**************************************************************************** * Name: work_available * diff --git a/include/spawn.h b/include/spawn.h index 83e32202a2905..dbecd88f12ec0 100644 --- a/include/spawn.h +++ b/include/spawn.h @@ -54,6 +54,13 @@ #define POSIX_SPAWN_SETSIGMASK (1 << 5) /* 1: Set sigmask */ #define POSIX_SPAWN_SETSID (1 << 7) /* 1: Create the new session(glibc specific) */ +/* NOTE: NuttX provides only one implementation: If + * CONFIG_LIBC_ENVPATH is defined, then only posix_spawnp() behavior + * is supported; otherwise, only posix_spawn behavior is supported. + */ + +#define posix_spawnp posix_spawn + /**************************************************************************** * Type Definitions ****************************************************************************/ @@ -129,8 +136,6 @@ int posix_spawn(FAR pid_t *pid, FAR const char *path, FAR const posix_spawn_file_actions_t *file_actions, FAR const posix_spawnattr_t *attr, FAR char * const argv[], FAR char * const envp[]); -#define posix_spawnp(pid,path,file_actions,attr,argv,envp) \ - posix_spawn(pid,path,file_actions,attr,argv,envp) #ifndef CONFIG_BUILD_KERNEL /* Non-standard task_spawn interface. This function uses the same diff --git a/include/stdlib.h b/include/stdlib.h index 745f4286b5e03..534dcb7db3187 100644 --- a/include/stdlib.h +++ b/include/stdlib.h @@ -62,7 +62,11 @@ * function call. However, get_environ_ptr() can be used in its place. */ -#define environ get_environ_ptr() +#ifdef CONFIG_DISABLE_ENVIRON +# define environ NULL +#else +# define environ get_environ_ptr() +#endif #if defined(CONFIG_FS_LARGEFILE) && defined(CONFIG_HAVE_LONG_LONG) # define mkstemp64 mkstemp diff --git a/include/strings.h b/include/strings.h index f0c216db3251f..9b763ccc2e9e6 100644 --- a/include/strings.h +++ b/include/strings.h @@ -46,11 +46,11 @@ #endif #ifndef bcopy /* See mm/README.txt */ -#define bcopy(b1,b2,len) (void)memmove(b2,b1,len) +#define bcopy(b1,b2,len) memmove(b2,b1,len) #endif #ifndef bzero /* See mm/README.txt */ -#define bzero(s,n) (void)memset(s,0,n) +#define bzero(s,n) memset(s,0,n) #endif #define strcasecmp_l(s1, s2, l) strcasecmp(s1, s2) diff --git a/include/sys/boardctl.h b/include/sys/boardctl.h index 7f9e07ae1c0d1..14e1526d6708f 100644 --- a/include/sys/boardctl.h +++ b/include/sys/boardctl.h @@ -180,6 +180,12 @@ * 1=locked. * CONFIGURATION: CONFIG_BOARDCTL_TESTSET * DEPENDENCIES: Architecture-specific logic provides up_testset() + * + * CMD: BOARDIOC_RESET_CAUSE + * DESCRIPTION: Get the cause of last-time board reset + * ARG: A pointer to an instance of struct boardioc_reset_cause_s + * CONFIGURATION: CONFIG_BOARDCTL_RESET_CAUSE + * DEPENDENCIES: Board logic must provide the board_reset_cause() interface. */ #define BOARDIOC_INIT _BOARDIOC(0x0001) @@ -202,6 +208,7 @@ #define BOARDIOC_UNIQUEKEY _BOARDIOC(0x0012) #define BOARDIOC_SWITCH_BOOT _BOARDIOC(0x0013) #define BOARDIOC_BOOT_IMAGE _BOARDIOC(0x0014) +#define BOARDIOC_RESET_CAUSE _BOARDIOC(0x0015) /* If CONFIG_BOARDCTL_IOCTL=y, then board-specific commands will be support. * In this case, all commands not recognized by boardctl() will be forwarded @@ -210,7 +217,7 @@ * User defined board commands may begin with this value: */ -#define BOARDIOC_USER _BOARDIOC(0x0015) +#define BOARDIOC_USER _BOARDIOC(0x0016) /**************************************************************************** * Public Type Definitions @@ -403,6 +410,39 @@ struct boardioc_boot_info_s }; #endif +#ifdef CONFIG_BOARDCTL_RESET_CAUSE +/* Describes the reason of last reset */ + +enum boardioc_reset_cause_e +{ + BOARDIOC_RESETCAUSE_NONE = 0, + BOARDIOC_RESETCAUSE_SYS_CHIPPOR, /* chip power on */ + BOARDIOC_RESETCAUSE_SYS_RWDT, /* RTC watchdog system reset */ + BOARDIOC_RESETCAUSE_SYS_BOR, /* brown-out system reset */ + BOARDIOC_RESETCAUSE_CORE_SOFT, /* software core reset */ + BOARDIOC_RESETCAUSE_CORE_DPSP, /* deep-sleep core reset */ + BOARDIOC_RESETCAUSE_CORE_MWDT, /* main watchdog core reset */ + BOARDIOC_RESETCAUSE_CORE_RWDT, /* RTC watchdog core reset */ + BOARDIOC_RESETCAUSE_CPU_MWDT, /* main watchdog cpu reset */ + BOARDIOC_RESETCAUSE_CPU_SOFT, /* software cpu reset */ + BOARDIOC_RESETCAUSE_CPU_RWDT /* RTC watchdog cpu reset */ +}; + +enum boardioc_softreset_subreason_e +{ + BOARDIOC_SOFTRESETCAUSE_USER_REBOOT = 0, + BOARDIOC_SOFTRESETCAUSE_PANIC, + BOARDIOC_SOFTRESETCAUSE_ASSERT +}; + +struct boardioc_reset_cause_s +{ + enum boardioc_reset_cause_e cause; /* The reason of last reset */ + uint32_t flag; /* watchdog number when watchdog reset, + * or soft-reset subreason */ +}; +#endif + /**************************************************************************** * Public Data ****************************************************************************/ diff --git a/include/sys/poll.h b/include/sys/poll.h index 015874fb1c212..4562ac89b5247 100644 --- a/include/sys/poll.h +++ b/include/sys/poll.h @@ -91,11 +91,11 @@ typedef unsigned int nfds_t; /* In the standard poll() definition, the size of the event set is 'short'. - * Here we pick the smallest storage element that will contain all of the - * poll events. + * Here we pick the uint32_t type to be consistent with the linux to support + * EPOLLRDHUP, EPOLLWAKEUP, EPOLLONESHOT... */ -typedef uint8_t pollevent_t; +typedef uint32_t pollevent_t; /* This is the NuttX variant of the standard pollfd structure. The poll() * interfaces receive a variable length array of such structures. diff --git a/include/sys/syscall_lookup.h b/include/sys/syscall_lookup.h index abc0b7137e2d4..201ea50846ada 100644 --- a/include/sys/syscall_lookup.h +++ b/include/sys/syscall_lookup.h @@ -151,7 +151,7 @@ SYSCALL_LOOKUP(up_assert, 2) #endif #ifdef CONFIG_LIBC_EXECFUNCS SYSCALL_LOOKUP(posix_spawn, 6) - SYSCALL_LOOKUP(execv, 2) + SYSCALL_LOOKUP(execve, 3) #endif #endif @@ -353,6 +353,7 @@ SYSCALL_LOOKUP(futimens, 2) /* The following are defined only if environment variables are supported */ #ifndef CONFIG_DISABLE_ENVIRON + SYSCALL_LOOKUP(get_environ_ptr, 0) SYSCALL_LOOKUP(clearenv, 0) SYSCALL_LOOKUP(getenv, 1) SYSCALL_LOOKUP(putenv, 1) diff --git a/include/sys/uio.h b/include/sys/uio.h index 551cc5c26e00d..4555d5e044af8 100644 --- a/include/sys/uio.h +++ b/include/sys/uio.h @@ -156,6 +156,12 @@ ssize_t readv(int fildes, FAR const struct iovec *iov, int iovcnt); ssize_t writev(int fildes, FAR const struct iovec *iov, int iovcnt); +ssize_t preadv(int fildes, FAR const struct iovec *iov, int iovcnt, + off_t offset); + +ssize_t pwritev(int fildes, FAR const struct iovec *iov, int iovcnt, + off_t offset); + #undef EXTERN #if defined(__cplusplus) } diff --git a/include/time.h b/include/time.h index 82900c05d5072..ac8c3d94bb548 100644 --- a/include/time.h +++ b/include/time.h @@ -200,6 +200,8 @@ FAR struct tm *localtime_r(FAR const time_t *timep, FAR struct tm *result); size_t strftime(FAR char *s, size_t max, FAR const char *format, FAR const struct tm *tm) strftimelike(3); +FAR char *strptime(FAR const char *s, FAR const char *format, + FAR struct tm *tm); FAR char *asctime(FAR const struct tm *tp); FAR char *asctime_r(FAR const struct tm *tp, FAR char *buf); diff --git a/include/unistd.h b/include/unistd.h index d2fd98827b26a..e754e0a804df2 100644 --- a/include/unistd.h +++ b/include/unistd.h @@ -280,6 +280,17 @@ # define lockf64 lockf #endif +/* NOTE: NuttX provides only one implementation: If + * CONFIG_LIBC_ENVPATH is defined, then only execvp/execlp/execvpe behavior + * is supported; otherwise, only execv/execl/execve behavior is supported. + */ + +#ifdef CONFIG_LIBC_EXECFUNCS +# define execvp execv +# define execlp execl +# define execvpe execve +#endif + /**************************************************************************** * Public Data ****************************************************************************/ @@ -368,7 +379,10 @@ int lchown(FAR const char *path, uid_t owner, gid_t group); #ifdef CONFIG_LIBC_EXECFUNCS int execl(FAR const char *path, FAR const char *arg0, ...); +int execle(FAR const char *path, FAR const char *arg0, ...); int execv(FAR const char *path, FAR char * const argv[]); +int execve(FAR const char *path, FAR char *const argv[], + FAR char *const envp[]); #endif /* Byte operations */ diff --git a/libs/libc/fixedmath/lib_ubsqrt.c b/libs/libc/fixedmath/lib_ubsqrt.c index ed9dfdf8f9381..342da15283c70 100644 --- a/libs/libc/fixedmath/lib_ubsqrt.c +++ b/libs/libc/fixedmath/lib_ubsqrt.c @@ -55,7 +55,7 @@ ub16_t ub32sqrtub16(ub32_t a) xk = (uint64_t)1 << 63; } - do + while (xk) { uint64_t xk1 = (xk + n / xk) >> 1; @@ -66,7 +66,6 @@ ub16_t ub32sqrtub16(ub32_t a) xk = xk1; } - while (1); /* 'xk' now holds 'sqrt(n)' => 'sqrt(a * 2^32)' => 'sqrt(a) * 2^16', thus * 'xk' holds square root of 'a' in ub16_t format. @@ -101,7 +100,7 @@ ub8_t ub16sqrtub8(ub16_t a) xk = (uint32_t)1 << 31; } - do + while (xk) { uint32_t xk1 = (xk + n / xk) >> 1; @@ -112,7 +111,6 @@ ub8_t ub16sqrtub8(ub16_t a) xk = xk1; } - while (1); /* 'xk' now holds 'sqrt(n)' => 'sqrt(a * 2^16)' => 'sqrt(a) * 2^8', thus * 'xk' holds square root of 'a' in ub8_t format. diff --git a/libs/libc/libc.csv b/libs/libc/libc.csv index 5054e927c1b16..a746df93cb5a9 100644 --- a/libs/libc/libc.csv +++ b/libs/libc/libc.csv @@ -1,7 +1,7 @@ "__errno","errno.h","defined(CONFIG_BUILD_FLAT)","FAR int *" "__stack_chk_fail","ssp/ssp.h","defined(CONFIG_STACK_CANARIES)","void","void" -"_assert","assert.h","","void","FAR const char *","int" "_alert","debug.h","!defined(CONFIG_CPP_HAVE_VARARGS) && defined(CONFIG_DEBUG_ERROR)","void","FAR const char *","..." +"_assert","assert.h","","void","FAR const char *","int" "_err","debug.h","!defined(CONFIG_CPP_HAVE_VARARGS) && defined(CONFIG_DEBUG_ERROR)","void","FAR const char *","..." "_info","debug.h","!defined(CONFIG_CPP_HAVE_VARARGS) && defined(CONFIG_DEBUG_INFO)","void","FAR const char *","..." "_warn","debug.h","!defined(CONFIG_CPP_HAVE_VARARGS) && defined(CONFIG_DEBUG_WARN)","void","FAR const char *","..." @@ -91,21 +91,18 @@ "inet_ntoa","arpa/inet.h","defined(CONFIG_NET_IPv4)","FAR char *","struct in_addr" "inet_ntop","arpa/inet.h","","FAR const char","int","FAR const void *","FAR char *","socklen_t" "inet_pton","arpa/inet.h","","int","int","FAR const char *","FAR void *" -"isspace","ctype.h","","int","int" -"isascii","ctype.h","","int","int" -"isprint","ctype.h","","int","int" -"isgraph","ctype.h","","int","int" -"iscntrl","ctype.h","","int","int" -"islower","ctype.h","","int","int" -"isupper","ctype.h","","int","int" +"isalnum","ctype.h","","int","int" "isalpha","ctype.h","","int","int" +"isascii","ctype.h","","int","int" "isblank","ctype.h","","int","int" +"iscntrl","ctype.h","","int","int" "isdigit","ctype.h","","int","int" -"isalnum","ctype.h","","int","int" +"isgraph","ctype.h","","int","int" +"islower","ctype.h","","int","int" +"isprint","ctype.h","","int","int" "ispunct","ctype.h","","int","int" -"isxdigit","ctype.h","","int","int" -"toupper","ctype.h","","int","int" -"tolower","ctype.h","","int","int" +"isspace","ctype.h","","int","int" +"isupper","ctype.h","","int","int" "iswalnum","wctype.h","defined(CONFIG_LIBC_WCHAR)","int","wint_t" "iswalpha","wctype.h","defined(CONFIG_LIBC_WCHAR)","int","wint_t" "iswblank","wctype.h","defined(CONFIG_LIBC_WCHAR)","int","wint_t" @@ -119,6 +116,7 @@ "iswspace","wctype.h","defined(CONFIG_LIBC_WCHAR)","int","wint_t" "iswupper","wctype.h","defined(CONFIG_LIBC_WCHAR)","int","wint_t" "iswxdigit","wctype.h","defined(CONFIG_LIBC_WCHAR)","int","wint_t" +"isxdigit","ctype.h","","int","int" "labs","stdlib.h","","long int","long int" "lib_dumpbuffer","debug.h","","void","FAR const char *","FAR const uint8_t *","unsigned int" "lio_listio","aio.h","defined(CONFIG_FS_AIO)","int","int","FAR struct aiocb * const []|FAR struct aiocb * const *","int","FAR struct sigevent *" @@ -149,6 +147,7 @@ "ntohs","arpa/inet.h","","uint16_t","uint16_t" "perror","stdio.h","defined(CONFIG_FILE_STREAM)","void","FAR const char *" "pipe","unistd.h","defined(CONFIG_PIPES) && CONFIG_DEV_PIPE_SIZE > 0","int","int [2]|FAR int *" +"preadv","sys/uio.h","","ssize_t","int","FAR const struct iovec *","int","off_t" "printf","stdio.h","","int","FAR const IPTR char *","..." "pthread_attr_destroy","pthread.h","!defined(CONFIG_DISABLE_PTHREAD)","int","FAR pthread_attr_t *" "pthread_attr_getinheritsched","pthread.h","!defined(CONFIG_DISABLE_PTHREAD)","int","FAR const pthread_attr_t *","FAR int *" @@ -185,6 +184,7 @@ "pthread_setname_np","pthread.h","!defined(CONFIG_DISABLE_PTHREAD)","int","pthread_t","const char *" "pthread_yield","pthread.h","!defined(CONFIG_DISABLE_PTHREAD)","void" "puts","stdio.h","defined(CONFIG_FILE_STREAM)","int","FAR const IPTR char *" +"pwritev","sys/uio.h","","ssize_t","int","FAR const struct iovec *","int","off_t" "qsort","stdlib.h","","void","FAR void *","size_t","size_t","int(*)(FAR const void *","FAR const void *)" "rand","stdlib.h","","int" "readdir_r","dirent.h","","int","FAR DIR *","FAR struct dirent *","FAR struct dirent **" @@ -257,6 +257,8 @@ "tcsetattr","termios.h","defined(CONFIG_SERIAL_TERMIOS)","int","int","int","FAR const struct termios *" "telldir","dirent.h","","off_t","FAR DIR *" "time","time.h","","time_t","FAR time_t *" +"tolower","ctype.h","","int","int" +"toupper","ctype.h","","int","int" "towlower","wchar.h","defined(CONFIG_LIBC_WCHAR)","wint_t","wint_t" "towupper","wchar.h","defined(CONFIG_LIBC_WCHAR)","wint_t","wint_t" "truncate","unistd.h","!defined(CONFIG_DISABLE_MOUNTPOINT)","FAR const char *","off_t" diff --git a/libs/libc/machine/arch_atomic.c b/libs/libc/machine/arch_atomic.c index b318e981a7cb8..146b998fba597 100644 --- a/libs/libc/machine/arch_atomic.c +++ b/libs/libc/machine/arch_atomic.c @@ -34,59 +34,60 @@ #define STORE(n, type) \ \ - void __atomic_store_ ## n (volatile void *ptr, \ + void __atomic_store_ ## n (FAR volatile void *ptr, \ type value, \ int memorder) \ { \ irqstate_t irqstate = spin_lock_irqsave(NULL); \ \ - *(type *)ptr = value; \ + *(FAR type *)ptr = value; \ \ spin_unlock_irqrestore(NULL, irqstate); \ } #define LOAD(n, type) \ \ - type __atomic_load_ ## n (const volatile void *ptr, \ + type __atomic_load_ ## n (FAR const volatile void *ptr, \ int memorder) \ { \ irqstate_t irqstate = spin_lock_irqsave(NULL); \ \ - type ret = *(type *)ptr; \ + type ret = *(FAR type *)ptr; \ \ spin_unlock_irqrestore(NULL, irqstate); \ - return ret; \ + return ret; \ } #define EXCHANGE(n, type) \ \ - type __atomic_exchange_ ## n (volatile void *ptr, \ + type __atomic_exchange_ ## n (FAR volatile void *ptr, \ type value, \ int memorder) \ { \ irqstate_t irqstate = spin_lock_irqsave(NULL); \ - type *tmp = (type *)ptr; \ + FAR type *tmp = (FAR type *)ptr; \ \ type ret = *tmp; \ *tmp = value; \ \ spin_unlock_irqrestore(NULL, irqstate); \ - return ret; \ + return ret; \ } #define CMP_EXCHANGE(n, type) \ \ - bool __atomic_compare_exchange_ ## n (volatile void *mem,\ - void *expect, \ - type desired, \ - bool weak, \ - int success, \ - int failure) \ + bool __atomic_compare_exchange_ ## n ( \ + FAR volatile void *mem, \ + FAR void *expect, \ + type desired, \ + bool weak, \ + int success, \ + int failure) \ { \ bool ret = false; \ irqstate_t irqstate = spin_lock_irqsave(NULL); \ - type *tmpmem = (type *)mem; \ - type *tmpexp = (type *)expect; \ + FAR type *tmpmem = (FAR type *)mem; \ + FAR type *tmpexp = (FAR type *)expect; \ \ if (*tmpmem == *tmpexp) \ { \ @@ -99,17 +100,17 @@ } \ \ spin_unlock_irqrestore(NULL, irqstate); \ - return ret; \ + return ret; \ } #define FETCH_ADD(n, type) \ \ - type __atomic_fetch_add_ ## n (volatile void *ptr, \ + type __atomic_fetch_add_ ## n (FAR volatile void *ptr, \ type value, \ int memorder) \ { \ irqstate_t irqstate = spin_lock_irqsave(NULL); \ - type *tmp = (type *)ptr; \ + FAR type *tmp = (FAR type *)ptr; \ type ret = *tmp; \ \ *tmp = *tmp + value; \ @@ -120,12 +121,12 @@ #define FETCH_SUB(n, type) \ \ - type __atomic_fetch_sub_ ## n (volatile void *ptr, \ + type __atomic_fetch_sub_ ## n (FAR volatile void *ptr, \ type value, \ int memorder) \ { \ irqstate_t irqstate = spin_lock_irqsave(NULL); \ - type *tmp = (type *)ptr; \ + FAR type *tmp = (FAR type *)ptr; \ type ret = *tmp; \ \ *tmp = *tmp - value; \ @@ -136,12 +137,12 @@ #define FETCH_AND(n, type) \ \ - type __atomic_fetch_and_ ## n (volatile void *ptr, \ + type __atomic_fetch_and_ ## n (FAR volatile void *ptr, \ type value, \ int memorder) \ { \ irqstate_t irqstate = spin_lock_irqsave(NULL); \ - type *tmp = (type *)ptr; \ + FAR type *tmp = (FAR type *)ptr; \ type ret = *tmp; \ \ *tmp = *tmp & value; \ @@ -152,12 +153,12 @@ #define FETCH_OR(n, type) \ \ - type __atomic_fetch_or_ ## n (volatile void *ptr, \ + type __atomic_fetch_or_ ## n (FAR volatile void *ptr, \ type value, \ int memorder) \ { \ irqstate_t irqstate = spin_lock_irqsave(NULL); \ - type *tmp = (type *)ptr; \ + FAR type *tmp = (FAR type *)ptr; \ type ret = *tmp; \ \ *tmp = *tmp | value; \ @@ -168,12 +169,12 @@ #define FETCH_XOR(n, type) \ \ - type __atomic_fetch_xor_ ## n (volatile void *ptr, \ + type __atomic_fetch_xor_ ## n (FAR volatile void *ptr, \ type value, \ int memorder) \ { \ irqstate_t irqstate = spin_lock_irqsave(NULL); \ - type *tmp = (type *)ptr; \ + FAR type *tmp = (FAR type *)ptr; \ type ret = *tmp; \ \ *tmp = *tmp ^ value; \ @@ -182,6 +183,137 @@ return ret; \ } +#define SYNC_ADD_FETCH(n, type) \ + \ + type __sync_add_and_fetch_ ## n ( \ + FAR volatile void *ptr, \ + type value) \ + { \ + irqstate_t irqstate = spin_lock_irqsave(NULL); \ + FAR type *tmp = (FAR type *)ptr; \ + \ + *tmp = *tmp + value; \ + \ + spin_unlock_irqrestore(NULL, irqstate); \ + return *tmp; \ + } + +#define SYNC_SUB_FETCH(n, type) \ + \ + type __sync_sub_and_fetch_ ## n ( \ + FAR volatile void *ptr, \ + type value) \ + { \ + irqstate_t irqstate = spin_lock_irqsave(NULL); \ + FAR type *tmp = (FAR type *)ptr; \ + \ + *tmp = *tmp - value; \ + \ + spin_unlock_irqrestore(NULL, irqstate); \ + return *tmp; \ + } + +#define SYNC_OR_FETCH(n, type) \ + \ + type __sync_or_and_fetch_ ## n ( \ + FAR volatile void *ptr, \ + type value) \ + { \ + irqstate_t irqstate = spin_lock_irqsave(NULL); \ + FAR type *tmp = (FAR type *)ptr; \ + \ + *tmp = *tmp | value; \ + \ + spin_unlock_irqrestore(NULL, irqstate); \ + return *tmp; \ + } + +#define SYNC_AND_FETCH(n, type) \ + \ + type __sync_and_and_fetch_ ## n ( \ + FAR volatile void *ptr, \ + type value) \ + { \ + irqstate_t irqstate = spin_lock_irqsave(NULL); \ + FAR type *tmp = (FAR type *)ptr; \ + \ + *tmp = *tmp & value; \ + \ + spin_unlock_irqrestore(NULL, irqstate); \ + return *tmp; \ + } + +#define SYNC_XOR_FETCH(n, type) \ + \ + type __sync_xor_and_fetch_ ## n ( \ + FAR volatile void *ptr, \ + type value) \ + { \ + irqstate_t irqstate = spin_lock_irqsave(NULL); \ + FAR type *tmp = (FAR type *)ptr; \ + \ + *tmp = *tmp ^ value; \ + \ + spin_unlock_irqrestore(NULL, irqstate); \ + return *tmp; \ + } + +#define SYNC_NAND_FETCH(n, type) \ + \ + type __sync_nand_and_fetch_ ## n ( \ + FAR volatile void *ptr, \ + type value) \ + { \ + irqstate_t irqstate = spin_lock_irqsave(NULL); \ + FAR type *tmp = (FAR type *)ptr; \ + \ + *tmp = ~(*tmp & value); \ + \ + spin_unlock_irqrestore(NULL, irqstate); \ + return *tmp; \ + } + +#define SYNC_BOOL_CMP_SWAP(n, type) \ + \ + bool __sync_bool_compare_and_swap_ ## n ( \ + FAR volatile void *ptr, \ + type oldvalue, \ + type newvalue) \ + { \ + bool ret = false; \ + irqstate_t irqstate = spin_lock_irqsave(NULL); \ + FAR type *tmp = (FAR type *)ptr; \ + \ + if (*tmp == oldvalue) \ + { \ + ret = true; \ + *tmp = newvalue; \ + } \ + \ + spin_unlock_irqrestore(NULL, irqstate); \ + return ret; \ + } + +#define SYNC_VAL_CMP_SWAP(n, type) \ + \ + type __sync_val_compare_and_swap_ ## n ( \ + FAR volatile void *ptr, \ + type oldvalue, \ + type newvalue) \ + { \ + irqstate_t irqstate = spin_lock_irqsave(NULL); \ + FAR type *tmp = (FAR type *)ptr; \ + type ret = *tmp; \ + \ + if (*tmp == oldvalue) \ + { \ + *tmp = newvalue; \ + } \ + \ + spin_unlock_irqrestore(NULL, irqstate); \ + return ret; \ + } + /**************************************************************************** * Public Functions ****************************************************************************/ @@ -401,3 +533,203 @@ FETCH_XOR(4, uint32_t) ****************************************************************************/ FETCH_XOR(8, uint64_t) + +/* Clang define the __sync builtins, add #ifndef to avoid + * redefined/redeclared problem. + */ + +#ifndef __clang__ + +/**************************************************************************** + * Name: __sync_add_and_fetch_1 + ****************************************************************************/ + +SYNC_ADD_FETCH(1, uint8_t) + +/**************************************************************************** + * Name: __sync_add_and_fetch_2 + ****************************************************************************/ + +SYNC_ADD_FETCH(2, uint16_t) + +/**************************************************************************** + * Name: __sync_add_and_fetch_4 + ****************************************************************************/ + +SYNC_ADD_FETCH(4, uint32_t) + +/**************************************************************************** + * Name: __sync_add_and_fetch_8 + ****************************************************************************/ + +SYNC_ADD_FETCH(8, uint64_t) + +/**************************************************************************** + * Name: __sync_sub_and_fetch_1 + ****************************************************************************/ + +SYNC_SUB_FETCH(1, uint8_t) + +/**************************************************************************** + * Name: __sync_sub_and_fetch_2 + ****************************************************************************/ + +SYNC_SUB_FETCH(2, uint16_t) + +/**************************************************************************** + * Name: __sync_sub_and_fetch_4 + ****************************************************************************/ + +SYNC_SUB_FETCH(4, uint32_t) + +/**************************************************************************** + * Name: __sync_sub_and_fetch_8 + ****************************************************************************/ + +SYNC_SUB_FETCH(8, uint64_t) + +/**************************************************************************** + * Name: __sync_or_and_fetch_1 + ****************************************************************************/ + +SYNC_OR_FETCH(1, uint8_t) + +/**************************************************************************** + * Name: __sync_or_and_fetch_2 + ****************************************************************************/ + +SYNC_OR_FETCH(2, uint16_t) + +/**************************************************************************** + * Name: __sync_or_and_fetch_4 + ****************************************************************************/ + +SYNC_OR_FETCH(4, uint32_t) + +/**************************************************************************** + * Name: __sync_or_and_fetch_8 + ****************************************************************************/ + +SYNC_OR_FETCH(8, uint64_t) + +/**************************************************************************** + * Name: __sync_and_and_fetch_1 + ****************************************************************************/ + +SYNC_AND_FETCH(1, uint8_t) + +/**************************************************************************** + * Name: __sync_and_and_fetch_2 + ****************************************************************************/ + +SYNC_AND_FETCH(2, uint16_t) + +/**************************************************************************** + * Name: __sync_and_and_fetch_4 + ****************************************************************************/ + +SYNC_AND_FETCH(4, uint32_t) + +/**************************************************************************** + * Name: __sync_and_and_fetch_8 + ****************************************************************************/ + +SYNC_AND_FETCH(8, uint64_t) + +/**************************************************************************** + * Name: __sync_xor_and_fetch_1 + ****************************************************************************/ + +SYNC_XOR_FETCH(1, uint8_t) + +/**************************************************************************** + * Name: __sync_xor_and_fetch_2 + ****************************************************************************/ + +SYNC_XOR_FETCH(2, uint16_t) + +/**************************************************************************** + * Name: __sync_xor_and_fetch_4 + ****************************************************************************/ + +SYNC_XOR_FETCH(4, uint32_t) + +/**************************************************************************** + * Name: __sync_xor_and_fetch_8 + ****************************************************************************/ + +SYNC_XOR_FETCH(8, uint64_t) + +/**************************************************************************** + * Name: __sync_nand_and_fetch_1 + ****************************************************************************/ + +SYNC_NAND_FETCH(1, uint8_t) + +/**************************************************************************** + * Name: __sync_nand_and_fetch_2 + ****************************************************************************/ + +SYNC_NAND_FETCH(2, uint16_t) + +/**************************************************************************** + * Name: __sync_nand_and_fetch_4 + ****************************************************************************/ + +SYNC_NAND_FETCH(4, uint32_t) + +/**************************************************************************** + * Name: __sync_nand_and_fetch_8 + ****************************************************************************/ + +SYNC_NAND_FETCH(8, uint64_t) + +/**************************************************************************** + * Name: __sync_bool_compare_and_swap_1 + ****************************************************************************/ + +SYNC_BOOL_CMP_SWAP(1, uint8_t) + +/**************************************************************************** + * Name: __sync_bool_compare_and_swap_2 + ****************************************************************************/ + +SYNC_BOOL_CMP_SWAP(2, uint16_t) + +/**************************************************************************** + * Name: __sync_bool_compare_and_swap_4 + ****************************************************************************/ + +SYNC_BOOL_CMP_SWAP(4, uint32_t) + +/**************************************************************************** + * Name: __sync_bool_compare_and_swap_8 + ****************************************************************************/ + +SYNC_BOOL_CMP_SWAP(8, uint64_t) + +/**************************************************************************** + * Name: __sync_val_compare_and_swap_1 + ****************************************************************************/ + +SYNC_VAL_CMP_SWAP(1, uint8_t) + +/**************************************************************************** + * Name: __sync_val_compare_and_swap_2 + ****************************************************************************/ + +SYNC_VAL_CMP_SWAP(2, uint16_t) + +/**************************************************************************** + * Name: __sync_val_compare_and_swap_4 + ****************************************************************************/ + +SYNC_VAL_CMP_SWAP(4, uint32_t) + +/**************************************************************************** + * Name: __sync_val_compare_and_swap_8 + ****************************************************************************/ + +SYNC_VAL_CMP_SWAP(8, uint64_t) + +#endif /* __clang__ */ diff --git a/libs/libc/machine/arm/gnu/arch_setjmp.S b/libs/libc/machine/arm/gnu/arch_setjmp.S index e110dc20b36a6..cae0f259fe6b0 100644 --- a/libs/libc/machine/arm/gnu/arch_setjmp.S +++ b/libs/libc/machine/arm/gnu/arch_setjmp.S @@ -65,7 +65,20 @@ setjmp: /* Store callee-saved Core registers */ mov ip, sp /* Move sp to ip so we can save it */ + +#ifdef CONFIG_ARCH_ARMV6M + stmia r0!, {r4-r7} /* Save R4 ~ R7 */ + + mov r2, r8 + mov r3, r9 + mov r4, r10 + mov r5, r11 + mov r6, ip + mov r7, lr + stmia r0!, {r2-r7} /* Save R8 ~ R11, IP, LR */ +#else stmia r0!, {r4-r11, ip, lr} +#endif #ifdef CONFIG_ARCH_FPU vstmia r0!, {s16-s31} /* Save the callee-saved FP registers */ @@ -81,7 +94,7 @@ setjmp: /* we're done, we're out of here */ - mov r0, #0 + movs r0, #0 bx lr .size setjmp, .-setjmp @@ -113,7 +126,24 @@ longjmp: /* Load callee-saved Core registers */ +#ifdef CONFIG_ARCH_ARMV6M + ldmia r0!, {r4-r7} /* Restore R4 ~ R7 */ + + ldmia r0!, {r2-r3} /* Restore R8, R9 */ + mov r8, r2 + mov r9, r3 + + ldmia r0!, {r2-r3} /* Restore R10, R11 */ + mov r10, r2 + mov r11, r3 + + ldmia r0!, {r2-r3} /* Restore IP, LR */ + mov ip, r2 + mov lr, r3 +#else ldmia r0!, {r4-r11, ip, lr} +#endif + mov sp, ip /* Restore sp */ #ifdef CONFIG_ARCH_FPU diff --git a/libs/libc/misc/lib_crc16.c b/libs/libc/misc/lib_crc16.c index c9f96e80a72ec..a564ffd860ead 100644 --- a/libs/libc/misc/lib_crc16.c +++ b/libs/libc/misc/lib_crc16.c @@ -1,48 +1,29 @@ /************************************************************************************************ * libs/libc/misc/lib_crc16.c * - * This file is a part of NuttX: + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at * - * Copyright (C) 2013 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt + * http://www.apache.org/licenses/LICENSE-2.0 * - * "Programmers may incorporate any or all code into their programs, + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ************************************************************************************************/ + +/* "Programmers may incorporate any or all code into their programs, * giving proper credit within the source. Publication of the * source routines is permitted so long as proper credit is given * to Stephen Satchell, Satchell Evaluations and Chuck Forsberg, * Omen Technology." - * - * Re-released under the Modified BSD license which, I believe, is - * consistent with the original authors' intent: - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * 3. Neither the name NuttX nor the names of its contributors may be - * used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - ************************************************************************************************/ + */ /* References: * diff --git a/libs/libc/misc/lib_err.c b/libs/libc/misc/lib_err.c index 04195ef0b5ddb..9ec3bda6eac16 100644 --- a/libs/libc/misc/lib_err.c +++ b/libs/libc/misc/lib_err.c @@ -70,6 +70,10 @@ void vwarn(FAR const char *fmt, va_list ap) #else dprintf(STDERR_FILENO, "%d: %pV: %s\n", getpid(), &vaf, strerror(error)); #endif + +#ifdef va_copy + va_end(copy); +#endif } /**************************************************************************** diff --git a/libs/libc/misc/lib_glob.c b/libs/libc/misc/lib_glob.c index e249f28008301..3bf8170c65196 100644 --- a/libs/libc/misc/lib_glob.c +++ b/libs/libc/misc/lib_glob.c @@ -328,7 +328,7 @@ static int do_glob(FAR char *buf, size_t pos, int type, FAR char *pat, continue; } - memcpy(buf + pos, de->d_name, l + 1); + strlcpy(buf + pos, de->d_name, l + 1); if (p2) { diff --git a/libs/libc/modlib/modlib_bind.c b/libs/libc/modlib/modlib_bind.c index b9de73acf89f1..ab7ce2747d019 100644 --- a/libs/libc/modlib/modlib_bind.c +++ b/libs/libc/modlib/modlib_bind.c @@ -297,8 +297,7 @@ static int modlib_relocate(FAR struct module_s *modp, /* Calculate the relocation address. */ - if (rel->r_offset < 0 || - rel->r_offset > dstsec->sh_size - sizeof(uint32_t)) + if (rel->r_offset + sizeof(uint32_t) > dstsec->sh_size) { berr("ERROR: Section %d reloc %d: " "Relocation address out of range, " @@ -485,8 +484,7 @@ static int modlib_relocateadd(FAR struct module_s *modp, /* Calculate the relocation address. */ - if (rela->r_offset < 0 || - rela->r_offset > dstsec->sh_size - sizeof(uint32_t)) + if (rela->r_offset + sizeof(uint32_t) > dstsec->sh_size) { berr("ERROR: Section %d reloc %d: " "Relocation address out of range, " diff --git a/libs/libc/net/lib_getifaddrs.c b/libs/libc/net/lib_getifaddrs.c index 0e17cd4fa6ec1..82630e8df6cb4 100644 --- a/libs/libc/net/lib_getifaddrs.c +++ b/libs/libc/net/lib_getifaddrs.c @@ -166,7 +166,7 @@ int getifaddrs(FAR struct ifaddrs **addrs) } myaddrs->addrs.ifa_name = myaddrs->name; - strncpy(myaddrs->name, req.lifr_name, IF_NAMESIZE); + strlcpy(myaddrs->name, req.lifr_name, IF_NAMESIZE); myaddrs->addrs.ifa_flags = flags; diff --git a/libs/libc/netdb/lib_dnsaddserver.c b/libs/libc/netdb/lib_dnsaddserver.c index e0f6adc8438ae..cc4e0b5933636 100644 --- a/libs/libc/netdb/lib_dnsaddserver.c +++ b/libs/libc/netdb/lib_dnsaddserver.c @@ -49,6 +49,26 @@ union dns_addr_u g_dns_servers[CONFIG_NETDB_DNSSERVER_NAMESERVERS]; uint8_t g_dns_nservers; /* Number of currently configured nameservers */ #endif +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +static int dns_check_nameserver(FAR void *arg, FAR struct sockaddr *addr, + socklen_t addrlen) +{ + FAR struct sockaddr *newaddr = (FAR struct sockaddr *)arg; + + if (addr->sa_family == newaddr->sa_family) + { + if (memcmp(addr, newaddr, addrlen) == 0) + { + return -EEXIST; + } + } + + return OK; +} + /**************************************************************************** * Public Functions ****************************************************************************/ @@ -66,9 +86,9 @@ int dns_add_nameserver(FAR const struct sockaddr *addr, socklen_t addrlen) { FAR FILE *stream; char addrstr[DNS_MAX_ADDRSTR]; -#ifdef CONFIG_NETDB_RESOLVCONF_NONSTDPORT - uint16_t port; -#endif + union dns_addr_u dns_addr; + FAR uint16_t *pport; + size_t copylen; int ret; stream = fopen(CONFIG_NETDB_RESOLVCONF_PATH, "a+"); @@ -81,6 +101,8 @@ int dns_add_nameserver(FAR const struct sockaddr *addr, socklen_t addrlen) return ret; } + dns_semtake(); + #ifdef CONFIG_NET_IPv4 /* Check for an IPv4 address */ @@ -95,6 +117,8 @@ int dns_add_nameserver(FAR const struct sockaddr *addr, socklen_t addrlen) { FAR struct sockaddr_in *in4 = (FAR struct sockaddr_in *)addr; + copylen = sizeof(struct sockaddr_in); + pport = &dns_addr.ipv4.sin_port; if (inet_ntop(AF_INET, &in4->sin_addr, addrstr, DNS_MAX_ADDRSTR) == NULL) { @@ -103,12 +127,6 @@ int dns_add_nameserver(FAR const struct sockaddr *addr, socklen_t addrlen) DEBUGASSERT(ret < 0); goto errout; } - -#ifdef CONFIG_NETDB_RESOLVCONF_NONSTDPORT - /* Get the port number */ - - port = NTOHS(in4->sin_port); -#endif } } else @@ -128,6 +146,8 @@ int dns_add_nameserver(FAR const struct sockaddr *addr, socklen_t addrlen) { FAR struct sockaddr_in6 *in6 = (FAR struct sockaddr_in6 *)addr; + copylen = sizeof(struct sockaddr_in6); + pport = &dns_addr.ipv6.sin6_port; if (inet_ntop(AF_INET6, &in6->sin6_addr, addrstr, DNS_MAX_ADDRSTR) == NULL) { @@ -136,12 +156,6 @@ int dns_add_nameserver(FAR const struct sockaddr *addr, socklen_t addrlen) DEBUGASSERT(ret < 0); goto errout; } - -#ifdef CONFIG_NETDB_RESOLVCONF_NONSTDPORT - /* Get the port number */ - - port = NTOHS(in6->sin6_port); -#endif } } else @@ -152,6 +166,21 @@ int dns_add_nameserver(FAR const struct sockaddr *addr, socklen_t addrlen) goto errout; } + memcpy(&dns_addr.addr, addr, copylen); + + /* A port number of zero means to use the default DNS server port number */ + + if (*pport == 0) + { + *pport = HTONS(DNS_DEFAULT_PORT); + } + + ret = dns_foreach_nameserver(dns_check_nameserver, &dns_addr.addr); + if (ret < 0) + { + goto errout; + } + /* Write the new record to the end of the resolv.conf file. */ #ifdef CONFIG_NETDB_RESOLVCONF_NONSTDPORT @@ -163,17 +192,12 @@ int dns_add_nameserver(FAR const struct sockaddr *addr, socklen_t addrlen) * nameserver [::1]:5353 */ - if (port != 0 && port != DNS_DEFAULT_PORT) - { - ret = fprintf(stream, "%s [%s]:%u\n", - NETDB_DNS_KEYWORD, addrstr, port); - } - else + ret = fprintf(stream, "%s [%s]:%u\n", + NETDB_DNS_KEYWORD, addrstr, NTOHS(*pport)); +#else + ret = fprintf(stream, "%s %s\n", + NETDB_DNS_KEYWORD, addrstr); #endif - { - ret = fprintf(stream, "%s %s\n", - NETDB_DNS_KEYWORD, addrstr); - } if (ret < 0) { @@ -183,11 +207,17 @@ int dns_add_nameserver(FAR const struct sockaddr *addr, socklen_t addrlen) goto errout; } - dns_notify_nameserver(addr, addrlen); ret = OK; errout: + dns_semgive(); fclose(stream); + + if (ret == OK) + { + dns_notify_nameserver(&dns_addr.addr, addrlen); + } + return ret; } @@ -195,10 +225,12 @@ int dns_add_nameserver(FAR const struct sockaddr *addr, socklen_t addrlen) int dns_add_nameserver(FAR const struct sockaddr *addr, socklen_t addrlen) { + union dns_addr_u dns_addr; FAR uint16_t *pport; size_t copylen; int nservers; int idx; + int ret; DEBUGASSERT(addr != NULL); @@ -224,7 +256,7 @@ int dns_add_nameserver(FAR const struct sockaddr *addr, socklen_t addrlen) /* Set up for the IPv4 address copy */ copylen = sizeof(struct sockaddr_in); - pport = &g_dns_servers[idx].ipv4.sin_port; + pport = &dns_addr.ipv4.sin_port; } else #endif @@ -237,7 +269,7 @@ int dns_add_nameserver(FAR const struct sockaddr *addr, socklen_t addrlen) /* Set up for the IPv6 address copy */ copylen = sizeof(struct sockaddr_in6); - pport = &g_dns_servers[idx].ipv6.sin6_port; + pport = &dns_addr.ipv6.sin6_port; } else #endif @@ -257,7 +289,7 @@ int dns_add_nameserver(FAR const struct sockaddr *addr, socklen_t addrlen) return -EINVAL; } - memcpy(&g_dns_servers[idx].addr, addr, copylen); + memcpy(&dns_addr.addr, addr, copylen); /* A port number of zero means to use the default DNS server port number */ @@ -266,6 +298,15 @@ int dns_add_nameserver(FAR const struct sockaddr *addr, socklen_t addrlen) *pport = HTONS(DNS_DEFAULT_PORT); } + ret = dns_foreach_nameserver(dns_check_nameserver, &dns_addr.addr); + if (ret < 0) + { + dns_semgive(); + return ret; + } + + memcpy(&g_dns_servers[idx].addr, &dns_addr.addr, copylen); + /* We now have a valid DNS address */ g_dns_nservers = nservers; @@ -273,7 +314,7 @@ int dns_add_nameserver(FAR const struct sockaddr *addr, socklen_t addrlen) #if CONFIG_NETDB_DNSCLIENT_ENTRIES > 0 dns_clear_answer(); #endif - dns_notify_nameserver(addr, addrlen); + dns_notify_nameserver(&dns_addr.addr, addrlen); return OK; } diff --git a/libs/libc/netdb/lib_dnscache.c b/libs/libc/netdb/lib_dnscache.c index c5a18af510d66..09b1d718c2339 100644 --- a/libs/libc/netdb/lib_dnscache.c +++ b/libs/libc/netdb/lib_dnscache.c @@ -142,7 +142,7 @@ void dns_save_answer(FAR const char *hostname, entry->ctime = (time_t)now.tv_sec; #endif - strncpy(entry->name, hostname, CONFIG_NETDB_DNSCLIENT_NAMESIZE); + strlcpy(entry->name, hostname, CONFIG_NETDB_DNSCLIENT_NAMESIZE); memcpy(&entry->addr, addr, naddr * sizeof(*addr)); entry->naddr = naddr; diff --git a/libs/libc/netdb/lib_dnsforeach.c b/libs/libc/netdb/lib_dnsforeach.c index 1df7f7cb165e9..2857fd6ad55a1 100644 --- a/libs/libc/netdb/lib_dnsforeach.c +++ b/libs/libc/netdb/lib_dnsforeach.c @@ -96,6 +96,8 @@ int dns_foreach_nameserver(dns_callback_t callback, FAR void *arg) return ret; } + dns_semtake(); + keylen = strlen(NETDB_DNS_KEYWORD); while (fgets(line, DNS_MAX_LINE, stream) != NULL) { @@ -218,14 +220,14 @@ int dns_foreach_nameserver(dns_callback_t callback, FAR void *arg) if (ret != OK) { - fclose(stream); - return ret; + break; } } } + dns_semgive(); fclose(stream); - return OK; + return ret; } #else /* CONFIG_NETDB_RESOLVCONF */ @@ -253,9 +255,7 @@ int dns_foreach_nameserver(dns_callback_t callback, FAR void *arg) /* Perform the callback */ - dns_semgive(); ret = callback(arg, addr, sizeof(struct sockaddr_in)); - dns_semtake(); } else #endif @@ -274,9 +274,7 @@ int dns_foreach_nameserver(dns_callback_t callback, FAR void *arg) /* Perform the callback */ - dns_semgive(); ret = callback(arg, addr, sizeof(struct sockaddr_in6)); - dns_semtake(); } else #endif diff --git a/libs/libc/netdb/lib_dnsinit.c b/libs/libc/netdb/lib_dnsinit.c index 5b07f5aa5972a..ae45b82142824 100644 --- a/libs/libc/netdb/lib_dnsinit.c +++ b/libs/libc/netdb/lib_dnsinit.c @@ -30,6 +30,7 @@ #include +#include #include #include "netdb/lib_dns.h" @@ -40,7 +41,9 @@ /* Protects DNS cache, nameserver list and notify list. */ -static sem_t g_dns_sem = SEM_INITIALIZER(1); +static sem_t g_dns_sem = SEM_INITIALIZER(1); +static pid_t g_dns_holder = INVALID_PROCESS_ID; +static int g_dns_count; /**************************************************************************** * Public Data @@ -143,9 +146,20 @@ bool dns_initialize(void) void dns_semtake(void) { + pid_t me = getpid(); int errcode = 0; int ret; + /* Does this thread already hold the semaphore? */ + + if (g_dns_holder == me) + { + /* Yes.. just increment the reference count */ + + g_dns_count++; + return; + } + do { ret = _SEM_WAIT(&g_dns_sem); @@ -156,6 +170,9 @@ void dns_semtake(void) } } while (ret < 0 && errcode == EINTR); + + g_dns_holder = me; + g_dns_count = 1; } /**************************************************************************** @@ -168,5 +185,11 @@ void dns_semtake(void) void dns_semgive(void) { - DEBUGVERIFY(_SEM_POST(&g_dns_sem)); + DEBUGASSERT(g_dns_holder == getpid() && g_dns_count > 0); + + if (--g_dns_count == 0) + { + g_dns_holder = INVALID_PROCESS_ID; + DEBUGVERIFY(_SEM_POST(&g_dns_sem)); + } } diff --git a/libs/libc/netdb/lib_netdb.c b/libs/libc/netdb/lib_netdb.c index 4a6f305116cd6..ed41e3ee2fde9 100644 --- a/libs/libc/netdb/lib_netdb.c +++ b/libs/libc/netdb/lib_netdb.c @@ -48,7 +48,7 @@ int h_errno; * Public Functions ****************************************************************************/ -bool convert_hostent(const FAR struct hostent_s *in, +bool convert_hostent(FAR const struct hostent_s *in, int type, FAR struct hostent *out) { int i; diff --git a/libs/libc/netdb/lib_netdb.h b/libs/libc/netdb/lib_netdb.h index 86bcd31d85b19..8a43d0c11aba9 100644 --- a/libs/libc/netdb/lib_netdb.h +++ b/libs/libc/netdb/lib_netdb.h @@ -105,7 +105,7 @@ EXTERN const struct services_db_s g_services_db[]; * Public Function Prototypes ****************************************************************************/ -bool convert_hostent(const FAR struct hostent_s *in, +bool convert_hostent(FAR const struct hostent_s *in, int type, FAR struct hostent *out); ssize_t parse_hostfile(FAR FILE *stream, FAR struct hostent_s *host, diff --git a/libs/libc/stdio/lib_libvsprintf.c b/libs/libc/stdio/lib_libvsprintf.c index 6812946dca3db..43d23d459f041 100644 --- a/libs/libc/stdio/lib_libvsprintf.c +++ b/libs/libc/stdio/lib_libvsprintf.c @@ -1160,7 +1160,7 @@ static int vsprintf_internal(FAR struct lib_outstream_s *stream, if (c == 'S') { - sprintf_internal(stream, "+%#jx/%#zx", + sprintf_internal(stream, "+%#tx/%#zx", addr - symbol->sym_value, symbolsize); } diff --git a/libs/libc/stdlib/lib_realpath.c b/libs/libc/stdlib/lib_realpath.c index 466432a7a00c6..86ec60ca2b196 100644 --- a/libs/libc/stdlib/lib_realpath.c +++ b/libs/libc/stdlib/lib_realpath.c @@ -67,6 +67,7 @@ FAR char *realpath(FAR const char *path, FAR char *resolved) fres = resolved = lib_malloc(PATH_MAX); if (resolved == NULL) { + set_errno(ENOMEM); return NULL; } } diff --git a/libs/libc/stream/Make.defs b/libs/libc/stream/Make.defs index 7af465dc09591..622b3f1f67b58 100644 --- a/libs/libc/stream/Make.defs +++ b/libs/libc/stream/Make.defs @@ -38,6 +38,10 @@ ifeq ($(CONFIG_LIBC_LZF),y) CSRCS += lib_lzfcompress.c endif +ifeq ($(CONFIG_DISABLE_MOUNTPOINT),) +CSRCS += lib_blkoutstream.c +endif + # Add the stdio directory to the build DEPPATH += --dep-path stream diff --git a/libs/libc/stream/lib_blkoutstream.c b/libs/libc/stream/lib_blkoutstream.c new file mode 100644 index 0000000000000..fba2b7b974dba --- /dev/null +++ b/libs/libc/stream/lib_blkoutstream.c @@ -0,0 +1,225 @@ +/**************************************************************************** + * libs/libc/stream/lib_blkoutstream.c + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include +#include + +#include "libc.h" + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +#ifndef CONFIG_DISABLE_MOUNTPOINT + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: blkoutstream_flush + ****************************************************************************/ + +static int blkoutstream_flush(FAR struct lib_outstream_s *this) +{ + FAR struct lib_blkoutstream_s *stream = + (FAR struct lib_blkoutstream_s *)this; + size_t sectorsize = stream->geo.geo_sectorsize; + int ret = OK; + + if (this->nput % sectorsize > 0) + { + ret = stream->inode->u.i_bops->write(stream->inode, stream->cache, + this->nput / sectorsize, 1); + } + + return ret; +} + +/**************************************************************************** + * Name: blkoutstream_puts + ****************************************************************************/ + +static int blkoutstream_puts(FAR struct lib_outstream_s *this, + FAR const void *buf, int len) +{ + FAR struct lib_blkoutstream_s *stream = + (FAR struct lib_blkoutstream_s *)this; + size_t sectorsize = stream->geo.geo_sectorsize; + FAR struct inode *inode = stream->inode; + FAR const unsigned char *ptr = buf; + size_t remain = len; + int ret; + + while (remain > 0) + { + size_t sblock = this->nput / sectorsize; + size_t offset = this->nput % sectorsize; + + if (offset > 0) + { + size_t copyin = offset + remain > sectorsize ? + sectorsize - offset : remain; + + memcpy(stream->cache + offset, ptr, copyin); + + ptr += copyin; + offset += copyin; + this->nput += copyin; + remain -= copyin; + + if (offset == stream->geo.geo_sectorsize) + { + ret = inode->u.i_bops->write(inode, stream->cache, sblock, 1); + if (ret < 0) + { + return ret; + } + } + } + else if (remain < stream->geo.geo_sectorsize) + { + memcpy(stream->cache, ptr, remain); + this->nput += remain; + remain = 0; + } + else if (remain >= stream->geo.geo_sectorsize) + { + size_t copyin = (remain / stream->geo.geo_sectorsize) * + stream->geo.geo_sectorsize; + + ret = inode->u.i_bops->write(inode, ptr, sblock, + remain / stream->geo.geo_sectorsize); + if (ret < 0) + { + return ret; + } + + ptr += copyin; + this->nput += copyin; + remain -= copyin; + } + } + + return len; +} + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: lib_blkoutstream_close + * + * Description: + * close block driver stream backend + * + * Input Parameters: + * stream - User allocated, uninitialized instance of struct + * lib_blkoutstream_s to be initialized. + * + * Returned Value: + * None (User allocated instance initialized). + * + ****************************************************************************/ + +void lib_blkoutstream_close(FAR struct lib_blkoutstream_s *stream) +{ + if (stream != NULL) + { + if (stream->inode != NULL) + { + close_blockdriver(stream->inode); + stream->inode = NULL; + } + + if (stream->cache != NULL) + { + lib_free(stream->cache); + stream->cache = NULL; + } + } +} + +/**************************************************************************** + * Name: lib_blkoutstream_open + * + * Description: + * block driver stream backend + * + * Input Parameters: + * stream - User allocated, uninitialized instance of struct + * lib_blkoutstream_s to be initialized. + * name - The full path to the block driver to be opened. + * + * Returned Value: + * Returns zero on success or a negated errno on failure + * + ****************************************************************************/ + +int lib_blkoutstream_open(FAR struct lib_blkoutstream_s *stream, + FAR const char *name) +{ + FAR struct inode *inode = NULL; + int ret; + + if (stream == NULL || name == NULL) + { + return -EINVAL; + } + + ret = open_blockdriver(name, 0, &inode); + if (ret < 0) + { + return ret; + } + + memset(stream, 0, sizeof(*stream)); + + if (inode->u.i_bops->geometry == NULL || + inode->u.i_bops->write == NULL || + inode->u.i_bops->geometry(inode, &stream->geo) < 0 || + stream->geo.geo_sectorsize <= 0 || + stream->geo.geo_nsectors <= 0) + { + close_blockdriver(inode); + return -EINVAL; + } + + stream->cache = lib_malloc(stream->geo.geo_sectorsize); + if (stream->cache == NULL) + { + close_blockdriver(inode); + return -ENOMEM; + } + + stream->inode = inode; + stream->public.puts = blkoutstream_puts; + stream->public.flush = blkoutstream_flush; + + return OK; +} +#endif diff --git a/libs/libc/stream/lib_memoutstream.c b/libs/libc/stream/lib_memoutstream.c index 91ca00f588502..58c673e312abb 100644 --- a/libs/libc/stream/lib_memoutstream.c +++ b/libs/libc/stream/lib_memoutstream.c @@ -67,7 +67,7 @@ static int memoutstream_puts(FAR struct lib_outstream_s *this, static void memoutstream_putc(FAR struct lib_outstream_s *this, int ch) { char tmp = ch; - (void)memoutstream_puts(this, &tmp, 1); + memoutstream_puts(this, &tmp, 1); } /**************************************************************************** diff --git a/libs/libc/stream/lib_rawsostream.c b/libs/libc/stream/lib_rawsostream.c index 48342462ecc34..0c417cd64c8a2 100644 --- a/libs/libc/stream/lib_rawsostream.c +++ b/libs/libc/stream/lib_rawsostream.c @@ -76,7 +76,7 @@ static int rawoutstream_puts(FAR struct lib_outstream_s *this, static void rawoutstream_putc(FAR struct lib_outstream_s *this, int ch) { char tmp = ch; - (void)rawoutstream_puts(this, &tmp, 1); + rawoutstream_puts(this, &tmp, 1); } /**************************************************************************** diff --git a/libs/libc/string/lib_memcmp.c b/libs/libc/string/lib_memcmp.c index 1f788f451ef37..9602c9a254dfa 100644 --- a/libs/libc/string/lib_memcmp.c +++ b/libs/libc/string/lib_memcmp.c @@ -32,6 +32,7 @@ #ifndef CONFIG_LIBC_ARCH_MEMCMP #undef memcmp /* See mm/README.txt */ +no_builtin("memcmp") int memcmp(FAR const void *s1, FAR const void *s2, size_t n) { unsigned char *p1 = (unsigned char *)s1; diff --git a/libs/libc/string/lib_memcpy.c b/libs/libc/string/lib_memcpy.c index de4f8eed23b24..ba91d5abb1d5c 100644 --- a/libs/libc/string/lib_memcpy.c +++ b/libs/libc/string/lib_memcpy.c @@ -36,6 +36,7 @@ #ifndef CONFIG_LIBC_ARCH_MEMCPY #undef memcpy /* See mm/README.txt */ +no_builtin("memcpy") FAR void *memcpy(FAR void *dest, FAR const void *src, size_t n) { FAR unsigned char *pout = (FAR unsigned char *)dest; diff --git a/libs/libc/string/lib_memmove.c b/libs/libc/string/lib_memmove.c index bc72a85daf59f..afed8e0172582 100644 --- a/libs/libc/string/lib_memmove.c +++ b/libs/libc/string/lib_memmove.c @@ -32,6 +32,7 @@ #ifndef CONFIG_LIBC_ARCH_MEMMOVE #undef memmove /* See mm/README.txt */ +no_builtin("memmove") FAR void *memmove(FAR void *dest, FAR const void *src, size_t count) { FAR char *tmp; diff --git a/libs/libc/string/lib_memset.c b/libs/libc/string/lib_memset.c index e22a6cd205f95..4f20f15f9e151 100644 --- a/libs/libc/string/lib_memset.c +++ b/libs/libc/string/lib_memset.c @@ -48,6 +48,7 @@ #ifndef CONFIG_LIBC_ARCH_MEMSET #undef memset /* See mm/README.txt */ +no_builtin("memset") FAR void *memset(FAR void *s, int c, size_t n) { #ifdef CONFIG_MEMSET_OPTSPEED diff --git a/libs/libc/string/lib_strcasecmp.c b/libs/libc/string/lib_strcasecmp.c index e02fddd717a47..b1be6b07ab973 100644 --- a/libs/libc/string/lib_strcasecmp.c +++ b/libs/libc/string/lib_strcasecmp.c @@ -35,10 +35,11 @@ #undef strcasecmp /* See mm/README.txt */ int strcasecmp(FAR const char *cs, FAR const char *ct) { - int result; + register int result; for (; ; ) { - if ((result = (int)toupper(*cs) - (int)toupper(*ct)) != 0 || !*cs) + if ((result = toupper(*cs) - toupper(*ct)) != 0 || + *cs == '\0') { break; } diff --git a/libs/libc/string/lib_strcasestr.c b/libs/libc/string/lib_strcasestr.c index e63e644a733ea..8da18860a1afe 100644 --- a/libs/libc/string/lib_strcasestr.c +++ b/libs/libc/string/lib_strcasestr.c @@ -36,15 +36,12 @@ static FAR char *strcasechr(FAR const char *s, int uc) { register char ch; - if (s) + for (; *s; s++) { - for (; *s; s++) + ch = *s; + if (toupper(ch) == uc) { - ch = *s; - if (toupper(ch) == uc) - { - return (FAR char *)s; - } + return (FAR char *)s; } } diff --git a/libs/libc/string/lib_strcat.c b/libs/libc/string/lib_strcat.c index beb23e2652b6d..33f5a97b7328e 100644 --- a/libs/libc/string/lib_strcat.c +++ b/libs/libc/string/lib_strcat.c @@ -32,11 +32,11 @@ #ifndef CONFIG_ARCH_STRCAT #undef strcat /* See mm/README.txt */ -char *strcat(char *dest, const char *src) +FAR char *strcat(FAR char *dest, FAR const char *src) { - char *ret = dest; + FAR char *ret = dest; - dest += strlen(dest); + dest += strlen(dest); while (*src != '\0') { *dest++ = *src++; diff --git a/libs/libc/string/lib_strcmp.c b/libs/libc/string/lib_strcmp.c index 2ac4f62619afb..3067684698e2c 100644 --- a/libs/libc/string/lib_strcmp.c +++ b/libs/libc/string/lib_strcmp.c @@ -34,11 +34,14 @@ #undef strcmp /* See mm/README.txt */ int strcmp(FAR const char *cs, FAR const char *ct) { - register signed char result; + register int result; for (; ; ) { - if ((result = *cs - *ct++) != 0 || !*cs++) - break; + if ((result = (unsigned char)*cs - (unsigned char)*ct++) != 0 || + *cs++ == '\0') + { + break; + } } return result; diff --git a/libs/libc/string/lib_strncasecmp.c b/libs/libc/string/lib_strncasecmp.c index 2b3ac6bfe3aa8..6aeb57273c146 100644 --- a/libs/libc/string/lib_strncasecmp.c +++ b/libs/libc/string/lib_strncasecmp.c @@ -34,12 +34,13 @@ #ifndef CONFIG_ARCH_STRNCASECMP #undef strncasecmp /* See mm/README.txt */ -int strncasecmp(const char *cs, const char *ct, size_t nb) +int strncasecmp(FAR const char *cs, FAR const char *ct, size_t nb) { - int result = 0; + register int result = 0; for (; nb > 0; nb--) { - if ((result = (int)toupper(*cs) - (int)toupper(*ct)) != 0 || !*cs) + if ((result = toupper(*cs) - toupper(*ct)) != 0 || + *cs == '\0') { break; } diff --git a/libs/libc/string/lib_strncat.c b/libs/libc/string/lib_strncat.c index cc68ea156a54a..23ae796054641 100644 --- a/libs/libc/string/lib_strncat.c +++ b/libs/libc/string/lib_strncat.c @@ -32,9 +32,9 @@ #ifndef CONFIG_ARCH_STRNCAT #undef strncat /* See mm/README.txt */ -char *strncat(char *dest, const char *src, size_t n) +FAR char *strncat(FAR char *dest, FAR const char *src, size_t n) { - char *ret = dest; + FAR char *ret = dest; dest += strlen(dest); for (; n > 0 && *src != '\0' ; n--) diff --git a/libs/libc/string/lib_strncmp.c b/libs/libc/string/lib_strncmp.c index 117f1fddf88d0..10869cb411a0a 100644 --- a/libs/libc/string/lib_strncmp.c +++ b/libs/libc/string/lib_strncmp.c @@ -32,12 +32,13 @@ #ifndef CONFIG_ARCH_STRNCMP #undef strncmp /* See mm/README.txt */ -int strncmp(const char *cs, const char *ct, size_t nb) +int strncmp(FAR const char *cs, FAR const char *ct, size_t nb) { - int result = 0; + register int result = 0; for (; nb > 0; nb--) { - if ((result = (int)*cs - (int)*ct++) != 0 || !*cs++) + if ((result = (unsigned char)*cs - (unsigned char)*ct++) != 0 || + *cs++ == '\0') { break; } diff --git a/libs/libc/string/lib_strstr.c b/libs/libc/string/lib_strstr.c index d8ee9f2768d3d..44cbc0456f719 100644 --- a/libs/libc/string/lib_strstr.c +++ b/libs/libc/string/lib_strstr.c @@ -1,20 +1,29 @@ /**************************************************************************** * libs/libc/string/lib_strstr.c * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. The - * ASF licenses this file to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance with the - * License. You may obtain a copy of the License at + * The MIT License (MIT) * - * http://www.apache.org/licenses/LICENSE-2.0 + * Copyright (c) 2014-2015 Tal Einat * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. + * Permission is hereby granted, free of charge, to any person + * obtaining a copy of this software and associated documentation files + * (the "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to permit + * persons to whom the Software is furnished to do so, subject to the + * following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE + * SOFTWARE. * ****************************************************************************/ @@ -25,67 +34,198 @@ #include #include +#include +#include + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +#define LONG_INT_N_BYTES sizeof(long) /**************************************************************************** * Public Functions ****************************************************************************/ -#undef strstr /* See mm/README.txt */ -FAR char *strstr(FAR const char *str, FAR const char *substr) +/* Finds the first occurrence of the sub-string needle in the + * string haystack. Returns NULL if needle was not found. + */ + +FAR char *strstr(FAR const char *haystack, FAR const char *needle) { - FAR const char *candidate; /* Candidate in str with matching start character */ - char ch; /* First character of the substring */ - size_t len; /* The length of the substring */ + FAR const unsigned char *needle_cmp_end; + FAR const unsigned char *i_haystack; + const char needle_first = *needle; + FAR const unsigned char *i_needle; + unsigned long last_haystack_chars; + unsigned long last_needle_chars; + FAR const char *sub_start; + size_t needle_cmp_len; + bool identical = true; + unsigned long mask; + size_t compare_len; + size_t needle_len; + + if (!*needle) + { + return (FAR char *)haystack; + } + + /* Runs strchr() on the first section of the haystack as it has a lower + * algorithmic complexity for discarding the first non-matching characters. + */ + + haystack = strchr(haystack, needle_first); + if (!haystack) /* First character of needle is not in the haystack. */ + { + return NULL; + } - /* Special case the empty substring */ + /* First characters of haystack and needle are the same now. Both are + * guaranteed to be at least one character long. + * Now computes the sum of the first needle_len characters of haystack + * minus the sum of characters values of needle. + */ - len = strlen(substr); - ch = *substr; + i_haystack = (FAR const unsigned char *)haystack + 1; + i_needle = (FAR const unsigned char *)needle + 1; - if (!ch) + while (*i_haystack && *i_needle) { - /* We'll say that an empty substring matches at the beginning of - * the string - */ + identical &= *i_haystack++ == *i_needle++; + } - return (FAR char *)str; + /* i_haystack now references the (needle_len + 1)-th character. */ + + if (*i_needle) /* haystack is smaller than needle. */ + { + return NULL; } + else if (identical) + { + return (FAR char *)haystack; + } + + needle_len = i_needle - (FAR const unsigned char *)needle; + + /* Note: + * needle_len > 1, because we checked that it isn't zero, and if it + * is 1 then identical must be true because the first strchr() ensured + * that the first characters are identical + */ + + sub_start = haystack; + needle_cmp_len = (needle_len < LONG_INT_N_BYTES) ? + needle_len : LONG_INT_N_BYTES; + + needle_cmp_end = i_needle; - /* Search for the substring */ + i_needle -= needle_cmp_len; + i_haystack -= needle_cmp_len; + last_needle_chars = 0; + last_haystack_chars = 0; - candidate = str; - for (; ; ) + while (i_needle != needle_cmp_end) { - /* strchr() will return a pointer to the next occurrence of the - * character ch in the string + last_needle_chars <<= 8; + last_needle_chars ^= *i_needle++; + last_haystack_chars <<= 8; + last_haystack_chars ^= *i_haystack++; + } + + /* At this point: + * needle is at least two characters long + * haystack is at least needle_len characters long (also at least two) + * the first characters of needle and haystack are identical + */ + + if (needle_len > LONG_INT_N_BYTES + 1) + { + /* we will call memcmp() only once we know that the LONG_INT_N_BYTES + * last chars are equal, so it will be enough to compare all but the + * last LONG_INT_N_BYTES characters */ - candidate = strchr(candidate, ch); - if (!candidate || strlen(candidate) < len) - { - /* First character of the substring does not appear in the string - * or the remainder of the string is not long enough to contain the - * substring. - */ + compare_len = needle_len - LONG_INT_N_BYTES; - return NULL; - } + /* iterate through the remainder of haystack while checking for + * identity of the last LONG_INT_N_BYTES, and checking the rest + * with memcmp() + */ - /* Check if this is the beginning of a matching substring */ + while (*i_haystack) + { + last_haystack_chars <<= 8; + last_haystack_chars ^= *i_haystack++; + + sub_start++; + if (last_haystack_chars == last_needle_chars && + memcmp(sub_start, needle, compare_len) == 0) + { + return (FAR char *)sub_start; + } + } + } + else if (needle_len == LONG_INT_N_BYTES + 1) + { + /* iterate through the remainder of haystack while checking for + * identity of the last LONG_INT_N_BYTES as well as the single + * additional character, which is the first one + */ - if (strncmp(candidate, substr, len) == 0) + while (*i_haystack) { - return (FAR char *)candidate; + last_haystack_chars <<= 8; + last_haystack_chars ^= *i_haystack++; + + sub_start++; + if (last_haystack_chars == last_needle_chars && + *sub_start == needle_first) + { + return (FAR char *)sub_start; + } } + } + else if (needle_len == LONG_INT_N_BYTES) + { + /* iterate through the remainder of haystack while checking for + * identity of the last LONG_INT_N_BYTES characters, which + * should exactly match the entire needle + */ - /* No, find the next candidate after this one */ + while (*i_haystack) + { + last_haystack_chars <<= 8; + last_haystack_chars ^= *i_haystack++; - candidate++; + if (last_haystack_chars == last_needle_chars) + { + return (FAR char *)(i_haystack - needle_len); + } + } } + else /* needle_len < LONG_INT_N_BYTES */ + { + mask = (((unsigned long)1) << (needle_len * 8)) - 1; + last_needle_chars &= mask; - /* Won't get here, but some compilers might complain. Other compilers - * might complain about this code being unreachable too. - */ + /* iterate through the remainder of haystack, updating the sums' + * difference and checking for identity whenever the difference + * is zero + */ + + while (*i_haystack) + { + last_haystack_chars <<= 8; + last_haystack_chars ^= *i_haystack++; + last_haystack_chars &= mask; + + if (last_haystack_chars == last_needle_chars) + { + return (FAR char *)(i_haystack - needle_len); + } + } + } return NULL; } diff --git a/libs/libc/string/lib_strtokr.c b/libs/libc/string/lib_strtokr.c index 5193b83b51220..f24d3428c26e1 100644 --- a/libs/libc/string/lib_strtokr.c +++ b/libs/libc/string/lib_strtokr.c @@ -77,8 +77,8 @@ FAR char *strtok_r(FAR char *str, FAR const char *delim, FAR char **saveptr) { - char *pbegin; - char *pend = NULL; + FAR char *pbegin; + FAR char *pend = NULL; /* Decide if we are starting a new string or continuing from * the point we left off. diff --git a/libs/libc/string/lib_vikmemcpy.c b/libs/libc/string/lib_vikmemcpy.c index 3e93b175d34cf..ce9a89a4e240f 100644 --- a/libs/libc/string/lib_vikmemcpy.c +++ b/libs/libc/string/lib_vikmemcpy.c @@ -51,12 +51,6 @@ * ****************************************************************************/ -/**************************************************************************** - * Configuration definitions. - ****************************************************************************/ - -#define CONFIG_MEMCPY_INDEXED_COPY - /**************************************************************************** * Included Files ****************************************************************************/ @@ -311,6 +305,7 @@ typedef uint32_t uintn; * ****************************************************************************/ +no_builtin("memcpy") FAR void *memcpy(FAR void *dest, FAR const void *src, size_t count) { FAR uint8_t *dst8 = (FAR uint8_t *)dest; diff --git a/libs/libc/time/Make.defs b/libs/libc/time/Make.defs index 65553c6c1cd31..e4fbbf16bb0aa 100644 --- a/libs/libc/time/Make.defs +++ b/libs/libc/time/Make.defs @@ -20,7 +20,7 @@ # Add the time C files to the build -CSRCS += lib_strftime.c lib_calendar2utc.c lib_daysbeforemonth.c +CSRCS += lib_strftime.c lib_strptime.c lib_calendar2utc.c lib_daysbeforemonth.c CSRCS += lib_gettimeofday.c lib_isleapyear.c lib_settimeofday.c lib_time.c CSRCS += lib_timespec_get.c lib_nanosleep.c lib_difftime.c lib_dayofweek.c CSRCS += lib_asctime.c lib_asctimer.c lib_ctime.c lib_ctimer.c diff --git a/libs/libc/time/lib_localtime.c b/libs/libc/time/lib_localtime.c index 66e90c7ab934f..11c08afa1b4ac 100644 --- a/libs/libc/time/lib_localtime.c +++ b/libs/libc/time/lib_localtime.c @@ -1518,9 +1518,7 @@ static int tzparse(FAR const char *name, FAR struct state_s *sp, else { int_fast32_t theirstdoffset; - int_fast32_t theirdstoffset; int_fast32_t theiroffset; - int isdst; int i; int j; @@ -1529,7 +1527,7 @@ static int tzparse(FAR const char *name, FAR struct state_s *sp, return -1; } - /* Initial values of theirstdoffset and theirdstoffset */ + /* Initial value of theirstdoffset */ theirstdoffset = 0; for (i = 0; i < sp->timecnt; ++i) @@ -1542,20 +1540,8 @@ static int tzparse(FAR const char *name, FAR struct state_s *sp, } } - theirdstoffset = 0; - for (i = 0; i < sp->timecnt; ++i) - { - j = sp->types[i]; - if (sp->ttis[j].tt_isdst) - { - theirdstoffset = -sp->ttis[j].tt_gmtoff; - break; - } - } - /* Initially we're assumed to be in standard time */ - isdst = FALSE; theiroffset = theirstdoffset; /* Now juggle transition times and types @@ -1578,29 +1564,13 @@ static int tzparse(FAR const char *name, FAR struct state_s *sp, * offset to the transition time; * otherwise, add the standard time * offset to the transition time. - * - * Transitions from DST to DDST - * will effectively disappear since - * POSIX provides for only one DST - * offset. */ - if (isdst && !sp->ttis[j].tt_ttisstd) - { - sp->ats[i] += dstoffset - theirdstoffset; - } - else - { - sp->ats[i] += stdoffset - theirstdoffset; - } + sp->ats[i] += stdoffset - theirstdoffset; } theiroffset = -sp->ttis[j].tt_gmtoff; - if (sp->ttis[j].tt_isdst) - { - theirdstoffset = theiroffset; - } - else + if (!sp->ttis[j].tt_isdst) { theirstdoffset = theiroffset; } @@ -1902,7 +1872,7 @@ static FAR struct tm *timesub(FAR const time_t *timep, y = EPOCH_YEAR; tdays = *timep / SECSPERDAY; rem = *timep - tdays * SECSPERDAY; - while (tdays < 0 || tdays >= g_year_lengths[isleap(y)]) + while (tdays >= g_year_lengths[isleap(y)]) { int newy; time_t tdelta; diff --git a/libs/libc/time/lib_strptime.c b/libs/libc/time/lib_strptime.c new file mode 100644 index 0000000000000..41b5aab09c8b5 --- /dev/null +++ b/libs/libc/time/lib_strptime.c @@ -0,0 +1,624 @@ +/**************************************************************************** + * libs/libc/time/lib_strptime.c + * + * $OpenBSD: strptime.c,v 1.11 2005/08/08 08:05:38 espie Exp $ + * $NetBSD: strptime.c,v 1.12 1998/01/20 21:39:40 mycroft Exp $ + * + * Copyright (c) 1997, 1998 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code was contributed to The NetBSD Foundation by Klaus Klein. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the NetBSD + * Foundation, Inc. and its contributors. + * 4. Neither the name of The NetBSD Foundation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ +#include + +#include +#include +#include +#include + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +#define TM_YEAR_BASE 1900 +#define _ctloc(x) (g_defaulttimelocale.x) + +/* We do not implement alternate representations. However, we always + * check whether a given modifier is allowed for a certain conversion. + */ + +#define _ALT_E 0x01 +#define _ALT_O 0x02 +#define _LEGAL_ALT(x) { if (alt_format & ~(x)) return (0); } + +/**************************************************************************** + * Private Data + ****************************************************************************/ + +static const struct +{ + const char *abday[7]; + const char *day[7]; + const char *abmon[12]; + const char *mon[12]; + const char *am_pm[2]; + const char *d_t_fmt; + const char *d_fmt; + const char *t_fmt; + const char *t_fmt_ampm; +} g_defaulttimelocale = +{ + { + "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", + }, + { + "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", + "Friday", "Saturday" + }, + { + "Jan", "Feb", "Mar", "Apr", "May", "Jun", + "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" + }, + { + "January", "February", "March", "April", "May", "June", "July", + "August", "September", "October", "November", "December" + }, + { + "AM", "PM" + }, + "%a %b %d %H:%M:%S %Y", + "%m/%d/%y", + "%H:%M:%S", + "%I:%M:%S %p" +}; + +struct century_relyear +{ + int century; + int relyear; +}; + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +static int _conv_num(FAR const unsigned char **buf, FAR int *dest, + int llim, int ulim) +{ + int result = 0; + int rulim = ulim; + + while (isspace(**buf)) + { + (*buf)++; + } + + if (**buf < '0' || **buf > '9') + { + return 0; + } + + /* we use rulim to break out of the loop when we run out of digits */ + + do + { + result *= 10; + result += *(*buf)++ - '0'; + rulim /= 10; + } + while ((result * 10 <= ulim) && rulim && **buf >= '0' && **buf <= '9'); + + if (result < llim || result > ulim) + { + return 0; + } + + *dest = result; + return 1; +} + +static FAR const unsigned char *_strptime(FAR const unsigned char *buf, + FAR const char *fmt, + FAR struct tm *tm, + FAR struct century_relyear *cr) +{ + unsigned char c; + FAR const unsigned char *bp; + size_t len = 0; + int alt_format; + int i; + + bp = buf; + while ((c = *fmt) != '\0') + { + /* Clear `alternate' modifier prior to new conversion. */ + + alt_format = 0; + + /* Eat up white-space. */ + + if (isspace(c)) + { + while (isspace(*bp)) + bp++; + + fmt++; + continue; + } + + if ((c = *fmt++) != '%') + { + goto literal; + } + + again: + switch (c = *fmt++) + { + case '%': /* "%%" is converted to "%". */ + literal: + if (c != *bp++) + { + return NULL; + } + + break; + + /* "Alternative" modifiers. Just set the appropriate flag + * and start over again. + */ + + case 'E': /* "%E?" alternative conversion modifier. */ + _LEGAL_ALT(0); + alt_format |= _ALT_E; + goto again; + + case 'O': /* "%O?" alternative conversion modifier. */ + _LEGAL_ALT(0); + alt_format |= _ALT_O; + goto again; + + /* "Complex" conversion rules, implemented through recursion. */ + + case 'c': /* Date and time, using the locale's format. */ + _LEGAL_ALT(_ALT_E); + if (!(bp = _strptime(bp, _ctloc(d_t_fmt), tm, cr))) + { + return NULL; + } + + break; + + case 'D': /* The date as "%m/%d/%y". */ + _LEGAL_ALT(0); + if (!(bp = _strptime(bp, "%m/%d/%y", tm, cr))) + { + return NULL; + } + + break; + + case 'R': /* The time as "%H:%M". */ + _LEGAL_ALT(0); + if (!(bp = _strptime(bp, "%H:%M", tm, cr))) + { + return NULL; + } + + break; + + case 'r': /* The time as "%I:%M:%S %p". */ + _LEGAL_ALT(0); + if (!(bp = _strptime(bp, "%I:%M:%S %p", tm, cr))) + { + return NULL; + } + + break; + + case 'T': /* The time as "%H:%M:%S". */ + _LEGAL_ALT(0); + if (!(bp = _strptime(bp, "%H:%M:%S", tm, cr))) + { + return NULL; + } + + break; + + case 'X': /* The time, using the locale's format. */ + _LEGAL_ALT(_ALT_E); + if (!(bp = _strptime(bp, _ctloc(t_fmt), tm, cr))) + { + return NULL; + } + + break; + + case 'x': /* The date, using the locale's format. */ + _LEGAL_ALT(_ALT_E); + if (!(bp = _strptime(bp, _ctloc(d_fmt), tm, cr))) + { + return NULL; + } + + break; + + /* "Elementary" conversion rules. */ + + case 'A': /* The day of week, using the locale's form. */ + case 'a': + _LEGAL_ALT(0); + for (i = 0; i < 7; i++) + { + /* Full name. */ + + len = strlen(_ctloc(day[i])); + if (strncasecmp(_ctloc(day[i]), + (const char *)bp, len) == 0) + break; + + /* Abbreviated name. */ + + len = strlen(_ctloc(abday[i])); + if (strncasecmp(_ctloc(abday[i]), + (const char *)bp, len) == 0) + break; + } + + /* Nothing matched. */ + + if (i == 7) + { + return NULL; + } + + tm->tm_wday = i; + bp += len; + break; + + case 'B': /* The month, using the locale's form. */ + case 'b': + case 'h': + _LEGAL_ALT(0); + for (i = 0; i < 12; i++) + { + /* Full name. */ + + len = strlen(_ctloc(mon[i])); + if (strncasecmp(_ctloc(mon[i]), + (const char *)bp, len) == 0) + { + break; + } + + /* Abbreviated name. */ + + len = strlen(_ctloc(abmon[i])); + if (strncasecmp(_ctloc(abmon[i]), + (const char *)bp, len) == 0) + { + break; + } + } + + /* Nothing matched. */ + + if (i == 12) + { + return NULL; + } + + tm->tm_mon = i; + bp += len; + break; + + case 'C': /* The century number. */ + _LEGAL_ALT(_ALT_E); + if (!(_conv_num(&bp, &i, 0, 99))) + { + return (NULL); + } + + cr->century = i * 100; + break; + + case 'd': /* The day of month. */ + case 'e': + _LEGAL_ALT(_ALT_O); + if (!(_conv_num(&bp, &tm->tm_mday, 1, 31))) + { + return (NULL); + } + + break; + + case 'k': /* The hour (24-hour clock representation). */ + _LEGAL_ALT(0); + + /* FALLTHROUGH */ + + case 'H': + _LEGAL_ALT(_ALT_O); + if (!(_conv_num(&bp, &tm->tm_hour, 0, 23))) + { + return NULL; + } + + break; + + case 'l': /* The hour (12-hour clock representation). */ + _LEGAL_ALT(0); + + /* FALLTHROUGH */ + + case 'I': + _LEGAL_ALT(_ALT_O); + if (!(_conv_num(&bp, &tm->tm_hour, 1, 12))) + { + return (NULL); + } + + break; + + case 'j': /* The day of year. */ + _LEGAL_ALT(0); + if (!(_conv_num(&bp, &tm->tm_yday, 1, 366))) + { + return NULL; + } + + tm->tm_yday--; + break; + + case 'M': /* The minute. */ + _LEGAL_ALT(_ALT_O); + if (!(_conv_num(&bp, &tm->tm_min, 0, 59))) + { + return NULL; + } + + break; + + case 'm': /* The month. */ + _LEGAL_ALT(_ALT_O); + if (!(_conv_num(&bp, &tm->tm_mon, 1, 12))) + { + return NULL; + } + + tm->tm_mon--; + break; + + case 'p': /* The locale's equivalent of AM/PM. */ + _LEGAL_ALT(0); + + /* AM? */ + + len = strlen(_ctloc(am_pm[0])); + if (strncasecmp(_ctloc(am_pm[0]), (const char *)bp, len) == 0) + { + if (tm->tm_hour > 12) /* i.e., 13:00 AM ?! */ + { + return NULL; + } + else if (tm->tm_hour == 12) + { + tm->tm_hour = 0; + } + + bp += len; + break; + } + + /* PM? */ + + len = strlen(_ctloc(am_pm[1])); + if (strncasecmp(_ctloc(am_pm[1]), (const char *)bp, len) == 0) + { + if (tm->tm_hour > 12) /* i.e., 13:00 PM ?! */ + { + return NULL; + } + else if (tm->tm_hour < 12) + { + tm->tm_hour += 12; + } + + bp += len; + break; + } + + /* Nothing matched. */ + + return NULL; + + case 'S': /* The seconds. */ + _LEGAL_ALT(_ALT_O); + if (!(_conv_num(&bp, &tm->tm_sec, 0, 61))) + { + return NULL; + } + + break; + + case 'U': /* The week of year, beginning on sunday. */ + case 'W': /* The week of year, beginning on monday. */ + _LEGAL_ALT(_ALT_O); + /* XXX This is bogus, as we can not assume any valid + * information present in the tm structure at this + * point to calculate a real value, so just check the + * range for now. + */ + + if (!(_conv_num(&bp, &i, 0, 53))) + { + return NULL; + } + + break; + + case 'w': /* The day of week, beginning on sunday. */ + _LEGAL_ALT(_ALT_O); + if (!(_conv_num(&bp, &tm->tm_wday, 0, 6))) + { + return NULL; + } + + break; + + case 'Y': /* The year. */ + _LEGAL_ALT(_ALT_E); + if (!(_conv_num(&bp, &i, 0, 9999))) + { + return NULL; + } + + cr->relyear = -1; + tm->tm_year = i - TM_YEAR_BASE; + break; + + case 'y': /* The year within the century (2 digits). */ + _LEGAL_ALT(_ALT_E | _ALT_O); + if (!(_conv_num(&bp, &cr->relyear, 0, 99))) + { + return NULL; + } + + break; + + /* Miscellaneous conversions. */ + + case 'n': /* Any kind of white-space. */ + case 't': + _LEGAL_ALT(0); + while (isspace(*bp)) + { + bp++; + } + + break; + + default: /* Unknown/unsupported conversion. */ + return NULL; + } + } + + /* We need to evaluate the two digit year spec (%y) + * last as we can get a century spec (%C) at any time. + */ + + if (cr->relyear != -1) + { + if (cr->century == TM_YEAR_BASE) + { + if (cr->relyear <= 68) + { + tm->tm_year = cr->relyear + 2000 - TM_YEAR_BASE; + } + else + { + tm->tm_year = cr->relyear + 1900 - TM_YEAR_BASE; + } + } + else + { + tm->tm_year = cr->relyear + cr->century - TM_YEAR_BASE; + } + } + + return bp; +} + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: strptime + * + * Description: + * Convert a string to a time type according to a specific time format + * The strptime() function processes the input string from left to + * right. Each of the three possible input elements (whitespace, + * literal, or format) are handled one after the other. If the + * input cannot be matched to the format string, the function stops. + * The remainder of the format and input strings are not processed. + * The supported input field descriptors are listed below. In case + * a text string (such as the name of a day of the week or a month + * name) is to be matched, the comparison is case insensitive. In + * case a number is to be matched, leading zeros are permitted but + * not required. + * %a The abbreviated weekday name according to the current locale. + * %A The full weekday name according to the current locale. + * %b The abbreviated month name according to the current locale. + * %B The full month name according to the current locale. + * %C The century number (year/100) as a 2-digit integer. (SU) + * %d The day of the month as a decimal number (range 01 to 31). + * %e Like %d, the day of the month as a decimal number, but a leading + * zero is replaced by a space. + * %h Equivalent to %b. (SU) + * %H The hour as a decimal number using a 24-hour clock + * (range 00 to 23). + * %I The hour as a decimal number using a 12-hour clock + * (range 01 to 12). + * %j The day of the year as a decimal number (range 001 to 366). + * %k The hour (24-hour clock) as a decimal number (range 0 to 23); + * single digits are preceded by a blank. (See also %H.) (TZ) + * %l The hour (12-hour clock) as a decimal number (range 1 to 12); + * single digits are preceded by a blank. (See also %I.) (TZ) + * %m The month as a decimal number (range 01 to 12). + * %M The minute as a decimal number (range 00 to 59). + * %n A newline character. (SU) + * %p Either "AM" or "PM" according to the given time value, or the + * corresponding strings for the current locale. Noon is treated + * as "PM" and midnight as "AM". + * %P Like %p but in lowercase: "am" or "pm" or a corresponding string + * for the current locale. (GNU) + * %S The second as a decimal number (range 00 to 60). (The range is + * up to 60 to allow for occasional leap seconds.) + * %t A tab character. (SU) + * %y The year as a decimal number without a century (range 00 to 99). + * %Y The year as a decimal number including the century. + * %% A literal '%' character. + * + * Returned Value: + * The return value of the function is a pointer to the first + * character not processed in this function call. In case the input + * string contains more characters than required by the format + * string, the return value points right after the last consumed + * input character. In case the whole input string is consumed, the + * return value points to the null byte at the end of the string. + * If strptime() fails to match all of the format string and + * therefore an error occurred, the function returns NULL. + * + ****************************************************************************/ + +FAR char *strptime(FAR const char *buf, FAR const char *fmt, + FAR struct tm *tm) +{ + struct century_relyear cr; + cr.century = TM_YEAR_BASE; + cr.relyear = -1; + return (FAR char *)(_strptime((FAR const unsigned char *)buf, + fmt, tm, &cr)); +} diff --git a/libs/libc/uio/Make.defs b/libs/libc/uio/Make.defs index 03cab6e236769..eca08968bcd27 100644 --- a/libs/libc/uio/Make.defs +++ b/libs/libc/uio/Make.defs @@ -21,6 +21,7 @@ # Add the uio.h C files to the build CSRCS += lib_readv.c lib_writev.c +CSRCS += lib_preadv.c lib_pwritev.c # Add the uio.h directory to the build diff --git a/libs/libc/uio/lib_preadv.c b/libs/libc/uio/lib_preadv.c new file mode 100644 index 0000000000000..427d5124fb376 --- /dev/null +++ b/libs/libc/uio/lib_preadv.c @@ -0,0 +1,97 @@ +/**************************************************************************** + * libs/libc/uio/lib_preadv.c + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include +#include +#include + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: preadv() + * + * Description: + * The preadv() function is equivalent to pread(), except it takes + * an iov array. + * + ****************************************************************************/ + +ssize_t preadv(int fildes, FAR const struct iovec *iov, int iovcnt, + off_t offset) +{ + ssize_t ntotal; + ssize_t nread; + size_t remaining; + FAR uint8_t *buffer; + int i; + + /* Process each entry in the struct iovec array */ + + for (i = 0, ntotal = 0; i < iovcnt; i++) + { + /* Ignore zero-length reads */ + + if (iov[i].iov_len > 0) + { + buffer = iov[i].iov_base; + remaining = iov[i].iov_len; + + /* Read repeatedly as necessary to fill buffer */ + + do + { + /* NOTE: pread() is a cancellation point */ + + nread = pread(fildes, buffer, remaining, offset + ntotal); + + /* Check for a read error */ + + if (nread < 0) + { + return nread; + } + + /* Check for an end-of-file condition */ + + else if (nread == 0) + { + return ntotal; + } + + /* Update pointers and counts in order to handle partial + * buffer reads. + */ + + buffer += nread; + remaining -= nread; + ntotal += nread; + } + while (remaining > 0); + } + } + + return ntotal; +} diff --git a/arch/arm/src/armv7-a/arm_fullcontextrestore.S b/libs/libc/uio/lib_pwritev.c similarity index 52% rename from arch/arm/src/armv7-a/arm_fullcontextrestore.S rename to libs/libc/uio/lib_pwritev.c index ce0632100faec..1203e20f0cabf 100644 --- a/arch/arm/src/armv7-a/arm_fullcontextrestore.S +++ b/libs/libc/uio/lib_pwritev.c @@ -1,5 +1,5 @@ /**************************************************************************** - * arch/arm/src/armv7-a/arm_fullcontextrestore.S + * libs/libc/uio/lib_pwritev.c * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with @@ -22,55 +22,70 @@ * Included Files ****************************************************************************/ -#include -#include -#include - -#include "arm.h" - -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -/**************************************************************************** - * Public Symbols - ****************************************************************************/ - - .file "arm_fullcontextrestore.S" - -/**************************************************************************** - * Macros - ****************************************************************************/ +#include +#include +#include +#include /**************************************************************************** * Public Functions ****************************************************************************/ /**************************************************************************** - * Name: arm_fullcontextrestore + * Name: pwritev() * * Description: - * Restore the current thread context. Full prototype is: - * - * void arm_fullcontextrestore(uint32_t *restoreregs) noreturn_function; - * - * Returned Value: - * None + * The pwritev() function is equivalent to write(), except it takes + * an iov array. * ****************************************************************************/ - .globl arm_fullcontextrestore - .type arm_fullcontextrestore, function -arm_fullcontextrestore: +ssize_t pwritev(int fildes, FAR const struct iovec *iov, int iovcnt, + off_t offset) +{ + ssize_t ntotal; + ssize_t nwritten; + size_t remaining; + FAR uint8_t *buffer; + int i; + + /* Process each entry in the struct iovec array */ + + for (i = 0, ntotal = 0; i < iovcnt; i++) + { + /* Ignore zero-length writes */ + + if (iov[i].iov_len > 0) + { + buffer = iov[i].iov_base; + remaining = iov[i].iov_len; + + /* Write repeatedly as necessary to write the entire buffer */ + + do + { + /* NOTE: pwrite() is a cancellation point */ + + nwritten = pwrite(fildes, buffer, remaining, offset + ntotal); + + /* Check for a write error */ - /* Perform the System call with R0=1 and R1=regs */ + if (nwritten < 0) + { + return ntotal ? ntotal : ERROR; + } - mov r1, r0 /* R1: regs */ - mov r0, #SYS_restore_context /* R0: restore context */ - svc #SYS_syscall /* Force synchronous SVCall (or Hard Fault) */ + /* Update pointers and counts in order to handle partial + * buffer writes. + */ - /* This call should not return */ + buffer += nwritten; + remaining -= nwritten; + ntotal += nwritten; + } + while (remaining > 0); + } + } - bx lr /* Unnecessary ... will not return */ - .size arm_fullcontextrestore, .-arm_fullcontextrestore - .end + return ntotal; +} diff --git a/libs/libc/uio/lib_writev.c b/libs/libc/uio/lib_writev.c index 02b9fc0326916..b8df8ff414de1 100644 --- a/libs/libc/uio/lib_writev.c +++ b/libs/libc/uio/lib_writev.c @@ -78,13 +78,8 @@ ssize_t writev(int fildes, FAR const struct iovec *iov, int iovcnt) ssize_t nwritten; size_t remaining; FAR uint8_t *buffer; - off_t pos; int i; - /* Get the current file position in case we have to reset it */ - - pos = lseek(fildes, 0, SEEK_CUR); - /* Process each entry in the struct iovec array */ for (i = 0, ntotal = 0; i < iovcnt; i++) @@ -108,21 +103,6 @@ ssize_t writev(int fildes, FAR const struct iovec *iov, int iovcnt) if (nwritten < 0) { - if (pos != (off_t)-1) - { - /* Save the errno value */ - - int save = get_errno(); - - /* Restore the file position */ - - lseek(fildes, pos, SEEK_SET); - - /* Restore the errno value */ - - set_errno(save); - } - return ntotal ? ntotal : ERROR; } diff --git a/libs/libc/unistd/Kconfig b/libs/libc/unistd/Kconfig index f3bb2a2b7f72c..ada5ea250e145 100644 --- a/libs/libc/unistd/Kconfig +++ b/libs/libc/unistd/Kconfig @@ -143,3 +143,10 @@ config LIBC_HOSTNAME default "" ---help--- A unique name to identify device on the network + +config LIBC_OPEN_MAX + int "OPEN_MAX for this device" + default 255 + ---help--- + The maximum number of files that a process can have open + at any time. Must not be less than _POSIX_OPEN_MAX. diff --git a/libs/libc/unistd/Make.defs b/libs/libc/unistd/Make.defs index 35e9e6d5ec0f8..926f1c7b9c9bb 100644 --- a/libs/libc/unistd/Make.defs +++ b/libs/libc/unistd/Make.defs @@ -39,7 +39,7 @@ CSRCS += lib_chdir.c lib_getcwd.c lib_restoredir.c endif ifeq ($(CONFIG_LIBC_EXECFUNCS),y) -CSRCS += lib_execl.c +CSRCS += lib_execl.c lib_execle.c lib_execv.c endif ifneq ($(CONFIG_DISABLE_MOUNTPOINTS),y) diff --git a/libs/libc/unistd/lib_chdir.c b/libs/libc/unistd/lib_chdir.c index 020027e8011bd..82438aa81219a 100644 --- a/libs/libc/unistd/lib_chdir.c +++ b/libs/libc/unistd/lib_chdir.c @@ -26,7 +26,6 @@ #include #include -#include #include #include @@ -34,30 +33,6 @@ #ifndef CONFIG_DISABLE_ENVIRON -/**************************************************************************** - * Private Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: _trimdir - ****************************************************************************/ - -#if 0 -static inline void _trimdir(char *path) -{ - /* Skip any trailing '/' characters (unless it is also the leading '/') */ - - int len = strlen(path) - 1; - while (len > 0 && path[len] == '/') - { - path[len] = '\0'; - len--; - } -} -#else -# define _trimdir(p) -#endif - /**************************************************************************** * Public Functions ****************************************************************************/ @@ -98,42 +73,35 @@ static inline void _trimdir(char *path) int chdir(FAR const char *path) { struct stat buf; - char *oldpwd; - char *alloc; - char *abspath; - int errcode; + FAR char *oldpwd; + FAR char *abspath; int ret; - /* Verify the input parameters */ - - if (!path) - { - errcode = ENOENT; - goto errout; - } - /* Verify that 'path' refers to a directory */ ret = stat(path, &buf); - if (ret != 0) + if (ret < 0) { - errcode = ENOENT; - goto errout; + return ret; } /* Something exists here... is it a directory? */ if (!S_ISDIR(buf.st_mode)) { - errcode = ENOTDIR; - goto errout; + set_errno(ENOTDIR); + return ERROR; } /* Yes, it is a directory. * Remove any trailing '/' characters from the path */ - _trimdir(path); + abspath = realpath(path, NULL); + if (abspath == NULL) + { + return ERROR; + } /* Replace any preceding OLDPWD with the current PWD (this is to * support 'cd -' in NSH) @@ -146,26 +114,14 @@ int chdir(FAR const char *path) oldpwd = CONFIG_LIBC_HOMEDIR; } - alloc = strdup(oldpwd); /* kludge needed because environment is realloc'ed */ - setenv("OLDPWD", alloc, TRUE); - lib_free(alloc); + setenv("OLDPWD", oldpwd, TRUE); /* Set the cwd to the input 'path' */ - abspath = realpath(path, NULL); - if (abspath == NULL) - { - errcode = ENOENT; - goto errout; - } - - setenv("PWD", abspath, TRUE); + ret = setenv("PWD", abspath, TRUE); lib_free(abspath); sched_unlock(); - return OK; -errout: - set_errno(errcode); - return ERROR; + return ret; } #endif /* !CONFIG_DISABLE_ENVIRON */ diff --git a/libs/libc/unistd/lib_execle.c b/libs/libc/unistd/lib_execle.c new file mode 100644 index 0000000000000..1aaffe5f74580 --- /dev/null +++ b/libs/libc/unistd/lib_execle.c @@ -0,0 +1,183 @@ +/**************************************************************************** + * libs/libc/unistd/lib_execle.c + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include +#include +#include +#include + +#include "libc.h" + +#ifdef CONFIG_LIBC_EXECFUNCS + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/* This is an artificial limit to detect error conditions where an argv[] + * list is not properly terminated. + */ + +#define MAX_EXECL_ARGS 256 + +/**************************************************************************** + * Public Data + ****************************************************************************/ + +/**************************************************************************** + * Private Data + ****************************************************************************/ + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: execle + * + * Description: + * The standard 'exec' family of functions will replace the current process + * image with a new process image. The new image will be constructed from a + * regular, executable file called the new process image file. There will + * be no return from a successful exec, because the calling process image + * is overlaid by the new process image. + * + * Simplified 'execl()' and 'execv()' functions are provided by NuttX for + * compatibility. NuttX is a tiny embedded RTOS that does not support + * processes and hence the concept of overlaying a tasks process image with + * a new process image does not make any sense. In NuttX, these functions + * are wrapper functions that: + * + * 1. Call the non-standard binfmt function 'exec', and then + * 2. exit(0). + * + * Note the inefficiency when 'exec[l|v]()' is called in the normal, two- + * step process: (1) first call vfork() to create a new thread, then (2) + * call 'exec[l|v]()' to replace the new thread with a program from the + * file system. Since the new thread will be terminated by the + * 'exec[l|v]()' call, it really served no purpose other than to support + * Unix compatility. + * + * The non-standard binfmt function 'exec()' needs to have (1) a symbol + * table that provides the list of symbols exported by the base code, and + * (2) the number of symbols in that table. This information is currently + * provided to 'exec()' from 'exec[l|v]()' via NuttX configuration setting: + * + * CONFIG_LIBC_EXECFUNCS : Enable exec[l|v] support + * CONFIG_EXECFUNCS_SYMTAB_ARRAY : Symbol table name used by exec[l|v] + * CONFIG_EXECFUNCS_NSYMBOLS_VAR : Variable holding number of symbols in + * the table + * + * As a result of the above, the current implementations of 'execl()' and + * 'execv()' suffer from some incompatibilities that may or may not be + * addressed in a future version of NuttX. Other than just being an + * inefficient use of MCU resource, the most serious of these is that + * the exec'ed task will not have the same task ID as the vfork'ed + * function. So the parent function cannot know the ID of the exec'ed + * task. + * + * Input Parameters: + * path - The path to the program to be executed. If CONFIG_LIBC_ENVPATH + * is defined in the configuration, then this may be a relative path + * from the current working directory. Otherwise, path must be the + * absolute path to the program. + * ... - A list of the string arguments to be recevied by the + * program. Zero indicates the end of the list. + * + * Returned Value: + * This function does not return on success. On failure, it will return + * -1 (ERROR) and will set the 'errno' value appropriately. + * + ****************************************************************************/ + +int execle(FAR const char *path, FAR const char *arg0, ...) +{ + FAR char *arg = (FAR char *)arg0; + FAR char **argv; + FAR char **envp; + size_t nargs; + va_list ap; + int argc; + int ret; + + /* Count the number of arguments */ + + va_start(ap, arg0); + nargs = 0; + + while (arg != NULL) + { + /* Yes.. increment the number of arguments. Here is a sanity + * check to prevent running away with an unterminated argv[] list. + * MAX_EXECL_ARGS should be sufficiently large that this never + * happens in normal usage. + */ + + if (++nargs > MAX_EXECL_ARGS) + { + set_errno(E2BIG); + va_end(ap); + return ERROR; + } + + arg = va_arg(ap, FAR char *); + } + + envp = va_arg(ap, FAR char **); + va_end(ap); + + /* Allocate a temporary argv[] array */ + + argv = (FAR char **)lib_malloc((nargs + 1) * sizeof(FAR char *)); + if (argv == NULL) + { + set_errno(ENOMEM); + return ERROR; + } + + argv[0] = (FAR char *)arg0; + + /* Collect the arguments into the argv[] array */ + + va_start(ap, arg0); + for (argc = 1; argc <= nargs; argc++) + { + argv[argc] = va_arg(ap, FAR char *); + } + + va_end(ap); + + /* Then let execve() do the real work */ + + ret = execve(path, argv, envp); + + /* Free the allocated argv[] list */ + + lib_free(argv); + return ret; +} + +#endif /* CONFIG_LIBC_EXECFUNCS */ diff --git a/libs/libc/unistd/lib_execv.c b/libs/libc/unistd/lib_execv.c new file mode 100644 index 0000000000000..59f0bc3491648 --- /dev/null +++ b/libs/libc/unistd/lib_execv.c @@ -0,0 +1,101 @@ +/**************************************************************************** + * libs/libc/unistd/lib_execv.c + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include + +#ifdef CONFIG_LIBC_EXECFUNCS + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: execv + * + * Description: + * The standard 'exec' family of functions will replace the current process + * image with a new process image. The new image will be constructed from a + * regular, executable file called the new process image file. There will + * be no return from a successful exec, because the calling process image + * is overlaid by the new process image. + * + * Simplified 'execl()' and 'execv()' functions are provided by NuttX for + * compatibility. NuttX is a tiny embedded RTOS that does not support + * processes and hence the concept of overlaying a tasks process image with + * a new process image does not make any sense. In NuttX, these functions + * are wrapper functions that: + * + * 1. Call the non-standard binfmt function 'exec', and then + * 2. exit(0). + * + * Note the inefficiency when 'exec[l|v]()' is called in the normal, two- + * step process: (1) first call vfork() to create a new thread, then (2) + * call 'exec[l|v]()' to replace the new thread with a program from the + * file system. Since the new thread will be terminated by the + * 'exec[l|v]()' call, it really served no purpose other than to support + * Unix compatility. + * + * The non-standard binfmt function 'exec()' needs to have (1) a symbol + * table that provides the list of symbols exported by the base code, and + * (2) the number of symbols in that table. This information is currently + * provided to 'exec()' from 'exec[l|v]()' via NuttX configuration + * settings: + * + * CONFIG_LIBC_EXECFUNCS : Enable exec[l|v] support + * CONFIG_EXECFUNCS_HAVE_SYMTAB : Defined if there is a pre-defined + * symbol table + * CONFIG_EXECFUNCS_SYMTAB_ARRAY : Symbol table name used by exec[l|v] + * CONFIG_EXECFUNCS_NSYMBOLS_VAR : Variable holding number of symbols + * in the table + * + * As a result of the above, the current implementations of 'execl()' and + * 'execv()' suffer from some incompatibilities that may or may not be + * addressed in a future version of NuttX. Other than just being an + * inefficient use of MCU resource, the most serious of these is that + * the exec'ed task will not have the same task ID as the vfork'ed + * function. So the parent function cannot know the ID of the exec'ed + * task. + * + * Input Parameters: + * path - The path to the program to be executed. If CONFIG_LIBC_ENVPATH + * is defined in the configuration, then this may be a relative path + * from the current working directory. Otherwise, path must be the + * absolute path to the program. + * argv - A pointer to an array of string arguments. The end of the + * array is indicated with a NULL entry. + * + * Returned Value: + * This function does not return on success. On failure, it will return + * -1 (ERROR) and will set the 'errno' value appropriately. + * + ****************************************************************************/ + +int execv(FAR const char *path, FAR char * const argv[]) +{ + return execve(path, argv, NULL); +} + +#endif /* CONFIG_LIBC_EXECFUNCS */ diff --git a/libs/libc/unistd/lib_restoredir.c b/libs/libc/unistd/lib_restoredir.c index 13fa3b6f1107b..e86f2f3693644 100644 --- a/libs/libc/unistd/lib_restoredir.c +++ b/libs/libc/unistd/lib_restoredir.c @@ -24,12 +24,10 @@ #include -#include +#include #include #include -#include "libc.h" - #ifndef CONFIG_DISABLE_ENVIRON /**************************************************************************** @@ -42,15 +40,13 @@ int lib_restoredir(void) { - char *oldpwd; + FAR char *oldpwd; int ret = OK; oldpwd = getenv("OLDPWD"); if (oldpwd) { - oldpwd = strdup(oldpwd); /* kludge needed because environment is realloc'ed */ ret = setenv("PWD", oldpwd, TRUE); - lib_free(oldpwd); } return ret; diff --git a/libs/libc/unistd/lib_sysconf.c b/libs/libc/unistd/lib_sysconf.c index 031e76ea83f8d..ee5fd2b35cd2a 100644 --- a/libs/libc/unistd/lib_sysconf.c +++ b/libs/libc/unistd/lib_sysconf.c @@ -211,7 +211,7 @@ long sysconf(int name) return CLOCKS_PER_SEC; case _SC_OPEN_MAX: - return _POSIX_OPEN_MAX; + return OPEN_MAX; case _SC_ATEXIT_MAX: #ifdef CONFIG_SCHED_EXIT_MAX diff --git a/libs/libxx/0001-libcxx-Rename-PS-macro-to-avoid-clashing-with-Xtensa.patch b/libs/libxx/0001-libcxx-Rename-PS-macro-to-avoid-clashing-with-Xtensa.patch new file mode 100644 index 0000000000000..b2f7dc5e5acc5 --- /dev/null +++ b/libs/libxx/0001-libcxx-Rename-PS-macro-to-avoid-clashing-with-Xtensa.patch @@ -0,0 +1,182 @@ +From 213f9acccb725a7ddcd9f41eee9d5234d81e1dc0 Mon Sep 17 00:00:00 2001 +From: Gustavo Henrique Nihei +Date: Fri, 25 Mar 2022 10:18:40 -0300 +Subject: [PATCH 1/2] [libcxx] Rename PS() macro to avoid clashing with Xtensa + register name + +This patch addresses a clash with the PS register from Xtensa +defined in the header file, which is commonly +included in OS implementation. + +Issue identified while building libc++ port for Apache NuttX, targeting +Xtensa-based chips (e.g. Espressif's ESP32). + +Signed-off-by: Gustavo Henrique Nihei + +Differential Revision: https://reviews.llvm.org/D122479 +--- + libcxx/src/filesystem/filesystem_common.h | 4 +- + libcxx/src/filesystem/operations.cpp | 46 +++++++++++------------ + 2 files changed, 24 insertions(+), 26 deletions(-) + +diff --git a/libcxx/src/filesystem/filesystem_common.h b/libcxx/src/filesystem/filesystem_common.h +index e0fdbccf96b1..b62f1406de39 100644 +--- a/libcxx/src/filesystem/filesystem_common.h ++++ b/libcxx/src/filesystem/filesystem_common.h +@@ -41,9 +41,9 @@ + #endif + + #if defined(_LIBCPP_WIN32API) +-#define PS(x) (L##x) ++# define PATHSTR(x) (L##x) + #else +-#define PS(x) (x) ++# define PATHSTR(x) (x) + #endif + + _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM +diff --git a/libcxx/src/filesystem/operations.cpp b/libcxx/src/filesystem/operations.cpp +index 50a895dc2fae..830781def52d 100644 +--- a/libcxx/src/filesystem/operations.cpp ++++ b/libcxx/src/filesystem/operations.cpp +@@ -188,14 +188,14 @@ public: + switch (State) { + case PS_BeforeBegin: + case PS_AtEnd: +- return PS(""); ++ return PATHSTR(""); + case PS_InRootDir: + if (RawEntry[0] == '\\') +- return PS("\\"); ++ return PATHSTR("\\"); + else +- return PS("/"); ++ return PATHSTR("/"); + case PS_InTrailingSep: +- return PS(""); ++ return PATHSTR(""); + case PS_InRootName: + case PS_InFilenames: + return RawEntry; +@@ -303,8 +303,8 @@ private: + }; + + string_view_pair separate_filename(string_view_t const& s) { +- if (s == PS(".") || s == PS("..") || s.empty()) +- return string_view_pair{s, PS("")}; ++ if (s == PATHSTR(".") || s == PATHSTR("..") || s.empty()) ++ return string_view_pair{s, PATHSTR("")}; + auto pos = s.find_last_of('.'); + if (pos == string_view_t::npos || pos == 0) + return string_view_pair{s, string_view_t{}}; +@@ -591,8 +591,8 @@ filesystem_error::~filesystem_error() {} + void filesystem_error::__create_what(int __num_paths) { + const char* derived_what = system_error::what(); + __storage_->__what_ = [&]() -> string { +- const path::value_type* p1 = path1().native().empty() ? PS("\"\"") : path1().c_str(); +- const path::value_type* p2 = path2().native().empty() ? PS("\"\"") : path2().c_str(); ++ const path::value_type* p1 = path1().native().empty() ? PATHSTR("\"\"") : path1().c_str(); ++ const path::value_type* p2 = path2().native().empty() ? PATHSTR("\"\"") : path2().c_str(); + switch (__num_paths) { + default: + return detail::format_string("filesystem error: %s", derived_what); +@@ -1378,7 +1378,7 @@ path& path::replace_extension(path const& replacement) { + } + if (!replacement.empty()) { + if (replacement.native()[0] != '.') { +- __pn_ += PS("."); ++ __pn_ += PATHSTR("."); + } + __pn_.append(replacement.__pn_); + } +@@ -1500,14 +1500,14 @@ enum PathPartKind : unsigned char { + static PathPartKind ClassifyPathPart(string_view_t Part) { + if (Part.empty()) + return PK_TrailingSep; +- if (Part == PS(".")) ++ if (Part == PATHSTR(".")) + return PK_Dot; +- if (Part == PS("..")) ++ if (Part == PATHSTR("..")) + return PK_DotDot; +- if (Part == PS("/")) ++ if (Part == PATHSTR("/")) + return PK_RootSep; + #if defined(_LIBCPP_WIN32API) +- if (Part == PS("\\")) ++ if (Part == PATHSTR("\\")) + return PK_RootSep; + #endif + return PK_Filename; +@@ -1557,7 +1557,7 @@ path path::lexically_normal() const { + NewPathSize -= Parts.back().first.size(); + Parts.pop_back(); + } else if (LastKind != PK_RootSep) +- AddPart(PK_DotDot, PS("..")); ++ AddPart(PK_DotDot, PATHSTR("..")); + MaybeNeedTrailingSep = LastKind == PK_Filename; + break; + } +@@ -1572,7 +1572,7 @@ path path::lexically_normal() const { + } + // [fs.path.generic]p6.8: If the path is empty, add a dot. + if (Parts.empty()) +- return PS("."); ++ return PATHSTR("."); + + // [fs.path.generic]p6.7: If the last filename is dot-dot, remove any + // trailing directory-separator. +@@ -1584,7 +1584,7 @@ path path::lexically_normal() const { + Result /= PK.first; + + if (NeedTrailingSep) +- Result /= PS(""); ++ Result /= PATHSTR(""); + + return Result; + } +@@ -1593,9 +1593,9 @@ static int DetermineLexicalElementCount(PathParser PP) { + int Count = 0; + for (; PP; ++PP) { + auto Elem = *PP; +- if (Elem == PS("..")) ++ if (Elem == PATHSTR("..")) + --Count; +- else if (Elem != PS(".") && Elem != PS("")) ++ else if (Elem != PATHSTR(".") && Elem != PATHSTR("")) + ++Count; + } + return Count; +@@ -1642,15 +1642,15 @@ path path::lexically_relative(const path& base) const { + return {}; + + // if n == 0 and (a == end() || a->empty()), returns path("."); otherwise +- if (ElemCount == 0 && (PP.atEnd() || *PP == PS(""))) +- return PS("."); ++ if (ElemCount == 0 && (PP.atEnd() || *PP == PATHSTR(""))) ++ return PATHSTR("."); + + // return a path constructed with 'n' dot-dot elements, followed by the the + // elements of '*this' after the mismatch. + path Result; + // FIXME: Reserve enough room in Result that it won't have to re-allocate. + while (ElemCount--) +- Result /= PS(".."); ++ Result /= PATHSTR(".."); + for (; PP; ++PP) + Result /= *PP; + return Result; +@@ -1662,9 +1662,7 @@ static int CompareRootName(PathParser *LHS, PathParser *RHS) { + if (!LHS->inRootName() && !RHS->inRootName()) + return 0; + +- auto GetRootName = [](PathParser *Parser) -> string_view_t { +- return Parser->inRootName() ? **Parser : PS(""); +- }; ++ auto GetRootName = [](PathParser* Parser) -> string_view_t { return Parser->inRootName() ? **Parser : PATHSTR(""); }; + int res = GetRootName(LHS).compare(GetRootName(RHS)); + ConsumeRootName(LHS); + ConsumeRootName(RHS); +-- +2.32.0 + diff --git a/libs/libxx/0002-Omit-atomic_-un-signed_lock_free-if-unsupported.patch b/libs/libxx/0002-Omit-atomic_-un-signed_lock_free-if-unsupported.patch new file mode 100644 index 0000000000000..d5020f1276ff0 --- /dev/null +++ b/libs/libxx/0002-Omit-atomic_-un-signed_lock_free-if-unsupported.patch @@ -0,0 +1,38 @@ +From ff00346174831ec01bc6b85c39c19d502cfa2093 Mon Sep 17 00:00:00 2001 +From: Brian Cain +Date: Thu, 27 Jan 2022 08:09:11 -0800 +Subject: [PATCH 2/2] Omit atomic_{,un}signed_lock_free if unsupported + +On targets that have limited atomic support, e.g. ones that define +ATOMIC_*_LOCK_FREE to '1' ("sometimes lock free"), we would end up +referencing yet-undefined __libcpp_{,un}signed_lock_free. + +This commit adds a guard to prevent these references for such +targets. + +Differential Revision: https://reviews.llvm.org/D118391 +--- + libcxx/include/atomic | 3 +++ + 1 file changed, 3 insertions(+) + +diff --git a/libcxx/include/atomic b/libcxx/include/atomic +index 0fc799a24319..57d01ad2791a 100644 +--- a/libcxx/include/atomic ++++ b/libcxx/include/atomic +@@ -2791,10 +2791,13 @@ typedef conditional<_LIBCPP_CONTENTION_LOCK_FREE, __cxx_contention_t, char>::typ + typedef conditional<_LIBCPP_CONTENTION_LOCK_FREE, __cxx_contention_t, unsigned char>::type __libcpp_unsigned_lock_free; + #else + // No signed/unsigned lock-free types ++#define _LIBCPP_NO_LOCK_FREE_TYPES + #endif + ++#if !defined(_LIBCPP_NO_LOCK_FREE_TYPES) + typedef atomic<__libcpp_signed_lock_free> atomic_signed_lock_free; + typedef atomic<__libcpp_unsigned_lock_free> atomic_unsigned_lock_free; ++#endif + + #define ATOMIC_FLAG_INIT {false} + #define ATOMIC_VAR_INIT(__v) {__v} +-- +2.32.0 + diff --git a/libs/libxx/libcxx.defs b/libs/libxx/libcxx.defs index 42b4c004cdebb..c79a5eb82c8ba 100644 --- a/libs/libxx/libcxx.defs +++ b/libs/libxx/libcxx.defs @@ -29,6 +29,10 @@ libcxx: libcxx-$(LIBCXX_VERSION).src.tar.xz $(Q) mv libcxx-$(LIBCXX_VERSION).src libcxx $(Q) patch -p0 < 0001-Remove-the-locale-fallback-for-NuttX.patch $(Q) patch -p0 < 0001-libc-avoid-the-waring-__EXCEPTIONS-is-not-defined-ev.patch + $(Q) patch -p1 < 0001-libcxx-Rename-PS-macro-to-avoid-clashing-with-Xtensa.patch +ifeq ($(CONFIG_LIBC_ARCH_ATOMIC),y) + $(Q) patch -p1 < 0002-Omit-atomic_-un-signed_lock_free-if-unsupported.patch +endif $(Q) touch $@ $(TOPDIR)/include/libcxx: libcxx @@ -41,7 +45,7 @@ distclean:: $(Q) $(DIRUNLINK) $(TOPDIR)/include/libcxx $(call DELDIR, libcxx) -CXXFLAGS += ${shell $(DEFINE) "$(CC)" _LIBCPP_BUILDING_LIBRARY} +CXXFLAGS += -std=c++17 ${shell $(DEFINE) "$(CC)" _LIBCPP_BUILDING_LIBRARY} ifeq ($(CONFIG_LIBSUPCXX), y) CXXFLAGS += ${shell $(DEFINE) "$(CC)" __GLIBCXX__} diff --git a/mm/mm_heap/mm.h b/mm/mm_heap/mm.h index af89268a50faa..9ea235ecd3e06 100644 --- a/mm/mm_heap/mm.h +++ b/mm/mm_heap/mm.h @@ -124,15 +124,14 @@ #define MM_ALIGN_UP(a) (((a) + MM_GRAN_MASK) & ~MM_GRAN_MASK) #define MM_ALIGN_DOWN(a) ((a) & ~MM_GRAN_MASK) -/* An allocated chunk is distinguished from a free chunk by bit 31 (or 15) +/* An allocated chunk is distinguished from a free chunk by bit 0 * of the 'preceding' chunk size. If set, then this is an allocated chunk. */ +#define MM_ALLOC_BIT 0x1 #ifdef CONFIG_MM_SMALL -# define MM_ALLOC_BIT 0x8000 # define MMSIZE_MAX UINT16_MAX #else -# define MM_ALLOC_BIT 0x80000000 # define MMSIZE_MAX UINT32_MAX #endif diff --git a/mm/mm_heap/mm_initialize.c b/mm/mm_heap/mm_initialize.c index e32c63cdac95c..df28679764cd9 100644 --- a/mm/mm_heap/mm_initialize.c +++ b/mm/mm_heap/mm_initialize.c @@ -93,11 +93,15 @@ void mm_addregion(FAR struct mm_heap_s *heap, FAR void *heapstart, DEBUGVERIFY(mm_takesemaphore(heap)); - /* Adjust the provided heap start and size so that they are both aligned - * with the MM_MIN_CHUNK size. + /* Adjust the provided heap start and size. + * + * Note: (uintptr_t)node + SIZEOF_MM_ALLOCNODE is what's actually + * returned to the malloc user, which should have natural alignment. + * (that is, in this implementation, MM_MIN_CHUNK-alignment.) */ - heapbase = MM_ALIGN_UP((uintptr_t)heapstart); + heapbase = MM_ALIGN_UP((uintptr_t)heapstart + 2 * SIZEOF_MM_ALLOCNODE) - + 2 * SIZEOF_MM_ALLOCNODE; heapend = MM_ALIGN_DOWN((uintptr_t)heapstart + (uintptr_t)heapsize); heapsize = heapend - heapbase; diff --git a/net/arp/arp_send.c b/net/arp/arp_send.c index 31d84c6fb4abb..174aa933a847b 100644 --- a/net/arp/arp_send.c +++ b/net/arp/arp_send.c @@ -289,7 +289,7 @@ int arp_send(in_addr_t ipaddr) /* Remember the routing device name */ - strncpy((FAR char *)state.snd_ifname, (FAR const char *)dev->d_ifname, + strlcpy((FAR char *)state.snd_ifname, (FAR const char *)dev->d_ifname, IFNAMSIZ); /* Now loop, testing if the address mapping is in the ARP table and re- diff --git a/net/devif/devif_iobsend.c b/net/devif/devif_iobsend.c index d83bd292db858..496bb1df8fb05 100644 --- a/net/devif/devif_iobsend.c +++ b/net/devif/devif_iobsend.c @@ -55,7 +55,12 @@ void devif_iob_send(FAR struct net_driver_s *dev, FAR struct iob_s *iob, unsigned int len, unsigned int offset) { - DEBUGASSERT(dev && len > 0 && len < NETDEV_PKTSIZE(dev)); + if (dev == NULL || len == 0 || len >= NETDEV_PKTSIZE(dev)) + { + nerr("devif_iob_send error, %p, send len: %u, pkt len: %u\n", + dev, len, NETDEV_PKTSIZE(dev)); + return; + } /* Copy the data from the I/O buffer chain to the device buffer */ diff --git a/net/icmp/Make.defs b/net/icmp/Make.defs index 0a0c23082ab5a..6586ca3f916a9 100644 --- a/net/icmp/Make.defs +++ b/net/icmp/Make.defs @@ -27,7 +27,7 @@ NET_CSRCS += icmp_input.c icmp_reply.c ifeq ($(CONFIG_NET_ICMP_SOCKET),y) SOCK_CSRCS += icmp_sockif.c icmp_poll.c icmp_conn.c icmp_sendmsg.c -SOCK_CSRCS += icmp_recvmsg.c icmp_netpoll.c +SOCK_CSRCS += icmp_recvmsg.c icmp_netpoll.c icmp_ioctl.c endif # Include ICMP build support diff --git a/net/icmp/icmp.h b/net/icmp/icmp.h index 7c6a36862a4a7..6015804abb69b 100644 --- a/net/icmp/icmp.h +++ b/net/icmp/icmp.h @@ -380,6 +380,25 @@ int icmp_pollteardown(FAR struct socket *psock, FAR struct pollfd *fds); void icmp_reply(FAR struct net_driver_s *dev, int type, int code); +/**************************************************************************** + * Name: icmp_ioctl + * + * Description: + * This function performs icmp specific ioctl() operations. + * + * Parameters: + * conn The ICMP connection of interest + * cmd The ioctl command + * arg The argument of the ioctl cmd + * arglen The length of 'arg' + * + ****************************************************************************/ + +#ifdef CONFIG_NET_ICMP_SOCKET +int icmp_ioctl(FAR struct socket *psock, + int cmd, FAR void *arg, size_t arglen); +#endif + #undef EXTERN #ifdef __cplusplus } diff --git a/net/icmp/icmp_ioctl.c b/net/icmp/icmp_ioctl.c new file mode 100644 index 0000000000000..dba9be4256637 --- /dev/null +++ b/net/icmp/icmp_ioctl.c @@ -0,0 +1,90 @@ +/**************************************************************************** + * net/icmp/icmp_ioctl.c + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include +#include +#include +#include + +#include + +#include +#include +#include + +#include "icmp/icmp.h" + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: icmp_ioctl + * + * Description: + * This function performs icmp specific ioctl() operations. + * + * Parameters: + * conn The ICMP connection of interest + * cmd The ioctl command + * arg The argument of the ioctl cmd + * arglen The length of 'arg' + * + ****************************************************************************/ + +int icmp_ioctl(FAR struct socket *psock, + int cmd, FAR void *arg, size_t arglen) +{ + FAR struct icmp_conn_s *conn = psock->s_conn; + int ret = OK; + + net_lock(); + + switch (cmd) + { + case FIONREAD: + if (iob_peek_queue(&conn->readahead) != NULL) + { + *(FAR int *)((uintptr_t)arg) = + iob_peek_queue(&conn->readahead)->io_pktlen; + } + else + { + *(FAR int *)((uintptr_t)arg) = 0; + } + break; + case FIONSPACE: + *(FAR int *)((uintptr_t)arg) = MIN_UDP_MSS; + break; + default: + ret = -ENOTTY; + break; + } + + net_unlock(); + + return ret; +} diff --git a/net/icmp/icmp_sockif.c b/net/icmp/icmp_sockif.c index 6985ada6da614..8e1e596ac672a 100644 --- a/net/icmp/icmp_sockif.c +++ b/net/icmp/icmp_sockif.c @@ -81,7 +81,8 @@ const struct sock_intf_s g_icmp_sockif = icmp_netpoll, /* si_poll */ icmp_sendmsg, /* si_sendmsg */ icmp_recvmsg, /* si_recvmsg */ - icmp_close /* si_close */ + icmp_close, /* si_close */ + icmp_ioctl /* si_ioctl */ }; /**************************************************************************** diff --git a/net/icmpv6/Make.defs b/net/icmpv6/Make.defs index 4f71904235429..6bf01acf5af40 100644 --- a/net/icmpv6/Make.defs +++ b/net/icmpv6/Make.defs @@ -28,7 +28,7 @@ NET_CSRCS += icmpv6_linkipaddr.c icmpv6_reply.c ifeq ($(CONFIG_NET_ICMPv6_SOCKET),y) SOCK_CSRCS += icmpv6_sockif.c icmpv6_conn.c icmpv6_sendmsg.c -SOCK_CSRCS += icmpv6_recvmsg.c icmpv6_netpoll.c +SOCK_CSRCS += icmpv6_recvmsg.c icmpv6_netpoll.c icmpv6_ioctl.c endif ifeq ($(CONFIG_NET_ICMPv6_NEIGHBOR),y) diff --git a/net/icmpv6/icmpv6.h b/net/icmpv6/icmpv6.h index 38e1170107f35..1e3fbbe2e0d9f 100644 --- a/net/icmpv6/icmpv6.h +++ b/net/icmpv6/icmpv6.h @@ -746,6 +746,25 @@ void icmpv6_linkipaddr(FAR struct net_driver_s *dev, net_ipv6addr_t ipaddr); void icmpv6_reply(FAR struct net_driver_s *dev, int type, int code, int data); +/**************************************************************************** + * Name: icmpv6_ioctl + * + * Description: + * This function performs icmp specific ioctl() operations. + * + * Parameters: + * conn The ICMP connection of interest + * cmd The ioctl command + * arg The argument of the ioctl cmd + * arglen The length of 'arg' + * + ****************************************************************************/ + +#ifdef CONFIG_NET_ICMPv6_SOCKET +int icmpv6_ioctl(FAR struct socket *psock, + int cmd, FAR void *arg, size_t arglen); +#endif + #undef EXTERN #ifdef __cplusplus } diff --git a/net/icmpv6/icmpv6_ioctl.c b/net/icmpv6/icmpv6_ioctl.c new file mode 100644 index 0000000000000..28cd658b277c3 --- /dev/null +++ b/net/icmpv6/icmpv6_ioctl.c @@ -0,0 +1,90 @@ +/**************************************************************************** + * net/icmpv6/icmpv6_ioctl.c + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include +#include +#include +#include + +#include + +#include +#include +#include + +#include "icmpv6/icmpv6.h" + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: icmpv6_ioctl + * + * Description: + * This function performs icmpv6 specific ioctl() operations. + * + * Parameters: + * conn The icmpv6 connection of interest + * cmd The ioctl command + * arg The argument of the ioctl cmd + * arglen The length of 'arg' + * + ****************************************************************************/ + +int icmpv6_ioctl(FAR struct socket *psock, + int cmd, FAR void *arg, size_t arglen) +{ + FAR struct icmpv6_conn_s *conn = psock->s_conn; + int ret = OK; + + net_lock(); + + switch (cmd) + { + case FIONREAD: + if (iob_peek_queue(&conn->readahead) != NULL) + { + *(FAR int *)((uintptr_t)arg) = + iob_peek_queue(&conn->readahead)->io_pktlen; + } + else + { + *(FAR int *)((uintptr_t)arg) = 0; + } + break; + case FIONSPACE: + *(FAR int *)((uintptr_t)arg) = MIN_UDP_MSS; + break; + default: + ret = -ENOTTY; + break; + } + + net_unlock(); + + return ret; +} diff --git a/net/icmpv6/icmpv6_sockif.c b/net/icmpv6/icmpv6_sockif.c index a0a5456673066..dc28d27920b04 100644 --- a/net/icmpv6/icmpv6_sockif.c +++ b/net/icmpv6/icmpv6_sockif.c @@ -81,7 +81,8 @@ const struct sock_intf_s g_icmpv6_sockif = icmpv6_netpoll, /* si_poll */ icmpv6_sendmsg, /* si_sendmsg */ icmpv6_recvmsg, /* si_recvmsg */ - icmpv6_close /* si_close */ + icmpv6_close, /* si_close */ + icmpv6_ioctl /* si_ioctl */ }; /**************************************************************************** diff --git a/net/local/local_listen.c b/net/local/local_listen.c index 409bf1c33694f..c6ffbe85cb587 100644 --- a/net/local/local_listen.c +++ b/net/local/local_listen.c @@ -96,7 +96,11 @@ int local_listen(FAR struct socket *psock, int backlog) /* Set the backlog value */ - DEBUGASSERT((unsigned)backlog < 256); + if (backlog > UINT8_MAX) + { + backlog = UINT8_MAX; + } + server->u.server.lc_backlog = backlog; /* Is this the first time since being bound to an address and that diff --git a/net/local/local_netpoll.c b/net/local/local_netpoll.c index fdf0fda5ebea3..741ffb2060ce2 100644 --- a/net/local/local_netpoll.c +++ b/net/local/local_netpoll.c @@ -135,7 +135,7 @@ void local_event_pollnotify(FAR struct local_conn_s *conn, fds->revents |= (fds->events & eventset); if (fds->revents != 0) { - ninfo("Report events: %02x\n", fds->revents); + ninfo("Report events: %08" PRIx32 "\n", fds->revents); nxsem_post(fds->sem); } } diff --git a/net/netdev/netdev_ifconf.c b/net/netdev/netdev_ifconf.c index 513ec6e9c84c9..360228468d24f 100644 --- a/net/netdev/netdev_ifconf.c +++ b/net/netdev/netdev_ifconf.c @@ -122,7 +122,7 @@ static int ifconf_ipv4_callback(FAR struct net_driver_s *dev, FAR void *arg) * transferred is returned in ifc_len. */ - strncpy(req->ifr_name, dev->d_ifname, IFNAMSIZ); + strlcpy(req->ifr_name, dev->d_ifname, IFNAMSIZ); inaddr->sin_family = AF_INET; inaddr->sin_port = 0; diff --git a/net/netdev/netdev_ioctl.c b/net/netdev/netdev_ioctl.c index 21d156afc5836..e3243be15c9f7 100644 --- a/net/netdev/netdev_ioctl.c +++ b/net/netdev/netdev_ioctl.c @@ -1086,7 +1086,7 @@ static int netdev_ifr_ioctl(FAR struct socket *psock, int cmd, dev = netdev_findbyindex(req->ifr_ifindex); if (dev != NULL) { - strncpy(req->ifr_name, dev->d_ifname, IFNAMSIZ); + strlcpy(req->ifr_name, dev->d_ifname, IFNAMSIZ); ret = OK; } else @@ -1522,7 +1522,7 @@ static int netdev_file_ioctl(FAR struct socket *psock, int cmd, conn->s_flags &= ~_SF_NONBLOCK; } - ret = OK; + ret = -ENOTTY; /* let file_vioctl update f_oflags */ } else { diff --git a/net/netdev/netdev_register.c b/net/netdev/netdev_register.c index 0aefec673d9dd..c44510ee8296f 100644 --- a/net/netdev/netdev_register.c +++ b/net/netdev/netdev_register.c @@ -399,7 +399,7 @@ int netdev_register(FAR struct net_driver_s *dev, enum net_lltype_e lltype) */ dev->d_ifname[IFNAMSIZ - 1] = '\0'; - strncpy(devfmt_str, dev->d_ifname, IFNAMSIZ); + strlcpy(devfmt_str, dev->d_ifname, IFNAMSIZ); /* Then use the content of the temporary buffer as the format * string. diff --git a/net/netlink/netlink_route.c b/net/netlink/netlink_route.c index eb0e9035c7e04..4e09229bbc270 100644 --- a/net/netlink/netlink_route.c +++ b/net/netlink/netlink_route.c @@ -217,7 +217,7 @@ netlink_get_device(FAR struct net_driver_s *dev, resp->attr.rta_len = RTA_LENGTH(strnlen(dev->d_ifname, IFNAMSIZ)); resp->attr.rta_type = IFLA_IFNAME; - strncpy((FAR char *)resp->data, dev->d_ifname, IFNAMSIZ); + strlcpy((FAR char *)resp->data, dev->d_ifname, IFNAMSIZ); /* Finally, return the response */ diff --git a/net/route/net_cacheroute.c b/net/route/net_cacheroute.c index c6629b75acfc1..5f6dd12ce7417 100644 --- a/net/route/net_cacheroute.c +++ b/net/route/net_cacheroute.c @@ -180,8 +180,8 @@ static sem_t g_ipv6_cachelock = SEM_INITIALIZER(1); * ****************************************************************************/ -#define net_unlock_ipv4_cache() (void)nxsem_post(&g_ipv4_cachelock) -#define net_unlock_ipv6_cache() (void)nxsem_post(&g_ipv6_cachelock) +#define net_unlock_ipv4_cache() nxsem_post(&g_ipv4_cachelock) +#define net_unlock_ipv6_cache() nxsem_post(&g_ipv6_cachelock) /**************************************************************************** * Name: net_add_newest_ipv4 and net_add_newest_ipv6 diff --git a/net/rpmsg/Kconfig b/net/rpmsg/Kconfig index 4dca6f99fcf68..bb57f5c75e75c 100644 --- a/net/rpmsg/Kconfig +++ b/net/rpmsg/Kconfig @@ -8,6 +8,7 @@ menu "Rpmsg Socket Support" config NET_RPMSG bool "Rpmsg domain (remote) sockets" + depends on RPTUN select MM_CIRCBUF default n ---help--- diff --git a/net/rpmsg/rpmsg_sockif.c b/net/rpmsg/rpmsg_sockif.c index f7c8eb5f47921..08aca79045f3a 100644 --- a/net/rpmsg/rpmsg_sockif.c +++ b/net/rpmsg/rpmsg_sockif.c @@ -517,8 +517,10 @@ static void rpmsg_socket_ns_bind(FAR struct rpmsg_device *rdev, return; } - strcpy(new->rpaddr.rp_cpu, rpmsg_get_cpuname(rdev)); - strcpy(new->rpaddr.rp_name, name + RPMSG_SOCKET_NAME_PREFIX_LEN); + strlcpy(new->rpaddr.rp_cpu, rpmsg_get_cpuname(rdev), + sizeof(new->rpaddr.rp_cpu)); + strlcpy(new->rpaddr.rp_name, name + RPMSG_SOCKET_NAME_PREFIX_LEN, + sizeof(new->rpaddr.rp_name)); rpmsg_socket_lock(&server->recvlock); diff --git a/net/socket/connect.c b/net/socket/connect.c index 8b14821f88a96..da3bfff4fb4e5 100644 --- a/net/socket/connect.c +++ b/net/socket/connect.c @@ -140,15 +140,7 @@ int psock_connect(FAR struct socket *psock, FAR const struct sockaddr *addr, if (ret >= 0) { FAR struct socket_conn_s *conn = psock->s_conn; - - if (addr != NULL) - { - conn->s_flags |= _SF_CONNECTED; - } - else - { - conn->s_flags &= ~_SF_CONNECTED; - } + conn->s_flags |= _SF_CONNECTED; } return ret; diff --git a/net/tcp/tcp.h b/net/tcp/tcp.h index b45e888ba9f10..308885ddd325c 100644 --- a/net/tcp/tcp.h +++ b/net/tcp/tcp.h @@ -1617,6 +1617,24 @@ FAR struct tcp_wrbuffer_s *tcp_wrbuffer_tryalloc(void); void tcp_wrbuffer_release(FAR struct tcp_wrbuffer_s *wrb); #endif /* CONFIG_NET_TCP_WRITE_BUFFERS */ +/**************************************************************************** + * Name: tcp_wrbuffer_inqueue_size + * + * Description: + * Get the in-queued write buffer size from connection + * + * Input Parameters: + * conn - The TCP connection of interest + * + * Assumptions: + * Called from user logic with the network locked. + * + ****************************************************************************/ + +#if CONFIG_NET_SEND_BUFSIZE > 0 +uint32_t tcp_wrbuffer_inqueue_size(FAR struct tcp_conn_s *conn); +#endif + /**************************************************************************** * Name: tcp_wrbuffer_test * diff --git a/net/tcp/tcp_conn.c b/net/tcp/tcp_conn.c index b74f7620c7eb4..bb93d0d43de38 100644 --- a/net/tcp/tcp_conn.c +++ b/net/tcp/tcp_conn.c @@ -49,6 +49,7 @@ #include #include #include +#include #include @@ -201,12 +202,26 @@ static int tcp_selectport(uint8_t domain, uint16_t portno) { static uint16_t g_last_tcp_port; + ssize_t ret; /* Generate port base dynamically */ if (g_last_tcp_port == 0) { - g_last_tcp_port = clock_systime_ticks() % 32000; + ret = getrandom(&g_last_tcp_port, sizeof(uint16_t), 0); + if (ret < 0) + { + ret = getrandom(&g_last_tcp_port, sizeof(uint16_t), GRND_RANDOM); + } + + if (ret != sizeof(uint16_t)) + { + g_last_tcp_port = clock_systime_ticks() % 32000; + } + else + { + g_last_tcp_port = g_last_tcp_port % 32000; + } if (g_last_tcp_port < 4096) { diff --git a/net/tcp/tcp_ioctl.c b/net/tcp/tcp_ioctl.c index af5bb985e04f2..9ebd4b50a36ee 100644 --- a/net/tcp/tcp_ioctl.c +++ b/net/tcp/tcp_ioctl.c @@ -74,6 +74,19 @@ int tcp_ioctl(FAR struct tcp_conn_s *conn, *(FAR int *)((uintptr_t)arg) = 0; } break; + case FIONSPACE: +#ifdef CONFIG_NET_TCP_WRITE_BUFFERS +# if CONFIG_NET_SEND_BUFSIZE == 0 + *(FAR int *)((uintptr_t)arg) = + iob_navail(true) * CONFIG_IOB_BUFSIZE; +# else + *(FAR int *)((uintptr_t)arg) = + conn->snd_bufs - tcp_wrbuffer_inqueue_size(conn); +# endif +#else + *(FAR int *)((uintptr_t)arg) = MIN_TCP_MSS; +#endif + break; default: ret = -ENOTTY; break; diff --git a/net/tcp/tcp_send_buffered.c b/net/tcp/tcp_send_buffered.c index cb5c62fb7ccb0..c5aac33db83fb 100644 --- a/net/tcp/tcp_send_buffered.c +++ b/net/tcp/tcp_send_buffered.c @@ -94,46 +94,6 @@ * Private Functions ****************************************************************************/ -/**************************************************************************** - * Name: tcp_inqueue_wrb_size - * - * Description: - * Get the in-queued write buffer size from connection - * - * Input Parameters: - * conn - The TCP connection of interest - * - * Assumptions: - * Called from user logic with the network locked. - * - ****************************************************************************/ - -#if CONFIG_NET_SEND_BUFSIZE > 0 -static uint32_t tcp_inqueue_wrb_size(FAR struct tcp_conn_s *conn) -{ - FAR struct tcp_wrbuffer_s *wrb; - FAR sq_entry_t *entry; - uint32_t total = 0; - - if (conn) - { - for (entry = sq_peek(&conn->unacked_q); entry; entry = sq_next(entry)) - { - wrb = (FAR struct tcp_wrbuffer_s *)entry; - total += TCP_WBPKTLEN(wrb); - } - - for (entry = sq_peek(&conn->write_q); entry; entry = sq_next(entry)) - { - wrb = (FAR struct tcp_wrbuffer_s *)entry; - total += TCP_WBPKTLEN(wrb); - } - } - - return total; -} -#endif /* CONFIG_NET_SEND_BUFSIZE */ - /**************************************************************************** * Name: psock_insert_segment * @@ -1223,7 +1183,7 @@ ssize_t psock_tcp_send(FAR struct socket *psock, FAR const void *buf, * wait for the write buffer to be released */ - while (tcp_inqueue_wrb_size(conn) >= conn->snd_bufs) + while (tcp_wrbuffer_inqueue_size(conn) >= conn->snd_bufs) { if (nonblock) { diff --git a/net/tcp/tcp_wrbuffer.c b/net/tcp/tcp_wrbuffer.c index bc2644f1e163d..f3e7beee6d00f 100644 --- a/net/tcp/tcp_wrbuffer.c +++ b/net/tcp/tcp_wrbuffer.c @@ -249,6 +249,46 @@ void tcp_wrbuffer_release(FAR struct tcp_wrbuffer_s *wrb) nxsem_post(&g_wrbuffer.sem); } +/**************************************************************************** + * Name: tcp_wrbuffer_inqueue_size + * + * Description: + * Get the in-queued write buffer size from connection + * + * Input Parameters: + * conn - The TCP connection of interest + * + * Assumptions: + * Called from user logic with the network locked. + * + ****************************************************************************/ + +#if CONFIG_NET_SEND_BUFSIZE > 0 +uint32_t tcp_wrbuffer_inqueue_size(FAR struct tcp_conn_s *conn) +{ + FAR struct tcp_wrbuffer_s *wrb; + FAR sq_entry_t *entry; + uint32_t total = 0; + + if (conn) + { + for (entry = sq_peek(&conn->unacked_q); entry; entry = sq_next(entry)) + { + wrb = (FAR struct tcp_wrbuffer_s *)entry; + total += TCP_WBPKTLEN(wrb); + } + + for (entry = sq_peek(&conn->write_q); entry; entry = sq_next(entry)) + { + wrb = (FAR struct tcp_wrbuffer_s *)entry; + total += TCP_WBPKTLEN(wrb); + } + } + + return total; +} +#endif /* CONFIG_NET_SEND_BUFSIZE */ + /**************************************************************************** * Name: tcp_wrbuffer_test * diff --git a/net/udp/udp.h b/net/udp/udp.h index 4f6ce5973dbb5..03daa0ae259da 100644 --- a/net/udp/udp.h +++ b/net/udp/udp.h @@ -510,6 +510,24 @@ FAR struct udp_wrbuffer_s *udp_wrbuffer_tryalloc(void); void udp_wrbuffer_release(FAR struct udp_wrbuffer_s *wrb); #endif /* CONFIG_NET_UDP_WRITE_BUFFERS */ +/**************************************************************************** + * Name: udp_wrbuffer_inqueue_size + * + * Description: + * Get the in-queued write buffer size from connection + * + * Input Parameters: + * conn - The UDP connection of interest + * + * Assumptions: + * Called from user logic with the network locked. + * + ****************************************************************************/ + +#if CONFIG_NET_SEND_BUFSIZE > 0 +uint32_t udp_wrbuffer_inqueue_size(FAR struct udp_conn_s *conn); +#endif /* CONFIG_NET_SEND_BUFSIZE */ + /**************************************************************************** * Name: udp_wrbuffer_test * diff --git a/net/udp/udp_ioctl.c b/net/udp/udp_ioctl.c index bb458f38bb711..9968c608f9a2b 100644 --- a/net/udp/udp_ioctl.c +++ b/net/udp/udp_ioctl.c @@ -76,6 +76,19 @@ int udp_ioctl(FAR struct udp_conn_s *conn, *(FAR int *)((uintptr_t)arg) = 0; } break; + case FIONSPACE: +#ifdef CONFIG_NET_UDP_WRITE_BUFFERS +# if CONFIG_NET_SEND_BUFSIZE == 0 + *(FAR int *)((uintptr_t)arg) = + iob_navail(true) * CONFIG_IOB_BUFSIZE; +# else + *(FAR int *)((uintptr_t)arg) = + conn->sndbufs - udp_wrbuffer_inqueue_size(conn); +# endif +#else + *(FAR int *)((uintptr_t)arg) = MIN_UDP_MSS; +#endif + break; default: ret = -ENOTTY; break; diff --git a/net/udp/udp_recvfrom.c b/net/udp/udp_recvfrom.c index e6364fc103cbc..076c7d739b18d 100644 --- a/net/udp/udp_recvfrom.c +++ b/net/udp/udp_recvfrom.c @@ -244,6 +244,7 @@ static inline void udp_readahead(struct udp_recvfrom_s *pstate) pstate->ir_recvlen = recvlen; pstate->ir_buffer += recvlen; pstate->ir_buflen -= recvlen; + *pstate->ir_fromlen = src_addr_size; } else { @@ -320,6 +321,7 @@ static inline void udp_sender(FAR struct net_driver_s *dev, { FAR struct sockaddr_in *infrom = (FAR struct sockaddr_in *)pstate->ir_from; + FAR socklen_t *fromlen = pstate->ir_fromlen; if (infrom) { @@ -334,7 +336,6 @@ static inline void udp_sender(FAR struct net_driver_s *dev, { FAR struct sockaddr_in6 *infrom6 = (FAR struct sockaddr_in6 *)infrom; - FAR socklen_t *fromlen = pstate->ir_fromlen; FAR struct udp_hdr_s *udp = UDPIPv6BUF; FAR struct ipv6_hdr_s *ipv6 = IPv6BUF; in_addr_t ipv4addr; @@ -356,6 +357,7 @@ static inline void udp_sender(FAR struct net_driver_s *dev, infrom->sin_family = AF_INET; infrom->sin_port = udp->srcport; + *fromlen = sizeof(struct sockaddr_in); net_ipv4addr_copy(infrom->sin_addr.s_addr, net_ip4addr_conv32(ipv4->srcipaddr)); diff --git a/net/udp/udp_sendto_buffered.c b/net/udp/udp_sendto_buffered.c index 0f2b2fc749116..470451ca55242 100644 --- a/net/udp/udp_sendto_buffered.c +++ b/net/udp/udp_sendto_buffered.c @@ -104,40 +104,6 @@ static uint16_t sendto_eventhandler(FAR struct net_driver_s *dev, * Private Functions ****************************************************************************/ -/**************************************************************************** - * Name: udp_inqueue_wrb_size - * - * Description: - * Get the in-queued write buffer size from connection - * - * Input Parameters: - * conn - The UDP connection of interest - * - * Assumptions: - * Called from user logic with the network locked. - * - ****************************************************************************/ - -#if CONFIG_NET_SEND_BUFSIZE > 0 -static uint32_t udp_inqueue_wrb_size(FAR struct udp_conn_s *conn) -{ - FAR struct udp_wrbuffer_s *wrb; - FAR sq_entry_t *entry; - uint32_t total = 0; - - if (conn) - { - for (entry = sq_peek(&conn->write_q); entry; entry = sq_next(entry)) - { - wrb = (FAR struct udp_wrbuffer_s *)entry; - total += wrb->wb_iob->io_pktlen; - } - } - - return total; -} -#endif /* CONFIG_NET_SEND_BUFSIZE */ - /**************************************************************************** * Name: sendto_writebuffer_release * @@ -676,7 +642,7 @@ ssize_t psock_udp_sendto(FAR struct socket *psock, FAR const void *buf, * wait for the write buffer to be released */ - while (udp_inqueue_wrb_size(conn) + len > conn->sndbufs) + while (udp_wrbuffer_inqueue_size(conn) + len > conn->sndbufs) { if (nonblock) { diff --git a/net/udp/udp_wrbuffer.c b/net/udp/udp_wrbuffer.c index 9e7b7c7fdb4d5..c8aa2f8e4a186 100644 --- a/net/udp/udp_wrbuffer.c +++ b/net/udp/udp_wrbuffer.c @@ -243,6 +243,40 @@ void udp_wrbuffer_release(FAR struct udp_wrbuffer_s *wrb) nxsem_post(&g_wrbuffer.sem); } +/**************************************************************************** + * Name: udp_wrbuffer_inqueue_size + * + * Description: + * Get the in-queued write buffer size from connection + * + * Input Parameters: + * conn - The UDP connection of interest + * + * Assumptions: + * Called from user logic with the network locked. + * + ****************************************************************************/ + +#if CONFIG_NET_SEND_BUFSIZE > 0 +uint32_t udp_wrbuffer_inqueue_size(FAR struct udp_conn_s *conn) +{ + FAR struct udp_wrbuffer_s *wrb; + FAR sq_entry_t *entry; + uint32_t total = 0; + + if (conn) + { + for (entry = sq_peek(&conn->write_q); entry; entry = sq_next(entry)) + { + wrb = (FAR struct udp_wrbuffer_s *)entry; + total += wrb->wb_iob->io_pktlen; + } + } + + return total; +} +#endif /* CONFIG_NET_SEND_BUFSIZE */ + /**************************************************************************** * Name: udp_wrbuffer_test * diff --git a/net/usrsock/usrsock_dev.c b/net/usrsock/usrsock_dev.c index 9d92cb6bd9e8f..9102c4950c3ab 100644 --- a/net/usrsock/usrsock_dev.c +++ b/net/usrsock/usrsock_dev.c @@ -143,7 +143,7 @@ static ssize_t iovec_do(FAR void *srcdst, size_t srcdstlen, /* Rewind to correct position. */ - while (pos > 0 && iovcnt > 0) + while (pos >= 0 && iovcnt > 0) { if (iov->iov_len <= pos) { @@ -295,7 +295,7 @@ static void usrsockdev_pollnotify(FAR struct usrsockdev_s *dev, fds->revents |= (fds->events & eventset); if (fds->revents != 0) { - ninfo("Report events: %02x\n", fds->revents); + ninfo("Report events: %08" PRIx32 "\n", fds->revents); nxsem_post(fds->sem); } } @@ -479,13 +479,13 @@ static ssize_t usrsockdev_handle_event(FAR struct usrsockdev_s *dev, #ifdef CONFIG_DEV_RANDOM /* Add randomness. */ - add_sw_randomness((hdr->events << 16) - hdr->usockid); + add_sw_randomness((hdr->head.events << 16) - hdr->usockid); #endif /* Handle event. */ ret = usrsock_event(conn, - hdr->events & ~USRSOCK_EVENT_INTERNAL_MASK); + hdr->head.events & ~USRSOCK_EVENT_INTERNAL_MASK); if (ret < 0) { return ret; diff --git a/net/usrsock/usrsock_ioctl.c b/net/usrsock/usrsock_ioctl.c index 0075ed16112bd..f77c563fd4d28 100644 --- a/net/usrsock/usrsock_ioctl.c +++ b/net/usrsock/usrsock_ioctl.c @@ -34,7 +34,9 @@ #include #include #include - +#ifdef CONFIG_NETDEV_WIRELESS_IOCTL +# include +#endif #include "socket/socket.h" #include "usrsock/usrsock.h" @@ -107,7 +109,9 @@ static int do_ioctl_request(FAR struct usrsock_conn_s *conn, int cmd, { }; - struct iovec bufs[2]; + struct iovec bufs[3] = + { + }; if (arglen > UINT16_MAX) { @@ -126,6 +130,15 @@ static int do_ioctl_request(FAR struct usrsock_conn_s *conn, int cmd, bufs[1].iov_base = (FAR void *)arg; bufs[1].iov_len = req.arglen; +#ifdef CONFIG_NETDEV_WIRELESS_IOCTL + if (WL_IS80211POINTERCMD(cmd)) + { + FAR struct iwreq *wlreq = arg; + bufs[2].iov_base = wlreq->u.data.pointer; + bufs[2].iov_len = wlreq->u.data.length; + } +#endif + return usrsockdev_do_request(conn, bufs, ARRAY_SIZE(bufs)); } @@ -155,7 +168,10 @@ int usrsock_ioctl(FAR struct socket *psock, int cmd, FAR void *arg, { }; - struct iovec inbufs[1]; + struct iovec inbufs[2] = + { + }; + int ret; net_lock(); @@ -186,6 +202,16 @@ int usrsock_ioctl(FAR struct socket *psock, int cmd, FAR void *arg, inbufs[0].iov_base = arg; inbufs[0].iov_len = arglen; + +#ifdef CONFIG_NETDEV_WIRELESS_IOCTL + if (WL_IS80211POINTERCMD(cmd)) + { + FAR struct iwreq *wlreq = arg; + inbufs[1].iov_base = wlreq->u.data.pointer; + inbufs[1].iov_len = wlreq->u.data.length; + } +#endif + usrsock_setup_datain(conn, inbufs, ARRAY_SIZE(inbufs)); /* Request user-space daemon to handle ioctl. */ diff --git a/openamp/0006-openamp-fix-scenario-case.patch b/openamp/0006-openamp-fix-scenario-case.patch index a9fa95f1bd0b8..0134467825154 100644 --- a/openamp/0006-openamp-fix-scenario-case.patch +++ b/openamp/0006-openamp-fix-scenario-case.patch @@ -1,7 +1,7 @@ -From d14f87ea5ff1371318acaf4539116b72986bae2c Mon Sep 17 00:00:00 2001 +From c2b9d18c72eebe558c6a013bf39818c47cffecc3 Mon Sep 17 00:00:00 2001 From: ligd Date: Thu, 18 Nov 2021 20:54:45 +0800 -Subject: [PATCH] openamp: fix scenario case +Subject: [PATCH 1/3] openamp: fix scenario case description: There are two CPUs use IPC. @@ -43,7 +43,6 @@ Resolve: add recursive call rpmsg_virtio_rx_callback() when get_tx_buffer() failed Signed-off-by: ligd -Change-Id: I60512c50327f180a0aba891e3ec847b211e172db --- lib/include/openamp/remoteproc.h | 10 +++ lib/include/openamp/rpmsg_virtio.h | 6 ++ @@ -53,7 +52,7 @@ Change-Id: I60512c50327f180a0aba891e3ec847b211e172db 5 files changed, 97 insertions(+), 66 deletions(-) diff --git a/lib/include/openamp/remoteproc.h open-amp/lib/include/openamp/remoteproc.h -index a71327b..222079e 100644 +index a71327b..328ec3f 100644 --- a/lib/include/openamp/remoteproc.h +++ open-amp/lib/include/openamp/remoteproc.h @@ -449,6 +449,16 @@ struct remoteproc_ops { @@ -61,56 +60,56 @@ index a71327b..222079e 100644 void *va, size_t size, struct remoteproc_mem *buf); + /** -+ * can_recursive ++ * wait_tx_buffer + * -+ * Check current vdev can do recursive rx_callabck or not ++ * Wait tx buffer available + * + * @rproc - pointer to remoteproc instance + * -+ * return true if can do recursive rx_callabck. ++ * return none + */ -+ int (*can_recursive)(struct remoteproc *rproc); ++ int (*wait_tx_buffer)(struct remoteproc *rproc); }; /* Remoteproc error codes */ diff --git a/lib/include/openamp/rpmsg_virtio.h open-amp/lib/include/openamp/rpmsg_virtio.h -index e552b96..fa556a2 100644 +index e552b96..ac155fb 100644 --- a/lib/include/openamp/rpmsg_virtio.h +++ open-amp/lib/include/openamp/rpmsg_virtio.h @@ -114,6 +114,12 @@ rpmsg_virtio_create_virtqueues(struct rpmsg_virtio_device *rvdev, callbacks); } -+static inline int rpmsg_virtio_can_recursive(struct rpmsg_virtio_device *rvdev) ++static inline int rpmsg_virtio_wait_tx_buffer(struct rpmsg_virtio_device *rvdev) +{ -+ return rvdev->vdev->func->can_recursive ? -+ rvdev->vdev->func->can_recursive(rvdev->vdev) : 0; ++ return rvdev->vdev->func->wait_tx_buffer ? ++ rvdev->vdev->func->wait_tx_buffer(rvdev->vdev) : -EAGAIN; +} + /** * rpmsg_virtio_get_buffer_size - get rpmsg virtio buffer size * diff --git a/lib/include/openamp/virtio.h open-amp/lib/include/openamp/virtio.h -index 55c8ea5..ce808cc 100644 +index 55c8ea5..34bccaa 100644 --- a/lib/include/openamp/virtio.h +++ open-amp/lib/include/openamp/virtio.h @@ -137,6 +137,7 @@ struct virtio_dispatch { void *src, int length); void (*reset_device)(struct virtio_device *dev); void (*notify)(struct virtqueue *vq); -+ int (*can_recursive)(struct virtio_device *dev); ++ int (*wait_tx_buffer)(struct virtio_device *dev); }; int virtio_create_virtqueues(struct virtio_device *vdev, unsigned int flags, diff --git a/lib/remoteproc/remoteproc_virtio.c open-amp/lib/remoteproc/remoteproc_virtio.c -index ed9f33c..937f294 100644 +index ed9f33c..0de31ee 100644 --- a/lib/remoteproc/remoteproc_virtio.c +++ open-amp/lib/remoteproc/remoteproc_virtio.c @@ -30,6 +30,17 @@ static void rproc_virtio_virtqueue_notify(struct virtqueue *vq) rpvdev->notify(rpvdev->priv, vring_info->notifyid); } -+static int rproc_virtio_can_recursive(struct virtio_device *vdev) ++static int rproc_virtio_wait_tx_buffer(struct virtio_device *vdev) +{ + struct remoteproc_virtio *rpvdev; + struct remoteproc *rproc; @@ -118,7 +117,7 @@ index ed9f33c..937f294 100644 + rpvdev = metal_container_of(vdev, struct remoteproc_virtio, vdev); + rproc = rpvdev->priv; + -+ return rproc->ops->can_recursive ? rproc->ops->can_recursive(rproc) : 0; ++ return rproc->ops->wait_tx_buffer ? rproc->ops->wait_tx_buffer(rproc) : -EAGAIN; +} + static unsigned char rproc_virtio_get_status(struct virtio_device *vdev) @@ -128,12 +127,12 @@ index ed9f33c..937f294 100644 .get_features = rproc_virtio_get_features, .read_config = rproc_virtio_read_config, .notify = rproc_virtio_virtqueue_notify, -+ .can_recursive = rproc_virtio_can_recursive, ++ .wait_tx_buffer = rproc_virtio_wait_tx_buffer, #ifndef VIRTIO_SLAVE_ONLY /* * We suppose here that the vdev is in a shared memory so that can diff --git a/lib/rpmsg/rpmsg_virtio.c open-amp/lib/rpmsg/rpmsg_virtio.c -index 2687320..a407be9 100644 +index 2687320..30c3ab3 100644 --- a/lib/rpmsg/rpmsg_virtio.c +++ open-amp/lib/rpmsg/rpmsg_virtio.c @@ -286,6 +286,72 @@ static void rpmsg_virtio_release_rx_buffer(struct rpmsg_device *rdev, @@ -213,8 +212,8 @@ index 2687320..a407be9 100644 metal_mutex_release(&rdev->lock); if (rp_hdr || !tick_count) break; -+ if (rpmsg_virtio_can_recursive(rvdev)) -+ rpmsg_virtio_rx_callback(rvdev->rvq); ++ if (rpmsg_virtio_wait_tx_buffer(rvdev) >= 0) ++ continue; metal_sleep_usec(RPMSG_TICKS_PER_INTERVAL); tick_count--; } diff --git a/openamp/0007-openamp-divide-shram-to-TX-shram-RX-shram.patch b/openamp/0007-openamp-divide-shram-to-TX-shram-RX-shram.patch new file mode 100644 index 0000000000000..012b5ae6267be --- /dev/null +++ b/openamp/0007-openamp-divide-shram-to-TX-shram-RX-shram.patch @@ -0,0 +1,130 @@ +From 0de084b8b7c65502a2339221b59aeaa60edbe8c5 Mon Sep 17 00:00:00 2001 +From: ligd +Date: Mon, 7 Feb 2022 20:36:25 +0800 +Subject: [PATCH 2/3] openamp: divide shram to TX shram & RX shram + +Add new API rpmsg_init_vdev_ext() + +Signed-off-by: ligd +Change-Id: I790cdcf27276ed12a633fab9cc8aefff7c7da830 +--- + lib/include/openamp/rpmsg_virtio.h | 30 +++++++++++++++++++++++++++++ + lib/rpmsg/rpmsg_virtio.c | 31 ++++++++++++++++++++---------- + 2 files changed, 51 insertions(+), 10 deletions(-) + +diff --git a/lib/include/openamp/rpmsg_virtio.h open-amp/lib/include/openamp/rpmsg_virtio.h +index ac155fb..9d6a16e 100644 +--- a/lib/include/openamp/rpmsg_virtio.h ++++ open-amp/lib/include/openamp/rpmsg_virtio.h +@@ -156,6 +156,36 @@ int rpmsg_init_vdev(struct rpmsg_virtio_device *rvdev, + struct metal_io_region *shm_io, + struct rpmsg_virtio_shm_pool *shpool); + ++/** ++ * rpmsg_init_vdev_ext - initialize rpmsg virtio device ++ * Master side: ++ * Initialize RPMsg virtio queues and shared buffers, the address of shm can be ++ * ANY. In this case, function will get shared memory from system shared memory ++ * pools. If the vdev has RPMsg name service feature, this API will create an ++ * name service endpoint. ++ * ++ * Slave side: ++ * This API will not return until the driver ready is set by the master side. ++ * ++ * @param rvdev - pointer to the rpmsg virtio device ++ * @param vdev - pointer to the virtio device ++ * @param ns_bind_cb - callback handler for name service announcement without ++ * local endpoints waiting to bind. ++ * @param shm_io - pointer to the share memory I/O region. ++ * @param tx_shpool - pointer to tx shared memory pool. rpmsg_virtio_init_shm_pool ++ * has to be called first to fill this structure. ++ * @param rx_shpool - pointer to rx shared memory pool. rpmsg_virtio_init_shm_pool ++ * has to be called first to fill this structure. ++ * ++ * @return - status of function execution ++ */ ++int rpmsg_init_vdev_ext(struct rpmsg_virtio_device *rvdev, ++ struct virtio_device *vdev, ++ rpmsg_ns_bind_cb ns_bind_cb, ++ struct metal_io_region *shm_io, ++ struct rpmsg_virtio_shm_pool *tx_shpool, ++ struct rpmsg_virtio_shm_pool *rx_shpool); ++ + /** + * rpmsg_deinit_vdev - deinitialize rpmsg virtio device + * +diff --git a/lib/rpmsg/rpmsg_virtio.c open-amp/lib/rpmsg/rpmsg_virtio.c +index 30c3ab3..8a2c795 100644 +--- a/lib/rpmsg/rpmsg_virtio.c ++++ open-amp/lib/rpmsg/rpmsg_virtio.c +@@ -604,11 +604,12 @@ int rpmsg_virtio_get_buffer_size(struct rpmsg_device *rdev) + return size; + } + +-int rpmsg_init_vdev(struct rpmsg_virtio_device *rvdev, +- struct virtio_device *vdev, +- rpmsg_ns_bind_cb ns_bind_cb, +- struct metal_io_region *shm_io, +- struct rpmsg_virtio_shm_pool *shpool) ++int rpmsg_init_vdev_ext(struct rpmsg_virtio_device *rvdev, ++ struct virtio_device *vdev, ++ rpmsg_ns_bind_cb ns_bind_cb, ++ struct metal_io_region *shm_io, ++ struct rpmsg_virtio_shm_pool *tx_shpool, ++ struct rpmsg_virtio_shm_pool *rx_shpool) + { + struct rpmsg_device *rdev; + const char *vq_names[RPMSG_NUM_VRINGS]; +@@ -654,11 +655,11 @@ int rpmsg_init_vdev(struct rpmsg_virtio_device *rvdev, + * Since device is RPMSG Remote so we need to manage the + * shared buffers. Create shared memory pool to handle buffers. + */ +- if (!shpool) ++ if (!tx_shpool || !rx_shpool) + return RPMSG_ERR_PARAM; +- if (!shpool->size) ++ if (!tx_shpool->size || !rx_shpool->size) + return RPMSG_ERR_NO_BUFF; +- rvdev->shpool = shpool; ++ rvdev->shpool = tx_shpool; + + vq_names[0] = "rx_vq"; + vq_names[1] = "tx_vq"; +@@ -670,7 +671,8 @@ int rpmsg_init_vdev(struct rpmsg_virtio_device *rvdev, + #endif /*!VIRTIO_SLAVE_ONLY*/ + + #ifndef VIRTIO_MASTER_ONLY +- (void)shpool; ++ (void)tx_shpool; ++ (void)rx_shpool; + if (role == RPMSG_REMOTE) { + vq_names[0] = "tx_vq"; + vq_names[1] = "rx_vq"; +@@ -711,7 +713,7 @@ int rpmsg_init_vdev(struct rpmsg_virtio_device *rvdev, + vqbuf.len = rvdev->config.txbuf_size; + for (idx = 0; idx < rvdev->rvq->vq_nentries; idx++) { + /* Initialize TX virtqueue buffers for remote device */ +- buffer = rpmsg_virtio_shm_pool_get_buffer(shpool, ++ buffer = rpmsg_virtio_shm_pool_get_buffer(rx_shpool, + rvdev->config.txbuf_size); + + if (!buffer) { +@@ -757,6 +759,15 @@ int rpmsg_init_vdev(struct rpmsg_virtio_device *rvdev, + return status; + } + ++int rpmsg_init_vdev(struct rpmsg_virtio_device *rvdev, ++ struct virtio_device *vdev, ++ rpmsg_ns_bind_cb ns_bind_cb, ++ struct metal_io_region *shm_io, ++ struct rpmsg_virtio_shm_pool *shpool) ++{ ++ return rpmsg_init_vdev_ext(rvdev, vdev, ns_bind_cb, shm_io, shpool, shpool); ++} ++ + void rpmsg_deinit_vdev(struct rpmsg_virtio_device *rvdev) + { + struct metal_list *node; +-- +2.25.1 + diff --git a/openamp/0008-rpmsg_virtio-don-t-need-check-status-when-get_tx_pay.patch b/openamp/0008-rpmsg_virtio-don-t-need-check-status-when-get_tx_pay.patch new file mode 100644 index 0000000000000..e003c769dac64 --- /dev/null +++ b/openamp/0008-rpmsg_virtio-don-t-need-check-status-when-get_tx_pay.patch @@ -0,0 +1,34 @@ +From 0e2e59941d9694e060f8ac06fce6b8284d8e74ec Mon Sep 17 00:00:00 2001 +From: ligd +Date: Mon, 28 Feb 2022 16:31:54 +0800 +Subject: [PATCH 3/3] rpmsg_virtio: don't need check status when get_tx_payload + +Signed-off-by: ligd +--- + lib/rpmsg/rpmsg_virtio.c | 6 ------ + 1 file changed, 6 deletions(-) + +diff --git a/lib/rpmsg/rpmsg_virtio.c open-amp/lib/rpmsg/rpmsg_virtio.c +index 8a2c795..b95bf6d 100644 +--- a/lib/rpmsg/rpmsg_virtio.c ++++ open-amp/lib/rpmsg/rpmsg_virtio.c +@@ -359,16 +359,10 @@ static void *rpmsg_virtio_get_tx_payload_buffer(struct rpmsg_device *rdev, + struct rpmsg_hdr *rp_hdr; + uint16_t idx; + int tick_count; +- int status; + + /* Get the associated remote device for channel. */ + rvdev = metal_container_of(rdev, struct rpmsg_virtio_device, rdev); + +- /* Validate device state */ +- status = rpmsg_virtio_get_status(rvdev); +- if (!(status & VIRTIO_CONFIG_STATUS_DRIVER_OK)) +- return NULL; +- + if (wait) + tick_count = RPMSG_TICK_COUNT / RPMSG_TICKS_PER_INTERVAL; + else +-- +2.25.1 + diff --git a/openamp/open-amp.defs b/openamp/open-amp.defs index cf0dd8d28f125..8c0053ce6c391 100644 --- a/openamp/open-amp.defs +++ b/openamp/open-amp.defs @@ -39,6 +39,8 @@ open-amp.zip: $(Q) patch -p0 < 0004-openamp-add-ns_unbind_notify-support.patch $(Q) patch -p0 < 0005-rpmsg-notify-the-user-when-the-remote-address-is-rec.patch $(Q) patch -p0 < 0006-openamp-fix-scenario-case.patch + $(Q) patch -p0 < 0007-openamp-divide-shram-to-TX-shram-RX-shram.patch + $(Q) patch -p0 < 0008-rpmsg_virtio-don-t-need-check-status-when-get_tx_pay.patch .openamp_headers: open-amp.zip $(eval headers := $(wildcard open-amp/lib/include/openamp/*.h)) diff --git a/sched/environ/env_dup.c b/sched/environ/env_dup.c index 0a7bbeb7dbf64..f1b351ef4c979 100644 --- a/sched/environ/env_dup.c +++ b/sched/environ/env_dup.c @@ -50,9 +50,9 @@ * private, exact duplicate of the parent task's environment. * * Input Parameters: - * group - The child task group to receive the newly allocated copy of the - * parent task groups environment structure. - * + * group - The child task group to receive the newly allocated copy of + * the parent task groups environment structure. + * envcp - Pointer to the environment strings to copy. * Returned Value: * zero on success * @@ -61,14 +61,14 @@ * ****************************************************************************/ -int env_dup(FAR struct task_group_s *group) +int env_dup(FAR struct task_group_s *group, FAR char * const *envcp) { FAR struct tcb_s *ptcb = this_task(); - FAR char *envp = NULL; - size_t envlen; + FAR char **envp = NULL; + size_t envc = 0; int ret = OK; - DEBUGASSERT(group != NULL && ptcb != NULL && ptcb->group != NULL); + DEBUGASSERT(group != NULL); /* Pre-emption must be disabled throughout the following because the * environment may be shared. @@ -76,46 +76,64 @@ int env_dup(FAR struct task_group_s *group) sched_lock(); - /* Does the parent task have an environment? */ + /* Is there an environment ? */ - if (ptcb->group != NULL && ptcb->group->tg_envp != NULL) + if (envcp || (envcp = ptcb->group->tg_envp)) { - /* Yes.. The parent task has an environment allocation. */ + /* Count the strings */ - envlen = ptcb->group->tg_envsize; - envp = NULL; + while (envcp[envc] != NULL) + { + envc++; + } /* A special case is that the parent has an "empty" environment * allocation, i.e., there is an allocation in place but it - * contains no variable definitions and, hence, envlen == 0. + * contains no variable definitions and, hence, envc == 0. */ - if (envlen > 0) + if (envc > 0) { /* There is an environment, duplicate it */ - envp = (FAR char *)group_malloc(group, envlen); + envp = group_malloc(group, sizeof(*envp) * (envc + 1)); if (envp == NULL) { /* The parent's environment can not be inherited due to a * failure in the allocation of the child environment. */ - envlen = 0; - ret = -ENOMEM; + ret = -ENOMEM; } else { + envp[envc] = NULL; + /* Duplicate the parent environment. */ - memcpy(envp, ptcb->group->tg_envp, envlen); + while (envc-- > 0) + { + envp[envc] = group_malloc(group, strlen(envcp[envc]) + 1); + if (envp[envc] == NULL) + { + while (envp[++envc] != NULL) + { + group_free(group, envp[envc]); + } + + group_free(group, envp); + ret = -ENOMEM; + break; + } + + strcpy(envp[envc], envcp[envc]); + } } } - /* Save the size and child environment allocation. */ + /* Save the child environment allocation. */ - group->tg_envsize = envlen; - group->tg_envp = envp; + group->tg_envp = envp; } sched_unlock(); diff --git a/sched/environ/env_findvar.c b/sched/environ/env_findvar.c index ce7df15d3428d..dfeb8efcad930 100644 --- a/sched/environ/env_findvar.c +++ b/sched/environ/env_findvar.c @@ -75,7 +75,7 @@ static bool env_cmpname(const char *pszname, const char *peqname) * pname - The variable name to find * * Returned Value: - * A pointer to the name=value string in the environment + * A index to the name=value string in the environment * * Assumptions: * - Not called from an interrupt handler @@ -83,25 +83,30 @@ static bool env_cmpname(const char *pszname, const char *peqname) * ****************************************************************************/ -FAR char *env_findvar(FAR struct task_group_s *group, FAR const char *pname) +int env_findvar(FAR struct task_group_s *group, FAR const char *pname) { - FAR char *ptr; - FAR char *end; + int i; /* Verify input parameters */ DEBUGASSERT(group != NULL && pname != NULL); - /* Search for a name=value string with matching name */ + if (group->tg_envp == NULL) + { + return -ENOENT; + } - end = &group->tg_envp[group->tg_envsize]; - for (ptr = group->tg_envp; - ptr < end && !env_cmpname(pname, ptr); - ptr += (strlen(ptr) + 1)); + /* Search for a name=value string with matching name */ - /* Check for success */ + for (i = 0; group->tg_envp[i] != NULL; i++) + { + if (env_cmpname(pname, group->tg_envp[i])) + { + return i; + } + } - return (ptr < end) ? ptr : NULL; + return -ENOENT; } #endif /* CONFIG_DISABLE_ENVIRON */ diff --git a/sched/environ/env_foreach.c b/sched/environ/env_foreach.c index 05a73a2e5a2b7..176cb5084dc86 100644 --- a/sched/environ/env_foreach.c +++ b/sched/environ/env_foreach.c @@ -65,22 +65,23 @@ int env_foreach(FAR struct task_group_s *group, env_foreach_t cb, FAR void *arg) { - FAR char *ptr; - FAR char *end; int ret = OK; + int i; /* Verify input parameters */ DEBUGASSERT(group != NULL && cb != NULL); - /* Search for a name=value string with matching name */ + if (group->tg_envp == NULL) + { + return ret; + } - end = &group->tg_envp[group->tg_envsize]; - for (ptr = group->tg_envp; ptr < end; ptr += (strlen(ptr) + 1)) + for (i = 0; group->tg_envp[i] != NULL; i++) { /* Perform the callback */ - ret = cb(arg, ptr); + ret = cb(arg, group->tg_envp[i]); /* Terminate the traversal early if the callback so requests by * returning a non-zero value. diff --git a/sched/environ/env_getenv.c b/sched/environ/env_getenv.c index c279cb5fa446d..19bcca822849b 100644 --- a/sched/environ/env_getenv.c +++ b/sched/environ/env_getenv.c @@ -60,7 +60,6 @@ FAR char *getenv(FAR const char *name) { FAR struct tcb_s *rtcb; FAR struct task_group_s *group; - FAR char *pvar; FAR char *pvalue = NULL; int ret = OK; @@ -68,7 +67,7 @@ FAR char *getenv(FAR const char *name) if (name == NULL) { - ret = EINVAL; + ret = -EINVAL; goto errout; } @@ -80,20 +79,19 @@ FAR char *getenv(FAR const char *name) /* Check if the variable exists */ - if (group == NULL || (pvar = env_findvar(group, name)) == NULL) + if (group == NULL || (ret = env_findvar(group, name)) < 0) { - ret = ENOENT; goto errout_with_lock; } /* It does! Get the value sub-string from the name=value string */ - pvalue = strchr(pvar, '='); + pvalue = strchr(group->tg_envp[ret], '='); if (pvalue == NULL) { /* The name=value string has no '=' This is a bug! */ - ret = EINVAL; + ret = -EINVAL; goto errout_with_lock; } @@ -106,7 +104,7 @@ FAR char *getenv(FAR const char *name) errout_with_lock: sched_unlock(); errout: - set_errno(ret); + set_errno(-ret); return NULL; } diff --git a/sched/environ/env_getenvironptr.c b/sched/environ/env_getenvironptr.c index 0ad5dc727e4d9..acf633140d06b 100644 --- a/sched/environ/env_getenvironptr.c +++ b/sched/environ/env_getenvironptr.c @@ -54,29 +54,9 @@ FAR char **get_environ_ptr(void) { -#if 1 + FAR struct tcb_s *tcb = this_task(); - /* Type of internal representation of environment is incompatible with - * char ** return value. - */ - - return NULL; - -#else - - /* Return a reference to the thread-private environ in the TCB. */ - - FAR struct tcb_s *ptcb = this_task(); - if (ptcb->envp) - { - return &ptcb->envp->ev_env; - } - else - { - return NULL; - } - -#endif + return tcb->group->tg_envp; } #endif /* CONFIG_DISABLE_ENVIRON */ diff --git a/sched/environ/env_release.c b/sched/environ/env_release.c index 412e2661a4cfe..e9089a0819e38 100644 --- a/sched/environ/env_release.c +++ b/sched/environ/env_release.c @@ -61,12 +61,19 @@ void env_release(FAR struct task_group_s *group) { - DEBUGASSERT(group != NULL); + int i; - /* Free any allocate environment strings */ + DEBUGASSERT(group != NULL); if (group->tg_envp) { + /* Free any allocate environment strings */ + + for (i = 0; group->tg_envp[i] != NULL; i++) + { + group_free(group, group->tg_envp[i]); + } + /* Free the environment */ group_free(group, group->tg_envp); @@ -76,7 +83,6 @@ void env_release(FAR struct task_group_s *group) * task group structure are reset to initial values. */ - group->tg_envsize = 0; group->tg_envp = NULL; } diff --git a/sched/environ/env_removevar.c b/sched/environ/env_removevar.c index 4149b301c9f68..f7afa192d1ca5 100644 --- a/sched/environ/env_removevar.c +++ b/sched/environ/env_removevar.c @@ -30,6 +30,8 @@ #include #include +#include + #include "environ/environ.h" /**************************************************************************** @@ -45,10 +47,10 @@ * Input Parameters: * group - The task group with the environment containing the name=value * pair - * pvar - A pointer to the name=value pair in the restroom + * index - A index to the name=value pair in the restroom * * Returned Value: - * Zero on success + * None * * Assumptions: * - Not called from an interrupt handler @@ -57,47 +59,39 @@ * ****************************************************************************/ -int env_removevar(FAR struct task_group_s *group, FAR char *pvar) +void env_removevar(FAR struct task_group_s *group, int index) { - FAR char *end; /* Pointer to the end+1 of the environment */ - int alloc; /* Size of the allocated environment */ - int ret = ERROR; + DEBUGASSERT(group != NULL && index >= 0); - DEBUGASSERT(group != NULL && pvar != NULL); + /* Free the allocate environment string */ - /* Verify that the pointer lies within the environment region */ + group_free(group, group->tg_envp[index]); - alloc = group->tg_envsize; /* Size of the allocated environment */ - end = &group->tg_envp[alloc]; /* Pointer to the end+1 of the environment */ + /* Move all of the environment strings after the removed one 'down.' + * this is inefficient, but robably not high duty. + */ - if (pvar >= group->tg_envp && pvar < end) + do { - /* Set up for the removal */ - - int len = strlen(pvar) + 1; /* Length of name=value string to remove */ - FAR char *src = &pvar[len]; /* Address of name=value string after */ - FAR char *dest = pvar; /* Location to move the next string */ - int count = end - src; /* Number of bytes to move (might be zero) */ - - /* Move all of the environment strings after the removed one 'down.' - * this is inefficient, but robably not high duty. - */ - - while (count-- > 0) - { - *dest++ = *src++; - } + group->tg_envp[index] = group->tg_envp[index + 1]; + } + while (group->tg_envp[++index] != NULL); - /* Then set to the new allocation size. The caller is expected to - * call realloc at some point but we don't do that here because the - * caller may add more stuff to the environment. - */ + /* Free the old environment (if there was one) */ - group->tg_envsize -= len; - ret = OK; + if (index == 1) + { + group_free(group, group->tg_envp); + group->tg_envp = NULL; } + else + { + /* Reallocate the environment to reclaim a little memory */ - return ret; + group->tg_envp = group_realloc(group, group->tg_envp, + sizeof(*group->tg_envp) * (index + 1)); + DEBUGASSERT(group->tg_envp != NULL); + } } #endif /* CONFIG_DISABLE_ENVIRON */ diff --git a/sched/environ/env_setenv.c b/sched/environ/env_setenv.c index 5a959a14d022d..979ab500c483c 100644 --- a/sched/environ/env_setenv.c +++ b/sched/environ/env_setenv.c @@ -70,8 +70,8 @@ int setenv(FAR const char *name, FAR const char *value, int overwrite) FAR struct tcb_s *rtcb; FAR struct task_group_s *group; FAR char *pvar; - FAR char *newenvp; - int newsize; + FAR char **envp; + int envc = 0; int varlen; int ret = OK; @@ -114,7 +114,7 @@ int setenv(FAR const char *name, FAR const char *value, int overwrite) /* Check if the variable already exists */ - if (group->tg_envp && (pvar = env_findvar(group, name)) != NULL) + if (group->tg_envp && (ret = env_findvar(group, name)) >= 0) { /* It does! Do we have permission to overwrite the existing value? */ @@ -131,7 +131,7 @@ int setenv(FAR const char *name, FAR const char *value, int overwrite) * the environment buffer; this will happen below. */ - env_removevar(group, pvar); + env_removevar(group, ret); } /* Get the size of the new name=value string. @@ -142,35 +142,44 @@ int setenv(FAR const char *name, FAR const char *value, int overwrite) /* Then allocate or reallocate the environment buffer */ + pvar = group_malloc(group, varlen); + if (pvar == NULL) + { + ret = ENOMEM; + goto errout_with_lock; + } + if (group->tg_envp) { - newsize = group->tg_envsize + varlen; - newenvp = (FAR char *)group_realloc(group, group->tg_envp, newsize); - if (!newenvp) + while (group->tg_envp[envc] != NULL) { - ret = ENOMEM; - goto errout_with_lock; + envc++; } - pvar = &newenvp[group->tg_envsize]; + envp = group_realloc(group, group->tg_envp, + sizeof(*envp) * (envc + 2)); + if (envp == NULL) + { + ret = ENOMEM; + goto errout_with_var; + } } else { - newsize = varlen; - newenvp = (FAR char *)group_malloc(group, varlen); - if (!newenvp) + envp = group_malloc(group, sizeof(*envp) * 2); + if (envp == NULL) { ret = ENOMEM; - goto errout_with_lock; + goto errout_with_var; } - - pvar = newenvp; } - /* Save the new buffer and size */ + envp[envc++] = pvar; + envp[envc] = NULL; + + /* Save the new buffer */ - group->tg_envp = newenvp; - group->tg_envsize = newsize; + group->tg_envp = envp; /* Now, put the new name=value string into the environment buffer */ @@ -178,6 +187,8 @@ int setenv(FAR const char *name, FAR const char *value, int overwrite) sched_unlock(); return OK; +errout_with_var: + group_free(group, pvar); errout_with_lock: sched_unlock(); errout: diff --git a/sched/environ/env_unsetenv.c b/sched/environ/env_unsetenv.c index 2a575739e3ec6..6d227d0d375b3 100644 --- a/sched/environ/env_unsetenv.c +++ b/sched/environ/env_unsetenv.c @@ -61,9 +61,6 @@ int unsetenv(FAR const char *name) { FAR struct tcb_s *rtcb = this_task(); FAR struct task_group_s *group = rtcb->group; - FAR char *pvar; - FAR char *newenvp; - int newsize; int ret = OK; DEBUGASSERT(name && group); @@ -71,48 +68,12 @@ int unsetenv(FAR const char *name) /* Check if the variable exists */ sched_lock(); - if (group && (pvar = env_findvar(group, name)) != NULL) + if (group && (ret = env_findvar(group, name)) >= 0) { /* It does! Remove the name=value pair from the environment. */ - env_removevar(group, pvar); - - /* Reallocate the new environment buffer */ - - newsize = group->tg_envsize; - if (newsize <= 0) - { - /* Free the old environment (if there was one) */ - - if (group->tg_envp != NULL) - { - group_free(group, group->tg_envp); - group->tg_envp = NULL; - } - - group->tg_envsize = 0; - } - else - { - /* Reallocate the environment to reclaim a little memory */ - - newenvp = (FAR char *)group_realloc(group, group->tg_envp, - newsize); - - if (newenvp == NULL) - { - set_errno(ENOMEM); - ret = ERROR; - } - else - { - /* Save the new environment pointer (it might have changed due - * to reallocation). - */ - - group->tg_envp = newenvp; - } - } + env_removevar(group, ret); + ret = OK; } sched_unlock(); diff --git a/sched/environ/environ.h b/sched/environ/environ.h index 3d8fdd012b1ff..15aeceb0f522e 100644 --- a/sched/environ/environ.h +++ b/sched/environ/environ.h @@ -33,8 +33,8 @@ ****************************************************************************/ #ifdef CONFIG_DISABLE_ENVIRON -# define env_dup(group) (0) -# define env_release(group) (0) +# define env_dup(group, envp) (0) +# define env_release(group) (0) #else /**************************************************************************** @@ -65,6 +65,7 @@ extern "C" * Input Parameters: * group - The child task group to receive the newly allocated copy of the * parent task groups environment structure. + * envp - Pointer to the environment strings. * * Returned Value: * zero on success @@ -74,7 +75,7 @@ extern "C" * ****************************************************************************/ -int env_dup(FAR struct task_group_s *group); +int env_dup(FAR struct task_group_s *group, FAR char * const *envp); /**************************************************************************** * Name: env_release @@ -111,7 +112,7 @@ void env_release(FAR struct task_group_s *group); * pname - The variable name to find * * Returned Value: - * A pointer to the name=value string in the environment + * A index to the name=value string in the environment * * Assumptions: * - Not called from an interrupt handler @@ -119,7 +120,7 @@ void env_release(FAR struct task_group_s *group); * ****************************************************************************/ -FAR char *env_findvar(FAR struct task_group_s *group, FAR const char *pname); +int env_findvar(FAR struct task_group_s *group, FAR const char *pname); /**************************************************************************** * Name: env_removevar @@ -130,10 +131,10 @@ FAR char *env_findvar(FAR struct task_group_s *group, FAR const char *pname); * Input Parameters: * group - The task group with the environment containing the name=value * pair - * pvar - A pointer to the name=value pair in the restroom + * index - A index to the name=value pair in the restroom * * Returned Value: - * Zero on success + * None * * Assumptions: * - Not called from an interrupt handler @@ -142,7 +143,7 @@ FAR char *env_findvar(FAR struct task_group_s *group, FAR const char *pname); * ****************************************************************************/ -int env_removevar(FAR struct task_group_s *group, FAR char *pvar); +void env_removevar(FAR struct task_group_s *group, int index); #undef EXTERN #ifdef __cplusplus diff --git a/sched/group/group_create.c b/sched/group/group_create.c index acfc79b8755c7..e5347ff541c85 100644 --- a/sched/group/group_create.c +++ b/sched/group/group_create.c @@ -37,7 +37,6 @@ #include #include -#include "environ/environ.h" #include "sched/sched.h" #include "group/group.h" @@ -201,15 +200,6 @@ int group_allocate(FAR struct task_tcb_s *tcb, uint8_t ttype) group_inherit_identity(group); - /* Duplicate the parent tasks environment */ - - ret = env_dup(group); - if (ret < 0) - { - tcb->cmn.group = NULL; - goto errout_with_taskinfo; - } - /* Initial user space semaphore */ nxsem_init(&group->tg_info->ta_sem, 0, 1); @@ -243,8 +233,6 @@ int group_allocate(FAR struct task_tcb_s *tcb, uint8_t ttype) return OK; -errout_with_taskinfo: - group_free(group, group->tg_info); errout_with_member: #ifdef HAVE_GROUP_MEMBERS kmm_free(group->tg_members); diff --git a/sched/init/nx_bringup.c b/sched/init/nx_bringup.c index 8ec1d743d79b3..5391c3336a471 100644 --- a/sched/init/nx_bringup.c +++ b/sched/init/nx_bringup.c @@ -292,7 +292,7 @@ static inline void nx_start_application(void) #ifndef CONFIG_ARCH_ADDRENV attr.stacksize = CONFIG_INIT_STACKSIZE; #endif - ret = exec_spawn(CONFIG_INIT_FILEPATH, argv, + ret = exec_spawn(CONFIG_INIT_FILEPATH, argv, NULL, CONFIG_INIT_SYMTAB, CONFIG_INIT_NEXPORTS, &attr); DEBUGASSERT(ret >= 0); #endif diff --git a/sched/init/nx_start.c b/sched/init/nx_start.c index 939c8fb187c85..9f5b04f0483a3 100644 --- a/sched/init/nx_start.c +++ b/sched/init/nx_start.c @@ -650,10 +650,6 @@ void nx_start(void) binfmt_initialize(); #endif - /* Initialize common drivers */ - - drivers_initialize(); - /* Initialize Hardware Facilities *****************************************/ /* The processor specific details of running the operating system @@ -664,6 +660,10 @@ void nx_start(void) up_initialize(); + /* Initialize common drivers */ + + drivers_initialize(); + #ifdef CONFIG_BOARD_EARLY_INITIALIZE /* Call the board-specific up_initialize() extension to support * early initialization of board-specific drivers and resources diff --git a/sched/irq/irq_dispatch.c b/sched/irq/irq_dispatch.c index 2b25e132fe7c8..a2afbb48c55b2 100644 --- a/sched/irq/irq_dispatch.c +++ b/sched/irq/irq_dispatch.c @@ -39,6 +39,12 @@ * Pre-processor Definitions ****************************************************************************/ +#ifdef CONFIG_ARCH_MINIMAL_VECTORTABLE +# define NUSER_IRQS CONFIG_ARCH_NUSER_INTERRUPTS +#else +# define NUSER_IRQS NR_IRQS +#endif + /* INCR_COUNT - Increment the count of interrupts taken on this IRQ number */ #ifndef CONFIG_SCHED_IRQMONITOR @@ -70,10 +76,7 @@ # define CONFIG_SCHED_CRITMONITOR_MAXTIME_IRQ 0 #endif -#ifndef CONFIG_SCHED_IRQMONITOR -# define CALL_VECTOR(ndx, vector, irq, context, arg) \ - vector(irq, context, arg) -#elif defined(CONFIG_SCHED_CRITMONITOR) +#ifdef CONFIG_SCHED_IRQMONITOR # define CALL_VECTOR(ndx, vector, irq, context, arg) \ do \ { \ @@ -84,9 +87,13 @@ vector(irq, context, arg); \ elapsed = up_perf_gettime() - start; \ up_perf_convert(elapsed, &delta); \ - if (delta.tv_nsec > g_irqvector[ndx].time) \ + if (ndx < NUSER_IRQS) \ { \ - g_irqvector[ndx].time = delta.tv_nsec; \ + INCR_COUNT(ndx); \ + if (delta.tv_nsec > g_irqvector[ndx].time) \ + { \ + g_irqvector[ndx].time = delta.tv_nsec; \ + } \ } \ if (CONFIG_SCHED_CRITMONITOR_MAXTIME_IRQ > 0 && \ elapsed > CONFIG_SCHED_CRITMONITOR_MAXTIME_IRQ) \ @@ -98,21 +105,7 @@ while (0) #else # define CALL_VECTOR(ndx, vector, irq, context, arg) \ - do \ - { \ - struct timespec start; \ - struct timespec end; \ - struct timespec delta; \ - clock_systime_timespec(&start); \ - vector(irq, context, arg); \ - clock_systime_timespec(&end); \ - clock_timespec_subtract(&end, &start, &delta); \ - if (delta.tv_nsec > g_irqvector[ndx].time) \ - { \ - g_irqvector[ndx].time = delta.tv_nsec; \ - } \ - } \ - while (0) + vector(irq, context, arg) #endif /* CONFIG_SCHED_IRQMONITOR */ /**************************************************************************** @@ -147,8 +140,6 @@ void irq_dispatch(int irq, FAR void *context) vector = g_irqvector[ndx].handler; arg = g_irqvector[ndx].arg; } - - INCR_COUNT(ndx); } #else if (g_irqvector[ndx].handler) @@ -156,8 +147,6 @@ void irq_dispatch(int irq, FAR void *context) vector = g_irqvector[ndx].handler; arg = g_irqvector[ndx].arg; } - - INCR_COUNT(ndx); #endif } #endif diff --git a/sched/module/mod_insmod.c b/sched/module/mod_insmod.c index 82c0a27c2e615..e63f0132a246e 100644 --- a/sched/module/mod_insmod.c +++ b/sched/module/mod_insmod.c @@ -198,9 +198,11 @@ FAR void *insmod(FAR const char *filename, FAR const char *modname) goto errout_with_loadinfo; } +#ifdef HAVE_MODLIB_NAMES /* Save the module name in the registry entry */ - strlcpy(modp->modname, modname, MODLIB_NAMEMAX); + strlcpy(modp->modname, modname, sizeof(modp->modname)); +#endif /* Load the program binary */ diff --git a/sched/mqueue/mq_timedsend.c b/sched/mqueue/mq_timedsend.c index 0a57d16d72384..94760b19a739a 100644 --- a/sched/mqueue/mq_timedsend.c +++ b/sched/mqueue/mq_timedsend.c @@ -403,7 +403,7 @@ int nxmq_timedsend(mqd_t mqdes, FAR const char *msg, size_t msglen, * On success, mq_send() returns 0 (OK); on error, -1 (ERROR) * is returned, with errno set to indicate the error: * - * EAGAIN The queue was empty, and the O_NONBLOCK flag was set for the + * EAGAIN The queue was full, and the O_NONBLOCK flag was set for the * message queue description referred to by mqdes. * EINVAL Either msg or mqdes is NULL or the value of prio is invalid. * EPERM Message queue opened not opened for writing. diff --git a/sched/pthread/pthread.h b/sched/pthread/pthread.h index 8a3317a5f70b7..b2db247d03d35 100644 --- a/sched/pthread/pthread.h +++ b/sched/pthread/pthread.h @@ -51,7 +51,6 @@ struct join_s { FAR struct join_s *next; /* Implements link list */ uint8_t crefs; /* Reference count */ - bool started; /* true: pthread started. */ bool detached; /* true: pthread_detached'ed */ bool terminated; /* true: detach'ed+exit'ed */ pthread_t thread; /* Includes pid */ diff --git a/sched/pthread/pthread_create.c b/sched/pthread/pthread_create.c index ea73f11b68f51..95bdbf97dba37 100644 --- a/sched/pthread/pthread_create.c +++ b/sched/pthread/pthread_create.c @@ -151,21 +151,9 @@ static inline void pthread_addjoininfo(FAR struct task_group_s *group, static void pthread_start(void) { FAR struct pthread_tcb_s *ptcb = (FAR struct pthread_tcb_s *)this_task(); - FAR struct task_group_s *group = ptcb->cmn.group; FAR struct join_s *pjoin = (FAR struct join_s *)ptcb->joininfo; - DEBUGASSERT(group != NULL && pjoin != NULL); - - /* Successfully spawned, add the pjoin to our data set. */ - - pthread_sem_take(&group->tg_joinsem, NULL, false); - pthread_addjoininfo(group, pjoin); - pthread_sem_give(&group->tg_joinsem); - - /* Report to the spawner that we successfully started. */ - - pjoin->started = true; - pthread_sem_give(&pjoin->data_sem); + DEBUGASSERT(pjoin != NULL); /* The priority of this thread may have been boosted to avoid priority * inversion problems. If that is the case, then drop to the correct @@ -529,37 +517,28 @@ int nx_pthread_create(pthread_trampoline_t trampoline, FAR pthread_t *thread, pid = ptcb->cmn.pid; pjoin->thread = (pthread_t)pid; - /* Initialize the semaphores in the join structure to zero. */ + /* Initialize the semaphore in the join structure to zero. */ - ret = nxsem_init(&pjoin->data_sem, 0, 0); - if (ret == OK) - { - ret = nxsem_init(&pjoin->exit_sem, 0, 0); - } + ret = nxsem_init(&pjoin->exit_sem, 0, 0); if (ret < 0) { ret = -ret; } - /* Thse semaphores are used for signaling and, hence, should not have + /* Thse semaphore are used for signaling and, hence, should not have * priority inheritance enabled. */ - if (ret == OK) - { - ret = nxsem_set_protocol(&pjoin->data_sem, SEM_PRIO_NONE); - - if (ret == OK) - { - ret = nxsem_set_protocol(&pjoin->exit_sem, SEM_PRIO_NONE); - } + if (ret == OK) + { + ret = nxsem_set_protocol(&pjoin->exit_sem, SEM_PRIO_NONE); + } - if (ret < 0) - { - ret = -ret; - } - } + if (ret < 0) + { + ret = -ret; + } /* If the priority of the new pthread is lower than the priority of the * parent thread, then starting the pthread could result in both the @@ -590,14 +569,11 @@ int nx_pthread_create(pthread_trampoline_t trampoline, FAR pthread_t *thread, sched_lock(); if (ret == OK) { + pthread_sem_take(&ptcb->cmn.group->tg_joinsem, NULL, false); + pthread_addjoininfo(ptcb->cmn.group, pjoin); + pthread_sem_give(&ptcb->cmn.group->tg_joinsem); nxtask_activate((FAR struct tcb_s *)ptcb); - /* Wait for the task to actually get running and to register - * its join structure. - */ - - pthread_sem_take(&pjoin->data_sem, NULL, false); - /* Return the thread information to the caller */ if (thread) @@ -605,19 +581,12 @@ int nx_pthread_create(pthread_trampoline_t trampoline, FAR pthread_t *thread, *thread = (pthread_t)pid; } - if (!pjoin->started) - { - ret = EINVAL; - } - sched_unlock(); - nxsem_destroy(&pjoin->data_sem); } else { sched_unlock(); dq_rem((FAR dq_entry_t *)ptcb, (FAR dq_queue_t *)&g_inactivetasks); - nxsem_destroy(&pjoin->data_sem); nxsem_destroy(&pjoin->exit_sem); errcode = EIO; diff --git a/sched/pthread/pthread_detach.c b/sched/pthread/pthread_detach.c index 6b68a3968e213..aa53973873654 100644 --- a/sched/pthread/pthread_detach.c +++ b/sched/pthread/pthread_detach.c @@ -65,7 +65,7 @@ int pthread_detach(pthread_t thread) FAR struct tcb_s *rtcb = this_task(); FAR struct task_group_s *group = rtcb->group; FAR struct join_s *pjoin; - int ret; + int ret = OK; sinfo("Thread=%d group=%p\n", thread, group); DEBUGASSERT(group); @@ -96,12 +96,15 @@ int pthread_detach(pthread_t thread) * thread exits */ - pjoin->detached = true; + if (pjoin->detached) + { + ret = EINVAL; + } + else + { + pjoin->detached = true; + } } - - /* Either case is successful */ - - ret = OK; } pthread_sem_give(&group->tg_joinsem); diff --git a/sched/pthread/pthread_join.c b/sched/pthread/pthread_join.c index f200461b3e3af..86be6f488cd9f 100644 --- a/sched/pthread/pthread_join.c +++ b/sched/pthread/pthread_join.c @@ -138,6 +138,13 @@ int pthread_join(pthread_t thread, FAR pthread_addr_t *pexit_value) } else { + if (pjoin->detached) + { + pthread_sem_give(&group->tg_joinsem); + leave_cancellation_point(); + return EINVAL; + } + /* NOTE: sched_lock() is not enough for SMP * because another CPU would continue the pthread and exit * sequences so need to protect it with a critical section diff --git a/sched/sched/sched_note.c b/sched/sched/sched_note.c index 180edcbb12641..e4900554b2d39 100644 --- a/sched/sched/sched_note.c +++ b/sched/sched/sched_note.c @@ -107,6 +107,28 @@ static unsigned int g_note_disabled_irq_nest[CONFIG_SMP_NCPUS]; * Private Functions ****************************************************************************/ +/**************************************************************************** + * Name: sched_note_flatten + * + * Description: + * Copy the data in the little endian layout + * + ****************************************************************************/ + +static inline void sched_note_flatten(FAR uint8_t *dst, + FAR void *src, size_t len) +{ +#ifdef CONFIG_ENDIAN_BIG + FAR uint8_t *end = (FAR uint8_t *)src + len - 1; + while (len-- > 0) + { + *dst++ = *end--; + } +#else + memcpy(dst, src, len); +#endif +} + /**************************************************************************** * Name: note_common * @@ -133,36 +155,26 @@ static void note_common(FAR struct tcb_s *tcb, clock_systime_timespec(&ts); #else - uint32_t systime = (uint32_t)clock_systime_ticks(); + clock_t systime = clock_systime_ticks(); #endif /* Save all of the common fields */ - note->nc_length = length; - note->nc_type = type; - note->nc_priority = tcb->sched_priority; + note->nc_length = length; + note->nc_type = type; + note->nc_priority = tcb->sched_priority; #ifdef CONFIG_SMP - note->nc_cpu = tcb->cpu; + note->nc_cpu = tcb->cpu; #endif - note->nc_pid[0] = (uint8_t)(tcb->pid & 0xff); - note->nc_pid[1] = (uint8_t)((tcb->pid >> 8) & 0xff); + sched_note_flatten(note->nc_pid, &tcb->pid, sizeof(tcb->pid)); #ifdef CONFIG_SCHED_INSTRUMENTATION_HIRES - note->nc_systime_nsec[0] = (uint8_t)(ts.tv_nsec & 0xff); - note->nc_systime_nsec[1] = (uint8_t)((ts.tv_nsec >> 8) & 0xff); - note->nc_systime_nsec[2] = (uint8_t)((ts.tv_nsec >> 16) & 0xff); - note->nc_systime_nsec[3] = (uint8_t)((ts.tv_nsec >> 24) & 0xff); - note->nc_systime_sec[0] = (uint8_t)(ts.tv_sec & 0xff); - note->nc_systime_sec[1] = (uint8_t)((ts.tv_sec >> 8) & 0xff); - note->nc_systime_sec[2] = (uint8_t)((ts.tv_sec >> 16) & 0xff); - note->nc_systime_sec[3] = (uint8_t)((ts.tv_sec >> 24) & 0xff); + sched_note_flatten(note->nc_systime_nsec, &ts.tv_nsec, sizeof(ts.tv_nsec)); + sched_note_flatten(note->nc_systime_sec, &ts.tv_sec, sizeof(ts.tv_sec)); #else /* Save the LS 32-bits of the system timer in little endian order */ - note->nc_systime[0] = (uint8_t)(systime & 0xff); - note->nc_systime[1] = (uint8_t)((systime >> 8) & 0xff); - note->nc_systime[2] = (uint8_t)((systime >> 16) & 0xff); - note->nc_systime[3] = (uint8_t)((systime >> 24) & 0xff); + sched_note_flatten(note->nc_systime, &systime, sizeof(systime)); #endif } @@ -419,20 +431,8 @@ static void note_spincommon(FAR struct tcb_s *tcb, note_common(tcb, ¬e.nsp_cmn, sizeof(struct note_spinlock_s), type); - note.nsp_spinlock[0] = (uint8_t)((uintptr_t)spinlock & 0xff); - note.nsp_spinlock[1] = (uint8_t)(((uintptr_t)spinlock >> 8) & 0xff); -#if UINTPTR_MAX > UINT16_MAX - note.nsp_spinlock[2] = (uint8_t)(((uintptr_t)spinlock >> 16) & 0xff); - note.nsp_spinlock[3] = (uint8_t)(((uintptr_t)spinlock >> 24) & 0xff); -#if UINTPTR_MAX > UINT32_MAX - note.nsp_spinlock[4] = (uint8_t)(((uintptr_t)spinlock >> 32) & 0xff); - note.nsp_spinlock[5] = (uint8_t)(((uintptr_t)spinlock >> 40) & 0xff); - note.nsp_spinlock[6] = (uint8_t)(((uintptr_t)spinlock >> 48) & 0xff); - note.nsp_spinlock[7] = (uint8_t)(((uintptr_t)spinlock >> 56) & 0xff); -#endif -#endif - - note.nsp_value = (uint8_t)*spinlock; + sched_note_flatten(note.nsp_spinlock, &spinlock, sizeof(spilock)); + note.nsp_value = (uint8_t)*spinlock; /* Add the note to circular buffer */ @@ -482,7 +482,7 @@ void sched_note_start(FAR struct tcb_s *tcb) namelen = strlen(tcb->name); DEBUGASSERT(namelen <= CONFIG_TASK_NAME_SIZE); - strncpy(note.nsa_name, tcb->name, CONFIG_TASK_NAME_SIZE + 1); + strlcpy(note.nsa_name, tcb->name, sizeof(note.nsa_name)); length = SIZEOF_NOTE_START(namelen + 1); #else @@ -691,8 +691,8 @@ void sched_note_premption(FAR struct tcb_s *tcb, bool locked) note_common(tcb, ¬e.npr_cmn, sizeof(struct note_preempt_s), locked ? NOTE_PREEMPT_LOCK : NOTE_PREEMPT_UNLOCK); - note.npr_count[0] = (uint8_t)(tcb->lockcount & 0xff); - note.npr_count[1] = (uint8_t)((tcb->lockcount >> 8) & 0xff); + sched_note_flatten(note.npr_count, + &tcb->lockcount, sizeof(tcb->lockcount)); /* Add the note to circular buffer */ @@ -715,8 +715,7 @@ void sched_note_csection(FAR struct tcb_s *tcb, bool enter) note_common(tcb, ¬e.ncs_cmn, sizeof(struct note_csection_s), enter ? NOTE_CSECTION_ENTER : NOTE_CSECTION_LEAVE); #ifdef CONFIG_SMP - note.ncs_count[0] = (uint8_t)(tcb->irqcount & 0xff); - note.ncs_count[1] = (uint8_t)((tcb->irqcount >> 8) & 0xff); + sched_note_flatten(note.ncs_count, &tcb->irqcount, sizeof(tcb->irqcount)); #endif /* Add the note to circular buffer */ @@ -755,10 +754,10 @@ void sched_note_syscall_enter(int nr, int argc, ...) struct note_syscall_enter_s note; FAR struct tcb_s *tcb = this_task(); unsigned int length; - va_list ap; uintptr_t arg; - int i; uint8_t *args; + va_list ap; + int i; if (!note_isenabled_syscall(nr)) { @@ -789,18 +788,8 @@ void sched_note_syscall_enter(int nr, int argc, ...) for (i = 0; i < argc; i++) { arg = (uintptr_t)va_arg(ap, uintptr_t); - *args++ = (uint8_t)(arg & 0xff); - *args++ = (uint8_t)((arg >> 8) & 0xff); -#if UINTPTR_MAX > UINT16_MAX - *args++ = (uint8_t)((arg >> 16) & 0xff); - *args++ = (uint8_t)((arg >> 24) & 0xff); -#if UINTPTR_MAX > UINT32_MAX - *args++ = (uint8_t)((arg >> 32) & 0xff); - *args++ = (uint8_t)((arg >> 40) & 0xff); - *args++ = (uint8_t)((arg >> 48) & 0xff); - *args++ = (uint8_t)((arg >> 56) & 0xff); -#endif -#endif + sched_note_flatten(args, &arg, sizeof(arg)); + args += sizeof(uintptr_t); } va_end(ap); @@ -825,20 +814,9 @@ void sched_note_syscall_leave(int nr, uintptr_t result) note_common(tcb, ¬e.nsc_cmn, sizeof(struct note_syscall_leave_s), NOTE_SYSCALL_LEAVE); DEBUGASSERT(nr <= UCHAR_MAX); - note.nsc_nr = nr; - - note.nsc_result[0] = (uint8_t)(result & 0xff); - note.nsc_result[1] = (uint8_t)((result >> 8) & 0xff); -#if UINTPTR_MAX > UINT16_MAX - note.nsc_result[2] = (uint8_t)((result >> 16) & 0xff); - note.nsc_result[3] = (uint8_t)((result >> 24) & 0xff); -#if UINTPTR_MAX > UINT32_MAX - note.nsc_result[4] = (uint8_t)((result >> 32) & 0xff); - note.nsc_result[5] = (uint8_t)((result >> 40) & 0xff); - note.nsc_result[6] = (uint8_t)((result >> 48) & 0xff); - note.nsc_result[7] = (uint8_t)((result >> 56) & 0xff); -#endif -#endif + note.nsc_nr = nr; + + sched_note_flatten(note.nsc_result, &result, sizeof(result)); /* Add the note to circular buffer */ @@ -872,7 +850,7 @@ void sched_note_irqhandler(int irq, FAR void *handler, bool enter) #endif #ifdef CONFIG_SCHED_INSTRUMENTATION_DUMP -void sched_note_string(FAR const char *buf) +void sched_note_string(uintptr_t ip, FAR const char *buf) { FAR struct note_string_s *note; uint8_t data[255]; @@ -896,6 +874,7 @@ void sched_note_string(FAR const char *buf) note_common(tcb, ¬e->nst_cmn, length, NOTE_DUMP_STRING); + sched_note_flatten(note->nst_ip, &ip, sizeof(uintptr_t)); memcpy(note->nst_data, buf, length - sizeof(struct note_string_s)); data[length - 1] = '\0'; @@ -904,7 +883,7 @@ void sched_note_string(FAR const char *buf) sched_note_add(note, length); } -void sched_note_dump(uint32_t module, uint8_t event, +void sched_note_dump(uintptr_t ip, uint8_t event, FAR const void *buf, size_t len) { FAR struct note_binary_s *note; @@ -929,10 +908,7 @@ void sched_note_dump(uint32_t module, uint8_t event, note_common(tcb, ¬e->nbi_cmn, length, NOTE_DUMP_BINARY); - note->nbi_module[0] = (uint8_t)(module & 0xff); - note->nbi_module[1] = (uint8_t)((module >> 8) & 0xff); - note->nbi_module[2] = (uint8_t)((module >> 16) & 0xff); - note->nbi_module[3] = (uint8_t)((module >> 24) & 0xff); + sched_note_flatten(note->nbi_ip, &ip, sizeof(uintptr_t)); note->nbi_event = event; memcpy(note->nbi_data, buf, length - sizeof(struct note_binary_s) + 1); @@ -941,7 +917,8 @@ void sched_note_dump(uint32_t module, uint8_t event, sched_note_add(note, length); } -void sched_note_vprintf(FAR const char *fmt, va_list va) +void sched_note_vprintf(uintptr_t ip, + FAR const char *fmt, va_list va) { FAR struct note_string_s *note; uint8_t data[255]; @@ -969,12 +946,14 @@ void sched_note_vprintf(FAR const char *fmt, va_list va) note_common(tcb, ¬e->nst_cmn, length, NOTE_DUMP_STRING); + sched_note_flatten(note->nst_ip, &ip, sizeof(uintptr_t)); + /* Add the note to circular buffer */ sched_note_add(note, length); } -void sched_note_vbprintf(uint32_t module, uint8_t event, +void sched_note_vbprintf(uintptr_t ip, uint8_t event, FAR const char *fmt, va_list va) { FAR struct note_binary_s *note; @@ -1168,10 +1147,7 @@ void sched_note_vbprintf(uint32_t module, uint8_t event, note_common(tcb, ¬e->nbi_cmn, length, NOTE_DUMP_BINARY); - note->nbi_module[0] = (uint8_t)(module & 0xff); - note->nbi_module[1] = (uint8_t)((module >> 8) & 0xff); - note->nbi_module[2] = (uint8_t)((module >> 16) & 0xff); - note->nbi_module[3] = (uint8_t)((module >> 24) & 0xff); + sched_note_flatten(note->nbi_ip, &ip, sizeof(uintptr_t)); note->nbi_event = event; /* Add the note to circular buffer */ @@ -1179,22 +1155,33 @@ void sched_note_vbprintf(uint32_t module, uint8_t event, sched_note_add(note, length); } -void sched_note_printf(FAR const char *fmt, ...) +void sched_note_printf(uintptr_t ip, + FAR const char *fmt, ...) { va_list va; va_start(va, fmt); - sched_note_vprintf(fmt, va); + sched_note_vprintf(ip, fmt, va); va_end(va); } -void sched_note_bprintf(uint32_t module, uint8_t event, +void sched_note_bprintf(uintptr_t ip, uint8_t event, FAR const char *fmt, ...) { va_list va; va_start(va, fmt); - sched_note_vbprintf(module, event, fmt, va); + sched_note_vbprintf(ip, event, fmt, va); va_end(va); } + +void sched_note_begin(uintptr_t ip, FAR const char *buf) +{ + sched_note_printf(ip, "B|%d|%s", getpid(), buf); +} + +void sched_note_end(uintptr_t ip, FAR const char *buf) +{ + sched_note_printf(ip, "E|%d|%s", getpid(), buf); +} #endif /* CONFIG_SCHED_INSTRUMENTATION_DUMP */ #ifdef CONFIG_SCHED_INSTRUMENTATION_FILTER diff --git a/sched/sched/sched_timerexpiration.c b/sched/sched/sched_timerexpiration.c index c58cc05ca6fc3..3eae452ca4fbd 100644 --- a/sched/sched/sched_timerexpiration.c +++ b/sched/sched/sched_timerexpiration.c @@ -373,7 +373,9 @@ static inline unsigned int nxsched_process_wdtimer(uint32_t ticks, static unsigned int nxsched_timer_process(unsigned int ticks, bool noswitches) { +#if CONFIG_RR_INTERVAL > 0 || defined(CONFIG_SCHED_SPORADIC) unsigned int cmptime = UINT_MAX; +#endif unsigned int rettime = 0; unsigned int tmp; @@ -388,7 +390,9 @@ static unsigned int nxsched_timer_process(unsigned int ticks, tmp = nxsched_process_wdtimer(ticks, noswitches); if (tmp > 0) { +#if CONFIG_RR_INTERVAL > 0 || defined(CONFIG_SCHED_SPORADIC) cmptime = tmp; +#endif rettime = tmp; } @@ -397,10 +401,13 @@ static unsigned int nxsched_timer_process(unsigned int ticks, */ tmp = nxsched_process_scheduler(ticks, noswitches); + +#if CONFIG_RR_INTERVAL > 0 || defined(CONFIG_SCHED_SPORADIC) if (tmp > 0 && tmp < cmptime) { rettime = tmp; } +#endif return rettime; } diff --git a/sched/sched/sched_waitpid.c b/sched/sched/sched_waitpid.c index a1a74fc505a4e..aac39eeea6e63 100644 --- a/sched/sched/sched_waitpid.c +++ b/sched/sched/sched_waitpid.c @@ -55,8 +55,6 @@ pid_t nx_waitpid(pid_t pid, int *stat_loc, int options) bool mystat = false; int ret; - DEBUGASSERT(stat_loc); - /* NOTE: sched_lock() is not enough for SMP * because the child task is running on another CPU */ @@ -194,8 +192,6 @@ pid_t nx_waitpid(pid_t pid, int *stat_loc, int options) sigset_t set; int ret; - DEBUGASSERT(stat_loc); - /* Create a signal set that contains only SIGCHLD */ sigemptyset(&set); @@ -312,7 +308,11 @@ pid_t nx_waitpid(pid_t pid, int *stat_loc, int options) /* The child has exited. Return the saved exit status */ - *stat_loc = child->ch_status << 8; + if (stat_loc != NULL) + { + *stat_loc = child->ch_status << 8; + } + pid = child->ch_pid; /* Discard the child entry and break out of the loop */ @@ -340,7 +340,10 @@ pid_t nx_waitpid(pid_t pid, int *stat_loc, int options) { /* The child has exited. Return the saved exit status */ - *stat_loc = child->ch_status << 8; + if (stat_loc != NULL) + { + *stat_loc = child->ch_status << 8; + } /* Discard the child entry and break out of the loop */ @@ -415,7 +418,11 @@ pid_t nx_waitpid(pid_t pid, int *stat_loc, int options) { /* Yes... return the status and PID (in the event it was -1) */ - *stat_loc = info.si_status << 8; + if (stat_loc != NULL) + { + *stat_loc = info.si_status << 8; + } + pid = info.si_pid; #ifdef CONFIG_SCHED_CHILD_STATUS diff --git a/sched/signal/sig_action.c b/sched/signal/sig_action.c index 2646197e4f047..cffd139df1061 100644 --- a/sched/signal/sig_action.c +++ b/sched/signal/sig_action.c @@ -101,7 +101,7 @@ static FAR sigactq_t *nxsig_alloc_action(void) /* Check if we got one. */ - if (!sigact) + while (!sigact) { /* Add another block of signal actions to the list */ @@ -112,7 +112,6 @@ static FAR sigactq_t *nxsig_alloc_action(void) flags = spin_lock_irqsave(&g_sigaction_spin); sigact = (FAR sigactq_t *)sq_remfirst(&g_sigfreeaction); spin_unlock_irqrestore(&g_sigaction_spin, flags); - DEBUGASSERT(sigact); } return sigact; diff --git a/sched/signal/sig_dispatch.c b/sched/signal/sig_dispatch.c index 1b5edb3ee30e5..7553c5d633f05 100644 --- a/sched/signal/sig_dispatch.c +++ b/sched/signal/sig_dispatch.c @@ -105,6 +105,13 @@ static int nxsig_queue_action(FAR struct tcb_s *stcb, siginfo_t *info) flags = enter_critical_section(); sq_addlast((FAR sq_entry_t *)sigq, &(stcb->sigpendactionq)); + + /* Then schedule execution of the signal handling action on the + * recipient's thread. SMP related handling will be done in + * up_schedule_sigaction() + */ + + up_schedule_sigaction(stcb, nxsig_deliver); leave_critical_section(flags); } } @@ -383,13 +390,6 @@ int nxsig_tcbdispatch(FAR struct tcb_s *stcb, siginfo_t *info) flags = enter_critical_section(); - /* Then schedule execution of the signal handling action on the - * recipient's thread. SMP related handling will be done in - * up_schedule_sigaction() - */ - - up_schedule_sigaction(stcb, nxsig_deliver); - /* Check if the task is waiting for an unmasked signal. If so, then * unblock it. This must be performed in a critical section because * signals can be queued from the interrupt level. diff --git a/sched/task/Make.defs b/sched/task/Make.defs index 85b893e642d91..406ea35a0b571 100644 --- a/sched/task/Make.defs +++ b/sched/task/Make.defs @@ -45,7 +45,7 @@ endif ifneq ($(CONFIG_BINFMT_DISABLE),y) ifeq ($(CONFIG_LIBC_EXECFUNCS),y) -CSRCS += task_execv.c task_posixspawn.c +CSRCS += task_execve.c task_posixspawn.c endif endif diff --git a/sched/task/spawn.h b/sched/task/spawn.h index d1d6ba4a2c200..521b065064458 100644 --- a/sched/task/spawn.h +++ b/sched/task/spawn.h @@ -49,6 +49,7 @@ struct spawn_parms_s FAR const posix_spawn_file_actions_t *file_actions; FAR const posix_spawnattr_t *attr; FAR char * const *argv; + FAR char * const *envp; /* Parameters that differ for posix_spawn[p] and task_spawn */ diff --git a/sched/task/task_create.c b/sched/task/task_create.c index e85ed653d39fb..380f5459c0276 100644 --- a/sched/task/task_create.c +++ b/sched/task/task_create.c @@ -91,7 +91,8 @@ static int nxthread_create(FAR const char *name, uint8_t ttype, /* Initialize the task */ - ret = nxtask_init(tcb, name, priority, stack_ptr, stack_size, entry, argv); + ret = nxtask_init(tcb, name, priority, stack_ptr, stack_size, entry, argv, + NULL); if (ret < OK) { kmm_free(tcb); diff --git a/sched/task/task_execv.c b/sched/task/task_execve.c similarity index 93% rename from sched/task/task_execv.c rename to sched/task/task_execve.c index b4472e828916d..555271effef5d 100644 --- a/sched/task/task_execv.c +++ b/sched/task/task_execve.c @@ -1,5 +1,5 @@ /**************************************************************************** - * sched/task/task_execv.c + * sched/task/task_execve.c * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with @@ -100,6 +100,9 @@ * absolute path to the program. * argv - A pointer to an array of string arguments. The end of the * array is indicated with a NULL entry. + * envp - An array of character pointers to null-terminated strings that + * provide the environment for the new process image. The environment + * array is terminated by a null pointer. * * Returned Value: * This function does not return on success. On failure, it will return @@ -107,7 +110,8 @@ * ****************************************************************************/ -int execv(FAR const char *path, FAR char * const argv[]) +int execve(FAR const char *path, FAR char * const argv[], + FAR char *const envp[]) { FAR const struct symtab_s *symtab; int nsymbols; @@ -119,7 +123,7 @@ int execv(FAR const char *path, FAR char * const argv[]) /* Start the task */ - ret = exec(path, (FAR char * const *)argv, symtab, nsymbols); + ret = exec(path, argv, envp, symtab, nsymbols); if (ret < 0) { serr("ERROR: exec failed: %d\n", get_errno()); diff --git a/sched/task/task_exithook.c b/sched/task/task_exithook.c index ce939b3a22fa2..0955658f5feaf 100644 --- a/sched/task/task_exithook.c +++ b/sched/task/task_exithook.c @@ -469,7 +469,7 @@ static inline void nxtask_exitwakeup(FAR struct tcb_s *tcb, int status) * Hmmm.. what do we return to the others? */ - if (group->tg_statloc) + if (group->tg_statloc != NULL) { *group->tg_statloc = status << 8; } diff --git a/sched/task/task_init.c b/sched/task/task_init.c index 126484b802a67..5cbb774fbab77 100644 --- a/sched/task/task_init.c +++ b/sched/task/task_init.c @@ -36,6 +36,7 @@ #include #include "sched/sched.h" +#include "environ/environ.h" #include "group/group.h" #include "task/task.h" @@ -83,7 +84,8 @@ int nxtask_init(FAR struct task_tcb_s *tcb, const char *name, int priority, FAR void *stack, uint32_t stack_size, - main_t entry, FAR char * const argv[]) + main_t entry, FAR char * const argv[], + FAR char * const envp[]) { uint8_t ttype = tcb->cmn.flags & TCB_FLAG_TTYPE_MASK; FAR struct tls_info_s *info; @@ -103,6 +105,14 @@ int nxtask_init(FAR struct task_tcb_s *tcb, const char *name, int priority, return ret; } + /* Duplicate the parent tasks environment */ + + ret = env_dup(tcb->cmn.group, envp); + if (ret < 0) + { + goto errout_with_group; + } + /* Associate file descriptors with the new task */ ret = group_setuptaskfiles(tcb); diff --git a/sched/task/task_posixspawn.c b/sched/task/task_posixspawn.c index 881d604002709..cb7f78d51cbd9 100644 --- a/sched/task/task_posixspawn.c +++ b/sched/task/task_posixspawn.c @@ -85,7 +85,8 @@ static int nxposix_spawn_exec(FAR pid_t *pidp, FAR const char *path, FAR const posix_spawnattr_t *attr, - FAR char * const argv[]) + FAR char * const argv[], + FAR char * const envp[]) { FAR const struct symtab_s *symtab; int nsymbols; @@ -107,7 +108,7 @@ static int nxposix_spawn_exec(FAR pid_t *pidp, FAR const char *path, /* Start the task */ - pid = exec_spawn(path, (FAR char * const *)argv, symtab, nsymbols, attr); + pid = exec_spawn(path, argv, envp, symtab, nsymbols, attr); if (pid < 0) { ret = -pid; @@ -184,7 +185,8 @@ static int nxposix_spawn_proxy(int argc, FAR char *argv[]) /* Start the task */ ret = nxposix_spawn_exec(g_spawn_parms.pid, g_spawn_parms.u.posix.path, - g_spawn_parms.attr, g_spawn_parms.argv); + g_spawn_parms.attr, g_spawn_parms.argv, + g_spawn_parms.envp); #ifdef CONFIG_SCHED_HAVE_PARENT if (ret == OK) @@ -274,12 +276,8 @@ static int nxposix_spawn_proxy(int argc, FAR char *argv[]) * array of pointers to null-terminated strings. The list is terminated * with a null pointer. * - * envp - The envp[] argument is not used by NuttX and may be NULL. In - * standard implementations, envp[] is an array of character pointers to - * null-terminated strings that provide the environment for the new - * process image. The environment array is terminated by a null pointer. - * In NuttX, the envp[] argument is ignored and the new task will simply - * inherit the environment of the parent task. + * envp - envp[] is an array of character pointers to null-terminated + * strings that provide the environment for the new process image. * * Returned Value: * posix_spawn() and posix_spawnp() will return zero on success. @@ -295,8 +293,6 @@ static int nxposix_spawn_proxy(int argc, FAR char *argv[]) * depending upon the setting of CONFIG_LIBC_ENVPATH: If * CONFIG_LIBC_ENVPATH is defined, then only posix_spawnp() behavior * is supported; otherwise, only posix_spawn behavior is supported. - * - The 'envp' argument is not used and the 'environ' variable is not - * altered (NuttX does not support the 'environ' variable). * - Process groups are not supported (POSIX_SPAWN_SETPGROUP). * - Effective user IDs are not supported (POSIX_SPAWN_RESETIDS). * - Signal default actions cannot be modified in the newly task executed @@ -335,7 +331,7 @@ int posix_spawn(FAR pid_t *pid, FAR const char *path, if ((file_actions == NULL || *file_actions == NULL) && (attr == NULL || (attr->flags & POSIX_SPAWN_SETSIGMASK) == 0)) { - return nxposix_spawn_exec(pid, path, attr, argv); + return nxposix_spawn_exec(pid, path, attr, argv, envp); } /* Otherwise, we will have to go through an intermediary/proxy task in @@ -365,6 +361,7 @@ int posix_spawn(FAR pid_t *pid, FAR const char *path, g_spawn_parms.file_actions = file_actions ? *file_actions : NULL; g_spawn_parms.attr = attr; g_spawn_parms.argv = argv; + g_spawn_parms.envp = envp; g_spawn_parms.u.posix.path = path; /* Get the priority of this (parent) task */ diff --git a/sched/task/task_spawn.c b/sched/task/task_spawn.c index 327bf8c6f00c6..7f79c941adac5 100644 --- a/sched/task/task_spawn.c +++ b/sched/task/task_spawn.c @@ -292,7 +292,8 @@ static int nxtask_spawn_proxy(int argc, FAR char *argv[]) * array of pointers to null-terminated strings. The list is terminated * with a null pointer. * - * envp - The envp[] argument is not used by NuttX and may be NULL. + * envp - envp[] is an array of character pointers to null-terminated + * strings that provide the environment for the new process image. * * Returned Value: * task_spawn() will return process ID of new task on success. @@ -365,6 +366,7 @@ int task_spawn(FAR const char *name, main_t entry, g_spawn_parms.file_actions = file_actions ? *file_actions : NULL; g_spawn_parms.attr = attr; g_spawn_parms.argv = argv; + g_spawn_parms.envp = envp; g_spawn_parms.u.task.name = name; g_spawn_parms.u.task.entry = entry; diff --git a/sched/task/task_start.c b/sched/task/task_start.c index 7eb1c9a907107..11af95dcd24da 100644 --- a/sched/task/task_start.c +++ b/sched/task/task_start.c @@ -82,9 +82,12 @@ void nxtask_start(void) TCB_FLAG_TTYPE_PTHREAD); #ifdef CONFIG_SIG_DEFAULT - /* Set up default signal actions */ + if ((tcb->cmn.flags & TCB_FLAG_TTYPE_MASK) != TCB_FLAG_TTYPE_KERNEL) + { + /* Set up default signal actions for NON-kernel thread */ - nxsig_default_initialize(&tcb->cmn); + nxsig_default_initialize(&tcb->cmn); + } #endif /* Execute the start hook if one has been registered */ diff --git a/sched/task/task_vfork.c b/sched/task/task_vfork.c index fe87899d1b056..f535614c6299f 100644 --- a/sched/task/task_vfork.c +++ b/sched/task/task_vfork.c @@ -37,6 +37,7 @@ #include #include "sched/sched.h" +#include "environ/environ.h" #include "group/group.h" #include "task/task.h" @@ -151,6 +152,14 @@ FAR struct task_tcb_s *nxtask_setup_vfork(start_t retaddr) goto errout_with_tcb; } + /* Duplicate the parent tasks environment */ + + ret = env_dup(child->cmn.group, environ); + if (ret < 0) + { + goto errout_with_tcb; + } + /* Associate file descriptors with the new task */ ret = group_setuptaskfiles(child); diff --git a/sched/wqueue/kwork_thread.c b/sched/wqueue/kwork_thread.c index 6a6cb025d719a..706267d8ce784 100644 --- a/sched/wqueue/kwork_thread.c +++ b/sched/wqueue/kwork_thread.c @@ -46,7 +46,11 @@ * Pre-processor Definitions ****************************************************************************/ -#if defined(CONFIG_SCHED_CRITMONITOR_MAXTIME_WQUEUE) && CONFIG_SCHED_CRITMONITOR_MAXTIME_WQUEUE > 0 +#ifndef CONFIG_SCHED_CRITMONITOR_MAXTIME_WQUEUE +# define CONFIG_SCHED_CRITMONITOR_MAXTIME_WQUEUE 0 +#endif + +#if CONFIG_SCHED_CRITMONITOR_MAXTIME_WQUEUE > 0 # define CALL_WORKER(worker, arg) \ do \ { \ @@ -76,7 +80,7 @@ struct hp_wqueue_s g_hpwork = { {}, - NXSEM_INITIALIZER(0, SEM_PRIO_NONE), + NXSEM_INITIALIZER(0, PRIOINHERIT_FLAGS_DISABLE), }; #endif /* CONFIG_SCHED_HPWORK */ @@ -87,7 +91,7 @@ struct hp_wqueue_s g_hpwork = struct lp_wqueue_s g_lpwork = { {}, - NXSEM_INITIALIZER(0, SEM_PRIO_NONE), + NXSEM_INITIALIZER(0, PRIOINHERIT_FLAGS_DISABLE), }; #endif /* CONFIG_SCHED_LPWORK */ @@ -232,9 +236,7 @@ static int work_thread_create(FAR const char *name, int priority, return pid; } -#ifdef CONFIG_PRIORITY_INHERITANCE wqueue->worker[wndx].pid = pid; -#endif } sched_unlock(); @@ -245,6 +247,55 @@ static int work_thread_create(FAR const char *name, int priority, * Public Functions ****************************************************************************/ +/**************************************************************************** + * Name: work_foreach + * + * Description: + * Enumerate over each work thread and provide the tid of each task to a + * user callback functions. + * + * Input Parameters: + * qid - The work queue ID + * handler - The function to be called with the pid of each task + * arg - The function callback + * + * Returned Value: + * None + * + ****************************************************************************/ + +void work_foreach(int qid, work_foreach_t handler, FAR void *arg) +{ + FAR struct kwork_wqueue_s *wqueue; + int nthread; + int wndx; + +#ifdef CONFIG_SCHED_HPWORK + if (qid == HPWORK) + { + wqueue = (FAR struct kwork_wqueue_s *)&g_hpwork; + nthread = CONFIG_SCHED_HPNTHREADS; + } + else +#endif +#ifdef CONFIG_SCHED_LPWORK + if (qid == LPWORK) + { + wqueue = (FAR struct kwork_wqueue_s *)&g_lpwork; + nthread = CONFIG_SCHED_LPNTHREADS; + } + else +#endif + { + return; + } + + for (wndx = 0; wndx < nthread; wndx++) + { + handler(wqueue->worker[wndx].pid, arg); + } +} + /**************************************************************************** * Name: work_start_highpri * diff --git a/sched/wqueue/wqueue.h b/sched/wqueue/wqueue.h index 774cebcda2b1f..399a3fbddc703 100644 --- a/sched/wqueue/wqueue.h +++ b/sched/wqueue/wqueue.h @@ -51,9 +51,7 @@ struct kworker_s { -#ifdef CONFIG_PRIORITY_INHERITANCE pid_t pid; /* The task ID of the worker thread */ -#endif }; /* This structure defines the state of one kernel-mode work queue */ diff --git a/syscall/Makefile b/syscall/Makefile index 7965907a6f3a7..47efbae007034 100644 --- a/syscall/Makefile +++ b/syscall/Makefile @@ -44,7 +44,7 @@ PROXY_OBJS = $(PROXY_SRCS:.c=$(OBJEXT)) STUB_OBJS = $(STUB_SRCS:.c=$(OBJEXT)) WRAP_OBJS = $(WRAP_SRCS:.c=$(OBJEXT)) -CSRCS = $(PROXY_SRCS) $(STUB_SRCS) $(WRAP_SRCS) +CSRCS = $(sort $(PROXY_SRCS) $(STUB_SRCS) $(WRAP_SRCS)) COBJS = $(CSRCS:.c=$(OBJEXT)) SRCS = $(ASRCS) $(CSRCS) diff --git a/syscall/syscall.csv b/syscall/syscall.csv index 3c3b14a7f27b6..448cd3a0d8dd4 100644 --- a/syscall/syscall.csv +++ b/syscall/syscall.csv @@ -23,8 +23,8 @@ "dup","unistd.h","","int","int" "dup2","unistd.h","","int","int","int" "eventfd","sys/eventfd.h","defined(CONFIG_EVENT_FD)","int","unsigned int","int" -"exec","nuttx/binfmt/binfmt.h","!defined(CONFIG_BINFMT_DISABLE) && !defined(CONFIG_BUILD_KERNEL)","int","FAR const char *","FAR char * const *","FAR const struct symtab_s *","int" -"execv","unistd.h","!defined(CONFIG_BINFMT_DISABLE) && defined(CONFIG_LIBC_EXECFUNCS)","int","FAR const char *","FAR char * const []|FAR char * const *" +"exec","nuttx/binfmt/binfmt.h","!defined(CONFIG_BINFMT_DISABLE) && !defined(CONFIG_BUILD_KERNEL)","int","FAR const char *","FAR char * const *","FAR char * const *","FAR const struct symtab_s *","int" +"execve","unistd.h","!defined(CONFIG_BINFMT_DISABLE) && defined(CONFIG_LIBC_EXECFUNCS)","int","FAR const char *","FAR char * const []|FAR char * const *","FAR char * const []|FAR char * const *" "exit","stdlib.h","","noreturn","int" "fchmod","sys/stat.h","","int","int","mode_t" "fchown","unistd.h","","int","int","uid_t","gid_t" @@ -35,6 +35,7 @@ "fsync","unistd.h","!defined(CONFIG_DISABLE_MOUNTPOINT)","int","int" "ftruncate","unistd.h","!defined(CONFIG_DISABLE_MOUNTPOINT)","int","int","off_t" "futimens","sys/stat.h","","int","int","const struct timespec [2]|FAR const struct timespec *" +"get_environ_ptr","stdlib.h","!defined(CONFIG_DISABLE_ENVIRON)","FAR char **" "getenv","stdlib.h","!defined(CONFIG_DISABLE_ENVIRON)","FAR char *","FAR const char *" "getgid","unistd.h","defined(CONFIG_SCHED_USER_IDENTITY)","gid_t" "gethostname","unistd.h","","int","FAR char *","size_t" diff --git a/tools/README.txt b/tools/README.txt index 782eac25bf743..aae444c276116 100644 --- a/tools/README.txt +++ b/tools/README.txt @@ -1026,10 +1026,10 @@ testbuild.sh The test list file is a sequence of build descriptions, one per line. One build descriptions consists of two comma separated values. For example: - stm32f429i-disco:nsh,CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIL - arduino-due:nsh,CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIL - /arm,CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIL - /risc-v,CONFIG_RISCV_TOOLCHAIN_GNU_RVGL + stm32f429i-disco:nsh + arduino-due:nsh + /arm + /risc-v The first value is the usual configuration description of the form : or / and must correspond to a diff --git a/tools/checkpatch.sh b/tools/checkpatch.sh index a3f25ab9a5a59..c05834e784a95 100755 --- a/tools/checkpatch.sh +++ b/tools/checkpatch.sh @@ -23,6 +23,7 @@ check=check_patch fail=0 range=0 spell=0 +message=0 usage() { echo "USAGE: ${0} [options] [list|-]" @@ -32,6 +33,7 @@ usage() { echo "-c spell check with codespell(install with: pip install codespell)" echo "-r range check only (coupled with -p or -g)" echo "-p (default)" + echo "-m Change-Id check in commit message (coupled with -g)" echo "-g " echo "-f " echo "- read standard input mainly used by git pre-commit hook as below:" @@ -122,8 +124,10 @@ check_msg() { } check_commit() { - msg=`git show -s --format=%B $1` - check_msg <<< "$msg" + if [ $message != 0 ]; then + msg=`git show -s --format=%B $1` + check_msg <<< "$msg" + fi diffs=`git diff $1` check_ranges <<< "$diffs" } @@ -146,6 +150,9 @@ while [ ! -z "$1" ]; do -f ) check=check_file ;; + -m ) + message=1 + ;; -g ) check=check_commit ;; diff --git a/tools/checkrelease.sh b/tools/checkrelease.sh index 23352121ac63e..3299c51270068 100755 --- a/tools/checkrelease.sh +++ b/tools/checkrelease.sh @@ -103,10 +103,6 @@ function check_required_files() { echo " - README.md file not present." MISSING_FILE=1 fi - if [ ! -f "$RELEASE_DIR/DISCLAIMER-WIP" ]; then - echo " - DISCLAIMER-WIP file not present." - MISSING_FILE=1 - fi if [ 0 -eq $MISSING_FILE ]; then echo " OK: all required files exist in $RELEASE_DIR." else diff --git a/tools/ci/cibuild.sh b/tools/ci/cibuild.sh index 1e720078c4467..3b18ae3fa9e6b 100755 --- a/tools/ci/cibuild.sh +++ b/tools/ci/cibuild.sh @@ -196,10 +196,10 @@ function riscv-gcc-toolchain { ;; esac cd "${prebuilt}" - wget --quiet https://static.dev.sifive.com/dev-tools/riscv64-unknown-elf-gcc-8.3.0-2019.08.0-${flavor}.tar.gz - tar zxf riscv64-unknown-elf-gcc-8.3.0-2019.08.0-${flavor}.tar.gz - mv riscv64-unknown-elf-gcc-8.3.0-2019.08.0-${flavor} riscv64-unknown-elf-gcc - rm riscv64-unknown-elf-gcc-8.3.0-2019.08.0-${flavor}.tar.gz + wget --quiet https://static.dev.sifive.com/dev-tools/freedom-tools/v2020.12/riscv64-unknown-elf-toolchain-10.2.0-2020.12.8-${flavor}.tar.gz + tar zxf riscv64-unknown-elf-toolchain-10.2.0-2020.12.8-${flavor}.tar.gz + mv riscv64-unknown-elf-toolchain-10.2.0-2020.12.8-${flavor} riscv64-unknown-elf-gcc + rm riscv64-unknown-elf-toolchain-10.2.0-2020.12.8-${flavor}.tar.gz fi riscv64-unknown-elf-gcc --version } diff --git a/tools/ci/testlist/arm-01.dat b/tools/ci/testlist/arm-01.dat index 8ef1b5a72ed83..421f36ee5c7dc 100644 --- a/tools/ci/testlist/arm-01.dat +++ b/tools/ci/testlist/arm-01.dat @@ -1,3 +1,3 @@ -/arm/[a]*,CONFIG_ARMV7A_TOOLCHAIN_GNU_EABIL +/arm/[a]*,CONFIG_ARMV7A_TOOLCHAIN_GNU_EABI -/arm/[b-h]*,CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIL +/arm/[b-h]*,CONFIG_ARMV7M_TOOLCHAIN_GNU_EABI diff --git a/tools/ci/testlist/arm-02.dat b/tools/ci/testlist/arm-02.dat index f5c6f973a9103..aa509836394c4 100644 --- a/tools/ci/testlist/arm-02.dat +++ b/tools/ci/testlist/arm-02.dat @@ -1,4 +1 @@ -/arm/[i-k]*,CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIL --imxrt1050-evk:libcxxtest --imxrt1060-evk:libcxxtest --imxrt1064-evk:libcxxtest +/arm/[i-k]*,CONFIG_ARMV7M_TOOLCHAIN_GNU_EABI diff --git a/tools/ci/testlist/arm-03.dat b/tools/ci/testlist/arm-03.dat index 8e92ab6b00819..8740271641651 100644 --- a/tools/ci/testlist/arm-03.dat +++ b/tools/ci/testlist/arm-03.dat @@ -1,4 +1,4 @@ -/arm/lpc17xx_40xx,CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIL +/arm/lpc17xx_40xx,CONFIG_ARMV7M_TOOLCHAIN_GNU_EABI -lpcxpresso-lpc1768:thttpd -olimex-lpc1766stk:slip-httpd -olimex-lpc1766stk:thttpd-nxflat diff --git a/tools/ci/testlist/arm-04.dat b/tools/ci/testlist/arm-04.dat index de8f68647b3fb..93d7f209f1afa 100644 --- a/tools/ci/testlist/arm-04.dat +++ b/tools/ci/testlist/arm-04.dat @@ -1,11 +1,11 @@ -/arm/lc823450,CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIL +/arm/lc823450,CONFIG_ARMV7M_TOOLCHAIN_GNU_EABI -/arm/lpc214x,CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIL +/arm/lpc214x,CONFIG_ARMV7M_TOOLCHAIN_GNU_EABI -/arm/lpc2378,CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIL +/arm/lpc2378,CONFIG_ARMV7M_TOOLCHAIN_GNU_EABI -/arm/lpc31xx,CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIL +/arm/lpc31xx,CONFIG_ARMV7M_TOOLCHAIN_GNU_EABI -/arm/lpc43xx,CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIL +/arm/lpc43xx,CONFIG_ARMV7M_TOOLCHAIN_GNU_EABI -/arm/lpc54xx,CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIL +/arm/lpc54xx,CONFIG_ARMV7M_TOOLCHAIN_GNU_EABI diff --git a/tools/ci/testlist/arm-05.dat b/tools/ci/testlist/arm-05.dat index e79de836c9be3..c2c4ce5a93712 100644 --- a/tools/ci/testlist/arm-05.dat +++ b/tools/ci/testlist/arm-05.dat @@ -1,6 +1,6 @@ -/arm/[m-r]*,CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIL +/arm/[m-r]*,CONFIG_ARMV7M_TOOLCHAIN_GNU_EABI -moxa:nsh -/arm/s32k1xx,CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIL +/arm/s32k1xx,CONFIG_ARMV7M_TOOLCHAIN_GNU_EABI -/arm/sam34,CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIL +/arm/sam34,CONFIG_ARMV7M_TOOLCHAIN_GNU_EABI diff --git a/tools/ci/testlist/arm-06.dat b/tools/ci/testlist/arm-06.dat index c733d4c60ea23..cf6ce280b8e51 100644 --- a/tools/ci/testlist/arm-06.dat +++ b/tools/ci/testlist/arm-06.dat @@ -1,7 +1,7 @@ -/arm/sama5,CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIL +/arm/sama5,CONFIG_ARMV7M_TOOLCHAIN_GNU_EABI -/arm/samd2l2,CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIL +/arm/samd2l2,CONFIG_ARMV7M_TOOLCHAIN_GNU_EABI -/arm/samd5e5,CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIL +/arm/samd5e5,CONFIG_ARMV7M_TOOLCHAIN_GNU_EABI -/arm/samv7,CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIL +/arm/samv7,CONFIG_ARMV7M_TOOLCHAIN_GNU_EABI diff --git a/tools/ci/testlist/arm-07.dat b/tools/ci/testlist/arm-07.dat index c531b45b3f529..df8db1fea6c5f 100644 --- a/tools/ci/testlist/arm-07.dat +++ b/tools/ci/testlist/arm-07.dat @@ -1,7 +1,7 @@ -/arm/stm32/[a-m]*,CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIL +/arm/stm32/[a-m]*,CONFIG_ARMV7M_TOOLCHAIN_GNU_EABI -/arm/stm32/nucleo-f1*,CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIL +/arm/stm32/nucleo-f1*,CONFIG_ARMV7M_TOOLCHAIN_GNU_EABI -/arm/stm32/nucleo-f2*,CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIL +/arm/stm32/nucleo-f2*,CONFIG_ARMV7M_TOOLCHAIN_GNU_EABI -/arm/stm32/nucleo-f30*,CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIL +/arm/stm32/nucleo-f30*,CONFIG_ARMV7M_TOOLCHAIN_GNU_EABI diff --git a/tools/ci/testlist/arm-08.dat b/tools/ci/testlist/arm-08.dat index ac945ace3cd2a..35afd3d75b3f5 100644 --- a/tools/ci/testlist/arm-08.dat +++ b/tools/ci/testlist/arm-08.dat @@ -1,9 +1,9 @@ -/arm/stm32/nucleo-f33*,CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIL +/arm/stm32/nucleo-f33*,CONFIG_ARMV7M_TOOLCHAIN_GNU_EABI -/arm/stm32/nucleo-f4*,CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIL +/arm/stm32/nucleo-f4*,CONFIG_ARMV7M_TOOLCHAIN_GNU_EABI -/arm/stm32/nucleo-g*,CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIL +/arm/stm32/nucleo-g*,CONFIG_ARMV7M_TOOLCHAIN_GNU_EABI -/arm/stm32/nucleo-l*,CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIL +/arm/stm32/nucleo-l*,CONFIG_ARMV7M_TOOLCHAIN_GNU_EABI -/arm/stm32/olimex-*,CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIL +/arm/stm32/olimex-*,CONFIG_ARMV7M_TOOLCHAIN_GNU_EABI diff --git a/tools/ci/testlist/arm-09.dat b/tools/ci/testlist/arm-09.dat index 277107012ceac..68918f2e76e67 100644 --- a/tools/ci/testlist/arm-09.dat +++ b/tools/ci/testlist/arm-09.dat @@ -1,14 +1,14 @@ -/arm/stm32/olimexino-stm32,CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIL +/arm/stm32/olimexino-stm32,CONFIG_ARMV7M_TOOLCHAIN_GNU_EABI -/arm/stm32/omnibusf4,CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIL +/arm/stm32/omnibusf4,CONFIG_ARMV7M_TOOLCHAIN_GNU_EABI -/arm/stm32/photon,CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIL +/arm/stm32/photon,CONFIG_ARMV7M_TOOLCHAIN_GNU_EABI -/arm/stm32/shenzhou,CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIL +/arm/stm32/shenzhou,CONFIG_ARMV7M_TOOLCHAIN_GNU_EABI -shenzhou:thttpd -/arm/stm32/stm3210e-eval,CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIL +/arm/stm32/stm3210e-eval,CONFIG_ARMV7M_TOOLCHAIN_GNU_EABI -/arm/stm32/stm3220g-eval,CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIL +/arm/stm32/stm3220g-eval,CONFIG_ARMV7M_TOOLCHAIN_GNU_EABI -/arm/stm32/stm3240g-eval,CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIL +/arm/stm32/stm3240g-eval,CONFIG_ARMV7M_TOOLCHAIN_GNU_EABI diff --git a/tools/ci/testlist/arm-10.dat b/tools/ci/testlist/arm-10.dat index c30d5ba188d88..1b9f2db311f74 100644 --- a/tools/ci/testlist/arm-10.dat +++ b/tools/ci/testlist/arm-10.dat @@ -1,15 +1,15 @@ -/arm/stm32/stm32_tiny,CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIL +/arm/stm32/stm32_tiny,CONFIG_ARMV7M_TOOLCHAIN_GNU_EABI -/arm/stm32/stm32butterfly2,CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIL +/arm/stm32/stm32butterfly2,CONFIG_ARMV7M_TOOLCHAIN_GNU_EABI -/arm/stm32/stm32f103-minimum,CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIL +/arm/stm32/stm32f103-minimum,CONFIG_ARMV7M_TOOLCHAIN_GNU_EABI -/arm/stm32/stm32f334-disco,CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIL +/arm/stm32/stm32f334-disco,CONFIG_ARMV7M_TOOLCHAIN_GNU_EABI -/arm/stm32/stm32f3discovery,CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIL +/arm/stm32/stm32f3discovery,CONFIG_ARMV7M_TOOLCHAIN_GNU_EABI -/arm/stm32/stm32f411-minimum,CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIL +/arm/stm32/stm32f411-minimum,CONFIG_ARMV7M_TOOLCHAIN_GNU_EABI -/arm/stm32/stm32f411e-disco,CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIL +/arm/stm32/stm32f411e-disco,CONFIG_ARMV7M_TOOLCHAIN_GNU_EABI -/arm/stm32/stm32f429i-disco,CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIL +/arm/stm32/stm32f429i-disco,CONFIG_ARMV7M_TOOLCHAIN_GNU_EABI diff --git a/tools/ci/testlist/arm-11.dat b/tools/ci/testlist/arm-11.dat index 2d8f2239a7ee8..65105e87c1980 100644 --- a/tools/ci/testlist/arm-11.dat +++ b/tools/ci/testlist/arm-11.dat @@ -1,10 +1,8 @@ -/arm/stm32/stm32f4discovery,CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIL --stm32f4discovery:cxxtest --stm32f4discovery:testlibcxx +/arm/stm32/stm32f4discovery,CONFIG_ARMV7M_TOOLCHAIN_GNU_EABI -stm32f4discovery:winbuild -/arm/stm32/stm32ldiscovery,CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIL +/arm/stm32/stm32ldiscovery,CONFIG_ARMV7M_TOOLCHAIN_GNU_EABI -/arm/stm32/stm32vldiscovery,CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIL +/arm/stm32/stm32vldiscovery,CONFIG_ARMV7M_TOOLCHAIN_GNU_EABI -/arm/stm32/viewtool-stm32f107,CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIL +/arm/stm32/viewtool-stm32f107,CONFIG_ARMV7M_TOOLCHAIN_GNU_EABI diff --git a/tools/ci/testlist/arm-12.dat b/tools/ci/testlist/arm-12.dat index 5fcca3045ef89..406df4231de32 100644 --- a/tools/ci/testlist/arm-12.dat +++ b/tools/ci/testlist/arm-12.dat @@ -1,3 +1,3 @@ -/arm/stm32f*,CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIL +/arm/stm32f*,CONFIG_ARMV7M_TOOLCHAIN_GNU_EABI -/arm/stm32h*,CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIL +/arm/stm32h*,CONFIG_ARMV7M_TOOLCHAIN_GNU_EABI diff --git a/tools/ci/testlist/arm-13.dat b/tools/ci/testlist/arm-13.dat index 5656de6595f29..e6bd412b2447c 100644 --- a/tools/ci/testlist/arm-13.dat +++ b/tools/ci/testlist/arm-13.dat @@ -1,8 +1,8 @@ -/arm/stm32l*,CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIL +/arm/stm32l*,CONFIG_ARMV7M_TOOLCHAIN_GNU_EABI -/arm/str71x,CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIL +/arm/str71x,CONFIG_ARMV7M_TOOLCHAIN_GNU_EABI -/arm/[t-z]*,CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIL +/arm/[t-z]*,CONFIG_ARMV7M_TOOLCHAIN_GNU_EABI -eagle100:nxflat -eagle100:thttpd -launchxl-cc1310:nsh diff --git a/tools/ci/testlist/macos.dat b/tools/ci/testlist/macos.dat index 9834d7b349627..222505abf4109 100644 --- a/tools/ci/testlist/macos.dat +++ b/tools/ci/testlist/macos.dat @@ -17,13 +17,13 @@ # RISC-V -/risc-v/bl602/bl602evb/configs/wifi,CONFIG_RISCV_TOOLCHAIN_GNU_RVGL +/risc-v/bl602/bl602evb/configs/wifi -/risc-v/esp32c3/esp32c3-devkit/configs/wapi,CONFIG_RISCV_TOOLCHAIN_GNU_RVGL +/risc-v/esp32c3/esp32c3-devkit/configs/wapi # ARM -/arm/stm32/stm32f4discovery/configs/nsh,CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIL +/arm/stm32/stm32f4discovery/configs/nsh,CONFIG_ARMV7M_TOOLCHAIN_GNU_EABI # XTENSA diff --git a/tools/ci/testlist/risc-v.dat b/tools/ci/testlist/risc-v.dat index 31ed032c73999..184cd480093a2 100644 --- a/tools/ci/testlist/risc-v.dat +++ b/tools/ci/testlist/risc-v.dat @@ -1 +1 @@ -/risc-v,CONFIG_RISCV_TOOLCHAIN_GNU_RVGL +/risc-v diff --git a/tools/configure.sh b/tools/configure.sh index 793c0c95af7e0..e0dd40b7aa275 100755 --- a/tools/configure.sh +++ b/tools/configure.sh @@ -268,8 +268,8 @@ fi # Okay... Everything looks good. Setup the configuration echo " Copy files" -install -m 644 ${src_makedefs} "${dest_makedefs}" || \ - { echo "Failed to copy ${src_makedefs}" ; exit 8 ; } +ln -sf ${src_makedefs} ${dest_makedefs} || \ + { echo "Failed to symlink ${src_makedefs}" ; exit 8 ; } install -m 644 ${src_config} "${dest_config}" || \ { echo "Failed to copy ${src_config}" ; exit 9 ; } install -m 644 ${src_config} "${backup_config}" || \ diff --git a/tools/incdir.c b/tools/incdir.c index 8b108dd1e22af..585aa25599b3d 100644 --- a/tools/incdir.c +++ b/tools/incdir.c @@ -389,8 +389,8 @@ int main(int argc, char **argv, char **envp) exit(EXIT_FAILURE); } - (void)cygwin_conv_path(CCP_POSIX_TO_WIN_A, dirname, convpath, - bufsize); + cygwin_conv_path(CCP_POSIX_TO_WIN_A, dirname, convpath, + bufsize); incpath = convpath; } else diff --git a/tools/jlink-nuttx.c b/tools/jlink-nuttx.c index 0e817888efb67..bd47c19b54228 100644 --- a/tools/jlink-nuttx.c +++ b/tools/jlink-nuttx.c @@ -97,7 +97,9 @@ begin_packed_struct struct tcbinfo_s uint16_t state_off; uint16_t pri_off; uint16_t name_off; - uint16_t reg_num; + uint16_t regs_off; + uint16_t basic_num; + uint16_t total_num; begin_packed_struct union { @@ -156,6 +158,7 @@ struct plugin_priv_s { uint32_t *pidhash; uint32_t npidhash; + uint32_t *regsaddr; struct tcbinfo_s *tcbinfo; uint16_t running; uint32_t ntcb; @@ -215,10 +218,9 @@ static int get_pid(struct plugin_priv_s *priv, uint32_t idx, if (ret != 0) { PERROR("read %d pid error return %d\n", idx, ret); - return ret; } - return 0; + return ret; } static int get_idx_from_pid(struct plugin_priv_s *priv, @@ -230,9 +232,10 @@ static int get_idx_from_pid(struct plugin_priv_s *priv, { uint32_t tmppid; - if (get_pid(priv, idx, &tmppid)) + int ret = get_pid(priv, idx, &tmppid); + if (ret != 0) { - return -1; + return ret; } if (tmppid == pid) @@ -241,16 +244,25 @@ static int get_idx_from_pid(struct plugin_priv_s *priv, } } - return -1; + return -ENOENT; } static int setget_reg(struct plugin_priv_s *priv, uint32_t idx, uint32_t regidx, uint32_t *regval, bool write) { uint32_t regaddr; - int ret = 0; - regaddr = priv->pidhash[idx] + priv->tcbinfo->reg_offs[regidx]; + if (priv->tcbinfo->reg_offs[regidx] == UINT16_MAX) + { + if (write == 0) + { + *regval = 0; + } + + return 0; + } + + regaddr = priv->regsaddr[idx] + priv->tcbinfo->reg_offs[regidx]; if (write) { @@ -258,7 +270,7 @@ static int setget_reg(struct plugin_priv_s *priv, uint32_t idx, } else { - ret = READU32(regaddr, regval); + int ret = READU32(regaddr, regval); if (ret != 0) { PERROR("regread %d regidx %d error %d\n", idx, regidx, ret); @@ -266,35 +278,40 @@ static int setget_reg(struct plugin_priv_s *priv, uint32_t idx, } } - return ret; + return 0; } static int update_tcbinfo(struct plugin_priv_s *priv) { if (!priv->tcbinfo) { - uint16_t reg_num; - int ret; + uint16_t total_num; uint32_t reg_off; + int ret; ret = READU16(g_symbols[TCBINFO].address + - offsetof(struct tcbinfo_s, reg_num), ®_num); - if (ret != 0 || !reg_num) + offsetof(struct tcbinfo_s, total_num), &total_num); + if (ret != 0) { PERROR("error reading regs ret %d\n", ret); return ret; } + if (!total_num) + { + return -EIO; + } + ret = READU32(g_symbols[TCBINFO].address + offsetof(struct tcbinfo_s, reg_off), ®_off); - if (ret != 0 || !reg_off) + if (ret != 0) { PERROR("error in read regoffs address ret %d\n", ret); return ret; } priv->tcbinfo = ALLOC(sizeof(struct tcbinfo_s) + - reg_num * sizeof(uint16_t)); + total_num * sizeof(uint16_t)); if (!priv->tcbinfo) { @@ -311,14 +328,12 @@ static int update_tcbinfo(struct plugin_priv_s *priv) } ret = READMEM(reg_off, (char *)&priv->tcbinfo->reg_offs[0], - reg_num * sizeof(uint16_t)); - if (ret != reg_num * sizeof(uint16_t)) + total_num * sizeof(uint16_t)); + if (ret != total_num * sizeof(uint16_t)) { PERROR("error in read tcbinfo_s reg_offs ret %d\n", ret); return ret; } - - PLOG("setup success! regs %d\n", priv->tcbinfo->reg_num); } return 0; @@ -329,6 +344,7 @@ static int update_pidhash(struct plugin_priv_s *priv) uint32_t npidhash; uint32_t pidhashaddr; int ret; + int i; ret = READU32(g_symbols[NPIDHASH].address, &npidhash); if (ret != 0 || npidhash == 0) @@ -347,6 +363,14 @@ static int update_pidhash(struct plugin_priv_s *priv) return -ENOMEM; } + priv->regsaddr = + REALLOC(priv->regsaddr, npidhash * sizeof(uint32_t *)); + if (!priv->regsaddr) + { + PERROR("error in malloc regsaddr\n"); + return -ENOMEM; + } + PLOG("npidhash change from %d to %d!\n", priv->npidhash, npidhash); priv->npidhash = npidhash; } @@ -366,6 +390,20 @@ static int update_pidhash(struct plugin_priv_s *priv) return ret; } + for (i = 0; i < priv->npidhash; i++) + { + if (priv->pidhash[i]) + { + ret = READU32(priv->pidhash[i] + priv->tcbinfo->regs_off, + &priv->regsaddr[i]); + if (ret != 0) + { + PERROR("error in task %d read regs pointer %d\n", i, ret); + return ret; + } + } + } + return 0; } @@ -381,7 +419,9 @@ static int normalize_tcb(struct plugin_priv_s *priv) { if (priv->pidhash[i]) { - priv->pidhash[priv->ntcb++] = priv->pidhash[i]; + priv->pidhash[priv->ntcb] = priv->pidhash[i]; + priv->regsaddr[priv->ntcb] = priv->regsaddr[i]; + priv->ntcb++; } } @@ -389,6 +429,7 @@ static int normalize_tcb(struct plugin_priv_s *priv) if (ret != 0) { PERROR("read readytorun error return %d\n", ret); + return ret; } ret = READU16(tcbaddr + priv->tcbinfo->pid_off, &priv->running); @@ -491,7 +532,7 @@ int RTOS_GetThreadDisplay(char *display, uint32_t threadid) if (idx < 0) { PERROR("error in get_idx_from_pid return %d\n", idx); - return -1; + return idx; } len += snprintf(display + len, @@ -544,6 +585,7 @@ int RTOS_GetThreadDisplay(char *display, uint32_t threadid) int RTOS_GetThreadReg(char *hexregval, uint32_t regindex, uint32_t threadid) { int idx; + int ret; uint32_t regval = 0; threadid -= THREADID_BASE; @@ -552,30 +594,29 @@ int RTOS_GetThreadReg(char *hexregval, uint32_t regindex, uint32_t threadid) if (threadid == g_plugin_priv.running) { - return -1; + return -ENOTSUP; } - if (regindex > g_plugin_priv.tcbinfo->reg_num) + if (regindex > g_plugin_priv.tcbinfo->total_num) { - return -1; + return -EINVAL; } idx = get_idx_from_pid(&g_plugin_priv, threadid); if (idx < 0) { PERROR("error in get_idx_from_pid return %d\n", idx); - return -1; + return idx; } - if (g_plugin_priv.tcbinfo->reg_offs[regindex]) + ret = setget_reg(&g_plugin_priv, idx, regindex, ®val, false); + if (ret != 0) { - setget_reg(&g_plugin_priv, idx, regindex, ®val, false); - - encode_hex(hexregval, regval); - return 0; + return ret; } - return -1; + encode_hex(hexregval, regval); + return 0; } int RTOS_GetThreadRegList(char *hexreglist, uint32_t threadid) @@ -590,23 +631,24 @@ int RTOS_GetThreadRegList(char *hexreglist, uint32_t threadid) if (threadid == g_plugin_priv.running) { - return -1; + return -ENOTSUP; } idx = get_idx_from_pid(&g_plugin_priv, threadid); if (idx < 0) { PERROR("error in get_idx_from_pid return %d\n", idx); - return -1; + return idx; } - for (j = 0; j < 17; j++) + for (j = 0; j < g_plugin_priv.tcbinfo->basic_num; j++) { regval = 0; - if (g_plugin_priv.tcbinfo->reg_offs[j]) + int ret = setget_reg(&g_plugin_priv, idx, j, ®val, false); + if (ret != 0) { - setget_reg(&g_plugin_priv, idx, j, ®val, false); + return ret; } hexreglist += encode_hex(hexreglist, regval); @@ -625,30 +667,24 @@ int RTOS_SetThreadReg(char *hexregval, if (threadid == g_plugin_priv.running) { - return -1; + return -ENOTSUP; } - if (regindex > g_plugin_priv.tcbinfo->reg_num) + if (regindex > g_plugin_priv.tcbinfo->total_num) { - return -1; + return -EINVAL; } idx = get_idx_from_pid(&g_plugin_priv, threadid); if (idx < 0) { PERROR("error in get_idx_from_pid return %d\n", idx); - return -1; + return idx; } - if (g_plugin_priv.tcbinfo->reg_offs[regindex]) - { - regval = decode_hex(hexregval); - - setget_reg(&g_plugin_priv, idx, regindex, ®val, true); - return 0; - } + regval = decode_hex(hexregval); - return -1; + return setget_reg(&g_plugin_priv, idx, regindex, ®val, true); } int RTOS_SetThreadRegList(char *hexreglist, uint32_t threadid) @@ -661,30 +697,27 @@ int RTOS_SetThreadRegList(char *hexreglist, uint32_t threadid) if (threadid == g_plugin_priv.running) { - return -1; + return -ENOTSUP; } idx = get_idx_from_pid(&g_plugin_priv, threadid); if (idx < 0) { PERROR("error in get_idx_from_pid return %d\n", idx); - return -1; + return idx; } - for (j = 0; j < 17; j++) + for (j = 0; j < g_plugin_priv.tcbinfo->basic_num; j++) { - if (g_plugin_priv.tcbinfo->reg_offs[j]) - { - regval = decode_hex(hexreglist); - - setget_reg(&g_plugin_priv, idx, j, ®val, true); + regval = decode_hex(hexreglist); - hexreglist += 4; - } - else + int ret = setget_reg(&g_plugin_priv, idx, j, ®val, true); + if (ret != 0) { - return -1; + return ret; } + + hexreglist += 4; } return 0; diff --git a/tools/minidumpserver.py b/tools/minidumpserver.py index 9800708ee3973..61ad8a27e13aa 100755 --- a/tools/minidumpserver.py +++ b/tools/minidumpserver.py @@ -165,6 +165,28 @@ def parse(self): "T6": 31, "PC": 32, }, + "xtensa": { + "PC": 0, + "SAR": 68, + "PS": 73, + "SCOM": 29, + "A0": 21, + "A1": 22, + "A2": 23, + "A3": 24, + "A4": 25, + "A5": 26, + "A6": 27, + "A7": 28, + "A8": 29, + "A9": 30, + "A10": 31, + "A11": 32, + "A12": 33, + "A13": 34, + "A14": 35, + "A15": 36, + } } @@ -200,7 +222,7 @@ def parse(self): logger.error("%s not supported" % (self.arch)) # init register list if len(self.registers) == 0: - for x in range(len(reg_table[self.arch])): + for x in range(max(reg_table[self.arch].values()) + 1): self.registers.append(b"x") # find register value diff --git a/tools/mkdeps.c b/tools/mkdeps.c index bb198169b933e..122fbb95e4aea 100644 --- a/tools/mkdeps.c +++ b/tools/mkdeps.c @@ -46,7 +46,7 @@ #define MAX_BUFFER (8192) #define MAX_EXPAND (2048) -#define MAX_SHQUOTE (2048) +#define MAX_SHQUOTE (3072) /* MAX_PATH might be defined in stdlib.h */ diff --git a/tools/mkromfsimg.sh b/tools/mkromfsimg.sh index 94eb858a4ec67..cbf2d0e3e1af8 100755 --- a/tools/mkromfsimg.sh +++ b/tools/mkromfsimg.sh @@ -23,6 +23,8 @@ wd=`pwd` workingdir=$wd/img +rcsysinitfile=rc.sysinit +rcsysinittemplate=$rcsysinitfile.template rcsfile=rcS rcstemplate=$rcsfile.template romfsimg=romfs.img @@ -33,8 +35,9 @@ headerfile=nsh_romfsimg.h nofat=$1 usefat=true topdir=$2 -rcs_fname=$3 -usage="USAGE: $0 [-nofat] []" +rcsysinit_fname=$3 +rcs_fname=$4 +usage="USAGE: $0 [-nofat] [rcsysinitfile] []" # Verify if we have the optional "-nofat" @@ -43,7 +46,8 @@ if [ "$nofat" == "-nofat" ]; then usefat=false else topdir=$1 - rcs_fname=$2 + rcsysinit_fname=$2 + rcs_fname=$3 fi if [ -z "$topdir" -o ! -d "$topdir" ]; then @@ -52,7 +56,12 @@ if [ -z "$topdir" -o ! -d "$topdir" ]; then exit 1 fi -# Verify if we have the optional "rcs_fname" +# Verify if we have the optional "rcsysinit_fname" and "rcs_fname" + +if [ ! -z "$rcsysinit_fname" ]; then + rcsysinittemplate=$rcsysinit_fname + echo "Target template is $rcsysinittemplate" +fi if [ ! -z "$rcs_fname" ]; then rcstemplate=$rcs_fname @@ -77,6 +86,7 @@ devconsole=`grep CONFIG_DEV_CONSOLE= $topdir/.config | cut -d'=' -f2` romfs=`grep CONFIG_FS_ROMFS= $topdir/.config | cut -d'=' -f2` romfsmpt=`grep CONFIG_NSH_ROMFSMOUNTPT= $topdir/.config | cut -d'=' -f2` initscript=`grep CONFIG_NSH_INITSCRIPT= $topdir/.config | cut -d'=' -f2` +sysinitscript=`grep CONFIG_NSH_SYSINITSCRIPT= $topdir/.config | cut -d'=' -f2` romfsdevno=`grep CONFIG_NSH_ROMFSDEVNO= $topdir/.config | cut -d'=' -f2` romfssectsize=`grep CONFIG_NSH_ROMFSSECTSIZE= $topdir/.config | cut -d'=' -f2` @@ -140,6 +150,9 @@ fi if [ -z "$initscript" ]; then initscript=\"init.d/rcS\" fi +if [ -z "$sysinitscript" ]; then + sysinitscript=\"init.d/rc.sysinit\" +fi if [ -z "$romfsdevno" ]; then romfsdevno=0 fi @@ -217,15 +230,35 @@ if [ "X$uinitscript" = "." -o ${uinitscript:0:2} = "./" -o \ exit 1 fi +if [ ${sysinitscript:0:1} != "\"" ]; then + echo "CONFIG_NSH_SYSINITSCRIPT must be a string" + echo "Change it so that it is enclosed in quotes." + exit 1 +fi + +usysinitscript=`echo $sysinitscript | sed -e "s/\"//g"` + +if [ ${usysinitscript:0:1} == "/" ]; then + echo "CONFIG_NSH_SYSINITSCRIPT must be an relative path in under $romfsmpt" + echo "Change it so that it begins with the character '/'. Eg. init.d/rc.sysinit. " + exit 1 +fi + +if [ "X$usysinitscript" = "." -o ${usysinitscript:0:2} = "./" -o \ + "X$usysinitscript" = ".." -o ${usysinitscript:0:3} = "../" ]; then + echo "Invalid CONFIG_NSH_SYSINITSCRIPT selection. Must not begin with . or .." + exit 1 +fi + # Create a working directory rm -rf $workingdir || { echo "Failed to remove the old $workingdir"; exit 1; } mkdir -p $workingdir || { echo "Failed to created the new $workingdir"; exit 1; } -# Create the rcS file from the rcS.template +# Create the rc.sysinit file from the rc.sysinit.template -if [ ! -r $rcstemplate ]; then - echo "$rcstemplate does not exist" +if [ ! -r $rcsysinittemplate ]; then + echo "$rcsysinittemplate does not exist" rmdir $workingdir exit 1 fi @@ -233,21 +266,35 @@ fi # If we are using FAT FS with RAMDISK we need to setup it if [ "$usefat" = true ]; then - cat $rcstemplate | \ + cat $rcsysinittemplate | \ sed -e "s,XXXMKRDMINORXXX,$fatdevno,g" | \ sed -e "s,XXMKRDSECTORSIZEXXX,$fatsectsize,g" | \ sed -e "s,XXMKRDBLOCKSXXX,$fatnsectors,g" | \ - sed -e "s,XXXRDMOUNTPOINTXXX,$fatmpt,g" >$rcsfile + sed -e "s,XXXRDMOUNTPOINTXXX,$fatmpt,g" >$rcsysinitfile else - cp $rcstemplate $rcsfile + cp $rcsysinittemplate $rcsysinitfile fi +# Create the rcS file from the rcS.template + +if [ ! -r $rcstemplate ]; then + echo "$rcstemplate does not exist" + rmdir $workingdir + exit 1 +fi + +cp $rcstemplate $rcsfile + # And install it at the specified relative location # Fix for BSD install without -D option mkdir -p $workingdir/$uinitscript rmdir $workingdir/$uinitscript +install -m 0755 $rcsysinitfile $workingdir/$usysinitscript || \ + { echo "Failed to install $rcsysinitfile at $workingdir/$usysinitscript"; rm -f $rcsysinitfile; exit 1; } +rm -f $rcsysinitfile + install -m 0755 $rcsfile $workingdir/$uinitscript || \ { echo "Failed to install $rcsfile at $workingdir/$uinitscript"; rm -f $rcsfile; exit 1; } rm -f $rcsfile diff --git a/tools/mksyscall.c b/tools/mksyscall.c index 352bd1c4b7f56..a03c8080ef99b 100644 --- a/tools/mksyscall.c +++ b/tools/mksyscall.c @@ -313,7 +313,7 @@ static void generate_proxy(int nfixed, int nparms) if (strcmp(g_parm[RETTYPE_INDEX], "void") == 0 || strcmp(g_parm[RETTYPE_INDEX], "noreturn") == 0) { - fprintf(stream, " (void)sys_call%d(", nparms); + fprintf(stream, " sys_call%d(", nparms); } else { diff --git a/tools/parsememdump.py b/tools/parsememdump.py index daf5bc9ae183d..7707e98060743 100755 --- a/tools/parsememdump.py +++ b/tools/parsememdump.py @@ -45,19 +45,10 @@ def __init__(self, line_str): return self.size = int(tmp.group(0)[1:]) - tmp = re.search(r"\b0x[0-9a-fA-F]+\b", line_str[tmp.span()[1] :]) - self.addr = tmp.group(0) - line_str = line_str[tmp.span()[1] :] - while 1: - tmp = re.search(r"\b0x[0-9a-fA-F]+\b", line_str[tmp.span()[1] :]) - if tmp is None: - break - self.mem.append(tmp.group(0)) - line_str = line_str[tmp.span()[1] :] - - if self.mem.__len__() == 0: - self.err = 1 - return + tmp = re.findall("0x([0-9a-fA-F]+)", line_str[tmp.span()[1] :]) + self.addr = tmp[0] + for str in tmp[1:]: + self.mem.append(str) class log_output: diff --git a/tools/testbuild.sh b/tools/testbuild.sh index 1cc92b5f0be32..a44a23fcb14ba 100755 --- a/tools/testbuild.sh +++ b/tools/testbuild.sh @@ -257,6 +257,10 @@ function build { xargs -I "{}" cp "{}" $artifactconfigdir < $nuttx/nuttx.manifest fi + return $fail +} + +function refresh { # Ensure defconfig in the canonical form if ! ./tools/refresh.sh --silent $config; then @@ -300,10 +304,11 @@ function dotest { config=`echo $1 | cut -d',' -f1` check=${HOST},${config/\//:} + skip=0 for re in $blacklist; do if [[ "${check}" =~ ${re:1}$ ]]; then echo "Skipping: $1" - return + skip=1 fi done @@ -346,8 +351,11 @@ function dotest { echo "------------------------------------------------------------------------------------" distclean configure - build - run + if [ ${skip} -ne 1 ]; then + build + run + fi + refresh } # Perform the build test for each entry in the test list file diff --git a/wireless/ieee802154/mac802154_device.c b/wireless/ieee802154/mac802154_device.c index 3b268fffa3302..ff937ab4986c7 100644 --- a/wireless/ieee802154/mac802154_device.c +++ b/wireless/ieee802154/mac802154_device.c @@ -130,11 +130,11 @@ static int mac802154dev_rxframe(FAR struct mac802154_chardevice_s *dev, static int mac802154dev_open(FAR struct file *filep); static int mac802154dev_close(FAR struct file *filep); static ssize_t mac802154dev_read(FAR struct file *filep, FAR char *buffer, - size_t len); + size_t len); static ssize_t mac802154dev_write(FAR struct file *filep, - FAR const char *buffer, size_t len); + FAR const char *buffer, size_t len); static int mac802154dev_ioctl(FAR struct file *filep, int cmd, - unsigned long arg); + unsigned long arg); /**************************************************************************** * Private Data @@ -142,9 +142,9 @@ static int mac802154dev_ioctl(FAR struct file *filep, int cmd, static const struct file_operations mac802154dev_fops = { - mac802154dev_open , /* open */ + mac802154dev_open, /* open */ mac802154dev_close, /* close */ - mac802154dev_read , /* read */ + mac802154dev_read, /* read */ mac802154dev_write, /* write */ NULL, /* seek */ mac802154dev_ioctl, /* ioctl */