timer.h 1003 B

123456789101112131415161718192021222324252627282930313233343536
  1. /* Copyright 2018 SiFive, Inc */
  2. /* SPDX-License-Identifier: Apache-2.0 */
  3. #ifndef METAL__TIMER_H
  4. #define METAL__TIMER_H
  5. /*!
  6. * @file timer.h
  7. * @brief API for reading and manipulating the machine timer
  8. */
  9. /*!
  10. * @brief Read the machine cycle count
  11. * @param hartid The hart ID to read the cycle count of
  12. * @param cyclecount The variable to hold the value
  13. * @return 0 upon success
  14. */
  15. int metal_timer_get_cyclecount(int hartid, unsigned long long *cyclecount);
  16. /*!
  17. * @brief Get the machine timebase frequency
  18. * @param hartid The hart ID to read the timebase of
  19. * @param timebase The variable to hold the value
  20. * @return 0 upon success
  21. */
  22. int metal_timer_get_timebase_frequency(int hartid, unsigned long long *timebase);
  23. /*!
  24. * @brief Set the machine timer tick interval in seconds
  25. * @param hartid The hart ID to read the timebase of
  26. * @param second The number of seconds to set the tick interval to
  27. * @return 0 upon success
  28. */
  29. int metal_timer_set_tick(int hartid, int second);
  30. #endif