summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBruce Beare <brucex.j.beare@intel.com>2010-03-04 10:29:38 -0800
committerBruce Beare <brucex.j.beare@intel.com>2010-03-04 10:29:38 -0800
commit3c543e1da9a2780a70b25299f39734bf0a18c4a0 (patch)
tree07780890d546321d9426758f629f5a951b5a2eeb
parent58060c50bc4228a7d0253338cae0437211759959 (diff)
downloadbionic-3c543e1da9a2780a70b25299f39734bf0a18c4a0.zip
bionic-3c543e1da9a2780a70b25299f39734bf0a18c4a0.tar.gz
bionic-3c543e1da9a2780a70b25299f39734bf0a18c4a0.tar.bz2
x86 syscall system call implementation
-rw-r--r--libc/Android.mk1
-rw-r--r--libc/arch-x86/bionic/syscall.S52
2 files changed, 53 insertions, 0 deletions
diff --git a/libc/Android.mk b/libc/Android.mk
index bafc118..9013e9a 100644
--- a/libc/Android.mk
+++ b/libc/Android.mk
@@ -329,6 +329,7 @@ libc_common_src_files += \
arch-x86/bionic/setjmp.S \
arch-x86/bionic/_setjmp.S \
arch-x86/bionic/vfork.S \
+ arch-x86/bionic/syscall.S \
arch-x86/string/bzero.S \
arch-x86/string/memset.S \
arch-x86/string/memcmp.S \
diff --git a/libc/arch-x86/bionic/syscall.S b/libc/arch-x86/bionic/syscall.S
new file mode 100644
index 0000000..71abe6b
--- /dev/null
+++ b/libc/arch-x86/bionic/syscall.S
@@ -0,0 +1,52 @@
+/*
+ * 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 %eax
+ push %ebx
+ push %ecx
+ push %edx
+ push %esi
+ push %edi
+ mov 28(%esp),%eax
+ mov 32(%esp),%ebx
+ mov 36(%esp),%ecx
+ mov 40(%esp),%edx
+ mov 44(%esp),%esi
+ mov 48(%esp),%edi
+
+ int $0x80
+
+ cmpl $-129, %eax
+ jb 1f
+ negl %eax
+ pushl %eax
+ call __set_errno
+ addl $4, %esp
+ orl $-1, %eax
+1:
+ pop %edi
+ pop %esi
+ pop %edx
+ pop %ecx
+ pop %ebx
+ pop %eax
+ ret