blob: d625ee55f9571e68503cbd43d01240de1875d22b [file] [log] [blame]
Becky Bruce25433b12005-09-19 17:01:54 -05001#ifndef _ASM_POWERPC_BUG_H
2#define _ASM_POWERPC_BUG_H
Linus Torvalds1da177e2005-04-16 15:20:36 -07003
4/*
5 * Define an illegal instr to trap on the bug.
6 * We don't use 0 because that marks the end of a function
7 * in the ELF ABI. That's "Boo Boo" in case you wonder...
8 */
9#define BUG_OPCODE .long 0x00b00b00 /* For asm */
10#define BUG_ILLEGAL_INSTR "0x00b00b00" /* For BUG macro */
11
12#ifndef __ASSEMBLY__
13
Becky Bruce25433b12005-09-19 17:01:54 -050014#ifdef __powerpc64__
Paul Mackerras104dd652005-11-02 15:19:47 +110015#define BUG_TABLE_ENTRY ".llong"
16#define BUG_TRAP_OP "tdnei"
Becky Bruce25433b12005-09-19 17:01:54 -050017#else
Paul Mackerras104dd652005-11-02 15:19:47 +110018#define BUG_TABLE_ENTRY ".long"
19#define BUG_TRAP_OP "twnei"
Becky Bruce25433b12005-09-19 17:01:54 -050020#endif /* __powerpc64__ */
21
Linus Torvalds1da177e2005-04-16 15:20:36 -070022struct bug_entry {
23 unsigned long bug_addr;
Paul Mackerras89003eb2005-11-01 21:54:38 +110024 long line;
Linus Torvalds1da177e2005-04-16 15:20:36 -070025 const char *file;
26 const char *function;
27};
28
29struct bug_entry *find_bug(unsigned long bugaddr);
30
31/*
32 * If this bit is set in the line number it means that the trap
33 * is for WARN_ON rather than BUG or BUG_ON.
34 */
35#define BUG_WARNING_TRAP 0x1000000
36
Matt Mackallc8538a72005-05-01 08:59:01 -070037#ifdef CONFIG_BUG
38
Linus Torvalds1da177e2005-04-16 15:20:36 -070039#define BUG() do { \
40 __asm__ __volatile__( \
41 "1: twi 31,0,0\n" \
Paul Mackerras104dd652005-11-02 15:19:47 +110042 ".section __bug_table,\"a\"\n" \
43 "\t"BUG_TABLE_ENTRY" 1b,%0,%1,%2\n" \
Linus Torvalds1da177e2005-04-16 15:20:36 -070044 ".previous" \
45 : : "i" (__LINE__), "i" (__FILE__), "i" (__FUNCTION__)); \
46} while (0)
47
48#define BUG_ON(x) do { \
49 __asm__ __volatile__( \
Paul Mackerras104dd652005-11-02 15:19:47 +110050 "1: "BUG_TRAP_OP" %0,0\n" \
51 ".section __bug_table,\"a\"\n" \
52 "\t"BUG_TABLE_ENTRY" 1b,%1,%2,%3\n" \
Linus Torvalds1da177e2005-04-16 15:20:36 -070053 ".previous" \
Al Virof2cad7a2005-11-02 03:10:43 +000054 : : "r" ((long)(x)), "i" (__LINE__), \
Anton Blanchard32818c22005-08-26 18:34:07 -070055 "i" (__FILE__), "i" (__FUNCTION__)); \
Linus Torvalds1da177e2005-04-16 15:20:36 -070056} while (0)
57
58#define WARN_ON(x) do { \
59 __asm__ __volatile__( \
Paul Mackerras104dd652005-11-02 15:19:47 +110060 "1: "BUG_TRAP_OP" %0,0\n" \
61 ".section __bug_table,\"a\"\n" \
62 "\t"BUG_TABLE_ENTRY" 1b,%1,%2,%3\n" \
Linus Torvalds1da177e2005-04-16 15:20:36 -070063 ".previous" \
Al Virof2cad7a2005-11-02 03:10:43 +000064 : : "r" ((long)(x)), \
Anton Blanchard32818c22005-08-26 18:34:07 -070065 "i" (__LINE__ + BUG_WARNING_TRAP), \
Linus Torvalds1da177e2005-04-16 15:20:36 -070066 "i" (__FILE__), "i" (__FUNCTION__)); \
67} while (0)
68
Linus Torvalds1da177e2005-04-16 15:20:36 -070069#define HAVE_ARCH_BUG
70#define HAVE_ARCH_BUG_ON
71#define HAVE_ARCH_WARN_ON
Becky Bruce25433b12005-09-19 17:01:54 -050072#endif /* CONFIG_BUG */
73#endif /* __ASSEMBLY __ */
Matt Mackallc8538a72005-05-01 08:59:01 -070074
Linus Torvalds1da177e2005-04-16 15:20:36 -070075#include <asm-generic/bug.h>
76
Becky Bruce25433b12005-09-19 17:01:54 -050077#endif /* _ASM_POWERPC_BUG_H */