feat(somehal): register x86 ACPI IOAPIC through rdrive#1155
Merged
Conversation
ZR233
marked this pull request as ready for review
June 5, 2026 09:46
This was referenced Jun 5, 2026
Merged
Contributor
There was a problem hiding this comment.
代码审查总结
PR 内容: 将 x86 ACPI IOAPIC 从 somehal 中的手动 post_paging() 初始化路径迁移到 rdrive 动态驱动注册模型,与 aarch64 GIC 的 rdrive 注册模式对齐。
实现逻辑:
- 在
rdif-def/src/irq.rs中新增中立的AcpiGsiRoute、AcpiIrqTrigger、AcpiIrqPolarity类型,将 ACPI 中断路由元数据从rdrive的内部定义提升到接口定义层。 - 在
rdif-intc的Interfacetrait 中新增setup_irq_by_acpi()方法,遵循setup_irq_by_fdt()已有模式。 rdriveACPI probe 复用新的 route 类型,AcpiPciIrqRoute简化为持有AcpiGsiRoute而非内联展开的字段。somehalx86 平台用module_driver!宏注册 "ACPI IOAPIC" 为 rdrive driver,实现rdif_intc::Interface,包含路由缓存和resolve_vector回退机制。- 移除
post_paging()中的init_acpi_irq()旁路调用。 ax-driver的 ACPI PCI helper 改为通过setup_irq_by_acpi()获取 IRQ,cfg 条件简化为pci_dyn_intx_route/pci_dyn_acpi_intx_route语义 cfg。
本地验证结果:
cargo fmt --check: ✅ 通过cargo clippy(rdif-def, rdif-intc, rdrive, somehal): ✅ 通过cargo clippy(ax-driver): ❌fdt.rs:247有 pre-existing 的useless_borrows_in_formatting警告,非本 PR 引入cargo test(rdrive, 含acpi_ioapic_routes_map_gsi_to_stable_vector): ✅ 通过 (4 tests passed)cargo test(rdif-intc, rdif-def): ✅ 通过
CI 状态: 所有 GitHub Actions check runs 结论为 skipped,属于矩阵/路径过滤正常行为,无 PR 引致的 CI 失败。PR 已于 2026-06-05 合并。
重复/重叠分析: 搜索 open PR 中的 IOAPIC/intc/ACPI GSI 关键词,未发现冲突或重复的开放 PR。仅发现 release PR (#1156) 已包含本 PR 变更。PR #1155 与 aarch64 GIC 的 rdrive 注册路径形成架构一致性,无重复实现风险。
代码质量评估:
- 架构方向正确:将 IOAPIC 初始化从静态旁路迁移到 rdrive probe 机制,与 aarch64 GIC 对齐
X86IoApicIntc中的路由缓存 +resolve_vector回退机制设计合理set_ioapic_vector_enable使用rdrive::get_list::<Intc>()+downcast+try_lock避免死锁unsafe块仅用于硬件寄存器操作,符合预期- cfg 条件大幅简化,用
build.rs生成的语义 flag 替代重复的 feature 列表 - 测试覆盖包括 route 映射和 intx flags 断言
结论: 无阻塞性问题,代码架构合理,本地验证通过。APPROVE。
Powered by mimo-v2.5-pro
Merged
aptacc2421
pushed a commit
to aptacc2421/tgoskits
that referenced
this pull request
Jun 14, 2026
luodeb
pushed a commit
that referenced
this pull request
Jun 30, 2026
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.
背景
当前 x86 动态平台的 IOAPIC 初始化仍由
somehal在post_paging()后手动调用,PCI ACPI_PRT路由在进入设备侧时也只保留了 vector,trigger/polarity 等 ACPI 元数据会提前丢失。这使 x86 中断控制器路径和 aarch64 GIC 的 rdrive 动态注册模型不一致,也不利于后续扩展 ACPI PCI legacy INTx 配置。修改内容
rdif-def/rdif-intc中新增中立的 ACPI GSI route 类型和setup_irq_by_acpi()接口,避免让rdif-intc依赖rdrive的具体 ACPI 实现。rdriveACPI probe 中复用该 route 类型,让 PCI_PRT解析返回完整的 GSI、vector、IOAPIC controller/input、trigger/polarity 信息。somehalx86 平台中把 ACPI IOAPIC 注册为rdif_intc::Intcrdrive driver,由probe_pre_kernel()初始化,并通过setup_irq_by_acpi()写入 IOAPIC redirection entry。post_paging()中手动init_acpi_irq()的旁路初始化,保留 LAPIC/PIC/timer/IPI/MSI/MSI-X 的既有路径。ax-driverACPI PCI helper 中把完整 route 交给 interrupt controller setup,再返回最终 IRQ/vector;同时用语义 cfg 简化 PCI ACPI/FDT INTx helper 的编译条件。方案逻辑
第一版只覆盖 ACPI IOAPIC + PCI legacy INTx:PCI 设备仍然只拿
usize IrqId注册中断,驱动侧不需要理解 IOAPIC;IOAPIC 细节集中在 x86somehal的 rdrive intc 实现中。setup_irq_by_acpi()会先缓存完整 route,再配置并屏蔽对应 IOAPIC entry,后续irq_set_enable(vector)使用缓存 route 启停,避免重新从 vector 反推默认 route 时丢失 trigger/polarity。验证
cargo fmt --checkcargo test --package rdrive acpi_ioapic_routes_map_gsi_to_stable_vectorcargo xtask clippy --package rdif-intccargo xtask clippy --package rdrivecargo xtask clippy --package somehalcargo xtask clippy --package ax-drivercargo xtask starry test qemu --arch x86_64 -g normal -c test-sysinfogit diff --check