Changeset 01c3bb4 in mainline for uspace/lib/c
- Timestamp:
- 2017-11-25T15:43:25Z (8 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- ce4a21a0
- Parents:
- 98cb5e0d
- Location:
- uspace/lib/c
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/generic/async.c
r98cb5e0d r01c3bb4 77 77 * } 78 78 * 79 * port_handler(ic allid, *icall)79 * port_handler(ichandle, *icall) 80 80 * { 81 81 * if (want_refuse) { 82 * async_answer_0(ic allid, ELIMIT);82 * async_answer_0(ichandle, ELIMIT); 83 83 * return; 84 84 * } 85 * async_answer_0(ic allid, EOK);86 * 87 * c allid= async_get_call(&call);88 * somehow_handle_the_call(c allid, call);89 * async_answer_2(c allid, 1, 2, 3);90 * 91 * c allid= async_get_call(&call);85 * async_answer_0(ichandle, EOK); 86 * 87 * chandle = async_get_call(&call); 88 * somehow_handle_the_call(chandle, call); 89 * async_answer_2(chandle, 1, 2, 3); 90 * 91 * chandle = async_get_call(&call); 92 92 * ... 93 93 * } … … 185 185 link_t link; 186 186 187 ipc_callid_t callid;187 cap_handle_t chandle; 188 188 ipc_call_t call; 189 189 } msg_t; … … 237 237 238 238 /** Identification of the opening call. */ 239 ipc_callid_t callid;239 cap_handle_t chandle; 240 240 241 241 /** Call data of the opening call. */ … … 243 243 244 244 /** Identification of the closing call. */ 245 ipc_callid_t close_callid;245 cap_handle_t close_chandle; 246 246 247 247 /** Fibril function that will be used to handle the connection. */ … … 374 374 /** Default fallback fibril function. 375 375 * 376 * This fallback fibril function gets called on incomming 377 * connections that donot have a specific handler defined.378 * 379 * @param c allid Hashof the incoming call.380 * @param call Data of the incoming call.381 * @param arg Local argument382 * 383 */ 384 static void default_fallback_port_handler( ipc_callid_t callid, ipc_call_t *call,385 void *arg)386 { 387 ipc_answer_0(c allid, ENOENT);376 * This fallback fibril function gets called on incomming connections that do 377 * not have a specific handler defined. 378 * 379 * @param chandle Handle of the incoming call. 380 * @param call Data of the incoming call. 381 * @param arg Local argument 382 * 383 */ 384 static void default_fallback_port_handler(cap_handle_t chandle, 385 ipc_call_t *call, void *arg) 386 { 387 ipc_answer_0(chandle, ENOENT); 388 388 } 389 389 … … 715 715 client_t *client = async_client_get(fibril_connection->in_task_id, true); 716 716 if (!client) { 717 ipc_answer_0(fibril_connection->c allid, ENOMEM);717 ipc_answer_0(fibril_connection->chandle, ENOMEM); 718 718 return 0; 719 719 } … … 724 724 * Call the connection handler function. 725 725 */ 726 fibril_connection->handler(fibril_connection->c allid,726 fibril_connection->handler(fibril_connection->chandle, 727 727 &fibril_connection->call, fibril_connection->data); 728 728 … … 751 751 752 752 list_remove(&msg->link); 753 ipc_answer_0(msg->c allid, EHANGUP);753 ipc_answer_0(msg->chandle, EHANGUP); 754 754 free(msg); 755 755 } … … 759 759 * i.e. IPC_M_PHONE_HUNGUP. 760 760 */ 761 if (fibril_connection->close_c allid)762 ipc_answer_0(fibril_connection->close_c allid, EOK);761 if (fibril_connection->close_chandle) 762 ipc_answer_0(fibril_connection->close_chandle, EOK); 763 763 764 764 free(fibril_connection); … … 768 768 /** Create a new fibril for a new connection. 769 769 * 770 * Create new fibril for connection, fill in connection structures 771 * and insert it into the hash table, so that later we can easily772 * do routing of messages toparticular fibrils.773 * 774 * @param in_task_id Identification of the incoming connection.775 * @param in_phone_hash Identification of the incoming connection.776 * @param c allid Hashof the opening IPC_M_CONNECT_ME_TO call.777 * If callid is zero, the connection was opened by778 * accepting the IPC_M_CONNECT_TO_ME call and this779 * function is called directly by the server.780 * @param call Call data of the opening call.781 * @param handler Connection handler.782 * @param data Client argument to pass to the connection handler.783 * 784 * @return New fibril id or NULL on failure.770 * Create new fibril for connection, fill in connection structures and insert it 771 * into the hash table, so that later we can easily do routing of messages to 772 * particular fibrils. 773 * 774 * @param in_task_id Identification of the incoming connection. 775 * @param in_phone_hash Identification of the incoming connection. 776 * @param chandle Handle of the opening IPC_M_CONNECT_ME_TO call. 777 * If chandle is CAP_NIL, the connection was opened by 778 * accepting the IPC_M_CONNECT_TO_ME call and this 779 * function is called directly by the server. 780 * @param call Call data of the opening call. 781 * @param handler Connection handler. 782 * @param data Client argument to pass to the connection handler. 783 * 784 * @return New fibril id or NULL on failure. 785 785 * 786 786 */ 787 787 static fid_t async_new_connection(task_id_t in_task_id, sysarg_t in_phone_hash, 788 ipc_callid_t callid, ipc_call_t *call, async_port_handler_t handler,788 cap_handle_t chandle, ipc_call_t *call, async_port_handler_t handler, 789 789 void *data) 790 790 { 791 791 connection_t *conn = malloc(sizeof(*conn)); 792 792 if (!conn) { 793 if (c allid)794 ipc_answer_0(c allid, ENOMEM);793 if (chandle != CAP_NIL) 794 ipc_answer_0(chandle, ENOMEM); 795 795 796 796 return (uintptr_t) NULL; … … 800 800 conn->in_phone_hash = in_phone_hash; 801 801 list_initialize(&conn->msg_queue); 802 conn->c allid = callid;803 conn->close_c allid = 0;802 conn->chandle = chandle; 803 conn->close_chandle = CAP_NIL; 804 804 conn->handler = handler; 805 805 conn->data = data; … … 815 815 free(conn); 816 816 817 if (c allid)818 ipc_answer_0(c allid, ENOMEM);817 if (chandle != CAP_NIL) 818 ipc_answer_0(chandle, ENOMEM); 819 819 820 820 return (uintptr_t) NULL; … … 892 892 893 893 fid_t fid = async_new_connection(answer.in_task_id, phone_hash, 894 0, NULL, handler, data);894 CAP_NIL, NULL, handler, data); 895 895 if (fid == (uintptr_t) NULL) 896 896 return ENOMEM; … … 961 961 * timeouts are unregistered. 962 962 * 963 * @param c allid Hashof the incoming call.964 * @param call Data of the incoming call.963 * @param chandle Handle of the incoming call. 964 * @param call Data of the incoming call. 965 965 * 966 966 * @return False if the call doesn't match any connection. … … 968 968 * 969 969 */ 970 static bool route_call( ipc_callid_t callid, ipc_call_t *call)970 static bool route_call(cap_handle_t chandle, ipc_call_t *call) 971 971 { 972 972 assert(call); … … 991 991 } 992 992 993 msg->c allid = callid;993 msg->chandle = chandle; 994 994 msg->call = *call; 995 995 list_append(&msg->link, &conn->msg_queue); 996 996 997 997 if (IPC_GET_IMETHOD(*call) == IPC_M_PHONE_HUNGUP) 998 conn->close_c allid = callid;998 conn->close_chandle = chandle; 999 999 1000 1000 /* If the connection fibril is waiting for an event, activate it */ … … 1017 1017 /** Process notification. 1018 1018 * 1019 * @param callid Hash of the incoming call.1020 1019 * @param call Data of the incoming call. 1021 1020 * 1022 1021 */ 1023 static void process_notification(ipc_call id_t callid, ipc_call_t *call)1022 static void process_notification(ipc_call_t *call) 1024 1023 { 1025 1024 async_notification_handler_t handler = NULL; … … 1042 1041 1043 1042 if (handler) 1044 handler(call id, call, data);1043 handler(call, data); 1045 1044 } 1046 1045 … … 1187 1186 /** Return new incoming message for the current (fibril-local) connection. 1188 1187 * 1189 * @param call Storage where the incoming call data will be stored. 1190 * @param usecs Timeout in microseconds. Zero denotes no timeout. 1191 * 1192 * @return If no timeout was specified, then a hash of the 1193 * incoming call is returned. If a timeout is specified, 1194 * then a hash of the incoming call is returned unless 1195 * the timeout expires prior to receiving a message. In 1196 * that case zero is returned. 1197 * 1198 */ 1199 ipc_callid_t async_get_call_timeout(ipc_call_t *call, suseconds_t usecs) 1188 * @param call Storage where the incoming call data will be stored. 1189 * @param usecs Timeout in microseconds. Zero denotes no timeout. 1190 * 1191 * @return If no timeout was specified, then a handle of the incoming call is 1192 * returned. If a timeout is specified, then a handle of the incoming 1193 * call is returned unless the timeout expires prior to receiving a 1194 * message. In that case zero CAP_NIL is returned. 1195 */ 1196 cap_handle_t async_get_call_timeout(ipc_call_t *call, suseconds_t usecs) 1200 1197 { 1201 1198 assert(call); … … 1220 1217 /* If nothing in queue, wait until something arrives */ 1221 1218 while (list_empty(&conn->msg_queue)) { 1222 if (conn->close_c allid) {1219 if (conn->close_chandle) { 1223 1220 /* 1224 1221 * Handle the case when the connection was already … … 1231 1228 IPC_SET_IMETHOD(*call, IPC_M_PHONE_HUNGUP); 1232 1229 futex_up(&async_futex); 1233 return conn->close_c allid;1230 return conn->close_chandle; 1234 1231 } 1235 1232 … … 1256 1253 /* If we timed out -> exit */ 1257 1254 futex_up(&async_futex); 1258 return 0;1255 return CAP_NIL; 1259 1256 } 1260 1257 } … … 1264 1261 list_remove(&msg->link); 1265 1262 1266 ipc_callid_t callid = msg->callid;1263 cap_handle_t chandle = msg->chandle; 1267 1264 *call = msg->call; 1268 1265 free(msg); 1269 1266 1270 1267 futex_up(&async_futex); 1271 return c allid;1268 return chandle; 1272 1269 } 1273 1270 … … 1332 1329 * Otherwise the call is routed to its connection fibril. 1333 1330 * 1334 * @param c allid Hashof the incoming call.1335 * @param call Data of the incoming call.1336 * 1337 */ 1338 static void handle_call( ipc_callid_t callid, ipc_call_t *call)1331 * @param chandle Handle of the incoming call. 1332 * @param call Data of the incoming call. 1333 * 1334 */ 1335 static void handle_call(cap_handle_t chandle, ipc_call_t *call) 1339 1336 { 1340 1337 assert(call); 1341 1338 1342 1339 /* Kernel notification */ 1343 if ( call->flags & IPC_CALLID_NOTIFICATION) {1340 if ((chandle == CAP_NIL) && (call->flags & IPC_CALLID_NOTIFICATION)) { 1344 1341 fibril_t *fibril = (fibril_t *) __tcb_get()->fibril_data; 1345 1342 unsigned oldsw = fibril->switches; 1346 1343 1347 process_notification(call id, call);1344 process_notification(call); 1348 1345 1349 1346 if (oldsw != fibril->switches) { … … 1371 1368 sysarg_t in_phone_hash = IPC_GET_ARG5(*call); 1372 1369 1373 async_ notification_handler_t handler = fallback_port_handler;1370 async_port_handler_t handler = fallback_port_handler; 1374 1371 void *data = fallback_port_data; 1375 1372 … … 1381 1378 } 1382 1379 1383 async_new_connection(call->in_task_id, in_phone_hash, c allid,1380 async_new_connection(call->in_task_id, in_phone_hash, chandle, 1384 1381 call, handler, data); 1385 1382 return; … … 1387 1384 1388 1385 /* Try to route the call through the connection hash table */ 1389 if (route_call(c allid, call))1386 if (route_call(chandle, call)) 1390 1387 return; 1391 1388 1392 1389 /* Unknown call from unknown phone - hang it up */ 1393 ipc_answer_0(c allid, EHANGUP);1390 ipc_answer_0(chandle, EHANGUP); 1394 1391 } 1395 1392 … … 1486 1483 1487 1484 ipc_call_t call; 1488 ipc_callid_t callid= ipc_wait_cycle(&call, timeout, flags);1485 cap_handle_t chandle = ipc_wait_cycle(&call, timeout, flags); 1489 1486 1490 1487 atomic_dec(&threads_in_ipc_wait); 1491 1488 1492 if (!callid) { 1493 handle_expired_timeouts(); 1494 continue; 1489 assert(chandle >= 0); 1490 1491 if (chandle == CAP_NIL) { 1492 if (call.flags == 0) { 1493 /* This neither a notification nor an answer. */ 1494 handle_expired_timeouts(); 1495 continue; 1496 } 1495 1497 } 1496 1498 1497 1499 if (call.flags & IPC_CALLID_ANSWERED) 1498 1500 continue; 1499 1500 handle_call(c allid, &call);1501 } 1502 1501 1502 handle_call(chandle, &call); 1503 } 1504 1503 1505 return 0; 1504 1506 } … … 1631 1633 * @param arg3 Service-defined payload argument. 1632 1634 * @param arg4 Service-defined payload argument. 1633 * @param dataptr If non-NULL, storage where the reply data will be 1634 * stored. 1635 * @param dataptr If non-NULL, storage where the reply data will be stored. 1635 1636 * 1636 1637 * @return Hash of the sent message or 0 on error. … … 2018 2019 } 2019 2020 2020 sysarg_t async_answer_0( ipc_callid_t callid, sysarg_t retval)2021 { 2022 return ipc_answer_0(c allid, retval);2023 } 2024 2025 sysarg_t async_answer_1( ipc_callid_t callid, sysarg_t retval, sysarg_t arg1)2026 { 2027 return ipc_answer_1(c allid, retval, arg1);2028 } 2029 2030 sysarg_t async_answer_2( ipc_callid_t callid, sysarg_t retval, sysarg_t arg1,2021 sysarg_t async_answer_0(cap_handle_t chandle, sysarg_t retval) 2022 { 2023 return ipc_answer_0(chandle, retval); 2024 } 2025 2026 sysarg_t async_answer_1(cap_handle_t chandle, sysarg_t retval, sysarg_t arg1) 2027 { 2028 return ipc_answer_1(chandle, retval, arg1); 2029 } 2030 2031 sysarg_t async_answer_2(cap_handle_t chandle, sysarg_t retval, sysarg_t arg1, 2031 2032 sysarg_t arg2) 2032 2033 { 2033 return ipc_answer_2(c allid, retval, arg1, arg2);2034 } 2035 2036 sysarg_t async_answer_3( ipc_callid_t callid, sysarg_t retval, sysarg_t arg1,2034 return ipc_answer_2(chandle, retval, arg1, arg2); 2035 } 2036 2037 sysarg_t async_answer_3(cap_handle_t chandle, sysarg_t retval, sysarg_t arg1, 2037 2038 sysarg_t arg2, sysarg_t arg3) 2038 2039 { 2039 return ipc_answer_3(c allid, retval, arg1, arg2, arg3);2040 } 2041 2042 sysarg_t async_answer_4( ipc_callid_t callid, sysarg_t retval, sysarg_t arg1,2040 return ipc_answer_3(chandle, retval, arg1, arg2, arg3); 2041 } 2042 2043 sysarg_t async_answer_4(cap_handle_t chandle, sysarg_t retval, sysarg_t arg1, 2043 2044 sysarg_t arg2, sysarg_t arg3, sysarg_t arg4) 2044 2045 { 2045 return ipc_answer_4(c allid, retval, arg1, arg2, arg3, arg4);2046 } 2047 2048 sysarg_t async_answer_5( ipc_callid_t callid, sysarg_t retval, sysarg_t arg1,2046 return ipc_answer_4(chandle, retval, arg1, arg2, arg3, arg4); 2047 } 2048 2049 sysarg_t async_answer_5(cap_handle_t chandle, sysarg_t retval, sysarg_t arg1, 2049 2050 sysarg_t arg2, sysarg_t arg3, sysarg_t arg4, sysarg_t arg5) 2050 2051 { 2051 return ipc_answer_5(c allid, retval, arg1, arg2, arg3, arg4, arg5);2052 } 2053 2054 int async_forward_fast( ipc_callid_t callid, async_exch_t *exch,2052 return ipc_answer_5(chandle, retval, arg1, arg2, arg3, arg4, arg5); 2053 } 2054 2055 int async_forward_fast(cap_handle_t chandle, async_exch_t *exch, 2055 2056 sysarg_t imethod, sysarg_t arg1, sysarg_t arg2, unsigned int mode) 2056 2057 { … … 2058 2059 return ENOENT; 2059 2060 2060 return ipc_forward_fast(c allid, exch->phone, imethod, arg1, arg2, mode);2061 } 2062 2063 int async_forward_slow( ipc_callid_t callid, async_exch_t *exch,2061 return ipc_forward_fast(chandle, exch->phone, imethod, arg1, arg2, mode); 2062 } 2063 2064 int async_forward_slow(cap_handle_t chandle, async_exch_t *exch, 2064 2065 sysarg_t imethod, sysarg_t arg1, sysarg_t arg2, sysarg_t arg3, 2065 2066 sysarg_t arg4, sysarg_t arg5, unsigned int mode) … … 2068 2069 return ENOENT; 2069 2070 2070 return ipc_forward_slow(c allid, exch->phone, imethod, arg1, arg2, arg3,2071 return ipc_forward_slow(chandle, exch->phone, imethod, arg1, arg2, arg3, 2071 2072 arg4, arg5, mode); 2072 2073 } … … 2604 2605 * So far, this wrapper is to be used from within a connection fibril. 2605 2606 * 2606 * @param c allid Storage for the hashof the IPC_M_SHARE_IN call.2607 * @param size Destination address space area size.2607 * @param chandle Storage for the handle of the IPC_M_SHARE_IN call. 2608 * @param size Destination address space area size. 2608 2609 * 2609 2610 * @return True on success, false on failure. 2610 2611 * 2611 2612 */ 2612 bool async_share_in_receive( ipc_callid_t *callid, size_t *size)2613 { 2614 assert(c allid);2613 bool async_share_in_receive(cap_handle_t *chandle, size_t *size) 2614 { 2615 assert(chandle); 2615 2616 assert(size); 2616 2617 2617 2618 ipc_call_t data; 2618 *c allid= async_get_call(&data);2619 *chandle = async_get_call(&data); 2619 2620 2620 2621 if (IPC_GET_IMETHOD(data) != IPC_M_SHARE_IN) … … 2631 2632 * argument. 2632 2633 * 2633 * @param c allid Hashof the IPC_M_DATA_READ call to answer.2634 * @param src Source address space base.2635 * @param flags Flags to be used for sharing. Bits can be only cleared.2634 * @param chandle Handle of the IPC_M_DATA_READ call to answer. 2635 * @param src Source address space base. 2636 * @param flags Flags to be used for sharing. Bits can be only cleared. 2636 2637 * 2637 2638 * @return Zero on success or a value from @ref errno.h on failure. 2638 2639 * 2639 2640 */ 2640 int async_share_in_finalize( ipc_callid_t callid, void *src, unsigned int flags)2641 { 2642 return ipc_answer_3(c allid, EOK, (sysarg_t) src, (sysarg_t) flags,2641 int async_share_in_finalize(cap_handle_t chandle, void *src, unsigned int flags) 2642 { 2643 return ipc_answer_3(chandle, EOK, (sysarg_t) src, (sysarg_t) flags, 2643 2644 (sysarg_t) __entry); 2644 2645 } … … 2670 2671 * So far, this wrapper is to be used from within a connection fibril. 2671 2672 * 2672 * @param c allidStorage for the hash of the IPC_M_SHARE_OUT call.2673 * @param size Storage for the source address space area size.2674 * @param flags Storage for the sharing flags.2673 * @param chandle Storage for the hash of the IPC_M_SHARE_OUT call. 2674 * @param size Storage for the source address space area size. 2675 * @param flags Storage for the sharing flags. 2675 2676 * 2676 2677 * @return True on success, false on failure. 2677 2678 * 2678 2679 */ 2679 bool async_share_out_receive(ipc_callid_t *callid, size_t *size, unsigned int *flags) 2680 { 2681 assert(callid); 2680 bool async_share_out_receive(cap_handle_t *chandle, size_t *size, 2681 unsigned int *flags) 2682 { 2683 assert(chandle); 2682 2684 assert(size); 2683 2685 assert(flags); 2684 2686 2685 2687 ipc_call_t data; 2686 *c allid= async_get_call(&data);2688 *chandle = async_get_call(&data); 2687 2689 2688 2690 if (IPC_GET_IMETHOD(data) != IPC_M_SHARE_OUT) … … 2700 2702 * argument. 2701 2703 * 2702 * @param c allid Hashof the IPC_M_DATA_WRITE call to answer.2703 * @param dst Address of the storage for the destination address space area2704 * base address.2705 * 2706 * @return Zero on success or a value from @ref errno.h on failure.2707 * 2708 */ 2709 int async_share_out_finalize( ipc_callid_t callid, void **dst)2710 { 2711 return ipc_answer_2(c allid, EOK, (sysarg_t) __entry, (sysarg_t) dst);2704 * @param chandle Handle of the IPC_M_DATA_WRITE call to answer. 2705 * @param dst Address of the storage for the destination address space area 2706 * base address. 2707 * 2708 * @return Zero on success or a value from @ref errno.h on failure. 2709 * 2710 */ 2711 int async_share_out_finalize(cap_handle_t chandle, void **dst) 2712 { 2713 return ipc_answer_2(chandle, EOK, (sysarg_t) __entry, (sysarg_t) dst); 2712 2714 } 2713 2715 … … 2755 2757 * So far, this wrapper is to be used from within a connection fibril. 2756 2758 * 2757 * @param c allid Storage for the hashof the IPC_M_DATA_READ.2758 * @param size Storage for the maximum size. Can be NULL.2759 * @param chandle Storage for the handle of the IPC_M_DATA_READ. 2760 * @param size Storage for the maximum size. Can be NULL. 2759 2761 * 2760 2762 * @return True on success, false on failure. 2761 2763 * 2762 2764 */ 2763 bool async_data_read_receive( ipc_callid_t *callid, size_t *size)2765 bool async_data_read_receive(cap_handle_t *chandle, size_t *size) 2764 2766 { 2765 2767 ipc_call_t data; 2766 return async_data_read_receive_call(c allid, &data, size);2768 return async_data_read_receive_call(chandle, &data, size); 2767 2769 } 2768 2770 … … 2775 2777 * So far, this wrapper is to be used from within a connection fibril. 2776 2778 * 2777 * @param c allid Storage for the hashof the IPC_M_DATA_READ.2778 * @param size Storage for the maximum size. Can be NULL.2779 * @param chandle Storage for the handle of the IPC_M_DATA_READ. 2780 * @param size Storage for the maximum size. Can be NULL. 2779 2781 * 2780 2782 * @return True on success, false on failure. 2781 2783 * 2782 2784 */ 2783 bool async_data_read_receive_call( ipc_callid_t *callid, ipc_call_t *data,2785 bool async_data_read_receive_call(cap_handle_t *chandle, ipc_call_t *data, 2784 2786 size_t *size) 2785 2787 { 2786 assert(c allid);2788 assert(chandle); 2787 2789 assert(data); 2788 2790 2789 *c allid= async_get_call(data);2791 *chandle = async_get_call(data); 2790 2792 2791 2793 if (IPC_GET_IMETHOD(*data) != IPC_M_DATA_READ) … … 2804 2806 * argument. 2805 2807 * 2806 * @param c allid Hashof the IPC_M_DATA_READ call to answer.2807 * @param src Source address for the IPC_M_DATA_READ call.2808 * @param size Size for the IPC_M_DATA_READ call. Can be smaller than2809 * the maximum size announced by the sender.2810 * 2811 * @return Zero on success or a value from @ref errno.h on failure.2812 * 2813 */ 2814 int async_data_read_finalize( ipc_callid_t callid, const void *src, size_t size)2815 { 2816 return ipc_answer_2(c allid, EOK, (sysarg_t) src, (sysarg_t) size);2808 * @param chandle Handle of the IPC_M_DATA_READ call to answer. 2809 * @param src Source address for the IPC_M_DATA_READ call. 2810 * @param size Size for the IPC_M_DATA_READ call. Can be smaller than 2811 * the maximum size announced by the sender. 2812 * 2813 * @return Zero on success or a value from @ref errno.h on failure. 2814 * 2815 */ 2816 int async_data_read_finalize(cap_handle_t chandle, const void *src, size_t size) 2817 { 2818 return ipc_answer_2(chandle, EOK, (sysarg_t) src, (sysarg_t) size); 2817 2819 } 2818 2820 … … 2827 2829 return ENOENT; 2828 2830 2829 ipc_callid_t callid;2830 if (!async_data_read_receive(&c allid, NULL)) {2831 ipc_answer_0(c allid, EINVAL);2831 cap_handle_t chandle; 2832 if (!async_data_read_receive(&chandle, NULL)) { 2833 ipc_answer_0(chandle, EINVAL); 2832 2834 return EINVAL; 2833 2835 } … … 2836 2838 dataptr); 2837 2839 if (msg == 0) { 2838 ipc_answer_0(c allid, EINVAL);2840 ipc_answer_0(chandle, EINVAL); 2839 2841 return EINVAL; 2840 2842 } 2841 2843 2842 int retval = ipc_forward_fast(c allid, exch->phone, 0, 0, 0,2844 int retval = ipc_forward_fast(chandle, exch->phone, 0, 0, 0, 2843 2845 IPC_FF_ROUTE_FROM_ME); 2844 2846 if (retval != EOK) { 2845 2847 async_forget(msg); 2846 ipc_answer_0(c allid, retval);2848 ipc_answer_0(chandle, retval); 2847 2849 return retval; 2848 2850 } … … 2880 2882 * So far, this wrapper is to be used from within a connection fibril. 2881 2883 * 2882 * @param c allid Storage for the hashof the IPC_M_DATA_WRITE.2883 * @param size Storage for the suggested size. May be NULL.2884 * 2885 * @return True on success, false on failure.2886 * 2887 */ 2888 bool async_data_write_receive( ipc_callid_t *callid, size_t *size)2884 * @param chandle Storage for the handle of the IPC_M_DATA_WRITE. 2885 * @param size Storage for the suggested size. May be NULL. 2886 * 2887 * @return True on success, false on failure. 2888 * 2889 */ 2890 bool async_data_write_receive(cap_handle_t *chandle, size_t *size) 2889 2891 { 2890 2892 ipc_call_t data; 2891 return async_data_write_receive_call(c allid, &data, size);2893 return async_data_write_receive_call(chandle, &data, size); 2892 2894 } 2893 2895 … … 2900 2902 * So far, this wrapper is to be used from within a connection fibril. 2901 2903 * 2902 * @param c allid Storage for the hashof the IPC_M_DATA_WRITE.2903 * @param data Storage for the ipc call data.2904 * @param size Storage for the suggested size. May be NULL.2904 * @param chandle Storage for the handle of the IPC_M_DATA_WRITE. 2905 * @param data Storage for the ipc call data. 2906 * @param size Storage for the suggested size. May be NULL. 2905 2907 * 2906 2908 * @return True on success, false on failure. 2907 2909 * 2908 2910 */ 2909 bool async_data_write_receive_call( ipc_callid_t *callid, ipc_call_t *data,2911 bool async_data_write_receive_call(cap_handle_t *chandle, ipc_call_t *data, 2910 2912 size_t *size) 2911 2913 { 2912 assert(c allid);2914 assert(chandle); 2913 2915 assert(data); 2914 2916 2915 *c allid= async_get_call(data);2917 *chandle = async_get_call(data); 2916 2918 2917 2919 if (IPC_GET_IMETHOD(*data) != IPC_M_DATA_WRITE) … … 2930 2932 * argument. 2931 2933 * 2932 * @param c allid Hashof the IPC_M_DATA_WRITE call to answer.2933 * @param dst Final destination address for the IPC_M_DATA_WRITE call.2934 * @param size Final size for the IPC_M_DATA_WRITE call.2935 * 2936 * @return Zero on success or a value from @ref errno.h on failure.2937 * 2938 */ 2939 int async_data_write_finalize( ipc_callid_t callid, void *dst, size_t size)2940 { 2941 return ipc_answer_2(c allid, EOK, (sysarg_t) dst, (sysarg_t) size);2934 * @param chandle Handle of the IPC_M_DATA_WRITE call to answer. 2935 * @param dst Final destination address for the IPC_M_DATA_WRITE call. 2936 * @param size Final size for the IPC_M_DATA_WRITE call. 2937 * 2938 * @return Zero on success or a value from @ref errno.h on failure. 2939 * 2940 */ 2941 int async_data_write_finalize(cap_handle_t chandle, void *dst, size_t size) 2942 { 2943 return ipc_answer_2(chandle, EOK, (sysarg_t) dst, (sysarg_t) size); 2942 2944 } 2943 2945 … … 2969 2971 assert(data); 2970 2972 2971 ipc_callid_t callid;2973 cap_handle_t chandle; 2972 2974 size_t size; 2973 if (!async_data_write_receive(&c allid, &size)) {2974 ipc_answer_0(c allid, EINVAL);2975 if (!async_data_write_receive(&chandle, &size)) { 2976 ipc_answer_0(chandle, EINVAL); 2975 2977 return EINVAL; 2976 2978 } 2977 2979 2978 2980 if (size < min_size) { 2979 ipc_answer_0(c allid, EINVAL);2981 ipc_answer_0(chandle, EINVAL); 2980 2982 return EINVAL; 2981 2983 } 2982 2984 2983 2985 if ((max_size > 0) && (size > max_size)) { 2984 ipc_answer_0(c allid, EINVAL);2986 ipc_answer_0(chandle, EINVAL); 2985 2987 return EINVAL; 2986 2988 } 2987 2989 2988 2990 if ((granularity > 0) && ((size % granularity) != 0)) { 2989 ipc_answer_0(c allid, EINVAL);2991 ipc_answer_0(chandle, EINVAL); 2990 2992 return EINVAL; 2991 2993 } … … 2999 3001 3000 3002 if (arg_data == NULL) { 3001 ipc_answer_0(c allid, ENOMEM);3003 ipc_answer_0(chandle, ENOMEM); 3002 3004 return ENOMEM; 3003 3005 } 3004 3006 3005 int rc = async_data_write_finalize(c allid, arg_data, size);3007 int rc = async_data_write_finalize(chandle, arg_data, size); 3006 3008 if (rc != EOK) { 3007 3009 free(arg_data); … … 3028 3030 void async_data_write_void(sysarg_t retval) 3029 3031 { 3030 ipc_callid_t callid;3031 async_data_write_receive(&c allid, NULL);3032 ipc_answer_0(c allid, retval);3032 cap_handle_t chandle; 3033 async_data_write_receive(&chandle, NULL); 3034 ipc_answer_0(chandle, retval); 3033 3035 } 3034 3036 … … 3043 3045 return ENOENT; 3044 3046 3045 ipc_callid_t callid;3046 if (!async_data_write_receive(&c allid, NULL)) {3047 ipc_answer_0(c allid, EINVAL);3047 cap_handle_t chandle; 3048 if (!async_data_write_receive(&chandle, NULL)) { 3049 ipc_answer_0(chandle, EINVAL); 3048 3050 return EINVAL; 3049 3051 } … … 3052 3054 dataptr); 3053 3055 if (msg == 0) { 3054 ipc_answer_0(c allid, EINVAL);3056 ipc_answer_0(chandle, EINVAL); 3055 3057 return EINVAL; 3056 3058 } 3057 3059 3058 int retval = ipc_forward_fast(c allid, exch->phone, 0, 0, 0,3060 int retval = ipc_forward_fast(chandle, exch->phone, 0, 0, 0, 3059 3061 IPC_FF_ROUTE_FROM_ME); 3060 3062 if (retval != EOK) { 3061 3063 async_forget(msg); 3062 ipc_answer_0(c allid, retval);3064 ipc_answer_0(chandle, retval); 3063 3065 return retval; 3064 3066 } … … 3085 3087 /* Accept the phone */ 3086 3088 ipc_call_t call; 3087 ipc_callid_t callid = async_get_call(&call); 3088 int phone = (int) IPC_GET_ARG5(call); 3089 3090 if ((IPC_GET_IMETHOD(call) != IPC_M_CONNECT_TO_ME) || 3091 (phone < 0)) { 3092 async_answer_0(callid, EINVAL); 3089 cap_handle_t chandle = async_get_call(&call); 3090 cap_handle_t phandle = (cap_handle_t) IPC_GET_ARG5(call); 3091 3092 if ((IPC_GET_IMETHOD(call) != IPC_M_CONNECT_TO_ME) || (phandle < 0)) { 3093 async_answer_0(chandle, EINVAL); 3093 3094 return NULL; 3094 3095 } … … 3096 3097 async_sess_t *sess = (async_sess_t *) malloc(sizeof(async_sess_t)); 3097 3098 if (sess == NULL) { 3098 async_answer_0(c allid, ENOMEM);3099 async_answer_0(chandle, ENOMEM); 3099 3100 return NULL; 3100 3101 } … … 3102 3103 sess->iface = 0; 3103 3104 sess->mgmt = mgmt; 3104 sess->phone = ph one;3105 sess->phone = phandle; 3105 3106 sess->arg1 = 0; 3106 3107 sess->arg2 = 0; … … 3115 3116 3116 3117 /* Acknowledge the connected phone */ 3117 async_answer_0(c allid, EOK);3118 async_answer_0(chandle, EOK); 3118 3119 3119 3120 return sess; … … 3136 3137 async_sess_t *async_callback_receive_start(exch_mgmt_t mgmt, ipc_call_t *call) 3137 3138 { 3138 int phone = (int) IPC_GET_ARG5(*call); 3139 3140 if ((IPC_GET_IMETHOD(*call) != IPC_M_CONNECT_TO_ME) || 3141 (phone < 0)) 3139 cap_handle_t phandle = (cap_handle_t) IPC_GET_ARG5(*call); 3140 3141 if ((IPC_GET_IMETHOD(*call) != IPC_M_CONNECT_TO_ME) || (phandle < 0)) 3142 3142 return NULL; 3143 3143 … … 3148 3148 sess->iface = 0; 3149 3149 sess->mgmt = mgmt; 3150 sess->phone = ph one;3150 sess->phone = phandle; 3151 3151 sess->arg1 = 0; 3152 3152 sess->arg2 = 0; … … 3170 3170 } 3171 3171 3172 bool async_state_change_receive( ipc_callid_t *callid, sysarg_t *arg1,3172 bool async_state_change_receive(cap_handle_t *chandle, sysarg_t *arg1, 3173 3173 sysarg_t *arg2, sysarg_t *arg3) 3174 3174 { 3175 assert(c allid);3175 assert(chandle); 3176 3176 3177 3177 ipc_call_t call; 3178 *c allid= async_get_call(&call);3178 *chandle = async_get_call(&call); 3179 3179 3180 3180 if (IPC_GET_IMETHOD(call) != IPC_M_STATE_CHANGE_AUTHORIZE) … … 3191 3191 } 3192 3192 3193 int async_state_change_finalize( ipc_callid_t callid, async_exch_t *other_exch)3194 { 3195 return ipc_answer_1(c allid, EOK, other_exch->phone);3193 int async_state_change_finalize(cap_handle_t chandle, async_exch_t *other_exch) 3194 { 3195 return ipc_answer_1(chandle, EOK, other_exch->phone); 3196 3196 } 3197 3197 -
uspace/lib/c/generic/ipc.c
r98cb5e0d r01c3bb4 59 59 struct { 60 60 ipc_call_t data; 61 int phoneid;62 61 } msg; 63 62 } async_call_t; … … 91 90 /** Epilogue for ipc_call_async_*() functions. 92 91 * 93 * @param callid Value returned by the SYS_IPC_CALL_ASYNC_* syscall. 94 * @param phoneid Phone handle through which the call was made. 95 * @param call Structure returned by ipc_prepare_async(). 96 */ 97 static inline void ipc_finish_async(ipc_callid_t callid, int phoneid, 98 async_call_t *call) 92 * @param rc Value returned by the SYS_IPC_CALL_ASYNC_* syscall. 93 * @param call Structure returned by ipc_prepare_async(). 94 */ 95 static inline void ipc_finish_async(int rc, async_call_t *call) 99 96 { 100 97 if (!call) { … … 103 100 } 104 101 105 if ( callid == (ipc_callid_t)IPC_CALLRET_FATAL) {102 if (rc == IPC_CALLRET_FATAL) { 106 103 /* Call asynchronous handler with error code */ 107 104 if (call->callback) … … 124 121 * error code. If the call cannot be temporarily made, it is queued. 125 122 * 126 * @param ph oneidPhone handle for the call.127 * @param imethod 128 * @param arg1 129 * @param arg2 130 * @param arg3 131 * @param private 132 * @param callback 133 */ 134 void ipc_call_async_fast( int phoneid, sysarg_t imethod, sysarg_t arg1,123 * @param phandle Phone handle for the call. 124 * @param imethod Requested interface and method. 125 * @param arg1 Service-defined payload argument. 126 * @param arg2 Service-defined payload argument. 127 * @param arg3 Service-defined payload argument. 128 * @param private Argument to be passed to the answer/error callback. 129 * @param callback Answer or error callback. 130 */ 131 void ipc_call_async_fast(cap_handle_t phandle, sysarg_t imethod, sysarg_t arg1, 135 132 sysarg_t arg2, sysarg_t arg3, void *private, ipc_async_callback_t callback) 136 133 { … … 139 136 return; 140 137 141 i pc_callid_t callid = __SYSCALL6(SYS_IPC_CALL_ASYNC_FAST, phoneid,142 imethod, arg1,arg2, arg3, (sysarg_t) call);143 144 ipc_finish_async( callid, phoneid, call);138 int rc = __SYSCALL6(SYS_IPC_CALL_ASYNC_FAST, phandle, imethod, arg1, 139 arg2, arg3, (sysarg_t) call); 140 141 ipc_finish_async(rc, call); 145 142 } 146 143 … … 153 150 * error code. If the call cannot be temporarily made, it is queued. 154 151 * 155 * @param ph oneidPhone handle for the call.156 * @param imethod 157 * @param arg1 158 * @param arg2 159 * @param arg3 160 * @param arg4 161 * @param arg5 162 * @param private 163 * @param callback 164 */ 165 void ipc_call_async_slow(int ph oneid, sysarg_t imethod, sysarg_t arg1,152 * @param phandle Phone handle for the call. 153 * @param imethod Requested interface and method. 154 * @param arg1 Service-defined payload argument. 155 * @param arg2 Service-defined payload argument. 156 * @param arg3 Service-defined payload argument. 157 * @param arg4 Service-defined payload argument. 158 * @param arg5 Service-defined payload argument. 159 * @param private Argument to be passed to the answer/error callback. 160 * @param callback Answer or error callback. 161 */ 162 void ipc_call_async_slow(int phandle, sysarg_t imethod, sysarg_t arg1, 166 163 sysarg_t arg2, sysarg_t arg3, sysarg_t arg4, sysarg_t arg5, void *private, 167 164 ipc_async_callback_t callback) … … 178 175 IPC_SET_ARG5(call->msg.data, arg5); 179 176 180 i pc_callid_t callid = __SYSCALL3(SYS_IPC_CALL_ASYNC_SLOW, phoneid,177 int rc = __SYSCALL3(SYS_IPC_CALL_ASYNC_SLOW, phandle, 181 178 (sysarg_t) &call->msg.data, (sysarg_t) call); 182 179 183 ipc_finish_async( callid, phoneid, call);180 ipc_finish_async(rc, call); 184 181 } 185 182 … … 189 186 * registers. If you need to return more, use the ipc_answer_slow() instead. 190 187 * 191 * @param c allid Hashof the call being answered.192 * @param retval Return value.193 * @param arg1 First return argument.194 * @param arg2 Second return argument.195 * @param arg3 Third return argument.196 * @param arg4 Fourth return argument.188 * @param chandle Handle of the call being answered. 189 * @param retval Return value. 190 * @param arg1 First return argument. 191 * @param arg2 Second return argument. 192 * @param arg3 Third return argument. 193 * @param arg4 Fourth return argument. 197 194 * 198 195 * @return Zero on success. … … 200 197 * 201 198 */ 202 sysarg_t ipc_answer_fast( ipc_callid_t callid, sysarg_t retval, sysarg_t arg1,199 sysarg_t ipc_answer_fast(cap_handle_t chandle, sysarg_t retval, sysarg_t arg1, 203 200 sysarg_t arg2, sysarg_t arg3, sysarg_t arg4) 204 201 { 205 return __SYSCALL6(SYS_IPC_ANSWER_FAST, c allid, retval, arg1, arg2, arg3,206 arg 4);202 return __SYSCALL6(SYS_IPC_ANSWER_FAST, chandle, retval, arg1, arg2, 203 arg3, arg4); 207 204 } 208 205 209 206 /** Answer received call (entire payload). 210 207 * 211 * @param c allid Hashof the call being answered.212 * @param retval Return value.213 * @param arg1 First return argument.214 * @param arg2 Second return argument.215 * @param arg3 Third return argument.216 * @param arg4 Fourth return argument.217 * @param arg5 Fifth return argument.208 * @param chandle Handle of the call being answered. 209 * @param retval Return value. 210 * @param arg1 First return argument. 211 * @param arg2 Second return argument. 212 * @param arg3 Third return argument. 213 * @param arg4 Fourth return argument. 214 * @param arg5 Fifth return argument. 218 215 * 219 216 * @return Zero on success. … … 221 218 * 222 219 */ 223 sysarg_t ipc_answer_slow( ipc_callid_t callid, sysarg_t retval, sysarg_t arg1,220 sysarg_t ipc_answer_slow(cap_handle_t chandle, sysarg_t retval, sysarg_t arg1, 224 221 sysarg_t arg2, sysarg_t arg3, sysarg_t arg4, sysarg_t arg5) 225 222 { … … 233 230 IPC_SET_ARG5(data, arg5); 234 231 235 return __SYSCALL2(SYS_IPC_ANSWER_SLOW, c allid, (sysarg_t) &data);232 return __SYSCALL2(SYS_IPC_ANSWER_SLOW, chandle, (sysarg_t) &data); 236 233 } 237 234 238 235 /** Handle received answer. 239 236 * 240 * @param callid Hash of the received answer. 241 * @param data Call data of the answer. 242 */ 243 static void handle_answer(ipc_callid_t callid, ipc_call_t *data) 237 * @param data Call data of the answer. 238 */ 239 static void handle_answer(ipc_call_t *data) 244 240 { 245 241 async_call_t *call = data->label; … … 255 251 /** Wait for first IPC call to come. 256 252 * 253 * @param call Incoming call storage. 254 * @param usec Timeout in microseconds 255 * @param flags Flags passed to SYS_IPC_WAIT (blocking, nonblocking). 256 * 257 * @return Call handle. 258 * @return Negative error code. 259 */ 260 cap_handle_t ipc_wait_cycle(ipc_call_t *call, sysarg_t usec, unsigned int flags) 261 { 262 cap_handle_t chandle = 263 __SYSCALL3(SYS_IPC_WAIT, (sysarg_t) call, usec, flags); 264 265 /* Handle received answers */ 266 if ((chandle == CAP_NIL) && (call->flags & IPC_CALLID_ANSWERED)) 267 handle_answer(call); 268 269 return chandle; 270 } 271 272 /** Interrupt one thread of this task from waiting for IPC. 273 * 274 */ 275 void ipc_poke(void) 276 { 277 __SYSCALL0(SYS_IPC_POKE); 278 } 279 280 /** Wait for first IPC call to come. 281 * 282 * Only requests are returned, answers are processed internally. 283 * 257 284 * @param call Incoming call storage. 258 285 * @param usec Timeout in microseconds 259 * @param flags Flags passed to SYS_IPC_WAIT (blocking, nonblocking). 260 * 261 * @return Hash of the call. 262 */ 263 ipc_callid_t ipc_wait_cycle(ipc_call_t *call, sysarg_t usec, 264 unsigned int flags) 265 { 266 ipc_callid_t callid = 267 __SYSCALL3(SYS_IPC_WAIT, (sysarg_t) call, usec, flags); 268 269 /* Handle received answers */ 270 if (callid && (call->flags & IPC_CALLID_ANSWERED)) 271 handle_answer(callid, call); 272 273 return callid; 274 } 275 276 /** Interrupt one thread of this task from waiting for IPC. 277 * 278 */ 279 void ipc_poke(void) 280 { 281 __SYSCALL0(SYS_IPC_POKE); 282 } 283 284 /** Wait for first IPC call to come. 286 * 287 * @return Call handle. 288 * @return Negative error code. 289 * 290 */ 291 cap_handle_t ipc_wait_for_call_timeout(ipc_call_t *call, sysarg_t usec) 292 { 293 cap_handle_t chandle; 294 295 do { 296 chandle = ipc_wait_cycle(call, usec, SYNCH_FLAGS_NONE); 297 } while ((chandle == CAP_NIL) && (call->flags & IPC_CALLID_ANSWERED)); 298 299 return chandle; 300 } 301 302 /** Check if there is an IPC call waiting to be picked up. 285 303 * 286 304 * Only requests are returned, answers are processed internally. 287 305 * 288 * @param call Incoming call storage.289 * @param usec Timeout in microseconds290 * 291 * @return Hash of the call.292 * 293 */ 294 ipc_callid_t ipc_wait_for_call_timeout(ipc_call_t *call, sysarg_t usec)295 { 296 ipc_callid_t callid;306 * @param call Incoming call storage. 307 * 308 * @return Call handle. 309 * @return Negative error code. 310 * 311 */ 312 cap_handle_t ipc_trywait_for_call(ipc_call_t *call) 313 { 314 cap_handle_t chandle; 297 315 298 316 do { 299 callid = ipc_wait_cycle(call, usec, SYNCH_FLAGS_NONE); 300 } while (callid && (call->flags & IPC_CALLID_ANSWERED)); 301 302 return callid; 303 } 304 305 /** Check if there is an IPC call waiting to be picked up. 306 * 307 * Only requests are returned, answers are processed internally. 308 * 309 * @param call Incoming call storage. 310 * 311 * @return Hash of the call. 312 * 313 */ 314 ipc_callid_t ipc_trywait_for_call(ipc_call_t *call) 315 { 316 ipc_callid_t callid; 317 318 do { 319 callid = ipc_wait_cycle(call, SYNCH_NO_TIMEOUT, 317 chandle = ipc_wait_cycle(call, SYNCH_NO_TIMEOUT, 320 318 SYNCH_FLAGS_NON_BLOCKING); 321 } while ( callid&& (call->flags & IPC_CALLID_ANSWERED));322 323 return c allid;319 } while ((chandle == CAP_NIL) && (call->flags & IPC_CALLID_ANSWERED)); 320 321 return chandle; 324 322 } 325 323 326 324 /** Hang up a phone. 327 325 * 328 * @param ph oneidHandle of the phone to be hung up.329 * 330 * @return Zero on success or a negative error code.331 * 332 */ 333 int ipc_hangup( int phoneid)334 { 335 return __SYSCALL1(SYS_IPC_HANGUP, ph oneid);326 * @param phandle Handle of the phone to be hung up. 327 * 328 * @return Zero on success or a negative error code. 329 * 330 */ 331 int ipc_hangup(cap_handle_t phandle) 332 { 333 return __SYSCALL1(SYS_IPC_HANGUP, phandle); 336 334 } 337 335 338 336 /** Forward a received call to another destination. 339 337 * 340 * For non-system methods, the old method, arg1 and arg2 are rewritten 341 * by the new values. For system methods, the new method, arg1 and arg2342 * are written to the old arg1, arg2 and arg3, respectivelly. Calls with343 * immutable methods areforwarded verbatim.344 * 345 * @param c allid Hashof the call to forward.346 * @param ph oneidPhone handle to use for forwarding.347 * @param imethod New interface and method for the forwarded call.348 * @param arg1 New value of the first argument for the forwarded call.349 * @param arg2 New value of the second argument for the forwarded call.350 * @param mode Flags specifying mode of the forward operation.351 * 352 * @return Zero on success or an error code.353 * 354 */ 355 int ipc_forward_fast( ipc_callid_t callid, int phoneid, sysarg_t imethod,356 sysarg_t arg1, sysarg_t arg2, unsigned int mode)357 { 358 return __SYSCALL6(SYS_IPC_FORWARD_FAST, c allid, phoneid, imethod, arg1,338 * For non-system methods, the old method, arg1 and arg2 are rewritten by the 339 * new values. For system methods, the new method, arg1 and arg2 are written to 340 * the old arg1, arg2 and arg3, respectivelly. Calls with immutable methods are 341 * forwarded verbatim. 342 * 343 * @param chandle Handle of the call to forward. 344 * @param phandle Phone handle to use for forwarding. 345 * @param imethod New interface and method for the forwarded call. 346 * @param arg1 New value of the first argument for the forwarded call. 347 * @param arg2 New value of the second argument for the forwarded call. 348 * @param mode Flags specifying mode of the forward operation. 349 * 350 * @return Zero on success or an error code. 351 * 352 */ 353 int ipc_forward_fast(cap_handle_t chandle, cap_handle_t phandle, 354 sysarg_t imethod, sysarg_t arg1, sysarg_t arg2, unsigned int mode) 355 { 356 return __SYSCALL6(SYS_IPC_FORWARD_FAST, chandle, phandle, imethod, arg1, 359 357 arg2, mode); 360 358 } 361 359 362 int ipc_forward_slow( ipc_callid_t callid, int phoneid, sysarg_t imethod,363 sysarg_t arg1, sysarg_t arg2, sysarg_t arg3, sysarg_t arg4, sysarg_t arg5,364 unsigned int mode)360 int ipc_forward_slow(cap_handle_t chandle, cap_handle_t phandle, 361 sysarg_t imethod, sysarg_t arg1, sysarg_t arg2, sysarg_t arg3, 362 sysarg_t arg4, sysarg_t arg5, unsigned int mode) 365 363 { 366 364 ipc_call_t data; … … 373 371 IPC_SET_ARG5(data, arg5); 374 372 375 return __SYSCALL4(SYS_IPC_FORWARD_SLOW, c allid, phoneid, (sysarg_t) &data,376 mode);373 return __SYSCALL4(SYS_IPC_FORWARD_SLOW, chandle, phandle, 374 (sysarg_t) &data, mode); 377 375 } 378 376 -
uspace/lib/c/include/async.h
r98cb5e0d r01c3bb4 49 49 #include <abi/ipc/event.h> 50 50 #include <abi/ipc/interfaces.h> 51 52 typedef ipc_callid_t aid_t; 51 #include <abi/cap.h> 52 53 typedef sysarg_t aid_t; 53 54 typedef sysarg_t port_id_t; 54 55 … … 58 59 /** Port connection handler 59 60 * 60 * @param c allid ID of incoming call or 0 if connection initiated from61 * inside using async_create_callback_port()62 * @param call Incoming call or 0 if connection initiated from inside63 * using async_create_callback_port()64 * @param arg Local argument.65 * 66 */ 67 typedef void (*async_port_handler_t)( ipc_callid_t, ipc_call_t *, void *);61 * @param chandle Handle of the incoming call or CAP_NIL if connection 62 * initiated from inside using async_create_callback_port() 63 * @param call Incoming call or 0 if connection initiated from inside 64 * using async_create_callback_port() 65 * @param arg Local argument. 66 * 67 */ 68 typedef void (*async_port_handler_t)(cap_handle_t, ipc_call_t *, void *); 68 69 69 70 /** Notification handler */ 70 typedef void (*async_notification_handler_t)(ipc_callid_t, ipc_call_t *, 71 void *); 71 typedef void (*async_notification_handler_t)(ipc_call_t *, void *); 72 72 73 73 /** Exchange management style … … 119 119 async_get_call_timeout(data, 0) 120 120 121 extern ipc_callid_t async_get_call_timeout(ipc_call_t *, suseconds_t);121 extern cap_handle_t async_get_call_timeout(ipc_call_t *, suseconds_t); 122 122 123 123 /* … … 196 196 */ 197 197 198 extern sysarg_t async_answer_0( ipc_callid_t, sysarg_t);199 extern sysarg_t async_answer_1( ipc_callid_t, sysarg_t, sysarg_t);200 extern sysarg_t async_answer_2( ipc_callid_t, sysarg_t, sysarg_t, sysarg_t);201 extern sysarg_t async_answer_3( ipc_callid_t, sysarg_t, sysarg_t, sysarg_t,198 extern sysarg_t async_answer_0(cap_handle_t, sysarg_t); 199 extern sysarg_t async_answer_1(cap_handle_t, sysarg_t, sysarg_t); 200 extern sysarg_t async_answer_2(cap_handle_t, sysarg_t, sysarg_t, sysarg_t); 201 extern sysarg_t async_answer_3(cap_handle_t, sysarg_t, sysarg_t, sysarg_t, 202 202 sysarg_t); 203 extern sysarg_t async_answer_4( ipc_callid_t, sysarg_t, sysarg_t, sysarg_t,203 extern sysarg_t async_answer_4(cap_handle_t, sysarg_t, sysarg_t, sysarg_t, 204 204 sysarg_t, sysarg_t); 205 extern sysarg_t async_answer_5( ipc_callid_t, sysarg_t, sysarg_t, sysarg_t,205 extern sysarg_t async_answer_5(cap_handle_t, sysarg_t, sysarg_t, sysarg_t, 206 206 sysarg_t, sysarg_t, sysarg_t); 207 207 … … 210 210 */ 211 211 212 extern int async_forward_fast( ipc_callid_t, async_exch_t *, sysarg_t, sysarg_t,212 extern int async_forward_fast(cap_handle_t, async_exch_t *, sysarg_t, sysarg_t, 213 213 sysarg_t, unsigned int); 214 extern int async_forward_slow( ipc_callid_t, async_exch_t *, sysarg_t, sysarg_t,214 extern int async_forward_slow(cap_handle_t, async_exch_t *, sysarg_t, sysarg_t, 215 215 sysarg_t, sysarg_t, sysarg_t, sysarg_t, unsigned int); 216 216 … … 382 382 extern int async_share_in_start(async_exch_t *, size_t, sysarg_t, 383 383 unsigned int *, void **); 384 extern bool async_share_in_receive( ipc_callid_t *, size_t *);385 extern int async_share_in_finalize( ipc_callid_t, void *, unsigned int);384 extern bool async_share_in_receive(cap_handle_t *, size_t *); 385 extern int async_share_in_finalize(cap_handle_t, void *, unsigned int); 386 386 387 387 extern int async_share_out_start(async_exch_t *, void *, unsigned int); 388 extern bool async_share_out_receive( ipc_callid_t *, size_t *, unsigned int *);389 extern int async_share_out_finalize( ipc_callid_t, void **);388 extern bool async_share_out_receive(cap_handle_t *, size_t *, unsigned int *); 389 extern int async_share_out_finalize(cap_handle_t, void **); 390 390 391 391 /* … … 421 421 extern aid_t async_data_read(async_exch_t *, void *, size_t, ipc_call_t *); 422 422 extern int async_data_read_start(async_exch_t *, void *, size_t); 423 extern bool async_data_read_receive( ipc_callid_t *, size_t *);424 extern bool async_data_read_receive_call( ipc_callid_t *, ipc_call_t *, size_t *);425 extern int async_data_read_finalize( ipc_callid_t, const void *, size_t);423 extern bool async_data_read_receive(cap_handle_t *, size_t *); 424 extern bool async_data_read_receive_call(cap_handle_t *, ipc_call_t *, size_t *); 425 extern int async_data_read_finalize(cap_handle_t, const void *, size_t); 426 426 427 427 extern int async_data_read_forward_fast(async_exch_t *, sysarg_t, sysarg_t, … … 460 460 461 461 extern int async_data_write_start(async_exch_t *, const void *, size_t); 462 extern bool async_data_write_receive( ipc_callid_t *, size_t *);463 extern bool async_data_write_receive_call( ipc_callid_t *, ipc_call_t *, size_t *);464 extern int async_data_write_finalize( ipc_callid_t, void *, size_t);462 extern bool async_data_write_receive(cap_handle_t *, size_t *); 463 extern bool async_data_write_receive_call(cap_handle_t *, ipc_call_t *, size_t *); 464 extern int async_data_write_finalize(cap_handle_t, void *, size_t); 465 465 466 466 extern int async_data_write_accept(void **, const bool, const size_t, … … 476 476 extern int async_state_change_start(async_exch_t *, sysarg_t, sysarg_t, 477 477 sysarg_t, async_exch_t *); 478 extern bool async_state_change_receive( ipc_callid_t *, sysarg_t *, sysarg_t *,478 extern bool async_state_change_receive(cap_handle_t *, sysarg_t *, sysarg_t *, 479 479 sysarg_t *); 480 extern int async_state_change_finalize( ipc_callid_t, async_exch_t *);480 extern int async_state_change_finalize(cap_handle_t, async_exch_t *); 481 481 482 482 extern void *async_remote_state_acquire(async_sess_t *); -
uspace/lib/c/include/ipc/common.h
r98cb5e0d r01c3bb4 40 40 #include <abi/proc/task.h> 41 41 #include <futex.h> 42 #include <abi/cap.h> 42 43 43 44 #define IPC_FLAG_BLOCKING 0x01 … … 53 54 } ipc_call_t; 54 55 55 typedef sysarg_t ipc_callid_t;56 typedef cap_handle_t ipc_callid_t; 56 57 57 58 extern futex_t async_futex; -
uspace/lib/c/include/ipc/ipc.h
r98cb5e0d r01c3bb4 44 44 #include <abi/synch.h> 45 45 #include <abi/proc/task.h> 46 #include <abi/cap.h> 46 47 47 48 typedef void (*ipc_async_callback_t)(void *, int, ipc_call_t *); 48 49 49 extern ipc_callid_t ipc_wait_cycle(ipc_call_t *, sysarg_t, unsigned int);50 extern cap_handle_t ipc_wait_cycle(ipc_call_t *, sysarg_t, unsigned int); 50 51 extern void ipc_poke(void); 51 52 … … 53 54 ipc_wait_for_call_timeout(data, SYNCH_NO_TIMEOUT); 54 55 55 extern ipc_callid_t ipc_wait_for_call_timeout(ipc_call_t *, sysarg_t);56 extern ipc_callid_t ipc_trywait_for_call(ipc_call_t *);56 extern cap_handle_t ipc_wait_for_call_timeout(ipc_call_t *, sysarg_t); 57 extern cap_handle_t ipc_trywait_for_call(ipc_call_t *); 57 58 58 59 /* … … 63 64 */ 64 65 65 #define ipc_answer_0(callid, retval) \ 66 ipc_answer_fast((callid), (retval), 0, 0, 0, 0) 67 #define ipc_answer_1(callid, retval, arg1) \ 68 ipc_answer_fast((callid), (retval), (arg1), 0, 0, 0) 69 #define ipc_answer_2(callid, retval, arg1, arg2) \ 70 ipc_answer_fast((callid), (retval), (arg1), (arg2), 0, 0) 71 #define ipc_answer_3(callid, retval, arg1, arg2, arg3) \ 72 ipc_answer_fast((callid), (retval), (arg1), (arg2), (arg3), 0) 73 #define ipc_answer_4(callid, retval, arg1, arg2, arg3, arg4) \ 74 ipc_answer_fast((callid), (retval), (arg1), (arg2), (arg3), (arg4)) 75 #define ipc_answer_5(callid, retval, arg1, arg2, arg3, arg4, arg5) \ 76 ipc_answer_slow((callid), (retval), (arg1), (arg2), (arg3), (arg4), (arg5)) 66 #define ipc_answer_0(chandle, retval) \ 67 ipc_answer_fast((chandle), (retval), 0, 0, 0, 0) 68 #define ipc_answer_1(chandle, retval, arg1) \ 69 ipc_answer_fast((chandle), (retval), (arg1), 0, 0, 0) 70 #define ipc_answer_2(chandle, retval, arg1, arg2) \ 71 ipc_answer_fast((chandle), (retval), (arg1), (arg2), 0, 0) 72 #define ipc_answer_3(chandle, retval, arg1, arg2, arg3) \ 73 ipc_answer_fast((chandle), (retval), (arg1), (arg2), (arg3), 0) 74 #define ipc_answer_4(chandle, retval, arg1, arg2, arg3, arg4) \ 75 ipc_answer_fast((chandle), (retval), (arg1), (arg2), (arg3), (arg4)) 76 #define ipc_answer_5(chandle, retval, arg1, arg2, arg3, arg4, arg5) \ 77 ipc_answer_slow((chandle), (retval), (arg1), (arg2), (arg3), (arg4), \ 78 (arg5)) 77 79 78 extern sysarg_t ipc_answer_fast( ipc_callid_t, sysarg_t, sysarg_t, sysarg_t,80 extern sysarg_t ipc_answer_fast(cap_handle_t, sysarg_t, sysarg_t, sysarg_t, 79 81 sysarg_t, sysarg_t); 80 extern sysarg_t ipc_answer_slow( ipc_callid_t, sysarg_t, sysarg_t, sysarg_t,82 extern sysarg_t ipc_answer_slow(cap_handle_t, sysarg_t, sysarg_t, sysarg_t, 81 83 sysarg_t, sysarg_t, sysarg_t); 82 84 … … 88 90 */ 89 91 90 #define ipc_call_async_0(ph oneid, method, private, callback) \91 ipc_call_async_fast((ph oneid), (method), 0, 0, 0, (private), (callback))92 #define ipc_call_async_1(ph oneid, method, arg1, private, callback) \93 ipc_call_async_fast((ph oneid), (method), (arg1), 0, 0, (private), \92 #define ipc_call_async_0(phandle, method, private, callback) \ 93 ipc_call_async_fast((phandle), (method), 0, 0, 0, (private), (callback)) 94 #define ipc_call_async_1(phandle, method, arg1, private, callback) \ 95 ipc_call_async_fast((phandle), (method), (arg1), 0, 0, (private), \ 94 96 (callback)) 95 #define ipc_call_async_2(ph oneid, method, arg1, arg2, private, callback) \96 ipc_call_async_fast((ph oneid), (method), (arg1), (arg2), 0, \97 #define ipc_call_async_2(phandle, method, arg1, arg2, private, callback) \ 98 ipc_call_async_fast((phandle), (method), (arg1), (arg2), 0, \ 97 99 (private), (callback)) 98 #define ipc_call_async_3(ph oneid, method, arg1, arg2, arg3, private, callback) \99 ipc_call_async_fast((ph oneid), (method), (arg1), (arg2), (arg3), \100 #define ipc_call_async_3(phandle, method, arg1, arg2, arg3, private, callback) \ 101 ipc_call_async_fast((phandle), (method), (arg1), (arg2), (arg3), \ 100 102 (private), (callback)) 101 #define ipc_call_async_4(ph oneid, method, arg1, arg2, arg3, arg4, private, \103 #define ipc_call_async_4(phandle, method, arg1, arg2, arg3, arg4, private, \ 102 104 callback) \ 103 ipc_call_async_slow((ph oneid), (method), (arg1), (arg2), (arg3), \105 ipc_call_async_slow((phandle), (method), (arg1), (arg2), (arg3), \ 104 106 (arg4), 0, (private), (callback)) 105 #define ipc_call_async_5(ph oneid, method, arg1, arg2, arg3, arg4, arg5, \107 #define ipc_call_async_5(phandle, method, arg1, arg2, arg3, arg4, arg5, \ 106 108 private, callback) \ 107 ipc_call_async_slow((ph oneid), (method), (arg1), (arg2), (arg3), \109 ipc_call_async_slow((phandle), (method), (arg1), (arg2), (arg3), \ 108 110 (arg4), (arg5), (private), (callback)) 109 111 110 extern void ipc_call_async_fast( int, sysarg_t, sysarg_t, sysarg_t, sysarg_t,111 void *, ipc_async_callback_t);112 extern void ipc_call_async_slow( int, sysarg_t, sysarg_t, sysarg_t, sysarg_t,113 sysarg_t, sysarg_t, void *, ipc_async_callback_t);112 extern void ipc_call_async_fast(cap_handle_t, sysarg_t, sysarg_t, sysarg_t, 113 sysarg_t, void *, ipc_async_callback_t); 114 extern void ipc_call_async_slow(cap_handle_t, sysarg_t, sysarg_t, sysarg_t, 115 sysarg_t, sysarg_t, sysarg_t, void *, ipc_async_callback_t); 114 116 115 extern int ipc_hangup( int);117 extern int ipc_hangup(cap_handle_t); 116 118 117 extern int ipc_forward_fast( ipc_callid_t, int, sysarg_t, sysarg_t, sysarg_t,118 unsigned int);119 extern int ipc_forward_slow( ipc_callid_t, int, sysarg_t, sysarg_t, sysarg_t,120 sysarg_t, sysarg_t, sysarg_t, unsigned int);119 extern int ipc_forward_fast(cap_handle_t, cap_handle_t, sysarg_t, sysarg_t, 120 sysarg_t, unsigned int); 121 extern int ipc_forward_slow(cap_handle_t, cap_handle_t, sysarg_t, sysarg_t, 122 sysarg_t, sysarg_t, sysarg_t, sysarg_t, unsigned int); 121 123 122 124 extern int ipc_connect_kbox(task_id_t);
Note:
See TracChangeset
for help on using the changeset viewer.