blob: b001ecb3cd9956030f8520b6fad183eb3186eee7 [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
David Gibson3ddfbcf2005-11-10 12:56:55 +11004#include <asm/asm-compat.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -07005/*
6 * Define an illegal instr to trap on the bug.
7 * We don't use 0 because that marks the end of a function
8 * in the ELF ABI. That's "Boo Boo" in case you wonder...
9 */
10#define BUG_OPCODE .long 0x00b00b00 /* For asm */
11#define BUG_ILLEGAL_INSTR "0x00b00b00" /* For BUG macro */
12
13#ifndef __ASSEMBLY__
14
15struct bug_entry {
16 unsigned long bug_addr;
Paul Mackerras89003eb2005-11-01 21:54:38 +110017 long line;
Linus Torvalds1da177e2005-04-16 15:20:36 -070018 const char *file;
19 const char *function;
20};
21
22struct bug_entry *find_bug(unsigned long bugaddr);
23
24/*
25 * If this bit is set in the line number it means that the trap
26 * is for WARN_ON rather than BUG or BUG_ON.
27 */
28#define BUG_WARNING_TRAP 0x1000000
29
Matt Mackallc8538a72005-05-01 08:59:01 -070030#ifdef CONFIG_BUG
31
Linus Torvalds1da177e2005-04-16 15:20:36 -070032#define BUG() do { \
33 __asm__ __volatile__( \
34 "1: twi 31,0,0\n" \
Paul Mackerras104dd652005-11-02 15:19:47 +110035 ".section __bug_table,\"a\"\n" \
David Gibson3ddfbcf2005-11-10 12:56:55 +110036 "\t"PPC_LONG" 1b,%0,%1,%2\n" \
Linus Torvalds1da177e2005-04-16 15:20:36 -070037 ".previous" \
38 : : "i" (__LINE__), "i" (__FILE__), "i" (__FUNCTION__)); \
39} while (0)
40
41#define BUG_ON(x) do { \
42 __asm__ __volatile__( \
David Gibson3ddfbcf2005-11-10 12:56:55 +110043 "1: "PPC_TLNEI" %0,0\n" \
Paul Mackerras104dd652005-11-02 15:19:47 +110044 ".section __bug_table,\"a\"\n" \
David Gibson3ddfbcf2005-11-10 12:56:55 +110045 "\t"PPC_LONG" 1b,%1,%2,%3\n" \
Linus Torvalds1da177e2005-04-16 15:20:36 -070046 ".previous" \
Al Virof2cad7a2005-11-02 03:10:43 +000047 : : "r" ((long)(x)), "i" (__LINE__), \
Anton Blanchard32818c22005-08-26 18:34:07 -070048 "i" (__FILE__), "i" (__FUNCTION__)); \
Linus Torvalds1da177e2005-04-16 15:20:36 -070049} while (0)
50
51#define WARN_ON(x) do { \
52 __asm__ __volatile__( \
David Gibson3ddfbcf2005-11-10 12:56:55 +110053 "1: "PPC_TLNEI" %0,0\n" \
Paul Mackerras104dd652005-11-02 15:19:47 +110054 ".section __bug_table,\"a\"\n" \
David Gibson3ddfbcf2005-11-10 12:56:55 +110055 "\t"PPC_LONG" 1b,%1,%2,%3\n" \
Linus Torvalds1da177e2005-04-16 15:20:36 -070056 ".previous" \
Al Virof2cad7a2005-11-02 03:10:43 +000057 : : "r" ((long)(x)), \
Anton Blanchard32818c22005-08-26 18:34:07 -070058 "i" (__LINE__ + BUG_WARNING_TRAP), \
Linus Torvalds1da177e2005-04-16 15:20:36 -070059 "i" (__FILE__), "i" (__FUNCTION__)); \
60} while (0)
61
Linus Torvalds1da177e2005-04-16 15:20:36 -070062#define HAVE_ARCH_BUG
63#define HAVE_ARCH_BUG_ON
64#define HAVE_ARCH_WARN_ON
Becky Bruce25433b12005-09-19 17:01:54 -050065#endif /* CONFIG_BUG */
66#endif /* __ASSEMBLY __ */
Matt Mackallc8538a72005-05-01 08:59:01 -070067
Linus Torvalds1da177e2005-04-16 15:20:36 -070068#include <asm-generic/bug.h>
69
Becky Bruce25433b12005-09-19 17:01:54 -050070#endif /* _ASM_POWERPC_BUG_H */