Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 /*
0003  * apei-internal.h - ACPI Platform Error Interface internal
0004  * definitions.
0005  */
0006 
0007 #ifndef APEI_INTERNAL_H
0008 #define APEI_INTERNAL_H
0009 
0010 #include <linux/cper.h>
0011 #include <linux/acpi.h>
0012 
0013 struct apei_exec_context;
0014 
0015 typedef int (*apei_exec_ins_func_t)(struct apei_exec_context *ctx,
0016                     struct acpi_whea_header *entry);
0017 
0018 #define APEI_EXEC_INS_ACCESS_REGISTER   0x0001
0019 
0020 struct apei_exec_ins_type {
0021     u32 flags;
0022     apei_exec_ins_func_t run;
0023 };
0024 
0025 struct apei_exec_context {
0026     u32 ip;
0027     u64 value;
0028     u64 var1;
0029     u64 var2;
0030     u64 src_base;
0031     u64 dst_base;
0032     struct apei_exec_ins_type *ins_table;
0033     u32 instructions;
0034     struct acpi_whea_header *action_table;
0035     u32 entries;
0036 };
0037 
0038 void apei_exec_ctx_init(struct apei_exec_context *ctx,
0039             struct apei_exec_ins_type *ins_table,
0040             u32 instructions,
0041             struct acpi_whea_header *action_table,
0042             u32 entries);
0043 
0044 static inline void apei_exec_ctx_set_input(struct apei_exec_context *ctx,
0045                        u64 input)
0046 {
0047     ctx->value = input;
0048 }
0049 
0050 static inline u64 apei_exec_ctx_get_output(struct apei_exec_context *ctx)
0051 {
0052     return ctx->value;
0053 }
0054 
0055 int __apei_exec_run(struct apei_exec_context *ctx, u8 action, bool optional);
0056 
0057 static inline int apei_exec_run(struct apei_exec_context *ctx, u8 action)
0058 {
0059     return __apei_exec_run(ctx, action, 0);
0060 }
0061 
0062 /* It is optional whether the firmware provides the action */
0063 static inline int apei_exec_run_optional(struct apei_exec_context *ctx, u8 action)
0064 {
0065     return __apei_exec_run(ctx, action, 1);
0066 }
0067 
0068 /* Common instruction implementation */
0069 
0070 /* IP has been set in instruction function */
0071 #define APEI_EXEC_SET_IP    1
0072 
0073 int apei_map_generic_address(struct acpi_generic_address *reg);
0074 
0075 static inline void apei_unmap_generic_address(struct acpi_generic_address *reg)
0076 {
0077     acpi_os_unmap_generic_address(reg);
0078 }
0079 
0080 int apei_read(u64 *val, struct acpi_generic_address *reg);
0081 int apei_write(u64 val, struct acpi_generic_address *reg);
0082 
0083 int __apei_exec_read_register(struct acpi_whea_header *entry, u64 *val);
0084 int __apei_exec_write_register(struct acpi_whea_header *entry, u64 val);
0085 int apei_exec_read_register(struct apei_exec_context *ctx,
0086                 struct acpi_whea_header *entry);
0087 int apei_exec_read_register_value(struct apei_exec_context *ctx,
0088                   struct acpi_whea_header *entry);
0089 int apei_exec_write_register(struct apei_exec_context *ctx,
0090                  struct acpi_whea_header *entry);
0091 int apei_exec_write_register_value(struct apei_exec_context *ctx,
0092                    struct acpi_whea_header *entry);
0093 int apei_exec_noop(struct apei_exec_context *ctx,
0094            struct acpi_whea_header *entry);
0095 int apei_exec_pre_map_gars(struct apei_exec_context *ctx);
0096 int apei_exec_post_unmap_gars(struct apei_exec_context *ctx);
0097 
0098 struct apei_resources {
0099     struct list_head iomem;
0100     struct list_head ioport;
0101 };
0102 
0103 static inline void apei_resources_init(struct apei_resources *resources)
0104 {
0105     INIT_LIST_HEAD(&resources->iomem);
0106     INIT_LIST_HEAD(&resources->ioport);
0107 }
0108 
0109 void apei_resources_fini(struct apei_resources *resources);
0110 int apei_resources_add(struct apei_resources *resources,
0111                unsigned long start, unsigned long size,
0112                bool iomem);
0113 int apei_resources_sub(struct apei_resources *resources1,
0114                struct apei_resources *resources2);
0115 int apei_resources_request(struct apei_resources *resources,
0116                const char *desc);
0117 void apei_resources_release(struct apei_resources *resources);
0118 int apei_exec_collect_resources(struct apei_exec_context *ctx,
0119                 struct apei_resources *resources);
0120 
0121 struct dentry;
0122 struct dentry *apei_get_debugfs_dir(void);
0123 
0124 static inline u32 cper_estatus_len(struct acpi_hest_generic_status *estatus)
0125 {
0126     if (estatus->raw_data_length)
0127         return estatus->raw_data_offset + \
0128             estatus->raw_data_length;
0129     else
0130         return sizeof(*estatus) + estatus->data_length;
0131 }
0132 
0133 void cper_estatus_print(const char *pfx,
0134             const struct acpi_hest_generic_status *estatus);
0135 int cper_estatus_check_header(const struct acpi_hest_generic_status *estatus);
0136 int cper_estatus_check(const struct acpi_hest_generic_status *estatus);
0137 
0138 int apei_osc_setup(void);
0139 #endif