Make x86_64 work (pre-syscalls)
This commit is contained in:
+37
-26
@@ -11,50 +11,61 @@ use crate::{
|
||||
},
|
||||
};
|
||||
use core::time::Duration;
|
||||
use core::arch::asm;
|
||||
|
||||
// TODO document the syscall ABI
|
||||
|
||||
// TODO move this to libusr
|
||||
macro_rules! syscall {
|
||||
($num:expr) => {{
|
||||
let mut res: usize;
|
||||
asm!("svc #0", out("x0") res, in("x8") $num.repr(), options(nostack));
|
||||
res
|
||||
// let mut res: usize;
|
||||
// asm!("svc #0", out("x0") res, in("x8") $num.repr(), options(nostack));
|
||||
// res
|
||||
loop {}
|
||||
0
|
||||
}};
|
||||
($num:expr, $a0:expr) => {{
|
||||
let mut res: usize = $a0;
|
||||
asm!("svc #0",
|
||||
inout("x0") res,
|
||||
in("x8") $num.repr(), options(nostack));
|
||||
res
|
||||
// let mut res: usize = $a0;
|
||||
// asm!("svc #0",
|
||||
// inout("x0") res,
|
||||
// in("x8") $num.repr(), options(nostack));
|
||||
// res
|
||||
loop {}
|
||||
0
|
||||
}};
|
||||
($num:expr, $a0:expr, $a1:expr) => {{
|
||||
let mut res: usize = $a0;
|
||||
asm!("svc #0",
|
||||
inout("x0") res, in("x1") $a1,
|
||||
in("x8") $num.repr(), options(nostack));
|
||||
res
|
||||
// let mut res: usize = $a0;
|
||||
// asm!("svc #0",
|
||||
// inout("x0") res, in("x1") $a1,
|
||||
// in("x8") $num.repr(), options(nostack));
|
||||
// res
|
||||
loop {}
|
||||
0
|
||||
}};
|
||||
($num:expr, $a0:expr, $a1:expr, $a2:expr) => {{
|
||||
let mut res: usize = $a0;
|
||||
asm!("svc #0",
|
||||
inout("x0") res, in("x1") $a1, in("x2") $a2,
|
||||
in("x8") $num.repr(), options(nostack));
|
||||
asm!("syscall",
|
||||
inout("rax") res, in("rdi") $a1, in("rsi") $a2,
|
||||
in("rdx") $num.repr(), options(nostack));
|
||||
res
|
||||
}};
|
||||
($num:expr, $a0:expr, $a1:expr, $a2:expr, $a3:expr) => {{
|
||||
let mut res: usize = $a0;
|
||||
asm!("svc #0",
|
||||
inout("x0") res, in("x1") $a1, in("x2") $a2,
|
||||
in("x3") $a3, in("x8") $num.repr(), options(nostack));
|
||||
res
|
||||
// let mut res: usize = $a0;
|
||||
// asm!("svc #0",
|
||||
// inout("x0") res, in("x1") $a1, in("x2") $a2,
|
||||
// in("x3") $a3, in("x8") $num.repr(), options(nostack));
|
||||
// res
|
||||
loop {}
|
||||
0
|
||||
}};
|
||||
($num:expr, $a0:expr, $a1:expr, $a2:expr, $a3:expr, $a4:expr) => {{
|
||||
let mut res: usize = $a0;
|
||||
asm!("svc #0",
|
||||
inout("x0") res, in("x1") $a1, in("x2") $a2,
|
||||
in("x3") $a3, in("x4") $a4, in("x8") $num.repr(), options(nostack));
|
||||
res
|
||||
// let mut res: usize = $a0;
|
||||
// asm!("svc #0",
|
||||
// inout("x0") res, in("x1") $a1, in("x2") $a2,
|
||||
// in("x3") $a3, in("x4") $a4, in("x8") $num.repr(), options(nostack));
|
||||
// res
|
||||
loop {}
|
||||
0
|
||||
}};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user