Index: kernel/Makefile
===================================================================
--- kernel/Makefile	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/Makefile	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -276,5 +276,5 @@
 
 arch/$(ARCH)/_link.ld: arch/$(ARCH)/_link.ld.in
-	$(CC) $(DEFS) $(CFLAGS) -D__ASM__ -E -x c $< | grep -v "^\#" > $@
+	$(CC) $(DEFS) $(CFLAGS) -D__ASM__ -D__LINKER__ -E -x c $< | grep -v "^\#" > $@
 
 generic/src/debug/real_map.bin: depend arch/$(ARCH)/_link.ld $(ARCH_OBJECTS) $(GENARCH_OBJECTS) $(GENERIC_OBJECTS)
Index: kernel/arch/amd64/_link.ld.in
===================================================================
--- kernel/arch/amd64/_link.ld.in	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/arch/amd64/_link.ld.in	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -9,5 +9,4 @@
  */
 
-#define __ASM__
 #include <arch/boot/boot.h>
 #include <arch/mm/page.h>
Index: kernel/arch/amd64/include/asm.h
===================================================================
--- kernel/arch/amd64/include/asm.h	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/arch/amd64/include/asm.h	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -36,6 +36,4 @@
 #define KERN_amd64_ASM_H_
 
-#include <arch/pm.h>
-#include <arch/types.h>
 #include <config.h>
 
Index: kernel/arch/amd64/include/atomic.h
===================================================================
--- kernel/arch/amd64/include/atomic.h	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/arch/amd64/include/atomic.h	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -39,5 +39,4 @@
 #include <arch/barrier.h>
 #include <preemption.h>
-#include <typedefs.h>
 
 static inline void atomic_inc(atomic_t *val) {
Index: kernel/arch/amd64/include/cpu.h
===================================================================
--- kernel/arch/amd64/include/cpu.h	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/arch/amd64/include/cpu.h	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -55,5 +55,4 @@
 #ifndef __ASM__
 
-#include <typedefs.h>
 #include <arch/pm.h>
 
Index: kernel/arch/amd64/include/interrupt.h
===================================================================
--- kernel/arch/amd64/include/interrupt.h	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/arch/amd64/include/interrupt.h	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -70,5 +70,5 @@
 
 /** This is passed to interrupt handlers */
-struct istate {
+typedef struct {
 	uint64_t rax;
 	uint64_t rbx;
@@ -91,5 +91,5 @@
 	uint64_t rflags;
 	uint64_t stack[]; /* Additional data on stack */
-};
+} istate_t;
 
 /** Return true if exception happened while in userspace */
Index: kernel/arch/amd64/include/mm/as.h
===================================================================
--- kernel/arch/amd64/include/mm/as.h	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/arch/amd64/include/mm/as.h	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -45,7 +45,4 @@
 #define USTACK_ADDRESS_ARCH	(USER_ADDRESS_SPACE_END_ARCH-(PAGE_SIZE-1))
 
-typedef struct {
-} as_arch_t;
-
 #define as_constructor_arch(as, flags)		(as != as)
 #define as_destructor_arch(as)			(as != as)
@@ -55,4 +52,9 @@
 #define as_invalidate_translation_cache(as, page, cnt)
 
+typedef struct {
+} as_arch_t;
+
+#include <genarch/mm/as_pt.h>
+
 extern void as_arch_init(void);
 
Index: kernel/arch/amd64/include/mm/page.h
===================================================================
--- kernel/arch/amd64/include/mm/page.h	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/arch/amd64/include/mm/page.h	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -58,9 +58,8 @@
 
 #ifndef __ASM__
-#  include <mm/page.h>
-#  include <arch/types.h>
-#endif
+#	include <mm/mm.h>
+#	include <arch/types.h>
+#	include <arch/interrupt.h>
 
-#ifndef __ASM__
 static inline uintptr_t ka2pa(uintptr_t x)
 {
@@ -70,10 +69,11 @@
 		return x - 0xffff800000000000;
 }
-# define KA2PA(x)      ka2pa((uintptr_t)x)
-# define PA2KA_CODE(x)      (((uintptr_t) (x)) + 0xffffffff80000000)
-# define PA2KA(x)      (((uintptr_t) (x)) + 0xffff800000000000)
+
+#	define KA2PA(x)      ka2pa((uintptr_t)x)
+#	define PA2KA_CODE(x)      (((uintptr_t) (x)) + 0xffffffff80000000)
+#	define PA2KA(x)      (((uintptr_t) (x)) + 0xffff800000000000)
 #else
-# define KA2PA(x)      ((x) - 0xffffffff80000000)
-# define PA2KA(x)      ((x) + 0xffffffff80000000)
+#	define KA2PA(x)      ((x) - 0xffffffff80000000)
+#	define PA2KA(x)      ((x) + 0xffffffff80000000)
 #endif
 
@@ -134,22 +134,4 @@
 #define PFERR_CODE_ID		(1<<4)
 
-/** Page Table Entry. */
-struct page_specifier {
-	unsigned present : 1;
-	unsigned writeable : 1;
-	unsigned uaccessible : 1;
-	unsigned page_write_through : 1;
-	unsigned page_cache_disable : 1;
-	unsigned accessed : 1;
-	unsigned dirty : 1;
-	unsigned unused: 1;
-	unsigned global : 1;
-	unsigned soft_valid : 1;		/**< Valid content even if present bit is cleared. */
-	unsigned avl : 2;
-	unsigned addr_12_31 : 30;
-	unsigned addr_32_51 : 21;
-	unsigned no_execute : 1;
-} __attribute__ ((packed));
-
 static inline int get_pt_flags(pte_t *pt, index_t i)
 {
Index: kernel/arch/amd64/include/pm.h
===================================================================
--- kernel/arch/amd64/include/pm.h	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/arch/amd64/include/pm.h	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -37,7 +37,6 @@
 
 #ifndef __ASM__
-# include <arch/types.h>
-# include <typedefs.h>
-# include <arch/context.h>
+#	include <arch/types.h>
+#	include <arch/context.h>
 #endif
 
Index: kernel/arch/amd64/include/proc/task.h
===================================================================
--- kernel/arch/amd64/include/proc/task.h	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/arch/amd64/include/proc/task.h	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -36,5 +36,4 @@
 #define KERN_amd64_TASK_H_
 
-#include <typedefs.h>
 #include <arch/types.h>
 #include <adt/bitmap.h>
Index: kernel/arch/amd64/include/proc/thread.h
===================================================================
--- kernel/arch/amd64/include/proc/thread.h	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/arch/amd64/include/proc/thread.h	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -36,6 +36,4 @@
 #define KERN_amd64_THREAD_H_
 
-#include <arch/types.h>
-
 typedef struct {
 	unative_t tls;
Index: kernel/arch/amd64/include/types.h
===================================================================
--- kernel/arch/amd64/include/types.h	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/arch/amd64/include/types.h	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -37,4 +37,6 @@
 
 #define NULL 0
+#define false 0
+#define true 1
 
 typedef signed char int8_t;
@@ -48,8 +50,11 @@
 typedef unsigned long long uint64_t;
 
+typedef uint64_t size_t;
+typedef uint64_t count_t;
+typedef uint64_t index_t;
+
 typedef uint64_t uintptr_t;
 typedef uint64_t pfn_t;
 
-/* Flags of processor (return value of interrupts_disable()) */
 typedef uint64_t ipl_t;
 
@@ -57,5 +62,28 @@
 typedef int64_t native_t;
 
-typedef struct page_specifier pte_t;
+typedef uint8_t bool;
+typedef uint64_t task_id_t;
+typedef uint32_t context_id_t;
+
+typedef int32_t inr_t;
+typedef int32_t devno_t;
+
+/** Page Table Entry. */
+typedef struct {
+	unsigned present : 1;
+	unsigned writeable : 1;
+	unsigned uaccessible : 1;
+	unsigned page_write_through : 1;
+	unsigned page_cache_disable : 1;
+	unsigned accessed : 1;
+	unsigned dirty : 1;
+	unsigned unused: 1;
+	unsigned global : 1;
+	unsigned soft_valid : 1;		/**< Valid content even if present bit is cleared. */
+	unsigned avl : 2;
+	unsigned addr_12_31 : 30;
+	unsigned addr_32_51 : 21;
+	unsigned no_execute : 1;
+} __attribute__ ((packed)) pte_t;
 
 #endif
Index: kernel/arch/amd64/src/cpu/cpu.c
===================================================================
--- kernel/arch/amd64/src/cpu/cpu.c	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/arch/amd64/src/cpu/cpu.c	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -33,4 +33,5 @@
  */
 
+#include <cpu.h>
 #include <arch/cpu.h>
 #include <arch/cpuid.h>
@@ -40,5 +41,4 @@
 #include <arch/types.h>
 #include <print.h>
-#include <typedefs.h>
 #include <fpu_context.h>
 
@@ -57,5 +57,5 @@
 
 enum vendor {
-	VendorUnknown=0,
+	VendorUnknown = 0,
 	VendorAMD,
 	VendorIntel
Index: kernel/arch/amd64/src/ddi/ddi.c
===================================================================
--- kernel/arch/amd64/src/ddi/ddi.c	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/arch/amd64/src/ddi/ddi.c	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -37,5 +37,4 @@
 #include <proc/task.h>
 #include <arch/types.h>
-#include <typedefs.h>
 #include <adt/bitmap.h>
 #include <mm/slab.h>
Index: kernel/arch/amd64/src/fpu_context.c
===================================================================
--- kernel/arch/amd64/src/fpu_context.c	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/arch/amd64/src/fpu_context.c	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -35,6 +35,4 @@
 
 #include <fpu_context.h>
-#include <arch.h>
-#include <cpu.h>
 
 /** Save FPU (mmx, sse) context using fxsave instruction */
Index: kernel/arch/amd64/src/mm/memory_init.c
===================================================================
--- kernel/arch/amd64/src/mm/memory_init.c	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/arch/amd64/src/mm/memory_init.c	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -39,5 +39,5 @@
 
 uint8_t e820counter = 0xff;
-struct e820memmap_ e820table[MEMMAP_E820_MAX_RECORDS];
+e820memmap_t e820table[MEMMAP_E820_MAX_RECORDS];
 uint32_t e801memorysize;
 
Index: kernel/arch/amd64/src/pm.c
===================================================================
--- kernel/arch/amd64/src/pm.c	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/arch/amd64/src/pm.c	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -35,16 +35,9 @@
 
 #include <arch/pm.h>
-#include <arch/mm/page.h>
-#include <arch/types.h>
-#include <arch/interrupt.h>
 #include <arch/asm.h>
-#include <interrupt.h>
 #include <mm/as.h>
-
-#include <config.h>
-
+#include <mm/frame.h>
 #include <memstr.h>
 #include <mm/slab.h>
-#include <debug.h>
 
 /*
Index: kernel/arch/ia32/_link.ld.in
===================================================================
--- kernel/arch/ia32/_link.ld.in	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/arch/ia32/_link.ld.in	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -9,5 +9,4 @@
  */
 
-#define __ASM__
 #include <arch/boot/boot.h>
 #include <arch/mm/page.h>
Index: kernel/arch/ia32/include/atomic.h
===================================================================
--- kernel/arch/ia32/include/atomic.h	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/arch/ia32/include/atomic.h	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -39,5 +39,4 @@
 #include <arch/barrier.h>
 #include <preemption.h>
-#include <typedefs.h>
 
 static inline void atomic_inc(atomic_t *val) {
Index: kernel/arch/ia32/include/boot/memmap.h
===================================================================
--- kernel/arch/ia32/include/boot/memmap.h	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/arch/ia32/include/boot/memmap.h	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -58,15 +58,13 @@
 #include <arch/types.h>
 
-struct e820memmap_ {
+typedef struct {
 	uint64_t base_address;
 	uint64_t size;
 	uint32_t type;
-} __attribute__ ((packed));
+} __attribute__ ((packed)) e820memmap_t;
 
-extern struct e820memmap_ e820table[MEMMAP_E820_MAX_RECORDS];
-
+extern e820memmap_t e820table[MEMMAP_E820_MAX_RECORDS];
 extern uint8_t e820counter; 
-
-extern uint32_t e801memorysize; /**< Size of available memory in KB. */
+extern uint32_t e801memorysize;         /**< Size of available memory in KB. */
 
 #endif
Index: kernel/arch/ia32/include/cpu.h
===================================================================
--- kernel/arch/ia32/include/cpu.h	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/arch/ia32/include/cpu.h	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -36,5 +36,4 @@
 #define KERN_ia32_CPU_H_
 
-#include <typedefs.h>
 #include <arch/pm.h>
 #include <arch/asm.h>
Index: kernel/arch/ia32/include/interrupt.h
===================================================================
--- kernel/arch/ia32/include/interrupt.h	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/arch/ia32/include/interrupt.h	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -69,5 +69,5 @@
 #define VECTOR_DEBUG_IPI			(IVT_FREEBASE + 2)
 
-struct istate {
+typedef struct {
 	uint32_t eax;
 	uint32_t ecx;
@@ -88,5 +88,5 @@
 	uint32_t eflags;
 	uint32_t stack[];
-};
+} istate_t;
 
 /** Return true if exception happened while in userspace */
Index: kernel/arch/ia32/include/mm/as.h
===================================================================
--- kernel/arch/ia32/include/mm/as.h	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/arch/ia32/include/mm/as.h	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -48,4 +48,6 @@
 } as_arch_t;
 
+#include <genarch/mm/as_pt.h>
+
 #define as_constructor_arch(as, flags)		(as != as)
 #define as_destructor_arch(as)			(as != as)
Index: kernel/arch/ia32/include/mm/asid.h
===================================================================
--- kernel/arch/ia32/include/mm/asid.h	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/arch/ia32/include/mm/asid.h	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -43,9 +43,11 @@
 #define KERN_ia32_ASID_H_
 
-typedef int asid_t;
+#include <arch/types.h>
+
+typedef int32_t asid_t;
 
 #define ASID_MAX_ARCH		3
 
-#define asid_get()		(ASID_START+1)
+#define asid_get()		(ASID_START + 1)
 #define asid_put(asid)
 
Index: kernel/arch/ia32/include/mm/memory_init.h
===================================================================
--- kernel/arch/ia32/include/mm/memory_init.h	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/arch/ia32/include/mm/memory_init.h	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -37,6 +37,4 @@
 #define KERN_ia32_MEMORY_INIT_H_
 
-#include <typedefs.h>
-
 size_t get_memory_size(void);
 
Index: kernel/arch/ia32/include/mm/page.h
===================================================================
--- kernel/arch/ia32/include/mm/page.h	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/arch/ia32/include/mm/page.h	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -62,13 +62,13 @@
 #define PTL3_ENTRIES_ARCH	1024
 
-#define PTL0_INDEX_ARCH(vaddr)	(((vaddr)>>22)&0x3ff)
+#define PTL0_INDEX_ARCH(vaddr)	(((vaddr) >> 22) & 0x3ff)
 #define PTL1_INDEX_ARCH(vaddr)	0
 #define PTL2_INDEX_ARCH(vaddr)	0
-#define PTL3_INDEX_ARCH(vaddr)	(((vaddr)>>12)&0x3ff)
+#define PTL3_INDEX_ARCH(vaddr)	(((vaddr) >> 12) & 0x3ff)
 
-#define GET_PTL1_ADDRESS_ARCH(ptl0, i)		((pte_t *)((((pte_t *)(ptl0))[(i)].frame_address)<<12))
+#define GET_PTL1_ADDRESS_ARCH(ptl0, i)		((pte_t *)((((pte_t *)(ptl0))[(i)].frame_address) << 12))
 #define GET_PTL2_ADDRESS_ARCH(ptl1, i)		(ptl1)
 #define GET_PTL3_ADDRESS_ARCH(ptl2, i)		(ptl2)
-#define GET_FRAME_ADDRESS_ARCH(ptl3, i)		((uintptr_t)((((pte_t *)(ptl3))[(i)].frame_address)<<12))
+#define GET_FRAME_ADDRESS_ARCH(ptl3, i)		((uintptr_t)((((pte_t *)(ptl3))[(i)].frame_address) << 12))
 
 #define SET_PTL0_ADDRESS_ARCH(ptl0)		(write_cr3((uintptr_t) (ptl0)))
@@ -90,5 +90,5 @@
 #define PTE_VALID_ARCH(p)			(*((uint32_t *) (p)) != 0)
 #define PTE_PRESENT_ARCH(p)			((p)->present != 0)
-#define PTE_GET_FRAME_ARCH(p)			((p)->frame_address<<FRAME_WIDTH)
+#define PTE_GET_FRAME_ARCH(p)			((p)->frame_address << FRAME_WIDTH)
 #define PTE_WRITABLE_ARCH(p)			((p)->writeable != 0)
 #define PTE_EXECUTABLE_ARCH(p)			1
@@ -96,38 +96,20 @@
 #ifndef __ASM__
 
-#include <mm/page.h>
-#include <arch/types.h>
-#include <arch/mm/frame.h>
-#include <typedefs.h>
+#include <mm/mm.h>
+#include <arch/interrupt.h>
 
 /* Page fault error codes. */
 
 /** When bit on this position is 0, the page fault was caused by a not-present page. */
-#define PFERR_CODE_P		(1<<0)
+#define PFERR_CODE_P		(1 << 0)
 
 /** When bit on this position is 1, the page fault was caused by a write. */
-#define PFERR_CODE_RW		(1<<1)
+#define PFERR_CODE_RW		(1 << 1)
 
 /** When bit on this position is 1, the page fault was caused in user mode. */
-#define PFERR_CODE_US		(1<<2)
+#define PFERR_CODE_US		(1 << 2)
 
 /** When bit on this position is 1, a reserved bit was set in page directory. */ 
-#define PFERR_CODE_RSVD		(1<<3)	
-
-/** Page Table Entry. */
-struct page_specifier {
-	unsigned present : 1;
-	unsigned writeable : 1;
-	unsigned uaccessible : 1;
-	unsigned page_write_through : 1;
-	unsigned page_cache_disable : 1;
-	unsigned accessed : 1;
-	unsigned dirty : 1;
-	unsigned pat : 1;
-	unsigned global : 1;
-	unsigned soft_valid : 1;	/**< Valid content even if the present bit is not set. */
-	unsigned avl : 2;
-	unsigned frame_address : 20;
-} __attribute__ ((packed));
+#define PFERR_CODE_RSVD		(1 << 3)	
 
 static inline int get_pt_flags(pte_t *pt, index_t i)
@@ -136,11 +118,11 @@
 	
 	return (
-		(!p->page_cache_disable)<<PAGE_CACHEABLE_SHIFT |
-		(!p->present)<<PAGE_PRESENT_SHIFT |
-		p->uaccessible<<PAGE_USER_SHIFT |
+		(!p->page_cache_disable) << PAGE_CACHEABLE_SHIFT |
+		(!p->present) << PAGE_PRESENT_SHIFT |
+		p->uaccessible << PAGE_USER_SHIFT |
 		1<<PAGE_READ_SHIFT |
-		p->writeable<<PAGE_WRITE_SHIFT |
+		p->writeable << PAGE_WRITE_SHIFT |
 		1<<PAGE_EXEC_SHIFT |
-		p->global<<PAGE_GLOBAL_SHIFT
+		p->global << PAGE_GLOBAL_SHIFT
 	);
 }
Index: kernel/arch/ia32/include/pm.h
===================================================================
--- kernel/arch/ia32/include/pm.h	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/arch/ia32/include/pm.h	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -82,5 +82,4 @@
 
 #include <arch/types.h>
-#include <typedefs.h>
 #include <arch/context.h>
 
Index: kernel/arch/ia32/include/proc/task.h
===================================================================
--- kernel/arch/ia32/include/proc/task.h	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/arch/ia32/include/proc/task.h	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -36,5 +36,4 @@
 #define KERN_ia32_TASK_H_
 
-#include <typedefs.h>
 #include <arch/types.h>
 #include <adt/bitmap.h>
Index: kernel/arch/ia32/include/smp/apic.h
===================================================================
--- kernel/arch/ia32/include/smp/apic.h	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/arch/ia32/include/smp/apic.h	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -108,5 +108,5 @@
 #define ICRlo		(0x300/sizeof(uint32_t))
 #define ICRhi		(0x310/sizeof(uint32_t))
-struct icr {
+typedef struct {
 	union {
 		uint32_t lo;
@@ -131,6 +131,5 @@
 		} __attribute__ ((packed));
 	};
-} __attribute__ ((packed));
-typedef struct icr icr_t;
+} __attribute__ ((packed)) icr_t;
 
 /* End Of Interrupt. */
@@ -139,5 +138,5 @@
 /** Error Status Register. */
 #define ESR		(0x280/sizeof(uint32_t))
-union esr {
+typedef union {
 	uint32_t value;
 	uint8_t err_bitmap;
@@ -153,10 +152,9 @@
 		unsigned : 24;
 	} __attribute__ ((packed));
-};
-typedef union esr esr_t;
+} esr_t;
 
 /* Task Priority Register */
 #define TPR		(0x080/sizeof(uint32_t))
-union tpr {
+typedef union {
 	uint32_t value;
 	struct {
@@ -164,10 +162,9 @@
 		unsigned pri : 4;		/**< Task Priority. */
 	} __attribute__ ((packed));
-};
-typedef union tpr tpr_t;
+} tpr_t;
 
 /** Spurious-Interrupt Vector Register. */
 #define SVR		(0x0f0/sizeof(uint32_t))
-union svr {
+typedef union {
 	uint32_t value;
 	struct {
@@ -177,10 +174,9 @@
 		unsigned : 22;			/**< Reserved. */
 	} __attribute__ ((packed));
-};
-typedef union svr svr_t;
+} svr_t;
 
 /** Time Divide Configuration Register. */
 #define TDCR		(0x3e0/sizeof(uint32_t))
-union tdcr {
+typedef union {
 	uint32_t value;
 	struct {
@@ -188,6 +184,5 @@
 		unsigned : 28;			/**< Reserved. */
 	} __attribute__ ((packed));
-};
-typedef union tdcr tdcr_t;
+} tdcr_t;
 
 /* Initial Count Register for Timer */
@@ -199,5 +194,5 @@
 /** LVT Timer register. */
 #define LVT_Tm		(0x320/sizeof(uint32_t))
-union lvt_tm {
+typedef union {
 	uint32_t value;
 	struct {
@@ -210,11 +205,10 @@
 		unsigned : 14;		/**< Reserved. */
 	} __attribute__ ((packed));
-};
-typedef union lvt_tm lvt_tm_t;
+} lvt_tm_t;
 
 /** LVT LINT registers. */
 #define LVT_LINT0	(0x350/sizeof(uint32_t))
 #define LVT_LINT1	(0x360/sizeof(uint32_t))
-union lvt_lint {
+typedef union {
 	uint32_t value;
 	struct {
@@ -229,10 +223,9 @@
 		unsigned : 15;			/**< Reserved. */
 	} __attribute__ ((packed));
-};
-typedef union lvt_lint lvt_lint_t;
+} lvt_lint_t;
 
 /** LVT Error register. */
 #define LVT_Err		(0x370/sizeof(uint32_t))
-union lvt_error {
+typedef union {
 	uint32_t value;
 	struct {
@@ -244,10 +237,9 @@
 		unsigned : 15;		/**< Reserved. */
 	} __attribute__ ((packed));
-};
-typedef union lvt_error lvt_error_t;
+} lvt_error_t;
 
 /** Local APIC ID Register. */
 #define L_APIC_ID	(0x020/sizeof(uint32_t))
-union l_apic_id {
+typedef union {
 	uint32_t value;
 	struct {
@@ -255,6 +247,5 @@
 		uint8_t apic_id;		/**< Local APIC ID. */
 	} __attribute__ ((packed));
-};
-typedef union l_apic_id l_apic_id_t;
+} l_apic_id_t;
 
 /** Local APIC Version Register */
@@ -267,5 +258,5 @@
 /** Logical Destination Register. */
 #define  LDR		(0x0d0/sizeof(uint32_t))
-union ldr {
+typedef union {
 	uint32_t value;
 	struct {
@@ -273,10 +264,9 @@
 		uint8_t id;		/**< Logical APIC ID. */
 	} __attribute__ ((packed));
-};
-typedef union ldr ldr_t;
+} ldr_t;
 
 /** Destination Format Register. */
 #define DFR		(0x0e0/sizeof(uint32_t))
-union dfr {
+typedef union {
 	uint32_t value;
 	struct {
@@ -284,6 +274,5 @@
 		unsigned model : 4;	/**< Model. */
 	} __attribute__ ((packed));
-};
-typedef union dfr dfr_t;
+} dfr_t;
 
 /* IO APIC */
@@ -297,5 +286,5 @@
 
 /** I/O Register Select Register. */
-union io_regsel {
+typedef union {
 	uint32_t value;
 	struct {
@@ -303,9 +292,8 @@
 		unsigned : 24;		/**< Reserved. */
 	} __attribute__ ((packed));
-};
-typedef union io_regsel io_regsel_t;
+} io_regsel_t;
 
 /** I/O Redirection Register. */
-struct io_redirection_reg {
+typedef struct io_redirection_reg {
 	union {
 		uint32_t lo;
@@ -330,10 +318,9 @@
 	};
 	
-} __attribute__ ((packed));
-typedef struct io_redirection_reg io_redirection_reg_t;
+} __attribute__ ((packed)) io_redirection_reg_t;
 
 
 /** IO APIC Identification Register. */
-union io_apic_id {
+typedef union {
 	uint32_t value;
 	struct {
@@ -342,6 +329,5 @@
 		unsigned : 4;		/**< Reserved. */
 	} __attribute__ ((packed));
-};
-typedef union io_apic_id io_apic_id_t;
+} io_apic_id_t;
 
 extern volatile uint32_t *l_apic;
Index: kernel/arch/ia32/include/smp/mps.h
===================================================================
--- kernel/arch/ia32/include/smp/mps.h	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/arch/ia32/include/smp/mps.h	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -37,5 +37,4 @@
 
 #include <arch/types.h>
-#include <typedefs.h>
 #include <synch/waitq.h>
 #include <config.h>
Index: kernel/arch/ia32/include/smp/smp.h
===================================================================
--- kernel/arch/ia32/include/smp/smp.h	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/arch/ia32/include/smp/smp.h	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -37,5 +37,4 @@
 
 #include <arch/types.h>
-#include <typedefs.h>
 
 /** SMP config opertaions interface. */
Index: kernel/arch/ia32/include/types.h
===================================================================
--- kernel/arch/ia32/include/types.h	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/arch/ia32/include/types.h	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -37,4 +37,6 @@
 
 #define NULL 0
+#define false 0
+#define true 1
 
 typedef signed char int8_t;
@@ -48,4 +50,8 @@
 typedef unsigned long long uint64_t;
 
+typedef uint32_t size_t;
+typedef uint32_t count_t;
+typedef uint32_t index_t;
+
 typedef uint32_t uintptr_t;
 typedef uint32_t pfn_t;
@@ -56,5 +62,26 @@
 typedef int32_t native_t;
 
-typedef struct page_specifier pte_t;
+typedef uint8_t bool;
+typedef uint64_t task_id_t;
+typedef uint32_t context_id_t;
+
+typedef int32_t inr_t;
+typedef int32_t devno_t;
+
+/** Page Table Entry. */
+typedef struct {
+	unsigned present : 1;
+	unsigned writeable : 1;
+	unsigned uaccessible : 1;
+	unsigned page_write_through : 1;
+	unsigned page_cache_disable : 1;
+	unsigned accessed : 1;
+	unsigned dirty : 1;
+	unsigned pat : 1;
+	unsigned global : 1;
+	unsigned soft_valid : 1;	/**< Valid content even if the present bit is not set. */
+	unsigned avl : 2;
+	unsigned frame_address : 20;
+} __attribute__ ((packed)) pte_t;
 
 #endif
Index: kernel/arch/ia32/src/boot/boot.S
===================================================================
--- kernel/arch/ia32/src/boot/boot.S	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/arch/ia32/src/boot/boot.S	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -75,5 +75,5 @@
 
 	mov $VESA_INIT_SEGMENT << 4, %edi
-	jmpl %edi
+	jmpl *%edi
 	
 	vesa_meeting_point:
Index: kernel/arch/ia32/src/cpu/cpu.c
===================================================================
--- kernel/arch/ia32/src/cpu/cpu.c	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/arch/ia32/src/cpu/cpu.c	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -40,5 +40,4 @@
 #include <arch/types.h>
 #include <print.h>
-#include <typedefs.h>
 #include <fpu_context.h>
 
Index: kernel/arch/ia32/src/ddi/ddi.c
===================================================================
--- kernel/arch/ia32/src/ddi/ddi.c	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/arch/ia32/src/ddi/ddi.c	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -37,5 +37,4 @@
 #include <proc/task.h>
 #include <arch/types.h>
-#include <typedefs.h>
 #include <adt/bitmap.h>
 #include <mm/slab.h>
Index: kernel/arch/ia32/src/drivers/vesa.c
===================================================================
--- kernel/arch/ia32/src/drivers/vesa.c	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/arch/ia32/src/drivers/vesa.c	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -48,5 +48,4 @@
 #include <arch/asm.h>
 #include <arch/types.h>
-#include <typedefs.h>
 #include <memstr.h>
 #include <bitops.h>
Index: kernel/arch/ia32/src/ia32.c
===================================================================
--- kernel/arch/ia32/src/ia32.c	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/arch/ia32/src/ia32.c	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -36,5 +36,4 @@
 
 #include <arch/types.h>
-#include <typedefs.h>
 
 #include <arch/pm.h>
Index: kernel/arch/ia32/src/mm/as.c
===================================================================
--- kernel/arch/ia32/src/mm/as.c	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/arch/ia32/src/mm/as.c	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -35,5 +35,5 @@
 
 #include <arch/mm/as.h>
-#include <genarch/mm/as_pt.h>
+#include <genarch/mm/page_pt.h>
 
 /** Architecture dependent address space init. */
Index: kernel/arch/ia32/src/mm/memory_init.c
===================================================================
--- kernel/arch/ia32/src/mm/memory_init.c	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/arch/ia32/src/mm/memory_init.c	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -39,5 +39,5 @@
 
 uint8_t e820counter = 0xff;
-struct e820memmap_ e820table[MEMMAP_E820_MAX_RECORDS];
+e820memmap_t e820table[MEMMAP_E820_MAX_RECORDS];
 uint32_t e801memorysize;
 
Index: kernel/arch/ia32/src/pm.c
===================================================================
--- kernel/arch/ia32/src/pm.c	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/arch/ia32/src/pm.c	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -36,5 +36,4 @@
 #include <config.h>
 #include <arch/types.h>
-#include <typedefs.h>
 #include <arch/interrupt.h>
 #include <arch/asm.h>
Index: kernel/arch/ia32/src/smp/mps.c
===================================================================
--- kernel/arch/ia32/src/smp/mps.c	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/arch/ia32/src/smp/mps.c	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -43,5 +43,4 @@
 #include <func.h>
 #include <arch/types.h>
-#include <typedefs.h>
 #include <cpu.h>
 #include <arch/asm.h>
Index: kernel/arch/ia32xen/_link.ld.in
===================================================================
--- kernel/arch/ia32xen/_link.ld.in	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/arch/ia32xen/_link.ld.in	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -2,6 +2,5 @@
  */
 
-#define __ASM__
-#include <arch/boot/boot.h>
+#include <arch/hypercall.h>
 #include <arch/mm/page.h>
 
Index: rnel/arch/ia32xen/include/boot/boot.h
===================================================================
--- kernel/arch/ia32xen/include/boot/boot.h	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ 	(revision )
@@ -1,190 +1,0 @@
-/*
- * Copyright (c) 2006 Martin Decky
- * 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 ia32xen
- * @{
- */
-/** @file
- */
-
-#ifndef KERN_ia32xen_BOOT_H_
-#define KERN_ia32xen_BOOT_H_
-
-#define GUEST_CMDLINE	1024
-#define VIRT_CPUS	32
-#define START_INFO_SIZE	1104
-
-#define BOOT_OFFSET		0x0000
-#define TEMP_STACK_SIZE 0x1000
-
-#define XEN_VIRT_START	0xFC000000
-#define XEN_CS			0xe019
-
-#define XEN_ELFNOTE_INFO			0
-#define XEN_ELFNOTE_ENTRY			1
-#define XEN_ELFNOTE_HYPERCALL_PAGE	2
-#define XEN_ELFNOTE_VIRT_BASE		3
-#define XEN_ELFNOTE_PADDR_OFFSET	4
-#define XEN_ELFNOTE_XEN_VERSION 	5
-#define XEN_ELFNOTE_GUEST_OS		6
-#define XEN_ELFNOTE_GUEST_VERSION	7
-#define XEN_ELFNOTE_LOADER			8
-#define XEN_ELFNOTE_PAE_MODE		9
-#define XEN_ELFNOTE_FEATURES		10
-#define XEN_ELFNOTE_BSD_SYMTAB		11
-
-#ifndef __ASM__
-
-#define mp_map ((pfn_t *) XEN_VIRT_START)
-
-#define SIF_PRIVILEGED	(1 << 0)  /**< Privileged domain */
-#define SIF_INITDOMAIN	(1 << 1)  /**< Iinitial control domain */
-
-#include <arch/types.h>
-
-typedef uint32_t evtchn_t;
-
-typedef struct {
-	uint32_t version;
-	uint32_t pad0;
-	uint64_t tsc_timestamp;   /**< TSC at last update of time vals */
-	uint64_t system_time;     /**< Time, in nanosecs, since boot */
-	uint32_t tsc_to_system_mul;
-	int8_t tsc_shift;
-	int8_t pad1[3];
-} vcpu_time_info_t;
-
-typedef struct {
-	uint32_t cr2;
-	uint32_t pad[5];
-} arch_vcpu_info_t;
-
-typedef struct arch_shared_info {
-	pfn_t max_pfn;                  /**< max pfn that appears in table */
-	uint32_t pfn_to_mfn_frame_list_list;
-    uint32_t nmi_reason;
-} arch_shared_info_t;
-
-typedef struct {
-	uint8_t evtchn_upcall_pending;
-	ipl_t evtchn_upcall_mask;
-	evtchn_t evtchn_pending_sel;
-	arch_vcpu_info_t arch;
-	vcpu_time_info_t time;
-} vcpu_info_t;
-
-typedef struct {
-	vcpu_info_t vcpu_info[VIRT_CPUS];
-	evtchn_t evtchn_pending[32];
-	evtchn_t evtchn_mask[32];
-	
-	uint32_t wc_version;                  /**< Version counter */
-	uint32_t wc_sec;                      /**< Secs  00:00:00 UTC, Jan 1, 1970 */
-	uint32_t wc_nsec;                     /**< Nsecs 00:00:00 UTC, Jan 1, 1970 */
-	
-	arch_shared_info_t arch;
-} shared_info_t;
-
-typedef struct {
-	int8_t magic[32];           /**< "xen-<version>-<platform>" */
-	uint32_t frames;            /**< Available frames */
-	shared_info_t *shared_info; /**< Shared info structure (machine address) */
-	uint32_t flags;             /**< SIF_xxx flags */
-	pfn_t store_mfn;            /**< Shared page (machine page) */
-	evtchn_t store_evtchn;      /**< Event channel for store communication */
-	
-	union {
-        struct {
-			pfn_t mfn;          /**< Console page (machine page) */
-			evtchn_t evtchn;    /**< Event channel for console messages */
-        } domU;
-		
-        struct {
-            uint32_t info_off;  /**< Offset of console_info struct */
-            uint32_t info_size; /**< Size of console_info struct from start */
-        } dom0;
-    } console;
-	
-	pte_t *ptl0;                /**< Boot PTL0 (kernel address) */
-	uint32_t pt_frames;         /**< Number of bootstrap page table frames */
-	pfn_t *pm_map;              /**< Physical->machine frame map (kernel address) */
-	void *mod_start;            /**< Modules start (kernel address) */
-	uint32_t mod_len;           /**< Modules size (bytes) */
-	int8_t cmd_line[GUEST_CMDLINE];
-} start_info_t;
-
-#define XEN_CONSOLE_VGA		0x03
-#define XEN_CONSOLE_VESA	0x23
-
-typedef struct {
-    uint8_t video_type;  
-
-    union {
-        struct {
-            uint16_t font_height;
-            uint16_t cursor_x;
-			uint16_t cursor_y;
-            uint16_t rows;
-			uint16_t columns;
-        } vga;
-
-        struct {
-            uint16_t width;
-			uint16_t height;
-            uint16_t bytes_per_line;
-            uint16_t bits_per_pixel;
-            uint32_t lfb_base;
-            uint32_t lfb_size;
-            uint8_t red_pos;
-			uint8_t red_size;
-            uint8_t green_pos;
-			uint8_t green_size;
-            uint8_t blue_pos;
-			uint8_t blue_size;
-            uint8_t rsvd_pos;
-			uint8_t rsvd_size;
-        } vesa_lfb;
-    } info;
-} console_info_t;
-
-typedef struct {
-	pfn_t start;
-	pfn_t size;
-	pfn_t reserved;
-} memzone_t;
-
-extern start_info_t start_info;
-extern shared_info_t shared_info;
-extern memzone_t meminfo;
-
-#endif
-
-#endif
-
-/** @}
- */
Index: kernel/arch/ia32xen/include/hypercall.h
===================================================================
--- kernel/arch/ia32xen/include/hypercall.h	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/arch/ia32xen/include/hypercall.h	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -30,28 +30,39 @@
 #define KERN_ia32xen_HYPERCALL_H_
 
-#include <arch/types.h>
-#include <macros.h>
-
-typedef uint16_t domid_t;
-
-typedef struct {
-	uint8_t vector;     /**< Exception vector */
-	uint8_t flags;      /**< 0-3: privilege level; 4: clear event enable */
-	uint16_t cs;        /**< Code selector */
-	void *address;      /**< Code offset */
-} trap_info_t;
-
-
-typedef struct {
-	evtchn_t port;
-} evtchn_send_t;
-
-typedef struct {
-	uint32_t cmd;
-	union {
-		evtchn_send_t send;
-    };
-} evtchn_op_t;
-
+#ifndef __ASM__
+#	include <arch/types.h>
+#	include <macros.h>
+#endif
+
+#define GUEST_CMDLINE	1024
+#define VIRT_CPUS	32
+#define START_INFO_SIZE	1104
+
+#define BOOT_OFFSET		0x0000
+#define TEMP_STACK_SIZE 0x1000
+
+#define XEN_VIRT_START	0xFC000000
+#define XEN_CS			0xe019
+
+#define XEN_ELFNOTE_INFO			0
+#define XEN_ELFNOTE_ENTRY			1
+#define XEN_ELFNOTE_HYPERCALL_PAGE	2
+#define XEN_ELFNOTE_VIRT_BASE		3
+#define XEN_ELFNOTE_PADDR_OFFSET	4
+#define XEN_ELFNOTE_XEN_VERSION 	5
+#define XEN_ELFNOTE_GUEST_OS		6
+#define XEN_ELFNOTE_GUEST_VERSION	7
+#define XEN_ELFNOTE_LOADER			8
+#define XEN_ELFNOTE_PAE_MODE		9
+#define XEN_ELFNOTE_FEATURES		10
+#define XEN_ELFNOTE_BSD_SYMTAB		11
+
+#define mp_map ((pfn_t *) XEN_VIRT_START)
+
+#define SIF_PRIVILEGED	(1 << 0)  /**< Privileged domain */
+#define SIF_INITDOMAIN	(1 << 1)  /**< Iinitial control domain */
+
+#define XEN_CONSOLE_VGA		0x03
+#define XEN_CONSOLE_VESA	0x23
 
 #define XEN_SET_TRAP_TABLE		0
@@ -104,4 +115,136 @@
 #define DOMID_IO   (0x7FF1U)
 
+#ifndef __ASM__
+
+typedef uint16_t domid_t;
+typedef uint32_t evtchn_t;
+
+typedef struct {
+	uint32_t version;
+	uint32_t pad0;
+	uint64_t tsc_timestamp;   /**< TSC at last update of time vals */
+	uint64_t system_time;     /**< Time, in nanosecs, since boot */
+	uint32_t tsc_to_system_mul;
+	int8_t tsc_shift;
+	int8_t pad1[3];
+} vcpu_time_info_t;
+
+typedef struct {
+	uint32_t cr2;
+	uint32_t pad[5];
+} arch_vcpu_info_t;
+
+typedef struct arch_shared_info {
+	pfn_t max_pfn;                  /**< max pfn that appears in table */
+	uint32_t pfn_to_mfn_frame_list_list;
+    uint32_t nmi_reason;
+} arch_shared_info_t;
+
+typedef struct {
+	uint8_t evtchn_upcall_pending;
+	ipl_t evtchn_upcall_mask;
+	evtchn_t evtchn_pending_sel;
+	arch_vcpu_info_t arch;
+	vcpu_time_info_t time;
+} vcpu_info_t;
+
+typedef struct {
+	vcpu_info_t vcpu_info[VIRT_CPUS];
+	evtchn_t evtchn_pending[32];
+	evtchn_t evtchn_mask[32];
+	
+	uint32_t wc_version;                  /**< Version counter */
+	uint32_t wc_sec;                      /**< Secs  00:00:00 UTC, Jan 1, 1970 */
+	uint32_t wc_nsec;                     /**< Nsecs 00:00:00 UTC, Jan 1, 1970 */
+	
+	arch_shared_info_t arch;
+} shared_info_t;
+
+typedef struct {
+	int8_t magic[32];           /**< "xen-<version>-<platform>" */
+	uint32_t frames;            /**< Available frames */
+	shared_info_t *shared_info; /**< Shared info structure (machine address) */
+	uint32_t flags;             /**< SIF_xxx flags */
+	pfn_t store_mfn;            /**< Shared page (machine page) */
+	evtchn_t store_evtchn;      /**< Event channel for store communication */
+	
+	union {
+        struct {
+			pfn_t mfn;          /**< Console page (machine page) */
+			evtchn_t evtchn;    /**< Event channel for console messages */
+        } domU;
+		
+        struct {
+            uint32_t info_off;  /**< Offset of console_info struct */
+            uint32_t info_size; /**< Size of console_info struct from start */
+        } dom0;
+    } console;
+	
+	pte_t *ptl0;                /**< Boot PTL0 (kernel address) */
+	uint32_t pt_frames;         /**< Number of bootstrap page table frames */
+	pfn_t *pm_map;              /**< Physical->machine frame map (kernel address) */
+	void *mod_start;            /**< Modules start (kernel address) */
+	uint32_t mod_len;           /**< Modules size (bytes) */
+	int8_t cmd_line[GUEST_CMDLINE];
+} start_info_t;
+
+typedef struct {
+    uint8_t video_type;  
+
+    union {
+        struct {
+            uint16_t font_height;
+            uint16_t cursor_x;
+			uint16_t cursor_y;
+            uint16_t rows;
+			uint16_t columns;
+        } vga;
+
+        struct {
+            uint16_t width;
+			uint16_t height;
+            uint16_t bytes_per_line;
+            uint16_t bits_per_pixel;
+            uint32_t lfb_base;
+            uint32_t lfb_size;
+            uint8_t red_pos;
+			uint8_t red_size;
+            uint8_t green_pos;
+			uint8_t green_size;
+            uint8_t blue_pos;
+			uint8_t blue_size;
+            uint8_t rsvd_pos;
+			uint8_t rsvd_size;
+        } vesa_lfb;
+    } info;
+} console_info_t;
+
+typedef struct {
+	pfn_t start;
+	pfn_t size;
+	pfn_t reserved;
+} memzone_t;
+
+extern start_info_t start_info;
+extern shared_info_t shared_info;
+extern memzone_t meminfo;
+
+typedef struct {
+	uint8_t vector;     /**< Exception vector */
+	uint8_t flags;      /**< 0-3: privilege level; 4: clear event enable */
+	uint16_t cs;        /**< Code selector */
+	void *address;      /**< Code offset */
+} trap_info_t;
+
+typedef struct {
+	evtchn_t port;
+} evtchn_send_t;
+
+typedef struct {
+	uint32_t cmd;
+	union {
+		evtchn_send_t send;
+    };
+} evtchn_op_t;
 
 #define force_evtchn_callback() ((void) xen_version(0, 0))
@@ -235,2 +378,4 @@
 
 #endif
+
+#endif
Index: kernel/arch/ia32xen/include/mm/as.h
===================================================================
--- kernel/arch/ia32xen/include/mm/as.h	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/arch/ia32xen/include/mm/as.h	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -48,4 +48,6 @@
 } as_arch_t;
 
+#include <genarch/mm/as_pt.h>
+
 #define as_constructor_arch(as, flags)		(as != as)
 #define as_destructor_arch(as)			(as != as)
Index: kernel/arch/ia32xen/include/mm/frame.h
===================================================================
--- kernel/arch/ia32xen/include/mm/frame.h	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/arch/ia32xen/include/mm/frame.h	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -43,7 +43,4 @@
 #ifndef __ASM__
 
-#include <arch/types.h>
-#include <arch/boot/boot.h>
-
 #define PA2MA(x)	((start_info.pm_map[((uintptr_t) (x)) >> 12] << 12) + (((uintptr_t) (x)) & 0xfff))
 #define MA2PA(x)	((mp_map[((uintptr_t) (x)) >> 12] << 12) + (((uintptr_t) (x)) & 0xfff))
Index: kernel/arch/ia32xen/include/mm/memory_init.h
===================================================================
--- kernel/arch/ia32xen/include/mm/memory_init.h	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/arch/ia32xen/include/mm/memory_init.h	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -37,5 +37,5 @@
 #define KERN_ia32xen_MEMORY_INIT_H_
 
-#include <typedefs.h>
+#include <arch/types.h>
 
 size_t get_memory_size(void);
Index: kernel/arch/ia32xen/include/mm/page.h
===================================================================
--- kernel/arch/ia32xen/include/mm/page.h	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/arch/ia32xen/include/mm/page.h	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -122,9 +122,7 @@
 #ifndef __ASM__
 
-#include <mm/page.h>
-#include <arch/types.h>
-#include <arch/mm/frame.h>
-#include <typedefs.h>
+#include <mm/mm.h>
 #include <arch/hypercall.h>
+#include <arch/interrupt.h>
 
 /* Page fault error codes. */
@@ -141,20 +139,4 @@
 /** When bit on this position is 1, a reserved bit was set in page directory. */ 
 #define PFERR_CODE_RSVD		(1 << 3)
-
-/** Page Table Entry. */
-struct page_specifier {
-	unsigned present : 1;
-	unsigned writeable : 1;
-	unsigned uaccessible : 1;
-	unsigned page_write_through : 1;
-	unsigned page_cache_disable : 1;
-	unsigned accessed : 1;
-	unsigned dirty : 1;
-	unsigned pat : 1;
-	unsigned global : 1;
-	unsigned soft_valid : 1;	/**< Valid content even if the present bit is not set. */
-	unsigned avl : 2;
-	unsigned frame_address : 20;
-} __attribute__ ((packed));
 
 typedef struct {
Index: kernel/arch/ia32xen/include/pm.h
===================================================================
--- kernel/arch/ia32xen/include/pm.h	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/arch/ia32xen/include/pm.h	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -70,5 +70,4 @@
 
 #include <arch/types.h>
-#include <typedefs.h>
 #include <arch/context.h>
 
Index: kernel/arch/ia32xen/include/types.h
===================================================================
--- kernel/arch/ia32xen/include/types.h	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/arch/ia32xen/include/types.h	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -37,4 +37,6 @@
 
 #define NULL 0
+#define false 0
+#define true 1
 
 typedef signed char int8_t;
@@ -48,4 +50,8 @@
 typedef unsigned long long uint64_t;
 
+typedef uint32_t size_t;
+typedef uint32_t count_t;
+typedef uint32_t index_t;
+
 typedef uint32_t uintptr_t;
 typedef uint32_t pfn_t;
@@ -56,5 +62,26 @@
 typedef int32_t native_t;
 
-typedef struct page_specifier pte_t;
+typedef uint8_t bool;
+typedef uint64_t task_id_t;
+typedef uint32_t context_id_t;
+
+typedef int32_t inr_t;
+typedef int32_t devno_t;
+
+/** Page Table Entry. */
+typedef struct {
+	unsigned present : 1;
+	unsigned writeable : 1;
+	unsigned uaccessible : 1;
+	unsigned page_write_through : 1;
+	unsigned page_cache_disable : 1;
+	unsigned accessed : 1;
+	unsigned dirty : 1;
+	unsigned pat : 1;
+	unsigned global : 1;
+	unsigned soft_valid : 1;	/**< Valid content even if the present bit is not set. */
+	unsigned avl : 2;
+	unsigned frame_address : 20;
+} __attribute__ ((packed)) pte_t;
 
 #endif
Index: kernel/arch/ia32xen/src/boot/boot.S
===================================================================
--- kernel/arch/ia32xen/src/boot/boot.S	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/arch/ia32xen/src/boot/boot.S	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -27,7 +27,6 @@
 #
 
-#include <arch/boot/boot.h>
 #include <arch/mm/page.h>
-#include <arch/pm.h>
+#include <arch/hypercall.h>
 
 #define ELFNOTE(name, type, desctype, descval) \
Index: kernel/arch/ia32xen/src/ia32xen.c
===================================================================
--- kernel/arch/ia32xen/src/ia32xen.c	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/arch/ia32xen/src/ia32xen.c	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -37,5 +37,4 @@
 
 #include <arch/types.h>
-#include <typedefs.h>
 #include <align.h>
 
@@ -55,5 +54,4 @@
 #include <arch/bios/bios.h>
 
-#include <arch/boot/boot.h>
 #include <arch/mm/memory_init.h>
 #include <interrupt.h>
Index: kernel/arch/ia32xen/src/mm/as.c
===================================================================
--- kernel/arch/ia32xen/src/mm/as.c	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/arch/ia32xen/src/mm/as.c	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -35,5 +35,5 @@
 
 #include <arch/mm/as.h>
-#include <genarch/mm/as_pt.h>
+#include <genarch/mm/page_pt.h>
 
 /** Architecture dependent address space init. */
Index: kernel/arch/ia32xen/src/mm/memory_init.c
===================================================================
--- kernel/arch/ia32xen/src/mm/memory_init.c	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/arch/ia32xen/src/mm/memory_init.c	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -35,5 +35,4 @@
 #include <arch/mm/memory_init.h>
 #include <arch/mm/page.h>
-#include <arch/boot/boot.h>
 #include <print.h>
 #include <mm/frame.h>
Index: kernel/arch/ia32xen/src/pm.c
===================================================================
--- kernel/arch/ia32xen/src/pm.c	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/arch/ia32xen/src/pm.c	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -36,5 +36,4 @@
 #include <config.h>
 #include <arch/types.h>
-#include <typedefs.h>
 #include <arch/interrupt.h>
 #include <arch/asm.h>
@@ -44,5 +43,4 @@
 #include <mm/slab.h>
 #include <memstr.h>
-#include <arch/boot/boot.h>
 #include <interrupt.h>
 
Index: kernel/arch/ia32xen/src/smp/apic.c
===================================================================
--- kernel/arch/ia32xen/src/smp/apic.c	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/arch/ia32xen/src/smp/apic.c	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -37,5 +37,4 @@
 #include <arch/smp/ap.h>
 #include <arch/smp/mps.h>
-#include <arch/boot/boot.h>
 #include <mm/page.h>
 #include <time/delay.h>
Index: kernel/arch/ia32xen/src/smp/mps.c
===================================================================
--- kernel/arch/ia32xen/src/smp/mps.c	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/arch/ia32xen/src/smp/mps.c	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -43,5 +43,4 @@
 #include <func.h>
 #include <arch/types.h>
-#include <typedefs.h>
 #include <cpu.h>
 #include <arch/asm.h>
Index: kernel/arch/ia32xen/src/smp/smp.c
===================================================================
--- kernel/arch/ia32xen/src/smp/smp.c	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/arch/ia32xen/src/smp/smp.c	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -37,5 +37,4 @@
 #include <arch/smp/mps.h>
 #include <arch/smp/ap.h>
-#include <arch/boot/boot.h>
 #include <genarch/acpi/acpi.h>
 #include <genarch/acpi/madt.h>
Index: kernel/arch/ia64/_link.ld.in
===================================================================
--- kernel/arch/ia64/_link.ld.in	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/arch/ia64/_link.ld.in	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -6,6 +6,4 @@
  *
  */
-
-#define __ASM__
 
 ENTRY(kernel_image_start)
Index: kernel/arch/ia64/include/context.h
===================================================================
--- kernel/arch/ia64/include/context.h	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/arch/ia64/include/context.h	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -38,5 +38,4 @@
 #include <arch/types.h>
 #include <arch/register.h>
-#include <typedefs.h>
 #include <align.h>
 #include <arch/stack.h>
@@ -48,5 +47,5 @@
  * One item is put onto the stack to support get_stack_base().
  */
-#define SP_DELTA	(0+ALIGN_UP(STACK_ITEM_SIZE, STACK_ALIGNMENT))
+#define SP_DELTA	(0 + ALIGN_UP(STACK_ITEM_SIZE, STACK_ALIGNMENT))
 
 #ifdef context_set
@@ -106,25 +105,25 @@
 	uint64_t pr;
 
-	__r128 f2 __attribute__ ((aligned(16)));
-	__r128 f3;
-	__r128 f4;
-	__r128 f5;
+	uint128_t f2 __attribute__ ((aligned(16)));
+	uint128_t f3;
+	uint128_t f4;
+	uint128_t f5;
 
-	__r128 f16;
-	__r128 f17;
-	__r128 f18;
-	__r128 f19;
-	__r128 f20;
-	__r128 f21;
-	__r128 f22;
-	__r128 f23;
-	__r128 f24;
-	__r128 f25;
-	__r128 f26;
-	__r128 f27;
-	__r128 f28;
-	__r128 f29;
-	__r128 f30;
-	__r128 f31;
+	uint128_t f16;
+	uint128_t f17;
+	uint128_t f18;
+	uint128_t f19;
+	uint128_t f20;
+	uint128_t f21;
+	uint128_t f22;
+	uint128_t f23;
+	uint128_t f24;
+	uint128_t f25;
+	uint128_t f26;
+	uint128_t f27;
+	uint128_t f28;
+	uint128_t f29;
+	uint128_t f30;
+	uint128_t f31;
 	
 	ipl_t ipl;
Index: kernel/arch/ia64/include/cpu.h
===================================================================
--- kernel/arch/ia64/include/cpu.h	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/arch/ia64/include/cpu.h	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -37,6 +37,6 @@
 
 #include <arch/types.h>
-#include <typedefs.h>
 #include <arch/register.h>
+#include <arch/asm.h>
 
 #define FAMILY_ITANIUM	0x7
Index: kernel/arch/ia64/include/fpu_context.h
===================================================================
--- kernel/arch/ia64/include/fpu_context.h	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/arch/ia64/include/fpu_context.h	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -44,5 +44,5 @@
 
 typedef struct {
-	__r128 fr[FRS];
+	uint128_t fr[FRS];
 } fpu_context_t;
 
Index: kernel/arch/ia64/include/interrupt.h
===================================================================
--- kernel/arch/ia64/include/interrupt.h	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/arch/ia64/include/interrupt.h	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -36,5 +36,4 @@
 #define KERN_ia64_INTERRUPT_H_
 
-#include <typedefs.h>
 #include <arch/types.h>
 #include <arch/register.h>
@@ -65,35 +64,35 @@
 #define EOI	0		/**< The actual value doesn't matter. */
 
-struct istate {
-	__r128 f2;
-	__r128 f3;
-	__r128 f4;
-	__r128 f5;
-	__r128 f6;
-	__r128 f7;
-	__r128 f8;
-	__r128 f9;
-	__r128 f10;
-	__r128 f11;
-	__r128 f12;
-	__r128 f13;
-	__r128 f14;
-	__r128 f15;
-	__r128 f16;
-	__r128 f17;
-	__r128 f18;
-	__r128 f19;
-	__r128 f20;
-	__r128 f21;
-	__r128 f22;
-	__r128 f23;
-	__r128 f24;
-	__r128 f25;
-	__r128 f26;
-	__r128 f27;
-	__r128 f28;
-	__r128 f29;
-	__r128 f30;
-	__r128 f31;
+typedef struct {
+	uint128_t f2;
+	uint128_t f3;
+	uint128_t f4;
+	uint128_t f5;
+	uint128_t f6;
+	uint128_t f7;
+	uint128_t f8;
+	uint128_t f9;
+	uint128_t f10;
+	uint128_t f11;
+	uint128_t f12;
+	uint128_t f13;
+	uint128_t f14;
+	uint128_t f15;
+	uint128_t f16;
+	uint128_t f17;
+	uint128_t f18;
+	uint128_t f19;
+	uint128_t f20;
+	uint128_t f21;
+	uint128_t f22;
+	uint128_t f23;
+	uint128_t f24;
+	uint128_t f25;
+	uint128_t f26;
+	uint128_t f27;
+	uint128_t f28;
+	uint128_t f29;
+	uint128_t f30;
+	uint128_t f31;
 		
 	uintptr_t ar_bsp;
@@ -120,5 +119,5 @@
 	uint64_t in3;
 	uint64_t in4;
-};
+} istate_t;
 
 static inline void istate_set_retaddr(istate_t *istate, uintptr_t retaddr)
Index: kernel/arch/ia64/include/mm/as.h
===================================================================
--- kernel/arch/ia64/include/mm/as.h	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/arch/ia64/include/mm/as.h	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -48,4 +48,6 @@
 } as_arch_t;
 
+#include <genarch/mm/as_ht.h>
+
 #define as_constructor_arch(as, flags)		(as != as)
 #define as_destructor_arch(as)			(as != as)
Index: kernel/arch/ia64/include/mm/page.h
===================================================================
--- kernel/arch/ia64/include/mm/page.h	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/arch/ia64/include/mm/page.h	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -86,10 +86,10 @@
 #ifndef __ASM__
 
+#include <arch/mm/as.h>
 #include <arch/mm/frame.h>
+#include <arch/interrupt.h>
 #include <arch/barrier.h>
-#include <genarch/mm/page_ht.h>
 #include <arch/mm/asid.h>
 #include <arch/types.h>
-#include <typedefs.h>
 #include <debug.h>
 
Index: kernel/arch/ia64/include/mm/tlb.h
===================================================================
--- kernel/arch/ia64/include/mm/tlb.h	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/arch/ia64/include/mm/tlb.h	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -43,5 +43,4 @@
 #include <arch/interrupt.h>
 #include <arch/types.h>
-#include <typedefs.h>
 
 /** Data and instruction Translation Register indices. */
Index: kernel/arch/ia64/include/types.h
===================================================================
--- kernel/arch/ia64/include/types.h	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/arch/ia64/include/types.h	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -36,10 +36,16 @@
 #define KERN_ia64_TYPES_H_
 
-#define NULL	0
+#define NULL 0
+#define false 0
+#define true 1
 
 typedef signed char int8_t;
-typedef signed short int int16_t;
+typedef signed short int16_t;
 typedef signed int int32_t;
 typedef signed long int64_t;
+typedef struct {
+	int64_t lo;
+	int64_t hi;
+} int128_t;
 
 typedef unsigned char uint8_t;
@@ -47,13 +53,12 @@
 typedef unsigned int uint32_t;
 typedef unsigned long uint64_t;
+typedef struct {
+	uint64_t lo;
+	uint64_t hi;
+} uint128_t;
 
-typedef unsigned char __r8; 			/* Reserve byte */
-typedef unsigned short __r16;
-typedef unsigned int __r32;
-typedef unsigned long __r64;
-typedef struct __r128 {
-	__r64 lo;
-	__r64 hi;
-} __r128;
+typedef uint64_t size_t;
+typedef uint64_t count_t;
+typedef uint64_t index_t;
 
 typedef uint64_t uintptr_t;
@@ -65,5 +70,10 @@
 typedef int64_t native_t;
 
-typedef struct pte pte_t;
+typedef uint8_t bool;
+typedef uint64_t task_id_t;
+typedef uint32_t context_id_t;
+
+typedef int32_t inr_t;
+typedef int32_t devno_t;
 
 #endif
Index: kernel/arch/ia64/src/ddi/ddi.c
===================================================================
--- kernel/arch/ia64/src/ddi/ddi.c	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/arch/ia64/src/ddi/ddi.c	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -36,5 +36,4 @@
 #include <proc/task.h>
 #include <arch/types.h>
-#include <typedefs.h>
 
 /** Enable I/O space range for task.
Index: kernel/arch/ia64/src/mm/page.c
===================================================================
--- kernel/arch/ia64/src/mm/page.c	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/arch/ia64/src/mm/page.c	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -40,5 +40,4 @@
 #include <arch/mm/vhpt.h>
 #include <arch/types.h>
-#include <typedefs.h>
 #include <print.h>
 #include <mm/page.h>
Index: kernel/arch/ia64/src/mm/tlb.c
===================================================================
--- kernel/arch/ia64/src/mm/tlb.c	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/arch/ia64/src/mm/tlb.c	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -48,5 +48,4 @@
 #include <arch/pal/pal.h>
 #include <arch/asm.h>
-#include <typedefs.h>
 #include <panic.h>
 #include <print.h>
Index: kernel/arch/ia64/src/mm/vhpt.c
===================================================================
--- kernel/arch/ia64/src/mm/vhpt.c	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/arch/ia64/src/mm/vhpt.c	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -33,4 +33,5 @@
 */
 
+#include <memstr.h>
 #include <arch/mm/vhpt.h>
 #include <mm/frame.h>
@@ -41,6 +42,6 @@
 uintptr_t vhpt_set_up(void)
 {
-	vhpt_base = frame_alloc(VHPT_WIDTH-FRAME_WIDTH,FRAME_KA | FRAME_ATOMIC);
-	if(!vhpt_base) 
+	vhpt_base = frame_alloc(VHPT_WIDTH - FRAME_WIDTH, FRAME_KA | FRAME_ATOMIC);
+	if (!vhpt_base) 
 		panic("Kernel configured with VHPT but no memory for table.");
 	vhpt_invalidate_all();
@@ -62,26 +63,24 @@
 	rid = ASID2RID(asid, vrn);
 																												
-  rr_save.word = rr_read(vrn);
-  rr.word = rr_save.word;
-  rr.map.rid = rid;
-  rr_write(vrn, rr.word);
-  srlz_i();
+	rr_save.word = rr_read(vrn);
+	rr.word = rr_save.word;
+	rr.map.rid = rid;
+	rr_write(vrn, rr.word);
+	srlz_i();
 	
 	ventry = (vhpt_entry_t *) thash(va);
-  tag = ttag(va);
-  rr_write(vrn, rr_save.word);
-  srlz_i();
-  srlz_d();
+	tag = ttag(va);
+	rr_write(vrn, rr_save.word);
+	srlz_i();
+	srlz_d();
 
-	ventry->word[0]=entry.word[0];
-	ventry->word[1]=entry.word[1];
+	ventry->word[0] = entry.word[0];
+	ventry->word[1] = entry.word[1];
 	ventry->present.tag.tag_word = tag;
-	
-
 }
 
 void vhpt_invalidate_all()
 {
-	memsetb((uintptr_t)vhpt_base,1<<VHPT_WIDTH,0);
+	memsetb((uintptr_t) vhpt_base, 1 << VHPT_WIDTH, 0);
 }
 
Index: kernel/arch/ia64/src/ski/ski.c
===================================================================
--- kernel/arch/ia64/src/ski/ski.c	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/arch/ia64/src/ski/ski.c	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -39,5 +39,4 @@
 #include <sysinfo/sysinfo.h>
 #include <arch/types.h>
-#include <typedefs.h>
 #include <ddi/device.h>
 #include <ddi/irq.h>
Index: kernel/arch/mips32/include/asm.h
===================================================================
--- kernel/arch/mips32/include/asm.h	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/arch/mips32/include/asm.h	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -37,5 +37,4 @@
 
 #include <arch/types.h>
-#include <typedefs.h>
 #include <config.h>
 
Index: kernel/arch/mips32/include/cache.h
===================================================================
--- kernel/arch/mips32/include/cache.h	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/arch/mips32/include/cache.h	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -36,5 +36,5 @@
 #define KERN_mips32_CACHE_H_
 
-#include <typedefs.h>
+#include <arch/exception.h>
 
 extern void cache_error(istate_t *istate);
Index: kernel/arch/mips32/include/context_offset.h
===================================================================
--- kernel/arch/mips32/include/context_offset.h	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/arch/mips32/include/context_offset.h	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -43,5 +43,5 @@
 #define OFFSET_GP      0x2c
 
-/* struct istate */
+/* istate_t */
 #define EOFFSET_AT     0x0
 #define EOFFSET_V0     0x4
Index: kernel/arch/mips32/include/cp0.h
===================================================================
--- kernel/arch/mips32/include/cp0.h	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/arch/mips32/include/cp0.h	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -37,12 +37,11 @@
 
 #include <arch/types.h>
-#include <arch/mm/tlb.h>
 
-#define cp0_status_ie_enabled_bit	(1<<0)
-#define cp0_status_exl_exception_bit	(1<<1)
-#define cp0_status_erl_error_bit	(1<<2)
-#define cp0_status_um_bit	        (1<<4)
-#define cp0_status_bev_bootstrap_bit	(1<<22)
-#define cp0_status_fpu_bit              (1<<29)
+#define cp0_status_ie_enabled_bit	(1 << 0)
+#define cp0_status_exl_exception_bit	(1 << 1)
+#define cp0_status_erl_error_bit	(1 << 2)
+#define cp0_status_um_bit	        (1 << 4)
+#define cp0_status_bev_bootstrap_bit	(1 << 22)
+#define cp0_status_fpu_bit              (1 << 29)
 
 #define cp0_status_im_shift		8
@@ -61,6 +60,6 @@
 #define cp0_mask_all_int() cp0_status_write(cp0_status_read() & ~(cp0_status_im_mask))
 #define cp0_unmask_all_int() cp0_status_write(cp0_status_read() | cp0_status_im_mask)
-#define cp0_mask_int(it) cp0_status_write(cp0_status_read() & ~(1<<(cp0_status_im_shift+(it))))
-#define cp0_unmask_int(it) cp0_status_write(cp0_status_read() | (1<<(cp0_status_im_shift+(it))))
+#define cp0_mask_int(it) cp0_status_write(cp0_status_read() & ~(1 << (cp0_status_im_shift + (it))))
+#define cp0_unmask_int(it) cp0_status_write(cp0_status_read() | (1 << (cp0_status_im_shift + (it))))
 
 #define GEN_READ_CP0(nm,reg) static inline uint32_t cp0_ ##nm##_read(void) \
Index: kernel/arch/mips32/include/cpu.h
===================================================================
--- kernel/arch/mips32/include/cpu.h	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/arch/mips32/include/cpu.h	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -37,4 +37,5 @@
 
 #include <arch/types.h>
+#include <arch/asm.h>
 
 typedef struct {
Index: kernel/arch/mips32/include/debugger.h
===================================================================
--- kernel/arch/mips32/include/debugger.h	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/arch/mips32/include/debugger.h	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -36,5 +36,4 @@
 #define KERN_mips32_DEBUGGER_H_
 
-#include <typedefs.h>
 #include <arch/exception.h>
 #include <arch/types.h>
Index: kernel/arch/mips32/include/exception.h
===================================================================
--- kernel/arch/mips32/include/exception.h	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/arch/mips32/include/exception.h	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -37,5 +37,4 @@
 
 #include <arch/types.h>
-#include <typedefs.h>
 #include <arch/cp0.h>
 
@@ -59,5 +58,5 @@
 #define EXC_VCED	31
 
-struct istate {
+typedef struct {
 	uint32_t at;
 	uint32_t v0;
@@ -96,5 +95,5 @@
 	uint32_t epc; /* cp0_epc */
 	uint32_t k1; /* We use it as thread-local pointer */
-};
+} istate_t;
 
 static inline void istate_set_retaddr(istate_t *istate, uintptr_t retaddr)
Index: kernel/arch/mips32/include/interrupt.h
===================================================================
--- kernel/arch/mips32/include/interrupt.h	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/arch/mips32/include/interrupt.h	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -36,4 +36,5 @@
 #define KERN_mips32_INTERRUPT_H_
 
+#include <typedefs.h>
 #include <arch/exception.h>
 
Index: kernel/arch/mips32/include/mm/as.h
===================================================================
--- kernel/arch/mips32/include/mm/as.h	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/arch/mips32/include/mm/as.h	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -43,8 +43,10 @@
 #define USER_ADDRESS_SPACE_END_ARCH		(unsigned long) 0x7fffffff
 
-#define USTACK_ADDRESS_ARCH	(0x80000000-PAGE_SIZE)
+#define USTACK_ADDRESS_ARCH	(0x80000000 - PAGE_SIZE)
 
 typedef struct {
 } as_arch_t;
+
+#include <genarch/mm/as_pt.h>
 
 #define as_constructor_arch(as, flags)		(as != as)
Index: kernel/arch/mips32/include/mm/page.h
===================================================================
--- kernel/arch/mips32/include/mm/page.h	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/arch/mips32/include/mm/page.h	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -44,9 +44,9 @@
 
 #ifndef __ASM__
-#  define KA2PA(x)	(((uintptr_t) (x)) - 0x80000000)
-#  define PA2KA(x)	(((uintptr_t) (x)) + 0x80000000)
+#	define KA2PA(x)	(((uintptr_t) (x)) - 0x80000000)
+#	define PA2KA(x)	(((uintptr_t) (x)) + 0x80000000)
 #else
-#  define KA2PA(x)	((x) - 0x80000000)
-#  define PA2KA(x)	((x) + 0x80000000)
+#	define KA2PA(x)	((x) - 0x80000000)
+#	define PA2KA(x)	((x) + 0x80000000)
 #endif
 
@@ -110,8 +110,6 @@
 #ifndef __ASM__
 
-#include <arch/mm/tlb.h>
-#include <mm/page.h>
-#include <arch/mm/frame.h>
-#include <arch/types.h>
+#include <mm/mm.h>
+#include <arch/exception.h>
 
 static inline int get_pt_flags(pte_t *pt, index_t i)
Index: kernel/arch/mips32/include/mm/tlb.h
===================================================================
--- kernel/arch/mips32/include/mm/tlb.h	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/arch/mips32/include/mm/tlb.h	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -37,5 +37,4 @@
 
 #include <arch/exception.h>
-#include <typedefs.h>
 
 #ifdef TLBCNT
@@ -53,10 +52,5 @@
 #define PAGE_CACHEABLE_EXC_WRITE	5
 
-typedef union entry_lo entry_lo_t;
-typedef union entry_hi entry_hi_t;
-typedef union page_mask page_mask_t;
-typedef union index tlb_index_t;
-
-union entry_lo {
+typedef union {
 	struct {
 #ifdef BIG_ENDIAN
@@ -77,20 +71,7 @@
 	} __attribute__ ((packed));
 	uint32_t value;
-};
+} entry_lo_t;
 
-/** Page Table Entry. */
-struct pte {
-	unsigned g : 1;			/**< Global bit. */
-	unsigned p : 1;			/**< Present bit. */
-	unsigned d : 1;			/**< Dirty bit. */
-	unsigned cacheable : 1;		/**< Cacheable bit. */
-	unsigned : 1;			/**< Unused. */
-	unsigned soft_valid : 1;	/**< Valid content even if not present. */
-	unsigned pfn : 24;		/**< Physical frame number. */
-	unsigned w : 1;			/**< Page writable bit. */
-	unsigned a : 1;			/**< Accessed bit. */
-};
-
-union entry_hi {
+typedef union {
 	struct {
 #ifdef BIG_ENDIAN
@@ -105,7 +86,7 @@
 	} __attribute__ ((packed));
 	uint32_t value;
-};
+} entry_hi_t;
 
-union page_mask {
+typedef union {
 	struct {
 #ifdef BIG_ENDIAN
@@ -120,7 +101,7 @@
 	} __attribute__ ((packed));
 	uint32_t value;
-};
+} page_mask_t;
 
-union index {
+typedef union {
 	struct {
 #ifdef BIG_ENDIAN
@@ -135,5 +116,5 @@
 	} __attribute__ ((packed));
 	uint32_t value;
-};
+} tlb_index_t;
 
 /** Probe TLB for Matching Entry
Index: kernel/arch/mips32/include/types.h
===================================================================
--- kernel/arch/mips32/include/types.h	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/arch/mips32/include/types.h	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -36,19 +36,24 @@
 #define KERN_mips32_TYPES_H_
 
-#define NULL	0
+#define NULL 0
+#define false 0
+#define true 1
 
 typedef signed char int8_t;
-typedef unsigned char uint8_t;
-
 typedef signed short int16_t;
-typedef unsigned short uint16_t;
-
-typedef unsigned long uint32_t;
 typedef signed long int32_t;
-
-typedef unsigned long long uint64_t;
 typedef signed long long int64_t;
 
+typedef unsigned char uint8_t;
+typedef unsigned short uint16_t;
+typedef unsigned long uint32_t;
+typedef unsigned long long uint64_t;
+
+typedef uint32_t size_t;
+typedef uint32_t count_t;
+typedef uint32_t index_t;
+
 typedef uint32_t uintptr_t;
+typedef uint32_t pfn_t;
 
 typedef uint32_t ipl_t;
@@ -57,7 +62,23 @@
 typedef int32_t native_t;
 
-typedef struct pte pte_t;
+typedef uint8_t bool;
+typedef uint64_t task_id_t;
+typedef uint32_t context_id_t;
 
-typedef uint32_t pfn_t;
+typedef int32_t inr_t;
+typedef int32_t devno_t;
+
+/** Page Table Entry. */
+typedef struct {
+	unsigned g : 1;			/**< Global bit. */
+	unsigned p : 1;			/**< Present bit. */
+	unsigned d : 1;			/**< Dirty bit. */
+	unsigned cacheable : 1;		/**< Cacheable bit. */
+	unsigned : 1;			/**< Unused. */
+	unsigned soft_valid : 1;	/**< Valid content even if not present. */
+	unsigned pfn : 24;		/**< Physical frame number. */
+	unsigned w : 1;			/**< Page writable bit. */
+	unsigned a : 1;			/**< Accessed bit. */
+} pte_t;
 
 #endif
Index: kernel/arch/mips32/src/cache.c
===================================================================
--- kernel/arch/mips32/src/cache.c	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/arch/mips32/src/cache.c	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -35,5 +35,4 @@
 #include <arch/cache.h>
 #include <arch/exception.h>
-#include <typedefs.h>
 #include <panic.h>
 
Index: kernel/arch/mips32/src/cpu/cpu.c
===================================================================
--- kernel/arch/mips32/src/cpu/cpu.c	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/arch/mips32/src/cpu/cpu.c	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -35,10 +35,6 @@
 #include <arch/cpu.h>
 #include <cpu.h>
-
 #include <arch.h>
-
 #include <arch/cp0.h>
-
-#include <typedefs.h>
 #include <print.h>	
 
Index: kernel/arch/mips32/src/ddi/ddi.c
===================================================================
--- kernel/arch/mips32/src/ddi/ddi.c	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/arch/mips32/src/ddi/ddi.c	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -36,5 +36,4 @@
 #include <proc/task.h>
 #include <arch/types.h>
-#include <typedefs.h>
 #include <security/cap.h>
 #include <arch.h>
Index: kernel/arch/mips32/src/drivers/msim.c
===================================================================
--- kernel/arch/mips32/src/drivers/msim.c	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/arch/mips32/src/drivers/msim.c	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -34,9 +34,9 @@
 
 #include <interrupt.h>
+#include <ipc/irq.h>
 #include <console/chardev.h>
 #include <arch/drivers/msim.h>
 #include <arch/cp0.h>
 #include <console/console.h>
-#include <ddi/irq.h>
 #include <sysinfo/sysinfo.h>
 
Index: kernel/arch/mips32/src/drivers/serial.c
===================================================================
--- kernel/arch/mips32/src/drivers/serial.c	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/arch/mips32/src/drivers/serial.c	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -35,8 +35,8 @@
 #include <interrupt.h>
 #include <arch/cp0.h>
+#include <ipc/irq.h>
 #include <arch/drivers/serial.h>
 #include <console/chardev.h>
 #include <console/console.h>
-#include <ddi/irq.h>
 
 #define SERIAL_IRQ 2
Index: kernel/arch/mips32/src/exception.c
===================================================================
--- kernel/arch/mips32/src/exception.c	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/arch/mips32/src/exception.c	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -35,4 +35,5 @@
 #include <arch/exception.h>
 #include <arch/interrupt.h>
+#include <arch/mm/tlb.h>
 #include <panic.h>
 #include <arch/cp0.h>
Index: kernel/arch/mips32/src/interrupt.c
===================================================================
--- kernel/arch/mips32/src/interrupt.c	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/arch/mips32/src/interrupt.c	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -42,5 +42,4 @@
 #include <ipc/sysipc.h>
 #include <ddi/device.h>
-#include <ddi/irq.h>
 
 #define IRQ_COUNT 8
Index: kernel/arch/mips32/src/mips32.c
===================================================================
--- kernel/arch/mips32/src/mips32.c	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/arch/mips32/src/mips32.c	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -37,5 +37,4 @@
 #include <arch/cp0.h>
 #include <arch/exception.h>
-#include <arch/asm.h>
 #include <mm/as.h>
 
Index: kernel/arch/ppc32/_link.ld.in
===================================================================
--- kernel/arch/ppc32/_link.ld.in	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/arch/ppc32/_link.ld.in	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -10,5 +10,4 @@
  */
 
-#define __ASM__
 #include <arch/boot/boot.h>
 #include <arch/mm/page.h>
Index: kernel/arch/ppc32/include/cpu.h
===================================================================
--- kernel/arch/ppc32/include/cpu.h	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/arch/ppc32/include/cpu.h	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -36,5 +36,5 @@
 #define KERN_ppc32_CPU_H_
 
-#include <typedefs.h>
+#include <arch/asm.h>
 
 typedef struct {
Index: kernel/arch/ppc32/include/drivers/cuda.h
===================================================================
--- kernel/arch/ppc32/include/drivers/cuda.h	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/arch/ppc32/include/drivers/cuda.h	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -37,5 +37,4 @@
 
 #include <arch/types.h>
-#include <typedefs.h>
 
 extern void cuda_init(devno_t devno, uintptr_t base, size_t size);
Index: kernel/arch/ppc32/include/drivers/pic.h
===================================================================
--- kernel/arch/ppc32/include/drivers/pic.h	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/arch/ppc32/include/drivers/pic.h	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -36,4 +36,6 @@
 #define KERN_ppc32_PIC_H_
 
+#include <arch/types.h>
+
 #define PIC_PENDING_LOW    8
 #define PIC_PENDING_HIGH   4
Index: kernel/arch/ppc32/include/exception.h
===================================================================
--- kernel/arch/ppc32/include/exception.h	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/arch/ppc32/include/exception.h	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -37,7 +37,6 @@
 
 #include <arch/types.h>
-#include <typedefs.h>
 
-struct istate {
+typedef struct {
 	uint32_t r0;
 	uint32_t r2;
@@ -78,5 +77,5 @@
 	uint32_t r12;
 	uint32_t sp;
-};
+} istate_t;
 
 static inline void istate_set_retaddr(istate_t *istate, uintptr_t retaddr)
Index: kernel/arch/ppc32/include/mm/as.h
===================================================================
--- kernel/arch/ppc32/include/mm/as.h	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/arch/ppc32/include/mm/as.h	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -43,8 +43,10 @@
 #define USER_ADDRESS_SPACE_END_ARCH		((unsigned long) 0x7fffffff)
 
-#define USTACK_ADDRESS_ARCH	(0x7fffffff-(PAGE_SIZE-1))
+#define USTACK_ADDRESS_ARCH	(0x7fffffff - (PAGE_SIZE - 1))
 
 typedef struct {
 } as_arch_t;
+
+#include <genarch/mm/as_pt.h>
 
 #define as_constructor_arch(as, flags)		(as != as)
Index: kernel/arch/ppc32/include/mm/memory_init.h
===================================================================
--- kernel/arch/ppc32/include/mm/memory_init.h	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/arch/ppc32/include/mm/memory_init.h	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -36,6 +36,4 @@
 #define KERN_ppc32_MEMORY_INIT_H_
 
-#include <typedefs.h>
-
 size_t get_memory_size(void);
 
Index: kernel/arch/ppc32/include/mm/page.h
===================================================================
--- kernel/arch/ppc32/include/mm/page.h	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/arch/ppc32/include/mm/page.h	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -105,7 +105,6 @@
 #ifndef __ASM__
 
-#include <mm/page.h>
-#include <arch/mm/frame.h>
-#include <arch/types.h>
+#include <mm/mm.h>
+#include <arch/interrupt.h>
 
 static inline int get_pt_flags(pte_t *pt, index_t i)
Index: kernel/arch/ppc32/include/mm/tlb.h
===================================================================
--- kernel/arch/ppc32/include/mm/tlb.h	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/arch/ppc32/include/mm/tlb.h	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -36,4 +36,6 @@
 #define KERN_ppc32_TLB_H_
 
+#include <arch/interrupt.h>
+
 typedef struct {
 	unsigned v : 1;          /**< Valid */
Index: kernel/arch/ppc32/include/types.h
===================================================================
--- kernel/arch/ppc32/include/types.h	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/arch/ppc32/include/types.h	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -37,4 +37,6 @@
 
 #define NULL 0
+#define false 0
+#define true 1
 
 typedef signed char int8_t;
@@ -48,4 +50,8 @@
 typedef unsigned long long uint64_t;
 
+typedef uint32_t size_t;
+typedef uint32_t count_t;
+typedef uint32_t index_t;
+
 typedef uint32_t uintptr_t;
 typedef uint32_t pfn_t;
@@ -54,4 +60,12 @@
 
 typedef uint32_t unative_t;
+typedef int32_t native_t;
+
+typedef uint8_t bool;
+typedef uint64_t task_id_t;
+typedef uint32_t context_id_t;
+
+typedef int32_t inr_t;
+typedef int32_t devno_t;
 
 /** Page Table Entry. */
Index: kernel/arch/ppc32/src/cpu/cpu.c
===================================================================
--- kernel/arch/ppc32/src/cpu/cpu.c	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/arch/ppc32/src/cpu/cpu.c	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -36,8 +36,5 @@
 #include <arch/cpuid.h>
 #include <cpu.h>
-
 #include <arch.h>
-
-#include <typedefs.h>
 #include <print.h>
 
Index: kernel/arch/ppc32/src/ddi/ddi.c
===================================================================
--- kernel/arch/ppc32/src/ddi/ddi.c	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/arch/ppc32/src/ddi/ddi.c	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -36,5 +36,4 @@
 #include <proc/task.h>
 #include <arch/types.h>
-#include <typedefs.h>
 
 /** Enable I/O space range for task.
Index: kernel/arch/ppc32/src/drivers/cuda.c
===================================================================
--- kernel/arch/ppc32/src/drivers/cuda.c	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/arch/ppc32/src/drivers/cuda.c	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -34,5 +34,5 @@
 
 #include <arch/drivers/cuda.h>
-#include <ddi/irq.h>
+#include <ipc/irq.h>
 #include <arch/asm.h>
 #include <console/console.h>
Index: kernel/arch/ppc32/src/drivers/pic.c
===================================================================
--- kernel/arch/ppc32/src/drivers/pic.c	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/arch/ppc32/src/drivers/pic.c	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -34,6 +34,6 @@
 
 
-#include <arch/asm.h>
 #include <arch/drivers/pic.h>
+#include <mm/page.h>
 #include <byteorder.h>
 #include <bitops.h>
Index: kernel/arch/ppc32/src/mm/memory_init.c
===================================================================
--- kernel/arch/ppc32/src/mm/memory_init.c	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/arch/ppc32/src/mm/memory_init.c	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -35,5 +35,4 @@
 #include <arch/boot/boot.h>
 #include <arch/mm/memory_init.h>
-#include <typedefs.h>
 #include <print.h>
 
Index: kernel/arch/ppc32/src/ppc32.c
===================================================================
--- kernel/arch/ppc32/src/ppc32.c	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/arch/ppc32/src/ppc32.c	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -33,4 +33,5 @@
  */
 
+#include <config.h>
 #include <arch.h>
 #include <arch/boot/boot.h>
Index: kernel/arch/ppc64/_link.ld.in
===================================================================
--- kernel/arch/ppc64/_link.ld.in	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/arch/ppc64/_link.ld.in	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -10,5 +10,4 @@
  */
 
-#define __ASM__
 #include <arch/boot/boot.h>
 #include <arch/mm/page.h>
Index: kernel/arch/ppc64/include/cpu.h
===================================================================
--- kernel/arch/ppc64/include/cpu.h	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/arch/ppc64/include/cpu.h	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -36,5 +36,5 @@
 #define KERN_ppc64_CPU_H_
 
-#include <typedefs.h>
+#include <arch/asm.h>
 
 typedef struct {
Index: kernel/arch/ppc64/include/drivers/pic.h
===================================================================
--- kernel/arch/ppc64/include/drivers/pic.h	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/arch/ppc64/include/drivers/pic.h	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -36,4 +36,6 @@
 #define KERN_ppc64_PIC_H_
 
+#include <arch/types.h>
+
 #define PIC_PENDING_LOW    8
 #define PIC_PENDING_HIGH   4
Index: kernel/arch/ppc64/include/exception.h
===================================================================
--- kernel/arch/ppc64/include/exception.h	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/arch/ppc64/include/exception.h	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -37,7 +37,6 @@
 
 #include <arch/types.h>
-#include <typedefs.h>
 
-struct istate {
+typedef struct {
 	uint64_t r0;
 	uint64_t r2;
@@ -78,5 +77,5 @@
 	uint64_t r12;
 	uint64_t sp;
-};
+} istate_t;
 
 static inline void istate_set_retaddr(istate_t *istate, uintptr_t retaddr)
Index: kernel/arch/ppc64/include/mm/as.h
===================================================================
--- kernel/arch/ppc64/include/mm/as.h	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/arch/ppc64/include/mm/as.h	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -43,8 +43,10 @@
 #define USER_ADDRESS_SPACE_END_ARCH		((unsigned long) 0x7fffffff)
 
-#define USTACK_ADDRESS_ARCH	(0x7fffffff-(PAGE_SIZE-1))
+#define USTACK_ADDRESS_ARCH	(0x7fffffff - (PAGE_SIZE - 1))
 
 typedef struct {
 } as_arch_t;
+
+#include <genarch/mm/as_pt.h>
 
 #define as_constructor_arch(as, flags)		(as != as)
Index: kernel/arch/ppc64/include/mm/memory_init.h
===================================================================
--- kernel/arch/ppc64/include/mm/memory_init.h	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/arch/ppc64/include/mm/memory_init.h	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -36,6 +36,4 @@
 #define KERN_ppc64_MEMORY_INIT_H_
 
-#include <typedefs.h>
-
 size_t get_memory_size(void);
 
Index: kernel/arch/ppc64/include/mm/page.h
===================================================================
--- kernel/arch/ppc64/include/mm/page.h	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/arch/ppc64/include/mm/page.h	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -105,7 +105,6 @@
 #ifndef __ASM__
 
-#include <mm/page.h>
-#include <arch/mm/frame.h>
-#include <arch/types.h>
+#include <mm/mm.h>
+#include <arch/interrupt.h>
 
 static inline int get_pt_flags(pte_t *pt, index_t i)
Index: kernel/arch/ppc64/include/types.h
===================================================================
--- kernel/arch/ppc64/include/types.h	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/arch/ppc64/include/types.h	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -37,4 +37,6 @@
 
 #define NULL 0
+#define false 0
+#define true 1
 
 typedef signed char int8_t;
@@ -48,4 +50,8 @@
 typedef unsigned long uint64_t;
 
+typedef uint64_t size_t;
+typedef uint64_t count_t;
+typedef uint64_t index_t;
+
 typedef uint64_t uintptr_t;
 typedef uint64_t pfn_t;
@@ -54,4 +60,12 @@
 
 typedef uint64_t unative_t;
+typedef int64_t native_t;
+
+typedef uint8_t bool;
+typedef uint64_t task_id_t;
+typedef uint32_t context_id_t;
+
+typedef int32_t inr_t;
+typedef int32_t devno_t;
 
 /** Page Table Entry. */
Index: kernel/arch/ppc64/src/cpu/cpu.c
===================================================================
--- kernel/arch/ppc64/src/cpu/cpu.c	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/arch/ppc64/src/cpu/cpu.c	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -36,8 +36,5 @@
 #include <arch/cpuid.h>
 #include <cpu.h>
-
 #include <arch.h>
-
-#include <typedefs.h>
 #include <print.h>
 
Index: kernel/arch/ppc64/src/ddi/ddi.c
===================================================================
--- kernel/arch/ppc64/src/ddi/ddi.c	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/arch/ppc64/src/ddi/ddi.c	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -36,5 +36,4 @@
 #include <proc/task.h>
 #include <arch/types.h>
-#include <typedefs.h>
 
 /** Enable I/O space range for task.
Index: kernel/arch/ppc64/src/drivers/pic.c
===================================================================
--- kernel/arch/ppc64/src/drivers/pic.c	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/arch/ppc64/src/drivers/pic.c	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -34,6 +34,6 @@
 
 
-#include <arch/asm.h>
 #include <arch/drivers/pic.h>
+#include <mm/page.h>
 #include <byteorder.h>
 #include <bitops.h>
Index: kernel/arch/ppc64/src/mm/as.c
===================================================================
--- kernel/arch/ppc64/src/mm/as.c	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/arch/ppc64/src/mm/as.c	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -34,5 +34,5 @@
 
 #include <arch/mm/as.h>
-#include <genarch/mm/as_pt.h>
+#include <genarch/mm/page_pt.h>
 
 /** Architecture dependent address space init. */
Index: kernel/arch/ppc64/src/mm/memory_init.c
===================================================================
--- kernel/arch/ppc64/src/mm/memory_init.c	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/arch/ppc64/src/mm/memory_init.c	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -35,5 +35,4 @@
 #include <arch/boot/boot.h>
 #include <arch/mm/memory_init.h>
-#include <typedefs.h>
 #include <print.h>
 
Index: kernel/arch/sparc64/_link.ld.in
===================================================================
--- kernel/arch/sparc64/_link.ld.in	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/arch/sparc64/_link.ld.in	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -7,5 +7,4 @@
  */
 
-#define __LINKER__
 #include <arch/boot/boot.h>
 
Index: kernel/arch/sparc64/include/asm.h
===================================================================
--- kernel/arch/sparc64/include/asm.h	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/arch/sparc64/include/asm.h	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -36,10 +36,9 @@
 #define KERN_sparc64_ASM_H_
 
-#include <arch.h>
-#include <typedefs.h>
+#include <arch/arch.h>
 #include <arch/types.h>
+#include <align.h>
 #include <arch/register.h>
 #include <config.h>
-#include <time/clock.h>
 #include <arch/stack.h>
 
Index: kernel/arch/sparc64/include/atomic.h
===================================================================
--- kernel/arch/sparc64/include/atomic.h	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/arch/sparc64/include/atomic.h	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -38,5 +38,4 @@
 #include <arch/barrier.h>
 #include <arch/types.h>
-#include <typedefs.h>
 
 /** Atomic add operation.
Index: kernel/arch/sparc64/include/boot/boot.h
===================================================================
--- kernel/arch/sparc64/include/boot/boot.h	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/arch/sparc64/include/boot/boot.h	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -44,5 +44,4 @@
 #include <config.h>
 #include <arch/types.h>
-#include <typedefs.h>
 #include <genarch/ofw/ofw_tree.h>
 
Index: kernel/arch/sparc64/include/cpu.h
===================================================================
--- kernel/arch/sparc64/include/cpu.h	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/arch/sparc64/include/cpu.h	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -38,4 +38,5 @@
 #include <arch/types.h>
 #include <arch/register.h>
+#include <arch/asm.h>
 
 #define MANUF_FUJITSU		0x04
Index: kernel/arch/sparc64/include/drivers/tick.h
===================================================================
--- kernel/arch/sparc64/include/drivers/tick.h	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/arch/sparc64/include/drivers/tick.h	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -36,5 +36,5 @@
 #define KERN_sparc64_TICK_H_
 
-#include <typedefs.h>
+#include <arch/interrupt.h>
 
 extern void tick_init(void);
Index: kernel/arch/sparc64/include/drivers/z8530.h
===================================================================
--- kernel/arch/sparc64/include/drivers/z8530.h	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/arch/sparc64/include/drivers/z8530.h	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -37,5 +37,4 @@
 
 #include <arch/types.h>
-#include <typedefs.h>
 #include <arch/drivers/kbd.h>
 
Index: kernel/arch/sparc64/include/interrupt.h
===================================================================
--- kernel/arch/sparc64/include/interrupt.h	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/arch/sparc64/include/interrupt.h	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -37,5 +37,4 @@
 #define KERN_sparc64_INTERRUPT_H_
 
-#include <typedefs.h>
 #include <arch/types.h>
 #include <arch/regdef.h>
@@ -51,9 +50,9 @@
 };		
 
-struct istate {
+typedef struct {
 	uint64_t	tnpc;
 	uint64_t	tpc;
 	uint64_t	tstate;
-};
+} istate_t;
 
 static inline void istate_set_retaddr(istate_t *istate, uintptr_t retaddr)
@@ -72,7 +71,4 @@
 }
 
-
-extern void interrupt_register(int n, const char *name, iroutine f);
-
 #endif
 
Index: kernel/arch/sparc64/include/mm/as.h
===================================================================
--- kernel/arch/sparc64/include/mm/as.h	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/arch/sparc64/include/mm/as.h	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -36,7 +36,5 @@
 #define KERN_sparc64_AS_H_
 
-#ifdef CONFIG_TSB
-#include <arch/mm/tsb.h>
-#endif
+#include <arch/mm/tte.h>
 
 #define KERNEL_ADDRESS_SPACE_SHADOWED_ARCH	1
@@ -47,14 +45,42 @@
 #define USER_ADDRESS_SPACE_END_ARCH		(unsigned long) 0xffffffffffffffff
 
-#define USTACK_ADDRESS_ARCH	(0xffffffffffffffffULL-(PAGE_SIZE-1))
+#define USTACK_ADDRESS_ARCH	(0xffffffffffffffffULL - (PAGE_SIZE - 1))
+
+#ifdef CONFIG_TSB
+
+/** TSB Tag Target register. */
+typedef union tsb_tag_target {
+	uint64_t value;
+	struct {
+		unsigned invalid : 1;	/**< Invalidated by software. */
+		unsigned : 2;
+		unsigned context : 13;	/**< Software ASID. */
+		unsigned : 6;
+		uint64_t va_tag : 42;	/**< Virtual address bits <63:22>. */
+	} __attribute__ ((packed));
+} tsb_tag_target_t;
+
+/** TSB entry. */
+typedef struct tsb_entry {
+	tsb_tag_target_t tag;
+	tte_data_t data;
+} __attribute__ ((packed)) tsb_entry_t;
 
 typedef struct {
-#ifdef CONFIG_TSB
 	tsb_entry_t *itsb;
 	tsb_entry_t *dtsb;
-#endif /* CONFIG_TSB */
 } as_arch_t;
 
+#else
+
+typedef struct {
+} as_arch_t;
+
+#endif /* CONFIG_TSB */
+
+#include <genarch/mm/as_ht.h>
+
 #ifdef CONFIG_TSB
+#	include <arch/mm/tsb.h>
 #	define as_invalidate_translation_cache(as, page, cnt)	tsb_invalidate(as, page, cnt)
 #else
Index: kernel/arch/sparc64/include/mm/memory_init.h
===================================================================
--- kernel/arch/sparc64/include/mm/memory_init.h	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/arch/sparc64/include/mm/memory_init.h	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -36,5 +36,5 @@
 #define KERN_sparc64_MEMORY_INIT_H_
 
-#include <typedefs.h>
+#include <arch/types.h>
 
 extern size_t get_memory_size(void);
Index: kernel/arch/sparc64/include/mm/mmu.h
===================================================================
--- kernel/arch/sparc64/include/mm/mmu.h	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/arch/sparc64/include/mm/mmu.h	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -80,8 +80,7 @@
 #include <arch/barrier.h>
 #include <arch/types.h>
-#include <typedefs.h>
 
 /** LSU Control Register. */
-union lsu_cr_reg {
+typedef union {
 	uint64_t value;
 	struct {
@@ -101,6 +100,5 @@
 		
 	} __attribute__ ((packed));
-};
-typedef union lsu_cr_reg lsu_cr_reg_t;
+} lsu_cr_reg_t;
 
 #endif /* !def __ASM__ */
Index: kernel/arch/sparc64/include/mm/page.h
===================================================================
--- kernel/arch/sparc64/include/mm/page.h	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/arch/sparc64/include/mm/page.h	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -47,7 +47,7 @@
 #ifndef __ASM__
 
-#include <mm/page.h>
-#include <arch/types.h>
-#include <genarch/mm/page_ht.h>
+//#include <arch/types.h>
+//#include <genarch/mm/page_ht.h>
+#include <arch/interrupt.h>
 
 extern uintptr_t physmem_base;
@@ -56,5 +56,5 @@
 #define PA2KA(x)	(((uintptr_t) (x)) - physmem_base)
 
-union page_address {
+typedef union {
 	uintptr_t address;
 	struct {
@@ -62,7 +62,5 @@
 		unsigned offset : 13;		/**< Offset. */
 	} __attribute__ ((packed));
-};
-
-typedef union page_address page_address_t;
+} page_address_t;
 
 extern void page_arch_init(void);
Index: kernel/arch/sparc64/include/mm/tlb.h
===================================================================
--- kernel/arch/sparc64/include/mm/tlb.h	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/arch/sparc64/include/mm/tlb.h	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -77,5 +77,4 @@
 #include <arch/barrier.h>
 #include <arch/types.h>
-#include <typedefs.h>
 
 union tlb_context_reg {
Index: kernel/arch/sparc64/include/mm/tsb.h
===================================================================
--- kernel/arch/sparc64/include/mm/tsb.h	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/arch/sparc64/include/mm/tsb.h	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -55,28 +55,8 @@
 #include <arch/mm/mmu.h>
 #include <arch/types.h>
-#include <typedefs.h>
-
-/** TSB Tag Target register. */
-union tsb_tag_target {
-	uint64_t value;
-	struct {
-		unsigned invalid : 1;	/**< Invalidated by software. */
-		unsigned : 2;
-		unsigned context : 13;	/**< Software ASID. */
-		unsigned : 6;
-		uint64_t va_tag : 42;	/**< Virtual address bits <63:22>. */
-	} __attribute__ ((packed));
-};
-typedef union tsb_tag_target tsb_tag_target_t;
-
-/** TSB entry. */
-struct tsb_entry {
-	tsb_tag_target_t tag;
-	tte_data_t data;
-} __attribute__ ((packed));
-typedef struct tsb_entry tsb_entry_t;
+#include <mm/as.h>
 
 /** TSB Base register. */
-union tsb_base_reg {
+typedef union tsb_base_reg {
 	uint64_t value;
 	struct {
@@ -91,6 +71,5 @@
 					 * 512 * 2^size. */
 	} __attribute__ ((packed));
-};
-typedef union tsb_base_reg tsb_base_reg_t;
+} tsb_base_reg_t;
 
 /** Read ITSB Base register.
Index: kernel/arch/sparc64/include/sparc64.h
===================================================================
--- kernel/arch/sparc64/include/sparc64.h	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
+++ kernel/arch/sparc64/include/sparc64.h	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2005 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 sparc64
+ * @{
+ */
+/** @file
+ */
+
+#ifndef KERN_sparc64_SPARC64_H_
+#define KERN_sparc64_SPARC64_H_
+
+#include <interrupt.h>
+
+extern void interrupt_register(int n, const char *name, iroutine f);
+
+#endif
+
+/** @}
+ */
Index: kernel/arch/sparc64/include/syscall.h
===================================================================
--- kernel/arch/sparc64/include/syscall.h	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/arch/sparc64/include/syscall.h	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -36,6 +36,6 @@
 #define KERN_sparc64_SYSCALL_H_
 
-#include <typedefs.h>
 #include <arch/types.h>
+#include <arch/interrupt.h>
 
 extern unative_t syscall(int n, istate_t *istate, unative_t a1, unative_t a2, unative_t a3, unative_t a4);
Index: kernel/arch/sparc64/include/trap/exception.h
===================================================================
--- kernel/arch/sparc64/include/trap/exception.h	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/arch/sparc64/include/trap/exception.h	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -59,5 +59,5 @@
 #ifndef __ASM__
 
-#include <typedefs.h>
+#include <arch/interrupt.h>
 
 extern void dump_istate(istate_t *istate);
Index: kernel/arch/sparc64/include/trap/interrupt.h
===================================================================
--- kernel/arch/sparc64/include/trap/interrupt.h	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/arch/sparc64/include/trap/interrupt.h	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -106,4 +106,7 @@
 
 #ifndef __ASM__
+
+#include <arch/interrupt.h>
+
 extern void interrupt(int n, istate_t *istate);
 #endif /* !def __ASM__ */
Index: kernel/arch/sparc64/include/types.h
===================================================================
--- kernel/arch/sparc64/include/types.h	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/arch/sparc64/include/types.h	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -36,5 +36,7 @@
 #define KERN_sparc64_TYPES_H_
 
-#define NULL	0
+#define NULL 0
+#define false 0
+#define true 1
 
 typedef signed char int8_t;
@@ -48,4 +50,8 @@
 typedef unsigned long uint64_t;
 
+typedef uint64_t size_t;
+typedef uint64_t count_t;
+typedef uint64_t index_t;
+
 typedef uint64_t uintptr_t;
 typedef uint64_t pfn_t;
@@ -56,6 +62,10 @@
 typedef int64_t native_t;
 
-typedef struct pte pte_t;
+typedef uint8_t bool;
+typedef uint64_t task_id_t;
+typedef uint32_t context_id_t;
 
+typedef int32_t inr_t;
+typedef int32_t devno_t;
 typedef uint8_t asi_t;
 
Index: kernel/arch/sparc64/src/console.c
===================================================================
--- kernel/arch/sparc64/src/console.c	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/arch/sparc64/src/console.c	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -35,5 +35,4 @@
 #include <arch/console.h>
 #include <arch/types.h>
-#include <typedefs.h>
 
 #include <arch/drivers/scr.h>
Index: kernel/arch/sparc64/src/cpu/cpu.c
===================================================================
--- kernel/arch/sparc64/src/cpu/cpu.c	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/arch/sparc64/src/cpu/cpu.c	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -33,12 +33,9 @@
  */
 
-#include <arch/asm.h>
 #include <cpu.h>
 #include <arch.h>
+#include <genarch/ofw/ofw_tree.h>
+#include <arch/drivers/tick.h>
 #include <print.h>
-#include <arch/register.h>
-#include <genarch/ofw/ofw_tree.h>
-#include <arch/types.h>
-#include <arch/drivers/tick.h>
 
 /** Perform sparc64 specific initialization of the processor structure for the
Index: kernel/arch/sparc64/src/ddi/ddi.c
===================================================================
--- kernel/arch/sparc64/src/ddi/ddi.c	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/arch/sparc64/src/ddi/ddi.c	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -36,5 +36,4 @@
 #include <proc/task.h>
 #include <arch/types.h>
-#include <typedefs.h>
 
 /** Enable I/O space range for task.
Index: kernel/arch/sparc64/src/drivers/fhc.c
===================================================================
--- kernel/arch/sparc64/src/drivers/fhc.c	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/arch/sparc64/src/drivers/fhc.c	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -42,8 +42,7 @@
 #include <arch/drivers/fhc.h>
 #include <arch/trap/interrupt.h>
-#include <arch/mm/page.h>
+#include <mm/page.h>
 #include <mm/slab.h>
 #include <arch/types.h>
-#include <typedefs.h>
 #include <genarch/ofw/ofw_tree.h>
 
Index: kernel/arch/sparc64/src/drivers/kbd.c
===================================================================
--- kernel/arch/sparc64/src/drivers/kbd.c	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/arch/sparc64/src/drivers/kbd.c	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -45,5 +45,4 @@
 #include <arch/mm/page.h>
 #include <arch/types.h>
-#include <typedefs.h>
 #include <align.h>
 #include <func.h>
Index: kernel/arch/sparc64/src/drivers/pci.c
===================================================================
--- kernel/arch/sparc64/src/drivers/pci.c	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/arch/sparc64/src/drivers/pci.c	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -38,8 +38,7 @@
 #include <genarch/ofw/ofw_tree.h>
 #include <arch/trap/interrupt.h>
-#include <arch/mm/page.h>
+#include <mm/page.h>
 #include <mm/slab.h>
 #include <arch/types.h>
-#include <typedefs.h>
 #include <debug.h>
 #include <print.h>
Index: kernel/arch/sparc64/src/drivers/scr.c
===================================================================
--- kernel/arch/sparc64/src/drivers/scr.c	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/arch/sparc64/src/drivers/scr.c	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -38,5 +38,4 @@
 #include <genarch/fb/visuals.h>
 #include <arch/types.h>
-#include <typedefs.h>
 #include <func.h>
 #include <align.h>
Index: kernel/arch/sparc64/src/drivers/tick.c
===================================================================
--- kernel/arch/sparc64/src/drivers/tick.c	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/arch/sparc64/src/drivers/tick.c	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -35,7 +35,7 @@
 #include <arch/drivers/tick.h>
 #include <arch/interrupt.h>
+#include <arch/sparc64.h>
 #include <arch/asm.h>
 #include <arch/register.h>
-#include <typedefs.h>
 #include <arch/cpu.h>
 #include <arch/boot/boot.h>
Index: kernel/arch/sparc64/src/mm/as.c
===================================================================
--- kernel/arch/sparc64/src/mm/as.c	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/arch/sparc64/src/mm/as.c	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -35,5 +35,5 @@
 #include <arch/mm/as.h>
 #include <arch/mm/tlb.h>
-#include <genarch/mm/as_ht.h>
+#include <genarch/mm/page_ht.h>
 #include <genarch/mm/asid_fifo.h>
 #include <debug.h>
Index: kernel/arch/sparc64/src/mm/memory_init.c
===================================================================
--- kernel/arch/sparc64/src/mm/memory_init.c	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/arch/sparc64/src/mm/memory_init.c	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -35,5 +35,4 @@
 #include <arch/mm/memory_init.h>
 #include <arch/boot/boot.h>
-#include <typedefs.h>
 
 /** Return total size of available memory in bytes.
Index: kernel/arch/sparc64/src/mm/tlb.c
===================================================================
--- kernel/arch/sparc64/src/mm/tlb.c	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/arch/sparc64/src/mm/tlb.c	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -45,5 +45,4 @@
 #include <print.h>
 #include <arch/types.h>
-#include <typedefs.h>
 #include <config.h>
 #include <arch/trap/trap.h>
Index: kernel/arch/sparc64/src/mm/tsb.c
===================================================================
--- kernel/arch/sparc64/src/mm/tsb.c	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/arch/sparc64/src/mm/tsb.c	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -38,5 +38,4 @@
 #include <mm/as.h>
 #include <arch/types.h>
-#include <typedefs.h>
 #include <macros.h>
 #include <debug.h>
Index: kernel/arch/sparc64/src/smp/ipi.c
===================================================================
--- kernel/arch/sparc64/src/smp/ipi.c	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/arch/sparc64/src/smp/ipi.c	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -35,4 +35,5 @@
 #include <smp/ipi.h>
 #include <cpu.h>
+#include <arch.h>
 #include <arch/cpu.h>
 #include <arch/asm.h>
Index: kernel/arch/sparc64/src/smp/smp.c
===================================================================
--- kernel/arch/sparc64/src/smp/smp.c	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/arch/sparc64/src/smp/smp.c	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -43,5 +43,4 @@
 #include <synch/synch.h>
 #include <synch/waitq.h>
-#include <typedefs.h>
 #include <print.h>
 
Index: kernel/arch/sparc64/src/trap/exception.c
===================================================================
--- kernel/arch/sparc64/src/trap/exception.c	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/arch/sparc64/src/trap/exception.c	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -41,5 +41,4 @@
 #include <arch/register.h>
 #include <debug.h>
-#include <typedefs.h>
 #include <symtab.h>
 #include <print.h>
Index: kernel/arch/sparc64/src/trap/interrupt.c
===================================================================
--- kernel/arch/sparc64/src/trap/interrupt.c	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/arch/sparc64/src/trap/interrupt.c	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -34,8 +34,8 @@
 
 #include <arch/interrupt.h>
+#include <arch/sparc64.h>
 #include <arch/trap/interrupt.h>
 #include <interrupt.h>
 #include <ddi/irq.h>
-#include <typedefs.h>
 #include <arch/types.h>
 #include <debug.h>
Index: kernel/arch/sparc64/src/trap/syscall.c
===================================================================
--- kernel/arch/sparc64/src/trap/syscall.c	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/arch/sparc64/src/trap/syscall.c	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -39,5 +39,4 @@
 #include <panic.h>
 #include <arch/types.h>
-#include <typedefs.h>
 
 unative_t syscall(int n, istate_t *istate, unative_t a1, unative_t a2, unative_t a3, unative_t a4)
Index: kernel/arch/sparc64/src/trap/trap.c
===================================================================
--- kernel/arch/sparc64/src/trap/trap.c	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/arch/sparc64/src/trap/trap.c	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -44,5 +44,4 @@
 #include <debug.h>
 #include <arch/types.h>
-#include <typedefs.h>
 #include <arch/drivers/tick.h>
 
Index: kernel/genarch/include/kbd/i8042.h
===================================================================
--- kernel/genarch/include/kbd/i8042.h	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ 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 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ 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 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ 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 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ 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 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ 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 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ 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 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ 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 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ 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 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ 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 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ 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 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ 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 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ 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 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ 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 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ 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 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ 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 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ 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 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ 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 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ 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 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ 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 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ 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>
Index: kernel/generic/include/adt/bitmap.h
===================================================================
--- kernel/generic/include/adt/bitmap.h	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/generic/include/adt/bitmap.h	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -37,5 +37,4 @@
 
 #include <arch/types.h>
-#include <typedefs.h>
 
 #define BITS2BYTES(bits)	(bits ? ((((bits)-1)>>3)+1) : 0)
Index: kernel/generic/include/adt/btree.h
===================================================================
--- kernel/generic/include/adt/btree.h	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/generic/include/adt/btree.h	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -37,5 +37,4 @@
 
 #include <arch/types.h>
-#include <typedefs.h>
 #include <adt/list.h>
 
@@ -46,5 +45,5 @@
 
 /** B-tree node structure. */
-struct btree_node {
+typedef struct btree_node {
 	/** Number of keys. */
 	count_t keys;
@@ -66,8 +65,8 @@
 	 * There is room for storing a subtree pointer for the extra key.
 	 */
-	btree_node_t *subtree[BTREE_M + 1];
+	struct btree_node *subtree[BTREE_M + 1];
 
 	/** Pointer to parent node. Root node has NULL parent. */
-	btree_node_t *parent;
+	struct btree_node *parent;
 
 	/** Link connecting leaf-level nodes. Defined only when this node is a leaf. */
@@ -77,11 +76,11 @@
 	link_t bfs_link;
 	int depth;
-};
+} btree_node_t;
 
 /** B-tree structure. */
-struct btree {
+typedef struct {
 	btree_node_t *root;	/**< B-tree root node pointer. */
 	link_t leaf_head;	/**< Leaf-level list head. */
-};
+} btree_t;
 
 extern void btree_init(void);
Index: kernel/generic/include/adt/fifo.h
===================================================================
--- kernel/generic/include/adt/fifo.h	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/generic/include/adt/fifo.h	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -46,5 +46,4 @@
 #define KERN_FIFO_H_
 
-#include <typedefs.h>
 #include <mm/slab.h>
 
Index: kernel/generic/include/adt/hash_table.h
===================================================================
--- kernel/generic/include/adt/hash_table.h	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/generic/include/adt/hash_table.h	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -38,16 +38,7 @@
 #include <adt/list.h>
 #include <arch/types.h>
-#include <typedefs.h>
-
-/** Hash table structure. */
-struct hash_table {
-	link_t *entry;
-	count_t entries;
-	count_t max_keys;
-	hash_table_operations_t *op;
-};
 
 /** Set of operations for hash table. */
-struct hash_table_operations {
+typedef struct {
 	/** Hash function.
 	 *
@@ -71,5 +62,13 @@
 	 */
 	void (*remove_callback)(link_t *item);
-};
+} hash_table_operations_t;
+
+/** Hash table structure. */
+typedef struct {
+	link_t *entry;
+	count_t entries;
+	count_t max_keys;
+	hash_table_operations_t *op;
+} hash_table_t;
 
 #define hash_table_get_instance(item, type, member)	list_get_instance((item), type, member)
Index: kernel/generic/include/adt/list.h
===================================================================
--- kernel/generic/include/adt/list.h	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/generic/include/adt/list.h	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -37,11 +37,10 @@
 
 #include <arch/types.h>
-#include <typedefs.h>
 
 /** Doubly linked list head and link type. */
-struct link {
-	link_t *prev;	/**< Pointer to the previous item in the list. */
-	link_t *next;	/**< Pointer to the next item in the list. */
-};
+typedef struct link {
+	struct link *prev;	/**< Pointer to the previous item in the list. */
+	struct link *next;	/**< Pointer to the next item in the list. */
+} link_t;
 
 /** Declare and initialize statically allocated list.
Index: kernel/generic/include/arch.h
===================================================================
--- kernel/generic/include/arch.h	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/generic/include/arch.h	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -36,11 +36,6 @@
 #define KERN_ARCH_H_
 
-#include <arch/types.h>
 #include <arch/arch.h>
-#include <typedefs.h>
-
-#include <cpu.h>
-#include <arch/cpu.h>
-#include <arch/asm.h> 
+#include <proc/task.h>
 
 #define DEFAULT_CONTEXT		0
Index: kernel/generic/include/bitops.h
===================================================================
--- kernel/generic/include/bitops.h	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/generic/include/bitops.h	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -35,6 +35,4 @@
 #ifndef KERN_BITOPS_H_
 #define KERN_BITOPS_H_
-
-#include <typedefs.h>
 
 
Index: kernel/generic/include/config.h
===================================================================
--- kernel/generic/include/config.h	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/generic/include/config.h	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -37,5 +37,4 @@
 
 #include <arch/types.h>
-#include <typedefs.h>
 #include <arch/mm/page.h>
 
Index: kernel/generic/include/console/chardev.h
===================================================================
--- kernel/generic/include/console/chardev.h	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/generic/include/console/chardev.h	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -36,5 +36,4 @@
 #define KERN_CHARDEV_H_
 
-#include <typedefs.h>
 #include <arch/types.h>
 #include <synch/waitq.h>
@@ -43,17 +42,17 @@
 #define CHARDEV_BUFLEN 512
 
+struct chardev;
+
 /* Character device operations interface. */
-struct chardev_operations {
-	void (* suspend)(chardev_t *);		/**< Suspend pushing characters. */
-	void (* resume)(chardev_t *); 		/**< Resume pushing characters. */
-	void (* write)(chardev_t *, char c);	/**< Write character to stream. */
+typedef struct {
+	void (* suspend)(struct chardev *);		/**< Suspend pushing characters. */
+	void (* resume)(struct chardev *); 		/**< Resume pushing characters. */
+	void (* write)(struct chardev *, char c);	/**< Write character to stream. */
 	/** Read character directly from device, assume interrupts disabled */
-	char (* read)(chardev_t *); 
-};
-
-typedef struct chardev_operations chardev_operations_t;
+	char (* read)(struct chardev *); 
+} chardev_operations_t;
 
 /** Character input device. */
-struct chardev {
+typedef struct chardev {
 	char *name;
 	
@@ -65,5 +64,5 @@
 	index_t index;
 	void *data;
-};
+} chardev_t;
 
 extern void chardev_initialize(char *name,
Index: kernel/generic/include/console/cmd.h
===================================================================
--- kernel/generic/include/console/cmd.h	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/generic/include/console/cmd.h	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -36,5 +36,5 @@
 #define KERN_CMD_H_
 
-#include <typedefs.h>
+#include <console/kconsole.h>
 
 extern void cmd_initialize(cmd_info_t *cmd);
Index: kernel/generic/include/console/console.h
===================================================================
--- kernel/generic/include/console/console.h	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/generic/include/console/console.h	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -37,5 +37,5 @@
 
 #include <arch/types.h>
-#include <typedefs.h>
+#include <console/chardev.h>
 
 extern chardev_t *stdin;
Index: kernel/generic/include/console/kconsole.h
===================================================================
--- kernel/generic/include/console/kconsole.h	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/generic/include/console/kconsole.h	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -36,5 +36,4 @@
 #define KERN_KCONSOLE_H_
 
-#include <typedefs.h>
 #include <adt/list.h>
 #include <synch/spinlock.h>
@@ -43,13 +42,13 @@
 #define KCONSOLE_HISTORY 10
 
-enum cmd_arg_type {
+typedef enum {
 	ARG_TYPE_INVALID = 0,
 	ARG_TYPE_INT,
 	ARG_TYPE_STRING,
 	ARG_TYPE_VAR      /**< Variable type - either symbol or string */
-};
+} cmd_arg_type_t;
 
 /** Structure representing one argument of kconsole command line. */
-struct cmd_arg {
+typedef struct {
 	cmd_arg_type_t type;		/**< Type descriptor. */
 	void *buffer;			/**< Buffer where to store data. */
@@ -57,8 +56,8 @@
 	unative_t intval;                /**< Integer value */
 	cmd_arg_type_t vartype;         /**< Resulting type of variable arg */
-};
+} cmd_arg_t;
 
 /** Structure representing one kconsole command. */
-struct cmd_info {
+typedef struct {
 	link_t link;			/**< Command list link. */
 	SPINLOCK_DECLARE(lock);		/**< This lock protects everything below. */
@@ -69,5 +68,5 @@
 	cmd_arg_t *argv;		/**< Argument vector. */
 	void (* help)(void);		/**< Function for printing detailed help. */
-};
+} cmd_info_t;
 
 extern spinlock_t cmd_lock;
Index: kernel/generic/include/context.h
===================================================================
--- kernel/generic/include/context.h	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/generic/include/context.h	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -37,5 +37,4 @@
 
 #include <arch/types.h>
-#include <typedefs.h>
 #include <arch/context.h>
 
Index: kernel/generic/include/cpu.h
===================================================================
--- kernel/generic/include/cpu.h	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/generic/include/cpu.h	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -36,61 +36,7 @@
 #define KERN_CPU_H_
 
-#include <arch/cpu.h>
-#include <proc/scheduler.h>
-#include <synch/spinlock.h>
-#include <synch/waitq.h>
-#include <arch/types.h>
-#include <typedefs.h>
-#include <arch/context.h>
-#include <config.h>
-#include <adt/list.h>
-#include <mm/tlb.h>
+#include <proc/thread.h>
 
 #define CPU_STACK_SIZE	STACK_SIZE
-
-/** CPU structure.
- *
- * There is one structure like this for every processor.
- */
-typedef struct {
-	SPINLOCK_DECLARE(lock);
-
-	tlb_shootdown_msg_t tlb_messages[TLB_MESSAGE_QUEUE_LEN];
-	count_t tlb_messages_count;
-	
-	context_t saved_context;
-
-	atomic_t nrdy;
-	runq_t rq[RQ_COUNT];
-	volatile count_t needs_relink;
-
-	SPINLOCK_DECLARE(timeoutlock);
-	link_t timeout_active_head;
-
-	count_t missed_clock_ticks;	/**< When system clock loses a tick, it is recorded here
-					     so that clock() can react. This variable is
-					     CPU-local and can be only accessed when interrupts
-					     are disabled. */
-
-	/**
-	 * Processor ID assigned by kernel.
-	 */
-	int id;
-	
-	int active;
-	int tlb_active;
-
-	uint16_t frequency_mhz;
-	uint32_t delay_loop_const;
-
-	cpu_arch_t arch;
-
-	thread_t *fpu_owner;
-	
-	/**
-	 * Stack used by scheduler when there is no running thread.
-	 */
-	uint8_t *stack;
-} cpu_t;
 
 extern cpu_t *cpus;
Index: kernel/generic/include/ddi/ddi.h
===================================================================
--- kernel/generic/include/ddi/ddi.h	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/generic/include/ddi/ddi.h	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -38,5 +38,5 @@
 #include <ddi/ddi_arg.h>
 #include <arch/types.h>
-#include <typedefs.h>
+#include <proc/task.h>
 
 /** Structure representing contiguous physical memory area. */
Index: kernel/generic/include/ddi/device.h
===================================================================
--- kernel/generic/include/ddi/device.h	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/generic/include/ddi/device.h	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -36,6 +36,4 @@
 #define KERN_DEVICE_H_
 
-#include <typedefs.h>
-
 extern devno_t device_assign_devno(void);
 
Index: kernel/generic/include/ddi/irq.h
===================================================================
--- kernel/generic/include/ddi/irq.h	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/generic/include/ddi/irq.h	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -36,9 +36,38 @@
 #define KERN_IRQ_H_
 
+typedef enum {
+	CMD_MEM_READ_1 = 0,
+	CMD_MEM_READ_2,
+	CMD_MEM_READ_4,
+	CMD_MEM_READ_8,
+	CMD_MEM_WRITE_1,
+	CMD_MEM_WRITE_2,
+	CMD_MEM_WRITE_4,
+	CMD_MEM_WRITE_8,
+	CMD_PORT_READ_1,
+	CMD_PORT_WRITE_1,
+	CMD_IA64_GETCHAR,
+	CMD_PPC32_GETCHAR,
+	CMD_LAST
+} irq_cmd_type;
+
+typedef struct {
+	irq_cmd_type cmd;
+	void *addr;
+	unsigned long long value; 
+	int dstarg;
+} irq_cmd_t;
+
+typedef struct {
+	unsigned int cmdcount;
+	irq_cmd_t *cmds;
+} irq_code_t;
+
+#ifdef KERNEL
+
 #include <arch/types.h>
-#include <typedefs.h>
 #include <adt/list.h>
-#include <ipc/irq.h>
 #include <synch/spinlock.h>
+#include <proc/task.h>
 
 typedef enum {
@@ -52,5 +81,24 @@
 } irq_trigger_t;
 
-typedef void (* irq_handler_t)(irq_t *irq, void *arg, ...);
+struct irq;
+typedef void (* irq_handler_t)(struct irq *irq, void *arg, ...);
+
+
+
+/** IPC notification config structure.
+ *
+ * Primarily, this structure is encapsulated in the irq_t structure.
+ * It is protected by irq_t::lock.
+ */
+typedef struct {
+	bool notify;			/**< When false, notifications are not sent. */
+	answerbox_t *answerbox;		/**< Answerbox for notifications. */
+	unative_t method;		/**< Method to be used for the notification. */
+	irq_code_t *code;		/**< Top-half pseudocode. */
+	count_t counter;		/**< Counter. */
+	link_t link;			/**< Link between IRQs that are notifying the
+					     same answerbox. The list is protected by
+					     the answerbox irq_lock. */
+} ipc_notif_cfg_t;
 
 /** Structure representing one device IRQ.
@@ -60,5 +108,5 @@
  * devno.
  */
-struct irq {
+typedef struct irq {
 	/** Hash table link. */
 	link_t link;
@@ -87,5 +135,5 @@
 	/** Notification configuration structure. */
 	ipc_notif_cfg_t notif_cfg; 
-};
+} irq_t;
 
 extern void irq_init(count_t inrs, count_t chains);
@@ -97,4 +145,6 @@
 #endif
 
+#endif
+
 /** @}
  */
Index: kernel/generic/include/debug.h
===================================================================
--- kernel/generic/include/debug.h	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/generic/include/debug.h	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -43,5 +43,5 @@
 #ifndef HERE
 /** Current Instruction Pointer address */
-#  define HERE ((uintptr_t *)0)
+#  define HERE ((uintptr_t *) 0)
 #endif
 
Index: kernel/generic/include/fpu_context.h
===================================================================
--- kernel/generic/include/fpu_context.h	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/generic/include/fpu_context.h	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -37,5 +37,4 @@
 
 #include <arch/fpu_context.h>
-#include <typedefs.h>
 
 #if defined(CONFIG_FPU_LAZY) && !defined(ARCH_HAS_FPU)
Index: kernel/generic/include/func.h
===================================================================
--- kernel/generic/include/func.h	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/generic/include/func.h	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -37,5 +37,4 @@
 
 #include <arch/types.h>
-#include <typedefs.h>
 #include <atomic.h>
 
Index: kernel/generic/include/interrupt.h
===================================================================
--- kernel/generic/include/interrupt.h	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/generic/include/interrupt.h	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -37,5 +37,4 @@
 
 #include <arch/interrupt.h>
-#include <typedefs.h>
 #include <arch/types.h>
 #include <proc/task.h>
@@ -43,5 +42,7 @@
 #include <arch.h>
 #include <console/klog.h>
-#include <ipc/irq.h>
+#include <ddi/irq.h>
+
+typedef void (* iroutine)(int n, istate_t *istate);
 
 #define fault_if_from_uspace(istate, cmd, ...) \
@@ -55,5 +56,4 @@
 }
 
-
 extern iroutine exc_register(int n, const char *name, iroutine f);
 extern void exc_dispatch(int n, istate_t *t);
Index: kernel/generic/include/ipc/ipc.h
===================================================================
--- kernel/generic/include/ipc/ipc.h	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/generic/include/ipc/ipc.h	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -159,50 +159,10 @@
 #ifdef KERNEL
 
-#include <synch/waitq.h>
-#include <adt/list.h>
-
-#define IPC_MAX_PHONES  16
-
-typedef struct answerbox_s answerbox_t;
-typedef struct phone_s phone_t;
+#include <proc/task.h>
+
 typedef struct {
 	unative_t args[IPC_CALL_LEN];
 	phone_t *phone;
 } ipc_data_t;
-
-struct answerbox_s {
-	SPINLOCK_DECLARE(lock);
-
-	task_t *task;
-
-	waitq_t wq;
-
-	link_t connected_phones;	/**< Phones connected to this answerbox */
-	link_t calls;			/**< Received calls */
-	link_t dispatched_calls;	/* Should be hash table in the future */
-
-	link_t answers;			/**< Answered calls */
-
-	SPINLOCK_DECLARE(irq_lock);
-	link_t irq_notifs;       	/**< Notifications from IRQ handlers */
-	link_t irq_head;		/**< IRQs with notifications to this answerbox. */
-};
-
-typedef enum {
-	IPC_PHONE_FREE = 0,     /**< Phone is free and can be allocated */
-	IPC_PHONE_CONNECTING,   /**< Phone is connecting somewhere */
-	IPC_PHONE_CONNECTED,    /**< Phone is connected */
-	IPC_PHONE_HUNGUP,  	/**< Phone is hung up, waiting for answers to come */
-	IPC_PHONE_SLAMMED       /**< Phone was hungup from server */
-} ipc_phone_state_t;
-
-/** Structure identifying phone (in TASK structure) */
-struct phone_s {
-	SPINLOCK_DECLARE(lock);
-	link_t link;
-	answerbox_t *callee;
-	ipc_phone_state_t state;
-	atomic_t active_calls;
-};
 
 typedef struct {
Index: kernel/generic/include/ipc/irq.h
===================================================================
--- kernel/generic/include/ipc/irq.h	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/generic/include/ipc/irq.h	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -39,54 +39,8 @@
 #define IRQ_MAX_PROG_SIZE 10
 
-typedef enum {
-	CMD_MEM_READ_1 = 0,
-	CMD_MEM_READ_2,
-	CMD_MEM_READ_4,
-	CMD_MEM_READ_8,
-	CMD_MEM_WRITE_1,
-	CMD_MEM_WRITE_2,
-	CMD_MEM_WRITE_4,
-	CMD_MEM_WRITE_8,
-	CMD_PORT_READ_1,
-	CMD_PORT_WRITE_1,
-	CMD_IA64_GETCHAR,
-	CMD_PPC32_GETCHAR,
-	CMD_LAST
-} irq_cmd_type;
-
-typedef struct {
-	irq_cmd_type cmd;
-	void *addr;
-	unsigned long long value; 
-	int dstarg;
-} irq_cmd_t;
-
-typedef struct {
-	unsigned int cmdcount;
-	irq_cmd_t *cmds;
-} irq_code_t;
-
-#ifdef KERNEL
-
 #include <ipc/ipc.h>
-#include <typedefs.h>
+#include <ddi/irq.h>
 #include <arch/types.h>
 #include <adt/list.h>
-
-/** IPC notification config structure.
- *
- * Primarily, this structure is encapsulated in the irq_t structure.
- * It is protected by irq_t::lock.
- */
-struct ipc_notif_cfg {
-	bool notify;			/**< When false, notifications are not sent. */
-	answerbox_t *answerbox;		/**< Answerbox for notifications. */
-	unative_t method;		/**< Method to be used for the notification. */
-	irq_code_t *code;		/**< Top-half pseudocode. */
-	count_t counter;		/**< Counter. */
-	link_t link;			/**< Link between IRQs that are notifying the
-					     same answerbox. The list is protected by
-					     the answerbox irq_lock. */
-};
 
 extern int ipc_irq_register(answerbox_t *box, inr_t inr, devno_t devno, unative_t method,
@@ -99,6 +53,4 @@
 #endif
 
-#endif
-
 /** @}
  */
Index: kernel/generic/include/ipc/sysipc.h
===================================================================
--- kernel/generic/include/ipc/sysipc.h	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/generic/include/ipc/sysipc.h	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -39,5 +39,4 @@
 #include <ipc/irq.h>
 #include <arch/types.h>
-#include <typedefs.h>
 
 unative_t sys_ipc_call_sync_fast(unative_t phoneid, unative_t method, 
Index: kernel/generic/include/lib/elf.h
===================================================================
--- kernel/generic/include/lib/elf.h	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/generic/include/lib/elf.h	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -38,5 +38,4 @@
 #include <arch/elf.h>
 #include <arch/types.h>
-#include <typedefs.h>
 
 /**
@@ -336,5 +335,4 @@
 #endif
 
-extern int elf_load(elf_header_t *header, as_t * as);
 extern char *elf_error(int rc);
 
Index: kernel/generic/include/lib/rd.h
===================================================================
--- kernel/generic/include/lib/rd.h	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/generic/include/lib/rd.h	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -37,5 +37,4 @@
 
 #include <arch/types.h>
-#include <typedefs.h>
 
 /**
Index: kernel/generic/include/macros.h
===================================================================
--- kernel/generic/include/macros.h	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/generic/include/macros.h	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -37,5 +37,4 @@
 
 #include <arch/types.h>
-#include <typedefs.h>
 
 #define is_digit(d)	(((d) >= '0') && ((d) <= '9'))
Index: kernel/generic/include/main/main.h
===================================================================
--- kernel/generic/include/main/main.h	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/generic/include/main/main.h	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -36,6 +36,4 @@
 #define KERN_MAIN_H_
 
-#include <typedefs.h>
-
 extern uintptr_t stack_safe;
 
Index: kernel/generic/include/memstr.h
===================================================================
--- kernel/generic/include/memstr.h	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/generic/include/memstr.h	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -36,5 +36,4 @@
 #define KERN_MEMSTR_H_
 
-#include <typedefs.h>
 #include <arch/types.h>
 #include <arch/memstr.h>
Index: kernel/generic/include/mm/as.h
===================================================================
--- kernel/generic/include/mm/as.h	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/generic/include/mm/as.h	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -48,5 +48,4 @@
 #include <arch/mm/asid.h>
 #include <arch/types.h>
-#include <typedefs.h>
 #include <synch/spinlock.h>
 #include <synch/mutex.h>
@@ -67,52 +66,18 @@
 #define FLAG_AS_KERNEL	    (1 << 0)	/**< Kernel address space. */
 
-/** 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.
- */
-struct as {
-	/** 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. Constant on architectures that use global page hash table. */
-	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;
-};
-
-struct as_operations {
+/** Address space area attributes. */
+#define AS_AREA_ATTR_NONE	0
+#define AS_AREA_ATTR_PARTIAL	1	/**< Not fully initialized area. */
+
+#define AS_PF_FAULT		0	/**< The page fault was not resolved by as_page_fault(). */
+#define AS_PF_OK		1	/**< The page fault was resolved by as_page_fault(). */
+#define AS_PF_DEFER		2	/**< The page fault was caused by memcpy_from_uspace() or memcpy_to_uspace(). */
+
+typedef struct {
 	pte_t *(* page_table_create)(int flags);
 	void (* page_table_destroy)(pte_t *page_table);
 	void (* page_table_lock)(as_t *as, bool lock);
 	void (* page_table_unlock)(as_t *as, bool unlock);
-};
-typedef struct as_operations as_operations_t;
-
-/** Address space area attributes. */
-#define AS_AREA_ATTR_NONE	0
-#define AS_AREA_ATTR_PARTIAL	1	/**< Not fully initialized area. */
-
-#define AS_PF_FAULT		0	/**< The page fault was not resolved by as_page_fault(). */
-#define AS_PF_OK		1	/**< The page fault was resolved by as_page_fault(). */
-#define AS_PF_DEFER		2	/**< The page fault was caused by memcpy_from_uspace()
-					     or memcpy_to_uspace(). */
+} as_operations_t;
 
 /** This structure contains information associated with the shared address space area. */
@@ -123,13 +88,15 @@
 } share_info_t;
 
-/** Address space area backend structure. */
-typedef struct {
-	int (* page_fault)(as_area_t *area, uintptr_t addr, pf_access_t access);
-	void (* frame_free)(as_area_t *area, uintptr_t page, uintptr_t frame);
-	void (* share)(as_area_t *area);
-} mem_backend_t;
+/** Page fault access type. */
+typedef enum {
+	PF_ACCESS_READ,
+	PF_ACCESS_WRITE,
+	PF_ACCESS_EXEC
+} pf_access_t;
+
+struct mem_backend;
 
 /** Backend data stored in address space area. */
-typedef union {
+typedef union mem_backend_data {
 	struct {	/**< elf_backend members */
 		elf_header_t *elf;
@@ -147,5 +114,5 @@
  * In the future, it should not be difficult to support shared areas.
  */
-struct as_area {
+typedef struct {
 	mutex_t lock;
 	as_t *as;		/**< Containing address space. */
@@ -157,9 +124,16 @@
 	share_info_t *sh_info;	/**< If the address space area has been shared, this pointer will
 			     	     reference the share info structure. */
-	mem_backend_t *backend;	/**< Memory backend backing this address space area. */
+	struct mem_backend *backend;	/**< Memory backend backing this address space area. */
 
 	/** Data to be used by the backend. */
 	mem_backend_data_t backend_data;
-};
+} as_area_t;
+
+/** Address space area backend structure. */
+typedef struct mem_backend {
+	int (* page_fault)(as_area_t *area, uintptr_t addr, pf_access_t access);
+	void (* frame_free)(as_area_t *area, uintptr_t page, uintptr_t frame);
+	void (* share)(as_area_t *area);
+} mem_backend_t;
 
 extern as_t *AS_KERNEL;
@@ -207,8 +181,10 @@
 #endif /* !def as_deinstall_arch */
 
-/* Backend declarations. */
+/* Backend declarations and functions. */
 extern mem_backend_t anon_backend;
 extern mem_backend_t elf_backend;
 extern mem_backend_t phys_backend;
+
+extern int elf_load(elf_header_t *header, as_t *as);
 
 /* Address space area related syscalls. */
Index: kernel/generic/include/mm/asid.h
===================================================================
--- kernel/generic/include/mm/asid.h	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/generic/include/mm/asid.h	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -45,5 +45,6 @@
 #include <arch/mm/asid.h>
 #include <synch/spinlock.h>
-#include <typedefs.h>
+#include <adt/list.h>
+#include <mm/as.h>
 
 #endif
Index: kernel/generic/include/mm/buddy.h
===================================================================
--- kernel/generic/include/mm/buddy.h	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/generic/include/mm/buddy.h	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -37,5 +37,5 @@
 
 #include <arch/types.h>
-#include <typedefs.h>
+#include <adt/list.h>
 
 #define BUDDY_SYSTEM_INNER_BLOCK	0xff
Index: kernel/generic/include/mm/frame.h
===================================================================
--- kernel/generic/include/mm/frame.h	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/generic/include/mm/frame.h	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -38,5 +38,4 @@
 
 #include <arch/types.h>
-#include <typedefs.h>
 #include <adt/list.h>
 #include <synch/spinlock.h>
Index: kernel/generic/include/mm/mm.h
===================================================================
--- kernel/generic/include/mm/mm.h	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
+++ kernel/generic/include/mm/mm.h	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) 2007 Martin Decky
+ * 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 genericmm
+ * @{
+ */
+/** @file
+ */
+
+#ifndef KERN_MM_H_
+#define KERN_MM_H_
+
+#define PAGE_CACHEABLE_SHIFT		0
+#define PAGE_NOT_CACHEABLE_SHIFT	PAGE_CACHEABLE_SHIFT
+#define PAGE_PRESENT_SHIFT		1
+#define PAGE_NOT_PRESENT_SHIFT		PAGE_PRESENT_SHIFT
+#define PAGE_USER_SHIFT			2
+#define PAGE_KERNEL_SHIFT		PAGE_USER_SHIFT
+#define PAGE_READ_SHIFT			3
+#define PAGE_WRITE_SHIFT		4
+#define PAGE_EXEC_SHIFT			5
+#define PAGE_GLOBAL_SHIFT		6
+
+#define PAGE_NOT_CACHEABLE	(0 << PAGE_CACHEABLE_SHIFT)
+#define PAGE_CACHEABLE		(1 << PAGE_CACHEABLE_SHIFT)
+
+#define PAGE_PRESENT		(0 << PAGE_PRESENT_SHIFT)
+#define PAGE_NOT_PRESENT	(1 << PAGE_PRESENT_SHIFT)
+
+#define PAGE_USER		(1 << PAGE_USER_SHIFT)
+#define PAGE_KERNEL		(0 << PAGE_USER_SHIFT)
+
+#define PAGE_READ		(1 << PAGE_READ_SHIFT)
+#define PAGE_WRITE		(1 << PAGE_WRITE_SHIFT)
+#define PAGE_EXEC		(1 << PAGE_EXEC_SHIFT)
+
+#define PAGE_GLOBAL		(1 << PAGE_GLOBAL_SHIFT)
+
+#endif
+
+/** @}
+ */
Index: kernel/generic/include/mm/page.h
===================================================================
--- kernel/generic/include/mm/page.h	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/generic/include/mm/page.h	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -36,35 +36,7 @@
 #define KERN_PAGE_H_
 
-#include <arch/mm/asid.h>
 #include <arch/types.h>
-#include <typedefs.h>
+#include <mm/as.h>
 #include <memstr.h>
-
-#define PAGE_CACHEABLE_SHIFT		0
-#define PAGE_NOT_CACHEABLE_SHIFT	PAGE_CACHEABLE_SHIFT
-#define PAGE_PRESENT_SHIFT		1
-#define PAGE_NOT_PRESENT_SHIFT		PAGE_PRESENT_SHIFT
-#define PAGE_USER_SHIFT			2
-#define PAGE_KERNEL_SHIFT		PAGE_USER_SHIFT
-#define PAGE_READ_SHIFT			3
-#define PAGE_WRITE_SHIFT		4
-#define PAGE_EXEC_SHIFT			5
-#define PAGE_GLOBAL_SHIFT		6
-
-#define PAGE_NOT_CACHEABLE	(0<<PAGE_CACHEABLE_SHIFT)
-#define PAGE_CACHEABLE		(1<<PAGE_CACHEABLE_SHIFT)
-
-#define PAGE_PRESENT		(0<<PAGE_PRESENT_SHIFT)
-#define PAGE_NOT_PRESENT	(1<<PAGE_PRESENT_SHIFT)
-
-#define PAGE_USER		(1<<PAGE_USER_SHIFT)
-#define PAGE_KERNEL		(0<<PAGE_USER_SHIFT)
-
-#define PAGE_READ		(1<<PAGE_READ_SHIFT)
-#define PAGE_WRITE		(1<<PAGE_WRITE_SHIFT)
-#define PAGE_EXEC		(1<<PAGE_EXEC_SHIFT)
-
-#define PAGE_GLOBAL		(1<<PAGE_GLOBAL_SHIFT)
-
 
 /**
@@ -73,20 +45,11 @@
 #define PAGE_COLOR(va)	(((va) >> PAGE_WIDTH) & ((1 << PAGE_COLOR_BITS) - 1))
 
-/** Page fault access type. */
-enum pf_access {
-	PF_ACCESS_READ,
-	PF_ACCESS_WRITE,
-	PF_ACCESS_EXEC
-};
-typedef enum pf_access pf_access_t;
-
 /** Operations to manipulate page mappings. */
-struct page_mapping_operations {
-	void (* mapping_insert)(as_t *as, uintptr_t page, uintptr_t frame, int
-		flags);
+typedef struct {
+	void (* mapping_insert)(as_t *as, uintptr_t page, uintptr_t frame,
+		int flags);
 	void (* mapping_remove)(as_t *as, uintptr_t page);
 	pte_t *(* mapping_find)(as_t *as, uintptr_t page);
-};
-typedef struct page_mapping_operations page_mapping_operations_t;
+} page_mapping_operations_t;
 
 extern page_mapping_operations_t *page_mapping_operations;
@@ -95,6 +58,6 @@
 extern void page_table_lock(as_t *as, bool lock);
 extern void page_table_unlock(as_t *as, bool unlock);
-extern void page_mapping_insert(as_t *as, uintptr_t page, uintptr_t frame, int
-	flags);
+extern void page_mapping_insert(as_t *as, uintptr_t page, uintptr_t frame,
+	int flags);
 extern void page_mapping_remove(as_t *as, uintptr_t page);
 extern pte_t *page_mapping_find(as_t *as, uintptr_t page);
Index: kernel/generic/include/mm/tlb.h
===================================================================
--- kernel/generic/include/mm/tlb.h	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/generic/include/mm/tlb.h	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -38,5 +38,4 @@
 #include <arch/mm/asid.h>
 #include <arch/types.h>
-#include <typedefs.h>
 
 /**
@@ -47,20 +46,18 @@
 
 /** Type of TLB shootdown message. */
-enum tlb_invalidate_type {
+typedef enum {
 	TLB_INVL_INVALID = 0,		/**< Invalid type. */
 	TLB_INVL_ALL,			/**< Invalidate all entries in TLB. */
 	TLB_INVL_ASID,			/**< Invalidate all entries belonging to one address space. */
 	TLB_INVL_PAGES			/**< Invalidate specified page range belonging to one address space. */
-};
-typedef enum tlb_invalidate_type tlb_invalidate_type_t;
+} tlb_invalidate_type_t;
 
 /** TLB shootdown message. */
-struct tlb_shootdown_msg {
+typedef struct {
 	tlb_invalidate_type_t type;	/**< Message type. */
 	asid_t asid;			/**< Address space identifier. */
 	uintptr_t page;			/**< Page address. */
 	count_t count;			/**< Number of pages to invalidate. */
-};
-typedef struct tlb_shootdown_msg tlb_shootdown_msg_t;
+} tlb_shootdown_msg_t;
 
 extern void tlb_init(void);
Index: kernel/generic/include/printf/printf_core.h
===================================================================
--- kernel/generic/include/printf/printf_core.h	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/generic/include/printf/printf_core.h	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -36,5 +36,5 @@
 #define KERN_PRINTF_CORE_H_
 
-#include <typedefs.h>
+#include <arch/types.h>
 #include <arch/arg.h>
 
Index: kernel/generic/include/proc/scheduler.h
===================================================================
--- kernel/generic/include/proc/scheduler.h	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/generic/include/proc/scheduler.h	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -38,5 +38,4 @@
 #include <synch/spinlock.h>
 #include <time/clock.h>		/* HZ */
-#include <typedefs.h>
 #include <atomic.h>
 #include <adt/list.h>
Index: kernel/generic/include/proc/task.h
===================================================================
--- kernel/generic/include/proc/task.h	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/generic/include/proc/task.h	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -1,3 +1,3 @@
-/*
+/*3D
  * Copyright (c) 2001-2004 Jakub Jermar
  * All rights reserved.
@@ -36,16 +36,63 @@
 #define KERN_TASK_H_
 
-#include <typedefs.h>
 #include <synch/spinlock.h>
 #include <synch/mutex.h>
+#include <synch/rwlock.h>
 #include <synch/futex.h>
 #include <adt/btree.h>
 #include <adt/list.h>
-#include <ipc/ipc.h>
 #include <security/cap.h>
 #include <arch/proc/task.h>
+#include <arch/proc/thread.h>
+#include <arch/context.h>
+#include <arch/fpu_context.h>
+#include <arch/cpu.h>
+#include <mm/tlb.h>
+#include <proc/scheduler.h>
+
+#define IPC_MAX_PHONES  16
+#define THREAD_NAME_BUFLEN	20
+
+struct answerbox;
+struct task;
+struct thread;
+
+typedef enum {
+	IPC_PHONE_FREE = 0,     /**< Phone is free and can be allocated */
+	IPC_PHONE_CONNECTING,   /**< Phone is connecting somewhere */
+	IPC_PHONE_CONNECTED,    /**< Phone is connected */
+	IPC_PHONE_HUNGUP,  	/**< Phone is hung up, waiting for answers to come */
+	IPC_PHONE_SLAMMED       /**< Phone was hungup from server */
+} ipc_phone_state_t;
+
+/** Structure identifying phone (in TASK structure) */
+typedef struct {
+	SPINLOCK_DECLARE(lock);
+	link_t link;
+	struct answerbox *callee;
+	ipc_phone_state_t state;
+	atomic_t active_calls;
+} phone_t;
+
+typedef struct answerbox {
+	SPINLOCK_DECLARE(lock);
+
+	struct task *task;
+
+	waitq_t wq;
+
+	link_t connected_phones;	/**< Phones connected to this answerbox */
+	link_t calls;			/**< Received calls */
+	link_t dispatched_calls;	/* Should be hash table in the future */
+
+	link_t answers;			/**< Answered calls */
+
+	SPINLOCK_DECLARE(irq_lock);
+	link_t irq_notifs;       	/**< Notifications from IRQ handlers */
+	link_t irq_head;		/**< IRQs with notifications to this answerbox. */
+} answerbox_t;
 
 /** Task structure. */
-struct task {
+typedef struct task {
 	/** Task lock.
 	 *
@@ -55,5 +102,5 @@
 	
 	char *name;
-	thread_t *main_thread;	/**< Pointer to the main thread. */
+	struct thread *main_thread;	/**< Pointer to the main thread. */
 	link_t th_head;		/**< List of threads contained in this task. */
 	as_t *as;		/**< Address space. */
@@ -85,5 +132,162 @@
 	
 	uint64_t cycles;	/**< Accumulated accounting. */
-};
+} task_t;
+
+/** CPU structure.
+ *
+ * There is one structure like this for every processor.
+ */
+typedef struct {
+	SPINLOCK_DECLARE(lock);
+
+	tlb_shootdown_msg_t tlb_messages[TLB_MESSAGE_QUEUE_LEN];
+	count_t tlb_messages_count;
+	
+	context_t saved_context;
+
+	atomic_t nrdy;
+	runq_t rq[RQ_COUNT];
+	volatile count_t needs_relink;
+
+	SPINLOCK_DECLARE(timeoutlock);
+	link_t timeout_active_head;
+
+	count_t missed_clock_ticks;	/**< When system clock loses a tick, it is recorded here
+					     so that clock() can react. This variable is
+					     CPU-local and can be only accessed when interrupts
+					     are disabled. */
+
+	/**
+	 * Processor ID assigned by kernel.
+	 */
+	int id;
+	
+	int active;
+	int tlb_active;
+
+	uint16_t frequency_mhz;
+	uint32_t delay_loop_const;
+
+	cpu_arch_t arch;
+
+	struct thread *fpu_owner;
+	
+	/**
+	 * Stack used by scheduler when there is no running thread.
+	 */
+	uint8_t *stack;
+} cpu_t;
+
+typedef void (* timeout_handler_t)(void *arg);
+
+typedef struct {
+	SPINLOCK_DECLARE(lock);
+
+	link_t link;			/**< Link to the list of active timeouts on THE->cpu */
+	
+	uint64_t ticks;			/**< Timeout will be activated in this amount of clock() ticks. */
+
+	timeout_handler_t handler;	/**< Function that will be called on timeout activation. */
+	void *arg;			/**< Argument to be passed to handler() function. */
+	
+	cpu_t *cpu;			/**< On which processor is this timeout registered. */
+} timeout_t;
+
+/** Thread states. */
+typedef enum {
+	Invalid,	/**< It is an error, if thread is found in this state. */
+	Running,	/**< State of a thread that is currently executing on some CPU. */
+	Sleeping,	/**< Thread in this state is waiting for an event. */
+	Ready,		/**< State of threads in a run queue. */
+	Entering,	/**< Threads are in this state before they are first readied. */
+	Exiting,	/**< After a thread calls thread_exit(), it is put into Exiting state. */
+	Undead		/**< Threads that were not detached but exited are in the Undead state. */
+} state_t;
+
+/** Join types. */
+typedef enum {
+	None,
+	TaskClnp,	/**< The thread will be joined by ktaskclnp thread. */
+	TaskGC		/**< The thread will be joined by ktaskgc thread. */
+} thread_join_type_t;
+
+/** Thread structure. There is one per thread. */
+typedef struct thread {
+	link_t rq_link;				/**< Run queue link. */
+	link_t wq_link;				/**< Wait queue link. */
+	link_t th_link;				/**< Links to threads within containing task. */
+	
+	/** Lock protecting thread structure.
+	 *
+	 * Protects the whole thread structure except list links above.
+	 */
+	SPINLOCK_DECLARE(lock);
+
+	char name[THREAD_NAME_BUFLEN];
+
+	void (* thread_code)(void *);		/**< Function implementing the thread. */
+	void *thread_arg;			/**< Argument passed to thread_code() function. */
+
+	/** From here, the stored context is restored when the thread is scheduled. */
+	context_t saved_context;
+	/** From here, the stored timeout context is restored when sleep times out. */
+	context_t sleep_timeout_context;
+	/** From here, the stored interruption context is restored when sleep is interrupted. */
+	context_t sleep_interruption_context;
+
+	bool sleep_interruptible;		/**< If true, the thread can be interrupted from sleep. */
+	waitq_t *sleep_queue;			/**< Wait queue in which this thread sleeps. */
+	timeout_t sleep_timeout;		/**< Timeout used for timeoutable sleeping.  */
+	volatile int timeout_pending;		/**< Flag signalling sleep timeout in progress. */
+
+	/** True if this thread is executing copy_from_uspace(). False otherwise. */
+	bool in_copy_from_uspace;
+	/** True if this thread is executing copy_to_uspace(). False otherwise. */
+	bool in_copy_to_uspace;
+	
+	/**
+	 * If true, the thread will not go to sleep at all and will
+	 * call thread_exit() before returning to userspace.
+	 */
+	bool interrupted;			
+	
+	thread_join_type_t	join_type;	/**< Who joinins the thread. */
+	bool detached;				/**< If true, thread_join_timeout() cannot be used on this thread. */
+	waitq_t join_wq;			/**< Waitq for thread_join_timeout(). */
+
+	fpu_context_t *saved_fpu_context;
+	int fpu_context_exists;
+
+	/*
+	 * Defined only if thread doesn't run.
+	 * It means that fpu context is in CPU that last time executes this thread.
+	 * This disables migration.
+	 */
+	int fpu_context_engaged;
+
+	rwlock_type_t rwlock_holder_type;
+
+	void (* call_me)(void *);		/**< Funtion to be called in scheduler before the thread is put asleep. */
+	void *call_me_with;			/**< Argument passed to call_me(). */
+
+	state_t state;				/**< Thread's state. */
+	int flags;				/**< Thread's flags. */
+	
+	cpu_t *cpu;				/**< Thread's CPU. */
+	task_t *task;				/**< Containing task. */
+
+	uint64_t ticks;				/**< Ticks before preemption. */
+	
+	uint64_t cycles;			/**< Thread accounting. */
+	uint64_t last_cycle;		/**< Last sampled cycle. */
+	bool uncounted;				/**< Thread doesn't affect accumulated accounting. */
+
+	int priority;				/**< Thread's priority. Implemented as index to CPU->rq */
+	uint32_t tid;				/**< Thread ID. */
+	
+	thread_arch_t arch;			/**< Architecture-specific data. */
+
+	uint8_t *kstack;			/**< Thread's kernel stack. */
+} thread_t;
 
 extern spinlock_t tasks_lock;
@@ -98,4 +302,7 @@
 extern uint64_t task_get_accounting(task_t *t);
 
+extern void cap_set(task_t *t, cap_t caps);
+extern cap_t cap_get(task_t *t);
+
 
 #ifndef task_create_arch
Index: kernel/generic/include/proc/thread.h
===================================================================
--- kernel/generic/include/proc/thread.h	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/generic/include/proc/thread.h	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -36,126 +36,22 @@
 #define KERN_THREAD_H_
 
-#include <arch/proc/thread.h>
-#include <synch/spinlock.h>
-#include <arch/context.h>
-#include <fpu_context.h>
-#include <arch/types.h>
-#include <typedefs.h>
-#include <time/timeout.h>
+#include <synch/waitq.h>
+#include <proc/task.h>
+#include <cpu.h>
 #include <synch/rwlock.h>
-#include <synch/synch.h>
-#include <config.h>
 #include <adt/btree.h>
-#include <adt/list.h>
 #include <mm/slab.h>
+#include <arch/cpu.h>
+#include <mm/tlb.h>
 #include <proc/uarg.h>
 
 #define THREAD_STACK_SIZE	STACK_SIZE
 
-/** Thread states. */
-typedef enum {
-	Invalid,	/**< It is an error, if thread is found in this state. */
-	Running,	/**< State of a thread that is currently executing on some CPU. */
-	Sleeping,	/**< Thread in this state is waiting for an event. */
-	Ready,		/**< State of threads in a run queue. */
-	Entering,	/**< Threads are in this state before they are first readied. */
-	Exiting,	/**< After a thread calls thread_exit(), it is put into Exiting state. */
-	Undead		/**< Threads that were not detached but exited are in the Undead state. */
-} state_t;
-
 extern char *thread_states[];
 
-/** Join types. */
-typedef enum {
-	None,
-	TaskClnp,	/**< The thread will be joined by ktaskclnp thread. */
-	TaskGC		/**< The thread will be joined by ktaskgc thread. */
-} thread_join_type_t;
-
 /* Thread flags */
-#define THREAD_FLAG_WIRED	(1<<0)	/**< Thread cannot be migrated to another CPU. */
-#define THREAD_FLAG_STOLEN	(1<<1)	/**< Thread was migrated to another CPU and has not run yet. */
-#define THREAD_FLAG_USPACE	(1<<2)	/**< Thread executes in userspace. */
-
-#define THREAD_NAME_BUFLEN	20
-
-/** Thread structure. There is one per thread. */
-struct thread {
-	link_t rq_link;				/**< Run queue link. */
-	link_t wq_link;				/**< Wait queue link. */
-	link_t th_link;				/**< Links to threads within containing task. */
-	
-	/** Lock protecting thread structure.
-	 *
-	 * Protects the whole thread structure except list links above.
-	 */
-	SPINLOCK_DECLARE(lock);
-
-	char name[THREAD_NAME_BUFLEN];
-
-	void (* thread_code)(void *);		/**< Function implementing the thread. */
-	void *thread_arg;			/**< Argument passed to thread_code() function. */
-
-	/** From here, the stored context is restored when the thread is scheduled. */
-	context_t saved_context;
-	/** From here, the stored timeout context is restored when sleep times out. */
-	context_t sleep_timeout_context;
-	/** From here, the stored interruption context is restored when sleep is interrupted. */
-	context_t sleep_interruption_context;
-
-	bool sleep_interruptible;		/**< If true, the thread can be interrupted from sleep. */
-	waitq_t *sleep_queue;			/**< Wait queue in which this thread sleeps. */
-	timeout_t sleep_timeout;		/**< Timeout used for timeoutable sleeping.  */
-	volatile int timeout_pending;		/**< Flag signalling sleep timeout in progress. */
-
-	/** True if this thread is executing copy_from_uspace(). False otherwise. */
-	bool in_copy_from_uspace;
-	/** True if this thread is executing copy_to_uspace(). False otherwise. */
-	bool in_copy_to_uspace;
-	
-	/**
-	 * If true, the thread will not go to sleep at all and will
-	 * call thread_exit() before returning to userspace.
-	 */
-	bool interrupted;			
-	
-	thread_join_type_t	join_type;	/**< Who joinins the thread. */
-	bool detached;				/**< If true, thread_join_timeout() cannot be used on this thread. */
-	waitq_t join_wq;			/**< Waitq for thread_join_timeout(). */
-
-	fpu_context_t *saved_fpu_context;
-	int fpu_context_exists;
-
-	/*
-	 * Defined only if thread doesn't run.
-	 * It means that fpu context is in CPU that last time executes this thread.
-	 * This disables migration.
-	 */
-	int fpu_context_engaged;
-
-	rwlock_type_t rwlock_holder_type;
-
-	void (* call_me)(void *);		/**< Funtion to be called in scheduler before the thread is put asleep. */
-	void *call_me_with;			/**< Argument passed to call_me(). */
-
-	state_t state;				/**< Thread's state. */
-	int flags;				/**< Thread's flags. */
-	
-	cpu_t *cpu;				/**< Thread's CPU. */
-	task_t *task;				/**< Containing task. */
-
-	uint64_t ticks;				/**< Ticks before preemption. */
-	
-	uint64_t cycles;			/**< Thread accounting. */
-	uint64_t last_cycle;		/**< Last sampled cycle. */
-	bool uncounted;				/**< Thread doesn't affect accumulated accounting. */
-
-	int priority;				/**< Thread's priority. Implemented as index to CPU->rq */
-	uint32_t tid;				/**< Thread ID. */
-	
-	thread_arch_t arch;			/**< Architecture-specific data. */
-
-	uint8_t *kstack;			/**< Thread's kernel stack. */
-};
+#define THREAD_FLAG_WIRED	(1 << 0)	/**< Thread cannot be migrated to another CPU. */
+#define THREAD_FLAG_STOLEN	(1 << 1)	/**< Thread was migrated to another CPU and has not run yet. */
+#define THREAD_FLAG_USPACE	(1 << 2)	/**< Thread executes in userspace. */
 
 /** Thread list lock.
@@ -196,4 +92,5 @@
 extern void thread_update_accounting(void);
 extern bool thread_exists(thread_t *t);
+extern void thread_interrupt_sleep(thread_t *t);
 
 /* Fpu context slab cache */
Index: kernel/generic/include/security/cap.h
===================================================================
--- kernel/generic/include/security/cap.h	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/generic/include/security/cap.h	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -50,5 +50,4 @@
 #include <syscall/sysarg64.h>
 #include <arch/types.h>
-#include <typedefs.h>
 
 /**
@@ -82,7 +81,4 @@
 typedef uint32_t cap_t;
 
-extern void cap_set(task_t *t, cap_t caps);
-extern cap_t cap_get(task_t *t);
-
 extern unative_t sys_cap_grant(sysarg64_t *uspace_taskid_arg, cap_t caps);
 extern unative_t sys_cap_revoke(sysarg64_t *uspace_taskid_arg, cap_t caps);
Index: kernel/generic/include/synch/futex.h
===================================================================
--- kernel/generic/include/synch/futex.h	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/generic/include/synch/futex.h	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -37,5 +37,4 @@
 
 #include <arch/types.h>
-#include <typedefs.h>
 #include <synch/waitq.h>
 #include <genarch/mm/page_ht.h>
Index: kernel/generic/include/synch/mutex.h
===================================================================
--- kernel/generic/include/synch/mutex.h	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/generic/include/synch/mutex.h	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -37,5 +37,4 @@
 
 #include <arch/types.h>
-#include <typedefs.h>
 #include <synch/semaphore.h>
 #include <synch/synch.h>
Index: kernel/generic/include/synch/rwlock.h
===================================================================
--- kernel/generic/include/synch/rwlock.h	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/generic/include/synch/rwlock.h	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -37,5 +37,4 @@
 
 #include <arch/types.h>
-#include <typedefs.h>
 #include <synch/mutex.h>
 #include <synch/synch.h>
Index: kernel/generic/include/synch/semaphore.h
===================================================================
--- kernel/generic/include/synch/semaphore.h	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/generic/include/synch/semaphore.h	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -37,5 +37,4 @@
 
 #include <arch/types.h>
-#include <typedefs.h>
 #include <synch/waitq.h>
 #include <synch/synch.h>
@@ -46,9 +45,9 @@
 
 #define semaphore_down(s) \
-	_semaphore_down_timeout((s),SYNCH_NO_TIMEOUT,SYNCH_FLAGS_NONE)
+	_semaphore_down_timeout((s), SYNCH_NO_TIMEOUT, SYNCH_FLAGS_NONE)
 #define semaphore_trydown(s) \
-	_semaphore_down_timeout((s),SYNCH_NO_TIMEOUT,SYNCH_FLAGS_NON_BLOCKING)	
-#define semaphore_down_timeout(s,usec) \
-	_semaphore_down_timeout((s),(usec),SYNCH_FLAGS_NONE)
+	_semaphore_down_timeout((s), SYNCH_NO_TIMEOUT, SYNCH_FLAGS_NON_BLOCKING)	
+#define semaphore_down_timeout(s, usec) \
+	_semaphore_down_timeout((s), (usec), SYNCH_FLAGS_NONE)
 
 extern void semaphore_initialize(semaphore_t *s, int val);
Index: kernel/generic/include/synch/spinlock.h
===================================================================
--- kernel/generic/include/synch/spinlock.h	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/generic/include/synch/spinlock.h	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -37,5 +37,4 @@
 
 #include <arch/types.h>
-#include <typedefs.h>
 #include <preemption.h>
 #include <atomic.h>
@@ -98,5 +97,5 @@
 	CS_LEAVE_BARRIER();
 	
-	atomic_set(&sl->val,0);
+	atomic_set(&sl->val, 0);
 	preemption_enable();
 }
@@ -110,5 +109,5 @@
 #define SPINLOCK_INITIALIZE(name)
 
-#define spinlock_initialize(x,name)
+#define spinlock_initialize(x, name)
 #define spinlock_lock(x)		preemption_disable()
 #define spinlock_trylock(x) 		(preemption_disable(), 1)
Index: kernel/generic/include/synch/waitq.h
===================================================================
--- kernel/generic/include/synch/waitq.h	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/generic/include/synch/waitq.h	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -37,5 +37,4 @@
 
 #include <arch/types.h>
-#include <typedefs.h>
 #include <synch/spinlock.h>
 #include <synch/synch.h>
@@ -59,5 +58,5 @@
 
 #define waitq_sleep(wq) \
-	waitq_sleep_timeout((wq),SYNCH_NO_TIMEOUT,SYNCH_FLAGS_NONE)
+	waitq_sleep_timeout((wq), SYNCH_NO_TIMEOUT, SYNCH_FLAGS_NONE)
 
 extern void waitq_initialize(waitq_t *wq);
@@ -68,5 +67,4 @@
 extern void waitq_wakeup(waitq_t *wq, bool all);
 extern void _waitq_wakeup_unsafe(waitq_t *wq, bool all);
-extern void waitq_interrupt_sleep(thread_t *t);
 
 #endif
Index: kernel/generic/include/syscall/copy.h
===================================================================
--- kernel/generic/include/syscall/copy.h	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/generic/include/syscall/copy.h	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -36,5 +36,5 @@
 #define KERN_COPY_H_
 
-#include <typedefs.h>
+#include <arch/types.h>
 
 /** Label within memcpy_from_uspace() that contains return -1. */
Index: kernel/generic/include/syscall/syscall.h
===================================================================
--- kernel/generic/include/syscall/syscall.h	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/generic/include/syscall/syscall.h	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -72,5 +72,4 @@
 
 #include <arch/types.h>
-#include <typedefs.h>
 
 typedef unative_t (*syshandler_t)();
Index: kernel/generic/include/time/timeout.h
===================================================================
--- kernel/generic/include/time/timeout.h	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/generic/include/time/timeout.h	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -37,24 +37,7 @@
 
 #include <arch/types.h>
-#include <cpu.h>
-#include <synch/spinlock.h>
-#include <adt/list.h>
+#include <proc/task.h>
 
-#define us2ticks(us)	((uint64_t)(((uint32_t) (us)/(1000000/HZ))))
-
-typedef void (* timeout_handler_t)(void *arg);
-
-typedef struct {
-	SPINLOCK_DECLARE(lock);
-
-	link_t link;			/**< Link to the list of active timeouts on THE->cpu */
-	
-	uint64_t ticks;			/**< Timeout will be activated in this amount of clock() ticks. */
-
-	timeout_handler_t handler;	/**< Function that will be called on timeout activation. */
-	void *arg;			/**< Argument to be passed to handler() function. */
-	
-	cpu_t *cpu;			/**< On which processor is this timeout registered. */
-} timeout_t;
+#define us2ticks(us)	((uint64_t) (((uint32_t) (us) / (1000000 / HZ))))
 
 extern void timeout_init(void);
Index: kernel/generic/include/typedefs.h
===================================================================
--- kernel/generic/include/typedefs.h	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/generic/include/typedefs.h	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -36,44 +36,5 @@
 #define KERN_TYPEDEFS_H_
 
-#define false 0
-#define true 1
-
-typedef short bool;
-
-typedef unsigned long size_t;
-typedef unsigned long count_t;
-typedef unsigned long index_t;
-
-typedef unsigned long long task_id_t;
-typedef unsigned long context_id_t;
-
-typedef struct task task_t;
-typedef struct thread thread_t;
-
-typedef struct as_area as_area_t;
-typedef struct as as_t;
-
-typedef struct link link_t;
-
-typedef struct chardev chardev_t;
-
-typedef enum cmd_arg_type cmd_arg_type_t;
-typedef struct cmd_arg cmd_arg_t;
-typedef struct cmd_info cmd_info_t;
-
-typedef struct istate istate_t;
 typedef void (* function)();
-typedef void (* iroutine)(int n, istate_t *istate);
-
-typedef struct hash_table hash_table_t;
-typedef struct hash_table_operations hash_table_operations_t;
-
-typedef struct btree_node btree_node_t;
-typedef struct btree btree_t;
-
-typedef signed int inr_t;
-typedef signed int devno_t;
-typedef struct irq irq_t;
-typedef struct ipc_notif_cfg ipc_notif_cfg_t;
 
 #endif
Index: kernel/generic/src/adt/bitmap.c
===================================================================
--- kernel/generic/src/adt/bitmap.c	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/generic/src/adt/bitmap.c	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -39,5 +39,4 @@
 
 #include <adt/bitmap.h>
-#include <typedefs.h>
 #include <arch/types.h>
 #include <align.h>
Index: kernel/generic/src/adt/btree.c
===================================================================
--- kernel/generic/src/adt/btree.c	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/generic/src/adt/btree.c	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -52,5 +52,4 @@
 #include <debug.h>
 #include <panic.h>
-#include <typedefs.h>
 #include <print.h>
 
Index: kernel/generic/src/adt/hash_table.c
===================================================================
--- kernel/generic/src/adt/hash_table.c	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/generic/src/adt/hash_table.c	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -40,5 +40,4 @@
 #include <adt/hash_table.h>
 #include <adt/list.h>
-#include <typedefs.h>
 #include <arch/types.h>
 #include <debug.h>
Index: kernel/generic/src/console/cmd.c
===================================================================
--- kernel/generic/src/console/cmd.c	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/generic/src/console/cmd.c	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -46,5 +46,4 @@
 #include <print.h>
 #include <panic.h>
-#include <typedefs.h>
 #include <arch/types.h>
 #include <adt/list.h>
Index: kernel/generic/src/console/console.c
===================================================================
--- kernel/generic/src/console/console.c	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/generic/src/console/console.c	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -39,5 +39,4 @@
 #include <synch/spinlock.h>
 #include <arch/types.h>
-#include <typedefs.h>
 #include <arch.h>
 #include <func.h>
Index: kernel/generic/src/console/kconsole.c
===================================================================
--- kernel/generic/src/console/kconsole.c	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/generic/src/console/kconsole.c	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -44,5 +44,4 @@
 #include <print.h>
 #include <panic.h>
-#include <typedefs.h>
 #include <arch/types.h>
 #include <adt/list.h>
Index: kernel/generic/src/cpu/cpu.c
===================================================================
--- kernel/generic/src/cpu/cpu.c	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/generic/src/cpu/cpu.c	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -45,5 +45,4 @@
 #include <config.h>
 #include <panic.h>
-#include <typedefs.h>
 #include <memstr.h>
 #include <adt/list.h>
Index: kernel/generic/src/ddi/device.c
===================================================================
--- kernel/generic/src/ddi/device.c	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/generic/src/ddi/device.c	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -39,5 +39,4 @@
 #include <atomic.h>
 #include <debug.h>
-#include <typedefs.h>
 
 static atomic_t last;
Index: kernel/generic/src/ddi/irq.c
===================================================================
--- kernel/generic/src/ddi/irq.c	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/generic/src/ddi/irq.c	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -70,5 +70,4 @@
 #include <adt/hash_table.h>
 #include <arch/types.h>
-#include <typedefs.h>
 #include <synch/spinlock.h>
 #include <arch.h>
Index: kernel/generic/src/debug/symtab.c
===================================================================
--- kernel/generic/src/debug/symtab.c	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/generic/src/debug/symtab.c	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -37,5 +37,4 @@
 
 #include <symtab.h>
-#include <typedefs.h>
 #include <arch/byteorder.h>
 #include <func.h>
Index: kernel/generic/src/lib/elf.c
===================================================================
--- kernel/generic/src/lib/elf.c	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/generic/src/lib/elf.c	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -40,5 +40,4 @@
 #include <debug.h>
 #include <arch/types.h>
-#include <typedefs.h>
 #include <mm/as.h>
 #include <mm/frame.h>
Index: kernel/generic/src/lib/func.c
===================================================================
--- kernel/generic/src/lib/func.c	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/generic/src/lib/func.c	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -41,5 +41,4 @@
 #include <arch/asm.h>
 #include <arch.h>
-#include <typedefs.h>
 #include <console/kconsole.h>
 
Index: kernel/generic/src/main/kinit.c
===================================================================
--- kernel/generic/src/main/kinit.c	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/generic/src/main/kinit.c	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -63,4 +63,5 @@
 #include <security/cap.h>
 #include <lib/rd.h>
+#include <ipc/ipc.h>
 
 #ifdef CONFIG_SMP
Index: kernel/generic/src/main/main.c
===================================================================
--- kernel/generic/src/main/main.c	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/generic/src/main/main.c	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -54,4 +54,5 @@
 #include <config.h>
 #include <time/clock.h>
+#include <time/timeout.h>
 #include <proc/scheduler.h>
 #include <proc/thread.h>
@@ -75,5 +76,4 @@
 #include <arch.h>
 #include <arch/faddr.h>
-#include <typedefs.h>
 #include <ipc/ipc.h>
 #include <macros.h>
Index: kernel/generic/src/mm/as.c
===================================================================
--- kernel/generic/src/mm/as.c	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/generic/src/mm/as.c	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -75,5 +75,4 @@
 #include <align.h>
 #include <arch/types.h>
-#include <typedefs.h>
 #include <syscall/copy.h>
 #include <arch/interrupt.h>
@@ -169,5 +168,9 @@
 	as->refcount = 0;
 	as->cpu_refcount = 0;
+#ifdef AS_PAGE_TABLE
 	as->page_table = page_table_create(flags);
+#else
+	page_table_create(flags);
+#endif
 
 	return as;
@@ -217,5 +220,9 @@
 
 	btree_destroy(&as->as_area_btree);
+#ifdef AS_PAGE_TABLE
 	page_table_destroy(as->page_table);
+#else
+	page_table_destroy(NULL);
+#endif
 
 	interrupts_restore(ipl);
Index: kernel/generic/src/mm/backend_anon.c
===================================================================
--- kernel/generic/src/mm/backend_anon.c	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/generic/src/mm/backend_anon.c	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -48,5 +48,4 @@
 #include <errno.h>
 #include <arch/types.h>
-#include <typedefs.h>
 #include <align.h>
 #include <arch.h>
Index: kernel/generic/src/mm/backend_elf.c
===================================================================
--- kernel/generic/src/mm/backend_elf.c	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/generic/src/mm/backend_elf.c	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -39,5 +39,4 @@
 #include <debug.h>
 #include <arch/types.h>
-#include <typedefs.h>
 #include <mm/as.h>
 #include <mm/frame.h>
Index: kernel/generic/src/mm/backend_phys.c
===================================================================
--- kernel/generic/src/mm/backend_phys.c	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/generic/src/mm/backend_phys.c	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -38,5 +38,4 @@
 #include <debug.h>
 #include <arch/types.h>
-#include <typedefs.h>
 #include <mm/as.h>
 #include <mm/frame.h>
Index: kernel/generic/src/mm/buddy.c
===================================================================
--- kernel/generic/src/mm/buddy.c	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/generic/src/mm/buddy.c	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -43,6 +43,4 @@
 #include <mm/frame.h>
 #include <arch/types.h>
-#include <typedefs.h>
-#include <adt/list.h>
 #include <debug.h>
 #include <print.h>
Index: kernel/generic/src/mm/frame.c
===================================================================
--- kernel/generic/src/mm/frame.c	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/generic/src/mm/frame.c	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -52,5 +52,4 @@
  */
 
-#include <typedefs.h>
 #include <arch/types.h>
 #include <mm/frame.h>
Index: kernel/generic/src/mm/page.c
===================================================================
--- kernel/generic/src/mm/page.c	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/generic/src/mm/page.c	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -47,5 +47,4 @@
 #include <mm/frame.h>
 #include <arch/types.h>
-#include <typedefs.h>
 #include <arch/asm.h>
 #include <memstr.h>
Index: kernel/generic/src/mm/tlb.c
===================================================================
--- kernel/generic/src/mm/tlb.c	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/generic/src/mm/tlb.c	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -45,5 +45,4 @@
 #include <smp/ipi.h>
 #include <synch/spinlock.h>
-#include <typedefs.h>
 #include <atomic.h>
 #include <arch/interrupt.h>
@@ -52,4 +51,5 @@
 #include <panic.h>
 #include <debug.h>
+#include <cpu.h>
 
 /**
Index: kernel/generic/src/proc/scheduler.c
===================================================================
--- kernel/generic/src/proc/scheduler.c	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/generic/src/proc/scheduler.c	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -45,4 +45,5 @@
 #include <mm/page.h>
 #include <mm/as.h>
+#include <time/timeout.h>
 #include <time/delay.h>
 #include <arch/asm.h>
@@ -53,9 +54,9 @@
 #include <config.h>
 #include <context.h>
+#include <fpu_context.h>
 #include <func.h>
 #include <arch.h>
 #include <adt/list.h>
 #include <panic.h>
-#include <typedefs.h>
 #include <cpu.h>
 #include <print.h>
Index: kernel/generic/src/proc/task.c
===================================================================
--- kernel/generic/src/proc/task.c	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/generic/src/proc/task.c	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -364,5 +364,5 @@
 		
 		if (sleeping)
-			waitq_interrupt_sleep(thr);
+			thread_interrupt_sleep(thr);
 	}
 	
Index: kernel/generic/src/proc/the.c
===================================================================
--- kernel/generic/src/proc/the.c	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/generic/src/proc/the.c	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -43,5 +43,4 @@
 
 #include <arch.h>
-#include <typedefs.h>
 
 
Index: kernel/generic/src/proc/thread.c
===================================================================
--- kernel/generic/src/proc/thread.c	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/generic/src/proc/thread.c	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -54,6 +54,6 @@
 #include <adt/btree.h>
 #include <adt/list.h>
-#include <typedefs.h>
 #include <time/clock.h>
+#include <time/timeout.h>
 #include <config.h>
 #include <arch/interrupt.h>
@@ -679,4 +679,57 @@
 }
 
+/** Interrupt sleeping thread.
+ *
+ * This routine attempts to interrupt a thread from its sleep in a waitqueue.
+ * If the thread is not found sleeping, no action is taken.
+ *
+ * @param t Thread to be interrupted.
+ */
+void thread_interrupt_sleep(thread_t *t)
+{
+	waitq_t *wq;
+	bool do_wakeup = false;
+	ipl_t ipl;
+
+	ipl = interrupts_disable();
+	spinlock_lock(&threads_lock);
+	if (!thread_exists(t))
+		goto out;
+
+grab_locks:
+	spinlock_lock(&t->lock);
+	if ((wq = t->sleep_queue)) {		/* assignment */
+		if (!(t->sleep_interruptible)) {
+			/*
+			 * The sleep cannot be interrupted.
+			 */
+			spinlock_unlock(&t->lock);
+			goto out;
+		}
+			
+		if (!spinlock_trylock(&wq->lock)) {
+			spinlock_unlock(&t->lock);
+			goto grab_locks;	/* avoid deadlock */
+		}
+
+		if (t->timeout_pending && timeout_unregister(&t->sleep_timeout))
+			t->timeout_pending = false;
+
+		list_remove(&t->wq_link);
+		t->saved_context = t->sleep_interruption_context;
+		do_wakeup = true;
+		t->sleep_queue = NULL;
+		spinlock_unlock(&wq->lock);
+	}
+	spinlock_unlock(&t->lock);
+
+	if (do_wakeup)
+		thread_ready(t);
+
+out:
+	spinlock_unlock(&threads_lock);
+	interrupts_restore(ipl);
+}
+
 /** @}
  */
Index: kernel/generic/src/security/cap.c
===================================================================
--- kernel/generic/src/security/cap.c	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/generic/src/security/cap.c	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -44,5 +44,4 @@
 #include <syscall/copy.h>
 #include <arch.h>
-#include <typedefs.h>
 #include <errno.h>
 
Index: kernel/generic/src/synch/condvar.c
===================================================================
--- kernel/generic/src/synch/condvar.c	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/generic/src/synch/condvar.c	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -41,5 +41,4 @@
 #include <synch/synch.h>
 #include <arch.h>
-#include <typedefs.h>
 
 /** Initialize condition variable.
Index: kernel/generic/src/synch/rwlock.c
===================================================================
--- kernel/generic/src/synch/rwlock.c	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/generic/src/synch/rwlock.c	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -64,5 +64,4 @@
 #include <synch/synch.h>
 #include <adt/list.h>
-#include <typedefs.h>
 #include <arch/asm.h>
 #include <arch.h>
Index: kernel/generic/src/synch/waitq.c
===================================================================
--- kernel/generic/src/synch/waitq.c	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/generic/src/synch/waitq.c	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -50,5 +50,4 @@
 #include <arch/asm.h>
 #include <arch/types.h>
-#include <typedefs.h>
 #include <time/timeout.h>
 #include <arch.h>
@@ -118,56 +117,4 @@
 }
 
-/** Interrupt sleeping thread.
- *
- * This routine attempts to interrupt a thread from its sleep in a waitqueue.
- * If the thread is not found sleeping, no action is taken.
- *
- * @param t Thread to be interrupted.
- */
-void waitq_interrupt_sleep(thread_t *t)
-{
-	waitq_t *wq;
-	bool do_wakeup = false;
-	ipl_t ipl;
-
-	ipl = interrupts_disable();
-	spinlock_lock(&threads_lock);
-	if (!thread_exists(t))
-		goto out;
-
-grab_locks:
-	spinlock_lock(&t->lock);
-	if ((wq = t->sleep_queue)) {		/* assignment */
-		if (!(t->sleep_interruptible)) {
-			/*
-			 * The sleep cannot be interrupted.
-			 */
-			spinlock_unlock(&t->lock);
-			goto out;
-		}
-			
-		if (!spinlock_trylock(&wq->lock)) {
-			spinlock_unlock(&t->lock);
-			goto grab_locks;	/* avoid deadlock */
-		}
-
-		if (t->timeout_pending && timeout_unregister(&t->sleep_timeout))
-			t->timeout_pending = false;
-
-		list_remove(&t->wq_link);
-		t->saved_context = t->sleep_interruption_context;
-		do_wakeup = true;
-		t->sleep_queue = NULL;
-		spinlock_unlock(&wq->lock);
-	}
-	spinlock_unlock(&t->lock);
-
-	if (do_wakeup)
-		thread_ready(t);
-
-out:
-	spinlock_unlock(&threads_lock);
-	interrupts_restore(ipl);
-}
 
 /** Sleep until either wakeup, timeout or interruption occurs
@@ -426,5 +373,5 @@
 	 * (the link belongs to the wait queue), but because
 	 * of synchronization with waitq_timeouted_sleep()
-	 * and waitq_interrupt_sleep().
+	 * and thread_interrupt_sleep().
 	 *
 	 * In order for these two functions to work, the following
Index: kernel/generic/src/syscall/copy.c
===================================================================
--- kernel/generic/src/syscall/copy.c	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/generic/src/syscall/copy.c	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -45,5 +45,4 @@
 #include <arch.h>
 #include <errno.h>
-#include <typedefs.h>
 
 /** Copy data from userspace to kernel.
Index: kernel/generic/src/time/timeout.c
===================================================================
--- kernel/generic/src/time/timeout.c	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/generic/src/time/timeout.c	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -37,5 +37,4 @@
 
 #include <time/timeout.h>
-#include <typedefs.h>
 #include <arch/types.h>
 #include <config.h>
Index: kernel/test/test.h
===================================================================
--- kernel/test/test.h	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ kernel/test/test.h	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -37,5 +37,4 @@
 
 #include <arch/types.h>
-#include <typedefs.h>
 
 typedef char * (* test_entry_t)(bool);
Index: uspace/init/init.c
===================================================================
--- uspace/init/init.c	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ uspace/init/init.c	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -50,5 +50,5 @@
 	version_print();
 
-	printf("Hello\nThis is Init\n");
+	printf("This is init\n");
 	
 	test_console();
Index: uspace/klog/klog.c
===================================================================
--- uspace/klog/klog.c	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ uspace/klog/klog.c	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -40,5 +40,4 @@
 #include <ipc/services.h>
 #include <as.h>
-#include <kernel/ipc/irq.h>
 #include <sysinfo.h>
 
Index: uspace/libc/include/as.h
===================================================================
--- uspace/libc/include/as.h	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ uspace/libc/include/as.h	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -38,5 +38,4 @@
 #include <types.h>
 #include <task.h>
-#include <kernel/arch/mm/as.h>
 #include <kernel/mm/as.h>
 #include <libarch/config.h>
Index: uspace/libc/include/ipc/ipc.h
===================================================================
--- uspace/libc/include/ipc/ipc.h	(revision 1ba41c5ae41f66c7fa3ef1caef4b77d414202fb3)
+++ uspace/libc/include/ipc/ipc.h	(revision b3f8fb771f871e7f2bb35ce9339717639e8f86d6)
@@ -37,5 +37,5 @@
 
 #include <kernel/ipc/ipc.h>
-#include <kernel/ipc/irq.h>
+#include <kernel/ddi/irq.h>
 #include <libc.h>
 #include <types.h>
@@ -46,5 +46,5 @@
 	ipcarg_t args[IPC_CALL_LEN];
 	ipcarg_t in_phone_hash;
-} ipc_call_t ;
+} ipc_call_t;
 typedef sysarg_t ipc_callid_t;
 
