1b2441318SGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 */
2e839ca52SDavid Howells #ifndef __ASM_SH_TRAPS_32_H
3e839ca52SDavid Howells #define __ASM_SH_TRAPS_32_H
4e839ca52SDavid Howells
5e839ca52SDavid Howells #include <linux/types.h>
6e839ca52SDavid Howells #include <asm/mmu.h>
7e839ca52SDavid Howells
8e839ca52SDavid Howells #ifdef CONFIG_CPU_HAS_SR_RB
9e839ca52SDavid Howells #define lookup_exception_vector() \
10e839ca52SDavid Howells ({ \
11e839ca52SDavid Howells unsigned long _vec; \
12e839ca52SDavid Howells \
13e839ca52SDavid Howells __asm__ __volatile__ ( \
14e839ca52SDavid Howells "stc r2_bank, %0\n\t" \
15e839ca52SDavid Howells : "=r" (_vec) \
16e839ca52SDavid Howells ); \
17e839ca52SDavid Howells \
18e839ca52SDavid Howells _vec; \
19e839ca52SDavid Howells })
20e839ca52SDavid Howells #else
21e839ca52SDavid Howells #define lookup_exception_vector() \
22e839ca52SDavid Howells ({ \
23e839ca52SDavid Howells unsigned long _vec; \
24e839ca52SDavid Howells __asm__ __volatile__ ( \
25e839ca52SDavid Howells "mov r4, %0\n\t" \
26e839ca52SDavid Howells : "=r" (_vec) \
27e839ca52SDavid Howells ); \
28e839ca52SDavid Howells \
29e839ca52SDavid Howells _vec; \
30e839ca52SDavid Howells })
31e839ca52SDavid Howells #endif
32e839ca52SDavid Howells
trigger_address_error(void)33e839ca52SDavid Howells static inline void trigger_address_error(void)
34e839ca52SDavid Howells {
35e839ca52SDavid Howells __asm__ __volatile__ (
36e839ca52SDavid Howells "ldc %0, sr\n\t"
37e839ca52SDavid Howells "mov.l @%1, %0"
38e839ca52SDavid Howells :
39e839ca52SDavid Howells : "r" (0x10000000), "r" (0x80000001)
40e839ca52SDavid Howells );
41e839ca52SDavid Howells }
42e839ca52SDavid Howells
43e839ca52SDavid Howells asmlinkage void do_address_error(struct pt_regs *regs,
44e839ca52SDavid Howells unsigned long writeaccess,
45e839ca52SDavid Howells unsigned long address);
46*23f8c182SArnd Bergmann asmlinkage void do_page_fault(struct pt_regs *regs,
47*23f8c182SArnd Bergmann unsigned long error_code,
48*23f8c182SArnd Bergmann unsigned long address);
49a3c19514SBobby Bingham asmlinkage void do_divide_error(unsigned long r4);
50a3c19514SBobby Bingham asmlinkage void do_reserved_inst(void);
51a3c19514SBobby Bingham asmlinkage void do_illegal_slot_inst(void);
52a3c19514SBobby Bingham asmlinkage void do_exception_error(void);
53e839ca52SDavid Howells
54e839ca52SDavid Howells #define BUILD_TRAP_HANDLER(name) \
55e839ca52SDavid Howells asmlinkage void name##_trap_handler(unsigned long r4, unsigned long r5, \
56e839ca52SDavid Howells unsigned long r6, unsigned long r7, \
57e839ca52SDavid Howells struct pt_regs __regs)
58e839ca52SDavid Howells
59e839ca52SDavid Howells #define TRAP_HANDLER_DECL \
60e839ca52SDavid Howells struct pt_regs *regs = RELOC_HIDE(&__regs, 0); \
61e839ca52SDavid Howells unsigned int vec = regs->tra; \
62e839ca52SDavid Howells (void)vec;
63e839ca52SDavid Howells
64e839ca52SDavid Howells #endif /* __ASM_SH_TRAPS_32_H */
65