2 * apei-internal.h - ACPI Platform Error Interface internal
6 #ifndef APEI_INTERNAL_H
7 #define APEI_INTERNAL_H
9 #include <linux/cper.h>
10 #include <linux/acpi.h>
11 #include <linux/acpi_io.h>
13 struct apei_exec_context
;
15 typedef int (*apei_exec_ins_func_t
)(struct apei_exec_context
*ctx
,
16 struct acpi_whea_header
*entry
);
18 #define APEI_EXEC_INS_ACCESS_REGISTER 0x0001
20 struct apei_exec_ins_type
{
22 apei_exec_ins_func_t run
;
25 struct apei_exec_context
{
32 struct apei_exec_ins_type
*ins_table
;
34 struct acpi_whea_header
*action_table
;
38 void apei_exec_ctx_init(struct apei_exec_context
*ctx
,
39 struct apei_exec_ins_type
*ins_table
,
41 struct acpi_whea_header
*action_table
,
44 static inline void apei_exec_ctx_set_input(struct apei_exec_context
*ctx
,
50 static inline u64
apei_exec_ctx_get_output(struct apei_exec_context
*ctx
)
55 int __apei_exec_run(struct apei_exec_context
*ctx
, u8 action
, bool optional
);
57 static inline int apei_exec_run(struct apei_exec_context
*ctx
, u8 action
)
59 return __apei_exec_run(ctx
, action
, 0);
62 /* It is optional whether the firmware provides the action */
63 static inline int apei_exec_run_optional(struct apei_exec_context
*ctx
, u8 action
)
65 return __apei_exec_run(ctx
, action
, 1);
68 /* Common instruction implementation */
70 /* IP has been set in instruction function */
71 #define APEI_EXEC_SET_IP 1
73 int apei_map_generic_address(struct acpi_generic_address
*reg
);
75 static inline void apei_unmap_generic_address(struct acpi_generic_address
*reg
)
77 acpi_os_unmap_generic_address(reg
);
80 int apei_read(u64
*val
, struct acpi_generic_address
*reg
);
81 int apei_write(u64 val
, struct acpi_generic_address
*reg
);
83 int __apei_exec_read_register(struct acpi_whea_header
*entry
, u64
*val
);
84 int __apei_exec_write_register(struct acpi_whea_header
*entry
, u64 val
);
85 int apei_exec_read_register(struct apei_exec_context
*ctx
,
86 struct acpi_whea_header
*entry
);
87 int apei_exec_read_register_value(struct apei_exec_context
*ctx
,
88 struct acpi_whea_header
*entry
);
89 int apei_exec_write_register(struct apei_exec_context
*ctx
,
90 struct acpi_whea_header
*entry
);
91 int apei_exec_write_register_value(struct apei_exec_context
*ctx
,
92 struct acpi_whea_header
*entry
);
93 int apei_exec_noop(struct apei_exec_context
*ctx
,
94 struct acpi_whea_header
*entry
);
95 int apei_exec_pre_map_gars(struct apei_exec_context
*ctx
);
96 int apei_exec_post_unmap_gars(struct apei_exec_context
*ctx
);
98 struct apei_resources
{
99 struct list_head iomem
;
100 struct list_head ioport
;
103 static inline void apei_resources_init(struct apei_resources
*resources
)
105 INIT_LIST_HEAD(&resources
->iomem
);
106 INIT_LIST_HEAD(&resources
->ioport
);
109 void apei_resources_fini(struct apei_resources
*resources
);
110 int apei_resources_add(struct apei_resources
*resources
,
111 unsigned long start
, unsigned long size
,
113 int apei_resources_sub(struct apei_resources
*resources1
,
114 struct apei_resources
*resources2
);
115 int apei_resources_request(struct apei_resources
*resources
,
117 void apei_resources_release(struct apei_resources
*resources
);
118 int apei_exec_collect_resources(struct apei_exec_context
*ctx
,
119 struct apei_resources
*resources
);
122 struct dentry
*apei_get_debugfs_dir(void);
124 #define apei_estatus_for_each_section(estatus, section) \
125 for (section = (struct acpi_hest_generic_data *)(estatus + 1); \
126 (void *)section - (void *)estatus < estatus->data_length; \
127 section = (void *)(section+1) + section->error_data_length)
129 static inline u32
apei_estatus_len(struct acpi_hest_generic_status
*estatus
)
131 if (estatus
->raw_data_length
)
132 return estatus
->raw_data_offset
+ \
133 estatus
->raw_data_length
;
135 return sizeof(*estatus
) + estatus
->data_length
;
138 void apei_estatus_print(const char *pfx
,
139 const struct acpi_hest_generic_status
*estatus
);
140 int apei_estatus_check_header(const struct acpi_hest_generic_status
*estatus
);
141 int apei_estatus_check(const struct acpi_hest_generic_status
*estatus
);
143 int apei_osc_setup(void);