Changeset 23 for trunk/kernel/kern/rpc.h


Ignore:
Timestamp:
Jun 18, 2017, 10:06:41 PM (7 years ago)
Author:
alain
Message:

Introduce syscalls.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/kernel/kern/rpc.h

    r16 r23  
    22 * rpc.h - RPC (Remote Procedure Call) operations definition.
    33 *
    4  * Authors Mohamed Karaoui (2015)
    5  *         Alain Greiner (2016)
     4 * Author  Alain Greiner (2016,2017)
    65 *
    76 * Copyright (c) UPMC Sorbonne Universites
     
    4342struct vfs_inode_s;
    4443struct vfs_dentry_s;
     44struct vfs_file_s;
    4545struct thread_s;
    4646struct mapper_s;
     
    6363    RPC_THREAD_USER_CREATE     = 4,
    6464    RPC_THREAD_KERNEL_CREATE   = 5,
     65    RPC_SIGNAL_RISE            = 6,
    6566
    6667    RPC_VFS_INODE_CREATE       = 10,
     
    6869    RPC_VFS_DENTRY_CREATE      = 12,
    6970    RPC_VFS_DENTRY_DESTROY     = 13,
     71    RPC_VFS_FILE_CREATE        = 14,
     72    RPC_VFS_FILE_DESTROY       = 15,
     73    RPC_FATFS_GET_CLUSTER      = 16,
    7074
    7175    RPC_VMM_GET_REF_VSEG       = 20,
    7276    RPC_VMM_GET_PTE            = 21,
    73     RPC_SEMAPHORE_ALLOC        = 22,
    74     RPC_SEMAPHORE_FREE         = 23,
     77    RPC_KCM_ALLOC              = 22,
     78    RPC_KCM_FREE               = 23,
    7579    RPC_MAPPER_MOVE            = 24,
    7680
    77     RPC_FATFS_GET_CLUSTER      = 30,
    78 
    79     RPC_MAX_INDEX              = 31,
     81    RPC_MAX_INDEX              = 30,
    8082}
    8183rpc_index_t;
     
    9698        rpc_index_t       index;       // index of requested RPC service
    9799        volatile uint32_t response;    // response valid when 0
    98     uint64_t          args[8];     // input/output arguments buffer
     100    uint64_t          args[10];    // input/output arguments buffer
    99101}
    100102rpc_desc_t;
     
    192194void __attribute__((noinline)) rpc_undefined();
    193195
     196
     197
     198
    194199/**********************************************************************************/
    195200/******* Marshalling functions attached to the various RPCs ***********************/
     
    197202
    198203/***********************************************************************************
    199  * The RPC_PMEM_GET_PAGES allocates one or several pages in a remote cluster,
     204 * [0] The RPC_PMEM_GET_PAGES allocates one or several pages in a remote cluster,
    200205 * and returns the PPN of the first allocated page.
    201206 ***********************************************************************************
     
    213218
    214219/***********************************************************************************
    215  * The RPC_PROCESS_PID_ALLOC allocates one new PID in a remote cluster, registers
     220 * [1] The RPC_PROCESS_PID_ALLOC allocates one new PID in a remote cluster, registers
    216221 * the new process in the remote cluster, and returns the PID, and an error code.
    217222 ***********************************************************************************
     
    229234
    230235/***********************************************************************************
    231  * The RPC_PROCESS_EXEC creates a process descriptor copy, in a remote cluster
     236 * [2] The RPC_PROCESS_EXEC creates a process descriptor copy, in a remote cluster
    232237 * and initializes if from information found in the reference process descriptor.
    233238 * This remote cluster becomes the new reference cluster.
     
    244249
    245250/***********************************************************************************
    246  * The RPC_PROCESS_KILL is actually a multicast RPC sent by the reference cluster
     251 * [3] The RPC_PROCESS_KILL is actually a multicast RPC sent by the reference cluster
    247252 * to other clusters containing a process descriptor copy, to destroy these copies.
    248253 ***********************************************************************************
     
    254259
    255260/***********************************************************************************
    256  * The RPC_THREAD_USER_CREATE creates an user thread in the server cluster,
    257  * as specified by the pthread_attr_t argument. It returns the local pointer
    258  * on the thread descriptor in server cluster, and an error code.
    259  * It is called by the pthread_create system call.
     261 * [4] The RPC_THREAD_USER_CREATE creates an user thread in the server cluster,
     262 * as specified by the arguments. It returns an extended pointer on the new
     263 * thread descriptor in server cluster, and an error code.
     264 * It is called by the sys_thread_create() system call.
    260265 ***********************************************************************************
    261266 * @ cxy       : server cluster identifier.
     
    265270 **********************************************************************************/
    266271void rpc_thread_user_create_client( cxy_t                   cxy,
     272                                    pid_t                   pid,
     273                                    void                  * start_func,
     274                                    void                  * start_arg,
    267275                                    struct pthread_attr_s * attr,
    268276                                    xptr_t                * thread_xp,
     
    272280
    273281/***********************************************************************************
    274  * The RPC_THREAD_KERNEL_CREATE creates a kernel thread in the server cluster,
     282 * [5] The RPC_THREAD_KERNEL_CREATE creates a kernel thread in the server cluster,
    275283 * as specified by the type, func and args arguments. It returns the local pointer
    276284 * on the thread descriptor in server cluster and an error code.
    277  * It is used by the dev_init() function to cretae the device server thread.
     285 * It is used by the dev_init() function to create the device server thread.
    278286 ***********************************************************************************
    279287 * @ cxy       : server cluster identifier.
     
    293301void rpc_thread_kernel_create_server( xptr_t xp );
    294302
     303/***********************************************************************************
     304 * [6] The RPC_SIGNAL_RISE ask a target cluster to register a given signal in
     305 * all threads descriptors of a given process.
     306 * It is used by the sys_kill() function.
     307 ***********************************************************************************
     308 * @ cxy       : server cluster identifier.
     309 * @ process   : [in]  local pointer on target process descriptor in server.
     310 * @ sig_id    : [in]  signal index.
     311 **********************************************************************************/
     312void rpc_signal_rise_client( cxy_t              cxy,
     313                             struct process_s * process,
     314                             uint32_t           sig_id );
     315                             
     316void rpc_signal_rise_server( xptr_t xp );
     317
    295318/***********************************************************************************
    296  * The RPC_VFS_INODE_CREATE creates an inode and the associated mapper in a
     319 * [10] The RPC_VFS_INODE_CREATE creates an inode and the associated mapper in a
    297320 * remote cluster. The parent dentry must have been previously created.
    298321 * It returns an extended pointer on the created inode.
    299322 ***********************************************************************************
    300  * @ cxy       :  server cluster identifier
    301  * @ dentry_xp : [in]  extended pointer on parent dentry.
    302  * @ type      : [in]  file system type.
    303  * @ attr      : [in]  TODO ???
    304  * @ mode      : [in]  access mode.
    305  * @ uid       : [in]  user ID
    306  * @ gid       : [in]  group ID
    307  * @ inode_xp  : [out] buffer for extended pointer on created inode.
    308  * @ error     : [out] error status (0 if success).
     323 * @ cxy        :  server cluster identifier.
     324 * @ dentry_xp  : [in]  extended pointer on parent dentry.
     325 * @ fs_type    : [in]  file system type.
     326 * @ inode_type : [in]  file system type.
     327 * @ attr       : [in]  inode attributes.
     328 * @ rights     : [in]  access rights
     329 * @ uid        : [in]  user ID
     330 * @ gid        : [in]  group ID
     331 * @ inode_xp   : [out] buffer for extended pointer on created inode.
     332 * @ error      : [out] error status (0 if success).
    309333 **********************************************************************************/
    310334void rpc_vfs_inode_create_client( cxy_t      cxy,
    311335                                  xptr_t     dentry_xp,
    312                                   uint32_t   type,
     336                                  uint32_t   fs_type,
     337                                  uint32_t   inode_type,
    313338                                  uint32_t   attr,   
    314                                   uint32_t   mode
     339                                  uint32_t   rights
    315340                                  uint32_t   uid,
    316341                                  uint32_t   gid,
     
    321346
    322347/***********************************************************************************
    323  * The RPC_VFS_INODE_DESTROY releases memory allocated for an inode descriptor
     348 * [11] The RPC_VFS_INODE_DESTROY releases memory allocated for an inode descriptor
    324349 * and for the associated mapper in a remote cluster.
    325350 ***********************************************************************************
     
    333358
    334359/***********************************************************************************
    335  * The RPC_VFS_DENTRY_CREATE creates a dentry in a remote cluster.
     360 * [12] The RPC_VFS_DENTRY_CREATE creates a dentry in a remote cluster.
    336361 * It returns an extended pointer on the created dentry.
    337362 ***********************************************************************************
     
    353378
    354379/***********************************************************************************
    355  * The RPC_VFS_DENTRY_DESTROY releases memory allocated for an dentry descriptor
     380 * [13] The RPC_VFS_DENTRY_DESTROY releases memory allocated for an dentry descriptor
    356381 * in a remote cluster.
    357382 ***********************************************************************************
     
    364389void rpc_vfs_dentry_destroy_server( xptr_t xp );
    365390
    366 
    367 
    368 
    369 /***********************************************************************************
    370  * The RPC_VMM_GET_REF_VSEG returns an extended pointer
     391/***********************************************************************************
     392 * [14] The RPC_VFS_FILE_CREATE creates a file descriptor in a remote cluster.
     393 * It returns an extended pointer on the created file structure.
     394 ***********************************************************************************
     395 * @ cxy        :  server cluster identifier
     396 * @ inode      : [in]  local pointer on parent inode.
     397 * @ file_attr  : [in]  new file attributes.
     398 * @ file_xp    : [out] buffer for extended pointer on created file.
     399 * @ error      : [out] error status (0 if success).
     400 **********************************************************************************/
     401void rpc_vfs_file_create_client( cxy_t                  cxy,
     402                                 struct vfs_inode_s   * inode,
     403                                 uint32_t               file_attr,
     404                                 xptr_t               * file_xp,
     405                                 error_t              * error );
     406
     407void rpc_vfs_file_create_server( xptr_t xp );
     408
     409/***********************************************************************************
     410 * [15] The RPC_VFS_FILE_DESTROY releases memory allocated for a file descriptor
     411 * in a remote cluster.
     412 ***********************************************************************************
     413 * @ cxy       :  server cluster identifier
     414 * @ file       : [in]  local pointer on file.
     415 **********************************************************************************/
     416void rpc_vfs_file_destroy_client( cxy_t               cxy,
     417                                  struct vfs_file_s * file );
     418
     419void rpc_vfs_file_destroy_server( xptr_t xp );
     420
     421/***********************************************************************************
     422 * [16] The RPC_FATFS_GET_CLUSTER can be send by any thread running in a "client"
     423 * cluster to scan the FAT mapper, stored in a remote "server" cluster, and get
     424 * from the mapper the local pointer on a given page.
     425 ***********************************************************************************
     426 * @ cxy      : server cluster identifier.
     427 * @ mapper   : [in]  local pointer on FAT mapper.
     428 * @ first    : [in]  FATFS cluster index allocated to first page of file.
     429 * @ page     : [in]  page index in file.
     430 * @ cluster  : [out] local pointer on buffer for found FATFS cluster index.
     431 * @ error    : [out] local pointer on buffer for error code (in client cluster).
     432 **********************************************************************************/
     433void rpc_fatfs_get_cluster_client( cxy_t             cxy,
     434                                   struct mapper_s * mapper,
     435                                   uint32_t          first,
     436                                   uint32_t          page,
     437                                   uint32_t        * cluster,
     438                                   error_t         * error );   
     439
     440void rpc_fatfs_get_cluster_server( xptr_t xp );
     441
     442/***********************************************************************************
     443 * [20] The RPC_VMM_GET_REF_VSEG returns an extended pointer
    371444 * on the vseg containing a given virtual address in a given process.
    372445 * The server cluster is supposed to be the reference cluster.
     
    386459
    387460/***********************************************************************************
    388  * The RPC_VMM_GET_PTE returns in the "ppn" and "attr" arguments the PTE value
     461 * [21] The RPC_VMM_GET_PTE returns in the "ppn" and "attr" arguments the PTE value
    389462 * for a given VPN in a given process.
    390463 * The server cluster is supposed to be the reference cluster, and the vseg
     
    410483
    411484/***********************************************************************************
    412  * The RPC_SEMAPHORE_ALLOC allocates memory for a semaphore in a remote cluster,
    413  * and returns an extended pointer on the created semaphore.
    414   It returns NULL if physical memory cannot be allocated.
    415  ***********************************************************************************
    416  * @ cxy     : server cluster identifier.
    417  * @ sem_xp  : [out] buffer for extended pointer on semaphore.
    418  **********************************************************************************/
    419 void rpc_semaphore_alloc_client( cxy_t    cxy,
    420                                  xptr_t * sem_xp ); 
    421 
    422 void rpc_semaphore_alloc_server( xptr_t xp );
    423 
    424 /***********************************************************************************
    425  * The RPC_SEMAPHORE_FREE releases memory allocated for a semaphore
     485 * [22] The RPC_KCM_ALLOC allocates memory from a given KCM in a remote cluster,
     486 * and returns an extended pointer on the allocated object.
     487  It returns XPTR_NULL if physical memory cannot be allocated.
     488 ***********************************************************************************
     489 * @ cxy       : server cluster identifier.
     490 * @ kmem_type : [in]  KCM object type (as defined in kmem.h).
     491 * @ buf_xp    : [out] buffer for extended pointer on allocated buffer.
     492 **********************************************************************************/
     493void rpc_kcm_alloc_client( cxy_t      cxy,
     494                           uint32_t   kmem_type,
     495                           xptr_t   * buf_xp ); 
     496
     497void rpc_kcm_alloc_server( xptr_t xp );
     498
     499/***********************************************************************************
     500 * [23] The RPC_KCM_FREE releases memory allocated for a KCM object of a given type,
    426501 * in a remote cluster.
    427502 ***********************************************************************************
    428  * @ cxy     : server cluster identifier.
    429  * @ sem     : [in] local pointer on semaphore.
    430  **********************************************************************************/
    431 void rpc_semaphore_free_client( cxy_t                 cxy,
    432                                 struct remote_sem_s * sem );
    433 
    434 void rpc_semaphore_free_server( xptr_t xp );
    435 
    436 /***********************************************************************************
    437  * The RPC_MAPPER_MOVE can be send by any thread running in a "client" cluster
    438  * to the "server" cluster containing the mapper of a given file. The service is
    439  * to move data between the mapper and an user buffer. This user buffer is described
    440  * as a set of fragments. Each fragment is contained in one single physical page.
    441  * It is defined by four parameters : size / file_offset / ppn / page_offset,
    442  * defined in the mapper.h file. The client thread is in charge of building
    443  * the fragments array covering the user buffer.
    444  * As each fragments can be stored in a different cluster, and this fragment can
    445  * be stored in two successive pages in the radix tree, each fragment is moved
    446  * using one or two different hal_remote_memcpy().
    447  ***********************************************************************************
    448  * @ cxy      : server cluster identifier.
    449  * @ inode    : [in]  local pointer on inode (in server cluster).
    450  * @ read     : [in]  mapper to buffer if true / buffer to mapper if false.
    451  * @ nb_frags : [in]  number of fragments in fragments array.
    452  * @ frags    : [in]  local pointer on fragments array (in client cluster).
    453  * @ error    : [out] local pointer on buffer for error code (in client cluster).
    454  **********************************************************************************/
    455 void rpc_mapper_move_client( cxy_t                cxy,
    456                              struct mapper_s    * mapper,
    457                              bool_t               read,
    458                              uint32_t             nb_frags,
    459                              struct fragment_s  * frags,
    460                              error_t            * error );
     503 * @ cxy       : server cluster identifier.
     504 * @ buf       : [in] local pointer on allocated buffer.
     505 * @ kmem_type : [in]  KCM object type (as defined in kmem.h).
     506 **********************************************************************************/
     507void rpc_kcm_free_client( cxy_t     cxy,
     508                          void    * buf,
     509                          uint32_t  kmem_type );
     510
     511void rpc_kcm_free_server( xptr_t xp );
     512
     513/***********************************************************************************
     514 * [24] The RPC_MAPPER_MOVE is called by the vfs_move() function.
     515 * It allows a client thread to requires a remote mapper to move data to/from
     516 * an user buffer, as specified by the arguments.
     517 ***********************************************************************************
     518 * @ cxy         : server cluster identifier.
     519 * @ mapper      : [in]  local pointer on mapper
     520 * @ to_buffer   : [in]  move data from buffer to mapper if non zero.
     521 * @ file_offset : [in]  first byte to move in mapper
     522 * @ buffer      : [in]  pointer on buffer in user space
     523 * @ size        : [in]  number of bytes to move
     524 * @ error       : [out] error status (0 if success).
     525 **********************************************************************************/
     526void rpc_mapper_move_client( cxy_t             cxy,
     527                             struct mapper_s * mapper,
     528                             uint32_t          to_buffer,
     529                             uint32_t          file_offset,
     530                             void            * buffer,
     531                             uint32_t          size,
     532                             error_t         * error );
    461533
    462534void rpc_mapper_move_server( xptr_t xp );
    463535
    464 /***********************************************************************************
    465  * The RPC_FATFS_GET_CLUSTER can be send by any thread running in a "client" cluster
    466  * to scan the FAT mapper, stored in a remote "server" cluster, and get the FATFS
    467  * cluster index of a given page of a given file.
    468  ***********************************************************************************
    469  * @ cxy      : server cluster identifier.
    470  * @ mapper   : [in]  local pointer on FAT mapper.
    471  * @ first    : [in]  FATFS cluster index allocated to first page of file.
    472  * @ page     : [in]  page index in file.
    473  * @ cluster  : [out] local pointer on buffer for found FATFS cluster index.
    474  * @ error    : [out] local pointer on buffer for error code (in client cluster).
    475  **********************************************************************************/
    476 void rpc_fatfs_get_cluster_client( cxy_t             cxy,
    477                                    struct mapper_s * mapper,
    478                                    uint32_t          first,
    479                                    uint32_t          page,
    480                                    uint32_t        * cluster,
    481                                    error_t         * error );   
    482 
    483 void rpc_fatfs_get_cluster_server( xptr_t xp );
     536
     537
    484538
    485539#endif
Note: See TracChangeset for help on using the changeset viewer.