2019-07-14 20:50:11 +00:00
|
|
|
|
using Ryujinx.HLE.HOS.Kernel.Threading;
|
|
|
|
|
|
|
|
|
|
namespace Ryujinx.HLE.HOS.Services.Time.Clock
|
|
|
|
|
{
|
|
|
|
|
abstract class SystemClockCore
|
|
|
|
|
{
|
2019-07-25 14:44:51 +00:00
|
|
|
|
private SteadyClockCore _steadyClockCore;
|
|
|
|
|
private SystemClockContext _context;
|
2019-07-14 20:50:11 +00:00
|
|
|
|
|
2019-07-25 14:44:51 +00:00
|
|
|
|
public SystemClockCore(SteadyClockCore steadyClockCore)
|
|
|
|
|
{
|
|
|
|
|
_steadyClockCore = steadyClockCore;
|
|
|
|
|
_context = new SystemClockContext();
|
|
|
|
|
|
|
|
|
|
_context.SteadyTimePoint.ClockSourceId = steadyClockCore.GetClockSourceId();
|
|
|
|
|
}
|
2019-07-14 20:50:11 +00:00
|
|
|
|
|
2019-07-25 14:44:51 +00: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 20:50:11 +00: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;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|