Index: kernel/arch/abs32le/include/istate.h
===================================================================
--- kernel/arch/abs32le/include/istate.h	(revision bee37cf38ae72b317ae253951b1acbcd937607bc)
+++ kernel/arch/abs32le/include/istate.h	(revision fcfac2508fadfedd93f8fbbfaf6016d658cc03f6)
@@ -36,15 +36,12 @@
 #define KERN_abs32le_ISTATE_H_
 
+#include <trace.h>
+
 #ifdef KERNEL
 
-#include <typedefs.h>
 #include <verify.h>
-#include <trace.h>
 
 #else /* KERNEL */
 
-#include <sys/types.h>
-
-#define NO_TRACE
 #define REQUIRES_EXTENT_MUTABLE(arg)
 #define WRITES(arg)
Index: kernel/arch/abs32le/include/mm/frame.h
===================================================================
--- kernel/arch/abs32le/include/mm/frame.h	(revision bee37cf38ae72b317ae253951b1acbcd937607bc)
+++ kernel/arch/abs32le/include/mm/frame.h	(revision fcfac2508fadfedd93f8fbbfaf6016d658cc03f6)
@@ -39,6 +39,4 @@
 #define FRAME_SIZE   (1 << FRAME_WIDTH)
 
-#ifdef KERNEL
-
 #include <typedefs.h>
 
@@ -46,6 +44,4 @@
 extern void physmem_print(void);
 
-#endif /* KERNEL */
-
 #endif
 
Index: kernel/arch/abs32le/include/mm/page.h
===================================================================
--- kernel/arch/abs32le/include/mm/page.h	(revision bee37cf38ae72b317ae253951b1acbcd937607bc)
+++ kernel/arch/abs32le/include/mm/page.h	(revision fcfac2508fadfedd93f8fbbfaf6016d658cc03f6)
@@ -41,6 +41,4 @@
 #define PAGE_WIDTH  FRAME_WIDTH
 #define PAGE_SIZE   FRAME_SIZE
-
-#ifdef KERNEL
 
 #define KA2PA(x)  (((uintptr_t) (x)) - UINT32_C(0x80000000))
@@ -178,6 +176,4 @@
 extern void page_fault(unsigned int, istate_t *);
 
-#endif /* KERNEL */
-
 #endif
 
Index: kernel/arch/abs32le/src/userspace.c
===================================================================
--- kernel/arch/abs32le/src/userspace.c	(revision bee37cf38ae72b317ae253951b1acbcd937607bc)
+++ kernel/arch/abs32le/src/userspace.c	(revision fcfac2508fadfedd93f8fbbfaf6016d658cc03f6)
@@ -36,7 +36,6 @@
 #include <typedefs.h>
 #include <arch.h>
-#include <proc/uarg.h>
+#include <abi/proc/uarg.h>
 #include <mm/as.h>
-
 
 void userspace(uspace_arg_t *kernel_uarg)
Index: kernel/arch/amd64/include/context.h
===================================================================
--- kernel/arch/amd64/include/context.h	(revision bee37cf38ae72b317ae253951b1acbcd937607bc)
+++ kernel/arch/amd64/include/context.h	(revision fcfac2508fadfedd93f8fbbfaf6016d658cc03f6)
@@ -36,6 +36,4 @@
 #define KERN_amd64_CONTEXT_H_
 
-#ifdef KERNEL
-
 #include <typedefs.h>
 
@@ -52,6 +50,4 @@
 		(c)->rbp = 0; \
 	} while (0)
-
-#endif /* KERNEL */
 
 /* We include only registers that must be preserved
Index: kernel/arch/amd64/include/istate.h
===================================================================
--- kernel/arch/amd64/include/istate.h	(revision bee37cf38ae72b317ae253951b1acbcd937607bc)
+++ kernel/arch/amd64/include/istate.h	(revision fcfac2508fadfedd93f8fbbfaf6016d658cc03f6)
@@ -36,16 +36,5 @@
 #define KERN_amd64_ISTATE_H_
 
-#ifdef KERNEL
-
-#include <typedefs.h>
 #include <trace.h>
-
-#else /* KERNEL */
-
-#include <sys/types.h>
-
-#define NO_TRACE
-
-#endif /* KERNEL */
 
 /** This is passed to interrupt handlers */
Index: kernel/arch/amd64/include/mm/frame.h
===================================================================
--- kernel/arch/amd64/include/mm/frame.h	(revision bee37cf38ae72b317ae253951b1acbcd937607bc)
+++ kernel/arch/amd64/include/mm/frame.h	(revision fcfac2508fadfedd93f8fbbfaf6016d658cc03f6)
@@ -39,5 +39,4 @@
 #define FRAME_SIZE   (1 << FRAME_WIDTH)
 
-#ifdef KERNEL
 #ifndef __ASM__
 
@@ -49,5 +48,4 @@
 
 #endif /* __ASM__ */
-#endif /* KERNEL */
 
 #endif
Index: kernel/arch/amd64/include/mm/page.h
===================================================================
--- kernel/arch/amd64/include/mm/page.h	(revision bee37cf38ae72b317ae253951b1acbcd937607bc)
+++ kernel/arch/amd64/include/mm/page.h	(revision fcfac2508fadfedd93f8fbbfaf6016d658cc03f6)
@@ -50,6 +50,4 @@
 #define PAGE_WIDTH  FRAME_WIDTH
 #define PAGE_SIZE   FRAME_SIZE
-
-#ifdef KERNEL
 
 #ifndef __ASM__
@@ -231,6 +229,4 @@
 #endif /* __ASM__ */
 
-#endif /* KERNEL */
-
 #endif
 
Index: kernel/arch/amd64/src/userspace.c
===================================================================
--- kernel/arch/amd64/src/userspace.c	(revision bee37cf38ae72b317ae253951b1acbcd937607bc)
+++ kernel/arch/amd64/src/userspace.c	(revision fcfac2508fadfedd93f8fbbfaf6016d658cc03f6)
@@ -38,7 +38,6 @@
 #include <typedefs.h>
 #include <arch.h>
-#include <proc/uarg.h>
+#include <abi/proc/uarg.h>
 #include <mm/as.h>
-
 
 /** Enter userspace
Index: kernel/arch/arm32/include/istate.h
===================================================================
--- kernel/arch/arm32/include/istate.h	(revision bee37cf38ae72b317ae253951b1acbcd937607bc)
+++ kernel/arch/arm32/include/istate.h	(revision fcfac2508fadfedd93f8fbbfaf6016d658cc03f6)
@@ -35,13 +35,15 @@
 #define KERN_arm32_ISTATE_H_
 
+#include <trace.h>
+
+#ifdef KERNEL
+
 #include <arch/regutils.h>
 
-#ifdef KERNEL
-#include <typedefs.h>
-#include <trace.h>
-#else
-#include <sys/types.h>
-#define NO_TRACE
-#endif
+#else /* KERNEL */
+
+#include <libarch/regutils.h>
+
+#endif /* KERNEL */
 
 /** Struct representing CPU state saved when an exception occurs. */
Index: kernel/arch/arm32/include/mm/frame.h
===================================================================
--- kernel/arch/arm32/include/mm/frame.h	(revision bee37cf38ae72b317ae253951b1acbcd937607bc)
+++ kernel/arch/arm32/include/mm/frame.h	(revision fcfac2508fadfedd93f8fbbfaf6016d658cc03f6)
@@ -40,5 +40,4 @@
 #define FRAME_SIZE   (1 << FRAME_WIDTH)
 
-#ifdef KERNEL
 #ifndef __ASM__
 
@@ -69,5 +68,4 @@
 
 #endif /* __ASM__ */
-#endif /* KERNEL */
 
 #endif
Index: kernel/arch/arm32/include/mm/page.h
===================================================================
--- kernel/arch/arm32/include/mm/page.h	(revision bee37cf38ae72b317ae253951b1acbcd937607bc)
+++ kernel/arch/arm32/include/mm/page.h	(revision fcfac2508fadfedd93f8fbbfaf6016d658cc03f6)
@@ -52,6 +52,4 @@
 #	define PA2KA(x)	((x) + 0x80000000)
 #endif
-
-#ifdef KERNEL
 
 /* Number of entries in each level. */
@@ -320,6 +318,4 @@
 #endif /* __ASM__ */
 
-#endif /* KERNEL */
-
 #endif
 
Index: kernel/arch/arm32/include/regutils.h
===================================================================
--- kernel/arch/arm32/include/regutils.h	(revision bee37cf38ae72b317ae253951b1acbcd937607bc)
+++ kernel/arch/arm32/include/regutils.h	(revision fcfac2508fadfedd93f8fbbfaf6016d658cc03f6)
@@ -30,5 +30,5 @@
  * @{
  */
-/** 
+/**
  * @file
  * @brief Utilities for convenient manipulation with ARM registers.
@@ -38,52 +38,49 @@
 #define KERN_arm32_REGUTILS_H_
 
-#define STATUS_REG_IRQ_DISABLED_BIT (1 << 7)
-#define STATUS_REG_MODE_MASK        0x1f
+#define STATUS_REG_IRQ_DISABLED_BIT  (1 << 7)
+#define STATUS_REG_MODE_MASK         0x1f
 
-#define CP15_R1_HIGH_VECTORS_BIT    (1 << 13)
-
+#define CP15_R1_HIGH_VECTORS_BIT     (1 << 13)
 
 /* ARM Processor Operation Modes */
-#define USER_MODE         0x10
-#define FIQ_MODE          0x11
-#define	IRQ_MODE          0x12
-#define	SUPERVISOR_MODE   0x13
-#define	ABORT_MODE        0x17
-#define	UNDEFINED_MODE    0x1b
-#define	SYSTEM_MODE       0x1f
+#define USER_MODE        0x10
+#define FIQ_MODE         0x11
+#define IRQ_MODE         0x12
+#define SUPERVISOR_MODE  0x13
+#define ABORT_MODE       0x17
+#define UNDEFINED_MODE   0x1b
+#define SYSTEM_MODE      0x1f
 
 /* [CS]PRS manipulation macros */
-#define GEN_STATUS_READ(nm,reg) \
-static inline uint32_t nm## _status_reg_read(void) \
-{ \
-	uint32_t retval; \
-	asm volatile( \
-		"mrs %[retval], " #reg \
-		: [retval] "=r" (retval) \
-	); \
-	return retval; \
-}
+#define GEN_STATUS_READ(nm, reg) \
+	static inline uint32_t nm## _status_reg_read(void) \
+	{ \
+		uint32_t retval; \
+		\
+		asm volatile ( \
+			"mrs %[retval], " #reg \
+			: [retval] "=r" (retval) \
+		); \
+		\
+		return retval; \
+	}
 
-#define GEN_STATUS_WRITE(nm,reg,fieldname, field) \
-static inline void nm## _status_reg_ ##fieldname## _write(uint32_t value) \
-{ \
-	asm volatile( \
-		"msr " #reg "_" #field ", %[value]" \
-		:: [value] "r" (value) \
-	); \
-}
+#define GEN_STATUS_WRITE(nm, reg, fieldname, field) \
+	static inline void nm## _status_reg_ ##fieldname## _write(uint32_t value) \
+	{ \
+		asm volatile ( \
+			"msr " #reg "_" #field ", %[value]" \
+			:: [value] "r" (value) \
+		); \
+	}
 
+/** Return the value of CPSR (Current Program Status Register). */
+GEN_STATUS_READ(current, cpsr);
 
-/** Returns the value of CPSR (Current Program Status Register). */
-GEN_STATUS_READ(current, cpsr)
-
-
-/** Sets control bits of CPSR. */
+/** Set control bits of CPSR. */
 GEN_STATUS_WRITE(current, cpsr, control, c);
 
-
-/** Returns the value of SPSR (Saved Program Status Register). */
-GEN_STATUS_READ(saved, spsr)
-
+/** Return the value of SPSR (Saved Program Status Register). */
+GEN_STATUS_READ(saved, spsr);
 
 #endif
Index: kernel/arch/arm32/src/arm32.c
===================================================================
--- kernel/arch/arm32/src/arm32.c	(revision bee37cf38ae72b317ae253951b1acbcd937607bc)
+++ kernel/arch/arm32/src/arm32.c	(revision fcfac2508fadfedd93f8fbbfaf6016d658cc03f6)
@@ -37,5 +37,5 @@
 #include <config.h>
 #include <genarch/fb/fb.h>
-#include <genarch/fb/visuals.h>
+#include <abi/fb/visuals.h>
 #include <sysinfo/sysinfo.h>
 #include <console/console.h>
Index: kernel/arch/arm32/src/mach/gta02/gta02.c
===================================================================
--- kernel/arch/arm32/src/mach/gta02/gta02.c	(revision bee37cf38ae72b317ae253951b1acbcd937607bc)
+++ kernel/arch/arm32/src/mach/gta02/gta02.c	(revision fcfac2508fadfedd93f8fbbfaf6016d658cc03f6)
@@ -39,5 +39,5 @@
 #include <mm/page.h>
 #include <genarch/fb/fb.h>
-#include <genarch/fb/visuals.h>
+#include <abi/fb/visuals.h>
 #include <genarch/drivers/s3c24xx_uart/s3c24xx_uart.h>
 #include <genarch/drivers/s3c24xx_irqc/s3c24xx_irqc.h>
Index: kernel/arch/arm32/src/mach/integratorcp/integratorcp.c
===================================================================
--- kernel/arch/arm32/src/mach/integratorcp/integratorcp.c	(revision bee37cf38ae72b317ae253951b1acbcd937607bc)
+++ kernel/arch/arm32/src/mach/integratorcp/integratorcp.c	(revision fcfac2508fadfedd93f8fbbfaf6016d658cc03f6)
@@ -48,5 +48,5 @@
 #include <arch/mach/integratorcp/integratorcp.h>
 #include <genarch/fb/fb.h>
-#include <genarch/fb/visuals.h>
+#include <abi/fb/visuals.h>
 #include <ddi/ddi.h>
 #include <print.h>
Index: kernel/arch/arm32/src/mach/testarm/testarm.c
===================================================================
--- kernel/arch/arm32/src/mach/testarm/testarm.c	(revision bee37cf38ae72b317ae253951b1acbcd937607bc)
+++ kernel/arch/arm32/src/mach/testarm/testarm.c	(revision fcfac2508fadfedd93f8fbbfaf6016d658cc03f6)
@@ -38,5 +38,5 @@
 #include <mm/page.h>
 #include <genarch/fb/fb.h>
-#include <genarch/fb/visuals.h>
+#include <abi/fb/visuals.h>
 #include <genarch/drivers/dsrln/dsrlnin.h>
 #include <genarch/drivers/dsrln/dsrlnout.h>
Index: kernel/arch/ia32/include/context.h
===================================================================
--- kernel/arch/ia32/include/context.h	(revision bee37cf38ae72b317ae253951b1acbcd937607bc)
+++ kernel/arch/ia32/include/context.h	(revision fcfac2508fadfedd93f8fbbfaf6016d658cc03f6)
@@ -36,6 +36,4 @@
 #define KERN_ia32_CONTEXT_H_
 
-#ifdef KERNEL
-
 #include <typedefs.h>
 
@@ -57,6 +55,4 @@
 	} while (0)
 
-#endif /* KERNEL */
-
 /*
  * Only save registers that must be preserved across
Index: kernel/arch/ia32/include/elf.h
===================================================================
--- kernel/arch/ia32/include/elf.h	(revision bee37cf38ae72b317ae253951b1acbcd937607bc)
+++ kernel/arch/ia32/include/elf.h	(revision fcfac2508fadfedd93f8fbbfaf6016d658cc03f6)
@@ -27,5 +27,5 @@
  */
 
-/** @addtogroup ia32	
+/** @addtogroup ia32
  * @{
  */
@@ -36,7 +36,7 @@
 #define KERN_ia32_ELF_H_
 
-#define	ELF_MACHINE		EM_386
-#define ELF_DATA_ENCODING	ELFDATA2LSB
-#define ELF_CLASS		ELFCLASS32
+#define ELF_MACHINE        EM_386
+#define ELF_DATA_ENCODING  ELFDATA2LSB
+#define ELF_CLASS          ELFCLASS32
 
 #endif
Index: kernel/arch/ia32/include/istate.h
===================================================================
--- kernel/arch/ia32/include/istate.h	(revision bee37cf38ae72b317ae253951b1acbcd937607bc)
+++ kernel/arch/ia32/include/istate.h	(revision fcfac2508fadfedd93f8fbbfaf6016d658cc03f6)
@@ -36,16 +36,5 @@
 #define KERN_ia32_ISTATE_H_
 
-#ifdef KERNEL
-
-#include <typedefs.h>
 #include <trace.h>
-
-#else /* KERNEL */
-
-#include <sys/types.h>
-
-#define NO_TRACE
-
-#endif /* KERNEL */
 
 typedef struct istate {
Index: kernel/arch/ia32/include/mm/frame.h
===================================================================
--- kernel/arch/ia32/include/mm/frame.h	(revision bee37cf38ae72b317ae253951b1acbcd937607bc)
+++ kernel/arch/ia32/include/mm/frame.h	(revision fcfac2508fadfedd93f8fbbfaf6016d658cc03f6)
@@ -39,5 +39,4 @@
 #define FRAME_SIZE   (1 << FRAME_WIDTH)
 
-#ifdef KERNEL
 #ifndef __ASM__
 
@@ -50,5 +49,4 @@
 
 #endif /* __ASM__ */
-#endif /* KERNEL */
 
 #endif
Index: kernel/arch/ia32/include/mm/page.h
===================================================================
--- kernel/arch/ia32/include/mm/page.h	(revision bee37cf38ae72b317ae253951b1acbcd937607bc)
+++ kernel/arch/ia32/include/mm/page.h	(revision fcfac2508fadfedd93f8fbbfaf6016d658cc03f6)
@@ -42,6 +42,4 @@
 #define PAGE_SIZE   FRAME_SIZE
 
-#ifdef KERNEL
-
 #ifndef __ASM__
 
@@ -201,6 +199,4 @@
 #endif /* __ASM__ */
 
-#endif /* KERNEL */
-
 #endif
 
Index: kernel/arch/ia32/src/drivers/vesa.c
===================================================================
--- kernel/arch/ia32/src/drivers/vesa.c	(revision bee37cf38ae72b317ae253951b1acbcd937607bc)
+++ kernel/arch/ia32/src/drivers/vesa.c	(revision fcfac2508fadfedd93f8fbbfaf6016d658cc03f6)
@@ -38,5 +38,4 @@
 
 #include <genarch/fb/fb.h>
-#include <genarch/fb/visuals.h>
 #include <arch/drivers/vesa.h>
 #include <console/chardev.h>
Index: kernel/arch/ia32/src/smp/smp.c
===================================================================
--- kernel/arch/ia32/src/smp/smp.c	(revision bee37cf38ae72b317ae253951b1acbcd937607bc)
+++ kernel/arch/ia32/src/smp/smp.c	(revision fcfac2508fadfedd93f8fbbfaf6016d658cc03f6)
@@ -42,5 +42,4 @@
 #include <config.h>
 #include <synch/waitq.h>
-#include <synch/synch.h>
 #include <arch/pm.h>
 #include <func.h>
Index: kernel/arch/ia32/src/userspace.c
===================================================================
--- kernel/arch/ia32/src/userspace.c	(revision bee37cf38ae72b317ae253951b1acbcd937607bc)
+++ kernel/arch/ia32/src/userspace.c	(revision fcfac2508fadfedd93f8fbbfaf6016d658cc03f6)
@@ -37,7 +37,6 @@
 #include <typedefs.h>
 #include <arch.h>
-#include <proc/uarg.h>
+#include <abi/proc/uarg.h>
 #include <mm/as.h>
-
 
 /** Enter userspace
Index: kernel/arch/ia64/include/elf.h
===================================================================
--- kernel/arch/ia64/include/elf.h	(revision bee37cf38ae72b317ae253951b1acbcd937607bc)
+++ kernel/arch/ia64/include/elf.h	(revision fcfac2508fadfedd93f8fbbfaf6016d658cc03f6)
@@ -27,5 +27,5 @@
  */
 
-/** @addtogroup ia64	
+/** @addtogroup ia64
  * @{
  */
@@ -36,7 +36,7 @@
 #define KERN_ia64_ELF_H_
 
-#define	ELF_MACHINE		EM_IA_64
-#define ELF_DATA_ENCODING	ELFDATA2LSB
-#define ELF_CLASS		ELFCLASS64
+#define ELF_MACHINE        EM_IA_64
+#define ELF_DATA_ENCODING  ELFDATA2LSB
+#define ELF_CLASS          ELFCLASS64
 
 #endif
Index: kernel/arch/ia64/include/istate.h
===================================================================
--- kernel/arch/ia64/include/istate.h	(revision bee37cf38ae72b317ae253951b1acbcd937607bc)
+++ kernel/arch/ia64/include/istate.h	(revision fcfac2508fadfedd93f8fbbfaf6016d658cc03f6)
@@ -36,13 +36,15 @@
 #define KERN_ia64_ISTATE_H_
 
+#include <trace.h>
+
+#ifdef KERNEL
+
 #include <arch/register.h>
 
-#ifdef KERNEL
-#include <typedefs.h>
-#include <trace.h>
-#else
-#include <sys/types.h>
-#define NO_TRACE
-#endif
+#else /* KERNEL */
+
+#include <libarch/register.h>
+
+#endif /* KERNEL */
 
 typedef struct istate {
Index: kernel/arch/ia64/include/mm/frame.h
===================================================================
--- kernel/arch/ia64/include/mm/frame.h	(revision bee37cf38ae72b317ae253951b1acbcd937607bc)
+++ kernel/arch/ia64/include/mm/frame.h	(revision fcfac2508fadfedd93f8fbbfaf6016d658cc03f6)
@@ -39,5 +39,4 @@
 #define FRAME_SIZE   (1 << FRAME_WIDTH)
 
-#ifdef KERNEL
 #ifndef __ASM__
 
@@ -50,5 +49,4 @@
 
 #endif /* __ASM__ */
-#endif /* KERNEL */
 
 #endif
Index: kernel/arch/ia64/include/mm/page.h
===================================================================
--- kernel/arch/ia64/include/mm/page.h	(revision bee37cf38ae72b317ae253951b1acbcd937607bc)
+++ kernel/arch/ia64/include/mm/page.h	(revision fcfac2508fadfedd93f8fbbfaf6016d658cc03f6)
@@ -41,6 +41,4 @@
 #define PAGE_SIZE   FRAME_SIZE
 #define PAGE_WIDTH  FRAME_WIDTH
-
-#ifdef KERNEL
 
 /** Bit width of the TLB-locked portion of kernel address space. */
@@ -316,6 +314,4 @@
 #endif /* __ASM__ */
 
-#endif /* KERNEL */
-
 #endif
 
Index: kernel/arch/ia64/include/register.h
===================================================================
--- kernel/arch/ia64/include/register.h	(revision bee37cf38ae72b317ae253951b1acbcd937607bc)
+++ kernel/arch/ia64/include/register.h	(revision fcfac2508fadfedd93f8fbbfaf6016d658cc03f6)
@@ -61,6 +61,6 @@
 #define PSR_CPL_MASK_SHIFTED  3
 
-#define PSR_RI_SHIFT	41
-#define PSR_RI_LEN	2
+#define PSR_RI_SHIFT  41
+#define PSR_RI_LEN    2
 
 #define PFM_MASK  (~0x3fffffffff)
@@ -145,10 +145,4 @@
 #ifndef __ASM__
 
-#ifdef KERNEL
-#include <typedefs.h>
-#else
-#include <sys/types.h>
-#endif
-
 /** Processor Status Register. */
 typedef union {
Index: kernel/arch/ia64/src/ia64.c
===================================================================
--- kernel/arch/ia64/src/ia64.c	(revision bee37cf38ae72b317ae253951b1acbcd937607bc)
+++ kernel/arch/ia64/src/ia64.c	(revision fcfac2508fadfedd93f8fbbfaf6016d658cc03f6)
@@ -50,5 +50,5 @@
 #include <userspace.h>
 #include <console/console.h>
-#include <proc/uarg.h>
+#include <abi/proc/uarg.h>
 #include <syscall/syscall.h>
 #include <ddi/irq.h>
Index: kernel/arch/mips32/include/context_offset.h
===================================================================
--- kernel/arch/mips32/include/context_offset.h	(revision bee37cf38ae72b317ae253951b1acbcd937607bc)
+++ kernel/arch/mips32/include/context_offset.h	(revision fcfac2508fadfedd93f8fbbfaf6016d658cc03f6)
@@ -63,119 +63,126 @@
 #ifdef __ASM__
 
+#ifdef KERNEL
+
 #include <arch/asm/regname.h>
 
-# ctx: address of the structure with saved context
+#else /* KERNEL */
+
+#include <libarch/regname.h>
+
+#endif /* KERNEL */
+
+/* ctx: address of the structure with saved context */
 .macro CONTEXT_SAVE_ARCH_CORE ctx:req
-	sw $s0,OFFSET_S0(\ctx)
-	sw $s1,OFFSET_S1(\ctx)
-	sw $s2,OFFSET_S2(\ctx)
-	sw $s3,OFFSET_S3(\ctx)
-	sw $s4,OFFSET_S4(\ctx)
-	sw $s5,OFFSET_S5(\ctx)
-	sw $s6,OFFSET_S6(\ctx)
-	sw $s7,OFFSET_S7(\ctx)
-	sw $s8,OFFSET_S8(\ctx)
-	sw $gp,OFFSET_GP(\ctx)
-
+	sw $s0, OFFSET_S0(\ctx)
+	sw $s1, OFFSET_S1(\ctx)
+	sw $s2, OFFSET_S2(\ctx)
+	sw $s3, OFFSET_S3(\ctx)
+	sw $s4, OFFSET_S4(\ctx)
+	sw $s5, OFFSET_S5(\ctx)
+	sw $s6, OFFSET_S6(\ctx)
+	sw $s7, OFFSET_S7(\ctx)
+	sw $s8, OFFSET_S8(\ctx)
+	sw $gp, OFFSET_GP(\ctx)
+	
 #ifndef KERNEL
-	sw $k1,OFFSET_TLS(\ctx)
-
+	sw $k1, OFFSET_TLS(\ctx)
+	
 #ifdef CONFIG_FPU
-	mfc1 $t0,$20
+	mfc1 $t0, $20
 	sw $t0, OFFSET_F20(\ctx)
-
-	mfc1 $t0,$21
+	
+	mfc1 $t0, $21
 	sw $t0, OFFSET_F21(\ctx)
-
-	mfc1 $t0,$22
+	
+	mfc1 $t0, $22
 	sw $t0, OFFSET_F22(\ctx)
-
-	mfc1 $t0,$23
+	
+	mfc1 $t0, $23
 	sw $t0, OFFSET_F23(\ctx)
-
-	mfc1 $t0,$24
+	
+	mfc1 $t0, $24
 	sw $t0, OFFSET_F24(\ctx)
-
-	mfc1 $t0,$25
+	
+	mfc1 $t0, $25
 	sw $t0, OFFSET_F25(\ctx)
-
-	mfc1 $t0,$26
+	
+	mfc1 $t0, $26
 	sw $t0, OFFSET_F26(\ctx)
-
-	mfc1 $t0,$27
+	
+	mfc1 $t0, $27
 	sw $t0, OFFSET_F27(\ctx)
-
-	mfc1 $t0,$28
+	
+	mfc1 $t0, $28
 	sw $t0, OFFSET_F28(\ctx)
-
-	mfc1 $t0,$29
+	
+	mfc1 $t0, $29
 	sw $t0, OFFSET_F29(\ctx)
 	
-	mfc1 $t0,$30
+	mfc1 $t0, $30
 	sw $t0, OFFSET_F30(\ctx)
 #endif /* CONFIG_FPU */
 #endif /* KERNEL */
-
-	sw $ra,OFFSET_PC(\ctx)
-	sw $sp,OFFSET_SP(\ctx)
+	
+	sw $ra, OFFSET_PC(\ctx)
+	sw $sp, OFFSET_SP(\ctx)
 .endm
 
-# ctx: address of the structure with saved context
+/* ctx: address of the structure with saved context */
 .macro CONTEXT_RESTORE_ARCH_CORE ctx:req
-	lw $s0,OFFSET_S0(\ctx)
-	lw $s1,OFFSET_S1(\ctx)
-	lw $s2,OFFSET_S2(\ctx)
-	lw $s3,OFFSET_S3(\ctx)
-	lw $s4,OFFSET_S4(\ctx)
-	lw $s5,OFFSET_S5(\ctx)
-	lw $s6,OFFSET_S6(\ctx)
-	lw $s7,OFFSET_S7(\ctx)
-	lw $s8,OFFSET_S8(\ctx)
-	lw $gp,OFFSET_GP(\ctx)
+	lw $s0, OFFSET_S0(\ctx)
+	lw $s1, OFFSET_S1(\ctx)
+	lw $s2, OFFSET_S2(\ctx)
+	lw $s3, OFFSET_S3(\ctx)
+	lw $s4, OFFSET_S4(\ctx)
+	lw $s5, OFFSET_S5(\ctx)
+	lw $s6, OFFSET_S6(\ctx)
+	lw $s7, OFFSET_S7(\ctx)
+	lw $s8, OFFSET_S8(\ctx)
+	lw $gp, OFFSET_GP(\ctx)
 #ifndef KERNEL
-	lw $k1,OFFSET_TLS(\ctx)
-
+	lw $k1, OFFSET_TLS(\ctx)
+	
 #ifdef CONFIG_FPU
 	lw $t0, OFFSET_F20(\ctx)
-	mtc1 $t0,$20
-
+	mtc1 $t0, $20
+	
 	lw $t0, OFFSET_F21(\ctx)
-	mtc1 $t0,$21
-
+	mtc1 $t0, $21
+	
 	lw $t0, OFFSET_F22(\ctx)
-	mtc1 $t0,$22
-
+	mtc1 $t0, $22
+	
 	lw $t0, OFFSET_F23(\ctx)
-	mtc1 $t0,$23
-
+	mtc1 $t0, $23
+	
 	lw $t0, OFFSET_F24(\ctx)
-	mtc1 $t0,$24
-
+	mtc1 $t0, $24
+	
 	lw $t0, OFFSET_F25(\ctx)
-	mtc1 $t0,$25
-
+	mtc1 $t0, $25
+	
 	lw $t0, OFFSET_F26(\ctx)
-	mtc1 $t0,$26
-
+	mtc1 $t0, $26
+	
 	lw $t0, OFFSET_F27(\ctx)
-	mtc1 $t0,$27
-
+	mtc1 $t0, $27
+	
 	lw $t0, OFFSET_F28(\ctx)
-	mtc1 $t0,$28
-
+	mtc1 $t0, $28
+	
 	lw $t0, OFFSET_F29(\ctx)
-	mtc1 $t0,$29
-
+	mtc1 $t0, $29
+	
 	lw $t0, OFFSET_F30(\ctx)
-	mtc1 $t0,$30
+	mtc1 $t0, $30
 #endif /* CONFIG_FPU */
 #endif /* KERNEL */
-
-	lw $ra,OFFSET_PC(\ctx)
-	lw $sp,OFFSET_SP(\ctx)
+	
+	lw $ra, OFFSET_PC(\ctx)
+	lw $sp, OFFSET_SP(\ctx)
 .endm
 
-#endif
-
+#endif /* __ASM__ */
 
 #endif
Index: kernel/arch/mips32/include/cp0.h
===================================================================
--- kernel/arch/mips32/include/cp0.h	(revision bee37cf38ae72b317ae253951b1acbcd937607bc)
+++ kernel/arch/mips32/include/cp0.h	(revision fcfac2508fadfedd93f8fbbfaf6016d658cc03f6)
@@ -36,10 +36,4 @@
 #define KERN_mips32_CP0_H_
 
-#ifdef KERNEL
-#include <typedefs.h>
-#else
-#include <sys/types.h>
-#endif
-
 #define cp0_status_ie_enabled_bit     (1 << 0)
 #define cp0_status_exl_exception_bit  (1 << 1)
@@ -49,33 +43,50 @@
 #define cp0_status_fpu_bit            (1 << 29)
 
-#define cp0_status_im_shift		8
-#define cp0_status_im_mask              0xff00
+#define cp0_status_im_shift  8
+#define cp0_status_im_mask   0xff00
 
-#define cp0_cause_excno(cause) ((cause >> 2) & 0x1f)
-#define cp0_cause_coperr(cause) ((cause >> 28) & 0x3)
+#define cp0_cause_excno(cause)   ((cause >> 2) & 0x1f)
+#define cp0_cause_coperr(cause)  ((cause >> 28) & 0x3)
 
-#define fpu_cop_id 1
+#define fpu_cop_id  1
 
 /*
  * Magic value for use in msim.
  */
-#define cp0_compare_value 		100000
+#define cp0_compare_value  100000
 
-#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_all_int() \
+	cp0_status_write(cp0_status_read() & ~(cp0_status_im_mask))
 
-#define GEN_READ_CP0(nm,reg) static inline uint32_t cp0_ ##nm##_read(void) \
-  { \
-      uint32_t retval; \
-      asm volatile ("mfc0 %0, $" #reg : "=r"(retval)); \
-      return retval; \
-  }
+#define cp0_unmask_all_int() \
+	cp0_status_write(cp0_status_read() | cp0_status_im_mask)
 
-#define GEN_WRITE_CP0(nm,reg) static inline void cp0_ ##nm##_write(uint32_t val) \
- { \
-    asm volatile ("mtc0 %0, $" #reg : : "r"(val) ); \
- }
+#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) \
+	{ \
+		uint32_t retval; \
+		\
+		asm volatile ( \
+			"mfc0 %0, $" #reg \
+			: "=r"(retval) \
+		); \
+		\
+		return retval; \
+	}
+
+#define GEN_WRITE_CP0(nm, reg) \
+	static inline void cp0_ ##nm##_write(uint32_t val) \
+	{ \
+		asm volatile ( \
+			"mtc0 %0, $" #reg \
+			:: "r"(val) \
+		); \
+	}
 
 GEN_READ_CP0(index, 0);
Index: kernel/arch/mips32/include/istate.h
===================================================================
--- kernel/arch/mips32/include/istate.h	(revision bee37cf38ae72b317ae253951b1acbcd937607bc)
+++ kernel/arch/mips32/include/istate.h	(revision fcfac2508fadfedd93f8fbbfaf6016d658cc03f6)
@@ -36,13 +36,15 @@
 #define KERN_mips32_ISTATE_H_
 
+#include <trace.h>
+
+#ifdef KERNEL
+
 #include <arch/cp0.h>
 
-#ifdef KERNEL
-#include <typedefs.h>
-#include <trace.h>
-#else
-#include <sys/types.h>
-#define NO_TRACE
-#endif
+#else /* KERNEL */
+
+#include <libarch/cp0.h>
+
+#endif /* KERNEL */
 
 typedef struct istate {
Index: kernel/arch/mips32/include/mm/frame.h
===================================================================
--- kernel/arch/mips32/include/mm/frame.h	(revision bee37cf38ae72b317ae253951b1acbcd937607bc)
+++ kernel/arch/mips32/include/mm/frame.h	(revision fcfac2508fadfedd93f8fbbfaf6016d658cc03f6)
@@ -39,5 +39,4 @@
 #define FRAME_SIZE   (1 << FRAME_WIDTH)
 
-#ifdef KERNEL
 #ifndef __ASM__
 
@@ -46,5 +45,4 @@
 
 #endif /* __ASM__ */
-#endif /* KERNEL */
 
 #endif
Index: kernel/arch/mips32/include/mm/page.h
===================================================================
--- kernel/arch/mips32/include/mm/page.h	(revision bee37cf38ae72b317ae253951b1acbcd937607bc)
+++ kernel/arch/mips32/include/mm/page.h	(revision fcfac2508fadfedd93f8fbbfaf6016d658cc03f6)
@@ -49,6 +49,4 @@
 #	define PA2KA(x)	((x) + 0x80000000)
 #endif
-
-#ifdef KERNEL
 
 /*
@@ -188,6 +186,4 @@
 #endif /* __ASM__ */
 
-#endif /* KERNEL */
-
 #endif
 
Index: kernel/arch/mips32/src/mips32.c
===================================================================
--- kernel/arch/mips32/src/mips32.c	(revision bee37cf38ae72b317ae253951b1acbcd937607bc)
+++ kernel/arch/mips32/src/mips32.c	(revision fcfac2508fadfedd93f8fbbfaf6016d658cc03f6)
@@ -41,5 +41,5 @@
 #include <memstr.h>
 #include <proc/thread.h>
-#include <proc/uarg.h>
+#include <abi/proc/uarg.h>
 #include <print.h>
 #include <console/console.h>
@@ -52,5 +52,5 @@
 #include <arch/debugger.h>
 #include <genarch/fb/fb.h>
-#include <genarch/fb/visuals.h>
+#include <abi/fb/visuals.h>
 #include <genarch/drivers/dsrln/dsrlnin.h>
 #include <genarch/drivers/dsrln/dsrlnout.h>
Index: kernel/arch/mips64/include/context_offset.h
===================================================================
--- kernel/arch/mips64/include/context_offset.h	(revision bee37cf38ae72b317ae253951b1acbcd937607bc)
+++ kernel/arch/mips64/include/context_offset.h	(revision fcfac2508fadfedd93f8fbbfaf6016d658cc03f6)
@@ -63,7 +63,15 @@
 #ifdef __ASM__
 
+#ifdef KERNEL
+
 #include <arch/asm/regname.h>
 
-# ctx: address of the structure with saved context
+#else /* KERNEL */
+
+#include <libarch/regname.h>
+
+#endif /* KERNEL */
+
+/* ctx: address of the structure with saved context */
 .macro CONTEXT_SAVE_ARCH_CORE ctx:req
 	sd $s0, OFFSET_S0(\ctx)
@@ -121,5 +129,5 @@
 .endm
 
-# ctx: address of the structure with saved context
+/* ctx: address of the structure with saved context */
 .macro CONTEXT_RESTORE_ARCH_CORE ctx:req
 	ld $s0, OFFSET_S0(\ctx)
Index: kernel/arch/mips64/include/cp0.h
===================================================================
--- kernel/arch/mips64/include/cp0.h	(revision bee37cf38ae72b317ae253951b1acbcd937607bc)
+++ kernel/arch/mips64/include/cp0.h	(revision fcfac2508fadfedd93f8fbbfaf6016d658cc03f6)
@@ -35,14 +35,4 @@
 #ifndef KERN_mips64_CP0_H_
 #define KERN_mips64_CP0_H_
-
-#ifdef KERNEL
-
-#include <typedefs.h>
-
-#else
-
-#include <sys/types.h>
-
-#endif
 
 #define cp0_status_ie_enabled_bit     (1 << 0)
Index: kernel/arch/mips64/include/istate.h
===================================================================
--- kernel/arch/mips64/include/istate.h	(revision bee37cf38ae72b317ae253951b1acbcd937607bc)
+++ kernel/arch/mips64/include/istate.h	(revision fcfac2508fadfedd93f8fbbfaf6016d658cc03f6)
@@ -36,17 +36,15 @@
 #define KERN_mips64_ISTATE_H_
 
-#include <arch/cp0.h>
+#include <trace.h>
 
 #ifdef KERNEL
 
-#include <typedefs.h>
-#include <trace.h>
+#include <arch/cp0.h>
 
-#else
+#else /* KERNEL */
 
-#include <sys/types.h>
-#define NO_TRACE
+#include <libarch/cp0.h>
 
-#endif
+#endif /* KERNEL */
 
 typedef struct istate {
Index: kernel/arch/mips64/include/mm/frame.h
===================================================================
--- kernel/arch/mips64/include/mm/frame.h	(revision bee37cf38ae72b317ae253951b1acbcd937607bc)
+++ kernel/arch/mips64/include/mm/frame.h	(revision fcfac2508fadfedd93f8fbbfaf6016d658cc03f6)
@@ -39,5 +39,4 @@
 #define FRAME_SIZE   (1 << FRAME_WIDTH)
 
-#ifdef KERNEL
 #ifndef __ASM__
 
@@ -46,5 +45,4 @@
 
 #endif /* __ASM__ */
-#endif /* KERNEL */
 
 #endif
Index: kernel/arch/mips64/include/mm/page.h
===================================================================
--- kernel/arch/mips64/include/mm/page.h	(revision bee37cf38ae72b317ae253951b1acbcd937607bc)
+++ kernel/arch/mips64/include/mm/page.h	(revision fcfac2508fadfedd93f8fbbfaf6016d658cc03f6)
@@ -50,5 +50,4 @@
 #endif
 
-#ifdef KERNEL
 #ifndef __ASM__
 
@@ -56,5 +55,4 @@
 
 #endif /* __ASM__ */
-#endif /* KERNEL */
 
 #endif
Index: kernel/arch/mips64/src/mips64.c
===================================================================
--- kernel/arch/mips64/src/mips64.c	(revision bee37cf38ae72b317ae253951b1acbcd937607bc)
+++ kernel/arch/mips64/src/mips64.c	(revision fcfac2508fadfedd93f8fbbfaf6016d658cc03f6)
@@ -41,5 +41,5 @@
 #include <memstr.h>
 #include <proc/thread.h>
-#include <proc/uarg.h>
+#include <abi/proc/uarg.h>
 #include <print.h>
 #include <console/console.h>
@@ -52,5 +52,5 @@
 #include <arch/debugger.h>
 #include <genarch/fb/fb.h>
-#include <genarch/fb/visuals.h>
+#include <abi/fb/visuals.h>
 #include <genarch/drivers/dsrln/dsrlnin.h>
 #include <genarch/drivers/dsrln/dsrlnout.h>
Index: kernel/arch/ppc32/include/asm.h
===================================================================
--- kernel/arch/ppc32/include/asm.h	(revision bee37cf38ae72b317ae253951b1acbcd937607bc)
+++ kernel/arch/ppc32/include/asm.h	(revision fcfac2508fadfedd93f8fbbfaf6016d658cc03f6)
@@ -38,5 +38,5 @@
 #include <typedefs.h>
 #include <config.h>
-#include <arch/cpu.h>
+#include <arch/msr.h>
 #include <arch/mm/asid.h>
 #include <trace.h>
Index: kernel/arch/ppc32/include/context_offset.h
===================================================================
--- kernel/arch/ppc32/include/context_offset.h	(revision bee37cf38ae72b317ae253951b1acbcd937607bc)
+++ kernel/arch/ppc32/include/context_offset.h	(revision fcfac2508fadfedd93f8fbbfaf6016d658cc03f6)
@@ -75,7 +75,16 @@
 
 #ifdef __ASM__
-# include <arch/asm/regname.h>
 
-# ctx: address of the structure with saved context
+#ifdef KERNEL
+
+#include <arch/asm/regname.h>
+
+#else /* KERNEL */
+
+#include <libarch/regname.h>
+
+#endif /* KERNEL */
+
+/* ctx: address of the structure with saved context */
 .macro CONTEXT_SAVE_ARCH_CORE ctx:req
 	stw sp, OFFSET_SP(\ctx)
@@ -102,5 +111,5 @@
 .endm
 
-# ctx: address of the structure with saved context
+/* ctx: address of the structure with saved context */
 .macro CONTEXT_RESTORE_ARCH_CORE ctx:req
 	lwz sp, OFFSET_SP(\ctx)
Index: kernel/arch/ppc32/include/cpu.h
===================================================================
--- kernel/arch/ppc32/include/cpu.h	(revision bee37cf38ae72b317ae253951b1acbcd937607bc)
+++ kernel/arch/ppc32/include/cpu.h	(revision fcfac2508fadfedd93f8fbbfaf6016d658cc03f6)
@@ -36,19 +36,4 @@
 #define KERN_ppc32_CPU_H_
 
-/* MSR bits */
-#define MSR_DR  (1 << 4)
-#define MSR_IR  (1 << 5)
-#define MSR_PR  (1 << 14)
-#define MSR_EE  (1 << 15)
-
-/* HID0 bits */
-#define HID0_STEN  (1 << 24)
-#define HID0_ICE   (1 << 15)
-#define HID0_DCE   (1 << 14)
-#define HID0_ICFI  (1 << 11)
-#define HID0_DCI   (1 << 10)
-
-#ifndef __ASM__
-
 #include <typedefs.h>
 #include <trace.h>
@@ -67,6 +52,4 @@
 }
 
-#endif /* __ASM__ */
-
 #endif
 
Index: kernel/arch/ppc32/include/exception.h
===================================================================
--- kernel/arch/ppc32/include/exception.h	(revision bee37cf38ae72b317ae253951b1acbcd937607bc)
+++ kernel/arch/ppc32/include/exception.h	(revision fcfac2508fadfedd93f8fbbfaf6016d658cc03f6)
@@ -37,5 +37,5 @@
 
 #include <typedefs.h>
-#include <arch/cpu.h>
+#include <arch/msr.h>
 #include <trace.h>
 
Index: kernel/arch/ppc32/include/istate.h
===================================================================
--- kernel/arch/ppc32/include/istate.h	(revision bee37cf38ae72b317ae253951b1acbcd937607bc)
+++ kernel/arch/ppc32/include/istate.h	(revision fcfac2508fadfedd93f8fbbfaf6016d658cc03f6)
@@ -36,7 +36,15 @@
 #define KERN_ppc32_EXCEPTION_H_
 
-#include <typedefs.h>
-#include <arch/cpu.h>
 #include <trace.h>
+
+#ifdef KERNEL
+
+#include <arch/msr.h>
+
+#else /* KERNEL */
+
+#include <libarch/msr.h>
+
+#endif /* KERNEL */
 
 typedef struct istate {
Index: kernel/arch/ppc32/include/mm/frame.h
===================================================================
--- kernel/arch/ppc32/include/mm/frame.h	(revision bee37cf38ae72b317ae253951b1acbcd937607bc)
+++ kernel/arch/ppc32/include/mm/frame.h	(revision fcfac2508fadfedd93f8fbbfaf6016d658cc03f6)
@@ -39,5 +39,4 @@
 #define FRAME_SIZE   (1 << FRAME_WIDTH)
 
-#ifdef KERNEL
 #ifndef __ASM__
 
@@ -63,5 +62,4 @@
 
 #endif /* __ASM__ */
-#endif /* KERNEL */
 
 #endif
Index: kernel/arch/ppc32/include/mm/page.h
===================================================================
--- kernel/arch/ppc32/include/mm/page.h	(revision bee37cf38ae72b317ae253951b1acbcd937607bc)
+++ kernel/arch/ppc32/include/mm/page.h	(revision fcfac2508fadfedd93f8fbbfaf6016d658cc03f6)
@@ -41,6 +41,4 @@
 #define PAGE_WIDTH  FRAME_WIDTH
 #define PAGE_SIZE   FRAME_SIZE
-
-#ifdef KERNEL
 
 #ifndef __ASM__
@@ -181,6 +179,4 @@
 #endif /* __ASM__ */
 
-#endif /* KERNEL */
-
 #endif
 
Index: kernel/arch/ppc32/include/msr.h
===================================================================
--- kernel/arch/ppc32/include/msr.h	(revision fcfac2508fadfedd93f8fbbfaf6016d658cc03f6)
+++ kernel/arch/ppc32/include/msr.h	(revision fcfac2508fadfedd93f8fbbfaf6016d658cc03f6)
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 2005 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 ppc32
+ * @{
+ */
+/** @file
+ */
+
+#ifndef KERN_ppc32_MSR_H_
+#define KERN_ppc32_MSR_H_
+
+/* MSR bits */
+#define MSR_DR  (1 << 4)
+#define MSR_IR  (1 << 5)
+#define MSR_PR  (1 << 14)
+#define MSR_EE  (1 << 15)
+
+/* HID0 bits */
+#define HID0_STEN  (1 << 24)
+#define HID0_ICE   (1 << 15)
+#define HID0_DCE   (1 << 14)
+#define HID0_ICFI  (1 << 11)
+#define HID0_DCI   (1 << 10)
+
+#endif
+
+/** @}
+ */
Index: kernel/arch/ppc32/src/asm.S
===================================================================
--- kernel/arch/ppc32/src/asm.S	(revision bee37cf38ae72b317ae253951b1acbcd937607bc)
+++ kernel/arch/ppc32/src/asm.S	(revision fcfac2508fadfedd93f8fbbfaf6016d658cc03f6)
@@ -28,5 +28,5 @@
 
 #include <arch/asm/regname.h>
-#include <arch/cpu.h>
+#include <arch/msr.h>
 
 .text
Index: kernel/arch/ppc32/src/exception.S
===================================================================
--- kernel/arch/ppc32/src/exception.S	(revision bee37cf38ae72b317ae253951b1acbcd937607bc)
+++ kernel/arch/ppc32/src/exception.S	(revision fcfac2508fadfedd93f8fbbfaf6016d658cc03f6)
@@ -28,5 +28,5 @@
 
 #include <arch/asm/regname.h>
-#include <arch/cpu.h>
+#include <arch/msr.h>
 #include <arch/mm/page.h>
 
Index: kernel/arch/ppc32/src/ppc32.c
===================================================================
--- kernel/arch/ppc32/src/ppc32.c	(revision bee37cf38ae72b317ae253951b1acbcd937607bc)
+++ kernel/arch/ppc32/src/ppc32.c	(revision fcfac2508fadfedd93f8fbbfaf6016d658cc03f6)
@@ -41,10 +41,10 @@
 #include <interrupt.h>
 #include <genarch/fb/fb.h>
-#include <genarch/fb/visuals.h>
+#include <abi/fb/visuals.h>
 #include <genarch/ofw/ofw_tree.h>
 #include <genarch/ofw/pci.h>
 #include <userspace.h>
 #include <mm/page.h>
-#include <proc/uarg.h>
+#include <abi/proc/uarg.h>
 #include <console/console.h>
 #include <sysinfo/sysinfo.h>
Index: kernel/arch/sparc64/include/barrier.h
===================================================================
--- kernel/arch/sparc64/include/barrier.h	(revision bee37cf38ae72b317ae253951b1acbcd937607bc)
+++ kernel/arch/sparc64/include/barrier.h	(revision fcfac2508fadfedd93f8fbbfaf6016d658cc03f6)
@@ -37,14 +37,4 @@
 
 #include <trace.h>
-
-#ifdef KERNEL
-
-#include <typedefs.h>
-
-#else
-
-#include <stdint.h>
-
-#endif
 
 /*
Index: kernel/arch/sparc64/include/elf.h
===================================================================
--- kernel/arch/sparc64/include/elf.h	(revision bee37cf38ae72b317ae253951b1acbcd937607bc)
+++ kernel/arch/sparc64/include/elf.h	(revision fcfac2508fadfedd93f8fbbfaf6016d658cc03f6)
@@ -27,5 +27,5 @@
  */
 
-/** @addtogroup sparc64	
+/** @addtogroup sparc64
  * @{
  */
@@ -36,7 +36,7 @@
 #define KERN_sparc64_ELF_H_
 
-#define	ELF_MACHINE		EM_SPARCV9
-#define ELF_DATA_ENCODING	ELFDATA2MSB
-#define ELF_CLASS		ELFCLASS64
+#define ELF_MACHINE        EM_SPARCV9
+#define ELF_DATA_ENCODING  ELFDATA2MSB
+#define ELF_CLASS          ELFCLASS64
 
 #endif
Index: kernel/arch/sparc64/include/istate.h
===================================================================
--- kernel/arch/sparc64/include/istate.h	(revision bee37cf38ae72b317ae253951b1acbcd937607bc)
+++ kernel/arch/sparc64/include/istate.h	(revision fcfac2508fadfedd93f8fbbfaf6016d658cc03f6)
@@ -37,13 +37,15 @@
 #define KERN_sparc64_ISTATE_H_
 
+#include <trace.h>
+
+#ifdef KERNEL
+
 #include <arch/regdef.h>
 
-#ifdef KERNEL
-#include <typedefs.h>
-#include <trace.h>
-#else
-#include <sys/types.h>
-#define NO_TRACE
-#endif
+#else /* KERNEL */
+
+#include <libarch/regdef.h>
+
+#endif /* KERNEL */
 
 typedef struct istate {
Index: kernel/arch/sparc64/include/mm/page.h
===================================================================
--- kernel/arch/sparc64/include/mm/page.h	(revision bee37cf38ae72b317ae253951b1acbcd937607bc)
+++ kernel/arch/sparc64/include/mm/page.h	(revision fcfac2508fadfedd93f8fbbfaf6016d658cc03f6)
@@ -54,6 +54,4 @@
 #define MMU_PAGES_PER_PAGE	(1 << (PAGE_WIDTH - MMU_PAGE_WIDTH))
 
-#ifdef KERNEL
-
 #ifndef __ASM__
 
@@ -77,6 +75,4 @@
 #endif /* !def __ASM__ */
 
-#endif /* KERNEL */
-
 #endif
 
Index: kernel/arch/sparc64/include/mm/sun4u/frame.h
===================================================================
--- kernel/arch/sparc64/include/mm/sun4u/frame.h	(revision bee37cf38ae72b317ae253951b1acbcd937607bc)
+++ kernel/arch/sparc64/include/mm/sun4u/frame.h	(revision fcfac2508fadfedd93f8fbbfaf6016d658cc03f6)
@@ -52,5 +52,4 @@
 #define FRAME_SIZE		(1 << FRAME_WIDTH)
 
-#ifdef KERNEL
 #ifndef __ASM__
 
@@ -80,5 +79,4 @@
 
 #endif
-#endif
 
 #endif
Index: kernel/arch/sparc64/include/mm/sun4v/frame.h
===================================================================
--- kernel/arch/sparc64/include/mm/sun4v/frame.h	(revision bee37cf38ae72b317ae253951b1acbcd937607bc)
+++ kernel/arch/sparc64/include/mm/sun4v/frame.h	(revision fcfac2508fadfedd93f8fbbfaf6016d658cc03f6)
@@ -42,5 +42,4 @@
 #define FRAME_SIZE		(1 << FRAME_WIDTH)
 
-#ifdef KERNEL
 #ifndef __ASM__
 
@@ -52,5 +51,4 @@
 
 #endif
-#endif
 
 #endif
Index: kernel/arch/sparc64/include/mm/sun4v/page.h
===================================================================
--- kernel/arch/sparc64/include/mm/sun4v/page.h	(revision bee37cf38ae72b317ae253951b1acbcd937607bc)
+++ kernel/arch/sparc64/include/mm/sun4v/page.h	(revision fcfac2508fadfedd93f8fbbfaf6016d658cc03f6)
@@ -46,6 +46,4 @@
 #define MMU_PAGES_PER_PAGE	(1 << (PAGE_WIDTH - MMU_PAGE_WIDTH))
 
-#ifdef KERNEL
-
 #ifndef __ASM__
 
@@ -69,6 +67,4 @@
 #endif /* !def __ASM__ */
 
-#endif /* KERNEL */
-
 #endif
 
Index: kernel/arch/sparc64/include/sun4v/regdef.h
===================================================================
--- kernel/arch/sparc64/include/sun4v/regdef.h	(revision bee37cf38ae72b317ae253951b1acbcd937607bc)
+++ kernel/arch/sparc64/include/sun4v/regdef.h	(revision fcfac2508fadfedd93f8fbbfaf6016d658cc03f6)
@@ -28,5 +28,5 @@
  */
 
-/** @addtogroup sparc64	
+/** @addtogroup sparc64
  * @{
  */
@@ -37,17 +37,8 @@
 #define KERN_sparc64_sun4v_REGDEF_H_
 
-#define PSTATE_IE_BIT	(1 << 1)
-#define PSTATE_PRIV_BIT	(1 << 2)
-#define PSTATE_PEF_BIT	(1 << 4)
+#define TSTATE_CWP_MASK  0x1f
 
-#define TSTATE_PSTATE_SHIFT	8
-#define TSTATE_PRIV_BIT		(PSTATE_PRIV_BIT << TSTATE_PSTATE_SHIFT)
-#define TSTATE_CWP_MASK		0x1f
-#define TSTATE_IE_BIT		(PSTATE_IE_BIT << TSTATE_PSTATE_SHIFT)
-
-#define WSTATE_NORMAL(n)	(n)
-#define WSTATE_OTHER(n)		((n) << 3)
-
-#define TSTATE_PEF_BIT		(PSTATE_PEF_BIT << TSTATE_PSTATE_SHIFT)
+#define WSTATE_NORMAL(n)  (n)
+#define WSTATE_OTHER(n)   ((n) << 3)
 
 #endif
Index: kernel/arch/sparc64/src/drivers/scr.c
===================================================================
--- kernel/arch/sparc64/src/drivers/scr.c	(revision bee37cf38ae72b317ae253951b1acbcd937607bc)
+++ kernel/arch/sparc64/src/drivers/scr.c	(revision fcfac2508fadfedd93f8fbbfaf6016d658cc03f6)
@@ -39,5 +39,5 @@
 #include <genarch/ofw/upa.h>
 #include <genarch/fb/fb.h>
-#include <genarch/fb/visuals.h>
+#include <abi/fb/visuals.h>
 #include <console/chardev.h>
 #include <console/console.h>
Index: kernel/arch/sparc64/src/smp/sun4u/smp.c
===================================================================
--- kernel/arch/sparc64/src/smp/sun4u/smp.c	(revision bee37cf38ae72b317ae253951b1acbcd937607bc)
+++ kernel/arch/sparc64/src/smp/sun4u/smp.c	(revision fcfac2508fadfedd93f8fbbfaf6016d658cc03f6)
@@ -42,5 +42,4 @@
 #include <macros.h>
 #include <typedefs.h>
-#include <synch/synch.h>
 #include <synch/waitq.h>
 #include <print.h>
Index: kernel/arch/sparc64/src/smp/sun4v/smp.c
===================================================================
--- kernel/arch/sparc64/src/smp/sun4v/smp.c	(revision bee37cf38ae72b317ae253951b1acbcd937607bc)
+++ kernel/arch/sparc64/src/smp/sun4v/smp.c	(revision fcfac2508fadfedd93f8fbbfaf6016d658cc03f6)
@@ -45,5 +45,4 @@
 #include <func.h>
 #include <typedefs.h>
-#include <synch/synch.h>
 #include <synch/waitq.h>
 #include <print.h>
Index: kernel/arch/sparc64/src/sun4v/start.S
===================================================================
--- kernel/arch/sparc64/src/sun4v/start.S	(revision bee37cf38ae72b317ae253951b1acbcd937607bc)
+++ kernel/arch/sparc64/src/sun4v/start.S	(revision fcfac2508fadfedd93f8fbbfaf6016d658cc03f6)
@@ -30,4 +30,5 @@
 #include <arch/arch.h>
 #include <arch/stack.h>
+#include <arch/regdef.h>
 #include <arch/context_offset.h>
 #include <arch/sun4v/regdef.h>
