0%
注册pstore_info,提供pstore存储区域和操作函数;
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
| static int ramoops_probe(struct platform_device *pdev) { struct ramoops_context * cxt = &oops_cxt;
if (cxt->max_dump_cnt) goto fail_out; cxt->pstore.data = cxt; err = pstore_register(&cxt-pstore); } static struct ramoops_context oops_cxt = { .pstore = { .owner = THIS_MODULE, .name = "ramoops", .open = ramoops_pstore_open, .read = ramoops_pstore_read, .write_buf = ramoops_pstore_write_buf, .erase = ramoops_pstore_erase, }; };
|
注册kmsg dumper;
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
| int pstore_register(struct pstore_info * psi) { if (!psi->write) psi->write = pstore_write_compat; psinfo = psi; allocate_buf_for_compression(); pstore_register_kmsg(); } static void allocate_buf_for_compression(void) { big_oops_buf_sz = (psinfo->bufsize * 100) / cmpr; big_oops_buf = kmalloc(big_oops_buf_sz, GFP_KERNEL); } static void pstore_register_kmsg(void ) { kmsg_dump_register(&pstore_dumper); } static struct kmsg_dumper pstore_dumper = { .dump = pstore_dump, };
|