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>
This commit is contained in:
Sean Cross 2023-12-07 17:36:00 +08:00
parent 1d8d7b16cb
commit dee1c260b8

View file

@ -88,29 +88,31 @@ fn lend_impl(
let a3 = opcode;
let a4 = data.as_ptr() as usize;
let a5 = data.len();
let mut a6 = arg1;
let mut a7 = arg2;
let a6 = arg1;
let a7 = arg2;
let mut ret1;
let mut ret2;
unsafe {
core::arch::asm!(
"ecall",
inlateout("a0") a0,
inlateout("a1") a1 => _,
inlateout("a2") a2 => _,
inlateout("a1") a1 => ret1,
inlateout("a2") a2 => ret2,
inlateout("a3") a3 => _,
inlateout("a4") a4 => _,
inlateout("a5") a5 => _,
inlateout("a6") a6,
inlateout("a7") a7,
inlateout("a6") a6 => _,
inlateout("a7") a7 => _,
)
};
let result = a0;
if result == SyscallResult::MemoryReturned as usize {
Ok((a6, a7))
Ok((ret1, ret2))
} else if result == SyscallResult::Error as usize {
Err(a1.into())
Err(ret1.into())
} else {
Err(Error::InternalError)
}