Index: kernel/genarch/include/kbd/i8042.h
===================================================================
--- kernel/genarch/include/kbd/i8042.h	(revision 51baa8ad19af87e921ddfb1497fd4610a93ad7a9)
+++ kernel/genarch/include/kbd/i8042.h	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -36,5 +36,5 @@
 #define KERN_I8042_H_
 
-#include <typedefs.h>
+#include <console/chardev.h>
 
 extern void i8042_init(devno_t kbd_devno, inr_t kbd_inr, devno_t mouse_devno, inr_t mouse_inr);
Index: kernel/genarch/include/kbd/key.h
===================================================================
--- kernel/genarch/include/kbd/key.h	(revision 51baa8ad19af87e921ddfb1497fd4610a93ad7a9)
+++ kernel/genarch/include/kbd/key.h	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -38,5 +38,5 @@
 
 #include <arch/types.h>
-#include <typedefs.h>
+#include <console/chardev.h>
 
 #define KEY_RELEASE     0x80
Index: kernel/genarch/include/kbd/ns16550.h
===================================================================
--- kernel/genarch/include/kbd/ns16550.h	(revision 51baa8ad19af87e921ddfb1497fd4610a93ad7a9)
+++ kernel/genarch/include/kbd/ns16550.h	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -38,6 +38,6 @@
 #define KERN_NS16550_H_
 
-#include <typedefs.h>
-#include <ddi/irq.h>
+#include <console/chardev.h> 
+#include <ipc/irq.h>
 
 extern void ns16550_init(devno_t devno, inr_t inr, uintptr_t vaddr);
Index: kernel/genarch/include/kbd/z8530.h
===================================================================
--- kernel/genarch/include/kbd/z8530.h	(revision 51baa8ad19af87e921ddfb1497fd4610a93ad7a9)
+++ kernel/genarch/include/kbd/z8530.h	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -38,6 +38,6 @@
 #define KERN_Z8530_H_
 
-#include <typedefs.h>
-#include <ddi/irq.h>
+#include <console/chardev.h>
+#include <ipc/irq.h>
 
 extern bool z8530_belongs_to_kernel;
Index: kernel/genarch/include/mm/as_ht.h
===================================================================
--- kernel/genarch/include/mm/as_ht.h	(revision 51baa8ad19af87e921ddfb1497fd4610a93ad7a9)
+++ kernel/genarch/include/mm/as_ht.h	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -36,7 +36,53 @@
 #define KERN_AS_HT_H_
 
-#include <mm/as.h>
+#include <mm/mm.h>
+#include <arch/mm/asid.h>
+#include <adt/list.h>
+#include <adt/btree.h>
+#include <synch/mutex.h>
 
-extern as_operations_t as_ht_operations;
+/** Address space structure.
+ *
+ * as_t contains the list of as_areas of userspace accessible
+ * pages for one or more tasks. Ranges of kernel memory pages are not
+ * supposed to figure in the list as they are shared by all tasks and
+ * set up during system initialization.
+ */
+typedef struct {
+	/** Protected by asidlock. */
+	link_t inactive_as_with_asid_link;
+
+	mutex_t lock;
+
+	/** Number of references (i.e tasks that reference this as). */
+	count_t refcount;
+
+	/** Number of processors on wich is this address space active. */
+	count_t cpu_refcount;
+
+	/** B+tree of address space areas. */
+	btree_t as_area_btree;
+
+	/** Address space identifier. Constant on architectures that do not support ASIDs.*/
+	asid_t asid;
+	
+	/** Architecture specific content. */
+	as_arch_t arch;
+} as_t;
+
+typedef struct {
+	link_t link;		/**< Page hash table link. */
+	as_t *as;		/**< Address space. */
+	uintptr_t page;		/**< Virtual memory page. */
+	uintptr_t frame;	/**< Physical memory frame. */
+	unsigned g : 1;		/**< Global page. */
+	unsigned x : 1;		/**< Execute. */
+	unsigned w : 1;		/**< Writable. */
+	unsigned k : 1;		/**< Kernel privileges required. */
+	unsigned c : 1;		/**< Cacheable. */
+	unsigned a : 1;		/**< Accessed. */
+	unsigned d : 1;		/**< Dirty. */
+	unsigned p : 1;		/**< Present. */
+} pte_t;
 
 #endif
Index: kernel/genarch/include/mm/as_pt.h
===================================================================
--- kernel/genarch/include/mm/as_pt.h	(revision 51baa8ad19af87e921ddfb1497fd4610a93ad7a9)
+++ kernel/genarch/include/mm/as_pt.h	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -36,7 +36,43 @@
 #define KERN_AS_PT_H_
 
-#include <mm/as.h>
+#include <mm/mm.h>
+#include <arch/mm/asid.h>
+#include <adt/list.h>
+#include <adt/btree.h>
+#include <synch/mutex.h>
 
-extern as_operations_t as_pt_operations;
+#define AS_PAGE_TABLE
+
+/** Address space structure.
+ *
+ * as_t contains the list of as_areas of userspace accessible
+ * pages for one or more tasks. Ranges of kernel memory pages are not
+ * supposed to figure in the list as they are shared by all tasks and
+ * set up during system initialization.
+ */
+typedef struct {
+	/** Protected by asidlock. */
+	link_t inactive_as_with_asid_link;
+
+	mutex_t lock;
+
+	/** Number of references (i.e tasks that reference this as). */
+	count_t refcount;
+
+	/** Number of processors on wich is this address space active. */
+	count_t cpu_refcount;
+
+	/** B+tree of address space areas. */
+	btree_t as_area_btree;
+	
+	/** Page table pointer. */
+	pte_t *page_table;
+
+	/** Address space identifier. Constant on architectures that do not support ASIDs.*/
+	asid_t asid;
+	
+	/** Architecture specific content. */
+	as_arch_t arch;
+} as_t;
 
 #endif
Index: kernel/genarch/include/mm/page_ht.h
===================================================================
--- kernel/genarch/include/mm/page_ht.h	(revision 51baa8ad19af87e921ddfb1497fd4610a93ad7a9)
+++ kernel/genarch/include/mm/page_ht.h	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -40,8 +40,8 @@
 #define KERN_PAGE_HT_H_
 
+#include <arch/types.h>
+#include <mm/as.h>
 #include <mm/page.h>
 #include <synch/mutex.h>
-#include <arch/types.h>
-#include <adt/list.h>
 #include <adt/hash_table.h>
 
@@ -62,20 +62,7 @@
 #define SET_PTL0_ADDRESS(x)
 
-struct pte {
-	link_t link;		/**< Page hash table link. */
-	as_t *as;		/**< Address space. */
-	uintptr_t page;		/**< Virtual memory page. */
-	uintptr_t frame;	/**< Physical memory frame. */
-	unsigned g : 1;		/**< Global page. */
-	unsigned x : 1;		/**< Execute. */
-	unsigned w : 1;		/**< Writable. */
-	unsigned k : 1;		/**< Kernel privileges required. */
-	unsigned c : 1;		/**< Cacheable. */
-	unsigned a : 1;		/**< Accessed. */
-	unsigned d : 1;		/**< Dirty. */
-	unsigned p : 1;		/**< Present. */
-};
+extern as_operations_t as_ht_operations;
+extern page_mapping_operations_t ht_mapping_operations;
 
-extern page_mapping_operations_t ht_mapping_operations;
 extern mutex_t page_ht_lock;
 extern hash_table_t page_ht;
Index: kernel/genarch/include/mm/page_pt.h
===================================================================
--- kernel/genarch/include/mm/page_pt.h	(revision 51baa8ad19af87e921ddfb1497fd4610a93ad7a9)
+++ kernel/genarch/include/mm/page_pt.h	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -45,5 +45,5 @@
 
 #include <arch/types.h>
-#include <typedefs.h>
+#include <mm/as.h>
 #include <mm/page.h>
 
@@ -108,4 +108,5 @@
 #define PTE_EXECUTABLE(p)	PTE_EXECUTABLE_ARCH((p))
 
+extern as_operations_t as_pt_operations;
 extern page_mapping_operations_t pt_mapping_operations;
 
Index: kernel/genarch/include/ofw/ofw_tree.h
===================================================================
--- kernel/genarch/include/ofw/ofw_tree.h	(revision 51baa8ad19af87e921ddfb1497fd4610a93ad7a9)
+++ kernel/genarch/include/ofw/ofw_tree.h	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -31,5 +31,4 @@
 
 #include <arch/types.h>
-#include <typedefs.h>
 
 #define OFW_TREE_PROPERTY_MAX_NAMELEN	32
Index: kernel/genarch/src/acpi/madt.c
===================================================================
--- kernel/genarch/src/acpi/madt.c	(revision 51baa8ad19af87e921ddfb1497fd4610a93ad7a9)
+++ kernel/genarch/src/acpi/madt.c	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -36,5 +36,4 @@
 
 #include <arch/types.h>
-#include <typedefs.h>
 #include <genarch/acpi/acpi.h>
 #include <genarch/acpi/madt.h>
Index: kernel/genarch/src/fb/fb.c
===================================================================
--- kernel/genarch/src/fb/fb.c	(revision 51baa8ad19af87e921ddfb1497fd4610a93ad7a9)
+++ kernel/genarch/src/fb/fb.c	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -47,5 +47,4 @@
 #include <ddi/ddi.h>
 #include <arch/types.h>
-#include <typedefs.h>
 
 #include "helenos.xbm"
Index: kernel/genarch/src/kbd/i8042.c
===================================================================
--- kernel/genarch/src/kbd/i8042.c	(revision 51baa8ad19af87e921ddfb1497fd4610a93ad7a9)
+++ kernel/genarch/src/kbd/i8042.c	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -45,10 +45,9 @@
 #include <arch/asm.h>
 #include <arch.h>
-#include <typedefs.h>
 #include <console/chardev.h>
 #include <console/console.h>
 #include <interrupt.h>
 #include <sysinfo/sysinfo.h>
-#include <ddi/irq.h>
+#include <ipc/irq.h>
 
 /* Keyboard commands. */
Index: kernel/genarch/src/kbd/key.c
===================================================================
--- kernel/genarch/src/kbd/key.c	(revision 51baa8ad19af87e921ddfb1497fd4610a93ad7a9)
+++ kernel/genarch/src/kbd/key.c	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -45,5 +45,4 @@
 #include <synch/spinlock.h>
 #include <console/chardev.h>
-#include <typedefs.h>
 #include <macros.h>
 
Index: kernel/genarch/src/kbd/ns16550.c
===================================================================
--- kernel/genarch/src/kbd/ns16550.c	(revision 51baa8ad19af87e921ddfb1497fd4610a93ad7a9)
+++ kernel/genarch/src/kbd/ns16550.c	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -46,5 +46,4 @@
 #include <arch/asm.h>
 #include <arch.h>
-#include <typedefs.h>
 #include <console/chardev.h>
 #include <console/console.h>
Index: kernel/genarch/src/kbd/z8530.c
===================================================================
--- kernel/genarch/src/kbd/z8530.c	(revision 51baa8ad19af87e921ddfb1497fd4610a93ad7a9)
+++ kernel/genarch/src/kbd/z8530.c	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -48,5 +48,4 @@
 #include <arch/asm.h>
 #include <arch.h>
-#include <typedefs.h>
 #include <console/chardev.h>
 #include <console/console.h>
Index: kernel/genarch/src/mm/as_ht.c
===================================================================
--- kernel/genarch/src/mm/as_ht.c	(revision 51baa8ad19af87e921ddfb1497fd4610a93ad7a9)
+++ kernel/genarch/src/mm/as_ht.c	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -36,4 +36,5 @@
  */
 
+#include <arch/mm/as.h>
 #include <genarch/mm/as_ht.h>
 #include <genarch/mm/page_ht.h>
@@ -41,5 +42,4 @@
 #include <mm/frame.h>
 #include <arch/types.h>
-#include <typedefs.h>
 #include <memstr.h>
 #include <adt/hash_table.h>
Index: kernel/genarch/src/mm/as_pt.c
===================================================================
--- kernel/genarch/src/mm/as_pt.c	(revision 51baa8ad19af87e921ddfb1497fd4610a93ad7a9)
+++ kernel/genarch/src/mm/as_pt.c	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -44,5 +44,4 @@
 #include <arch/mm/as.h>
 #include <arch/types.h>
-#include <typedefs.h>
 #include <memstr.h>
 #include <arch.h>
Index: kernel/genarch/src/mm/asid_fifo.c
===================================================================
--- kernel/genarch/src/mm/asid_fifo.c	(revision 51baa8ad19af87e921ddfb1497fd4610a93ad7a9)
+++ kernel/genarch/src/mm/asid_fifo.c	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -43,5 +43,4 @@
 #include <arch/mm/asid.h>
 #include <mm/asid.h>
-#include <typedefs.h>
 #include <adt/fifo.h>
 
Index: kernel/genarch/src/mm/page_ht.c
===================================================================
--- kernel/genarch/src/mm/page_ht.c	(revision 51baa8ad19af87e921ddfb1497fd4610a93ad7a9)
+++ kernel/genarch/src/mm/page_ht.c	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -44,5 +44,4 @@
 #include <arch/mm/asid.h>
 #include <arch/types.h>
-#include <typedefs.h>
 #include <arch/asm.h>
 #include <synch/spinlock.h>
Index: kernel/genarch/src/mm/page_pt.c
===================================================================
--- kernel/genarch/src/mm/page_pt.c	(revision 51baa8ad19af87e921ddfb1497fd4610a93ad7a9)
+++ kernel/genarch/src/mm/page_pt.c	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -43,5 +43,4 @@
 #include <arch/mm/as.h>
 #include <arch/types.h>
-#include <typedefs.h>
 #include <arch/asm.h>
 #include <memstr.h>
