| Simon Kagstrom | 456b565 | 2009-10-16 14:09:18 +0200 | [diff] [blame] | 1 | /* | 
 | 2 |  * linux/include/kmsg_dump.h | 
 | 3 |  * | 
 | 4 |  * Copyright (C) 2009 Net Insight AB | 
 | 5 |  * | 
 | 6 |  * Author: Simon Kagstrom <simon.kagstrom@netinsight.net> | 
 | 7 |  * | 
 | 8 |  * This file is subject to the terms and conditions of the GNU General Public | 
 | 9 |  * License.  See the file COPYING in the main directory of this archive | 
 | 10 |  * for more details. | 
 | 11 |  */ | 
 | 12 | #ifndef _LINUX_KMSG_DUMP_H | 
 | 13 | #define _LINUX_KMSG_DUMP_H | 
 | 14 |  | 
| Randy Dunlap | ac56224 | 2011-06-15 15:08:17 -0700 | [diff] [blame] | 15 | #include <linux/errno.h> | 
| Simon Kagstrom | 456b565 | 2009-10-16 14:09:18 +0200 | [diff] [blame] | 16 | #include <linux/list.h> | 
 | 17 |  | 
 | 18 | enum kmsg_dump_reason { | 
 | 19 | 	KMSG_DUMP_OOPS, | 
 | 20 | 	KMSG_DUMP_PANIC, | 
| KOSAKI Motohiro | 0f4bd46 | 2009-12-22 03:15:43 +0000 | [diff] [blame] | 21 | 	KMSG_DUMP_KEXEC, | 
| Seiji Aguchi | 04c6862 | 2011-01-12 16:59:30 -0800 | [diff] [blame] | 22 | 	KMSG_DUMP_RESTART, | 
 | 23 | 	KMSG_DUMP_HALT, | 
 | 24 | 	KMSG_DUMP_POWEROFF, | 
 | 25 | 	KMSG_DUMP_EMERG, | 
| Simon Kagstrom | 456b565 | 2009-10-16 14:09:18 +0200 | [diff] [blame] | 26 | }; | 
 | 27 |  | 
 | 28 | /** | 
 | 29 |  * struct kmsg_dumper - kernel crash message dumper structure | 
 | 30 |  * @dump:	The callback which gets called on crashes. The buffer is passed | 
 | 31 |  * 		as two sections, where s1 (length l1) contains the older | 
 | 32 |  * 		messages and s2 (length l2) contains the newer. | 
 | 33 |  * @list:	Entry in the dumper list (private) | 
 | 34 |  * @registered:	Flag that specifies if this is already registered | 
 | 35 |  */ | 
 | 36 | struct kmsg_dumper { | 
 | 37 | 	void (*dump)(struct kmsg_dumper *dumper, enum kmsg_dump_reason reason, | 
 | 38 | 			const char *s1, unsigned long l1, | 
 | 39 | 			const char *s2, unsigned long l2); | 
 | 40 | 	struct list_head list; | 
 | 41 | 	int registered; | 
 | 42 | }; | 
 | 43 |  | 
| Randy Dunlap | 595dd3d | 2009-12-01 10:52:02 -0800 | [diff] [blame] | 44 | #ifdef CONFIG_PRINTK | 
| Simon Kagstrom | 456b565 | 2009-10-16 14:09:18 +0200 | [diff] [blame] | 45 | void kmsg_dump(enum kmsg_dump_reason reason); | 
 | 46 |  | 
 | 47 | int kmsg_dump_register(struct kmsg_dumper *dumper); | 
 | 48 |  | 
 | 49 | int kmsg_dump_unregister(struct kmsg_dumper *dumper); | 
| Randy Dunlap | 595dd3d | 2009-12-01 10:52:02 -0800 | [diff] [blame] | 50 | #else | 
 | 51 | static inline void kmsg_dump(enum kmsg_dump_reason reason) | 
 | 52 | { | 
 | 53 | } | 
 | 54 |  | 
 | 55 | static inline int kmsg_dump_register(struct kmsg_dumper *dumper) | 
 | 56 | { | 
 | 57 | 	return -EINVAL; | 
 | 58 | } | 
 | 59 |  | 
 | 60 | static inline int kmsg_dump_unregister(struct kmsg_dumper *dumper) | 
 | 61 | { | 
 | 62 | 	return -EINVAL; | 
 | 63 | } | 
 | 64 | #endif | 
| Simon Kagstrom | 456b565 | 2009-10-16 14:09:18 +0200 | [diff] [blame] | 65 |  | 
 | 66 | #endif /* _LINUX_KMSG_DUMP_H */ |