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