pstore_ram.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. /*
  2. * Copyright (C) 2010 Marco Stornelli <marco.stornelli@gmail.com>
  3. * Copyright (C) 2011 Kees Cook <keescook@chromium.org>
  4. * Copyright (C) 2011 Google, Inc.
  5. *
  6. * This software is licensed under the terms of the GNU General Public
  7. * License version 2, as published by the Free Software Foundation, and
  8. * may be copied, distributed, and modified under those terms.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. */
  16. #ifndef __LINUX_PSTORE_RAM_H__
  17. #define __LINUX_PSTORE_RAM_H__
  18. #include <linux/device.h>
  19. #include <linux/kernel.h>
  20. #include <linux/list.h>
  21. #include <linux/types.h>
  22. #include <linux/init.h>
  23. struct persistent_ram_buffer;
  24. struct persistent_ram_descriptor {
  25. const char *name;
  26. phys_addr_t size;
  27. };
  28. struct persistent_ram {
  29. phys_addr_t start;
  30. phys_addr_t size;
  31. int num_descs;
  32. struct persistent_ram_descriptor *descs;
  33. struct list_head node;
  34. };
  35. struct persistent_ram_zone {
  36. phys_addr_t paddr;
  37. size_t size;
  38. void *vaddr;
  39. struct persistent_ram_buffer *buffer;
  40. size_t buffer_size;
  41. /* ECC correction */
  42. bool ecc;
  43. char *par_buffer;
  44. char *par_header;
  45. struct rs_control *rs_decoder;
  46. int corrected_bytes;
  47. int bad_blocks;
  48. int ecc_block_size;
  49. int ecc_size;
  50. int ecc_symsize;
  51. int ecc_poly;
  52. char *old_log;
  53. size_t old_log_size;
  54. };
  55. int persistent_ram_early_init(struct persistent_ram *ram);
  56. struct persistent_ram_zone * __init persistent_ram_new(phys_addr_t start,
  57. size_t size,
  58. bool ecc);
  59. void persistent_ram_free(struct persistent_ram_zone *prz);
  60. void persistent_ram_zap(struct persistent_ram_zone *prz);
  61. struct persistent_ram_zone *persistent_ram_init_ringbuffer(struct device *dev,
  62. bool ecc);
  63. int persistent_ram_write(struct persistent_ram_zone *prz, const void *s,
  64. unsigned int count);
  65. void persistent_ram_save_old(struct persistent_ram_zone *prz);
  66. size_t persistent_ram_old_size(struct persistent_ram_zone *prz);
  67. void *persistent_ram_old(struct persistent_ram_zone *prz);
  68. void persistent_ram_free_old(struct persistent_ram_zone *prz);
  69. ssize_t persistent_ram_ecc_string(struct persistent_ram_zone *prz,
  70. char *str, size_t len);
  71. /*
  72. * Ramoops platform data
  73. * @mem_size memory size for ramoops
  74. * @mem_address physical memory address to contain ramoops
  75. */
  76. struct ramoops_platform_data {
  77. unsigned long mem_size;
  78. unsigned long mem_address;
  79. unsigned long record_size;
  80. unsigned long console_size;
  81. int dump_oops;
  82. bool ecc;
  83. };
  84. #endif