blob: 169868fa307defa30c7782cea4b96b2ab278ac54 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001#ifndef _PPC64_BUG_H
2#define _PPC64_BUG_H
3
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
14struct bug_entry {
15 unsigned long bug_addr;
16 long line;
17 const char *file;
18 const char *function;
19};
20
21struct bug_entry *find_bug(unsigned long bugaddr);
22
23/*
24 * If this bit is set in the line number it means that the trap
25 * is for WARN_ON rather than BUG or BUG_ON.
26 */
27#define BUG_WARNING_TRAP 0x1000000
28
Matt Mackallc8538a72005-05-01 08:59:01 -070029#ifdef CONFIG_BUG
30
Linus Torvalds1da177e2005-04-16 15:20:36 -070031#define BUG() do { \
32 __asm__ __volatile__( \
33 "1: twi 31,0,0\n" \
34 ".section __bug_table,\"a\"\n\t" \
35 " .llong 1b,%0,%1,%2\n" \
36 ".previous" \
37 : : "i" (__LINE__), "i" (__FILE__), "i" (__FUNCTION__)); \
38} while (0)
39
40#define BUG_ON(x) do { \
41 __asm__ __volatile__( \
42 "1: tdnei %0,0\n" \
43 ".section __bug_table,\"a\"\n\t" \
44 " .llong 1b,%1,%2,%3\n" \
45 ".previous" \
46 : : "r" (x), "i" (__LINE__), "i" (__FILE__), \
47 "i" (__FUNCTION__)); \
48} while (0)
49
50#define WARN_ON(x) do { \
51 __asm__ __volatile__( \
52 "1: tdnei %0,0\n" \
53 ".section __bug_table,\"a\"\n\t" \
54 " .llong 1b,%1,%2,%3\n" \
55 ".previous" \
56 : : "r" (x), "i" (__LINE__ + BUG_WARNING_TRAP), \
57 "i" (__FILE__), "i" (__FUNCTION__)); \
58} while (0)
59
Linus Torvalds1da177e2005-04-16 15:20:36 -070060#define HAVE_ARCH_BUG
61#define HAVE_ARCH_BUG_ON
62#define HAVE_ARCH_WARN_ON
Matt Mackallc8538a72005-05-01 08:59:01 -070063#endif
64#endif
65
Linus Torvalds1da177e2005-04-16 15:20:36 -070066#include <asm-generic/bug.h>
67
68#endif