1 /* SPDX-License-Identifier: GPL-2.0 */
3 * apei-internal.h - ACPI Platform Error Interface internal
7 #ifndef APEI_INTERNAL_H
8 #define APEI_INTERNAL_H
10 #include <linux/acpi.h>
12 struct apei_exec_context
;
14 typedef int (*apei_exec_ins_func_t
)(struct apei_exec_context
*ctx
,
15 struct acpi_whea_header
*entry
);
17 #define APEI_EXEC_INS_ACCESS_REGISTER 0x0001
19 struct apei_exec_ins_type
{
21 apei_exec_ins_func_t run
;
24 struct apei_exec_context
{
31 struct apei_exec_ins_type
*ins_table
;
33 struct acpi_whea_header
*action_table
;
37 void apei_exec_ctx_init(struct apei_exec_context
*ctx
,
38 struct apei_exec_ins_type
*ins_table
,
40 struct acpi_whea_header
*action_table
,
43 static inline void apei_exec_ctx_set_input(struct apei_exec_context
*ctx
,
49 static inline u64
apei_exec_ctx_get_output(struct apei_exec_context
*ctx
)
54 int __apei_exec_run(struct apei_exec_context
*ctx
, u8 action
, bool optional
);
56 static inline int apei_exec_run(struct apei_exec_context
*ctx
, u8 action
)
58 return __apei_exec_run(ctx
, action
, 0);
61 /* It is optional whether the firmware provides the action */
62 static inline int apei_exec_run_optional(struct apei_exec_context
*ctx
, u8 action
)
64 return __apei_exec_run(ctx
, action
, 1);
67 /* Common instruction implementation */
69 /* IP has been set in instruction function */
70 #define APEI_EXEC_SET_IP 1
72 int apei_map_generic_address(struct acpi_generic_address
*reg
);
74 static inline void apei_unmap_generic_address(struct acpi_generic_address
*reg
)
76 acpi_os_unmap_generic_address(reg
);
79 int apei_read(u64
*val
, struct acpi_generic_address
*reg
);
80 int apei_write(u64 val
, struct acpi_generic_address
*reg
);
82 int __apei_exec_read_register(struct acpi_whea_header
*entry
, u64
*val
);
83 int __apei_exec_write_register(struct acpi_whea_header
*entry
, u64 val
);
84 int apei_exec_read_register(struct apei_exec_context
*ctx
,
85 struct acpi_whea_header
*entry
);
86 int apei_exec_read_register_value(struct apei_exec_context
*ctx
,
87 struct acpi_whea_header
*entry
);
88 int apei_exec_write_register(struct apei_exec_context
*ctx
,
89 struct acpi_whea_header
*entry
);
90 int apei_exec_write_register_value(struct apei_exec_context
*ctx
,
91 struct acpi_whea_header
*entry
);
92 int apei_exec_noop(struct apei_exec_context
*ctx
,
93 struct acpi_whea_header
*entry
);
94 int apei_exec_pre_map_gars(struct apei_exec_context
*ctx
);
95 int apei_exec_post_unmap_gars(struct apei_exec_context
*ctx
);
97 struct apei_resources
{
98 struct list_head iomem
;
99 struct list_head ioport
;
102 static inline void apei_resources_init(struct apei_resources
*resources
)
104 INIT_LIST_HEAD(&resources
->iomem
);
105 INIT_LIST_HEAD(&resources
->ioport
);
108 void apei_resources_fini(struct apei_resources
*resources
);
109 int apei_resources_add(struct apei_resources
*resources
,
110 unsigned long start
, unsigned long size
,
112 int apei_resources_sub(struct apei_resources
*resources1
,
113 struct apei_resources
*resources2
);
114 int apei_resources_request(struct apei_resources
*resources
,
116 void apei_resources_release(struct apei_resources
*resources
);
117 int apei_exec_collect_resources(struct apei_exec_context
*ctx
,
118 struct apei_resources
*resources
);
121 struct dentry
*apei_get_debugfs_dir(void);
123 static inline u32
cper_estatus_len(struct acpi_hest_generic_status
*estatus
)
125 if (estatus
->raw_data_length
)
126 return estatus
->raw_data_offset
+ \
127 estatus
->raw_data_length
;
129 return sizeof(*estatus
) + estatus
->data_length
;
132 int apei_osc_setup(void);
134 int einj_get_available_error_type(u32
*type
);
135 int einj_error_inject(u32 type
, u32 flags
, u64 param1
, u64 param2
, u64 param3
,
137 int einj_cxl_rch_error_inject(u32 type
, u32 flags
, u64 param1
, u64 param2
,
138 u64 param3
, u64 param4
);
139 bool einj_is_cxl_error_type(u64 type
);
140 int einj_validate_error_type(u64 type
);
142 #ifndef ACPI_EINJ_CXL_CACHE_CORRECTABLE
143 #define ACPI_EINJ_CXL_CACHE_CORRECTABLE BIT(12)
144 #define ACPI_EINJ_CXL_CACHE_UNCORRECTABLE BIT(13)
145 #define ACPI_EINJ_CXL_CACHE_FATAL BIT(14)
146 #define ACPI_EINJ_CXL_MEM_CORRECTABLE BIT(15)
147 #define ACPI_EINJ_CXL_MEM_UNCORRECTABLE BIT(16)
148 #define ACPI_EINJ_CXL_MEM_FATAL BIT(17)