• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Generic syscall call.
3 * Upon entry
4 *	%eax: system call number
5 *	%ebx: arg0 to system call
6 *	%ecx: arg..
7 *	%edx: arg..
8 *	%esi: arg..
9 *	%edi: arg..
10 * We push these (to save them) load them up with the
11 * values from the calling frame (not all will actually be valid)
12 * and make the syscall.
13 */
14
15#include <sys/linux-syscalls.h>
16
17    .text
18    .type syscall, @function
19    .globl syscall
20    .align 4
21
22syscall:
23    push    %ebx
24    push    %esi
25    push    %edi
26    mov     16(%esp),%eax
27    mov     20(%esp),%ebx
28    mov     24(%esp),%ecx
29    mov     28(%esp),%edx
30    mov     32(%esp),%esi
31    mov     36(%esp),%edi
32
33    int     $0x80
34
35    cmpl    $-4095, %eax
36    jb      1f
37    negl    %eax
38    pushl   %eax
39    call    __set_errno
40    addl    $4, %esp
41    orl     $-1, %eax
421:
43    pop    %edi
44    pop    %esi
45    pop    %ebx
46    ret
47