Skip to content

Commit d7bc04d

Browse files
committed
[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>
1 parent dc8aaa7 commit d7bc04d

164 files changed

Lines changed: 15112 additions & 2611 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.github/workflows/utest_auto_run.yml‎

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,12 @@ jobs:
269269
- name: Build BSP
270270
if: ${{ env.TOOLCHAIN_INSTALLED != '' && success() }}
271271
run: |
272+
# Keep regular RISC-V jobs UP; SMP coverage has its own matrix entry.
273+
if [[ "$TEST_BSP_ROOT" == "bsp/qemu-virt64-riscv" && "${{ matrix.platform.SMP_RUN }}" != "smp" ]]; then
274+
echo "# CONFIG_RT_USING_SMP is not set" >> $TEST_BSP_ROOT/.config
275+
echo "CONFIG_RT_CPUS_NR=1" >> $TEST_BSP_ROOT/.config
276+
fi
277+
272278
# Whether plan to run SMP?
273279
if [[ "${{ matrix.platform.SMP_RUN }}" == "smp" ]]; then
274280
cat $UTEST_CONFIG_ROOT/smp/smp.cfg >> $TEST_BSP_ROOT/.config
@@ -338,6 +344,39 @@ jobs:
338344
$QEMU_BIN -cpu c906fd -M $TEST_QEMU_MACHINE -kernel $TEST_BSP_ROOT/rtthread.bin -nographic \
339345
-drive if=none,file=$TEST_BSP_ROOT/sd.bin,format=raw,id=blk0 -device virtio-blk-device,drive=blk0,bus=virtio-mmio-bus.0 \
340346
> qemu_output_$TEST_QEMU_ARCH.log 2>&1 &
347+
elif [[ "$TEST_BSP_ROOT" == "bsp/qemu-virt64-riscv" ]]; then
348+
cpus=$(grep -E '^#define[[:space:]]+RT_CPUS_NR' "$TEST_BSP_ROOT/rtconfig.h" | awk '{print $3}')
349+
cpus=${cpus:-1}
350+
351+
dtb_args=()
352+
if [[ "${{ matrix.platform.KERNEL }}" == "rtsmart" ]]; then
353+
# QEMU 6.2 has no satp-mode CPU properties; RT-Smart currently uses an Sv39 VA layout.
354+
dtb="$RUNNER_TEMP/qemu-${TEST_QEMU_ARCH}-sv39.dtb"
355+
qemu-system-$TEST_QEMU_ARCH \
356+
-M "$TEST_QEMU_MACHINE,dumpdtb=$dtb" \
357+
-cpu rv64 \
358+
-smp "$cpus" \
359+
-m 256M
360+
# QEMU 6.2 recreates fw-cfg after loading an external DTB.
361+
if fdtget "$dtb" /fw-cfg@10100000 compatible >/dev/null 2>&1; then
362+
fdtput -r "$dtb" /fw-cfg@10100000
363+
fi
364+
for ((cpu = 0; cpu < cpus; cpu++)); do
365+
fdtput -t s "$dtb" "/cpus/cpu@$cpu" mmu-type riscv,sv39
366+
done
367+
dtb_args=(-dtb "$dtb")
368+
fi
369+
370+
qemu-system-$TEST_QEMU_ARCH \
371+
-nographic \
372+
-M $TEST_QEMU_MACHINE \
373+
-cpu rv64 \
374+
-smp "$cpus" \
375+
-m 256M \
376+
-kernel "$TEST_BSP_ROOT/rtthread.bin" \
377+
"${dtb_args[@]}" \
378+
-append "console=ttyS0 earlycon=sbi" \
379+
> qemu_output_$TEST_QEMU_ARCH.log 2>&1 &
341380
elif [[ "${{ matrix.platform.QEMU_ARCH }}" == "arm" ]]; then
342381
qemu-system-$TEST_QEMU_ARCH \
343382
-nographic \

0 commit comments

Comments
 (0)