apei-internal.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. /*
  2. * apei-internal.h - ACPI Platform Error Interface internal
  3. * definations.
  4. */
  5. #ifndef APEI_INTERNAL_H
  6. #define APEI_INTERNAL_H
  7. #include <linux/cper.h>
  8. struct apei_exec_context;
  9. typedef int (*apei_exec_ins_func_t)(struct apei_exec_context *ctx,
  10. struct acpi_whea_header *entry);
  11. #define APEI_EXEC_INS_ACCESS_REGISTER 0x0001
  12. struct apei_exec_ins_type {
  13. u32 flags;
  14. apei_exec_ins_func_t run;
  15. };
  16. struct apei_exec_context {
  17. u32 ip;
  18. u64 value;
  19. u64 var1;
  20. u64 var2;
  21. u64 src_base;
  22. u64 dst_base;
  23. struct apei_exec_ins_type *ins_table;
  24. u32 instructions;
  25. struct acpi_whea_header *action_table;
  26. u32 entries;
  27. };
  28. void apei_exec_ctx_init(struct apei_exec_context *ctx,
  29. struct apei_exec_ins_type *ins_table,
  30. u32 instructions,
  31. struct acpi_whea_header *action_table,
  32. u32 entries);
  33. static inline void apei_exec_ctx_set_input(struct apei_exec_context *ctx,
  34. u64 input)
  35. {
  36. ctx->value = input;
  37. }
  38. static inline u64 apei_exec_ctx_get_output(struct apei_exec_context *ctx)
  39. {
  40. return ctx->value;
  41. }
  42. int apei_exec_run(struct apei_exec_context *ctx, u8 action);
  43. /* Common instruction implementation */
  44. /* IP has been set in instruction function */
  45. #define APEI_EXEC_SET_IP 1
  46. int __apei_exec_read_register(struct acpi_whea_header *entry, u64 *val);
  47. int __apei_exec_write_register(struct acpi_whea_header *entry, u64 val);
  48. int apei_exec_read_register(struct apei_exec_context *ctx,
  49. struct acpi_whea_header *entry);
  50. int apei_exec_read_register_value(struct apei_exec_context *ctx,
  51. struct acpi_whea_header *entry);
  52. int apei_exec_write_register(struct apei_exec_context *ctx,
  53. struct acpi_whea_header *entry);
  54. int apei_exec_write_register_value(struct apei_exec_context *ctx,
  55. struct acpi_whea_header *entry);
  56. int apei_exec_noop(struct apei_exec_context *ctx,
  57. struct acpi_whea_header *entry);
  58. int apei_exec_pre_map_gars(struct apei_exec_context *ctx);
  59. int apei_exec_post_unmap_gars(struct apei_exec_context *ctx);
  60. struct apei_resources {
  61. struct list_head iomem;
  62. struct list_head ioport;
  63. };
  64. static inline void apei_resources_init(struct apei_resources *resources)
  65. {
  66. INIT_LIST_HEAD(&resources->iomem);
  67. INIT_LIST_HEAD(&resources->ioport);
  68. }
  69. void apei_resources_fini(struct apei_resources *resources);
  70. int apei_resources_sub(struct apei_resources *resources1,
  71. struct apei_resources *resources2);
  72. int apei_resources_request(struct apei_resources *resources,
  73. const char *desc);
  74. void apei_resources_release(struct apei_resources *resources);
  75. int apei_exec_collect_resources(struct apei_exec_context *ctx,
  76. struct apei_resources *resources);
  77. struct dentry;
  78. struct dentry *apei_get_debugfs_dir(void);
  79. #define apei_estatus_for_each_section(estatus, section) \
  80. for (section = (struct acpi_hest_generic_data *)(estatus + 1); \
  81. (void *)section - (void *)estatus < estatus->data_length; \
  82. section = (void *)(section+1) + section->error_data_length)
  83. static inline u32 apei_estatus_len(struct acpi_hest_generic_status *estatus)
  84. {
  85. if (estatus->raw_data_length)
  86. return estatus->raw_data_offset + \
  87. estatus->raw_data_length;
  88. else
  89. return sizeof(*estatus) + estatus->data_length;
  90. }
  91. int apei_estatus_check_header(const struct acpi_hest_generic_status *estatus);
  92. int apei_estatus_check(const struct acpi_hest_generic_status *estatus);
  93. #endif