2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
6 * Copyright (C) 1996, 1997, 1998, 2001 by Ralf Baechle
11 #include <asm/cpu-features.h>
12 #include <asm/mipsregs.h>
13 #include <asm/ptrace.h>
16 extern int __isa_exception_epc(struct pt_regs *regs);
17 extern int __compute_return_epc(struct pt_regs *regs);
18 extern int __compute_return_epc_for_insn(struct pt_regs *regs,
19 union mips_instruction insn);
20 extern int __microMIPS_compute_return_epc(struct pt_regs *regs);
21 extern int __MIPS16e_compute_return_epc(struct pt_regs *regs);
26 #define MM_POOL32A_MINOR_MASK 0x3f
27 #define MM_POOL32A_MINOR_SHIFT 0x6
28 #define MM_MIPS32_COND_FC 0x30
30 extern int __mm_isBranchInstr(struct pt_regs *regs,
31 struct mm_decoded_insn dec_insn, unsigned long *contpc);
33 static inline int mm_isBranchInstr(struct pt_regs *regs,
34 struct mm_decoded_insn dec_insn, unsigned long *contpc)
39 return __mm_isBranchInstr(regs, dec_insn, contpc);
42 static inline int delay_slot(struct pt_regs *regs)
44 return regs->cp0_cause & CAUSEF_BD;
47 static inline void clear_delay_slot(struct pt_regs *regs)
49 regs->cp0_cause &= ~CAUSEF_BD;
52 static inline void set_delay_slot(struct pt_regs *regs)
54 regs->cp0_cause |= CAUSEF_BD;
57 static inline unsigned long exception_epc(struct pt_regs *regs)
59 if (likely(!delay_slot(regs)))
62 if (get_isa16_mode(regs->cp0_epc))
63 return __isa_exception_epc(regs);
65 return regs->cp0_epc + 4;
68 #define BRANCH_LIKELY_TAKEN 0x0001
70 static inline int compute_return_epc(struct pt_regs *regs)
72 if (get_isa16_mode(regs->cp0_epc)) {
74 return __microMIPS_compute_return_epc(regs);
76 return __MIPS16e_compute_return_epc(regs);
77 } else if (!delay_slot(regs)) {
82 return __compute_return_epc(regs);
85 static inline int MIPS16e_compute_return_epc(struct pt_regs *regs,
86 union mips16e_instruction *inst)
88 if (likely(!delay_slot(regs))) {
89 if (inst->ri.opcode == MIPS16e_extend_op) {
97 return __MIPS16e_compute_return_epc(regs);
100 #endif /* _ASM_BRANCH_H */