18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci * apei.h - ACPI Platform Error Interface
48c2ecf20Sopenharmony_ci */
58c2ecf20Sopenharmony_ci
68c2ecf20Sopenharmony_ci#ifndef ACPI_APEI_H
78c2ecf20Sopenharmony_ci#define ACPI_APEI_H
88c2ecf20Sopenharmony_ci
98c2ecf20Sopenharmony_ci#include <linux/acpi.h>
108c2ecf20Sopenharmony_ci#include <linux/cper.h>
118c2ecf20Sopenharmony_ci#include <asm/ioctls.h>
128c2ecf20Sopenharmony_ci
138c2ecf20Sopenharmony_ci#define APEI_ERST_INVALID_RECORD_ID	0xffffffffffffffffULL
148c2ecf20Sopenharmony_ci
158c2ecf20Sopenharmony_ci#define APEI_ERST_CLEAR_RECORD		_IOW('E', 1, u64)
168c2ecf20Sopenharmony_ci#define APEI_ERST_GET_RECORD_COUNT	_IOR('E', 2, u32)
178c2ecf20Sopenharmony_ci
188c2ecf20Sopenharmony_ci#ifdef __KERNEL__
198c2ecf20Sopenharmony_ci
208c2ecf20Sopenharmony_cienum hest_status {
218c2ecf20Sopenharmony_ci	HEST_ENABLED,
228c2ecf20Sopenharmony_ci	HEST_DISABLED,
238c2ecf20Sopenharmony_ci	HEST_NOT_FOUND,
248c2ecf20Sopenharmony_ci};
258c2ecf20Sopenharmony_ci
268c2ecf20Sopenharmony_ciextern int hest_disable;
278c2ecf20Sopenharmony_ciextern int erst_disable;
288c2ecf20Sopenharmony_ci#ifdef CONFIG_ACPI_APEI_GHES
298c2ecf20Sopenharmony_ciextern bool ghes_disable;
308c2ecf20Sopenharmony_civoid __init ghes_init(void);
318c2ecf20Sopenharmony_ci#else
328c2ecf20Sopenharmony_ci#define ghes_disable 1
338c2ecf20Sopenharmony_cistatic inline void ghes_init(void) { }
348c2ecf20Sopenharmony_ci#endif
358c2ecf20Sopenharmony_ci
368c2ecf20Sopenharmony_ci#ifdef CONFIG_ACPI_APEI
378c2ecf20Sopenharmony_civoid __init acpi_hest_init(void);
388c2ecf20Sopenharmony_ci#else
398c2ecf20Sopenharmony_cistatic inline void acpi_hest_init(void) { }
408c2ecf20Sopenharmony_ci#endif
418c2ecf20Sopenharmony_ci
428c2ecf20Sopenharmony_citypedef int (*apei_hest_func_t)(struct acpi_hest_header *hest_hdr, void *data);
438c2ecf20Sopenharmony_ciint apei_hest_parse(apei_hest_func_t func, void *data);
448c2ecf20Sopenharmony_ci
458c2ecf20Sopenharmony_ciint erst_write(const struct cper_record_header *record);
468c2ecf20Sopenharmony_cissize_t erst_get_record_count(void);
478c2ecf20Sopenharmony_ciint erst_get_record_id_begin(int *pos);
488c2ecf20Sopenharmony_ciint erst_get_record_id_next(int *pos, u64 *record_id);
498c2ecf20Sopenharmony_civoid erst_get_record_id_end(void);
508c2ecf20Sopenharmony_cissize_t erst_read(u64 record_id, struct cper_record_header *record,
518c2ecf20Sopenharmony_ci		  size_t buflen);
528c2ecf20Sopenharmony_ciint erst_clear(u64 record_id);
538c2ecf20Sopenharmony_ci
548c2ecf20Sopenharmony_ciint arch_apei_enable_cmcff(struct acpi_hest_header *hest_hdr, void *data);
558c2ecf20Sopenharmony_civoid arch_apei_report_mem_error(int sev, struct cper_sec_mem_err *mem_err);
568c2ecf20Sopenharmony_ci
578c2ecf20Sopenharmony_ci#endif
588c2ecf20Sopenharmony_ci#endif
59