From ad2f02388cf84e9cdfef8cdee535d0cba8741b47 Mon Sep 17 00:00:00 2001 From: Jiajie Chen Date: Thu, 2 May 2019 15:18:41 +0800 Subject: [PATCH] Fix compilation on mipsel --- kernel/src/drivers/bus/pci.rs | 1 - kernel/src/fs/file_like.rs | 4 ++-- kernel/src/fs/mod.rs | 3 --- kernel/src/memory.rs | 10 +++++++--- kernel/src/process/structs.rs | 2 +- kernel/src/shell.rs | 4 ++-- kernel/src/syscall/mem.rs | 2 +- kernel/src/syscall/net.rs | 1 - 8 files changed, 13 insertions(+), 14 deletions(-) diff --git a/kernel/src/drivers/bus/pci.rs b/kernel/src/drivers/bus/pci.rs index 2744b2b..b2c86e7 100644 --- a/kernel/src/drivers/bus/pci.rs +++ b/kernel/src/drivers/bus/pci.rs @@ -5,7 +5,6 @@ use crate::drivers::{Driver, DRIVERS, NET_DRIVERS}; use crate::memory::active_table; use alloc::collections::BTreeMap; use alloc::sync::Arc; -use core::cmp::Ordering; use pci::*; use rcore_memory::{paging::PageTable, PAGE_SIZE}; use spin::Mutex; diff --git a/kernel/src/fs/file_like.rs b/kernel/src/fs/file_like.rs index c8730eb..5f7ebc4 100644 --- a/kernel/src/fs/file_like.rs +++ b/kernel/src/fs/file_like.rs @@ -53,8 +53,8 @@ impl FileLike { impl fmt::Debug for FileLike { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match self { - FileLike::File(file) => write!(f, "File {:?}", file), - FileLike::Socket(_) => write!(f, "Socket"), + FileLike::File(file) => write!(f, "File({:?})", file), + FileLike::Socket(_) => write!(f, "Socket(..)"), } } } diff --git a/kernel/src/fs/mod.rs b/kernel/src/fs/mod.rs index 419e3eb..7217ae3 100644 --- a/kernel/src/fs/mod.rs +++ b/kernel/src/fs/mod.rs @@ -3,9 +3,6 @@ use alloc::{sync::Arc, vec::Vec}; use rcore_fs::vfs::*; use rcore_fs_sfs::SimpleFileSystem; -#[cfg(target_arch = "x86_64")] -use crate::arch::driver::ide; - pub use self::file::*; pub use self::file_like::*; pub use self::pipe::Pipe; diff --git a/kernel/src/memory.rs b/kernel/src/memory.rs index 6ee97b9..b3b013a 100644 --- a/kernel/src/memory.rs +++ b/kernel/src/memory.rs @@ -18,9 +18,8 @@ use crate::consts::{KERNEL_OFFSET, MEMORY_OFFSET}; use crate::process::process_unsafe; use crate::sync::SpinNoIrqLock; use alloc::boxed::Box; -use alloc::vec::Vec; use bitmap_allocator::BitAlloc; -use buddy_system_allocator::{Heap, LockedHeap}; +use buddy_system_allocator::Heap; use lazy_static::*; use log::*; pub use rcore_memory::memory_set::{handler::*, MemoryArea, MemoryAttr}; @@ -149,13 +148,18 @@ pub fn init_heap() { } pub fn enlarge_heap(heap: &mut Heap) { + info!("Enlarging heap to avoid oom"); + let mut page_table = active_table(); let mut addrs = [(0, 0); 32]; let mut addr_len = 0; + #[cfg(target_arch = "x86_64")] let va_offset = KERNEL_OFFSET + 0xe0000000; + #[cfg(not(target_arch = "x86_64"))] + let va_offset = KERNEL_OFFSET + 0x00e00000; for i in 0..16384 { let page = alloc_frame().unwrap(); - let va = KERNEL_OFFSET + 0xe0000000 + page; + let va = va_offset + page; if addr_len > 0 { let (ref mut addr, ref mut len) = addrs[addr_len - 1]; if *addr - PAGE_SIZE == va { diff --git a/kernel/src/process/structs.rs b/kernel/src/process/structs.rs index 2ec8dcf..bea6a9e 100644 --- a/kernel/src/process/structs.rs +++ b/kernel/src/process/structs.rs @@ -13,7 +13,7 @@ use xmas_elf::{ }; use crate::arch::interrupt::{Context, TrapFrame}; -use crate::fs::{FileHandle, FileLike, INodeExt, OpenOptions, FOLLOW_MAX_DEPTH}; +use crate::fs::{FileHandle, FileLike, OpenOptions, FOLLOW_MAX_DEPTH}; use crate::memory::{ ByFrame, Delay, File, GlobalFrameAlloc, KernelStack, MemoryAttr, MemorySet, Read, }; diff --git a/kernel/src/shell.rs b/kernel/src/shell.rs index 84c4367..7e8822b 100644 --- a/kernel/src/shell.rs +++ b/kernel/src/shell.rs @@ -1,7 +1,6 @@ //! Kernel shell -use crate::drivers::CMDLINE; -use crate::fs::{INodeExt, ROOT_INODE}; +use crate::fs::ROOT_INODE; use crate::process::*; use alloc::string::String; use alloc::vec::Vec; @@ -40,6 +39,7 @@ pub fn add_user_shell() { #[cfg(feature = "run_cmdline")] pub fn add_user_shell() { + use crate::drivers::CMDLINE; let cmdline = CMDLINE.read(); let inode = ROOT_INODE.lookup(&cmdline).unwrap(); processor().manager().add(Thread::new_user( diff --git a/kernel/src/syscall/mem.rs b/kernel/src/syscall/mem.rs index d108a7c..1a241ac 100644 --- a/kernel/src/syscall/mem.rs +++ b/kernel/src/syscall/mem.rs @@ -1,4 +1,4 @@ -use rcore_memory::memory_set::handler::{ByFrame, Delay, File}; +use rcore_memory::memory_set::handler::{Delay, File}; use rcore_memory::memory_set::MemoryAttr; use rcore_memory::paging::PageTable; use rcore_memory::Page; diff --git a/kernel/src/syscall/net.rs b/kernel/src/syscall/net.rs index af28065..e7c3318 100644 --- a/kernel/src/syscall/net.rs +++ b/kernel/src/syscall/net.rs @@ -2,7 +2,6 @@ use super::fs::IoVecs; use super::*; -use crate::drivers::SOCKET_ACTIVITY; use crate::fs::FileLike; use crate::net::{ Endpoint, LinkLevelEndpoint, NetlinkEndpoint, NetlinkSocketState, PacketSocketState,