Index: kernel/generic/include/debug.h
===================================================================
--- kernel/generic/include/debug.h	(revision 09a0bd4a4ab5a70550f327984b135164b05aa58d)
+++ kernel/generic/include/debug.h	(revision 8e374ea71403569c82edd76a6713a88b1a9d12a8)
@@ -55,5 +55,5 @@
 	do { \
 		if (!(expr)) \
-			panic("Assertion failed (%s)", #expr); \
+			panic_assert("%s", #expr); \
 	} while (0)
 
@@ -72,5 +72,5 @@
 	do { \
 		if (!(expr)) \
-			panic("Assertion failed (%s, %s)", #expr, msg); \
+			panic_assert("%s, %s", #expr, msg); \
 	} while (0)
 
Index: kernel/generic/include/panic.h
===================================================================
--- kernel/generic/include/panic.h	(revision 09a0bd4a4ab5a70550f327984b135164b05aa58d)
+++ kernel/generic/include/panic.h	(revision 8e374ea71403569c82edd76a6713a88b1a9d12a8)
@@ -1,4 +1,4 @@
 /*
- * Copyright (c) 2001-2004 Jakub Jermar
+ * Copyright (c) 2010 Jakub Jermar
  * All rights reserved.
  *
@@ -37,33 +37,30 @@
 
 #include <typedefs.h>
-#include <stacktrace.h>
-#include <print.h>
 
-#ifdef CONFIG_DEBUG
+#define panic(fmt, ...) \
+	panic_common(PANIC_OTHER, NULL, 0, 0, fmt, ##__VA_ARGS__)
 
-#define panic(format, ...) \
-	do { \
-		silent = false; \
-		printf("Kernel panic in %s() at %s:%u\n", \
-		    __func__, __FILE__, __LINE__); \
-		stack_trace(); \
-		panic_printf("Panic message: " format "\n", \
-		    ##__VA_ARGS__);\
-	} while (0)
+#define panic_assert(fmt, ...) \
+	panic_common(PANIC_ASSERT, NULL, 0, 0, fmt, ##__VA_ARGS__)
 
-#else /* CONFIG_DEBUG */
+#define panic_badtrap(istate, n, fmt, ...) \
+	panic_common(PANIC_BADTRAP, istate, 0, n, fmt, ##__VA_ARGS__)
 
-#define panic(format, ...) \
-	do { \
-		silent = false; \
-		panic_printf("Kernel panic: " format "\n", ##__VA_ARGS__); \
-		stack_trace(); \
-	} while (0)
+#define panic_memtrap(istate, access, addr, fmt, ...) \
+	panic_common(PANIC_MEMTRAP, istate, access, addr, fmt, ##__VA_ARGS__)
 
-#endif /* CONFIG_DEBUG */
+typedef enum {
+	PANIC_OTHER,
+	PANIC_ASSERT,
+	PANIC_BADTRAP,
+	PANIC_MEMTRAP
+} panic_category_t;
+
+struct istate;
 
 extern bool silent;
 
-extern void panic_printf(const char *fmt, ...) __attribute__((noreturn));
+extern void panic_common(panic_category_t, struct istate *, int,
+    uintptr_t, const char *, ...) __attribute__ ((noreturn));
 
 #endif
