apei-internal.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  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, bool optional);
  43. static inline int apei_exec_run(struct apei_exec_context *ctx, u8 action)
  44. {
  45. return __apei_exec_run(ctx, action, 0);
  46. }
  47. /* It is optional whether the firmware provides the action */
  48. static inline int apei_exec_run_optional(struct apei_exec_context *ctx, u8 action)
  49. {
  50. return __apei_exec_run(ctx, action, 1);
  51. }
  52. /* Common instruction implementation */
  53. /* IP has been set in instruction function */
  54. #define APEI_EXEC_SET_IP 1
  55. int __apei_exec_read_register(struct acpi_whea_header *entry, u64 *val);
  56. int __apei_exec_write_register(struct acpi_whea_header *entry, u64 val);
  57. int apei_exec_read_register(struct apei_exec_context *ctx,
  58. struct acpi_whea_header *entry);
  59. int apei_exec_read_register_value(struct apei_exec_context *ctx,
  60. struct acpi_whea_header *entry);
  61. int apei_exec_write_register(struct apei_exec_context *ctx,
  62. struct acpi_whea_header *entry);
  63. int apei_exec_write_register_value(struct apei_exec_context *ctx,
  64. struct acpi_whea_header *entry);
  65. int apei_exec_noop(struct apei_exec_context *ctx,
  66. struct acpi_whea_header *entry);
  67. int apei_exec_pre_map_gars(struct apei_exec_context *ctx);
  68. int apei_exec_post_unmap_gars(struct apei_exec_context *ctx);
  69. struct apei_resources {
  70. struct list_head iomem;
  71. struct list_head ioport;
  72. };
  73. static inline void apei_resources_init(struct apei_resources *resources)
  74. {
  75. INIT_LIST_HEAD(&resources->iomem);
  76. INIT_LIST_HEAD(&resources->ioport);
  77. }
  78. void apei_resources_fini(struct apei_resources *resources);
  79. int apei_resources_sub(struct apei_resources *resources1,
  80. struct apei_resources *resources2);
  81. int apei_resources_request(struct apei_resources *resources,
  82. const char *desc);
  83. void apei_resources_release(struct apei_resources *resources);
  84. int apei_exec_collect_resources(struct apei_exec_context *ctx,
  85. struct apei_resources *resources);
  86. struct dentry;
  87. struct dentry *apei_get_debugfs_dir(void);
  88. #define apei_estatus_for_each_section(estatus, section) \
  89. for (section = (struct acpi_hest_generic_data *)(estatus + 1); \
  90. (void *)section - (void *)estatus < estatus->data_length; \
  91. section = (void *)(section+1) + section->error_data_length)
  92. static inline u32 apei_estatus_len(struct acpi_hest_generic_status *estatus)
  93. {
  94. if (estatus->raw_data_length)
  95. return estatus->raw_data_offset + \
  96. estatus->raw_data_length;
  97. else
  98. return sizeof(*estatus) + estatus->data_length;
  99. }
  100. void apei_estatus_print(const char *pfx,
  101. const struct acpi_hest_generic_status *estatus);
  102. int apei_estatus_check_header(const struct acpi_hest_generic_status *estatus);
  103. int apei_estatus_check(const struct acpi_hest_generic_status *estatus);
  104. int apei_osc_setup(void);
  105. #endif