xref: /linux/include/linux/bug.h (revision 7664c5a1da4711bb6383117f51b94c8dc8f3f1cd)
1*7664c5a1SJeremy Fitzhardinge #ifndef _LINUX_BUG_H
2*7664c5a1SJeremy Fitzhardinge #define _LINUX_BUG_H
3*7664c5a1SJeremy Fitzhardinge 
4*7664c5a1SJeremy Fitzhardinge #include <linux/module.h>
5*7664c5a1SJeremy Fitzhardinge #include <asm/bug.h>
6*7664c5a1SJeremy Fitzhardinge 
7*7664c5a1SJeremy Fitzhardinge enum bug_trap_type {
8*7664c5a1SJeremy Fitzhardinge 	BUG_TRAP_TYPE_NONE = 0,
9*7664c5a1SJeremy Fitzhardinge 	BUG_TRAP_TYPE_WARN = 1,
10*7664c5a1SJeremy Fitzhardinge 	BUG_TRAP_TYPE_BUG = 2,
11*7664c5a1SJeremy Fitzhardinge };
12*7664c5a1SJeremy Fitzhardinge 
13*7664c5a1SJeremy Fitzhardinge #ifdef CONFIG_GENERIC_BUG
14*7664c5a1SJeremy Fitzhardinge #include <asm-generic/bug.h>
15*7664c5a1SJeremy Fitzhardinge 
16*7664c5a1SJeremy Fitzhardinge static inline int is_warning_bug(const struct bug_entry *bug)
17*7664c5a1SJeremy Fitzhardinge {
18*7664c5a1SJeremy Fitzhardinge 	return bug->flags & BUGFLAG_WARNING;
19*7664c5a1SJeremy Fitzhardinge }
20*7664c5a1SJeremy Fitzhardinge 
21*7664c5a1SJeremy Fitzhardinge const struct bug_entry *find_bug(unsigned long bugaddr);
22*7664c5a1SJeremy Fitzhardinge 
23*7664c5a1SJeremy Fitzhardinge enum bug_trap_type report_bug(unsigned long bug_addr);
24*7664c5a1SJeremy Fitzhardinge 
25*7664c5a1SJeremy Fitzhardinge int  module_bug_finalize(const Elf_Ehdr *, const Elf_Shdr *,
26*7664c5a1SJeremy Fitzhardinge 			 struct module *);
27*7664c5a1SJeremy Fitzhardinge void module_bug_cleanup(struct module *);
28*7664c5a1SJeremy Fitzhardinge 
29*7664c5a1SJeremy Fitzhardinge /* These are defined by the architecture */
30*7664c5a1SJeremy Fitzhardinge int is_valid_bugaddr(unsigned long addr);
31*7664c5a1SJeremy Fitzhardinge 
32*7664c5a1SJeremy Fitzhardinge #else	/* !CONFIG_GENERIC_BUG */
33*7664c5a1SJeremy Fitzhardinge 
34*7664c5a1SJeremy Fitzhardinge static inline enum bug_trap_type report_bug(unsigned long bug_addr)
35*7664c5a1SJeremy Fitzhardinge {
36*7664c5a1SJeremy Fitzhardinge 	return BUG_TRAP_TYPE_BUG;
37*7664c5a1SJeremy Fitzhardinge }
38*7664c5a1SJeremy Fitzhardinge static inline int  module_bug_finalize(const Elf_Ehdr *hdr,
39*7664c5a1SJeremy Fitzhardinge 					const Elf_Shdr *sechdrs,
40*7664c5a1SJeremy Fitzhardinge 					struct module *mod)
41*7664c5a1SJeremy Fitzhardinge {
42*7664c5a1SJeremy Fitzhardinge 	return 0;
43*7664c5a1SJeremy Fitzhardinge }
44*7664c5a1SJeremy Fitzhardinge static inline void module_bug_cleanup(struct module *mod) {}
45*7664c5a1SJeremy Fitzhardinge 
46*7664c5a1SJeremy Fitzhardinge #endif	/* CONFIG_GENERIC_BUG */
47*7664c5a1SJeremy Fitzhardinge #endif	/* _LINUX_BUG_H */
48