Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | #ifndef _ASMARM_BUG_H |
| 2 | #define _ASMARM_BUG_H |
| 3 | |
David Howells | 9f97da7 | 2012-03-28 18:30:01 +0100 | [diff] [blame] | 4 | #include <linux/linkage.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5 | |
Matt Mackall | c8538a7 | 2005-05-01 08:59:01 -0700 | [diff] [blame] | 6 | #ifdef CONFIG_BUG |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7 | |
Simon Glass | 87e040b | 2011-08-16 23:44:26 +0100 | [diff] [blame] | 8 | /* |
| 9 | * Use a suitable undefined instruction to use for ARM/Thumb2 bug handling. |
| 10 | * We need to be careful not to conflict with those used by other modules and |
| 11 | * the register_undef_hook() system. |
| 12 | */ |
| 13 | #ifdef CONFIG_THUMB2_KERNEL |
| 14 | #define BUG_INSTR_VALUE 0xde02 |
| 15 | #define BUG_INSTR_TYPE ".hword " |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 16 | #else |
Simon Glass | 87e040b | 2011-08-16 23:44:26 +0100 | [diff] [blame] | 17 | #define BUG_INSTR_VALUE 0xe7f001f2 |
| 18 | #define BUG_INSTR_TYPE ".word " |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 19 | #endif |
| 20 | |
Simon Glass | 87e040b | 2011-08-16 23:44:26 +0100 | [diff] [blame] | 21 | |
| 22 | #define BUG() _BUG(__FILE__, __LINE__, BUG_INSTR_VALUE) |
| 23 | #define _BUG(file, line, value) __BUG(file, line, value) |
| 24 | |
| 25 | #ifdef CONFIG_DEBUG_BUGVERBOSE |
| 26 | |
| 27 | /* |
| 28 | * The extra indirection is to ensure that the __FILE__ string comes through |
| 29 | * OK. Many version of gcc do not support the asm %c parameter which would be |
| 30 | * preferable to this unpleasantness. We use mergeable string sections to |
| 31 | * avoid multiple copies of the string appearing in the kernel image. |
| 32 | */ |
| 33 | |
| 34 | #define __BUG(__file, __line, __value) \ |
| 35 | do { \ |
Simon Glass | 87e040b | 2011-08-16 23:44:26 +0100 | [diff] [blame] | 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 | 87e040b | 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 | |
David Howells | 9f97da7 | 2012-03-28 18:30:01 +0100 | [diff] [blame] | 61 | struct pt_regs; |
| 62 | void die(const char *msg, struct pt_regs *regs, int err); |
| 63 | |
| 64 | struct siginfo; |
| 65 | void arm_notify_die(const char *str, struct pt_regs *regs, struct siginfo *info, |
| 66 | unsigned long err, unsigned long trap); |
| 67 | |
| 68 | #ifdef CONFIG_ARM_LPAE |
| 69 | #define FAULT_CODE_ALIGNMENT 33 |
| 70 | #define FAULT_CODE_DEBUG 34 |
| 71 | #else |
| 72 | #define FAULT_CODE_ALIGNMENT 1 |
| 73 | #define FAULT_CODE_DEBUG 2 |
| 74 | #endif |
| 75 | |
| 76 | void hook_fault_code(int nr, int (*fn)(unsigned long, unsigned int, |
| 77 | struct pt_regs *), |
| 78 | int sig, int code, const char *name); |
| 79 | |
| 80 | void hook_ifault_code(int nr, int (*fn)(unsigned long, unsigned int, |
| 81 | struct pt_regs *), |
| 82 | int sig, int code, const char *name); |
| 83 | |
| 84 | extern asmlinkage void c_backtrace(unsigned long fp, int pmode); |
| 85 | |
| 86 | struct mm_struct; |
| 87 | extern void show_pte(struct mm_struct *mm, unsigned long addr); |
| 88 | extern void __show_regs(struct pt_regs *); |
| 89 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 90 | #endif |