mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-18 08:52:45 +00:00
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:
parent
cfb8c216e2
commit
a406648bcc
1 changed files with 12 additions and 5 deletions
|
|
@ -16,14 +16,21 @@ use crate::definitions::SysCallResult;
|
||||||
use crate::syscall::SysCall;
|
use crate::syscall::SysCall;
|
||||||
|
|
||||||
pub fn syscall(call: SysCall) -> SysCallResult {
|
pub fn syscall(call: SysCall) -> SysCallResult {
|
||||||
let mut ret = crate::Result::Ok;
|
let mut args = call.as_args();
|
||||||
let args = call.as_args();
|
|
||||||
unsafe {
|
unsafe {
|
||||||
_xous_syscall(
|
core::arch::asm!(
|
||||||
args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7], &mut ret,
|
"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),
|
crate::Result::Error(e) => Err(e),
|
||||||
other => Ok(other),
|
other => Ok(other),
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue