feat: add support for aarch64 timer/interrupts, port MontaukOS userspace

This commit is contained in:
daniel committed 2026-10-25 08:27:09 +01:00
1 parent 8b6379fb7e
commit 8c09ccef66
101 files changed
+1720 -629

No files matched your search

+51
View File
@@ -32,6 +32,8 @@
Raw syscall wrappers (C versions matching kernel ABI)
======================================================================== */
#if defined(__x86_64__)
static inline long _mtk_syscall0(long nr) {
long ret;
__asm__ volatile("syscall" : "=a"(ret) : "a"(nr)
@@ -89,6 +91,55 @@ static inline long _mtk_syscall4(long nr, long a1, long a2, long a3, long a4) {
return ret;
}
#elif defined(__aarch64__)
// AArch64: number in x8, arguments in x0-x5, `svc #0`; the kernel
// preserves every register except x0, which carries the result.
static inline long _mtk_syscall0(long nr) {
register long x8 __asm__("x8") = nr;
register long x0 __asm__("x0");
__asm__ volatile("svc #0" : "=r"(x0) : "r"(x8) : "memory");
return x0;
}
static inline long _mtk_syscall1(long nr, long a1) {
register long x8 __asm__("x8") = nr;
register long x0 __asm__("x0") = a1;
__asm__ volatile("svc #0" : "+r"(x0) : "r"(x8) : "memory");
return x0;
}
static inline long _mtk_syscall2(long nr, long a1, long a2) {
register long x8 __asm__("x8") = nr;
register long x0 __asm__("x0") = a1;
register long x1 __asm__("x1") = a2;
__asm__ volatile("svc #0" : "+r"(x0) : "r"(x8), "r"(x1) : "memory");
return x0;
}
static inline long _mtk_syscall3(long nr, long a1, long a2, long a3) {
register long x8 __asm__("x8") = nr;
register long x0 __asm__("x0") = a1;
register long x1 __asm__("x1") = a2;
register long x2 __asm__("x2") = a3;
__asm__ volatile("svc #0" : "+r"(x0) : "r"(x8), "r"(x1), "r"(x2) : "memory");
return x0;
}
static inline long _mtk_syscall4(long nr, long a1, long a2, long a3, long a4) {
register long x8 __asm__("x8") = nr;
register long x0 __asm__("x0") = a1;
register long x1 __asm__("x1") = a2;
register long x2 __asm__("x2") = a3;
register long x3 __asm__("x3") = a4;
__asm__ volatile("svc #0" : "+r"(x0) : "r"(x8), "r"(x1), "r"(x2), "r"(x3) : "memory");
return x0;
}
#else
#error "unsupported architecture"
#endif
/* Syscall numbers */
#define SYS_EXIT 0
#define SYS_YIELD 1