Revert "WORKAROUND: mkbp: Remove KEY_BATTERY from valid keys."
[cascardo/linux.git] / Documentation / ramoops.txt
1 Ramoops oops/panic logger
2 =========================
3
4 Sergiu Iordache <sergiu@chromium.org>
5
6 Updated: 4 June 2012
7
8 0. Introduction
9
10 Ramoops is an oops/panic logger that writes its logs to RAM before the system
11 crashes. It works by logging oopses and panics in a circular buffer. Ramoops
12 needs a system with persistent RAM so that the content of that area can
13 survive after a restart.
14
15 1. Ramoops concepts
16
17 Ramoops uses a predefined memory area to store the dump. The start and size of
18 the memory area are set using two variables:
19   * "mem_address" for the start
20   * "mem_size" for the size. The memory size will be rounded down to a
21   power of two.
22
23 The memory area is divided into "record_size" chunks (also rounded down to
24 power of two) and each oops/panic writes a "record_size" chunk of
25 information.
26
27 Dumping both oopses and panics can be done by setting 1 in the "dump_oops"
28 variable while setting 0 in that variable dumps only the panics.
29
30 The module uses a counter to record multiple dumps but the counter gets reset
31 on restart (i.e. new dumps after the restart will overwrite old ones).
32
33 2. Setting the parameters
34
35 Setting the ramoops parameters can be done in 2 different manners:
36  1. Use the Flattened Device Tree to specify the platform data.
37  An example of this is:
38   arch/arm/boot/dts/$BOARD.dts:
39         ramoops {
40                 compatible = "ramoops";
41                 reg = <0x41f00000 0x00100000>;
42                 record-size = <0x00020000>;
43                 dump-oops;
44         };
45  The "reg = <0x41f00000 0x00100000>" line tells ramoops to use 1MB at
46  physical address 0x41f00000.
47  The "record-size = <0x00020000>" line specifies a record size of 128KB.
48  The optional "dump-oops" line tells ramoops to dump oopses as well as panics.
49
50  2. Use a platform device and set the platform data. The parameters can then
51  be set through that platform data. An example of doing that is:
52
53 #include <linux/ramoops.h>
54 [...]
55
56 static struct ramoops_platform_data ramoops_data = {
57         .mem_size               = <...>,
58         .mem_address            = <...>,
59         .record_size            = <...>,
60         .dump_oops              = <...>,
61 };
62
63 static struct platform_device ramoops_dev = {
64         .name = "ramoops",
65         .dev = {
66                 .platform_data = &ramoops_data,
67         },
68 };
69
70 [... inside a function ...]
71 int ret;
72
73 ret = platform_device_register(&ramoops_dev);
74 if (ret) {
75         printk(KERN_ERR "unable to register platform device\n");
76         return ret;
77 }
78
79 3. Dump format
80
81 The data dump begins with a header, currently defined as "====" followed by a
82 timestamp and a new line. The dump then continues with the actual data.
83
84 4. Reading the data
85
86 The dump data can be read from memory (through /dev/mem or other means).
87 Getting the module parameters, which are needed in order to parse the data, can
88 be done through /sys/module/ramoops/parameters/* .