diff options
author | gdkchan <gab.dark.100@gmail.com> | 2022-05-31 16:29:35 -0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-05-31 16:29:35 -0300 |
commit | 0c87bf9ea4b0655fc6b90b4ab20e93f237e7549b (patch) | |
tree | 0fe100d5cd958bfb8f5974f1b614b94c09e89a26 /Ryujinx.HLE/HOS/Services/Time/TimeManager.cs | |
parent | 9827dc35e14cb704cb4adcb894e0efbac893080c (diff) |
Refactor CPU interface to allow the implementation of other CPU emulators (#3362)1.1.134
* 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
Diffstat (limited to 'Ryujinx.HLE/HOS/Services/Time/TimeManager.cs')
-rw-r--r-- | Ryujinx.HLE/HOS/Services/Time/TimeManager.cs | 28 |
1 files changed, 13 insertions, 15 deletions
diff --git a/Ryujinx.HLE/HOS/Services/Time/TimeManager.cs b/Ryujinx.HLE/HOS/Services/Time/TimeManager.cs index e2217890..ac9f0880 100644 --- a/Ryujinx.HLE/HOS/Services/Time/TimeManager.cs +++ b/Ryujinx.HLE/HOS/Services/Time/TimeManager.cs @@ -1,11 +1,10 @@ -using System; -using System.IO; +using Ryujinx.Cpu; using Ryujinx.HLE.Exceptions; using Ryujinx.HLE.HOS.Kernel.Memory; -using Ryujinx.HLE.HOS.Kernel.Threading; using Ryujinx.HLE.HOS.Services.Time.Clock; using Ryujinx.HLE.HOS.Services.Time.TimeZone; using Ryujinx.HLE.Utilities; +using System.IO; namespace Ryujinx.HLE.HOS.Services.Time { @@ -68,14 +67,13 @@ namespace Ryujinx.HLE.HOS.Services.Time TimeZone.Initialize(this, device); } - - public void SetupStandardSteadyClock(KThread thread, UInt128 clockSourceId, TimeSpanType setupValue, TimeSpanType internalOffset, TimeSpanType testOffset, bool isRtcResetDetected) + public void SetupStandardSteadyClock(ITickSource tickSource, UInt128 clockSourceId, TimeSpanType setupValue, TimeSpanType internalOffset, TimeSpanType testOffset, bool isRtcResetDetected) { SetupInternalStandardSteadyClock(clockSourceId, setupValue, internalOffset, testOffset, isRtcResetDetected); - TimeSpanType currentTimePoint = StandardSteadyClock.GetCurrentRawTimePoint(thread); + TimeSpanType currentTimePoint = StandardSteadyClock.GetCurrentRawTimePoint(tickSource); - SharedMemory.SetupStandardSteadyClock(thread, clockSourceId, currentTimePoint); + SharedMemory.SetupStandardSteadyClock(tickSource, clockSourceId, currentTimePoint); // TODO: propagate IPC late binding of "time:s" and "time:p" } @@ -97,18 +95,18 @@ namespace Ryujinx.HLE.HOS.Services.Time // TODO: propagate IPC late binding of "time:s" and "time:p" } - public void SetupStandardLocalSystemClock(KThread thread, SystemClockContext clockContext, long posixTime) + public void SetupStandardLocalSystemClock(ITickSource tickSource, SystemClockContext clockContext, long posixTime) { StandardLocalSystemClock.SetUpdateCallbackInstance(LocalClockContextWriter); - SteadyClockTimePoint currentTimePoint = StandardLocalSystemClock.GetSteadyClockCore().GetCurrentTimePoint(thread); + SteadyClockTimePoint currentTimePoint = StandardLocalSystemClock.GetSteadyClockCore().GetCurrentTimePoint(tickSource); if (currentTimePoint.ClockSourceId == clockContext.SteadyTimePoint.ClockSourceId) { StandardLocalSystemClock.SetSystemClockContext(clockContext); } else { - if (StandardLocalSystemClock.SetCurrentTime(thread, posixTime) != ResultCode.Success) + if (StandardLocalSystemClock.SetCurrentTime(tickSource, posixTime) != ResultCode.Success) { throw new InternalServiceException("Cannot set current local time"); } @@ -157,9 +155,9 @@ namespace Ryujinx.HLE.HOS.Services.Time // TODO: propagate IPC late binding of "time:s" and "time:p" } - public void SetupStandardUserSystemClock(KThread thread, bool isAutomaticCorrectionEnabled, SteadyClockTimePoint steadyClockTimePoint) + public void SetupStandardUserSystemClock(ITickSource tickSource, bool isAutomaticCorrectionEnabled, SteadyClockTimePoint steadyClockTimePoint) { - if (StandardUserSystemClock.SetAutomaticCorrectionEnabled(thread, isAutomaticCorrectionEnabled) != ResultCode.Success) + if (StandardUserSystemClock.SetAutomaticCorrectionEnabled(tickSource, isAutomaticCorrectionEnabled) != ResultCode.Success) { throw new InternalServiceException("Cannot set automatic user time correction state"); } @@ -172,13 +170,13 @@ namespace Ryujinx.HLE.HOS.Services.Time // TODO: propagate IPC late binding of "time:s" and "time:p" } - public void SetStandardSteadyClockRtcOffset(KThread thread, TimeSpanType rtcOffset) + public void SetStandardSteadyClockRtcOffset(ITickSource tickSource, TimeSpanType rtcOffset) { StandardSteadyClock.SetSetupValue(rtcOffset); - TimeSpanType currentTimePoint = StandardSteadyClock.GetCurrentRawTimePoint(thread); + TimeSpanType currentTimePoint = StandardSteadyClock.GetCurrentRawTimePoint(tickSource); - SharedMemory.SetSteadyClockRawTimePoint(thread, currentTimePoint); + SharedMemory.SetSteadyClockRawTimePoint(tickSource, currentTimePoint); } } } |