Skip to content

Instantly share code, notes, and snippets.

@coolreader18
Created May 22, 2019
Embed
What would you like to do?
inline fn wa_syscall(nr: usize) usize {
return asm volatile ("swi %[nr]"
: [ret] "={r}" (-> usize)
: [nr] "{i}" (nr)
: "memory", "r1", "r2", "r3", "r4", "r12", "lr"
);
}
inline fn wa_syscall1(nr: usize, p1: usize) usize {
return asm volatile ("swi %[nr]"
: [ret] "={r}" (-> usize)
: [nr] "{i}" (nr),
[r0] "{r}" (p1)
: "memory", "r1", "r2", "r3", "r4", "r12", "lr"
);
}
inline fn wa_syscall2(nr: usize, p1: usize, p2: usize) usize {
return asm volatile ("swi %[nr]\n"
: [ret] "={r}" (-> usize)
: [nr] "{i}" (nr),
[r0] "{r}" (p1),
[r1] "{r}" (p2)
: "memory", "r2", "r3", "r4", "r12", "lr"
);
}
inline fn wa_syscall3(nr: usize, p1: usize, p2: usize, p3: usize) usize {
return asm volatile ("swi %[nr]\n"
: [ret] "=r" (-> usize)
: [nr] "{i}" (nr),
[r0] "{r}" (p1),
[r1] "{r}" (p2),
[r2] "{r}" (p3)
: "memory", "r3", "r4", "r12", "lr"
);
}
inline fn wa_syscall4(nr: usize, p1: usize, p2: usize, p3: usize, p4: usize) usize {
return asm volatile ("swi %[nr]\n"
: [ret] "={r}" (-> usize)
: [nr] "{i}" (nr),
[r0] "{r}" (p1),
[r1] "{r}" (p2),
[r2] "{r}" (p3),
[r3] "{r}" (p4)
: "memory", "r4", "r12", "lr"
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment