2010-03-04 18:29:38 +00:00
|
|
|
/*
|
|
|
|
* Generic syscall call.
|
|
|
|
* Upon entry
|
|
|
|
* %eax: system call number
|
|
|
|
* %ebx: arg0 to system call
|
|
|
|
* %ecx: arg..
|
|
|
|
* %edx: arg..
|
|
|
|
* %esi: arg..
|
|
|
|
* %edi: arg..
|
|
|
|
* We push these (to save them) load them up with the
|
|
|
|
* values from the calling frame (not all will actually be valid)
|
|
|
|
* and make the syscall.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <sys/linux-syscalls.h>
|
|
|
|
|
|
|
|
.text
|
|
|
|
.type syscall, @function
|
|
|
|
.globl syscall
|
|
|
|
.align 4
|
|
|
|
|
|
|
|
syscall:
|
|
|
|
push %ebx
|
|
|
|
push %esi
|
|
|
|
push %edi
|
2011-03-29 04:00:38 +00:00
|
|
|
mov 16(%esp),%eax
|
|
|
|
mov 20(%esp),%ebx
|
|
|
|
mov 24(%esp),%ecx
|
|
|
|
mov 28(%esp),%edx
|
|
|
|
mov 32(%esp),%esi
|
|
|
|
mov 36(%esp),%edi
|
2010-03-04 18:29:38 +00:00
|
|
|
|
|
|
|
int $0x80
|
|
|
|
|
2011-06-17 21:37:50 +00:00
|
|
|
cmpl $-4095, %eax
|
2010-03-04 18:29:38 +00:00
|
|
|
jb 1f
|
|
|
|
negl %eax
|
|
|
|
pushl %eax
|
|
|
|
call __set_errno
|
|
|
|
addl $4, %esp
|
|
|
|
orl $-1, %eax
|
|
|
|
1:
|
|
|
|
pop %edi
|
|
|
|
pop %esi
|
|
|
|
pop %ebx
|
|
|
|
ret
|