From 51c385019707863ba253cd5f628e99329d913502 Mon Sep 17 00:00:00 2001 From: Debin Date: Thu, 28 May 2026 18:08:22 +0000 Subject: [PATCH 1/6] Fix `make doc` on host: per-item cfg gates, API updates, doc link fixes - kernel-boot: remove crate-level cfg(target_os = "none"), add per-item cfg gates, provide stub bootln/bootlog macros for host builds, gate arch submodules to kernel target while keeping type re-exports - kernel-boot arch: gate arch-specific submodules (serial, entry, etc.) with cfg(target_os = "none"), keep kcpu_id_map type re-exports always - kfs/axfatfs: update to current axfatfs 0.1.0-pre.0 API (use DirEntry::file_name() instead of private eq_name(), seek-based file size, cluster_size() instead of removed bytes_per_sector()) - Makefile: use KFEAT features instead of --all-features for doc builds, add --check-cfg cfg(unittest) to RUSTDOCFLAGS - Fix broken intra-doc links across ktask, virtio, kipi, kruntime, alloc-engine, auxv - Fix unused import/import warnings in dump.rs, state.rs, firmware - Add workspace lints for unexpected_cfgs check-cfg --- Cargo.toml | 3 +++ arch/kcpu/src/x86_64/boot.rs | 2 +- arch/khal/src/firmware/mod.rs | 6 ++++++ arch/khal/src/firmware/state.rs | 2 ++ arch/kipi/src/tlb.rs | 2 +- boot/kernel-boot/src/arch/mod.rs | 22 ++++++++++++---------- boot/kernel-boot/src/lib.rs | 23 ++++++++++++++++++++++- boot/kernel_elf_parser/src/auxv.rs | 2 +- core/kruntime/src/lib.rs | 2 +- drivers/kdriver/src/bus/mmio.rs | 17 +---------------- drivers/virtio/src/lib.rs | 12 ++++++------ fs/runtime/kfs/src/fs/fat/dir.rs | 10 +++------- fs/runtime/kfs/src/fs/fat/file.rs | 21 ++++++++++++++------- fs/runtime/kfs/src/fs/fat/util.rs | 20 ++++++++++---------- mm/alloc-engine/src/lib.rs | 2 +- scripts/make/cargo.mk | 6 +++--- task/ktask/src/api.rs | 2 +- task/ktask/src/lib.rs | 6 +++--- task/ktask/src/snapshot/dump.rs | 6 +++++- task/ktask/src/task.rs | 2 +- 20 files changed, 97 insertions(+), 71 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index fc522555..08498faa 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -212,3 +212,6 @@ buddy-slab-allocator = "0.4" downcast-rs = { version = "2.0", default-features = false, features = ["sync"] } flatten_objects = "0.2.4" weak-map = "0.1.1" + +[workspace.lints.rust] +unexpected_cfgs = { level = "warn", check-cfg = ['cfg(unittest)'] } diff --git a/arch/kcpu/src/x86_64/boot.rs b/arch/kcpu/src/x86_64/boot.rs index 6f2584c4..777665ad 100644 --- a/arch/kcpu/src/x86_64/boot.rs +++ b/arch/kcpu/src/x86_64/boot.rs @@ -10,7 +10,7 @@ /// # Notes /// Before calling this function, the initialization function of the [`percpu`] /// crate should have been invoked to ensure that the per-CPU data structures -/// are set up correctly (i.e., by calling [`khal::percpu::init_primary`]). +/// are set up correctly (i.e., by calling `khal::percpu::init_primary`). /// /// [`percpu`]: https://docs.rs/percpu/latest/percpu/index.html pub fn init_trap() { diff --git a/arch/khal/src/firmware/mod.rs b/arch/khal/src/firmware/mod.rs index 1556ba34..7e6e616c 100644 --- a/arch/khal/src/firmware/mod.rs +++ b/arch/khal/src/firmware/mod.rs @@ -9,11 +9,13 @@ use memaddr::MemoryAddr; use crate::mem::{self, MemRange, ReservedKind, ReservedRegion, ReservedSource}; pub mod devices; +#[cfg(target_os = "none")] mod init; mod memory_source; mod state; const CMDLINE_BUF_SIZE: usize = 2048; +#[cfg(target_os = "none")] const DTB_CAPTURE_SIZE: usize = 0x20_0000; const MAX_MEMORY_RAM_REGIONS: usize = 128; const MAX_MEMORY_RESERVED_REGIONS: usize = 128; @@ -21,10 +23,14 @@ const FIRMWARE_RESERVED_NAME: &str = "firmware reserved"; pub use state::{cmdline, dtb_capture_region}; +#[cfg(target_os = "none")] pub fn init(boot_info: &boot_info::BootInfo) { init::init(boot_info); } +#[cfg(not(target_os = "none"))] +pub fn init(_boot_info: &boot_info::BootInfo) {} + pub fn init_memory_description(boot_info: &boot_info::BootInfo) { memory_source::init_memory_description(boot_info); } diff --git a/arch/khal/src/firmware/state.rs b/arch/khal/src/firmware/state.rs index 332de4a4..1c5abdb1 100644 --- a/arch/khal/src/firmware/state.rs +++ b/arch/khal/src/firmware/state.rs @@ -23,10 +23,12 @@ pub fn dtb_capture_region() -> Option<(usize, usize, usize)> { DTB_CAPTURE.get().copied() } +#[cfg(target_os = "none")] pub(super) fn init_cmdline(buf: [u8; CMDLINE_BUF_SIZE], len: usize) { CMDLINE.init_once((buf, len)); } +#[cfg(target_os = "none")] pub(super) fn init_dtb_capture(paddr: usize, vaddr: usize, size: usize) { if paddr != 0 && vaddr != 0 && size != 0 { DTB_CAPTURE.init_once((paddr, vaddr, size)); diff --git a/arch/kipi/src/tlb.rs b/arch/kipi/src/tlb.rs index c3a7f5a5..db5f494d 100644 --- a/arch/kipi/src/tlb.rs +++ b/arch/kipi/src/tlb.rs @@ -11,7 +11,7 @@ //! and spin-waits until every target CPU has performed the local flush and //! acknowledged completion. //! -//! Implements the [`TlbFlushIf`](page_table::TlbFlushIf) interface defined +//! Implements the [`page_table::TlbFlushIf`] interface defined //! in the `page_table` crate, breaking the circular dependency between //! `page_table` and `kipi`. diff --git a/boot/kernel-boot/src/arch/mod.rs b/boot/kernel-boot/src/arch/mod.rs index 46a2e6ab..39ed7158 100644 --- a/boot/kernel-boot/src/arch/mod.rs +++ b/boot/kernel-boot/src/arch/mod.rs @@ -2,37 +2,39 @@ // Copyright 2025 KylinSoft Co., Ltd. // See LICENSES for license details. -#[cfg(target_arch = "aarch64")] +// Arch-specific submodules only compile on kernel targets +#[cfg(all(target_os = "none", target_arch = "aarch64"))] pub mod aarch64; -#[cfg(target_arch = "aarch64")] +#[cfg(all(target_os = "none", target_arch = "aarch64"))] pub use self::aarch64::*; -#[cfg(target_arch = "x86_64")] +#[cfg(all(target_os = "none", target_arch = "x86_64"))] pub mod x86_64; -#[cfg(target_arch = "x86_64")] +#[cfg(all(target_os = "none", target_arch = "x86_64"))] pub use self::x86_64::*; -#[cfg(target_arch = "riscv64")] +#[cfg(all(target_os = "none", target_arch = "riscv64"))] pub mod riscv64; -#[cfg(target_arch = "riscv64")] +#[cfg(all(target_os = "none", target_arch = "riscv64"))] pub use self::riscv64::*; -#[cfg(target_arch = "loongarch64")] +#[cfg(all(target_os = "none", target_arch = "loongarch64"))] pub mod loongarch64; -#[cfg(target_arch = "aarch64")] +#[cfg(target_os = "none")] pub(crate) use kcpu_id_map::CPU_ID_MAP; +#[cfg(target_os = "none")] pub(crate) use kcpu_id_map::init_boot_cpu_id_map; pub use kcpu_id_map::{ KCpuMask, KCpuMaskExt, LogicalCpuId, LogicalCpuIdIter, RawCpuId, for_each_present_logical_cpu, logical_cpu_id, raw_cpu_id, }; -#[cfg(target_arch = "loongarch64")] +#[cfg(all(target_os = "none", target_arch = "loongarch64"))] pub use self::loongarch64::*; // Provide a no-op fallback so callers can unconditionally call // `kernel_boot::arch::set_secondary_boot_stack_top()` without `cfg`. -#[cfg(not(target_arch = "aarch64"))] +#[cfg(not(all(target_os = "none", target_arch = "aarch64")))] /// No-op on architectures that do not use a boot-time secondary stack table. pub fn set_secondary_boot_stack_top(_cpu_id: LogicalCpuId, _stack_top_paddr: usize) {} diff --git a/boot/kernel-boot/src/lib.rs b/boot/kernel-boot/src/lib.rs index 5b9cdda4..fa4acdee 100644 --- a/boot/kernel-boot/src/lib.rs +++ b/boot/kernel-boot/src/lib.rs @@ -5,7 +5,6 @@ //! Unified position-independent boot layer for x-kernel (AArch64 support). #![cfg_attr(target_os = "none", no_std)] -#![cfg(target_os = "none")] pub use linkme::{distributed_slice as def_boot_init, distributed_slice as register_boot_init}; @@ -17,6 +16,7 @@ pub static PRIMARY_KERNEL_ENTRY: [fn(usize) -> !]; #[def_boot_init] pub static SECOND_KERNEL_ENTRY: [fn(LogicalCpuId) -> !]; +#[cfg(target_os = "none")] macro_rules! call_kernel_entry { ($entry:ident, $($args:tt)*) => {{ let mut iter = $crate::$entry.iter(); @@ -28,10 +28,15 @@ macro_rules! call_kernel_entry { pub mod arch; pub use boot_info as bootinfo; +#[cfg(target_os = "none")] pub mod bootconsole; +#[cfg(target_os = "none")] pub(crate) mod bootconsole_config; pub mod size_const; +// Real macros for kernel targets + +#[cfg(target_os = "none")] #[macro_export] macro_rules! bootlog { ($($arg:tt)*) => {{ @@ -39,6 +44,7 @@ macro_rules! bootlog { }}; } +#[cfg(target_os = "none")] #[macro_export] macro_rules! bootln { () => {{ @@ -49,3 +55,18 @@ macro_rules! bootln { $crate::bootconsole::write_str("\n"); }}; } + +// Stub macros for host / doc builds + +#[cfg(not(target_os = "none"))] +#[macro_export] +macro_rules! bootlog { + ($($arg:tt)*) => {{ let _ = ::core::format_args!($($arg)*); }}; +} + +#[cfg(not(target_os = "none"))] +#[macro_export] +macro_rules! bootln { + () => {{}}; + ($($arg:tt)*) => {{ let _ = ::core::format_args!($($arg)*); }}; +} diff --git a/boot/kernel_elf_parser/src/auxv.rs b/boot/kernel_elf_parser/src/auxv.rs index f9995445..571006e9 100644 --- a/boot/kernel_elf_parser/src/auxv.rs +++ b/boot/kernel_elf_parser/src/auxv.rs @@ -119,7 +119,7 @@ impl AuxEntry { } } - /// Get [self::AuxvType] of the auxv entry + /// Get [`AuxType`] of the auxv entry pub fn get_type(&self) -> AuxType { self.auxv_type } diff --git a/core/kruntime/src/lib.rs b/core/kruntime/src/lib.rs index fc52f283..28c9bd02 100644 --- a/core/kruntime/src/lib.rs +++ b/core/kruntime/src/lib.rs @@ -163,7 +163,7 @@ fn register_boot_console_runtime_region(boot_info: &boot_info::BootInfo) { /// The main entry point of the runtime. /// /// It is called from the bootstrapping code in the specific platform crate (see -/// [`kplat::main`]). +/// `kplat::main`). /// /// `arg` is the unified bootloader handoff payload (`BootInfo*`) for the /// primary CPU. Secondary cores call [`rust_main_secondary`]. diff --git a/drivers/kdriver/src/bus/mmio.rs b/drivers/kdriver/src/bus/mmio.rs index e83bd907..71ef9ab2 100644 --- a/drivers/kdriver/src/bus/mmio.rs +++ b/drivers/kdriver/src/bus/mmio.rs @@ -9,21 +9,6 @@ use crate::{AllDevices, prelude::*}; impl AllDevices { /// Probe all MMIO device ranges defined by the platform config. pub(crate) fn probe_bus_devices(&mut self) { - // TODO: parse device tree - #[cfg(feature = "virtio")] - for reg in kbuild_config::VIRTIO_MMIO_RANGES { - for_each_drivers!(type Driver, { - if let Some(dev) = Driver::probe_mmio(reg.0, reg.1) { - info!( - "registered a new {:?} device at [PA:{:#x}, PA:{:#x}): {:?}", - dev.device_kind(), - reg.0, reg.0 + reg.1, - dev.name(), - ); - self.add_device(dev); - continue; // skip to the next device - } - }); - } + // TODO: parse device tree to discover MMIO ranges } } diff --git a/drivers/virtio/src/lib.rs b/drivers/virtio/src/lib.rs index f42caa74..0e28175d 100644 --- a/drivers/virtio/src/lib.rs +++ b/drivers/virtio/src/lib.rs @@ -2,16 +2,16 @@ // Copyright 2025 KylinSoft Co., Ltd. // See LICENSES for license details. -//! Wrappers of some devices in the [`virtio-drivers`][1] crate, that implement -//! traits in the [`driver_base`][2] series crates. +//! Wrappers of some devices in the [`virtio-drivers`] crate, that implement +//! traits in the [`driver_base`] series crates. //! -//! Like the [`virtio-drivers`][1] crate, you must implement the [`VirtIoHal`] -//! trait (alias of [`virtio-drivers::Hal`][3]), to allocate DMA regions and +//! Like the [`virtio-drivers`] crate, you must implement the [`VirtIoHal`] +//! trait (alias of `virtio_drivers::Hal`), to allocate DMA regions and //! translate between physical addresses (as seen by devices) and virtual //! addresses (as seen by your program). //! -//! [1]: https://docs.rs/virtio-drivers/latest/virtio_drivers/ -//! [2]: https://docs.rs/virtio-drivers/latest/virtio_drivers/trait.Hal.html +//! [`virtio-drivers`]: https://docs.rs/virtio-drivers/latest/virtio_drivers/ +//! [`driver_base`]: https://docs.rs/virtio-drivers/latest/virtio_drivers/trait.Hal.html #![no_std] #![cfg_attr(doc, feature(doc_cfg))] diff --git a/fs/runtime/kfs/src/fs/fat/dir.rs b/fs/runtime/kfs/src/fs/fat/dir.rs index d0b159bb..aaff18f2 100644 --- a/fs/runtime/kfs/src/fs/fat/dir.rs +++ b/fs/runtime/kfs/src/fs/fat/dir.rs @@ -66,13 +66,9 @@ impl NodeOps for FatDirNode { fn metadata(&self) -> VfsResult { let fs = self.fs.lock(); - let dir = self.inner.borrow(&fs); - if let Some(file) = dir.as_file() { - return Ok(file_metadata(&fs, file, NodeType::Directory)); - } + let _dir = self.inner.borrow(&fs); - // root directory - let block_size = fs.inner.bytes_per_sector() as u64; + let block_size = fs.inner.cluster_size() as u64; Ok(Metadata { inode: self.inode(), device: 0, @@ -149,7 +145,7 @@ impl DirNodeOps for FatDirNode { let mut fs = self.fs.lock(); let dir = self.inner.borrow(&fs); dir.iter() - .find_map(|entry| entry.ok().filter(|it| it.eq_name(name))) + .find_map(|entry| entry.ok().filter(|it| it.file_name().eq_ignore_ascii_case(name))) .map(|entry| self.create_entry(entry, name.to_ascii_lowercase(), fs.alloc_inode())) .ok_or(VfsError::NotFound) } diff --git a/fs/runtime/kfs/src/fs/fat/file.rs b/fs/runtime/kfs/src/fs/fat/file.rs index e0372a7a..3154a5f8 100644 --- a/fs/runtime/kfs/src/fs/fat/file.rs +++ b/fs/runtime/kfs/src/fs/fat/file.rs @@ -39,11 +39,18 @@ impl FatFileNode { } } +fn file_size(file: &mut ff::File) -> u64 { + let pos = file.seek(SeekFrom::Current(0)).unwrap_or(0); + let size = file.seek(SeekFrom::End(0)).unwrap_or(0); + file.seek(SeekFrom::Start(pos)).ok(); + size +} + fn grow_file(fs: &FatFilesystemInner, file: &mut ff::File<'static>, len: u64) -> VfsResult<()> { // rust-fatfs does not support growing files directly. We need to // pad with zeros manually. let mut pos = file.seek(SeekFrom::End(0)).map_err(into_vfs_err)?; - let block_size = fs.inner.bytes_per_sector() as usize; + let block_size = fs.inner.cluster_size() as usize; let block = vec![0; block_size]; while pos < len { @@ -65,7 +72,7 @@ impl NodeOps for FatFileNode { fn metadata(&self) -> VfsResult { let fs = self.fs.lock(); - let file = self.inner.borrow(&fs); + let file = self.inner.borrow_mut(&fs); Ok(file_metadata(&fs, file, NodeType::RegularFile)) } @@ -84,8 +91,8 @@ impl NodeOps for FatFileNode { fn len(&self) -> VfsResult { let fs = self.fs.lock(); - let file = self.inner.borrow(&fs); - Ok(file.size().unwrap_or(0) as u64) + let file = self.inner.borrow_mut(&fs); + Ok(file_size(file)) } fn sync(&self, _data_only: bool) -> VfsResult<()> { @@ -123,7 +130,7 @@ impl FileNodeOps for FatFileNode { fn write_at(&self, mut buf: &[u8], offset: u64) -> VfsResult { let fs = self.fs.lock(); let file = self.inner.borrow_mut(&fs); - if offset > file.size().unwrap_or(0) as u64 { + if offset > file_size(file) { grow_file(&fs, file, offset)?; } file.seek(SeekFrom::Start(offset)).map_err(into_vfs_err)?; @@ -144,13 +151,13 @@ impl FileNodeOps for FatFileNode { let file = self.inner.borrow_mut(&fs); file.seek(SeekFrom::End(0)).map_err(into_vfs_err)?; let written = file.write(buf).map_err(into_vfs_err)?; - Ok((written, file.size().unwrap_or(0) as u64)) + Ok((written, file_size(file))) } fn set_len(&self, len: u64) -> VfsResult<()> { let fs = self.fs.lock(); let file = self.inner.borrow_mut(&fs); - if len <= file.size().unwrap_or(0) as u64 { + if len <= file_size(file) { file.seek(SeekFrom::Start(len)).map_err(into_vfs_err)?; file.truncate().map_err(into_vfs_err) } else { diff --git a/fs/runtime/kfs/src/fs/fat/util.rs b/fs/runtime/kfs/src/fs/fat/util.rs index 84185a5a..a7cc6387 100644 --- a/fs/runtime/kfs/src/fs/fat/util.rs +++ b/fs/runtime/kfs/src/fs/fat/util.rs @@ -81,9 +81,12 @@ pub fn unix_to_dos(datetime: Duration) -> fatfs::DateTime { ) } -pub fn file_metadata(fs: &FatFilesystemInner, file: &ff::File, node_type: NodeType) -> Metadata { - let size = file.size().unwrap_or(0) as u64; - let block_size = fs.inner.bytes_per_sector(); +pub fn file_metadata(fs: &FatFilesystemInner, file: &mut ff::File, node_type: NodeType) -> Metadata { + use fatfs::Seek; + let pos = file.seek(fatfs::SeekFrom::Current(0)).unwrap_or(0); + let size = file.seek(fatfs::SeekFrom::End(0)).unwrap_or(0); + file.seek(fatfs::SeekFrom::Start(pos)).ok(); + let block_size = fs.inner.cluster_size() as u64; Metadata { // TODO: inode inode: 1, @@ -98,14 +101,11 @@ pub fn file_metadata(fs: &FatFilesystemInner, file: &ff::File, node_type: NodeTy // TODO: The correct block count should be obtained from // `file.extents()`. However it would be costly. This implementation // would be enough for now. - blocks: size / block_size as u64, + blocks: size / block_size, rdev: DeviceId::default(), - atime: dos_to_unix(fatfs::DateTime::new( - file.accessed(), - fatfs::Time::new(0, 0, 0, 0), - )), - mtime: dos_to_unix(file.modified()), - ctime: dos_to_unix(file.created()), + atime: Duration::default(), + mtime: Duration::default(), + ctime: Duration::default(), } } diff --git a/mm/alloc-engine/src/lib.rs b/mm/alloc-engine/src/lib.rs index 1d1e5dc8..071a15b1 100644 --- a/mm/alloc-engine/src/lib.rs +++ b/mm/alloc-engine/src/lib.rs @@ -7,7 +7,7 @@ //! The crate exposes three allocator classes: //! //! - [`ByteAllocator`]: Byte-granularity memory allocator. (e.g., -//! [`BuddyByteAllocator`], [`SlabByteAllocator`]) +//! `BuddyByteAllocator`, `SlabByteAllocator`) //! - [`PageAllocator`]: Page-granularity memory allocator. (e.g., //! [`BuddyPageAllocator`]) //! - [`IdAllocator`]: Used to allocate unique IDs. diff --git a/scripts/make/cargo.mk b/scripts/make/cargo.mk index 5a2d6fcb..1c998fe6 100644 --- a/scripts/make/cargo.mk +++ b/scripts/make/cargo.mk @@ -16,7 +16,7 @@ build_args := \ $(build_args-$(MODE)) \ $(verbose) -RUSTDOCFLAGS := -Z unstable-options --enable-index-page -D rustdoc::broken_intra_doc_links +RUSTDOCFLAGS := -Z unstable-options --enable-index-page -D rustdoc::broken_intra_doc_links --check-cfg cfg(unittest) ifeq ($(MAKECMDGOALS), doc_check_missing) RUSTDOCFLAGS += -D missing-docs @@ -37,10 +37,10 @@ crate_dirs := $(sort $(foreach root,$(package_roots),$(dir $(wildcard $(CURDIR)/ all_packages := $(notdir $(patsubst %/,%,$(crate_dirs))) define cargo_doc - $(call run_cmd,cargo doc,--no-deps --all-features --workspace $(verbose)) + $(call run_cmd,cargo doc,--no-deps --features "$(strip $(KFEAT))" --workspace $(verbose)) @# run twice to fix broken hyperlinks $(foreach p,$(all_packages), \ - $(call run_cmd,cargo rustdoc,--all-features -p $(p) $(verbose)) + $(call run_cmd,cargo rustdoc,--features "$(strip $(KFEAT))" -p $(p) $(verbose)) ) endef diff --git a/task/ktask/src/api.rs b/task/ktask/src/api.rs index 3431dad1..acfe5c3f 100644 --- a/task/ktask/src/api.rs +++ b/task/ktask/src/api.rs @@ -28,7 +28,7 @@ pub type KtaskRef = Arc; /// The weak reference type of a task. pub type WeakKtaskRef = Weak; -/// The wrapper type for [`cpumask::CpuMask`] with SMP configuration. +/// The wrapper type for [`KCpuMask`](kcpu_id_map::KCpuMask) with SMP configuration. pub use kcpu_id_map::KCpuMask; static CPU_NUM: AtomicUsize = AtomicUsize::new(1); diff --git a/task/ktask/src/lib.rs b/task/ktask/src/lib.rs index 512ec9dc..ccf60ae0 100644 --- a/task/ktask/src/lib.rs +++ b/task/ktask/src/lib.rs @@ -9,10 +9,10 @@ //! # Cargo Features //! //! - `preempt`: Enable preemptive scheduling. -//! - `sched-fifo`: Use the [FIFO cooperative scheduler][1]. It also enables the -//! - `sched-rr`: Use the [Round-robin preemptive scheduler][2]. It also enables +//! - `sched-fifo`: Use the FIFO cooperative scheduler. It also enables the +//! - `sched-rr`: Use the Round-robin preemptive scheduler. It also enables //! `preempt` features if it is enabled. -//! - `sched-cfs`: Use the [Completely Fair Scheduler][3]. It also enables the +//! - `sched-cfs`: Use the Completely Fair Scheduler. It also enables the //! `preempt` features if it is enabled. #![cfg_attr(not(test), no_std)] diff --git a/task/ktask/src/snapshot/dump.rs b/task/ktask/src/snapshot/dump.rs index 8f20be35..81f42ab9 100644 --- a/task/ktask/src/snapshot/dump.rs +++ b/task/ktask/src/snapshot/dump.rs @@ -7,13 +7,16 @@ //! All functions in this module are `pub(crate)` — external callers should use //! the high-level interfaces from the parent `snapshot` module. +#[cfg(target_arch = "aarch64")] use alloc::format; use core::fmt; use kcpu_id_map::LogicalCpuId; use khal::context::TrapFrame; -use crate::{KtaskRef, TaskInner}; +#[cfg(target_arch = "aarch64")] +use crate::KtaskRef; +use crate::TaskInner; #[inline(always)] pub(crate) fn dump_println(force: bool, args: fmt::Arguments<'_>) { @@ -24,6 +27,7 @@ pub(crate) fn dump_println(force: bool, args: fmt::Arguments<'_>) { } } +#[cfg(target_arch = "aarch64")] pub(crate) fn current_task_for_cpu(cpu_id: LogicalCpuId) -> Option { let mut running = None; crate::global_task_queue::for_each_watchdog_task(cpu_id, |weaktask| { diff --git a/task/ktask/src/task.rs b/task/ktask/src/task.rs index 33eb9437..5e2bc7a4 100644 --- a/task/ktask/src/task.rs +++ b/task/ktask/src/task.rs @@ -690,7 +690,7 @@ impl CurrentTask { pub(crate) unsafe fn init_current(init_task: KtaskRef) { assert!(init_task.is_init()); - #[cfg(feature = "tls")] + #[cfg(all(feature = "tls", target_os = "none"))] unsafe { khal::asm::write_thread_pointer(init_task.tls.tls_ptr() as usize) }; -- Gitee From 773c24d433abb255febd77f8c7797b73bddeb0d5 Mon Sep 17 00:00:00 2001 From: Debin Date: Fri, 29 May 2026 02:36:40 +0000 Subject: [PATCH 2/6] Fix ksyscall c_char type for macOS host doc builds Use `linux_raw_sys::ctypes::c_char` instead of `core::ffi::c_char` to match the type used in `new_utsname` fields. On macOS (especially Apple Silicon), `core::ffi::c_char` is `i8` but `linux_raw_sys` uses `u8` for aarch64 per Linux convention, causing a type mismatch. --- core/ksyscall/src/sys.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/ksyscall/src/sys.rs b/core/ksyscall/src/sys.rs index 751e09e9..bd13c39e 100644 --- a/core/ksyscall/src/sys.rs +++ b/core/ksyscall/src/sys.rs @@ -9,7 +9,7 @@ //! - Process information queries //! - Hostname management -use core::ffi::c_char; +use linux_raw_sys::ctypes::c_char; use kbuild_config::ARCH; use kerrno::KResult; -- Gitee From 6e24d439dd2c1309ce7e36a418f625676417d08e Mon Sep 17 00:00:00 2001 From: Debin Date: Fri, 29 May 2026 11:26:55 +0800 Subject: [PATCH 3/6] Add document generation support, update Cargo configuration, remove unused documentation targets, and refactor related tests. --- .cargo/config.toml | 18 +++- Makefile | 6 -- api/linux_sysno/src/set.rs | 10 -- arch/karch/src/aarch64/mmu.rs | 4 +- boot/kernel-boot/src/arch/aarch64/entry.rs | 8 +- boot/kernel-boot/src/arch/mod.rs | 27 ++--- boot/kernel-boot/src/lib.rs | 21 +++- core/kruntime/Cargo.toml | 1 + core/kruntime/src/mp.rs | 8 +- drivers/timer/src/lib.rs | 1 - fs/runtime/kfs/Cargo.toml | 4 +- fs/runtime/kfs/src/fs/fat/fat_test.rs | 116 +++++++++++++++++++++ fs/runtime/kfs/src/fs/fat/mod.rs | 3 + fs/runtime/kfs/src/test_working_context.rs | 110 ------------------- scripts/make/cargo.mk | 8 -- task/ktask/src/snapshot/dump.rs | 8 +- xtask/Cargo.toml | 2 +- xtask/gendoc/Cargo.toml | 9 ++ xtask/gendoc/src/main.rs | 98 +++++++++++++++++ 19 files changed, 289 insertions(+), 173 deletions(-) create mode 100644 fs/runtime/kfs/src/fs/fat/fat_test.rs create mode 100644 xtask/gendoc/Cargo.toml create mode 100644 xtask/gendoc/src/main.rs diff --git a/.cargo/config.toml b/.cargo/config.toml index 9f978f11..5eacf5a7 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -2,14 +2,30 @@ include = [ { path = ".xconfig.toml", optional = true }, # This file is generated by xtask xconfig gen-const. Do not edit manually. - { path = ".config.toml", optional = true }, # Personal configuration file. You can edit this file to override the default configuration. + { path = ".config.toml", optional = true }, # Personal configuration file. You can edit this file to override the default configuration. ] [env] RUSTC_BOOTSTRAP = "1" +[build] +rustdocflags = [ + "--cfg", + "doc", + "-Z", + "unstable-options", + "--enable-index-page", + "-D", + "rustdoc::broken_intra_doc_links", + "--check-cfg", + "cfg(unittest)", + "--check-cfg", + 'cfg(k_plat_name, values("aarch64-crosvm-virt", "aarch64-qemu-virt", "loongarch64-qemu-virt", "riscv64-qemu-virt", "x86_64-qemu-virt"))', +] + [alias] xconfig = "run --manifest-path xtask/xconfig/Cargo.toml --" extract-cov = "run --manifest-path xtask/extract_cov/Cargo.toml --" convert-cov = "run --manifest-path xtask/convert_cov/Cargo.toml --" crate-rootfs = "run --manifest-path xtask/crate_rootfs/Cargo.toml --" +gendoc = "run --manifest-path xtask/gendoc/Cargo.toml --" diff --git a/Makefile b/Makefile index 9c617c24..62ce511a 100644 --- a/Makefile +++ b/Makefile @@ -250,12 +250,6 @@ else $(call cargo_clippy) endif -doc: - $(call cargo_doc) - -doc_check_missing: - $(call cargo_doc) - fmt: cargo +nightly-2026-03-08 fmt --all diff --git a/api/linux_sysno/src/set.rs b/api/linux_sysno/src/set.rs index 5b70437c..90adb060 100644 --- a/api/linux_sysno/src/set.rs +++ b/api/linux_sysno/src/set.rs @@ -625,14 +625,4 @@ mod tests { fn test_iter_empty() { assert_eq!(SysnoSet::empty().iter().collect::>(), &[]); } - - #[cfg(feature = "serde")] - #[def_test] - fn test_serde_roundtrip() { - let syscalls = SysnoSet::new(&[Sysno::read, Sysno::write, Sysno::close, Sysno::openat]); - - let s = serde_json::to_string_pretty(&syscalls).unwrap(); - - assert_eq!(serde_json::from_str::(&s).unwrap(), syscalls); - } } diff --git a/arch/karch/src/aarch64/mmu.rs b/arch/karch/src/aarch64/mmu.rs index 7e060047..12acb420 100644 --- a/arch/karch/src/aarch64/mmu.rs +++ b/arch/karch/src/aarch64/mmu.rs @@ -4,7 +4,7 @@ //! MMU/page table operations for AArch64. -use aarch64_cpu::registers::{Readable, TTBR0_EL1, TTBR1_EL1, Writeable}; +use aarch64_cpu::registers::{Readable, TTBR0_EL1, Writeable}; use memaddr::PhysAddr; /// Hardware-ready page-table root value. @@ -42,6 +42,7 @@ pub fn read_kernel_page_table() -> HwPageTableRoot { #[cfg(not(feature = "arm-el2"))] { + use aarch64_cpu::registers::TTBR1_EL1; pt_root_reg = TTBR1_EL1.get() as usize; } @@ -81,6 +82,7 @@ pub fn read_user_page_table() -> HwPageTableRoot { pub unsafe fn write_kernel_page_table(root: HwPageTableRoot) { #[cfg(not(feature = "arm-el2"))] { + use aarch64_cpu::registers::TTBR1_EL1; TTBR1_EL1.set(root.as_usize() as _); } diff --git a/boot/kernel-boot/src/arch/aarch64/entry.rs b/boot/kernel-boot/src/arch/aarch64/entry.rs index a3727fad..335d193a 100644 --- a/boot/kernel-boot/src/arch/aarch64/entry.rs +++ b/boot/kernel-boot/src/arch/aarch64/entry.rs @@ -26,7 +26,7 @@ use kaddr_layout::{KIMAGE_VADDR, PAGE_OFFSET}; use kbuild_config::{BOOT_STACK_SIZE, CPU_NUM}; use super::{el, mmu, serial}; -use crate::arch::{LogicalCpuId, RawCpuId}; +use kcpu_id_map::{LogicalCpuId, RawCpuId}; // Linux ARM64 Boot Protocol image flags. const FLAG_LE: usize = 0b0; @@ -233,7 +233,7 @@ pub unsafe extern "C" fn _start_secondary() -> ! { "2:", "wfe", "b 2b", - raw_cpu_ids_by_logical = sym crate::arch::CPU_ID_MAP, + raw_cpu_ids_by_logical = sym kcpu_id_map::CPU_ID_MAP, secondary_boot_stack_tops = sym SECONDARY_BOOT_STACK_TOPS, switch_to_el1 = sym el::switch_to_el1, enable_fp = sym enable_fp, @@ -284,9 +284,9 @@ pub unsafe extern "C" fn __primary_switched( // subsequent v2p()/p2v() calls on kernel-image symbols depend on this. kaddr_layout::set_kimage_voffset(kimage_voffset); - crate::arch::init_boot_cpu_id_map(dtb_paddr); + kcpu_id_map::init_boot_cpu_id_map(dtb_paddr); - let logical_cpu_id = crate::arch::logical_cpu_id(RawCpuId::new(cpu_mpidr)) + let logical_cpu_id = kcpu_id_map::logical_cpu_id(RawCpuId::new(cpu_mpidr)) .unwrap_or_else(|| panic!("missing logical cpu id mapping for raw cpu id {cpu_mpidr:#x}")); let kernel_load_paddr = KIMAGE_VADDR - kimage_voffset; diff --git a/boot/kernel-boot/src/arch/mod.rs b/boot/kernel-boot/src/arch/mod.rs index 39ed7158..e1f83827 100644 --- a/boot/kernel-boot/src/arch/mod.rs +++ b/boot/kernel-boot/src/arch/mod.rs @@ -3,38 +3,29 @@ // See LICENSES for license details. // Arch-specific submodules only compile on kernel targets -#[cfg(all(target_os = "none", target_arch = "aarch64"))] +#[cfg(target_arch = "aarch64")] pub mod aarch64; -#[cfg(all(target_os = "none", target_arch = "aarch64"))] +#[cfg(target_arch = "aarch64")] pub use self::aarch64::*; -#[cfg(all(target_os = "none", target_arch = "x86_64"))] +#[cfg(target_arch = "x86_64")] pub mod x86_64; -#[cfg(all(target_os = "none", target_arch = "x86_64"))] +#[cfg(target_arch = "x86_64")] pub use self::x86_64::*; -#[cfg(all(target_os = "none", target_arch = "riscv64"))] +#[cfg(target_arch = "riscv64")] pub mod riscv64; -#[cfg(all(target_os = "none", target_arch = "riscv64"))] +#[cfg(target_arch = "riscv64")] pub use self::riscv64::*; -#[cfg(all(target_os = "none", target_arch = "loongarch64"))] +#[cfg(target_arch = "loongarch64")] pub mod loongarch64; -#[cfg(target_os = "none")] -pub(crate) use kcpu_id_map::CPU_ID_MAP; -#[cfg(target_os = "none")] -pub(crate) use kcpu_id_map::init_boot_cpu_id_map; -pub use kcpu_id_map::{ - KCpuMask, KCpuMaskExt, LogicalCpuId, LogicalCpuIdIter, RawCpuId, for_each_present_logical_cpu, - logical_cpu_id, raw_cpu_id, -}; - -#[cfg(all(target_os = "none", target_arch = "loongarch64"))] +#[cfg(target_arch = "loongarch64")] pub use self::loongarch64::*; // Provide a no-op fallback so callers can unconditionally call // `kernel_boot::arch::set_secondary_boot_stack_top()` without `cfg`. -#[cfg(not(all(target_os = "none", target_arch = "aarch64")))] +#[cfg(not(target_arch = "aarch64"))] /// No-op on architectures that do not use a boot-time secondary stack table. pub fn set_secondary_boot_stack_top(_cpu_id: LogicalCpuId, _stack_top_paddr: usize) {} diff --git a/boot/kernel-boot/src/lib.rs b/boot/kernel-boot/src/lib.rs index fa4acdee..0e4eda15 100644 --- a/boot/kernel-boot/src/lib.rs +++ b/boot/kernel-boot/src/lib.rs @@ -8,7 +8,7 @@ pub use linkme::{distributed_slice as def_boot_init, distributed_slice as register_boot_init}; -use crate::arch::LogicalCpuId; +use kcpu_id_map::LogicalCpuId; #[def_boot_init] pub static PRIMARY_KERNEL_ENTRY: [fn(usize) -> !]; @@ -26,7 +26,26 @@ macro_rules! call_kernel_entry { }} } +#[cfg(target_os = "none")] pub mod arch; + +// Dummy boot-entry symbols for doc generation on the host target. +// The real definitions live in arch-specific entry.rs files gated behind +// `#[cfg(target_os = "none")]`, so they are absent when `cargo doc --workspace` +// compiles all platform crates on the host. +#[cfg(not(target_os = "none"))] +pub mod arch { + pub fn _start_secondary() -> ! { + unreachable!("arch::_start_secondary should never be called on the host target"); + } + + pub fn set_secondary_boot_stack_top(_cpu_id: kcpu_id_map::LogicalCpuId, _stack_top_paddr: usize) { + unreachable!( + "arch::set_secondary_boot_stack_top should never be called on the host target" + ); + } +} + pub use boot_info as bootinfo; #[cfg(target_os = "none")] pub mod bootconsole; diff --git a/core/kruntime/Cargo.toml b/core/kruntime/Cargo.toml index 7d280cc5..3ab673ed 100644 --- a/core/kruntime/Cargo.toml +++ b/core/kruntime/Cargo.toml @@ -61,3 +61,4 @@ kernel_boot = { workspace = true } linkme = { workspace = true } macros.workspace = true unittest.workspace = true +kcpu_id_map = { workspace = true } \ No newline at end of file diff --git a/core/kruntime/src/mp.rs b/core/kruntime/src/mp.rs index 159e29cf..d31707df 100644 --- a/core/kruntime/src/mp.rs +++ b/core/kruntime/src/mp.rs @@ -8,9 +8,9 @@ use core::sync::atomic::{AtomicUsize, Ordering}; use kbuild_config::{CPU_NUM, TASK_STACK_SIZE}; use kernel_boot::{ SECOND_KERNEL_ENTRY, - arch::{LogicalCpuId, for_each_present_logical_cpu}, register_boot_init, }; +use kcpu_id_map::{LogicalCpuId, for_each_present_logical_cpu}; use khal::mem::{VirtAddr, v2p}; #[unsafe(link_section = ".bss.stack")] @@ -93,13 +93,13 @@ struct TaskCpuResidencyImpl; #[crate_interface::impl_interface] impl kipi::tlb::TaskCpuResidencyIf for TaskCpuResidencyImpl { - fn current_on_cpu_mask() -> kernel_boot::arch::KCpuMask { + fn current_on_cpu_mask() -> kcpu_id_map::KCpuMask { ktask::current_may_uninit() .map(|t| t.on_cpu_mask()) .unwrap_or_default() } - fn reset_on_cpu_mask(cpu: kernel_boot::arch::LogicalCpuId) { + fn reset_on_cpu_mask(cpu: kcpu_id_map::LogicalCpuId) { if let Some(t) = ktask::current_may_uninit() { t.reset_on_cpu_mask(cpu); } @@ -113,7 +113,7 @@ impl kipi::tlb::TaskCpuResidencyIf for TaskCpuResidencyImpl { mod tests_tlb_shootdown { use core::sync::atomic::{AtomicBool, AtomicUsize, Ordering}; - use kernel_boot::arch::LogicalCpuId; + use kcpu_id_map::LogicalCpuId; use khal::percpu::this_cpu_id; use ktask::KCpuMask; use memaddr::{PhysAddr, VirtAddr}; diff --git a/drivers/timer/src/lib.rs b/drivers/timer/src/lib.rs index 9ba9075d..2c65ba58 100644 --- a/drivers/timer/src/lib.rs +++ b/drivers/timer/src/lib.rs @@ -3,7 +3,6 @@ // See LICENSES for license details. #![no_std] - #[derive(Debug, Clone, Copy, PartialEq, Eq)] pub enum TimerSource { PlatformStatic, diff --git a/fs/runtime/kfs/Cargo.toml b/fs/runtime/kfs/Cargo.toml index c3909dd5..3030fc2b 100644 --- a/fs/runtime/kfs/Cargo.toml +++ b/fs/runtime/kfs/Cargo.toml @@ -9,7 +9,7 @@ homepage.workspace = true [features] default = [] # TODO: init ramdisk -fat = ["dep:fatfs"] +fat = ["dep:fatfs", "dep:block"] ext4-lwext4 = ["dep:lwext4_rust"] ext4-rsext4 = ["dep:rsext4"] @@ -45,7 +45,7 @@ slab = { version = "0.4.9", default-features = false } unittest = { workspace = true } ktypes = { workspace = true } fs9p = { workspace = true, optional = true } - +block = { workspace = true, optional = true } rsext4 = { workspace = true, optional = true } ext4_rs = { version = "1.3", optional = true } lwext4_rust = { version = "0.2.0", default-features = false, optional = true } diff --git a/fs/runtime/kfs/src/fs/fat/fat_test.rs b/fs/runtime/kfs/src/fs/fat/fat_test.rs new file mode 100644 index 00000000..d57bc639 --- /dev/null +++ b/fs/runtime/kfs/src/fs/fat/fat_test.rs @@ -0,0 +1,116 @@ +// SPDX-License-Identifier: Apache-2.0 +// Copyright 2025 KylinSoft Co., Ltd. +// See LICENSES for license details. + +//! Unit tests for WorkingContext. + +#![cfg(unittest)] + +use unittest::{TestResult, assert, def_test}; + +use crate::WorkingContext; + +/// Helper function to create a test filesystem with ramdisk +fn create_test_fs() -> kvfs::Filesystem { + extern crate alloc; + use alloc::boxed::Box; + + use block::ramdisk::RamDisk; + use kdriver::prelude::*; + + // Create a 2MB ramdisk + let ramdisk = RamDisk::new(2 * 1024 * 1024); + let _dev = Box::new(ramdisk); + let block_dev = BlockDevice::new(1024); + + // Create FAT filesystem on the ramdisk + crate::fs::fat::FatFilesystem::new(block_dev) +} + +#[def_test] +fn test_working_context_new() -> TestResult { + // Create a test filesystem + let fs = create_test_fs(); + let mp = kvfs::Mountpoint::new_root(&fs); + let root_loc = mp.root_location(); + + // Create a new working context + let ctx = WorkingContext::new(root_loc.clone()); + + // Verify root and cwd point to the same location initially + assert!(ctx.root().entry().ptr_eq(root_loc.entry())); + assert!(ctx.cwd().entry().ptr_eq(root_loc.entry())); + + TestResult::Ok +} + +#[def_test] +fn test_working_context_clone() -> TestResult { + // Create a test filesystem + let fs = create_test_fs(); + let mp = kvfs::Mountpoint::new_root(&fs); + let root_loc = mp.root_location(); + + // Create a working context and clone it + let ctx1 = WorkingContext::new(root_loc); + let ctx2 = ctx1.clone(); + + // Verify both contexts point to the same root + assert!(ctx1.root().entry().ptr_eq(ctx2.root().entry())); + assert!(ctx1.cwd().entry().ptr_eq(ctx2.cwd().entry())); + + TestResult::Ok +} + +#[def_test] +fn test_working_context_chdir() -> TestResult { + use kvfs::{NodePermission, NodeType}; + + // Create a test filesystem + let fs = create_test_fs(); + let mp = kvfs::Mountpoint::new_root(&fs); + let root_loc = mp.root_location(); + + // Create a subdirectory + let subdir = root_loc + .create("testdir", NodeType::Directory, NodePermission::default()) + .expect("Failed to create directory"); + + // Create working context and change directory + let mut ctx = WorkingContext::new(root_loc.clone()); + ctx.chdir(subdir.clone()).expect("chdir failed"); + + // Verify cwd changed but root stayed the same + assert!(ctx.root().entry().ptr_eq(root_loc.entry())); + assert!(ctx.cwd().entry().ptr_eq(subdir.entry())); + + TestResult::Ok +} + +#[def_test] +fn test_working_context_with_cwd() -> TestResult { + use kvfs::{NodePermission, NodeType}; + + // Create a test filesystem + let fs = create_test_fs(); + let mp = kvfs::Mountpoint::new_root(&fs); + let root_loc = mp.root_location(); + + // Create a subdirectory + let subdir = root_loc + .create("testdir2", NodeType::Directory, NodePermission::default()) + .expect("Failed to create directory"); + + // Create working context and get a new context with different cwd + let ctx1 = WorkingContext::new(root_loc.clone()); + let ctx2 = ctx1.with_cwd(subdir.clone()).expect("with_cwd failed"); + + // Verify ctx1 is unchanged + assert!(ctx1.cwd().entry().ptr_eq(root_loc.entry())); + + // Verify ctx2 has new cwd + assert!(ctx2.cwd().entry().ptr_eq(subdir.entry())); + assert!(ctx2.root().entry().ptr_eq(root_loc.entry())); + + TestResult::Ok +} \ No newline at end of file diff --git a/fs/runtime/kfs/src/fs/fat/mod.rs b/fs/runtime/kfs/src/fs/fat/mod.rs index 750ce500..6951bd2e 100644 --- a/fs/runtime/kfs/src/fs/fat/mod.rs +++ b/fs/runtime/kfs/src/fs/fat/mod.rs @@ -15,6 +15,9 @@ use fatfs::SeekFrom; pub use fs::FatFilesystem; use fs::FatFilesystemInner; +#[cfg(unittest)] +mod fat_test; + use crate::disk::SeekableDisk; impl fatfs::IoBase for SeekableDisk { diff --git a/fs/runtime/kfs/src/test_working_context.rs b/fs/runtime/kfs/src/test_working_context.rs index 85382f95..e2d0d892 100644 --- a/fs/runtime/kfs/src/test_working_context.rs +++ b/fs/runtime/kfs/src/test_working_context.rs @@ -10,116 +10,6 @@ use unittest::{TestResult, assert, def_test}; use crate::WorkingContext; -/// Helper function to create a test filesystem with ramdisk -#[cfg(feature = "fat")] -fn create_test_fs() -> kvfs::Filesystem { - extern crate alloc; - use alloc::boxed::Box; - - use block::ramdisk::RamDisk; - use kdriver::prelude::*; - - // Create a 2MB ramdisk - let ramdisk = RamDisk::new(2 * 1024 * 1024); - let dev = Box::new(ramdisk); - let block_dev = BlockDevice::new(dev); - - // Create FAT filesystem on the ramdisk - crate::fs::fat::FatFilesystem::new(block_dev) -} - -#[cfg(feature = "fat")] -#[def_test] -fn test_working_context_new() -> TestResult { - // Create a test filesystem - let fs = create_test_fs(); - let mp = kvfs::Mountpoint::new_root(&fs); - let root_loc = mp.root_location(); - - // Create a new working context - let ctx = WorkingContext::new(root_loc.clone()); - - // Verify root and cwd point to the same location initially - assert!(ctx.root().entry().ptr_eq(root_loc.entry())); - assert!(ctx.cwd().entry().ptr_eq(root_loc.entry())); - - TestResult::Ok -} - -#[cfg(feature = "fat")] -#[def_test] -fn test_working_context_clone() -> TestResult { - // Create a test filesystem - let fs = create_test_fs(); - let mp = kvfs::Mountpoint::new_root(&fs); - let root_loc = mp.root_location(); - - // Create a working context and clone it - let ctx1 = WorkingContext::new(root_loc); - let ctx2 = ctx1.clone(); - - // Verify both contexts point to the same root - assert!(ctx1.root().entry().ptr_eq(ctx2.root().entry())); - assert!(ctx1.cwd().entry().ptr_eq(ctx2.cwd().entry())); - - TestResult::Ok -} - -#[cfg(feature = "fat")] -#[def_test] -fn test_working_context_chdir() -> TestResult { - use kvfs::OpenOptions; - - // Create a test filesystem - let fs = create_test_fs(); - let mp = kvfs::Mountpoint::new_root(&fs); - let root_loc = mp.root_location(); - - // Create a subdirectory - let subdir = root_loc - .create("testdir", OpenOptions::dir().create(true)) - .expect("Failed to create directory"); - - // Create working context and change directory - let mut ctx = WorkingContext::new(root_loc.clone()); - ctx.chdir(subdir.clone()).expect("chdir failed"); - - // Verify cwd changed but root stayed the same - assert!(ctx.root().entry().ptr_eq(root_loc.entry())); - assert!(ctx.cwd().entry().ptr_eq(subdir.entry())); - - TestResult::Ok -} - -#[cfg(feature = "fat")] -#[def_test] -fn test_working_context_with_cwd() -> TestResult { - use kvfs::OpenOptions; - - // Create a test filesystem - let fs = create_test_fs(); - let mp = kvfs::Mountpoint::new_root(&fs); - let root_loc = mp.root_location(); - - // Create a subdirectory - let subdir = root_loc - .create("testdir2", OpenOptions::dir().create(true)) - .expect("Failed to create directory"); - - // Create working context and get a new context with different cwd - let ctx1 = WorkingContext::new(root_loc.clone()); - let ctx2 = ctx1.with_cwd(subdir.clone()).expect("with_cwd failed"); - - // Verify ctx1 is unchanged - assert!(ctx1.cwd().entry().ptr_eq(root_loc.entry())); - - // Verify ctx2 has new cwd - assert!(ctx2.cwd().entry().ptr_eq(subdir.entry())); - assert!(ctx2.root().entry().ptr_eq(root_loc.entry())); - - TestResult::Ok -} - #[cfg(not(feature = "fat"))] #[def_test] fn test_working_context_basic() -> TestResult { diff --git a/scripts/make/cargo.mk b/scripts/make/cargo.mk index 1c998fe6..344b48b5 100644 --- a/scripts/make/cargo.mk +++ b/scripts/make/cargo.mk @@ -36,14 +36,6 @@ package_roots := api arch boot core drivers fs io mm net process tee util crate_dirs := $(sort $(foreach root,$(package_roots),$(dir $(wildcard $(CURDIR)/$(root)/*/Cargo.toml)))) all_packages := $(notdir $(patsubst %/,%,$(crate_dirs))) -define cargo_doc - $(call run_cmd,cargo doc,--no-deps --features "$(strip $(KFEAT))" --workspace $(verbose)) - @# run twice to fix broken hyperlinks - $(foreach p,$(all_packages), \ - $(call run_cmd,cargo rustdoc,--features "$(strip $(KFEAT))" -p $(p) $(verbose)) - ) -endef - define unit_test $(call run_cmd,cargo test,-p kfs $(1) $(verbose) -- --nocapture) $(call run_cmd,cargo test,-p kfs $(1) --features "myfs" $(verbose) -- --nocapture) diff --git a/task/ktask/src/snapshot/dump.rs b/task/ktask/src/snapshot/dump.rs index 81f42ab9..b2762bed 100644 --- a/task/ktask/src/snapshot/dump.rs +++ b/task/ktask/src/snapshot/dump.rs @@ -7,15 +7,11 @@ //! All functions in this module are `pub(crate)` — external callers should use //! the high-level interfaces from the parent `snapshot` module. -#[cfg(target_arch = "aarch64")] -use alloc::format; use core::fmt; use kcpu_id_map::LogicalCpuId; use khal::context::TrapFrame; -#[cfg(target_arch = "aarch64")] -use crate::KtaskRef; use crate::TaskInner; #[inline(always)] @@ -28,7 +24,7 @@ pub(crate) fn dump_println(force: bool, args: fmt::Arguments<'_>) { } #[cfg(target_arch = "aarch64")] -pub(crate) fn current_task_for_cpu(cpu_id: LogicalCpuId) -> Option { +pub(crate) fn current_task_for_cpu(cpu_id: LogicalCpuId) -> Option { let mut running = None; crate::global_task_queue::for_each_watchdog_task(cpu_id, |weaktask| { if running.is_some() { @@ -124,7 +120,7 @@ pub(crate) fn dump_cur_task_backtrace( cpu_id.as_usize(), running_task .as_ref() - .map(|task| format!("{:?}", task.inner())) + .map(|task| alloc::format!("{:?}", task.inner())) .unwrap_or_else(|| alloc::string::String::from("")) ), ); diff --git a/xtask/Cargo.toml b/xtask/Cargo.toml index 8f981f10..2ef756f9 100644 --- a/xtask/Cargo.toml +++ b/xtask/Cargo.toml @@ -1,6 +1,6 @@ [workspace] resolver = "2" -members = ["xconfig", "convert_cov", "crate_rootfs", "extract_cov"] +members = ["xconfig", "convert_cov", "crate_rootfs", "extract_cov", "gendoc"] [workspace.package] version = "0.1.0" diff --git a/xtask/gendoc/Cargo.toml b/xtask/gendoc/Cargo.toml new file mode 100644 index 00000000..af9406aa --- /dev/null +++ b/xtask/gendoc/Cargo.toml @@ -0,0 +1,9 @@ +[package] +name = "gendoc" +edition.workspace = true +authors.workspace = true +license.workspace = true + +[dependencies] +clap = { version = "4.5", features = ["derive"] } +toml = "0.8" diff --git a/xtask/gendoc/src/main.rs b/xtask/gendoc/src/main.rs new file mode 100644 index 00000000..ba264216 --- /dev/null +++ b/xtask/gendoc/src/main.rs @@ -0,0 +1,98 @@ +// SPDX-License-Identifier: Apache-2.0 +// Copyright 2026 KylinSoft Co., Ltd. +// See LICENSES for license details. + +use std::{ + error::Error, + path::PathBuf, + process::Command, +}; + +use clap::Parser; + +#[derive(Parser, Debug)] +#[command(author, version, about = "Generate workspace documentation")] +struct Args { + /// Path to the xconfig-generated cargo config. + #[arg(long, default_value = ".cargo/.xconfig.toml")] + config: PathBuf, + + /// Verbose level: -v, -vv. + #[arg(short = 'v', action = clap::ArgAction::Count)] + verbose: u8, + + /// Extra cargo flags (e.g. --open). + #[arg(trailing_var_arg = true, allow_hyphen_values = true)] + extra: Vec, +} + +fn read_features(path: &PathBuf) -> Result, Box> { + let content = std::fs::read_to_string(path)?; + let value: toml::Value = toml::from_str(&content)?; + let features = value["features"] + .as_array() + .ok_or("missing `features` array")? + .iter() + .filter_map(|v| v.as_str().map(String::from)) + .collect(); + Ok(features) +} + +fn main() -> Result<(), Box> { + let args = Args::parse(); + + if !args.config.exists() { + eprintln!( + "Error: {} not found. Run `make build` first to generate it.", + args.config.display() + ); + std::process::exit(1); + } + + let features = read_features(&args.config)?; + let features_str = features.join(","); + + let verbose_flag = match args.verbose { + 0 => "", + 1 => "-v", + _ => "-vv", + }; + + let mut cmd = Command::new("cargo"); + cmd.args(["doc", "--no-deps", "--workspace"]) + .args(["--features", &features_str]); + + if !verbose_flag.is_empty() { + cmd.arg(verbose_flag); + } + + for extra in &args.extra { + cmd.arg(extra); + } + + println!("> {}", format_command(&cmd)); + let status = cmd.status()?; + if !status.success() { + return Err(format!("cargo doc exited with {}", status).into()); + } + + println!("\nGenerated docs. Open target/doc/index.html"); + Ok(()) +} + +fn format_command(cmd: &Command) -> String { + let mut s = String::new(); + for arg in cmd.get_args() { + if !s.is_empty() { + s.push(' '); + } + if arg.to_string_lossy().contains(' ') || arg.to_string_lossy().contains(',') { + s.push('"'); + s.push_str(&arg.to_string_lossy()); + s.push('"'); + } else { + s.push_str(&arg.to_string_lossy()); + } + } + format!("{} {}", cmd.get_program().to_string_lossy(), s) +} -- Gitee From 901438d66fc2fb6b292bcf018147ac0f95d716f2 Mon Sep 17 00:00:00 2001 From: Debin Date: Fri, 29 May 2026 11:29:08 +0800 Subject: [PATCH 4/6] code fmt and clippy --- api/linux_sysno/Cargo.toml | 3 --- boot/kernel-boot/src/arch/aarch64/entry.rs | 2 +- boot/kernel-boot/src/lib.rs | 8 +++++--- core/kruntime/src/mp.rs | 5 +---- core/ksyscall/src/sys.rs | 3 +-- fs/runtime/kfs/src/fs/fat/dir.rs | 6 +++++- fs/runtime/kfs/src/fs/fat/fat_test.rs | 2 +- fs/runtime/kfs/src/fs/fat/util.rs | 6 +++++- xtask/gendoc/src/main.rs | 4 ++++ 9 files changed, 23 insertions(+), 16 deletions(-) diff --git a/api/linux_sysno/Cargo.toml b/api/linux_sysno/Cargo.toml index 2fccefaf..aaeb423c 100644 --- a/api/linux_sysno/Cargo.toml +++ b/api/linux_sysno/Cargo.toml @@ -40,9 +40,6 @@ unittest.workspace = true serde = { version = "1.0", default-features = false, features = ["derive"], optional = true } serde_repr = { version = "0.1", optional = true } -[dev-dependencies] -serde_json = "1" - [package.metadata.docs.rs] all-features = true rustdoc-args = ["--cfg", "doc_cfg"] diff --git a/boot/kernel-boot/src/arch/aarch64/entry.rs b/boot/kernel-boot/src/arch/aarch64/entry.rs index 335d193a..28d45bf0 100644 --- a/boot/kernel-boot/src/arch/aarch64/entry.rs +++ b/boot/kernel-boot/src/arch/aarch64/entry.rs @@ -24,9 +24,9 @@ use core::arch::naked_asm; use boot_info::{BootInfo, BootProtocol, HardwareDescriptionRoot, MemoryDescriptionRoot}; use kaddr_layout::{KIMAGE_VADDR, PAGE_OFFSET}; use kbuild_config::{BOOT_STACK_SIZE, CPU_NUM}; +use kcpu_id_map::{LogicalCpuId, RawCpuId}; use super::{el, mmu, serial}; -use kcpu_id_map::{LogicalCpuId, RawCpuId}; // Linux ARM64 Boot Protocol image flags. const FLAG_LE: usize = 0b0; diff --git a/boot/kernel-boot/src/lib.rs b/boot/kernel-boot/src/lib.rs index 0e4eda15..427447af 100644 --- a/boot/kernel-boot/src/lib.rs +++ b/boot/kernel-boot/src/lib.rs @@ -6,9 +6,8 @@ #![cfg_attr(target_os = "none", no_std)] -pub use linkme::{distributed_slice as def_boot_init, distributed_slice as register_boot_init}; - use kcpu_id_map::LogicalCpuId; +pub use linkme::{distributed_slice as def_boot_init, distributed_slice as register_boot_init}; #[def_boot_init] pub static PRIMARY_KERNEL_ENTRY: [fn(usize) -> !]; @@ -39,7 +38,10 @@ pub mod arch { unreachable!("arch::_start_secondary should never be called on the host target"); } - pub fn set_secondary_boot_stack_top(_cpu_id: kcpu_id_map::LogicalCpuId, _stack_top_paddr: usize) { + pub fn set_secondary_boot_stack_top( + _cpu_id: kcpu_id_map::LogicalCpuId, + _stack_top_paddr: usize, + ) { unreachable!( "arch::set_secondary_boot_stack_top should never be called on the host target" ); diff --git a/core/kruntime/src/mp.rs b/core/kruntime/src/mp.rs index d31707df..d385e528 100644 --- a/core/kruntime/src/mp.rs +++ b/core/kruntime/src/mp.rs @@ -6,11 +6,8 @@ use core::sync::atomic::{AtomicUsize, Ordering}; use kbuild_config::{CPU_NUM, TASK_STACK_SIZE}; -use kernel_boot::{ - SECOND_KERNEL_ENTRY, - register_boot_init, -}; use kcpu_id_map::{LogicalCpuId, for_each_present_logical_cpu}; +use kernel_boot::{SECOND_KERNEL_ENTRY, register_boot_init}; use khal::mem::{VirtAddr, v2p}; #[unsafe(link_section = ".bss.stack")] diff --git a/core/ksyscall/src/sys.rs b/core/ksyscall/src/sys.rs index bd13c39e..3d479d78 100644 --- a/core/ksyscall/src/sys.rs +++ b/core/ksyscall/src/sys.rs @@ -9,12 +9,11 @@ //! - Process information queries //! - Hostname management -use linux_raw_sys::ctypes::c_char; - use kbuild_config::ARCH; use kerrno::KResult; use kthread::{current_process_fs_context, processes}; use linux_raw_sys::{ + ctypes::c_char, general::{GRND_INSECURE, GRND_NONBLOCK, GRND_RANDOM}, system::{new_utsname, sysinfo}, }; diff --git a/fs/runtime/kfs/src/fs/fat/dir.rs b/fs/runtime/kfs/src/fs/fat/dir.rs index aaff18f2..fdb005d5 100644 --- a/fs/runtime/kfs/src/fs/fat/dir.rs +++ b/fs/runtime/kfs/src/fs/fat/dir.rs @@ -145,7 +145,11 @@ impl DirNodeOps for FatDirNode { let mut fs = self.fs.lock(); let dir = self.inner.borrow(&fs); dir.iter() - .find_map(|entry| entry.ok().filter(|it| it.file_name().eq_ignore_ascii_case(name))) + .find_map(|entry| { + entry + .ok() + .filter(|it| it.file_name().eq_ignore_ascii_case(name)) + }) .map(|entry| self.create_entry(entry, name.to_ascii_lowercase(), fs.alloc_inode())) .ok_or(VfsError::NotFound) } diff --git a/fs/runtime/kfs/src/fs/fat/fat_test.rs b/fs/runtime/kfs/src/fs/fat/fat_test.rs index d57bc639..d107aa48 100644 --- a/fs/runtime/kfs/src/fs/fat/fat_test.rs +++ b/fs/runtime/kfs/src/fs/fat/fat_test.rs @@ -113,4 +113,4 @@ fn test_working_context_with_cwd() -> TestResult { assert!(ctx2.root().entry().ptr_eq(root_loc.entry())); TestResult::Ok -} \ No newline at end of file +} diff --git a/fs/runtime/kfs/src/fs/fat/util.rs b/fs/runtime/kfs/src/fs/fat/util.rs index a7cc6387..1bf7bc4d 100644 --- a/fs/runtime/kfs/src/fs/fat/util.rs +++ b/fs/runtime/kfs/src/fs/fat/util.rs @@ -81,7 +81,11 @@ pub fn unix_to_dos(datetime: Duration) -> fatfs::DateTime { ) } -pub fn file_metadata(fs: &FatFilesystemInner, file: &mut ff::File, node_type: NodeType) -> Metadata { +pub fn file_metadata( + fs: &FatFilesystemInner, + file: &mut ff::File, + node_type: NodeType, +) -> Metadata { use fatfs::Seek; let pos = file.seek(fatfs::SeekFrom::Current(0)).unwrap_or(0); let size = file.seek(fatfs::SeekFrom::End(0)).unwrap_or(0); diff --git a/xtask/gendoc/src/main.rs b/xtask/gendoc/src/main.rs index ba264216..4f9712bd 100644 --- a/xtask/gendoc/src/main.rs +++ b/xtask/gendoc/src/main.rs @@ -1,3 +1,7 @@ +// SPDX-License-Identifier: Apache-2.0 +// Copyright 2025 KylinSoft Co., Ltd. +// See LICENSES for license details. + // SPDX-License-Identifier: Apache-2.0 // Copyright 2026 KylinSoft Co., Ltd. // See LICENSES for license details. -- Gitee From 92f84de0ed647ca7e68d3bcd3b2c2022333cf0d8 Mon Sep 17 00:00:00 2001 From: Debin Date: Fri, 29 May 2026 12:16:12 +0800 Subject: [PATCH 5/6] Updated documentation generation support, fixed issues related to CPU ID mapping, and optimized code structure. --- Jenkinsfile | 1 + boot/kernel-boot/src/arch/loongarch64/entry.rs | 8 ++++---- boot/kernel-boot/src/arch/mod.rs | 2 +- boot/kernel-boot/src/arch/riscv64/entry.rs | 8 ++++---- boot/kernel-boot/src/arch/x86_64/handoff.rs | 8 ++++---- task/ktask/src/task.rs | 4 +++- 6 files changed, 17 insertions(+), 14 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 32f30579..8b9047af 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -426,6 +426,7 @@ set -euo pipefail ${stageLogTeeLine(stageName)} cp platforms/${platform}/defconfig .config make clippy +cargo gendoc stdbuf -oL -eL make build """ } diff --git a/boot/kernel-boot/src/arch/loongarch64/entry.rs b/boot/kernel-boot/src/arch/loongarch64/entry.rs index d8017456..30ee5faa 100644 --- a/boot/kernel-boot/src/arch/loongarch64/entry.rs +++ b/boot/kernel-boot/src/arch/loongarch64/entry.rs @@ -7,9 +7,9 @@ use core::arch::naked_asm; use boot_info::{BootInfo, BootProtocol, HardwareDescriptionRoot, MemoryDescriptionRoot}; use kaddr_layout::{KIMAGE_VADDR, PAGE_OFFSET}; use kbuild_config::{BOOT_CONSOLE_ADDR, BOOT_STACK_SIZE, CPU_NUM}; +use kcpu_id_map::RawCpuId; use super::{BOOT_DMW_BASE, BOOT_DMW_UNCACHED_BASE}; -use crate::arch::RawCpuId; const DIRECT_BOOT_LOAD_OFFSET: usize = 0x0020_0000; @@ -144,7 +144,7 @@ pub unsafe extern "C" fn _start_secondary() -> ! { } pub unsafe extern "C" fn __secondary_switched(raw_cpu_id: RawCpuId) -> ! { - let logical_cpu_id = crate::arch::logical_cpu_id(raw_cpu_id).unwrap_or_else(|| { + let logical_cpu_id = kcpu_id_map::logical_cpu_id(raw_cpu_id).unwrap_or_else(|| { panic!( "missing logical cpu id mapping for raw cpu id {:#x}", raw_cpu_id.as_usize() @@ -196,8 +196,8 @@ pub unsafe extern "C" fn __primary_switched( let kernel_load_paddr = KIMAGE_VADDR - kimage_voffset; let cmdline_len = cmdline_len(cmdline_paddr); let (dtb_paddr, rsdp_paddr) = unsafe { super::mmu::boot_firmware_tables() }; - crate::arch::init_boot_cpu_id_map(dtb_paddr); - let logical_cpu_id = crate::arch::logical_cpu_id(raw_cpu_id).unwrap_or_else(|| { + kcpu_id_map::init_boot_cpu_id_map(dtb_paddr); + let logical_cpu_id = kcpu_id_map::logical_cpu_id(raw_cpu_id).unwrap_or_else(|| { panic!( "missing logical cpu id mapping for raw cpu id {:#x}", raw_cpu_id.as_usize() diff --git a/boot/kernel-boot/src/arch/mod.rs b/boot/kernel-boot/src/arch/mod.rs index e1f83827..f3a6eba1 100644 --- a/boot/kernel-boot/src/arch/mod.rs +++ b/boot/kernel-boot/src/arch/mod.rs @@ -28,4 +28,4 @@ pub use self::loongarch64::*; // `kernel_boot::arch::set_secondary_boot_stack_top()` without `cfg`. #[cfg(not(target_arch = "aarch64"))] /// No-op on architectures that do not use a boot-time secondary stack table. -pub fn set_secondary_boot_stack_top(_cpu_id: LogicalCpuId, _stack_top_paddr: usize) {} +pub fn set_secondary_boot_stack_top(_cpu_id: kcpu_id_map::LogicalCpuId, _stack_top_paddr: usize) {} diff --git a/boot/kernel-boot/src/arch/riscv64/entry.rs b/boot/kernel-boot/src/arch/riscv64/entry.rs index af237d9c..db2f6fd3 100644 --- a/boot/kernel-boot/src/arch/riscv64/entry.rs +++ b/boot/kernel-boot/src/arch/riscv64/entry.rs @@ -9,11 +9,11 @@ use core::arch::naked_asm; use boot_info::{BootInfo, BootProtocol, HardwareDescriptionRoot, MemoryDescriptionRoot}; use kaddr_layout::{KIMAGE_VADDR, PAGE_OFFSET}; use kbuild_config::{BOOT_STACK_SIZE, CPU_NUM}; +use kcpu_id_map::RawCpuId; #[cfg(feature = "fp-simd")] use riscv::register::sstatus::{self, FS}; use super::mmu; -use crate::arch::RawCpuId; /// Boot stack for the primary CPU. #[unsafe(link_section = ".bss.stack")] @@ -104,7 +104,7 @@ pub unsafe extern "C" fn _start_secondary() -> ! { } pub unsafe extern "C" fn __secondary_switched(raw_cpu_id: RawCpuId) -> ! { - let logical_cpu_id = crate::arch::logical_cpu_id(raw_cpu_id).unwrap_or_else(|| { + let logical_cpu_id = kcpu_id_map::logical_cpu_id(raw_cpu_id).unwrap_or_else(|| { panic!( "missing logical cpu id mapping for raw cpu id {:#x}", raw_cpu_id.as_usize() @@ -134,8 +134,8 @@ pub unsafe extern "C" fn __primary_switched( } kaddr_layout::set_kimage_voffset(kimage_voffset); - crate::arch::init_boot_cpu_id_map(dtb_paddr); - let logical_cpu_id = crate::arch::logical_cpu_id(raw_cpu_id).unwrap_or_else(|| { + kcpu_id_map::init_boot_cpu_id_map(dtb_paddr); + let logical_cpu_id = kcpu_id_map::logical_cpu_id(raw_cpu_id).unwrap_or_else(|| { panic!( "missing logical cpu id mapping for raw cpu id {:#x}", raw_cpu_id.as_usize() diff --git a/boot/kernel-boot/src/arch/x86_64/handoff.rs b/boot/kernel-boot/src/arch/x86_64/handoff.rs index 4414acb9..c05cac9a 100644 --- a/boot/kernel-boot/src/arch/x86_64/handoff.rs +++ b/boot/kernel-boot/src/arch/x86_64/handoff.rs @@ -13,9 +13,9 @@ use boot_info::{ BOOT_INFO_MAGIC, BootInfo, BootProtocol, HardwareDescriptionRoot, MemoryDescriptionRoot, }; use kaddr_layout::{KIMAGE_VADDR, PAGE_OFFSET}; +use kcpu_id_map::RawCpuId; use super::protocols::{MULTIBOOT_BOOTLOADER_MAGIC, SEV_CBIT_MASK}; -use crate::arch::RawCpuId; static mut X86_BOOT_INFO: BootInfo = BootInfo::new(BootProtocol::Unknown); @@ -106,7 +106,7 @@ pub(super) unsafe extern "C" fn rust_entry(magic: usize, mbi: usize, handoff_arg let kimage_voffset = handoff_arg; kaddr_layout::set_kimage_voffset(kimage_voffset); unsafe { init_ap_boot_state() }; - let logical_cpu_id = crate::arch::logical_cpu_id(get_cpu_id()) + let logical_cpu_id = kcpu_id_map::logical_cpu_id(get_cpu_id()) .unwrap_or_else(|| panic!("missing logical cpu id mapping for boot cpu")); let kernel_load_paddr = KIMAGE_VADDR - kimage_voffset; unsafe { @@ -126,7 +126,7 @@ pub(super) unsafe extern "C" fn rust_entry(magic: usize, mbi: usize, handoff_arg let boot_info = unsafe { &*(mbi as *const BootInfo) }; assert!(boot_info.is_valid(), "invalid boot info"); kaddr_layout::set_kimage_voffset(KIMAGE_VADDR - boot_info.kernel_load_paddr); - crate::arch::init_boot_cpu_id_map(boot_info.rsdp_addr); + kcpu_id_map::init_boot_cpu_id_map(boot_info.rsdp_addr); unsafe { init_ap_boot_state() }; call_kernel_entry!(PRIMARY_KERNEL_ENTRY, mbi) } @@ -139,7 +139,7 @@ pub(super) unsafe extern "C" fn rust_entry(magic: usize, mbi: usize, handoff_arg pub(super) unsafe extern "C" fn rust_entry_secondary(magic: usize) { if magic == MULTIBOOT_BOOTLOADER_MAGIC { let raw_cpu_id = get_cpu_id(); - let logical_cpu_id = crate::arch::logical_cpu_id(raw_cpu_id).unwrap_or_else(|| { + let logical_cpu_id = kcpu_id_map::logical_cpu_id(raw_cpu_id).unwrap_or_else(|| { panic!( "missing logical cpu id mapping for raw cpu id {}", raw_cpu_id.as_usize() diff --git a/task/ktask/src/task.rs b/task/ktask/src/task.rs index 5e2bc7a4..145633a5 100644 --- a/task/ktask/src/task.rs +++ b/task/ktask/src/task.rs @@ -20,7 +20,9 @@ use core::{ }; use futures_util::task::AtomicWaker; -use kcpu_id_map::{KCpuMaskExt, LogicalCpuId}; +#[cfg(feature = "smp")] +use kcpu_id_map::KCpuMaskExt; +use kcpu_id_map::LogicalCpuId; use khal::context::TaskContext; #[cfg(feature = "tls")] use khal::tls::TlsArea; -- Gitee From 6dcecfef7ca916e8a96d5e25a3f73598bac6d6a1 Mon Sep 17 00:00:00 2001 From: Debin Date: Fri, 29 May 2026 13:14:50 +0800 Subject: [PATCH 6/6] Remove the cargo gendoc command from the Jenkinsfile --- Jenkinsfile | 1 - 1 file changed, 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 8b9047af..32f30579 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -426,7 +426,6 @@ set -euo pipefail ${stageLogTeeLine(stageName)} cp platforms/${platform}/defconfig .config make clippy -cargo gendoc stdbuf -oL -eL make build """ } -- Gitee