From 8d8dc96b67eee53af2841a8819364d52fbec39cb Mon Sep 17 00:00:00 2001 From: GUI <39894654+GuEe-GUI@users.noreply.github.com> Date: Sat, 17 Oct 2026 09:44:26 +0800 Subject: [ARCH/RISC-V] Next RISC-V (#10320) * [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 * [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 Co-authored-by: seteiro --- components/drivers/core/mnt.c | 4 ++++ components/drivers/core/platform_ofw.c | 26 ++++++++++++++++++++++---- 2 files changed, 26 insertions(+), 4 deletions(-) (limited to 'components/drivers/core') diff --git a/components/drivers/core/mnt.c b/components/drivers/core/mnt.c index 02a68d46dd..d5c6cc5a4d 100644 --- a/components/drivers/core/mnt.c +++ b/components/drivers/core/mnt.c @@ -20,8 +20,10 @@ #ifdef RT_USING_FINSH #include #endif +#ifdef ARCH_MM_MMU #include #include +#endif #ifdef RT_USING_OFW #define bootargs_select rt_ofw_bootargs_select @@ -38,6 +40,7 @@ static int rootfs_mnt_init(void) const char *fstype = bootargs_select("rootfstype=", 0); const char *rw = bootargs_select("rw", 0); +#ifdef ARCH_MM_MMU if (!dev || !fstype) { const char *name = "initrd"; @@ -64,6 +67,7 @@ static int rootfs_mnt_init(void) } } } +#endif /* ARCH_MM_MMU */ if (fstype != cromfs_type && dev) { diff --git a/components/drivers/core/platform_ofw.c b/components/drivers/core/platform_ofw.c index 4bc2deed5d..7bcfd4ea6c 100644 --- a/components/drivers/core/platform_ofw.c +++ b/components/drivers/core/platform_ofw.c @@ -20,6 +20,7 @@ #include #include #include +#include #include "../ofw/ofw_internal.h" @@ -42,6 +43,20 @@ static const struct rt_ofw_node_id platform_ofw_ids[] = { /* sentinel */ } }; +static void ofw_address_to_string(char *buffer, rt_size_t size, rt_uint64_t address) +{ + rt_uint32_t address_hi = rt_upper_32_bits(address); + + if (address_hi) + { + rt_snprintf(buffer, size, "%x%08x", address_hi, rt_lower_32_bits(address)); + } + else + { + rt_snprintf(buffer, size, "%x", rt_lower_32_bits(address)); + } +} + static void ofw_device_rename(struct rt_device *dev) { rt_uint32_t mask; @@ -60,18 +75,21 @@ static void ofw_device_rename(struct rt_device *dev) { if (!rt_ofw_get_address(np, 0, &addr, RT_NULL)) { + char addr_str[sizeof(addr) * 2 + 1]; const char *node_name = rt_fdt_node_name(np->full_name); rt_size_t tag_len = strchrnul(node_name, '@') - node_name; + ofw_address_to_string(addr_str, sizeof(addr_str), addr); + if (!rt_ofw_prop_read_u32(np, "mask", &mask)) { - rt_dm_dev_set_name(dev, dev_name ? "%lx.%x.%.*s:%s" : "%lx.%x.%.*s", - addr, __rt_ffs(mask) - 1, tag_len, node_name, dev_name); + rt_dm_dev_set_name(dev, dev_name ? "%s.%x.%.*s:%s" : "%s.%x.%.*s", + addr_str, __rt_ffs(mask) - 1, tag_len, node_name, dev_name); } else { - rt_dm_dev_set_name(dev, dev_name ? "%lx.%.*s:%s" : "%lx.%.*s", - addr, tag_len, node_name, dev_name); + rt_dm_dev_set_name(dev, dev_name ? "%s.%.*s:%s" : "%s.%.*s", + addr_str, tag_len, node_name, dev_name); } return; -- cgit v1.3.1