Implement IsSvcPermitted

This commit is contained in:
Gabriel A 2024-07-20 15:26:35 -03:00
commit b381d38270
3 changed files with 35 additions and 6 deletions

View file

@ -509,12 +509,10 @@ namespace Ryujinx.HLE.HOS.Kernel.Process
return result; return result;
} }
#pragma warning disable CA1822 // Mark member as static
private void GenerateRandomEntropy() private void GenerateRandomEntropy()
{ {
// TODO. // TODO.
} }
#pragma warning restore CA1822
public Result Start(int mainThreadPriority, ulong stackSize) public Result Start(int mainThreadPriority, ulong stackSize)
{ {
@ -1172,5 +1170,10 @@ namespace Ryujinx.HLE.HOS.Kernel.Process
// TODO // TODO
return false; return false;
} }
public bool IsSvcPermitted(int svcId)
{
return Capabilities.IsSvcPermitted(svcId);
}
} }
} }

View file

@ -8,6 +8,8 @@ namespace Ryujinx.HLE.HOS.Kernel.Process
{ {
class KProcessCapabilities class KProcessCapabilities
{ {
private const int SvcMaskElementBits = 8;
public byte[] SvcAccessMask { get; } public byte[] SvcAccessMask { get; }
public byte[] IrqAccessMask { get; } public byte[] IrqAccessMask { get; }
@ -22,7 +24,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Process
public KProcessCapabilities() public KProcessCapabilities()
{ {
// length / number of bits of the underlying type // length / number of bits of the underlying type
SvcAccessMask = new byte[KernelConstants.SupervisorCallCount / 8]; SvcAccessMask = new byte[KernelConstants.SupervisorCallCount / SvcMaskElementBits];
IrqAccessMask = new byte[0x80]; IrqAccessMask = new byte[0x80];
} }
@ -208,7 +210,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Process
return KernelResult.MaximumExceeded; return KernelResult.MaximumExceeded;
} }
SvcAccessMask[svcId / 8] |= (byte)(1 << (svcId & 7)); SvcAccessMask[svcId / SvcMaskElementBits] |= (byte)(1 << (svcId % SvcMaskElementBits));
} }
break; break;
@ -324,5 +326,13 @@ namespace Ryujinx.HLE.HOS.Kernel.Process
return mask << (int)min; return mask << (int)min;
} }
public bool IsSvcPermitted(int svcId)
{
int index = svcId / SvcMaskElementBits;
int mask = (byte)(1 << (svcId % SvcMaskElementBits));
return (uint)svcId < KernelConstants.SupervisorCallCount && (SvcAccessMask[index] & mask) != 0;
}
} }
} }

View file

@ -2225,6 +2225,22 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
break; break;
} }
case InfoType.IsSvcPermitted:
{
if (handle != 0)
{
return KernelResult.InvalidHandle;
}
if (subId != 0x36)
{
return KernelResult.InvalidCombination;
}
value = KernelStatic.GetCurrentProcess().IsSvcPermitted((int)subId) ? 1UL : 0UL;
break;
}
case InfoType.MesosphereCurrentProcess: case InfoType.MesosphereCurrentProcess:
{ {
if (handle != 0) if (handle != 0)
@ -2232,7 +2248,7 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
return KernelResult.InvalidHandle; return KernelResult.InvalidHandle;
} }
if ((ulong)subId != 0) if (subId != 0)
{ {
return KernelResult.InvalidCombination; return KernelResult.InvalidCombination;
} }
@ -2247,7 +2263,7 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
return result; return result;
} }
value = (ulong)outHandle; value = (uint)outHandle;
break; break;
} }