Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0
0002 // Copyright (C) 2017 Arm Ltd.
0003 #ifndef __LINUX_ARM_SDEI_H
0004 #define __LINUX_ARM_SDEI_H
0005 
0006 #include <uapi/linux/arm_sdei.h>
0007 
0008 #include <acpi/ghes.h>
0009 
0010 #ifdef CONFIG_ARM_SDE_INTERFACE
0011 #include <asm/sdei.h>
0012 #endif
0013 
0014 /* Arch code should override this to set the entry point from firmware... */
0015 #ifndef sdei_arch_get_entry_point
0016 #define sdei_arch_get_entry_point(conduit)  (0)
0017 #endif
0018 
0019 /*
0020  * When an event occurs sdei_event_handler() will call a user-provided callback
0021  * like this in NMI context on the CPU that received the event.
0022  */
0023 typedef int (sdei_event_callback)(u32 event, struct pt_regs *regs, void *arg);
0024 
0025 /*
0026  * Register your callback to claim an event. The event must be described
0027  * by firmware.
0028  */
0029 int sdei_event_register(u32 event_num, sdei_event_callback *cb, void *arg);
0030 
0031 /*
0032  * Calls to sdei_event_unregister() may return EINPROGRESS. Keep calling
0033  * it until it succeeds.
0034  */
0035 int sdei_event_unregister(u32 event_num);
0036 
0037 int sdei_event_enable(u32 event_num);
0038 int sdei_event_disable(u32 event_num);
0039 
0040 /* GHES register/unregister helpers */
0041 int sdei_register_ghes(struct ghes *ghes, sdei_event_callback *normal_cb,
0042                sdei_event_callback *critical_cb);
0043 int sdei_unregister_ghes(struct ghes *ghes);
0044 
0045 #ifdef CONFIG_ARM_SDE_INTERFACE
0046 /* For use by arch code when CPU hotplug notifiers are not appropriate. */
0047 int sdei_mask_local_cpu(void);
0048 int sdei_unmask_local_cpu(void);
0049 void __init sdei_init(void);
0050 #else
0051 static inline int sdei_mask_local_cpu(void) { return 0; }
0052 static inline int sdei_unmask_local_cpu(void) { return 0; }
0053 static inline void sdei_init(void) { }
0054 #endif /* CONFIG_ARM_SDE_INTERFACE */
0055 
0056 
0057 /*
0058  * This struct represents an event that has been registered. The driver
0059  * maintains a list of all events, and which ones are registered. (Private
0060  * events have one entry in the list, but are registered on each CPU).
0061  * A pointer to this struct is passed to firmware, and back to the event
0062  * handler. The event handler can then use this to invoke the registered
0063  * callback, without having to walk the list.
0064  *
0065  * For CPU private events, this structure is per-cpu.
0066  */
0067 struct sdei_registered_event {
0068     /* For use by arch code: */
0069     struct pt_regs          interrupted_regs;
0070 
0071     sdei_event_callback *callback;
0072     void            *callback_arg;
0073     u32          event_num;
0074     u8           priority;
0075 };
0076 
0077 /* The arch code entry point should then call this when an event arrives. */
0078 int notrace sdei_event_handler(struct pt_regs *regs,
0079                    struct sdei_registered_event *arg);
0080 
0081 /* arch code may use this to retrieve the extra registers. */
0082 int sdei_api_event_context(u32 query, u64 *result);
0083 
0084 #endif /* __LINUX_ARM_SDEI_H */