refactor(boot): 收敛 RISC-V 和 LoongArch 主核启动流程#252
Merged
Conversation
Move common RISC-V and LoongArch primary boot steps into kernel boot code. Keep architecture boot modules focused on arch-specific hooks.
Route kernel task trap frame initialization through arch helpers. Remove direct TrapFrame construction from common task setup.
Program the LoongArch timer with the correct CSRs and restore kernel task entries directly during first schedule.
Contributor
There was a problem hiding this comment.
Code Review
This pull request unifies the primary boot sequence across architectures by introducing a generic run_primary_boot function and a PrimaryBootOps structure. It also standardizes kernel task initialization through the new init_kernel_trap_frame function and adds an interrupts_enabled method to the CpuOps trait. Review feedback identified critical copy-paste errors in the LoongArch implementation where RISC-V specific constants (SSTATUS_SIE) were used instead of the correct LoongArch CSR bits (CSR_CRMD_IE) for interrupt status checks.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
变更内容
本 PR 处理 #249,主要收敛 RISC-V 和 LoongArch 中重复的主核启动流程。
kernel::boot中新增PrimaryBootOps和run_primary_boot(),统一主核启动顺序arch::interrupts_enabled(),移除kernel/boot.rs对arch::intr的直接依赖arch::kernel::task::init_kernel_trap_frame(),避免 common boot/task 代码直接构造TrapFrame验证情况
cargo fmt --checkcargo checkcargo check --target loongarch64-unknown-nonecargo buildcargo build --target loongarch64-unknown-nonekernel/boot.rs中已无直接TrapFrame/arch::intr引用/sbin/init路径Closes #249