1#ifndef _ASM_POWERPC_BUG_H
2#define _ASM_POWERPC_BUG_H
3#ifdef __KERNEL__
4
5#include <asm/asm-compat.h>
6
7
8
9
10
11#define BUG_OPCODE .long 0x00b00b00
12#define BUG_ILLEGAL_INSTR "0x00b00b00"
13
14#ifndef __ASSEMBLY__
15
16struct bug_entry {
17 unsigned long bug_addr;
18 long line;
19 const char *file;
20 const char *function;
21};
22
23struct bug_entry *find_bug(unsigned long bugaddr);
24
25
26
27
28
29#define BUG_WARNING_TRAP 0x1000000
30
31#ifdef CONFIG_BUG
32
33
34
35
36
37
38
39#define BUG() do { \
40 __asm__ __volatile__( \
41 "1: twi 31,0,0\n" \
42 ".section __bug_table,\"a\"\n" \
43 "\t"PPC_LONG" 1b,%0,%1,%2\n" \
44 ".previous" \
45 : : "i" (__LINE__), "i" (__FILE__), "i" (__FUNCTION__)); \
46} while (0)
47
48#define BUG_ON(x) do { \
49 if (__builtin_constant_p(x)) { \
50 if (x) \
51 BUG(); \
52 } else { \
53 __asm__ __volatile__( \
54 "1: "PPC_TLNEI" %0,0\n" \
55 ".section __bug_table,\"a\"\n" \
56 "\t"PPC_LONG" 1b,%1,%2,%3\n" \
57 ".previous" \
58 : : "r" ((long)(x)), "i" (__LINE__), \
59 "i" (__FILE__), "i" (__FUNCTION__)); \
60 } \
61} while (0)
62
63#define __WARN() do { \
64 __asm__ __volatile__( \
65 "1: twi 31,0,0\n" \
66 ".section __bug_table,\"a\"\n" \
67 "\t"PPC_LONG" 1b,%0,%1,%2\n" \
68 ".previous" \
69 : : "i" (__LINE__ + BUG_WARNING_TRAP), \
70 "i" (__FILE__), "i" (__FUNCTION__)); \
71} while (0)
72
73#define WARN_ON(x) do { \
74 if (__builtin_constant_p(x)) { \
75 if (x) \
76 __WARN(); \
77 } else { \
78 __asm__ __volatile__( \
79 "1: "PPC_TLNEI" %0,0\n" \
80 ".section __bug_table,\"a\"\n" \
81 "\t"PPC_LONG" 1b,%1,%2,%3\n" \
82 ".previous" \
83 : : "r" ((long)(x)), \
84 "i" (__LINE__ + BUG_WARNING_TRAP), \
85 "i" (__FILE__), "i" (__FUNCTION__)); \
86 } \
87} while (0)
88
89#define HAVE_ARCH_BUG
90#define HAVE_ARCH_BUG_ON
91#define HAVE_ARCH_WARN_ON
92#endif
93#endif
94
95#include <asm-generic/bug.h>
96
97#endif
98#endif
99