Bruce Beare | 3c543e1 | 2010-03-04 10:29:38 -0800 | [diff] [blame] | 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 | |
| 22 | syscall: |
Bruce Beare | 3c543e1 | 2010-03-04 10:29:38 -0800 | [diff] [blame] | 23 | push %ebx |
Bruce Beare | 3c543e1 | 2010-03-04 10:29:38 -0800 | [diff] [blame] | 24 | push %esi |
| 25 | push %edi |
Kan-Ru Chen | 8488efa | 2011-03-29 12:00:38 +0800 | [diff] [blame] | 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 |
Bruce Beare | 3c543e1 | 2010-03-04 10:29:38 -0800 | [diff] [blame] | 32 | |
| 33 | int $0x80 |
| 34 | |
| 35 | cmpl $-129, %eax |
| 36 | jb 1f |
| 37 | negl %eax |
| 38 | pushl %eax |
| 39 | call __set_errno |
| 40 | addl $4, %esp |
| 41 | orl $-1, %eax |
| 42 | 1: |
| 43 | pop %edi |
| 44 | pop %esi |
Bruce Beare | 3c543e1 | 2010-03-04 10:29:38 -0800 | [diff] [blame] | 45 | pop %ebx |
Bruce Beare | 3c543e1 | 2010-03-04 10:29:38 -0800 | [diff] [blame] | 46 | ret |