arm_sdei.h 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. // 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. #include <uapi/linux/arm_sdei.h>
  6. enum sdei_conduit_types {
  7. CONDUIT_INVALID = 0,
  8. CONDUIT_SMC,
  9. CONDUIT_HVC,
  10. };
  11. #include <asm/sdei.h>
  12. /* Arch code should override this to set the entry point from firmware... */
  13. #ifndef sdei_arch_get_entry_point
  14. #define sdei_arch_get_entry_point(conduit) (0)
  15. #endif
  16. /*
  17. * When an event occurs sdei_event_handler() will call a user-provided callback
  18. * like this in NMI context on the CPU that received the event.
  19. */
  20. typedef int (sdei_event_callback)(u32 event, struct pt_regs *regs, void *arg);
  21. /*
  22. * Register your callback to claim an event. The event must be described
  23. * by firmware.
  24. */
  25. int sdei_event_register(u32 event_num, sdei_event_callback *cb, void *arg);
  26. /*
  27. * Calls to sdei_event_unregister() may return EINPROGRESS. Keep calling
  28. * it until it succeeds.
  29. */
  30. int sdei_event_unregister(u32 event_num);
  31. int sdei_event_enable(u32 event_num);
  32. int sdei_event_disable(u32 event_num);
  33. #ifdef CONFIG_ARM_SDE_INTERFACE
  34. /* For use by arch code when CPU hotplug notifiers are not appropriate. */
  35. int sdei_mask_local_cpu(void);
  36. int sdei_unmask_local_cpu(void);
  37. #else
  38. static inline int sdei_mask_local_cpu(void) { return 0; }
  39. static inline int sdei_unmask_local_cpu(void) { return 0; }
  40. #endif /* CONFIG_ARM_SDE_INTERFACE */
  41. /*
  42. * This struct represents an event that has been registered. The driver
  43. * maintains a list of all events, and which ones are registered. (Private
  44. * events have one entry in the list, but are registered on each CPU).
  45. * A pointer to this struct is passed to firmware, and back to the event
  46. * handler. The event handler can then use this to invoke the registered
  47. * callback, without having to walk the list.
  48. *
  49. * For CPU private events, this structure is per-cpu.
  50. */
  51. struct sdei_registered_event {
  52. /* For use by arch code: */
  53. struct pt_regs interrupted_regs;
  54. sdei_event_callback *callback;
  55. void *callback_arg;
  56. u32 event_num;
  57. u8 priority;
  58. };
  59. /* The arch code entry point should then call this when an event arrives. */
  60. int notrace sdei_event_handler(struct pt_regs *regs,
  61. struct sdei_registered_event *arg);
  62. /* arch code may use this to retrieve the extra registers. */
  63. int sdei_api_event_context(u32 query, u64 *result);
  64. #endif /* __LINUX_ARM_SDEI_H */