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

Last change on this file since 428 was 428, checked in by alain, 6 years ago

blip

File size: 37.7 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    RPC_VMM_DISPLAY            = 29,
93
94    RPC_MAX_INDEX              = 30,
95}
96rpc_index_t;
97
98/***********************************************************************************
99 * This defines the prototype of the rpc_server functions,
100 * defined by the rpc_server[] array in the rpc.c file.
101 **********************************************************************************/
102
103typedef  void (rpc_server_t) ( xptr_t xp );
104
105/***********************************************************************************
106 *  This structure defines the RPC descriptor
107 **********************************************************************************/
108
109typedef struct rpc_desc_s
110{
111        rpc_index_t         index;       /*! index of requested RPC service           */
112        volatile uint32_t   response;    /*! all responses received when 0            */
113    struct thread_s   * thread;      /*! local pointer on client thread           */
114    uint32_t            lid;         /*! index of core running the calling thread */ 
115    bool_t              blocking;    /*! blocking RPC when true                   */
116    uint64_t            args[10];    /*! input/output arguments buffer            */
117} 
118rpc_desc_t;
119
120/**********************************************************************************/
121/******* Generic functions supporting RPCs : client side **************************/
122/**********************************************************************************/
123
124/***********************************************************************************
125 * This function is executed by the client thread in the client cluster.
126 * It puts one RPC descriptor defined by the <desc> argument in the remote fifo
127 * defined by the <cxy> argument.  It sends an IPI to the server if fifo is empty.
128 * The RPC descriptor must be allocated in the caller's stack, and initialised by
129 * the caller. It exit with a Panic message if remote fifo is still full after
130 * (CONFIG_RPC_PUT_MAX_ITERATIONS) retries.
131 * - When the RPC <blocking> field is true, this function blocks and deschedule.
132 *   It returns only when the server acknowledges the RPC by writing in the RPC
133 *   "response" field, and unblocks the client.
134 * - When the <blocking> field is false, this function returns as soon as the RPC
135 *   has been registered in the FIFO, and the server thread must directly signal
136 *   completion to the client thread.
137 ***********************************************************************************
138 * @ cxy   : server cluster identifier
139 * @ desc  : local pointer on RPC descriptor in client cluster
140 **********************************************************************************/
141void rpc_send( cxy_t        cxy,   
142               rpc_desc_t * desc );
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 the target process.
255 ***********************************************************************************
256 * @ cxy      : owner cluster identifier.
257 * @ pid      : target process identifier.
258 * @ status   : calling process exit status.
259 **********************************************************************************/
260void rpc_process_make_exit_client( cxy_t              cxy,
261                                   pid_t              pid,
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      : owner cluster identifier.
271 * @ pid      : target process identifier.
272 * @ seg_id   : signal type (only SIGKILL / SIGSTOP / SIGCONT are supported).
273 **********************************************************************************/
274void rpc_process_make_kill_client( cxy_t              cxy,
275                                   pid_t              pid,
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 rpc descriptor is allocated in the client
342 * thread stack by the process_sigaction() function. The various server threads
343 * must decrement the responses counter defined in the rsp descriptor, and the last
344 * server thread unblock the client thread that blocked (after sending all RPC
345 * requests) in the process_sigaction() function.
346 * - The first RPC argument is the sigaction type (BLOCK / UNBLOCK / DELETE).
347 * - The second RPC argument is the local pointer on target process.
348 ***********************************************************************************
349 * @ cxy       : server cluster identifier.
350 * @ rpc_ptr   : [in]  local pointer on rpc descriptor in client cluster.
351 **********************************************************************************/
352void rpc_process_sigaction_client( cxy_t        cxy,
353                                   rpc_desc_t * rpc_ptr );
354                             
355void rpc_process_sigaction_server( xptr_t xp );
356
357/***********************************************************************************
358 * [10] The RPC_VFS_INODE_CREATE creates an inode and the associated mapper in a
359 * remote cluster. The parent dentry must have been previously created.
360 * It returns an extended pointer on the created inode.
361 ***********************************************************************************
362 * @ cxy        :  server cluster identifier.
363 * @ dentry_xp  : [in]  extended pointer on parent dentry.
364 * @ fs_type    : [in]  file system type.
365 * @ inode_type : [in]  file system type.
366 * @ extend     : [in]  fs_type_specific inode extension.
367 * @ attr       : [in]  inode attributes.
368 * @ rights     : [in]  access rights
369 * @ uid        : [in]  user ID
370 * @ gid        : [in]  group ID
371 * @ inode_xp   : [out] buffer for extended pointer on created inode.
372 * @ error      : [out] error status (0 if success).
373 **********************************************************************************/
374void rpc_vfs_inode_create_client( cxy_t      cxy,
375                                  xptr_t     dentry_xp,
376                                  uint32_t   fs_type,
377                                  uint32_t   inode_type,
378                                  void     * extend,
379                                  uint32_t   attr,   
380                                  uint32_t   rights, 
381                                  uint32_t   uid,
382                                  uint32_t   gid,
383                                  xptr_t   * inode_xp,
384                                  error_t  * error );
385
386void rpc_vfs_inode_create_server( xptr_t xp );
387
388/***********************************************************************************
389 * [11] The RPC_VFS_INODE_DESTROY releases memory allocated for an inode descriptor
390 * and for the associated mapper in a remote cluster.
391 ***********************************************************************************
392 * @ cxy       :  server cluster identifier
393 * @ inode     : [in]  local pointer on inode.
394 **********************************************************************************/
395void rpc_vfs_inode_destroy_client( cxy_t                 cxy,
396                                   struct vfs_inode_s * inode );
397
398void rpc_vfs_inode_destroy_server( xptr_t xp );
399
400/***********************************************************************************
401 * [12] The RPC_VFS_DENTRY_CREATE creates a dentry in a remote cluster.
402 * It returns an extended pointer on the created dentry.
403 ***********************************************************************************
404 * @ cxy        :  server cluster identifier
405 * @ type       : [in]  file system type.
406 * @ name       : [in]  directory entry name.
407 * @ parent     : [in]  local pointer on parent inode.
408 * @ dentry_xp  : [out] buffer for extended pointer on created dentry.
409 * @ error      : [out] error status (0 if success).
410 **********************************************************************************/
411void rpc_vfs_dentry_create_client( cxy_t                  cxy,
412                                   uint32_t               type,
413                                   char                 * name,   
414                                   struct vfs_inode_s   * parent,
415                                   xptr_t               * dentry_xp,
416                                   error_t              * error );
417
418void rpc_vfs_dentry_create_server( xptr_t xp );
419
420/***********************************************************************************
421 * [13] The RPC_VFS_DENTRY_DESTROY releases memory allocated for an dentry descriptor
422 * in a remote cluster.
423 ***********************************************************************************
424 * @ cxy       :  server cluster identifier
425 * @ dentry     : [in]  local pointer on dentry.
426 **********************************************************************************/
427void rpc_vfs_dentry_destroy_client( cxy_t                 cxy,
428                                    struct vfs_dentry_s * dentry );
429
430void rpc_vfs_dentry_destroy_server( xptr_t xp );
431
432/***********************************************************************************
433 * [14] The RPC_VFS_FILE_CREATE creates a file descriptor in a remote cluster.
434 * It returns an extended pointer on the created file structure.
435 ***********************************************************************************
436 * @ cxy        :  server cluster identifier
437 * @ inode      : [in]  local pointer on parent inode.
438 * @ file_attr  : [in]  new file attributes.
439 * @ file_xp    : [out] buffer for extended pointer on created file.
440 * @ error      : [out] error status (0 if success).
441 **********************************************************************************/
442void rpc_vfs_file_create_client( cxy_t                  cxy,
443                                 struct vfs_inode_s   * inode,
444                                 uint32_t               file_attr,
445                                 xptr_t               * file_xp,
446                                 error_t              * error );
447
448void rpc_vfs_file_create_server( xptr_t xp );
449
450/***********************************************************************************
451 * [15] The RPC_VFS_FILE_DESTROY releases memory allocated for a file descriptor
452 * in a remote cluster.
453 ***********************************************************************************
454 * @ cxy       :  server cluster identifier
455 * @ file       : [in]  local pointer on file.
456 **********************************************************************************/
457void rpc_vfs_file_destroy_client( cxy_t               cxy,
458                                  struct vfs_file_s * file );
459
460void rpc_vfs_file_destroy_server( xptr_t xp );
461
462/***********************************************************************************
463 * [16] The RPC_VFS_LOAD_INODE calls the vfs_inode_load() kernel function in a
464 * remote cluster containing a parent inode directory to scan the associated
465 * mapper, find a directory entry, identified by its name, and update the remote
466 * child inode.
467 ***********************************************************************************
468 * @ cxy            :  server cluster identifier
469 * @ parent_inode   : [in]  local pointer on parent inode.
470 * @ name           : [in]  local pointer on child name (in client cluster).
471 * @ child_inode_xp : [in]  extended pointer on child inode (in another cluster).
472 * @ error          : [out] error status (0 if success).
473 **********************************************************************************/
474void rpc_vfs_inode_load_client( cxy_t                cxy,
475                                struct vfs_inode_s * parent_inode,
476                                char               * name,
477                                xptr_t               child_inode_xp,
478                                error_t            * error );
479
480void rpc_vfs_inode_load_server( xptr_t xp );
481
482/***********************************************************************************
483 * [17] The RPC_VFS_MAPPER_LOAD_ALL calls the vfs_mapper_load_all() kernel function
484 * in a remote cluster containing an inode, to load all pages of the associated
485 * mapper from the file system on device.
486 ***********************************************************************************
487 * @ cxy     :  server cluster identifier
488 * @ inode   : [in]  local pointer on inode in server cluster.
489 * @ error   : [out] error status (0 if success).
490 **********************************************************************************/
491void rpc_vfs_mapper_load_all_client( cxy_t                cxy,
492                                     struct vfs_inode_s * inode,
493                                     error_t            * error );
494
495void rpc_vfs_mapper_load_all_server( xptr_t xp );
496
497/***********************************************************************************
498 * [18] The RPC_FATFS_GET_CLUSTER can be send by any thread running in a "client"
499 * cluster to scan the FAT mapper, stored in a remote "server" cluster, and get
500 * from the mapper the local pointer on a given page.
501 ***********************************************************************************
502 * @ cxy      : server cluster identifier.
503 * @ mapper   : [in]  local pointer on FAT mapper.
504 * @ first    : [in]  FATFS cluster index allocated to first page of file.
505 * @ page     : [in]  page index in file.
506 * @ cluster  : [out] local pointer on buffer for found FATFS cluster index.
507 * @ error    : [out] local pointer on buffer for error code (in client cluster).
508 **********************************************************************************/
509void rpc_fatfs_get_cluster_client( cxy_t             cxy,
510                                   struct mapper_s * mapper,
511                                   uint32_t          first,
512                                   uint32_t          page,
513                                   uint32_t        * cluster,
514                                   error_t         * error );   
515
516void rpc_fatfs_get_cluster_server( xptr_t xp );
517
518/***********************************************************************************
519 * [20] The RPC_VMM_GET_VSEG returns an extended pointer
520 * on the vseg containing a given virtual address in a given process.
521 * The server cluster is supposed to be the reference cluster.
522 * It returns a non zero error value if no vseg has been founded.
523 ***********************************************************************************
524 * @ cxy     : server cluster identifier.
525 * @ process : [in]   pointer on process descriptor in server cluster.
526 * @ vaddr   : [in]   virtual address to be searched.
527 * @ vseg_xp : [out]  buffer for extended pointer on vseg in client cluster.
528 * @ error   : [out] local pointer on buffer for error code (in client cluster).
529 **********************************************************************************/
530void rpc_vmm_get_vseg_client( cxy_t              cxy,
531                              struct process_s * process,
532                              intptr_t           vaddr,
533                              xptr_t           * vseg_xp,
534                              error_t          * error );
535
536void rpc_vmm_get_vseg_server( xptr_t xp );
537
538/***********************************************************************************
539 * [21] The RPC_VMM_GET_PTE returns in the <ppn> and <attr> arguments the PTE value
540 * for a given <vpn> in a given <process> (page_fault or copy_on_write event).
541 * The server cluster is supposed to be the reference cluster, and the vseg
542 * containing the VPN must be registered in the reference VMM.
543 * It returns an error if physical memory cannot be allocated for the missing PTE2,
544 * or for the missing page itself.
545 ***********************************************************************************
546 * @ cxy     : server cluster identifier.
547 * @ process : [in]   pointer on process descriptor in server cluster.
548 * @ vaddr   : [in]   virtual address to be searched.
549 * @ cow     : [in]   "copy_on_write" event if true / "page_fault" event if false.
550 * @ attr    : [out]  address of buffer for attributes.
551 * @ ppn     : [out]  address of buffer for PPN.
552 * @ error   : [out]  address of buffer for error code.
553 **********************************************************************************/
554void rpc_vmm_get_pte_client( cxy_t              cxy,
555                             struct process_s * process,
556                             vpn_t              vpn,
557                             bool_t             cow,
558                             uint32_t         * attr,
559                             ppn_t            * ppn,
560                             error_t          * error );
561
562void rpc_vmm_get_pte_server( xptr_t xp );
563
564/***********************************************************************************
565 * [22] The RPC_KCM_ALLOC allocates memory from a given KCM in a remote cluster,
566 * and returns an extended pointer on the allocated object.
567  It returns XPTR_NULL if physical memory cannot be allocated.
568 ***********************************************************************************
569 * @ cxy       : server cluster identifier.
570 * @ kmem_type : [in]  KCM object type (as defined in kmem.h).
571 * @ buf_xp    : [out] buffer for extended pointer on allocated buffer.
572 **********************************************************************************/
573void rpc_kcm_alloc_client( cxy_t      cxy,
574                           uint32_t   kmem_type,
575                           xptr_t   * buf_xp ); 
576
577void rpc_kcm_alloc_server( xptr_t xp );
578
579/***********************************************************************************
580 * [23] The RPC_KCM_FREE releases memory allocated for a KCM object of a given type,
581 * in a remote cluster.
582 ***********************************************************************************
583 * @ cxy       : server cluster identifier.
584 * @ buf       : [in] local pointer on allocated buffer.
585 * @ kmem_type : [in]  KCM object type (as defined in kmem.h).
586 **********************************************************************************/
587void rpc_kcm_free_client( cxy_t     cxy,
588                          void    * buf,
589                          uint32_t  kmem_type );
590
591void rpc_kcm_free_server( xptr_t xp );
592
593/***********************************************************************************
594 * [24] The RPC_MAPPER_MOVE_BUFFER allows a client thread to require a remote
595 * mapper to move data to/from a kernel or user buffer.
596 * - It calls the mapper_move_user() function for a - possibly distributed -
597 *   user buffer identified by a user-space pointer, and casted to uint64_t.
598 * - It calls the mapper_move_kernel() function for a - possibly remote -
599 *   kernel buffer identified by an extended pointer, and casted to uint64_t.
600 * It is used by the vfs_move_user() function to move data between a mapper
601 * and an user buffer required by a sys_read() or a sys_write().
602 * It is used by the vmm_get_one_ppn() function to initialise a physical page
603 * from a .elf file mapper, for a CODE or DATA vseg page fault.
604 ***********************************************************************************
605 * @ cxy         : server cluster identifier.
606 * @ mapper      : [in]  local pointer on mapper
607 * @ to_buffer   : [in]  move data from mapper to buffer if non zero.
608 * @ is_user     : [in]  buffer in user space if true
609 * @ file_offset : [in]  first byte to move in mapper
610 * @ buffer      : [in]  user space pointer / kernel extended pointer
611 * @ size        : [in]  number of bytes to move
612 * @ error       : [out] error status (0 if success).
613 **********************************************************************************/
614void rpc_mapper_move_buffer_client( cxy_t             cxy,
615                                    struct mapper_s * mapper,
616                                    bool_t            to_buffer,
617                                    bool_t            is_user,
618                                    uint32_t          file_offset,
619                                    uint64_t          buffer,
620                                    uint32_t          size,
621                                    error_t         * error );
622
623void rpc_mapper_move_buffer_server( xptr_t xp );
624
625/***********************************************************************************
626 * [25] The RPC_MAPPER_GET_PAGE allows a client thread to get the local pointer
627 * on a remote page descriptor, for a page, identified by the page index in mapper.
628 * It is used by the vmm_get_one_ppn() function to handle a page fault on
629 * a FILE type vseg.
630 ***********************************************************************************
631 * @ cxy         : server cluster identifier.
632 * @ mapper      : [in]  local pointer on mapper.
633 * @ index       : [in]  page index in mapper.
634 * @ page        : [out] local pointer on page descriptor / NULL if failure.
635 **********************************************************************************/
636void rpc_mapper_get_page_client( cxy_t             cxy,
637                                 struct mapper_s * mapper,
638                                 uint32_t          index,
639                                 struct page_s  ** page );
640
641void rpc_mapper_get_page_server( xptr_t xp );
642
643/***********************************************************************************
644 * [26] The RPC_VMM_CREATE_VSEG allows a client thread to request the remote
645 * reference cluster of a given process to allocate and register in the reference
646 * process VMM a new vseg descriptor.
647 * On the server side, this RPC uses the vmm_create_vseg() function, and returns
648 * to the client the local pointer on the created vseg descriptor.
649 ***********************************************************************************
650 * @ cxy         : server cluster identifier.
651 * @ process     : [in]  local pointer on process descriptor in server.
652 * @ type        : [in]  vseg type.
653 * @ base        : [in]  base address (unused for dynamically allocated vsegs).
654 * @ size        : [in]  number of bytes.
655 * @ file_offset : [in]  offset in file (for CODE, DATA, FILE types).
656 * @ file_size   : [in]  can be smaller than size for DATA type.
657 * @ mapper_xp   : [in]  extended pointer on mapper (for CODE, DATA, FILE types).
658 * @ vseg_cxy    : [in]  target cluster for mapping (if not data type).
659 * @ vseg        : [out] local pointer on vseg descriptor / NULL if failure.
660 **********************************************************************************/
661void rpc_vmm_create_vseg_client( cxy_t              cxy,
662                                 struct process_s * process,
663                                 vseg_type_t        type,
664                                 intptr_t           base,
665                                 uint32_t           size,
666                                 uint32_t           file_offset,
667                                 uint32_t           file_size,
668                                 xptr_t             mapper_xp,
669                                 cxy_t              vseg_cxy,
670                                 struct vseg_s   ** vseg );
671
672void rpc_vmm_create_vseg_server( xptr_t xp );
673
674/***********************************************************************************
675 * [27] The RPC_SCHED_DISPLAY allows a client thread to request the display
676 * of a remote scheduler, identified by the <lid> argument.
677 ***********************************************************************************
678 * @ cxy         : server cluster identifier.
679 * @ lid         : [in]  local index of target core in client cluster.
680 **********************************************************************************/
681void rpc_sched_display_client( cxy_t              cxy,
682                               lid_t              lid );
683
684void rpc_sched_display_server( xptr_t xp );
685
686/***********************************************************************************
687 * [28] The RPC_VMM_SET_COW allows a client thread to request the remote reference
688 * cluster to set the COW flag and reset the WRITABLE flag of all GPT entries for
689 * the DATA, MMAP and REMOTE vsegs of process identified by the <process> argument.
690
691 * of a remote scheduler, identified by the <lid> argument.
692 ***********************************************************************************
693 * @ cxy         : server cluster identifier.
694 * @ process     : [in]  local pointer on reference process descriptor.
695 **********************************************************************************/
696void rpc_vmm_set_cow_client( cxy_t              cxy,
697                             struct process_s * process );
698
699void rpc_vmm_set_cow_server( xptr_t xp );
700
701/***********************************************************************************
702 * [29] The RPC_VMM_DISPLAY allows any client thread to display the VMM state
703 * of a remote reference process identified by the <cxy> and <process> arguments.
704 * The type of display is defined by the <detailed> boolean argument.
705 ***********************************************************************************
706 * @ cxy         : server cluster identifier.
707 * @ process     : [in]  local pointer on reference process descriptor.
708 * @ detailed    : [in]  detailed display if true.
709 **********************************************************************************/
710void rpc_vmm_display_client( cxy_t              cxy,
711                             struct process_s * process,
712                             bool_t             detailed );
713
714void rpc_vmm_display_server( xptr_t xp );
715
716
717#endif
Note: See TracBrowser for help on using the repository browser.