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