Ignore:
Timestamp:
Dec 5, 2017, 4:20:07 PM (6 years ago)
Author:
alain
Message:

Fix several bugs in the fork() syscall.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/kernel/kern/do_syscall.c

    r407 r408  
    2929#include <printk.h>
    3030#include <syscalls.h>
     31#include <shared_syscalls.h>
    3132
    32 /////////////////////////////////////////////////////////////////////////////////////////////
     33///////////////////////////////////////////////////////////////////////////////////////
    3334// This ƒonction should never be called...
    34 /////////////////////////////////////////////////////////////////////////////////////////////
     35///////////////////////////////////////////////////////////////////////////////////////
    3536static int sys_undefined()
    3637{
     
    3940}
    4041
    41 /////////////////////////////////////////////////////////////////////////////////////////////
     42///////////////////////////////////////////////////////////////////////////////////////
    4243// This array of pointers define the kernel functions implementing the syscalls.
    4344// It must be kept consistent with the enum in "shared_syscalls.h" file.
    44 /////////////////////////////////////////////////////////////////////////////////////////////
     45///////////////////////////////////////////////////////////////////////////////////////
    4546
    4647typedef int (*sys_func_t) ();
     
    5960    sys_mutex,              // 9
    6061
    61     sys_undefined,          // 10
     62    sys_exit,               // 10
    6263    sys_munmap,             // 11
    6364    sys_open,               // 12
     
    101102};
    102103
     104////////////////////////////////////
     105char * syscall_str( uint32_t index )
     106{
     107        if     ( index == SYS_THREAD_EXIT    ) return "THREAD_EXIT";      // 0
     108        else if( index == SYS_THREAD_YIELD   ) return "THREAD_YIELD";     // 1
     109        else if( index == SYS_THREAD_CREATE  ) return "THREAD_CREATE";    // 2
     110        else if( index == SYS_THREAD_JOIN    ) return "THREAD_JOIN";      // 3
     111        else if( index == SYS_THREAD_DETACH  ) return "THREAD_DETACH";    // 4
     112        else if( index == SYS_SEM            ) return "SEM";              // 6
     113        else if( index == SYS_CONDVAR        ) return "CONDVAR";          // 7
     114        else if( index == SYS_BARRIER        ) return "BARRIER";          // 8
     115        else if( index == SYS_MUTEX          ) return "MUTEX";            // 9
     116
     117    else if( index == SYS_EXIT           ) return "EXIT";             // 10
     118    else if( index == SYS_MUNMAP         ) return "MUNMAP";           // 11
     119        else if( index == SYS_OPEN           ) return "OPEN";             // 12
     120        else if( index == SYS_MMAP           ) return "MMAP";             // 13
     121        else if( index == SYS_READ           ) return "READ";             // 14
     122        else if( index == SYS_WRITE          ) return "WRITE";            // 15
     123        else if( index == SYS_LSEEK          ) return "LSEEK";            // 16
     124        else if( index == SYS_CLOSE          ) return "CLOSE";            // 17
     125        else if( index == SYS_UNLINK         ) return "UNLINK";           // 18
     126        else if( index == SYS_PIPE           ) return "PIPE";             // 19
     127
     128        else if( index == SYS_CHDIR          ) return "CHDIR";            // 20
     129        else if( index == SYS_MKDIR          ) return "MKDIR";            // 21
     130        else if( index == SYS_MKFIFO         ) return "MKFIFO";           // 22   
     131        else if( index == SYS_OPENDIR        ) return "OPENDIR";          // 23
     132        else if( index == SYS_READDIR        ) return "READDIR";          // 24
     133        else if( index == SYS_CLOSEDIR       ) return "CLOSEDIR";         // 25
     134        else if( index == SYS_GETCWD         ) return "GETCWD";           // 26
     135        else if( index == SYS_ALARM          ) return "ALARM";            // 28
     136        else if( index == SYS_RMDIR          ) return "RMDIR";            // 29
     137
     138        else if( index == SYS_UTLS           ) return "UTLS";             // 30
     139        else if( index == SYS_CHMOD          ) return "CHMOD";            // 31
     140        else if( index == SYS_SIGNAL         ) return "SIGNAL";           // 32
     141        else if( index == SYS_TIMEOFDAY      ) return "TIMEOFDAY";        // 33
     142        else if( index == SYS_KILL           ) return "KILL";             // 34
     143        else if( index == SYS_GETPID         ) return "GETPID";           // 35
     144        else if( index == SYS_FORK           ) return "FORK";             // 36
     145        else if( index == SYS_EXEC           ) return "EXEC";             // 37
     146        else if( index == SYS_STAT           ) return "STAT";             // 38
     147        else if( index == SYS_TRACE          ) return "TRACE";            // 39
     148
     149    else if( index == SYS_GET_CONFIG     ) return "GET_CONFIG";       // 40
     150    else if( index == SYS_GET_CORE       ) return "GET_CORE";         // 41
     151    else if( index == SYS_GET_CYCLE      ) return "GET_CYCLE";        // 42
     152    else if( index == SYS_GET_SCHED      ) return "GET_SCHED";        // 43
     153    else if( index == SYS_PANIC          ) return "PANIC";            // 44
     154        else if( index == SYS_SLEEP          ) return "SLEEP";            // 45
     155        else if( index == SYS_WAKEUP         ) return "WAKEUP";           // 46
     156
     157    else                                   return "undefined";   
     158}
     159
     160
    103161//////////////////////////////////
    104162reg_t do_syscall( thread_t * this,
     
    109167                          reg_t      service_num )
    110168{
    111         int           error = 0;
     169        int  error = 0;
    112170       
    113171    // update user time
    114172        thread_user_time_update( this );
    115173
    116     // enable interrupts
    117         hal_enable_irq( NULL );
    118  
    119174    // check syscall index
    120175        if( service_num >= SYSCALLS_NR )
     
    128183        }
    129184
    130 #if( CONFIG_SYSCALL_DEBUG & 0x1)
    131 printk("\n[DBG] %s : pid = %x / trdid = %x / service #%d\n"
    132 "      arg0 = %x / arg1 = %x / arg2 = %x / arg3 = %x\n",
    133 __FUNCTION__ , this->process->pid , this->trdid , service_num , arg0 , arg1 , arg2 , arg3 );
    134 #endif
    135 
    136185    // reset errno
    137186        this->errno = 0;
     
    140189        error = syscall_tbl[service_num] ( arg0 , arg1 , arg2 , arg3 );
    141190
    142     // disable interrupt
    143         hal_disable_irq( NULL );
    144 
    145191    // update kernel time
    146192        thread_kernel_time_update( this );
Note: See TracChangeset for help on using the changeset viewer.