Skip to content

Commit 9f0b0b6

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 991f0ff commit 9f0b0b6

171 files changed

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

0 commit comments

Comments
 (0)