linux/drivers/acpi/apei/apei-internal.h
<<
>>
Prefs
   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
  13struct apei_exec_context;
  14
  15typedef 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
  20struct apei_exec_ins_type {
  21        u32 flags;
  22        apei_exec_ins_func_t run;
  23};
  24
  25struct 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
  38void 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
  44static inline void apei_exec_ctx_set_input(struct apei_exec_context *ctx,
  45                                           u64 input)
  46{
  47        ctx->value = input;
  48}
  49
  50static inline u64 apei_exec_ctx_get_output(struct apei_exec_context *ctx)
  51{
  52        return ctx->value;
  53}
  54
  55int __apei_exec_run(struct apei_exec_context *ctx, u8 action, bool optional);
  56
  57static 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 */
  63static 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
  73int apei_map_generic_address(struct acpi_generic_address *reg);
  74
  75static inline void apei_unmap_generic_address(struct acpi_generic_address *reg)
  76{
  77        acpi_os_unmap_generic_address(reg);
  78}
  79
  80int apei_read(u64 *val, struct acpi_generic_address *reg);
  81int apei_write(u64 val, struct acpi_generic_address *reg);
  82
  83int __apei_exec_read_register(struct acpi_whea_header *entry, u64 *val);
  84int __apei_exec_write_register(struct acpi_whea_header *entry, u64 val);
  85int apei_exec_read_register(struct apei_exec_context *ctx,
  86                            struct acpi_whea_header *entry);
  87int apei_exec_read_register_value(struct apei_exec_context *ctx,
  88                                  struct acpi_whea_header *entry);
  89int apei_exec_write_register(struct apei_exec_context *ctx,
  90                             struct acpi_whea_header *entry);
  91int apei_exec_write_register_value(struct apei_exec_context *ctx,
  92                                   struct acpi_whea_header *entry);
  93int apei_exec_noop(struct apei_exec_context *ctx,
  94                   struct acpi_whea_header *entry);
  95int apei_exec_pre_map_gars(struct apei_exec_context *ctx);
  96int apei_exec_post_unmap_gars(struct apei_exec_context *ctx);
  97
  98struct apei_resources {
  99        struct list_head iomem;
 100        struct list_head ioport;
 101};
 102
 103static inline void apei_resources_init(struct apei_resources *resources)
 104{
 105        INIT_LIST_HEAD(&resources->iomem);
 106        INIT_LIST_HEAD(&resources->ioport);
 107}
 108
 109void apei_resources_fini(struct apei_resources *resources);
 110int apei_resources_add(struct apei_resources *resources,
 111                       unsigned long start, unsigned long size,
 112                       bool iomem);
 113int apei_resources_sub(struct apei_resources *resources1,
 114                       struct apei_resources *resources2);
 115int apei_resources_request(struct apei_resources *resources,
 116                           const char *desc);
 117void apei_resources_release(struct apei_resources *resources);
 118int apei_exec_collect_resources(struct apei_exec_context *ctx,
 119                                struct apei_resources *resources);
 120
 121struct dentry;
 122struct dentry *apei_get_debugfs_dir(void);
 123
 124static 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
 133void cper_estatus_print(const char *pfx,
 134                        const struct acpi_hest_generic_status *estatus);
 135int cper_estatus_check_header(const struct acpi_hest_generic_status *estatus);
 136int cper_estatus_check(const struct acpi_hest_generic_status *estatus);
 137
 138int apei_osc_setup(void);
 139#endif
 140