| 1 | |
| 2 | |
| 3 | #ifndef __LINUX_ARM_SDEI_H
|
| 4 | #define __LINUX_ARM_SDEI_H
|
| 5 |
|
| 6 | #include <uapi/linux/arm_sdei.h>
|
| 7 |
|
| 8 | #include <acpi/ghes.h>
|
| 9 |
|
| 10 | #ifdef CONFIG_ARM_SDE_INTERFACE
|
| 11 | #include <asm/sdei.h>
|
| 12 | #endif
|
| 13 |
|
| 14 |
|
| 15 | #ifndef sdei_arch_get_entry_point
|
| 16 | #define sdei_arch_get_entry_point(conduit) (0)
|
| 17 | #endif
|
| 18 |
|
| 19 | |
| 20 | * When an event occurs sdei_event_handler() will call a user-provided callback
|
| 21 | * like this in NMI context on the CPU that received the event.
|
| 22 |
|
| 23 | typedef int (sdei_event_callback)(u32 event, struct pt_regs *regs, void *arg);
|
| 24 |
|
| 25 | |
| 26 | * Register your callback to claim an event. The event must be described
|
| 27 | * by firmware.
|
| 28 |
|
| 29 | int sdei_event_register(u32 event_num, sdei_event_callback *cb, void *arg);
|
| 30 |
|
| 31 | |
| 32 | * Calls to sdei_event_unregister() may return EINPROGRESS. Keep calling
|
| 33 | * it until it succeeds.
|
| 34 |
|
| 35 | int sdei_event_unregister(u32 event_num);
|
| 36 |
|
| 37 | int sdei_event_enable(u32 event_num);
|
| 38 | int sdei_event_disable(u32 event_num);
|
| 39 |
|
| 40 | |
| 41 | * Signal the software-signalled event (event 0) to another PE, NMI-like.
|
| 42 | * @mpidr is the target's MPIDR affinity.
|
| 43 |
|
| 44 | int sdei_event_signal(u32 event_num, u64 mpidr);
|
| 45 |
|
| 46 |
|
| 47 | bool sdei_is_present(void);
|
| 48 |
|
| 49 |
|
| 50 | int sdei_register_ghes(struct ghes *ghes, sdei_event_callback *normal_cb,
|
| 51 | sdei_event_callback *critical_cb);
|
| 52 | int sdei_unregister_ghes(struct ghes *ghes);
|
| 53 |
|
| 54 | #ifdef CONFIG_ARM_SDE_INTERFACE
|
| 55 |
|
| 56 | int sdei_mask_local_cpu(void);
|
| 57 | int sdei_unmask_local_cpu(void);
|
| 58 | void __init acpi_sdei_init(void);
|
| 59 | void sdei_handler_abort(void);
|
| 60 | #else
|
| 61 | static inline int sdei_mask_local_cpu(void) { return 0; }
|
| 62 | static inline int sdei_unmask_local_cpu(void) { return 0; }
|
| 63 | static inline void acpi_sdei_init(void) { }
|
| 64 | static inline void sdei_handler_abort(void) { }
|
| 65 | #endif
|
| 66 |
|
| 67 |
|
| 68 | |
| 69 | * This struct represents an event that has been registered. The driver
|
| 70 | * maintains a list of all events, and which ones are registered. (Private
|
| 71 | * events have one entry in the list, but are registered on each CPU).
|
| 72 | * A pointer to this struct is passed to firmware, and back to the event
|
| 73 | * handler. The event handler can then use this to invoke the registered
|
| 74 | * callback, without having to walk the list.
|
| 75 | *
|
| 76 | * For CPU private events, this structure is per-cpu.
|
| 77 |
|
| 78 | struct sdei_registered_event {
|
| 79 |
|
| 80 | struct pt_regs interrupted_regs;
|
| 81 |
|
| 82 | sdei_event_callback *callback;
|
| 83 | void *callback_arg;
|
| 84 | u32 event_num;
|
| 85 | u8 priority;
|
| 86 | };
|
| 87 |
|
| 88 |
|
| 89 | int notrace sdei_event_handler(struct pt_regs *regs,
|
| 90 | struct sdei_registered_event *arg);
|
| 91 |
|
| 92 |
|
| 93 | int sdei_api_event_context(u32 query, u64 *result);
|
| 94 |
|
| 95 | #endif
|