aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.HLE/HOS/Services/IpcService.cs
diff options
context:
space:
mode:
authorAc_K <Acoustik666@gmail.com>2019-07-12 03:13:43 +0200
committergdkchan <gab.dark.100@gmail.com>2019-07-11 22:13:43 -0300
commit560ccbeb2d55a4426ad2827bf7534d4a695431c2 (patch)
tree7e224acbd6c023ea56ff80c6207aa0966aa06ee5 /Ryujinx.HLE/HOS/Services/IpcService.cs
parentf723f6f39aaf7b1cebc0224a055058d62e3b689c (diff)
Refactoring commands handling (#728)
* Refactoring commands handling - Use Reflection to handle commands ID. - Add all symbols (from SwIPC so not all time accurate). - Re-sort some services commands methods. - Some cleanup. - Keep some empty constructor for consistency. * Fix order in IProfile
Diffstat (limited to 'Ryujinx.HLE/HOS/Services/IpcService.cs')
-rw-r--r--Ryujinx.HLE/HOS/Services/IpcService.cs25
1 files changed, 19 insertions, 6 deletions
diff --git a/Ryujinx.HLE/HOS/Services/IpcService.cs b/Ryujinx.HLE/HOS/Services/IpcService.cs
index b93c8422..5fec1d3e 100644
--- a/Ryujinx.HLE/HOS/Services/IpcService.cs
+++ b/Ryujinx.HLE/HOS/Services/IpcService.cs
@@ -7,12 +7,14 @@ using System;
using System.Collections.Generic;
using System.IO;
using Ryujinx.Profiler;
+using System.Reflection;
+using System.Linq;
namespace Ryujinx.HLE.HOS.Services
{
abstract class IpcService : IIpcService
{
- public abstract IReadOnlyDictionary<int, ServiceProcessRequest> Commands { get; }
+ public IReadOnlyDictionary<int, MethodInfo> Commands { get; }
private IdDictionary _domainObjects;
@@ -22,6 +24,13 @@ namespace Ryujinx.HLE.HOS.Services
public IpcService()
{
+ Commands = Assembly.GetExecutingAssembly().GetTypes()
+ .Where(type => type == GetType())
+ .SelectMany(type => type.GetMethods(BindingFlags.Static | BindingFlags.Instance | BindingFlags.Public))
+ .SelectMany(methodInfo => methodInfo.GetCustomAttributes(typeof(CommandAttribute))
+ .Select(command => (((CommandAttribute)command).Id, methodInfo)))
+ .ToDictionary(command => command.Id, command => command.methodInfo);
+
_domainObjects = new IdDictionary();
_selfId = -1;
@@ -90,7 +99,7 @@ namespace Ryujinx.HLE.HOS.Services
long sfciMagic = context.RequestData.ReadInt64();
int commandId = (int)context.RequestData.ReadInt64();
- bool serviceExists = service.Commands.TryGetValue(commandId, out ServiceProcessRequest processRequest);
+ bool serviceExists = service.Commands.TryGetValue(commandId, out MethodInfo processRequest);
if (ServiceConfiguration.IgnoreMissingServices || serviceExists)
{
@@ -100,19 +109,23 @@ namespace Ryujinx.HLE.HOS.Services
if (serviceExists)
{
- Logger.PrintDebug(LogClass.KernelIpc, $"{service.GetType().Name}: {processRequest.Method.Name}");
+ Logger.PrintDebug(LogClass.KernelIpc, $"{service.GetType().Name}: {processRequest.Name}");
ProfileConfig profile = Profiles.ServiceCall;
- profile.SessionGroup = service.GetType().Name;
- profile.SessionItem = processRequest.Method.Name;
+
+ profile.SessionGroup = service.GetType().Name;
+ profile.SessionItem = processRequest.Name;
Profile.Begin(profile);
- result = processRequest(context);
+
+ result = (long)processRequest.Invoke(service, new object[] { context });
+
Profile.End(profile);
}
else
{
string serviceName;
+
DummyService dummyService = service as DummyService;
serviceName = (dummyService == null) ? service.GetType().FullName : dummyService.ServiceName;