public void SetSteadyClockRawTimePoint(KThread thread, TimeSpanType currentTimePoint) { SteadyClockContext context = ReadObjectFromSharedMemory <SteadyClockContext>(SteadyClockContextOffset, 4); TimeSpanType ticksTimeSpan = TimeSpanType.FromTicks(thread.Context.CntpctEl0, thread.Context.CntfrqEl0); context.InternalOffset = (ulong)(currentTimePoint.NanoSeconds - ticksTimeSpan.NanoSeconds); WriteObjectToSharedMemory(SteadyClockContextOffset, 4, context); }
public void SetupStandardSteadyClock(ITickSource tickSource, UInt128 clockSourceId, TimeSpanType currentTimePoint) { TimeSpanType ticksTimeSpan = TimeSpanType.FromTicks(tickSource.Counter, tickSource.Frequency); SteadyClockContext context = new SteadyClockContext { InternalOffset = (ulong)(currentTimePoint.NanoSeconds - ticksTimeSpan.NanoSeconds), ClockSourceId = clockSourceId }; WriteObjectToSharedMemory(SteadyClockContextOffset, 4, context); }
[Command(300)] // 4.0.0+ // CalculateMonotonicSystemClockBaseTimePoint(nn::time::SystemClockContext) -> s64 public ResultCode CalculateMonotonicSystemClockBaseTimePoint(ServiceCtx context) { SystemClockContext otherContext = context.RequestData.ReadStruct <SystemClockContext>(); SteadyClockTimePoint currentTimePoint = StandardSteadyClockCore.Instance.GetCurrentTimePoint(context.Thread); ResultCode result = ResultCode.TimeMismatch; if (currentTimePoint.ClockSourceId == otherContext.SteadyTimePoint.ClockSourceId) { TimeSpanType ticksTimeSpan = TimeSpanType.FromTicks(context.Thread.Context.CntpctEl0, context.Thread.Context.CntfrqEl0); long baseTimePoint = otherContext.Offset + currentTimePoint.TimePoint - ticksTimeSpan.ToSeconds(); context.ResponseData.Write(baseTimePoint); result = 0; } return(result); }
public void SetupStandardSteadyClock(KThread thread, UInt128 clockSourceId, TimeSpanType currentTimePoint) { TimeSpanType ticksTimeSpan; // As this may be called before the guest code, we support passing a null thread to make this api usable. if (thread == null) { ticksTimeSpan = TimeSpanType.FromSeconds(0); } else { ticksTimeSpan = TimeSpanType.FromTicks(thread.Context.CntpctEl0, thread.Context.CntfrqEl0); } SteadyClockContext context = new SteadyClockContext { InternalOffset = (ulong)(currentTimePoint.NanoSeconds - ticksTimeSpan.NanoSeconds), ClockSourceId = clockSourceId }; WriteObjectToSharedMemory(SteadyClockContextOffset, 4, context); }