blob: 35f7237ec972bef4ce1ba24cd617571a193ce806 [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
Randy Dunlapac562242011-06-15 15:08:17 -070015#include <linux/errno.h>
Simon Kagstrom456b5652009-10-16 14:09:18 +020016#include <linux/list.h>
17
Matthew Garrettc22ab332012-03-05 14:59:10 -080018/*
19 * Keep this list arranged in rough order of priority. Anything listed after
20 * KMSG_DUMP_OOPS will not be logged by default unless printk.always_kmsg_dump
21 * is passed to the kernel.
22 */
Simon Kagstrom456b5652009-10-16 14:09:18 +020023enum kmsg_dump_reason {
Simon Kagstrom456b5652009-10-16 14:09:18 +020024 KMSG_DUMP_PANIC,
Matthew Garrettc22ab332012-03-05 14:59:10 -080025 KMSG_DUMP_OOPS,
26 KMSG_DUMP_EMERG,
Seiji Aguchi04c68622011-01-12 16:59:30 -080027 KMSG_DUMP_RESTART,
28 KMSG_DUMP_HALT,
29 KMSG_DUMP_POWEROFF,
Simon Kagstrom456b5652009-10-16 14:09:18 +020030};
31
32/**
33 * struct kmsg_dumper - kernel crash message dumper structure
34 * @dump: The callback which gets called on crashes. The buffer is passed
35 * as two sections, where s1 (length l1) contains the older
36 * messages and s2 (length l2) contains the newer.
37 * @list: Entry in the dumper list (private)
38 * @registered: Flag that specifies if this is already registered
39 */
40struct kmsg_dumper {
41 void (*dump)(struct kmsg_dumper *dumper, enum kmsg_dump_reason reason,
42 const char *s1, unsigned long l1,
43 const char *s2, unsigned long l2);
44 struct list_head list;
45 int registered;
46};
47
Randy Dunlap595dd3d2009-12-01 10:52:02 -080048#ifdef CONFIG_PRINTK
Simon Kagstrom456b5652009-10-16 14:09:18 +020049void kmsg_dump(enum kmsg_dump_reason reason);
50
51int kmsg_dump_register(struct kmsg_dumper *dumper);
52
53int kmsg_dump_unregister(struct kmsg_dumper *dumper);
Randy Dunlap595dd3d2009-12-01 10:52:02 -080054#else
55static inline void kmsg_dump(enum kmsg_dump_reason reason)
56{
57}
58
59static inline int kmsg_dump_register(struct kmsg_dumper *dumper)
60{
61 return -EINVAL;
62}
63
64static inline int kmsg_dump_unregister(struct kmsg_dumper *dumper)
65{
66 return -EINVAL;
67}
68#endif
Simon Kagstrom456b5652009-10-16 14:09:18 +020069
70#endif /* _LINUX_KMSG_DUMP_H */