Index: generic/include/console/klog.h
===================================================================
--- generic/include/console/klog.h	(revision a175a672ae67972fd0aeeaae855819ca1135ee7c)
+++ generic/include/console/klog.h	(revision a175a672ae67972fd0aeeaae855819ca1135ee7c)
@@ -0,0 +1,35 @@
+/*
+ * Copyright (C) 2006 Ondrej Palkovsky
+ * 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.
+ */
+
+#ifndef _KLOG_H_
+#define _KLOG_H_
+
+void klog_init(void);
+void klog_printf(const char *fmt, ...);
+
+#endif
Index: generic/include/interrupt.h
===================================================================
--- generic/include/interrupt.h	(revision d8f7362433d8362e6786d4323938f5439281167a)
+++ generic/include/interrupt.h	(revision a175a672ae67972fd0aeeaae855819ca1135ee7c)
@@ -33,4 +33,9 @@
 #include <typedefs.h>
 #include <arch/types.h>
+#include <proc/task.h>
+#include <proc/thread.h>
+#include <arch.h>
+#include <console/klog.h>
+#include <ipc/irq.h>
 
 #ifndef IVT_ITEMS
@@ -42,4 +47,15 @@
 #endif
 
+#define fault_if_from_uspace(istate, cmd, ...) \
+{ \
+	if (istate_from_uspace(istate)) { \
+                klog_printf(cmd, ##__VA_ARGS__); \
+                klog_printf("Task %lld got exception at PC:%P. Task killed.", TASK->taskid, istate_get_pc(istate)); \
+		task_kill(TASK->taskid); \
+		thread_exit(); \
+	} \
+}
+
+
 extern iroutine exc_register(int n, const char *name, iroutine f);
 extern void exc_dispatch(int n, istate_t *t);
Index: generic/include/ipc/irq.h
===================================================================
--- generic/include/ipc/irq.h	(revision d8f7362433d8362e6786d4323938f5439281167a)
+++ generic/include/ipc/irq.h	(revision a175a672ae67972fd0aeeaae855819ca1135ee7c)
@@ -30,5 +30,11 @@
 #define __IRQ_H__
 
+/** Maximum length of IPC IRQ program */
 #define IRQ_MAX_PROG_SIZE 10
+
+/** Reserved 'virtual' messages for kernel notifications */
+#define IPC_IRQ_RESERVED_VIRTUAL 10
+
+#define IPC_IRQ_KLOG  (-1)
 
 typedef enum {
@@ -60,7 +66,10 @@
 #ifdef KERNEL
 
+#include <ipc/ipc.h>
+
 extern void ipc_irq_make_table(int irqcount);
 extern int ipc_irq_register(answerbox_t *box, int irq, irq_code_t *ucode);
 extern void ipc_irq_send_notif(int irq);
+extern void ipc_irq_send_msg(int irq, __native a2, __native a3);
 extern void ipc_irq_unregister(answerbox_t *box, int irq);
 extern void irq_ipc_bind_arch(__native irq);
Index: generic/include/ipc/sysipc.h
===================================================================
--- generic/include/ipc/sysipc.h	(revision d8f7362433d8362e6786d4323938f5439281167a)
+++ generic/include/ipc/sysipc.h	(revision a175a672ae67972fd0aeeaae855819ca1135ee7c)
@@ -48,6 +48,6 @@
 			      __native method, __native arg1);
 __native sys_ipc_hangup(int phoneid);
-__native sys_ipc_register_irq(__native irq, irq_code_t *ucode);
-__native sys_ipc_unregister_irq(__native irq);
+__native sys_ipc_register_irq(int irq, irq_code_t *ucode);
+__native sys_ipc_unregister_irq(int irq);
 
 #endif
Index: generic/include/proc/thread.h
===================================================================
--- generic/include/proc/thread.h	(revision d8f7362433d8362e6786d4323938f5439281167a)
+++ generic/include/proc/thread.h	(revision a175a672ae67972fd0aeeaae855819ca1135ee7c)
@@ -151,5 +151,5 @@
 extern thread_t *thread_create(void (* func)(void *), void *arg, task_t *task, int flags, char *name);
 extern void thread_ready(thread_t *t);
-extern void thread_exit(void);
+extern void thread_exit(void) __attribute__((noreturn));
 
 #ifndef thread_create_arch
Index: generic/include/stackarg.h
===================================================================
--- generic/include/stackarg.h	(revision d8f7362433d8362e6786d4323938f5439281167a)
+++ generic/include/stackarg.h	(revision a175a672ae67972fd0aeeaae855819ca1135ee7c)
@@ -50,4 +50,5 @@
 	(*((type *)((ap).last + ((ap).pos  += sizeof(type) ) - sizeof(type))))
 
+#define va_copy(dst,src)       dst=src
 #define va_end(ap)
 
Index: generic/include/stdarg.h
===================================================================
--- generic/include/stdarg.h	(revision d8f7362433d8362e6786d4323938f5439281167a)
+++ generic/include/stdarg.h	(revision a175a672ae67972fd0aeeaae855819ca1135ee7c)
@@ -41,4 +41,5 @@
 #define va_arg(ap, type) 		__builtin_va_arg(ap, type)
 #define va_end(ap)			__builtin_va_end(ap)
+#define va_copy(dst,src)		__builtin_va_copy(dst,src)
 
 #endif
