powerpc/mm: Merge various PTE bits and accessors definitions
[deliverable/linux.git] / arch / powerpc / include / asm / bug.h
CommitLineData
25433b12
BB
1#ifndef _ASM_POWERPC_BUG_H
2#define _ASM_POWERPC_BUG_H
88ced031 3#ifdef __KERNEL__
1da177e4 4
3ddfbcf1 5#include <asm/asm-compat.h>
a58f053b 6
1da177e4
LT
7/*
8 * Define an illegal instr to trap on the bug.
9 * We don't use 0 because that marks the end of a function
10 * in the ELF ABI. That's "Boo Boo" in case you wonder...
11 */
12#define BUG_OPCODE .long 0x00b00b00 /* For asm */
13#define BUG_ILLEGAL_INSTR "0x00b00b00" /* For BUG macro */
14
c8538a7a
MM
15#ifdef CONFIG_BUG
16
007d88d0 17#ifdef __ASSEMBLY__
a58f053b 18#include <asm/asm-offsets.h>
007d88d0
DW
19#ifdef CONFIG_DEBUG_BUGVERBOSE
20.macro EMIT_BUG_ENTRY addr,file,line,flags
21 .section __bug_table,"a"
225001: PPC_LONG \addr, 5002f
23 .short \line, \flags
24 .org 5001b+BUG_ENTRY_SIZE
25 .previous
26 .section .rodata,"a"
275002: .asciz "\file"
28 .previous
29.endm
30#else
a58f053b 31.macro EMIT_BUG_ENTRY addr,file,line,flags
007d88d0
DW
32 .section __bug_table,"a"
335001: PPC_LONG \addr
34 .short \flags
35 .org 5001b+BUG_ENTRY_SIZE
36 .previous
37.endm
38#endif /* verbose */
39
40#else /* !__ASSEMBLY__ */
73c9ceab
JF
41/* _EMIT_BUG_ENTRY expects args %0,%1,%2,%3 to be FILE, LINE, flags and
42 sizeof(struct bug_entry), respectively */
43#ifdef CONFIG_DEBUG_BUGVERBOSE
44#define _EMIT_BUG_ENTRY \
45 ".section __bug_table,\"a\"\n" \
46 "2:\t" PPC_LONG "1b, %0\n" \
47 "\t.short %1, %2\n" \
48 ".org 2b+%3\n" \
49 ".previous\n"
50#else
51#define _EMIT_BUG_ENTRY \
52 ".section __bug_table,\"a\"\n" \
53 "2:\t" PPC_LONG "1b\n" \
54 "\t.short %2\n" \
55 ".org 2b+%3\n" \
56 ".previous\n"
57#endif
58
e3f94b85
ME
59/*
60 * BUG_ON() and WARN_ON() do their best to cooperate with compile-time
61 * optimisations. However depending on the complexity of the condition
62 * some compiler versions may not produce optimal results.
63 */
64
73c9ceab
JF
65#define BUG() do { \
66 __asm__ __volatile__( \
67 "1: twi 31,0,0\n" \
68 _EMIT_BUG_ENTRY \
69 : : "i" (__FILE__), "i" (__LINE__), \
70 "i" (0), "i" (sizeof(struct bug_entry))); \
71 for(;;) ; \
1da177e4
LT
72} while (0)
73
74#define BUG_ON(x) do { \
e3f94b85
ME
75 if (__builtin_constant_p(x)) { \
76 if (x) \
77 BUG(); \
78 } else { \
79 __asm__ __volatile__( \
73c9ceab
JF
80 "1: "PPC_TLNEI" %4,0\n" \
81 _EMIT_BUG_ENTRY \
82 : : "i" (__FILE__), "i" (__LINE__), "i" (0), \
83 "i" (sizeof(struct bug_entry)), \
97f1e7f7 84 "r" ((__force long)(x))); \
e3f94b85 85 } \
1da177e4
LT
86} while (0)
87
872345b7 88#define __WARN() do { \
1da177e4 89 __asm__ __volatile__( \
e3f94b85 90 "1: twi 31,0,0\n" \
73c9ceab
JF
91 _EMIT_BUG_ENTRY \
92 : : "i" (__FILE__), "i" (__LINE__), \
93 "i" (BUGFLAG_WARNING), \
94 "i" (sizeof(struct bug_entry))); \
e3f94b85
ME
95} while (0)
96
684f9783 97#define WARN_ON(x) ({ \
8d4fbcfb 98 int __ret_warn_on = !!(x); \
684f9783
HX
99 if (__builtin_constant_p(__ret_warn_on)) { \
100 if (__ret_warn_on) \
872345b7 101 __WARN(); \
e3f94b85
ME
102 } else { \
103 __asm__ __volatile__( \
73c9ceab
JF
104 "1: "PPC_TLNEI" %4,0\n" \
105 _EMIT_BUG_ENTRY \
106 : : "i" (__FILE__), "i" (__LINE__), \
107 "i" (BUGFLAG_WARNING), \
108 "i" (sizeof(struct bug_entry)), \
109 "r" (__ret_warn_on)); \
e3f94b85 110 } \
684f9783
HX
111 unlikely(__ret_warn_on); \
112})
1da177e4 113
1da177e4
LT
114#define HAVE_ARCH_BUG
115#define HAVE_ARCH_BUG_ON
116#define HAVE_ARCH_WARN_ON
25433b12 117#endif /* __ASSEMBLY __ */
a58f053b
BH
118#else
119#ifdef __ASSEMBLY__
120.macro EMIT_BUG_ENTRY addr,file,line,flags
121.endm
122#else /* !__ASSEMBLY__ */
123#define _EMIT_BUG_ENTRY
124#endif
007d88d0 125#endif /* CONFIG_BUG */
c8538a7a 126
1da177e4
LT
127#include <asm-generic/bug.h>
128
88ced031 129#endif /* __KERNEL__ */
25433b12 130#endif /* _ASM_POWERPC_BUG_H */
This page took 0.378663 seconds and 5 git commands to generate.