Follow Nintendo's abort logic for TimeManager

This commit is contained in:
Thog 2019-10-01 01:00:44 +02:00
commit aca91c4610
No known key found for this signature in database
GPG key ID: 0CD291558FAFDBC6
2 changed files with 29 additions and 11 deletions

View file

@ -0,0 +1,9 @@
using System;
namespace Ryujinx.HLE.Exceptions
{
class InternalServiceException: Exception
{
public InternalServiceException(string message) : base(message) { }
}
}

View file

@ -1,5 +1,6 @@
using System; using System;
using System.IO; using System.IO;
using Ryujinx.HLE.Exceptions;
using Ryujinx.HLE.HOS.Kernel.Memory; using Ryujinx.HLE.HOS.Kernel.Memory;
using Ryujinx.HLE.HOS.Kernel.Threading; using Ryujinx.HLE.HOS.Kernel.Threading;
using Ryujinx.HLE.HOS.Services.Time.Clock; using Ryujinx.HLE.HOS.Services.Time.Clock;
@ -33,11 +34,12 @@ namespace Ryujinx.HLE.HOS.Services.Time
public TimeZoneContentManager TimeZone { get; private set; } public TimeZoneContentManager TimeZone { get; private set; }
public EphemeralNetworkSystemClockCore EphemeralNetworkSystemClock { get; private set; } public EphemeralNetworkSystemClockCore EphemeralNetworkSystemClock { get; private set; }
public TimeSharedMemory SharedMemory { get; private set; } public TimeSharedMemory SharedMemory { get; private set; }
// TODO: 9.0.0+ power states and alarms
public LocalSystemClockContextWriter LocalClockContextWriter { get; private set; } public LocalSystemClockContextWriter LocalClockContextWriter { get; private set; }
public NetworkSystemClockContextWriter NetworkClockContextWriter { get; private set; } public NetworkSystemClockContextWriter NetworkClockContextWriter { get; private set; }
public EphemeralNetworkSystemClockContextWriter EphemeralClockContextWriter { get; private set; } public EphemeralNetworkSystemClockContextWriter EphemeralClockContextWriter { get; private set; }
// TODO: 9.0.0+ power states and alarms
public TimeManager() public TimeManager()
{ {
StandardSteadyClock = new StandardSteadyClockCore(); StandardSteadyClock = new StandardSteadyClockCore();
@ -67,7 +69,7 @@ namespace Ryujinx.HLE.HOS.Services.Time
} }
public ResultCode SetupStandardSteadyClock(KThread thread, UInt128 clockSourceId, TimeSpanType setupValue, TimeSpanType internalOffset, TimeSpanType testOffset, bool isRtcResetDetected) public void SetupStandardSteadyClock(KThread thread, UInt128 clockSourceId, TimeSpanType setupValue, TimeSpanType internalOffset, TimeSpanType testOffset, bool isRtcResetDetected)
{ {
SetupInternalStandardSteadyClock(clockSourceId, setupValue, internalOffset, testOffset, isRtcResetDetected); SetupInternalStandardSteadyClock(clockSourceId, setupValue, internalOffset, testOffset, isRtcResetDetected);
@ -76,7 +78,6 @@ namespace Ryujinx.HLE.HOS.Services.Time
SharedMemory.SetupStandardSteadyClock(thread, clockSourceId, currentTimePoint); SharedMemory.SetupStandardSteadyClock(thread, clockSourceId, currentTimePoint);
// TODO: propagate IPC late binding of "time:s" and "time:p" // TODO: propagate IPC late binding of "time:s" and "time:p"
return ResultCode.Success;
} }
private void SetupInternalStandardSteadyClock(UInt128 clockSourceId, TimeSpanType setupValue, TimeSpanType internalOffset, TimeSpanType testOffset, bool isRtcResetDetected) private void SetupInternalStandardSteadyClock(UInt128 clockSourceId, TimeSpanType setupValue, TimeSpanType internalOffset, TimeSpanType testOffset, bool isRtcResetDetected)
@ -107,8 +108,10 @@ namespace Ryujinx.HLE.HOS.Services.Time
} }
else else
{ {
// TODO: if the result of this is wrong, abort if (StandardLocalSystemClock.SetCurrentTime(thread, posixTime) != ResultCode.Success)
StandardLocalSystemClock.SetCurrentTime(thread, posixTime); {
throw new InternalServiceException("Cannot set current local time");
}
} }
StandardLocalSystemClock.MarkInitialized(); StandardLocalSystemClock.MarkInitialized();
@ -121,8 +124,10 @@ namespace Ryujinx.HLE.HOS.Services.Time
{ {
StandardNetworkSystemClock.SetUpdateCallbackInstance(NetworkClockContextWriter); StandardNetworkSystemClock.SetUpdateCallbackInstance(NetworkClockContextWriter);
// TODO: if the result of this is wrong, abort if (StandardNetworkSystemClock.SetSystemClockContext(clockContext) != ResultCode.Success)
StandardNetworkSystemClock.SetSystemClockContext(clockContext); {
throw new InternalServiceException("Cannot set network SystemClockContext");
}
StandardNetworkSystemClock.SetStandardNetworkClockSufficientAccuracy(sufficientAccuracy); StandardNetworkSystemClock.SetStandardNetworkClockSufficientAccuracy(sufficientAccuracy);
StandardNetworkSystemClock.MarkInitialized(); StandardNetworkSystemClock.MarkInitialized();
@ -133,8 +138,10 @@ namespace Ryujinx.HLE.HOS.Services.Time
public void SetupTimeZoneManager(string locationName, SteadyClockTimePoint timeZoneUpdatedTimePoint, uint totalLocationNameCount, UInt128 timeZoneRuleVersion, Stream timeZoneBinaryStream) public void SetupTimeZoneManager(string locationName, SteadyClockTimePoint timeZoneUpdatedTimePoint, uint totalLocationNameCount, UInt128 timeZoneRuleVersion, Stream timeZoneBinaryStream)
{ {
// TODO: if the result of this is wrong, abort if (TimeZone.Manager.SetDeviceLocationNameWithTimeZoneRule(locationName, timeZoneBinaryStream) != ResultCode.Success)
TimeZone.Manager.SetDeviceLocationNameWithTimeZoneRule(locationName, timeZoneBinaryStream); {
throw new InternalServiceException("Cannot set DeviceLocationName with a given TimeZoneBinary");
}
TimeZone.Manager.SetUpdatedTime(timeZoneUpdatedTimePoint, true); TimeZone.Manager.SetUpdatedTime(timeZoneUpdatedTimePoint, true);
TimeZone.Manager.SetTotalLocationNameCount(totalLocationNameCount); TimeZone.Manager.SetTotalLocationNameCount(totalLocationNameCount);
@ -156,8 +163,10 @@ namespace Ryujinx.HLE.HOS.Services.Time
public void SetupStandardUserSystemClock(KThread thread, bool isAutomaticCorrectionEnabled, SteadyClockTimePoint steadyClockTimePoint) public void SetupStandardUserSystemClock(KThread thread, bool isAutomaticCorrectionEnabled, SteadyClockTimePoint steadyClockTimePoint)
{ {
// TODO: if the result of this is wrong, abort if (StandardUserSystemClock.SetAutomaticCorrectionEnabled(thread, isAutomaticCorrectionEnabled) != ResultCode.Success)
StandardUserSystemClock.SetAutomaticCorrectionEnabled(thread, isAutomaticCorrectionEnabled); {
throw new InternalServiceException("Cannot set automatic user time correction state");
}
StandardUserSystemClock.SetAutomaticCorrectionUpdatedTime(steadyClockTimePoint); StandardUserSystemClock.SetAutomaticCorrectionUpdatedTime(steadyClockTimePoint);
StandardUserSystemClock.MarkInitialized(); StandardUserSystemClock.MarkInitialized();