Changeset 506 for trunk


Ignore:
Timestamp:
Aug 25, 2018, 6:29:34 PM (6 years ago)
Author:
viala@…
Message:

[syscalls] add interface in implementation.

Add const where possible, fix protoypes to follow interface.

Location:
trunk
Files:
38 edited

Legend:

Unmodified
Added
Removed
  • trunk/hal/tsar_mips32/drivers/soclib_nic.c

    r493 r506  
    271271        }
    272272        break;  // end READABLE
    273     } 
     273    }
    274274} // end soclib_nic_cmd()
    275275
  • trunk/kernel/syscalls/sys_alarm.c

    r473 r506  
    3030#include <core.h>
    3131
     32#include <syscalls.h>
     33
    3234////////////////////////////////
    33 int sys_alarm( uint64_t cycles )
     35int sys_alarm( uint32_t cycles )
    3436{
    3537    thread_t  * this    = CURRENT_THREAD;
  • trunk/kernel/syscalls/sys_chdir.c

    r457 r506  
    3232#include <process.h>
    3333
     34#include <syscalls.h>
     35
    3436/////////////////////////////////
    35 int sys_chdir ( char * pathname )
     37int sys_chdir ( const char * pathname )
    3638{
    3739    error_t   error;
  • trunk/kernel/syscalls/sys_chmod.c

    r457 r506  
    3030#include <process.h>
    3131
     32#include <syscalls.h>
     33
    3234//////////////////////////////////
    33 int sys_chmod( char    * pathname,
    34                uint32_t  rights )
     35int sys_chmod( const char * pathname,
     36               uint32_t     rights )
    3537{
    3638    error_t     error;
  • trunk/kernel/syscalls/sys_close.c

    r459 r506  
    2929#include <thread.h>
    3030#include <printk.h>
     31
     32#include <syscalls.h>
    3133
    3234//////////////////////////////////
  • trunk/kernel/syscalls/sys_display.c

    r457 r506  
    3131#include <string.h>
    3232#include <shared_syscalls.h>
     33
     34#include <syscalls.h>
    3335
    3436/////////////////////////////////////////////////////////////////////////////////
  • trunk/kernel/syscalls/sys_exec.c

    r492 r506  
    3636#include <rpc.h>
    3737
     38#include <syscalls.h>
    3839
    3940////////////////////////////////////////////////i//////////////////////////////////////
     
    162163// TODO : the args & envs arguments are not supported yet : both must be NULL  [AG]
    163164/////////////////////////////////////////////////////////////////////////////////////////
    164 int sys_exec( char  * pathname,    // .elf file pathname
    165               char ** args,         // process arguments
    166               char ** envs )        // environment variables
     165int sys_exec( const char  * pathname, // .elf file pathname
     166              char ** args,           // process arguments
     167              char ** envs )          // environment variables
    167168{
    168169    exec_info_t   exec_info;        // structure to pass to process_make_exec()
  • trunk/kernel/syscalls/sys_exit.c

    r457 r506  
    3232#include <cluster.h>
    3333#include <rpc.h>
     34
     35#include <syscalls.h>
    3436
    3537///////////////////////////////
  • trunk/kernel/syscalls/sys_fg.c

    r457 r506  
    3232#include <cluster.h>
    3333#include <rpc.h>
     34
     35#include <syscalls.h>
    3436
    3537///////////////////////
  • trunk/kernel/syscalls/sys_fork.c

    r479 r506  
    3737#include <dqdt.h>
    3838#include <process.h>
     39
     40#include <syscalls.h>
    3941
    4042//////////////
  • trunk/kernel/syscalls/sys_get_config.c

    r457 r506  
    3232#include <printk.h>
    3333
     34#include <syscalls.h>
     35
    3436//////////////////////////////////////
    3537int sys_get_config( uint32_t * x_size,
    3638                    uint32_t * y_size,
     39                    uint32_t * y_width,
    3740                    uint32_t * ncores )
    3841{
  • trunk/kernel/syscalls/sys_get_core.c

    r457 r506  
    3232#include <printk.h>
    3333
     34#include <syscalls.h>
    3435
    3536/////////////////////////////////
  • trunk/kernel/syscalls/sys_get_cycle.c

    r457 r506  
    3131#include <vmm.h>
    3232#include <printk.h>
     33
     34#include <syscalls.h>
    3335
    3436//////////////////////////////////////
  • trunk/kernel/syscalls/sys_getcwd.c

    r457 r506  
    3232#include <thread.h>
    3333#include <printk.h>
     34
     35#include <syscalls.h>
    3436
    3537/* TODO: user page(s) need to be locked  [AG] */
  • trunk/kernel/syscalls/sys_getpid.c

    r479 r506  
    2424#include <thread.h>
    2525
     26#include <syscalls.h>
     27
    2628////////////////
    2729int sys_getpid( void )
  • trunk/kernel/syscalls/sys_is_fg.c

    r469 r506  
    3333#include <shared_syscalls.h>
    3434#include <cluster.h>
     35
     36#include <syscalls.h>
    3537
    3638//////////////////////////////
  • trunk/kernel/syscalls/sys_isatty.c

    r457 r506  
    3434#include <printk.h>
    3535#include <process.h>
     36
     37#include <syscalls.h>
    3638
    3739////////////////////////////////////
  • trunk/kernel/syscalls/sys_kill.c

    r457 r506  
    3232#include <cluster.h>
    3333#include <rpc.h>
     34
     35#include <syscalls.h>
    3436
    3537///////////////////////////
  • trunk/kernel/syscalls/sys_mmap.c

    r457 r506  
    3535#include <vmm.h>
    3636
     37#include <syscalls.h>
     38
    3739//////////////////////////////////
    3840int sys_mmap( mmap_attr_t * attr )
  • trunk/kernel/syscalls/sys_munmap.c

    r457 r506  
    3333#include <process.h>
    3434#include <vmm.h>
     35
     36#include <syscalls.h>
    3537
    3638////////////////////////////////
  • trunk/kernel/syscalls/sys_open.c

    r459 r506  
    3333#include <remote_rwlock.h>
    3434
     35#include <syscalls.h>
     36
    3537///////////////////////////////////
    36 int sys_open ( char    * pathname,
    37                uint32_t   flags,
    38                uint32_t   mode )
     38int sys_open ( const char * pathname,
     39               uint32_t     flags,
     40               uint32_t     mode )
    3941{
    4042    error_t        error;
  • trunk/kernel/syscalls/sys_pipe.c

    r473 r506  
    2828#include <printk.h>
    2929
     30#include <syscalls.h>
     31
    3032//////////////////////////////////////
    31 int sys_pipe ( uint32_t * file_fd[2] )
     33int sys_pipe ( uint32_t file_fd[2] )
    3234{
    33     thread_t * this = CURRENT_THREAD;
    34 
    3535    printk("\n[ERROR] in %d : not implemented yet\n", __FUNCTION__, file_fd );
    36     return -1;
     36    return ENOSYS;
    3737}
  • trunk/kernel/syscalls/sys_read.c

    r492 r506  
    3333#include <printk.h>
    3434#include <process.h>
     35
     36#include <syscalls.h>
    3537
    3638// TODO: concurrent user page(s) munmap need to be handled [AG]
  • trunk/kernel/syscalls/sys_rmdir.c

    r457 r506  
    3131#include <process.h>
    3232
     33#include <syscalls.h>
     34
    3335////////////////////////////////
    34 int sys_rmdir( char * pathname )
     36int sys_rmdir( const char * pathname )
    3537{
    3638    error_t     error;
  • trunk/kernel/syscalls/sys_signal.c

    r473 r506  
    2828#include <printk.h>
    2929
     30#include <syscalls.h>
     31
    3032//////////////////////////////////
    3133int sys_signal( uint32_t   sig_id,
    3234                void     * handler )
    33 { 
    34         thread_t  * this    = CURRENT_THREAD;
     35{
     36    thread_t  * this    = CURRENT_THREAD;
    3537    process_t * process = this->process;
    3638
    3739    printk("\n[ERROR] in %s : thread %x in process %x / not implemented yet\n",
    3840    __FUNCTION__, this->trdid, process->pid, sig_id, handler );
    39     return -1;
     41    return ENOSYS;
    4042}
    4143
  • trunk/kernel/syscalls/sys_stat.c

    r457 r506  
    3232#include <process.h>
    3333
     34#include <syscalls.h>
     35
    3436/////////////////////////////////////
    35 int sys_stat( char        * pathname,
     37int sys_stat( const char  * pathname,
    3638              struct stat * u_stat )
    3739{
  • trunk/kernel/syscalls/sys_thread_cancel.c

    r457 r506  
    2929#include <errno.h>
    3030#include <printk.h>
     31
     32#include <syscalls.h>
    3133
    3234//////////////////////////////////////
  • trunk/kernel/syscalls/sys_thread_create.c

    r457 r506  
    3939#include <rpc.h>
    4040
     41#include <syscalls.h>
    4142
    4243///////////////////////////////////////////////////
    43 int sys_thread_create ( pthread_t      * trdid_ptr,
    44                         pthread_attr_t * user_attr,
    45                         void           * start_func,
    46                         void           * start_arg )
     44int sys_thread_create(
     45  struct thread_s             * new_thread,
     46  const struct pthread_attr_s * user_attr,
     47  const void                  * start_func,
     48  const void                  * start_args )
    4749{
    4850        pthread_attr_t   kern_attr;        // copy of pthread attributes in kernel space
     
    7274
    7375    // check trdid buffer in user space
    74     error = vmm_get_vseg( process , (intptr_t)trdid_ptr , &vseg );
     76    error = vmm_get_vseg( process , (intptr_t)new_thread , &vseg );
    7577
    7678    if ( error )
     
    7981#if DEBUG_SYSCALLS_ERROR
    8082printk("\n[ERROR] in %s : trdid buffer unmapped %x / thread %x / process %x\n",
    81 __FUNCTION__ , (intptr_t)trdid_ptr, parent->trdid, process->pid );
     83__FUNCTION__ , (intptr_t)new_thread, parent->trdid, process->pid );
    8284vmm_display( process , false );
    8385#endif
     
    121123        }
    122124
    123         // check start_arg buffer in user space
    124         if( start_arg != NULL )
    125     {
    126         error = vmm_get_vseg( process , (intptr_t)start_arg , &vseg );
     125        // check start_args buffer in user space
     126        if( start_args != NULL )
     127    {
     128        error = vmm_get_vseg( process , (intptr_t)start_args , &vseg );
    127129
    128130            if( error )
     
    130132
    131133#if DEBUG_SYSCALLS_ERROR
    132 printk("\n[ERROR] in %s : start_arg buffer unmapped %x / thread %x / process %x\n",
    133 __FUNCTION__ , (intptr_t)start_arg , parent->trdid , process->pid );
     134printk("\n[ERROR] in %s : start_args buffer unmapped %x / thread %x / process %x\n",
     135__FUNCTION__ , (intptr_t)start_args , parent->trdid , process->pid );
    134136vmm_display( process , false );
    135137#endif
     
    176178                error = thread_user_create( process->pid,
    177179                                            start_func,
    178                                             start_arg,
     180                                            start_args,
    179181                                            &kern_attr,
    180182                                            &child_ptr );
     
    187189                                               process->pid,
    188190                                               start_func,
    189                                                start_arg,
     191                                               start_args,
    190192                                               &kern_attr,
    191193                                               &child_xp,
     
    209211        // returns trdid to user space
    210212        trdid = hal_remote_lw( XPTR( target_cxy , &child_ptr->trdid ) );
    211         hal_copy_to_uspace( trdid_ptr , &trdid , sizeof(pthread_t) );
     213        hal_copy_to_uspace( new_thread , &trdid , sizeof(pthread_t) );
    212214
    213215    // activate new thread
  • trunk/kernel/syscalls/sys_thread_detach.c

    r457 r506  
    2828#include <errno.h>
    2929#include <printk.h>
     30
     31#include <syscalls.h>
    3032
    3133//////////////////////////////////////
  • trunk/kernel/syscalls/sys_thread_exit.c

    r457 r506  
    3030#include <scheduler.h>
    3131#include <printk.h>
     32
     33#include <syscalls.h>
    3234
    3335////////////////////////////////////////
  • trunk/kernel/syscalls/sys_thread_join.c

    r473 r506  
    3232#include <printk.h>
    3333#include <remote_spinlock.h>
     34
     35#include <syscalls.h>
    3436
    3537///////////////////////////////////////
  • trunk/kernel/syscalls/sys_thread_sleep.c

    r479 r506  
    2626#include <thread.h>
    2727#include <printk.h>
     28#include <syscalls.h>
    2829
    2930//////////////////////
  • trunk/kernel/syscalls/sys_thread_wakeup.c

    r467 r506  
    2727#include <process.h>
    2828#include <errno.h>
     29
     30#include <syscalls.h>
    2931
    3032//////////////////////////////////////
  • trunk/kernel/syscalls/sys_thread_yield.c

    r479 r506  
    2727#include <thread.h>
    2828
     29#include <syscalls.h>
     30
    2931int sys_thread_yield( void )
    3032{
  • trunk/kernel/syscalls/sys_timeofday.c

    r457 r506  
    3131#include <core.h>
    3232#include <shared_syscalls.h>
     33
     34#include <syscalls.h>
    3335
    3436////////////////////////////////////////
  • trunk/kernel/syscalls/sys_unlink.c

    r457 r506  
    2828#include <printk.h>
    2929
     30#include <syscalls.h>
     31
    3032//////////////////////////////////
    31 int sys_unlink ( char * pathname )
     33int sys_unlink ( const char * pathname )
    3234{
    3335    error_t   error;
  • trunk/kernel/syscalls/sys_wait.c

    r457 r506  
    3030#include <vmm.h>
    3131#include <printk.h>
     32
     33#include <syscalls.h>
    3234
    3335/////////////////////////////////
  • trunk/kernel/syscalls/syscalls.h

    r479 r506  
    3636struct mmap_attr_s;               // defined in vmm.h
    3737
     38// debug:
     39const char * syscall_str( uint32_t index );
     40
    3841/******************************************************************************************
    3942 * [0] This function terminates the execution of the calling user thread,
     
    7073 * @ return 0 if success / return -1 if failure.
    7174 *****************************************************************************************/
    72 int sys_thread_create( struct thread_s        * new_thread,
    73                        struct pthread_attr_s  * user_attr,
    74                        void                   * start_func,
    75                        void                   * start_args );
     75int sys_thread_create(
     76  struct thread_s             * new_thread,
     77  const struct pthread_attr_s * user_attr,
     78  const void                  * start_func,
     79  const void                  * start_args );
    7680
    7781/******************************************************************************************
     
    201205 * @ return file descriptor index in fd_array if success / return -1 if failure.
    202206 *****************************************************************************************/
    203 int sys_open( char    * pathname,
    204               uint32_t  flags,
    205               uint32_t  mode );
     207int sys_open( const char * pathname,
     208              uint32_t     flags,
     209              uint32_t     mode );
    206210
    207211/******************************************************************************************
     
    276280 * @ return 0 if success / returns -1 if failure.
    277281 *****************************************************************************************/
    278 int sys_unlink( char * pathname );
     282int sys_unlink( const char * pathname );
    279283
    280284/******************************************************************************************
     
    295299 * @ return 0 if success / returns -1 if failure.
    296300 *****************************************************************************************/
    297 int sys_chdir( char * pathname );
     301int sys_chdir( const char * pathname );
    298302
    299303/******************************************************************************************
     
    383387 * @ return 0 if success / returns -1 if failure.
    384388 *****************************************************************************************/
    385 int sys_rmdir( char * pathname );
     389int sys_rmdir( const char * pathname );
    386390
    387391/******************************************************************************************
     
    404408 * @ return 0 if success / returns -1 if failure.
    405409 *****************************************************************************************/
    406 int sys_chmod( char    * pathname,
    407                uint32_t   rights );
     410int sys_chmod( const char * pathname,
     411               uint32_t     rights );
    408412
    409413/******************************************************************************************
     
    490494 * @ does not return if success / returns -1 if failure.
    491495 *****************************************************************************************/
    492 int sys_exec( char  * filename,
    493               char ** argv,
    494               char ** envp );
     496int sys_exec( const char  * filename,
     497              char        ** argv,
     498              char        ** envp );
    495499
    496500/******************************************************************************************
     
    610614 * @ return 0 if success / return -1 if failure.
    611615 *****************************************************************************************/
    612 int sys_thread_wakeup( void );
     616int sys_thread_wakeup( trdid_t trdid );
    613617
    614618/******************************************************************************************
Note: See TracChangeset for help on using the changeset viewer.