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 <remote_fifo.h> |
---|
33 | |
---|
34 | /**** Forward declarations ****/ |
---|
35 | |
---|
36 | struct process_s; |
---|
37 | struct page_s; |
---|
38 | struct vseg_s; |
---|
39 | struct exec_info_s; |
---|
40 | struct pthread_attr_s; |
---|
41 | struct remote_sem_s; |
---|
42 | struct fragment_s; |
---|
43 | struct vfs_inode_s; |
---|
44 | struct vfs_dentry_s; |
---|
45 | struct vfs_file_s; |
---|
46 | struct thread_s; |
---|
47 | struct mapper_s; |
---|
48 | |
---|
49 | /**********************************************************************************/ |
---|
50 | /************** structures for Remote Procedure Calls ****************************/ |
---|
51 | /**********************************************************************************/ |
---|
52 | |
---|
53 | /*********************************************************************************** |
---|
54 | * This enum defines all RPC indexes. |
---|
55 | * It must be consistent with the rpc_server[] array defined in in the rpc.c file. |
---|
56 | **********************************************************************************/ |
---|
57 | |
---|
58 | typedef enum |
---|
59 | { |
---|
60 | RPC_PMEM_GET_PAGES = 0, |
---|
61 | RPC_PROCESS_PID_ALLOC = 1, |
---|
62 | RPC_PROCESS_EXEC = 2, |
---|
63 | RPC_PROCESS_KILL = 3, |
---|
64 | RPC_THREAD_USER_CREATE = 4, |
---|
65 | RPC_THREAD_KERNEL_CREATE = 5, |
---|
66 | RPC_SIGNAL_RISE = 6, |
---|
67 | |
---|
68 | RPC_VFS_INODE_CREATE = 10, |
---|
69 | RPC_VFS_INODE_DESTROY = 11, |
---|
70 | RPC_VFS_DENTRY_CREATE = 12, |
---|
71 | RPC_VFS_DENTRY_DESTROY = 13, |
---|
72 | RPC_VFS_FILE_CREATE = 14, |
---|
73 | RPC_VFS_FILE_DESTROY = 15, |
---|
74 | RPC_VFS_INODE_LOAD = 16, |
---|
75 | RPC_VFS_MAPPER_LOAD_ALL = 17, |
---|
76 | RPC_FATFS_GET_CLUSTER = 18, |
---|
77 | |
---|
78 | RPC_VMM_GET_REF_VSEG = 20, |
---|
79 | RPC_VMM_GET_PTE = 21, |
---|
80 | RPC_KCM_ALLOC = 22, |
---|
81 | RPC_KCM_FREE = 23, |
---|
82 | RPC_MAPPER_MOVE_BUFFER = 24, |
---|
83 | RPC_MAPPER_GET_PAGE = 25, |
---|
84 | |
---|
85 | RPC_MAX_INDEX = 30, |
---|
86 | } |
---|
87 | rpc_index_t; |
---|
88 | |
---|
89 | /*********************************************************************************** |
---|
90 | * This defines the prototype of the rpc_server functions, |
---|
91 | * defined by the rpc_server[] array in the rpc.c file. |
---|
92 | **********************************************************************************/ |
---|
93 | |
---|
94 | typedef void (rpc_server_t) ( xptr_t xp ); |
---|
95 | |
---|
96 | /*********************************************************************************** |
---|
97 | * This structure defines the RPC descriptor |
---|
98 | **********************************************************************************/ |
---|
99 | |
---|
100 | typedef struct rpc_desc_s |
---|
101 | { |
---|
102 | rpc_index_t index; // index of requested RPC service |
---|
103 | volatile uint32_t response; // response valid when 0 |
---|
104 | uint64_t args[10]; // input/output arguments buffer |
---|
105 | } |
---|
106 | rpc_desc_t; |
---|
107 | |
---|
108 | /*********************************************************************************** |
---|
109 | * This structure defines the RPC fifo, containing a remote_fifo, the owner RPC |
---|
110 | * thread TRDID (used as a light lock), and the intrumentation counter. |
---|
111 | * |
---|
112 | * Implementation note: the TRDID is a good owner identifier, because all |
---|
113 | * RPC threads in a given cluster belong to the same process_zero kernel process, |
---|
114 | * and RPC threads cannot have local index LTID = 0. |
---|
115 | **********************************************************************************/ |
---|
116 | |
---|
117 | typedef struct rpc_fifo_s |
---|
118 | { |
---|
119 | trdid_t owner; // owner thread / 0 if no owner |
---|
120 | uint64_t count; // total number of received RPCs (instrumentation) |
---|
121 | remote_fifo_t fifo; // embedded remote fifo |
---|
122 | } |
---|
123 | rpc_fifo_t; |
---|
124 | |
---|
125 | |
---|
126 | /**********************************************************************************/ |
---|
127 | /******* Generic functions supporting RPCs : client side **************************/ |
---|
128 | /**********************************************************************************/ |
---|
129 | |
---|
130 | /*********************************************************************************** |
---|
131 | * This blocking function executes on the client core. |
---|
132 | * It puts one RPC extended pointer in the remote fifo. |
---|
133 | * It sends an IPI if fifo is empty, and waits until RPC response available. |
---|
134 | * The RPC descriptor must be allocated in the caller's stack |
---|
135 | * and initialised by the caller. Exit with a Panic message if remote fifo |
---|
136 | * is still full after (CONFIG_RPC_PUT_MAX_ITERATIONS) retries. |
---|
137 | *********************************************************************************** |
---|
138 | * @ cxy : server cluster identifier |
---|
139 | * @ desc : local pointer on RPC descriptor in client cluster |
---|
140 | **********************************************************************************/ |
---|
141 | void rpc_send_sync( 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 initialises the local RPC fifo and the lock protecting readers. |
---|
152 | * The number of slots is defined by the CONFIG_REMOTE_FIFO_SLOTS parameter. |
---|
153 | * Each slot contains an extended pointer on the RPC descriptor. |
---|
154 | *********************************************************************************** |
---|
155 | * @ rf : pointer on the local RPC fifo. |
---|
156 | **********************************************************************************/ |
---|
157 | void rpc_fifo_init( rpc_fifo_t * rf ); |
---|
158 | |
---|
159 | /*********************************************************************************** |
---|
160 | * This function is the entry point for RPC handling on the server side. |
---|
161 | * It is executed by a core receiving an IPI. |
---|
162 | * It checks the RPC fifo, try to take the light-lock and activates (or creates) |
---|
163 | * an RPC thread in case of success. |
---|
164 | *********************************************************************************** |
---|
165 | * @ returns true if success / false otherwise. |
---|
166 | **********************************************************************************/ |
---|
167 | bool_t rpc_check(); |
---|
168 | |
---|
169 | /*********************************************************************************** |
---|
170 | * This function contains the loop to execute all pending RPCs on the server side. |
---|
171 | * It should be called with irq disabled and after light lock acquisition. |
---|
172 | *********************************************************************************** |
---|
173 | * @ rpc_fifo : pointer on the local RPC fifo |
---|
174 | **********************************************************************************/ |
---|
175 | void rpc_execute_all( rpc_fifo_t * rpc_fifo ); |
---|
176 | |
---|
177 | /********************************************************************************** |
---|
178 | * This function is called by any thread running on any core in any cluster, |
---|
179 | * that detected a non-empty RPC_FIFO and got the RPC_FIFO ownership. |
---|
180 | * It activates one RPC thread, and immediately switches to the RPC thread. |
---|
181 | * It gets the first free RPC thread from the core free-list, or creates a new one |
---|
182 | * when the core free-list is empty. |
---|
183 | *********************************************************************************** |
---|
184 | * @ rpc_fifo : pointer on the non-empty RPC fifo. |
---|
185 | * @ return 0 if success / return ENOMEM if error. |
---|
186 | **********************************************************************************/ |
---|
187 | error_t rpc_activate_thread( rpc_fifo_t * rpc_fifo ); |
---|
188 | |
---|
189 | /*********************************************************************************** |
---|
190 | * This function contains the infinite loop executed by each RPC thread. |
---|
191 | **********************************************************************************/ |
---|
192 | void rpc_thread_func(); |
---|
193 | |
---|
194 | /*********************************************************************************** |
---|
195 | * This function is executed in case of illegal RPC index. |
---|
196 | **********************************************************************************/ |
---|
197 | void __attribute__((noinline)) rpc_undefined(); |
---|
198 | |
---|
199 | |
---|
200 | |
---|
201 | |
---|
202 | /**********************************************************************************/ |
---|
203 | /******* Marshalling functions attached to the various RPCs ***********************/ |
---|
204 | /**********************************************************************************/ |
---|
205 | |
---|
206 | /*********************************************************************************** |
---|
207 | * [0] The RPC_PMEM_GET_PAGES allocates one or several pages in a remote cluster, |
---|
208 | * and returns the local pointer on the page descriptor. |
---|
209 | *********************************************************************************** |
---|
210 | * @ cxy : server cluster identifier |
---|
211 | * @ order : [in] ln2( number of requested pages ) |
---|
212 | * @ page : [out] local pointer on page descriptor / NULL if failure |
---|
213 | **********************************************************************************/ |
---|
214 | void rpc_pmem_get_pages_client( cxy_t cxy, |
---|
215 | uint32_t order, |
---|
216 | struct page_s ** page ); |
---|
217 | |
---|
218 | void rpc_pmem_get_pages_server( xptr_t xp ); |
---|
219 | |
---|
220 | /*********************************************************************************** |
---|
221 | * [1] The RPC_PROCESS_PID_ALLOC allocates one new PID in a remote cluster, registers |
---|
222 | * the new process in the remote cluster, and returns the PID, and an error code. |
---|
223 | *********************************************************************************** |
---|
224 | * @ cxy : server cluster identifier. |
---|
225 | * @ process : [in] local pointer on process descriptor in client cluster. |
---|
226 | * @ error : [out] error status (0 if success). |
---|
227 | * @ pid : [out] new process identifier. |
---|
228 | **********************************************************************************/ |
---|
229 | void rpc_process_pid_alloc_client( cxy_t cxy, |
---|
230 | struct process_s * process, |
---|
231 | error_t * error, |
---|
232 | pid_t * pid ); |
---|
233 | |
---|
234 | void rpc_process_pid_alloc_server( xptr_t xp ); |
---|
235 | |
---|
236 | /*********************************************************************************** |
---|
237 | * [2] The RPC_PROCESS_EXEC creates a process descriptor copy, in a remote cluster |
---|
238 | * and initializes if from information found in the reference process descriptor. |
---|
239 | * This remote cluster becomes the new reference cluster. |
---|
240 | *********************************************************************************** |
---|
241 | * @ cxy : server cluster identifier. |
---|
242 | * @ info : [in] pointer on local exec_info structure. |
---|
243 | * @ error : [out] error status (0 if success). |
---|
244 | **********************************************************************************/ |
---|
245 | void rpc_process_exec_client( cxy_t cxy, |
---|
246 | struct exec_info_s * info, |
---|
247 | error_t * error ); |
---|
248 | |
---|
249 | void rpc_process_exec_server( xptr_t xp ); |
---|
250 | |
---|
251 | /*********************************************************************************** |
---|
252 | * [3] The RPC_PROCESS_KILL is actually a multicast RPC sent by the reference cluster |
---|
253 | * to other clusters containing a process descriptor copy, to destroy these copies. |
---|
254 | *********************************************************************************** |
---|
255 | * @ process : local pointer on target process. |
---|
256 | **********************************************************************************/ |
---|
257 | void rpc_process_kill_client( struct process_s * process ); |
---|
258 | |
---|
259 | void rpc_process_kill_server( xptr_t xp ); |
---|
260 | |
---|
261 | /*********************************************************************************** |
---|
262 | * [4] The RPC_THREAD_USER_CREATE creates an user thread in the server cluster, |
---|
263 | * as specified by the arguments. It returns an extended pointer on the new |
---|
264 | * thread descriptor in server cluster, and an error code. |
---|
265 | * It is called by the sys_thread_create() system call. |
---|
266 | *********************************************************************************** |
---|
267 | * @ cxy : server cluster identifier. |
---|
268 | * @ attr : [in] pointer on pthread_attr_t in client cluster. |
---|
269 | * @ thread_xp : [out] pointer on buffer for thread extended pointer. |
---|
270 | * @ error : [out] error status (0 if success). |
---|
271 | **********************************************************************************/ |
---|
272 | void rpc_thread_user_create_client( cxy_t cxy, |
---|
273 | pid_t pid, |
---|
274 | void * start_func, |
---|
275 | void * start_arg, |
---|
276 | struct pthread_attr_s * attr, |
---|
277 | xptr_t * thread_xp, |
---|
278 | error_t * error ); |
---|
279 | |
---|
280 | void rpc_thread_user_create_server( xptr_t xp ); |
---|
281 | |
---|
282 | /*********************************************************************************** |
---|
283 | * [5] The RPC_THREAD_KERNEL_CREATE creates a kernel thread in the server cluster, |
---|
284 | * as specified by the type, func and args arguments. It returns the local pointer |
---|
285 | * on the thread descriptor in server cluster and an error code. |
---|
286 | * It is used by the dev_init() function to create the device server thread. |
---|
287 | *********************************************************************************** |
---|
288 | * @ cxy : server cluster identifier. |
---|
289 | * @ type : [in] type of kernel thread. |
---|
290 | * @ func : [in] local pointer on thread function. |
---|
291 | * @ args : [in] local pointer on function arguments. |
---|
292 | * @ thread_xp : [out] pointer on buffer for thread extended pointer. |
---|
293 | * @ error : [out] error status (0 if success). |
---|
294 | **********************************************************************************/ |
---|
295 | void rpc_thread_kernel_create_client( cxy_t cxy, |
---|
296 | uint32_t type, |
---|
297 | void * func, |
---|
298 | void * args, |
---|
299 | xptr_t * thread_xp, |
---|
300 | error_t * error ); |
---|
301 | |
---|
302 | void rpc_thread_kernel_create_server( xptr_t xp ); |
---|
303 | |
---|
304 | /*********************************************************************************** |
---|
305 | * [6] The RPC_SIGNAL_RISE ask a target cluster to register a given signal in |
---|
306 | * all threads descriptors of a given process. |
---|
307 | * It is used by the sys_kill() function. |
---|
308 | *********************************************************************************** |
---|
309 | * @ cxy : server cluster identifier. |
---|
310 | * @ process : [in] local pointer on target process descriptor in server. |
---|
311 | * @ sig_id : [in] signal index. |
---|
312 | **********************************************************************************/ |
---|
313 | void rpc_signal_rise_client( cxy_t cxy, |
---|
314 | struct process_s * process, |
---|
315 | uint32_t sig_id ); |
---|
316 | |
---|
317 | void rpc_signal_rise_server( xptr_t xp ); |
---|
318 | |
---|
319 | /*********************************************************************************** |
---|
320 | * [10] The RPC_VFS_INODE_CREATE creates an inode and the associated mapper in a |
---|
321 | * remote cluster. The parent dentry must have been previously created. |
---|
322 | * It returns an extended pointer on the created inode. |
---|
323 | *********************************************************************************** |
---|
324 | * @ cxy : server cluster identifier. |
---|
325 | * @ dentry_xp : [in] extended pointer on parent dentry. |
---|
326 | * @ fs_type : [in] file system type. |
---|
327 | * @ inode_type : [in] file system type. |
---|
328 | * @ extend : [in] fs_type_specific inode extension. |
---|
329 | * @ attr : [in] inode attributes. |
---|
330 | * @ rights : [in] access rights |
---|
331 | * @ uid : [in] user ID |
---|
332 | * @ gid : [in] group ID |
---|
333 | * @ inode_xp : [out] buffer for extended pointer on created inode. |
---|
334 | * @ error : [out] error status (0 if success). |
---|
335 | **********************************************************************************/ |
---|
336 | void rpc_vfs_inode_create_client( cxy_t cxy, |
---|
337 | xptr_t dentry_xp, |
---|
338 | uint32_t fs_type, |
---|
339 | uint32_t inode_type, |
---|
340 | void * extend, |
---|
341 | uint32_t attr, |
---|
342 | uint32_t rights, |
---|
343 | uint32_t uid, |
---|
344 | uint32_t gid, |
---|
345 | xptr_t * inode_xp, |
---|
346 | error_t * error ); |
---|
347 | |
---|
348 | void rpc_vfs_inode_create_server( xptr_t xp ); |
---|
349 | |
---|
350 | /*********************************************************************************** |
---|
351 | * [11] The RPC_VFS_INODE_DESTROY releases memory allocated for an inode descriptor |
---|
352 | * and for the associated mapper in a remote cluster. |
---|
353 | *********************************************************************************** |
---|
354 | * @ cxy : server cluster identifier |
---|
355 | * @ inode : [in] local pointer on inode. |
---|
356 | **********************************************************************************/ |
---|
357 | void rpc_vfs_inode_destroy_client( cxy_t cxy, |
---|
358 | struct vfs_inode_s * inode ); |
---|
359 | |
---|
360 | void rpc_vfs_inode_destroy_server( xptr_t xp ); |
---|
361 | |
---|
362 | /*********************************************************************************** |
---|
363 | * [12] The RPC_VFS_DENTRY_CREATE creates a dentry in a remote cluster. |
---|
364 | * It returns an extended pointer on the created dentry. |
---|
365 | *********************************************************************************** |
---|
366 | * @ cxy : server cluster identifier |
---|
367 | * @ type : [in] file system type. |
---|
368 | * @ name : [in] directory entry name. |
---|
369 | * @ parent : [in] local pointer on parent inode. |
---|
370 | * @ dentry_xp : [out] buffer for extended pointer on created dentry. |
---|
371 | * @ error : [out] error status (0 if success). |
---|
372 | **********************************************************************************/ |
---|
373 | void rpc_vfs_dentry_create_client( cxy_t cxy, |
---|
374 | uint32_t type, |
---|
375 | char * name, |
---|
376 | struct vfs_inode_s * parent, |
---|
377 | xptr_t * dentry_xp, |
---|
378 | error_t * error ); |
---|
379 | |
---|
380 | void rpc_vfs_dentry_create_server( xptr_t xp ); |
---|
381 | |
---|
382 | /*********************************************************************************** |
---|
383 | * [13] The RPC_VFS_DENTRY_DESTROY releases memory allocated for an dentry descriptor |
---|
384 | * in a remote cluster. |
---|
385 | *********************************************************************************** |
---|
386 | * @ cxy : server cluster identifier |
---|
387 | * @ dentry : [in] local pointer on dentry. |
---|
388 | **********************************************************************************/ |
---|
389 | void rpc_vfs_dentry_destroy_client( cxy_t cxy, |
---|
390 | struct vfs_dentry_s * dentry ); |
---|
391 | |
---|
392 | void rpc_vfs_dentry_destroy_server( xptr_t xp ); |
---|
393 | |
---|
394 | /*********************************************************************************** |
---|
395 | * [14] The RPC_VFS_FILE_CREATE creates a file descriptor in a remote cluster. |
---|
396 | * It returns an extended pointer on the created file structure. |
---|
397 | *********************************************************************************** |
---|
398 | * @ cxy : server cluster identifier |
---|
399 | * @ inode : [in] local pointer on parent inode. |
---|
400 | * @ file_attr : [in] new file attributes. |
---|
401 | * @ file_xp : [out] buffer for extended pointer on created file. |
---|
402 | * @ error : [out] error status (0 if success). |
---|
403 | **********************************************************************************/ |
---|
404 | void rpc_vfs_file_create_client( cxy_t cxy, |
---|
405 | struct vfs_inode_s * inode, |
---|
406 | uint32_t file_attr, |
---|
407 | xptr_t * file_xp, |
---|
408 | error_t * error ); |
---|
409 | |
---|
410 | void rpc_vfs_file_create_server( xptr_t xp ); |
---|
411 | |
---|
412 | /*********************************************************************************** |
---|
413 | * [15] The RPC_VFS_FILE_DESTROY releases memory allocated for a file descriptor |
---|
414 | * in a remote cluster. |
---|
415 | *********************************************************************************** |
---|
416 | * @ cxy : server cluster identifier |
---|
417 | * @ file : [in] local pointer on file. |
---|
418 | **********************************************************************************/ |
---|
419 | void rpc_vfs_file_destroy_client( cxy_t cxy, |
---|
420 | struct vfs_file_s * file ); |
---|
421 | |
---|
422 | void rpc_vfs_file_destroy_server( xptr_t xp ); |
---|
423 | |
---|
424 | /*********************************************************************************** |
---|
425 | * [16] The RPC_VFS_LOAD_INODE calls the vfs_inode_load() kernel function in a |
---|
426 | * remote cluster containing a parent inode directory to scan the associated |
---|
427 | * mapper, find a directory entry, identified by its name, and update the remote |
---|
428 | * child inode. |
---|
429 | *********************************************************************************** |
---|
430 | * @ cxy : server cluster identifier |
---|
431 | * @ parent_inode : [in] local pointer on parent inode. |
---|
432 | * @ name : [in] local pointer on child name (in client cluster). |
---|
433 | * @ child_inode_xp : [in] extended pointer on child inode (in another cluster). |
---|
434 | * @ error : [out] error status (0 if success). |
---|
435 | **********************************************************************************/ |
---|
436 | void rpc_vfs_inode_load_client( cxy_t cxy, |
---|
437 | struct vfs_inode_s * parent_inode, |
---|
438 | char * name, |
---|
439 | xptr_t child_inode_xp, |
---|
440 | error_t * error ); |
---|
441 | |
---|
442 | void rpc_vfs_inode_load_server( xptr_t xp ); |
---|
443 | |
---|
444 | /*********************************************************************************** |
---|
445 | * [17] The RPC_VFS_MAPPER_LOAD_ALL calls the vfs_mapper_load_all() kernel function |
---|
446 | * in a remote cluster containing an inode, to load all pages of the associated |
---|
447 | * mapper from the file system on device. |
---|
448 | *********************************************************************************** |
---|
449 | * @ cxy : server cluster identifier |
---|
450 | * @ inode : [in] local pointer on inode in server cluster. |
---|
451 | * @ error : [out] error status (0 if success). |
---|
452 | **********************************************************************************/ |
---|
453 | void rpc_vfs_mapper_load_all_client( cxy_t cxy, |
---|
454 | struct vfs_inode_s * inode, |
---|
455 | error_t * error ); |
---|
456 | |
---|
457 | void rpc_vfs_mapper_load_all_server( xptr_t xp ); |
---|
458 | |
---|
459 | /*********************************************************************************** |
---|
460 | * [18] The RPC_FATFS_GET_CLUSTER can be send by any thread running in a "client" |
---|
461 | * cluster to scan the FAT mapper, stored in a remote "server" cluster, and get |
---|
462 | * from the mapper the local pointer on a given page. |
---|
463 | *********************************************************************************** |
---|
464 | * @ cxy : server cluster identifier. |
---|
465 | * @ mapper : [in] local pointer on FAT mapper. |
---|
466 | * @ first : [in] FATFS cluster index allocated to first page of file. |
---|
467 | * @ page : [in] page index in file. |
---|
468 | * @ cluster : [out] local pointer on buffer for found FATFS cluster index. |
---|
469 | * @ error : [out] local pointer on buffer for error code (in client cluster). |
---|
470 | **********************************************************************************/ |
---|
471 | void rpc_fatfs_get_cluster_client( cxy_t cxy, |
---|
472 | struct mapper_s * mapper, |
---|
473 | uint32_t first, |
---|
474 | uint32_t page, |
---|
475 | uint32_t * cluster, |
---|
476 | error_t * error ); |
---|
477 | |
---|
478 | void rpc_fatfs_get_cluster_server( xptr_t xp ); |
---|
479 | |
---|
480 | /*********************************************************************************** |
---|
481 | * [20] The RPC_VMM_GET_REF_VSEG returns an extended pointer |
---|
482 | * on the vseg containing a given virtual address in a given process. |
---|
483 | * The server cluster is supposed to be the reference cluster. |
---|
484 | * It returns XPTR_NULL if no vseg has been founded. |
---|
485 | *********************************************************************************** |
---|
486 | * @ cxy : server cluster identifier. |
---|
487 | * @ process : [in] pointer on process descriptor in server cluster. |
---|
488 | * @ vaddr : [in] virtual address to be searched. |
---|
489 | * @ vseg_xp : [out] buffer for extended pointer on vseg in client cluster. |
---|
490 | **********************************************************************************/ |
---|
491 | void rpc_vmm_get_ref_vseg_client( cxy_t cxy, |
---|
492 | struct process_s * process, |
---|
493 | intptr_t vaddr, |
---|
494 | xptr_t * vseg_xp ); |
---|
495 | |
---|
496 | void rpc_vmm_get_ref_vseg_server( xptr_t xp ); |
---|
497 | |
---|
498 | /*********************************************************************************** |
---|
499 | * [21] The RPC_VMM_GET_PTE returns in the "ppn" and "attr" arguments the PTE value |
---|
500 | * for a given VPN in a given process. |
---|
501 | * The server cluster is supposed to be the reference cluster, and the vseg |
---|
502 | * containing the VPN must be registered in the reference VMM. |
---|
503 | * It returns an error if physical memory cannot be allocated for the PTE2, |
---|
504 | * or for the missing page itself. |
---|
505 | *********************************************************************************** |
---|
506 | * @ cxy : server cluster identifier. |
---|
507 | * @ process : [in] pointer on process descriptor in server cluster. |
---|
508 | * @ vaddr : [in] virtual address to be searched. |
---|
509 | * @ attr : [out] address of buffer for attributes. |
---|
510 | * @ ppn : [out] address of buffer for PPN. |
---|
511 | * @ error : [out] address of buffer for error code. |
---|
512 | **********************************************************************************/ |
---|
513 | void rpc_vmm_get_pte_client( cxy_t cxy, |
---|
514 | struct process_s * process, |
---|
515 | vpn_t vpn, |
---|
516 | uint32_t * attr, |
---|
517 | ppn_t * ppn, |
---|
518 | error_t * error ); |
---|
519 | |
---|
520 | void rpc_vmm_get_pte_server( xptr_t xp ); |
---|
521 | |
---|
522 | /*********************************************************************************** |
---|
523 | * [22] The RPC_KCM_ALLOC allocates memory from a given KCM in a remote cluster, |
---|
524 | * and returns an extended pointer on the allocated object. |
---|
525 | It returns XPTR_NULL if physical memory cannot be allocated. |
---|
526 | *********************************************************************************** |
---|
527 | * @ cxy : server cluster identifier. |
---|
528 | * @ kmem_type : [in] KCM object type (as defined in kmem.h). |
---|
529 | * @ buf_xp : [out] buffer for extended pointer on allocated buffer. |
---|
530 | **********************************************************************************/ |
---|
531 | void rpc_kcm_alloc_client( cxy_t cxy, |
---|
532 | uint32_t kmem_type, |
---|
533 | xptr_t * buf_xp ); |
---|
534 | |
---|
535 | void rpc_kcm_alloc_server( xptr_t xp ); |
---|
536 | |
---|
537 | /*********************************************************************************** |
---|
538 | * [23] The RPC_KCM_FREE releases memory allocated for a KCM object of a given type, |
---|
539 | * in a remote cluster. |
---|
540 | *********************************************************************************** |
---|
541 | * @ cxy : server cluster identifier. |
---|
542 | * @ buf : [in] local pointer on allocated buffer. |
---|
543 | * @ kmem_type : [in] KCM object type (as defined in kmem.h). |
---|
544 | **********************************************************************************/ |
---|
545 | void rpc_kcm_free_client( cxy_t cxy, |
---|
546 | void * buf, |
---|
547 | uint32_t kmem_type ); |
---|
548 | |
---|
549 | void rpc_kcm_free_server( xptr_t xp ); |
---|
550 | |
---|
551 | /*********************************************************************************** |
---|
552 | * [24] The RPC_MAPPER_MOVE_BUFFER allows a client thread to require a remote |
---|
553 | * mapper to move data to/from a kernel or user buffer. |
---|
554 | * - It calls the mapper_move_user() function for a - possibly distributed - |
---|
555 | * user buffer identified by a user-space pointer, and casted to uint64_t. |
---|
556 | * - It calls the mapper_move_kernel() function for a - possibly remote - |
---|
557 | * kernel buffer identified by an extended pointer, and casted to uint64_t. |
---|
558 | * It is used by the vfs_move_user() function to move data between a mapper |
---|
559 | * and an user buffer required by a sys_read() or a sys_write(). |
---|
560 | * It is used by the vmm_get_one_ppn() function to initialise a physical page |
---|
561 | * from a .elf file mapper, for a CODE or DATA vseg page fault. |
---|
562 | *********************************************************************************** |
---|
563 | * @ cxy : server cluster identifier. |
---|
564 | * @ mapper : [in] local pointer on mapper |
---|
565 | * @ to_buffer : [in] move data from mapper to buffer if non zero. |
---|
566 | * @ is_user : [in] buffer in user space if true |
---|
567 | * @ file_offset : [in] first byte to move in mapper |
---|
568 | * @ buffer : [in] user space pointer / kernel extended pointer |
---|
569 | * @ size : [in] number of bytes to move |
---|
570 | * @ error : [out] error status (0 if success). |
---|
571 | **********************************************************************************/ |
---|
572 | void rpc_mapper_move_buffer_client( cxy_t cxy, |
---|
573 | struct mapper_s * mapper, |
---|
574 | bool_t to_buffer, |
---|
575 | bool_t is_user, |
---|
576 | uint32_t file_offset, |
---|
577 | uint64_t buffer, |
---|
578 | uint32_t size, |
---|
579 | error_t * error ); |
---|
580 | |
---|
581 | void rpc_mapper_move_buffer_server( xptr_t xp ); |
---|
582 | |
---|
583 | /*********************************************************************************** |
---|
584 | * [25] The RPC_MAPPER_GET_PAGE allows a client thread to get the local pointer |
---|
585 | * on a remote page descriptor, for a page, identified by the page index in mapper. |
---|
586 | * It is used by the vmm_get_one_ppn() function to handle a page fault on |
---|
587 | * a FILE type vseg. |
---|
588 | *********************************************************************************** |
---|
589 | * @ cxy : server cluster identifier. |
---|
590 | * @ mapper : [in] local pointer on mapper. |
---|
591 | * @ index : [in] page index in mapper. |
---|
592 | * @ page : [out] local pointer on page descriptor / NULL if failure. |
---|
593 | **********************************************************************************/ |
---|
594 | void rpc_mapper_get_page_client( cxy_t cxy, |
---|
595 | struct mapper_s * mapper, |
---|
596 | uint32_t index, |
---|
597 | struct page_s ** page ); |
---|
598 | |
---|
599 | void rpc_mapper_get_page_server( xptr_t xp ); |
---|
600 | |
---|
601 | #endif |
---|