Changeset 313 for trunk/kernel/kern
- Timestamp:
- Aug 2, 2017, 3:24:57 PM (7 years ago)
- Location:
- trunk/kernel/kern
- Files:
-
- 2 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 /***************************************************************************************/ -
trunk/kernel/kern/rpc.h
r296 r313 35 35 36 36 struct process_s; 37 struct page_s; 37 38 struct vseg_s; 38 39 struct exec_info_s; … … 80 81 RPC_KCM_FREE = 23, 81 82 RPC_MAPPER_MOVE_BUFFER = 24, 83 RPC_MAPPER_GET_PAGE = 25, 82 84 83 85 RPC_MAX_INDEX = 30, … … 204 206 /*********************************************************************************** 205 207 * [0] The RPC_PMEM_GET_PAGES allocates one or several pages in a remote cluster, 206 * and returns the PPN of the first allocated page.208 * and returns the local pointer on the page descriptor. 207 209 *********************************************************************************** 208 210 * @ cxy : server cluster identifier 209 211 * @ order : [in] ln2( number of requested pages ) 210 * @ error : [out] error status (0 if success) 211 * @ ppn : [out] first physical page number 212 **********************************************************************************/ 213 void rpc_pmem_get_pages_client( cxy_t cxy, 214 uint32_t order, 215 error_t * error, 216 uint32_t * ppn ); 212 * @ page : [out] local pointer on page descriptor / NULL if failure 213 **********************************************************************************/ 214 void rpc_pmem_get_pages_client( cxy_t cxy, 215 uint32_t order, 216 struct page_s ** page ); 217 217 218 218 void rpc_pmem_get_pages_server( xptr_t xp ); … … 550 550 551 551 /*********************************************************************************** 552 * [24] The RPC_MAPPER_MOVE_USER is called by the vfs_move() function. 553 * It allows a client thread to requires a remote mapper to move data to/from 554 * an user buffer, as specified by the arguments. 552 * [24] The RPC_MAPPER_MOVE_BUFFER allows a client thread to require a remote 553 * mapper to move data to/from a kernel or user buffer. 554 * - It calls the mapper_move_user() function for a - possibly distributed - 555 * user buffer identified by a user-space pointer, and casted to uint64_t. 556 * - It calls the mapper_move_kernel() function for a - possibly remote - 557 * kernel buffer identified by an extended pointer, and casted to uint64_t. 558 * It is used by the vfs_move_user() function to move data between a mapper 559 * and an user buffer required by a sys_read() or a sys_write(). 560 * It is used by the vmm_get_one_ppn() function to initialise a physical page 561 * from a .elf file mapper, for a CODE or DATA vseg page fault. 555 562 *********************************************************************************** 556 563 * @ cxy : server cluster identifier. 557 564 * @ mapper : [in] local pointer on mapper 558 * @ to_buffer : [in] move data from buffer to mapper if non zero.559 * @ is_user : [in] buffer in user space if non zero.565 * @ to_buffer : [in] move data from mapper to buffer if non zero. 566 * @ is_user : [in] buffer in user space if true 560 567 * @ file_offset : [in] first byte to move in mapper 561 * @ buffer : [in] pointer on buffer in user space568 * @ buffer : [in] user space pointer / kernel extended pointer 562 569 * @ size : [in] number of bytes to move 563 570 * @ error : [out] error status (0 if success). … … 568 575 bool_t is_user, 569 576 uint32_t file_offset, 570 void *buffer,577 uint64_t buffer, 571 578 uint32_t size, 572 579 error_t * error ); … … 574 581 void rpc_mapper_move_buffer_server( xptr_t xp ); 575 582 576 577 583 /*********************************************************************************** 584 * [25] The RPC_MAPPER_GET_PAGE allows a client thread to get the local pointer 585 * on a remote page descriptor, for a page, identified by the page index in mapper. 586 * It is used by the vmm_get_one_ppn() function to handle a page fault on 587 * a FILE type vseg. 588 *********************************************************************************** 589 * @ cxy : server cluster identifier. 590 * @ mapper : [in] local pointer on mapper. 591 * @ index : [in] page index in mapper. 592 * @ page : [out] local pointer on page descriptor / NULL if failure. 593 **********************************************************************************/ 594 void rpc_mapper_get_page_client( cxy_t cxy, 595 struct mapper_s * mapper, 596 uint32_t index, 597 struct page_s ** page ); 598 599 void rpc_mapper_get_page_server( xptr_t xp ); 578 600 579 601 #endif
Note: See TracChangeset
for help on using the changeset viewer.