Support to multi-threading and pthread interface (POSIX.1-2008) (#23)
[lunaix-os.git] / lunaix-os / arch / i386 / syscall.S
index ac3fe80d4a75afb9a7d93e643324309f62345d58..bfbf740f940e83971468b62c39fa62395d5a984c 100644 (file)
         .long __lxsys_sys_mmap
         .long __lxsys_munmap
         .long __lxsys_execve
+        .long __lxsys_fstat         /* 55 */
+        .long __lxsys_pollctl
+        .long __lxsys_th_create
+        .long __lxsys_th_self
+        .long __lxsys_th_exit
+        .long __lxsys_th_join       /* 60 */
+        .long __lxsys_th_kill
+        .long __lxsys_th_detach
+        .long __lxsys_th_sigmask
         2:
         .rept __SYSCALL_MAX - (2b - 1b)/4
             .long 0
         .endr
 
-.global syscall_hndlr
 
 .section .text
+    .type syscall_hndlr, @function
+    .global syscall_hndlr
     syscall_hndlr:
         pushl %ebp
-        movl 8(%esp), %ebp          // isr_param*
+        movl %esp, %ebp
+        movl 8(%esp), %ebx          // isr_param*
 
-        addl $4, %ebp
-        movl (%ebp), %eax          /* eax: call code as well as the return value from syscall */
+        addl $4, %ebx
+        movl (%ebx), %eax          /* eax: call code as well as the return value from syscall */
         cmpl $__SYSCALL_MAX, %eax
         jae 2f
 
         jne 1f
     2:    
         neg   %eax
+        movl %ebp, %esp
         popl  %ebp
         ret
+
     1:
-        pushl 24(%ebp)      /* esi - #5 arg */
-        pushl 16(%ebp)      /* edi - #4 arg */
-        pushl 12(%ebp)      /* edx - #3 arg */
-        pushl 8(%ebp)       /* ecx - #2 arg */
-        pushl 4(%ebp)       /* ebx - #1 arg */
+        pushl %ebx
+        pushl 24(%ebx)      /* esi - #5 arg */
+        pushl 16(%ebx)      /* edi - #4 arg */
+        pushl 12(%ebx)      /* edx - #3 arg */
+        pushl 8(%ebx)       /* ecx - #2 arg */
+        pushl 4(%ebx)       /* ebx - #1 arg */
         
         call *(%eax)
 
-        movl %eax, (%ebp)    /* save the return value */
-
         addl $20, %esp      /* remove the parameters from stack */
-
+        
+        popl %ebx
+        movl %eax, (%ebx)    /* save the return value */
+        
+        movl %ebp, %esp
         popl %ebp
         
         ret
\ No newline at end of file