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

Last change on this file since 421 was 416, checked in by alain, 7 years ago

Improve sys_exec.

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