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