SM instance & TIPC fixes (#2241)

This PR addresses the following issues:
- SM was previously instancied once and reused on all sessions. This
  could cause inconsistency on the service initialization.
- TIPC replies were not matching what is generated on hardware.
This commit is contained in:
Mary
2021-05-05 23:44:26 +02:00
committed by GitHub
parent eb056218a1
commit b94dc01d43
4 changed files with 85 additions and 15 deletions

View File

@ -15,15 +15,20 @@ namespace Ryujinx.HLE.HOS.Services.Sm
{
class IUserInterface : IpcService
{
private Dictionary<string, Type> _services;
private static Dictionary<string, Type> _services;
private readonly ConcurrentDictionary<string, KPort> _registeredServices;
private static readonly ConcurrentDictionary<string, KPort> _registeredServices;
private readonly ServerBase _commonServer;
private bool _isInitialized;
public IUserInterface(KernelContext context)
{
_commonServer = new ServerBase(context, "CommonServer");
}
static IUserInterface()
{
_registeredServices = new ConcurrentDictionary<string, KPort>();
@ -31,10 +36,6 @@ namespace Ryujinx.HLE.HOS.Services.Sm
.SelectMany(type => type.GetCustomAttributes(typeof(ServiceAttribute), true)
.Select(service => (((ServiceAttribute)service).Name, type)))
.ToDictionary(service => service.Name, service => service.type);
TrySetServer(new ServerBase(context, "SmServer") { SmObject = this });
_commonServer = new ServerBase(context, "CommonServer");
}
[CommandHipc(0)]
@ -47,9 +48,16 @@ namespace Ryujinx.HLE.HOS.Services.Sm
return ResultCode.Success;
}
[CommandHipc(1)]
[CommandTipc(1)] // 12.0.0+
// GetService(ServiceName name) -> handle<move, session>
public ResultCode GetServiceTipc(ServiceCtx context)
{
context.Response.HandleDesc = IpcHandleDesc.MakeMove(0);
return GetService(context);
}
[CommandHipc(1)]
public ResultCode GetService(ServiceCtx context)
{
if (!_isInitialized)
@ -142,6 +150,8 @@ namespace Ryujinx.HLE.HOS.Services.Sm
{
if (!_isInitialized)
{
context.Response.HandleDesc = IpcHandleDesc.MakeMove(0);
return ResultCode.NotInitialized;
}