From a708ee401d1c53ce64589f5fcfbced67a90c81fb Mon Sep 17 00:00:00 2001 From: Yuhao Zhou Date: Sat, 25 May 2019 20:05:27 +0800 Subject: [PATCH] Fix syscall in thinpad. --- kernel/src/arch/mipsel/context.rs | 31 +++++++++++++++++++++++++++++ kernel/src/arch/mipsel/interrupt.rs | 9 ++++++++- 2 files changed, 39 insertions(+), 1 deletion(-) diff --git a/kernel/src/arch/mipsel/context.rs b/kernel/src/arch/mipsel/context.rs index 94413139..668d21c9 100644 --- a/kernel/src/arch/mipsel/context.rs +++ b/kernel/src/arch/mipsel/context.rs @@ -133,6 +133,37 @@ impl Debug for TrapFrame { .field("epc", &self.epc) .field("cause", &self.cause.bits) .field("vaddr", &self.vaddr) + .field("at", &self.at) + .field("v0", &self.v0) + .field("v1", &self.v1) + .field("a0", &self.a0) + .field("a1", &self.a1) + .field("a2", &self.a2) + .field("a3", &self.a3) + .field("t0", &self.t0) + .field("t1", &self.t1) + .field("t2", &self.t2) + .field("t3", &self.t3) + .field("t4", &self.t4) + .field("t5", &self.t5) + .field("t6", &self.t6) + .field("t7", &self.t7) + .field("s0", &self.s0) + .field("s1", &self.s1) + .field("s2", &self.s2) + .field("s3", &self.s3) + .field("s4", &self.s4) + .field("s5", &self.s5) + .field("s6", &self.s6) + .field("s7", &self.s7) + .field("t8", &self.t8) + .field("t9", &self.t9) + .field("k0", &self.k0) + .field("k1", &self.k1) + .field("gp", &self.gp) + .field("sp", &self.sp) + .field("fp", &self.fp) + .field("ra", &self.ra) .finish() } } diff --git a/kernel/src/arch/mipsel/interrupt.rs b/kernel/src/arch/mipsel/interrupt.rs index bc4b9cdd..ffe064be 100644 --- a/kernel/src/arch/mipsel/interrupt.rs +++ b/kernel/src/arch/mipsel/interrupt.rs @@ -154,7 +154,14 @@ fn timer() { fn syscall(tf: &mut TrapFrame) { tf.epc += 4; // Must before syscall, because of fork. let arguments = [tf.a0, tf.a1, tf.a2, tf.a3, tf.t0, tf.t1]; - trace!("MIPS syscall {} invoked with {:?}", tf.v0, arguments); + trace!("MIPS syscall {} invoked with {:x?}, epc = {:x?}", tf.v0, arguments, tf.epc); + + + // temporary solution for ThinPad + if(tf.v0 == 0) { + warn!("Syscall ID = 0"); + tf.v0 = unsafe { *((tf.sp + 28) as *const usize) }; + } let ret = crate::syscall::syscall(tf.v0, arguments, tf) as isize; // comply with mips n32 abi, always return a positive value