Implement IsSvcPermitted

This commit is contained in:
Gabriel A 2024-07-20 15:26:35 -03:00
parent b37f7caacb
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;
}
#pragma warning disable CA1822 // Mark member as static
private void GenerateRandomEntropy()
{
// TODO.
}
#pragma warning restore CA1822
public Result Start(int mainThreadPriority, ulong stackSize)
{
@ -1172,5 +1170,10 @@ namespace Ryujinx.HLE.HOS.Kernel.Process
// TODO
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
{
private const int SvcMaskElementBits = 8;
public byte[] SvcAccessMask { get; }
public byte[] IrqAccessMask { get; }
@ -22,7 +24,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Process
public KProcessCapabilities()
{
// length / number of bits of the underlying type
SvcAccessMask = new byte[KernelConstants.SupervisorCallCount / 8];
SvcAccessMask = new byte[KernelConstants.SupervisorCallCount / SvcMaskElementBits];
IrqAccessMask = new byte[0x80];
}
@ -208,7 +210,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Process
return KernelResult.MaximumExceeded;
}
SvcAccessMask[svcId / 8] |= (byte)(1 << (svcId & 7));
SvcAccessMask[svcId / SvcMaskElementBits] |= (byte)(1 << (svcId % SvcMaskElementBits));
}
break;
@ -324,5 +326,13 @@ namespace Ryujinx.HLE.HOS.Kernel.Process
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;
}
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:
{
if (handle != 0)
@ -2232,7 +2248,7 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
return KernelResult.InvalidHandle;
}
if ((ulong)subId != 0)
if (subId != 0)
{
return KernelResult.InvalidCombination;
}
@ -2247,7 +2263,7 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
return result;
}
value = (ulong)outHandle;
value = (uint)outHandle;
break;
}