Changeset 610 for trunk/kernel/kern/rpc.c
- Timestamp:
- Dec 27, 2018, 7:38:58 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/kernel/kern/rpc.c
r601 r610 75 75 &rpc_kcm_alloc_server, // 22 76 76 &rpc_kcm_free_server, // 23 77 &rpc_ mapper_move_user_server, // 2477 &rpc_undefined, // 24 unused slot 78 78 &rpc_mapper_handle_miss_server, // 25 79 79 &rpc_undefined, // 26 unused slot … … 111 111 "KCM_ALLOC", // 22 112 112 "KCM_FREE", // 23 113 " MAPPER_MOVE_USER",// 24113 "undefined", // 24 114 114 "MAPPER_HANDLE_MISS", // 25 115 115 "undefined", // 26 … … 302 302 uint32_t cycle = (uint32_t)hal_get_cycles(); 303 303 if( DEBUG_RPC_SERVER_GENERIC < cycle ) 304 printk("\n[ DBG] %s :RPC thread %x on core[%d] takes RPC_FIFO ownership / cycle %d\n",304 printk("\n[%s] RPC thread %x on core[%d] takes RPC_FIFO ownership / cycle %d\n", 305 305 __FUNCTION__, server_ptr->trdid, server_core_lid, cycle ); 306 306 #endif … … 318 318 desc_ptr = GET_PTR( desc_xp ); 319 319 320 index = hal_remote_l32( XPTR( desc_cxy , &desc_ptr->index ) ); 321 blocking = hal_remote_l32( XPTR( desc_cxy , &desc_ptr->blocking ) ); 320 index = hal_remote_l32( XPTR( desc_cxy , &desc_ptr->index ) ); 321 blocking = hal_remote_l32( XPTR( desc_cxy , &desc_ptr->blocking ) ); 322 client_ptr = hal_remote_lpt( XPTR( desc_cxy , &desc_ptr->thread ) ); 322 323 323 324 #if DEBUG_RPC_SERVER_GENERIC … … 325 326 uint32_t items = remote_fifo_items( XPTR( local_cxy , rpc_fifo ) ); 326 327 if( DEBUG_RPC_SERVER_GENERIC < cycle ) 327 printk("\n[ DBG] %s :RPC thread %x got rpc %s / client_cxy %x / items %d / cycle %d\n",328 printk("\n[%s] RPC thread %x got rpc %s / client_cxy %x / items %d / cycle %d\n", 328 329 __FUNCTION__, server_ptr->trdid, rpc_str[index], desc_cxy, items, cycle ); 329 330 #endif 331 // register client thread in RPC thread descriptor 332 server_ptr->rpc_client_xp = XPTR( desc_cxy , client_ptr ); 333 330 334 // call the relevant server function 331 335 rpc_server[index]( desc_xp ); … … 334 338 cycle = (uint32_t)hal_get_cycles(); 335 339 if( DEBUG_RPC_SERVER_GENERIC < cycle ) 336 printk("\n[ DBG] %s :RPC thread %x completes rpc %s / client_cxy %x / cycle %d\n",340 printk("\n[%s] RPC thread %x completes rpc %s / client_cxy %x / cycle %d\n", 337 341 __FUNCTION__, server_ptr->trdid, rpc_str[index], desc_cxy, cycle ); 338 342 #endif … … 355 359 cycle = (uint32_t)hal_get_cycles(); 356 360 if( DEBUG_RPC_SERVER_GENERIC < cycle ) 357 printk("\n[ DBG] %s :RPC thread %x unblocked client thread %x / cycle %d\n",361 printk("\n[%s] RPC thread %x unblocked client thread %x / cycle %d\n", 358 362 __FUNCTION__, server_ptr->trdid, client_ptr->trdid, cycle ); 359 363 #endif … … 372 376 uint32_t cycle = (uint32_t)hal_get_cycles(); 373 377 if( DEBUG_RPC_SERVER_GENERIC < cycle ) 374 printk("\n[ DBG] %s :RPC thread %x suicides / cycle %d\n",378 printk("\n[%s] RPC thread %x suicides / cycle %d\n", 375 379 __FUNCTION__, server_ptr->trdid, cycle ); 376 380 #endif … … 391 395 uint32_t cycle = (uint32_t)hal_get_cycles(); 392 396 if( DEBUG_RPC_SERVER_GENERIC < cycle ) 393 printk("\n[ DBG] %s :RPC thread %x block IDLE & deschedules / cycle %d\n",397 printk("\n[%s] RPC thread %x block IDLE & deschedules / cycle %d\n", 394 398 __FUNCTION__, server_ptr->trdid, cycle ); 395 399 #endif … … 870 874 uint32_t action = rpc->args[0]; 871 875 pid_t pid = rpc->args[1]; 876 thread_t * this = CURRENT_THREAD; 872 877 if( DEBUG_RPC_PROCESS_SIGACTION < cycle ) 873 printk("\n[ DBG] %s :enter to request %s of process %x in cluster %x / cycle %d\n",874 __FUNCTION__ , process_action_str( action ) , pid , cxy, cycle );878 printk("\n[%s] thread[%x,%x] enter to request %s of process %x in cluster %x / cycle %d\n", 879 __FUNCTION__, this->process->pid, this->trdid, process_action_str(action), pid, cxy, cycle ); 875 880 #endif 876 881 … … 885 890 cycle = (uint32_t)hal_get_cycles(); 886 891 if( DEBUG_RPC_PROCESS_SIGACTION < cycle ) 887 printk("\n[ DBG] %s : exit after requesting to %sprocess %x in cluster %x / cycle %d\n",888 __FUNCTION__ , process_action_str( action ) , pid , cxy, cycle );892 printk("\n[%s] thread[%x,%x] requested %s of process %x in cluster %x / cycle %d\n", 893 __FUNCTION__, this->process->pid, this->trdid, process_action_str(action), pid, cxy, cycle ); 889 894 #endif 890 895 … … 915 920 #if DEBUG_RPC_PROCESS_SIGACTION 916 921 uint32_t cycle = (uint32_t)hal_get_cycles(); 922 thread_t * this = CURRENT_THREAD; 917 923 if( DEBUG_RPC_PROCESS_SIGACTION < cycle ) 918 printk("\n[DBG] %s : enter to %s process %x in cluster %x / cycle %d\n", 919 __FUNCTION__ , process_action_str( action ) , pid , local_cxy , cycle ); 924 printk("\n[%s] thread[%x,%x] enter to %s process %x in cluster %x / cycle %d\n", 925 __FUNCTION__, this->process->pid, this->trdid, 926 process_action_str( action ), pid, local_cxy, cycle ); 920 927 #endif 921 928 … … 954 961 cycle = (uint32_t)hal_get_cycles(); 955 962 if( DEBUG_RPC_PROCESS_SIGACTION < cycle ) 956 printk("\n[DBG] %s : exit after %s process %x in cluster %x / cycle %d\n", 957 __FUNCTION__ , process_action_str( action ) , pid , local_cxy , cycle ); 963 printk("\n[%s] thread[%x,%x] exit after %s process %x in cluster %x / cycle %d\n", 964 __FUNCTION__, this->process->pid, this->trdid, 965 process_action_str( action ), pid, local_cxy, cycle ); 958 966 #endif 959 967 … … 966 974 ///////////////////////////////////////////////////// 967 975 void rpc_vfs_inode_create_client( cxy_t cxy, 968 xptr_t dentry_xp, // in969 976 uint32_t fs_type, // in 970 977 uint32_t inode_type, // in … … 993 1000 994 1001 // set input arguments in RPC descriptor 995 rpc.args[0] = (uint64_t)dentry_xp; 996 rpc.args[1] = (uint64_t)fs_type; 997 rpc.args[2] = (uint64_t)inode_type; 998 rpc.args[3] = (uint64_t)attr; 999 rpc.args[4] = (uint64_t)rights; 1000 rpc.args[5] = (uint64_t)uid; 1001 rpc.args[6] = (uint64_t)gid; 1002 rpc.args[0] = (uint64_t)fs_type; 1003 rpc.args[1] = (uint64_t)inode_type; 1004 rpc.args[2] = (uint64_t)attr; 1005 rpc.args[3] = (uint64_t)rights; 1006 rpc.args[4] = (uint64_t)uid; 1007 rpc.args[5] = (uint64_t)gid; 1002 1008 1003 1009 // register RPC request in remote RPC fifo … … 1005 1011 1006 1012 // get output values from RPC descriptor 1007 *inode_xp = (xptr_t)rpc.args[ 7];1008 *error = (error_t)rpc.args[ 8];1013 *inode_xp = (xptr_t)rpc.args[6]; 1014 *error = (error_t)rpc.args[7]; 1009 1015 1010 1016 #if DEBUG_RPC_VFS_INODE_CREATE … … 1027 1033 #endif 1028 1034 1029 xptr_t dentry_xp;1030 1035 uint32_t fs_type; 1031 1036 uint32_t inode_type; … … 1042 1047 1043 1048 // get input arguments from client rpc descriptor 1044 dentry_xp = (xptr_t) hal_remote_l64( XPTR( client_cxy , &desc->args[0] ) ); 1045 fs_type = (uint32_t) hal_remote_l64( XPTR( client_cxy , &desc->args[1] ) ); 1046 inode_type = (uint32_t) hal_remote_l64( XPTR( client_cxy , &desc->args[2] ) ); 1047 attr = (uint32_t) hal_remote_l64( XPTR( client_cxy , &desc->args[3] ) ); 1048 rights = (uint32_t) hal_remote_l64( XPTR( client_cxy , &desc->args[4] ) ); 1049 uid = (uid_t) hal_remote_l64( XPTR( client_cxy , &desc->args[5] ) ); 1050 gid = (gid_t) hal_remote_l64( XPTR( client_cxy , &desc->args[6] ) ); 1049 fs_type = (uint32_t) hal_remote_l64( XPTR( client_cxy , &desc->args[0] ) ); 1050 inode_type = (uint32_t) hal_remote_l64( XPTR( client_cxy , &desc->args[1] ) ); 1051 attr = (uint32_t) hal_remote_l64( XPTR( client_cxy , &desc->args[2] ) ); 1052 rights = (uint32_t) hal_remote_l64( XPTR( client_cxy , &desc->args[3] ) ); 1053 uid = (uid_t) hal_remote_l64( XPTR( client_cxy , &desc->args[4] ) ); 1054 gid = (gid_t) hal_remote_l64( XPTR( client_cxy , &desc->args[5] ) ); 1051 1055 1052 1056 // call local kernel function 1053 error = vfs_inode_create( dentry_xp, 1054 fs_type, 1057 error = vfs_inode_create( fs_type, 1055 1058 inode_type, 1056 1059 attr, … … 1061 1064 1062 1065 // set output arguments 1063 hal_remote_s64( XPTR( client_cxy , &desc->args[ 7] ) , (uint64_t)inode_xp );1064 hal_remote_s64( XPTR( client_cxy , &desc->args[ 8] ) , (uint64_t)error );1066 hal_remote_s64( XPTR( client_cxy , &desc->args[6] ) , (uint64_t)inode_xp ); 1067 hal_remote_s64( XPTR( client_cxy , &desc->args[7] ) , (uint64_t)error ); 1065 1068 1066 1069 #if DEBUG_RPC_VFS_INODE_CREATE … … 1149 1152 uint32_t type, // in 1150 1153 char * name, // in 1151 struct vfs_inode_s * parent, // in1152 1154 xptr_t * dentry_xp, // out 1153 1155 error_t * error ) // out … … 1172 1174 rpc.args[0] = (uint64_t)type; 1173 1175 rpc.args[1] = (uint64_t)(intptr_t)name; 1174 rpc.args[2] = (uint64_t)(intptr_t)parent;1175 1176 1176 1177 // register RPC request in remote RPC fifo … … 1178 1179 1179 1180 // get output values from RPC descriptor 1180 *dentry_xp = (xptr_t)rpc.args[ 3];1181 *error = (error_t)rpc.args[ 4];1181 *dentry_xp = (xptr_t)rpc.args[2]; 1182 *error = (error_t)rpc.args[3]; 1182 1183 1183 1184 #if DEBUG_RPC_VFS_DENTRY_CREATE … … 1202 1203 uint32_t type; 1203 1204 char * name; 1204 vfs_inode_t * parent;1205 1205 xptr_t dentry_xp; 1206 1206 error_t error; … … 1212 1212 1213 1213 // get arguments "name", "type", and "parent" from client RPC descriptor 1214 type = (uint32_t) hal_remote_l64( XPTR( client_cxy , &desc->args[0] ) ); 1215 name = (char *)(intptr_t) hal_remote_l64( XPTR( client_cxy , &desc->args[1] ) ); 1216 parent = (vfs_inode_t *)(intptr_t)hal_remote_l64( XPTR( client_cxy , &desc->args[2] ) ); 1214 type = (uint32_t) hal_remote_l64( XPTR( client_cxy , &desc->args[0] ) ); 1215 name = (char *)(intptr_t) hal_remote_l64( XPTR( client_cxy , &desc->args[1] ) ); 1217 1216 1218 1217 // makes a local copy of name … … 1223 1222 error = vfs_dentry_create( type, 1224 1223 name_copy, 1225 parent,1226 1224 &dentry_xp ); 1227 1225 // set output arguments 1228 hal_remote_s64( XPTR( client_cxy , &desc->args[ 3] ) , (uint64_t)dentry_xp );1229 hal_remote_s64( XPTR( client_cxy , &desc->args[ 4] ) , (uint64_t)error );1226 hal_remote_s64( XPTR( client_cxy , &desc->args[2] ) , (uint64_t)dentry_xp ); 1227 hal_remote_s64( XPTR( client_cxy , &desc->args[3] ) , (uint64_t)error ); 1230 1228 1231 1229 #if DEBUG_RPC_VFS_DENTRY_CREATE … … 2112 2110 2113 2111 ///////////////////////////////////////////////////////////////////////////////////////// 2114 // [24] Marshaling functions attached to RPC_MAPPER_MOVE_USER 2115 ///////////////////////////////////////////////////////////////////////////////////////// 2116 2117 ///////////////////////////////////////////////// 2118 void rpc_mapper_move_user_client( cxy_t cxy, 2119 mapper_t * mapper, // in 2120 bool_t to_buffer, // in 2121 uint32_t file_offset, // in 2122 void * buffer, // in 2123 uint32_t size, // in 2124 error_t * error ) // out 2125 { 2126 #if DEBUG_RPC_MAPPER_MOVE_USER 2127 uint32_t cycle = (uint32_t)hal_get_cycles(); 2128 if( cycle > DEBUG_RPC_MAPPER_MOVE_USER ) 2129 printk("\n[%s] thread[%x,%x] on core %d enter / cycle %d\n", 2130 __FUNCTION__, this->process->pid, this->trdid, this->core->lid , cycle ); 2131 #endif 2132 2133 assert( (cxy != local_cxy) , "target cluster is not remote\n"); 2134 2135 // initialise RPC descriptor header 2136 rpc_desc_t rpc; 2137 rpc.index = RPC_MAPPER_MOVE_USER; 2138 rpc.blocking = true; 2139 rpc.responses = 1; 2140 2141 // set input arguments in RPC descriptor 2142 rpc.args[0] = (uint64_t)(intptr_t)mapper; 2143 rpc.args[1] = (uint64_t)to_buffer; 2144 rpc.args[2] = (uint64_t)file_offset; 2145 rpc.args[3] = (uint64_t)(intptr_t)buffer; 2146 rpc.args[4] = (uint64_t)size; 2147 2148 // register RPC request in remote RPC fifo 2149 rpc_send( cxy , &rpc ); 2150 2151 // get output values from RPC descriptor 2152 *error = (error_t)rpc.args[5]; 2153 2154 #if DEBUG_RPC_MAPPER_MOVE_USER 2155 cycle = (uint32_t)hal_get_cycles(); 2156 if( cycle > DEBUG_RPC_MAPPER_MOVE_USER ) 2157 printk("\n[%s] thread[%x,%x] on core %d exit / cycle %d\n", 2158 __FUNCTION__, this->process->pid, this->trdid, this->core->lid , cycle ); 2159 #endif 2160 } 2161 2162 ///////////////////////////////////////////// 2163 void rpc_mapper_move_user_server( xptr_t xp ) 2164 { 2165 #if DEBUG_RPC_MAPPER_MOVE_USER 2166 uint32_t cycle = (uint32_t)hal_get_cycles(); 2167 if( cycle > DEBUG_RPC_MAPPER_MOVE_USER ) 2168 printk("\n[%s] thread[%x,%x] on core %d enter / cycle %d\n", 2169 __FUNCTION__, this->process->pid, this->trdid, this->core->lid , cycle ); 2170 #endif 2171 2172 mapper_t * mapper; 2173 bool_t to_buffer; 2174 uint32_t file_offset; 2175 void * buffer; 2176 uint32_t size; 2177 error_t error; 2178 2179 // get client cluster identifier and pointer on RPC descriptor 2180 cxy_t client_cxy = GET_CXY( xp ); 2181 rpc_desc_t * desc = GET_PTR( xp ); 2182 2183 // get arguments from client RPC descriptor 2184 mapper = (mapper_t *)(intptr_t)hal_remote_l64( XPTR( client_cxy , &desc->args[0] ) ); 2185 to_buffer = hal_remote_l64( XPTR( client_cxy , &desc->args[1] ) ); 2186 file_offset = hal_remote_l64( XPTR( client_cxy , &desc->args[2] ) ); 2187 buffer = (void *)(intptr_t) hal_remote_l64( XPTR( client_cxy , &desc->args[3] ) ); 2188 size = hal_remote_l64( XPTR( client_cxy , &desc->args[4] ) ); 2189 2190 // call local kernel function 2191 error = mapper_move_user( mapper, 2192 to_buffer, 2193 file_offset, 2194 buffer, 2195 size ); 2196 2197 // set output argument to client RPC descriptor 2198 hal_remote_s64( XPTR( client_cxy , &desc->args[6] ) , (uint64_t)error ); 2199 2200 #if DEBUG_RPC_MAPPER_MOVE_USER 2201 cycle = (uint32_t)hal_get_cycles(); 2202 if( cycle > DEBUG_RPC_MAPPER_MOVE_USER ) 2203 printk("\n[%s] thread[%x,%x] on core %d exit / cycle %d\n", 2204 __FUNCTION__, this->process->pid, this->trdid, this->core->lid , cycle ); 2205 #endif 2206 } 2112 // [24] undefined slot 2113 ///////////////////////////////////////////////////////////////////////////////////////// 2207 2114 2208 2115 ///////////////////////////////////////////////////////////////////////////////////////// … … 2280 2187 2281 2188 // set output argument to client RPC descriptor 2282 hal_remote_s64( XPTR( client_cxy , &desc->args[2] ) , (uint64_t) error);2283 hal_remote_s64( XPTR( client_cxy , &desc->args[3] ) , (uint64_t) page_xp);2189 hal_remote_s64( XPTR( client_cxy , &desc->args[2] ) , (uint64_t)page_xp ); 2190 hal_remote_s64( XPTR( client_cxy , &desc->args[3] ) , (uint64_t)error ); 2284 2191 2285 2192 #if DEBUG_RPC_MAPPER_HANDLE_MISS
Note: See TracChangeset
for help on using the changeset viewer.