Index: kernel/generic/include/cap/cap.h
===================================================================
--- kernel/generic/include/cap/cap.h	(revision 6abfd250b332c7fec99a5c8647d7dc3d22442cb3)
+++ kernel/generic/include/cap/cap.h	(revision 48bcf4941bbfdcd0432cdae89d208c3fd44aecf5)
@@ -37,29 +37,57 @@
 
 #include <typedefs.h>
-#include <ipc/ipc.h>
 #include <adt/list.h>
 #include <synch/mutex.h>
+#include <atomic.h>
 
 #define MAX_CAPS  64
 
+typedef int cap_handle_t;
+
 typedef enum {
-	CAP_TYPE_INVALID,
-	CAP_TYPE_ALLOCATED,
-	CAP_TYPE_PHONE,
-	CAP_TYPE_IRQ,
-	CAP_TYPE_MAX
-} cap_type_t;
+	CAP_STATE_FREE,
+	CAP_STATE_ALLOCATED,
+	CAP_STATE_PUBLISHED
+} cap_state_t;
+
+typedef enum {
+	KOBJECT_TYPE_PHONE,
+	KOBJECT_TYPE_IRQ,
+	KOBJECT_TYPE_MAX
+} kobject_type_t;
+
+struct task;
+struct phone;
+struct irq;
+
+struct kobject;
+typedef struct kobject_ops {
+	bool (*reclaim)(struct kobject *);
+	void (*destroy)(void *);
+} kobject_ops_t;
+
+typedef struct kobject {
+	kobject_type_t type;
+	atomic_t refcnt;
+
+	kobject_ops_t *ops;
+
+	union {
+		void *raw;
+		struct phone *phone;
+		struct irq *irq;
+	};
+} kobject_t;
 
 typedef struct cap {
-	cap_type_t type;
-	int handle;
+	cap_state_t state;
 
-	bool (* can_reclaim)(struct cap *);
+	cap_handle_t handle;
 
-	/* Link to the task's capabilities of the same type. */
+	/* Link to the task's capabilities of the same kobject type. */
 	link_t link;
 
 	/* The underlying kernel object. */
-	void *kobject;
+	kobject_t *kobject;
 } cap_t;
 
@@ -67,25 +95,25 @@
 	mutex_t lock;
 
-	list_t type_list[CAP_TYPE_MAX];
+	list_t type_list[KOBJECT_TYPE_MAX];
 
 	cap_t *caps;
 } cap_info_t;
 
-struct task;
-
 extern void caps_task_alloc(struct task *);
 extern void caps_task_free(struct task *);
 extern void caps_task_init(struct task *);
-extern bool caps_apply_to_type(struct task *, cap_type_t,
+extern bool caps_apply_to_kobject_type(struct task *, kobject_type_t,
     bool (*)(cap_t *, void *), void *);
-extern void caps_lock(struct task *);
-extern void caps_unlock(struct task *);
 
-extern void cap_initialize(cap_t *, int);
-extern cap_t *cap_get(struct task *, int, cap_type_t);
-extern int cap_alloc(struct task *);
-extern void cap_publish(struct task *, int, cap_type_t, void *);
-extern cap_t *cap_unpublish(struct task *, int, cap_type_t);
-extern void cap_free(struct task *, int);
+extern void cap_initialize(cap_t *, cap_handle_t);
+extern cap_handle_t cap_alloc(struct task *);
+extern void cap_publish(struct task *, cap_handle_t, kobject_t *);
+extern kobject_t *cap_unpublish(struct task *, cap_handle_t, kobject_type_t);
+extern void cap_free(struct task *, cap_handle_t);
+
+extern void kobject_initialize(kobject_t *, kobject_type_t, void *,
+    kobject_ops_t *);
+extern kobject_t *kobject_get(struct task *, cap_handle_t, kobject_type_t);
+extern void kobject_put(kobject_t *);
 
 #endif
Index: kernel/generic/include/ddi/irq.h
===================================================================
--- kernel/generic/include/ddi/irq.h	(revision 6abfd250b332c7fec99a5c8647d7dc3d22442cb3)
+++ kernel/generic/include/ddi/irq.h	(revision 48bcf4941bbfdcd0432cdae89d208c3fd44aecf5)
@@ -81,4 +81,6 @@
 	/** When false, notifications are not sent. */
 	bool notify;
+	/** True if the structure is in irq_uspace_hash_table_table */
+	bool hashed_in;
 	/** Answerbox for notifications. */
 	answerbox_t *answerbox;
Index: kernel/generic/include/ipc/ipc.h
===================================================================
--- kernel/generic/include/ipc/ipc.h	(revision 6abfd250b332c7fec99a5c8647d7dc3d22442cb3)
+++ kernel/generic/include/ipc/ipc.h	(revision 48bcf4941bbfdcd0432cdae89d208c3fd44aecf5)
@@ -43,4 +43,5 @@
 #include <typedefs.h>
 #include <mm/slab.h>
+#include <cap/cap.h>
 
 struct answerbox;
@@ -61,5 +62,5 @@
 
 /** Structure identifying phone (in TASK structure) */
-typedef struct {
+typedef struct phone {
 	mutex_t lock;
 	link_t link;
@@ -68,4 +69,5 @@
 	ipc_phone_state_t state;
 	atomic_t active_calls;
+	kobject_t *kobject;
 } phone_t;
 
Index: kernel/generic/include/ipc/ipcrsc.h
===================================================================
--- kernel/generic/include/ipc/ipcrsc.h	(revision 6abfd250b332c7fec99a5c8647d7dc3d22442cb3)
+++ kernel/generic/include/ipc/ipcrsc.h	(revision 48bcf4941bbfdcd0432cdae89d208c3fd44aecf5)
@@ -38,11 +38,10 @@
 #include <proc/task.h>
 #include <ipc/ipc.h>
+#include <cap/cap.h>
 
 extern call_t *get_call(sysarg_t);
-extern phone_t *phone_get_current(int);
-extern phone_t *phone_get(task_t *, int);
-extern int phone_alloc(task_t *);
-extern bool phone_connect(int, answerbox_t *);
-extern void phone_dealloc(int);
+extern cap_handle_t phone_alloc(task_t *);
+extern bool phone_connect(cap_handle_t, answerbox_t *);
+extern void phone_dealloc(cap_handle_t);
 
 #endif
