xous: use asm!() macro for syscalls

Previously we used externally-linked assembly in order to make syscalls.
Now that `asm!()` is stable, use this macro.

This will help to optimize IPC between programs and the kernel.
Additionally, it resolves an unsoundness issue where we were filling in
values on the stack and hoping that Rust didn't reorder the structs.

Signed-off-by: Sean Cross <sean@xobs.io>
This commit is contained in:
Sean Cross 2023-01-30 21:49:24 +08:00
parent 5185b2ee07
commit a24291b462

View file

@ -16,14 +16,21 @@ use crate::definitions::SysCallResult;
use crate::syscall::SysCall;
pub fn syscall(call: SysCall) -> SysCallResult {
let mut ret = crate::Result::Ok;
let args = call.as_args();
let mut args = call.as_args();
unsafe {
_xous_syscall(
args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7], &mut ret,
core::arch::asm!(
"ecall",
inlateout("a0") args[0],
inlateout("a1") args[1],
inlateout("a2") args[2],
inlateout("a3") args[3],
inlateout("a4") args[4],
inlateout("a5") args[5],
inlateout("a6") args[6],
inlateout("a7") args[7],
)
};
match ret {
match crate::definitions::Result::from_args(args) {
crate::Result::Error(e) => Err(e),
other => Ok(other),
}