2013-01-12 13:48:27 -05:00
|
|
|
/*******************************************************************************
|
|
|
|
|
2014-02-18 10:51:48 -05:00
|
|
|
Copyright(C) Jonas 'Sortie' Termansen 2013, 2014.
|
2013-01-12 13:48:27 -05:00
|
|
|
|
2013-07-10 09:26:01 -04:00
|
|
|
This file is part of the Sortix C Library.
|
2013-01-12 13:48:27 -05:00
|
|
|
|
2013-07-10 09:26:01 -04:00
|
|
|
The Sortix C Library is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU Lesser General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or (at your
|
|
|
|
option) any later version.
|
2013-01-12 13:48:27 -05:00
|
|
|
|
2013-07-10 09:26:01 -04:00
|
|
|
The Sortix C Library is distributed in the hope that it will be useful, but
|
|
|
|
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
|
|
|
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
|
|
|
License for more details.
|
2013-01-12 13:48:27 -05:00
|
|
|
|
2013-07-10 09:26:01 -04:00
|
|
|
You should have received a copy of the GNU Lesser General Public License
|
|
|
|
along with the Sortix C Library. If not, see <http://www.gnu.org/licenses/>.
|
2013-01-12 13:48:27 -05:00
|
|
|
|
2013-12-28 15:00:15 -05:00
|
|
|
x64/syscall.S
|
2013-07-10 09:26:01 -04:00
|
|
|
Function for performing system calls.
|
2013-01-12 13:48:27 -05:00
|
|
|
|
|
|
|
*******************************************************************************/
|
|
|
|
|
|
|
|
# x86_64 system call conventions:
|
|
|
|
# interrupt 128
|
|
|
|
# system call number: %rax
|
|
|
|
# parameters: %rdi, %rsi, %rdx, %rcx, %r8, %r9
|
|
|
|
# return value: %rax, %rdx
|
|
|
|
# return errno: %rcx
|
|
|
|
# clobbered: %rdi, %rsi, %r8, %r9, %r10, %r11
|
|
|
|
# preserved: %rbx, %rsp, %rbp, %r12, %r13, %r14, %r15
|
|
|
|
|
|
|
|
.global asm_syscall
|
|
|
|
asm_syscall: /* syscall num in %rax. */
|
|
|
|
push %rbp
|
|
|
|
mov %rsp, %rbp
|
|
|
|
int $0x80
|
|
|
|
test %ecx, %ecx
|
2014-02-18 10:51:48 -05:00
|
|
|
jz 1f
|
|
|
|
mov %fs:0, %rsi
|
|
|
|
mov %ecx, errno@tpoff(%rsi)
|
2013-01-12 13:48:27 -05:00
|
|
|
1:
|
|
|
|
pop %rbp
|
|
|
|
ret
|
2013-05-22 16:06:18 -04:00
|
|
|
.size asm_syscall, .-asm_syscall
|