0c87bf9ea4
* Refactor CPU interface * Use IExecutionContext interface on SVC handler, change how CPU interrupts invokes the handlers * Make CpuEngine take a ITickSource rather than returning one The previous implementation had the scenario where the CPU engine had to implement the tick source in mind, like for example, when we have a hypervisor and the game can read CNTPCT on the host directly. However given that we need to do conversion due to different frequencies anyway, it's not worth it. It's better to just let the user pass the tick source and redirect any reads to CNTPCT to the user tick source * XML docs for the public interfaces * PPTC invalidation due to NativeInterface function name changes * Fix build of the CPU tests * PR feedback
98 lines
2.4 KiB
C#
98 lines
2.4 KiB
C#
using Ryujinx.Cpu;
|
|
using Ryujinx.HLE.Utilities;
|
|
using System;
|
|
|
|
namespace Ryujinx.HLE.HOS.Services.Time.Clock
|
|
{
|
|
abstract class SteadyClockCore
|
|
{
|
|
private UInt128 _clockSourceId;
|
|
private bool _isRtcResetDetected;
|
|
private bool _isInitialized;
|
|
|
|
public SteadyClockCore()
|
|
{
|
|
_clockSourceId = new UInt128(Guid.NewGuid().ToByteArray());
|
|
_isRtcResetDetected = false;
|
|
_isInitialized = false;
|
|
}
|
|
|
|
public UInt128 GetClockSourceId()
|
|
{
|
|
return _clockSourceId;
|
|
}
|
|
|
|
public void SetClockSourceId(UInt128 clockSourceId)
|
|
{
|
|
_clockSourceId = clockSourceId;
|
|
}
|
|
|
|
public void SetRtcReset()
|
|
{
|
|
_isRtcResetDetected = true;
|
|
}
|
|
|
|
public virtual TimeSpanType GetTestOffset()
|
|
{
|
|
return new TimeSpanType(0);
|
|
}
|
|
|
|
public virtual void SetTestOffset(TimeSpanType testOffset) {}
|
|
|
|
public ResultCode GetRtcValue(out ulong rtcValue)
|
|
{
|
|
rtcValue = 0;
|
|
|
|
return ResultCode.NotImplemented;
|
|
}
|
|
|
|
public bool IsRtcResetDetected()
|
|
{
|
|
return _isRtcResetDetected;
|
|
}
|
|
|
|
public ResultCode GetSetupResultValue()
|
|
{
|
|
return ResultCode.Success;
|
|
}
|
|
|
|
public virtual TimeSpanType GetInternalOffset()
|
|
{
|
|
return new TimeSpanType(0);
|
|
}
|
|
|
|
public virtual void SetInternalOffset(TimeSpanType internalOffset) {}
|
|
|
|
public virtual SteadyClockTimePoint GetTimePoint(ITickSource tickSource)
|
|
{
|
|
throw new NotImplementedException();
|
|
}
|
|
|
|
public virtual TimeSpanType GetCurrentRawTimePoint(ITickSource tickSource)
|
|
{
|
|
SteadyClockTimePoint timePoint = GetTimePoint(tickSource);
|
|
|
|
return TimeSpanType.FromSeconds(timePoint.TimePoint);
|
|
}
|
|
|
|
public SteadyClockTimePoint GetCurrentTimePoint(ITickSource tickSource)
|
|
{
|
|
SteadyClockTimePoint result = GetTimePoint(tickSource);
|
|
|
|
result.TimePoint += GetTestOffset().ToSeconds();
|
|
result.TimePoint += GetInternalOffset().ToSeconds();
|
|
|
|
return result;
|
|
}
|
|
|
|
public bool IsInitialized()
|
|
{
|
|
return _isInitialized;
|
|
}
|
|
|
|
public void MarkInitialized()
|
|
{
|
|
_isInitialized = true;
|
|
}
|
|
}
|
|
}
|