diff --git a/kernel/src/arch/riscv/trap.rs b/kernel/src/arch/riscv/trap.rs index c836e62..78dbf6d 100644 --- a/kernel/src/arch/riscv/trap.rs +++ b/kernel/src/arch/riscv/trap.rs @@ -110,16 +110,16 @@ impl TrapContextOps for TrapContext { } fn get_reg(&self, index: usize) -> usize { - // x10 ~ x17: Function arguments + // x9(a0) ~ x16(a7): Function arguments assert!(index < 8, "TrapContext get_reg index out of range"); - self.gprs[index + 10] + self.gprs[index + 9] } fn set_reg(&mut self, index: usize, value: usize) { - // x10 ~ x17: Function arguments - // x10 ~ x11: Function return values + // x9(a0) ~ x16(a7): Function arguments + // x9(a0) ~ x10(a1): Function return values assert!(index < 8, "TrapContext set_reg index out of range"); - self.gprs[index + 10] = value; + self.gprs[index + 9] = value; } }