aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgdkchan <gab.dark.100@gmail.com>2024-07-22 12:46:04 -0300
committerGitHub <noreply@github.com>2024-07-22 12:46:04 -0300
commit95d252b7b8d9940be032e6f4e37fba37b2fb9aad (patch)
tree06684d58995365a5b3f35e4cf4989c6e2127145d
parentadd681144bd1ab8eb5094f38ec71292a33958aff (diff)
Update kernel GetInfo SVC for firmware 18.0.0 (#7075)1.1.1359
* Implement kernel GetInfo AliasRegionExtraSize * Implement IsSvcPermitted * Remove warning supressions that are no longer needed * Remove useless cast
-rw-r--r--src/Ryujinx.HLE/HOS/Kernel/Memory/AddressSpaceType.cs10
-rw-r--r--src/Ryujinx.HLE/HOS/Kernel/Memory/KPageTableBase.cs66
-rw-r--r--src/Ryujinx.HLE/HOS/Kernel/Process/KProcess.cs29
-rw-r--r--src/Ryujinx.HLE/HOS/Kernel/Process/KProcessCapabilities.cs14
-rw-r--r--src/Ryujinx.HLE/HOS/Kernel/Process/ProcessCreationFlags.cs6
-rw-r--r--src/Ryujinx.HLE/HOS/Kernel/SupervisorCall/InfoType.cs7
-rw-r--r--src/Ryujinx.HLE/HOS/Kernel/SupervisorCall/Syscall.cs144
7 files changed, 109 insertions, 167 deletions
diff --git a/src/Ryujinx.HLE/HOS/Kernel/Memory/AddressSpaceType.cs b/src/Ryujinx.HLE/HOS/Kernel/Memory/AddressSpaceType.cs
deleted file mode 100644
index 8dfa4303f..000000000
--- a/src/Ryujinx.HLE/HOS/Kernel/Memory/AddressSpaceType.cs
+++ /dev/null
@@ -1,10 +0,0 @@
1namespace Ryujinx.HLE.HOS.Kernel.Memory
2{
3 enum AddressSpaceType
4 {
5 Addr32Bits = 0,
6 Addr36Bits = 1,
7 Addr32BitsNoMap = 2,
8 Addr39Bits = 3,
9 }
10}
diff --git a/src/Ryujinx.HLE/HOS/Kernel/Memory/KPageTableBase.cs b/src/Ryujinx.HLE/HOS/Kernel/Memory/KPageTableBase.cs
index 58bbc0dbf..bf2bbb97b 100644
--- a/src/Ryujinx.HLE/HOS/Kernel/Memory/KPageTableBase.cs
+++ b/src/Ryujinx.HLE/HOS/Kernel/Memory/KPageTableBase.cs
@@ -58,11 +58,10 @@ namespace Ryujinx.HLE.HOS.Kernel.Memory
58 public ulong AslrRegionStart { get; private set; } 58 public ulong AslrRegionStart { get; private set; }
59 public ulong AslrRegionEnd { get; private set; } 59 public ulong AslrRegionEnd { get; private set; }
60 60
61#pragma warning disable IDE0052 // Remove unread private member
62 private ulong _heapCapacity; 61 private ulong _heapCapacity;
63#pragma warning restore IDE0052
64 62
65 public ulong PhysicalMemoryUsage { get; private set; } 63 public ulong PhysicalMemoryUsage { get; private set; }
64 public ulong AliasRegionExtraSize { get; private set; }
66 65
67 private readonly KMemoryBlockManager _blockManager; 66 private readonly KMemoryBlockManager _blockManager;
68 67
@@ -98,30 +97,21 @@ namespace Ryujinx.HLE.HOS.Kernel.Memory
98 _reservedAddressSpaceSize = reservedAddressSpaceSize; 97 _reservedAddressSpaceSize = reservedAddressSpaceSize;
99 } 98 }
100 99
101 private static readonly int[] _addrSpaceSizes = { 32, 36, 32, 39 };
102
103 public Result InitializeForProcess( 100 public Result InitializeForProcess(
104 AddressSpaceType addrSpaceType, 101 ProcessCreationFlags flags,
105 bool aslrEnabled,
106 bool fromBack, 102 bool fromBack,
107 MemoryRegion memRegion, 103 MemoryRegion memRegion,
108 ulong address, 104 ulong address,
109 ulong size, 105 ulong size,
110 KMemoryBlockSlabManager slabManager) 106 KMemoryBlockSlabManager slabManager)
111 { 107 {
112 if ((uint)addrSpaceType > (uint)AddressSpaceType.Addr39Bits)
113 {
114 throw new ArgumentException($"AddressSpaceType bigger than {(uint)AddressSpaceType.Addr39Bits}: {(uint)addrSpaceType}", nameof(addrSpaceType));
115 }
116
117 _contextId = Context.ContextIdManager.GetId(); 108 _contextId = Context.ContextIdManager.GetId();
118 109
119 ulong addrSpaceBase = 0; 110 ulong addrSpaceBase = 0;
120 ulong addrSpaceSize = 1UL << _addrSpaceSizes[(int)addrSpaceType]; 111 ulong addrSpaceSize = 1UL << GetAddressSpaceWidth(flags);
121 112
122 Result result = CreateUserAddressSpace( 113 Result result = CreateUserAddressSpace(
123 addrSpaceType, 114 flags,
124 aslrEnabled,
125 fromBack, 115 fromBack,
126 addrSpaceBase, 116 addrSpaceBase,
127 addrSpaceSize, 117 addrSpaceSize,
@@ -138,6 +128,22 @@ namespace Ryujinx.HLE.HOS.Kernel.Memory
138 return result; 128 return result;
139 } 129 }
140 130
131 private static int GetAddressSpaceWidth(ProcessCreationFlags flags)
132 {
133 switch (flags & ProcessCreationFlags.AddressSpaceMask)
134 {
135 case ProcessCreationFlags.AddressSpace32Bit:
136 case ProcessCreationFlags.AddressSpace32BitWithoutAlias:
137 return 32;
138 case ProcessCreationFlags.AddressSpace64BitDeprecated:
139 return 36;
140 case ProcessCreationFlags.AddressSpace64Bit:
141 return 39;
142 }
143
144 throw new ArgumentException($"Invalid process flags {flags}", nameof(flags));
145 }
146
141 private struct Region 147 private struct Region
142 { 148 {
143 public ulong Start; 149 public ulong Start;
@@ -147,8 +153,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Memory
147 } 153 }
148 154
149 private Result CreateUserAddressSpace( 155 private Result CreateUserAddressSpace(
150 AddressSpaceType addrSpaceType, 156 ProcessCreationFlags flags,
151 bool aslrEnabled,
152 bool fromBack, 157 bool fromBack,
153 ulong addrSpaceStart, 158 ulong addrSpaceStart,
154 ulong addrSpaceEnd, 159 ulong addrSpaceEnd,
@@ -168,9 +173,11 @@ namespace Ryujinx.HLE.HOS.Kernel.Memory
168 ulong stackAndTlsIoStart; 173 ulong stackAndTlsIoStart;
169 ulong stackAndTlsIoEnd; 174 ulong stackAndTlsIoEnd;
170 175
171 switch (addrSpaceType) 176 AliasRegionExtraSize = 0;
177
178 switch (flags & ProcessCreationFlags.AddressSpaceMask)
172 { 179 {
173 case AddressSpaceType.Addr32Bits: 180 case ProcessCreationFlags.AddressSpace32Bit:
174 aliasRegion.Size = 0x40000000; 181 aliasRegion.Size = 0x40000000;
175 heapRegion.Size = 0x40000000; 182 heapRegion.Size = 0x40000000;
176 stackRegion.Size = 0; 183 stackRegion.Size = 0;
@@ -183,7 +190,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Memory
183 stackAndTlsIoEnd = 0x40000000; 190 stackAndTlsIoEnd = 0x40000000;
184 break; 191 break;
185 192
186 case AddressSpaceType.Addr36Bits: 193 case ProcessCreationFlags.AddressSpace64BitDeprecated:
187 aliasRegion.Size = 0x180000000; 194 aliasRegion.Size = 0x180000000;
188 heapRegion.Size = 0x180000000; 195 heapRegion.Size = 0x180000000;
189 stackRegion.Size = 0; 196 stackRegion.Size = 0;
@@ -196,7 +203,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Memory
196 stackAndTlsIoEnd = 0x80000000; 203 stackAndTlsIoEnd = 0x80000000;
197 break; 204 break;
198 205
199 case AddressSpaceType.Addr32BitsNoMap: 206 case ProcessCreationFlags.AddressSpace32BitWithoutAlias:
200 aliasRegion.Size = 0; 207 aliasRegion.Size = 0;
201 heapRegion.Size = 0x80000000; 208 heapRegion.Size = 0x80000000;
202 stackRegion.Size = 0; 209 stackRegion.Size = 0;
@@ -209,7 +216,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Memory
209 stackAndTlsIoEnd = 0x40000000; 216 stackAndTlsIoEnd = 0x40000000;
210 break; 217 break;
211 218
212 case AddressSpaceType.Addr39Bits: 219 case ProcessCreationFlags.AddressSpace64Bit:
213 if (_reservedAddressSpaceSize < addrSpaceEnd) 220 if (_reservedAddressSpaceSize < addrSpaceEnd)
214 { 221 {
215 int addressSpaceWidth = (int)ulong.Log2(_reservedAddressSpaceSize); 222 int addressSpaceWidth = (int)ulong.Log2(_reservedAddressSpaceSize);
@@ -218,8 +225,8 @@ namespace Ryujinx.HLE.HOS.Kernel.Memory
218 heapRegion.Size = 0x180000000; 225 heapRegion.Size = 0x180000000;
219 stackRegion.Size = 1UL << (addressSpaceWidth - 8); 226 stackRegion.Size = 1UL << (addressSpaceWidth - 8);
220 tlsIoRegion.Size = 1UL << (addressSpaceWidth - 3); 227 tlsIoRegion.Size = 1UL << (addressSpaceWidth - 3);
221 CodeRegionStart = BitUtils.AlignDown<ulong>(address, RegionAlignment); 228 CodeRegionStart = BitUtils.AlignDown(address, RegionAlignment);
222 codeRegionSize = BitUtils.AlignUp<ulong>(endAddr, RegionAlignment) - CodeRegionStart; 229 codeRegionSize = BitUtils.AlignUp(endAddr, RegionAlignment) - CodeRegionStart;
223 stackAndTlsIoStart = 0; 230 stackAndTlsIoStart = 0;
224 stackAndTlsIoEnd = 0; 231 stackAndTlsIoEnd = 0;
225 AslrRegionStart = 0x8000000; 232 AslrRegionStart = 0x8000000;
@@ -239,9 +246,16 @@ namespace Ryujinx.HLE.HOS.Kernel.Memory
239 stackAndTlsIoStart = 0; 246 stackAndTlsIoStart = 0;
240 stackAndTlsIoEnd = 0; 247 stackAndTlsIoEnd = 0;
241 } 248 }
249
250 if (flags.HasFlag(ProcessCreationFlags.EnableAliasRegionExtraSize))
251 {
252 AliasRegionExtraSize = addrSpaceEnd / 8;
253 aliasRegion.Size += AliasRegionExtraSize;
254 }
242 break; 255 break;
256
243 default: 257 default:
244 throw new ArgumentException($"AddressSpaceType bigger than {(uint)AddressSpaceType.Addr39Bits}: {(uint)addrSpaceType}", nameof(addrSpaceType)); 258 throw new ArgumentException($"Invalid process flags {flags}", nameof(flags));
245 } 259 }
246 260
247 CodeRegionEnd = CodeRegionStart + codeRegionSize; 261 CodeRegionEnd = CodeRegionStart + codeRegionSize;
@@ -266,6 +280,8 @@ namespace Ryujinx.HLE.HOS.Kernel.Memory
266 280
267 ulong aslrMaxOffset = mapAvailableSize - mapTotalSize; 281 ulong aslrMaxOffset = mapAvailableSize - mapTotalSize;
268 282
283 bool aslrEnabled = flags.HasFlag(ProcessCreationFlags.EnableAslr);
284
269 _aslrEnabled = aslrEnabled; 285 _aslrEnabled = aslrEnabled;
270 286
271 AddrSpaceStart = addrSpaceStart; 287 AddrSpaceStart = addrSpaceStart;
@@ -725,7 +741,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Memory
725 { 741 {
726 address = 0; 742 address = 0;
727 743
728 if (size > HeapRegionEnd - HeapRegionStart) 744 if (size > HeapRegionEnd - HeapRegionStart || size > _heapCapacity)
729 { 745 {
730 return KernelResult.OutOfMemory; 746 return KernelResult.OutOfMemory;
731 } 747 }
diff --git a/src/Ryujinx.HLE/HOS/Kernel/Process/KProcess.cs b/src/Ryujinx.HLE/HOS/Kernel/Process/KProcess.cs
index 6008548be..422f03c64 100644
--- a/src/Ryujinx.HLE/HOS/Kernel/Process/KProcess.cs
+++ b/src/Ryujinx.HLE/HOS/Kernel/Process/KProcess.cs
@@ -126,8 +126,6 @@ namespace Ryujinx.HLE.HOS.Kernel.Process
126 _contextFactory = contextFactory ?? new ProcessContextFactory(); 126 _contextFactory = contextFactory ?? new ProcessContextFactory();
127 _customThreadStart = customThreadStart; 127 _customThreadStart = customThreadStart;
128 128
129 AddressSpaceType addrSpaceType = (AddressSpaceType)((int)(creationInfo.Flags & ProcessCreationFlags.AddressSpaceMask) >> (int)ProcessCreationFlags.AddressSpaceShift);
130
131 Pid = KernelContext.NewKipId(); 129 Pid = KernelContext.NewKipId();
132 130
133 if (Pid == 0 || Pid >= KernelConstants.InitialProcessId) 131 if (Pid == 0 || Pid >= KernelConstants.InitialProcessId)
@@ -137,8 +135,6 @@ namespace Ryujinx.HLE.HOS.Kernel.Process
137 135
138 InitializeMemoryManager(creationInfo.Flags); 136 InitializeMemoryManager(creationInfo.Flags);
139 137
140 bool aslrEnabled = creationInfo.Flags.HasFlag(ProcessCreationFlags.EnableAslr);
141
142 ulong codeAddress = creationInfo.CodeAddress; 138 ulong codeAddress = creationInfo.CodeAddress;
143 139
144 ulong codeSize = (ulong)creationInfo.CodePagesCount * KPageTableBase.PageSize; 140 ulong codeSize = (ulong)creationInfo.CodePagesCount * KPageTableBase.PageSize;
@@ -148,9 +144,8 @@ namespace Ryujinx.HLE.HOS.Kernel.Process
148 : KernelContext.SmallMemoryBlockSlabManager; 144 : KernelContext.SmallMemoryBlockSlabManager;
149 145
150 Result result = MemoryManager.InitializeForProcess( 146 Result result = MemoryManager.InitializeForProcess(
151 addrSpaceType, 147 creationInfo.Flags,
152 aslrEnabled, 148 !creationInfo.Flags.HasFlag(ProcessCreationFlags.EnableAslr),
153 !aslrEnabled,
154 memRegion, 149 memRegion,
155 codeAddress, 150 codeAddress,
156 codeSize, 151 codeSize,
@@ -234,8 +229,6 @@ namespace Ryujinx.HLE.HOS.Kernel.Process
234 : KernelContext.SmallMemoryBlockSlabManager; 229 : KernelContext.SmallMemoryBlockSlabManager;
235 } 230 }
236 231
237 AddressSpaceType addrSpaceType = (AddressSpaceType)((int)(creationInfo.Flags & ProcessCreationFlags.AddressSpaceMask) >> (int)ProcessCreationFlags.AddressSpaceShift);
238
239 Pid = KernelContext.NewProcessId(); 232 Pid = KernelContext.NewProcessId();
240 233
241 if (Pid == ulong.MaxValue || Pid < KernelConstants.InitialProcessId) 234 if (Pid == ulong.MaxValue || Pid < KernelConstants.InitialProcessId)
@@ -245,16 +238,13 @@ namespace Ryujinx.HLE.HOS.Kernel.Process
245 238
246 InitializeMemoryManager(creationInfo.Flags); 239 InitializeMemoryManager(creationInfo.Flags);
247 240
248 bool aslrEnabled = creationInfo.Flags.HasFlag(ProcessCreationFlags.EnableAslr);
249
250 ulong codeAddress = creationInfo.CodeAddress; 241 ulong codeAddress = creationInfo.CodeAddress;
251 242
252 ulong codeSize = codePagesCount * KPageTableBase.PageSize; 243 ulong codeSize = codePagesCount * KPageTableBase.PageSize;
253 244
254 Result result = MemoryManager.InitializeForProcess( 245 Result result = MemoryManager.InitializeForProcess(
255 addrSpaceType, 246 creationInfo.Flags,
256 aslrEnabled, 247 !creationInfo.Flags.HasFlag(ProcessCreationFlags.EnableAslr),
257 !aslrEnabled,
258 memRegion, 248 memRegion,
259 codeAddress, 249 codeAddress,
260 codeSize, 250 codeSize,
@@ -309,8 +299,8 @@ namespace Ryujinx.HLE.HOS.Kernel.Process
309 private Result ParseProcessInfo(ProcessCreationInfo creationInfo) 299 private Result ParseProcessInfo(ProcessCreationInfo creationInfo)
310 { 300 {
311 // Ensure that the current kernel version is equal or above to the minimum required. 301 // Ensure that the current kernel version is equal or above to the minimum required.
312 uint requiredKernelVersionMajor = (uint)Capabilities.KernelReleaseVersion >> 19; 302 uint requiredKernelVersionMajor = Capabilities.KernelReleaseVersion >> 19;
313 uint requiredKernelVersionMinor = ((uint)Capabilities.KernelReleaseVersion >> 15) & 0xf; 303 uint requiredKernelVersionMinor = (Capabilities.KernelReleaseVersion >> 15) & 0xf;
314 304
315 if (KernelContext.EnableVersionChecks) 305 if (KernelContext.EnableVersionChecks)
316 { 306 {
@@ -519,12 +509,10 @@ namespace Ryujinx.HLE.HOS.Kernel.Process
519 return result; 509 return result;
520 } 510 }
521 511
522#pragma warning disable CA1822 // Mark member as static
523 private void GenerateRandomEntropy() 512 private void GenerateRandomEntropy()
524 { 513 {
525 // TODO. 514 // TODO.
526 } 515 }
527#pragma warning restore CA1822
528 516
529 public Result Start(int mainThreadPriority, ulong stackSize) 517 public Result Start(int mainThreadPriority, ulong stackSize)
530 { 518 {
@@ -1182,5 +1170,10 @@ namespace Ryujinx.HLE.HOS.Kernel.Process
1182 // TODO 1170 // TODO
1183 return false; 1171 return false;
1184 } 1172 }
1173
1174 public bool IsSvcPermitted(int svcId)
1175 {
1176 return Capabilities.IsSvcPermitted(svcId);
1177 }
1185 } 1178 }
1186} 1179}
diff --git a/src/Ryujinx.HLE/HOS/Kernel/Process/KProcessCapabilities.cs b/src/Ryujinx.HLE/HOS/Kernel/Process/KProcessCapabilities.cs
index 314aadf36..ebab67bb8 100644
--- a/src/Ryujinx.HLE/HOS/Kernel/Process/KProcessCapabilities.cs
+++ b/src/Ryujinx.HLE/HOS/Kernel/Process/KProcessCapabilities.cs
@@ -8,6 +8,8 @@ namespace Ryujinx.HLE.HOS.Kernel.Process
8{ 8{
9 class KProcessCapabilities 9 class KProcessCapabilities
10 { 10 {
11 private const int SvcMaskElementBits = 8;
12
11 public byte[] SvcAccessMask { get; } 13 public byte[] SvcAccessMask { get; }
12 public byte[] IrqAccessMask { get; } 14 public byte[] IrqAccessMask { get; }
13 15
@@ -22,7 +24,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Process
22 public KProcessCapabilities() 24 public KProcessCapabilities()
23 { 25 {
24 // length / number of bits of the underlying type 26 // length / number of bits of the underlying type
25 SvcAccessMask = new byte[KernelConstants.SupervisorCallCount / 8]; 27 SvcAccessMask = new byte[KernelConstants.SupervisorCallCount / SvcMaskElementBits];
26 IrqAccessMask = new byte[0x80]; 28 IrqAccessMask = new byte[0x80];
27 } 29 }
28 30
@@ -208,7 +210,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Process
208 return KernelResult.MaximumExceeded; 210 return KernelResult.MaximumExceeded;
209 } 211 }
210 212
211 SvcAccessMask[svcId / 8] |= (byte)(1 << (svcId & 7)); 213 SvcAccessMask[svcId / SvcMaskElementBits] |= (byte)(1 << (svcId % SvcMaskElementBits));
212 } 214 }
213 215
214 break; 216 break;
@@ -324,5 +326,13 @@ namespace Ryujinx.HLE.HOS.Kernel.Process
324 326
325 return mask << (int)min; 327 return mask << (int)min;
326 } 328 }
329
330 public bool IsSvcPermitted(int svcId)
331 {
332 int index = svcId / SvcMaskElementBits;
333 int mask = 1 << (svcId % SvcMaskElementBits);
334
335 return (uint)svcId < KernelConstants.SupervisorCallCount && (SvcAccessMask[index] & mask) != 0;
336 }
327 } 337 }
328} 338}
diff --git a/src/Ryujinx.HLE/HOS/Kernel/Process/ProcessCreationFlags.cs b/src/Ryujinx.HLE/HOS/Kernel/Process/ProcessCreationFlags.cs
index f0e43e023..1b62a29d4 100644
--- a/src/Ryujinx.HLE/HOS/Kernel/Process/ProcessCreationFlags.cs
+++ b/src/Ryujinx.HLE/HOS/Kernel/Process/ProcessCreationFlags.cs
@@ -29,6 +29,8 @@ namespace Ryujinx.HLE.HOS.Kernel.Process
29 PoolPartitionMask = 0xf << PoolPartitionShift, 29 PoolPartitionMask = 0xf << PoolPartitionShift,
30 30
31 OptimizeMemoryAllocation = 1 << 11, 31 OptimizeMemoryAllocation = 1 << 11,
32 DisableDeviceAddressSpaceMerge = 1 << 12,
33 EnableAliasRegionExtraSize = 1 << 13,
32 34
33 All = 35 All =
34 Is64Bit | 36 Is64Bit |
@@ -38,6 +40,8 @@ namespace Ryujinx.HLE.HOS.Kernel.Process
38 IsApplication | 40 IsApplication |
39 DeprecatedUseSecureMemory | 41 DeprecatedUseSecureMemory |
40 PoolPartitionMask | 42 PoolPartitionMask |
41 OptimizeMemoryAllocation, 43 OptimizeMemoryAllocation |
44 DisableDeviceAddressSpaceMerge |
45 EnableAliasRegionExtraSize,
42 } 46 }
43} 47}
diff --git a/src/Ryujinx.HLE/HOS/Kernel/SupervisorCall/InfoType.cs b/src/Ryujinx.HLE/HOS/Kernel/SupervisorCall/InfoType.cs
index c0db82105..cbaae8780 100644
--- a/src/Ryujinx.HLE/HOS/Kernel/SupervisorCall/InfoType.cs
+++ b/src/Ryujinx.HLE/HOS/Kernel/SupervisorCall/InfoType.cs
@@ -21,14 +21,17 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
21 SystemResourceSizeTotal, 21 SystemResourceSizeTotal,
22 SystemResourceSizeUsed, 22 SystemResourceSizeUsed,
23 ProgramId, 23 ProgramId,
24 // NOTE: Added in 4.0.0, removed in 5.0.0. 24 InitialProcessIdRange, // NOTE: Added in 4.0.0, removed in 5.0.0.
25 InitialProcessIdRange,
26 UserExceptionContextAddress, 25 UserExceptionContextAddress,
27 TotalNonSystemMemorySize, 26 TotalNonSystemMemorySize,
28 UsedNonSystemMemorySize, 27 UsedNonSystemMemorySize,
29 IsApplication, 28 IsApplication,
30 FreeThreadCount, 29 FreeThreadCount,
31 ThreadTickCount, 30 ThreadTickCount,
31 IsSvcPermitted,
32 IoRegionHint,
33 AliasRegionExtraSize,
34
32 MesosphereCurrentProcess = 65001, 35 MesosphereCurrentProcess = 65001,
33 } 36 }
34} 37}
diff --git a/src/Ryujinx.HLE/HOS/Kernel/SupervisorCall/Syscall.cs b/src/Ryujinx.HLE/HOS/Kernel/SupervisorCall/Syscall.cs
index 8f104b0b7..2f487243d 100644
--- a/src/Ryujinx.HLE/HOS/Kernel/SupervisorCall/Syscall.cs
+++ b/src/Ryujinx.HLE/HOS/Kernel/SupervisorCall/Syscall.cs
@@ -84,6 +84,17 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
84 return KernelResult.InvalidSize; 84 return KernelResult.InvalidSize;
85 } 85 }
86 86
87 if (info.Flags.HasFlag(ProcessCreationFlags.EnableAliasRegionExtraSize))
88 {
89 if ((info.Flags & ProcessCreationFlags.AddressSpaceMask) != ProcessCreationFlags.AddressSpace64Bit ||
90 info.SystemResourcePagesCount <= 0)
91 {
92 return KernelResult.InvalidState;
93 }
94
95 // TODO: Check that we are in debug mode.
96 }
97
87 if (info.Flags.HasFlag(ProcessCreationFlags.OptimizeMemoryAllocation) && 98 if (info.Flags.HasFlag(ProcessCreationFlags.OptimizeMemoryAllocation) &&
88 !info.Flags.HasFlag(ProcessCreationFlags.IsApplication)) 99 !info.Flags.HasFlag(ProcessCreationFlags.IsApplication))
89 { 100 {
@@ -139,7 +150,6 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
139 return handleTable.GenerateHandle(process, out handle); 150 return handleTable.GenerateHandle(process, out handle);
140 } 151 }
141 152
142#pragma warning disable CA1822 // Mark member as static
143 public Result StartProcess(int handle, int priority, int cpuCore, ulong mainThreadStackSize) 153 public Result StartProcess(int handle, int priority, int cpuCore, ulong mainThreadStackSize)
144 { 154 {
145 KProcess process = KernelStatic.GetCurrentProcess().HandleTable.GetObject<KProcess>(handle); 155 KProcess process = KernelStatic.GetCurrentProcess().HandleTable.GetObject<KProcess>(handle);
@@ -172,17 +182,14 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
172 182
173 return Result.Success; 183 return Result.Success;
174 } 184 }
175#pragma warning restore CA1822
176 185
177 [Svc(0x5f)] 186 [Svc(0x5f)]
178#pragma warning disable CA1822 // Mark member as static
179 public Result FlushProcessDataCache(int processHandle, ulong address, ulong size) 187 public Result FlushProcessDataCache(int processHandle, ulong address, ulong size)
180 { 188 {
181 // FIXME: This needs to be implemented as ARMv7 doesn't have any way to do cache maintenance operations on EL0. 189 // FIXME: This needs to be implemented as ARMv7 doesn't have any way to do cache maintenance operations on EL0.
182 // As we don't support (and don't actually need) to flush the cache, this is stubbed. 190 // As we don't support (and don't actually need) to flush the cache, this is stubbed.
183 return Result.Success; 191 return Result.Success;
184 } 192 }
185#pragma warning restore CA1822
186 193
187 // IPC 194 // IPC
188 195
@@ -256,7 +263,6 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
256 } 263 }
257 264
258 [Svc(0x22)] 265 [Svc(0x22)]
259#pragma warning disable CA1822 // Mark member as static
260 public Result SendSyncRequestWithUserBuffer( 266 public Result SendSyncRequestWithUserBuffer(
261 [PointerSized] ulong messagePtr, 267 [PointerSized] ulong messagePtr,
262 [PointerSized] ulong messageSize, 268 [PointerSized] ulong messageSize,
@@ -306,7 +312,6 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
306 312
307 return result; 313 return result;
308 } 314 }
309#pragma warning restore CA1822
310 315
311 [Svc(0x23)] 316 [Svc(0x23)]
312 public Result SendAsyncRequestWithUserBuffer( 317 public Result SendAsyncRequestWithUserBuffer(
@@ -896,7 +901,6 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
896 } 901 }
897 902
898 [Svc(2)] 903 [Svc(2)]
899#pragma warning disable CA1822 // Mark member as static
900 public Result SetMemoryPermission([PointerSized] ulong address, [PointerSized] ulong size, KMemoryPermission permission) 904 public Result SetMemoryPermission([PointerSized] ulong address, [PointerSized] ulong size, KMemoryPermission permission)
901 { 905 {
902 if (!PageAligned(address)) 906 if (!PageAligned(address))
@@ -928,10 +932,8 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
928 932
929 return currentProcess.MemoryManager.SetMemoryPermission(address, size, permission); 933 return currentProcess.MemoryManager.SetMemoryPermission(address, size, permission);
930 } 934 }
931#pragma warning restore CA1822
932 935
933 [Svc(3)] 936 [Svc(3)]
934#pragma warning disable CA1822 // Mark member as static
935 public Result SetMemoryAttribute( 937 public Result SetMemoryAttribute(
936 [PointerSized] ulong address, 938 [PointerSized] ulong address,
937 [PointerSized] ulong size, 939 [PointerSized] ulong size,
@@ -979,10 +981,8 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
979 981
980 return result; 982 return result;
981 } 983 }
982#pragma warning restore CA1822
983 984
984 [Svc(4)] 985 [Svc(4)]
985#pragma warning disable CA1822 // Mark member as static
986 public Result MapMemory([PointerSized] ulong dst, [PointerSized] ulong src, [PointerSized] ulong size) 986 public Result MapMemory([PointerSized] ulong dst, [PointerSized] ulong src, [PointerSized] ulong size)
987 { 987 {
988 if (!PageAligned(src | dst)) 988 if (!PageAligned(src | dst))
@@ -1018,10 +1018,8 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
1018 1018
1019 return process.MemoryManager.Map(dst, src, size); 1019 return process.MemoryManager.Map(dst, src, size);
1020 } 1020 }
1021#pragma warning restore CA1822
1022 1021
1023 [Svc(5)] 1022 [Svc(5)]
1024#pragma warning disable CA1822 // Mark member as static
1025 public Result UnmapMemory([PointerSized] ulong dst, [PointerSized] ulong src, [PointerSized] ulong size) 1023 public Result UnmapMemory([PointerSized] ulong dst, [PointerSized] ulong src, [PointerSized] ulong size)
1026 { 1024 {
1027 if (!PageAligned(src | dst)) 1025 if (!PageAligned(src | dst))
@@ -1057,7 +1055,6 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
1057 1055
1058 return process.MemoryManager.Unmap(dst, src, size); 1056 return process.MemoryManager.Unmap(dst, src, size);
1059 } 1057 }
1060#pragma warning restore CA1822
1061 1058
1062 [Svc(6)] 1059 [Svc(6)]
1063 public Result QueryMemory([PointerSized] ulong infoPtr, [PointerSized] out ulong pageInfo, [PointerSized] ulong address) 1060 public Result QueryMemory([PointerSized] ulong infoPtr, [PointerSized] out ulong pageInfo, [PointerSized] ulong address)
@@ -1074,7 +1071,6 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
1074 return result; 1071 return result;
1075 } 1072 }
1076 1073
1077#pragma warning disable CA1822 // Mark member as static
1078 public Result QueryMemory(out MemoryInfo info, out ulong pageInfo, ulong address) 1074 public Result QueryMemory(out MemoryInfo info, out ulong pageInfo, ulong address)
1079 { 1075 {
1080 KProcess process = KernelStatic.GetCurrentProcess(); 1076 KProcess process = KernelStatic.GetCurrentProcess();
@@ -1094,10 +1090,8 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
1094 1090
1095 return Result.Success; 1091 return Result.Success;
1096 } 1092 }
1097#pragma warning restore CA1822
1098 1093
1099 [Svc(0x13)] 1094 [Svc(0x13)]
1100#pragma warning disable CA1822 // Mark member as static
1101 public Result MapSharedMemory(int handle, [PointerSized] ulong address, [PointerSized] ulong size, KMemoryPermission permission) 1095 public Result MapSharedMemory(int handle, [PointerSized] ulong address, [PointerSized] ulong size, KMemoryPermission permission)
1102 { 1096 {
1103 if (!PageAligned(address)) 1097 if (!PageAligned(address))
@@ -1143,10 +1137,8 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
1143 currentProcess, 1137 currentProcess,
1144 permission); 1138 permission);
1145 } 1139 }
1146#pragma warning restore CA1822
1147 1140
1148 [Svc(0x14)] 1141 [Svc(0x14)]
1149#pragma warning disable CA1822 // Mark member as static
1150 public Result UnmapSharedMemory(int handle, [PointerSized] ulong address, [PointerSized] ulong size) 1142 public Result UnmapSharedMemory(int handle, [PointerSized] ulong address, [PointerSized] ulong size)
1151 { 1143 {
1152 if (!PageAligned(address)) 1144 if (!PageAligned(address))
@@ -1186,7 +1178,6 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
1186 size, 1178 size,
1187 currentProcess); 1179 currentProcess);
1188 } 1180 }
1189#pragma warning restore CA1822
1190 1181
1191 [Svc(0x15)] 1182 [Svc(0x15)]
1192 public Result CreateTransferMemory(out int handle, [PointerSized] ulong address, [PointerSized] ulong size, KMemoryPermission permission) 1183 public Result CreateTransferMemory(out int handle, [PointerSized] ulong address, [PointerSized] ulong size, KMemoryPermission permission)
@@ -1253,7 +1244,6 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
1253 } 1244 }
1254 1245
1255 [Svc(0x51)] 1246 [Svc(0x51)]
1256#pragma warning disable CA1822 // Mark member as static
1257 public Result MapTransferMemory(int handle, [PointerSized] ulong address, [PointerSized] ulong size, KMemoryPermission permission) 1247 public Result MapTransferMemory(int handle, [PointerSized] ulong address, [PointerSized] ulong size, KMemoryPermission permission)
1258 { 1248 {
1259 if (!PageAligned(address)) 1249 if (!PageAligned(address))
@@ -1299,10 +1289,8 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
1299 currentProcess, 1289 currentProcess,
1300 permission); 1290 permission);
1301 } 1291 }
1302#pragma warning restore CA1822
1303 1292
1304 [Svc(0x52)] 1293 [Svc(0x52)]
1305#pragma warning disable CA1822 // Mark member as static
1306 public Result UnmapTransferMemory(int handle, [PointerSized] ulong address, [PointerSized] ulong size) 1294 public Result UnmapTransferMemory(int handle, [PointerSized] ulong address, [PointerSized] ulong size)
1307 { 1295 {
1308 if (!PageAligned(address)) 1296 if (!PageAligned(address))
@@ -1342,10 +1330,8 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
1342 size, 1330 size,
1343 currentProcess); 1331 currentProcess);
1344 } 1332 }
1345#pragma warning restore CA1822
1346 1333
1347 [Svc(0x2c)] 1334 [Svc(0x2c)]
1348#pragma warning disable CA1822 // Mark member as static
1349 public Result MapPhysicalMemory([PointerSized] ulong address, [PointerSized] ulong size) 1335 public Result MapPhysicalMemory([PointerSized] ulong address, [PointerSized] ulong size)
1350 { 1336 {
1351 if (!PageAligned(address)) 1337 if (!PageAligned(address))
@@ -1380,10 +1366,8 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
1380 1366
1381 return process.MemoryManager.MapPhysicalMemory(address, size); 1367 return process.MemoryManager.MapPhysicalMemory(address, size);
1382 } 1368 }
1383#pragma warning restore CA1822
1384 1369
1385 [Svc(0x2d)] 1370 [Svc(0x2d)]
1386#pragma warning disable CA1822 // Mark member as static
1387 public Result UnmapPhysicalMemory([PointerSized] ulong address, [PointerSized] ulong size) 1371 public Result UnmapPhysicalMemory([PointerSized] ulong address, [PointerSized] ulong size)
1388 { 1372 {
1389 if (!PageAligned(address)) 1373 if (!PageAligned(address))
@@ -1418,7 +1402,6 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
1418 1402
1419 return process.MemoryManager.UnmapPhysicalMemory(address, size); 1403 return process.MemoryManager.UnmapPhysicalMemory(address, size);
1420 } 1404 }
1421#pragma warning restore CA1822
1422 1405
1423 [Svc(0x4b)] 1406 [Svc(0x4b)]
1424 public Result CreateCodeMemory(out int handle, [PointerSized] ulong address, [PointerSized] ulong size) 1407 public Result CreateCodeMemory(out int handle, [PointerSized] ulong address, [PointerSized] ulong size)
@@ -1462,7 +1445,6 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
1462 } 1445 }
1463 1446
1464 [Svc(0x4c)] 1447 [Svc(0x4c)]
1465#pragma warning disable CA1822 // Mark member as static
1466 public Result ControlCodeMemory( 1448 public Result ControlCodeMemory(
1467 int handle, 1449 int handle,
1468 CodeMemoryOperation op, 1450 CodeMemoryOperation op,
@@ -1540,10 +1522,8 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
1540 return KernelResult.InvalidEnumValue; 1522 return KernelResult.InvalidEnumValue;
1541 } 1523 }
1542 } 1524 }
1543#pragma warning restore CA1822
1544 1525
1545 [Svc(0x73)] 1526 [Svc(0x73)]
1546#pragma warning disable CA1822 // Mark member as static
1547 public Result SetProcessMemoryPermission( 1527 public Result SetProcessMemoryPermission(
1548 int handle, 1528 int handle,
1549 ulong src, 1529 ulong src,
@@ -1584,10 +1564,8 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
1584 1564
1585 return targetProcess.MemoryManager.SetProcessMemoryPermission(src, size, permission); 1565 return targetProcess.MemoryManager.SetProcessMemoryPermission(src, size, permission);
1586 } 1566 }
1587#pragma warning restore CA1822
1588 1567
1589 [Svc(0x74)] 1568 [Svc(0x74)]
1590#pragma warning disable CA1822 // Mark member as static
1591 public Result MapProcessMemory( 1569 public Result MapProcessMemory(
1592 [PointerSized] ulong dst, 1570 [PointerSized] ulong dst,
1593 int handle, 1571 int handle,
@@ -1643,10 +1621,8 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
1643 1621
1644 return dstProcess.MemoryManager.MapPages(dst, pageList, MemoryState.ProcessMemory, KMemoryPermission.ReadAndWrite); 1622 return dstProcess.MemoryManager.MapPages(dst, pageList, MemoryState.ProcessMemory, KMemoryPermission.ReadAndWrite);
1645 } 1623 }
1646#pragma warning restore CA1822
1647 1624
1648 [Svc(0x75)] 1625 [Svc(0x75)]
1649#pragma warning disable CA1822 // Mark member as static
1650 public Result UnmapProcessMemory( 1626 public Result UnmapProcessMemory(
1651 [PointerSized] ulong dst, 1627 [PointerSized] ulong dst,
1652 int handle, 1628 int handle,
@@ -1691,10 +1667,8 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
1691 1667
1692 return Result.Success; 1668 return Result.Success;
1693 } 1669 }
1694#pragma warning restore CA1822
1695 1670
1696 [Svc(0x77)] 1671 [Svc(0x77)]
1697#pragma warning disable CA1822 // Mark member as static
1698 public Result MapProcessCodeMemory(int handle, ulong dst, ulong src, ulong size) 1672 public Result MapProcessCodeMemory(int handle, ulong dst, ulong src, ulong size)
1699 { 1673 {
1700 if (!PageAligned(dst) || !PageAligned(src)) 1674 if (!PageAligned(dst) || !PageAligned(src))
@@ -1731,10 +1705,8 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
1731 1705
1732 return targetProcess.MemoryManager.MapProcessCodeMemory(dst, src, size); 1706 return targetProcess.MemoryManager.MapProcessCodeMemory(dst, src, size);
1733 } 1707 }
1734#pragma warning restore CA1822
1735 1708
1736 [Svc(0x78)] 1709 [Svc(0x78)]
1737#pragma warning disable CA1822 // Mark member as static
1738 public Result UnmapProcessCodeMemory(int handle, ulong dst, ulong src, ulong size) 1710 public Result UnmapProcessCodeMemory(int handle, ulong dst, ulong src, ulong size)
1739 { 1711 {
1740 if (!PageAligned(dst) || !PageAligned(src)) 1712 if (!PageAligned(dst) || !PageAligned(src))
@@ -1771,7 +1743,6 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
1771 1743
1772 return targetProcess.MemoryManager.UnmapProcessCodeMemory(dst, src, size); 1744 return targetProcess.MemoryManager.UnmapProcessCodeMemory(dst, src, size);
1773 } 1745 }
1774#pragma warning restore CA1822
1775 1746
1776 private static bool PageAligned(ulong address) 1747 private static bool PageAligned(ulong address)
1777 { 1748 {
@@ -1781,7 +1752,6 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
1781 // System 1752 // System
1782 1753
1783 [Svc(0x7b)] 1754 [Svc(0x7b)]
1784#pragma warning disable CA1822 // Mark member as static
1785 public Result TerminateProcess(int handle) 1755 public Result TerminateProcess(int handle)
1786 { 1756 {
1787 KProcess process = KernelStatic.GetCurrentProcess(); 1757 KProcess process = KernelStatic.GetCurrentProcess();
@@ -1810,15 +1780,12 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
1810 1780
1811 return result; 1781 return result;
1812 } 1782 }
1813#pragma warning restore CA1822
1814 1783
1815 [Svc(7)] 1784 [Svc(7)]
1816#pragma warning disable CA1822 // Mark member as static
1817 public void ExitProcess() 1785 public void ExitProcess()
1818 { 1786 {
1819 KernelStatic.GetCurrentProcess().TerminateCurrentProcess(); 1787 KernelStatic.GetCurrentProcess().TerminateCurrentProcess();
1820 } 1788 }
1821#pragma warning restore CA1822
1822 1789
1823 [Svc(0x11)] 1790 [Svc(0x11)]
1824 public Result SignalEvent(int handle) 1791 public Result SignalEvent(int handle)
@@ -1911,7 +1878,6 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
1911 } 1878 }
1912 1879
1913 [Svc(0x26)] 1880 [Svc(0x26)]
1914#pragma warning disable CA1822 // Mark member as static
1915 public void Break(ulong reason) 1881 public void Break(ulong reason)
1916 { 1882 {
1917 KThread currentThread = KernelStatic.GetCurrentThread(); 1883 KThread currentThread = KernelStatic.GetCurrentThread();
@@ -1937,10 +1903,8 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
1937 Logger.Debug?.Print(LogClass.KernelSvc, "Debugger triggered."); 1903 Logger.Debug?.Print(LogClass.KernelSvc, "Debugger triggered.");
1938 } 1904 }
1939 } 1905 }
1940#pragma warning restore CA1822
1941 1906
1942 [Svc(0x27)] 1907 [Svc(0x27)]
1943#pragma warning disable CA1822 // Mark member as static
1944 public void OutputDebugString([PointerSized] ulong strPtr, [PointerSized] ulong size) 1908 public void OutputDebugString([PointerSized] ulong strPtr, [PointerSized] ulong size)
1945 { 1909 {
1946 KProcess process = KernelStatic.GetCurrentProcess(); 1910 KProcess process = KernelStatic.GetCurrentProcess();
@@ -1949,7 +1913,6 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
1949 1913
1950 Logger.Warning?.Print(LogClass.KernelSvc, str); 1914 Logger.Warning?.Print(LogClass.KernelSvc, str);
1951 } 1915 }
1952#pragma warning restore CA1822
1953 1916
1954 [Svc(0x29)] 1917 [Svc(0x29)]
1955 public Result GetInfo(out ulong value, InfoType id, int handle, long subId) 1918 public Result GetInfo(out ulong value, InfoType id, int handle, long subId)
@@ -1978,6 +1941,7 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
1978 case InfoType.UsedNonSystemMemorySize: 1941 case InfoType.UsedNonSystemMemorySize:
1979 case InfoType.IsApplication: 1942 case InfoType.IsApplication:
1980 case InfoType.FreeThreadCount: 1943 case InfoType.FreeThreadCount:
1944 case InfoType.AliasRegionExtraSize:
1981 { 1945 {
1982 if (subId != 0) 1946 if (subId != 0)
1983 { 1947 {
@@ -2006,22 +1970,19 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
2006 value = process.MemoryManager.AliasRegionStart; 1970 value = process.MemoryManager.AliasRegionStart;
2007 break; 1971 break;
2008 case InfoType.AliasRegionSize: 1972 case InfoType.AliasRegionSize:
2009 value = (process.MemoryManager.AliasRegionEnd - 1973 value = process.MemoryManager.AliasRegionEnd - process.MemoryManager.AliasRegionStart;
2010 process.MemoryManager.AliasRegionStart);
2011 break; 1974 break;
2012 1975
2013 case InfoType.HeapRegionAddress: 1976 case InfoType.HeapRegionAddress:
2014 value = process.MemoryManager.HeapRegionStart; 1977 value = process.MemoryManager.HeapRegionStart;
2015 break; 1978 break;
2016 case InfoType.HeapRegionSize: 1979 case InfoType.HeapRegionSize:
2017 value = (process.MemoryManager.HeapRegionEnd - 1980 value = process.MemoryManager.HeapRegionEnd - process.MemoryManager.HeapRegionStart;
2018 process.MemoryManager.HeapRegionStart);
2019 break; 1981 break;
2020 1982
2021 case InfoType.TotalMemorySize: 1983 case InfoType.TotalMemorySize:
2022 value = process.GetMemoryCapacity(); 1984 value = process.GetMemoryCapacity();
2023 break; 1985 break;
2024
2025 case InfoType.UsedMemorySize: 1986 case InfoType.UsedMemorySize:
2026 value = process.GetMemoryUsage(); 1987 value = process.GetMemoryUsage();
2027 break; 1988 break;
@@ -2029,7 +1990,6 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
2029 case InfoType.AslrRegionAddress: 1990 case InfoType.AslrRegionAddress:
2030 value = process.MemoryManager.GetAddrSpaceBaseAddr(); 1991 value = process.MemoryManager.GetAddrSpaceBaseAddr();
2031 break; 1992 break;
2032
2033 case InfoType.AslrRegionSize: 1993 case InfoType.AslrRegionSize:
2034 value = process.MemoryManager.GetAddrSpaceSize(); 1994 value = process.MemoryManager.GetAddrSpaceSize();
2035 break; 1995 break;
@@ -2038,20 +1998,17 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
2038 value = process.MemoryManager.StackRegionStart; 1998 value = process.MemoryManager.StackRegionStart;
2039 break; 1999 break;
2040 case InfoType.StackRegionSize: 2000 case InfoType.StackRegionSize:
2041 value = (process.MemoryManager.StackRegionEnd - 2001 value = process.MemoryManager.StackRegionEnd - process.MemoryManager.StackRegionStart;
2042 process.MemoryManager.StackRegionStart);
2043 break; 2002 break;
2044 2003
2045 case InfoType.SystemResourceSizeTotal: 2004 case InfoType.SystemResourceSizeTotal:
2046 value = process.PersonalMmHeapPagesCount * KPageTableBase.PageSize; 2005 value = process.PersonalMmHeapPagesCount * KPageTableBase.PageSize;
2047 break; 2006 break;
2048
2049 case InfoType.SystemResourceSizeUsed: 2007 case InfoType.SystemResourceSizeUsed:
2050 if (process.PersonalMmHeapPagesCount != 0) 2008 if (process.PersonalMmHeapPagesCount != 0)
2051 { 2009 {
2052 value = process.MemoryManager.GetMmUsedPages() * KPageTableBase.PageSize; 2010 value = process.MemoryManager.GetMmUsedPages() * KPageTableBase.PageSize;
2053 } 2011 }
2054
2055 break; 2012 break;
2056 2013
2057 case InfoType.ProgramId: 2014 case InfoType.ProgramId:
@@ -2065,7 +2022,6 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
2065 case InfoType.TotalNonSystemMemorySize: 2022 case InfoType.TotalNonSystemMemorySize:
2066 value = process.GetMemoryCapacityWithoutPersonalMmHeap(); 2023 value = process.GetMemoryCapacityWithoutPersonalMmHeap();
2067 break; 2024 break;
2068
2069 case InfoType.UsedNonSystemMemorySize: 2025 case InfoType.UsedNonSystemMemorySize:
2070 value = process.GetMemoryUsageWithoutPersonalMmHeap(); 2026 value = process.GetMemoryUsageWithoutPersonalMmHeap();
2071 break; 2027 break;
@@ -2084,10 +2040,12 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
2084 { 2040 {
2085 value = 0; 2041 value = 0;
2086 } 2042 }
2043 break;
2087 2044
2045 case InfoType.AliasRegionExtraSize:
2046 value = process.MemoryManager.AliasRegionExtraSize;
2088 break; 2047 break;
2089 } 2048 }
2090
2091 break; 2049 break;
2092 } 2050 }
2093 2051
@@ -2104,7 +2062,6 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
2104 } 2062 }
2105 2063
2106 value = KernelStatic.GetCurrentProcess().Debug ? 1UL : 0UL; 2064 value = KernelStatic.GetCurrentProcess().Debug ? 1UL : 0UL;
2107
2108 break; 2065 break;
2109 } 2066 }
2110 2067
@@ -2136,7 +2093,6 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
2136 2093
2137 value = (uint)resLimHandle; 2094 value = (uint)resLimHandle;
2138 } 2095 }
2139
2140 break; 2096 break;
2141 } 2097 }
2142 2098
@@ -2155,7 +2111,6 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
2155 } 2111 }
2156 2112
2157 value = (ulong)KTimeManager.ConvertHostTicksToTicks(_context.Schedulers[currentCore].TotalIdleTimeTicks); 2113 value = (ulong)KTimeManager.ConvertHostTicksToTicks(_context.Schedulers[currentCore].TotalIdleTimeTicks);
2158
2159 break; 2114 break;
2160 } 2115 }
2161 2116
@@ -2174,7 +2129,6 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
2174 KProcess currentProcess = KernelStatic.GetCurrentProcess(); 2129 KProcess currentProcess = KernelStatic.GetCurrentProcess();
2175 2130
2176 value = currentProcess.RandomEntropy[subId]; 2131 value = currentProcess.RandomEntropy[subId];
2177
2178 break; 2132 break;
2179 } 2133 }
2180 2134
@@ -2220,7 +2174,22 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
2220 2174
2221 value = (ulong)KTimeManager.ConvertHostTicksToTicks(totalTimeRunning); 2175 value = (ulong)KTimeManager.ConvertHostTicksToTicks(totalTimeRunning);
2222 } 2176 }
2177 break;
2178 }
2223 2179
2180 case InfoType.IsSvcPermitted:
2181 {
2182 if (handle != 0)
2183 {
2184 return KernelResult.InvalidHandle;
2185 }
2186
2187 if (subId != 0x36)
2188 {
2189 return KernelResult.InvalidCombination;
2190 }
2191
2192 value = KernelStatic.GetCurrentProcess().IsSvcPermitted((int)subId) ? 1UL : 0UL;
2224 break; 2193 break;
2225 } 2194 }
2226 2195
@@ -2231,7 +2200,7 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
2231 return KernelResult.InvalidHandle; 2200 return KernelResult.InvalidHandle;
2232 } 2201 }
2233 2202
2234 if ((ulong)subId != 0) 2203 if (subId != 0)
2235 { 2204 {
2236 return KernelResult.InvalidCombination; 2205 return KernelResult.InvalidCombination;
2237 } 2206 }
@@ -2246,8 +2215,7 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
2246 return result; 2215 return result;
2247 } 2216 }
2248 2217
2249 value = (ulong)outHandle; 2218 value = (uint)outHandle;
2250
2251 break; 2219 break;
2252 } 2220 }
2253 2221
@@ -2398,7 +2366,6 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
2398 } 2366 }
2399 2367
2400 [Svc(0x30)] 2368 [Svc(0x30)]
2401#pragma warning disable CA1822 // Mark member as static
2402 public Result GetResourceLimitLimitValue(out long limitValue, int handle, LimitableResource resource) 2369 public Result GetResourceLimitLimitValue(out long limitValue, int handle, LimitableResource resource)
2403 { 2370 {
2404 limitValue = 0; 2371 limitValue = 0;
@@ -2419,10 +2386,8 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
2419 2386
2420 return Result.Success; 2387 return Result.Success;
2421 } 2388 }
2422#pragma warning restore CA1822
2423 2389
2424 [Svc(0x31)] 2390 [Svc(0x31)]
2425#pragma warning disable CA1822 // Mark member as static
2426 public Result GetResourceLimitCurrentValue(out long limitValue, int handle, LimitableResource resource) 2391 public Result GetResourceLimitCurrentValue(out long limitValue, int handle, LimitableResource resource)
2427 { 2392 {
2428 limitValue = 0; 2393 limitValue = 0;
@@ -2443,10 +2408,8 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
2443 2408
2444 return Result.Success; 2409 return Result.Success;
2445 } 2410 }
2446#pragma warning restore CA1822
2447 2411
2448 [Svc(0x37)] 2412 [Svc(0x37)]
2449#pragma warning disable CA1822 // Mark member as static
2450 public Result GetResourceLimitPeakValue(out long peak, int handle, LimitableResource resource) 2413 public Result GetResourceLimitPeakValue(out long peak, int handle, LimitableResource resource)
2451 { 2414 {
2452 peak = 0; 2415 peak = 0;
@@ -2467,7 +2430,6 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
2467 2430
2468 return Result.Success; 2431 return Result.Success;
2469 } 2432 }
2470#pragma warning restore CA1822
2471 2433
2472 [Svc(0x7d)] 2434 [Svc(0x7d)]
2473 public Result CreateResourceLimit(out int handle) 2435 public Result CreateResourceLimit(out int handle)
@@ -2480,7 +2442,6 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
2480 } 2442 }
2481 2443
2482 [Svc(0x7e)] 2444 [Svc(0x7e)]
2483#pragma warning disable CA1822 // Mark member as static
2484 public Result SetResourceLimitLimitValue(int handle, LimitableResource resource, long limitValue) 2445 public Result SetResourceLimitLimitValue(int handle, LimitableResource resource, long limitValue)
2485 { 2446 {
2486 if (resource >= LimitableResource.Count) 2447 if (resource >= LimitableResource.Count)
@@ -2497,7 +2458,6 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
2497 2458
2498 return resourceLimit.SetLimitValue(resource, limitValue); 2459 return resourceLimit.SetLimitValue(resource, limitValue);
2499 } 2460 }
2500#pragma warning restore CA1822
2501 2461
2502 // Thread 2462 // Thread
2503 2463
@@ -2577,7 +2537,6 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
2577 } 2537 }
2578 2538
2579 [Svc(9)] 2539 [Svc(9)]
2580#pragma warning disable CA1822 // Mark member as static
2581 public Result StartThread(int handle) 2540 public Result StartThread(int handle)
2582 { 2541 {
2583 KProcess process = KernelStatic.GetCurrentProcess(); 2542 KProcess process = KernelStatic.GetCurrentProcess();
@@ -2604,17 +2563,14 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
2604 return KernelResult.InvalidHandle; 2563 return KernelResult.InvalidHandle;
2605 } 2564 }
2606 } 2565 }
2607#pragma warning restore CA1822
2608 2566
2609 [Svc(0xa)] 2567 [Svc(0xa)]
2610#pragma warning disable CA1822 // Mark member as static
2611 public void ExitThread() 2568 public void ExitThread()
2612 { 2569 {
2613 KThread currentThread = KernelStatic.GetCurrentThread(); 2570 KThread currentThread = KernelStatic.GetCurrentThread();
2614 2571
2615 currentThread.Exit(); 2572 currentThread.Exit();
2616 } 2573 }
2617#pragma warning restore CA1822
2618 2574
2619 [Svc(0xb)] 2575 [Svc(0xb)]
2620 public void SleepThread(long timeout) 2576 public void SleepThread(long timeout)
@@ -2641,7 +2597,6 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
2641 } 2597 }
2642 2598
2643 [Svc(0xc)] 2599 [Svc(0xc)]
2644#pragma warning disable CA1822 // Mark member as static
2645 public Result GetThreadPriority(out int priority, int handle) 2600 public Result GetThreadPriority(out int priority, int handle)
2646 { 2601 {
2647 KProcess process = KernelStatic.GetCurrentProcess(); 2602 KProcess process = KernelStatic.GetCurrentProcess();
@@ -2661,10 +2616,8 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
2661 return KernelResult.InvalidHandle; 2616 return KernelResult.InvalidHandle;
2662 } 2617 }
2663 } 2618 }
2664#pragma warning restore CA1822
2665 2619
2666 [Svc(0xd)] 2620 [Svc(0xd)]
2667#pragma warning disable CA1822 // Mark member as static
2668 public Result SetThreadPriority(int handle, int priority) 2621 public Result SetThreadPriority(int handle, int priority)
2669 { 2622 {
2670 // TODO: NPDM check. 2623 // TODO: NPDM check.
@@ -2682,10 +2635,8 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
2682 2635
2683 return Result.Success; 2636 return Result.Success;
2684 } 2637 }
2685#pragma warning restore CA1822
2686 2638
2687 [Svc(0xe)] 2639 [Svc(0xe)]
2688#pragma warning disable CA1822 // Mark member as static
2689 public Result GetThreadCoreMask(out int preferredCore, out ulong affinityMask, int handle) 2640 public Result GetThreadCoreMask(out int preferredCore, out ulong affinityMask, int handle)
2690 { 2641 {
2691 KProcess process = KernelStatic.GetCurrentProcess(); 2642 KProcess process = KernelStatic.GetCurrentProcess();
@@ -2707,10 +2658,8 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
2707 return KernelResult.InvalidHandle; 2658 return KernelResult.InvalidHandle;
2708 } 2659 }
2709 } 2660 }
2710#pragma warning restore CA1822
2711 2661
2712 [Svc(0xf)] 2662 [Svc(0xf)]
2713#pragma warning disable CA1822 // Mark member as static
2714 public Result SetThreadCoreMask(int handle, int preferredCore, ulong affinityMask) 2663 public Result SetThreadCoreMask(int handle, int preferredCore, ulong affinityMask)
2715 { 2664 {
2716 KProcess currentProcess = KernelStatic.GetCurrentProcess(); 2665 KProcess currentProcess = KernelStatic.GetCurrentProcess();
@@ -2758,18 +2707,14 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
2758 2707
2759 return thread.SetCoreAndAffinityMask(preferredCore, affinityMask); 2708 return thread.SetCoreAndAffinityMask(preferredCore, affinityMask);
2760 } 2709 }
2761#pragma warning restore CA1822
2762 2710
2763 [Svc(0x10)] 2711 [Svc(0x10)]
2764#pragma warning disable CA1822 // Mark member as static
2765 public int GetCurrentProcessorNumber() 2712 public int GetCurrentProcessorNumber()
2766 { 2713 {
2767 return KernelStatic.GetCurrentThread().CurrentCore; 2714 return KernelStatic.GetCurrentThread().CurrentCore;
2768 } 2715 }
2769#pragma warning restore CA1822
2770 2716
2771 [Svc(0x25)] 2717 [Svc(0x25)]
2772#pragma warning disable CA1822 // Mark member as static
2773 public Result GetThreadId(out ulong threadUid, int handle) 2718 public Result GetThreadId(out ulong threadUid, int handle)
2774 { 2719 {
2775 KProcess process = KernelStatic.GetCurrentProcess(); 2720 KProcess process = KernelStatic.GetCurrentProcess();
@@ -2789,10 +2734,8 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
2789 return KernelResult.InvalidHandle; 2734 return KernelResult.InvalidHandle;
2790 } 2735 }
2791 } 2736 }
2792#pragma warning restore CA1822
2793 2737
2794 [Svc(0x32)] 2738 [Svc(0x32)]
2795#pragma warning disable CA1822 // Mark member as static
2796 public Result SetThreadActivity(int handle, bool pause) 2739 public Result SetThreadActivity(int handle, bool pause)
2797 { 2740 {
2798 KProcess process = KernelStatic.GetCurrentProcess(); 2741 KProcess process = KernelStatic.GetCurrentProcess();
@@ -2816,10 +2759,8 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
2816 2759
2817 return thread.SetActivity(pause); 2760 return thread.SetActivity(pause);
2818 } 2761 }
2819#pragma warning restore CA1822
2820 2762
2821 [Svc(0x33)] 2763 [Svc(0x33)]
2822#pragma warning disable CA1822 // Mark member as static
2823 public Result GetThreadContext3([PointerSized] ulong address, int handle) 2764 public Result GetThreadContext3([PointerSized] ulong address, int handle)
2824 { 2765 {
2825 KProcess currentProcess = KernelStatic.GetCurrentProcess(); 2766 KProcess currentProcess = KernelStatic.GetCurrentProcess();
@@ -2853,7 +2794,6 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
2853 2794
2854 return result; 2795 return result;
2855 } 2796 }
2856#pragma warning restore CA1822
2857 2797
2858 // Thread synchronization 2798 // Thread synchronization
2859 2799
@@ -2986,7 +2926,6 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
2986 } 2926 }
2987 2927
2988 [Svc(0x1a)] 2928 [Svc(0x1a)]
2989#pragma warning disable CA1822 // Mark member as static
2990 public Result ArbitrateLock(int ownerHandle, [PointerSized] ulong mutexAddress, int requesterHandle) 2929 public Result ArbitrateLock(int ownerHandle, [PointerSized] ulong mutexAddress, int requesterHandle)
2991 { 2930 {
2992 if (IsPointingInsideKernel(mutexAddress)) 2931 if (IsPointingInsideKernel(mutexAddress))
@@ -3003,10 +2942,8 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
3003 2942
3004 return currentProcess.AddressArbiter.ArbitrateLock(ownerHandle, mutexAddress, requesterHandle); 2943 return currentProcess.AddressArbiter.ArbitrateLock(ownerHandle, mutexAddress, requesterHandle);
3005 } 2944 }
3006#pragma warning restore CA1822
3007 2945
3008 [Svc(0x1b)] 2946 [Svc(0x1b)]
3009#pragma warning disable CA1822 // Mark member as static
3010 public Result ArbitrateUnlock([PointerSized] ulong mutexAddress) 2947 public Result ArbitrateUnlock([PointerSized] ulong mutexAddress)
3011 { 2948 {
3012 if (IsPointingInsideKernel(mutexAddress)) 2949 if (IsPointingInsideKernel(mutexAddress))
@@ -3023,10 +2960,8 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
3023 2960
3024 return currentProcess.AddressArbiter.ArbitrateUnlock(mutexAddress); 2961 return currentProcess.AddressArbiter.ArbitrateUnlock(mutexAddress);
3025 } 2962 }
3026#pragma warning restore CA1822
3027 2963
3028 [Svc(0x1c)] 2964 [Svc(0x1c)]
3029#pragma warning disable CA1822 // Mark member as static
3030 public Result WaitProcessWideKeyAtomic( 2965 public Result WaitProcessWideKeyAtomic(
3031 [PointerSized] ulong mutexAddress, 2966 [PointerSized] ulong mutexAddress,
3032 [PointerSized] ulong condVarAddress, 2967 [PointerSized] ulong condVarAddress,
@@ -3056,10 +2991,8 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
3056 handle, 2991 handle,
3057 timeout); 2992 timeout);
3058 } 2993 }
3059#pragma warning restore CA1822
3060 2994
3061 [Svc(0x1d)] 2995 [Svc(0x1d)]
3062#pragma warning disable CA1822 // Mark member as static
3063 public Result SignalProcessWideKey([PointerSized] ulong address, int count) 2996 public Result SignalProcessWideKey([PointerSized] ulong address, int count)
3064 { 2997 {
3065 KProcess currentProcess = KernelStatic.GetCurrentProcess(); 2998 KProcess currentProcess = KernelStatic.GetCurrentProcess();
@@ -3068,10 +3001,8 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
3068 3001
3069 return Result.Success; 3002 return Result.Success;
3070 } 3003 }
3071#pragma warning restore CA1822
3072 3004
3073 [Svc(0x34)] 3005 [Svc(0x34)]
3074#pragma warning disable CA1822 // Mark member as static
3075 public Result WaitForAddress([PointerSized] ulong address, ArbitrationType type, int value, long timeout) 3006 public Result WaitForAddress([PointerSized] ulong address, ArbitrationType type, int value, long timeout)
3076 { 3007 {
3077 if (IsPointingInsideKernel(address)) 3008 if (IsPointingInsideKernel(address))
@@ -3102,10 +3033,8 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
3102 _ => KernelResult.InvalidEnumValue, 3033 _ => KernelResult.InvalidEnumValue,
3103 }; 3034 };
3104 } 3035 }
3105#pragma warning restore CA1822
3106 3036
3107 [Svc(0x35)] 3037 [Svc(0x35)]
3108#pragma warning disable CA1822 // Mark member as static
3109 public Result SignalToAddress([PointerSized] ulong address, SignalType type, int value, int count) 3038 public Result SignalToAddress([PointerSized] ulong address, SignalType type, int value, int count)
3110 { 3039 {
3111 if (IsPointingInsideKernel(address)) 3040 if (IsPointingInsideKernel(address))
@@ -3131,17 +3060,14 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
3131 _ => KernelResult.InvalidEnumValue, 3060 _ => KernelResult.InvalidEnumValue,
3132 }; 3061 };
3133 } 3062 }
3134#pragma warning restore CA1822
3135 3063
3136 [Svc(0x36)] 3064 [Svc(0x36)]
3137#pragma warning disable CA1822 // Mark member as static
3138 public Result SynchronizePreemptionState() 3065 public Result SynchronizePreemptionState()
3139 { 3066 {
3140 KernelStatic.GetCurrentThread().SynchronizePreemptionState(); 3067 KernelStatic.GetCurrentThread().SynchronizePreemptionState();
3141 3068
3142 return Result.Success; 3069 return Result.Success;
3143 } 3070 }
3144#pragma warning restore CA1822
3145 3071
3146 // Not actual syscalls, used by HLE services and such. 3072 // Not actual syscalls, used by HLE services and such.
3147 3073