2 * Copyright (C) 2012 Regents of the University of California
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation, version 2.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
14 #ifndef _ASM_RISCV_BUG_H
15 #define _ASM_RISCV_BUG_H
17 #include <linux/compiler.h>
18 #include <linux/const.h>
19 #include <linux/types.h>
23 #ifdef CONFIG_GENERIC_BUG
24 #define __BUG_INSN _AC(0x00100073, UL) /* ebreak */
27 typedef u32 bug_insn_t
;
29 #ifdef CONFIG_GENERIC_BUG_RELATIVE_POINTERS
30 #define __BUG_ENTRY_ADDR RISCV_INT " 1b - 2b"
31 #define __BUG_ENTRY_FILE RISCV_INT " %0 - 2b"
33 #define __BUG_ENTRY_ADDR RISCV_PTR " 1b"
34 #define __BUG_ENTRY_FILE RISCV_PTR " %0"
37 #ifdef CONFIG_DEBUG_BUGVERBOSE
39 __BUG_ENTRY_ADDR "\n\t" \
40 __BUG_ENTRY_FILE "\n\t" \
49 __asm__ __volatile__ ( \
52 ".pushsection __bug_table,\"a\"\n\t" \
58 : "i" (__FILE__), "i" (__LINE__), \
59 "i" (sizeof(struct bug_entry))); \
62 #endif /* !__ASSEMBLY__ */
63 #else /* CONFIG_GENERIC_BUG */
67 __asm__ __volatile__ ("ebreak\n"); \
70 #endif /* !__ASSEMBLY__ */
71 #endif /* CONFIG_GENERIC_BUG */
75 #include <asm-generic/bug.h>
82 extern void die(struct pt_regs
*regs
, const char *str
);
83 extern void do_trap(struct pt_regs
*regs
, int signo
, int code
,
84 unsigned long addr
, struct task_struct
*tsk
);
86 #endif /* !__ASSEMBLY__ */
88 #endif /* _ASM_RISCV_BUG_H */