RiscVPlatformTimerLib.S 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. //------------------------------------------------------------------------------
  2. //
  3. // SiFive U5 Series Timer CSR functions.
  4. //
  5. // Copyright (c) 2019, Hewlett Packard Enterprise Development LP. All rights reserved.<BR>
  6. //
  7. // SPDX-License-Identifier: BSD-2-Clause-Patent
  8. //
  9. //------------------------------------------------------------------------------
  10. #include <Base.h>
  11. #include <RiscVImpl.h>
  12. #include <U5Clint.h>
  13. .data
  14. .text
  15. .align 3
  16. .global ASM_PFX(RiscVReadMachineTimer)
  17. .global ASM_PFX(RiscVSetMachineTimerCmp)
  18. .global ASM_PFX(RiscVReadMachineTimerCmp)
  19. //
  20. // Read machine timer CSR.
  21. // @retval a0 : 64-bit machine timer.
  22. //
  23. ASM_PFX (RiscVReadMachineTimer):
  24. li t1, CLINT_REG_MTIME
  25. ld a0, (t1)
  26. ret
  27. //
  28. // Set machine timer compare CSR.
  29. // @param a0 : UINT64
  30. //
  31. ASM_PFX (RiscVSetMachineTimerCmp):
  32. li t1, CLINT_REG_MTIMECMP0
  33. sd a0, (t1)
  34. ret
  35. //
  36. // Read machine timer compare CSR.
  37. // @param a0 : UINT64
  38. //
  39. ASM_PFX (RiscVReadMachineTimerCmp):
  40. li t1, CLINT_REG_MTIMECMP0
  41. ld a0, (t1)
  42. ret