Address comments
This commit is contained in:
parent
792a0b3e6d
commit
7efb073ac9
4 changed files with 338 additions and 330 deletions
|
@ -61,6 +61,7 @@ namespace Ryujinx.HLE.HOS.Services.Time
|
||||||
public long SetDeviceLocationName(ServiceCtx context)
|
public long SetDeviceLocationName(ServiceCtx context)
|
||||||
{
|
{
|
||||||
string locationName = Encoding.ASCII.GetString(context.RequestData.ReadBytes(0x24)).TrimEnd('\0');
|
string locationName = Encoding.ASCII.GetString(context.RequestData.ReadBytes(0x24)).TrimEnd('\0');
|
||||||
|
|
||||||
return TimeZoneManager.Instance.SetDeviceLocationName(locationName);
|
return TimeZoneManager.Instance.SetDeviceLocationName(locationName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -97,6 +98,7 @@ namespace Ryujinx.HLE.HOS.Services.Time
|
||||||
|
|
||||||
context.Memory.WriteBytes(bufferPosition + offset, Encoding.ASCII.GetBytes(locationName));
|
context.Memory.WriteBytes(bufferPosition + offset, Encoding.ASCII.GetBytes(locationName));
|
||||||
MemoryHelper.FillWithZeros(context.Memory, bufferPosition + offset + locationName.Length, padding);
|
MemoryHelper.FillWithZeros(context.Memory, bufferPosition + offset + locationName.Length, padding);
|
||||||
|
|
||||||
offset += 0x24;
|
offset += 0x24;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -116,6 +118,7 @@ namespace Ryujinx.HLE.HOS.Services.Time
|
||||||
{
|
{
|
||||||
// TODO: find error code here
|
// TODO: find error code here
|
||||||
Logger.PrintError(LogClass.ServiceTime, $"TimeZoneRule buffer size is 0x{bufferSize:x} (expected 0x4000)");
|
Logger.PrintError(LogClass.ServiceTime, $"TimeZoneRule buffer size is 0x{bufferSize:x} (expected 0x4000)");
|
||||||
|
|
||||||
throw new InvalidOperationException();
|
throw new InvalidOperationException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -144,6 +147,7 @@ namespace Ryujinx.HLE.HOS.Services.Time
|
||||||
{
|
{
|
||||||
// TODO: find error code here
|
// TODO: find error code here
|
||||||
Logger.PrintError(LogClass.ServiceTime, $"TimeZoneRule buffer size is 0x{bufferSize:x} (expected 0x4000)");
|
Logger.PrintError(LogClass.ServiceTime, $"TimeZoneRule buffer size is 0x{bufferSize:x} (expected 0x4000)");
|
||||||
|
|
||||||
throw new InvalidOperationException();
|
throw new InvalidOperationException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -186,6 +190,7 @@ namespace Ryujinx.HLE.HOS.Services.Time
|
||||||
{
|
{
|
||||||
// TODO: find error code here
|
// TODO: find error code here
|
||||||
Logger.PrintError(LogClass.ServiceTime, $"TimeZoneRule buffer size is 0x{inBufferSize:x} (expected 0x4000)");
|
Logger.PrintError(LogClass.ServiceTime, $"TimeZoneRule buffer size is 0x{inBufferSize:x} (expected 0x4000)");
|
||||||
|
|
||||||
throw new InvalidOperationException();
|
throw new InvalidOperationException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -218,6 +223,8 @@ namespace Ryujinx.HLE.HOS.Services.Time
|
||||||
long outBufferSize = context.Request.RecvListBuff[0].Size;
|
long outBufferSize = context.Request.RecvListBuff[0].Size;
|
||||||
|
|
||||||
context.Memory.WriteInt64(outBufferPosition, posixTime);
|
context.Memory.WriteInt64(outBufferPosition, posixTime);
|
||||||
|
|
||||||
|
// There could be only one result on one calendar as leap seconds aren't supported.
|
||||||
context.ResponseData.Write(1);
|
context.ResponseData.Write(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,24 +5,24 @@ namespace Ryujinx.HLE.HOS.Services.Time
|
||||||
[StructLayout(LayoutKind.Sequential, Size = 0x10, Pack = 4)]
|
[StructLayout(LayoutKind.Sequential, Size = 0x10, Pack = 4)]
|
||||||
public struct TimeTypeInfo
|
public struct TimeTypeInfo
|
||||||
{
|
{
|
||||||
public int gmtOffset;
|
public int GmtOffset;
|
||||||
|
|
||||||
[MarshalAs(UnmanagedType.I1)]
|
[MarshalAs(UnmanagedType.I1)]
|
||||||
public bool isDaySavingTime;
|
public bool IsDaySavingTime;
|
||||||
|
|
||||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)]
|
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)]
|
||||||
char[] padding1;
|
char[] Padding1;
|
||||||
|
|
||||||
public int abbreviationListIndex;
|
public int AbbreviationListIndex;
|
||||||
|
|
||||||
[MarshalAs(UnmanagedType.I1)]
|
[MarshalAs(UnmanagedType.I1)]
|
||||||
public bool isStandardTimeDaylight;
|
public bool IsStandardTimeDaylight;
|
||||||
|
|
||||||
[MarshalAs(UnmanagedType.I1)]
|
[MarshalAs(UnmanagedType.I1)]
|
||||||
public bool isGMT;
|
public bool IsGMT;
|
||||||
|
|
||||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 2)]
|
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 2)]
|
||||||
char[] padding2;
|
char[] Padding2;
|
||||||
}
|
}
|
||||||
|
|
||||||
[StructLayout(LayoutKind.Sequential, Pack = 4, Size = 0x4000, CharSet = CharSet.Ansi)]
|
[StructLayout(LayoutKind.Sequential, Pack = 4, Size = 0x4000, CharSet = CharSet.Ansi)]
|
||||||
|
@ -35,94 +35,94 @@ namespace Ryujinx.HLE.HOS.Services.Time
|
||||||
public const int TzNameMax = 255;
|
public const int TzNameMax = 255;
|
||||||
public const int TzCharsArraySize = 2 * (TzNameMax + 1);
|
public const int TzCharsArraySize = 2 * (TzNameMax + 1);
|
||||||
|
|
||||||
public int timeCount;
|
public int TimeCount;
|
||||||
public int typeCount;
|
public int TypeCount;
|
||||||
public int charCount;
|
public int CharCount;
|
||||||
|
|
||||||
[MarshalAs(UnmanagedType.I1)]
|
[MarshalAs(UnmanagedType.I1)]
|
||||||
public bool goBack;
|
public bool GoBack;
|
||||||
|
|
||||||
[MarshalAs(UnmanagedType.I1)]
|
[MarshalAs(UnmanagedType.I1)]
|
||||||
public bool goAhead;
|
public bool GoAhead;
|
||||||
|
|
||||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = TzMaxTimes)]
|
[MarshalAs(UnmanagedType.ByValArray, SizeConst = TzMaxTimes)]
|
||||||
public long[] ats;
|
public long[] Ats;
|
||||||
|
|
||||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = TzMaxTimes)]
|
[MarshalAs(UnmanagedType.ByValArray, SizeConst = TzMaxTimes)]
|
||||||
public byte[] types;
|
public byte[] Types;
|
||||||
|
|
||||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = TzMaxTypes)]
|
[MarshalAs(UnmanagedType.ByValArray, SizeConst = TzMaxTypes)]
|
||||||
public TimeTypeInfo[] ttis;
|
public TimeTypeInfo[] Ttis;
|
||||||
|
|
||||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = TzCharsArraySize)]
|
[MarshalAs(UnmanagedType.ByValArray, SizeConst = TzCharsArraySize)]
|
||||||
public char[] chars;
|
public char[] Chars;
|
||||||
|
|
||||||
public int defaultType;
|
public int DefaultType;
|
||||||
}
|
}
|
||||||
|
|
||||||
[StructLayout(LayoutKind.Sequential, Pack = 0x4, Size = 0x2C)]
|
[StructLayout(LayoutKind.Sequential, Pack = 0x4, Size = 0x2C)]
|
||||||
public struct TzifHeader
|
public struct TzifHeader
|
||||||
{
|
{
|
||||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)]
|
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)]
|
||||||
public char[] magic;
|
public char[] Magic;
|
||||||
|
|
||||||
public char version;
|
public char Version;
|
||||||
|
|
||||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 15)]
|
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 15)]
|
||||||
public byte[] reserved;
|
public byte[] Reserved;
|
||||||
|
|
||||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)]
|
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)]
|
||||||
public byte[] ttisGMTCount;
|
public byte[] TtisGMTCount;
|
||||||
|
|
||||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)]
|
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)]
|
||||||
public byte[] ttisSTDCount;
|
public byte[] TtisSTDCount;
|
||||||
|
|
||||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)]
|
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)]
|
||||||
public byte[] leapCount;
|
public byte[] LeapCount;
|
||||||
|
|
||||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)]
|
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)]
|
||||||
public byte[] timeCount;
|
public byte[] TimeCount;
|
||||||
|
|
||||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)]
|
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)]
|
||||||
public byte[] typeCount;
|
public byte[] TypeCount;
|
||||||
|
|
||||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)]
|
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)]
|
||||||
public byte[] charCount;
|
public byte[] CharCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
[StructLayout(LayoutKind.Sequential, Pack = 0x4, Size = 0x8)]
|
[StructLayout(LayoutKind.Sequential, Pack = 0x4, Size = 0x8)]
|
||||||
public struct CalendarTime
|
public struct CalendarTime
|
||||||
{
|
{
|
||||||
public short year;
|
public short Year;
|
||||||
public sbyte month;
|
public sbyte Month;
|
||||||
public sbyte day;
|
public sbyte Day;
|
||||||
public sbyte hour;
|
public sbyte Hour;
|
||||||
public sbyte minute;
|
public sbyte Minute;
|
||||||
public sbyte second;
|
public sbyte Second;
|
||||||
}
|
}
|
||||||
|
|
||||||
[StructLayout(LayoutKind.Sequential, Pack = 0x4, Size = 0x18, CharSet = CharSet.Ansi)]
|
[StructLayout(LayoutKind.Sequential, Pack = 0x4, Size = 0x18, CharSet = CharSet.Ansi)]
|
||||||
public struct CalendarAdditionalInfo
|
public struct CalendarAdditionalInfo
|
||||||
{
|
{
|
||||||
public uint dayOfWeek;
|
public uint DayOfWeek;
|
||||||
public uint dayOfYear;
|
public uint DayOfYear;
|
||||||
|
|
||||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)]
|
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)]
|
||||||
public char[] timezoneName;
|
public char[] TimezoneName;
|
||||||
|
|
||||||
[MarshalAs(UnmanagedType.I1)]
|
[MarshalAs(UnmanagedType.I1)]
|
||||||
public bool isDaySavingTime;
|
public bool IsDaySavingTime;
|
||||||
|
|
||||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)]
|
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)]
|
||||||
char[] padding;
|
char[] Padding;
|
||||||
|
|
||||||
public int gmtOffset;
|
public int GmtOffset;
|
||||||
}
|
}
|
||||||
|
|
||||||
[StructLayout(LayoutKind.Sequential, Pack = 0x4, Size = 0x20, CharSet = CharSet.Ansi)]
|
[StructLayout(LayoutKind.Sequential, Pack = 0x4, Size = 0x20, CharSet = CharSet.Ansi)]
|
||||||
public struct CalendarInfo
|
public struct CalendarInfo
|
||||||
{
|
{
|
||||||
public CalendarTime time;
|
public CalendarTime Time;
|
||||||
public CalendarAdditionalInfo additionalInfo;
|
public CalendarAdditionalInfo AdditionalInfo;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -18,11 +18,10 @@ namespace Ryujinx.HLE.HOS.Services.Time.TimeZone
|
||||||
{
|
{
|
||||||
private const long TimeZoneBinaryTitleId = 0x010000000000080E;
|
private const long TimeZoneBinaryTitleId = 0x010000000000080E;
|
||||||
|
|
||||||
private static TimeZoneManager instance = null;
|
private static TimeZoneManager instance;
|
||||||
|
|
||||||
private static object instanceLock = new object();
|
private static object instanceLock = new object();
|
||||||
|
|
||||||
|
|
||||||
private Switch _device;
|
private Switch _device;
|
||||||
private TimeZoneRule _myRules;
|
private TimeZoneRule _myRules;
|
||||||
private string _deviceLocationName;
|
private string _deviceLocationName;
|
||||||
|
@ -35,10 +34,10 @@ namespace Ryujinx.HLE.HOS.Services.Time.TimeZone
|
||||||
// Empty rules (UTC)
|
// Empty rules (UTC)
|
||||||
_myRules = new TimeZoneRule
|
_myRules = new TimeZoneRule
|
||||||
{
|
{
|
||||||
ats = new long[TzMaxTimes],
|
Ats = new long[TzMaxTimes],
|
||||||
types = new byte[TzMaxTimes],
|
Types = new byte[TzMaxTimes],
|
||||||
ttis = new TimeTypeInfo[TzMaxTypes],
|
Ttis = new TimeTypeInfo[TzMaxTypes],
|
||||||
chars = new char[TzCharsArraySize]
|
Chars = new char[TzCharsArraySize]
|
||||||
};
|
};
|
||||||
|
|
||||||
_deviceLocationName = "UTC";
|
_deviceLocationName = "UTC";
|
||||||
|
@ -155,6 +154,7 @@ namespace Ryujinx.HLE.HOS.Services.Time.TimeZone
|
||||||
if (locationName.Length > 0x24)
|
if (locationName.Length > 0x24)
|
||||||
{
|
{
|
||||||
outLocationNameArray = new string[0];
|
outLocationNameArray = new string[0];
|
||||||
|
|
||||||
return MakeError(ErrorModule.Time, TimeError.LocationNameTooLong);
|
return MakeError(ErrorModule.Time, TimeError.LocationNameTooLong);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -162,6 +162,7 @@ namespace Ryujinx.HLE.HOS.Services.Time.TimeZone
|
||||||
}
|
}
|
||||||
|
|
||||||
outLocationNameArray = locationNameList.ToArray();
|
outLocationNameArray = locationNameList.ToArray();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -184,10 +185,10 @@ namespace Ryujinx.HLE.HOS.Services.Time.TimeZone
|
||||||
{
|
{
|
||||||
outRules = new TimeZoneRule
|
outRules = new TimeZoneRule
|
||||||
{
|
{
|
||||||
ats = new long[TzMaxTimes],
|
Ats = new long[TzMaxTimes],
|
||||||
types = new byte[TzMaxTimes],
|
Types = new byte[TzMaxTimes],
|
||||||
ttis = new TimeTypeInfo[TzMaxTypes],
|
Ttis = new TimeTypeInfo[TzMaxTypes],
|
||||||
chars = new char[TzCharsArraySize]
|
Chars = new char[TzCharsArraySize]
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!IsLocationNameValid(locationName))
|
if (!IsLocationNameValid(locationName))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue