pstore_ram.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  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. uint16_t *par;
  38. };
  39. struct persistent_ram_zone {
  40. phys_addr_t paddr;
  41. size_t size;
  42. void *vaddr;
  43. struct persistent_ram_buffer *buffer;
  44. size_t buffer_size;
  45. u32 flags;
  46. raw_spinlock_t buffer_lock;
  47. /* ECC correction */
  48. char *par_buffer;
  49. char *par_header;
  50. struct rs_control *rs_decoder;
  51. int corrected_bytes;
  52. int bad_blocks;
  53. struct persistent_ram_ecc_info ecc_info;
  54. char *old_log;
  55. size_t old_log_size;
  56. };
  57. struct persistent_ram_zone *persistent_ram_new(phys_addr_t start, size_t size,
  58. u32 sig, struct persistent_ram_ecc_info *ecc_info,
  59. unsigned int memtype, u32 flags);
  60. void persistent_ram_free(struct persistent_ram_zone *prz);
  61. void persistent_ram_zap(struct persistent_ram_zone *prz);
  62. int persistent_ram_write(struct persistent_ram_zone *prz, const void *s,
  63. unsigned int count);
  64. int persistent_ram_write_user(struct persistent_ram_zone *prz,
  65. const void __user *s, unsigned int count);
  66. void persistent_ram_save_old(struct persistent_ram_zone *prz);
  67. size_t persistent_ram_old_size(struct persistent_ram_zone *prz);
  68. void *persistent_ram_old(struct persistent_ram_zone *prz);
  69. void persistent_ram_free_old(struct persistent_ram_zone *prz);
  70. ssize_t persistent_ram_ecc_string(struct persistent_ram_zone *prz,
  71. char *str, size_t len);
  72. /*
  73. * Ramoops platform data
  74. * @mem_size memory size for ramoops
  75. * @mem_address physical memory address to contain ramoops
  76. */
  77. #define RAMOOPS_FLAG_FTRACE_PER_CPU BIT(0)
  78. struct ramoops_platform_data {
  79. unsigned long mem_size;
  80. phys_addr_t mem_address;
  81. unsigned int mem_type;
  82. unsigned long record_size;
  83. unsigned long console_size;
  84. unsigned long ftrace_size;
  85. unsigned long pmsg_size;
  86. int dump_oops;
  87. u32 flags;
  88. struct persistent_ram_ecc_info ecc_info;
  89. };
  90. #endif