summaryrefslogtreecommitdiff
path: root/libcpu/risc-v
AgeCommit message (Collapse)Author
2026-01-13Resolve merge conflicts with master branchcopilot-swe-agent[bot]
Co-authored-by: Rbb666 <[email protected]>
2025-11-16Reorganize Group names in build system for clarity and IDE integration #10923Copilot
2025-09-03fix(risc-v, virt64, plic): use volatile rw for claim and completeHaojin Tang
2025-09-01fix(risc-v, mmu): fix type mismatch of `_query`Haojin Tang
2025-09-01fix(risc-v/virt64, cpp): add spaces to fix `Wliteral-suffix`Haojin Tang
2025-09-01fix(riscv, cpp): remove `rt_hw_cpu_id` in `cpuport.h` to fix errorHaojin Tang
2025-07-23[lwp][rv64] restore tp register in arch_thread_signal_enter to fix user-mode ↵Yulong Wang
memory access
2025-05-30[bsp]增加超睿DP1000 bsp支持ZhangJing
2025-05-30移除无用文件,该文件未被任何BSP使用Yaochenger
2025-05-30[libcpu/common] ↵Yaochenger
修正对RV32E的支持,RV32E不支持s2寄存器,修改为s1寄存器
2025-05-28[libcpu][risc-v]:add comment for the round down of symb_pczhangjing
2025-05-28[libcpu][risc-v] fix:only map the 1GB space where the original code segment ↵zhangjing
is located
2025-04-11libcpu: riscv: declare external symbols insideChen Wang
libcpu/risc-v/common64/mmu.c uses the external symbol "__bss_end" (this symbol generally is defined in the link script file) and depends on the extern declaration of this symbol in the bsp's "board.h". This is not a problem in implementation, but it is not a good habit. If this extern symbol is used locally, just declare it locally should be better. In this way, there will be no dependency of the kernel core on the bsp header file. And there will be no special requirements for the bsp board code, such as the need to make extern declarations for these "__bss_end" symbols in "board.h". This patch currently only explicitly externly declares "__bss_end" inside libcpu itself. The code of "#include <board.h>" is kept, because the modification involved is too large, it is necessary to clean up the bsp involved before cleaning this include code line uniformly. Signed-off-by: Chen Wang <[email protected]>
2025-04-11libcpu: cleanup undefined rt_hw_mmu_kernel_map_init (#10177)Chen Wang
* libcpu: cleanup undefined rt_hw_mmu_kernel_map_init rt_hw_mmu_kernel_map_init() is declared in header files but no definition found, cleanup the code. Signed-off-by: Chen Wang <[email protected]> * bsp: allwinner: d1: remove calling of rt_hw_mmu_kernel_map_init rt_hw_mmu_kernel_map_init is an undefined function, calling it is meaningless. Signed-off-by: Chen Wang <[email protected]> --------- Signed-off-by: Chen Wang <[email protected]>
2025-03-17[libcpu][risc-v]add code for handling exception scenarios in _unmap_area.ligr
2025-03-17[libcpu][risc-v]remove unused parameter 'size' for func _unmap_area.ligr
Signed-off-by: ligr <[email protected]>
2025-03-12[libcpu][risc-v]add comments for rt_hw_mem_setup_early. (#10102)Guorui Li
2025-03-03[libcpu][riscv] add a doc for wch saving the irq stack as stack-512 (#10063)Kai
2025-03-02[libcpu][risc-v]add comments for rv64 sv39 mmu APIs. (#10053)Guorui Li
2025-02-28[bugfix][risc-v]fix the PPN length error in GET_PPN(pte). (#10020)Guorui Li
2025-02-22libcpu: riscv: fixed ARCH_RISCV_VECTOR issuekenneth.liu
description: Using the vector instruction set to trigger an illegal instruction exception when ARCH_SISCV_VECTOR=y. analysis: When initializing the thread stack, the rt_cw_stack_init function did not enable VS for SSTATUS. Solution: When ARCH_SISCV_VECTOR=y, increment the initial value of sstatus by 0x600(SSTATUS_VS). Signed-off-by: Liu Gui <[email protected]>
2025-01-29libcpu: riscv: rv64: fixed warningsChen Wang
When building bsp/cvitek/c906_little, compiler reports: ``` .../rt-thread/libcpu/risc-v/rv64/trap.c: In function 'handle_trap': .../rt-thread/libcpu/risc-v/rv64/trap.c:106:13: warning: implicit declaration of function 'rt_hw_tick_isr'; did you mean 'rt_hw_stack_init'? [-Wimplicit-function-declaration] 106 | rt_hw_tick_isr(); | ^~~~~~~~~~~~~~ | rt_hw_stack_init .../rt-thread/libcpu/risc-v/rv64/trap.c:110:13: warning: implicit declaration of function 'rt_hw_irq_isr'; did you mean 'rt_hw_soft_irq_isr'? [-Wimplicit-function-declaration] 110 | rt_hw_irq_isr(); | ^~~~~~~~~~~~~ | rt_hw_soft_irq_isr ``` rt_hw_tick_isr()/rt_hw_irq_isr() are implemented by bsp, but libcpu/risc-v/rv64 doesn't declare them, so compiler warns. There are three BSPs using 'rv64' (libcpu/risc-v/rv64): - `bsp/cvitek/c906_little/rtconfig.py` - `bsp/juicevm/rtconfig.py` - `bsp/k210/rtconfig.py` `handle_trap` in `libcpu/risc-v/rv64` is defined as weak. BSP can use this function directly or define and overload it by itself. If bsp use this function directly, bsp need to pay attention to the fact that three functions will be called in this function: - `rt_hw_soft_irq_isr` - `rt_hw_tick_isr` - `rt_hw_irq_isr` In `libcpu/risc-v/rv64`, `rt_hw_soft_irq_isr` has a weak definition, while the other two do not. This means that if the bsp does not overload `handle_trap`, bsp must define `rt_hw_tick_isr` and `rt_hw_irq_isr` itself. This is also the practice of `bsp/cvitek/c906_little`. There is also a similar bsp `bsp/k210`, and the form of `bsp/juicevm` implements `handle_trap` by itself. It seems that `rt_hw_tick_isr` and `rt_hw_irq_isr` are not required to be implemented by all BSPs using `libcpu/risc-v/rv64`. The premise for BSP to implement them is that it does not overload `handle_trap`. So declaring `rt_hw_tick_isr` and `rt_hw_irq_isr` with extern in `libcpu/risc-v/rv64` is not proper. In addition, the `rt_hw_tick_isr/rt_hw_irq_isr` are only used by `libcpu/risc-v/rv64`, so it is not worth putting the declaration in `./include/rthw.h`. Sum up, the best solution is to add weak definition to `rt_hw_tick_isr/rt_hw_irq_isr` as existing `rt_hw_soft_irq_isr`. Signed-off-by: Chen Wang <[email protected]>
2025-01-29libcpu: riscv: common: fixed build warningsChen Wang
When building bsp/cvitek/c906_little, compiler warns: ``` .../rt-thread/libcpu/risc-v/common/trap_common.c: In function 'rt_hw_interrupt_install': .../rt-thread/libcpu/risc-v/common/trap_common.c:50:11: warning: unused variable 'user_param' [-Wunused-variable] 50 | void *user_param = param; | ^~~~~~~~~~ .../rt-thread/libcpu/risc-v/common/trap_common.c: In function 'rt_rv32_system_irq_handler': .../rt-thread/libcpu/risc-v/common/trap_common.c:77:25: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast] 77 | s_stack_frame = (rt_hw_stack_frame_t *)mscratch; | ^ ``` Fixed these warnings as per indication from gcc. Signed-off-by: Chen Wang <[email protected]>
2025-01-10bsp: qemu-virt64-riscv: remove config RISCV_S_MODEChen Wang
RISCV_S_MODE configuration only affects the code in libcpu/risc-v/virt64, and the only bsp using this libcpu is qemu-virt64-riscv. Considering s-mode is the default mode RT-Thread running on virt64 machine, it seems unnecessary to make RISCV_S_MODE a Kconfig option. Solution: Remove RISCV_S_MODE from Kconfig and define it as a macro in the code in libcpu/risc-v/virt64. Plus, due to this macro is only related to virt64, rename RISCV_S_MODE to RISCV_VIRT64_S_MODE. Update the .config/rtconfig.h in this patch. Signed-off-by: Chen Wang <[email protected]>
2024-11-29[libcpu/riscv]解决smp下cpuport.h中的编译问题 (#9714)heyuanjie87
2024-11-27给vector模块添加构建脚本heyuanjie87
2024-11-27[libcpu][riscv]virt64使用通用vector支持代码heyuanjie87
2024-11-21[libcpu][riscv]纠正pv_offset的对齐检查heyuanjie87
2024-11-15[libcpu]riscv使用call指令解决长跳转问题heyuanjie87
2024-10-23[kernel] Specification interrupt nested level variable declaration type (#9568)Yuqiang Wang
2024-10-16[libcpu]添加对riscv vector的支持 (#9531)heyuanjie87
[libcpu]添加对riscv vector的支持
2024-10-11[libcpu][risc-v] fix the bug when using ASID in the RV64 MMUzhangjing0303
* (fix) mmu: satp value should be 64-bit Corrected the SATP register to ensure it uses the correct 64-bit format as required by the system architecture. * use __asm__ instead of asm for the GNU C compiler Co-authored-by: Shell <[email protected]> --------- Co-authored-by: Shell <[email protected]>
2024-10-09[libcpu][risc-v]remove the redundant "0x" from the printed information when ↵zhangjing0303
cpu is in exception (#9516) Remove redundant '0x' from printed output
2024-10-08[libcpu][risc-v]add README for RV64zhangjing0303
2024-09-23删除多余空格heyuanjie87
2024-09-23[libcpu]rv添加c908 cpuheyuanjie87
2024-09-18[libcpu]优化rv构建脚本中选择vendor目录的判断条件heyuanjie87
2024-09-13feat: remove redundant codes under virt64, c906Shell
Changes: - create new folder name `common64` and save all common codes of rv64 inside Signed-off-by: Shell <[email protected]>
2024-09-11feat: libcpu/risc-v: unify low-level bringupsShell
This patch consolidates the separated architecture-specific code for rv64 (virt64 and c906) under a more unified approach. The changes aim to enhance maintainability and code reuse, reducing duplication between these two architectures while adding small improvements in porting compatibility. Changes: - Modified build scripts (SConscript) for both virt64 and c906 to remove ASID and vector dependencies when not required. - Updated c906's sbi.c and sbi.h to use standard integer types (uint32_t) and include the missing <stdint.h> header. - Unified inline function declaration for `sbi_call` across both c906 and virt64 using `rt_inline`. - Disabled FPU and vector in c906's startup assembly file, aligning it with the virt64 handling. - Corrected syscall handler type definitions in c906 for consistency. Signed-off-by: Shell <[email protected]>
2024-09-11feat: libcpu/risc-v: unify interrupt & IO on rv64Shell
This patch aims to unify the two currently separated RISC-V 64-bit architecture ports, 'virt64' and 'c906', into a single generic 'common64' port. The changes include renaming files and updating includes to use a unified 'interrupt.h' header, as well as making adjustments to IO and trap handling to be more consistent between the two architectures. Changes: - Renamed 'rt_interrupt.h' to 'interrupt.h' and updated includes accordingly. - Unified IO register access functions in 'riscv_io.h'. - Added 'opcode.h' for portable assembly support. - Updated 'plic.c' and 'plic.h' to handle interrupts in a unified manner. - Modified 'trap.c' to handle exceptions and interrupts consistently for 'rv64'. Signed-off-by: Shell <[email protected]>
2024-09-11feat: libcpu/risc-v: unify mmu related worksShell
These changes are designed to standardize the memory management across 'virt64' and 'c906', ensuring efficient handling of address spaces and page tables. Changes: - Creation of ASID management files (`asid.c`) for both 'c906' and 'virt64' architectures, which is essential for maintaining stability. - Extensive updates to the MMU configuration and handling in `mmu.c` and `mmu.h` files. - Addition of functions to manage ASID allocation and switching of page tables. - For c906, accommodated the early memory setup to the one from virt64. Signed-off-by: Shell <[email protected]>
2024-09-11feat: libcpu/risc-v: unify context on c906, virt64Shell
Changes: - added config for NEW_CTX_SWITCH - used new context on c906 sched switch routine - update _rt_hw_stack_init to fit into NEW_CTX_SWITCH - separated vector ctx from the generic Signed-off-by: Shell <[email protected]>
2024-09-01feat: kernel/libcpu: fit into ilp32dShell
2024-08-27rename c906 FPU macro (#9290)flyingcys
1. 修改 ENABLE_FPU 为 ARCH_RISCV_FPU,与libcpu/common 保持统一 2. 对 bsp/cvitek/cv18xx_risc-v 中增加使能 ARCH_RISCV_FPU 的动作。解决了 issue #9075
2024-08-01[bsp][ch32] add eth driverYaochenger
2024-07-18adapt to rv64ilp32 toolchainMuChenger
2024-07-17Merge branch 'master' into shell/rv64-tickShell
2024-07-15Bugfix/fix weak handle trap in riscv common crash rv64 trap handling (#9189)Fan Yang
* [bsp][hpmicro] add weak handle_trap implementation - added weak handle_trap implementation Signed-off-by: Fan YANG <[email protected]> * [libcpu][risc-v][common] remove weak handle_trap function - removed weak handle_trap function from trap_common.c Signed-off-by: Fan YANG <[email protected]> --------- Signed-off-by: Fan YANG <[email protected]>
2024-07-15[libcpu/rv64] feat: unify tick.cShell
The changes unify the tick.c implementations for all risc-v64 architectures, leveraging the CPUTIME feature. This refactoring was necessary to streamline the codebase, and ensure consistent timer handling across different platforms. Changes: - Updated `Kconfig` in `bsp/cvitek/cv18xx_risc-v` to fix formatting issues. - Updated .config for BSPs to update `CPUTIME_TIMER_FREQ` - Updated header of for API `riscv_cputime_init` - Initialized riscv timer on `rt_hw_tick_init` - Refactored `tick.c` and `tick.h` in `libcpu/risc-v/t-head/c906` and `libcpu/risc-v/virt64`: - Replaced direct use of `rdtime` with `clock_cpu_gettime`. - Removed redundant timer frequency definitions. - Added static assertions to check the value of `CPUTIME_TIMER_FREQ`. - Initialized `tick_cycles` based on `CPUTIME_TIMER_FREQ`. - Integrated `ktime` support for tick initialization. Signed-off-by: Shell <[email protected]> Reviewed-on: https://github.com/RT-Thread/rt-thread/pull/9164 Reviewed-by: Chen Wang <[email protected]>
2024-07-11feat: support ARCH_REMAP_KERNEL on libcpu/c906 (#9123)Shell
feat: [libcpu/c906] support ARCH_REMAP_KERNEL This change was necessary to enable the remapping of the kernel image to a high virtual address region on the c906 platform. Changes: - Introduced new configuration options `ARCH_REMAP_KERNEL`, and `ARCH_USING_ASID` under the `ARCH_RISCV64` section. - Updated MMU initialization and switching functions to incorporate remapping handling. - Modified page table setup for proper memory attribute settings. - Added support for early memory setup, kernel remapping - Added conditional compilation for ASID support in the `rt_aspace` struct, since this is not enable currently for most architecture. Signed-off-by: Shell <[email protected]>