Changeset 313 for trunk/kernel/kern/rpc.c
- Timestamp:
- Aug 2, 2017, 3:24:57 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/kernel/kern/rpc.c
r296 r313 75 75 &rpc_kcm_free_server, // 23 76 76 &rpc_mapper_move_buffer_server, // 24 77 &rpc_ undefined,// 2577 &rpc_mapper_get_page_server, // 25 78 78 &rpc_undefined, // 26 79 79 &rpc_undefined, // 27 … … 96 96 void rpc_pmem_get_pages_client( cxy_t cxy, 97 97 uint32_t order, // in 98 error_t * error, // out 99 uint32_t * ppn ) // out 98 page_t ** page ) // out 100 99 { 101 100 rpc_dmsg("\n[INFO] %s : enter at cycle %d\n", __FUNCTION__ , hal_time_stamp() ); … … 114 113 rpc_send_sync( cxy , &rpc ); 115 114 116 // get output arguments RPC descriptor 117 *error = (error_t)rpc.args[0]; 118 *ppn = (uint32_t)rpc.args[1]; 115 // get output arguments from RPC descriptor 116 *page = (page_t *)(intptr_t)rpc.args[1]; 119 117 120 118 rpc_dmsg("\n[INFO] %s : completed at cycle %d\n", __FUNCTION__ , hal_time_stamp() ); … … 124 122 void rpc_pmem_get_pages_server( xptr_t xp ) 125 123 { 126 uint32_t order; // input127 error_t error; // output128 uint32_t ppn; // output129 130 124 rpc_dmsg("\n[INFO] %s : enter at cycle %d\n", __FUNCTION__ , hal_time_stamp() ); 131 125 … … 135 129 136 130 // get input arguments from client RPC descriptor 137 order = hal_remote_lw( XPTR( cxy , &desc->args[0] ) );131 uint32_t order = hal_remote_lw( XPTR( cxy , &desc->args[0] ) ); 138 132 139 133 // call local pmem allocator 140 134 page_t * page = ppm_alloc_pages( order ); 141 error = ( page == NULL ) ? ENOMEM : 0;142 ppn = ppm_page2ppn( page );143 135 144 136 // set output arguments into client RPC descriptor 145 hal_remote_sw( XPTR( cxy , &desc->args[0] ) , error ); 146 hal_remote_sw( XPTR( cxy , &desc->args[1] ) , ppn ); 137 hal_remote_swd( XPTR( cxy , &desc->args[1] ) , (uint64_t)(intptr_t)page ); 147 138 148 139 rpc_dmsg("\n[INFO] %s : completed at cycle %d\n", __FUNCTION__ , hal_time_stamp() ); … … 1353 1344 bool_t is_user, // in 1354 1345 uint32_t file_offset, // in 1355 void *buffer, // in1346 uint64_t buffer, // in 1356 1347 uint32_t size, // in 1357 1348 error_t * error ) // out … … 1371 1362 rpc.args[2] = (uint64_t)is_user; 1372 1363 rpc.args[3] = (uint64_t)file_offset; 1373 rpc.args[4] = (uint64_t) (intptr_t)buffer;1364 rpc.args[4] = (uint64_t)buffer; 1374 1365 rpc.args[5] = (uint64_t)size; 1375 1366 … … 1390 1381 bool_t is_user; 1391 1382 uint32_t file_offset; 1392 void * buffer; 1383 void * user_buffer; 1384 xptr_t kern_buffer; 1393 1385 uint32_t size; 1394 1386 error_t error; … … 1405 1397 is_user = hal_remote_lwd( XPTR( client_cxy , &desc->args[2] ) ); 1406 1398 file_offset = hal_remote_lwd( XPTR( client_cxy , &desc->args[3] ) ); 1407 buffer = (void *)(intptr_t)hal_remote_lwd( XPTR( client_cxy , &desc->args[4] ) );1408 1399 size = hal_remote_lwd( XPTR( client_cxy , &desc->args[5] ) ); 1409 1400 1410 1401 // call local kernel function 1411 error = mapper_move_buffer( mapper, 1412 to_buffer, 1413 is_user, 1414 file_offset, 1415 buffer, 1416 size ); 1402 if( is_user ) 1403 { 1404 user_buffer = (void *)(intptr_t)hal_remote_lwd( XPTR( client_cxy , &desc->args[4] ) ); 1405 1406 error = mapper_move_user_buffer( mapper, 1407 to_buffer, 1408 file_offset, 1409 user_buffer, 1410 size ); 1411 } 1412 else 1413 { 1414 kern_buffer = (xptr_t)hal_remote_lwd( XPTR( client_cxy , &desc->args[4] ) ); 1415 1416 error = mapper_move_user_buffer( mapper, 1417 to_buffer, 1418 file_offset, 1419 kern_buffer, 1420 size ); 1421 } 1417 1422 1418 1423 // set output argument to client RPC descriptor … … 1421 1426 rpc_dmsg("\n[INFO] %s : completed at cycle %d\n", __FUNCTION__ , hal_time_stamp() ); 1422 1427 } 1428 1429 ///////////////////////////////////////////////////////////////////////////////////////// 1430 // [25] Marshaling functions attached to RPC_MAPPER_GET_PAGE 1431 ///////////////////////////////////////////////////////////////////////////////////////// 1432 1433 /////////////////////////////////////////////////////// 1434 void rpc_mapper_get_page_client( cxy_t cxy, 1435 struct mapper_s * mapper, // in 1436 uint32_t index, // in 1437 page_t ** page ) // out 1438 { 1439 rpc_dmsg("\n[INFO] %s : enter at cycle %d\n", __FUNCTION__ , hal_time_stamp() ); 1440 1441 assert( (cxy != local_cxy) , __FUNCTION__ , "target cluster is not remote\n"); 1442 1443 // initialise RPC descriptor header 1444 rpc_desc_t rpc; 1445 rpc.index = RPC_MAPPER_GET_PAGE; 1446 rpc.response = 1; 1447 1448 // set input arguments in RPC descriptor 1449 rpc.args[0] = (uint64_t)(intptr_t)mapper; 1450 rpc.args[1] = (uint64_t)index; 1451 1452 // register RPC request in remote RPC fifo (blocking function) 1453 rpc_send_sync( cxy , &rpc ); 1454 1455 // get output values from RPC descriptor 1456 *page = (page_t *)(intptr_t)rpc.args[2]; 1457 1458 rpc_dmsg("\n[INFO] %s : completed at cycle %d\n", __FUNCTION__ , hal_time_stamp() ); 1459 } 1460 1461 //////////////////////////////////////////// 1462 void rpc_mapper_get_page_server( xptr_t xp ) 1463 { 1464 rpc_dmsg("\n[INFO] %s : enter at cycle %d\n", __FUNCTION__ , hal_time_stamp() ); 1465 1466 // get client cluster identifier and pointer on RPC descriptor 1467 cxy_t cxy = (cxy_t)GET_CXY( xp ); 1468 rpc_desc_t * desc = (rpc_desc_t *)GET_PTR( xp ); 1469 1470 // get input arguments from client RPC descriptor 1471 mapper_t * mapper = (mapper_t *)(intptr_t)hal_remote_lwd( XPTR( cxy , &desc->args[0] ) ); 1472 uint32_t index = (uint32_t) hal_remote_lwd( XPTR( cxy , &desc->args[1] ) ); 1473 1474 // call local pmem allocator 1475 page_t * page = mapper_get_page( mapper , index ); 1476 1477 // set output arguments into client RPC descriptor 1478 hal_remote_swd( XPTR( cxy , &desc->args[1] ) , (uint64_t)(intptr_t)page ); 1479 1480 rpc_dmsg("\n[INFO] %s : completed at cycle %d\n", __FUNCTION__ , hal_time_stamp() ); 1481 } 1482 1423 1483 1424 1484 /***************************************************************************************/
Note: See TracChangeset
for help on using the changeset viewer.