1 | /* |
---|
2 | * rpc.c - RPC operations implementation. |
---|
3 | * |
---|
4 | * Author Alain Greiner (2016,2017,2018,2019) |
---|
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 | #include <kernel_config.h> |
---|
25 | #include <hal_kernel_types.h> |
---|
26 | #include <hal_vmm.h> |
---|
27 | #include <hal_atomic.h> |
---|
28 | #include <hal_remote.h> |
---|
29 | #include <hal_irqmask.h> |
---|
30 | #include <hal_special.h> |
---|
31 | #include <printk.h> |
---|
32 | #include <user_dir.h> |
---|
33 | #include <remote_sem.h> |
---|
34 | #include <core.h> |
---|
35 | #include <mapper.h> |
---|
36 | #include <chdev.h> |
---|
37 | #include <bits.h> |
---|
38 | #include <thread.h> |
---|
39 | #include <cluster.h> |
---|
40 | #include <process.h> |
---|
41 | #include <vfs.h> |
---|
42 | #include <fatfs.h> |
---|
43 | #include <rpc.h> |
---|
44 | |
---|
45 | |
---|
46 | ///////////////////////////////////////////////////////////////////////////////////////// |
---|
47 | // Array of function pointers and array of printable strings. |
---|
48 | // These arrays must be kept consistent with enum in rpc.h file. |
---|
49 | ///////////////////////////////////////////////////////////////////////////////////////// |
---|
50 | |
---|
51 | rpc_server_t * rpc_server[RPC_MAX_INDEX] = |
---|
52 | { |
---|
53 | &rpc_undefined, // 0 |
---|
54 | &rpc_undefined, // 1 |
---|
55 | &rpc_undefined, // 2 |
---|
56 | &rpc_process_make_fork_server, // 3 |
---|
57 | &rpc_user_dir_create_server, // 4 |
---|
58 | &rpc_user_dir_destroy_server, // 5 |
---|
59 | &rpc_thread_user_create_server, // 6 |
---|
60 | &rpc_thread_kernel_create_server, // 7 |
---|
61 | &rpc_vfs_fs_update_dentry_server, // 8 |
---|
62 | &rpc_process_sigaction_server, // 9 |
---|
63 | |
---|
64 | &rpc_vfs_inode_create_server, // 10 |
---|
65 | &rpc_vfs_inode_destroy_server, // 11 |
---|
66 | &rpc_vfs_dentry_create_server, // 12 |
---|
67 | &rpc_vfs_dentry_destroy_server, // 13 |
---|
68 | &rpc_vfs_file_create_server, // 14 |
---|
69 | &rpc_vfs_file_destroy_server, // 15 |
---|
70 | &rpc_vfs_fs_new_dentry_server, // 16 |
---|
71 | &rpc_vfs_fs_add_dentry_server, // 17 |
---|
72 | &rpc_vfs_fs_remove_dentry_server, // 18 |
---|
73 | &rpc_vfs_inode_load_all_pages_server, // 19 |
---|
74 | |
---|
75 | &rpc_undefined, // 20 |
---|
76 | &rpc_undefined, // 21 |
---|
77 | &rpc_undefined, // 22 |
---|
78 | &rpc_undefined, // 23 |
---|
79 | &rpc_mapper_sync_server, // 24 |
---|
80 | &rpc_vmm_resize_vseg_server, // 25 |
---|
81 | &rpc_vmm_remove_vseg_server, // 26 |
---|
82 | &rpc_vmm_create_vseg_server, // 27 |
---|
83 | &rpc_vmm_set_cow_server, // 28 |
---|
84 | &rpc_undefined, // 29 |
---|
85 | }; |
---|
86 | |
---|
87 | char * rpc_str[RPC_MAX_INDEX] = |
---|
88 | { |
---|
89 | "undefined_0", // 0 |
---|
90 | "undefined_1", // 1 |
---|
91 | "undefined_2", // 2 |
---|
92 | "PROCESS_MAKE_FORK", // 3 |
---|
93 | "USER_DIR_CREATE", // 4 |
---|
94 | "USER_DIR_DESTROY", // 5 |
---|
95 | "THREAD_USER_CREATE", // 6 |
---|
96 | "THREAD_KERNEL_CREATE", // 7 |
---|
97 | "VFS_FS_UPDATE_DENTRY", // 8 |
---|
98 | "PROCESS_SIGACTION", // 9 |
---|
99 | |
---|
100 | "VFS_INODE_CREATE", // 10 |
---|
101 | "VFS_INODE_DESTROY", // 11 |
---|
102 | "VFS_DENTRY_CREATE", // 12 |
---|
103 | "VFS_DENTRY_DESTROY", // 13 |
---|
104 | "VFS_FILE_CREATE", // 14 |
---|
105 | "VFS_FILE_DESTROY", // 15 |
---|
106 | "VFS_FS_NEW_DENTRY", // 16 |
---|
107 | "VFS_FS_ADD_DENTRY", // 17 |
---|
108 | "VFS_FS_REMOVE_DENTRY", // 18 |
---|
109 | "VFS_INODE_LOAD_ALL_PAGES", // 19 |
---|
110 | |
---|
111 | "VMM_GLOBAL_RESIZE_VSEG", // 20 |
---|
112 | "VMM_GLOBAL_UPDATE_PTE", // 21 |
---|
113 | "undefined_22", // 22 |
---|
114 | "undefined_23", // 23 |
---|
115 | "MAPPER_SYNC", // 24 |
---|
116 | "undefined_25", // 25 |
---|
117 | "VMM_REMOVE_VSEG", // 26 |
---|
118 | "VMM_CREATE_VSEG", // 27 |
---|
119 | "VMM_SET_COW", // 28 |
---|
120 | "undefined_29", // 29 |
---|
121 | }; |
---|
122 | |
---|
123 | ////////////////////////////////////////////////////////////////////////////////// |
---|
124 | void __attribute__((noinline)) rpc_undefined( xptr_t xp __attribute__ ((unused)) ) |
---|
125 | { |
---|
126 | assert( false , "called in cluster %x", local_cxy ); |
---|
127 | } |
---|
128 | |
---|
129 | /***************************************************************************************/ |
---|
130 | /************ Generic function supporting RPCs : client side ***************************/ |
---|
131 | /***************************************************************************************/ |
---|
132 | |
---|
133 | /////////////////////////////////////// |
---|
134 | void rpc_send( cxy_t server_cxy, |
---|
135 | rpc_desc_t * rpc ) |
---|
136 | { |
---|
137 | lid_t server_core_lid; |
---|
138 | lid_t client_core_lid; |
---|
139 | volatile error_t full; |
---|
140 | thread_t * this; |
---|
141 | |
---|
142 | full = 0; |
---|
143 | this = CURRENT_THREAD; |
---|
144 | client_core_lid = this->core->lid; |
---|
145 | |
---|
146 | // check calling thread can yield when is not the IDLE thread |
---|
147 | // RPCs executed by the IDLE thread during kernel_init do not deschedule |
---|
148 | if( this->type != THREAD_IDLE ) thread_assert_can_yield( this , __FUNCTION__ ); |
---|
149 | |
---|
150 | // select a server_core : use client core index if possible / core 0 otherwise |
---|
151 | if( client_core_lid < hal_remote_l32( XPTR( server_cxy , &LOCAL_CLUSTER->cores_nr ) ) ) |
---|
152 | { |
---|
153 | server_core_lid = client_core_lid; |
---|
154 | } |
---|
155 | else |
---|
156 | { |
---|
157 | server_core_lid = 0; |
---|
158 | } |
---|
159 | |
---|
160 | // register client_thread and client_core in RPC descriptor |
---|
161 | rpc->thread = this; |
---|
162 | rpc->lid = client_core_lid; |
---|
163 | |
---|
164 | // build extended pointer on the RPC descriptor |
---|
165 | xptr_t desc_xp = XPTR( local_cxy , rpc ); |
---|
166 | |
---|
167 | // get local pointer on rpc_fifo in remote cluster, |
---|
168 | remote_fifo_t * rpc_fifo = &LOCAL_CLUSTER->rpc_fifo[server_core_lid]; |
---|
169 | xptr_t rpc_fifo_xp = XPTR( server_cxy , rpc_fifo ); |
---|
170 | |
---|
171 | // post RPC in remote fifo / deschedule without blocking if fifo full |
---|
172 | do |
---|
173 | { |
---|
174 | full = remote_fifo_put_item( rpc_fifo_xp , (uint64_t )desc_xp ); |
---|
175 | |
---|
176 | if ( full ) |
---|
177 | { |
---|
178 | printk("\n[WARNING] %s : cluster %x cannot post RPC to cluster %x\n", |
---|
179 | __FUNCTION__ , local_cxy , server_cxy ); |
---|
180 | |
---|
181 | // deschedule without blocking |
---|
182 | sched_yield("RPC fifo full"); |
---|
183 | } |
---|
184 | } |
---|
185 | while( full ); |
---|
186 | |
---|
187 | #if DEBUG_RPC_CLIENT_GENERIC |
---|
188 | uint32_t cycle = (uint32_t)hal_get_cycles(); |
---|
189 | uint32_t items = remote_fifo_items( rpc_fifo_xp ); |
---|
190 | if( DEBUG_RPC_CLIENT_GENERIC < cycle ) |
---|
191 | printk("\n[%s] thread[%x,%x] / rpc %s / server[%x,%d] / items %d / cycle %d\n", |
---|
192 | __FUNCTION__, this->process->pid, this->trdid, rpc_str[rpc->index], |
---|
193 | server_cxy, server_core_lid, items, cycle ); |
---|
194 | #endif |
---|
195 | |
---|
196 | // send IPI to the selected server core |
---|
197 | dev_pic_send_ipi( server_cxy , server_core_lid ); |
---|
198 | |
---|
199 | // wait RPC completion before returning if blocking RPC : |
---|
200 | // - deschedule without blocking if thread idle (in kernel init) |
---|
201 | // - block and deschedule policy for any other thread |
---|
202 | if ( rpc->blocking ) |
---|
203 | { |
---|
204 | if( this->type == THREAD_IDLE ) // deschedule without blocking policy |
---|
205 | { |
---|
206 | |
---|
207 | #if DEBUG_RPC_CLIENT_GENERIC |
---|
208 | cycle = (uint32_t)hal_get_cycles(); |
---|
209 | if( DEBUG_RPC_CLIENT_GENERIC < cycle ) |
---|
210 | printk("\n[%s] thread[%x,%x] enter waiting loop for rpc %s / cycle %d\n", |
---|
211 | __FUNCTION__, this->process->pid, this->trdid, rpc_str[rpc->index], cycle ); |
---|
212 | #endif |
---|
213 | while( 1 ) |
---|
214 | { |
---|
215 | // check responses counter |
---|
216 | if( hal_remote_l32( XPTR( local_cxy , rpc->rsp ) ) == 0 ) break; |
---|
217 | |
---|
218 | // deschedule |
---|
219 | sched_yield("busy_waiting RPC completion"); |
---|
220 | } |
---|
221 | |
---|
222 | #if DEBUG_RPC_CLIENT_GENERIC |
---|
223 | cycle = (uint32_t)hal_get_cycles(); |
---|
224 | if( DEBUG_RPC_CLIENT_GENERIC < cycle ) |
---|
225 | printk("\n[%s] thread[%x,%x] received response for rpc %s / cycle %d\n", |
---|
226 | __FUNCTION__, this->process->pid, this->trdid, rpc_str[rpc->index], cycle ); |
---|
227 | #endif |
---|
228 | |
---|
229 | } |
---|
230 | else // block and deschedule policy |
---|
231 | { |
---|
232 | |
---|
233 | #if DEBUG_RPC_CLIENT_GENERIC |
---|
234 | cycle = (uint32_t)hal_get_cycles(); |
---|
235 | if( DEBUG_RPC_CLIENT_GENERIC < cycle ) |
---|
236 | printk("\n[%s] thread[%x,%x] blocks & deschedules for rpc %s / cycle %d\n", |
---|
237 | __FUNCTION__, this->process->pid, this->trdid, rpc_str[rpc->index], cycle ); |
---|
238 | #endif |
---|
239 | |
---|
240 | // block client thread |
---|
241 | thread_block( XPTR( local_cxy , this ) , THREAD_BLOCKED_RPC ); |
---|
242 | |
---|
243 | // deschedule |
---|
244 | sched_yield("blocked on RPC"); |
---|
245 | |
---|
246 | #if DEBUG_RPC_CLIENT_GENERIC |
---|
247 | cycle = (uint32_t)hal_get_cycles(); |
---|
248 | if( DEBUG_RPC_CLIENT_GENERIC < cycle ) |
---|
249 | printk("\n[%s] thread[%x,%x] resumes after rpc %s / cycle %d\n", |
---|
250 | __FUNCTION__, this->process->pid, this->trdid, rpc_str[rpc->index], cycle ); |
---|
251 | #endif |
---|
252 | } |
---|
253 | |
---|
254 | // response must be available for a blocking RPC |
---|
255 | assert( (*rpc->rsp == 0) , "illegal response for RPC %s\n", rpc_str[rpc->index] ); |
---|
256 | |
---|
257 | } |
---|
258 | else // non blocking RPC |
---|
259 | { |
---|
260 | |
---|
261 | #if DEBUG_RPC_CLIENT_GENERIC |
---|
262 | cycle = (uint32_t)hal_get_cycles(); |
---|
263 | if( DEBUG_RPC_CLIENT_GENERIC < cycle ) |
---|
264 | printk("\n[%s] thread[%x,%x] returns for non blocking rpc %s / cycle %d\n", |
---|
265 | __FUNCTION__, this->process->pid, this->trdid, rpc_str[rpc->index], cycle ); |
---|
266 | #endif |
---|
267 | |
---|
268 | } |
---|
269 | } // end rpc_send() |
---|
270 | |
---|
271 | |
---|
272 | /***************************************************************************************/ |
---|
273 | /************ Generic functions supporting RPCs : server side **************************/ |
---|
274 | /***************************************************************************************/ |
---|
275 | |
---|
276 | //////////////////////////// |
---|
277 | void rpc_server_func( void ) |
---|
278 | { |
---|
279 | error_t empty; // local RPC fifo state |
---|
280 | xptr_t desc_xp; // extended pointer on RPC request |
---|
281 | cxy_t desc_cxy; // RPC request cluster (client) |
---|
282 | rpc_desc_t * desc_ptr; // RPC request local pointer |
---|
283 | uint32_t index; // RPC request index |
---|
284 | thread_t * client_ptr; // local pointer on client thread |
---|
285 | xptr_t client_xp; // extended pointer on client thread |
---|
286 | lid_t client_lid; // local index of client core |
---|
287 | thread_t * server_ptr; // local pointer on server thread |
---|
288 | xptr_t server_xp; // extended pointer on server thread |
---|
289 | lid_t server_lid; // local index of server core |
---|
290 | remote_fifo_t * rpc_fifo; // local pointer on RPC fifo |
---|
291 | uint32_t * rsp_ptr; // local pointer on responses counter |
---|
292 | xptr_t rsp_xp; // extended pointer on responses counter |
---|
293 | uint32_t responses; // number of expected responses |
---|
294 | |
---|
295 | // makes RPC thread not preemptable |
---|
296 | hal_disable_irq( NULL ); |
---|
297 | |
---|
298 | server_ptr = CURRENT_THREAD; |
---|
299 | server_xp = XPTR( local_cxy , server_ptr ); |
---|
300 | server_lid = server_ptr->core->lid; |
---|
301 | rpc_fifo = &LOCAL_CLUSTER->rpc_fifo[server_lid]; |
---|
302 | |
---|
303 | // "infinite" RPC thread loop |
---|
304 | while(1) |
---|
305 | { |
---|
306 | // try to take RPC_FIFO ownership |
---|
307 | if( hal_atomic_test_set( &rpc_fifo->owner , server_ptr->trdid ) ) |
---|
308 | { |
---|
309 | |
---|
310 | #if DEBUG_RPC_SERVER_GENERIC |
---|
311 | uint32_t cycle = (uint32_t)hal_get_cycles(); |
---|
312 | if( DEBUG_RPC_SERVER_GENERIC < cycle ) |
---|
313 | printk("\n[%s] RPC thread[%x,%x] on core[%d] takes RPC_FIFO ownership / cycle %d\n", |
---|
314 | __FUNCTION__, server_ptr->process->pid, server_ptr->trdid, server_lid, cycle ); |
---|
315 | #endif |
---|
316 | // try to consume one RPC request |
---|
317 | empty = remote_fifo_get_item( rpc_fifo , (uint64_t *)&desc_xp ); |
---|
318 | |
---|
319 | // release RPC_FIFO ownership |
---|
320 | rpc_fifo->owner = 0; |
---|
321 | |
---|
322 | // handle RPC request if success |
---|
323 | if ( empty == 0 ) |
---|
324 | { |
---|
325 | // get client cluster and pointer on RPC descriptor |
---|
326 | desc_cxy = GET_CXY( desc_xp ); |
---|
327 | desc_ptr = GET_PTR( desc_xp ); |
---|
328 | |
---|
329 | // get relevant infos from RPC descriptor |
---|
330 | index = hal_remote_l32( XPTR( desc_cxy , &desc_ptr->index ) ); |
---|
331 | client_ptr = hal_remote_lpt( XPTR( desc_cxy , &desc_ptr->thread ) ); |
---|
332 | rsp_ptr = hal_remote_lpt( XPTR( desc_cxy , &desc_ptr->rsp ) ); |
---|
333 | client_lid = hal_remote_l32( XPTR( desc_cxy , &desc_ptr->lid ) ); |
---|
334 | |
---|
335 | rsp_xp = XPTR( desc_cxy , rsp_ptr ); |
---|
336 | client_xp = XPTR( desc_cxy , client_ptr ); |
---|
337 | |
---|
338 | #if DEBUG_RPC_SERVER_GENERIC |
---|
339 | cycle = (uint32_t)hal_get_cycles(); |
---|
340 | uint32_t items = remote_fifo_items( XPTR( local_cxy , rpc_fifo ) ); |
---|
341 | if( DEBUG_RPC_SERVER_GENERIC < cycle ) |
---|
342 | printk("\n[%s] RPC thread[%x,%x] got rpc %s / client_cxy %x / items %d / cycle %d\n", |
---|
343 | __FUNCTION__, server_ptr->process->pid, server_ptr->trdid, rpc_str[index], desc_cxy, items, cycle ); |
---|
344 | #endif |
---|
345 | // register client thread in RPC thread descriptor |
---|
346 | server_ptr->rpc_client_xp = client_xp; |
---|
347 | |
---|
348 | // call the relevant server function |
---|
349 | rpc_server[index]( desc_xp ); |
---|
350 | |
---|
351 | // update responses counter |
---|
352 | responses = hal_remote_atomic_add( rsp_xp , -1 ); |
---|
353 | |
---|
354 | #if DEBUG_RPC_SERVER_GENERIC |
---|
355 | cycle = (uint32_t)hal_get_cycles(); |
---|
356 | if( DEBUG_RPC_SERVER_GENERIC < cycle ) |
---|
357 | printk("\n[%s] RPC thread[%x,%x] completes rpc %s / responses %d / cycle %d\n", |
---|
358 | __FUNCTION__, server_ptr->process->pid, server_ptr->trdid, rpc_str[index], responses, cycle ); |
---|
359 | #endif |
---|
360 | // decrement expected responses counter |
---|
361 | // unblock client thread if last response |
---|
362 | if( responses == 1 ) |
---|
363 | { |
---|
364 | // unblock client thread |
---|
365 | thread_unblock( client_xp , THREAD_BLOCKED_RPC ); |
---|
366 | |
---|
367 | hal_fence(); |
---|
368 | |
---|
369 | #if DEBUG_RPC_SERVER_GENERIC |
---|
370 | cycle = (uint32_t)hal_get_cycles(); |
---|
371 | trdid_t client_trdid = hal_remote_l32( XPTR( desc_cxy , &client_ptr->trdid ) ); |
---|
372 | process_t * process = hal_remote_lpt( XPTR( desc_cxy , &client_ptr->process ) ); |
---|
373 | pid_t client_pid = hal_remote_l32( XPTR( desc_cxy , &process->pid ) ); |
---|
374 | if( DEBUG_RPC_SERVER_GENERIC < cycle ) |
---|
375 | printk("\n[%s] RPC thread[%x,%x] unblocked client thread[%x,%x] / cycle %d\n", |
---|
376 | __FUNCTION__, server_ptr->process->pid, server_ptr->trdid, |
---|
377 | client_pid, client_trdid, cycle ); |
---|
378 | #endif |
---|
379 | // send IPI to client core |
---|
380 | dev_pic_send_ipi( desc_cxy , client_lid ); |
---|
381 | } |
---|
382 | } // end RPC handling if fifo non empty |
---|
383 | } // end if RPC_fIFO ownership successfully taken and released |
---|
384 | |
---|
385 | // sucide if too many RPC threads |
---|
386 | if( LOCAL_CLUSTER->rpc_threads[server_lid] >= CONFIG_RPC_THREADS_MAX ) |
---|
387 | { |
---|
388 | |
---|
389 | #if DEBUG_RPC_SERVER_GENERIC |
---|
390 | uint32_t cycle = (uint32_t)hal_get_cycles(); |
---|
391 | if( DEBUG_RPC_SERVER_GENERIC < cycle ) |
---|
392 | printk("\n[%s] RPC thread[%x,%x] suicides / cycle %d\n", |
---|
393 | __FUNCTION__, server_ptr->process->pid, server_ptr->trdid, cycle ); |
---|
394 | #endif |
---|
395 | // update RPC threads counter |
---|
396 | hal_atomic_add( &LOCAL_CLUSTER->rpc_threads[server_lid] , -1 ); |
---|
397 | |
---|
398 | // RPC thread blocks on GLOBAL |
---|
399 | thread_block( server_xp , THREAD_BLOCKED_GLOBAL ); |
---|
400 | |
---|
401 | // RPC thread set the REQ_DELETE flag to suicide |
---|
402 | hal_remote_atomic_or( server_xp , THREAD_FLAG_REQ_DELETE ); |
---|
403 | } |
---|
404 | // block and deschedule otherwise |
---|
405 | else |
---|
406 | { |
---|
407 | |
---|
408 | #if DEBUG_RPC_SERVER_GENERIC |
---|
409 | uint32_t cycle = (uint32_t)hal_get_cycles(); |
---|
410 | if( DEBUG_RPC_SERVER_GENERIC < cycle ) |
---|
411 | printk("\n[%s] RPC thread[%x,%x] blocks & deschedules / cycle %d\n", |
---|
412 | __FUNCTION__, server_ptr->process->pid, server_ptr->trdid, cycle ); |
---|
413 | #endif |
---|
414 | // RPC thread blocks on IDLE |
---|
415 | thread_block( server_xp , THREAD_BLOCKED_IDLE ); |
---|
416 | |
---|
417 | // RPC thread deschedules |
---|
418 | sched_yield("RPC_FIFO empty"); |
---|
419 | } |
---|
420 | } // end infinite loop |
---|
421 | |
---|
422 | } // end rpc_server_func() |
---|
423 | |
---|
424 | |
---|
425 | ///////////////////////////////////////////////////////////////////////////////////////// |
---|
426 | // [0] RPC_PMEM_GET_PAGES deprecated [AG] May 2019 |
---|
427 | ///////////////////////////////////////////////////////////////////////////////////////// |
---|
428 | |
---|
429 | /* |
---|
430 | /////////////////////////////////////////////// |
---|
431 | void rpc_pmem_get_pages_client( cxy_t cxy, |
---|
432 | uint32_t order, // in |
---|
433 | page_t ** page ) // out |
---|
434 | { |
---|
435 | #if DEBUG_RPC_PMEM_GET_PAGES |
---|
436 | thread_t * this = CURRENT_THREAD; |
---|
437 | uint32_t cycle = (uint32_t)hal_get_cycles(); |
---|
438 | if( cycle > DEBUG_RPC_PMEM_GET_PAGES ) |
---|
439 | printk("\n[%s] thread[%x,%x] on core %d enter / cycle %d\n", |
---|
440 | __FUNCTION__, this->process->pid, this->trdid, this->core->lid, cycle ); |
---|
441 | #endif |
---|
442 | |
---|
443 | uint32_t responses = 1; |
---|
444 | |
---|
445 | // initialise RPC descriptor header |
---|
446 | rpc_desc_t rpc; |
---|
447 | rpc.index = RPC_PMEM_GET_PAGES; |
---|
448 | rpc.blocking = true; |
---|
449 | rpc.rsp = &responses; |
---|
450 | |
---|
451 | // set input arguments in RPC descriptor |
---|
452 | rpc.args[0] = (uint64_t)order; |
---|
453 | |
---|
454 | // register RPC request in remote RPC fifo |
---|
455 | rpc_send( cxy , &rpc ); |
---|
456 | |
---|
457 | // get output arguments from RPC descriptor |
---|
458 | *page = (page_t *)(intptr_t)rpc.args[1]; |
---|
459 | |
---|
460 | #if DEBUG_RPC_PMEM_GET_PAGES |
---|
461 | cycle = (uint32_t)hal_get_cycles(); |
---|
462 | if( cycle > DEBUG_RPC_PMEM_GET_PAGES ) |
---|
463 | printk("\n[%s] thread[%x,%x] on core %d exit / cycle %d\n", |
---|
464 | __FUNCTION__, this->process->pid, this->trdid, this->core->lid, cycle ); |
---|
465 | #endif |
---|
466 | } |
---|
467 | |
---|
468 | /////////////////////////////////////////// |
---|
469 | void rpc_pmem_get_pages_server( xptr_t xp ) |
---|
470 | { |
---|
471 | #if DEBUG_RPC_PMEM_GET_PAGES |
---|
472 | thread_t * this = CURRENT_THREAD; |
---|
473 | uint32_t cycle = (uint32_t)hal_get_cycles(); |
---|
474 | if( cycle > DEBUG_RPC_PMEM_GET_PAGES ) |
---|
475 | printk("\n[%s] thread[%x,%x] on core %d enter / cycle %d\n", |
---|
476 | __FUNCTION__, this->process->pid, this->trdid, this->core->lid, cycle ); |
---|
477 | #endif |
---|
478 | |
---|
479 | // get client cluster identifier and pointer on RPC descriptor |
---|
480 | cxy_t cxy = GET_CXY( xp ); |
---|
481 | rpc_desc_t * desc = GET_PTR( xp ); |
---|
482 | |
---|
483 | // get input arguments from client RPC descriptor |
---|
484 | uint32_t order = (uint32_t)hal_remote_l64( XPTR( cxy , &desc->args[0] ) ); |
---|
485 | |
---|
486 | // call local pmem allocator |
---|
487 | page_t * page = ppm_alloc_pages( order ); |
---|
488 | |
---|
489 | // set output arguments into client RPC descriptor |
---|
490 | hal_remote_s64( XPTR( cxy , &desc->args[1] ) , (uint64_t)(intptr_t)page ); |
---|
491 | |
---|
492 | #if DEBUG_RPC_PMEM_GET_PAGES |
---|
493 | cycle = (uint32_t)hal_get_cycles(); |
---|
494 | if( cycle > DEBUG_RPC_PMEM_GET_PAGES ) |
---|
495 | printk("\n[%s] thread[%x,%x] on core %d exit / cycle %d\n", |
---|
496 | __FUNCTION__, this->process->pid, this->trdid, this->core->lid, cycle ); |
---|
497 | #endif |
---|
498 | } |
---|
499 | */ |
---|
500 | |
---|
501 | ///////////////////////////////////////////////////////////////////////////////////////// |
---|
502 | // [1] RPC_PMEM_RELEASE_PAGES deprecated [AG] may 2019 |
---|
503 | ///////////////////////////////////////////////////////////////////////////////////////// |
---|
504 | |
---|
505 | /* |
---|
506 | ////////////////////////////////////////////////// |
---|
507 | void rpc_pmem_release_pages_client( cxy_t cxy, |
---|
508 | page_t * page ) // out |
---|
509 | { |
---|
510 | #if DEBUG_RPC_PMEM_RELEASE_PAGES |
---|
511 | thread_t * this = CURRENT_THREAD; |
---|
512 | uint32_t cycle = (uint32_t)hal_get_cycles(); |
---|
513 | if( cycle > DEBUG_RPC_PMEM_RELEASE_PAGES ) |
---|
514 | printk("\n[%s] thread[%x,%x] on core %d enter / cycle %d\n", |
---|
515 | __FUNCTION__, this->process->pid, this->trdid, this->core->lid , cycle ); |
---|
516 | #endif |
---|
517 | |
---|
518 | uint32_t responses = 1; |
---|
519 | |
---|
520 | // initialise RPC descriptor header |
---|
521 | rpc_desc_t rpc; |
---|
522 | rpc.index = RPC_PMEM_RELEASE_PAGES; |
---|
523 | rpc.blocking = true; |
---|
524 | rpc.rsp = &responses; |
---|
525 | |
---|
526 | // set input arguments in RPC descriptor |
---|
527 | rpc.args[0] = (uint64_t)(intptr_t)page; |
---|
528 | |
---|
529 | // register RPC request in remote RPC fifo |
---|
530 | rpc_send( cxy , &rpc ); |
---|
531 | |
---|
532 | #if DEBUG_RPC_PMEM_RELEASE_PAGES |
---|
533 | cycle = (uint32_t)hal_get_cycles(); |
---|
534 | if( cycle > DEBUG_RPC_PMEM_RELEASE_PAGES ) |
---|
535 | printk("\n[%s] thread[%x,%x] on core %d exit / cycle %d\n", |
---|
536 | __FUNCTION__, this->process->pid, this->trdid, this->core->lid, cycle ); |
---|
537 | #endif |
---|
538 | } |
---|
539 | |
---|
540 | /////////////////////////////////////////////// |
---|
541 | void rpc_pmem_release_pages_server( xptr_t xp ) |
---|
542 | { |
---|
543 | #if DEBUG_RPC_PMEM_RELEASE_PAGES |
---|
544 | thread_t * this = CURRENT_THREAD; |
---|
545 | uint32_t cycle = (uint32_t)hal_get_cycles(); |
---|
546 | if( cycle > DEBUG_RPC_PMEM_RELEASE_PAGES ) |
---|
547 | printk("\n[%s] thread[%x,%x] on core %d enter / cycle %d\n", |
---|
548 | __FUNCTION__, this->process->pid, this->trdid, this->core->lid , cycle ); |
---|
549 | #endif |
---|
550 | |
---|
551 | // get client cluster identifier and pointer on RPC descriptor |
---|
552 | cxy_t cxy = GET_CXY( xp ); |
---|
553 | rpc_desc_t * desc = GET_PTR( xp ); |
---|
554 | |
---|
555 | // get input arguments from client RPC descriptor |
---|
556 | page_t * page = (page_t *)(intptr_t)hal_remote_l64( XPTR( cxy , &desc->args[0] ) ); |
---|
557 | |
---|
558 | // release memory to local pmem |
---|
559 | kmem_req_t req; |
---|
560 | req.type = KMEM_PPM; |
---|
561 | req.ptr = page; |
---|
562 | kmem_free( &req ); |
---|
563 | |
---|
564 | #if DEBUG_RPC_PMEM_RELEASE_PAGES |
---|
565 | cycle = (uint32_t)hal_get_cycles(); |
---|
566 | if( cycle > DEBUG_RPC_PMEM_RELEASE_PAGES ) |
---|
567 | printk("\n[%s] thread[%x,%x] on core %d exit / cycle %d\n", |
---|
568 | __FUNCTION__, this->process->pid, this->trdid, this->core->lid, cycle ); |
---|
569 | #endif |
---|
570 | } |
---|
571 | */ |
---|
572 | |
---|
573 | ///////////////////////////////////////////////////////////////////////////////////////// |
---|
574 | // [2] RPC_PPM_DISPLAY deprecated [AG] May 2019 |
---|
575 | ///////////////////////////////////////////////////////////////////////////////////////// |
---|
576 | |
---|
577 | /* |
---|
578 | ///////////////////////////////////////// |
---|
579 | void rpc_ppm_display_client( cxy_t cxy ) |
---|
580 | { |
---|
581 | #if DEBUG_RPC_PPM_DISPLAY |
---|
582 | thread_t * this = CURRENT_THREAD; |
---|
583 | uint32_t cycle = (uint32_t)hal_get_cycles(); |
---|
584 | if( cycle > DEBUG_RPC_PPM_DISPLAY ) |
---|
585 | printk("\n[%s] thread[%x,%x] on core %d enter / cycle %d\n", |
---|
586 | __FUNCTION__, this->process->pid, this->trdid, this->core->lid , cycle ); |
---|
587 | #endif |
---|
588 | |
---|
589 | uint32_t responses = 1; |
---|
590 | |
---|
591 | // initialise RPC descriptor header |
---|
592 | rpc_desc_t rpc; |
---|
593 | rpc.index = RPC_PPM_DISPLAY; |
---|
594 | rpc.blocking = true; |
---|
595 | rpc.rsp = &responses; |
---|
596 | |
---|
597 | // register RPC request in remote RPC fifo |
---|
598 | rpc_send( cxy , &rpc ); |
---|
599 | |
---|
600 | #if DEBUG_RPC_PPM_DISPLAY |
---|
601 | cycle = (uint32_t)hal_get_cycles(); |
---|
602 | if( cycle > DEBUG_RPC_PPM_DISPLAY ) |
---|
603 | printk("\n[%s] thread[%x,%x] on core %d exit / cycle %d\n", |
---|
604 | __FUNCTION__, this->process->pid, this->trdid, this->core->lid, cycle ); |
---|
605 | #endif |
---|
606 | } |
---|
607 | |
---|
608 | //////////////////////////////////////////////////////////////////// |
---|
609 | void rpc_ppm_display_server( xptr_t __attribute__((__unused__)) xp ) |
---|
610 | { |
---|
611 | #if DEBUG_RPC_PPM_DISPLAY |
---|
612 | thread_t * this = CURRENT_THREAD; |
---|
613 | uint32_t cycle = (uint32_t)hal_get_cycles(); |
---|
614 | if( cycle > DEBUG_RPC_PPM_DISPLAY ) |
---|
615 | printk("\n[%s] thread[%x,%x] on core %d enter / cycle %d\n", |
---|
616 | __FUNCTION__, this->process->pid, this->trdid, this->core->lid , cycle ); |
---|
617 | #endif |
---|
618 | |
---|
619 | // call local kernel function |
---|
620 | ppm_display(); |
---|
621 | |
---|
622 | #if DEBUG_RPC_PPM_DISPLAY |
---|
623 | cycle = (uint32_t)hal_get_cycles(); |
---|
624 | if( cycle > DEBUG_RPC_PPM_DISPLAY ) |
---|
625 | printk("\n[%s] thread[%x,%x] on core %d exit / cycle %d\n", |
---|
626 | __FUNCTION__, this->process->pid, this->trdid, this->core->lid, cycle ); |
---|
627 | #endif |
---|
628 | } |
---|
629 | */ |
---|
630 | |
---|
631 | ///////////////////////////////////////////////////////////////////////////////////////// |
---|
632 | // [3] Marshaling functions attached to RPC_PROCESS_MAKE_FORK |
---|
633 | ///////////////////////////////////////////////////////////////////////////////////////// |
---|
634 | |
---|
635 | /////////////////////////////////////////////////// |
---|
636 | void rpc_process_make_fork_client( cxy_t cxy, |
---|
637 | xptr_t ref_process_xp, // in |
---|
638 | xptr_t parent_thread_xp, // in |
---|
639 | pid_t * child_pid, // out |
---|
640 | thread_t ** child_thread_ptr, // out |
---|
641 | error_t * error ) // out |
---|
642 | { |
---|
643 | #if DEBUG_RPC_PROCESS_MAKE_FORK |
---|
644 | thread_t * this = CURRENT_THREAD; |
---|
645 | uint32_t cycle = (uint32_t)hal_get_cycles(); |
---|
646 | if( cycle > DEBUG_RPC_PROCESS_MAKE_FORK ) |
---|
647 | printk("\n[%s] thread[%x,%x] on core %d enter / cycle %d\n", |
---|
648 | __FUNCTION__, this->process->pid, this->trdid, this->core->lid , cycle ); |
---|
649 | #endif |
---|
650 | |
---|
651 | uint32_t responses = 1; |
---|
652 | |
---|
653 | // initialise RPC descriptor header |
---|
654 | rpc_desc_t rpc; |
---|
655 | rpc.index = RPC_PROCESS_MAKE_FORK; |
---|
656 | rpc.blocking = true; |
---|
657 | rpc.rsp = &responses; |
---|
658 | |
---|
659 | // set input arguments in RPC descriptor |
---|
660 | rpc.args[0] = (uint64_t)ref_process_xp; |
---|
661 | rpc.args[1] = (uint64_t)parent_thread_xp; |
---|
662 | |
---|
663 | // register RPC request in remote RPC fifo |
---|
664 | rpc_send( cxy , &rpc ); |
---|
665 | |
---|
666 | // get output arguments from RPC descriptor |
---|
667 | *child_pid = (pid_t)rpc.args[2]; |
---|
668 | *child_thread_ptr = (thread_t *)(intptr_t)rpc.args[3]; |
---|
669 | *error = (error_t)rpc.args[4]; |
---|
670 | |
---|
671 | #if DEBUG_RPC_PROCESS_MAKE_FORK |
---|
672 | cycle = (uint32_t)hal_get_cycles(); |
---|
673 | if( cycle > DEBUG_RPC_PROCESS_MAKE_FORK ) |
---|
674 | printk("\n[%s] thread[%x,%x] on core %d exit / cycle %d\n", |
---|
675 | __FUNCTION__, this->process->pid, this->trdid, this->core->lid, cycle ); |
---|
676 | #endif |
---|
677 | } |
---|
678 | |
---|
679 | ////////////////////////////////////////////// |
---|
680 | void rpc_process_make_fork_server( xptr_t xp ) |
---|
681 | { |
---|
682 | #if DEBUG_RPC_PROCESS_MAKE_FORK |
---|
683 | thread_t * this = CURRENT_THREAD; |
---|
684 | uint32_t cycle = (uint32_t)hal_get_cycles(); |
---|
685 | if( cycle > DEBUG_RPC_PROCESS_MAKE_FORK ) |
---|
686 | printk("\n[%s] thread[%x,%x] on core %d enter / cycle %d\n", |
---|
687 | __FUNCTION__, this->process->pid, this->trdid, this->core->lid, cycle ); |
---|
688 | #endif |
---|
689 | |
---|
690 | xptr_t ref_process_xp; // extended pointer on reference parent process |
---|
691 | xptr_t parent_thread_xp; // extended pointer on parent thread |
---|
692 | pid_t child_pid; // child process identifier |
---|
693 | thread_t * child_thread_ptr; // local copy of exec_info structure |
---|
694 | error_t error; // local error status |
---|
695 | |
---|
696 | // get client cluster identifier and pointer on RPC descriptor |
---|
697 | cxy_t client_cxy = GET_CXY( xp ); |
---|
698 | rpc_desc_t * desc = GET_PTR( xp ); |
---|
699 | |
---|
700 | // get input arguments from cient RPC descriptor |
---|
701 | ref_process_xp = (xptr_t)hal_remote_l64( XPTR( client_cxy , &desc->args[0] ) ); |
---|
702 | parent_thread_xp = (xptr_t)hal_remote_l64( XPTR( client_cxy , &desc->args[1] ) ); |
---|
703 | |
---|
704 | // call local kernel function |
---|
705 | error = process_make_fork( ref_process_xp, |
---|
706 | parent_thread_xp, |
---|
707 | &child_pid, |
---|
708 | &child_thread_ptr ); |
---|
709 | |
---|
710 | // set output argument into client RPC descriptor |
---|
711 | hal_remote_s64( XPTR( client_cxy , &desc->args[2] ) , (uint64_t)child_pid ); |
---|
712 | hal_remote_s64( XPTR( client_cxy , &desc->args[3] ) , (uint64_t)(intptr_t)child_thread_ptr ); |
---|
713 | hal_remote_s64( XPTR( client_cxy , &desc->args[4] ) , (uint64_t)error ); |
---|
714 | |
---|
715 | #if DEBUG_RPC_PROCESS_MAKE_FORK |
---|
716 | cycle = (uint32_t)hal_get_cycles(); |
---|
717 | if( cycle > DEBUG_RPC_PROCESS_MAKE_FORK ) |
---|
718 | printk("\n[%s] thread[%x,%x] on core %d exit / cycle %d\n", |
---|
719 | __FUNCTION__, this->process->pid, this->trdid, this->core->lid, cycle ); |
---|
720 | #endif |
---|
721 | } |
---|
722 | |
---|
723 | ///////////////////////////////////////////////////////////////////////////////////////// |
---|
724 | // [4] Marshaling functions attached to RPC_USER_DIR_CREATE |
---|
725 | ///////////////////////////////////////////////////////////////////////////////////////// |
---|
726 | |
---|
727 | //////////////////////////////////////////////////// |
---|
728 | void rpc_user_dir_create_client( cxy_t cxy, |
---|
729 | vfs_inode_t * inode, |
---|
730 | xptr_t ref_xp, |
---|
731 | user_dir_t ** dir ) |
---|
732 | { |
---|
733 | #if DEBUG_RPC_USER_DIR_CREATE |
---|
734 | thread_t * this = CURRENT_THREAD; |
---|
735 | uint32_t cycle = (uint32_t)hal_get_cycles(); |
---|
736 | if( cycle > DEBUG_RPC_USER_DIR_CREATE) |
---|
737 | printk("\n[%s] thread[%x,%x] on core %d enter / cycle %d\n", |
---|
738 | __FUNCTION__, this->process->pid, this->trdid, this->core->lid, cycle ); |
---|
739 | #endif |
---|
740 | |
---|
741 | uint32_t responses = 1; |
---|
742 | |
---|
743 | // initialise RPC descriptor header |
---|
744 | rpc_desc_t rpc; |
---|
745 | rpc.index = RPC_USER_DIR_CREATE; |
---|
746 | rpc.blocking = true; |
---|
747 | rpc.rsp = &responses; |
---|
748 | |
---|
749 | // set input arguments in RPC descriptor |
---|
750 | rpc.args[0] = (uint64_t)(intptr_t)inode; |
---|
751 | rpc.args[1] = (uint64_t)ref_xp; |
---|
752 | |
---|
753 | // register RPC request in remote RPC fifo |
---|
754 | rpc_send( cxy , &rpc ); |
---|
755 | |
---|
756 | // get output argument from RPC descriptor |
---|
757 | *dir = (user_dir_t *)(intptr_t)rpc.args[2]; |
---|
758 | |
---|
759 | #if DEBUG_RPC_USER_DIR_CREATE |
---|
760 | cycle = (uint32_t)hal_get_cycles(); |
---|
761 | if( cycle > DEBUG_RPC_USER_DIR_CREATE) |
---|
762 | printk("\n[%s] thread[%x,%x] on core %d exit / cycle %d\n", |
---|
763 | __FUNCTION__, this->process->pid, this->trdid, this->core->lid, cycle ); |
---|
764 | #endif |
---|
765 | } |
---|
766 | |
---|
767 | //////////////////////////////////////////// |
---|
768 | void rpc_user_dir_create_server( xptr_t xp ) |
---|
769 | { |
---|
770 | #if DEBUG_RPC_USER_DIR_CREATE |
---|
771 | thread_t * this = CURRENT_THREAD; |
---|
772 | uint32_t cycle = (uint32_t)hal_get_cycles(); |
---|
773 | if( cycle > DEBUG_RPC_USER_DIR_CREATE) |
---|
774 | printk("\n[%s] thread[%x,%x] on core %d enter / cycle %d\n", |
---|
775 | __FUNCTION__, this->process->pid, this->trdid, this->core->lid, cycle ); |
---|
776 | #endif |
---|
777 | |
---|
778 | vfs_inode_t * inode; // pointer on inode in server cluster |
---|
779 | xptr_t ref_xp; // extended pointer on reference user process |
---|
780 | user_dir_t * dir; // pointer on user_dir structure in server cluster |
---|
781 | |
---|
782 | // get client cluster identifier and pointer on RPC descriptor |
---|
783 | cxy_t client_cxy = GET_CXY( xp ); |
---|
784 | rpc_desc_t * desc = GET_PTR( xp ); |
---|
785 | |
---|
786 | // get input argument from RPC descriptor |
---|
787 | inode = (vfs_inode_t *)(intptr_t)hal_remote_l64(XPTR(client_cxy , &desc->args[0])); |
---|
788 | ref_xp = (xptr_t) hal_remote_l64(XPTR(client_cxy , &desc->args[1])); |
---|
789 | |
---|
790 | // call kernel function |
---|
791 | dir = user_dir_create( inode , ref_xp ); |
---|
792 | |
---|
793 | // set output argument into RPC descriptor |
---|
794 | hal_remote_s64( XPTR( client_cxy , &desc->args[2] ) , (intptr_t)dir ); |
---|
795 | |
---|
796 | #if DEBUG_RPC_USER_DIR_CREATE |
---|
797 | cycle = (uint32_t)hal_get_cycles(); |
---|
798 | if( cycle > DEBUG_RPC_USER_DIR_CREATE) |
---|
799 | printk("\n[%s] thread[%x,%x] on core %d exit / cycle %d\n", |
---|
800 | __FUNCTION__, this->process->pid, this->trdid, this->core->lid, cycle ); |
---|
801 | #endif |
---|
802 | } |
---|
803 | |
---|
804 | ///////////////////////////////////////////////////////////////////////////////////////// |
---|
805 | // [5] Marshaling functions attached to RPC_USER_DIR_DESTROY |
---|
806 | ///////////////////////////////////////////////////////////////////////////////////////// |
---|
807 | |
---|
808 | //////////////////////////////////////////////////// |
---|
809 | void rpc_user_dir_destroy_client( cxy_t cxy, |
---|
810 | user_dir_t * dir, |
---|
811 | xptr_t ref_xp ) |
---|
812 | { |
---|
813 | #if DEBUG_RPC_USER_DIR_DESTROY |
---|
814 | thread_t * this = CURRENT_THREAD; |
---|
815 | uint32_t cycle = (uint32_t)hal_get_cycles(); |
---|
816 | if( cycle > DEBUG_RPC_USER_DIR_DESTROY) |
---|
817 | printk("\n[%s] thread[%x,%x] on core %d enter / cycle %d\n", |
---|
818 | __FUNCTION__, this->process->pid, this->trdid, this->core->lid, cycle ); |
---|
819 | #endif |
---|
820 | |
---|
821 | uint32_t responses = 1; |
---|
822 | |
---|
823 | // initialise RPC descriptor header |
---|
824 | rpc_desc_t rpc; |
---|
825 | rpc.index = RPC_USER_DIR_DESTROY; |
---|
826 | rpc.blocking = true; |
---|
827 | rpc.rsp = &responses; |
---|
828 | |
---|
829 | // set input arguments in RPC descriptor |
---|
830 | rpc.args[0] = (uint64_t)(intptr_t)dir; |
---|
831 | rpc.args[1] = (uint64_t)ref_xp; |
---|
832 | |
---|
833 | // register RPC request in remote RPC fifo |
---|
834 | rpc_send( cxy , &rpc ); |
---|
835 | |
---|
836 | #if DEBUG_RPC_USER_DIR_DESTROY |
---|
837 | cycle = (uint32_t)hal_get_cycles(); |
---|
838 | if( cycle > DEBUG_RPC_USER_DIR_DESTROY) |
---|
839 | printk("\n[%s] thread[%x,%x] on core %d exit / cycle %d\n", |
---|
840 | __FUNCTION__, this->process->pid, this->trdid, this->core->lid, cycle ); |
---|
841 | #endif |
---|
842 | } |
---|
843 | |
---|
844 | ///////////////////////////////////////////// |
---|
845 | void rpc_user_dir_destroy_server( xptr_t xp ) |
---|
846 | { |
---|
847 | #if DEBUG_RPC_USER_DIR_DESTROY |
---|
848 | thread_t * this = CURRENT_THREAD; |
---|
849 | uint32_t cycle = (uint32_t)hal_get_cycles(); |
---|
850 | if( cycle > DEBUG_RPC_USER_DIR_DESTROY) |
---|
851 | printk("\n[%s] thread[%x,%x] on core %d enter / cycle %d\n", |
---|
852 | __FUNCTION__, this->process->pid, this->trdid, this->core->lid, cycle ); |
---|
853 | #endif |
---|
854 | |
---|
855 | user_dir_t * dir; // pointer on user_dir structure in server cluster |
---|
856 | xptr_t ref_xp; // extended pointer on reference process |
---|
857 | |
---|
858 | // get client cluster identifier and pointer on RPC descriptor |
---|
859 | cxy_t client_cxy = GET_CXY( xp ); |
---|
860 | rpc_desc_t * desc = GET_PTR( xp ); |
---|
861 | |
---|
862 | // get input argument from RPC descriptor |
---|
863 | dir = (user_dir_t *)(intptr_t)hal_remote_l64(XPTR(client_cxy , &desc->args[0])); |
---|
864 | ref_xp = (xptr_t) hal_remote_l64(XPTR(client_cxy , &desc->args[1])); |
---|
865 | |
---|
866 | // call kernel function |
---|
867 | user_dir_destroy( dir , ref_xp ); |
---|
868 | |
---|
869 | #if DEBUG_RPC_USER_DIR_DESTROY |
---|
870 | cycle = (uint32_t)hal_get_cycles(); |
---|
871 | if( cycle > DEBUG_RPC_USER_DIR_DESTROY) |
---|
872 | printk("\n[%s] thread[%x,%x] on core %d exit / cycle %d\n", |
---|
873 | __FUNCTION__, this->process->pid, this->trdid, this->core->lid, cycle ); |
---|
874 | #endif |
---|
875 | } |
---|
876 | |
---|
877 | ///////////////////////////////////////////////////////////////////////////////////////// |
---|
878 | // [6] Marshaling functions attached to RPC_THREAD_USER_CREATE |
---|
879 | ///////////////////////////////////////////////////////////////////////////////////////// |
---|
880 | |
---|
881 | ///////////////////////////////////////////////////////// |
---|
882 | void rpc_thread_user_create_client( cxy_t cxy, |
---|
883 | pid_t pid, // in |
---|
884 | void * start_func, // in |
---|
885 | void * start_arg, // in |
---|
886 | pthread_attr_t * attr, // in |
---|
887 | xptr_t * thread_xp, // out |
---|
888 | error_t * error ) // out |
---|
889 | { |
---|
890 | #if DEBUG_RPC_THREAD_USER_CREATE |
---|
891 | thread_t * this = CURRENT_THREAD; |
---|
892 | uint32_t cycle = (uint32_t)hal_get_cycles(); |
---|
893 | if( cycle > DEBUG_RPC_THREAD_USER_CREATE) |
---|
894 | printk("\n[%s] thread[%x,%x] on core %d enter / cycle %d\n", |
---|
895 | __FUNCTION__, this->process->pid, this->trdid, this->core->lid, cycle ); |
---|
896 | #endif |
---|
897 | |
---|
898 | uint32_t responses = 1; |
---|
899 | |
---|
900 | // initialise RPC descriptor header |
---|
901 | rpc_desc_t rpc; |
---|
902 | rpc.index = RPC_THREAD_USER_CREATE; |
---|
903 | rpc.blocking = true; |
---|
904 | rpc.rsp = &responses; |
---|
905 | |
---|
906 | // set input arguments in RPC descriptor |
---|
907 | rpc.args[0] = (uint64_t)pid; |
---|
908 | rpc.args[1] = (uint64_t)(intptr_t)start_func; |
---|
909 | rpc.args[2] = (uint64_t)(intptr_t)start_arg; |
---|
910 | rpc.args[3] = (uint64_t)(intptr_t)attr; |
---|
911 | |
---|
912 | // register RPC request in remote RPC fifo |
---|
913 | rpc_send( cxy , &rpc ); |
---|
914 | |
---|
915 | // get output arguments from RPC descriptor |
---|
916 | *thread_xp = (xptr_t)rpc.args[4]; |
---|
917 | *error = (error_t)rpc.args[5]; |
---|
918 | |
---|
919 | #if DEBUG_RPC_THREAD_USER_CREATE |
---|
920 | cycle = (uint32_t)hal_get_cycles(); |
---|
921 | if( cycle > DEBUG_RPC_THREAD_USER_CREATE) |
---|
922 | printk("\n[%s] thread[%x,%x] on core %d exit / cycle %d\n", |
---|
923 | __FUNCTION__, this->process->pid, this->trdid, this->core->lid, cycle ); |
---|
924 | #endif |
---|
925 | } |
---|
926 | |
---|
927 | /////////////////////////////////////////////// |
---|
928 | void rpc_thread_user_create_server( xptr_t xp ) |
---|
929 | { |
---|
930 | #if DEBUG_RPC_THREAD_USER_CREATE |
---|
931 | thread_t * this = CURRENT_THREAD; |
---|
932 | uint32_t cycle = (uint32_t)hal_get_cycles(); |
---|
933 | if( cycle > DEBUG_RPC_THREAD_USER_CREATE) |
---|
934 | printk("\n[%s] thread[%x,%x] on core %d enter / cycle %d\n", |
---|
935 | __FUNCTION__, this->process->pid, this->trdid, this->core->lid, cycle ); |
---|
936 | #endif |
---|
937 | |
---|
938 | pthread_attr_t * attr_ptr; // pointer on attributes structure in client cluster |
---|
939 | pthread_attr_t attr_copy; // attributes structure copy in server cluster |
---|
940 | thread_t * thread_ptr; // local pointer on thread descriptor |
---|
941 | xptr_t thread_xp; // extended pointer on thread descriptor |
---|
942 | |
---|
943 | pid_t pid; // process identifier |
---|
944 | void * start_func; |
---|
945 | void * start_arg; |
---|
946 | error_t error; |
---|
947 | |
---|
948 | // get client cluster identifier and pointer on RPC descriptor |
---|
949 | cxy_t client_cxy = GET_CXY( xp ); |
---|
950 | rpc_desc_t * desc = GET_PTR( xp ); |
---|
951 | |
---|
952 | // get input arguments from RPC descriptor |
---|
953 | pid = (pid_t) hal_remote_l64(XPTR(client_cxy , &desc->args[0])); |
---|
954 | start_func = (void *)(intptr_t) hal_remote_l64(XPTR(client_cxy , &desc->args[1])); |
---|
955 | start_arg = (void *)(intptr_t) hal_remote_l64(XPTR(client_cxy , &desc->args[2])); |
---|
956 | attr_ptr = (pthread_attr_t *)(intptr_t)hal_remote_l64(XPTR(client_cxy , &desc->args[3])); |
---|
957 | |
---|
958 | // makes a local copy of attributes structure |
---|
959 | hal_remote_memcpy( XPTR( local_cxy , &attr_copy ), |
---|
960 | XPTR( client_cxy , attr_ptr ), |
---|
961 | sizeof(pthread_attr_t) ); |
---|
962 | |
---|
963 | // call kernel function |
---|
964 | error = thread_user_create( pid, |
---|
965 | start_func, |
---|
966 | start_arg, |
---|
967 | &attr_copy, |
---|
968 | &thread_ptr ); |
---|
969 | // set output arguments |
---|
970 | thread_xp = XPTR( local_cxy , thread_ptr ); |
---|
971 | hal_remote_s64( XPTR( client_cxy , &desc->args[4] ) , (uint64_t)thread_xp ); |
---|
972 | hal_remote_s64( XPTR( client_cxy , &desc->args[5] ) , (uint64_t)error ); |
---|
973 | |
---|
974 | #if DEBUG_RPC_THREAD_USER_CREATE |
---|
975 | cycle = (uint32_t)hal_get_cycles(); |
---|
976 | if( cycle > DEBUG_RPC_THREAD_USER_CREATE) |
---|
977 | printk("\n[%s] thread[%x,%x] on core %d exit / cycle %d\n", |
---|
978 | __FUNCTION__, this->process->pid, this->trdid, this->core->lid, cycle ); |
---|
979 | #endif |
---|
980 | } |
---|
981 | |
---|
982 | ///////////////////////////////////////////////////////////////////////////////////////// |
---|
983 | // [7] Marshaling functions attached to RPC_THREAD_KERNEL_CREATE |
---|
984 | ///////////////////////////////////////////////////////////////////////////////////////// |
---|
985 | |
---|
986 | //////////////////////////////////////////////////// |
---|
987 | void rpc_thread_kernel_create_client( cxy_t cxy, |
---|
988 | uint32_t type, // in |
---|
989 | void * func, // in |
---|
990 | void * args, // in |
---|
991 | xptr_t * thread_xp, // out |
---|
992 | error_t * error ) // out |
---|
993 | { |
---|
994 | #if DEBUG_RPC_THREAD_KERNEL_CREATE |
---|
995 | thread_t * this = CURRENT_THREAD; |
---|
996 | uint32_t cycle = (uint32_t)hal_get_cycles(); |
---|
997 | if( cycle > DEBUG_RPC_THREAD_KERNEL_CREATE) |
---|
998 | printk("\n[%s] thread[%x,%x] on core %d enter / cycle %d\n", |
---|
999 | __FUNCTION__, this->process->pid, this->trdid, this->core->lid, cycle ); |
---|
1000 | #endif |
---|
1001 | |
---|
1002 | uint32_t responses = 1; |
---|
1003 | |
---|
1004 | // initialise RPC descriptor header |
---|
1005 | rpc_desc_t rpc; |
---|
1006 | rpc.index = RPC_THREAD_KERNEL_CREATE; |
---|
1007 | rpc.blocking = true; |
---|
1008 | rpc.rsp = &responses; |
---|
1009 | |
---|
1010 | // set input arguments in RPC descriptor |
---|
1011 | rpc.args[0] = (uint64_t)type; |
---|
1012 | rpc.args[1] = (uint64_t)(intptr_t)func; |
---|
1013 | rpc.args[2] = (uint64_t)(intptr_t)args; |
---|
1014 | |
---|
1015 | // register RPC request in remote RPC fifo |
---|
1016 | rpc_send( cxy , &rpc ); |
---|
1017 | |
---|
1018 | // get output arguments from RPC descriptor |
---|
1019 | *thread_xp = (xptr_t)rpc.args[3]; |
---|
1020 | *error = (error_t)rpc.args[4]; |
---|
1021 | |
---|
1022 | #if DEBUG_RPC_THREAD_KERNEL_CREATE |
---|
1023 | cycle = (uint32_t)hal_get_cycles(); |
---|
1024 | if( cycle > DEBUG_RPC_THREAD_KERNEL_CREATE) |
---|
1025 | printk("\n[%s] thread[%x,%x] on core %d exit / cycle %d\n", |
---|
1026 | __FUNCTION__, this->process->pid, this->trdid, this->core->lid, cycle ); |
---|
1027 | #endif |
---|
1028 | } |
---|
1029 | |
---|
1030 | ///////////////////////////////////////////////// |
---|
1031 | void rpc_thread_kernel_create_server( xptr_t xp ) |
---|
1032 | { |
---|
1033 | #if DEBUG_RPC_THREAD_KERNEL_CREATE |
---|
1034 | thread_t * this = CURRENT_THREAD; |
---|
1035 | uint32_t cycle = (uint32_t)hal_get_cycles(); |
---|
1036 | if( cycle > DEBUG_RPC_THREAD_KERNEL_CREATE) |
---|
1037 | printk("\n[%s] thread[%x,%x] on core %d enter / cycle %d\n", |
---|
1038 | __FUNCTION__, this->process->pid, this->trdid, this->core->lid, cycle ); |
---|
1039 | #endif |
---|
1040 | |
---|
1041 | thread_t * thread_ptr; // local pointer on thread descriptor |
---|
1042 | xptr_t thread_xp; // extended pointer on thread descriptor |
---|
1043 | lid_t core_lid; // core local index |
---|
1044 | error_t error; |
---|
1045 | |
---|
1046 | // get client cluster identifier and pointer on RPC descriptor |
---|
1047 | cxy_t client_cxy = GET_CXY( xp ); |
---|
1048 | rpc_desc_t * desc = GET_PTR( xp ); |
---|
1049 | |
---|
1050 | // get attributes from RPC descriptor |
---|
1051 | uint32_t type = (uint32_t) hal_remote_l64( XPTR( client_cxy , &desc->args[0] ) ); |
---|
1052 | void * func = (void*)(intptr_t)hal_remote_l64( XPTR( client_cxy , &desc->args[1] ) ); |
---|
1053 | void * args = (void*)(intptr_t)hal_remote_l64( XPTR( client_cxy , &desc->args[2] ) ); |
---|
1054 | |
---|
1055 | // select one core |
---|
1056 | core_lid = cluster_select_local_core( local_cxy ); |
---|
1057 | |
---|
1058 | // call local kernel function |
---|
1059 | error = thread_kernel_create( &thread_ptr , type , func , args , core_lid ); |
---|
1060 | |
---|
1061 | // set output arguments |
---|
1062 | thread_xp = XPTR( local_cxy , thread_ptr ); |
---|
1063 | hal_remote_s64( XPTR( client_cxy , &desc->args[1] ) , (uint64_t)error ); |
---|
1064 | hal_remote_s64( XPTR( client_cxy , &desc->args[2] ) , (uint64_t)thread_xp ); |
---|
1065 | |
---|
1066 | #if DEBUG_RPC_THREAD_KERNEL_CREATE |
---|
1067 | cycle = (uint32_t)hal_get_cycles(); |
---|
1068 | if( cycle > DEBUG_RPC_THREAD_KERNEL_CREATE) |
---|
1069 | printk("\n[%s] thread[%x,%x] on core %d exit / cycle %d\n", |
---|
1070 | __FUNCTION__, this->process->pid, this->trdid, this->core->lid, cycle ); |
---|
1071 | #endif |
---|
1072 | } |
---|
1073 | |
---|
1074 | ///////////////////////////////////////////////////////////////////////////////////////// |
---|
1075 | // [8] Marshaling functions attached to RPC_VFS_FS_UPDATE_DENTRY |
---|
1076 | ///////////////////////////////////////////////////////////////////////////////////////// |
---|
1077 | |
---|
1078 | ///////////////////////////////////////////////////////// |
---|
1079 | void rpc_vfs_fs_update_dentry_client( cxy_t cxy, |
---|
1080 | vfs_inode_t * inode, |
---|
1081 | vfs_dentry_t * dentry, |
---|
1082 | uint32_t size, |
---|
1083 | error_t * error ) |
---|
1084 | { |
---|
1085 | #if DEBUG_RPC_VFS_FS_UPDATE_DENTRY |
---|
1086 | thread_t * this = CURRENT_THREAD; |
---|
1087 | uint32_t cycle = (uint32_t)hal_get_cycles(); |
---|
1088 | if( cycle > DEBUG_RPC_VFS_FS_UPDATE_DENTRY ) |
---|
1089 | printk("\n[%s] thread[%x,%x] on core %d enter / cycle %d\n", |
---|
1090 | __FUNCTION__, this->process->pid, this->trdid, this->core->lid , cycle ); |
---|
1091 | #endif |
---|
1092 | |
---|
1093 | uint32_t responses = 1; |
---|
1094 | |
---|
1095 | // initialise RPC descriptor header |
---|
1096 | rpc_desc_t rpc; |
---|
1097 | rpc.index = RPC_VFS_FS_UPDATE_DENTRY; |
---|
1098 | rpc.blocking = true; |
---|
1099 | rpc.rsp = &responses; |
---|
1100 | |
---|
1101 | // set input arguments in RPC descriptor |
---|
1102 | rpc.args[0] = (uint64_t)(intptr_t)inode; |
---|
1103 | rpc.args[1] = (uint64_t)(intptr_t)dentry; |
---|
1104 | rpc.args[2] = (uint64_t)size; |
---|
1105 | |
---|
1106 | // register RPC request in remote RPC fifo |
---|
1107 | rpc_send( cxy , &rpc ); |
---|
1108 | |
---|
1109 | // get output values from RPC descriptor |
---|
1110 | *error = (error_t)rpc.args[3]; |
---|
1111 | |
---|
1112 | #if DEBUG_RPC_VFS_FS_UPDATE_DENTRY |
---|
1113 | cycle = (uint32_t)hal_get_cycles(); |
---|
1114 | if( cycle > DEBUG_RPC_VFS_FS_UPDATE_DENTRY ) |
---|
1115 | printk("\n[%s] thread[%x,%x] on core %d exit / cycle %d\n", |
---|
1116 | __FUNCTION__, this->process->pid, this->trdid, this->core->lid , cycle ); |
---|
1117 | #endif |
---|
1118 | } |
---|
1119 | |
---|
1120 | ///////////////////////////////////////////////// |
---|
1121 | void rpc_vfs_fs_update_dentry_server( xptr_t xp ) |
---|
1122 | { |
---|
1123 | #if DEBUG_RPC_VFS_FS_UPDATE_DENTRY |
---|
1124 | thread_t * this = CURRENT_THREAD; |
---|
1125 | uint32_t cycle = (uint32_t)hal_get_cycles(); |
---|
1126 | if( cycle > DEBUG_RPC_VFS_FS_UPDATE_DENTRY ) |
---|
1127 | printk("\n[%s] thread[%x,%x] on core %d enter / cycle %d\n", |
---|
1128 | __FUNCTION__, this->process->pid, this->trdid, this->core->lid , cycle ); |
---|
1129 | #endif |
---|
1130 | |
---|
1131 | error_t error; |
---|
1132 | vfs_inode_t * inode; |
---|
1133 | vfs_dentry_t * dentry; |
---|
1134 | uint32_t size; |
---|
1135 | |
---|
1136 | // get client cluster identifier and pointer on RPC descriptor |
---|
1137 | cxy_t client_cxy = GET_CXY( xp ); |
---|
1138 | rpc_desc_t * desc = GET_PTR( xp ); |
---|
1139 | |
---|
1140 | // get input arguments |
---|
1141 | inode = (vfs_inode_t*)(intptr_t) hal_remote_l64(XPTR(client_cxy , &desc->args[0])); |
---|
1142 | dentry = (vfs_dentry_t*)(intptr_t)hal_remote_l64(XPTR(client_cxy , &desc->args[1])); |
---|
1143 | size = (uint32_t) hal_remote_l64(XPTR(client_cxy , &desc->args[2])); |
---|
1144 | |
---|
1145 | // call the kernel function |
---|
1146 | error = vfs_fs_update_dentry( inode , dentry , size ); |
---|
1147 | |
---|
1148 | // set output argument |
---|
1149 | hal_remote_s64( XPTR( client_cxy , &desc->args[3] ) , (uint64_t)error ); |
---|
1150 | |
---|
1151 | #if DEBUG_RPC_VFS_FS_UPDATE_DENTRY |
---|
1152 | cycle = (uint32_t)hal_get_cycles(); |
---|
1153 | if( cycle > DEBUG_RPC_VFS_FS_UPDATE_DENTRY ) |
---|
1154 | printk("\n[%s] thread[%x,%x] on core %d exit / cycle %d\n", |
---|
1155 | __FUNCTION__, this->process->pid, this->trdid, this->core->lid , cycle ); |
---|
1156 | #endif |
---|
1157 | } |
---|
1158 | |
---|
1159 | ///////////////////////////////////////////////////////////////////////////////////////// |
---|
1160 | // [9] Marshaling functions attached to RPC_PROCESS_SIGACTION |
---|
1161 | ///////////////////////////////////////////////////////////////////////////////////////// |
---|
1162 | |
---|
1163 | //////////////////////////////////////////////////// |
---|
1164 | void rpc_process_sigaction_client( cxy_t cxy, |
---|
1165 | pid_t pid, |
---|
1166 | uint32_t action ) |
---|
1167 | { |
---|
1168 | #if DEBUG_RPC_PROCESS_SIGACTION |
---|
1169 | uint32_t cycle = (uint32_t)hal_get_cycles(); |
---|
1170 | thread_t * this = CURRENT_THREAD; |
---|
1171 | if( DEBUG_RPC_PROCESS_SIGACTION < cycle ) |
---|
1172 | printk("\n[%s] thread[%x,%x] on core %d : enter to %s process %x / cycle %d\n", |
---|
1173 | __FUNCTION__, this->process->pid, this->trdid, this->core->lid, |
---|
1174 | process_action_str( action ), pid, cycle ); |
---|
1175 | #endif |
---|
1176 | |
---|
1177 | uint32_t responses = 1; |
---|
1178 | rpc_desc_t rpc; |
---|
1179 | |
---|
1180 | // initialise RPC descriptor header |
---|
1181 | rpc.index = RPC_PROCESS_SIGACTION; |
---|
1182 | rpc.blocking = true; |
---|
1183 | rpc.rsp = &responses; |
---|
1184 | |
---|
1185 | // set input arguments in RPC descriptor |
---|
1186 | rpc.args[0] = (uint64_t)pid; |
---|
1187 | rpc.args[1] = (uint64_t)action; |
---|
1188 | |
---|
1189 | // register RPC request in remote RPC fifo |
---|
1190 | rpc_send( cxy , &rpc ); |
---|
1191 | |
---|
1192 | #if DEBUG_RPC_PROCESS_SIGACTION |
---|
1193 | cycle = (uint32_t)hal_get_cycles(); |
---|
1194 | if( DEBUG_RPC_PROCESS_SIGACTION < cycle ) |
---|
1195 | printk("\n[%s] thread[%x,%x] on core %d : exit after %s process %x / cycle %d\n", |
---|
1196 | __FUNCTION__, this->process->pid, this->trdid, this->core->lid, |
---|
1197 | process_action_str( action ), pid, cycle ); |
---|
1198 | #endif |
---|
1199 | } // end rpc_process_sigaction_client() |
---|
1200 | |
---|
1201 | ////////////////////////////////////////////// |
---|
1202 | void rpc_process_sigaction_server( xptr_t xp ) |
---|
1203 | { |
---|
1204 | // get client cluster identifier and pointer on RPC descriptor |
---|
1205 | cxy_t client_cxy = GET_CXY( xp ); |
---|
1206 | rpc_desc_t * desc = GET_PTR( xp ); |
---|
1207 | |
---|
1208 | // get arguments from RPC descriptor |
---|
1209 | pid_t pid = (pid_t) hal_remote_l64( XPTR(client_cxy , &desc->args[0]) ); |
---|
1210 | uint32_t action = (uint32_t)hal_remote_l64( XPTR(client_cxy , &desc->args[1]) ); |
---|
1211 | |
---|
1212 | #if DEBUG_RPC_PROCESS_SIGACTION |
---|
1213 | uint32_t cycle = (uint32_t)hal_get_cycles(); |
---|
1214 | thread_t * this = CURRENT_THREAD; |
---|
1215 | if( DEBUG_RPC_PROCESS_SIGACTION < cycle ) |
---|
1216 | printk("\n[%s] thread[%x,%x] on core %d : enter to %s process %x / cycle %d\n", |
---|
1217 | __FUNCTION__, this->process->pid, this->trdid, this->core->lid, |
---|
1218 | process_action_str( action ), pid, cycle ); |
---|
1219 | #endif |
---|
1220 | |
---|
1221 | // get client thread pointers |
---|
1222 | thread_t * client_ptr = hal_remote_lpt( XPTR( client_cxy , &desc->thread ) ); |
---|
1223 | xptr_t client_xp = XPTR( client_cxy , client_ptr ); |
---|
1224 | |
---|
1225 | // get local process descriptor |
---|
1226 | process_t * process = cluster_get_local_process_from_pid( pid ); |
---|
1227 | |
---|
1228 | // call relevant kernel function if found / does nothing if not found |
---|
1229 | if( process != NULL ) |
---|
1230 | { |
---|
1231 | if ( action == DELETE_ALL_THREADS ) process_delete_threads ( process , client_xp ); |
---|
1232 | if ( action == BLOCK_ALL_THREADS ) process_block_threads ( process ); |
---|
1233 | if ( action == UNBLOCK_ALL_THREADS ) process_unblock_threads( process ); |
---|
1234 | } |
---|
1235 | |
---|
1236 | #if DEBUG_RPC_PROCESS_SIGACTION |
---|
1237 | cycle = (uint32_t)hal_get_cycles(); |
---|
1238 | if( DEBUG_RPC_PROCESS_SIGACTION < cycle ) |
---|
1239 | printk("\n[%s] thread[%x,%x] on core %d : exit after %s process %x / cycle %d\n", |
---|
1240 | __FUNCTION__, this->process->pid, this->trdid, this->core->lid, |
---|
1241 | process_action_str( action ), pid, cycle ); |
---|
1242 | #endif |
---|
1243 | } // end rpc_process_sigaction_server() |
---|
1244 | |
---|
1245 | ///////////////////////////////////////////////////////////////////////////////////////// |
---|
1246 | // [10] Marshaling functions attached to RPC_VFS_INODE_CREATE |
---|
1247 | ///////////////////////////////////////////////////////////////////////////////////////// |
---|
1248 | |
---|
1249 | ///////////////////////////////////////////////////// |
---|
1250 | void rpc_vfs_inode_create_client( cxy_t cxy, |
---|
1251 | uint32_t fs_type, // in |
---|
1252 | uint32_t attr, // in |
---|
1253 | uint32_t rights, // in |
---|
1254 | uint32_t uid, // in |
---|
1255 | uint32_t gid, // in |
---|
1256 | xptr_t * inode_xp, // out |
---|
1257 | error_t * error ) // out |
---|
1258 | { |
---|
1259 | #if DEBUG_RPC_VFS_INODE_CREATE |
---|
1260 | thread_t * this = CURRENT_THREAD; |
---|
1261 | uint32_t cycle = (uint32_t)hal_get_cycles(); |
---|
1262 | if( cycle > DEBUG_RPC_VFS_INODE_CREATE ) |
---|
1263 | printk("\n[%s] thread[%x,%x] on core %d enter / cycle %d\n", |
---|
1264 | __FUNCTION__, this->process->pid, this->trdid, this->core->lid , cycle ); |
---|
1265 | #endif |
---|
1266 | |
---|
1267 | uint32_t responses = 1; |
---|
1268 | |
---|
1269 | // initialise RPC descriptor header |
---|
1270 | rpc_desc_t rpc; |
---|
1271 | rpc.index = RPC_VFS_INODE_CREATE; |
---|
1272 | rpc.blocking = true; |
---|
1273 | rpc.rsp = &responses; |
---|
1274 | |
---|
1275 | // set input arguments in RPC descriptor |
---|
1276 | rpc.args[0] = (uint64_t)fs_type; |
---|
1277 | rpc.args[1] = (uint64_t)attr; |
---|
1278 | rpc.args[2] = (uint64_t)rights; |
---|
1279 | rpc.args[3] = (uint64_t)uid; |
---|
1280 | rpc.args[4] = (uint64_t)gid; |
---|
1281 | |
---|
1282 | // register RPC request in remote RPC fifo |
---|
1283 | rpc_send( cxy , &rpc ); |
---|
1284 | |
---|
1285 | // get output values from RPC descriptor |
---|
1286 | *inode_xp = (xptr_t)rpc.args[5]; |
---|
1287 | *error = (error_t)rpc.args[6]; |
---|
1288 | |
---|
1289 | #if DEBUG_RPC_VFS_INODE_CREATE |
---|
1290 | cycle = (uint32_t)hal_get_cycles(); |
---|
1291 | if( cycle > DEBUG_RPC_VFS_INODE_CREATE ) |
---|
1292 | printk("\n[%s] thread[%x,%x] on core %d exit / cycle %d\n", |
---|
1293 | __FUNCTION__, this->process->pid, this->trdid, this->core->lid, cycle ); |
---|
1294 | #endif |
---|
1295 | } |
---|
1296 | |
---|
1297 | ///////////////////////////////////////////// |
---|
1298 | void rpc_vfs_inode_create_server( xptr_t xp ) |
---|
1299 | { |
---|
1300 | #if DEBUG_RPC_VFS_INODE_CREATE |
---|
1301 | thread_t * this = CURRENT_THREAD; |
---|
1302 | uint32_t cycle = (uint32_t)hal_get_cycles(); |
---|
1303 | if( cycle > DEBUG_RPC_VFS_INODE_CREATE ) |
---|
1304 | printk("\n[%s] thread[%x,%x] on core %d enter / cycle %d\n", |
---|
1305 | __FUNCTION__, this->process->pid, this->trdid, this->core->lid, cycle ); |
---|
1306 | #endif |
---|
1307 | |
---|
1308 | uint32_t fs_type; |
---|
1309 | uint32_t attr; |
---|
1310 | uint32_t rights; |
---|
1311 | uint32_t uid; |
---|
1312 | uint32_t gid; |
---|
1313 | xptr_t inode_xp; |
---|
1314 | error_t error; |
---|
1315 | |
---|
1316 | // get client cluster identifier and pointer on RPC descriptor |
---|
1317 | cxy_t client_cxy = GET_CXY( xp ); |
---|
1318 | rpc_desc_t * desc = GET_PTR( xp ); |
---|
1319 | |
---|
1320 | // get input arguments from client rpc descriptor |
---|
1321 | fs_type = (uint32_t) hal_remote_l64( XPTR( client_cxy , &desc->args[0] ) ); |
---|
1322 | attr = (uint32_t) hal_remote_l64( XPTR( client_cxy , &desc->args[1] ) ); |
---|
1323 | rights = (uint32_t) hal_remote_l64( XPTR( client_cxy , &desc->args[2] ) ); |
---|
1324 | uid = (uid_t) hal_remote_l64( XPTR( client_cxy , &desc->args[3] ) ); |
---|
1325 | gid = (gid_t) hal_remote_l64( XPTR( client_cxy , &desc->args[4] ) ); |
---|
1326 | |
---|
1327 | // call local kernel function |
---|
1328 | error = vfs_inode_create( fs_type, |
---|
1329 | attr, |
---|
1330 | rights, |
---|
1331 | uid, |
---|
1332 | gid, |
---|
1333 | &inode_xp ); |
---|
1334 | |
---|
1335 | // set output arguments |
---|
1336 | hal_remote_s64( XPTR( client_cxy , &desc->args[5] ) , (uint64_t)inode_xp ); |
---|
1337 | hal_remote_s64( XPTR( client_cxy , &desc->args[6] ) , (uint64_t)error ); |
---|
1338 | |
---|
1339 | #if DEBUG_RPC_VFS_INODE_CREATE |
---|
1340 | cycle = (uint32_t)hal_get_cycles(); |
---|
1341 | if( cycle > DEBUG_RPC_VFS_INODE_CREATE ) |
---|
1342 | printk("\n[%s] thread[%x,%x] on core %d exit / cycle %d\n", |
---|
1343 | __FUNCTION__, this->process->pid, this->trdid, this->core->lid, cycle ); |
---|
1344 | #endif |
---|
1345 | } |
---|
1346 | |
---|
1347 | ///////////////////////////////////////////////////////////////////////////////////////// |
---|
1348 | // [11] Marshaling functions attached to RPC_VFS_INODE_DESTROY |
---|
1349 | ///////////////////////////////////////////////////////////////////////////////////////// |
---|
1350 | |
---|
1351 | ///////////////////////////////////////////////////////////// |
---|
1352 | void rpc_vfs_inode_destroy_client( cxy_t cxy, |
---|
1353 | struct vfs_inode_s * inode ) |
---|
1354 | { |
---|
1355 | #if DEBUG_RPC_VFS_INODE_DESTROY |
---|
1356 | thread_t * this = CURRENT_THREAD; |
---|
1357 | uint32_t cycle = (uint32_t)hal_get_cycles(); |
---|
1358 | if( cycle > DEBUG_RPC_VFS_INODE_DESTROY ) |
---|
1359 | printk("\n[%s] thread[%x,%x] on core %d enter / cycle %d\n", |
---|
1360 | __FUNCTION__, this->process->pid, this->trdid, this->core->lid, cycle ); |
---|
1361 | #endif |
---|
1362 | |
---|
1363 | uint32_t responses = 1; |
---|
1364 | |
---|
1365 | // initialise RPC descriptor header |
---|
1366 | rpc_desc_t rpc; |
---|
1367 | rpc.index = RPC_VFS_INODE_DESTROY; |
---|
1368 | rpc.blocking = true; |
---|
1369 | rpc.rsp = &responses; |
---|
1370 | |
---|
1371 | // set input arguments in RPC descriptor |
---|
1372 | rpc.args[0] = (uint64_t)(intptr_t)inode; |
---|
1373 | |
---|
1374 | // register RPC request in remote RPC fifo |
---|
1375 | rpc_send( cxy , &rpc ); |
---|
1376 | |
---|
1377 | #if DEBUG_RPC_VFS_INODE_DESTROY |
---|
1378 | cycle = (uint32_t)hal_get_cycles(); |
---|
1379 | if( cycle > DEBUG_RPC_VFS_INODE_DESTROY ) |
---|
1380 | printk("\n[%s] thread[%x,%x] on core %d exit / cycle %d\n", |
---|
1381 | __FUNCTION__, this->process->pid, this->trdid, this->core->lid, cycle ); |
---|
1382 | #endif |
---|
1383 | } |
---|
1384 | |
---|
1385 | ////////////////////////////////////////////// |
---|
1386 | void rpc_vfs_inode_destroy_server( xptr_t xp ) |
---|
1387 | { |
---|
1388 | #if DEBUG_RPC_VFS_INODE_DESTROY |
---|
1389 | thread_t * this = CURRENT_THREAD; |
---|
1390 | uint32_t cycle = (uint32_t)hal_get_cycles(); |
---|
1391 | if( cycle > DEBUG_RPC_VFS_INODE_DESTROY ) |
---|
1392 | printk("\n[%s] thread[%x,%x] on core %d enter / cycle %d\n", |
---|
1393 | __FUNCTION__, this->process->pid, this->trdid, this->core->lid, cycle ); |
---|
1394 | #endif |
---|
1395 | |
---|
1396 | vfs_inode_t * inode; |
---|
1397 | |
---|
1398 | // get client cluster identifier and pointer on RPC descriptor |
---|
1399 | cxy_t client_cxy = GET_CXY( xp ); |
---|
1400 | rpc_desc_t * desc = GET_PTR( xp ); |
---|
1401 | |
---|
1402 | // get argument "inode" from client RPC descriptor |
---|
1403 | inode = (vfs_inode_t *)(intptr_t)hal_remote_l64( XPTR( client_cxy , &desc->args[0] ) ); |
---|
1404 | |
---|
1405 | // call local kernel function |
---|
1406 | vfs_inode_destroy( inode ); |
---|
1407 | |
---|
1408 | #if DEBUG_RPC_VFS_INODE_DESTROY |
---|
1409 | cycle = (uint32_t)hal_get_cycles(); |
---|
1410 | if( cycle > DEBUG_RPC_VFS_INODE_DESTROY ) |
---|
1411 | printk("\n[%s] thread[%x,%x] on core %d exit / cycle %d\n", |
---|
1412 | __FUNCTION__, this->process->pid, this->trdid, this->core->lid, cycle ); |
---|
1413 | #endif |
---|
1414 | } |
---|
1415 | |
---|
1416 | ///////////////////////////////////////////////////////////////////////////////////////// |
---|
1417 | // [12] Marshaling functions attached to RPC_VFS_DENTRY_CREATE |
---|
1418 | ///////////////////////////////////////////////////////////////////////////////////////// |
---|
1419 | |
---|
1420 | ////////////////////////////////////////////////////////////// |
---|
1421 | void rpc_vfs_dentry_create_client( cxy_t cxy, |
---|
1422 | uint32_t type, // in |
---|
1423 | char * name, // in |
---|
1424 | xptr_t * dentry_xp, // out |
---|
1425 | error_t * error ) // out |
---|
1426 | { |
---|
1427 | #if DEBUG_RPC_VFS_DENTRY_CREATE |
---|
1428 | thread_t * this = CURRENT_THREAD; |
---|
1429 | uint32_t cycle = (uint32_t)hal_get_cycles(); |
---|
1430 | if( cycle > DEBUG_RPC_VFS_DENTRY_CREATE ) |
---|
1431 | printk("\n[%s] thread[%x,%x] on core %d enter / cycle %d\n", |
---|
1432 | __FUNCTION__, this->process->pid, this->trdid, this->core->lid, cycle ); |
---|
1433 | #endif |
---|
1434 | |
---|
1435 | uint32_t responses = 1; |
---|
1436 | |
---|
1437 | // initialise RPC descriptor header |
---|
1438 | rpc_desc_t rpc; |
---|
1439 | rpc.index = RPC_VFS_DENTRY_CREATE; |
---|
1440 | rpc.blocking = true; |
---|
1441 | rpc.rsp = &responses; |
---|
1442 | |
---|
1443 | // set input arguments in RPC descriptor |
---|
1444 | rpc.args[0] = (uint64_t)type; |
---|
1445 | rpc.args[1] = (uint64_t)(intptr_t)name; |
---|
1446 | |
---|
1447 | // register RPC request in remote RPC fifo |
---|
1448 | rpc_send( cxy , &rpc ); |
---|
1449 | |
---|
1450 | // get output values from RPC descriptor |
---|
1451 | *dentry_xp = (xptr_t)rpc.args[2]; |
---|
1452 | *error = (error_t)rpc.args[3]; |
---|
1453 | |
---|
1454 | #if DEBUG_RPC_VFS_DENTRY_CREATE |
---|
1455 | cycle = (uint32_t)hal_get_cycles(); |
---|
1456 | if( cycle > DEBUG_RPC_VFS_DENTRY_CREATE ) |
---|
1457 | printk("\n[%s] thread[%x,%x] on core %d exit / cycle %d\n", |
---|
1458 | __FUNCTION__, this->process->pid, this->trdid, this->core->lid, cycle ); |
---|
1459 | #endif |
---|
1460 | } |
---|
1461 | |
---|
1462 | ////////////////////////////////////////////// |
---|
1463 | void rpc_vfs_dentry_create_server( xptr_t xp ) |
---|
1464 | { |
---|
1465 | #if DEBUG_RPC_VFS_DENTRY_CREATE |
---|
1466 | thread_t * this = CURRENT_THREAD; |
---|
1467 | uint32_t cycle = (uint32_t)hal_get_cycles(); |
---|
1468 | if( cycle > DEBUG_RPC_VFS_DENTRY_CREATE ) |
---|
1469 | printk("\n[%s] thread[%x,%x] on core %d enter / cycle %d\n", |
---|
1470 | __FUNCTION__, this->process->pid, this->trdid, this->core->lid , cycle ); |
---|
1471 | #endif |
---|
1472 | |
---|
1473 | uint32_t type; |
---|
1474 | char * name; |
---|
1475 | xptr_t dentry_xp; |
---|
1476 | error_t error; |
---|
1477 | char name_copy[CONFIG_VFS_MAX_NAME_LENGTH]; |
---|
1478 | |
---|
1479 | // get client cluster identifier and pointer on RPC descriptor |
---|
1480 | cxy_t client_cxy = GET_CXY( xp ); |
---|
1481 | rpc_desc_t * desc = GET_PTR( xp ); |
---|
1482 | |
---|
1483 | // get arguments "name", "type", and "parent" from client RPC descriptor |
---|
1484 | type = (uint32_t) hal_remote_l64( XPTR( client_cxy , &desc->args[0] ) ); |
---|
1485 | name = (char *)(intptr_t) hal_remote_l64( XPTR( client_cxy , &desc->args[1] ) ); |
---|
1486 | |
---|
1487 | // makes a local copy of name |
---|
1488 | hal_remote_strcpy( XPTR( local_cxy , name_copy ), |
---|
1489 | XPTR( client_cxy , name ) ); |
---|
1490 | |
---|
1491 | // call local kernel function |
---|
1492 | error = vfs_dentry_create( type, |
---|
1493 | name_copy, |
---|
1494 | &dentry_xp ); |
---|
1495 | // set output arguments |
---|
1496 | hal_remote_s64( XPTR( client_cxy , &desc->args[2] ) , (uint64_t)dentry_xp ); |
---|
1497 | hal_remote_s64( XPTR( client_cxy , &desc->args[3] ) , (uint64_t)error ); |
---|
1498 | |
---|
1499 | #if DEBUG_RPC_VFS_DENTRY_CREATE |
---|
1500 | cycle = (uint32_t)hal_get_cycles(); |
---|
1501 | if( cycle > DEBUG_RPC_VFS_DENTRY_CREATE ) |
---|
1502 | printk("\n[%s] thread[%x,%x] on core %d exit / cycle %d\n", |
---|
1503 | __FUNCTION__, this->process->pid, this->trdid, this->core->lid, cycle ); |
---|
1504 | #endif |
---|
1505 | } |
---|
1506 | |
---|
1507 | ///////////////////////////////////////////////////////////////////////////////////////// |
---|
1508 | // [13] Marshaling functions attached to RPC_VFS_DENTRY_DESTROY |
---|
1509 | ///////////////////////////////////////////////////////////////////////////////////////// |
---|
1510 | |
---|
1511 | /////////////////////////////////////////////////////// |
---|
1512 | void rpc_vfs_dentry_destroy_client( cxy_t cxy, |
---|
1513 | vfs_dentry_t * dentry ) |
---|
1514 | { |
---|
1515 | #if DEBUG_RPC_VFS_DENTRY_DESTROY |
---|
1516 | thread_t * this = CURRENT_THREAD; |
---|
1517 | uint32_t cycle = (uint32_t)hal_get_cycles(); |
---|
1518 | if( cycle > DEBUG_RPC_VFS_DENTRY_DESTROY ) |
---|
1519 | printk("\n[%s] thread[%x,%x] on core %d enter / cycle %d\n", |
---|
1520 | __FUNCTION__, this->process->pid, this->trdid, this->core->lid , cycle ); |
---|
1521 | #endif |
---|
1522 | |
---|
1523 | uint32_t responses = 1; |
---|
1524 | |
---|
1525 | // initialise RPC descriptor header |
---|
1526 | rpc_desc_t rpc; |
---|
1527 | rpc.index = RPC_VFS_DENTRY_DESTROY; |
---|
1528 | rpc.blocking = true; |
---|
1529 | rpc.rsp = &responses; |
---|
1530 | |
---|
1531 | // set input arguments in RPC descriptor |
---|
1532 | rpc.args[0] = (uint64_t)(intptr_t)dentry; |
---|
1533 | |
---|
1534 | // register RPC request in remote RPC fifo |
---|
1535 | rpc_send( cxy , &rpc ); |
---|
1536 | |
---|
1537 | #if DEBUG_RPC_VFS_DENTRY_DESTROY |
---|
1538 | cycle = (uint32_t)hal_get_cycles(); |
---|
1539 | if( cycle > DEBUG_RPC_VFS_DENTRY_DESTROY ) |
---|
1540 | printk("\n[%s] thread[%x,%x] on core %d exit / cycle %d\n", |
---|
1541 | __FUNCTION__, this->process->pid, this->trdid, this->core->lid, cycle ); |
---|
1542 | #endif |
---|
1543 | } |
---|
1544 | |
---|
1545 | /////////////////////////////////////////////// |
---|
1546 | void rpc_vfs_dentry_destroy_server( xptr_t xp ) |
---|
1547 | { |
---|
1548 | #if DEBUG_RPC_VFS_DENTRY_DESTROY |
---|
1549 | thread_t * this = CURRENT_THREAD; |
---|
1550 | uint32_t cycle = (uint32_t)hal_get_cycles(); |
---|
1551 | if( cycle > DEBUG_RPC_VFS_DENTRY_DESTROY ) |
---|
1552 | printk("\n[%s] thread[%x,%x] on core %d enter / cycle %d\n", |
---|
1553 | __FUNCTION__, this->process->pid, this->trdid, this->core->lid , cycle ); |
---|
1554 | #endif |
---|
1555 | |
---|
1556 | vfs_dentry_t * dentry; |
---|
1557 | |
---|
1558 | // get client cluster identifier and pointer on RPC descriptor |
---|
1559 | cxy_t client_cxy = GET_CXY( xp ); |
---|
1560 | rpc_desc_t * desc = GET_PTR( xp ); |
---|
1561 | |
---|
1562 | // get arguments "dentry" from client RPC descriptor |
---|
1563 | dentry = (vfs_dentry_t *)(intptr_t)hal_remote_l64( XPTR( client_cxy , &desc->args[0] ) ); |
---|
1564 | |
---|
1565 | // call local kernel function |
---|
1566 | vfs_dentry_destroy( dentry ); |
---|
1567 | |
---|
1568 | #if DEBUG_RPC_VFS_DENTRY_DESTROY |
---|
1569 | cycle = (uint32_t)hal_get_cycles(); |
---|
1570 | if( cycle > DEBUG_RPC_VFS_DENTRY_DESTROY ) |
---|
1571 | printk("\n[%s] thread[%x,%x] on core %d exit / cycle %d\n", |
---|
1572 | __FUNCTION__, this->process->pid, this->trdid, this->core->lid, cycle ); |
---|
1573 | #endif |
---|
1574 | } |
---|
1575 | |
---|
1576 | |
---|
1577 | ///////////////////////////////////////////////////////////////////////////////////////// |
---|
1578 | // [14] Marshaling functions attached to RPC_VFS_FILE_CREATE |
---|
1579 | ///////////////////////////////////////////////////////////////////////////////////////// |
---|
1580 | |
---|
1581 | ////////////////////////////////////////////////////////////// |
---|
1582 | void rpc_vfs_file_create_client( cxy_t cxy, |
---|
1583 | struct vfs_inode_s * inode, // in |
---|
1584 | uint32_t file_attr, // in |
---|
1585 | xptr_t * file_xp, // out |
---|
1586 | error_t * error ) // out |
---|
1587 | { |
---|
1588 | #if DEBUG_RPC_VFS_FILE_CREATE |
---|
1589 | thread_t * this = CURRENT_THREAD; |
---|
1590 | uint32_t cycle = (uint32_t)hal_get_cycles(); |
---|
1591 | if( cycle > DEBUG_RPC_VFS_FILE_CREATE ) |
---|
1592 | printk("\n[%s] thread[%x,%x] on core %d enter / cycle %d\n", |
---|
1593 | __FUNCTION__, this->process->pid, this->trdid, this->core->lid , cycle ); |
---|
1594 | #endif |
---|
1595 | |
---|
1596 | uint32_t responses = 1; |
---|
1597 | |
---|
1598 | // initialise RPC descriptor header |
---|
1599 | rpc_desc_t rpc; |
---|
1600 | rpc.index = RPC_VFS_FILE_CREATE; |
---|
1601 | rpc.blocking = true; |
---|
1602 | rpc.rsp = &responses; |
---|
1603 | |
---|
1604 | // set input arguments in RPC descriptor |
---|
1605 | rpc.args[0] = (uint64_t)(intptr_t)inode; |
---|
1606 | rpc.args[1] = (uint64_t)file_attr; |
---|
1607 | |
---|
1608 | // register RPC request in remote RPC fifo |
---|
1609 | rpc_send( cxy , &rpc ); |
---|
1610 | |
---|
1611 | // get output values from RPC descriptor |
---|
1612 | *file_xp = (xptr_t)rpc.args[2]; |
---|
1613 | *error = (error_t)rpc.args[3]; |
---|
1614 | |
---|
1615 | #if DEBUG_RPC_VFS_FILE_CREATE |
---|
1616 | cycle = (uint32_t)hal_get_cycles(); |
---|
1617 | if( cycle > DEBUG_RPC_VFS_FILE_CREATE ) |
---|
1618 | printk("\n[%s] thread[%x,%x] on core %d exit / cycle %d\n", |
---|
1619 | __FUNCTION__, this->process->pid, this->trdid, this->core->lid, cycle ); |
---|
1620 | #endif |
---|
1621 | } |
---|
1622 | |
---|
1623 | //////////////////////////////////////////// |
---|
1624 | void rpc_vfs_file_create_server( xptr_t xp ) |
---|
1625 | { |
---|
1626 | #if DEBUG_RPC_VFS_FILE_CREATE |
---|
1627 | thread_t * this = CURRENT_THREAD; |
---|
1628 | uint32_t cycle = (uint32_t)hal_get_cycles(); |
---|
1629 | if( cycle > DEBUG_RPC_VFS_FILE_CREATE ) |
---|
1630 | printk("\n[%s] thread[%x,%x] on core %d enter / cycle %d\n", |
---|
1631 | __FUNCTION__, this->process->pid, this->trdid, this->core->lid , cycle ); |
---|
1632 | #endif |
---|
1633 | |
---|
1634 | uint32_t file_attr; |
---|
1635 | vfs_inode_t * inode; |
---|
1636 | xptr_t file_xp; |
---|
1637 | error_t error; |
---|
1638 | |
---|
1639 | // get client cluster identifier and pointer on RPC descriptor |
---|
1640 | cxy_t client_cxy = GET_CXY( xp ); |
---|
1641 | rpc_desc_t * desc = GET_PTR( xp ); |
---|
1642 | |
---|
1643 | // get arguments "file_attr" and "inode" from client RPC descriptor |
---|
1644 | inode = (vfs_inode_t *)(intptr_t)hal_remote_l64( XPTR( client_cxy , &desc->args[0] ) ); |
---|
1645 | file_attr = (uint32_t) hal_remote_l64( XPTR( client_cxy , &desc->args[1] ) ); |
---|
1646 | |
---|
1647 | // call local kernel function |
---|
1648 | error = vfs_file_create( inode, |
---|
1649 | file_attr, |
---|
1650 | &file_xp ); |
---|
1651 | |
---|
1652 | // set output arguments |
---|
1653 | hal_remote_s64( XPTR( client_cxy , &desc->args[2] ) , (uint64_t)file_xp ); |
---|
1654 | hal_remote_s64( XPTR( client_cxy , &desc->args[3] ) , (uint64_t)error ); |
---|
1655 | |
---|
1656 | #if DEBUG_RPC_VFS_FILE_CREATE |
---|
1657 | cycle = (uint32_t)hal_get_cycles(); |
---|
1658 | if( cycle > DEBUG_RPC_VFS_FILE_CREATE ) |
---|
1659 | printk("\n[%s] thread[%x,%x] on core %d exit / cycle %d\n", |
---|
1660 | __FUNCTION__, this->process->pid, this->trdid, this->core->lid, cycle ); |
---|
1661 | #endif |
---|
1662 | } |
---|
1663 | |
---|
1664 | ///////////////////////////////////////////////////////////////////////////////////////// |
---|
1665 | // [15] Marshaling functions attached to RPC_VFS_FILE_DESTROY |
---|
1666 | ///////////////////////////////////////////////////////////////////////////////////////// |
---|
1667 | |
---|
1668 | /////////////////////////////////////////////////// |
---|
1669 | void rpc_vfs_file_destroy_client( cxy_t cxy, |
---|
1670 | vfs_file_t * file ) |
---|
1671 | { |
---|
1672 | #if DEBUG_RPC_VFS_FILE_DESTROY |
---|
1673 | thread_t * this = CURRENT_THREAD; |
---|
1674 | uint32_t cycle = (uint32_t)hal_get_cycles(); |
---|
1675 | if( cycle > DEBUG_RPC_VFS_FILE_DESTROY ) |
---|
1676 | printk("\n[%s] thread[%x,%x] on core %d enter / cycle %d\n", |
---|
1677 | __FUNCTION__, this->process->pid, this->trdid, this->core->lid , cycle ); |
---|
1678 | #endif |
---|
1679 | |
---|
1680 | uint32_t responses = 1; |
---|
1681 | |
---|
1682 | // initialise RPC descriptor header |
---|
1683 | rpc_desc_t rpc; |
---|
1684 | rpc.index = RPC_VFS_FILE_DESTROY; |
---|
1685 | rpc.blocking = true; |
---|
1686 | rpc.rsp = &responses; |
---|
1687 | |
---|
1688 | // set input arguments in RPC descriptor |
---|
1689 | rpc.args[0] = (uint64_t)(intptr_t)file; |
---|
1690 | |
---|
1691 | // register RPC request in remote RPC fifo |
---|
1692 | rpc_send( cxy , &rpc ); |
---|
1693 | |
---|
1694 | #if DEBUG_RPC_VFS_FILE_DESTROY |
---|
1695 | cycle = (uint32_t)hal_get_cycles(); |
---|
1696 | if( cycle > DEBUG_RPC_VFS_FILE_DESTROY ) |
---|
1697 | printk("\n[%s] thread[%x,%x] on core %d exit / cycle %d\n", |
---|
1698 | __FUNCTION__, this->process->pid, this->trdid, this->core->lid, cycle ); |
---|
1699 | #endif |
---|
1700 | } |
---|
1701 | |
---|
1702 | ///////////////////////////////////////////// |
---|
1703 | void rpc_vfs_file_destroy_server( xptr_t xp ) |
---|
1704 | { |
---|
1705 | #if DEBUG_RPC_VFS_FILE_DESTROY |
---|
1706 | thread_t * this = CURRENT_THREAD; |
---|
1707 | uint32_t cycle = (uint32_t)hal_get_cycles(); |
---|
1708 | if( cycle > DEBUG_RPC_VFS_FILE_DESTROY ) |
---|
1709 | printk("\n[%s] thread[%x,%x] on core %d enter / cycle %d\n", |
---|
1710 | __FUNCTION__, this->process->pid, this->trdid, this->core->lid , cycle ); |
---|
1711 | #endif |
---|
1712 | |
---|
1713 | vfs_file_t * file; |
---|
1714 | |
---|
1715 | // get client cluster identifier and pointer on RPC descriptor |
---|
1716 | cxy_t client_cxy = GET_CXY( xp ); |
---|
1717 | rpc_desc_t * desc = GET_PTR( xp ); |
---|
1718 | |
---|
1719 | // get arguments "dentry" from client RPC descriptor |
---|
1720 | file = (vfs_file_t *)(intptr_t)hal_remote_l64( XPTR( client_cxy , &desc->args[0] ) ); |
---|
1721 | |
---|
1722 | // call local kernel function |
---|
1723 | vfs_file_destroy( file ); |
---|
1724 | |
---|
1725 | #if DEBUG_RPC_VFS_FILE_DESTROY |
---|
1726 | cycle = (uint32_t)hal_get_cycles(); |
---|
1727 | if( cycle > DEBUG_RPC_VFS_FILE_DESTROY ) |
---|
1728 | printk("\n[%s] thread[%x,%x] on core %d exit / cycle %d\n", |
---|
1729 | __FUNCTION__, this->process->pid, this->trdid, this->core->lid, cycle ); |
---|
1730 | #endif |
---|
1731 | } |
---|
1732 | |
---|
1733 | ///////////////////////////////////////////////////////////////////////////////////////// |
---|
1734 | // [16] Marshaling functions attached to RPC_VFS_FS_GET_DENTRY |
---|
1735 | ///////////////////////////////////////////////////////////////////////////////////////// |
---|
1736 | |
---|
1737 | ///////////////////////////////////////////////////////// |
---|
1738 | void rpc_vfs_fs_new_dentry_client( cxy_t cxy, |
---|
1739 | vfs_inode_t * parent_inode, // in |
---|
1740 | char * name, // in |
---|
1741 | xptr_t child_inode_xp, // in |
---|
1742 | error_t * error ) // out |
---|
1743 | { |
---|
1744 | #if DEBUG_RPC_VFS_FS_NEW_DENTRY |
---|
1745 | thread_t * this = CURRENT_THREAD; |
---|
1746 | uint32_t cycle = (uint32_t)hal_get_cycles(); |
---|
1747 | if( cycle > DEBUG_RPC_VFS_FS_NEW_DENTRY ) |
---|
1748 | printk("\n[%s] thread[%x,%x] on core %d enter / cycle %d\n", |
---|
1749 | __FUNCTION__, this->process->pid, this->trdid, this->core->lid , cycle ); |
---|
1750 | #endif |
---|
1751 | |
---|
1752 | uint32_t responses = 1; |
---|
1753 | |
---|
1754 | // initialise RPC descriptor header |
---|
1755 | rpc_desc_t rpc; |
---|
1756 | rpc.index = RPC_VFS_FS_NEW_DENTRY; |
---|
1757 | rpc.blocking = true; |
---|
1758 | rpc.rsp = &responses; |
---|
1759 | |
---|
1760 | // set input arguments in RPC descriptor |
---|
1761 | rpc.args[0] = (uint64_t)(intptr_t)parent_inode; |
---|
1762 | rpc.args[1] = (uint64_t)(intptr_t)name; |
---|
1763 | rpc.args[2] = (uint64_t)child_inode_xp; |
---|
1764 | |
---|
1765 | // register RPC request in remote RPC fifo |
---|
1766 | rpc_send( cxy , &rpc ); |
---|
1767 | |
---|
1768 | // get output values from RPC descriptor |
---|
1769 | *error = (error_t)rpc.args[3]; |
---|
1770 | |
---|
1771 | #if DEBUG_RPC_VFS_FS_NEW_DENTRY |
---|
1772 | cycle = (uint32_t)hal_get_cycles(); |
---|
1773 | if( cycle > DEBUG_RPC_VFS_FS_NEW_DENTRY ) |
---|
1774 | printk("\n[%s] thread[%x,%x] on core %d exit / cycle %d\n", |
---|
1775 | __FUNCTION__, this->process->pid, this->trdid, this->core->lid , cycle ); |
---|
1776 | #endif |
---|
1777 | } |
---|
1778 | |
---|
1779 | ////////////////////////////////////////////// |
---|
1780 | void rpc_vfs_fs_new_dentry_server( xptr_t xp ) |
---|
1781 | { |
---|
1782 | #if DEBUG_RPC_VFS_FS_NEW_DENTRY |
---|
1783 | thread_t * this = CURRENT_THREAD; |
---|
1784 | uint32_t cycle = (uint32_t)hal_get_cycles(); |
---|
1785 | if( cycle > DEBUG_RPC_VFS_FS_NEW_DENTRY ) |
---|
1786 | printk("\n[%s] thread[%x,%x] on core %d enter / cycle %d\n", |
---|
1787 | __FUNCTION__, this->process->pid, this->trdid, this->core->lid , cycle ); |
---|
1788 | #endif |
---|
1789 | |
---|
1790 | error_t error; |
---|
1791 | vfs_inode_t * parent; |
---|
1792 | xptr_t child_xp; |
---|
1793 | char * name; |
---|
1794 | |
---|
1795 | char name_copy[CONFIG_VFS_MAX_NAME_LENGTH]; |
---|
1796 | |
---|
1797 | // get client cluster identifier and pointer on RPC descriptor |
---|
1798 | cxy_t client_cxy = GET_CXY( xp ); |
---|
1799 | rpc_desc_t * desc = GET_PTR( xp ); |
---|
1800 | |
---|
1801 | // get arguments "parent", "name", and "child_xp" |
---|
1802 | parent = (vfs_inode_t*)(intptr_t)hal_remote_l64(XPTR(client_cxy , &desc->args[0])); |
---|
1803 | name = (char*)(intptr_t) hal_remote_l64(XPTR(client_cxy , &desc->args[1])); |
---|
1804 | child_xp = (xptr_t) hal_remote_l64(XPTR(client_cxy , &desc->args[2])); |
---|
1805 | |
---|
1806 | // get name local copy |
---|
1807 | hal_remote_strcpy( XPTR( local_cxy , name_copy ) , |
---|
1808 | XPTR( client_cxy , name ) ); |
---|
1809 | |
---|
1810 | // call the kernel function |
---|
1811 | error = vfs_fs_new_dentry( parent , name_copy , child_xp ); |
---|
1812 | |
---|
1813 | // set output argument |
---|
1814 | hal_remote_s64( XPTR( client_cxy , &desc->args[3] ) , (uint64_t)error ); |
---|
1815 | |
---|
1816 | #if DEBUG_RPC_VFS_FS_NEW_DENTRY |
---|
1817 | cycle = (uint32_t)hal_get_cycles(); |
---|
1818 | if( cycle > DEBUG_RPC_VFS_FS_NEW_DENTRY ) |
---|
1819 | printk("\n[%s] thread[%x,%x] on core %d exit / cycle %d\n", |
---|
1820 | __FUNCTION__, this->process->pid, this->trdid, this->core->lid , cycle ); |
---|
1821 | #endif |
---|
1822 | } |
---|
1823 | |
---|
1824 | ///////////////////////////////////////////////////////////////////////////////////////// |
---|
1825 | // [17] Marshaling function attached to RPC_VFS_FS_ADD_DENTRY |
---|
1826 | ///////////////////////////////////////////////////////////////////////////////////////// |
---|
1827 | |
---|
1828 | void rpc_vfs_fs_add_dentry_client( cxy_t cxy, |
---|
1829 | vfs_inode_t * parent, // in |
---|
1830 | vfs_dentry_t * dentry, // in |
---|
1831 | error_t * error ) // out |
---|
1832 | { |
---|
1833 | #if DEBUG_RPC_VFS_FS_ADD_DENTRY |
---|
1834 | thread_t * this = CURRENT_THREAD; |
---|
1835 | uint32_t cycle = (uint32_t)hal_get_cycles(); |
---|
1836 | if( cycle > DEBUG_RPC_VFS_FS_ADD_DENTRY ) |
---|
1837 | printk("\n[%s] thread[%x,%x] on core %d enter / cycle %d\n", |
---|
1838 | __FUNCTION__, this->process->pid, this->trdid, this->core->lid , cycle ); |
---|
1839 | #endif |
---|
1840 | |
---|
1841 | uint32_t responses = 1; |
---|
1842 | |
---|
1843 | // initialise RPC descriptor header |
---|
1844 | rpc_desc_t rpc; |
---|
1845 | rpc.index = RPC_VFS_FS_ADD_DENTRY; |
---|
1846 | rpc.blocking = true; |
---|
1847 | rpc.rsp = &responses; |
---|
1848 | |
---|
1849 | // set input arguments in RPC descriptor |
---|
1850 | rpc.args[0] = (uint64_t)(intptr_t)parent; |
---|
1851 | rpc.args[1] = (uint64_t)(intptr_t)dentry; |
---|
1852 | |
---|
1853 | // register RPC request in remote RPC fifo |
---|
1854 | rpc_send( cxy , &rpc ); |
---|
1855 | |
---|
1856 | // get output values from RPC descriptor |
---|
1857 | *error = (error_t)rpc.args[2]; |
---|
1858 | |
---|
1859 | #if DEBUG_RPC_VFS_FS_ADD_DENTRY |
---|
1860 | cycle = (uint32_t)hal_get_cycles(); |
---|
1861 | if( cycle > DEBUG_RPC_VFS_FS_ADD_DENTRY ) |
---|
1862 | printk("\n[%s] thread[%x,%x] on core %d exit / cycle %d\n", |
---|
1863 | __FUNCTION__, this->process->pid, this->trdid, this->core->lid , cycle ); |
---|
1864 | #endif |
---|
1865 | } |
---|
1866 | |
---|
1867 | ////////////////////////////////////////////// |
---|
1868 | void rpc_vfs_fs_add_dentry_server( xptr_t xp ) |
---|
1869 | { |
---|
1870 | #if DEBUG_RPC_VFS_FS_ADD_DENTRY |
---|
1871 | thread_t * this = CURRENT_THREAD; |
---|
1872 | uint32_t cycle = (uint32_t)hal_get_cycles(); |
---|
1873 | if( cycle > DEBUG_RPC_VFS_FS_ADD_DENTRY ) |
---|
1874 | printk("\n[%s] thread[%x,%x] on core %d enter / cycle %d\n", |
---|
1875 | __FUNCTION__, this->process->pid, this->trdid, this->core->lid , cycle ); |
---|
1876 | #endif |
---|
1877 | |
---|
1878 | error_t error; |
---|
1879 | vfs_inode_t * parent; |
---|
1880 | vfs_dentry_t * dentry; |
---|
1881 | |
---|
1882 | // get client cluster identifier and pointer on RPC descriptor |
---|
1883 | cxy_t client_cxy = GET_CXY( xp ); |
---|
1884 | rpc_desc_t * desc = GET_PTR( xp ); |
---|
1885 | |
---|
1886 | // get input arguments |
---|
1887 | parent = (vfs_inode_t*)(intptr_t) hal_remote_l64(XPTR(client_cxy , &desc->args[0])); |
---|
1888 | dentry = (vfs_dentry_t*)(intptr_t)hal_remote_l64(XPTR(client_cxy , &desc->args[1])); |
---|
1889 | |
---|
1890 | // call the kernel function |
---|
1891 | error = vfs_fs_add_dentry( parent , dentry ); |
---|
1892 | |
---|
1893 | // set output argument |
---|
1894 | hal_remote_s64( XPTR( client_cxy , &desc->args[2] ) , (uint64_t)error ); |
---|
1895 | |
---|
1896 | #if DEBUG_RPC_VFS_FS_ADD_DENTRY |
---|
1897 | cycle = (uint32_t)hal_get_cycles(); |
---|
1898 | if( cycle > DEBUG_RPC_VFS_FS_ADD_DENTRY ) |
---|
1899 | printk("\n[%s] thread[%x,%x] on core %d exit / cycle %d\n", |
---|
1900 | __FUNCTION__, this->process->pid, this->trdid, this->core->lid , cycle ); |
---|
1901 | #endif |
---|
1902 | } |
---|
1903 | |
---|
1904 | ///////////////////////////////////////////////////////////////////////////////////////// |
---|
1905 | // [18] Marshaling function attached to RPC_VFS_FS_REMOVE_DENTRY |
---|
1906 | ///////////////////////////////////////////////////////////////////////////////////////// |
---|
1907 | |
---|
1908 | void rpc_vfs_fs_remove_dentry_client( cxy_t cxy, |
---|
1909 | vfs_inode_t * parent, // in |
---|
1910 | vfs_dentry_t * dentry, // in |
---|
1911 | error_t * error ) // out |
---|
1912 | { |
---|
1913 | #if DEBUG_RPC_VFS_FS_REMOVE_DENTRY |
---|
1914 | thread_t * this = CURRENT_THREAD; |
---|
1915 | uint32_t cycle = (uint32_t)hal_get_cycles(); |
---|
1916 | if( cycle > DEBUG_RPC_VFS_FS_REMOVE_DENTRY ) |
---|
1917 | printk("\n[%s] thread[%x,%x] on core %d enter / cycle %d\n", |
---|
1918 | __FUNCTION__, this->process->pid, this->trdid, this->core->lid , cycle ); |
---|
1919 | #endif |
---|
1920 | |
---|
1921 | uint32_t responses = 1; |
---|
1922 | |
---|
1923 | // initialise RPC descriptor header |
---|
1924 | rpc_desc_t rpc; |
---|
1925 | rpc.index = RPC_VFS_FS_REMOVE_DENTRY; |
---|
1926 | rpc.blocking = true; |
---|
1927 | rpc.rsp = &responses; |
---|
1928 | |
---|
1929 | // set input arguments in RPC descriptor |
---|
1930 | rpc.args[0] = (uint64_t)(intptr_t)parent; |
---|
1931 | rpc.args[1] = (uint64_t)(intptr_t)dentry; |
---|
1932 | |
---|
1933 | // register RPC request in remote RPC fifo |
---|
1934 | rpc_send( cxy , &rpc ); |
---|
1935 | |
---|
1936 | // get output values from RPC descriptor |
---|
1937 | *error = (error_t)rpc.args[2]; |
---|
1938 | |
---|
1939 | #if DEBUG_RPC_VFS_FS_REMOVE_DENTRY |
---|
1940 | cycle = (uint32_t)hal_get_cycles(); |
---|
1941 | if( cycle > DEBUG_RPC_VFS_FS_REMOVE_DENTRY ) |
---|
1942 | printk("\n[%s] thread[%x,%x] on core %d exit / cycle %d\n", |
---|
1943 | __FUNCTION__, this->process->pid, this->trdid, this->core->lid , cycle ); |
---|
1944 | #endif |
---|
1945 | } |
---|
1946 | |
---|
1947 | ///////////////////////////////////////////////// |
---|
1948 | void rpc_vfs_fs_remove_dentry_server( xptr_t xp ) |
---|
1949 | { |
---|
1950 | #if DEBUG_RPC_VFS_FS_REMOVE_DENTRY |
---|
1951 | thread_t * this = CURRENT_THREAD; |
---|
1952 | uint32_t cycle = (uint32_t)hal_get_cycles(); |
---|
1953 | if( cycle > DEBUG_RPC_VFS_FS_REMOVE_DENTRY ) |
---|
1954 | printk("\n[%s] thread[%x,%x] on core %d enter / cycle %d\n", |
---|
1955 | __FUNCTION__, this->process->pid, this->trdid, this->core->lid , cycle ); |
---|
1956 | #endif |
---|
1957 | |
---|
1958 | error_t error; |
---|
1959 | vfs_inode_t * parent; |
---|
1960 | vfs_dentry_t * dentry; |
---|
1961 | |
---|
1962 | // get client cluster identifier and pointer on RPC descriptor |
---|
1963 | cxy_t client_cxy = GET_CXY( xp ); |
---|
1964 | rpc_desc_t * desc = GET_PTR( xp ); |
---|
1965 | |
---|
1966 | // get input arguments |
---|
1967 | parent = (vfs_inode_t*)(intptr_t) hal_remote_l64(XPTR(client_cxy , &desc->args[0])); |
---|
1968 | dentry = (vfs_dentry_t*)(intptr_t)hal_remote_l64(XPTR(client_cxy , &desc->args[1])); |
---|
1969 | |
---|
1970 | // call the kernel function |
---|
1971 | error = vfs_fs_remove_dentry( parent , dentry ); |
---|
1972 | |
---|
1973 | // set output argument |
---|
1974 | hal_remote_s64( XPTR( client_cxy , &desc->args[2] ) , (uint64_t)error ); |
---|
1975 | |
---|
1976 | #if DEBUG_RPC_VFS_FS_REMOVE_DENTRY |
---|
1977 | cycle = (uint32_t)hal_get_cycles(); |
---|
1978 | if( cycle > DEBUG_RPC_VFS_FS_REMOVE_DENTRY ) |
---|
1979 | printk("\n[%s] thread[%x,%x] on core %d exit / cycle %d\n", |
---|
1980 | __FUNCTION__, this->process->pid, this->trdid, this->core->lid , cycle ); |
---|
1981 | #endif |
---|
1982 | } |
---|
1983 | |
---|
1984 | ///////////////////////////////////////////////////////////////////////////////////////// |
---|
1985 | // [19] Marshaling functions attached to RPC_VFS_INODE_LOAD_ALL_PAGES |
---|
1986 | ///////////////////////////////////////////////////////////////////////////////////////// |
---|
1987 | |
---|
1988 | //////////////////////////////////////////////////////////// |
---|
1989 | void rpc_vfs_inode_load_all_pages_client( cxy_t cxy, |
---|
1990 | vfs_inode_t * inode, // in |
---|
1991 | error_t * error ) // out |
---|
1992 | { |
---|
1993 | #if DEBUG_RPC_VFS_INODE_LOAD_ALL_PAGES |
---|
1994 | thread_t * this = CURRENT_THREAD; |
---|
1995 | uint32_t cycle = (uint32_t)hal_get_cycles(); |
---|
1996 | if( cycle > DEBUG_RPC_VFS_INODE_LOAD_ALL_PAGES ) |
---|
1997 | printk("\n[%s] thread[%x,%x] on core %d enter / cycle %d\n", |
---|
1998 | __FUNCTION__, this->process->pid, this->trdid, this->core->lid , cycle ); |
---|
1999 | #endif |
---|
2000 | |
---|
2001 | uint32_t responses = 1; |
---|
2002 | |
---|
2003 | // initialise RPC descriptor header |
---|
2004 | rpc_desc_t rpc; |
---|
2005 | rpc.index = RPC_VFS_INODE_LOAD_ALL_PAGES; |
---|
2006 | rpc.blocking = true; |
---|
2007 | rpc.rsp = &responses; |
---|
2008 | |
---|
2009 | // set input arguments in RPC descriptor |
---|
2010 | rpc.args[0] = (uint64_t)(intptr_t)inode; |
---|
2011 | |
---|
2012 | // register RPC request in remote RPC fifo |
---|
2013 | rpc_send( cxy , &rpc ); |
---|
2014 | |
---|
2015 | // get output values from RPC descriptor |
---|
2016 | *error = (error_t)rpc.args[1]; |
---|
2017 | |
---|
2018 | #if DEBUG_RPC_VFS_INODE_LOAD_ALL_PAGES |
---|
2019 | cycle = (uint32_t)hal_get_cycles(); |
---|
2020 | if( cycle > DEBUG_RPC_VFS_INODE_LOAD_ALL_PAGES ) |
---|
2021 | printk("\n[%s] thread[%x,%x] on core %d exit / cycle %d\n", |
---|
2022 | __FUNCTION__, this->process->pid, this->trdid, this->core->lid , cycle ); |
---|
2023 | #endif |
---|
2024 | } |
---|
2025 | |
---|
2026 | ///////////////////////////////////////////////////// |
---|
2027 | void rpc_vfs_inode_load_all_pages_server( xptr_t xp ) |
---|
2028 | { |
---|
2029 | #if DEBUG_RPC_VFS_INODE_LOAD_ALL_PAGES |
---|
2030 | thread_t * this = CURRENT_THREAD; |
---|
2031 | uint32_t cycle = (uint32_t)hal_get_cycles(); |
---|
2032 | if( cycle > DEBUG_RPC_VFS_INODE_LOAD_ALL_PAGES ) |
---|
2033 | printk("\n[%s] thread[%x,%x] on core %d enter / cycle %d\n", |
---|
2034 | __FUNCTION__, this->process->pid, this->trdid, this->core->lid , cycle ); |
---|
2035 | #endif |
---|
2036 | |
---|
2037 | error_t error; |
---|
2038 | vfs_inode_t * inode; |
---|
2039 | |
---|
2040 | // get client cluster identifier and pointer on RPC descriptor |
---|
2041 | cxy_t client_cxy = GET_CXY( xp ); |
---|
2042 | rpc_desc_t * desc = GET_PTR( xp ); |
---|
2043 | |
---|
2044 | // get input argument |
---|
2045 | inode = (vfs_inode_t*)(intptr_t)hal_remote_l64(XPTR(client_cxy , &desc->args[0])); |
---|
2046 | |
---|
2047 | // call the kernel function |
---|
2048 | error = vfs_inode_load_all_pages( inode ); |
---|
2049 | |
---|
2050 | // set output argument |
---|
2051 | hal_remote_s64( XPTR( client_cxy , &desc->args[1] ) , (uint64_t)error ); |
---|
2052 | |
---|
2053 | #if DEBUG_RPC_VFS_INODE_LOAD_ALL_PAGES |
---|
2054 | cycle = (uint32_t)hal_get_cycles(); |
---|
2055 | if( cycle > DEBUG_RPC_VFS_INODE_LOAD_ALL_PAGES ) |
---|
2056 | printk("\n[%s] thread[%x,%x] on core %d exit / cycle %d\n", |
---|
2057 | __FUNCTION__, this->process->pid, this->trdid, this->core->lid , cycle ); |
---|
2058 | #endif |
---|
2059 | } |
---|
2060 | |
---|
2061 | ///////////////////////////////////////////////////////////////////////////////////////// |
---|
2062 | // [20] RPC_VMM_GET_VSEG deprecated [AG] sept 2019 |
---|
2063 | ///////////////////////////////////////////////////////////////////////////////////////// |
---|
2064 | |
---|
2065 | /* |
---|
2066 | ////////////////////////////////////////////////// |
---|
2067 | void rpc_vmm_get_vseg_client( cxy_t cxy, |
---|
2068 | process_t * process, // in |
---|
2069 | intptr_t vaddr, // in |
---|
2070 | xptr_t * vseg_xp, // out |
---|
2071 | error_t * error ) // out |
---|
2072 | { |
---|
2073 | #if DEBUG_RPC_VMM_GET_VSEG |
---|
2074 | thread_t * this = CURRENT_THREAD; |
---|
2075 | uint32_t cycle = (uint32_t)hal_get_cycles(); |
---|
2076 | if( cycle > DEBUG_RPC_VMM_GET_VSEG ) |
---|
2077 | printk("\n[%s] thread[%x,%x] on core %d enter / cycle %d\n", |
---|
2078 | __FUNCTION__, this->process->pid, this->trdid, this->core->lid , cycle ); |
---|
2079 | #endif |
---|
2080 | |
---|
2081 | uint32_t responses = 1; |
---|
2082 | |
---|
2083 | // initialise RPC descriptor header |
---|
2084 | rpc_desc_t rpc; |
---|
2085 | rpc.index = RPC_VMM_GET_VSEG; |
---|
2086 | rpc.blocking = true; |
---|
2087 | rpc.rsp = &responses; |
---|
2088 | |
---|
2089 | // set input arguments in RPC descriptor |
---|
2090 | rpc.args[0] = (uint64_t)(intptr_t)process; |
---|
2091 | rpc.args[1] = (uint64_t)vaddr; |
---|
2092 | |
---|
2093 | // register RPC request in remote RPC fifo |
---|
2094 | rpc_send( cxy , &rpc ); |
---|
2095 | |
---|
2096 | // get output argument from rpc descriptor |
---|
2097 | *vseg_xp = rpc.args[2]; |
---|
2098 | *error = (error_t)rpc.args[3]; |
---|
2099 | |
---|
2100 | #if DEBUG_RPC_VMM_GET_VSEG |
---|
2101 | cycle = (uint32_t)hal_get_cycles(); |
---|
2102 | if( cycle > DEBUG_RPC_VMM_GET_VSEG ) |
---|
2103 | printk("\n[%s] thread[%x,%x] on core %d exit / cycle %d\n", |
---|
2104 | __FUNCTION__, this->process->pid, this->trdid, this->core->lid , cycle ); |
---|
2105 | #endif |
---|
2106 | } |
---|
2107 | |
---|
2108 | ///////////////////////////////////////// |
---|
2109 | void rpc_vmm_get_vseg_server( xptr_t xp ) |
---|
2110 | { |
---|
2111 | #if DEBUG_RPC_VMM_GET_VSEG |
---|
2112 | thread_t * this = CURRENT_THREAD; |
---|
2113 | uint32_t cycle = (uint32_t)hal_get_cycles(); |
---|
2114 | if( cycle > DEBUG_RPC_VMM_GET_VSEG ) |
---|
2115 | printk("\n[%s] thread[%x,%x] on core %d enter / cycle %d\n", |
---|
2116 | __FUNCTION__, this->process->pid, this->trdid, this->core->lid , cycle ); |
---|
2117 | #endif |
---|
2118 | |
---|
2119 | process_t * process; |
---|
2120 | intptr_t vaddr; |
---|
2121 | vseg_t * vseg_ptr; |
---|
2122 | xptr_t vseg_xp; |
---|
2123 | error_t error; |
---|
2124 | |
---|
2125 | // get client cluster identifier and pointer on RPC descriptor |
---|
2126 | cxy_t client_cxy = GET_CXY( xp ); |
---|
2127 | rpc_desc_t * desc = GET_PTR( xp ); |
---|
2128 | |
---|
2129 | // get input argument from client RPC descriptor |
---|
2130 | process = (process_t *)(intptr_t)hal_remote_l64( XPTR( client_cxy , &desc->args[0] ) ); |
---|
2131 | vaddr = (intptr_t)hal_remote_l64( XPTR( client_cxy , &desc->args[1] ) ); |
---|
2132 | |
---|
2133 | // call local kernel function |
---|
2134 | error = vmm_get_vseg( process , vaddr , &vseg_ptr ); |
---|
2135 | |
---|
2136 | // set output arguments to client RPC descriptor |
---|
2137 | vseg_xp = XPTR( local_cxy , vseg_ptr ); |
---|
2138 | hal_remote_s64( XPTR( client_cxy , &desc->args[2] ) , (uint64_t)vseg_xp ); |
---|
2139 | hal_remote_s64( XPTR( client_cxy , &desc->args[3] ) , (uint64_t)error ); |
---|
2140 | |
---|
2141 | #if DEBUG_RPC_VMM_GET_VSEG |
---|
2142 | cycle = (uint32_t)hal_get_cycles(); |
---|
2143 | if( cycle > DEBUG_RPC_VMM_GET_VSEG ) |
---|
2144 | printk("\n[%s] thread[%x,%x] on core %d exit / cycle %d\n", |
---|
2145 | __FUNCTION__, this->process->pid, this->trdid, this->core->lid , cycle ); |
---|
2146 | #endif |
---|
2147 | } |
---|
2148 | */ |
---|
2149 | |
---|
2150 | ///////////////////////////////////////////////////////////////////////////////////////// |
---|
2151 | // [21] undefined |
---|
2152 | ///////////////////////////////////////////////////////////////////////////////////////// |
---|
2153 | |
---|
2154 | ///////////////////////////////////////////////////////////////////////////////////////// |
---|
2155 | // [22] RPC_KCM_ALLOC deprecated [AG] sept 2019 |
---|
2156 | ///////////////////////////////////////////////////////////////////////////////////////// |
---|
2157 | |
---|
2158 | /* |
---|
2159 | ////////////////////////////////////////// |
---|
2160 | void rpc_kcm_alloc_client( cxy_t cxy, |
---|
2161 | uint32_t kmem_type, // in |
---|
2162 | xptr_t * buf_xp ) // out |
---|
2163 | { |
---|
2164 | #if DEBUG_RPC_KCM_ALLOC |
---|
2165 | thread_t * this = CURRENT_THREAD; |
---|
2166 | uint32_t cycle = (uint32_t)hal_get_cycles(); |
---|
2167 | if( cycle > DEBUG_RPC_KCM_ALLOC ) |
---|
2168 | printk("\n[%s] thread[%x,%x] on core %d enter / cycle %d\n", |
---|
2169 | __FUNCTION__, this->process->pid, this->trdid, this->core->lid , cycle ); |
---|
2170 | #endif |
---|
2171 | |
---|
2172 | uint32_t responses = 1; |
---|
2173 | |
---|
2174 | // initialise RPC descriptor header |
---|
2175 | rpc_desc_t rpc; |
---|
2176 | rpc.index = RPC_KCM_ALLOC; |
---|
2177 | rpc.blocking = true; |
---|
2178 | rpc.rsp = &responses; |
---|
2179 | |
---|
2180 | // set input arguments in RPC descriptor |
---|
2181 | rpc.args[0] = (uint64_t)kmem_type; |
---|
2182 | |
---|
2183 | // register RPC request in remote RPC fifo |
---|
2184 | rpc_send( cxy , &rpc ); |
---|
2185 | |
---|
2186 | // get output arguments from RPC descriptor |
---|
2187 | *buf_xp = (xptr_t)rpc.args[1]; |
---|
2188 | |
---|
2189 | #if DEBUG_RPC_KCM_ALLOC |
---|
2190 | cycle = (uint32_t)hal_get_cycles(); |
---|
2191 | if( cycle > DEBUG_RPC_KCM_ALLOC ) |
---|
2192 | printk("\n[%s] thread[%x,%x] on core %d exit / cycle %d\n", |
---|
2193 | __FUNCTION__, this->process->pid, this->trdid, this->core->lid , cycle ); |
---|
2194 | #endif |
---|
2195 | } |
---|
2196 | |
---|
2197 | ////////////////////////////////////// |
---|
2198 | void rpc_kcm_alloc_server( xptr_t xp ) |
---|
2199 | { |
---|
2200 | #if DEBUG_RPC_KCM_ALLOC |
---|
2201 | thread_t * this = CURRENT_THREAD; |
---|
2202 | uint32_t cycle = (uint32_t)hal_get_cycles(); |
---|
2203 | if( cycle > DEBUG_RPC_KCM_ALLOC ) |
---|
2204 | printk("\n[%s] thread[%x,%x] on core %d enter / cycle %d\n", |
---|
2205 | __FUNCTION__, this->process->pid, this->trdid, this->core->lid , cycle ); |
---|
2206 | #endif |
---|
2207 | |
---|
2208 | // get client cluster identifier and pointer on RPC descriptor |
---|
2209 | cxy_t client_cxy = GET_CXY( xp ); |
---|
2210 | rpc_desc_t * desc = GET_PTR( xp ); |
---|
2211 | |
---|
2212 | // get input argument "kmem_type" from client RPC descriptor |
---|
2213 | uint32_t kmem_type = (uint32_t)hal_remote_l64( XPTR( client_cxy , &desc->args[0] ) ); |
---|
2214 | |
---|
2215 | // allocates memory for kcm |
---|
2216 | kmem_req_t req; |
---|
2217 | req.type = kmem_type; |
---|
2218 | req.flags = AF_ZERO; |
---|
2219 | void * buf_ptr = kmem_alloc( &req ); |
---|
2220 | |
---|
2221 | // set output argument |
---|
2222 | xptr_t buf_xp = XPTR( local_cxy , buf_ptr ); |
---|
2223 | hal_remote_s64( XPTR( client_cxy , &desc->args[1] ) , (uint64_t)buf_xp ); |
---|
2224 | |
---|
2225 | #if DEBUG_RPC_KCM_ALLOC |
---|
2226 | cycle = (uint32_t)hal_get_cycles(); |
---|
2227 | if( cycle > DEBUG_RPC_KCM_ALLOC ) |
---|
2228 | printk("\n[%s] thread[%x,%x] on core %d exit / cycle %d\n", |
---|
2229 | __FUNCTION__, this->process->pid, this->trdid, this->core->lid , cycle ); |
---|
2230 | #endif |
---|
2231 | } |
---|
2232 | */ |
---|
2233 | |
---|
2234 | ///////////////////////////////////////////////////////////////////////////////////////// |
---|
2235 | // [23] RPC_KCM_FREE deprecated [AG] sept 2019 |
---|
2236 | ///////////////////////////////////////////////////////////////////////////////////////// |
---|
2237 | |
---|
2238 | /* |
---|
2239 | ///////////////////////////////////////// |
---|
2240 | void rpc_kcm_free_client( cxy_t cxy, |
---|
2241 | void * buf, // in |
---|
2242 | uint32_t kmem_type ) // in |
---|
2243 | { |
---|
2244 | #if DEBUG_RPC_KCM_FREE |
---|
2245 | thread_t * this = CURRENT_THREAD; |
---|
2246 | uint32_t cycle = (uint32_t)hal_get_cycles(); |
---|
2247 | if( cycle > DEBUG_RPC_KCM_FREE ) |
---|
2248 | printk("\n[%s] thread[%x,%x] on core %d enter / cycle %d\n", |
---|
2249 | __FUNCTION__, this->process->pid, this->trdid, this->core->lid , cycle ); |
---|
2250 | #endif |
---|
2251 | |
---|
2252 | uint32_t responses = 1; |
---|
2253 | |
---|
2254 | // initialise RPC descriptor header |
---|
2255 | rpc_desc_t rpc; |
---|
2256 | rpc.index = RPC_KCM_FREE; |
---|
2257 | rpc.blocking = true; |
---|
2258 | rpc.rsp = &responses; |
---|
2259 | |
---|
2260 | // set input arguments in RPC descriptor |
---|
2261 | rpc.args[0] = (uint64_t)(intptr_t)buf; |
---|
2262 | rpc.args[1] = (uint64_t)kmem_type; |
---|
2263 | |
---|
2264 | // register RPC request in remote RPC fifo |
---|
2265 | rpc_send( cxy , &rpc ); |
---|
2266 | |
---|
2267 | #if DEBUG_RPC_KCM_FREE |
---|
2268 | cycle = (uint32_t)hal_get_cycles(); |
---|
2269 | if( cycle > DEBUG_RPC_KCM_FREE ) |
---|
2270 | printk("\n[%s] thread[%x,%x] on core %d exit / cycle %d\n", |
---|
2271 | __FUNCTION__, this->process->pid, this->trdid, this->core->lid , cycle ); |
---|
2272 | #endif |
---|
2273 | } |
---|
2274 | |
---|
2275 | ///////////////////////////////////// |
---|
2276 | void rpc_kcm_free_server( xptr_t xp ) |
---|
2277 | { |
---|
2278 | #if DEBUG_RPC_KCM_FREE |
---|
2279 | thread_t * this = CURRENT_THREAD; |
---|
2280 | uint32_t cycle = (uint32_t)hal_get_cycles(); |
---|
2281 | if( cycle > DEBUG_RPC_KCM_FREE ) |
---|
2282 | printk("\n[%s] thread[%x,%x] on core %d enter / cycle %d\n", |
---|
2283 | __FUNCTION__, this->process->pid, this->trdid, this->core->lid , cycle ); |
---|
2284 | #endif |
---|
2285 | |
---|
2286 | // get client cluster identifier and pointer on RPC descriptor |
---|
2287 | cxy_t client_cxy = GET_CXY( xp ); |
---|
2288 | rpc_desc_t * desc = GET_PTR( xp ); |
---|
2289 | |
---|
2290 | // get input arguments "buf" and "kmem_type" from client RPC descriptor |
---|
2291 | void * buf = (void *)(intptr_t)hal_remote_l64( XPTR( client_cxy , &desc->args[0] ) ); |
---|
2292 | uint32_t kmem_type = (uint32_t)hal_remote_l64( XPTR( client_cxy , &desc->args[1] ) ); |
---|
2293 | |
---|
2294 | // releases memory |
---|
2295 | kmem_req_t req; |
---|
2296 | req.type = kmem_type; |
---|
2297 | req.ptr = buf; |
---|
2298 | kmem_free( &req ); |
---|
2299 | |
---|
2300 | #if DEBUG_RPC_KCM_FREE |
---|
2301 | cycle = (uint32_t)hal_get_cycles(); |
---|
2302 | if( cycle > DEBUG_RPC_KCM_FREE ) |
---|
2303 | printk("\n[%s] thread[%x,%x] on core %d exit / cycle %d\n", |
---|
2304 | __FUNCTION__, this->process->pid, this->trdid, this->core->lid , cycle ); |
---|
2305 | #endif |
---|
2306 | } |
---|
2307 | */ |
---|
2308 | |
---|
2309 | ///////////////////////////////////////////////////////////////////////////////////////// |
---|
2310 | // [24] Marshaling functions attached to RPC_MAPPER_SYNC |
---|
2311 | ///////////////////////////////////////////////////////////////////////////////////////// |
---|
2312 | |
---|
2313 | /////////////////////////////////////////////////// |
---|
2314 | void rpc_mapper_sync_client( cxy_t cxy, |
---|
2315 | struct mapper_s * mapper, |
---|
2316 | error_t * error ) |
---|
2317 | { |
---|
2318 | #if DEBUG_RPC_MAPPER_SYNC |
---|
2319 | thread_t * this = CURRENT_THREAD; |
---|
2320 | uint32_t cycle = (uint32_t)hal_get_cycles(); |
---|
2321 | if( cycle > DEBUG_RPC_MAPPER_SYNC ) |
---|
2322 | printk("\n[%s] thread[%x,%x] on core %d enter / cycle %d\n", |
---|
2323 | __FUNCTION__, this->process->pid, this->trdid, this->core->lid , cycle ); |
---|
2324 | #endif |
---|
2325 | |
---|
2326 | uint32_t responses = 1; |
---|
2327 | |
---|
2328 | // initialise RPC descriptor header |
---|
2329 | rpc_desc_t rpc; |
---|
2330 | rpc.index = RPC_MAPPER_SYNC; |
---|
2331 | rpc.blocking = true; |
---|
2332 | rpc.rsp = &responses; |
---|
2333 | |
---|
2334 | // set input arguments in RPC descriptor |
---|
2335 | rpc.args[0] = (uint64_t)(intptr_t)mapper; |
---|
2336 | |
---|
2337 | // register RPC request in remote RPC fifo |
---|
2338 | rpc_send( cxy , &rpc ); |
---|
2339 | |
---|
2340 | // get output values from RPC descriptor |
---|
2341 | *error = (error_t)rpc.args[1]; |
---|
2342 | |
---|
2343 | #if DEBUG_RPC_MAPPER_SYNC |
---|
2344 | cycle = (uint32_t)hal_get_cycles(); |
---|
2345 | if( cycle > DEBUG_RPC_MAPPER_SYNC ) |
---|
2346 | printk("\n[%s] thread[%x,%x] on core %d exit / cycle %d\n", |
---|
2347 | __FUNCTION__, this->process->pid, this->trdid, this->core->lid , cycle ); |
---|
2348 | #endif |
---|
2349 | } |
---|
2350 | |
---|
2351 | //////////////////////////////////////// |
---|
2352 | void rpc_mapper_sync_server( xptr_t xp ) |
---|
2353 | { |
---|
2354 | #if DEBUG_RPC_MAPPER_SYNC |
---|
2355 | thread_t * this = CURRENT_THREAD; |
---|
2356 | uint32_t cycle = (uint32_t)hal_get_cycles(); |
---|
2357 | if( cycle > DEBUG_RPC_MAPPER_SYNC ) |
---|
2358 | printk("\n[%s] thread[%x,%x] on core %d enter / cycle %d\n", |
---|
2359 | __FUNCTION__, this->process->pid, this->trdid, this->core->lid , cycle ); |
---|
2360 | #endif |
---|
2361 | |
---|
2362 | mapper_t * mapper; |
---|
2363 | error_t error; |
---|
2364 | |
---|
2365 | // get client cluster identifier and pointer on RPC descriptor |
---|
2366 | cxy_t client_cxy = GET_CXY( xp ); |
---|
2367 | rpc_desc_t * desc = GET_PTR( xp ); |
---|
2368 | |
---|
2369 | // get arguments from client RPC descriptor |
---|
2370 | mapper = (mapper_t *)(intptr_t)hal_remote_l64( XPTR( client_cxy , &desc->args[0] ) ); |
---|
2371 | |
---|
2372 | // call local kernel function |
---|
2373 | error = mapper_sync( mapper ); |
---|
2374 | |
---|
2375 | // set output argument to client RPC descriptor |
---|
2376 | hal_remote_s64( XPTR( client_cxy , &desc->args[1] ) , (uint64_t)error ); |
---|
2377 | |
---|
2378 | #if DEBUG_RPC_MAPPER_SYNC |
---|
2379 | cycle = (uint32_t)hal_get_cycles(); |
---|
2380 | if( cycle > DEBUG_RPC_MAPPER_SYNC ) |
---|
2381 | printk("\n[%s] thread[%x,%x] on core %d exit / cycle %d\n", |
---|
2382 | __FUNCTION__, this->process->pid, this->trdid, this->core->lid , cycle ); |
---|
2383 | #endif |
---|
2384 | } |
---|
2385 | |
---|
2386 | ///////////////////////////////////////////////////////////////////////////////////////// |
---|
2387 | // [25] Marshaling functions attached to RPC_VMM_RESIZE_VSEG |
---|
2388 | ///////////////////////////////////////////////////////////////////////////////////////// |
---|
2389 | |
---|
2390 | ////////////////////////////////////////////////////////// |
---|
2391 | void rpc_vmm_resize_vseg_client( cxy_t cxy, |
---|
2392 | pid_t pid, |
---|
2393 | intptr_t base, |
---|
2394 | intptr_t new_base, |
---|
2395 | intptr_t new_size ) |
---|
2396 | { |
---|
2397 | #if DEBUG_RPC_VMM_RESIZE_VSEG |
---|
2398 | thread_t * this = CURRENT_THREAD; |
---|
2399 | uint32_t cycle = (uint32_t)hal_get_cycles(); |
---|
2400 | if( cycle > DEBUG_RPC_VMM_RESIZE_VSEG ) |
---|
2401 | printk("\n[%s] thread[%x,%x] on core %d enter / cycle %d\n", |
---|
2402 | __FUNCTION__, this->process->pid, this->trdid, this->core->lid , cycle ); |
---|
2403 | #endif |
---|
2404 | |
---|
2405 | uint32_t responses = 1; |
---|
2406 | |
---|
2407 | // initialise RPC descriptor header |
---|
2408 | rpc_desc_t rpc; |
---|
2409 | rpc.index = RPC_VMM_RESIZE_VSEG; |
---|
2410 | rpc.blocking = true; |
---|
2411 | rpc.rsp = &responses; |
---|
2412 | |
---|
2413 | // set input arguments in RPC descriptor |
---|
2414 | rpc.args[0] = (uint64_t)pid; |
---|
2415 | rpc.args[1] = (uint64_t)base; |
---|
2416 | rpc.args[2] = (uint64_t)new_base; |
---|
2417 | rpc.args[3] = (uint64_t)new_size; |
---|
2418 | |
---|
2419 | // register RPC request in remote RPC fifo |
---|
2420 | rpc_send( cxy , &rpc ); |
---|
2421 | |
---|
2422 | #if DEBUG_RPC_VMM_RESIZE_VSEG |
---|
2423 | cycle = (uint32_t)hal_get_cycles(); |
---|
2424 | if( cycle > DEBUG_RPC_VMM_RESIZE_VSEG ) |
---|
2425 | printk("\n[%s] thread[%x,%x] on core %d exit / cycle %d\n", |
---|
2426 | __FUNCTION__, this->process->pid, this->trdid, this->core->lid , cycle ); |
---|
2427 | #endif |
---|
2428 | } |
---|
2429 | |
---|
2430 | //////////////////////////////////////////// |
---|
2431 | void rpc_vmm_resize_vseg_server( xptr_t xp ) |
---|
2432 | { |
---|
2433 | #if DEBUG_RPC_VMM_RESIZE_VSEG |
---|
2434 | thread_t * this = CURRENT_THREAD; |
---|
2435 | uint32_t cycle = (uint32_t)hal_get_cycles(); |
---|
2436 | if( cycle > DEBUG_RPC_VMM_RESIZE_VSEG ) |
---|
2437 | printk("\n[%s] thread[%x,%x] on core %d enter / cycle %d\n", |
---|
2438 | __FUNCTION__, this->process->pid, this->trdid, this->core->lid , cycle ); |
---|
2439 | #endif |
---|
2440 | |
---|
2441 | pid_t pid; |
---|
2442 | process_t * process; |
---|
2443 | intptr_t base; |
---|
2444 | vseg_t * vseg; |
---|
2445 | intptr_t new_base; |
---|
2446 | intptr_t new_size; |
---|
2447 | |
---|
2448 | // get client cluster identifier and pointer on RPC descriptor |
---|
2449 | cxy_t client_cxy = GET_CXY( xp ); |
---|
2450 | rpc_desc_t * desc = GET_PTR( xp ); |
---|
2451 | |
---|
2452 | // get arguments from client RPC descriptor |
---|
2453 | pid = (pid_t) hal_remote_l64( XPTR( client_cxy , &desc->args[0] ) ); |
---|
2454 | base = (intptr_t)hal_remote_l64( XPTR( client_cxy , &desc->args[1] ) ); |
---|
2455 | new_base = (intptr_t)hal_remote_l64( XPTR( client_cxy , &desc->args[2] ) ); |
---|
2456 | new_size = (intptr_t)hal_remote_l64( XPTR( client_cxy , &desc->args[3] ) ); |
---|
2457 | |
---|
2458 | // get local pointer on target process |
---|
2459 | process = cluster_get_local_process_from_pid( pid ); |
---|
2460 | |
---|
2461 | // get target vseg from vaddr |
---|
2462 | vmm_get_vseg( process , base , &vseg ); |
---|
2463 | |
---|
2464 | // call relevant kernel function |
---|
2465 | vmm_resize_vseg( process, |
---|
2466 | vseg, |
---|
2467 | new_base, |
---|
2468 | new_size ); |
---|
2469 | |
---|
2470 | #if DEBUG_RPC_VMM_RESIZE_VSEG |
---|
2471 | cycle = (uint32_t)hal_get_cycles(); |
---|
2472 | if( cycle > DEBUG_RPC_VMM_RESIZE_VSEG ) |
---|
2473 | printk("\n[%s] thread[%x,%x] on core %d exit / cycle %d\n", |
---|
2474 | __FUNCTION__, this->process->pid, this->trdid, this->core->lid , cycle ); |
---|
2475 | #endif |
---|
2476 | } |
---|
2477 | |
---|
2478 | |
---|
2479 | ///////////////////////////////////////////////////////////////////////////////////////// |
---|
2480 | // [26] Marshaling functions attached to RPC_VMM_REMOVE_VSEG |
---|
2481 | ///////////////////////////////////////////////////////////////////////////////////////// |
---|
2482 | |
---|
2483 | ///////////////////////////////////////////////// |
---|
2484 | void rpc_vmm_remove_vseg_client( cxy_t cxy, |
---|
2485 | pid_t pid, |
---|
2486 | intptr_t base ) |
---|
2487 | { |
---|
2488 | #if DEBUG_RPC_VMM_REMOVE_VSEG |
---|
2489 | thread_t * this = CURRENT_THREAD; |
---|
2490 | uint32_t cycle = (uint32_t)hal_get_cycles(); |
---|
2491 | if( cycle > DEBUG_RPC_VMM_REMOVE_VSEG ) |
---|
2492 | printk("\n[%s] thread[%x,%x] on core %d enter / cycle %d\n", |
---|
2493 | __FUNCTION__, this->process->pid, this->trdid, this->core->lid, cycle ); |
---|
2494 | #endif |
---|
2495 | |
---|
2496 | uint32_t responses = 1; |
---|
2497 | rpc_desc_t rpc; |
---|
2498 | |
---|
2499 | // initialise RPC descriptor header |
---|
2500 | rpc.index = RPC_VMM_REMOVE_VSEG; |
---|
2501 | rpc.blocking = true; |
---|
2502 | rpc.rsp = &responses; |
---|
2503 | |
---|
2504 | // set input arguments in RPC descriptor |
---|
2505 | rpc.args[0] = (uint64_t)pid; |
---|
2506 | rpc.args[1] = (uint64_t)base; |
---|
2507 | |
---|
2508 | // register RPC request in remote RPC fifo |
---|
2509 | rpc_send( cxy , &rpc ); |
---|
2510 | |
---|
2511 | #if DEBUG_RPC_VMM_REMOVE_VSEG |
---|
2512 | cycle = (uint32_t)hal_get_cycles(); |
---|
2513 | if( cycle > DEBUG_RPC_VMM_REMOVE_VSEG ) |
---|
2514 | printk("\n[%s] thread[%x,%x] on core %d exit / cycle %d\n", |
---|
2515 | __FUNCTION__, this->process->pid, this->trdid, this->core->lid, cycle ); |
---|
2516 | #endif |
---|
2517 | } |
---|
2518 | |
---|
2519 | //////////////////////////////////////////// |
---|
2520 | void rpc_vmm_remove_vseg_server( xptr_t xp ) |
---|
2521 | { |
---|
2522 | #if DEBUG_RPC_VMM_REMOVE_VSEG |
---|
2523 | uint32_t cycle = (uint32_t)hal_get_cycles(); |
---|
2524 | thread_t * this = CURRENT_THREAD; |
---|
2525 | if( DEBUG_RPC_VMM_REMOVE_VSEG < cycle ) |
---|
2526 | printk("\n[%s] thread[%x,%x] on core %d enter / cycle %d\n", |
---|
2527 | __FUNCTION__, this->process->pid, this->trdid, this->core->lid, cycle ); |
---|
2528 | #endif |
---|
2529 | |
---|
2530 | pid_t pid; |
---|
2531 | intptr_t vaddr; |
---|
2532 | process_t * process; |
---|
2533 | vseg_t * vseg; |
---|
2534 | |
---|
2535 | // get client cluster identifier and pointer on RPC descriptor |
---|
2536 | cxy_t client_cxy = GET_CXY( xp ); |
---|
2537 | rpc_desc_t * desc = GET_PTR( xp ); |
---|
2538 | |
---|
2539 | // get arguments from RPC descriptor |
---|
2540 | pid = (pid_t) hal_remote_l64( XPTR( client_cxy , &desc->args[0] ) ); |
---|
2541 | vaddr = (intptr_t)hal_remote_l64( XPTR( client_cxy , &desc->args[1] ) ); |
---|
2542 | |
---|
2543 | // get local pointer on target process |
---|
2544 | process = cluster_get_local_process_from_pid( pid ); |
---|
2545 | |
---|
2546 | // get target vseg from vaddr |
---|
2547 | vmm_get_vseg( process , vaddr , &vseg ); |
---|
2548 | |
---|
2549 | // call relevant kernel function |
---|
2550 | vmm_remove_vseg( process, |
---|
2551 | vseg ); |
---|
2552 | |
---|
2553 | #if DEBUG_RPC_VMM_REMOVE_VSEG |
---|
2554 | cycle = (uint32_t)hal_get_cycles(); |
---|
2555 | if( DEBUG_RPC_VMM_REMOVE_VSEG < cycle ) |
---|
2556 | printk("\n[%s] thread[%x,%x] on core %d exit / cycle %d\n", |
---|
2557 | __FUNCTION__, this->process->pid, this->trdid, this->core->lid, cycle ); |
---|
2558 | #endif |
---|
2559 | } |
---|
2560 | |
---|
2561 | ///////////////////////////////////////////////////////////////////////////////////////// |
---|
2562 | // [27] Marshaling functions attached to RPC_VMM_CREATE_VSEG |
---|
2563 | ///////////////////////////////////////////////////////////////////////////////////////// |
---|
2564 | |
---|
2565 | //////////////////////////////////////////////////////// |
---|
2566 | void rpc_vmm_create_vseg_client( cxy_t cxy, |
---|
2567 | struct process_s * process, |
---|
2568 | vseg_type_t type, |
---|
2569 | intptr_t base, |
---|
2570 | uint32_t size, |
---|
2571 | uint32_t file_offset, |
---|
2572 | uint32_t file_size, |
---|
2573 | xptr_t mapper_xp, |
---|
2574 | cxy_t vseg_cxy, |
---|
2575 | struct vseg_s ** vseg ) |
---|
2576 | { |
---|
2577 | #if DEBUG_RPC_VMM_CREATE_VSEG |
---|
2578 | thread_t * this = CURRENT_THREAD; |
---|
2579 | uint32_t cycle = (uint32_t)hal_get_cycles(); |
---|
2580 | if( cycle > DEBUG_RPC_VMM_CREATE_VSEG ) |
---|
2581 | printk("\n[%s] thread[%x,%x] on core %d enter / cycle %d\n", |
---|
2582 | __FUNCTION__, this->process->pid, this->trdid, this->core->lid , cycle ); |
---|
2583 | #endif |
---|
2584 | |
---|
2585 | uint32_t responses = 1; |
---|
2586 | |
---|
2587 | // initialise RPC descriptor header |
---|
2588 | rpc_desc_t rpc; |
---|
2589 | rpc.index = RPC_VMM_CREATE_VSEG; |
---|
2590 | rpc.blocking = true; |
---|
2591 | rpc.rsp = &responses; |
---|
2592 | |
---|
2593 | // set input arguments in RPC descriptor |
---|
2594 | rpc.args[0] = (uint64_t)(intptr_t)process; |
---|
2595 | rpc.args[1] = (uint64_t)type; |
---|
2596 | rpc.args[2] = (uint64_t)base; |
---|
2597 | rpc.args[3] = (uint64_t)size; |
---|
2598 | rpc.args[4] = (uint64_t)file_offset; |
---|
2599 | rpc.args[5] = (uint64_t)file_size; |
---|
2600 | rpc.args[6] = (uint64_t)mapper_xp; |
---|
2601 | rpc.args[7] = (uint64_t)vseg_cxy; |
---|
2602 | |
---|
2603 | // register RPC request in remote RPC fifo |
---|
2604 | rpc_send( cxy , &rpc ); |
---|
2605 | |
---|
2606 | // get output values from RPC descriptor |
---|
2607 | *vseg = (vseg_t *)(intptr_t)rpc.args[8]; |
---|
2608 | |
---|
2609 | #if DEBUG_RPC_VMM_CREATE_VSEG |
---|
2610 | cycle = (uint32_t)hal_get_cycles(); |
---|
2611 | if( cycle > DEBUG_RPC_VMM_CREATE_VSEG ) |
---|
2612 | printk("\n[%s] thread[%x,%x] on core %d exit / cycle %d\n", |
---|
2613 | __FUNCTION__, this->process->pid, this->trdid, this->core->lid , cycle ); |
---|
2614 | #endif |
---|
2615 | } |
---|
2616 | |
---|
2617 | //////////////////////////////////////////// |
---|
2618 | void rpc_vmm_create_vseg_server( xptr_t xp ) |
---|
2619 | { |
---|
2620 | #if DEBUG_RPC_VMM_CREATE_VSEG |
---|
2621 | thread_t * this = CURRENT_THREAD; |
---|
2622 | uint32_t cycle = (uint32_t)hal_get_cycles(); |
---|
2623 | if( cycle > DEBUG_RPC_VMM_CREATE_VSEG ) |
---|
2624 | printk("\n[%s] thread[%x,%x] on core %d enter / cycle %d\n", |
---|
2625 | __FUNCTION__, this->process->pid, this->trdid, this->core->lid , cycle ); |
---|
2626 | #endif |
---|
2627 | |
---|
2628 | // get client cluster identifier and pointer on RPC descriptor |
---|
2629 | cxy_t cxy = GET_CXY( xp ); |
---|
2630 | rpc_desc_t * desc = GET_PTR( xp ); |
---|
2631 | |
---|
2632 | // get input arguments from client RPC descriptor |
---|
2633 | process_t * process = (process_t *)(intptr_t)hal_remote_l64( XPTR(cxy , &desc->args[0])); |
---|
2634 | vseg_type_t type = (vseg_type_t)(uint32_t)hal_remote_l64( XPTR(cxy , &desc->args[1])); |
---|
2635 | intptr_t base = (intptr_t) hal_remote_l64( XPTR(cxy , &desc->args[2])); |
---|
2636 | uint32_t size = (uint32_t) hal_remote_l64( XPTR(cxy , &desc->args[3])); |
---|
2637 | uint32_t file_offset = (uint32_t) hal_remote_l64( XPTR(cxy , &desc->args[4])); |
---|
2638 | uint32_t file_size = (uint32_t) hal_remote_l64( XPTR(cxy , &desc->args[5])); |
---|
2639 | xptr_t mapper_xp = (xptr_t) hal_remote_l64( XPTR(cxy , &desc->args[6])); |
---|
2640 | cxy_t vseg_cxy = (cxy_t)(uint32_t) hal_remote_l64( XPTR(cxy , &desc->args[7])); |
---|
2641 | |
---|
2642 | // call local kernel function |
---|
2643 | vseg_t * vseg = vmm_create_vseg( process, |
---|
2644 | type, |
---|
2645 | base, |
---|
2646 | size, |
---|
2647 | file_offset, |
---|
2648 | file_size, |
---|
2649 | mapper_xp, |
---|
2650 | vseg_cxy ); |
---|
2651 | |
---|
2652 | // set output arguments into client RPC descriptor |
---|
2653 | hal_remote_s64( XPTR( cxy , &desc->args[8] ) , (uint64_t)(intptr_t)vseg ); |
---|
2654 | |
---|
2655 | #if DEBUG_RPC_VMM_CREATE_VSEG |
---|
2656 | cycle = (uint32_t)hal_get_cycles(); |
---|
2657 | if( cycle > DEBUG_RPC_VMM_CREATE_VSEG ) |
---|
2658 | printk("\n[%s] thread[%x,%x] on core %d exit / cycle %d\n", |
---|
2659 | __FUNCTION__, this->process->pid, this->trdid, this->core->lid , cycle ); |
---|
2660 | #endif |
---|
2661 | } |
---|
2662 | |
---|
2663 | ///////////////////////////////////////////////////////////////////////////////////////// |
---|
2664 | // [28] Marshaling functions attached to RPC_VMM_SET_COW |
---|
2665 | ///////////////////////////////////////////////////////////////////////////////////////// |
---|
2666 | |
---|
2667 | ///////////////////////////////////////////// |
---|
2668 | void rpc_vmm_set_cow_client( cxy_t cxy, |
---|
2669 | process_t * process ) |
---|
2670 | { |
---|
2671 | #if DEBUG_RPC_VMM_SET_COW |
---|
2672 | thread_t * this = CURRENT_THREAD; |
---|
2673 | uint32_t cycle = (uint32_t)hal_get_cycles(); |
---|
2674 | if( cycle > DEBUG_RPC_VMM_SET_COW ) |
---|
2675 | printk("\n[%s] thread[%x,%x] on core %d enter / cycle %d\n", |
---|
2676 | __FUNCTION__, this->process->pid, this->trdid, this->core->lid , cycle ); |
---|
2677 | #endif |
---|
2678 | |
---|
2679 | uint32_t responses = 1; |
---|
2680 | |
---|
2681 | // initialise RPC descriptor header |
---|
2682 | rpc_desc_t rpc; |
---|
2683 | rpc.index = RPC_VMM_SET_COW; |
---|
2684 | rpc.blocking = true; |
---|
2685 | rpc.rsp = &responses; |
---|
2686 | |
---|
2687 | // set input arguments in RPC descriptor |
---|
2688 | rpc.args[0] = (uint64_t)(intptr_t)process; |
---|
2689 | |
---|
2690 | // register RPC request in remote RPC fifo |
---|
2691 | rpc_send( cxy , &rpc ); |
---|
2692 | |
---|
2693 | #if DEBUG_RPC_VMM_SET_COW |
---|
2694 | cycle = (uint32_t)hal_get_cycles(); |
---|
2695 | if( cycle > DEBUG_RPC_VMM_SET_COW ) |
---|
2696 | printk("\n[%s] thread[%x,%x] on core %d exit / cycle %d\n", |
---|
2697 | __FUNCTION__, this->process->pid, this->trdid, this->core->lid , cycle ); |
---|
2698 | #endif |
---|
2699 | } |
---|
2700 | |
---|
2701 | //////////////////////////////////////// |
---|
2702 | void rpc_vmm_set_cow_server( xptr_t xp ) |
---|
2703 | { |
---|
2704 | #if DEBUG_RPC_VMM_SET_COW |
---|
2705 | thread_t * this = CURRENT_THREAD; |
---|
2706 | uint32_t cycle = (uint32_t)hal_get_cycles(); |
---|
2707 | if( cycle > DEBUG_RPC_VMM_SET_COW ) |
---|
2708 | printk("\n[%s] thread[%x,%x] on core %d enter / cycle %d\n", |
---|
2709 | __FUNCTION__, this->process->pid, this->trdid, this->core->lid , cycle ); |
---|
2710 | #endif |
---|
2711 | |
---|
2712 | process_t * process; |
---|
2713 | |
---|
2714 | // get client cluster identifier and pointer on RPC descriptor |
---|
2715 | cxy_t cxy = GET_CXY( xp ); |
---|
2716 | rpc_desc_t * desc = GET_PTR( xp ); |
---|
2717 | |
---|
2718 | // get input arguments from client RPC descriptor |
---|
2719 | process = (process_t *)(intptr_t)hal_remote_l64( XPTR(cxy , &desc->args[0])); |
---|
2720 | |
---|
2721 | // call local kernel function |
---|
2722 | vmm_set_cow( process ); |
---|
2723 | |
---|
2724 | #if DEBUG_RPC_VMM_SET_COW |
---|
2725 | cycle = (uint32_t)hal_get_cycles(); |
---|
2726 | if( cycle > DEBUG_RPC_VMM_SET_COW ) |
---|
2727 | printk("\n[%s] thread[%x,%x] on core %d exit / cycle %d\n", |
---|
2728 | __FUNCTION__, this->process->pid, this->trdid, this->core->lid , cycle ); |
---|
2729 | #endif |
---|
2730 | } |
---|
2731 | |
---|
2732 | ///////////////////////////////////////////////////////////////////////////////////////// |
---|
2733 | // [29] RPC_VMM_DISPLAY deprecated [AG] June 2019 |
---|
2734 | ///////////////////////////////////////////////////////////////////////////////////////// |
---|
2735 | |
---|
2736 | /* |
---|
2737 | ///////////////////////////////////////////// |
---|
2738 | void rpc_hal_vmm_display_client( cxy_t cxy, |
---|
2739 | process_t * process, |
---|
2740 | bool_t detailed ) |
---|
2741 | { |
---|
2742 | #if DEBUG_RPC_VMM_DISPLAY |
---|
2743 | thread_t * this = CURRENT_THREAD; |
---|
2744 | uint32_t cycle = (uint32_t)hal_get_cycles(); |
---|
2745 | if( cycle > DEBUG_RPC_VMM_DISPLAY ) |
---|
2746 | printk("\n[%s] thread[%x,%x] on core %d enter / cycle %d\n", |
---|
2747 | __FUNCTION__, this->process->pid, this->trdid, this->core->lid , cycle ); |
---|
2748 | #endif |
---|
2749 | |
---|
2750 | uint32_t responses = 1; |
---|
2751 | |
---|
2752 | // initialise RPC descriptor header |
---|
2753 | rpc_desc_t rpc; |
---|
2754 | rpc.index = RPC_VMM_DISPLAY; |
---|
2755 | rpc.blocking = true; |
---|
2756 | rpc.rsp = &responses; |
---|
2757 | |
---|
2758 | // set input arguments in RPC descriptor |
---|
2759 | rpc.args[0] = (uint64_t)(intptr_t)process; |
---|
2760 | rpc.args[1] = (uint64_t)detailed; |
---|
2761 | |
---|
2762 | // register RPC request in remote RPC fifo |
---|
2763 | rpc_send( cxy , &rpc ); |
---|
2764 | |
---|
2765 | #if DEBUG_RPC_VMM_DISPLAY |
---|
2766 | cycle = (uint32_t)hal_get_cycles(); |
---|
2767 | if( cycle > DEBUG_RPC_VMM_DISPLAY ) |
---|
2768 | printk("\n[%s] thread[%x,%x] on core %d exit / cycle %d\n", |
---|
2769 | __FUNCTION__, this->process->pid, this->trdid, this->core->lid , cycle ); |
---|
2770 | #endif |
---|
2771 | } |
---|
2772 | |
---|
2773 | //////////////////////////////////////// |
---|
2774 | void rpc_hal_vmm_display_server( xptr_t xp ) |
---|
2775 | { |
---|
2776 | #if DEBUG_RPC_VMM_DISPLAY |
---|
2777 | thread_t * this = CURRENT_THREAD; |
---|
2778 | uint32_t cycle = (uint32_t)hal_get_cycles(); |
---|
2779 | if( cycle > DEBUG_RPC_VMM_DISPLAY ) |
---|
2780 | printk("\n[%s] thread[%x,%x] on core %d enter / cycle %d\n", |
---|
2781 | __FUNCTION__, this->process->pid, this->trdid, this->core->lid , cycle ); |
---|
2782 | #endif |
---|
2783 | |
---|
2784 | process_t * process; |
---|
2785 | bool_t detailed; |
---|
2786 | |
---|
2787 | // get client cluster identifier and pointer on RPC descriptor |
---|
2788 | cxy_t cxy = GET_CXY( xp ); |
---|
2789 | rpc_desc_t * desc = GET_PTR( xp ); |
---|
2790 | |
---|
2791 | // get input arguments from client RPC descriptor |
---|
2792 | process = (process_t *)(intptr_t)hal_remote_l64( XPTR(cxy , &desc->args[0])); |
---|
2793 | detailed = (bool_t) hal_remote_l64( XPTR(cxy , &desc->args[1])); |
---|
2794 | |
---|
2795 | // call local kernel function |
---|
2796 | hal_vmm_display( process , detailed ); |
---|
2797 | |
---|
2798 | #if DEBUG_RPC_VMM_DISPLAY |
---|
2799 | cycle = (uint32_t)hal_get_cycles(); |
---|
2800 | if( cycle > DEBUG_RPC_VMM_DISPLAY ) |
---|
2801 | printk("\n[%s] thread[%x,%x] on core %d exit / cycle %d\n", |
---|
2802 | __FUNCTION__, this->process->pid, this->trdid, this->core->lid , cycle ); |
---|
2803 | #endif |
---|
2804 | } |
---|
2805 | |
---|
2806 | */ |
---|