blob: 4452da456b7ae4c617e36f0f7826d906b632f500 [file] [log] [blame]
Bruce Beare3c543e12010-03-04 10:29:38 -08001/*
2 * Generic syscall call.
Jin Weic164f2a2012-04-12 16:50:42 +08003 * Upon entry:
4 * %eax: system call number - caller save
5 * %ebx: arg0 to system call - callee save
6 * %ecx: arg1 - caller save
7 * %edx: arg2 - caller save
8 * %esi: arg3 - callee save
9 * %edi: arg4 - callee save
10 * %ebp: arg5 - callee save
Bruce Beare3c543e12010-03-04 10:29:38 -080011 */
12
Elliott Hughes4cdde5f2013-03-21 22:48:18 -070013#include <asm/unistd.h>
Elliott Hughesbdff26d2013-02-11 17:08:16 -080014#include <machine/asm.h>
Bruce Beare3c543e12010-03-04 10:29:38 -080015
Elliott Hughesbdff26d2013-02-11 17:08:16 -080016ENTRY(syscall)
Jin Weic164f2a2012-04-12 16:50:42 +080017 # Push the callee save registers.
Bruce Beare3c543e12010-03-04 10:29:38 -080018 push %ebx
Bruce Beare3c543e12010-03-04 10:29:38 -080019 push %esi
20 push %edi
Jin Weic164f2a2012-04-12 16:50:42 +080021 push %ebp
Bruce Beare3c543e12010-03-04 10:29:38 -080022
Jin Weic164f2a2012-04-12 16:50:42 +080023 # Load all the arguments from the calling frame.
24 # (Not all will be valid, depending on the syscall.)
25 mov 20(%esp),%eax
26 mov 24(%esp),%ebx
27 mov 28(%esp),%ecx
28 mov 32(%esp),%edx
29 mov 36(%esp),%esi
30 mov 40(%esp),%edi
31 mov 44(%esp),%ebp
32
33 # Make the system call.
Bruce Beare3c543e12010-03-04 10:29:38 -080034 int $0x80
35
Jin Weic164f2a2012-04-12 16:50:42 +080036 # Error?
Jun Nakajima5288fee2011-06-17 14:37:50 -070037 cmpl $-4095, %eax
Bruce Beare3c543e12010-03-04 10:29:38 -080038 jb 1f
Jin Weic164f2a2012-04-12 16:50:42 +080039 # Yes, so set errno.
Bruce Beare3c543e12010-03-04 10:29:38 -080040 negl %eax
41 pushl %eax
42 call __set_errno
43 addl $4, %esp
44 orl $-1, %eax
451:
Jin Weic164f2a2012-04-12 16:50:42 +080046 # Restore the callee save registers.
47 pop %ebp
Bruce Beare3c543e12010-03-04 10:29:38 -080048 pop %edi
49 pop %esi
Bruce Beare3c543e12010-03-04 10:29:38 -080050 pop %ebx
Bruce Beare3c543e12010-03-04 10:29:38 -080051 ret
Elliott Hughesbdff26d2013-02-11 17:08:16 -080052END(syscall)