#[derive(Copy, Clone, Debug, Eq, Ord, PartialEq, PartialOrd)]
#[must_use]
pub struct Result(u32);
impl Result {
#[inline]
pub const fn new(register_r0: u32) -> Self {
Self(register_r0)
}
#[inline]
pub const fn as_u32_unchecked(self) -> u32 {
self.0
}
#[inline]
pub const fn as_usize_unchecked(self) -> usize {
self.0 as usize
}
}
single_register_result32!(Result);
#[cfg(not(doc))]
#[macro_export]
macro_rules! syscall {
($nr:expr $(,)?) => {{
let mut out_r0;
core::arch::asm!(
"svc #0",
in("r7") u32::from(Into::<$crate::Syscall>::into($nr)),
lateout("r0") out_r0,
options(nostack),
);
$crate::arch::arm::Result::new(out_r0)
}};
($nr:expr, $a1:expr $(,)?) => {{
let mut out_r0;
core::arch::asm!(
"svc #0",
in("r7") u32::from(Into::<$crate::Syscall>::into($nr)),
in("r0") $a1,
lateout("r0") out_r0,
options(nostack),
);
$crate::arch::arm::Result::new(out_r0)
}};
($nr:expr, $a1:expr, $a2:expr $(,)?) => {{
let mut out_r0;
core::arch::asm!(
"svc #0",
in("r7") u32::from(Into::<$crate::Syscall>::into($nr)),
in("r0") $a1,
in("r1") $a2,
lateout("r0") out_r0,
options(nostack),
);
$crate::arch::arm::Result::new(out_r0)
}};
($nr:expr, $a1:expr, $a2:expr, $a3:expr $(,)?) => {{
let mut out_r0;
core::arch::asm!(
"svc #0",
in("r7") u32::from(Into::<$crate::Syscall>::into($nr)),
in("r0") $a1,
in("r1") $a2,
in("r2") $a3,
lateout("r0") out_r0,
options(nostack),
);
$crate::arch::arm::Result::new(out_r0)
}};
($nr:expr, $a1:expr, $a2:expr, $a3:expr, $a4:expr $(,)?) => {{
let mut out_r0;
core::arch::asm!(
"svc #0",
in("r7") u32::from(Into::<$crate::Syscall>::into($nr)),
in("r0") $a1,
in("r1") $a2,
in("r2") $a3,
in("r3") $a4,
lateout("r0") out_r0,
options(nostack),
);
$crate::arch::arm::Result::new(out_r0)
}};
($nr:expr, $a1:expr, $a2:expr, $a3:expr, $a4:expr, $a5:expr $(,)?) => {{
let mut out_r0;
core::arch::asm!(
"svc #0",
in("r7") u32::from(Into::<$crate::Syscall>::into($nr)),
in("r0") $a1,
in("r1") $a2,
in("r2") $a3,
in("r3") $a4,
in("r4") $a5,
lateout("r0") out_r0,
options(nostack),
);
$crate::arch::arm::Result::new(out_r0)
}};
($nr:expr, $a1:expr, $a2:expr, $a3:expr, $a4:expr, $a5:expr, $a6:expr $(,)?) => {{
let mut out_r0;
core::arch::asm!(
"svc #0",
in("r7") u32::from(Into::<$crate::Syscall>::into($nr)),
in("r0") $a1,
in("r1") $a2,
in("r2") $a3,
in("r3") $a4,
in("r4") $a5,
in("r5") $a6,
lateout("r0") out_r0,
options(nostack),
);
$crate::arch::arm::Result::new(out_r0)
}};
}