Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | #ifndef _ASMARM_BUG_H |
| 2 | #define _ASMARM_BUG_H |
| 3 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4 | |
Matt Mackall | c8538a7 | 2005-05-01 08:59:01 -0700 | [diff] [blame] | 5 | #ifdef CONFIG_BUG |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6 | |
Simon Glass | d3dc306 | 2011-08-16 23:44:26 +0100 | [diff] [blame] | 7 | /* |
| 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 Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 15 | #else |
Simon Glass | d3dc306 | 2011-08-16 23:44:26 +0100 | [diff] [blame] | 16 | #define BUG_INSTR_VALUE 0xe7f001f2 |
| 17 | #define BUG_INSTR_TYPE ".word " |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 18 | #endif |
| 19 | |
Simon Glass | d3dc306 | 2011-08-16 23:44:26 +0100 | [diff] [blame] | 20 | |
| 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) \ |
| 34 | do { \ |
| 35 | BUILD_BUG_ON(sizeof(struct bug_entry) != 12); \ |
| 36 | asm volatile("1:\t" BUG_INSTR_TYPE #__value "\n" \ |
| 37 | ".pushsection .rodata.str, \"aMS\", %progbits, 1\n" \ |
| 38 | "2:\t.asciz " #__file "\n" \ |
| 39 | ".popsection\n" \ |
| 40 | ".pushsection __bug_table,\"a\"\n" \ |
| 41 | "3:\t.word 1b, 2b\n" \ |
| 42 | "\t.hword " #__line ", 0\n" \ |
| 43 | ".popsection"); \ |
| 44 | unreachable(); \ |
| 45 | } while (0) |
| 46 | |
| 47 | #else /* not CONFIG_DEBUG_BUGVERBOSE */ |
| 48 | |
| 49 | #define __BUG(__file, __line, __value) \ |
| 50 | do { \ |
| 51 | asm volatile(BUG_INSTR_TYPE #__value); \ |
| 52 | unreachable(); \ |
| 53 | } while (0) |
| 54 | #endif /* CONFIG_DEBUG_BUGVERBOSE */ |
| 55 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 56 | #define HAVE_ARCH_BUG |
Simon Glass | d3dc306 | 2011-08-16 23:44:26 +0100 | [diff] [blame] | 57 | #endif /* CONFIG_BUG */ |
Matt Mackall | c8538a7 | 2005-05-01 08:59:01 -0700 | [diff] [blame] | 58 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 59 | #include <asm-generic/bug.h> |
| 60 | |
| 61 | #endif |