arm_sdei.h 2.5 KB

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