From ff8930a36cc9d12ad131bb0be91cb5122be87735 Mon Sep 17 00:00:00 2001 From: WangRunji Date: Tue, 7 Aug 2018 14:59:45 +0800 Subject: [PATCH] Make frame allocator smaller. Fix serial stupid bug. --- kernel/Makefile | 1 + kernel/src/arch/riscv32/io.rs | 2 +- kernel/src/arch/riscv32/timer.rs | 2 +- kernel/src/memory.rs | 4 ++-- kernel/src/process/mod.rs | 1 + 5 files changed, 6 insertions(+), 4 deletions(-) diff --git a/kernel/Makefile b/kernel/Makefile index eae0e89..4321f80 100644 --- a/kernel/Makefile +++ b/kernel/Makefile @@ -112,6 +112,7 @@ build/x86_64/os.iso: $(kernel) $(grub_cfg) build/riscv32/os.iso: kernel @cp $(rust_lib) $@ + @cp $(rust_lib) $(kernel) $(kernel): kernel $(assembly_object_files) $(linker_script) @$(ld) -n --gc-sections -T $(linker_script) -o $(kernel) \ diff --git a/kernel/src/arch/riscv32/io.rs b/kernel/src/arch/riscv32/io.rs index e392e46..d529ef1 100644 --- a/kernel/src/arch/riscv32/io.rs +++ b/kernel/src/arch/riscv32/io.rs @@ -41,5 +41,5 @@ pub fn putfmt(fmt: Arguments) { const DATA: *mut u8 = 0x10000000 as *mut u8; const STATUS: *const u8 = 0x10000005 as *const u8; -const CAN_READ: u8 = 1 << 1; +const CAN_READ: u8 = 1 << 0; const CAN_WRITE: u8 = 1 << 5; diff --git a/kernel/src/arch/riscv32/timer.rs b/kernel/src/arch/riscv32/timer.rs index 0ddc916..f5960ae 100644 --- a/kernel/src/arch/riscv32/timer.rs +++ b/kernel/src/arch/riscv32/timer.rs @@ -27,7 +27,7 @@ pub fn init() { pub fn set_next() { // 100Hz @ QEMU - let timebase = 100000; + let timebase = 250000; set_timer(get_cycle() + timebase); } diff --git a/kernel/src/memory.rs b/kernel/src/memory.rs index 0da3fb3..3f88ff0 100644 --- a/kernel/src/memory.rs +++ b/kernel/src/memory.rs @@ -1,5 +1,5 @@ pub use arch::paging::*; -use bit_allocator::{BitAlloc, BitAlloc64K}; +use bit_allocator::{BitAlloc, BitAlloc4K}; use consts::MEMORY_OFFSET; use spin::{Mutex, MutexGuard}; use super::HEAP_ALLOCATOR; @@ -10,7 +10,7 @@ pub use ucore_memory::memory_set::{MemoryArea, MemoryAttr, MemorySet as MemorySe pub type MemorySet = MemorySet_; lazy_static! { - pub static ref FRAME_ALLOCATOR: Mutex = Mutex::new(BitAlloc64K::default()); + pub static ref FRAME_ALLOCATOR: Mutex = Mutex::new(BitAlloc4K::default()); } pub fn alloc_frame() -> Option { diff --git a/kernel/src/process/mod.rs b/kernel/src/process/mod.rs index 6f207be..569f3d2 100644 --- a/kernel/src/process/mod.rs +++ b/kernel/src/process/mod.rs @@ -24,6 +24,7 @@ pub fn init() { processor }) ); + info!("process init end"); } pub static PROCESSOR: Once> = Once::new();