2019-07-14 13:50:11 -07:00
|
|
|
|
using Ryujinx.HLE.HOS.Kernel.Threading;
|
|
|
|
|
|
|
|
|
|
namespace Ryujinx.HLE.HOS.Services.Time.Clock
|
|
|
|
|
{
|
|
|
|
|
abstract class SystemClockCore
|
|
|
|
|
{
|
2019-07-25 07:44:51 -07:00
|
|
|
|
private SteadyClockCore _steadyClockCore;
|
|
|
|
|
private SystemClockContext _context;
|
2019-07-14 13:50:11 -07:00
|
|
|
|
|
2019-07-25 07:44:51 -07:00
|
|
|
|
public SystemClockCore(SteadyClockCore steadyClockCore)
|
|
|
|
|
{
|
|
|
|
|
_steadyClockCore = steadyClockCore;
|
|
|
|
|
_context = new SystemClockContext();
|
|
|
|
|
|
|
|
|
|
_context.SteadyTimePoint.ClockSourceId = steadyClockCore.GetClockSourceId();
|
|
|
|
|
}
|
2019-07-14 13:50:11 -07:00
|
|
|
|
|
2019-07-25 07:44:51 -07:00
|
|
|
|
public virtual SteadyClockCore GetSteadyClockCore()
|
|
|
|
|
{
|
|
|
|
|
return _steadyClockCore;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public virtual ResultCode GetSystemClockContext(KThread thread, out SystemClockContext context)
|
|
|
|
|
{
|
|
|
|
|
context = _context;
|
|
|
|
|
|
|
|
|
|
return ResultCode.Success;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public virtual ResultCode SetSystemClockContext(SystemClockContext context)
|
|
|
|
|
{
|
|
|
|
|
_context = context;
|
|
|
|
|
|
|
|
|
|
return ResultCode.Success;
|
|
|
|
|
}
|
2019-07-14 13:50:11 -07:00
|
|
|
|
|
|
|
|
|
public abstract ResultCode Flush(SystemClockContext context);
|
|
|
|
|
|
|
|
|
|
public bool IsClockSetup(KThread thread)
|
|
|
|
|
{
|
|
|
|
|
ResultCode result = GetSystemClockContext(thread, out SystemClockContext context);
|
|
|
|
|
|
|
|
|
|
if (result == ResultCode.Success)
|
|
|
|
|
{
|
|
|
|
|
SteadyClockCore steadyClockCore = GetSteadyClockCore();
|
|
|
|
|
|
|
|
|
|
SteadyClockTimePoint steadyClockTimePoint = steadyClockCore.GetCurrentTimePoint(thread);
|
|
|
|
|
|
|
|
|
|
return steadyClockTimePoint.ClockSourceId == context.SteadyTimePoint.ClockSourceId;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|