From a6cd153fca83ed6f6b535e5ba4e4f7ebef9088dd Mon Sep 17 00:00:00 2001 From: equation314 Date: Sat, 4 Apr 2020 17:48:45 +0800 Subject: [PATCH] Remove unused import --- kernel/src/arch/mipsel/board/malta/mod.rs | 1 - kernel/src/arch/mipsel/interrupt.rs | 10 ++++----- kernel/src/arch/mipsel/memory.rs | 4 +--- kernel/src/arch/mipsel/mod.rs | 1 - kernel/src/arch/riscv/interrupt.rs | 2 +- kernel/src/arch/riscv/memory.rs | 7 +++--- kernel/src/arch/riscv/mod.rs | 3 +-- kernel/src/arch/riscv/paging.rs | 8 ++----- kernel/src/arch/x86_64/board/mod.rs | 4 +--- kernel/src/arch/x86_64/interrupt/handler.rs | 2 +- kernel/src/backtrace.rs | 2 +- kernel/src/drivers/block/virtio_blk.rs | 2 -- kernel/src/drivers/bus/virtio_mmio.rs | 2 +- kernel/src/drivers/gpu/fb.rs | 1 - kernel/src/drivers/gpu/virtio_gpu.rs | 1 - kernel/src/drivers/net/virtio_net.rs | 2 -- kernel/src/fs/device.rs | 1 + kernel/src/fs/epoll.rs | 7 ++---- kernel/src/fs/file_like.rs | 2 -- kernel/src/fs/mod.rs | 5 ++--- kernel/src/fs/pipe.rs | 2 +- kernel/src/fs/pseudo.rs | 2 +- kernel/src/fs/random.rs | 3 +-- kernel/src/fs/stdio.rs | 3 +-- kernel/src/fs/vga.rs | 2 -- kernel/src/ipc/semary.rs | 3 +-- kernel/src/lkm/api.rs | 4 +--- kernel/src/lkm/kernelvm.rs | 6 +----- kernel/src/lkm/manager.rs | 24 ++++++--------------- kernel/src/sync/condvar.rs | 2 +- kernel/src/syscall/custom.rs | 5 +++-- kernel/src/syscall/fs.rs | 7 +----- kernel/src/syscall/ipc.rs | 5 ----- kernel/src/syscall/lkm.rs | 3 --- 34 files changed, 40 insertions(+), 98 deletions(-) diff --git a/kernel/src/arch/mipsel/board/malta/mod.rs b/kernel/src/arch/mipsel/board/malta/mod.rs index 94ca1bb5..bb929912 100644 --- a/kernel/src/arch/mipsel/board/malta/mod.rs +++ b/kernel/src/arch/mipsel/board/malta/mod.rs @@ -1,6 +1,5 @@ use crate::drivers::bus::pci; use crate::drivers::gpu::fb::{self, FramebufferInfo}; -use alloc::string::String; use mips::registers::cp0; pub mod consts; diff --git a/kernel/src/arch/mipsel/interrupt.rs b/kernel/src/arch/mipsel/interrupt.rs index 578a16dd..52ea2b68 100644 --- a/kernel/src/arch/mipsel/interrupt.rs +++ b/kernel/src/arch/mipsel/interrupt.rs @@ -1,12 +1,10 @@ pub use self::context::*; use crate::arch::paging::get_root_page_table_ptr; -use crate::drivers::{DRIVERS, IRQ_MANAGER}; +use crate::drivers::IRQ_MANAGER; use log::*; use mips::addr::*; use mips::interrupts; -use mips::paging::{ - PageTable as MIPSPageTable, PageTableEntry, PageTableFlags as EF, TwoLevelPageTable, -}; +use mips::paging::PageTable as MIPSPageTable; use mips::registers::cp0; use mips::tlb; @@ -154,7 +152,7 @@ fn syscall(tf: &mut TrapFrame) { ); // temporary solution for ThinPad - if (tf.v0 == 0) { + if tf.v0 == 0 { warn!("Syscall ID = 0"); tf.v0 = unsafe { *((tf.sp + 28) as *const usize) }; } @@ -162,7 +160,7 @@ fn syscall(tf: &mut TrapFrame) { let ret = crate::syscall::syscall(tf.v0, arguments, tf) as isize; // comply with mips n32 abi, always return a positive value // https://git.musl-libc.org/cgit/musl/tree/arch/mipsn32/syscall_arch.h - if (ret < 0) { + if ret < 0 { tf.v0 = (-ret) as usize; tf.a3 = 1; } else { diff --git a/kernel/src/arch/mipsel/memory.rs b/kernel/src/arch/mipsel/memory.rs index 43c99f0d..c859756c 100644 --- a/kernel/src/arch/mipsel/memory.rs +++ b/kernel/src/arch/mipsel/memory.rs @@ -1,8 +1,6 @@ use crate::arch::paging::*; use crate::consts::{KERNEL_OFFSET, MEMORY_END, MEMORY_OFFSET}; -use crate::memory::{init_heap, Linear, MemoryAttr, MemorySet, FRAME_ALLOCATOR}; -use core::mem; -use log::*; +use crate::memory::{init_heap, FRAME_ALLOCATOR}; use rcore_memory::PAGE_SIZE; /// Initialize the memory management module diff --git a/kernel/src/arch/mipsel/mod.rs b/kernel/src/arch/mipsel/mod.rs index 027823c1..3d368434 100644 --- a/kernel/src/arch/mipsel/mod.rs +++ b/kernel/src/arch/mipsel/mod.rs @@ -9,7 +9,6 @@ pub mod rand; pub mod syscall; pub mod timer; -use log::*; use mips::registers::cp0; #[cfg(feature = "board_malta")] diff --git a/kernel/src/arch/riscv/interrupt.rs b/kernel/src/arch/riscv/interrupt.rs index 8a342b91..f16ece3b 100644 --- a/kernel/src/arch/riscv/interrupt.rs +++ b/kernel/src/arch/riscv/interrupt.rs @@ -1,5 +1,5 @@ pub use self::context::*; -use crate::drivers::{DRIVERS, IRQ_MANAGER}; +use crate::drivers::IRQ_MANAGER; use log::*; use riscv::register::*; diff --git a/kernel/src/arch/riscv/memory.rs b/kernel/src/arch/riscv/memory.rs index 6ea6a7e0..31b75f51 100644 --- a/kernel/src/arch/riscv/memory.rs +++ b/kernel/src/arch/riscv/memory.rs @@ -1,10 +1,9 @@ -use crate::consts::{KERNEL_OFFSET, MEMORY_END, MEMORY_OFFSET, PHYSICAL_MEMORY_OFFSET}; -use crate::memory::{init_heap, Linear, MemoryAttr, MemorySet, FRAME_ALLOCATOR}; +use crate::consts::{KERNEL_OFFSET, MEMORY_END, MEMORY_OFFSET}; +use crate::memory::{init_heap, MemorySet, FRAME_ALLOCATOR}; use core::mem; use log::*; use rcore_memory::PAGE_SIZE; -use riscv::register::satp; -use riscv::{addr::*, register::sstatus}; +use riscv::register::sstatus; /// Initialize the memory management module pub fn init(dtb: usize) { diff --git a/kernel/src/arch/riscv/mod.rs b/kernel/src/arch/riscv/mod.rs index 33bf2280..8fc712d0 100644 --- a/kernel/src/arch/riscv/mod.rs +++ b/kernel/src/arch/riscv/mod.rs @@ -22,7 +22,6 @@ pub mod timer; use crate::memory::phys_to_virt; use core::sync::atomic::{AtomicBool, Ordering}; -use log::*; #[no_mangle] pub extern "C" fn rust_main(hartid: usize, device_tree_paddr: usize) -> ! { @@ -88,7 +87,7 @@ const BOOT_HART_ID: usize = 0; #[cfg(feature = "board_u540")] const BOOT_HART_ID: usize = 1; -/// Constant & Macro for `trap.asm` +// Constant & Macro for `trap.asm` #[cfg(target_arch = "riscv32")] global_asm!( r" diff --git a/kernel/src/arch/riscv/paging.rs b/kernel/src/arch/riscv/paging.rs index 57a8cfc1..2591e2dc 100644 --- a/kernel/src/arch/riscv/paging.rs +++ b/kernel/src/arch/riscv/paging.rs @@ -6,11 +6,7 @@ use rcore_memory::paging::*; use riscv::addr::*; use riscv::asm::{sfence_vma, sfence_vma_all}; use riscv::paging::{FrameAllocator, FrameDeallocator}; -use riscv::paging::{ - Mapper, PageTable as RvPageTable, PageTableEntry, PageTableFlags as EF, PageTableType, - RecursivePageTable, -}; -use riscv::register::satp; +use riscv::paging::{Mapper, PageTable as RvPageTable, PageTableEntry, PageTableFlags as EF}; #[cfg(target_arch = "riscv32")] type TopLevelPageTable<'a> = riscv::paging::Rv32PageTable<'a>; @@ -199,7 +195,7 @@ impl PageTableExt for PageTableImpl { } #[cfg(target_arch = "riscv64")] for i in 509..512 { - if (i == 510) { + if i == 510 { // MMIO range 0x60000000 - 0x7FFFFFFF does not work as a large page, dunno why continue; } diff --git a/kernel/src/arch/x86_64/board/mod.rs b/kernel/src/arch/x86_64/board/mod.rs index 8699975c..4b29dbd5 100755 --- a/kernel/src/arch/x86_64/board/mod.rs +++ b/kernel/src/arch/x86_64/board/mod.rs @@ -1,7 +1,5 @@ -use crate::consts::KERNEL_OFFSET; use crate::drivers::gpu::fb::{self, ColorDepth, ColorFormat, FramebufferInfo}; use crate::memory::phys_to_virt; -use core::mem::zeroed; use rboot::BootInfo; pub fn init_driver(boot_info: &BootInfo) { @@ -17,7 +15,7 @@ pub fn init_driver(boot_info: &BootInfo) { xoffset: 0, yoffset: 0, depth: ColorDepth::ColorDepth32, - format: fb::ColorFormat::RGBA8888, + format: ColorFormat::RGBA8888, paddr: info.fb_addr as usize, vaddr: phys_to_virt(info.fb_addr as usize), screen_size: info.fb_size as usize, diff --git a/kernel/src/arch/x86_64/interrupt/handler.rs b/kernel/src/arch/x86_64/interrupt/handler.rs index b71b766d..53539e1e 100644 --- a/kernel/src/arch/x86_64/interrupt/handler.rs +++ b/kernel/src/arch/x86_64/interrupt/handler.rs @@ -66,7 +66,7 @@ use super::consts::*; use super::TrapFrame; -use crate::drivers::{DRIVERS, IRQ_MANAGER}; +use crate::drivers::IRQ_MANAGER; use bitflags::*; use log::*; diff --git a/kernel/src/backtrace.rs b/kernel/src/backtrace.rs index 223e99be..6a41652e 100644 --- a/kernel/src/backtrace.rs +++ b/kernel/src/backtrace.rs @@ -1,5 +1,4 @@ use core::mem::size_of; -use rcore_memory::PAGE_SIZE; extern "C" { fn stext(); @@ -165,6 +164,7 @@ pub fn backtrace() { // Kernel stack at 0x0000_57ac_0000_0000 (defined in bootloader crate) // size = 512 pages current_fp = *(current_fp as *const usize).offset(0); + use rcore_memory::PAGE_SIZE; if current_fp >= 0x0000_57ac_0000_0000 + 512 * PAGE_SIZE - size_of::() && current_fp <= 0xffff_ff00_0000_0000 { diff --git a/kernel/src/drivers/block/virtio_blk.rs b/kernel/src/drivers/block/virtio_blk.rs index e38d49c0..ca99b816 100644 --- a/kernel/src/drivers/block/virtio_blk.rs +++ b/kernel/src/drivers/block/virtio_blk.rs @@ -1,11 +1,9 @@ use alloc::string::String; use alloc::sync::Arc; -use log::*; use virtio_drivers::{VirtIOBlk, VirtIOHeader}; use super::super::{DeviceType, Driver, BLK_DRIVERS, DRIVERS, IRQ_MANAGER}; -use crate::memory::phys_to_virt; use crate::sync::SpinNoIrqLock as Mutex; struct VirtIOBlkDriver(Mutex>); diff --git a/kernel/src/drivers/bus/virtio_mmio.rs b/kernel/src/drivers/bus/virtio_mmio.rs index 4d8331dd..61c8fd3d 100644 --- a/kernel/src/drivers/bus/virtio_mmio.rs +++ b/kernel/src/drivers/bus/virtio_mmio.rs @@ -8,7 +8,7 @@ use super::super::block::virtio_blk; use super::super::gpu::virtio_gpu; use super::super::input::virtio_input; use super::super::net::virtio_net; -use crate::memory::{phys_to_virt, virt_to_phys}; +use crate::memory::phys_to_virt; pub fn virtio_probe(node: &Node) { let reg = match node.prop_raw("reg") { diff --git a/kernel/src/drivers/gpu/fb.rs b/kernel/src/drivers/gpu/fb.rs index a3745f23..e9b43472 100644 --- a/kernel/src/drivers/gpu/fb.rs +++ b/kernel/src/drivers/gpu/fb.rs @@ -2,7 +2,6 @@ use alloc::string::String; use core::fmt; -use lazy_static::lazy_static; use log::*; use spin::Mutex; diff --git a/kernel/src/drivers/gpu/virtio_gpu.rs b/kernel/src/drivers/gpu/virtio_gpu.rs index a17e2b3f..e9d2bbf2 100644 --- a/kernel/src/drivers/gpu/virtio_gpu.rs +++ b/kernel/src/drivers/gpu/virtio_gpu.rs @@ -1,7 +1,6 @@ use alloc::string::String; use alloc::sync::Arc; -use log::*; use virtio_drivers::{VirtIOGpu, VirtIOHeader}; use super::super::{DeviceType, Driver, DRIVERS, IRQ_MANAGER}; diff --git a/kernel/src/drivers/net/virtio_net.rs b/kernel/src/drivers/net/virtio_net.rs index 957f8dd0..a5a4c12b 100644 --- a/kernel/src/drivers/net/virtio_net.rs +++ b/kernel/src/drivers/net/virtio_net.rs @@ -2,7 +2,6 @@ use alloc::format; use alloc::string::String; use alloc::sync::Arc; -use log::*; use smoltcp::phy::{self, DeviceCapabilities}; use smoltcp::time::Instant; use smoltcp::wire::{EthernetAddress, Ipv4Address}; @@ -10,7 +9,6 @@ use smoltcp::Result; use virtio_drivers::{VirtIOHeader, VirtIONet}; use super::super::{DeviceType, Driver, DRIVERS, IRQ_MANAGER, NET_DRIVERS}; -use crate::memory::phys_to_virt; use crate::sync::SpinNoIrqLock as Mutex; #[derive(Clone)] diff --git a/kernel/src/fs/device.rs b/kernel/src/fs/device.rs index 10f36213..b067e63b 100644 --- a/kernel/src/fs/device.rs +++ b/kernel/src/fs/device.rs @@ -8,6 +8,7 @@ use crate::arch::driver::ide; #[cfg(target_arch = "aarch64")] use crate::arch::board::emmc; +#[cfg(target_arch = "aarch64")] use crate::sync::SpinNoIrqLock as Mutex; pub struct MemBuf(RwLock<&'static mut [u8]>); diff --git a/kernel/src/fs/epoll.rs b/kernel/src/fs/epoll.rs index 65380ab2..94389b89 100644 --- a/kernel/src/fs/epoll.rs +++ b/kernel/src/fs/epoll.rs @@ -1,11 +1,8 @@ use crate::fs::FileLike; -use crate::memory::MemorySet; use crate::process::Process; -use crate::sync::{Condvar, SpinNoIrqLock}; +use crate::sync::SpinNoIrqLock; use crate::syscall::{SysError, SysResult}; use alloc::{collections::BTreeMap, collections::BTreeSet}; -use core::mem::size_of; -use core::slice; pub struct EpollInstance { pub events: BTreeMap, @@ -29,7 +26,7 @@ impl EpollInstance { } pub fn control(&mut self, op: usize, fd: usize, event: &EpollEvent) -> SysResult { - match (op as i32) { + match op as i32 { EPollCtlOp::ADD => { self.events.insert(fd, event.clone()); self.newCtlList.lock().insert(fd); diff --git a/kernel/src/fs/file_like.rs b/kernel/src/fs/file_like.rs index e180f4dc..1e83c725 100644 --- a/kernel/src/fs/file_like.rs +++ b/kernel/src/fs/file_like.rs @@ -4,10 +4,8 @@ use super::ioctl::*; use super::FileHandle; use crate::fs::epoll::EpollInstance; use crate::net::Socket; -use crate::sync::Condvar; use crate::syscall::{SysError, SysResult}; use alloc::boxed::Box; -use alloc::vec::Vec; use rcore_fs::vfs::PollStatus; // TODO: merge FileLike to FileHandle ? diff --git a/kernel/src/fs/mod.rs b/kernel/src/fs/mod.rs index 75e812b9..4fed389e 100644 --- a/kernel/src/fs/mod.rs +++ b/kernel/src/fs/mod.rs @@ -1,14 +1,11 @@ use alloc::{sync::Arc, vec::Vec}; -use rcore_fs::dev::block_cache::BlockCache; use rcore_fs::vfs::*; use rcore_fs_devfs::{special::*, DevFS}; use rcore_fs_mountfs::MountFS; use rcore_fs_ramfs::RamFS; use rcore_fs_sfs::SimpleFileSystem; -use crate::drivers::BlockDriver; - pub use self::file::*; pub use self::file_like::*; pub use self::pipe::Pipe; @@ -50,6 +47,8 @@ lazy_static! { let device = { #[cfg(any(target_arch = "riscv32", target_arch = "riscv64", target_arch = "x86_64"))] { + use crate::drivers::BlockDriver; + use rcore_fs::dev::block_cache::BlockCache; let driver = BlockDriver( crate::drivers::BLK_DRIVERS .read().iter() diff --git a/kernel/src/fs/pipe.rs b/kernel/src/fs/pipe.rs index 1019c4c9..c56fd65f 100644 --- a/kernel/src/fs/pipe.rs +++ b/kernel/src/fs/pipe.rs @@ -1,6 +1,6 @@ //! Implement INode for Pipe -use alloc::{collections::vec_deque::VecDeque, string::String, sync::Arc}; +use alloc::{collections::vec_deque::VecDeque, sync::Arc}; use core::any::Any; use rcore_fs::vfs::*; diff --git a/kernel/src/fs/pseudo.rs b/kernel/src/fs/pseudo.rs index 5f01a954..44b8c6d6 100644 --- a/kernel/src/fs/pseudo.rs +++ b/kernel/src/fs/pseudo.rs @@ -1,6 +1,6 @@ //! Pseudo file system INode -use alloc::{string::String, sync::Arc, vec::Vec}; +use alloc::vec::Vec; use core::any::Any; use rcore_fs::vfs::*; diff --git a/kernel/src/fs/random.rs b/kernel/src/fs/random.rs index 065b7931..13c2345c 100644 --- a/kernel/src/fs/random.rs +++ b/kernel/src/fs/random.rs @@ -1,11 +1,10 @@ //! Implement INode for RandomINode -use alloc::{collections::vec_deque::VecDeque, string::String, sync::Arc}; +use alloc::sync::Arc; use core::any::Any; use rcore_fs::vfs::*; -use crate::sync::Condvar; use crate::sync::SpinNoIrqLock as Mutex; pub struct RandomINodeData { diff --git a/kernel/src/fs/stdio.rs b/kernel/src/fs/stdio.rs index 0d40c56f..72f3787f 100644 --- a/kernel/src/fs/stdio.rs +++ b/kernel/src/fs/stdio.rs @@ -1,12 +1,11 @@ //! Implement INode for Stdin & Stdout -use alloc::{collections::vec_deque::VecDeque, string::String, sync::Arc}; +use alloc::{collections::vec_deque::VecDeque, sync::Arc}; use core::any::Any; use rcore_fs::vfs::*; use super::ioctl::*; -use crate::process::Process; use crate::sync::Condvar; use crate::sync::SpinNoIrqLock as Mutex; diff --git a/kernel/src/fs/vga.rs b/kernel/src/fs/vga.rs index e3f7d3b6..454fa520 100755 --- a/kernel/src/fs/vga.rs +++ b/kernel/src/fs/vga.rs @@ -1,8 +1,6 @@ use rcore_fs::vfs::*; use crate::drivers::gpu::fb::{ColorFormat, FramebufferInfo, FRAME_BUFFER}; -use crate::memory::phys_to_virt; -use alloc::{string::String, sync::Arc, vec::Vec}; use core::any::Any; #[derive(Default)] diff --git a/kernel/src/ipc/semary.rs b/kernel/src/ipc/semary.rs index b54511af..a79f9e87 100644 --- a/kernel/src/ipc/semary.rs +++ b/kernel/src/ipc/semary.rs @@ -1,6 +1,5 @@ use crate::sync::Semaphore; -use crate::sync::SpinLock as Mutex; -use alloc::{boxed::Box, collections::BTreeMap, string::String, sync::Arc, sync::Weak, vec::Vec}; +use alloc::{collections::BTreeMap, sync::Arc, sync::Weak, vec::Vec}; use core::ops::Index; use spin::RwLock; diff --git a/kernel/src/lkm/api.rs b/kernel/src/lkm/api.rs index 72e1d1a0..81dcf4a7 100644 --- a/kernel/src/lkm/api.rs +++ b/kernel/src/lkm/api.rs @@ -1,7 +1,5 @@ use super::*; -use crate::lkm::manager::ModuleManager; use crate::lkm::structs::LoadedModule; -use alloc::boxed::Box; use alloc::string::String; use alloc::sync::Arc; use core::alloc::{GlobalAlloc, Layout}; @@ -10,7 +8,7 @@ use core::slice::from_raw_parts; pub fn get_module(this_module: usize) -> &'static mut LoadedModule { unsafe { let ptr = this_module as *mut LoadedModule; - &mut (*ptr) as (&'static mut LoadedModule) + &mut (*ptr) as &'static mut LoadedModule } } diff --git a/kernel/src/lkm/kernelvm.rs b/kernel/src/lkm/kernelvm.rs index 6ef4af60..bf18022e 100644 --- a/kernel/src/lkm/kernelvm.rs +++ b/kernel/src/lkm/kernelvm.rs @@ -1,14 +1,10 @@ // Simple kernel memory set for kernel virtual memory use crate::arch::paging::PageTableImpl; -use crate::consts::*; use crate::memory::GlobalFrameAlloc; use crate::sync::SpinLock as Mutex; use alloc::vec::*; -use buddy_system_allocator::*; -use core::alloc::Layout; use core::mem::ManuallyDrop; use core::ops::DerefMut; -use core::ptr::NonNull; use lazy_static::lazy_static; use rcore_memory::memory_set::handler::{ByFrame, MemoryHandler}; use rcore_memory::memory_set::MemoryAttr; @@ -119,7 +115,7 @@ impl VirtualArea { parent: &mut VirtualSpace, ) -> VirtualArea { let aligned_start_addr = page_addr - page_addr % PAGE_SIZE; - let mut aligned_end = (page_addr + size + PAGE_SIZE - 1); + let mut aligned_end = page_addr + size + PAGE_SIZE - 1; aligned_end = aligned_end - aligned_end % PAGE_SIZE; let lock = parent.allocator.lock(); let mut active_pt = lock.kernel_table(); diff --git a/kernel/src/lkm/manager.rs b/kernel/src/lkm/manager.rs index d81c67e9..84f09c9f 100644 --- a/kernel/src/lkm/manager.rs +++ b/kernel/src/lkm/manager.rs @@ -2,36 +2,26 @@ use super::api::*; use super::const_reloc as loader; use super::kernelvm::*; use super::structs::*; -use crate::consts::*; use crate::lkm::structs::ModuleState::{Ready, Unloading}; -use crate::memory::GlobalFrameAlloc; -use crate::sync::{Condvar, SpinLock as Mutex}; +use crate::sync::SpinLock as Mutex; use crate::syscall::SysError::*; use crate::syscall::SysResult; use alloc::boxed::Box; use alloc::collections::btree_map::BTreeMap; -use alloc::prelude::*; use alloc::string::*; use alloc::sync::Arc; use alloc::vec::*; -use core::borrow::BorrowMut; use core::mem::transmute; -use core::slice; use lazy_static::lazy_static; -use rcore_memory::memory_set::handler::{ByFrame, MemoryHandler}; use rcore_memory::memory_set::MemoryAttr; -use rcore_memory::{Page, PAGE_SIZE}; +use rcore_memory::PAGE_SIZE; use xmas_elf::dynamic::Tag; use xmas_elf::program::Type::Load; use xmas_elf::sections::SectionData; use xmas_elf::sections::SectionData::{DynSymbolTable64, Dynamic64, Undefined}; use xmas_elf::symbol_table::DynEntry64; use xmas_elf::symbol_table::Entry; -use xmas_elf::{ - header, - program::{Flags, Type}, - ElfFile, -}; +use xmas_elf::{header, ElfFile}; // The symbol data table. global_asm!(include_str!("symbol_table.asm")); @@ -96,15 +86,15 @@ impl ModuleManager { return; } use compression::prelude::*; - let zipped_symbols = - unsafe { slice::from_raw_parts(symbol_table_start as *const u8, symbol_table_len) } - .to_vec(); + let zipped_symbols = unsafe { + core::slice::from_raw_parts(symbol_table_start as *const u8, symbol_table_len) + } + .to_vec(); let real_symbols = zipped_symbols .decode(&mut GZipDecoder::new()) .collect::, _>>() .unwrap(); - use core::slice; use core::str::from_utf8; self.init_kernel_symbols(from_utf8(&real_symbols).unwrap()); } diff --git a/kernel/src/sync/condvar.rs b/kernel/src/sync/condvar.rs index 22ca8f63..37b76262 100644 --- a/kernel/src/sync/condvar.rs +++ b/kernel/src/sync/condvar.rs @@ -1,6 +1,6 @@ use super::*; +use crate::process::thread_manager; use crate::process::Process; -use crate::process::{current_thread, thread_manager}; use crate::thread; use alloc::collections::VecDeque; use alloc::sync::Arc; diff --git a/kernel/src/syscall/custom.rs b/kernel/src/syscall/custom.rs index 08253f14..42df0c99 100644 --- a/kernel/src/syscall/custom.rs +++ b/kernel/src/syscall/custom.rs @@ -1,7 +1,5 @@ //! Custom nonstandard syscalls use super::*; -use rcore_memory::memory_set::handler::Linear; -use rcore_memory::memory_set::MemoryAttr; impl Syscall<'_> { /// Allocate this PCI device to user space @@ -9,6 +7,9 @@ impl Syscall<'_> { #[cfg(target_arch = "x86_64")] pub fn sys_map_pci_device(&mut self, vendor: usize, product: usize) -> SysResult { use crate::drivers::bus::pci; + use rcore_memory::memory_set::handler::Linear; + use rcore_memory::memory_set::MemoryAttr; + info!( "map_pci_device: vendor: {:x}, product: {:x}", vendor, product diff --git a/kernel/src/syscall/fs.rs b/kernel/src/syscall/fs.rs index f4e2213c..f04d2cff 100644 --- a/kernel/src/syscall/fs.rs +++ b/kernel/src/syscall/fs.rs @@ -8,18 +8,14 @@ use rcore_fs::vfs::Timespec; use crate::drivers::SOCKET_ACTIVITY; use crate::fs::*; use crate::memory::MemorySet; -use crate::sync::{Condvar, SpinNoIrqLock}; +use crate::sync::Condvar; use crate::trap::TICK_ACTIVITY; -use alloc::{collections::BTreeMap, collections::BTreeSet}; use bitvec::prelude::{BitSlice, BitVec, LittleEndian}; use super::*; use crate::fs::epoll::EpollInstance; -use crate::net::server; use crate::process::Process; -use alloc::collections::VecDeque; -use bitflags::_core::task::Poll; use rcore_fs::vfs::PollStatus; impl Syscall<'_> { @@ -394,7 +390,6 @@ impl Syscall<'_> { let begin_time_ms = crate::trap::uptime_msec(); let condition = move || { - use PollEvents as PE; let mut proc = self.process(); let epollInstance = match proc.get_epoll_instance_mut(epfd) { diff --git a/kernel/src/syscall/ipc.rs b/kernel/src/syscall/ipc.rs index c9956f3b..367bad3f 100644 --- a/kernel/src/syscall/ipc.rs +++ b/kernel/src/syscall/ipc.rs @@ -1,9 +1,4 @@ -use crate::sync::Semaphore; -use crate::sync::SpinLock as Mutex; -use alloc::{boxed::Box, collections::BTreeMap, string::String, sync::Arc, sync::Weak, vec::Vec}; use bitflags::*; -use core::cell::UnsafeCell; -use spin::RwLock; pub use crate::ipc::*; diff --git a/kernel/src/syscall/lkm.rs b/kernel/src/syscall/lkm.rs index 9941feba..2bf4e256 100644 --- a/kernel/src/syscall/lkm.rs +++ b/kernel/src/syscall/lkm.rs @@ -1,8 +1,5 @@ use crate::lkm::manager::ModuleManager; -use crate::sync::Mutex; use crate::syscall::{check_and_clone_cstr, SysResult, Syscall}; -use alloc::collections::btree_map::BTreeMap; -use compression::prelude::Action; impl Syscall<'_> { pub fn sys_init_module(