sbi_hsm.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /*
  2. * SPDX-License-Identifier: BSD-2-Clause
  3. *
  4. * Copyright (c) 2020 Western Digital Corporation or its affiliates.
  5. *
  6. * Authors:
  7. * Atish Patra <atish.patra@wdc.com>
  8. */
  9. #ifndef __SBI_HSM_H__
  10. #define __SBI_HSM_H__
  11. #include <sbi/sbi_types.h>
  12. /** Hart state managment device */
  13. struct sbi_hsm_device {
  14. /** Name of the hart state managment device */
  15. char name[32];
  16. /** Start (or power-up) the given hart */
  17. int (*hart_start)(u32 hartid, ulong saddr);
  18. /**
  19. * Stop (or power-down) the current hart from running. This call
  20. * doesn't expect to return if success.
  21. */
  22. int (*hart_stop)(void);
  23. /**
  24. * Put the current hart in platform specific suspend (or low-power)
  25. * state.
  26. *
  27. * For successful retentive suspend, the call will return 0 when
  28. * the hart resumes normal execution.
  29. *
  30. * For successful non-retentive suspend, the hart will resume from
  31. * specified resume address
  32. */
  33. int (*hart_suspend)(u32 suspend_type, ulong raddr);
  34. };
  35. struct sbi_domain;
  36. struct sbi_scratch;
  37. const struct sbi_hsm_device *sbi_hsm_get_device(void);
  38. void sbi_hsm_set_device(const struct sbi_hsm_device *dev);
  39. int sbi_hsm_init(struct sbi_scratch *scratch, u32 hartid, bool cold_boot);
  40. void __noreturn sbi_hsm_exit(struct sbi_scratch *scratch);
  41. int sbi_hsm_hart_start(struct sbi_scratch *scratch,
  42. const struct sbi_domain *dom,
  43. u32 hartid, ulong saddr, ulong smode, ulong priv);
  44. int sbi_hsm_hart_stop(struct sbi_scratch *scratch, bool exitnow);
  45. void sbi_hsm_hart_resume_start(struct sbi_scratch *scratch);
  46. void sbi_hsm_hart_resume_finish(struct sbi_scratch *scratch);
  47. int sbi_hsm_hart_suspend(struct sbi_scratch *scratch, u32 suspend_type,
  48. ulong raddr, ulong rmode, ulong priv);
  49. int sbi_hsm_hart_get_state(const struct sbi_domain *dom, u32 hartid);
  50. int sbi_hsm_hart_interruptible_mask(const struct sbi_domain *dom,
  51. ulong hbase, ulong *out_hmask);
  52. void sbi_hsm_prepare_next_jump(struct sbi_scratch *scratch, u32 hartid);
  53. #endif