From 200a574a1f09eb2293dee16dffc83b7877231ea1 Mon Sep 17 00:00:00 2001 From: WangRunji Date: Wed, 7 Nov 2018 13:16:52 +0800 Subject: [PATCH] fix physical memory range on RV32 --- kernel/src/arch/riscv32/consts.rs | 1 - kernel/src/arch/riscv32/memory.rs | 5 ++--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/kernel/src/arch/riscv32/consts.rs b/kernel/src/arch/riscv32/consts.rs index d60b6e2..f411a4d 100644 --- a/kernel/src/arch/riscv32/consts.rs +++ b/kernel/src/arch/riscv32/consts.rs @@ -5,7 +5,6 @@ const P2_MASK: usize = 0x3ff << 22; pub const RECURSIVE_INDEX: usize = 0x3fe; pub const KERNEL_OFFSET: usize = 0; pub const KERNEL_P2_INDEX: usize = 0x8000_0000 >> 22; -pub const KERNEL_HEAP_OFFSET: usize = 0x8020_0000; pub const KERNEL_HEAP_SIZE: usize = 0x0020_0000; pub const MEMORY_OFFSET: usize = 0x8000_0000; pub const MEMORY_END: usize = 0x8080_0000; diff --git a/kernel/src/arch/riscv32/memory.rs b/kernel/src/arch/riscv32/memory.rs index bd3be70..882b542 100644 --- a/kernel/src/arch/riscv32/memory.rs +++ b/kernel/src/arch/riscv32/memory.rs @@ -29,8 +29,7 @@ fn init_frame_allocator() { use consts::{MEMORY_OFFSET, MEMORY_END}; let mut ba = FRAME_ALLOCATOR.lock(); - use consts::{KERNEL_HEAP_OFFSET, KERNEL_HEAP_SIZE}; - ba.insert(to_range(KERNEL_HEAP_OFFSET + KERNEL_HEAP_SIZE, MEMORY_END)); + ba.insert(to_range(end as usize + PAGE_SIZE, MEMORY_END)); info!("FrameAllocator init end"); fn to_range(start: usize, end: usize) -> Range { @@ -41,8 +40,8 @@ fn init_frame_allocator() { } fn remap_the_kernel() { - use consts::{KERNEL_HEAP_OFFSET, KERNEL_HEAP_SIZE}; let mut ms = MemorySet::new_bare(); + #[cfg(feature = "no_bbl")] ms.push(MemoryArea::new_identity(0x10000000, 0x10000008, MemoryAttr::default(), "serial")); ms.push(MemoryArea::new_identity(stext as usize, etext as usize, MemoryAttr::default().execute().readonly(), "text")); ms.push(MemoryArea::new_identity(sdata as usize, edata as usize, MemoryAttr::default(), "data"));