From 3705cf387ec9a87f0330766ccc933ff53f0bf530 Mon Sep 17 00:00:00 2001 From: Eugen Wissner Date: Fri, 8 Sep 2017 19:52:17 +0200 Subject: Add syscalls to x86-64 linux --- arch/x64/linux/syscall.S | 65 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 arch/x64/linux/syscall.S (limited to 'arch/x64/linux/syscall.S') diff --git a/arch/x64/linux/syscall.S b/arch/x64/linux/syscall.S new file mode 100644 index 0000000..9261d87 --- /dev/null +++ b/arch/x64/linux/syscall.S @@ -0,0 +1,65 @@ +/* +The kernel uses the following registers: +%rdi, %rsi, %rdx, %r8, %r9, %r10 + +The number of the syscall is passed in %rax. + +A syscall clobbers: +%rax, %rcx, %r11 + +The returned value is placed in %rax. +*/ + .text + + .globl syscall1 + .type syscall1, @function + +syscall1: + movq %rsi, %rax // Syscall number. + + syscall + + ret + + + .globl syscall2 + .type syscall2, @function + +syscall2: + // Store registers. + movq %rdi, %r8 + + movq %rdx, %rax // Syscall number. + + // Syscall arguments. + movq %rsi, %rdi + movq %r8, %rsi + + syscall + + // Restore registers. + movq %rdi, %rsi + movq %r8, %rdi + + ret + + + .globl syscall3 + .type syscall3, @function + +syscall3: + // Store registers. + movq %rdi, %r8 + + movq %rcx, %rax // Syscall number. + + // Syscall arguments. + movq %rdx, %rdi + movq %r8, %rdx + + syscall + + // Restore registers. + movq %r8, %rdi + + ret -- cgit v1.2.3