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>
48 lines
1.2 KiB
C
48 lines
1.2 KiB
C
/*
|
|
* Copyright (c) 2006-2025, RT-Thread Development Team
|
|
*
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
*
|
|
* Change Logs:
|
|
* Date Author Notes
|
|
* 2025-04-20 GuEe-GUI The first version
|
|
*/
|
|
|
|
#ifndef __CPU_H__
|
|
#define __CPU_H__
|
|
|
|
#include <rtdef.h>
|
|
|
|
#ifndef RT_CPUS_NR
|
|
#define RT_CPUS_NR 1
|
|
#endif
|
|
|
|
#if defined(RT_USING_DM) && defined(RT_USING_SMP)
|
|
struct cpu_ops_t
|
|
{
|
|
const char *method;
|
|
int (*cpu_init)(rt_uint32_t id, void *param);
|
|
int (*cpu_boot)(rt_uint32_t id, rt_uint64_t entry);
|
|
void (*cpu_shutdown)(void);
|
|
};
|
|
#endif
|
|
|
|
extern rt_ubase_t boot_cpu_hartid;
|
|
extern void _secondary_cpu_entry(void);
|
|
|
|
#if defined(RT_USING_SMP) && defined(ARCH_MM_MMU)
|
|
extern char __percpu_real_end, __percpu_end, __percpu_start;
|
|
#endif /* RT_USING_SMP && ARCH_MM_MMU */
|
|
|
|
rt_ubase_t riscv_cpu_id_to_hartid(int cpu_id);
|
|
rt_bool_t riscv_cpu_id_available(int cpu_id);
|
|
int riscv_hartid_to_cpu_id(rt_ubase_t hartid);
|
|
int riscv_hartid_register(rt_ubase_t hartid);
|
|
void riscv_cpu_id_set(int cpu_id);
|
|
#if defined(RT_USING_SMP) && !defined(RT_USING_DM)
|
|
rt_size_t riscv_hartid_list_get(rt_ubase_t *hartids, rt_size_t max_harts);
|
|
#endif
|
|
void riscv_boot_hart_init(rt_ubase_t hartid);
|
|
|
|
#endif /* __CPU_H__ */
|