summaryrefslogtreecommitdiff
path: root/zap/source/arm64/sys/syscall.s
diff options
context:
space:
mode:
Diffstat (limited to 'zap/source/arm64/sys/syscall.s')
-rw-r--r--zap/source/arm64/sys/syscall.s26
1 files changed, 26 insertions, 0 deletions
diff --git a/zap/source/arm64/sys/syscall.s b/zap/source/arm64/sys/syscall.s
new file mode 100644
index 0000000..df4817d
--- /dev/null
+++ b/zap/source/arm64/sys/syscall.s
@@ -0,0 +1,26 @@
+// Copyright 2022-2023 Gabriel Jensen.
+// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
+// If a copy of the MPL was not distributed with this file, You can obtain one at <https://mozilla.org/MPL/2.0>.
+
+.globl zap_syscall
+
+zap_syscall:
+ // System calls on ARM64 use the following registers:
+ // x0 : System call identifier
+ // x1 : First parameter
+ // x2 : Second parameter
+ // x3 : Third parameter
+ // x4 : Fourth parameter
+ // x5 : Fifth parameter
+ // x6 : Sixth parameter
+ // x0 : Return value
+ mov x8,x0 // Move the first parameter (the identifier) to x8.
+ mov x0,x1 // Shift all of the other parameters to the left.
+ mov x1,x2
+ mov x2,x3
+ mov x3,x4
+ mov x4,x5
+ mov x5,x6
+ svc 0x0 // Zephyr
+ // No need to move the return value (already in x0).
+ ret