Index: uspace/lib/c/generic/async.c
===================================================================
--- uspace/lib/c/generic/async.c	(revision 503ffceaab0f4c54907677d3399c3ed1363e507f)
+++ uspace/lib/c/generic/async.c	(revision 474c68b035efbc94a86c767f8dd6133e1652189e)
@@ -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);
 }
 
