refactor(drivers): split shared driver stack from ArceOS#831
Conversation
- Implemented the RK3588 PCIe host driver in `resources.rs`, handling GPIO resets, memory mapping, and configuration. - Created slot drivers for multiple PCIe slots in `slots.rs`, enabling dynamic probing of PCIe devices. - Added memory window programming logic in `windows.rs`, including configuration window detection and logging of resources. - Introduced a new `PlatformVsockDevice` in `vsock.rs` for managing Virtio socket devices, with registration and device handling. - Updated `virtio.rs` to use the new Virtio driver interface. - Modified the Clippy crates list to include new dependencies for the added components. - Adjusted build configuration to remove unnecessary Virtio net feature for the AArch64 platform.
- Updated Cargo.lock and Cargo.toml to include dma-api and mmio-api dependencies. - Implemented DMA operations in axklib with a new dma.rs file, providing functionality for allocating and managing DMA pages. - Created mmio.rs to handle memory-mapped I/O operations, including ioremap and iounmap functionalities. - Refactored axruntime and various platform drivers to utilize the new DMA and MMIO abstractions, replacing previous implementations. - Removed obsolete DmaImpl struct and related code from drivers, streamlining the DMA handling process. - Ensured compatibility with existing driver interfaces by adapting to the new DMA and MMIO APIs.
- Consolidated static device initialization logic into `devices.rs`. - Introduced `StaticBlockDevice` to handle block device operations. - Removed old static device modules (`block.rs`, `dma.rs`, `virtio.rs`, `virtio_block.rs`) and their associated functionality. - Updated `Cargo.toml` files to remove unused driver dependencies. - Adjusted build configurations to reflect the removal of static device drivers. - Enhanced error handling and device probing for static devices.
- Removed the `virtio/input.rs`, `virtio/vsock.rs`, and `vsock.rs` files as they are no longer needed. - Updated `Cargo.toml` files to change dependencies from `ax-driver` to `ax-drivers` for better modularization. - Refactored device initialization in `devices.rs` to utilize the new `ax-drivers` bindings for display, input, net, and vsock devices. - Simplified PCI driver implementations by using the new `ax-drivers` functions for transport and IRQ registration. - Cleaned up the `virtio` and `pci` driver implementations to align with the new structure and removed legacy code. - Updated the `clippy_crates.csv` to include `ax-driver` and `ax-drivers` for linting checks.
- Removed static driver registration and initialization functions from `init.rs`, `registers.rs`, and `source.rs`. - Updated `ramdisk.rs`, `sdmmc.rs`, `fxmac.rs`, and other driver files to use a simplified registration approach. - Introduced `register_mmio` and `register_ecam_controller` functions for dynamic device registration. - Enhanced the `probe_pci` functions across various drivers to focus solely on PCI device registration. - Removed unnecessary static device descriptors and streamlined the initialization process for static devices. - Updated Cargo.toml files to reflect changes in dependencies and features, including the addition of `sdmmc` and `cvsd`. - Added new driver registration logic in the `riscv64-visionfive2` platform to support SD/MMC devices.
- Deleted the `virtio.rs`, `virtio_pci.rs`, `display.rs`, `input.rs`, `serial/mod.rs`, `net/mod.rs`, `usb/mod.rs`, `vsock.rs`, and `pci.rs` files to streamline the driver architecture. - Moved relevant functionality to `ax_drivers` for better modularity and maintainability. - Updated `mod.rs` to reflect the removal of unused modules and adjusted the driver registration process. - Enhanced the `generic_timer.rs` by making `try_init_epoch_offset` public for broader access. - Cleaned up the `lib.rs` to expose necessary components while removing deprecated references.
- Removed the `bindings` module and integrated its contents directly into the respective driver modules (block, display, input, net, vsock). - Created new binding files for block, display, input, net, and vsock drivers to encapsulate their platform-specific device structures and functionalities. - Updated references throughout the codebase to reflect the new module structure, ensuring that all driver implementations correctly utilize the new bindings. - Improved organization and clarity of the driver code by separating concerns and enhancing modularity.
- Updated linker scripts to define driver registration sections for various architectures (x86, RISC-V, Loongarch). - Refactored driver initialization in axplat crates to conditionally include PCI and Virtio drivers based on feature flags. - Introduced new driver modules for RISC-V and x86 platforms to handle Virtio block devices. - Enhanced Cargo.toml files to include necessary dependencies for PCI and Virtio drivers. - Modified initialization routines to ensure proper setup of drivers during platform initialization. - Updated configuration files for QEMU boards to enable PCI and Virtio features.
- Removed the `registers.rs` files from various platforms, consolidating the register handling into a new `registers.rs` in the `axruntime` module. - Updated the `init.rs` files across platforms to eliminate direct driver initialization calls, instead relying on a unified `probe_all_devices` function. - Introduced static device registration for various drivers (SD/MMC, PCIe ECAM, VirtIO) using the new static device registration mechanism. - Enhanced the `StaticDeviceDesc` structure to support additional properties like `regs` and `pci_ecam`. - Updated the build scripts to include new static features for drivers. - Adjusted the `DriversIf` trait implementation to provide static device descriptions for platforms.
- Updated feature lists in multiple TOML files for aarch64, loongarch64, riscv64gc, and x86_64 architectures to include new hardware abstraction layer (HAL) and driver features. - Added support for PCI, VirtIO block, VirtIO net, and other drivers to improve hardware compatibility and performance. - Adjusted features in the axvisor and starryos test suites to ensure consistency and leverage new capabilities. - Ensured that all configurations now utilize the latest HAL and driver features for enhanced functionality and stability.
…x-driver" - Updated multiple TOML configuration files across various test suites to change the feature prefix from "ax-drivers" to "ax-driver" for consistency and clarity. - This change affects configurations for platforms including x86_64, aarch64, loongarch64, and riscv64 in both normal and stress test scenarios. - Ensured that all relevant files reflect this naming convention to maintain uniformity across the codebase.
- Added virtio-net-pci and netdev configurations to QEMU arguments for aarch64, loongarch64, riscv64, and x86_64 test cases to enable networking capabilities. - Removed unnecessary PCI and virtio driver features from build configurations for aarch64, loongarch64, riscv64, and x86_64. - Updated hello world, HTTP client, IO test, thread test, and Tokio test configurations to include virtio-blk-pci for disk access. - Adjusted Cargo.toml files to streamline dependencies by removing unused features related to multitasking and IRQ handling.
- Replaced instances of `ax-driver-base`, `axdriver_*` with new naming conventions: `rdrive`, `rd-*`, and `rdif-*` across various documentation files. - Updated dependency references in `ax-hal`, `ax-input`, `ax-net-ng`, `ax-posix-api`, `ax-runtime`, and `axplat-dyn` to reflect the new driver structure. - Removed references to deprecated driver crates in `layers.md`, `overview.md`, and `components.md`. - Adjusted the driver subsystem section in the documentation to align with the new driver architecture. - Modified the repository management script to remove specific handling for `axdriver_crates` due to structural changes.
… macro for driver registration
… configuration logic
There was a problem hiding this comment.
审查意见:refactor(drivers): split shared driver stack from ArceOS
总体评价
本次 PR 将公共驱动能力从 ArceOS 拆出到 drivers/ax-driver(v0.6.0),引入 rdif-display、rdif-input、rdif-vsock 新 RDIF 接口,新增 rd-block-volume 分区扫描库,并完整清理了废弃的 components/axdriver_crates 包组及旧 os/arceos/modules/axdriver。Driver Core / Capability Boundary / OS Glue 三层方向正确,代码质量整体良好。
与前轮审查意见的关系
前轮审查提出的所有阻塞点和代码建议在当前 head 884afd12c 中均已解决:
- ✅ 合并冲突:
git merge-tree确认无冲突,mergeable: true。 - ✅ DMA
alloc_for_layout文档注释:已添加 doc comment,明确说明dma_alloc_pages应保证 DMA mask 和对齐约束,下方检查为防御性验证。 - ✅
SyncBlockOps::flush()移除:已从 trait 中移除。 - ✅
SyncBlockQueue::poll_request优化:现在直接返回Ok(()),与 VirtIO block 的实现保持一致。
本地验证结果(head 884afd12c)
cargo fmt --all -- --check: ✅ 通过cargo clippy -p rd-block-volume -p rdif-display -p rdif-input -p rdif-vsock --all-features -- -D warnings: ✅ 通过cargo test -p rd-block-volume: ✅ 5 个测试通过(GPT/MBR 分区扫描)cargo test -p rdif-input: ✅ 1 个测试通过cargo test -p rdif-vsock: ✅ 2 个测试通过cargo test -p rdif-display: ✅ 1 个测试通过git merge-tree: ✅ 无冲突- 旧包
components/axdriver_crates及os/arceos/modules/axdriver: ✅ 已从 workspace 完整移除
代码审查要点
-
Feature flag 体系完整:
ax-driver/Cargo.toml的 feature 设计覆盖块设备、网络、显示、输入、vsock、VirtIO、USB、PCI、SoC 等所有驱动类别,依赖方向清晰,每个类别有独立的 feature gate。 -
build.rscfg 设计精巧:通过probecfg(static/fdt/pci)和sync_block_dev等自定义 cfg 实现条件编译,配合rustc-check-cfg声明,编译器诊断友好。sync_block_dev仅在 ahci/bcm2835-sdhci/sdmmc 或 cvsd on riscv 时启用,覆盖准确。 -
VirtIO 驱动适配层干净:
VirtIoHalImpl正确委托给axklib的virt_to_phys/ioremap_raw。virtio/block.rs的buff_config设置VIRTIO_BLK_DMA_BUFFER_SIZE = 32 * SECTOR_SIZE,解决了性能回归问题。poll_request返回Ok(())与同步设备语义一致。 -
rd-block-volume分区扫描:GPT/MBR 扫描逻辑干净,5 个单元测试覆盖完整,无外部依赖(仅alloc),适合作为no_std基础库。 -
QEMU 配置修复正确:aarch64 std QEMU 内存 128M→512M 修复 DataAbort,根因分析清晰。StarryOS timeout 放宽(
util-linux、test-mmap-prot-write)合理。 -
axplat-dyn依赖简化:原先直接依赖大量驱动 crate,现在统一委托给ax-driver,依赖图更清晰。 -
配置迁移一致:所有 build config 中的 feature 引用已从
axplat-dyn/*、ax-feat/*统一迁移到ax-driver/*,与新的 crate 结构匹配。
重复/重叠分析
- base 分支:dev 上不存在等效的统一驱动栈重构,旧
components/axdriver_crates包组已被本 PR 替换。 - 相关 open PR:
- 结论:本 PR 独特,无重复。
遗留观察(非阻塞)
- VirtIoHalImpl
share缺少 cache flush:与旧代码行为一致,KlibDmaDMA 框架已就绪,后续可在非 cache-coherent 平台上统一管理 streaming DMA 的 cache 一致性。 - 远端 CI 全部 skipped:fork PR 上 CI 未触发,这是 fork PR 的已知行为,需要维护者在 GitHub Actions 中 approve workflow 运行。
mergeable: true表明合入无技术障碍。
结论
代码拆分正确、本地 fmt/clippy/test 全部通过、新接口设计干净、文档完善、前轮建议全部采纳、无合并冲突。建议合入。
Powered by glm-5.1
# Conflicts: # Cargo.lock # Cargo.toml # components/axdriver_crates/axdriver_net/Cargo.toml # components/axdriver_crates/axdriver_net/src/net_buf.rs # drivers/ax-driver/src/block/binding.rs # drivers/ax-driver/src/soc/scmi.rs # drivers/rdrive/src/lib.rs # os/StarryOS/kernel/Cargo.toml # os/StarryOS/kernel/src/pseudofs/dev/loop.rs # os/StarryOS/kernel/src/pseudofs/dev/tty/mod.rs # os/StarryOS/kernel/src/pseudofs/dev/tty/terminal/job.rs # os/arceos/api/arceos_api/Cargo.toml # os/arceos/api/axfeat/Cargo.toml # os/arceos/modules/axdriver/Cargo.toml # os/arceos/modules/axfs-ng/Cargo.toml # os/arceos/modules/axfs-ng/src/fs/ext4/lwext4/fs.rs # os/arceos/modules/axfs-ng/src/fs/ext4/rsext4/fs.rs # os/arceos/modules/axfs-ng/src/fs/fat/fs.rs # os/arceos/modules/axfs/src/dev.rs # platform/axplat-dyn/src/drivers/blk/virtio_pci.rs # platform/axplat-dyn/src/drivers/mod.rs # platform/axplat-dyn/src/drivers/net/virtio_pci.rs # platform/axplat-dyn/src/drivers/pci.rs
…tex for submitted URBs
There was a problem hiding this comment.
审查意见:refactor(drivers): split shared driver stack from ArceOS
总体评价
本次 PR 将公共驱动能力从 ArceOS 单一 OS 模块拆出到 drivers/ax-driver(v0.6.0),引入 rdif-display、rdif-input、rdif-vsock、rd-block-volume 等新接口和库,并完整清理了废弃的 components/axdriver_crates 包组(8 个子 crate)。Driver Core / Capability Boundary / OS Glue 三层分层方向正确,代码质量整体良好。
与历史审查意见的关系
前五轮审查(mai-team-app)的核心阻塞点是合并冲突和远端 CI。当前 head d046c8cb5 的 merge-base 与 dev HEAD(7793fb648)完全一致,合并冲突已解决。
前轮代码层面建议的评估(延续上轮结论):
- DMA
alloc_for_layout后验逻辑:dma_alloc_pages接受dma_mask参数,在约束内尝试分配;后验检查是安全兜底,不构成阻塞。 - VirtIoHalImpl
share缺少 cache flush:与旧代码行为一致,KlibDmaDMA 框架已就绪,后续可统一管理。不构成阻塞。 - SyncBlockQueue
poll_request调用 flush():默认flush()返回Ok(()),性能影响微小。VirtIO block 的poll_request已直接返回Ok(()),建议 SyncBlockQueue 保持一致。不构成阻塞。
本地验证结果
cargo fmt --check:✅ 通过cargo clippy -p ax-driver --all-features -- -D warnings:✅ 通过cargo test -p rd-block-volume --all-features:✅ 5 个测试通过(GPT/MBR 分区扫描)cargo test -p rdif-display:✅ 1 个测试通过cargo test -p rdif-input:✅ 1 个测试通过cargo test -p rdif-vsock:✅ 2 个测试通过
代码审查重点
-
drivers/ax-driver架构设计:新的ax-drivercrate 通过rdriveprobe 机制统一管理设备注册,平台侧通过DriversIf::static_devices_fn()声明静态设备描述,不再直接依赖具体驱动 crate。axplat-dyn的drivers.rs精简为rdrive::probe_all(false)一行调用,依赖从直接依赖大量驱动 crate 统一为ax-driver。架构清晰。 -
Feature flag 体系:
ax-driver/Cargo.toml的 feature 设计覆盖了块设备(ramdisk/ahci/cvsd/bcm2835-sdhci/rockchip-sdhci/rockchip-dwmmc/phytium-mci)、网络(ixgbe/fxmac/intel-net/realtek-rtl8125)、VirtIO(blk/net/gpu/input/socket)、USB(dwc-xhci/xhci-mmio/xhci-pci)、PCI(rk3588-pcie)、SoC(rockchip/rockchip-pm)、串口/RTC/NPU 等所有驱动类别。依赖方向清晰,每个驱动类别有独立 feature gate。 -
build.rs cfg 设计:通过
probecfg(static/fdt/pci)和sync_block_dev等自定义 cfg 实现条件编译,配合rustc-check-cfg声明,编译器诊断友好。build.rs中 feature→cfg 映射逻辑正确。 -
VirtIO 块设备性能修复:
virtio/block.rs的buff_config设置VIRTIO_BLK_DMA_BUFFER_SIZE = 32 * SECTOR_SIZE,配合rd-block的max_blocks_per_request()和block_ranges()按 buffer 大小拆分连续请求,解决了新驱动栈下util-linux变慢的性能回归。PR 正文报告的加速数据(64-80s → 18.86s,约 3.4x-4.3x)来自合理的批量 I/O 语义修复。 -
新 RDIF 接口:
rdif-display、rdif-input、rdif-vsock三个新接口 trait 设计干净,默认实现合理,与现有rdif-*系列风格一致。 -
rd-block-volume分区扫描:GPT/MBR 扫描逻辑干净,5 个单元测试覆盖完整(GPT 单分区、MBR 主分区、MBR 逻辑分区、GPT 数组边界、全盘回退),无外部依赖(仅alloc),适合作为no_std基础库。 -
驱动 crate 解耦:
arm-scmi-rs、nvme-driver、ramdisk、rdif-serial、realtek-rtl8125、crab-usb等从ax-kspin迁移到spin,提升了驱动 crate 的跨内核可移植性。 -
QEMU 配置修复:aarch64 std QEMU 内存 128M→512M 修复 DataAbort 问题,根因分析(平台声明 512M 但 QEMU 只给 128M)清晰。
重复与重叠分析
-
dev 基线检查:dev 分支上
components/axdriver_crates目录仍然存在(PR #861 只迁移了 spin 用法但未移除旧 crate),PR #831 是第一个完整清理该目录的 PR。dev 上没有等效的驱动拆分实现,PR #831 是唯一的。 -
相关开放 PR 检查:
- PR #859(AxVisor board tests)也涉及
rockchip-sdhci/rockchip-dwmmc/phytium-mci的 feature 拆分,但 PR #859 是 AxVisor 板级测试增强,其 driver feature 命名与本 PR 一致。PR #859 为 draft 状态,应在本 PR 合入后 rebase,不构成冲突。 - PR #704(UART support for RK3588)为 draft,与本 PR 的驱动框架无关。
- 结论:无重复、无冲突、无被取代风险。PR #831 是基础性重构,其他 driver 相关 PR 宜在本 PR 后合入。
- PR #859(AxVisor board tests)也涉及
⚠️ 阻塞项
远端 CI 全部 skipped:当前 head d046c8cb5 上所有 GitHub Actions check run 均为 skipped(共 15+ 个 job,包括 clippy、test starry、test arceos、test axvisor、test with std 等)。mergeable_state: unknown 意味着无法确认分支保护规则是否满足。
这是第六轮审查仍持续存在的问题。虽然本地 fmt/clippy/unit test 全部通过,但涉及 532 个文件、14k+ 行新增的驱动重构,无法仅靠本地验证覆盖所有平台(aarch64/riscv64/loongarch64/x86_64 的 ArceOS/StarryOS/AxVisor QEMU 和板级测试)。
请作者确认:
- GitHub Actions 工作流是否在 fork PR 上正确触发(可能需要 repo maintainer 手动 approve fork 运行,或配置
pull_request_target事件) - 远端 CI 全部通过后方可合入
结论
代码拆分正确、架构分层清晰、本地 fmt/clippy/test 全部通过、合并冲突已解决、无重复/冲突 PR。远端 CI 全部 skipped 是唯一阻塞项。请确认 CI 正常运行后可合入。
Powered by deepseek-v4-pro
…feature propagation
# Conflicts: # scripts/axbuild/src/axvisor/build.rs # scripts/axbuild/src/build.rs
There was a problem hiding this comment.
审查意见:refactor(drivers): split shared driver stack from ArceOS
总体评价
本次 PR 将公共驱动能力从 ArceOS 单一 OS 模块拆出到 drivers/ax-driver(v0.6.0),引入 rdif-display、rdif-input、rdif-vsock 新 RDIF 接口,新增 rd-block-volume 分区扫描库,并完整清理了废弃的 components/axdriver_crates 包组及旧 os/arceos/modules/axdriver。Driver Core / Capability Boundary / OS Glue 三层方向正确,代码质量整体良好。
与前九轮审查意见的关系
前九轮审查提出的所有阻塞点和代码建议在最新提交中均已解决:
- ✅ 合并冲突:当前 head
8f77a431已合并最新 dev,无冲突。 - ✅ DMA
alloc_for_layout文档注释:已添加 doc comment,明确说明dma_alloc_pages应保证 DMA mask 和对齐约束。 - ✅
SyncBlockOps::flush()移除:已从 trait 中移除。 - ✅
SyncBlockQueue::poll_request优化:现在直接返回Ok(()),与 VirtIO block 的poll_request实现一致。 - ✅ 旧包
components/axdriver_crates:已从 workspace 完整移除。 - ✅
rdif-ethDmaBuffer 结构体:将submit()接口从(bus_addr, len)升级为DmaBuffer结构体,保留virt、bus_addr、len三个字段,向后兼容且设计合理。
本地验证结果(head 8f77a431)
cargo fmt --all -- --check: ✅ 通过cargo clippy -p rd-block-volume -p rdif-display -p rdif-input -p rdif-vsock --all-features -- -D warnings: ✅ 通过,零 warningcargo test -p rd-block-volume: ✅ 5 个测试通过(GPT/MBR 分区扫描)cargo test -p rdif-input: ✅ 1 个测试通过cargo test -p rdif-vsock: ✅ 2 个测试通过cargo test -p rdif-display: ✅ 1 个测试通过
代码审查要点
-
Feature flag 体系完整:
ax-driver/Cargo.toml的 feature 设计覆盖块设备、网络、显示、输入、vsock、VirtIO、USB、PCI、SoC 等所有驱动类别,依赖方向清晰。 -
build.rscfg 设计精巧:通过probecfg(static/fdt/pci)和sync_block_dev自定义 cfg 实现条件编译,配合rustc-check-cfg声明,编译器诊断友好。 -
VirtIO 驱动适配层干净:
VirtIoHalImpl正确委托给axklib的virt_to_phys/ioremap_raw,拆分后注册逻辑清晰(register_static_transport按DeviceType路由到对应子模块)。 -
rd-block-volume分区扫描:GPT/MBR 扫描逻辑干净,5 个单元测试覆盖完整,无外部依赖(仅alloc),适合作为no_std基础库。 -
QEMU 配置修复正确:aarch64 std QEMU 内存 128M→512M 修复 DataAbort,根因分析清晰。StarryOS timeout 放宽(
util-linux60→120,test-mmap-prot-write30→60)合理。 -
apk-curl重试机制:新增 3 次重试 +sleep 2的 shell 脚本逻辑,应对网络波动导致的偶发失败,设计合理。 -
rdif-ethDmaBuffer引入:将原先(bus_addr, len)的接口扩展为包含virt指针的DmaBuffer结构,使驱动能直接访问 CPU 虚拟地址构建描述符,设计正确且已同步更新e1000/ixgbe等消费方。
重复/重叠分析
- base 分支:dev 上不存在等效的统一驱动栈重构,旧
components/axdriver_crates包组已被本 PR 完整替换。 - 相关 open PR:PR #839(axbuild 重构)、PR #847(kprobe 内核探针)、PR #849(LKM 支持)均与驱动栈拆分互补,无重叠。
- 结论:本 PR 独特,无重复。
远端 CI 状态
当前 head 8f77a431 上 CI 已运行:
Check formatting / run_host: ✅ successDetect changed paths: ✅ successRun sync-lint / run_container: ⏳ queued(容器环境中排队)- 其他 job(Publish 镜像、容器格式检查等):均为 skipped
fork PR 上 CI 部分 skipped 是已知行为。格式检查和路径检测已通过,表明代码质量良好。
遗留观察(非阻塞)
- VirtIoHalImpl
share缺少 cache flush:与旧代码行为一致,KlibDmaDMA 框架已就绪,后续可在非 cache-coherent 平台上统一管理 streaming DMA 的 cache 一致性。 - StarryOS build config feature 迁移:大量
qemu-*.toml从ax-feat/bus-mmio/ax-feat/bus-pci迁移到ax-hal/<plat>+ax-driver/<driver>明确 feature,迁移完整且一致。
结论
代码拆分正确、本地 fmt/clippy/test 全部通过、新接口设计干净、文档完善、前九轮建议全部采纳。建议合入。
Powered by deepseek-v4-pro
* feat(docs): 添加 rdrive + rdif 驱动框架文档,记录宿主物理设备重构目标 * Add RK3588 PCIe driver support and related components - Implemented the RK3588 PCIe host driver in `resources.rs`, handling GPIO resets, memory mapping, and configuration. - Created slot drivers for multiple PCIe slots in `slots.rs`, enabling dynamic probing of PCIe devices. - Added memory window programming logic in `windows.rs`, including configuration window detection and logging of resources. - Introduced a new `PlatformVsockDevice` in `vsock.rs` for managing Virtio socket devices, with registration and device handling. - Updated `virtio.rs` to use the new Virtio driver interface. - Modified the Clippy crates list to include new dependencies for the added components. - Adjusted build configuration to remove unnecessary Virtio net feature for the AArch64 platform. * Add DMA and MMIO support to axklib - Updated Cargo.lock and Cargo.toml to include dma-api and mmio-api dependencies. - Implemented DMA operations in axklib with a new dma.rs file, providing functionality for allocating and managing DMA pages. - Created mmio.rs to handle memory-mapped I/O operations, including ioremap and iounmap functionalities. - Refactored axruntime and various platform drivers to utilize the new DMA and MMIO abstractions, replacing previous implementations. - Removed obsolete DmaImpl struct and related code from drivers, streamlining the DMA handling process. - Ensured compatibility with existing driver interfaces by adapting to the new DMA and MMIO APIs. * Refactor static device management and remove deprecated components - Consolidated static device initialization logic into `devices.rs`. - Introduced `StaticBlockDevice` to handle block device operations. - Removed old static device modules (`block.rs`, `dma.rs`, `virtio.rs`, `virtio_block.rs`) and their associated functionality. - Updated `Cargo.toml` files to remove unused driver dependencies. - Adjusted build configurations to reflect the removal of static device drivers. - Enhanced error handling and device probing for static devices. * Refactor axdriver module structure and update dependencies - Removed the `virtio/input.rs`, `virtio/vsock.rs`, and `vsock.rs` files as they are no longer needed. - Updated `Cargo.toml` files to change dependencies from `ax-driver` to `ax-drivers` for better modularization. - Refactored device initialization in `devices.rs` to utilize the new `ax-drivers` bindings for display, input, net, and vsock devices. - Simplified PCI driver implementations by using the new `ax-drivers` functions for transport and IRQ registration. - Cleaned up the `virtio` and `pci` driver implementations to align with the new structure and removed legacy code. - Updated the `clippy_crates.csv` to include `ax-driver` and `ax-drivers` for linting checks. * Refactor and streamline driver registration and initialization - Removed static driver registration and initialization functions from `init.rs`, `registers.rs`, and `source.rs`. - Updated `ramdisk.rs`, `sdmmc.rs`, `fxmac.rs`, and other driver files to use a simplified registration approach. - Introduced `register_mmio` and `register_ecam_controller` functions for dynamic device registration. - Enhanced the `probe_pci` functions across various drivers to focus solely on PCI device registration. - Removed unnecessary static device descriptors and streamlined the initialization process for static devices. - Updated Cargo.toml files to reflect changes in dependencies and features, including the addition of `sdmmc` and `cvsd`. - Added new driver registration logic in the `riscv64-visionfive2` platform to support SD/MMC devices. * Refactor: Remove obsolete drivers and consolidate functionality - Deleted the `virtio.rs`, `virtio_pci.rs`, `display.rs`, `input.rs`, `serial/mod.rs`, `net/mod.rs`, `usb/mod.rs`, `vsock.rs`, and `pci.rs` files to streamline the driver architecture. - Moved relevant functionality to `ax_drivers` for better modularity and maintainability. - Updated `mod.rs` to reflect the removal of unused modules and adjusted the driver registration process. - Enhanced the `generic_timer.rs` by making `try_init_epoch_offset` public for broader access. - Cleaned up the `lib.rs` to expose necessary components while removing deprecated references. * Refactor: Update dependencies and remove obsolete driver modules * Refactor driver bindings and module structure - Removed the `bindings` module and integrated its contents directly into the respective driver modules (block, display, input, net, vsock). - Created new binding files for block, display, input, net, and vsock drivers to encapsulate their platform-specific device structures and functionalities. - Updated references throughout the codebase to reflect the new module structure, ensuring that all driver implementations correctly utilize the new bindings. - Improved organization and clarity of the driver code by separating concerns and enhancing modularity. * Add PCI and Virtio support across multiple platforms - Updated linker scripts to define driver registration sections for various architectures (x86, RISC-V, Loongarch). - Refactored driver initialization in axplat crates to conditionally include PCI and Virtio drivers based on feature flags. - Introduced new driver modules for RISC-V and x86 platforms to handle Virtio block devices. - Enhanced Cargo.toml files to include necessary dependencies for PCI and Virtio drivers. - Modified initialization routines to ensure proper setup of drivers during platform initialization. - Updated configuration files for QEMU boards to enable PCI and Virtio features. * Refactor driver initialization and static device registration - Removed the `registers.rs` files from various platforms, consolidating the register handling into a new `registers.rs` in the `axruntime` module. - Updated the `init.rs` files across platforms to eliminate direct driver initialization calls, instead relying on a unified `probe_all_devices` function. - Introduced static device registration for various drivers (SD/MMC, PCIe ECAM, VirtIO) using the new static device registration mechanism. - Enhanced the `StaticDeviceDesc` structure to support additional properties like `regs` and `pci_ecam`. - Updated the build scripts to include new static features for drivers. - Adjusted the `DriversIf` trait implementation to provide static device descriptions for platforms. * Enhance feature sets across various build configurations - Updated feature lists in multiple TOML files for aarch64, loongarch64, riscv64gc, and x86_64 architectures to include new hardware abstraction layer (HAL) and driver features. - Added support for PCI, VirtIO block, VirtIO net, and other drivers to improve hardware compatibility and performance. - Adjusted features in the axvisor and starryos test suites to ensure consistency and leverage new capabilities. - Ensured that all configurations now utilize the latest HAL and driver features for enhanced functionality and stability. * 为 virtio-net 驱动添加 ax-kernel-guard 依赖并重构 IRQ 处理逻辑 * 重构 PCI 设备 IRQ 处理逻辑,更新相关驱动以支持新的 IRQ 路由机制 * Refactor feature names in configuration files from "ax-drivers" to "ax-driver" - Updated multiple TOML configuration files across various test suites to change the feature prefix from "ax-drivers" to "ax-driver" for consistency and clarity. - This change affects configurations for platforms including x86_64, aarch64, loongarch64, and riscv64 in both normal and stress test scenarios. - Ensured that all relevant files reflect this naming convention to maintain uniformity across the codebase. * 更新 ax-driver 版本至 0.6.0,并相应修改 CHANGELOG * 在构建配置中添加对 "ax-hal/riscv64-qemu-virt-hv" 的支持 * 重构特性解析逻辑,添加平台特性检查并优化特性列表生成 * 优化文件系统块设备的条件编译,支持非动态平台和特定操作系统 * 移除 qemu 特性中的动态平台支持,优化特性列表 * 优化 Tty 设备的会话管理逻辑,确保终端与会话的正确关联;增加 JobControl 的会话设置错误处理;调整 QEMU 测试超时时间至 120 秒 * fix(axbuild): preserve driver features for C tests * 优化 pass_std_build_nested_features 函数以支持可变特性列表,并添加单元测试验证功能 * Update QEMU configurations and dependencies for various architectures - Added virtio-net-pci and netdev configurations to QEMU arguments for aarch64, loongarch64, riscv64, and x86_64 test cases to enable networking capabilities. - Removed unnecessary PCI and virtio driver features from build configurations for aarch64, loongarch64, riscv64, and x86_64. - Updated hello world, HTTP client, IO test, thread test, and Tokio test configurations to include virtio-blk-pci for disk access. - Adjusted Cargo.toml files to streamline dependencies by removing unused features related to multitasking and IRQ handling. * fix: 增加 QEMU 配置中的内存大小至 512M * Refactor driver-related documentation and code structure - Replaced instances of `ax-driver-base`, `axdriver_*` with new naming conventions: `rdrive`, `rd-*`, and `rdif-*` across various documentation files. - Updated dependency references in `ax-hal`, `ax-input`, `ax-net-ng`, `ax-posix-api`, `ax-runtime`, and `axplat-dyn` to reflect the new driver structure. - Removed references to deprecated driver crates in `layers.md`, `overview.md`, and `components.md`. - Adjusted the driver subsystem section in the documentation to align with the new driver architecture. - Modified the repository management script to remove specific handling for `axdriver_crates` due to structural changes. * fix(starryos): relax x86_64 qemu test timeouts * 优化块设备的读写操作,合并块读取和写入方法,提升性能 * 重构块设备读写方法,移除合并操作,简化代码逻辑 * 为 DmaPages 结构体添加 DMA 统一页面分配方法,并移除 SyncBlockOps 中的 flush 方法实现 * 为 PCI 和 USB 驱动程序添加 IRQ 解析功能,重构相关方法以提高可读性和可维护性 * 移除不再使用的 simple-sdmmc 驱动相关代码,更新文档以反映当前驱动栈状态 * 重构设备初始化逻辑,使用 cfg_if 宏简化条件编译,提升可读性 * 重构平台特性管理,简化条件编译逻辑,移除冗余代码 * 添加对 rk3588-pcie 的支持到 Orange Pi 5 Plus 的构建配置 * 为 UsbKernel 实现 DmaOp 特性,添加 prepare_read 和 confirm_write 方法 * refactor(root): simplify partition selection logic and add helper functions * refactor(driver): replace crate::register_driver! with module_driver! macro for driver registration * refactor(driver): remove unused device feature constants and simplify configuration logic * refactor(ci): rename required_repository_owner to limit_to_owner for clarity * refactor: replace ax-kspin with spin in various drivers and update dependencies * refactor: remove ax-kspin dependency and update mutex usage in USB driver * refactor: add ax-hal dependency to arceos-stack-guard-page * refactor: update UVC stream parameters and change Mutex to BlockingMutex for submitted URBs * refactor: enhance std feature normalization and add test for runtime feature propagation
背景
当前驱动实现和 ArceOS 平台 glue 耦合较深,跨 ArceOS、StarryOS、Axvisor 复用驱动时需要重复处理设备注册、MMIO/DMA、PCI/IRQ 路由和块/网络/显示/输入等接口边界。这个分支将公共驱动能力从单一 OS 模块中拆出,整理为更清晰的 Driver Core / Capability Boundary / OS Glue 分层。
主要改动
drivers/ax-driver,承载通用块设备、网络、PCI、VirtIO、USB、SoC 等驱动实现。rdrive探测注册流程,让驱动 crate 通过统一接口暴露给不同内核侧。components/axdriver_crates包组,并清理 workspace、lockfile、repo 元数据和文档引用。util-linux在新驱动栈下明显变慢的问题:rd-block支持按设备 DMA buffer 合并连续块请求,ax-driver块设备适配层保留上层批量 I/O 语义,virtio-blk 将 DMA buffer 调整为 32 个 sector。thread_test在堆扩展后触发 DataAbort。util-linux的主要耗时回归已通过批量块 I/O 修复。处理逻辑
drivers/下沉,降低行为变化范围。components/axdriver_crates,先确认仓库代码、workspace feature 和测试配置已切到drivers/ax-driver、rdrive、rd-block、rd-net、rdif-*,再完整移除旧本地 path crate,避免继续暴露已弃用入口。thread_test压力下 allocator 访问到声明内存范围内、QEMU 实际内存范围外的地址。因此同步 QEMU 内存到 512M。util-linux变慢,根因是新ax-driver/rd-block路径把 ext4/rsext4 传下来的批量块 I/O 拆成大量 512B 同步请求,loop/ext4 的 writeback 和umount阶段因此被放大。修复后,rd-block根据设备声明的 buffer 大小切分连续请求,ax-driver的Block适配层使用 merged read/write,virtio-blk 最终可以把多 sector buffer 直接交给VirtIOBlk::read_blocks/write_blocks。性能提升
util-linuxx86_64 的变慢集中在 loop/ext4 写回路径。修复前,本分支在旧 CI 日志中qemu run约 64.36s、case 约 70.53s;本地单跑也出现过qemu run约 80.52s、case 约 102.33s。对比 dev 上同类 CI 日志,util-linux通常约 38-41s。修复后本地验证:
cargo xtask starry test qemu --arch x86_64 -c util-linuxqemu run: 18.86sPASS util-linux (19.69s)也就是说,QEMU 阶段相对修复前约 64-80s 降到 18.86s,约 3.4x-4.3x 加速,并且已经低于 dev 日志中的 38-41s 水平。
验证
cargo metadata --locked --format-version 1cargo tree --locked --workspace -i ax-driver-base,预期找不到该 packagecargo tree --locked --workspace -i ax-driver-virtio,预期找不到该 packagecargo tree --locked -p ax-driver --edges normal,featurescargo fmt --all -- --checkcargo fmt --allcargo xtask clippy --package rd-blockcargo xtask clippy --package ax-drivercargo xtask clippy --package axplat-dyncargo xtask clippy --package ax-runtimecargo xtask sync-lint --since c41e98ba2fef8aa529a7a50fa1fd11deab5d7faccargo xtask arceos test qemu --arch aarch64 --test-group std --test-case thread_testcargo xtask starry test qemu --arch x86_64 -c test-mmap-prot-writecargo xtask starry test qemu --arch x86_64 -c util-linux最新 head:
5e4096b0b。