sbi_ipi.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. /*
  2. * SPDX-License-Identifier: BSD-2-Clause
  3. *
  4. * Copyright (c) 2019 Western Digital Corporation or its affiliates.
  5. *
  6. * Authors:
  7. * Anup Patel <anup.patel@wdc.com>
  8. */
  9. #ifndef __SBI_IPI_H__
  10. #define __SBI_IPI_H__
  11. #include <sbi/sbi_types.h>
  12. /* clang-format off */
  13. #define SBI_IPI_EVENT_MAX __riscv_xlen
  14. /* clang-format on */
  15. /** IPI hardware device */
  16. struct sbi_ipi_device {
  17. /** Name of the IPI device */
  18. char name[32];
  19. /** Send IPI to a target HART */
  20. void (*ipi_send)(u32 target_hart);
  21. /** Clear IPI for a target HART */
  22. void (*ipi_clear)(u32 target_hart);
  23. };
  24. struct sbi_scratch;
  25. /** IPI event operations or callbacks */
  26. struct sbi_ipi_event_ops {
  27. /** Name of the IPI event operations */
  28. char name[32];
  29. /**
  30. * Update callback to save/enqueue data for remote HART
  31. * Note: This is an optional callback and it is called just before
  32. * triggering IPI to remote HART.
  33. */
  34. int (* update)(struct sbi_scratch *scratch,
  35. struct sbi_scratch *remote_scratch,
  36. u32 remote_hartid, void *data);
  37. /**
  38. * Sync callback to wait for remote HART
  39. * Note: This is an optional callback and it is called just after
  40. * triggering IPI to remote HART.
  41. */
  42. void (* sync)(struct sbi_scratch *scratch);
  43. /**
  44. * Process callback to handle IPI event
  45. * Note: This is a mandatory callback and it is called on the
  46. * remote HART after IPI is triggered.
  47. */
  48. void (* process)(struct sbi_scratch *scratch);
  49. };
  50. int sbi_ipi_send_many(ulong hmask, ulong hbase, u32 event, void *data);
  51. int sbi_ipi_event_create(const struct sbi_ipi_event_ops *ops);
  52. void sbi_ipi_event_destroy(u32 event);
  53. int sbi_ipi_send_smode(ulong hmask, ulong hbase);
  54. void sbi_ipi_clear_smode(void);
  55. int sbi_ipi_send_halt(ulong hmask, ulong hbase);
  56. void sbi_ipi_process(void);
  57. void sbi_ipi_raw_send(u32 target_hart);
  58. const struct sbi_ipi_device *sbi_ipi_get_device(void);
  59. void sbi_ipi_set_device(const struct sbi_ipi_device *dev);
  60. int sbi_ipi_init(struct sbi_scratch *scratch, bool cold_boot);
  61. void sbi_ipi_exit(struct sbi_scratch *scratch);
  62. #endif