TickBasedSteadyClockCore.cs 1002 B

12345678910111213141516171819202122232425262728293031323334
  1. using Ryujinx.HLE.HOS.Kernel.Threading;
  2. namespace Ryujinx.HLE.HOS.Services.Time.Clock
  3. {
  4. class TickBasedSteadyClockCore : SteadyClockCore
  5. {
  6. public TickBasedSteadyClockCore() {}
  7. public override SteadyClockTimePoint GetTimePoint(KThread thread)
  8. {
  9. SteadyClockTimePoint result = new SteadyClockTimePoint
  10. {
  11. TimePoint = 0,
  12. ClockSourceId = GetClockSourceId()
  13. };
  14. TimeSpanType ticksTimeSpan;
  15. // As this may be called before the guest code, we support passing a null thread to make this api usable.
  16. if (thread == null)
  17. {
  18. ticksTimeSpan = TimeSpanType.FromSeconds(0);
  19. }
  20. else
  21. {
  22. ticksTimeSpan = TimeSpanType.FromTicks(thread.Context.CntpctEl0, thread.Context.CntfrqEl0);
  23. }
  24. result.TimePoint = ticksTimeSpan.ToSeconds();
  25. return result;
  26. }
  27. }
  28. }