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