Index: uspace/app/trace/ipcp.c
===================================================================
--- uspace/app/trace/ipcp.c	(revision a35b458e9db1ca95e679799dc7c1b12c83359ca3)
+++ uspace/app/trace/ipcp.c	(revision eadaeae8dacc68cf558028f23cc96b90a08b7361)
@@ -46,9 +46,9 @@
 
 typedef struct {
-	sysarg_t phone_hash;
+	cap_phone_handle_t phone_handle;
 	ipc_call_t question;
 	oper_t *oper;
 
-	ipc_callid_t call_hash;
+	cap_call_handle_t call_handle;
 
 	ht_link_t link;
@@ -75,6 +75,6 @@
 static size_t pending_call_key_hash(void *key)
 {
-	ipc_callid_t *call_id = (ipc_callid_t *)key;
-	return *call_id;
+	cap_call_handle_t *chandle = (cap_call_handle_t *) key;
+	return CAP_HANDLE_RAW(*chandle);
 }
 
@@ -82,13 +82,13 @@
 {
 	pending_call_t *hs = hash_table_get_inst(item, pending_call_t, link);
-	return hs->call_hash;
+	return CAP_HANDLE_RAW(hs->call_handle);
 }
 
 static bool pending_call_key_equal(void *key, const ht_link_t *item)
 {
-	ipc_callid_t *call_id = (ipc_callid_t *)key;
+	cap_call_handle_t *chandle = (cap_call_handle_t *) key;
 	pending_call_t *hs = hash_table_get_inst(item, pending_call_t, link);
 
-	return *call_id == hs->call_hash;
+	return *chandle == hs->call_handle;
 }
 
@@ -102,17 +102,20 @@
 
 
-void ipcp_connection_set(int phone, int server, proto_t *proto)
-{
-	if (phone <0 || phone >= MAX_PHONE) return;
-	connections[phone].server = server;
-	connections[phone].proto = proto;
-	have_conn[phone] = 1;
-}
-
-void ipcp_connection_clear(int phone)
-{
-	have_conn[phone] = 0;
-	connections[phone].server = 0;
-	connections[phone].proto = NULL;
+void ipcp_connection_set(cap_phone_handle_t phone, int server, proto_t *proto)
+{
+	// XXX: there is no longer a limit on the number of phones as phones are
+	// now handled using capabilities
+	if (CAP_HANDLE_RAW(phone) < 0 || CAP_HANDLE_RAW(phone) >= MAX_PHONE)
+	    return;
+	connections[CAP_HANDLE_RAW(phone)].server = server;
+	connections[CAP_HANDLE_RAW(phone)].proto = proto;
+	have_conn[CAP_HANDLE_RAW(phone)] = 1;
+}
+
+void ipcp_connection_clear(cap_phone_handle_t phone)
+{
+	have_conn[CAP_HANDLE_RAW(phone)] = 0;
+	connections[CAP_HANDLE_RAW(phone)].server = 0;
+	connections[CAP_HANDLE_RAW(phone)].proto = NULL;
 }
 
@@ -174,5 +177,6 @@
 }
 
-void ipcp_call_out(int phone, ipc_call_t *call, ipc_callid_t hash)
+void ipcp_call_out(cap_phone_handle_t phandle, ipc_call_t *call,
+    cap_call_handle_t chandle)
 {
 	pending_call_t *pcall;
@@ -182,13 +186,14 @@
 	int i;
 
-	if (have_conn[phone]) proto = connections[phone].proto;
-	else proto = NULL;
+	if (have_conn[CAP_HANDLE_RAW(phandle)])
+		proto = connections[CAP_HANDLE_RAW(phandle)].proto;
+	else
+		proto = NULL;
 
 	args = call->args;
 
 	if ((display_mask & DM_IPC) != 0) {
-		printf("Call ID: %d, phone: %d, proto: %s, method: ",
-		    hash, phone,
-		    (proto ? proto->name : "n/a"));
+		printf("Call ID: %p, phone: %p, proto: %s, method: ",
+		    chandle, phandle, (proto ? proto->name : "n/a"));
 		ipc_m_print(proto, IPC_GET_IMETHOD(*call));
 		printf(" args: (%" PRIun ", %" PRIun ", %" PRIun ", "
@@ -208,6 +213,6 @@
 		if (oper != NULL) {
 
-			printf("%s(%d).%s", (proto ? proto->name : "n/a"),
-			    phone, (oper ? oper->name : "unknown"));
+			printf("%s(%p).%s", (proto ? proto->name : "n/a"),
+			    phandle, (oper ? oper->name : "unknown"));
 
 			putchar('(');
@@ -236,7 +241,7 @@
 
 	pcall = malloc(sizeof(pending_call_t));
-	pcall->phone_hash = phone;
+	pcall->phone_handle = phandle;
 	pcall->question = *call;
-	pcall->call_hash = hash;
+	pcall->call_handle = chandle;
 	pcall->oper = oper;
 
@@ -244,13 +249,13 @@
 }
 
-static void parse_answer(ipc_callid_t hash, pending_call_t *pcall,
+static void parse_answer(cap_call_handle_t call_handle, pending_call_t *pcall,
     ipc_call_t *answer)
 {
-	sysarg_t phone;
+	cap_phone_handle_t phone;
 	sysarg_t method;
 	sysarg_t service;
 	errno_t retval;
 	proto_t *proto;
-	int cphone;
+	cap_phone_handle_t cphone;
 
 	sysarg_t *resp;
@@ -258,5 +263,5 @@
 	int i;
 
-	phone = pcall->phone_hash;
+	phone = pcall->phone_handle;
 	method = IPC_GET_IMETHOD(pcall->question);
 	retval = IPC_GET_RETVAL(*answer);
@@ -265,7 +270,7 @@
 
 	if ((display_mask & DM_IPC) != 0) {
-		printf("Response to %d: retval=%s, args = (%" PRIun ", "
+		printf("Response to %p: retval=%s, args = (%" PRIun ", "
 		    "%" PRIun ", %" PRIun ", %" PRIun ", %" PRIun ")\n",
-		    hash, str_error_name(retval), IPC_GET_ARG1(*answer),
+		    call_handle, str_error_name(retval), IPC_GET_ARG1(*answer),
 		    IPC_GET_ARG2(*answer), IPC_GET_ARG3(*answer),
 		    IPC_GET_ARG4(*answer), IPC_GET_ARG5(*answer));
@@ -307,7 +312,7 @@
 			proto = proto_unknown;
 
-		cphone = IPC_GET_ARG5(*answer);
+		cphone = (cap_phone_handle_t) IPC_GET_ARG5(*answer);
 		if ((display_mask & DM_SYSTEM) != 0) {
-			printf("Registering connection (phone %d, protocol: %s)\n", cphone,
+			printf("Registering connection (phone %p, protocol: %s)\n", cphone,
 		    proto->name);
 		}
@@ -317,5 +322,5 @@
 }
 
-void ipcp_call_in(ipc_call_t *call, ipc_callid_t hash)
+void ipcp_call_in(ipc_call_t *call, cap_call_handle_t chandle)
 {
 	ht_link_t *item;
@@ -325,10 +330,10 @@
 		/* Not a response */
 		if ((display_mask & DM_IPC) != 0) {
-			printf("Not a response (hash %d)\n", hash);
+			printf("Not a response (handle %p)\n", chandle);
 		}
 		return;
 	}
 
-	item = hash_table_find(&pending_calls, &hash);
+	item = hash_table_find(&pending_calls, &chandle);
 	if (item == NULL)
 		return; /* No matching question found */
@@ -339,14 +344,14 @@
 
 	pcall = hash_table_get_inst(item, pending_call_t, link);
-	hash_table_remove(&pending_calls, &hash);
-
-	parse_answer(hash, pcall, call);
+	hash_table_remove(&pending_calls, &chandle);
+
+	parse_answer(chandle, pcall, call);
 	free(pcall);
 }
 
-void ipcp_hangup(int phone, errno_t rc)
+void ipcp_hangup(cap_phone_handle_t phone, errno_t rc)
 {
 	if ((display_mask & DM_SYSTEM) != 0) {
-		printf("Hang phone %d up -> %s\n", phone, str_error_name(rc));
+		printf("Hang up phone %p -> %s\n", phone, str_error_name(rc));
 		ipcp_connection_clear(phone);
 	}
Index: uspace/app/trace/ipcp.h
===================================================================
--- uspace/app/trace/ipcp.h	(revision a35b458e9db1ca95e679799dc7c1b12c83359ca3)
+++ uspace/app/trace/ipcp.h	(revision eadaeae8dacc68cf558028f23cc96b90a08b7361)
@@ -41,11 +41,11 @@
 void ipcp_cleanup(void);
 
-void ipcp_call_out(int phone, ipc_call_t *call, ipc_callid_t hash);
-void ipcp_call_sync(int phone, ipc_call_t *call, ipc_call_t *answer);
-void ipcp_call_in(ipc_call_t *call, ipc_callid_t hash);
-void ipcp_hangup(int phone, errno_t rc);
+void ipcp_call_out(cap_phone_handle_t, ipc_call_t *, cap_call_handle_t);
+void ipcp_call_sync(cap_phone_handle_t, ipc_call_t *call, ipc_call_t *answer);
+void ipcp_call_in(ipc_call_t *call, cap_call_handle_t);
+void ipcp_hangup(cap_phone_handle_t, errno_t);
 
-void ipcp_connection_set(int phone, int server, proto_t *proto);
-void ipcp_connection_clear(int phone);
+void ipcp_connection_set(cap_phone_handle_t, int server, proto_t *proto);
+void ipcp_connection_clear(cap_phone_handle_t);
 
 #endif
Index: uspace/app/trace/trace.c
===================================================================
--- uspace/app/trace/trace.c	(revision a35b458e9db1ca95e679799dc7c1b12c83359ca3)
+++ uspace/app/trace/trace.c	(revision eadaeae8dacc68cf558028f23cc96b90a08b7361)
@@ -282,10 +282,10 @@
 {
 	ipc_call_t call;
-	sysarg_t phoneid;
+	cap_phone_handle_t phandle;
 
 	if (sc_rc != EOK)
 		return;
 
-	phoneid = sc_args[0];
+	phandle = (cap_phone_handle_t) sc_args[0];
 
 	IPC_SET_IMETHOD(call, sc_args[1]);
@@ -296,5 +296,5 @@
 	IPC_SET_ARG5(call, 0);
 
-	ipcp_call_out(phoneid, &call, 0);
+	ipcp_call_out(phandle, &call, 0);
 }
 
@@ -311,9 +311,9 @@
 
 	if (rc == EOK) {
-		ipcp_call_out(sc_args[0], &call, 0);
-	}
-}
-
-static void sc_ipc_wait(sysarg_t *sc_args, int sc_rc)
+		ipcp_call_out((cap_phone_handle_t) sc_args[0], &call, 0);
+	}
+}
+
+static void sc_ipc_wait(sysarg_t *sc_args, cap_call_handle_t sc_rc)
 {
 	ipc_call_t call;
@@ -390,5 +390,5 @@
 		break;
 	case SYS_IPC_WAIT:
-		sc_ipc_wait(sc_args, sc_rc);
+		sc_ipc_wait(sc_args, (cap_call_handle_t) sc_rc);
 		break;
 	default:
