blob: 99817a802ca4e4d7c6a6784b3be2d39620018aa0 [file] [log] [blame]
Becky Bruce25433b12005-09-19 17:01:54 -05001#ifndef _ASM_POWERPC_BUG_H
2#define _ASM_POWERPC_BUG_H
Arnd Bergmann88ced032005-12-16 22:43:46 +01003#ifdef __KERNEL__
Linus Torvalds1da177e2005-04-16 15:20:36 -07004
David Gibson3ddfbcf2005-11-10 12:56:55 +11005#include <asm/asm-compat.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -07006/*
7 * Define an illegal instr to trap on the bug.
8 * We don't use 0 because that marks the end of a function
9 * in the ELF ABI. That's "Boo Boo" in case you wonder...
10 */
11#define BUG_OPCODE .long 0x00b00b00 /* For asm */
12#define BUG_ILLEGAL_INSTR "0x00b00b00" /* For BUG macro */
13
14#ifndef __ASSEMBLY__
15
16struct bug_entry {
17 unsigned long bug_addr;
Paul Mackerras89003eb2005-11-01 21:54:38 +110018 long line;
Linus Torvalds1da177e2005-04-16 15:20:36 -070019 const char *file;
20 const char *function;
21};
22
23struct bug_entry *find_bug(unsigned long bugaddr);
24
25/*
26 * If this bit is set in the line number it means that the trap
27 * is for WARN_ON rather than BUG or BUG_ON.
28 */
29#define BUG_WARNING_TRAP 0x1000000
30
Matt Mackallc8538a72005-05-01 08:59:01 -070031#ifdef CONFIG_BUG
32
Linus Torvalds1da177e2005-04-16 15:20:36 -070033#define BUG() do { \
34 __asm__ __volatile__( \
35 "1: twi 31,0,0\n" \
Paul Mackerras104dd652005-11-02 15:19:47 +110036 ".section __bug_table,\"a\"\n" \
David Gibson3ddfbcf2005-11-10 12:56:55 +110037 "\t"PPC_LONG" 1b,%0,%1,%2\n" \
Linus Torvalds1da177e2005-04-16 15:20:36 -070038 ".previous" \
39 : : "i" (__LINE__), "i" (__FILE__), "i" (__FUNCTION__)); \
40} while (0)
41
42#define BUG_ON(x) do { \
43 __asm__ __volatile__( \
David Gibson3ddfbcf2005-11-10 12:56:55 +110044 "1: "PPC_TLNEI" %0,0\n" \
Paul Mackerras104dd652005-11-02 15:19:47 +110045 ".section __bug_table,\"a\"\n" \
David Gibson3ddfbcf2005-11-10 12:56:55 +110046 "\t"PPC_LONG" 1b,%1,%2,%3\n" \
Linus Torvalds1da177e2005-04-16 15:20:36 -070047 ".previous" \
Al Virof2cad7a2005-11-02 03:10:43 +000048 : : "r" ((long)(x)), "i" (__LINE__), \
Anton Blanchard32818c22005-08-26 18:34:07 -070049 "i" (__FILE__), "i" (__FUNCTION__)); \
Linus Torvalds1da177e2005-04-16 15:20:36 -070050} while (0)
51
52#define WARN_ON(x) do { \
53 __asm__ __volatile__( \
David Gibson3ddfbcf2005-11-10 12:56:55 +110054 "1: "PPC_TLNEI" %0,0\n" \
Paul Mackerras104dd652005-11-02 15:19:47 +110055 ".section __bug_table,\"a\"\n" \
David Gibson3ddfbcf2005-11-10 12:56:55 +110056 "\t"PPC_LONG" 1b,%1,%2,%3\n" \
Linus Torvalds1da177e2005-04-16 15:20:36 -070057 ".previous" \
Al Virof2cad7a2005-11-02 03:10:43 +000058 : : "r" ((long)(x)), \
Anton Blanchard32818c22005-08-26 18:34:07 -070059 "i" (__LINE__ + BUG_WARNING_TRAP), \
Linus Torvalds1da177e2005-04-16 15:20:36 -070060 "i" (__FILE__), "i" (__FUNCTION__)); \
61} while (0)
62
Linus Torvalds1da177e2005-04-16 15:20:36 -070063#define HAVE_ARCH_BUG
64#define HAVE_ARCH_BUG_ON
65#define HAVE_ARCH_WARN_ON
Becky Bruce25433b12005-09-19 17:01:54 -050066#endif /* CONFIG_BUG */
67#endif /* __ASSEMBLY __ */
Matt Mackallc8538a72005-05-01 08:59:01 -070068
Linus Torvalds1da177e2005-04-16 15:20:36 -070069#include <asm-generic/bug.h>
70
Arnd Bergmann88ced032005-12-16 22:43:46 +010071#endif /* __KERNEL__ */
Becky Bruce25433b12005-09-19 17:01:54 -050072#endif /* _ASM_POWERPC_BUG_H */