blob: 07ea467f22fcd50f5e6721db491e9165d417666f [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001#ifndef _PARISC_BUG_H
2#define _PARISC_BUG_H
3
James Bottomleyf1ea8b62012-06-03 01:49:32 -07004#include <linux/kernel.h> /* for BUGFLAG_TAINT */
5
Helge Deller6891f8a2006-12-16 16:16:50 +01006/*
7 * Tell the user there is some problem.
8 * The offending file and line are encoded in the __bug_table section.
9 */
10
Matt Mackallc8538a72005-05-01 08:59:01 -070011#ifdef CONFIG_BUG
Linus Torvalds1da177e2005-04-16 15:20:36 -070012#define HAVE_ARCH_BUG
Helge Deller6891f8a2006-12-16 16:16:50 +010013#define HAVE_ARCH_WARN_ON
14
15/* the break instruction is used as BUG() marker. */
16#define PARISC_BUG_BREAK_ASM "break 0x1f, 0x1fff"
17#define PARISC_BUG_BREAK_INSN 0x03ffe01f /* PARISC_BUG_BREAK_ASM */
18
Helge Deller0b3d6432007-01-28 14:52:57 +010019#if defined(CONFIG_64BIT)
20#define ASM_WORD_INSN ".dword\t"
Helge Deller6891f8a2006-12-16 16:16:50 +010021#else
Helge Deller0b3d6432007-01-28 14:52:57 +010022#define ASM_WORD_INSN ".word\t"
Helge Deller6891f8a2006-12-16 16:16:50 +010023#endif
24
25#ifdef CONFIG_DEBUG_BUGVERBOSE
26#define BUG() \
27 do { \
28 asm volatile("\n" \
29 "1:\t" PARISC_BUG_BREAK_ASM "\n" \
Josh Poimboeuf325cdac2017-07-15 00:10:58 -050030 "\t.pushsection __bug_table,\"aw\"\n" \
Helge Deller0b3d6432007-01-28 14:52:57 +010031 "2:\t" ASM_WORD_INSN "1b, %c0\n" \
Helge Deller6891f8a2006-12-16 16:16:50 +010032 "\t.short %c1, %c2\n" \
33 "\t.org 2b+%c3\n" \
34 "\t.popsection" \
35 : : "i" (__FILE__), "i" (__LINE__), \
36 "i" (0), "i" (sizeof(struct bug_entry)) ); \
David Daney05920792009-12-10 17:28:18 +000037 unreachable(); \
Helge Deller6891f8a2006-12-16 16:16:50 +010038 } while(0)
39
40#else
41#define BUG() \
42 do { \
43 asm volatile(PARISC_BUG_BREAK_ASM : : ); \
David Daney05920792009-12-10 17:28:18 +000044 unreachable(); \
Helge Deller6891f8a2006-12-16 16:16:50 +010045 } while(0)
46#endif
47
Helge Dellere3828762006-12-16 17:48:26 +010048#ifdef CONFIG_DEBUG_BUGVERBOSE
Peter Zijlstra19d43622017-02-25 08:56:53 +010049#define __WARN_FLAGS(flags) \
Helge Deller6891f8a2006-12-16 16:16:50 +010050 do { \
51 asm volatile("\n" \
52 "1:\t" PARISC_BUG_BREAK_ASM "\n" \
Josh Poimboeuf325cdac2017-07-15 00:10:58 -050053 "\t.pushsection __bug_table,\"aw\"\n" \
Helge Deller0b3d6432007-01-28 14:52:57 +010054 "2:\t" ASM_WORD_INSN "1b, %c0\n" \
Helge Deller6891f8a2006-12-16 16:16:50 +010055 "\t.short %c1, %c2\n" \
56 "\t.org 2b+%c3\n" \
57 "\t.popsection" \
58 : : "i" (__FILE__), "i" (__LINE__), \
Peter Zijlstra19d43622017-02-25 08:56:53 +010059 "i" (BUGFLAG_WARNING|(flags)), \
Helge Deller6891f8a2006-12-16 16:16:50 +010060 "i" (sizeof(struct bug_entry)) ); \
61 } while(0)
Helge Dellere3828762006-12-16 17:48:26 +010062#else
Peter Zijlstra19d43622017-02-25 08:56:53 +010063#define __WARN_FLAGS(flags) \
Helge Dellere3828762006-12-16 17:48:26 +010064 do { \
65 asm volatile("\n" \
66 "1:\t" PARISC_BUG_BREAK_ASM "\n" \
Josh Poimboeuf325cdac2017-07-15 00:10:58 -050067 "\t.pushsection __bug_table,\"aw\"\n" \
Helge Deller0b3d6432007-01-28 14:52:57 +010068 "2:\t" ASM_WORD_INSN "1b\n" \
Helge Dellere3828762006-12-16 17:48:26 +010069 "\t.short %c0\n" \
70 "\t.org 2b+%c1\n" \
71 "\t.popsection" \
Peter Zijlstra19d43622017-02-25 08:56:53 +010072 : : "i" (BUGFLAG_WARNING|(flags)), \
Helge Dellere3828762006-12-16 17:48:26 +010073 "i" (sizeof(struct bug_entry)) ); \
74 } while(0)
75#endif
Helge Deller6891f8a2006-12-16 16:16:50 +010076
77
78#define WARN_ON(x) ({ \
Heiko Carstensfd0cbdd2007-08-02 00:18:38 +020079 int __ret_warn_on = !!(x); \
Helge Deller6891f8a2006-12-16 16:16:50 +010080 if (__builtin_constant_p(__ret_warn_on)) { \
81 if (__ret_warn_on) \
82 __WARN(); \
83 } else { \
84 if (unlikely(__ret_warn_on)) \
85 __WARN(); \
86 } \
87 unlikely(__ret_warn_on); \
88})
89
Matt Mackallc8538a72005-05-01 08:59:01 -070090#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -070091
92#include <asm-generic/bug.h>
93#endif
Helge Deller6891f8a2006-12-16 16:16:50 +010094