mirror of
https://github.com/SerenityOS/serenity.git
synced 2025-01-23 01:41:59 -05:00
Kernel: Implement userspace support for syscalls on AARCH64
There are no guarantees that the final syscall API will look like this but at least for now this lets us compile the userland binaries.
This commit is contained in:
parent
a650c74b27
commit
5921df75b6
1 changed files with 56 additions and 6 deletions
|
@ -483,7 +483,7 @@ struct SC_chmod_params {
|
|||
void initialize();
|
||||
int sync();
|
||||
|
||||
# if ARCH(I386) || ARCH(X86_64)
|
||||
# if ARCH(I386) || ARCH(X86_64) || ARCH(AARCH64)
|
||||
inline uintptr_t invoke(Function function)
|
||||
{
|
||||
uintptr_t result;
|
||||
|
@ -492,11 +492,19 @@ inline uintptr_t invoke(Function function)
|
|||
: "=a"(result)
|
||||
: "a"(function)
|
||||
: "memory");
|
||||
# else
|
||||
# elif ARCH(X86_64)
|
||||
asm volatile("syscall"
|
||||
: "=a"(result)
|
||||
: "a"(function)
|
||||
: "rcx", "r11", "memory");
|
||||
# elif ARCH(AARCH64)
|
||||
register uintptr_t x0 asm("x0");
|
||||
register uintptr_t x8 asm("x8") = function;
|
||||
asm volatile("svc #0"
|
||||
: "=r"(x0)
|
||||
: "r"(x8)
|
||||
: "memory");
|
||||
result = x0;
|
||||
# endif
|
||||
return result;
|
||||
}
|
||||
|
@ -510,11 +518,20 @@ inline uintptr_t invoke(Function function, T1 arg1)
|
|||
: "=a"(result)
|
||||
: "a"(function), "d"((uintptr_t)arg1)
|
||||
: "memory");
|
||||
# else
|
||||
# elif ARCH(X86_64)
|
||||
asm volatile("syscall"
|
||||
: "=a"(result)
|
||||
: "a"(function), "d"((uintptr_t)arg1)
|
||||
: "rcx", "r11", "memory");
|
||||
# else
|
||||
register uintptr_t x0 asm("x0");
|
||||
register uintptr_t x1 asm("x1") = arg1;
|
||||
register uintptr_t x8 asm("x8") = function;
|
||||
asm volatile("svc #0"
|
||||
: "=r"(x0)
|
||||
: "r"(x1), "r"(x8)
|
||||
: "memory");
|
||||
result = x0;
|
||||
# endif
|
||||
return result;
|
||||
}
|
||||
|
@ -528,11 +545,21 @@ inline uintptr_t invoke(Function function, T1 arg1, T2 arg2)
|
|||
: "=a"(result)
|
||||
: "a"(function), "d"((uintptr_t)arg1), "c"((uintptr_t)arg2)
|
||||
: "memory");
|
||||
# else
|
||||
# elif ARCH(X86_64)
|
||||
asm volatile("syscall"
|
||||
: "=a"(result)
|
||||
: "a"(function), "d"((uintptr_t)arg1), "D"((uintptr_t)arg2)
|
||||
: "rcx", "r11", "memory");
|
||||
# else
|
||||
register uintptr_t x0 asm("x0");
|
||||
register uintptr_t x1 asm("x1") = arg1;
|
||||
register uintptr_t x2 asm("x2") = arg2;
|
||||
register uintptr_t x8 asm("x8") = function;
|
||||
asm volatile("svc #0"
|
||||
: "=r"(x0)
|
||||
: "r"(x1), "r"(x2), "r"(x8)
|
||||
: "memory");
|
||||
result = x0;
|
||||
# endif
|
||||
return result;
|
||||
}
|
||||
|
@ -546,11 +573,22 @@ inline uintptr_t invoke(Function function, T1 arg1, T2 arg2, T3 arg3)
|
|||
: "=a"(result)
|
||||
: "a"(function), "d"((uintptr_t)arg1), "c"((uintptr_t)arg2), "b"((uintptr_t)arg3)
|
||||
: "memory");
|
||||
# else
|
||||
# elif ARCH(X86_64)
|
||||
asm volatile("syscall"
|
||||
: "=a"(result)
|
||||
: "a"(function), "d"((uintptr_t)arg1), "D"((uintptr_t)arg2), "b"((uintptr_t)arg3)
|
||||
: "rcx", "r11", "memory");
|
||||
# else
|
||||
register uintptr_t x0 asm("x0");
|
||||
register uintptr_t x1 asm("x1") = arg1;
|
||||
register uintptr_t x2 asm("x2") = arg2;
|
||||
register uintptr_t x3 asm("x3") = arg3;
|
||||
register uintptr_t x8 asm("x8") = function;
|
||||
asm volatile("svc #0"
|
||||
: "=r"(x0)
|
||||
: "r"(x1), "r"(x2), "r"(x3), "r"(x8)
|
||||
: "memory");
|
||||
result = x0;
|
||||
# endif
|
||||
return result;
|
||||
}
|
||||
|
@ -564,11 +602,23 @@ inline uintptr_t invoke(Function function, T1 arg1, T2 arg2, T3 arg3, T4 arg4)
|
|||
: "=a"(result)
|
||||
: "a"(function), "d"((uintptr_t)arg1), "c"((uintptr_t)arg2), "b"((uintptr_t)arg3), "S"((uintptr_t)arg4)
|
||||
: "memory");
|
||||
# else
|
||||
# elif ARCH(X86_64)
|
||||
asm volatile("syscall"
|
||||
: "=a"(result)
|
||||
: "a"(function), "d"((uintptr_t)arg1), "D"((uintptr_t)arg2), "b"((uintptr_t)arg3), "S"((uintptr_t)arg4)
|
||||
: "memory");
|
||||
# else
|
||||
register uintptr_t x0 asm("x0");
|
||||
register uintptr_t x1 asm("x1") = arg1;
|
||||
register uintptr_t x2 asm("x2") = arg2;
|
||||
register uintptr_t x3 asm("x3") = arg3;
|
||||
register uintptr_t x4 asm("x4") = arg4;
|
||||
register uintptr_t x8 asm("x8") = function;
|
||||
asm volatile("svc #0"
|
||||
: "=r"(x0)
|
||||
: "r"(x1), "r"(x2), "r"(x3), "r"(x4), "r"(x8)
|
||||
: "memory");
|
||||
result = x0;
|
||||
# endif
|
||||
return result;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue