pstore_ram.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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/compiler.h>
  19. #include <linux/device.h>
  20. #include <linux/init.h>
  21. #include <linux/kernel.h>
  22. #include <linux/list.h>
  23. #include <linux/types.h>
  24. /*
  25. * Choose whether access to the RAM zone requires locking or not. If a zone
  26. * can be written to from different CPUs like with ftrace for example, then
  27. * PRZ_FLAG_NO_LOCK is used. For all other cases, locking is required.
  28. */
  29. #define PRZ_FLAG_NO_LOCK BIT(0)
  30. struct persistent_ram_buffer;
  31. struct rs_control;
  32. struct persistent_ram_ecc_info {
  33. int block_size;
  34. int ecc_size;
  35. int symsize;
  36. int poly;
  37. };
  38. struct persistent_ram_zone {
  39. phys_addr_t paddr;
  40. size_t size;
  41. void *vaddr;
  42. struct persistent_ram_buffer *buffer;
  43. size_t buffer_size;
  44. u32 flags;
  45. raw_spinlock_t buffer_lock;
  46. /* ECC correction */
  47. char *par_buffer;
  48. char *par_header;
  49. struct rs_control *rs_decoder;
  50. int corrected_bytes;
  51. int bad_blocks;
  52. struct persistent_ram_ecc_info ecc_info;
  53. char *old_log;
  54. size_t old_log_size;
  55. };
  56. struct persistent_ram_zone *persistent_ram_new(phys_addr_t start, size_t size,
  57. u32 sig, struct persistent_ram_ecc_info *ecc_info,
  58. unsigned int memtype, u32 flags);
  59. void persistent_ram_free(struct persistent_ram_zone *prz);
  60. void persistent_ram_zap(struct persistent_ram_zone *prz);
  61. int persistent_ram_write(struct persistent_ram_zone *prz, const void *s,
  62. unsigned int count);
  63. int persistent_ram_write_user(struct persistent_ram_zone *prz,
  64. const void __user *s, 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. phys_addr_t mem_address;
  79. unsigned int mem_type;
  80. unsigned long record_size;
  81. unsigned long console_size;
  82. unsigned long ftrace_size;
  83. unsigned long pmsg_size;
  84. int dump_oops;
  85. struct persistent_ram_ecc_info ecc_info;
  86. };
  87. #endif