pstore_zone.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef __PSTORE_ZONE_H_
  3. #define __PSTORE_ZONE_H_
  4. #include <linux/types.h>
  5. typedef ssize_t (*pstore_zone_read_op)(char *, size_t, loff_t);
  6. typedef ssize_t (*pstore_zone_write_op)(const char *, size_t, loff_t);
  7. typedef ssize_t (*pstore_zone_erase_op)(size_t, loff_t);
  8. /**
  9. * struct pstore_zone_info - pstore/zone back-end driver structure
  10. *
  11. * @owner: Module which is responsible for this back-end driver.
  12. * @name: Name of the back-end driver.
  13. * @total_size: The total size in bytes pstore/zone can use. It must be greater
  14. * than 4096 and be multiple of 4096.
  15. * @kmsg_size: The size of oops/panic zone. Zero means disabled, otherwise,
  16. * it must be multiple of SECTOR_SIZE(512 Bytes).
  17. * @max_reason: Maximum kmsg dump reason to store.
  18. * @pmsg_size: The size of pmsg zone which is the same as @kmsg_size.
  19. * @console_size:The size of console zone which is the same as @kmsg_size.
  20. * @ftrace_size:The size of ftrace zone which is the same as @kmsg_size.
  21. * @read: The general read operation. Both of the function parameters
  22. * @size and @offset are relative value to storage.
  23. * On success, the number of bytes should be returned, others
  24. * mean error.
  25. * @write: The same as @read, but the following error number:
  26. * -EBUSY means try to write again later.
  27. * -ENOMSG means to try next zone.
  28. * @erase: The general erase operation for device with special removing
  29. * job. Both of the function parameters @size and @offset are
  30. * relative value to storage.
  31. * Return 0 on success and others on failure.
  32. * @panic_write:The write operation only used for panic case. It's optional
  33. * if you do not care panic log. The parameters are relative
  34. * value to storage.
  35. * On success, the number of bytes should be returned, others
  36. * excluding -ENOMSG mean error. -ENOMSG means to try next zone.
  37. */
  38. struct pstore_zone_info {
  39. struct module *owner;
  40. const char *name;
  41. unsigned long total_size;
  42. unsigned long kmsg_size;
  43. int max_reason;
  44. unsigned long pmsg_size;
  45. unsigned long console_size;
  46. unsigned long ftrace_size;
  47. pstore_zone_read_op read;
  48. pstore_zone_write_op write;
  49. pstore_zone_erase_op erase;
  50. pstore_zone_write_op panic_write;
  51. };
  52. extern int register_pstore_zone(struct pstore_zone_info *info);
  53. extern void unregister_pstore_zone(struct pstore_zone_info *info);
  54. #endif