Skip to content

Commit dee1c26

Browse files
committed
xous: ffi: fix lend_impl() return values
The `ret1` and `ret2` return values from lend operations are returned in $a1 and $a2. This function incorrectly pulled them from $a6 and $a7, causing them to always be `0`. Signed-off-by: Sean Cross <sean@xobs.io>
1 parent 1d8d7b1 commit dee1c26

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

library/std/src/os/xous/ffi.rs

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -88,29 +88,31 @@ fn lend_impl(
8888
let a3 = opcode;
8989
let a4 = data.as_ptr() as usize;
9090
let a5 = data.len();
91-
let mut a6 = arg1;
92-
let mut a7 = arg2;
91+
let a6 = arg1;
92+
let a7 = arg2;
93+
let mut ret1;
94+
let mut ret2;
9395

9496
unsafe {
9597
core::arch::asm!(
9698
"ecall",
9799
inlateout("a0") a0,
98-
inlateout("a1") a1 => _,
99-
inlateout("a2") a2 => _,
100+
inlateout("a1") a1 => ret1,
101+
inlateout("a2") a2 => ret2,
100102
inlateout("a3") a3 => _,
101103
inlateout("a4") a4 => _,
102104
inlateout("a5") a5 => _,
103-
inlateout("a6") a6,
104-
inlateout("a7") a7,
105+
inlateout("a6") a6 => _,
106+
inlateout("a7") a7 => _,
105107
)
106108
};
107109

108110
let result = a0;
109111

110112
if result == SyscallResult::MemoryReturned as usize {
111-
Ok((a6, a7))
113+
Ok((ret1, ret2))
112114
} else if result == SyscallResult::Error as usize {
113-
Err(a1.into())
115+
Err(ret1.into())
114116
} else {
115117
Err(Error::InternalError)
116118
}

0 commit comments

Comments
 (0)