23 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
25 #include <linux/kernel.h>
27 #include <linux/module.h>
28 #include <linux/version.h>
30 #include <linux/time.h>
34 #include <linux/slab.h>
35 #include <linux/compiler.h>
38 #define RAMOOPS_KERNMSG_HDR "===="
39 #define MIN_MEM_SIZE 4096UL
44 "size of each dump done on oops/panic");
54 static ulong mem_address;
57 "start of reserved RAM used to store oops/panic logs");
62 "size of reserved RAM used to store oops/panic logs");
64 static int dump_oops = 1;
67 "set to 1 to dump oopses, 0 to only dump panics (default 1)");
69 static int ramoops_ecc;
72 "if non-zero, the option enables ECC support and specifies "
73 "ECC buffer size in bytes (1 is a special value, means 16 "
98 static int ramoops_pstore_open(
struct pstore_info *psi)
178 len = hdr ?
strlen(hdr) : 0;
188 const char *buf,
size_t size,
229 hlen = ramoops_write_kmsg_hdr(prz);
271 .open = ramoops_pstore_open,
272 .read = ramoops_pstore_read,
273 .write_buf = ramoops_pstore_write_buf,
274 .erase = ramoops_pstore_erase,
285 for (i = 0; !IS_ERR_OR_NULL(cxt->
przs[i]); i++)
306 dev_err(dev,
"failed to initialize a prz array for dumps\n");
314 if (IS_ERR(cxt->
przs[i])) {
315 err = PTR_ERR(cxt->
przs[i]);
316 dev_err(dev,
"failed to request mem region (0x%zx@0x%llx): %d\n",
317 sz, (
unsigned long long)*paddr, err);
325 ramoops_free_przs(cxt);
336 if (*paddr + sz > *paddr + cxt->
size)
341 int err = PTR_ERR(*prz);
343 dev_err(dev,
"failed to request mem region (0x%zx@0x%llx): %d\n",
344 sz, (
unsigned long long)*paddr, err);
372 pr_err(
"The memory size and the record/console size must be "
394 err = ramoops_init_przs(dev, cxt, &paddr, dump_mem_sz);
398 err = ramoops_init_prz(dev, cxt, &cxt->
cprz, &paddr,
409 pr_err(
"memory size too small, minimum is %zu\n",
423 cxt->
pstore.bufsize = 1024;
428 pr_err(
"cannot allocate pstore buffer\n");
434 pr_err(
"registering with pstore failed\n");
447 pr_info(
"attached 0x%lx@0x%llx, ecc: %d\n",
463 ramoops_free_przs(cxt);
490 .probe = ramoops_probe,
498 static void ramoops_register_dummy(
void)
503 pr_info(
"using module parameters\n");
505 dummy_data = kzalloc(
sizeof(*dummy_data),
GFP_KERNEL);
507 pr_info(
"could not allocate pdata\n");
521 dummy_data->
ecc_size = ramoops_ecc == 1 ? 16 : ramoops_ecc;
523 dummy = platform_device_register_data(
NULL,
"ramoops", -1,
526 pr_info(
"could not create platform device: %ld\n",
531 static int __init ramoops_init(
void)
533 ramoops_register_dummy();
538 static void __exit ramoops_exit(
void)