From 684a2c5dd8642a6c1426a41b56dad5c4f35e8bfe Mon Sep 17 00:00:00 2001 From: Yuhao Zhou Date: Mon, 8 Apr 2019 01:00:26 +0800 Subject: [PATCH] Fix syscall return register. --- kernel/Makefile | 2 +- kernel/src/arch/mipsel/context.rs | 8 ++++---- kernel/src/arch/mipsel/interrupt.rs | 6 ++++-- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/kernel/Makefile b/kernel/Makefile index d7d1df1..2db02a5 100644 --- a/kernel/Makefile +++ b/kernel/Makefile @@ -200,7 +200,7 @@ prefix := riscv64-unknown-elf- else ifeq ($(arch), riscv64) prefix := riscv64-unknown-elf- else ifeq ($(arch), mipsel) -prefix ?= mipsel-linux-gnu- +prefix ?= mipsel-linux-musln32- else ifeq ($(arch), aarch64) prefix ?= aarch64-none-elf- ifeq (,$(shell which $(prefix)ld)) diff --git a/kernel/src/arch/mipsel/context.rs b/kernel/src/arch/mipsel/context.rs index 9227bef..3236703 100644 --- a/kernel/src/arch/mipsel/context.rs +++ b/kernel/src/arch/mipsel/context.rs @@ -174,7 +174,7 @@ impl Context { /// The stack pointer will be set to `kstack_top`. /// The SATP register will be set to `satp`. pub unsafe fn new_kernel_thread(entry: extern fn(usize) -> !, arg: usize, kstack_top: usize, satp: usize) -> Self { - trace!("New kernel thread @ {:x}, stack = {:x}", entry as usize, kstack_top); + info!("New kernel thread @ {:x}, stack = {:x}", entry as usize, kstack_top); InitStack { context: ContextData::new(satp), @@ -188,7 +188,7 @@ impl Context { /// The stack pointer of user and kernel mode will be set to `ustack_top`, `kstack_top`. /// The SATP register will be set to `satp`. pub unsafe fn new_user_thread(entry_addr: usize, ustack_top: usize, kstack_top: usize, _is32: bool, satp: usize) -> Self { - trace!("New user thread @ {:x}, stack = {:x}", entry_addr, kstack_top); + info!("New user thread @ {:x}, stack = {:x}", entry_addr, kstack_top); InitStack { context: ContextData::new(satp), @@ -207,7 +207,7 @@ impl Context { tf: { let mut tf = tf.clone(); // fork function's ret value, the new process is 0 - tf.a0 = 0; + tf.v0 = 0; tf }, }.push_at(kstack_top) @@ -227,7 +227,7 @@ impl Context { let mut tf = tf.clone(); tf.sp = ustack_top; // sp tf.v1 = tls; // tp - tf.a0 = 0; // a0 + tf.v0 = 0; // a0 tf }, }.push_at(kstack_top) diff --git a/kernel/src/arch/mipsel/interrupt.rs b/kernel/src/arch/mipsel/interrupt.rs index 36176b9..21f39f2 100644 --- a/kernel/src/arch/mipsel/interrupt.rs +++ b/kernel/src/arch/mipsel/interrupt.rs @@ -156,8 +156,10 @@ fn page_fault(tf: &mut TrapFrame) { let tlb_result = root_table.lookup(addr); match tlb_result { Ok(tlb_entry) => tlb::write_tlb_random(tlb_entry), - Err(()) => if !crate::memory::handle_page_fault(addr) { - crate::trap::error(tf); + Err(()) => { + if !crate::memory::handle_page_fault(addr) { + crate::trap::error(tf); + } } } }