blob: b274bde24905a7503f60d38672346636d093854b [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001#ifndef _ASMARM_BUG_H
2#define _ASMARM_BUG_H
3
David Howells9f97da72012-03-28 18:30:01 +01004#include <linux/linkage.h>
Ben Dooks56cbe5e2013-07-25 14:38:03 +01005#include <linux/types.h>
6#include <asm/opcodes.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -07007
Matt Mackallc8538a72005-05-01 08:59:01 -07008#ifdef CONFIG_BUG
Linus Torvalds1da177e2005-04-16 15:20:36 -07009
Simon Glass87e040b2011-08-16 23:44:26 +010010/*
11 * Use a suitable undefined instruction to use for ARM/Thumb2 bug handling.
12 * We need to be careful not to conflict with those used by other modules and
13 * the register_undef_hook() system.
14 */
15#ifdef CONFIG_THUMB2_KERNEL
16#define BUG_INSTR_VALUE 0xde02
Ben Dooks56cbe5e2013-07-25 14:38:03 +010017#define BUG_INSTR(__value) __inst_thumb16(__value)
Linus Torvalds1da177e2005-04-16 15:20:36 -070018#else
Simon Glass87e040b2011-08-16 23:44:26 +010019#define BUG_INSTR_VALUE 0xe7f001f2
Ben Dooks56cbe5e2013-07-25 14:38:03 +010020#define BUG_INSTR(__value) __inst_arm(__value)
Linus Torvalds1da177e2005-04-16 15:20:36 -070021#endif
22
Simon Glass87e040b2011-08-16 23:44:26 +010023
24#define BUG() _BUG(__FILE__, __LINE__, BUG_INSTR_VALUE)
25#define _BUG(file, line, value) __BUG(file, line, value)
26
27#ifdef CONFIG_DEBUG_BUGVERBOSE
28
29/*
30 * The extra indirection is to ensure that the __FILE__ string comes through
31 * OK. Many version of gcc do not support the asm %c parameter which would be
32 * preferable to this unpleasantness. We use mergeable string sections to
33 * avoid multiple copies of the string appearing in the kernel image.
34 */
35
36#define __BUG(__file, __line, __value) \
37do { \
Ben Dooks56cbe5e2013-07-25 14:38:03 +010038 asm volatile("1:\t" BUG_INSTR(__value) "\n" \
Simon Glass87e040b2011-08-16 23:44:26 +010039 ".pushsection .rodata.str, \"aMS\", %progbits, 1\n" \
40 "2:\t.asciz " #__file "\n" \
41 ".popsection\n" \
42 ".pushsection __bug_table,\"a\"\n" \
43 "3:\t.word 1b, 2b\n" \
44 "\t.hword " #__line ", 0\n" \
45 ".popsection"); \
46 unreachable(); \
47} while (0)
48
49#else /* not CONFIG_DEBUG_BUGVERBOSE */
50
51#define __BUG(__file, __line, __value) \
52do { \
Ben Dooks56cbe5e2013-07-25 14:38:03 +010053 asm volatile(BUG_INSTR(__value) "\n"); \
Simon Glass87e040b2011-08-16 23:44:26 +010054 unreachable(); \
55} while (0)
56#endif /* CONFIG_DEBUG_BUGVERBOSE */
57
Linus Torvalds1da177e2005-04-16 15:20:36 -070058#define HAVE_ARCH_BUG
Simon Glass87e040b2011-08-16 23:44:26 +010059#endif /* CONFIG_BUG */
Matt Mackallc8538a72005-05-01 08:59:01 -070060
Linus Torvalds1da177e2005-04-16 15:20:36 -070061#include <asm-generic/bug.h>
62
David Howells9f97da72012-03-28 18:30:01 +010063struct pt_regs;
64void die(const char *msg, struct pt_regs *regs, int err);
65
66struct siginfo;
67void arm_notify_die(const char *str, struct pt_regs *regs, struct siginfo *info,
68 unsigned long err, unsigned long trap);
69
70#ifdef CONFIG_ARM_LPAE
71#define FAULT_CODE_ALIGNMENT 33
72#define FAULT_CODE_DEBUG 34
73#else
74#define FAULT_CODE_ALIGNMENT 1
75#define FAULT_CODE_DEBUG 2
76#endif
77
78void hook_fault_code(int nr, int (*fn)(unsigned long, unsigned int,
79 struct pt_regs *),
80 int sig, int code, const char *name);
81
82void hook_ifault_code(int nr, int (*fn)(unsigned long, unsigned int,
83 struct pt_regs *),
84 int sig, int code, const char *name);
85
86extern asmlinkage void c_backtrace(unsigned long fp, int pmode);
87
88struct mm_struct;
89extern void show_pte(struct mm_struct *mm, unsigned long addr);
90extern void __show_regs(struct pt_regs *);
91
Linus Torvalds1da177e2005-04-16 15:20:36 -070092#endif