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