blob: fac79dceb7361b411eafad341d824f1eef7b7bfb [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001#ifndef _ASMARM_BUG_H
2#define _ASMARM_BUG_H
3
Linus Torvalds1da177e2005-04-16 15:20:36 -07004
Matt Mackallc8538a72005-05-01 08:59:01 -07005#ifdef CONFIG_BUG
Linus Torvalds1da177e2005-04-16 15:20:36 -07006
Simon Glass87e040b2011-08-16 23:44:26 +01007/*
8 * Use a suitable undefined instruction to use for ARM/Thumb2 bug handling.
9 * We need to be careful not to conflict with those used by other modules and
10 * the register_undef_hook() system.
11 */
12#ifdef CONFIG_THUMB2_KERNEL
13#define BUG_INSTR_VALUE 0xde02
14#define BUG_INSTR_TYPE ".hword "
Linus Torvalds1da177e2005-04-16 15:20:36 -070015#else
Simon Glass87e040b2011-08-16 23:44:26 +010016#define BUG_INSTR_VALUE 0xe7f001f2
17#define BUG_INSTR_TYPE ".word "
Linus Torvalds1da177e2005-04-16 15:20:36 -070018#endif
19
Simon Glass87e040b2011-08-16 23:44:26 +010020
21#define BUG() _BUG(__FILE__, __LINE__, BUG_INSTR_VALUE)
22#define _BUG(file, line, value) __BUG(file, line, value)
23
24#ifdef CONFIG_DEBUG_BUGVERBOSE
25
26/*
27 * The extra indirection is to ensure that the __FILE__ string comes through
28 * OK. Many version of gcc do not support the asm %c parameter which would be
29 * preferable to this unpleasantness. We use mergeable string sections to
30 * avoid multiple copies of the string appearing in the kernel image.
31 */
32
33#define __BUG(__file, __line, __value) \
34do { \
Simon Glass87e040b2011-08-16 23:44:26 +010035 asm volatile("1:\t" BUG_INSTR_TYPE #__value "\n" \
36 ".pushsection .rodata.str, \"aMS\", %progbits, 1\n" \
37 "2:\t.asciz " #__file "\n" \
38 ".popsection\n" \
39 ".pushsection __bug_table,\"a\"\n" \
40 "3:\t.word 1b, 2b\n" \
41 "\t.hword " #__line ", 0\n" \
42 ".popsection"); \
43 unreachable(); \
44} while (0)
45
46#else /* not CONFIG_DEBUG_BUGVERBOSE */
47
48#define __BUG(__file, __line, __value) \
49do { \
50 asm volatile(BUG_INSTR_TYPE #__value); \
51 unreachable(); \
52} while (0)
53#endif /* CONFIG_DEBUG_BUGVERBOSE */
54
Linus Torvalds1da177e2005-04-16 15:20:36 -070055#define HAVE_ARCH_BUG
Simon Glass87e040b2011-08-16 23:44:26 +010056#endif /* CONFIG_BUG */
Matt Mackallc8538a72005-05-01 08:59:01 -070057
Linus Torvalds1da177e2005-04-16 15:20:36 -070058#include <asm-generic/bug.h>
59
60#endif