]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
xtensa: add trap_set_handler function
authorMax Filippov <jcmvbkbc@gmail.com>
Mon, 19 Nov 2012 04:30:15 +0000 (08:30 +0400)
committerChris Zankel <chris@zankel.net>
Wed, 19 Dec 2012 05:10:22 +0000 (21:10 -0800)
trap_set_handler sets new C-handler in the exception table and returns
previous handler.

Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
Signed-off-by: Chris Zankel <chris@zankel.net>
arch/xtensa/include/asm/traps.h [new file with mode: 0644]
arch/xtensa/kernel/traps.c

diff --git a/arch/xtensa/include/asm/traps.h b/arch/xtensa/include/asm/traps.h
new file mode 100644 (file)
index 0000000..54f7044
--- /dev/null
@@ -0,0 +1,23 @@
+/*
+ * arch/xtensa/include/asm/traps.h
+ *
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License.  See the file "COPYING" in the main directory of this archive
+ * for more details.
+ *
+ * Copyright (C) 2012 Tensilica Inc.
+ */
+#ifndef _XTENSA_TRAPS_H
+#define _XTENSA_TRAPS_H
+
+#include <asm/ptrace.h>
+
+/*
+ * handler must be either of the following:
+ *  void (*)(struct pt_regs *regs);
+ *  void (*)(struct pt_regs *regs, unsigned long exccause);
+ */
+extern void * __init trap_set_handler(int cause, void *handler);
+extern void do_unhandled(struct pt_regs *regs, unsigned long exccause);
+
+#endif /* _XTENSA_TRAPS_H */
index 5caf2b64d43ac846c7a0c148166c54877dec8178..691a792b01d30adddcdc30f788e162c234b62d1d 100644 (file)
@@ -293,6 +293,17 @@ do_debug(struct pt_regs *regs)
 }
 
 
+/* Set exception C handler - for temporary use when probing exceptions */
+
+void * __init trap_set_handler(int cause, void *handler)
+{
+       unsigned long *entry = &exc_table[EXC_TABLE_DEFAULT / 4 + cause];
+       void *previous = (void *)*entry;
+       *entry = (unsigned long)handler;
+       return previous;
+}
+
+
 /*
  * Initialize dispatch tables.
  *