Count.S 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. #------------------------------------------------------------------------------
  2. #
  3. # Count for LoongArch
  4. #
  5. # Copyright (c) 2022 Loongson Technology Corporation Limited. All rights reserved.<BR>
  6. #
  7. # SPDX-License-Identifier: BSD-2-Clause-Patent
  8. #
  9. #------------------------------------------------------------------------------
  10. #ifndef __ASSEMBLY__
  11. #define __ASSEMBLY__
  12. #endif
  13. #include "Library/Cpu.h"
  14. ASM_GLOBAL ASM_PFX(CpuSetIP)
  15. ASM_GLOBAL ASM_PFX(LoongArchReadTime)
  16. ASM_GLOBAL ASM_PFX(LoongArchReadCpuCfg)
  17. #
  18. # Set cpu interrupts
  19. # @param A0 The interrupt number
  20. #
  21. ASM_PFX(CpuSetIP):
  22. csrrd T0, LOONGARCH_CSR_ECFG
  23. or T0, T0, A0
  24. csrwr T0, LOONGARCH_CSR_ECFG
  25. jirl ZERO, RA, 0
  26. #
  27. #Gets the timer count value.
  28. #@param[] VOID
  29. #@retval timer count value.
  30. #
  31. ASM_PFX(LoongArchReadTime):
  32. rdtime.d A0, ZERO
  33. jirl ZERO, RA, 0
  34. #
  35. # Read Csr CPUCFG register.
  36. # @param A0 Pointer to the variable used to store the CPUCFG register value.
  37. # @param A1 Specifies the register number of the CPUCFG to read the data.
  38. # @retval none
  39. #
  40. ASM_PFX(LoongArchReadCpuCfg):
  41. cpucfg T0, A1
  42. stptr.d T0, A0, 0
  43. jirl ZERO, RA, 0