root/drivers/acpi/apei/apei-internal.h

/* [<][>][^][v][top][bottom][index][help] */

INCLUDED FROM


DEFINITIONS

This source file includes following definitions.
  1. apei_exec_ctx_set_input
  2. apei_exec_ctx_get_output
  3. apei_exec_run
  4. apei_exec_run_optional
  5. apei_unmap_generic_address
  6. apei_resources_init
  7. cper_estatus_len

   1 /* SPDX-License-Identifier: GPL-2.0 */
   2 /*
   3  * apei-internal.h - ACPI Platform Error Interface internal
   4  * definitions.
   5  */
   6 
   7 #ifndef APEI_INTERNAL_H
   8 #define APEI_INTERNAL_H
   9 
  10 #include <linux/cper.h>
  11 #include <linux/acpi.h>
  12 
  13 struct apei_exec_context;
  14 
  15 typedef int (*apei_exec_ins_func_t)(struct apei_exec_context *ctx,
  16                                     struct acpi_whea_header *entry);
  17 
  18 #define APEI_EXEC_INS_ACCESS_REGISTER   0x0001
  19 
  20 struct apei_exec_ins_type {
  21         u32 flags;
  22         apei_exec_ins_func_t run;
  23 };
  24 
  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;
  36 };
  37 
  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);
  43 
  44 static inline void apei_exec_ctx_set_input(struct apei_exec_context *ctx,
  45                                            u64 input)
  46 {
  47         ctx->value = input;
  48 }
  49 
  50 static inline u64 apei_exec_ctx_get_output(struct apei_exec_context *ctx)
  51 {
  52         return ctx->value;
  53 }
  54 
  55 int __apei_exec_run(struct apei_exec_context *ctx, u8 action, bool optional);
  56 
  57 static inline int apei_exec_run(struct apei_exec_context *ctx, u8 action)
  58 {
  59         return __apei_exec_run(ctx, action, 0);
  60 }
  61 
  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)
  64 {
  65         return __apei_exec_run(ctx, action, 1);
  66 }
  67 
  68 /* Common instruction implementation */
  69 
  70 /* IP has been set in instruction function */
  71 #define APEI_EXEC_SET_IP        1
  72 
  73 int apei_map_generic_address(struct acpi_generic_address *reg);
  74 
  75 static inline void apei_unmap_generic_address(struct acpi_generic_address *reg)
  76 {
  77         acpi_os_unmap_generic_address(reg);
  78 }
  79 
  80 int apei_read(u64 *val, struct acpi_generic_address *reg);
  81 int apei_write(u64 val, struct acpi_generic_address *reg);
  82 
  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);
  97 
  98 struct apei_resources {
  99         struct list_head iomem;
 100         struct list_head ioport;
 101 };
 102 
 103 static inline void apei_resources_init(struct apei_resources *resources)
 104 {
 105         INIT_LIST_HEAD(&resources->iomem);
 106         INIT_LIST_HEAD(&resources->ioport);
 107 }
 108 
 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);
 120 
 121 struct dentry;
 122 struct dentry *apei_get_debugfs_dir(void);
 123 
 124 static inline u32 cper_estatus_len(struct acpi_hest_generic_status *estatus)
 125 {
 126         if (estatus->raw_data_length)
 127                 return estatus->raw_data_offset + \
 128                         estatus->raw_data_length;
 129         else
 130                 return sizeof(*estatus) + estatus->data_length;
 131 }
 132 
 133 void cper_estatus_print(const char *pfx,
 134                         const struct acpi_hest_generic_status *estatus);
 135 int cper_estatus_check_header(const struct acpi_hest_generic_status *estatus);
 136 int cper_estatus_check(const struct acpi_hest_generic_status *estatus);
 137 
 138 int apei_osc_setup(void);
 139 #endif

/* [<][>][^][v][top][bottom][index][help] */