kobject: introduce kobj_completion
[linux/fpc-iii.git] / drivers / acpi / apei / apei-internal.h
blobf220d642136ed94a1844411ee532e777be6f847e
1 /*
2 * apei-internal.h - ACPI Platform Error Interface internal
3 * definations.
4 */
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 {
21 u32 flags;
22 apei_exec_ins_func_t run;
25 struct apei_exec_context {
26 u32 ip;
27 u64 value;
28 u64 var1;
29 u64 var2;
30 u64 src_base;
31 u64 dst_base;
32 struct apei_exec_ins_type *ins_table;
33 u32 instructions;
34 struct acpi_whea_header *action_table;
35 u32 entries;
38 void apei_exec_ctx_init(struct apei_exec_context *ctx,
39 struct apei_exec_ins_type *ins_table,
40 u32 instructions,
41 struct acpi_whea_header *action_table,
42 u32 entries);
44 static inline void apei_exec_ctx_set_input(struct apei_exec_context *ctx,
45 u64 input)
47 ctx->value = input;
50 static inline u64 apei_exec_ctx_get_output(struct apei_exec_context *ctx)
52 return ctx->value;
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,
112 bool iomem);
113 int apei_resources_sub(struct apei_resources *resources1,
114 struct apei_resources *resources2);
115 int apei_resources_request(struct apei_resources *resources,
116 const char *desc);
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);
121 struct dentry;
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;
134 else
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);
144 #endif