]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blame - arch/sh/include/asm/bug.h
Merge tag 'powerpc-4.13-8' of git://git.kernel.org/pub/scm/linux/kernel/git/powerpc...
[mirror_ubuntu-artful-kernel.git] / arch / sh / include / asm / bug.h
CommitLineData
1da177e4
LT
1#ifndef __ASM_SH_BUG_H
2#define __ASM_SH_BUG_H
3
e839ca52
DH
4#include <linux/linkage.h>
5
44530c69 6#define TRAPA_BUG_OPCODE 0xc33e /* trapa #0x3e */
e115f2c1 7#define BUGFLAG_UNWINDER (1 << 1)
44530c69 8
e1cd93ea 9#ifdef CONFIG_GENERIC_BUG
fa691511
PM
10#define HAVE_ARCH_BUG
11#define HAVE_ARCH_WARN_ON
dc34d312 12
fa691511
PM
13/**
14 * _EMIT_BUG_ENTRY
15 * %1 - __FILE__
16 * %2 - __LINE__
17 * %3 - trap type
18 * %4 - sizeof(struct bug_entry)
19 *
20 * The trapa opcode itself sits in %0.
21 * The %O notation is used to avoid # generation.
22 *
23 * The offending file and line are encoded in the __bug_table section.
24 */
dc34d312 25#ifdef CONFIG_DEBUG_BUGVERBOSE
fa691511 26#define _EMIT_BUG_ENTRY \
325cdacd 27 "\t.pushsection __bug_table,\"aw\"\n" \
fa691511
PM
28 "2:\t.long 1b, %O1\n" \
29 "\t.short %O2, %O3\n" \
30 "\t.org 2b+%O4\n" \
31 "\t.popsection\n"
32#else
33#define _EMIT_BUG_ENTRY \
325cdacd 34 "\t.pushsection __bug_table,\"aw\"\n" \
fa691511
PM
35 "2:\t.long 1b\n" \
36 "\t.short %O3\n" \
37 "\t.org 2b+%O4\n" \
38 "\t.popsection\n"
39#endif
dc34d312
PM
40
41#define BUG() \
42do { \
43 __asm__ __volatile__ ( \
fa691511
PM
44 "1:\t.short %O0\n" \
45 _EMIT_BUG_ENTRY \
46 : \
47 : "n" (TRAPA_BUG_OPCODE), \
48 "i" (__FILE__), \
49 "i" (__LINE__), "i" (0), \
50 "i" (sizeof(struct bug_entry))); \
579e1452 51 unreachable(); \
dc34d312
PM
52} while (0)
53
19d43626 54#define __WARN_FLAGS(flags) \
fa691511
PM
55do { \
56 __asm__ __volatile__ ( \
57 "1:\t.short %O0\n" \
58 _EMIT_BUG_ENTRY \
59 : \
60 : "n" (TRAPA_BUG_OPCODE), \
61 "i" (__FILE__), \
62 "i" (__LINE__), \
19d43626 63 "i" (BUGFLAG_WARNING|(flags)), \
fa691511 64 "i" (sizeof(struct bug_entry))); \
1da177e4
LT
65} while (0)
66
fa691511 67#define WARN_ON(x) ({ \
fd0cbdd3 68 int __ret_warn_on = !!(x); \
fa691511
PM
69 if (__builtin_constant_p(__ret_warn_on)) { \
70 if (__ret_warn_on) \
71 __WARN(); \
72 } else { \
73 if (unlikely(__ret_warn_on)) \
74 __WARN(); \
75 } \
76 unlikely(__ret_warn_on); \
77})
dc34d312 78
e115f2c1 79#define UNWINDER_BUG() \
b344e24a
MF
80do { \
81 __asm__ __volatile__ ( \
82 "1:\t.short %O0\n" \
e115f2c1 83 _EMIT_BUG_ENTRY \
b344e24a 84 : \
e115f2c1 85 : "n" (TRAPA_BUG_OPCODE), \
b344e24a 86 "i" (__FILE__), \
e115f2c1
PM
87 "i" (__LINE__), \
88 "i" (BUGFLAG_UNWINDER), \
b344e24a
MF
89 "i" (sizeof(struct bug_entry))); \
90} while (0)
91
92#define UNWINDER_BUG_ON(x) ({ \
93 int __ret_unwinder_on = !!(x); \
94 if (__builtin_constant_p(__ret_unwinder_on)) { \
95 if (__ret_unwinder_on) \
96 UNWINDER_BUG(); \
97 } else { \
98 if (unlikely(__ret_unwinder_on)) \
99 UNWINDER_BUG(); \
100 } \
101 unlikely(__ret_unwinder_on); \
102})
103
74db2479
PM
104#else
105
106#define UNWINDER_BUG BUG
107#define UNWINDER_BUG_ON BUG_ON
108
e1cd93ea 109#endif /* CONFIG_GENERIC_BUG */
c8538a7a 110
1da177e4
LT
111#include <asm-generic/bug.h>
112
e839ca52 113struct pt_regs;
5f857bce
PM
114
115/* arch/sh/kernel/traps.c */
e839ca52 116extern void die(const char *str, struct pt_regs *regs, long err) __attribute__ ((noreturn));
5f857bce
PM
117extern void die_if_kernel(const char *str, struct pt_regs *regs, long err);
118extern void die_if_no_fixup(const char *str, struct pt_regs *regs, long err);
e839ca52 119
dc34d312 120#endif /* __ASM_SH_BUG_H */