1
0
mirror of https://github.com/rcore-os/rCore.git synced 2024-11-22 16:16:16 +04:00

Remove unused import

This commit is contained in:
equation314 2020-04-04 17:48:45 +08:00
parent c1907b6772
commit a6cd153fca
34 changed files with 40 additions and 98 deletions

View File

@ -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;

View File

@ -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 {

View File

@ -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

View File

@ -9,7 +9,6 @@ pub mod rand;
pub mod syscall;
pub mod timer;
use log::*;
use mips::registers::cp0;
#[cfg(feature = "board_malta")]

View File

@ -1,5 +1,5 @@
pub use self::context::*;
use crate::drivers::{DRIVERS, IRQ_MANAGER};
use crate::drivers::IRQ_MANAGER;
use log::*;
use riscv::register::*;

View File

@ -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) {

View File

@ -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"

View File

@ -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;
}

View File

@ -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,

View File

@ -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::*;

View File

@ -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::<usize>()
&& current_fp <= 0xffff_ff00_0000_0000
{

View File

@ -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<VirtIOBlk<'static>>);

View File

@ -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") {

View File

@ -2,7 +2,6 @@
use alloc::string::String;
use core::fmt;
use lazy_static::lazy_static;
use log::*;
use spin::Mutex;

View File

@ -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};

View File

@ -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)]

View File

@ -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]>);

View File

@ -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<usize, EpollEvent>,
@ -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);

View File

@ -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 ?

View File

@ -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()

View File

@ -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::*;

View File

@ -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::*;

View File

@ -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 {

View File

@ -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;

View File

@ -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)]

View File

@ -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;

View File

@ -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
}
}

View File

@ -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();

View File

@ -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) }
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::<Result<Vec<_>, _>>()
.unwrap();
use core::slice;
use core::str::from_utf8;
self.init_kernel_symbols(from_utf8(&real_symbols).unwrap());
}

View File

@ -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;

View File

@ -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

View File

@ -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) {

View File

@ -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::*;

View File

@ -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(