diff options
| author | Ac_K <Acoustik666@gmail.com> | 2019-07-12 03:13:43 +0200 |
|---|---|---|
| committer | gdkchan <gab.dark.100@gmail.com> | 2019-07-11 22:13:43 -0300 |
| commit | 560ccbeb2d55a4426ad2827bf7534d4a695431c2 (patch) | |
| tree | 7e224acbd6c023ea56ff80c6207aa0966aa06ee5 /Ryujinx.HLE/HOS/Services/Vi | |
| parent | f723f6f39aaf7b1cebc0224a055058d62e3b689c (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/Vi')
7 files changed, 101 insertions, 122 deletions
diff --git a/Ryujinx.HLE/HOS/Services/Vi/IApplicationDisplayService.cs b/Ryujinx.HLE/HOS/Services/Vi/IApplicationDisplayService.cs index be9fc263..948309fe 100644 --- a/Ryujinx.HLE/HOS/Services/Vi/IApplicationDisplayService.cs +++ b/Ryujinx.HLE/HOS/Services/Vi/IApplicationDisplayService.cs @@ -1,7 +1,6 @@ using ChocolArm64.Memory; using Ryujinx.HLE.HOS.Ipc; using Ryujinx.HLE.HOS.Kernel.Common; -using System.Collections.Generic; using System; using System.IO; using System.Text; @@ -13,45 +12,26 @@ namespace Ryujinx.HLE.HOS.Services.Vi { class IApplicationDisplayService : IpcService { - private Dictionary<int, ServiceProcessRequest> _commands; - - public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => _commands; - private IdDictionary _displays; public IApplicationDisplayService() { - _commands = new Dictionary<int, ServiceProcessRequest> - { - { 100, GetRelayService }, - { 101, GetSystemDisplayService }, - { 102, GetManagerDisplayService }, - { 103, GetIndirectDisplayTransactionService }, - { 1000, ListDisplays }, - { 1010, OpenDisplay }, - { 1020, CloseDisplay }, - { 1102, GetDisplayResolution }, - { 2020, OpenLayer }, - { 2021, CloseLayer }, - { 2030, CreateStrayLayer }, - { 2031, DestroyStrayLayer }, - { 2101, SetLayerScalingMode }, - { 2102, ConvertScalingMode }, - { 5202, GetDisplayVSyncEvent } - }; - _displays = new IdDictionary(); } + [Command(100)] + // GetRelayService() -> object<nns::hosbinder::IHOSBinderDriver> public long GetRelayService(ServiceCtx context) { - MakeObject(context, new IhosBinderDriver( + MakeObject(context, new IHOSBinderDriver( context.Device.System, context.Device.Gpu.Renderer)); return 0; } + [Command(101)] + // GetSystemDisplayService() -> object<nn::visrv::sf::ISystemDisplayService> public long GetSystemDisplayService(ServiceCtx context) { MakeObject(context, new ISystemDisplayService(this)); @@ -59,6 +39,8 @@ namespace Ryujinx.HLE.HOS.Services.Vi return 0; } + [Command(102)] + // GetManagerDisplayService() -> object<nn::visrv::sf::IManagerDisplayService> public long GetManagerDisplayService(ServiceCtx context) { MakeObject(context, new IManagerDisplayService(this)); @@ -66,15 +48,19 @@ namespace Ryujinx.HLE.HOS.Services.Vi return 0; } + [Command(103)] // 2.0.0+ + // GetIndirectDisplayTransactionService() -> object<nns::hosbinder::IHOSBinderDriver> public long GetIndirectDisplayTransactionService(ServiceCtx context) { - MakeObject(context, new IhosBinderDriver( + MakeObject(context, new IHOSBinderDriver( context.Device.System, context.Device.Gpu.Renderer)); return 0; } + [Command(1000)] + // ListDisplays() -> (u64, buffer<nn::vi::DisplayInfo, 6>) public long ListDisplays(ServiceCtx context) { long recBuffPtr = context.Request.ReceiveBuff[0].Position; @@ -93,6 +79,8 @@ namespace Ryujinx.HLE.HOS.Services.Vi return 0; } + [Command(1010)] + // OpenDisplay(nn::vi::DisplayName) -> u64 public long OpenDisplay(ServiceCtx context) { string name = GetDisplayName(context); @@ -104,6 +92,8 @@ namespace Ryujinx.HLE.HOS.Services.Vi return 0; } + [Command(1020)] + // CloseDisplay(u64) public long CloseDisplay(ServiceCtx context) { int displayId = context.RequestData.ReadInt32(); @@ -113,6 +103,8 @@ namespace Ryujinx.HLE.HOS.Services.Vi return 0; } + [Command(1102)] + // GetDisplayResolution(u64) -> (u64, u64) public long GetDisplayResolution(ServiceCtx context) { long displayId = context.RequestData.ReadInt32(); @@ -123,6 +115,8 @@ namespace Ryujinx.HLE.HOS.Services.Vi return 0; } + [Command(2020)] + // OpenLayer(nn::vi::DisplayName, u64, nn::applet::AppletResourceUserId, pid) -> (u64, buffer<bytes, 6>) public long OpenLayer(ServiceCtx context) { long layerId = context.RequestData.ReadInt64(); @@ -139,6 +133,8 @@ namespace Ryujinx.HLE.HOS.Services.Vi return 0; } + [Command(2021)] + // CloseLayer(u64) public long CloseLayer(ServiceCtx context) { long layerId = context.RequestData.ReadInt64(); @@ -146,6 +142,8 @@ namespace Ryujinx.HLE.HOS.Services.Vi return 0; } + [Command(2030)] + // CreateStrayLayer(u32, u64) -> (u64, u64, buffer<bytes, 6>) public long CreateStrayLayer(ServiceCtx context) { long layerFlags = context.RequestData.ReadInt64(); @@ -165,11 +163,15 @@ namespace Ryujinx.HLE.HOS.Services.Vi return 0; } + [Command(2031)] + // DestroyStrayLayer(u64) public long DestroyStrayLayer(ServiceCtx context) { return 0; } + [Command(2101)] + // SetLayerScalingMode(u32, u64) public long SetLayerScalingMode(ServiceCtx context) { int scalingMode = context.RequestData.ReadInt32(); @@ -178,6 +180,8 @@ namespace Ryujinx.HLE.HOS.Services.Vi return 0; } + [Command(2102)] // 5.0.0+ + // ConvertScalingMode(unknown) -> unknown public long ConvertScalingMode(ServiceCtx context) { SrcScalingMode scalingMode = (SrcScalingMode)context.RequestData.ReadInt32(); @@ -216,6 +220,8 @@ namespace Ryujinx.HLE.HOS.Services.Vi return null; } + [Command(5202)] + // GetDisplayVsyncEvent(u64) -> handle<copy> public long GetDisplayVSyncEvent(ServiceCtx context) { string name = GetDisplayName(context); diff --git a/Ryujinx.HLE/HOS/Services/Vi/IApplicationRootService.cs b/Ryujinx.HLE/HOS/Services/Vi/IApplicationRootService.cs index 27ffcc93..a614d877 100644 --- a/Ryujinx.HLE/HOS/Services/Vi/IApplicationRootService.cs +++ b/Ryujinx.HLE/HOS/Services/Vi/IApplicationRootService.cs @@ -1,23 +1,12 @@ -using Ryujinx.HLE.HOS.Ipc; -using System.Collections.Generic; - namespace Ryujinx.HLE.HOS.Services.Vi { [Service("vi:u")] class IApplicationRootService : IpcService { - private Dictionary<int, ServiceProcessRequest> _commands; - - public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => _commands; - - public IApplicationRootService(ServiceCtx context) - { - _commands = new Dictionary<int, ServiceProcessRequest> - { - { 0, GetDisplayService } - }; - } + public IApplicationRootService(ServiceCtx context) { } + [Command(0)] + // GetDisplayService(u32) -> object<nn::visrv::sf::IApplicationDisplayService> public long GetDisplayService(ServiceCtx context) { int serviceType = context.RequestData.ReadInt32(); diff --git a/Ryujinx.HLE/HOS/Services/Vi/IHOSBinderDriver.cs b/Ryujinx.HLE/HOS/Services/Vi/IHOSBinderDriver.cs index adcedf4e..5583326f 100644 --- a/Ryujinx.HLE/HOS/Services/Vi/IHOSBinderDriver.cs +++ b/Ryujinx.HLE/HOS/Services/Vi/IHOSBinderDriver.cs @@ -4,30 +4,17 @@ using Ryujinx.HLE.HOS.Kernel.Common; using Ryujinx.HLE.HOS.Kernel.Threading; using Ryujinx.HLE.HOS.Services.Android; using System; -using System.Collections.Generic; namespace Ryujinx.HLE.HOS.Services.Vi { - class IhosBinderDriver : IpcService, IDisposable + class IHOSBinderDriver : IpcService, IDisposable { - private Dictionary<int, ServiceProcessRequest> _commands; - - public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => _commands; - private KEvent _binderEvent; private NvFlinger _flinger; - public IhosBinderDriver(Horizon system, IGalRenderer renderer) + public IHOSBinderDriver(Horizon system, IGalRenderer renderer) { - _commands = new Dictionary<int, ServiceProcessRequest> - { - { 0, TransactParcel }, - { 1, AdjustRefcount }, - { 2, GetNativeHandle }, - { 3, TransactParcelAuto } - }; - _binderEvent = new KEvent(system); _binderEvent.ReadableEvent.Signal(); @@ -35,6 +22,8 @@ namespace Ryujinx.HLE.HOS.Services.Vi _flinger = new NvFlinger(renderer, _binderEvent); } + [Command(0)] + // TransactParcel(s32, u32, u32, buffer<unknown, 5, 0>) -> buffer<unknown, 6, 0> public long TransactParcel(ServiceCtx context) { int id = context.RequestData.ReadInt32(); @@ -50,20 +39,8 @@ namespace Ryujinx.HLE.HOS.Services.Vi return _flinger.ProcessParcelRequest(context, data, code); } - public long TransactParcelAuto(ServiceCtx context) - { - int id = context.RequestData.ReadInt32(); - int code = context.RequestData.ReadInt32(); - - (long dataPos, long dataSize) = context.Request.GetBufferType0x21(); - - byte[] data = context.Memory.ReadBytes(dataPos, dataSize); - - data = Parcel.GetParcelData(data); - - return _flinger.ProcessParcelRequest(context, data, code); - } - + [Command(1)] + // AdjustRefcount(s32, s32, s32) public long AdjustRefcount(ServiceCtx context) { int id = context.RequestData.ReadInt32(); @@ -73,6 +50,8 @@ namespace Ryujinx.HLE.HOS.Services.Vi return 0; } + [Command(2)] + // GetNativeHandle(s32, s32) -> handle<copy> public long GetNativeHandle(ServiceCtx context) { int id = context.RequestData.ReadInt32(); @@ -88,6 +67,22 @@ namespace Ryujinx.HLE.HOS.Services.Vi return 0; } + [Command(3)] // 3.0.0+ + // TransactParcelAuto(s32, u32, u32, buffer<unknown, 21, 0>) -> buffer<unknown, 22, 0> + public long TransactParcelAuto(ServiceCtx context) + { + int id = context.RequestData.ReadInt32(); + int code = context.RequestData.ReadInt32(); + + (long dataPos, long dataSize) = context.Request.GetBufferType0x21(); + + byte[] data = context.Memory.ReadBytes(dataPos, dataSize); + + data = Parcel.GetParcelData(data); + + return _flinger.ProcessParcelRequest(context, data, code); + } + public void Dispose() { Dispose(true); diff --git a/Ryujinx.HLE/HOS/Services/Vi/IManagerDisplayService.cs b/Ryujinx.HLE/HOS/Services/Vi/IManagerDisplayService.cs index d717b78a..ac6d49bd 100644 --- a/Ryujinx.HLE/HOS/Services/Vi/IManagerDisplayService.cs +++ b/Ryujinx.HLE/HOS/Services/Vi/IManagerDisplayService.cs @@ -1,27 +1,18 @@ using Ryujinx.Common.Logging; -using Ryujinx.HLE.HOS.Ipc; -using System.Collections.Generic; namespace Ryujinx.HLE.HOS.Services.Vi { class IManagerDisplayService : IpcService { - private Dictionary<int, ServiceProcessRequest> _commands; - - public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => _commands; + private static IApplicationDisplayService _applicationDisplayService; public IManagerDisplayService(IApplicationDisplayService applicationDisplayService) { - _commands = new Dictionary<int, ServiceProcessRequest> - { - { 2010, CreateManagedLayer }, - { 2011, DestroyManagedLayer }, - { 2012, applicationDisplayService.CreateStrayLayer }, - { 6000, AddToLayerStack }, - { 6002, SetLayerVisibility } - }; + _applicationDisplayService = applicationDisplayService; } + [Command(2010)] + // CreateManagedLayer(u32, u64, nn::applet::AppletResourceUserId) -> u64 public static long CreateManagedLayer(ServiceCtx context) { Logger.PrintStub(LogClass.ServiceVi); @@ -31,6 +22,8 @@ namespace Ryujinx.HLE.HOS.Services.Vi return 0; } + [Command(2011)] + // DestroyManagedLayer(u64) public long DestroyManagedLayer(ServiceCtx context) { Logger.PrintStub(LogClass.ServiceVi); @@ -38,6 +31,17 @@ namespace Ryujinx.HLE.HOS.Services.Vi return 0; } + [Command(2012)] // 7.0.0+ + // CreateStrayLayer(u32, u64) -> (u64, u64, buffer<bytes, 6>) + public static long CreateStrayLayer(ServiceCtx context) + { + Logger.PrintStub(LogClass.ServiceVi); + + return _applicationDisplayService.CreateStrayLayer(context); + } + + [Command(6000)] + // AddToLayerStack(u32, u64) public static long AddToLayerStack(ServiceCtx context) { Logger.PrintStub(LogClass.ServiceVi); @@ -45,6 +49,8 @@ namespace Ryujinx.HLE.HOS.Services.Vi return 0; } + [Command(6002)] + // SetLayerVisibility(b8, u64) public static long SetLayerVisibility(ServiceCtx context) { Logger.PrintStub(LogClass.ServiceVi); diff --git a/Ryujinx.HLE/HOS/Services/Vi/IManagerRootService.cs b/Ryujinx.HLE/HOS/Services/Vi/IManagerRootService.cs index 59f76e93..991f01c3 100644 --- a/Ryujinx.HLE/HOS/Services/Vi/IManagerRootService.cs +++ b/Ryujinx.HLE/HOS/Services/Vi/IManagerRootService.cs @@ -1,23 +1,12 @@ -using Ryujinx.HLE.HOS.Ipc; -using System.Collections.Generic; - namespace Ryujinx.HLE.HOS.Services.Vi { [Service("vi:m")] class IManagerRootService : IpcService { - private Dictionary<int, ServiceProcessRequest> _commands; - - public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => _commands; - - public IManagerRootService(ServiceCtx context) - { - _commands = new Dictionary<int, ServiceProcessRequest> - { - { 2, GetDisplayService } - }; - } + public IManagerRootService(ServiceCtx context) { } + [Command(2)] + // GetDisplayService(u32) -> object<nn::visrv::sf::IApplicationDisplayService> public long GetDisplayService(ServiceCtx context) { int serviceType = context.RequestData.ReadInt32(); diff --git a/Ryujinx.HLE/HOS/Services/Vi/ISystemDisplayService.cs b/Ryujinx.HLE/HOS/Services/Vi/ISystemDisplayService.cs index 076618d7..28702d6f 100644 --- a/Ryujinx.HLE/HOS/Services/Vi/ISystemDisplayService.cs +++ b/Ryujinx.HLE/HOS/Services/Vi/ISystemDisplayService.cs @@ -1,26 +1,18 @@ using Ryujinx.Common.Logging; -using Ryujinx.HLE.HOS.Ipc; -using System.Collections.Generic; namespace Ryujinx.HLE.HOS.Services.Vi { class ISystemDisplayService : IpcService { - private Dictionary<int, ServiceProcessRequest> _commands; - - public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => _commands; + private static IApplicationDisplayService _applicationDisplayService; public ISystemDisplayService(IApplicationDisplayService applicationDisplayService) { - _commands = new Dictionary<int, ServiceProcessRequest> - { - { 2205, SetLayerZ }, - { 2207, SetLayerVisibility }, - { 2312, applicationDisplayService.CreateStrayLayer }, - { 3200, GetDisplayMode } - }; + _applicationDisplayService = applicationDisplayService; } + [Command(2205)] + // SetLayerZ(u64, u64) public static long SetLayerZ(ServiceCtx context) { Logger.PrintStub(LogClass.ServiceVi); @@ -28,6 +20,8 @@ namespace Ryujinx.HLE.HOS.Services.Vi return 0; } + [Command(2207)] + // SetLayerVisibility(b8, u64) public static long SetLayerVisibility(ServiceCtx context) { Logger.PrintStub(LogClass.ServiceVi); @@ -35,6 +29,17 @@ namespace Ryujinx.HLE.HOS.Services.Vi return 0; } + [Command(2312)] // 1.0.0-6.2.0 + // CreateStrayLayer(u32, u64) -> (u64, u64, buffer<bytes, 6>) + public static long CreateStrayLayer(ServiceCtx context) + { + Logger.PrintStub(LogClass.ServiceVi); + + return _applicationDisplayService.CreateStrayLayer(context); + } + + [Command(3200)] + // GetDisplayMode(u64) -> nn::vi::DisplayModeInfo public static long GetDisplayMode(ServiceCtx context) { // TODO: De-hardcode resolution. diff --git a/Ryujinx.HLE/HOS/Services/Vi/ISystemRootService.cs b/Ryujinx.HLE/HOS/Services/Vi/ISystemRootService.cs index 6a8aed07..9d7ae3fd 100644 --- a/Ryujinx.HLE/HOS/Services/Vi/ISystemRootService.cs +++ b/Ryujinx.HLE/HOS/Services/Vi/ISystemRootService.cs @@ -1,23 +1,12 @@ -using Ryujinx.HLE.HOS.Ipc; -using System.Collections.Generic; - namespace Ryujinx.HLE.HOS.Services.Vi { [Service("vi:s")] class ISystemRootService : IpcService { - private Dictionary<int, ServiceProcessRequest> _commands; - - public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => _commands; - - public ISystemRootService(ServiceCtx context) - { - _commands = new Dictionary<int, ServiceProcessRequest> - { - { 1, GetDisplayService } - }; - } + public ISystemRootService(ServiceCtx context) { } + [Command(1)] + // GetDisplayService(u32) -> object<nn::visrv::sf::IApplicationDisplayService> public long GetDisplayService(ServiceCtx context) { int serviceType = context.RequestData.ReadInt32(); |
