Changeset 5 for trunk/kernel/kern/rpc.c
- Timestamp:
- Apr 26, 2017, 2:11:56 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/kernel/kern/rpc.c
r1 r5 33 33 #include <core.h> 34 34 #include <mapper.h> 35 #include < device.h>35 #include <chdev.h> 36 36 #include <bits.h> 37 37 #include <thread.h> … … 55 55 &rpc_thread_user_create_server, // 4 56 56 &rpc_thread_kernel_create_server, // 5 57 &rpc_ icu_wti_alloc_server,// 658 &rpc_ device_alloc_server,// 757 &rpc_undefined, // 6 58 &rpc_undefined, // 7 59 59 &rpc_undefined, // 8 60 60 &rpc_undefined, // 9 … … 1018 1018 1019 1019 ///////////////////////////////////////////////////////////////////////////////////////// 1020 // Marshaling functions attached to RPC_ICU_WTI_ALLOC1021 /////////////////////////////////////////////////////////////////////////////////////////1022 1023 //////////////////////////////////////////////1024 void rpc_icu_wti_alloc_client( cxy_t cxy,1025 uint32_t * wti_id ) // out1026 {1027 // RPC must be remote1028 if( cxy == local_cxy )1029 {1030 printk("PANIC in %s : target is not remote\n", __FUNCTION__ );1031 hal_core_sleep();1032 }1033 1034 // initialise RPC descriptor header1035 rpc_desc_t rpc;1036 rpc.index = RPC_ICU_WTI_ALLOC;1037 rpc.response = 1;1038 1039 // register RPC request in remote RPC fifo1040 rpc_send_sync( cxy , &rpc );1041 1042 // get output argument from rpc descriptor1043 *wti_id = (uint32_t)rpc.args[0];1044 }1045 1046 //////////////////////////////////////////1047 void rpc_icu_wti_alloc_server( xptr_t xp )1048 {1049 uint32_t wti_id;1050 1051 // get client cluster identifier and pointer on RPC descriptor1052 cxy_t client_cxy = (cxy_t)GET_CXY( xp );1053 rpc_desc_t * desc = (rpc_desc_t *)GET_PTR( xp );1054 1055 // call icu_wti_alloc() function1056 wti_id = dev_icu_wti_alloc();1057 1058 // set output argument1059 hal_remote_swd( XPTR( client_cxy , &desc->args[0] ) , (uint64_t)wti_id);1060 }1061 1062 /////////////////////////////////////////////////////////////////////////////////////////1063 // Marshaling functions attached to RPC_DEVICE_ALLOC1064 /////////////////////////////////////////////////////////////////////////////////////////1065 1066 /////////////////////////////////////////////1067 void rpc_device_alloc_client( cxy_t cxy,1068 xptr_t * dev_xp, // out1069 error_t * error ) // out1070 {1071 // RPC must be remote1072 if( cxy == local_cxy )1073 {1074 printk("PANIC in %s : target is not remote\n", __FUNCTION__ );1075 hal_core_sleep();1076 }1077 1078 // initialise RPC descriptor header1079 rpc_desc_t rpc;1080 rpc.index = RPC_DEVICE_ALLOC;1081 rpc.response = 1;1082 1083 // register RPC request in remote RPC fifo1084 rpc_send_sync( cxy , &rpc );1085 1086 // get output argument from rpc descriptor1087 *dev_xp = (xptr_t)rpc.args[0];1088 *error = (error_t)rpc.args[1];1089 }1090 1091 /////////////////////////////////////////1092 void rpc_device_alloc_server( xptr_t xp )1093 {1094 error_t error;1095 kmem_req_t req;1096 device_t * dev_ptr;1097 xptr_t dev_xp;1098 1099 // get client cluster identifier and pointer on RPC descriptor1100 cxy_t client_cxy = (cxy_t)GET_CXY( xp );1101 rpc_desc_t * desc = (rpc_desc_t *)GET_PTR( xp );1102 1103 // allocate memory for a device descriptor1104 req.type = KMEM_DEVICE;1105 req.flags = AF_ZERO;1106 dev_ptr = (device_t *)kmem_alloc( &req );1107 1108 // set output arguments1109 error = ( dev_ptr == NULL );1110 dev_xp = XPTR( local_cxy , dev_ptr );1111 hal_remote_swd( XPTR( client_cxy , &desc->args[0] ) , (uint64_t)dev_xp );1112 hal_remote_swd( XPTR( client_cxy , &desc->args[1] ) , (uint64_t)error );1113 }1114 1115 1116 /////////////////////////////////////////////////////////////////////////////////////////1117 1020 // Marshaling functions attached to RPC_FATFS_GET_CLUSTER 1118 1021 ///////////////////////////////////////////////////////////////////////////////////////// … … 1190 1093 bool_t first; 1191 1094 reg_t sr_save; 1095 1096 printk("\n@@@ coucou 0\n"); 1192 1097 1193 1098 // get client CPU and cluster coordinates … … 1220 1125 while( error ); 1221 1126 1127 printk("\n@@@ coucou 1\n"); 1128 1222 1129 rpc_dmsg("\n[INFO] %s on core %d in cluster %x sent RPC %p to cluster %x\n", 1223 1130 __FUNCTION__ , client_lid , client_cxy , rpc , server_cxy ); … … 1240 1147 } 1241 1148 1149 printk("\n@@@ coucou 2\n"); 1150 1242 1151 // activate preemption to allow incoming RPC and avoid deadlock 1243 1152 if( this->type == THREAD_RPC ) hal_enable_irq( &sr_save ); … … 1248 1157 if( rpc->response == 0 ) break; 1249 1158 } 1159 1160 printk("\n@@@ coucou 3\n"); 1250 1161 1251 1162 // restore preemption … … 1425 1336 error_t error; 1426 1337 1427 // donothing if light lock already taken or FIFO empty1338 // calling thread does nothing if light lock already taken or FIFO empty 1428 1339 if( (rpc_fifo->owner != 0) || (local_fifo_is_empty( &rpc_fifo->fifo )) ) 1429 1340 { … … 1431 1342 } 1432 1343 1433 // The calling thread tryto take the light lock,1434 // and activate an RPC thread if success1344 // calling thread tries to take the light lock, 1345 // and activates an RPC thread if success 1435 1346 if( hal_atomic_test_set( &rpc_fifo->owner , this->trdid ) ) 1436 1347 { … … 1452 1363 return false; 1453 1364 } 1454 } // end __rpc_check()1365 } // end rpc_check() 1455 1366 1456 1367
Note: See TracChangeset
for help on using the changeset viewer.