blob: 2a0d7d651dc34f98daff0d111c5e458339006945 [file] [log] [blame]
Simon Kagstrom456b5652009-10-16 14:09:18 +02001/*
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
15#include <linux/list.h>
16
17enum kmsg_dump_reason {
18 KMSG_DUMP_OOPS,
19 KMSG_DUMP_PANIC,
KOSAKI Motohiro0f4bd462009-12-22 03:15:43 +000020 KMSG_DUMP_KEXEC,
Seiji Aguchi04c68622011-01-12 16:59:30 -080021 KMSG_DUMP_RESTART,
22 KMSG_DUMP_HALT,
23 KMSG_DUMP_POWEROFF,
24 KMSG_DUMP_EMERG,
Simon Kagstrom456b5652009-10-16 14:09:18 +020025};
26
27/**
28 * struct kmsg_dumper - kernel crash message dumper structure
29 * @dump: The callback which gets called on crashes. The buffer is passed
30 * as two sections, where s1 (length l1) contains the older
31 * messages and s2 (length l2) contains the newer.
32 * @list: Entry in the dumper list (private)
33 * @registered: Flag that specifies if this is already registered
34 */
35struct kmsg_dumper {
36 void (*dump)(struct kmsg_dumper *dumper, enum kmsg_dump_reason reason,
37 const char *s1, unsigned long l1,
38 const char *s2, unsigned long l2);
39 struct list_head list;
40 int registered;
41};
42
Randy Dunlap595dd3d2009-12-01 10:52:02 -080043#ifdef CONFIG_PRINTK
Simon Kagstrom456b5652009-10-16 14:09:18 +020044void kmsg_dump(enum kmsg_dump_reason reason);
45
46int kmsg_dump_register(struct kmsg_dumper *dumper);
47
48int kmsg_dump_unregister(struct kmsg_dumper *dumper);
Randy Dunlap595dd3d2009-12-01 10:52:02 -080049#else
50static inline void kmsg_dump(enum kmsg_dump_reason reason)
51{
52}
53
54static inline int kmsg_dump_register(struct kmsg_dumper *dumper)
55{
56 return -EINVAL;
57}
58
59static inline int kmsg_dump_unregister(struct kmsg_dumper *dumper)
60{
61 return -EINVAL;
62}
63#endif
Simon Kagstrom456b5652009-10-16 14:09:18 +020064
65#endif /* _LINUX_KMSG_DUMP_H */