blob: 8c194f6af45e09932976b3f71d8d70a8f556488f [file] [log] [blame]
Max Filippov28570e82012-11-19 08:30:15 +04001/*
2 * arch/xtensa/include/asm/traps.h
3 *
4 * This file is subject to the terms and conditions of the GNU General Public
5 * License. See the file "COPYING" in the main directory of this archive
6 * for more details.
7 *
8 * Copyright (C) 2012 Tensilica Inc.
9 */
10#ifndef _XTENSA_TRAPS_H
11#define _XTENSA_TRAPS_H
12
13#include <asm/ptrace.h>
14
15/*
16 * handler must be either of the following:
17 * void (*)(struct pt_regs *regs);
18 * void (*)(struct pt_regs *regs, unsigned long exccause);
19 */
20extern void * __init trap_set_handler(int cause, void *handler);
21extern void do_unhandled(struct pt_regs *regs, unsigned long exccause);
Max Filippovf6151362013-10-17 02:42:26 +040022void secondary_trap_init(void);
Max Filippov28570e82012-11-19 08:30:15 +040023
Max Filippov2d6f82f2013-02-03 05:39:22 +040024static inline void spill_registers(void)
25{
Max Filippov2d6f82f2013-02-03 05:39:22 +040026
27 __asm__ __volatile__ (
Max Filippov4e962742013-04-06 04:10:13 +040028 "movi a14, "__stringify((1 << PS_EXCM_BIT) | LOCKLEVEL)"\n\t"
Max Filippov2d6f82f2013-02-03 05:39:22 +040029 "mov a12, a0\n\t"
30 "rsr a13, sar\n\t"
31 "xsr a14, ps\n\t"
32 "movi a0, _spill_registers\n\t"
33 "rsync\n\t"
34 "callx0 a0\n\t"
35 "mov a0, a12\n\t"
36 "wsr a13, sar\n\t"
37 "wsr a14, ps\n\t"
Max Filippov4e962742013-04-06 04:10:13 +040038 : :
Max Filippov2d6f82f2013-02-03 05:39:22 +040039#if defined(CONFIG_FRAME_POINTER)
40 : "a2", "a3", "a4", "a11", "a12", "a13", "a14", "a15",
41#else
42 : "a2", "a3", "a4", "a7", "a11", "a12", "a13", "a14", "a15",
43#endif
44 "memory");
45}
46
Max Filippov28570e82012-11-19 08:30:15 +040047#endif /* _XTENSA_TRAPS_H */