Index: kernel/Makefile
===================================================================
--- kernel/Makefile	(revision e7ac23d02750f85979a275420d969126143b3738)
+++ kernel/Makefile	(revision 3f74275b545272926eb993b683eae30e42326ab4)
@@ -285,5 +285,5 @@
 	generic/src/ipc/irq.c \
 	generic/src/ipc/event.c \
-	generic/src/kobject/kobject.c \
+	generic/src/cap/cap.c \
 	generic/src/security/perm.c \
 	generic/src/sysinfo/sysinfo.c \
Index: kernel/generic/include/cap/cap.h
===================================================================
--- kernel/generic/include/cap/cap.h	(revision 3f74275b545272926eb993b683eae30e42326ab4)
+++ kernel/generic/include/cap/cap.h	(revision 3f74275b545272926eb993b683eae30e42326ab4)
@@ -0,0 +1,87 @@
+/*
+ * Copyright (c) 2017 Jakub Jermar
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/** @addtogroup generic
+ * @{
+ */
+/** @file
+ */
+
+#ifndef KERN_CAP_H_
+#define KERN_CAP_H_
+
+#include <typedefs.h>
+#include <ipc/ipc.h>
+#include <ddi/irq.h>
+
+#define MAX_CAPS  64
+
+#define for_each_cap(task, cap, type) \
+	for (int i = 0, l = 1; i < MAX_CAPS && l; i++) \
+		for (cap_t *(cap) = cap_get((task), i, (type)); \
+		    (cap) && !(l = 0); (cap) = NULL, l = 1)
+
+#define for_each_cap_current(cap, type) \
+	for_each_cap(TASK, (cap), (type))
+
+typedef enum {
+	CAP_TYPE_INVALID,
+	CAP_TYPE_ALLOCATED,
+	CAP_TYPE_PHONE,
+	CAP_TYPE_IRQ
+} cap_type_t;
+
+typedef struct cap {
+	cap_type_t type;
+	bool (* can_reclaim)(struct cap *);
+
+	/* The underlying kernel object. */
+	union {
+		phone_t phone;
+		irq_t irq;
+	};
+} cap_t;
+
+struct task;
+
+void caps_task_alloc(struct task *);
+void caps_task_free(struct task *);
+void caps_task_init(struct task *);
+
+extern void cap_initialize(cap_t *);
+extern cap_t *cap_get(struct task *, int, cap_type_t);
+extern cap_t *cap_get_current(int, cap_type_t);
+extern int cap_alloc(struct task *);
+extern void cap_free(struct task *, int);
+
+extern int cap_get_handle(struct task *, cap_t *);
+
+#endif
+
+/** @}
+ */
Index: kernel/generic/include/kobject/kobject.h
===================================================================
--- kernel/generic/include/kobject/kobject.h	(revision e7ac23d02750f85979a275420d969126143b3738)
+++ 	(revision )
@@ -1,86 +1,0 @@
-/*
- * Copyright (c) 2017 Jakub Jermar
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/** @addtogroup generic
- * @{
- */
-/** @file
- */
-
-#ifndef KERN_KOBJECT_H_
-#define KERN_KOBJECT_H_
-
-#include <typedefs.h>
-#include <ipc/ipc.h>
-#include <ddi/irq.h>
-
-#define MAX_KERNEL_OBJECTS  64
-
-#define for_each_kobject(task, ko, type) \
-	for (int i = 0, l = 1; i < MAX_KERNEL_OBJECTS && l; i++) \
-		for (kobject_t *(ko) = kobject_get((task), i, (type)); \
-		    (ko) && !(l = 0); (ko) = NULL, l = 1)
-
-#define for_each_kobject_current(ko, type) \
-	for_each_kobject(TASK, (ko), (type))
-
-typedef enum {
-	KOBJECT_TYPE_INVALID,
-	KOBJECT_TYPE_ALLOCATED,
-	KOBJECT_TYPE_PHONE,
-	KOBJECT_TYPE_IRQ
-} kobject_type_t;
-
-typedef struct kobject {
-	kobject_type_t type;
-	bool (* can_reclaim)(struct kobject *);
-
-	union {
-		phone_t phone;
-		irq_t irq;
-	};
-} kobject_t;
-
-struct task;
-
-void kobject_task_alloc(struct task *);
-void kobject_task_free(struct task *);
-void kobject_task_init(struct task *);
-
-extern void kobject_initialize(kobject_t *);
-extern kobject_t *kobject_get(struct task *, int, kobject_type_t);
-extern kobject_t *kobject_get_current(int, kobject_type_t);
-extern int kobject_alloc(struct task *);
-extern void kobject_free(struct task *, int);
-
-extern int kobject_to_cap(struct task *, kobject_t *);
-
-#endif
-
-/** @}
- */
Index: kernel/generic/include/proc/task.h
===================================================================
--- kernel/generic/include/proc/task.h	(revision e7ac23d02750f85979a275420d969126143b3738)
+++ kernel/generic/include/proc/task.h	(revision 3f74275b545272926eb993b683eae30e42326ab4)
@@ -65,5 +65,5 @@
 
 struct thread;
-struct kobject;
+struct cap;
 
 /** Task structure. */
@@ -97,6 +97,6 @@
 	perm_t perms;
 
-	/** Kernel objects */
-	struct kobject *kobject;
+	/** Capabilities */
+	struct cap *caps;
 	
 	/* IPC stuff */
Index: kernel/generic/src/cap/cap.c
===================================================================
--- kernel/generic/src/cap/cap.c	(revision 3f74275b545272926eb993b683eae30e42326ab4)
+++ kernel/generic/src/cap/cap.c	(revision 3f74275b545272926eb993b683eae30e42326ab4)
@@ -0,0 +1,116 @@
+/*
+ * Copyright (c) 2017 Jakub Jermar
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/** @addtogroup generic
+ * @{
+ */
+/** @file
+ */
+
+#include <cap/cap.h>
+#include <proc/task.h>
+#include <synch/spinlock.h>
+#include <abi/errno.h>
+#include <mm/slab.h>
+
+void cap_initialize(cap_t *cap)
+{
+	cap->type = CAP_TYPE_INVALID;
+	cap->can_reclaim = NULL;
+}
+
+void caps_task_alloc(task_t *task)
+{
+	task->caps = malloc(sizeof(cap_t) * MAX_CAPS, 0);
+}
+
+void caps_task_init(task_t *task)
+{
+	for (int i = 0; i < MAX_CAPS; i++)
+		cap_initialize(&task->caps[i]);
+}
+
+void caps_task_free(task_t *task)
+{
+	free(task->caps);
+}
+
+cap_t *cap_get(task_t *task, int handle, cap_type_t type)
+{
+	if ((handle < 0) || (handle >= MAX_CAPS))
+		return NULL;
+	if (task->caps[handle].type != type)
+		return NULL;
+	return &task->caps[handle];
+}
+
+cap_t *cap_get_current(int handle, cap_type_t type)
+{
+	return cap_get(TASK, handle, type);
+}
+
+int cap_alloc(task_t *task)
+{
+	int handle;
+
+	irq_spinlock_lock(&task->lock, true);
+	for (handle = 0; handle < MAX_CAPS; handle++) {
+		cap_t *cap = &task->caps[handle];
+		if (cap->type > CAP_TYPE_ALLOCATED) {
+			if (cap->can_reclaim && cap->can_reclaim(cap))
+				cap_initialize(cap);
+		}
+		if (cap->type == CAP_TYPE_INVALID) {
+			cap->type = CAP_TYPE_ALLOCATED;
+			irq_spinlock_unlock(&task->lock, true);
+			return handle;
+		}
+	}
+	irq_spinlock_unlock(&task->lock, true);
+
+	return ELIMIT;
+}
+
+void cap_free(task_t *task, int handle)
+{
+	assert(handle >= 0);
+	assert(handle < MAX_CAPS);
+	assert(task->caps[handle].type != CAP_TYPE_INVALID);
+
+	irq_spinlock_lock(&task->lock, true);
+	cap_initialize(&task->caps[handle]);
+	irq_spinlock_unlock(&task->lock, true);
+}
+
+int cap_get_handle(task_t *task, cap_t *cap)
+{
+	return cap - task->caps;
+}
+
+/** @}
+ */
Index: kernel/generic/src/ipc/ipc.c
===================================================================
--- kernel/generic/src/ipc/ipc.c	(revision e7ac23d02750f85979a275420d969126143b3738)
+++ kernel/generic/src/ipc/ipc.c	(revision 3f74275b545272926eb993b683eae30e42326ab4)
@@ -59,5 +59,5 @@
 #include <arch/interrupt.h>
 #include <ipc/irq.h>
-#include <kobject/kobject.h>
+#include <cap/cap.h>
 
 static void ipc_forget_call(call_t *);
@@ -743,6 +743,6 @@
 	 */
 	all_clean = true;
-	for_each_kobject_current(kobj, KOBJECT_TYPE_PHONE) {
-		phone_t *phone = &kobj->phone;
+	for_each_cap_current(cap, CAP_TYPE_PHONE) {
+		phone_t *phone = &cap->phone;
 
 		mutex_lock(&phone->lock);
@@ -820,6 +820,6 @@
 
 	/* Disconnect all our phones ('ipc_phone_hangup') */
-	for_each_kobject_current(kobj, KOBJECT_TYPE_PHONE) {
-		phone_t *phone = &kobj->phone;
+	for_each_cap_current(cap, CAP_TYPE_PHONE) {
+		phone_t *phone = &cap->phone;
 		ipc_phone_hangup(phone);
 	}
@@ -911,15 +911,15 @@
 	printf("[phone cap] [calls] [state\n");
 	
-	for_each_kobject(task, kobj, KOBJECT_TYPE_PHONE) {
-		phone_t *phone = &kobj->phone;
-		int cap = kobject_to_cap(task, kobj);
-
+	for_each_cap(task, cap, CAP_TYPE_PHONE) {
+		phone_t *phone = &cap->phone;
+		int cap_handle = cap_get_handle(task, cap);
+	
 		if (SYNCH_FAILED(mutex_trylock(&phone->lock))) {
-			printf("%-11d (mutex busy)\n", cap);
+			printf("%-11d (mutex busy)\n", cap_handle);
 			continue;
 		}
 		
 		if (phone->state != IPC_PHONE_FREE) {
-			printf("%-11d %7" PRIun " ", cap,
+			printf("%-11d %7" PRIun " ", cap_handle,
 			    atomic_get(&phone->active_calls));
 			
Index: kernel/generic/src/ipc/ipcrsc.c
===================================================================
--- kernel/generic/src/ipc/ipcrsc.c	(revision e7ac23d02750f85979a275420d969126143b3738)
+++ kernel/generic/src/ipc/ipcrsc.c	(revision 3f74275b545272926eb993b683eae30e42326ab4)
@@ -133,5 +133,5 @@
 #include <assert.h>
 #include <abi/errno.h>
-#include <kobject/kobject.h>
+#include <cap/cap.h>
 
 /** Find call_t * in call table according to callid.
@@ -163,8 +163,8 @@
 }
 
-/** Get phone from the current task by capability.
- *
- * @param cap    Phone capability.
- * @param phone  Place to store pointer to phone.
+/** Get phone from the current task by capability handle.
+ *
+ * @param handle  Phone capability handle.
+ * @param phone   Place to store pointer to phone.
  *
  * @return  Address of the phone kernel object.
@@ -172,24 +172,24 @@
  *
  */
-phone_t *phone_get(task_t *task, int cap)
-{
-	kobject_t *kobj = kobject_get(task, cap, KOBJECT_TYPE_PHONE);
-	if (!kobj)
+phone_t *phone_get(task_t *task, int handle)
+{
+	cap_t *cap = cap_get(task, handle, CAP_TYPE_PHONE);
+	if (!cap)
 		return NULL;
 	
-	return &kobj->phone;
-}
-
-phone_t *phone_get_current(int cap)
-{
-	return phone_get(TASK, cap);
-}
-
-static bool phone_can_reclaim(kobject_t *kobj)
-{
-	assert(kobj->type == KOBJECT_TYPE_PHONE);
-
-	return (kobj->phone.state == IPC_PHONE_HUNGUP) &&
-	    (atomic_get(&kobj->phone.active_calls) == 0);
+	return &cap->phone;
+}
+
+phone_t *phone_get_current(int handle)
+{
+	return phone_get(TASK, handle);
+}
+
+static bool phone_can_reclaim(cap_t *cap)
+{
+	assert(cap->type == CAP_TYPE_PHONE);
+
+	return (cap->phone.state == IPC_PHONE_HUNGUP) &&
+	    (atomic_get(&cap->phone.active_calls) == 0);
 }
 
@@ -198,21 +198,21 @@
  * @param task  Task for which to allocate a new phone.
  *
- * @return  New phone capability.
+ * @return  New phone capability handle.
  * @return  Negative error code if a new capability cannot be allocated.
  */
 int phone_alloc(task_t *task)
 {
-	int cap = kobject_alloc(task);
-	if (cap >= 0) {
+	int handle = cap_alloc(task);
+	if (handle >= 0) {
 		irq_spinlock_lock(&task->lock, true);
-		kobject_t *kobj = &task->kobject[cap];
-		ipc_phone_init(&kobj->phone, task);
-		kobj->type = KOBJECT_TYPE_PHONE;
-		kobj->can_reclaim = phone_can_reclaim;
-		kobj->phone.state = IPC_PHONE_CONNECTING;
+		cap_t *cap = &task->caps[handle];
+		ipc_phone_init(&cap->phone, task);
+		cap->type = CAP_TYPE_PHONE;
+		cap->can_reclaim = phone_can_reclaim;
+		cap->phone.state = IPC_PHONE_CONNECTING;
 		irq_spinlock_unlock(&task->lock, true);
 	}
 	
-	return cap;
+	return handle;
 }
 
@@ -221,22 +221,22 @@
  * All already sent messages will be correctly processed.
  *
- * @param phoneid Phone handle of the phone to be freed.
- *
- */
-void phone_dealloc(int cap)
-{
-	phone_t *phone = phone_get_current(cap);
+ * @param handle Phone capability handle of the phone to be freed.
+ *
+ */
+void phone_dealloc(int handle)
+{
+	phone_t *phone = phone_get_current(handle);
 	
 	assert(phone);
 	assert(phone->state == IPC_PHONE_CONNECTING);
 
-	kobject_free(TASK, cap);
+	cap_free(TASK, handle);
 }
 
 /** Connect phone to a given answerbox.
  *
- * @param cap  Phone capability to be connected.
- * @param box  Answerbox to which to connect the phone capability.
- * @return     True if the phone was connected, false otherwise.
+ * @param handle  Capability handle of the phone to be connected.
+ * @param box     Answerbox to which to connect the phone.
+ * @return        True if the phone was connected, false otherwise.
  *
  * The procedure _enforces_ that the user first marks the phone busy (e.g. via
@@ -245,7 +245,7 @@
  *
  */
-bool phone_connect(int cap, answerbox_t *box)
-{
-	phone_t *phone = phone_get_current(cap);
+bool phone_connect(int handle, answerbox_t *box)
+{
+	phone_t *phone = phone_get_current(handle);
 	
 	assert(phone);
Index: kernel/generic/src/ipc/irq.c
===================================================================
--- kernel/generic/src/ipc/irq.c	(revision e7ac23d02750f85979a275420d969126143b3738)
+++ kernel/generic/src/ipc/irq.c	(revision 3f74275b545272926eb993b683eae30e42326ab4)
@@ -84,5 +84,5 @@
 #include <print.h>
 #include <macros.h>
-#include <kobject/kobject.h>
+#include <cap/cap.h>
 
 static void ranges_unmap(irq_pio_range_t *ranges, size_t rangecount)
@@ -298,5 +298,5 @@
  * @param ucode   Uspace pointer to top-half pseudocode.
  *
- * @return  IRQ capability.
+ * @return  IRQ capability handle.
  * @return  Negative error code.
  *
@@ -324,12 +324,12 @@
 	 * Allocate and populate the IRQ kernel object.
 	 */
-	int cap = kobject_alloc(TASK);
-	if (cap < 0)
-		return cap;
-	kobject_t *kobj = kobject_get_current(cap, KOBJECT_TYPE_ALLOCATED);
-	assert(kobj);
-	kobj->type = KOBJECT_TYPE_IRQ;
-
-	irq_t *irq = &kobj->irq;
+	int handle = cap_alloc(TASK);
+	if (handle < 0)
+		return handle;
+	cap_t *cap = cap_get_current(handle, CAP_TYPE_ALLOCATED);
+	assert(cap);
+	cap->type = CAP_TYPE_IRQ;
+
+	irq_t *irq = &cap->irq;
 	irq_initialize(irq);
 	irq->inr = inr;
@@ -357,21 +357,21 @@
 	irq_spinlock_unlock(&irq_uspace_hash_table_lock, true);
 	
-	return cap;
+	return handle;
 }
 
 /** Unsubscribe task from IRQ notification.
  *
- * @param box      Answerbox associated with the notification.
- * @param irq_cap  IRQ capability.
+ * @param box     Answerbox associated with the notification.
+ * @param handle  IRQ capability handle.
  *
  * @return EOK on success or a negative error code.
  *
  */
-int ipc_irq_unsubscribe(answerbox_t *box, int irq_cap)
-{
-	kobject_t *kobj = kobject_get_current(irq_cap, KOBJECT_TYPE_IRQ);
-	if (!kobj)
+int ipc_irq_unsubscribe(answerbox_t *box, int handle)
+{
+	cap_t *cap = cap_get_current(handle, CAP_TYPE_IRQ);
+	if (!cap)
 		return ENOENT;
-	irq_t *irq = &kobj->irq;
+	irq_t *irq = &cap->irq;
 
 	irq_spinlock_lock(&irq_uspace_hash_table_lock, true);
@@ -394,6 +394,6 @@
 	code_free(irq->notif_cfg.code);
 	
-	/* Free up the IRQ kernel object. */
-	kobject_free(TASK, irq_cap);
+	/* Free up the IRQ capability and the underlying kernel object. */
+	cap_free(TASK, handle);
 	
 	return EOK;
Index: kernel/generic/src/kobject/kobject.c
===================================================================
--- kernel/generic/src/kobject/kobject.c	(revision e7ac23d02750f85979a275420d969126143b3738)
+++ 	(revision )
@@ -1,116 +1,0 @@
-/*
- * Copyright (c) 2017 Jakub Jermar
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/** @addtogroup generic
- * @{
- */
-/** @file
- */
-
-#include <kobject/kobject.h>
-#include <proc/task.h>
-#include <synch/spinlock.h>
-#include <abi/errno.h>
-#include <mm/slab.h>
-
-void kobject_initialize(kobject_t *kobj)
-{
-	kobj->type = KOBJECT_TYPE_INVALID;
-	kobj->can_reclaim = NULL;
-}
-
-void kobject_task_alloc(task_t *task)
-{
-	task->kobject = malloc(sizeof(kobject_t) * MAX_KERNEL_OBJECTS, 0);
-}
-
-void kobject_task_init(task_t *task)
-{
-	for (int cap = 0; cap < MAX_KERNEL_OBJECTS; cap++)
-		kobject_initialize(&task->kobject[cap]);
-}
-
-void kobject_task_free(task_t *task)
-{
-	free(task->kobject);
-}
-
-kobject_t *kobject_get(task_t *task, int cap, kobject_type_t type)
-{
-	if ((cap < 0) || (cap >= MAX_KERNEL_OBJECTS))
-		return NULL;
-	if (task->kobject[cap].type != type)
-		return NULL;
-	return &task->kobject[cap];
-}
-
-kobject_t *kobject_get_current(int cap, kobject_type_t type)
-{
-	return kobject_get(TASK, cap, type);
-}
-
-int kobject_alloc(task_t *task)
-{
-	int cap;
-
-	irq_spinlock_lock(&task->lock, true);
-	for (cap = 0; cap < MAX_KERNEL_OBJECTS; cap++) {
-		kobject_t *kobj = &task->kobject[cap];
-		if (kobj->type > KOBJECT_TYPE_ALLOCATED) {
-			if (kobj->can_reclaim && kobj->can_reclaim(kobj))
-				kobject_initialize(kobj);
-		}
-		if (kobj->type == KOBJECT_TYPE_INVALID) {
-			kobj->type = KOBJECT_TYPE_ALLOCATED;
-			irq_spinlock_unlock(&task->lock, true);
-			return cap;
-		}
-	}
-	irq_spinlock_unlock(&task->lock, true);
-
-	return ELIMIT;
-}
-
-void kobject_free(task_t *task, int cap)
-{
-	assert(cap >= 0);
-	assert(cap < MAX_KERNEL_OBJECTS);
-	assert(task->kobject[cap].type != KOBJECT_TYPE_INVALID);
-
-	irq_spinlock_lock(&task->lock, true);
-	kobject_initialize(&task->kobject[cap]);
-	irq_spinlock_unlock(&task->lock, true);
-}
-
-int kobject_to_cap(task_t *task, kobject_t *kobj)
-{
-	return kobj - task->kobject;
-}
-
-/** @}
- */
Index: kernel/generic/src/proc/task.c
===================================================================
--- kernel/generic/src/proc/task.c	(revision e7ac23d02750f85979a275420d969126143b3738)
+++ kernel/generic/src/proc/task.c	(revision 3f74275b545272926eb993b683eae30e42326ab4)
@@ -50,5 +50,5 @@
 #include <adt/btree.h>
 #include <adt/list.h>
-#include <kobject/kobject.h>
+#include <cap/cap.h>
 #include <ipc/ipc.h>
 #include <ipc/ipcrsc.h>
@@ -169,5 +169,5 @@
 	list_initialize(&task->threads);
 	
-	kobject_task_alloc(task);
+	caps_task_alloc(task);
 	
 	ipc_answerbox_init(&task->answerbox, task);
@@ -190,5 +190,5 @@
 	task_t *task = (task_t *) obj;
 	
-	kobject_task_free(task);
+	caps_task_free(task);
 	return 0;
 }
@@ -215,5 +215,5 @@
 	task->kcycles = 0;
 
-	kobject_task_init(task);
+	caps_task_init(task);
 
 	task->ipc_info.call_sent = 0;
@@ -624,8 +624,8 @@
 	
 	if (*additional) {
-		for_each_kobject(task, ko, KOBJECT_TYPE_PHONE) {
-			phone_t *phone = &ko->phone;
+		for_each_cap(task, cap, CAP_TYPE_PHONE) {
+			phone_t *phone = &cap->phone;
 			if (phone->callee)
-				printf(" %d:%p", kobject_to_cap(task, ko),
+				printf(" %d:%p", cap_get_handle(task, cap),
 				    phone->callee);
 		}
