From ed3fb6d423c72be815208388ebb91c668c02759a Mon Sep 17 00:00:00 2001 From: dzy Date: Wed, 26 Dec 2018 09:47:00 +0800 Subject: [PATCH] another temporary --- crate/riscv | 2 +- kernel/Makefile | 2 +- kernel/run-qemu-script-custom-llc | 14 +++++++------- kernel/src/arch/riscv32/consts.rs | 6 +++++- kernel/src/arch/riscv32/memory.rs | 4 ++-- riscv-pk | 2 +- 6 files changed, 17 insertions(+), 13 deletions(-) diff --git a/crate/riscv b/crate/riscv index 03033e9..82562ff 160000 --- a/crate/riscv +++ b/crate/riscv @@ -1 +1 @@ -Subproject commit 03033e9570079f85476280de4e155ef21d6c9e8b +Subproject commit 82562ff04c4f269f6bf23eee363fb4e2b8536b8f diff --git a/kernel/Makefile b/kernel/Makefile index fb96ca9..2ca538a 100644 --- a/kernel/Makefile +++ b/kernel/Makefile @@ -181,7 +181,7 @@ ifeq ($(arch), riscv32) $(shell rustc --print sysroot)/lib/rustlib/src/rust/src/libcore/sync/atomic.rs \ src/arch/riscv32/atomic.patch endif - @CC=$(cc) LOG=trace cargo xbuild $(build_args) + @CC=$(cc) cargo xbuild $(build_args) endif diff --git a/kernel/run-qemu-script-custom-llc b/kernel/run-qemu-script-custom-llc index 9097784..753a8b3 100755 --- a/kernel/run-qemu-script-custom-llc +++ b/kernel/run-qemu-script-custom-llc @@ -17,19 +17,19 @@ then exit 1 fi -if ! [[ ${RV32} = 1 ]]; then +if [[ ${RV32} = 1 ]]; then + TARGET_ARCH=riscv32 + COMPILER_RT_CFLAGS="-march=rv32ia -mabi=ilp32 -O3" + SFSIMG_CFLAGS="-march=rv32ia -mabi=ilp32" + RISCV_PK_CONFIGURE_FLAGS="--with-arch=rv32imac --disable-fp-emulation --host=riscv32-unknown-elf" + UCORE_USER_IMAGE="../user/img/ucore-rv32.img" +else TARGET_ARCH=riscv64 export LOG=trace COMPILER_RT_CFLAGS="-march=rv64ia -mabi=lp64 -O3" SFSIMG_CFLAGS="-march=rv64ia -mabi=lp64" RISCV_PK_CONFIGURE_FLAGS="--with-arch=rv64imac --disable-fp-emulation --host=riscv64-unknown-elf" UCORE_USER_IMAGE="../user/img/ucore-riscv64.img" -else - TARGET_ARCH=riscv32 - COMPILER_RT_CFLAGS="-march=rv32ia -mabi=ilp32 -O3" - SFSIMG_CFLAGS="-march=rv32ia -mabi=ilp32" - RISCV_PK_CONFIGURE_FLAGS="--with-arch=rv32imac --disable-fp-emulation --host=riscv32-unknown-elf" - UCORE_USER_IMAGE="../user/img/ucore-rv32.img" fi LLC=llc RUST_SRC_PATH=$(rustc --print sysroot)/lib/rustlib/src/rust/src diff --git a/kernel/src/arch/riscv32/consts.rs b/kernel/src/arch/riscv32/consts.rs index 4bc47ea..99396c3 100644 --- a/kernel/src/arch/riscv32/consts.rs +++ b/kernel/src/arch/riscv32/consts.rs @@ -12,8 +12,12 @@ pub const RECURSIVE_INDEX: usize = 0x1fd; // root_table[0776] points to root_table itself as leaf page #[cfg(target_arch = "riscv32")] -pub const KERNEL_P2_INDEX: usize = 0x8000_0000 >> 22; +pub const KERN_VA_BASE: usize = 0; +#[cfg(target_arch = "riscv64")] +pub const KERN_VA_BASE: usize = 0xFFFF_FFFF_0000_0000; +#[cfg(target_arch = "riscv32")] +pub const KERNEL_P2_INDEX: usize = 0x8000_0000 >> 22; #[cfg(feature = "board_k210")] pub const KERNEL_HEAP_SIZE: usize = 0x0010_0000; #[cfg(not(feature = "board_k210"))] diff --git a/kernel/src/arch/riscv32/memory.rs b/kernel/src/arch/riscv32/memory.rs index e31a24c..867f011 100644 --- a/kernel/src/arch/riscv32/memory.rs +++ b/kernel/src/arch/riscv32/memory.rs @@ -3,7 +3,7 @@ use riscv::{addr::*, register::sstatus}; use ucore_memory::PAGE_SIZE; use log::*; use crate::memory::{active_table, FRAME_ALLOCATOR, init_heap, MemoryArea, MemoryAttr, MemorySet, MEMORY_ALLOCATOR}; -use crate::consts::{MEMORY_OFFSET, MEMORY_END}; +use crate::consts::{MEMORY_OFFSET, MEMORY_END, KERN_VA_BASE}; use riscv::register::satp; #[cfg(feature = "no_mmu")] @@ -48,7 +48,7 @@ fn init_frame_allocator() { // TODO: delete debug code let mut ba = FRAME_ALLOCATOR.lock(); - let range = to_range((end as usize) - 0xFFFF_FFFF_0000_0000 + PAGE_SIZE, MEMORY_END); + let range = to_range((end as usize) - KERN_VA_BASE + PAGE_SIZE, MEMORY_END); info!("FrameAllocator insert {} .. {}", range.start, range.end); ba.insert(range); info!("FrameAllocator init end"); diff --git a/riscv-pk b/riscv-pk index 11fe816..f4ec45a 160000 --- a/riscv-pk +++ b/riscv-pk @@ -1 +1 @@ -Subproject commit 11fe816ca3b7745268e9322c51cd115d6059654e +Subproject commit f4ec45a908005331149af5816247dcb89fbd4654