Index: uspace/lib/c/generic/async.c
===================================================================
--- uspace/lib/c/generic/async.c	(revision ac307b25a02622848f9ee9d1bff85d6cd4c35ca2)
+++ uspace/lib/c/generic/async.c	(revision 9940ce0abda70ea8d091bd0be88bbccc2059eceb)
@@ -77,17 +77,17 @@
  *   }
  *
- *   port_handler(icallid, *icall)
+ *   port_handler(ichandle, *icall)
  *   {
  *     if (want_refuse) {
- *       async_answer_0(icallid, ELIMIT);
+ *       async_answer_0(ichandle, ELIMIT);
  *       return;
  *     }
- *     async_answer_0(icallid, EOK);
- *
- *     callid = async_get_call(&call);
- *     somehow_handle_the_call(callid, call);
- *     async_answer_2(callid, 1, 2, 3);
- *
- *     callid = async_get_call(&call);
+ *     async_answer_0(ichandle, EOK);
+ *
+ *     chandle = async_get_call(&call);
+ *     somehow_handle_the_call(chandle, call);
+ *     async_answer_2(chandle, 1, 2, 3);
+ *
+ *     chandle = async_get_call(&call);
  *     ...
  *   }
@@ -185,5 +185,5 @@
 	link_t link;
 	
-	ipc_callid_t callid;
+	cap_handle_t chandle;
 	ipc_call_t call;
 } msg_t;
@@ -237,5 +237,5 @@
 	
 	/** Identification of the opening call. */
-	ipc_callid_t callid;
+	cap_handle_t chandle;
 	
 	/** Call data of the opening call. */
@@ -243,5 +243,5 @@
 	
 	/** Identification of the closing call. */
-	ipc_callid_t close_callid;
+	cap_handle_t close_chandle;
 	
 	/** Fibril function that will be used to handle the connection. */
@@ -374,16 +374,16 @@
 /** Default fallback fibril function.
  *
- * This fallback fibril function gets called on incomming
- * connections that do not have a specific handler defined.
- *
- * @param callid Hash of the incoming call.
- * @param call   Data of the incoming call.
- * @param arg    Local argument
- *
- */
-static void default_fallback_port_handler(ipc_callid_t callid, ipc_call_t *call,
-    void *arg)
-{
-	ipc_answer_0(callid, ENOENT);
+ * This fallback fibril function gets called on incomming connections that do
+ * not have a specific handler defined.
+ *
+ * @param chandle  Handle of the incoming call.
+ * @param call     Data of the incoming call.
+ * @param arg      Local argument
+ *
+ */
+static void default_fallback_port_handler(cap_handle_t chandle,
+    ipc_call_t *call, void *arg)
+{
+	ipc_answer_0(chandle, ENOENT);
 }
 
@@ -715,5 +715,5 @@
 	client_t *client = async_client_get(fibril_connection->in_task_id, true);
 	if (!client) {
-		ipc_answer_0(fibril_connection->callid, ENOMEM);
+		ipc_answer_0(fibril_connection->chandle, ENOMEM);
 		return 0;
 	}
@@ -724,5 +724,5 @@
 	 * Call the connection handler function.
 	 */
-	fibril_connection->handler(fibril_connection->callid,
+	fibril_connection->handler(fibril_connection->chandle,
 	    &fibril_connection->call, fibril_connection->data);
 	
@@ -751,5 +751,5 @@
 		
 		list_remove(&msg->link);
-		ipc_answer_0(msg->callid, EHANGUP);
+		ipc_answer_0(msg->chandle, EHANGUP);
 		free(msg);
 	}
@@ -759,6 +759,6 @@
 	 * i.e. IPC_M_PHONE_HUNGUP.
 	 */
-	if (fibril_connection->close_callid)
-		ipc_answer_0(fibril_connection->close_callid, EOK);
+	if (fibril_connection->close_chandle)
+		ipc_answer_0(fibril_connection->close_chandle, EOK);
 	
 	free(fibril_connection);
@@ -768,29 +768,29 @@
 /** Create a new fibril for a new connection.
  *
- * Create new fibril for connection, fill in connection structures
- * and insert it into the hash table, so that later we can easily
- * do routing of messages to particular fibrils.
- *
- * @param in_task_id    Identification of the incoming connection.
- * @param in_phone_hash Identification of the incoming connection.
- * @param callid        Hash of the opening IPC_M_CONNECT_ME_TO call.
- *                      If callid is zero, the connection was opened by
- *                      accepting the IPC_M_CONNECT_TO_ME call and this
- *                      function is called directly by the server.
- * @param call          Call data of the opening call.
- * @param handler       Connection handler.
- * @param data          Client argument to pass to the connection handler.
- *
- * @return New fibril id or NULL on failure.
+ * Create new fibril for connection, fill in connection structures and insert it
+ * into the hash table, so that later we can easily do routing of messages to
+ * particular fibrils.
+ *
+ * @param in_task_id     Identification of the incoming connection.
+ * @param in_phone_hash  Identification of the incoming connection.
+ * @param chandle        Handle of the opening IPC_M_CONNECT_ME_TO call.
+ *                       If chandle is CAP_NIL, the connection was opened by
+ *                       accepting the IPC_M_CONNECT_TO_ME call and this
+ *                       function is called directly by the server.
+ * @param call           Call data of the opening call.
+ * @param handler        Connection handler.
+ * @param data           Client argument to pass to the connection handler.
+ *
+ * @return  New fibril id or NULL on failure.
  *
  */
 static fid_t async_new_connection(task_id_t in_task_id, sysarg_t in_phone_hash,
-    ipc_callid_t callid, ipc_call_t *call, async_port_handler_t handler,
+    cap_handle_t chandle, ipc_call_t *call, async_port_handler_t handler,
     void *data)
 {
 	connection_t *conn = malloc(sizeof(*conn));
 	if (!conn) {
-		if (callid)
-			ipc_answer_0(callid, ENOMEM);
+		if (chandle != CAP_NIL)
+			ipc_answer_0(chandle, ENOMEM);
 		
 		return (uintptr_t) NULL;
@@ -800,6 +800,6 @@
 	conn->in_phone_hash = in_phone_hash;
 	list_initialize(&conn->msg_queue);
-	conn->callid = callid;
-	conn->close_callid = 0;
+	conn->chandle = chandle;
+	conn->close_chandle = CAP_NIL;
 	conn->handler = handler;
 	conn->data = data;
@@ -815,6 +815,6 @@
 		free(conn);
 		
-		if (callid)
-			ipc_answer_0(callid, ENOMEM);
+		if (chandle != CAP_NIL)
+			ipc_answer_0(chandle, ENOMEM);
 		
 		return (uintptr_t) NULL;
@@ -892,5 +892,5 @@
 	
 	fid_t fid = async_new_connection(answer.in_task_id, phone_hash,
-	    0, NULL, handler, data);
+	    CAP_NIL, NULL, handler, data);
 	if (fid == (uintptr_t) NULL)
 		return ENOMEM;
@@ -961,6 +961,6 @@
  * timeouts are unregistered.
  *
- * @param callid Hash of the incoming call.
- * @param call   Data of the incoming call.
+ * @param chandle  Handle of the incoming call.
+ * @param call     Data of the incoming call.
  *
  * @return False if the call doesn't match any connection.
@@ -968,5 +968,5 @@
  *
  */
-static bool route_call(ipc_callid_t callid, ipc_call_t *call)
+static bool route_call(cap_handle_t chandle, ipc_call_t *call)
 {
 	assert(call);
@@ -991,10 +991,10 @@
 	}
 	
-	msg->callid = callid;
+	msg->chandle = chandle;
 	msg->call = *call;
 	list_append(&msg->link, &conn->msg_queue);
 	
 	if (IPC_GET_IMETHOD(*call) == IPC_M_PHONE_HUNGUP)
-		conn->close_callid = callid;
+		conn->close_chandle = chandle;
 	
 	/* If the connection fibril is waiting for an event, activate it */
@@ -1017,9 +1017,8 @@
 /** Process notification.
  *
- * @param callid Hash of the incoming call.
  * @param call   Data of the incoming call.
  *
  */
-static void process_notification(ipc_callid_t callid, ipc_call_t *call)
+static void process_notification(ipc_call_t *call)
 {
 	async_notification_handler_t handler = NULL;
@@ -1042,5 +1041,5 @@
 	
 	if (handler)
-		handler(callid, call, data);
+		handler(call, data);
 }
 
@@ -1187,15 +1186,13 @@
 /** Return new incoming message for the current (fibril-local) connection.
  *
- * @param call  Storage where the incoming call data will be stored.
- * @param usecs Timeout in microseconds. Zero denotes no timeout.
- *
- * @return If no timeout was specified, then a hash of the
- *         incoming call is returned. If a timeout is specified,
- *         then a hash of the incoming call is returned unless
- *         the timeout expires prior to receiving a message. In
- *         that case zero is returned.
- *
- */
-ipc_callid_t async_get_call_timeout(ipc_call_t *call, suseconds_t usecs)
+ * @param call   Storage where the incoming call data will be stored.
+ * @param usecs  Timeout in microseconds. Zero denotes no timeout.
+ *
+ * @return  If no timeout was specified, then a handle of the incoming call is
+ *          returned. If a timeout is specified, then a handle of the incoming
+ *          call is returned unless the timeout expires prior to receiving a
+ *          message. In that case zero CAP_NIL is returned.
+ */
+cap_handle_t async_get_call_timeout(ipc_call_t *call, suseconds_t usecs)
 {
 	assert(call);
@@ -1220,5 +1217,5 @@
 	/* If nothing in queue, wait until something arrives */
 	while (list_empty(&conn->msg_queue)) {
-		if (conn->close_callid) {
+		if (conn->close_chandle) {
 			/*
 			 * Handle the case when the connection was already
@@ -1231,5 +1228,5 @@
 			IPC_SET_IMETHOD(*call, IPC_M_PHONE_HUNGUP);
 			futex_up(&async_futex);
-			return conn->close_callid;
+			return conn->close_chandle;
 		}
 		
@@ -1256,5 +1253,5 @@
 			/* If we timed out -> exit */
 			futex_up(&async_futex);
-			return 0;
+			return CAP_NIL;
 		}
 	}
@@ -1264,10 +1261,10 @@
 	list_remove(&msg->link);
 	
-	ipc_callid_t callid = msg->callid;
+	cap_handle_t chandle = msg->chandle;
 	*call = msg->call;
 	free(msg);
 	
 	futex_up(&async_futex);
-	return callid;
+	return chandle;
 }
 
@@ -1332,18 +1329,18 @@
  * Otherwise the call is routed to its connection fibril.
  *
- * @param callid Hash of the incoming call.
- * @param call   Data of the incoming call.
- *
- */
-static void handle_call(ipc_callid_t callid, ipc_call_t *call)
+ * @param chandle  Handle of the incoming call.
+ * @param call     Data of the incoming call.
+ *
+ */
+static void handle_call(cap_handle_t chandle, ipc_call_t *call)
 {
 	assert(call);
 	
 	/* Kernel notification */
-	if (call->flags & IPC_CALLID_NOTIFICATION) {
+	if ((chandle == CAP_NIL) && (call->flags & IPC_CALLID_NOTIFICATION)) {
 		fibril_t *fibril = (fibril_t *) __tcb_get()->fibril_data;
 		unsigned oldsw = fibril->switches;
 		
-		process_notification(callid, call);
+		process_notification(call);
 		
 		if (oldsw != fibril->switches) {
@@ -1371,5 +1368,5 @@
 		sysarg_t in_phone_hash = IPC_GET_ARG5(*call);
 		
-		async_notification_handler_t handler = fallback_port_handler;
+		async_port_handler_t handler = fallback_port_handler;
 		void *data = fallback_port_data;
 		
@@ -1381,5 +1378,5 @@
 		}
 		
-		async_new_connection(call->in_task_id, in_phone_hash, callid,
+		async_new_connection(call->in_task_id, in_phone_hash, chandle,
 		    call, handler, data);
 		return;
@@ -1387,9 +1384,9 @@
 	
 	/* Try to route the call through the connection hash table */
-	if (route_call(callid, call))
+	if (route_call(chandle, call))
 		return;
 	
 	/* Unknown call from unknown phone - hang it up */
-	ipc_answer_0(callid, EHANGUP);
+	ipc_answer_0(chandle, EHANGUP);
 }
 
@@ -1486,19 +1483,24 @@
 		
 		ipc_call_t call;
-		ipc_callid_t callid = ipc_wait_cycle(&call, timeout, flags);
+		cap_handle_t chandle = ipc_wait_cycle(&call, timeout, flags);
 		
 		atomic_dec(&threads_in_ipc_wait);
 		
-		if (!callid) {
-			handle_expired_timeouts();
-			continue;
+		assert(chandle >= 0);
+
+		if (chandle == CAP_NIL) {
+			if (call.flags == 0) {
+				/* This neither a notification nor an answer. */
+				handle_expired_timeouts();
+				continue;
+			}
 		}
-		
+
 		if (call.flags & IPC_CALLID_ANSWERED)
 			continue;
-		
-		handle_call(callid, &call);
-	}
-	
+
+		handle_call(chandle, &call);
+	}
+
 	return 0;
 }
@@ -1631,6 +1633,5 @@
  * @param arg3    Service-defined payload argument.
  * @param arg4    Service-defined payload argument.
- * @param dataptr If non-NULL, storage where the reply data will be
- *                stored.
+ * @param dataptr If non-NULL, storage where the reply data will be stored.
  *
  * @return Hash of the sent message or 0 on error.
@@ -2018,39 +2019,39 @@
 }
 
-sysarg_t async_answer_0(ipc_callid_t callid, sysarg_t retval)
-{
-	return ipc_answer_0(callid, retval);
-}
-
-sysarg_t async_answer_1(ipc_callid_t callid, sysarg_t retval, sysarg_t arg1)
-{
-	return ipc_answer_1(callid, retval, arg1);
-}
-
-sysarg_t async_answer_2(ipc_callid_t callid, sysarg_t retval, sysarg_t arg1,
+sysarg_t async_answer_0(cap_handle_t chandle, sysarg_t retval)
+{
+	return ipc_answer_0(chandle, retval);
+}
+
+sysarg_t async_answer_1(cap_handle_t chandle, sysarg_t retval, sysarg_t arg1)
+{
+	return ipc_answer_1(chandle, retval, arg1);
+}
+
+sysarg_t async_answer_2(cap_handle_t chandle, sysarg_t retval, sysarg_t arg1,
     sysarg_t arg2)
 {
-	return ipc_answer_2(callid, retval, arg1, arg2);
-}
-
-sysarg_t async_answer_3(ipc_callid_t callid, sysarg_t retval, sysarg_t arg1,
+	return ipc_answer_2(chandle, retval, arg1, arg2);
+}
+
+sysarg_t async_answer_3(cap_handle_t chandle, sysarg_t retval, sysarg_t arg1,
     sysarg_t arg2, sysarg_t arg3)
 {
-	return ipc_answer_3(callid, retval, arg1, arg2, arg3);
-}
-
-sysarg_t async_answer_4(ipc_callid_t callid, sysarg_t retval, sysarg_t arg1,
+	return ipc_answer_3(chandle, retval, arg1, arg2, arg3);
+}
+
+sysarg_t async_answer_4(cap_handle_t chandle, sysarg_t retval, sysarg_t arg1,
     sysarg_t arg2, sysarg_t arg3, sysarg_t arg4)
 {
-	return ipc_answer_4(callid, retval, arg1, arg2, arg3, arg4);
-}
-
-sysarg_t async_answer_5(ipc_callid_t callid, sysarg_t retval, sysarg_t arg1,
+	return ipc_answer_4(chandle, retval, arg1, arg2, arg3, arg4);
+}
+
+sysarg_t async_answer_5(cap_handle_t chandle, sysarg_t retval, sysarg_t arg1,
     sysarg_t arg2, sysarg_t arg3, sysarg_t arg4, sysarg_t arg5)
 {
-	return ipc_answer_5(callid, retval, arg1, arg2, arg3, arg4, arg5);
-}
-
-int async_forward_fast(ipc_callid_t callid, async_exch_t *exch,
+	return ipc_answer_5(chandle, retval, arg1, arg2, arg3, arg4, arg5);
+}
+
+int async_forward_fast(cap_handle_t chandle, async_exch_t *exch,
     sysarg_t imethod, sysarg_t arg1, sysarg_t arg2, unsigned int mode)
 {
@@ -2058,8 +2059,8 @@
 		return ENOENT;
 	
-	return ipc_forward_fast(callid, exch->phone, imethod, arg1, arg2, mode);
-}
-
-int async_forward_slow(ipc_callid_t callid, async_exch_t *exch,
+	return ipc_forward_fast(chandle, exch->phone, imethod, arg1, arg2, mode);
+}
+
+int async_forward_slow(cap_handle_t chandle, async_exch_t *exch,
     sysarg_t imethod, sysarg_t arg1, sysarg_t arg2, sysarg_t arg3,
     sysarg_t arg4, sysarg_t arg5, unsigned int mode)
@@ -2068,5 +2069,5 @@
 		return ENOENT;
 	
-	return ipc_forward_slow(callid, exch->phone, imethod, arg1, arg2, arg3,
+	return ipc_forward_slow(chandle, exch->phone, imethod, arg1, arg2, arg3,
 	    arg4, arg5, mode);
 }
@@ -2604,17 +2605,17 @@
  * So far, this wrapper is to be used from within a connection fibril.
  *
- * @param callid Storage for the hash of the IPC_M_SHARE_IN call.
- * @param size   Destination address space area size.
+ * @param chandle  Storage for the handle of the IPC_M_SHARE_IN call.
+ * @param size     Destination address space area size.
  *
  * @return True on success, false on failure.
  *
  */
-bool async_share_in_receive(ipc_callid_t *callid, size_t *size)
-{
-	assert(callid);
+bool async_share_in_receive(cap_handle_t *chandle, size_t *size)
+{
+	assert(chandle);
 	assert(size);
 	
 	ipc_call_t data;
-	*callid = async_get_call(&data);
+	*chandle = async_get_call(&data);
 	
 	if (IPC_GET_IMETHOD(data) != IPC_M_SHARE_IN)
@@ -2631,14 +2632,14 @@
  * argument.
  *
- * @param callid Hash of the IPC_M_DATA_READ call to answer.
- * @param src    Source address space base.
- * @param flags  Flags to be used for sharing. Bits can be only cleared.
+ * @param chandle  Handle of the IPC_M_DATA_READ call to answer.
+ * @param src      Source address space base.
+ * @param flags    Flags to be used for sharing. Bits can be only cleared.
  *
  * @return Zero on success or a value from @ref errno.h on failure.
  *
  */
-int async_share_in_finalize(ipc_callid_t callid, void *src, unsigned int flags)
-{
-	return ipc_answer_3(callid, EOK, (sysarg_t) src, (sysarg_t) flags,
+int async_share_in_finalize(cap_handle_t chandle, void *src, unsigned int flags)
+{
+	return ipc_answer_3(chandle, EOK, (sysarg_t) src, (sysarg_t) flags,
 	    (sysarg_t) __entry);
 }
@@ -2670,19 +2671,20 @@
  * So far, this wrapper is to be used from within a connection fibril.
  *
- * @param callid Storage for the hash of the IPC_M_SHARE_OUT call.
- * @param size   Storage for the source address space area size.
- * @param flags  Storage for the sharing flags.
+ * @param chandle  Storage for the hash of the IPC_M_SHARE_OUT call.
+ * @param size     Storage for the source address space area size.
+ * @param flags    Storage for the sharing flags.
  *
  * @return True on success, false on failure.
  *
  */
-bool async_share_out_receive(ipc_callid_t *callid, size_t *size, unsigned int *flags)
-{
-	assert(callid);
+bool async_share_out_receive(cap_handle_t *chandle, size_t *size,
+    unsigned int *flags)
+{
+	assert(chandle);
 	assert(size);
 	assert(flags);
 	
 	ipc_call_t data;
-	*callid = async_get_call(&data);
+	*chandle = async_get_call(&data);
 	
 	if (IPC_GET_IMETHOD(data) != IPC_M_SHARE_OUT)
@@ -2700,14 +2702,14 @@
  * argument.
  *
- * @param callid Hash of the IPC_M_DATA_WRITE call to answer.
- * @param dst    Address of the storage for the destination address space area
- *               base address.
- *
- * @return Zero on success or a value from @ref errno.h on failure.
- *
- */
-int async_share_out_finalize(ipc_callid_t callid, void **dst)
-{
-	return ipc_answer_2(callid, EOK, (sysarg_t) __entry, (sysarg_t) dst);
+ * @param chandle  Handle of the IPC_M_DATA_WRITE call to answer.
+ * @param dst      Address of the storage for the destination address space area
+ *                 base address.
+ *
+ * @return  Zero on success or a value from @ref errno.h on failure.
+ *
+ */
+int async_share_out_finalize(cap_handle_t chandle, void **dst)
+{
+	return ipc_answer_2(chandle, EOK, (sysarg_t) __entry, (sysarg_t) dst);
 }
 
@@ -2755,14 +2757,14 @@
  * So far, this wrapper is to be used from within a connection fibril.
  *
- * @param callid Storage for the hash of the IPC_M_DATA_READ.
- * @param size   Storage for the maximum size. Can be NULL.
+ * @param chandle  Storage for the handle of the IPC_M_DATA_READ.
+ * @param size     Storage for the maximum size. Can be NULL.
  *
  * @return True on success, false on failure.
  *
  */
-bool async_data_read_receive(ipc_callid_t *callid, size_t *size)
+bool async_data_read_receive(cap_handle_t *chandle, size_t *size)
 {
 	ipc_call_t data;
-	return async_data_read_receive_call(callid, &data, size);
+	return async_data_read_receive_call(chandle, &data, size);
 }
 
@@ -2775,17 +2777,17 @@
  * So far, this wrapper is to be used from within a connection fibril.
  *
- * @param callid Storage for the hash of the IPC_M_DATA_READ.
- * @param size   Storage for the maximum size. Can be NULL.
+ * @param chandle  Storage for the handle of the IPC_M_DATA_READ.
+ * @param size     Storage for the maximum size. Can be NULL.
  *
  * @return True on success, false on failure.
  *
  */
-bool async_data_read_receive_call(ipc_callid_t *callid, ipc_call_t *data,
+bool async_data_read_receive_call(cap_handle_t *chandle, ipc_call_t *data,
     size_t *size)
 {
-	assert(callid);
+	assert(chandle);
 	assert(data);
 	
-	*callid = async_get_call(data);
+	*chandle = async_get_call(data);
 	
 	if (IPC_GET_IMETHOD(*data) != IPC_M_DATA_READ)
@@ -2804,15 +2806,15 @@
  * argument.
  *
- * @param callid Hash of the IPC_M_DATA_READ call to answer.
- * @param src    Source address for the IPC_M_DATA_READ call.
- * @param size   Size for the IPC_M_DATA_READ call. Can be smaller than
- *               the maximum size announced by the sender.
- *
- * @return Zero on success or a value from @ref errno.h on failure.
- *
- */
-int async_data_read_finalize(ipc_callid_t callid, const void *src, size_t size)
-{
-	return ipc_answer_2(callid, EOK, (sysarg_t) src, (sysarg_t) size);
+ * @param chandle  Handle of the IPC_M_DATA_READ call to answer.
+ * @param src      Source address for the IPC_M_DATA_READ call.
+ * @param size     Size for the IPC_M_DATA_READ call. Can be smaller than
+ *                 the maximum size announced by the sender.
+ *
+ * @return  Zero on success or a value from @ref errno.h on failure.
+ *
+ */
+int async_data_read_finalize(cap_handle_t chandle, const void *src, size_t size)
+{
+	return ipc_answer_2(chandle, EOK, (sysarg_t) src, (sysarg_t) size);
 }
 
@@ -2827,7 +2829,7 @@
 		return ENOENT;
 	
-	ipc_callid_t callid;
-	if (!async_data_read_receive(&callid, NULL)) {
-		ipc_answer_0(callid, EINVAL);
+	cap_handle_t chandle;
+	if (!async_data_read_receive(&chandle, NULL)) {
+		ipc_answer_0(chandle, EINVAL);
 		return EINVAL;
 	}
@@ -2836,13 +2838,13 @@
 	    dataptr);
 	if (msg == 0) {
-		ipc_answer_0(callid, EINVAL);
+		ipc_answer_0(chandle, EINVAL);
 		return EINVAL;
 	}
 	
-	int retval = ipc_forward_fast(callid, exch->phone, 0, 0, 0,
+	int retval = ipc_forward_fast(chandle, exch->phone, 0, 0, 0,
 	    IPC_FF_ROUTE_FROM_ME);
 	if (retval != EOK) {
 		async_forget(msg);
-		ipc_answer_0(callid, retval);
+		ipc_answer_0(chandle, retval);
 		return retval;
 	}
@@ -2880,14 +2882,14 @@
  * So far, this wrapper is to be used from within a connection fibril.
  *
- * @param callid Storage for the hash of the IPC_M_DATA_WRITE.
- * @param size   Storage for the suggested size. May be NULL.
- *
- * @return True on success, false on failure.
- *
- */
-bool async_data_write_receive(ipc_callid_t *callid, size_t *size)
+ * @param chandle  Storage for the handle of the IPC_M_DATA_WRITE.
+ * @param size     Storage for the suggested size. May be NULL.
+ *
+ * @return  True on success, false on failure.
+ *
+ */
+bool async_data_write_receive(cap_handle_t *chandle, size_t *size)
 {
 	ipc_call_t data;
-	return async_data_write_receive_call(callid, &data, size);
+	return async_data_write_receive_call(chandle, &data, size);
 }
 
@@ -2900,18 +2902,18 @@
  * So far, this wrapper is to be used from within a connection fibril.
  *
- * @param callid Storage for the hash of the IPC_M_DATA_WRITE.
- * @param data   Storage for the ipc call data.
- * @param size   Storage for the suggested size. May be NULL.
+ * @param chandle  Storage for the handle of the IPC_M_DATA_WRITE.
+ * @param data     Storage for the ipc call data.
+ * @param size     Storage for the suggested size. May be NULL.
  *
  * @return True on success, false on failure.
  *
  */
-bool async_data_write_receive_call(ipc_callid_t *callid, ipc_call_t *data,
+bool async_data_write_receive_call(cap_handle_t *chandle, ipc_call_t *data,
     size_t *size)
 {
-	assert(callid);
+	assert(chandle);
 	assert(data);
 	
-	*callid = async_get_call(data);
+	*chandle = async_get_call(data);
 	
 	if (IPC_GET_IMETHOD(*data) != IPC_M_DATA_WRITE)
@@ -2930,14 +2932,14 @@
  * argument.
  *
- * @param callid Hash of the IPC_M_DATA_WRITE call to answer.
- * @param dst    Final destination address for the IPC_M_DATA_WRITE call.
- * @param size   Final size for the IPC_M_DATA_WRITE call.
- *
- * @return Zero on success or a value from @ref errno.h on failure.
- *
- */
-int async_data_write_finalize(ipc_callid_t callid, void *dst, size_t size)
-{
-	return ipc_answer_2(callid, EOK, (sysarg_t) dst, (sysarg_t) size);
+ * @param chandle  Handle of the IPC_M_DATA_WRITE call to answer.
+ * @param dst      Final destination address for the IPC_M_DATA_WRITE call.
+ * @param size     Final size for the IPC_M_DATA_WRITE call.
+ *
+ * @return  Zero on success or a value from @ref errno.h on failure.
+ *
+ */
+int async_data_write_finalize(cap_handle_t chandle, void *dst, size_t size)
+{
+	return ipc_answer_2(chandle, EOK, (sysarg_t) dst, (sysarg_t) size);
 }
 
@@ -2969,23 +2971,23 @@
 	assert(data);
 	
-	ipc_callid_t callid;
+	cap_handle_t chandle;
 	size_t size;
-	if (!async_data_write_receive(&callid, &size)) {
-		ipc_answer_0(callid, EINVAL);
+	if (!async_data_write_receive(&chandle, &size)) {
+		ipc_answer_0(chandle, EINVAL);
 		return EINVAL;
 	}
 	
 	if (size < min_size) {
-		ipc_answer_0(callid, EINVAL);
+		ipc_answer_0(chandle, EINVAL);
 		return EINVAL;
 	}
 	
 	if ((max_size > 0) && (size > max_size)) {
-		ipc_answer_0(callid, EINVAL);
+		ipc_answer_0(chandle, EINVAL);
 		return EINVAL;
 	}
 	
 	if ((granularity > 0) && ((size % granularity) != 0)) {
-		ipc_answer_0(callid, EINVAL);
+		ipc_answer_0(chandle, EINVAL);
 		return EINVAL;
 	}
@@ -2999,9 +3001,9 @@
 	
 	if (arg_data == NULL) {
-		ipc_answer_0(callid, ENOMEM);
+		ipc_answer_0(chandle, ENOMEM);
 		return ENOMEM;
 	}
 	
-	int rc = async_data_write_finalize(callid, arg_data, size);
+	int rc = async_data_write_finalize(chandle, arg_data, size);
 	if (rc != EOK) {
 		free(arg_data);
@@ -3028,7 +3030,7 @@
 void async_data_write_void(sysarg_t retval)
 {
-	ipc_callid_t callid;
-	async_data_write_receive(&callid, NULL);
-	ipc_answer_0(callid, retval);
+	cap_handle_t chandle;
+	async_data_write_receive(&chandle, NULL);
+	ipc_answer_0(chandle, retval);
 }
 
@@ -3043,7 +3045,7 @@
 		return ENOENT;
 	
-	ipc_callid_t callid;
-	if (!async_data_write_receive(&callid, NULL)) {
-		ipc_answer_0(callid, EINVAL);
+	cap_handle_t chandle;
+	if (!async_data_write_receive(&chandle, NULL)) {
+		ipc_answer_0(chandle, EINVAL);
 		return EINVAL;
 	}
@@ -3052,13 +3054,13 @@
 	    dataptr);
 	if (msg == 0) {
-		ipc_answer_0(callid, EINVAL);
+		ipc_answer_0(chandle, EINVAL);
 		return EINVAL;
 	}
 	
-	int retval = ipc_forward_fast(callid, exch->phone, 0, 0, 0,
+	int retval = ipc_forward_fast(chandle, exch->phone, 0, 0, 0,
 	    IPC_FF_ROUTE_FROM_ME);
 	if (retval != EOK) {
 		async_forget(msg);
-		ipc_answer_0(callid, retval);
+		ipc_answer_0(chandle, retval);
 		return retval;
 	}
@@ -3085,10 +3087,9 @@
 	/* Accept the phone */
 	ipc_call_t call;
-	ipc_callid_t callid = async_get_call(&call);
-	int phone = (int) IPC_GET_ARG5(call);
-	
-	if ((IPC_GET_IMETHOD(call) != IPC_M_CONNECT_TO_ME) ||
-	    (phone < 0)) {
-		async_answer_0(callid, EINVAL);
+	cap_handle_t chandle = async_get_call(&call);
+	cap_handle_t phandle = (cap_handle_t) IPC_GET_ARG5(call);
+	
+	if ((IPC_GET_IMETHOD(call) != IPC_M_CONNECT_TO_ME) || (phandle < 0)) {
+		async_answer_0(chandle, EINVAL);
 		return NULL;
 	}
@@ -3096,5 +3097,5 @@
 	async_sess_t *sess = (async_sess_t *) malloc(sizeof(async_sess_t));
 	if (sess == NULL) {
-		async_answer_0(callid, ENOMEM);
+		async_answer_0(chandle, ENOMEM);
 		return NULL;
 	}
@@ -3102,5 +3103,5 @@
 	sess->iface = 0;
 	sess->mgmt = mgmt;
-	sess->phone = phone;
+	sess->phone = phandle;
 	sess->arg1 = 0;
 	sess->arg2 = 0;
@@ -3115,5 +3116,5 @@
 	
 	/* Acknowledge the connected phone */
-	async_answer_0(callid, EOK);
+	async_answer_0(chandle, EOK);
 	
 	return sess;
@@ -3136,8 +3137,7 @@
 async_sess_t *async_callback_receive_start(exch_mgmt_t mgmt, ipc_call_t *call)
 {
-	int phone = (int) IPC_GET_ARG5(*call);
-	
-	if ((IPC_GET_IMETHOD(*call) != IPC_M_CONNECT_TO_ME) ||
-	    (phone < 0))
+	cap_handle_t phandle = (cap_handle_t) IPC_GET_ARG5(*call);
+	
+	if ((IPC_GET_IMETHOD(*call) != IPC_M_CONNECT_TO_ME) || (phandle < 0))
 		return NULL;
 	
@@ -3148,5 +3148,5 @@
 	sess->iface = 0;
 	sess->mgmt = mgmt;
-	sess->phone = phone;
+	sess->phone = phandle;
 	sess->arg1 = 0;
 	sess->arg2 = 0;
@@ -3170,11 +3170,11 @@
 }
 
-bool async_state_change_receive(ipc_callid_t *callid, sysarg_t *arg1,
+bool async_state_change_receive(cap_handle_t *chandle, sysarg_t *arg1,
     sysarg_t *arg2, sysarg_t *arg3)
 {
-	assert(callid);
+	assert(chandle);
 	
 	ipc_call_t call;
-	*callid = async_get_call(&call);
+	*chandle = async_get_call(&call);
 	
 	if (IPC_GET_IMETHOD(call) != IPC_M_STATE_CHANGE_AUTHORIZE)
@@ -3191,7 +3191,7 @@
 }
 
-int async_state_change_finalize(ipc_callid_t callid, async_exch_t *other_exch)
-{
-	return ipc_answer_1(callid, EOK, other_exch->phone);
+int async_state_change_finalize(cap_handle_t chandle, async_exch_t *other_exch)
+{
+	return ipc_answer_1(chandle, EOK, other_exch->phone);
 }
 
Index: uspace/lib/c/generic/ipc.c
===================================================================
--- uspace/lib/c/generic/ipc.c	(revision ac307b25a02622848f9ee9d1bff85d6cd4c35ca2)
+++ uspace/lib/c/generic/ipc.c	(revision 9940ce0abda70ea8d091bd0be88bbccc2059eceb)
@@ -59,5 +59,4 @@
 	struct {
 		ipc_call_t data;
-		int phoneid;
 	} msg;
 } async_call_t;
@@ -91,10 +90,8 @@
 /** Epilogue for ipc_call_async_*() functions.
  *
- * @param callid      Value returned by the SYS_IPC_CALL_ASYNC_* syscall.
- * @param phoneid     Phone handle through which the call was made.
- * @param call        Structure returned by ipc_prepare_async().
- */
-static inline void ipc_finish_async(ipc_callid_t callid, int phoneid,
-    async_call_t *call)
+ * @param rc       Value returned by the SYS_IPC_CALL_ASYNC_* syscall.
+ * @param call     Structure returned by ipc_prepare_async().
+ */
+static inline void ipc_finish_async(int rc, async_call_t *call)
 {
 	if (!call) {
@@ -103,5 +100,5 @@
 	}
 	
-	if (callid == (ipc_callid_t) IPC_CALLRET_FATAL) {
+	if (rc == IPC_CALLRET_FATAL) {
 		/* Call asynchronous handler with error code */
 		if (call->callback)
@@ -124,13 +121,13 @@
  * error code. If the call cannot be temporarily made, it is queued.
  *
- * @param phoneid     Phone handle for the call.
- * @param imethod     Requested interface and method.
- * @param arg1        Service-defined payload argument.
- * @param arg2        Service-defined payload argument.
- * @param arg3        Service-defined payload argument.
- * @param private     Argument to be passed to the answer/error callback.
- * @param callback    Answer or error callback.
- */
-void ipc_call_async_fast(int phoneid, sysarg_t imethod, sysarg_t arg1,
+ * @param phandle   Phone handle for the call.
+ * @param imethod   Requested interface and method.
+ * @param arg1      Service-defined payload argument.
+ * @param arg2      Service-defined payload argument.
+ * @param arg3      Service-defined payload argument.
+ * @param private   Argument to be passed to the answer/error callback.
+ * @param callback  Answer or error callback.
+ */
+void ipc_call_async_fast(cap_handle_t phandle, sysarg_t imethod, sysarg_t arg1,
     sysarg_t arg2, sysarg_t arg3, void *private, ipc_async_callback_t callback)
 {
@@ -139,8 +136,8 @@
 		return;
 	
-	ipc_callid_t callid = __SYSCALL6(SYS_IPC_CALL_ASYNC_FAST, phoneid,
-	    imethod, arg1, arg2, arg3, (sysarg_t) call);
-	
-	ipc_finish_async(callid, phoneid, call);
+	int rc = __SYSCALL6(SYS_IPC_CALL_ASYNC_FAST, phandle, imethod, arg1,
+	    arg2, arg3, (sysarg_t) call);
+	
+	ipc_finish_async(rc, call);
 }
 
@@ -153,15 +150,15 @@
  * error code. If the call cannot be temporarily made, it is queued.
  *
- * @param phoneid     Phone handle for the call.
- * @param imethod     Requested interface and method.
- * @param arg1        Service-defined payload argument.
- * @param arg2        Service-defined payload argument.
- * @param arg3        Service-defined payload argument.
- * @param arg4        Service-defined payload argument.
- * @param arg5        Service-defined payload argument.
- * @param private     Argument to be passed to the answer/error callback.
- * @param callback    Answer or error callback.
- */
-void ipc_call_async_slow(int phoneid, sysarg_t imethod, sysarg_t arg1,
+ * @param phandle   Phone handle for the call.
+ * @param imethod   Requested interface and method.
+ * @param arg1      Service-defined payload argument.
+ * @param arg2      Service-defined payload argument.
+ * @param arg3      Service-defined payload argument.
+ * @param arg4      Service-defined payload argument.
+ * @param arg5      Service-defined payload argument.
+ * @param private   Argument to be passed to the answer/error callback.
+ * @param callback  Answer or error callback.
+ */
+void ipc_call_async_slow(int phandle, sysarg_t imethod, sysarg_t arg1,
     sysarg_t arg2, sysarg_t arg3, sysarg_t arg4, sysarg_t arg5, void *private,
     ipc_async_callback_t callback)
@@ -178,8 +175,8 @@
 	IPC_SET_ARG5(call->msg.data, arg5);
 	
-	ipc_callid_t callid = __SYSCALL3(SYS_IPC_CALL_ASYNC_SLOW, phoneid,
+	int rc = __SYSCALL3(SYS_IPC_CALL_ASYNC_SLOW, phandle,
 	    (sysarg_t) &call->msg.data, (sysarg_t) call);
 	
-	ipc_finish_async(callid, phoneid, call);
+	ipc_finish_async(rc, call);
 }
 
@@ -189,10 +186,10 @@
  * registers. If you need to return more, use the ipc_answer_slow() instead.
  *
- * @param callid Hash of the call being answered.
- * @param retval Return value.
- * @param arg1   First return argument.
- * @param arg2   Second return argument.
- * @param arg3   Third return argument.
- * @param arg4   Fourth return argument.
+ * @param chandle  Handle of the call being answered.
+ * @param retval   Return value.
+ * @param arg1     First return argument.
+ * @param arg2     Second return argument.
+ * @param arg3     Third return argument.
+ * @param arg4     Fourth return argument.
  *
  * @return Zero on success.
@@ -200,20 +197,20 @@
  *
  */
-sysarg_t ipc_answer_fast(ipc_callid_t callid, sysarg_t retval, sysarg_t arg1,
+sysarg_t ipc_answer_fast(cap_handle_t chandle, sysarg_t retval, sysarg_t arg1,
     sysarg_t arg2, sysarg_t arg3, sysarg_t arg4)
 {
-	return __SYSCALL6(SYS_IPC_ANSWER_FAST, callid, retval, arg1, arg2, arg3,
-	    arg4);
+	return __SYSCALL6(SYS_IPC_ANSWER_FAST, chandle, retval, arg1, arg2,
+	    arg3, arg4);
 }
 
 /** Answer received call (entire payload).
  *
- * @param callid Hash of the call being answered.
- * @param retval Return value.
- * @param arg1   First return argument.
- * @param arg2   Second return argument.
- * @param arg3   Third return argument.
- * @param arg4   Fourth return argument.
- * @param arg5   Fifth return argument.
+ * @param chandle  Handle of the call being answered.
+ * @param retval   Return value.
+ * @param arg1     First return argument.
+ * @param arg2     Second return argument.
+ * @param arg3     Third return argument.
+ * @param arg4     Fourth return argument.
+ * @param arg5     Fifth return argument.
  *
  * @return Zero on success.
@@ -221,5 +218,5 @@
  *
  */
-sysarg_t ipc_answer_slow(ipc_callid_t callid, sysarg_t retval, sysarg_t arg1,
+sysarg_t ipc_answer_slow(cap_handle_t chandle, sysarg_t retval, sysarg_t arg1,
     sysarg_t arg2, sysarg_t arg3, sysarg_t arg4, sysarg_t arg5)
 {
@@ -233,13 +230,12 @@
 	IPC_SET_ARG5(data, arg5);
 	
-	return __SYSCALL2(SYS_IPC_ANSWER_SLOW, callid, (sysarg_t) &data);
+	return __SYSCALL2(SYS_IPC_ANSWER_SLOW, chandle, (sysarg_t) &data);
 }
 
 /** Handle received answer.
  *
- * @param callid Hash of the received answer.
- * @param data   Call data of the answer.
- */
-static void handle_answer(ipc_callid_t callid, ipc_call_t *data)
+ * @param data  Call data of the answer.
+ */
+static void handle_answer(ipc_call_t *data)
 {
 	async_call_t *call = data->label;
@@ -255,112 +251,114 @@
 /** Wait for first IPC call to come.
  *
+ * @param call   Incoming call storage.
+ * @param usec   Timeout in microseconds
+ * @param flags  Flags passed to SYS_IPC_WAIT (blocking, nonblocking).
+ *
+ * @return  Call handle.
+ * @return  Negative error code.
+ */
+cap_handle_t ipc_wait_cycle(ipc_call_t *call, sysarg_t usec, unsigned int flags)
+{
+	cap_handle_t chandle =
+	    __SYSCALL3(SYS_IPC_WAIT, (sysarg_t) call, usec, flags);
+	
+	/* Handle received answers */
+	if ((chandle == CAP_NIL) && (call->flags & IPC_CALLID_ANSWERED))
+		handle_answer(call);
+	
+	return chandle;
+}
+
+/** Interrupt one thread of this task from waiting for IPC.
+ *
+ */
+void ipc_poke(void)
+{
+	__SYSCALL0(SYS_IPC_POKE);
+}
+
+/** Wait for first IPC call to come.
+ *
+ * Only requests are returned, answers are processed internally.
+ *
  * @param call  Incoming call storage.
  * @param usec  Timeout in microseconds
- * @param flags Flags passed to SYS_IPC_WAIT (blocking, nonblocking).
- *
- * @return Hash of the call.
- */
-ipc_callid_t ipc_wait_cycle(ipc_call_t *call, sysarg_t usec,
-    unsigned int flags)
-{
-	ipc_callid_t callid =
-	    __SYSCALL3(SYS_IPC_WAIT, (sysarg_t) call, usec, flags);
-	
-	/* Handle received answers */
-	if (callid && (call->flags & IPC_CALLID_ANSWERED))
-		handle_answer(callid, call);
-	
-	return callid;
-}
-
-/** Interrupt one thread of this task from waiting for IPC.
- *
- */
-void ipc_poke(void)
-{
-	__SYSCALL0(SYS_IPC_POKE);
-}
-
-/** Wait for first IPC call to come.
+ *
+ * @return  Call handle.
+ * @return  Negative error code.
+ *
+ */
+cap_handle_t ipc_wait_for_call_timeout(ipc_call_t *call, sysarg_t usec)
+{
+	cap_handle_t chandle;
+	
+	do {
+		chandle = ipc_wait_cycle(call, usec, SYNCH_FLAGS_NONE);
+	} while ((chandle == CAP_NIL) && (call->flags & IPC_CALLID_ANSWERED));
+	
+	return chandle;
+}
+
+/** Check if there is an IPC call waiting to be picked up.
  *
  * Only requests are returned, answers are processed internally.
  *
- * @param call Incoming call storage.
- * @param usec Timeout in microseconds
- *
- * @return Hash of the call.
- *
- */
-ipc_callid_t ipc_wait_for_call_timeout(ipc_call_t *call, sysarg_t usec)
-{
-	ipc_callid_t callid;
+ * @param call  Incoming call storage.
+ *
+ * @return  Call handle.
+ * @return  Negative error code.
+ *
+ */
+cap_handle_t ipc_trywait_for_call(ipc_call_t *call)
+{
+	cap_handle_t chandle;
 	
 	do {
-		callid = ipc_wait_cycle(call, usec, SYNCH_FLAGS_NONE);
-	} while (callid && (call->flags & IPC_CALLID_ANSWERED));
-	
-	return callid;
-}
-
-/** Check if there is an IPC call waiting to be picked up.
- *
- * Only requests are returned, answers are processed internally.
- *
- * @param call Incoming call storage.
- *
- * @return Hash of the call.
- *
- */
-ipc_callid_t ipc_trywait_for_call(ipc_call_t *call)
-{
-	ipc_callid_t callid;
-	
-	do {
-		callid = ipc_wait_cycle(call, SYNCH_NO_TIMEOUT,
+		chandle = ipc_wait_cycle(call, SYNCH_NO_TIMEOUT,
 		    SYNCH_FLAGS_NON_BLOCKING);
-	} while (callid && (call->flags & IPC_CALLID_ANSWERED));
-	
-	return callid;
+	} while ((chandle == CAP_NIL) && (call->flags & IPC_CALLID_ANSWERED));
+	
+	return chandle;
 }
 
 /** Hang up a phone.
  *
- * @param phoneid Handle of the phone to be hung up.
- *
- * @return Zero on success or a negative error code.
- *
- */
-int ipc_hangup(int phoneid)
-{
-	return __SYSCALL1(SYS_IPC_HANGUP, phoneid);
+ * @param phandle  Handle of the phone to be hung up.
+ *
+ * @return  Zero on success or a negative error code.
+ *
+ */
+int ipc_hangup(cap_handle_t phandle)
+{
+	return __SYSCALL1(SYS_IPC_HANGUP, phandle);
 }
 
 /** Forward a received call to another destination.
  *
- * For non-system methods, the old method, arg1 and arg2 are rewritten
- * by the new values. For system methods, the new method, arg1 and arg2
- * are written to the old arg1, arg2 and arg3, respectivelly. Calls with
- * immutable methods are forwarded verbatim.
- *
- * @param callid  Hash of the call to forward.
- * @param phoneid Phone handle to use for forwarding.
- * @param imethod New interface and method for the forwarded call.
- * @param arg1    New value of the first argument for the forwarded call.
- * @param arg2    New value of the second argument for the forwarded call.
- * @param mode    Flags specifying mode of the forward operation.
- *
- * @return Zero on success or an error code.
- *
- */
-int ipc_forward_fast(ipc_callid_t callid, int phoneid, sysarg_t imethod,
-    sysarg_t arg1, sysarg_t arg2, unsigned int mode)
-{
-	return __SYSCALL6(SYS_IPC_FORWARD_FAST, callid, phoneid, imethod, arg1,
+ * For non-system methods, the old method, arg1 and arg2 are rewritten by the
+ * new values. For system methods, the new method, arg1 and arg2 are written to
+ * the old arg1, arg2 and arg3, respectivelly. Calls with immutable methods are
+ * forwarded verbatim.
+ *
+ * @param chandle  Handle of the call to forward.
+ * @param phandle  Phone handle to use for forwarding.
+ * @param imethod  New interface and method for the forwarded call.
+ * @param arg1     New value of the first argument for the forwarded call.
+ * @param arg2     New value of the second argument for the forwarded call.
+ * @param mode     Flags specifying mode of the forward operation.
+ *
+ * @return  Zero on success or an error code.
+ *
+ */
+int ipc_forward_fast(cap_handle_t chandle, cap_handle_t phandle,
+    sysarg_t imethod, sysarg_t arg1, sysarg_t arg2, unsigned int mode)
+{
+	return __SYSCALL6(SYS_IPC_FORWARD_FAST, chandle, phandle, imethod, arg1,
 	    arg2, mode);
 }
 
-int ipc_forward_slow(ipc_callid_t callid, int phoneid, sysarg_t imethod,
-    sysarg_t arg1, sysarg_t arg2, sysarg_t arg3, sysarg_t arg4, sysarg_t arg5,
-    unsigned int mode)
+int ipc_forward_slow(cap_handle_t chandle, cap_handle_t phandle,
+    sysarg_t imethod, sysarg_t arg1, sysarg_t arg2, sysarg_t arg3,
+    sysarg_t arg4, sysarg_t arg5, unsigned int mode)
 {
 	ipc_call_t data;
@@ -373,6 +371,6 @@
 	IPC_SET_ARG5(data, arg5);
 	
-	return __SYSCALL4(SYS_IPC_FORWARD_SLOW, callid, phoneid, (sysarg_t) &data,
-	    mode);
+	return __SYSCALL4(SYS_IPC_FORWARD_SLOW, chandle, phandle,
+	    (sysarg_t) &data, mode);
 }
 
Index: uspace/lib/c/include/async.h
===================================================================
--- uspace/lib/c/include/async.h	(revision ac307b25a02622848f9ee9d1bff85d6cd4c35ca2)
+++ uspace/lib/c/include/async.h	(revision 9940ce0abda70ea8d091bd0be88bbccc2059eceb)
@@ -49,6 +49,7 @@
 #include <abi/ipc/event.h>
 #include <abi/ipc/interfaces.h>
-
-typedef ipc_callid_t aid_t;
+#include <abi/cap.h>
+
+typedef sysarg_t aid_t;
 typedef sysarg_t port_id_t;
 
@@ -58,16 +59,15 @@
 /** Port connection handler
  *
- * @param callid ID of incoming call or 0 if connection initiated from
- *               inside using async_create_callback_port()
- * @param call   Incoming call or 0 if connection initiated from inside
- *               using async_create_callback_port()
- * @param arg    Local argument.
- *
- */
-typedef void (*async_port_handler_t)(ipc_callid_t, ipc_call_t *, void *);
+ * @param chandle  Handle of the incoming call or CAP_NIL if connection
+ *                 initiated from inside using async_create_callback_port()
+ * @param call     Incoming call or 0 if connection initiated from inside
+ *                 using async_create_callback_port()
+ * @param arg      Local argument.
+ *
+ */
+typedef void (*async_port_handler_t)(cap_handle_t, ipc_call_t *, void *);
 
 /** Notification handler */
-typedef void (*async_notification_handler_t)(ipc_callid_t, ipc_call_t *,
-    void *);
+typedef void (*async_notification_handler_t)(ipc_call_t *, void *);
 
 /** Exchange management style
@@ -119,5 +119,5 @@
 	async_get_call_timeout(data, 0)
 
-extern ipc_callid_t async_get_call_timeout(ipc_call_t *, suseconds_t);
+extern cap_handle_t async_get_call_timeout(ipc_call_t *, suseconds_t);
 
 /*
@@ -196,12 +196,12 @@
  */
 
-extern sysarg_t async_answer_0(ipc_callid_t, sysarg_t);
-extern sysarg_t async_answer_1(ipc_callid_t, sysarg_t, sysarg_t);
-extern sysarg_t async_answer_2(ipc_callid_t, sysarg_t, sysarg_t, sysarg_t);
-extern sysarg_t async_answer_3(ipc_callid_t, sysarg_t, sysarg_t, sysarg_t,
+extern sysarg_t async_answer_0(cap_handle_t, sysarg_t);
+extern sysarg_t async_answer_1(cap_handle_t, sysarg_t, sysarg_t);
+extern sysarg_t async_answer_2(cap_handle_t, sysarg_t, sysarg_t, sysarg_t);
+extern sysarg_t async_answer_3(cap_handle_t, sysarg_t, sysarg_t, sysarg_t,
     sysarg_t);
-extern sysarg_t async_answer_4(ipc_callid_t, sysarg_t, sysarg_t, sysarg_t,
+extern sysarg_t async_answer_4(cap_handle_t, sysarg_t, sysarg_t, sysarg_t,
     sysarg_t, sysarg_t);
-extern sysarg_t async_answer_5(ipc_callid_t, sysarg_t, sysarg_t, sysarg_t,
+extern sysarg_t async_answer_5(cap_handle_t, sysarg_t, sysarg_t, sysarg_t,
     sysarg_t, sysarg_t, sysarg_t);
 
@@ -210,7 +210,7 @@
  */
 
-extern int async_forward_fast(ipc_callid_t, async_exch_t *, sysarg_t, sysarg_t,
+extern int async_forward_fast(cap_handle_t, async_exch_t *, sysarg_t, sysarg_t,
     sysarg_t, unsigned int);
-extern int async_forward_slow(ipc_callid_t, async_exch_t *, sysarg_t, sysarg_t,
+extern int async_forward_slow(cap_handle_t, async_exch_t *, sysarg_t, sysarg_t,
     sysarg_t, sysarg_t, sysarg_t, sysarg_t, unsigned int);
 
@@ -382,10 +382,10 @@
 extern int async_share_in_start(async_exch_t *, size_t, sysarg_t,
     unsigned int *, void **);
-extern bool async_share_in_receive(ipc_callid_t *, size_t *);
-extern int async_share_in_finalize(ipc_callid_t, void *, unsigned int);
+extern bool async_share_in_receive(cap_handle_t *, size_t *);
+extern int async_share_in_finalize(cap_handle_t, void *, unsigned int);
 
 extern int async_share_out_start(async_exch_t *, void *, unsigned int);
-extern bool async_share_out_receive(ipc_callid_t *, size_t *, unsigned int *);
-extern int async_share_out_finalize(ipc_callid_t, void **);
+extern bool async_share_out_receive(cap_handle_t *, size_t *, unsigned int *);
+extern int async_share_out_finalize(cap_handle_t, void **);
 
 /*
@@ -421,7 +421,7 @@
 extern aid_t async_data_read(async_exch_t *, void *, size_t, ipc_call_t *);
 extern int async_data_read_start(async_exch_t *, void *, size_t);
-extern bool async_data_read_receive(ipc_callid_t *, size_t *);
-extern bool async_data_read_receive_call(ipc_callid_t *, ipc_call_t *, size_t *);
-extern int async_data_read_finalize(ipc_callid_t, const void *, size_t);
+extern bool async_data_read_receive(cap_handle_t *, size_t *);
+extern bool async_data_read_receive_call(cap_handle_t *, ipc_call_t *, size_t *);
+extern int async_data_read_finalize(cap_handle_t, const void *, size_t);
 
 extern int async_data_read_forward_fast(async_exch_t *, sysarg_t, sysarg_t,
@@ -460,7 +460,7 @@
 
 extern int async_data_write_start(async_exch_t *, const void *, size_t);
-extern bool async_data_write_receive(ipc_callid_t *, size_t *);
-extern bool async_data_write_receive_call(ipc_callid_t *, ipc_call_t *, size_t *);
-extern int async_data_write_finalize(ipc_callid_t, void *, size_t);
+extern bool async_data_write_receive(cap_handle_t *, size_t *);
+extern bool async_data_write_receive_call(cap_handle_t *, ipc_call_t *, size_t *);
+extern int async_data_write_finalize(cap_handle_t, void *, size_t);
 
 extern int async_data_write_accept(void **, const bool, const size_t,
@@ -476,7 +476,7 @@
 extern int async_state_change_start(async_exch_t *, sysarg_t, sysarg_t,
     sysarg_t, async_exch_t *);
-extern bool async_state_change_receive(ipc_callid_t *, sysarg_t *, sysarg_t *,
+extern bool async_state_change_receive(cap_handle_t *, sysarg_t *, sysarg_t *,
     sysarg_t *);
-extern int async_state_change_finalize(ipc_callid_t, async_exch_t *);
+extern int async_state_change_finalize(cap_handle_t, async_exch_t *);
 
 extern void *async_remote_state_acquire(async_sess_t *);
Index: uspace/lib/c/include/ipc/common.h
===================================================================
--- uspace/lib/c/include/ipc/common.h	(revision ac307b25a02622848f9ee9d1bff85d6cd4c35ca2)
+++ uspace/lib/c/include/ipc/common.h	(revision 9940ce0abda70ea8d091bd0be88bbccc2059eceb)
@@ -40,4 +40,5 @@
 #include <abi/proc/task.h>
 #include <futex.h>
+#include <abi/cap.h>
 
 #define IPC_FLAG_BLOCKING  0x01
@@ -53,5 +54,5 @@
 } ipc_call_t;
 
-typedef sysarg_t ipc_callid_t;
+typedef cap_handle_t ipc_callid_t;
 
 extern futex_t async_futex;
Index: uspace/lib/c/include/ipc/ipc.h
===================================================================
--- uspace/lib/c/include/ipc/ipc.h	(revision ac307b25a02622848f9ee9d1bff85d6cd4c35ca2)
+++ uspace/lib/c/include/ipc/ipc.h	(revision 9940ce0abda70ea8d091bd0be88bbccc2059eceb)
@@ -44,8 +44,9 @@
 #include <abi/synch.h>
 #include <abi/proc/task.h>
+#include <abi/cap.h>
 
 typedef void (*ipc_async_callback_t)(void *, int, ipc_call_t *);
 
-extern ipc_callid_t ipc_wait_cycle(ipc_call_t *, sysarg_t, unsigned int);
+extern cap_handle_t ipc_wait_cycle(ipc_call_t *, sysarg_t, unsigned int);
 extern void ipc_poke(void);
 
@@ -53,6 +54,6 @@
 	ipc_wait_for_call_timeout(data, SYNCH_NO_TIMEOUT);
 
-extern ipc_callid_t ipc_wait_for_call_timeout(ipc_call_t *, sysarg_t);
-extern ipc_callid_t ipc_trywait_for_call(ipc_call_t *);
+extern cap_handle_t ipc_wait_for_call_timeout(ipc_call_t *, sysarg_t);
+extern cap_handle_t ipc_trywait_for_call(ipc_call_t *);
 
 /*
@@ -63,20 +64,21 @@
  */
 
-#define ipc_answer_0(callid, retval) \
-	ipc_answer_fast((callid), (retval), 0, 0, 0, 0)
-#define ipc_answer_1(callid, retval, arg1) \
-	ipc_answer_fast((callid), (retval), (arg1), 0, 0, 0)
-#define ipc_answer_2(callid, retval, arg1, arg2) \
-	ipc_answer_fast((callid), (retval), (arg1), (arg2), 0, 0)
-#define ipc_answer_3(callid, retval, arg1, arg2, arg3) \
-	ipc_answer_fast((callid), (retval), (arg1), (arg2), (arg3), 0)
-#define ipc_answer_4(callid, retval, arg1, arg2, arg3, arg4) \
-	ipc_answer_fast((callid), (retval), (arg1), (arg2), (arg3), (arg4))
-#define ipc_answer_5(callid, retval, arg1, arg2, arg3, arg4, arg5) \
-	ipc_answer_slow((callid), (retval), (arg1), (arg2), (arg3), (arg4), (arg5))
+#define ipc_answer_0(chandle, retval) \
+	ipc_answer_fast((chandle), (retval), 0, 0, 0, 0)
+#define ipc_answer_1(chandle, retval, arg1) \
+	ipc_answer_fast((chandle), (retval), (arg1), 0, 0, 0)
+#define ipc_answer_2(chandle, retval, arg1, arg2) \
+	ipc_answer_fast((chandle), (retval), (arg1), (arg2), 0, 0)
+#define ipc_answer_3(chandle, retval, arg1, arg2, arg3) \
+	ipc_answer_fast((chandle), (retval), (arg1), (arg2), (arg3), 0)
+#define ipc_answer_4(chandle, retval, arg1, arg2, arg3, arg4) \
+	ipc_answer_fast((chandle), (retval), (arg1), (arg2), (arg3), (arg4))
+#define ipc_answer_5(chandle, retval, arg1, arg2, arg3, arg4, arg5) \
+	ipc_answer_slow((chandle), (retval), (arg1), (arg2), (arg3), (arg4), \
+	    (arg5))
 
-extern sysarg_t ipc_answer_fast(ipc_callid_t, sysarg_t, sysarg_t, sysarg_t,
+extern sysarg_t ipc_answer_fast(cap_handle_t, sysarg_t, sysarg_t, sysarg_t,
     sysarg_t, sysarg_t);
-extern sysarg_t ipc_answer_slow(ipc_callid_t, sysarg_t, sysarg_t, sysarg_t,
+extern sysarg_t ipc_answer_slow(cap_handle_t, sysarg_t, sysarg_t, sysarg_t,
     sysarg_t, sysarg_t, sysarg_t);
 
@@ -88,35 +90,35 @@
  */
 
-#define ipc_call_async_0(phoneid, method, private, callback) \
-	ipc_call_async_fast((phoneid), (method), 0, 0, 0, (private), (callback))
-#define ipc_call_async_1(phoneid, method, arg1, private, callback) \
-	ipc_call_async_fast((phoneid), (method), (arg1), 0, 0, (private), \
+#define ipc_call_async_0(phandle, method, private, callback) \
+	ipc_call_async_fast((phandle), (method), 0, 0, 0, (private), (callback))
+#define ipc_call_async_1(phandle, method, arg1, private, callback) \
+	ipc_call_async_fast((phandle), (method), (arg1), 0, 0, (private), \
 	    (callback))
-#define ipc_call_async_2(phoneid, method, arg1, arg2, private, callback) \
-	ipc_call_async_fast((phoneid), (method), (arg1), (arg2), 0, \
+#define ipc_call_async_2(phandle, method, arg1, arg2, private, callback) \
+	ipc_call_async_fast((phandle), (method), (arg1), (arg2), 0, \
 	    (private), (callback))
-#define ipc_call_async_3(phoneid, method, arg1, arg2, arg3, private, callback) \
-	ipc_call_async_fast((phoneid), (method), (arg1), (arg2), (arg3), \
+#define ipc_call_async_3(phandle, method, arg1, arg2, arg3, private, callback) \
+	ipc_call_async_fast((phandle), (method), (arg1), (arg2), (arg3), \
 	    (private), (callback))
-#define ipc_call_async_4(phoneid, method, arg1, arg2, arg3, arg4, private, \
+#define ipc_call_async_4(phandle, method, arg1, arg2, arg3, arg4, private, \
     callback) \
-	ipc_call_async_slow((phoneid), (method), (arg1), (arg2), (arg3), \
+	ipc_call_async_slow((phandle), (method), (arg1), (arg2), (arg3), \
 	    (arg4), 0, (private), (callback))
-#define ipc_call_async_5(phoneid, method, arg1, arg2, arg3, arg4, arg5, \
+#define ipc_call_async_5(phandle, method, arg1, arg2, arg3, arg4, arg5, \
     private, callback) \
-	ipc_call_async_slow((phoneid), (method), (arg1), (arg2), (arg3), \
+	ipc_call_async_slow((phandle), (method), (arg1), (arg2), (arg3), \
 	    (arg4), (arg5), (private), (callback))
 
-extern void ipc_call_async_fast(int, sysarg_t, sysarg_t, sysarg_t, sysarg_t,
-    void *, ipc_async_callback_t);
-extern void ipc_call_async_slow(int, sysarg_t, sysarg_t, sysarg_t, sysarg_t,
-    sysarg_t, sysarg_t, void *, ipc_async_callback_t);
+extern void ipc_call_async_fast(cap_handle_t, sysarg_t, sysarg_t, sysarg_t,
+    sysarg_t, void *, ipc_async_callback_t);
+extern void ipc_call_async_slow(cap_handle_t, sysarg_t, sysarg_t, sysarg_t,
+    sysarg_t, sysarg_t, sysarg_t, void *, ipc_async_callback_t);
 
-extern int ipc_hangup(int);
+extern int ipc_hangup(cap_handle_t);
 
-extern int ipc_forward_fast(ipc_callid_t, int, sysarg_t, sysarg_t, sysarg_t,
-    unsigned int);
-extern int ipc_forward_slow(ipc_callid_t, int, sysarg_t, sysarg_t, sysarg_t,
-    sysarg_t, sysarg_t, sysarg_t, unsigned int);
+extern int ipc_forward_fast(cap_handle_t, cap_handle_t, sysarg_t, sysarg_t,
+    sysarg_t, unsigned int);
+extern int ipc_forward_slow(cap_handle_t, cap_handle_t, sysarg_t, sysarg_t,
+    sysarg_t, sysarg_t, sysarg_t, sysarg_t, unsigned int);
 
 extern int ipc_connect_kbox(task_id_t);
