sbi_hart.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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_HART_H__
  10. #define __SBI_HART_H__
  11. #include <sbi/sbi_types.h>
  12. /** Possible feature flags of a hart */
  13. enum sbi_hart_features {
  14. /** Hart has S-mode counter enable */
  15. SBI_HART_HAS_SCOUNTEREN = (1 << 0),
  16. /** Hart has M-mode counter enable */
  17. SBI_HART_HAS_MCOUNTEREN = (1 << 1),
  18. /** HART has timer csr implementation in hardware */
  19. SBI_HART_HAS_TIME = (1 << 2),
  20. /** Last index of Hart features*/
  21. SBI_HART_HAS_LAST_FEATURE = SBI_HART_HAS_TIME,
  22. };
  23. struct sbi_scratch;
  24. int sbi_hart_reinit(struct sbi_scratch *scratch);
  25. int sbi_hart_init(struct sbi_scratch *scratch, bool cold_boot);
  26. extern void (*sbi_hart_expected_trap)(void);
  27. static inline ulong sbi_hart_expected_trap_addr(void)
  28. {
  29. return (ulong)sbi_hart_expected_trap;
  30. }
  31. unsigned int sbi_hart_mhpm_count(struct sbi_scratch *scratch);
  32. void sbi_hart_delegation_dump(struct sbi_scratch *scratch,
  33. const char *prefix, const char *suffix);
  34. unsigned int sbi_hart_pmp_count(struct sbi_scratch *scratch);
  35. unsigned long sbi_hart_pmp_granularity(struct sbi_scratch *scratch);
  36. unsigned int sbi_hart_pmp_addrbits(struct sbi_scratch *scratch);
  37. int sbi_hart_pmp_configure(struct sbi_scratch *scratch);
  38. bool sbi_hart_has_feature(struct sbi_scratch *scratch, unsigned long feature);
  39. void sbi_hart_get_features_str(struct sbi_scratch *scratch,
  40. char *features_str, int nfstr);
  41. void __attribute__((noreturn)) sbi_hart_hang(void);
  42. void __attribute__((noreturn))
  43. sbi_hart_switch_mode(unsigned long arg0, unsigned long arg1,
  44. unsigned long next_addr, unsigned long next_mode,
  45. bool next_virt);
  46. #endif