From 55aa3fc0ab32a67d2253a080309815906f96d887 Mon Sep 17 00:00:00 2001 From: yufeng <321353225@qq.com> Date: Tue, 16 Apr 2024 23:45:40 +0800 Subject: [PATCH] fix: optimize dep source code --- drivers/general-plic/src/lib.rs | 5 ++++- drivers/k210-sdcard/src/lib.rs | 3 ++- drivers/kcvitek-sd/src/lib.rs | 3 ++- drivers/kgoldfish-rtc/src/lib.rs | 5 ++++- drivers/knvme/src/lib.rs | 3 ++- drivers/kvirtio/src/lib.rs | 5 ++++- drivers/kvirtio/src/virtio_impl.rs | 2 +- drivers/ns16550a/src/lib.rs | 5 ++++- kernel/src/syscall/task.rs | 34 ++++++++++++++++++------------ modules/devices/src/lib.rs | 2 +- modules/executor/src/task.rs | 4 ++-- 11 files changed, 46 insertions(+), 25 deletions(-) diff --git a/drivers/general-plic/src/lib.rs b/drivers/general-plic/src/lib.rs index 156732b..96f31dd 100644 --- a/drivers/general-plic/src/lib.rs +++ b/drivers/general-plic/src/lib.rs @@ -7,7 +7,10 @@ mod plic; use alloc::sync::Arc; use devices::{ - device::{DeviceType, Driver, IntDriver}, driver_define, fdt::node::FdtNode, VIRT_ADDR_START + device::{DeviceType, Driver, IntDriver}, + driver_define, + fdt::node::FdtNode, + VIRT_ADDR_START, }; pub struct PLIC { diff --git a/drivers/k210-sdcard/src/lib.rs b/drivers/k210-sdcard/src/lib.rs index 1579b7d..0303e51 100644 --- a/drivers/k210-sdcard/src/lib.rs +++ b/drivers/k210-sdcard/src/lib.rs @@ -10,7 +10,8 @@ extern crate alloc; use alloc::sync::Arc; use core::{cell::RefCell, convert::TryInto}; use devices::{ - device::{BlkDriver, DeviceType, Driver}, driver_define, Mutex, DRIVERS_INIT + device::{BlkDriver, DeviceType, Driver}, + driver_define, Mutex, DRIVERS_INIT, }; use k210_hal::prelude::*; use k210_pac::{Peripherals, SPI0}; diff --git a/drivers/kcvitek-sd/src/lib.rs b/drivers/kcvitek-sd/src/lib.rs index 8b861f0..d34f655 100644 --- a/drivers/kcvitek-sd/src/lib.rs +++ b/drivers/kcvitek-sd/src/lib.rs @@ -10,7 +10,8 @@ use alloc::sync::Arc; use cv1811_sd::clk_en; use devices::{ device::{BlkDriver, DeviceType, Driver}, - driver_define, fdt::node::FdtNode, + driver_define, + fdt::node::FdtNode, }; pub struct CvSd; diff --git a/drivers/kgoldfish-rtc/src/lib.rs b/drivers/kgoldfish-rtc/src/lib.rs index c5b0fb7..37b405f 100644 --- a/drivers/kgoldfish-rtc/src/lib.rs +++ b/drivers/kgoldfish-rtc/src/lib.rs @@ -9,7 +9,10 @@ extern crate log; use alloc::sync::Arc; use core::ptr::read_volatile; use devices::{ - device::{DeviceType, Driver, RtcDriver}, driver_define, fdt::node::FdtNode, VIRT_ADDR_START + device::{DeviceType, Driver, RtcDriver}, + driver_define, + fdt::node::FdtNode, + VIRT_ADDR_START, }; use timestamp::DateTime; diff --git a/drivers/knvme/src/lib.rs b/drivers/knvme/src/lib.rs index 60d9743..e57efad 100644 --- a/drivers/knvme/src/lib.rs +++ b/drivers/knvme/src/lib.rs @@ -9,7 +9,8 @@ extern crate log; use alloc::{sync::Arc, vec::Vec}; use devices::{ - device::{BlkDriver, DeviceType, Driver}, driver_define, frame_alloc_much, FrameTracker, Mutex, PAGE_SIZE, VIRT_ADDR_START + device::{BlkDriver, DeviceType, Driver}, + driver_define, frame_alloc_much, FrameTracker, Mutex, PAGE_SIZE, VIRT_ADDR_START, }; use nvme_driver::{DmaAllocator, IrqController, NvmeInterface}; diff --git a/drivers/kvirtio/src/lib.rs b/drivers/kvirtio/src/lib.rs index 731ac2e..2e2fe5b 100644 --- a/drivers/kvirtio/src/lib.rs +++ b/drivers/kvirtio/src/lib.rs @@ -14,7 +14,10 @@ use core::ptr::NonNull; use alloc::{sync::Arc, vec::Vec}; use devices::{ - device::{Driver, UnsupportedDriver}, driver_define, fdt::node::FdtNode, node_to_interrupts, VIRT_ADDR_START + device::{Driver, UnsupportedDriver}, + driver_define, + fdt::node::FdtNode, + node_to_interrupts, VIRT_ADDR_START, }; use virtio_drivers::transport::{ mmio::{MmioTransport, VirtIOHeader}, diff --git a/drivers/kvirtio/src/virtio_impl.rs b/drivers/kvirtio/src/virtio_impl.rs index dbf4537..59d2fa1 100644 --- a/drivers/kvirtio/src/virtio_impl.rs +++ b/drivers/kvirtio/src/virtio_impl.rs @@ -1,6 +1,6 @@ use alloc::vec::Vec; -use devices::{frame_alloc_much, FrameTracker, Mutex, VIRT_ADDR_START}; use core::ptr::NonNull; +use devices::{frame_alloc_much, FrameTracker, Mutex, VIRT_ADDR_START}; use log::trace; use virtio_drivers::{BufferDirection, Hal, PhysAddr}; diff --git a/drivers/ns16550a/src/lib.rs b/drivers/ns16550a/src/lib.rs index 7f93c17..f94dde9 100644 --- a/drivers/ns16550a/src/lib.rs +++ b/drivers/ns16550a/src/lib.rs @@ -5,7 +5,10 @@ extern crate alloc; use alloc::{sync::Arc, vec::Vec}; use devices::{ - device::{DeviceType, Driver, UartDriver}, driver_define, fdt::node::FdtNode, node_to_interrupts, register_device_irqs, VIRT_ADDR_START + device::{DeviceType, Driver, UartDriver}, + driver_define, + fdt::node::FdtNode, + node_to_interrupts, register_device_irqs, VIRT_ADDR_START, }; use log::info; use ns16550a::{ diff --git a/kernel/src/syscall/task.rs b/kernel/src/syscall/task.rs index 83ace87..0299bc0 100644 --- a/kernel/src/syscall/task.rs +++ b/kernel/src/syscall/task.rs @@ -1,17 +1,23 @@ -use crate::syscall::consts::{from_vfs, CloneFlags, Rusage}; -use crate::syscall::time::WaitUntilsec; -use crate::tasks::elf::{init_task_stack, ElfExtra}; -use crate::tasks::{futex_requeue, futex_wake, WaitFutex, WaitPid}; -use crate::user::entry::user_entry; -use crate::user::UserTaskContainer; -use alloc::string::{String, ToString}; -use alloc::sync::Weak; -use alloc::vec::Vec; -use alloc::{boxed::Box, sync::Arc}; -use arch::addr::VirtPage; -use arch::pagetable::MappingFlags; -use arch::time::Time; -use arch::{TrapFrameArgs, PAGE_SIZE}; +use crate::{ + syscall::consts::{from_vfs, CloneFlags, Rusage}, + syscall::time::WaitUntilsec, + tasks::elf::{init_task_stack, ElfExtra}, + tasks::{futex_requeue, futex_wake, WaitFutex, WaitPid}, + user::entry::user_entry, + user::UserTaskContainer, +}; +use alloc::{ + string::{String, ToString}, + sync::Weak, + vec::Vec, + {boxed::Box, sync::Arc}, +}; +use arch::{ + addr::VirtPage, + pagetable::MappingFlags, + time::Time, + {TrapFrameArgs, PAGE_SIZE}, +}; use async_recursion::async_recursion; use core::cmp; use executor::{ diff --git a/modules/devices/src/lib.rs b/modules/devices/src/lib.rs index aa97cae..9cb2965 100644 --- a/modules/devices/src/lib.rs +++ b/modules/devices/src/lib.rs @@ -13,7 +13,7 @@ pub mod device; pub use arch::{PAGE_SIZE, VIRT_ADDR_START}; pub use fdt; -pub use frame_allocator::{frame_alloc, FrameTracker, frame_alloc_much}; +pub use frame_allocator::{frame_alloc, frame_alloc_much, FrameTracker}; pub use linkme::{self, distributed_slice as linker_use}; pub use sync::{LazyInit, Mutex, MutexGuard}; // pub mod virtio; diff --git a/modules/executor/src/task.rs b/modules/executor/src/task.rs index e4d8daa..835ebc3 100644 --- a/modules/executor/src/task.rs +++ b/modules/executor/src/task.rs @@ -9,12 +9,12 @@ use alloc::{ use arch::{ addr::{PhysPage, VirtAddr, VirtPage}, pagetable::{MappingFlags, MappingSize, PageTableWrapper}, - {TrapFrame, TrapFrameArgs, PAGE_SIZE} + {TrapFrame, TrapFrameArgs, PAGE_SIZE}, }; use frame_allocator::{ceil_div, frame_alloc_much, FrameTracker}; use fs::File; use log::{debug, warn}; -use signal::{REAL_TIME_SIGNAL_NUM, SigAction, SigProcMask, SignalFlags}; +use signal::{SigAction, SigProcMask, SignalFlags, REAL_TIME_SIGNAL_NUM}; use sync::{Mutex, MutexGuard, RwLock}; use vfscore::OpenFlags;