source: trunk/kernel/kern/rpc.h @ 409

Last change on this file since 409 was 409, checked in by alain, 4 years ago

Fix bugs in exec

File size: 36.9 KB
Line 
1/*
2 * rpc.h - RPC (Remote Procedure Call) operations definition.
3 *
4 * Author  Alain Greiner (2016,2017)
5 *
6 * Copyright (c) UPMC Sorbonne Universites
7 *
8 * This file is part of ALMOS-MKH.
9 *
10 * ALMOS-MKH is free software; you can redistribute it and/or modify it
11 * under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; version 2.0 of the License.
13 *
14 * ALMOS-MKH is distributed in the hope that it will be useful, but
15 * WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17 * General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with ALMOS-MKH; if not, write to the Free Software Foundation,
21 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22 */
23
24#ifndef _RPC_H_
25#define _RPC_H_
26
27#include <kernel_config.h>
28#include <hal_types.h>
29#include <hal_atomic.h>
30#include <bits.h>
31#include <spinlock.h>
32#include <vseg.h>
33#include <remote_fifo.h>
34#include <signal.h>
35
36/**** Forward declarations ****/
37
38struct process_s;
39struct page_s;
40struct vseg_s;
41struct exec_info_s;
42struct pthread_attr_s;
43struct remote_sem_s;
44struct fragment_s;
45struct vfs_inode_s;
46struct vfs_dentry_s;
47struct vfs_file_s;
48struct thread_s;
49struct mapper_s;
50
51/**********************************************************************************/
52/**************  structures for Remote Procedure Calls ****************************/
53/**********************************************************************************/
54
55/***********************************************************************************
56 * This enum defines all RPC indexes.
57 * It must be consistent with the rpc_server[] array defined in in the rpc.c file.
58 **********************************************************************************/
59
60typedef enum
61{
62    RPC_PMEM_GET_PAGES         = 0,
63    RPC_PMEM_RELEASE_PAGES     = 1,
64    RPC_PROCESS_MAKE_EXEC      = 2,     
65    RPC_PROCESS_MAKE_FORK      = 3,
66    RPC_PROCESS_MAKE_EXIT      = 4,
67    RPC_PROCESS_MAKE_KILL      = 5,
68    RPC_THREAD_USER_CREATE     = 6,
69    RPC_THREAD_KERNEL_CREATE   = 7,
70    RPC_THREAD_KILL            = 8,
71    RPC_PROCESS_SIGACTION      = 9,
72
73    RPC_VFS_INODE_CREATE       = 10,
74    RPC_VFS_INODE_DESTROY      = 11,
75    RPC_VFS_DENTRY_CREATE      = 12,
76    RPC_VFS_DENTRY_DESTROY     = 13,
77    RPC_VFS_FILE_CREATE        = 14,
78    RPC_VFS_FILE_DESTROY       = 15,
79    RPC_VFS_INODE_LOAD         = 16,
80    RPC_VFS_MAPPER_LOAD_ALL    = 17,
81    RPC_FATFS_GET_CLUSTER      = 18,
82
83    RPC_VMM_GET_VSEG           = 20,
84    RPC_VMM_GET_PTE            = 21,
85    RPC_KCM_ALLOC              = 22,
86    RPC_KCM_FREE               = 23,
87    RPC_MAPPER_MOVE_BUFFER     = 24,
88    RPC_MAPPER_GET_PAGE        = 25,
89    RPC_VMM_CREATE_VSEG        = 26,
90    RPC_SCHED_DISPLAY          = 27,
91    RPC_VMM_SET_COW            = 28,
92
93    RPC_MAX_INDEX              = 30,
94}
95rpc_index_t;
96
97/***********************************************************************************
98 * This defines the prototype of the rpc_server functions,
99 * defined by the rpc_server[] array in the rpc.c file.
100 **********************************************************************************/
101
102typedef  void (rpc_server_t) ( xptr_t xp );
103
104/***********************************************************************************
105 *  This structure defines the RPC descriptor
106 **********************************************************************************/
107
108typedef struct rpc_desc_s
109{
110        rpc_index_t         index;       /*! index of requested RPC service           */
111        volatile uint32_t   response;    /*! response valid when 0                    */
112    struct thread_s   * thread;      /*! local pointer on client thread           */
113    uint32_t            lid;         /*! index of core running the calling thread */ 
114    uint64_t            args[10];    /*! input/output arguments buffer            */
115} 
116rpc_desc_t;
117
118/**********************************************************************************/
119/******* Generic functions supporting RPCs : client side **************************/
120/**********************************************************************************/
121
122/***********************************************************************************
123 * This function is executed by the client thread in the client cluster.
124 * It puts one RPC descriptor defined by the <desc> argument in the remote fifo
125 * defined by the <cxy> argument.  It sends an IPI to the server if fifo is empty.
126 * The RPC descriptor must be allocated in the caller's stack, and initialised by
127 * the caller. It exit with a Panic message if remote fifo is still full after
128 * (CONFIG_RPC_PUT_MAX_ITERATIONS) retries.
129 * - When the <block> argument is true, this function blocks and deschedule.
130 *   It returns only when the server acknowledges the RPC by writing in the RPC
131 *   "response" field, and unblocks the client.
132 * - When the <block> argument is false, this function returns as soon as the RPC
133 *   has been registered in the FIFO, and the server thread must directly signal
134 *   completion to the client thread.
135 ***********************************************************************************
136 * @ cxy   : server cluster identifier
137 * @ desc  : local pointer on RPC descriptor in client cluster
138 * @ block : boolean true when blocking behaviour is required.
139 **********************************************************************************/
140void rpc_send( cxy_t        cxy,   
141               rpc_desc_t * desc,
142               bool_t       block );
143
144
145
146/**********************************************************************************/
147/******* Generic functions supporting RPCs : server side **************************/
148/**********************************************************************************/
149
150/***********************************************************************************
151 * This function is the entry point for RPC handling on the server side.
152 * It is executed by a core receiving an IPI, and each time the core enters,
153 * or exit the kernel to handle .
154 * It does nothing and return if the RPC_FIFO is empty.
155 * The calling thread checks if it exist at least one non-blocked RPC thread,
156 * creates a new RPC if required, and deschedule to allow the RPC thead to execute.
157 **********************************************************************************/
158void rpc_check();
159
160/***********************************************************************************
161 * This function contains the loop to execute all pending RPCs on the server side.
162 * It is called by the rpc_thread_func() function with irq disabled, and after
163 * RPC_FIFO ownership acquisition.
164 ***********************************************************************************
165 * @ rpc_fifo  : pointer on the local RPC fifo
166 **********************************************************************************/
167void rpc_execute_all( remote_fifo_t * rpc_fifo );
168
169/***********************************************************************************
170 * This function contains the infinite loop executed by a RPC thread.
171 **********************************************************************************/
172void rpc_thread_func();
173
174/***********************************************************************************
175 * This function is executed in case of illegal RPC index.
176 **********************************************************************************/
177void __attribute__((noinline)) rpc_undefined();
178
179
180
181
182/**********************************************************************************/
183/******* Marshalling functions attached to the various RPCs ***********************/
184/**********************************************************************************/
185
186/***********************************************************************************
187 * [0] The RPC_PMEM_GET_PAGES allocates one or several pages in a remote cluster,
188 * and returns the local pointer on the page descriptor.
189 ***********************************************************************************
190 * @ cxy     : server cluster identifier
191 * @ order   : [in]  ln2( number of requested pages )
192 * @ page    : [out] local pointer on page descriptor / NULL if failure
193 **********************************************************************************/
194void rpc_pmem_get_pages_client( cxy_t             cxy,
195                                uint32_t          order,
196                                struct page_s  ** page );
197
198void rpc_pmem_get_pages_server( xptr_t xp );
199
200/***********************************************************************************
201 * [1] The RPC_PMEM_RELEASE_PAGES release one or several pages to a remote cluster.
202 ***********************************************************************************
203 * @ cxy     : server cluster identifier
204 * @ page    : [in] local pointer on page descriptor to release.
205 **********************************************************************************/
206void rpc_pmem_release_pages_client( cxy_t            cxy,
207                                    struct page_s  * page );
208
209void rpc_pmem_release_pages_server( xptr_t xp );
210
211/***********************************************************************************
212 * [2] The RPC_PROCESS_MAKE_EXEC creates a new process descriptor, from an existing
213 * process descriptor in a remote server cluster. This server cluster must be
214 * the owner cluster for the existing process. The new process descriptor is
215 * initialized from informations found in the <exec_info> structure.
216 * A new main thread descriptor is created in the server cluster.
217 * All copies of the old process descriptor and all old threads are destroyed.
218 ***********************************************************************************
219 * @ cxy     : server cluster identifier.
220 * @ process : [in]  local pointer on the exec_info structure in client cluster.
221 * @ error   : [out] error status (0 if success).
222 **********************************************************************************/
223void rpc_process_make_exec_client( cxy_t                cxy,
224                                   struct exec_info_s * info, 
225                                   error_t            * error );
226
227void rpc_process_make_exec_server( xptr_t xp );
228
229/***********************************************************************************
230 * [3] The RPC_PROCESS_MAKE_FORK creates a "child" process descriptor, and the
231 * associated "child" thread descriptor in a target remote cluster that can be
232 * any cluster.  The child process is initialized from informations found in the
233 * "parent" process descriptor (that must be the parent reference cluster),
234 * and from the "parent" thread descriptor that can be in any cluster.
235 ***********************************************************************************
236 * @ cxy              : server cluster identifier.
237 * @ ref_process_xp   : [in]  extended pointer on reference parent process.
238 * @ parent_thread_xp : [in]  extended pointer on parent thread.
239 * @ child_pid        : [out] child process identifier.
240 * @ child_thread_ptr : [out] local pointer on child thread.
241 * @ error            : [out]  error status (0 if success).
242 **********************************************************************************/
243void rpc_process_make_fork_client( cxy_t              cxy,
244                                   xptr_t             ref_process_xp,
245                                   xptr_t             parent_thread_xp,
246                                   pid_t            * child_pid,
247                                   struct thread_s ** child_thread_ptr,
248                                   error_t          * error );
249
250void rpc_process_make_fork_server( xptr_t xp );
251
252/***********************************************************************************
253 * [4] The RPC_PROCESS_MAKE_EXIT can be called by any thread to request the owner
254 * cluster to execute the process_make_exit() function for a calling process.
255 ***********************************************************************************
256 * @ cxy      : server cluster identifier.
257 * @ process  : local pointer on calling process in owner cluster.
258 * @ status   : calling process exit status.
259 **********************************************************************************/
260void rpc_process_make_exit_client( cxy_t              cxy,
261                                   struct process_s * process,
262                                   uint32_t           status );
263
264void rpc_process_make_exit_server( xptr_t xp );
265
266/***********************************************************************************
267 * [5] The RPC_PROCESS_MAKE_KILL can be called by any thread to request the owner
268 * cluster to execute the process_make_kill() function for a target process.
269 ***********************************************************************************
270 * @ cxy      : server cluster identifier.
271 * @ process  : local pointer on target process in owner cluster.
272 * @ seg_id   : signal type (only SIGKILL / SIGSTOP / SIGCONT are supported).
273 **********************************************************************************/
274void rpc_process_make_kill_client( cxy_t              cxy,
275                                   struct process_s * process,
276                                   uint32_t           seg_id );
277
278void rpc_process_make_kill_server( xptr_t xp );
279
280/***********************************************************************************
281 * [6] The RPC_THREAD_USER_CREATE creates an user thread in the server cluster,
282 * as specified by the arguments. It returns an extended pointer on the new
283 * thread descriptor in server cluster, and an error code.
284 * It is called by the sys_thread_create() system call.
285 ***********************************************************************************
286 * @ cxy       : server cluster identifier.
287 * @ attr      : [in]  local pointer on pthread_attr_t in client cluster.
288 * @ thread_xp : [out] buffer for thread extended pointer.
289 * @ error     : [out] error status (0 if success).
290 **********************************************************************************/
291void rpc_thread_user_create_client( cxy_t                   cxy,
292                                    pid_t                   pid,
293                                    void                  * start_func,
294                                    void                  * start_arg,
295                                    pthread_attr_t        * attr,
296                                    xptr_t                * thread_xp,
297                                    error_t               * error );
298
299void rpc_thread_user_create_server( xptr_t xp );
300
301/***********************************************************************************
302 * [7] The RPC_THREAD_KERNEL_CREATE creates a kernel thread in the server cluster,
303 * as specified by the type, func and args arguments. It returns the local pointer
304 * on the thread descriptor in server cluster and an error code.
305 * It is used by the dev_init() function to create the device server thread.
306 ***********************************************************************************
307 * @ cxy       : server cluster identifier.
308 * @ type      : [in]  type of kernel thread.
309 * @ func      : [in]  local pointer on thread function.
310 * @ args      : [in]  local pointer on function arguments.
311 * @ thread_xp : [out] pointer on buffer for thread extended pointer.
312 * @ error     : [out] error status (0 if success).
313 **********************************************************************************/
314void rpc_thread_kernel_create_client( cxy_t     cxy,
315                                      uint32_t  type,
316                                      void    * func,
317                                      void    * args,
318                                      xptr_t  * thread_xp,
319                                      error_t * error );
320
321void rpc_thread_kernel_create_server( xptr_t xp );
322
323/***********************************************************************************
324 * [8] The RPC_THREAD_KILL ask a target cluster to kill a given thread descriptor.
325 * It is called by the sys_thread_cancel() function for a remote thread.
326 ***********************************************************************************
327 * @ cxy       : server cluster identifier.
328 * @ thread   : [in]  local pointer on target process descriptor in server.
329 **********************************************************************************/
330void rpc_thread_kill_client( cxy_t              cxy,
331                             struct thread_s  * thread );
332                             
333void rpc_thread_kill_server( xptr_t xp );
334
335/***********************************************************************************
336 * [9] The RPC_PROCESS_SIGACTION allows the owner cluster to request any other
337 * cluster to execute a given sigaction (BLOCK / UNBLOCK / DELETE) for all threads
338 * of a given process.
339 *
340 * WARNING : It is implemented as a NON BLOCKING multicast RPC, that can be sent
341 * in parallel to all process copies. The various server threads must decrement the
342 * responses counter defined by the <rsp_xp> argument, and the last server thread
343 * must unblock the <client_xp> thread.
344 ***********************************************************************************
345 * @ cxy       : server cluster identifier.
346 * @ process   : [in]  local pointer on target process in server cluster.
347 * @ sigaction : [in]  action type (BLOCK / UNBLOCK / DELETE).
348 * @ rsp_xp    : [in]  extended pointer on response counter.
349 * @ client_xp : [in]  extended pointer on client thread.
350 **********************************************************************************/
351void rpc_process_sigaction_client( cxy_t               cxy,
352                                   struct process_s  * process,
353                                   uint32_t            sigaction,
354                                   xptr_t              rsp_xp,
355                                   xptr_t              client_xp );
356                             
357void rpc_process_sigaction_server( xptr_t xp );
358
359/***********************************************************************************
360 * [10] The RPC_VFS_INODE_CREATE creates an inode and the associated mapper in a
361 * remote cluster. The parent dentry must have been previously created.
362 * It returns an extended pointer on the created inode.
363 ***********************************************************************************
364 * @ cxy        :  server cluster identifier.
365 * @ dentry_xp  : [in]  extended pointer on parent dentry.
366 * @ fs_type    : [in]  file system type.
367 * @ inode_type : [in]  file system type.
368 * @ extend     : [in]  fs_type_specific inode extension.
369 * @ attr       : [in]  inode attributes.
370 * @ rights     : [in]  access rights
371 * @ uid        : [in]  user ID
372 * @ gid        : [in]  group ID
373 * @ inode_xp   : [out] buffer for extended pointer on created inode.
374 * @ error      : [out] error status (0 if success).
375 **********************************************************************************/
376void rpc_vfs_inode_create_client( cxy_t      cxy,
377                                  xptr_t     dentry_xp,
378                                  uint32_t   fs_type,
379                                  uint32_t   inode_type,
380                                  void     * extend,
381                                  uint32_t   attr,   
382                                  uint32_t   rights, 
383                                  uint32_t   uid,
384                                  uint32_t   gid,
385                                  xptr_t   * inode_xp,
386                                  error_t  * error );
387
388void rpc_vfs_inode_create_server( xptr_t xp );
389
390/***********************************************************************************
391 * [11] The RPC_VFS_INODE_DESTROY releases memory allocated for an inode descriptor
392 * and for the associated mapper in a remote cluster.
393 ***********************************************************************************
394 * @ cxy       :  server cluster identifier
395 * @ inode     : [in]  local pointer on inode.
396 **********************************************************************************/
397void rpc_vfs_inode_destroy_client( cxy_t                 cxy,
398                                   struct vfs_inode_s * inode );
399
400void rpc_vfs_inode_destroy_server( xptr_t xp );
401
402/***********************************************************************************
403 * [12] The RPC_VFS_DENTRY_CREATE creates a dentry in a remote cluster.
404 * It returns an extended pointer on the created dentry.
405 ***********************************************************************************
406 * @ cxy        :  server cluster identifier
407 * @ type       : [in]  file system type.
408 * @ name       : [in]  directory entry name.
409 * @ parent     : [in]  local pointer on parent inode.
410 * @ dentry_xp  : [out] buffer for extended pointer on created dentry.
411 * @ error      : [out] error status (0 if success).
412 **********************************************************************************/
413void rpc_vfs_dentry_create_client( cxy_t                  cxy,
414                                   uint32_t               type,
415                                   char                 * name,   
416                                   struct vfs_inode_s   * parent,
417                                   xptr_t               * dentry_xp,
418                                   error_t              * error );
419
420void rpc_vfs_dentry_create_server( xptr_t xp );
421
422/***********************************************************************************
423 * [13] The RPC_VFS_DENTRY_DESTROY releases memory allocated for an dentry descriptor
424 * in a remote cluster.
425 ***********************************************************************************
426 * @ cxy       :  server cluster identifier
427 * @ dentry     : [in]  local pointer on dentry.
428 **********************************************************************************/
429void rpc_vfs_dentry_destroy_client( cxy_t                 cxy,
430                                    struct vfs_dentry_s * dentry );
431
432void rpc_vfs_dentry_destroy_server( xptr_t xp );
433
434/***********************************************************************************
435 * [14] The RPC_VFS_FILE_CREATE creates a file descriptor in a remote cluster.
436 * It returns an extended pointer on the created file structure.
437 ***********************************************************************************
438 * @ cxy        :  server cluster identifier
439 * @ inode      : [in]  local pointer on parent inode.
440 * @ file_attr  : [in]  new file attributes.
441 * @ file_xp    : [out] buffer for extended pointer on created file.
442 * @ error      : [out] error status (0 if success).
443 **********************************************************************************/
444void rpc_vfs_file_create_client( cxy_t                  cxy,
445                                 struct vfs_inode_s   * inode,
446                                 uint32_t               file_attr,
447                                 xptr_t               * file_xp,
448                                 error_t              * error );
449
450void rpc_vfs_file_create_server( xptr_t xp );
451
452/***********************************************************************************
453 * [15] The RPC_VFS_FILE_DESTROY releases memory allocated for a file descriptor
454 * in a remote cluster.
455 ***********************************************************************************
456 * @ cxy       :  server cluster identifier
457 * @ file       : [in]  local pointer on file.
458 **********************************************************************************/
459void rpc_vfs_file_destroy_client( cxy_t               cxy,
460                                  struct vfs_file_s * file );
461
462void rpc_vfs_file_destroy_server( xptr_t xp );
463
464/***********************************************************************************
465 * [16] The RPC_VFS_LOAD_INODE calls the vfs_inode_load() kernel function in a
466 * remote cluster containing a parent inode directory to scan the associated
467 * mapper, find a directory entry, identified by its name, and update the remote
468 * child inode.
469 ***********************************************************************************
470 * @ cxy            :  server cluster identifier
471 * @ parent_inode   : [in]  local pointer on parent inode.
472 * @ name           : [in]  local pointer on child name (in client cluster).
473 * @ child_inode_xp : [in]  extended pointer on child inode (in another cluster).
474 * @ error          : [out] error status (0 if success).
475 **********************************************************************************/
476void rpc_vfs_inode_load_client( cxy_t                cxy,
477                                struct vfs_inode_s * parent_inode,
478                                char               * name,
479                                xptr_t               child_inode_xp,
480                                error_t            * error );
481
482void rpc_vfs_inode_load_server( xptr_t xp );
483
484/***********************************************************************************
485 * [17] The RPC_VFS_MAPPER_LOAD_ALL calls the vfs_mapper_load_all() kernel function
486 * in a remote cluster containing an inode, to load all pages of the associated
487 * mapper from the file system on device.
488 ***********************************************************************************
489 * @ cxy     :  server cluster identifier
490 * @ inode   : [in]  local pointer on inode in server cluster.
491 * @ error   : [out] error status (0 if success).
492 **********************************************************************************/
493void rpc_vfs_mapper_load_all_client( cxy_t                cxy,
494                                     struct vfs_inode_s * inode,
495                                     error_t            * error );
496
497void rpc_vfs_mapper_load_all_server( xptr_t xp );
498
499/***********************************************************************************
500 * [18] The RPC_FATFS_GET_CLUSTER can be send by any thread running in a "client"
501 * cluster to scan the FAT mapper, stored in a remote "server" cluster, and get
502 * from the mapper the local pointer on a given page.
503 ***********************************************************************************
504 * @ cxy      : server cluster identifier.
505 * @ mapper   : [in]  local pointer on FAT mapper.
506 * @ first    : [in]  FATFS cluster index allocated to first page of file.
507 * @ page     : [in]  page index in file.
508 * @ cluster  : [out] local pointer on buffer for found FATFS cluster index.
509 * @ error    : [out] local pointer on buffer for error code (in client cluster).
510 **********************************************************************************/
511void rpc_fatfs_get_cluster_client( cxy_t             cxy,
512                                   struct mapper_s * mapper,
513                                   uint32_t          first,
514                                   uint32_t          page,
515                                   uint32_t        * cluster,
516                                   error_t         * error );   
517
518void rpc_fatfs_get_cluster_server( xptr_t xp );
519
520/***********************************************************************************
521 * [20] The RPC_VMM_GET_VSEG returns an extended pointer
522 * on the vseg containing a given virtual address in a given process.
523 * The server cluster is supposed to be the reference cluster.
524 * It returns a non zero error value if no vseg has been founded.
525 ***********************************************************************************
526 * @ cxy     : server cluster identifier.
527 * @ process : [in]   pointer on process descriptor in server cluster.
528 * @ vaddr   : [in]   virtual address to be searched.
529 * @ vseg_xp : [out]  buffer for extended pointer on vseg in client cluster.
530 * @ error   : [out] local pointer on buffer for error code (in client cluster).
531 **********************************************************************************/
532void rpc_vmm_get_vseg_client( cxy_t              cxy,
533                              struct process_s * process,
534                              intptr_t           vaddr,
535                              xptr_t           * vseg_xp,
536                              error_t          * error );
537
538void rpc_vmm_get_vseg_server( xptr_t xp );
539
540/***********************************************************************************
541 * [21] The RPC_VMM_GET_PTE returns in the <ppn> and <attr> arguments the PTE value
542 * for a given <vpn> in a given <process> (page_fault or copy_on_write event).
543 * The server cluster is supposed to be the reference cluster, and the vseg
544 * containing the VPN must be registered in the reference VMM.
545 * It returns an error if physical memory cannot be allocated for the missing PTE2,
546 * or for the missing page itself.
547 ***********************************************************************************
548 * @ cxy     : server cluster identifier.
549 * @ process : [in]   pointer on process descriptor in server cluster.
550 * @ vaddr   : [in]   virtual address to be searched.
551 * @ cow     : [in]   "copy_on_write" event if true / "page_fault" event if false.
552 * @ attr    : [out]  address of buffer for attributes.
553 * @ ppn     : [out]  address of buffer for PPN.
554 * @ error   : [out]  address of buffer for error code.
555 **********************************************************************************/
556void rpc_vmm_get_pte_client( cxy_t              cxy,
557                             struct process_s * process,
558                             vpn_t              vpn,
559                             bool_t             cow,
560                             uint32_t         * attr,
561                             ppn_t            * ppn,
562                             error_t          * error );
563
564void rpc_vmm_get_pte_server( xptr_t xp );
565
566/***********************************************************************************
567 * [22] The RPC_KCM_ALLOC allocates memory from a given KCM in a remote cluster,
568 * and returns an extended pointer on the allocated object.
569  It returns XPTR_NULL if physical memory cannot be allocated.
570 ***********************************************************************************
571 * @ cxy       : server cluster identifier.
572 * @ kmem_type : [in]  KCM object type (as defined in kmem.h).
573 * @ buf_xp    : [out] buffer for extended pointer on allocated buffer.
574 **********************************************************************************/
575void rpc_kcm_alloc_client( cxy_t      cxy,
576                           uint32_t   kmem_type,
577                           xptr_t   * buf_xp ); 
578
579void rpc_kcm_alloc_server( xptr_t xp );
580
581/***********************************************************************************
582 * [23] The RPC_KCM_FREE releases memory allocated for a KCM object of a given type,
583 * in a remote cluster.
584 ***********************************************************************************
585 * @ cxy       : server cluster identifier.
586 * @ buf       : [in] local pointer on allocated buffer.
587 * @ kmem_type : [in]  KCM object type (as defined in kmem.h).
588 **********************************************************************************/
589void rpc_kcm_free_client( cxy_t     cxy,
590                          void    * buf,
591                          uint32_t  kmem_type );
592
593void rpc_kcm_free_server( xptr_t xp );
594
595/***********************************************************************************
596 * [24] The RPC_MAPPER_MOVE_BUFFER allows a client thread to require a remote
597 * mapper to move data to/from a kernel or user buffer.
598 * - It calls the mapper_move_user() function for a - possibly distributed -
599 *   user buffer identified by a user-space pointer, and casted to uint64_t.
600 * - It calls the mapper_move_kernel() function for a - possibly remote -
601 *   kernel buffer identified by an extended pointer, and casted to uint64_t.
602 * It is used by the vfs_move_user() function to move data between a mapper
603 * and an user buffer required by a sys_read() or a sys_write().
604 * It is used by the vmm_get_one_ppn() function to initialise a physical page
605 * from a .elf file mapper, for a CODE or DATA vseg page fault.
606 ***********************************************************************************
607 * @ cxy         : server cluster identifier.
608 * @ mapper      : [in]  local pointer on mapper
609 * @ to_buffer   : [in]  move data from mapper to buffer if non zero.
610 * @ is_user     : [in]  buffer in user space if true
611 * @ file_offset : [in]  first byte to move in mapper
612 * @ buffer      : [in]  user space pointer / kernel extended pointer
613 * @ size        : [in]  number of bytes to move
614 * @ error       : [out] error status (0 if success).
615 **********************************************************************************/
616void rpc_mapper_move_buffer_client( cxy_t             cxy,
617                                    struct mapper_s * mapper,
618                                    bool_t            to_buffer,
619                                    bool_t            is_user,
620                                    uint32_t          file_offset,
621                                    uint64_t          buffer,
622                                    uint32_t          size,
623                                    error_t         * error );
624
625void rpc_mapper_move_buffer_server( xptr_t xp );
626
627/***********************************************************************************
628 * [25] The RPC_MAPPER_GET_PAGE allows a client thread to get the local pointer
629 * on a remote page descriptor, for a page, identified by the page index in mapper.
630 * It is used by the vmm_get_one_ppn() function to handle a page fault on
631 * a FILE type vseg.
632 ***********************************************************************************
633 * @ cxy         : server cluster identifier.
634 * @ mapper      : [in]  local pointer on mapper.
635 * @ index       : [in]  page index in mapper.
636 * @ page        : [out] local pointer on page descriptor / NULL if failure.
637 **********************************************************************************/
638void rpc_mapper_get_page_client( cxy_t             cxy,
639                                 struct mapper_s * mapper,
640                                 uint32_t          index,
641                                 struct page_s  ** page );
642
643void rpc_mapper_get_page_server( xptr_t xp );
644
645/***********************************************************************************
646 * [26] The RPC_VMM_CREATE_VSEG allows a client thread to request the remote
647 * reference cluster of a given process to allocate and register in the reference
648 * process VMM a new vseg descriptor.
649 * On the server side, this RPC uses the vmm_create_vseg() function, and returns
650 * to the client the local pointer on the created vseg descriptor.
651 ***********************************************************************************
652 * @ cxy         : server cluster identifier.
653 * @ process     : [in]  local pointer on process descriptor in server.
654 * @ type        : [in]  vseg type.
655 * @ base        : [in]  base address (unused for dynamically allocated vsegs).
656 * @ size        : [in]  number of bytes.
657 * @ file_offset : [in]  offset in file (for CODE, DATA, FILE types).
658 * @ file_size   : [in]  can be smaller than size for DATA type.
659 * @ mapper_xp   : [in]  extended pointer on mapper (for CODE, DATA, FILE types).
660 * @ vseg_cxy    : [in]  target cluster for mapping (if not data type).
661 * @ vseg        : [out] local pointer on vseg descriptor / NULL if failure.
662 **********************************************************************************/
663void rpc_vmm_create_vseg_client( cxy_t              cxy,
664                                 struct process_s * process,
665                                 vseg_type_t        type,
666                                 intptr_t           base,
667                                 uint32_t           size,
668                                 uint32_t           file_offset,
669                                 uint32_t           file_size,
670                                 xptr_t             mapper_xp,
671                                 cxy_t              vseg_cxy,
672                                 struct vseg_s   ** vseg );
673
674void rpc_vmm_create_vseg_server( xptr_t xp );
675
676/***********************************************************************************
677 * [27] The RPC_SCHED_DISPLAY allows a client thread to request the display
678 * of a remote scheduler, identified by the <lid> argument.
679 ***********************************************************************************
680 * @ cxy         : server cluster identifier.
681 * @ lid         : [in]  local index of target core in client cluster.
682 **********************************************************************************/
683void rpc_sched_display_client( cxy_t              cxy,
684                               lid_t              lid );
685
686void rpc_sched_display_server( xptr_t xp );
687
688/***********************************************************************************
689 * [28] The RPC_VMM_SET_COW allows a client thread to request the remote reference
690 * cluster to set the COW flag and reset the WRITABLE flag of all GPT entries for
691 * the DATA, MMAP and REMOTE vsegs of process identified by the <process> argument.
692
693 * of a remote scheduler, identified by the <lid> argument.
694 ***********************************************************************************
695 * @ cxy         : server cluster identifier.
696 * @ process     : [in]  local pointer on reference process descriptor.
697 **********************************************************************************/
698void rpc_vmm_set_cow_client( cxy_t              cxy,
699                             struct process_s * process );
700
701void rpc_vmm_set_cow_server( xptr_t xp );
702
703#endif
Note: See TracBrowser for help on using the repository browser.