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