162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
262306a36Sopenharmony_ci// Copyright (C) 2017 Arm Ltd.
362306a36Sopenharmony_ci#ifndef __ASM_SDEI_H
462306a36Sopenharmony_ci#define __ASM_SDEI_H
562306a36Sopenharmony_ci
662306a36Sopenharmony_ci/* Values for sdei_exit_mode */
762306a36Sopenharmony_ci#define SDEI_EXIT_HVC  0
862306a36Sopenharmony_ci#define SDEI_EXIT_SMC  1
962306a36Sopenharmony_ci
1062306a36Sopenharmony_ci#define SDEI_STACK_SIZE		IRQ_STACK_SIZE
1162306a36Sopenharmony_ci
1262306a36Sopenharmony_ci#ifndef __ASSEMBLY__
1362306a36Sopenharmony_ci
1462306a36Sopenharmony_ci#include <linux/linkage.h>
1562306a36Sopenharmony_ci#include <linux/preempt.h>
1662306a36Sopenharmony_ci#include <linux/types.h>
1762306a36Sopenharmony_ci
1862306a36Sopenharmony_ci#include <asm/virt.h>
1962306a36Sopenharmony_ci
2062306a36Sopenharmony_ciDECLARE_PER_CPU(struct sdei_registered_event *, sdei_active_normal_event);
2162306a36Sopenharmony_ciDECLARE_PER_CPU(struct sdei_registered_event *, sdei_active_critical_event);
2262306a36Sopenharmony_ci
2362306a36Sopenharmony_ciextern unsigned long sdei_exit_mode;
2462306a36Sopenharmony_ci
2562306a36Sopenharmony_ci/* Software Delegated Exception entry point from firmware*/
2662306a36Sopenharmony_ciasmlinkage void __sdei_asm_handler(unsigned long event_num, unsigned long arg,
2762306a36Sopenharmony_ci				   unsigned long pc, unsigned long pstate);
2862306a36Sopenharmony_ci
2962306a36Sopenharmony_ci/* and its CONFIG_UNMAP_KERNEL_AT_EL0 trampoline */
3062306a36Sopenharmony_ciasmlinkage void __sdei_asm_entry_trampoline(unsigned long event_num,
3162306a36Sopenharmony_ci						   unsigned long arg,
3262306a36Sopenharmony_ci						   unsigned long pc,
3362306a36Sopenharmony_ci						   unsigned long pstate);
3462306a36Sopenharmony_ci
3562306a36Sopenharmony_ci/* Abort a running handler. Context is discarded. */
3662306a36Sopenharmony_civoid __sdei_handler_abort(void);
3762306a36Sopenharmony_ci
3862306a36Sopenharmony_ci/*
3962306a36Sopenharmony_ci * The above entry point does the minimum to call C code. This function does
4062306a36Sopenharmony_ci * anything else, before calling the driver.
4162306a36Sopenharmony_ci */
4262306a36Sopenharmony_cistruct sdei_registered_event;
4362306a36Sopenharmony_ciasmlinkage unsigned long __sdei_handler(struct pt_regs *regs,
4462306a36Sopenharmony_ci					struct sdei_registered_event *arg);
4562306a36Sopenharmony_ci
4662306a36Sopenharmony_ciunsigned long do_sdei_event(struct pt_regs *regs,
4762306a36Sopenharmony_ci			    struct sdei_registered_event *arg);
4862306a36Sopenharmony_ci
4962306a36Sopenharmony_ciunsigned long sdei_arch_get_entry_point(int conduit);
5062306a36Sopenharmony_ci#define sdei_arch_get_entry_point(x)	sdei_arch_get_entry_point(x)
5162306a36Sopenharmony_ci
5262306a36Sopenharmony_ci#endif /* __ASSEMBLY__ */
5362306a36Sopenharmony_ci#endif	/* __ASM_SDEI_H */
54