aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.HLE/OsHle/Services/Time
diff options
context:
space:
mode:
authorgdkchan <gab.dark.100@gmail.com>2018-06-10 21:46:42 -0300
committergdkchan <gab.dark.100@gmail.com>2018-06-10 21:46:42 -0300
commit76f3b1b3a4637ec72abfbb8cbc0679f2e0ca838f (patch)
tree0411b709de31c1c0517763512df8eeb9f7491bc9 /Ryujinx.HLE/OsHle/Services/Time
parent518fe799da6dd4f12c58c9e6e174767effb0b868 (diff)
Rename Ryujinx.Core to Ryujinx.HLE and add a separate project for a future LLE implementation
Diffstat (limited to 'Ryujinx.HLE/OsHle/Services/Time')
-rw-r--r--Ryujinx.HLE/OsHle/Services/Time/IStaticService.cs60
-rw-r--r--Ryujinx.HLE/OsHle/Services/Time/ISteadyClock.cs20
-rw-r--r--Ryujinx.HLE/OsHle/Services/Time/ISystemClock.cs42
-rw-r--r--Ryujinx.HLE/OsHle/Services/Time/ITimeZoneService.cs76
-rw-r--r--Ryujinx.HLE/OsHle/Services/Time/SystemClockType.cs9
5 files changed, 207 insertions, 0 deletions
diff --git a/Ryujinx.HLE/OsHle/Services/Time/IStaticService.cs b/Ryujinx.HLE/OsHle/Services/Time/IStaticService.cs
new file mode 100644
index 00000000..1f012144
--- /dev/null
+++ b/Ryujinx.HLE/OsHle/Services/Time/IStaticService.cs
@@ -0,0 +1,60 @@
+using Ryujinx.HLE.OsHle.Ipc;
+using System.Collections.Generic;
+
+namespace Ryujinx.HLE.OsHle.Services.Time
+{
+ class IStaticService : IpcService
+ {
+ private Dictionary<int, ServiceProcessRequest> m_Commands;
+
+ public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => m_Commands;
+
+ public IStaticService()
+ {
+ m_Commands = new Dictionary<int, ServiceProcessRequest>()
+ {
+ { 0, GetStandardUserSystemClock },
+ { 1, GetStandardNetworkSystemClock },
+ { 2, GetStandardSteadyClock },
+ { 3, GetTimeZoneService },
+ { 4, GetStandardLocalSystemClock }
+ };
+ }
+
+ public long GetStandardUserSystemClock(ServiceCtx Context)
+ {
+ MakeObject(Context, new ISystemClock(SystemClockType.User));
+
+ return 0;
+ }
+
+ public long GetStandardNetworkSystemClock(ServiceCtx Context)
+ {
+ MakeObject(Context, new ISystemClock(SystemClockType.Network));
+
+ return 0;
+ }
+
+ public long GetStandardSteadyClock(ServiceCtx Context)
+ {
+ MakeObject(Context, new ISteadyClock());
+
+ return 0;
+ }
+
+ public long GetTimeZoneService(ServiceCtx Context)
+ {
+ MakeObject(Context, new ITimeZoneService());
+
+ return 0;
+ }
+
+ public long GetStandardLocalSystemClock(ServiceCtx Context)
+ {
+ MakeObject(Context, new ISystemClock(SystemClockType.Local));
+
+ return 0;
+ }
+
+ }
+} \ No newline at end of file
diff --git a/Ryujinx.HLE/OsHle/Services/Time/ISteadyClock.cs b/Ryujinx.HLE/OsHle/Services/Time/ISteadyClock.cs
new file mode 100644
index 00000000..6be097b7
--- /dev/null
+++ b/Ryujinx.HLE/OsHle/Services/Time/ISteadyClock.cs
@@ -0,0 +1,20 @@
+using Ryujinx.HLE.OsHle.Ipc;
+using System.Collections.Generic;
+
+namespace Ryujinx.HLE.OsHle.Services.Time
+{
+ class ISteadyClock : IpcService
+ {
+ private Dictionary<int, ServiceProcessRequest> m_Commands;
+
+ public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => m_Commands;
+
+ public ISteadyClock()
+ {
+ m_Commands = new Dictionary<int, ServiceProcessRequest>()
+ {
+ //...
+ };
+ }
+ }
+} \ No newline at end of file
diff --git a/Ryujinx.HLE/OsHle/Services/Time/ISystemClock.cs b/Ryujinx.HLE/OsHle/Services/Time/ISystemClock.cs
new file mode 100644
index 00000000..787f86c2
--- /dev/null
+++ b/Ryujinx.HLE/OsHle/Services/Time/ISystemClock.cs
@@ -0,0 +1,42 @@
+using Ryujinx.HLE.OsHle.Ipc;
+using System;
+using System.Collections.Generic;
+
+namespace Ryujinx.HLE.OsHle.Services.Time
+{
+ class ISystemClock : IpcService
+ {
+ private Dictionary<int, ServiceProcessRequest> m_Commands;
+
+ public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => m_Commands;
+
+ private static readonly DateTime Epoch = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
+
+ private SystemClockType ClockType;
+
+ public ISystemClock(SystemClockType ClockType)
+ {
+ m_Commands = new Dictionary<int, ServiceProcessRequest>()
+ {
+ { 0, GetCurrentTime }
+ };
+
+ this.ClockType = ClockType;
+ }
+
+ public long GetCurrentTime(ServiceCtx Context)
+ {
+ DateTime CurrentTime = DateTime.Now;
+
+ if (ClockType == SystemClockType.User ||
+ ClockType == SystemClockType.Network)
+ {
+ CurrentTime = CurrentTime.ToUniversalTime();
+ }
+
+ Context.ResponseData.Write((long)(DateTime.Now - Epoch).TotalSeconds);
+
+ return 0;
+ }
+ }
+} \ No newline at end of file
diff --git a/Ryujinx.HLE/OsHle/Services/Time/ITimeZoneService.cs b/Ryujinx.HLE/OsHle/Services/Time/ITimeZoneService.cs
new file mode 100644
index 00000000..39454d43
--- /dev/null
+++ b/Ryujinx.HLE/OsHle/Services/Time/ITimeZoneService.cs
@@ -0,0 +1,76 @@
+using Ryujinx.HLE.Logging;
+using Ryujinx.HLE.OsHle.Ipc;
+using System;
+using System.Collections.Generic;
+
+namespace Ryujinx.HLE.OsHle.Services.Time
+{
+ class ITimeZoneService : IpcService
+ {
+ private Dictionary<int, ServiceProcessRequest> m_Commands;
+
+ public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => m_Commands;
+
+ private static readonly DateTime Epoch = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
+
+ public ITimeZoneService()
+ {
+ m_Commands = new Dictionary<int, ServiceProcessRequest>()
+ {
+ { 0, GetDeviceLocationName },
+ { 101, ToCalendarTimeWithMyRule }
+ };
+ }
+
+ public long GetDeviceLocationName(ServiceCtx Context)
+ {
+ Context.Ns.Log.PrintStub(LogClass.ServiceTime, "Stubbed.");
+
+ for (int Index = 0; Index < 0x24; Index++)
+ {
+ Context.ResponseData.Write((byte)0);
+ }
+
+ return 0;
+ }
+
+ public long ToCalendarTimeWithMyRule(ServiceCtx Context)
+ {
+ long PosixTime = Context.RequestData.ReadInt64();
+
+ DateTime CurrentTime = Epoch.AddSeconds(PosixTime).ToLocalTime();
+
+ Context.ResponseData.Write((ushort)CurrentTime.Year);
+ Context.ResponseData.Write((byte)CurrentTime.Month);
+ Context.ResponseData.Write((byte)CurrentTime.Day);
+ Context.ResponseData.Write((byte)CurrentTime.Hour);
+ Context.ResponseData.Write((byte)CurrentTime.Minute);
+ Context.ResponseData.Write((byte)CurrentTime.Second);
+ Context.ResponseData.Write((byte)0);
+
+ /* Thanks to TuxSH
+ struct CalendarAdditionalInfo {
+ u32 tm_wday; //day of week [0,6] (Sunday = 0)
+ s32 tm_yday; //day of year [0,365]
+ struct timezone {
+ char[8] tz_name;
+ bool isDaylightSavingTime;
+ s32 utcOffsetSeconds;
+ };
+ };
+ */
+ Context.ResponseData.Write((int)CurrentTime.DayOfWeek);
+
+ Context.ResponseData.Write(CurrentTime.DayOfYear - 1);
+
+ //TODO: Find out the names used.
+ Context.ResponseData.Write(new byte[8]);
+
+ Context.ResponseData.Write((byte)(CurrentTime.IsDaylightSavingTime() ? 1 : 0));
+
+ Context.ResponseData.Write((int)TimeZoneInfo.Local.GetUtcOffset(CurrentTime).TotalSeconds);
+
+ return 0;
+ }
+ }
+} \ No newline at end of file
diff --git a/Ryujinx.HLE/OsHle/Services/Time/SystemClockType.cs b/Ryujinx.HLE/OsHle/Services/Time/SystemClockType.cs
new file mode 100644
index 00000000..518e1eb0
--- /dev/null
+++ b/Ryujinx.HLE/OsHle/Services/Time/SystemClockType.cs
@@ -0,0 +1,9 @@
+namespace Ryujinx.HLE.OsHle.Services.Time
+{
+ enum SystemClockType
+ {
+ User,
+ Network,
+ Local
+ }
+} \ No newline at end of file