feat: add support for aarch64 timer/interrupts, port MontaukOS userspace
This commit is contained in:
1 parent
8b6379fb7e
commit
8c09ccef66
101 files changed
+1720
-629
No files matched your search
@@ -419,6 +419,8 @@ typedef struct {
|
||||
Raw syscall wrappers
|
||||
==================================================================== */
|
||||
|
||||
#if defined(__x86_64__)
|
||||
|
||||
static inline long _mtk_syscall0(long nr) {
|
||||
long ret;
|
||||
__asm__ volatile("syscall" : "=a"(ret) : "a"(nr)
|
||||
@@ -491,6 +493,66 @@ static inline long _mtk_syscall5(long nr, long a1, long a2, long a3, long a4, lo
|
||||
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;
|
||||
}
|
||||
|
||||
static inline long _mtk_syscall5(long nr, long a1, long a2, long a3, long a4, long a5) {
|
||||
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;
|
||||
register long x4 __asm__("x4") = a5;
|
||||
__asm__ volatile("svc #0" : "+r"(x0) : "r"(x8), "r"(x1), "r"(x2), "r"(x3), "r"(x4) : "memory");
|
||||
return x0;
|
||||
}
|
||||
|
||||
#else
|
||||
#error "unsupported architecture"
|
||||
#endif
|
||||
|
||||
/* ====================================================================
|
||||
Process management
|
||||
==================================================================== */
|
||||
|
||||
@@ -7,7 +7,11 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef unsigned long jmp_buf[8];
|
||||
#if defined(__aarch64__)
|
||||
typedef unsigned long jmp_buf[21]; /* x19-x30, sp, d8-d15 */
|
||||
#else
|
||||
typedef unsigned long jmp_buf[8]; /* rbx, rbp, r12-r15, rsp, rip */
|
||||
#endif
|
||||
|
||||
int setjmp(jmp_buf env);
|
||||
void longjmp(jmp_buf env, int val) __attribute__((noreturn));
|
||||
|
||||
Reference in new issue
Block a user