mirror of
https://github.com/RT-Thread/rt-thread.git
synced 2026-11-16 01:05:15 +08:00
* [libcpu][risc-v] Refactor the RISC-V architecture port Introduce an opt-in unified RISC-V common layer for RV32 and RV64 while keeping existing BSPs on the legacy implementation during migration. - use ARCH_RISCV and ARCH_CPU_64BIT for architecture and XLEN selection - unify context, trap, MMU, cache, timer, SBI, SMP and ISA handling - add PLIC, CLIC, ACLINT, APLIC and IMSIC support - map physical hart IDs to contiguous logical CPU IDs - add T-Head vendor overrides while preserving legacy ports - migrate qemu-virt64-riscv with RV32 and RV64 support - update clock_time, MM, LWP, OFW, PCI and Rust integration Existing BSPs continue using legacy_common or common64 unless they select RT_USING_RISCV_NEW_COMMON. Signed-off-by: GuEe-GUI <2991707448@qq.com> * [libcpu][risc-v] skip disabled CPU nodes in early FDT walk Rbb666 noted that rt_hw_fdt_install_early() walked every /cpus child without checking status, so disabled cores still joined hart registration and MMU capability probing. Skip nodes that are not okay/ok via rt_fdt_device_is_available() before reading reg or mmu-type. Signed-off-by: seteiro <chenmoushun@163.com> * [libcpu][risc-v] Fix per-CPU page table mapping - reuse existing non-leaf page table entries when mapping per-CPU areas - reject leaf entry conflicts instead of overwriting mappings Signed-off-by: GuEe-GUI <2991707448@qq.com> --------- Signed-off-by: GuEe-GUI <2991707448@qq.com> Signed-off-by: seteiro <chenmoushun@163.com> Co-authored-by: seteiro <chenmoushun@163.com>
85 lines
2.4 KiB
C
85 lines
2.4 KiB
C
/*
|
|
* Copyright (c) 2006-2025, RT-Thread Development Team
|
|
*
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
*
|
|
* Change Logs:
|
|
* Date Author Notes
|
|
* 2022-11-09 Shell Add portable asm support
|
|
* 2025-04-26 GuEe-GUI Follow the specific and vendor
|
|
*/
|
|
|
|
#ifndef __OPCODE_H__
|
|
#define __OPCODE_H__
|
|
|
|
#include <rtcompiler.h>
|
|
|
|
#include <asm-generic.h>
|
|
#ifdef __HAS_OPCODE_VENDOR__
|
|
#include <opcode_vendor.h>
|
|
#endif
|
|
|
|
/**
|
|
* @brief binary opcode pseudo operations
|
|
* Used to bypass toolchain restriction on extension ISA
|
|
*
|
|
*/
|
|
|
|
/**
|
|
* @brief RISC-V instruction formats
|
|
*/
|
|
|
|
#define OPCODE_MISC_MEM 15
|
|
#define OPCODE_SYSTEM 115
|
|
|
|
#ifndef __OPC_INSN_FORMAT_R
|
|
/**
|
|
* R type: .insn r opcode6, func3, func7, rd, rs1, rs2
|
|
*
|
|
* +-------+-----+-----+-------+----+---------+
|
|
* | func7 | rs2 | rs1 | func3 | rd | opcode6 |
|
|
* +-------+-----+-----+-------+----+---------+
|
|
* 31 25 20 15 12 7 0
|
|
*/
|
|
#define __OPC_INSN_FORMAT_R(opcode, func3, func7, rd, rs1, rs2) \
|
|
".insn r "RT_STRINGIFY(opcode)","RT_STRINGIFY(func3)","RT_STRINGIFY(func7)","RT_STRINGIFY(rd)","RT_STRINGIFY(rs1)","RT_STRINGIFY(rs2)"\n\t"
|
|
#endif /* !__OPC_INSN_FORMAT_R */
|
|
|
|
#ifndef __OPC_INSN_FORMAT_I
|
|
/**
|
|
* I type: .insn i opcode6, func3, rd, rs1, simm12
|
|
*
|
|
* +--------+-----+-------+----+---------+
|
|
* | simm12 | rs1 | func3 | rd | opcode6 |
|
|
* +--------+-----+-------+----+---------+
|
|
* 31 20 15 12 7 0
|
|
*/
|
|
#define __OPC_INSN_FORMAT_I(opcode, func3, rd, rs1, simm12) \
|
|
".insn i "RT_STRINGIFY(opcode)","RT_STRINGIFY(func3)","RT_STRINGIFY(rd)","RT_STRINGIFY(rs1)","RT_STRINGIFY(simm12)"\n\t"
|
|
#endif /* !__OPC_INSN_FORMAT_I */
|
|
|
|
#ifndef OPC_CBO_INVAL
|
|
#define OPC_CBO_INVAL(base) __OPC_INSN_FORMAT_I(OPCODE_MISC_MEM, 2, x0, base, 0)
|
|
#endif
|
|
|
|
#ifndef OPC_CBO_CLEAN
|
|
#define OPC_CBO_CLEAN(base) __OPC_INSN_FORMAT_I(OPCODE_MISC_MEM, 2, x0, base, 1)
|
|
#endif
|
|
|
|
#ifndef OPC_FENCE_I
|
|
#ifdef ARCH_TOOLCHAIN_HAS_ZIFENCEI_ISA
|
|
#define OPC_FENCE_I __ASM_STR(fence.i)
|
|
#else /* !ARCH_TOOLCHAIN_HAS_ZIFENCEI_ISA */
|
|
#define OPC_FENCE_I __ASM_STR(.long 0x0000100f)
|
|
#endif /* ARCH_TOOLCHAIN_HAS_ZIFENCEI_ISA */
|
|
#endif /* !OPC_FENCE_I */
|
|
|
|
#ifndef OPC_PAUSE_I
|
|
#ifdef ARCH_TOOLCHAIN_HAS_ZIHINTPAUSE
|
|
#define OPC_PAUSE_I __ASM_STR(pause)
|
|
#else /* !ARCH_TOOLCHAIN_HAS_ZIHINTPAUSE */
|
|
#define OPC_PAUSE_I __ASM_STR(.4byte 0x0100000f)
|
|
#endif /* ARCH_TOOLCHAIN_HAS_ZIHINTPAUSE */
|
|
#endif /* !OPC_PAUSE_I */
|
|
|
|
#endif /* __OPCODE_H__ */ |