blob: 393899192906db3e7222173e004a4c212e0db4d9 [file] [log] [blame]
James Morsead6eb312018-01-08 15:38:09 +00001// SPDX-License-Identifier: GPL-2.0
2// Copyright (C) 2017 Arm Ltd.
3#ifndef __LINUX_ARM_SDEI_H
4#define __LINUX_ARM_SDEI_H
5
6#include <uapi/linux/arm_sdei.h>
7
8enum sdei_conduit_types {
9 CONDUIT_INVALID = 0,
10 CONDUIT_SMC,
11 CONDUIT_HVC,
12};
13
James Morsef96935d2019-01-29 18:49:01 +000014#include <acpi/ghes.h>
James Morsead6eb312018-01-08 15:38:09 +000015#include <asm/sdei.h>
16
17/* Arch code should override this to set the entry point from firmware... */
18#ifndef sdei_arch_get_entry_point
19#define sdei_arch_get_entry_point(conduit) (0)
20#endif
21
22/*
23 * When an event occurs sdei_event_handler() will call a user-provided callback
24 * like this in NMI context on the CPU that received the event.
25 */
26typedef int (sdei_event_callback)(u32 event, struct pt_regs *regs, void *arg);
27
28/*
29 * Register your callback to claim an event. The event must be described
30 * by firmware.
31 */
32int sdei_event_register(u32 event_num, sdei_event_callback *cb, void *arg);
33
34/*
35 * Calls to sdei_event_unregister() may return EINPROGRESS. Keep calling
36 * it until it succeeds.
37 */
38int sdei_event_unregister(u32 event_num);
39
40int sdei_event_enable(u32 event_num);
41int sdei_event_disable(u32 event_num);
42
James Morsef96935d2019-01-29 18:49:01 +000043/* GHES register/unregister helpers */
44int sdei_register_ghes(struct ghes *ghes, sdei_event_callback *normal_cb,
45 sdei_event_callback *critical_cb);
46int sdei_unregister_ghes(struct ghes *ghes);
47
James Morsead6eb312018-01-08 15:38:09 +000048#ifdef CONFIG_ARM_SDE_INTERFACE
49/* For use by arch code when CPU hotplug notifiers are not appropriate. */
50int sdei_mask_local_cpu(void);
51int sdei_unmask_local_cpu(void);
52#else
53static inline int sdei_mask_local_cpu(void) { return 0; }
54static inline int sdei_unmask_local_cpu(void) { return 0; }
55#endif /* CONFIG_ARM_SDE_INTERFACE */
56
57
58/*
59 * This struct represents an event that has been registered. The driver
60 * maintains a list of all events, and which ones are registered. (Private
61 * events have one entry in the list, but are registered on each CPU).
62 * A pointer to this struct is passed to firmware, and back to the event
63 * handler. The event handler can then use this to invoke the registered
64 * callback, without having to walk the list.
65 *
66 * For CPU private events, this structure is per-cpu.
67 */
68struct sdei_registered_event {
69 /* For use by arch code: */
70 struct pt_regs interrupted_regs;
71
72 sdei_event_callback *callback;
73 void *callback_arg;
74 u32 event_num;
75 u8 priority;
76};
77
78/* The arch code entry point should then call this when an event arrives. */
79int notrace sdei_event_handler(struct pt_regs *regs,
80 struct sdei_registered_event *arg);
81
82/* arch code may use this to retrieve the extra registers. */
83int sdei_api_event_context(u32 query, u64 *result);
84
85#endif /* __LINUX_ARM_SDEI_H */